diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2022-04-13 21:17:29 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2022-04-13 21:17:29 (GMT) |
commit | cabc39c3e197e2591449d2604bfee26465fb60e1 (patch) | |
tree | d5f39f5f5965584bf9bf49646a2af617adfd3e4e /tools/test | |
parent | 7355f4c505092a7a85474b47f18d5206028e2c95 (diff) | |
parent | ab69f5df770ee3cc6cd6c81d905a5317b894a002 (diff) | |
download | hdf5-feature/coding_standards.zip hdf5-feature/coding_standards.tar.gz hdf5-feature/coding_standards.tar.bz2 |
Merge branch 'develop' into feature/coding_standardsfeature/coding_standards
Diffstat (limited to 'tools/test')
230 files changed, 19241 insertions, 22995 deletions
diff --git a/tools/test/CMakeLists.txt b/tools/test/CMakeLists.txt index f4106fc..a43a848 100644 --- a/tools/test/CMakeLists.txt +++ b/tools/test/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_TOOLS_TEST C) #-- Add the h5diff tests diff --git a/tools/test/Makefile.am b/tools/test/Makefile.am index 19bb047..1e4e09b 100644 --- a/tools/test/Makefile.am +++ b/tools/test/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. ## diff --git a/tools/test/h5copy/CMakeLists.txt b/tools/test/h5copy/CMakeLists.txt index 1130ea7..f63eb84 100644 --- a/tools/test/h5copy/CMakeLists.txt +++ b/tools/test/h5copy/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_TOOLS_TEST_H5COPY C) # -------------------------------------------------------------------- @@ -6,11 +6,18 @@ project (HDF5_TOOLS_TEST_H5COPY C) # -------------------------------------------------------------------- if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) add_executable (h5copygentest ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/h5copygentest.c) - target_include_directories (h5copygentest PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (h5copygentest PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h5copygentest STATIC) target_link_libraries (h5copygentest PRIVATE ${HDF5_LIB_TARGET}) set_target_properties (h5copygentest PROPERTIES FOLDER generator/tools) + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5COPY_FORMAT h5copygentest) + endif () + #add_test (NAME h5copygentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copygentest>) endif () @@ -23,13 +30,21 @@ if (BUILD_SHARED_LIBS) set (H5COPY_TOOL_PLUGIN_LIB_TARGET ${H5COPY_TOOL_PLUGIN_LIB_CORENAME}) add_library (${H5COPY_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_copy.c) - target_include_directories (${H5COPY_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (${H5COPY_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (${H5COPY_TOOL_PLUGIN_LIB_TARGET} SHARED) - target_link_libraries (${H5COPY_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIBSH_TARGET}) + target_link_libraries (${H5COPY_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_LIBSH_TARGET}) H5_SET_LIB_OPTIONS (${H5COPY_TOOL_PLUGIN_LIB_TARGET} ${H5COPY_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5COPY_PLUGIN_FORMAT ${H5COPY_TOOL_PLUGIN_LIB_TARGET}) + endif () + # make plugins dir file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") + #----------------------------------------------------------------------------- # Copy plugin library to a plugins folder #----------------------------------------------------------------------------- @@ -43,4 +58,6 @@ if (BUILD_SHARED_LIBS) ) endif () -include (CMakeTests.cmake) +if (HDF5_TEST_TOOLS AND HDF5_TEST_SERIAL) + include (CMakeTests.cmake) +endif () diff --git a/tools/test/h5copy/CMakeTests.cmake b/tools/test/h5copy/CMakeTests.cmake index b0d1615..154ca15 100644 --- a/tools/test/h5copy/CMakeTests.cmake +++ b/tools/test/h5copy/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. # @@ -45,12 +45,6 @@ endforeach () add_custom_target(h5copy_files ALL COMMENT "Copying files needed by h5copy tests" DEPENDS ${h5copy_files_list}) - if (NOT BUILD_SHARED_LIBS) - set (tgt_ext "") - else () - set (tgt_ext "-shared") - endif () - ############################################################################## ############################################################################## ### T H E T E S T S M A C R O S ### @@ -71,7 +65,7 @@ add_test ( NAME H5COPY_F-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copy${tgt_ext}> -f ${fparam} -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copy${tgt_file_ext}> -f ${fparam} -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN} ) if (HDF5_ENABLE_USING_MEMCHECKER) if (last_test) @@ -82,13 +76,13 @@ endif () # resultcode=2 will cause the test to skip the diff test - if (NOT ${resultcode} EQUAL 2) + if (NOT "${resultcode}" STREQUAL "2") add_test ( NAME H5COPY_F-${testname}-DIFF - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_ext}> -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_file_ext}> -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) set_tests_properties (H5COPY_F-${testname}-DIFF PROPERTIES DEPENDS H5COPY_F-${testname}) - if (${resultcode} EQUAL 1) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5COPY_F-${testname}-DIFF PROPERTIES WILL_FAIL "true") endif () endif () @@ -105,7 +99,7 @@ add_test ( NAME H5COPY-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copy${tgt_ext}> -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copy${tgt_file_ext}> -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN} ) if (HDF5_ENABLE_USING_MEMCHECKER) if (last_test) @@ -116,13 +110,13 @@ endif () # resultcode=2 will cause the test to skip the diff test - if (NOT ${resultcode} EQUAL 2) + if (NOT "${resultcode}" STREQUAL "2") add_test ( NAME H5COPY-${testname}-DIFF - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_ext}> -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_file_ext}> -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) set_tests_properties (H5COPY-${testname}-DIFF PROPERTIES DEPENDS H5COPY-${testname}) - if (${resultcode} EQUAL 1) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5COPY-${testname}-DIFF PROPERTIES WILL_FAIL "true") endif () endif () @@ -149,7 +143,7 @@ add_test ( NAME H5COPY-${testname}-prefill - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copy${tgt_ext}> -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 -v -s ${psparam} -d ${pdparam} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copy${tgt_file_ext}> -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 -v -s ${psparam} -d ${pdparam} ) if (HDF5_ENABLE_USING_MEMCHECKER) if (last_test) @@ -161,17 +155,17 @@ add_test ( NAME H5COPY-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copy${tgt_ext}> -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copy${tgt_file_ext}> -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN} ) set_tests_properties (H5COPY-${testname} PROPERTIES DEPENDS H5COPY-${testname}-prefill) # resultcode=2 will cause the test to skip the diff test - if (NOT ${resultcode} EQUAL 2) + if (NOT "${resultcode}" STREQUAL "2") add_test ( NAME H5COPY-${testname}-DIFF - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_ext}> -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_file_ext}> -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) set_tests_properties (H5COPY-${testname}-DIFF PROPERTIES DEPENDS H5COPY-${testname}) - if (${resultcode} EQUAL 1) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5COPY-${testname}-DIFF PROPERTIES WILL_FAIL "true") endif () endif () @@ -188,7 +182,7 @@ add_test ( NAME H5COPY_SAME-${testname}-prefill - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copy${tgt_ext}> -i ./testfiles/${pfile} -o ./testfiles/${testname}.out.h5 -v -s ${psparam} -d ${pdparam} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copy${tgt_file_ext}> -i ./testfiles/${pfile} -o ./testfiles/${testname}.out.h5 -v -s ${psparam} -d ${pdparam} ) if (HDF5_ENABLE_USING_MEMCHECKER) if (last_test) @@ -200,31 +194,31 @@ add_test ( NAME H5COPY_SAME-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copy${tgt_ext}> -i ./testfiles/${testname}.out.h5 -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copy${tgt_file_ext}> -i ./testfiles/${testname}.out.h5 -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN} ) set_tests_properties (H5COPY_SAME-${testname} PROPERTIES DEPENDS H5COPY_SAME-${testname}-prefill) # resultcode=2 will cause the test to skip the diff test - if (NOT ${resultcode} EQUAL 2) + if (NOT "${resultcode}" STREQUAL "2") add_test ( NAME H5COPY_SAME-${testname}-DIFF - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_ext}> -v ./testfiles/${testname}.out.h5 ./testfiles/${testname}.out.h5 ${srcname} ${dstname} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_file_ext}> -v ./testfiles/${testname}.out.h5 ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) set_tests_properties (H5COPY_SAME-${testname}-DIFF PROPERTIES DEPENDS H5COPY_SAME-${testname}) - if (${resultcode} EQUAL 1) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5COPY_SAME-${testname}-DIFF PROPERTIES WILL_FAIL "true") endif () endif () endmacro () # - # Similiar to ADD_H5_TEST macro. Compare to outputs from source & target + # Similar to ADD_H5_TEST macro. Compare to outputs from source & target # files instead of checking with h5ls. # macro (ADD_H5_CMP_TEST testname resultcode infile vparam sparam srcname dparam dstname) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5COPY-CMP-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copy${tgt_ext}> -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN}) - if (${resultcode} EQUAL 1) + add_test (NAME H5COPY-CMP-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copy${tgt_file_ext}> -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN}) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5COPY-CMP-${testname} PROPERTIES WILL_FAIL "true") endif () if (last_test) @@ -240,7 +234,7 @@ NAME H5COPY-CMP-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5copy${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5copy${tgt_file_ext}>" -D "TEST_ARGS=-i;./testfiles/${infile};-o;./testfiles/${testname}.out.h5;${vparam};${sparam};${srcname};${dparam};${dstname}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=./testfiles/${testname}.out.out" @@ -261,7 +255,7 @@ NAME H5COPY_UD-${testname}-clear-objects COMMAND ${CMAKE_COMMAND} -E remove testfiles/${testname}.out.h5 ) - if (${resultcode} EQUAL 2) + if ("${resultcode}" STREQUAL "2") add_test ( NAME H5COPY_UD-${testname} COMMAND "${CMAKE_COMMAND}" @@ -324,7 +318,7 @@ NAME H5COPY_UD_ERR-${testname}-clearall-objects COMMAND ${CMAKE_COMMAND} -E remove testfiles/${testname}_ERR.out.h5 ) - if (${resultcode} EQUAL 2) + if ("${resultcode}" STREQUAL "2") add_test ( NAME H5COPY_UD_ERR-${testname} COMMAND "${CMAKE_COMMAND}" diff --git a/tools/test/h5copy/Makefile.am b/tools/test/h5copy/Makefile.am index 5fda4a0..804fc56 100644 --- a/tools/test/h5copy/Makefile.am +++ b/tools/test/h5copy/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. ## diff --git a/tools/test/h5copy/dynlib_copy.c b/tools/test/h5copy/dynlib_copy.c index 571452e..b954a22 100644 --- a/tools/test/h5copy/dynlib_copy.c +++ b/tools/test/h5copy/dynlib_copy.c @@ -5,7 +5,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,25 +17,33 @@ #include <stdio.h> #include "H5PLextern.h" -#define H5Z_FILTER_DYNLIBUD 300 -#define MULTIPLIER 3 +#define H5Z_FILTER_DYNLIBUD 300 +#define MULTIPLIER 3 -static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_DYNLIBUD[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_DYNLIBUD, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "dynlibud", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_DYNLIBUD, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "dynlibud", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + H5Z_filter_dynlibud, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_FILTER; +} +const void * +H5PLget_plugin_info(void) +{ + return H5Z_DYNLIBUD; +} /*------------------------------------------------------------------------- * Function: H5Z_filter_dynlibud @@ -51,39 +59,37 @@ const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} *------------------------------------------------------------------------- */ static size_t -H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) { - char *int_ptr = (char *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + char * int_ptr = (char *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ /* Check for the correct number of parameters */ - if(cd_nelmts > 0) - return(0); + if (cd_nelmts > 0) + return (0); /* Assignment to eliminate unused parameter warning. */ - cd_values = cd_values; + (void)cd_values; - if(flags & H5Z_FLAG_REVERSE) { /*read*/ + if (flags & H5Z_FLAG_REVERSE) { /*read*/ /* Subtract the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = temp - MULTIPLIER; + *int_ptr = temp - MULTIPLIER; int_ptr++; buf_left -= sizeof(*int_ptr); - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ else { /*write*/ /* Add the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = temp + MULTIPLIER; + *int_ptr = temp + MULTIPLIER; int_ptr++; buf_left -= sizeof(*int_ptr); } /* end while */ - } /* end else */ + } /* end else */ return nbytes; } /* end H5Z_filter_dynlibud() */ - diff --git a/tools/test/h5copy/h5copygentest.c b/tools/test/h5copy/h5copygentest.c index f6aa72f..e415c97 100644 --- a/tools/test/h5copy/h5copygentest.c +++ b/tools/test/h5copy/h5copygentest.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,35 +18,34 @@ #include "H5private.h" /* HDF file names */ -#define HDF_FILE1 "h5copytst.h5" -#define HDF_FILE1_NEW "h5copytst_new.h5" -#define HDF_FILE2 "h5copy_ref.h5" -#define HDF_EXT_SRC_FILE "h5copy_extlinks_src.h5" -#define HDF_EXT_TRG_FILE "h5copy_extlinks_trg.h5" +#define HDF_FILE1 "h5copytst.h5" +#define HDF_FILE1_NEW "h5copytst_new.h5" +#define HDF_FILE2 "h5copy_ref.h5" +#define HDF_EXT_SRC_FILE "h5copy_extlinks_src.h5" +#define HDF_EXT_TRG_FILE "h5copy_extlinks_trg.h5" /* objects in HDF_FILE1 */ -#define DATASET_SIMPLE "simple" -#define DATASET_CHUNK "chunk" -#define DATASET_COMPACT "compact" -#define DATASET_COMPOUND "compound" -#define DATASET_COMPRESSED "compressed" -#define DATASET_NAMED_VL "named_vl" -#define DATASET_NESTED_VL "nested_vl" -#define DATASET_ATTR "dset_attr" -#define ATTR "attr" -#define GROUP_EMPTY "grp_empty" -#define GROUP_DATASETS "grp_dsets" -#define GROUP_NESTED "grp_nested" -#define GROUP_ATTR "grp_attr" +#define DATASET_SIMPLE "simple" +#define DATASET_CHUNK "chunk" +#define DATASET_COMPACT "compact" +#define DATASET_COMPOUND "compound" +#define DATASET_COMPRESSED "compressed" +#define DATASET_NAMED_VL "named_vl" +#define DATASET_NESTED_VL "nested_vl" +#define DATASET_ATTR "dset_attr" +#define ATTR "attr" +#define GROUP_EMPTY "grp_empty" +#define GROUP_DATASETS "grp_dsets" +#define GROUP_NESTED "grp_nested" +#define GROUP_ATTR "grp_attr" /* Obj reference */ -#define OBJ_REF_DS "Dset1" +#define OBJ_REF_DS "Dset1" #define OBJ_REF_GRP "Group" /* Region reference */ #define REG_REF_DS1 "Dset_REGREF" #define REG_REF_DS2 "Dset2" - /*------------------------------------------------------------------------- * Function: gent_simple * @@ -54,11 +53,12 @@ * *------------------------------------------------------------------------- */ -static void gent_simple(hid_t loc_id) +static void +gent_simple(hid_t loc_id) { hid_t sid, did; hsize_t dims[1] = {6}; - int buf[6] = {1,2,3,4,5,6}; + int buf[6] = {1, 2, 3, 4, 5, 6}; /* create dataspace */ sid = H5Screate_simple(1, dims, NULL); @@ -81,12 +81,13 @@ static void gent_simple(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_chunked(hid_t loc_id) +static void +gent_chunked(hid_t loc_id) { hid_t sid, did, pid; - hsize_t dims[1] = {6}; + hsize_t dims[1] = {6}; hsize_t chunk_dims[1] = {2}; - int buf[6] = {1,2,3,4,5,6}; + int buf[6] = {1, 2, 3, 4, 5, 6}; /* create dataspace */ sid = H5Screate_simple(1, dims, NULL); @@ -107,7 +108,6 @@ static void gent_chunked(hid_t loc_id) H5Pclose(pid); } - /*------------------------------------------------------------------------- * Function: gent_compact * @@ -115,18 +115,19 @@ static void gent_chunked(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_compact(hid_t loc_id) +static void +gent_compact(hid_t loc_id) { hid_t sid, did, pid; hsize_t dims[1] = {6}; - int buf[6] = {1,2,3,4,5,6}; + int buf[6] = {1, 2, 3, 4, 5, 6}; /* create dataspace */ sid = H5Screate_simple(1, dims, NULL); /* create property plist */ pid = H5Pcreate(H5P_DATASET_CREATE); - H5Pset_layout (pid,H5D_COMPACT); + H5Pset_layout(pid, H5D_COMPACT); /* create dataset */ did = H5Dcreate2(loc_id, DATASET_COMPACT, H5T_NATIVE_INT, sid, H5P_DEFAULT, pid, H5P_DEFAULT); @@ -140,7 +141,6 @@ static void gent_compact(hid_t loc_id) H5Pclose(pid); } - /*------------------------------------------------------------------------- * Function: gent_compound * @@ -148,10 +148,10 @@ static void gent_compact(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_compound(hid_t loc_id) +static void +gent_compound(hid_t loc_id) { - typedef struct s_t - { + typedef struct s_t { char str1[20]; char str2[20]; } s_t; @@ -167,8 +167,8 @@ static void gent_compound(hid_t loc_id) tid_s = H5Tcopy(H5T_C_S1); H5Tset_size(tid_s, 20); - H5Tinsert(tid_c, "str1", HOFFSET(s_t,str1), tid_s); - H5Tinsert(tid_c, "str2", HOFFSET(s_t,str2), tid_s); + H5Tinsert(tid_c, "str1", HOFFSET(s_t, str1), tid_s); + H5Tinsert(tid_c, "str2", HOFFSET(s_t, str2), tid_s); /* create dataset */ did = H5Dcreate2(loc_id, DATASET_COMPOUND, tid_c, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -190,12 +190,13 @@ static void gent_compound(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_compressed(hid_t loc_id) +static void +gent_compressed(hid_t loc_id) { hid_t sid, did, pid; - hsize_t dims[1] = {6}; + hsize_t dims[1] = {6}; hsize_t chunk_dims[1] = {2}; - int buf[6] = {1,2,3,4,5,6}; + int buf[6] = {1, 2, 3, 4, 5, 6}; /* create dataspace */ sid = H5Screate_simple(1, dims, NULL); @@ -205,7 +206,7 @@ static void gent_compressed(hid_t loc_id) H5Pset_chunk(pid, 1, chunk_dims); /* set the deflate filter */ -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) H5Pset_deflate(pid, 1); #endif @@ -221,7 +222,6 @@ static void gent_compressed(hid_t loc_id) H5Pclose(pid); } - /*------------------------------------------------------------------------- * Function: gent_named_vl * @@ -230,20 +230,21 @@ static void gent_compressed(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_named_vl(hid_t loc_id) +static void +gent_named_vl(hid_t loc_id) { hid_t sid, did, tid; hsize_t dims[1] = {2}; hvl_t buf[2]; /* allocate and initialize VL dataset to write */ - buf[0].len = 1; - buf[0].p = HDmalloc( 1 * sizeof(int)); - ((int *)buf[0].p)[0]=1; - buf[1].len = 2; - buf[1].p = HDmalloc( 2 * sizeof(int)); - ((int *)buf[1].p)[0]=2; - ((int *)buf[1].p)[1]=3; + buf[0].len = 1; + buf[0].p = HDmalloc(1 * sizeof(int)); + ((int *)buf[0].p)[0] = 1; + buf[1].len = 2; + buf[1].p = HDmalloc(2 * sizeof(int)); + ((int *)buf[1].p)[0] = 2; + ((int *)buf[1].p)[1] = 3; /* create dataspace */ sid = H5Screate_simple(1, dims, NULL); @@ -261,13 +262,12 @@ static void gent_named_vl(hid_t loc_id) H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); /* close */ - H5Dvlen_reclaim(tid,sid,H5P_DEFAULT,buf); + H5Treclaim(tid, sid, H5P_DEFAULT, buf); H5Sclose(sid); H5Dclose(did); H5Tclose(tid); } - /*------------------------------------------------------------------------- * Function: gent_nested_vl * @@ -275,28 +275,29 @@ static void gent_named_vl(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_nested_vl(hid_t loc_id) +static void +gent_nested_vl(hid_t loc_id) { hid_t sid, did, tid1, tid2; hsize_t dims[1] = {2}; hvl_t buf[2]; - hvl_t *tvl; + hvl_t * tvl; /* allocate and initialize VL dataset to write */ - buf[0].len = 1; - buf[0].p = HDmalloc( 1 * sizeof(hvl_t)); - tvl = (hvl_t *)buf[0].p; - tvl->p = HDmalloc( 1 * sizeof(int) ); - tvl->len = 1; - ((int *)tvl->p)[0]=1; - - buf[1].len = 1; - buf[1].p = HDmalloc( 1 * sizeof(hvl_t)); - tvl = (hvl_t *)buf[1].p; - tvl->p = HDmalloc( 2 * sizeof(int) ); - tvl->len = 2; - ((int *)tvl->p)[0]=2; - ((int *)tvl->p)[1]=3; + buf[0].len = 1; + buf[0].p = HDmalloc(1 * sizeof(hvl_t)); + tvl = (hvl_t *)buf[0].p; + tvl->p = HDmalloc(1 * sizeof(int)); + tvl->len = 1; + ((int *)tvl->p)[0] = 1; + + buf[1].len = 1; + buf[1].p = HDmalloc(1 * sizeof(hvl_t)); + tvl = (hvl_t *)buf[1].p; + tvl->p = HDmalloc(2 * sizeof(int)); + tvl->len = 2; + ((int *)tvl->p)[0] = 2; + ((int *)tvl->p)[1] = 3; /* create dataspace */ sid = H5Screate_simple(1, dims, NULL); @@ -314,14 +315,13 @@ static void gent_nested_vl(hid_t loc_id) H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); /* close */ - H5Dvlen_reclaim(tid2,sid,H5P_DEFAULT,buf); + H5Treclaim(tid2, sid, H5P_DEFAULT, buf); H5Sclose(sid); H5Dclose(did); H5Tclose(tid1); H5Tclose(tid2); } - /*------------------------------------------------------------------------- * Function: gent_att_compound_vlstr * @@ -331,22 +331,23 @@ static void gent_nested_vl(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_att_compound_vlstr(hid_t loc_id) +static void +gent_att_compound_vlstr(hid_t loc_id) { typedef struct { /* Compound structure for the attribute */ - int i; + int i; const char *v; } s1; - hsize_t dim[1] = {1}; /* Dimension size */ - hid_t sid = -1; /* Dataspace ID */ - hid_t tid = -1; /* Datatype ID */ - hid_t aid = -1; /* Attribute ID */ - hid_t did = -1; /* Dataset ID */ - hid_t gid = -1; /* Group ID */ - hid_t vl_str_tid = -1; /* Variable length datatype ID */ - hid_t cmpd_tid = -1; /* Compound datatype ID */ - hid_t null_sid = -1; /* Null dataspace ID */ - s1 buf; /* Buffer */ + hsize_t dim[1] = {1}; /* Dimension size */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hid_t tid = H5I_INVALID_HID; /* Datatype ID */ + hid_t aid = H5I_INVALID_HID; /* Attribute ID */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + hid_t gid = H5I_INVALID_HID; /* Group ID */ + hid_t vl_str_tid = H5I_INVALID_HID; /* Variable length datatype ID */ + hid_t cmpd_tid = H5I_INVALID_HID; /* Compound datatype ID */ + hid_t null_sid = H5I_INVALID_HID; /* Null dataspace ID */ + s1 buf; /* Buffer */ buf.i = 9; buf.v = "ThisIsAString"; @@ -409,7 +410,8 @@ static void gent_att_compound_vlstr(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_datasets(hid_t loc_id) +static void +gent_datasets(hid_t loc_id) { gent_simple(loc_id); gent_chunked(loc_id); @@ -427,9 +429,10 @@ static void gent_datasets(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_empty_group(hid_t loc_id) +static void +gent_empty_group(hid_t loc_id) { - hid_t gid; + hid_t gid; /* Create group in location */ gid = H5Gcreate2(loc_id, GROUP_EMPTY, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -446,9 +449,10 @@ static void gent_empty_group(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_nested_datasets(hid_t loc_id) +static void +gent_nested_datasets(hid_t loc_id) { - hid_t gid; + hid_t gid; /* Create group in location */ gid = H5Gcreate2(loc_id, GROUP_DATASETS, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -468,9 +472,10 @@ static void gent_nested_datasets(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_nested_group(hid_t loc_id) +static void +gent_nested_group(hid_t loc_id) { - hid_t gid; + hid_t gid; /* Create group in location */ gid = H5Gcreate2(loc_id, GROUP_NESTED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -482,7 +487,6 @@ static void gent_nested_group(hid_t loc_id) H5Gclose(gid); } - /*------------------------------------------------------------------------- * Function: gen_obj_ref * @@ -490,42 +494,40 @@ static void gent_nested_group(hid_t loc_id) * * Programmer: Jonathan Kim (Feb 23, 2010) *------------------------------------------------------------------------*/ -static herr_t gen_obj_ref(hid_t loc_id) +static herr_t +gen_obj_ref(hid_t loc_id) { - hid_t sid=0, oid=0; - hsize_t dims1[1]={3}; - hsize_t dims2[1]={2}; - int data[3] = {10,20,30}; - int status; + hid_t sid = 0, oid = 0; + hsize_t dims1[1] = {3}; + hsize_t dims2[1] = {2}; + int data[3] = {10, 20, 30}; + int status; /*--------------------- * create obj references to the previously created objects. * Passing -1 as reference is an object.*/ - hobj_ref_t or_data[2]; /* write buffer */ - herr_t ret = SUCCEED; + hobj_ref_t or_data[2]; /* write buffer */ + herr_t ret = SUCCEED; /*-------------- * add dataset */ sid = H5Screate_simple(1, dims1, NULL); - if (sid < 0) - { - HDfprintf(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; } - oid = H5Dcreate2 (loc_id, OBJ_REF_DS, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (oid < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); + oid = H5Dcreate2(loc_id, OBJ_REF_DS, H5T_NATIVE_INT, 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_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - if (status < 0) - { - HDfprintf(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; } @@ -535,64 +537,57 @@ static herr_t gen_obj_ref(hid_t loc_id) /*-------------- * add group */ - oid = H5Gcreate2 (loc_id, OBJ_REF_GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (oid < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", FUNC, __LINE__); + oid = H5Gcreate2(loc_id, OBJ_REF_GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (oid < 0) { + HDfprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", __func__, __LINE__); ret = FAIL; goto out; } H5Gclose(oid); - status = H5Rcreate (&or_data[0], loc_id, OBJ_REF_DS, H5R_OBJECT, (hid_t)-1); - if (status < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + status = H5Rcreate(&or_data[0], loc_id, OBJ_REF_DS, H5R_OBJECT, (hid_t)-1); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", __func__, __LINE__); ret = FAIL; goto out; } - status = H5Rcreate (&or_data[1], loc_id, OBJ_REF_GRP, H5R_OBJECT, (hid_t)-1); - if (status < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + status = H5Rcreate(&or_data[1], loc_id, OBJ_REF_GRP, H5R_OBJECT, (hid_t)-1); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", __func__, __LINE__); ret = FAIL; goto out; } - sid = H5Screate_simple (1, dims2, NULL); - if (sid < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); + sid = H5Screate_simple(1, dims2, 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) - { - HDfprintf(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, or_data); - if (status < 0) - { - HDfprintf(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; } out: - if(oid > 0) + if (oid > 0) H5Dclose(oid); - if(sid > 0) + if (sid > 0) H5Sclose(sid); return ret; } - /*------------------------------------------------------------------------- * Function: gen_region_ref * @@ -600,119 +595,110 @@ out: * * Programmer: Jonathan Kim (Feb 23, 2010) *------------------------------------------------------------------------*/ -static herr_t gen_region_ref(hid_t loc_id) +static herr_t +gen_region_ref(hid_t loc_id) { - hid_t sid=0, oid1=0, oid2=0; - int status; - herr_t ret = SUCCEED; - char data[3][16] = {"The quick brown", "fox jumps over ", "the 5 lazy dogs"}; - hsize_t dims2[2] = {3,16}; - 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}; - - sid = H5Screate_simple (2, dims2, NULL); - if (sid < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); + hid_t sid = 0, oid1 = 0, oid2 = 0; + int status; + herr_t ret = SUCCEED; + char data[3][16] = {"The quick brown", "fox jumps over ", "the 5 lazy dogs"}; + hsize_t dims2[2] = {3, 16}; + 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}; + + sid = H5Screate_simple(2, dims2, NULL); + if (sid < 0) { + HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", __func__, __LINE__); ret = FAIL; goto out; } - /* create normal dataset which is refered */ - oid2 = H5Dcreate2 (loc_id, REG_REF_DS2, H5T_STD_I8LE, sid, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); - if (oid2 < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); + /* create normal dataset which is referred */ + oid2 = H5Dcreate2(loc_id, REG_REF_DS2, H5T_STD_I8LE, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (oid2 < 0) { + HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", __func__, __LINE__); ret = FAIL; goto out; } /* write values to dataset */ - status = H5Dwrite (oid2, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - if (status < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); + status = H5Dwrite(oid2, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", __func__, __LINE__); ret = FAIL; goto out; } /* select elements space for reference */ - status = H5Sselect_elements (sid, H5S_SELECT_SET, 4, coords[0]); - if (status < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); + status = H5Sselect_elements(sid, H5S_SELECT_SET, 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, REG_REF_DS2, H5R_DATASET_REGION, sid); - if (status < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + status = H5Rcreate(&rr_data[0], loc_id, REG_REF_DS2, H5R_DATASET_REGION, sid); + 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, H5S_SELECT_SET, start, stride, count, block); - if (status < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Sselect_hyperslab failed.\n", FUNC, __LINE__); + status = H5Sselect_hyperslab(sid, 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, REG_REF_DS2, H5R_DATASET_REGION, sid); - if (status < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + status = H5Rcreate(&rr_data[1], loc_id, REG_REF_DS2, H5R_DATASET_REGION, sid); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", __func__, __LINE__); ret = FAIL; goto out; } - H5Sclose (sid); + H5Sclose(sid); /* Create dataspace. */ - sid = H5Screate_simple (1, dims1, NULL); - if (sid < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); + sid = H5Screate_simple(1, dims1, NULL); + if (sid < 0) { + HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", __func__, __LINE__); ret = FAIL; goto out; } /* create region reference dataset */ - oid1 = H5Dcreate2 (loc_id, REG_REF_DS1, H5T_STD_REF_DSETREG, sid, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); - if (oid1 < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); + oid1 = H5Dcreate2(loc_id, REG_REF_DS1, H5T_STD_REF_DSETREG, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (oid1 < 0) { + HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", __func__, __LINE__); ret = FAIL; goto out; } /* write data as region references */ - status = H5Dwrite (oid1, 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__); + status = H5Dwrite(oid1, 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; } out: if (oid1 > 0) - H5Dclose (oid1); + H5Dclose(oid1); if (oid2 > 0) - H5Dclose (oid2); + H5Dclose(oid2); if (sid > 0) - H5Sclose (sid); + H5Sclose(sid); return ret; } @@ -723,31 +709,32 @@ out: * Purpose: Testing with various objects * *------------------------------------------------------------------------*/ -static void Test_Obj_Copy(void) +static void +Test_Obj_Copy(void) { - hid_t fid = -1; /* File id */ - hid_t fapl_new = (-1); /* File access property id */ - unsigned new_format; /* New format or old format */ + hid_t fid = H5I_INVALID_HID; /* File id */ + hid_t fapl_new = (-1); /* File access property id */ + unsigned new_format; /* New format or old format */ - if((fapl_new = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + if ((fapl_new = H5Pcreate(H5P_FILE_ACCESS)) < 0) { HDfprintf(stderr, "Error: H5Pcreate failed.\n"); goto out; } - if(H5Pset_libver_bounds(fapl_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { + if (H5Pset_libver_bounds(fapl_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { HDfprintf(stderr, "Error: H5Pset_libver_bounds failed.\n"); goto out; } /* Test with old & new format groups */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { + for (new_format = FALSE; new_format <= TRUE; new_format++) { /* Set the FAPL for the type of format */ /* Create source file */ - if(new_format) - fid = H5Fcreate(HDF_FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_new); - else - fid = H5Fcreate(HDF_FILE1_NEW, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if(fid < 0) { + if (new_format) + fid = H5Fcreate(HDF_FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_new); + else + fid = H5Fcreate(HDF_FILE1_NEW, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if (fid < 0) { HDfprintf(stderr, "Error: H5Fcreate failed.\n"); goto out; } @@ -756,7 +743,7 @@ static void Test_Obj_Copy(void) gent_empty_group(fid); gent_nested_datasets(fid); gent_nested_group(fid); - gent_att_compound_vlstr(fid); + gent_att_compound_vlstr(fid); H5Fclose(fid); fid = (-1); @@ -764,11 +751,11 @@ static void Test_Obj_Copy(void) out: /*----------------------------------------------------------------------- - * Close - *------------------------------------------------------------------------*/ - if(fid > 0) + * Close + *------------------------------------------------------------------------*/ + if (fid > 0) H5Fclose(fid); - if(fapl_new > 0) + if (fapl_new > 0) H5Pclose(fapl_new); } @@ -778,14 +765,14 @@ out: * Purpose: Testing with various references * *------------------------------------------------------------------------*/ -static void Test_Ref_Copy(void) +static void +Test_Ref_Copy(void) { - hid_t fid=0; + hid_t fid = 0; herr_t status; - fid = H5Fcreate (HDF_FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if (fid < 0) - { + fid = H5Fcreate(HDF_FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if (fid < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", HDF_FILE2); goto out; } @@ -802,9 +789,9 @@ static void Test_Ref_Copy(void) out: /*----------------------------------------------------------------------- - * Close - *------------------------------------------------------------------------*/ - if(fid > 0) + * Close + *------------------------------------------------------------------------*/ + if (fid > 0) H5Fclose(fid); } @@ -815,45 +802,44 @@ out: * * Programmer: Jonathan Kim (March 03, 2010) *------------------------------------------------------------------------*/ -static herr_t gen_extlink_trg(hid_t loc_id) +static herr_t +gen_extlink_trg(hid_t loc_id) { - hid_t gid=0, tid=0; - int status; + hid_t gid = 0, tid = 0; + int status; herr_t ret = SUCCEED; /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ /*-------------- * target file */ gid = H5Gcreate2(loc_id, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (gid < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", FUNC, __LINE__); + if (gid < 0) { + HDfprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", __func__, __LINE__); ret = FAIL; goto out; } /*-------------- * add dataset */ - gent_simple(loc_id); + gent_simple(loc_id); /*-------------------- * add named datatype */ - tid = H5Tcopy(H5T_NATIVE_INT); - status = H5Tcommit2(loc_id, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Tcommit2 failed.\n", FUNC, __LINE__); + tid = H5Tcopy(H5T_NATIVE_INT); + status = H5Tcommit2(loc_id, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Tcommit2 failed.\n", __func__, __LINE__); ret = FAIL; goto out; } out: - if(gid > 0) + if (gid > 0) H5Gclose(gid); - if(tid > 0) + if (tid > 0) H5Tclose(tid); return ret; @@ -866,73 +852,69 @@ out: * * Programmer: Jonathan Kim (March 03, 2010) *------------------------------------------------------------------------*/ -static herr_t gen_extlink_src(hid_t loc_id) +static herr_t +gen_extlink_src(hid_t loc_id) { - hid_t gid=0; - int status; + hid_t gid = 0; + int status; herr_t ret = SUCCEED; /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ gid = H5Gcreate2(loc_id, "/group_ext", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (gid < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", FUNC, __LINE__); + if (gid < 0) { + HDfprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", __func__, __LINE__); ret = FAIL; goto out; } /*----------------------------------------------------------------------- - * External links - *------------------------------------------------------------------------*/ + * External links + *------------------------------------------------------------------------*/ /* link to dataset */ status = H5Lcreate_external(HDF_EXT_TRG_FILE, "/simple", gid, "extlink_dset", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", FUNC, __LINE__); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", __func__, __LINE__); ret = FAIL; goto out; } /* link to group */ status = H5Lcreate_external(HDF_EXT_TRG_FILE, "/group", gid, "extlink_grp", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", FUNC, __LINE__); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", __func__, __LINE__); ret = FAIL; goto out; } /* link to datatype */ - status = H5Lcreate_external(HDF_EXT_TRG_FILE, "/datatype", gid, "extlink_datatype", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", FUNC, __LINE__); + status = + H5Lcreate_external(HDF_EXT_TRG_FILE, "/datatype", gid, "extlink_datatype", H5P_DEFAULT, H5P_DEFAULT); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", __func__, __LINE__); ret = FAIL; goto out; } /* dangling link - no obj*/ status = H5Lcreate_external(HDF_EXT_TRG_FILE, "notyet", gid, "extlink_notyet1", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", FUNC, __LINE__); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", __func__, __LINE__); ret = FAIL; goto out; } /* dangling link - no file */ status = H5Lcreate_external("notyet_file.h5", "notyet", gid, "extlink_notyet2", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", FUNC, __LINE__); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", __func__, __LINE__); ret = FAIL; goto out; } out: - if(gid > 0) + if (gid > 0) H5Gclose(gid); return ret; @@ -941,25 +923,24 @@ out: /*------------------------------------------------------------------------- * Function: Test_Extlink_Copy * - * Purpose: gerenate external link files + * Purpose: generate external link files * *------------------------------------------------------------------------*/ -static void Test_Extlink_Copy(void) +static void +Test_Extlink_Copy(void) { - hid_t fid1=0; - hid_t fid2=0; + hid_t fid1 = 0; + hid_t fid2 = 0; herr_t status; - fid1 = H5Fcreate (HDF_EXT_SRC_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if (fid1 < 0) - { + fid1 = H5Fcreate(HDF_EXT_SRC_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", HDF_EXT_SRC_FILE); goto out; } - fid2 = H5Fcreate (HDF_EXT_TRG_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if (fid2 < 0) - { + fid2 = H5Fcreate(HDF_EXT_TRG_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if (fid2 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", HDF_EXT_TRG_FILE); goto out; } @@ -976,11 +957,11 @@ static void Test_Extlink_Copy(void) out: /*----------------------------------------------------------------------- - * Close - *------------------------------------------------------------------------*/ - if(fid1 > 0) + * Close + *------------------------------------------------------------------------*/ + if (fid1 > 0) H5Fclose(fid1); - if(fid2 > 0) + if (fid2 > 0) H5Fclose(fid2); } @@ -990,7 +971,8 @@ out: *------------------------------------------------------------------------- */ -int main(void) +int +main(void) { Test_Obj_Copy(); Test_Ref_Copy(); @@ -998,4 +980,3 @@ int main(void) return 0; } - diff --git a/tools/test/h5copy/testh5copy.sh.in b/tools/test/h5copy/testh5copy.sh.in index 2440ca4..6349ef4 100644 --- a/tools/test/h5copy/testh5copy.sh.in +++ b/tools/test/h5copy/testh5copy.sh.in @@ -7,13 +7,13 @@ # 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. # # Tests for the h5copy tool # -# Pedro Vicente Nunes (pvn@hdfgroup.org), Albert Cheng (acheng@hdfgroup.org) +# Pedro Vicente Nunes, Albert Cheng # Thursday, July 20, 2006 # @@ -88,7 +88,7 @@ test -d $TESTDIR || mkdir $TESTDIR # RUNSERIAL is used. Check if it can return exit code from executalbe correctly. if [ -n "$RUNSERIAL_NOEXITCODE" ]; then - echo "***Warning*** Serial Exit Code is not passed back to shell corretly." + echo "***Warning*** Serial Exit Code is not passed back to shell correctly." echo "***Warning*** Exit code checking is skipped." h5haveexitcode=no fi @@ -200,6 +200,7 @@ TOOLTEST() fi runh5diff=no fi + if [ "$3" = -o ]; then outputfile=$4 else @@ -219,6 +220,7 @@ TOOLTEST() $RUNSERIAL $H5COPY_BIN $@ ) > $actualout 2> $actualerr RET=$? + if [ $RET != 0 ]; then echo "*FAILED*" echo "failed result is:" @@ -268,6 +270,7 @@ TOOLTEST_PREFILL() $RUNSERIAL $H5COPY_BIN -i $inputfile -o $outputfile -v -s $grp_name -d $grp_name2 ) > $actualout 2> $actualerr RET=$? + if [ $RET != 0 ]; then echo "*FAILED*" echo "failed result is:" @@ -282,6 +285,7 @@ TOOLTEST_PREFILL() $RUNSERIAL $H5COPY_BIN -i $inputfile -o $outputfile -v -s $obj_name -d $obj_name2 ) > $actualout 2> $actualerr RET=$? + if [ $RET != 0 ]; then echo "*FAILED*" echo "failed result is:" @@ -313,6 +317,7 @@ TOOLTEST_SAME() else runh5diff=no fi + if [ "$3" = -o ]; then outputfile=$4 else @@ -330,6 +335,7 @@ TOOLTEST_SAME() $RUNSERIAL $H5COPY_BIN -i $inputfile -o $outputfile -v -s $grp_name -d $grp_name ) > $actualout 2> $actualerr RET=$? + if [ $RET != 0 ]; then echo "*FAILED*" echo "failed result is:" @@ -344,6 +350,7 @@ TOOLTEST_SAME() $RUNSERIAL $H5COPY_BIN -i $outputfile -o $outputfile -v -s $grp_name -d $grp_name2 ) > $actualout 2> $actualerr RET=$? + if [ $RET != 0 ]; then echo "*FAILED*" echo "failed result is:" @@ -406,6 +413,7 @@ TOOLTEST_FAIL() if [ "$1" = -i ]; then inputfile=$2 fi + if [ "$3" = -o ]; then outputfile=$4 fi @@ -417,8 +425,8 @@ TOOLTEST_FAIL() #echo "#############################" $RUNSERIAL $H5COPY_BIN $@ ) > $actualout 2> $actualerr - RET=$? + # save actualout and actualerr in case they are needed later. cp $actualout $actualout_sav STDOUT_FILTER $actualout diff --git a/tools/test/h5diff/CMakeLists.txt b/tools/test/h5diff/CMakeLists.txt index cb4397f..f74db0f 100644 --- a/tools/test/h5diff/CMakeLists.txt +++ b/tools/test/h5diff/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_TOOLS_TEST_H5DIFF C) # -------------------------------------------------------------------- @@ -6,11 +6,18 @@ project (HDF5_TOOLS_TEST_H5DIFF C) # -------------------------------------------------------------------- if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) add_executable (h5diffgentest ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/h5diffgentest.c) - target_include_directories (h5diffgentest PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (h5diffgentest PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h5diffgentest STATIC) target_link_libraries (h5diffgentest PRIVATE ${HDF5_LIB_TARGET}) set_target_properties (h5diffgentest PROPERTIES FOLDER generator/tools) + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5DIFF_FORMAT h5diffgentest) + endif () + #add_test (NAME h5diffgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diffgentest>) endif () @@ -23,11 +30,18 @@ if (BUILD_SHARED_LIBS) set (H5DIFF_TOOL_PLUGIN_LIB_TARGET ${H5DIFF_TOOL_PLUGIN_LIB_CORENAME}) add_library (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_diff.c) - target_include_directories (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} SHARED) - target_link_libraries (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIBSH_TARGET}) + target_link_libraries (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_LIBSH_TARGET}) H5_SET_LIB_OPTIONS (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} ${H5DIFF_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5DIFF_PLUGIN_FORMAT ${H5DIFF_TOOL_PLUGIN_LIB_TARGET}) + endif () + # make plugins dir file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") #----------------------------------------------------------------------------- @@ -43,4 +57,6 @@ if (BUILD_SHARED_LIBS) ) endif () -include (CMakeTests.cmake) +if (HDF5_TEST_TOOLS) + include (CMakeTests.cmake) +endif () diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake index 93dfd72..8e01605 100644 --- a/tools/test/h5diff/CMakeTests.cmake +++ b/tools/test/h5diff/CMakeTests.cmake @@ -5,7 +5,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -66,8 +66,10 @@ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/non_comparables2.h5 ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/tudfilter.h5 ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/tudfilter2.h5 - ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/diff_strings1.h5 - ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/diff_strings2.h5 + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_strings1.h5 + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_strings2.h5 + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_eps1.h5 + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_eps2.h5 # tools/testfiles/vds ${HDF5_TOOLS_DIR}/testfiles/vds/1_a.h5 ${HDF5_TOOLS_DIR}/testfiles/vds/1_b.h5 @@ -94,6 +96,17 @@ ${HDF5_TOOLS_DIR}/testfiles/vds/5_vds.h5 # tools/testfiles ${HDF5_TOOLS_DIR}/testfiles/tvlstr.h5 + #STD_REF_OBJ files + ${HDF5_TOOLS_DIR}/testfiles/trefer_attr.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_compat.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_ext1.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_ext2.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_grp.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_obj_del.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_obj.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_param.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_reg_1d.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_reg.h5 ) set (LIST_OTHER_TEST_FILES @@ -201,6 +214,7 @@ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_56.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_57.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_58.txt + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_58_ref.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_59.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_500.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_501.txt @@ -279,9 +293,11 @@ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_80.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_800.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_801.txt + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_830.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_90.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_8625.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_8639.txt + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_reg.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_ud.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_udfail.err ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_udfail.txt @@ -289,6 +305,7 @@ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_v2.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_v3.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_vlstr.txt + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_eps.txt ) set (LIST_WIN_TEST_FILES @@ -325,9 +342,10 @@ # Overwrite system dependent files (Windows) and not VS2015 # set (COPY_WINDOWS_FILES false) - if (MINGW) - set (COPY_WINDOWS_FILES true) - endif () + # MinGW tests may depend on host system + #if (MINGW) + # set (COPY_WINDOWS_FILES true) + #endif () if (WIN32 AND MSVC_VERSION LESS 1900) set (COPY_WINDOWS_FILES true) endif () @@ -350,12 +368,6 @@ endif () add_custom_target(h5diff_files ALL COMMENT "Copying files needed by h5diff tests" DEPENDS ${h5diff_files_list}) - if (NOT BUILD_SHARED_LIBS) - set (tgt_ext "") - else () - set (tgt_ext "-shared") - endif () - ############################################################################## ############################################################################## ### T H E T E S T S M A C R O S ### @@ -363,9 +375,18 @@ ############################################################################## macro (ADD_H5_TEST resultfile resultcode) + if (HDF5_TEST_SERIAL) + ADD_SH5_TEST (${resultfile} ${resultcode} ${ARGN}) + endif () + if (H5_HAVE_PARALLEL AND HDF5_TEST_PARALLEL) + ADD_PH5_TEST (${resultfile} ${resultcode} ${ARGN}) + endif () + endmacro () + + macro (ADD_SH5_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DIFF-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_ext}> ${ARGN}) + add_test (NAME H5DIFF-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_file_ext}> ${ARGN}) set_tests_properties (H5DIFF-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") if (${resultcode}) set_tests_properties (H5DIFF-${resultfile} PROPERTIES WILL_FAIL "true") @@ -378,7 +399,7 @@ NAME H5DIFF-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5diff${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5diff${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${resultfile}.out" @@ -391,15 +412,12 @@ set_tests_properties (H5DIFF-${resultfile} PROPERTIES DEPENDS ${last_test}) endif () endif () - if (H5_HAVE_PARALLEL) - ADD_PH5_TEST (${resultfile} ${resultcode} ${ARGN}) - endif () endmacro () macro (ADD_PH5_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME MPI_TEST_H5DIFF-${resultfile} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $<TARGET_FILE:ph5diff> ${MPIEXEC_POSTFLAGS} ${ARGN}) + add_test (NAME MPI_TEST_H5DIFF-${resultfile} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $<TARGET_FILE:ph5diff${tgt_file_ext}> ${MPIEXEC_POSTFLAGS} ${ARGN}) set_tests_properties (MPI_TEST_H5DIFF-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/PAR/testfiles") if (${resultcode}) set_tests_properties (MPI_TEST_H5DIFF-${resultfile} PROPERTIES WILL_FAIL "true") @@ -411,7 +429,7 @@ add_test ( NAME MPI_TEST_H5DIFF-${resultfile} COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=${MPIEXEC_EXECUTABLE};${MPIEXEC_NUMPROC_FLAG};${MPIEXEC_MAX_NUMPROCS};${MPIEXEC_PREFLAGS};$<TARGET_FILE:ph5diff>;${MPIEXEC_POSTFLAGS}" + -D "TEST_PROGRAM=${MPIEXEC_EXECUTABLE};${MPIEXEC_NUMPROC_FLAG};${MPIEXEC_MAX_NUMPROCS};${MPIEXEC_PREFLAGS};$<TARGET_FILE:ph5diff${tgt_file_ext}>;${MPIEXEC_POSTFLAGS}" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/PAR/testfiles" -D "TEST_OUTPUT=${resultfile}.out" @@ -426,13 +444,13 @@ if (last_test) set_tests_properties (MPI_TEST_H5DIFF-${resultfile} PROPERTIES DEPENDS ${last_test}) endif () - set (last_test "PH5DIFF-${resultfile}") + set (last_test "MPI_TEST_H5DIFF-${resultfile}") endif () endmacro () macro (ADD_H5_UD_TEST testname resultcode resultfile) if (NOT HDF5_ENABLE_USING_MEMCHECKER) - if (${resultcode} EQUAL 2) + if ("${resultcode}" STREQUAL "2") add_test ( NAME H5DIFF_UD-${testname} COMMAND "${CMAKE_COMMAND}" @@ -530,8 +548,11 @@ set (ATTR_VERBOSE_LEVEL_FILE1 h5diff_attr_v_level1.h5) set (ATTR_VERBOSE_LEVEL_FILE2 h5diff_attr_v_level2.h5) # strings - set (STRINGS1 diff_strings1.h5) - set (STRINGS2 diff_strings2.h5) + set (STRINGS1 h5diff_strings1.h5) + set (STRINGS2 h5diff_strings2.h5) + # epsilon + set (EPS1 h5diff_eps1.h5) + set (EPS2 h5diff_eps2.h5) # VDS tests set (FILEV1 1_vds.h5) @@ -903,6 +924,8 @@ h5diff_800.out.err h5diff_801.out h5diff_801.out.err + h5diff_830.out + h5diff_830.out.err h5diff_8625.out h5diff_8625.out.err h5diff_8639.out @@ -917,6 +940,8 @@ h5diff_v3.out.err h5diff_vlstr.out h5diff_vlstr.out.err + h5diff_eps.out + h5diff_eps.out.err ) set_tests_properties (H5DIFF-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") if (last_test) @@ -1044,7 +1069,10 @@ ADD_H5_TEST (h5diff_56 1 -v ${FILE4} ${FILE4} dset6a dset6b) ADD_H5_TEST (h5diff_57 0 -v ${FILE4} ${FILE4} dset7a dset7b) # 5.8 (region reference) -ADD_H5_TEST (h5diff_58 1 -v ${FILE7} ${FILE8} refreg) +ADD_H5_TEST (h5diff_58 1 -v2 ${FILE7} ${FILE8} refreg) +ADD_H5_TEST (h5diff_58_ref 1 -v2 ${FILE7} ${FILE8} /g1/reference2D) +# STD_REF_OBJ +ADD_H5_TEST (h5diff_reg 0 -v2 trefer_attr.h5 trefer_ext2.h5 Dataset3 Dataset3) # test for both dset and attr with same type but with different size # ( HDDFV-7942 ) @@ -1095,6 +1123,9 @@ ADD_H5_TEST (h5diff_609 0 -d 200 ${FILE1} ${FILE2} g1/dset3 g1/dset4) # 6.10: number smaller than smallest difference ADD_H5_TEST (h5diff_610 1 -d 1 ${FILE1} ${FILE2} g1/dset3 g1/dset4) +# eps: number smaller than epsilon +ADD_H5_TEST (h5diff_eps 0 -v3 -d 1e-16 ${EPS1} ${EPS2}) + # ############################################################################## # # -p # ############################################################################## @@ -1247,7 +1278,7 @@ ADD_H5_TEST (h5diff_208 0 -c ${FILE19} ${FILE20}) ADD_H5_TEST (h5diff_220 1 -c non_comparables1.h5 non_comparables2.h5 /g1) # comparable dataset with non-comparable attribute and other comparable attributes. -# Also test non-compatible attributes with different type, dimention, rank. +# Also test non-compatible attributes with different type, dimension, rank. # All the rest comparables should display differences. ADD_H5_TEST (h5diff_221 1 -c non_comparables1.h5 non_comparables2.h5 /g2) @@ -1407,7 +1438,7 @@ ADD_H5_TEST (h5diff_475 1 -v h5diff_danglelinks1.h5 h5diff_danglelinks2.h5 /ext_ # ############################################################################## -# # test for group diff recursivly +# # test for group diff recursively # ############################################################################## # root ADD_H5_TEST (h5diff_500 1 -v ${GRP_RECURSE_FILE1} ${GRP_RECURSE_FILE2} / /) @@ -1480,11 +1511,9 @@ ADD_H5_TEST (h5diff_484 0 -v --exclude-path "/dset3" ${EXCLUDE_FILE1_1} ${EXCLUD # Only one file contains unique objs. Common objs are same. # (HDFFV-7837) # -ADD_H5_TEST (h5diff_485 0 -v --exclude-path "/group1" h5diff_exclude3-1.h5 h5diff_exclude3-2.h5) -ADD_H5_TEST (h5diff_486 0 -v --exclude-path "/group1" h5diff_exclude3-2.h5 h5diff_exclude3-1.h5) -ADD_H5_TEST (h5diff_487 1 -v --exclude-path "/group1/dset" h5diff_exclude3-1.h5 h5diff_exclude3-2.h5) - - +ADD_H5_TEST (h5diff_485 0 -v --exclude-path "/group1" ${EXCLUDE_FILE3_1} ${EXCLUDE_FILE3_2}) +ADD_H5_TEST (h5diff_486 0 -v --exclude-path "/group1" ${EXCLUDE_FILE3_2} ${EXCLUDE_FILE3_1}) +ADD_H5_TEST (h5diff_487 1 -v --exclude-path "/group1/dset" ${EXCLUDE_FILE3_1} ${EXCLUDE_FILE3_2}) # ############################################################################## # # diff various multiple vlen and fixed strings in a compound type dataset @@ -1518,13 +1547,17 @@ ADD_H5_TEST (h5diff_646 1 -v --use-system-epsilon -p 0.05 ${FILE1} ${FILE2} /g1/ # ############################################################################## # # Test array variances # ############################################################################## -# -# Test with -d , -p and --use-system-epsilon. ADD_H5_TEST (h5diff_800 1 -v ${FILE7} ${FILE8} /g1/array /g1/array) ADD_H5_TEST (h5diff_801 1 -v ${FILE7} ${FILE8A} /g1/array /g1/array) # ############################################################################## -# VDS tests +# # dataset subsets +# ############################################################################## +#serial only +ADD_SH5_TEST (h5diff_830 1 --enable-error-stack -v ${FILE7} ${FILE8} /g1/array3D[0,0,0;2,2,1;2,2,2;] /g1/array3D[0,0,0;2,2,1;2,2,2;]) + +# ############################################################################## +# # VDS tests # ############################################################################## ADD_H5_TEST (h5diff_v1 0 -v ${FILEV1} ${FILEV2}) ADD_H5_TEST (h5diff_v2 0 -r ${FILEV1} ${FILEV2}) @@ -1533,7 +1566,7 @@ ADD_H5_TEST (h5diff_v3 0 -c ${FILEV1} ${FILEV2}) ############################################################################## ### P L U G I N T E S T S ############################################################################## -if (BUILD_SHARED_LIBS) +if (BUILD_SHARED_LIBS AND HDF5_TEST_SERIAL) ADD_H5_UD_TEST (h5diff_plugin_test 0 h5diff_ud -v tudfilter.h5 tudfilter2.h5) ADD_H5_UD_TEST (h5diff_plugin_fail 2 h5diff_udfail -v tudfilter.h5 tudfilter2.h5) endif () diff --git a/tools/test/h5diff/Makefile.am b/tools/test/h5diff/Makefile.am index 3a88573..17af61b 100644 --- a/tools/test/h5diff/Makefile.am +++ b/tools/test/h5diff/Makefile.am @@ -6,7 +6,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. ## diff --git a/tools/test/h5diff/dynlib_diff.c b/tools/test/h5diff/dynlib_diff.c index 571452e..433522d 100644 --- a/tools/test/h5diff/dynlib_diff.c +++ b/tools/test/h5diff/dynlib_diff.c @@ -5,7 +5,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,25 +17,33 @@ #include <stdio.h> #include "H5PLextern.h" -#define H5Z_FILTER_DYNLIBUD 300 -#define MULTIPLIER 3 +#define H5Z_FILTER_DYNLIBUD 300 +#define MULTIPLIER 3 -static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_DYNLIBUD[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_DYNLIBUD, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "dynlibud", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_DYNLIBUD, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "dynlibud", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + H5Z_filter_dynlibud, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_FILTER; +} +const void * +H5PLget_plugin_info(void) +{ + return H5Z_DYNLIBUD; +} /*------------------------------------------------------------------------- * Function: H5Z_filter_dynlibud @@ -51,39 +59,37 @@ const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} *------------------------------------------------------------------------- */ static size_t -H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) { - char *int_ptr = (char *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + char * int_ptr = (char *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ /* Check for the correct number of parameters */ - if(cd_nelmts > 0) - return(0); + if (cd_nelmts > 0) + return (0); /* Assignment to eliminate unused parameter warning. */ - cd_values = cd_values; + (void)cd_values; - if(flags & H5Z_FLAG_REVERSE) { /*read*/ + if (flags & H5Z_FLAG_REVERSE) { /*read*/ /* Subtract the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = temp - MULTIPLIER; + *int_ptr = (int8_t)(temp - MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ else { /*write*/ /* Add the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = temp + MULTIPLIER; + *int_ptr = (int8_t)(temp + MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); } /* end while */ - } /* end else */ + } /* end else */ return nbytes; } /* end H5Z_filter_dynlibud() */ - diff --git a/tools/test/h5diff/h5diff_plugin.sh.in b/tools/test/h5diff/h5diff_plugin.sh.in index 341cba5..28f723e 100644 --- a/tools/test/h5diff/h5diff_plugin.sh.in +++ b/tools/test/h5diff/h5diff_plugin.sh.in @@ -6,7 +6,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -135,30 +135,30 @@ CLEAN_TESTFILES_AND_TESTDIR() # -h print help page while [ $# -gt 0 ]; do case "$1" in - -p) # reset the tool name and bin to run ph5diff tests - TESTNAME=ph5diff - H5DIFF=../../src/h5diff/ph5diff # The tool name - H5DIFF_BIN=`pwd`/$H5DIFF # The path of the tool binary - pmode=yes - shift - ;; + -p) # reset the tool name and bin to run ph5diff tests + TESTNAME=ph5diff + H5DIFF=../../src/h5diff/ph5diff # The tool name + H5DIFF_BIN=`pwd`/$H5DIFF # The path of the tool binary + pmode=yes + shift + ;; -h) # print help page - echo "$0 [-p] [-h]" - echo " -p run ph5diff tests" - echo " -h print help page" - shift - exit 0 - ;; + echo "$0 [-p] [-h]" + echo " -p run ph5diff tests" + echo " -h print help page" + shift + exit 0 + ;; *) # unknown option echo "$0: Unknown option ($1)" - exit 1 - ;; + exit 1 + ;; esac done # RUNSERIAL is used. Check if it can return exit code from executalbe correctly. if [ -n "$RUNSERIAL_NOEXITCODE" ]; then - echo "***Warning*** Serial Exit Code is not passed back to shell corretly." + echo "***Warning*** Serial Exit Code is not passed back to shell correctly." echo "***Warning*** Exit code checking is skipped." h5haveexitcode=no fi @@ -218,23 +218,25 @@ TOOLTEST() { # Run test. TESTING $H5DIFF $@ ( - #echo "#############################" - #echo "Expected output for '$H5DIFF $@'" - #echo "#############################" - cd $TESTDIR - eval $ENVCMD $RUNCMD $H5DIFF_BIN "$@" + #echo "#############################" + #echo "Expected output for '$H5DIFF $@'" + #echo "#############################" + cd $TESTDIR + eval $ENVCMD $RUNCMD $H5DIFF_BIN "$@" ) >$actual 2>$actual_err EXIT_CODE=$? + # save actual and actual_err in case they are needed later. cp $actual $actual_sav STDOUT_FILTER $actual cp $actual_err $actual_err_sav STDERR_FILTER $actual_err cat $actual_err >> $actual + # don't add exit code check in pmode, as it causes failure. (exit code # is from mpirun not tool) # if any problem occurs relate to an exit code, it will be caught in - # serial mode, so the test is fullfilled. + # serial mode, so the test is fulfilled. if test $h5haveexitcode = 'yes' -a -z "$pmode"; then echo "EXIT CODE: $EXIT_CODE" >> $actual fi @@ -260,27 +262,29 @@ TOOLTEST() { actual_sorted=actual_sorted sort $expect -o $expect_sorted sort $actual -o $actual_sorted + # remove "EXIT CODE:" line from expect file. test for exit code # is done by serial mode. grep -v "EXIT CODE:" $expect_sorted > $expect_sorted.noexit mv $expect_sorted.noexit $expect_sorted - if $CMP $expect_sorted $actual_sorted; then - echo " PASSED" - else - echo "*FAILED*" - nerrors="`expr $nerrors + 1`" - if test yes = "$verbose"; then - echo "====Expected result ($expect_sorted) differs from actual result ($actual_sorted)" - $DIFF $expect_sorted $actual_sorted |sed 's/^/ /' - echo "====The actual output ($actual_sav)" - sed 's/^/ /' < $actual_sav - echo "====The actual stderr ($actual_err_sav)" - sed 's/^/ /' < $actual_err_sav - echo "====End of actual stderr ($actual_err_sav)" - echo "" + + if $CMP $expect_sorted $actual_sorted; then + echo " PASSED" + else + echo "*FAILED*" + nerrors="`expr $nerrors + 1`" + if test yes = "$verbose"; then + echo "====Expected result ($expect_sorted) differs from actual result ($actual_sorted)" + $DIFF $expect_sorted $actual_sorted |sed 's/^/ /' + echo "====The actual output ($actual_sav)" + sed 's/^/ /' < $actual_sav + echo "====The actual stderr ($actual_err_sav)" + sed 's/^/ /' < $actual_err_sav + echo "====End of actual stderr ($actual_err_sav)" + echo "" + fi fi fi - fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then @@ -306,22 +310,24 @@ TOOLTEST_ERR() { # Run test. TESTING $H5DIFF $@ ( - #echo "#############################" - #echo "Expected output for '$H5DIFF $@'" - #echo "#############################" - cd $TESTDIR - eval $ENVCMD $RUNCMD $H5DIFF_BIN "$@" + #echo "#############################" + #echo "Expected output for '$H5DIFF $@'" + #echo "#############################" + cd $TESTDIR + eval $ENVCMD $RUNCMD $H5DIFF_BIN "$@" ) >$actual 2>$actual_err EXIT_CODE=$? + # save actual and actual_err in case they are needed later. cp $actual $actual_sav STDOUT_FILTER $actual cp $actual_err $actual_err_sav STDERR_FILTER $actual_err + # don't add exit code check in pmode, as it causes failure. (exit code # is from mpirun not tool) # if any problem occurs relate to an exit code, it will be caught in - # serial mode, so the test is fullfilled. + # serial mode, so the test is fulfilled. if test $h5haveexitcode = 'yes' -a -z "$pmode"; then echo "EXIT CODE: $EXIT_CODE" >> $actual fi @@ -348,23 +354,24 @@ TOOLTEST_ERR() { sort $expect_err -o $expect_sorted sort $actual_err -o $actual_sorted mv $expect_sorted.noexit $expect_sorted - if $CMP $expect_sorted $actual_sorted; then - echo " PASSED" - else - echo "*FAILED*" - nerrors="`expr $nerrors + 1`" - if test yes = "$verbose"; then - echo "====Expected result ($expect_sorted) differs from actual result ($actual_sorted)" - $DIFF $expect_sorted $actual_sorted |sed 's/^/ /' - echo "====The actual output ($actual_sav)" - sed 's/^/ /' < $actual_sav - echo "====The actual stderr ($actual_err_sav)" - sed 's/^/ /' < $actual_err_sav - echo "====End of actual stderr ($actual_err_sav)" - echo "" + + if $CMP $expect_sorted $actual_sorted; then + echo " PASSED" + else + echo "*FAILED*" + nerrors="`expr $nerrors + 1`" + if test yes = "$verbose"; then + echo "====Expected result ($expect_sorted) differs from actual result ($actual_sorted)" + $DIFF $expect_sorted $actual_sorted |sed 's/^/ /' + echo "====The actual output ($actual_sav)" + sed 's/^/ /' < $actual_sav + echo "====The actual stderr ($actual_err_sav)" + sed 's/^/ /' < $actual_err_sav + echo "====End of actual stderr ($actual_err_sav)" + echo "" + fi fi fi - fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then diff --git a/tools/test/h5diff/h5diffgentest.c b/tools/test/h5diff/h5diffgentest.c index d60e393..5e0f830 100644 --- a/tools/test/h5diff/h5diffgentest.c +++ b/tools/test/h5diff/h5diffgentest.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,75 +31,78 @@ size_t H5TOOLS_MALLOCSIZE = (128 * 1024 * 1024); * * Purpose: generate files for h5diff testing * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * Programmer: Pedro Vicente * * Date: November 12, 2003 * *------------------------------------------------------------------------- */ -#define FILE1 "h5diff_basic1.h5" -#define FILE2 "h5diff_basic2.h5" -#define FILE3 "h5diff_types.h5" -#define FILE4 "h5diff_dtypes.h5" -#define FILE5 "h5diff_attr1.h5" -#define FILE6 "h5diff_attr2.h5" -#define FILE6a "h5diff_attr3.h5" -#define FILE7 "h5diff_dset1.h5" -#define FILE8 "h5diff_dset2.h5" -#define FILE8A "h5diff_dset3.h5" -#define FILE9 "h5diff_hyper1.h5" -#define FILE10 "h5diff_hyper2.h5" -#define FILE11 "h5diff_empty.h5" -#define FILE12 "h5diff_links.h5" -#define FILE13 "h5diff_softlinks.h5" -#define FILE14 "h5diff_linked_softlink.h5" -#define FILE15 "h5diff_extlink_src.h5" -#define FILE16 "h5diff_extlink_trg.h5" -#define FILE17 "h5diff_ext2softlink_src.h5" -#define FILE18 "h5diff_ext2softlink_trg.h5" -#define FILE19 "h5diff_dset_zero_dim_size1.h5" -#define FILE20 "h5diff_dset_zero_dim_size2.h5" -#define FILE21 "h5diff_dset_idx1.h5" -#define FILE22 "h5diff_dset_idx2.h5" -#define DANGLE_LINK_FILE1 "h5diff_danglelinks1.h5" -#define DANGLE_LINK_FILE2 "h5diff_danglelinks2.h5" -#define GRP_RECURSE_FILE1 "h5diff_grp_recurse1.h5" -#define GRP_RECURSE_FILE2 "h5diff_grp_recurse2.h5" +#define FILE1 "h5diff_basic1.h5" +#define FILE2 "h5diff_basic2.h5" +#define FILE3 "h5diff_types.h5" +#define FILE4 "h5diff_dtypes.h5" +#define FILE5 "h5diff_attr1.h5" +#define FILE6 "h5diff_attr2.h5" +#define FILE6a "h5diff_attr3.h5" +#define FILE7 "h5diff_dset1.h5" +#define FILE8 "h5diff_dset2.h5" +#define FILE8A "h5diff_dset3.h5" +#define FILE9 "h5diff_hyper1.h5" +#define FILE10 "h5diff_hyper2.h5" +#define FILE11 "h5diff_empty.h5" +#define FILE12 "h5diff_links.h5" +#define FILE13 "h5diff_softlinks.h5" +#define FILE14 "h5diff_linked_softlink.h5" +#define FILE15 "h5diff_extlink_src.h5" +#define FILE16 "h5diff_extlink_trg.h5" +#define FILE17 "h5diff_ext2softlink_src.h5" +#define FILE18 "h5diff_ext2softlink_trg.h5" +#define FILE19 "h5diff_dset_zero_dim_size1.h5" +#define FILE20 "h5diff_dset_zero_dim_size2.h5" +#define FILE21 "h5diff_dset_idx1.h5" +#define FILE22 "h5diff_dset_idx2.h5" +#define DANGLE_LINK_FILE1 "h5diff_danglelinks1.h5" +#define DANGLE_LINK_FILE2 "h5diff_danglelinks2.h5" +#define GRP_RECURSE_FILE1 "h5diff_grp_recurse1.h5" +#define GRP_RECURSE_FILE2 "h5diff_grp_recurse2.h5" /* same structure via external links through files */ -#define GRP_RECURSE1_EXT "h5diff_grp_recurse_ext1.h5" -#define GRP_RECURSE2_EXT1 "h5diff_grp_recurse_ext2-1.h5" -#define GRP_RECURSE2_EXT2 "h5diff_grp_recurse_ext2-2.h5" -#define GRP_RECURSE2_EXT3 "h5diff_grp_recurse_ext2-3.h5" +#define GRP_RECURSE1_EXT "h5diff_grp_recurse_ext1.h5" +#define GRP_RECURSE2_EXT1 "h5diff_grp_recurse_ext2-1.h5" +#define GRP_RECURSE2_EXT2 "h5diff_grp_recurse_ext2-2.h5" +#define GRP_RECURSE2_EXT3 "h5diff_grp_recurse_ext2-3.h5" /* same structure, same obj name with different value */ -#define EXCLUDE_FILE1_1 "h5diff_exclude1-1.h5" -#define EXCLUDE_FILE1_2 "h5diff_exclude1-2.h5" +#define EXCLUDE_FILE1_1 "h5diff_exclude1-1.h5" +#define EXCLUDE_FILE1_2 "h5diff_exclude1-2.h5" /* different structure and obj names */ -#define EXCLUDE_FILE2_1 "h5diff_exclude2-1.h5" -#define EXCLUDE_FILE2_2 "h5diff_exclude2-2.h5" +#define EXCLUDE_FILE2_1 "h5diff_exclude2-1.h5" +#define EXCLUDE_FILE2_2 "h5diff_exclude2-2.h5" /* only one file has unique objs */ -#define EXCLUDE_FILE3_1 "h5diff_exclude3-1.h5" -#define EXCLUDE_FILE3_2 "h5diff_exclude3-2.h5" +#define EXCLUDE_FILE3_1 "h5diff_exclude3-1.h5" +#define EXCLUDE_FILE3_2 "h5diff_exclude3-2.h5" /* compound type with multiple vlen string types */ -#define COMP_VL_STRS_FILE "h5diff_comp_vl_strs.h5" -/* attribute compre with verbose level */ +#define COMP_VL_STRS_FILE "h5diff_comp_vl_strs.h5" +/* attribute compare with verbose level */ #define ATTR_VERBOSE_LEVEL_FILE1 "h5diff_attr_v_level1.h5" #define ATTR_VERBOSE_LEVEL_FILE2 "h5diff_attr_v_level2.h5" /* file containing valid/invalid enum value mix */ #define ENUM_INVALID_VALUES "h5diff_enum_invalid_values.h5" /* file with container types (array,vlen) with multiple compounds */ -#define COMPS_COMPLEX1 "compounds_array_vlen1.h5" -#define COMPS_COMPLEX2 "compounds_array_vlen2.h5" +#define COMPS_COMPLEX1 "compounds_array_vlen1.h5" +#define COMPS_COMPLEX2 "compounds_array_vlen2.h5" /* non-comparable dataset and attribute */ #define NON_COMPARBLES1 "non_comparables1.h5" #define NON_COMPARBLES2 "non_comparables2.h5" /* string dataset and attribute */ -#define DIFF_STRINGS1 "diff_strings1.h5" -#define DIFF_STRINGS2 "diff_strings2.h5" +#define DIFF_STRINGS1 "h5diff_strings1.h5" +#define DIFF_STRINGS2 "h5diff_strings2.h5" +/* double dataset and epsilon */ +#define DIFF_EPS1 "h5diff_eps1.h5" +#define DIFF_EPS2 "h5diff_eps2.h5" #define UIMAX 4294967295u /*Maximum value for a variable of type unsigned int */ #define STR_SIZE 3 -#define GBLL ((unsigned long long) 1024 * 1024 *1024 ) +#define GBLL ((unsigned long long)1024 * 1024 * 1024) #define MY_LINKCLASS 187 @@ -109,79 +112,82 @@ size_t H5TOOLS_MALLOCSIZE = (128 * 1024 * 1024); #define SPACE1_DIM2 0 /* Error macros */ -#define AT() HDprintf("ERROR at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); -#define PROGRAM_ERROR {AT(); goto error;} +#define AT() HDprintf("ERROR at %s:%d in %s()...\n", __FILE__, __LINE__, __func__); +#define PROGRAM_ERROR \ + do { \ + AT(); \ + goto error; \ + } while (0) /* A UD link traversal function. Shouldn't actually be called. */ static hid_t -UD_traverse(H5_ATTR_UNUSED const char * link_name, H5_ATTR_UNUSED hid_t cur_group, - H5_ATTR_UNUSED const void * udata, H5_ATTR_UNUSED size_t udata_size, H5_ATTR_UNUSED hid_t lapl_id, - H5_ATTR_UNUSED hid_t dxpl_id) +UD_traverse(H5_ATTR_UNUSED const char *link_name, H5_ATTR_UNUSED hid_t cur_group, + H5_ATTR_UNUSED const void *udata, H5_ATTR_UNUSED size_t udata_size, H5_ATTR_UNUSED hid_t lapl_id, + H5_ATTR_UNUSED hid_t dxpl_id) { return -1; } const H5L_class_t UD_link_class[1] = {{ H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)MY_LINKCLASS, /* Link type id number */ - "UD link class", /* name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move/rename callback */ - NULL, /* Copy callback */ - UD_traverse, /* The actual traversal function */ - NULL, /* Deletion callback */ - NULL /* Query callback */ + (H5L_type_t)MY_LINKCLASS, /* Link type id number */ + "UD link class", /* name for debugging */ + NULL, /* Creation callback */ + NULL, /* Move/rename callback */ + NULL, /* Copy callback */ + UD_traverse, /* The actual traversal function */ + NULL, /* Deletion callback */ + NULL /* Query callback */ }}; - /*------------------------------------------------------------------------- * prototypes *------------------------------------------------------------------------- */ /* tests called in main() */ -static int test_basic(const char *fname1, const char *fname2, const char *fname3); -static int test_types(const char *fname); -static int test_datatypes(const char *fname); -static int test_attributes(const char *fname, int make_diffs); -static int test_datasets(const char *fname, int make_diffs); -static int test_special_datasets(const char *fname, int make_diffs); -static int test_hyperslab(const char *fname, int make_diffs); -static int test_link_name(const char *fname1); -static int test_soft_links(const char *fname1); -static int test_linked_softlinks(const char *fname1); -static int test_external_links(const char *fname1, const char *fname2); -static int test_ext2soft_links(const char *fname1, const char *fname2); -static int test_dangle_links(const char *fname1, const char *fname2); -static int test_group_recurse(const char *fname1, const char *fname2); -static int test_group_recurse2(void); -static int test_exclude_obj1(const char *fname1, const char *fname2); -static int test_exclude_obj2(const char *fname1, const char *fname2); -static int test_exclude_obj3(const char *fname1, const char *fname2); -static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int is_file_new); -static int test_attributes_verbose_level(const char *fname1, const char *fname2); -static int test_enums(const char *fname); -static void test_comps_array(const char *fname, const char *dset, - const char *attr, int diff, int is_file_new); -static void test_comps_vlen(const char *fname, const char *dset, - const char *attr, int diff, int is_file_new); -static void test_comps_array_vlen(const char *fname, const char *dset, - const char *attr, int diff, int is_file_new); -static void test_comps_vlen_arry(const char *fname, const char *dset, - const char *attr, int diff, int is_file_new); +static int test_basic(const char *fname1, const char *fname2, const char *fname3); +static int test_types(const char *fname); +static int test_datatypes(const char *fname); +static int test_attributes(const char *fname, int make_diffs); +static int test_datasets(const char *fname, int make_diffs); +static int test_special_datasets(const char *fname, int make_diffs); +static int test_hyperslab(const char *fname, int make_diffs); +static int test_link_name(const char *fname1); +static int test_soft_links(const char *fname1); +static int test_linked_softlinks(const char *fname1); +static int test_external_links(const char *fname1, const char *fname2); +static int test_ext2soft_links(const char *fname1, const char *fname2); +static int test_dangle_links(const char *fname1, const char *fname2); +static int test_group_recurse(const char *fname1, const char *fname2); +static int test_group_recurse2(void); +static int test_exclude_obj1(const char *fname1, const char *fname2); +static int test_exclude_obj2(const char *fname1, const char *fname2); +static int test_exclude_obj3(const char *fname1, const char *fname2); +static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int is_file_new); +static int test_attributes_verbose_level(const char *fname1, const char *fname2); +static int test_enums(const char *fname); +static void test_comps_array(const char *fname, const char *dset, const char *attr, int diff, + int is_file_new); +static void test_comps_vlen(const char *fname, const char *dset, const char *attr, int diff, int is_file_new); +static void test_comps_array_vlen(const char *fname, const char *dset, const char *attr, int diff, + int is_file_new); +static void test_comps_vlen_arry(const char *fname, const char *dset, const char *attr, int diff, + int is_file_new); static void test_data_nocomparables(const char *fname, int diff); static void test_objs_nocomparables(const char *fname1, const char *fname2); static void test_objs_strings(const char *fname, const char *fname2); +static void test_double_epsilon(const char *fname1, const char *fname2); /* called by test_attributes() and test_datasets() */ -static void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs); -static void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs); -static void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs); +static void write_attr_strings(hid_t loc_id, const char *dset_name, hid_t fid, int make_diffs); +static void write_attr_in(hid_t loc_id, const char *dset_name, hid_t fid, int make_diffs); +static void write_dset_in(hid_t loc_id, const char *dset_name, hid_t fid, int make_diffs); static void gen_datareg(hid_t fid, int make_diffs); /* utilities */ -static int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf); +static int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf); static herr_t write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf); -static int gen_dataset_idx(const char *file, int format); +static int gen_dataset_idx(const char *file, int format); /*------------------------------------------------------------------------- * Function: main @@ -191,7 +197,8 @@ static int gen_dataset_idx(const char *file, int format); *------------------------------------------------------------------------- */ -int main(void) +int +main(void) { test_basic(FILE1, FILE2, FILE11); @@ -231,11 +238,11 @@ int main(void) test_special_datasets(FILE20, 1); /* - * Generate 2 files: FILE21 with old format; FILE22 with new format - * Create 2 datasets in each file: - * One dataset: chunked layout, w/o filters, fixed dimension - * One dataset: chunked layout, w/ filters, fixed dimension - */ + * Generate 2 files: FILE21 with old format; FILE22 with new format + * Create 2 datasets in each file: + * One dataset: chunked layout, w/o filters, fixed dimension + * One dataset: chunked layout, w/ filters, fixed dimension + */ gen_dataset_idx(FILE21, 0); gen_dataset_idx(FILE22, 1); @@ -253,16 +260,16 @@ int main(void) test_comp_vlen_strings(COMP_VL_STRS_FILE, "group_copy", 0); /* diff when invalid enum values are present. - * This will probably grow to involve more extensive testing of - * enums so it has been given its own test file and test (apart - * from the basic type testing). - */ + * This will probably grow to involve more extensive testing of + * enums so it has been given its own test file and test (apart + * from the basic type testing). + */ test_enums(ENUM_INVALID_VALUES); /* ------------------------------------------------- - * Create test files with dataset and attribute with container types - * (array, vlen) with multiple nested compound types. - */ + * Create test files with dataset and attribute with container types + * (array, vlen) with multiple nested compound types. + */ /* file1 */ test_comps_array(COMPS_COMPLEX1, "dset1", "attr1", 0, 1); test_comps_vlen(COMPS_COMPLEX1, "dset2", "attr2", 0, 0); @@ -275,10 +282,10 @@ int main(void) test_comps_vlen_arry(COMPS_COMPLEX2, "dset4", "attr4", 5, 0); /*------------------------------------------------- - * Create test files with non-comparable dataset and attributes with - * comparable datasets and attributes. All the comparables should display - * differences. - */ + * Create test files with non-comparable dataset and attributes with + * comparable datasets and attributes. All the comparables should display + * differences. + */ test_data_nocomparables(NON_COMPARBLES1, 0); test_data_nocomparables(NON_COMPARBLES2, 5); @@ -288,6 +295,9 @@ int main(void) /* string dataset and attribute. HDFFV-10028 */ test_objs_strings(DIFF_STRINGS1, DIFF_STRINGS2); + /* double dataset and epsilion. HDFFV-10897 */ + test_double_epsilon(DIFF_EPS1, DIFF_EPS2); + return EXIT_SUCCESS; } @@ -300,13 +310,13 @@ int main(void) *------------------------------------------------------------------------- */ -static -int test_basic(const char *fname1, const char *fname2, const char *fname3) +static int +test_basic(const char *fname1, const char *fname2, const char *fname3) { - hid_t fid1 = -1, fid2 = -1; - hid_t gid1 = -1, gid2 = -1, gid3 = -1; - hsize_t dims1[1] = { 6 }; - hsize_t dims2[2] = { 3, 2 }; + hid_t fid1 = H5I_INVALID_HID, fid2 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID, gid2 = H5I_INVALID_HID, gid3 = H5I_INVALID_HID; + hsize_t dims1[1] = {6}; + hsize_t dims2[2] = {3, 2}; /* create the empty file */ if ((fid1 = H5Fcreate(fname3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { @@ -319,9 +329,9 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) } /*------------------------------------------------------------------------- - * create two files - *------------------------------------------------------------------------- - */ + * create two files + *------------------------------------------------------------------------- + */ if ((fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; @@ -329,190 +339,170 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) goto out; /*------------------------------------------------------------------------- - * create groups - *------------------------------------------------------------------------- - */ + * create groups + *------------------------------------------------------------------------- + */ gid1 = H5Gcreate2(fid1, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); gid2 = H5Gcreate2(fid2, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); gid3 = H5Gcreate2(fid2, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * tests: - * # 1.1 normal mode - * # 1.2 normal mode with objects - * # 1.3 report mode - * # 1.4 report mode with objects - * # 1.5 with -d - *------------------------------------------------------------------------- - */ + * tests: + * # 1.1 normal mode + * # 1.2 normal mode with objects + * # 1.3 report mode + * # 1.4 report mode with objects + * # 1.5 with -d + *------------------------------------------------------------------------- + */ { - double data1[3][2] = - { { 1.0F, 1.0F }, { 1.00F, 1.000F }, { 0.0F, 0.0F } }; - double data2[3][2] = - { { 0.0F, 1.1F }, { 1.01F, 1.001F }, { 0.0F, 1.0F } }; - double data3[3][2] = { { 100.0F, 100.0F }, { 100.00F, 100.000F }, { - 100.0F, 100.0F } }; - double data4[3][2] = { { 105.0F, 120.0F }, { 160.00F, 95.000F }, { - 80.0F, 40.0F } }; + double data1[3][2] = {{1.0, 1.0}, {1.00, 1.000}, {0.0, 0.0}}; + double data2[3][2] = {{0.0, 1.1}, {1.01, 1.001}, {0.0, 1.0}}; + double data3[3][2] = {{100.0, 100.0}, {100.00, 100.000}, {100.0, 100.0}}; + double data4[3][2] = {{105.0, 120.0}, {160.00, 95.000}, {80.0, 40.0}}; write_dset(gid1, 2, dims2, "dset1", H5T_NATIVE_DOUBLE, data1); write_dset(gid2, 2, dims2, "dset2", H5T_NATIVE_DOUBLE, data2); write_dset(gid1, 2, dims2, "dset3", H5T_NATIVE_DOUBLE, data3); write_dset(gid2, 2, dims2, "dset4", H5T_NATIVE_DOUBLE, data4); write_dset(gid2, 2, dims2, "dset1", H5T_NATIVE_DOUBLE, data2); - } /*------------------------------------------------------------------------- - * relative error, compare divide by zero, both zero - * # 1.6.1 with -p (int) - *------------------------------------------------------------------------- - */ + * relative error, compare divide by zero, both zero + * # 1.6.1 with -p (int) + *------------------------------------------------------------------------- + */ { - int data5[3][2] = { { 100, 100 }, { 100, 0 }, { 0, 100 } }; - int data6[3][2] = { { 120, 80 }, { 0, 100 }, { 0, 50 } }; + int data5[3][2] = {{100, 100}, {100, 0}, {0, 100}}; + int data6[3][2] = {{120, 80}, {0, 100}, {0, 50}}; write_dset(gid1, 2, dims2, "dset5", H5T_NATIVE_INT, data5); write_dset(gid1, 2, dims2, "dset6", H5T_NATIVE_INT, data6); - } /*------------------------------------------------------------------------- - * relative error, compare divide by zero, both zero - * # 1.6.2 with -p (unsigned long long) - *------------------------------------------------------------------------- - */ + * relative error, compare divide by zero, both zero + * # 1.6.2 with -p (unsigned long long) + *------------------------------------------------------------------------- + */ { - unsigned long long data7[3][2] = - { { 100, 100 }, { 100, 0 }, { 0, 100 } }; - unsigned long long data8[3][2] = { { 120, 80 }, { 0, 100 }, { 0, 50 } }; + unsigned long long data7[3][2] = {{100, 100}, {100, 0}, {0, 100}}; + unsigned long long data8[3][2] = {{120, 80}, {0, 100}, {0, 50}}; write_dset(gid1, 2, dims2, "dset7", H5T_NATIVE_ULLONG, data7); write_dset(gid1, 2, dims2, "dset8", H5T_NATIVE_ULLONG, data8); - } /*------------------------------------------------------------------------- - * relative error, compare divide by zero, both zero - * # 1.6.3 with -p (double) - * - * A B 1-B/A % - * 100 120 0.2 20 - * 100 80 0.2 20 - * 100 0 1 100 - * 0 100 #DIV/0! #DIV/0! - * 0 0 #DIV/0! #DIV/0! - * 100 50 0.5 50 - *------------------------------------------------------------------------- - */ + * relative error, compare divide by zero, both zero + * # 1.6.3 with -p (double) + * + * A B 1-B/A % + * 100 120 0.2 20 + * 100 80 0.2 20 + * 100 0 1 100 + * 0 100 #DIV/0! #DIV/0! + * 0 0 #DIV/0! #DIV/0! + * 100 50 0.5 50 + *------------------------------------------------------------------------- + */ { - double data9[3][2] = { { 100.0F, 100.0F }, { 100.0F, 0.0F }, { 0.0F, - 100.0F } }; - double data10[3][2] = { { 120.0F, 80.0F }, { 0.0F, 100.0F }, { 0.0F, - 50.0F } }; + double data9[3][2] = {{100.0, 100.0}, {100.0, 0.0}, {0.0, 100.0}}; + double data10[3][2] = {{120.0, 80.0}, {0.0, 100.0}, {0.0, 50.0}}; write_dset(gid1, 2, dims2, "dset9", H5T_NATIVE_DOUBLE, data9); write_dset(gid1, 2, dims2, "dset10", H5T_NATIVE_DOUBLE, data10); - } /*------------------------------------------------------------------------- - * test floating point comparison - *------------------------------------------------------------------------- - */ + * test floating point comparison + *------------------------------------------------------------------------- + */ { /* epsilon = 0.0000001 = 1e-7 - * system epsilon for float : FLT_EPSILON = 1.19209E-07 - */ - float data11[3][2] = { { 0.000000f, 0.0000001f }, { 0.0000001f, - 0.00000022f }, { 0.0000001f, 0.0000001f } }; - float data12[3][2] = { { 0.000000f, 0.0000002f }, { 0.0000003f, - 0.0000001f }, { 0.000000f, 0.0000001f } }; + * system epsilon for float : FLT_EPSILON = 1.19209E-07 + */ + float data11[3][2] = {{0.000000f, 0.0000001f}, {0.0000001f, 0.00000022f}, {0.0000001f, 0.0000001f}}; + float data12[3][2] = {{0.000000f, 0.0000002f}, {0.0000003f, 0.0000001f}, {0.000000f, 0.0000001f}}; /* epsilon = 0.0000000000000001 = 1e-16 - * system epsilon for double : DBL_EPSILON = 2.22045E-16 - */ - double data13[3][2] = { { H5_DOUBLE(0.0000000000000000), H5_DOUBLE( - 0.0000000000000001) }, { H5_DOUBLE(0.0000000000000001), - H5_DOUBLE(0.0000000000000000) }, { H5_DOUBLE( - 0.00000000000000033), H5_DOUBLE(0.0000000000000001) } }; - double data14[3][2] = { { H5_DOUBLE(0.0000000000000000), H5_DOUBLE( - 0.0000000000000004) }, { H5_DOUBLE(0.0000000000000002), - H5_DOUBLE(0.0000000000000001) }, { H5_DOUBLE( - 0.0000000000000001), H5_DOUBLE(0.00000000000000000) } }; + * system epsilon for double : DBL_EPSILON = 2.22045E-16 + */ + double data13[3][2] = {{0.0000000000000000, 0.0000000000000001}, + {0.0000000000000001, 0.0000000000000000}, + {0.00000000000000033, 0.0000000000000001}}; + double data14[3][2] = {{0.0000000000000000, 0.0000000000000004}, + {0.0000000000000002, 0.0000000000000001}, + {0.0000000000000001, 0.00000000000000000}}; write_dset(gid1, 2, dims2, "fp1", H5T_NATIVE_FLOAT, data11); write_dset(gid1, 2, dims2, "fp2", H5T_NATIVE_FLOAT, data12); write_dset(gid1, 2, dims2, "d1", H5T_NATIVE_DOUBLE, data13); write_dset(gid1, 2, dims2, "d2", H5T_NATIVE_DOUBLE, data14); - } -#if H5_SIZEOF_LONG_DOUBLE !=0 { /*------------------------------------------------------------------------- - * H5T_NATIVE_LDOUBLE - *------------------------------------------------------------------------- - */ - - long double data15[3][2] = { {1.0L,1.0L}, {1.0L,1.0L}, {1.0L,1.0L}}; + * H5T_NATIVE_LDOUBLE + *------------------------------------------------------------------------- + */ - write_dset(gid1,2,dims2,"ld",H5T_NATIVE_LDOUBLE,data15); + long double data15[3][2] = {{1.0L, 1.0L}, {1.0L, 1.0L}, {1.0L, 1.0L}}; + write_dset(gid1, 2, dims2, "ld", H5T_NATIVE_LDOUBLE, data15); } -#endif /*------------------------------------------------------------------------- - * NaNs in H5T_NATIVE_FLOAT - *------------------------------------------------------------------------- - */ + * NaNs in H5T_NATIVE_FLOAT + *------------------------------------------------------------------------- + */ { float data15[6]; float data16[6]; - data15[0] = (float) HDsqrt(-1.0F); - data15[1] = 1.0F; - data15[2] = (float) HDsqrt(-1.0F); - data15[3] = 1.0F; - data15[4] = 1.0F; - data15[5] = 1.0F; + data15[0] = (float)HDsqrt(-1.0); + data15[1] = 1.0; + data15[2] = (float)HDsqrt(-1.0); + data15[3] = 1.0; + data15[4] = 1.0; + data15[5] = 1.0; - data16[0] = (float) HDsqrt(-1.0F); - data16[1] = (float) HDsqrt(-1.0F); - data16[2] = 1.0F; - data16[3] = 1.0F; - data16[4] = 1.0F; - data16[5] = 1.0F; + data16[0] = (float)HDsqrt(-1.0); + data16[1] = (float)HDsqrt(-1.0); + data16[2] = 1.0; + data16[3] = 1.0; + data16[4] = 1.0; + data16[5] = 1.0; write_dset(gid1, 1, dims1, "fp15", H5T_NATIVE_FLOAT, data15); write_dset(gid1, 1, dims1, "fp16", H5T_NATIVE_FLOAT, data16); - } /*------------------------------------------------------------------------- - * NaNs in H5T_NATIVE_DOUBLE - *------------------------------------------------------------------------- - */ + * NaNs in H5T_NATIVE_DOUBLE + *------------------------------------------------------------------------- + */ { double data17[6]; double data18[6]; - data17[0] = HDsqrt(-1.0F); - data17[1] = 1.0F; - data17[2] = HDsqrt(-1.0F); - data17[3] = 1.0F; - data17[4] = 1.0F; - data17[5] = 1.0F; + data17[0] = HDsqrt(-1.0); + data17[1] = 1.0; + data17[2] = HDsqrt(-1.0); + data17[3] = 1.0; + data17[4] = 1.0; + data17[5] = 1.0; - data18[0] = HDsqrt(-1.0F); - data18[1] = HDsqrt(-10000.0F); - data18[2] = 1.0F; - data18[3] = 1.0F; - data18[4] = 1.0F; - data18[5] = 1.0F; + data18[0] = HDsqrt(-1.0); + data18[1] = HDsqrt(-10000.0); + data18[2] = 1.0; + data18[3] = 1.0; + data18[4] = 1.0; + data18[5] = 1.0; write_dset(gid1, 1, dims1, "fp17", H5T_NATIVE_DOUBLE, data17); write_dset(gid1, 1, dims1, "fp18", H5T_NATIVE_DOUBLE, data18); @@ -520,18 +510,18 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) } /*------------------------------------------------------------------------ - * INFINITY values - *------------------------------------------------------------------------ - */ + * INFINITY values + *------------------------------------------------------------------------ + */ { - float data19[6]; + float data19[6]; double data20[6]; - data19[0] = data19[1] = data19[2] = (float) HDlog(0.0F); - data19[3] = data19[4] = data19[5] = (float) -HDlog(0.0F); + data19[0] = data19[1] = data19[2] = (float)HDlog(0.0); + data19[3] = data19[4] = data19[5] = (float)-HDlog(0.0); - data20[0] = data20[1] = data20[2] = HDlog(0.0F); - data20[3] = data20[4] = data20[5] = -HDlog(0.0F); + data20[0] = data20[1] = data20[2] = HDlog(0.0); + data20[3] = data20[4] = data20[5] = -HDlog(0.0); write_dset(gid1, 1, dims1, "fp19", H5T_NATIVE_FLOAT, data19); write_dset(gid1, 1, dims1, "fp19_COPY", H5T_NATIVE_FLOAT, data19); @@ -540,39 +530,38 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) } /*------------------------------------------------------------------------- - * NaNs in H5T_NATIVE_DOUBLE and H5T_NATIVE_FLOAT inside H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * NaNs in H5T_NATIVE_DOUBLE and H5T_NATIVE_FLOAT inside H5T_COMPOUND + *------------------------------------------------------------------------- + */ { typedef struct cmp1_t { double d; - float f; + float f; } cmp1_t; - cmp1_t buf1[2]; - cmp1_t buf2[2]; - hsize_t dims[1] = { 2 }; - size_t type_size; - hid_t tid; + cmp1_t buf1[2]; + cmp1_t buf2[2]; + hsize_t dims[1] = {2}; + size_t type_size; + hid_t tid; - buf1[0].d = HDsqrt(-1.0F); - buf1[0].f = (float) HDsqrt(-1.0F); - buf2[0].d = HDsqrt(-1.0F); - buf2[0].f = (float) HDsqrt(-1.0F); + buf1[0].d = HDsqrt(-1.0); + buf1[0].f = (float)HDsqrt(-1.0); + buf2[0].d = HDsqrt(-1.0); + buf2[0].f = (float)HDsqrt(-1.0); - buf1[1].d = HDsqrt(-1.0F); - buf1[1].f = (float) HDsqrt(-1.0F); - buf2[1].d = 0.0F; - buf2[1].f = 0.0F; + buf1[1].d = HDsqrt(-1.0); + buf1[1].f = (float)HDsqrt(-1.0); + buf2[1].d = 0.0; + buf2[1].f = 0.0; type_size = sizeof(cmp1_t); - tid = H5Tcreate(H5T_COMPOUND, type_size); + tid = H5Tcreate(H5T_COMPOUND, type_size); H5Tinsert(tid, "d", HOFFSET(cmp1_t, d), H5T_NATIVE_DOUBLE); H5Tinsert(tid, "f", HOFFSET(cmp1_t, f), H5T_NATIVE_FLOAT); write_dset(gid1, 1, dims, "dset11", tid, buf1); write_dset(gid1, 1, dims, "dset12", tid, buf2); H5Tclose(tid); - } /* not comparable objects */ @@ -580,11 +569,11 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) typedef struct cmp1_t { double d; - int i; + int i; } cmp1_t; typedef struct cmp2_t { - int i; + int i; double d; } cmp2_t; @@ -592,17 +581,17 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) int i; } cmp3_t; - double data2[6] = { 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F }; - int data3[6] = { 0, 0, 0, 0, 0, 0 }; - int data4[3][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 } }; - int data5[2][2] = { { 0, 0 }, { 0, 0 } }; - unsigned int data6[3][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 } }; - cmp1_t data7[1] = { { 1.0f, 2 } }; - cmp2_t data8[1] = { { 1, 2.0f } }; - hsize_t dims3[2] = { 2, 2 }; - hsize_t dims4[1] = { 1 }; - size_t type_size; - hid_t tid; + double data2[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + int data3[6] = {0, 0, 0, 0, 0, 0}; + int data4[3][2] = {{0, 0}, {0, 0}, {0, 0}}; + int data5[2][2] = {{0, 0}, {0, 0}}; + unsigned int data6[3][2] = {{0, 0}, {0, 0}, {0, 0}}; + cmp1_t data7[1] = {{1.0, 2}}; + cmp2_t data8[1] = {{1, 2.0}}; + hsize_t dims3[2] = {2, 2}; + hsize_t dims4[1] = {1}; + size_t type_size; + hid_t tid; write_dset(gid3, 1, dims1, "dset1", H5T_NATIVE_DOUBLE, NULL); write_dset(gid3, 1, dims1, "dset2", H5T_NATIVE_DOUBLE, data2); @@ -613,14 +602,14 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) /* case of compound with different type members */ type_size = sizeof(cmp1_t); - tid = H5Tcreate(H5T_COMPOUND, type_size); + tid = H5Tcreate(H5T_COMPOUND, type_size); H5Tinsert(tid, "d", HOFFSET(cmp1_t, d), H5T_NATIVE_DOUBLE); H5Tinsert(tid, "i", HOFFSET(cmp1_t, i), H5T_NATIVE_INT); write_dset(gid3, 1, dims4, "dset7", tid, data7); H5Tclose(tid); type_size = sizeof(cmp2_t); - tid = H5Tcreate(H5T_COMPOUND, type_size); + tid = H5Tcreate(H5T_COMPOUND, type_size); H5Tinsert(tid, "i", HOFFSET(cmp2_t, i), H5T_NATIVE_INT); H5Tinsert(tid, "d", HOFFSET(cmp2_t, d), H5T_NATIVE_DOUBLE); write_dset(gid3, 1, dims4, "dset8", tid, data8); @@ -628,17 +617,16 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) /* case of compound with different number of members */ type_size = sizeof(cmp3_t); - tid = H5Tcreate(H5T_COMPOUND, type_size); + tid = H5Tcreate(H5T_COMPOUND, type_size); H5Tinsert(tid, "i", HOFFSET(cmp2_t, i), H5T_NATIVE_INT); write_dset(gid3, 1, dims4, "dset9", tid, NULL); H5Tclose(tid); - } /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ + * close + *------------------------------------------------------------------------- + */ H5Gclose(gid1); H5Gclose(gid2); H5Gclose(gid3); @@ -659,18 +647,18 @@ out: * *------------------------------------------------------------------------- */ -static -int test_types(const char *fname) +static int +test_types(const char *fname) { - hid_t fid1 = -1; - hid_t gid1 = -1; - hid_t gid2 = -1; - hid_t tid1 = -1; - hid_t tid2 = -1; - herr_t status; - hsize_t dims[1] = { 1 }; + hid_t fid1 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hid_t tid1 = H5I_INVALID_HID; + hid_t tid2 = H5I_INVALID_HID; + herr_t status; + hsize_t dims[1] = {1}; typedef struct s1_t { - int a; + int a; float b; } s1_t; typedef struct s2_t { @@ -678,30 +666,30 @@ int test_types(const char *fname) } s2_t; /*------------------------------------------------------------------------- - * Create one file - *------------------------------------------------------------------------- - */ + * Create one file + *------------------------------------------------------------------------- + */ fid1 = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * H5G_DATASET - *------------------------------------------------------------------------- - */ + * H5G_DATASET + *------------------------------------------------------------------------- + */ write_dset(fid1, 1, dims, "dset", H5T_NATIVE_INT, 0); /*------------------------------------------------------------------------- - * H5G_GROUP - *------------------------------------------------------------------------- - */ - gid1 = H5Gcreate2(fid1, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * H5G_GROUP + *------------------------------------------------------------------------- + */ + gid1 = H5Gcreate2(fid1, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Gclose(gid1); - gid2 = H5Gcreate2(fid1, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + gid2 = H5Gcreate2(fid1, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Gclose(gid2); /*------------------------------------------------------------------------- - * H5G_TYPE - *------------------------------------------------------------------------- - */ + * H5G_TYPE + *------------------------------------------------------------------------- + */ /* create and commit datatype 1 */ tid1 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); @@ -716,25 +704,25 @@ int test_types(const char *fname) H5Tclose(tid2); /*------------------------------------------------------------------------- - * H5G_LINK - *------------------------------------------------------------------------- - */ + * H5G_LINK + *------------------------------------------------------------------------- + */ status = H5Lcreate_soft("g1", fid1, "l1", H5P_DEFAULT, H5P_DEFAULT); status = H5Lcreate_soft("g2", fid1, "l2", H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * H5G_UDLINK - *------------------------------------------------------------------------- - */ + * H5G_UDLINK + *------------------------------------------------------------------------- + */ H5Lcreate_external("filename", "objname", fid1, "ext_link", H5P_DEFAULT, H5P_DEFAULT); H5Lregister(UD_link_class); - H5Lcreate_ud(fid1, "ud_link", (H5L_type_t) MY_LINKCLASS, NULL, (size_t) 0, H5P_DEFAULT, H5P_DEFAULT); + H5Lcreate_ud(fid1, "ud_link", (H5L_type_t)MY_LINKCLASS, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * Close - *------------------------------------------------------------------------- - */ + * Close + *------------------------------------------------------------------------- + */ status = H5Fclose(fid1); return status; } @@ -784,138 +772,138 @@ int test_types(const char *fname) * *------------------------------------------------------------------------- */ -static -int test_datatypes(const char *fname) +static int +test_datatypes(const char *fname) { - hid_t fid1 = -1; - hid_t dset = -1; - hsize_t dims[2] = { 3, 2 }; - herr_t status; - char buf1a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - char buf1b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; - short buf2a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - short buf2b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; - int buf3a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - int buf3b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; - long buf4a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - long buf4b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; - float buf5a[3][2] = { { 1.0F, 1.0F }, { 1.0F, 1.0F }, { 1.0F, 1.0F } }; - float buf5b[3][2] = { { 1.0F, 1.0F }, { 3.0F, 4.0F }, { 5.0F, 6.0F } }; - double buf6a[3][2] = { { 1.0F, 1.0F }, { 1.0F, 1.0F }, { 1.0F, 1.0F } }; - double buf6b[3][2] = { { 1.0F, 1.0F }, { 3.0F, 4.0F }, { 5.0F, 6.0F } }; + hid_t fid1 = H5I_INVALID_HID; + hid_t dset = H5I_INVALID_HID; + hsize_t dims[2] = {3, 2}; + herr_t status; + char buf1a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + char buf1b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; + short buf2a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + short buf2b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; + int buf3a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + int buf3b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; + long buf4a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + long buf4b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; + float buf5a[3][2] = {{1.0, 1.0}, {1.0, 1.0}, {1.0, 1.0}}; + float buf5b[3][2] = {{1.0, 1.0}, {3.0, 4.0}, {5.0, 6.0}}; + double buf6a[3][2] = {{1.0, 1.0}, {1.0, 1.0}, {1.0, 1.0}}; + double buf6b[3][2] = {{1.0, 1.0}, {3.0, 4.0}, {5.0, 6.0}}; /*unsigned/signed test signed char -128 to 127 unsigned char 0 to 255 */ - char buf7a[3][2] = { { -1, -128 }, { -1, -1 }, { -1, -1 } }; - unsigned char buf7b[3][2] = { { 1, 128 }, { 1, 1 }, { 1, 1 } }; + char buf7a[3][2] = {{-1, -128}, {-1, -1}, {-1, -1}}; + unsigned char buf7b[3][2] = {{1, 128}, {1, 1}, {1, 1}}; /* long long test */ - long long buf8a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - long long buf8b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; - unsigned long long buf9a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - unsigned long long buf9b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; + long long buf8a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + long long buf8b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; + unsigned long long buf9a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + unsigned long long buf9b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; - unsigned int buf10a[3][2] = { { UIMAX, 1 }, { 1, 1 }, { 1, 1 } }; - unsigned int buf10b[3][2] = { { UIMAX - 1, 1 }, { 3, 4 }, { 5, 6 } }; + unsigned int buf10a[3][2] = {{UIMAX, 1}, {1, 1}, {1, 1}}; + unsigned int buf10b[3][2] = {{UIMAX - 1, 1}, {3, 4}, {5, 6}}; - unsigned short buf11a[3][2] = { { 204, 205 }, { 2, 3 }, { 1, 1 } }; - unsigned int buf11b[3][2] = { { 204, 205 }, { 2, 3 }, { 1, 1 } }; + unsigned short buf11a[3][2] = {{204, 205}, {2, 3}, {1, 1}}; + unsigned int buf11b[3][2] = {{204, 205}, {2, 3}, {1, 1}}; /*------------------------------------------------------------------------- - * Create a file - *------------------------------------------------------------------------- - */ + * Create a file + *------------------------------------------------------------------------- + */ fid1 = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * Check for different storage order. Give a warning if they are different - *------------------------------------------------------------------------- - */ + * Check for different storage order. Give a warning if they are different + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset0a", H5T_STD_I16LE, buf2a); write_dset(fid1, 2, dims, "dset0b", H5T_STD_I32LE, buf3b); /*------------------------------------------------------------------------- - * H5T_NATIVE_CHAR - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_CHAR + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset1a", H5T_NATIVE_CHAR, buf1a); write_dset(fid1, 2, dims, "dset1b", H5T_NATIVE_CHAR, buf1b); /*------------------------------------------------------------------------- - * H5T_NATIVE_SHORT - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_SHORT + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset2a", H5T_NATIVE_SHORT, buf2a); write_dset(fid1, 2, dims, "dset2b", H5T_NATIVE_SHORT, buf2b); /*------------------------------------------------------------------------- - * H5T_NATIVE_INT - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_INT + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset3a", H5T_NATIVE_INT, buf3a); write_dset(fid1, 2, dims, "dset3b", H5T_NATIVE_INT, buf3b); /*------------------------------------------------------------------------- - * H5T_NATIVE_LONG - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_LONG + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset4a", H5T_NATIVE_LONG, buf4a); write_dset(fid1, 2, dims, "dset4b", H5T_NATIVE_LONG, buf4b); /*------------------------------------------------------------------------- - * H5T_NATIVE_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_FLOAT + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset5a", H5T_NATIVE_FLOAT, buf5a); write_dset(fid1, 2, dims, "dset5b", H5T_NATIVE_FLOAT, buf5b); /*------------------------------------------------------------------------- - * H5T_NATIVE_DOUBLE - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_DOUBLE + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset6a", H5T_NATIVE_DOUBLE, buf6a); write_dset(fid1, 2, dims, "dset6b", H5T_NATIVE_DOUBLE, buf6b); /*------------------------------------------------------------------------- - * H5T_NATIVE_CHAR and H5T_NATIVE_UCHAR - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_CHAR and H5T_NATIVE_UCHAR + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset7a", H5T_NATIVE_CHAR, buf7a); write_dset(fid1, 2, dims, "dset7b", H5T_NATIVE_UCHAR, buf7b); /*------------------------------------------------------------------------- - * H5T_NATIVE_LLONG - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_LLONG + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset8a", H5T_NATIVE_LLONG, buf8a); write_dset(fid1, 2, dims, "dset8b", H5T_NATIVE_LLONG, buf8b); /*------------------------------------------------------------------------- - * H5T_NATIVE_ULLONG - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_ULLONG + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset9a", H5T_NATIVE_ULLONG, buf9a); write_dset(fid1, 2, dims, "dset9b", H5T_NATIVE_ULLONG, buf9b); /*------------------------------------------------------------------------- - * H5T_NATIVE_INT - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_INT + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset10a", H5T_NATIVE_UINT, buf10a); write_dset(fid1, 2, dims, "dset10b", H5T_NATIVE_UINT, buf10b); /*------------------------------------------------------------------------- - * Same type class, different size - *------------------------------------------------------------------------- - */ + * Same type class, different size + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset11a", H5T_STD_U16LE, buf11a); dset = H5Dopen2(fid1, "dset11a", H5P_DEFAULT); write_attr(dset, 2, dims, "attr", H5T_STD_U16LE, buf11a); @@ -927,9 +915,9 @@ int test_datatypes(const char *fname) H5Dclose(dset); /*------------------------------------------------------------------------- - * Close - *------------------------------------------------------------------------- - */ + * Close + *------------------------------------------------------------------------- + */ status = H5Fclose(fid1); return status; } @@ -974,44 +962,44 @@ int test_datatypes(const char *fname) * *------------------------------------------------------------------------- */ -static -int test_attributes(const char *file, int make_diffs /* flag to modify data buffers */) +static int +test_attributes(const char *file, int make_diffs /* flag to modify data buffers */) { - hid_t fid = -1; - hid_t did = -1; - hid_t gid = -1; - hid_t root_id = -1; - hid_t sid = -1; - hsize_t dims[1] = { 2 }; - herr_t status; + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t root_id = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hsize_t dims[1] = {2}; + herr_t status; /* Create a file */ if ((fid = H5Fcreate(file, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; /* Create a 1D dataset */ - sid = H5Screate_simple(1, dims, NULL); - did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Sclose(sid); assert(status >= 0); /* Create groups */ - gid = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + gid = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); root_id = H5Gopen2(fid, "/", H5P_DEFAULT); /*------------------------------------------------------------------------- - * write a series of attributes on the dataset, group, and root group - *------------------------------------------------------------------------- - */ + * write a series of attributes on the dataset, group, and root group + *------------------------------------------------------------------------- + */ if (make_diffs > 1) { write_attr_strings(did, "dset", fid, make_diffs); - write_attr_strings(gid, NULL, (hid_t) 0, make_diffs); - write_attr_strings(root_id, NULL, (hid_t) 0, make_diffs); + write_attr_strings(gid, NULL, (hid_t)0, make_diffs); + write_attr_strings(root_id, NULL, (hid_t)0, make_diffs); } else { write_attr_in(did, "dset", fid, make_diffs); - write_attr_in(gid, NULL, (hid_t) 0, make_diffs); - write_attr_in(root_id, NULL, (hid_t) 0, make_diffs); + write_attr_in(gid, NULL, (hid_t)0, make_diffs); + write_attr_in(root_id, NULL, (hid_t)0, make_diffs); } /* Close */ @@ -1036,34 +1024,35 @@ int test_attributes(const char *file, int make_diffs /* flag to modify data buff * *------------------------------------------------------------------------- */ -static int test_attributes_verbose_level(const char *fname1, const char *fname2) +static int +test_attributes_verbose_level(const char *fname1, const char *fname2) { herr_t status = SUCCEED; - hid_t fid1 = -1, fid2 = -1; - hid_t f1_gid = -1, f2_gid = -1; - hid_t f1_gid2 = -1, f2_gid2 = -1; - hid_t f1_gid3 = -1, f2_gid3 = -1; - hid_t f1_gid4 = -1, f2_gid4 = -1; - hid_t f1_did = -1, f2_did = -1; - hid_t f1_sid = -1, f2_sid = -1; - hid_t f1_tid = -1, f2_tid = -1; + hid_t fid1 = H5I_INVALID_HID, fid2 = H5I_INVALID_HID; + hid_t f1_gid = H5I_INVALID_HID, f2_gid = H5I_INVALID_HID; + hid_t f1_gid2 = H5I_INVALID_HID, f2_gid2 = H5I_INVALID_HID; + hid_t f1_gid3 = H5I_INVALID_HID, f2_gid3 = H5I_INVALID_HID; + hid_t f1_gid4 = H5I_INVALID_HID, f2_gid4 = H5I_INVALID_HID; + hid_t f1_did = H5I_INVALID_HID, f2_did = H5I_INVALID_HID; + hid_t f1_sid = H5I_INVALID_HID, f2_sid = H5I_INVALID_HID; + hid_t f1_tid = H5I_INVALID_HID, f2_tid = H5I_INVALID_HID; /* dset */ - hsize_t dset_dims[1] = { 3 }; - int dset_data[3] = { 0, 1, 2 }; + hsize_t dset_dims[1] = {3}; + int dset_data[3] = {0, 1, 2}; /* common attrs dim */ - hsize_t attr_dims[1] = { 2 }; + hsize_t attr_dims[1] = {2}; /* file1 attr */ - int f1_attr_idata[2] = { 1, 2 }; /* integer */ - float f1_attr_fdata[2] = { 1.1F, 2.2F }; /* float */ + int f1_attr_idata[2] = {1, 2}; /* integer */ + float f1_attr_fdata[2] = {1.1F, 2.2F}; /* float */ /* file2 attr */ - int f2_attr_idata[2] = { 2, 3 }; /* integer */ - float f2_attr_fdata[2] = { 2.1F, 3.2F }; /* float */ + int f2_attr_idata[2] = {2, 3}; /* integer */ + float f2_attr_fdata[2] = {2.1F, 3.2F}; /* float */ /*---------------------------------------------------------------------- - * Create file1 - *-----------------------------------------------------------------------*/ + * Create file1 + *-----------------------------------------------------------------------*/ if ((fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); status = FAIL; @@ -1071,8 +1060,8 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) } /*---------------------------------- - * Groups - */ + * Groups + */ f1_gid = H5Gcreate2(fid1, "g", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f1_gid < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); @@ -1102,8 +1091,8 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) } /*---------------------------------- - * Datasets - */ + * Datasets + */ f1_sid = H5Screate_simple(1, dset_dims, NULL); f1_did = H5Dcreate2(fid1, "dset", H5T_NATIVE_INT, f1_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f1_did == FAIL) { @@ -1119,8 +1108,8 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) } /*---------------------------------- - * Named Datatype - */ + * Named Datatype + */ f1_tid = H5Tcopy(H5T_NATIVE_INT); status = H5Tcommit2(fid1, "ntype", f1_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -1130,8 +1119,8 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) } /*---------------------------------------------------------------------- - * Create file2 - *-----------------------------------------------------------------------*/ + * Create file2 + *-----------------------------------------------------------------------*/ if ((fid2 = H5Fcreate(fname2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); status = FAIL; @@ -1139,8 +1128,8 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) } /*---------------------------------- - * Groups - */ + * Groups + */ f2_gid = H5Gcreate2(fid2, "g", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f2_gid < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); @@ -1170,8 +1159,8 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) } /*---------------------------------- - * Datasets - */ + * Datasets + */ f2_sid = H5Screate_simple(1, dset_dims, NULL); f2_did = H5Dcreate2(fid2, "dset", H5T_NATIVE_INT, f2_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f2_did == FAIL) { @@ -1187,8 +1176,8 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) } /*---------------------------------- - * Named Datatype - */ + * Named Datatype + */ f2_tid = H5Tcopy(H5T_NATIVE_INT); status = H5Tcommit2(fid2, "ntype", f2_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -1198,9 +1187,9 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) } /*---------------------------------- - * CASE1 - Same attr number, all Same attr name - * add attr to group - */ + * CASE1 - Same attr number, all Same attr name + * add attr to group + */ write_attr(f1_gid, 1, attr_dims, "integer1", H5T_NATIVE_INT, f1_attr_idata); write_attr(f1_gid, 1, attr_dims, "float1", H5T_NATIVE_FLOAT, f1_attr_fdata); @@ -1208,9 +1197,9 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) write_attr(f2_gid, 1, attr_dims, "float1", H5T_NATIVE_FLOAT, f2_attr_fdata); /*---------------------------------- - * CASE2 - Same attr number, some Same attr name - * add attr to dset - */ + * CASE2 - Same attr number, some Same attr name + * add attr to dset + */ write_attr(f1_did, 1, attr_dims, "integer1", H5T_NATIVE_INT, f1_attr_idata); write_attr(f1_did, 1, attr_dims, "float2", H5T_NATIVE_FLOAT, f1_attr_fdata); @@ -1218,9 +1207,9 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) write_attr(f2_did, 1, attr_dims, "float3", H5T_NATIVE_FLOAT, f2_attr_fdata); /*---------------------------------- - * CASE3 - Same attr number, all different attr name - * add attr to ntype - */ + * CASE3 - Same attr number, all different attr name + * add attr to ntype + */ write_attr(f1_tid, 1, attr_dims, "integer1", H5T_NATIVE_INT, f1_attr_idata); write_attr(f1_tid, 1, attr_dims, "float2", H5T_NATIVE_FLOAT, f1_attr_fdata); write_attr(f1_tid, 1, attr_dims, "float3", H5T_NATIVE_FLOAT, f1_attr_fdata); @@ -1230,9 +1219,9 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) write_attr(f2_tid, 1, attr_dims, "float6", H5T_NATIVE_FLOAT, f2_attr_fdata); /*---------------------------------- - * CASE4 - Different attr number, some same attr name (vs file2-g2) - * add attr to g2 - */ + * CASE4 - Different attr number, some same attr name (vs file2-g2) + * add attr to g2 + */ write_attr(f1_gid2, 1, attr_dims, "integer1", H5T_NATIVE_INT, f1_attr_idata); write_attr(f1_gid2, 1, attr_dims, "float2", H5T_NATIVE_FLOAT, f1_attr_fdata); write_attr(f1_gid2, 1, attr_dims, "float3", H5T_NATIVE_FLOAT, f1_attr_fdata); @@ -1241,9 +1230,9 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) write_attr(f2_gid2, 1, attr_dims, "float2", H5T_NATIVE_FLOAT, f2_attr_fdata); /*---------------------------------- - * CASE5 - Different attr number, all different attr name - * add attr to g3 - */ + * CASE5 - Different attr number, all different attr name + * add attr to g3 + */ write_attr(f1_gid3, 1, attr_dims, "integer10", H5T_NATIVE_INT, f1_attr_idata); write_attr(f1_gid3, 1, attr_dims, "float11", H5T_NATIVE_FLOAT, f1_attr_fdata); write_attr(f1_gid3, 1, attr_dims, "float12", H5T_NATIVE_FLOAT, f1_attr_fdata); @@ -1253,8 +1242,8 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1 > 0) H5Fclose(fid1); if (fid2 > 0) @@ -1301,16 +1290,16 @@ out: * *------------------------------------------------------------------------- */ -static -int test_datasets(const char *file, int make_diffs /* flag to modify data buffers */) +static int +test_datasets(const char *file, int make_diffs /* flag to modify data buffers */) { - hid_t fid = -1; - hid_t did = -1; - hid_t gid = -1; - hid_t sid = -1; - hsize_t dims[1] = { 2 }; - herr_t status; - int buf[2] = { 1, 2 }; + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hsize_t dims[1] = {2}; + herr_t status; + int buf[2] = {1, 2}; if (make_diffs > 0) memset(buf, 0, sizeof buf); @@ -1320,8 +1309,8 @@ int test_datasets(const char *file, int make_diffs /* flag to modify data buffer return -1; /* Create a 1D dataset */ - sid = H5Screate_simple(1, dims, NULL); - did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); status = H5Sclose(sid); assert(status >= 0); @@ -1330,9 +1319,9 @@ int test_datasets(const char *file, int make_diffs /* flag to modify data buffer gid = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * write a series of datasets on the group - *------------------------------------------------------------------------- - */ + * write a series of datasets on the group + *------------------------------------------------------------------------- + */ write_dset_in(gid, "/dset", fid, make_diffs); @@ -1354,16 +1343,16 @@ int test_datasets(const char *file, int make_diffs /* flag to modify data buffer * Purpose: Check datasets with datasapce of zero dimension size. *------------------------------------------------------------------------- */ -static -int test_special_datasets(const char *file, int make_diffs /* flag to modify data buffers */) +static int +test_special_datasets(const char *file, int make_diffs /* flag to modify data buffers */) { - hid_t fid = -1; - hid_t did = -1; - hid_t sid0 = -1; - hid_t sid = -1; - hsize_t dims0[SPACE1_RANK] = { SPACE1_DIM1, SPACE1_DIM2 }; - hsize_t dims[SPACE1_RANK] = { SPACE1_DIM1, SPACE1_DIM2 }; - herr_t status; + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t sid0 = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hsize_t dims0[SPACE1_RANK] = {SPACE1_DIM1, SPACE1_DIM2}; + hsize_t dims[SPACE1_RANK] = {SPACE1_DIM1, SPACE1_DIM2}; + herr_t status; /* Create a file */ if ((fid = H5Fcreate(file, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -1371,7 +1360,7 @@ int test_special_datasets(const char *file, int make_diffs /* flag to modify dat /* Create a dataset with zero dimension size */ sid0 = H5Screate_simple(SPACE1_RANK, dims0, NULL); - did = H5Dcreate2(fid, "dset1", H5T_NATIVE_INT, sid0, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + did = H5Dcreate2(fid, "dset1", H5T_NATIVE_INT, sid0, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* close dataset */ status = H5Dclose(did); @@ -1382,7 +1371,7 @@ int test_special_datasets(const char *file, int make_diffs /* flag to modify dat assert(status >= 0); /* Create a dataset with zero dimension size in one file but the other one - * has a dataset with a non-zero dimension size */ + * has a dataset with a non-zero dimension size */ if (make_diffs) dims[1] = SPACE1_DIM2 + 4; @@ -1411,16 +1400,17 @@ int test_special_datasets(const char *file, int make_diffs /* flag to modify dat * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_link_name(const char *fname1) +static int +test_link_name(const char *fname1) { - hid_t fid1 = -1; - hid_t gid1 = -1; - hid_t gid2 = -1; + hid_t fid1 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); @@ -1429,16 +1419,15 @@ static int test_link_name(const char *fname1) } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ gid1 = H5Gcreate2(fid1, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } - gid2 = H5Gcreate2(fid1, "group_longname", H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT); + gid2 = H5Gcreate2(fid1, "group_longname", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid2 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); @@ -1447,8 +1436,8 @@ static int test_link_name(const char *fname1) } /*----------------------------------------------------------------------- - * Soft Links - *------------------------------------------------------------------------*/ + * Soft Links + *------------------------------------------------------------------------*/ status = H5Lcreate_soft("group", fid1, "link_g1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); @@ -1465,8 +1454,8 @@ static int test_link_name(const char *fname1) out: /*----------------------------------------------------------------------- - * Close - *------------------------------------------------------------------------*/ + * Close + *------------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (gid1) @@ -1484,18 +1473,19 @@ out: * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_soft_links(const char *fname1) +static int +test_soft_links(const char *fname1) { - hid_t fid1 = -1; - hid_t gid1 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - int data2[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + int data2[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); @@ -1504,8 +1494,8 @@ static int test_soft_links(const char *fname1) } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ gid1 = H5Gcreate2(fid1, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); @@ -1514,8 +1504,8 @@ static int test_soft_links(const char *fname1) } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "target_dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { @@ -1539,8 +1529,8 @@ static int test_soft_links(const char *fname1) } /*----------------------------------------------------------------------- - * Soft Links - *------------------------------------------------------------------------*/ + * Soft Links + *------------------------------------------------------------------------*/ /* file 1 */ status = H5Lcreate_soft("/target_dset1", fid1, "softlink_dset1_1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -1586,8 +1576,8 @@ static int test_soft_links(const char *fname1) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (gid1) @@ -1603,20 +1593,21 @@ out: * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_linked_softlinks(const char *fname1) +static int +test_linked_softlinks(const char *fname1) { - hid_t fid1 = -1; - hid_t gid1 = -1; - hid_t gid2 = -1; - hid_t gid3 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - int data2[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hid_t gid3 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + int data2[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); @@ -1625,8 +1616,8 @@ static int test_linked_softlinks(const char *fname1) } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ gid1 = H5Gcreate2(fid1, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); @@ -1649,8 +1640,8 @@ static int test_linked_softlinks(const char *fname1) } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "target_dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { @@ -1673,10 +1664,10 @@ static int test_linked_softlinks(const char *fname1) } /*----------------------------------------------------------------------- - * Soft Links (Linked) - *------------------------------------------------------------------------*/ + * Soft Links (Linked) + *------------------------------------------------------------------------*/ /*--------- - * file 1 */ + * file 1 */ status = H5Lcreate_soft("/target_dset1", fid1, "softlink1_to_dset1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); @@ -1763,8 +1754,8 @@ static int test_linked_softlinks(const char *fname1) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (gid1) @@ -1784,20 +1775,21 @@ out: * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_external_links(const char *fname1, const char *fname2) +static int +test_external_links(const char *fname1, const char *fname2) { - hid_t fid1 = -1; - hid_t fid2 = -1; - hid_t gid1 = -1; - hid_t gid2 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - int data2[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + int data2[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ /* source file */ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { @@ -1815,10 +1807,10 @@ static int test_external_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ /*-------------- - * target file */ + * target file */ gid1 = H5Gcreate2(fid2, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); @@ -1833,10 +1825,10 @@ static int test_external_links(const char *fname1, const char *fname2) goto out; } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /*-------------- - * target file */ + * target file */ status = write_dset(fid2, 2, dims2, "target_dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); @@ -1859,18 +1851,20 @@ static int test_external_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * External Links - *------------------------------------------------------------------------*/ + * External Links + *------------------------------------------------------------------------*/ /*--------------*/ /* source file */ - status = H5Lcreate_external(fname2, "/target_group/x_dset", fid1, "ext_link_dset1", H5P_DEFAULT, H5P_DEFAULT); + status = + H5Lcreate_external(fname2, "/target_group/x_dset", fid1, "ext_link_dset1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } - status = H5Lcreate_external(fname2, "/target_group2/x_dset", fid1, "ext_link_dset2", H5P_DEFAULT, H5P_DEFAULT); + status = + H5Lcreate_external(fname2, "/target_group2/x_dset", fid1, "ext_link_dset2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; @@ -1907,8 +1901,8 @@ static int test_external_links(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -1929,19 +1923,20 @@ out: * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_ext2soft_links(const char *fname1, const char *fname2) +static int +test_ext2soft_links(const char *fname1, const char *fname2) { - hid_t fid1 = -1; - hid_t fid2 = -1; - hid_t gid2 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - int data2[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + int data2[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ /* source file */ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { @@ -1959,8 +1954,8 @@ static int test_ext2soft_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ /* target file */ gid2 = H5Gcreate2(fid2, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid2 < 0) { @@ -1970,10 +1965,10 @@ static int test_ext2soft_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /*-------------- - * target file */ + * target file */ status = write_dset(fid2, 2, dims2, "dset1", H5T_NATIVE_INT, data2); if (status == FAIL) { HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); @@ -1989,10 +1984,10 @@ static int test_ext2soft_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Soft Links (Linked) - *------------------------------------------------------------------------*/ + * Soft Links (Linked) + *------------------------------------------------------------------------*/ /*--------------- - * target file */ + * target file */ status = H5Lcreate_soft("/dset1", fid2, "softlink_to_dset1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); @@ -2008,10 +2003,10 @@ static int test_ext2soft_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * External Links - *------------------------------------------------------------------------*/ + * External Links + *------------------------------------------------------------------------*/ /*--------------- - * source file */ + * source file */ status = H5Lcreate_external(fname2, "/target_group", fid1, "ext_link", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); @@ -2019,14 +2014,16 @@ static int test_ext2soft_links(const char *fname1, const char *fname2) goto out; } - status = H5Lcreate_external(fname2, "/softlink_to_dset1", fid1, "ext_link_to_slink1", H5P_DEFAULT, H5P_DEFAULT); + status = H5Lcreate_external(fname2, "/softlink_to_dset1", fid1, "ext_link_to_slink1", H5P_DEFAULT, + H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } - status = H5Lcreate_external(fname2, "/softlink_to_dset2", fid1, "ext_link_to_slink2", H5P_DEFAULT, H5P_DEFAULT); + status = H5Lcreate_external(fname2, "/softlink_to_dset2", fid1, "ext_link_to_slink2", H5P_DEFAULT, + H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; @@ -2035,8 +2032,8 @@ static int test_ext2soft_links(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -2057,20 +2054,20 @@ out: * *------------------------------------------------------------------------- */ -static -int gen_dataset_idx(const char *file, int format) +static int +gen_dataset_idx(const char *file, int format) { - hid_t fid = -1; /* file id */ - hid_t did = -1; - hid_t did2 = -1; /* dataset id */ - hid_t sid = -1; /* space id */ - hid_t fapl = -1; /* file access property id */ - hid_t dcpl = -1; /* dataset creation property id */ - hsize_t dims[1] = { 10 }; /* dataset dimension */ - hsize_t c_dims[1] = { 2 }; /* chunk dimension */ - herr_t status; /* return status */ - int buf[10]; /* data buffer */ - int i; /* local index variable */ + hid_t fid = H5I_INVALID_HID; /* file id */ + hid_t did = H5I_INVALID_HID; + hid_t did2 = H5I_INVALID_HID; /* dataset id */ + hid_t sid = H5I_INVALID_HID; /* space id */ + hid_t fapl = H5I_INVALID_HID; /* file access property id */ + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property id */ + hsize_t dims[1] = {10}; /* dataset dimension */ + hsize_t c_dims[1] = {2}; /* chunk dimension */ + herr_t status; /* return status */ + int buf[10]; /* data buffer */ + int i; /* local index variable */ /* Get a copy of the file aaccess property */ fapl = H5Pcreate(H5P_FILE_ACCESS); @@ -2090,7 +2087,7 @@ int gen_dataset_idx(const char *file, int format) buf[i] = i; /* Set chunk */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); status = H5Pset_chunk(dcpl, 1, c_dims); assert(status >= 0); @@ -2102,13 +2099,13 @@ int gen_dataset_idx(const char *file, int format) status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); assert(status >= 0); -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) /* set deflate data */ status = H5Pset_deflate(dcpl, 9); assert(status >= 0); /* Create and write the dataset */ - did2 = H5Dcreate2(fid, "dset_filter", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + did2 = H5Dcreate2(fid, "dset_filter", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); status = H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); assert(status >= 0); @@ -2144,18 +2141,19 @@ int gen_dataset_idx(const char *file, int format) * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_dangle_links(const char *fname1, const char *fname2) +static int +test_dangle_links(const char *fname1, const char *fname2) { - hid_t fid1 = -1; - hid_t fid2 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - int data2[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + int data2[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); @@ -2171,8 +2169,8 @@ static int test_dangle_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { @@ -2204,8 +2202,8 @@ static int test_dangle_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Soft Links - *------------------------------------------------------------------------*/ + * Soft Links + *------------------------------------------------------------------------*/ /* file 1 */ status = H5Lcreate_soft("no_obj", fid1, "soft_link1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -2265,8 +2263,8 @@ static int test_dangle_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * External Links - *------------------------------------------------------------------------*/ + * External Links + *------------------------------------------------------------------------*/ /* file1 */ status = H5Lcreate_external(fname2, "no_obj", fid1, "ext_link1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -2327,8 +2325,8 @@ static int test_dangle_links(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -2344,21 +2342,24 @@ out: * Programmer: Jonathan Kim (Aug 19, 2010) * *-------------------------------------------------------------------------*/ -static int test_group_recurse(const char *fname1, const char *fname2) +static int +test_group_recurse(const char *fname1, const char *fname2) { - hid_t fid1 = -1; - hid_t fid2 = -1; - hid_t gid1_f1 = -1, gid2_f1 = -1, gid3_f1 = -1, gid10_f1 = -1; - hid_t gid1_f2 = -1, gid2_f2 = -1, gid3_f2 = -1, gid11_f2 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 0, 1 }, { 1, 0 }, { 1, 0 } }; - int data2[4][2] = { { 0, 2 }, { 0, 2 }, { 2, 0 }, { 2, 0 } }; - int data3[4][2] = { { 0, 3 }, { 0, 3 }, { 3, 0 }, { 3, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid1_f1 = H5I_INVALID_HID, gid2_f1 = H5I_INVALID_HID, gid3_f1 = H5I_INVALID_HID, + gid10_f1 = H5I_INVALID_HID; + hid_t gid1_f2 = H5I_INVALID_HID, gid2_f2 = H5I_INVALID_HID, gid3_f2 = H5I_INVALID_HID, + gid11_f2 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {0, 1}, {1, 0}, {1, 0}}; + int data2[4][2] = {{0, 2}, {0, 2}, {2, 0}, {2, 0}}; + int data3[4][2] = {{0, 3}, {0, 3}, {3, 0}, {3, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); @@ -2374,8 +2375,8 @@ static int test_group_recurse(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ /* file1 */ gid1_f1 = H5Gcreate2(fid1, "/grp1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1_f1 < 0) { @@ -2435,8 +2436,8 @@ static int test_group_recurse(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Datasets under root - *------------------------------------------------------------------------*/ + * Datasets under root + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { @@ -2482,8 +2483,8 @@ static int test_group_recurse(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Datasets under group - *------------------------------------------------------------------------*/ + * Datasets under group + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(gid1_f1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { @@ -2595,8 +2596,8 @@ static int test_group_recurse(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Soft Links - *------------------------------------------------------------------------*/ + * Soft Links + *------------------------------------------------------------------------*/ /* file 1 */ status = H5Lcreate_soft("/grp1", fid1, "slink_grp1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -2656,8 +2657,8 @@ static int test_group_recurse(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * External Links - *------------------------------------------------------------------------*/ + * External Links + *------------------------------------------------------------------------*/ /* file1 */ status = H5Lcreate_external(fname2, "/grp1", fid1, "elink_grp1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -2703,9 +2704,9 @@ static int test_group_recurse(const char *fname1, const char *fname2) } /*------------------------------ - * external circle route test - * file1/grp11 <-> file2/grp10 via elink_grp_circle link - */ + * external circle route test + * file1/grp11 <-> file2/grp10 via elink_grp_circle link + */ /* file1 */ status = H5Lcreate_external(fname2, "/grp11", gid10_f1, "elink_grp_circle", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -2723,8 +2724,8 @@ static int test_group_recurse(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -2756,38 +2757,39 @@ out: *-------------------------------------------------------------------------*/ #define GRP_R_DSETNAME1 "dset1" #define GRP_R_DSETNAME2 "dset2" -static int test_group_recurse2(void) +static int +test_group_recurse2(void) { - hid_t fileid1 = -1; - hid_t grp1 = -1; - hid_t grp2 = -1; - hid_t grp3 = -1; - hid_t grp4 = -1; - hid_t dset1 = -1; - hid_t dset2 = -1; - hid_t datatype = -1; - hid_t dataspace = -1; - hid_t fileid2 = -1; - hid_t fileid3 = -1; - hid_t fileid4 = -1; + hid_t fileid1 = H5I_INVALID_HID; + hid_t grp1 = H5I_INVALID_HID; + hid_t grp2 = H5I_INVALID_HID; + hid_t grp3 = H5I_INVALID_HID; + hid_t grp4 = H5I_INVALID_HID; + hid_t dset1 = H5I_INVALID_HID; + hid_t dset2 = H5I_INVALID_HID; + hid_t datatype = H5I_INVALID_HID; + hid_t dataspace = H5I_INVALID_HID; + hid_t fileid2 = H5I_INVALID_HID; + hid_t fileid3 = H5I_INVALID_HID; + hid_t fileid4 = H5I_INVALID_HID; hsize_t dimsf[2]; /* dataset dimensions */ - herr_t status = 0; - int data1[4][2] = { { 0, 0 }, { 1, 1 }, { 2, 2 }, { 3, 3 } }; - int data2[4][2] = { { 0, 0 }, { 0, 1 }, { 0, 2 }, { 3, 3 } }; + herr_t status = 0; + int data1[4][2] = {{0, 0}, {1, 1}, {2, 2}, {3, 3}}; + int data2[4][2] = {{0, 0}, {0, 1}, {0, 2}, {3, 3}}; /*----------------------------------------------------------------------- - * FILE 1 - *------------------------------------------------------------------------*/ + * FILE 1 + *------------------------------------------------------------------------*/ /* - * Create a new file using H5F_ACC_TRUNC access, - * default file creation properties, and default file - * access properties. - */ + * Create a new file using H5F_ACC_TRUNC access, + * default file creation properties, and default file + * access properties. + */ fileid1 = H5Fcreate(GRP_RECURSE1_EXT, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ grp1 = H5Gcreate2(fileid1, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (grp1 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE1_EXT); @@ -2817,72 +2819,72 @@ static int test_group_recurse2(void) } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* - * Describe the size of the array and create the data space for fixed - * size dataset. - */ - dimsf[0] = 4; - dimsf[1] = 2; + * Describe the size of the array and create the data space for fixed + * size dataset. + */ + dimsf[0] = 4; + dimsf[1] = 2; dataspace = H5Screate_simple(2, dimsf, NULL); /* - * Define datatype for the data in the file. - * We will store little endian INT numbers. - */ + * Define datatype for the data in the file. + * We will store little endian INT numbers. + */ datatype = H5Tcopy(H5T_NATIVE_INT); - status = H5Tset_order(datatype, H5T_ORDER_LE); + status = H5Tset_order(datatype, H5T_ORDER_LE); /*--------------- - * dset1 - */ + * dset1 + */ /* - * Create a new dataset within the file using defined dataspace and - * datatype and default dataset creation properties. - */ + * Create a new dataset within the file using defined dataspace and + * datatype and default dataset creation properties. + */ dset1 = H5Dcreate2(fileid1, GRP_R_DSETNAME1, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1); H5Dclose(dset1); /*--------------- - * dset1 - */ + * dset1 + */ /* - * Create a new dataset within the file using defined dataspace and - * datatype and default dataset creation properties. - */ + * Create a new dataset within the file using defined dataspace and + * datatype and default dataset creation properties. + */ dset1 = H5Dcreate2(grp3, GRP_R_DSETNAME1, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1); /*--------------- - * dset2 - */ + * dset2 + */ /* - * Create a new dataset within the fileid1 using defined dataspace and - * datatype and default dataset creation properties. - */ + * Create a new dataset within the fileid1 using defined dataspace and + * datatype and default dataset creation properties. + */ dset2 = H5Dcreate2(grp4, GRP_R_DSETNAME2, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2); /*----------------------------------------------------------------------- - * Soft links - *------------------------------------------------------------------------*/ + * Soft links + *------------------------------------------------------------------------*/ /* - * under '/' root - */ + * under '/' root + */ /* link to dset1 */ status = H5Lcreate_soft(GRP_R_DSETNAME1, fileid1, "soft_dset1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -2899,15 +2901,15 @@ static int test_group_recurse2(void) H5Gclose(grp4); /*----------------------------------------------------------------------- - * FILE 2-3 - *------------------------------------------------------------------------*/ + * FILE 2-3 + *------------------------------------------------------------------------*/ - /* crate target file */ + /* create target file */ fileid4 = H5Fcreate(GRP_RECURSE2_EXT3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*----------------------------------------------- - * Groups - */ + * Groups + */ grp4 = H5Gcreate2(fileid4, "/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (grp4 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE2_EXT3); @@ -2916,32 +2918,32 @@ static int test_group_recurse2(void) } /*--------------- - * dset2 - */ + * dset2 + */ /* - * Create a new dataset within the fileid1 using defined dataspace and - * datatype and default dataset creation properties. - */ + * Create a new dataset within the fileid1 using defined dataspace and + * datatype and default dataset creation properties. + */ dset2 = H5Dcreate2(grp4, GRP_R_DSETNAME2, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2); H5Gclose(grp4); H5Dclose(dset2); /*----------------------------------------------------------------------- - * FILE 2-2 - *------------------------------------------------------------------------*/ + * FILE 2-2 + *------------------------------------------------------------------------*/ - /* crate target file */ + /* create target file */ fileid3 = H5Fcreate(GRP_RECURSE2_EXT2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*----------------------------------------------- - * Groups - */ + * Groups + */ grp2 = H5Gcreate2(fileid3, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (grp2 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE2_EXT2); @@ -2957,22 +2959,22 @@ static int test_group_recurse2(void) } /*--------------- - * dset1 - */ + * dset1 + */ /* - * Create a new dataset within the fileid1 using defined dataspace and - * datatype and default dataset creation properties. - */ + * Create a new dataset within the fileid1 using defined dataspace and + * datatype and default dataset creation properties. + */ dset1 = H5Dcreate2(grp3, GRP_R_DSETNAME1, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1); /*----------------------------------------------- - * extlink to $GRP_RECURSE2_EXT3/g4 - */ + * extlink to $GRP_RECURSE2_EXT3/g4 + */ status = H5Lcreate_external(GRP_RECURSE2_EXT3, "/g4", fileid3, "/g2/g3/g4", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", GRP_RECURSE2_EXT2); @@ -2985,15 +2987,15 @@ static int test_group_recurse2(void) H5Gclose(grp3); /*----------------------------------------------------------------------- - * FILE 2-1 - *------------------------------------------------------------------------*/ + * FILE 2-1 + *------------------------------------------------------------------------*/ - /* crate target file */ + /* create target file */ fileid2 = H5Fcreate(GRP_RECURSE2_EXT1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*----------------------------------------------- - * Groups - */ + * Groups + */ grp1 = H5Gcreate2(fileid2, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (grp1 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE1_EXT); @@ -3002,21 +3004,21 @@ static int test_group_recurse2(void) } /*--------------- - * dset1 - */ + * dset1 + */ dset1 = H5Dcreate2(fileid2, GRP_R_DSETNAME1, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1); /*----------------------------------------------------------------------- - * Soft links - *------------------------------------------------------------------------*/ + * Soft links + *------------------------------------------------------------------------*/ /* - * under '/' root - */ + * under '/' root + */ /* link to dset1 */ status = H5Lcreate_soft(GRP_R_DSETNAME1, fileid2, "soft_dset1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -3026,8 +3028,8 @@ static int test_group_recurse2(void) } /*----------------------------------------------- - * extlink to $GRP_RECURSE2_EXT2/g2 - */ + * extlink to $GRP_RECURSE2_EXT2/g2 + */ status = H5Lcreate_external(GRP_RECURSE2_EXT2, "/g2", fileid2, "/g1/g2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", GRP_RECURSE2_EXT1); @@ -3040,8 +3042,8 @@ static int test_group_recurse2(void) out: /* - * Close/release resources. - */ + * Close/release resources. + */ if (dataspace > 0) H5Sclose(dataspace); if (datatype > 0) @@ -3067,20 +3069,21 @@ out: * Programmer: Jonathan Kim (July, 21, 2010) * *-------------------------------------------------------------------------*/ -static int test_exclude_obj1(const char *fname1, const char *fname2) +static int +test_exclude_obj1(const char *fname1, const char *fname2) { - hid_t fid1 = -1; - hid_t fid2 = -1; - hid_t gid1 = -1; - hid_t gid2 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - int data2[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + int data2[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); @@ -3096,8 +3099,8 @@ static int test_exclude_obj1(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Group - *------------------------------------------------------------------------*/ + * Group + *------------------------------------------------------------------------*/ /* file1 */ gid1 = H5Gcreate2(fid1, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { @@ -3116,8 +3119,8 @@ static int test_exclude_obj1(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { @@ -3164,8 +3167,8 @@ static int test_exclude_obj1(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -3187,21 +3190,22 @@ out: * Programmer: Jonathan Kim (July, 21, 2010) * *-------------------------------------------------------------------------*/ -static int test_exclude_obj2(const char *fname1, const char *fname2) +static int +test_exclude_obj2(const char *fname1, const char *fname2) { - hid_t fid1 = -1; - hid_t fid2 = -1; - hid_t gid1 = -1; - hid_t gid2 = -1; - hid_t gid3 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - int data2[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hid_t gid3 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + int data2[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); @@ -3217,8 +3221,8 @@ static int test_exclude_obj2(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Group - *------------------------------------------------------------------------*/ + * Group + *------------------------------------------------------------------------*/ /* file1 */ gid1 = H5Gcreate2(fid1, "group10", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { @@ -3245,8 +3249,8 @@ static int test_exclude_obj2(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "dset10", H5T_NATIVE_INT, data1); if (status == FAIL) { @@ -3293,8 +3297,8 @@ static int test_exclude_obj2(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -3318,18 +3322,19 @@ out: * Programmer: Jonathan Kim (Mar, 19, 2012) * *-------------------------------------------------------------------------*/ -static int test_exclude_obj3(const char *fname1, const char *fname2) +static int +test_exclude_obj3(const char *fname1, const char *fname2) { - hid_t fid1 = -1; - hid_t fid2 = -1; - hid_t gid1 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); @@ -3345,8 +3350,8 @@ static int test_exclude_obj3(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Group - *------------------------------------------------------------------------*/ + * Group + *------------------------------------------------------------------------*/ /* file1 */ gid1 = H5Gcreate2(fid1, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { @@ -3356,8 +3361,8 @@ static int test_exclude_obj3(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { @@ -3383,8 +3388,8 @@ static int test_exclude_obj3(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -3404,182 +3409,181 @@ out: * Programmer: Jonathan Kim (Oct, 26, 2010) * *-------------------------------------------------------------------------*/ -#define STR_RANK 1 -#define VLEN_STR_DIM 1 -#define FIXLEN_STR_SIZE 21 -#define FIXLEN_STR_DIM 1 -#define VLEN_STR_ARRY_DIM 3 -#define FIXLEN_STR_ARRY_DIM 3 +#define STR_RANK 1 +#define VLEN_STR_DIM 1 +#define FIXLEN_STR_SIZE 21 +#define FIXLEN_STR_DIM 1 +#define VLEN_STR_ARRY_DIM 3 +#define FIXLEN_STR_ARRY_DIM 3 #define FIXLEN_STR_ARRY_SIZE 30 -#define COMP_RANK 1 -#define COMP_DIM 1 -static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int is_file_new) +#define COMP_RANK 1 +#define COMP_DIM 1 +static int +test_comp_vlen_strings(const char *fname1, const char *grp_name, int is_file_new) { - int i; - hid_t fid1 = -1; /* file id */ - hid_t gid = -1; + int i; + hid_t fid1 = H5I_INVALID_HID; /* file id */ + hid_t gid = H5I_INVALID_HID; /* compound1 datatype */ typedef struct comp1_t { - char *str_vlen; /* vlen string */ - char *str_vlen_repeat; /* vlen string */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char * str_vlen; /* vlen string */ + char * str_vlen_repeat; /* vlen string */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ } comp1_t; /* compound2 datatype */ typedef struct comp2_t { - char *str_vlen; /* vlen string */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen_repeat; /* vlen string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char * str_vlen; /* vlen string */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen_repeat; /* vlen string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ } comp2_t; /* compound3 datatype */ typedef struct comp3_t { - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen; /* vlen string */ - char *str_vlen_repeat; /* vlen string */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + char *str_vlen; /* vlen string */ + char *str_vlen_repeat; /* vlen string */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ } comp3_t; /* compound4 datatype */ typedef struct comp4_t { - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen; /* vlen string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen_repeat; /* vlen string */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen; /* vlen string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen_repeat; /* vlen string */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ } comp4_t; /* compound5 datatype */ typedef struct comp5_t { - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - char *str_vlen; /* vlen string */ - char *str_vlen_repeat; /* vlen string */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char *str_vlen; /* vlen string */ + char *str_vlen_repeat; /* vlen string */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ } comp5_t; /* compound6 datatype */ typedef struct comp6_t { - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - char *str_vlen; /* vlen string */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen_repeat; /* vlen string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char *str_vlen; /* vlen string */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char *str_vlen_repeat; /* vlen string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ } comp6_t; /* compound7 datatype */ typedef struct comp7_t { - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen; /* vlen string */ - char *str_vlen_repeat; /* vlen string */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen; /* vlen string */ + char * str_vlen_repeat; /* vlen string */ } comp7_t; /* compound8 datatype */ typedef struct comp8_t { - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen; /* vlen string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen_repeat; /* vlen string */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen; /* vlen string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen_repeat; /* vlen string */ } comp8_t; /* compound9 datatype */ typedef struct comp9_t { - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - int int_data1; - hobj_ref_t objref1; /* reference */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - hobj_ref_t objref2; /* reference */ - char *str_vlen; /* vlen string */ - int int_data2; - char *str_vlen_repeat; /* vlen string */ - hobj_ref_t objref3; /* reference */ - int int_data3; + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + int int_data1; + hobj_ref_t objref1; /* reference */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + hobj_ref_t objref2; /* reference */ + char * str_vlen; /* vlen string */ + int int_data2; + char * str_vlen_repeat; /* vlen string */ + hobj_ref_t objref3; /* reference */ + int int_data3; } comp9_t; /* vlen string */ - hid_t sid_vlen_str = -1; /* dataspace ID */ - hid_t tid_vlen_str = -1; /* datatype ID */ - char vlen_str_buf[] = { "Variable length string" }; - hsize_t dims_vlen_str[] = { VLEN_STR_DIM }; + hid_t sid_vlen_str = H5I_INVALID_HID; /* dataspace ID */ + hid_t tid_vlen_str = H5I_INVALID_HID; /* datatype ID */ + char vlen_str_buf[] = {"Variable length string"}; + hsize_t dims_vlen_str[] = {VLEN_STR_DIM}; /* fixlen string */ - hid_t sid_fixlen_str = -1; /* dataspace ID */ - hid_t tid_fixlen_str = -1; /* datatype ID */ - const char fixlen_str_buf[FIXLEN_STR_SIZE] = { "Fixed length string" }; - hsize_t dims_fixlen_str[] = { FIXLEN_STR_DIM }; + hid_t sid_fixlen_str = H5I_INVALID_HID; /* dataspace ID */ + hid_t tid_fixlen_str = H5I_INVALID_HID; /* datatype ID */ + const char fixlen_str_buf[FIXLEN_STR_SIZE] = {"Fixed length string"}; + hsize_t dims_fixlen_str[] = {FIXLEN_STR_DIM}; /* vlen string array */ - hid_t sid_vlen_str_array = -1; /* dataspace ID */ - hid_t tid_vlen_str_array_pre = -1; /* datatype ID */ - hid_t tid_vlen_str_array = -1; /* datatype ID */ - const char *vlen_str_array_buf[VLEN_STR_ARRY_DIM] = - { "1 - Variable length string Array", - "2 - Testing variable length string array in compound type", - "3 - Four score and seven\n years ago our forefathers brought forth on this continent a new nation," }; - hsize_t dims_vlen_str_array[] = { VLEN_STR_ARRY_DIM }; + hid_t sid_vlen_str_array = H5I_INVALID_HID; /* dataspace ID */ + hid_t tid_vlen_str_array_pre = H5I_INVALID_HID; /* datatype ID */ + hid_t tid_vlen_str_array = H5I_INVALID_HID; /* datatype ID */ + const char *vlen_str_array_buf[VLEN_STR_ARRY_DIM] = { + "1 - Variable length string Array", "2 - Testing variable length string array in compound type", + "3 - Four score and seven\n years ago our forefathers brought forth on this continent a new nation,"}; + hsize_t dims_vlen_str_array[] = {VLEN_STR_ARRY_DIM}; /* fixlen string array */ - hid_t sid_fixlen_str_array = -1; /* dataspace ID */ - hid_t tid_fixlen_str_array_pre = -1; /* datatype ID */ - hid_t tid_fixlen_str_array = -1; /* datatype ID */ + hid_t sid_fixlen_str_array = H5I_INVALID_HID; /* dataspace ID */ + hid_t tid_fixlen_str_array_pre = H5I_INVALID_HID; /* datatype ID */ + hid_t tid_fixlen_str_array = H5I_INVALID_HID; /* datatype ID */ const char *fixlen_str_array_buf[FIXLEN_STR_ARRY_DIM] = { - "1 - Fixed length string Array", "2 - Fixed length string Array", - "3 - Fixed length string Array" }; - hsize_t dims_fixlen_str_array[] = { FIXLEN_STR_ARRY_DIM }; + "1 - Fixed length string Array", "2 - Fixed length string Array", "3 - Fixed length string Array"}; + hsize_t dims_fixlen_str_array[] = {FIXLEN_STR_ARRY_DIM}; /*------------------------------------------ - * compound dataset - *------------------------------------------*/ - hid_t sid_comp = -1; /* dataspace ID */ - hid_t tid1_comp = -1; /* datatype ID */ - hid_t tid2_comp = -1; /* datatype ID */ - hid_t tid3_comp = -1; /* datatype ID */ - hid_t tid4_comp = -1; /* datatype ID */ - hid_t tid5_comp = -1; /* datatype ID */ - hid_t tid6_comp = -1; /* datatype ID */ - hid_t tid7_comp = -1; /* datatype ID */ - hid_t tid8_comp = -1; /* datatype ID */ - hid_t tid9_comp = -1; /* datatype ID */ - hid_t did_comp = -1; /* dataset ID */ - hsize_t dims_comp[] = { COMP_DIM }; - herr_t status = SUCCEED; + * compound dataset + *------------------------------------------*/ + hid_t sid_comp = H5I_INVALID_HID; /* dataspace ID */ + hid_t tid1_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid2_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid3_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid4_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid5_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid6_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid7_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid8_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid9_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t did_comp = H5I_INVALID_HID; /* dataset ID */ + hsize_t dims_comp[] = {COMP_DIM}; + herr_t status = SUCCEED; /* make compound strings data */ comp1_t comp1_buf; @@ -3636,25 +3640,15 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* copy vlen string array data to compound buffers */ for (i = 0; i < VLEN_STR_ARRY_DIM; i++) { - comp1_buf.str_array_vlen[i] = comp1_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp2_buf.str_array_vlen[i] = comp2_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp3_buf.str_array_vlen[i] = comp3_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp4_buf.str_array_vlen[i] = comp4_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp5_buf.str_array_vlen[i] = comp5_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp6_buf.str_array_vlen[i] = comp6_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp7_buf.str_array_vlen[i] = comp7_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp8_buf.str_array_vlen[i] = comp8_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp9_buf.str_array_vlen[i] = comp9_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - + comp1_buf.str_array_vlen[i] = comp1_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp2_buf.str_array_vlen[i] = comp2_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp3_buf.str_array_vlen[i] = comp3_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp4_buf.str_array_vlen[i] = comp4_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp5_buf.str_array_vlen[i] = comp5_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp6_buf.str_array_vlen[i] = comp6_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp7_buf.str_array_vlen[i] = comp7_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp8_buf.str_array_vlen[i] = comp8_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp9_buf.str_array_vlen[i] = comp9_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; } /* copy fixlen string attay data to compound buffers */ @@ -3693,8 +3687,8 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int comp9_buf.int_data3 = 30; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ if (is_file_new == 1) { fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { @@ -3713,8 +3707,8 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } /*----------------------------------------------------------------------- - * Create group - *------------------------------------------------------------------------*/ + * Create group + *------------------------------------------------------------------------*/ gid = H5Gcreate2(fid1, grp_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); @@ -3723,8 +3717,8 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } /*----------------------------------------------------------------------- - * Variable length String1 - Create space and type - *------------------------------------------------------------------------*/ + * Variable length String1 - Create space and type + *------------------------------------------------------------------------*/ sid_vlen_str = H5Screate_simple(STR_RANK, dims_vlen_str, NULL); if (sid_vlen_str < 0) { HDfprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); @@ -3733,7 +3727,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } tid_vlen_str = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid_vlen_str, H5T_VARIABLE); + status = H5Tset_size(tid_vlen_str, H5T_VARIABLE); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Tset_size failed.\n", fname1); status = FAIL; @@ -3741,8 +3735,8 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } /*----------------------------------------------------------------------- - * Fixed length String2 - Create space and type - *------------------------------------------------------------------------*/ + * Fixed length String2 - Create space and type + *------------------------------------------------------------------------*/ sid_fixlen_str = H5Screate_simple(STR_RANK, dims_fixlen_str, NULL); if (sid_fixlen_str < 0) { HDfprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); @@ -3751,7 +3745,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } tid_fixlen_str = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid_fixlen_str, FIXLEN_STR_SIZE); + status = H5Tset_size(tid_fixlen_str, FIXLEN_STR_SIZE); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Tset_size failed.\n", fname1); status = FAIL; @@ -3759,8 +3753,8 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } /*----------------------------------------------------------------------- - * Fixed length String3 array - Create space and type - *------------------------------------------------------------------------*/ + * Fixed length String3 array - Create space and type + *------------------------------------------------------------------------*/ sid_vlen_str_array = H5Screate_simple(STR_RANK, dims_vlen_str_array, NULL); if (sid_vlen_str_array < 0) { HDfprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); @@ -3769,7 +3763,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } tid_vlen_str_array_pre = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid_vlen_str_array_pre, H5T_VARIABLE); + status = H5Tset_size(tid_vlen_str_array_pre, H5T_VARIABLE); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Tset_size failed.\n", fname1); status = FAIL; @@ -3785,8 +3779,8 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } /*----------------------------------------------------------------------- - * Variable length String4 array - Create space and type - *------------------------------------------------------------------------*/ + * Variable length String4 array - Create space and type + *------------------------------------------------------------------------*/ sid_fixlen_str_array = H5Screate_simple(STR_RANK, dims_fixlen_str_array, NULL); if (sid_fixlen_str_array < 0) { HDfprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); @@ -3795,7 +3789,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } tid_fixlen_str_array_pre = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid_fixlen_str_array_pre, FIXLEN_STR_ARRY_SIZE); + status = H5Tset_size(tid_fixlen_str_array_pre, FIXLEN_STR_ARRY_SIZE); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Tset_size failed.\n", fname1); status = FAIL; @@ -3810,8 +3804,8 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } /*------------------------------------------------------------------------- - * Compound dataset - *------------------------------------------------------------------------*/ + * Compound dataset + *------------------------------------------------------------------------*/ sid_comp = H5Screate_simple(COMP_RANK, dims_comp, NULL); if (sid_comp < 0) { HDfprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); @@ -3874,7 +3868,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int H5Tinsert(tid5_comp, "FIXLEN_STR1", HOFFSET(comp5_t, str_fixlen), tid_fixlen_str); H5Tinsert(tid5_comp, "FIXLEN_STR2", HOFFSET(comp5_t, str_fixlen_repeat), tid_fixlen_str); H5Tinsert(tid5_comp, "VLEN_STR_ARRAY1", HOFFSET(comp5_t, str_array_vlen), tid_vlen_str_array); - H5Tinsert(tid5_comp, "VLEN_STR_ARRAY2", HOFFSET(comp5_t, str_vlen_array_again), tid_vlen_str_array); + H5Tinsert(tid5_comp, "VLEN_STR_ARRAY2", HOFFSET(comp5_t, str_vlen_array_again), tid_vlen_str_array); H5Tinsert(tid5_comp, "FIXLEN_STR_ARRAY1", HOFFSET(comp5_t, str_array_fixlen), tid_fixlen_str_array); H5Tinsert(tid5_comp, "FIXLEN_STR_ARRAY2", HOFFSET(comp5_t, str_fixlen_array_again), tid_fixlen_str_array); @@ -3926,7 +3920,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 1 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset1", tid1_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid1_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp1_buf); + status = H5Dwrite(did_comp, tid1_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp1_buf); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; @@ -3936,7 +3930,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 2 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset2", tid2_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid2_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp2_buf); + status = H5Dwrite(did_comp, tid2_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp2_buf); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; @@ -3946,7 +3940,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 3 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset3", tid3_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid3_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp3_buf); + status = H5Dwrite(did_comp, tid3_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp3_buf); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; @@ -3956,7 +3950,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 4 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset4", tid4_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid4_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp4_buf); + status = H5Dwrite(did_comp, tid4_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp4_buf); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; @@ -3966,7 +3960,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 5 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset5", tid5_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid5_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp5_buf); + status = H5Dwrite(did_comp, tid5_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp5_buf); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; @@ -3976,7 +3970,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 6 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset6", tid6_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid6_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp6_buf); + status = H5Dwrite(did_comp, tid6_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp6_buf); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; @@ -3986,7 +3980,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 7 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset7", tid7_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid7_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp7_buf); + status = H5Dwrite(did_comp, tid7_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp7_buf); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; @@ -3996,7 +3990,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 8 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset8", tid8_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid8_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp8_buf); + status = H5Dwrite(did_comp, tid8_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp8_buf); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; @@ -4008,9 +4002,9 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int did_comp = H5Dcreate2(gid, "Compound_dset9", tid9_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* obj references */ - status = H5Rcreate(&(comp9_buf.objref1), gid, "Compound_dset2", H5R_OBJECT, (hid_t) -1); - status = H5Rcreate(&(comp9_buf.objref2), gid, "Compound_dset3", H5R_OBJECT, (hid_t) -1); - status = H5Rcreate(&(comp9_buf.objref3), gid, "Compound_dset4", H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&(comp9_buf.objref1), gid, "Compound_dset2", H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&(comp9_buf.objref2), gid, "Compound_dset3", H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&(comp9_buf.objref3), gid, "Compound_dset4", H5R_OBJECT, (hid_t)-1); status = H5Dwrite(did_comp, tid9_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp9_buf); if (status < 0) { @@ -4020,12 +4014,12 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } H5Dclose(did_comp); - did_comp = -1; + did_comp = H5I_INVALID_HID; out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1 > 0) H5Fclose(fid1); if (gid > 0) @@ -4089,59 +4083,60 @@ out: * *-------------------------------------------------------------------------*/ -static int test_enums(const char *fname) +static int +test_enums(const char *fname) { - hid_t fid = -1; + hid_t fid = H5I_INVALID_HID; - hid_t tid = -1; - int enum_val = -1; + hid_t tid = H5I_INVALID_HID; + int enum_val = -1; /* The data in the two arrays cover the following cases: - * - * V = valid enum value, I = invalid enum value - * - * 0: I-I (same value) - * 1: V-I - * 2: I-V - * 3: V-V (same value) - * 4: I-I (different values) SKIPPED FOR NOW - * 5: V-V (different values) - */ + * + * V = valid enum value, I = invalid enum value + * + * 0: I-I (same value) + * 1: V-I + * 2: I-V + * 3: V-V (same value) + * 4: I-I (different values) SKIPPED FOR NOW + * 5: V-V (different values) + */ /* *** NOTE *** - * - * There is a bug in H5Dread() where invalid enum values are always - * returned as -1 so two different invalid enum values cannot be - * properly compared. Test 4 has been adjusted to pass here - * while we fix the issue. - */ - int data1[6] = { 9, 0, 9, 0, 9, 0 }; + * + * There is a bug in H5Dread() where invalid enum values are always + * returned as -1 so two different invalid enum values cannot be + * properly compared. Test 4 has been adjusted to pass here + * while we fix the issue. + */ + int data1[6] = {9, 0, 9, 0, 9, 0}; /*int data1[6] = {9, 0, 9, 0, 8, 0}; */ - int data2[6] = { 9, 9, 0, 0, 9, 1 }; + int data2[6] = {9, 9, 0, 0, 9, 1}; hsize_t dims = 6; herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create the file - *---------------------------------------------------------------------*/ + * Create the file + *---------------------------------------------------------------------*/ fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*----------------------------------------------------------------------- - * Create enum types - *---------------------------------------------------------------------*/ + * Create enum types + *---------------------------------------------------------------------*/ - tid = H5Tenum_create(H5T_NATIVE_INT); + tid = H5Tenum_create(H5T_NATIVE_INT); enum_val = 0; - status = H5Tenum_insert(tid, "YIN", &enum_val); + status = H5Tenum_insert(tid, "YIN", &enum_val); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Tenum_insert failed.\n", fname); status = FAIL; goto out; } enum_val = 1; - status = H5Tenum_insert(tid, "YANG", &enum_val); + status = H5Tenum_insert(tid, "YANG", &enum_val); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Tenum_insert failed.\n", fname); status = FAIL; @@ -4149,8 +4144,8 @@ static int test_enums(const char *fname) } /*----------------------------------------------------------------------- - * Create datasets containing enum data. - *---------------------------------------------------------------------*/ + * Create datasets containing enum data. + *---------------------------------------------------------------------*/ status = write_dset(fid, 1, &dims, "dset1", tid, data1); if (status < 0) { @@ -4167,8 +4162,8 @@ static int test_enums(const char *fname) out: /*----------------------------------------------------------------------- - * Close - *---------------------------------------------------------------------*/ + * Close + *---------------------------------------------------------------------*/ if (fid) H5Fclose(fid); if (tid) @@ -4198,56 +4193,57 @@ out: * Programmer: Jonathan Kim (Sep, 1, 2011) * *-------------------------------------------------------------------------*/ -#define SDIM_DSET 2 +#define SDIM_DSET 2 #define SDIM_CMPD_ARRAY 2 -static void test_comps_array(const char *fname, const char *dset, const char *attr, int diff, int is_file_new) +static void +test_comps_array(const char *fname, const char *dset, const char *attr, int diff, int is_file_new) { /* sub compound 2 */ typedef struct { - int i2; + int i2; float f2; } cmpd2_t; /* top compound 1 */ typedef struct { - int i1; + int i1; cmpd2_t cmpd2[SDIM_CMPD_ARRAY]; } cmpd1_t; cmpd1_t wdata[SDIM_DSET]; /* dataset with compound1 */ - hid_t fid = -1; /* HDF5 File IDs */ - hid_t did_dset = -1; /* Dataset ID */ - hid_t sid_dset = -1; /* Dataset space ID */ - hid_t tid_cmpd1 = -1; /* Compound1 type ID */ - hid_t tid_arry1 = -1; /* Array type ID in compound1 */ - hid_t tid_cmpd2 = -1; /* Compound2 type ID */ - hid_t tid_attr = -1; - hsize_t sdims_dset[] = { SDIM_DSET }; - hsize_t sdims_cmpd_arry[] = { SDIM_CMPD_ARRAY }; - int i, j; - herr_t ret; /* Generic return value */ + hid_t fid = H5I_INVALID_HID; /* HDF5 File IDs */ + hid_t did_dset = H5I_INVALID_HID; /* Dataset ID */ + hid_t sid_dset = H5I_INVALID_HID; /* Dataset space ID */ + hid_t tid_cmpd1 = H5I_INVALID_HID; /* Compound1 type ID */ + hid_t tid_arry1 = H5I_INVALID_HID; /* Array type ID in compound1 */ + hid_t tid_cmpd2 = H5I_INVALID_HID; /* Compound2 type ID */ + hid_t tid_attr = H5I_INVALID_HID; + hsize_t sdims_dset[] = {SDIM_DSET}; + hsize_t sdims_cmpd_arry[] = {SDIM_CMPD_ARRAY}; + int i, j; + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Initialize array data to write */ for (i = 0; i < SDIM_DSET; i++) { wdata[i].i1 = i; for (j = 0; j < SDIM_CMPD_ARRAY; j++) { wdata[i].cmpd2[j].i2 = i * 10 + diff; - wdata[i].cmpd2[j].f2 = (float) i * 10.5F + (float) diff; + wdata[i].cmpd2[j].f2 = (float)i * 10.5F + (float)diff; } /* end for */ } /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ if (is_file_new == 1) fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); else fid = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT); /* ------------------------------- - * Create a sub compound2 datatype */ + * Create a sub compound2 datatype */ tid_cmpd2 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd2_t)); /* Insert integer field */ @@ -4259,8 +4255,8 @@ static void test_comps_array(const char *fname, const char *dset, const char *at assert(ret >= 0); /*----------------------------------- - * Create a top compound1. - */ + * Create a top compound1. + */ tid_cmpd1 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd1_t)); ret = H5Tinsert(tid_cmpd1, "int1", HOFFSET(cmpd1_t, i1), H5T_NATIVE_INT); @@ -4273,8 +4269,8 @@ static void test_comps_array(const char *fname, const char *dset, const char *at assert(ret >= 0); /* ------------------- - * Create a dataset - */ + * Create a dataset + */ /* Create dataspace for datasets */ sid_dset = H5Screate_simple(1, sdims_dset, NULL); @@ -4285,15 +4281,15 @@ static void test_comps_array(const char *fname, const char *dset, const char *at assert(ret >= 0); /*----------------------------------- - * Create an attribute in root group - */ + * Create an attribute in root group + */ tid_attr = H5Acreate2(fid, attr, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT); assert(tid_attr > 0); ret = H5Awrite(tid_attr, tid_cmpd1, wdata); assert(ret >= 0); /* ---------------- - * Close Dataset */ + * Close Dataset */ ret = H5Aclose(tid_attr); assert(ret >= 0); ret = H5Tclose(tid_arry1); @@ -4310,57 +4306,56 @@ static void test_comps_array(const char *fname, const char *dset, const char *at assert(ret >= 0); } -static void test_comps_vlen(const char * fname, const char *dset, const char *attr, int diff, int is_file_new) +static void +test_comps_vlen(const char *fname, const char *dset, const char *attr, int diff, int is_file_new) { /* sub compound 2 */ typedef struct { - int i2; + int i2; float f2; } cmpd2_t; /* top compound 1 */ typedef struct { - int i1; + int i1; hvl_t vl; /* VL information for compound2 */ } cmpd1_t; cmpd1_t wdata[SDIM_DSET]; /* Dataset for compound1 */ - hid_t fid = -1; /* HDF5 File ID */ - hid_t did_dset = -1; /* dataset ID */ - hid_t sid_dset = -1; /* dataset space ID */ - hid_t tid_attr = -1; - hid_t tid_cmpd2 = -1; /* compound2 type ID */ - hid_t tid_cmpd1 = -1; /* compound1 type ID */ - hid_t tid_cmpd1_vlen = -1; - hsize_t sdims_dset[] = { SDIM_DSET }; + hid_t fid = H5I_INVALID_HID; /* HDF5 File ID */ + hid_t did_dset = H5I_INVALID_HID; /* dataset ID */ + hid_t sid_dset = H5I_INVALID_HID; /* dataset space ID */ + hid_t tid_attr = H5I_INVALID_HID; + hid_t tid_cmpd2 = H5I_INVALID_HID; /* compound2 type ID */ + hid_t tid_cmpd1 = H5I_INVALID_HID; /* compound1 type ID */ + hid_t tid_cmpd1_vlen = H5I_INVALID_HID; + hsize_t sdims_dset[] = {SDIM_DSET}; - unsigned i, j; /* counting variables */ - herr_t ret; /* Generic return value */ + unsigned i, j; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Allocate and initialize VL data to write */ for (i = 0; i < SDIM_DSET; i++) { - wdata[i].i1 = (int) i; - wdata[i].vl.p = HDmalloc((i + 1) * sizeof(cmpd2_t)); + wdata[i].i1 = (int)i; + wdata[i].vl.p = HDmalloc((i + 1) * sizeof(cmpd2_t)); wdata[i].vl.len = i + 1; for (j = 0; j < (i + 1); j++) { - ((cmpd2_t *) wdata[i].vl.p)[j].i2 = - (int) (i * 10 + (unsigned) diff); - ((cmpd2_t *) wdata[i].vl.p)[j].f2 = (float) i * 10.5F - + (float) diff; + ((cmpd2_t *)wdata[i].vl.p)[j].i2 = (int)(i * 10 + (unsigned)diff); + ((cmpd2_t *)wdata[i].vl.p)[j].f2 = (float)i * 10.5F + (float)diff; } /* end for */ - } /* end for */ + } /* end for */ /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ if (is_file_new == 1) fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); else fid = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT); /* ----------------------------- - * Create sub compound2 type */ + * Create sub compound2 type */ tid_cmpd2 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd2_t)); /* Insert fields */ @@ -4370,7 +4365,7 @@ static void test_comps_vlen(const char * fname, const char *dset, const char *at assert(ret >= 0); /* --------------------------- - * Create top compound1 type */ + * Create top compound1 type */ tid_cmpd1 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd1_t)); /* Insert fields */ ret = H5Tinsert(tid_cmpd1, "int1", HOFFSET(cmpd1_t, i1), H5T_NATIVE_INT); @@ -4382,8 +4377,8 @@ static void test_comps_vlen(const char * fname, const char *dset, const char *at assert(ret >= 0); /* ------------------------------- - * Create dataset with compound1 - */ + * Create dataset with compound1 + */ /* Create dataspace for dataset */ sid_dset = H5Screate_simple(1, sdims_dset, NULL); @@ -4395,19 +4390,19 @@ static void test_comps_vlen(const char * fname, const char *dset, const char *at assert(ret >= 0); /*----------------------------------- - * Create an attribute in root group - */ + * Create an attribute in root group + */ tid_attr = H5Acreate2(fid, attr, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT); assert(tid_attr > 0); ret = H5Awrite(tid_attr, tid_cmpd1, wdata); assert(ret >= 0); /* Reclaim the write VL data */ - ret = H5Dvlen_reclaim(tid_cmpd1, sid_dset, H5P_DEFAULT, wdata); + ret = H5Treclaim(tid_cmpd1, sid_dset, H5P_DEFAULT, wdata); assert(ret >= 0); /* ---------------- - * Close IDs */ + * Close IDs */ ret = H5Aclose(tid_attr); assert(ret >= 0); ret = H5Dclose(did_dset); @@ -4424,60 +4419,59 @@ static void test_comps_vlen(const char * fname, const char *dset, const char *at assert(ret >= 0); } -static void test_comps_array_vlen(const char * fname, const char *dset, const char *attr, int diff, int is_file_new) +static void +test_comps_array_vlen(const char *fname, const char *dset, const char *attr, int diff, int is_file_new) { typedef struct { - int i3; + int i3; float f3; } cmpd3_t; typedef struct { /* Typedef for compound datatype */ - int i2; + int i2; hvl_t vl; /* VL information to write */ } cmpd2_t; typedef struct { - int i1; + int i1; cmpd2_t cmpd2[SDIM_CMPD_ARRAY]; } cmpd1_t; - cmpd1_t wdata[SDIM_DSET]; /* Information to write */ - hid_t fid = -1; /* HDF5 File IDs */ - hid_t did_dset = -1; /* Dataset ID */ - hid_t sid_dset = -1; /* Dataspace ID */ - hid_t tid_attr = -1; - hid_t tid_cmpd1 = -1; /* Compound1 Datatype ID */ - hid_t tid_arry1 = -1; /* Array Datatype ID */ - hid_t tid_cmpd2 = -1; /* Compound2 Datatype ID */ - hid_t tid_cmpd2_vlen = -1; - hid_t tid_cmpd3 = -1; /* Compound3 Datatype ID */ - hsize_t sdims_dset[] = { SDIM_DSET }; - hsize_t sdims_arry[] = { SDIM_CMPD_ARRAY }; - unsigned i, j, k; /* counting variables */ - herr_t ret; /* Generic return value */ + cmpd1_t wdata[SDIM_DSET]; /* Information to write */ + hid_t fid = H5I_INVALID_HID; /* HDF5 File IDs */ + hid_t did_dset = H5I_INVALID_HID; /* Dataset ID */ + hid_t sid_dset = H5I_INVALID_HID; /* Dataspace ID */ + hid_t tid_attr = H5I_INVALID_HID; + hid_t tid_cmpd1 = H5I_INVALID_HID; /* Compound1 Datatype ID */ + hid_t tid_arry1 = H5I_INVALID_HID; /* Array Datatype ID */ + hid_t tid_cmpd2 = H5I_INVALID_HID; /* Compound2 Datatype ID */ + hid_t tid_cmpd2_vlen = H5I_INVALID_HID; + hid_t tid_cmpd3 = H5I_INVALID_HID; /* Compound3 Datatype ID */ + hsize_t sdims_dset[] = {SDIM_DSET}; + hsize_t sdims_arry[] = {SDIM_CMPD_ARRAY}; + unsigned i, j, k; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Initialize array data to write in compound1 */ for (i = 0; i < SDIM_DSET; i++) { - wdata[i].i1 = (int) i; + wdata[i].i1 = (int)i; /* Allocate and initialize VL data to write in compound2 */ for (j = 0; j < SDIM_CMPD_ARRAY; j++) { - wdata[i].cmpd2[j].i2 = (int) (j * 10); - wdata[i].cmpd2[j].vl.p = HDmalloc((j + 1) * sizeof(cmpd3_t)); + wdata[i].cmpd2[j].i2 = (int)(j * 10); + wdata[i].cmpd2[j].vl.p = HDmalloc((j + 1) * sizeof(cmpd3_t)); wdata[i].cmpd2[j].vl.len = j + 1; for (k = 0; k < (j + 1); k++) { /* Initialize data of compound3 */ - ((cmpd3_t *) wdata[i].cmpd2[j].vl.p)[k].i3 = (int) j * 10 - + diff; - ((cmpd3_t *) wdata[i].cmpd2[j].vl.p)[k].f3 = (float) j * 10.5F - + (float) diff; + ((cmpd3_t *)wdata[i].cmpd2[j].vl.p)[k].i3 = (int)j * 10 + diff; + ((cmpd3_t *)wdata[i].cmpd2[j].vl.p)[k].f3 = (float)j * 10.5F + (float)diff; } /* end for */ - } /* end for */ + } /* end for */ } /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ if (is_file_new == 1) fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); else @@ -4487,7 +4481,7 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch sid_dset = H5Screate_simple(1, sdims_dset, NULL); /*------------------------------------- - * Create a sub compound3 datatype */ + * Create a sub compound3 datatype */ tid_cmpd3 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd3_t)); /* Insert integer field */ @@ -4499,7 +4493,7 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch assert(ret >= 0); /*------------------------------------- - * Create a sub compound2 datatype */ + * Create a sub compound2 datatype */ tid_cmpd2 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd2_t)); /* Insert integer field */ @@ -4507,12 +4501,12 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch assert(ret >= 0); /* Create a VL datatype */ tid_cmpd2_vlen = H5Tvlen_create(tid_cmpd3); - ret = H5Tinsert(tid_cmpd2, "vlen", HOFFSET(cmpd2_t, vl), tid_cmpd2_vlen); + ret = H5Tinsert(tid_cmpd2, "vlen", HOFFSET(cmpd2_t, vl), tid_cmpd2_vlen); assert(ret >= 0); /*----------------------------------- - * Create a top compound1 datatype for dataset. - */ + * Create a top compound1 datatype for dataset. + */ tid_cmpd1 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd1_t)); /* Create an array datatype */ @@ -4521,7 +4515,7 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch H5Tinsert(tid_cmpd1, "array_comp", HOFFSET(cmpd1_t, cmpd2), tid_arry1); /* ---------------------- - * Create a dataset */ + * Create a dataset */ did_dset = H5Dcreate2(fid, dset, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* Write dataset to disk */ @@ -4529,19 +4523,19 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch assert(ret >= 0); /*----------------------------------- - * Create an attribute in root group - */ + * Create an attribute in root group + */ tid_attr = H5Acreate2(fid, attr, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT); assert(tid_attr > 0); ret = H5Awrite(tid_attr, tid_cmpd1, wdata); assert(ret >= 0); /* Reclaim the write VL data */ - ret = H5Dvlen_reclaim(tid_cmpd1, sid_dset, H5P_DEFAULT, wdata); + ret = H5Treclaim(tid_cmpd1, sid_dset, H5P_DEFAULT, wdata); assert(ret >= 0); /*------------------- - * Close IDs */ + * Close IDs */ ret = H5Aclose(tid_attr); assert(ret >= 0); ret = H5Tclose(tid_arry1); @@ -4562,70 +4556,71 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch assert(ret >= 0); } -static void test_comps_vlen_arry(const char * fname, const char *dset, const char *attr, int diff, int is_file_new) +static void +test_comps_vlen_arry(const char *fname, const char *dset, const char *attr, int diff, int is_file_new) { /* sub compound 3 */ typedef struct { - int i3; + int i3; float f3; } cmpd3_t; /* sub compound 2 */ typedef struct { - int i2; + int i2; cmpd3_t cmpd3[SDIM_CMPD_ARRAY]; } cmpd2_t; /* top compound 1 */ typedef struct { - int i1; + int i1; hvl_t vl; /* VL information for compound2 */ } cmpd1_t; cmpd1_t wdata[SDIM_DSET]; /* Dataset for compound1 */ - hid_t fid = -1; /* HDF5 File ID */ - hid_t did_dset = -1; /* dataset ID */ - hid_t sid_dset = -1; /* dataset space ID */ - hid_t tid_attr = -1; - hid_t tid_cmpd3 = -1; /* compound3 type ID */ - hid_t tid_cmpd2 = -1; /* compound2 type ID */ - hid_t tid_cmpd2_arry = -1; - hid_t tid_cmpd1 = -1; /* compound1 type ID */ - hid_t tid_cmpd1_vlen = -1; - hsize_t sdims_dset[] = { SDIM_DSET }; - hsize_t sdims_cmpd_arry[] = { SDIM_CMPD_ARRAY }; - - unsigned i, j, k; /* counting variables */ - herr_t ret; /* Generic return value */ + hid_t fid = H5I_INVALID_HID; /* HDF5 File ID */ + hid_t did_dset = H5I_INVALID_HID; /* dataset ID */ + hid_t sid_dset = H5I_INVALID_HID; /* dataset space ID */ + hid_t tid_attr = H5I_INVALID_HID; + hid_t tid_cmpd3 = H5I_INVALID_HID; /* compound3 type ID */ + hid_t tid_cmpd2 = H5I_INVALID_HID; /* compound2 type ID */ + hid_t tid_cmpd2_arry = H5I_INVALID_HID; + hid_t tid_cmpd1 = H5I_INVALID_HID; /* compound1 type ID */ + hid_t tid_cmpd1_vlen = H5I_INVALID_HID; + hsize_t sdims_dset[] = {SDIM_DSET}; + hsize_t sdims_cmpd_arry[] = {SDIM_CMPD_ARRAY}; + + unsigned i, j, k; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Allocate and initialize VL data to write */ for (i = 0; i < SDIM_DSET; i++) { /* compound 1 data */ - wdata[i].i1 = (int) i; - wdata[i].vl.p = HDmalloc((i + 1) * sizeof(cmpd2_t)); + wdata[i].i1 = (int)i; + wdata[i].vl.p = HDmalloc((i + 1) * sizeof(cmpd2_t)); wdata[i].vl.len = i + 1; for (j = 0; j < (i + 1); j++) { /* compound2 data */ - ((cmpd2_t *) wdata[i].vl.p)[j].i2 = (int) i * 10 + diff; + ((cmpd2_t *)wdata[i].vl.p)[j].i2 = (int)i * 10 + diff; for (k = 0; k < SDIM_CMPD_ARRAY; k++) { /* compound 3 data */ - ((cmpd2_t *) (wdata[i].vl.p))[j].cmpd3[k].i3 = (int) ((float) k * 10.5F) + diff; - ((cmpd2_t *) (wdata[i].vl.p))[j].cmpd3[k].f3 = (float) k * 10.5F + (float) diff; + ((cmpd2_t *)(wdata[i].vl.p))[j].cmpd3[k].i3 = (int)((float)k * 10.5F) + diff; + ((cmpd2_t *)(wdata[i].vl.p))[j].cmpd3[k].f3 = (float)k * 10.5F + (float)diff; } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ if (is_file_new == 1) fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); else fid = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT); /* ----------------------------- - * Create sub compound3 type */ + * Create sub compound3 type */ tid_cmpd3 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd3_t)); /* Insert fields */ @@ -4635,56 +4630,55 @@ static void test_comps_vlen_arry(const char * fname, const char *dset, const cha assert(ret >= 0); /* ----------------------------- - * Create sub compound2 type */ + * Create sub compound2 type */ tid_cmpd2 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd2_t)); ret = H5Tinsert(tid_cmpd2, "int2", HOFFSET(cmpd2_t, i2), H5T_NATIVE_INT); assert(ret >= 0); tid_cmpd2_arry = H5Tarray_create2(tid_cmpd3, 1, sdims_cmpd_arry); - ret = H5Tinsert(tid_cmpd2, "array_cmpd2", HOFFSET(cmpd2_t, cmpd3), tid_cmpd2_arry); + ret = H5Tinsert(tid_cmpd2, "array_cmpd2", HOFFSET(cmpd2_t, cmpd3), tid_cmpd2_arry); assert(ret >= 0); /* --------------------------- - * Create top compound1 type - */ + * Create top compound1 type + */ /* Create a VL datatype */ tid_cmpd1 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd1_t)); /* Insert fields */ ret = H5Tinsert(tid_cmpd1, "int1", HOFFSET(cmpd1_t, i1), H5T_NATIVE_INT); assert(ret >= 0); tid_cmpd1_vlen = H5Tvlen_create(tid_cmpd2); - ret = H5Tinsert(tid_cmpd1, "vlen_cmpd1", HOFFSET(cmpd1_t, vl), tid_cmpd1_vlen); + ret = H5Tinsert(tid_cmpd1, "vlen_cmpd1", HOFFSET(cmpd1_t, vl), tid_cmpd1_vlen); assert(ret >= 0); /* ------------------------------- - * Create dataset with compound1 - */ + * Create dataset with compound1 + */ /* Create dataspace for dataset */ sid_dset = H5Screate_simple(1, sdims_dset, NULL); /* Create a dataset */ - did_dset = H5Dcreate2(fid, dset, tid_cmpd1, sid_dset, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + did_dset = H5Dcreate2(fid, dset, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* Write dataset to disk */ ret = H5Dwrite(did_dset, tid_cmpd1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); assert(ret >= 0); /*----------------------------------- - * Create an attribute in root group - */ + * Create an attribute in root group + */ tid_attr = H5Acreate2(fid, attr, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT); assert(tid_attr > 0); ret = H5Awrite(tid_attr, tid_cmpd1, wdata); assert(ret >= 0); /* Reclaim the write VL data */ - ret = H5Dvlen_reclaim(tid_cmpd1, sid_dset, H5P_DEFAULT, wdata); + ret = H5Treclaim(tid_cmpd1, sid_dset, H5P_DEFAULT, wdata); assert(ret >= 0); /* ---------------- - * Close IDs */ + * Close IDs */ ret = H5Aclose(tid_attr); assert(ret >= 0); ret = H5Dclose(did_dset); @@ -4715,83 +4709,83 @@ static void test_comps_vlen_arry(const char * fname, const char *dset, const cha * *-------------------------------------------------------------------------*/ #define DIM_ARRY 3 -static void test_data_nocomparables(const char * fname, int make_diffs) +static void +test_data_nocomparables(const char *fname, int make_diffs) { - hid_t fid = -1; - hid_t gid1 = -1; - hid_t gid2 = -1; - hid_t did1 = -1; - hid_t did2 = -1; - hid_t sid1 = -1; - hid_t tid_dset1 = -1; - hid_t tid_attr1 = -1; - hsize_t dims1_1[1] = { DIM_ARRY }; - hsize_t dims1_2[1] = { DIM_ARRY + 1 }; - hsize_t dims2[2] = { DIM_ARRY, 1 }; - int data1[DIM_ARRY] = { 0, 0, 0 }; - int data2[DIM_ARRY] = { 1, 1, 1 }; - int data3[DIM_ARRY + 1] = { 1, 1, 1, 1 }; - int data1_dim2[DIM_ARRY][1] = { { 0 }, { 0 }, { 0 } }; - int rank_attr; - char data1_str[DIM_ARRY][STR_SIZE] = { "ab", "cd", "ef" }; - herr_t status = SUCCEED; - void *dset_data_ptr1 = NULL; - void *dset_data_ptr2 = NULL; - void *dset_data_ptr3 = NULL; - void *attr_data_ptr1 = NULL; - void *attr_data_ptr2 = NULL; - void *attr_data_ptr3 = NULL; - void *attr_data_ptr4 = NULL; - void *attr2_dim_ptr = NULL; - void *attr3_dim_ptr = NULL; + hid_t fid = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hid_t did1 = H5I_INVALID_HID; + hid_t did2 = H5I_INVALID_HID; + hid_t sid1 = H5I_INVALID_HID; + hid_t tid_dset1 = H5I_INVALID_HID; + hid_t tid_attr1 = H5I_INVALID_HID; + hsize_t dims1_1[1] = {DIM_ARRY}; + hsize_t dims1_2[1] = {DIM_ARRY + 1}; + hsize_t dims2[2] = {DIM_ARRY, 1}; + int data1[DIM_ARRY] = {0, 0, 0}; + int data2[DIM_ARRY] = {1, 1, 1}; + int data3[DIM_ARRY + 1] = {1, 1, 1, 1}; + int data1_dim2[DIM_ARRY][1] = {{0}, {0}, {0}}; + int rank_attr; + char data1_str[DIM_ARRY][STR_SIZE] = {"ab", "cd", "ef"}; + herr_t status = SUCCEED; + void * dset_data_ptr1 = NULL; + void * dset_data_ptr2 = NULL; + void * dset_data_ptr3 = NULL; + void * attr_data_ptr1 = NULL; + void * attr_data_ptr2 = NULL; + void * attr_data_ptr3 = NULL; + void * attr_data_ptr4 = NULL; + void * attr2_dim_ptr = NULL; + void * attr3_dim_ptr = NULL; /* init */ - tid_dset1 = H5Tcopy(H5T_NATIVE_INT); - dset_data_ptr1 = (int*) &data1; - dset_data_ptr2 = (int*) &data1; - dset_data_ptr3 = (int*) &data1; - tid_attr1 = H5Tcopy(H5T_NATIVE_INT); - attr_data_ptr1 = (int*) &data1; - attr_data_ptr3 = (int*) &data1; - attr_data_ptr4 = (int*) &data1; - attr2_dim_ptr = (hsize_t*) &dims1_1; - attr3_dim_ptr = (hsize_t*) &dims1_1; - rank_attr = 1; + tid_dset1 = H5Tcopy(H5T_NATIVE_INT); + dset_data_ptr1 = (int *)&data1; + dset_data_ptr2 = (int *)&data1; + dset_data_ptr3 = (int *)&data1; + tid_attr1 = H5Tcopy(H5T_NATIVE_INT); + attr_data_ptr1 = (int *)&data1; + attr_data_ptr3 = (int *)&data1; + attr_data_ptr4 = (int *)&data1; + attr2_dim_ptr = (hsize_t *)&dims1_1; + attr3_dim_ptr = (hsize_t *)&dims1_1; + rank_attr = 1; if (make_diffs) { /* ------------ - * group1 */ + * group1 */ tid_dset1 = H5Tcopy(H5T_C_S1); - H5Tset_size(tid_dset1, (size_t) STR_SIZE); - dset_data_ptr1 = (char*) &data1_str; - dset_data_ptr2 = (int*) &data2; - attr_data_ptr1 = (int*) &data2; + H5Tset_size(tid_dset1, (size_t)STR_SIZE); + dset_data_ptr1 = (char *)&data1_str; + dset_data_ptr2 = (int *)&data2; + attr_data_ptr1 = (int *)&data2; /* ----------- - * group2 - */ - dset_data_ptr3 = (int*) &data2; + * group2 + */ + dset_data_ptr3 = (int *)&data2; /* dset1/attr1 */ tid_attr1 = H5Tcopy(H5T_C_S1); - H5Tset_size(tid_attr1, (size_t) STR_SIZE); - attr_data_ptr2 = (char*) &data1_str; + H5Tset_size(tid_attr1, (size_t)STR_SIZE); + attr_data_ptr2 = (char *)&data1_str; /* dset1/attr2 */ - attr2_dim_ptr = (hsize_t*) &dims1_2; + attr2_dim_ptr = (hsize_t *)&dims1_2; /* dset1/attr3 */ - attr_data_ptr3 = (int*) &data1_dim2; - attr3_dim_ptr = (hsize_t*) &dims2; - rank_attr = 2; + attr_data_ptr3 = (int *)&data1_dim2; + attr3_dim_ptr = (hsize_t *)&dims2; + rank_attr = 2; /* dset1/attr4 */ - attr_data_ptr4 = (int*) &data2; - + attr_data_ptr4 = (int *)&data2; } /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname); @@ -4800,8 +4794,8 @@ static void test_data_nocomparables(const char * fname, int make_diffs) } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ gid1 = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname); @@ -4817,8 +4811,8 @@ static void test_data_nocomparables(const char * fname, int make_diffs) } /*----------------------------------------------------------------------- - * Datasets in /g1 - *------------------------------------------------------------------------*/ + * Datasets in /g1 + *------------------------------------------------------------------------*/ if ((sid1 = H5Screate_simple(1, dims1_1, NULL)) < 0) goto out; @@ -4844,10 +4838,10 @@ static void test_data_nocomparables(const char * fname, int make_diffs) } /*----------------------------------------------------------------------- - * Datasets in /g2 - *------------------------------------------------------------------------*/ + * Datasets in /g2 + *------------------------------------------------------------------------*/ /* --------- - * dset1 */ + * dset1 */ if ((did2 = H5Dcreate2(gid2, "dset1", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { HDfprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", "dset1"); status = FAIL; @@ -4862,17 +4856,17 @@ static void test_data_nocomparables(const char * fname, int make_diffs) /* attr1 - non-compatible : different type */ write_attr(did2, 1, dims1_1, "attr1", tid_attr1, attr_data_ptr2); - /* attr2 - non-compatible : same rank, different dimention */ - write_attr(did2, 1, (hsize_t *) attr2_dim_ptr, "attr2", H5T_NATIVE_INT, data3); + /* attr2 - non-compatible : same rank, different dimension */ + write_attr(did2, 1, (hsize_t *)attr2_dim_ptr, "attr2", H5T_NATIVE_INT, data3); /* attr3 - non-compatible : different rank */ - write_attr(did2, rank_attr, (hsize_t *) attr3_dim_ptr, "attr3", H5T_NATIVE_INT, attr_data_ptr3); + write_attr(did2, rank_attr, (hsize_t *)attr3_dim_ptr, "attr3", H5T_NATIVE_INT, attr_data_ptr3); /* attr4 - compatible : different data values */ write_attr(did2, 1, dims1_1, "attr4", H5T_NATIVE_INT, attr_data_ptr4); /*---------- - * dset2 */ + * dset2 */ status = write_dset(gid2, 1, dims1_1, "dset2", H5T_NATIVE_INT, dset_data_ptr3); if (status == FAIL) { HDfprintf(stderr, "Error: %s> write_dset failed\n", fname); @@ -4882,8 +4876,8 @@ static void test_data_nocomparables(const char * fname, int make_diffs) out: /*----------------------------------------------------------------------- - * Close IDs - *-----------------------------------------------------------------------*/ + * Close IDs + *-----------------------------------------------------------------------*/ if (fid) H5Fclose(fid); if (gid1) @@ -4913,95 +4907,96 @@ out: static void test_objs_nocomparables(const char *fname1, const char *fname2) { - hid_t fid1 = -1; - hid_t fid2 = -1; - hid_t topgid1 = -1; - hid_t topgid2 = -1; - hid_t gid1 = -1; - hid_t tid1 = -1; - hid_t gid2 = -1; - hid_t tid2 = -1; - hsize_t dims[1] = { DIM_ARRY }; - int data1[DIM_ARRY] = { 1, 1, 1 }; - int data2[DIM_ARRY] = { 2, 2, 2 }; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t topgid1 = H5I_INVALID_HID; + hid_t topgid2 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t tid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hid_t tid2 = H5I_INVALID_HID; + hsize_t dims[1] = {DIM_ARRY}; + int data1[DIM_ARRY] = {1, 1, 1}; + int data2[DIM_ARRY] = {2, 2, 2}; /*----------------------------------------------------------------------- - * Open file(s) to add objects - *------------------------------------------------------------------------*/ + * Open file(s) to add objects + *------------------------------------------------------------------------*/ /* file1 */ - if((fid1 = H5Fopen(fname1, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) - PROGRAM_ERROR + if ((fid1 = H5Fopen(fname1, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + PROGRAM_ERROR; /* file2 */ - if((fid2 = H5Fopen(fname2, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) - PROGRAM_ERROR + if ((fid2 = H5Fopen(fname2, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + PROGRAM_ERROR; /*----------------------------------------------------------------------- - * in file1 : add member objects - *------------------------------------------------------------------------*/ + * in file1 : add member objects + *------------------------------------------------------------------------*/ /* parent group */ - if((topgid1 = H5Gcreate2(fid1, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - PROGRAM_ERROR + if ((topgid1 = H5Gcreate2(fid1, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + PROGRAM_ERROR; /* dataset */ - if(write_dset(topgid1, 1, dims, "obj1", H5T_NATIVE_INT, data1) < 0) - PROGRAM_ERROR + if (write_dset(topgid1, 1, dims, "obj1", H5T_NATIVE_INT, data1) < 0) + PROGRAM_ERROR; /* group */ - if((gid1 = H5Gcreate2(topgid1, "obj2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - PROGRAM_ERROR + if ((gid1 = H5Gcreate2(topgid1, "obj2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + PROGRAM_ERROR; /* committed type */ - if((tid1 = H5Tcopy(H5T_NATIVE_INT)) < 0) - PROGRAM_ERROR - if(H5Tcommit2(topgid1, "obj3", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) - PROGRAM_ERROR + if ((tid1 = H5Tcopy(H5T_NATIVE_INT)) < 0) + PROGRAM_ERROR; + if (H5Tcommit2(topgid1, "obj3", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + PROGRAM_ERROR; /*----------------------------------------------------------------------- - * in file2 : add member objects - *------------------------------------------------------------------------*/ + * in file2 : add member objects + *------------------------------------------------------------------------*/ /* parent group */ - if((topgid2 = H5Gcreate2(fid2, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - PROGRAM_ERROR + if ((topgid2 = H5Gcreate2(fid2, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + PROGRAM_ERROR; /* group */ - if((gid2 = H5Gcreate2(topgid2, "obj1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - PROGRAM_ERROR + if ((gid2 = H5Gcreate2(topgid2, "obj1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + PROGRAM_ERROR; /* committed type */ - if((tid2 = H5Tcopy(H5T_NATIVE_INT)) < 0) - PROGRAM_ERROR - if(H5Tcommit2(topgid2, "obj2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) - PROGRAM_ERROR + if ((tid2 = H5Tcopy(H5T_NATIVE_INT)) < 0) + PROGRAM_ERROR; + if (H5Tcommit2(topgid2, "obj2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + PROGRAM_ERROR; /* dataset */ - if(write_dset(topgid2, 1, dims, "obj3", H5T_NATIVE_INT, data2) < 0) - PROGRAM_ERROR + if (write_dset(topgid2, 1, dims, "obj3", H5T_NATIVE_INT, data2) < 0) + PROGRAM_ERROR; /*----------------------------------------------------------------------- - * Close IDs - *-----------------------------------------------------------------------*/ - if(H5Fclose(fid1) < 0) - PROGRAM_ERROR - if(H5Fclose(fid2) < 0) - PROGRAM_ERROR - if(H5Gclose(topgid1) < 0) - PROGRAM_ERROR - if(H5Gclose(topgid2) < 0) - PROGRAM_ERROR - if(H5Gclose(gid1) < 0) - PROGRAM_ERROR - if(H5Gclose(gid2) < 0) - PROGRAM_ERROR - if(H5Tclose(tid1) < 0) - PROGRAM_ERROR - if(H5Tclose(tid2) < 0) - PROGRAM_ERROR + * Close IDs + *-----------------------------------------------------------------------*/ + if (H5Fclose(fid1) < 0) + PROGRAM_ERROR; + if (H5Fclose(fid2) < 0) + PROGRAM_ERROR; + if (H5Gclose(topgid1) < 0) + PROGRAM_ERROR; + if (H5Gclose(topgid2) < 0) + PROGRAM_ERROR; + if (H5Gclose(gid1) < 0) + PROGRAM_ERROR; + if (H5Gclose(gid2) < 0) + PROGRAM_ERROR; + if (H5Tclose(tid1) < 0) + PROGRAM_ERROR; + if (H5Tclose(tid2) < 0) + PROGRAM_ERROR; return; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid1); H5Fclose(fid2); H5Gclose(topgid1); @@ -5010,18 +5005,18 @@ error: H5Gclose(gid2); H5Tclose(tid1); H5Tclose(tid2); - } H5E_END_TRY; - - return; + } + H5E_END_TRY; } -static hid_t mkstr(int size, H5T_str_t pad) +static hid_t +mkstr(int size, H5T_str_t pad) { hid_t type; if ((type = H5Tcopy(H5T_C_S1)) < 0) return -1; - if (H5Tset_size(type, (size_t) size) < 0) + if (H5Tset_size(type, (size_t)size) < 0) return -1; if (H5Tset_strpad(type, pad) < 0) return -1; @@ -5037,51 +5032,44 @@ static hid_t mkstr(int size, H5T_str_t pad) * types. * h5diff should show differences output from these common objects. *-------------------------------------------------------------------------*/ -static void test_objs_strings(const char *fname1, const char *fname2) +static void +test_objs_strings(const char *fname1, const char *fname2) { - hid_t fid1 = -1; - hid_t fid2 = -1; - hid_t dataset = -1; - hid_t space = -1; - hid_t f_type = -1; - hid_t m_type = -1; - hsize_t dims1[] = { 3, 4 }; - char string1A[12][3] = { "s1", "s2", "s3", "s4", "s5", "s6", "s", "s", "s9", - "s0", "s1", "s2" }; - char string1B[12][3] = { "s1", "s2", "s3", "s4", "s", "s", "s7", "s8", "s9", - "s0", "s1", "s2" }; - - hsize_t dims2[] = { 20 }; - char string2A[20][10] = { "ab cd ef1", "ab cd ef2", "ab cd ef3", - "ab cd ef4", "ab cd ef5", "ab cd ef6", "ab cd ef7", "ab cd ef8", - "ab cd 9", "ab cd 0", "ab cd 1", "ab cd 2", "ab cd ef3", - "ab cd ef4", "ab cd ef5", "ab cd ef6", "ab cd ef7", "ab cd ef8", - "ab cd ef9", "ab cd ef0" }; - char string2B[20][10] = { "ab cd ef1", "ab cd ef2", "ab cd ef3", - "ab cd ef4", "ab cd ef5", "ab cd ef6", "ab cd ef7", "ab cd ef8", - "ab cd ef9", "ab cd ef0", "ab cd ef1", "ab cd ef2", "ab cd 3", - "ab cd 4", "ab cd 5", "ab cd 6", "ab cd ef7", "ab cd ef8", - "ab cd ef9", "ab cd ef0" }; - - hsize_t dims3[] = { 27 }; - char string3A[27][6] = { "abcd0", "abcd1", "abcd2", "abcd3", "abcd4", - "abcd5", "abcd6", "abcd7", "abcd8", "abcd9", "abcd0", "abcd1", - "abd2", "abc3", "bcd4", "acd5", "abcd6", "abcd7", "abcd8", "abcd9", - "abcd0", "abcd1", "abcd2", "abcd3", "abc4", "abc5", "abc6" }; - char string3B[27][6] = { "abcd0", "abcd1", "abcd2", "abcd3", "abcd4", - "abcd5", "abcd6", "abcd7", "abcd8", "abcd9", "abcd0", "abcd1", - "abcd2", "abcd3", "abcd4", "abcd5", "abd6", "abc7", "bcd8", "acd9", - "abcd0", "abcd1", "abcd2", "abcd3", "abd4", "abd5", "abd6" }; - - hsize_t dims4[] = { 3 }; - char string4A[3][21] = { "s1234567890123456789", "s1234567890123456789", - "s12345678901234567" }; - char string4B[3][21] = { "s1234567890123456789", "s12345678901234567", - "s1234567890123456789" }; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t f_type = H5I_INVALID_HID; + hid_t m_type = H5I_INVALID_HID; + hsize_t dims1[] = {3, 4}; + char string1A[12][3] = {"s1", "s2", "s3", "s4", "s5", "s6", "s", "s", "s9", "s0", "s1", "s2"}; + char string1B[12][3] = {"s1", "s2", "s3", "s4", "s", "s", "s7", "s8", "s9", "s0", "s1", "s2"}; + + hsize_t dims2[] = {20}; + char string2A[20][10] = {"ab cd ef1", "ab cd ef2", "ab cd ef3", "ab cd ef4", "ab cd ef5", + "ab cd ef6", "ab cd ef7", "ab cd ef8", "ab cd 9", "ab cd 0", + "ab cd 1", "ab cd 2", "ab cd ef3", "ab cd ef4", "ab cd ef5", + "ab cd ef6", "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0"}; + char string2B[20][10] = {"ab cd ef1", "ab cd ef2", "ab cd ef3", "ab cd ef4", "ab cd ef5", + "ab cd ef6", "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0", + "ab cd ef1", "ab cd ef2", "ab cd 3", "ab cd 4", "ab cd 5", + "ab cd 6", "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0"}; + + hsize_t dims3[] = {27}; + char string3A[27][6] = {"abcd0", "abcd1", "abcd2", "abcd3", "abcd4", "abcd5", "abcd6", "abcd7", "abcd8", + "abcd9", "abcd0", "abcd1", "abd2", "abc3", "bcd4", "acd5", "abcd6", "abcd7", + "abcd8", "abcd9", "abcd0", "abcd1", "abcd2", "abcd3", "abc4", "abc5", "abc6"}; + char string3B[27][6] = {"abcd0", "abcd1", "abcd2", "abcd3", "abcd4", "abcd5", "abcd6", "abcd7", "abcd8", + "abcd9", "abcd0", "abcd1", "abcd2", "abcd3", "abcd4", "abcd5", "abd6", "abc7", + "bcd8", "acd9", "abcd0", "abcd1", "abcd2", "abcd3", "abd4", "abd5", "abd6"}; + + hsize_t dims4[] = {3}; + char string4A[3][21] = {"s1234567890123456789", "s1234567890123456789", "s12345678901234567"}; + char string4B[3][21] = {"s1234567890123456789", "s12345678901234567", "s1234567890123456789"}; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ /* file1 */ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { @@ -5097,9 +5085,9 @@ static void test_objs_strings(const char *fname1, const char *fname2) } /* string 1 : nullterm string */ - space = H5Screate_simple(2, dims1, NULL); - f_type = mkstr(5, H5T_STR_NULLTERM); - m_type = mkstr(3, H5T_STR_NULLTERM); + space = H5Screate_simple(2, dims1, NULL); + f_type = mkstr(5, H5T_STR_NULLTERM); + m_type = mkstr(3, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid1, "/string1", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string1A); H5Dclose(dataset); @@ -5111,9 +5099,9 @@ static void test_objs_strings(const char *fname1, const char *fname2) H5Dclose(dataset); /* string 2 : space pad string */ - space = H5Screate_simple(1, dims2, NULL); - f_type = mkstr(11, H5T_STR_SPACEPAD); - m_type = mkstr(10, H5T_STR_NULLTERM); + space = H5Screate_simple(1, dims2, NULL); + f_type = mkstr(11, H5T_STR_SPACEPAD); + m_type = mkstr(10, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid1, "/string2", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string2A); H5Dclose(dataset); @@ -5125,9 +5113,9 @@ static void test_objs_strings(const char *fname1, const char *fname2) H5Dclose(dataset); /* string 3 : null pad string */ - space = H5Screate_simple(1, dims3, NULL); - f_type = mkstr(8, H5T_STR_NULLPAD); - m_type = mkstr(6, H5T_STR_NULLTERM); + space = H5Screate_simple(1, dims3, NULL); + f_type = mkstr(8, H5T_STR_NULLPAD); + m_type = mkstr(6, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid1, "/string3", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string3A); H5Dclose(dataset); @@ -5139,9 +5127,9 @@ static void test_objs_strings(const char *fname1, const char *fname2) H5Dclose(dataset); /* string 4 : space pad long string */ - space = H5Screate_simple(1, dims4, NULL); - f_type = mkstr(168, H5T_STR_SPACEPAD); - m_type = mkstr(21, H5T_STR_NULLTERM); + space = H5Screate_simple(1, dims4, NULL); + f_type = mkstr(168, H5T_STR_SPACEPAD); + m_type = mkstr(21, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid1, "/string4", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string4A); H5Dclose(dataset); @@ -5167,10 +5155,10 @@ static void test_objs_strings(const char *fname1, const char *fname2) string4B[2][11] = 'a'; string4B[2][12] = 'B'; string4B[2][13] = 'c'; - space = H5Screate_simple(1, dims4, NULL); - f_type = mkstr(168, H5T_STR_NULLTERM); - m_type = mkstr(21, H5T_STR_NULLTERM); - dataset = H5Dcreate2(fid1, "/string5", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, dims4, NULL); + f_type = mkstr(168, H5T_STR_NULLTERM); + m_type = mkstr(21, H5T_STR_NULLTERM); + dataset = H5Dcreate2(fid1, "/string5", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string4A); H5Dclose(dataset); dataset = H5Dcreate2(fid2, "/string5", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -5182,8 +5170,8 @@ static void test_objs_strings(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close IDs - *-----------------------------------------------------------------------*/ + * Close IDs + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -5198,78 +5186,77 @@ out: * *------------------------------------------------------------------------- */ -static -void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs /* flag to modify data buffers */) +static void +write_attr_strings(hid_t loc_id, const char *dset_name, hid_t fid, + int make_diffs /* flag to modify data buffers */) { /* Compound datatype */ typedef struct s_t { - char a; + char a; double b; } s_t; - typedef enum { - RED, GREEN - } e_t; + typedef enum { RED, GREEN } e_t; - hid_t aid = -1; - hid_t sid = -1; - hid_t tid = -1; - herr_t status; - int val, i, j, k, l, n; - float f; + hid_t aid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + herr_t H5_ATTR_NDEBUG_UNUSED status; + int val, i, j, k, l, n; + float f; /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1] = { 2 }; - char buf1[2][STR_SIZE] = { "ab", "de" }; /* string */ - char *buf1a[2]; /* VL string */ - char buf2[2] = { 1, 2 }; /* bitfield, opaque */ - s_t buf3[2] = { { 1, 2.0F }, { 3, 4.0F } }; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - e_t buf45[2] = { RED, RED }; /* enum */ - hvl_t buf5[2]; /* vlen */ - hsize_t dimarray[1] = { 3 }; /* array dimension */ - int buf6[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } }; /* array */ - int buf7[2] = { 1, 2 }; /* integer */ - float buf8[2] = { 1.0F, 2.0F }; /* float */ + hsize_t dims[1] = {2}; + char buf1[2][STR_SIZE] = {"ab", "de"}; /* string */ + char * buf1a[2]; /* VL string */ + char buf2[2] = {1, 2}; /* bitfield, opaque */ + s_t buf3[2] = {{1, 2.0}, {3, 4.0}}; /* 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.0, 2.0}; /* float */ /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2] = { 3, 2 }; - char buf12[3][2][STR_SIZE] = { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }; /* string */ - char *buf12a[3][2]; /* VL string */ - char buf22[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* bitfield, opaque */ - s_t buf32[6] = { { 1, 2.0F }, { 3, 4.0F }, { 5, 6.0F }, { 7, 8.0F }, { 9, 10.0F }, { 11, 12.0F } }; /* compound */ - hobj_ref_t buf42[3][2]; /* reference */ - e_t buf452[3][2]; /* enum */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 }, { 13, 14, 15 }, { 16, 17, 18 } }; /* array */ - int buf72[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* integer */ - float buf82[3][2] = { { 1.0F, 2.0F }, { 3.0F, 4.0F }, { 5.0F, 6.0F } }; /* float */ + hsize_t dims2[2] = {3, 2}; + char buf12[3][2][STR_SIZE] = {{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}; /* string */ + char * buf12a[3][2]; /* VL string */ + char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */ + s_t buf32[6] = {{1, 2.0}, {3, 4.0}, {5, 6.0}, {7, 8.0}, {9, 10.0}, {11, 12.0}}; /* 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.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}}; /* float */ /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3] = { 4, 3, 2 }; - char buf13[4][3][2][STR_SIZE] = { { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }, - { { "mn", "pq" }, { "rs", "tu" }, { "vw", "xz" } }, - { { "AB", "CD" }, { "EF", "GH" }, { "IJ", "KL" } }, - { { "MN", "PQ" }, { "RS", "TU" }, { "VW", "XZ" } } }; /* string */ - char *buf13a[4][3][2]; /* VL string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[4][3][2]; /* reference */ - e_t buf453[4][3][2]; /* enum */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ - - /*------------------------------------------------------------------------- - * 1D attributes - *------------------------------------------------------------------------- - */ + hsize_t dims3[3] = {4, 3, 2}; + char buf13[4][3][2][STR_SIZE] = {{{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}, + {{"mn", "pq"}, {"rs", "tu"}, {"vw", "xz"}}, + {{"AB", "CD"}, {"EF", "GH"}, {"IJ", "KL"}}, + {{"MN", "PQ"}, {"RS", "TU"}, {"VW", "XZ"}}}; /* string */ + char * buf13a[4][3][2]; /* VL string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[4][3][2]; /* reference */ + e_t buf453[4][3][2]; /* enum */ + hvl_t buf53[4][3][2]; /* vlen */ + int buf63[24][3]; /* array */ + int buf73[4][3][2]; /* integer */ + float buf83[4][3][2]; /* float */ + + /*------------------------------------------------------------------------- + * 1D attributes + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -5291,20 +5278,20 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make for (i = 0; i < 2; i++) buf1a[i] = buf1[i]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 1, dims, "string", tid, buf1a); status = H5Tclose(tid); - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 1, dims, "VLstring", tid, buf1); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -5326,9 +5313,9 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ /* buf2[2]= {1,2}; @@ -5342,15 +5329,15 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make [ 1 ] 2 0 2 */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 1, dims, "opaque", tid, buf2); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) { @@ -5378,13 +5365,13 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { - status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t) -1); - status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 1, dims, "reference", H5T_STD_REF_OBJ, buf4); } @@ -5418,18 +5405,18 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make /* Allocate and initialize VL dataset to write */ - buf5[0].len = 1; - buf5[0].p = HDmalloc(1 * sizeof(int)); - ((int *) buf5[0].p)[0] = 1; - buf5[1].len = 2; - buf5[1].p = HDmalloc(2 * sizeof(int)); - ((int *) buf5[1].p)[0] = 2; - ((int *) buf5[1].p)[1] = 3; + buf5[0].len = 1; + buf5[0].p = HDmalloc(1 * sizeof(int)); + ((int *)buf5[0].p)[0] = 1; + buf5[1].len = 2; + buf5[1].p = HDmalloc(2 * sizeof(int)); + ((int *)buf5[1].p)[0] = 2; + ((int *)buf5[1].p)[1] = 3; if (make_diffs) { - ((int *) buf5[0].p)[0] = 0; - ((int *) buf5[1].p)[0] = 0; - ((int *) buf5[1].p)[1] = 0; + ((int *)buf5[0].p)[0] = 0; + ((int *)buf5[1].p)[0] = 0; + ((int *)buf5[1].p)[1] = 0; } /* $h5diff file7.h5 file6.h5 g1 g1 -v @@ -5441,12 +5428,12 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make [ 1 ] 3 0 3 */ - sid = H5Screate_simple(1, dims, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf5); assert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5); + status = H5Treclaim(tid, sid, H5P_DEFAULT, buf5); assert(status >= 0); status = H5Aclose(aid); status = H5Tclose(tid); @@ -5545,13 +5532,13 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make for (j = 0; j < 2; j++) buf12a[i][j] = buf12[i][j]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 2, dims2, "string2D", tid, buf12a); status = H5Tclose(tid); - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 2, dims2, "VLstring2D", tid, buf12); status = H5Tclose(tid); @@ -5598,7 +5585,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make [ 2 0 ] 5 0 5 [ 2 1 ] 6 0 6 */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 2, dims2, "opaque2D", tid, buf22); status = H5Tclose(tid); @@ -5638,8 +5625,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make if (dset_name) { for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) - status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, - (hid_t) -1); + status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 2, dims2, "reference2D", H5T_STD_REF_OBJ, buf42); } @@ -5681,13 +5667,13 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make n = 0; for (i = 0; i < 3; i++) { for (j = 0; j < 2; j++) { - buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) if (make_diffs) - ((int *) buf52[i][j].p)[l] = 0; + ((int *)buf52[i][j].p)[l] = 0; else - ((int *) buf52[i][j].p)[l] = n++; + ((int *)buf52[i][j].p)[l] = n++; } } @@ -5707,12 +5693,12 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make [ 2 1 ] 11 0 11 */ - sid = H5Screate_simple(2, dims2, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(2, dims2, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf52); assert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52); + status = H5Treclaim(tid, sid, H5P_DEFAULT, buf52); assert(status >= 0); status = H5Aclose(aid); status = H5Tclose(tid); @@ -5868,13 +5854,13 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make for (k = 0; k < 2; k++) buf13a[i][j][k] = buf13[i][j][k]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 3, dims3, "string3D", tid, buf13a); status = H5Tclose(tid); - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 3, dims3, "VLstring3D", tid, buf13); status = H5Tclose(tid); @@ -5890,7 +5876,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make if (make_diffs) buf23[i][j][k] = 0; else - buf23[i][j][k] = (char) n++; + buf23[i][j][k] = (char)n++; /* position bitfield3D of </g1> bitfield3D of </g1> difference @@ -5929,7 +5915,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make * H5T_OPAQUE *------------------------------------------------------------------------- */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 3, dims3, "opaque3D", tid, buf23); status = H5Tclose(tid); @@ -5945,9 +5931,10 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make for (k = 0; k < 2; k++) if (make_diffs) { buf33[i][j][k].a = 0; - buf33[i][j][k].b = 0.0F; - } else { - buf33[i][j][k].a = (char) n++; + buf33[i][j][k].b = 0.0; + } + else { + buf33[i][j][k].a = (char)n++; buf33[i][j][k].b = n++; } /*position compound3D of </g1> compound3D of </g1> difference @@ -6017,8 +6004,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) - status = H5Rcreate(&buf43[i][j][k], fid, dset_name, - H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 3, dims3, "reference3D", H5T_STD_REF_OBJ, buf43); } @@ -6080,13 +6066,13 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) { - buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) if (make_diffs) - ((int *) buf53[i][j][k].p)[l] = 0; + ((int *)buf53[i][j][k].p)[l] = 0; else - ((int *) buf53[i][j][k].p)[l] = n++; + ((int *)buf53[i][j][k].p)[l] = n++; } /* position vlen3D of </g1> vlen3D of </g1> difference @@ -6103,12 +6089,12 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make [ 1 1 0 ] 10 0 10 etc */ - sid = H5Screate_simple(3, dims3, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(3, dims3, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf53); assert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53); + status = H5Treclaim(tid, sid, H5P_DEFAULT, buf53); assert(status >= 0); status = H5Aclose(aid); status = H5Tclose(tid); @@ -6120,7 +6106,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make */ n = 1; for (i = 0; i < 24; i++) { - for (j = 0; j < (int) dimarray[0]; j++) { + for (j = 0; j < (int)dimarray[0]; j++) { if (make_diffs) buf63[i][j] = 0; else @@ -6155,7 +6141,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make for (k = 0; k < 2; k++) { if (make_diffs) { buf73[i][j][k] = 0; - buf83[i][j][k] = 0.0F; + buf83[i][j][k] = 0.0; } else { buf73[i][j][k] = n++; @@ -6189,78 +6175,77 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make * *------------------------------------------------------------------------- */ -static -void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs /* flag to modify data buffers */) +static void +write_attr_in(hid_t loc_id, const char *dset_name, hid_t fid, + int make_diffs /* flag to modify data buffers */) { /* Compound datatype */ typedef struct s_t { - char a; + char a; double b; } s_t; - typedef enum { - RED, GREEN - } e_t; + typedef enum { RED, GREEN } e_t; - hid_t aid = -1; - hid_t sid = -1; - hid_t tid = -1; - herr_t status; - int val, i, j, k, l, n; - float f; + hid_t aid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + herr_t H5_ATTR_NDEBUG_UNUSED status; + int val, i, j, k, l, n; + float f; /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1] = { 2 }; - char buf1[2][STR_SIZE] = { "ab", "de" }; /* string */ - char *buf1a[2]; /* VL string */ - char buf2[2] = { 1, 2 }; /* bitfield, opaque */ - s_t buf3[2] = { { 1, 2.0F }, { 3, 4.0F } }; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - e_t buf45[2] = { RED, RED }; /* enum */ - hvl_t buf5[2]; /* vlen */ - hsize_t dimarray[1] = { 3 }; /* array dimension */ - int buf6[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } }; /* array */ - int buf7[2] = { 1, 2 }; /* integer */ - float buf8[2] = { 1.0F, 2.0F }; /* float */ + hsize_t dims[1] = {2}; + char buf1[2][STR_SIZE] = {"ab", "de"}; /* string */ + char * buf1a[2]; /* VL string */ + char buf2[2] = {1, 2}; /* bitfield, opaque */ + s_t buf3[2] = {{1, 2.0}, {3, 4.0}}; /* 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.0, 2.0}; /* float */ /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2] = { 3, 2 }; - char buf12[3][2][STR_SIZE] = { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }; /* string */ - char *buf12a[3][2]; /* VL string */ - char buf22[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* bitfield, opaque */ - s_t buf32[6] = { { 1, 2.0F }, { 3, 4.0F }, { 5, 6.0F }, { 7, 8.0F }, { 9, 10.0F }, { 11, 12.0F } }; /* compound */ - hobj_ref_t buf42[3][2]; /* reference */ - e_t buf452[3][2]; /* enum */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 }, { 13, 14, 15 }, { 16, 17, 18 } }; /* array */ - int buf72[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* integer */ - float buf82[3][2] = { { 1.0F, 2.0F }, { 3.0F, 4.0F }, { 5.0F, 6.0F } }; /* float */ + hsize_t dims2[2] = {3, 2}; + char buf12[3][2][STR_SIZE] = {{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}; /* string */ + char * buf12a[3][2]; /* VL string */ + char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */ + s_t buf32[6] = {{1, 2.0}, {3, 4.0}, {5, 6.0}, {7, 8.0}, {9, 10.0}, {11, 12.0}}; /* 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.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}}; /* float */ /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3] = { 4, 3, 2 }; - char buf13[4][3][2][STR_SIZE] = { { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }, - { { "mn", "pq" }, { "rs", "tu" }, { "vw", "xz" } }, - { { "AB", "CD" }, { "EF", "GH" }, { "IJ", "KL" } }, - { { "MN", "PQ" }, { "RS", "TU" }, { "VW", "XZ" } } }; /* string */ - char *buf13a[4][3][2]; /* VL string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[4][3][2]; /* reference */ - e_t buf453[4][3][2]; /* enum */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ - - /*------------------------------------------------------------------------- - * 1D attributes - *------------------------------------------------------------------------- - */ + hsize_t dims3[3] = {4, 3, 2}; + char buf13[4][3][2][STR_SIZE] = {{{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}, + {{"mn", "pq"}, {"rs", "tu"}, {"vw", "xz"}}, + {{"AB", "CD"}, {"EF", "GH"}, {"IJ", "KL"}}, + {{"MN", "PQ"}, {"RS", "TU"}, {"VW", "XZ"}}}; /* string */ + char * buf13a[4][3][2]; /* VL string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[4][3][2]; /* reference */ + e_t buf453[4][3][2]; /* enum */ + hvl_t buf53[4][3][2]; /* vlen */ + int buf63[24][3]; /* array */ + int buf73[4][3][2]; /* integer */ + float buf83[4][3][2]; /* float */ + + /*------------------------------------------------------------------------- + * 1D attributes + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -6278,22 +6263,22 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 1 ] d z [ 1 ] e z */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 1, dims, "string", tid, buf1); status = H5Tclose(tid); for (i = 0; i < 2; i++) buf1a[i] = buf1[i]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 1, dims, "VLstring", tid, buf1a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -6315,9 +6300,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ /* buf2[2]= {1,2}; @@ -6331,15 +6316,15 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 1 ] 2 0 2 */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 1, dims, "opaque", tid, buf2); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) { @@ -6366,20 +6351,20 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { - status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t) -1); - status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 1, dims, "reference", H5T_STD_REF_OBJ, buf4); } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) buf45[i] = GREEN; @@ -6400,24 +6385,24 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ - buf5[0].len = 1; - buf5[0].p = HDmalloc(1 * sizeof(int)); - ((int *) buf5[0].p)[0] = 1; - buf5[1].len = 2; - buf5[1].p = HDmalloc(2 * sizeof(int)); - ((int *) buf5[1].p)[0] = 2; - ((int *) buf5[1].p)[1] = 3; + buf5[0].len = 1; + buf5[0].p = HDmalloc(1 * sizeof(int)); + ((int *)buf5[0].p)[0] = 1; + buf5[1].len = 2; + buf5[1].p = HDmalloc(2 * sizeof(int)); + ((int *)buf5[1].p)[0] = 2; + ((int *)buf5[1].p)[1] = 3; if (make_diffs) { - ((int *) buf5[0].p)[0] = 0; - ((int *) buf5[1].p)[0] = 0; - ((int *) buf5[1].p)[1] = 0; + ((int *)buf5[0].p)[0] = 0; + ((int *)buf5[1].p)[0] = 0; + ((int *)buf5[1].p)[1] = 0; } /* $h5diff file7.h5 file6.h5 g1 g1 -v @@ -6429,21 +6414,21 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 1 ] 3 0 3 */ - sid = H5Screate_simple(1, dims, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf5); assert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5); + status = H5Treclaim(tid, sid, H5P_DEFAULT, buf5); assert(status >= 0); status = H5Aclose(aid); status = H5Tclose(tid); status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 2; i++) @@ -6469,9 +6454,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 2; i++) { @@ -6497,14 +6482,14 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff write_attr(loc_id, 1, dims, "float", H5T_NATIVE_FLOAT, buf8); /*------------------------------------------------------------------------- - * 2D attributes - *------------------------------------------------------------------------- - */ + * 2D attributes + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) @@ -6532,8 +6517,8 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 2 1 ] l z */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 2, dims2, "string2D", tid, buf12); status = H5Tclose(tid); @@ -6541,15 +6526,15 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff for (j = 0; j < 2; j++) buf12a[i][j] = buf12[i][j]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 2, dims2, "VLstring2D", tid, buf12a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf22, 0, sizeof buf22); @@ -6572,9 +6557,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ /* buf22[3][2]= {{1,2},{3,4},{5,6}}; @@ -6589,15 +6574,15 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 2 0 ] 5 0 5 [ 2 1 ] 6 0 6 */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 2, dims2, "opaque2D", tid, buf22); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf32, 0, sizeof buf32); /* @@ -6621,21 +6606,21 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) - status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 2, dims2, "reference2D", H5T_STD_REF_OBJ, buf42); } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) { if (make_diffs) @@ -6663,21 +6648,21 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ n = 0; for (i = 0; i < 3; i++) { for (j = 0; j < 2; j++) { - buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) if (make_diffs) - ((int *) buf52[i][j].p)[l] = 0; + ((int *)buf52[i][j].p)[l] = 0; else - ((int *) buf52[i][j].p)[l] = n++; + ((int *)buf52[i][j].p)[l] = n++; } } @@ -6697,21 +6682,21 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 2 1 ] 11 0 11 */ - sid = H5Screate_simple(2, dims2, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(2, dims2, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf52); assert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52); + status = H5Treclaim(tid, sid, H5P_DEFAULT, buf52); assert(status >= 0); status = H5Aclose(aid); status = H5Tclose(tid); status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf62, 0, sizeof buf62); @@ -6746,9 +6731,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ if (make_diffs) { memset(buf72, 0, sizeof buf72); @@ -6780,14 +6765,14 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff write_attr(loc_id, 2, dims2, "float2D", H5T_NATIVE_FLOAT, buf82); /*------------------------------------------------------------------------- - * 3D attributes - *------------------------------------------------------------------------- - */ + * 3D attributes + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 4; i++) @@ -6854,8 +6839,8 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 3 2 1 ] Z z */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 3, dims3, "string3D", tid, buf13); status = H5Tclose(tid); @@ -6863,15 +6848,15 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) buf13a[i][j][k] = buf13[i][j][k]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 3, dims3, "VLstring3D", tid, buf13a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 4; i++) @@ -6880,7 +6865,7 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff if (make_diffs) buf23[i][j][k] = 0; else - buf23[i][j][k] = (char) n++; + buf23[i][j][k] = (char)n++; } /* position bitfield3D of </g1> bitfield3D of </g1> difference @@ -6916,18 +6901,18 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 3, dims3, "opaque3D", tid, buf23); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 4; i++) @@ -6935,10 +6920,10 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff for (k = 0; k < 2; k++) { if (make_diffs) { buf33[i][j][k].a = 0; - buf33[i][j][k].b = 0.0F; + buf33[i][j][k].b = 0.0; } else { - buf33[i][j][k].a = (char) n++; + buf33[i][j][k].a = (char)n++; buf33[i][j][k].b = n++; } } @@ -7001,23 +6986,22 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) - status = H5Rcreate(&buf43[i][j][k], fid, dset_name, - H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 3, dims3, "reference3D", H5T_STD_REF_OBJ, buf43); } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) @@ -7063,22 +7047,22 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ n = 0; for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) { - buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) if (make_diffs) - ((int *) buf53[i][j][k].p)[l] = 0; + ((int *)buf53[i][j][k].p)[l] = 0; else - ((int *) buf53[i][j][k].p)[l] = n++; + ((int *)buf53[i][j][k].p)[l] = n++; } /* position vlen3D of </g1> vlen3D of </g1> difference @@ -7095,24 +7079,24 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 1 1 0 ] 10 0 10 etc */ - sid = H5Screate_simple(3, dims3, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(3, dims3, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf53); assert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53); + status = H5Treclaim(tid, sid, H5P_DEFAULT, buf53); assert(status >= 0); status = H5Aclose(aid); status = H5Tclose(tid); status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 24; i++) - for (j = 0; j < (int) dimarray[0]; j++) { + for (j = 0; j < (int)dimarray[0]; j++) { if (make_diffs) buf63[i][j] = 0; else @@ -7136,9 +7120,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ n = 1; f = 1; for (i = 0; i < 4; i++) @@ -7146,7 +7130,7 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff for (k = 0; k < 2; k++) { if (make_diffs) { buf73[i][j][k] = 0; - buf83[i][j][k] = 0.0F; + buf83[i][j][k] = 0.0; } else { buf73[i][j][k] = n++; @@ -7180,77 +7164,76 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff * *------------------------------------------------------------------------- */ -static -void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs /* flag to modify data buffers */) +static void +write_dset_in(hid_t loc_id, const char *dset_name, hid_t fid, + int make_diffs /* flag to modify data buffers */) { /* Compound datatype */ typedef struct s_t { - char a; + char a; double b; } s_t; - typedef enum { - RED, GREEN - } e_t; + typedef enum { RED, GREEN } e_t; - hid_t did = -1; - hid_t sid = -1; - hid_t tid = -1; - hid_t dcpl = -1; - herr_t status; - int val, i, j, k, l, n; - float f; - int fillvalue = 2; - int scalar_data = 2; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; + herr_t H5_ATTR_NDEBUG_UNUSED status; + int val, i, j, k, l, n; + float f; + int fillvalue = 2; + int scalar_data = 2; /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1] = { 2 }; - char buf1[2][STR_SIZE] = { "ab", "de" }; /* string */ - char *buf1a[2]; /* VL string */ - char buf2[2] = { 1, 2 }; /* bitfield, opaque */ - s_t buf3[2] = { { 1, 2.0F }, { 3, 4.0F } }; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - e_t buf45[2] = { RED, GREEN }; /* enum */ - hvl_t buf5[2]; /* vlen */ - hsize_t dimarray[1] = { 3 }; /* array dimension */ - int buf6[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } }; /* array */ - int buf7[2] = { 1, 2 }; /* integer */ - float buf8[2] = { 1.0F, 2.0F }; /* float */ + hsize_t dims[1] = {2}; + char buf1[2][STR_SIZE] = {"ab", "de"}; /* string */ + char * buf1a[2]; /* VL string */ + char buf2[2] = {1, 2}; /* bitfield, opaque */ + s_t buf3[2] = {{1, 2.0}, {3, 4.0}}; /* 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.0, 2.0}; /* float */ /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2] = { 3, 2 }; - char buf12[3][2][STR_SIZE] = { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }; /* string */ - char *buf12a[3][2]; /* VL string */ - char buf22[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* bitfield, opaque */ - s_t buf32[6] = { { 1, 2.0F }, { 3, 4.0F }, { 5, 6.0F }, { 7, 8.0F }, { 9, 10.0F }, { 11, 12.0F } }; /* compound */ - hobj_ref_t buf42[3][2]; /* reference */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 }, { 13, 14, 15 }, { 16, 17, 18 } }; /* array */ - int buf72[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* integer */ - float buf82[3][2] = { { 1.0F, 2.0F }, { 3.0F, 4.0F }, { 5.0F, 6.0F } }; /* float */ + hsize_t dims2[2] = {3, 2}; + char buf12[3][2][STR_SIZE] = {{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}; /* string */ + char * buf12a[3][2]; /* VL string */ + char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */ + s_t buf32[6] = {{1, 2.0}, {3, 4.0}, {5, 6.0}, {7, 8.0}, {9, 10.0}, {11, 12.0}}; /* compound */ + hobj_ref_t buf42[3][2]; /* reference */ + hvl_t buf52[3][2]; /* vlen */ + int buf62[6][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}, {16, 17, 18}}; /* array */ + int buf72[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* integer */ + float buf82[3][2] = {{1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}}; /* float */ /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3] = { 4, 3, 2 }; - char buf13[4][3][2][STR_SIZE] = { { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }, - { { "mn", "pq" }, { "rs", "tu" }, { "vw", "xz" } }, - { { "AB", "CD" }, { "EF", "GH" }, { "IJ", "KL" } }, - { { "MN", "PQ" }, { "RS", "TU" }, { "VW", "XZ" } } }; /* string */ - char *buf13a[4][3][2]; /* VL string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[4][3][2]; /* reference */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ + hsize_t dims3[3] = {4, 3, 2}; + char buf13[4][3][2][STR_SIZE] = {{{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}, + {{"mn", "pq"}, {"rs", "tu"}, {"vw", "xz"}}, + {{"AB", "CD"}, {"EF", "GH"}, {"IJ", "KL"}}, + {{"MN", "PQ"}, {"RS", "TU"}, {"VW", "XZ"}}}; /* string */ + char * buf13a[4][3][2]; /* VL string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[4][3][2]; /* reference */ + hvl_t buf53[4][3][2]; /* vlen */ + int buf63[24][3]; /* array */ + int buf73[4][3][2]; /* integer */ + float buf83[4][3][2]; /* float */ if (make_diffs == 2) dimarray[0] = 4; /*------------------------------------------------------------------------- - * H5S_SCALAR - *------------------------------------------------------------------------- - */ + * H5S_SCALAR + *------------------------------------------------------------------------- + */ if (make_diffs) scalar_data = 1; @@ -7269,37 +7252,37 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff H5Sclose(sid); /*------------------------------------------------------------------------- - * 1D - *------------------------------------------------------------------------- - */ + * 1D + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) buf1[i][j] = 'z'; - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_dset(loc_id, 1, dims, "string", tid, buf1); status = H5Tclose(tid); for (i = 0; i < 2; i++) buf1a[i] = buf1[i]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_dset(loc_id, 1, dims, "VLstring", tid, buf1a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -7310,9 +7293,9 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) { @@ -7320,15 +7303,15 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff buf3[i].b = 0; } - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_dset(loc_id, 1, dims, "opaque", tid, buf2); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -7341,27 +7324,27 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { - status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t) -1); - status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_dset(loc_id, 1, dims, "reference", H5T_STD_REF_OBJ, buf4); } /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_DATASET_REGION dataset region reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_DATASET_REGION dataset region reference) + *------------------------------------------------------------------------- + */ gen_datareg(fid, make_diffs); /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); @@ -7369,42 +7352,41 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ - buf5[0].len = 1; - buf5[0].p = HDmalloc(1 * sizeof(int)); - ((int *) buf5[0].p)[0] = 1; - buf5[1].len = 2; - buf5[1].p = HDmalloc(2 * sizeof(int)); - ((int *) buf5[1].p)[0] = 2; - ((int *) buf5[1].p)[1] = 3; + buf5[0].len = 1; + buf5[0].p = HDmalloc(1 * sizeof(int)); + ((int *)buf5[0].p)[0] = 1; + buf5[1].len = 2; + buf5[1].p = HDmalloc(2 * sizeof(int)); + ((int *)buf5[1].p)[0] = 2; + ((int *)buf5[1].p)[1] = 3; if (make_diffs) { - ((int *) buf5[0].p)[0] = 0; - ((int *) buf5[1].p)[0] = 0; - ((int *) buf5[1].p)[1] = 0; + ((int *)buf5[0].p)[0] = 0; + ((int *)buf5[1].p)[0] = 0; + ((int *)buf5[1].p)[1] = 0; } - sid = H5Screate_simple(1, dims, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + did = H5Dcreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); HDassert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5); + status = H5Treclaim(tid, sid, H5P_DEFAULT, buf5); HDassert(status >= 0); status = H5Dclose(did); status = H5Tclose(tid); status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -7416,21 +7398,21 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); { - double *dbuf; /* information to write */ - hid_t ldid = -1; /* dataset ID */ - hid_t lsid = -1; /* dataspace ID */ - hid_t ltid = -1; /* datatype ID */ - size_t size; - hsize_t sdims[] = { 1 }; - hsize_t tdims[] = { H5TOOLS_MALLOCSIZE / sizeof(double) + 1 }; - size_t jj; + double *dbuf; /* information to write */ + hid_t ldid = H5I_INVALID_HID; /* dataset ID */ + hid_t lsid = H5I_INVALID_HID; /* dataspace ID */ + hid_t ltid = H5I_INVALID_HID; /* datatype ID */ + size_t size; + hsize_t sdims[] = {1}; + hsize_t tdims[] = {H5TOOLS_MALLOCSIZE / sizeof(double) + 1}; + size_t jj; /* allocate and initialize array data to write */ size = (H5TOOLS_MALLOCSIZE / sizeof(double) + 1) * sizeof(double); - dbuf = (double *) HDmalloc(size); + dbuf = (double *)HDmalloc(size); for (jj = 0; jj < (H5TOOLS_MALLOCSIZE / sizeof(double) + 1); jj++) - dbuf[jj] = (double) jj; + dbuf[jj] = (double)jj; if (make_diffs) { dbuf[5] = 0; @@ -7454,9 +7436,9 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff } /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) { @@ -7468,14 +7450,14 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff write_dset(loc_id, 1, dims, "float", H5T_NATIVE_FLOAT, buf8); /*------------------------------------------------------------------------- - * 2D - *------------------------------------------------------------------------- - */ + * 2D + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 3; i++) @@ -7484,8 +7466,8 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff buf12[i][j][k] = 'z'; } - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_dset(loc_id, 2, dims2, "string2D", tid, buf12); status = H5Tclose(tid); @@ -7493,15 +7475,15 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff for (j = 0; j < 2; j++) buf12a[i][j] = buf12[i][j]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_dset(loc_id, 2, dims2, "VLstring2D", tid, buf12a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf22, 0, sizeof buf22); @@ -7511,18 +7493,18 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_dset(loc_id, 2, dims2, "opaque2D", tid, buf22); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf32, 0, sizeof buf32); @@ -7534,21 +7516,21 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) - status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_dset(loc_id, 2, dims2, "reference2D", H5T_STD_REF_OBJ, buf42); } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); H5Tenum_insert(tid, "RED", (val = 0, &val)); @@ -7557,39 +7539,39 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ n = 0; for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) { - buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) { if (make_diffs) - ((int *) buf52[i][j].p)[l] = 0; + ((int *)buf52[i][j].p)[l] = 0; else - ((int *) buf52[i][j].p)[l] = n++; + ((int *)buf52[i][j].p)[l] = n++; } } - sid = H5Screate_simple(2, dims2, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(2, dims2, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + did = H5Dcreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf52); assert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52); + status = H5Treclaim(tid, sid, H5P_DEFAULT, buf52); assert(status >= 0); status = H5Dclose(did); status = H5Tclose(tid); status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf62, 0, sizeof buf62); @@ -7599,40 +7581,40 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_INTEGER, write a fill value - *------------------------------------------------------------------------- - */ + * H5T_INTEGER, write a fill value + *------------------------------------------------------------------------- + */ if (make_diffs) { memset(buf72, 0, sizeof buf72); memset(buf82, 0, sizeof buf82); } - dcpl = H5Pcreate(H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); status = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue); - sid = H5Screate_simple(2, dims2, NULL); - did = H5Dcreate2(loc_id, "integer2D", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + sid = H5Screate_simple(2, dims2, NULL); + did = H5Dcreate2(loc_id, "integer2D", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf72); status = H5Pclose(dcpl); status = H5Dclose(did); status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_FLOAT + *------------------------------------------------------------------------- + */ write_dset(loc_id, 2, dims2, "float2D", H5T_NATIVE_FLOAT, buf82); /*------------------------------------------------------------------------- - * 3D - *------------------------------------------------------------------------- - */ + * 3D + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 4; i++) @@ -7642,8 +7624,8 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff buf13[i][j][k][l] = 'z'; } - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_dset(loc_id, 3, dims3, "string3D", tid, buf13); status = H5Tclose(tid); @@ -7652,15 +7634,15 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff for (k = 0; k < 2; k++) buf13a[i][j][k] = buf13[i][j][k]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_dset(loc_id, 3, dims3, "VLstring3D", tid, buf13a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 4; i++) @@ -7669,7 +7651,7 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff if (make_diffs) buf23[i][j][k] = 0; else - buf23[i][j][k] = (char) n++; + buf23[i][j][k] = (char)n++; } tid = H5Tcopy(H5T_STD_B8LE); @@ -7677,18 +7659,18 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_dset(loc_id, 3, dims3, "opaque3D", tid, buf23); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 4; i++) @@ -7696,10 +7678,10 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff for (k = 0; k < 2; k++) { if (make_diffs) { buf33[i][j][k].a = 0; - buf33[i][j][k].b = 0.0F; + buf33[i][j][k].b = 0.0; } else { - buf33[i][j][k].a = (char) n++; + buf33[i][j][k].a = (char)n++; buf33[i][j][k].b = n++; } } @@ -7711,22 +7693,22 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) - status = H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_dset(loc_id, 3, dims3, "reference3D", H5T_STD_REF_OBJ, buf43); } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); H5Tenum_insert(tid, "RED", (val = 0, &val)); @@ -7735,40 +7717,40 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ n = 0; for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) { - buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) { if (make_diffs) - ((int *) buf53[i][j][k].p)[l] = 0; + ((int *)buf53[i][j][k].p)[l] = 0; else - ((int *) buf53[i][j][k].p)[l] = n++; + ((int *)buf53[i][j][k].p)[l] = n++; } } - sid = H5Screate_simple(3, dims3, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(3, dims3, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + did = H5Dcreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf53); assert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53); + status = H5Treclaim(tid, sid, H5P_DEFAULT, buf53); assert(status >= 0); status = H5Dclose(did); status = H5Tclose(tid); status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 24; i++) @@ -7784,9 +7766,9 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ n = 1; f = 1; for (i = 0; i < 4; i++) @@ -7794,7 +7776,7 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff for (k = 0; k < 2; k++) { if (make_diffs) { buf73[i][j][k] = 0; - buf83[i][j][k] = 0.0F; + buf83[i][j][k] = 0.0; } else { buf73[i][j][k] = n++; @@ -7816,44 +7798,43 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff *------------------------------------------------------------------------- */ -static -void gen_datareg(hid_t fid, int make_diffs /* flag to modify data buffers */) +static void +gen_datareg(hid_t fid, int make_diffs /* flag to modify data buffers */) { /* data dataset */ - hid_t did1 = -1; /* dataset ID */ - hid_t sid1 = -1; /* dataspace ID */ - hsize_t dims1[2] = { 10, 10 };/* dimensions */ - int *buf; /* dataset buffer */ + hid_t did1 = H5I_INVALID_HID; /* dataset ID */ + hid_t sid1 = H5I_INVALID_HID; /* dataspace ID */ + hsize_t dims1[2] = {10, 10}; /* dimensions */ + int * buf; /* dataset buffer */ /* reference dataset */ - hid_t did2 = -1; /* dataset ID */ - hid_t sid2 = -1; /* dataspace ID */ - hsize_t dims2[] = { 2 }; /* 2 references */ - hdset_reg_ref_t *rbuf; /* buffer for write the references */ - hsize_t start[10]; /* starting location of hyperslab */ - hsize_t count[10]; /* element count of hyperslab */ - hsize_t coord[5][2]; /* coordinates for point selection */ - herr_t status; - int i; + hid_t did2 = H5I_INVALID_HID; /* dataset ID */ + hid_t sid2 = H5I_INVALID_HID; /* dataspace ID */ + hsize_t dims2[] = {2}; /* 2 references */ + hdset_reg_ref_t * rbuf; /* buffer for write the references */ + hsize_t start[10]; /* starting location of hyperslab */ + hsize_t count[10]; /* element count of hyperslab */ + hsize_t coord[5][2]; /* coordinates for point selection */ + herr_t H5_ATTR_NDEBUG_UNUSED status; + int i; /* allocate the buffer for write the references */ - rbuf = (hdset_reg_ref_t *) HDcalloc((size_t )2, sizeof(hdset_reg_ref_t)); + rbuf = (hdset_reg_ref_t *)HDcalloc((size_t)2, sizeof(hdset_reg_ref_t)); /* allocate the buffer for write the data dataset */ - buf = (int *) HDmalloc(10 * 10 * sizeof(int)); + buf = (int *)HDmalloc(10 * 10 * sizeof(int)); for (i = 0; i < 10 * 10; i++) buf[i] = i; /* create the data dataset */ - sid1 = H5Screate_simple(2, dims1, NULL); - did1 = H5Dcreate2(fid, "dsetref", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid1 = H5Screate_simple(2, dims1, NULL); + did1 = H5Dcreate2(fid, "dsetref", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); HDassert(status >= 0); /* create the reference dataset */ sid2 = H5Screate_simple(1, dims2, NULL); - did2 = H5Dcreate2(fid, "refreg", H5T_STD_REF_DSETREG, sid2, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + did2 = H5Dcreate2(fid, "refreg", H5T_STD_REF_DSETREG, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* create the references */ /* select hyperslab for first reference */ @@ -7896,7 +7877,7 @@ void gen_datareg(hid_t fid, int make_diffs /* flag to modify data buffers */) coord[4][0] = 1; coord[4][1] = 7; } - H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t) 5, (const hsize_t *) coord); + H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)5, (const hsize_t *)coord); H5Sget_select_npoints(sid1); /* store second dataset region */ @@ -7924,29 +7905,29 @@ void gen_datareg(hid_t fid, int make_diffs /* flag to modify data buffers */) * Function: test_hyperslab * * Purpose: test diff by hyperslabs. create a dataset with 1GB dimensions - * by iterating trough 1KB hyperslabs + * by iterating through 1KB hyperslabs * *------------------------------------------------------------------------- */ -static -int test_hyperslab(const char *fname, int make_diffs /* flag to modify data buffers */) +static int +test_hyperslab(const char *fname, int make_diffs /* flag to modify data buffers */) { - hid_t did = -1; - hid_t fid = -1; - hid_t f_sid = -1; - hid_t m_sid = -1; - hid_t tid = -1; - hid_t dcpl = -1; - hsize_t dims[1] = { GBLL }; /* dataset dimensions */ - hsize_t hs_size[1] = { GBLL / (1024 * 1024) }; /* hyperslab dimensions */ - hsize_t chunk_dims[1] = { GBLL / 1024 }; /* chunk dimensions */ + hid_t did = H5I_INVALID_HID; + hid_t fid = H5I_INVALID_HID; + hid_t f_sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; + hsize_t dims[1] = {GBLL}; /* dataset dimensions */ + hsize_t hs_size[1] = {GBLL / (1024 * 1024)}; /* hyperslab dimensions */ + hsize_t chunk_dims[1] = {GBLL / 1024}; /* chunk dimensions */ hsize_t hs_start[1]; - size_t size; - size_t nelmts = (size_t)GBLL / (1024 * 1024); /* elements in each hyperslab */ - char fillvalue = -1; - char *buf = NULL; - int i, j, s; - char c; + size_t size; + size_t nelmts = (size_t)GBLL / (1024 * 1024); /* elements in each hyperslab */ + char fillvalue = -1; + char * buf = NULL; + int i, j, s; + char c; /* create */ fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -7968,8 +7949,8 @@ int test_hyperslab(const char *fname, int make_diffs /* flag to modify data buff goto out; /* create a evenly divided buffer from 0 to 127 */ - buf = (char *) HDmalloc((size_t)(nelmts * size)); - s = 1024 * 1024 / 127; + buf = (char *)HDmalloc((size_t)(nelmts * size)); + s = 1024 * 1024 / 127; for (i = 0, j = 0, c = 0; i < 1024 * 1024; j++, i++) { if (j == s) { c++; @@ -7983,7 +7964,7 @@ int test_hyperslab(const char *fname, int make_diffs /* flag to modify data buff if (make_diffs && i == 512 * 512) HDmemset(buf, 0, nelmts); - hs_start[0] = (unsigned long long) i * GBLL / (1024 * 1024); + hs_start[0] = (unsigned long long)i * GBLL / (1024 * 1024); if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, hs_start, NULL, hs_size, NULL) < 0) goto out; @@ -8010,16 +7991,71 @@ int test_hyperslab(const char *fname, int make_diffs /* flag to modify data buff return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(f_sid); H5Sclose(m_sid); H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } +/* + * Function: test_double_epsilion + * + * Purpose: Create test files to compare data with epsilion + */ +static void +test_double_epsilon(const char *fname1, const char *fname2) +{ + hid_t fid1 = H5I_INVALID_HID, fid2 = H5I_INVALID_HID; + hsize_t dims1[2] = {4, 7}; + double wdata[4][7]; + int i, j; + + /*------------------------------------------------------------------------- + * create two files + *------------------------------------------------------------------------- + */ + if ((fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + PROGRAM_ERROR; + if ((fid2 = H5Fcreate(fname2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + PROGRAM_ERROR; + + /* + * Initialize data. + */ + for (i = 0; i < 4; i++) + for (j = 0; j < 7; j++) + wdata[i][j] = 0.0; + + /* dataset */ + if (write_dset(fid1, 2, dims1, "dataset", H5T_IEEE_F64LE, wdata) < 0) + PROGRAM_ERROR; + + /* + * Initialize data. + */ + for (i = 0; i < 4; i++) + for (j = 0; j < 7; j++) + wdata[i][j] = (double)1.e-19; + + /* dataset */ + if (write_dset(fid2, 2, dims1, "dataset", H5T_IEEE_F64LE, wdata) < 0) + PROGRAM_ERROR; + +error: + H5E_BEGIN_TRY + { + H5Fclose(fid1); + H5Fclose(fid2); + } + H5E_END_TRY; +} + /*------------------------------------------------------------------------- * Function: write_attr * @@ -8027,11 +8063,11 @@ out: * *------------------------------------------------------------------------- */ -static -int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf) +static int +write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf) { - hid_t aid = -1; - hid_t sid = -1; + hid_t aid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; /* create a space */ if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) @@ -8070,37 +8106,38 @@ out: static herr_t write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf) { - hid_t did = -1; - hid_t sid = -1; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; /* create a space */ - if((sid = H5Screate_simple(rank, dims, NULL)) < 0) - PROGRAM_ERROR + if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) + PROGRAM_ERROR; /* create the dataset */ - if((did = H5Dcreate2(loc_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - PROGRAM_ERROR + if ((did = H5Dcreate2(loc_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + PROGRAM_ERROR; /* write */ - if(buf) - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - PROGRAM_ERROR + if (buf) + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + PROGRAM_ERROR; /* close */ - if(H5Dclose(did) < 0) - PROGRAM_ERROR - if(H5Sclose(sid) < 0) - PROGRAM_ERROR + if (H5Dclose(did) < 0) + PROGRAM_ERROR; + if (H5Sclose(sid) < 0) + PROGRAM_ERROR; return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end write_dset() */ - diff --git a/tools/test/h5diff/testfiles/h5diff_10.txt b/tools/test/h5diff/testfiles/h5diff_10.txt index 11ad800..b1d607e 100644 --- a/tools/test/h5diff/testfiles/h5diff_10.txt +++ b/tools/test/h5diff/testfiles/h5diff_10.txt @@ -4,6 +4,9 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] [obj1] Name of an HDF5 object, in absolute path [obj2] Name of an HDF5 object, in absolute path + ERROR + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. OPTIONS -h, --help Print a usage message and exit. @@ -17,14 +20,35 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. - --enable-error-stack - Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -97,8 +121,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: - Default mode: print the number of differences found and where they occured + Default mode: print the number of differences found and where they occurred -r Report mode: print the above plus the differences -v Verbose mode: print the above plus a list of objects and warnings -q Quiet mode: do not print output @@ -124,6 +156,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] (The option --follow-symlinks overrides the default behavior when symbolic links are compared.). + Subsetting options: + Subsetting is available by using the fcompact form of subsetting, as follows: + obj1 /foo/mydataset[START;STRIDE;COUNT;BLOCK] + It is not required to use all parameters, but until the last parameter value used, + all of the semicolons (;) are required, even when a parameter value is not specified. Example: + obj1 /foo/mydataset[START;;COUNT;BLOCK] + obj1 /foo/mydataset[START] + The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in + each dimension. START is optional and will default to 0 in each dimension. + Each of START, STRIDE, COUNT, and BLOCK must be a comma-separated list of integers with + one integer for each dimension of the dataset. + Exit code: 0 if no differences, 1 if differences found, 2 if error diff --git a/tools/test/h5diff/testfiles/h5diff_58.txt b/tools/test/h5diff/testfiles/h5diff_58.txt index d27a0c9..da147bc 100644 --- a/tools/test/h5diff/testfiles/h5diff_58.txt +++ b/tools/test/h5diff/testfiles/h5diff_58.txt @@ -1,3 +1,4 @@ + dataset: </refreg> and </refreg> Referenced dataset 10784 10784 ------------------------------------------------------------ @@ -8,4 +9,7 @@ point #1 (2,2) (3,3) point #3 (1,6) (2,5) point #4 (2,8) (1,7) 4 differences found + obj1 obj2 + -------------------------------------- +Attributes status: 0 common, 0 only in obj1, 0 only in obj2 EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_58_ref.txt b/tools/test/h5diff/testfiles/h5diff_58_ref.txt new file mode 100644 index 0000000..48a4b33 --- /dev/null +++ b/tools/test/h5diff/testfiles/h5diff_58_ref.txt @@ -0,0 +1,37 @@ + +dataset: </g1/reference2D> and </g1/reference2D> +size: [2] [2] +position reference2D reference2D difference +------------------------------------------------------------ +[ 0 ] 1 0 1 +[ 1 ] 2 0 2 +size: [2] [2] +position reference2D reference2D difference +------------------------------------------------------------ +[ 0 ] 1 0 1 +[ 1 ] 2 0 2 +size: [2] [2] +position reference2D reference2D difference +------------------------------------------------------------ +[ 0 ] 1 0 1 +[ 1 ] 2 0 2 +size: [2] [2] +position reference2D reference2D difference +------------------------------------------------------------ +[ 0 ] 1 0 1 +[ 1 ] 2 0 2 +size: [2] [2] +position reference2D reference2D difference +------------------------------------------------------------ +[ 0 ] 1 0 1 +[ 1 ] 2 0 2 +size: [2] [2] +position reference2D reference2D difference +------------------------------------------------------------ +[ 0 ] 1 0 1 +[ 1 ] 2 0 2 +12 differences found + obj1 obj2 + -------------------------------------- +Attributes status: 0 common, 0 only in obj1, 0 only in obj2 +EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_600.txt b/tools/test/h5diff/testfiles/h5diff_600.txt index 13d627c..5236964 100644 --- a/tools/test/h5diff/testfiles/h5diff_600.txt +++ b/tools/test/h5diff/testfiles/h5diff_600.txt @@ -4,6 +4,9 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] [obj1] Name of an HDF5 object, in absolute path [obj2] Name of an HDF5 object, in absolute path + ERROR + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. OPTIONS -h, --help Print a usage message and exit. @@ -17,14 +20,35 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. - --enable-error-stack - Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -97,8 +121,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: - Default mode: print the number of differences found and where they occured + Default mode: print the number of differences found and where they occurred -r Report mode: print the above plus the differences -v Verbose mode: print the above plus a list of objects and warnings -q Quiet mode: do not print output @@ -124,6 +156,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] (The option --follow-symlinks overrides the default behavior when symbolic links are compared.). + Subsetting options: + Subsetting is available by using the fcompact form of subsetting, as follows: + obj1 /foo/mydataset[START;STRIDE;COUNT;BLOCK] + It is not required to use all parameters, but until the last parameter value used, + all of the semicolons (;) are required, even when a parameter value is not specified. Example: + obj1 /foo/mydataset[START;;COUNT;BLOCK] + obj1 /foo/mydataset[START] + The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in + each dimension. START is optional and will default to 0 in each dimension. + Each of START, STRIDE, COUNT, and BLOCK must be a comma-separated list of integers with + one integer for each dimension of the dataset. + Exit code: 0 if no differences, 1 if differences found, 2 if error diff --git a/tools/test/h5diff/testfiles/h5diff_603.txt b/tools/test/h5diff/testfiles/h5diff_603.txt index 0d6b474..e7bad17 100644 --- a/tools/test/h5diff/testfiles/h5diff_603.txt +++ b/tools/test/h5diff/testfiles/h5diff_603.txt @@ -5,6 +5,9 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] [obj1] Name of an HDF5 object, in absolute path [obj2] Name of an HDF5 object, in absolute path + ERROR + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. OPTIONS -h, --help Print a usage message and exit. @@ -18,14 +21,35 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. - --enable-error-stack - Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -98,8 +122,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: - Default mode: print the number of differences found and where they occured + Default mode: print the number of differences found and where they occurred -r Report mode: print the above plus the differences -v Verbose mode: print the above plus a list of objects and warnings -q Quiet mode: do not print output @@ -125,6 +157,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] (The option --follow-symlinks overrides the default behavior when symbolic links are compared.). + Subsetting options: + Subsetting is available by using the fcompact form of subsetting, as follows: + obj1 /foo/mydataset[START;STRIDE;COUNT;BLOCK] + It is not required to use all parameters, but until the last parameter value used, + all of the semicolons (;) are required, even when a parameter value is not specified. Example: + obj1 /foo/mydataset[START;;COUNT;BLOCK] + obj1 /foo/mydataset[START] + The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in + each dimension. START is optional and will default to 0 in each dimension. + Each of START, STRIDE, COUNT, and BLOCK must be a comma-separated list of integers with + one integer for each dimension of the dataset. + Exit code: 0 if no differences, 1 if differences found, 2 if error diff --git a/tools/test/h5diff/testfiles/h5diff_606.txt b/tools/test/h5diff/testfiles/h5diff_606.txt index 94f44e8..410528d 100644 --- a/tools/test/h5diff/testfiles/h5diff_606.txt +++ b/tools/test/h5diff/testfiles/h5diff_606.txt @@ -5,6 +5,9 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] [obj1] Name of an HDF5 object, in absolute path [obj2] Name of an HDF5 object, in absolute path + ERROR + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. OPTIONS -h, --help Print a usage message and exit. @@ -18,14 +21,35 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. - --enable-error-stack - Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -98,8 +122,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: - Default mode: print the number of differences found and where they occured + Default mode: print the number of differences found and where they occurred -r Report mode: print the above plus the differences -v Verbose mode: print the above plus a list of objects and warnings -q Quiet mode: do not print output @@ -125,6 +157,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] (The option --follow-symlinks overrides the default behavior when symbolic links are compared.). + Subsetting options: + Subsetting is available by using the fcompact form of subsetting, as follows: + obj1 /foo/mydataset[START;STRIDE;COUNT;BLOCK] + It is not required to use all parameters, but until the last parameter value used, + all of the semicolons (;) are required, even when a parameter value is not specified. Example: + obj1 /foo/mydataset[START;;COUNT;BLOCK] + obj1 /foo/mydataset[START] + The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in + each dimension. START is optional and will default to 0 in each dimension. + Each of START, STRIDE, COUNT, and BLOCK must be a comma-separated list of integers with + one integer for each dimension of the dataset. + Exit code: 0 if no differences, 1 if differences found, 2 if error diff --git a/tools/test/h5diff/testfiles/h5diff_612.txt b/tools/test/h5diff/testfiles/h5diff_612.txt index 7f83c64..ffc191e 100644 --- a/tools/test/h5diff/testfiles/h5diff_612.txt +++ b/tools/test/h5diff/testfiles/h5diff_612.txt @@ -5,6 +5,9 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] [obj1] Name of an HDF5 object, in absolute path [obj2] Name of an HDF5 object, in absolute path + ERROR + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. OPTIONS -h, --help Print a usage message and exit. @@ -18,14 +21,35 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. - --enable-error-stack - Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -98,8 +122,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: - Default mode: print the number of differences found and where they occured + Default mode: print the number of differences found and where they occurred -r Report mode: print the above plus the differences -v Verbose mode: print the above plus a list of objects and warnings -q Quiet mode: do not print output @@ -125,6 +157,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] (The option --follow-symlinks overrides the default behavior when symbolic links are compared.). + Subsetting options: + Subsetting is available by using the fcompact form of subsetting, as follows: + obj1 /foo/mydataset[START;STRIDE;COUNT;BLOCK] + It is not required to use all parameters, but until the last parameter value used, + all of the semicolons (;) are required, even when a parameter value is not specified. Example: + obj1 /foo/mydataset[START;;COUNT;BLOCK] + obj1 /foo/mydataset[START] + The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in + each dimension. START is optional and will default to 0 in each dimension. + Each of START, STRIDE, COUNT, and BLOCK must be a comma-separated list of integers with + one integer for each dimension of the dataset. + Exit code: 0 if no differences, 1 if differences found, 2 if error diff --git a/tools/test/h5diff/testfiles/h5diff_615.txt b/tools/test/h5diff/testfiles/h5diff_615.txt index 3cfe6b9..2ff50e9 100644 --- a/tools/test/h5diff/testfiles/h5diff_615.txt +++ b/tools/test/h5diff/testfiles/h5diff_615.txt @@ -5,6 +5,9 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] [obj1] Name of an HDF5 object, in absolute path [obj2] Name of an HDF5 object, in absolute path + ERROR + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. OPTIONS -h, --help Print a usage message and exit. @@ -18,14 +21,35 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. - --enable-error-stack - Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -98,8 +122,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: - Default mode: print the number of differences found and where they occured + Default mode: print the number of differences found and where they occurred -r Report mode: print the above plus the differences -v Verbose mode: print the above plus a list of objects and warnings -q Quiet mode: do not print output @@ -125,6 +157,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] (The option --follow-symlinks overrides the default behavior when symbolic links are compared.). + Subsetting options: + Subsetting is available by using the fcompact form of subsetting, as follows: + obj1 /foo/mydataset[START;STRIDE;COUNT;BLOCK] + It is not required to use all parameters, but until the last parameter value used, + all of the semicolons (;) are required, even when a parameter value is not specified. Example: + obj1 /foo/mydataset[START;;COUNT;BLOCK] + obj1 /foo/mydataset[START] + The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in + each dimension. START is optional and will default to 0 in each dimension. + Each of START, STRIDE, COUNT, and BLOCK must be a comma-separated list of integers with + one integer for each dimension of the dataset. + Exit code: 0 if no differences, 1 if differences found, 2 if error diff --git a/tools/test/h5diff/testfiles/h5diff_621.txt b/tools/test/h5diff/testfiles/h5diff_621.txt index 9c34945..7db4959 100644 --- a/tools/test/h5diff/testfiles/h5diff_621.txt +++ b/tools/test/h5diff/testfiles/h5diff_621.txt @@ -5,6 +5,9 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] [obj1] Name of an HDF5 object, in absolute path [obj2] Name of an HDF5 object, in absolute path + ERROR + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. OPTIONS -h, --help Print a usage message and exit. @@ -18,14 +21,35 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. - --enable-error-stack - Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -98,8 +122,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: - Default mode: print the number of differences found and where they occured + Default mode: print the number of differences found and where they occurred -r Report mode: print the above plus the differences -v Verbose mode: print the above plus a list of objects and warnings -q Quiet mode: do not print output @@ -125,6 +157,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] (The option --follow-symlinks overrides the default behavior when symbolic links are compared.). + Subsetting options: + Subsetting is available by using the fcompact form of subsetting, as follows: + obj1 /foo/mydataset[START;STRIDE;COUNT;BLOCK] + It is not required to use all parameters, but until the last parameter value used, + all of the semicolons (;) are required, even when a parameter value is not specified. Example: + obj1 /foo/mydataset[START;;COUNT;BLOCK] + obj1 /foo/mydataset[START] + The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in + each dimension. START is optional and will default to 0 in each dimension. + Each of START, STRIDE, COUNT, and BLOCK must be a comma-separated list of integers with + one integer for each dimension of the dataset. + Exit code: 0 if no differences, 1 if differences found, 2 if error diff --git a/tools/test/h5diff/testfiles/h5diff_622.txt b/tools/test/h5diff/testfiles/h5diff_622.txt index 2b2df2f..db77f88 100644 --- a/tools/test/h5diff/testfiles/h5diff_622.txt +++ b/tools/test/h5diff/testfiles/h5diff_622.txt @@ -5,6 +5,9 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] [obj1] Name of an HDF5 object, in absolute path [obj2] Name of an HDF5 object, in absolute path + ERROR + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. OPTIONS -h, --help Print a usage message and exit. @@ -18,14 +21,35 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. - --enable-error-stack - Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -98,8 +122,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: - Default mode: print the number of differences found and where they occured + Default mode: print the number of differences found and where they occurred -r Report mode: print the above plus the differences -v Verbose mode: print the above plus a list of objects and warnings -q Quiet mode: do not print output @@ -125,6 +157,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] (The option --follow-symlinks overrides the default behavior when symbolic links are compared.). + Subsetting options: + Subsetting is available by using the fcompact form of subsetting, as follows: + obj1 /foo/mydataset[START;STRIDE;COUNT;BLOCK] + It is not required to use all parameters, but until the last parameter value used, + all of the semicolons (;) are required, even when a parameter value is not specified. Example: + obj1 /foo/mydataset[START;;COUNT;BLOCK] + obj1 /foo/mydataset[START] + The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in + each dimension. START is optional and will default to 0 in each dimension. + Each of START, STRIDE, COUNT, and BLOCK must be a comma-separated list of integers with + one integer for each dimension of the dataset. + Exit code: 0 if no differences, 1 if differences found, 2 if error diff --git a/tools/test/h5diff/testfiles/h5diff_623.txt b/tools/test/h5diff/testfiles/h5diff_623.txt index 3e80438..11739be 100644 --- a/tools/test/h5diff/testfiles/h5diff_623.txt +++ b/tools/test/h5diff/testfiles/h5diff_623.txt @@ -5,6 +5,9 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] [obj1] Name of an HDF5 object, in absolute path [obj2] Name of an HDF5 object, in absolute path + ERROR + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. OPTIONS -h, --help Print a usage message and exit. @@ -18,14 +21,35 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. - --enable-error-stack - Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -98,8 +122,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: - Default mode: print the number of differences found and where they occured + Default mode: print the number of differences found and where they occurred -r Report mode: print the above plus the differences -v Verbose mode: print the above plus a list of objects and warnings -q Quiet mode: do not print output @@ -125,6 +157,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] (The option --follow-symlinks overrides the default behavior when symbolic links are compared.). + Subsetting options: + Subsetting is available by using the fcompact form of subsetting, as follows: + obj1 /foo/mydataset[START;STRIDE;COUNT;BLOCK] + It is not required to use all parameters, but until the last parameter value used, + all of the semicolons (;) are required, even when a parameter value is not specified. Example: + obj1 /foo/mydataset[START;;COUNT;BLOCK] + obj1 /foo/mydataset[START] + The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in + each dimension. START is optional and will default to 0 in each dimension. + Each of START, STRIDE, COUNT, and BLOCK must be a comma-separated list of integers with + one integer for each dimension of the dataset. + Exit code: 0 if no differences, 1 if differences found, 2 if error diff --git a/tools/test/h5diff/testfiles/h5diff_624.txt b/tools/test/h5diff/testfiles/h5diff_624.txt index 7a2f585..6af9fe3 100644 --- a/tools/test/h5diff/testfiles/h5diff_624.txt +++ b/tools/test/h5diff/testfiles/h5diff_624.txt @@ -5,6 +5,9 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] [obj1] Name of an HDF5 object, in absolute path [obj2] Name of an HDF5 object, in absolute path + ERROR + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. OPTIONS -h, --help Print a usage message and exit. @@ -18,14 +21,35 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. - --enable-error-stack - Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -98,8 +122,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: - Default mode: print the number of differences found and where they occured + Default mode: print the number of differences found and where they occurred -r Report mode: print the above plus the differences -v Verbose mode: print the above plus a list of objects and warnings -q Quiet mode: do not print output @@ -125,6 +157,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] (The option --follow-symlinks overrides the default behavior when symbolic links are compared.). + Subsetting options: + Subsetting is available by using the fcompact form of subsetting, as follows: + obj1 /foo/mydataset[START;STRIDE;COUNT;BLOCK] + It is not required to use all parameters, but until the last parameter value used, + all of the semicolons (;) are required, even when a parameter value is not specified. Example: + obj1 /foo/mydataset[START;;COUNT;BLOCK] + obj1 /foo/mydataset[START] + The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in + each dimension. START is optional and will default to 0 in each dimension. + Each of START, STRIDE, COUNT, and BLOCK must be a comma-separated list of integers with + one integer for each dimension of the dataset. + Exit code: 0 if no differences, 1 if differences found, 2 if error diff --git a/tools/test/h5diff/testfiles/h5diff_70.txt b/tools/test/h5diff/testfiles/h5diff_70.txt index efa34ea..b0b8bf6 100644 --- a/tools/test/h5diff/testfiles/h5diff_70.txt +++ b/tools/test/h5diff/testfiles/h5diff_70.txt @@ -1183,10 +1183,42 @@ position opaque3D of </dset> opaque3D of </dset> difference [ 3 2 1 ] 24 0 24 24 differences found attribute: <reference of </dset>> and <reference of </dset>> +Not comparable: <reference of </dset>> or <reference of </dset>> is an empty dataset +Not comparable: <reference of </dset>> or <reference of </dset>> is an empty dataset 0 differences found attribute: <reference2D of </dset>> and <reference2D of </dset>> +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset 0 differences found attribute: <reference3D of </dset>> and <reference3D of </dset>> +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset 0 differences found attribute: <string of </dset>> and <string of </dset>> size: [2] [2] diff --git a/tools/test/h5diff/testfiles/h5diff_700.txt b/tools/test/h5diff/testfiles/h5diff_700.txt index 851a407..6cf9893 100644 --- a/tools/test/h5diff/testfiles/h5diff_700.txt +++ b/tools/test/h5diff/testfiles/h5diff_700.txt @@ -1187,10 +1187,42 @@ position opaque3D of </dset> opaque3D of </dset> difference [ 3 2 1 ] 24 0 24 24 differences found attribute: <reference of </dset>> and <reference of </dset>> +Not comparable: <reference of </dset>> or <reference of </dset>> is an empty dataset +Not comparable: <reference of </dset>> or <reference of </dset>> is an empty dataset 0 differences found attribute: <reference2D of </dset>> and <reference2D of </dset>> +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset 0 differences found attribute: <reference3D of </dset>> and <reference3D of </dset>> +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset 0 differences found attribute: <string of </dset>> and <string of </dset>> size: [2] [2] diff --git a/tools/test/h5diff/testfiles/h5diff_701.txt b/tools/test/h5diff/testfiles/h5diff_701.txt index 33f1a0f..4187754 100644 --- a/tools/test/h5diff/testfiles/h5diff_701.txt +++ b/tools/test/h5diff/testfiles/h5diff_701.txt @@ -1254,10 +1254,42 @@ position opaque3D of </dset> opaque3D of </dset> difference [ 3 2 1 ] 24 0 24 24 differences found attribute: <reference of </dset>> and <reference of </dset>> +Not comparable: <reference of </dset>> or <reference of </dset>> is an empty dataset +Not comparable: <reference of </dset>> or <reference of </dset>> is an empty dataset 0 differences found attribute: <reference2D of </dset>> and <reference2D of </dset>> +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset 0 differences found attribute: <reference3D of </dset>> and <reference3D of </dset>> +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset 0 differences found attribute: <string of </dset>> and <string of </dset>> size: [2] [2] diff --git a/tools/test/h5diff/testfiles/h5diff_702.txt b/tools/test/h5diff/testfiles/h5diff_702.txt index 851a407..6cf9893 100644 --- a/tools/test/h5diff/testfiles/h5diff_702.txt +++ b/tools/test/h5diff/testfiles/h5diff_702.txt @@ -1187,10 +1187,42 @@ position opaque3D of </dset> opaque3D of </dset> difference [ 3 2 1 ] 24 0 24 24 differences found attribute: <reference of </dset>> and <reference of </dset>> +Not comparable: <reference of </dset>> or <reference of </dset>> is an empty dataset +Not comparable: <reference of </dset>> or <reference of </dset>> is an empty dataset 0 differences found attribute: <reference2D of </dset>> and <reference2D of </dset>> +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset 0 differences found attribute: <reference3D of </dset>> and <reference3D of </dset>> +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset 0 differences found attribute: <string of </dset>> and <string of </dset>> size: [2] [2] diff --git a/tools/test/h5diff/testfiles/h5diff_703.txt b/tools/test/h5diff/testfiles/h5diff_703.txt index 33f1a0f..4187754 100644 --- a/tools/test/h5diff/testfiles/h5diff_703.txt +++ b/tools/test/h5diff/testfiles/h5diff_703.txt @@ -1254,10 +1254,42 @@ position opaque3D of </dset> opaque3D of </dset> difference [ 3 2 1 ] 24 0 24 24 differences found attribute: <reference of </dset>> and <reference of </dset>> +Not comparable: <reference of </dset>> or <reference of </dset>> is an empty dataset +Not comparable: <reference of </dset>> or <reference of </dset>> is an empty dataset 0 differences found attribute: <reference2D of </dset>> and <reference2D of </dset>> +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset +Not comparable: <reference2D of </dset>> or <reference2D of </dset>> is an empty dataset 0 differences found attribute: <reference3D of </dset>> and <reference3D of </dset>> +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset +Not comparable: <reference3D of </dset>> or <reference3D of </dset>> is an empty dataset 0 differences found attribute: <string of </dset>> and <string of </dset>> size: [2] [2] diff --git a/tools/test/h5diff/testfiles/h5diff_80.txt b/tools/test/h5diff/testfiles/h5diff_80.txt index b223eed..11dccd8 100644 --- a/tools/test/h5diff/testfiles/h5diff_80.txt +++ b/tools/test/h5diff/testfiles/h5diff_80.txt @@ -528,166 +528,166 @@ position opaque3D opaque3D difference 24 differences found dataset: </g1/reference> and </g1/reference> size: [2] [2] -position difference +position reference reference difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference reference difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 4 differences found dataset: </g1/reference2D> and </g1/reference2D> size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 12 differences found dataset: </g1/reference3D> and </g1/reference3D> size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 diff --git a/tools/test/h5diff/testfiles/h5diff_830.txt b/tools/test/h5diff/testfiles/h5diff_830.txt new file mode 100644 index 0000000..8f00d8b --- /dev/null +++ b/tools/test/h5diff/testfiles/h5diff_830.txt @@ -0,0 +1,30 @@ +dataset: </g1/array3D> and </g1/array3D> +size: [4x3x2] [4x3x2] +position array3D array3D difference +------------------------------------------------------------ +[ 0 0 0 ] 1 0 1 +[ 0 0 0 ] 2 0 2 +[ 0 0 0 ] 3 0 3 +[ 0 0 1 ] 4 0 4 +[ 0 0 1 ] 5 0 5 +[ 0 0 1 ] 6 0 6 +[ 0 2 0 ] 13 0 13 +[ 0 2 0 ] 14 0 14 +[ 0 2 0 ] 15 0 15 +[ 0 2 1 ] 16 0 16 +[ 0 2 1 ] 17 0 17 +[ 0 2 1 ] 18 0 18 +[ 2 0 0 ] 37 0 37 +[ 2 0 0 ] 38 0 38 +[ 2 0 0 ] 39 0 39 +[ 2 0 1 ] 40 0 40 +[ 2 0 1 ] 41 0 41 +[ 2 0 1 ] 42 0 42 +[ 2 2 0 ] 49 0 49 +[ 2 2 0 ] 50 0 50 +[ 2 2 0 ] 51 0 51 +[ 2 2 1 ] 52 0 52 +[ 2 2 1 ] 53 0 53 +[ 2 2 1 ] 54 0 54 +24 differences found +EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_eps.txt b/tools/test/h5diff/testfiles/h5diff_eps.txt new file mode 100644 index 0000000..3a71366 --- /dev/null +++ b/tools/test/h5diff/testfiles/h5diff_eps.txt @@ -0,0 +1,17 @@ +file1: h5diff_eps1.h5 +file2: h5diff_eps2.h5 + +file1 file2 +--------------------------------------- + x x / + x x /DS1 + + +group : </> and </> +0 differences found +Attributes status: 0 common, 0 only in obj1, 0 only in obj2 + +dataset: </DS1> and </DS1> +0 differences found +Attributes status: 0 common, 0 only in obj1, 0 only in obj2 +EXIT CODE: 0 diff --git a/tools/test/h5diff/testfiles/h5diff_eps1.h5 b/tools/test/h5diff/testfiles/h5diff_eps1.h5 Binary files differnew file mode 100644 index 0000000..2803a1d --- /dev/null +++ b/tools/test/h5diff/testfiles/h5diff_eps1.h5 diff --git a/tools/test/h5diff/testfiles/h5diff_eps2.h5 b/tools/test/h5diff/testfiles/h5diff_eps2.h5 Binary files differnew file mode 100644 index 0000000..4acf27a --- /dev/null +++ b/tools/test/h5diff/testfiles/h5diff_eps2.h5 diff --git a/tools/test/h5diff/testfiles/h5diff_reg.txt b/tools/test/h5diff/testfiles/h5diff_reg.txt new file mode 100644 index 0000000..ecb6275 --- /dev/null +++ b/tools/test/h5diff/testfiles/h5diff_reg.txt @@ -0,0 +1,14 @@ + +dataset: </Dataset3> and </Dataset3> +attribute: <Attr1 of <Dataset3>> and <Attr1 of <Dataset3>> +0 differences found +Warning: Cannot open referenced attribute1 +attribute: <Attr2 of <Dataset3>> and <Attr2 of <Dataset3>> +0 differences found +attribute: <Attr3 of <Dataset3>> and <Attr3 of <Dataset3>> +0 differences found +0 differences found + obj1 obj2 + -------------------------------------- +Attributes status: 0 common, 0 only in obj1, 0 only in obj2 +EXIT CODE: 0 diff --git a/tools/test/h5diff/testfiles/diff_strings1.h5 b/tools/test/h5diff/testfiles/h5diff_strings1.h5 Binary files differindex 0f8b380..0f8b380 100644 --- a/tools/test/h5diff/testfiles/diff_strings1.h5 +++ b/tools/test/h5diff/testfiles/h5diff_strings1.h5 diff --git a/tools/test/h5diff/testfiles/diff_strings2.h5 b/tools/test/h5diff/testfiles/h5diff_strings2.h5 Binary files differindex e8520ae..e8520ae 100644 --- a/tools/test/h5diff/testfiles/diff_strings2.h5 +++ b/tools/test/h5diff/testfiles/h5diff_strings2.h5 diff --git a/tools/test/h5diff/testh5diff.sh.in b/tools/test/h5diff/testh5diff.sh.in index 557d2ff..6871463 100644 --- a/tools/test/h5diff/testh5diff.sh.in +++ b/tools/test/h5diff/testh5diff.sh.in @@ -7,7 +7,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -85,6 +85,7 @@ $SRC_H5DIFF_TESTFILES/h5diff_attr2.h5 $SRC_H5DIFF_TESTFILES/h5diff_attr3.h5 $SRC_H5DIFF_TESTFILES/h5diff_dset1.h5 $SRC_H5DIFF_TESTFILES/h5diff_dset2.h5 +$SRC_H5DIFF_TESTFILES/h5diff_dset3.h5 $SRC_H5DIFF_TESTFILES/h5diff_hyper1.h5 $SRC_H5DIFF_TESTFILES/h5diff_hyper2.h5 $SRC_H5DIFF_TESTFILES/h5diff_empty.h5 @@ -119,8 +120,10 @@ $SRC_H5DIFF_TESTFILES/h5diff_attr_v_level2.h5 $SRC_H5DIFF_TESTFILES/h5diff_enum_invalid_values.h5 $SRC_H5DIFF_TESTFILES/non_comparables1.h5 $SRC_H5DIFF_TESTFILES/non_comparables2.h5 -$SRC_H5DIFF_TESTFILES/diff_strings1.h5 -$SRC_H5DIFF_TESTFILES/diff_strings2.h5 +$SRC_H5DIFF_TESTFILES/h5diff_strings1.h5 +$SRC_H5DIFF_TESTFILES/h5diff_strings2.h5 +$SRC_H5DIFF_TESTFILES/h5diff_eps1.h5 +$SRC_H5DIFF_TESTFILES/h5diff_eps2.h5 $SRC_TOOLS_TESTFILES/tvlstr.h5 " @@ -150,6 +153,19 @@ $SRC_TOOLS_TESTFILES/vds/5_c.h5 $SRC_TOOLS_TESTFILES/vds/5_vds.h5 " +LIST_HDF5_STD_REF_OBJ_TEST_FILES=" +$SRC_TOOLS_TESTFILES/trefer_attr.h5 +$SRC_TOOLS_TESTFILES/trefer_compat.h5 +$SRC_TOOLS_TESTFILES/trefer_ext1.h5 +$SRC_TOOLS_TESTFILES/trefer_ext2.h5 +$SRC_TOOLS_TESTFILES/trefer_grp.h5 +$SRC_TOOLS_TESTFILES/trefer_obj_del.h5 +$SRC_TOOLS_TESTFILES/trefer_obj.h5 +$SRC_TOOLS_TESTFILES/trefer_param.h5 +$SRC_TOOLS_TESTFILES/trefer_reg_1d.h5 +$SRC_TOOLS_TESTFILES/trefer_reg.h5 +" + LIST_OTHER_TEST_FILES=" $SRC_H5DIFF_TESTFILES/h5diff_10.txt $SRC_H5DIFF_TESTFILES/h5diff_100.txt @@ -259,6 +275,7 @@ $SRC_H5DIFF_TESTFILES/h5diff_55.txt $SRC_H5DIFF_TESTFILES/h5diff_56.txt $SRC_H5DIFF_TESTFILES/h5diff_57.txt $SRC_H5DIFF_TESTFILES/h5diff_58.txt +$SRC_H5DIFF_TESTFILES/h5diff_58_ref.txt $SRC_H5DIFF_TESTFILES/h5diff_59.txt $SRC_H5DIFF_TESTFILES/h5diff_500.txt $SRC_H5DIFF_TESTFILES/h5diff_501.txt @@ -335,19 +352,24 @@ $SRC_H5DIFF_TESTFILES/h5diff_708.txt $SRC_H5DIFF_TESTFILES/h5diff_709.txt $SRC_H5DIFF_TESTFILES/h5diff_710.txt $SRC_H5DIFF_TESTFILES/h5diff_80.txt +$SRC_H5DIFF_TESTFILES/h5diff_800.txt +$SRC_H5DIFF_TESTFILES/h5diff_801.txt +$SRC_H5DIFF_TESTFILES/h5diff_830.txt $SRC_H5DIFF_TESTFILES/h5diff_90.txt $SRC_H5DIFF_TESTFILES/h5diff_8625.txt $SRC_H5DIFF_TESTFILES/h5diff_8639.txt +$SRC_H5DIFF_TESTFILES/h5diff_reg.txt $SRC_H5DIFF_TESTFILES/h5diff_v1.txt $SRC_H5DIFF_TESTFILES/h5diff_v2.txt $SRC_H5DIFF_TESTFILES/h5diff_v3.txt $SRC_H5DIFF_TESTFILES/h5diff_vlstr.txt +$SRC_H5DIFF_TESTFILES/h5diff_eps.txt " # # copy test files and expected output files from source dirs to test dir # -COPY_TESTFILES="$LIST_HDF5_TEST_FILES $LIST_HDF5_VDS_TEST_FILES $LIST_OTHER_TEST_FILES $LIST_HDF5_TEST_FILES_XML $LIST_OTHER_TEST_FILES_XML" +COPY_TESTFILES="$LIST_HDF5_TEST_FILES $LIST_HDF5_VDS_TEST_FILES $LIST_HDF5_STD_REF_OBJ_TEST_FILES $LIST_OTHER_TEST_FILES $LIST_HDF5_TEST_FILES_XML $LIST_OTHER_TEST_FILES_XML" COPY_TESTFILES_TO_TESTDIR() { @@ -433,7 +455,7 @@ done # RUNSERIAL is used. Check if it can return exit code from executalbe correctly. if [ -n "$RUNSERIAL_NOEXITCODE" ]; then - echo "***Warning*** Serial Exit Code is not passed back to shell corretly." + echo "***Warning*** Serial Exit Code is not passed back to shell correctly." echo "***Warning*** Exit code checking is skipped." h5haveexitcode=no fi @@ -479,22 +501,24 @@ TOOLTEST() { # Run test. TESTING $H5DIFF $@ ( - #echo "#############################" - #echo "Expected output for '$H5DIFF $@'" - #echo "#############################" - cd $TESTDIR - eval $RUNCMD $H5DIFF_BIN "$@" + #echo "#############################" + #echo "Expected output for '$H5DIFF $@'" + #echo "#############################" + cd $TESTDIR + eval $RUNCMD $H5DIFF_BIN "$@" ) >$actual 2>$actual_err EXIT_CODE=$? + # save actual and actual_err in case they are needed later. cp $actual $actual_sav STDOUT_FILTER $actual cp $actual_err $actual_err_sav STDERR_FILTER $actual_err + # don't add exit code check in pmode, as it causes failure. (exit code # is from mpirun not tool) # if any problem occurs relate to an exit code, it will be caught in - # serial mode, so the test is fullfilled. + # serial mode, so the test is fulfilled. if test $h5haveexitcode = 'yes' -a -z "$pmode"; then echo "EXIT CODE: $EXIT_CODE" >> $actual fi @@ -524,23 +548,24 @@ TOOLTEST() { # is done by serial mode. grep -v "EXIT CODE:" $expect_sorted > $expect_sorted.noexit mv $expect_sorted.noexit $expect_sorted - if $CMP $expect_sorted $actual_sorted; then - echo " PASSED" - else - echo "*FAILED*" - nerrors="`expr $nerrors + 1`" - if test yes = "$verbose"; then - echo "====Expected result ($expect_sorted) differs from actual result ($actual_sorted)" - $DIFF $expect_sorted $actual_sorted |sed 's/^/ /' - echo "====The actual output ($actual_sav)" - sed 's/^/ /' < $actual_sav - echo "====The actual stderr ($actual_err_sav)" - sed 's/^/ /' < $actual_err_sav - echo "====End of actual stderr ($actual_err_sav)" - echo "" + + if $CMP $expect_sorted $actual_sorted; then + echo " PASSED" + else + echo "*FAILED*" + nerrors="`expr $nerrors + 1`" + if test yes = "$verbose"; then + echo "====Expected result ($expect_sorted) differs from actual result ($actual_sorted)" + $DIFF $expect_sorted $actual_sorted |sed 's/^/ /' + echo "====The actual output ($actual_sav)" + sed 's/^/ /' < $actual_sav + echo "====The actual stderr ($actual_err_sav)" + sed 's/^/ /' < $actual_err_sav + echo "====End of actual stderr ($actual_err_sav)" + echo "" + fi fi fi - fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then @@ -691,7 +716,10 @@ TOOLTEST h5diff_56.txt -v h5diff_dtypes.h5 h5diff_dtypes.h5 dset6a dset6b TOOLTEST h5diff_57.txt -v h5diff_dtypes.h5 h5diff_dtypes.h5 dset7a dset7b # 5.8 (region reference) -TOOLTEST h5diff_58.txt -v h5diff_dset1.h5 h5diff_dset2.h5 refreg +TOOLTEST h5diff_58.txt -v2 h5diff_dset1.h5 h5diff_dset2.h5 refreg +TOOLTEST h5diff_58_ref.txt -v2 h5diff_dset1.h5 h5diff_dset2.h5 /g1/reference2D +# STD_REF_OBJ +TOOLTEST h5diff_reg.txt -v2 trefer_attr.h5 trefer_ext2.h5 Dataset3 Dataset3 # test for both dset and attr with same type but with different size # ( HDDFV-7942 ) @@ -699,10 +727,10 @@ TOOLTEST h5diff_59.txt -v h5diff_dtypes.h5 h5diff_dtypes.h5 dset11a dset11b # Strings # ( HDFFV-10128 ) -TOOLTEST h5diff_60.txt -v diff_strings1.h5 diff_strings2.h5 string1 string1 -TOOLTEST h5diff_61.txt -v diff_strings1.h5 diff_strings2.h5 string2 string2 -TOOLTEST h5diff_62.txt -v diff_strings1.h5 diff_strings2.h5 string3 string3 -TOOLTEST h5diff_63.txt -v diff_strings1.h5 diff_strings2.h5 string4 string4 +TOOLTEST h5diff_60.txt -v h5diff_strings1.h5 h5diff_strings2.h5 string1 string1 +TOOLTEST h5diff_61.txt -v h5diff_strings1.h5 h5diff_strings2.h5 string2 string2 +TOOLTEST h5diff_62.txt -v h5diff_strings1.h5 h5diff_strings2.h5 string3 string3 +TOOLTEST h5diff_63.txt -v h5diff_strings1.h5 h5diff_strings2.h5 string4 string4 # ############################################################################## # # Error messages @@ -745,6 +773,9 @@ TOOLTEST h5diff_609.txt -d 200 h5diff_basic1.h5 h5diff_basic2.h5 g1/dset3 g1/dse # 6.10: number smaller than smallest difference TOOLTEST h5diff_610.txt -d 1 h5diff_basic1.h5 h5diff_basic2.h5 g1/dset3 g1/dset4 +# eps: number smaller than epsilon +TOOLTEST h5diff_eps.txt -v3 -d 1e-16 h5diff_eps1.h5 h5diff_eps2.h5 + # ############################################################################## # # -p @@ -895,7 +926,7 @@ TOOLTEST h5diff_207.txt -c h5diff_basic2.h5 h5diff_basic2.h5 g2/dset8 g2/dset9 TOOLTEST h5diff_208.txt -c h5diff_dset_zero_dim_size1.h5 h5diff_dset_zero_dim_size2.h5 # non-comparable dataset with comparable attribute, and other comparable datasets. -# Also test non-compatible attributes with different type, dimention, rank. +# Also test non-compatible attributes with different type, dimension, rank. # All the comparables should display differences. TOOLTEST h5diff_220.txt -c non_comparables1.h5 non_comparables2.h5 /g1 @@ -1058,7 +1089,7 @@ TOOLTEST h5diff_474.txt -v h5diff_danglelinks1.h5 h5diff_danglelinks2.h5 /ext_li TOOLTEST h5diff_475.txt -v h5diff_danglelinks1.h5 h5diff_danglelinks2.h5 /ext_link1 # ############################################################################## -# # test for group diff recursivly +# # test for group diff recursively # ############################################################################## # root TOOLTEST h5diff_500.txt -v h5diff_grp_recurse1.h5 h5diff_grp_recurse2.h5 / / @@ -1166,6 +1197,17 @@ TOOLTEST h5diff_645.txt -v -p 0.05 --use-system-epsilon h5diff_basic1.h5 h5diff_ TOOLTEST h5diff_646.txt -v --use-system-epsilon -p 0.05 h5diff_basic1.h5 h5diff_basic2.h5 /g1/dset3 /g1/dset4 # ############################################################################## +# # Test array variances +# ############################################################################## +TOOLTEST h5diff_800.txt -v h5diff_dset1.h5 h5diff_dset2.h5 /g1/array /g1/array +TOOLTEST h5diff_801.txt -v h5diff_dset1.h5 h5diff_dset3.h5 /g1/array /g1/array + +# ############################################################################## +# # dataset subsets +# ############################################################################## +#TOOLTEST h5diff_830.txt --enable-error-stack -v h5diff_dset1.h5 h5diff_dset2.h5 "/g1/array3D[0,0,0;2,2,1;2,2,2;]" "/g1/array3D[0,0,0;2,2,1;2,2,2;]" + +# ############################################################################## # VDS tests # ############################################################################## TOOLTEST h5diff_v1.txt -v 1_vds.h5 2_vds.h5 diff --git a/tools/test/h5diff/testph5diff.sh.in b/tools/test/h5diff/testph5diff.sh.in index b726a80..5bb6e52 100644 --- a/tools/test/h5diff/testph5diff.sh.in +++ b/tools/test/h5diff/testph5diff.sh.in @@ -7,7 +7,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # diff --git a/tools/test/h5dump/CMakeLists.txt b/tools/test/h5dump/CMakeLists.txt index 38f4118..a7b4846 100644 --- a/tools/test/h5dump/CMakeLists.txt +++ b/tools/test/h5dump/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_TOOLS_TEST_H5DUMP C) #----------------------------------------------------------------------------- @@ -10,11 +10,18 @@ if (BUILD_SHARED_LIBS) set (H5DUMP_TOOL_PLUGIN_LIB_TARGET ${H5DUMP_TOOL_PLUGIN_LIB_CORENAME}) add_library (${H5DUMP_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_dump.c) - target_include_directories (${H5DUMP_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (${H5DUMP_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (${H5DUMP_TOOL_PLUGIN_LIB_TARGET} SHARED) - target_link_libraries (${H5DUMP_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIBSH_TARGET}) + target_link_libraries (${H5DUMP_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_LIBSH_TARGET}) H5_SET_LIB_OPTIONS (${H5DUMP_TOOL_PLUGIN_LIB_TARGET} ${H5DUMP_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5DUMP_PLUGIN_FORMAT ${H5DUMP_TOOL_PLUGIN_LIB_TARGET}) + endif () + # make plugins dir file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") #----------------------------------------------------------------------------- @@ -35,18 +42,27 @@ endif () # -------------------------------------------------------------------- if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) add_executable (h5dumpgentest ${HDF5_TOOLS_TEST_H5DUMP_SOURCE_DIR}/h5dumpgentest.c) - target_include_directories (h5dumpgentest PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (h5dumpgentest PRIVATE "${HDF5_SRC_DIR};${HDF5_TEST_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h5dumpgentest STATIC) target_link_libraries (h5dumpgentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (h5dumpgentest PROPERTIES FOLDER generator/tools) + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5DUMP_FORMAT h5dumpgentest) + endif () + #add_test (NAME h5dumpgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dumpgentest>) endif () -include (CMakeTests.cmake) +if (HDF5_TEST_TOOLS AND HDF5_TEST_SERIAL) + include (CMakeTests.cmake) -include (CMakeTestsPBITS.cmake) + include (CMakeTestsPBITS.cmake) -include (CMakeTestsVDS.cmake) + include (CMakeTestsVDS.cmake) -include (CMakeTestsXML.cmake) + include (CMakeTestsXML.cmake) +endif () diff --git a/tools/test/h5dump/CMakeTests.cmake b/tools/test/h5dump/CMakeTests.cmake index 6299821..933aba9 100644 --- a/tools/test/h5dump/CMakeTests.cmake +++ b/tools/test/h5dump/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. # @@ -101,6 +101,8 @@ ${HDF5_TOOLS_DIR}/testfiles/tfamily.ddl ${HDF5_TOOLS_DIR}/testfiles/tfill.ddl ${HDF5_TOOLS_DIR}/testfiles/tfletcher32.ddl + #${HDF5_TOOLS_DIR}/testfiles/tfloatsattrs.ddl #native + #${HDF5_TOOLS_DIR}/testfiles/tfloatsattrs.wddl #special for windows ${HDF5_TOOLS_DIR}/testfiles/tfpformat.ddl ${HDF5_TOOLS_DIR}/testfiles/tgroup-1.ddl ${HDF5_TOOLS_DIR}/testfiles/tgroup-2.ddl @@ -127,7 +129,8 @@ ${HDF5_TOOLS_DIR}/testfiles/tintsattrs.ddl ${HDF5_TOOLS_DIR}/testfiles/tintsnodata.ddl ${HDF5_TOOLS_DIR}/testfiles/tlarge_objname.ddl - #${HDF5_TOOLS_DIR}/testfiles/tldouble.ddl + ${HDF5_TOOLS_DIR}/testfiles/tldouble.ddl + ${HDF5_TOOLS_DIR}/testfiles/tldouble_scalar.ddl ${HDF5_TOOLS_DIR}/testfiles/tlonglinks.ddl ${HDF5_TOOLS_DIR}/testfiles/tloop-1.ddl ${HDF5_TOOLS_DIR}/testfiles/tmulti.ddl @@ -198,6 +201,16 @@ ${HDF5_TOOLS_DIR}/testfiles/h5dump-help.txt ${HDF5_TOOLS_DIR}/testfiles/out3.h5import ${HDF5_TOOLS_DIR}/testfiles/zerodim.ddl + #STD_REF_OBJ files + ${HDF5_TOOLS_DIR}/testfiles/trefer_attrR.ddl + ${HDF5_TOOLS_DIR}/testfiles/trefer_compatR.ddl + ${HDF5_TOOLS_DIR}/testfiles/trefer_extR.ddl + ${HDF5_TOOLS_DIR}/testfiles/trefer_grpR.ddl + ${HDF5_TOOLS_DIR}/testfiles/trefer_obj_delR.ddl + ${HDF5_TOOLS_DIR}/testfiles/trefer_objR.ddl + ${HDF5_TOOLS_DIR}/testfiles/trefer_paramR.ddl + ${HDF5_TOOLS_DIR}/testfiles/trefer_reg_1dR.ddl + ${HDF5_TOOLS_DIR}/testfiles/trefer_regR.ddl ) set (HDF5_N_REFERENCE_FILES tall-3 @@ -272,6 +285,7 @@ ${HDF5_TOOLS_DIR}/testfiles/tfcontents1.h5 ${HDF5_TOOLS_DIR}/testfiles/tfcontents2.h5 ${HDF5_TOOLS_DIR}/testfiles/tfilters.h5 + ${HDF5_TOOLS_DIR}/testfiles/tfloatsattrs.h5 ${HDF5_TOOLS_DIR}/testfiles/tfpformat.h5 ${HDF5_TOOLS_DIR}/testfiles/tfvalues.h5 ${HDF5_TOOLS_DIR}/testfiles/tgroup.h5 @@ -283,7 +297,8 @@ ${HDF5_TOOLS_DIR}/testfiles/tintsattrs.h5 ${HDF5_TOOLS_DIR}/testfiles/tintsnodata.h5 ${HDF5_TOOLS_DIR}/testfiles/tlarge_objname.h5 - #${HDF5_TOOLS_DIR}/testfiles/tldouble.h5 + ${HDF5_TOOLS_DIR}/testfiles/tldouble.h5 + ${HDF5_TOOLS_DIR}/testfiles/tldouble_scalar.h5 ${HDF5_TOOLS_DIR}/testfiles/tlonglinks.h5 ${HDF5_TOOLS_DIR}/testfiles/tloop.h5 ${HDF5_TOOLS_DIR}/testfiles/tmulti-b.h5 @@ -321,7 +336,21 @@ ${HDF5_TOOLS_DIR}/testfiles/tvlstr.h5 ${HDF5_TOOLS_DIR}/testfiles/tvms.h5 ${HDF5_TOOLS_DIR}/testfiles/t128bit_float.h5 + ${HDF5_TOOLS_DIR}/testfiles/tCVE_2018_11206_fill_old.h5 + ${HDF5_TOOLS_DIR}/testfiles/tCVE_2018_11206_fill_new.h5 ${HDF5_TOOLS_DIR}/testfiles/zerodim.h5 + #STD_REF_OBJ files + ${HDF5_TOOLS_DIR}/testfiles/trefer_attr.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_compat.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_ext1.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_ext2.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_grp.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_obj_del.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_obj.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_param.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_reg_1d.h5 + ${HDF5_TOOLS_DIR}/testfiles/trefer_reg.h5 + ) set (HDF5_ERROR_REFERENCE_TEST_FILES ${PROJECT_SOURCE_DIR}/errfiles/filter_fail.err @@ -383,12 +412,14 @@ # -------------------------------------------------------------------- HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/tbin1.ddl" "${PROJECT_BINARY_DIR}/testfiles/std/tbin1LE.ddl" "h5dump_std_files") - if (WIN32 OR MINGW) + if (WIN32 AND CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS 10.0.18362.0) configure_file(${HDF5_TOOLS_DIR}/testfiles/tbinregR.exp ${PROJECT_BINARY_DIR}/testfiles/std/tbinregR.exp NEWLINE_STYLE CRLF) #file (READ ${HDF5_TOOLS_DIR}/testfiles/tbinregR.exp TEST_STREAM) #file (WRITE ${PROJECT_BINARY_DIR}/testfiles/std/tbinregR.exp "${TEST_STREAM}") + HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/tfloatsattrs.wddl" "${PROJECT_BINARY_DIR}/testfiles/std/tfloatsattrs.ddl" "h5dump_std_files") else () HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/tbinregR.exp" "${PROJECT_BINARY_DIR}/testfiles/std/tbinregR.exp" "h5dump_std_files") + HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/tfloatsattrs.ddl" "${PROJECT_BINARY_DIR}/testfiles/std/tfloatsattrs.ddl" "h5dump_std_files") endif () add_custom_target(h5dump_std_files ALL COMMENT "Copying files needed by h5dump_std tests" DEPENDS ${h5dump_std_files_list}) @@ -398,16 +429,10 @@ ############################################################################## ############################################################################## - if (NOT BUILD_SHARED_LIBS) - set (tgt_ext "") - else () - set (tgt_ext "-shared") - endif () - macro (ADD_HELP_TEST testname resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_ext}> ${ARGN}) + add_test (NAME H5DUMP-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_file_ext}> ${ARGN}) set_tests_properties (H5DUMP-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") if (last_test) set_tests_properties (H5DUMP-${testname} PROPERTIES DEPENDS ${last_test}) @@ -418,7 +443,7 @@ NAME H5DUMP-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" -D "TEST_OUTPUT=h5dump-${testname}.out" @@ -449,7 +474,7 @@ macro (ADD_H5_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_ext}> ${ARGN}) + add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_file_ext}> ${ARGN}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") if (${resultcode}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") @@ -467,7 +492,7 @@ NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" -D "TEST_OUTPUT=${resultfile}.out" @@ -482,7 +507,7 @@ macro (ADD_H5_TEST_N resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-N-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_ext}> ${ARGN}) + add_test (NAME H5DUMP-N-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_file_ext}> ${ARGN}) set_tests_properties (H5DUMP-N-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") if (${resultcode}) set_tests_properties (H5DUMP-N-${resultfile} PROPERTIES WILL_FAIL "true") @@ -500,7 +525,7 @@ NAME H5DUMP-N-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" -D "TEST_OUTPUT=${resultfile}-N.out" @@ -515,7 +540,7 @@ macro (ADD_H5_TEST_EXPORT resultfile targetfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_ext}> ${ARGN} ${resultfile}.txt ${targetfile}) + add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_file_ext}> ${ARGN} ${resultfile}.txt ${targetfile}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") if (${resultcode}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") @@ -533,7 +558,7 @@ NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN};${resultfile}.txt;${targetfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" -D "TEST_OUTPUT=${resultfile}.out" @@ -542,21 +567,19 @@ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") - if(NOT CMAKE_VERSION VERSION_LESS "3.14.0") - add_test ( - NAME H5DUMP-${resultfile}-output-cmp - COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${resultfile}.txt ${resultfile}.exp - ) - set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES DEPENDS H5DUMP-${resultfile}) - endif () + add_test ( + NAME H5DUMP-${resultfile}-output-cmp + COMMAND ${CMAKE_COMMAND} -E compare_files ${CMAKE_IGNORE_EOL} ${resultfile}.txt ${resultfile}.exp + ) + set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") + set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES DEPENDS H5DUMP-${resultfile}) endif () endmacro () macro (ADD_H5_TEST_EXPORT_DDL resultfile targetfile resultcode ddlfile) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_ext}> --ddl=${ddlfile}.txt ${ARGN} ${resultfile}.txt ${targetfile}) + add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_file_ext}> --ddl=${ddlfile}.txt ${ARGN} ${resultfile}.txt ${targetfile}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") if (${resultcode}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") @@ -576,7 +599,7 @@ NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=--ddl=${ddlfile}.txt;${ARGN};${resultfile}.txt;${targetfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" -D "TEST_OUTPUT=${resultfile}.out" @@ -585,20 +608,18 @@ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") - if(NOT CMAKE_VERSION VERSION_LESS "3.14.0") - add_test ( - NAME H5DUMP-${resultfile}-output-cmp - COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${resultfile}.txt ${resultfile}.exp - ) - set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES DEPENDS H5DUMP-${resultfile}) - add_test ( - NAME H5DUMP-${resultfile}-output-cmp-ddl - COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${ddlfile}.txt ${ddlfile}.exp - ) - set_tests_properties (H5DUMP-${resultfile}-output-cmp-ddl PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - set_tests_properties (H5DUMP-${resultfile}-output-cmp-ddl PROPERTIES DEPENDS H5DUMP-${resultfile}-output-cmp) - endif () + add_test ( + NAME H5DUMP-${resultfile}-output-cmp + COMMAND ${CMAKE_COMMAND} -E compare_files ${CMAKE_IGNORE_EOL} ${resultfile}.txt ${resultfile}.exp + ) + set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") + set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES DEPENDS H5DUMP-${resultfile}) + add_test ( + NAME H5DUMP-${resultfile}-output-cmp-ddl + COMMAND ${CMAKE_COMMAND} -E compare_files ${CMAKE_IGNORE_EOL} ${ddlfile}.txt ${ddlfile}.exp + ) + set_tests_properties (H5DUMP-${resultfile}-output-cmp-ddl PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") + set_tests_properties (H5DUMP-${resultfile}-output-cmp-ddl PROPERTIES DEPENDS H5DUMP-${resultfile}-output-cmp) endif () endmacro () @@ -611,18 +632,16 @@ set_tests_properties (H5DUMP-output-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") add_test ( NAME H5DUMP-output-${resultfile} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_ext}> ${ARGN} ${resultfile}.txt ${targetfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_file_ext}> ${ARGN} ${resultfile}.txt ${targetfile} ) set_tests_properties (H5DUMP-output-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") set_tests_properties (H5DUMP-output-${resultfile} PROPERTIES DEPENDS H5DUMP-output-${resultfile}-clear-objects) - if(NOT CMAKE_VERSION VERSION_LESS "3.14.0") - add_test ( - NAME H5DUMP-output-cmp-${resultfile} - COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${resultfile}.txt ${resultfile}.exp - ) - set_tests_properties (H5DUMP-output-cmp-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - set_tests_properties (H5DUMP-output-cmp-${resultfile} PROPERTIES DEPENDS H5DUMP-output-${resultfile}) - endif () + add_test ( + NAME H5DUMP-output-cmp-${resultfile} + COMMAND ${CMAKE_COMMAND} -E compare_files ${CMAKE_IGNORE_EOL} ${resultfile}.txt ${resultfile}.exp + ) + set_tests_properties (H5DUMP-output-cmp-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") + set_tests_properties (H5DUMP-output-cmp-${resultfile} PROPERTIES DEPENDS H5DUMP-output-${resultfile}) endif () endmacro () @@ -632,7 +651,7 @@ NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" -D "TEST_OUTPUT=${resultfile}.out" @@ -650,7 +669,7 @@ NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" -D "TEST_OUTPUT=${resultfile}.out" @@ -667,7 +686,7 @@ NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" -D "TEST_OUTPUT=${resultfile}.out" @@ -685,7 +704,7 @@ NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" -D "TEST_OUTPUT=${resultfile}.out" @@ -713,7 +732,7 @@ NAME H5DUMP-IMPORT-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN};-o;${resultfile}.bin;${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" -D "TEST_OUTPUT=${conffile}.out" @@ -722,10 +741,10 @@ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5DUMP-IMPORT-${resultfile} PROPERTIES DEPENDS "H5DUMP-IMPORT-${resultfile}-clear-objects") - add_test (NAME H5DUMP-IMPORT-h5import-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5import> ${resultfile}.bin -c ${conffile}.out -o ${resultfile}.h5) + add_test (NAME H5DUMP-IMPORT-h5import-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5import${tgt_file_ext}> ${resultfile}.bin -c ${conffile}.out -o ${resultfile}.h5) set_tests_properties (H5DUMP-IMPORT-h5import-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") set_tests_properties (H5DUMP-IMPORT-h5import-${resultfile} PROPERTIES DEPENDS H5DUMP-IMPORT-${resultfile}) - add_test (NAME H5DUMP-IMPORT-h5diff-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff> ${testfile} ${resultfile}.h5 /integer /integer) + add_test (NAME H5DUMP-IMPORT-h5diff-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_file_ext}> ${testfile} ${resultfile}.h5 /integer /integer) set_tests_properties (H5DUMP-IMPORT-h5diff-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") set_tests_properties (H5DUMP-IMPORT-h5diff-${resultfile} PROPERTIES DEPENDS H5DUMP-IMPORT-h5import-${resultfile}) endif () @@ -737,7 +756,7 @@ NAME H5DUMP_UD-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" -D "TEST_OUTPUT=${resultfile}.out" @@ -844,7 +863,7 @@ # test for named data types ADD_H5_TEST (tcomp-2 0 --enable-error-stack -t /type1 --datatype /type2 --datatype=/group1/type3 tcompound.h5) ADD_H5_TEST_N (tcomp-2 0 --enable-error-stack -N /type1 --any_path /type2 --any_path=/group1/type3 tcompound.h5) - # test for unamed type + # test for unnamed type ADD_H5ERR_MASK_TEST (tcomp-3 0 "object '#6632' doesn't exist" "--enable-error-stack;-t;/#6632;-g;/group2;tcompound.h5") # test complicated compound datatype ADD_H5_TEST (tcomp-4 0 --enable-error-stack tcompound_complex.h5) @@ -892,7 +911,7 @@ # test for files with array data ADD_H5_TEST (tarray1 0 --enable-error-stack tarray1.h5) # # added for bug# 2092 - tarray1_big.h5 - ADD_H5ERR_MASK_TEST (tarray1_big 0 "Undefined reference pointer" --enable-error-stack -R tarray1_big.h5) + ADD_H5ERR_MASK_TEST (tarray1_big 0 "NULL token size" --enable-error-stack -R tarray1_big.h5) ADD_H5_TEST (tarray2 0 --enable-error-stack tarray2.h5) ADD_H5_TEST (tarray3 0 --enable-error-stack tarray3.h5) ADD_H5_TEST (tarray4 0 --enable-error-stack tarray4.h5) @@ -1075,7 +1094,9 @@ ADD_H5_TEST (zerodim 0 --enable-error-stack zerodim.h5) # test for long double (some systems do not have long double) - #ADD_H5_TEST (tldouble 0 --enable-error-stack tldouble.h5) + ADD_H5_TEST (tfloatsattrs 0 -p --enable-error-stack tfloatsattrs.h5) + ADD_H5_TEST (tldouble 0 --enable-error-stack tldouble.h5) + ADD_H5_TEST (tldouble_scalar 0 -p --enable-error-stack tldouble_scalar.h5) # test for vms ADD_H5_TEST (tvms 0 --enable-error-stack tvms.h5) @@ -1103,11 +1124,22 @@ # test for dataset region references ADD_H5_TEST (tdatareg 0 --enable-error-stack tdatareg.h5) - ADD_H5ERR_MASK_TEST (tdataregR 0 "Undefined reference pointer" --enable-error-stack -R tdatareg.h5) + ADD_H5ERR_MASK_TEST (tdataregR 0 "NULL token size" --enable-error-stack -R tdatareg.h5) ADD_H5_TEST (tattrreg 0 --enable-error-stack tattrreg.h5) - ADD_H5ERR_MASK_TEST (tattrregR 0 "Undefined reference pointer" -R --enable-error-stack tattrreg.h5) + ADD_H5ERR_MASK_TEST (tattrregR 0 "NULL token size" -R --enable-error-stack tattrreg.h5) ADD_H5_EXPORT_TEST (tbinregR tdatareg.h5 0 --enable-error-stack -d /Dataset1 -s 0 -R -y -o) + # test for 1.12 region references + ADD_H5_TEST (trefer_attrR 0 --enable-error-stack -R trefer_attr.h5) + ADD_H5_TEST (trefer_compatR 0 --enable-error-stack -R trefer_compat.h5) + ADD_H5_TEST (trefer_extR 0 --enable-error-stack -R trefer_ext2.h5) + ADD_H5_TEST (trefer_grpR 0 --enable-error-stack -R trefer_grp.h5) + ADD_H5_TEST (trefer_obj_delR 0 --enable-error-stack -R trefer_obj_del.h5) + ADD_H5_TEST (trefer_objR 0 --enable-error-stack -R trefer_obj.h5) + ADD_H5_TEST (trefer_paramR 0 --enable-error-stack -R trefer_param.h5) + ADD_H5_TEST (trefer_regR 0 --enable-error-stack -R trefer_reg.h5) + ADD_H5_TEST (trefer_reg_1dR 0 --enable-error-stack -R trefer_reg_1d.h5) + # tests for group creation order # "1" tracked, "2" name, root tracked ADD_H5_TEST (tordergr1 0 --enable-error-stack --group=1 --sort_by=creation_order --sort_order=ascending tordergr.h5) @@ -1149,7 +1181,11 @@ ADD_H5_TEST (err_attr_dspace 1 err_attr_dspace.h5) # test to verify HDFFV-9407: long double full precision - ADD_H5_GREP_TEST (t128bit_float 1 "1.123456789012345" -m %.35Lf t128bit_float.h5) +# ADD_H5_GREP_TEST (t128bit_float 1 "1.123456789012345" -m %.35Lg t128bit_float.h5) + + # test to verify HDFFV-10480: out of bounds read in H5O_fill_new[old]_decode + ADD_H5_TEST (tCVE_2018_11206_fill_old 1 tCVE_2018_11206_fill_old.h5) + ADD_H5_TEST (tCVE_2018_11206_fill_new 1 tCVE_2018_11206_fill_new.h5) ############################################################################## ### P L U G I N T E S T S diff --git a/tools/test/h5dump/CMakeTestsPBITS.cmake b/tools/test/h5dump/CMakeTestsPBITS.cmake index a6be9ae..0c3297f 100644 --- a/tools/test/h5dump/CMakeTestsPBITS.cmake +++ b/tools/test/h5dump/CMakeTestsPBITS.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. # @@ -119,16 +119,10 @@ ############################################################################## ############################################################################## - if (NOT BUILD_SHARED_LIBS) - set (tgt_ext "") - else () - set (tgt_ext "-shared") - endif () - macro (ADD_H5_PBITS_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_ext}> ${ARGN}) + add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_file_ext}> ${ARGN}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/pbits") if (${resultcode}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") @@ -141,7 +135,7 @@ NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/pbits" -D "TEST_OUTPUT=${resultfile}.out" @@ -164,7 +158,7 @@ # Limits: # Maximum number of packed bits is 8 (for now). # Maximum integer size is 8*sizeof(long long). - # Maximun Offset is Maximum size - 1. + # Maximum Offset is Maximum size - 1. # Maximum Offset+Length is Maximum size. # Tests: # Normal operation on both signed and unsigned int datasets. diff --git a/tools/test/h5dump/CMakeTestsVDS.cmake b/tools/test/h5dump/CMakeTestsVDS.cmake index 036609c..88df9ad 100644 --- a/tools/test/h5dump/CMakeTestsVDS.cmake +++ b/tools/test/h5dump/CMakeTestsVDS.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. # @@ -115,16 +115,10 @@ ############################################################################## ############################################################################## - if (NOT BUILD_SHARED_LIBS) - set (tgt_ext "") - else () - set (tgt_ext "-shared") - endif () - macro (ADD_H5_VDS_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_ext}> ${ARGN}) + add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_file_ext}> ${ARGN}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds") if (${resultcode}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") @@ -137,7 +131,7 @@ NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/vds" -D "TEST_OUTPUT=${resultfile}.out" @@ -151,7 +145,7 @@ macro (ADD_H5_VDS_PREFIX_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP_PREFIX-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_ext}> ${ARGN}) + add_test (NAME H5DUMP_PREFIX-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_file_ext}> ${ARGN}) set_tests_properties (H5DUMP_PREFIX-${resultfile} PROPERTIES ENVIRONMENT "HDF5_VDS_PREFIX=${PROJECT_BINARY_DIR}/testfiles/vds/" WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds/prefix" @@ -167,7 +161,7 @@ NAME H5DUMP_PREFIX-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/vds/prefix" -D "TEST_OUTPUT=${resultfile}.out" @@ -183,7 +177,7 @@ macro (ADD_H5_VDS_LAYOUT resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_ext}> -p ${ARGN}) + add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_file_ext}> -p ${ARGN}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds") if (${resultcode}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") @@ -196,7 +190,7 @@ NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=-p;${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/vds" -D "TEST_OUTPUT=${resultfile}.out" diff --git a/tools/test/h5dump/CMakeTestsXML.cmake b/tools/test/h5dump/CMakeTestsXML.cmake index 6d73cb1..d735257 100644 --- a/tools/test/h5dump/CMakeTestsXML.cmake +++ b/tools/test/h5dump/CMakeTestsXML.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. # @@ -160,12 +160,6 @@ ############################################################################## ############################################################################## - if (NOT BUILD_SHARED_LIBS) - set (tgt_ext "") - else () - set (tgt_ext "-shared") - endif () - macro (ADD_XML_SKIP_H5_TEST skipresultfile skipresultcode testtype) if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) @@ -182,7 +176,7 @@ macro (ADD_XML_H5_TEST resultfile resultcode) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP_XML-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_ext}> --xml ${ARGN}) + add_test (NAME H5DUMP_XML-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5dump${tgt_file_ext}> --xml ${ARGN}) set_tests_properties (H5DUMP_XML-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/xml") if (${resultcode}) set_tests_properties (H5DUMP_XML-${resultfile} PROPERTIES WILL_FAIL "true") @@ -195,7 +189,7 @@ NAME H5DUMP_XML-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=--xml;${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/xml" -D "TEST_OUTPUT=${resultfile}.out" diff --git a/tools/test/h5dump/CMakeVFDTests.cmake b/tools/test/h5dump/CMakeVFDTests.cmake index 0a345ef..7ab8c1f 100644 --- a/tools/test/h5dump/CMakeVFDTests.cmake +++ b/tools/test/h5dump/CMakeVFDTests.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. # @@ -15,20 +15,7 @@ ### T E S T I N G ### ############################################################################## ############################################################################## - -set (VFD_H5DUMP_LIST - sec2 - stdio - core - core_paged - split - multi - family -) - -if (DIRECT_VFD) - set (VFD_H5DUMP_LIST ${VFD_H5DUMP_LIST} direct) -endif () +H5_CREATE_VFD_DIR() # -------------------------------------------------------------------- # Copy all the HDF5 files from the source directory into the test directory @@ -37,8 +24,7 @@ set (HDF5_VFD_H5DUMP_FILES packedbits ) -foreach (vfdtest ${VFD_H5DUMP_LIST}) - file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdname}") +foreach (vfdtest ${VFD_LIST}) foreach (h5_tfile ${HDF5_VFD_H5DUMP_FILES}) HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_tfile}.h5" "${PROJECT_BINARY_DIR}/${vfdtest}/${h5_tfile}.h5" "HDF5_VFD_H5DUMP_files") HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_tfile}.ddl" "${PROJECT_BINARY_DIR}/${vfdtest}/${h5_tfile}.ddl" "HDF5_VFD_H5DUMP_files") @@ -53,19 +39,13 @@ add_custom_target(HDF5_VFD_H5DUMP_files ALL COMMENT "Copying files needed by HDF ############################################################################## ############################################################################## -if (NOT BUILD_SHARED_LIBS) - set (tgt_ext "") -else () - set (tgt_ext "-shared") -endif () - macro (ADD_VFD_H5DUMP_TEST vfdname resultfile resultcode) if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5DUMP_VFD-${vfdname}-${resultfile}-h5dump COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_VFD:STRING=${vfdname}" -D "TEST_EXPECT=${resultcode}" @@ -85,7 +65,7 @@ endmacro () ############################################################################## # Run test with different Virtual File Driver -foreach (vfd ${VFD_H5DUMP_LIST}) +foreach (vfd ${VFD_LIST}) # test for signed/unsigned datasets ADD_VFD_H5DUMP_TEST (${vfd} packedbits 0 --enable-error-stack packedbits.h5) endforeach () diff --git a/tools/test/h5dump/Makefile.am b/tools/test/h5dump/Makefile.am index a7a2bcb..2651320 100644 --- a/tools/test/h5dump/Makefile.am +++ b/tools/test/h5dump/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,7 +19,7 @@ include $(top_srcdir)/config/commence.am # Include files in /src directory and /tools/lib directory -AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib +AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib # Test programs and scripts TEST_PROG=h5dumpgentest diff --git a/tools/test/h5dump/binread.c b/tools/test/h5dump/binread.c index 6165cd8..341a085 100644 --- a/tools/test/h5dump/binread.c +++ b/tools/test/h5dump/binread.c @@ -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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,9 +27,9 @@ */ -#define NELMTS 6 -#define TYPE int -#define FORMAT "%d " +#define NELMTS 6 +#define TYPE int +#define FORMAT "%d " /*------------------------------------------------------------------------- * Function: usage @@ -45,7 +45,7 @@ *------------------------------------------------------------------------- */ static void -usage (void) +usage(void) { fprintf(stderr, "usage: binread FILE_NAME\n"); } @@ -59,13 +59,13 @@ usage (void) */ int -main (int argc, const char *argv[]) +main(int argc, char *argv[]) { - FILE *stream; + FILE * stream; size_t numread; TYPE buf[NELMTS]; size_t i, nelmts = NELMTS; - char *fname=NULL; + char * fname = NULL; if (argc != 2) { usage(); @@ -74,12 +74,12 @@ main (int argc, const char *argv[]) fname = strdup(argv[1]); - if((stream = fopen(fname, "rb")) != NULL) { - numread = fread(buf, sizeof( TYPE ), nelmts, stream); + if ((stream = fopen(fname, "rb")) != NULL) { + numread = fread(buf, sizeof(TYPE), nelmts, stream); printf("Number of items read = %llu\n", (unsigned long long)numread); for (i = 0; i < nelmts; i++) { - printf(FORMAT,buf[i]); + printf(FORMAT, buf[i]); } printf("\n"); @@ -92,4 +92,3 @@ main (int argc, const char *argv[]) return 0; } - diff --git a/tools/test/h5dump/dynlib_dump.c b/tools/test/h5dump/dynlib_dump.c index 571452e..433522d 100644 --- a/tools/test/h5dump/dynlib_dump.c +++ b/tools/test/h5dump/dynlib_dump.c @@ -5,7 +5,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,25 +17,33 @@ #include <stdio.h> #include "H5PLextern.h" -#define H5Z_FILTER_DYNLIBUD 300 -#define MULTIPLIER 3 +#define H5Z_FILTER_DYNLIBUD 300 +#define MULTIPLIER 3 -static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_DYNLIBUD[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_DYNLIBUD, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "dynlibud", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_DYNLIBUD, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "dynlibud", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + H5Z_filter_dynlibud, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_FILTER; +} +const void * +H5PLget_plugin_info(void) +{ + return H5Z_DYNLIBUD; +} /*------------------------------------------------------------------------- * Function: H5Z_filter_dynlibud @@ -51,39 +59,37 @@ const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} *------------------------------------------------------------------------- */ static size_t -H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) { - char *int_ptr = (char *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + char * int_ptr = (char *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ /* Check for the correct number of parameters */ - if(cd_nelmts > 0) - return(0); + if (cd_nelmts > 0) + return (0); /* Assignment to eliminate unused parameter warning. */ - cd_values = cd_values; + (void)cd_values; - if(flags & H5Z_FLAG_REVERSE) { /*read*/ + if (flags & H5Z_FLAG_REVERSE) { /*read*/ /* Subtract the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = temp - MULTIPLIER; + *int_ptr = (int8_t)(temp - MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ else { /*write*/ /* Add the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = temp + MULTIPLIER; + *int_ptr = (int8_t)(temp + MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); } /* end while */ - } /* end else */ + } /* end else */ return nbytes; } /* end H5Z_filter_dynlibud() */ - diff --git a/tools/test/h5dump/errfiles/tall-1.err b/tools/test/h5dump/errfiles/tall-1.err index 84140f2..8440159 100644 --- a/tools/test/h5dump/errfiles/tall-1.err +++ b/tools/test/h5dump/errfiles/tall-1.err @@ -1,34 +1,37 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object + #000: (file name) line (number) in H5Oopen(): unable to synchronously open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): object open failed + #001: (file name) line (number) in H5O__open_api_common(): unable to open object + major: Object header + minor: Can't open object + #002: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL__object_open(): object open failed + #003: (file name) line (number) in H5VL__object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name + #004: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #004: (file name) line (number) in H5O_open_name(): object not found + #005: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #005: (file name) line (number) in H5G_loc_find(): can't find object + #006: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G_traverse(): internal path traversal failed + #007: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #008: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #009: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #010: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) - #010: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'somefile' + minor: Unable to find ID information (already closed?) + #011: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'somefile' major: Links minor: Unable to open file diff --git a/tools/test/h5dump/errfiles/tall-2A.err b/tools/test/h5dump/errfiles/tall-2A.err index 84140f2..8440159 100644 --- a/tools/test/h5dump/errfiles/tall-2A.err +++ b/tools/test/h5dump/errfiles/tall-2A.err @@ -1,34 +1,37 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object + #000: (file name) line (number) in H5Oopen(): unable to synchronously open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): object open failed + #001: (file name) line (number) in H5O__open_api_common(): unable to open object + major: Object header + minor: Can't open object + #002: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL__object_open(): object open failed + #003: (file name) line (number) in H5VL__object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name + #004: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #004: (file name) line (number) in H5O_open_name(): object not found + #005: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #005: (file name) line (number) in H5G_loc_find(): can't find object + #006: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G_traverse(): internal path traversal failed + #007: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #008: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #009: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #010: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) - #010: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'somefile' + minor: Unable to find ID information (already closed?) + #011: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'somefile' major: Links minor: Unable to open file diff --git a/tools/test/h5dump/errfiles/tall-2A0.err b/tools/test/h5dump/errfiles/tall-2A0.err index 84140f2..8440159 100644 --- a/tools/test/h5dump/errfiles/tall-2A0.err +++ b/tools/test/h5dump/errfiles/tall-2A0.err @@ -1,34 +1,37 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object + #000: (file name) line (number) in H5Oopen(): unable to synchronously open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): object open failed + #001: (file name) line (number) in H5O__open_api_common(): unable to open object + major: Object header + minor: Can't open object + #002: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL__object_open(): object open failed + #003: (file name) line (number) in H5VL__object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name + #004: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #004: (file name) line (number) in H5O_open_name(): object not found + #005: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #005: (file name) line (number) in H5G_loc_find(): can't find object + #006: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G_traverse(): internal path traversal failed + #007: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #008: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #009: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #010: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) - #010: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'somefile' + minor: Unable to find ID information (already closed?) + #011: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'somefile' major: Links minor: Unable to open file diff --git a/tools/test/h5dump/errfiles/tall-2B.err b/tools/test/h5dump/errfiles/tall-2B.err index 84140f2..8440159 100644 --- a/tools/test/h5dump/errfiles/tall-2B.err +++ b/tools/test/h5dump/errfiles/tall-2B.err @@ -1,34 +1,37 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object + #000: (file name) line (number) in H5Oopen(): unable to synchronously open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): object open failed + #001: (file name) line (number) in H5O__open_api_common(): unable to open object + major: Object header + minor: Can't open object + #002: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL__object_open(): object open failed + #003: (file name) line (number) in H5VL__object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name + #004: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #004: (file name) line (number) in H5O_open_name(): object not found + #005: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #005: (file name) line (number) in H5G_loc_find(): can't find object + #006: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G_traverse(): internal path traversal failed + #007: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #008: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #009: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #010: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) - #010: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'somefile' + minor: Unable to find ID information (already closed?) + #011: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'somefile' major: Links minor: Unable to open file diff --git a/tools/test/h5dump/errfiles/tarray1_big.err b/tools/test/h5dump/errfiles/tarray1_big.err index ff22495..a20b0b7 100644 --- a/tools/test/h5dump/errfiles/tarray1_big.err +++ b/tools/test/h5dump/errfiles/tarray1_big.err @@ -1,58 +1,31 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Rdereference2(): unable to dereference object + #000: (file name) line (number) in H5Rget_obj_type3(): unable to get object token major: References - minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): object open failed - major: Virtual Object Layer - minor: Can't open object - #002: (file name) line (number) in H5VL__object_open(): object open failed - major: Virtual Object Layer - minor: Can't open object - #003: (file name) line (number) in H5VL__native_object_open(): unable to dereference object + minor: Can't get value + #001: (file name) line (number) in H5R__get_obj_token(): NULL token size major: References - minor: Can't open object - #004: (file name) line (number) in H5R__dereference(): Undefined reference pointer - major: Invalid arguments to routine - minor: Bad value + minor: Unable to copy object HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Rdereference2(): unable to dereference object + #000: (file name) line (number) in H5Rget_obj_type3(): unable to get object token major: References - minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): object open failed - major: Virtual Object Layer - minor: Can't open object - #002: (file name) line (number) in H5VL__object_open(): object open failed - major: Virtual Object Layer - minor: Can't open object - #003: (file name) line (number) in H5VL__native_object_open(): unable to dereference object + minor: Can't get value + #001: (file name) line (number) in H5R__get_obj_token(): NULL token size major: References - minor: Can't open object - #004: (file name) line (number) in H5R__dereference(): Undefined reference pointer - major: Invalid arguments to routine - minor: Bad value + minor: Unable to copy object HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Rdereference2(): unable to dereference object + #000: (file name) line (number) in H5Rget_obj_type3(): unable to get object token major: References - minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): object open failed - major: Virtual Object Layer - minor: Can't open object - #002: (file name) line (number) in H5VL__object_open(): object open failed - major: Virtual Object Layer - minor: Can't open object - #003: (file name) line (number) in H5VL__native_object_open(): unable to dereference object + minor: Can't get value + #001: (file name) line (number) in H5R__get_obj_token(): NULL token size major: References - minor: Can't open object - #004: (file name) line (number) in H5R__dereference(): Undefined reference pointer - major: Invalid arguments to routine - minor: Bad value + minor: Unable to copy object H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5tools_dump_simple_data(): H5Rdereference failed + #000: (file name) line (number) in h5tools_dump_data(): H5Rget_obj_type3 H5R_OBJECT1 failed major: Failure in tools library minor: error in function - #001: (file name) line (number) in h5tools_dump_simple_data(): H5Rdereference failed + #001: (file name) line (number) in h5tools_dump_data(): H5Rget_obj_type3 H5R_OBJECT1 failed major: Failure in tools library minor: error in function - #002: (file name) line (number) in h5tools_dump_simple_data(): H5Rdereference failed + #002: (file name) line (number) in h5tools_dump_data(): H5Rget_obj_type3 H5R_OBJECT1 failed major: Failure in tools library minor: error in function diff --git a/tools/test/h5dump/errfiles/tattr-3.err b/tools/test/h5dump/errfiles/tattr-3.err index 8481acf..7625965 100644 --- a/tools/test/h5dump/errfiles/tattr-3.err +++ b/tools/test/h5dump/errfiles/tattr-3.err @@ -1,20 +1,26 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Aopen(): unable to open attribute: 'attr' + #000: (file name) line (number) in H5Aopen(): unable to synchronously open attribute + major: Attribute + minor: Unable to create file + #001: (file name) line (number) in H5A__open_api_common(): unable to open attribute: 'attr' + major: Attribute + minor: Can't open object + #002: (file name) line (number) in H5A__open_common(): unable to open attribute: 'attr' major: Attribute minor: Can't open object - #001: (file name) line (number) in H5VL_attr_open(): attribute open failed + #003: (file name) line (number) in H5VL_attr_open(): attribute open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL__attr_open(): attribute open failed + #004: (file name) line (number) in H5VL__attr_open(): attribute open failed major: Virtual Object Layer minor: Can't open object - #003: (file name) line (number) in H5VL__native_attr_open(): unable to open attribute: 'attr' + #005: (file name) line (number) in H5VL__native_attr_open(): unable to open attribute: 'attr' major: Attribute minor: Can't open object - #004: (file name) line (number) in H5A__open(): unable to load attribute info from object header for attribute: 'attr' + #006: (file name) line (number) in H5A__open(): unable to load attribute info from object header for attribute: 'attr' major: Attribute minor: Can't open object - #005: (file name) line (number) in H5O__attr_open_by_name(): can't locate attribute: 'attr' + #007: (file name) line (number) in H5O__attr_open_by_name(): can't locate attribute: 'attr' major: Attribute minor: Object not found h5dump error: unable to open attribute "attr" diff --git a/tools/test/h5dump/errfiles/tattrregR.err b/tools/test/h5dump/errfiles/tattrregR.err index 8a1539c..fa2014a 100644 --- a/tools/test/h5dump/errfiles/tattrregR.err +++ b/tools/test/h5dump/errfiles/tattrregR.err @@ -1,39 +1,21 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Rdereference2(): unable to dereference object + #000: (file name) line (number) in H5Rget_obj_type3(): unable to get object token major: References - minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): object open failed - major: Virtual Object Layer - minor: Can't open object - #002: (file name) line (number) in H5VL__object_open(): object open failed - major: Virtual Object Layer - minor: Can't open object - #003: (file name) line (number) in H5VL__native_object_open(): unable to dereference object + minor: Can't get value + #001: (file name) line (number) in H5R__get_obj_token(): NULL token size major: References - minor: Can't open object - #004: (file name) line (number) in H5R__dereference(): Undefined reference pointer - major: Invalid arguments to routine - minor: Bad value + minor: Unable to copy object HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Rdereference2(): unable to dereference object + #000: (file name) line (number) in H5Rget_obj_type3(): unable to get object token major: References - minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): object open failed - major: Virtual Object Layer - minor: Can't open object - #002: (file name) line (number) in H5VL__object_open(): object open failed - major: Virtual Object Layer - minor: Can't open object - #003: (file name) line (number) in H5VL__native_object_open(): unable to dereference object + minor: Can't get value + #001: (file name) line (number) in H5R__get_obj_token(): NULL token size major: References - minor: Can't open object - #004: (file name) line (number) in H5R__dereference(): Undefined reference pointer - major: Invalid arguments to routine - minor: Bad value + minor: Unable to copy object H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5tools_dump_simple_data(): H5Rdereference failed + #000: (file name) line (number) in h5tools_dump_data(): H5Rget_obj_type3 H5R_OBJECT1 failed major: Failure in tools library minor: error in function - #001: (file name) line (number) in h5tools_dump_simple_data(): H5Rdereference failed + #001: (file name) line (number) in h5tools_dump_data(): H5Rget_obj_type3 H5R_OBJECT1 failed major: Failure in tools library minor: error in function diff --git a/tools/test/h5dump/errfiles/tcomp-3.err b/tools/test/h5dump/errfiles/tcomp-3.err index fc59b0b..650df92 100644 --- a/tools/test/h5dump/errfiles/tcomp-3.err +++ b/tools/test/h5dump/errfiles/tcomp-3.err @@ -1,28 +1,31 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Topen2(): unable to open named datatype + #000: (file name) line (number) in H5Topen2(): unable to open named datatype synchronously major: Datatype minor: Can't open object - #001: (file name) line (number) in H5VL_datatype_open(): datatype open failed + #001: (file name) line (number) in H5T__open_api_common(): unable to open named datatype + major: Datatype + minor: Can't open object + #002: (file name) line (number) in H5VL_datatype_open(): datatype open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL__datatype_open(): datatype open failed + #003: (file name) line (number) in H5VL__datatype_open(): datatype open failed major: Virtual Object Layer minor: Can't open object - #003: (file name) line (number) in H5VL__native_datatype_open(): unable to open named datatype + #004: (file name) line (number) in H5VL__native_datatype_open(): unable to open named datatype major: Datatype minor: Can't open object - #004: (file name) line (number) in H5T__open_name(): not found + #005: (file name) line (number) in H5T__open_name(): not found major: Datatype minor: Object not found - #005: (file name) line (number) in H5G_loc_find(): can't find object + #006: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G_traverse(): internal path traversal failed + #007: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #007: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #008: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #008: (file name) line (number) in H5G__loc_find_cb(): object '#6632' doesn't exist + #009: (file name) line (number) in H5G__loc_find_cb(): object '#6632' doesn't exist major: Symbol table minor: Object not found diff --git a/tools/test/h5dump/errfiles/tdataregR.err b/tools/test/h5dump/errfiles/tdataregR.err index 8a1539c..fa2014a 100644 --- a/tools/test/h5dump/errfiles/tdataregR.err +++ b/tools/test/h5dump/errfiles/tdataregR.err @@ -1,39 +1,21 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Rdereference2(): unable to dereference object + #000: (file name) line (number) in H5Rget_obj_type3(): unable to get object token major: References - minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): object open failed - major: Virtual Object Layer - minor: Can't open object - #002: (file name) line (number) in H5VL__object_open(): object open failed - major: Virtual Object Layer - minor: Can't open object - #003: (file name) line (number) in H5VL__native_object_open(): unable to dereference object + minor: Can't get value + #001: (file name) line (number) in H5R__get_obj_token(): NULL token size major: References - minor: Can't open object - #004: (file name) line (number) in H5R__dereference(): Undefined reference pointer - major: Invalid arguments to routine - minor: Bad value + minor: Unable to copy object HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Rdereference2(): unable to dereference object + #000: (file name) line (number) in H5Rget_obj_type3(): unable to get object token major: References - minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): object open failed - major: Virtual Object Layer - minor: Can't open object - #002: (file name) line (number) in H5VL__object_open(): object open failed - major: Virtual Object Layer - minor: Can't open object - #003: (file name) line (number) in H5VL__native_object_open(): unable to dereference object + minor: Can't get value + #001: (file name) line (number) in H5R__get_obj_token(): NULL token size major: References - minor: Can't open object - #004: (file name) line (number) in H5R__dereference(): Undefined reference pointer - major: Invalid arguments to routine - minor: Bad value + minor: Unable to copy object H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5tools_dump_simple_data(): H5Rdereference failed + #000: (file name) line (number) in h5tools_dump_data(): H5Rget_obj_type3 H5R_OBJECT1 failed major: Failure in tools library minor: error in function - #001: (file name) line (number) in h5tools_dump_simple_data(): H5Rdereference failed + #001: (file name) line (number) in h5tools_dump_data(): H5Rget_obj_type3 H5R_OBJECT1 failed major: Failure in tools library minor: error in function diff --git a/tools/test/h5dump/errfiles/tdset-2.err b/tools/test/h5dump/errfiles/tdset-2.err index 2d70b35..051c677 100644 --- a/tools/test/h5dump/errfiles/tdset-2.err +++ b/tools/test/h5dump/errfiles/tdset-2.err @@ -1,33 +1,36 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dopen2(): unable to open dataset + #000: (file name) line (number) in H5Dopen2(): unable to synchronously open dataset major: Dataset minor: Can't open object - #001: (file name) line (number) in H5VL_dataset_open(): dataset open failed + #001: (file name) line (number) in H5D__open_api_common(): unable to open dataset + major: Dataset + minor: Can't open object + #002: (file name) line (number) in H5VL_dataset_open(): dataset open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL__dataset_open(): dataset open failed + #003: (file name) line (number) in H5VL__dataset_open(): dataset open failed major: Virtual Object Layer minor: Can't open object - #003: (file name) line (number) in H5VL__native_dataset_open(): unable to open dataset + #004: (file name) line (number) in H5VL__native_dataset_open(): unable to open dataset major: Dataset minor: Can't open object - #004: (file name) line (number) in H5D__open_name(): not found + #005: (file name) line (number) in H5D__open_name(): not found major: Dataset minor: Object not found - #005: (file name) line (number) in H5G_loc_find(): can't find object + #006: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G_traverse(): internal path traversal failed + #007: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #007: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #008: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #008: (file name) line (number) in H5G__loc_find_cb(): object 'dset3' doesn't exist + #009: (file name) line (number) in H5G__loc_find_cb(): object 'dset3' doesn't exist major: Symbol table minor: Object not found HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Lget_info(): unable to get link info + #000: (file name) line (number) in H5Lget_info2(): unable to get link info major: Links minor: Can't get value #001: (file name) line (number) in H5VL_link_get(): link get failed diff --git a/tools/test/h5dump/errfiles/textlink.err b/tools/test/h5dump/errfiles/textlink.err index 3f77f38..04b129c 100644 --- a/tools/test/h5dump/errfiles/textlink.err +++ b/tools/test/h5dump/errfiles/textlink.err @@ -1,68 +1,74 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object + #000: (file name) line (number) in H5Oopen(): unable to synchronously open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): object open failed + #001: (file name) line (number) in H5O__open_api_common(): unable to open object + major: Object header + minor: Can't open object + #002: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL__object_open(): object open failed + #003: (file name) line (number) in H5VL__object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name + #004: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #004: (file name) line (number) in H5O_open_name(): object not found + #005: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #005: (file name) line (number) in H5G_loc_find(): can't find object + #006: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G_traverse(): internal path traversal failed + #007: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #008: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #009: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #010: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) - #010: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'filename' + minor: Unable to find ID information (already closed?) + #011: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'filename' major: Links minor: Unable to open file HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object + #000: (file name) line (number) in H5Oopen(): unable to synchronously open object + major: Object header + minor: Can't open object + #001: (file name) line (number) in H5O__open_api_common(): unable to open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): object open failed + #002: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL__object_open(): object open failed + #003: (file name) line (number) in H5VL__object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name + #004: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #004: (file name) line (number) in H5O_open_name(): object not found + #005: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #005: (file name) line (number) in H5G_loc_find(): can't find object + #006: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G_traverse(): internal path traversal failed + #007: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #008: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #009: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #010: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) - #010: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'anotherfile' + minor: Unable to find ID information (already closed?) + #011: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'anotherfile' major: Links minor: Unable to open file diff --git a/tools/test/h5dump/errfiles/textlinkfar.err b/tools/test/h5dump/errfiles/textlinkfar.err index 8245291..e5b81ce 100644 --- a/tools/test/h5dump/errfiles/textlinkfar.err +++ b/tools/test/h5dump/errfiles/textlinkfar.err @@ -1,59 +1,62 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object + #000: (file name) line (number) in H5Oopen(): unable to synchronously open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): object open failed + #001: (file name) line (number) in H5O__open_api_common(): unable to open object + major: Object header + minor: Can't open object + #002: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL__object_open(): object open failed + #003: (file name) line (number) in H5VL__object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name + #004: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #004: (file name) line (number) in H5O_open_name(): object not found + #005: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #005: (file name) line (number) in H5G_loc_find(): can't find object + #006: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G_traverse(): internal path traversal failed + #007: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #008: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #009: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #010: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) - #010: (file name) line (number) in H5L__extern_traverse(): unable to open object + minor: Unable to find ID information (already closed?) + #011: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object - #011: (file name) line (number) in H5O_open_name(): object not found + #012: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #012: (file name) line (number) in H5G_loc_find(): can't find object + #013: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #013: (file name) line (number) in H5G_traverse(): internal path traversal failed + #014: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #014: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #015: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #015: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed + #016: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed major: Links minor: Link traversal failure - #016: (file name) line (number) in H5G__traverse_slink(): unable to follow symbolic link + #017: (file name) line (number) in H5G__traverse_slink(): unable to follow symbolic link major: Symbol table minor: Object not found - #017: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #018: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #018: (file name) line (number) in H5G__traverse_slink_cb(): component not found + #019: (file name) line (number) in H5G__traverse_slink_cb(): component not found major: Symbol table minor: Object not found HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): @@ -71,7 +74,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Link traversal failure #004: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) + minor: Unable to find ID information (already closed?) #005: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object @@ -92,7 +95,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Link traversal failure #011: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) + minor: Unable to find ID information (already closed?) #012: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object @@ -113,7 +116,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Link traversal failure #018: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) + minor: Unable to find ID information (already closed?) #019: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object @@ -134,7 +137,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Link traversal failure #025: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) + minor: Unable to find ID information (already closed?) #026: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object @@ -168,7 +171,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Link traversal failure #004: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) + minor: Unable to find ID information (already closed?) #005: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object @@ -189,7 +192,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Link traversal failure #011: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) + minor: Unable to find ID information (already closed?) #012: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object @@ -210,7 +213,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Link traversal failure #018: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) + minor: Unable to find ID information (already closed?) #019: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object @@ -231,7 +234,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Link traversal failure #025: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) + minor: Unable to find ID information (already closed?) #026: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object diff --git a/tools/test/h5dump/errfiles/textlinksrc.err b/tools/test/h5dump/errfiles/textlinksrc.err index 8245291..e5b81ce 100644 --- a/tools/test/h5dump/errfiles/textlinksrc.err +++ b/tools/test/h5dump/errfiles/textlinksrc.err @@ -1,59 +1,62 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object + #000: (file name) line (number) in H5Oopen(): unable to synchronously open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): object open failed + #001: (file name) line (number) in H5O__open_api_common(): unable to open object + major: Object header + minor: Can't open object + #002: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL__object_open(): object open failed + #003: (file name) line (number) in H5VL__object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name + #004: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #004: (file name) line (number) in H5O_open_name(): object not found + #005: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #005: (file name) line (number) in H5G_loc_find(): can't find object + #006: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G_traverse(): internal path traversal failed + #007: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #008: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #009: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #010: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) - #010: (file name) line (number) in H5L__extern_traverse(): unable to open object + minor: Unable to find ID information (already closed?) + #011: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object - #011: (file name) line (number) in H5O_open_name(): object not found + #012: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #012: (file name) line (number) in H5G_loc_find(): can't find object + #013: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #013: (file name) line (number) in H5G_traverse(): internal path traversal failed + #014: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #014: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #015: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #015: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed + #016: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed major: Links minor: Link traversal failure - #016: (file name) line (number) in H5G__traverse_slink(): unable to follow symbolic link + #017: (file name) line (number) in H5G__traverse_slink(): unable to follow symbolic link major: Symbol table minor: Object not found - #017: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #018: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #018: (file name) line (number) in H5G__traverse_slink_cb(): component not found + #019: (file name) line (number) in H5G__traverse_slink_cb(): component not found major: Symbol table minor: Object not found HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): @@ -71,7 +74,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Link traversal failure #004: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) + minor: Unable to find ID information (already closed?) #005: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object @@ -92,7 +95,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Link traversal failure #011: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) + minor: Unable to find ID information (already closed?) #012: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object @@ -113,7 +116,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Link traversal failure #018: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) + minor: Unable to find ID information (already closed?) #019: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object @@ -134,7 +137,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Link traversal failure #025: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) + minor: Unable to find ID information (already closed?) #026: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object @@ -168,7 +171,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Link traversal failure #004: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) + minor: Unable to find ID information (already closed?) #005: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object @@ -189,7 +192,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Link traversal failure #011: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) + minor: Unable to find ID information (already closed?) #012: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object @@ -210,7 +213,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Link traversal failure #018: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) + minor: Unable to find ID information (already closed?) #019: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object @@ -231,7 +234,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Link traversal failure #025: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) + minor: Unable to find ID information (already closed?) #026: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object diff --git a/tools/test/h5dump/errfiles/tgroup-2.err b/tools/test/h5dump/errfiles/tgroup-2.err index 27557f3..f9fa0cf 100644 --- a/tools/test/h5dump/errfiles/tgroup-2.err +++ b/tools/test/h5dump/errfiles/tgroup-2.err @@ -1,29 +1,32 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Gopen2(): unable to open group + #000: (file name) line (number) in H5Gopen2(): unable to synchronously open group + major: Symbol table + minor: Unable to create file + #001: (file name) line (number) in H5G__open_api_common(): unable to open group major: Symbol table minor: Can't open object - #001: (file name) line (number) in H5VL_group_open(): group open failed + #002: (file name) line (number) in H5VL_group_open(): group open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL__group_open(): group open failed + #003: (file name) line (number) in H5VL__group_open(): group open failed major: Virtual Object Layer minor: Can't open object - #003: (file name) line (number) in H5VL__native_group_open(): unable to open group + #004: (file name) line (number) in H5VL__native_group_open(): unable to open group major: Symbol table minor: Can't open object - #004: (file name) line (number) in H5G__open_name(): group not found + #005: (file name) line (number) in H5G__open_name(): group not found major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G_loc_find(): can't find object + #006: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G_traverse(): internal path traversal failed + #007: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #007: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #008: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #008: (file name) line (number) in H5G__loc_find_cb(): object 'y' doesn't exist + #009: (file name) line (number) in H5G__loc_find_cb(): object 'y' doesn't exist major: Symbol table minor: Object not found h5dump error: unable to open group "/y" diff --git a/tools/test/h5dump/errfiles/torderlinks1.err b/tools/test/h5dump/errfiles/torderlinks1.err index caeef27..182fc31 100644 --- a/tools/test/h5dump/errfiles/torderlinks1.err +++ b/tools/test/h5dump/errfiles/torderlinks1.err @@ -1,34 +1,37 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object + #000: (file name) line (number) in H5Oopen(): unable to synchronously open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): object open failed + #001: (file name) line (number) in H5O__open_api_common(): unable to open object + major: Object header + minor: Can't open object + #002: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL__object_open(): object open failed + #003: (file name) line (number) in H5VL__object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name + #004: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #004: (file name) line (number) in H5O_open_name(): object not found + #005: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #005: (file name) line (number) in H5G_loc_find(): can't find object + #006: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G_traverse(): internal path traversal failed + #007: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #008: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #009: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #010: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) - #010: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'fname' + minor: Unable to find ID information (already closed?) + #011: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'fname' major: Links minor: Unable to open file diff --git a/tools/test/h5dump/errfiles/torderlinks2.err b/tools/test/h5dump/errfiles/torderlinks2.err index caeef27..182fc31 100644 --- a/tools/test/h5dump/errfiles/torderlinks2.err +++ b/tools/test/h5dump/errfiles/torderlinks2.err @@ -1,34 +1,37 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object + #000: (file name) line (number) in H5Oopen(): unable to synchronously open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): object open failed + #001: (file name) line (number) in H5O__open_api_common(): unable to open object + major: Object header + minor: Can't open object + #002: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL__object_open(): object open failed + #003: (file name) line (number) in H5VL__object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name + #004: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #004: (file name) line (number) in H5O_open_name(): object not found + #005: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #005: (file name) line (number) in H5G_loc_find(): can't find object + #006: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G_traverse(): internal path traversal failed + #007: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #008: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #009: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #010: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table - minor: Unable to find atom information (already closed?) - #010: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'fname' + minor: Unable to find ID information (already closed?) + #011: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'fname' major: Links minor: Unable to open file diff --git a/tools/test/h5dump/errfiles/tperror.err b/tools/test/h5dump/errfiles/tperror.err index b0b908b..9e7972a 100644 --- a/tools/test/h5dump/errfiles/tperror.err +++ b/tools/test/h5dump/errfiles/tperror.err @@ -1,33 +1,36 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dopen2(): unable to open dataset + #000: (file name) line (number) in H5Dopen2(): unable to synchronously open dataset major: Dataset minor: Can't open object - #001: (file name) line (number) in H5VL_dataset_open(): dataset open failed + #001: (file name) line (number) in H5D__open_api_common(): unable to open dataset + major: Dataset + minor: Can't open object + #002: (file name) line (number) in H5VL_dataset_open(): dataset open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL__dataset_open(): dataset open failed + #003: (file name) line (number) in H5VL__dataset_open(): dataset open failed major: Virtual Object Layer minor: Can't open object - #003: (file name) line (number) in H5VL__native_dataset_open(): unable to open dataset + #004: (file name) line (number) in H5VL__native_dataset_open(): unable to open dataset major: Dataset minor: Can't open object - #004: (file name) line (number) in H5D__open_name(): not found + #005: (file name) line (number) in H5D__open_name(): not found major: Dataset minor: Object not found - #005: (file name) line (number) in H5G_loc_find(): can't find object + #006: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G_traverse(): internal path traversal failed + #007: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #007: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #008: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #008: (file name) line (number) in H5G__loc_find_cb(): object 'bogus' doesn't exist + #009: (file name) line (number) in H5G__loc_find_cb(): object 'bogus' doesn't exist major: Symbol table minor: Object not found HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Lget_info(): unable to get link info + #000: (file name) line (number) in H5Lget_info2(): unable to get link info major: Links minor: Can't get value #001: (file name) line (number) in H5VL_link_get(): link get failed diff --git a/tools/test/h5dump/errfiles/tqmarkfile.err b/tools/test/h5dump/errfiles/tqmarkfile.err index 2c4f1ff..4c3b2ef 100644 --- a/tools/test/h5dump/errfiles/tqmarkfile.err +++ b/tools/test/h5dump/errfiles/tqmarkfile.err @@ -15,7 +15,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): major: Symbol table minor: Object not found HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Lget_info(): unable to get link info + #000: (file name) line (number) in H5Lget_info2(): unable to get link info major: Symbol table minor: Object not found #001: (file name) line (number) in H5L_get_info(): name doesn't exist diff --git a/tools/test/h5dump/errfiles/tslink-D.err b/tools/test/h5dump/errfiles/tslink-D.err index e650a33..f465f29 100644 --- a/tools/test/h5dump/errfiles/tslink-D.err +++ b/tools/test/h5dump/errfiles/tslink-D.err @@ -1,37 +1,40 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dopen2(): unable to open dataset + #000: (file name) line (number) in H5Dopen2(): unable to synchronously open dataset major: Dataset minor: Can't open object - #001: (file name) line (number) in H5VL_dataset_open(): dataset open failed + #001: (file name) line (number) in H5D__open_api_common(): unable to open dataset + major: Dataset + minor: Can't open object + #002: (file name) line (number) in H5VL_dataset_open(): dataset open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL__dataset_open(): dataset open failed + #003: (file name) line (number) in H5VL__dataset_open(): dataset open failed major: Virtual Object Layer minor: Can't open object - #003: (file name) line (number) in H5VL__native_dataset_open(): unable to open dataset + #004: (file name) line (number) in H5VL__native_dataset_open(): unable to open dataset major: Dataset minor: Can't open object - #004: (file name) line (number) in H5D__open_name(): not found + #005: (file name) line (number) in H5D__open_name(): not found major: Dataset minor: Object not found - #005: (file name) line (number) in H5G_loc_find(): can't find object + #006: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G_traverse(): internal path traversal failed + #007: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #008: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed + #009: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed major: Links minor: Link traversal failure - #009: (file name) line (number) in H5G__traverse_slink(): unable to follow symbolic link + #010: (file name) line (number) in H5G__traverse_slink(): unable to follow symbolic link major: Symbol table minor: Object not found - #010: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #011: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #011: (file name) line (number) in H5G__traverse_slink_cb(): component not found + #012: (file name) line (number) in H5G__traverse_slink_cb(): component not found major: Symbol table minor: Object not found diff --git a/tools/test/h5dump/h5dump_plugin.sh.in b/tools/test/h5dump/h5dump_plugin.sh.in index 6a00a16..a552f60 100644 --- a/tools/test/h5dump/h5dump_plugin.sh.in +++ b/tools/test/h5dump/h5dump_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. # @@ -181,8 +181,8 @@ TOOLTEST() { # Run test. TESTING $H5DUMP $@ ( - cd $TESTDIR - $ENVCMD $RUNSERIAL $H5DUMP_BIN "$@" + cd $TESTDIR + $ENVCMD $RUNSERIAL $H5DUMP_BIN "$@" ) >$actual 2>$actual_err # save actual and actual_err in case they are needed later. @@ -192,24 +192,24 @@ TOOLTEST() { STDERR_FILTER $actual_err cat $actual_err >> $actual - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.ddl) missing" - nerrors="`expr $nerrors + 1`" + if [ ! -f $expect ]; then + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + echo " Expected result (*.ddl) missing" + nerrors="`expr $nerrors + 1`" elif $CMP $expect $actual > /dev/null 2>&1 ; then - echo " PASSED" + echo " PASSED" else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $caseless $expect $actual |sed 's/^/ /' + echo "*FAILED*" + echo " Expected result (*.ddl) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $caseless $expect $actual |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav $actual_ext + rm -f $actual $actual_err $actual_sav $actual_err_sav $actual_ext fi } diff --git a/tools/test/h5dump/h5dumpgentest.c b/tools/test/h5dump/h5dumpgentest.c index 35c3e3c..339b563 100644 --- a/tools/test/h5dump/h5dumpgentest.c +++ b/tools/test/h5dump/h5dumpgentest.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,99 +22,101 @@ */ #include "hdf5.h" -#include "H5private.h" +#include "h5test.h" #include "h5tools.h" -#define FILE1 "tgroup.h5" -#define FILE2 "tdset.h5" -#define FILE3 "tattr.h5" -#define FILE4 "tslink.h5" -#define FILE4_1 "tsoftlinks.h5" -#define FILE5 "thlink.h5" -#define FILE6 "tcompound.h5" -#define FILE7 "tall.h5" -#define FILE8 "tdset2.h5" -#define FILE9 "tcompound2.h5" -#define FILE10 "tloop.h5" -#define FILE11 "tloop2.h5" -#define FILE12 "tmany.h5" -#define FILE13 "tstr.h5" -#define FILE14 "tstr2.h5" -#define FILE15 "tenum.h5" -#define FILE16 "tobjref.h5" -#define FILE17 "tdatareg.h5" -#define FILE18 "tnestedcomp.h5" -#define FILE19 "topaque.h5" -#define FILE20 "tbitfields.h5" -#define FILE21 "tvldtypes1.h5" -#define FILE22 "tvldtypes2.h5" -#define FILE23 "tvldtypes3.h5" -#define FILE24 "tvldtypes4.h5" -#define FILE25 "tarray1.h5" +#define FILE1 "tgroup.h5" +#define FILE2 "tdset.h5" +#define FILE3 "tattr.h5" +#define FILE4 "tslink.h5" +#define FILE4_1 "tsoftlinks.h5" +#define FILE5 "thlink.h5" +#define FILE6 "tcompound.h5" +#define FILE7 "tall.h5" +#define FILE8 "tdset2.h5" +#define FILE9 "tcompound2.h5" +#define FILE10 "tloop.h5" +#define FILE11 "tloop2.h5" +#define FILE12 "tmany.h5" +#define FILE13 "tstr.h5" +#define FILE14 "tstr2.h5" +#define FILE15 "tenum.h5" +#define FILE16 "tobjref.h5" +#define FILE17 "tdatareg.h5" +#define FILE18 "tnestedcomp.h5" +#define FILE19 "topaque.h5" +#define FILE20 "tbitfields.h5" +#define FILE21 "tvldtypes1.h5" +#define FILE22 "tvldtypes2.h5" +#define FILE23 "tvldtypes3.h5" +#define FILE24 "tvldtypes4.h5" +#define FILE25 "tarray1.h5" #define FILE25_BIG "tarray1_big.h5" -#define FILE26 "tarray2.h5" -#define FILE27 "tarray3.h5" -#define FILE28 "tarray4.h5" -#define FILE29 "tarray5.h5" -#define FILE30 "tarray6.h5" -#define FILE31 "tarray7.h5" -#define FILE32 "tempty.h5" -#define FILE33 "tgrp_comments.h5" -#define FILE34 "tsplit_file" -#define FILE35 "tfamily%05d.h5" -#define FILE36 "tmulti" -#define FILE37 "tlarge_objname.h5" -#define FILE38 "tvlstr.h5" -#define FILE39 "tchar.h5" -#define FILE40 "tattr2.h5" -#define FILE41 "tcompound_complex.h5" -#define FILE42 "tnamed_dtype_attr.h5" -#define FILE43 "tvldtypes5.h5" -#define FILE44 "tfilters.h5" -#define FILE45 "tnullspace.h5" -#define FILE46 "tfcontents1.h5" -#define FILE47 "tfcontents2.h5" -#define FILE48 "tfvalues.h5" -#define FILE49 "tstr3.h5" -#define FILE50 "taindices.h5" -#define FILE51 "tlonglinks.h5" -#define FILE52 "tldouble.h5" -#define FILE53 "textlink.h5" -#define FILE54 "tudlink.h5" -#define FILE55 "tbinary.h5" -#define FILE56 "tbigdims.h5" -#define FILE57 "thyperslab.h5" -#define FILE58 "tordergr.h5" -#define FILE59 "torderattr.h5" -#define FILE60 "tfpformat.h5" -#define FILE61 "textlinksrc.h5" -#define FILE62 "textlinktar.h5" -#define FILE63 "textlinkfar.h5" -#define FILE64 "tattrreg.h5" -#define FILE65 "file_space.h5" -#define FILE66 "packedbits.h5" -#define FILE67 "zerodim.h5" -#define FILE68 "charsets.h5" -#define FILE68a "tdset_idx.h5" -#define FILE69 "tattrintsize.h5" -#define FILE70 "tcmpdintsize.h5" -#define FILE71 "tcmpdattrintsize.h5" -#define FILE72 "tnestedcmpddt.h5" -#define FILE73 "tscalarintsize.h5" -#define FILE74 "tscalarattrintsize.h5" -#define FILE75 "tscalarstring.h5" -#define FILE76 "tcmpdintarray.h5" -#define FILE77 "tcmpdints.h5" -#define FILE78 "tscalarintattrsize.h5" -#define FILE79 "tintsattrs.h5" -#define FILE80 "tbitnopaque.h5" -#define FILE81 "tints4dims.h5" -#define FILE82 "tcompound_complex2.h5" -#define FILE83 "tvlenstr_array.h5" -#define FILE84 "tudfilter.h5" -#define FILE85 "tgrpnullspace.h5" -#define FILE86 "err_attr_dspace.h5" -#define FILE87 "tintsnodata.h5" +#define FILE26 "tarray2.h5" +#define FILE27 "tarray3.h5" +#define FILE28 "tarray4.h5" +#define FILE29 "tarray5.h5" +#define FILE30 "tarray6.h5" +#define FILE31 "tarray7.h5" +#define FILE32 "tempty.h5" +#define FILE33 "tgrp_comments.h5" +#define FILE34 "tsplit_file" +#define FILE35 "tfamily%05d.h5" +#define FILE36 "tmulti" +#define FILE37 "tlarge_objname.h5" +#define FILE38 "tvlstr.h5" +#define FILE39 "tchar.h5" +#define FILE40 "tattr2.h5" +#define FILE41 "tcompound_complex.h5" +#define FILE42 "tnamed_dtype_attr.h5" +#define FILE43 "tvldtypes5.h5" +#define FILE44 "tfilters.h5" +#define FILE45 "tnullspace.h5" +#define FILE46 "tfcontents1.h5" +#define FILE47 "tfcontents2.h5" +#define FILE48 "tfvalues.h5" +#define FILE49 "tstr3.h5" +#define FILE50 "taindices.h5" +#define FILE51 "tlonglinks.h5" +#define FILE52 "tldouble.h5" +#define FILE53 "textlink.h5" +#define FILE54 "tudlink.h5" +#define FILE55 "tbinary.h5" +#define FILE56 "tbigdims.h5" +#define FILE57 "thyperslab.h5" +#define FILE58 "tordergr.h5" +#define FILE59 "torderattr.h5" +#define FILE60 "tfpformat.h5" +#define FILE61 "textlinksrc.h5" +#define FILE62 "textlinktar.h5" +#define FILE63 "textlinkfar.h5" +#define FILE64 "tattrreg.h5" +#define FILE65 "file_space.h5" +#define FILE66 "packedbits.h5" +#define FILE67 "zerodim.h5" +#define FILE68 "charsets.h5" +#define FILE68a "tdset_idx.h5" +#define FILE69 "tattrintsize.h5" +#define FILE70 "tcmpdintsize.h5" +#define FILE71 "tcmpdattrintsize.h5" +#define FILE72 "tnestedcmpddt.h5" +#define FILE73 "tscalarintsize.h5" +#define FILE74 "tscalarattrintsize.h5" +#define FILE75 "tscalarstring.h5" +#define FILE76 "tcmpdintarray.h5" +#define FILE77 "tcmpdints.h5" +#define FILE78 "tscalarintattrsize.h5" +#define FILE79 "tintsattrs.h5" +#define FILE80 "tbitnopaque.h5" +#define FILE81 "tints4dims.h5" +#define FILE82 "tcompound_complex2.h5" +#define FILE83 "tvlenstr_array.h5" +#define FILE84 "tudfilter.h5" +#define FILE85 "tgrpnullspace.h5" +#define FILE86 "err_attr_dspace.h5" +#define FILE87 "tintsnodata.h5" +#define FILE88 "tldouble_scalar.h5" +#define FILE89 "tfloatsattrs.h5" /*------------------------------------------------------------------------- * prototypes @@ -122,60 +124,51 @@ */ /* utility functions */ -static int -make_dset(hid_t loc_id, const char *name, hid_t sid, hid_t tid, hid_t dcpl, void *buf); -static int -write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, - hid_t tid, void *buf); -static int -write_dset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, - hid_t tid, void *buf ); +static int make_dset(hid_t loc_id, const char *name, hid_t sid, hid_t tid, hid_t dcpl, void *buf); +static int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, hid_t tid, void *buf); +static int write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, hid_t tid, void *buf); /* a filter operation callback function */ -static size_t -myfilter(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf); +static size_t myfilter(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, + const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, + size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf); /* a "set local" callback */ -static herr_t -set_local_myfilter(hid_t dcpl_id, hid_t tid, hid_t H5_ATTR_UNUSED sid); +static herr_t set_local_myfilter(hid_t dcpl_id, hid_t tid, hid_t H5_ATTR_UNUSED sid); #define MYFILTER_ID 405 /* This message derives from H5Z */ const H5Z_class2_t H5Z_MYFILTER[1] = {{ - H5Z_CLASS_T_VERS, - MYFILTER_ID, /* Filter id number */ - 1, 1, - "myfilter", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - set_local_myfilter, /* The "set local" callback */ - myfilter, /* The actual filter function */ + H5Z_CLASS_T_VERS, MYFILTER_ID, /* Filter id number */ + 1, 1, "myfilter", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + set_local_myfilter, /* The "set local" callback */ + myfilter, /* The actual filter function */ }}; -#define H5Z_FILTER_DYNLIBUD 300 -#define MULTIPLIER 3 +#define H5Z_FILTER_DYNLIBUD 300 +#define MULTIPLIER 3 -static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_DYNLIBUD[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_DYNLIBUD, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "dynlibud", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_DYNLIBUD, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "dynlibud", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + H5Z_filter_dynlibud, /* The actual filter function */ }}; - /* A UD link traversal function. Shouldn't actually be called. */ -static hid_t UD_traverse(H5_ATTR_UNUSED const char * link_name, H5_ATTR_UNUSED hid_t cur_group, - H5_ATTR_UNUSED const void * udata, H5_ATTR_UNUSED size_t udata_size, H5_ATTR_UNUSED hid_t lapl_id, - H5_ATTR_UNUSED hid_t dxpl_id) +static hid_t +UD_traverse(H5_ATTR_UNUSED const char *link_name, H5_ATTR_UNUSED hid_t cur_group, + H5_ATTR_UNUSED const void *udata, H5_ATTR_UNUSED size_t udata_size, H5_ATTR_UNUSED hid_t lapl_id, + H5_ATTR_UNUSED hid_t dxpl_id) { return -1; } @@ -183,20 +176,19 @@ static hid_t UD_traverse(H5_ATTR_UNUSED const char * link_name, H5_ATTR_UNUSED h #define MY_LINKCLASS 187 const H5L_class_t UD_link_class[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)MY_LINKCLASS, /* Link type id number */ - "UD link class", /* name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move/rename callback */ - NULL, /* Copy callback */ - UD_traverse, /* The actual traversal function */ - NULL, /* Deletion callback */ - NULL /* Query callback */ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + (H5L_type_t)MY_LINKCLASS, /* Link type id number */ + "UD link class", /* name for debugging */ + NULL, /* Creation callback */ + NULL, /* Move/rename callback */ + NULL, /* Copy callback */ + UD_traverse, /* The actual traversal function */ + NULL, /* Deletion callback */ + NULL /* Query callback */ }}; - #define LENSTR 50 -#define LENSTR2 11 +#define LENSTR2 11 #define SPACE2_RANK 2 #define SPACE2_DIM1 10 @@ -207,8 +199,8 @@ const H5L_class_t UD_link_class[1] = {{ #define DIM1 20 #define DIM2 10 -#define CDIM1 DIM1/2 -#define CDIM2 DIM2/2 +#define CDIM1 (DIM1 / 2) +#define CDIM2 (DIM2 / 2) #define RANK 2 /* Dataspace of 0 dimension size */ @@ -219,22 +211,15 @@ const H5L_class_t UD_link_class[1] = {{ /* Element selection information */ #define POINT1_NPOINTS 10 -typedef enum{ - RED, - GREEN, - BLUE, - WHITE, - BLACK -} enumtype; +typedef enum { RED, GREEN, BLUE, WHITE, BLACK } enumtype; /* Compound datatype */ typedef struct s1_t { - unsigned int a; - unsigned int b; - float c; + unsigned int a; + unsigned int b; + float c; } s1_t; - /* 1-D array datatype */ #define ARRAY1_RANK 1 #define ARRAY1_DIM1 4 @@ -251,22 +236,22 @@ typedef struct s1_t { #define ARRAY3_DIM2 3 /* VL string datatype name */ -/* TODO remove complier error not used, remove the link when everything is OK */ +/* TODO remove compiler error not used, remove the link when everything is OK */ /* #define VLSTR_TYPE "vl_string_type" */ /* "File 41" macros */ /* Name of dataset to create in datafile */ -#define F41_DATASETNAME "CompoundComplex" +#define F41_DATASETNAME "CompoundComplex" /* Dataset dimensions */ -#define F41_LENGTH 6 -#define F41_RANK 1 -#define F41_ARRAY_RANK 1 -#define F41_ARRAY_RANKd 2 -#define F41_DIMb 4 -#define F41_ARRAY_DIMc 6 -#define F41_ARRAY_DIMd1 5 -#define F41_ARRAY_DIMd2 6 -#define F41_ARRAY_DIMf 10 +#define F41_LENGTH 6 +#define F41_RANK 1 +#define F41_ARRAY_RANK 1 +#define F41_ARRAY_RANKd 2 +#define F41_DIMb 4 +#define F41_ARRAY_DIMc 6 +#define F41_ARRAY_DIMd1 5 +#define F41_ARRAY_DIMd2 6 +#define F41_ARRAY_DIMf 10 /* "File 42" macros */ /* Name of dataset to create in datafile */ @@ -280,113 +265,113 @@ typedef struct s1_t { #define F43_DSETNAME "Dataset" /* "File 51" macros */ -#define F51_MAX_NAME_LEN ((64*1024)+1024) +#define F51_MAX_NAME_LEN ((64 * 1024) + 1024) /* "File 64" macros */ -#define F64_FILE "tarray8.h5" -#define F64_DATASET "DS1" -#define F64_DIM0 1 -#define F64_ARRAY_BUF_LEN (4*1024) -#define F64_DIM1 (F64_ARRAY_BUF_LEN / sizeof(int) + 1) +#define F64_FILE "tarray8.h5" +#define F64_DATASET "DS1" +#define F64_DIM0 1 +#define F64_ARRAY_BUF_LEN (4 * 1024) +#define F64_DIM1 (F64_ARRAY_BUF_LEN / sizeof(int) + 1) /* File 65 macros */ -#define STRATEGY H5F_FSPACE_STRATEGY_NONE /* File space handling strategy */ -#define THRESHOLD10 10 /* Free-space section threshold */ -#define FSPACE_PAGE_SIZE 8192 /* File space page size */ +#define STRATEGY H5F_FSPACE_STRATEGY_NONE /* File space handling strategy */ +#define THRESHOLD10 10 /* Free-space section threshold */ +#define FSPACE_PAGE_SIZE 8192 /* File space page size */ /* "FILE66" macros and for FILE69, FILE87 */ -#define F66_XDIM 8 -#define F66_DATASETU08 "DU08BITS" -#define F66_DATASETS08 "DS08BITS" -#define F66_YDIM8 8 -#define F66_DATASETU16 "DU16BITS" -#define F66_DATASETS16 "DS16BITS" -#define F66_YDIM16 16 -#define F66_DATASETU32 "DU32BITS" -#define F66_DATASETS32 "DS32BITS" -#define F66_YDIM32 32 -#define F66_DATASETU64 "DU64BITS" -#define F66_DATASETS64 "DS64BITS" -#define F66_YDIM64 64 -#define F66_DUMMYDBL "DummyDBL" +#define F66_XDIM 8 +#define F66_DATASETU08 "DU08BITS" +#define F66_DATASETS08 "DS08BITS" +#define F66_YDIM8 8 +#define F66_DATASETU16 "DU16BITS" +#define F66_DATASETS16 "DS16BITS" +#define F66_YDIM16 16 +#define F66_DATASETU32 "DU32BITS" +#define F66_DATASETS32 "DS32BITS" +#define F66_YDIM32 32 +#define F66_DATASETU64 "DU64BITS" +#define F66_DATASETS64 "DS64BITS" +#define F66_YDIM64 64 +#define F66_DUMMYDBL "DummyDBL" /* Declarations for gent_dataset_idx() for "FILE68a" */ #define F68a_DSET_FIXED "dset_fixed" -#define F68a_DSET_FIXED_FILTER "dset_filter" +#define F68a_DSET_FIXED_FILTER "dset_filter" #define F68a_DSET_BTREE "dset_btree" -#define F68a_DIM200 200 -#define F68a_DIM100 100 -#define F68a_DIM20 20 -#define F68a_DIM10 10 -#define F68a_CHUNK 5 +#define F68a_DIM200 200 +#define F68a_DIM100 100 +#define F68a_DIM20 20 +#define F68a_DIM10 10 +#define F68a_CHUNK 5 /* "FILE70" macros and for FILE71 */ /* Name of dataset to create in datafile */ -#define F70_DATASETNAME "CompoundIntSize" +#define F70_DATASETNAME "CompoundIntSize" #define F70_LENGTH 4 #define F70_RANK 1 #define F70_ARRAY_RANK 2 #define F70_XDIM 8 -#define F70_DATASETU08 "DU08BITS" -#define F70_DATASETS08 "DS08BITS" +#define F70_DATASETU08 "DU08BITS" +#define F70_DATASETS08 "DS08BITS" #define F70_YDIM8 8 -#define F70_DATASETU16 "DU16BITS" -#define F70_DATASETS16 "DS16BITS" +#define F70_DATASETU16 "DU16BITS" +#define F70_DATASETS16 "DS16BITS" #define F70_YDIM16 16 -#define F70_DATASETU32 "DU32BITS" -#define F70_DATASETS32 "DS32BITS" +#define F70_DATASETU32 "DU32BITS" +#define F70_DATASETS32 "DS32BITS" #define F70_YDIM32 32 -#define F70_DATASETU64 "DU64BITS" -#define F70_DATASETS64 "DS64BITS" +#define F70_DATASETU64 "DU64BITS" +#define F70_DATASETS64 "DS64BITS" #define F70_YDIM64 64 -#define F70_DUMMYDBL "DummyDBL" +#define F70_DUMMYDBL "DummyDBL" /* Name of dataset to create in datafile */ -#define F71_DATASETNAME "CompoundAttrIntSize" +#define F71_DATASETNAME "CompoundAttrIntSize" /* "FILE73" macros and for FILE69 and FILE78 */ -#define F73_ARRAY_RANK 2 -#define F73_XDIM 8 -#define F73_DATASETU08 "DU08BITS" -#define F73_DATASETS08 "DS08BITS" -#define F73_YDIM8 8 -#define F73_DATASETU16 "DU16BITS" -#define F73_DATASETS16 "DS16BITS" -#define F73_YDIM16 16 -#define F73_DATASETU32 "DU32BITS" -#define F73_DATASETS32 "DS32BITS" -#define F73_YDIM32 32 -#define F73_DATASETU64 "DU64BITS" -#define F73_DATASETS64 "DS64BITS" -#define F73_YDIM64 64 -#define F73_DUMMYDBL "DummyDBL" +#define F73_ARRAY_RANK 2 +#define F73_XDIM 8 +#define F73_DATASETU08 "DU08BITS" +#define F73_DATASETS08 "DS08BITS" +#define F73_YDIM8 8 +#define F73_DATASETU16 "DU16BITS" +#define F73_DATASETS16 "DS16BITS" +#define F73_YDIM16 16 +#define F73_DATASETU32 "DU32BITS" +#define F73_DATASETS32 "DS32BITS" +#define F73_YDIM32 32 +#define F73_DATASETU64 "DU64BITS" +#define F73_DATASETS64 "DS64BITS" +#define F73_YDIM64 64 +#define F73_DUMMYDBL "DummyDBL" /* "FILE76 and FILE77 */ /* Name of dataset to create in datafile */ -#define F76_DATASETNAME "CompoundIntArray" +#define F76_DATASETNAME "CompoundIntArray" #define F76_LENGTH 4 #define F76_RANK 1 #define F76_ARRAY_RANK 1 -#define F76_DATASETU08 "DU08BITS" -#define F76_DATASETS08 "DS08BITS" -#define F76_DIM8 8 -#define F76_DATASETU16 "DU16BITS" -#define F76_DATASETS16 "DS16BITS" -#define F76_DIM16 16 -#define F76_DATASETU32 "DU32BITS" -#define F76_DATASETS32 "DS32BITS" -#define F76_DIM32 32 -#define F76_DATASETU64 "DU64BITS" -#define F76_DATASETS64 "DS64BITS" -#define F76_DIM64 64 -#define F76_DUMMYDBL "DummyDBL" +#define F76_DATASETU08 "DU08BITS" +#define F76_DATASETS08 "DS08BITS" +#define F76_DIM8 8 +#define F76_DATASETU16 "DU16BITS" +#define F76_DATASETS16 "DS16BITS" +#define F76_DIM16 16 +#define F76_DATASETU32 "DU32BITS" +#define F76_DATASETS32 "DS32BITS" +#define F76_DIM32 32 +#define F76_DATASETU64 "DU64BITS" +#define F76_DATASETS64 "DS64BITS" +#define F76_DIM64 64 +#define F76_DUMMYDBL "DummyDBL" /* Name of dataset to create in datafile */ -#define F77_DATASETNAME1 "CompoundInts" -#define F77_DATASETNAME2 "CompoundRInts" -#define F77_LENGTH 64 +#define F77_DATASETNAME1 "CompoundInts" +#define F77_DATASETNAME2 "CompoundRInts" +#define F77_LENGTH 64 -#define F80_DIM32 32 +#define F80_DIM32 32 -#define F81_DATASETNAME "FourDimInts" +#define F81_DATASETNAME "FourDimInts" #define F81_RANK 4 #define F81_WDIM 10 #define F81_XDIM 8 @@ -395,22 +380,31 @@ typedef struct s1_t { /* "File 82" macros */ /* Name of dataset to create in datafile */ -#define F82_DATASETNAME "CompoundComplex1D" +#define F82_DATASETNAME "CompoundComplex1D" /* Dataset dimensions */ -#define F82_DIM32 32 -#define F82_RANK 1 +#define F82_DIM32 32 +#define F82_RANK 1 /* #define F82_RANK2 2 */ /* #define F82_RANK3 3 */ /* #define F82_RANK4 4 */ /* "File 83" macros */ /* Name of dataset to create in datafile */ -#define F83_DATASETNAME "ScalarArrayOfVlenStr" -#define F83_DATASETNAME2 "CompoundArrayOfVlenStr" +#define F83_DATASETNAME "ScalarArrayOfVlenStr" +#define F83_DATASETNAME2 "CompoundArrayOfVlenStr" /* Dataset dimensions */ -#define F83_DIM 5 -#define F83_RANK 1 -#define F83_ARRAYDIM 3 +#define F83_DIM 5 +#define F83_RANK 1 +#define F83_ARRAYDIM 3 + +/* "FILE89" macros */ +#define F89_XDIM 8 +#define F89_DATASETF32 "DS32BITS" +#define F89_YDIM32 32 +#define F89_DATASETF64 "DS64BITS" +#define F89_YDIM64 64 +#define F89_DATASETF128 "DS128BITS" +#define F89_YDIM128 128 static void gent_group(void) @@ -461,66 +455,89 @@ gent_group(void) static void gent_dataset(void) { - hid_t fid, dataset, space; - hsize_t dims[2]; - int dset1[10][20]; - double dset2[30][20]; - int i, j; + hid_t fid, dataset, space; + hsize_t dims[2]; + int ** dset1 = NULL; + int * dset1_data = NULL; + double **dset2 = NULL; + double * dset2_data = NULL; + int i, j; + + /* Set up data arrays */ + dset1_data = (int *)HDcalloc(10 * 20, sizeof(int)); + dset1 = (int **)HDcalloc(10, sizeof(dset1_data)); + for (i = 0; i < 10; i++) + dset1[i] = dset1_data + (i * 20); + + dset2_data = (double *)HDcalloc(30 * 20, sizeof(double)); + dset2 = (double **)HDcalloc(30, sizeof(dset2_data)); + for (i = 0; i < 30; i++) + dset2[i] = dset2_data + (i * 20); fid = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* dset1 */ - dims[0] = 10; dims[1] = 20; - space = H5Screate_simple(2, dims, NULL); + dims[0] = 10; + dims[1] = 20; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 20; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 20; j++) dset1[i][j] = j + i; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); + H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1_data); H5Sclose(space); H5Dclose(dataset); /* dset2 */ - dims[0] = 30; dims[1] = 20; - space = H5Screate_simple(2, dims, NULL); + dims[0] = 30; + dims[1] = 20; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, "/dset2", H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 30; i++) - for(j = 0; j < 20; j++) - dset2[i][j] = 0.0001F * (float)j + (float)i; + for (i = 0; i < 30; i++) + for (j = 0; j < 20; j++) + dset2[i][j] = 0.0001 * (double)j + (double)i; - H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); + H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_data); H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); + + HDfree(dset1); + HDfree(dset1_data); + HDfree(dset2); + HDfree(dset2_data); } static void gent_dataset2(void) { - hid_t fid, dataset, space, create_plist; + hid_t fid, dataset, space, create_plist; hsize_t dims[2]; hsize_t maxdims[2]; - int dset1[10][20]; - double dset2[30][10]; - int i, j; + int dset1[10][20]; + double dset2[30][10]; + int i, j; - fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); create_plist = H5Pcreate(H5P_DATASET_CREATE); - dims[0] = 5; dims[1] = 5; + dims[0] = 5; + dims[1] = 5; H5Pset_chunk(create_plist, 2, dims); /* dset1 */ - dims[0] = 10; dims[1] = 20; - maxdims[0] = H5S_UNLIMITED; maxdims[1] = 20; - space = H5Screate_simple(2, dims, maxdims); - dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - - for(i = 0; i < 10; i++) - for(j = 0; j < 20; j++) + dims[0] = 10; + dims[1] = 20; + maxdims[0] = H5S_UNLIMITED; + maxdims[1] = 20; + space = H5Screate_simple(2, dims, maxdims); + dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); + + for (i = 0; i < 10; i++) + for (j = 0; j < 20; j++) dset1[i][j] = j; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); @@ -528,13 +545,15 @@ gent_dataset2(void) H5Dclose(dataset); /* dset2 */ - dims[0] = 30; dims[1] = 10; - maxdims[0] = 30; maxdims[1] = H5S_UNLIMITED; - space = H5Screate_simple(2, dims, maxdims); - dataset = H5Dcreate2(fid, "/dset2", H5T_IEEE_F64BE, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - - for(i = 0; i < 30; i++) - for(j = 0; j < 10; j++) + dims[0] = 30; + dims[1] = 10; + maxdims[0] = 30; + maxdims[1] = H5S_UNLIMITED; + space = H5Screate_simple(2, dims, maxdims); + dataset = H5Dcreate2(fid, "/dset2", H5T_IEEE_F64BE, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); + + for (i = 0; i < 30; i++) + for (j = 0; j < 10; j++) dset2[i][j] = j; H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); @@ -548,21 +567,21 @@ gent_dataset2(void) static void gent_attribute(void) { - hid_t fid, root, space, attr, type; + hid_t fid, root, space, attr, type; hsize_t dims[2]; - char buf[60]; - int i, data[10]; - double d[10]; - char string[]= "string attribute"; - int point = 100; + char buf[60]; + int i, data[10]; + double d[10]; + char string[] = "string attribute"; + int point = 100; - fid = H5Fcreate(FILE3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); /* attribute 1 */ dims[0] = 24; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(root, "/attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(root, "/attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); HDsprintf(buf, "attribute of root group"); H5Awrite(attr, H5T_NATIVE_SCHAR, buf); H5Sclose(space); @@ -570,10 +589,11 @@ gent_attribute(void) /* attribute 2 */ dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(root, "attr2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(root, "attr2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) data[i] = i+1; + for (i = 0; i < 10; i++) + data[i] = i + 1; H5Awrite(attr, H5T_NATIVE_INT, data); H5Sclose(space); @@ -581,10 +601,11 @@ gent_attribute(void) /* attribute 3 */ dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(root, "attr3", H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(root, "attr3", H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) d[i] = 0.1F * (float)i; + for (i = 0; i < 10; i++) + d[i] = 0.1 * (double)i; H5Awrite(attr, H5T_NATIVE_DOUBLE, d); H5Sclose(space); @@ -592,14 +613,14 @@ gent_attribute(void) /* attribute 4 */ space = H5Screate(H5S_SCALAR); - attr = H5Acreate2(root, "attr4", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); + attr = H5Acreate2(root, "attr4", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_INT, &point); H5Sclose(space); H5Aclose(attr); /* attribute 5 */ space = H5Screate(H5S_SCALAR); - type = H5Tcopy(H5T_C_S1); + type = H5Tcopy(H5T_C_S1); H5Tset_size(type, 17); attr = H5Acreate2(root, "attr5", type, space, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, type, string); @@ -611,11 +632,12 @@ gent_attribute(void) H5Fclose(fid); } -static void gent_softlink(void) +static void +gent_softlink(void) { hid_t fid, root; - fid = H5Fcreate(FILE4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); H5Lcreate_soft("somevalue", root, "slink1", H5P_DEFAULT, H5P_DEFAULT); H5Lcreate_soft("linkvalue", root, "slink2", H5P_DEFAULT, H5P_DEFAULT); @@ -636,25 +658,25 @@ static void gent_softlink(void) *-------------------------------------------------------------------------*/ #define NX 4 #define NY 2 -static int gent_softlink2(void) +static int +gent_softlink2(void) { - hid_t fileid1 = -1; - hid_t gid1 = -1, gid2 = -1; - hid_t datatype = -1; - hid_t dset1 = -1, dset2 = -1; - hid_t dataspace = -1; - hsize_t dimsf[2]; /* dataset dimensions */ - int data1[NX][NY] = {{0,0},{1,1},{2,2},{3,3}}; - int data2[NX][NY] = {{0,0},{0,1},{0,2},{3,3}}; - herr_t status = SUCCEED; + hid_t fileid1 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID, gid2 = H5I_INVALID_HID; + hid_t datatype = H5I_INVALID_HID; + hid_t dset1 = H5I_INVALID_HID, dset2 = H5I_INVALID_HID; + hid_t dataspace = H5I_INVALID_HID; + hsize_t dimsf[2]; /* dataset dimensions */ + int data1[NX][NY] = {{0, 0}, {1, 1}, {2, 2}, {3, 3}}; + int data2[NX][NY] = {{0, 0}, {0, 1}, {0, 2}, {3, 3}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- * FILE *------------------------------------------------------------------------*/ /* Create a new file */ fileid1 = H5Fcreate(FILE4_1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if (fileid1 < 0) - { + if (fileid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", FILE4_1); status = FAIL; goto out; @@ -664,16 +686,14 @@ static int gent_softlink2(void) * Groups *------------------------------------------------------------------------*/ gid1 = H5Gcreate2(fileid1, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (gid1 < 0) - { + if (gid1 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", FILE4_1); status = FAIL; goto out; } gid2 = H5Gcreate2(fileid1, "group_empty", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (gid2 < 0) - { + if (gid2 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", FILE4_1); status = FAIL; goto out; @@ -683,9 +703,8 @@ static int gent_softlink2(void) * Named datatype *------------------------------------------------------------------------*/ datatype = H5Tcopy(H5T_NATIVE_INT); - status = H5Tcommit2(fileid1, "dtype", datatype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + status = H5Tcommit2(fileid1, "dtype", datatype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Tcommit2 failed.\n", FILE4_1); status = FAIL; goto out; @@ -698,8 +717,8 @@ static int gent_softlink2(void) * Describe the size of the array and create the data space for fixed * size dataset. */ - dimsf[0] = NX; - dimsf[1] = NY; + dimsf[0] = NX; + dimsf[1] = NY; dataspace = H5Screate_simple(2, dimsf, NULL); /* @@ -710,18 +729,15 @@ static int gent_softlink2(void) * dset1 */ /* Create a new dataset as sample object */ - dset1 = H5Dcreate2(fileid1, "/dset1", H5T_NATIVE_INT, dataspace, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (dset1 < 0) - { + dset1 = H5Dcreate2(fileid1, "/dset1", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (dset1 < 0) { HDfprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", FILE4_1); status = FAIL; goto out; } status = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", FILE4_1); status = FAIL; goto out; @@ -731,18 +747,15 @@ static int gent_softlink2(void) * dset2 */ /* Create a new dataset as sample object */ - dset2 = H5Dcreate2(fileid1, "/dset2", H5T_NATIVE_INT, dataspace, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (dset2 < 0) - { + dset2 = H5Dcreate2(fileid1, "/dset2", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (dset2 < 0) { HDfprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", FILE4_1); status = FAIL; goto out; } status = H5Dwrite(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", FILE4_1); status = FAIL; goto out; @@ -756,8 +769,7 @@ static int gent_softlink2(void) */ /* link to dset1 */ status = H5Lcreate_soft("/dset1", fileid1, "soft_dset1", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -765,8 +777,7 @@ static int gent_softlink2(void) /* link to data type */ status = H5Lcreate_soft("/dtype", fileid1, "soft_dtype", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -774,8 +785,7 @@ static int gent_softlink2(void) /* link to group1 */ status = H5Lcreate_soft("/group1", fileid1, "soft_group1", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -783,8 +793,7 @@ static int gent_softlink2(void) /* link to empty group */ status = H5Lcreate_soft("/group_empty", fileid1, "soft_empty_grp", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -792,8 +801,7 @@ static int gent_softlink2(void) /* dangling link */ status = H5Lcreate_soft("not_yet", fileid1, "soft_dangle", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -804,8 +812,7 @@ static int gent_softlink2(void) */ /* link to dset1 */ status = H5Lcreate_soft("/dset1", gid1, "soft_dset1", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -813,8 +820,7 @@ static int gent_softlink2(void) /* link to dset2 */ status = H5Lcreate_soft("/dset2", gid1, "soft_dset2", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -822,8 +828,7 @@ static int gent_softlink2(void) /* link to data type */ status = H5Lcreate_soft("/dtype", gid1, "soft_dtype", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -831,8 +836,7 @@ static int gent_softlink2(void) /* link to empty group */ status = H5Lcreate_soft("/group_empty", gid1, "soft_empty_grp", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -840,42 +844,41 @@ static int gent_softlink2(void) /* dangling link */ status = H5Lcreate_soft("not_yet", gid1, "soft_dangle", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; } - out: +out: /* * Close/release resources. */ - if(dataspace >= 0 && H5Sclose(dataspace) < 0) { + if (dataspace >= 0 && H5Sclose(dataspace) < 0) { HDfprintf(stderr, "Error: %s> H5Sclose failed.\n", FILE4_1); status = FAIL; } - if(gid1 >= 0 && H5Gclose(gid1) < 0) { + if (gid1 >= 0 && H5Gclose(gid1) < 0) { HDfprintf(stderr, "Error: %s> H5Gclose failed.\n", FILE4_1); status = FAIL; } - if(gid2 >= 0 && H5Gclose(gid2) < 0) { + if (gid2 >= 0 && H5Gclose(gid2) < 0) { HDfprintf(stderr, "Error: %s> H5Gclose failed.\n", FILE4_1); status = FAIL; } - if(datatype >= 0 && H5Tclose(datatype) < 0) { + if (datatype >= 0 && H5Tclose(datatype) < 0) { HDfprintf(stderr, "Error: %s> H5Tclose failed.\n", FILE4_1); status = FAIL; } - if(dset1 >= 0 && H5Dclose(dset1) < 0) { + if (dset1 >= 0 && H5Dclose(dset1) < 0) { HDfprintf(stderr, "Error: %s> H5Dclose failed.\n", FILE4_1); status = FAIL; } - if(dset2 >= 0 && H5Dclose(dset2) < 0) { + if (dset2 >= 0 && H5Dclose(dset2) < 0) { HDfprintf(stderr, "Error: %s> H5Dclose failed.\n", FILE4_1); status = FAIL; } - if(fileid1 >= 0 && H5Fclose(fileid1) < 0) { + if (fileid1 >= 0 && H5Fclose(fileid1) < 0) { HDfprintf(stderr, "Error: %s> H5Fclose failed.\n", FILE4_1); status = FAIL; } @@ -896,18 +899,20 @@ static int gent_softlink2(void) dset3 */ -static void gent_hardlink(void) +static void +gent_hardlink(void) { - hid_t fid, group, dataset, space; + hid_t fid, group, dataset, space; hsize_t dim = 5; - int i, dset[5]; + int i, dset[5]; fid = H5Fcreate(FILE5, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - space = H5Screate_simple(1, &dim, NULL); + space = H5Screate_simple(1, &dim, NULL); dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 5; i++) dset[i] = i; + for (i = 0; i < 5; i++) + dset[i] = i; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset); H5Sclose(space); @@ -930,7 +935,8 @@ static void gent_hardlink(void) H5Fclose(fid); } -static void gent_extlink(void) +static void +gent_extlink(void) { hid_t fid; @@ -942,10 +948,11 @@ static void gent_extlink(void) H5Fclose(fid); } -static void gent_udlink(void) +static void +gent_udlink(void) { hid_t fid; - char buf[4]; + char buf[4]; H5Lregister(UD_link_class); @@ -958,7 +965,6 @@ static void gent_udlink(void) H5Fclose(fid); } - /* / / | \ \ @@ -967,69 +973,69 @@ static void gent_udlink(void) dset2 */ -static void gent_compound_dt(void) { /* test compound data type */ +static void +gent_compound_dt(void) +{ /* test compound data type */ hid_t fid, group, dataset, space, space3, type, type2; hid_t array_dt; typedef struct { - int a; - float b; - double c; + int a; + float b; + double c; } dset1_t; dset1_t dset1[5]; typedef struct { - int a; - float b; + int a; + float b; } dset2_t; dset2_t dset2[5]; typedef struct { - int a[4]; - float b[5][6]; + int a[4]; + float b[5][6]; } dset3_t; dset3_t dset3[3][6]; typedef struct { - int a; - float b; + int a; + float b; } dset4_t; dset4_t dset4[5]; typedef struct { - int a; - float b; + int a; + float b; } dset5_t; dset5_t dset5[5]; - int i, j, k, l; + int i, j, k, l; unsigned ndims; - hsize_t dim[2]; + hsize_t dim[2]; hsize_t sdim = 5; hsize_t dset3_dim[2]; - - for(i = 0; i < (int)sdim; i++) { + for (i = 0; i < (int)sdim; i++) { dset1[i].a = i; - dset1[i].b = (float)(i*i); - dset1[i].c = (float)(1.0F/(float)(i+1)); + dset1[i].b = (float)(i * i); + dset1[i].c = (double)(1.0 / (double)(i + 1)); dset2[i].a = i; - dset2[i].b = (float)((float)i+ (float)i*0.1F); + dset2[i].b = (float)((float)i + (float)i * 0.1F); dset4[i].a = i; - dset4[i].b = (float)(i+3); + dset4[i].b = (float)(i + 3); dset5[i].a = i; - dset5[i].b = (float)((float)i*0.1F); + dset5[i].b = (float)((float)i * 0.1F); } - fid = H5Fcreate(FILE6, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); space = H5Screate_simple(1, &sdim, NULL); - type = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); + type = H5Tcreate(H5T_COMPOUND, sizeof(dset1[0])); type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset1[0])); H5Tinsert(type, "a_name", HOFFSET(dset1_t, a), H5T_STD_I32BE); H5Tinsert(type, "b_name", HOFFSET(dset1_t, b), H5T_IEEE_F32BE); @@ -1044,11 +1050,11 @@ static void gent_compound_dt(void) { /* test compound data type */ H5Dclose(dataset); /* shared data type 1 */ - type = H5Tcreate (H5T_COMPOUND, sizeof(dset2_t)); + type = H5Tcreate(H5T_COMPOUND, sizeof(dset2_t)); H5Tinsert(type, "int_name", HOFFSET(dset2_t, a), H5T_STD_I32BE); H5Tinsert(type, "float_name", HOFFSET(dset2_t, b), H5T_IEEE_F32BE); H5Tcommit2(fid, "type1", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset2_t)); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset2_t)); H5Tinsert(type2, "int_name", HOFFSET(dset2_t, a), H5T_NATIVE_INT); H5Tinsert(type2, "float_name", HOFFSET(dset2_t, b), H5T_NATIVE_FLOAT); group = H5Gcreate2(fid, "/group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -1059,12 +1065,12 @@ static void gent_compound_dt(void) { /* test compound data type */ H5Tclose(type); H5Dclose(dataset); - /* shared data type 2 */ - type = H5Tcreate (H5T_COMPOUND, sizeof(dset3_t)); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset3_t)); + type = H5Tcreate(H5T_COMPOUND, sizeof(dset3_t)); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset3_t)); - ndims = 1; dim[0] = 4; + ndims = 1; + dim[0] = 4; array_dt = H5Tarray_create2(H5T_STD_I32BE, ndims, dim); H5Tinsert(type, "int_array", HOFFSET(dset3_t, a), array_dt); @@ -1074,7 +1080,9 @@ static void gent_compound_dt(void) { /* test compound data type */ H5Tinsert(type2, "int_array", HOFFSET(dset3_t, a), array_dt); H5Tclose(array_dt); - ndims = 2; dim[0] = 5; dim[1] = 6; + ndims = 2; + dim[0] = 5; + dim[1] = 6; array_dt = H5Tarray_create2(H5T_IEEE_F32BE, ndims, dim); H5Tinsert(type, "float_array", HOFFSET(dset3_t, b), array_dt); @@ -1086,16 +1094,16 @@ static void gent_compound_dt(void) { /* test compound data type */ H5Tcommit2(fid, "type2", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - dset3_dim[0] = 3; dset3_dim[1] = 6; - space3 = H5Screate_simple(2, dset3_dim, NULL); - dataset = H5Dcreate2(group, "dset3", type, space3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < (int)dset3_dim[0]; i++) - for(j = 0; j < (int)dset3_dim[1]; j++) { - for(k = 0; k < 4; k++) + dset3_dim[0] = 3; + dset3_dim[1] = 6; + space3 = H5Screate_simple(2, dset3_dim, NULL); + dataset = H5Dcreate2(group, "dset3", type, space3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + for (i = 0; i < (int)dset3_dim[0]; i++) + for (j = 0; j < (int)dset3_dim[1]; j++) { + for (k = 0; k < 4; k++) dset3[i][j].a[k] = k + j + i; - for(k = 0; k < 5; k++) - for(l = 0; l < 6; l++) + for (k = 0; k < 5; k++) + for (l = 0; l < 6; l++) dset3[i][j].b[k][l] = (float)((k + 1) + l + j + i); } H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset3); @@ -1105,8 +1113,8 @@ static void gent_compound_dt(void) { /* test compound data type */ H5Dclose(dataset); /* shared data type 3 */ - type = H5Tcreate (H5T_COMPOUND, sizeof(dset4_t)); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset4_t)); + type = H5Tcreate(H5T_COMPOUND, sizeof(dset4_t)); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset4_t)); H5Tinsert(type, "int", HOFFSET(dset4_t, a), H5T_STD_I32BE); H5Tinsert(type, "float", HOFFSET(dset4_t, b), H5T_IEEE_F32BE); H5Tcommit2(group, "type3", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -1120,8 +1128,7 @@ static void gent_compound_dt(void) { /* test compound data type */ H5Dclose(dataset); H5Gclose(group); - - /* unamed data type */ + /* unnamed data type */ group = H5Gcreate2(fid, "/group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); type = H5Tcreate(H5T_COMPOUND, sizeof(dset5_t)); @@ -1153,51 +1160,53 @@ static void gent_compound_dt(void) { /* test compound data type */ dset2 */ -static void gent_compound_dt2(void) { /* test compound data type */ +static void +gent_compound_dt2(void) +{ /* test compound data type */ hid_t fid, group, dataset, space, type, create_plist, type2; hid_t array_dt; typedef struct { - int a; - float b; - double c; + int a; + float b; + double c; } dset1_t; dset1_t dset1[10]; typedef struct { - int a; - float b; + int a; + float b; } dset2_t; dset2_t dset2[10]; typedef struct { - int a[4]; - float b[5][6]; + int a[4]; + float b[5][6]; } dset3_t; typedef struct { - int a; - float b; + int a; + float b; } dset4_t; dset4_t dset4[10]; typedef struct { - int a; - float b; + int a; + float b; } dset5_t; dset5_t dset5[10]; - int i; + int i; unsigned ndims; - hsize_t dim[2]; + hsize_t dim[2]; hsize_t sdim, maxdim; sdim = 10; - for(i = 0; i < (int)sdim; i++) { + for (i = 0; i < (int)sdim; i++) { dset1[i].a = i; - dset1[i].b = (float)(i*i); - dset1[i].c = (float)(1.0F / (float)(i+ 1)); + dset1[i].b = (float)(i * i); + dset1[i].c = (double)(1.0 / (double)(i + 1)); dset2[i].a = i; dset2[i].b = (float)((float)i + (float)i * 0.1F); @@ -1216,12 +1225,12 @@ static void gent_compound_dt2(void) { /* test compound data type */ sdim = 2; H5Pset_chunk(create_plist, 1, &sdim); - sdim = 6; + sdim = 6; maxdim = H5S_UNLIMITED; space = H5Screate_simple(1, &sdim, &maxdim); - type = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); + type = H5Tcreate(H5T_COMPOUND, sizeof(dset1[0])); H5Tinsert(type, "a_name", HOFFSET(dset1_t, a), H5T_STD_I32BE); H5Tinsert(type, "b_name", HOFFSET(dset1_t, b), H5T_IEEE_F32BE); @@ -1229,7 +1238,7 @@ static void gent_compound_dt2(void) { /* test compound data type */ dataset = H5Dcreate2(fid, "/dset1", type, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset1[0])); H5Tinsert(type2, "a_name", HOFFSET(dset1_t, a), H5T_NATIVE_INT); H5Tinsert(type2, "b_name", HOFFSET(dset1_t, b), H5T_NATIVE_FLOAT); @@ -1242,7 +1251,7 @@ static void gent_compound_dt2(void) { /* test compound data type */ H5Sclose(space); H5Dclose(dataset); - sdim = 6; + sdim = 6; maxdim = 10; space = H5Screate_simple(1, &sdim, &maxdim); @@ -1257,7 +1266,7 @@ static void gent_compound_dt2(void) { /* test compound data type */ dataset = H5Dcreate2(group, "dset2", type, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset2_t)); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset2_t)); H5Tinsert(type2, "int_name", HOFFSET(dset2_t, a), H5T_NATIVE_INT); H5Tinsert(type2, "float_name", HOFFSET(dset2_t, b), H5T_NATIVE_FLOAT); H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); @@ -1266,16 +1275,18 @@ static void gent_compound_dt2(void) { /* test compound data type */ H5Tclose(type2); H5Dclose(dataset); - /* shared data type 2 */ - type = H5Tcreate (H5T_COMPOUND, sizeof(dset3_t)); + type = H5Tcreate(H5T_COMPOUND, sizeof(dset3_t)); - ndims = 1; dim[0] = 4; + ndims = 1; + dim[0] = 4; array_dt = H5Tarray_create2(H5T_STD_I32BE, ndims, dim); H5Tinsert(type, "int_array", HOFFSET(dset3_t, a), array_dt); H5Tclose(array_dt); - ndims = 2; dim[0] = 5; dim[1] = 6; + ndims = 2; + dim[0] = 5; + dim[1] = 6; array_dt = H5Tarray_create2(H5T_IEEE_F32BE, ndims, dim); H5Tinsert(type, "float_array", HOFFSET(dset3_t, b), array_dt); H5Tclose(array_dt); @@ -1291,7 +1302,7 @@ static void gent_compound_dt2(void) { /* test compound data type */ dataset = H5Dcreate2(group, "dset4", type, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset4_t)); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset4_t)); H5Tinsert(type2, "int", HOFFSET(dset4_t, a), H5T_NATIVE_INT); H5Tinsert(type2, "float", HOFFSET(dset4_t, b), H5T_NATIVE_FLOAT); H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset4); @@ -1301,8 +1312,7 @@ static void gent_compound_dt2(void) { /* test compound data type */ H5Dclose(dataset); H5Gclose(group); - - /* unamed data type */ + /* unnamed data type */ group = H5Gcreate2(fid, "/group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); type = H5Tcreate(H5T_COMPOUND, sizeof(dset5_t)); @@ -1310,7 +1320,7 @@ static void gent_compound_dt2(void) { /* test compound data type */ H5Tinsert(type, "float", HOFFSET(dset5_t, b), H5T_IEEE_F32BE); H5Tcommit2(group, "type4", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); dataset = H5Dcreate2(group, "dset5", type, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset5_t)); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset5_t)); H5Tinsert(type2, "int", HOFFSET(dset5_t, a), H5T_NATIVE_INT); H5Tinsert(type2, "float", HOFFSET(dset5_t, b), H5T_NATIVE_FLOAT); H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset5); @@ -1325,10 +1335,8 @@ static void gent_compound_dt2(void) { /* test compound data type */ H5Pclose(create_plist); H5Fclose(fid); - } - /* / : g1 g2 attr1 attr2 @@ -1340,14 +1348,15 @@ g2 : dset2.1 dset2.2 udlink */ -static void gent_all(void) +static void +gent_all(void) { - hid_t fid, group, attr, dataset, space; + hid_t fid, group, attr, dataset, space; hsize_t dims[2]; - int data[2][2], dset1[10][10], dset2[20]; - char buf[60]; - int i, j; - float dset2_1[10], dset2_2[3][5]; + int data[2][2], dset1[10][10], dset2[20]; + char buf[60]; + int i, j; + float dset2_1[10], dset2_2[3][5]; fid = H5Fcreate(FILE7, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1371,17 +1380,21 @@ static void gent_all(void) group = H5Gopen2(fid, "/", H5P_DEFAULT); dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(group, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(group, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); HDsprintf(buf, "abcdefghi"); H5Awrite(attr, H5T_NATIVE_SCHAR, buf); H5Sclose(space); H5Aclose(attr); - dims[0] = 2; dims[1] = 2; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(group, "attr2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); - data[0][0] = 0; data[0][1] = 1; data[1][0] = 2; data[1][1] = 3; + dims[0] = 2; + dims[1] = 2; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(group, "attr2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); + data[0][0] = 0; + data[0][1] = 1; + data[1][0] = 2; + data[1][1] = 3; H5Awrite(attr, H5T_NATIVE_INT, data); H5Sclose(space); H5Aclose(attr); @@ -1391,27 +1404,28 @@ static void gent_all(void) group = H5Gopen2(fid, "/g1/g1.1", H5P_DEFAULT); /* dset1.1.1 */ - dims[0] = 10; dims[1] = 10; - space = H5Screate_simple(2, dims, NULL); + dims[0] = 10; + dims[1] = 10; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(group, "dset1.1.1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 10; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) dset1[i][j] = j * i; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); H5Sclose(space); /* attributes of dset1.1.1 */ dims[0] = 27; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(dataset, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); HDsprintf(buf, "1st attribute of dset1.1.1"); H5Awrite(attr, H5T_NATIVE_SCHAR, buf); H5Sclose(space); H5Aclose(attr); dims[0] = 27; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr2", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(dataset, "attr2", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); HDsprintf(buf, "2nd attribute of dset1.1.1"); H5Awrite(attr, H5T_NATIVE_SCHAR, buf); H5Sclose(space); @@ -1421,9 +1435,9 @@ static void gent_all(void) /* dset1.1.2 */ dims[0] = 20; - space = H5Screate_simple(1, dims, NULL); + space = H5Screate_simple(1, dims, NULL); dataset = H5Dcreate2(group, "dset1.1.2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 20; i++) + for (i = 0; i < 20; i++) dset2[i] = i; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); H5Sclose(space); @@ -1443,20 +1457,21 @@ static void gent_all(void) /* dset2.1 */ dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); + space = H5Screate_simple(1, dims, NULL); dataset = H5Dcreate2(group, "dset2.1", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) dset2_1[i] = (float)((float)i * 0.1F + 1); H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_1); H5Sclose(space); H5Dclose(dataset); /* dset2.2 */ - dims[0] = 3; dims[1] = 5; - space = H5Screate_simple(2, dims, NULL); + dims[0] = 3; + dims[1] = 5; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(group, "dset2.2", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 3; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 3; i++) + for (j = 0; j < 5; j++) dset2_2[i][j] = (float)((float)(i + 1) * (float)j * 0.1F); H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_2); H5Sclose(space); @@ -1482,7 +1497,9 @@ o - group objects */ -static void gent_loop(void) { +static void +gent_loop(void) +{ hid_t fid, group; fid = H5Fcreate(FILE10, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1498,17 +1515,18 @@ static void gent_loop(void) { H5Fclose(fid); } -static void gent_loop2(void) +static void +gent_loop2(void) { hid_t fid, group; fid = H5Fcreate(FILE11, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - /* create group object g1 and implcit path from root object */ + /* create group object g1 and implicit path from root object */ group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Gclose(group); - /* create group object g2 and implcit path from root object */ + /* create group object g2 and implicit path from root object */ group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Gclose(group); @@ -1535,26 +1553,26 @@ static void gent_loop2(void) static void gent_many(void) { - hid_t fid, group, attr, dataset, space, space2, type, create_plist, type2; - hid_t array_dt; + hid_t fid, group, attr, dataset, space, space2, type, create_plist, type2; + hid_t array_dt; hsize_t dims[2]; - int data[2][2], dset2[10][10], dset3[10][10]; - double d[10]; + int data[2][2], dset2[10][10], dset3[10][10]; + double d[10]; - char buf[60]; - int i, j; - int i0, i1, i2, i3; + char buf[60]; + int i, j; + int i0, i1, i2, i3; hsize_t sdim, maxdim; - typedef struct { /* compound type has members with rank > 1 */ - int a[2][2][2][2]; /* arrays are 2x2x2x2 */ - double b[2][2][2][2]; - double c[2][2][2][2]; + typedef struct { /* compound type has members with rank > 1 */ + int a[2][2][2][2]; /* arrays are 2x2x2x2 */ + double b[2][2][2][2]; + double c[2][2][2][2]; } dset1_t; dset1_t dset1[6]; - hsize_t dim[4]; - herr_t ret; + hsize_t dim[4]; + herr_t H5_ATTR_NDEBUG_UNUSED ret; fid = H5Fcreate(FILE12, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1568,10 +1586,10 @@ gent_many(void) group = H5Gcreate2(fid, "/g1/g1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - type = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); + type = H5Tcreate(H5T_COMPOUND, sizeof(dset1[0])); dim[0] = dim[1] = dim[2] = dim[3] = 2; - array_dt = H5Tarray_create2(H5T_STD_I32BE, 4, dim); + array_dt = H5Tarray_create2(H5T_STD_I32BE, 4, dim); H5Tinsert(type, "a_array", HOFFSET(dset1_t, a), array_dt); H5Tclose(array_dt); @@ -1583,7 +1601,7 @@ gent_many(void) H5Tinsert(type, "c_array", HOFFSET(dset1_t, c), array_dt); H5Tclose(array_dt); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset1[0])); array_dt = H5Tarray_create2(H5T_NATIVE_INT, 4, dim); H5Tinsert(type2, "a_array", HOFFSET(dset1_t, a), array_dt); @@ -1597,44 +1615,47 @@ gent_many(void) H5Tinsert(type2, "c_array", HOFFSET(dset1_t, c), array_dt); H5Tclose(array_dt); - /* dset1 */ - sdim = 6; - maxdim = H5S_UNLIMITED; - space = H5Screate_simple(1, &sdim, &maxdim); + sdim = 6; + maxdim = H5S_UNLIMITED; + space = H5Screate_simple(1, &sdim, &maxdim); dataset = H5Dcreate2(group, "dset1", type, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); /* add attributes to dset1 */ dims[0] = 10; - space2 = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr1", H5T_STD_I8BE, space2, H5P_DEFAULT, H5P_DEFAULT); + space2 = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(dataset, "attr1", H5T_STD_I8BE, space2, H5P_DEFAULT, H5P_DEFAULT); HDsprintf(buf, "abcdefghi"); H5Awrite(attr, H5T_NATIVE_CHAR, buf); H5Sclose(space2); H5Aclose(attr); - dims[0] = 2; dims[1] = 2; - space2 = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(dataset, "attr2", H5T_STD_I32BE, space2, H5P_DEFAULT, H5P_DEFAULT); - data[0][0] = 0; data[0][1] = 1; data[1][0] = 2; data[1][1] = 3; + dims[0] = 2; + dims[1] = 2; + space2 = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(dataset, "attr2", H5T_STD_I32BE, space2, H5P_DEFAULT, H5P_DEFAULT); + data[0][0] = 0; + data[0][1] = 1; + data[1][0] = 2; + data[1][1] = 3; H5Awrite(attr, H5T_NATIVE_INT, data); H5Sclose(space2); H5Aclose(attr); dims[0] = 10; - space2 = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr3", H5T_IEEE_F64BE, space2, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - d[i] = 0.1F * (float)i; + space2 = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(dataset, "attr3", H5T_IEEE_F64BE, space2, H5P_DEFAULT, H5P_DEFAULT); + for (i = 0; i < 10; i++) + d[i] = 0.1 * (double)i; H5Awrite(attr, H5T_NATIVE_DOUBLE, d); H5Sclose(space2); H5Aclose(attr); - for(j=0; j<(int)sdim; j++) { - for(i3 = 0; i3 < 2; i3++) { - for(i2 = 0; i2 < 2; i2++) { - for(i1 = 0; i1 < 2; i1++) { - for(i0 = 0; i0 < 2; i0++) { + for (j = 0; j < (int)sdim; j++) { + for (i3 = 0; i3 < 2; i3++) { + for (i2 = 0; i2 < 2; i2++) { + for (i1 = 0; i1 < 2; i1++) { + for (i0 = 0; i0 < 2; i0++) { dset1[j].a[i3][i2][i1][i0] = i0 + j; dset1[j].b[i3][i2][i1][i0] = (double)(i0 + j); dset1[j].c[i3][i2][i1][i0] = (double)((hsize_t)i0 + (hsize_t)j + sdim); @@ -1667,12 +1688,13 @@ gent_many(void) group = H5Gcreate2(fid, "/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* dset2 */ - dims[0] = 10; dims[1] = 10; - space = H5Screate_simple(2, dims, NULL); + dims[0] = 10; + dims[1] = 10; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(group, "dset2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 10; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) dset2[i][j] = j; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); @@ -1690,12 +1712,13 @@ gent_many(void) group = H5Gcreate2(fid, "/g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* dset3 */ - dims[0] = 10; dims[1] = 10; - space = H5Screate_simple(2, dims, NULL); + dims[0] = 10; + dims[1] = 10; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(group, "dset3", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 10; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) dset3[i][j] = i; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset3); @@ -1728,60 +1751,68 @@ gent_many(void) H5Fclose(fid); } -static hid_t mkstr(int size, H5T_str_t pad) { +static hid_t +mkstr(int size, H5T_str_t pad) +{ hid_t type; - if((type=H5Tcopy(H5T_C_S1)) < 0) return -1; - if(H5Tset_size(type, (size_t)size) < 0) return -1; - if(H5Tset_strpad(type, pad) < 0) return -1; + if ((type = H5Tcopy(H5T_C_S1)) < 0) + return -1; + if (H5Tset_size(type, (size_t)size) < 0) + return -1; + if (H5Tset_strpad(type, pad) < 0) + return -1; return type; } -static void gent_str(void) { +static void +gent_str(void) +{ hid_t fid, dataset, space, f_type, m_type, str_type, f_type2; hid_t array_dt; - hsize_t dims1[] = { 3, 4}; - char string1[12][3] = {"s1","s2","s3","s4","s5","s6","s7","s8","s9", - "s0","s1","s2"}; - - hsize_t dims2[]={20}; - char string2[20][10] = {"ab cd ef1", "ab cd ef2", "ab cd ef3", "ab cd ef4", - "ab cd ef5", "ab cd ef6", "ab cd ef7", "ab cd ef8", - "ab cd ef9", "ab cd ef0", "ab cd ef1", "ab cd ef2", - "ab cd ef3", "ab cd ef4", "ab cd ef5", "ab cd ef6", - "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0"}; - - hsize_t dims3[] = { 27}; - char string3[27][6] = {"abcd0", "abcd1", "abcd2", "abcd3", - "abcd4", "abcd5", "abcd6", "abcd7", - "abcd8", "abcd9", "abcd0", "abcd1", - "abcd2", "abcd3", "abcd4", "abcd5", - "abcd6", "abcd7", "abcd8", "abcd9", - "abcd0", "abcd1", "abcd2", "abcd3", - "abcd4", "abcd5", "abcd6"}; + hsize_t dims1[] = {3, 4}; + char string1[12][3] = {"s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s0", "s1", "s2"}; + + hsize_t dims2[] = {20}; + char string2[20][10] = {"ab cd ef1", "ab cd ef2", "ab cd ef3", "ab cd ef4", "ab cd ef5", + "ab cd ef6", "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0", + "ab cd ef1", "ab cd ef2", "ab cd ef3", "ab cd ef4", "ab cd ef5", + "ab cd ef6", "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0"}; + + hsize_t dims3[] = {27}; + char string3[27][6] = {"abcd0", "abcd1", "abcd2", "abcd3", "abcd4", "abcd5", "abcd6", "abcd7", "abcd8", + "abcd9", "abcd0", "abcd1", "abcd2", "abcd3", "abcd4", "abcd5", "abcd6", "abcd7", + "abcd8", "abcd9", "abcd0", "abcd1", "abcd2", "abcd3", "abcd4", "abcd5", "abcd6"}; int i, j, k, l; - hsize_t dims4[] = { 3 }; - char string4[3][21] = { "s1234567890123456789", "s1234567890123456789", - "s1234567890123456789"}; + hsize_t dims4[] = {3}; + char string4[3][21] = {"s1234567890123456789", "s1234567890123456789", "s1234567890123456789"}; - hsize_t dims5[] = { 3, 6}; + hsize_t dims5[] = {3, 6}; typedef struct { - int a[8][10]; - char s[12][33]; + int a[8][10]; + char s[12][33]; } compound_t; - compound_t comp1[3][6]; - hsize_t mdims[2]; + + compound_t **comp1 = NULL; + compound_t * comp1_data = NULL; + hsize_t mdims[2]; + + /* Set up data array */ + comp1_data = (compound_t *)HDcalloc(3 * 6, sizeof(compound_t)); + comp1 = (compound_t **)HDcalloc(3, sizeof(comp1_data)); + for (i = 0; i < 3; i++) + comp1[i] = comp1_data + (i * 6); fid = H5Fcreate(FILE13, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* string 1 : nullterm string */ - space = H5Screate_simple(2, dims1, NULL); - f_type = mkstr(5, H5T_STR_NULLTERM); - m_type = mkstr(3, H5T_STR_NULLTERM); + space = H5Screate_simple(2, dims1, NULL); + f_type = mkstr(5, H5T_STR_NULLTERM); + m_type = mkstr(3, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid, "/string1", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string1); H5Tclose(m_type); @@ -1790,9 +1821,9 @@ static void gent_str(void) { H5Dclose(dataset); /* string 2 : space pad string */ - space = H5Screate_simple(1, dims2, NULL); - f_type = mkstr(11, H5T_STR_SPACEPAD); - m_type = mkstr(10, H5T_STR_NULLTERM); + space = H5Screate_simple(1, dims2, NULL); + f_type = mkstr(11, H5T_STR_SPACEPAD); + m_type = mkstr(10, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid, "/string2", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string2); H5Tclose(m_type); @@ -1801,9 +1832,9 @@ static void gent_str(void) { H5Dclose(dataset); /* string 3 : null pad string */ - space = H5Screate_simple(1, dims3, NULL); - f_type = mkstr(8, H5T_STR_NULLPAD); - m_type = mkstr(6, H5T_STR_NULLTERM); + space = H5Screate_simple(1, dims3, NULL); + f_type = mkstr(8, H5T_STR_NULLPAD); + m_type = mkstr(6, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid, "/string3", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string3); H5Tclose(m_type); @@ -1812,9 +1843,9 @@ static void gent_str(void) { H5Dclose(dataset); /* string 4 : space pad long string */ - space = H5Screate_simple(1, dims4, NULL); - f_type = mkstr(168, H5T_STR_SPACEPAD); - m_type = mkstr(21, H5T_STR_NULLTERM); + space = H5Screate_simple(1, dims4, NULL); + f_type = mkstr(168, H5T_STR_SPACEPAD); + m_type = mkstr(21, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid, "/string4", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string4); H5Tclose(m_type); @@ -1823,11 +1854,12 @@ static void gent_str(void) { H5Dclose(dataset); /* compound data */ - space = H5Screate_simple(2, dims5, NULL); - f_type = H5Tcreate (H5T_COMPOUND, sizeof(compound_t)); - f_type2 = H5Tcreate (H5T_COMPOUND, sizeof(compound_t)); + space = H5Screate_simple(2, dims5, NULL); + f_type = H5Tcreate(H5T_COMPOUND, sizeof(compound_t)); + f_type2 = H5Tcreate(H5T_COMPOUND, sizeof(compound_t)); - mdims[0] = 8; mdims[1] = 10; + mdims[0] = 8; + mdims[1] = 10; array_dt = H5Tarray_create2(H5T_STD_I32BE, 2, mdims); H5Tinsert(f_type, "int_array", HOFFSET(compound_t, a), array_dt); @@ -1837,7 +1869,8 @@ static void gent_str(void) { H5Tinsert(f_type2, "int_array", HOFFSET(compound_t, a), array_dt); H5Tclose(array_dt); - mdims[0] = 3; mdims[1] = 4; + mdims[0] = 3; + mdims[1] = 4; str_type = mkstr(32, H5T_STR_SPACEPAD); array_dt = H5Tarray_create2(str_type, 2, mdims); @@ -1851,17 +1884,17 @@ static void gent_str(void) { H5Tclose(array_dt); H5Tclose(str_type); - for(i = 0; i < 3; i++) - for(j = 0; j < 6; j++) { - for(k = 0 ; k < 8; k++) - for(l = 0; l < 10; l++) + for (i = 0; i < 3; i++) + for (j = 0; j < 6; j++) { + for (k = 0; k < 8; k++) + for (l = 0; l < 10; l++) comp1[i][j].a[k][l] = (l + j + k) * (l + j + k); - for(k = 0 ; k < 12; k++) + for (k = 0; k < 12; k++) HDstrcpy(comp1[i][j].s[k], "abcdefgh12345678abcdefgh12345678"); } dataset = H5Dcreate2(fid, "/comp1", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(dataset, f_type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, comp1); + H5Dwrite(dataset, f_type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, comp1_data); H5Tclose(f_type); H5Tclose(f_type2); @@ -1869,6 +1902,9 @@ static void gent_str(void) { H5Dclose(dataset); H5Fclose(fid); + + HDfree(comp1); + HDfree(comp1_data); } /* @@ -1880,17 +1916,17 @@ static void gent_str(void) { string2 string4 string6 */ -static void gent_str2(void) +static void +gent_str2(void) { - hid_t fid, group, attr, dataset, space, space2, mem_space, hyper_space; - hid_t fxdlenstr, fxdlenstr2, memtype; + hid_t fid, group, attr, dataset, space, space2, mem_space, hyper_space; + hid_t fxdlenstr, fxdlenstr2, memtype; hsize_t dims[1], size[1], stride[1], count[1], block[1]; hsize_t start[1]; - - int i; - char buf[LENSTR+20]; - char buf2[3*LENSTR2]; + int i; + char buf[LENSTR + 20]; + char buf2[3 * LENSTR2]; hsize_t sdim; fid = H5Fcreate(FILE14, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1905,16 +1941,16 @@ static void gent_str2(void) H5Tset_cset(memtype, H5T_CSET_ASCII); H5Tset_strpad(memtype, H5T_STR_NULLTERM); - sdim = 10; - size[0] = sdim; - space = H5Screate_simple(1, size, NULL); - size[0] = 1; - mem_space = H5Screate_simple(1,size,NULL); + sdim = 10; + size[0] = sdim; + space = H5Screate_simple(1, size, NULL); + size[0] = 1; + mem_space = H5Screate_simple(1, size, NULL); hyper_space = H5Scopy(space); /* dset1 */ - group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); dataset = H5Dcreate2(group, "dset1", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* add attributes to dset1 */ @@ -1925,71 +1961,69 @@ static void gent_str2(void) H5Tset_strpad(fxdlenstr2, H5T_STR_NULLTERM); dims[0] = 3; - space2 = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr1", fxdlenstr2, space2, H5P_DEFAULT, H5P_DEFAULT); - HDsprintf(&(buf2[0*LENSTR2]), "0123456789"); - HDsprintf(&(buf2[1*LENSTR2]), "abcdefghij"); - HDsprintf(&(buf2[2*LENSTR2]), "ABCDEFGHIJ"); + space2 = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(dataset, "attr1", fxdlenstr2, space2, H5P_DEFAULT, H5P_DEFAULT); + HDsprintf(&(buf2[0 * LENSTR2]), "0123456789"); + HDsprintf(&(buf2[1 * LENSTR2]), "abcdefghij"); + HDsprintf(&(buf2[2 * LENSTR2]), "ABCDEFGHIJ"); H5Awrite(attr, fxdlenstr2, buf2); H5Sclose(space2); H5Tclose(fxdlenstr2); H5Aclose(attr); - stride[0]=1; - count[0]=1; - block[0]=1; + stride[0] = 1; + count[0] = 1; + block[0] = 1; - for(i = 0; (hsize_t)i < sdim; i++) { + for (i = 0; (hsize_t)i < sdim; i++) { start[0] = (hsize_t)i; HDsprintf(buf, "This is row %1d of type H5T_STR_NULLTERM of", i); - H5Tset_size(memtype, HDstrlen(buf)+1); + H5Tset_size(memtype, HDstrlen(buf) + 1); H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block); H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf); } H5Dclose(dataset); H5Gclose(group); - group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); dataset = H5Dcreate2(group, "dset2", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; (hsize_t)i < sdim; i++) { + for (i = 0; (hsize_t)i < sdim; i++) { start[0] = (hsize_t)i; HDsprintf(buf, "This is row %1d of type H5T_STR_NULLTERM of string array", i); - H5Tset_size(memtype, HDstrlen(buf)+1); + H5Tset_size(memtype, HDstrlen(buf) + 1); H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block); H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf); } H5Dclose(dataset); H5Gclose(group); - H5Tclose(fxdlenstr); fxdlenstr = H5Tcopy(H5T_C_S1); H5Tset_size(fxdlenstr, LENSTR); H5Tset_cset(fxdlenstr, H5T_CSET_ASCII); H5Tset_strpad(fxdlenstr, H5T_STR_NULLPAD); - group = H5Gcreate2(fid, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + group = H5Gcreate2(fid, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); dataset = H5Dcreate2(group, "dset3", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0;(hsize_t) i < sdim; i++) { + for (i = 0; (hsize_t)i < sdim; i++) { start[0] = (hsize_t)i; HDsprintf(buf, "This is row %1d of type H5T_STR_NULLPAD of", i); - H5Tset_size(memtype, HDstrlen(buf)+1); + H5Tset_size(memtype, HDstrlen(buf) + 1); H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block); H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf); } H5Dclose(dataset); H5Gclose(group); - - group = H5Gcreate2(fid, "/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + group = H5Gcreate2(fid, "/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); dataset = H5Dcreate2(group, "dset4", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; (hsize_t)i < sdim; i++) { + for (i = 0; (hsize_t)i < sdim; i++) { start[0] = (hsize_t)i; HDsprintf(buf, "This is row %1d of type H5T_STR_NULLPAD of string array", i); - H5Tset_size(memtype, HDstrlen(buf)+1); + H5Tset_size(memtype, HDstrlen(buf) + 1); H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block); H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf); } @@ -2002,10 +2036,10 @@ static void gent_str2(void) H5Tset_cset(fxdlenstr, H5T_CSET_ASCII); H5Tset_strpad(fxdlenstr, H5T_STR_SPACEPAD); - group = H5Gcreate2(fid, "/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + group = H5Gcreate2(fid, "/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); dataset = H5Dcreate2(group, "dset5", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; (hsize_t)i < sdim; i++) { + for (i = 0; (hsize_t)i < sdim; i++) { start[0] = (hsize_t)i; HDsprintf(buf, "This is row %1d of type H5T_STR_SPACEPAD of", i); H5Tset_size(memtype, HDstrlen(buf) + 1); @@ -2015,11 +2049,10 @@ static void gent_str2(void) H5Dclose(dataset); H5Gclose(group); - - group = H5Gcreate2(fid, "/g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + group = H5Gcreate2(fid, "/g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); dataset = H5Dcreate2(group, "dset6", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; (hsize_t)i < sdim; i++) { + for (i = 0; (hsize_t)i < sdim; i++) { start[0] = (hsize_t)i; HDsprintf(buf, "This is row %1d of type H5T_STR_SPACEPAD of string array", i); H5Tset_size(memtype, HDstrlen(buf) + 1); @@ -2037,30 +2070,29 @@ static void gent_str2(void) H5Fclose(fid); } -static void gent_enum(void) +static void +gent_enum(void) { /*some code is taken from enum.c in the test dir */ - hid_t file, type, space, dset; - int val; - enumtype data[] = {RED, GREEN, BLUE, GREEN, WHITE, - WHITE, BLACK, GREEN, BLUE, RED, - RED, BLUE, GREEN, BLACK, WHITE, - RED, WHITE, GREEN, GREEN, BLUE}; - hsize_t size[1] = {NELMTS(data)}; + hid_t file, type, space, dset; + int val; + enumtype data[] = {RED, GREEN, BLUE, GREEN, WHITE, WHITE, BLACK, GREEN, BLUE, RED, + RED, BLUE, GREEN, BLACK, WHITE, RED, WHITE, GREEN, GREEN, BLUE}; + hsize_t size[1] = {NELMTS(data)}; - file = H5Fcreate(FILE15,H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(FILE15, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Try to test names with special characters */ type = H5Tcreate(H5T_ENUM, sizeof(enumtype)); - H5Tenum_insert(type, "RED", (val = 0, &val)); + H5Tenum_insert(type, "RED", (val = 0, &val)); H5Tenum_insert(type, "GREEN\ngreen", (val = 1, &val)); - H5Tenum_insert(type, "BLUE blue", (val = 2, &val)); + H5Tenum_insert(type, "BLUE blue", (val = 2, &val)); H5Tenum_insert(type, "WHITE \"white\"", (val = 3, &val)); H5Tenum_insert(type, "BLACK \'black\'", (val = 4, &val)); H5Tcommit2(file, "enum normal", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - space = H5Screate_simple(1,size,NULL); - dset = H5Dcreate2(file,"table",type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, size, NULL); + dset = H5Dcreate2(file, "table", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dset, type, space, space, H5P_DEFAULT, data); H5Dclose(dset); @@ -2068,27 +2100,29 @@ static void gent_enum(void) H5Fclose(file); } -static void gent_objref(void) +static void +gent_objref(void) { /*some code is taken from enum.c in the test dir */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - - hid_t group; /* Group ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - hobj_ref_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf; /* temp. buffer read from disk */ - uint32_t *tu32; /* Temporary pointer to uint32 data */ - int i; /* counting variables */ - const char *write_comment = "Foo!"; /* Comments for group */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + + hid_t group; /* Group ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hobj_ref_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer read from disk */ + *tbuf; /* temp. buffer read from disk */ + uint32_t * tu32; /* Temporary pointer to uint32 data */ + int i; /* counting variables */ + const char *write_comment = "Foo!"; /* Comments for group */ + uint64_t supports_comments = 0; /* Allocate write & read buffers */ - wbuf = (hobj_ref_t*) HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1); - rbuf = (hobj_ref_t*) HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1); - tbuf = (hobj_ref_t*) HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1); + wbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1); + rbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1); + tbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1); /* Create file */ fid1 = H5Fcreate(FILE16, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -2099,13 +2133,17 @@ static void gent_objref(void) /* Create a group */ group = H5Gcreate2(fid1, "Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + /* Check if we support comments in the current VOL connector */ + H5VLquery_optional(fid1, H5VL_SUBCLS_OBJECT, H5VL_NATIVE_OBJECT_SET_COMMENT, &supports_comments); + /* Set group's comment */ - H5Oset_comment(group, write_comment); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) + H5Oset_comment(group, write_comment); /* Create a dataset (inside Group1) */ dataset = H5Dcreate2(group, "Dataset1", H5T_STD_U32BE, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(tu32 = (uint32_t *)((void*)wbuf), i = 0; i < SPACE1_DIM1; i++) + for (tu32 = (uint32_t *)((void *)wbuf), i = 0; i < SPACE1_DIM1; i++) *tu32++ = (uint32_t)(i * 3); /* Write selection to disk */ @@ -2124,11 +2162,11 @@ static void gent_objref(void) tid1 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); /* Insert fields */ - H5Tinsert(tid1, "a", HOFFSET(s1_t,a), H5T_STD_I32BE); + H5Tinsert(tid1, "a", HOFFSET(s1_t, a), H5T_STD_I32BE); - H5Tinsert(tid1, "b", HOFFSET(s1_t,b), H5T_IEEE_F32BE); + H5Tinsert(tid1, "b", HOFFSET(s1_t, b), H5T_IEEE_F32BE); - H5Tinsert(tid1, "c", HOFFSET(s1_t,c), H5T_IEEE_F32BE); + H5Tinsert(tid1, "c", HOFFSET(s1_t, c), H5T_IEEE_F32BE); /* Save datatype for later */ H5Tcommit2(group, "Datatype1", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -2172,34 +2210,34 @@ static void gent_objref(void) HDfree(tbuf); } -static void gent_datareg(void) +static void +gent_datareg(void) { /*some code is taken from enum.c in the test dir */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dset1, /* Dataset ID */ - dset2; /* Dereferenced dataset ID */ - hid_t sid1, /* Dataspace ID #1 */ - sid2; /* Dataspace ID #2 */ - hsize_t dims1[] = {SPACE1_DIM1}, - dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ - hdset_reg_ref_t *wbuf, /* buffer to write to disk */ - *rbuf; /* buffer read from disk */ - uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ - *drbuf; /* Buffer for reading numeric data from disk */ - uint8_t *tu8; /* Temporary pointer to uint8 data */ - int i; /* counting variables */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dset1, /* Dataset ID */ + dset2; /* Dereferenced dataset ID */ + hid_t sid1, /* Dataspace ID #1 */ + sid2; /* Dataspace ID #2 */ + hsize_t dims1[] = {SPACE1_DIM1}, dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ + hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ + hdset_reg_ref_t *wbuf, /* buffer to write to disk */ + *rbuf; /* buffer read from disk */ + uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ + *drbuf; /* Buffer for reading numeric data from disk */ + uint8_t *tu8; /* Temporary pointer to uint8 data */ + int i; /* counting variables */ /* Allocate write & read buffers */ - wbuf = (hdset_reg_ref_t*) HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); - rbuf = (hdset_reg_ref_t*) HDmalloc(sizeof(hdset_reg_ref_t)*SPACE1_DIM1); - dwbuf = (uint8_t*) HDmalloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2); - drbuf = (uint8_t*) HDcalloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2); + wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); + rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); + dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); + drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), SPACE2_DIM1 * SPACE2_DIM2); /* Create file */ fid1 = H5Fcreate(FILE17, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -2210,7 +2248,7 @@ static void gent_datareg(void) /* Create a dataset */ dset2 = H5Dcreate2(fid1, "Dataset2", H5T_STD_U8BE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++) + for (tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++) *tu8++ = (uint8_t)(i * 3); /* Write selection to disk */ @@ -2228,10 +2266,14 @@ static void gent_datareg(void) /* Create references */ /* Select 6x6 hyperslab for first reference */ - start[0] = 2; start[1] = 2; - stride[0] = 1; stride[1] = 1; - count[0] = 6; count[1] = 6; - block[0] = 1; block[1] = 1; + start[0] = 2; + start[1] = 2; + stride[0] = 1; + stride[1] = 1; + count[0] = 6; + count[1] = 6; + block[0] = 1; + block[1] = 1; H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); H5Sget_select_npoints(sid2); @@ -2240,25 +2282,35 @@ static void gent_datareg(void) H5Rcreate(&wbuf[0], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); /* Select sequence of ten points for second reference */ - coord1[0][0]=6; coord1[0][1]=9; - coord1[1][0]=2; coord1[1][1]=2; - coord1[2][0]=8; coord1[2][1]=4; - coord1[3][0]=1; coord1[3][1]=6; - coord1[4][0]=2; coord1[4][1]=8; - coord1[5][0]=3; coord1[5][1]=2; - coord1[6][0]=0; coord1[6][1]=4; - coord1[7][0]=9; coord1[7][1]=0; - coord1[8][0]=7; coord1[8][1]=1; - coord1[9][0]=3; coord1[9][1]=3; - H5Sselect_elements(sid2,H5S_SELECT_SET,POINT1_NPOINTS,(hsize_t *)coord1); + coord1[0][0] = 6; + coord1[0][1] = 9; + coord1[1][0] = 2; + coord1[1][1] = 2; + coord1[2][0] = 8; + coord1[2][1] = 4; + coord1[3][0] = 1; + coord1[3][1] = 6; + coord1[4][0] = 2; + coord1[4][1] = 8; + coord1[5][0] = 3; + coord1[5][1] = 2; + coord1[6][0] = 0; + coord1[6][1] = 4; + coord1[7][0] = 9; + coord1[7][1] = 0; + coord1[8][0] = 7; + coord1[8][1] = 1; + coord1[9][0] = 3; + coord1[9][1] = 3; + H5Sselect_elements(sid2, H5S_SELECT_SET, POINT1_NPOINTS, (hsize_t *)coord1); H5Sget_select_npoints(sid2); /* Store second dataset region */ - H5Rcreate(&wbuf[1],fid1,"/Dataset2",H5R_DATASET_REGION,sid2); + H5Rcreate(&wbuf[1], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); /* Write selection to disk */ - H5Dwrite(dset1,H5T_STD_REF_DSETREG,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf); + H5Dwrite(dset1, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); /* Close disk dataspace */ H5Sclose(sid1); @@ -2279,36 +2331,37 @@ static void gent_datareg(void) HDfree(drbuf); } -static void gent_attrreg(void) +static void +gent_attrreg(void) { /*some code is taken from enum.c in the test dir */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dset1; /* Dataset ID */ - hid_t dset2; /* Dereferenced dataset ID */ - hid_t sid1; /* Dataspace ID #1 */ - hid_t sid2; /* Dataspace ID #2 */ - hid_t sid3; /* Dataspace ID #3 */ - hid_t attr1; /* Attribute ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ - hdset_reg_ref_t *wbuf; /* buffer to write to disk */ - hdset_reg_ref_t *rbuf; /* buffer read from disk */ - uint8_t *dwbuf; /* Buffer for writing numeric data to disk */ - uint8_t *drbuf; /* Buffer for reading numeric data from disk */ - uint8_t *tu8; /* Temporary pointer to uint8 data */ - int i; /* counting variables */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dset1; /* Dataset ID */ + hid_t dset2; /* Dereferenced dataset ID */ + hid_t sid1; /* Dataspace ID #1 */ + hid_t sid2; /* Dataspace ID #2 */ + hid_t sid3; /* Dataspace ID #3 */ + hid_t attr1; /* Attribute ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ + hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ + hdset_reg_ref_t *wbuf; /* buffer to write to disk */ + hdset_reg_ref_t *rbuf; /* buffer read from disk */ + uint8_t * dwbuf; /* Buffer for writing numeric data to disk */ + uint8_t * drbuf; /* Buffer for reading numeric data from disk */ + uint8_t * tu8; /* Temporary pointer to uint8 data */ + int i; /* counting variables */ /* Allocate write & read buffers */ - wbuf = (hdset_reg_ref_t*) HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); - rbuf = (hdset_reg_ref_t*) HDmalloc(sizeof(hdset_reg_ref_t)*SPACE1_DIM1); - dwbuf = (uint8_t*) HDmalloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2); - drbuf = (uint8_t*) HDcalloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2); + wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); + rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); + dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); + drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), SPACE2_DIM1 * SPACE2_DIM2); /* Create file */ fid1 = H5Fcreate(FILE64, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -2319,7 +2372,7 @@ static void gent_attrreg(void) /* Create a dataset */ dset2 = H5Dcreate2(fid1, "Dataset2", H5T_STD_U8BE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++) + for (tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++) *tu8++ = (uint8_t)(i * 3); /* Write selection to disk */ @@ -2332,18 +2385,21 @@ static void gent_attrreg(void) * Create dataset with a null dataspace to serve as the parent for * the attribute. */ - sid1 = H5Screate (H5S_NULL); - dset1 = H5Dcreate2 (fid1, "Dataset1", H5T_STD_I32LE, sid1, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); - H5Sclose (sid1); + sid1 = H5Screate(H5S_NULL); + dset1 = H5Dcreate2(fid1, "Dataset1", H5T_STD_I32LE, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Sclose(sid1); /* Create references */ /* Select 6x6 hyperslab for first reference */ - start[0] = 2; start[1] = 2; - stride[0] = 1; stride[1] = 1; - count[0] = 6; count[1] = 6; - block[0] = 1; block[1] = 1; + start[0] = 2; + start[1] = 2; + stride[0] = 1; + stride[1] = 1; + count[0] = 6; + count[1] = 6; + block[0] = 1; + block[1] = 1; H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); H5Sget_select_npoints(sid2); @@ -2352,36 +2408,45 @@ static void gent_attrreg(void) H5Rcreate(&wbuf[0], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); /* Select sequence of ten points for second reference */ - coord1[0][0]=6; coord1[0][1]=9; - coord1[1][0]=2; coord1[1][1]=2; - coord1[2][0]=8; coord1[2][1]=4; - coord1[3][0]=1; coord1[3][1]=6; - coord1[4][0]=2; coord1[4][1]=8; - coord1[5][0]=3; coord1[5][1]=2; - coord1[6][0]=0; coord1[6][1]=4; - coord1[7][0]=9; coord1[7][1]=0; - coord1[8][0]=7; coord1[8][1]=1; - coord1[9][0]=3; coord1[9][1]=3; - H5Sselect_elements(sid2,H5S_SELECT_SET,POINT1_NPOINTS,(hsize_t *)coord1); + coord1[0][0] = 6; + coord1[0][1] = 9; + coord1[1][0] = 2; + coord1[1][1] = 2; + coord1[2][0] = 8; + coord1[2][1] = 4; + coord1[3][0] = 1; + coord1[3][1] = 6; + coord1[4][0] = 2; + coord1[4][1] = 8; + coord1[5][0] = 3; + coord1[5][1] = 2; + coord1[6][0] = 0; + coord1[6][1] = 4; + coord1[7][0] = 9; + coord1[7][1] = 0; + coord1[8][0] = 7; + coord1[8][1] = 1; + coord1[9][0] = 3; + coord1[9][1] = 3; + H5Sselect_elements(sid2, H5S_SELECT_SET, POINT1_NPOINTS, (hsize_t *)coord1); H5Sget_select_npoints(sid2); /* Store second dataset region */ - H5Rcreate(&wbuf[1],fid1,"/Dataset2",H5R_DATASET_REGION,sid2); + H5Rcreate(&wbuf[1], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); /* Create dataspace for the attribute */ sid3 = H5Screate_simple(SPACE1_RANK, dims1, NULL); /* Create the attribute and write the region references to it. */ - attr1 = H5Acreate2 (dset1, "Attribute1", H5T_STD_REF_DSETREG, sid3, H5P_DEFAULT, - H5P_DEFAULT); - H5Awrite (attr1, H5T_STD_REF_DSETREG, wbuf); + attr1 = H5Acreate2(dset1, "Attribute1", H5T_STD_REF_DSETREG, sid3, H5P_DEFAULT, H5P_DEFAULT); + H5Awrite(attr1, H5T_STD_REF_DSETREG, wbuf); /* Close attribute dataspace */ H5Sclose(sid3); /* Close attribute */ - H5Aclose (attr1); + H5Aclose(attr1); /* Close Dataset */ H5Dclose(dset1); @@ -2400,48 +2465,48 @@ static void gent_attrreg(void) } /*taken from Elena's compound test file*/ -static void gent_nestcomp(void) +static void +gent_nestcomp(void) { - /* Compound memeber of the compound datatype*/ + /* Compound member of the compound datatype*/ typedef struct cmp_t { - char a; - float b[2]; + char a; + float b[2]; } cmp_t; /* First structure and dataset*/ typedef struct s1_t { - int a; - float b; - double c; - cmp_t d; + int a; + float b; + double c; + cmp_t d; } s2_t; - hid_t cmp_tid; /* Handle for the compound datatype */ - hid_t char_id; /* Handle for the string datatype */ - hid_t array_dt; - hsize_t array_dims[] = {2}; /* Dataspace dimensions */ - unsigned ndims = 1; /* Number of dimensions in the array field */ + hid_t cmp_tid; /* Handle for the compound datatype */ + hid_t char_id; /* Handle for the string datatype */ + hid_t array_dt; + hsize_t array_dims[] = {2}; /* Dataspace dimensions */ + unsigned ndims = 1; /* Number of dimensions in the array field */ - s2_t s1[10]; - hid_t s2_tid; /* File datatype identifier */ + s2_t s1[10]; + hid_t s2_tid; /* File datatype identifier */ - int i; - hid_t file, dataset, space; /* Handles */ - herr_t status; - hsize_t dim[] = {10}; /* Dataspace dimensions */ + int i; + hid_t file, dataset, space; /* Handles */ + herr_t status; + hsize_t dim[] = {10}; /* Dataspace dimensions */ char datasetname[] = "ArrayOfStructures"; - /* * Initialize the data */ - for(i = 0; i< 10; i++) { - s1[i].a = i; - s1[i].b = (float)(i*i); - s1[i].c = 1.0F/(float)(i + 1); - s1[i].d.a = (char)(65 + i); + for (i = 0; i < 10; i++) { + s1[i].a = i; + s1[i].b = (float)(i * i); + s1[i].c = 1.0 / (double)(i + 1); + s1[i].d.a = (char)(65 + i); s1[i].d.b[0] = -100.0F; - s1[i].d.b[1] = 100.0F; + s1[i].d.b[1] = 100.0F; } /* @@ -2460,7 +2525,7 @@ static void gent_nestcomp(void) /* * Create a datatype for compound field first. */ - cmp_tid = H5Tcreate (H5T_COMPOUND, sizeof(cmp_t)); + cmp_tid = H5Tcreate(H5T_COMPOUND, sizeof(cmp_t)); /* We are using C string of length one to represent "real" character */ char_id = H5Tcopy(H5T_C_S1); @@ -2471,12 +2536,12 @@ static void gent_nestcomp(void) H5Tinsert(cmp_tid, "array_name", HOFFSET(cmp_t, b), array_dt); H5Tclose(array_dt); - s2_tid = H5Tcreate (H5T_COMPOUND, sizeof(s2_t)); + s2_tid = H5Tcreate(H5T_COMPOUND, sizeof(s2_t)); H5Tinsert(s2_tid, "a_name", HOFFSET(s2_t, a), H5T_NATIVE_INT); H5Tinsert(s2_tid, "c_name", HOFFSET(s2_t, c), H5T_NATIVE_DOUBLE); H5Tinsert(s2_tid, "b_name", HOFFSET(s2_t, b), H5T_NATIVE_FLOAT); - /* Insert compound memeber created above */ + /* Insert compound member created above */ H5Tinsert(s2_tid, "d_name", HOFFSET(s2_t, d), cmp_tid); /* @@ -2488,7 +2553,7 @@ static void gent_nestcomp(void) * Wtite data to the dataset; */ status = H5Dwrite(dataset, s2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1); - if(status < 0) + if (status < 0) HDfprintf(stderr, "gent_nestcomp H5Dwrite failed\n"); /* @@ -2502,14 +2567,15 @@ static void gent_nestcomp(void) H5Fclose(file); } -static void gent_opaque(void) +static void +gent_opaque(void) { - hid_t file, type, dataset, space; - char test[100][2]; - int x; + hid_t file, type, dataset, space; + char test[100][2]; + int x; hsize_t dim = 2; - for(x = 0; x < 100; x++){ + for (x = 0; x < 100; x++) { test[x][0] = (char)x; test[x][1] = (char)(99 - x); } @@ -2546,85 +2612,96 @@ static void gent_opaque(void) H5Fclose(file); } -static void gent_bitfields(void) +static void +gent_bitfields(void) { - hid_t file, grp=-1, type=-1, space=-1, dset=-1; - size_t i; - hsize_t nelmts; + hid_t file, grp = H5I_INVALID_HID, type = H5I_INVALID_HID, space = H5I_INVALID_HID, + dset = H5I_INVALID_HID; + size_t i; + hsize_t nelmts; unsigned char buf[32]; file = H5Fcreate(FILE20, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if((grp = H5Gcreate2(file, "typetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if ((grp = H5Gcreate2(file, "typetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; /* bitfield_1 */ nelmts = sizeof(buf); - if((type = H5Tcopy(H5T_STD_B8LE)) < 0 || - (space = H5Screate_simple(1, &nelmts, NULL)) < 0 || - (dset = H5Dcreate2(grp, "bitfield_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((type = H5Tcopy(H5T_STD_B8LE)) < 0 || (space = H5Screate_simple(1, &nelmts, NULL)) < 0 || + (dset = H5Dcreate2(grp, "bitfield_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - for(i = 0; i < sizeof buf; i++) - buf[i] = (unsigned char)0xff ^ (unsigned char)i; - if(H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + for (i = 0; i < sizeof buf; i++) + buf[i] = (uint8_t)(0xff ^ i); + if (H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Tclose(type) < 0) + goto error; + if (H5Dclose(dset) < 0) goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Tclose(type) < 0) goto error; - if(H5Dclose(dset) < 0) goto error; /* bitfield_2 */ - nelmts = sizeof(buf)/2; - if((type = H5Tcopy(H5T_STD_B16LE)) < 0 || - (space = H5Screate_simple(1, &nelmts, NULL)) < 0 || - (dset = H5Dcreate2(grp, "bitfield_2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + nelmts = sizeof(buf) / 2; + if ((type = H5Tcopy(H5T_STD_B16LE)) < 0 || (space = H5Screate_simple(1, &nelmts, NULL)) < 0 || + (dset = H5Dcreate2(grp, "bitfield_2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + for (i = 0; i < sizeof buf; i++) + buf[i] = (uint8_t)(0xff ^ i); + if (H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Tclose(type) < 0) goto error; - for(i = 0; i < sizeof buf; i++) - buf[i] = (unsigned char)0xff ^ (unsigned char)i; - if(H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dclose(dset) < 0) + goto error; + if (H5Gclose(grp) < 0) goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Tclose(type) < 0) goto error; - if(H5Dclose(dset) < 0) goto error; - if(H5Gclose(grp) < 0) goto error; H5Fclose(file); - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Gclose(grp); H5Tclose(type); H5Sclose(space); H5Dclose(dset); - } H5E_END_TRY; + } + H5E_END_TRY; } -static void gent_vldatatypes(void) +static void +gent_vldatatypes(void) { - hvl_t adata, wdata[SPACE1_DIM1]; - hid_t file, dset, space, type; - hsize_t dims[] = { SPACE1_DIM1 }; - int i; - herr_t ret=0; + hvl_t adata, wdata[SPACE1_DIM1]; + hid_t file, dset, space, type; + hsize_t dims[] = {SPACE1_DIM1}; + int i; + herr_t H5_ATTR_NDEBUG_UNUSED ret = 0; file = H5Fcreate(FILE21, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Allocate and initialize VL dataset to write */ - for(i = 0; i < SPACE1_DIM1; i++) { + for (i = 0; i < SPACE1_DIM1; i++) { int j; - wdata[i].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + wdata[i].p = HDmalloc((size_t)(i + 1) * sizeof(int)); wdata[i].len = (size_t)(i + 1); - for(j = 0; j < i + 1; j++) + for (j = 0; j < i + 1; j++) ((int *)wdata[i].p)[j] = i * 10 + j; } /* write out the integers in little-endian format */ space = H5Screate_simple(SPACE1_RANK, dims, NULL); - type = H5Tvlen_create(H5T_NATIVE_INT); - dset = H5Dcreate2(file, "Dataset1.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); + type = H5Tvlen_create(H5T_NATIVE_INT); + dset = H5Dcreate2(file, "Dataset1.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); HDassert(ret >= 0); - ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, wdata); + ret = H5Treclaim(type, space, H5P_DEFAULT, wdata); HDassert(ret >= 0); ret = H5Dclose(dset); @@ -2635,23 +2712,23 @@ static void gent_vldatatypes(void) HDassert(ret >= 0); /* Allocate and initialize VL dataset to write */ - for(i = 0; i < SPACE1_DIM1; i++) { + for (i = 0; i < SPACE1_DIM1; i++) { int j; - wdata[i].p = HDmalloc((size_t)(i + 1) * sizeof(float)); + wdata[i].p = HDmalloc((size_t)(i + 1) * sizeof(float)); wdata[i].len = (size_t)(i + 1); - for(j = 0; j < i + 1; j++) + for (j = 0; j < i + 1; j++) ((float *)wdata[i].p)[j] = (float)((float)(i * 10) + ((float)j) / 10.0F); } /* end for */ /* write out the floats in little-endian format */ space = H5Screate_simple(SPACE1_RANK, dims, NULL); - type = H5Tvlen_create(H5T_NATIVE_FLOAT); - dset = H5Dcreate2(file, "Dataset2.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); + type = H5Tvlen_create(H5T_NATIVE_FLOAT); + dset = H5Dcreate2(file, "Dataset2.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); HDassert(ret >= 0); - ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, wdata); + ret = H5Treclaim(type, space, H5P_DEFAULT, wdata); HDassert(ret >= 0); ret = H5Dclose(dset); @@ -2662,19 +2739,19 @@ static void gent_vldatatypes(void) HDassert(ret >= 0); /* Allocate and initialize a scalar VL dataset to write */ - adata.p = HDmalloc(37 * sizeof(int)); + adata.p = HDmalloc(37 * sizeof(int)); adata.len = 37; - for(i = 0; i < 37; i++) + for (i = 0; i < 37; i++) ((int *)adata.p)[i] = i * 2; /* write out scalar VL dataset in little-endian format */ space = H5Screate_simple(0, NULL, NULL); - type = H5Tvlen_create(H5T_NATIVE_INT); - dset = H5Dcreate2(file, "Dataset3.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, &adata); + type = H5Tvlen_create(H5T_NATIVE_INT); + dset = H5Dcreate2(file, "Dataset3.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, &adata); HDassert(ret >= 0); - ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, &adata); + ret = H5Treclaim(type, space, H5P_DEFAULT, &adata); HDassert(ret >= 0); ret = H5Dclose(dset); @@ -2690,35 +2767,35 @@ static void gent_vldatatypes(void) static void gent_vldatatypes2(void) { - hvl_t wdata[SPACE1_DIM1]; /* Information to write */ - hvl_t *t1; /* Temporary pointer to VL information */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1, tid2; /* Datatype IDs */ - hsize_t dims1[] = {SPACE1_DIM1}; - unsigned i,j,k; /* counting variables */ - herr_t ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1]; /* Information to write */ + hvl_t * t1; /* Temporary pointer to VL information */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1, tid2; /* Datatype IDs */ + hsize_t dims1[] = {SPACE1_DIM1}; + unsigned i, j, k; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Allocate and initialize VL data to write */ - for(i = 0; i < SPACE1_DIM1; i++) { + for (i = 0; i < SPACE1_DIM1; i++) { wdata[i].p = (hvl_t *)HDmalloc((i + 1) * sizeof(hvl_t)); - if(wdata[i].p == NULL) { + if (wdata[i].p == NULL) { HDprintf("Cannot allocate memory for VL data! i=%u\n", i); return; } /* end if */ wdata[i].len = i + 1; - for(t1 = (hvl_t *)wdata[i].p, j = 0; j < (i + 1); j++, t1++) { + for (t1 = (hvl_t *)wdata[i].p, j = 0; j < (i + 1); j++, t1++) { t1->p = (unsigned *)HDmalloc((j + 1) * sizeof(unsigned)); - if(t1->p == NULL) { - HDprintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); + if (t1->p == NULL) { + HDprintf("Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); return; } /* end if */ - t1->len=j+1; - for(k=0; k<(j+1); k++) - ((unsigned int *)t1->p)[k]=i*100+j*10+k; + t1->len = j + 1; + for (k = 0; k < (j + 1); k++) + ((unsigned int *)t1->p)[k] = i * 100 + j * 10 + k; } /* end for */ - } /* end for */ + } /* end for */ /* Create file */ fid1 = H5Fcreate(FILE22, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -2740,7 +2817,7 @@ gent_vldatatypes2(void) HDassert(ret >= 0); /* Reclaim the write VL data */ - ret = H5Dvlen_reclaim(tid2, sid1, H5P_DEFAULT, wdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, wdata); HDassert(ret >= 0); /* Close Dataset */ @@ -2754,32 +2831,32 @@ gent_vldatatypes2(void) HDassert(ret >= 0); ret = H5Fclose(fid1); HDassert(ret >= 0); - } -static void gent_vldatatypes3(void) +static void +gent_vldatatypes3(void) { - typedef struct { /* Struct that the VL sequences are composed of */ - int i; + typedef struct { /* Struct that the VL sequences are composed of */ + int i; float f; hvl_t v; } s1; - s1 wdata[SPACE1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1, tid2; /* Datatype IDs */ - hsize_t dims1[] = {SPACE1_DIM1}; - unsigned i,j; /* counting variables */ - herr_t ret; /* Generic return value */ + s1 wdata[SPACE1_DIM1]; /* Information to write */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1, tid2; /* Datatype IDs */ + hsize_t dims1[] = {SPACE1_DIM1}; + unsigned i, j; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Allocate and initialize VL data to write */ - for(i=0; i<SPACE1_DIM1; i++) { - wdata[i].i = (int)(i * 10); - wdata[i].f = (float)((float)(i * 20)/3.0F); - wdata[i].v.p = HDmalloc((size_t)(i + 1) * sizeof(unsigned int)); + for (i = 0; i < SPACE1_DIM1; i++) { + wdata[i].i = (int)(i * 10); + wdata[i].f = (float)((float)(i * 20) / 3.0F); + wdata[i].v.p = HDmalloc((size_t)(i + 1) * sizeof(unsigned int)); wdata[i].v.len = (size_t)(i + 1); - for(j = 0; j < (i + 1); j++) + for (j = 0; j < (i + 1); j++) ((unsigned int *)wdata[i].v.p)[j] = i * 10 + j; } /* end for */ @@ -2811,7 +2888,7 @@ static void gent_vldatatypes3(void) HDassert(ret >= 0); /* Reclaim the write VL data */ - ret = H5Dvlen_reclaim(tid2, sid1, H5P_DEFAULT, wdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, wdata); HDassert(ret >= 0); /* Close Dataset */ @@ -2827,30 +2904,31 @@ static void gent_vldatatypes3(void) HDassert(ret >= 0); } -static void gent_vldatatypes4(void) +static void +gent_vldatatypes4(void) { - typedef struct { /* Struct that the VL sequences are composed of */ - int i; + typedef struct { /* Struct that the VL sequences are composed of */ + int i; float f; } s1; - hvl_t wdata[SPACE1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1, tid2; /* Datatype IDs */ - hsize_t dims1[] = {SPACE1_DIM1}; - unsigned i,j; /* counting variables */ - herr_t ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1]; /* Information to write */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1, tid2; /* Datatype IDs */ + hsize_t dims1[] = {SPACE1_DIM1}; + unsigned i, j; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Allocate and initialize VL data to write */ - for(i=0; i<SPACE1_DIM1; i++) { - wdata[i].p = HDmalloc((i + 1) * sizeof(s1)); + for (i = 0; i < SPACE1_DIM1; i++) { + wdata[i].p = HDmalloc((i + 1) * sizeof(s1)); wdata[i].len = i + 1; - for(j = 0; j < (i + 1); j++) { + for (j = 0; j < (i + 1); j++) { ((s1 *)wdata[i].p)[j].i = (int)(i * 10 + j); ((s1 *)wdata[i].p)[j].f = (float)((float)(i * 20 + j) / 3.0F); } /* end for */ - } /* end for */ + } /* end for */ /* Create file */ fid1 = H5Fcreate(FILE24, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -2878,7 +2956,7 @@ static void gent_vldatatypes4(void) HDassert(ret >= 0); /* Reclaim the write VL data */ - ret = H5Dvlen_reclaim(tid1, sid1, H5P_DEFAULT, wdata); + ret = H5Treclaim(tid1, sid1, H5P_DEFAULT, wdata); HDassert(ret >= 0); /* Close Dataset */ @@ -2895,46 +2973,47 @@ static void gent_vldatatypes4(void) } /* Generate a variable-length dataset with NULL values in it */ -static void gent_vldatatypes5(void) +static void +gent_vldatatypes5(void) { - hvl_t wdata [SPACE1_DIM1]; - hid_t fid1; - hid_t dataset; - hid_t sid1; - hid_t tid1; - hsize_t dims1[] = {SPACE1_DIM1}; - int i,j; /* counting variable */ - herr_t ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1]; + hid_t fid1; + hid_t dataset; + hid_t sid1; + hid_t tid1; + hsize_t dims1[] = {SPACE1_DIM1}; + int i, j; /* counting variable */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* initialize data for dataset */ - for(i=0; i<SPACE1_DIM1; i++) { - if(i%2) { - wdata[i].len=0; - wdata[i].p=NULL; + for (i = 0; i < SPACE1_DIM1; i++) { + if (i % 2) { + wdata[i].len = 0; + wdata[i].p = NULL; } /* end if */ else { wdata[i].len = (size_t)(i + 5); - wdata[i].p = HDmalloc(sizeof(unsigned) * (size_t)(i + 5)); - for(j = 0; j < i + 5; j++) + wdata[i].p = HDmalloc(sizeof(unsigned) * (size_t)(i + 5)); + for (j = 0; j < i + 5; j++) ((unsigned *)wdata[i].p)[j] = (unsigned)(j * 2); } /* end else */ - } /* end for */ + } /* end for */ /* Create file */ fid1 = H5Fcreate(FILE43, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid1>0); + HDassert(fid1 > 0); /* Create dataspace for datasets */ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); - HDassert(sid1>0); + HDassert(sid1 > 0); /* Create a datatype to refer to */ tid1 = H5Tvlen_create(H5T_NATIVE_UINT); - HDassert(tid1>0); + HDassert(tid1 > 0); /* Create a dataset */ dataset = H5Dcreate2(fid1, F43_DSETNAME, tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - HDassert(dataset>0); + HDassert(dataset > 0); ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); HDassert(ret >= 0); @@ -2942,16 +3021,16 @@ static void gent_vldatatypes5(void) ret = H5Dclose(dataset); HDassert(ret >= 0); - ret = H5Dvlen_reclaim(tid1, sid1, H5P_DEFAULT, wdata); + ret = H5Treclaim(tid1, sid1, H5P_DEFAULT, wdata); HDassert(ret >= 0); ret = H5Tclose(tid1); HDassert(ret >= 0); - ret = H5Sclose (sid1); + ret = H5Sclose(sid1); HDassert(ret >= 0); - ret = H5Fclose (fid1); + ret = H5Fclose(fid1); HDassert(ret >= 0); } @@ -2962,43 +3041,43 @@ static void gent_vldatatypes5(void) display array indices every 262 x N (N > 0) based on 2000x1000 dims. */ #define SPACE_ARRAY1BIG_DIM 2000 -#define ARRAY1BIG_DIM 1000 +#define ARRAY1BIG_DIM 1000 -static void gent_array1_big(void) +static void +gent_array1_big(void) { - int *wdata; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hsize_t sdims1[] = {SPACE_ARRAY1BIG_DIM}; - hsize_t tdims1[] = {ARRAY1BIG_DIM}; - int i,j; /* counting variables */ - herr_t ret; /* Generic return value */ - + int * wdata; /* Information to write */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hsize_t sdims1[] = {SPACE_ARRAY1BIG_DIM}; + hsize_t tdims1[] = {ARRAY1BIG_DIM}; + int i, j; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* for region reference dataset */ - hid_t dset2; - hid_t sid2; - hsize_t dims2[] = {SPACE1_DIM1}; - hsize_t start[SPACE1_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE1_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE1_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE1_RANK]; /* Block size of hyperslab */ - hdset_reg_ref_t *wbuf; /* buffer to write to disk */ - - start[0] = 0; + hid_t dset2; + hid_t sid2; + hsize_t dims2[] = {SPACE1_DIM1}; + hsize_t start[SPACE1_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE1_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE1_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE1_RANK]; /* Block size of hyperslab */ + hdset_reg_ref_t *wbuf; /* buffer to write to disk */ + + start[0] = 0; stride[0] = 1; - count[0] = 999; - block[0] = 1; + count[0] = 999; + block[0] = 1; /* Allocate write & read buffers */ - wbuf = (hdset_reg_ref_t*) HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); + wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); wdata = (int *)HDmalloc(sizeof(int) * (size_t)(SPACE_ARRAY1BIG_DIM * ARRAY1BIG_DIM)); /* Allocate and initialize array data to write */ - for(i = 0; i < SPACE_ARRAY1BIG_DIM; i++) - for(j = 0; j < ARRAY1BIG_DIM; j++) + for (i = 0; i < SPACE_ARRAY1BIG_DIM; i++) + for (j = 0; j < ARRAY1BIG_DIM; j++) *(wdata + (i * ARRAY1BIG_DIM) + j) = i * 1; /* Create file */ @@ -3038,7 +3117,7 @@ static void gent_array1_big(void) H5Rcreate(&wbuf[0], fid1, "/Dataset1", H5R_DATASET_REGION, sid1); /* Write selection to disk */ - H5Dwrite(dset2,H5T_STD_REF_DSETREG,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf); + H5Dwrite(dset2, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); /* Close Dataset */ ret = H5Dclose(dataset); @@ -3055,22 +3134,23 @@ static void gent_array1_big(void) HDfree(wdata); } -static void gent_array1(void) +static void +gent_array1(void) { - int wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int i,j; /* counting variables */ - herr_t ret; /* Generic return value */ + int wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int i, j; /* counting variables */ + herr_t ret H5_ATTR_NDEBUG_UNUSED; /* Generic return value */ /* Allocate and initialize array data to write */ - for(i=0; i<SPACE1_DIM1; i++) - for(j=0; j<ARRAY1_DIM1; j++) - wdata[i][j]=i*10+j; + for (i = 0; i < SPACE1_DIM1; i++) + for (j = 0; j < ARRAY1_DIM1; j++) + wdata[i][j] = i * 10 + j; /* Create file */ fid1 = H5Fcreate(FILE25, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -3099,24 +3179,25 @@ static void gent_array1(void) HDassert(ret >= 0); } -static void gent_array2(void) +static void +gent_array2(void) { - int wdata[SPACE1_DIM1][ARRAY2_DIM1][ARRAY2_DIM2][ARRAY2_DIM3]; /* Information to write */ - hid_t fid; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid; /* Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims2[] = {ARRAY2_DIM1,ARRAY2_DIM2,ARRAY2_DIM3}; - int i,j,k,l; /* counting variables */ - herr_t ret; /* Generic return value */ + int wdata[SPACE1_DIM1][ARRAY2_DIM1][ARRAY2_DIM2][ARRAY2_DIM3]; /* Information to write */ + hid_t fid; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid; /* Datatype ID */ + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims2[] = {ARRAY2_DIM1, ARRAY2_DIM2, ARRAY2_DIM3}; + int i, j, k, l; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Allocate and initialize array data to write */ - for(i=0; i<SPACE1_DIM1; i++) - for(j=0; j<ARRAY2_DIM1; j++) - for(k=0; k<ARRAY2_DIM2; k++) - for(l=0; l<ARRAY2_DIM3; l++) - wdata[i][j][k][l]=i*1000+j*100+k*10+l; + for (i = 0; i < SPACE1_DIM1; i++) + for (j = 0; j < ARRAY2_DIM1; j++) + for (k = 0; k < ARRAY2_DIM2; k++) + for (l = 0; l < ARRAY2_DIM3; l++) + wdata[i][j][k][l] = i * 1000 + j * 100 + k * 10 + l; /* Create file */ fid = H5Fcreate(FILE26, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -3145,26 +3226,27 @@ static void gent_array2(void) HDassert(ret >= 0); } -static void gent_array3(void) +static void +gent_array3(void) { - int wdata[SPACE1_DIM1][ARRAY1_DIM1][ARRAY3_DIM1][ARRAY3_DIM2]; /* Information to write */ - hid_t fid; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid1; /* 1-D array Datatype ID */ - hid_t tid2; /* 2-D array Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - hsize_t tdims2[] = {ARRAY3_DIM1,ARRAY3_DIM2}; - int i,j,k,l; /* counting variables */ - herr_t ret; /* Generic return value */ + int wdata[SPACE1_DIM1][ARRAY1_DIM1][ARRAY3_DIM1][ARRAY3_DIM2]; /* Information to write */ + hid_t fid; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid1; /* 1-D array Datatype ID */ + hid_t tid2; /* 2-D array Datatype ID */ + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + hsize_t tdims2[] = {ARRAY3_DIM1, ARRAY3_DIM2}; + int i, j, k, l; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Allocate and initialize array data to write */ - for(i=0; i<SPACE1_DIM1; i++) - for(j=0; j<ARRAY1_DIM1; j++) - for(k=0; k<ARRAY3_DIM1; k++) - for(l=0; l<ARRAY3_DIM2; l++) - wdata[i][j][k][l]=i*1000+j*100+k*10+l; + for (i = 0; i < SPACE1_DIM1; i++) + for (j = 0; j < ARRAY1_DIM1; j++) + for (k = 0; k < ARRAY3_DIM1; k++) + for (l = 0; l < ARRAY3_DIM2; l++) + wdata[i][j][k][l] = i * 1000 + j * 100 + k * 10 + l; /* Create file */ fid = H5Fcreate(FILE27, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -3198,26 +3280,27 @@ static void gent_array3(void) HDassert(ret >= 0); } -static void gent_array4(void) +static void +gent_array4(void) { - typedef struct { /* Typedef for compound datatype */ - int i; - float f; + typedef struct { /* Typedef for compound datatype */ + int i; + float f; } s2_t; - s2_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Array Datatype ID */ - hid_t tid2; /* Compound Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int i,j; /* counting variables */ - herr_t ret; /* Generic return value */ + s2_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Array Datatype ID */ + hid_t tid2; /* Compound Datatype ID */ + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int i, j; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Initialize array data to write */ - for(i=0; i<SPACE1_DIM1; i++) - for(j=0; j<ARRAY1_DIM1; j++) { + for (i = 0; i < SPACE1_DIM1; i++) + for (j = 0; j < ARRAY1_DIM1; j++) { wdata[i][j].i = i * 10 + j; wdata[i][j].f = (float)((float)i * 2.5F + (float)j); } /* end for */ @@ -3264,29 +3347,30 @@ static void gent_array4(void) HDassert(ret >= 0); } -static void gent_array5(void) +static void +gent_array5(void) { - typedef struct { /* Typedef for compound datatype */ - int i; - float f[ARRAY1_DIM1]; + typedef struct { /* Typedef for compound datatype */ + int i; + float f[ARRAY1_DIM1]; } s2_t; - s2_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Array Datatype ID */ - hid_t tid2; /* Compound Datatype ID */ - hid_t tid3; /* Nested Array Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int i,j,k; /* counting variables */ - herr_t ret; /* Generic return value */ + s2_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Array Datatype ID */ + hid_t tid2; /* Compound Datatype ID */ + hid_t tid3; /* Nested Array Datatype ID */ + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int i, j, k; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Initialize array data to write */ - for(i=0; i<SPACE1_DIM1; i++) - for(j=0; j<ARRAY1_DIM1; j++) { + for (i = 0; i < SPACE1_DIM1; i++) + for (j = 0; j < ARRAY1_DIM1; j++) { wdata[i][j].i = i * 10 + j; - for(k=0; k<ARRAY1_DIM1; k++) + for (k = 0; k < ARRAY1_DIM1; k++) wdata[i][j].f[k] = (float)((float)i * 10 + (float)j * 2.5F + (float)k); } /* end for */ @@ -3300,14 +3384,14 @@ static void gent_array5(void) tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s2_t)); /* Insert integer field */ - ret = H5Tinsert (tid2, "i", HOFFSET(s2_t,i), H5T_NATIVE_INT); + ret = H5Tinsert(tid2, "i", HOFFSET(s2_t, i), H5T_NATIVE_INT); HDassert(ret >= 0); /* Create an array of floats datatype */ tid3 = H5Tarray_create2(H5T_NATIVE_FLOAT, ARRAY1_RANK, tdims1); /* Insert float array field */ - ret = H5Tinsert (tid2, "f", HOFFSET(s2_t,f), tid3); + ret = H5Tinsert(tid2, "f", HOFFSET(s2_t, f), tid3); HDassert(ret >= 0); /* Close array of floats field datatype */ @@ -3339,25 +3423,26 @@ static void gent_array5(void) HDassert(ret >= 0); } -static void gent_array6(void) +static void +gent_array6(void) { - hvl_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Array Datatype ID */ - hid_t tid2; /* VL Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int i,j,k; /* counting variables */ - herr_t ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Array Datatype ID */ + hid_t tid2; /* VL Datatype ID */ + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int i, j, k; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Initialize array data to write */ - for(i=0; i<SPACE1_DIM1; i++) - for(j=0; j<ARRAY1_DIM1; j++) { - wdata[i][j].p = HDmalloc((size_t)(i + j + 1) * sizeof(unsigned int)); + for (i = 0; i < SPACE1_DIM1; i++) + for (j = 0; j < ARRAY1_DIM1; j++) { + wdata[i][j].p = HDmalloc((size_t)(i + j + 1) * sizeof(unsigned int)); wdata[i][j].len = (size_t)(i + j + 1); - for(k = 0; k < (i + j + 1); k++) + for (k = 0; k < (i + j + 1); k++) ((unsigned int *)wdata[i][j].p)[k] = (unsigned)(i * 100 + j * 10 + k); } /* end for */ @@ -3385,7 +3470,7 @@ static void gent_array6(void) HDassert(ret >= 0); /* Reclaim the write VL data */ - ret = H5Dvlen_reclaim(tid1, sid1, H5P_DEFAULT, wdata); + ret = H5Treclaim(tid1, sid1, H5P_DEFAULT, wdata); HDassert(ret >= 0); /* Close Dataset */ @@ -3399,28 +3484,30 @@ static void gent_array6(void) HDassert(ret >= 0); } -static void gent_array7(void) +static void +gent_array7(void) { - hvl_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Array Datatype ID */ - hid_t tid2; /* VL Datatype ID */ - hid_t tid3; /* Nested Array Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int i,j,k,l; /* Index variables */ - herr_t ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Array Datatype ID */ + hid_t tid2; /* VL Datatype ID */ + hid_t tid3; /* Nested Array Datatype ID */ + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int i, j, k, l; /* Index variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Initialize array data to write */ - for(i=0; i<SPACE1_DIM1; i++) - for(j=0; j<ARRAY1_DIM1; j++) { - wdata[i][j].p = HDmalloc((size_t)(i + j + 1) * (sizeof(unsigned int) * ARRAY1_DIM1)); + for (i = 0; i < SPACE1_DIM1; i++) + for (j = 0; j < ARRAY1_DIM1; j++) { + wdata[i][j].p = HDmalloc((size_t)(i + j + 1) * (sizeof(unsigned int) * ARRAY1_DIM1)); wdata[i][j].len = (size_t)(i + j + 1); - for(k = 0; k < (i + j + 1); k++) - for(l = 0; l<ARRAY1_DIM1; l++) - ((unsigned int *)wdata[i][j].p)[k * ARRAY1_DIM1 + l] = (unsigned)(i * 1000+j * 100+k * 10 + l); + for (k = 0; k < (i + j + 1); k++) + for (l = 0; l < ARRAY1_DIM1; l++) + ((unsigned int *)wdata[i][j].p)[k * ARRAY1_DIM1 + l] = + (unsigned)(i * 1000 + j * 100 + k * 10 + l); } /* end for */ /* Create file */ @@ -3454,7 +3541,7 @@ static void gent_array7(void) HDassert(ret >= 0); /* Reclaim the write VL data */ - ret = H5Dvlen_reclaim(tid1, sid1, H5P_DEFAULT, wdata); + ret = H5Treclaim(tid1, sid1, H5P_DEFAULT, wdata); HDassert(ret >= 0); /* Close Dataset */ @@ -3469,17 +3556,18 @@ static void gent_array7(void) } /* Test the boundary of the display output buffer at the reallocation event */ -static void gent_array8(void) +static void +gent_array8(void) { - hid_t file = -1; /* Handles */ - hid_t filetype = -1; /* Handles */ - hid_t space = -1; /* Handles */ - hid_t dset = -1; /* Handles */ - herr_t status = -1; - hsize_t sdims[] = {F64_DIM0}; - hsize_t tdims[] = {F64_DIM1}; - int *wdata; /* Write buffer */ - unsigned int i; + hid_t file = H5I_INVALID_HID; /* Handles */ + hid_t filetype = H5I_INVALID_HID; /* Handles */ + hid_t space = H5I_INVALID_HID; /* Handles */ + hid_t dset = H5I_INVALID_HID; /* Handles */ + herr_t H5_ATTR_NDEBUG_UNUSED status = -1; + hsize_t sdims[] = {F64_DIM0}; + hsize_t tdims[] = {F64_DIM1}; + int * wdata; /* Write buffer */ + unsigned int i; /* Allocate data buffer */ wdata = (int *)HDmalloc(F64_DIM1 * sizeof(int)); @@ -3495,54 +3583,54 @@ static void gent_array8(void) /* * Create a new file using the default properties. */ - file = H5Fcreate (F64_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(F64_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* * Create array datatypes for file and memory. */ - filetype = H5Tarray_create2 (H5T_NATIVE_INT, 1, tdims); + filetype = H5Tarray_create2(H5T_NATIVE_INT, 1, tdims); /* * Create dataspace. Setting maximum size to NULL sets the maximum * size to be the current size. */ - space = H5Screate_simple (1, sdims, NULL); + space = H5Screate_simple(1, sdims, NULL); /* * Create the dataset and write the array data to it. */ - if(file>=0 && filetype>=0 && space>=0) { - dset = H5Dcreate2 (file, F64_DATASET, filetype, space, H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT); - if(dset>=0) - status = H5Dwrite (dset, filetype, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - HDassert(status >= 0); + if (file >= 0 && filetype >= 0 && space >= 0) { + dset = H5Dcreate2(file, F64_DATASET, filetype, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (dset >= 0) + status = H5Dwrite(dset, filetype, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); + HDassert(status >= 0); } /* * Close and release resources. */ - status = H5Dclose (dset); + status = H5Dclose(dset); HDassert(status >= 0); - status = H5Sclose (space); + status = H5Sclose(space); HDassert(status >= 0); - status = H5Tclose (filetype); + status = H5Tclose(filetype); HDassert(status >= 0); - status = H5Fclose (file); + status = H5Fclose(file); HDassert(status >= 0); HDfree(wdata); } -static void gent_empty(void) +static void +gent_empty(void) { typedef struct { - int a; - float b; - char c; + int a; + float b; + char c; } empty_struct; - hid_t file, dset, space, type; - hsize_t dims[] = { SPACE1_DIM1 }; - herr_t ret=0; + hid_t file, dset, space, type; + hsize_t dims[] = {SPACE1_DIM1}; + herr_t H5_ATTR_NDEBUG_UNUSED ret = 0; file = H5Fcreate(FILE32, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -3579,10 +3667,10 @@ static void gent_empty(void) HDassert(ret >= 0); /* write out an empty compound dataset */ - type = H5Tcreate(H5T_COMPOUND,sizeof(empty_struct)); - H5Tinsert(type, "a", HOFFSET(empty_struct, a),H5T_NATIVE_INT); - H5Tinsert(type, "b", HOFFSET(empty_struct, b),H5T_NATIVE_FLOAT); - H5Tinsert(type, "c", HOFFSET(empty_struct, c),H5T_NATIVE_CHAR); + type = H5Tcreate(H5T_COMPOUND, sizeof(empty_struct)); + H5Tinsert(type, "a", HOFFSET(empty_struct, a), H5T_NATIVE_INT); + H5Tinsert(type, "b", HOFFSET(empty_struct, b), H5T_NATIVE_FLOAT); + H5Tinsert(type, "c", HOFFSET(empty_struct, c), H5T_NATIVE_CHAR); dset = H5Dcreate2(file, "Dataset5.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* Don't write any data */ ret = H5Dclose(dset); @@ -3600,78 +3688,100 @@ static void gent_empty(void) static void gent_group_comments(void) { - hid_t fid, group; + hid_t fid = H5I_INVALID_HID; + hid_t group = H5I_INVALID_HID; + uint64_t supports_comments = 0; fid = H5Fcreate(FILE33, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + /* Check if we support comments in the current VOL connector */ + H5VLquery_optional(fid, H5VL_SUBCLS_OBJECT, H5VL_NATIVE_OBJECT_SET_COMMENT, &supports_comments); + /* / */ group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g1", "Comment for group /g1", H5P_DEFAULT); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) + H5Oset_comment_by_name(group, "/g1", "Comment for group /g1", H5P_DEFAULT); H5Gclose(group); group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g2", "Comment for group /g2", H5P_DEFAULT); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) + H5Oset_comment_by_name(group, "/g2", "Comment for group /g2", H5P_DEFAULT); H5Gclose(group); group = H5Gcreate2(fid, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g3", "Comment for group /g3", H5P_DEFAULT); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) + H5Oset_comment_by_name(group, "/g3", "Comment for group /g3", H5P_DEFAULT); H5Gclose(group); /* /g1 */ group = H5Gcreate2(fid, "/g1/g1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g1/g1.1", "Comment for group /g1/g1.1", H5P_DEFAULT); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) + H5Oset_comment_by_name(group, "/g1/g1.1", "Comment for group /g1/g1.1", H5P_DEFAULT); H5Gclose(group); group = H5Gcreate2(fid, "/g1/g1.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g1/g1.2", "Comment for group /g1/g1.2", H5P_DEFAULT); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) + H5Oset_comment_by_name(group, "/g1/g1.2", "Comment for group /g1/g1.2", H5P_DEFAULT); H5Gclose(group); /* /g2 */ group = H5Gcreate2(fid, "/g2/g2.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g2/g2.1", "Comment for group /g2/g2.1", H5P_DEFAULT); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) + H5Oset_comment_by_name(group, "/g2/g2.1", "Comment for group /g2/g2.1", H5P_DEFAULT); H5Gclose(group); /* /g3 */ group = H5Gcreate2(fid, "/g3/g3.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g3/g3.1", "Comment for group /g3/g3.1", H5P_DEFAULT); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) + H5Oset_comment_by_name(group, "/g3/g3.1", "Comment for group /g3/g3.1", H5P_DEFAULT); H5Gclose(group); group = H5Gcreate2(fid, "/g3/g3.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g3/g3.2", "Comment for group /g3/g3.2", H5P_DEFAULT); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) + H5Oset_comment_by_name(group, "/g3/g3.2", "Comment for group /g3/g3.2", H5P_DEFAULT); H5Gclose(group); group = H5Gcreate2(fid, "/g3/g3.3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g3/g3.3", "Comment for group /g3/g3.3", H5P_DEFAULT); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) + H5Oset_comment_by_name(group, "/g3/g3.3", "Comment for group /g3/g3.3", H5P_DEFAULT); H5Gclose(group); group = H5Gcreate2(fid, "/g3/g3.4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g3/g3.4", "Comment for group /g3/g3.4", H5P_DEFAULT); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) + H5Oset_comment_by_name(group, "/g3/g3.4", "Comment for group /g3/g3.4", H5P_DEFAULT); H5Gclose(group); /* /g2/g2.1 */ group = H5Gcreate2(fid, "/g2/g2.1/g2.1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g2/g2.1/g2.1.1", "Comment for group /g2/g2.1/g2.1.1", H5P_DEFAULT); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) + H5Oset_comment_by_name(group, "/g2/g2.1/g2.1.1", "Comment for group /g2/g2.1/g2.1.1", H5P_DEFAULT); H5Gclose(group); group = H5Gcreate2(fid, "/g2/g2.1/g2.1.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g2/g2.1/g2.1.2", "Comment for group /g2/g2.1/g2.1.2", H5P_DEFAULT); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) + H5Oset_comment_by_name(group, "/g2/g2.1/g2.1.2", "Comment for group /g2/g2.1/g2.1.2", H5P_DEFAULT); H5Gclose(group); group = H5Gcreate2(fid, "/g2/g2.1/g2.1.3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g2/g2.1/g2.1.3", "Comment for group /g2/g2.1/g2.1.3", H5P_DEFAULT); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) + H5Oset_comment_by_name(group, "/g2/g2.1/g2.1.3", "Comment for group /g2/g2.1/g2.1.3", H5P_DEFAULT); H5Gclose(group); /* /glongcomment */ group = H5Gcreate2(fid, "/glongcomment", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/glongcomment", "Comment for group /glongcomment with a really, really, really long, long, long comment", H5P_DEFAULT); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) + H5Oset_comment_by_name( + group, "/glongcomment", + "Comment for group /glongcomment with a really, really, really long, long, long comment", + H5P_DEFAULT); H5Gclose(group); H5Fclose(fid); } -static -void gent_split_file(void) +static void +gent_split_file(void) { - hid_t fapl, fid, root, attr, space, dataset, atype; - char meta[] = "this is some metadata on this file"; + hid_t fapl, fid, root, attr, space, dataset, atype; + char meta[] = "this is some metadata on this file"; hsize_t dims[2]; - int i, j, dset[10][15]; + int i, j, dset[10][15]; fapl = H5Pcreate(H5P_FILE_ACCESS); H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT); - fid = H5Fcreate(FILE34, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + fid = H5Fcreate(FILE34, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); root = H5Gopen2(fid, "/", H5P_DEFAULT); atype = H5Tcopy(H5T_C_S1); @@ -3679,8 +3789,8 @@ void gent_split_file(void) H5Tset_strpad(atype, H5T_STR_NULLTERM); dims[0] = 1; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(root, "Metadata", atype, space, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(root, "Metadata", atype, space, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, atype, meta); H5Tclose(atype); H5Sclose(space); @@ -3689,11 +3799,11 @@ void gent_split_file(void) /* create dataset */ dims[0] = 10; dims[1] = 15; - space = H5Screate_simple(2, dims, NULL); + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 15; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 15; j++) dset[i][j] = i + j; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset); @@ -3704,14 +3814,14 @@ void gent_split_file(void) H5Pclose(fapl); } -static -void gent_family(void) +static void +gent_family(void) { - hid_t fapl, fid, space, dataset; + hid_t fapl, fid, space, dataset; hsize_t dims[2]; - int i, j, dset[10][15]; + int i, j, dset[10][15]; -#define FAMILY_SIZE 256 +#define FAMILY_SIZE 256 fapl = H5Pcreate(H5P_FILE_ACCESS); H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT); @@ -3721,11 +3831,11 @@ void gent_family(void) /* create dataset */ dims[0] = 10; dims[1] = 15; - space = H5Screate_simple(2, dims, NULL); + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 15; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 15; j++) dset[i][j] = i + j; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset); @@ -3737,19 +3847,25 @@ void gent_family(void) static const char *multi_letters = "msbrglo"; -static -void gent_multi(void) +static void +gent_multi(void) { - hid_t fapl, fid, space, dataset; + hid_t fapl, fid, space, dataset; hsize_t dims[2]; - int i, j, dset[10][15]; + int i, j, dset[10][15]; /* Multi-file driver, general case of the split driver */ - H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; + H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; + hid_t memb_fapl[H5FD_MEM_NTYPES]; const char *memb_name[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][1024]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; + char ** sv = NULL; + char * sv_data = NULL; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + + sv_data = (char *)HDcalloc(H5FD_MEM_NTYPES * 1024, sizeof(char)); + sv = (char **)HDcalloc(H5FD_MEM_NTYPES, sizeof(sv_data)); + for (i = 0; i < H5FD_MEM_NTYPES; i++) + sv[i] = sv_data + (i * 1024); fapl = H5Pcreate(H5P_FILE_ACCESS); @@ -3760,9 +3876,9 @@ void gent_multi(void) HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES); - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { memb_fapl[mt] = H5P_DEFAULT; - memb_map[mt] = mt; + memb_map[mt] = mt; HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); memb_name[mt] = sv[mt]; /*HDprintf("memb_name[%d]=%s, memb_map[%d]=%d; ", mt, memb_name[mt], mt, memb_map[mt]);*/ @@ -3770,19 +3886,18 @@ void gent_multi(void) } memb_map[H5FD_MEM_DEFAULT] = H5FD_MEM_SUPER; - H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, - memb_addr, FALSE); + H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE); fid = H5Fcreate(FILE36, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); /* create dataset */ dims[0] = 10; dims[1] = 15; - space = H5Screate_simple(2, dims, NULL); + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 15; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 15; j++) dset[i][j] = i + j; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset); @@ -3791,19 +3906,23 @@ void gent_multi(void) H5Dclose(dataset); H5Fclose(fid); H5Pclose(fapl); + + HDfree(sv); + HDfree(sv_data); } -static void gent_large_objname(void) +static void +gent_large_objname(void) { hid_t fid, group, group2; - char grp_name[128]; - register int i; + char grp_name[128]; + int i; fid = H5Fcreate(FILE37, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); group = H5Gcreate2(fid, "this_is_a_large_group_name", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 50; ++i) { + for (i = 0; i < 50; ++i) { HDsprintf(grp_name, "this_is_a_large_group_name%d", i); group2 = H5Gcreate2(group, grp_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Gclose(group2); @@ -3813,20 +3932,19 @@ static void gent_large_objname(void) H5Fclose(fid); } -static void gent_vlstr(void) +static void +gent_vlstr(void) { - const char *wdata[SPACE1_DIM1]= { - "Four score and seven years ago our forefathers brought forth on this continent a new nation,", - "conceived in liberty and dedicated to the proposition that all men are created equal.", - "", - NULL - }; /* Information to write */ - const char *string_att= "This is the string for the attribute"; - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, root; /* Dataset ID */ - hid_t sid1, dataspace;/* Dataspace ID */ - hid_t tid1, att; /* Datatype ID */ - hsize_t dims1[] = {SPACE1_DIM1}; + const char *wdata[SPACE1_DIM1] = { + "Four score and seven years ago our forefathers brought forth on this continent a new nation,", + "conceived in liberty and dedicated to the proposition that all men are created equal.", "", + NULL}; /* Information to write */ + const char *string_att = "This is the string for the attribute"; + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, root; /* Dataset ID */ + hid_t sid1, dataspace; /* Dataspace ID */ + hid_t tid1, att; /* Datatype ID */ + hsize_t dims1[] = {SPACE1_DIM1}; /* Create file */ fid1 = H5Fcreate(FILE38, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -3834,8 +3952,8 @@ static void gent_vlstr(void) sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); /* Create a VL string datatype to refer to */ - tid1 = H5Tcopy (H5T_C_S1); - H5Tset_size (tid1, H5T_VARIABLE); + tid1 = H5Tcopy(H5T_C_S1); + H5Tset_size(tid1, H5T_VARIABLE); /* Create a dataset and write VL string to it. */ dataset = H5Dcreate2(fid1, "Dataset1", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -3847,7 +3965,7 @@ static void gent_vlstr(void) H5Tcommit2(fid1, "vl_string_type", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* Create an group attribute of VL string type */ - root = H5Gopen2(fid1, "/", H5P_DEFAULT); + root = H5Gopen2(fid1, "/", H5P_DEFAULT); dataspace = H5Screate(H5S_SCALAR); att = H5Acreate2(root, "test_scalar", tid1, dataspace, H5P_DEFAULT, H5P_DEFAULT); @@ -3862,19 +3980,19 @@ static void gent_vlstr(void) H5Fclose(fid1); } -static void gent_char(void) +static void +gent_char(void) { - const char *wdata = - "Four score and seven years ago our forefathers brought " - "forth on this continent a new nation, conceived in " - "liberty and dedicated to the proposition that all " - "men are created equal. Now we are engaged in a great " - "civil war, testing whether that nation or any nation " - "so conceived and so dedicated can long endure."; - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hsize_t dims1[1]; + const char *wdata = "Four score and seven years ago our forefathers brought " + "forth on this continent a new nation, conceived in " + "liberty and dedicated to the proposition that all " + "men are created equal. Now we are engaged in a great " + "civil war, testing whether that nation or any nation " + "so conceived and so dedicated can long endure."; + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hsize_t dims1[1]; dims1[0] = HDstrlen(wdata); @@ -3894,8 +4012,6 @@ static void gent_char(void) H5Fclose(fid1); } - - /*------------------------------------------------------------------------- * Function: write_attr_in * @@ -3903,73 +4019,66 @@ static void gent_char(void) * * Return: void * - * Programmer: pvn@ncsa.uiuc.edu + * Programmer: Pedro Vicente * * Date: May 28, 2003 * *------------------------------------------------------------------------- */ -static void write_attr_in(hid_t loc_id, - const char* dset_name, /* for saving reference to dataset*/ - hid_t fid) +static void +write_attr_in(hid_t loc_id, const char *dset_name, /* for saving reference to dataset*/ + hid_t fid) { /* Compound datatype */ - typedef struct s_t - { - char a; - double b; + typedef struct s_t { + char a; + double b; } s_t; - typedef enum - { - E_RED, - E_GREEN - } e_t; + typedef enum { E_RED, E_GREEN } e_t; - hid_t aid; - hid_t sid; - hid_t tid; - herr_t status; - int val, i, j, k, n; - float f; + hid_t aid; + hid_t sid; + hid_t tid; + herr_t H5_ATTR_NDEBUG_UNUSED status; + int val, i, j, k, n; + float f; /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1]={2}; - char buf1[2][3]= {"ab","de"}; /* string */ - char buf2[2]= {1,2}; /* bitfield, opaque */ - s_t buf3[2]= {{1,2},{3,4}}; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - hvl_t buf5[2]; /* vlen */ - hsize_t dimarray[1]={3}; /* array dimension */ - int buf6[2][3]= {{1,2,3},{4,5,6}}; /* array */ - int buf7[2]= {1,2}; /* integer */ - float buf8[2]= {1,2}; /* float */ + hsize_t dims[1] = {2}; + char buf1[2][3] = {"ab", "de"}; /* string */ + char buf2[2] = {1, 2}; /* bitfield, opaque */ + s_t buf3[2] = {{1, 2}, {3, 4}}; /* compound */ + hobj_ref_t buf4[2]; /* reference */ + hvl_t buf5[2]; /* vlen */ + hsize_t dimarray[1] = {3}; /* array dimension */ + int buf6[2][3] = {{1, 2, 3}, {4, 5, 6}}; /* array */ + int buf7[2] = {1, 2}; /* integer */ + float buf8[2] = {1, 2}; /* float */ /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2]={3,2}; - char buf12[6][3]= {"ab","cd","ef","gh","ij","kl"}; /* string */ - char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */ - s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */ - hobj_ref_t buf42[3][2]; /* reference */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; /* array */ - int buf72[3][2]= {{1,2},{3,4},{5,6}}; /* integer */ - float buf82[3][2]= {{1,2},{3,4},{5,6}}; /* float */ + hsize_t dims2[2] = {3, 2}; + char buf12[6][3] = {"ab", "cd", "ef", "gh", "ij", "kl"}; /* string */ + char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */ + s_t buf32[6] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}}; /* compound */ + hobj_ref_t buf42[3][2]; /* reference */ + hvl_t buf52[3][2]; /* vlen */ + int buf62[6][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}, {16, 17, 18}}; /* array */ + int buf72[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* integer */ + float buf82[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* float */ /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3]={4,3,2}; - char buf13[24][3]= {"ab","cd","ef","gh","ij","kl","mn","pq", - "rs","tu","vw","xz","AB","CD","EF","GH", - "IJ","KL","MN","PQ","RS","TU","VW","XZ"}; /* string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[4][3][2]; /* reference */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ - + hsize_t dims3[3] = {4, 3, 2}; + char buf13[24][3] = {"ab", "cd", "ef", "gh", "ij", "kl", "mn", "pq", "rs", "tu", "vw", "xz", + "AB", "CD", "EF", "GH", "IJ", "KL", "MN", "PQ", "RS", "TU", "VW", "XZ"}; /* string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[4][3][2]; /* reference */ + hvl_t buf53[4][3][2]; /* vlen */ + int buf63[24][3]; /* array */ + int buf73[4][3][2]; /* integer */ + float buf83[4][3][2]; /* float */ /*------------------------------------------------------------------------- * 1D attributes @@ -3980,9 +4089,9 @@ static void write_attr_in(hid_t loc_id, * H5T_STRING *------------------------------------------------------------------------- */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_attr(loc_id,1,dims,"string",tid,buf1); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, 2); + write_attr(loc_id, 1, dims, "string", tid, buf1); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -3990,26 +4099,26 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcopy(H5T_STD_B8LE); - write_attr(loc_id,1,dims,"bitfield",tid,buf2); + write_attr(loc_id, 1, dims, "bitfield", tid, buf2); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - tid = H5Tcreate(H5T_OPAQUE, 1); + tid = H5Tcreate(H5T_OPAQUE, 1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_attr(loc_id,1,dims,"opaque",tid,buf2); + write_attr(loc_id, 1, dims, "opaque", tid, buf2); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- */ - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); + tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_attr(loc_id,1,dims,"compound",tid,buf3); + write_attr(loc_id, 1, dims, "compound", tid, buf3); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4017,11 +4126,10 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ /* Create references to dataset */ - if(dset_name) - { - status=H5Rcreate(&buf4[0],fid,dset_name,H5R_OBJECT,(hid_t)-1); - status=H5Rcreate(&buf4[1],fid,dset_name,H5R_OBJECT,(hid_t)-1); - write_attr(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4); + if (dset_name) { + status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t)-1); + write_attr(loc_id, 1, dims, "reference", H5T_STD_REF_OBJ, buf4); } /*------------------------------------------------------------------------- @@ -4029,9 +4137,9 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); + H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_attr(loc_id,1,dims,"enum",tid,0); + write_attr(loc_id, 1, dims, "enum", tid, 0); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4041,20 +4149,20 @@ static void write_attr_in(hid_t loc_id, /* Allocate and initialize VL dataset to write */ - buf5[0].len = 1; - buf5[0].p = HDmalloc(1 * 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)); + buf5[1].len = 2; + buf5[1].p = HDmalloc(2 * sizeof(int)); ((int *)buf5[1].p)[0] = 2; ((int *)buf5[1].p)[1] = 3; - sid = H5Screate_simple(1, dims, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf5); HDassert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5); + status = H5Treclaim(tid, sid, H5P_DEFAULT, buf5); HDassert(status >= 0); status = H5Aclose(aid); status = H5Tclose(tid); @@ -4075,7 +4183,6 @@ static void write_attr_in(hid_t loc_id, write_attr(loc_id, 1, dims, "integer", H5T_NATIVE_INT, buf7); write_attr(loc_id, 1, dims, "float", H5T_NATIVE_FLOAT, buf8); - /*------------------------------------------------------------------------- * 2D attributes *------------------------------------------------------------------------- @@ -4085,9 +4192,9 @@ static void write_attr_in(hid_t loc_id, * H5T_STRING *------------------------------------------------------------------------- */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_attr(loc_id,2,dims2,"string2D",tid,buf12); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, 2); + write_attr(loc_id, 2, dims2, "string2D", tid, buf12); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4095,26 +4202,26 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcopy(H5T_STD_B8LE); - write_attr(loc_id,2,dims2,"bitfield2D",tid,buf22); + write_attr(loc_id, 2, dims2, "bitfield2D", tid, buf22); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - tid = H5Tcreate(H5T_OPAQUE, 1); + tid = H5Tcreate(H5T_OPAQUE, 1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_attr(loc_id,2,dims2,"opaque2D",tid,buf22); + write_attr(loc_id, 2, dims2, "opaque2D", tid, buf22); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- */ - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); + tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_attr(loc_id,2,dims2,"compound2D",tid,buf32); + write_attr(loc_id, 2, dims2, "compound2D", tid, buf32); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4122,14 +4229,13 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ /* Create references to dataset */ - if(dset_name) - { - for(i = 0; i < 3; i++) { - for(j = 0; j < 2; j++) { - status=H5Rcreate(&buf42[i][j],fid,dset_name,H5R_OBJECT,(hid_t)-1); + if (dset_name) { + for (i = 0; i < 3; i++) { + for (j = 0; j < 2; j++) { + status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t)-1); } } - write_attr(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42); + write_attr(loc_id, 2, dims2, "reference2D", H5T_STD_REF_OBJ, buf42); } /*------------------------------------------------------------------------- @@ -4137,9 +4243,9 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); + H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_attr(loc_id,2,dims2,"enum2D",tid,0); + write_attr(loc_id, 2, dims2, "enum2D", tid, 0); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4148,24 +4254,24 @@ static void write_attr_in(hid_t loc_id, */ /* 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++) { int l; - buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) + for (l = 0; l < i + 1; l++) ((int *)buf52[i][j].p)[l] = n++; } } - sid = H5Screate_simple(2, dims2, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(2, dims2, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf52); HDassert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52); + status = H5Treclaim(tid, sid, H5P_DEFAULT, buf52); HDassert(status >= 0); status = H5Aclose(aid); status = H5Tclose(tid); @@ -4186,7 +4292,6 @@ static void write_attr_in(hid_t loc_id, write_attr(loc_id, 2, dims2, "integer2D", H5T_NATIVE_INT, buf72); write_attr(loc_id, 2, dims2, "float2D", H5T_NATIVE_FLOAT, buf82); - /*------------------------------------------------------------------------- * 3D attributes *------------------------------------------------------------------------- @@ -4196,9 +4301,9 @@ static void write_attr_in(hid_t loc_id, * H5T_STRING *------------------------------------------------------------------------- */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_attr(loc_id,3,dims3,"string3D",tid,buf13); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, 2); + write_attr(loc_id, 3, dims3, "string3D", tid, buf13); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4206,25 +4311,25 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ - n=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { + n = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { buf23[i][j][k] = (char)n++; } } } tid = H5Tcopy(H5T_STD_B8LE); - write_attr(loc_id,3,dims3,"bitfield3D",tid,buf23); + write_attr(loc_id, 3, dims3, "bitfield3D", tid, buf23); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - tid = H5Tcreate(H5T_OPAQUE, 1); + tid = H5Tcreate(H5T_OPAQUE, 1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_attr(loc_id,3,dims3,"opaque3D",tid,buf23); + write_attr(loc_id, 3, dims3, "opaque3D", tid, buf23); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4232,19 +4337,19 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ - n=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { + n = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { buf33[i][j][k].a = (char)n++; - buf33[i][j][k].b=n++; + buf33[i][j][k].b = n++; } } } - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); + tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_attr(loc_id,3,dims3,"compound3D",tid,buf33); + write_attr(loc_id, 3, dims3, "compound3D", tid, buf33); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4252,15 +4357,14 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ /* Create references to dataset */ - if(dset_name) - { - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) - status=H5Rcreate(&buf43[i][j][k],fid,dset_name,H5R_OBJECT,(hid_t)-1); + if (dset_name) { + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) + status = H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t)-1); } } - write_attr(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43); + write_attr(loc_id, 3, dims3, "reference3D", H5T_STD_REF_OBJ, buf43); } /*------------------------------------------------------------------------- @@ -4268,9 +4372,9 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); + H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_attr(loc_id,3,dims3,"enum3D",tid,0); + write_attr(loc_id, 3, dims3, "enum3D", tid, 0); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4280,25 +4384,25 @@ static void write_attr_in(hid_t loc_id, /* 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++) { int l; - buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) + for (l = 0; l < i + 1; l++) ((int *)buf53[i][j][k].p)[l] = n++; } } } - sid = H5Screate_simple(3, dims3, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(3, dims3, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf53); HDassert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53); + status = H5Treclaim(tid, sid, H5P_DEFAULT, buf53); HDassert(status >= 0); status = H5Aclose(aid); status = H5Tclose(tid); @@ -4309,8 +4413,8 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ n = 1; - for(i = 0; i < 24; i++) - for(j = 0; j < (int)dimarray[0]; j++) + for (i = 0; i < 24; i++) + for (j = 0; j < (int)dimarray[0]; j++) buf63[i][j] = n++; tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); @@ -4321,21 +4425,20 @@ static void write_attr_in(hid_t loc_id, * H5T_INTEGER and H5T_FLOAT *------------------------------------------------------------------------- */ - n=1; f=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { - buf73[i][j][k]=n++; - buf83[i][j][k]=f++; + n = 1; + f = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + buf73[i][j][k] = n++; + buf83[i][j][k] = f++; } } } - write_attr(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73); - write_attr(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83); + write_attr(loc_id, 3, dims3, "integer3D", H5T_NATIVE_INT, buf73); + write_attr(loc_id, 3, dims3, "float3D", H5T_NATIVE_FLOAT, buf83); } - - /*------------------------------------------------------------------------- * Function: write_dset_in * @@ -4343,75 +4446,68 @@ static void write_attr_in(hid_t loc_id, * * Return: void * - * Programmer: pvn@ncsa.uiuc.edu + * Programmer: Pedro Vicente * * Date: May 28, 2003 * *------------------------------------------------------------------------- */ -static void write_dset_in(hid_t loc_id, - const char* dset_name, /* for saving reference to dataset*/ - hid_t fid) +static void +write_dset_in(hid_t loc_id, const char *dset_name, /* for saving reference to dataset*/ + hid_t fid) { /* Compound datatype */ - typedef struct s_t - { - char a; - double b; + typedef struct s_t { + char a; + double b; } s_t; - typedef enum - { - E_RED, - E_GREEN - } e_t; - - hid_t did; - hid_t sid; - hid_t tid; - hid_t plist_id; - herr_t status; - int val, i, j, k, n; - float f; - int fillvalue=2; + typedef enum { E_RED, E_GREEN } e_t; + + hid_t did; + hid_t sid; + hid_t tid; + hid_t plist_id; + herr_t H5_ATTR_NDEBUG_UNUSED status; + int val, i, j, k, n; + float f; + int fillvalue = 2; /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1]={2}; - char buf1[2][3]= {"ab","de"}; /* string */ - char buf2[2]= {1,2}; /* bitfield, opaque */ - s_t buf3[2]= {{1,2},{3,4}}; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - hvl_t buf5[2]; /* vlen */ - hsize_t dimarray[1]={3}; /* array dimension */ - int buf6[2][3]= {{1,2,3},{4,5,6}}; /* array */ - int buf7[2]= {1,2}; /* integer */ - float buf8[2]= {1,2}; /* float */ + hsize_t dims[1] = {2}; + char buf1[2][3] = {"ab", "de"}; /* string */ + char buf2[2] = {1, 2}; /* bitfield, opaque */ + s_t buf3[2] = {{1, 2}, {3, 4}}; /* compound */ + hobj_ref_t buf4[2]; /* reference */ + hvl_t buf5[2]; /* vlen */ + hsize_t dimarray[1] = {3}; /* array dimension */ + int buf6[2][3] = {{1, 2, 3}, {4, 5, 6}}; /* array */ + int buf7[2] = {1, 2}; /* integer */ + float buf8[2] = {1, 2}; /* float */ /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2]={3,2}; - char buf12[6][3]= {"ab","cd","ef","gh","ij","kl"}; /* string */ - char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */ - s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */ - hobj_ref_t buf42[3][2]; /* reference */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; /* array */ - int buf72[3][2]= {{1,2},{3,4},{5,6}}; /* integer */ - float buf82[3][2]= {{1,2},{3,4},{5,6}}; /* float */ + hsize_t dims2[2] = {3, 2}; + char buf12[6][3] = {"ab", "cd", "ef", "gh", "ij", "kl"}; /* string */ + char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */ + s_t buf32[6] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}}; /* compound */ + hobj_ref_t buf42[3][2]; /* reference */ + hvl_t buf52[3][2]; /* vlen */ + int buf62[6][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}, {16, 17, 18}}; /* array */ + int buf72[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* integer */ + float buf82[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* float */ /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3]={4,3,2}; - char buf13[24][3]= {"ab","cd","ef","gh","ij","kl","mn","pq", - "rs","tu","vw","xz","AB","CD","EF","GH", - "IJ","KL","MN","PQ","RS","TU","VW","XZ"}; /* string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[4][3][2]; /* reference */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ - + hsize_t dims3[3] = {4, 3, 2}; + char buf13[24][3] = {"ab", "cd", "ef", "gh", "ij", "kl", "mn", "pq", "rs", "tu", "vw", "xz", + "AB", "CD", "EF", "GH", "IJ", "KL", "MN", "PQ", "RS", "TU", "VW", "XZ"}; /* string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[4][3][2]; /* reference */ + hvl_t buf53[4][3][2]; /* vlen */ + int buf63[24][3]; /* array */ + int buf73[4][3][2]; /* integer */ + float buf83[4][3][2]; /* float */ /*------------------------------------------------------------------------- * 1D @@ -4422,9 +4518,9 @@ static void write_dset_in(hid_t loc_id, * H5T_STRING *------------------------------------------------------------------------- */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_dset(loc_id,1,dims,"string",tid,buf1); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, 2); + write_dset(loc_id, 1, dims, "string", tid, buf1); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4432,26 +4528,26 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcopy(H5T_STD_B8LE); - write_dset(loc_id,1,dims,"bitfield",tid,buf2); + write_dset(loc_id, 1, dims, "bitfield", tid, buf2); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - tid = H5Tcreate(H5T_OPAQUE, 1); + tid = H5Tcreate(H5T_OPAQUE, 1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_dset(loc_id,1,dims,"opaque",tid,buf2); + write_dset(loc_id, 1, dims, "opaque", tid, buf2); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- */ - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); + tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_dset(loc_id,1,dims,"compound",tid,buf3); + write_dset(loc_id, 1, dims, "compound", tid, buf3); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4459,11 +4555,10 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ /* Create references to dataset */ - if(dset_name) - { - status=H5Rcreate(&buf4[0],fid,dset_name,H5R_OBJECT,(hid_t)-1); - status=H5Rcreate(&buf4[1],fid,dset_name,H5R_OBJECT,(hid_t)-1); - write_dset(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4); + if (dset_name) { + status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t)-1); + write_dset(loc_id, 1, dims, "reference", H5T_STD_REF_OBJ, buf4); } /*------------------------------------------------------------------------- @@ -4471,9 +4566,9 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); + H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_dset(loc_id,1,dims,"enum",tid,0); + write_dset(loc_id, 1, dims, "enum", tid, 0); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4483,20 +4578,20 @@ static void write_dset_in(hid_t loc_id, /* Allocate and initialize VL dataset to write */ - buf5[0].len = 1; - buf5[0].p = HDmalloc( 1 * sizeof(int)); - ((int *)buf5[0].p)[0]=1; - buf5[1].len = 2; - buf5[1].p = HDmalloc( 2 * sizeof(int)); - ((int *)buf5[1].p)[0]=2; - ((int *)buf5[1].p)[1]=3; + buf5[0].len = 1; + buf5[0].p = HDmalloc(1 * sizeof(int)); + ((int *)buf5[0].p)[0] = 1; + buf5[1].len = 2; + buf5[1].p = HDmalloc(2 * sizeof(int)); + ((int *)buf5[1].p)[0] = 2; + ((int *)buf5[1].p)[1] = 3; - sid = H5Screate_simple(1, dims, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + did = H5Dcreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); HDassert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5); + status = H5Treclaim(tid, sid, H5P_DEFAULT, buf5); HDassert(status >= 0); status = H5Dclose(did); status = H5Tclose(tid); @@ -4514,9 +4609,8 @@ static void write_dset_in(hid_t loc_id, * H5T_INTEGER and H5T_FLOAT *------------------------------------------------------------------------- */ - write_dset(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7); - write_dset(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8); - + write_dset(loc_id, 1, dims, "integer", H5T_NATIVE_INT, buf7); + write_dset(loc_id, 1, dims, "float", H5T_NATIVE_FLOAT, buf8); /*------------------------------------------------------------------------- * 2D @@ -4527,9 +4621,9 @@ static void write_dset_in(hid_t loc_id, * H5T_STRING *------------------------------------------------------------------------- */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_dset(loc_id,2,dims2,"string2D",tid,buf12); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, 2); + write_dset(loc_id, 2, dims2, "string2D", tid, buf12); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4537,26 +4631,26 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcopy(H5T_STD_B8LE); - write_dset(loc_id,2,dims2,"bitfield2D",tid,buf22); + write_dset(loc_id, 2, dims2, "bitfield2D", tid, buf22); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - tid = H5Tcreate(H5T_OPAQUE, 1); + tid = H5Tcreate(H5T_OPAQUE, 1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_dset(loc_id,2,dims2,"opaque2D",tid,buf22); + write_dset(loc_id, 2, dims2, "opaque2D", tid, buf22); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- */ - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); + tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_dset(loc_id,2,dims2,"compound2D",tid,buf32); + write_dset(loc_id, 2, dims2, "compound2D", tid, buf32); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4564,14 +4658,13 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ /* Create references to dataset */ - if(dset_name) - { - for(i = 0; i < 3; i++) { - for(j = 0; j < 2; j++) { - status=H5Rcreate(&buf42[i][j],fid,dset_name,H5R_OBJECT,(hid_t)-1); + if (dset_name) { + for (i = 0; i < 3; i++) { + for (j = 0; j < 2; j++) { + status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t)-1); } } - write_dset(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42); + write_dset(loc_id, 2, dims2, "reference2D", H5T_STD_REF_OBJ, buf42); } /*------------------------------------------------------------------------- @@ -4579,9 +4672,9 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); + H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_dset(loc_id,2,dims2,"enum2D",tid,0); + write_dset(loc_id, 2, dims2, "enum2D", tid, 0); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4590,23 +4683,23 @@ static void write_dset_in(hid_t loc_id, */ /* 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++) { int l; - buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) + for (l = 0; l < i + 1; l++) ((int *)buf52[i][j].p)[l] = n++; } - sid = H5Screate_simple(2, dims2, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(2, dims2, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + did = H5Dcreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf52); HDassert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52); + status = H5Treclaim(tid, sid, H5P_DEFAULT, buf52); HDassert(status >= 0); status = H5Dclose(did); status = H5Tclose(tid); @@ -4625,13 +4718,13 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ plist_id = H5Pcreate(H5P_DATASET_CREATE); - status = H5Pset_fill_value(plist_id, H5T_NATIVE_INT, &fillvalue); - sid = H5Screate_simple(2, dims2, NULL); - did = H5Dcreate2(loc_id, "integer2D", H5T_NATIVE_INT, sid, H5P_DEFAULT, plist_id, H5P_DEFAULT); - status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf72); - status = H5Pclose(plist_id); - status = H5Dclose(did); - status = H5Sclose(sid); + status = H5Pset_fill_value(plist_id, H5T_NATIVE_INT, &fillvalue); + sid = H5Screate_simple(2, dims2, NULL); + did = H5Dcreate2(loc_id, "integer2D", H5T_NATIVE_INT, sid, H5P_DEFAULT, plist_id, H5P_DEFAULT); + status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf72); + status = H5Pclose(plist_id); + status = H5Dclose(did); + status = H5Sclose(sid); /*------------------------------------------------------------------------- * H5T_FLOAT @@ -4640,7 +4733,6 @@ static void write_dset_in(hid_t loc_id, write_dset(loc_id, 2, dims2, "float2D", H5T_NATIVE_FLOAT, buf82); - /*------------------------------------------------------------------------- * 3D *------------------------------------------------------------------------- @@ -4650,9 +4742,9 @@ static void write_dset_in(hid_t loc_id, * H5T_STRING *------------------------------------------------------------------------- */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_dset(loc_id,3,dims3,"string3D",tid,buf13); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, 2); + write_dset(loc_id, 3, dims3, "string3D", tid, buf13); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4660,22 +4752,22 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ - n=1; - for(i = 0; i < 4; i++) - for(j = 0; j < 3; j++) - for(k = 0; k < 2; k++) + n = 1; + for (i = 0; i < 4; i++) + for (j = 0; j < 3; j++) + for (k = 0; k < 2; k++) buf23[i][j][k] = (char)n++; tid = H5Tcopy(H5T_STD_B8LE); - write_dset(loc_id,3,dims3,"bitfield3D",tid,buf23); + write_dset(loc_id, 3, dims3, "bitfield3D", tid, buf23); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - tid = H5Tcreate(H5T_OPAQUE, 1); + tid = H5Tcreate(H5T_OPAQUE, 1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_dset(loc_id,3,dims3,"opaque3D",tid,buf23); + write_dset(loc_id, 3, dims3, "opaque3D", tid, buf23); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4683,17 +4775,17 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ - n=1; - for(i = 0; i < 4; i++) - for(j = 0; j < 3; j++) - for(k = 0; k < 2; k++) { + n = 1; + for (i = 0; i < 4; i++) + for (j = 0; j < 3; j++) + for (k = 0; k < 2; k++) { buf33[i][j][k].a = (char)n++; buf33[i][j][k].b = n++; } - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); + tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_dset(loc_id,3,dims3,"compound3D",tid,buf33); + write_dset(loc_id, 3, dims3, "compound3D", tid, buf33); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4701,15 +4793,14 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ /* Create references to dataset */ - if(dset_name) - { - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) - status=H5Rcreate(&buf43[i][j][k],fid,dset_name,H5R_OBJECT,(hid_t)-1); + if (dset_name) { + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) + status = H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t)-1); } } - write_dset(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43); + write_dset(loc_id, 3, dims3, "reference3D", H5T_STD_REF_OBJ, buf43); } /*------------------------------------------------------------------------- @@ -4717,9 +4808,9 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); + H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_dset(loc_id,3,dims3,"enum3D",tid,0); + write_dset(loc_id, 3, dims3, "enum3D", tid, 0); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4729,23 +4820,23 @@ static void write_dset_in(hid_t loc_id, /* 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++) { int l; - buf53[i][j][k].p = HDmalloc(((size_t)i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc(((size_t)i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) + for (l = 0; l < i + 1; l++) ((int *)buf53[i][j][k].p)[l] = n++; } - sid = H5Screate_simple(3, dims3, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(3, dims3, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + did = H5Dcreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf53); HDassert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53); + status = H5Treclaim(tid, sid, H5P_DEFAULT, buf53); HDassert(status >= 0); status = H5Dclose(did); status = H5Tclose(tid); @@ -4755,10 +4846,10 @@ static void write_dset_in(hid_t loc_id, * H5T_ARRAY *------------------------------------------------------------------------- */ - n=1; - for(i = 0; i < 24; i++) { - for(j = 0; j < (int)dimarray[0]; j++) { - buf63[i][j]=n++; + n = 1; + for (i = 0; i < 24; i++) { + for (j = 0; j < (int)dimarray[0]; j++) { + buf63[i][j] = n++; } } @@ -4770,22 +4861,20 @@ static void write_dset_in(hid_t loc_id, * H5T_INTEGER and H5T_FLOAT *------------------------------------------------------------------------- */ - n=1; f=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { - buf73[i][j][k]=n++; - buf83[i][j][k]=f++; + n = 1; + f = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + buf73[i][j][k] = n++; + buf83[i][j][k] = f++; } } } - write_dset(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73); - write_dset(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83); + write_dset(loc_id, 3, dims3, "integer3D", H5T_NATIVE_INT, buf73); + write_dset(loc_id, 3, dims3, "float3D", H5T_NATIVE_FLOAT, buf83); } - - - /*------------------------------------------------------------------------- * Function: gent_attr_all * @@ -4793,30 +4882,31 @@ static void write_dset_in(hid_t loc_id, * * Return: void * - * Programmer: pvn@ncsa.uiuc.edu + * Programmer: Pedro Vicente * * Date: May 19, 2003 * *------------------------------------------------------------------------- */ -static void gent_attr_all(void) +static void +gent_attr_all(void) { - hid_t fid; - hid_t did; - hid_t group_id; - hid_t group2_id; - hid_t root_id; - hid_t sid; - hsize_t dims[1] = {2}; - herr_t status; + hid_t fid; + hid_t did; + hid_t group_id; + hid_t group2_id; + hid_t root_id; + hid_t sid; + hsize_t dims[1] = {2}; + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Create a file and a dataset */ fid = H5Fcreate(FILE40, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Create a 1D dataset */ - sid = H5Screate_simple(1,dims,NULL); - did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Sclose(sid); HDassert(status >= 0); @@ -4830,16 +4920,16 @@ static void gent_attr_all(void) *------------------------------------------------------------------------- */ - write_attr_in(did,"dset",fid); - write_attr_in(group_id,NULL,(hid_t)0); - write_attr_in(root_id,NULL,(hid_t)0); + write_attr_in(did, "dset", fid); + write_attr_in(group_id, NULL, (hid_t)0); + write_attr_in(root_id, NULL, (hid_t)0); /*------------------------------------------------------------------------- * write a series of datasets on group 2 *------------------------------------------------------------------------- */ - write_dset_in(group2_id,"/dset",fid); + write_dset_in(group2_id, "/dset", fid); /* Close */ status = H5Dclose(did); @@ -4856,26 +4946,24 @@ static void gent_attr_all(void) HDassert(status >= 0); } - /*------------------------------------------------------------------------- * Function: write_attr * * Purpose: utility function to write an attribute * - * Programmer: pvn@ncsa.uiuc.edu + * Programmer: Pedro Vicente * * Date: May 19, 2003 * *------------------------------------------------------------------------- */ -static -int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, - hid_t tid, void *buf) +static int +write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, hid_t tid, void *buf) { - hid_t aid; - hid_t sid; - herr_t status; + hid_t aid; + hid_t sid; + herr_t status; /* Create a buf space */ sid = H5Screate_simple(rank, dims, NULL); @@ -4884,7 +4972,7 @@ int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, aid = H5Acreate2(loc_id, attr_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT); /* Write the buf */ - if(buf) + if (buf) status = H5Awrite(aid, tid, buf); /* Close */ @@ -4901,20 +4989,19 @@ int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, * * Return: * - * Programmer: pvn@ncsa.uiuc.edu + * Programmer: Pedro Vicente * * Date: May 27, 2003 * *------------------------------------------------------------------------- */ -static -int write_dset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, - hid_t tid, void *buf ) +static int +write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, hid_t tid, void *buf) { - hid_t did; - hid_t sid; - herr_t status; + hid_t did; + hid_t sid; + herr_t status; /* Create a buf space */ sid = H5Screate_simple(rank, dims, NULL); @@ -4923,7 +5010,7 @@ int write_dset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* Write the buf */ - if(buf) + if (buf) status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); /* Close */ @@ -4933,67 +5020,64 @@ int write_dset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, return status; } - -static void gent_compound_complex(void) +static void +gent_compound_complex(void) { /* Structure and array for compound types */ typedef struct Array1Struct { - int a; - const char *b[F41_DIMb]; - char c[F41_ARRAY_DIMc]; - short d[F41_ARRAY_DIMd1][F41_ARRAY_DIMd2]; - float e; - double f[F41_ARRAY_DIMf]; - char g; + int a; + const char *b[F41_DIMb]; + char c[F41_ARRAY_DIMc]; + short d[F41_ARRAY_DIMd1][F41_ARRAY_DIMd2]; + float e; + double f[F41_ARRAY_DIMf]; + char g; } Array1Struct; - Array1Struct Array1[F41_LENGTH]; + Array1Struct Array1[F41_LENGTH]; /* Define the value of the string array */ - const char *quote [F41_DIMb] = { - "A fight is a contract that takes two people to honor.", - "A combative stance means that you've accepted the contract.", - "In which case, you deserve what you get.", - " -- Professor Cheng Man-ch'ing" - }; + const char *quote[F41_DIMb] = {"A fight is a contract that takes two people to honor.", + "A combative stance means that you've accepted the contract.", + "In which case, you deserve what you get.", + " -- Professor Cheng Man-ch'ing"}; /* Define the value of the character array */ - char chararray [F41_ARRAY_DIMc] = {'H', 'e', 'l', 'l', 'o', '!'}; - - - hid_t Array1Structid; /* File datatype identifier */ - hid_t array_tid; /* Array datatype handle */ - hid_t array1_tid; /* Array datatype handle */ - hid_t array2_tid; /* Array datatype handle */ - hid_t array4_tid; /* Array datatype handle */ - hid_t datafile, dataset; /* Datafile/dataset handles */ - hid_t dataspace; /* Dataspace handle */ - herr_t status; /* Error checking variable */ - hsize_t dim[] = {F41_LENGTH}; /* Dataspace dimensions */ - hsize_t array_dimb[] = {F41_DIMb}; /* Array dimensions */ - hsize_t array_dimd[]={F41_ARRAY_DIMd1,F41_ARRAY_DIMd2}; /* Array dimensions */ - hsize_t array_dimf[]={F41_ARRAY_DIMf}; /* Array dimensions */ - hid_t str_array_id; + char chararray[F41_ARRAY_DIMc] = {'H', 'e', 'l', 'l', 'o', '!'}; + + hid_t Array1Structid; /* File datatype identifier */ + hid_t array_tid; /* Array datatype handle */ + hid_t array1_tid; /* Array datatype handle */ + hid_t array2_tid; /* Array datatype handle */ + hid_t array4_tid; /* Array datatype handle */ + hid_t datafile, dataset; /* Datafile/dataset handles */ + hid_t dataspace; /* Dataspace handle */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Error checking variable */ + hsize_t dim[] = {F41_LENGTH}; /* Dataspace dimensions */ + hsize_t array_dimb[] = {F41_DIMb}; /* Array dimensions */ + hsize_t array_dimd[] = {F41_ARRAY_DIMd1, F41_ARRAY_DIMd2}; /* Array dimensions */ + hsize_t array_dimf[] = {F41_ARRAY_DIMf}; /* Array dimensions */ + hid_t str_array_id; - int m, n, o; /* Array init loop vars */ + int m, n, o; /* Array init loop vars */ /* Initialize the data in the arrays/datastructure */ - for(m = 0; m< F41_LENGTH; m++) { + for (m = 0; m < F41_LENGTH; m++) { Array1[m].a = m; - for(n = 0; n < F41_DIMb; n++) + for (n = 0; n < F41_DIMb; n++) Array1[m].b[n] = quote[n]; - for(n = 0; n < F41_ARRAY_DIMc; n++) + for (n = 0; n < F41_ARRAY_DIMc; n++) Array1[m].c[n] = chararray[n]; - for(n = 0; n < F41_ARRAY_DIMd1; n++) - for(o = 0; o < F41_ARRAY_DIMd2; o++) + for (n = 0; n < F41_ARRAY_DIMd1; n++) + for (o = 0; o < F41_ARRAY_DIMd2; o++) Array1[m].d[n][o] = (short)(m + n + o); - Array1[m].e = (float)((float)m * 0.96F ); + Array1[m].e = (float)((float)m * 0.96F); - for(n = 0; n < F41_ARRAY_DIMf; n++) - Array1[m].f[n] = ((float)m * 1024.9637F ); + for (n = 0; n < F41_ARRAY_DIMf; n++) + Array1[m].f[n] = ((double)m * 1024.9637); Array1[m].g = 'm'; } @@ -5003,16 +5087,15 @@ static void gent_compound_complex(void) HDassert(dataspace >= 0); /* Create the file */ - datafile = H5Fcreate(FILE41, H5F_ACC_TRUNC, H5P_DEFAULT, - H5P_DEFAULT); + datafile = H5Fcreate(FILE41, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); HDassert(datafile >= 0); /* Copy the array data type for the string array */ - array_tid = H5Tcopy (H5T_C_S1); + array_tid = H5Tcopy(H5T_C_S1); HDassert(array_tid >= 0); /* Set the string array size to Variable */ - status = H5Tset_size (array_tid,H5T_VARIABLE); + status = H5Tset_size(array_tid, H5T_VARIABLE); HDassert(status >= 0); /* Create the array data type for the string array */ @@ -5020,11 +5103,11 @@ static void gent_compound_complex(void) HDassert(str_array_id >= 0); /* Copy the array data type for the character array */ - array1_tid = H5Tcopy (H5T_C_S1); + array1_tid = H5Tcopy(H5T_C_S1); HDassert(array1_tid >= 0); /* Set the character array size */ - status = H5Tset_size (array1_tid, F41_ARRAY_DIMc); + status = H5Tset_size(array1_tid, F41_ARRAY_DIMc); HDassert(status >= 0); /* Create the array data type for the character array */ @@ -5036,45 +5119,37 @@ static void gent_compound_complex(void) HDassert(array4_tid >= 0); /* Create the memory data type */ - Array1Structid = H5Tcreate (H5T_COMPOUND, sizeof(Array1Struct)); + Array1Structid = H5Tcreate(H5T_COMPOUND, sizeof(Array1Struct)); HDassert(Array1Structid >= 0); /* Insert the arrays and variables into the structure */ - status = H5Tinsert(Array1Structid, "a_name", - HOFFSET(Array1Struct, a), H5T_NATIVE_INT); + status = H5Tinsert(Array1Structid, "a_name", HOFFSET(Array1Struct, a), H5T_NATIVE_INT); HDassert(status >= 0); - status = H5Tinsert(Array1Structid, "b_name", - HOFFSET(Array1Struct, b), str_array_id); + status = H5Tinsert(Array1Structid, "b_name", HOFFSET(Array1Struct, b), str_array_id); HDassert(status >= 0); - status = H5Tinsert(Array1Structid, "c_name", - HOFFSET(Array1Struct, c), array1_tid); + status = H5Tinsert(Array1Structid, "c_name", HOFFSET(Array1Struct, c), array1_tid); HDassert(status >= 0); - status = H5Tinsert(Array1Structid, "d_name", - HOFFSET(Array1Struct, d), array2_tid); + status = H5Tinsert(Array1Structid, "d_name", HOFFSET(Array1Struct, d), array2_tid); HDassert(status >= 0); - status = H5Tinsert(Array1Structid, "e_name", - HOFFSET(Array1Struct, e), H5T_NATIVE_FLOAT); + status = H5Tinsert(Array1Structid, "e_name", HOFFSET(Array1Struct, e), H5T_NATIVE_FLOAT); HDassert(status >= 0); - status = H5Tinsert(Array1Structid, "f_name", - HOFFSET(Array1Struct, f), array4_tid); + status = H5Tinsert(Array1Structid, "f_name", HOFFSET(Array1Struct, f), array4_tid); HDassert(status >= 0); - status = H5Tinsert(Array1Structid, "g_name", - HOFFSET(Array1Struct, g), H5T_NATIVE_CHAR); + status = H5Tinsert(Array1Structid, "g_name", HOFFSET(Array1Struct, g), H5T_NATIVE_CHAR); HDassert(status >= 0); /* Create the dataset */ - dataset = H5Dcreate2(datafile, F41_DATASETNAME, Array1Structid, - dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(datafile, F41_DATASETNAME, Array1Structid, dataspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); /* Write data to the dataset */ - status = H5Dwrite(dataset, Array1Structid, H5S_ALL, H5S_ALL, - H5P_DEFAULT, Array1); + status = H5Dwrite(dataset, Array1Structid, H5S_ALL, H5S_ALL, H5P_DEFAULT, Array1); HDassert(status >= 0); /* Release resources */ @@ -5106,21 +5181,21 @@ static void gent_compound_complex(void) HDassert(status >= 0); } - -static void gent_named_dtype_attr(void) +static void +gent_named_dtype_attr(void) { - hid_t fid; - hid_t did; - hid_t sid; - hid_t tid; - hid_t aid; - hid_t gid; - int data=8; - herr_t ret; + hid_t fid; + hid_t did; + hid_t sid; + hid_t tid; + hid_t aid; + hid_t gid; + int data = 8; + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Create a file */ - fid=H5Fcreate(FILE42, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>0); + fid = H5Fcreate(FILE42, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid > 0); /*------------------------------------------------------------------------- * datatype @@ -5128,8 +5203,8 @@ static void gent_named_dtype_attr(void) */ /* Create a datatype to commit and use */ - tid=H5Tcopy(H5T_NATIVE_INT); - HDassert(tid>0); + tid = H5Tcopy(H5T_NATIVE_INT); + HDassert(tid > 0); /* Commit datatype to file */ ret = H5Tcommit2(fid, F42_TYPENAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -5143,7 +5218,7 @@ static void gent_named_dtype_attr(void) sid = H5Screate(H5S_SCALAR); HDassert(sid > 0); - /* Create attribute on commited datatype */ + /* Create attribute on committed datatype */ aid = H5Acreate2(tid, F42_ATTRNAME, H5T_STD_I32LE, sid, H5P_DEFAULT, H5P_DEFAULT); HDassert(aid > 0); @@ -5211,20 +5286,20 @@ static void gent_named_dtype_attr(void) HDassert(ret >= 0); } - /*------------------------------------------------------------------------- * Function: gent_null_space * * Purpose: generates dataset and attribute of null dataspace *------------------------------------------------------------------------- */ -static void gent_null_space(void) +static void +gent_null_space(void) { hid_t fid, root, dataset, space, attr; - int dset_buf = 10; - int point = 4; + int dset_buf = 10; + int point = 4; - fid = H5Fcreate(FILE45, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE45, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); /* null space */ @@ -5252,22 +5327,23 @@ static void gent_null_space(void) * Purpose: generates dataset and attribute with dataspace of 0 dimension size *------------------------------------------------------------------------- */ -static void gent_zero_dim_size(void) +static void +gent_zero_dim_size(void) { - hid_t fid, root, dataset, space, attr; - hsize_t dims1[] = {SPACE3_DIM1, SPACE3_DIM2}; - int dset_buf = 10; - int point = 4; + hid_t fid, root, dataset, space, attr; + hsize_t dims1[] = {SPACE3_DIM1, SPACE3_DIM2}; + int dset_buf = 10; + int point = 4; - fid = H5Fcreate(FILE67, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE67, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); /* dataspace of 0 dimension size */ space = H5Screate_simple(SPACE3_RANK, dims1, NULL); /* dataset */ - dataset = H5Dcreate2(fid, "dset of 0 dimension size", H5T_STD_I32BE, space, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid, "dset of 0 dimension size", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); /* nothing should be written */ H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &dset_buf); @@ -5289,39 +5365,34 @@ static void gent_zero_dim_size(void) * *------------------------------------------------------------------------- */ -static -int make_dset(hid_t loc_id, - const char *name, - hid_t sid, - hid_t tid, - hid_t dcpl, - void *buf) +static int +make_dset(hid_t loc_id, const char *name, hid_t sid, hid_t tid, hid_t dcpl, void *buf) { - hid_t dsid; + hid_t dsid; /* create the dataset */ - if((dsid = H5Dcreate2(loc_id, name, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(loc_id, name, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) return -1; /* write */ - if(H5Dwrite(dsid, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(dsid, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* close */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) return -1; return 0; - out: - H5E_BEGIN_TRY { +out: + H5E_BEGIN_TRY + { H5Dclose(dsid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - - /*------------------------------------------------------------------------- * Function: make_external * @@ -5332,19 +5403,19 @@ int make_dset(hid_t loc_id, static void make_external(hid_t fid) { - hid_t dcpl; /*dataset creation property list */ - hid_t sid; /*dataspace ID */ - hid_t dsid; /*dataset ID */ - hsize_t cur_size[1]; /*data space current size */ - hsize_t max_size[1]; /*data space maximum size */ - hsize_t size; /*bytes reserved for data in the external file*/ - int ret; + hid_t dcpl; /*dataset creation property list */ + hid_t sid; /*dataspace ID */ + hid_t dsid; /*dataset ID */ + hsize_t cur_size[1]; /*data space current size */ + hsize_t max_size[1]; /*data space maximum size */ + hsize_t size; /*bytes reserved for data in the external file*/ + int H5_ATTR_NDEBUG_UNUSED ret; cur_size[0] = max_size[0] = 100; - size = (max_size[0]*sizeof(int)/2); + size = (max_size[0] * sizeof(int) / 2); dcpl = H5Pcreate(H5P_DATASET_CREATE); - ret = H5Pset_external(dcpl, "ext1.bin", (off_t)0, size); + ret = H5Pset_external(dcpl, "ext1.bin", (off_t)0, size); HDassert(ret >= 0); ret = H5Pset_external(dcpl, "ext2.bin", (off_t)0, size); @@ -5373,30 +5444,36 @@ make_external(hid_t fid) * *------------------------------------------------------------------------- */ -static void gent_filters(void) +static void +gent_filters(void) { - hid_t fid; /* file id */ - hid_t dcpl; /* dataset creation property list */ - hid_t sid; /* dataspace ID */ - hid_t tid; /* datatype ID */ + hid_t fid; /* file id */ + hid_t dcpl; /* dataset creation property list */ + hid_t sid; /* dataspace ID */ + hid_t tid; /* datatype ID */ #ifdef H5_HAVE_FILTER_SZIP - unsigned szip_options_mask=H5_SZIP_ALLOW_K13_OPTION_MASK|H5_SZIP_NN_OPTION_MASK; - unsigned szip_pixels_per_block=4; + unsigned szip_options_mask = H5_SZIP_ALLOW_K13_OPTION_MASK | H5_SZIP_NN_OPTION_MASK; + unsigned szip_pixels_per_block = 4; #endif /* H5_HAVE_FILTER_SZIP */ - hsize_t dims1[RANK] = {DIM1,DIM2}; - hsize_t chunk_dims[RANK] = {CDIM1,CDIM2}; - int buf1[DIM1][DIM2]; - int i, j, n, ret; - - for(i=n=0; i<DIM1; i++){ - for(j=0; j<DIM2; j++){ - buf1[i][j]=n++; + hsize_t dims1[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int buf1[DIM1][DIM2]; + int i, j, n; + int H5_ATTR_NDEBUG_UNUSED ret; + uint64_t supports_comments = 0; + + for (i = n = 0; i < DIM1; i++) { + for (j = 0; j < DIM2; j++) { + buf1[i][j] = n++; } } /* create a file */ - fid = H5Fcreate(FILE44, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); + fid = H5Fcreate(FILE44, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); + + /* Check if we support comments in the current VOL connector */ + H5VLquery_optional(fid, H5VL_SUBCLS_OBJECT, H5VL_NATIVE_OBJECT_SET_COMMENT, &supports_comments); /* create a space */ sid = H5Screate_simple(SPACE2_RANK, dims1, NULL); @@ -5412,20 +5489,25 @@ static void gent_filters(void) ret = H5Pset_layout(dcpl, H5D_COMPACT); HDassert(ret >= 0); - ret=make_dset(fid,"compact",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "compact", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); - ret = H5Oset_comment_by_name(fid, "compact", "This is a dataset with compact storage", H5P_DEFAULT); - HDassert(ret >= 0); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) { + ret = H5Oset_comment_by_name(fid, "compact", "This is a dataset with compact storage", H5P_DEFAULT); + HDassert(ret >= 0); + } ret = H5Pset_layout(dcpl, H5D_CONTIGUOUS); HDassert(ret >= 0); - ret=make_dset(fid,"contiguous",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "contiguous", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); - ret = H5Oset_comment_by_name(fid, "contiguous", "This is a dataset with contiguous storage", H5P_DEFAULT); - HDassert(ret >= 0); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) { + ret = H5Oset_comment_by_name(fid, "contiguous", "This is a dataset with contiguous storage", + H5P_DEFAULT); + HDassert(ret >= 0); + } ret = H5Pset_layout(dcpl, H5D_CHUNKED); HDassert(ret >= 0); @@ -5433,11 +5515,13 @@ static void gent_filters(void) ret = H5Pset_chunk(dcpl, SPACE2_RANK, chunk_dims); HDassert(ret >= 0); - ret=make_dset(fid,"chunked",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "chunked", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); - ret = H5Oset_comment_by_name(fid, "chunked", "This is a dataset with chunked storage", H5P_DEFAULT); - HDassert(ret >= 0); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) { + ret = H5Oset_comment_by_name(fid, "chunked", "This is a dataset with chunked storage", H5P_DEFAULT); + HDassert(ret >= 0); + } /*------------------------------------------------------------------------- * make several dataset with filters @@ -5453,16 +5537,16 @@ static void gent_filters(void) *------------------------------------------------------------------------- */ #ifdef H5_HAVE_FILTER_SZIP - if(h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { + if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); /* set szip data */ - ret = H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block); + ret = H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block); HDassert(ret >= 0); - ret=make_dset(fid,"szip",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "szip", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); } #endif /* H5_HAVE_FILTER_SZIP */ @@ -5471,51 +5555,49 @@ static void gent_filters(void) * GZIP *------------------------------------------------------------------------- */ -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); /* set deflate data */ ret = H5Pset_deflate(dcpl, 9); HDassert(ret >= 0); - ret=make_dset(fid,"deflate",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "deflate", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); #endif - /*------------------------------------------------------------------------- * shuffle *------------------------------------------------------------------------- */ /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); /* set the shuffle filter */ ret = H5Pset_shuffle(dcpl); HDassert(ret >= 0); - ret=make_dset(fid,"shuffle",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "shuffle", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); - /*------------------------------------------------------------------------- * checksum *------------------------------------------------------------------------- */ /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); /* set the checksum filter */ ret = H5Pset_fletcher32(dcpl); HDassert(ret >= 0); - ret=make_dset(fid,"fletcher32",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "fletcher32", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5524,16 +5606,16 @@ static void gent_filters(void) */ /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); /* set the checksum filter */ ret = H5Pset_nbit(dcpl); HDassert(ret >= 0); - tid=H5Tcopy(H5T_NATIVE_INT); - H5Tset_precision(tid,H5Tget_size(tid)-1); - ret=make_dset(fid,"nbit",sid,tid,dcpl,buf1); + tid = H5Tcopy(H5T_NATIVE_INT); + H5Tset_precision(tid, H5Tget_size(tid) - 1); + ret = make_dset(fid, "nbit", sid, tid, dcpl, buf1); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5542,14 +5624,14 @@ static void gent_filters(void) */ /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); /* set the scaleoffset filter */ - ret = H5Pset_scaleoffset(dcpl,H5Z_SO_INT,(int)H5Tget_size(H5T_NATIVE_INT)); + ret = H5Pset_scaleoffset(dcpl, H5Z_SO_INT, (int)H5Tget_size(H5T_NATIVE_INT)); HDassert(ret >= 0); - ret=make_dset(fid,"scaleoffset",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "scaleoffset", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5557,7 +5639,7 @@ static void gent_filters(void) *------------------------------------------------------------------------- */ /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); /* set the shuffle filter */ @@ -5565,15 +5647,15 @@ static void gent_filters(void) HDassert(ret >= 0); #ifdef H5_HAVE_FILTER_SZIP - if(h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { - szip_options_mask=H5_SZIP_CHIP_OPTION_MASK | H5_SZIP_EC_OPTION_MASK; + if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { + szip_options_mask = H5_SZIP_CHIP_OPTION_MASK | H5_SZIP_EC_OPTION_MASK; /* set szip data */ - ret = H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block); + ret = H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block); HDassert(ret >= 0); } #endif /* H5_HAVE_FILTER_SZIP */ -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) /* set deflate data */ ret = H5Pset_deflate(dcpl, 5); HDassert(ret >= 0); @@ -5587,29 +5669,28 @@ static void gent_filters(void) ret = H5Pset_nbit(dcpl); HDassert(ret >= 0); - ret=make_dset(fid,"all",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "all", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); - /*------------------------------------------------------------------------- * user defined filter *------------------------------------------------------------------------- */ /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); - ret = H5Zregister (H5Z_MYFILTER); + ret = H5Zregister(H5Z_MYFILTER); HDassert(ret >= 0); - ret = H5Pset_filter (dcpl, MYFILTER_ID, 0, 0, NULL); + ret = H5Pset_filter(dcpl, MYFILTER_ID, 0, 0, NULL); HDassert(ret >= 0); - ret=make_dset(fid,"myfilter",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "myfilter", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5624,7 +5705,7 @@ static void gent_filters(void) */ ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY); HDassert(ret >= 0); - ret=make_dset(fid,"alloc_time_early",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "alloc_time_early", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5633,7 +5714,7 @@ static void gent_filters(void) */ ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_INCR); HDassert(ret >= 0); - ret=make_dset(fid,"alloc_time_incr",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "alloc_time_incr", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5642,7 +5723,7 @@ static void gent_filters(void) */ ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE); HDassert(ret >= 0); - ret=make_dset(fid,"alloc_time_late",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "alloc_time_late", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5653,8 +5734,10 @@ static void gent_filters(void) ret = H5Tcommit2(fid, "mytype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); HDassert(ret >= 0); - ret = H5Oset_comment_by_name(fid, "mytype", "This is a commited datatype", H5P_DEFAULT); - HDassert(ret >= 0); + if (supports_comments & H5VL_OPT_QUERY_SUPPORTED) { + ret = H5Oset_comment_by_name(fid, "mytype", "This is a committed datatype", H5P_DEFAULT); + HDassert(ret >= 0); + } ret = H5Tclose(tid); HDassert(ret >= 0); @@ -5673,7 +5756,6 @@ static void gent_filters(void) HDassert(ret >= 0); } - /*------------------------------------------------------------------------- * Function: myfilter * @@ -5683,13 +5765,12 @@ static void gent_filters(void) */ static size_t myfilter(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) + const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, size_t H5_ATTR_UNUSED *buf_size, + void H5_ATTR_UNUSED **buf) { return nbytes; } - /*------------------------------------------------------------------------- * Function: set_local_myfilter * @@ -5701,21 +5782,21 @@ myfilter(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, static herr_t set_local_myfilter(hid_t dcpl_id, hid_t H5_ATTR_UNUSED tid, hid_t H5_ATTR_UNUSED sid) { - unsigned flags; /* Filter flags */ - size_t cd_nelmts = 0; /* Number of filter parameters */ - unsigned cd_values[2] = {5, 6}; /* Filter parameters */ + unsigned flags; /* Filter flags */ + size_t cd_nelmts = 0; /* Number of filter parameters */ + unsigned cd_values[2] = {5, 6}; /* Filter parameters */ /* Get the filter's current parameters */ - if(H5Pget_filter_by_id2(dcpl_id, MYFILTER_ID, &flags, &cd_nelmts, cd_values, 0, NULL, NULL) < 0) - return(FAIL); + if (H5Pget_filter_by_id2(dcpl_id, MYFILTER_ID, &flags, &cd_nelmts, cd_values, 0, NULL, NULL) < 0) + return (FAIL); cd_nelmts = 2; /* Modify the filter's parameters for this dataset */ - if(H5Pmodify_filter(dcpl_id, MYFILTER_ID, flags, cd_nelmts, cd_values) < 0) - return(FAIL); + if (H5Pmodify_filter(dcpl_id, MYFILTER_ID, flags, cd_nelmts, cd_values) < 0) + return (FAIL); - return(SUCCEED); + return (SUCCEED); } /*------------------------------------------------------------------------- @@ -5725,63 +5806,54 @@ set_local_myfilter(hid_t dcpl_id, hid_t H5_ATTR_UNUSED tid, hid_t H5_ATTR_UNUSED * *------------------------------------------------------------------------- */ -static void gent_fcontents(void) +static void +gent_fcontents(void) { - hid_t fid; /* file id */ - hid_t gid1; /* group ID */ - hid_t tid; /* datatype ID */ - hsize_t dims[1]={4}; - int buf[4]={1,2,3,4}; - int ret; - + hid_t fid; /* file id */ + hid_t gid1; /* group ID */ + hid_t tid; /* datatype ID */ + hsize_t dims[1] = {4}; + int buf[4] = {1, 2, 3, 4}; + int H5_ATTR_NDEBUG_UNUSED ret; /* create a file */ - fid = H5Fcreate(FILE46, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); - - - write_dset(fid,1,dims,"dset",H5T_NATIVE_INT,buf); + fid = H5Fcreate(FILE46, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); + write_dset(fid, 1, dims, "dset", H5T_NATIVE_INT, buf); /*------------------------------------------------------------------------- * links *------------------------------------------------------------------------- */ - /* hard link to "dset" */ gid1 = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Lcreate_hard(gid1, "/dset", H5L_SAME_LOC, "dset1", H5P_DEFAULT, H5P_DEFAULT); H5Gclose(gid1); - /* hard link to "dset" */ gid1 = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Lcreate_hard(gid1, "/dset", H5L_SAME_LOC, "dset2", H5P_DEFAULT, H5P_DEFAULT); H5Gclose(gid1); - /* hard link to "g2" */ gid1 = H5Gopen2(fid, "/g1", H5P_DEFAULT); H5Lcreate_hard(gid1, "/g2", H5L_SAME_LOC, "g1.1", H5P_DEFAULT, H5P_DEFAULT); H5Gclose(gid1); - /* hard link to "dset" */ ret = H5Lcreate_hard(fid, "/dset", H5L_SAME_LOC, "dset3", H5P_DEFAULT, H5P_DEFAULT); HDassert(ret >= 0); - /* hard link to "dset" */ ret = H5Lcreate_hard(fid, "/dset", H5L_SAME_LOC, "dset4", H5P_DEFAULT, H5P_DEFAULT); HDassert(ret >= 0); - /* soft link to itself */ ret = H5Lcreate_soft("mylink", fid, "mylink", H5P_DEFAULT, H5P_DEFAULT); HDassert(ret >= 0); - /* soft link to "dset" */ ret = H5Lcreate_soft("/dset", fid, "softlink", H5P_DEFAULT, H5P_DEFAULT); HDassert(ret >= 0); @@ -5804,7 +5876,6 @@ static void gent_fcontents(void) ret = H5Tclose(tid); HDassert(ret >= 0); - /* no name datatype */ tid = H5Tcopy(H5T_NATIVE_INT); ret = H5Tcommit2(fid, "mytype2", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -5815,21 +5886,17 @@ static void gent_fcontents(void) ret = H5Tclose(tid); HDassert(ret >= 0); - /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- */ - ret = H5Fclose(fid); HDassert(ret >= 0); - /* create a file for the bootblock test */ - fid = H5Fcreate(FILE47, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); - + fid = H5Fcreate(FILE47, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); ret = H5Fclose(fid); HDassert(ret >= 0); @@ -5842,35 +5909,34 @@ static void gent_fcontents(void) * *------------------------------------------------------------------------- */ -static void gent_fvalues(void) +static void +gent_fvalues(void) { /* compound datatype */ - typedef struct c_t - { - char a; - double b; + typedef struct c_t { + char a; + double b; } c_t; - - hid_t fid; /* file id */ - hid_t dcpl; /* dataset creation property list */ - hid_t sid; /* dataspace ID */ - hid_t tid; /* datatype ID */ - hid_t did; /* datasetID */ - hsize_t dims[1]={2}; - int buf[2]={1,2}; /* integer */ - int fillval1=-99; /* integer fill value */ - c_t buf2[2]={{1,2},{3,4}}; /* compound */ - c_t fillval2[1]={{1,2}}; /* compound fill value */ - hvl_t buf3[2]; /* vlen */ - hvl_t fillval3; /* vlen fill value */ - hsize_t dimarray[1]={3}; /* array dimension */ - int buf4[2][3]= {{1,2,3},{4,5,6}}; /* array */ - int ret; + hid_t fid; /* file id */ + hid_t dcpl; /* dataset creation property list */ + hid_t sid; /* dataspace ID */ + hid_t tid; /* datatype ID */ + hid_t did; /* datasetID */ + hsize_t dims[1] = {2}; + int buf[2] = {1, 2}; /* integer */ + int fillval1 = -99; /* integer fill value */ + c_t buf2[2] = {{1, 2}, {3, 4}}; /* compound */ + c_t fillval2[1] = {{1, 2}}; /* compound fill value */ + hvl_t buf3[2]; /* vlen */ + hvl_t fillval3; /* vlen fill value */ + hsize_t dimarray[1] = {3}; /* array dimension */ + int buf4[2][3] = {{1, 2, 3}, {4, 5, 6}}; /* array */ + int H5_ATTR_NDEBUG_UNUSED ret; /* create a file */ - fid = H5Fcreate(FILE48, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); + fid = H5Fcreate(FILE48, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); /* create a space */ sid = H5Screate_simple(1, dims, NULL); @@ -5889,7 +5955,7 @@ static void gent_fvalues(void) ret = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval1); HDassert(ret >= 0); - ret=make_dset(fid,"fill_time_ifset",sid,H5T_NATIVE_INT,dcpl,buf); + ret = make_dset(fid, "fill_time_ifset", sid, H5T_NATIVE_INT, dcpl, buf); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5902,7 +5968,7 @@ static void gent_fvalues(void) ret = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval1); HDassert(ret >= 0); - ret=make_dset(fid,"fill_time_never",sid,H5T_NATIVE_INT,dcpl,buf); + ret = make_dset(fid, "fill_time_never", sid, H5T_NATIVE_INT, dcpl, buf); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5915,7 +5981,7 @@ static void gent_fvalues(void) ret = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval1); HDassert(ret >= 0); - ret=make_dset(fid,"fill_time_alloc",sid,H5T_NATIVE_INT,dcpl,buf); + ret = make_dset(fid, "fill_time_alloc", sid, H5T_NATIVE_INT, dcpl, buf); HDassert(ret >= 0); ret = H5Pclose(dcpl); @@ -5925,19 +5991,19 @@ static void gent_fvalues(void) * dataset with no fill value *------------------------------------------------------------------------- */ - write_dset(fid,1,dims,"no_fill",H5T_NATIVE_INT,buf); + write_dset(fid, 1, dims, "no_fill", H5T_NATIVE_INT, buf); /*------------------------------------------------------------------------- * dataset with a H5T_COMPOUND fill value *------------------------------------------------------------------------- */ dcpl = H5Pcreate(H5P_DATASET_CREATE); - tid = H5Tcreate (H5T_COMPOUND, sizeof(c_t)); + tid = H5Tcreate(H5T_COMPOUND, sizeof(c_t)); H5Tinsert(tid, "a", HOFFSET(c_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(c_t, b), H5T_NATIVE_DOUBLE); ret = H5Pset_fill_value(dcpl, tid, &fillval2); HDassert(ret >= 0); - ret=make_dset(fid,"fill_compound",sid,tid,dcpl,buf2); + ret = make_dset(fid, "fill_compound", sid, tid, dcpl, buf2); HDassert(ret >= 0); ret = H5Tclose(tid); HDassert(ret >= 0); @@ -5948,25 +6014,26 @@ static void gent_fvalues(void) * dataset with a H5T_VLEN fill value *------------------------------------------------------------------------- */ - buf3[0].len = 1; - buf3[0].p = HDmalloc( 1 * sizeof(int)); - ((int *)buf3[0].p)[0]=1; - buf3[1].len = 2; - buf3[1].p = HDmalloc(2 * sizeof(int)); + buf3[0].len = 1; + buf3[0].p = HDmalloc(1 * sizeof(int)); + ((int *)buf3[0].p)[0] = 1; + buf3[1].len = 2; + buf3[1].p = HDmalloc(2 * sizeof(int)); ((int *)buf3[1].p)[0] = 2; ((int *)buf3[1].p)[1] = 3; - tid = H5Tvlen_create(H5T_NATIVE_INT); + tid = H5Tvlen_create(H5T_NATIVE_INT); dcpl = H5Pcreate(H5P_DATASET_CREATE); - fillval3.p=NULL; fillval3.len=0; - ret = H5Pset_fill_value(dcpl, tid, &fillval3); + fillval3.p = NULL; + fillval3.len = 0; + ret = H5Pset_fill_value(dcpl, tid, &fillval3); HDassert(ret >= 0); did = H5Dcreate2(fid, "fill_vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); ret = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf3); HDassert(ret >= 0); - ret = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf3); + ret = H5Treclaim(tid, sid, H5P_DEFAULT, buf3); HDassert(ret >= 0); ret = H5Dclose(did); ret = H5Tclose(tid); @@ -5981,7 +6048,6 @@ static void gent_fvalues(void) write_dset(fid, 1, dims, "fill_array", tid, buf4); ret = H5Tclose(tid); - /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- @@ -5992,7 +6058,6 @@ static void gent_fvalues(void) HDassert(ret >= 0); } - /*------------------------------------------------------------------------- * Function: gent_string * @@ -6000,49 +6065,50 @@ static void gent_fvalues(void) * *------------------------------------------------------------------------- */ -static void gent_string(void) +static void +gent_string(void) { /* compound datatype */ - typedef struct c_t - { - int a; - char str[255]; + typedef struct c_t { + int a; + char str[255]; } c_t; - hid_t fid; /* file id */ - hid_t sid; /* dataspace ID */ - hid_t tid; /* datatype ID */ - hid_t str_tid; /* datatype ID */ - hid_t did; /* dataset ID */ - char buf1[]={"quote \" backspace\b form feed\f new line\n tab\t new line\n carriage return\r"}; - const char *buf2[SPACE1_DIM1]= { - "Four score and seven\n years ago our forefathers brought forth on this continent a new nation,", - "conceived in liberty\n and dedicated to the proposition that all men are created equal.", - "Now we are engaged\n in a great civil war,", - "testing whether that\n nation or any nation so conceived and so dedicated can long endure." - }; - c_t buf3 = {24, "Four score and seven\n years ago our forefathers brought forth on this continent a new nation"}; - char buf4[] = {"Four score and seven\n years ago our forefathers brought forth on this continent a new nation"}; - hsize_t dims1[] = {1}; - hsize_t dims2[] = {SPACE1_DIM1}; - hsize_t dims4[1]; - int ret; + hid_t fid; /* file id */ + hid_t sid; /* dataspace ID */ + hid_t tid; /* datatype ID */ + hid_t str_tid; /* datatype ID */ + hid_t did; /* dataset ID */ + char buf1[] = {"quote \" backspace\b form feed\f new line\n tab\t new line\n carriage return\r"}; + const char *buf2[SPACE1_DIM1] = { + "Four score and seven\n years ago our forefathers brought forth on this continent a new nation,", + "conceived in liberty\n and dedicated to the proposition that all men are created equal.", + "Now we are engaged\n in a great civil war,", + "testing whether that\n nation or any nation so conceived and so dedicated can long endure."}; + c_t buf3 = { + 24, "Four score and seven\n years ago our forefathers brought forth on this continent a new nation"}; + char buf4[] = { + "Four score and seven\n years ago our forefathers brought forth on this continent a new nation"}; + hsize_t dims1[] = {1}; + hsize_t dims2[] = {SPACE1_DIM1}; + hsize_t dims4[1]; + int H5_ATTR_NDEBUG_UNUSED ret; dims4[0] = sizeof(buf4); /* create a file */ - fid = H5Fcreate(FILE49, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); + fid = H5Fcreate(FILE49, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); /*------------------------------------------------------------------------- * str1 *------------------------------------------------------------------------- */ - tid=H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); ret = H5Tset_size(tid, sizeof(buf1)); HDassert(ret >= 0); - write_dset(fid,1,dims1,"str1",tid,buf1); + write_dset(fid, 1, dims1, "str1", tid, buf1); HDassert(ret >= 0); ret = H5Tclose(tid); HDassert(ret >= 0); @@ -6069,13 +6135,13 @@ static void gent_string(void) * str3 *------------------------------------------------------------------------- */ - sid = H5Screate_simple(SPACE1_RANK, dims1, NULL); - tid = H5Tcreate (H5T_COMPOUND, sizeof(c_t)); - str_tid = H5Tcopy( H5T_C_S1 ); - H5Tset_size( str_tid, 255 ); + sid = H5Screate_simple(SPACE1_RANK, dims1, NULL); + tid = H5Tcreate(H5T_COMPOUND, sizeof(c_t)); + str_tid = H5Tcopy(H5T_C_S1); + H5Tset_size(str_tid, 255); H5Tinsert(tid, "a", HOFFSET(c_t, a), H5T_NATIVE_INT); - H5Tinsert(tid, "str", HOFFSET(c_t, str), str_tid ); - ret=make_dset(fid,"str3",sid,tid,H5P_DEFAULT,&buf3); + H5Tinsert(tid, "str", HOFFSET(c_t, str), str_tid); + ret = make_dset(fid, "str3", sid, tid, H5P_DEFAULT, &buf3); HDassert(ret >= 0); ret = H5Tclose(tid); HDassert(ret >= 0); @@ -6089,7 +6155,7 @@ static void gent_string(void) *------------------------------------------------------------------------- */ sid = H5Screate_simple(SPACE1_RANK, dims4, NULL); - ret=make_dset(fid,"str4",sid,H5T_NATIVE_CHAR,H5P_DEFAULT,buf4); + ret = make_dset(fid, "str4", sid, H5T_NATIVE_CHAR, H5P_DEFAULT, buf4); ret = H5Sclose(sid); HDassert(ret >= 0); @@ -6101,7 +6167,6 @@ static void gent_string(void) HDassert(ret >= 0); } - /*------------------------------------------------------------------------- * Function: gent_aindices * @@ -6109,48 +6174,50 @@ static void gent_string(void) * *------------------------------------------------------------------------- */ -static void gent_aindices(void) +static void +gent_aindices(void) { - hid_t fid; /* file id */ - hid_t gid[6]; /* group ids */ - hsize_t dims1[1] = {100}; - hsize_t dims2[2] = {10,10}; - hsize_t dims3[3] = {2,10,10}; - hsize_t dims4[4] = {2,2,10,10}; - int buf1[100]; - int buf2[10][10]; - int buf3[2][10][10]; - int buf4[2][2][10][10]; - int i, j, k, l, n, ret; - - for(i = n = 0; i < 100; i++) + hid_t fid; /* file id */ + hid_t gid[6]; /* group ids */ + hsize_t dims1[1] = {100}; + hsize_t dims2[2] = {10, 10}; + hsize_t dims3[3] = {2, 10, 10}; + hsize_t dims4[4] = {2, 2, 10, 10}; + int buf1[100]; + int buf2[10][10]; + int buf3[2][10][10]; + int buf4[2][2][10][10]; + int i, j, k, l, n; + int H5_ATTR_NDEBUG_UNUSED ret; + + for (i = n = 0; i < 100; i++) buf1[i] = n++; - for(i = n = 0; i < 10; i++) - for(j = 0; j < 10; j++) + for (i = n = 0; i < 10; i++) + for (j = 0; j < 10; j++) buf2[i][j] = n++; - for(i = n = 0; i < 2; i++) - for(j = 0; j < 10; j++) - for(k = 0; k < 10; k++) + for (i = n = 0; i < 2; i++) + for (j = 0; j < 10; j++) + for (k = 0; k < 10; k++) buf3[i][j][k] = n++; - for(i = n = 0; i < 2; i++) - for(j = 0; j < 2; j++) - for(k = 0; k < 10; k++) - for(l = 0; l < 10; l++) + for (i = n = 0; i < 2; i++) + for (j = 0; j < 2; j++) + for (k = 0; k < 10; k++) + for (l = 0; l < 10; l++) buf4[i][j][k][l] = n++; /* create a file */ - fid = H5Fcreate(FILE50, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); + fid = H5Fcreate(FILE50, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); /*------------------------------------------------------------------------- * root datasets *------------------------------------------------------------------------- */ - write_dset(fid,1,dims1,"1d",H5T_NATIVE_INT,buf1); - write_dset(fid,2,dims2,"2d",H5T_NATIVE_INT,buf2); - write_dset(fid,3,dims3,"3d",H5T_NATIVE_INT,buf3); - write_dset(fid,4,dims4,"4d",H5T_NATIVE_INT,buf4); + write_dset(fid, 1, dims1, "1d", H5T_NATIVE_INT, buf1); + write_dset(fid, 2, dims2, "2d", H5T_NATIVE_INT, buf2); + write_dset(fid, 3, dims3, "3d", H5T_NATIVE_INT, buf3); + write_dset(fid, 4, dims4, "4d", H5T_NATIVE_INT, buf4); /*------------------------------------------------------------------------- * test with group indentation @@ -6162,11 +6229,11 @@ static void gent_aindices(void) gid[3] = H5Gcreate2(fid, "g1/g2/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); gid[4] = H5Gcreate2(fid, "g1/g2/g3/g4/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); gid[5] = H5Gcreate2(fid, "g1/g2/g3/g4/g5/g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - write_dset(gid[5],1,dims1,"1d",H5T_NATIVE_INT,buf1); - write_dset(gid[5],2,dims2,"2d",H5T_NATIVE_INT,buf2); - write_dset(gid[5],3,dims3,"3d",H5T_NATIVE_INT,buf3); - write_dset(gid[5],4,dims4,"4d",H5T_NATIVE_INT,buf4); - for(i = 0; i < 6; i++) + write_dset(gid[5], 1, dims1, "1d", H5T_NATIVE_INT, buf1); + write_dset(gid[5], 2, dims2, "2d", H5T_NATIVE_INT, buf2); + write_dset(gid[5], 3, dims3, "3d", H5T_NATIVE_INT, buf3); + write_dset(gid[5], 4, dims4, "4d", H5T_NATIVE_INT, buf4); + for (i = 0; i < 6; i++) H5Gclose(gid[i]); /*------------------------------------------------------------------------- @@ -6175,10 +6242,8 @@ static void gent_aindices(void) */ ret = H5Fclose(fid); HDassert(ret >= 0); - } - /*------------------------------------------------------------------------- * Function: gent_longlinks * @@ -6186,13 +6251,14 @@ static void gent_aindices(void) * *------------------------------------------------------------------------- */ -static void gent_longlinks(void) +static void +gent_longlinks(void) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ - hid_t gid2 = (-1); /* Datatype ID */ - char *objname = NULL; /* Name of object [Long] */ - size_t u; /* Local index variable */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group ID */ + hid_t H5_ATTR_NDEBUG_UNUSED gid2 = (-1); /* Datatype ID */ + char * objname = NULL; /* Name of object [Long] */ + size_t u; /* Local index variable */ /* Create files */ fid = H5Fcreate(FILE51, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -6203,9 +6269,9 @@ static void gent_longlinks(void) HDassert(gid >= 0); /* Construct very long file name */ - objname = (char*) HDmalloc((size_t)(F51_MAX_NAME_LEN + 1)); + objname = (char *)HDmalloc((size_t)(F51_MAX_NAME_LEN + 1)); HDassert(objname); - for(u = 0; u < F51_MAX_NAME_LEN; u++) + for (u = 0; u < F51_MAX_NAME_LEN; u++) objname[u] = 'a'; objname[F51_MAX_NAME_LEN] = '\0'; @@ -6236,50 +6302,100 @@ static void gent_longlinks(void) * *------------------------------------------------------------------------- */ -static int gent_ldouble(void) +static int +gent_ldouble(void) { hid_t fid; hid_t did; hid_t tid; hid_t sid; hsize_t dims[1] = {3}; - long double buf[3] = {1,2,3}; + long double buf[3] = {1, 2, 3}; - if((fid = H5Fcreate(FILE52, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILE52, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto error; - if((tid = H5Tcopy(H5T_NATIVE_LDOUBLE)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_LDOUBLE)) < 0) goto error; - if(H5Tget_size(tid) == 0) + if (H5Tget_size(tid) == 0) goto error; - if((did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto error; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; return 0; - error: +error: HDprintf("error !\n"); return -1; - } +/*------------------------------------------------------------------------- + * Function: gent_ldouble_scalar + * + * Purpose: make file with a long double scalar dataset + * + *------------------------------------------------------------------------- + */ +static int +gent_ldouble_scalar(void) +{ + hid_t fid; + hid_t did; + hid_t tid; + hid_t sid; + hsize_t dims[1] = {6}; + long double buf[6] = {0.0L, 1.0L, 2.0L, 3.0L, 4.0L, 5.0L}; + + if ((fid = H5Fcreate(FILE88, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + + if ((sid = H5Screate(H5S_SCALAR)) < 0) + goto error; + + if ((tid = H5Tarray_create2(H5T_NATIVE_LDOUBLE, 1, dims)) < 0) + goto error; + + if (H5Tget_size(tid) == 0) + goto error; + + if ((did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto error; + + if (H5Sclose(sid) < 0) + goto error; + if (H5Tclose(tid) < 0) + goto error; + if (H5Dclose(did) < 0) + goto error; + if (H5Fclose(fid) < 0) + goto error; + + return 0; + +error: + HDprintf("error !\n"); + return -1; +} /*------------------------------------------------------------------------- * Function: gent_binary @@ -6295,16 +6411,15 @@ static int gent_ldouble(void) static void gent_binary(void) { - hid_t fid, sid, did, aid; - hsize_t dims[1] = {6}; - int ibuf[6] = {1,2,3,4,5,6}; - float fbuf[6] = {1,2,3,4,5,6}; - double dbuf[6] = {1,2,3,4,5,6}; + hid_t fid, sid, did, aid; + hsize_t dims[1] = {6}; + int ibuf[6] = {1, 2, 3, 4, 5, 6}; + float fbuf[6] = {1, 2, 3, 4, 5, 6}; + double dbuf[6] = {1, 2, 3, 4, 5, 6}; fid = H5Fcreate(FILE55, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); sid = H5Screate_simple(1, dims, NULL); - /*------------------------------------------------------------------------- * integer *------------------------------------------------------------------------- @@ -6333,7 +6448,6 @@ gent_binary(void) H5Aclose(aid); H5Dclose(did); - /* close */ H5Sclose(sid); H5Fclose(fid); @@ -6347,111 +6461,108 @@ gent_binary(void) * *------------------------------------------------------------------------- */ -#define GB4LL ((unsigned long long) 4*1024*1024*1024) -#define DIM_4GB (GB4LL + 10) +#define GB4LL ((unsigned long long)4 * 1024 * 1024 * 1024) +#define DIM_4GB (GB4LL + 10) static void gent_bigdims(void) { - hid_t fid = -1; - hid_t did = -1; - hid_t f_sid = -1; - hid_t m_sid = -1; - hid_t tid = -1; - hid_t dcpl = -1; - hsize_t dims[1]={DIM_4GB}; /* dataset dimensions */ - hsize_t chunk_dims[1]={1024}; /* chunk dimensions */ - hsize_t hs_start[1]; - hsize_t hs_size[1]; /* hyperslab dimensions */ - size_t size; - char fillvalue=0; - char *buf=NULL; - hsize_t i; - char c; - size_t nelmts; - int ret; + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t f_sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; + hsize_t dims[1] = {DIM_4GB}; /* dataset dimensions */ + hsize_t chunk_dims[1] = {1024}; /* chunk dimensions */ + hsize_t hs_start[1]; + hsize_t hs_size[1]; /* hyperslab dimensions */ + size_t size; + char fillvalue = 0; + char * buf = NULL; + hsize_t i; + char c; + size_t nelmts; + int H5_ATTR_NDEBUG_UNUSED ret; /* create a file */ - fid = H5Fcreate(FILE56, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE56, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); HDassert(fid >= 0); /* create dataset */ - 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(fid, "dset4gb", H5T_NATIVE_SCHAR, f_sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dset4gb", H5T_NATIVE_SCHAR, f_sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 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; /* select an hyperslab */ - nelmts = 20; + nelmts = 20; hs_start[0] = GB4LL - 10; hs_size[0] = nelmts; - if((m_sid = H5Screate_simple(1, hs_size, hs_size)) < 0) + if ((m_sid = H5Screate_simple(1, hs_size, hs_size)) < 0) goto out; - buf=(char *) HDmalloc((unsigned)(nelmts*size)); + buf = (char *)HDmalloc((unsigned)(nelmts * size)); - for(i=0, c=0; i<nelmts; i++, c++) - { + for (i = 0, c = 0; i < nelmts; i++, c++) { buf[i] = c; } - if(H5Sselect_hyperslab (f_sid,H5S_SELECT_SET,hs_start,NULL,hs_size,NULL) < 0) + 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(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - tid = -1; - if(H5Sclose(f_sid) < 0) + tid = H5I_INVALID_HID; + if (H5Sclose(f_sid) < 0) goto out; - f_sid = -1; - if(H5Sclose(m_sid) < 0) + f_sid = H5I_INVALID_HID; + if (H5Sclose(m_sid) < 0) goto out; - m_sid = -1; - if(H5Pclose(dcpl) < 0) + m_sid = H5I_INVALID_HID; + if (H5Pclose(dcpl) < 0) goto out; - dcpl = -1; - if(H5Dclose(did) < 0) + dcpl = H5I_INVALID_HID; + if (H5Dclose(did) < 0) goto out; - did = -1; + did = H5I_INVALID_HID; ret = H5Fclose(fid); HDassert(ret >= 0); return; - out: +out: HDprintf("Error.....\n"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(f_sid); H5Sclose(m_sid); H5Tclose(tid); H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; - return; + } + H5E_END_TRY; } - - /*------------------------------------------------------------------------- * Function: gent_hyperslab * @@ -6462,20 +6573,21 @@ gent_bigdims(void) static void gent_hyperslab(void) { - hid_t fid; /* file id */ - hsize_t dims[2] = {32,4097}; /* big enough data size to force a second stripmine read */ - double *buf; - int i, ret; - - buf = (double*) HDmalloc(32 * 4097 * sizeof(double) ); - for(i = 0; i < 32 * 4097; i++) + hid_t fid; /* file id */ + hsize_t dims[2] = {32, 4097}; /* big enough data size to force a second stripmine read */ + double *buf; + int i; + int H5_ATTR_NDEBUG_UNUSED ret; + + buf = (double *)HDmalloc(32 * 4097 * sizeof(double)); + for (i = 0; i < 32 * 4097; i++) buf[i] = 1; /* create a file */ - fid = H5Fcreate(FILE57, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); + fid = H5Fcreate(FILE57, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); - write_dset(fid,2,dims,"stripmine",H5T_NATIVE_DOUBLE,buf); + write_dset(fid, 2, dims, "stripmine", H5T_NATIVE_DOUBLE, buf); ret = H5Fclose(fid); HDassert(ret >= 0); @@ -6494,23 +6606,22 @@ gent_hyperslab(void) static void gent_group_creation_order(void) { - hid_t fid = -1; /* file ID */ - hid_t gid = -1; /* group ID */ - hid_t gcpl_id = -1; /* group creation property list ID */ - hid_t fcpl_id = -1; /* file creation property list ID (to set root group order) */ + hid_t fid = H5I_INVALID_HID; /* file ID */ + hid_t gid = H5I_INVALID_HID; /* group ID */ + hid_t gcpl_id = H5I_INVALID_HID; /* group creation property list ID */ + hid_t fcpl_id = H5I_INVALID_HID; /* file creation property list ID (to set root group order) */ - if((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) goto out; - if(H5Pset_link_creation_order(fcpl_id, H5P_CRT_ORDER_TRACKED ) < 0) + if (H5Pset_link_creation_order(fcpl_id, H5P_CRT_ORDER_TRACKED) < 0) goto out; - if((fid = H5Fcreate(FILE58, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILE58, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT)) < 0) goto out; - /* create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) goto out; /*------------------------------------------------------------------------- @@ -6518,128 +6629,123 @@ gent_group_creation_order(void) *------------------------------------------------------------------------- */ - - if((gid = H5Gcreate2(fid, "2", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "2", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; + gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "2/c", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "2/c", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; - if((gid = H5Gcreate2(fid, "2/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + gid = H5I_INVALID_HID; + if ((gid = H5Gcreate2(fid, "2/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; - if((gid = H5Gcreate2(fid, "2/a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + gid = H5I_INVALID_HID; + if ((gid = H5Gcreate2(fid, "2/a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; + gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "2/a/a2", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "2/a/a2", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; - if((gid = H5Gcreate2(fid, "2/a/a1", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + gid = H5I_INVALID_HID; + if ((gid = H5Gcreate2(fid, "2/a/a1", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; + gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "2/a/a2/a22", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "2/a/a2/a22", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; - if((gid = H5Gcreate2(fid, "2/a/a2/a21", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + gid = H5I_INVALID_HID; + if ((gid = H5Gcreate2(fid, "2/a/a2/a21", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; - + gid = H5I_INVALID_HID; /*------------------------------------------------------------------------- * create a group "1" with H5P_CRT_ORDER_TRACKED set *------------------------------------------------------------------------- */ - if(H5Pset_link_creation_order(gcpl_id, H5P_CRT_ORDER_TRACKED) < 0) + if (H5Pset_link_creation_order(gcpl_id, H5P_CRT_ORDER_TRACKED) < 0) goto out; - - if((gid = H5Gcreate2(fid, "1", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "1", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; + gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "1/c", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "1/c", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; - if((gid = H5Gcreate2(fid, "1/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + gid = H5I_INVALID_HID; + if ((gid = H5Gcreate2(fid, "1/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; - if((gid = H5Gcreate2(fid, "1/a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + gid = H5I_INVALID_HID; + if ((gid = H5Gcreate2(fid, "1/a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; + gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "1/a/a2", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "1/a/a2", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; - if((gid = H5Gcreate2(fid, "1/a/a1", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + gid = H5I_INVALID_HID; + if ((gid = H5Gcreate2(fid, "1/a/a1", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; + gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "1/a/a2/a22", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "1/a/a2/a22", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; - if((gid = H5Gcreate2(fid, "1/a/a2/a21", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + gid = H5I_INVALID_HID; + if ((gid = H5Gcreate2(fid, "1/a/a2/a21", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; + gid = H5I_INVALID_HID; - - if(H5Pclose(gcpl_id) < 0) + if (H5Pclose(gcpl_id) < 0) goto out; - gcpl_id = -1; - if(H5Pclose(fcpl_id) < 0) + gcpl_id = H5I_INVALID_HID; + if (H5Pclose(fcpl_id) < 0) goto out; - fcpl_id = -1; - if(H5Fclose(fid) < 0) + fcpl_id = H5I_INVALID_HID; + if (H5Fclose(fid) < 0) goto out; - fid = -1; + fid = H5I_INVALID_HID; return; - out: +out: HDprintf("Error.....\n"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Pclose(gcpl_id); H5Pclose(fcpl_id); H5Fclose(fid); - - } H5E_END_TRY; - return; - + } + H5E_END_TRY; } /*------------------------------------------------------------------------- @@ -6653,254 +6759,243 @@ gent_group_creation_order(void) static void gent_attr_creation_order(void) { - hid_t fid = -1; /* file id */ - hid_t gid = -1; /* group id */ - hid_t did = -1; /* dataset id */ - hid_t sid = -1; /* space id */ - hid_t aid = -1; /* attribute id */ - hid_t tid = -1; /* datatype id */ - hid_t gcpl_id = -1; /* group creation property list ID */ - hid_t dcpl_id = -1; /* dataset creation property list ID */ - hid_t tcpl_id = -1; /* datatype creation property list ID */ - int i; - const char *attr_name[3] = {"c", "b", "a" }; - - if((fid = H5Fcreate(FILE59, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + hid_t fid = H5I_INVALID_HID; /* file id */ + hid_t gid = H5I_INVALID_HID; /* group id */ + hid_t did = H5I_INVALID_HID; /* dataset id */ + hid_t sid = H5I_INVALID_HID; /* space id */ + hid_t aid = H5I_INVALID_HID; /* attribute id */ + hid_t tid = H5I_INVALID_HID; /* datatype id */ + hid_t gcpl_id = H5I_INVALID_HID; /* group creation property list ID */ + hid_t dcpl_id = H5I_INVALID_HID; /* dataset creation property list ID */ + hid_t tcpl_id = H5I_INVALID_HID; /* datatype creation property list ID */ + int i; + const char *attr_name[3] = {"c", "b", "a"}; + + if ((fid = H5Fcreate(FILE59, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) goto out; /* create dataset creation property list */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; /* create dataset creation property list */ - if((tcpl_id = H5Pcreate(H5P_DATATYPE_CREATE)) < 0) + if ((tcpl_id = H5Pcreate(H5P_DATATYPE_CREATE)) < 0) goto out; /* enable attribute creation order tracking on dataset property list */ - if(H5Pset_attr_creation_order(dcpl_id, H5P_CRT_ORDER_TRACKED) < 0) + if (H5Pset_attr_creation_order(dcpl_id, H5P_CRT_ORDER_TRACKED) < 0) goto out; /* enable attribute creation order tracking on group property list */ - if(H5Pset_attr_creation_order(gcpl_id, H5P_CRT_ORDER_TRACKED) < 0) + if (H5Pset_attr_creation_order(gcpl_id, H5P_CRT_ORDER_TRACKED) < 0) goto out; /* enable attribute creation order tracking on datatype property list */ - if(H5Pset_attr_creation_order(tcpl_id, H5P_CRT_ORDER_TRACKED) < 0) + if (H5Pset_attr_creation_order(tcpl_id, H5P_CRT_ORDER_TRACKED) < 0) goto out; /* create a dataspace */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) goto out; /*------------------------------------------------------------------------- - * create a dataset with creation order tracked for attributes and atributes in it + * create a dataset with creation order tracked for attributes and attributes in it *------------------------------------------------------------------------- */ /* create a dataset */ - if((did = H5Dcreate2(fid, "dt", H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dt", H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) goto out; /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(did, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < 3; i++) { + if ((aid = H5Acreate2(did, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* close attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - aid = -1; + aid = H5I_INVALID_HID; } /* end for */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; - did = -1; - + did = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * create a dataset without creation order tracked for attributes and atributes in it + * create a dataset without creation order tracked for attributes and attributes in it *------------------------------------------------------------------------- */ /* create a dataset */ - if((did = H5Dcreate2(fid, "d", H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "d", H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(did, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < 3; i++) { + if ((aid = H5Acreate2(did, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* close attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - aid = -1; + aid = H5I_INVALID_HID; } /* end for */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; - did = -1; - - + did = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * create a group with creation order tracked for attributes and atributes in it + * create a group with creation order tracked for attributes and attributes in it *------------------------------------------------------------------------- */ - if((gid = H5Gcreate2(fid, "gt", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "gt", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) goto out; /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(gid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < 3; i++) { + if ((aid = H5Acreate2(gid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* close attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - aid = -1; + aid = H5I_INVALID_HID; } /* end for */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; + gid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * create a group without creation order tracked for attributes and atributes in it + * create a group without creation order tracked for attributes and attributes in it *------------------------------------------------------------------------- */ - if((gid = H5Gcreate2(fid, "g", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "g", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(gid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < 3; i++) { + if ((aid = H5Acreate2(gid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* close attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - aid = -1; + aid = H5I_INVALID_HID; } /* end for */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; + gid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * create a named datatype with creation order tracked for attributes and atributes in it + * create a named datatype with creation order tracked for attributes and attributes in it *------------------------------------------------------------------------- */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) goto out; - if((H5Tcommit2(fid, "tt", tid, H5P_DEFAULT, tcpl_id, H5P_DEFAULT)) < 0) + if ((H5Tcommit2(fid, "tt", tid, H5P_DEFAULT, tcpl_id, H5P_DEFAULT)) < 0) goto out; /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(tid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < 3; i++) { + if ((aid = H5Acreate2(tid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* close attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - aid = -1; + aid = H5I_INVALID_HID; } /* end for */ - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * create a named datatype without creation order tracked for attributes and atributes in it + * create a named datatype without creation order tracked for attributes and attributes in it *------------------------------------------------------------------------- */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) goto out; - if((H5Tcommit2(fid, "t", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((H5Tcommit2(fid, "t", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(tid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < 3; i++) { + if ((aid = H5Acreate2(tid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* close attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - aid = -1; + aid = H5I_INVALID_HID; } /* end for */ - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- * add some attributes to the root group *------------------------------------------------------------------------- */ - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) goto out; /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(gid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < 3; i++) { + if ((aid = H5Acreate2(gid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* close attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - aid = -1; + aid = H5I_INVALID_HID; } /* end for */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - gid = -1; + gid = H5I_INVALID_HID; /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - sid = -1; - if(H5Pclose(dcpl_id) < 0) + sid = H5I_INVALID_HID; + if (H5Pclose(dcpl_id) < 0) goto out; - dcpl_id = -1; - if(H5Pclose(gcpl_id) < 0) + dcpl_id = H5I_INVALID_HID; + if (H5Pclose(gcpl_id) < 0) goto out; - gcpl_id = -1; - if(H5Pclose(tcpl_id) < 0) + gcpl_id = H5I_INVALID_HID; + if (H5Pclose(tcpl_id) < 0) goto out; - tcpl_id = -1; - if(H5Fclose(fid) < 0) + tcpl_id = H5I_INVALID_HID; + if (H5Fclose(fid) < 0) goto out; - fid = -1; - - + fid = H5I_INVALID_HID; return; - out: +out: HDprintf("Error.....\n"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Dclose(did); H5Sclose(sid); @@ -6908,10 +7003,8 @@ gent_attr_creation_order(void) H5Pclose(dcpl_id); H5Pclose(tcpl_id); H5Fclose(fid); - - } H5E_END_TRY; - return; - + } + H5E_END_TRY; } /*------------------------------------------------------------------------- @@ -6927,10 +7020,10 @@ gent_attr_creation_order(void) static void gent_fpformat(void) { - hid_t fid, sid, did; - hsize_t dims[1] = {6}; - double dbuf[6] = {-0.1234567f, 0.1234567f, 0, 0, 0, 0}; - float fbuf[6] = {-0.1234567f, 0.1234567f, 0, 0, 0, 0}; + hid_t fid, sid, did; + hsize_t dims[1] = {6}; + double dbuf[6] = {-0.1234567, 0.1234567, 0, 0, 0, 0}; + float fbuf[6] = {-0.1234567f, 0.1234567f, 0, 0, 0, 0}; fid = H5Fcreate(FILE60, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); sid = H5Screate_simple(1, dims, NULL); @@ -6943,7 +7036,6 @@ gent_fpformat(void) H5Dwrite(did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dbuf); H5Dclose(did); - /*------------------------------------------------------------------------- * float *------------------------------------------------------------------------- @@ -6952,7 +7044,6 @@ gent_fpformat(void) H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, fbuf); H5Dclose(did); - /* close */ H5Sclose(sid); H5Fclose(fid); @@ -6970,15 +7061,14 @@ gent_fpformat(void) static void gent_extlinks(void) { - hid_t source_fid, target_fid, far_fid, sid, did, gid, gid2, tid; - hsize_t dims[1] = {6}; - int buf[6] = {1, 2, 3, 4, 5, 6}; + hid_t source_fid, target_fid, far_fid, sid, did, gid, gid2, tid; + hsize_t dims[1] = {6}; + int buf[6] = {1, 2, 3, 4, 5, 6}; /* create two files, a source and a target */ source_fid = H5Fcreate(FILE61, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); target_fid = H5Fcreate(FILE62, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - far_fid = H5Fcreate(FILE63, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - + far_fid = H5Fcreate(FILE63, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- * create Groups, a Dataset, a committed Datatype, external links, and a @@ -7002,7 +7092,6 @@ gent_extlinks(void) H5Gclose(gid2); H5Gclose(gid); - sid = H5Screate_simple(1, dims, NULL); did = H5Dcreate2(target_fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); @@ -7052,8 +7141,8 @@ gent_extlinks(void) static void gent_fs_strategy_threshold(void) { - hid_t fid; /* File id */ - hid_t fcpl; /* File creation property */ + hid_t fid; /* File id */ + hid_t fcpl; /* File creation property */ /* Create file-creation template */ fcpl = H5Pcreate(H5P_FILE_CREATE); @@ -7087,11 +7176,12 @@ gent_fs_strategy_threshold(void) static void gent_dataset_idx(void) { - hid_t fid, space, dcpl, fapl; - hsize_t dims[2]; - hsize_t maxdims[2]; - int buf[20][10]; - int i, j, ret; + hid_t fid, space, dcpl, fapl; + hsize_t dims[2]; + hsize_t maxdims[2]; + int buf[20][10]; + int i, j; + int H5_ATTR_NDEBUG_UNUSED ret; /* Get a copy of the file aaccess property */ fapl = H5Pcreate(H5P_FILE_ACCESS); @@ -7100,7 +7190,7 @@ gent_dataset_idx(void) ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); assert(ret >= 0); - fid = H5Fcreate(FILE68a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + fid = H5Fcreate(FILE68a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); dcpl = H5Pcreate(H5P_DATASET_CREATE); dims[0] = F68a_CHUNK; @@ -7113,11 +7203,11 @@ gent_dataset_idx(void) /* dataset with fixed dimensions */ dims[0] = F68a_DIM20; dims[1] = F68a_DIM10; - space = H5Screate_simple(RANK, dims, NULL); + space = H5Screate_simple(RANK, dims, NULL); - for(i = 0; i < F68a_DIM20; i++) - for(j = 0; j < F68a_DIM10; j++) - buf[i][j] = j; + for (i = 0; i < F68a_DIM20; i++) + for (j = 0; j < F68a_DIM10; j++) + buf[i][j] = j; ret = make_dset(fid, F68a_DSET_FIXED, space, H5T_NATIVE_INT, dcpl, buf); assert(ret >= 0); @@ -7126,13 +7216,13 @@ gent_dataset_idx(void) /* dataset with non-fixed dimensions */ maxdims[0] = F68a_DIM200; maxdims[1] = F68a_DIM100; - space = H5Screate_simple(RANK, dims, maxdims); + space = H5Screate_simple(RANK, dims, maxdims); ret = make_dset(fid, F68a_DSET_BTREE, space, H5T_NATIVE_INT, dcpl, buf); assert(ret >= 0); H5Sclose(space); -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) /* dataset with fixed dimensions and filters */ /* remove the filters from the dcpl */ @@ -7144,7 +7234,7 @@ gent_dataset_idx(void) assert(ret >= 0); space = H5Screate_simple(RANK, dims, NULL); - ret = make_dset(fid, F68a_DSET_FIXED_FILTER, space, H5T_NATIVE_INT, dcpl, buf); + ret = make_dset(fid, F68a_DSET_FIXED_FILTER, space, H5T_NATIVE_INT, dcpl, buf); assert(ret >= 0); H5Sclose(space); @@ -7169,31 +7259,74 @@ gent_dataset_idx(void) static void gent_packedbits(void) { - hid_t fid, dataset, space; + hid_t fid = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t dsetu8[F66_XDIM][F66_YDIM8], valu8bits; - uint16_t dsetu16[F66_XDIM][F66_YDIM16], valu16bits; - uint32_t dsetu32[F66_XDIM][F66_YDIM32], valu32bits; - uint64_t dsetu64[F66_XDIM][F66_YDIM64], valu64bits; - int8_t dset8[F66_XDIM][F66_YDIM8], val8bits; - int16_t dset16[F66_XDIM][F66_YDIM16], val16bits; - int32_t dset32[F66_XDIM][F66_YDIM32], val32bits; - int64_t dset64[F66_XDIM][F66_YDIM64], val64bits; - double dsetdbl[F66_XDIM][F66_YDIM8]; + + struct { + uint8_t arr[F66_XDIM][F66_YDIM8]; + } * dsetu8; + struct { + uint16_t arr[F66_XDIM][F66_YDIM16]; + } * dsetu16; + struct { + uint32_t arr[F66_XDIM][F66_YDIM32]; + } * dsetu32; + struct { + uint64_t arr[F66_XDIM][F66_YDIM64]; + } * dsetu64; + struct { + int8_t arr[F66_XDIM][F66_YDIM8]; + } * dset8; + struct { + int16_t arr[F66_XDIM][F66_YDIM16]; + } * dset16; + struct { + int32_t arr[F66_XDIM][F66_YDIM32]; + } * dset32; + struct { + int64_t arr[F66_XDIM][F66_YDIM64]; + } * dset64; + struct { + double arr[F66_XDIM][F66_YDIM8]; + } * dsetdbl; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; + /* Create arrays */ + dsetu8 = malloc(sizeof(*dsetu8)); + dsetu16 = malloc(sizeof(*dsetu16)); + dsetu32 = malloc(sizeof(*dsetu32)); + dsetu64 = malloc(sizeof(*dsetu64)); + dset8 = malloc(sizeof(*dset8)); + dset16 = malloc(sizeof(*dset16)); + dset32 = malloc(sizeof(*dset32)); + dset64 = malloc(sizeof(*dset64)); + dsetdbl = malloc(sizeof(*dsetdbl)); + fid = H5Fcreate(FILE66, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU08, H5T_STD_U8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu8[i][0] = valu8bits; - for(j = 1; j < dims[1]; j++) - dsetu8[i][j] = (uint8_t)(dsetu8[i][j - 1] << 1); + valu8bits = (uint8_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu8->arr[i][0] = valu8bits; + for (j = 1; j < dims[1]; j++) + dsetu8->arr[i][j] = (uint8_t)(dsetu8->arr[i][j - 1] << 1); valu8bits = (uint8_t)(valu8bits << 1); } @@ -7202,15 +7335,16 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 16 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU16, H5T_STD_U16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu16[i][0] = valu16bits; - for(j = 1; j < dims[1]; j++) - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); + valu16bits = (uint16_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu16->arr[i][0] = valu16bits; + for (j = 1; j < dims[1]; j++) + dsetu16->arr[i][j] = (uint16_t)(dsetu16->arr[i][j - 1] << 1); valu16bits = (uint16_t)(valu16bits << 1); } @@ -7219,15 +7353,16 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 32 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU32, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu32[i][0] = valu32bits; - for(j = 1; j < dims[1]; j++) - dsetu32[i][j] = dsetu32[i][j-1] << 1; + valu32bits = (uint32_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu32->arr[i][0] = valu32bits; + for (j = 1; j < dims[1]; j++) + dsetu32->arr[i][j] = dsetu32->arr[i][j - 1] << 1; valu32bits <<= 1; } @@ -7236,15 +7371,16 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 64 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU64, H5T_STD_U64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu64[i][0] = valu64bits; - for(j = 1; j < dims[1]; j++) - dsetu64[i][j] = dsetu64[i][j-1] << 1; + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu64->arr[i][0] = valu64bits; + for (j = 1; j < dims[1]; j++) + dsetu64->arr[i][j] = dsetu64->arr[i][j - 1] << 1; valu64bits <<= 1; } @@ -7253,15 +7389,16 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 8 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS08, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset8[i][0] = val8bits; - for(j = 1; j < dims[1]; j++) - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); + val8bits = (int8_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset8->arr[i][0] = val8bits; + for (j = 1; j < dims[1]; j++) + dset8->arr[i][j] = (int8_t)(dset8->arr[i][j - 1] << 1); val8bits = (int8_t)(val8bits << 1); } @@ -7270,15 +7407,16 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 16 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS16, H5T_STD_I16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset16[i][0] = val16bits; - for(j = 1; j < dims[1]; j++) - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); + val16bits = (int16_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset16->arr[i][0] = val16bits; + for (j = 1; j < dims[1]; j++) + dset16->arr[i][j] = (int16_t)(dset16->arr[i][j - 1] << 1); val16bits = (int16_t)(val16bits << 1); } @@ -7287,15 +7425,16 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 32 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS32, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset32[i][0] = val32bits; - for(j = 1; j < dims[1]; j++) - dset32[i][j] = dset32[i][j-1] << 1; + val32bits = (int32_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset32->arr[i][0] = val32bits; + for (j = 1; j < dims[1]; j++) + dset32->arr[i][j] = dset32->arr[i][j - 1] << 1; val32bits <<= 1; } @@ -7304,15 +7443,16 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 64 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS64, H5T_STD_I64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset64[i][0] = val64bits; - for(j = 1; j < dims[1]; j++) - dset64[i][j] = dset64[i][j-1] << 1; + val64bits = (int64_t)~0L; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset64->arr[i][0] = val64bits; + for (j = 1; j < dims[1]; j++) + dset64->arr[i][j] = dset64->arr[i][j - 1] << 1; val64bits <<= 1; } @@ -7321,19 +7461,30 @@ gent_packedbits(void) H5Dclose(dataset); /* Double Dummy set for failure tests */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DUMMYDBL, H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < dims[0]; i++) - for(j = 0; j < dims[1]; j++) - dsetdbl[i][j] = 0.0001F * (float)j + (float)i; + for (i = 0; i < dims[0]; i++) + for (j = 0; j < dims[1]; j++) + dsetdbl->arr[i][j] = 0.0001 * (double)j + (double)i; H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); } /*------------------------------------------------------------------------- @@ -7350,32 +7501,76 @@ gent_packedbits(void) static void gent_attr_intsize(void) { - hid_t fid, attr, space, root; + hid_t fid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t root = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t dsetu8[F66_XDIM][F66_YDIM8], valu8bits; - uint16_t dsetu16[F66_XDIM][F66_YDIM16], valu16bits; - uint32_t dsetu32[F66_XDIM][F66_YDIM32], valu32bits; - uint64_t dsetu64[F66_XDIM][F66_YDIM64], valu64bits; - int8_t dset8[F66_XDIM][F66_YDIM8], val8bits; - int16_t dset16[F66_XDIM][F66_YDIM16], val16bits; - int32_t dset32[F66_XDIM][F66_YDIM32], val32bits; - int64_t dset64[F66_XDIM][F66_YDIM64], val64bits; - double dsetdbl[F66_XDIM][F66_YDIM8]; + + struct { + uint8_t arr[F66_XDIM][F66_YDIM8]; + } * dsetu8; + struct { + uint16_t arr[F66_XDIM][F66_YDIM16]; + } * dsetu16; + struct { + uint32_t arr[F66_XDIM][F66_YDIM32]; + } * dsetu32; + struct { + uint64_t arr[F66_XDIM][F66_YDIM64]; + } * dsetu64; + struct { + int8_t arr[F66_XDIM][F66_YDIM8]; + } * dset8; + struct { + int16_t arr[F66_XDIM][F66_YDIM16]; + } * dset16; + struct { + int32_t arr[F66_XDIM][F66_YDIM64]; + } * dset32; + struct { + int64_t arr[F66_XDIM][F66_YDIM64]; + } * dset64; + struct { + double arr[F66_XDIM][F66_YDIM8]; + } * dsetdbl; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; - fid = H5Fcreate(FILE69, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + /* Create arrays */ + dsetu8 = malloc(sizeof(*dsetu8)); + dsetu16 = malloc(sizeof(*dsetu16)); + dsetu32 = malloc(sizeof(*dsetu32)); + dsetu64 = malloc(sizeof(*dsetu64)); + dset8 = malloc(sizeof(*dset8)); + dset16 = malloc(sizeof(*dset16)); + dset32 = malloc(sizeof(*dset32)); + dset64 = malloc(sizeof(*dset64)); + dsetdbl = malloc(sizeof(*dsetdbl)); + + fid = H5Fcreate(FILE69, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); /* Attribute of 8 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETU08, H5T_STD_U8LE, space, H5P_DEFAULT, H5P_DEFAULT); - - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu8[i][0] = valu8bits; - for(j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETU08, H5T_STD_U8LE, space, H5P_DEFAULT, H5P_DEFAULT); + + valu8bits = (uint8_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu8->arr[i][0] = valu8bits; + for (j = 1; j < dims[1]; j++) { + dsetu8->arr[i][j] = (uint8_t)(dsetu8->arr[i][j - 1] << 1); } valu8bits = (uint8_t)(valu8bits << 1); } @@ -7385,15 +7580,16 @@ gent_attr_intsize(void) H5Aclose(attr); /* Attribute of 16 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETU16, H5T_STD_U16LE, space, H5P_DEFAULT, H5P_DEFAULT); - - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu16[i][0] = valu16bits; - for(j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETU16, H5T_STD_U16LE, space, H5P_DEFAULT, H5P_DEFAULT); + + valu16bits = (uint16_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu16->arr[i][0] = valu16bits; + for (j = 1; j < dims[1]; j++) { + dsetu16->arr[i][j] = (uint16_t)(dsetu16->arr[i][j - 1] << 1); } valu16bits = (uint16_t)(valu16bits << 1); } @@ -7403,15 +7599,16 @@ gent_attr_intsize(void) H5Aclose(attr); /* Attribute of 32 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETU32, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT); - - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu32[i][0] = valu32bits; - for(j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j-1] << 1; + dims[0] = F66_XDIM; + dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETU32, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT); + + valu32bits = (uint32_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu32->arr[i][0] = valu32bits; + for (j = 1; j < dims[1]; j++) { + dsetu32->arr[i][j] = dsetu32->arr[i][j - 1] << 1; } valu32bits <<= 1; } @@ -7421,15 +7618,16 @@ gent_attr_intsize(void) H5Aclose(attr); /* Attribute of 64 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETU64, H5T_STD_U64LE, space, H5P_DEFAULT, H5P_DEFAULT); - - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu64[i][0] = valu64bits; - for(j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j-1] << 1; + dims[0] = F66_XDIM; + dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETU64, H5T_STD_U64LE, space, H5P_DEFAULT, H5P_DEFAULT); + + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu64->arr[i][0] = valu64bits; + for (j = 1; j < dims[1]; j++) { + dsetu64->arr[i][j] = dsetu64->arr[i][j - 1] << 1; } valu64bits <<= 1; } @@ -7439,15 +7637,16 @@ gent_attr_intsize(void) H5Aclose(attr); /* Attribute of 8 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETS08, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT); - - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset8[i][0] = val8bits; - for(j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETS08, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT); + + val8bits = (int8_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset8->arr[i][0] = val8bits; + for (j = 1; j < dims[1]; j++) { + dset8->arr[i][j] = (int8_t)(dset8->arr[i][j - 1] << 1); } val8bits = (int8_t)(val8bits << 1); } @@ -7457,15 +7656,16 @@ gent_attr_intsize(void) H5Aclose(attr); /* Attribute of 16 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETS16, H5T_STD_I16LE, space, H5P_DEFAULT, H5P_DEFAULT); - - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset16[i][0] = val16bits; - for(j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETS16, H5T_STD_I16LE, space, H5P_DEFAULT, H5P_DEFAULT); + + val16bits = (int16_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset16->arr[i][0] = val16bits; + for (j = 1; j < dims[1]; j++) { + dset16->arr[i][j] = (int16_t)(dset16->arr[i][j - 1] << 1); } val16bits = (int16_t)(val16bits << 1); } @@ -7475,15 +7675,16 @@ gent_attr_intsize(void) H5Aclose(attr); /* Attribute of 32 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETS32, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT); - - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset32[i][0] = val32bits; - for(j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j-1] << 1; + dims[0] = F66_XDIM; + dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETS32, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT); + + val32bits = (int32_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset32->arr[i][0] = val32bits; + for (j = 1; j < dims[1]; j++) { + dset32->arr[i][j] = dset32->arr[i][j - 1] << 1; } val32bits <<= 1; } @@ -7493,15 +7694,16 @@ gent_attr_intsize(void) H5Aclose(attr); /* Attribute of 64 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETS64, H5T_STD_I64LE, space, H5P_DEFAULT, H5P_DEFAULT); - - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset64[i][0] = val64bits; - for(j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j-1] << 1; + dims[0] = F66_XDIM; + dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETS64, H5T_STD_I64LE, space, H5P_DEFAULT, H5P_DEFAULT); + + val64bits = (int64_t)~0L; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset64->arr[i][0] = val64bits; + for (j = 1; j < dims[1]; j++) { + dset64->arr[i][j] = dset64->arr[i][j - 1] << 1; } val64bits <<= 1; } @@ -7511,13 +7713,14 @@ gent_attr_intsize(void) H5Aclose(attr); /* Double Dummy set for failure tests */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DUMMYDBL, H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DUMMYDBL, H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < dims[0]; i++) - for(j = 0; j < dims[1]; j++) - dsetdbl[i][j] = 0.0001F * (float)j + (float)i; + for (i = 0; i < dims[0]; i++) + for (j = 0; j < dims[1]; j++) + dsetdbl->arr[i][j] = 0.0001 * (double)j + (double)i; H5Awrite(attr, H5T_NATIVE_DOUBLE, dsetdbl); @@ -7526,81 +7729,100 @@ gent_attr_intsize(void) H5Gclose(root); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); } + static void gent_nodata(void) { - hid_t fid, dataset, space; + hid_t fid, dataset, space; hsize_t dims[2]; fid = H5Fcreate(FILE87, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU08, H5T_STD_U8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); /* Dataset of 16 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU16, H5T_STD_U16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); /* Dataset of 32 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU32, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); /* Dataset of 64 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU64, H5T_STD_U64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); /* Dataset of 8 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS08, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); /* Dataset of 16 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS16, H5T_STD_I16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); /* Dataset of 32 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS32, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); /* Dataset of 64 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS64, H5T_STD_I64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); /* Double Dummy set for failure tests */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DUMMYDBL, H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); } - /*------------------------------------------------------------------------- * Function: gent_charsets * @@ -7614,83 +7836,88 @@ gent_nodata(void) static void gent_charsets(void) { - hid_t fid, did, sid; - herr_t status; - hsize_t dim[] = {1}; /* Dataspace dimensions */ + hid_t fid, did, sid; + herr_t H5_ATTR_NDEBUG_UNUSED status; + hsize_t dim[] = {1}; /* Dataspace dimensions */ typedef struct CharSetInfo { - const char *ascii_p_; - const char *utf8_p_; + const char *ascii_p_; + const char *utf8_p_; } CharSetInfo; - hid_t charset_dtid = H5Tcreate( H5T_COMPOUND, sizeof( CharSetInfo ) ); - hid_t ascii_dtid = H5Tcreate( H5T_STRING, H5T_VARIABLE ); - hid_t utf8_dtid = H5Tcreate( H5T_STRING, H5T_VARIABLE ); - const char * writeData[] = { "ascii", "utf8", }; + hid_t charset_dtid = H5Tcreate(H5T_COMPOUND, sizeof(CharSetInfo)); + hid_t ascii_dtid = H5Tcreate(H5T_STRING, H5T_VARIABLE); + hid_t utf8_dtid = H5Tcreate(H5T_STRING, H5T_VARIABLE); + const char *writeData[] = { + "ascii", + "utf8", + }; - sid = H5Screate_simple( 1, dim, NULL ); - fid = H5Fcreate( FILE68, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ); - status = H5Tset_cset( ascii_dtid, H5T_CSET_ASCII ); + sid = H5Screate_simple(1, dim, NULL); + fid = H5Fcreate(FILE68, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + status = H5Tset_cset(ascii_dtid, H5T_CSET_ASCII); HDassert(status >= 0); - H5Tinsert( charset_dtid, "ascii", HOFFSET(CharSetInfo, ascii_p_ ), ascii_dtid ); + H5Tinsert(charset_dtid, "ascii", HOFFSET(CharSetInfo, ascii_p_), ascii_dtid); - status = H5Tset_cset( utf8_dtid, H5T_CSET_UTF8 ); + status = H5Tset_cset(utf8_dtid, H5T_CSET_UTF8); HDassert(status >= 0); - H5Tinsert( charset_dtid, "utf8", HOFFSET( CharSetInfo, utf8_p_ ), utf8_dtid ); + H5Tinsert(charset_dtid, "utf8", HOFFSET(CharSetInfo, utf8_p_), utf8_dtid); - did = H5Dcreate2( fid, "CharSets", charset_dtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT ); + did = H5Dcreate2(fid, "CharSets", charset_dtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite( did, charset_dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, writeData ); + status = H5Dwrite(did, charset_dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, writeData); HDassert(status >= 0); - H5Tclose( charset_dtid ); - H5Tclose( ascii_dtid ); - H5Tclose( utf8_dtid ); - H5Sclose( sid ); - H5Dclose( did ); - H5Fclose( fid ); + H5Tclose(charset_dtid); + H5Tclose(ascii_dtid); + H5Tclose(utf8_dtid); + H5Sclose(sid); + H5Dclose(did); + H5Fclose(fid); } -static void gent_compound_intsizes(void) { - hid_t fid, dataset, space; - hsize_t dims[2]; - hsize_t array_dim8[]={F70_XDIM,F70_YDIM8}; /* Array dimensions */ - hsize_t array_dim16[]={F70_XDIM,F70_YDIM16}; /* Array dimensions */ - hsize_t array_dim32[]={F70_XDIM,F70_YDIM32}; /* Array dimensions */ - hsize_t array_dim64[]={F70_XDIM,F70_YDIM64}; /* Array dimensions */ - hid_t arrayu8_tid; /* Array datatype handle */ - hid_t arrayu16_tid; /* Array datatype handle */ - hid_t arrayu32_tid; /* Array datatype handle */ - hid_t arrayu64_tid; /* Array datatype handle */ - hid_t array8_tid; /* Array datatype handle */ - hid_t array16_tid; /* Array datatype handle */ - hid_t array32_tid; /* Array datatype handle */ - hid_t array64_tid; /* Array datatype handle */ - hid_t arraydbl_tid; /* Array datatype handle */ +static void +gent_compound_intsizes(void) +{ + hid_t fid, dataset, space; + hsize_t dims[2]; + hsize_t array_dim8[] = {F70_XDIM, F70_YDIM8}; /* Array dimensions */ + hsize_t array_dim16[] = {F70_XDIM, F70_YDIM16}; /* Array dimensions */ + hsize_t array_dim32[] = {F70_XDIM, F70_YDIM32}; /* Array dimensions */ + hsize_t array_dim64[] = {F70_XDIM, F70_YDIM64}; /* Array dimensions */ + hid_t arrayu8_tid; /* Array datatype handle */ + hid_t arrayu16_tid; /* Array datatype handle */ + hid_t arrayu32_tid; /* Array datatype handle */ + hid_t arrayu64_tid; /* Array datatype handle */ + hid_t array8_tid; /* Array datatype handle */ + hid_t array16_tid; /* Array datatype handle */ + hid_t array32_tid; /* Array datatype handle */ + hid_t array64_tid; /* Array datatype handle */ + hid_t arraydbl_tid; /* Array datatype handle */ uint8_t valu8bits; uint16_t valu16bits; uint32_t valu32bits; uint64_t valu64bits; - int8_t val8bits; - int16_t val16bits; - int32_t val32bits; - int64_t val64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; /* Structure and array for compound types */ typedef struct Array1Struct { - uint8_t dsetu8[F70_XDIM][F70_YDIM8]; - uint16_t dsetu16[F70_XDIM][F70_YDIM16]; - uint32_t dsetu32[F70_XDIM][F70_YDIM32]; - uint64_t dsetu64[F70_XDIM][F70_YDIM64]; - int8_t dset8[F70_XDIM][F70_YDIM8]; - int16_t dset16[F70_XDIM][F70_YDIM16]; - int32_t dset32[F70_XDIM][F70_YDIM32]; - int64_t dset64[F70_XDIM][F70_YDIM64]; - double dsetdbl[F70_XDIM][F70_YDIM8]; + uint8_t dsetu8[F70_XDIM][F70_YDIM8]; + uint16_t dsetu16[F70_XDIM][F70_YDIM16]; + uint32_t dsetu32[F70_XDIM][F70_YDIM32]; + uint64_t dsetu64[F70_XDIM][F70_YDIM64]; + int8_t dset8[F70_XDIM][F70_YDIM8]; + int16_t dset16[F70_XDIM][F70_YDIM16]; + int32_t dset32[F70_XDIM][F70_YDIM32]; + int64_t dset64[F70_XDIM][F70_YDIM64]; + double dsetdbl[F70_XDIM][F70_YDIM8]; } Array1Struct; Array1Struct *Array1; - hid_t Array1Structid; /* File datatype identifier */ - herr_t status; /* Error checking variable */ - hsize_t dim[] = { F70_LENGTH }; /* Dataspace dimensions */ + hid_t Array1Structid; /* File datatype identifier */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Error checking variable */ + hsize_t dim[] = {F70_LENGTH}; /* Dataspace dimensions */ int m, n, o; /* Array init loop vars */ @@ -7702,99 +7929,108 @@ static void gent_compound_intsizes(void) { for (m = 0; m < F70_LENGTH; m++) { /* Array of 8 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM8; - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu8bits = (uint8_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dsetu8[n][0] = valu8bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dsetu8[n][o] = (uint8_t)(Array1[m].dsetu8[n][o-1] << 1); + for (o = 1; o < (int)dims[1]; o++) + Array1[m].dsetu8[n][o] = (uint8_t)(Array1[m].dsetu8[n][o - 1] << 1); valu8bits = (uint8_t)(valu8bits << 1); } /* Array of 16 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM16; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM16; - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu16bits = (uint16_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dsetu16[n][0] = valu16bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dsetu16[n][o] = (uint16_t)(Array1[m].dsetu16[n][o-1] << 1); + for (o = 1; o < (int)dims[1]; o++) + Array1[m].dsetu16[n][o] = (uint16_t)(Array1[m].dsetu16[n][o - 1] << 1); valu16bits = (uint16_t)(valu16bits << 1); } /* Array of 32 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM32; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM32; - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu32bits = (uint32_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dsetu32[n][0] = valu32bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dsetu32[n][o] = Array1[m].dsetu32[n][o-1] << 1; + for (o = 1; o < (int)dims[1]; o++) + Array1[m].dsetu32[n][o] = Array1[m].dsetu32[n][o - 1] << 1; valu32bits <<= 1; } /* Array of 64 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM64; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM64; - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dsetu64[n][0] = valu64bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dsetu64[n][o] = Array1[m].dsetu64[n][o-1] << 1; + for (o = 1; o < (int)dims[1]; o++) + Array1[m].dsetu64[n][o] = Array1[m].dsetu64[n][o - 1] << 1; valu64bits <<= 1; } /* Array of 8 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM8; - val8bits = (int8_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val8bits = (int8_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dset8[n][0] = val8bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dset8[n][o] = (int8_t)(Array1[m].dset8[n][o-1] << 1); + for (o = 1; o < (int)dims[1]; o++) + Array1[m].dset8[n][o] = (int8_t)(Array1[m].dset8[n][o - 1] << 1); val8bits = (int8_t)(val8bits << 1); } /* Array of 16 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM16; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM16; - val16bits = (int16_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val16bits = (int16_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dset16[n][0] = val16bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dset16[n][o] = (int16_t)(Array1[m].dset16[n][o-1] << 1); + for (o = 1; o < (int)dims[1]; o++) + Array1[m].dset16[n][o] = (int16_t)(Array1[m].dset16[n][o - 1] << 1); val16bits = (int16_t)(val16bits << 1); } /* Array of 32 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM32; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM32; - val32bits = (int32_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val32bits = (int32_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dset32[n][0] = val32bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dset32[n][o] = Array1[m].dset32[n][o-1] << 1; + for (o = 1; o < (int)dims[1]; o++) + Array1[m].dset32[n][o] = Array1[m].dset32[n][o - 1] << 1; val32bits <<= 1; } /* Array of 64 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM64; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM64; - val64bits = (int64_t) ~0L; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val64bits = (int64_t)~0L; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dset64[n][0] = val64bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dset64[n][o] = Array1[m].dset64[n][o-1] << 1; + for (o = 1; o < (int)dims[1]; o++) + Array1[m].dset64[n][o] = Array1[m].dset64[n][o - 1] << 1; val64bits <<= 1; } /* Double Dummy set for failure tests */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM8; - for(n = 0; n < (int)dims[0]; n++) - for(o = 0; o < (int)dims[1]; o++) - Array1[m].dsetdbl[n][o] = 0.0001F * (float)o + (float)n; + for (n = 0; n < (int)dims[0]; n++) + for (o = 0; o < (int)dims[1]; o++) + Array1[m].dsetdbl[n][o] = 0.0001 * (double)o + (double)n; } /* Create the array data type for the 8 bits signed int array */ @@ -7923,155 +8159,168 @@ static void gent_compound_intsizes(void) { HDfree(Array1); } -static void gent_compound_attr_intsizes(void) { - hid_t fid, attr, space, root; - hsize_t dims[2]; - hsize_t array_dim8[]={F70_XDIM,F70_YDIM8}; /* Array dimensions */ - hsize_t array_dim16[]={F70_XDIM,F70_YDIM16}; /* Array dimensions */ - hsize_t array_dim32[]={F70_XDIM,F70_YDIM32}; /* Array dimensions */ - hsize_t array_dim64[]={F70_XDIM,F70_YDIM64}; /* Array dimensions */ - hid_t arrayu8_tid; /* Array datatype handle */ - hid_t arrayu16_tid; /* Array datatype handle */ - hid_t arrayu32_tid; /* Array datatype handle */ - hid_t arrayu64_tid; /* Array datatype handle */ - hid_t array8_tid; /* Array datatype handle */ - hid_t array16_tid; /* Array datatype handle */ - hid_t array32_tid; /* Array datatype handle */ - hid_t array64_tid; /* Array datatype handle */ - hid_t arraydbl_tid; /* Array datatype handle */ +static void +gent_compound_attr_intsizes(void) +{ + hid_t fid, attr, space, root; + hsize_t dims[2]; + hsize_t array_dim8[] = {F70_XDIM, F70_YDIM8}; /* Array dimensions */ + hsize_t array_dim16[] = {F70_XDIM, F70_YDIM16}; /* Array dimensions */ + hsize_t array_dim32[] = {F70_XDIM, F70_YDIM32}; /* Array dimensions */ + hsize_t array_dim64[] = {F70_XDIM, F70_YDIM64}; /* Array dimensions */ + hid_t arrayu8_tid; /* Array datatype handle */ + hid_t arrayu16_tid; /* Array datatype handle */ + hid_t arrayu32_tid; /* Array datatype handle */ + hid_t arrayu64_tid; /* Array datatype handle */ + hid_t array8_tid; /* Array datatype handle */ + hid_t array16_tid; /* Array datatype handle */ + hid_t array32_tid; /* Array datatype handle */ + hid_t array64_tid; /* Array datatype handle */ + hid_t arraydbl_tid; /* Array datatype handle */ uint8_t valu8bits; uint16_t valu16bits; uint32_t valu32bits; uint64_t valu64bits; - int8_t val8bits; - int16_t val16bits; - int32_t val32bits; - int64_t val64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; /* Structure and array for compound types */ typedef struct Array1Struct { - uint8_t dsetu8[F70_XDIM][F70_YDIM8]; - uint16_t dsetu16[F70_XDIM][F70_YDIM16]; - uint32_t dsetu32[F70_XDIM][F70_YDIM32]; - uint64_t dsetu64[F70_XDIM][F70_YDIM64]; - int8_t dset8[F70_XDIM][F70_YDIM8]; - int16_t dset16[F70_XDIM][F70_YDIM16]; - int32_t dset32[F70_XDIM][F70_YDIM32]; - int64_t dset64[F70_XDIM][F70_YDIM64]; - double dsetdbl[F70_XDIM][F70_YDIM8]; + uint8_t dsetu8[F70_XDIM][F70_YDIM8]; + uint16_t dsetu16[F70_XDIM][F70_YDIM16]; + uint32_t dsetu32[F70_XDIM][F70_YDIM32]; + uint64_t dsetu64[F70_XDIM][F70_YDIM64]; + int8_t dset8[F70_XDIM][F70_YDIM8]; + int16_t dset16[F70_XDIM][F70_YDIM16]; + int32_t dset32[F70_XDIM][F70_YDIM32]; + int64_t dset64[F70_XDIM][F70_YDIM64]; + double dsetdbl[F70_XDIM][F70_YDIM8]; } Array1Struct; - Array1Struct Array1[F70_LENGTH]; + Array1Struct *Array1 = NULL; - hid_t Array1Structid; /* File datatype identifier */ - herr_t status; /* Error checking variable */ - hsize_t dim[] = { F70_LENGTH }; /* Dataspace dimensions */ + hid_t Array1Structid; /* File datatype identifier */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Error checking variable */ + hsize_t dim[] = {F70_LENGTH}; /* Dataspace dimensions */ int m, n, o; /* Array init loop vars */ + Array1 = (Array1Struct *)HDcalloc(F70_LENGTH, sizeof(Array1Struct)); + /* Initialize the data in the arrays/datastructure */ for (m = 0; m < F70_LENGTH; m++) { /* Array of 8 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM8; - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu8bits = (uint8_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dsetu8[n][0] = valu8bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dsetu8[n][o] = (uint8_t)(Array1[m].dsetu8[n][o-1] << 1); + for (o = 1; o < (int)dims[1]; o++) { + Array1[m].dsetu8[n][o] = (uint8_t)(Array1[m].dsetu8[n][o - 1] << 1); } valu8bits = (uint8_t)(valu8bits << 1); } /* Array of 16 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM16; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM16; - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu16bits = (uint16_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dsetu16[n][0] = valu16bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dsetu16[n][o] = (uint16_t)(Array1[m].dsetu16[n][o-1] << 1); + for (o = 1; o < (int)dims[1]; o++) { + Array1[m].dsetu16[n][o] = (uint16_t)(Array1[m].dsetu16[n][o - 1] << 1); } valu16bits = (uint16_t)(valu16bits << 1); } /* Array of 32 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM32; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM32; - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu32bits = (uint32_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dsetu32[n][0] = valu32bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dsetu32[n][o] = Array1[m].dsetu32[n][o-1] << 1; + for (o = 1; o < (int)dims[1]; o++) { + Array1[m].dsetu32[n][o] = Array1[m].dsetu32[n][o - 1] << 1; } valu32bits <<= 1; } /* Array of 64 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM64; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM64; - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dsetu64[n][0] = valu64bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dsetu64[n][o] = Array1[m].dsetu64[n][o-1] << 1; + for (o = 1; o < (int)dims[1]; o++) { + Array1[m].dsetu64[n][o] = Array1[m].dsetu64[n][o - 1] << 1; } valu64bits <<= 1; } /* Array of 8 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM8; - val8bits = (int8_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val8bits = (int8_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dset8[n][0] = val8bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dset8[n][o] = (int8_t)(Array1[m].dset8[n][o-1] << 1); + for (o = 1; o < (int)dims[1]; o++) { + Array1[m].dset8[n][o] = (int8_t)(Array1[m].dset8[n][o - 1] << 1); } val8bits = (int8_t)(val8bits << 1); } /* Array of 16 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM16; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM16; - val16bits = (int16_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val16bits = (int16_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dset16[n][0] = val16bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dset16[n][o] = (int16_t)(Array1[m].dset16[n][o-1] << 1); + for (o = 1; o < (int)dims[1]; o++) { + Array1[m].dset16[n][o] = (int16_t)(Array1[m].dset16[n][o - 1] << 1); } val16bits = (int16_t)(val16bits << 1); } /* Array of 32 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM32; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM32; - val32bits = (int32_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val32bits = (int32_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dset32[n][0] = val32bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dset32[n][o] = Array1[m].dset32[n][o-1] << 1; + for (o = 1; o < (int)dims[1]; o++) { + Array1[m].dset32[n][o] = Array1[m].dset32[n][o - 1] << 1; } val32bits <<= 1; } /* Array of 64 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM64; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM64; - val64bits = (int64_t) ~0L; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val64bits = (int64_t)~0L; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dset64[n][0] = val64bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dset64[n][o] = Array1[m].dset64[n][o-1] << 1; + for (o = 1; o < (int)dims[1]; o++) { + Array1[m].dset64[n][o] = Array1[m].dset64[n][o - 1] << 1; } val64bits <<= 1; } /* Double Dummy set for failure tests */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM8; - for(n = 0; n < (int)dims[0]; n++) - for(o = 0; o < (int)dims[1]; o++) - Array1[m].dsetdbl[n][o] = 0.0001F * (float)o + (float)n; + for (n = 0; n < (int)dims[0]; n++) + for (o = 0; o < (int)dims[1]; o++) + Array1[m].dsetdbl[n][o] = 0.0001 * (double)o + (double)n; } /* Create the array data type for the 8 bits signed int array */ @@ -8198,53 +8447,57 @@ static void gent_compound_attr_intsizes(void) { status = H5Fclose(fid); HDassert(status >= 0); + + HDfree(Array1); } -static void gent_nested_compound_dt(void) { /* test nested data type */ - hid_t fid, group, dataset, space, type, create_plist, type1, type2; - hid_t array_dt, enum_dt; +static void +gent_nested_compound_dt(void) +{ /* test nested data type */ + hid_t fid, group, dataset, space, type, create_plist, type1, type2; + hid_t array_dt, enum_dt; enumtype val; typedef struct { - int a; - float b; + int a; + float b; } dset1_t; dset1_t dset1[10]; typedef struct { - int a; - float b; - enumtype c; + int a; + float b; + enumtype c; } dset2_t; dset2_t dset2[10]; typedef struct { - int a[5]; - float b[5][6]; - dset1_t c; + int a[5]; + float b[5][6]; + dset1_t c; } dset3_t; dset3_t dset3[10]; enumtype dset4[] = {RED, GREEN, BLUE, GREEN, WHITE, BLUE}; - int i, j, k; + int i, j, k; unsigned ndims; - hsize_t dim[2]; + hsize_t dim[2]; hsize_t sdim, maxdim; sdim = 10; - for(i = 0; i < (int)sdim; i++) { + for (i = 0; i < (int)sdim; i++) { dset1[i].a = i; - dset1[i].b = (float)(i*i); + dset1[i].b = (float)(i * i); dset2[i].a = i; dset2[i].b = (float)((float)i + (float)i * 0.1F); dset2[i].c = GREEN; - for(j = 0; j < 5; j++) { + for (j = 0; j < 5; j++) { dset3[i].a[j] = i * j; - for(k = 0; k < 6; k++) { + for (k = 0; k < 6; k++) { dset3[i].b[j][k] = (float)((float)i * (float)j * (float)k * 1.0F); } } @@ -8259,13 +8512,12 @@ static void gent_nested_compound_dt(void) { /* test nested data type */ sdim = 2; H5Pset_chunk(create_plist, 1, &sdim); - - sdim = 6; + sdim = 6; maxdim = H5S_UNLIMITED; space = H5Screate_simple(1, &sdim, &maxdim); - type = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); + type = H5Tcreate(H5T_COMPOUND, sizeof(dset1[0])); H5Tinsert(type, "a_name", HOFFSET(dset1_t, a), H5T_STD_I32LE); H5Tinsert(type, "b_name", HOFFSET(dset1_t, b), H5T_IEEE_F32LE); @@ -8277,20 +8529,20 @@ static void gent_nested_compound_dt(void) { /* test nested data type */ H5Dclose(dataset); /* Create the shared enumerated datatype. */ - enum_dt = H5Tenum_create (H5T_NATIVE_INT); - val = (enumtype) RED; - H5Tenum_insert (enum_dt, "Red", &val); - val = (enumtype) GREEN; - H5Tenum_insert (enum_dt, "Green", &val); - val = (enumtype) BLUE; - H5Tenum_insert (enum_dt, "Blue", &val); - val = (enumtype) WHITE; - H5Tenum_insert (enum_dt, "White", &val); - val = (enumtype) BLACK; - H5Tenum_insert (enum_dt, "Black", &val); - H5Tcommit2(fid, "enumtype", enum_dt, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset2[0])); + enum_dt = H5Tenum_create(H5T_NATIVE_INT); + val = (enumtype)RED; + H5Tenum_insert(enum_dt, "Red", &val); + val = (enumtype)GREEN; + H5Tenum_insert(enum_dt, "Green", &val); + val = (enumtype)BLUE; + H5Tenum_insert(enum_dt, "Blue", &val); + val = (enumtype)WHITE; + H5Tenum_insert(enum_dt, "White", &val); + val = (enumtype)BLACK; + H5Tenum_insert(enum_dt, "Black", &val); + H5Tcommit2(fid, "enumtype", enum_dt, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset2[0])); H5Tinsert(type2, "a_name", HOFFSET(dset2_t, a), H5T_NATIVE_INT); H5Tinsert(type2, "b_name", HOFFSET(dset2_t, b), H5T_NATIVE_FLOAT); @@ -8316,19 +8568,22 @@ static void gent_nested_compound_dt(void) { /* test nested data type */ group = H5Gcreate2(fid, "/group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset3_t)); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset3_t)); - ndims = 1; dim[0] = 5; + ndims = 1; + dim[0] = 5; array_dt = H5Tarray_create2(H5T_STD_I32LE, ndims, dim); H5Tinsert(type2, "int_name", HOFFSET(dset3_t, a), array_dt); H5Tclose(array_dt); - ndims = 2; dim[0] = 5; dim[1] = 6; + ndims = 2; + dim[0] = 5; + dim[1] = 6; array_dt = H5Tarray_create2(H5T_IEEE_F32LE, ndims, dim); H5Tinsert(type2, "float_name", HOFFSET(dset3_t, b), array_dt); H5Tclose(array_dt); - H5Tinsert (type2, "cmpd_name", HOFFSET (dset3_t, c), type1); + H5Tinsert(type2, "cmpd_name", HOFFSET(dset3_t, c), type1); dataset = H5Dcreate2(group, "dset3", type2, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); @@ -8346,7 +8601,6 @@ static void gent_nested_compound_dt(void) { /* test nested data type */ H5Pclose(create_plist); H5Fclose(fid); - } /*------------------------------------------------------------------------- @@ -8362,32 +8616,76 @@ static void gent_nested_compound_dt(void) { /* test nested data type */ static void gent_intscalars(void) { - hid_t fid, dataset, space, tid; + hid_t fid = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t dsetu8[F73_XDIM][F73_YDIM8], valu8bits; - uint16_t dsetu16[F73_XDIM][F73_YDIM16], valu16bits; - uint32_t dsetu32[F73_XDIM][F73_YDIM32], valu32bits; - uint64_t dsetu64[F73_XDIM][F73_YDIM64], valu64bits; - int8_t dset8[F73_XDIM][F73_YDIM8], val8bits; - int16_t dset16[F73_XDIM][F73_YDIM16], val16bits; - int32_t dset32[F73_XDIM][F73_YDIM32], val32bits; - int64_t dset64[F73_XDIM][F73_YDIM64], val64bits; - double dsetdbl[F73_XDIM][F73_YDIM8]; + + struct { + uint8_t arr[F73_XDIM][F73_YDIM8]; + } * dsetu8; + struct { + uint16_t arr[F73_XDIM][F73_YDIM16]; + } * dsetu16; + struct { + uint32_t arr[F73_XDIM][F73_YDIM32]; + } * dsetu32; + struct { + uint64_t arr[F73_XDIM][F73_YDIM64]; + } * dsetu64; + struct { + int8_t arr[F73_XDIM][F73_YDIM8]; + } * dset8; + struct { + int16_t arr[F73_XDIM][F73_YDIM16]; + } * dset16; + struct { + int32_t arr[F73_XDIM][F73_YDIM32]; + } * dset32; + struct { + int64_t arr[F73_XDIM][F73_YDIM64]; + } * dset64; + struct { + double arr[F73_XDIM][F73_YDIM8]; + } * dsetdbl; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; + /* Create arrays */ + dsetu8 = malloc(sizeof(*dsetu8)); + dsetu16 = malloc(sizeof(*dsetu16)); + dsetu32 = malloc(sizeof(*dsetu32)); + dsetu64 = malloc(sizeof(*dsetu64)); + dset8 = malloc(sizeof(*dset8)); + dset16 = malloc(sizeof(*dset16)); + dset32 = malloc(sizeof(*dset32)); + dset64 = malloc(sizeof(*dset64)); + dsetdbl = malloc(sizeof(*dsetdbl)); + fid = H5Fcreate(FILE73, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U8LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U8LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETU08, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu8[i][0] = valu8bits; - for(j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1); + valu8bits = (uint8_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu8->arr[i][0] = valu8bits; + for (j = 1; j < dims[1]; j++) { + dsetu8->arr[i][j] = (uint8_t)(dsetu8->arr[i][j - 1] << 1); } valu8bits = (uint8_t)(valu8bits << 1); } @@ -8397,16 +8695,17 @@ gent_intscalars(void) H5Dclose(dataset); /* Dataset of 16 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U16LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM16; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U16LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETU16, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu16[i][0] = valu16bits; - for(j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); + valu16bits = (uint16_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu16->arr[i][0] = valu16bits; + for (j = 1; j < dims[1]; j++) { + dsetu16->arr[i][j] = (uint16_t)(dsetu16->arr[i][j - 1] << 1); } valu16bits = (uint16_t)(valu16bits << 1); } @@ -8416,16 +8715,17 @@ gent_intscalars(void) H5Dclose(dataset); /* Dataset of 32 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U32LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM32; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U32LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETU32, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu32[i][0] = valu32bits; - for(j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j-1] << 1; + valu32bits = (uint32_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu32->arr[i][0] = valu32bits; + for (j = 1; j < dims[1]; j++) { + dsetu32->arr[i][j] = dsetu32->arr[i][j - 1] << 1; } valu32bits <<= 1; } @@ -8435,16 +8735,17 @@ gent_intscalars(void) H5Dclose(dataset); /* Dataset of 64 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U64LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM64; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U64LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETU64, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu64[i][0] = valu64bits; - for(j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j-1] << 1; + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu64->arr[i][0] = valu64bits; + for (j = 1; j < dims[1]; j++) { + dsetu64->arr[i][j] = dsetu64->arr[i][j - 1] << 1; } valu64bits <<= 1; } @@ -8454,16 +8755,17 @@ gent_intscalars(void) H5Dclose(dataset); /* Dataset of 8 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I8LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I8LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETS08, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset8[i][0] = val8bits; - for(j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); + val8bits = (int8_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset8->arr[i][0] = val8bits; + for (j = 1; j < dims[1]; j++) { + dset8->arr[i][j] = (int8_t)(dset8->arr[i][j - 1] << 1); } val8bits = (int8_t)(val8bits << 1); } @@ -8473,16 +8775,17 @@ gent_intscalars(void) H5Dclose(dataset); /* Dataset of 16 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I16LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM16; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I16LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETS16, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset16[i][0] = val16bits; - for(j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); + val16bits = (int16_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset16->arr[i][0] = val16bits; + for (j = 1; j < dims[1]; j++) { + dset16->arr[i][j] = (int16_t)(dset16->arr[i][j - 1] << 1); } val16bits = (int16_t)(val16bits << 1); } @@ -8492,16 +8795,17 @@ gent_intscalars(void) H5Dclose(dataset); /* Dataset of 32 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I32LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM32; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I32LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETS32, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset32[i][0] = val32bits; - for(j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j-1] << 1; + val32bits = (int32_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset32->arr[i][0] = val32bits; + for (j = 1; j < dims[1]; j++) { + dset32->arr[i][j] = dset32->arr[i][j - 1] << 1; } val32bits <<= 1; } @@ -8511,16 +8815,17 @@ gent_intscalars(void) H5Dclose(dataset); /* Dataset of 64 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I64LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM64; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I64LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETS64, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset64[i][0] = val64bits; - for(j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j-1] << 1; + val64bits = (int64_t)~0L; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset64->arr[i][0] = val64bits; + for (j = 1; j < dims[1]; j++) { + dset64->arr[i][j] = dset64->arr[i][j - 1] << 1; } val64bits <<= 1; } @@ -8530,20 +8835,31 @@ gent_intscalars(void) H5Dclose(dataset); /* Double Dummy set for failure tests */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < dims[0]; i++) - for(j = 0; j < dims[1]; j++) - dsetdbl[i][j] = 0.0001F * (float)j + (float)i; + for (i = 0; i < dims[0]; i++) + for (j = 0; j < dims[1]; j++) + dsetdbl->arr[i][j] = 0.0001 * (double)j + (double)i; H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); } /*------------------------------------------------------------------------- @@ -8560,33 +8876,78 @@ gent_intscalars(void) static void gent_attr_intscalars(void) { - hid_t fid, attr, space, root, tid; + hid_t fid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t root = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t dsetu8[F73_XDIM][F73_YDIM8], valu8bits; - uint16_t dsetu16[F73_XDIM][F73_YDIM16], valu16bits; - uint32_t dsetu32[F73_XDIM][F73_YDIM32], valu32bits; - uint64_t dsetu64[F73_XDIM][F73_YDIM64], valu64bits; - int8_t dset8[F73_XDIM][F73_YDIM8], val8bits; - int16_t dset16[F73_XDIM][F73_YDIM16], val16bits; - int32_t dset32[F73_XDIM][F73_YDIM32], val32bits; - int64_t dset64[F73_XDIM][F73_YDIM64], val64bits; - double dsetdbl[F73_XDIM][F73_YDIM8]; + + struct { + uint8_t arr[F73_XDIM][F73_YDIM8]; + } * dsetu8; + struct { + uint16_t arr[F73_XDIM][F73_YDIM16]; + } * dsetu16; + struct { + uint32_t arr[F73_XDIM][F73_YDIM32]; + } * dsetu32; + struct { + uint64_t arr[F73_XDIM][F73_YDIM64]; + } * dsetu64; + struct { + int8_t arr[F73_XDIM][F73_YDIM8]; + } * dset8; + struct { + int16_t arr[F73_XDIM][F73_YDIM16]; + } * dset16; + struct { + int32_t arr[F73_XDIM][F73_YDIM32]; + } * dset32; + struct { + int64_t arr[F73_XDIM][F73_YDIM64]; + } * dset64; + struct { + double arr[F73_XDIM][F73_YDIM8]; + } * dsetdbl; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; - fid = H5Fcreate(FILE74, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + /* Create arrays */ + dsetu8 = malloc(sizeof(*dsetu8)); + dsetu16 = malloc(sizeof(*dsetu16)); + dsetu32 = malloc(sizeof(*dsetu32)); + dsetu64 = malloc(sizeof(*dsetu64)); + dset8 = malloc(sizeof(*dset8)); + dset16 = malloc(sizeof(*dset16)); + dset32 = malloc(sizeof(*dset32)); + dset64 = malloc(sizeof(*dset64)); + dsetdbl = malloc(sizeof(*dsetdbl)); + + fid = H5Fcreate(FILE74, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); /* Attribute of 8 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U8LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETU08, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu8[i][0] = valu8bits; - for(j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U8LE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DATASETU08, tid, space, H5P_DEFAULT, H5P_DEFAULT); + + valu8bits = (uint8_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu8->arr[i][0] = valu8bits; + for (j = 1; j < dims[1]; j++) { + dsetu8->arr[i][j] = (uint8_t)(dsetu8->arr[i][j - 1] << 1); } valu8bits = (uint8_t)(valu8bits << 1); } @@ -8596,16 +8957,17 @@ gent_attr_intscalars(void) H5Aclose(attr); /* Attribute of 16 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U16LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETU16, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu16[i][0] = valu16bits; - for(j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM16; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U16LE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DATASETU16, tid, space, H5P_DEFAULT, H5P_DEFAULT); + + valu16bits = (uint16_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu16->arr[i][0] = valu16bits; + for (j = 1; j < dims[1]; j++) { + dsetu16->arr[i][j] = (uint16_t)(dsetu16->arr[i][j - 1] << 1); } valu16bits = (uint16_t)(valu16bits << 1); } @@ -8615,16 +8977,17 @@ gent_attr_intscalars(void) H5Aclose(attr); /* Attribute of 32 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U32LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETU32, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu32[i][0] = valu32bits; - for(j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j-1] << 1; + dims[0] = F73_XDIM; + dims[1] = F73_YDIM32; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U32LE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DATASETU32, tid, space, H5P_DEFAULT, H5P_DEFAULT); + + valu32bits = (uint32_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu32->arr[i][0] = valu32bits; + for (j = 1; j < dims[1]; j++) { + dsetu32->arr[i][j] = dsetu32->arr[i][j - 1] << 1; } valu32bits <<= 1; } @@ -8634,16 +8997,17 @@ gent_attr_intscalars(void) H5Aclose(attr); /* Attribute of 64 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U64LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETU64, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu64[i][0] = valu64bits; - for(j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j-1] << 1; + dims[0] = F73_XDIM; + dims[1] = F73_YDIM64; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U64LE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DATASETU64, tid, space, H5P_DEFAULT, H5P_DEFAULT); + + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu64->arr[i][0] = valu64bits; + for (j = 1; j < dims[1]; j++) { + dsetu64->arr[i][j] = dsetu64->arr[i][j - 1] << 1; } valu64bits <<= 1; } @@ -8653,16 +9017,17 @@ gent_attr_intscalars(void) H5Aclose(attr); /* Attribute of 8 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I8LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETS08, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset8[i][0] = val8bits; - for(j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I8LE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DATASETS08, tid, space, H5P_DEFAULT, H5P_DEFAULT); + + val8bits = (int8_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset8->arr[i][0] = val8bits; + for (j = 1; j < dims[1]; j++) { + dset8->arr[i][j] = (int8_t)(dset8->arr[i][j - 1] << 1); } val8bits = (int8_t)(val8bits << 1); } @@ -8672,16 +9037,17 @@ gent_attr_intscalars(void) H5Aclose(attr); /* Attribute of 16 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I16LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETS16, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset16[i][0] = val16bits; - for(j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM16; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I16LE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DATASETS16, tid, space, H5P_DEFAULT, H5P_DEFAULT); + + val16bits = (int16_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset16->arr[i][0] = val16bits; + for (j = 1; j < dims[1]; j++) { + dset16->arr[i][j] = (int16_t)(dset16->arr[i][j - 1] << 1); } val16bits = (int16_t)(val16bits << 1); } @@ -8691,16 +9057,17 @@ gent_attr_intscalars(void) H5Aclose(attr); /* Attribute of 32 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I32LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETS32, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset32[i][0] = val32bits; - for(j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j-1] << 1; + dims[0] = F73_XDIM; + dims[1] = F73_YDIM32; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I32LE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DATASETS32, tid, space, H5P_DEFAULT, H5P_DEFAULT); + + val32bits = (int32_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset32->arr[i][0] = val32bits; + for (j = 1; j < dims[1]; j++) { + dset32->arr[i][j] = dset32->arr[i][j - 1] << 1; } val32bits <<= 1; } @@ -8710,16 +9077,17 @@ gent_attr_intscalars(void) H5Aclose(attr); /* Attribute of 64 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I64LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETS64, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset64[i][0] = val64bits; - for(j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j-1] << 1; + dims[0] = F73_XDIM; + dims[1] = F73_YDIM64; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I64LE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DATASETS64, tid, space, H5P_DEFAULT, H5P_DEFAULT); + + val64bits = (int64_t)~0L; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset64->arr[i][0] = val64bits; + for (j = 1; j < dims[1]; j++) { + dset64->arr[i][j] = dset64->arr[i][j - 1] << 1; } val64bits <<= 1; } @@ -8729,14 +9097,15 @@ gent_attr_intscalars(void) H5Aclose(attr); /* Double Dummy set for failure tests */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < dims[0]; i++) - for(j = 0; j < dims[1]; j++) - dsetdbl[i][j] = 0.0001F * (float)j + (float)i; + for (i = 0; i < dims[0]; i++) + for (j = 0; j < dims[1]; j++) + dsetdbl->arr[i][j] = 0.0001 * (double)j + (double)i; H5Awrite(attr, tid, dsetdbl); @@ -8745,6 +9114,16 @@ gent_attr_intscalars(void) H5Gclose(root); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); } /*------------------------------------------------------------------------- @@ -8759,28 +9138,29 @@ gent_attr_intscalars(void) static void gent_string_scalars(void) { - hid_t fid, attr, dataset, space, tid, root; - hsize_t dims[2]; - char string[F73_XDIM][F73_YDIM8]; + hid_t fid, attr, dataset, space, tid, root; + hsize_t dims[2]; + char string[F73_XDIM][F73_YDIM8]; unsigned int i, j; - fid = H5Fcreate(FILE75, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE75, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); /* string scalar */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tcopy(H5T_C_S1); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tcopy(H5T_C_S1); H5Tset_size(tid, F73_XDIM * F73_YDIM8); memset(string, ' ', F73_XDIM * F73_YDIM8); - for(i = 0; i < dims[0]; i++) { + for (i = 0; i < dims[0]; i++) { string[i][0] = (char)('A' + i); - for(j = 1; j < dims[1]; j++) { - string[i][j] = (char)(string[i][j-1] + 1); + for (j = 1; j < dims[1]; j++) { + string[i][j] = (char)(string[i][j - 1] + 1); } } - string[dims[0]-1][dims[1]-1] = 0; + string[dims[0] - 1][dims[1] - 1] = 0; /* Dataset of string scalar */ dataset = H5Dcreate2(fid, "the_str", tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -8799,47 +9179,49 @@ gent_string_scalars(void) H5Fclose(fid); } -static void gent_compound_int_array(void) { - hid_t fid, dataset, space; - hsize_t dims[1]; +static void +gent_compound_int_array(void) +{ + hid_t fid, dataset, space; + hsize_t dims[1]; uint8_t valu8bits; uint16_t valu16bits; uint32_t valu32bits; uint64_t valu64bits; - int8_t val8bits; - int16_t val16bits; - int32_t val32bits; - int64_t val64bits; - hsize_t array_dim8[]={F76_DIM8}; /* Array dimensions */ - hsize_t array_dim16[]={F76_DIM16}; /* Array dimensions */ - hsize_t array_dim32[]={F76_DIM32}; /* Array dimensions */ - hsize_t array_dim64[]={F76_DIM64}; /* Array dimensions */ - hid_t arrayu8_tid; /* Array datatype handle */ - hid_t arrayu16_tid; /* Array datatype handle */ - hid_t arrayu32_tid; /* Array datatype handle */ - hid_t arrayu64_tid; /* Array datatype handle */ - hid_t array8_tid; /* Array datatype handle */ - hid_t array16_tid; /* Array datatype handle */ - hid_t array32_tid; /* Array datatype handle */ - hid_t array64_tid; /* Array datatype handle */ - hid_t arraydbl_tid; /* Array datatype handle */ + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + hsize_t array_dim8[] = {F76_DIM8}; /* Array dimensions */ + hsize_t array_dim16[] = {F76_DIM16}; /* Array dimensions */ + hsize_t array_dim32[] = {F76_DIM32}; /* Array dimensions */ + hsize_t array_dim64[] = {F76_DIM64}; /* Array dimensions */ + hid_t arrayu8_tid; /* Array datatype handle */ + hid_t arrayu16_tid; /* Array datatype handle */ + hid_t arrayu32_tid; /* Array datatype handle */ + hid_t arrayu64_tid; /* Array datatype handle */ + hid_t array8_tid; /* Array datatype handle */ + hid_t array16_tid; /* Array datatype handle */ + hid_t array32_tid; /* Array datatype handle */ + hid_t array64_tid; /* Array datatype handle */ + hid_t arraydbl_tid; /* Array datatype handle */ /* Structure and array for compound types */ typedef struct Cmpd1Struct { - uint8_t dsetu8[F76_DIM8]; - uint16_t dsetu16[F76_DIM16]; - uint32_t dsetu32[F76_DIM32]; - uint64_t dsetu64[F76_DIM64]; - int8_t dset8[F76_DIM8]; - int16_t dset16[F76_DIM16]; - int32_t dset32[F76_DIM32]; - int64_t dset64[F76_DIM64]; - double dsetdbl[F76_DIM8]; + uint8_t dsetu8[F76_DIM8]; + uint16_t dsetu16[F76_DIM16]; + uint32_t dsetu32[F76_DIM32]; + uint64_t dsetu64[F76_DIM64]; + int8_t dset8[F76_DIM8]; + int16_t dset16[F76_DIM16]; + int32_t dset32[F76_DIM32]; + int64_t dset64[F76_DIM64]; + double dsetdbl[F76_DIM8]; } Cmpd1Struct; Cmpd1Struct *Cmpd1; - hid_t Cmpd1Structid; /* File datatype identifier */ - herr_t status; /* Error checking variable */ - hsize_t dim[] = { F76_LENGTH }; /* Dataspace dimensions */ + hid_t Cmpd1Structid; /* File datatype identifier */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Error checking variable */ + hsize_t dim[] = {F76_LENGTH}; /* Dataspace dimensions */ int m, n; /* Array init loop vars */ @@ -8853,26 +9235,26 @@ static void gent_compound_int_array(void) { /* Array of 8 bits unsigned int */ dims[0] = F76_DIM8; - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu8bits = (uint8_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Cmpd1[m].dsetu8[n] = valu8bits; - valu8bits = (uint8_t)(valu8bits << 1); + valu8bits = (uint8_t)(valu8bits << 1); } /* Array of 16 bits unsigned int */ dims[0] = F76_DIM16; - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu16bits = (uint16_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Cmpd1[m].dsetu16[n] = valu16bits; - valu16bits = (uint16_t)(valu16bits << 1); + valu16bits = (uint16_t)(valu16bits << 1); } /* Array of 32 bits unsigned int */ dims[0] = F76_DIM32; - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu32bits = (uint32_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Cmpd1[m].dsetu32[n] = valu32bits; valu32bits <<= 1; } @@ -8880,8 +9262,8 @@ static void gent_compound_int_array(void) { /* Array of 64 bits unsigned int */ dims[0] = F76_DIM64; - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Cmpd1[m].dsetu64[n] = valu64bits; valu64bits <<= 1; } @@ -8889,26 +9271,26 @@ static void gent_compound_int_array(void) { /* Array of 8 bits signed int */ dims[0] = F76_DIM8; - val8bits = (int8_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val8bits = (int8_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Cmpd1[m].dset8[n] = val8bits; - val8bits = (int8_t)(val8bits << 1); + val8bits = (int8_t)(val8bits << 1); } /* Array of 16 bits signed int */ dims[0] = F76_DIM16; - val16bits = (int16_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val16bits = (int16_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Cmpd1[m].dset16[n] = val16bits; - val16bits = (int16_t)(val16bits << 1); + val16bits = (int16_t)(val16bits << 1); } /* Array of 32 bits signed int */ dims[0] = F76_DIM32; - val32bits = (int32_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val32bits = (int32_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Cmpd1[m].dset32[n] = val32bits; val32bits <<= 1; } @@ -8916,8 +9298,8 @@ static void gent_compound_int_array(void) { /* Array of 64 bits signed int */ dims[0] = F76_DIM64; - val64bits = (int64_t) ~0L; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val64bits = (int64_t)~0L; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Cmpd1[m].dset64[n] = val64bits; val64bits <<= 1; } @@ -8925,8 +9307,8 @@ static void gent_compound_int_array(void) { /* Double Dummy set for failure tests */ dims[0] = F76_DIM8; - for(n = 0; n < (int)dims[0]; n++) - Cmpd1[m].dsetdbl[n] = 0.0001F + (float)n; + for (n = 0; n < (int)dims[0]; n++) + Cmpd1[m].dsetdbl[n] = 0.0001 + (double)n; } /* Create the array data type for the 8 bits signed int array */ @@ -9055,47 +9437,49 @@ static void gent_compound_int_array(void) { HDfree(Cmpd1); } -static void gent_compound_ints(void) { - hid_t fid, dataset, space; - uint8_t valu8bits = (uint8_t) ~0u; /* all 1s */ - uint16_t valu16bits = (uint16_t) ~0u; /* all 1s */ - uint32_t valu32bits = (uint32_t) ~0u; /* all 1s */ - uint64_t valu64bits = (uint64_t) ~0Lu; /* all 1s */ - int8_t val8bits = (int8_t) ~0; /* all 1s */ - int16_t val16bits = (int16_t) ~0; /* all 1s */ - int32_t val32bits = (int32_t) ~0; /* all 1s */ - int64_t val64bits = (int64_t) ~0L; /* all 1s */ +static void +gent_compound_ints(void) +{ + hid_t fid, dataset, space; + uint8_t valu8bits = (uint8_t)~0u; /* all 1s */ + uint16_t valu16bits = (uint16_t)~0u; /* all 1s */ + uint32_t valu32bits = (uint32_t)~0u; /* all 1s */ + uint64_t valu64bits = (uint64_t)~0Lu; /* all 1s */ + int8_t val8bits = (int8_t)~0; /* all 1s */ + int16_t val16bits = (int16_t)~0; /* all 1s */ + int32_t val32bits = (int32_t)~0; /* all 1s */ + int64_t val64bits = (int64_t)~0L; /* all 1s */ /* Structure and array for compound types */ typedef struct Cmpd1Struct { - uint8_t dsetu8; - uint16_t dsetu16; - uint32_t dsetu32; - uint64_t dsetu64; - int8_t dset8; - int16_t dset16; - int32_t dset32; - int64_t dset64; - double dsetdbl; + uint8_t dsetu8; + uint16_t dsetu16; + uint32_t dsetu32; + uint64_t dsetu64; + int8_t dset8; + int16_t dset16; + int32_t dset32; + int64_t dset64; + double dsetdbl; } Cmpd1Struct; Cmpd1Struct *Cmpd1; typedef struct Cmpd2Struct { - uint64_t dsetu64; - uint32_t dsetu32; - uint16_t dsetu16; - uint8_t dsetu8; - int64_t dset64; - int32_t dset32; - int16_t dset16; - int8_t dset8; - double dsetdbl; + uint64_t dsetu64; + uint32_t dsetu32; + uint16_t dsetu16; + uint8_t dsetu8; + int64_t dset64; + int32_t dset32; + int16_t dset16; + int8_t dset8; + double dsetdbl; } Cmpd2Struct; Cmpd2Struct *Cmpd2; - hid_t Cmpd1Structid; /* File datatype identifier */ - hid_t Cmpd2Structid; /* File datatype identifier */ - herr_t status; /* Error checking variable */ - hsize_t dim[] = { F77_LENGTH }; /* Dataspace dimensions */ + hid_t Cmpd1Structid; /* File datatype identifier */ + hid_t Cmpd2Structid; /* File datatype identifier */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Error checking variable */ + hsize_t dim[] = {F77_LENGTH}; /* Dataspace dimensions */ int m; /* Array init loop vars */ @@ -9109,64 +9493,64 @@ static void gent_compound_ints(void) { for (m = 0; m < F77_LENGTH; m++) { /* Array of 8 bits unsigned int */ - if((m % F76_DIM8) == 0) - valu8bits = (uint8_t) ~0u; /* all 1s */ + if ((m % F76_DIM8) == 0) + valu8bits = (uint8_t)~0u; /* all 1s */ Cmpd1[m].dsetu8 = valu8bits; Cmpd2[m].dsetu8 = valu8bits; - valu8bits = (uint8_t)(valu8bits << 1); + valu8bits = (uint8_t)(valu8bits << 1); /* Array of 16 bits unsigned int */ - if((m % F76_DIM16) == 0) - valu16bits = (uint16_t) ~0u; /* all 1s */ + if ((m % F76_DIM16) == 0) + valu16bits = (uint16_t)~0u; /* all 1s */ Cmpd1[m].dsetu16 = valu16bits; Cmpd2[m].dsetu16 = valu16bits; - valu16bits = (uint16_t)(valu16bits << 1); + valu16bits = (uint16_t)(valu16bits << 1); /* Array of 32 bits unsigned int */ - if((m % F76_DIM32) == 0) - valu32bits = (uint32_t) ~0u; /* all 1s */ + if ((m % F76_DIM32) == 0) + valu32bits = (uint32_t)~0u; /* all 1s */ Cmpd1[m].dsetu32 = valu32bits; Cmpd2[m].dsetu32 = valu32bits; valu32bits <<= 1; /* Array of 64 bits unsigned int */ - if((m % F76_DIM64) == 0) - valu64bits = (uint64_t) ~0Lu; /* all 1s */ + if ((m % F76_DIM64) == 0) + valu64bits = (uint64_t)~0Lu; /* all 1s */ Cmpd1[m].dsetu64 = valu64bits; Cmpd2[m].dsetu64 = valu64bits; valu64bits <<= 1; /* Array of 8 bits signed int */ - if((m % F76_DIM8) == 0) - val8bits = (int8_t) ~0; /* all 1s */ + if ((m % F76_DIM8) == 0) + val8bits = (int8_t)~0; /* all 1s */ Cmpd1[m].dset8 = val8bits; Cmpd2[m].dset8 = val8bits; - val8bits = (int8_t)(val8bits << 1); + val8bits = (int8_t)(val8bits << 1); /* Array of 16 bits signed int */ - if((m % F76_DIM16) == 0) - val16bits = (int16_t) ~0; /* all 1s */ + if ((m % F76_DIM16) == 0) + val16bits = (int16_t)~0; /* all 1s */ Cmpd1[m].dset16 = val16bits; Cmpd2[m].dset16 = val16bits; - val16bits = (int16_t)(val16bits << 1); + val16bits = (int16_t)(val16bits << 1); /* Array of 32 bits signed int */ - if((m % F76_DIM32) == 0) - val32bits = (int32_t) ~0; /* all 1s */ + if ((m % F76_DIM32) == 0) + val32bits = (int32_t)~0; /* all 1s */ Cmpd1[m].dset32 = val32bits; Cmpd2[m].dset32 = val32bits; val32bits <<= 1; /* Array of 64 bits signed int */ - if((m % F76_DIM64) == 0) - val64bits = (int64_t) ~0L; /* all 1s */ + if ((m % F76_DIM64) == 0) + val64bits = (int64_t)~0L; /* all 1s */ Cmpd1[m].dset64 = val64bits; Cmpd2[m].dset64 = val64bits; val64bits <<= 1; /* Double Dummy set for failure tests */ - Cmpd1[m].dsetdbl = 0.0001F + (float)m; - Cmpd2[m].dsetdbl = 0.0001F + (float)m; + Cmpd1[m].dsetdbl = 0.0001 + (double)m; + Cmpd2[m].dsetdbl = 0.0001 + (double)m; } /* Create the dataspace */ @@ -9299,32 +9683,77 @@ static void gent_compound_ints(void) { static void gent_intattrscalars(void) { - hid_t fid, attr, dataset, space, tid; + hid_t fid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t dsetu8[F73_XDIM][F73_YDIM8], valu8bits; - uint16_t dsetu16[F73_XDIM][F73_YDIM16], valu16bits; - uint32_t dsetu32[F73_XDIM][F73_YDIM32], valu32bits; - uint64_t dsetu64[F73_XDIM][F73_YDIM64], valu64bits; - int8_t dset8[F73_XDIM][F73_YDIM8], val8bits; - int16_t dset16[F73_XDIM][F73_YDIM16], val16bits; - int32_t dset32[F73_XDIM][F73_YDIM32], val32bits; - int64_t dset64[F73_XDIM][F73_YDIM64], val64bits; - double dsetdbl[F73_XDIM][F73_YDIM8]; + + struct { + uint8_t arr[F73_XDIM][F73_YDIM8]; + } *dsetu8 = NULL; + struct { + uint16_t arr[F73_XDIM][F73_YDIM16]; + } *dsetu16 = NULL; + struct { + uint32_t arr[F73_XDIM][F73_YDIM32]; + } *dsetu32 = NULL; + struct { + uint64_t arr[F73_XDIM][F73_YDIM64]; + } *dsetu64 = NULL; + struct { + int8_t arr[F73_XDIM][F73_YDIM8]; + } *dset8 = NULL; + struct { + int16_t arr[F73_XDIM][F73_YDIM16]; + } *dset16 = NULL; + struct { + int32_t arr[F73_XDIM][F73_YDIM32]; + } *dset32 = NULL; + struct { + int64_t arr[F73_XDIM][F73_YDIM64]; + } *dset64 = NULL; + struct { + double arr[F73_XDIM][F73_YDIM8]; + } *dsetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; + /* Create arrays */ + dsetu8 = malloc(sizeof(*dsetu8)); + dsetu16 = malloc(sizeof(*dsetu16)); + dsetu32 = malloc(sizeof(*dsetu32)); + dsetu64 = malloc(sizeof(*dsetu64)); + dset8 = malloc(sizeof(*dset8)); + dset16 = malloc(sizeof(*dset16)); + dset32 = malloc(sizeof(*dset32)); + dset64 = malloc(sizeof(*dset64)); + dsetdbl = malloc(sizeof(*dsetdbl)); + fid = H5Fcreate(FILE78, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U8LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U8LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETU08, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu8[i][0] = valu8bits; - for(j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1); + valu8bits = (uint8_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu8->arr[i][0] = valu8bits; + for (j = 1; j < dims[1]; j++) { + dsetu8->arr[i][j] = (uint8_t)(dsetu8->arr[i][j - 1] << 1); } valu8bits = (uint8_t)(valu8bits << 1); } @@ -9338,16 +9767,17 @@ gent_intattrscalars(void) H5Dclose(dataset); /* Dataset of 16 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U16LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM16; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U16LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETU16, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu16[i][0] = valu16bits; - for(j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); + valu16bits = (uint16_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu16->arr[i][0] = valu16bits; + for (j = 1; j < dims[1]; j++) { + dsetu16->arr[i][j] = (uint16_t)(dsetu16->arr[i][j - 1] << 1); } valu16bits = (uint16_t)(valu16bits << 1); } @@ -9361,16 +9791,17 @@ gent_intattrscalars(void) H5Dclose(dataset); /* Dataset of 32 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U32LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM32; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U32LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETU32, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu32[i][0] = valu32bits; - for(j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j-1] << 1; + valu32bits = (uint32_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu32->arr[i][0] = valu32bits; + for (j = 1; j < dims[1]; j++) { + dsetu32->arr[i][j] = dsetu32->arr[i][j - 1] << 1; } valu32bits <<= 1; } @@ -9384,16 +9815,17 @@ gent_intattrscalars(void) H5Dclose(dataset); /* Dataset of 64 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U64LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM64; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U64LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETU64, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu64[i][0] = valu64bits; - for(j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j-1] << 1; + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu64->arr[i][0] = valu64bits; + for (j = 1; j < dims[1]; j++) { + dsetu64->arr[i][j] = dsetu64->arr[i][j - 1] << 1; } valu64bits <<= 1; } @@ -9407,16 +9839,17 @@ gent_intattrscalars(void) H5Dclose(dataset); /* Dataset of 8 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I8LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I8LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETS08, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset8[i][0] = val8bits; - for(j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); + val8bits = (int8_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset8->arr[i][0] = val8bits; + for (j = 1; j < dims[1]; j++) { + dset8->arr[i][j] = (int8_t)(dset8->arr[i][j - 1] << 1); } val8bits = (int8_t)(val8bits << 1); } @@ -9430,16 +9863,17 @@ gent_intattrscalars(void) H5Dclose(dataset); /* Dataset of 16 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I16LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM16; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I16LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETS16, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset16[i][0] = val16bits; - for(j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); + val16bits = (int16_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset16->arr[i][0] = val16bits; + for (j = 1; j < dims[1]; j++) { + dset16->arr[i][j] = (int16_t)(dset16->arr[i][j - 1] << 1); } val16bits = (int16_t)(val16bits << 1); } @@ -9453,16 +9887,17 @@ gent_intattrscalars(void) H5Dclose(dataset); /* Dataset of 32 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I32LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM32; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I32LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETS32, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset32[i][0] = val32bits; - for(j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j-1] << 1; + val32bits = (int32_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset32->arr[i][0] = val32bits; + for (j = 1; j < dims[1]; j++) { + dset32->arr[i][j] = dset32->arr[i][j - 1] << 1; } val32bits <<= 1; } @@ -9476,16 +9911,17 @@ gent_intattrscalars(void) H5Dclose(dataset); /* Dataset of 64 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I64LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM64; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I64LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETS64, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset64[i][0] = val64bits; - for(j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j-1] << 1; + val64bits = (int64_t)~0L; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset64->arr[i][0] = val64bits; + for (j = 1; j < dims[1]; j++) { + dset64->arr[i][j] = dset64->arr[i][j - 1] << 1; } val64bits <<= 1; } @@ -9499,23 +9935,35 @@ gent_intattrscalars(void) H5Dclose(dataset); /* Double Dummy set for failure tests */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < dims[0]; i++) - for(j = 0; j < dims[1]; j++) - dsetdbl[i][j] = 0.0001F * (float)j + (float)i; + for (i = 0; i < dims[0]; i++) + for (j = 0; j < dims[1]; j++) + dsetdbl->arr[i][j] = 0.0001 * (double)j + (double)i; H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); /* Attribute of double */ attr = H5Acreate2(dataset, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, tid, dsetdbl); + H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); } /*------------------------------------------------------------------------- @@ -9531,33 +9979,98 @@ gent_intattrscalars(void) static void gent_intsattrs(void) { - hid_t fid, attr, dataset, space, aspace; + hid_t fid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t aspace = H5I_INVALID_HID; hsize_t dims[2], adims[1]; - uint8_t dsetu8[F66_XDIM][F66_YDIM8], asetu8[F66_XDIM*F66_YDIM8], valu8bits; - uint16_t dsetu16[F66_XDIM][F66_YDIM16], asetu16[F66_XDIM*F66_YDIM16], valu16bits; - uint32_t dsetu32[F66_XDIM][F66_YDIM32], asetu32[F66_XDIM*F66_YDIM32], valu32bits; - uint64_t dsetu64[F66_XDIM][F66_YDIM64], asetu64[F66_XDIM*F66_YDIM64], valu64bits; - int8_t dset8[F66_XDIM][F66_YDIM8], aset8[F66_XDIM*F66_YDIM8], val8bits; - int16_t dset16[F66_XDIM][F66_YDIM16], aset16[F66_XDIM*F66_YDIM16], val16bits; - int32_t dset32[F66_XDIM][F66_YDIM32], aset32[F66_XDIM*F66_YDIM32], val32bits; - int64_t dset64[F66_XDIM][F66_YDIM64], aset64[F66_XDIM*F66_YDIM64], val64bits; - double dsetdbl[F66_XDIM][F66_YDIM8], asetdbl[F66_XDIM*F66_YDIM8]; + + struct { + uint8_t arr[F66_XDIM][F66_YDIM8]; + } * dsetu8; + struct { + uint16_t arr[F66_XDIM][F66_YDIM16]; + } * dsetu16; + struct { + uint32_t arr[F66_XDIM][F66_YDIM32]; + } * dsetu32; + struct { + uint64_t arr[F66_XDIM][F66_YDIM64]; + } * dsetu64; + struct { + int8_t arr[F66_XDIM][F66_YDIM8]; + } * dset8; + struct { + int16_t arr[F66_XDIM][F66_YDIM16]; + } * dset16; + struct { + int32_t arr[F66_XDIM][F66_YDIM32]; + } * dset32; + struct { + int64_t arr[F66_XDIM][F66_YDIM64]; + } * dset64; + struct { + double arr[F66_XDIM][F66_YDIM8]; + } * dsetdbl; + + uint8_t * asetu8 = NULL; + uint16_t *asetu16 = NULL; + uint32_t *asetu32 = NULL; + uint64_t *asetu64 = NULL; + int8_t * aset8 = NULL; + int16_t * aset16 = NULL; + int32_t * aset32 = NULL; + int64_t * aset64 = NULL; + double * asetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; + /* Create arrays */ + dsetu8 = malloc(sizeof(*dsetu8)); + dsetu16 = malloc(sizeof(*dsetu16)); + dsetu32 = malloc(sizeof(*dsetu32)); + dsetu64 = malloc(sizeof(*dsetu64)); + dset8 = malloc(sizeof(*dset8)); + dset16 = malloc(sizeof(*dset16)); + dset32 = malloc(sizeof(*dset32)); + dset64 = malloc(sizeof(*dset64)); + dsetdbl = malloc(sizeof(*dsetdbl)); + + asetu8 = HDcalloc(F66_XDIM * F66_YDIM8, sizeof(uint8_t)); + asetu16 = HDcalloc(F66_XDIM * F66_YDIM16, sizeof(uint16_t)); + asetu32 = HDcalloc(F66_XDIM * F66_YDIM32, sizeof(uint32_t)); + asetu64 = HDcalloc(F66_XDIM * F66_YDIM64, sizeof(uint64_t)); + aset8 = HDcalloc(F66_XDIM * F66_YDIM8, sizeof(int8_t)); + aset16 = HDcalloc(F66_XDIM * F66_YDIM16, sizeof(int16_t)); + aset32 = HDcalloc(F66_XDIM * F66_YDIM32, sizeof(int32_t)); + aset64 = HDcalloc(F66_XDIM * F66_YDIM64, sizeof(int64_t)); + asetdbl = HDcalloc(F66_XDIM * F66_YDIM8, sizeof(double)); + fid = H5Fcreate(FILE79, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU08, H5T_STD_U8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu8[i][0] = valu8bits; - asetu8[i*dims[1]] = dsetu8[i][0]; - for(j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1); - asetu8[i*dims[1]+j] = dsetu8[i][j]; + valu8bits = (uint8_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu8->arr[i][0] = valu8bits; + asetu8[i * dims[1]] = dsetu8->arr[i][0]; + for (j = 1; j < dims[1]; j++) { + dsetu8->arr[i][j] = (uint8_t)(dsetu8->arr[i][j - 1] << 1); + asetu8[i * dims[1] + j] = dsetu8->arr[i][j]; } valu8bits = (uint8_t)(valu8bits << 1); } @@ -9565,8 +10078,8 @@ gent_intsattrs(void) H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8); /* Attribute of 8 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM8; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETU08, H5T_STD_U8LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DATASETU08, H5T_STD_U8LE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_UINT8, asetu8); H5Aclose(attr); H5Sclose(aspace); @@ -9574,17 +10087,18 @@ gent_intsattrs(void) H5Dclose(dataset); /* Dataset of 16 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU16, H5T_STD_U16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu16[i][0] = valu16bits; - asetu16[i*dims[1]] = dsetu16[i][0]; - for(j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); - asetu16[i*dims[1]+j] = dsetu16[i][j]; + valu16bits = (uint16_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu16->arr[i][0] = valu16bits; + asetu16[i * dims[1]] = dsetu16->arr[i][0]; + for (j = 1; j < dims[1]; j++) { + dsetu16->arr[i][j] = (uint16_t)(dsetu16->arr[i][j - 1] << 1); + asetu16[i * dims[1] + j] = dsetu16->arr[i][j]; } valu16bits = (uint16_t)(valu16bits << 1); } @@ -9592,8 +10106,8 @@ gent_intsattrs(void) H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16); /* Attribute of 16 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM16; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETU16, H5T_STD_U16LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DATASETU16, H5T_STD_U16LE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_UINT16, asetu16); H5Aclose(attr); H5Sclose(aspace); @@ -9601,17 +10115,18 @@ gent_intsattrs(void) H5Dclose(dataset); /* Dataset of 32 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU32, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu32[i][0] = valu32bits; - asetu32[i*dims[1]] = dsetu32[i][0]; - for(j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j-1] << 1; - asetu32[i*dims[1]+j] = dsetu32[i][j]; + valu32bits = (uint32_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu32->arr[i][0] = valu32bits; + asetu32[i * dims[1]] = dsetu32->arr[i][0]; + for (j = 1; j < dims[1]; j++) { + dsetu32->arr[i][j] = dsetu32->arr[i][j - 1] << 1; + asetu32[i * dims[1] + j] = dsetu32->arr[i][j]; } valu32bits <<= 1; } @@ -9619,8 +10134,8 @@ gent_intsattrs(void) H5Dwrite(dataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32); /* Attribute of 32 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM32; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETU32, H5T_STD_U32LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DATASETU32, H5T_STD_U32LE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_UINT32, asetu32); H5Aclose(attr); H5Sclose(aspace); @@ -9628,17 +10143,18 @@ gent_intsattrs(void) H5Dclose(dataset); /* Dataset of 64 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU64, H5T_STD_U64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu64[i][0] = valu64bits; - asetu64[i*dims[1]] = dsetu64[i][0]; - for(j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j-1] << 1; - asetu64[i*dims[1]+j] = dsetu64[i][j]; + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu64->arr[i][0] = valu64bits; + asetu64[i * dims[1]] = dsetu64->arr[i][0]; + for (j = 1; j < dims[1]; j++) { + dsetu64->arr[i][j] = dsetu64->arr[i][j - 1] << 1; + asetu64[i * dims[1] + j] = dsetu64->arr[i][j]; } valu64bits <<= 1; } @@ -9646,8 +10162,8 @@ gent_intsattrs(void) H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64); /* Attribute of 64 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM64; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETU64, H5T_STD_U64LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DATASETU64, H5T_STD_U64LE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_UINT64, asetu64); H5Aclose(attr); H5Sclose(aspace); @@ -9655,17 +10171,18 @@ gent_intsattrs(void) H5Dclose(dataset); /* Dataset of 8 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS08, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset8[i][0] = val8bits; - aset8[i*dims[1]] = dset8[i][0]; - for(j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); - aset8[i*dims[1]+j] = dset8[i][j]; + val8bits = (int8_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset8->arr[i][0] = val8bits; + aset8[i * dims[1]] = dset8->arr[i][0]; + for (j = 1; j < dims[1]; j++) { + dset8->arr[i][j] = (int8_t)(dset8->arr[i][j - 1] << 1); + aset8[i * dims[1] + j] = dset8->arr[i][j]; } val8bits = (int8_t)(val8bits << 1); } @@ -9673,8 +10190,8 @@ gent_intsattrs(void) H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8); /* Attribute of 8 bits signed int */ adims[0] = F66_XDIM * F66_YDIM8; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETS08, H5T_STD_I8LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DATASETS08, H5T_STD_I8LE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_INT8, aset8); H5Aclose(attr); H5Sclose(aspace); @@ -9682,17 +10199,18 @@ gent_intsattrs(void) H5Dclose(dataset); /* Dataset of 16 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS16, H5T_STD_I16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset16[i][0] = val16bits; - aset16[i*dims[1]] = dset16[i][0]; - for(j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); - aset16[i*dims[1]+j] = dset16[i][j]; + val16bits = (int16_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset16->arr[i][0] = val16bits; + aset16[i * dims[1]] = dset16->arr[i][0]; + for (j = 1; j < dims[1]; j++) { + dset16->arr[i][j] = (int16_t)(dset16->arr[i][j - 1] << 1); + aset16[i * dims[1] + j] = dset16->arr[i][j]; } val16bits = (int16_t)(val16bits << 1); } @@ -9700,8 +10218,8 @@ gent_intsattrs(void) H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); /* Attribute of 16 bits signed int */ adims[0] = F66_XDIM * F66_YDIM16; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETS16, H5T_STD_I16LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DATASETS16, H5T_STD_I16LE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_INT16, aset16); H5Aclose(attr); H5Sclose(aspace); @@ -9709,17 +10227,18 @@ gent_intsattrs(void) H5Dclose(dataset); /* Dataset of 32 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS32, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset32[i][0] = val32bits; - aset32[i*dims[1]] = dset32[i][0]; - for(j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j-1] << 1; - aset32[i*dims[1]+j] = dset32[i][j]; + val32bits = (int32_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset32->arr[i][0] = val32bits; + aset32[i * dims[1]] = dset32->arr[i][0]; + for (j = 1; j < dims[1]; j++) { + dset32->arr[i][j] = dset32->arr[i][j - 1] << 1; + aset32[i * dims[1] + j] = dset32->arr[i][j]; } val32bits <<= 1; } @@ -9727,8 +10246,8 @@ gent_intsattrs(void) H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); /* Attribute of 32 bits signed int */ adims[0] = F66_XDIM * F66_YDIM32; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETS32, H5T_STD_I32LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DATASETS32, H5T_STD_I32LE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_INT32, aset32); H5Aclose(attr); H5Sclose(aspace); @@ -9736,17 +10255,18 @@ gent_intsattrs(void) H5Dclose(dataset); /* Dataset of 64 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS64, H5T_STD_I64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset64[i][0] = val64bits; - aset64[i*dims[1]] = dset64[i][0]; - for(j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j-1] << 1; - aset64[i*dims[1]+j] = dset64[i][j]; + val64bits = (int64_t)~0L; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset64->arr[i][0] = val64bits; + aset64[i * dims[1]] = dset64->arr[i][0]; + for (j = 1; j < dims[1]; j++) { + dset64->arr[i][j] = dset64->arr[i][j - 1] << 1; + aset64[i * dims[1] + j] = dset64->arr[i][j]; } val64bits <<= 1; } @@ -9754,8 +10274,8 @@ gent_intsattrs(void) H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); /* Attribute of 64 bits signed int */ adims[0] = F66_XDIM * F66_YDIM64; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETS64, H5T_STD_I64LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DATASETS64, H5T_STD_I64LE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_INT64, aset64); H5Aclose(attr); H5Sclose(aspace); @@ -9763,58 +10283,233 @@ gent_intsattrs(void) H5Dclose(dataset); /* Double Dummy set for failure tests */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DUMMYDBL, H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < dims[0]; i++) - for(j = 0; j < dims[1]; j++) { - dsetdbl[i][j] = 0.0001F * (float)j + (float)i; - asetdbl[i*dims[1]+j] = dsetdbl[i][j]; + for (i = 0; i < dims[0]; i++) + for (j = 0; j < dims[1]; j++) { + dsetdbl->arr[i][j] = 0.0001 * (double)j + (double)i; + asetdbl[i * dims[1] + j] = dsetdbl->arr[i][j]; } H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); /* Attribute of double */ adims[0] = F66_XDIM * F66_YDIM8; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DUMMYDBL, H5T_IEEE_F64BE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DUMMYDBL, H5T_IEEE_F64BE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_DOUBLE, asetdbl); H5Aclose(attr); H5Sclose(aspace); H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); + + HDfree(asetu8); + HDfree(asetu16); + HDfree(asetu32); + HDfree(asetu64); + HDfree(aset8); + HDfree(aset16); + HDfree(aset32); + HDfree(aset64); + HDfree(asetdbl); } -static void gent_bitnopaquefields(void) +/*------------------------------------------------------------------------- + * Function: gent_floatsattrs + * + * Purpose: Generate a file to be used in the h5dump tests. + * Three datasets of 4, 8 and 16 bytes of float types are created. + * Fill them with raw data such that no bit will be all zero in a dataset. + *------------------------------------------------------------------------- + */ +static void +gent_floatsattrs(void) +{ + hid_t fid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t aspace = H5I_INVALID_HID; + hsize_t dims[2], adims[1]; + + struct { + float arr[F89_XDIM][F89_YDIM32]; + } * dset32; + struct { + double arr[F89_XDIM][F89_YDIM64]; + } * dset64; + struct { + long double arr[F89_XDIM][F89_YDIM128]; + } * dset128; + + float * aset32 = NULL; + double * aset64 = NULL; + long double *aset128 = NULL; + + float val32bits; + double val64bits; + long double val128bits; + + unsigned int i, j; + + /* Create arrays */ + dset32 = malloc(sizeof(*dset32)); + dset64 = malloc(sizeof(*dset64)); + dset128 = malloc(sizeof(*dset128)); + + aset32 = HDcalloc(F89_XDIM * F89_YDIM32, sizeof(float)); + aset64 = HDcalloc(F89_XDIM * F89_YDIM64, sizeof(double)); + aset128 = HDcalloc(F89_XDIM * F89_YDIM128, sizeof(long double)); + + fid = H5Fcreate(FILE89, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + if ((tid = H5Tcopy(H5T_NATIVE_LDOUBLE)) < 0) + goto error; + + if (H5Tget_size(tid) == 0) + goto error; + + /* Dataset of 32 bits float */ + dims[0] = F89_XDIM; + dims[1] = F89_YDIM32; + space = H5Screate_simple(2, dims, NULL); + dataset = H5Dcreate2(fid, F89_DATASETF32, H5T_IEEE_F32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + val32bits = (float)F89_YDIM32; + for (i = 0; i < dims[0]; i++) { + dset32->arr[i][0] = val32bits; + aset32[i * dims[1]] = dset32->arr[i][0]; + for (j = 1; j < dims[1]; j++) { + dset32->arr[i][j] = (float)(j * dims[0] + i) / (float)F89_YDIM32; + aset32[i * dims[1] + j] = dset32->arr[i][j]; + } + val32bits -= (float)1; + } + + H5Dwrite(dataset, H5T_IEEE_F32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); + /* Attribute of 32 bits float */ + adims[0] = F89_XDIM * F89_YDIM32; + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F89_DATASETF32, H5T_IEEE_F32LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + H5Awrite(attr, H5T_IEEE_F32LE, aset32); + H5Aclose(attr); + H5Sclose(aspace); + H5Sclose(space); + H5Dclose(dataset); + + /* Dataset of 64 bits double */ + dims[0] = F89_XDIM; + dims[1] = F89_YDIM64; + space = H5Screate_simple(2, dims, NULL); + dataset = H5Dcreate2(fid, F89_DATASETF64, H5T_IEEE_F64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + val64bits = (double)F89_YDIM64; + for (i = 0; i < dims[0]; i++) { + dset64->arr[i][0] = val64bits; + aset64[i * dims[1]] = dset64->arr[i][0]; + for (j = 1; j < dims[1]; j++) { + dset64->arr[i][j] = (double)(j * dims[0] + i) / (double)F89_YDIM64; + aset64[i * dims[1] + j] = dset64->arr[i][j]; + } + val64bits -= (double)1; + } + + H5Dwrite(dataset, H5T_IEEE_F64LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); + /* Attribute of 64 bits double */ + adims[0] = F89_XDIM * F89_YDIM64; + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F89_DATASETF64, H5T_IEEE_F64LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + H5Awrite(attr, H5T_IEEE_F64LE, aset64); + H5Aclose(attr); + H5Sclose(aspace); + H5Sclose(space); + H5Dclose(dataset); + + /* Dataset of 128 bits long double */ + dims[0] = F89_XDIM; + dims[1] = F89_YDIM128; + space = H5Screate_simple(2, dims, NULL); + dataset = H5Dcreate2(fid, F89_DATASETF128, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + val128bits = (long double)F89_YDIM128; + for (i = 0; i < dims[0]; i++) { + dset128->arr[i][0] = val128bits; + aset128[i * dims[1]] = dset128->arr[i][0]; + for (j = 1; j < dims[1]; j++) { + dset128->arr[i][j] = (long double)(j * dims[0] + i) / (long double)F89_YDIM128; + aset128[i * dims[1] + j] = dset128->arr[i][j]; + } + val128bits -= (long double)1; + } + + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset128); + /* Attribute of 128 bits long double */ + adims[0] = F89_XDIM * F89_YDIM128; + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F89_DATASETF128, tid, aspace, H5P_DEFAULT, H5P_DEFAULT); + H5Awrite(attr, tid, aset128); + H5Aclose(attr); + H5Sclose(aspace); + H5Sclose(space); + H5Dclose(dataset); + +error: + H5Fclose(fid); + + HDfree(dset32); + HDfree(dset64); + HDfree(dset128); + + HDfree(aset32); + HDfree(aset64); + HDfree(aset128); +} + +static void +gent_bitnopaquefields(void) { /* Compound datatype */ - typedef struct s_t - { - uint8_t a; - uint16_t b; - uint32_t c; - uint64_t d; + typedef struct s_t { + uint8_t a; + uint16_t b; + uint32_t c; + uint64_t d; } s_t; - hid_t file, grp=-1, type=-1, space=-1, dset=-1; - size_t i; + hid_t file_id = H5I_INVALID_HID, grp = H5I_INVALID_HID, type = H5I_INVALID_HID, space = H5I_INVALID_HID, + dset = H5I_INVALID_HID; + size_t i; hsize_t nelmts = F80_DIM32; - uint8_t buf[F80_DIM32]; /* bitfield, opaque */ - uint16_t buf2[F80_DIM32]; /* bitfield, opaque */ - uint32_t buf3[F80_DIM32]; /* bitfield, opaque */ - uint64_t buf4[F80_DIM32]; /* bitfield, opaque */ - s_t buf5[F80_DIM32]; /* compound */ + uint8_t buf[F80_DIM32]; /* bitfield, opaque */ + uint16_t buf2[F80_DIM32]; /* bitfield, opaque */ + uint32_t buf3[F80_DIM32]; /* bitfield, opaque */ + uint64_t buf4[F80_DIM32]; /* bitfield, opaque */ + s_t buf5[F80_DIM32]; /* compound */ - file = H5Fcreate(FILE80, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file_id = H5Fcreate(FILE80, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if ((grp = H5Gcreate2(file, "bittypetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((grp = H5Gcreate2(file_id, "bittypetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { /* bitfield_1 */ if ((type = H5Tcopy(H5T_STD_B8LE)) >= 0) { if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "bitfield_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((dset = H5Dcreate2(grp, "bitfield_1", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { for (i = 0; i < nelmts; i++) { - buf[i] = (uint8_t)0xff ^ (uint8_t)i; + buf[i] = (uint8_t)(0xff ^ i); } H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); H5Dclose(dset); @@ -9827,9 +10522,10 @@ static void gent_bitnopaquefields(void) /* bitfield_2 */ if ((type = H5Tcopy(H5T_STD_B16LE)) >= 0) { if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "bitfield_2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((dset = H5Dcreate2(grp, "bitfield_2", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { for (i = 0; i < nelmts; i++) { - buf2[i] = (uint16_t)0xffff ^ (uint16_t)(i * 16); + buf2[i] = (uint16_t)(0xffff ^ (i * 16)); } H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2); H5Dclose(dset); @@ -9842,7 +10538,8 @@ static void gent_bitnopaquefields(void) /* bitfield_3 */ if ((type = H5Tcopy(H5T_STD_B32LE)) >= 0) { if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "bitfield_3", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((dset = H5Dcreate2(grp, "bitfield_3", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { for (i = 0; i < nelmts; i++) { buf3[i] = (uint32_t)0xffffffff ^ (uint32_t)(i * 32); } @@ -9857,7 +10554,8 @@ static void gent_bitnopaquefields(void) /* bitfield_4 */ if ((type = H5Tcopy(H5T_STD_B64LE)) >= 0) { if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "bitfield_4", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((dset = H5Dcreate2(grp, "bitfield_4", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { for (i = 0; i < nelmts; i++) { buf4[i] = (uint64_t)0xffffffffffffffff ^ (uint64_t)(i * 64); } @@ -9872,14 +10570,15 @@ static void gent_bitnopaquefields(void) H5Gclose(grp); } - if ((grp = H5Gcreate2(file, "opaquetypetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((grp = H5Gcreate2(file_id, "opaquetypetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { /* opaque_1 */ if ((type = H5Tcreate(H5T_OPAQUE, 1)) >= 0) { if ((H5Tset_tag(type, "1-byte opaque type")) >= 0) { if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "opaque_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for(i = 0; i < nelmts; i++) - buf[i] = (uint8_t)0xff ^ (uint8_t)i; + if ((dset = H5Dcreate2(grp, "opaque_1", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { + for (i = 0; i < nelmts; i++) + H5_CHECKED_ASSIGN(buf[i], uint8_t, 0xff ^ i, size_t); H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); H5Dclose(dset); } @@ -9893,9 +10592,10 @@ static void gent_bitnopaquefields(void) if ((type = H5Tcreate(H5T_OPAQUE, 2)) >= 0) { if ((H5Tset_tag(type, "2-byte opaque type")) >= 0) { if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "opaque_2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for(i = 0; i < nelmts; i++) - buf2[i] = (uint16_t)0xffff ^ (uint16_t)(i * 16); + if ((dset = H5Dcreate2(grp, "opaque_2", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { + for (i = 0; i < nelmts; i++) + H5_CHECKED_ASSIGN(buf2[i], uint16_t, 0xffff ^ (i * 16), size_t); H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2); H5Dclose(dset); @@ -9908,7 +10608,7 @@ static void gent_bitnopaquefields(void) H5Gclose(grp); } - if ((grp = H5Gcreate2(file, "cmpdtypetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((grp = H5Gcreate2(file_id, "cmpdtypetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { /* compound_1 */ if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); @@ -9916,10 +10616,11 @@ static void gent_bitnopaquefields(void) H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for(i = 0; i < nelmts; i++) { - buf5[i].a = (uint8_t)0xff ^ (uint8_t)i; - buf5[i].b = (uint16_t)0xffff ^ (uint16_t)(i * 16); + if ((dset = H5Dcreate2(grp, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { + for (i = 0; i < nelmts; i++) { + H5_CHECKED_ASSIGN(buf5[i].a, uint8_t, 0xff ^ i, size_t); + H5_CHECKED_ASSIGN(buf5[i].b, uint16_t, 0xffff ^ (i * 16), size_t); buf5[i].c = (uint32_t)0xffffffff ^ (uint32_t)(i * 32); buf5[i].d = (uint64_t)0xffffffffffffffff ^ (uint64_t)(i * 64); } @@ -9934,7 +10635,7 @@ static void gent_bitnopaquefields(void) H5Gclose(grp); } - H5Fclose(file); + H5Fclose(file_id); } /*------------------------------------------------------------------------- @@ -9947,29 +10648,38 @@ static void gent_bitnopaquefields(void) static void gent_intsfourdims(void) { - hid_t fid, dataset, space; + hid_t fid, dataset, space; hsize_t dims[F81_RANK]; - uint32_t dset1[F81_ZDIM][F81_YDIM][F81_XDIM][F81_WDIM]; + struct { + uint32_t arr[F81_ZDIM][F81_YDIM][F81_XDIM][F81_WDIM]; + } * dset1; unsigned int i, j, k, l; fid = H5Fcreate(FILE81, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + dset1 = malloc(sizeof(*dset1)); + /* Dataset of 32 bits unsigned int */ - dims[0] = F81_ZDIM; dims[1] = F81_YDIM; dims[2] = F81_XDIM; dims[3] = F81_WDIM; - space = H5Screate_simple(F81_RANK, dims, NULL); + dims[0] = F81_ZDIM; + dims[1] = F81_YDIM; + dims[2] = F81_XDIM; + dims[3] = F81_WDIM; + space = H5Screate_simple(F81_RANK, dims, NULL); dataset = H5Dcreate2(fid, F81_DATASETNAME, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < F81_ZDIM; i++) - for(j = 0; j < F81_YDIM; j++) - for(k = 0; k < F81_XDIM; k++) - for(l = 0; l < F81_WDIM; l++) - dset1[i][j][k][l] = i*F81_YDIM*F81_XDIM*F81_WDIM + j*F81_XDIM*F81_WDIM + k*F81_WDIM + l; + for (i = 0; i < F81_ZDIM; i++) + for (j = 0; j < F81_YDIM; j++) + for (k = 0; k < F81_XDIM; k++) + for (l = 0; l < F81_WDIM; l++) + dset1->arr[i][j][k][l] = + i * F81_YDIM * F81_XDIM * F81_WDIM + j * F81_XDIM * F81_WDIM + k * F81_WDIM + l; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); + free(dset1); } /*------------------------------------------------------------------------- @@ -9979,7 +10689,8 @@ gent_intsfourdims(void) * various sizes, dimensions, member types and nesting. *------------------------------------------------------------------------- */ -static void gent_compound_complex2(void) +static void +gent_compound_complex2(void) { /* Third-level nested compound */ typedef struct { @@ -9999,45 +10710,42 @@ static void gent_compound_complex2(void) } further_nested; typedef struct { - char further_nested_string[11]; - char further_nested_string_array[4][13]; + char further_nested_string[11]; + char further_nested_string_array[4][13]; third_level_compound deep_nest; } further_nested2; /* First First-level nested compound */ - typedef struct - { + typedef struct { double nested_a; char nested_string[23]; char nested_string_array[4][12]; } nested_compound; /* Second First-level nested compound */ - typedef struct - { + typedef struct { float a; further_nested b; further_nested2 c; } multiple_nested_compound; /* Compound datatype with different member types */ - typedef struct - { + typedef struct { /* Arrays nested inside compound */ unsigned int a[4]; int b[6]; float c[2][4]; - nested_compound d; /* Compound inside compound */ - multiple_nested_compound e; /* Compound inside compound with further nested compound */ + nested_compound d; /* Compound inside compound */ + multiple_nested_compound e; /* Compound inside compound with further nested compound */ } compound; - compound *buf; /* compound */ + compound *buf; /* compound */ - hid_t file, type=-1, space=-1, dset=-1; - hid_t dset_array_a, dset_array_b, dset_array_c; - hid_t cmpd_tid1 = -1, cmpd_tid2 = -1, cmpd_tid3 = -1; - size_t i; - size_t j, k; + hid_t file, type = H5I_INVALID_HID, space = H5I_INVALID_HID, dset = H5I_INVALID_HID; + hid_t dset_array_a, dset_array_b, dset_array_c; + hid_t cmpd_tid1 = H5I_INVALID_HID, cmpd_tid2 = H5I_INVALID_HID, cmpd_tid3 = H5I_INVALID_HID; + size_t i; + size_t j, k; unsigned dset_array_ndims; hsize_t dset_array_a_dims[1], dset_array_b_dims[1], dset_array_c_dims[2]; hsize_t nelmts = F82_DIM32; @@ -10051,23 +10759,27 @@ static void gent_compound_complex2(void) if ((space = H5Screate_simple(F82_RANK, &nelmts, NULL)) >= 0) { /* CompoundComplex1D */ if ((type = H5Tcreate(H5T_COMPOUND, sizeof(compound))) >= 0) { - hid_t str_type, array; + hid_t str_type, array; hsize_t dims[1]; - hid_t nest1, nest2; + hid_t nest1, nest2; /* Insert top-level array members */ - dset_array_ndims = 1; dset_array_a_dims[0] = 4; - dset_array_a = H5Tarray_create2(H5T_STD_U32LE, dset_array_ndims, dset_array_a_dims); + dset_array_ndims = 1; + dset_array_a_dims[0] = 4; + dset_array_a = H5Tarray_create2(H5T_STD_U32LE, dset_array_ndims, dset_array_a_dims); H5Tinsert(type, "a", HOFFSET(compound, a), dset_array_a); H5Tclose(dset_array_a); - dset_array_ndims = 1; dset_array_b_dims[0] = 6; - dset_array_b = H5Tarray_create2(H5T_STD_I32LE, dset_array_ndims, dset_array_b_dims); + dset_array_ndims = 1; + dset_array_b_dims[0] = 6; + dset_array_b = H5Tarray_create2(H5T_STD_I32LE, dset_array_ndims, dset_array_b_dims); H5Tinsert(type, "b", HOFFSET(compound, b), dset_array_b); H5Tclose(dset_array_b); - dset_array_ndims = 2; dset_array_c_dims[0] = 2; dset_array_c_dims[1] = 4; - dset_array_c = H5Tarray_create2(H5T_IEEE_F32LE, dset_array_ndims, dset_array_c_dims); + dset_array_ndims = 2; + dset_array_c_dims[0] = 2; + dset_array_c_dims[1] = 4; + dset_array_c = H5Tarray_create2(H5T_IEEE_F32LE, dset_array_ndims, dset_array_c_dims); H5Tinsert(type, "c", HOFFSET(compound, c), dset_array_c); H5Tclose(dset_array_c); @@ -10076,16 +10788,16 @@ static void gent_compound_complex2(void) H5Tinsert(cmpd_tid1, "nested_double", HOFFSET(nested_compound, nested_a), H5T_IEEE_F64LE); - dims[0] = 1; + dims[0] = 1; str_type = mkstr(23, H5T_STR_NULLTERM); - array = H5Tarray_create2(str_type, 1, dims); + array = H5Tarray_create2(str_type, 1, dims); H5Tinsert(cmpd_tid1, "nested_string", HOFFSET(nested_compound, nested_string), array); H5Tclose(array); H5Tclose(str_type); - dims[0] = 4; + dims[0] = 4; str_type = mkstr(12, H5T_STR_NULLTERM); - array = H5Tarray_create2(str_type, 1, dims); + array = H5Tarray_create2(str_type, 1, dims); H5Tinsert(cmpd_tid1, "nested_string_array", HOFFSET(nested_compound, nested_string_array), array); H5Tclose(array); H5Tclose(str_type); @@ -10101,7 +10813,7 @@ static void gent_compound_complex2(void) nest1 = H5Tcreate(H5T_COMPOUND, sizeof(further_nested)); dims[0] = 5; - array = H5Tarray_create2(H5T_STD_U32LE, 1, dims); + array = H5Tarray_create2(H5T_STD_U32LE, 1, dims); H5Tinsert(nest1, "nested_unsigned_int", HOFFSET(further_nested, multiple_nested_a), array); H5Tclose(array); @@ -10123,17 +10835,18 @@ static void gent_compound_complex2(void) /* Add second further nested compound */ nest2 = H5Tcreate(H5T_COMPOUND, sizeof(further_nested2)); - dims[0] = 1; + dims[0] = 1; str_type = mkstr(11, H5T_STR_NULLTERM); - array = H5Tarray_create2(str_type, 1, dims); + array = H5Tarray_create2(str_type, 1, dims); H5Tinsert(nest2, "nested_string", HOFFSET(further_nested2, further_nested_string), array); H5Tclose(array); H5Tclose(str_type); - dims[0] = 4; + dims[0] = 4; str_type = mkstr(13, H5T_STR_NULLTERM); - array = H5Tarray_create2(str_type, 1, dims); - H5Tinsert(nest2, "nested_string_array", HOFFSET(further_nested2, further_nested_string_array), array); + array = H5Tarray_create2(str_type, 1, dims); + H5Tinsert(nest2, "nested_string_array", HOFFSET(further_nested2, further_nested_string_array), + array); H5Tclose(array); H5Tclose(str_type); @@ -10141,8 +10854,9 @@ static void gent_compound_complex2(void) cmpd_tid3 = H5Tcreate(H5T_COMPOUND, sizeof(third_level_compound)); dims[0] = 10; - array = H5Tarray_create2(H5T_STD_I16LE, 1, dims); - H5Tinsert(cmpd_tid3, "deep_nested_short", HOFFSET(third_level_compound, deep_nested_short), array); + array = H5Tarray_create2(H5T_STD_I16LE, 1, dims); + H5Tinsert(cmpd_tid3, "deep_nested_short", HOFFSET(third_level_compound, deep_nested_short), + array); H5Tclose(array); array = H5Tarray_create2(H5T_STD_I32LE, 1, dims); @@ -10154,11 +10868,13 @@ static void gent_compound_complex2(void) H5Tclose(array); array = H5Tarray_create2(H5T_IEEE_F64LE, 1, dims); - H5Tinsert(cmpd_tid3, "deep_nested_double", HOFFSET(third_level_compound, deep_nested_double), array); + H5Tinsert(cmpd_tid3, "deep_nested_double", HOFFSET(third_level_compound, deep_nested_double), + array); H5Tclose(array); array = H5Tarray_create2(H5T_IEEE_F32LE, 1, dims); - H5Tinsert(cmpd_tid3, "deep_nested_float", HOFFSET(third_level_compound, deep_nested_float), array); + H5Tinsert(cmpd_tid3, "deep_nested_float", HOFFSET(third_level_compound, deep_nested_float), + array); H5Tclose(array); H5Tinsert(nest2, "deep_nested_compound", HOFFSET(further_nested2, deep_nest), cmpd_tid3); @@ -10168,19 +10884,19 @@ static void gent_compound_complex2(void) H5Tinsert(type, "multiple_nested_compound", HOFFSET(compound, e), cmpd_tid2); - - if ((dset = H5Dcreate2(file, F82_DATASETNAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for(i = 0; i < nelmts; i++) { + if ((dset = H5Dcreate2(file, F82_DATASETNAME, type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { + for (i = 0; i < nelmts; i++) { for (j = 0; j < dset_array_a_dims[0]; j++) - buf[i].a[j] = (unsigned int)(j + i*10); + buf[i].a[j] = (unsigned int)(j + i * 10); for (j = 0; j < dset_array_b_dims[0]; j++) - buf[i].b[j] = (int)(j - i*10); + buf[i].b[j] = (int)(j - i * 10); for (j = 0; j < dset_array_c_dims[0]; j++) for (k = 0; k < dset_array_c_dims[1]; k++) - buf[i].c[j][k] = (float)(j + k + i*10) + (float)(j) * 0.1F; + buf[i].c[j][k] = (float)(j + k + i * 10) + (float)(j)*0.1F; /* Set up first nested compound */ - buf[i].d.nested_a = (double) i; + buf[i].d.nested_a = (double)i; HDstrcpy(buf[i].d.nested_string, "This is a test string."); @@ -10188,13 +10904,13 @@ static void gent_compound_complex2(void) HDstrcpy(buf[i].d.nested_string_array[j], "String test"); /* Set up multiple nested compound */ - buf[i].e.a = (float) i; + buf[i].e.a = (float)i; for (j = 0; j < 5; j++) { - buf[i].e.b.multiple_nested_a[j] = (unsigned int)(j + i*10); - buf[i].e.b.multiple_nested_b[j] = (int)(j - i*10); - buf[i].e.b.multiple_nested_c[j] = (unsigned long)(j + i*10); - buf[i].e.b.multiple_nested_d[j] = (long)(j - i*10); + buf[i].e.b.multiple_nested_a[j] = (unsigned int)(j + i * 10); + buf[i].e.b.multiple_nested_b[j] = (int)(j - i * 10); + buf[i].e.b.multiple_nested_c[j] = (unsigned long)(j + i * 10); + buf[i].e.b.multiple_nested_d[j] = (long)(j - i * 10); } HDstrcpy(buf[i].e.c.further_nested_string, "1234567890"); @@ -10202,11 +10918,11 @@ static void gent_compound_complex2(void) HDstrcpy(buf[i].e.c.further_nested_string_array[j], "STRING ARRAY"); for (j = 0; j < 10; j++) { - buf[i].e.c.deep_nest.deep_nested_short[j] = (short)(j + i*10); - buf[i].e.c.deep_nest.deep_nested_int[j] = (int)(j - i*10); - buf[i].e.c.deep_nest.deep_nested_long[j] = (long)(j + i*10); - buf[i].e.c.deep_nest.deep_nested_double[j] = (double)(j + i*10); - buf[i].e.c.deep_nest.deep_nested_float[j] = (float)(j + i*10); + buf[i].e.c.deep_nest.deep_nested_short[j] = (short)(j + i * 10); + buf[i].e.c.deep_nest.deep_nested_int[j] = (int)(j - i * 10); + buf[i].e.c.deep_nest.deep_nested_long[j] = (long)(j + i * 10); + buf[i].e.c.deep_nest.deep_nested_double[j] = (double)(j + i * 10); + buf[i].e.c.deep_nest.deep_nested_float[j] = (float)(j + i * 10); } } @@ -10224,74 +10940,71 @@ static void gent_compound_complex2(void) } /* CompoundComplex2D */ -/* if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { - H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); - H5Tinsert(type, "b", HOFFSET(s_t, b), H5T_STD_B16LE); - H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); - H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); - if ((space = H5Screate_simple(F82_RANK2, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(file, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for(i = 0; i < nelmts; i++) { - buf5[i].a = (unsigned char)0xff ^ (unsigned char)i; - buf5[i].b = (unsigned int)0xffff ^ (unsigned int)(i * 16); - buf5[i].c = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); - buf5[i].d = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); - } + /* if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { + H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); + H5Tinsert(type, "b", HOFFSET(s_t, b), H5T_STD_B16LE); + H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); + H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); + if ((space = H5Screate_simple(F82_RANK2, &nelmts, NULL)) >= 0) { + if ((dset = H5Dcreate2(file, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { for(i = 0; i < nelmts; i++) { buf5[i].a = (unsigned char)0xff ^ (unsigned char)i; + buf5[i].b = (unsigned int)0xffff ^ (unsigned int)(i * 16); + buf5[i].c = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); + buf5[i].d = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); + } - H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); - H5Dclose(dset); + H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); + H5Dclose(dset); + } + H5Sclose(space); } - H5Sclose(space); + H5Tclose(type); } - H5Tclose(type); - } -*/ + */ /* CompoundComplex3D */ -/* if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { - H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); - H5Tinsert(type, "b", HOFFSET(s_t, b), H5T_STD_B16LE); - H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); - H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); - if ((space = H5Screate_simple(F82_RANK3, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(file, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for(i = 0; i < nelmts; i++) { - buf5[i].a = (unsigned char)0xff ^ (unsigned char)i; - buf5[i].b = (unsigned int)0xffff ^ (unsigned int)(i * 16); - buf5[i].c = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); - buf5[i].d = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); - } + /* if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { + H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); + H5Tinsert(type, "b", HOFFSET(s_t, b), H5T_STD_B16LE); + H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); + H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); + if ((space = H5Screate_simple(F82_RANK3, &nelmts, NULL)) >= 0) { + if ((dset = H5Dcreate2(file, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { for(i = 0; i < nelmts; i++) { buf5[i].a = (unsigned char)0xff ^ (unsigned char)i; + buf5[i].b = (unsigned int)0xffff ^ (unsigned int)(i * 16); + buf5[i].c = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); + buf5[i].d = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); + } - H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); - H5Dclose(dset); + H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); + H5Dclose(dset); + } + H5Sclose(space); } - H5Sclose(space); + H5Tclose(type); } - H5Tclose(type); - } -*/ + */ /* CompoundComplex4D */ -/* if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { - H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); - H5Tinsert(type, "b", HOFFSET(s_t, b), H5T_STD_B16LE); - H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); - H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); - if ((space = H5Screate_simple(F82_RANK4, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(file, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for(i = 0; i < nelmts; i++) { - buf5[i].a = (unsigned char)0xff ^ (unsigned char)i; - buf5[i].b = (unsigned int)0xffff ^ (unsigned int)(i * 16); - buf5[i].c = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); - buf5[i].d = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); - } + /* if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { + H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); + H5Tinsert(type, "b", HOFFSET(s_t, b), H5T_STD_B16LE); + H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); + H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); + if ((space = H5Screate_simple(F82_RANK4, &nelmts, NULL)) >= 0) { + if ((dset = H5Dcreate2(file, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { for(i = 0; i < nelmts; i++) { buf5[i].a = (unsigned char)0xff ^ (unsigned char)i; + buf5[i].b = (unsigned int)0xffff ^ (unsigned int)(i * 16); + buf5[i].c = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); + buf5[i].d = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); + } - H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); - H5Dclose(dset); + H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); + H5Dclose(dset); + } + H5Sclose(space); } - H5Sclose(space); + H5Tclose(type); } - H5Tclose(type); - } -*/ + */ H5Fclose(file); HDfree(buf); @@ -10304,32 +11017,30 @@ static void gent_compound_complex2(void) * length strings. *------------------------------------------------------------------------- */ -static void gent_vlenstr_array(void) +static void +gent_vlenstr_array(void) { /* Compound datatype with different member types */ - typedef struct compound - { + typedef struct compound { /* Array of variable-length strings*/ const char *vlen_array[F83_ARRAYDIM]; } compound; - compound buf[F83_DIM]; + compound buf[F83_DIM]; const char *test[F83_ARRAYDIM] = { - "This is a variable-length test string.", - "This test string is also variable-length.", - "A final test of variable-length strings. This string is longer than the others." - }; - const char *buffer[F83_DIM*F83_ARRAYDIM]; + "This is a variable-length test string.", "This test string is also variable-length.", + "A final test of variable-length strings. This string is longer than the others."}; + const char *buffer[F83_DIM * F83_ARRAYDIM]; - hid_t file, type=-1, space=-1, dset=-1; + hid_t file, type = H5I_INVALID_HID, space = H5I_INVALID_HID, dset = H5I_INVALID_HID; hid_t cmpd_tid1, array_tid; - int i, j; + int i, j; hsize_t dims[] = {F83_DIM}, arraydim[] = {F83_ARRAYDIM}; /* Initialize scalar data */ for (i = 0; i < F83_DIM; i++) for (j = 0; j < 3; j++) - buffer[j + 3*i] = test[j]; + buffer[j + 3 * i] = test[j]; /* Initialize compound data */ for (i = 0; i < F83_DIM; i++) @@ -10344,7 +11055,8 @@ static void gent_vlenstr_array(void) /* ScalarArrayOfVlenStr */ if ((type = H5Tarray_create2(array_tid, F83_RANK, arraydim)) >= 0) { - if ((dset = H5Dcreate2(file, F83_DATASETNAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((dset = H5Dcreate2(file, F83_DATASETNAME, type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { if (H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer) < 0) HDfprintf(stderr, "gent_vlenstr_array H5Dwrite failed\n"); @@ -10365,7 +11077,8 @@ static void gent_vlenstr_array(void) array_tid = H5Tarray_create2(cmpd_tid1, F83_RANK, arraydim); H5Tinsert(type, "vlen_str_array", HOFFSET(compound, vlen_array), array_tid); - if ((dset = H5Dcreate2(file, F83_DATASETNAME2, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((dset = H5Dcreate2(file, F83_DATASETNAME2, type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { if (H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) HDfprintf(stderr, "gent_vlenstr_array H5Dwrite failed\n"); @@ -10386,33 +11099,35 @@ static void gent_vlenstr_array(void) * Purpose: Generate a file to be used in testing user defined filter plugin3. *------------------------------------------------------------------------- */ -static void gent_udfilter(void) +static void +gent_udfilter(void) { - hid_t fid; /* file id */ - hid_t dcpl; /* dataset creation property list */ - hid_t dsid; /* dataset ID */ - hid_t sid; /* dataspace ID */ - - hsize_t dims1[RANK] = {DIM1,DIM2}; - hsize_t chunk_dims[RANK] = {CDIM1,CDIM2}; - int buf1[DIM1][DIM2]; - int i, j, n, ret; - - for(i=n=0; i<DIM1; i++){ - for(j=0; j<DIM2; j++){ - buf1[i][j]=n++; + hid_t fid; /* file id */ + hid_t dcpl; /* dataset creation property list */ + hid_t dsid; /* dataset ID */ + hid_t sid; /* dataspace ID */ + + hsize_t dims1[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int buf1[DIM1][DIM2]; + int i, j, n; + int H5_ATTR_NDEBUG_UNUSED ret; + + for (i = n = 0; i < DIM1; i++) { + for (j = 0; j < DIM2; j++) { + buf1[i][j] = n++; } } /* create a file */ - fid = H5Fcreate(FILE84, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); + fid = H5Fcreate(FILE84, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); /* create a space */ sid = H5Screate_simple(SPACE2_RANK, dims1, NULL); dcpl = H5Pcreate(H5P_DATASET_CREATE); - HDassert(dcpl>=0); + HDassert(dcpl >= 0); ret = H5Pset_layout(dcpl, H5D_CHUNKED); HDassert(ret >= 0); @@ -10420,10 +11135,10 @@ static void gent_udfilter(void) ret = H5Pset_chunk(dcpl, SPACE2_RANK, chunk_dims); HDassert(ret >= 0); - ret = H5Zregister (H5Z_DYNLIBUD); + ret = H5Zregister(H5Z_DYNLIBUD); HDassert(ret >= 0); - ret = H5Pset_filter (dcpl, H5Z_FILTER_DYNLIBUD, H5Z_FLAG_MANDATORY, 0, NULL); + ret = H5Pset_filter(dcpl, H5Z_FILTER_DYNLIBUD, H5Z_FLAG_MANDATORY, 0, NULL); HDassert(ret >= 0); /* create the dataset */ @@ -10470,38 +11185,37 @@ static void gent_udfilter(void) *------------------------------------------------------------------------- */ static size_t -H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) { - char *int_ptr = (char *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + char * int_ptr = (char *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ /* Check for the correct number of parameters */ - if(cd_nelmts > 0) - return(0); + if (cd_nelmts > 0) + return (0); /* Assignment to eliminate unused parameter warning. */ - cd_values = cd_values; + (void)cd_values; - if(flags & H5Z_FLAG_REVERSE) { /*read*/ + if (flags & H5Z_FLAG_REVERSE) { /*read*/ /* Subtract the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = temp - MULTIPLIER; + *int_ptr = (int8_t)(temp - MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ else { /*write*/ /* Add the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = temp + MULTIPLIER; + *int_ptr = (int8_t)(temp + MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); } /* end while */ - } /* end else */ + } /* end else */ return nbytes; } /* end H5Z_filter_dynlibud() */ @@ -10518,13 +11232,14 @@ H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, * Purpose: generates dataset and attribute of null dataspace in a group *------------------------------------------------------------------------- */ -static void gent_null_space_group(void) +static void +gent_null_space_group(void) { hid_t fid, root, group, dataset, space, attr; - int dset_buf = 10; - int point = 4; + int dset_buf = 10; + int point = 4; - fid = H5Fcreate(FILE85, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE85, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -10564,75 +11279,78 @@ static void gent_null_space_group(void) static void gent_err_attr_dspace(void) { - hid_t fid = -1; /* File identifier */ - hid_t fcpl = -1; /* File access property list */ - hid_t sid = -1; /* Dataspace identifier */ - hid_t aid = -1; /* Attribute identifier */ - hsize_t dims = 2; /* Dimensino size */ - int wdata[2] = {7, 42}; /* The buffer to write */ - int fd = -1; /* The file descriptor */ - char val = 6; /* An invalid version */ + hid_t fid = H5I_INVALID_HID; /* File identifier */ + hid_t fcpl = H5I_INVALID_HID; /* File access property list */ + hid_t sid = H5I_INVALID_HID; /* Dataspace identifier */ + hid_t aid = H5I_INVALID_HID; /* Attribute identifier */ + hsize_t dims = 2; /* Dimensino size */ + int wdata[2] = {7, 42}; /* The buffer to write */ + int fd = -1; /* The file descriptor */ + char val = 6; /* An invalid version */ /* Create an fcpl */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; /* Set up the dataspace message to be shared */ - if(H5Pset_shared_mesg_nindexes(fcpl, 1) < 0) + if (H5Pset_shared_mesg_nindexes(fcpl, 1) < 0) goto error; - if(H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_SDSPACE_FLAG, 1) < 0) + if (H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_SDSPACE_FLAG, 1) < 0) goto error; /* Create the file with the shared message setting */ - if((fid = H5Fcreate(FILE86, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILE86, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) goto error; /* Create the dataspace */ - if((sid = H5Screate_simple(1, &dims, &dims)) < 0) + if ((sid = H5Screate_simple(1, &dims, &dims)) < 0) goto error; /* Create an attribute with shared dataspace */ - if((aid = H5Acreate2(fid, "attribute", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(fid, "attribute", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Awrite(aid, H5T_NATIVE_INT, wdata) < 0) + if (H5Awrite(aid, H5T_NATIVE_INT, wdata) < 0) goto error; /* Closing */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; /* This section of code will write an illegal version to the "version" field of the shared dataspace message */ - if((fd = HDopen(FILE86, O_RDWR, 0633)) < 0) + if ((fd = HDopen(FILE86, O_RDWR, 0633)) < 0) goto error; /* Offset of the "version" field to modify is as follows: */ /* 1916: offset of the object header containing the attribute message */ /* 32: offset of the attribute message in the object header */ /* 30: offset in the attribute message containing the version of the shared dataspace message */ - if(HDlseek(fd, 1916+32+30, SEEK_SET) < 0) + if (HDlseek(fd, 1916 + 32 + 30, SEEK_SET) < 0) goto error; - if(HDwrite(fd, &val, 1) < 0) + if (HDwrite(fd, &val, 1) < 0) goto error; - if(HDclose(fd) < 0) + if (HDclose(fd) < 0) goto error; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fcpl); H5Aclose(aid); H5Sclose(sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; } /* gen_err_attr_dspace() */ -int main(void) +int +main(void) { gent_group(); gent_attribute(); @@ -10695,6 +11413,7 @@ int main(void) gent_aindices(); gent_longlinks(); gent_ldouble(); + gent_ldouble_scalar(); gent_binary(); gent_bigdims(); gent_hyperslab(); @@ -10718,6 +11437,7 @@ int main(void) gent_compound_ints(); gent_intattrscalars(); gent_intsattrs(); + gent_floatsattrs(); gent_bitnopaquefields(); gent_nodata(); @@ -10730,4 +11450,3 @@ int main(void) return 0; } - diff --git a/tools/test/h5dump/testh5dump.sh.in b/tools/test/h5dump/testh5dump.sh.in index e5680cf..f9f3734 100644 --- a/tools/test/h5dump/testh5dump.sh.in +++ b/tools/test/h5dump/testh5dump.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. # @@ -132,6 +132,7 @@ $SRC_H5DUMP_TESTFILES/tfamily00010.h5 $SRC_H5DUMP_TESTFILES/tfcontents1.h5 $SRC_H5DUMP_TESTFILES/tfcontents2.h5 $SRC_H5DUMP_TESTFILES/tfilters.h5 +$SRC_H5DUMP_TESTFILES/tfloatsattrs.h5 $SRC_H5DUMP_TESTFILES/tfpformat.h5 $SRC_H5DUMP_TESTFILES/tfvalues.h5 $SRC_H5DUMP_TESTFILES/tgroup.h5 @@ -142,7 +143,8 @@ $SRC_H5DUMP_TESTFILES/thyperslab.h5 $SRC_H5DUMP_TESTFILES/tintsattrs.h5 $SRC_H5DUMP_TESTFILES/tints4dims.h5 $SRC_H5DUMP_TESTFILES/tlarge_objname.h5 -#$SRC_H5DUMP_TESTFILES/tldouble.h5 +$SRC_H5DUMP_TESTFILES/tldouble.h5 +$SRC_H5DUMP_TESTFILES/tldouble_scalar.h5 $SRC_H5DUMP_TESTFILES/tlonglinks.h5 $SRC_H5DUMP_TESTFILES/tloop.h5 $SRC_H5DUMP_TESTFILES/tmulti-b.h5 @@ -180,6 +182,8 @@ $SRC_H5DUMP_TESTFILES/tvlenstr_array.h5 $SRC_H5DUMP_TESTFILES/tvlstr.h5 $SRC_H5DUMP_TESTFILES/tvms.h5 $SRC_H5DUMP_TESTFILES/err_attr_dspace.h5 +$SRC_H5DUMP_TESTFILES/tCVE_2018_11206_fill_old.h5 +$SRC_H5DUMP_TESTFILES/tCVE_2018_11206_fill_new.h5 " LIST_OTHER_TEST_FILES=" @@ -262,6 +266,7 @@ $SRC_H5DUMP_TESTFILES/textlink.ddl $SRC_H5DUMP_TESTFILES/tfamily.ddl $SRC_H5DUMP_TESTFILES/tfill.ddl $SRC_H5DUMP_TESTFILES/tfletcher32.ddl +$SRC_H5DUMP_TESTFILES/tfloatsattrs.ddl $SRC_H5DUMP_TESTFILES/tfpformat.ddl $SRC_H5DUMP_TESTFILES/tgroup-1.ddl $SRC_H5DUMP_TESTFILES/tgroup-2.ddl @@ -287,7 +292,8 @@ $SRC_H5DUMP_TESTFILES/tints4dimsCountEq.ddl $SRC_H5DUMP_TESTFILES/tints4dimsStride2.ddl $SRC_H5DUMP_TESTFILES/tintsattrs.ddl $SRC_H5DUMP_TESTFILES/tlarge_objname.ddl -#$SRC_H5DUMP_TESTFILES/tldouble.ddl +$SRC_H5DUMP_TESTFILES/tldouble.ddl +$SRC_H5DUMP_TESTFILES/tldouble_scalar.ddl $SRC_H5DUMP_TESTFILES/tlonglinks.ddl $SRC_H5DUMP_TESTFILES/tloop-1.ddl $SRC_H5DUMP_TESTFILES/tmulti.ddl @@ -465,14 +471,14 @@ TESTING() { TOOLTEST() { # check if caseless compare and diff requested if [ "$1" = ignorecase ]; then - caseless="-i" - # replace cmp with diff which runs much longer. - xCMP="$DIFF -i" - shift + caseless="-i" + # replace cmp with diff which runs much longer. + xCMP="$DIFF -i" + shift else - caseless="" - # stick with faster cmp if ignorecase is not requested. - xCMP="$CMP" + caseless="" + # stick with faster cmp if ignorecase is not requested. + xCMP="$CMP" fi expect="$TESTDIR/$1" @@ -485,8 +491,8 @@ TOOLTEST() { # Run test. TESTING $DUMPER $@ ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" + cd $TESTDIR + $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err # save actual and actual_err in case they are needed later. @@ -495,24 +501,24 @@ TOOLTEST() { cp $actual_err $actual_err_sav STDERR_FILTER $actual_err - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.ddl) missing" - nerrors="`expr $nerrors + 1`" + if [ ! -f $expect ]; then + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + echo " Expected result (*.ddl) missing" + nerrors="`expr $nerrors + 1`" elif $xCMP $expect $actual > /dev/null 2>&1 ; then - echo " PASSED" + echo " PASSED" else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $caseless $expect $actual |sed 's/^/ /' + echo "*FAILED*" + echo " Expected result (*.ddl) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $caseless $expect $actual |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav $actual_ext + rm -f $actual $actual_err $actual_sav $actual_err_sav $actual_ext fi } @@ -534,41 +540,41 @@ TOOLTEST2() { # Run test. TESTING $DUMPER $@ ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" + cd $TESTDIR + $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.ddl) missing" - nerrors="`expr $nerrors + 1`" - elif $CMP $expect $actual; then - if [ ! -f $expectdata ]; then - # Create the expect data file if it doesn't yet exist. + # Create the expect file if it doesn't yet exist. echo " CREATED" - cp $actualdata $expectdata - echo " Expected data (*.exp) missing" + cp $actual $expect + echo " Expected result (*.ddl) missing" nerrors="`expr $nerrors + 1`" - elif $CMP $expectdata $actualdata; then - echo " PASSED" - else + elif $CMP $expect $actual; then + if [ ! -f $expectdata ]; then + # Create the expect data file if it doesn't yet exist. + echo " CREATED" + cp $actualdata $expectdata + echo " Expected data (*.exp) missing" + nerrors="`expr $nerrors + 1`" + elif $CMP $expectdata $actualdata; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected datafile (*.exp) differs from actual datafile (*.txt)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /' + fi + else echo "*FAILED*" - echo " Expected datafile (*.exp) differs from actual datafile (*.txt)" + echo " Expected result (*.ddl) differs from actual result (*.out)" nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /' - fi - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actualdata $actual_err + rm -f $actual $actualdata $actual_err fi } @@ -592,56 +598,55 @@ TOOLTEST2A() { # Run test. TESTING $DUMPER $@ ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" + cd $TESTDIR + $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.ddl) missing" - nerrors="`expr $nerrors + 1`" - elif $CMP $expect $actual; then - if [ ! -f $expectdata ]; then - # Create the expect data file if it doesn't yet exist. + # Create the expect file if it doesn't yet exist. echo " CREATED" - cp $actualdata $expectdata - echo " Expected data (*.exp) missing" + cp $actual $expect + echo " Expected result (*.ddl) missing" nerrors="`expr $nerrors + 1`" - elif $DIFF $expectdata $actualdata; then - if [ ! -f $expectmeta ]; then - # Create the expect meta file if it doesn't yet exist. - echo " CREATED" - cp $actualmeta $expectmeta - echo " Expected metafile (*.ddl) missing" - nerrors="`expr $nerrors + 1`" - elif $CMP $expectmeta $actualmeta; then - echo " PASSED" + elif $CMP $expect $actual; then + if [ ! -f $expectdata ]; then + # Create the expect data file if it doesn't yet exist. + echo " CREATED" + cp $actualdata $expectdata + echo " Expected data (*.exp) missing" + nerrors="`expr $nerrors + 1`" + elif $DIFF $expectdata $actualdata; then + if [ ! -f $expectmeta ]; then + # Create the expect meta file if it doesn't yet exist. + echo " CREATED" + cp $actualmeta $expectmeta + echo " Expected metafile (*.ddl) missing" + nerrors="`expr $nerrors + 1`" + elif $CMP $expectmeta $actualmeta; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected metafile (*.ddl) differs from actual metafile (*.txt)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expectmeta $actualmeta |sed 's/^/ /' + fi else - echo "*FAILED*" - echo " Expected metafile (*.ddl) differs from actual metafile (*.txt)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expectmeta $actualmeta |sed 's/^/ /' + echo "*FAILED*" + echo " Expected datafile (*.exp) differs from actual datafile (*.txt)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /' fi - else + else echo "*FAILED*" - echo " Expected datafile (*.exp) differs from actual datafile (*.txt)" + echo " Expected result (*.ddl) differs from actual result (*.out)" nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /' - fi - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actualdata $actual_err $actualmeta + rm -f $actual $actualdata $actual_err $actualmeta fi - } # same as TOOLTEST2 but only compares the generated data file to the expected data file @@ -658,28 +663,28 @@ TOOLTEST2B() { # Run test. TESTING $DUMPER $@ ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" + cd $TESTDIR + $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err if [ ! -f $expectdata ]; then - # Create the expect data file if it doesn't yet exist. - echo " CREATED" - cp $actualdata $expectdata - echo " Expected data (*.exp) missing" - nerrors="`expr $nerrors + 1`" + # Create the expect data file if it doesn't yet exist. + echo " CREATED" + cp $actualdata $expectdata + echo " Expected data (*.exp) missing" + nerrors="`expr $nerrors + 1`" elif $CMP $expectdata $actualdata; then - echo " PASSED" + echo " PASSED" else - echo "*FAILED*" - echo " Expected datafile (*.exp) differs from actual datafile (*.txt)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /' + echo "*FAILED*" + echo " Expected datafile (*.exp) differs from actual datafile (*.txt)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actualdata $actual_err + rm -f $actual $actualdata $actual_err fi } @@ -699,8 +704,8 @@ TOOLTEST3() { # Run test. TESTING $DUMPER $@ ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" + cd $TESTDIR + $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err # save actual and actual_err in case they are needed later. @@ -719,23 +724,23 @@ TOOLTEST3() { $actual_err > $actual_ext if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.ddl) missing" - nerrors="`expr $nerrors + 1`" + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + echo " Expected result (*.ddl) missing" + nerrors="`expr $nerrors + 1`" elif $CMP $expect $actual; then - echo " PASSED" + echo " PASSED" else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + echo "*FAILED*" + echo " Expected result (*.ddl) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav + rm -f $actual $actual_err $actual_sav $actual_err_sav fi } @@ -757,8 +762,8 @@ TOOLTEST4() { # Run test. TESTING $DUMPER $@ ( - cd $TESTDIR - $ENVCMD $RUNSERIAL $DUMPER_BIN "$@" + cd $TESTDIR + $ENVCMD $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err # save actual and actual_err in case they are needed later. @@ -777,30 +782,30 @@ TOOLTEST4() { $actual_err > $actual_ext if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.ddl) missing" - nerrors="`expr $nerrors + 1`" + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + echo " Expected result (*.ddl) missing" + nerrors="`expr $nerrors + 1`" elif $CMP $expect $actual; then - if $CMP $expect_err $actual_ext; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.err) differs from actual result (*.oerr)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect_err $actual_ext |sed 's/^/ /' - fi + if $CMP $expect_err $actual_ext; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result (*.err) differs from actual result (*.oerr)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect_err $actual_ext |sed 's/^/ /' + fi else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + echo "*FAILED*" + echo " Expected result (*.ddl) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav + rm -f $actual $actual_err $actual_sav $actual_err_sav fi } @@ -822,8 +827,8 @@ TOOLTEST5() { # Run test. TESTING $DUMPER $@ ( - cd $TESTDIR - $ENVCMD $RUNSERIAL $DUMPER_BIN "$@" + cd $TESTDIR + $ENVCMD $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err # save actual and actual_err in case they are needed later. @@ -842,33 +847,62 @@ TOOLTEST5() { $actual_err > $actual_ext if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.ddl) missing" - nerrors="`expr $nerrors + 1`" + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + echo " Expected result (*.ddl) missing" + nerrors="`expr $nerrors + 1`" elif $CMP $expect $actual; then - if $CMP $expect_err $actual_ext; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.err) differs from actual result (*.oerr)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect_err $actual_ext |sed 's/^/ /' - fi + if $CMP $expect_err $actual_ext; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result (*.err) differs from actual result (*.oerr)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect_err $actual_ext |sed 's/^/ /' + fi else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + echo "*FAILED*" + echo " Expected result (*.ddl) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav + rm -f $actual $actual_err $actual_sav $actual_err_sav + fi +} + +# same as TOOLTEST1 but expects h5dump to fail +# +TOOLTEST_FAIL() { + + infile=$1 + expect="$TESTDIR/`basename $1 exp`.ddl" + actual="$TESTDIR/`basename $1 .exp`.out" + + # Run test. + TESTING $DUMPER $@ + ( + cd $TESTDIR + $RUNSERIAL $DUMPER_BIN "$@" $infile + ) >&$actual + RET=$? + # Segfault occurred + if [ $RET == 139 ] ; then + nerrors="`expr $nerrors + 1`" + echo "*FAILED - test on $infile failed with segmentation fault" + # Should fail but didn't + elif [ $RET == 0 ] ; then + nerrors="`expr $nerrors + 1`" + echo "*FAILED - test on $infile did not fail as expected" + else + echo " PASSED" fi } + # ADD_HELP_TEST TOOLTEST_HELP() { @@ -880,48 +914,56 @@ TOOLTEST_HELP() { # Run test. TESTING $DUMPER $@ ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" + cd $TESTDIR + $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err if [ ! -f $expectdata ]; then - # Create the expect data file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect-CREATED - echo " Expected output (*.txt) missing" - nerrors="`expr $nerrors + 1`" + # Create the expect data file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect-CREATED + echo " Expected output (*.txt) missing" + nerrors="`expr $nerrors + 1`" elif $CMP $expect $actual; then - echo " PASSED" + echo " PASSED" else - echo "*FAILED*" - echo " Expected output (*.txt) differs from actual output (*.out)" - nerrors="`expr $nerrors + 1`" + echo "*FAILED*" + echo " Expected output (*.txt) differs from actual output (*.out)" + nerrors="`expr $nerrors + 1`" fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err + rm -f $actual $actual_err fi } # Call the h5dump tool and grep for a value -# +# txttype ERRTXT greps test error output, otherwise greps test output GREPTEST() { - expectdata=$1 - actual=$TESTDIR/$2 - actual_err="$TESTDIR/`basename $2 .ddl`.oerr" + txttype=$1 + expectdata=$2 + actual=$TESTDIR/$3 + actual_err="$TESTDIR/`basename $3 .ddl`.oerr" + shift shift shift # Run test. TESTING $DUMPER -p $@ ( - cd $TESTDIR - $ENVCMD $RUNSERIAL $DUMPER_BIN -p "$@" + cd $TESTDIR + $ENVCMD $RUNSERIAL $DUMPER_BIN -p "$@" ) >$actual 2>$actual_err - $GREP $expectdata $actual > /dev/null + + if [ "$txttype" = "ERRTXT" ]; then + $GREP "$expectdata" $actual_err > /dev/null + else + $GREP "$expectdata" $actual > /dev/null + fi + if [ $? -eq 0 ]; then echo " PASSED" else @@ -931,21 +973,59 @@ GREPTEST() # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err + rm -f $actual $actual_err + fi +} + +# Call the h5dump tool and grep for a value but disables plugin filter loading +# txttype ERRTXT greps test error output, otherwise greps test output +GREPTEST2() +{ + txttype=$1 + expectdata=$2 + actual=$TESTDIR/$3 + actual_err="$TESTDIR/`basename $3 .ddl`.oerr" + shift + shift + shift + + # Run test. + TESTING $DUMPER -p $@ + ( + cd $TESTDIR + $ENVCMD $RUNSERIAL $DUMPER_BIN -p "$@" + ) >$actual 2>$actual_err + + if [ "$txttype" = "ERRTXT" ]; then + $GREP "$expectdata" $actual_err > /dev/null + else + $GREP "$expectdata" $actual > /dev/null + fi + + if [ $? -eq 0 ]; then + echo " PASSED" + else + echo " FAILED" + nerrors="`expr $nerrors + 1`" + fi + + # Clean up output file + if test -z "$HDF5_NOCLEANUP"; then + rm -f $actual $actual_err fi } # Print a "SKIP" message SKIP() { - TESTING $DUMPER $@ + TESTING $DUMPER $@ echo " -SKIP-" } # Print a line-line message left justified in a field of 70 characters # PRINT_H5DIFF() { - SPACES=" " - echo " Running h5diff $* $SPACES" | cut -c1-70 | tr -d '\012' + SPACES=" " + echo " Running h5diff $* $SPACES" | cut -c1-70 | tr -d '\012' } @@ -955,10 +1035,11 @@ DIFFTEST() { PRINT_H5DIFF $@ ( - cd $TESTDIR - $RUNSERIAL $H5DIFF_BIN "$@" -q + cd $TESTDIR + $RUNSERIAL $H5DIFF_BIN "$@" -q ) RET=$? + if [ $RET != 0 ] ; then echo "*FAILED*" nerrors="`expr $nerrors + 1`" @@ -972,8 +1053,8 @@ DIFFTEST() # beginning with the word "Verifying". # PRINT_H5IMPORT() { - SPACES=" " - echo " Running h5import $* $SPACES" | cut -c1-70 | tr -d '\012' + SPACES=" " + echo " Running h5import $* $SPACES" | cut -c1-70 | tr -d '\012' } # Call the h5import tool @@ -983,15 +1064,16 @@ IMPORTTEST() # remove the output hdf5 file if it exists hdf5_file="$TESTDIR/$5" if [ -f $hdf5_file ]; then - rm -f $hdf5_file + rm -f $hdf5_file fi PRINT_H5IMPORT $@ ( - cd $TESTDIR - $RUNSERIAL $H5IMPORT_BIN "$@" + cd $TESTDIR + $RUNSERIAL $H5IMPORT_BIN "$@" ) RET=$? + if [ $RET != 0 ] ; then echo "*FAILED*" nerrors="`expr $nerrors + 1`" @@ -1089,16 +1171,16 @@ TOOLTEST tcomp-1.ddl --enable-error-stack tcompound.h5 # test for named data types TOOLTEST tcomp-2.ddl --enable-error-stack -t /type1 --datatype /type2 --datatype=/group1/type3 tcompound.h5 TOOLTEST tcomp-2.ddl --enable-error-stack -N /type1 --any_path /type2 --any_path=/group1/type3 tcompound.h5 -# test for unamed type +# test for unnamed type TOOLTEST4 tcomp-3.ddl --enable-error-stack -t /#6632 -g /group2 tcompound.h5 # test complicated compound datatype TOOLTEST tcomp-4.ddl --enable-error-stack tcompound_complex.h5 TOOLTEST tcompound_complex2.ddl --enable-error-stack tcompound_complex2.h5 # tests for bitfields and opaque data types if test $WORDS_BIGENDIAN != "yes"; then -TOOLTEST tbitnopaque_le.ddl --enable-error-stack tbitnopaque.h5 + TOOLTEST tbitnopaque_le.ddl --enable-error-stack tbitnopaque.h5 else -TOOLTEST tbitnopaque_be.ddl --enable-error-stack tbitnopaque.h5 + TOOLTEST tbitnopaque_be.ddl --enable-error-stack tbitnopaque.h5 fi #test for the nested compound type @@ -1137,7 +1219,7 @@ TOOLTEST tvlenstr_array.ddl --enable-error-stack tvlenstr_array.h5 # test for files with array data TOOLTEST tarray1.ddl --enable-error-stack tarray1.h5 # # added for bug# 2092 - tarray1_big.h -TOOLTEST4 tarray1_big.ddl --enable-error-stack -R tarray1_big.h5 +GREPTEST ERRTXT "NULL token size" tarray1_big.ddl --enable-error-stack -R tarray1_big.h5 TOOLTEST tarray2.ddl --enable-error-stack tarray2.h5 TOOLTEST tarray3.ddl --enable-error-stack tarray3.h5 TOOLTEST tarray4.ddl --enable-error-stack tarray4.h5 @@ -1276,12 +1358,12 @@ TOOLTEST tallfilters.ddl --enable-error-stack -H -p -d all tfilters.h5 TOOLTEST tuserfilter.ddl --enable-error-stack -H -p -d myfilter tfilters.h5 if test $USE_FILTER_DEFLATE = "yes" ; then - # data read internal filters - TOOLTEST treadintfilter.ddl --enable-error-stack -d deflate -d shuffle -d fletcher32 -d nbit -d scaleoffset tfilters.h5 - if test $USE_FILTER_SZIP = "yes"; then - # data read - TOOLTEST treadfilter.ddl --enable-error-stack -d all -d szip tfilters.h5 - fi + # data read internal filters + TOOLTEST treadintfilter.ddl --enable-error-stack -d deflate -d shuffle -d fletcher32 -d nbit -d scaleoffset tfilters.h5 + if test $USE_FILTER_SZIP = "yes"; then + # data read + TOOLTEST treadfilter.ddl --enable-error-stack -d all -d szip tfilters.h5 + fi fi # test for displaying objects with very long names @@ -1304,7 +1386,9 @@ TOOLTEST tgrpnullspace.ddl -p --enable-error-stack tgrpnullspace.h5 TOOLTEST zerodim.ddl --enable-error-stack zerodim.h5 # test for long double (some systems do not have long double) -#TOOLTEST tldouble.ddl --enable-error-stack tldouble.h5 +TOOLTEST tfloatsattrs.ddl -p --enable-error-stack tfloatsattrs.h5 +TOOLTEST tldouble.ddl --enable-error-stack tldouble.h5 +TOOLTEST tldouble_scalar.ddl -p --enable-error-stack tldouble_scalar.h5 # test for vms TOOLTEST tvms.ddl --enable-error-stack tvms.h5 @@ -1338,21 +1422,21 @@ TOOLTEST tbin4.ddl --enable-error-stack -d double -b FILE -o out4.bin tbin # Clean up binary output files if test -z "$HDF5_NOCLEANUP"; then - rm -f out[1-4].bin - rm -f out1.h5 - rm -f out3.h5 + rm -f out[1-4].bin + rm -f out1.h5 + rm -f out3.h5 fi # test for dataset region references TOOLTEST tdatareg.ddl --enable-error-stack tdatareg.h5 -TOOLTEST4 tdataregR.ddl --enable-error-stack -R tdatareg.h5 +GREPTEST ERRTXT "NULL token size" tdataregR.ddl --enable-error-stack -R tdatareg.h5 TOOLTEST tattrreg.ddl --enable-error-stack tattrreg.h5 -TOOLTEST4 tattrregR.ddl --enable-error-stack -R tattrreg.h5 +GREPTEST ERRTXT "NULL token size" tattrregR.ddl --enable-error-stack -R tattrreg.h5 TOOLTEST2 tbinregR.exp --enable-error-stack -d /Dataset1 -s 0 -R -y -o tbinregR.txt tdatareg.h5 # Clean up text output files if test -z "$HDF5_NOCLEANUP"; then - rm -f tbinregR.txt + rm -f tbinregR.txt fi # tests for group creation order @@ -1384,7 +1468,7 @@ TOOLTEST4 textlinkfar.ddl --enable-error-stack textlinkfar.h5 TOOLTEST4 textlink.ddl --enable-error-stack textlink.h5 # test for error stack display (BZ2048) -TOOLTEST5 filter_fail.ddl --enable-error-stack filter_fail.h5 +GREPTEST2 ERRTXT "filter plugins disabled" filter_fail.ddl --enable-error-stack filter_fail.h5 # test for -o -y for dataset with attributes TOOLTEST2 tall-6.exp --enable-error-stack -y -o tall-6.txt -d /g1/g1.1/dset1.1.1 tall.h5 @@ -1396,7 +1480,11 @@ TOOLTEST3 non_existing.ddl --enable-error-stack tgroup.h5 non_existing.h5 TOOLTEST err_attr_dspace.ddl err_attr_dspace.h5 # test to verify HDFFV-9407: long double full precision -GREPTEST "1.123456789012345" t128bit_float.ddl -m %.35Lf t128bit_float.h5 +#GREPTEST OUTTXT "1.123456789012345" t128bit_float.ddl -m %.35Lf t128bit_float.h5 + +# test to verify HDFFV-10480: out of bounds read in H5O_fill_new[old]_decode +TOOLTEST_FAIL tCVE_2018_11206_fill_old.h5 +TOOLTEST_FAIL tCVE_2018_11206_fill_new.h5 # Clean up temporary files/directories CLEAN_TESTFILES_AND_TESTDIR diff --git a/tools/test/h5dump/testh5dumppbits.sh.in b/tools/test/h5dump/testh5dumppbits.sh.in index febce2c..eaf91fd 100644 --- a/tools/test/h5dump/testh5dumppbits.sh.in +++ b/tools/test/h5dump/testh5dumppbits.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. # @@ -236,26 +236,25 @@ TOOLTEST() { cp $actual_err $actual_err_sav STDERR_FILTER $actual_err - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.ddl) missing" - nerrors="`expr $nerrors + 1`" + if [ ! -f $expect ]; then + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + echo " Expected result (*.ddl) missing" + nerrors="`expr $nerrors + 1`" elif $CMP $expect $actual; then - echo " PASSED" + echo " PASSED" else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + echo "*FAILED*" + echo " Expected result (*.ddl) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav $actual_ext + rm -f $actual $actual_err $actual_sav $actual_err_sav $actual_ext fi - } @@ -274,36 +273,36 @@ TOOLTEST2() { # Run test. TESTING $DUMPER $@ ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" + cd $TESTDIR + $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.ddl) missing" - nerrors="`expr $nerrors + 1`" - elif $CMP $expect $actual; then - if [ ! -f $expectdata ]; then - # Create the expect data file if it doesn't yet exist. + # Create the expect file if it doesn't yet exist. echo " CREATED" - cp $actualdata $expectdata - echo " Expected data (*.exp) missing" + cp $actual $expect + echo " Expected result (*.ddl) missing" nerrors="`expr $nerrors + 1`" - elif $CMP $expectdata $actualdata; then - echo " PASSED" - else + elif $CMP $expect $actual; then + if [ ! -f $expectdata ]; then + # Create the expect data file if it doesn't yet exist. + echo " CREATED" + cp $actualdata $expectdata + echo " Expected data (*.exp) missing" + nerrors="`expr $nerrors + 1`" + elif $CMP $expectdata $actualdata; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected datafile (*.exp) differs from actual datafile (*.txt)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /' + fi + else echo "*FAILED*" - echo " Expected datafile (*.exp) differs from actual datafile (*.txt)" + echo " Expected result (*.ddl) differs from actual result (*.out)" nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /' - fi - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi # Clean up output file @@ -328,8 +327,8 @@ TOOLTEST3() { # Run test. TESTING $DUMPER $@ ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" + cd $TESTDIR + $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err # save actual and actual_err in case they are needed later. @@ -348,23 +347,23 @@ TOOLTEST3() { $actual_err > $actual_ext if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.ddl) missing" - nerrors="`expr $nerrors + 1`" + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + echo " Expected result (*.ddl) missing" + nerrors="`expr $nerrors + 1`" elif $CMP $expect $actual; then - echo " PASSED" + echo " PASSED" else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + echo "*FAILED*" + echo " Expected result (*.ddl) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav + rm -f $actual $actual_err $actual_sav $actual_err_sav fi } @@ -385,8 +384,8 @@ TOOLTEST4() { # Run test. TESTING $DUMPER $@ ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" + cd $TESTDIR + $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err # save actual and actual_err in case they are needed later. @@ -405,30 +404,30 @@ TOOLTEST4() { $actual_err > $actual_ext if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.ddl) missing" - nerrors="`expr $nerrors + 1`" + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + echo " Expected result (*.ddl) missing" + nerrors="`expr $nerrors + 1`" elif $CMP $expect $actual; then - if $CMP $expect_err $actual_ext; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.err) differs from actual result (*.oerr)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect_err $actual_ext |sed 's/^/ /' - fi + if $CMP $expect_err $actual_ext; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result (*.err) differs from actual result (*.oerr)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect_err $actual_ext |sed 's/^/ /' + fi else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + echo "*FAILED*" + echo " Expected result (*.ddl) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav + rm -f $actual $actual_err $actual_sav $actual_err_sav fi } @@ -442,8 +441,8 @@ SKIP() { # Print a line-line message left justified in a field of 70 characters # PRINT_H5DIFF() { - SPACES=" " - echo " Running h5diff $* $SPACES" | cut -c1-70 | tr -d '\012' + SPACES=" " + echo " Running h5diff $* $SPACES" | cut -c1-70 | tr -d '\012' } @@ -453,10 +452,11 @@ DIFFTEST() { PRINT_H5DIFF $@ ( - cd $TESTDIR - $RUNSERIAL $H5DIFF_BIN "$@" -q + cd $TESTDIR + $RUNSERIAL $H5DIFF_BIN "$@" -q ) RET=$? + if [ $RET != 0 ] ; then echo "*FAILED*" nerrors="`expr $nerrors + 1`" @@ -470,8 +470,8 @@ DIFFTEST() # beginning with the word "Verifying". # PRINT_H5IMPORT() { - SPACES=" " - echo " Running h5import $* $SPACES" | cut -c1-70 | tr -d '\012' + SPACES=" " + echo " Running h5import $* $SPACES" | cut -c1-70 | tr -d '\012' } # Call the h5import tool @@ -481,22 +481,22 @@ IMPORTTEST() # remove the output hdf5 file if it exists hdf5_file="$TESTDIR/$5" if [ -f $hdf5_file ]; then - rm -f $hdf5_file + rm -f $hdf5_file fi PRINT_H5IMPORT $@ ( - cd $TESTDIR - $RUNSERIAL $H5IMPORT_BIN "$@" + cd $TESTDIR + $RUNSERIAL $H5IMPORT_BIN "$@" ) RET=$? + if [ $RET != 0 ] ; then echo "*FAILED*" nerrors="`expr $nerrors + 1`" else echo " PASSED" fi - } @@ -516,7 +516,7 @@ TOOLTEST tnofilename-with-packed-bits.ddl --enable-error-stack # Limits: # Maximum number of packed bits is 8 (for now). # Maximum integer size is 64 (for now). -# Maximun Offset is 63 (Maximum size - 1). +# Maximum Offset is 63 (Maximum size - 1). # Maximum Offset+Length is 64 (Maximum size). # Tests: # Normal operation on both signed and unsigned int datasets. diff --git a/tools/test/h5dump/testh5dumpvds.sh.in b/tools/test/h5dump/testh5dumpvds.sh.in index f89234e..f2c486e 100644 --- a/tools/test/h5dump/testh5dumpvds.sh.in +++ b/tools/test/h5dump/testh5dumpvds.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. # @@ -205,8 +205,8 @@ TOOLTEST() { # Run test. TESTING $DUMPER $@ ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" + cd $TESTDIR + $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err # save actual and actual_err in case they are needed later. @@ -216,26 +216,25 @@ TOOLTEST() { STDERR_FILTER $actual_err cat $actual_err >> $actual - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.ddl) missing" - nerrors="`expr $nerrors + 1`" + if [ ! -f $expect ]; then + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + echo " Expected result (*.ddl) missing" + nerrors="`expr $nerrors + 1`" elif $CMP $expect $actual; then - echo " PASSED" + echo " PASSED" else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + echo "*FAILED*" + echo " Expected result (*.ddl) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav $actual_ext + rm -f $actual $actual_err $actual_sav $actual_err_sav $actual_ext fi - } @@ -254,42 +253,42 @@ TOOLTEST2() { # Run test. TESTING $DUMPER $@ ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" + cd $TESTDIR + $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err cat $actual_err >> $actual if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.ddl) missing" - nerrors="`expr $nerrors + 1`" - elif $CMP $expect $actual; then - if [ ! -f $expectdata ]; then - # Create the expect data file if it doesn't yet exist. + # Create the expect file if it doesn't yet exist. echo " CREATED" - cp $actualdata $expectdata - echo " Expected data (*.exp) missing" + cp $actual $expect + echo " Expected result (*.ddl) missing" nerrors="`expr $nerrors + 1`" - elif $CMP $expectdata $actualdata; then - echo " PASSED" - else + elif $CMP $expect $actual; then + if [ ! -f $expectdata ]; then + # Create the expect data file if it doesn't yet exist. + echo " CREATED" + cp $actualdata $expectdata + echo " Expected data (*.exp) missing" + nerrors="`expr $nerrors + 1`" + elif $CMP $expectdata $actualdata; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected datafile (*.exp) differs from actual datafile (*.txt)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /' + fi + else echo "*FAILED*" - echo " Expected datafile (*.exp) differs from actual datafile (*.txt)" + echo " Expected result (*.ddl) differs from actual result (*.out)" nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /' - fi - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actualdata $actual_err + rm -f $actual $actualdata $actual_err fi } @@ -309,8 +308,8 @@ TOOLTEST3() { # Run test. TESTING $DUMPER $@ ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" + cd $TESTDIR + $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err # save actual and actual_err in case they are needed later. @@ -326,27 +325,27 @@ TOOLTEST3() { -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ - $actual_err > $actual_ext + $actual_err > $actual_ext cat $actual_ext >> $actual if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.ddl) missing" - nerrors="`expr $nerrors + 1`" + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + echo " Expected result (*.ddl) missing" + nerrors="`expr $nerrors + 1`" elif $CMP $expect $actual; then - echo " PASSED" + echo " PASSED" else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + echo "*FAILED*" + echo " Expected result (*.ddl) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav + rm -f $actual $actual_err $actual_sav $actual_err_sav fi } @@ -367,8 +366,8 @@ TOOLTEST4() { # Run test. TESTING $DUMPER $@ ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" + cd $TESTDIR + $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err # save actual and actual_err in case they are needed later. @@ -384,47 +383,46 @@ TOOLTEST4() { -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ - $actual_err > $actual_ext + $actual_err > $actual_ext #cat $actual_ext >> $actual if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect elif $CMP $expect $actual; then - if $CMP $expect_err $actual_ext; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.err) differs from actual result (*.oerr)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect_err $actual_ext |sed 's/^/ /' - fi + if $CMP $expect_err $actual_ext; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result (*.err) differs from actual result (*.oerr)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect_err $actual_ext |sed 's/^/ /' + fi else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + echo "*FAILED*" + echo " Expected result (*.ddl) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav + rm -f $actual $actual_err $actual_sav $actual_err_sav fi - } # Print a "SKIP" message SKIP() { - TESTING $DUMPER $@ + TESTING $DUMPER $@ echo " -SKIP-" } # Print a line-line message left justified in a field of 70 characters # PRINT_H5DIFF() { - SPACES=" " - echo " Running h5diff $* $SPACES" | cut -c1-70 | tr -d '\012' + SPACES=" " + echo " Running h5diff $* $SPACES" | cut -c1-70 | tr -d '\012' } @@ -434,25 +432,25 @@ DIFFTEST() { PRINT_H5DIFF $@ ( - cd $TESTDIR - $RUNSERIAL $H5DIFF_BIN "$@" -q + cd $TESTDIR + $RUNSERIAL $H5DIFF_BIN "$@" -q ) RET=$? + if [ $RET != 0 ] ; then echo "*FAILED*" nerrors="`expr $nerrors + 1`" else echo " PASSED" fi - } # Print a line-line message left justified in a field of 70 characters # beginning with the word "Verifying". # PRINT_H5IMPORT() { - SPACES=" " - echo " Running h5import $* $SPACES" | cut -c1-70 | tr -d '\012' + SPACES=" " + echo " Running h5import $* $SPACES" | cut -c1-70 | tr -d '\012' } # Call the h5import tool @@ -462,22 +460,22 @@ IMPORTTEST() # remove the output hdf5 file if it exists hdf5_file="$TESTDIR/$5" if [ -f $hdf5_file ]; then - rm -f $hdf5_file + rm -f $hdf5_file fi PRINT_H5IMPORT $@ ( - cd $TESTDIR - $RUNSERIAL $H5IMPORT_BIN "$@" + cd $TESTDIR + $RUNSERIAL $H5IMPORT_BIN "$@" ) RET=$? + if [ $RET != 0 ] ; then echo "*FAILED*" nerrors="`expr $nerrors + 1`" else echo " PASSED" fi - } @@ -491,7 +489,7 @@ COPY_TESTFILES_TO_TESTDIR ####### test for dataset vds ###### - # Data read +# Data read if test $USE_FILTER_DEFLATE = "yes" ; then TOOLTEST tvds-1.ddl --enable-error-stack 1_vds.h5 TOOLTEST tvds-2.ddl --enable-error-stack 2_vds.h5 @@ -504,7 +502,7 @@ if test $USE_FILTER_DEFLATE = "yes" ; then TOOLTEST vds-gap2.ddl --vds-gap-size=2 --enable-error-stack vds-eiger.h5 fi - # Layout read +# Layout read if test $USE_FILTER_DEFLATE = "yes" ; then TOOLTEST tvds_layout-1.ddl -p --enable-error-stack 1_vds.h5 TOOLTEST tvds_layout-2.ddl -p --enable-error-stack 2_vds.h5 diff --git a/tools/test/h5dump/testh5dumpxml.sh.in b/tools/test/h5dump/testh5dumpxml.sh.in index f7af300..447c819 100644 --- a/tools/test/h5dump/testh5dumpxml.sh.in +++ b/tools/test/h5dump/testh5dumpxml.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. # @@ -262,36 +262,35 @@ TOOLTEST() { # Run test. TESTING $DUMPER $@ ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" + cd $TESTDIR + $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.xml) missing" - nerrors="`expr $nerrors + 1`" + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + echo " Expected result (*.xml) missing" + nerrors="`expr $nerrors + 1`" elif $CMP $expect $actual; then - echo " PASSED" + echo " PASSED" else - echo "*FAILED*" - echo " Expected result (*.xml) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + echo "*FAILED*" + echo " Expected result (*.xml) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err + rm -f $actual $actual_err fi } # Print a "SKIP" message SKIP() { - TESTING $DUMPER $@ - echo " -SKIP-" + TESTING $DUMPER $@ + echo " -SKIP-" } diff --git a/tools/test/h5format_convert/CMakeLists.txt b/tools/test/h5format_convert/CMakeLists.txt index 55d5623..34a3c7b 100644 --- a/tools/test/h5format_convert/CMakeLists.txt +++ b/tools/test/h5format_convert/CMakeLists.txt @@ -1,11 +1,11 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_TOOLS_TEST_H5FC C) # -------------------------------------------------------------------- # Add the h5format_convert test executables # -------------------------------------------------------------------- add_executable (h5fc_chk_idx ${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/h5fc_chk_idx.c) -target_include_directories (h5fc_chk_idx PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +target_include_directories (h5fc_chk_idx PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (h5fc_chk_idx STATIC) target_link_libraries (h5fc_chk_idx PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) @@ -15,14 +15,30 @@ else () endif () set_target_properties (h5fc_chk_idx PROPERTIES FOLDER tools) +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5FC_h5fc_chk_idx_FORMAT h5fc_chk_idx) +endif () + if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) add_executable (h5fc_gentest ${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/h5fc_gentest.c) - target_include_directories (h5fc_gentest PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (h5fc_gentest PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h5fc_gentest STATIC) target_link_libraries (h5fc_gentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (h5fc_gentest PROPERTIES FOLDER generator/tools) + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5FC_FORMAT h5fc_gentest) + endif () + #add_test (NAME h5fc_gentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5fc_gentest>) endif () -include (CMakeTests.cmake) +if (HDF5_TEST_TOOLS AND HDF5_TEST_SERIAL) + include (CMakeTests.cmake) +endif () diff --git a/tools/test/h5format_convert/CMakeTests.cmake b/tools/test/h5format_convert/CMakeTests.cmake index 398866c..00a28bb 100644 --- a/tools/test/h5format_convert/CMakeTests.cmake +++ b/tools/test/h5format_convert/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. # @@ -97,12 +97,6 @@ ############################################################################## ############################################################################## - if (NOT BUILD_SHARED_LIBS) - set (tgt_ext "") - else () - set (tgt_ext "-shared") - endif () - macro (ADD_H5_OUTPUT testname resultfile resultcode testfile) # If using memchecker add tests without using scripts if (NOT HDF5_ENABLE_USING_MEMCHECKER) @@ -123,7 +117,7 @@ NAME H5FC-${testname}-${testfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5format_convert${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5format_convert${tgt_file_ext}>" -D "TEST_ARGS=${ARGN};outtmp.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${testname}.out" @@ -139,7 +133,7 @@ NAME H5FC-${testname}-NA COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5format_convert${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5format_convert${tgt_file_ext}>" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${testname}.out" @@ -172,7 +166,7 @@ NAME H5FC-${testname}-${testfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5format_convert${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5format_convert${tgt_file_ext}>" -D "TEST_ARGS=${ARGN};outtmp.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${testname}.out" @@ -204,7 +198,7 @@ NAME H5FC-${testname}-${testfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5format_convert${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5format_convert${tgt_file_ext}>" -D "TEST_ARGS=${ARGN};outtmp.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${testname}.out" @@ -237,7 +231,7 @@ NAME H5FC-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5format_convert${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5format_convert${tgt_file_ext}>" -D "TEST_ARGS=${ARGN};./testfiles/tmp.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=testfiles/${testname}.out" @@ -280,7 +274,7 @@ NAME H5FC-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5format_convert${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5format_convert${tgt_file_ext}>" -D "TEST_ARGS=-d;${ARGN};./testfiles/chktmp.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=testfiles/${testname}.out" @@ -317,7 +311,7 @@ NAME H5FC-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5format_convert${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5format_convert${tgt_file_ext}>" -D "TEST_ARGS=${ARGN};./testfiles/dmptmp.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=testfiles/${testname}.out" @@ -330,7 +324,7 @@ NAME H5FC_CHECK_DUMP-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=-BH;./testfiles/dmptmp.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=testfiles/${testname}_chk.out" diff --git a/tools/test/h5format_convert/Makefile.am b/tools/test/h5format_convert/Makefile.am index eb2d5af..1922399 100644 --- a/tools/test/h5format_convert/Makefile.am +++ b/tools/test/h5format_convert/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. ## diff --git a/tools/test/h5format_convert/h5fc_chk_idx.c b/tools/test/h5format_convert/h5fc_chk_idx.c index 8369668..26a0fb9 100644 --- a/tools/test/h5format_convert/h5fc_chk_idx.c +++ b/tools/test/h5format_convert/h5fc_chk_idx.c @@ -6,14 +6,14 @@ * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * A program to verify that the chunk indexing type of a dataset in a file - * is version 1 B-tree. + * is version 1 B-tree. * This is to support the testing of the tool "h5format_convert". */ @@ -32,7 +32,7 @@ usage(void) /*------------------------------------------------------------------------- * Function: main * - * Purpose: To check that the chunk indexing type for the dataset in + * Purpose: To check that the chunk indexing type for the dataset in * the file is version 1 B-tree. * * Return: 0 -- the indexing type is version 1 B-tree @@ -43,16 +43,16 @@ usage(void) int main(int argc, char *argv[]) { - char *fname = NULL; - char *dname = NULL; - hid_t fid = -1; - hid_t did = -1; + char * fname = NULL; + char * dname = NULL; + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; H5D_chunk_index_t idx_type; /* h5fc_chk_idx fname dname */ - if(argc != 3) { - usage(); - HDexit(EXIT_FAILURE); + if (argc != 3) { + usage(); + HDexit(EXIT_FAILURE); } /* end if */ /* Duplicate the file name & dataset name */ @@ -60,42 +60,41 @@ main(int argc, char *argv[]) dname = HDstrdup(argv[2]); /* Try opening the file */ - if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { - HDfprintf(stderr, "h5fc_chk_idx: unable to open the file\n"); - HDexit(EXIT_FAILURE); + if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, (size_t)0)) < 0) { + HDfprintf(stderr, "h5fc_chk_idx: unable to open the file\n"); + HDexit(EXIT_FAILURE); } /* end if */ /* Open the dataset */ - if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) { - HDfprintf(stderr, "h5fc_chk_idx: unable to open the dataset\n"); - HDexit(EXIT_FAILURE); + if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) { + HDfprintf(stderr, "h5fc_chk_idx: unable to open the dataset\n"); + HDexit(EXIT_FAILURE); } /* end if */ /* Get the dataset's chunk indexing type */ - if(H5Dget_chunk_index_type(did, &idx_type) < 0) { - HDfprintf(stderr, "h5fc_chk_idx: unable to get chunk index type for the dataset\n"); - HDexit(EXIT_FAILURE); + if (H5Dget_chunk_index_type(did, &idx_type) < 0) { + HDfprintf(stderr, "h5fc_chk_idx: unable to get chunk index type for the dataset\n"); + HDexit(EXIT_FAILURE); } /* end if */ /* Close the dataset */ - if(H5Dclose(did) < 0) { - HDfprintf(stderr, "h5fc_chk_idx: unable to close the dataset\n"); - HDexit(EXIT_FAILURE); + if (H5Dclose(did) < 0) { + HDfprintf(stderr, "h5fc_chk_idx: unable to close the dataset\n"); + HDexit(EXIT_FAILURE); } /* end if */ /* Close the file */ - if(H5Fclose(fid) < 0) { - HDfprintf(stderr, "h5fc_chk_idx_type: cannot close the file\n"); - HDexit(EXIT_FAILURE); + if (H5Fclose(fid) < 0) { + HDfprintf(stderr, "h5fc_chk_idx_type: cannot close the file\n"); + HDexit(EXIT_FAILURE); } /* end if */ /* Return success when the chunk indexing type is version 1 B-tree */ - if(idx_type == H5D_CHUNK_IDX_BTREE) - HDexit(EXIT_SUCCESS); + if (idx_type == H5D_CHUNK_IDX_BTREE) + HDexit(EXIT_SUCCESS); else { - HDfprintf(stderr, "Error: chunk indexing type is %d\n", idx_type); - HDexit(EXIT_FAILURE); + HDfprintf(stderr, "Error: chunk indexing type is %d\n", idx_type); + HDexit(EXIT_FAILURE); } /* end if */ } /* main() */ - diff --git a/tools/test/h5format_convert/h5fc_gentest.c b/tools/test/h5format_convert/h5fc_gentest.c index b482dee..ccb64b5 100644 --- a/tools/test/h5format_convert/h5fc_gentest.c +++ b/tools/test/h5format_convert/h5fc_gentest.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,45 +24,42 @@ #include "hdf5.h" #include "H5private.h" -#define NON_V3_FILE "h5fc_non_v3.h5" -#define EDGE_V3_FILE "h5fc_edge_v3.h5" -#define ERR_LEVEL_FILE "h5fc_err_level.h5" - -const char *FILENAME[] = { - "h5fc_ext1_i.h5", /* 0 */ - "h5fc_ext1_s.h5", /* 1 */ - "h5fc_ext1_f.h5", /* 2 */ - "h5fc_ext2_is.h5", /* 3 */ - "h5fc_ext2_if.h5", /* 4 */ - "h5fc_ext2_sf.h5", /* 5 */ - "h5fc_ext3_isf.h5", /* 6 */ - "h5fc_ext_none.h5", /* 7 */ - NULL -}; - -#define GROUP "GROUP" - -#define DSET_COMPACT "DSET_COMPACT" -#define DSET_CONTIGUOUS "DSET_CONTIGUOUS" - -#define DSET_EA "DSET_EA" -#define DSET_NDATA_EA "DSET_NDATA_EA" +#define NON_V3_FILE "h5fc_non_v3.h5" +#define EDGE_V3_FILE "h5fc_edge_v3.h5" +#define ERR_LEVEL_FILE "h5fc_err_level.h5" + +const char *FILENAME[] = {"h5fc_ext1_i.h5", /* 0 */ + "h5fc_ext1_s.h5", /* 1 */ + "h5fc_ext1_f.h5", /* 2 */ + "h5fc_ext2_is.h5", /* 3 */ + "h5fc_ext2_if.h5", /* 4 */ + "h5fc_ext2_sf.h5", /* 5 */ + "h5fc_ext3_isf.h5", /* 6 */ + "h5fc_ext_none.h5", /* 7 */ + NULL}; + +#define GROUP "GROUP" + +#define DSET_COMPACT "DSET_COMPACT" +#define DSET_CONTIGUOUS "DSET_CONTIGUOUS" + +#define DSET_EA "DSET_EA" +#define DSET_NDATA_EA "DSET_NDATA_EA" #define DSET_BT2 "DSET_BT2" -#define DSET_NDATA_BT2 "DSET_NDATA_BT2" -#define DSET_FA "DSET_FA" -#define DSET_NDATA_FA "DSET_NDATA_FA" -#define DSET_NONE "DSET_NONE" -#define DSET_NDATA_NONE "DSET_NDATA_NONE" +#define DSET_NDATA_BT2 "DSET_NDATA_BT2" +#define DSET_FA "DSET_FA" +#define DSET_NDATA_FA "DSET_NDATA_FA" +#define DSET_NONE "DSET_NONE" +#define DSET_NDATA_NONE "DSET_NDATA_NONE" -#define DSET_EDGE "DSET_EDGE" -#define DSET_ERR "DSET_ERR" +#define DSET_EDGE "DSET_EDGE" +#define DSET_ERR "DSET_ERR" #define ISTORE_IK 64 #define ISTORE_ERR 1 #define NUM 500 - /* * Function: gen_non() * @@ -77,42 +74,42 @@ const char *FILENAME[] = { static void gen_non(const char *fname) { - hid_t fid = -1; /* file id */ - hid_t fcpl = -1; /* file creation property list */ - hid_t gid = -1; /* group id */ - hid_t sid = -1; /* space id */ - hid_t dcpl = -1; /* dataset creation property id */ - hid_t did1 = -1, did2 = -1; /* dataset id */ - hsize_t dims1[1] = {10}; /* dataset dimension */ - hsize_t dims2[2] = {4, 6}; /* dataset dimension */ - hsize_t max_dims[2]; /* maximum dataset dimension */ - hsize_t c_dims[2] = {2, 3}; /* chunk dimension */ - int i; /* local index variable */ - int buf[24]; /* data buffer */ + hid_t fid = H5I_INVALID_HID; /* file id */ + hid_t fcpl = H5I_INVALID_HID; /* file creation property list */ + hid_t gid = H5I_INVALID_HID; /* group id */ + hid_t sid = H5I_INVALID_HID; /* space id */ + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property id */ + hid_t did1 = -1, did2 = H5I_INVALID_HID; /* dataset id */ + hsize_t dims1[1] = {10}; /* dataset dimension */ + hsize_t dims2[2] = {4, 6}; /* dataset dimension */ + hsize_t max_dims[2]; /* maximum dataset dimension */ + hsize_t c_dims[2] = {2, 3}; /* chunk dimension */ + int i; /* local index variable */ + int buf[24]; /* data buffer */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; - if(H5Pset_shared_mesg_nindexes(fcpl, 4) < 0) + if (H5Pset_shared_mesg_nindexes(fcpl, 4) < 0) goto error; - if(H5Pset_istore_k(fcpl, 64) < 0) + if (H5Pset_istore_k(fcpl, 64) < 0) goto error; /* Create an empty file with latest-format */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, fcpl, H5P_DEFAULT)) < 0) goto error; /* Create a group */ - if((gid = H5Gcreate2(fid, GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create data */ - for(i = 0; i < 24; i++) + for (i = 0; i < 24; i++) buf[i] = i; /* Set chunk */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 2, c_dims) < 0) + if (H5Pset_chunk(dcpl, 2, c_dims) < 0) goto error; /* @@ -122,17 +119,17 @@ gen_non(const char *fname) /* Create dataspace */ max_dims[0] = 10; max_dims[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(2, dims2, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims2, max_dims)) < 0) goto error; /* Create the dataset */ - if((did1 = H5Dcreate2(fid, DSET_NDATA_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, DSET_NDATA_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Closing */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; /* @@ -143,35 +140,35 @@ gen_non(const char *fname) max_dims[0] = 10; max_dims[0] = H5S_UNLIMITED; max_dims[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(2, dims2, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims2, max_dims)) < 0) goto error; /* Create the dataset */ - if((did1 = H5Dcreate2(gid, DSET_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(gid, DSET_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write to the dataset */ - if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Closing */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; /* Re-open the file with old format */ - if((fid = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) goto error; /* Open the group */ - if((gid = H5Gopen2(fid, GROUP, H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(fid, GROUP, H5P_DEFAULT)) < 0) goto error; /* @@ -179,23 +176,23 @@ gen_non(const char *fname) */ /* Set chunk */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 2, c_dims) < 0) + if (H5Pset_chunk(dcpl, 2, c_dims) < 0) goto error; /* Create dataspace */ max_dims[0] = H5S_UNLIMITED; max_dims[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(2, dims2, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims2, max_dims)) < 0) goto error; /* Create the dataset */ - if((did1 = H5Dcreate2(fid, DSET_NDATA_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, DSET_NDATA_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Close the dataspace */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; /* @@ -205,25 +202,25 @@ gen_non(const char *fname) /* Create dataspace */ max_dims[0] = 10; max_dims[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(2, dims2, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims2, max_dims)) < 0) goto error; /* Create the dataset */ - if((did2 = H5Dcreate2(gid, DSET_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(gid, DSET_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write to the dataset */ - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Closing */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) goto error; /* @@ -231,61 +228,64 @@ gen_non(const char *fname) */ /* Create dataspace */ - if((sid = H5Screate_simple(1, dims1, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims1, NULL)) < 0) goto error; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_layout(dcpl, H5D_COMPACT) < 0) + if (H5Pset_layout(dcpl, H5D_COMPACT) < 0) goto error; /* Create the dataset */ - if((did1 = H5Dcreate2(gid, DSET_COMPACT, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(gid, DSET_COMPACT, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) goto error; /* Closing */ - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; /* * Create a contiguous dataset with (2d with data) in the file */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_layout(dcpl, H5D_CONTIGUOUS) < 0) + if (H5Pset_layout(dcpl, H5D_CONTIGUOUS) < 0) goto error; - if((sid = H5Screate_simple(2, dims2, NULL)) < 0) + if ((sid = H5Screate_simple(2, dims2, NULL)) < 0) goto error; /* Create the dataset */ - if((did2 = H5Dcreate2(fid, DSET_CONTIGUOUS, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(fid, DSET_CONTIGUOUS, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; /* Write to the dataset */ - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Closing */ - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Gclose(gid) < 0) - goto error; - if(H5Pclose(fcpl) < 0) - goto error; - if(H5Fclose(fid) < 0) + if (H5Gclose(gid) < 0) + goto error; + if (H5Pclose(fcpl) < 0) + goto error; + if (H5Fclose(fid) < 0) goto error; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); H5Dclose(did1); @@ -293,7 +293,8 @@ error: H5Gclose(gid); H5Fclose(fcpl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; } /* gen_non() */ @@ -307,79 +308,80 @@ error: static void gen_edge(const char *fname) { - hid_t fid = -1; /* file id */ - hid_t fapl = -1; /* file access property list */ - hid_t sid = -1; /* dataspace id */ - hid_t dcpl = -1; /* dataset creation property id */ - hid_t did = -1; /* dataset id */ - hsize_t dims2[2] = {12, 6}; /* Dataset dimensions */ - hsize_t c_dims[2] = {5, 5}; /* Chunk dimensions */ - float buf[12][6]; /* Buffer for writing data */ - int i, j; /* local index variable */ + hid_t fid = H5I_INVALID_HID; /* file id */ + hid_t fapl = H5I_INVALID_HID; /* file access property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace id */ + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property id */ + hid_t did = H5I_INVALID_HID; /* dataset id */ + hsize_t dims2[2] = {12, 6}; /* Dataset dimensions */ + hsize_t c_dims[2] = {5, 5}; /* Chunk dimensions */ + float buf[12][6]; /* Buffer for writing data */ + int i, j; /* local index variable */ /* Create a new format file */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; /* Set chunk, filter, no-filter-edge-chunk */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 2, c_dims) < 0) + if (H5Pset_chunk(dcpl, 2, c_dims) < 0) goto error; - if(H5Pset_deflate(dcpl, 9) < 0) + if (H5Pset_deflate(dcpl, 9) < 0) goto error; - if(H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) + if (H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) goto error; /* Create dataspace */ - if((sid = H5Screate_simple(2, dims2, NULL)) < 0) + if ((sid = H5Screate_simple(2, dims2, NULL)) < 0) goto error; /* Create the dataset */ - if((did = H5Dcreate2(fid, DSET_EDGE, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET_EDGE, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Create data */ - for (i = 0; i< 12; i++) - for (j = 0; j< 6; j++) + for (i = 0; i < 12; i++) + for (j = 0; j < 6; j++) buf[i][j] = 100.0F; /* Write to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Closing */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); H5Dclose(did); H5Fclose(fid); H5Pclose(fapl); - } H5E_END_TRY; + } + H5E_END_TRY; } /* gen_edge() */ - /* * Function: gen_err_level() * - * Generate a file to test the situtation described in HDFFV-9434: + * Generate a file to test the situation described in HDFFV-9434: * Exceed the limit of v1-btree level * * Create a file with H5Pset_istore_k(fcpl, 1). @@ -395,30 +397,30 @@ error: static void gen_err_level(const char *fname) { - hid_t fid = -1; /* file ID */ - hid_t fapl = -1; /* file access property list */ - hid_t fcpl = -1; /* file creation property list */ - hid_t sid = -1; /* dataspace id */ - hid_t dcpl = -1; /* dataset creation property list */ - hid_t did = -1; /* dataset ID */ - hid_t fsid = -1; /* file dataspace ID */ - hid_t msid = -1; /* memory dataspace ID */ - unsigned char *buf = NULL; /* buffer for data */ - hsize_t dims[2] = {0, 1}; /* dataset dimension sizes */ - hsize_t max_dims[2] = {1, H5S_UNLIMITED}; /* dataset maximum dimension sizes */ - hsize_t chunk_dims[2] = {1, 1}; /* chunk dimension sizes */ - int n = 0; /* local index variable */ + hid_t fid = H5I_INVALID_HID; /* file ID */ + hid_t fapl = H5I_INVALID_HID; /* file access property list */ + hid_t fcpl = H5I_INVALID_HID; /* file creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace id */ + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t did = H5I_INVALID_HID; /* dataset ID */ + hid_t fsid = H5I_INVALID_HID; /* file dataspace ID */ + hid_t msid = H5I_INVALID_HID; /* memory dataspace ID */ + unsigned char *buf = NULL; /* buffer for data */ + hsize_t dims[2] = {0, 1}; /* dataset dimension sizes */ + hsize_t max_dims[2] = {1, H5S_UNLIMITED}; /* dataset maximum dimension sizes */ + hsize_t chunk_dims[2] = {1, 1}; /* chunk dimension sizes */ + int n = 0; /* local index variable */ /* Create a new format file */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; /* Set 'K' value to 1 in file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; - if(H5Pset_istore_k(fcpl, ISTORE_ERR) < 0) + if (H5Pset_istore_k(fcpl, ISTORE_ERR) < 0) goto error; /* Initialize data buffer */ @@ -426,87 +428,88 @@ gen_err_level(const char *fname) HDmemset(buf, 42, NUM * sizeof(unsigned char)); /* Create the test file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0) goto error; /* Create a chunked dataset with extensible array chunk index */ - if((sid = H5Screate_simple(2, dims, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) goto error; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) goto error; - if((did = H5Dcreate2(fid, DSET_ERR, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET_ERR, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Closing */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; /* Re-open the file */ - if((fid = H5Fopen(fname, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(fname, H5F_ACC_RDWR, fapl)) < 0) goto error; /* Open the dataset */ - if((did = H5Dopen2(fid, DSET_ERR, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, DSET_ERR, H5P_DEFAULT)) < 0) goto error; /* Loop through appending 1 element at a time */ - for(n = 0; n < NUM; n++) { - hsize_t start[2] = {0, 0}; - hsize_t count[2] = {1, 1}; - hsize_t extent[2] = {0, 0}; + for (n = 0; n < NUM; n++) { + hsize_t start[2] = {0, 0}; + hsize_t count[2] = {1, 1}; + hsize_t extent[2] = {0, 0}; + + start[0] = 0; + start[1] = (hsize_t)n; + extent[0] = 1; + extent[1] = (hsize_t)(n + 1); + + /* Set current dimension sizes for the dataset */ + if (H5Dset_extent(did, extent) < 0) + goto error; - start[0] = 0; - start[1] = (hsize_t)n; - extent[0] = 1; - extent[1] = (hsize_t)(n + 1); + /* Set up memory dataspace */ + if ((msid = H5Screate_simple(2, count, NULL)) < 0) + goto error; - /* Set current dimension sizes for the dataset */ - if(H5Dset_extent(did, extent) < 0) - goto error; + /* Get file dataspace */ + if ((fsid = H5Dget_space(did)) < 0) + goto error; - /* Set up memory dataspace */ - if((msid = H5Screate_simple(2, count, NULL)) < 0) - goto error; + if ((H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, count, NULL)) < 0) + goto error; - /* Get file dataspace */ - if((fsid = H5Dget_space(did)) < 0) - goto error; + /* Write to the dataset */ + if (H5Dwrite(did, H5T_NATIVE_UCHAR, msid, fsid, H5P_DEFAULT, buf) < 0) + goto error; - if((H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, count, NULL)) < 0) - goto error; + if (H5Sclose(fsid) < 0) + goto error; + if (H5Sclose(msid) < 0) + goto error; + } - /* Write to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_UCHAR, msid, fsid, H5P_DEFAULT, buf) < 0) + /* Closing */ + if (H5Dclose(did) < 0) goto error; - - if(H5Sclose(fsid) < 0) + if (H5Fclose(fid) < 0) goto error; - if(H5Sclose(msid) < 0) + if (H5Pclose(fapl) < 0) goto error; - } - - /* Closing */ - if(H5Dclose(did) < 0) - goto error; - if(H5Fclose(fid) < 0) - goto error; - if(H5Pclose(fapl) < 0) - goto error; error: - if(buf) + if (buf) free(buf); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); H5Dclose(did); @@ -515,7 +518,8 @@ error: H5Fclose(fid); H5Pclose(fapl); H5Pclose(fcpl); - } H5E_END_TRY; + } + H5E_END_TRY; } /* gen_err_level() */ @@ -534,26 +538,26 @@ error: static void gen_ext(const char *fname, unsigned new_format, unsigned what) { - hid_t fid = -1; /* file id */ - hid_t fapl = -1; /* file access property list */ - hid_t fcpl = -1; /* file creation property list */ - hid_t gid = -1; /* group id */ - hid_t sid = -1; /* space id */ - hid_t dcpl = -1; /* dataset creation property id */ - hid_t did1 = -1, did2 = -1; /* dataset id */ - hsize_t dims1[1] = {10}; /* dataset dimension */ - hsize_t dims2[2] = {4, 6}; /* dataset dimension */ - hsize_t max_dims[2]; /* maximum dataset dimension */ - hsize_t c_dims[2] = {2, 3}; /* chunk dimension */ - int i; /* local index variable */ - int buf[24]; /* data buffer */ - - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; - - if(new_format) { + hid_t fid = H5I_INVALID_HID; /* file id */ + hid_t fapl = H5I_INVALID_HID; /* file access property list */ + hid_t fcpl = H5I_INVALID_HID; /* file creation property list */ + hid_t gid = H5I_INVALID_HID; /* group id */ + hid_t sid = H5I_INVALID_HID; /* space id */ + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property id */ + hid_t did1 = H5I_INVALID_HID, did2 = H5I_INVALID_HID; /* dataset id */ + hsize_t dims1[1] = {10}; /* dataset dimension */ + hsize_t dims2[2] = {4, 6}; /* dataset dimension */ + hsize_t max_dims[2]; /* maximum dataset dimension */ + hsize_t c_dims[2] = {2, 3}; /* chunk dimension */ + int i; /* local index variable */ + int buf[24]; /* data buffer */ + + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + + if (new_format) { /* Create a new format file */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; } /* end if */ @@ -561,68 +565,68 @@ gen_ext(const char *fname, unsigned new_format, unsigned what) fcpl = H5Pcreate(H5P_FILE_CREATE); /* Generate messages that might be placed in superblock extension */ - switch(what) { - case 0: - H5Pset_istore_k(fcpl, ISTORE_IK); - break; - case 1: - H5Pset_shared_mesg_nindexes(fcpl, 4); - break; - case 2: - H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1); - break; - case 3: - H5Pset_istore_k(fcpl, ISTORE_IK); - H5Pset_shared_mesg_nindexes(fcpl, 4); - break; - case 4: - H5Pset_istore_k(fcpl, ISTORE_IK); - H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1); - break; - case 5: - H5Pset_shared_mesg_nindexes(fcpl, 4); - H5Pset_file_space_page_size(fcpl, (hsize_t)512); - break; - case 6: - H5Pset_istore_k(fcpl, ISTORE_IK); - H5Pset_shared_mesg_nindexes(fcpl, 4); - H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_NONE, FALSE, (hsize_t)1); - break; - default: - break; + switch (what) { + case 0: + H5Pset_istore_k(fcpl, ISTORE_IK); + break; + case 1: + H5Pset_shared_mesg_nindexes(fcpl, 4); + break; + case 2: + H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1); + break; + case 3: + H5Pset_istore_k(fcpl, ISTORE_IK); + H5Pset_shared_mesg_nindexes(fcpl, 4); + break; + case 4: + H5Pset_istore_k(fcpl, ISTORE_IK); + H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1); + break; + case 5: + H5Pset_shared_mesg_nindexes(fcpl, 4); + H5Pset_file_space_page_size(fcpl, (hsize_t)512); + break; + case 6: + H5Pset_istore_k(fcpl, ISTORE_IK); + H5Pset_shared_mesg_nindexes(fcpl, 4); + H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_NONE, FALSE, (hsize_t)1); + break; + default: + break; } /* Create the file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0) goto error; /* Create a group */ - if((gid = H5Gcreate2(fid, GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Set chunk */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 2, c_dims) < 0) + if (H5Pset_chunk(dcpl, 2, c_dims) < 0) goto error; - /* * Create a contiguous dataset */ /* Create dataspace */ - if((sid = H5Screate_simple(1, dims1, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims1, NULL)) < 0) goto error; /* Create the dataset */ - if((did1 = H5Dcreate2(fid, DSET_CONTIGUOUS, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, DSET_CONTIGUOUS, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; /* Closing */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; /* @@ -633,33 +637,32 @@ gen_ext(const char *fname, unsigned new_format, unsigned what) /* Create dataspace */ max_dims[0] = 10; max_dims[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(2, dims2, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims2, max_dims)) < 0) goto error; /* Create the 2 datasets */ - if((did1 = H5Dcreate2(gid, DSET_NDATA_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(gid, DSET_NDATA_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if((did2 = H5Dcreate2(fid, DSET_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(fid, DSET_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Create data */ - for(i = 0; i < 24; i++) + for (i = 0; i < 24; i++) buf[i] = i; /* Write to one dataset */ - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Closing */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) goto error; - /* * Create 2 chunked datasets with version 2 B-tree chunk indexing type * (one with data; one without data) @@ -669,26 +672,26 @@ gen_ext(const char *fname, unsigned new_format, unsigned what) max_dims[0] = 10; max_dims[0] = H5S_UNLIMITED; max_dims[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(2, dims2, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims2, max_dims)) < 0) goto error; /* Create the 2 datasets */ - if((did1 = H5Dcreate2(fid, DSET_NDATA_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, DSET_NDATA_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if((did2 = H5Dcreate2(gid, DSET_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(gid, DSET_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write to one dataset */ - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Closing */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) goto error; /* @@ -699,70 +702,70 @@ gen_ext(const char *fname, unsigned new_format, unsigned what) /* Create dataspace */ max_dims[0] = 20; max_dims[1] = 10; - if((sid = H5Screate_simple(2, dims2, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims2, max_dims)) < 0) goto error; /* Create the datasets */ - if((did1 = H5Dcreate2(fid, DSET_FA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, DSET_FA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if((did2 = H5Dcreate2(gid, DSET_NDATA_FA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(gid, DSET_NDATA_FA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write to the dataset */ - if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Closing */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) goto error; - /* * Create 2 chunked datasets with implicit chunk indexing type * (one with data; one without data) */ /* Create dataspace */ - if((sid = H5Screate_simple(2, dims2, NULL)) < 0) + if ((sid = H5Screate_simple(2, dims2, NULL)) < 0) goto error; /* Set early allocation */ - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) goto error; /* Create the 2 datasets */ - if((did1 = H5Dcreate2(fid, DSET_NONE, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, DSET_NONE, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if((did2 = H5Dcreate2(gid, DSET_NDATA_NONE, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(gid, DSET_NDATA_NONE, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write to one dataset */ - if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Closing */ - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); H5Dclose(did1); @@ -771,7 +774,8 @@ error: H5Fclose(fid); H5Pclose(fapl); H5Pclose(fcpl); - } H5E_END_TRY; + } + H5E_END_TRY; } /* end gen_ext() */ @@ -790,19 +794,18 @@ main(void) gen_err_level(ERR_LEVEL_FILE); /* Generate old/new format file with/without messages in the superblock extension */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { - for(i = 0; i < 8; i++) { + for (new_format = FALSE; new_format <= TRUE; new_format++) { + for (i = 0; i < 8; i++) { char filename[50]; HDmemset(filename, 0, sizeof(filename)); - if(!new_format) + if (!new_format) HDstrcat(filename, "old_"); HDstrcat(filename, FILENAME[i]); gen_ext(filename, new_format, i); } /* end for */ - } /* end for */ + } /* end for */ return 0; } /* end main */ - diff --git a/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl.err b/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl.err index d85a999..e72892d 100644 --- a/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl.err +++ b/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl.err @@ -1,8 +1 @@ h5format_convert error: unable to downgrade dataset "/DSET_ERR" -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5trav_visit(): traverse failed - major: Failure in tools library - minor: error in function - #001: (file name) line (number) in traverse(): H5Lvisit_by_name failed - major: Failure in tools library - minor: error in function diff --git a/tools/test/h5format_convert/testh5fc.sh.in b/tools/test/h5format_convert/testh5fc.sh.in index 2cdd445..df083d1 100644 --- a/tools/test/h5format_convert/testh5fc.sh.in +++ b/tools/test/h5format_convert/testh5fc.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. # @@ -313,7 +313,7 @@ TOOLTEST_MASK_OUT() { $RM $actual $actual_err $actual_sav $actual_err_sav fi } -# Same as TOOLTEST_OUT except only compares error outout +# Same as TOOLTEST_OUT except only compares error output TOOLTEST_ERR() { # Prepare expected and actual output expect="$TESTDIR/$1" diff --git a/tools/test/h5import/CMakeLists.txt b/tools/test/h5import/CMakeLists.txt index 9364683..e8b5bce 100644 --- a/tools/test/h5import/CMakeLists.txt +++ b/tools/test/h5import/CMakeLists.txt @@ -1,11 +1,11 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_TOOLS_TEST_H5IMPORT C) # -------------------------------------------------------------------- # Add the h5import executables # -------------------------------------------------------------------- add_executable (h5importtest ${HDF5_TOOLS_TEST_H5IMPORT_SOURCE_DIR}/h5importtest.c) -target_include_directories (h5importtest PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +target_include_directories (h5importtest PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (h5importtest STATIC) target_link_libraries (h5importtest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) @@ -15,4 +15,13 @@ else () endif () set_target_properties (h5importtest PROPERTIES FOLDER tools) -include (CMakeTests.cmake) +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5IMPORT_FORMAT h5importtest) +endif () + +if (HDF5_TEST_TOOLS AND HDF5_TEST_SERIAL) + include (CMakeTests.cmake) +endif () diff --git a/tools/test/h5import/CMakeTests.cmake b/tools/test/h5import/CMakeTests.cmake index 22ab848..ee1d401 100644 --- a/tools/test/h5import/CMakeTests.cmake +++ b/tools/test/h5import/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. # @@ -96,16 +96,10 @@ ############################################################################## ############################################################################## - if (NOT BUILD_SHARED_LIBS) - set (tgt_ext "") - else () - set (tgt_ext "-shared") - endif () - macro (ADD_H5_TEST testname importfile conffile testfile) # If using memchecker skip macro based tests if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5IMPORT-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5import${tgt_ext}> ${importfile} -c ${conffile} -o ${testfile}) + add_test (NAME H5IMPORT-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5import${tgt_file_ext}> ${importfile} -c ${conffile} -o ${testfile}) set_tests_properties (H5IMPORT-${testname} PROPERTIES FIXTURES_REQUIRED set_h5importtest ) @@ -118,7 +112,7 @@ FIXTURES_REQUIRED set_h5importtest ) - add_test (NAME H5IMPORT-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5import${tgt_ext}> ${importfile} -c ${conffile} -o ${testfile}) + add_test (NAME H5IMPORT-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5import${tgt_file_ext}> ${importfile} -c ${conffile} -o ${testfile}) set_tests_properties (H5IMPORT-${testname} PROPERTIES DEPENDS H5IMPORT-${testname}-clear-objects ) @@ -127,7 +121,7 @@ NAME H5IMPORT-${testname}-H5DMP COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=${testfile}.new" @@ -143,7 +137,7 @@ NAME H5IMPORT-${testname}-H5DMP_CMP COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=testfiles/${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=${testfile}.out" @@ -176,7 +170,7 @@ NAME H5IMPORT-DUMP-${testname}-H5DMP COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=-p;-d;${datasetname};-o;d${testfile}.bin;-b;NATIVE;testfiles/${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=d${testfile}.dmp" @@ -189,7 +183,7 @@ NAME H5IMPORT-DUMP-${testname}-H5DMP COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=-p;-d;${datasetname};-o;d${testfile}.bin;-y;--width=1;testfiles/${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=d${testfile}.dmp" @@ -206,7 +200,7 @@ NAME H5IMPORT-DUMP-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5import${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5import${tgt_file_ext}>" -D "TEST_ARGS:STRING=d${testfile}.bin;-c;d${testfile}.dmp;-o;d${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=d${testfile}.imp" @@ -222,7 +216,7 @@ NAME H5IMPORT-DUMP-${testname}-H5DFF COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5diff${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5diff${tgt_file_ext}>" -D "TEST_ARGS:STRING=-r;d${testfile};testfiles/${testfile};${datasetname};${datasetname}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=d${testfile}.dff" @@ -254,7 +248,7 @@ NAME H5IMPORT_SUB-DUMP-${testname}-H5DMP COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=-p;-d;${datasetname};${ARGN};-o;${testname}.bin;-b;NATIVE;testfiles/${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=${testname}.dmp" @@ -270,7 +264,7 @@ NAME H5IMPORT_SUB-DUMP-${testname}-H5IMP COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5import${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5import${tgt_file_ext}>" -D "TEST_ARGS:STRING=${testname}.bin;-c;${testname}.dmp;-o;d-${testname}.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=${testname}.imp" @@ -285,7 +279,7 @@ NAME H5IMPORT_SUB-DUMP-${testname}-CMP COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=-p;d-${testname}.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=d-${testname}.dmp" diff --git a/tools/test/h5import/Makefile.am b/tools/test/h5import/Makefile.am index 7c5371c..61e3548 100644 --- a/tools/test/h5import/Makefile.am +++ b/tools/test/h5import/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. ## diff --git a/tools/test/h5import/h5importtest.c b/tools/test/h5import/h5importtest.c index 560f1b3..7dbf762 100644 --- a/tools/test/h5import/h5importtest.c +++ b/tools/test/h5import/h5importtest.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -32,64 +32,60 @@ int main(void) { - int nrow = 3, ncol = 4, npln = 5; - int i, j, k; - FILE *sp; - char machine_order[3] = {0, 0, 0}; + int nrow = 3, ncol = 4, npln = 5; + int i, j, k; + FILE *sp; + char machine_order[3] = {0, 0, 0}; - float row4[3], col4[4], pln4[5]; - float rowo4 = 11.0F, colo4 = 21.0F, plno4 = 51.0F; - float rowi4 = 1.0F, coli4 = 2.0F, plni4 = 5.0F; + float row4[3], col4[4], pln4[5]; + float rowo4 = 11.0F, colo4 = 21.0F, plno4 = 51.0F; + float rowi4 = 1.0F, coli4 = 2.0F, plni4 = 5.0F; - int b32i3[5][3][4]; - int row4i[3], col4i[4], pln4i[5]; - int rowo4i = 11 , colo4i = 21 , plno4i = 51 ; - int rowi4i = 1 , coli4i = 2 , plni4i = 5 ; + int b32i3[5][3][4]; + int row4i[3], col4i[4], pln4i[5]; + int rowo4i = 11, colo4i = 21, plno4i = 51; + int rowi4i = 1, coli4i = 2, plni4i = 5; -#ifdef H5_SIZEOF_LONG_LONG long long row4i64[3], col4i64[4], pln4i64[5]; - long long rowo4i64 = (long long)11 , colo4i64 = (long long)21 , plno4i64 = (long long)51 ; - long long rowi4i64 = (long long)1 , coli4i64 = (long long)2 , plni4i64 = (long long)5 ; -#endif + long long rowo4i64 = (long long)11, colo4i64 = (long long)21, plno4i64 = (long long)51; + long long rowi4i64 = (long long)1, coli4i64 = (long long)2, plni4i64 = (long long)5; - short b16i3[5][3][4]; - short row4i16[3], col4i16[4], pln4i16[5]; - short rowo4i16 = (short)11 , colo4i16 = (short)21 , plno4i16 = (short)51 ; - short rowi4i16 = (short)1 , coli4i16 = (short)2 , plni4i16 = (short)5 ; + short b16i3[5][3][4]; + short row4i16[3], col4i16[4], pln4i16[5]; + short rowo4i16 = (short)11, colo4i16 = (short)21, plno4i16 = (short)51; + short rowi4i16 = (short)1, coli4i16 = (short)2, plni4i16 = (short)5; - char b8i3[5][3][4]; - char row4i8[3], col4i8[4], pln4i8[5]; - char rowo4i8 = (char)11 , colo4i8 = (char)21 , plno4i8 = (char)51 ; - char rowi4i8 = (char)1 , coli4i8 = (char)2 , plni4i8 = (char)5 ; + char b8i3[5][3][4]; + char row4i8[3], col4i8[4], pln4i8[5]; + char rowo4i8 = (char)11, colo4i8 = (char)21, plno4i8 = (char)51; + char rowi4i8 = (char)1, coli4i8 = (char)2, plni4i8 = (char)5; - double b64r3[5][3][4]; - double row8[3], col8[4], pln8[5]; - double rowo8 = 11.0F, colo8 = 21.0F, plno8 = 51.0F; - double rowi8 = 1.0F, coli8 = 2.0F, plni8 = 5.0F; + double b64r3[5][3][4]; + double row8[3], col8[4], pln8[5]; + double rowo8 = 11.0, colo8 = 21.0, plno8 = 51.0; + double rowi8 = 1.0, coli8 = 2.0, plni8 = 5.0; /* Initialize machine endian */ - volatile uint32_t ibyte=0x01234567; + volatile uint32_t ibyte = 0x01234567; /* 0 for big endian, 1 for little endian. */ - if ((*((uint8_t*)(&ibyte))) == 0x67) - HDstrncpy(machine_order, "LE", 2); + if ((*((volatile uint8_t *)(&ibyte))) == 0x67) + HDstrcpy(machine_order, "LE"); else - HDstrncpy(machine_order, "BE", 2); - + HDstrcpy(machine_order, "BE"); /* - * initialize the row, column, and plane vectors - * - * row values start at 11 and increment by 1 => 11, 12, 13 - * column values start at 21 and increment by 2 => 21, 23, 25, 27 - * plane values start at 51 and increment by 5 => 51, 56, 61, 66, 71 - */ - + * initialize the row, column, and plane vectors + * + * row values start at 11 and increment by 1 => 11, 12, 13 + * column values start at 21 and increment by 2 => 21, 23, 25, 27 + * plane values start at 51 and increment by 5 => 51, 56, 61, 66, 71 + */ /* - * build array elements - rank 2 - * - * element value = sum of row value and col values - */ + * build array elements - rank 2 + * + * element value = sum of row value and col values + */ row4[0] = rowo4; col4[0] = colo4; @@ -103,11 +99,9 @@ main(void) col4i[0] = colo4i; pln4i[0] = plno4i; -#ifdef H5_SIZEOF_LONG_LONG row4i64[0] = rowo4i64; col4i64[0] = colo4i64; pln4i64[0] = plno4i64; -#endif row4i16[0] = rowo4i16; col4i16[0] = colo4i16; @@ -117,46 +111,37 @@ main(void) col4i8[0] = colo4i8; pln4i8[0] = plno4i8; - for (i = 1; i < nrow; i++) - { - row4[i] = row4[i - 1] + rowi4; - row8[i] = row8[i - 1] + rowi8; - row4i[i] = row4i[i - 1] + rowi4i; -#ifdef H5_SIZEOF_LONG_LONG + for (i = 1; i < nrow; i++) { + row4[i] = row4[i - 1] + rowi4; + row8[i] = row8[i - 1] + rowi8; + row4i[i] = row4i[i - 1] + rowi4i; row4i64[i] = row4i64[i - 1] + rowi4i64; -#endif row4i16[i] = (short)(row4i16[i - 1] + rowi4i16); - row4i8[i] = (char)(row4i8[i - 1] + rowi4i8); + row4i8[i] = (char)(row4i8[i - 1] + rowi4i8); } - for (j = 1; j < ncol; j++) - { - col4[j] = col4[j - 1] + coli4; - col8[j] = col8[j - 1] + coli8; - col4i[j] = col4i[j - 1] + coli4i; -#ifdef H5_SIZEOF_LONG_LONG + for (j = 1; j < ncol; j++) { + col4[j] = col4[j - 1] + coli4; + col8[j] = col8[j - 1] + coli8; + col4i[j] = col4i[j - 1] + coli4i; col4i64[j] = col4i64[j - 1] + coli4i64; -#endif col4i16[j] = (short)(col4i16[j - 1] + coli4i16); - col4i8[j] = (char)(col4i8[j - 1] + coli4i8); + col4i8[j] = (char)(col4i8[j - 1] + coli4i8); } - for (k = 1; k < npln; k++) - { - pln4[k] = pln4[k - 1] + plni4; - pln8[k] = pln8[k - 1] + plni8; - pln4i[k] = pln4i[k - 1] + plni4i; -#ifdef H5_SIZEOF_LONG_LONG + for (k = 1; k < npln; k++) { + pln4[k] = pln4[k - 1] + plni4; + pln8[k] = pln8[k - 1] + plni8; + pln4i[k] = pln4i[k - 1] + plni4i; pln4i64[k] = pln4i64[k - 1] + plni4i64; -#endif pln4i16[k] = (short)(pln4i16[k - 1] + plni4i16); - pln4i8[k] = (char)(pln4i8[k - 1] + plni4i8); + pln4i8[k] = (char)(pln4i8[k - 1] + plni4i8); } /* - * build array elements - rank 3 - * - * element value = sum of row value, col, and plane values - */ + * build array elements - rank 3 + * + * element value = sum of row value, col, and plane values + */ for (i = 0; i < nrow; i++) for (j = 0; j < ncol; j++) @@ -164,296 +149,267 @@ main(void) b64r3[k][i][j] = row8[i] + col8[j] + pln8[k]; b32i3[k][i][j] = row4i[i] + col4i[j] + pln4i[k]; b16i3[k][i][j] = (short)(row4i16[i] + col4i16[j] + pln4i16[k]); - b8i3[k][i][j] = (char)(row4i8[i] + col4i8[j] + pln4i8[k]); + b8i3[k][i][j] = (char)(row4i8[i] + col4i8[j] + pln4i8[k]); } - - #ifndef UNICOS #ifdef REBUILDTEXTFILES - /*------------------------------------------------------------------------- - * TOOLTEST txtin8.txt -c $srcdir/testfiles/txtin8.conf -o txtin8.h5 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * TOOLTEST txtin8.txt -c $srcdir/testfiles/txtin8.conf -o txtin8.h5 + *------------------------------------------------------------------------- + */ sp = HDfopen("txtin8.txt", "w"); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { - for (j = 0; j < ncol; j++) - (void) HDfprintf(sp, "%10u", b8i3[k][i][j]); - (void) HDfprintf(sp, "\n"); - } + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { + for (j = 0; j < ncol; j++) + (void)HDfprintf(sp, "%10u", b8i3[k][i][j]); + (void)HDfprintf(sp, "\n"); + } } - (void) HDfclose(sp); + (void)HDfclose(sp); - /*------------------------------------------------------------------------- - * TOOLTEST txtin16.txt -c $srcdir/testfiles/txtin16.conf -o txtin16.h5 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * TOOLTEST txtin16.txt -c $srcdir/testfiles/txtin16.conf -o txtin16.h5 + *------------------------------------------------------------------------- + */ sp = HDfopen("txtin16.txt", "w"); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { - for (j = 0; j < ncol; j++) - (void) HDfprintf(sp, "%10u", b16i3[k][i][j]); - (void) HDfprintf(sp, "\n"); - } + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { + for (j = 0; j < ncol; j++) + (void)HDfprintf(sp, "%10u", b16i3[k][i][j]); + (void)HDfprintf(sp, "\n"); + } } - (void) HDfclose(sp); + (void)HDfclose(sp); - /*------------------------------------------------------------------------- - * TOOLTEST txtin32.txt -c $srcdir/testfiles/textin32.conf -o textin32.h5 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * TOOLTEST txtin32.txt -c $srcdir/testfiles/textin32.conf -o textin32.h5 + *------------------------------------------------------------------------- + */ sp = HDfopen("txtin32.txt", "w"); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { for (j = 0; j < ncol; j++) - (void) HDfprintf(sp, "%10d", b32i3[k][i][j]); - (void) HDfprintf(sp, "\n"); + (void)HDfprintf(sp, "%10d", b32i3[k][i][j]); + (void)HDfprintf(sp, "\n"); } } - (void) HDfclose(sp); + (void)HDfclose(sp); #endif - /*------------------------------------------------------------------------- - * TOOLTEST binin32.bin -c binin32.conf -o binin32.h5 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * TOOLTEST binin32.bin -c binin32.conf -o binin32.h5 + *------------------------------------------------------------------------- + */ sp = HDfopen("binin32.bin", OPEN_FLAGS); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { - for (j = 0; j < ncol; j++) - { - (void) HDfwrite((char *) &b32i3[k][i][j], sizeof(int), 1, sp); + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { + for (j = 0; j < ncol; j++) { + (void)HDfwrite((char *)&b32i3[k][i][j], sizeof(int), 1, sp); } } } - (void) HDfclose(sp); + (void)HDfclose(sp); sp = HDfopen("binin32.conf", "w"); - (void) HDfprintf(sp, "PATH /int/bin/32-bit\n"); - (void) HDfprintf(sp, "INPUT-CLASS IN\n"); - (void) HDfprintf(sp, "INPUT-SIZE 32\n"); - (void) HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); - (void) HDfprintf(sp, "RANK 3\n"); - (void) HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); - (void) HDfprintf(sp, "OUTPUT-BYTE-ORDER BE\n"); - (void) HDfprintf(sp, "DIMENSION-SIZES 5 3 4\n"); - (void) HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 1 2 1\n"); - (void) HDfprintf(sp, "\n"); - (void) HDfclose(sp); - - /*------------------------------------------------------------------------- - * TOOLTEST binuin32.bin -c binuin32.conf -o binuin32.h5 - *------------------------------------------------------------------------- - */ + (void)HDfprintf(sp, "PATH /int/bin/32-bit\n"); + (void)HDfprintf(sp, "INPUT-CLASS IN\n"); + (void)HDfprintf(sp, "INPUT-SIZE 32\n"); + (void)HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); + (void)HDfprintf(sp, "RANK 3\n"); + (void)HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); + (void)HDfprintf(sp, "OUTPUT-BYTE-ORDER BE\n"); + (void)HDfprintf(sp, "DIMENSION-SIZES 5 3 4\n"); + (void)HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 1 2 1\n"); + (void)HDfprintf(sp, "\n"); + (void)HDfclose(sp); + + /*------------------------------------------------------------------------- + * TOOLTEST binuin32.bin -c binuin32.conf -o binuin32.h5 + *------------------------------------------------------------------------- + */ sp = HDfopen("binuin32.bin", OPEN_FLAGS); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { - for (j = 0; j < ncol; j++) - { - (void) HDfwrite((char *) &b32i3[k][i][j], sizeof(unsigned int), 1, sp); + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { + for (j = 0; j < ncol; j++) { + (void)HDfwrite((char *)&b32i3[k][i][j], sizeof(unsigned int), 1, sp); } } } - (void) HDfclose(sp); + (void)HDfclose(sp); sp = HDfopen("binuin32.conf", "w"); - (void) HDfprintf(sp, "PATH /int/buin/32-bit\n"); - (void) HDfprintf(sp, "INPUT-CLASS UIN\n"); - (void) HDfprintf(sp, "INPUT-SIZE 32\n"); - (void) HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); - (void) HDfprintf(sp, "RANK 3\n"); - (void) HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); - (void) HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); - (void) HDfprintf(sp, "DIMENSION-SIZES 5 3 4\n"); - (void) HDfprintf(sp, "\n"); - (void) HDfclose(sp); - - /*------------------------------------------------------------------------- - * TOOLTEST binin16.bin -c binin16.conf -o binin16.h5 - *------------------------------------------------------------------------- - */ + (void)HDfprintf(sp, "PATH /int/buin/32-bit\n"); + (void)HDfprintf(sp, "INPUT-CLASS UIN\n"); + (void)HDfprintf(sp, "INPUT-SIZE 32\n"); + (void)HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); + (void)HDfprintf(sp, "RANK 3\n"); + (void)HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); + (void)HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); + (void)HDfprintf(sp, "DIMENSION-SIZES 5 3 4\n"); + (void)HDfprintf(sp, "\n"); + (void)HDfclose(sp); + + /*------------------------------------------------------------------------- + * TOOLTEST binin16.bin -c binin16.conf -o binin16.h5 + *------------------------------------------------------------------------- + */ sp = HDfopen("binin16.bin", OPEN_FLAGS); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { - for (j = 0; j < ncol; j++) - { - (void) HDfwrite((char *) &b16i3[k][i][j], sizeof(short), 1, sp); + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { + for (j = 0; j < ncol; j++) { + (void)HDfwrite((char *)&b16i3[k][i][j], sizeof(short), 1, sp); } } } - (void) HDfclose(sp); + (void)HDfclose(sp); sp = HDfopen("binin16.conf", "w"); - (void) HDfprintf(sp, "PATH /int/bin/16-bit\n"); - (void) HDfprintf(sp, "INPUT-CLASS IN\n"); - (void) HDfprintf(sp, "INPUT-SIZE 16\n"); - (void) HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); - (void) HDfprintf(sp, "RANK 3\n"); - (void) HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); - (void) HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); - (void) HDfprintf(sp, "DIMENSION-SIZES 2 3 4\n"); - (void) HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 2 2 2\n"); - (void) HDfprintf(sp, "MAXIMUM-DIMENSIONS -1 -1 8\n"); - (void) HDfprintf(sp, "\n"); - (void) HDfclose(sp); - - /*------------------------------------------------------------------------- - * TOOLTEST binuin16.bin -c binuin16.conf -o binuin16.h5 - *------------------------------------------------------------------------- - */ + (void)HDfprintf(sp, "PATH /int/bin/16-bit\n"); + (void)HDfprintf(sp, "INPUT-CLASS IN\n"); + (void)HDfprintf(sp, "INPUT-SIZE 16\n"); + (void)HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); + (void)HDfprintf(sp, "RANK 3\n"); + (void)HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); + (void)HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); + (void)HDfprintf(sp, "DIMENSION-SIZES 2 3 4\n"); + (void)HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 2 2 2\n"); + (void)HDfprintf(sp, "MAXIMUM-DIMENSIONS -1 -1 8\n"); + (void)HDfprintf(sp, "\n"); + (void)HDfclose(sp); + + /*------------------------------------------------------------------------- + * TOOLTEST binuin16.bin -c binuin16.conf -o binuin16.h5 + *------------------------------------------------------------------------- + */ sp = HDfopen("binuin16.bin", OPEN_FLAGS); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { - for (j = 0; j < ncol; j++) - { - (void) HDfwrite((char *) &b16i3[k][i][j], sizeof(unsigned short), 1, sp); + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { + for (j = 0; j < ncol; j++) { + (void)HDfwrite((char *)&b16i3[k][i][j], sizeof(unsigned short), 1, sp); } } } - (void) HDfclose(sp); + (void)HDfclose(sp); sp = HDfopen("binuin16.conf", "w"); - (void) HDfprintf(sp, "PATH /int/buin/16-bit\n"); - (void) HDfprintf(sp, "INPUT-CLASS UIN\n"); - (void) HDfprintf(sp, "INPUT-SIZE 16\n"); - (void) HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); - (void) HDfprintf(sp, "RANK 3\n"); - (void) HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); - (void) HDfprintf(sp, "OUTPUT-BYTE-ORDER BE\n"); - (void) HDfprintf(sp, "DIMENSION-SIZES 2 3 4\n"); - (void) HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 2 2 2\n"); - (void) HDfprintf(sp, "MAXIMUM-DIMENSIONS -1 -1 8\n"); - (void) HDfprintf(sp, "\n"); - (void) HDfclose(sp); - - /*------------------------------------------------------------------------- - * TOOLTEST binin8.bin -c binin8.conf -o binin8.h5 - *------------------------------------------------------------------------- - */ + (void)HDfprintf(sp, "PATH /int/buin/16-bit\n"); + (void)HDfprintf(sp, "INPUT-CLASS UIN\n"); + (void)HDfprintf(sp, "INPUT-SIZE 16\n"); + (void)HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); + (void)HDfprintf(sp, "RANK 3\n"); + (void)HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); + (void)HDfprintf(sp, "OUTPUT-BYTE-ORDER BE\n"); + (void)HDfprintf(sp, "DIMENSION-SIZES 2 3 4\n"); + (void)HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 2 2 2\n"); + (void)HDfprintf(sp, "MAXIMUM-DIMENSIONS -1 -1 8\n"); + (void)HDfprintf(sp, "\n"); + (void)HDfclose(sp); + + /*------------------------------------------------------------------------- + * TOOLTEST binin8.bin -c binin8.conf -o binin8.h5 + *------------------------------------------------------------------------- + */ sp = HDfopen("binin8.bin", OPEN_FLAGS); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { - for (j = 0; j < ncol; j++) - { - (void) HDfwrite((char *) &b8i3[k][i][j], sizeof(char), 1, sp); + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { + for (j = 0; j < ncol; j++) { + (void)HDfwrite((char *)&b8i3[k][i][j], sizeof(char), 1, sp); } } } - (void) HDfclose(sp); + (void)HDfclose(sp); sp = HDfopen("binin8.conf", "w"); - (void) HDfprintf(sp, "PATH /int/bin/8-bit\n"); - (void) HDfprintf(sp, "INPUT-CLASS IN\n"); - (void) HDfprintf(sp, "INPUT-SIZE 8\n"); - (void) HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); - (void) HDfprintf(sp, "RANK 3\n"); - (void) HDfprintf(sp, "OUTPUT-CLASS IN\n"); - (void) HDfprintf(sp, "OUTPUT-SIZE 16\n"); - (void) HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); - (void) HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); - (void) HDfprintf(sp, "DIMENSION-SIZES 5 3 4\n"); - (void) HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 2 2 2\n"); - (void) HDfprintf(sp, "MAXIMUM-DIMENSIONS -1 -1 -1\n"); - (void) HDfprintf(sp, "COMPRESSION-PARAM 3\n"); - (void) HDfprintf(sp, "\n"); - (void) HDfclose(sp); + (void)HDfprintf(sp, "PATH /int/bin/8-bit\n"); + (void)HDfprintf(sp, "INPUT-CLASS IN\n"); + (void)HDfprintf(sp, "INPUT-SIZE 8\n"); + (void)HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); + (void)HDfprintf(sp, "RANK 3\n"); + (void)HDfprintf(sp, "OUTPUT-CLASS IN\n"); + (void)HDfprintf(sp, "OUTPUT-SIZE 16\n"); + (void)HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); + (void)HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); + (void)HDfprintf(sp, "DIMENSION-SIZES 5 3 4\n"); + (void)HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 2 2 2\n"); + (void)HDfprintf(sp, "MAXIMUM-DIMENSIONS -1 -1 -1\n"); + (void)HDfprintf(sp, "COMPRESSION-PARAM 3\n"); + (void)HDfprintf(sp, "\n"); + (void)HDfclose(sp); #endif /* UNICOS */ - /*------------------------------------------------------------------------- - * TOOLTEST binfp64.bin -c binfp64.conf -o binfp64.h5 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * TOOLTEST binfp64.bin -c binfp64.conf -o binfp64.h5 + *------------------------------------------------------------------------- + */ - /* - * binary 64-bit file - rank 2 & 3 - */ + /* + * binary 64-bit file - rank 2 & 3 + */ sp = HDfopen("binfp64.bin", OPEN_FLAGS); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { - for (j = 0; j < ncol; j++) - { - (void) HDfwrite((char *) &b64r3[k][i][j], sizeof(double), 1, sp); + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { + for (j = 0; j < ncol; j++) { + (void)HDfwrite((char *)&b64r3[k][i][j], sizeof(double), 1, sp); } } } - (void) HDfclose(sp); + (void)HDfclose(sp); sp = HDfopen("binfp64.conf", "w"); - (void) HDfprintf(sp, "PATH /fp/bin/64-bit\n"); - (void) HDfprintf(sp, "INPUT-CLASS FP\n"); - (void) HDfprintf(sp, "INPUT-SIZE 64\n"); - (void) HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); - (void) HDfprintf(sp, "RANK 3\n"); - (void) HDfprintf(sp, "OUTPUT-ARCHITECTURE IEEE\n"); - (void) HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); - (void) HDfprintf(sp, "DIMENSION-SIZES 5 3 4\n"); - (void) HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 2 2 2\n"); - (void) HDfprintf(sp, "MAXIMUM-DIMENSIONS -1 6 7\n"); - (void) HDfprintf(sp, "COMPRESSION-PARAM 8\n"); - (void) HDfprintf(sp, "\n"); - (void) HDfclose(sp); - - /*------------------------------------------------------------------------- - * TOOLTEST binin8w.bin -c binin8w.conf -o binin8w.h5 - *------------------------------------------------------------------------- - */ + (void)HDfprintf(sp, "PATH /fp/bin/64-bit\n"); + (void)HDfprintf(sp, "INPUT-CLASS FP\n"); + (void)HDfprintf(sp, "INPUT-SIZE 64\n"); + (void)HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); + (void)HDfprintf(sp, "RANK 3\n"); + (void)HDfprintf(sp, "OUTPUT-ARCHITECTURE IEEE\n"); + (void)HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); + (void)HDfprintf(sp, "DIMENSION-SIZES 5 3 4\n"); + (void)HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 2 2 2\n"); + (void)HDfprintf(sp, "MAXIMUM-DIMENSIONS -1 6 7\n"); + (void)HDfprintf(sp, "COMPRESSION-PARAM 8\n"); + (void)HDfprintf(sp, "\n"); + (void)HDfclose(sp); + + /*------------------------------------------------------------------------- + * TOOLTEST binin8w.bin -c binin8w.conf -o binin8w.h5 + *------------------------------------------------------------------------- + */ { /* test CR+LF (13,10) and EOF (26) in windows */ - char bin8w[4] = {13,10,26,0}; + char bin8w[4] = {13, 10, 26, 0}; sp = HDfopen("binin8w.bin", OPEN_FLAGS); - for (i = 0; i < 4; i++) - { + for (i = 0; i < 4; i++) { char c = bin8w[i]; - if ( HDfwrite( &c, sizeof(char), 1, sp) != 1 ) + if (HDfwrite(&c, sizeof(char), 1, sp) != 1) HDprintf("error writing file\n"); } HDfclose(sp); sp = HDfopen("binin8w.conf", "w"); - (void) HDfprintf(sp, "INPUT-CLASS IN\n"); - (void) HDfprintf(sp, "INPUT-SIZE 8\n"); - (void) HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); - (void) HDfprintf(sp, "RANK 1\n"); - (void) HDfprintf(sp, "OUTPUT-CLASS IN\n"); - (void) HDfprintf(sp, "OUTPUT-SIZE 8\n"); - (void) HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); - (void) HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); - (void) HDfprintf(sp, "DIMENSION-SIZES 4\n"); - (void) HDfprintf(sp, "\n"); - (void) HDfclose(sp); - + (void)HDfprintf(sp, "INPUT-CLASS IN\n"); + (void)HDfprintf(sp, "INPUT-SIZE 8\n"); + (void)HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); + (void)HDfprintf(sp, "RANK 1\n"); + (void)HDfprintf(sp, "OUTPUT-CLASS IN\n"); + (void)HDfprintf(sp, "OUTPUT-SIZE 8\n"); + (void)HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); + (void)HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); + (void)HDfprintf(sp, "DIMENSION-SIZES 4\n"); + (void)HDfprintf(sp, "\n"); + (void)HDfclose(sp); } return (EXIT_SUCCESS); } - diff --git a/tools/test/h5import/h5importtestutil.sh.in b/tools/test/h5import/h5importtestutil.sh.in index 7dff689..0cbc8f1 100644 --- a/tools/test/h5import/h5importtestutil.sh.in +++ b/tools/test/h5import/h5importtestutil.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. # diff --git a/tools/test/h5jam/CMakeLists.txt b/tools/test/h5jam/CMakeLists.txt index 6fdf7b0..9da7080 100644 --- a/tools/test/h5jam/CMakeLists.txt +++ b/tools/test/h5jam/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_TOOLS_TEST_H5JAM C) # -------------------------------------------------------------------- @@ -6,16 +6,23 @@ project (HDF5_TOOLS_TEST_H5JAM C) # -------------------------------------------------------------------- if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) add_executable (h5jamgentest ${HDF5_TOOLS_TEST_H5JAM_SOURCE_DIR}/h5jamgentest.c) - target_include_directories (h5jamgentest PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (h5jamgentest PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h5jamgentest STATIC) target_link_libraries (h5jamgentest PRIVATE ${HDF5_LIB_TARGET}) set_target_properties (h5jamgentest PROPERTIES FOLDER generator/tools) + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5JAM_FORMAT h5jamgentest) + endif () + #add_test (NAME h5jamgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5jamgentest>) endif () add_executable (getub ${HDF5_TOOLS_TEST_H5JAM_SOURCE_DIR}/getub.c) -target_include_directories (getub PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +target_include_directories (getub PRIVATE "${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 (getub STATIC) target_link_libraries (getub PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) @@ -26,7 +33,7 @@ endif () set_target_properties (getub PROPERTIES FOLDER tools) add_executable (tellub ${HDF5_TOOLS_TEST_H5JAM_SOURCE_DIR}/tellub.c) -target_include_directories (tellub PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +target_include_directories (tellub PRIVATE "${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 (tellub STATIC) target_link_libraries (tellub PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) @@ -36,4 +43,14 @@ else () endif () set_target_properties (tellub PROPERTIES FOLDER tools) -include (CMakeTests.cmake) +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5JAM_getub_FORMAT getub) + clang_format (HDF5_TOOLS_TEST_H5JAM_tellub_FORMAT tellub) +endif () + +if (HDF5_TEST_TOOLS AND HDF5_TEST_SERIAL) + include (CMakeTests.cmake) +endif () diff --git a/tools/test/h5jam/CMakeTests.cmake b/tools/test/h5jam/CMakeTests.cmake index f108afc..82d99b7 100644 --- a/tools/test/h5jam/CMakeTests.cmake +++ b/tools/test/h5jam/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. # @@ -47,12 +47,6 @@ ############################################################################## ############################################################################## - if (NOT BUILD_SHARED_LIBS) - set (tgt_ext "") - else () - set (tgt_ext "-shared") - endif () - # ============================================================ # TEST_H5JAM_OUTPUT # For the purpose to verify only output & exitcode from h5jam @@ -60,7 +54,7 @@ macro (TEST_H5JAM_OUTPUT expectfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5JAM-${expectfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5jam${tgt_ext}> ${ARGN}) + add_test (NAME H5JAM-${expectfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5jam${tgt_file_ext}> ${ARGN}) if (${resultcode}) set_tests_properties (H5JAM-${expectfile} PROPERTIES WILL_FAIL "true") endif () @@ -69,7 +63,7 @@ NAME H5JAM-${expectfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5jam${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5jam${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=${expectfile}.out" @@ -89,7 +83,7 @@ macro (TEST_H5UNJAM_OUTPUT expectfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5JAM-UNJAM-${expectfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5unjam${tgt_ext}> ${ARGN}) + add_test (NAME H5JAM-UNJAM-${expectfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5unjam${tgt_file_ext}> ${ARGN}) if (${resultcode}) set_tests_properties (H5JAM-UNJAM-${expectfile} PROPERTIES WILL_FAIL "true") endif () @@ -98,7 +92,7 @@ NAME H5JAM-UNJAM-${expectfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5unjam${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5unjam${tgt_file_ext}>" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=${expectfile}.out" @@ -116,7 +110,7 @@ NAME H5JAM-${testname}-CHECKFILE-H5DMP COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=testfiles/${expected}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=${actual}.new" @@ -130,7 +124,7 @@ NAME H5JAM-${testname}-CHECKFILE-H5DMP_CMP COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=${actual}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=${actual}.out" @@ -165,7 +159,7 @@ COMMAND ${CMAKE_COMMAND} -E remove ${ufile} ) set_tests_properties (H5JAM-${testname}-UNJAM_D-clear-objects PROPERTIES DEPENDS H5JAM-${testname}-UNJAM-clear-objects) - add_test (NAME H5JAM-${testname}-UNJAM COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5unjam${tgt_ext}> -i ${infile} -u ${ufile} -o ${outfile}) + add_test (NAME H5JAM-${testname}-UNJAM COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5unjam${tgt_file_ext}> -i ${infile} -u ${ufile} -o ${outfile}) set_tests_properties (H5JAM-${testname}-UNJAM PROPERTIES DEPENDS H5JAM-${testname}-UNJAM_D-clear-objects) set (compare_test ${ufile}) else () @@ -174,7 +168,7 @@ NAME H5JAM-${testname}-UNJAM COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5unjam${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5unjam${tgt_file_ext}>" -D "TEST_ARGS:STRING=-i;${infile};-o;${outfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=${outfile}.ufile.txt" @@ -185,7 +179,7 @@ set_tests_properties (H5JAM-${testname}-UNJAM PROPERTIES DEPENDS H5JAM-${testname}-UNJAM-clear-objects) set (compare_test "${outfile}.ufile.txt") else () - add_test (NAME H5JAM-${testname}-UNJAM COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5unjam${tgt_ext}> -i ${infile} -o ${outfile}) + add_test (NAME H5JAM-${testname}-UNJAM COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5unjam${tgt_file_ext}> -i ${infile} -o ${outfile}) set_tests_properties (H5JAM-${testname}-UNJAM PROPERTIES DEPENDS H5JAM-${testname}-UNJAM-clear-objects) set (compare_test "") endif () @@ -247,7 +241,7 @@ COMMAND ${CMAKE_COMMAND} -E remove ${outfile} ${infile}.cpy.h5 ) endif () - add_test (NAME H5JAM-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5jam${tgt_ext}> -u testfiles/${jamfile} -i testfiles/${infile} -o ${outfile} ${ARGN}) + add_test (NAME H5JAM-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5jam${tgt_file_ext}> -u testfiles/${jamfile} -i testfiles/${infile} -o ${outfile} ${ARGN}) if (NOT HDF5_ENABLE_USING_MEMCHECKER) set_tests_properties (H5JAM-${testname} PROPERTIES DEPENDS H5JAM-${testname}-clear-objects) set (compare_test ${outfile}) @@ -302,7 +296,7 @@ ) set_tests_properties (H5JAM-${testname}_NONE_COPY PROPERTIES DEPENDS H5JAM-${testname}_NONE-SETUP) - add_test (NAME H5JAM-${testname}_NONE COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5jam${tgt_ext}> -u testfiles/${jamfile} -i ${chkfile} ${ARGN}) + add_test (NAME H5JAM-${testname}_NONE COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5jam${tgt_file_ext}> -u testfiles/${jamfile} -i ${chkfile} ${ARGN}) set_tests_properties (H5JAM-${testname}_NONE PROPERTIES DEPENDS H5JAM-${testname}_NONE_COPY) set (compare_test ${chkfile}) diff --git a/tools/test/h5jam/Makefile.am b/tools/test/h5jam/Makefile.am index c07aeb2..bbbdf7d 100644 --- a/tools/test/h5jam/Makefile.am +++ b/tools/test/h5jam/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. ## diff --git a/tools/test/h5jam/getub.c b/tools/test/h5jam/getub.c index 26a427d..4e67e98 100644 --- a/tools/test/h5jam/getub.c +++ b/tools/test/h5jam/getub.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 "h5tools.h" #include "h5tools_utils.h" -void parse_command_line(int argc, const char *argv[]); +void parse_command_line(int argc, const char *const *argv); /* Name of tool */ #define PROGRAM_NAME "getub" char *nbytes = NULL; -static const char *s_opts = "c:"; /* add more later ? */ -static struct long_options l_opts[] = { - {"c", require_arg, 'c'}, /* input file */ - {NULL, 0, '\0'} -}; +static const char * s_opts = "c:"; /* add more later ? */ +static struct h5_long_options l_opts[] = {{"c", require_arg, 'c'}, /* input file */ + {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: usage @@ -36,7 +34,7 @@ static struct long_options l_opts[] = { *------------------------------------------------------------------------- */ static void -usage (const char *prog) +usage(const char *prog) { HDfflush(stdout); HDfprintf(stdout, "usage: %s -c nb file] \n", prog); @@ -54,38 +52,38 @@ usage (const char *prog) *------------------------------------------------------------------------- */ void -parse_command_line(int argc, const char *argv[]) +parse_command_line(int argc, const char *const *argv) { int opt; /* parse command line options */ - while((opt = get_option (argc, argv, s_opts, l_opts)) != EOF) { - switch((char) opt) { - case 'c': - nbytes = HDstrdup(opt_arg); - break; - case '?': - default: - usage(h5tools_getprogname()); - HDexit(EXIT_FAILURE); + while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) { + switch ((char)opt) { + case 'c': + nbytes = HDstrdup(H5_optarg); + break; + case '?': + default: + usage(h5tools_getprogname()); + HDexit(EXIT_FAILURE); } /* end switch */ - } /* end while */ + } /* end while */ - if(argc <= opt_ind) { - error_msg("missing file name\n"); - usage(h5tools_getprogname()); - HDexit(EXIT_FAILURE); + if (argc <= H5_optind) { + error_msg("missing file name\n"); + usage(h5tools_getprogname()); + HDexit(EXIT_FAILURE); } /* end if */ } /* end parse_command_line() */ int -main(int argc, const char *argv[]) +main(int argc, char *argv[]) { - int fd = -1; + int fd = H5I_INVALID_HID; unsigned size; - char *filename = NULL; - long res; - char *buf = NULL; + char * filename = NULL; + long res; + char * buf = NULL; h5tools_setprogname(PROGRAM_NAME); h5tools_setstatus(EXIT_SUCCESS); @@ -93,63 +91,63 @@ main(int argc, const char *argv[]) /* Initialize h5tools lib */ h5tools_init(); - parse_command_line(argc, argv); + parse_command_line(argc, (const char *const *)argv); - if(NULL == nbytes) { + if (NULL == nbytes) { /* missing arg */ error_msg("missing size\n"); usage(h5tools_getprogname()); goto error; } /* end if */ - if(argc <= (opt_ind)) { + if (argc <= (H5_optind)) { error_msg("missing file name\n"); usage(h5tools_getprogname()); goto error; } /* end if */ - filename = HDstrdup(argv[opt_ind]); + filename = HDstrdup(argv[H5_optind]); size = 0; - if(EOF == (res = sscanf(nbytes, "%u", &size))) { - /* fail */ - error_msg("missing file name\n"); - usage(h5tools_getprogname()); - goto error; + if (EOF == (res = HDsscanf(nbytes, "%u", &size))) { + /* fail */ + error_msg("missing file name\n"); + usage(h5tools_getprogname()); + goto error; } /* end if */ - if((fd = HDopen(filename, O_RDONLY, 0)) < 0) { + if ((fd = HDopen(filename, O_RDONLY, 0)) < 0) { error_msg("can't open file %s\n", filename); goto error; } /* end if */ - if(NULL == (buf = (char *)HDmalloc((unsigned)(size + 1)))) { + if (NULL == (buf = (char *)HDmalloc((unsigned)(size + 1)))) { error_msg("can't allocate buffer \n"); goto error; } /* end if */ res = HDread(fd, buf, (unsigned)size); - if(res < (long)size) { + if (res < (long)size) { error_msg("Bad read \n"); goto error; } /* end if */ - if(HDwrite(1, buf, (unsigned)size) < 0) { + if (HDwrite(1, buf, (unsigned)size) < 0) { error_msg("Bad write \n"); goto error; } /* end if */ /* close things and exit */ + HDfree(filename); HDfree(buf); HDclose(fd); return EXIT_SUCCESS; error: - if(buf) - HDfree(buf); - if(fd >= 0) + HDfree(filename); + HDfree(buf); + if (fd >= 0) HDclose(fd); return EXIT_FAILURE; } /* end main() */ - diff --git a/tools/test/h5jam/h5jamgentest.c b/tools/test/h5jam/h5jamgentest.c index 56b4ead..5632cc0 100644 --- a/tools/test/h5jam/h5jamgentest.c +++ b/tools/test/h5jam/h5jamgentest.c @@ -1,4 +1,4 @@ - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * @@ -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,24 +31,7 @@ #define UBTXT3 "u511.txt" #define UBTXT4 "u512.txt" #define UBTXT5 "u513.txt" -/* not used yet -#define UBTXT6 "u1023.txt" -#define UBTXT7 "u1024.txt" -#define UBTXT8 "u1025.txt" -#define UBTXT9 "u2047.txt" -#define UBTXT10 "u2048.txt" -#define UBTXT11 "u2049.txt" -#define UBBIN1 "u0.dat" -#define UBBIN2 "u10.dat" -#define UBBIN3 "u511.dat" -#define UBBIN4 "u512.dat" -#define UBBIN5 "u513.dat" -*/ -/* not used yet -#define FILE1 "tnull.h5" -#define FILE2 "tnullwithub.h5" -*/ /* tall is same as dumper test */ #define FILE7 "tall.h5" #define FILE8 "twithub.h5" @@ -64,33 +47,15 @@ char pattern[11] = "abcdefghij"; *------------------------------------------------------------------------- */ - #define BUF_SIZE 1024 -/* Element selection information */ - -typedef enum{ - RED, - GREEN, - BLUE, - WHITE, - BLACK -} enumtype; - -/* Compound datatype */ -typedef struct s1_t { - unsigned int a; - unsigned int b; - float c; -} s1_t; - - /* A UD link traversal function. Shouldn't actually be called. */ -static hid_t UD_traverse(const char H5_ATTR_UNUSED * link_name, hid_t H5_ATTR_UNUSED cur_group, - const void H5_ATTR_UNUSED * udata, size_t H5_ATTR_UNUSED udata_size, hid_t H5_ATTR_UNUSED lapl_id, - hid_t H5_ATTR_UNUSED dxpl_id) +static hid_t +UD_traverse(const char H5_ATTR_UNUSED *link_name, hid_t H5_ATTR_UNUSED cur_group, + const void H5_ATTR_UNUSED *udata, size_t H5_ATTR_UNUSED udata_size, hid_t H5_ATTR_UNUSED lapl_id, + hid_t H5_ATTR_UNUSED dxpl_id) { - return -1; + return H5I_INVALID_HID; } #define MY_LINKCLASS 187 @@ -106,8 +71,6 @@ const H5L_class_t UD_link_class[1] = {{ NULL /* Query callback */ }}; - - /* gent_ub with no ub, identical to gent_all from h5dumpgentest.c @@ -124,257 +87,340 @@ g1.2.1 : slink g2 : dset2.1 dset2.2 udlink */ - -static void -gent_ub(const char * filename, size_t ub_size, size_t ub_fill) +static herr_t +gent_ub(const char *filename, size_t ub_size, size_t ub_fill) { - hid_t fid, group, attr, dataset, space; - hid_t create_plist; + hid_t fid = H5I_INVALID_HID; + hid_t group = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t create_plist = H5I_INVALID_HID; hsize_t dims[2]; - int data[2][2], dset1[10][10], dset2[20]; - char buf[BUF_SIZE]; - int i, j; - size_t u; - float dset2_1[10], dset2_2[3][5]; - int fd; - char *bp; - - if(ub_size > 0) - { - create_plist = H5Pcreate(H5P_FILE_CREATE); - H5Pset_userblock(create_plist, (hsize_t)ub_size); - fid = H5Fcreate(filename, H5F_ACC_TRUNC, create_plist, H5P_DEFAULT); - } - else - { - fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - } - - /* create groups */ - group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g1/g1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g1/g1.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g1/g1.2/g1.2.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - /* root attributes */ - group = H5Gopen2(fid, "/", H5P_DEFAULT); - - dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(group, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); - HDsprintf(buf, "abcdefghi"); - H5Awrite(attr, H5T_NATIVE_SCHAR, buf); - H5Sclose(space); - H5Aclose(attr); - - dims[0] = 2; dims[1] = 2; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(group, "attr2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); - data[0][0] = 0; data[0][1] = 1; data[1][0] = 2; data[1][1] = 3; - H5Awrite(attr, H5T_NATIVE_INT, data); - H5Sclose(space); - H5Aclose(attr); - - H5Gclose(group); - - group = H5Gopen2(fid, "/g1/g1.1", H5P_DEFAULT); - - /* dset1.1.1 */ - dims[0] = 10; dims[1] = 10; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(group, "dset1.1.1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) - dset1[i][j] = j*i; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); - H5Sclose(space); - - /* attributes of dset1.1.1 */ - dims[0] = 27; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); - HDsprintf(buf, "1st attribute of dset1.1.1"); - H5Awrite(attr, H5T_NATIVE_SCHAR, buf); - H5Sclose(space); - H5Aclose(attr); - - dims[0] = 27; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr2", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); - HDsprintf(buf, "2nd attribute of dset1.1.1"); - H5Awrite(attr, H5T_NATIVE_SCHAR, buf); - H5Sclose(space); - H5Aclose(attr); - - H5Dclose(dataset); - - /* dset1.1.2 */ - dims[0] = 20; - space = H5Screate_simple(1, dims, NULL); - dataset = H5Dcreate2(group, "dset1.1.2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for (i = 0; i < 20; i++) - dset2[i] = i; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); - H5Sclose(space); - H5Dclose(dataset); - - H5Gclose(group); - - /* external link */ - H5Lcreate_external("somefile", "somepath", fid, "/g1/g1.2/extlink", H5P_DEFAULT, H5P_DEFAULT); - - /* soft link */ - group = H5Gopen2(fid, "/g1/g1.2/g1.2.1", H5P_DEFAULT); - H5Lcreate_soft("somevalue", group, "slink", H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gopen2(fid, "/g2", H5P_DEFAULT); - - /* dset2.1 */ - dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); - dataset = H5Dcreate2(group, "dset2.1", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for (i = 0; i < 10; i++) - dset2_1[i] = (float)((float)i * 0.1F + 1.0F); - H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_1); - H5Sclose(space); - H5Dclose(dataset); - - /* dset2.2 */ - dims[0] = 3; dims[1] = 5; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(group, "dset2.2", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for (i = 0; i < 3; i++) - for (j = 0; j < 5; j++) + int data[2][2], dset1[10][10], dset2[20]; + char buf[BUF_SIZE]; + int i, j; + size_t u; + float dset2_1[10], dset2_2[3][5]; + int fd = -1; + + if (ub_size > 0) { + if ((create_plist = H5Pcreate(H5P_FILE_CREATE)) < 0) + goto error; + if (H5Pset_userblock(create_plist, (hsize_t)ub_size) < 0) + goto error; + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, create_plist, H5P_DEFAULT)) < 0) + goto error; + } + else { + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + } + + /* Create groups */ + if ((group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (H5Gclose(group) < 0) + goto error; + + if ((group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (H5Gclose(group) < 0) + goto error; + + if ((group = H5Gcreate2(fid, "/g1/g1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (H5Gclose(group) < 0) + goto error; + + if ((group = H5Gcreate2(fid, "/g1/g1.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (H5Gclose(group) < 0) + goto error; + + if ((group = H5Gcreate2(fid, "/g1/g1.2/g1.2.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (H5Gclose(group) < 0) + goto error; + + /* Root attributes */ + if ((group = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + goto error; + + dims[0] = 10; + if ((space = H5Screate_simple(1, dims, NULL)) < 0) + goto error; + if ((attr = H5Acreate2(group, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (HDsprintf(buf, "abcdefghi") < 0) + goto error; + if (H5Awrite(attr, H5T_NATIVE_SCHAR, buf) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Aclose(attr) < 0) + goto error; + + dims[0] = 2; + dims[1] = 2; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + goto error; + if ((attr = H5Acreate2(group, "attr2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + data[0][0] = 0; + data[0][1] = 1; + data[1][0] = 2; + data[1][1] = 3; + if (H5Awrite(attr, H5T_NATIVE_INT, data) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Aclose(attr) < 0) + goto error; + + if (H5Gclose(group) < 0) + goto error; + + if ((group = H5Gopen2(fid, "/g1/g1.1", H5P_DEFAULT)) < 0) + goto error; + + /* Dataset 1.1.1 */ + dims[0] = 10; + dims[1] = 10; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + goto error; + if ((dataset = + H5Dcreate2(group, "dset1.1.1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + dset1[i][j] = j * i; + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + + /* Attributes of dset1.1.1 */ + dims[0] = 27; + if ((space = H5Screate_simple(1, dims, NULL)) < 0) + goto error; + if ((attr = H5Acreate2(dataset, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (HDsprintf(buf, "1st attribute of dset1.1.1") < 0) + goto error; + if (H5Awrite(attr, H5T_NATIVE_SCHAR, buf) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Aclose(attr) < 0) + goto error; + + dims[0] = 27; + if ((space = H5Screate_simple(1, dims, NULL)) < 0) + goto error; + if ((attr = H5Acreate2(dataset, "attr2", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (HDsprintf(buf, "2nd attribute of dset1.1.1") < 0) + goto error; + if (H5Awrite(attr, H5T_NATIVE_SCHAR, buf) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Aclose(attr) < 0) + goto error; + + if (H5Dclose(dataset) < 0) + goto error; + + /* Dataset 1.1.2 */ + dims[0] = 20; + if ((space = H5Screate_simple(1, dims, NULL)) < 0) + goto error; + if ((dataset = + H5Dcreate2(group, "dset1.1.2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + for (i = 0; i < 20; i++) + dset2[i] = i; + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Dclose(dataset) < 0) + goto error; + + if (H5Gclose(group) < 0) + goto error; + + /* External link */ + if (H5Lcreate_external("somefile", "somepath", fid, "/g1/g1.2/extlink", H5P_DEFAULT, H5P_DEFAULT) < 0) + goto error; + + /* Soft link */ + if ((group = H5Gopen2(fid, "/g1/g1.2/g1.2.1", H5P_DEFAULT)) < 0) + goto error; + if (H5Lcreate_soft("somevalue", group, "slink", H5P_DEFAULT, H5P_DEFAULT) < 0) + goto error; + if (H5Gclose(group) < 0) + goto error; + + if ((group = H5Gopen2(fid, "/g2", H5P_DEFAULT)) < 0) + goto error; + + /* Dataset 2.1 */ + dims[0] = 10; + if ((space = H5Screate_simple(1, dims, NULL)) < 0) + goto error; + if ((dataset = + H5Dcreate2(group, "dset2.1", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + for (i = 0; i < 10; i++) + dset2_1[i] = (float)((float)i * 0.1F + 1.0F); + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_1) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Dclose(dataset) < 0) + goto error; + + /* Dataset 2.2 */ + dims[0] = 3; + dims[1] = 5; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + goto error; + if ((dataset = + H5Dcreate2(group, "dset2.2", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + for (i = 0; i < 3; i++) + for (j = 0; j < 5; j++) dset2_2[i][j] = (float)(((float)i + 1.0F) * (float)j * 0.1F); - H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_2); - H5Sclose(space); - H5Dclose(dataset); - - H5Gclose(group); - - /* user-defined link */ - H5Lregister(UD_link_class); - H5Lcreate_ud(fid, "/g2/udlink", (H5L_type_t)MY_LINKCLASS, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT); - - H5Fclose(fid); - - /* If a user block is being used, write to it here */ - if(ub_size > 0) { - HDassert(ub_size <= BUF_SIZE); - - fd = HDopen(filename, O_RDWR); - HDassert(fd >= 0); - - /* fill buf with pattern */ - HDmemset(buf, '\0', ub_size); - bp = buf; - for (u = 0; u < ub_fill; u++) - *bp++ = pattern[u % 10]; - - HDwrite(fd, buf, ub_size); - - HDclose(fd); - } + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_2) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Dclose(dataset) < 0) + goto error; + + if (H5Gclose(group) < 0) + goto error; + + /* User-defined link */ + if (H5Lregister(UD_link_class) < 0) + goto error; + if (H5Lcreate_ud(fid, "/g2/udlink", (H5L_type_t)MY_LINKCLASS, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) < + 0) + goto error; + + /* MUST close the file ID before the user block code or you risk tripping + * over file locking issues. + */ + if (H5Fclose(fid) < 0) + goto error; + + /* If a user block is being used, write to it here */ + if (ub_size > 0) { + char *bp; + + if (ub_size > BUF_SIZE) + goto error; + + if ((fd = HDopen(filename, O_RDWR)) < 0) + goto error; + + /* Fill buf with pattern */ + HDmemset(buf, '\0', ub_size); + bp = buf; + for (u = 0; u < ub_fill; u++) + *bp++ = pattern[u % 10]; + + if (HDwrite(fd, buf, ub_size) < 0) + goto error; + + if (HDclose(fd) < 0) + goto error; + } + + return SUCCEED; + +error: + if (fd >= 0) + HDclose(fd); + + H5E_BEGIN_TRY + { + H5Fclose(fid); + H5Gclose(group); + H5Aclose(attr); + H5Dclose(dataset); + H5Sclose(space); + H5Pclose(create_plist); + } + H5E_END_TRY; + + return FAIL; } -static void +/* Creates a simple (i.e., not HDF5) text file and fills it with a pattern */ +static herr_t create_textfile(const char *name, size_t size) { - char *buf; - int fd; + char * buf = NULL; + int fd = -1; size_t i; - char *bp; + char * bp = NULL; - fd = HDcreat(name,0777); - HDassert(fd >= 0); - buf = (char *)HDcalloc(size, (size_t)1); - HDassert(buf); + if ((fd = HDcreat(name, 0777)) < 0) + goto error; + if (NULL == (buf = (char *)HDcalloc(size, 1))) + goto error; - /* fill buf with pattern */ + /* Fill buf with pattern */ bp = buf; - for(i = 0; i < size; i++) + for (i = 0; i < size; i++) *bp++ = pattern[i % 10]; - HDwrite(fd, buf, size); + if (HDwrite(fd, buf, size) < 0) + goto error; HDfree(buf); - HDclose(fd); -} - -#ifdef notdef -/* not used yet */ -void -create_binfile(char *name, off_t size) -{ - char *buf; - int fd; - int i; - char *bp; - fd = creat(name,0777); - HDassert(fd >= 0); + return SUCCEED; - buf = HDcalloc(size,1); - HDassert(buf); - - /* fill buf with pattern */ - bp = buf; - for (i = 0; i < size; i++) - *bp++ = (char) i & 0xff; - - HDwrite(fd,buf,size); +error: + HDfree(buf); + if (fd >= 0) + HDclose(fd); - HDclose(fd); + return FAIL; } -#endif /*------------------------------------------------------------------------- * Function: main * *------------------------------------------------------------------------- */ - - -int main(void) +int +main(void) { - -/* -create_textfile(UBTXT1, (size_t)0); -*/ -create_textfile(UBTXT2, (size_t)10); -create_textfile(UBTXT3, (size_t)511); -create_textfile(UBTXT4, (size_t)512); -create_textfile(UBTXT5, (size_t)513); -/* -create_textfile(UBTXT6, (size_t)1023); -create_textfile(UBTXT7, (size_t)1024); -create_textfile(UBTXT8, (size_t)1025); -create_textfile(UBTXT9, (size_t)2047); -create_textfile(UBTXT10, (size_t)2048); -create_textfile(UBTXT11, (size_t)2049); - -create_binfile(UBBIN1, (off_t)0); -create_binfile(UBBIN2, (off_t)10); -create_binfile(UBBIN3, (off_t)511); -create_binfile(UBBIN4, (off_t)512); -create_binfile(UBBIN5, (off_t)513); - -*/ - gent_ub(FILE7, (size_t)0, (size_t)0); - gent_ub(FILE8, (size_t)512, HDstrlen(pattern)); - gent_ub(FILE9, (size_t)1024, (size_t)513); - - return 0; + if (create_textfile(UBTXT2, 10) < 0) + goto error; + if (create_textfile(UBTXT3, 511) < 0) + goto error; + if (create_textfile(UBTXT4, 512) < 0) + goto error; + if (create_textfile(UBTXT5, 513) < 0) + goto error; + + if (gent_ub(FILE7, 0, 0) < 0) + goto error; + if (gent_ub(FILE8, 512, HDstrlen(pattern)) < 0) + goto error; + if (gent_ub(FILE9, 1024, 513) < 0) + goto error; + + return EXIT_SUCCESS; + +error: + HDfprintf(stderr, "h5jam test generator FAILED\n"); + return EXIT_FAILURE; } diff --git a/tools/test/h5jam/tellub.c b/tools/test/h5jam/tellub.c index 559c677..f264d9b 100644 --- a/tools/test/h5jam/tellub.c +++ b/tools/test/h5jam/tellub.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,12 +24,8 @@ * parameters. The long-named ones can be partially spelled. When * adding more, make sure that they don't clash with each other. */ -static const char *s_opts = "h"; -static struct long_options l_opts[] = { - {"help", no_arg, 'h'}, - {"hel", no_arg, 'h'}, - {NULL, 0, '\0'} -}; +static const char * s_opts = "h"; +static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'}, {"hel", no_arg, 'h'}, {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: usage @@ -40,12 +36,11 @@ static struct long_options l_opts[] = { *------------------------------------------------------------------------- */ static void -usage (const char *prog) +usage(const char *prog) { HDfflush(stdout); HDfprintf(stdout, "usage: %s h5_file\n", prog); - HDfprintf(stdout, - " Check that h5_fil is HDF5 file and print size of user block \n"); + HDfprintf(stdout, " Check that h5_fil is HDF5 file and print size of user block \n"); HDfprintf(stdout, " %s -h\n", prog); HDfprintf(stdout, " Print a usage message and exit\n"); } /* end usage() */ @@ -61,31 +56,39 @@ usage (const char *prog) */ static void -parse_command_line (int argc, const char *argv[]) +parse_command_line(int argc, const char *const *argv) { int opt; /* parse command line options */ - while ((opt = get_option (argc, argv, s_opts, l_opts)) != EOF) { - switch ((char) opt) { + while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) { + switch ((char)opt) { case 'h': - usage (h5tools_getprogname()); - HDexit(EXIT_SUCCESS); + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_SUCCESS); + break; case '?': default: - usage (h5tools_getprogname()); - HDexit(EXIT_FAILURE); + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); } } /* check for file name to be processed */ - if (argc <= opt_ind) { + if (argc <= H5_optind) { error_msg("missing file name\n"); - usage (h5tools_getprogname()); - HDexit(EXIT_FAILURE); + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); } } /* end parse_command_line() */ +static void +leave(int ret) +{ + h5tools_close(); + HDexit(ret); +} + /*------------------------------------------------------------------------- * Function: main * @@ -95,16 +98,14 @@ parse_command_line (int argc, const char *argv[]) *------------------------------------------------------------------------- */ int -main (int argc, const char *argv[]) +main(int argc, char *argv[]) { - char *ifname; - void *edata; - H5E_auto2_t func; - hid_t ifile; + char * ifname; + hid_t ifile = H5I_INVALID_HID; hsize_t usize; - htri_t testval; - herr_t status; - hid_t plist = H5I_INVALID_HID; + htri_t testval; + herr_t status; + hid_t plist = H5I_INVALID_HID; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -112,51 +113,56 @@ main (int argc, const char *argv[]) /* Initialize h5tools lib */ h5tools_init(); - /* Disable error reporting */ - H5Eget_auto2(H5E_DEFAULT, &func, &edata); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + parse_command_line(argc, (const char *const *)argv); - parse_command_line(argc, argv); + /* enable error reporting if command line option */ + h5tools_error_report(); - if(argc <= (opt_ind)) { + if (argc <= (H5_optind)) { error_msg("missing file name\n"); - usage (h5tools_getprogname()); - return EXIT_FAILURE; + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); + goto done; } - ifname = HDstrdup(argv[opt_ind]); + ifname = HDstrdup(argv[H5_optind]); testval = H5Fis_accessible(ifname, H5P_DEFAULT); - if(testval <= 0) { + if (testval <= 0) { error_msg("Input HDF5 file is not HDF \"%s\"\n", ifname); - return EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); + goto done; } ifile = H5Fopen(ifname, H5F_ACC_RDONLY, H5P_DEFAULT); - if(ifile < 0) { + if (ifile < 0) { error_msg("Can't open input HDF5 file \"%s\"\n", ifname); - return EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); + goto done; } plist = H5Fget_create_plist(ifile); - if(plist < 0) { + if (plist < 0) { error_msg("Can't get file creation plist for file \"%s\"\n", ifname); - return EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); + goto done; } status = H5Pget_userblock(plist, &usize); - if(status < 0) { + if (status < 0) { error_msg("Can't get user block for file \"%s\"\n", ifname); - return EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); + goto done; } - HDprintf("%ld\n", (long) usize); + HDprintf("%ld\n", (long)usize); - H5Pclose (plist); - H5Fclose (ifile); +done: + H5Pclose(plist); + if (ifile >= 0) + H5Fclose(ifile); - return EXIT_SUCCESS; + leave(h5tools_getstatus()); } /* end main() */ - diff --git a/tools/test/h5jam/testh5jam.sh.in b/tools/test/h5jam/testh5jam.sh.in index 3ae180b..191fef0 100644 --- a/tools/test/h5jam/testh5jam.sh.in +++ b/tools/test/h5jam/testh5jam.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. # @@ -345,7 +345,7 @@ CHECK_NOUB() { # JAMTEST user_block file.h5 [--clobber] [ofile.h5] # # Test the 'jam' tool: -# 1. figure out the input and output, and the comparision +# 1. figure out the input and output, and the comparison # that will be done. # 2. call 'jam' with the appropriate arguments # 3. check the user block is correct in the output (Check_UB) @@ -474,9 +474,9 @@ UNJAMTEST () { # TOOLTEST_OUTPUT() { - if [ "$1" == "JAM" ]; then + if [ "$1" = "JAM" ]; then TOOLCMD=$JAM_BIN/$JAM - elif [ "$1" == "UNJAM" ]; then + elif [ "$1" = "UNJAM" ]; then TOOLCMD=$JAM_BIN/$UNJAM fi shift diff --git a/tools/test/h5ls/CMakeLists.txt b/tools/test/h5ls/CMakeLists.txt index 0da03c5..ba6e468 100644 --- a/tools/test/h5ls/CMakeLists.txt +++ b/tools/test/h5ls/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_TOOLS_TEST_H5LS C) #----------------------------------------------------------------------------- @@ -10,13 +10,21 @@ if (BUILD_SHARED_LIBS) set (H5LS_TOOL_PLUGIN_LIB_TARGET ${H5LS_TOOL_PLUGIN_LIB_CORENAME}) add_library (${H5LS_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_ls.c) - target_include_directories (${H5LS_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (${H5LS_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (${H5LS_TOOL_PLUGIN_LIB_TARGET} SHARED) - target_link_libraries (${H5LS_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIBSH_TARGET}) + target_link_libraries (${H5LS_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_LIBSH_TARGET}) H5_SET_LIB_OPTIONS (${H5LS_TOOL_PLUGIN_LIB_TARGET} ${H5LS_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5LS_PLUGIN_FORMAT ${H5LS_TOOL_PLUGIN_LIB_TARGET}) + endif () + # make plugins dir file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") + #----------------------------------------------------------------------------- # Copy plugin library to a plugins folder #----------------------------------------------------------------------------- @@ -30,6 +38,8 @@ if (BUILD_SHARED_LIBS) ) endif () -include (CMakeTests.cmake) +if (HDF5_TEST_TOOLS AND HDF5_TEST_SERIAL) + include (CMakeTests.cmake) -include (CMakeTestsVDS.cmake) + include (CMakeTestsVDS.cmake) +endif () diff --git a/tools/test/h5ls/CMakeTests.cmake b/tools/test/h5ls/CMakeTests.cmake index 2f3f3ab..cd2f764 100644 --- a/tools/test/h5ls/CMakeTests.cmake +++ b/tools/test/h5ls/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. # @@ -134,18 +134,12 @@ ############################################################################## ############################################################################## - if (NOT BUILD_SHARED_LIBS) - set (tgt_ext "") - else () - set (tgt_ext "-shared") - endif () - macro (ADD_H5_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5LS-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5ls${tgt_ext}> ${ARGN}) + add_test (NAME H5LS-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5ls${tgt_file_ext}> ${ARGN}) set_tests_properties (H5LS-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (${resultcode} EQUAL 1) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5LS-${resultfile} PROPERTIES WILL_FAIL "true") endif () else () @@ -154,7 +148,7 @@ NAME H5LS-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5ls${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5ls${tgt_file_ext}>" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${resultfile}.out" @@ -168,9 +162,9 @@ macro (ADD_H5_ERR_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5LS-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5ls> ${ARGN}) + add_test (NAME H5LS-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5ls${tgt_file_ext}> ${ARGN}) set_tests_properties (H5LS-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (${resultcode} EQUAL 1) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5LS-${resultfile} PROPERTIES WILL_FAIL "true") endif () else () @@ -178,7 +172,7 @@ NAME H5LS-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5ls${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5ls${tgt_file_ext}>" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${resultfile}.out" @@ -196,7 +190,7 @@ NAME H5LS_UD-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5ls${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5ls${tgt_file_ext}>" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${resultfile}.out" diff --git a/tools/test/h5ls/CMakeTestsVDS.cmake b/tools/test/h5ls/CMakeTestsVDS.cmake index cf5b6d7..e93e7e7 100644 --- a/tools/test/h5ls/CMakeTestsVDS.cmake +++ b/tools/test/h5ls/CMakeTestsVDS.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. # @@ -80,18 +80,12 @@ ############################################################################## ############################################################################## - if (NOT BUILD_SHARED_LIBS) - set (tgt_ext "") - else () - set (tgt_ext "-shared") - endif () - macro (ADD_H5_VDS_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5LS-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5ls${tgt_ext}> ${ARGN}) + add_test (NAME H5LS-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5ls${tgt_file_ext}> ${ARGN}) set_tests_properties (H5LS-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds") - if (${resultcode} EQUAL 1) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5LS-${resultfile} PROPERTIES WILL_FAIL "true") endif () else () @@ -99,7 +93,7 @@ NAME H5LS-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5ls${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5ls${tgt_file_ext}>" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/vds" -D "TEST_OUTPUT=${resultfile}.out" @@ -113,12 +107,12 @@ macro (ADD_H5_VDS_PREFIX_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5LS_PREFIX-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5ls${tgt_ext}> ${ARGN}) + add_test (NAME H5LS_PREFIX-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5ls${tgt_file_ext}> ${ARGN}) set_tests_properties (H5LS_PREFIX-${resultfile} PROPERTIES ENVIRONMENT "HDF5_VDS_PREFIX=\${ORIGIN}" WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" ) - if (${resultcode} EQUAL 1) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5LS_PREFIX-${resultfile} PROPERTIES WILL_FAIL "true") endif () else () @@ -126,7 +120,7 @@ NAME H5LS_PREFIX-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5ls${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5ls${tgt_file_ext}>" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=vds/prefix/${resultfile}.out" diff --git a/tools/test/h5ls/Makefile.am b/tools/test/h5ls/Makefile.am index f5ec0f7..7e7b8b8 100644 --- a/tools/test/h5ls/Makefile.am +++ b/tools/test/h5ls/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. ## diff --git a/tools/test/h5ls/dynlib_ls.c b/tools/test/h5ls/dynlib_ls.c index 571452e..433522d 100644 --- a/tools/test/h5ls/dynlib_ls.c +++ b/tools/test/h5ls/dynlib_ls.c @@ -5,7 +5,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,25 +17,33 @@ #include <stdio.h> #include "H5PLextern.h" -#define H5Z_FILTER_DYNLIBUD 300 -#define MULTIPLIER 3 +#define H5Z_FILTER_DYNLIBUD 300 +#define MULTIPLIER 3 -static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_DYNLIBUD[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_DYNLIBUD, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "dynlibud", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_DYNLIBUD, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "dynlibud", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + H5Z_filter_dynlibud, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_FILTER; +} +const void * +H5PLget_plugin_info(void) +{ + return H5Z_DYNLIBUD; +} /*------------------------------------------------------------------------- * Function: H5Z_filter_dynlibud @@ -51,39 +59,37 @@ const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} *------------------------------------------------------------------------- */ static size_t -H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) { - char *int_ptr = (char *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + char * int_ptr = (char *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ /* Check for the correct number of parameters */ - if(cd_nelmts > 0) - return(0); + if (cd_nelmts > 0) + return (0); /* Assignment to eliminate unused parameter warning. */ - cd_values = cd_values; + (void)cd_values; - if(flags & H5Z_FLAG_REVERSE) { /*read*/ + if (flags & H5Z_FLAG_REVERSE) { /*read*/ /* Subtract the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = temp - MULTIPLIER; + *int_ptr = (int8_t)(temp - MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ else { /*write*/ /* Add the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = temp + MULTIPLIER; + *int_ptr = (int8_t)(temp + MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); } /* end while */ - } /* end else */ + } /* end else */ return nbytes; } /* end H5Z_filter_dynlibud() */ - diff --git a/tools/test/h5ls/h5ls_plugin.sh.in b/tools/test/h5ls/h5ls_plugin.sh.in index c89269d..0077b07 100644 --- a/tools/test/h5ls/h5ls_plugin.sh.in +++ b/tools/test/h5ls/h5ls_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. # @@ -139,8 +139,8 @@ CLEAN_TESTFILES_AND_TESTDIR() # Print a $* message left justified in a field of 70 characters # MESSAGE() { - SPACES=" " - echo "$* $SPACES" | cut -c1-70 | tr -d '\012' + SPACES=" " + echo "$* $SPACES" | cut -c1-70 | tr -d '\012' } # Print a line-line message left justified in a field of 70 characters @@ -166,7 +166,7 @@ VERIFY() { # the `nerrors' global variable and (if $verbose is set) display up to $NLINS # lines of the actual output from the tool test. The actual output is not # removed if $HDF5_NOCLEANUP has a non-zero value. -# Arguemnts: +# Arguments: # $1 -- actual output filename to use # $2 and on -- argument for the h5ls tool TOOLTEST() { @@ -206,7 +206,7 @@ TOOLTEST() { echo "" fi elif [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. + # Create the expect file if it doesn't yet exist. echo " CREATED" cp $actual $expect echo " Expected result (*.ls) missing" diff --git a/tools/test/h5ls/testh5ls.sh.in b/tools/test/h5ls/testh5ls.sh.in index 353f1bb..36583da 100644 --- a/tools/test/h5ls/testh5ls.sh.in +++ b/tools/test/h5ls/testh5ls.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. # @@ -164,7 +164,7 @@ $SRC_H5LS_TESTFILES/tdset_idx.ls # RUNSERIAL is used. Check if it can return exit code from executalbe correctly. if [ -n "$RUNSERIAL_NOEXITCODE" ]; then - echo "***Warning*** Serial Exit Code is not passed back to shell corretly." + echo "***Warning*** Serial Exit Code is not passed back to shell correctly." echo "***Warning*** Exit code checking is skipped." h5haveexitcode=no fi @@ -230,7 +230,7 @@ TESTING() { # the `nerrors' global variable and (if $verbose is set) display up to $NLINS # lines of the actual output from the tool test. The actual output is not # removed if $HDF5_NOCLEANUP has a non-zero value. -# Arguemnts: +# Arguments: # $1 -- actual output filename to use # $2 and on -- argument for the h5ls tool TOOLTEST() { diff --git a/tools/test/h5ls/testh5lsvds.sh.in b/tools/test/h5ls/testh5lsvds.sh.in index eb44367..ab2d137 100644 --- a/tools/test/h5ls/testh5lsvds.sh.in +++ b/tools/test/h5ls/testh5lsvds.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. # @@ -103,7 +103,7 @@ $SRC_H5LS_TESTFILES/vds/tvds-5.ls # RUNSERIAL is used. Check if it can return exit code from executalbe correctly. if [ -n "$RUNSERIAL_NOEXITCODE" ]; then - echo "***Warning*** Serial Exit Code is not passed back to shell corretly." + echo "***Warning*** Serial Exit Code is not passed back to shell correctly." echo "***Warning*** Exit code checking is skipped." h5haveexitcode=no fi @@ -169,7 +169,7 @@ TESTING() { # the `nerrors' global variable and (if $verbose is set) display up to $NLINS # lines of the actual output from the tool test. The actual output is not # removed if $HDF5_NOCLEANUP has a non-zero value. -# Arguemnts: +# Arguments: # $1 -- actual output filename to use # $2 and on -- argument for the h5ls tool TOOLTEST() { diff --git a/tools/test/h5repack/CMakeLists.txt b/tools/test/h5repack/CMakeLists.txt index 92b61fc..0b90750 100644 --- a/tools/test/h5repack/CMakeLists.txt +++ b/tools/test/h5repack/CMakeLists.txt @@ -1,12 +1,12 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_TOOLS_TEST_H5REPACK C) # -------------------------------------------------------------------- -# Add h5Repack test executables +# Add h5repack test executables # -------------------------------------------------------------------- add_executable (testh5repack_detect_szip ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testh5repack_detect_szip.c) target_include_directories (testh5repack_detect_szip - PRIVATE "${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR};${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" + PRIVATE "${HDF5_TOOLS_SRC_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) @@ -17,6 +17,7 @@ else () endif () set_target_properties (testh5repack_detect_szip PROPERTIES FOLDER tools) +# These are the same files used by the h5repack tool set (REPACK_COMMON_SOURCES ${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR}/h5repack_copy.c ${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR}/h5repack_filters.c @@ -28,7 +29,7 @@ set (REPACK_COMMON_SOURCES ) add_executable (h5repacktest ${REPACK_COMMON_SOURCES} ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/h5repacktst.c) target_include_directories (h5repacktest - PRIVATE "${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR};${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" + PRIVATE "${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR};${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_TEST_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" ) if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (h5repacktest STATIC) @@ -51,17 +52,25 @@ if (BUILD_SHARED_LIBS) 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_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + 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}) + target_link_libraries (${H5REPACK_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_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_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + 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}) + target_link_libraries (${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} PRIVATE ${HDF5_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") #----------------------------------------------------------------------------- @@ -85,4 +94,26 @@ if (BUILD_SHARED_LIBS) ) endif () -include (CMakeTests.cmake) +# -------------------------------------------------------------------- +# Add the h5repack test executable +# -------------------------------------------------------------------- +if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) + add_executable (h5repackgentest ${HDF5_TOOLS_TEST_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 () diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index a28a282..09648ff 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/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. # @@ -26,10 +26,23 @@ ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_deflate.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_early.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_ext.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_f32le.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_f32le_ex-0.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_f32le_ex.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_fill.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_filters.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_fletcher.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_hlink.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_1d.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_1d_ex-0.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_1d_ex-1.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_1d_ex.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_2d.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_2d_ex-0.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_2d_ex.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_3d.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_3d_ex-0.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_3d_ex.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layout.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layouto.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layout2.h5 @@ -38,12 +51,20 @@ ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_named_dtypes.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_nested_8bit_enum.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_nested_8bit_enum_deflated.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_CVE-2018-17432.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_CVE-2018-14460.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_nbit.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_objs.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_refs.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_shuffle.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_soffset.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_szip.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-0.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-1.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-2.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-3.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex.h5 # fsm ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_aggr.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_fsm_aggr_nopersist.h5 @@ -53,6 +74,14 @@ ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_paged_persist.h5 # h5diff/testfile ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_attr1.h5 + # tools/testfiles for external links + ${HDF5_TOOLS_DIR}/testfiles/tsoftlinks.h5 + ${HDF5_TOOLS_DIR}/testfiles/textlinkfar.h5 + ${HDF5_TOOLS_DIR}/testfiles/textlinksrc.h5 + ${HDF5_TOOLS_DIR}/testfiles/textlinktar.h5 + ${HDF5_TOOLS_DIR}/testfiles/textlink.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5copy_extlinks_src.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5copy_extlinks_trg.h5 # tools/testfiles ${HDF5_TOOLS_DIR}/testfiles/tfamily00000.h5 ${HDF5_TOOLS_DIR}/testfiles/tfamily00001.h5 @@ -66,6 +95,9 @@ ${HDF5_TOOLS_DIR}/testfiles/tfamily00009.h5 ${HDF5_TOOLS_DIR}/testfiles/tfamily00010.h5 ${HDF5_TOOLS_DIR}/testfiles/tordergr.h5 + # reference conversion files + ${HDF5_TOOLS_DIR}/testfiles/tattrreg.h5 + ${HDF5_TOOLS_DIR}/testfiles/tdatareg.h5 # tools/testfiles/vds ${HDF5_TOOLS_DIR}/testfiles/vds/1_a.h5 ${HDF5_TOOLS_DIR}/testfiles/vds/1_b.h5 @@ -106,6 +138,13 @@ ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/plugin_version_test.h5repack_layout.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/plugin_zero.h5repack_layout.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/plugin_none.h5repack_layout.UD.h5 + # tools/testfiles for external links + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/tsoftlinks-merge.tsoftlinks.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/textlinkfar-merge.textlinkfar.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/textlinksrc-merge.textlinksrc.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/textlinktar-merge.textlinktar.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/textlink-merge.textlink.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5copy_extlinks_src-merge.h5copy_extlinks_src.h5 ) set (LIST_DDL_TEST_FILES @@ -129,6 +168,28 @@ ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/3_1_vds.h5-vds_chunk2x5x8-v ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/4_vds.h5-vds_compa-v ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/4_vds.h5-vds_conti-v + # refs + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/attrregion.tattrreg.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/dataregion.tdatareg.h5 + # tools/testfiles for external links + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/textlinkfar-base.textlinkfar.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/textlinksrc-base.textlinksrc.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/textlinktar-base.textlinktar.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/textlink-base.textlink.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/tsoftlinks-base.tsoftlinks.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5copy_extlinks_src-base.h5copy_extlinks_src.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/textlinkfar-prune.textlinkfar.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/textlinksrc-prune.textlinksrc.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/textlinktar-prune.textlinktar.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/textlink-prune.textlink.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/tsoftlinks-prune.tsoftlinks.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5copy_extlinks_src-prune.h5copy_extlinks_src.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/textlinkfar-mergeprune.textlinkfar.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/textlinksrc-mergeprune.textlinksrc.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/textlinktar-mergeprune.textlinktar.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/textlink-mergeprune.textlink.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/tsoftlinks-mergeprune.tsoftlinks.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5copy_extlinks_src-mergeprune.h5copy_extlinks_src.h5 ) foreach (h5_file ${LIST_HDF5_TEST_FILES}) @@ -157,16 +218,10 @@ ############################################################################## ############################################################################## - if (NOT BUILD_SHARED_LIBS) - set (tgt_ext "") - else () - set (tgt_ext "-shared") - endif () - 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 ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_ext}> ${ARGN}) + 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" ) @@ -175,7 +230,7 @@ NAME H5REPACK-h5repack-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5repack${tgt_ext}>" + -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" @@ -207,14 +262,14 @@ ) add_test ( NAME H5REPACK_OLD-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_ext}> ${ARGN} -i ${PROJECT_BINARY_DIR}/testfiles/${testfile} -o ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + 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_ext}> ${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_OLD-${testname}_DFF PROPERTIES DEPENDS H5REPACK_OLD-${testname} @@ -242,14 +297,14 @@ ) add_test ( NAME H5REPACK-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_ext}> --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 ) add_test ( NAME H5REPACK-${testname}_DFF - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_ext}> --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} @@ -257,7 +312,7 @@ endif () endmacro () - macro (ADD_H5_CMP_TEST testname testfilter testtype resultcode resultfile) + macro (ADD_H5_FILTER_TEST testname testfilter testtype resultcode resultfile) if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( @@ -271,7 +326,7 @@ if (HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5REPACK_CMP-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_ext}> ${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} ) else () add_test ( @@ -285,7 +340,7 @@ NAME H5REPACK_CMP-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5repack${tgt_ext}>" + -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" @@ -315,7 +370,7 @@ if (HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5REPACK_MASK-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_ext}> ${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 @@ -332,7 +387,7 @@ NAME H5REPACK_MASK-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5repack${tgt_ext}>" + -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" @@ -366,7 +421,7 @@ ) add_test ( NAME H5REPACK_DMP-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_ext}> ${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 @@ -376,7 +431,7 @@ NAME H5REPACK_DMP-h5dump-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -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" @@ -391,6 +446,48 @@ endif () endmacro () + macro (ADD_H5_DIFF_TEST testname testtype resultcode testfile) + if ("${testtype}" STREQUAL "SKIP") + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5REPACK_DIFF-${testname} + COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile}" + ) + set_property(TEST H5REPACK_DIFF-${testname} PROPERTY DISABLED) + endif () + else () + add_test ( + NAME H5REPACK_DIFF-${testname}-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${testfile} + ) + set_tests_properties (H5REPACK_DIFF-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack + ) + add_test ( + NAME H5REPACK_DIFF-${testname} + 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_DIFF-${testname} PROPERTIES + DEPENDS H5REPACK_DIFF-${testname}-clear-objects + ) + add_test ( + NAME H5REPACK_DIFF-${testname}_DFF + COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5diff${tgt_file_ext}>" + -D "TEST_ARGS:STRING=-v;--enable-error-stack;${testfile};out-${testname}.${testfile}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=out-${testname}.${testfile}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${testname}.${testfile}.tst" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5REPACK_DIFF-${testname}_DFF PROPERTIES + DEPENDS H5REPACK_DIFF-${testname} + ) + endif () + endmacro () + macro (ADD_H5_STAT_TEST testname testtype resultcode statarg resultfile) if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) @@ -410,7 +507,7 @@ ) add_test ( NAME H5REPACK_STAT-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_ext}> ${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 @@ -420,7 +517,7 @@ NAME H5REPACK_STAT-h5stat-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5stat${tgt_ext}>" + -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" @@ -455,14 +552,14 @@ ) add_test ( NAME H5REPACK_VERIFY_LAYOUT-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_ext}> ${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 ) add_test ( NAME H5REPACK_VERIFY_LAYOUT-${testname}_DFF - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_ext}> ${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} @@ -472,7 +569,7 @@ NAME H5REPACK_VERIFY_LAYOUT-${testname}_DMP COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -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" @@ -498,7 +595,7 @@ NAME H5REPACK_VERIFY_LAYOUT-${testname}_DMP COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -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" @@ -536,7 +633,7 @@ ) add_test ( NAME H5REPACK_VERIFY_LAYOUT_VDS-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_ext}> ${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_VDS-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" @@ -546,7 +643,7 @@ NAME H5REPACK_VERIFY_LAYOUT_VDS-${testname}_DMP COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=-d;${testdset};-p;out-${testname}.${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${testfile}-${testname}-v.out" @@ -574,7 +671,7 @@ ) add_test ( NAME H5REPACK_VERIFY_SUPERBLOCK-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_ext}> -j;${lowbound};-k;${highbound} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_file_ext}> -j;${lowbound};-k;${highbound} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) set_tests_properties (H5REPACK_VERIFY_SUPERBLOCK-${testname} PROPERTIES DEPENDS H5REPACK_VERIFY_SUPERBLOCK-${testname}-clear-objects @@ -583,7 +680,7 @@ NAME H5REPACK_VERIFY_SUPERBLOCK-${testname}_DMP COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=-H;-B;out-${testname}.${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${testfile}-${testname}-v.out" @@ -608,7 +705,7 @@ ) add_test ( NAME ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_ext}> -j;${lowbound};-k;${highbound} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_file_ext}> -j;${lowbound};-k;${highbound} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) set_tests_properties (ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname} PROPERTIES DEPENDS ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname}-clear-objects @@ -619,34 +716,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 + 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}_N-clear-objects PROPERTIES + set_tests_properties (H5REPACK_META-${testname}-clear-objects PROPERTIES FIXTURES_REQUIRED clear_h5repack ) add_test ( NAME H5REPACK_META-${testname}_N - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_ext}> ${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}_N-clear-objects + 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=-v;${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 ) add_test ( NAME H5REPACK_META-${testname}_M - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_ext}> ${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 + DEPENDS H5REPACK_META-${testname}_N_DFF ) - - 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" + 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=-v;${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 + ) endmacro () macro (ADD_H5_UD_TEST testname resultcode resultfile) @@ -699,6 +840,104 @@ 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 () + ############################################################################## ############################################################################## ### T H E T E S T S ### @@ -987,7 +1226,7 @@ if (NOT USE_FILTER_DEFLATE) set (TESTTYPE "SKIP") endif () - ADD_H5_CMP_TEST (gzip_verbose_filters "O?...ing file[^\n]+\n" ${TESTTYPE} 0 ${arg}) + ADD_H5_FILTER_TEST (gzip_verbose_filters "O?...ing file[^\n]+\n" ${TESTTYPE} 0 ${arg}) ########################################################### # the following tests assume the input files have filters @@ -1302,16 +1541,26 @@ ADD_H5_TEST (bug1814 "TEST" ${FILE_REF}) # test attribute with various references (bug1797 / HDFFV-5932) -# the references in attribute of compund or vlen datatype +# the references in attribute of compound or vlen datatype ADD_H5_TEST (HDFFV-5932 "TEST" ${FILE_ATTR_REF}) -# Add test for memory leak in attirbute. This test is verified by CTEST. +# Add test for memory leak in attribute. This test is verified by CTEST. # 1. leak from vlen string # 2. leak from compound type without reference member # (HDFFV-7840, ) # Note: this test is experimental for sharing test file among tools ADD_H5_TEST (HDFFV-7840 "TEST" h5diff_attr1.h5) +# test CVE-2018-17432 fix + set (arg h5repack_CVE-2018-17432.h5 --low=1 --high=2 -f GZIP=8 -l dset1:CHUNK=5x6) + set (TESTTYPE "TEST") + ADD_H5_FILTER_TEST (HDFFV-10590 "" ${TESTTYPE} 1 ${arg}) + +# test CVE-2018-14460 fix + set (arg h5repack_CVE-2018-14460.h5) + set (TESTTYPE "TEST") + ADD_H5_FILTER_TEST (HDFFV-11223 "" ${TESTTYPE} 1 ${arg}) + # tests for metadata block size option ('-M') ADD_H5_TEST_META (meta_short h5repack_layout.h5 -M 8192) ADD_H5_TEST_META (meta_long h5repack_layout.h5 --metadata_block_size=8192) @@ -1351,6 +1600,12 @@ endif () ADD_H5_VERIFY_VDS (vds_conti ${TESTTYPE} 0 ${FILEV4} vds_dset CONTIGUOUS -l vds_dset:CONTI) +################################################################ +# reference new api conversions +############################################################### +ADD_H5_DMP_TEST (attrregion "TEST" 0 tattrreg.h5) +ADD_H5_DMP_TEST (dataregion "TEST" 0 tdatareg.h5) + ############################################################################## ### V E R S I O N B O U N D S T E S T S ############################################################################## @@ -1364,6 +1619,53 @@ ADD_H5_VERIFY_SUPERBLOCK (SB_IS_3 h5repack_layout.h5 2 2 3) ADD_H5_VERIFY_INVALIDBOUNDS (latest_latest_invalid bounds_latest_latest.h5 0 1) ############################################################################## +### 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) + +############################################################################## +### E X T E R N A L L I N K T E S T S +############################################################################## +### HDFFV-11128 needs fixed to enable the following test +#ADD_H5_DMP_TEST (h5copy_extlinks_src-base "TEST" 0 h5copy_extlinks_src.h5 --enable-error-stack) +ADD_H5_DMP_TEST (tsoftlinks-base "TEST" 0 tsoftlinks.h5 --enable-error-stack) +ADD_H5_DMP_TEST (textlink-base "TEST" 0 textlink.h5 --enable-error-stack) +ADD_H5_DMP_TEST (textlinkfar-base "TEST" 0 textlinkfar.h5 --enable-error-stack) +ADD_H5_DMP_TEST (textlinksrc-base "TEST" 0 textlinksrc.h5 --enable-error-stack) +ADD_H5_DMP_TEST (textlinktar-base "TEST" 0 textlinktar.h5 --enable-error-stack) + +ADD_H5_DIFF_TEST (h5copy_extlinks_src-merge "TEST" 0 h5copy_extlinks_src.h5 --merge) +ADD_H5_DIFF_TEST (tsoftlinks-merge "TEST" 1 tsoftlinks.h5 --merge) +ADD_H5_DIFF_TEST (textlink-merge "TEST" 0 textlink.h5 --merge) +### HDFFV-11128 needs fixed to enable the following test +#ADD_H5_DIFF_TEST (textlinkfar-merge "TEST" 1 textlinkfar.h5 --merge) +### HDFFV-11128 needs fixed to enable the following test +#ADD_H5_DIFF_TEST (textlinksrc-merge "TEST" 1 textlinksrc.h5 --merge) +### HDFFV-11128 needs fixed to enable the following test +#ADD_H5_DIFF_TEST (textlinktar-merge "TEST" 1 textlinktar.h5 --merge) + +ADD_H5_DMP_TEST (h5copy_extlinks_src-prune "TEST" 0 h5copy_extlinks_src.h5 --prune --enable-error-stack) +ADD_H5_DMP_TEST (tsoftlinks-prune "TEST" 0 tsoftlinks.h5 --prune --enable-error-stack) +ADD_H5_DMP_TEST (textlink-prune "TEST" 0 textlink.h5 --prune --enable-error-stack) +ADD_H5_DMP_TEST (textlinkfar-prune "TEST" 0 textlinkfar.h5 --prune --enable-error-stack) +ADD_H5_DMP_TEST (textlinksrc-prune "TEST" 0 textlinksrc.h5 --prune --enable-error-stack) +ADD_H5_DMP_TEST (textlinktar-prune "TEST" 0 textlinktar.h5 --prune --enable-error-stack) + +ADD_H5_DMP_TEST (h5copy_extlinks_src-mergeprune "TEST" 0 h5copy_extlinks_src.h5 --merge --prune --enable-error-stack) +ADD_H5_DMP_TEST (tsoftlinks-mergeprune "TEST" 0 tsoftlinks.h5 --merge --prune --enable-error-stack) +ADD_H5_DMP_TEST (textlink-mergeprune "TEST" 0 textlink.h5 --merge --prune --enable-error-stack) +### HDFFV-11128 needs fixed to enable the following test +#ADD_H5_DMP_TEST (textlinkfar-mergeprune "TEST" 0 textlinkfar.h5 --merge --prune --enable-error-stack) +### HDFFV-11128 needs fixed to enable the following test +#ADD_H5_DMP_TEST (textlinksrc-mergeprune "TEST" 0 textlinksrc.h5 --merge --prune --enable-error-stack) +### HDFFV-11128 needs fixed to enable the following test +#ADD_H5_DMP_TEST (textlinktar-mergeprune "TEST" 0 textlinktar.h5 --merge --prune --enable-error-stack) + +############################################################################## ### P L U G I N T E S T S ############################################################################## if (BUILD_SHARED_LIBS) diff --git a/tools/test/h5repack/CMakeVFDTests.cmake b/tools/test/h5repack/CMakeVFDTests.cmake index c1a280b..f8ac10b 100644 --- a/tools/test/h5repack/CMakeVFDTests.cmake +++ b/tools/test/h5repack/CMakeVFDTests.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. # @@ -15,20 +15,7 @@ ### T E S T I N G ### ############################################################################## ############################################################################## - -set (VFD_LIST - sec2 - stdio - core - core_paged - split - multi - family -) - -if (DIRECT_VFD) - set (VFD_LIST ${VFD_LIST} direct) -endif () +H5_CREATE_VFD_DIR() ############################################################################## ############################################################################## @@ -38,7 +25,6 @@ endif () 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 diff --git a/tools/test/h5repack/Makefile.am b/tools/test/h5repack/Makefile.am index 59d7a6a..dbd8478 100644 --- a/tools/test/h5repack/Makefile.am +++ b/tools/test/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. ## @@ -22,10 +22,12 @@ include $(top_srcdir)/config/commence.am AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib -I$(top_srcdir)/tools/src/h5repack # Test programs and scripts +TEST_PROG=h5repackgentest TEST_SCRIPT=h5repack.sh noinst_PROGRAMS=h5repacktst testh5repack_detect_szip +check_PROGRAMS=$(TEST_PROG) SCRIPT_DEPEND=../../src/h5repack/h5repack$(EXEEXT) h5repacktst$(EXEEXT) if HAVE_SHARED_CONDITIONAL if USE_PLUGINS_CONDITIONAL @@ -40,7 +42,7 @@ LDADD=../../src/h5repack/libh5repack.la $(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5) testh5repack_detect_szip_SOURCES=testh5repack_detect_szip.c -h5repacktst_SOURCES=h5repacktst.c +h5repacktst_SOURCES=h5repacktst.c if HAVE_SHARED_CONDITIONAL @@ -57,7 +59,8 @@ 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/test/h5repack/dynlib_rpk.c b/tools/test/h5repack/dynlib_rpk.c index 29c3eae..bef032a 100644 --- a/tools/test/h5repack/dynlib_rpk.c +++ b/tools/test/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_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 */ + 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_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*/ - /* Substract the "add on" value to all the data values */ - while(buf_left > 0) { + if (flags & H5Z_FLAG_REVERSE) { /*read*/ + /* Subtract the "add on" value to all the data values */ + 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/test/h5repack/dynlib_vrpk.c b/tools/test/h5repack/dynlib_vrpk.c index 06d90ff..a45de65 100644 --- a/tools/test/h5repack/dynlib_vrpk.c +++ b/tools/test/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_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 */ + 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_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*/ - /* Substract the "add on" value to all the data values */ - while(buf_left > 0) { + if (flags & H5Z_FLAG_REVERSE) { /*read*/ + /* Subtract the "add on" value to all the data values */ + 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/test/h5repack/h5repack.sh.in b/tools/test/h5repack/h5repack.sh.in index c515786..a241ea8 100644 --- a/tools/test/h5repack/h5repack.sh.in +++ b/tools/test/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. # @@ -92,10 +92,18 @@ $SRC_H5REPACK_TESTFILES/h5repack_attr_refs.h5 $SRC_H5REPACK_TESTFILES/h5repack_deflate.h5 $SRC_H5REPACK_TESTFILES/h5repack_early.h5 $SRC_H5REPACK_TESTFILES/h5repack_ext.h5 +$SRC_H5REPACK_TESTFILES/h5repack_f32le.h5 +$SRC_H5REPACK_TESTFILES/h5repack_f32le_ex.h5 $SRC_H5REPACK_TESTFILES/h5repack_fill.h5 $SRC_H5REPACK_TESTFILES/h5repack_filters.h5 $SRC_H5REPACK_TESTFILES/h5repack_fletcher.h5 $SRC_H5REPACK_TESTFILES/h5repack_hlink.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_layout.h5 $SRC_H5REPACK_TESTFILES/h5repack_layouto.h5 $SRC_H5REPACK_TESTFILES/h5repack_layout2.h5 @@ -109,13 +117,29 @@ $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_uint8be.h5 +$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex.h5 +########fsm#files######## $SRC_H5REPACK_TESTFILES/h5repack_aggr.h5 $SRC_H5REPACK_TESTFILES/h5repack_fsm_aggr_nopersist.h5 $SRC_H5REPACK_TESTFILES/h5repack_fsm_aggr_persist.h5 $SRC_H5REPACK_TESTFILES/h5repack_none.h5 $SRC_H5REPACK_TESTFILES/h5repack_paged_nopersist.h5 $SRC_H5REPACK_TESTFILES/h5repack_paged_persist.h5 +########h5diff/testfile######## $SRC_H5DIFF_TESTFILES/h5diff_attr1.h5 +########test#HDFFV-10590######## +$SRC_H5REPACK_TESTFILES/h5repack_CVE-2018-17432.h5 +$SRC_H5REPACK_TESTFILES/h5repack_CVE-2018-14460.h5 +########tools/testfiles#for#external#links######## +$SRC_TOOLS_TESTFILES/tsoftlinks.h5 +$SRC_TOOLS_TESTFILES/textlinkfar.h5 +$SRC_TOOLS_TESTFILES/textlinksrc.h5 +$SRC_TOOLS_TESTFILES/textlinktar.h5 +$SRC_TOOLS_TESTFILES/textlink.h5 +$SRC_H5REPACK_TESTFILES/h5copy_extlinks_src.h5 +$SRC_H5REPACK_TESTFILES/h5copy_extlinks_trg.h5 +########tools/testfiles######## $SRC_TOOLS_TESTFILES/tfamily00000.h5 $SRC_TOOLS_TESTFILES/tfamily00001.h5 $SRC_TOOLS_TESTFILES/tfamily00002.h5 @@ -128,6 +152,8 @@ $SRC_TOOLS_TESTFILES/tfamily00008.h5 $SRC_TOOLS_TESTFILES/tfamily00009.h5 $SRC_TOOLS_TESTFILES/tfamily00010.h5 $SRC_TOOLS_TESTFILES/tordergr.h5 +########reference#conversion#files######## +########tools/testfiles/vds######## $SRC_TOOLS_TESTFILES/vds/1_a.h5 $SRC_TOOLS_TESTFILES/vds/1_b.h5 $SRC_TOOLS_TESTFILES/vds/1_c.h5 @@ -158,24 +184,73 @@ $SRC_H5REPACK_TESTFILES/h5repack-help.txt $SRC_H5REPACK_TESTFILES/h5repack_ext.bin $SRC_H5REPACK_TESTFILES/ublock.bin $SRC_H5REPACK_TESTFILES/h5repack.info +########dat#files######## +$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_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/crtorder.tordergr.h5.ddl $SRC_H5REPACK_TESTFILES/deflate_limit.h5repack_layout.h5.ddl $SRC_H5REPACK_TESTFILES/h5repack_layout.h5.ddl -$SRC_H5REPACK_TESTFILES/h5repack_filters.h5-gzip_verbose_filters.tst -$SRC_H5REPACK_TESTFILES/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst $SRC_H5REPACK_TESTFILES/h5repack_layout.h5-plugin_test.ddl -$SRC_H5REPACK_TESTFILES/plugin_test.h5repack_layout.h5.tst -$SRC_H5REPACK_TESTFILES/1_vds.h5-vds_dset_chunk20x10x5-v.ddl -$SRC_H5REPACK_TESTFILES/2_vds.h5-vds_chunk3x6x9-v.ddl -$SRC_H5REPACK_TESTFILES/3_1_vds.h5-vds_chunk2x5x8-v.ddl -$SRC_H5REPACK_TESTFILES/4_vds.h5-vds_compa-v.ddl -$SRC_H5REPACK_TESTFILES/4_vds.h5-vds_conti-v.ddl +########fsm#files######## $SRC_H5REPACK_TESTFILES/SP.h5repack_fsm_aggr_nopersist.h5.ddl $SRC_H5REPACK_TESTFILES/S.h5repack_fsm_aggr_persist.h5.ddl $SRC_H5REPACK_TESTFILES/STG.h5repack_none.h5.ddl $SRC_H5REPACK_TESTFILES/GS.h5repack_paged_nopersist.h5.ddl $SRC_H5REPACK_TESTFILES/SP.h5repack_paged_persist.h5.ddl $SRC_H5REPACK_TESTFILES/SPT.h5repack_aggr.h5.ddl +########vds#files######## +$SRC_H5REPACK_TESTFILES/1_vds.h5-vds_dset_chunk20x10x5-v.ddl +$SRC_H5REPACK_TESTFILES/2_vds.h5-vds_chunk3x6x9-v.ddl +$SRC_H5REPACK_TESTFILES/3_1_vds.h5-vds_chunk2x5x8-v.ddl +$SRC_H5REPACK_TESTFILES/4_vds.h5-vds_compa-v.ddl +$SRC_H5REPACK_TESTFILES/4_vds.h5-vds_conti-v.ddl +########refs#files######## +$SRC_H5REPACK_TESTFILES/attrregion.tattrreg.h5.ddl +$SRC_H5REPACK_TESTFILES/dataregion.tdatareg.h5.ddl +########external#links#files######## +$SRC_H5REPACK_TESTFILES/textlinkfar-base.textlinkfar.h5.ddl +$SRC_H5REPACK_TESTFILES/textlinksrc-base.textlinksrc.h5.ddl +$SRC_H5REPACK_TESTFILES/textlinktar-base.textlinktar.h5.ddl +$SRC_H5REPACK_TESTFILES/textlink-base.textlink.h5.ddl +$SRC_H5REPACK_TESTFILES/tsoftlinks-base.tsoftlinks.h5.ddl +$SRC_H5REPACK_TESTFILES/h5copy_extlinks_src-base.h5copy_extlinks_src.h5.ddl +$SRC_H5REPACK_TESTFILES/textlinkfar-merge.textlinkfar.h5.tst +$SRC_H5REPACK_TESTFILES/textlinksrc-merge.textlinksrc.h5.tst +$SRC_H5REPACK_TESTFILES/textlinktar-merge.textlinktar.h5.tst +$SRC_H5REPACK_TESTFILES/textlink-merge.textlink.h5.tst +$SRC_H5REPACK_TESTFILES/tsoftlinks-merge.tsoftlinks.h5.tst +$SRC_H5REPACK_TESTFILES/h5copy_extlinks_src-merge.h5copy_extlinks_src.h5.tst +$SRC_H5REPACK_TESTFILES/textlinkfar-prune.textlinkfar.h5.ddl +$SRC_H5REPACK_TESTFILES/textlinksrc-prune.textlinksrc.h5.ddl +$SRC_H5REPACK_TESTFILES/textlinktar-prune.textlinktar.h5.ddl +$SRC_H5REPACK_TESTFILES/textlink-prune.textlink.h5.ddl +$SRC_H5REPACK_TESTFILES/tsoftlinks-prune.tsoftlinks.h5.ddl +$SRC_H5REPACK_TESTFILES/h5copy_extlinks_src-prune.h5copy_extlinks_src.h5.ddl +$SRC_H5REPACK_TESTFILES/textlinkfar-mergeprune.textlinkfar.h5.ddl +$SRC_H5REPACK_TESTFILES/textlinksrc-mergeprune.textlinksrc.h5.ddl +$SRC_H5REPACK_TESTFILES/textlinktar-mergeprune.textlinktar.h5.ddl +$SRC_H5REPACK_TESTFILES/textlink-mergeprune.textlink.h5.ddl +$SRC_H5REPACK_TESTFILES/tsoftlinks-mergeprune.tsoftlinks.h5.ddl +$SRC_H5REPACK_TESTFILES/h5copy_extlinks_src-mergeprune.h5copy_extlinks_src.h5.ddl +########tst#files######## +$SRC_H5REPACK_TESTFILES/h5repack_filters.h5-gzip_verbose_filters.tst +$SRC_H5REPACK_TESTFILES/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst +$SRC_H5REPACK_TESTFILES/plugin_test.h5repack_layout.h5.tst +########external#links#tst#files######## +$SRC_H5REPACK_TESTFILES/tsoftlinks-merge.tsoftlinks.h5.tst +$SRC_H5REPACK_TESTFILES/textlinkfar-merge.textlinkfar.h5.tst +$SRC_H5REPACK_TESTFILES/textlinksrc-merge.textlinksrc.h5.tst +$SRC_H5REPACK_TESTFILES/textlinktar-merge.textlinktar.h5.tst +$SRC_H5REPACK_TESTFILES/textlink-merge.textlink.h5.tst +$SRC_H5REPACK_TESTFILES/h5copy_extlinks_src-merge.h5copy_extlinks_src.h5.tst " # @@ -252,6 +327,12 @@ SKIP() { echo " -SKIP-" } +############################################################################## +############################################################################## +### T H E T E S T S M A C R O S ### +############################################################################## +############################################################################## + # Call the h5diff tool # DIFFTEST() @@ -444,7 +525,7 @@ VERIFY_LAYOUT_ALL() #--------------------------------- # check the layout from a dataset - # check if the other layouts still exsit + # check if the other layouts still exist VERIFY "layouts" ( cd $TESTDIR @@ -599,8 +680,95 @@ VERIFY_INVALIDBOUNDS() } # end of VERIFY_INVALIDBOUNDS +# ----------------------------------------------------------------------------- +# Expect h5diff to fail +# Use only by VERIFY_EXTERNAL_CONSOLIDATION +# ----------------------------------------------------------------------------- +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 @@ -640,7 +808,7 @@ TOOLTEST1() TESTING $H5REPACK $@ ( cd $TESTDIR - $RUNSERIAL $H5REPACK_BIN "$@" $infile $outfile + $ENVCMD $RUNSERIAL $H5REPACK_BIN "$@" $infile $outfile ) RET=$? if [ $RET != 0 ] ; then @@ -700,6 +868,160 @@ TOOLTESTV() rm -f $outfile } +# Same as TOOLTEST, but expects h5repack fails +# +TOOLTEST_FAIL() +{ + infile=$1 + outfile=$2 + expect="$TESTDIR/$2-$1.ddl" + actual="$TESTDIR/$2-$1.out" + actual_err="$TESTDIR/$2-$1.err" + shift + shift + + # Run test. + TESTING $H5REPACK $@ + ( + cd $TESTDIR + $ENVCMD $RUNSERIAL $H5REPACK_BIN "$@" $infile $outfile + ) >&$actual + RET=$? + + # Normally h5repack of files tested with this function are expected + # to return not 0, but if the command results in "Segmentation fault" + # or "core dumped" it is a failure regardless of the return value. + failure=`grep -e 'Segmentation fault' -e 'core dumped' $actual` + if [ "$failure" != "" ]; then + nerrors="`expr $nerrors + 1`" + echo " FAILED" + echo " $failure" + else + if [ $RET == 0 ] ; then + nerrors="`expr $nerrors + 1`" + echo " FAILED" + else + echo " PASSED" + fi + fi + rm -f $outfile +} + +# This is same as TOOLTESTV() with comparing display output +# with actual filename swapped +# +TOOLTESTSV() +{ + expect="$TESTDIR/$1.$2.tst" + actual="$TESTDIR/`basename $2 .ddl`.out" + actual_err="$TESTDIR/`basename $2 .ddl`.err" + + infile=$2 + outfile=out-$1.$2 + shift + shift + + # Run test. + TESTING $H5REPACK $@ + ( + cd $TESTDIR + $RUNSERIAL $H5REPACK_BIN "$@" $infile $outfile + ) >$actual 2>$actual_err + RET=$? + if [ $RET != 0 ] ; then + echo "*FAILED*" + nerrors="`expr $nerrors + 1`" + else + echo " PASSED" + VERIFY h5diff equal $@ + ( + cd $TESTDIR + $RUNSERIAL $H5DIFF_BIN -v $infile $outfile + ) >$actual 2>$actual_err + RET=$? + if [ $RET != 0 ] ; then + echo "*FAILED*" + nerrors="`expr $nerrors + 1`" + else + echo " PASSED" + fi + fi + + # display output compare + STDOUT_FILTER $actual + cat $actual_err >> $actual + + VERIFY output from $H5REPACK $@ + if cmp -s $expect $actual; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result (*.tst) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && diff -c $expect $actual |sed 's/^/ /' + fi + + rm -f $actual $actual_err + rm -f $outfile +} + +# This is same as TOOLTESTSV() but expects a diff fail +# +TOOLFAILSV() +{ + expect="$TESTDIR/$1.$2.tst" + actual="$TESTDIR/`basename $2 .ddl`.out" + actual_err="$TESTDIR/`basename $2 .ddl`.err" + + infile=$2 + outfile=out-$1.$2 + shift + shift + + # Run test. + TESTING $H5REPACK $@ + ( + cd $TESTDIR + $RUNSERIAL $H5REPACK_BIN "$@" $infile $outfile + ) >$actual 2>$actual_err + RET=$? + if [ $RET != 0 ] ; then + echo "*FAILED*" + nerrors="`expr $nerrors + 1`" + else + echo " PASSED" + VERIFY h5diff unequal $@ + ( + cd $TESTDIR + $RUNSERIAL $H5DIFF_BIN -v $infile $outfile + ) >$actual 2>$actual_err + RET=$? + if [ $RET == 0 ] ; then + echo "*FAILED*" + nerrors="`expr $nerrors + 1`" + else + echo " PASSED" + fi + fi + + # display output compare + STDOUT_FILTER $actual + cat $actual_err >> $actual + + VERIFY output from $H5REPACK $@ + if cmp -s $expect $actual; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result (*.tst) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && diff -c $expect $actual |sed 's/^/ /' + fi + + rm -f $actual $actual_err + rm -f $outfile +} + # same as TOOLTESTV but filters error stack output and compares to an error file # Extract file name, line number, version and thread IDs because they may be different # ADD_H5ERR_MASK_TEST @@ -1251,44 +1573,28 @@ TOOLTEST_STAT SPT $arg # layout options (these files have no filters) ######################################################### VERIFY_LAYOUT_DSET dset2_chunk_20x10 h5repack_layout.h5 dset2 CHUNKED --layout dset2:CHUNK=20x10 - VERIFY_LAYOUT_ALL chunk_20x10 h5repack_layout.h5 CHUNKED -l CHUNK=20x10 - VERIFY_LAYOUT_DSET dset2_conti h5repack_layout.h5 dset2 CONTIGUOUS -l dset2:CONTI - VERIFY_LAYOUT_ALL conti h5repack_layout.h5 CONTIGUOUS -l CONTI - VERIFY_LAYOUT_DSET dset2_compa h5repack_layout.h5 dset2 COMPACT -l dset2:COMPA - VERIFY_LAYOUT_ALL compa h5repack_layout.h5 COMPACT -l COMPA - TOOLTESTM dset2_chunk_20x10-errstk h5repack_layout.h5 --layout=dset2:CHUNK=20x10x5 --enable-error-stack ################################################################ # layout conversions (file has no filters) ############################################################### - VERIFY_LAYOUT_DSET dset_compa_conti h5repack_layout.h5 dset_compact CONTIGUOUS -l dset_compact:CONTI - VERIFY_LAYOUT_DSET dset_compa_chunk h5repack_layout.h5 dset_compact CHUNKED -l dset_compact:CHUNK=2x5 - VERIFY_LAYOUT_DSET dset_compa_compa h5repack_layout.h5 dset_compact COMPACT -l dset_compact:COMPA - VERIFY_LAYOUT_DSET dset_conti_compa h5repack_layout.h5 dset_contiguous COMPACT -l dset_contiguous:COMPA - VERIFY_LAYOUT_DSET dset_conti_chunk h5repack_layout.h5 dset_contiguous CHUNKED -l dset_contiguous:CHUNK=3x6 - VERIFY_LAYOUT_DSET dset_conti_conti h5repack_layout.h5 dset_contiguous CONTIGUOUS -l dset_contiguous:CONTI - VERIFY_LAYOUT_DSET chunk_compa h5repack_layout.h5 dset_chunk COMPACT -l dset_chunk:COMPA - VERIFY_LAYOUT_DSET chunk_conti h5repack_layout.h5 dset_chunk CONTIGUOUS -l dset_chunk:CONTI - VERIFY_LAYOUT_DSET chunk_18x13 h5repack_layout.h5 dset_chunk CHUNKED -l dset_chunk:CHUNK=18x13 # test convert small size dataset ( < 1k) to compact layout without -m VERIFY_LAYOUT_DSET contig_small_compa h5repack_layout2.h5 contig_small COMPACT -l contig_small:COMPA - VERIFY_LAYOUT_DSET contig_small_fixed_compa h5repack_layout2.h5 chunked_small_fixed COMPACT -l chunked_small_fixed:COMPA #--------------------------------------------------------------------------- @@ -1316,6 +1622,7 @@ VERIFY_LAYOUT_DSET chunk2compa h5repack_layout3.h5 chunk_unlimit1 CHUNK -l chunk # chunk dim is bigger than dataset dim. ( dset size < 64k ) VERIFY_LAYOUT_DSET error1 h5repack_layout3.h5 chunk_unlimit1 H5S_UNLIMITED -f chunk_unlimit1:NONE # chunk dim is bigger than dataset dim. ( dset size > 64k ) + VERIFY_LAYOUT_DSET error2 h5repack_layout3.h5 chunk_unlimit2 H5S_UNLIMITED -f chunk_unlimit2:NONE # chunk dims are smaller than dataset dims. ( dset size < 64k ) @@ -1330,7 +1637,6 @@ TOOLTEST error4 h5repack_layout3.h5 -f NONE # (dset size < 64K) and with unlimited max dims on a condition as follow. # (HDFFV-8214) #-------------------------------------------------------------------------- - # chunk dim is bigger than dataset dim. should succeed. VERIFY_LAYOUT_DSET ckdim_biger h5repack_layout3.h5 chunk_unlimit2 CONTI -l chunk_unlimit2:CONTI # chunk dim is smaller than dataset dim. should succeed. @@ -1361,7 +1667,6 @@ else fi # several global filters - arg="h5repack_layout.h5 --filter GZIP=1 --filter SHUF" if test $USE_FILTER_DEFLATE != "yes" ; then SKIP $arg @@ -1408,16 +1713,24 @@ TOOLTEST1 family tfamily%05d.h5 TOOLTEST bug1814 h5repack_refs.h5 # test attribute with various references (bug1797 / HDFFV-5932) -# the references in attribute of compund or vlen datatype +# the references in attribute of compound or vlen datatype TOOLTEST HDFFV-5932 h5repack_attr_refs.h5 -# Add test for memory leak in attirbute. This test is verified by CTEST. +# Add test for memory leak in attribute. This test is verified by CTEST. # 1. leak from vlen string # 2. leak from compound type without reference member # (HDFFV-7840, ) # Note: this test is experimental for sharing test file among tools TOOLTEST HDFFV-7840 h5diff_attr1.h5 +# test HDFFV-10590 +arg="h5repack_CVE-2018-17432.h5 h5repack_CVE-2018-17432_out.h5 --low=1 --high=2 -f GZIP=8 -l dset1:CHUNK=5x6" +TOOLTEST_FAIL $arg + +# test HDFFV-11223 +arg="h5repack_CVE-2018-14460.h5 h5repack_CVE-2018-14460_out.h5" +TOOLTEST_FAIL $arg + # tests for metadata block size option TOOLTEST_META meta_short h5repack_layout.h5 -M 8192 TOOLTEST_META meta_long h5repack_layout.h5 --metadata_block_size=8192 @@ -1457,9 +1770,15 @@ else VERIFY_LAYOUT_VDS vds_conti 4_vds.h5 vds_dset CONTIGUOUS -l vds_dset:CONTI fi -######################################################### -# Testing version bounds -######################################################### +################################################################ +# reference new api conversions +############################################################### +#TOOLTEST_DUMP attrregion tattrreg.h5 +#TOOLTEST_DUMP dataregion tdatareg.h5 + +############################################################################## +### V E R S I O N B O U N D S T E S T S +############################################################################## # -j 0 -k 2, superblock will be 0 VERIFY_SUPERBLOCK 0 2 0 h5repack_layout.h5 -j 0 -k 2 h5repack_layout.h5 # -j 1 -k 2, superblock will be 2 @@ -1469,6 +1788,49 @@ VERIFY_SUPERBLOCK 2 2 3 h5repack_layout.h5 -j 2 -k 2 h5repack_layout.h5 # -j 0 -k 1, file cannot be opened VERIFY_INVALIDBOUNDS 0 1 bounds_latest_latest.h5 +############################################################################## +### E X T E R N A L S T O R A G E T E S T S +############################################################################## +VERIFY_EXTERNAL_CONSOLIDATION -l CONTI + +############################################################################## +### E X T E R N A L L I N K T E S T S +############################################################################## +### HDFFV-11128 needs fixed to enable the following test +#TOOLTEST_DUMP h5copy_extlinks_src-base h5copy_extlinks_src.h5 --enable-error-stack +TOOLTEST_DUMP tsoftlinks-base tsoftlinks.h5 --enable-error-stack +TOOLTEST_DUMP textlink-base textlink.h5 --enable-error-stack +TOOLTEST_DUMP textlinkfar-base textlinkfar.h5 --enable-error-stack +TOOLTEST_DUMP textlinksrc-base textlinksrc.h5 --enable-error-stack +TOOLTEST_DUMP textlinktar-base textlinktar.h5 --enable-error-stack + +TOOLTESTSV h5copy_extlinks_src-merge h5copy_extlinks_src.h5 --merge +TOOLFAILSV tsoftlinks-merge tsoftlinks.h5 --merge +TOOLTESTSV textlink-merge textlink.h5 --merge +### HDFFV-11128 needs fixed to enable the following test +#TOOLFAILSV textlinkfar-merge textlinkfar.h5 --merge +### HDFFV-11128 needs fixed to enable the following test +#TOOLFAILSV textlinksrc-merge textlinksrc.h5 --merge +### HDFFV-11128 needs fixed to enable the following test +#TOOLFAILSV textlinktar-merge textlinktar.h5 --merge + +TOOLTEST_DUMP h5copy_extlinks_src-prune h5copy_extlinks_src.h5 --prune --enable-error-stack +TOOLTEST_DUMP tsoftlinks-prune tsoftlinks.h5 --prune --enable-error-stack +TOOLTEST_DUMP textlink-prune textlink.h5 --prune --enable-error-stack +TOOLTEST_DUMP textlinkfar-prune textlinkfar.h5 --prune --enable-error-stack +TOOLTEST_DUMP textlinksrc-prune textlinksrc.h5 --prune --enable-error-stack +TOOLTEST_DUMP textlinktar-prune textlinktar.h5 --prune --enable-error-stack + +TOOLTEST_DUMP h5copy_extlinks_src-mergeprune h5copy_extlinks_src.h5 --merge --prune --enable-error-stack +TOOLTEST_DUMP tsoftlinks-mergeprune tsoftlinks.h5 --merge --prune --enable-error-stack +TOOLTEST_DUMP textlink-mergeprune textlink.h5 --merge --prune --enable-error-stack +### HDFFV-11128 needs fixed to enable the following test +#TOOLTEST_DUMP textlinkfar-mergeprune textlinkfar.h5 --merge --prune --enable-error-stack +### HDFFV-11128 needs fixed to enable the following test +#TOOLTEST_DUMP textlinksrc-mergeprune textlinksrc.h5 --merge --prune --enable-error-stack +### HDFFV-11128 needs fixed to enable the following test +#TOOLTEST_DUMP textlinktar-mergeprune textlinktar.h5 --merge --prune --enable-error-stack + # Clean up temporary files/directories CLEAN_TESTFILES_AND_TESTDIR diff --git a/tools/test/h5repack/h5repack_plugin.sh.in b/tools/test/h5repack/h5repack_plugin.sh.in index 5efd9e8..0331d85 100644 --- a/tools/test/h5repack/h5repack_plugin.sh.in +++ b/tools/test/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/test/h5repack/h5repackgentest.c b/tools/test/h5repack/h5repackgentest.c new file mode 100644 index 0000000..c025891 --- /dev/null +++ b/tools/test/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 included datatypes should be more than adequate to verify the correctness + * of the behavior -- if one type can be consolidated from external storage, + * then they 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/test/h5repack/h5repacktst.c b/tools/test/h5repack/h5repacktst.c index ec8df3c..8b114e4 100644 --- a/tools/test/h5repack/h5repacktst.c +++ b/tools/test/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,58 +75,55 @@ #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" /* Files for testing file space paging */ -#define FSPACE_OUT "h5repack_fspace_OUT.h5" /* The output file */ -#define NELMTS(X) (sizeof(X)/sizeof(X[0])) /* # of elements */ +#define FSPACE_OUT "h5repack_fspace_OUT.h5" /* The output file */ +#define NELMTS(X) (sizeof(X) / sizeof(X[0])) /* # of elements */ const char *H5REPACK_FSPACE_FNAMES[] = { - "h5repack_latest.h5", /* 0 */ - "h5repack_default.h5", /* 1 */ - "h5repack_page_persist.h5", /* 2 */ - "h5repack_fsm_aggr_persist.h5", /* 3 */ - "h5repack_page_threshold.h5", /* 4 */ - "h5repack_fsm_aggr_threshold.h5", /* 5 */ - "h5repack_aggr.h5", /* 6 */ - "h5repack_none.h5" /* 7 */ + "h5repack_latest.h5", /* 0 */ + "h5repack_default.h5", /* 1 */ + "h5repack_page_persist.h5", /* 2 */ + "h5repack_fsm_aggr_persist.h5", /* 3 */ + "h5repack_page_threshold.h5", /* 4 */ + "h5repack_fsm_aggr_threshold.h5", /* 5 */ + "h5repack_aggr.h5", /* 6 */ + "h5repack_none.h5" /* 7 */ }; -#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 @@ -148,21 +148,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 * @@ -173,18 +172,19 @@ 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; + pack_opt_t pack_options; + diff_opt_t diff_options; - unsigned j; /* Local index variable for testing file space */ - const char *fname; /* File name for testing file space */ + unsigned j; /* Local index variable for testing file space */ + const char *fname; /* File name for testing file space */ - h5_stat_t file_stat; - h5_stat_size_t fsize1, fsize2; /* file sizes */ -#if defined (H5_HAVE_FILTER_SZIP) - int szip_can_encode = 0; + 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); @@ -194,8 +194,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:"); @@ -218,155 +218,154 @@ int main (void) *------------------------------------------------------------------------- */ TESTING(" files with file space info setting--no options (-S, -P, -T, -G) are set"); - j = 0; /* #0 */ + j = 0; /* #0 */ HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); fname = H5REPACK_FSPACE_FNAMES[j]; - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; - if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) GOERROR; - if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); - TESTING(" files with file space info setting--all options -S, -P, -T, -G are set"); - ++j; /* #1 */ + ++j; /* #1 */ HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); fname = H5REPACK_FSPACE_FNAMES[j]; - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; - pack_options.fs_strategy = H5F_FSPACE_STRATEGY_NONE; - pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ + pack_options.fs_strategy = H5F_FSPACE_STRATEGY_NONE; + pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ pack_options.fs_threshold = 1; - pack_options.fs_pagesize = 8192; - if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + pack_options.fs_pagesize = 8192; + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) GOERROR; - if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); - TESTING(" files with file space info setting--options -S and -T are set"); - ++j; /* #2 */ + ++j; /* #2 */ HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); fname = H5REPACK_FSPACE_FNAMES[j]; - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; - pack_options.fs_strategy = (H5F_fspace_strategy_t)-1; /* "FSM_AGGR" specified via -S FSM_AGGR */ - pack_options.fs_threshold = -1; /* "0" specified via -T 0 */ - if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + pack_options.fs_strategy = (H5F_fspace_strategy_t)-1; /* "FSM_AGGR" specified via -S FSM_AGGR */ + pack_options.fs_threshold = -1; /* "0" specified via -T 0 */ + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) GOERROR; - if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); + if (h5_using_default_driver(NULL)) { + TESTING(" files with file space info setting-- options -S and -P are set & -L"); + ++j; /* #3 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if (h5repack_init(&pack_options, 0, TRUE) < 0) + GOERROR; + pack_options.fs_strategy = H5F_FSPACE_STRATEGY_PAGE; /* "PAGE" specified via -S */ + pack_options.fs_persist = TRUE; + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); - TESTING(" files with file space info setting-- options -S and -P are set & -L"); - ++j; /* #3 */ - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - fname = H5REPACK_FSPACE_FNAMES[j]; - if(h5repack_init(&pack_options, 0, TRUE) < 0) - GOERROR; - pack_options.fs_strategy = H5F_FSPACE_STRATEGY_PAGE; /* "PAGE" specified via -S */ - pack_options.fs_persist = TRUE; - if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) - GOERROR; - if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if(h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) - GOERROR; - if(h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); - - TESTING(" files with file space info setting-- options -P and -T are set & -L"); - ++j; /* #4 */ - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - fname = H5REPACK_FSPACE_FNAMES[j]; - if(h5repack_init(&pack_options, 0, TRUE) < 0) - GOERROR; - pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ - pack_options.fs_threshold = 2; - if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) - GOERROR; - if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if(h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) - GOERROR; - if(h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); + TESTING(" files with file space info setting-- options -P and -T are set & -L"); + ++j; /* #4 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if (h5repack_init(&pack_options, 0, TRUE) < 0) + GOERROR; + pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ + pack_options.fs_threshold = 2; + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); - TESTING(" files with file space info setting-- options -S and -G are set & -L"); - ++j; /* #5 */ - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - fname = H5REPACK_FSPACE_FNAMES[j]; - if(h5repack_init(&pack_options, 0, TRUE) < 0) - GOERROR; - pack_options.fs_strategy = H5F_FSPACE_STRATEGY_PAGE; - pack_options.fs_pagesize = 8192; - if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) - GOERROR; - if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if(h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) - GOERROR; - if(h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); + TESTING(" files with file space info setting-- options -S and -G are set & -L"); + ++j; /* #5 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if (h5repack_init(&pack_options, 0, TRUE) < 0) + GOERROR; + pack_options.fs_strategy = H5F_FSPACE_STRATEGY_PAGE; + pack_options.fs_pagesize = 8192; + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); - TESTING(" files with file space info setting-- options -S, -P, -T, -G are set"); - ++j; /* #6 */ - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - fname = H5REPACK_FSPACE_FNAMES[j]; - if(h5repack_init(&pack_options, 0, FALSE) < 0) - GOERROR; - pack_options.fs_strategy = H5F_FSPACE_STRATEGY_NONE; - pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ - pack_options.fs_threshold = 1; - pack_options.fs_pagesize = 8192; - if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) - GOERROR; - if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if(h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) - GOERROR; - if(h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); + TESTING(" files with file space info setting-- options -S, -P, -T, -G are set"); + ++j; /* #6 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if (h5repack_init(&pack_options, 0, FALSE) < 0) + GOERROR; + pack_options.fs_strategy = H5F_FSPACE_STRATEGY_NONE; + pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ + pack_options.fs_threshold = 1; + pack_options.fs_pagesize = 8192; + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); - TESTING(" files with file space info setting-- options -S, -T, -G are set & -L"); - ++j; /* #7 */ - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - fname = H5REPACK_FSPACE_FNAMES[j]; - if(h5repack_init(&pack_options, 0, TRUE) < 0) - GOERROR; - pack_options.fs_strategy = H5F_FSPACE_STRATEGY_AGGR; - pack_options.fs_threshold = 1; - pack_options.fs_pagesize = 4096; - if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) - GOERROR; - if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if(h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) - GOERROR; - if(h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); + TESTING(" files with file space info setting-- options -S, -T, -G are set & -L"); + ++j; /* #7 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if (h5repack_init(&pack_options, 0, TRUE) < 0) + GOERROR; + pack_options.fs_strategy = H5F_FSPACE_STRATEGY_AGGR; + pack_options.fs_threshold = 1; + pack_options.fs_pagesize = 4096; + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + } /*------------------------------------------------------------------------- * file with fill values @@ -382,32 +381,32 @@ int main (void) GOERROR; if (h5repack_verify(FNAME0, FNAME0OUT, &pack_options) <= 0) GOERROR; - if (h5repack_cmp_pl(FNAME0, FNAME0OUT) <= 0) + if (h5repack_cmp_pl(FNAME0, pack_options.fin_fapl, FNAME0OUT, pack_options.fout_fapl) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); - /*------------------------------------------------------------------------- * file with all kinds of dataset datatypes *------------------------------------------------------------------------- */ - TESTING(" copy of datasets (all datatypes)"); - if (h5repack_init(&pack_options, 0, FALSE) < 0) - GOERROR; - if (h5repack(FNAME1, FNAME1OUT, &pack_options) < 0) - GOERROR; - if (h5diff(FNAME1, FNAME1OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if (h5repack_verify(FNAME1, FNAME1OUT, &pack_options) <= 0) - GOERROR; - if (h5repack_cmp_pl(FNAME1, FNAME1OUT) <= 0) - GOERROR; - if (h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); - + if (!h5_using_parallel_driver(NULL)) { + TESTING(" copy of datasets (all datatypes)"); + if (h5repack_init(&pack_options, 0, FALSE) < 0) + GOERROR; + if (h5repack(FNAME1, FNAME1OUT, &pack_options) < 0) + GOERROR; + if (h5diff(FNAME1, FNAME1OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(FNAME1, FNAME1OUT, &pack_options) <= 0) + GOERROR; + if (h5repack_cmp_pl(FNAME1, pack_options.fin_fapl, FNAME1OUT, pack_options.fout_fapl) <= 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + } /*------------------------------------------------------------------------- * file with attributes @@ -422,7 +421,7 @@ int main (void) GOERROR; if (h5repack_verify(FNAME2, FNAME2OUT, &pack_options) <= 0) GOERROR; - if (h5repack_cmp_pl(FNAME2, FNAME2OUT) <= 0) + if (h5repack_cmp_pl(FNAME2, pack_options.fin_fapl, FNAME2OUT, pack_options.fout_fapl) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; @@ -441,7 +440,7 @@ int main (void) GOERROR; if (h5repack_verify(FNAME3, FNAME3OUT, &pack_options) <= 0) GOERROR; - if (h5repack_cmp_pl(FNAME3, FNAME3OUT) <= 0) + if (h5repack_cmp_pl(FNAME3, pack_options.fin_fapl, FNAME3OUT, pack_options.fout_fapl) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; @@ -565,7 +564,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; @@ -575,7 +574,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; @@ -587,7 +586,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(); @@ -599,14 +598,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; @@ -630,8 +628,7 @@ int main (void) SKIPPED(); #endif - - TESTING(" addding shuffle filter"); + TESTING(" adding shuffle filter"); /*------------------------------------------------------------------------- * test an individual object option @@ -660,7 +657,7 @@ int main (void) *------------------------------------------------------------------------- */ - TESTING(" addding shuffle filter to all"); + TESTING(" adding shuffle filter to all"); if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; @@ -679,7 +676,6 @@ int main (void) PASSED(); - TESTING(" adding checksum filter"); /*------------------------------------------------------------------------- @@ -726,7 +722,6 @@ int main (void) PASSED(); - TESTING(" filter queue fletcher, shuffle, deflate, szip"); /*------------------------------------------------------------------------- @@ -743,7 +738,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; @@ -766,7 +761,6 @@ int main (void) PASSED(); - TESTING(" adding layout chunked (old format)"); /*------------------------------------------------------------------------- @@ -782,7 +776,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; @@ -804,7 +798,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; @@ -933,7 +927,6 @@ int main (void) PASSED(); - TESTING(" layout compact to contiguous conversion"); /*------------------------------------------------------------------------- @@ -986,9 +979,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; @@ -1110,7 +1103,6 @@ int main (void) GOERROR; PASSED(); - /*------------------------------------------------------------------------- * the following tests assume the input files have filters * FNAME7 @@ -1122,7 +1114,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; @@ -1132,7 +1124,7 @@ int main (void) GOERROR; if (h5repack_verify(FNAME7, FNAME7OUT, &pack_options) <= 0) GOERROR; - if (h5repack_cmp_pl(FNAME7, FNAME7OUT) <= 0) + if (h5repack_cmp_pl(FNAME7, pack_options.fin_fapl, FNAME7OUT, pack_options.fout_fapl) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; @@ -1148,7 +1140,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; @@ -1172,7 +1164,6 @@ int main (void) SKIPPED(); #endif - TESTING(" copy of deflate filter"); #ifdef H5_HAVE_FILTER_DEFLATE @@ -1192,7 +1183,6 @@ int main (void) SKIPPED(); #endif - TESTING(" removing deflate filter"); #ifdef H5_HAVE_FILTER_DEFLATE @@ -1214,8 +1204,6 @@ int main (void) SKIPPED(); #endif - - TESTING(" copy of shuffle filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1231,7 +1219,6 @@ int main (void) PASSED(); - TESTING(" removing shuffle filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1249,7 +1236,6 @@ int main (void) PASSED(); - TESTING(" copy of fletcher filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1265,7 +1251,6 @@ int main (void) PASSED(); - TESTING(" removing fletcher filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1283,7 +1268,6 @@ int main (void) PASSED(); - TESTING(" copy of nbit filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1299,7 +1283,6 @@ int main (void) PASSED(); - TESTING(" removing nbit filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1317,7 +1300,6 @@ int main (void) PASSED(); - TESTING(" adding nbit filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1328,14 +1310,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) @@ -1351,7 +1332,6 @@ int main (void) PASSED(); - TESTING(" removing scaleoffset filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1369,7 +1349,6 @@ int main (void) PASSED(); - TESTING(" adding scaleoffset filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1387,7 +1366,6 @@ int main (void) PASSED(); - /*------------------------------------------------------------------------- * file with all filters * dset_all @@ -1399,7 +1377,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) @@ -1426,7 +1404,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) @@ -1451,7 +1429,6 @@ int main (void) SKIPPED(); #endif - /*------------------------------------------------------------------------- * test the NONE global option *------------------------------------------------------------------------- @@ -1459,7 +1436,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; @@ -1514,50 +1491,53 @@ int main (void) GOERROR; PASSED(); - /*------------------------------------------------------------------------- - * test file with userblock - *------------------------------------------------------------------------- - */ - TESTING(" file with userblock"); - if(h5repack_init(&pack_options, 0, FALSE) < 0) - GOERROR; - if(h5repack(FNAME16, FNAME16OUT, &pack_options) < 0) - GOERROR; - if(h5diff(FNAME16, FNAME16OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if(h5repack_verify(FNAME16, FNAME16OUT, &pack_options) <= 0) - GOERROR; - if(verify_userblock(FNAME16OUT) < 0) - GOERROR; - if(h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); + if (h5_using_default_driver(NULL)) { + /*------------------------------------------------------------------------- + * test file with userblock + *------------------------------------------------------------------------- + */ + TESTING(" file with userblock"); + if (h5repack_init(&pack_options, 0, FALSE) < 0) + GOERROR; + if (h5repack(FNAME16, FNAME16OUT, &pack_options) < 0) + GOERROR; + if (h5diff(FNAME16, FNAME16OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(FNAME16, FNAME16OUT, &pack_options) <= 0) + GOERROR; + if (verify_userblock(FNAME16OUT) < 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + } /*------------------------------------------------------------------------- * test --latest options *------------------------------------------------------------------------- */ - TESTING(" latest file format options"); - if (h5repack_init(&pack_options, 0, FALSE) < 0) - GOERROR; - pack_options.latest = 1; - pack_options.grp_compact = 10; - pack_options.grp_indexed = 5; - pack_options.msg_size[0] = 10; - pack_options.msg_size[1] = 20; - pack_options.msg_size[2] = 30; - pack_options.msg_size[3] = 40; - pack_options.msg_size[4] = 50; - if (h5repack(FNAME1, FNAME1OUT, &pack_options) < 0) - GOERROR; - if (h5diff(FNAME1, FNAME1OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if (h5repack_verify(FNAME1, FNAME1OUT, &pack_options)<=0) - GOERROR; - if (h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); - + if (!h5_using_parallel_driver(NULL)) { + TESTING(" latest file format options"); + if (h5repack_init(&pack_options, 0, FALSE) < 0) + GOERROR; + pack_options.latest = 1; + pack_options.grp_compact = 10; + pack_options.grp_indexed = 5; + pack_options.msg_size[0] = 10; + pack_options.msg_size[1] = 20; + pack_options.msg_size[2] = 30; + pack_options.msg_size[3] = 40; + pack_options.msg_size[4] = 50; + if (h5repack(FNAME1, FNAME1OUT, &pack_options) < 0) + GOERROR; + if (h5diff(FNAME1, FNAME1OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(FNAME1, FNAME1OUT, &pack_options) <= 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + } /*------------------------------------------------------------------------- * test several global filters @@ -1566,7 +1546,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; @@ -1588,63 +1568,62 @@ int main (void) SKIPPED(); #endif - - /*------------------------------------------------------------------------- - * test file with userblock - *------------------------------------------------------------------------- - */ - TESTING(" file with added userblock"); + if (h5_using_default_driver(NULL)) { + /*------------------------------------------------------------------------- + * test file with userblock + *------------------------------------------------------------------------- + */ + TESTING(" file with added userblock"); #ifdef H5_HAVE_FILTER_DEFLATE - 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_filename = FNAME_UB; + if (h5repack_init(&pack_options, 0, FALSE) < 0) + GOERROR; - if(h5repack(FNAME8, FNAME8OUT, &pack_options) < 0) - GOERROR; - if(h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if(h5repack_verify(FNAME8, FNAME8OUT, &pack_options) <= 0) - GOERROR; - if(verify_userblock(FNAME8OUT) < 0) - GOERROR; - if(h5repack_end(&pack_options) < 0) - GOERROR; + /* add the options for a user block size and user block filename */ + pack_options.ublock_size = USERBLOCK_SIZE; + pack_options.ublock_filename = FNAME_UB; + if (h5repack(FNAME8, FNAME8OUT, &pack_options) < 0) + GOERROR; + if (h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(FNAME8, FNAME8OUT, &pack_options) <= 0) + GOERROR; + if (verify_userblock(FNAME8OUT) < 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; - PASSED(); + PASSED(); #else - SKIPPED(); + SKIPPED(); #endif - + } /*------------------------------------------------------------------------- - * test file with aligment + * test file with alignment *------------------------------------------------------------------------- */ - TESTING(" file with aligment"); + TESTING(" file with alignment"); #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 */ + /* add the options for alignment */ 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 */ + /* verify alignment */ { hsize_t threshold; hsize_t alignment; @@ -1655,7 +1634,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; @@ -1665,14 +1644,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(); @@ -1684,75 +1660,74 @@ 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(); - /*------------------------------------------------------------------------- - * test --metadata_block_size option - * Also verify that output file using the metadata_block_size option is - * larger than the output file one not using it. - * FNAME4 is used because it is the same as the test file used for the - * shell script version of this test (h5repack.sh). - *------------------------------------------------------------------------- - */ - TESTING(" metadata block size option"); - /* 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) - GOERROR; - if(h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) - GOERROR; - if(HDstat(FNAME4OUT, &file_stat) < 0) - GOERROR; - fsize1 = file_stat.st_size; - if(h5repack_end(&pack_options) < 0) - GOERROR; - - /* run it again with metadata option */ - if(h5repack_init(&pack_options, 0, FALSE) < 0) - GOERROR; - pack_options.meta_block_size = 8192; - if(h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) - GOERROR; - if(h5diff(FNAME4, FNAME4OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if(h5repack_verify(FNAME4, FNAME4OUT, &pack_options) <= 0) - GOERROR; - /* record the file size of the output file */ - 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) - GOERROR; - if(h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); + if (h5_using_default_driver(NULL)) { + /*------------------------------------------------------------------------- + * test --metadata_block_size option + * Also verify that output file using the metadata_block_size option is + * larger than the output file one not using it. + * FNAME4 is used because it is the same as the test file used for the + * shell script version of this test (h5repack.sh). + *------------------------------------------------------------------------- + */ + TESTING(" metadata block size option"); + /* 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) + GOERROR; + if (h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) + GOERROR; + if (HDstat(FNAME4OUT, &file_stat) < 0) + GOERROR; + fsize1 = file_stat.st_size; + if (h5repack_end(&pack_options) < 0) + GOERROR; + /* run it again with metadata option */ + if (h5repack_init(&pack_options, 0, FALSE) < 0) + GOERROR; + pack_options.meta_block_size = 8192; + if (h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) + GOERROR; + if (h5diff(FNAME4, FNAME4OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(FNAME4, FNAME4OUT, &pack_options) <= 0) + GOERROR; + /* record the file size of the output file */ + 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) + GOERROR; + 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."); @@ -1762,107 +1737,110 @@ int main (void) return 0; error: + h5tools_close(); + puts("***** H5REPACK TESTS FAILED *****"); - return 1; + 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 fcpl = -1; /* File creation property list */ - hid_t fapl = -1; /* File access property list */ - unsigned j; /* Local index variable */ + hid_t fid = H5I_INVALID_HID; + hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + unsigned j; /* Local index variable */ /*------------------------------------------------------------------------- * 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) - return -1; - if (make_all_objects(fid) < 0) - goto out; - if(H5Fclose(fid) < 0) - return -1; + if (!h5_using_parallel_driver(NULL)) { + 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) + 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; /*------------------------------------------------------------------------- @@ -1872,168 +1850,171 @@ 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) - goto out; + if (h5_using_default_driver(NULL)) { + /*------------------------------------------------------------------------- + * create a file with userblock + *------------------------------------------------------------------------- + */ + if (make_userblock() < 0) + goto out; - /*------------------------------------------------------------------------- - * create a userblock file - *------------------------------------------------------------------------- - */ - if(make_userblock_file() < 0) - goto out; + /*------------------------------------------------------------------------- + * create a userblock file + *------------------------------------------------------------------------- + */ + 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; - /*------------------------------------------------------------------------- - * create obj and region reference type datasets (bug1814) - * add attribute with int type (bug1726) - * add attribute with obj and region reference type (bug1726) - *------------------------------------------------------------------------- - */ - 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) - return -1; + if (!h5_using_parallel_driver(NULL)) { + /*------------------------------------------------------------------------- + * create obj and region reference type datasets (bug1814) + * add attribute with int type (bug1726) + * add attribute with obj and region reference type (bug1726) + *------------------------------------------------------------------------- + */ + 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) + 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) - return -1; - if (make_complex_attr_references(fid) < 0) - goto out; - 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) + return -1; + if (make_complex_attr_references(fid) < 0) + goto out; + if (H5Fclose(fid) < 0) + return -1; + } /*------------------------------------------------------------------------- * create 8 files with combinations ??? *------------------------------------------------------------------------- */ /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) return -1; /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) return -1; /* @@ -2042,9 +2023,9 @@ int make_testfiles(void) * default: inpage=4096 */ j = 0; - if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[j], H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[j], H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) return -1; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /* @@ -2053,118 +2034,118 @@ int make_testfiles(void) * default: inpage=4096 */ HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) - return -1; - if(H5Fclose(fid) < 0) - return -1; - - /* - * #2 -- h5repack_page_persist.h5 - * Setting: - * strategy=PAGE, persist=TRUE, threshold=1 - * inpage=512 - * latest format - */ - /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - return -1; - if(H5Pset_file_space_page_size(fcpl, (hsize_t)512) < 0) - return -1; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) - return -1; - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) - return -1; - if(H5Fclose(fid) < 0) + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; - if(H5Pclose(fcpl) < 0) + if (H5Fclose(fid) < 0) return -1; + if (h5_using_default_driver(NULL)) { + /* + * #2 -- h5repack_page_persist.h5 + * Setting: + * strategy=PAGE, persist=TRUE, threshold=1 + * inpage=512 + * latest format + */ + /* Create file creation property list */ + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + return -1; + if (H5Pset_file_space_page_size(fcpl, (hsize_t)512) < 0) + return -1; + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) + return -1; + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) + return -1; + if (H5Fclose(fid) < 0) + return -1; + if (H5Pclose(fcpl) < 0) + return -1; - /* - * #3 -- h5repack_fsm_aggr_persist.h5 - * Setting: - * strategy=FSM_AGGR, persist=TRUE, threshold=1 - * default: inpage=4096 - */ - /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - return -1; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) - return -1; - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) - return -1; - if(H5Fclose(fid) < 0) - return -1; - if(H5Pclose(fcpl) < 0) - return -1; - + /* + * #3 -- h5repack_fsm_aggr_persist.h5 + * Setting: + * strategy=FSM_AGGR, persist=TRUE, threshold=1 + * default: inpage=4096 + */ + /* Create file creation property list */ + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + return -1; + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) + return -1; + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + return -1; + if (H5Fclose(fid) < 0) + return -1; + if (H5Pclose(fcpl) < 0) + return -1; - /* - * #4 -- h5repack_page_threshold.h5 - * Setting: - * strategy=PAGE, persist=FALSE, threshold=3 - * inpage=8192 - * latest format - */ + /* + * #4 -- h5repack_page_threshold.h5 + * Setting: + * strategy=PAGE, persist=FALSE, threshold=3 + * inpage=8192 + * latest format + */ - /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - return -1; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)3) < 0) - return -1; - if(H5Pset_file_space_page_size(fcpl, (hsize_t)8192) < 0) - return -1; - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) - return -1; - if(H5Fclose(fid) < 0) - return -1; - if(H5Pclose(fcpl) < 0) - return -1; + /* Create file creation property list */ + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + return -1; + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)3) < 0) + return -1; + if (H5Pset_file_space_page_size(fcpl, (hsize_t)8192) < 0) + return -1; + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) + return -1; + if (H5Fclose(fid) < 0) + return -1; + if (H5Pclose(fcpl) < 0) + return -1; - /* - * #5 -- h5repack_fsm_aggr_threshold.h5 - * Setting: - * strategy=FSM_AGGR, persist=FALSE, threshold=3 - * inpage=4096 - */ + /* + * #5 -- h5repack_fsm_aggr_threshold.h5 + * Setting: + * strategy=FSM_AGGR, persist=FALSE, threshold=3 + * inpage=4096 + */ - /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - return -1; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, FALSE, (hsize_t)3) < 0) - return -1; - if(H5Pset_file_space_page_size(fcpl, (hsize_t)FS_PAGESIZE_DEF) < 0) - return -1; - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) - return -1; - if(H5Fclose(fid) < 0) - return -1; - if(H5Pclose(fcpl) < 0) - return -1; + /* Create file creation property list */ + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + return -1; + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, FALSE, (hsize_t)3) < 0) + return -1; + if (H5Pset_file_space_page_size(fcpl, (hsize_t)FS_PAGESIZE_DEF) < 0) + return -1; + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + return -1; + if (H5Fclose(fid) < 0) + return -1; + if (H5Pclose(fcpl) < 0) + return -1; - /* - * #6 -- h5repack_aggr.h5 - * Setting: - * strategy=AGGR, persist=FALSE, threshold=1 - * latest format - */ + /* + * #6 -- h5repack_aggr.h5 + * Setting: + * strategy=AGGR, persist=FALSE, threshold=1 + * latest format + */ - /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - return -1; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_AGGR, FALSE, (hsize_t)1) < 0) - return -1; - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) - return -1; - if(H5Fclose(fid) < 0) - return -1; - if(H5Pclose(fcpl) < 0) - return -1; + /* Create file creation property list */ + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + return -1; + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_AGGR, FALSE, (hsize_t)1) < 0) + return -1; + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) + return -1; + if (H5Fclose(fid) < 0) + return -1; + if (H5Pclose(fcpl) < 0) + return -1; + } /* * #7 -- h5repack_none.h5 @@ -2174,21 +2155,21 @@ int make_testfiles(void) */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) return -1; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_NONE, FALSE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_NONE, FALSE, (hsize_t)1) < 0) return -1; - if(H5Pset_file_space_page_size(fcpl, (hsize_t)8192) < 0) + if (H5Pset_file_space_page_size(fcpl, (hsize_t)8192) < 0) return -1; HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) return -1; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) return -1; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) return -1; return 0; @@ -2198,47 +2179,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; @@ -2254,9 +2232,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) @@ -2269,27 +2247,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; @@ -2317,58 +2295,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) @@ -2387,59 +2365,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; @@ -2456,635 +2433,708 @@ 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}; - int buf[DIM1][DIM2]; - int i, j, n; - int szip_can_encode = 0; - - for (i = n = 0; i < DIM1; i++) { - for (j = 0; j < DIM2; j++) { - buf[i][j] = n++; - } - } + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int szip_can_encode = 0; + + /* Create and fill array */ + struct { + int arr[DIM1][DIM2]; + } *buf = malloc(sizeof(*buf)); + if (NULL == buf) + goto error; + H5TEST_FILL_2D_HEAP_ARRAY(buf, int); + /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) - return -1; + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + goto error; /* create a dcpl */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto out; + goto error; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) - goto out; + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + goto error; /*------------------------------------------------------------------------- - * 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) - goto out; + if (H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block) < 0) + goto error; if (make_dset(loc_id, "dset_szip", sid, dcpl, buf) < 0) - goto out; + goto error; } else /* WARNING? SZIP is decoder only, can't generate test files */ - if(H5Sclose(sid) < 0) - goto out; - if(H5Pclose(dcpl) < 0) - goto out; + if (H5Sclose(sid) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; + + HDfree(buf); return 0; -out: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; + + HDfree(buf); + 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}; - int buf[DIM1][DIM2]; + 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}; hobj_ref_t bufref[1]; /* reference */ hsize_t dims1r[1] = {1}; - int i, j, n; - for (i = n = 0; i < DIM1; i++) { - for (j = 0; j < DIM2; j++) { - buf[i][j] = n++; - } - } + /* Create and fill array */ + struct { + int arr[DIM1][DIM2]; + } *buf = malloc(sizeof(*buf)); + if (NULL == buf) + goto error; + H5TEST_FILL_2D_HEAP_ARRAY(buf, int); /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) - return -1; + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + goto error; /* create a dcpl */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto out; + goto error; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) - goto out; + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + goto error; - /*------------------------------------------------------------------------- - * GZIP - *------------------------------------------------------------------------- - */ -#if defined (H5_HAVE_FILTER_DEFLATE) + /*------------------------------------------------------------------------- + * GZIP + *------------------------------------------------------------------------- + */ +#if defined(H5_HAVE_FILTER_DEFLATE) /* set deflate data */ - if(H5Pset_deflate(dcpl, 9) < 0) - goto out; + if (H5Pset_deflate(dcpl, 9) < 0) + goto error; if (make_dset(loc_id, "dset_deflate", sid, dcpl, buf) < 0) - goto out; + goto error; /* create a reference to the dataset, test second seeep of file for references */ if (H5Rcreate(&bufref[0], loc_id, "dset_deflate", H5R_OBJECT, (hid_t)-1) < 0) - goto out; + goto error; if (write_dset(loc_id, 1, dims1r, "ref", H5T_STD_REF_OBJ, bufref) < 0) - goto out; + goto error; #endif - /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) - goto out; - if(H5Pclose(dcpl) < 0) - goto out; + * close space and dcpl + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; + + HDfree(buf); return 0; -out: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; + + HDfree(buf); + 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; - - for (i=n=0; i<DIM1; i++) - { - for (j=0; j<DIM2; j++) - { - buf[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}; + + /* Create and fill array */ + struct { + int arr[DIM1][DIM2]; + } *buf = malloc(sizeof(*buf)); + if (NULL == buf) + goto error; + H5TEST_FILL_2D_HEAP_ARRAY(buf, int); + /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) - return -1; + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + goto error; /* create a dcpl */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto out; + goto error; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) - goto out; + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + goto error; /*------------------------------------------------------------------------- - * shuffle - *------------------------------------------------------------------------- - */ + * shuffle + *------------------------------------------------------------------------- + */ /* set the shuffle filter */ if (H5Pset_shuffle(dcpl) < 0) - goto out; - if (make_dset(loc_id,"dset_shuffle",sid,dcpl,buf) < 0) - goto out; - + goto error; + if (make_dset(loc_id, "dset_shuffle", sid, dcpl, buf) < 0) + goto error; /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) - goto out; - if(H5Pclose(dcpl) < 0) - goto out; + * close space and dcpl + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; + + HDfree(buf); return 0; -out: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; + + HDfree(buf); + 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; - - for (i = n = 0; i < DIM1; i++) { - for (j = 0; j < DIM2; j++) { - buf[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}; + + /* Create and fill array */ + struct { + int arr[DIM1][DIM2]; + } *buf = malloc(sizeof(*buf)); + if (NULL == buf) + goto error; + H5TEST_FILL_2D_HEAP_ARRAY(buf, int); + /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) - return -1; + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + goto error; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto out; + goto error; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) - goto out; - + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + goto error; /*------------------------------------------------------------------------- - * fletcher32 - *------------------------------------------------------------------------- - */ + * fletcher32 + *------------------------------------------------------------------------- + */ /* remove the filters from the dcpl */ - if (H5Premove_filter(dcpl,H5Z_FILTER_ALL) < 0) - goto out; + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) + goto error; /* set the checksum filter */ if (H5Pset_fletcher32(dcpl) < 0) - goto out; - if (make_dset(loc_id,"dset_fletcher32",sid,dcpl,buf) < 0) - goto out; + goto error; + if (make_dset(loc_id, "dset_fletcher32", sid, dcpl, buf) < 0) + goto error; /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) - goto out; - if(H5Pclose(dcpl) < 0) - goto out; + * close space and dcpl + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; + + HDfree(buf); return 0; -out: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; + + HDfree(buf); + 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; - - for (i = n = 0; i < DIM1; i++) { - for (j = 0; j < DIM2; j++) { - buf[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; + hid_t dxpl = H5P_DEFAULT; + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + + /* Create and fill array */ + struct { + int arr[DIM1][DIM2]; + } *buf = malloc(sizeof(*buf)); + if (NULL == buf) + goto error; + H5TEST_FILL_2D_HEAP_ARRAY(buf, int); + /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) - return -1; + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + goto error; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto out; + goto error; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) - goto out; + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + goto error; + +#ifdef H5_HAVE_PARALLEL + /* Set up collective writes for parallel driver */ + if (h5_using_parallel_driver(NULL)) { + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; + if (H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE) < 0) + goto error; + } +#endif dtid = H5Tcopy(H5T_NATIVE_INT); - if (H5Tset_precision(dtid,(H5Tget_precision(dtid) - 1)) < 0) - goto out; + if (H5Tset_precision(dtid, (H5Tget_precision(dtid) - 1)) < 0) + goto error; /* remove the filters from the dcpl */ - if(H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) - goto out; - if(H5Pset_nbit(dcpl) < 0) - goto out; - 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) - goto out; + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) + goto error; + if (H5Pset_nbit(dcpl) < 0) + goto error; + if ((dsid = H5Dcreate2(loc_id, "dset_nbit", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf) < 0) + goto error; H5Dclose(dsid); - 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) - goto out; - if(H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto out; + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) + goto error; + if ((dsid = H5Dcreate2(loc_id, "dset_int31", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf) < 0) + goto error; H5Dclose(dsid); /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) - goto out; - if(H5Pclose(dcpl) < 0) - goto out; + * close + *------------------------------------------------------------------------- + */ + if (dxpl != H5P_DEFAULT && H5Pclose(dxpl) < 0) + goto error; + if (H5Sclose(sid) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; if (H5Tclose(dtid) < 0) - goto out; + goto error; + + HDfree(buf); return 0; -out: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Tclose(dtid); + H5Pclose(dxpl); H5Pclose(dcpl); H5Sclose(sid); H5Dclose(dsid); - } H5E_END_TRY; + } + H5E_END_TRY; + + HDfree(buf); + 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; - - for (i = n = 0; i < DIM1; i++) { - for (j = 0; j < DIM2; j++) { - buf[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; + hid_t dxpl = H5P_DEFAULT; + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + + /* Create and fill array */ + struct { + int arr[DIM1][DIM2]; + } *buf = malloc(sizeof(*buf)); + if (NULL == buf) + goto error; + H5TEST_FILL_2D_HEAP_ARRAY(buf, int); + /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) - return -1; + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + goto error; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto out; + goto error; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) - goto out; + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + goto error; + +#ifdef H5_HAVE_PARALLEL + /* Set up collective writes for parallel driver */ + if (h5_using_parallel_driver(NULL)) { + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; + if (H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE) < 0) + goto error; + } +#endif dtid = H5Tcopy(H5T_NATIVE_INT); /* remove the filters from the dcpl */ - if(H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) - goto out; - 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) - goto out; - if(H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto out; + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) + goto error; + if (H5Pset_scaleoffset(dcpl, H5Z_SO_INT, 31) < 0) + goto error; + if ((dsid = H5Dcreate2(loc_id, "dset_scaleoffset", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf) < 0) + goto error; H5Dclose(dsid); - 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) - goto out; + if ((dsid = H5Dcreate2(loc_id, "dset_none", dtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf) < 0) + goto error; H5Tclose(dtid); H5Dclose(dsid); /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) - goto out; - if(H5Pclose(dcpl) < 0) - goto out; + * close space, dxpl and dcpl + *------------------------------------------------------------------------- + */ + if (dxpl != H5P_DEFAULT && H5Pclose(dxpl) < 0) + goto error; + if (H5Sclose(sid) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; + + HDfree(buf); return 0; -out: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { + H5Pclose(dxpl); H5Dclose(dsid); H5Tclose(dtid); H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; + + HDfree(buf); + 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 = 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; + 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; + hid_t dxpl = H5P_DEFAULT; +#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}; +#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++; - } - } + /* Create and fill array */ + struct { + int arr[DIM1][DIM2]; + } *buf = malloc(sizeof(*buf)); + if (NULL == buf) + goto error; + H5TEST_FILL_2D_HEAP_ARRAY(buf, int); + /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) - return -1; + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + goto error; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto out; + goto error; /* set up chunk */ if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) - goto out; + goto error; + +#ifdef H5_HAVE_PARALLEL + /* Set up collective writes for parallel driver */ + if (h5_using_parallel_driver(NULL)) { + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; + if (H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE) < 0) + goto error; + } +#endif /* set the shuffle filter */ if (H5Pset_shuffle(dcpl) < 0) - goto out; + goto error; /* set the checksum filter */ if (H5Pset_fletcher32(dcpl) < 0) - goto out; + goto error; -#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) - goto out; - } else { + if (H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block) < 0) + goto error; + } + 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) - goto out; + if (H5Pset_deflate(dcpl, 9) < 0) + goto error; #endif - if (make_dset(loc_id,"dset_all",sid,dcpl,buf) < 0) - goto out; + if (make_dset(loc_id, "dset_all", sid, dcpl, buf) < 0) + goto error; /* remove the filters from the dcpl */ - if (H5Premove_filter(dcpl,H5Z_FILTER_ALL) < 0) - goto out; + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) + goto error; /* set the checksum filter */ if (H5Pset_fletcher32(dcpl) < 0) - goto out; - if (make_dset(loc_id,"dset_fletcher32",sid,dcpl,buf) < 0) - goto out; - + goto error; + if (make_dset(loc_id, "dset_fletcher32", sid, dcpl, buf) < 0) + goto error; - /* 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) - goto out; + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) + goto error; /* set szip data */ - 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; - } else - { + if (H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block) < 0) + goto error; + if (make_dset(loc_id, "dset_szip", sid, dcpl, buf) < 0) + goto error; + } + 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) - goto out; + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) + goto error; /* set the shuffle filter */ if (H5Pset_shuffle(dcpl) < 0) - goto out; - if (make_dset(loc_id,"dset_shuffle",sid,dcpl,buf) < 0) - goto out; + goto error; + if (make_dset(loc_id, "dset_shuffle", sid, dcpl, buf) < 0) + goto error; - -#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) - goto out; + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) + goto error; /* set deflate data */ - if(H5Pset_deflate(dcpl, 1) < 0) - goto out; - if (make_dset(loc_id,"dset_deflate",sid,dcpl,buf) < 0) - goto out; + if (H5Pset_deflate(dcpl, 1) < 0) + goto error; + if (make_dset(loc_id, "dset_deflate", sid, dcpl, buf) < 0) + goto error; #endif - - /* remove the filters from the dcpl */ if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) - goto out; + goto error; /* set the shuffle filter */ if (H5Pset_nbit(dcpl) < 0) - goto out; + goto error; if ((dtid = H5Tcopy(H5T_NATIVE_INT)) < 0) - goto out; + goto error; 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) - goto out; - if(H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto out; + goto error; + if ((dsid = H5Dcreate2(loc_id, "dset_nbit", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf) < 0) + goto error; /* close */ - if(H5Tclose(dtid) < 0) - goto out; - if(H5Dclose(dsid) < 0) - goto out; + if (H5Tclose(dtid) < 0) + goto error; + if (H5Dclose(dsid) < 0) + goto error; - if(H5Sclose(sid) < 0) - goto out; - if(H5Pclose(dcpl) < 0) - goto out; + if (H5Sclose(sid) < 0) + goto error; + if (dxpl != H5P_DEFAULT && H5Pclose(dxpl) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; + + HDfree(buf); return 0; -out: +error: H5E_BEGIN_TRY { H5Tclose(dtid); H5Dclose(dsid); + H5Pclose(dxpl); H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; - return -1; -} + } + H5E_END_TRY; + HDfree(buf); + 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[16]; - int iter=100; + int iter = 100; if ((fid = H5Fcreate(FNAME5, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; @@ -3100,8 +3150,7 @@ 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) @@ -3122,15 +3171,14 @@ 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; HDsprintf(name, "%d", i); @@ -3157,113 +3205,107 @@ 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[16]; - + 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 i; + char name[16]; - for (i=n=0; i<DIM1; i++) - { - for (j=0; j<DIM2; j++) - { - buf[i][j]=n++; - } - } + /* Create and fill array */ + struct { + int arr[DIM1][DIM2]; + } *buf = malloc(sizeof(*buf)); + if (NULL == buf) + goto error; + H5TEST_FILL_2D_HEAP_ARRAY(buf, int); /*------------------------------------------------------------------------- - * 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 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) + goto error; } - /*------------------------------------------------------------------------- - * 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) - return -1; + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + goto error; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - { - goto out; - } + goto error; /*------------------------------------------------------------------------- - * H5D_COMPACT - *------------------------------------------------------------------------- - */ - if(H5Pset_layout (dcpl,H5D_COMPACT) < 0) - goto out; - if (make_dset(loc_id,"dset_compact",sid,dcpl,buf) < 0) - { - goto out; - } + * H5D_COMPACT + *------------------------------------------------------------------------- + */ + if (H5Pset_layout(dcpl, H5D_COMPACT) < 0) + goto error; + if (make_dset(loc_id, "dset_compact", sid, dcpl, buf) < 0) + goto error; /*------------------------------------------------------------------------- - * H5D_CONTIGUOUS - *------------------------------------------------------------------------- - */ - if(H5Pset_layout (dcpl,H5D_CONTIGUOUS) < 0) - goto out; - if (make_dset(loc_id,"dset_contiguous",sid,dcpl,buf) < 0) - { - goto out; - } + * H5D_CONTIGUOUS + *------------------------------------------------------------------------- + */ + if (H5Pset_layout(dcpl, H5D_CONTIGUOUS) < 0) + goto error; + if (make_dset(loc_id, "dset_contiguous", sid, dcpl, buf) < 0) + goto error; /*------------------------------------------------------------------------- - * H5D_CHUNKED - *------------------------------------------------------------------------- - */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) - goto out; - if (make_dset(loc_id,"dset_chunk",sid,dcpl,buf) < 0) - { - goto out; - } + * H5D_CHUNKED + *------------------------------------------------------------------------- + */ + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + goto error; + if (make_dset(loc_id, "dset_chunk", sid, dcpl, buf) < 0) + goto error; /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) - goto out; - if(H5Pclose(dcpl) < 0) - goto out; + * close space and dcpl + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; + + HDfree(buf); return 0; -out: +error: H5E_BEGIN_TRY { H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; + + HDfree(buf); + return -1; } @@ -3277,202 +3319,197 @@ 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 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 */ - - for(i = n = 0; i < S_DIM1; i++) { - for (j = 0; j < S_DIM2; j++) { - s_buf[i][j] = n++; - } - } + /* Create and fill array */ + struct { + int arr[S_DIM1][S_DIM2]; + } *s_buf = malloc(sizeof(*s_buf)); + if (NULL == s_buf) + goto error; + H5TEST_FILL_2D_HEAP_ARRAY(s_buf, int); /* Create dataspaces */ - if((s_sid = H5Screate_simple(RANK, s_dims, NULL)) < 0) - goto out; + if ((s_sid = H5Screate_simple(RANK, s_dims, NULL)) < 0) + goto error; /* Create contiguous datasets */ - if((contig_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto out; - if(H5Pset_layout(contig_dcpl, H5D_CONTIGUOUS) < 0) - goto out; - if(make_dset(loc_id, CONTIG_S, s_sid, contig_dcpl, s_buf) < 0) - goto out; + if ((contig_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_layout(contig_dcpl, H5D_CONTIGUOUS) < 0) + goto error; + if (make_dset(loc_id, CONTIG_S, s_sid, contig_dcpl, s_buf) < 0) + goto error; /* Create chunked datasets */ - if((chunked_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto out; - 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) - goto out; + if ((chunked_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(chunked_dcpl, RANK, chunk_dims) < 0) + goto error; + if (make_dset(loc_id, CHUNKED_S_FIX, s_sid, chunked_dcpl, s_buf) < 0) + goto error; ret_value = 0; -out: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Pclose(contig_dcpl); H5Pclose(chunked_dcpl); H5Sclose(s_sid); + } + H5E_END_TRY; - } H5E_END_TRY; + HDfree(s_buf); - 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; - - /* init buf1 */ - 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++; - } - } - - /*------------------------------------------------------------------------- - * make chunked dataset with - * - dset maxdims are UNLIMIT - * - a chunk dim is bigger than dset dim - * - dset size bigger than compact max (64K) - *------------------------------------------------------------------------- - */ + 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}; + + /* Create arrays */ + struct { + int arr[DIM1_L3][DIM2_L3]; + } *buf1 = malloc(sizeof(*buf1)); + struct { + int arr[SDIM1_L3][SDIM2_L3]; + } *buf2 = malloc(sizeof(*buf2)); + + if (NULL == buf1 || NULL == buf2) + goto error; + + /* Fill arrays */ + H5TEST_FILL_2D_HEAP_ARRAY(buf1, int); + H5TEST_FILL_2D_HEAP_ARRAY(buf2, int); + + /*------------------------------------------------------------------------- + * 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) - return -1; + if ((sid1 = H5Screate_simple(RANK, dims1, maxdims)) < 0) + goto error; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl1 = H5Pcreate(H5P_DATASET_CREATE)) < 0) - { - goto out; - } + goto error; - if(H5Pset_chunk(dcpl1, RANK, chunk_dims1) < 0) - goto out; - if (make_dset(loc_id,"chunk_unlimit1",sid1,dcpl1,buf1) < 0) - { - goto out; - } + if (H5Pset_chunk(dcpl1, RANK, chunk_dims1) < 0) + goto error; + if (make_dset(loc_id, "chunk_unlimit1", sid1, dcpl1, buf1) < 0) + goto error; /*------------------------------------------------------------------------- - * 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) - return -1; + if ((sid2 = H5Screate_simple(RANK, dims2, maxdims)) < 0) + goto error; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto out; + goto error; - if(H5Pset_chunk(dcpl2, RANK, chunk_dims2) < 0) - goto out; + if (H5Pset_chunk(dcpl2, RANK, chunk_dims2) < 0) + goto error; - if (make_dset(loc_id,"chunk_unlimit2",sid2,dcpl2,buf2) < 0) - goto out; + if (make_dset(loc_id, "chunk_unlimit2", sid2, dcpl2, buf2) < 0) + goto error; /*------------------------------------------------------------------------- - * 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; + goto error; - if(H5Pset_chunk(dcpl3, RANK, chunk_dims3) < 0) - goto out; + if (H5Pset_chunk(dcpl3, RANK, chunk_dims3) < 0) + goto error; - if (make_dset(loc_id,"chunk_unlimit3",sid2,dcpl3,buf2) < 0) - goto out; + if (make_dset(loc_id, "chunk_unlimit3", sid2, dcpl3, buf2) < 0) + goto error; /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid1) < 0) - goto out; - if(H5Sclose(sid2) < 0) - goto out; - if(H5Pclose(dcpl1) < 0) - goto out; - if(H5Pclose(dcpl2) < 0) - goto out; - if(H5Pclose(dcpl3) < 0) - goto out; + * close space and dcpl + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid1) < 0) + goto error; + if (H5Sclose(sid2) < 0) + goto error; + if (H5Pclose(dcpl1) < 0) + goto error; + if (H5Pclose(dcpl2) < 0) + goto error; + if (H5Pclose(dcpl3) < 0) + goto error; + + HDfree(buf1); + HDfree(buf2); return 0; -out: +error: H5E_BEGIN_TRY { H5Sclose(sid1); @@ -3480,183 +3517,189 @@ out: H5Pclose(dcpl1); H5Pclose(dcpl2); H5Pclose(dcpl3); - } H5E_END_TRY; + } + H5E_END_TRY; + + HDfree(buf1); + HDfree(buf2); + 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; @@ -3667,51 +3710,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 */ - char ub[USERBLOCK_SIZE]; /* User block data */ - ssize_t nwritten; /* # of bytes written */ - size_t u; /* Local index variable */ + 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 H5_ATTR_NDEBUG_UNUSED 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)) < 0) + if ((fd = HDopen(FNAME16, O_WRONLY)) < 0) goto out; /* Write userblock data */ @@ -3724,58 +3766,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 */ - 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 */ + 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 H5_ATTR_NDEBUG_UNUSED 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) + if ((fd = HDopen(filename, O_RDONLY)) < 0) goto out; /* Read userblock data */ @@ -3783,8 +3826,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 */ @@ -3793,38 +3836,39 @@ 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) { - 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 */ + int fd = -1; /* File descriptor for writing userblock */ + char ub[USERBLOCK_SIZE]; /* User block data */ + ssize_t H5_ATTR_NDEBUG_UNUSED nwritten; /* # of bytes written */ + 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, H5_POSIX_CREATE_MODE_RW)) < 0) + if ((fd = HDopen(FNAME_UB, O_WRONLY | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) goto out; /* write userblock data */ @@ -3838,147 +3882,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 + * + * 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; } @@ -3988,45 +4020,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; } @@ -4034,38 +4064,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; @@ -4079,7 +4108,7 @@ int write_dset_in(hid_t loc_id, goto out; if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5) < 0) goto out; - if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5) < 0) + if (H5Treclaim(tid, sid, H5P_DEFAULT, buf5) < 0) goto out; if (H5Dclose(did) < 0) goto out; @@ -4089,13 +4118,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; } @@ -4108,27 +4137,26 @@ 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) - { - HDprintf ("\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; } @@ -4159,107 +4187,100 @@ int write_dset_in(hid_t loc_id, } /*------------------------------------------------------------------------- - * 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) @@ -4267,36 +4288,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++; @@ -4312,7 +4333,7 @@ int write_dset_in(hid_t loc_id, goto out; if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf52) < 0) goto out; - if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52) < 0) + if (H5Treclaim(tid, sid, H5P_DEFAULT, buf52) < 0) goto out; if (H5Dclose(did) < 0) goto out; @@ -4322,16 +4343,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) @@ -4340,17 +4359,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) @@ -4367,49 +4384,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++); @@ -4417,37 +4431,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; } @@ -4459,25 +4472,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) @@ -4485,37 +4496,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++; @@ -4533,7 +4544,7 @@ int write_dset_in(hid_t loc_id, if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf53) < 0) goto out; - if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53) < 0) + if (H5Treclaim(tid, sid, H5P_DEFAULT, buf53) < 0) goto out; if (H5Dclose(did) < 0) @@ -4544,15 +4555,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++; @@ -4567,76 +4577,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 */ @@ -4644,7 +4655,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++) @@ -4659,24 +4671,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 */ @@ -4692,9 +4708,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 @@ -4703,105 +4719,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 + * + * 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'; } } /* @@ -4820,21 +4827,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}; @@ -4850,16 +4856,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}; @@ -4877,22 +4883,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; } } @@ -4909,43 +4914,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; } } /* @@ -4960,33 +4961,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; @@ -5009,29 +5009,27 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Awrite(aid, tid, buf5) < 0) goto out; - if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5) < 0) + if (H5Treclaim(tid, sid, H5P_DEFAULT, buf5) < 0) 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; } } /* @@ -5054,19 +5052,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; } } @@ -5084,23 +5080,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); } @@ -5128,20 +5122,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); } /* @@ -5158,19 +5151,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}}; @@ -5189,19 +5181,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); } /* @@ -5218,47 +5209,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; } } @@ -5276,31 +5264,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++; @@ -5331,26 +5319,25 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Awrite(aid, tid, buf52) < 0) goto out; - if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52) < 0) + if (H5Treclaim(tid, sid, H5P_DEFAULT, buf52) < 0) 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}}; @@ -5384,15 +5371,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); } @@ -5418,25 +5404,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); } /* @@ -5500,22 +5484,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++); @@ -5554,36 +5538,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; } @@ -5646,58 +5630,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; } } } @@ -5732,35 +5706,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) @@ -5793,29 +5763,29 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Awrite(aid, tid, buf53) < 0) goto out; - if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53) < 0) + if (H5Treclaim(tid, sid, H5P_DEFAULT, buf53) < 0) 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++; } } /* @@ -5837,26 +5807,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++; } @@ -5879,93 +5845,109 @@ 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 + * + * 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; + hid_t dxpl_id = H5P_DEFAULT; if ((did = H5Dcreate2(loc_id, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) return -1; - if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + +#ifdef H5_HAVE_PARALLEL + /* Set up collective writes for parallel driver */ + if (h5_using_parallel_driver(NULL)) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto out; + if (H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0) + goto out; + } +#endif + + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, buf) < 0) + goto out; + if (dxpl_id != H5P_DEFAULT && H5Pclose(dxpl_id) < 0) goto out; if (H5Dclose(did) < 0) return -1; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); - } H5E_END_TRY; + } + 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 + * + * 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; + hid_t dxpl_id = H5P_DEFAULT; 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) { +#ifdef H5_HAVE_PARALLEL + /* Set up collective writes for parallel driver */ + if (h5_using_parallel_driver(NULL)) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto out; + if (H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0) + goto out; + } +#endif + + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, dxpl_id, buf) < 0) goto out; } + if (dxpl_id != H5P_DEFAULT && H5Pclose(dxpl_id) < 0) + goto out; if (H5Dclose(did) < 0) goto out; if (H5Sclose(sid) < 0) @@ -5974,44 +5956,39 @@ int write_dset( hid_t loc_id, return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { + H5Pclose(dxpl_id); 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 + * + * 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) @@ -6021,119 +5998,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 */ @@ -6150,7 +6128,8 @@ out: H5Sclose(sid); H5Dclose(did); H5Gclose(gid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end make_named_dtype() */ @@ -6167,49 +6146,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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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; } @@ -6217,7 +6193,6 @@ static herr_t add_attr_with_objref(hid_t file_id, hid_t obj_id) out: return ret; - } /*------------------------------------------------------------------------- @@ -6232,63 +6207,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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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; - } /*------------------------------------------------------------------------- @@ -6302,45 +6272,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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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; } @@ -6349,10 +6317,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) - { - HDfprintf(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; } @@ -6361,62 +6328,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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); + /* create normal dataset which is referred */ + 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) - { - HDfprintf(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; - } /*------------------------------------------------------------------------- @@ -6426,21 +6387,22 @@ out: * Generate object references to objects (dataset,group and named datatype) * * Note: - * copied from h5copygentest.c and upate to create named datatype + * copied from h5copygentest.c and update to create named datatype * * 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]; @@ -6450,28 +6412,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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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; } @@ -6479,62 +6438,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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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 * @@ -6545,168 +6498,158 @@ 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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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) - { + 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) - { + 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) - { + if (status == FAIL) { HDfprintf(stderr, "Failed to generate region reference.\n"); ret = FAIL; } @@ -6715,110 +6658,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 */ @@ -6829,9 +6769,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) - { - HDfprintf(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; } @@ -6839,22 +6778,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) - { - HDfprintf(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) - { - HDfprintf(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; } @@ -6864,12 +6800,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) - { - HDfprintf(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; } @@ -6881,7 +6817,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); @@ -6889,31 +6825,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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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; } @@ -6922,12 +6855,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) - { - HDfprintf(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; } @@ -6938,7 +6871,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); @@ -6946,17 +6879,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) - { - HDfprintf(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) - { - HDfprintf(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; } @@ -6965,81 +6896,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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(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) - { - HDfprintf(stderr, "Error: %s %d> H5Dvlen_reclaim failed.\n", FUNC, __LINE__); + status = H5Treclaim(vlen_objref_attr_tid, vlen_objref_attr_sid, H5P_DEFAULT, vlen_objref_data); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Treclaim failed.\n", __func__, __LINE__); ret = FAIL; goto out; } @@ -7052,22 +6981,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) - { - HDfprintf(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) - { - HDfprintf(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; } @@ -7081,20 +7009,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) - { - HDfprintf(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) - { - HDfprintf(stderr, "Error: %s %d> H5Dvlen_reclaim failed.\n", FUNC, __LINE__); + status = H5Treclaim(vlen_regref_attr_tid, vlen_regref_attr_sid, H5P_DEFAULT, vlen_regref_data); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Treclaim failed.\n", __func__, __LINE__); ret = FAIL; goto out; } diff --git a/tools/test/h5repack/testfiles/README b/tools/test/h5repack/testfiles/README index 4096dee..4cb66f4 100644 --- a/tools/test/h5repack/testfiles/README +++ b/tools/test/h5repack/testfiles/README @@ -1,5 +1,5 @@ h5repack_nested_8bit_enum_deflated.h5: h5repack_nested_8bit_enum.h5: - enuberated 8bit type nested in compount type. Original file provided + enuberated 8bit type nested in compound type. Original file provided by a user (HDFFV-8667) as a test file. Used h5copy to extract only the Compound type dataset. The non-deflated version is produced by h5repack. diff --git a/tools/test/h5repack/testfiles/attrregion.tattrreg.h5.ddl b/tools/test/h5repack/testfiles/attrregion.tattrreg.h5.ddl new file mode 100644 index 0000000..7cab02b --- /dev/null +++ b/tools/test/h5repack/testfiles/attrregion.tattrreg.h5.ddl @@ -0,0 +1,46 @@ +HDF5 "out-attrregion.tattrreg.h5" { +GROUP "/" { + DATASET "Dataset1" { + DATATYPE H5T_STD_I32LE + DATASPACE NULL + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 0 + OFFSET HADDR_UNDEF + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + ATTRIBUTE "Attribute1" { + DATATYPE H5T_REFERENCE { H5T_STD_REF_DSETREG } + DATASPACE SIMPLE { ( 4 ) / ( 4 ) } + } + } + DATASET "Dataset2" { + DATATYPE H5T_STD_U8BE + DATASPACE SIMPLE { ( 10, 10 ) / ( 10, 10 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 100 + OFFSET 2048 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } +} +} diff --git a/tools/test/h5repack/testfiles/dataregion.tdatareg.h5.ddl b/tools/test/h5repack/testfiles/dataregion.tdatareg.h5.ddl new file mode 100644 index 0000000..bd31118 --- /dev/null +++ b/tools/test/h5repack/testfiles/dataregion.tdatareg.h5.ddl @@ -0,0 +1,42 @@ +HDF5 "out-dataregion.tdatareg.h5" { +GROUP "/" { + DATASET "Dataset1" { + DATATYPE H5T_REFERENCE { H5T_STD_REF_DSETREG } + DATASPACE SIMPLE { ( 4 ) / ( 4 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 48 + OFFSET 6244 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_UNDEFINED + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + DATASET "Dataset2" { + DATATYPE H5T_STD_U8BE + DATASPACE SIMPLE { ( 10, 10 ) / ( 10, 10 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 100 + OFFSET 2048 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_UNDEFINED + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } +} +} diff --git a/tools/test/h5repack/testfiles/h5copy_extlinks_src-base.h5copy_extlinks_src.h5.ddl b/tools/test/h5repack/testfiles/h5copy_extlinks_src-base.h5copy_extlinks_src.h5.ddl new file mode 100644 index 0000000..ad8a320 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5copy_extlinks_src-base.h5copy_extlinks_src.h5.ddl @@ -0,0 +1,28 @@ +HDF5 "out-h5copy_extlinks_src-mergeprune.h5copy_extlinks_src.h5" { +GROUP "/" { + GROUP "group_ext" { + DATATYPE "extlink_datatype" H5T_STD_I32LE; + DATASET "extlink_dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 2200 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + GROUP "extlink_grp" { + } + } +} +} diff --git a/tools/test/h5repack/testfiles/h5copy_extlinks_src-merge.h5copy_extlinks_src.h5.tst b/tools/test/h5repack/testfiles/h5copy_extlinks_src-merge.h5copy_extlinks_src.h5.tst new file mode 100644 index 0000000..52f215d --- /dev/null +++ b/tools/test/h5repack/testfiles/h5copy_extlinks_src-merge.h5copy_extlinks_src.h5.tst @@ -0,0 +1,26 @@ + +file1 file2 +--------------------------------------- + x x / + x x /group_ext + x x /group_ext/extlink_datatype + x x /group_ext/extlink_dset + x x /group_ext/extlink_grp + x x /group_ext/extlink_notyet1 + x x /group_ext/extlink_notyet2 + +group : </> and </> +0 differences found +group : </group_ext> and </group_ext> +0 differences found +Not comparable: </group_ext/extlink_datatype> is of type H5G_UDLINK and </group_ext/extlink_datatype> is of type H5G_TYPE +Not comparable: </group_ext/extlink_dset> is of type H5G_UDLINK and </group_ext/extlink_dset> is of type H5G_DATASET +Not comparable: </group_ext/extlink_grp> is of type H5G_UDLINK and </group_ext/extlink_grp> is of type H5G_GROUP +external link: </group_ext/extlink_notyet1> and </group_ext/extlink_notyet1> +0 differences found +external link: </group_ext/extlink_notyet2> and </group_ext/extlink_notyet2> +0 differences found +-------------------------------- +Some objects are not comparable +-------------------------------- +Use -c for a list of objects without details of differences. diff --git a/tools/test/h5repack/testfiles/h5copy_extlinks_src-mergeprune.h5copy_extlinks_src.h5.ddl b/tools/test/h5repack/testfiles/h5copy_extlinks_src-mergeprune.h5copy_extlinks_src.h5.ddl new file mode 100644 index 0000000..ad8a320 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5copy_extlinks_src-mergeprune.h5copy_extlinks_src.h5.ddl @@ -0,0 +1,28 @@ +HDF5 "out-h5copy_extlinks_src-mergeprune.h5copy_extlinks_src.h5" { +GROUP "/" { + GROUP "group_ext" { + DATATYPE "extlink_datatype" H5T_STD_I32LE; + DATASET "extlink_dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 2200 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + GROUP "extlink_grp" { + } + } +} +} diff --git a/tools/test/h5repack/testfiles/h5copy_extlinks_src-prune.h5copy_extlinks_src.h5.ddl b/tools/test/h5repack/testfiles/h5copy_extlinks_src-prune.h5copy_extlinks_src.h5.ddl new file mode 100644 index 0000000..b7d7bca --- /dev/null +++ b/tools/test/h5repack/testfiles/h5copy_extlinks_src-prune.h5copy_extlinks_src.h5.ddl @@ -0,0 +1,6 @@ +HDF5 "out-h5copy_extlinks_src-prune.h5copy_extlinks_src.h5" { +GROUP "/" { + GROUP "group_ext" { + } +} +} diff --git a/tools/test/h5repack/testfiles/h5copy_extlinks_src.h5 b/tools/test/h5repack/testfiles/h5copy_extlinks_src.h5 Binary files differnew file mode 100644 index 0000000..7b8621e --- /dev/null +++ b/tools/test/h5repack/testfiles/h5copy_extlinks_src.h5 diff --git a/tools/test/h5repack/testfiles/h5copy_extlinks_trg.h5 b/tools/test/h5repack/testfiles/h5copy_extlinks_trg.h5 Binary files differnew file mode 100644 index 0000000..3a0242d --- /dev/null +++ b/tools/test/h5repack/testfiles/h5copy_extlinks_trg.h5 diff --git a/tools/test/h5repack/testfiles/h5repack-help.txt b/tools/test/h5repack/testfiles/h5repack-help.txt index 2381865..bff70af 100644 --- a/tools/test/h5repack/testfiles/h5repack-help.txt +++ b/tools/test/h5repack/testfiles/h5repack-help.txt @@ -1,18 +1,51 @@ usage: h5repack [OPTIONS] file1 file2 file1 Input HDF5 File file2 Output HDF5 File + ERROR + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. OPTIONS -h, --help Print a usage message and exit - -v, --verbose Verbose mode, print object information + -v N, --verbose=N Verbose mode, print object information. + N - is an integer greater than 1, 2 displays read/write timing -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 + --src-vol-value Value (ID) of the VOL connector to use for opening the + input HDF5 file specified + --src-vol-name Name of the VOL connector to use for opening the input + HDF5 file specified + --src-vol-info VOL-specific info to pass to the VOL connector used for + opening the input HDF5 file specified + --dst-vol-value Value (ID) of the VOL connector to use for opening the + output HDF5 file specified + --dst-vol-name Name of the VOL connector to use for opening the output + HDF5 file specified + --dst-vol-info VOL-specific info to pass to the VOL connector used for + opening the output HDF5 file specified + --src-vfd-value Value (ID) of the VFL driver to use for opening the + input HDF5 file specified + --src-vfd-name Name of the VFL driver to use for opening the input + HDF5 file specified + --src-vfd-info VFD-specific info to pass to the VFL driver used for + opening the input HDF5 file specified + --dst-vfd-value Value (ID) of the VFL driver to use for opening the + output HDF5 file specified + --dst-vfd-name Name of the VFL driver to use for opening the output + HDF5 file specified + --dst-vfd-info VFD-specific info to pass to the VFL driver used for + opening the output HDF5 file specified -L, --latest Use latest version of file format - This option will take precedence over the -j and -k options - --low=BOUND The low bound for library release versions to use when creating - objects in the file (default is H5F_LIBVER_EARLIEST) - --high=BOUND The high bound for library release versions to use when creating - objects in the file (default is H5F_LIBVER_LATEST) + This option will take precedence over the options + --low and --high + --low=BOUND The low bound for library release versions to use + when creating objects in the file + (default is H5F_LIBVER_EARLIEST) + --high=BOUND The high bound for library release versions to use + when creating objects in the file + (default is H5F_LIBVER_LATEST) + --merge Follow external soft link recursively and merge data + --prune Do not follow external soft links and remove link + --merge --prune Follow external link, merge data and remove dangling link -c L1, --compact=L1 Maximum number of links in header messages -d L2, --indexed=L2 Minimum number of links in the indexed format -s S[:F], --ssize=S[:F] Shared object header message minimum size @@ -27,10 +60,14 @@ usage: h5repack [OPTIONS] file1 file2 -z Z, --sort_order=Z Sort groups and attributes by order Z -f FILT, --filter=FILT Filter type -l LAYT, --layout=LAYT Layout type - -S FS_STRATEGY, --fs_strategy=FS_STRATEGY File space management strategy for H5Pset_file_space_strategy - -P FS_PERSIST, --fs_persist=FS_PERSIST Persisting or not persisting free-space for H5Pset_file_space_strategy - -T FS_THRESHOLD, --fs_threshold=FS_THRESHOLD Free-space section threshold for H5Pset_file_space_strategy - -G FS_PAGESIZE, --fs_pagesize=FS_PAGESIZE File space page size for H5Pset_file_space_page_size + -S FS_STRATEGY, --fs_strategy=FS_STRATEGY File space management strategy for + H5Pset_file_space_strategy + -P FS_PERSIST, --fs_persist=FS_PERSIST Persisting or not persisting free- + space for H5Pset_file_space_strategy + -T FS_THRESHOLD, --fs_threshold=FS_THRESHOLD Free-space section threshold + for H5Pset_file_space_strategy + -G FS_PAGESIZE, --fs_pagesize=FS_PAGESIZE File space page size for + H5Pset_file_space_page_size M - is an integer greater than 1, size of dataset in bytes (default is 0) E - is a filename. @@ -38,41 +75,51 @@ 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 - BOUND is an integer indicating the library release versions to use when creating - objects in the file (see H5Pset_libver_bounds()): + BOUND is an integer indicating the library release versions to use when + creating objects in the file (see H5Pset_libver_bounds()): 0: This is H5F_LIBVER_EARLIEST in H5F_libver_t struct 1: This is H5F_LIBVER_V18 in H5F_libver_t struct 2: This is H5F_LIBVER_V110 in H5F_libver_t struct 3: This is H5F_LIBVER_V112 in H5F_libver_t struct - (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V112 for this release + 4: This is H5F_LIBVER_V114 in H5F_libver_t struct + (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V114 for this release FS_STRATEGY is a string indicating the file space strategy used: FSM_AGGR: - The mechanisms used in managing file space are free-space managers, aggregators and virtual file driver. + The mechanisms used in managing file space are free-space + managers, aggregators and virtual file driver. PAGE: - The mechanisms used in managing file space are free-space managers with embedded paged aggregation and virtual file driver. + The mechanisms used in managing file space are free-space + managers with embedded paged aggregation and virtual file driver. AGGR: - The mechanisms used in managing file space are aggregators and virtual file driver. + The mechanisms used in managing file space are aggregators and + virtual file driver. NONE: - The mechanisms used in managing file space are virtual file driver. - The default strategy when not set is FSM_AGGR without persisting free-space. + The mechanisms used in managing file space are virtual file + driver. + The default strategy when not set is FSM_AGGR without persisting free- + space. FS_PERSIST is 1 to persisting free-space or 0 to not persisting free-space. The default when not set is not persisting free-space. The value is ignored for AGGR and NONE strategies. - FS_THRESHOLD is the minimum size (in bytes) of free-space sections to be tracked by the library. + FS_THRESHOLD is the minimum size (in bytes) of free-space sections to be + tracked by the library. The default when not set is 1. The value is ignored for AGGR and NONE strategies. - FS_PAGESIZE is the size (in bytes) >=512 that is used by the library when the file space strategy PAGE is used. + FS_PAGESIZE is the size (in bytes) >=512 that is used by the library when + the file space strategy PAGE is used. The default when not set is 4096. FILT - is a string with the format: @@ -100,9 +147,10 @@ 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 + filter_flag: 1 is OPTIONAL or 0 is MANDATORY NONE (no parameter) LAYT - is a string with the format: @@ -139,12 +187,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 - -5) h5repack --low=0 --high=1 file1 file2 - - Set low=H5F_LIBVER_EARLIEST and high=H5F_LIBVER_V18 via H5Pset_libver_bounds() when - creating the repacked file: file2 + minimum shared datatype size of 20 5) h5repack -f SHUF -f GZIP=1 file1 file2 @@ -154,3 +197,8 @@ Examples of use: Add bzip2 filter to all datasets +7) h5repack --low=0 --high=1 file1 file2 + + Set low=H5F_LIBVER_EARLIEST and high=H5F_LIBVER_V18 via + H5Pset_libver_bounds() when creating the repacked file, file2 + diff --git a/tools/test/h5repack/testfiles/h5repack_CVE-2018-14460.h5 b/tools/test/h5repack/testfiles/h5repack_CVE-2018-14460.h5 Binary files differnew file mode 100644 index 0000000..f4093b5 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_CVE-2018-14460.h5 diff --git a/tools/test/h5repack/testfiles/h5repack_CVE-2018-17432.h5 b/tools/test/h5repack/testfiles/h5repack_CVE-2018-17432.h5 Binary files differnew file mode 100644 index 0000000..7a815ba --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_CVE-2018-17432.h5 diff --git a/tools/test/h5repack/testfiles/h5repack_f32le.h5 b/tools/test/h5repack/testfiles/h5repack_f32le.h5 Binary files differnew file mode 100644 index 0000000..03a9b57 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_f32le.h5 diff --git a/tools/test/h5repack/testfiles/h5repack_f32le_ex-0.dat b/tools/test/h5repack/testfiles/h5repack_f32le_ex-0.dat Binary files differnew file mode 100644 index 0000000..8378fc2 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_f32le_ex-0.dat diff --git a/tools/test/h5repack/testfiles/h5repack_f32le_ex.h5 b/tools/test/h5repack/testfiles/h5repack_f32le_ex.h5 Binary files differnew file mode 100644 index 0000000..ca6c49d --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_f32le_ex.h5 diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_1d.h5 b/tools/test/h5repack/testfiles/h5repack_int32le_1d.h5 Binary files differnew file mode 100644 index 0000000..7d60566 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_int32le_1d.h5 diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex-0.dat b/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex-0.dat new file mode 100644 index 0000000..f75ada5 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex-0.dat @@ -0,0 +1 @@ +úÿÿÿûÿÿÿüÿÿÿýÿÿÿþÿÿÿÿÿÿÿ
\ No newline at end of file diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex-1.dat b/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex-1.dat Binary files differnew file mode 100644 index 0000000..1f8f3b6 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex-1.dat diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex.h5 b/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex.h5 Binary files differnew file mode 100644 index 0000000..ba4b534 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex.h5 diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_2d.h5 b/tools/test/h5repack/testfiles/h5repack_int32le_2d.h5 Binary files differnew file mode 100644 index 0000000..2f32bd1 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_int32le_2d.h5 diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_2d_ex-0.dat b/tools/test/h5repack/testfiles/h5repack_int32le_2d_ex-0.dat Binary files differnew file mode 100644 index 0000000..c6bfc64 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_int32le_2d_ex-0.dat diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_2d_ex.h5 b/tools/test/h5repack/testfiles/h5repack_int32le_2d_ex.h5 Binary files differnew file mode 100644 index 0000000..f6cce59 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_int32le_2d_ex.h5 diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_3d.h5 b/tools/test/h5repack/testfiles/h5repack_int32le_3d.h5 Binary files differnew file mode 100644 index 0000000..7a61ef5 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_int32le_3d.h5 diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_3d_ex-0.dat b/tools/test/h5repack/testfiles/h5repack_int32le_3d_ex-0.dat Binary files differnew file mode 100644 index 0000000..b505eb4 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_int32le_3d_ex-0.dat diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_3d_ex.h5 b/tools/test/h5repack/testfiles/h5repack_int32le_3d_ex.h5 Binary files differnew file mode 100644 index 0000000..7c4b750 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_int32le_3d_ex.h5 diff --git a/tools/test/h5repack/testfiles/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst b/tools/test/h5repack/testfiles/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst index 4e69148..3d9f0c2 100644 --- a/tools/test/h5repack/testfiles/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst +++ b/tools/test/h5repack/testfiles/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst @@ -1,47 +1,50 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dcreate2(): unable to create dataset + #000: (file name) line (number) in H5Dcreate2(): unable to synchronously create dataset major: Dataset - minor: Unable to initialize object - #001: (file name) line (number) in H5VL_dataset_create(): dataset create failed + minor: Unable to create file + #001: (file name) line (number) in H5D__create_api_common(): unable to create dataset + major: Dataset + minor: Unable to create file + #002: (file name) line (number) in H5VL_dataset_create(): dataset create failed major: Virtual Object Layer minor: Unable to create file - #002: (file name) line (number) in H5VL__dataset_create(): dataset create failed + #003: (file name) line (number) in H5VL__dataset_create(): dataset create failed major: Virtual Object Layer minor: Unable to create file - #003: (file name) line (number) in H5VL__native_dataset_create(): unable to create dataset + #004: (file name) line (number) in H5VL__native_dataset_create(): unable to create dataset major: Dataset minor: Unable to initialize object - #004: (file name) line (number) in H5D__create_named(): unable to create and link to dataset + #005: (file name) line (number) in H5D__create_named(): unable to create and link to dataset major: Dataset minor: Unable to initialize object - #005: (file name) line (number) in H5L_link_object(): unable to create new link to object + #006: (file name) line (number) in H5L_link_object(): unable to create new link to object major: Links minor: Unable to initialize object - #006: (file name) line (number) in H5L__create_real(): can't insert link + #007: (file name) line (number) in H5L__create_real(): can't insert link major: Links minor: Unable to insert object - #007: (file name) line (number) in H5G_traverse(): internal path traversal failed + #008: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #008: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #009: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #009: (file name) line (number) in H5L__link_cb(): unable to create object + #010: (file name) line (number) in H5L__link_cb(): unable to create object major: Links minor: Unable to initialize object - #010: (file name) line (number) in H5O_obj_create(): unable to open object + #011: (file name) line (number) in H5O_obj_create(): unable to open object major: Object header minor: Can't open object - #011: (file name) line (number) in H5O__dset_create(): unable to create dataset + #012: (file name) line (number) in H5O__dset_create(): unable to create dataset major: Dataset minor: Unable to initialize object - #012: (file name) line (number) in H5D__create(): unable to construct layout information + #013: (file name) line (number) in H5D__create(): unable to construct layout information major: Dataset minor: Unable to initialize object - #013: (file name) line (number) in H5D__chunk_construct(): dimensionality of chunks doesn't match the dataspace + #014: (file name) line (number) in H5D__chunk_construct(): dimensionality of chunks doesn't match the dataspace major: Dataset minor: Bad value H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): #000: (file name) line (number) in do_copy_objects(): H5Dcreate2 failed major: Failure in tools library - minor: error in function + minor: function info diff --git a/tools/test/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl b/tools/test/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl index 3ff2170..0992a0c 100644 --- a/tools/test/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl +++ b/tools/test/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 11 6 } + PARAMS { 9 1 13 2 } } } FILLVALUE { @@ -33,7 +33,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 11 6 } + PARAMS { 9 1 13 2 } } } FILLVALUE { @@ -55,7 +55,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 11 6 } + PARAMS { 9 1 13 2 } } } FILLVALUE { @@ -77,7 +77,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 11 6 } + PARAMS { 9 1 13 2 } } } FILLVALUE { @@ -99,7 +99,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 11 6 } + PARAMS { 9 1 13 2 } } } FILLVALUE { @@ -121,7 +121,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 11 6 } + PARAMS { 9 1 13 2 } } } FILLVALUE { @@ -143,7 +143,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 11 6 } + PARAMS { 9 1 13 2 } } } FILLVALUE { diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be.h5 b/tools/test/h5repack/testfiles/h5repack_uint8be.h5 Binary files differnew file mode 100644 index 0000000..0e25211 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_uint8be.h5 diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-0.dat b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-0.dat Binary files differnew file mode 100644 index 0000000..f95b90a --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-0.dat diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-1.dat b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-1.dat new file mode 100644 index 0000000..011ab48 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-1.dat @@ -0,0 +1 @@ +@¿B½D»F¹H·JµL³N±P¯RT«V©X§Z¥\£^¡`Ÿbd›f™h—j•l“n‘prt‹v‰x‡z…|ƒ~
\ No newline at end of file diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-2.dat b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-2.dat new file mode 100644 index 0000000..069b96d --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-2.dat @@ -0,0 +1 @@ +€‚}„{†yˆwŠuŒsŽqo’m”k–i˜gšeœcža _¢]¤[¦Y¨WªU¬S®Q°O²M´K¶I¸GºE¼C¾A
\ No newline at end of file diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-3.dat b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-3.dat new file mode 100644 index 0000000..240d8ca --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-3.dat @@ -0,0 +1 @@ +À?Â=Ä;Æ9È7Ê5Ì3Î1Ð/Ò-Ô+Ö)Ø'Ú%Ü#Þ!àâäæèêìîðò
ôö øúüþ
\ No newline at end of file diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex.h5 b/tools/test/h5repack/testfiles/h5repack_uint8be_ex.h5 Binary files differnew file mode 100644 index 0000000..8787188 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_uint8be_ex.h5 diff --git a/tools/test/h5repack/testfiles/textlink-base.textlink.h5.ddl b/tools/test/h5repack/testfiles/textlink-base.textlink.h5.ddl new file mode 100644 index 0000000..b87a17d --- /dev/null +++ b/tools/test/h5repack/testfiles/textlink-base.textlink.h5.ddl @@ -0,0 +1,12 @@ +HDF5 "out-textlink-base.textlink.h5" { +GROUP "/" { + EXTERNAL_LINK "extlink1" { + TARGETFILE "filename" + TARGETPATH "objname" + } + EXTERNAL_LINK "extlink2" { + TARGETFILE "anotherfile" + TARGETPATH "anotherobj" + } +} +} diff --git a/tools/test/h5repack/testfiles/textlink-merge.textlink.h5.tst b/tools/test/h5repack/testfiles/textlink-merge.textlink.h5.tst new file mode 100644 index 0000000..a7ff71d --- /dev/null +++ b/tools/test/h5repack/testfiles/textlink-merge.textlink.h5.tst @@ -0,0 +1,13 @@ + +file1 file2 +--------------------------------------- + x x / + x x /extlink1 + x x /extlink2 + +group : </> and </> +0 differences found +external link: </extlink1> and </extlink1> +0 differences found +external link: </extlink2> and </extlink2> +0 differences found diff --git a/tools/test/h5repack/testfiles/textlink-mergeprune.textlink.h5.ddl b/tools/test/h5repack/testfiles/textlink-mergeprune.textlink.h5.ddl new file mode 100644 index 0000000..7206ae9 --- /dev/null +++ b/tools/test/h5repack/testfiles/textlink-mergeprune.textlink.h5.ddl @@ -0,0 +1,4 @@ +HDF5 "out-textlink-mergeprune.textlink.h5" { +GROUP "/" { +} +} diff --git a/tools/test/h5repack/testfiles/textlink-prune.textlink.h5.ddl b/tools/test/h5repack/testfiles/textlink-prune.textlink.h5.ddl new file mode 100644 index 0000000..83db344 --- /dev/null +++ b/tools/test/h5repack/testfiles/textlink-prune.textlink.h5.ddl @@ -0,0 +1,4 @@ +HDF5 "out-textlink-prune.textlink.h5" { +GROUP "/" { +} +} diff --git a/tools/test/h5repack/testfiles/textlinkfar-base.textlinkfar.h5.ddl b/tools/test/h5repack/testfiles/textlinkfar-base.textlinkfar.h5.ddl new file mode 100644 index 0000000..a5eb497 --- /dev/null +++ b/tools/test/h5repack/testfiles/textlinkfar-base.textlinkfar.h5.ddl @@ -0,0 +1,116 @@ +HDF5 "out-textlinkfar-base.textlinkfar.h5" { +GROUP "/" { + EXTERNAL_LINK "src_file" { + TARGETFILE "textlinksrc.h5" + TARGETPATH "/" + GROUP "/" { + EXTERNAL_LINK "ext2soft_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dset1" + DATASET "/soft_dset1" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 4, 2 ) / ( 4, 2 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 32 + OFFSET 2848 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + } + EXTERNAL_LINK "ext2softdangle_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dangle" + } + EXTERNAL_LINK "ext_link1" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group" + GROUP "group" { + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 3136 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + EXTERNAL_LINK "elink_t1" { + TARGETFILE "textlinksrc.h5" + TARGETPATH "/" + GROUP "/" { + HARDLINK "/" + } + } + EXTERNAL_LINK "elink_t2" { + TARGETFILE "textlinksrc.h5" + TARGETPATH "/ext_link4" + } + GROUP "subgroup" { + GROUP "link_to_group" { + HARDLINK "/group" + } + } + } + } + EXTERNAL_LINK "ext_link2" { + TARGETFILE "textlinktar.h5" + TARGETPATH "dset" + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 3160 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + } + EXTERNAL_LINK "ext_link3" { + TARGETFILE "textlinktar.h5" + TARGETPATH "type" + DATATYPE "type" H5T_STD_I32LE; + } + EXTERNAL_LINK "ext_link4" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group/elink_t2" + } + EXTERNAL_LINK "ext_link5" { + TARGETFILE "textlinktar.h5" + TARGETPATH "empty_group" + GROUP "empty_group" { + } + } + } + } +} +} diff --git a/tools/test/h5repack/testfiles/textlinkfar-merge.textlinkfar.h5.tst b/tools/test/h5repack/testfiles/textlinkfar-merge.textlinkfar.h5.tst new file mode 100644 index 0000000..6673d39 --- /dev/null +++ b/tools/test/h5repack/testfiles/textlinkfar-merge.textlinkfar.h5.tst @@ -0,0 +1,20 @@ + +file1 file2 +--------------------------------------- + x x / + x x /src_file + x /src_file/ext2soft_link1 + x /src_file/ext2softdangle_link1 + x /src_file/ext_link1 + x /src_file/ext_link2 + x /src_file/ext_link3 + x /src_file/ext_link4 + x /src_file/ext_link5 + +group : </> and </> +0 differences found +Not comparable: </src_file> is of type H5G_UDLINK and </src_file> is of type H5G_GROUP +-------------------------------- +Some objects are not comparable +-------------------------------- +Use -c for a list of objects without details of differences. diff --git a/tools/test/h5repack/testfiles/textlinkfar-mergeprune.textlinkfar.h5.ddl b/tools/test/h5repack/testfiles/textlinkfar-mergeprune.textlinkfar.h5.ddl new file mode 100644 index 0000000..7ba3308 --- /dev/null +++ b/tools/test/h5repack/testfiles/textlinkfar-mergeprune.textlinkfar.h5.ddl @@ -0,0 +1,152 @@ +HDF5 "out-textlinkfar-mergeprune.textlinkfar.h5" { +GROUP "/" { + GROUP "src_file" { + EXTERNAL_LINK "ext2soft_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dset1" + DATASET "/soft_dset1" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 4, 2 ) / ( 4, 2 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 32 + OFFSET 2848 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + } + EXTERNAL_LINK "ext2softdangle_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dangle" + } + EXTERNAL_LINK "ext_link1" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group" + GROUP "group" { + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 3136 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + EXTERNAL_LINK "elink_t1" { + TARGETFILE "textlinksrc.h5" + TARGETPATH "/" + GROUP "/" { + EXTERNAL_LINK "ext2soft_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dset1" + DATASET "/soft_dset1" { + HARDLINK "/dset1" + } + } + EXTERNAL_LINK "ext2softdangle_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dangle" + } + EXTERNAL_LINK "ext_link1" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group" + GROUP "group" { + HARDLINK "/group" + } + } + EXTERNAL_LINK "ext_link2" { + TARGETFILE "textlinktar.h5" + TARGETPATH "dset" + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 3160 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + } + EXTERNAL_LINK "ext_link3" { + TARGETFILE "textlinktar.h5" + TARGETPATH "type" + DATATYPE "type" H5T_STD_I32LE; + } + EXTERNAL_LINK "ext_link4" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group/elink_t2" + } + EXTERNAL_LINK "ext_link5" { + TARGETFILE "textlinktar.h5" + TARGETPATH "empty_group" + GROUP "empty_group" { + } + } + } + } + EXTERNAL_LINK "elink_t2" { + TARGETFILE "textlinksrc.h5" + TARGETPATH "/ext_link4" + } + GROUP "subgroup" { + GROUP "link_to_group" { + HARDLINK "/group" + } + } + } + } + EXTERNAL_LINK "ext_link2" { + TARGETFILE "textlinktar.h5" + TARGETPATH "dset" + DATASET "dset" { + HARDLINK "/dset" + } + } + EXTERNAL_LINK "ext_link3" { + TARGETFILE "textlinktar.h5" + TARGETPATH "type" + DATATYPE "type" HARDLINK "/type" + } + EXTERNAL_LINK "ext_link4" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group/elink_t2" + } + EXTERNAL_LINK "ext_link5" { + TARGETFILE "textlinktar.h5" + TARGETPATH "empty_group" + GROUP "empty_group" { + HARDLINK "/empty_group" + } + } + } +} +} diff --git a/tools/test/h5repack/testfiles/textlinkfar-prune.textlinkfar.h5.ddl b/tools/test/h5repack/testfiles/textlinkfar-prune.textlinkfar.h5.ddl new file mode 100644 index 0000000..30f8f1b --- /dev/null +++ b/tools/test/h5repack/testfiles/textlinkfar-prune.textlinkfar.h5.ddl @@ -0,0 +1,4 @@ +HDF5 "out-textlinkfar-prune.textlinkfar.h5" { +GROUP "/" { +} +} diff --git a/tools/test/h5repack/testfiles/textlinksrc-base.textlinksrc.h5.ddl b/tools/test/h5repack/testfiles/textlinksrc-base.textlinksrc.h5.ddl new file mode 100644 index 0000000..9a9a9aa --- /dev/null +++ b/tools/test/h5repack/testfiles/textlinksrc-base.textlinksrc.h5.ddl @@ -0,0 +1,150 @@ +HDF5 "out-textlinksrc-base.textlinksrc.h5" { +GROUP "/" { + EXTERNAL_LINK "ext2soft_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dset1" + DATASET "/soft_dset1" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 4, 2 ) / ( 4, 2 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 32 + OFFSET 2848 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + } + EXTERNAL_LINK "ext2softdangle_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dangle" + } + EXTERNAL_LINK "ext_link1" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group" + GROUP "group" { + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 3136 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + EXTERNAL_LINK "elink_t1" { + TARGETFILE "textlinksrc.h5" + TARGETPATH "/" + GROUP "/" { + EXTERNAL_LINK "ext2soft_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dset1" + DATASET "/soft_dset1" { + HARDLINK "/dset1" + } + } + EXTERNAL_LINK "ext2softdangle_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dangle" + } + EXTERNAL_LINK "ext_link1" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group" + GROUP "group" { + HARDLINK "/group" + } + } + EXTERNAL_LINK "ext_link2" { + TARGETFILE "textlinktar.h5" + TARGETPATH "dset" + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 3160 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + } + EXTERNAL_LINK "ext_link3" { + TARGETFILE "textlinktar.h5" + TARGETPATH "type" + DATATYPE "type" H5T_STD_I32LE; + } + EXTERNAL_LINK "ext_link4" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group/elink_t2" + } + EXTERNAL_LINK "ext_link5" { + TARGETFILE "textlinktar.h5" + TARGETPATH "empty_group" + GROUP "empty_group" { + } + } + } + } + EXTERNAL_LINK "elink_t2" { + TARGETFILE "textlinksrc.h5" + TARGETPATH "/ext_link4" + } + GROUP "subgroup" { + GROUP "link_to_group" { + HARDLINK "/group" + } + } + } + } + EXTERNAL_LINK "ext_link2" { + TARGETFILE "textlinktar.h5" + TARGETPATH "dset" + DATASET "dset" { + HARDLINK "/dset" + } + } + EXTERNAL_LINK "ext_link3" { + TARGETFILE "textlinktar.h5" + TARGETPATH "type" + DATATYPE "type" HARDLINK "/type" + } + EXTERNAL_LINK "ext_link4" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group/elink_t2" + } + EXTERNAL_LINK "ext_link5" { + TARGETFILE "textlinktar.h5" + TARGETPATH "empty_group" + GROUP "empty_group" { + HARDLINK "/empty_group" + } + } +} +} diff --git a/tools/test/h5repack/testfiles/textlinksrc-merge.textlinksrc.h5.tst b/tools/test/h5repack/testfiles/textlinksrc-merge.textlinksrc.h5.tst new file mode 100644 index 0000000..d5a5902 --- /dev/null +++ b/tools/test/h5repack/testfiles/textlinksrc-merge.textlinksrc.h5.tst @@ -0,0 +1,32 @@ + +file1 file2 +--------------------------------------- + x x / + x x /ext2soft_link1 + x x /ext2softdangle_link1 + x x /ext_link1 + x /ext_link1/dset + x /ext_link1/elink_t1 + x /ext_link1/elink_t2 + x /ext_link1/subgroup + x /ext_link1/subgroup/link_to_group + x x /ext_link2 + x x /ext_link3 + x x /ext_link4 + x x /ext_link5 + +group : </> and </> +0 differences found +Not comparable: </ext2soft_link1> is of type H5G_UDLINK and </ext2soft_link1> is of type H5G_DATASET +external link: </ext2softdangle_link1> and </ext2softdangle_link1> +0 differences found +Not comparable: </ext_link1> is of type H5G_UDLINK and </ext_link1> is of type H5G_GROUP +Not comparable: </ext_link2> is of type H5G_UDLINK and </ext_link2> is of type H5G_DATASET +Not comparable: </ext_link3> is of type H5G_UDLINK and </ext_link3> is of type H5G_TYPE +external link: </ext_link4> and </ext_link4> +0 differences found +Not comparable: </ext_link5> is of type H5G_UDLINK and </ext_link5> is of type H5G_GROUP +-------------------------------- +Some objects are not comparable +-------------------------------- +Use -c for a list of objects without details of differences. diff --git a/tools/test/h5repack/testfiles/textlinksrc-mergeprune.textlinksrc.h5.ddl b/tools/test/h5repack/testfiles/textlinksrc-mergeprune.textlinksrc.h5.ddl new file mode 100644 index 0000000..5b3c740 --- /dev/null +++ b/tools/test/h5repack/testfiles/textlinksrc-mergeprune.textlinksrc.h5.ddl @@ -0,0 +1,187 @@ +HDF5 "out-textlinksrc-mergeprune.textlinksrc.h5" { +GROUP "/" { + DATASET "ext2soft_link1" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 4, 2 ) / ( 4, 2 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 32 + OFFSET 2048 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + GROUP "ext_link1" { + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 2080 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + EXTERNAL_LINK "elink_t1" { + TARGETFILE "textlinksrc.h5" + TARGETPATH "/" + GROUP "/" { + EXTERNAL_LINK "ext2soft_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dset1" + DATASET "/soft_dset1" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 4, 2 ) / ( 4, 2 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 32 + OFFSET 2848 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + } + EXTERNAL_LINK "ext2softdangle_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dangle" + } + EXTERNAL_LINK "ext_link1" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group" + GROUP "group" { + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 3136 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + EXTERNAL_LINK "elink_t1" { + TARGETFILE "textlinksrc.h5" + TARGETPATH "/" + GROUP "/" { + HARDLINK "/" + } + } + EXTERNAL_LINK "elink_t2" { + TARGETFILE "textlinksrc.h5" + TARGETPATH "/ext_link4" + } + GROUP "subgroup" { + GROUP "link_to_group" { + HARDLINK "/group" + } + } + } + } + EXTERNAL_LINK "ext_link2" { + TARGETFILE "textlinktar.h5" + TARGETPATH "dset" + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 3160 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + } + EXTERNAL_LINK "ext_link3" { + TARGETFILE "textlinktar.h5" + TARGETPATH "type" + DATATYPE "type" H5T_STD_I32LE; + } + EXTERNAL_LINK "ext_link4" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group/elink_t2" + } + EXTERNAL_LINK "ext_link5" { + TARGETFILE "textlinktar.h5" + TARGETPATH "empty_group" + GROUP "empty_group" { + } + } + } + } + EXTERNAL_LINK "elink_t2" { + TARGETFILE "textlinksrc.h5" + TARGETPATH "/ext_link4" + } + GROUP "subgroup" { + GROUP "link_to_group" { + HARDLINK "/ext_link1" + } + } + } + DATASET "ext_link2" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 2104 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + DATATYPE "ext_link3" H5T_STD_I32LE; + GROUP "ext_link5" { + } +} +} diff --git a/tools/test/h5repack/testfiles/textlinksrc-prune.textlinksrc.h5.ddl b/tools/test/h5repack/testfiles/textlinksrc-prune.textlinksrc.h5.ddl new file mode 100644 index 0000000..65d35ef --- /dev/null +++ b/tools/test/h5repack/testfiles/textlinksrc-prune.textlinksrc.h5.ddl @@ -0,0 +1,4 @@ +HDF5 "out-textlinksrc-prune.textlinksrc.h5" { +GROUP "/" { +} +} diff --git a/tools/test/h5repack/testfiles/textlinktar-base.textlinktar.h5.ddl b/tools/test/h5repack/testfiles/textlinktar-base.textlinktar.h5.ddl new file mode 100644 index 0000000..3f02ff2 --- /dev/null +++ b/tools/test/h5repack/testfiles/textlinktar-base.textlinktar.h5.ddl @@ -0,0 +1,168 @@ +HDF5 "out-textlinktar-base.textlinktar.h5" { +GROUP "/" { + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 2048 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + GROUP "empty_group" { + } + GROUP "group" { + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 2072 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + EXTERNAL_LINK "elink_t1" { + TARGETFILE "textlinksrc.h5" + TARGETPATH "/" + GROUP "/" { + EXTERNAL_LINK "ext2soft_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dset1" + DATASET "/soft_dset1" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 4, 2 ) / ( 4, 2 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 32 + OFFSET 2848 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + } + EXTERNAL_LINK "ext2softdangle_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dangle" + } + EXTERNAL_LINK "ext_link1" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group" + GROUP "group" { + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 3136 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + EXTERNAL_LINK "elink_t1" { + TARGETFILE "textlinksrc.h5" + TARGETPATH "/" + GROUP "/" { + HARDLINK "/" + } + } + EXTERNAL_LINK "elink_t2" { + TARGETFILE "textlinksrc.h5" + TARGETPATH "/ext_link4" + } + GROUP "subgroup" { + GROUP "link_to_group" { + HARDLINK "/group" + } + } + } + } + EXTERNAL_LINK "ext_link2" { + TARGETFILE "textlinktar.h5" + TARGETPATH "dset" + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 3160 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + } + EXTERNAL_LINK "ext_link3" { + TARGETFILE "textlinktar.h5" + TARGETPATH "type" + DATATYPE "type" H5T_STD_I32LE; + } + EXTERNAL_LINK "ext_link4" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group/elink_t2" + } + EXTERNAL_LINK "ext_link5" { + TARGETFILE "textlinktar.h5" + TARGETPATH "empty_group" + GROUP "empty_group" { + } + } + } + } + EXTERNAL_LINK "elink_t2" { + TARGETFILE "textlinksrc.h5" + TARGETPATH "/ext_link4" + } + GROUP "subgroup" { + GROUP "link_to_group" { + HARDLINK "/group" + } + } + } + DATATYPE "type" H5T_STD_I32LE; +} +} diff --git a/tools/test/h5repack/testfiles/textlinktar-merge.textlinktar.h5.tst b/tools/test/h5repack/testfiles/textlinktar-merge.textlinktar.h5.tst new file mode 100644 index 0000000..ccf4f7b --- /dev/null +++ b/tools/test/h5repack/testfiles/textlinktar-merge.textlinktar.h5.tst @@ -0,0 +1,44 @@ + +file1 file2 +--------------------------------------- + x x / + x x /dset + x x /empty_group + x x /group + x x /group/dset + x x /group/elink_t1 + x /group/elink_t1/ext2soft_link1 + x /group/elink_t1/ext2softdangle_link1 + x /group/elink_t1/ext_link1 + x /group/elink_t1/ext_link2 + x /group/elink_t1/ext_link3 + x /group/elink_t1/ext_link4 + x /group/elink_t1/ext_link5 + x x /group/elink_t2 + x x /group/subgroup + x x /group/subgroup/link_to_group + x x /type + +group : </> and </> +0 differences found +dataset: </dset> and </dset> +0 differences found +group : </empty_group> and </empty_group> +0 differences found +group : </group> and </group> +0 differences found +dataset: </group/dset> and </group/dset> +0 differences found +Not comparable: </group/elink_t1> is of type H5G_UDLINK and </group/elink_t1> is of type H5G_GROUP +external link: </group/elink_t2> and </group/elink_t2> +0 differences found +group : </group/subgroup> and </group/subgroup> +0 differences found +group : </group/subgroup/link_to_group> and </group/subgroup/link_to_group> +0 differences found +datatype: </type> and </type> +0 differences found +-------------------------------- +Some objects are not comparable +-------------------------------- +Use -c for a list of objects without details of differences. diff --git a/tools/test/h5repack/testfiles/textlinktar-mergeprune.textlinktar.h5.ddl b/tools/test/h5repack/testfiles/textlinktar-mergeprune.textlinktar.h5.ddl new file mode 100644 index 0000000..c52e34d --- /dev/null +++ b/tools/test/h5repack/testfiles/textlinktar-mergeprune.textlinktar.h5.ddl @@ -0,0 +1,200 @@ +HDF5 "out-textlinktar-mergeprune.textlinktar.h5" { +GROUP "/" { + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 2048 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + GROUP "empty_group" { + } + GROUP "group" { + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 2072 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + GROUP "elink_t1" { + EXTERNAL_LINK "ext2soft_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dset1" + DATASET "/soft_dset1" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 4, 2 ) / ( 4, 2 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 32 + OFFSET 2848 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + } + EXTERNAL_LINK "ext2softdangle_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dangle" + } + EXTERNAL_LINK "ext_link1" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group" + GROUP "group" { + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 3136 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + EXTERNAL_LINK "elink_t1" { + TARGETFILE "textlinksrc.h5" + TARGETPATH "/" + GROUP "/" { + EXTERNAL_LINK "ext2soft_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dset1" + DATASET "/soft_dset1" { + HARDLINK "/dset1" + } + } + EXTERNAL_LINK "ext2softdangle_link1" { + TARGETFILE "tsoftlinks.h5" + TARGETPATH "/soft_dangle" + } + EXTERNAL_LINK "ext_link1" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group" + GROUP "group" { + HARDLINK "/group" + } + } + EXTERNAL_LINK "ext_link2" { + TARGETFILE "textlinktar.h5" + TARGETPATH "dset" + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 3160 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + } + EXTERNAL_LINK "ext_link3" { + TARGETFILE "textlinktar.h5" + TARGETPATH "type" + DATATYPE "type" H5T_STD_I32LE; + } + EXTERNAL_LINK "ext_link4" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group/elink_t2" + } + EXTERNAL_LINK "ext_link5" { + TARGETFILE "textlinktar.h5" + TARGETPATH "empty_group" + GROUP "empty_group" { + } + } + } + } + EXTERNAL_LINK "elink_t2" { + TARGETFILE "textlinksrc.h5" + TARGETPATH "/ext_link4" + } + GROUP "subgroup" { + GROUP "link_to_group" { + HARDLINK "/group" + } + } + } + } + EXTERNAL_LINK "ext_link2" { + TARGETFILE "textlinktar.h5" + TARGETPATH "dset" + DATASET "dset" { + HARDLINK "/dset" + } + } + EXTERNAL_LINK "ext_link3" { + TARGETFILE "textlinktar.h5" + TARGETPATH "type" + DATATYPE "type" HARDLINK "/type" + } + EXTERNAL_LINK "ext_link4" { + TARGETFILE "textlinktar.h5" + TARGETPATH "group/elink_t2" + } + EXTERNAL_LINK "ext_link5" { + TARGETFILE "textlinktar.h5" + TARGETPATH "empty_group" + GROUP "empty_group" { + HARDLINK "/empty_group" + } + } + } + GROUP "subgroup" { + GROUP "link_to_group" { + HARDLINK "/group" + } + } + } + DATATYPE "type" H5T_STD_I32LE; +} +} diff --git a/tools/test/h5repack/testfiles/textlinktar-prune.textlinktar.h5.ddl b/tools/test/h5repack/testfiles/textlinktar-prune.textlinktar.h5.ddl new file mode 100644 index 0000000..6787784 --- /dev/null +++ b/tools/test/h5repack/testfiles/textlinktar-prune.textlinktar.h5.ddl @@ -0,0 +1,52 @@ +HDF5 "out-textlinktar-prune.textlinktar.h5" { +GROUP "/" { + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 2048 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + GROUP "empty_group" { + } + GROUP "group" { + DATASET "dset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 24 + OFFSET 2072 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + GROUP "subgroup" { + GROUP "link_to_group" { + HARDLINK "/group" + } + } + } + DATATYPE "type" H5T_STD_I32LE; +} +} diff --git a/tools/test/h5repack/testfiles/tsoftlinks-base.tsoftlinks.h5.ddl b/tools/test/h5repack/testfiles/tsoftlinks-base.tsoftlinks.h5.ddl new file mode 100644 index 0000000..b0cd32d --- /dev/null +++ b/tools/test/h5repack/testfiles/tsoftlinks-base.tsoftlinks.h5.ddl @@ -0,0 +1,77 @@ +HDF5 "out-tsoftlinks-base.tsoftlinks.h5" { +GROUP "/" { + DATASET "dset1" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 4, 2 ) / ( 4, 2 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 32 + OFFSET 2048 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + DATASET "dset2" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 4, 2 ) / ( 4, 2 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 32 + OFFSET 2080 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + DATATYPE "dtype" H5T_STD_I32BE; + GROUP "group1" { + SOFTLINK "soft_dangle" { + LINKTARGET "not_yet" + } + SOFTLINK "soft_dset1" { + LINKTARGET "/dset1" + } + SOFTLINK "soft_dset2" { + LINKTARGET "/dset2" + } + SOFTLINK "soft_dtype" { + LINKTARGET "/dtype" + } + SOFTLINK "soft_empty_grp" { + LINKTARGET "/group_empty" + } + } + GROUP "group_empty" { + } + SOFTLINK "soft_dangle" { + LINKTARGET "not_yet" + } + SOFTLINK "soft_dset1" { + LINKTARGET "/dset1" + } + SOFTLINK "soft_dtype" { + LINKTARGET "/dtype" + } + SOFTLINK "soft_empty_grp" { + LINKTARGET "/group_empty" + } + SOFTLINK "soft_group1" { + LINKTARGET "/group1" + } +} +} diff --git a/tools/test/h5repack/testfiles/tsoftlinks-merge.tsoftlinks.h5.tst b/tools/test/h5repack/testfiles/tsoftlinks-merge.tsoftlinks.h5.tst new file mode 100644 index 0000000..27c33d7 --- /dev/null +++ b/tools/test/h5repack/testfiles/tsoftlinks-merge.tsoftlinks.h5.tst @@ -0,0 +1,53 @@ + +file1 file2 +--------------------------------------- + x x / + x x /dset1 + x x /dset2 + x x /dtype + x x /group1 + x x /group1/soft_dangle + x x /group1/soft_dset1 + x x /group1/soft_dset2 + x x /group1/soft_dtype + x x /group1/soft_empty_grp + x x /group_empty + x x /soft_dangle + x x /soft_dset1 + x x /soft_dtype + x x /soft_empty_grp + x x /soft_group1 + x /soft_group1/soft_dangle + x /soft_group1/soft_dset1 + x /soft_group1/soft_dset2 + x /soft_group1/soft_dtype + x /soft_group1/soft_empty_grp + +group : </> and </> +0 differences found +dataset: </dset1> and </dset1> +0 differences found +dataset: </dset2> and </dset2> +0 differences found +datatype: </dtype> and </dtype> +0 differences found +group : </group1> and </group1> +0 differences found +link : </group1/soft_dangle> and </group1/soft_dangle> +0 differences found +Not comparable: </group1/soft_dset1> is of type H5G_LINK and </group1/soft_dset1> is of type H5G_DATASET +Not comparable: </group1/soft_dset2> is of type H5G_LINK and </group1/soft_dset2> is of type H5G_DATASET +Not comparable: </group1/soft_dtype> is of type H5G_LINK and </group1/soft_dtype> is of type H5G_TYPE +Not comparable: </group1/soft_empty_grp> is of type H5G_LINK and </group1/soft_empty_grp> is of type H5G_GROUP +group : </group_empty> and </group_empty> +0 differences found +link : </soft_dangle> and </soft_dangle> +0 differences found +Not comparable: </soft_dset1> is of type H5G_LINK and </soft_dset1> is of type H5G_DATASET +Not comparable: </soft_dtype> is of type H5G_LINK and </soft_dtype> is of type H5G_TYPE +Not comparable: </soft_empty_grp> is of type H5G_LINK and </soft_empty_grp> is of type H5G_GROUP +Not comparable: </soft_group1> is of type H5G_LINK and </soft_group1> is of type H5G_GROUP +-------------------------------- +Some objects are not comparable +-------------------------------- +Use -c for a list of objects without details of differences. diff --git a/tools/test/h5repack/testfiles/tsoftlinks-mergeprune.tsoftlinks.h5.ddl b/tools/test/h5repack/testfiles/tsoftlinks-mergeprune.tsoftlinks.h5.ddl new file mode 100644 index 0000000..fa4e12d --- /dev/null +++ b/tools/test/h5repack/testfiles/tsoftlinks-mergeprune.tsoftlinks.h5.ddl @@ -0,0 +1,127 @@ +HDF5 "out-tsoftlinks-mergeprune.tsoftlinks.h5" { +GROUP "/" { + DATASET "dset1" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 4, 2 ) / ( 4, 2 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 32 + OFFSET 2048 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + DATASET "dset2" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 4, 2 ) / ( 4, 2 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 32 + OFFSET 2080 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + DATATYPE "dtype" H5T_STD_I32BE; + GROUP "group1" { + DATASET "soft_dset1" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 4, 2 ) / ( 4, 2 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 32 + OFFSET 2112 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + DATASET "soft_dset2" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 4, 2 ) / ( 4, 2 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 32 + OFFSET 2144 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + DATATYPE "soft_dtype" H5T_STD_I32BE; + GROUP "soft_empty_grp" { + } + } + GROUP "group_empty" { + } + DATASET "soft_dset1" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 4, 2 ) / ( 4, 2 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 32 + OFFSET 2176 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + DATATYPE "soft_dtype" H5T_STD_I32BE; + GROUP "soft_empty_grp" { + } + GROUP "soft_group1" { + SOFTLINK "soft_dangle" { + LINKTARGET "not_yet" + } + SOFTLINK "soft_dset1" { + LINKTARGET "/dset1" + } + SOFTLINK "soft_dset2" { + LINKTARGET "/dset2" + } + SOFTLINK "soft_dtype" { + LINKTARGET "/dtype" + } + SOFTLINK "soft_empty_grp" { + LINKTARGET "/group_empty" + } + } +} +} diff --git a/tools/test/h5repack/testfiles/tsoftlinks-prune.tsoftlinks.h5.ddl b/tools/test/h5repack/testfiles/tsoftlinks-prune.tsoftlinks.h5.ddl new file mode 100644 index 0000000..de58ef2 --- /dev/null +++ b/tools/test/h5repack/testfiles/tsoftlinks-prune.tsoftlinks.h5.ddl @@ -0,0 +1,47 @@ +HDF5 "out-tsoftlinks-prune.tsoftlinks.h5" { +GROUP "/" { + DATASET "dset1" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 4, 2 ) / ( 4, 2 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 32 + OFFSET 2048 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + DATASET "dset2" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 4, 2 ) / ( 4, 2 ) } + STORAGE_LAYOUT { + CONTIGUOUS + SIZE 32 + OFFSET 2080 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_LATE + } + } + DATATYPE "dtype" H5T_STD_I32BE; + GROUP "group1" { + } + GROUP "group_empty" { + } +} +} diff --git a/tools/test/h5repack/testh5repack_detect_szip.c b/tools/test/h5repack/testh5repack_detect_szip.c index 6b86dd5..29414b4 100644 --- a/tools/test/h5repack/testh5repack_detect_szip.c +++ b/tools/test/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); @@ -51,9 +50,9 @@ int main(void) #ifdef H5_HAVE_FILTER_SZIP if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { HDprintf("yes\n"); - return(1); + return (1); } #endif /* H5_HAVE_FILTER_SZIP */ HDprintf("no\n"); - return(0); + return (0); } diff --git a/tools/test/h5stat/CMakeLists.txt b/tools/test/h5stat/CMakeLists.txt index 5c17fd5..a40d196 100644 --- a/tools/test/h5stat/CMakeLists.txt +++ b/tools/test/h5stat/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_TOOLS_TEST_H5STAT C) # -------------------------------------------------------------------- @@ -6,12 +6,21 @@ project (HDF5_TOOLS_TEST_H5STAT C) # -------------------------------------------------------------------- if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) add_executable (h5stat_gentest ${HDF5_TOOLS_TEST_H5STAT_SOURCE_DIR}/h5stat_gentest.c) - target_include_directories (h5stat_gentest PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (h5stat_gentest PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h5stat_gentest STATIC) target_link_libraries (h5stat_gentest PRIVATE ${HDF5_LIB_TARGET}) set_target_properties (h5stat_gentest PROPERTIES FOLDER generator/tools) + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5STAT_FORMAT h5stat_gentest) + endif () + #add_test (NAME h5stat_gentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5stat_gentest>) endif () -include (CMakeTests.cmake) +if (HDF5_TEST_TOOLS AND HDF5_TEST_SERIAL) + include (CMakeTests.cmake) +endif () diff --git a/tools/test/h5stat/CMakeTests.cmake b/tools/test/h5stat/CMakeTests.cmake index 9674a77..d4238b5 100644 --- a/tools/test/h5stat/CMakeTests.cmake +++ b/tools/test/h5stat/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. # @@ -93,16 +93,10 @@ ############################################################################## ############################################################################## - if (NOT BUILD_SHARED_LIBS) - set (tgt_ext "") - else () - set (tgt_ext "-shared") - endif () - macro (ADD_H5_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5STAT-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5stat${tgt_ext}> ${ARGN}) + add_test (NAME H5STAT-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5stat${tgt_file_ext}> ${ARGN}) if (${resultcode}) set_tests_properties (H5STAT-${resultfile} PROPERTIES WILL_FAIL "true") endif () @@ -111,7 +105,7 @@ NAME H5STAT-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5stat${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5stat${tgt_file_ext}>" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=${resultfile}.out" @@ -125,7 +119,7 @@ macro (ADD_H5_ERR_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5STAT-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5stat${tgt_ext}> ${ARGN}) + add_test (NAME H5STAT-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5stat${tgt_file_ext}> ${ARGN}) if (${resultcode}) set_tests_properties (H5STAT-${resultfile} PROPERTIES WILL_FAIL "true") endif () @@ -134,7 +128,7 @@ NAME H5STAT-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5stat${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5stat${tgt_file_ext}>" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=${resultfile}.out" @@ -213,7 +207,7 @@ # -d --di=15 ADD_H5_ERR_TEST (h5stat_err1_dims 1 -d --dims=-1 h5stat_threshold.h5) ADD_H5_TEST (h5stat_dims1 0 -gd -m 5 h5stat_threshold.h5) - ADD_H5_TEST (h5stat_dims2 0 -d --di=15 h5stat_threshold.h5) + ADD_H5_TEST (h5stat_dims2 0 -d --dims=15 h5stat_threshold.h5) # # Tests for -a option on h5stat_threshold.h5 # -a -2 (incorrect threshold value) diff --git a/tools/test/h5stat/Makefile.am b/tools/test/h5stat/Makefile.am index dd251f8..ca1108f 100644 --- a/tools/test/h5stat/Makefile.am +++ b/tools/test/h5stat/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. ## diff --git a/tools/test/h5stat/h5stat_gentest.c b/tools/test/h5stat/h5stat_gentest.c index 2edfcf6..c775d6a 100644 --- a/tools/test/h5stat/h5stat_gentest.c +++ b/tools/test/h5stat/h5stat_gentest.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,101 +24,117 @@ #include "H5private.h" /* For gen_newgrat_file() */ -#define NEWGRAT_FILE "h5stat_newgrat.h5" -#define DATASET_NAME "DATASET_NAME" -#define GROUP_NAME "GROUP" +#define NEWGRAT_FILE "h5stat_newgrat.h5" +#define DATASET_NAME "DATASET_NAME" +#define GROUP_NAME "GROUP" #define ATTR_NAME "ATTR" #define NUM_GRPS 35000 #define NUM_ATTRS 100 /* Declarations for gen_idx_file() */ -#define IDX_FILE "h5stat_idx.h5" +#define IDX_FILE "h5stat_idx.h5" #define DSET "dset" -#define DSET_FILTER "dset_filter" +#define DSET_FILTER "dset_filter" /* For gen_threshold_file() */ -#define THRESHOLD_FILE "h5stat_threshold.h5" -#define THRES_ATTR_NAME "attr" -#define THRES_ATTR_GRP_NAME "grp_attr" +#define THRESHOLD_FILE "h5stat_threshold.h5" +#define THRES_ATTR_NAME "attr" +#define THRES_ATTR_GRP_NAME "grp_attr" #define THRES_DSET_NAME "dset" -#define THRES_NUM 10 +#define THRES_NUM 10 #define THRES_NUM_25 25 /* For gen_err_refcount() */ -#define ERR_REFCOUNT_FILE "h5stat_err_refcount.h5" +#define ERR_REFCOUNT_FILE "h5stat_err_refcount.h5" /* * Generate HDF5 file with latest format with * NUM_GRPS groups and NUM_ATTRS attributes for the dataset */ -static void +static herr_t gen_newgrat_file(const char *fname) { - hid_t fcpl = -1; /* File creation property */ - hid_t fapl = -1; /* File access property */ - hid_t fid = -1; /* File id */ - hid_t gid = -1; /* Group id */ - hid_t tid = -1; /* Datatype id */ - hid_t sid = -1; /* Dataspace id */ - hid_t attr_id = -1; /* Attribute id */ - hid_t did = -1; /* Dataset id */ - char name[30]; /* Group name */ - char attrname[30]; /* Attribute name */ - int i; /* Local index variable */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property */ + hid_t fapl = H5I_INVALID_HID; /* File access property */ + hid_t fid = H5I_INVALID_HID; /* File id */ + hid_t gid = H5I_INVALID_HID; /* Group id */ + hid_t tid = H5I_INVALID_HID; /* Datatype id */ + hid_t sid = H5I_INVALID_HID; /* Dataspace id */ + hid_t attr_id = H5I_INVALID_HID; /* Attribute id */ + hid_t did = H5I_INVALID_HID; /* Dataset id */ + char name[30]; /* Group name */ + char attrname[30]; /* Attribute name */ + int i; /* Local index variable */ /* Get a copy file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; /* Get a copy of file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; /* Set file space handling strategy */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, 1, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, 1, (hsize_t)1) < 0) goto error; - /* Create file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + /* Create file */ + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0) goto error; /* Create NUM_GRPS groups in the root group */ - for(i = 1; i <= NUM_GRPS; i++) { - HDsprintf(name, "%s%d", GROUP_NAME,i); - if((gid = H5Gcreate2(fid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 1; i <= NUM_GRPS; i++) { + HDsprintf(name, "%s%d", GROUP_NAME, i); + if ((gid = H5Gcreate2(fid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; } /* end for */ /* Create a datatype to commit and use */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) goto error; /* Create dataspace for dataset */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) goto error; /* Create dataset */ - if((did = H5Dcreate2(fid, DATASET_NAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DATASET_NAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create NUM_ATTRS for the dataset */ - for(i = 1; i <= NUM_ATTRS; i++) { - HDsprintf(attrname, "%s%d", ATTR_NAME,i); - if((attr_id = H5Acreate2(did, attrname, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 1; i <= NUM_ATTRS; i++) { + HDsprintf(attrname, "%s%d", ATTR_NAME, i); + if ((attr_id = H5Acreate2(did, attrname, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; } /* end for */ /* Close dataset, dataspace, datatype, file */ + if (H5Pclose(fapl) < 0) + goto error; + if (H5Pclose(fcpl) < 0) + goto error; + if (H5Dclose(did) < 0) + goto error; + if (H5Tclose(tid) < 0) + goto error; + if (H5Sclose(sid) < 0) + goto error; + if (H5Fclose(fid) < 0) + goto error; + + return SUCCEED; + error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(fcpl); H5Aclose(attr_id); @@ -127,178 +143,202 @@ error: H5Sclose(sid); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; + + return FAIL; } /* gen_newgrat_file() */ /* * Generate an HDF5 file with groups, datasets, attributes for testing the options: * -l N (--links=N): Set the threshold for # of links when printing information for small groups. - * -m N (--dims=N): Set the threshold for the # of dimension sizes when printing information for small datasets. - * -a N (--numattrs=N): Set the threshold for the # of attributes when printing information for small # of attributes. + * -m N (--dims=N): Set the threshold for the # of dimension sizes when printing information for small + * datasets. -a N (--numattrs=N): Set the threshold for the # of attributes when printing information for + * small # of attributes. */ -static void +static herr_t gen_threshold_file(const char *fname) { - hid_t fid = -1; /* File ID */ - hid_t sid0 = -1; /* Dataspace IDs */ - hid_t sid1 = -1; /* Dataspace IDs */ - hid_t sid2 = -1; /* Dataspace IDs */ - hid_t sid3 = -1; /* Dataspace IDs */ - hid_t sid4 = -1; /* Dataspace IDs */ - hid_t did = -1; /* Dataset ID */ - hid_t attr_id = -1; /* Attribute ID */ - hid_t gid = -1; /* Group ID */ - hsize_t two_dims[] = {2, 5}; /* Dimension array */ - hsize_t one_dims[] = {6}; /* Dimension array */ - hsize_t zero_dims[] = {0}; /* Dimension array */ - char name[30]; /* Name */ - unsigned i; /* Local index variable */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t sid0 = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t sid1 = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t sid2 = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t sid3 = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t sid4 = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + hid_t attr_id = H5I_INVALID_HID; /* Attribute ID */ + hid_t gid = H5I_INVALID_HID; /* Group ID */ + hsize_t two_dims[] = {2, 5}; /* Dimension array */ + hsize_t one_dims[] = {6}; /* Dimension array */ + hsize_t zero_dims[] = {0}; /* Dimension array */ + char name[30]; /* Name */ + unsigned i; /* Local index variable */ /* Create file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create 1-D dataspace with zero dimension size */ - if((sid0 = H5Screate_simple(1, zero_dims, NULL)) < 0) + if ((sid0 = H5Screate_simple(1, zero_dims, NULL)) < 0) goto error; /* Create 1-D dataspace with non-zero dimension size*/ - if((sid1 = H5Screate_simple(1, one_dims, NULL)) < 0) + if ((sid1 = H5Screate_simple(1, one_dims, NULL)) < 0) goto error; /* Create 2-D dataspace */ - if((sid2 = H5Screate_simple(2, two_dims, NULL)) < 0) + if ((sid2 = H5Screate_simple(2, two_dims, NULL)) < 0) goto error; /* Create scalar dataspace */ - if((sid3 = H5Screate(H5S_SCALAR)) < 0) + if ((sid3 = H5Screate(H5S_SCALAR)) < 0) goto error; /* Create null dataspace */ - if((sid4 = H5Screate(H5S_NULL)) < 0) + if ((sid4 = H5Screate(H5S_NULL)) < 0) goto error; /* Create an attribute for the root group */ - if((attr_id = H5Acreate2(fid, "attr", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(fid, "attr", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; /* Create 1-D dataset with zero dimension size for the root group */ - if((did = H5Dcreate2(fid, "zero_dset", H5T_NATIVE_UCHAR, sid0, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "zero_dset", H5T_NATIVE_UCHAR, sid0, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) goto error; /* Create 11 attributes for the dataset */ - for(i = 1; i <= (THRES_NUM+1); i++) { - HDsprintf(name, "%s%d", THRES_ATTR_NAME,i); - if((attr_id = H5Acreate2(did, name, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 1; i <= (THRES_NUM + 1); i++) { + HDsprintf(name, "%s%d", THRES_ATTR_NAME, i); + if ((attr_id = H5Acreate2(did, name, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; } - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; /* Create dataset with scalar dataspace for the root group */ - if((did = H5Dcreate2(fid, "scalar_dset", H5T_NATIVE_UCHAR, sid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "scalar_dset", H5T_NATIVE_UCHAR, sid3, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; /* Create dataset with null dataspace for the root group */ - if((did = H5Dcreate2(fid, "null_dset", H5T_NATIVE_UCHAR, sid4, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "null_dset", H5T_NATIVE_UCHAR, sid4, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) goto error; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; /* Create 2-D dataset for the root group */ - if((did = H5Dcreate2(fid, "dset", H5T_NATIVE_UCHAR, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dset", H5T_NATIVE_UCHAR, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create 10 attributes for the 2-D dataset */ - for(i = 1; i <= THRES_NUM; i++) { - HDsprintf(name, "%s%d", THRES_ATTR_NAME,i); - if((attr_id = H5Acreate2(did, name, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 1; i <= THRES_NUM; i++) { + HDsprintf(name, "%s%d", THRES_ATTR_NAME, i); + if ((attr_id = H5Acreate2(did, name, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; } - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; /* Create first group */ - if((gid = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create an attribute for the group */ - if((attr_id = H5Acreate2(gid, "ATTR", H5T_NATIVE_INT, sid3, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(gid, "ATTR", H5T_NATIVE_INT, sid3, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Close attribute */ - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; /* Create 10 1-D datasets with non-zero dimension size for the group */ - for(i = 1; i <= THRES_NUM; i++) { + for (i = 1; i <= THRES_NUM; i++) { /* set up dataset name */ - HDsprintf(name, "%s%d", THRES_DSET_NAME,i); + HDsprintf(name, "%s%d", THRES_DSET_NAME, i); /* Create the dataset */ - if((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; } /* Close the group */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; - /* Create second group */ - if((gid = H5Gcreate2(fid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create 25 attributes for the group */ - for(i = 1; i <= THRES_NUM_25; i++) { - /* Set up attribute name */ - HDsprintf(name, "%s%d", THRES_ATTR_GRP_NAME,i); + for (i = 1; i <= THRES_NUM_25; i++) { + /* Set up attribute name */ + HDsprintf(name, "%s%d", THRES_ATTR_GRP_NAME, i); /* Create the attribute */ - if((attr_id = H5Acreate2(gid, name, H5T_NATIVE_INT, sid2, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(gid, name, H5T_NATIVE_INT, sid2, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Close the attribute */ - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; } /* Close the group */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; /* Create third group */ - if((gid = H5Gcreate2(fid, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create 9 1-D datasets with non-zero dimension size for the group */ - for(i = 1; i < THRES_NUM; i++) { + for (i = 1; i < THRES_NUM; i++) { /* set up dataset name */ - HDsprintf(name, "%s%d", THRES_DSET_NAME,i); + HDsprintf(name, "%s%d", THRES_DSET_NAME, i); /* Create the dataset */ - if((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; } + if (H5Gclose(gid) < 0) + goto error; + if (H5Sclose(sid0) < 0) + goto error; + if (H5Sclose(sid1) < 0) + goto error; + if (H5Sclose(sid2) < 0) + goto error; + if (H5Sclose(sid3) < 0) + goto error; + if (H5Sclose(sid4) < 0) + goto error; + if (H5Fclose(fid) < 0) + goto error; + + return SUCCEED; + error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Aclose(attr_id); H5Dclose(did); @@ -308,7 +348,10 @@ error: H5Sclose(sid3); H5Sclose(sid4); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; + + return FAIL; } /* gen_threshold_file() */ @@ -320,80 +363,100 @@ error: * one dataset: fixed dimension, chunked layout, w/ filters * */ -static void +static herr_t gen_idx_file(const char *fname) { - hid_t fapl = -1; /* file access property id */ - hid_t fid = -1; /* file id */ - hid_t sid = -1; /* space id */ - hid_t dcpl = -1; /* dataset creation property id */ - hid_t did = -1, did2 = -1; /* dataset id */ - hsize_t dims[1] = {10}; /* dataset dimension */ - hsize_t c_dims[1] = {2}; /* chunk dimension */ - int i; /* local index variable */ - int buf[10]; /* data buffer */ + hid_t fapl = H5I_INVALID_HID; /* file access property id */ + hid_t fid = H5I_INVALID_HID; /* file id */ + hid_t sid = H5I_INVALID_HID; /* space id */ + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property id */ + hid_t did = H5I_INVALID_HID; /* dataset id */ +#if defined(H5_HAVE_FILTER_DEFLATE) + hid_t did2 = H5I_INVALID_HID; /* dataset id (compressed) */ +#endif + hsize_t dims[1] = {10}; /* dataset dimension */ + hsize_t c_dims[1] = {2}; /* chunk dimension */ + int i; /* local index variable */ + int buf[10]; /* data buffer */ /* Get a copy of the file access property */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; /* Set the "use the latest format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; /* Create file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; /* Create data */ - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) buf[i] = i; /* Set chunk */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 1, c_dims) < 0) + if (H5Pset_chunk(dcpl, 1, c_dims) < 0) goto error; /* Create a 1D dataset */ - if((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto error; - if((did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write to the dataset */ - 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 error; -#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 error; /* Create and write the dataset */ - if((did2 = H5Dcreate2(fid, DSET_FILTER, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(fid, DSET_FILTER, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Close the dataset */ - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) goto error; #endif /* closing: dataspace, dataset, file */ + if (H5Pclose(fapl) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; + if (H5Sclose(sid) < 0) + goto error; + if (H5Dclose(did) < 0) + goto error; + if (H5Fclose(fid) < 0) + goto error; + + return SUCCEED; + error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(dcpl); H5Sclose(sid); H5Dclose(did); H5Fclose(fid); -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) H5Dclose(did2); #endif - } H5E_END_TRY; + } + H5E_END_TRY; + + return FAIL; } /* gen_idx_file() */ @@ -410,73 +473,78 @@ error: * H5O_refcount_decode in the jira issue. * */ -static void +static herr_t gen_err_refcount(const char *fname) { - hid_t fid = -1; /* File identifier */ - hid_t sid = -1; /* Dataspace message */ - hid_t did = -1; /* Dataset identifier */ - hid_t gid = -1; /* Group identifier */ - hid_t aid1 = -1, aid2 = -1; /* Attribute identifier */ - hid_t tid = -1; /* Datatype identifier */ - int i, n; /* Local index variables */ - int buf[10]; /* Data buffer */ - hsize_t dims[1]; /* Dimension size */ - int fd = -1; /* File descriptor */ - unsigned short val = 22; /* The refcount message ID */ + hid_t fid = H5I_INVALID_HID; /* File identifier */ + hid_t sid = H5I_INVALID_HID; /* Dataspace message */ + hid_t did = H5I_INVALID_HID; /* Dataset identifier */ + hid_t gid = H5I_INVALID_HID; /* Group identifier */ + hid_t aid1 = H5I_INVALID_HID; /* Attribute identifier */ + hid_t aid2 = H5I_INVALID_HID; /* Attribute identifier */ + hid_t tid = H5I_INVALID_HID; /* Datatype identifier */ + int i, n; /* Local index variables */ + int buf[10]; /* Data buffer */ + hsize_t dims[1]; /* Dimension size */ + int fd = -1; /* File descriptor */ + unsigned short val = 22; /* The refcount message ID */ /* Initialize data buffer */ n = 0; - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) buf[i] = n++; /* Create the file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create a group */ - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create a committed datatype in the group */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) goto error; - if(H5Tcommit2(gid, "dtype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(gid, "dtype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) goto error; /* Create the dataspace */ dims[0] = 10; - if((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto error; /* Create a dataset with the committed datatype in the file */ - if((did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Write to the dataset */ - 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 error; /* Attach an attribute with the committed datatype to the group */ - if((aid1 = H5Acreate2(gid, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid1 = H5Acreate2(gid, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Attach an attribute with the committed datatype to the dataset */ - if((aid2 = H5Acreate2(did, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid2 = H5Acreate2(did, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Closing */ - if(H5Aclose(aid1) < 0) + if (H5Aclose(aid1) < 0) goto error; - if(H5Aclose(aid2) < 0) + if (H5Aclose(aid2) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto error; - if(H5Fclose(fid) < 0) + + /* Be sure to close this before opening the file again via open(), below, + * or you'll possibly trip over the file locking. + */ + if (H5Fclose(fid) < 0) goto error; /* This section of code will write a refcount message ID to a message in the @@ -486,14 +554,20 @@ gen_err_refcount(const char *fname) with the committed datatype */ /* 24: the offset in the object header containing the version of the attribute message */ - if((fd = HDopen(fname, O_RDWR, 0633)) >= 0) { - HDlseek(fd, 4520+24, SEEK_SET); - HDwrite(fd, &val, 2); - HDclose(fd); - } + if ((fd = HDopen(fname, O_RDWR, 0633)) < 0) + goto error; + if (HDlseek(fd, 4520 + 24, SEEK_SET) < 0) + goto error; + if (HDwrite(fd, &val, 2) < 0) + goto error; + if (HDclose(fd) < 0) + goto error; + + return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Dclose(did); H5Tclose(tid); @@ -501,7 +575,13 @@ error: H5Aclose(aid1); H5Aclose(aid2); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; + + if (fd >= 0) + HDclose(fd); + + return FAIL; } /* gen_err_refcount() */ /* @@ -528,17 +608,25 @@ error: * jira issue. */ -int main(void) +int +main(void) { - gen_newgrat_file(NEWGRAT_FILE); - gen_threshold_file(THRESHOLD_FILE); + if (gen_newgrat_file(NEWGRAT_FILE) < 0) + goto error; + if (gen_threshold_file(THRESHOLD_FILE) < 0) + goto error; /* Generate an HDF file to test for datasets with Fixed Array indexing */ - gen_idx_file(IDX_FILE); + if (gen_idx_file(IDX_FILE) < 0) + goto error; /* Generate a file with a refcount message ID */ - gen_err_refcount(ERR_REFCOUNT_FILE); + if (gen_err_refcount(ERR_REFCOUNT_FILE) < 0) + goto error; - return 0; -} + return EXIT_SUCCESS; +error: + HDfprintf(stderr, "h5stat test generator FAILED\n"); + return EXIT_FAILURE; +} diff --git a/tools/test/h5stat/testfiles/h5stat_help1.ddl b/tools/test/h5stat/testfiles/h5stat_help1.ddl index 2ba7772..1f65f0d 100644 --- a/tools/test/h5stat/testfiles/h5stat_help1.ddl +++ b/tools/test/h5stat/testfiles/h5stat_help1.ddl @@ -1,5 +1,8 @@ Usage: h5stat [OPTIONS] file + ERROR + --enable-error-stack Prints messages from the HDF5 error stack as they occur + Optional value 2 also prints file open errors OPTIONS -h, --help Print a usage message and exit -V, --version Print version number and exit @@ -22,7 +25,6 @@ Usage: h5stat [OPTIONS] file than 0. The default threshold is 10. -s, --freespace Print free space information -S, --summary Print summary of file space information - --enable-error-stack Prints messages from the HDF5 error stack as they occur --s3-cred=<cred> Access file on S3, using provided credential <cred> :: (region,id,key) If <cred> == "(,,)", no authentication is used. diff --git a/tools/test/h5stat/testfiles/h5stat_help2.ddl b/tools/test/h5stat/testfiles/h5stat_help2.ddl index 2ba7772..1f65f0d 100644 --- a/tools/test/h5stat/testfiles/h5stat_help2.ddl +++ b/tools/test/h5stat/testfiles/h5stat_help2.ddl @@ -1,5 +1,8 @@ Usage: h5stat [OPTIONS] file + ERROR + --enable-error-stack Prints messages from the HDF5 error stack as they occur + Optional value 2 also prints file open errors OPTIONS -h, --help Print a usage message and exit -V, --version Print version number and exit @@ -22,7 +25,6 @@ Usage: h5stat [OPTIONS] file than 0. The default threshold is 10. -s, --freespace Print free space information -S, --summary Print summary of file space information - --enable-error-stack Prints messages from the HDF5 error stack as they occur --s3-cred=<cred> Access file on S3, using provided credential <cred> :: (region,id,key) If <cred> == "(,,)", no authentication is used. diff --git a/tools/test/h5stat/testfiles/h5stat_nofile.ddl b/tools/test/h5stat/testfiles/h5stat_nofile.ddl index 2ba7772..1f65f0d 100644 --- a/tools/test/h5stat/testfiles/h5stat_nofile.ddl +++ b/tools/test/h5stat/testfiles/h5stat_nofile.ddl @@ -1,5 +1,8 @@ Usage: h5stat [OPTIONS] file + ERROR + --enable-error-stack Prints messages from the HDF5 error stack as they occur + Optional value 2 also prints file open errors OPTIONS -h, --help Print a usage message and exit -V, --version Print version number and exit @@ -22,7 +25,6 @@ Usage: h5stat [OPTIONS] file than 0. The default threshold is 10. -s, --freespace Print free space information -S, --summary Print summary of file space information - --enable-error-stack Prints messages from the HDF5 error stack as they occur --s3-cred=<cred> Access file on S3, using provided credential <cred> :: (region,id,key) If <cred> == "(,,)", no authentication is used. diff --git a/tools/test/h5stat/testh5stat.sh.in b/tools/test/h5stat/testh5stat.sh.in index 69b856e..1b4e504 100644 --- a/tools/test/h5stat/testh5stat.sh.in +++ b/tools/test/h5stat/testh5stat.sh.in @@ -7,13 +7,13 @@ # 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. # # Tests for the h5stat tool # -# Modifcations: +# Modifications: # Vailin Choi; July 2013 # Add tests for -l, -m, -a options # @@ -304,7 +304,7 @@ TOOLTEST h5stat_links5.ddl -g -l 40000 h5stat_newgrat.h5 # -d --di=15 TOOLTEST h5stat_err1_dims.ddl -d --dims=-1 h5stat_threshold.h5 TOOLTEST h5stat_dims1.ddl -gd -m 5 h5stat_threshold.h5 -TOOLTEST h5stat_dims2.ddl -d --di=15 h5stat_threshold.h5 +TOOLTEST h5stat_dims2.ddl -d --dims=15 h5stat_threshold.h5 # # Tests for -a option on h5stat_threshold.h5 # -a -2 (incorrect threshold value) diff --git a/tools/test/misc/CMakeLists.txt b/tools/test/misc/CMakeLists.txt index a250222..f67f36b 100644 --- a/tools/test/misc/CMakeLists.txt +++ b/tools/test/misc/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_TOOLS_TEST_MISC C) # -------------------------------------------------------------------- @@ -6,7 +6,7 @@ project (HDF5_TOOLS_TEST_MISC C) # -------------------------------------------------------------------- if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) add_executable (h5repart_gentest ${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/h5repart_gentest.c) - target_include_directories (h5repart_gentest PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (h5repart_gentest PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (h5repart_gentest STATIC) target_link_libraries (h5repart_gentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) @@ -17,8 +17,15 @@ if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) set_target_properties (h5repart_gentest PROPERTIES FOLDER generator/tools) #add_test (NAME h5repart_gentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repart_gentest>) + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_MISC_h5repart_gentest_FORMAT h5repart_gentest) + endif () + add_executable (h5clear_gentest ${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/h5clear_gentest.c) - target_include_directories (h5clear_gentest PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (h5clear_gentest PRIVATE "${HDF5_SRC_DIR};${HDF5_TEST_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (h5clear_gentest STATIC) target_link_libraries (h5clear_gentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) @@ -29,12 +36,19 @@ if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) set_target_properties (h5clear_gentest PROPERTIES FOLDER tools) #add_test (NAME H5CLEAR-h5clear_gentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear_gentest>) + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_MISC_h5clear_gentest_FORMAT h5clear_gentest) + endif () + add_subdirectory (vds) endif () add_executable (h5repart_test ${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/repart_test.c) -target_include_directories (h5repart_test PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +target_include_directories (h5repart_test PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (h5repart_test STATIC) target_link_libraries (h5repart_test PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) @@ -44,8 +58,15 @@ else () endif () set_target_properties (h5repart_test PROPERTIES FOLDER tools) +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_MISC_h5repart_test_FORMAT h5repart_test) +endif () + add_executable (clear_open_chk ${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/clear_open_chk.c) -target_include_directories (clear_open_chk PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +target_include_directories (clear_open_chk PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (clear_open_chk STATIC) target_link_libraries (clear_open_chk PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) @@ -55,6 +76,15 @@ else () endif () set_target_properties (clear_open_chk PROPERTIES FOLDER tools) -include (CMakeTestsRepart.cmake) -include (CMakeTestsClear.cmake) -include (CMakeTestsMkgrp.cmake) +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_MISC_clear_open_chk_FORMAT clear_open_chk) +endif () + +if (HDF5_TEST_SERIAL) + include (CMakeTestsRepart.cmake) + include (CMakeTestsClear.cmake) + include (CMakeTestsMkgrp.cmake) +endif () diff --git a/tools/test/misc/CMakeTestsClear.cmake b/tools/test/misc/CMakeTestsClear.cmake index a2c494d..198a363 100644 --- a/tools/test/misc/CMakeTestsClear.cmake +++ b/tools/test/misc/CMakeTestsClear.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. # @@ -83,12 +83,6 @@ ############################################################################## ############################################################################## - if (NOT BUILD_SHARED_LIBS) - set (tgt_ext "") - else () - set (tgt_ext "-shared") - endif () - # Need special dependencies for tests that use the same reference file # This is an issue on Windows macro (ADD_H5_CMP testname resultfile resultcode) @@ -97,7 +91,7 @@ NAME H5CLEAR_CMP-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${testname}.out" @@ -114,7 +108,7 @@ NAME H5CLEAR_CMP-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${testname}.out" @@ -144,7 +138,7 @@ NAME H5CLEAR_CMP-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN};${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${testname}.out" @@ -176,7 +170,7 @@ NAME H5CLEAR_CMP-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN};${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${testname}.out" @@ -195,7 +189,7 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5CLEAR_RET-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_ext}> ${ARGN} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_file_ext}> ${ARGN} ) set_tests_properties (H5CLEAR_RET-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" @@ -222,7 +216,7 @@ NAME H5CLEAR_FILESIZE_CMP-${testname}_before_size COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_file_ext}>" -D "TEST_ARGS:STRING=--filesize;${testname}.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${testname}_before_size.out" @@ -236,12 +230,12 @@ if (NOT ${incr_size} MATCHES "NONE") add_test ( NAME H5CLEAR_FILESIZE_INCR-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_ext}> --increment=${incr_size} ${testname}.h5 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_file_ext}> --increment=${incr_size} ${testname}.h5 ) else () add_test ( NAME H5CLEAR_FILESIZE_INCR-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_ext}> --increment ${testname}.h5 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_file_ext}> --increment ${testname}.h5 ) endif () set_tests_properties (H5CLEAR_FILESIZE_INCR-${testname} PROPERTIES @@ -253,7 +247,7 @@ NAME H5CLEAR_FILESIZE_CMP-${testname}_after_size COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_file_ext}>" -D "TEST_ARGS:STRING=--filesize;${testname}.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${testname}_after_size.out" @@ -285,7 +279,7 @@ NAME H5CLEAR_FILESIZE_FAIL_CMP-${testname}_before_size COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_file_ext}>" -D "TEST_ARGS:STRING=--filesize;${testname}.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${testname}_before_size.out" @@ -299,12 +293,12 @@ if (NOT ${incr_size} MATCHES "NONE") add_test ( NAME H5CLEAR_FILESIZE_FAIL_INCR-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_ext}> -s --increment=${incr_size} ${testname}.h5 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_file_ext}> -s --increment=${incr_size} ${testname}.h5 ) else () add_test ( NAME H5CLEAR_FILESIZE_FAIL_INCR-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_ext}> -s --increment ${testname}.h5 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_file_ext}> -s --increment ${testname}.h5 ) endif () set_tests_properties (H5CLEAR_FILESIZE_FAIL_INCR-${testname} PROPERTIES @@ -315,7 +309,7 @@ NAME H5CLEAR_FILESIZE_FAIL_CMP-${testname}_after_size COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_file_ext}>" -D "TEST_ARGS:STRING=--filesize;${testname}.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${testname}_after_size.out" @@ -352,7 +346,7 @@ # After "h5clear" the file, the subsequent file open succeeds add_test ( NAME H5CLEAR-h5clr-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_ext}> -s ${testfile}.h5 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_file_ext}> -s ${testfile}.h5 ) set_tests_properties (H5CLEAR-h5clr-${testname} PROPERTIES DEPENDS H5CLEAR-clr_open_chk-${testname}_${resultcode} @@ -403,7 +397,7 @@ # # The following are tests to verify the expected exit code from h5clear: # "h5clear -m h5clear_mdc_image.h5" (valid option, existing file, succeed exit code) -# "h5clear --vers" (valid option, version #, succeed exit code) +# "h5clear --version" (valid option, version #, succeed exit code) # "h5clear -k" (invalid 1 option, no file, fail exit code) # "h5clear -k junk.h5" (invalid 1 option, nonexisting file, fail exit code) # "h5clear -l h5clear_sec2_v2.h5" (invalid 1 option, existing file, fail exit code) @@ -414,7 +408,7 @@ # "h5clear -m -l h5clear_sec2_v0.h5" (valid/invalid 2 options, existing file, fail exit code) # "h5clear -l -m h5clear_sec2_v0.h5" (invalid/valid 2 options, existing file, fail exit code) ADD_H5_RETTEST (h5clr_mdc_image "false" "-m" h5clear_mdc_image.h5) - ADD_H5_RETTEST (h5clr_vers "false" "--vers") + ADD_H5_RETTEST (h5clr_vers "false" "--version") ADD_H5_RETTEST (h5clr_k "true" "-k") ADD_H5_RETTEST (h5clr_k_junk "true" "-k" junk.h5) ADD_H5_RETTEST (h5clr_l_sec2 "true" "-l" h5clear_sec2_v2.h5) diff --git a/tools/test/misc/CMakeTestsMkgrp.cmake b/tools/test/misc/CMakeTestsMkgrp.cmake index 11fa3f2..11c9fdf 100644 --- a/tools/test/misc/CMakeTestsMkgrp.cmake +++ b/tools/test/misc/CMakeTestsMkgrp.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. # @@ -54,34 +54,33 @@ ############################################################################## ############################################################################## - if (NOT BUILD_SHARED_LIBS) - set (tgt_ext "") - else () - set (tgt_ext "-shared") - endif () - macro (ADD_H5_TEST resultfile resultcode resultoption) - add_test ( - NAME H5MKGRP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} -E remove ${resultfile}.h5 - ) - set_tests_properties (H5MKGRP-${resultfile}-clear-objects PROPERTIES - WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" - ) - add_test ( - NAME H5MKGRP-${resultfile} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5mkgrp${tgt_ext}> ${resultoption} ${resultfile}.h5 ${ARGN} - ) - set_tests_properties (H5MKGRP-${resultfile} PROPERTIES - DEPENDS H5MKGRP-${resultfile}-clear-objects - WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" - ) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5MKGRP-${resultfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5mkgrp${tgt_file_ext}> ${resultoption} ${resultfile}.h5 ${ARGN} + ) + else () + add_test ( + NAME H5MKGRP-${resultfile}-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove ${resultfile}.h5 + ) + set_tests_properties (H5MKGRP-${resultfile}-clear-objects PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + ) + add_test ( + NAME H5MKGRP-${resultfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5mkgrp${tgt_file_ext}> ${resultoption} ${resultfile}.h5 ${ARGN} + ) + set_tests_properties (H5MKGRP-${resultfile} PROPERTIES + DEPENDS H5MKGRP-${resultfile}-clear-objects + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + ) add_test ( NAME H5MKGRP-${resultfile}-h5ls COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5ls${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5ls${tgt_file_ext}>" -D "TEST_ARGS:STRING=-v;-r;${resultfile}.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${resultfile}.out" @@ -96,7 +95,7 @@ macro (ADD_H5_CMP resultfile resultcode) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5MKGRP_CMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5mkgrp> ${ARGN}) + add_test (NAME H5MKGRP_CMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5mkgrp${tgt_file_ext}> ${ARGN}) else () add_test ( NAME H5MKGRP_CMP-${resultfile}-clear-objects @@ -109,7 +108,7 @@ NAME H5MKGRP_CMP-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5mkgrp${tgt_ext}>" + -D "TEST_PROGRAM=$<TARGET_FILE:h5mkgrp${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${resultfile}.out" diff --git a/tools/test/misc/CMakeTestsRepart.cmake b/tools/test/misc/CMakeTestsRepart.cmake index fa49c53..20ae263 100644 --- a/tools/test/misc/CMakeTestsRepart.cmake +++ b/tools/test/misc/CMakeTestsRepart.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. # @@ -58,12 +58,6 @@ ############################################################################## ############################################################################## - if (NOT BUILD_SHARED_LIBS) - set (tgt_ext "") - else () - set (tgt_ext "-shared") - endif () - # Remove any output file left over from previous test run add_test ( NAME H5REPART-clearall-objects @@ -82,7 +76,7 @@ # repartition family member size to 20,000 bytes. add_test ( NAME H5REPART-h5repart_20K - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repart${tgt_ext}> -m 20000 family_file%05d.h5 fst_family%05d.h5 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repart${tgt_file_ext}> -m 20000 family_file%05d.h5 fst_family%05d.h5 ) set_tests_properties (H5REPART-h5repart_20K PROPERTIES FIXTURES_REQUIRED clear_testrepart @@ -91,7 +85,7 @@ # repartition family member size to 5 KB. add_test ( NAME H5REPART-h5repart_5K - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repart${tgt_ext}> -m 5k family_file%05d.h5 scd_family%05d.h5 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repart${tgt_file_ext}> -m 5k family_file%05d.h5 scd_family%05d.h5 ) set_tests_properties (H5REPART-h5repart_5K PROPERTIES FIXTURES_REQUIRED clear_testrepart @@ -100,7 +94,7 @@ # convert family file to sec2 file of 20,000 bytes add_test ( NAME H5REPART-h5repart_single - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repart${tgt_ext}> -m 20000 -family_to_single family_file%05d.h5 family_to_single.h5 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repart${tgt_file_ext}> -m 20000 -family_to_single family_file%05d.h5 family_to_single.h5 ) set_tests_properties (H5REPART-h5repart_single PROPERTIES FIXTURES_REQUIRED clear_testrepart @@ -109,7 +103,7 @@ # convert family file to sec2 file of 20,000 bytes (old argument) add_test ( NAME H5REPART-h5repart_sec2 - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repart${tgt_ext}> -m 20000 -family_to_sec2 family_file%05d.h5 family_to_sec2.h5 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repart${tgt_file_ext}> -m 20000 -family_to_sec2 family_file%05d.h5 family_to_sec2.h5 ) set_tests_properties (H5REPART-h5repart_sec2 PROPERTIES FIXTURES_REQUIRED clear_testrepart diff --git a/tools/test/misc/Makefile.am b/tools/test/misc/Makefile.am index f2d2489..2dcbe7c 100644 --- a/tools/test/misc/Makefile.am +++ b/tools/test/misc/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. ## @@ -21,7 +21,7 @@ include $(top_srcdir)/config/commence.am SUBDIRS=vds # Include src directory -AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib +AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib #test scripts and programs TEST_PROG=h5repart_gentest h5clear_gentest talign diff --git a/tools/test/misc/clear_open_chk.c b/tools/test/misc/clear_open_chk.c index 3a61385..dd217b0 100644 --- a/tools/test/misc/clear_open_chk.c +++ b/tools/test/misc/clear_open_chk.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -40,11 +40,11 @@ usage(void) int main(int argc, char *argv[]) { - char *fname; /* The HDF5 file name */ - hid_t fid; /* File ID */ + char *fname; /* The HDF5 file name */ + hid_t fid; /* File ID */ /* Check the # of arguments */ - if(argc != 2) { + if (argc != 2) { usage(); HDexit(EXIT_FAILURE); } @@ -53,7 +53,7 @@ main(int argc, char *argv[]) fname = HDstrdup(argv[1]); /* Try opening the file */ - if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { + if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, (size_t)0)) < 0) { HDfprintf(stderr, "clear_open_chk: unable to open the file\n"); HDfree(fname); HDexit(EXIT_FAILURE); @@ -61,7 +61,7 @@ main(int argc, char *argv[]) HDfree(fname); /* Close the file */ - if(H5Fclose(fid) < 0) { + if (H5Fclose(fid) < 0) { HDfprintf(stderr, "clear_open_chk: cannot close the file\n"); HDexit(EXIT_FAILURE); } diff --git a/tools/test/misc/h5clear_gentest.c b/tools/test/misc/h5clear_gentest.c index 96d7e75e7..97feabd 100644 --- a/tools/test/misc/h5clear_gentest.c +++ b/tools/test/misc/h5clear_gentest.c @@ -6,40 +6,40 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "hdf5.h" -#include "H5private.h" +#include "h5test.h" /* The HDF5 test files */ const char *FILENAME[] = { - "h5clear_sec2_v3.h5", /* 0 -- sec2 file with superblock version 3 */ - "h5clear_log_v3.h5", /* 1 -- log file with superblock veresion 3 */ - "h5clear_sec2_v0.h5", /* 2 -- sec2 file with superblock version 0 */ - "h5clear_sec2_v2.h5" /* 3 -- sec2 file with superblock version 2 */ + "h5clear_sec2_v3.h5", /* 0 -- sec2 file with superblock version 3 */ + "h5clear_log_v3.h5", /* 1 -- log file with superblock version 3 */ + "h5clear_sec2_v0.h5", /* 2 -- sec2 file with superblock version 0 */ + "h5clear_sec2_v2.h5" /* 3 -- sec2 file with superblock version 2 */ }; const char *FILENAME_ENHANCE[] = { - "h5clear_fsm_persist_equal.h5", /* 0: persisting free-space, stored EOA = actual EOF */ - "h5clear_fsm_persist_greater.h5", /* 1: persisting free-space, stored EOA > actual EOF */ - "h5clear_fsm_persist_less.h5", /* 2: persisting free-space, stored EOA < actual EOF */ - "h5clear_fsm_persist_user_equal.h5", /* 3: user block, persisting free-space, stored EOA = actual EOF */ - "h5clear_fsm_persist_user_greater.h5", /* 4: user block, persisting free-space, stored EOA > actual EOF */ - "h5clear_fsm_persist_user_less.h5", /* 5: user block, persisting free-space, stored EOA < actual EOF */ - "h5clear_status_noclose.h5", /* 6 -- v3 superblock, nonzero status_flags, no flush, exit, - stored EOA < actual EOF */ - "h5clear_fsm_persist_noclose.h5" /* 7 -- persisting free-space, no flush, exit, stored EOA < actual EOF */ + "h5clear_fsm_persist_equal.h5", /* 0: persisting free-space, stored EOA = actual EOF */ + "h5clear_fsm_persist_greater.h5", /* 1: persisting free-space, stored EOA > actual EOF */ + "h5clear_fsm_persist_less.h5", /* 2: persisting free-space, stored EOA < actual EOF */ + "h5clear_fsm_persist_user_equal.h5", /* 3: user block, persisting free-space, stored EOA = actual EOF */ + "h5clear_fsm_persist_user_greater.h5", /* 4: user block, persisting free-space, stored EOA > actual EOF */ + "h5clear_fsm_persist_user_less.h5", /* 5: user block, persisting free-space, stored EOA < actual EOF */ + "h5clear_status_noclose.h5", /* 6 -- v3 superblock, nonzero status_flags, no flush, exit, + stored EOA < actual EOF */ + "h5clear_fsm_persist_noclose.h5" /* 7 -- persisting free-space, no flush, exit, stored EOA < actual EOF */ }; -#define KB 1024U +#define KB 1024U -#define CACHE_IMAGE_FILE "h5clear_mdc_image.h5" -#define DSET "DSET" -#define DATASET "dset" -#define NUM_ELMTS 100 -#define USERBLOCK 512 +#define CACHE_IMAGE_FILE "h5clear_mdc_image.h5" +#define DSET "DSET" +#define DATASET "dset" +#define NUM_ELMTS 100 +#define USERBLOCK 512 /*------------------------------------------------------------------------- * Function: gen_cache_image_file @@ -56,82 +56,93 @@ const char *FILENAME_ENHANCE[] = { static int gen_cache_image_file(const char *fname) { - hid_t fid = -1; /* File ID */ - hid_t did = -1, sid = -1; /* Dataset ID, dataspace ID */ - hid_t fapl = -1; /* File access property list */ - hid_t dcpl = -1; /* Dataset creation property list */ - hsize_t dims[2]; /* Dimension sizes */ - hsize_t chunks[2]; /* Chunked dimension sizes */ - int buf[50][100]; /* Buffer for data to write */ - int i, j; /* Local index variables */ - H5AC_cache_image_config_t cache_image_config = /* Cache image input configuration */ - { H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, - TRUE, FALSE, - H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE}; + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t did = -1, sid = H5I_INVALID_HID; /* Dataset ID, dataspace ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ + hsize_t dims[2]; /* Dimension sizes */ + hsize_t chunks[2]; /* Chunked dimension sizes */ + int i, j; /* Local index variables */ + struct { + int arr[50][100]; + } * buf; /* Buffer for data to write */ + H5AC_cache_image_config_t cache_image_config = /* Cache image input configuration */ + {H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, TRUE, FALSE, H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE}; + + /* Create and fill array */ + buf = malloc(sizeof(*buf)); + if (NULL == buf) + goto error; + for (i = 0; i < 50; i++) + for (j = 0; j < 100; j++) + buf->arr[i][j] = i * j; /* Create a copy of file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; /* Enable latest format in fapl */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; /* Enable metadata cache image in fapl */ - if(H5Pset_mdc_image_config(fapl, &cache_image_config) < 0) + if (H5Pset_mdc_image_config(fapl, &cache_image_config) < 0) goto error; /* Create the file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; /* Create dataspace */ dims[0] = 50; dims[1] = 100; - if((sid = H5Screate_simple(2, dims, NULL)) < 0) + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) goto error; - /* Initialize buffer for writing to dataset */ - for(i = 0; i < 50; i++) - for(j = 0; j < 100; j++) - buf[i][j] = i * j; - /* Set up to create a chunked dataset */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; chunks[0] = 5; chunks[1] = 10; - if(H5Pset_chunk(dcpl, 2, chunks) < 0) + if (H5Pset_chunk(dcpl, 2, chunks) < 0) goto error; - if((did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write to the dataset */ - 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 error; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; + + HDfree(buf); + return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); H5Dclose(did); H5Fclose(fid); H5Pclose(fapl); H5Pclose(dcpl); - } H5E_END_TRY; + } + H5E_END_TRY; + + HDfree(buf); + return 1; } /* gen_cache_image_file() */ @@ -164,61 +175,61 @@ error: static int gen_enhance_files(hbool_t user) { - hid_t fid = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - hsize_t dim[1]; /* Dimension sizes */ - int data[NUM_ELMTS]; /* Buffer for data */ - int fd = -1; /* The file descriptor ID */ - int64_t eoa; /* The EOA value */ - uint32_t chksum; /* The chksum value */ - int i = 0 , j = 0, u = 0; /* Local index variable */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + hsize_t dim[1]; /* Dimension sizes */ + int data[NUM_ELMTS]; /* Buffer for data */ + int fd = H5I_INVALID_HID; /* The file descriptor ID */ + int64_t eoa; /* The EOA value */ + uint32_t chksum; /* The chksum value */ + int i = 0, j = 0, u = 0; /* Local index variable */ /* Get a copy of the default file creation property */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; /* Check to see if user block will be added */ - if(user) { - if(H5Pset_userblock(fcpl, (hsize_t)USERBLOCK) < 0) + if (user) { + if (H5Pset_userblock(fcpl, (hsize_t)USERBLOCK) < 0) goto error; u = 3; } /* Set file space strategy and persisting free-space */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) goto error; /* * Create the file, then write invalid EOA to the file. */ - for(i = 0+u; i < 3+u; i++) { + for (i = 0 + u; i < 3 + u; i++) { /* Create the file with the file space strategy and persisting free-space */ - if((fid = H5Fcreate(FILENAME_ENHANCE[i], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILENAME_ENHANCE[i], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) goto error; /* Create the dataset */ dim[0] = NUM_ELMTS; - if((sid = H5Screate_simple(1, dim, NULL)) < 0) - goto error; - if((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((sid = H5Screate_simple(1, dim, NULL)) < 0) + goto error; + if ((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - for(j = 0; j < NUM_ELMTS; j++) + for (j = 0; j < NUM_ELMTS; j++) data[j] = j; /* Write the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto error; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; /* @@ -226,7 +237,7 @@ gen_enhance_files(hbool_t user) * --FILENAME_ENHANCE[0]: "h5clear_fsm_persist_equal.h5" * --FILENAME_ENHANCE[3]: "h5clear_fsm_persist_user_equal.h5", */ - if(!(i % 3)) + if (!(i % 3)) continue; /* * For the following files: @@ -239,27 +250,27 @@ gen_enhance_files(hbool_t user) * update the chksum value. */ /* Open the file */ - if((fd = open(FILENAME_ENHANCE[i], O_RDWR, 0663)) < 0) + if ((fd = open(FILENAME_ENHANCE[i], O_RDWR, 0663)) < 0) goto error; - switch(i) { + switch (i) { case 1: /* stored EOA is > EOF */ - eoa = 3048; + eoa = 3048; chksum = 268376587; break; case 2: /* stored EOA is < EOF */ - eoa = 512; + eoa = 512; chksum = 372920305; break; case 4: /* with userblock, stored EOA > EOF */ - eoa = 4000; + eoa = 4000; chksum = 4168810027; break; case 5: /* with userblock, stored EOA < EOF */ - eoa = 3000; + eoa = 3000; chksum = 3716054346; break; @@ -268,40 +279,42 @@ gen_enhance_files(hbool_t user) } /* location of "end of file address" */ - if(lseek(fd, (off_t)(28+(user?USERBLOCK:0)), SEEK_SET) < 0) + if (lseek(fd, (off_t)(28 + (user ? USERBLOCK : 0)), SEEK_SET) < 0) goto error; /* Write the bad eoa value to the file */ - if(write(fd, &eoa, sizeof(eoa)) < 0) + if (write(fd, &eoa, sizeof(eoa)) < 0) goto error; /* location of "superblock checksum" */ - if(lseek(fd, (off_t)(44+(user?USERBLOCK:0)), SEEK_SET) < 0) + if (lseek(fd, (off_t)(44 + (user ? USERBLOCK : 0)), SEEK_SET) < 0) goto error; /* Write the chksum value to the file */ - if(write(fd, &chksum, sizeof(chksum)) < 0) + if (write(fd, &chksum, sizeof(chksum)) < 0) goto error; /* Close the file */ - if(close(fd) < 0) + if (close(fd) < 0) goto error; } /* end for */ /* Close the property list */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) goto error; return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Dclose(did); H5Fclose(fid); H5Pclose(fcpl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* gen_enhance_files() */ @@ -361,39 +374,39 @@ error: int main(void) { - hid_t fid = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list */ - hid_t fapl = -1, new_fapl = -1; /* File access property lists */ - char fname[512]; /* File name */ - unsigned new_format; /* To use latest library format or not */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - hsize_t dim[1]; /* Dimension sizes */ - int data[NUM_ELMTS]; /* Buffer for data */ - int i; /* Local index variables */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ + hid_t fapl = -1, new_fapl = H5I_INVALID_HID; /* File access property lists */ + char fname[512]; /* File name */ + unsigned new_format; /* To use latest library format or not */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + hsize_t dim[1]; /* Dimension sizes */ + int data[NUM_ELMTS]; /* Buffer for data */ + int i; /* Local index variables */ /* Generate a file with cache image feature enabled */ - if(gen_cache_image_file(CACHE_IMAGE_FILE) < 0) + if (gen_cache_image_file(CACHE_IMAGE_FILE) < 0) goto error; /* Generate the first 6 files in FILENAME_ENHANCE[] */ - if(gen_enhance_files(FALSE) < 0) + if (gen_enhance_files(FALSE) < 0) goto error; - if(gen_enhance_files(TRUE) < 0) + if (gen_enhance_files(TRUE) < 0) goto error; /* * Generate files in FILENAME[] */ /* Create a copy of the file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; /* Copy the file access property list */ - if((new_fapl = H5Pcopy(fapl)) < 0) + if ((new_fapl = H5Pcopy(fapl)) < 0) goto error; /* Set to latest library format */ - if(H5Pset_libver_bounds(new_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(new_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; /* @@ -401,54 +414,56 @@ main(void) * --FILENAME[0]: "h5clear_sec2_v3.h5", "latest_h5clear_sec2_v3.h5" * --FILENAME[1]: "h5clear_log_v3.h5", "latest_h5clear_log_v3.h5" */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { - hid_t fapl2, my_fapl; /* File access property lists */ + for (new_format = FALSE; new_format <= TRUE; new_format++) { + hid_t fapl2, my_fapl; /* File access property lists */ /* Set to use the appropriate file access property list */ - if(new_format) + if (new_format) fapl2 = new_fapl; else fapl2 = fapl; /* * Create a sec2 file */ - if((my_fapl = H5Pcopy(fapl2)) < 0) + if ((my_fapl = H5Pcopy(fapl2)) < 0) goto error; /* Create the file */ - HDsprintf(fname, "%s%s", new_format? "latest_":"", FILENAME[0]); - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT, my_fapl)) < 0) + HDsnprintf(fname, sizeof(fname), "%s%s", new_format ? "latest_" : "", FILENAME[0]); + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT, + my_fapl)) < 0) goto error; /* Flush the file */ - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) goto error; /* Close the property list */ - if(H5Pclose(my_fapl) < 0) + if (H5Pclose(my_fapl) < 0) goto error; /* * Create a log file */ /* Create a copy of file access property list */ - if((my_fapl = H5Pcopy(fapl2)) < 0) - goto error; + if ((my_fapl = H5Pcopy(fapl2)) < 0) + goto error; /* Setup the fapl for the log driver */ - if(H5Pset_fapl_log(my_fapl, "append.log", (unsigned long long)H5FD_LOG_ALL, (size_t)(4 * KB)) < 0) + if (H5Pset_fapl_log(my_fapl, "append.log", (unsigned long long)H5FD_LOG_ALL, (size_t)(4 * KB)) < 0) goto error; /* Create the file */ - HDsprintf(fname, "%s%s", new_format? "latest_":"", FILENAME[1]); - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT, my_fapl)) < 0) + HDsnprintf(fname, sizeof(fname), "%s%s", new_format ? "latest_" : "", FILENAME[1]); + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT, + my_fapl)) < 0) goto error; /* Flush the file */ - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) goto error; /* Close the property list */ - if(H5Pclose(my_fapl) < 0) + if (H5Pclose(my_fapl) < 0) goto error; } /* end for */ @@ -457,39 +472,37 @@ main(void) * Create a sec2 file with v0 superblock but nonzero status_flags: * FILENAME[2]: "h5clear_sec2_v0.h5" */ - if((fid = H5Fcreate(FILENAME[2], H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(FILENAME[2], H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; /* Flush the file */ - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) goto error; - /* * Create a sec2 file with v2 superblock but nonzero status_flags: * FILENAME[3]: "h5clear_sec2_v2.h5" */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; - if(H5Pset_shared_mesg_nindexes(fcpl, 1) < 0) + if (H5Pset_shared_mesg_nindexes(fcpl, 1) < 0) goto error; - if(H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_DTYPE_FLAG, 50) < 0) + if (H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_DTYPE_FLAG, 50) < 0) goto error; - if((fid = H5Fcreate(FILENAME[3], H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(FILENAME[3], H5F_ACC_TRUNC, fcpl, fapl)) < 0) goto error; /* Flush the file */ - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) goto error; - /* Close the property lists */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) goto error; - if(H5Pclose(new_fapl) < 0) + if (H5Pclose(new_fapl) < 0) goto error; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) goto error; /* @@ -506,42 +519,41 @@ main(void) * --does not flush the file, just exit without closing file: * --this file is similar to the user-suppplied test file attached with HDFFV-10347 */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; /* Set to latest format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - goto error; + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + goto error; /* Create file with SWMR-write access */ - if((fid = H5Fcreate(FILENAME_ENHANCE[6], H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(FILENAME_ENHANCE[6], H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) goto error; /* Create the dataset */ dim[0] = NUM_ELMTS; - if((sid = H5Screate_simple(1, dim, NULL)) < 0) + if ((sid = H5Screate_simple(1, dim, NULL)) < 0) goto error; - if((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - for(i = 0; i < NUM_ELMTS; i++) + for (i = 0; i < NUM_ELMTS; i++) data[i] = i; /* Write the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto error; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) goto error; /* Does not flush and does not close the file */ - /* * FILENAME_ENHANCE[7]: h5clear_fsm_persist_noclose.h5 * --stored EOA < actual EOF @@ -550,42 +562,41 @@ main(void) * --undefined fsinfo.fs_addr * --does not flush the file, just exit without closing */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; /* Set file space strategy and persisting free-space */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) - goto error; + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) + goto error; /* Create the file with the set file space info */ - if((fid = H5Fcreate(FILENAME_ENHANCE[7], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILENAME_ENHANCE[7], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) goto error; /* Create the dataset */ dim[0] = NUM_ELMTS; - if((sid = H5Screate_simple(1, dim, NULL)) < 0) + if ((sid = H5Screate_simple(1, dim, NULL)) < 0) goto error; - if((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - for(i = 0; i < NUM_ELMTS; i++) + for (i = 0; i < NUM_ELMTS; i++) data[i] = i; /* Write the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto error; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) goto error; /* Does not flush and does not close the file */ - fflush(stdout); fflush(stderr); diff --git a/tools/test/misc/h5perf_gentest.c b/tools/test/misc/h5perf_gentest.c index f50e5fb..248fd92 100644 --- a/tools/test/misc/h5perf_gentest.c +++ b/tools/test/misc/h5perf_gentest.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,77 +14,77 @@ creates a large number of attributes, groups, and datasets by specifying -a, -g, -d options respectively. Using "-h" option to see details. - Programmer: Peter Cao <xcao@hdfgroup.org>, Jan. 2013 + Programmer: Peter Cao, Jan. 2013 ****************************************************************************/ #include "hdf5.h" #include <stdio.h> #include <stdlib.h> -#define FNAME "test_perf.h5" -#define NGROUPS 20 -#define NDSETS 20 -#define NATTRS 20 -#define DIM0 40 -#define NROWS 100 -#define NTYPES 9 -#define MAXVLEN 10 -#define FIXED_LEN 8 +#define FNAME "test_perf.h5" +#define NGROUPS 20 +#define NDSETS 20 +#define NATTRS 20 +#define DIM0 40 +#define NROWS 100 +#define NTYPES 9 +#define MAXVLEN 10 +#define FIXED_LEN 8 -typedef enum { SOLID=0, LIQUID, GAS, PLASMA } phase_t; +typedef enum { SOLID = 0, LIQUID, GAS, PLASMA } phase_t; typedef struct { - int i; - unsigned long long l; - float f; - double d; - char s[FIXED_LEN]; - phase_t e; - float f_array[FIXED_LEN]; - hvl_t i_vlen; - char *s_vlen; + int i; + unsigned long long l; + float f; + double d; + char s[FIXED_LEN]; + phase_t e; + float f_array[FIXED_LEN]; + hvl_t i_vlen; + char * s_vlen; } test_comp_t; typedef struct { - int zipcode; - char *city; + int zipcode; + char *city; } zipcode_t; -int add_attrs(hid_t oid, int idx); -int add_attr(hid_t oid, const char *name, hid_t tid, hid_t sid, void *buf) ; -herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, - int nattrs, hsize_t nrows, hsize_t dim0, hsize_t chunk, int vlen, - int compressed, int latest); +int add_attrs(hid_t oid, int idx); +int add_attr(hid_t oid, const char *name, hid_t tid, hid_t sid, void *buf); +herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, int nattrs, hsize_t nrows, + hsize_t dim0, hsize_t chunk, int vlen, int compressed, int latest); -int main (int argc, char *argv[]) +int +main(int argc, char *argv[]) { char fname[32]; - int i, ngrps=NGROUPS, ndsets=NDSETS, nattrs=NATTRS, dim0=DIM0, - chunk=DIM0/10+1, nrows=NROWS, vlen=MAXVLEN, l=0, z=0; + int i, ngrps = NGROUPS, ndsets = NDSETS, nattrs = NATTRS, dim0 = DIM0, chunk = DIM0 / 10 + 1, + nrows = NROWS, vlen = MAXVLEN, l = 0, z = 0; memset(fname, 0, 32); - for (i=1; i<argc; i++) { - if (strcmp(argv[i], "-f")==0) - strcpy(fname, argv[i+1]); - else if (strcmp(argv[i], "-g")==0) - ngrps = atoi(argv[i+1]); - else if (strcmp(argv[i], "-d")==0) - ndsets = atoi(argv[i+1]); - else if (strcmp(argv[i], "-a")==0) - nattrs = atoi(argv[i+1]); - else if (strcmp(argv[i], "-r")==0) - nrows = atoi(argv[i+1]); - else if (strcmp(argv[i], "-s")==0) - dim0 = atoi(argv[i+1]); - else if (strcmp(argv[i], "-c")==0) - chunk = atoi(argv[i+1]); - else if (strcmp(argv[i], "-v")==0) - vlen = atoi(argv[i+1]); - else if (strcmp(argv[i], "-l")==0) + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-f") == 0) + strcpy(fname, argv[i + 1]); + else if (strcmp(argv[i], "-g") == 0) + ngrps = atoi(argv[i + 1]); + else if (strcmp(argv[i], "-d") == 0) + ndsets = atoi(argv[i + 1]); + else if (strcmp(argv[i], "-a") == 0) + nattrs = atoi(argv[i + 1]); + else if (strcmp(argv[i], "-r") == 0) + nrows = atoi(argv[i + 1]); + else if (strcmp(argv[i], "-s") == 0) + dim0 = atoi(argv[i + 1]); + else if (strcmp(argv[i], "-c") == 0) + chunk = atoi(argv[i + 1]); + else if (strcmp(argv[i], "-v") == 0) + vlen = atoi(argv[i + 1]); + else if (strcmp(argv[i], "-l") == 0) l = 1; - else if (strcmp(argv[i], "-z")==0) + else if (strcmp(argv[i], "-z") == 0) z = 1; - else if (strcmp(argv[i], "-h")==0) { + else if (strcmp(argv[i], "-h") == 0) { HDprintf("\nOPTONS:\n"); HDprintf("\t-f F:\tname of the test file (default: %s).\n", FNAME); HDprintf("\t-g N:\tnumber of top level groups (default: %d).\n", NGROUPS); @@ -92,7 +92,7 @@ int main (int argc, char *argv[]) HDprintf("\t-a N:\tnumber of attributes (default: %d).\n", NATTRS); HDprintf("\t-r N:\tnumber of rows in the large compound dataset (default: %d).\n", NROWS); HDprintf("\t-s N:\tsize of dim0 in datasets (default: %d).\n", DIM0); - HDprintf("\t-c N:\tchunk size of dim0 (default: %d).\n", (DIM0/10+1)); + HDprintf("\t-c N:\tchunk size of dim0 (default: %d).\n", (DIM0 / 10 + 1)); HDprintf("\t-v N:\tmax vlen size (default: %d).\n", MAXVLEN); HDprintf("\t-l:\tuse latest format (default: no).\n"); HDprintf("\t-z:\tuse gzip compression (default: no).\n"); @@ -103,11 +103,11 @@ int main (int argc, char *argv[]) } } - if (strlen(fname)<=0) + if (strlen(fname) <= 0) HDsprintf(fname, FNAME); - create_perf_test_file(fname, ngrps, ndsets, nattrs, (hsize_t)nrows, - (hsize_t)dim0, (hsize_t)chunk, vlen, z, l); + create_perf_test_file(fname, ngrps, ndsets, nattrs, (hsize_t)nrows, (hsize_t)dim0, (hsize_t)chunk, vlen, + z, l); return 0; } @@ -128,341 +128,380 @@ int main (int argc, char *argv[]) Return: Non-negative on success/Negative on failure - Programmer: Peter Cao <xcao@hdfgroup.org>, Jan. 2013 + Programmer: Peter Cao, Jan. 2013 ****************************************************************************/ -herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, - int nattrs, hsize_t nrows, hsize_t dim0, hsize_t chunk, int vlen, - int compressed, int latest) +herr_t +create_perf_test_file(const char *fname, int ngrps, int ndsets, int nattrs, hsize_t nrows, hsize_t dim0, + hsize_t chunk, int vlen, int compressed, int latest) { - int i, j, k; - hid_t fid, sid_null, sid_scalar, sid_1d, sid_2d, did, aid, sid_2, sid_large, - fapl=H5P_DEFAULT, dcpl=H5P_DEFAULT, gid1, gid2, cmp_tid, tid_str, - tid_enum, tid_array_f, tid_vlen_i, tid_vlen_s; - char name[32], tmp_name1[32], tmp_name2[32], tmp_name3[32]; - hsize_t dims[1]={dim0}, dims2d[2]={dim0, (dim0/4+1)}, dims_array[1]={FIXED_LEN}, - dim1[1]={2}; - char *enum_names[4] = {"SOLID", "LIQUID", "GAS", "PLASMA"}; - test_comp_t *buf_comp=NULL, *buf_comp_large=NULL; - int *buf_int=NULL; - float (*buf_float_a)[FIXED_LEN]=NULL; - double **buf_double2d=NULL; - hvl_t *buf_vlen_i=NULL; - char (*buf_str)[FIXED_LEN]; - char **buf_vlen_s=NULL; - hobj_ref_t buf_ref[2]; + int i, j, k; + hid_t fid, sid_null, sid_scalar, sid_1d, sid_2d, did, aid, sid_2, sid_large, + fapl = H5P_DEFAULT, dcpl = H5P_DEFAULT, gid1, gid2, cmp_tid, tid_str, tid_enum, tid_array_f, + tid_vlen_i, tid_vlen_s; + char name[32], tmp_name1[32], tmp_name2[32], tmp_name3[32]; + hsize_t dims[1] = {dim0}, dims2d[2] = {dim0, (dim0 / 4 + 1)}, dims_array[1] = {FIXED_LEN}, dim1[1] = {2}; + char * enum_names[4] = {"SOLID", "LIQUID", "GAS", "PLASMA"}; + test_comp_t *buf_comp = NULL, *buf_comp_large = NULL; + int * buf_int = NULL; + float(*buf_float_a)[FIXED_LEN] = NULL; + double **buf_double2d = NULL; + hvl_t * buf_vlen_i = NULL; + char(*buf_str)[FIXED_LEN]; + char ** buf_vlen_s = NULL; + hobj_ref_t buf_ref[2]; hdset_reg_ref_t buf_reg_ref[2]; - size_t offset, len; - herr_t status; - char *names[NTYPES] = { "int", "ulong", "float", "double", "fixed string", - "enum", "fixed float array", "vlen int array", "vlen strings"}; - hid_t types[NTYPES] = { H5T_NATIVE_INT, H5T_NATIVE_UINT64, H5T_NATIVE_FLOAT, - H5T_NATIVE_DOUBLE, tid_str, tid_enum, tid_array_f, tid_vlen_i, tid_vlen_s}; - hsize_t coords[4][2] = { {0, 1}, {3, 5}, {1, 0}, {2, 4}}, start=0, stride=1, count=1; - - if (nrows < NROWS) nrows = NROWS; - if (ngrps<NGROUPS) ngrps=NGROUPS; - if (ndsets<NDSETS) ndsets=NDSETS; - if (nattrs<NATTRS) nattrs=NATTRS; - if (dim0<DIM0) dim0=DIM0; - if (chunk>dim0) chunk=dim0/4; - if (chunk<1) chunk = 1; - if (vlen<1) vlen = MAXVLEN; + size_t offset, len; + herr_t status; + char * names[NTYPES] = {"int", + "ulong", + "float", + "double", + "fixed string", + "enum", + "fixed float array", + "vlen int array", + "vlen strings"}; + hid_t types[NTYPES] = {H5T_NATIVE_INT, H5T_NATIVE_UINT64, H5T_NATIVE_FLOAT, H5T_NATIVE_DOUBLE, tid_str, + tid_enum, tid_array_f, tid_vlen_i, tid_vlen_s}; + hsize_t coords[4][2] = {{0, 1}, {3, 5}, {1, 0}, {2, 4}}, start = 0, stride = 1, count = 1; + + if (nrows < NROWS) + nrows = NROWS; + if (ngrps < NGROUPS) + ngrps = NGROUPS; + if (ndsets < NDSETS) + ndsets = NDSETS; + if (nattrs < NATTRS) + nattrs = NATTRS; + if (dim0 < DIM0) + dim0 = DIM0; + if (chunk > dim0) + chunk = dim0 / 4; + if (chunk < 1) + chunk = 1; + if (vlen < 1) + vlen = MAXVLEN; /* create fixed string datatype */ - types[4] = tid_str = H5Tcopy (H5T_C_S1); - H5Tset_size (tid_str, FIXED_LEN); + types[4] = tid_str = H5Tcopy(H5T_C_S1); + H5Tset_size(tid_str, FIXED_LEN); /* create enum datatype */ types[5] = tid_enum = H5Tenum_create(H5T_NATIVE_INT); - for (i = (int) SOLID; i <= (int) PLASMA; i++) { - phase_t val = (phase_t) i; - status = H5Tenum_insert (tid_enum, enum_names[i], &val); + for (i = (int)SOLID; i <= (int)PLASMA; i++) { + phase_t val = (phase_t)i; + status = H5Tenum_insert(tid_enum, enum_names[i], &val); } /* create float array datatype */ - types[6] = tid_array_f = H5Tarray_create (H5T_NATIVE_FLOAT, 1, dims_array); + types[6] = tid_array_f = H5Tarray_create(H5T_NATIVE_FLOAT, 1, dims_array); /* create variable length integer datatypes */ - types[7] = tid_vlen_i = H5Tvlen_create (H5T_NATIVE_INT); + types[7] = tid_vlen_i = H5Tvlen_create(H5T_NATIVE_INT); /* create variable length string datatype */ - types[8] = tid_vlen_s = H5Tcopy (H5T_C_S1); - H5Tset_size (tid_vlen_s, H5T_VARIABLE); + types[8] = tid_vlen_s = H5Tcopy(H5T_C_S1); + H5Tset_size(tid_vlen_s, H5T_VARIABLE); /* create compound datatypes */ - cmp_tid = H5Tcreate (H5T_COMPOUND, sizeof (test_comp_t)); - offset = 0; - for (i=0; i<NTYPES-2; i++) { + cmp_tid = H5Tcreate(H5T_COMPOUND, sizeof(test_comp_t)); + offset = 0; + for (i = 0; i < NTYPES - 2; i++) { H5Tinsert(cmp_tid, names[i], offset, types[i]); offset += H5Tget_size(types[i]); } H5Tinsert(cmp_tid, names[7], offset, types[7]); - offset += sizeof (hvl_t); + offset += sizeof(hvl_t); H5Tinsert(cmp_tid, names[8], offset, types[8]); /* create dataspace */ - sid_1d = H5Screate_simple (1, dims, NULL); - sid_2d = H5Screate_simple (2, dims2d, NULL); - sid_2 = H5Screate_simple (1, dim1, NULL); - sid_large = H5Screate_simple (1, &nrows, NULL); - sid_null = H5Screate (H5S_NULL); - sid_scalar = H5Screate (H5S_SCALAR); + sid_1d = H5Screate_simple(1, dims, NULL); + sid_2d = H5Screate_simple(2, dims2d, NULL); + sid_2 = H5Screate_simple(1, dim1, NULL); + sid_large = H5Screate_simple(1, &nrows, NULL); + sid_null = H5Screate(H5S_NULL); + sid_scalar = H5Screate(H5S_SCALAR); /* create fid access property */ - fapl = H5Pcreate (H5P_FILE_ACCESS); - H5Pset_libver_bounds (fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); + fapl = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); /* create dataset creation property */ - dcpl = H5Pcreate (H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); /* set dataset chunk */ - if (chunk>0) { - H5Pset_chunk (dcpl, 1, &chunk); + if (chunk > 0) { + H5Pset_chunk(dcpl, 1, &chunk); } /* set dataset compression */ if (compressed) { - if (chunk<=0) { - chunk = dim0/10+1;; - H5Pset_chunk (dcpl, 1, &chunk); + if (chunk <= 0) { + chunk = dim0 / 10 + 1; + ; + H5Pset_chunk(dcpl, 1, &chunk); } - H5Pset_shuffle (dcpl); - H5Pset_deflate (dcpl, 6); + H5Pset_shuffle(dcpl); + H5Pset_deflate(dcpl, 6); } /* allocate buffers */ - buf_comp = (test_comp_t *)calloc(dim0, sizeof(test_comp_t)); - buf_comp_large = (test_comp_t *)calloc(nrows, sizeof(test_comp_t)); - buf_int = (int *)calloc(dim0, sizeof(int)); - buf_float_a = malloc(dim0*sizeof(*buf_float_a)); - buf_vlen_i = (hvl_t *)calloc(dim0, sizeof (hvl_t)); - buf_vlen_s = (char **)calloc(dim0, sizeof(char *)); - buf_str = malloc(dim0*sizeof (*buf_str)); - - /* allocate array of doulbe pointers */ - buf_double2d = (double **)calloc(dims2d[0],sizeof(double *)); - /* allocate a contigous chunk of memory for the data */ - buf_double2d[0] = (double *)calloc( dims2d[0]*dims2d[1],sizeof(double) ); + buf_comp = (test_comp_t *)calloc(dim0, sizeof(test_comp_t)); + buf_comp_large = (test_comp_t *)calloc(nrows, sizeof(test_comp_t)); + buf_int = (int *)calloc(dim0, sizeof(int)); + buf_float_a = malloc(dim0 * sizeof(*buf_float_a)); + buf_vlen_i = (hvl_t *)calloc(dim0, sizeof(hvl_t)); + buf_vlen_s = (char **)calloc(dim0, sizeof(char *)); + buf_str = malloc(dim0 * sizeof(*buf_str)); + + /* allocate array of double pointers */ + buf_double2d = (double **)calloc(dims2d[0], sizeof(double *)); + /* allocate a contiguous chunk of memory for the data */ + buf_double2d[0] = (double *)calloc(dims2d[0] * dims2d[1], sizeof(double)); /* assign memory city to pointer array */ - for (i=1; i <dims2d[0]; i++) buf_double2d[i] = buf_double2d[0]+i*dims2d[1]; + for (i = 1; i < dims2d[0]; i++) + buf_double2d[i] = buf_double2d[0] + i * dims2d[1]; /* fill buffer values */ len = 1; - for (i=0; i<dims[0]; i++) { - buf_comp[i].i = buf_int[i] = i-2147483648; - buf_comp[i].l = 0xffffffffffffffff-i; - buf_comp[i].f = 1.0/(i+1.0); - buf_comp[i].d = 987654321.0*i+1.0/(i+1.0); - buf_comp[i].e = (phase_t) (i % (int) (PLASMA + 1)); - - for (j=0; j<FIXED_LEN; j++) { - buf_comp[i].f_array[j] = buf_float_a[i][j] = i*100+j; - buf_str[i][j] = 'a' + (i%26); + for (i = 0; i < dims[0]; i++) { + buf_comp[i].i = buf_int[i] = i - 2147483648; + buf_comp[i].l = 0xffffffffffffffff - i; + buf_comp[i].f = 1.0 / (i + 1.0); + buf_comp[i].d = 987654321.0 * i + 1.0 / (i + 1.0); + buf_comp[i].e = (phase_t)(i % (int)(PLASMA + 1)); + + for (j = 0; j < FIXED_LEN; j++) { + buf_comp[i].f_array[j] = buf_float_a[i][j] = i * 100 + j; + buf_str[i][j] = 'a' + (i % 26); } - buf_str[i][FIXED_LEN-1] = 0; + buf_str[i][FIXED_LEN - 1] = 0; strcpy(buf_comp[i].s, buf_str[i]); - len = (1-cos(i/8.0))/2*vlen+1; - if (!i) len = vlen; + len = (1 - cos(i / 8.0)) / 2 * vlen + 1; + if (!i) + len = vlen; buf_vlen_i[i].len = len; - buf_vlen_i[i].p = (int *)calloc(len, sizeof(int)); - for (j=0; j<len; j++) ((int*)(buf_vlen_i[i].p))[j] = i*100+j; + buf_vlen_i[i].p = (int *)calloc(len, sizeof(int)); + for (j = 0; j < len; j++) + ((int *)(buf_vlen_i[i].p))[j] = i * 100 + j; buf_comp[i].i_vlen = buf_vlen_i[i]; buf_vlen_s[i] = (char *)calloc(len, sizeof(char)); - for (j=0; j<len-1; j++) - buf_vlen_s[i][j] = j%26+'A'; + for (j = 0; j < len - 1; j++) + buf_vlen_s[i][j] = j % 26 + 'A'; buf_comp[i].s_vlen = buf_vlen_s[i]; - for (j=0; j<dims2d[1]; j++) - buf_double2d[i][j] = i+j/10000.0; + for (j = 0; j < dims2d[1]; j++) + buf_double2d[i][j] = i + j / 10000.0; } - for (i=0; i<nrows; i++) { - buf_comp_large[i].i = i-2147483648; - buf_comp_large[i].l = 0xffffffffffffffff-i; - buf_comp_large[i].f = 1.0/(i+1.0); - buf_comp_large[i].d = 987654321.0*i+1.0/(i+1.0); - buf_comp_large[i].e = (phase_t) (i % (int) (PLASMA + 1)); - for (j=0; j<FIXED_LEN-1; j++) { - buf_comp_large[i].f_array[j] = i*100+j; - buf_comp_large[i].s[j] = 'a' + (i%26); + for (i = 0; i < nrows; i++) { + buf_comp_large[i].i = i - 2147483648; + buf_comp_large[i].l = 0xffffffffffffffff - i; + buf_comp_large[i].f = 1.0 / (i + 1.0); + buf_comp_large[i].d = 987654321.0 * i + 1.0 / (i + 1.0); + buf_comp_large[i].e = (phase_t)(i % (int)(PLASMA + 1)); + for (j = 0; j < FIXED_LEN - 1; j++) { + buf_comp_large[i].f_array[j] = i * 100 + j; + buf_comp_large[i].s[j] = 'a' + (i % 26); } - len = i%vlen+1; + len = i % vlen + 1; buf_comp_large[i].i_vlen.len = len; - buf_comp_large[i].i_vlen.p = (int *)calloc(len, sizeof(int)); - for (j=0; j<len; j++) ((int*)(buf_comp_large[i].i_vlen.p))[j] = i*100+j; - buf_comp_large[i].s_vlen = (char *)calloc(i+2, sizeof(char)); - for (j=0; j<i+1; j++) (buf_comp_large[i].s_vlen)[j] = j%26+'A'; + buf_comp_large[i].i_vlen.p = (int *)calloc(len, sizeof(int)); + for (j = 0; j < len; j++) + ((int *)(buf_comp_large[i].i_vlen.p))[j] = i * 100 + j; + buf_comp_large[i].s_vlen = (char *)calloc(i + 2, sizeof(char)); + for (j = 0; j < i + 1; j++) + (buf_comp_large[i].s_vlen)[j] = j % 26 + 'A'; } /* create file */ if (latest) - fid = H5Fcreate (fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); else - fid = H5Fcreate (fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); add_attrs(fid, 0); HDsprintf(name, "a cmp ds of %d rows", nrows); - did = H5Dcreate (fid, name, cmp_tid, sid_large, H5P_DEFAULT, dcpl, H5P_DEFAULT); - H5Dwrite (did, cmp_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_comp_large); + did = H5Dcreate(fid, name, cmp_tid, sid_large, H5P_DEFAULT, dcpl, H5P_DEFAULT); + H5Dwrite(did, cmp_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_comp_large); add_attrs(did, 0); H5Dclose(did); // /* add attributes*/ - gid1 = H5Gcreate (fid, "attributes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (nattrs<1) nattrs = 1; - i=0; - while (i<nattrs) i += add_attrs(gid1, i); + gid1 = H5Gcreate(fid, "attributes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (nattrs < 1) + nattrs = 1; + i = 0; + while (i < nattrs) + i += add_attrs(gid1, i); H5Gclose(gid1); /* add many sub groups to a group*/ - gid1 = H5Gcreate (fid, "groups", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + gid1 = H5Gcreate(fid, "groups", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); add_attrs(gid1, 0); - for (i=0; i<ngrps; i++) { + for (i = 0; i < ngrps; i++) { /* create sub groups */ HDsprintf(name, "g%02d", i); - gid2 = H5Gcreate (gid1, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (i<10) add_attrs(gid2, 0); + gid2 = H5Gcreate(gid1, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (i < 10) + add_attrs(gid2, 0); H5Gclose(gid2); } H5Gclose(gid1); /* add many datasets to a group */ - gid1 = H5Gcreate (fid, "datasets", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + gid1 = H5Gcreate(fid, "datasets", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); add_attrs(gid1, 0); - for (j=0; j<ndsets; j+=12) { + for (j = 0; j < ndsets; j += 12) { /* 1 add a null dataset */ HDsprintf(name, "%05d null dataset", j); - did = H5Dcreate (gid1, name, H5T_STD_I32LE, sid_null, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (!j) add_attrs(did, j); + did = H5Dcreate(gid1, name, H5T_STD_I32LE, sid_null, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (!j) + add_attrs(did, j); H5Dclose(did); /* 2 add scalar int point */ HDsprintf(name, "%05d scalar int point", j); - did = H5Dcreate (gid1, name, H5T_NATIVE_INT, sid_scalar, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite (did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &j); - if (!j) add_attrs(did, j); + did = H5Dcreate(gid1, name, H5T_NATIVE_INT, sid_scalar, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &j); + if (!j) + add_attrs(did, j); H5Dclose(did); /* 3 scalar vlen string */ HDsprintf(name, "%05d scalar vlen string", j); - did = H5Dcreate (gid1, name, tid_vlen_s, sid_scalar, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite (did, tid_vlen_s, H5S_ALL, H5S_ALL, H5P_DEFAULT, &buf_vlen_s[0]); - if (!j) add_attrs(did, j); + did = H5Dcreate(gid1, name, tid_vlen_s, sid_scalar, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Dwrite(did, tid_vlen_s, H5S_ALL, H5S_ALL, H5P_DEFAULT, &buf_vlen_s[0]); + if (!j) + add_attrs(did, j); H5Dclose(did); /* 4 add fixed-length float array */ HDsprintf(name, "%05d fixed-length float array", j); - did = H5Dcreate (gid1, name, tid_array_f, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); - H5Dwrite (did, tid_array_f, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_float_a); - if (!j) add_attrs(did, j); + did = H5Dcreate(gid1, name, tid_array_f, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); + H5Dwrite(did, tid_array_f, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_float_a); + if (!j) + add_attrs(did, j); H5Dclose(did); /* 5 add fixed-length strings */ HDsprintf(name, "%05d fixed-length strings", j); - did = H5Dcreate (gid1, name, tid_str, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); - H5Dwrite (did, tid_str, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_str); - if (!j) add_attrs(did, j); + did = H5Dcreate(gid1, name, tid_str, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); + H5Dwrite(did, tid_str, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_str); + if (!j) + add_attrs(did, j); H5Dclose(did); /* 6 add compound data */ - HDsprintf(name, "%05d compund data", j); - did = H5Dcreate (gid1, name, cmp_tid, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); - H5Dwrite (did, cmp_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_comp); - if (!j) add_attrs(did, j); + HDsprintf(name, "%05d compound data", j); + did = H5Dcreate(gid1, name, cmp_tid, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); + H5Dwrite(did, cmp_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_comp); + if (!j) + add_attrs(did, j); H5Dclose(did); /* 7 add 2D double */ HDsprintf(name, "%05d 2D double", j); - strcpy (tmp_name1, name); - did = H5Dcreate (gid1, name, H5T_NATIVE_DOUBLE, sid_2d, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite (did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_double2d[0]); - if (!j) add_attrs(did, j); + strcpy(tmp_name1, name); + did = H5Dcreate(gid1, name, H5T_NATIVE_DOUBLE, sid_2d, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Dwrite(did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_double2d[0]); + if (!j) + add_attrs(did, j); H5Dclose(did); /* 8 add 1D int array */ HDsprintf(name, "%05d 1D int array", j); - did = H5Dcreate (gid1, name, H5T_NATIVE_INT, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); - H5Dwrite (did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_int); - if (!j) add_attrs(did, j); + did = H5Dcreate(gid1, name, H5T_NATIVE_INT, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); + H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_int); + if (!j) + add_attrs(did, j); H5Dclose(did); /* 9 add vlen int array */ HDsprintf(name, "%05d vlen int array", j); - strcpy (tmp_name2, name); - did = H5Dcreate (gid1, name, tid_vlen_i, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); - H5Dwrite (did, tid_vlen_i, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_vlen_i); - if (!j) add_attrs(did, j); + strcpy(tmp_name2, name); + did = H5Dcreate(gid1, name, tid_vlen_i, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); + H5Dwrite(did, tid_vlen_i, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_vlen_i); + if (!j) + add_attrs(did, j); H5Dclose(did); /* 10 add vlen strings */ HDsprintf(name, "%05d vlen strings", j); - strcpy (tmp_name3, name); - did = H5Dcreate (gid1, name, tid_vlen_s, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); - H5Dwrite (did, tid_vlen_s, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_vlen_s); - if (!j) add_attrs(did, j); + strcpy(tmp_name3, name); + did = H5Dcreate(gid1, name, tid_vlen_s, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); + H5Dwrite(did, tid_vlen_s, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_vlen_s); + if (!j) + add_attrs(did, j); H5Dclose(did); /* 11 add object refs */ - H5Rcreate(&buf_ref[0],gid1, ".", H5R_OBJECT, (hid_t)-1); - H5Rcreate(&buf_ref[1],gid1, tmp_name3, H5R_OBJECT, (hid_t)-1); + H5Rcreate(&buf_ref[0], gid1, ".", H5R_OBJECT, (hid_t)-1); + H5Rcreate(&buf_ref[1], gid1, tmp_name3, H5R_OBJECT, (hid_t)-1); HDsprintf(name, "%05d obj refs", j); - did = H5Dcreate (gid1, name, H5T_STD_REF_OBJ, sid_2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite (did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_ref); - if (!j) add_attrs(did, j); + did = H5Dcreate(gid1, name, H5T_STD_REF_OBJ, sid_2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Dwrite(did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_ref); + if (!j) + add_attrs(did, j); H5Dclose(did); /* 12 add region refs */ - H5Sselect_elements (sid_2d, H5S_SELECT_SET, 4, coords[0]); - H5Rcreate(&buf_reg_ref[0],gid1, tmp_name1, H5R_DATASET_REGION, sid_2d); + H5Sselect_elements(sid_2d, H5S_SELECT_SET, 4, coords[0]); + H5Rcreate(&buf_reg_ref[0], gid1, tmp_name1, H5R_DATASET_REGION, sid_2d); H5Sselect_none(sid_2d); - count = dims[0]/2+1; - H5Sselect_hyperslab (sid_1d, H5S_SELECT_SET, &start, &stride, &count,NULL); - H5Rcreate(&buf_reg_ref[1],gid1, tmp_name2, H5R_DATASET_REGION, sid_1d); + count = dims[0] / 2 + 1; + H5Sselect_hyperslab(sid_1d, H5S_SELECT_SET, &start, &stride, &count, NULL); + H5Rcreate(&buf_reg_ref[1], gid1, tmp_name2, H5R_DATASET_REGION, sid_1d); H5Sselect_none(sid_1d); HDsprintf(name, "%05d region refs", j); - did = H5Dcreate (gid1, name, H5T_STD_REF_DSETREG, sid_2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite (did, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_reg_ref); - if (!j) add_attrs(did, j); + did = H5Dcreate(gid1, name, H5T_STD_REF_DSETREG, sid_2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Dwrite(did, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_reg_ref); + if (!j) + add_attrs(did, j); H5Dclose(did); } H5Gclose(gid1); - H5Tclose (tid_array_f); - H5Tclose (tid_vlen_i); - H5Tclose (tid_vlen_s); - H5Tclose (tid_enum); - H5Tclose (tid_str); - H5Tclose (cmp_tid); - H5Pclose (dcpl); - H5Pclose (fapl); - H5Sclose (sid_1d); - H5Sclose (sid_2d); - H5Sclose (sid_2); - H5Sclose (sid_large); - H5Sclose (sid_null); - H5Sclose (sid_scalar); - H5Fclose (fid); - - for (i=0; i<dims[0]; i++) { - if (buf_vlen_i[i].p) free(buf_vlen_i[i].p); - if (buf_vlen_s[i]) free(buf_vlen_s[i]); + H5Tclose(tid_array_f); + H5Tclose(tid_vlen_i); + H5Tclose(tid_vlen_s); + H5Tclose(tid_enum); + H5Tclose(tid_str); + H5Tclose(cmp_tid); + H5Pclose(dcpl); + H5Pclose(fapl); + H5Sclose(sid_1d); + H5Sclose(sid_2d); + H5Sclose(sid_2); + H5Sclose(sid_large); + H5Sclose(sid_null); + H5Sclose(sid_scalar); + H5Fclose(fid); + + for (i = 0; i < dims[0]; i++) { + if (buf_vlen_i[i].p) + free(buf_vlen_i[i].p); + if (buf_vlen_s[i]) + free(buf_vlen_s[i]); } - for (i=0; i<nrows; i++) { - if (buf_comp_large[i].i_vlen.p) free(buf_comp_large[i].i_vlen.p); - if (buf_comp_large[i].s_vlen) free(buf_comp_large[i].s_vlen); + for (i = 0; i < nrows; i++) { + if (buf_comp_large[i].i_vlen.p) + free(buf_comp_large[i].i_vlen.p); + if (buf_comp_large[i].s_vlen) + free(buf_comp_large[i].s_vlen); } - free (buf_comp); - free (buf_comp_large); - free (buf_int); - free (buf_float_a); - free (buf_double2d[0]); - free (buf_double2d); - free (buf_str); + free(buf_comp); + free(buf_comp_large); + free(buf_int); + free(buf_float_a); + free(buf_double2d[0]); + free(buf_double2d); + free(buf_str); free(buf_vlen_i); free(buf_vlen_s); @@ -470,13 +509,14 @@ herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, } /* add a single attribute */ -int add_attr(hid_t oid, const char *name, hid_t tid, hid_t sid, void *buf) +int +add_attr(hid_t oid, const char *name, hid_t tid, hid_t sid, void *buf) { hid_t aid; - aid = H5Acreate (oid, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT); - if (aid <0) - return 0; + aid = H5Acreate(oid, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT); + if (aid < 0) + return 0; H5Awrite(aid, tid, buf); @@ -490,60 +530,61 @@ int add_attr(hid_t oid, const char *name, hid_t tid, hid_t sid, void *buf) returns the number of attributes added to the objects. */ -int add_attrs(hid_t oid, int idx) +int +add_attrs(hid_t oid, int idx) { - char name[32]; - int i0, i1, i2, j, nattrs=0; - hid_t aid, tid, tid1, sid; - hvl_t i_vlen[4]; - hobj_ref_t ref; - zipcode_t cmp_data[4]; - unsigned int i = 0xffffffff; - long long l = -2147483647; - float f = 123456789.987654321; - double d = 987654321.123456789; - char *s[7] = {"Parting", "is such", "sweeter", "sorrow."}; - float f_array[4] = {1.0, 2.22, 3.333, 4.444}; - char *s_vlen[4] = {"Parting", "is such", "sweet", "sorrow."}; - hsize_t dims1[1]={1}, dims2[1]={4}, dims3[2]={3,5}; - int int3d[4][3][5]; - size_t offset = 0; - - for (i0=0; i0<4; i0++) { - i_vlen[i0].len = (i0+1); - i_vlen[i0].p = (int *)calloc(i_vlen[i0].len, sizeof(int)); - for (j=0; j<i_vlen[i0].len; j++) - ((int *)i_vlen[i0].p)[j] = i0*100+j; - for (i1=0; i1<3; i1++) { - for (i2=0; i2<5; i2++) - int3d[i0][i1][i2] = i0*i1-i1*i2+i0*i2; + char name[32]; + int i0, i1, i2, j, nattrs = 0; + hid_t aid, tid, tid1, sid; + hvl_t i_vlen[4]; + hobj_ref_t ref; + zipcode_t cmp_data[4]; + unsigned int i = 0xffffffff; + long long l = -2147483647; + float f = 123456789.987654321; + double d = 987654321.123456789; + char * s[7] = {"Parting", "is such", "sweeter", "sorrow."}; + float f_array[4] = {1.0, 2.22, 3.333, 4.444}; + char * s_vlen[4] = {"Parting", "is such", "sweet", "sorrow."}; + hsize_t dims1[1] = {1}, dims2[1] = {4}, dims3[2] = {3, 5}; + int int3d[4][3][5]; + size_t offset = 0; + + for (i0 = 0; i0 < 4; i0++) { + i_vlen[i0].len = (i0 + 1); + i_vlen[i0].p = (int *)calloc(i_vlen[i0].len, sizeof(int)); + for (j = 0; j < i_vlen[i0].len; j++) + ((int *)i_vlen[i0].p)[j] = i0 * 100 + j; + for (i1 = 0; i1 < 3; i1++) { + for (i2 = 0; i2 < 5; i2++) + int3d[i0][i1][i2] = i0 * i1 - i1 * i2 + i0 * i2; } } cmp_data[0].zipcode = 01001; - cmp_data[0].city = "Agawam, Massachusetts"; + cmp_data[0].city = "Agawam, Massachusetts"; cmp_data[1].zipcode = 99950; - cmp_data[1].city = "Ketchikan, Alaska"; + cmp_data[1].city = "Ketchikan, Alaska"; cmp_data[2].zipcode = 00501; - cmp_data[2].city = "Holtsville, New York"; + cmp_data[2].city = "Holtsville, New York"; cmp_data[3].zipcode = 61820; - cmp_data[3].city = "Champaign, Illinois"; + cmp_data[3].city = "Champaign, Illinois"; /* 1 scalar point */ - sid = H5Screate (H5S_SCALAR); + sid = H5Screate(H5S_SCALAR); HDsprintf(name, "%05d scalar int", idx); nattrs += add_attr(oid, name, H5T_NATIVE_UINT, sid, &i); HDsprintf(name, "%05d scalar ulong", idx); nattrs += add_attr(oid, name, H5T_NATIVE_INT64, sid, &l); HDsprintf(name, "%05d scalar str", idx); - tid = H5Tcopy (H5T_C_S1); - H5Tset_size (tid, H5T_VARIABLE); + tid = H5Tcopy(H5T_C_S1); + H5Tset_size(tid, H5T_VARIABLE); nattrs += add_attr(oid, name, tid, sid, &s[2]); H5Tclose(tid); H5Sclose(sid); /* 4 single point */ - sid = H5Screate_simple (1, dims1, NULL); + sid = H5Screate_simple(1, dims1, NULL); H5Rcreate(&ref, oid, ".", H5R_OBJECT, (hid_t)-1); HDsprintf(name, "%05d single float", idx); nattrs += add_attr(oid, name, H5T_NATIVE_FLOAT, sid, &f); @@ -554,14 +595,14 @@ int add_attrs(hid_t oid, int idx) H5Sclose(sid); /* 7 fixed length 1D array */ - sid = H5Screate_simple (1, dims1, NULL); - tid = H5Tarray_create (H5T_NATIVE_FLOAT, 1, dims2); + sid = H5Screate_simple(1, dims1, NULL); + tid = H5Tarray_create(H5T_NATIVE_FLOAT, 1, dims2); HDsprintf(name, "%05d array float", idx); nattrs += add_attr(oid, name, tid, sid, &f_array[0]); H5Tclose(tid); - tid = H5Tcopy (H5T_C_S1); - H5Tset_size (tid, strlen(s[0])+1); - tid1 = H5Tarray_create (tid, 1, dims2); + tid = H5Tcopy(H5T_C_S1); + H5Tset_size(tid, strlen(s[0]) + 1); + tid1 = H5Tarray_create(tid, 1, dims2); HDsprintf(name, "%05d array str", idx); nattrs += add_attr(oid, name, tid1, sid, s); H5Tclose(tid1); @@ -569,40 +610,43 @@ int add_attrs(hid_t oid, int idx) H5Sclose(sid); /* 9 fixed length 2D int arrays */ - sid = H5Screate_simple (1, dims2, NULL); - tid = H5Tarray_create (H5T_NATIVE_INT, 2, dims3); + sid = H5Screate_simple(1, dims2, NULL); + tid = H5Tarray_create(H5T_NATIVE_INT, 2, dims3); HDsprintf(name, "%05d array int 2D", idx); nattrs += add_attr(oid, name, tid, sid, int3d[0][0]); H5Tclose(tid); H5Sclose(sid); /* 10 variable length arrays */ - sid = H5Screate_simple (1, dims2, NULL); - tid = H5Tcopy (H5T_C_S1); - H5Tset_size (tid, H5T_VARIABLE); + sid = H5Screate_simple(1, dims2, NULL); + tid = H5Tcopy(H5T_C_S1); + H5Tset_size(tid, H5T_VARIABLE); HDsprintf(name, "%05d vlen strings", idx); nattrs += add_attr(oid, name, tid, sid, s_vlen); H5Tclose(tid); - tid = H5Tvlen_create (H5T_NATIVE_INT);; + tid = H5Tvlen_create(H5T_NATIVE_INT); + ; HDsprintf(name, "%05d vlen int array", idx); nattrs += add_attr(oid, name, tid, sid, i_vlen); H5Tclose(tid); H5Sclose(sid); /* 12 compound data */ - sid = H5Screate_simple (1, dims2, NULL); - tid = H5Tcreate (H5T_COMPOUND, sizeof (zipcode_t)); - tid1 = H5Tcopy (H5T_C_S1); - H5Tset_size (tid1, H5T_VARIABLE); - H5Tinsert (tid, "zip code", 0, H5T_NATIVE_INT); offset += sizeof(H5T_NATIVE_INT); - H5Tinsert (tid, "City", offset, tid1); offset += sizeof(char *); + sid = H5Screate_simple(1, dims2, NULL); + tid = H5Tcreate(H5T_COMPOUND, sizeof(zipcode_t)); + tid1 = H5Tcopy(H5T_C_S1); + H5Tset_size(tid1, H5T_VARIABLE); + H5Tinsert(tid, "zip code", 0, H5T_NATIVE_INT); + offset += sizeof(H5T_NATIVE_INT); + H5Tinsert(tid, "City", offset, tid1); + offset += sizeof(char *); HDsprintf(name, "%05d compound data", idx); nattrs += add_attr(oid, name, tid, sid, cmp_data); H5Tclose(tid1); H5Tclose(tid); H5Sclose(sid); - for (i0=0; i0<4; i0++) + for (i0 = 0; i0 < 4; i0++) free(i_vlen[i0].p); return nattrs; diff --git a/tools/test/misc/h5repart_gentest.c b/tools/test/misc/h5repart_gentest.c index 5c1ff87..b068985 100644 --- a/tools/test/misc/h5repart_gentest.c +++ b/tools/test/misc/h5repart_gentest.c @@ -6,13 +6,13 @@ * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Raymond Lu<slu@ncsa.uiuc.edu> + * Programmer: Raymond Lu * June 1, 2005 * * Purpose: Generate a family file of 1024 bytes for each member @@ -21,79 +21,94 @@ #include "hdf5.h" #include "H5private.h" -#define FAMILY_NUMBER 4 -#define FAMILY_SIZE 1024 -#define FILENAME "family_file%05d.h5" +#define FAMILY_NUMBER 4 +#define FAMILY_SIZE 1024 +#define FILENAME "family_file%05d.h5" -static int buf[FAMILY_NUMBER][FAMILY_SIZE]; +int **buf = NULL; +int * buf_data = NULL; -int main(void) +int +main(void) { - hid_t file=(-1), fapl, space=(-1), dset=(-1); - char dname[]="dataset"; - int i, j; - hsize_t dims[2]={FAMILY_NUMBER, FAMILY_SIZE}; + hid_t file = (-1), fapl, space = (-1), dset = (-1); + char dname[] = "dataset"; + int i, j; + hsize_t dims[2] = {FAMILY_NUMBER, FAMILY_SIZE}; + + /* Set up data array */ + if (NULL == (buf_data = (int *)HDcalloc(FAMILY_NUMBER * FAMILY_SIZE, sizeof(int)))) { + HDperror("HDcalloc"); + HDexit(EXIT_FAILURE); + } + if (NULL == (buf = (int **)HDcalloc(FAMILY_NUMBER, sizeof(buf_data)))) { + HDperror("HDcalloc"); + HDexit(EXIT_FAILURE); + } + for (i = 0; i < FAMILY_NUMBER; i++) + buf[i] = buf_data + (i * FAMILY_SIZE); /* Set property list and file name for FAMILY driver */ - if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) { - perror ("H5Pcreate"); - exit (EXIT_FAILURE); + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + HDperror("H5Pcreate"); + HDexit(EXIT_FAILURE); } - if(H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) { - perror ("H5Pset_fapl_family"); - exit (EXIT_FAILURE); + if (H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) { + HDperror("H5Pset_fapl_family"); + HDexit(EXIT_FAILURE); } - if((file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { - perror("H5Fcreate"); - exit(EXIT_FAILURE); + if ((file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { + HDperror("H5Fcreate"); + HDexit(EXIT_FAILURE); } /* Create and write dataset */ - if((space = H5Screate_simple(2, dims, NULL)) < 0) { - perror("H5Screate_simple"); - exit(EXIT_FAILURE); + if ((space = H5Screate_simple(2, dims, NULL)) < 0) { + HDperror("H5Screate_simple"); + HDexit(EXIT_FAILURE); } - - if((dset = H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - perror("H5Dcreate2"); - exit(EXIT_FAILURE); + if ((dset = H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + HDperror("H5Dcreate2"); + HDexit(EXIT_FAILURE); } - - for(i = 0; i<FAMILY_NUMBER; i++) - for(j = 0; j<FAMILY_SIZE; j++) + for (i = 0; i < FAMILY_NUMBER; i++) + for (j = 0; j < FAMILY_SIZE; j++) buf[i][j] = i * 10000 + j; - if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) { - perror("H5Dwrite"); - exit(EXIT_FAILURE); + if (H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) { + HDperror("H5Dwrite"); + HDexit(EXIT_FAILURE); } - - if(H5Sclose(space) < 0) { - perror ("H5Sclose"); - exit (EXIT_FAILURE); + if (H5Sclose(space) < 0) { + HDperror("H5Sclose"); + HDexit(EXIT_FAILURE); } - if(H5Dclose(dset) < 0) { - perror ("H5Dclose"); - exit (EXIT_FAILURE); + if (H5Dclose(dset) < 0) { + HDperror("H5Dclose"); + HDexit(EXIT_FAILURE); } - if(H5Pclose(fapl) < 0) { - perror ("H5Pclose"); - exit (EXIT_FAILURE); + if (H5Pclose(fapl) < 0) { + HDperror("H5Pclose"); + HDexit(EXIT_FAILURE); } - if(H5Fclose(file) < 0) { - perror ("H5Fclose"); - exit (EXIT_FAILURE); + if (H5Fclose(file) < 0) { + HDperror("H5Fclose"); + HDexit(EXIT_FAILURE); } - puts(" PASSED"); fflush(stdout); + HDfree(buf); + HDfree(buf_data); + + HDputs(" PASSED"); + HDfflush(stdout); - return 0; + return EXIT_SUCCESS; } diff --git a/tools/test/misc/repart_test.c b/tools/test/misc/repart_test.c index b8e0292..7aa5ad9 100644 --- a/tools/test/misc/repart_test.c +++ b/tools/test/misc/repart_test.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -19,22 +19,16 @@ #include "hdf5.h" #include "H5private.h" -#define KB 1024 -#define FAMILY_H5REPART_SIZE1 20000 -#define FAMILY_H5REPART_SIZE2 (5*KB) +#define KB 1024 +#define FAMILY_H5REPART_SIZE1 20000 +#define FAMILY_H5REPART_SIZE2 (5 * KB) -const char *FILENAME[] = { - "fst_family%05d.h5", - "scd_family%05d.h5", - "family_to_single.h5", - "family_to_sec2.h5", - NULL -}; +const char *FILENAME[] = {"fst_family%05d.h5", "scd_family%05d.h5", "family_to_single.h5", + "family_to_sec2.h5", NULL}; herr_t test_family_h5repart_opens(void); herr_t test_single_h5repart_opens(void); - /*------------------------------------------------------------------------- * Function: test_family_h5repart_opens * @@ -47,8 +41,8 @@ herr_t test_single_h5repart_opens(void); herr_t test_family_h5repart_opens(void) { - hid_t fid = -1; - hid_t fapl_id = -1; + hid_t fid = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; /* open 1st file(single member file) with correct family size(20000 byte) */ if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) @@ -57,7 +51,7 @@ test_family_h5repart_opens(void) if (H5Pset_fapl_family(fapl_id, (hsize_t)FAMILY_H5REPART_SIZE1, H5P_DEFAULT) < 0) goto error; - if ((fid = H5Fopen(FILENAME[0], H5F_ACC_RDWR, fapl_id))<0) + if ((fid = H5Fopen(FILENAME[0], H5F_ACC_RDWR, fapl_id)) < 0) goto error; if (H5Fclose(fid) < 0) @@ -79,17 +73,17 @@ test_family_h5repart_opens(void) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_id); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_family_h5repart_opens() */ - - /*------------------------------------------------------------------------- * Function: test_single_h5repart_opens * @@ -102,7 +96,7 @@ error: herr_t test_single_h5repart_opens(void) { - hid_t fid = -1; + hid_t fid = H5I_INVALID_HID; /* open the single file */ if ((fid = H5Fopen(FILENAME[2], H5F_ACC_RDWR, H5P_DEFAULT)) < 0) @@ -119,15 +113,16 @@ test_single_h5repart_opens(void) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_single_h5repart_opens() */ - /*------------------------------------------------------------------------- * Function: main * @@ -140,10 +135,10 @@ error: int main(void) { - int nerrors = 0; + int nerrors = 0; - nerrors += test_family_h5repart_opens() < 0 ? 1 : 0; - nerrors += test_single_h5repart_opens() < 0 ? 1 : 0; + nerrors += test_family_h5repart_opens() < 0 ? 1 : 0; + nerrors += test_single_h5repart_opens() < 0 ? 1 : 0; if (nerrors) goto error; @@ -152,8 +147,6 @@ main(void) error: nerrors = MAX(1, nerrors); - HDprintf("***** %d FAMILY FILE TEST%s FAILED! *****\n", - nerrors, 1 == nerrors ? "" : "S"); + HDprintf("***** %d FAMILY FILE TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); HDexit(EXIT_FAILURE); } /* end main() */ - diff --git a/tools/test/misc/talign.c b/tools/test/misc/talign.c index 7f1f038..f214527 100644 --- a/tools/test/misc/talign.c +++ b/tools/test/misc/talign.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,7 +20,7 @@ #include "H5private.h" #include "h5tools.h" -const char *fname = "talign.h5"; +const char *fname = "talign.h5"; const char *setname = "align"; /* @@ -30,26 +30,27 @@ const char *setname = "align"; * another per construction) */ -int main(void) +int +main(void) { - hid_t fil=-1, spc=-1, set=-1; - hid_t cs6=-1, cmp=-1, fix=-1; - hid_t cmp1=-1, cmp2=-1, cmp3=-1; - hid_t plist=-1; - hid_t array_dt=-1; + hid_t fil = H5I_INVALID_HID, spc = H5I_INVALID_HID, set = H5I_INVALID_HID; + hid_t cs6 = H5I_INVALID_HID, cmp = H5I_INVALID_HID, fix = H5I_INVALID_HID; + hid_t cmp1 = H5I_INVALID_HID, cmp2 = H5I_INVALID_HID, cmp3 = H5I_INVALID_HID; + hid_t plist = H5I_INVALID_HID; + hid_t array_dt = H5I_INVALID_HID; hsize_t dim[2]; hsize_t cdim[4]; - char string5[5]; - float fok[2] = {1234.0f, 2341.0f}; - float fnok[2] = {5678.0f, 6785.0f}; - float *fptr = NULL; + char string5[5]; + float fok[2] = {1234.0f, 2341.0f}; + float fnok[2] = {5678.0f, 6785.0f}; + float *fptr = NULL; char *data = NULL; - int result = 0; - herr_t error = 1; + int result = 0; + herr_t error = 1; HDprintf("%-70s", "Testing alignment in compound datatypes"); @@ -62,9 +63,11 @@ int main(void) return 1; } - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Ldelete(fil, setname, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; cs6 = H5Tcopy(H5T_C_S1); H5Tset_size(cs6, sizeof(string5)); @@ -73,20 +76,20 @@ int main(void) cmp = H5Tcreate(H5T_COMPOUND, sizeof(fok) + sizeof(string5) + sizeof(fnok)); H5Tinsert(cmp, "Awkward length", 0, cs6); - cdim[0] = sizeof(fok) / sizeof(float); + cdim[0] = sizeof(fok) / sizeof(float); array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim); H5Tinsert(cmp, "Ok", sizeof(string5), array_dt); H5Tclose(array_dt); - cdim[0] = sizeof(fnok) / sizeof(float); + cdim[0] = sizeof(fnok) / sizeof(float); array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim); H5Tinsert(cmp, "Not Ok", sizeof(fok) + sizeof(string5), array_dt); H5Tclose(array_dt); - fix = H5Tget_native_type(cmp, H5T_DIR_DEFAULT); + fix = H5Tget_native_type(cmp, H5T_DIR_DEFAULT); cmp1 = H5Tcreate(H5T_COMPOUND, sizeof(fok)); - cdim[0] = sizeof(fok) / sizeof(float); + cdim[0] = sizeof(fok) / sizeof(float); array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim); H5Tinsert(cmp1, "Ok", 0, array_dt); H5Tclose(array_dt); @@ -96,13 +99,13 @@ int main(void) cmp3 = H5Tcreate(H5T_COMPOUND, sizeof(fnok)); - cdim[0] = sizeof(fnok) / sizeof(float); + cdim[0] = sizeof(fnok) / sizeof(float); array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim); H5Tinsert(cmp3, "Not Ok", 0, array_dt); H5Tclose(array_dt); plist = H5Pcreate(H5P_DATASET_XFER); - if((error = H5Pset_preserve(plist, 1)) < 0) + if ((error = H5Pset_preserve(plist, 1)) < 0) goto out; /* @@ -110,8 +113,8 @@ int main(void) * in turn so that we are avoid alignment issues at this point */ dim[0] = 1; - spc = H5Screate_simple(1, dim, NULL); - set = H5Dcreate2(fil, setname, cmp, spc, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + spc = H5Screate_simple(1, dim, NULL); + set = H5Dcreate2(fil, setname, cmp, spc, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(set, cmp1, spc, H5S_ALL, plist, fok); H5Dwrite(set, cmp2, spc, H5S_ALL, plist, string5); @@ -122,7 +125,7 @@ int main(void) /* Now open the set, and read it back in */ data = (char *)HDmalloc(H5Tget_size(fix)); - if(!data) { + if (!data) { HDperror("malloc() failed"); HDabort(); } @@ -134,61 +137,56 @@ int main(void) H5Dclose(set); out: - if(error < 0) { + if (error < 0) { result = 1; HDputs("*FAILED - HDF5 library error*"); - } else if(!(H5_FLT_ABS_EQUAL(fok[0], fptr[0])) - || !(H5_FLT_ABS_EQUAL(fok[1], fptr[1])) - || !(H5_FLT_ABS_EQUAL(fnok[0], fptr[2])) - || !(H5_FLT_ABS_EQUAL(fnok[1], fptr[3]))) { + } + else if (!(H5_FLT_ABS_EQUAL(fok[0], fptr[0])) || !(H5_FLT_ABS_EQUAL(fok[1], fptr[1])) || + !(H5_FLT_ABS_EQUAL(fnok[0], fptr[2])) || !(H5_FLT_ABS_EQUAL(fnok[1], fptr[3]))) { char *mname; result = 1; - mname = H5Tget_member_name(fix, 0); - HDprintf("%14s (%2d) %6s = %s\n", - mname ? mname : "(null)", (int)H5Tget_member_offset(fix,0), - string5, (char *)(data + H5Tget_member_offset(fix, 0))); - if(mname) + mname = H5Tget_member_name(fix, 0); + HDprintf("%14s (%2d) %6s = %s\n", mname ? mname : "(null)", (int)H5Tget_member_offset(fix, 0), + string5, (char *)(data + H5Tget_member_offset(fix, 0))); + if (mname) H5free_memory(mname); - fptr = (float *)((void *)(data + H5Tget_member_offset(fix, 1))); + fptr = (float *)((void *)(data + H5Tget_member_offset(fix, 1))); mname = H5Tget_member_name(fix, 1); HDprintf("Data comparison:\n" - "%14s (%2d) %6f = %f\n" - " %6f = %f\n", - mname ? mname : "(null)", (int)H5Tget_member_offset(fix,1), - (double)fok[0], (double)fptr[0], - (double)fok[1], (double)fptr[1]); - if(mname) + "%14s (%2d) %6f = %f\n" + " %6f = %f\n", + mname ? mname : "(null)", (int)H5Tget_member_offset(fix, 1), (double)fok[0], (double)fptr[0], + (double)fok[1], (double)fptr[1]); + if (mname) H5free_memory(mname); - fptr = (float *)((void *)(data + H5Tget_member_offset(fix, 2))); + fptr = (float *)((void *)(data + H5Tget_member_offset(fix, 2))); mname = H5Tget_member_name(fix, 2); HDprintf("%14s (%2d) %6f = %f\n" - " %6f = %6f\n", - mname ? mname : "(null)", (int)H5Tget_member_offset(fix,2), - (double)fnok[0], (double)fptr[0], - (double)fnok[1], (double)fptr[1]); - if(mname) + " %6f = %6f\n", + mname ? mname : "(null)", (int)H5Tget_member_offset(fix, 2), (double)fnok[0], + (double)fptr[0], (double)fnok[1], (double)fptr[1]); + if (mname) H5free_memory(mname); fptr = (float *)((void *)(data + H5Tget_member_offset(fix, 1))); HDprintf("\n" - "Short circuit\n" - " %6f = %f\n" - " %6f = %f\n" - " %6f = %f\n" - " %6f = %f\n", - (double)fok[0], (double)fptr[0], - (double)fok[1], (double)fptr[1], - (double)fnok[0], (double)fptr[2], - (double)fnok[1], (double)fptr[3]); + "Short circuit\n" + " %6f = %f\n" + " %6f = %f\n" + " %6f = %f\n" + " %6f = %f\n", + (double)fok[0], (double)fptr[0], (double)fok[1], (double)fptr[1], (double)fnok[0], + (double)fptr[2], (double)fnok[1], (double)fptr[3]); HDputs("*FAILED - compound type alignmnent problem*"); - } else { + } + else { HDputs(" PASSED"); } - if(data) + if (data) HDfree(data); H5Sclose(spc); H5Tclose(cs6); @@ -203,4 +201,3 @@ out: HDfflush(stdout); return result; } - diff --git a/tools/test/misc/testfiles/h5clear_missing_file.ddl b/tools/test/misc/testfiles/h5clear_missing_file.ddl index 32dd549..c4d21c9 100644 --- a/tools/test/misc/testfiles/h5clear_missing_file.ddl +++ b/tools/test/misc/testfiles/h5clear_missing_file.ddl @@ -5,8 +5,14 @@ usage: h5clear [OPTIONS] file_name -s, --status Clear the status_flags field in the file's superblock -m, --image Remove the metadata cache image from the file --filesize Print the file's EOA and EOF - --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for the file <file_name> - C is >= 0; C is optional and will default to 1M when not set + --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for + the file <file_name>. + C is >= 0; C is optional and will default to 1M when not set. + This option helps to repair a crashed file where the stored EOA + in the superblock is different from the actual EOF. + The file’s EOA and EOF will be the same after applying + this option to the file. + Examples of use: h5clear -s file_name diff --git a/tools/test/misc/testfiles/h5clear_usage.ddl b/tools/test/misc/testfiles/h5clear_usage.ddl index 32dd549..c4d21c9 100644 --- a/tools/test/misc/testfiles/h5clear_usage.ddl +++ b/tools/test/misc/testfiles/h5clear_usage.ddl @@ -5,8 +5,14 @@ usage: h5clear [OPTIONS] file_name -s, --status Clear the status_flags field in the file's superblock -m, --image Remove the metadata cache image from the file --filesize Print the file's EOA and EOF - --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for the file <file_name> - C is >= 0; C is optional and will default to 1M when not set + --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for + the file <file_name>. + C is >= 0; C is optional and will default to 1M when not set. + This option helps to repair a crashed file where the stored EOA + in the superblock is different from the actual EOF. + The file’s EOA and EOF will be the same after applying + this option to the file. + Examples of use: h5clear -s file_name diff --git a/tools/test/misc/testfiles/h5mkgrp_help.txt b/tools/test/misc/testfiles/h5mkgrp_help.txt index ba130f6..5d81b34 100644 --- a/tools/test/misc/testfiles/h5mkgrp_help.txt +++ b/tools/test/misc/testfiles/h5mkgrp_help.txt @@ -5,3 +5,16 @@ usage: h5mkgrp [OPTIONS] FILE GROUP... -p, --parents No error if existing, make parent groups as needed -v, --verbose Print information about OBJECTS and OPTIONS -V, --version Print version number and exit + --vol-value Value (ID) of the VOL connector to use for opening the + HDF5 file specified + --vol-name Name of the VOL connector to use for opening the + HDF5 file specified + --vol-info VOL-specific info to pass to the VOL connector used for + opening the HDF5 file specified + --vfd-value Value (ID) of the VFL driver to use for opening the + HDF5 file specified + --vfd-name Name of the VFL driver to use for opening the + HDF5 file specified + --vfd-info VFD-specific info to pass to the VFL driver used for + opening the HDF5 file specified + diff --git a/tools/test/misc/testfiles/h5mkgrp_version.txt.in b/tools/test/misc/testfiles/h5mkgrp_version.txt.in index 75c13a5..37dbabd 100644 --- a/tools/test/misc/testfiles/h5mkgrp_version.txt.in +++ b/tools/test/misc/testfiles/h5mkgrp_version.txt.in @@ -1 +1 @@ -h5mkgrp: Version @HDF5_PACKAGE_VERSION_STRING@ +h5mkgrp: Version @HDF5_RELEASE_VERSION_STRING@ diff --git a/tools/test/misc/testh5clear.sh.in b/tools/test/misc/testh5clear.sh.in index 3f2b32f..a01fa4a 100644 --- a/tools/test/misc/testh5clear.sh.in +++ b/tools/test/misc/testh5clear.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. # @@ -315,7 +315,7 @@ TOOLTEST_ERR orig_h5clear_sec2_v0.h5 -s -m "" h5clear_no_mdc_image.err # # The following are tests to verify the expected exit code from h5clear: # "h5clear -m h5clear_mdc_image.h5" (valid option, existing file, succeed exit code) -# "h5clear --vers" (valid option, version #, succeed exit code) +# "h5clear --version" (valid option, version #, succeed exit code) # "h5clear -k" (invalid 1 option, no file, fail exit code) # "h5clear -k junk.h5" (invalid 1 option, nonexisting file, fail exit code) # "h5clear -l h5clear_sec2_v2.h5" (invalid 1 option, existing file, fail exit code) @@ -326,7 +326,7 @@ TOOLTEST_ERR orig_h5clear_sec2_v0.h5 -s -m "" h5clear_no_mdc_image.err # "h5clear -m -l h5clear_sec2_v0.h5" (valid/invalid 2 options, existing file, fail exit code) # "h5clear -l -m h5clear_sec2_v0.h5" (invalid/valid 2 options, existing file, fail exit code) TOOLTEST h5clear_mdc_image.h5 -m "" $SUCCEED -TOOLTEST "" --vers "" $SUCCEED +TOOLTEST "" --version "" $SUCCEED TOOLTEST "" -k "" $FAIL TOOLTEST junk.h5 -k "" $FAIL TOOLTEST h5clear_sec2_v2.h5 -l "" $FAIL diff --git a/tools/test/misc/testh5mkgrp.sh.in b/tools/test/misc/testh5mkgrp.sh.in index 3ad1f71..5cd852a 100644 --- a/tools/test/misc/testh5mkgrp.sh.in +++ b/tools/test/misc/testh5mkgrp.sh.in @@ -7,13 +7,13 @@ # 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. # # Tests for the h5mkgrp tool # -# Quincey Koziol (koziol@hdfgroup.org) +# Quincey Koziol # Tuesday, February 13, 2007 # @@ -150,10 +150,11 @@ TOOLTEST() { TESTING $H5MKGRP $@ ( - cd $TESTDIR - $RUNSERIAL $H5MKGRP_BIN $@ + cd $TESTDIR + $RUNSERIAL $H5MKGRP_BIN $@ ) > output.out RET=$? + if [ $RET != 0 ]; then echo "*FAILED*" echo "failed result is:" @@ -164,7 +165,7 @@ TOOLTEST() # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f output.out + rm -f output.out fi fi } @@ -181,8 +182,8 @@ H5LSTEST() # any unexpected output from that stream too. VERIFY_H5LS $@ ( - cd $TESTDIR - $RUNSERIAL $H5LS_BIN $H5LS_ARGS $@ + cd $TESTDIR + $RUNSERIAL $H5LS_BIN $H5LS_ARGS $@ ) 2>&1 |sed 's/Modified:.*/Modified: XXXX-XX-XX XX:XX:XX XXX/' >$actual # save actual in case it is needed later. @@ -190,25 +191,25 @@ H5LSTEST() STDOUT_FILTER $actual STDERR_FILTER $actual - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.ls) missing" - nerrors="`expr $nerrors + 1`" - elif $CMP $expect $actual; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.ls) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_sav - fi + if [ ! -f $expect ]; then + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + echo " Expected result (*.ls) missing" + nerrors="`expr $nerrors + 1`" + elif $CMP $expect $actual; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result (*.ls) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + fi + + # Clean up output file + if test -z "$HDF5_NOCLEANUP"; then + rm -f $actual $actual_sav + fi } # Single run of tool @@ -258,30 +259,30 @@ CMPTEST() # any unexpected output from that stream too. TESTING $H5MKGRP $@ ( - cd $TESTDIR - $RUNSERIAL $H5MKGRP_BIN $@ + cd $TESTDIR + $RUNSERIAL $H5MKGRP_BIN $@ ) >$actual 2>$actual_err cat $actual_err >> $actual - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.txt) missing" - nerrors="`expr $nerrors + 1`" - elif $CMP $expect $actual; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.txt) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err - fi + if [ ! -f $expect ]; then + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + echo " Expected result (*.txt) missing" + nerrors="`expr $nerrors + 1`" + elif $CMP $expect $actual; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result (*.txt) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + fi + + # Clean up output file + if test -z "$HDF5_NOCLEANUP"; then + rm -f $actual $actual_err + fi } ############################################################################## diff --git a/tools/test/misc/testh5repart.sh.in b/tools/test/misc/testh5repart.sh.in index 143f607..be07f0d 100644 --- a/tools/test/misc/testh5repart.sh.in +++ b/tools/test/misc/testh5repart.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. # diff --git a/tools/test/misc/vds/CMakeLists.txt b/tools/test/misc/vds/CMakeLists.txt index 092cabc..e8eb960 100644 --- a/tools/test/misc/vds/CMakeLists.txt +++ b/tools/test/misc/vds/CMakeLists.txt @@ -1,9 +1,9 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_TOOLS_TEST_MISC_VDS C) -MACRO (ADD_H5_GENERATOR genfile) +macro (ADD_H5_GENERATOR genfile) add_executable (${genfile} ${HDF5_TOOLS_TEST_MISC_VDS_SOURCE_DIR}/${genfile}.c) - target_include_directories (${genfile} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (${genfile} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (${genfile} STATIC) target_link_libraries (${genfile} PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) @@ -12,7 +12,14 @@ MACRO (ADD_H5_GENERATOR genfile) target_link_libraries (${genfile} PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) endif () set_target_properties (${genfile} PROPERTIES FOLDER generator/tools) -ENDMACRO () + + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_MISC_VDS_${genfile}_FORMAT ${genfile}) + endif () +endmacro () # generator executables set (H5_GENERATORS diff --git a/tools/test/misc/vds/Makefile.am b/tools/test/misc/vds/Makefile.am index 73c335f..90923fa 100644 --- a/tools/test/misc/vds/Makefile.am +++ b/tools/test/misc/vds/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. ## diff --git a/tools/test/misc/vds/UC_1.h b/tools/test/misc/vds/UC_1.h index 9d1f758..f38ed54 100644 --- a/tools/test/misc/vds/UC_1.h +++ b/tools/test/misc/vds/UC_1.h @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -49,7 +49,7 @@ | | +-------M-------+ - + dim[0] / @@ -63,57 +63,40 @@ */ - -#define UC_1_N_SOURCES 6 +#define UC_1_N_SOURCES 6 /* Dataset dimensions */ -#define UC_1_SM_HEIGHT 2 /* K */ -#define UC_1_LG_HEIGHT 4 /* N */ -#define UC_1_SM_LG_HEIGHT 6 /* SM_HEIGHT + LG_HEIGHT */ -#define UC_1_FULL_HEIGHT 18 /* (3 * K) + (3 * N) */ -#define UC_1_HALF_HEIGHT 9 -#define UC_1_WIDTH 8 /* M */ -#define UC_1_HALF_WIDTH 4 +#define UC_1_SM_HEIGHT 2 /* K */ +#define UC_1_LG_HEIGHT 4 /* N */ +#define UC_1_SM_LG_HEIGHT 6 /* SM_HEIGHT + LG_HEIGHT */ +#define UC_1_FULL_HEIGHT 18 /* (3 * K) + (3 * N) */ +#define UC_1_HALF_HEIGHT 9 +#define UC_1_WIDTH 8 /* M */ +#define UC_1_HALF_WIDTH 4 -#define UC_1_N_MAX_PLANES H5S_UNLIMITED /* max number of planes */ -#define UC_1_N_TEST_PLANES 5 /* number of planes we write */ +#define UC_1_N_MAX_PLANES H5S_UNLIMITED /* max number of planes */ +#define UC_1_N_TEST_PLANES 5 /* number of planes we write */ /* Dataset datatypes */ -#define UC_1_SOURCE_DATATYPE H5T_STD_I32LE -#define UC_1_VDS_DATATYPE H5T_STD_I32LE +#define UC_1_SOURCE_DATATYPE H5T_STD_I32LE +#define UC_1_VDS_DATATYPE H5T_STD_I32LE /* Starting size of datasets, both source and VDS */ static hsize_t UC_1_DIMS[UC_1_N_SOURCES][RANK] = { - {0, UC_1_SM_HEIGHT, UC_1_WIDTH}, - {0, UC_1_LG_HEIGHT, UC_1_WIDTH}, - {0, UC_1_SM_HEIGHT, UC_1_WIDTH}, - {0, UC_1_LG_HEIGHT, UC_1_WIDTH}, - {0, UC_1_SM_HEIGHT, UC_1_WIDTH}, - {0, UC_1_LG_HEIGHT, UC_1_WIDTH} -}; + {0, UC_1_SM_HEIGHT, UC_1_WIDTH}, {0, UC_1_LG_HEIGHT, UC_1_WIDTH}, {0, UC_1_SM_HEIGHT, UC_1_WIDTH}, + {0, UC_1_LG_HEIGHT, UC_1_WIDTH}, {0, UC_1_SM_HEIGHT, UC_1_WIDTH}, {0, UC_1_LG_HEIGHT, UC_1_WIDTH}}; /* Maximum size of datasets, both source and VDS */ static hsize_t UC_1_MAX_DIMS[UC_1_N_SOURCES][RANK] = { - {UC_1_N_MAX_PLANES, UC_1_SM_HEIGHT, UC_1_WIDTH}, - {UC_1_N_MAX_PLANES, UC_1_LG_HEIGHT, UC_1_WIDTH}, - {UC_1_N_MAX_PLANES, UC_1_SM_HEIGHT, UC_1_WIDTH}, - {UC_1_N_MAX_PLANES, UC_1_LG_HEIGHT, UC_1_WIDTH}, - {UC_1_N_MAX_PLANES, UC_1_SM_HEIGHT, UC_1_WIDTH}, - {UC_1_N_MAX_PLANES, UC_1_LG_HEIGHT, UC_1_WIDTH} -}; + {UC_1_N_MAX_PLANES, UC_1_SM_HEIGHT, UC_1_WIDTH}, {UC_1_N_MAX_PLANES, UC_1_LG_HEIGHT, UC_1_WIDTH}, + {UC_1_N_MAX_PLANES, UC_1_SM_HEIGHT, UC_1_WIDTH}, {UC_1_N_MAX_PLANES, UC_1_LG_HEIGHT, UC_1_WIDTH}, + {UC_1_N_MAX_PLANES, UC_1_SM_HEIGHT, UC_1_WIDTH}, {UC_1_N_MAX_PLANES, UC_1_LG_HEIGHT, UC_1_WIDTH}}; /* File names for source datasets */ -static char UC_1_FILE_NAMES[UC_1_N_SOURCES][NAME_LEN] = { - {"1_a.h5"}, - {"1_b.h5"}, - {"1_c.h5"}, - {"1_d.h5"}, - {"1_e.h5"}, - {"1_f.h5"} -}; +static char UC_1_FILE_NAMES[UC_1_N_SOURCES][NAME_LEN] = {{"1_a.h5"}, {"1_b.h5"}, {"1_c.h5"}, + {"1_d.h5"}, {"1_e.h5"}, {"1_f.h5"}}; /* Dataset names */ static char UC_1_SOURCE_DSET_PATH[NAME_LEN] = "/source_dset"; #endif /* UC_1_H */ - diff --git a/tools/test/misc/vds/UC_1_one_dim_gen.c b/tools/test/misc/vds/UC_1_one_dim_gen.c index b997280..a816fb8 100644 --- a/tools/test/misc/vds/UC_1_one_dim_gen.c +++ b/tools/test/misc/vds/UC_1_one_dim_gen.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,18 +25,13 @@ #include "UC_common.h" #include "UC_1.h" -static hsize_t UC_1_VDS_DIMS[RANK] = {0, UC_1_FULL_HEIGHT, UC_1_WIDTH}; +static hsize_t UC_1_VDS_DIMS[RANK] = {0, UC_1_FULL_HEIGHT, UC_1_WIDTH}; static hsize_t UC_1_VDS_MAX_DIMS[RANK] = {UC_1_N_MAX_PLANES, UC_1_FULL_HEIGHT, UC_1_WIDTH}; /* Planes */ static hsize_t UC_1_PLANES[UC_1_N_SOURCES][RANK] = { - {1, UC_1_SM_HEIGHT, UC_1_WIDTH}, - {1, UC_1_LG_HEIGHT, UC_1_WIDTH}, - {1, UC_1_SM_HEIGHT, UC_1_WIDTH}, - {1, UC_1_LG_HEIGHT, UC_1_WIDTH}, - {1, UC_1_SM_HEIGHT, UC_1_WIDTH}, - {1, UC_1_LG_HEIGHT, UC_1_WIDTH} -}; + {1, UC_1_SM_HEIGHT, UC_1_WIDTH}, {1, UC_1_LG_HEIGHT, UC_1_WIDTH}, {1, UC_1_SM_HEIGHT, UC_1_WIDTH}, + {1, UC_1_LG_HEIGHT, UC_1_WIDTH}, {1, UC_1_SM_HEIGHT, UC_1_WIDTH}, {1, UC_1_LG_HEIGHT, UC_1_WIDTH}}; /* VDS file name */ static char UC_1_VDS_FILE_NAME[NAME_LEN] = "1_vds.h5"; @@ -44,45 +39,37 @@ static char UC_1_VDS_FILE_NAME[NAME_LEN] = "1_vds.h5"; /* Dataset names */ static char UC_1_SOURCE_DSET_NAME[NAME_LEN] = "source_dset"; static char UC_1_VDS_DSET_NAME[NAME_LEN] = "vds_dset"; - + /* Fill values */ -static int UC_1_FILL_VALUES[UC_1_N_SOURCES] = { - -1, - -2, - -3, - -4, - -5, - -6 -}; -static int UC_1_VDS_FILL_VALUE = -9; +static int UC_1_FILL_VALUES[UC_1_N_SOURCES] = {-1, -2, -3, -4, -5, -6}; +static int UC_1_VDS_FILL_VALUE = -9; int main(void) { - hid_t src_sid = -1; /* source dataset's dataspace ID */ - hid_t src_dcplid = -1; /* source dataset property list ID */ - - hid_t vds_sid = -1; /* VDS dataspace ID */ - hid_t vds_dcplid = -1; /* VDS dataset property list ID */ + hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */ + hid_t src_dcplid = H5I_INVALID_HID; /* source dataset property list ID */ - hid_t fid = -1; /* HDF5 file ID */ - hid_t did = -1; /* dataset ID */ - hid_t msid = -1; /* memory dataspace ID */ - hid_t fsid = -1; /* file dataspace ID */ + hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */ + hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */ - hsize_t extent[RANK]; /* dataset extents */ - hsize_t start[RANK]; /* starting point for hyperslab */ - hsize_t map_start = 0; /* starting point in the VDS map */ + hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ + hid_t did = H5I_INVALID_HID; /* dataset ID */ + hid_t msid = H5I_INVALID_HID; /* memory dataspace ID */ + hid_t fsid = H5I_INVALID_HID; /* file dataspace ID */ - int *buffer = NULL; /* data buffer */ - hsize_t count = 0; /* number of elements in a plane */ - int n_planes = -1; /* number of planes to write */ - int value = -1; /* value written to datasets */ + hsize_t extent[RANK]; /* dataset extents */ + hsize_t start[RANK]; /* starting point for hyperslab */ + hsize_t map_start = 0; /* starting point in the VDS map */ - int i; /* iterator */ - int j; /* iterator */ - hsize_t k; /* iterator */ + int * buffer = NULL; /* data buffer */ + hsize_t count = 0; /* number of elements in a plane */ + int n_planes = -1; /* number of planes to write */ + int value = -1; /* value written to datasets */ + int i; /* iterator */ + int j; /* iterator */ + hsize_t k; /* iterator */ /* Start by creating the virtual dataset (VDS) dataspace and creation * property list. The individual source datasets are then created @@ -90,86 +77,80 @@ main(void) */ /* Create VDS dcpl */ - if((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_fill_value(vds_dcplid, UC_1_VDS_DATATYPE, - &UC_1_VDS_FILL_VALUE) < 0) + if (H5Pset_fill_value(vds_dcplid, UC_1_VDS_DATATYPE, &UC_1_VDS_FILL_VALUE) < 0) UC_ERROR /* Create VDS dataspace */ - if((vds_sid = H5Screate_simple(RANK, UC_1_VDS_DIMS, - UC_1_VDS_MAX_DIMS)) < 0) + if ((vds_sid = H5Screate_simple(RANK, UC_1_VDS_DIMS, UC_1_VDS_MAX_DIMS)) < 0) UC_ERROR /************************************ * Create source files and datasets * ************************************/ - start[0] = 0; - start[1] = 0; - start[2] = 0; + start[0] = 0; + start[1] = 0; + start[2] = 0; map_start = 0; - for(i = 0; i < UC_1_N_SOURCES; i++) { + for (i = 0; i < UC_1_N_SOURCES; i++) { /* Create source dataset dcpl */ - if((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_chunk(src_dcplid, RANK, UC_1_PLANES[i]) < 0) + if (H5Pset_chunk(src_dcplid, RANK, UC_1_PLANES[i]) < 0) UC_ERROR - if(H5Pset_fill_value(src_dcplid, UC_1_SOURCE_DATATYPE, - &UC_1_FILL_VALUES[i]) < 0) + if (H5Pset_fill_value(src_dcplid, UC_1_SOURCE_DATATYPE, &UC_1_FILL_VALUES[i]) < 0) UC_ERROR - if(0 != i % 2) - if(H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0) + if (0 != i % 2) + if (H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0) UC_ERROR /* Create source file, dataspace, and dataset */ - if((fid = H5Fcreate(UC_1_FILE_NAMES[i], H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_1_FILE_NAMES[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR - if((src_sid = H5Screate_simple(RANK, UC_1_DIMS[i], - UC_1_MAX_DIMS[i])) < 0) + if ((src_sid = H5Screate_simple(RANK, UC_1_DIMS[i], UC_1_MAX_DIMS[i])) < 0) UC_ERROR - if((did = H5Dcreate2(fid, UC_1_SOURCE_DSET_NAME, - UC_1_SOURCE_DATATYPE, src_sid, - H5P_DEFAULT, src_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_1_SOURCE_DSET_NAME, UC_1_SOURCE_DATATYPE, src_sid, H5P_DEFAULT, + src_dcplid, H5P_DEFAULT)) < 0) UC_ERROR /* Set the dataset's extent (will eventually vary with i) */ extent[0] = UC_1_N_TEST_PLANES; extent[1] = UC_1_PLANES[i][1]; extent[2] = UC_1_PLANES[i][2]; - if(H5Dset_extent(did, extent) < 0) + if (H5Dset_extent(did, extent) < 0) UC_ERROR /* Create a data buffer that represents a plane */ count = UC_1_PLANES[i][1] * UC_1_PLANES[i][2]; - if(NULL == (buffer = (int *)malloc(count * sizeof(int)))) + if (NULL == (buffer = (int *)malloc(count * sizeof(int)))) UC_ERROR /* Create the memory dataspace */ - if((msid = H5Screate_simple(RANK, UC_1_PLANES[i], NULL)) < 0) + if ((msid = H5Screate_simple(RANK, UC_1_PLANES[i], NULL)) < 0) UC_ERROR /* Get the file dataspace */ - if((fsid = H5Dget_space(did)) < 0) + if ((fsid = H5Dget_space(did)) < 0) UC_ERROR /* Write planes to the dataset, number will eventually vary with i */ n_planes = UC_1_N_TEST_PLANES; - for(j = 0; j < n_planes; j++) { + for (j = 0; j < n_planes; j++) { value = ((i + 1) * 10) + j; - for(k = 0; k < count; k++) - buffer[k] = value; + for (k = 0; k < count; k++) + buffer[k] = value; start[0] = (hsize_t)j; start[1] = 0; start[2] = 0; - if(H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_1_PLANES[i], NULL) < 0) + if (H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_1_PLANES[i], NULL) < 0) UC_ERROR - if(H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) UC_ERROR } /* end for */ @@ -178,90 +159,86 @@ main(void) start[0] = 0; start[1] = 0; start[2] = 0; - if(H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, - UC_1_MAX_DIMS[i], NULL) < 0) + if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_1_MAX_DIMS[i], NULL) < 0) UC_ERROR start[0] = 0; start[1] = map_start; start[2] = 0; - if(H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, NULL, - UC_1_MAX_DIMS[i], NULL) < 0) + if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, NULL, UC_1_MAX_DIMS[i], NULL) < 0) UC_ERROR map_start += UC_1_PLANES[i][1]; /* Add VDS mapping */ - if(H5Pset_virtual(vds_dcplid, vds_sid, UC_1_FILE_NAMES[i], - UC_1_SOURCE_DSET_PATH, src_sid) < 0) + if (H5Pset_virtual(vds_dcplid, vds_sid, UC_1_FILE_NAMES[i], UC_1_SOURCE_DSET_PATH, src_sid) < 0) UC_ERROR /* close */ - if(H5Sclose(src_sid) < 0) + if (H5Sclose(src_sid) < 0) UC_ERROR - if(H5Pclose(src_dcplid) < 0) + if (H5Pclose(src_dcplid) < 0) UC_ERROR - if(H5Sclose(msid) < 0) + if (H5Sclose(msid) < 0) UC_ERROR - if(H5Sclose(fsid) < 0) + if (H5Sclose(fsid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR free(buffer); } /* end for */ - /******************* * Create VDS file * *******************/ /* file */ - if((fid = H5Fcreate(UC_1_VDS_FILE_NAME, H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_1_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR /* dataset */ - if((did = H5Dcreate2(fid, UC_1_VDS_DSET_NAME, UC_1_VDS_DATATYPE, vds_sid, - H5P_DEFAULT, vds_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_1_VDS_DSET_NAME, UC_1_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid, + H5P_DEFAULT)) < 0) UC_ERROR /* close */ - if(H5Pclose(vds_dcplid) < 0) + if (H5Pclose(vds_dcplid) < 0) UC_ERROR - if(H5Sclose(vds_sid) < 0) + if (H5Sclose(vds_sid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR return EXIT_SUCCESS; error: - H5E_BEGIN_TRY { - if(src_sid >= 0) + H5E_BEGIN_TRY + { + if (src_sid >= 0) (void)H5Sclose(src_sid); - if(src_dcplid >= 0) + if (src_dcplid >= 0) (void)H5Pclose(src_dcplid); - if(vds_sid >= 0) + if (vds_sid >= 0) (void)H5Sclose(vds_sid); - if(vds_dcplid >= 0) + if (vds_dcplid >= 0) (void)H5Pclose(vds_dcplid); - if(fid >= 0) + if (fid >= 0) (void)H5Fclose(fid); - if(did >= 0) + if (did >= 0) (void)H5Dclose(did); - if(msid >= 0) + if (msid >= 0) (void)H5Sclose(msid); - if(fsid >= 0) + if (fsid >= 0) (void)H5Sclose(fsid); - if(buffer != NULL) + if (buffer != NULL) free(buffer); - } H5E_END_TRY + } + H5E_END_TRY return EXIT_FAILURE; } /* end main */ - diff --git a/tools/test/misc/vds/UC_2.h b/tools/test/misc/vds/UC_2.h index a3ee0f7..8165756 100644 --- a/tools/test/misc/vds/UC_2.h +++ b/tools/test/misc/vds/UC_2.h @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -45,64 +45,54 @@ | | dim[1] - + */ -#define UC_2_N_SOURCES 5 +#define UC_2_N_SOURCES 5 /* Dataset dimensions */ -#define UC_2_A_HEIGHT 2 -#define UC_2_B_HEIGHT 4 -#define UC_2_AB_HEIGHT 6 /* For hyperslab start position */ -#define UC_2_C_HEIGHT 2 -#define UC_2_D_HEIGHT 5 -#define UC_2_E_HEIGHT 3 -#define UC_2_FULL_HEIGHT 8 /* A+B+C and D+E */ -#define UC_2_WIDTH 7 -#define UC_2_FULL_WIDTH 14 /* 2*width */ - -#define UC_2_N_PLANES_IN_SERIES 3 /* number of planes in a series of sub-images */ -#define UC_2_N_MAX_PLANES H5S_UNLIMITED /* max number of planes */ -#define UC_2_N_TEST_PLANES 6 /* number of planes we write */ +#define UC_2_A_HEIGHT 2 +#define UC_2_B_HEIGHT 4 +#define UC_2_AB_HEIGHT 6 /* For hyperslab start position */ +#define UC_2_C_HEIGHT 2 +#define UC_2_D_HEIGHT 5 +#define UC_2_E_HEIGHT 3 +#define UC_2_FULL_HEIGHT 8 /* A+B+C and D+E */ +#define UC_2_WIDTH 7 +#define UC_2_FULL_WIDTH 14 /* 2*width */ + +#define UC_2_N_PLANES_IN_SERIES 3 /* number of planes in a series of sub-images */ +#define UC_2_N_MAX_PLANES H5S_UNLIMITED /* max number of planes */ +#define UC_2_N_TEST_PLANES 6 /* number of planes we write */ /* Dataset datatypes */ -#define UC_2_SOURCE_DATATYPE H5T_STD_I32LE -#define UC_2_VDS_DATATYPE H5T_STD_I32LE +#define UC_2_SOURCE_DATATYPE H5T_STD_I32LE +#define UC_2_VDS_DATATYPE H5T_STD_I32LE /* Starting size of datasets, both source and VDS */ -static hsize_t UC_2_DIMS[UC_2_N_SOURCES][RANK] = { - {0, UC_2_A_HEIGHT, UC_2_WIDTH}, - {0, UC_2_B_HEIGHT, UC_2_WIDTH}, - {0, UC_2_C_HEIGHT, UC_2_WIDTH}, - {0, UC_2_D_HEIGHT, UC_2_WIDTH}, - {0, UC_2_E_HEIGHT, UC_2_WIDTH} -}; +static hsize_t UC_2_DIMS[UC_2_N_SOURCES][RANK] = {{0, UC_2_A_HEIGHT, UC_2_WIDTH}, + {0, UC_2_B_HEIGHT, UC_2_WIDTH}, + {0, UC_2_C_HEIGHT, UC_2_WIDTH}, + {0, UC_2_D_HEIGHT, UC_2_WIDTH}, + {0, UC_2_E_HEIGHT, UC_2_WIDTH}}; /* Maximum size of datasets, both source and VDS */ -static hsize_t UC_2_MAX_DIMS[UC_2_N_SOURCES][RANK] = { - {UC_2_N_MAX_PLANES, UC_2_A_HEIGHT, UC_2_WIDTH}, - {UC_2_N_MAX_PLANES, UC_2_B_HEIGHT, UC_2_WIDTH}, - {UC_2_N_MAX_PLANES, UC_2_C_HEIGHT, UC_2_WIDTH}, - {UC_2_N_MAX_PLANES, UC_2_D_HEIGHT, UC_2_WIDTH}, - {UC_2_N_MAX_PLANES, UC_2_E_HEIGHT, UC_2_WIDTH} -}; +static hsize_t UC_2_MAX_DIMS[UC_2_N_SOURCES][RANK] = {{UC_2_N_MAX_PLANES, UC_2_A_HEIGHT, UC_2_WIDTH}, + {UC_2_N_MAX_PLANES, UC_2_B_HEIGHT, UC_2_WIDTH}, + {UC_2_N_MAX_PLANES, UC_2_C_HEIGHT, UC_2_WIDTH}, + {UC_2_N_MAX_PLANES, UC_2_D_HEIGHT, UC_2_WIDTH}, + {UC_2_N_MAX_PLANES, UC_2_E_HEIGHT, UC_2_WIDTH}}; /* File names for source datasets */ static char UC_2_FILE_NAMES[UC_2_N_SOURCES][NAME_LEN] = { - {"2_a.h5"}, - {"2_b.h5"}, - {"2_c.h5"}, - {"2_d.h5"}, - {"2_e.h5"} -}; + {"2_a.h5"}, {"2_b.h5"}, {"2_c.h5"}, {"2_d.h5"}, {"2_e.h5"}}; /* VDS file name */ -#define UC_2_VDS_FILE_NAME "2_vds.h5" - +#define UC_2_VDS_FILE_NAME "2_vds.h5" + /* Dataset names */ -#define UC_2_SOURCE_DSET_NAME "source_dset" -#define UC_2_SOURCE_DSET_PATH "/source_dset" -#define UC_2_VDS_DSET_NAME "vds_dset" +#define UC_2_SOURCE_DSET_NAME "source_dset" +#define UC_2_SOURCE_DSET_PATH "/source_dset" +#define UC_2_VDS_DSET_NAME "vds_dset" #endif /* UC_2_H */ - diff --git a/tools/test/misc/vds/UC_2_two_dims_gen.c b/tools/test/misc/vds/UC_2_two_dims_gen.c index bd70fda..85bd63d 100644 --- a/tools/test/misc/vds/UC_2_two_dims_gen.c +++ b/tools/test/misc/vds/UC_2_two_dims_gen.c @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,7 +17,6 @@ * See the header file for a description. */ - #include <stdlib.h> #include "hdf5.h" @@ -25,72 +24,60 @@ #include "UC_common.h" #include "UC_2.h" -static hsize_t UC_2_VDS_DIMS[RANK] = {0, UC_2_FULL_HEIGHT, UC_2_FULL_WIDTH}; -static hsize_t UC_2_VDS_MAX_DIMS[RANK] = {UC_2_N_MAX_PLANES, UC_2_FULL_HEIGHT, UC_2_FULL_WIDTH}; +static hsize_t UC_2_VDS_DIMS[RANK] = {0, UC_2_FULL_HEIGHT, UC_2_FULL_WIDTH}; +static hsize_t UC_2_VDS_MAX_DIMS[RANK] = {UC_2_N_MAX_PLANES, UC_2_FULL_HEIGHT, UC_2_FULL_WIDTH}; /* Positions of source datasets in the VDS */ static hsize_t UC_2_POSITIONS[UC_2_N_SOURCES][RANK] = { - /* A */ {0, 0, 0}, - /* B */ {0, UC_2_A_HEIGHT, 0}, + /* A */ {0, 0, 0}, + /* B */ {0, UC_2_A_HEIGHT, 0}, /* C */ {0, UC_2_AB_HEIGHT, 0}, - /* D */ {0, 0, UC_2_WIDTH}, - /* E */ {0, UC_2_D_HEIGHT, UC_2_WIDTH} -}; + /* D */ {0, 0, UC_2_WIDTH}, + /* E */ {0, UC_2_D_HEIGHT, UC_2_WIDTH}}; /* Planes */ -static hsize_t UC_2_PLANES[UC_2_N_SOURCES][RANK] = { - {1, UC_2_A_HEIGHT, UC_2_WIDTH}, - {1, UC_2_B_HEIGHT, UC_2_WIDTH}, - {1, UC_2_C_HEIGHT, UC_2_WIDTH}, - {1, UC_2_D_HEIGHT, UC_2_WIDTH}, - {1, UC_2_E_HEIGHT, UC_2_WIDTH} -}; +static hsize_t UC_2_PLANES[UC_2_N_SOURCES][RANK] = {{1, UC_2_A_HEIGHT, UC_2_WIDTH}, + {1, UC_2_B_HEIGHT, UC_2_WIDTH}, + {1, UC_2_C_HEIGHT, UC_2_WIDTH}, + {1, UC_2_D_HEIGHT, UC_2_WIDTH}, + {1, UC_2_E_HEIGHT, UC_2_WIDTH}}; /* Chunk dimensions */ -static hsize_t UC_2_CHUNK_DIMS[UC_2_N_SOURCES][RANK] = { - {UC_2_N_PLANES_IN_SERIES, UC_2_A_HEIGHT, UC_2_WIDTH}, - {UC_2_N_PLANES_IN_SERIES, UC_2_B_HEIGHT, UC_2_WIDTH}, - {UC_2_N_PLANES_IN_SERIES, UC_2_C_HEIGHT, UC_2_WIDTH}, - {UC_2_N_PLANES_IN_SERIES, UC_2_D_HEIGHT, UC_2_WIDTH}, - {UC_2_N_PLANES_IN_SERIES, UC_2_E_HEIGHT, UC_2_WIDTH} -}; +static hsize_t UC_2_CHUNK_DIMS[UC_2_N_SOURCES][RANK] = {{UC_2_N_PLANES_IN_SERIES, UC_2_A_HEIGHT, UC_2_WIDTH}, + {UC_2_N_PLANES_IN_SERIES, UC_2_B_HEIGHT, UC_2_WIDTH}, + {UC_2_N_PLANES_IN_SERIES, UC_2_C_HEIGHT, UC_2_WIDTH}, + {UC_2_N_PLANES_IN_SERIES, UC_2_D_HEIGHT, UC_2_WIDTH}, + {UC_2_N_PLANES_IN_SERIES, UC_2_E_HEIGHT, UC_2_WIDTH}}; /* Fill values */ -static int UC_2_FILL_VALUES[UC_2_N_SOURCES] = { - -1, - -2, - -3, - -4, - -5 -}; -static int UC_2_VDS_FILL_VALUE = -9; +static int UC_2_FILL_VALUES[UC_2_N_SOURCES] = {-1, -2, -3, -4, -5}; +static int UC_2_VDS_FILL_VALUE = -9; int main(void) { - hid_t src_sid = -1; /* source dataset's dataspace ID */ - hid_t src_dcplid = -1; /* source dataset property list ID */ - - hid_t vds_sid = -1; /* VDS dataspace ID */ - hid_t vds_dcplid = -1; /* VDS dataset property list ID */ + hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */ + hid_t src_dcplid = H5I_INVALID_HID; /* source dataset property list ID */ - hid_t fid = -1; /* HDF5 file ID */ - hid_t did = -1; /* dataset ID */ - hid_t msid = -1; /* memory dataspace ID */ - hid_t fsid = -1; /* file dataspace ID */ + hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */ + hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */ - hsize_t start[RANK]; /* starting point for hyperslab */ - hsize_t extent[RANK]; /* dataset extents */ + hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ + hid_t did = H5I_INVALID_HID; /* dataset ID */ + hid_t msid = H5I_INVALID_HID; /* memory dataspace ID */ + hid_t fsid = H5I_INVALID_HID; /* file dataspace ID */ - int *buffer = NULL; /* data buffer */ - int value = -1; /* value written to datasets */ - hsize_t count = 0; /* number of elements in a plane */ - int n_planes = -1; /* number of planes to write */ + hsize_t start[RANK]; /* starting point for hyperslab */ + hsize_t extent[RANK]; /* dataset extents */ - int i; /* iterator */ - int j; /* iterator */ - hsize_t k; /* iterator */ + int * buffer = NULL; /* data buffer */ + int value = -1; /* value written to datasets */ + hsize_t count = 0; /* number of elements in a plane */ + int n_planes = -1; /* number of planes to write */ + int i; /* iterator */ + int j; /* iterator */ + hsize_t k; /* iterator */ /* Start by creating the virtual dataset (VDS) dataspace and creation * property list. The individual source datasets are then created @@ -98,15 +85,13 @@ main(void) */ /* Create VDS dcpl */ - if((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_fill_value(vds_dcplid, UC_2_VDS_DATATYPE, - &UC_2_VDS_FILL_VALUE) < 0) + if (H5Pset_fill_value(vds_dcplid, UC_2_VDS_DATATYPE, &UC_2_VDS_FILL_VALUE) < 0) UC_ERROR /* Create VDS dataspace */ - if((vds_sid = H5Screate_simple(RANK, UC_2_VDS_DIMS, - UC_2_VDS_MAX_DIMS)) < 0) + if ((vds_sid = H5Screate_simple(RANK, UC_2_VDS_DIMS, UC_2_VDS_MAX_DIMS)) < 0) UC_ERROR /************************************ @@ -117,65 +102,61 @@ main(void) start[1] = 0; start[2] = 0; - for(i = 0; i < UC_2_N_SOURCES; i++) { + for (i = 0; i < UC_2_N_SOURCES; i++) { /* source dataset dcpl */ - if((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_chunk(src_dcplid, RANK, UC_2_CHUNK_DIMS[i]) < 0) + if (H5Pset_chunk(src_dcplid, RANK, UC_2_CHUNK_DIMS[i]) < 0) UC_ERROR - if(H5Pset_fill_value(src_dcplid, UC_2_SOURCE_DATATYPE, - &UC_2_FILL_VALUES[i]) < 0) + if (H5Pset_fill_value(src_dcplid, UC_2_SOURCE_DATATYPE, &UC_2_FILL_VALUES[i]) < 0) UC_ERROR - if(H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0) + if (H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0) UC_ERROR /* Create source file, dataspace, and dataset */ - if((fid = H5Fcreate(UC_2_FILE_NAMES[i], H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_2_FILE_NAMES[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR - if((src_sid = H5Screate_simple(RANK, UC_2_DIMS[i], - UC_2_MAX_DIMS[i])) < 0) + if ((src_sid = H5Screate_simple(RANK, UC_2_DIMS[i], UC_2_MAX_DIMS[i])) < 0) UC_ERROR - if((did = H5Dcreate2(fid, UC_2_SOURCE_DSET_NAME, - UC_2_SOURCE_DATATYPE, src_sid, - H5P_DEFAULT, src_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_2_SOURCE_DSET_NAME, UC_2_SOURCE_DATATYPE, src_sid, H5P_DEFAULT, + src_dcplid, H5P_DEFAULT)) < 0) UC_ERROR /* Set the dataset's extent (will eventually vary with i) */ extent[0] = UC_2_N_TEST_PLANES; extent[1] = UC_2_PLANES[i][1]; extent[2] = UC_2_PLANES[i][2]; - if(H5Dset_extent(did, extent) < 0) + if (H5Dset_extent(did, extent) < 0) UC_ERROR /* Create a data buffer that represents a plane */ count = UC_2_PLANES[i][1] * UC_2_PLANES[i][2]; - if(NULL == (buffer = (int *)malloc(count * sizeof(int)))) + if (NULL == (buffer = (int *)malloc(count * sizeof(int)))) UC_ERROR /* Create the memory dataspace */ - if((msid = H5Screate_simple(RANK, UC_2_PLANES[i], NULL)) < 0) + if ((msid = H5Screate_simple(RANK, UC_2_PLANES[i], NULL)) < 0) UC_ERROR /* Get the file dataspace */ - if((fsid = H5Dget_space(did)) < 0) + if ((fsid = H5Dget_space(did)) < 0) UC_ERROR /* Write planes to the dataset, number will eventually vary with i */ n_planes = UC_2_N_TEST_PLANES; - for(j = 0; j < n_planes; j++) { + for (j = 0; j < n_planes; j++) { value = ((i + 1) * 10) + j; - for(k = 0; k < count; k++) - buffer[k] = value; + for (k = 0; k < count; k++) + buffer[k] = value; start[0] = (hsize_t)j; start[1] = 0; start[2] = 0; - if(H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_2_PLANES[i], NULL) < 0) + if (H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_2_PLANES[i], NULL) < 0) UC_ERROR - if(H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) UC_ERROR } /* end for */ @@ -184,30 +165,27 @@ main(void) start[0] = 0; start[1] = 0; start[2] = 0; - if(H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, - UC_2_MAX_DIMS[i], NULL) < 0) + if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_2_MAX_DIMS[i], NULL) < 0) UC_ERROR - if(H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, UC_2_POSITIONS[i], NULL, - UC_2_MAX_DIMS[i], NULL) < 0) + if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, UC_2_POSITIONS[i], NULL, UC_2_MAX_DIMS[i], NULL) < 0) UC_ERROR /* Add VDS mapping */ - if(H5Pset_virtual(vds_dcplid, vds_sid, UC_2_FILE_NAMES[i], - UC_2_SOURCE_DSET_PATH, src_sid) < 0) + if (H5Pset_virtual(vds_dcplid, vds_sid, UC_2_FILE_NAMES[i], UC_2_SOURCE_DSET_PATH, src_sid) < 0) UC_ERROR /* close */ - if(H5Sclose(msid) < 0) + if (H5Sclose(msid) < 0) UC_ERROR - if(H5Sclose(fsid) < 0) + if (H5Sclose(fsid) < 0) UC_ERROR - if(H5Sclose(src_sid) < 0) + if (H5Sclose(src_sid) < 0) UC_ERROR - if(H5Pclose(src_dcplid) < 0) + if (H5Pclose(src_dcplid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR free(buffer); @@ -218,51 +196,51 @@ main(void) *******************************/ /* file */ - if((fid = H5Fcreate(UC_2_VDS_FILE_NAME, H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_2_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR /* dataset */ - if((did = H5Dcreate2(fid, UC_2_VDS_DSET_NAME, UC_2_VDS_DATATYPE, vds_sid, - H5P_DEFAULT, vds_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_2_VDS_DSET_NAME, UC_2_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid, + H5P_DEFAULT)) < 0) UC_ERROR /* close */ - if(H5Pclose(vds_dcplid) < 0) + if (H5Pclose(vds_dcplid) < 0) UC_ERROR - if(H5Sclose(vds_sid) < 0) + if (H5Sclose(vds_sid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR return EXIT_SUCCESS; error: - H5E_BEGIN_TRY { - if(src_sid >= 0) + H5E_BEGIN_TRY + { + if (src_sid >= 0) (void)H5Sclose(src_sid); - if(src_dcplid >= 0) + if (src_dcplid >= 0) (void)H5Pclose(src_dcplid); - if(vds_sid >= 0) + if (vds_sid >= 0) (void)H5Sclose(vds_sid); - if(vds_dcplid >= 0) + if (vds_dcplid >= 0) (void)H5Pclose(vds_dcplid); - if(fid >= 0) + if (fid >= 0) (void)H5Fclose(fid); - if(did >= 0) + if (did >= 0) (void)H5Dclose(did); - if(msid >= 0) + if (msid >= 0) (void)H5Sclose(msid); - if(fsid >= 0) + if (fsid >= 0) (void)H5Sclose(fsid); - if(buffer != NULL) + if (buffer != NULL) free(buffer); - } H5E_END_TRY + } + H5E_END_TRY return EXIT_FAILURE; } /* end main() */ - diff --git a/tools/test/misc/vds/UC_3.h b/tools/test/misc/vds/UC_3.h index 0c26dfb..f7e84eb 100644 --- a/tools/test/misc/vds/UC_3.h +++ b/tools/test/misc/vds/UC_3.h @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -31,42 +31,40 @@ * Height and width are large enough to encompass the * mapped source datasets with gaps. */ -#define UC_31_VDS_HEIGHT 25 /* full height + 7 (gaps of 1) */ -#define UC_31_VDS_WIDTH 8 /* full width + 0 (no gaps) */ -#define UC_32_VDS_HEIGHT 13 /* full height + 5 */ -#define UC_32_VDS_WIDTH 19 /* full width + 5 */ -#define UC_31_GAP 1 +#define UC_31_VDS_HEIGHT 25 /* full height + 7 (gaps of 1) */ +#define UC_31_VDS_WIDTH 8 /* full width + 0 (no gaps) */ +#define UC_32_VDS_HEIGHT 13 /* full height + 5 */ +#define UC_32_VDS_WIDTH 19 /* full width + 5 */ +#define UC_31_GAP 1 /* VDS datatypes */ -#define UC_31_VDS_DATATYPE H5T_STD_I32LE -#define UC_32_VDS_DATATYPE H5T_STD_I32LE +#define UC_31_VDS_DATATYPE H5T_STD_I32LE +#define UC_32_VDS_DATATYPE H5T_STD_I32LE /* Starting size of virtual datasets */ -static hsize_t UC_31_VDS_DIMS[RANK] = {0, UC_31_VDS_HEIGHT, UC_31_VDS_WIDTH}; -static hsize_t UC_32_VDS_DIMS[RANK] = {0, UC_32_VDS_HEIGHT, UC_32_VDS_WIDTH}; +static hsize_t UC_31_VDS_DIMS[RANK] = {0, UC_31_VDS_HEIGHT, UC_31_VDS_WIDTH}; +static hsize_t UC_32_VDS_DIMS[RANK] = {0, UC_32_VDS_HEIGHT, UC_32_VDS_WIDTH}; /* Maximum size of virtual datasets */ -static hsize_t UC_31_VDS_MAX_DIMS[RANK] = {UC_1_N_MAX_PLANES, UC_31_VDS_HEIGHT, UC_31_VDS_WIDTH}; -static hsize_t UC_32_VDS_MAX_DIMS[RANK] = {UC_2_N_MAX_PLANES, UC_32_VDS_HEIGHT, UC_32_VDS_WIDTH}; +static hsize_t UC_31_VDS_MAX_DIMS[RANK] = {UC_1_N_MAX_PLANES, UC_31_VDS_HEIGHT, UC_31_VDS_WIDTH}; +static hsize_t UC_32_VDS_MAX_DIMS[RANK] = {UC_2_N_MAX_PLANES, UC_32_VDS_HEIGHT, UC_32_VDS_WIDTH}; /* Positions of mapped source datasets */ static hsize_t UC_32_POSITIONS[UC_2_N_SOURCES][RANK] = { - /* A */ {0, 1, 1}, - /* B */ {0, 4, 0}, - /* C */ {0, 11, 4}, - /* D */ {0, 1, 9}, - /* E */ {0, 8, 12} -}; + /* A */ {0, 1, 1}, + /* B */ {0, 4, 0}, + /* C */ {0, 11, 4}, + /* D */ {0, 1, 9}, + /* E */ {0, 8, 12}}; /* VDS file names */ -#define UC_31_VDS_FILE_NAME "3_1_vds.h5" -#define UC_32_VDS_FILE_NAME "3_2_vds.h5" +#define UC_31_VDS_FILE_NAME "3_1_vds.h5" +#define UC_32_VDS_FILE_NAME "3_2_vds.h5" /* Dataset name */ -#define UC_3_VDS_DSET_NAME "vds_dset" +#define UC_3_VDS_DSET_NAME "vds_dset" /* Fill value */ -static int UC_3_VDS_FILL_VALUE = -9; +static int UC_3_VDS_FILL_VALUE = -9; #endif /* UC_3_H */ - diff --git a/tools/test/misc/vds/UC_3_gaps_gen.c b/tools/test/misc/vds/UC_3_gaps_gen.c index e6e7226..e6e311a 100644 --- a/tools/test/misc/vds/UC_3_gaps_gen.c +++ b/tools/test/misc/vds/UC_3_gaps_gen.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -29,28 +29,26 @@ static herr_t create_3_1_vds(void) { - hid_t src_sid = -1; /* source dataset's dataspace ID */ - hid_t vds_sid = -1; /* VDS dataspace ID */ - hid_t vds_dcplid = -1; /* VDS dataset property list ID */ + hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */ + hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */ + hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */ - hid_t fid = -1; /* HDF5 file ID */ - hid_t did = -1; /* dataset ID */ + hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ + hid_t did = H5I_INVALID_HID; /* dataset ID */ - hsize_t start[RANK]; /* source starting point for hyperslab */ - hsize_t position[RANK]; /* vds mapping positions */ + hsize_t start[RANK]; /* source starting point for hyperslab */ + hsize_t position[RANK]; /* vds mapping positions */ - int i; /* iterator */ + int i; /* iterator */ /* Create VDS dcpl */ - if((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_fill_value(vds_dcplid, UC_31_VDS_DATATYPE, - &UC_3_VDS_FILL_VALUE) < 0) + if (H5Pset_fill_value(vds_dcplid, UC_31_VDS_DATATYPE, &UC_3_VDS_FILL_VALUE) < 0) UC_ERROR /* Create VDS dataspace */ - if((vds_sid = H5Screate_simple(RANK, UC_31_VDS_DIMS, - UC_31_VDS_MAX_DIMS)) < 0) + if ((vds_sid = H5Screate_simple(RANK, UC_31_VDS_DIMS, UC_31_VDS_MAX_DIMS)) < 0) UC_ERROR /* Set starting positions */ @@ -65,26 +63,22 @@ create_3_1_vds(void) /****************************** * Create source-VDS mappings * ******************************/ - for(i = 0; i < UC_1_N_SOURCES; i++) { + for (i = 0; i < UC_1_N_SOURCES; i++) { - if((src_sid = H5Screate_simple(RANK, UC_1_DIMS[i], - UC_1_MAX_DIMS[i])) < 0) - UC_ERROR + if ((src_sid = H5Screate_simple(RANK, UC_1_DIMS[i], UC_1_MAX_DIMS[i])) < 0) + UC_ERROR /* set up hyperslabs for source and destination datasets */ - if(H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, - UC_1_MAX_DIMS[i], NULL) < 0) + if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_1_MAX_DIMS[i], NULL) < 0) UC_ERROR - if(H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, position, - NULL, UC_1_MAX_DIMS[i], NULL) < 0) + if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, position, NULL, UC_1_MAX_DIMS[i], NULL) < 0) UC_ERROR position[1] += UC_1_DIMS[i][1] + UC_31_GAP; /* Add VDS mapping */ - if(H5Pset_virtual(vds_dcplid, vds_sid, UC_1_FILE_NAMES[i], - UC_1_SOURCE_DSET_PATH, src_sid) < 0) + if (H5Pset_virtual(vds_dcplid, vds_sid, UC_1_FILE_NAMES[i], UC_1_SOURCE_DSET_PATH, src_sid) < 0) UC_ERROR - if(H5Sclose(src_sid) < 0) + if (H5Sclose(src_sid) < 0) UC_ERROR } /* end for */ @@ -94,39 +88,40 @@ create_3_1_vds(void) *******************************/ /* file */ - if((fid = H5Fcreate(UC_31_VDS_FILE_NAME, H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_31_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR /* dataset */ - if((did = H5Dcreate2(fid, UC_3_VDS_DSET_NAME, UC_31_VDS_DATATYPE, vds_sid, - H5P_DEFAULT, vds_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_3_VDS_DSET_NAME, UC_31_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid, + H5P_DEFAULT)) < 0) UC_ERROR /* close */ - if(H5Pclose(vds_dcplid) < 0) + if (H5Pclose(vds_dcplid) < 0) UC_ERROR - if(H5Sclose(vds_sid) < 0) + if (H5Sclose(vds_sid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR return 0; error: - H5E_BEGIN_TRY { - if(vds_sid >= 0) + H5E_BEGIN_TRY + { + if (vds_sid >= 0) (void)H5Sclose(vds_sid); - if(vds_dcplid >= 0) + if (vds_dcplid >= 0) (void)H5Pclose(vds_dcplid); - if(fid >= 0) + if (fid >= 0) (void)H5Fclose(fid); - if(did >= 0) + if (did >= 0) (void)H5Dclose(did); - } H5E_END_TRY + } + H5E_END_TRY return -1; @@ -136,27 +131,25 @@ error: static herr_t create_3_2_vds(void) { - hid_t src_sid = -1; /* source dataset's dataspace ID */ - hid_t vds_sid = -1; /* VDS dataspace ID */ - hid_t vds_dcplid = -1; /* VDS dataset property list ID */ + hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */ + hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */ + hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */ - hid_t fid = -1; /* HDF5 file ID */ - hid_t did = -1; /* dataset ID */ + hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ + hid_t did = H5I_INVALID_HID; /* dataset ID */ - hsize_t start[RANK]; /* source starting point for hyperslab */ + hsize_t start[RANK]; /* source starting point for hyperslab */ - int i; /* iterator */ + int i; /* iterator */ /* Create VDS dcpl */ - if((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_fill_value(vds_dcplid, UC_32_VDS_DATATYPE, - &UC_3_VDS_FILL_VALUE) < 0) + if (H5Pset_fill_value(vds_dcplid, UC_32_VDS_DATATYPE, &UC_3_VDS_FILL_VALUE) < 0) UC_ERROR /* Create VDS dataspace */ - if((vds_sid = H5Screate_simple(RANK, UC_32_VDS_DIMS, - UC_32_VDS_MAX_DIMS)) < 0) + if ((vds_sid = H5Screate_simple(RANK, UC_32_VDS_DIMS, UC_32_VDS_MAX_DIMS)) < 0) UC_ERROR /* Set starting positions */ @@ -167,25 +160,22 @@ create_3_2_vds(void) /****************************** * Create source-VDS mappings * ******************************/ - for(i = 0; i < UC_2_N_SOURCES; i++) { + for (i = 0; i < UC_2_N_SOURCES; i++) { - if((src_sid = H5Screate_simple(RANK, UC_2_DIMS[i], - UC_2_MAX_DIMS[i])) < 0) - UC_ERROR + if ((src_sid = H5Screate_simple(RANK, UC_2_DIMS[i], UC_2_MAX_DIMS[i])) < 0) + UC_ERROR /* set up hyperslabs for source and destination datasets */ - if(H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, - UC_2_MAX_DIMS[i], NULL) < 0) + if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_2_MAX_DIMS[i], NULL) < 0) UC_ERROR - if(H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, UC_32_POSITIONS[i], - NULL, UC_2_MAX_DIMS[i], NULL) < 0) + if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, UC_32_POSITIONS[i], NULL, UC_2_MAX_DIMS[i], NULL) < + 0) UC_ERROR /* Add VDS mapping */ - if(H5Pset_virtual(vds_dcplid, vds_sid, UC_2_FILE_NAMES[i], - UC_2_SOURCE_DSET_PATH, src_sid) < 0) + if (H5Pset_virtual(vds_dcplid, vds_sid, UC_2_FILE_NAMES[i], UC_2_SOURCE_DSET_PATH, src_sid) < 0) UC_ERROR - if(H5Sclose(src_sid) < 0) + if (H5Sclose(src_sid) < 0) UC_ERROR } /* end for */ @@ -195,39 +185,40 @@ create_3_2_vds(void) *******************************/ /* file */ - if((fid = H5Fcreate(UC_32_VDS_FILE_NAME, H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_32_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR /* dataset */ - if((did = H5Dcreate2(fid, UC_3_VDS_DSET_NAME, UC_32_VDS_DATATYPE, vds_sid, - H5P_DEFAULT, vds_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_3_VDS_DSET_NAME, UC_32_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid, + H5P_DEFAULT)) < 0) UC_ERROR /* close */ - if(H5Pclose(vds_dcplid) < 0) + if (H5Pclose(vds_dcplid) < 0) UC_ERROR - if(H5Sclose(vds_sid) < 0) + if (H5Sclose(vds_sid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR return 0; error: - H5E_BEGIN_TRY { - if(vds_sid >= 0) + H5E_BEGIN_TRY + { + if (vds_sid >= 0) (void)H5Sclose(vds_sid); - if(vds_dcplid >= 0) + if (vds_dcplid >= 0) (void)H5Pclose(vds_dcplid); - if(fid >= 0) + if (fid >= 0) (void)H5Fclose(fid); - if(did >= 0) + if (did >= 0) (void)H5Dclose(did); - } H5E_END_TRY + } + H5E_END_TRY return -1; @@ -237,10 +228,10 @@ int main(void) { - if(create_3_1_vds() < 0) + if (create_3_1_vds() < 0) UC_ERROR - if(create_3_2_vds() < 0) + if (create_3_2_vds() < 0) UC_ERROR return EXIT_SUCCESS; @@ -250,4 +241,3 @@ error: return EXIT_FAILURE; } /* end main() */ - diff --git a/tools/test/misc/vds/UC_4.h b/tools/test/misc/vds/UC_4.h index 5dba4fb..9efd077 100644 --- a/tools/test/misc/vds/UC_4.h +++ b/tools/test/misc/vds/UC_4.h @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -29,39 +29,35 @@ /* virtual dataset <---> source dataset mapping and sizes */ -#define UC_4_N_SOURCES 3 +#define UC_4_N_SOURCES 3 /* Dataset dimensions */ -#define UC_4_SRC_PLANES 3 -#define UC_4_HEIGHT 4 -#define UC_4_WIDTH 4 +#define UC_4_SRC_PLANES 3 +#define UC_4_HEIGHT 4 +#define UC_4_WIDTH 4 /* max number of planes for VDS (sources are finite) */ -#define UC_4_VDS_MAX_PLANES H5S_UNLIMITED -#define UC_4_N_TEST_PLANES 9 /* number of planes in the VDS */ +#define UC_4_VDS_MAX_PLANES H5S_UNLIMITED +#define UC_4_N_TEST_PLANES 9 /* number of planes in the VDS */ /* Dataset datatypes */ -#define UC_4_SOURCE_DATATYPE H5T_STD_I32LE -#define UC_4_VDS_DATATYPE H5T_STD_I32LE +#define UC_4_SOURCE_DATATYPE H5T_STD_I32LE +#define UC_4_VDS_DATATYPE H5T_STD_I32LE /* Starting size of datasets, both source and VDS */ static hsize_t UC_4_SOURCE_DIMS[RANK] = {0, UC_4_HEIGHT, UC_4_WIDTH}; -static hsize_t UC_4_VDS_DIMS[RANK] = {0, UC_4_HEIGHT, UC_4_WIDTH}; +static hsize_t UC_4_VDS_DIMS[RANK] = {0, UC_4_HEIGHT, UC_4_WIDTH}; /* Max size of datasets, both source and VDS */ static hsize_t UC_4_SOURCE_MAX_DIMS[RANK] = {UC_4_SRC_PLANES, UC_4_HEIGHT, UC_4_WIDTH}; -static hsize_t UC_4_VDS_MAX_DIMS[RANK] = {UC_4_VDS_MAX_PLANES, UC_4_HEIGHT, UC_4_WIDTH}; +static hsize_t UC_4_VDS_MAX_DIMS[RANK] = {UC_4_VDS_MAX_PLANES, UC_4_HEIGHT, UC_4_WIDTH}; /* Planes (both source and VDS) */ static hsize_t UC_4_PLANE[RANK] = {1, UC_4_HEIGHT, UC_4_WIDTH}; /* File names for source datasets */ -static char UC_4_FILE_NAMES[UC_4_N_SOURCES][NAME_LEN] = { - {"4_0.h5"}, - {"4_1.h5"}, - {"4_2.h5"} -}; -static char UC_4_MAPPING_FILE_NAME[NAME_LEN] = "4_%b.h5"; +static char UC_4_FILE_NAMES[UC_4_N_SOURCES][NAME_LEN] = {{"4_0.h5"}, {"4_1.h5"}, {"4_2.h5"}}; +static char UC_4_MAPPING_FILE_NAME[NAME_LEN] = "4_%b.h5"; /* VDS file name */ static char UC_4_VDS_FILE_NAME[NAME_LEN] = "4_vds.h5"; @@ -72,13 +68,7 @@ static char UC_4_SOURCE_DSET_PATH[NAME_LEN] = "/source_dset"; static char UC_4_VDS_DSET_NAME[NAME_LEN] = "vds_dset"; /* Fill values */ -static int UC_4_FILL_VALUES[UC_4_N_SOURCES] = { - -1, - -2, - -3 -}; -static int UC_4_VDS_FILL_VALUE = -9; +static int UC_4_FILL_VALUES[UC_4_N_SOURCES] = {-1, -2, -3}; +static int UC_4_VDS_FILL_VALUE = -9; #endif /* UC_4_H */ - - diff --git a/tools/test/misc/vds/UC_4_printf_gen.c b/tools/test/misc/vds/UC_4_printf_gen.c index b328046..206e1f3 100644 --- a/tools/test/misc/vds/UC_4_printf_gen.c +++ b/tools/test/misc/vds/UC_4_printf_gen.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,109 +27,104 @@ int main(void) { - hid_t src_sid = -1; /* source dataset's dataspace ID */ - hid_t src_dcplid = -1; /* source dataset property list ID */ + hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */ + hid_t src_dcplid = H5I_INVALID_HID; /* source dataset property list ID */ - hid_t vds_sid = -1; /* VDS dataspace ID */ - hid_t vds_dcplid = -1; /* VDS dataset property list ID */ + hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */ + hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */ - hid_t fid = -1; /* HDF5 file ID */ - hid_t did = -1; /* dataset ID */ - hid_t msid = -1; /* memory dataspace ID */ - hid_t fsid = -1; /* file dataspace ID */ + hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ + hid_t did = H5I_INVALID_HID; /* dataset ID */ + hid_t msid = H5I_INVALID_HID; /* memory dataspace ID */ + hid_t fsid = H5I_INVALID_HID; /* file dataspace ID */ /* Hyperslab arrays */ hsize_t start[RANK] = {0, 0, 0}; hsize_t count[RANK] = {H5S_UNLIMITED, 1, 1}; - int *buffer = NULL; /* data buffer */ - int value = -1; /* value written to datasets */ + int *buffer = NULL; /* data buffer */ + int value = -1; /* value written to datasets */ - hsize_t n = 0; /* number of elements in a plane */ + hsize_t n = 0; /* number of elements in a plane */ - int i; /* iterator */ - int j; /* iterator */ - hsize_t k; /* iterator */ + int i; /* iterator */ + int j; /* iterator */ + hsize_t k; /* iterator */ /************************************ * Create source files and datasets * ************************************/ /* Create source dataspace ID */ - if((src_sid = H5Screate_simple(RANK, UC_4_SOURCE_DIMS, - UC_4_SOURCE_MAX_DIMS)) < 0) + if ((src_sid = H5Screate_simple(RANK, UC_4_SOURCE_DIMS, UC_4_SOURCE_MAX_DIMS)) < 0) UC_ERROR - if(H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, - UC_4_SOURCE_MAX_DIMS, NULL) < 0) + if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_4_SOURCE_MAX_DIMS, NULL) < 0) UC_ERROR /* Create source files and datasets */ - for(i = 0; i < UC_4_N_SOURCES; i++) { + for (i = 0; i < UC_4_N_SOURCES; i++) { /* source dataset dcpl */ - if((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_chunk(src_dcplid, RANK, UC_4_PLANE) < 0) + if (H5Pset_chunk(src_dcplid, RANK, UC_4_PLANE) < 0) UC_ERROR - if(H5Pset_fill_value(src_dcplid, UC_4_SOURCE_DATATYPE, - &UC_4_FILL_VALUES[i]) < 0) + if (H5Pset_fill_value(src_dcplid, UC_4_SOURCE_DATATYPE, &UC_4_FILL_VALUES[i]) < 0) UC_ERROR - if(H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0) + if (H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0) UC_ERROR /* Create source file and dataset */ - if((fid = H5Fcreate(UC_4_FILE_NAMES[i], H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_4_FILE_NAMES[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR - if((did = H5Dcreate2(fid, UC_4_SOURCE_DSET_NAME, - UC_4_SOURCE_DATATYPE, src_sid, - H5P_DEFAULT, src_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_4_SOURCE_DSET_NAME, UC_4_SOURCE_DATATYPE, src_sid, H5P_DEFAULT, + src_dcplid, H5P_DEFAULT)) < 0) UC_ERROR /* Set the dataset's extent */ - if(H5Dset_extent(did, UC_4_SOURCE_MAX_DIMS) < 0) + if (H5Dset_extent(did, UC_4_SOURCE_MAX_DIMS) < 0) UC_ERROR /* Create a data buffer that represents a plane */ n = UC_4_PLANE[1] * UC_4_PLANE[2]; - if(NULL == (buffer = (int *)malloc(n * sizeof(int)))) + if (NULL == (buffer = (int *)malloc(n * sizeof(int)))) UC_ERROR /* Create the memory dataspace */ - if((msid = H5Screate_simple(RANK, UC_4_PLANE, NULL)) < 0) + if ((msid = H5Screate_simple(RANK, UC_4_PLANE, NULL)) < 0) UC_ERROR /* Get the file dataspace */ - if((fsid = H5Dget_space(did)) < 0) + if ((fsid = H5Dget_space(did)) < 0) UC_ERROR /* Write planes to the dataset */ - for(j = 0; j < UC_4_SRC_PLANES; j++) { + for (j = 0; j < UC_4_SRC_PLANES; j++) { value = ((i + 1) * 10) + j; - for(k = 0; k < n; k++) - buffer[k] = value; + for (k = 0; k < n; k++) + buffer[k] = value; start[0] = (hsize_t)j; start[1] = 0; start[2] = 0; - if(H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_4_PLANE, NULL) < 0) + if (H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_4_PLANE, NULL) < 0) UC_ERROR - if(H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) UC_ERROR } /* end for */ /* close */ - if(H5Sclose(msid) < 0) + if (H5Sclose(msid) < 0) UC_ERROR - if(H5Sclose(fsid) < 0) + if (H5Sclose(fsid) < 0) UC_ERROR - if(H5Pclose(src_dcplid) < 0) + if (H5Pclose(src_dcplid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR free(buffer); @@ -140,78 +135,75 @@ main(void) *******************/ /* Create file */ - if((fid = H5Fcreate(UC_4_VDS_FILE_NAME, H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_4_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR /* Create VDS dcpl */ - if((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_fill_value(vds_dcplid, UC_4_VDS_DATATYPE, - &UC_4_VDS_FILL_VALUE) < 0) + if (H5Pset_fill_value(vds_dcplid, UC_4_VDS_DATATYPE, &UC_4_VDS_FILL_VALUE) < 0) UC_ERROR /* Create VDS dataspace */ - if((vds_sid = H5Screate_simple(RANK, UC_4_VDS_DIMS, - UC_4_VDS_MAX_DIMS)) < 0) + if ((vds_sid = H5Screate_simple(RANK, UC_4_VDS_DIMS, UC_4_VDS_MAX_DIMS)) < 0) UC_ERROR start[0] = 0; start[1] = 0; start[2] = 0; - if(H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, - UC_4_SOURCE_MAX_DIMS, count, UC_4_SOURCE_MAX_DIMS) < 0) + if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, UC_4_SOURCE_MAX_DIMS, count, + UC_4_SOURCE_MAX_DIMS) < 0) UC_ERROR /* Add VDS mapping - The mapped file name uses a printf-like * naming scheme that automatically maps new files. */ - if(H5Pset_virtual(vds_dcplid, vds_sid, UC_4_MAPPING_FILE_NAME, - UC_4_SOURCE_DSET_PATH, src_sid) < 0) + if (H5Pset_virtual(vds_dcplid, vds_sid, UC_4_MAPPING_FILE_NAME, UC_4_SOURCE_DSET_PATH, src_sid) < 0) UC_ERROR /* Create dataset */ - if((did = H5Dcreate2(fid, UC_4_VDS_DSET_NAME, UC_4_VDS_DATATYPE, vds_sid, - H5P_DEFAULT, vds_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_4_VDS_DSET_NAME, UC_4_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid, + H5P_DEFAULT)) < 0) UC_ERROR /* close */ - if(H5Sclose(src_sid) < 0) + if (H5Sclose(src_sid) < 0) UC_ERROR - if(H5Pclose(vds_dcplid) < 0) + if (H5Pclose(vds_dcplid) < 0) UC_ERROR - if(H5Sclose(vds_sid) < 0) + if (H5Sclose(vds_sid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR return EXIT_SUCCESS; error: - H5E_BEGIN_TRY { - if(src_sid >= 0) + H5E_BEGIN_TRY + { + if (src_sid >= 0) (void)H5Sclose(src_sid); - if(src_dcplid >= 0) + if (src_dcplid >= 0) (void)H5Pclose(src_dcplid); - if(vds_sid >= 0) + if (vds_sid >= 0) (void)H5Sclose(vds_sid); - if(vds_dcplid >= 0) + if (vds_dcplid >= 0) (void)H5Pclose(vds_dcplid); - if(fid >= 0) + if (fid >= 0) (void)H5Fclose(fid); - if(did >= 0) + if (did >= 0) (void)H5Dclose(did); - if(msid >= 0) + if (msid >= 0) (void)H5Sclose(msid); - if(fsid >= 0) + if (fsid >= 0) (void)H5Sclose(fsid); - if(buffer != NULL) + if (buffer != NULL) free(buffer); - } H5E_END_TRY + } + H5E_END_TRY return EXIT_FAILURE; } /* end main() */ - diff --git a/tools/test/misc/vds/UC_5.h b/tools/test/misc/vds/UC_5.h index 3f8fe41..a81960f 100644 --- a/tools/test/misc/vds/UC_5.h +++ b/tools/test/misc/vds/UC_5.h @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -28,20 +28,20 @@ /* virtual dataset <---> source dataset mapping and sizes */ -#define UC_5_N_SOURCES 3 +#define UC_5_N_SOURCES 3 /* Dataset dimensions */ -#define UC_5_SRC_PLANES 3 -#define UC_5_HEIGHT 4 -#define UC_5_WIDTH 4 +#define UC_5_SRC_PLANES 3 +#define UC_5_HEIGHT 4 +#define UC_5_WIDTH 4 /* max number of planes for datasets */ -#define UC_5_MAX_PLANES H5S_UNLIMITED -#define UC_5_N_TEST_PLANES 9 /* number of planes in VDS */ +#define UC_5_MAX_PLANES H5S_UNLIMITED +#define UC_5_N_TEST_PLANES 9 /* number of planes in VDS */ /* Dataset datatypes */ -#define UC_5_SOURCE_DATATYPE H5T_STD_I32LE -#define UC_5_VDS_DATATYPE H5T_STD_I32LE +#define UC_5_SOURCE_DATATYPE H5T_STD_I32LE +#define UC_5_VDS_DATATYPE H5T_STD_I32LE /* Starting size of datasets, both source and VDS */ static hsize_t UC_5_SOURCE_DIMS[RANK] = {0, UC_5_HEIGHT, UC_5_WIDTH}; @@ -55,11 +55,7 @@ static hsize_t UC_5_VDS_MAX_DIMS[RANK] = {UC_5_MAX_PLANES, UC_5_HEIGHT, UC_5_ static hsize_t UC_5_PLANE[RANK] = {1, UC_5_HEIGHT, UC_5_WIDTH}; /* File names for source datasets */ -static char UC_5_FILE_NAMES[UC_5_N_SOURCES][NAME_LEN] = { - {"5_a.h5"}, - {"5_b.h5"}, - {"5_c.h5"} -}; +static char UC_5_FILE_NAMES[UC_5_N_SOURCES][NAME_LEN] = {{"5_a.h5"}, {"5_b.h5"}, {"5_c.h5"}}; /* VDS file name */ static char UC_5_VDS_FILE_NAME[NAME_LEN] = "5_vds.h5"; @@ -70,12 +66,7 @@ static char UC_5_SOURCE_DSET_PATH[NAME_LEN] = "/source_dset"; static char UC_5_VDS_DSET_NAME[NAME_LEN] = "vds_dset"; /* Fill values */ -static int UC_5_FILL_VALUES[UC_5_N_SOURCES] = { - -1, - -2, - -3 -}; -static int UC_5_VDS_FILL_VALUE = -9; +static int UC_5_FILL_VALUES[UC_5_N_SOURCES] = {-1, -2, -3}; +static int UC_5_VDS_FILL_VALUE = -9; #endif /* UC_5_H */ - diff --git a/tools/test/misc/vds/UC_5_stride_gen.c b/tools/test/misc/vds/UC_5_stride_gen.c index a105bbd..d4ba139 100644 --- a/tools/test/misc/vds/UC_5_stride_gen.c +++ b/tools/test/misc/vds/UC_5_stride_gen.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,31 +27,31 @@ int main(void) { - hid_t src_sid = -1; /* source dataset's dataspace ID */ - hid_t src_dcplid = -1; /* source dataset property list ID */ + hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */ + hid_t src_dcplid = H5I_INVALID_HID; /* source dataset property list ID */ - hid_t vds_sid = -1; /* VDS dataspace ID */ - hid_t vds_dcplid = -1; /* VDS dataset property list ID */ + hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */ + hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */ - hid_t fid = -1; /* HDF5 file ID */ - hid_t did = -1; /* dataset ID */ - hid_t msid = -1; /* memory dataspace ID */ - hid_t fsid = -1; /* file dataspace ID */ + hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ + hid_t did = H5I_INVALID_HID; /* dataset ID */ + hid_t msid = H5I_INVALID_HID; /* memory dataspace ID */ + hid_t fsid = H5I_INVALID_HID; /* file dataspace ID */ - hsize_t extent[RANK]; /* source dataset extents */ - hsize_t start[RANK]; /* starting point for hyperslab */ - hsize_t stride[RANK]; /* hypserslab stride */ - hsize_t count[RANK]; /* hypserslab count */ - hsize_t map_start = 0; /* starting point in the VDS map */ + hsize_t extent[RANK]; /* source dataset extents */ + hsize_t start[RANK]; /* starting point for hyperslab */ + hsize_t stride[RANK]; /* hypserslab stride */ + hsize_t count[RANK]; /* hypserslab count */ + hsize_t map_start = 0; /* starting point in the VDS map */ - int *buffer = NULL; /* data buffer */ - int value = -1; /* value written to datasets */ + int *buffer = NULL; /* data buffer */ + int value = -1; /* value written to datasets */ - hsize_t n = 0; /* number of elements in a plane */ + hsize_t n = 0; /* number of elements in a plane */ - int i; /* iterator */ - int j; /* iterator */ - hsize_t k; /* iterator */ + int i; /* iterator */ + int j; /* iterator */ + hsize_t k; /* iterator */ /* Start by creating the virtual dataset (VDS) dataspace and creation * property list. The individual source datasets are then created @@ -59,15 +59,13 @@ main(void) */ /* Create VDS dcpl */ - if((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_fill_value(vds_dcplid, UC_5_VDS_DATATYPE, - &UC_5_VDS_FILL_VALUE) < 0) + if (H5Pset_fill_value(vds_dcplid, UC_5_VDS_DATATYPE, &UC_5_VDS_FILL_VALUE) < 0) UC_ERROR /* Create VDS dataspace */ - if((vds_sid = H5Screate_simple(RANK, UC_5_VDS_DIMS, - UC_5_VDS_MAX_DIMS)) < 0) + if ((vds_sid = H5Screate_simple(RANK, UC_5_VDS_DIMS, UC_5_VDS_MAX_DIMS)) < 0) UC_ERROR /********************************* @@ -75,9 +73,9 @@ main(void) *********************************/ /* Hyperslab array setup */ - start[0] = 0; - start[1] = 0; - start[2] = 0; + start[0] = 0; + start[1] = 0; + start[2] = 0; map_start = 0; stride[0] = UC_5_N_SOURCES; @@ -92,61 +90,57 @@ main(void) extent[1] = UC_5_HEIGHT; extent[2] = UC_5_WIDTH; - for(i = 0; i < UC_5_N_SOURCES; i++) { + for (i = 0; i < UC_5_N_SOURCES; i++) { /* source dataset dcpl */ - if((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_chunk(src_dcplid, RANK, UC_5_PLANE) < 0) + if (H5Pset_chunk(src_dcplid, RANK, UC_5_PLANE) < 0) UC_ERROR - if(H5Pset_fill_value(src_dcplid, UC_5_SOURCE_DATATYPE, - &UC_5_FILL_VALUES[i]) < 0) + if (H5Pset_fill_value(src_dcplid, UC_5_SOURCE_DATATYPE, &UC_5_FILL_VALUES[i]) < 0) UC_ERROR - if(H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0) + if (H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0) UC_ERROR /* Create source file, dataspace, and dataset */ - if((fid = H5Fcreate(UC_5_FILE_NAMES[i], H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_5_FILE_NAMES[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR - if((src_sid = H5Screate_simple(RANK, UC_5_SOURCE_DIMS, - UC_5_SOURCE_MAX_DIMS)) < 0) + if ((src_sid = H5Screate_simple(RANK, UC_5_SOURCE_DIMS, UC_5_SOURCE_MAX_DIMS)) < 0) UC_ERROR - if((did = H5Dcreate2(fid, UC_5_SOURCE_DSET_NAME, - UC_5_SOURCE_DATATYPE, src_sid, - H5P_DEFAULT, src_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_5_SOURCE_DSET_NAME, UC_5_SOURCE_DATATYPE, src_sid, H5P_DEFAULT, + src_dcplid, H5P_DEFAULT)) < 0) UC_ERROR /* Set the dataset's extent */ - if(H5Dset_extent(did, extent) < 0) + if (H5Dset_extent(did, extent) < 0) UC_ERROR /* Create a data buffer that represents a plane */ n = UC_5_PLANE[1] * UC_5_PLANE[2]; - if(NULL == (buffer = (int *)malloc(n * sizeof(int)))) + if (NULL == (buffer = (int *)malloc(n * sizeof(int)))) UC_ERROR /* Create the memory dataspace */ - if((msid = H5Screate_simple(RANK, UC_5_PLANE, NULL)) < 0) + if ((msid = H5Screate_simple(RANK, UC_5_PLANE, NULL)) < 0) UC_ERROR /* Get the file dataspace */ - if((fsid = H5Dget_space(did)) < 0) + if ((fsid = H5Dget_space(did)) < 0) UC_ERROR /* Write planes to the dataset */ - for(j = 0; j < UC_5_SRC_PLANES; j++) { + for (j = 0; j < UC_5_SRC_PLANES; j++) { value = ((i + 1) * 10) + j; - for(k = 0; k < n; k++) - buffer[k] = value; + for (k = 0; k < n; k++) + buffer[k] = value; start[0] = (hsize_t)j; start[1] = 0; start[2] = 0; - if(H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_5_PLANE, NULL) < 0) + if (H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_5_PLANE, NULL) < 0) UC_ERROR - if(H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) UC_ERROR } /* end for */ @@ -155,32 +149,29 @@ main(void) start[0] = 0; start[1] = 0; start[2] = 0; - if(H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, - UC_5_SOURCE_MAX_DIMS, NULL) < 0) + if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_5_SOURCE_MAX_DIMS, NULL) < 0) UC_ERROR start[0] = map_start; - if(H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, stride, - count, UC_5_PLANE) < 0) + if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, stride, count, UC_5_PLANE) < 0) UC_ERROR map_start += 1; /* Add VDS mapping */ - if(H5Pset_virtual(vds_dcplid, vds_sid, UC_5_FILE_NAMES[i], - UC_5_SOURCE_DSET_PATH, src_sid) < 0) + if (H5Pset_virtual(vds_dcplid, vds_sid, UC_5_FILE_NAMES[i], UC_5_SOURCE_DSET_PATH, src_sid) < 0) UC_ERROR /* close */ - if(H5Sclose(msid) < 0) + if (H5Sclose(msid) < 0) UC_ERROR - if(H5Sclose(fsid) < 0) + if (H5Sclose(fsid) < 0) UC_ERROR - if(H5Sclose(src_sid) < 0) + if (H5Sclose(src_sid) < 0) UC_ERROR - if(H5Pclose(src_dcplid) < 0) + if (H5Pclose(src_dcplid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR free(buffer); @@ -191,51 +182,51 @@ main(void) *******************/ /* file */ - if((fid = H5Fcreate(UC_5_VDS_FILE_NAME, H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_5_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR /* dataset */ - if((did = H5Dcreate2(fid, UC_5_VDS_DSET_NAME, UC_5_VDS_DATATYPE, vds_sid, - H5P_DEFAULT, vds_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_5_VDS_DSET_NAME, UC_5_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid, + H5P_DEFAULT)) < 0) UC_ERROR /* close */ - if(H5Pclose(vds_dcplid) < 0) + if (H5Pclose(vds_dcplid) < 0) UC_ERROR - if(H5Sclose(vds_sid) < 0) + if (H5Sclose(vds_sid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR return EXIT_SUCCESS; error: - H5E_BEGIN_TRY { - if(src_sid >= 0) + H5E_BEGIN_TRY + { + if (src_sid >= 0) (void)H5Sclose(src_sid); - if(src_dcplid >= 0) + if (src_dcplid >= 0) (void)H5Pclose(src_dcplid); - if(vds_sid >= 0) + if (vds_sid >= 0) (void)H5Sclose(vds_sid); - if(vds_dcplid >= 0) + if (vds_dcplid >= 0) (void)H5Pclose(vds_dcplid); - if(fid >= 0) + if (fid >= 0) (void)H5Fclose(fid); - if(did >= 0) + if (did >= 0) (void)H5Dclose(did); - if(msid >= 0) + if (msid >= 0) (void)H5Sclose(msid); - if(fsid >= 0) + if (fsid >= 0) (void)H5Sclose(fsid); - if(buffer != NULL) + if (buffer != NULL) free(buffer); - } H5E_END_TRY + } + H5E_END_TRY return EXIT_FAILURE; } /* end main() */ - diff --git a/tools/test/misc/vds/UC_common.h b/tools/test/misc/vds/UC_common.h index 78d8a11..d84d545 100644 --- a/tools/test/misc/vds/UC_common.h +++ b/tools/test/misc/vds/UC_common.h @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,35 +14,31 @@ #ifndef USE_CASE_COMMON_H #define USE_CASE_COMMON_H -/* Use FUNC to safely handle variations of C99 __func__ keyword handling */ -#ifdef H5_HAVE_C99_FUNC -#define FUNC __func__ -#elif defined(H5_HAVE_FUNCTION) -#define FUNC __FUNCTION__ -#else -#error "We need __func__ or __FUNCTION__ to test function names!" -#endif - /****************************************** * Symbols used across multiple use cases * ******************************************/ /* All datasets are 3D */ -#define RANK 3 +#define RANK 3 /* Lengths of string identifiers (file, dataset names, etc.) */ -#define NAME_LEN 32 +#define NAME_LEN 32 /* Compression level */ -#define COMPRESSION_LEVEL 7 +#define COMPRESSION_LEVEL 7 /* Booleans */ -#define TRUE 1 +#define TRUE 1 #define FALSE 0 /* Testing macros */ -#define AT() printf (" at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); -#define UC_ERROR {puts("*ERROR*"); fflush(stdout); AT(); goto error;} +#define AT() printf(" at %s:%d in %s()...\n", __FILE__, __LINE__, __func__); +#define UC_ERROR \ + { \ + puts("*ERROR*"); \ + fflush(stdout); \ + AT(); \ + goto error; \ + } #endif /* USE_CASE_COMMON_H */ - diff --git a/tools/test/perform/CMakeLists.txt b/tools/test/perform/CMakeLists.txt index 38dd605..7bf79c5 100644 --- a/tools/test/perform/CMakeLists.txt +++ b/tools/test/perform/CMakeLists.txt @@ -1,45 +1,36 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_TOOLS_TEST_PERFORM C) # -------------------------------------------------------------------- # Add the executables # -------------------------------------------------------------------- -#-- Adding test for h5perf_serial -set (h5perf_serial_SOURCES - ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/sio_perf.c - ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/sio_engine.c -) -add_executable (h5perf_serial ${h5perf_serial_SOURCES}) -target_include_directories (h5perf_serial PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") -if (NOT BUILD_SHARED_LIBS) - TARGET_C_PROPERTIES (h5perf_serial STATIC) - target_link_libraries (h5perf_serial PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) -else () - TARGET_C_PROPERTIES (h5perf_serial SHARED) - target_link_libraries (h5perf_serial PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) -endif () -set_target_properties (h5perf_serial PROPERTIES FOLDER perform) if (HDF5_BUILD_PERFORM_STANDALONE) - #-- Adding test for h5perf_serial_alone + #-- Adding test for h5perf_serial_alone - io_timer.c includes set (h5perf_serial_alone_SOURCES - ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/sio_perf.c - ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/sio_engine.c + ${HDF5_TOOLS_DIR}/lib/io_timer.c + ${HDF5_TOOLS_SRC_H5PERF_SOURCE_DIR}/sio_perf.c + ${HDF5_TOOLS_SRC_H5PERF_SOURCE_DIR}/sio_engine.c ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/sio_standalone.c ) add_executable (h5perf_serial_alone ${h5perf_serial_alone_SOURCES}) - target_include_directories (h5perf_serial_alone PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (h5perf_serial_alone PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};${HDF5_TOOLS_DIR}/lib;${HDF5_TOOLS_SRC_H5PERF_SOURCE_DIR};${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (h5perf_serial_alone STATIC) - target_link_libraries (h5perf_serial_alone PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) + target_link_libraries (h5perf_serial_alone PRIVATE ${HDF5_LIB_TARGET} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>") else () TARGET_C_PROPERTIES (h5perf_serial_alone SHARED) - target_link_libraries (h5perf_serial_alone PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + target_link_libraries (h5perf_serial_alone PRIVATE ${HDF5_LIBSH_TARGET} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>") endif () set_target_properties (h5perf_serial_alone PROPERTIES FOLDER perform) - set_property (TARGET h5perf_serial_alone - APPEND PROPERTY COMPILE_DEFINITIONS STANDALONE - ) + set_property (TARGET h5perf_serial_alone APPEND PROPERTY COMPILE_DEFINITIONS STANDALONE) + + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_PERFORM_h5perf_serial_alone_FORMAT h5perf_serial_alone) + endif () endif () #-- Adding test for chunk @@ -47,7 +38,7 @@ set (chunk_SOURCES ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/chunk.c ) add_executable(chunk ${chunk_SOURCES}) -target_include_directories (chunk PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +target_include_directories (chunk PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (chunk STATIC) target_link_libraries (chunk PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) @@ -57,12 +48,19 @@ else () endif () set_target_properties (chunk PROPERTIES FOLDER perform) +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_PERFORM_chunk_FORMAT chunk) +endif () + #-- Adding test for iopipe set (iopipe_SOURCES ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/iopipe.c ) add_executable (iopipe ${iopipe_SOURCES}) -target_include_directories (iopipe PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +target_include_directories (iopipe PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (iopipe STATIC) target_link_libraries (iopipe PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) @@ -72,12 +70,19 @@ else () endif () set_target_properties (iopipe PROPERTIES FOLDER perform) +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_PERFORM_iopipe_FORMAT iopipe) +endif () + #-- Adding test for chunk_cache set (chunk_cache_SOURCES ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/chunk_cache.c ) add_executable (chunk_cache ${chunk_cache_SOURCES}) -target_include_directories (chunk_cache PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +target_include_directories (chunk_cache PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (chunk_cache STATIC) target_link_libraries (chunk_cache PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) @@ -87,12 +92,19 @@ else () endif () set_target_properties (chunk_cache PROPERTIES FOLDER perform) +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_PERFORM_chunk_cache_FORMAT chunk_cache) +endif () + #-- Adding test for overhead set (overhead_SOURCES ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/overhead.c ) add_executable (overhead ${overhead_SOURCES}) -target_include_directories (overhead PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +target_include_directories (overhead PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (overhead STATIC) target_link_libraries (overhead PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) @@ -102,12 +114,19 @@ else () endif () set_target_properties (overhead PROPERTIES FOLDER perform) +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_PERFORM_overhead_FORMAT overhead) +endif () + #-- Adding test for perf_meta set (perf_meta_SOURCES ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/perf_meta.c ) add_executable (perf_meta ${perf_meta_SOURCES}) -target_include_directories (perf_meta PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +target_include_directories (perf_meta PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (perf_meta STATIC) target_link_libraries (perf_meta PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) @@ -117,12 +136,19 @@ else () endif () set_target_properties (perf_meta PROPERTIES FOLDER perform) +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_PERFORM_perf_meta_FORMAT perf_meta) +endif () + #-- Adding test for zip_perf set (zip_perf_SOURCES ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/zip_perf.c ) add_executable (zip_perf ${zip_perf_SOURCES}) -target_include_directories (zip_perf PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +target_include_directories (zip_perf PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (zip_perf STATIC) target_link_libraries (zip_perf PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET} ${LINK_COMP_LIBS}) @@ -132,61 +158,45 @@ else () endif () set_target_properties (zip_perf PROPERTIES FOLDER perform) -if (H5_HAVE_PARALLEL AND BUILD_TESTING) - if (UNIX) - #-- Adding test for perf - only on unix systems - set (perf_SOURCES - ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/perf.c - ) - add_executable (perf ${perf_SOURCES}) - target_include_directories (perf PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") - if (NOT BUILD_SHARED_LIBS) - TARGET_C_PROPERTIES (perf STATIC) - target_link_libraries (perf PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) - else () - TARGET_C_PROPERTIES (perf SHARED) - target_link_libraries (perf PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) - endif () - set_target_properties (perf PROPERTIES FOLDER perform) - endif () - - #-- Adding test for h5perf - set (h5perf_SOURCES - ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/pio_perf.c - ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/pio_engine.c - ) - add_executable (h5perf ${h5perf_SOURCES}) - target_include_directories (h5perf PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") - if (NOT BUILD_SHARED_LIBS) - TARGET_C_PROPERTIES (h5perf STATIC) - target_link_libraries (h5perf PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) - else () - TARGET_C_PROPERTIES (h5perf SHARED) - target_link_libraries (h5perf PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) - endif () - set_target_properties (h5perf PROPERTIES FOLDER perform) +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_PERFORM_zip_perf_FORMAT zip_perf) +endif () +if (H5_HAVE_PARALLEL AND HDF5_TEST_PARALLEL) if (HDF5_BUILD_PERFORM_STANDALONE) #-- Adding test for h5perf set (h5perf_alone_SOURCES - ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/pio_perf.c - ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/pio_engine.c + ${HDF5_TOOLS_DIR}/lib/io_timer.c + ${HDF5_TOOLS_SRC_H5PERF_SOURCE_DIR}/pio_perf.c + ${HDF5_TOOLS_SRC_H5PERF_SOURCE_DIR}/pio_engine.c ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/pio_standalone.c ) add_executable (h5perf_alone ${h5perf_alone_SOURCES}) - target_include_directories (h5perf_alone PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (h5perf_alone PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};${HDF5_TOOLS_DIR}/lib;${HDF5_TOOLS_SRC_H5PERF_SOURCE_DIR};${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (h5perf_alone STATIC) - target_link_libraries (h5perf_alone PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) + target_link_libraries (h5perf_alone PRIVATE ${HDF5_LIB_TARGET} ${LINK_LIBS} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>") else () TARGET_C_PROPERTIES (h5perf_alone SHARED) - target_link_libraries (h5perf_alone PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + target_link_libraries (h5perf_alone PRIVATE ${HDF5_LIBSH_TARGET} ${LINK_LIBS} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>") endif () set_target_properties (h5perf_alone PROPERTIES FOLDER perform) set_property (TARGET h5perf_alone APPEND PROPERTY COMPILE_DEFINITIONS STANDALONE ) + + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_PERFORM_h5perf_alone_FORMAT h5perf_alone) + endif () endif () endif () -include (CMakeTests.cmake) +if (HDF5_TEST_TOOLS) + include (CMakeTests.cmake) +endif () diff --git a/tools/test/perform/CMakeTests.cmake b/tools/test/perform/CMakeTests.cmake index f0ae416..73b2260 100644 --- a/tools/test/perform/CMakeTests.cmake +++ b/tools/test/perform/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. # @@ -22,175 +22,176 @@ add_custom_target(zip_perf_files ALL COMMENT "Copying files needed by zip_perf t #----------------------------------------------------------------------------- # Add Tests #----------------------------------------------------------------------------- +if (HDF5_TEST_SERIAL) + # Remove any output file left over from previous test run + add_test ( + NAME PERFORM_h5perform-clearall-objects + COMMAND ${CMAKE_COMMAND} + -E remove + chunk.h5 + iopipe.h5 + iopipe.raw + x-diag-rd.dat + x-diag-wr.dat + x-rowmaj-rd.dat + x-rowmaj-wr.dat + x-gnuplot + h5perf_serial.txt + h5perf_serial.txt.err + chunk.txt + chunk.txt.err + iopipe.txt + iopipe.txt.err + overhead.txt + overhead.txt.err + perf_meta.txt + perf_meta.txt.err + zip_perf-h.txt + zip_perf-h.txt.err + zip_perf.txt + zip_perf.txt.err + ) -# Remove any output file left over from previous test run -add_test ( - NAME PERFORM_h5perform-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - chunk.h5 - iopipe.h5 - iopipe.raw - x-diag-rd.dat - x-diag-wr.dat - x-rowmaj-rd.dat - x-rowmaj-wr.dat - x-gnuplot - h5perf_serial.txt - h5perf_serial.txt.err - chunk.txt - chunk.txt.err - iopipe.txt - iopipe.txt.err - overhead.txt - overhead.txt.err - perf_meta.txt - perf_meta.txt.err - zip_perf-h.txt - zip_perf-h.txt.err - zip_perf.txt - zip_perf.txt.err -) - -if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PERFORM_h5perf_serial COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5perf_serial>) -else () - add_test (NAME PERFORM_h5perf_serial COMMAND "${CMAKE_COMMAND}" - -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5perf_serial>" - -D "TEST_ARGS:STRING=" - -D "TEST_EXPECT=0" - -D "TEST_SKIP_COMPARE=TRUE" - -D "TEST_OUTPUT=h5perf_serial.txt" - #-D "TEST_REFERENCE=h5perf_serial.out" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME PERFORM_h5perf_serial COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5perf_serial>) + else () + add_test (NAME PERFORM_h5perf_serial COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5perf_serial>" + -D "TEST_ARGS:STRING=" + -D "TEST_EXPECT=0" + -D "TEST_SKIP_COMPARE=TRUE" + -D "TEST_OUTPUT=h5perf_serial.txt" + #-D "TEST_REFERENCE=h5perf_serial.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + endif () + set_tests_properties (PERFORM_h5perf_serial PROPERTIES + TIMEOUT ${CTEST_VERY_LONG_TIMEOUT} + DEPENDS "PERFORM_h5perform-clearall-objects" ) -endif () -set_tests_properties (PERFORM_h5perf_serial PROPERTIES - TIMEOUT ${CTEST_VERY_LONG_TIMEOUT} - DEPENDS "PERFORM_h5perform-clearall-objects" -) -if (HDF5_BUILD_PERFORM_STANDALONE) - add_test (NAME PERFORM_h5perf_serial_alone COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5perf_serial_alone>) -endif () + if (HDF5_BUILD_PERFORM_STANDALONE) + add_test (NAME PERFORM_h5perf_serial_alone COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5perf_serial_alone>) + endif () -if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PERFORM_chunk COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:chunk>) -else () - add_test (NAME PERFORM_chunk COMMAND "${CMAKE_COMMAND}" - -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:chunk>" - -D "TEST_ARGS:STRING=" - -D "TEST_EXPECT=0" - -D "TEST_SKIP_COMPARE=TRUE" - -D "TEST_OUTPUT=chunk.txt" - #-D "TEST_REFERENCE=chunk.out" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME PERFORM_chunk COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:chunk>) + else () + add_test (NAME PERFORM_chunk COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:chunk>" + -D "TEST_ARGS:STRING=" + -D "TEST_EXPECT=0" + -D "TEST_SKIP_COMPARE=TRUE" + -D "TEST_OUTPUT=chunk.txt" + #-D "TEST_REFERENCE=chunk.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + endif () + set_tests_properties (PERFORM_chunk PROPERTIES + DEPENDS "PERFORM_h5perform-clearall-objects" ) -endif () -set_tests_properties (PERFORM_chunk PROPERTIES - DEPENDS "PERFORM_h5perform-clearall-objects" -) -if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PERFORM_iopipe COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:iopipe>) -else () - add_test (NAME PERFORM_iopipe COMMAND "${CMAKE_COMMAND}" - -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:iopipe>" - -D "TEST_ARGS:STRING=" - -D "TEST_EXPECT=0" - -D "TEST_SKIP_COMPARE=TRUE" - -D "TEST_OUTPUT=iopipe.txt" - #-D "TEST_REFERENCE=iopipe.out" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME PERFORM_iopipe COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:iopipe>) + else () + add_test (NAME PERFORM_iopipe COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:iopipe>" + -D "TEST_ARGS:STRING=" + -D "TEST_EXPECT=0" + -D "TEST_SKIP_COMPARE=TRUE" + -D "TEST_OUTPUT=iopipe.txt" + #-D "TEST_REFERENCE=iopipe.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + endif () + set_tests_properties (PERFORM_iopipe PROPERTIES + DEPENDS "PERFORM_h5perform-clearall-objects" ) -endif () -set_tests_properties (PERFORM_iopipe PROPERTIES - DEPENDS "PERFORM_h5perform-clearall-objects" -) -if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PERFORM_overhead COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:overhead>) -else () - add_test (NAME PERFORM_overhead COMMAND "${CMAKE_COMMAND}" - -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:overhead>" - -D "TEST_ARGS:STRING=" - -D "TEST_EXPECT=0" - -D "TEST_SKIP_COMPARE=TRUE" - -D "TEST_OUTPUT=overhead.txt" - #-D "TEST_REFERENCE=overhead.out" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME PERFORM_overhead COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:overhead>) + else () + add_test (NAME PERFORM_overhead COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:overhead>" + -D "TEST_ARGS:STRING=" + -D "TEST_EXPECT=0" + -D "TEST_SKIP_COMPARE=TRUE" + -D "TEST_OUTPUT=overhead.txt" + #-D "TEST_REFERENCE=overhead.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + endif () + set_tests_properties (PERFORM_overhead PROPERTIES + DEPENDS "PERFORM_h5perform-clearall-objects" ) -endif () -set_tests_properties (PERFORM_overhead PROPERTIES - DEPENDS "PERFORM_h5perform-clearall-objects" -) -if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PERFORM_perf_meta COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:perf_meta>) -else () - add_test (NAME PERFORM_perf_meta COMMAND "${CMAKE_COMMAND}" - -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:perf_meta>" - -D "TEST_ARGS:STRING=" - -D "TEST_EXPECT=0" - -D "TEST_SKIP_COMPARE=TRUE" - -D "TEST_OUTPUT=perf_meta.txt" - #-D "TEST_REFERENCE=perf_meta.out" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME PERFORM_perf_meta COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:perf_meta>) + else () + add_test (NAME PERFORM_perf_meta COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:perf_meta>" + -D "TEST_ARGS:STRING=" + -D "TEST_EXPECT=0" + -D "TEST_SKIP_COMPARE=TRUE" + -D "TEST_OUTPUT=perf_meta.txt" + #-D "TEST_REFERENCE=perf_meta.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + endif () + set_tests_properties (PERFORM_perf_meta PROPERTIES + DEPENDS "PERFORM_h5perform-clearall-objects" ) -endif () -set_tests_properties (PERFORM_perf_meta PROPERTIES - DEPENDS "PERFORM_h5perform-clearall-objects" -) -if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PERFORM_zip_perf_help COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:zip_perf> "-h") -else () - add_test (NAME PERFORM_zip_perf_help COMMAND "${CMAKE_COMMAND}" - -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:zip_perf>" - -D "TEST_ARGS:STRING=" - -D "TEST_EXPECT=0" - -D "TEST_SKIP_COMPARE=TRUE" - -D "TEST_OUTPUT=zip_perf-h.txt" - #-D "TEST_REFERENCE=zip_perf-h.out" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME PERFORM_zip_perf_help COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:zip_perf> "-h") + else () + add_test (NAME PERFORM_zip_perf_help COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:zip_perf>" + -D "TEST_ARGS:STRING=" + -D "TEST_EXPECT=0" + -D "TEST_SKIP_COMPARE=TRUE" + -D "TEST_OUTPUT=zip_perf-h.txt" + #-D "TEST_REFERENCE=zip_perf-h.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + endif () + set_tests_properties (PERFORM_zip_perf_help PROPERTIES + DEPENDS "PERFORM_h5perform-clearall-objects" ) -endif () -set_tests_properties (PERFORM_zip_perf_help PROPERTIES - DEPENDS "PERFORM_h5perform-clearall-objects" -) -if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PERFORM_zip_perf COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:zip_perf> tfilters.h5) -else () - add_test (NAME PERFORM_zip_perf COMMAND "${CMAKE_COMMAND}" - -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$<TARGET_FILE:zip_perf>" - -D "TEST_ARGS:STRING=" - -D "TEST_EXPECT=0" - -D "TEST_SKIP_COMPARE=TRUE" - -D "TEST_OUTPUT=zip_perf.txt" - #-D "TEST_REFERENCE=zip_perf.out" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME PERFORM_zip_perf COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:zip_perf> tfilters.h5) + else () + add_test (NAME PERFORM_zip_perf COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:zip_perf>" + -D "TEST_ARGS:STRING=" + -D "TEST_EXPECT=0" + -D "TEST_SKIP_COMPARE=TRUE" + -D "TEST_OUTPUT=zip_perf.txt" + #-D "TEST_REFERENCE=zip_perf.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + endif () + set_tests_properties (PERFORM_zip_perf PROPERTIES + DEPENDS "PERFORM_zip_perf_help;PERFORM_h5perform-clearall-objects" ) endif () -set_tests_properties (PERFORM_zip_perf PROPERTIES - DEPENDS "PERFORM_zip_perf_help;PERFORM_h5perform-clearall-objects" -) -if (H5_HAVE_PARALLEL) +if (H5_HAVE_PARALLEL AND HDF5_TEST_PARALLEL) if (UNIX) add_test (NAME MPI_TEST_PERFORM_perf COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $<TARGET_FILE:perf> ${MPIEXEC_POSTFLAGS}) endif () diff --git a/tools/test/perform/COPYING b/tools/test/perform/COPYING deleted file mode 100644 index 6497ace..0000000 --- a/tools/test/perform/COPYING +++ /dev/null @@ -1,13 +0,0 @@ - - Copyright by The HDF Group and - The Board of Trustees of the University of Illinois. - All rights reserved. - - The files and subdirectories in this directory are 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. If you do - not have access to either file, you may request a copy from - help@hdfgroup.org. - diff --git a/tools/test/perform/Makefile.am b/tools/test/perform/Makefile.am index 39800d7..10b13fe 100644 --- a/tools/test/perform/Makefile.am +++ b/tools/test/perform/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. ## @@ -21,17 +21,6 @@ include $(top_srcdir)/config/commence.am AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib -# bin_PROGRAMS will be installed. -if BUILD_PARALLEL_CONDITIONAL - bin_PROGRAMS=h5perf_serial h5perf -else - bin_PROGRAMS=h5perf_serial -endif - -# Add h5perf and h5perf_serial specific linker flags here -h5perf_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) -h5perf_serial_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) - # Some programs are not built or run by default, but can be built by hand or by # specifying --enable-build-all at configure time. # Also, some of these programs should only be built in parallel. @@ -47,18 +36,15 @@ endif # List them in the order they should be run. # Parallel test programs. if BUILD_PARALLEL_CONDITIONAL - TEST_PROG_PARA=h5perf perf + TEST_PROG_PARA= endif # Serial test programs. -TEST_PROG = iopipe chunk chunk_cache overhead zip_perf perf_meta h5perf_serial $(BUILD_ALL_PROGS) +TEST_PROG = iopipe chunk chunk_cache overhead zip_perf perf_meta $(BUILD_ALL_PROGS) # check_PROGRAMS will be built but not installed. Do not any executable # that is in bin_PROGRAMS already. Otherwise, it will be removed twice in # "make clean" and some systems, e.g., AIX, do not like it. -check_PROGRAMS= iopipe chunk chunk_cache overhead zip_perf perf_meta $(BUILD_ALL_PROGS) perf - -h5perf_SOURCES=pio_perf.c pio_engine.c -h5perf_serial_SOURCES=sio_perf.c sio_engine.c +check_PROGRAMS= $(TEST_PROG) $(BUILD_ALL_PROGS) # These are the files that `make clean' (and derivatives) will remove from # this directory. @@ -67,9 +53,6 @@ CLEANFILES=*.h5 *.raw *.dat x-gnuplot perftest.out # All of the programs depend on the main hdf5 library, and some of them # depend on test or tools library. LDADD=$(LIBHDF5) -h5perf_LDADD=$(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5) -h5perf_serial_LDADD=$(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5) -perf_LDADD=$(LIBH5TEST) $(LIBHDF5) iopipe_LDADD=$(LIBH5TEST) $(LIBHDF5) zip_perf_LDADD=$(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5) perf_meta_LDADD=$(LIBH5TEST) $(LIBHDF5) diff --git a/tools/test/perform/build_h5perf_alone.sh b/tools/test/perform/build_h5perf_alone.sh index 30d272f..95a437b 100644 --- a/tools/test/perform/build_h5perf_alone.sh +++ b/tools/test/perform/build_h5perf_alone.sh @@ -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. # diff --git a/tools/test/perform/build_h5perf_serial_alone.sh b/tools/test/perform/build_h5perf_serial_alone.sh index 099e7f9..d2a0660 100644 --- a/tools/test/perform/build_h5perf_serial_alone.sh +++ b/tools/test/perform/build_h5perf_serial_alone.sh @@ -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. # diff --git a/tools/test/perform/chunk.c b/tools/test/perform/chunk.c index 804f88e..5e2dde2 100644 --- a/tools/test/perform/chunk.c +++ b/tools/test/perform/chunk.c @@ -6,13 +6,13 @@ * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke <robb@arborea.spizella.com> + * Programmer: Robb Matzke * Thursday, May 14, 1998 * * Purpose: Checks the effect of various I/O request sizes and raw data @@ -21,77 +21,71 @@ */ /* See H5private.h for how to include headers */ -#undef NDEBUG #include "hdf5.h" -#ifdef H5_STDC_HEADERS -# include <assert.h> -# include <stdio.h> -# include <stdlib.h> -# include <string.h> -#endif +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> /* Solaris Studio defines attribute, but for the attributes we need */ #if !defined(H5_HAVE_ATTRIBUTE) || defined __cplusplus || defined(__SUNPRO_C) -# undef __attribute__ -# define __attribute__(X) /*void*/ -# define H5_ATTR_UNUSED /*void*/ +#undef __attribute__ +#define __attribute__(X) /*void*/ +#define H5_ATTR_UNUSED /*void*/ #else -# define H5_ATTR_UNUSED __attribute__((unused)) +#define H5_ATTR_UNUSED __attribute__((unused)) #endif -#define FILE_NAME "chunk.h5" -#define LINESPOINTS "lines" -#define CH_SIZE 100 /*squared in terms of bytes */ -#define DS_SIZE 20 /*squared in terms of chunks */ -#define FILTER_COUNTER 305 -#define READ 0 -#define WRITE 1 -#define MIN(X,Y) ((X)<(Y)?(X):(Y)) -#define MAX(X,Y) ((X)>(Y)?(X):(Y)) -#define SQUARE(X) ((X)*(X)) +#define FILE_NAME "chunk.h5" +#define LINESPOINTS "lines" +#define CH_SIZE 100 /*squared in terms of bytes */ +#define DS_SIZE 20 /*squared in terms of chunks */ +#define FILTER_COUNTER 305 +#define READ 0 +#define WRITE 1 +#define MIN(X, Y) ((X) < (Y) ? (X) : (Y)) +#define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) +#define SQUARE(X) ((X) * (X)) /* The row-major test */ -#define RM_CACHE_STRT 25 -#define RM_CACHE_END 25 -#define RM_CACHE_DELT 5 -#define RM_START (double)0.50F -#define RM_END (double)5.00F -#define RM_DELTA (double)0.50F -#define RM_W0 0.0F -#define RM_NRDCC 521 +#define RM_CACHE_STRT 25 +#define RM_CACHE_END 25 +#define RM_CACHE_DELT 5 +#define RM_START 0.50 +#define RM_END 5.00 +#define RM_DELTA 0.50 +#define RM_W0 0.0 +#define RM_NRDCC 521 /* Diagonal test */ -#define DIAG_CACHE_STRT 25 -#define DIAG_CACHE_END 25 -#define DIAG_CACHE_DELT 5 -#define DIAG_START (double)0.50F -#define DIAG_END (double)5.00F -#define DIAG_DELTA (double)0.50F -/* #define DIAG_W0 0.65F */ +#define DIAG_CACHE_STRT 25 +#define DIAG_CACHE_END 25 +#define DIAG_CACHE_DELT 5 +#define DIAG_START 0.50 +#define DIAG_END 5.00 +#define DIAG_DELTA 0.50 +/* #define DIAG_W0 0.65 */ /* #define DIAG_NRDCC 521 */ -static size_t nio_g; -static hid_t fapl_g = -1; +static size_t nio_g; +static hid_t fapl_g = H5I_INVALID_HID; /* Local function prototypes */ -static size_t -counter (unsigned H5_ATTR_UNUSED flags, size_t cd_nelmts, - const unsigned *cd_values, size_t nbytes, - size_t *buf_size, void **buf); +static size_t counter(unsigned H5_ATTR_UNUSED flags, size_t cd_nelmts, const unsigned *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_COUNTER[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - FILTER_COUNTER, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "counter", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - counter, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER_COUNTER, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "counter", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + counter, /* The actual filter function */ }}; - /*------------------------------------------------------------------------- * Function: counter * @@ -109,15 +103,14 @@ const H5Z_class2_t H5Z_COUNTER[1] = {{ *------------------------------------------------------------------------- */ static size_t -counter (unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) +counter(unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, + const unsigned H5_ATTR_UNUSED *cd_values, size_t nbytes, size_t H5_ATTR_UNUSED *buf_size, + void H5_ATTR_UNUSED **buf) { nio_g += nbytes; return nbytes; } - /*------------------------------------------------------------------------- * Function: create_dataset * @@ -136,21 +129,21 @@ counter (unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, *------------------------------------------------------------------------- */ static void -create_dataset (void) +create_dataset(void) { - hid_t file, space, dcpl, dset; - hsize_t size[2]; - signed char *buf; + hid_t file, space, dcpl, dset; + hsize_t size[2]; + signed char *buf; /* The file */ - file = H5Fcreate (FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_g); + file = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_g); /* The data space */ size[0] = size[1] = DS_SIZE * CH_SIZE; - space = H5Screate_simple(2, size, size); + space = H5Screate_simple(2, size, size); /* The storage layout and compression */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); size[0] = size[1] = CH_SIZE; H5Pset_chunk(dcpl, 2, size); H5Zregister(H5Z_COUNTER); @@ -158,10 +151,10 @@ create_dataset (void) /* The dataset */ dset = H5Dcreate2(file, "dset", H5T_NATIVE_SCHAR, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - assert(dset>=0); + assert(dset >= 0); /* The data */ - buf = (signed char *)calloc(1, SQUARE (DS_SIZE*CH_SIZE)); + buf = (signed char *)calloc(1, SQUARE(DS_SIZE * CH_SIZE)); H5Dwrite(dset, H5T_NATIVE_SCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); free(buf); @@ -172,7 +165,6 @@ create_dataset (void) H5Fclose(file); } - /*------------------------------------------------------------------------- * Function: test_rowmaj * @@ -189,64 +181,60 @@ create_dataset (void) *------------------------------------------------------------------------- */ static double -test_rowmaj (int op, size_t cache_size, size_t io_size) +test_rowmaj(int op, size_t cache_size, size_t io_size) { - hid_t file, dset, mem_space, file_space; - signed char *buf = (signed char *)calloc (1, (size_t)(SQUARE(io_size))); - hsize_t i, j, hs_size[2]; - hsize_t hs_offset[2]; - int mdc_nelmts; - size_t rdcc_nelmts; - double w0; - - H5Pget_cache (fapl_g, &mdc_nelmts, &rdcc_nelmts, NULL, &w0); + hid_t file, dset, mem_space, file_space; + signed char *buf = (signed char *)calloc(1, (size_t)(SQUARE(io_size))); + hsize_t i, j, hs_size[2]; + hsize_t hs_offset[2]; + int mdc_nelmts; + size_t rdcc_nelmts; + double w0; + + H5Pget_cache(fapl_g, &mdc_nelmts, &rdcc_nelmts, NULL, &w0); #ifdef RM_W0 w0 = RM_W0; #endif #ifdef RM_NRDCC rdcc_nelmts = RM_NRDCC; #endif - H5Pset_cache (fapl_g, mdc_nelmts, rdcc_nelmts, - cache_size*SQUARE (CH_SIZE), w0); - file = H5Fopen(FILE_NAME, H5F_ACC_RDWR, fapl_g); - dset = H5Dopen2(file, "dset", H5P_DEFAULT); + H5Pset_cache(fapl_g, mdc_nelmts, rdcc_nelmts, cache_size * SQUARE(CH_SIZE), w0); + file = H5Fopen(FILE_NAME, H5F_ACC_RDWR, fapl_g); + dset = H5Dopen2(file, "dset", H5P_DEFAULT); file_space = H5Dget_space(dset); - nio_g = 0; + nio_g = 0; - for (i=0; i<CH_SIZE*DS_SIZE; i+=io_size) { + for (i = 0; i < CH_SIZE * DS_SIZE; i += io_size) { #if 0 fprintf (stderr, "%5d\b\b\b\b\b", (int)i); fflush (stderr); #endif - for (j=0; j<CH_SIZE*DS_SIZE; j+=io_size) { - hs_offset[0] = i; - hs_size[0] = MIN (io_size, CH_SIZE*DS_SIZE-i); - hs_offset[1] = j; - hs_size[1] = MIN (io_size, CH_SIZE*DS_SIZE-j); - mem_space = H5Screate_simple (2, hs_size, hs_size); - H5Sselect_hyperslab (file_space, H5S_SELECT_SET, hs_offset, - NULL, hs_size, NULL); - - if (READ==op) { - H5Dread (dset, H5T_NATIVE_SCHAR, mem_space, file_space, - H5P_DEFAULT, buf); - } else { - H5Dwrite (dset, H5T_NATIVE_SCHAR, mem_space, file_space, - H5P_DEFAULT, buf); - } - H5Sclose (mem_space); - } + for (j = 0; j < CH_SIZE * DS_SIZE; j += io_size) { + hs_offset[0] = i; + hs_size[0] = MIN(io_size, CH_SIZE * DS_SIZE - i); + hs_offset[1] = j; + hs_size[1] = MIN(io_size, CH_SIZE * DS_SIZE - j); + mem_space = H5Screate_simple(2, hs_size, hs_size); + H5Sselect_hyperslab(file_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL); + + if (READ == op) { + H5Dread(dset, H5T_NATIVE_SCHAR, mem_space, file_space, H5P_DEFAULT, buf); + } + else { + H5Dwrite(dset, H5T_NATIVE_SCHAR, mem_space, file_space, H5P_DEFAULT, buf); + } + H5Sclose(mem_space); + } } - free (buf); - H5Sclose (file_space); - H5Dclose (dset); - H5Fclose (file); + free(buf); + H5Sclose(file_space); + H5Dclose(dset); + H5Fclose(file); - return (double)SQUARE(CH_SIZE*DS_SIZE)/(double)nio_g; + return (double)SQUARE(CH_SIZE * DS_SIZE) / (double)nio_g; } - /*------------------------------------------------------------------------- * Function: test_diag * @@ -265,63 +253,60 @@ test_rowmaj (int op, size_t cache_size, size_t io_size) *------------------------------------------------------------------------- */ static double -test_diag (int op, size_t cache_size, size_t io_size, size_t offset) +test_diag(int op, size_t cache_size, size_t io_size, size_t offset) { - hid_t file, dset, mem_space, file_space; - hsize_t i, hs_size[2]; - hsize_t nio = 0; - hsize_t hs_offset[2]; - signed char *buf = (signed char *)calloc(1, (size_t)(SQUARE (io_size))); - int mdc_nelmts; - size_t rdcc_nelmts; - double w0; - - H5Pget_cache (fapl_g, &mdc_nelmts, &rdcc_nelmts, NULL, &w0); + hid_t file, dset, mem_space, file_space; + hsize_t i, hs_size[2]; + hsize_t nio = 0; + hsize_t hs_offset[2]; + signed char *buf = (signed char *)calloc(1, (size_t)(SQUARE(io_size))); + int mdc_nelmts; + size_t rdcc_nelmts; + double w0; + + H5Pget_cache(fapl_g, &mdc_nelmts, &rdcc_nelmts, NULL, &w0); #ifdef DIAG_W0 w0 = DIAG_W0; #endif #ifdef DIAG_NRDCC rdcc_nelmts = DIAG_NRDCC; #endif - H5Pset_cache (fapl_g, mdc_nelmts, rdcc_nelmts, - cache_size*SQUARE (CH_SIZE), w0); - file = H5Fopen(FILE_NAME, H5F_ACC_RDWR, fapl_g); - dset = H5Dopen2(file, "dset", H5P_DEFAULT); + H5Pset_cache(fapl_g, mdc_nelmts, rdcc_nelmts, cache_size * SQUARE(CH_SIZE), w0); + file = H5Fopen(FILE_NAME, H5F_ACC_RDWR, fapl_g); + dset = H5Dopen2(file, "dset", H5P_DEFAULT); file_space = H5Dget_space(dset); - nio_g = 0; - - for (i=0, hs_size[0]=io_size; hs_size[0]==io_size; i+=offset) { - hs_offset[0] = hs_offset[1] = i; - hs_size[0] = hs_size[1] = MIN (io_size, CH_SIZE*DS_SIZE-i); - mem_space = H5Screate_simple (2, hs_size, hs_size); - H5Sselect_hyperslab (file_space, H5S_SELECT_SET, hs_offset, NULL, - hs_size, NULL); - if (READ==op) { - H5Dread (dset, H5T_NATIVE_SCHAR, mem_space, file_space, - H5P_DEFAULT, buf); - } else { - H5Dwrite (dset, H5T_NATIVE_SCHAR, mem_space, file_space, - H5P_DEFAULT, buf); - } - H5Sclose (mem_space); - nio += hs_size[0]*hs_size[1]; - if (i>0) nio -= SQUARE (io_size-offset); + nio_g = 0; + + for (i = 0, hs_size[0] = io_size; hs_size[0] == io_size; i += offset) { + hs_offset[0] = hs_offset[1] = i; + hs_size[0] = hs_size[1] = MIN(io_size, CH_SIZE * DS_SIZE - i); + mem_space = H5Screate_simple(2, hs_size, hs_size); + H5Sselect_hyperslab(file_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL); + if (READ == op) { + H5Dread(dset, H5T_NATIVE_SCHAR, mem_space, file_space, H5P_DEFAULT, buf); + } + else { + H5Dwrite(dset, H5T_NATIVE_SCHAR, mem_space, file_space, H5P_DEFAULT, buf); + } + H5Sclose(mem_space); + nio += hs_size[0] * hs_size[1]; + if (i > 0) + nio -= SQUARE(io_size - offset); } - free (buf); - H5Sclose (file_space); - H5Dclose (dset); - H5Fclose (file); + free(buf); + H5Sclose(file_space); + H5Dclose(dset); + H5Fclose(file); /* * The extra cast in the following statement is a bug workaround for the * Win32 version 5.0 compiler. * 1998-11-06 ptl */ - return (double)nio/(double)nio_g; + return (double)nio / (double)nio_g; } - /*------------------------------------------------------------------------- * Function: main * @@ -339,25 +324,25 @@ test_diag (int op, size_t cache_size, size_t io_size, size_t offset) *------------------------------------------------------------------------- */ int -main (void) +main(void) { - size_t io_size; - double effic, io_percent; - FILE *f, *d; - size_t cache_size; - double w0; + size_t io_size; + double effic, io_percent; + FILE * f, *d; + size_t cache_size; + double w0; /* * Create a global file access property list. */ - fapl_g = H5Pcreate (H5P_FILE_ACCESS); - H5Pget_cache (fapl_g, NULL, NULL, NULL, &w0); + fapl_g = H5Pcreate(H5P_FILE_ACCESS); + H5Pget_cache(fapl_g, NULL, NULL, NULL, &w0); /* Create the file */ - create_dataset (); - f = fopen ("x-gnuplot", "w"); + create_dataset(); + f = fopen("x-gnuplot", "w"); - printf("Test %8s %8s %8s\n", "CacheSz", "ChunkSz", "Effic"); + printf("Test %8s %8s %8s\n", "CacheSz", "ChunkSz", "Effic"); printf("--------- -------- -------- --------\n"); #if 1 @@ -365,45 +350,44 @@ main (void) * Test row-major reading of the dataset with various sizes of request * windows. */ - if (RM_CACHE_STRT==RM_CACHE_END) { - fprintf (f, "set yrange [0:1.2]\n"); - fprintf (f, "set ytics 0, 0.1, 1\n"); - fprintf (f, "set xlabel \"%s\"\n", - "Request size as a fraction of chunk size"); - fprintf (f, "set ylabel \"Efficiency\"\n"); - fprintf (f, "set title \"Cache %d chunks, w0=%g, " - "Size=(total=%d, chunk=%d)\"\n", - RM_CACHE_STRT, w0, DS_SIZE*CH_SIZE, CH_SIZE); - } else { - fprintf (f, "set autoscale\n"); - fprintf (f, "set hidden3d\n"); + if (RM_CACHE_STRT == RM_CACHE_END) { + fprintf(f, "set yrange [0:1.2]\n"); + fprintf(f, "set ytics 0, 0.1, 1\n"); + fprintf(f, "set xlabel \"%s\"\n", "Request size as a fraction of chunk size"); + fprintf(f, "set ylabel \"Efficiency\"\n"); + fprintf(f, + "set title \"Cache %d chunks, w0=%g, " + "Size=(total=%d, chunk=%d)\"\n", + RM_CACHE_STRT, w0, DS_SIZE * CH_SIZE, CH_SIZE); + } + else { + fprintf(f, "set autoscale\n"); + fprintf(f, "set hidden3d\n"); } - fprintf (f, "set terminal postscript\nset output \"x-rowmaj-rd.ps\"\n"); - fprintf (f, "%s \"x-rowmaj-rd.dat\" title \"RowMaj-Read\" with %s\n", - RM_CACHE_STRT==RM_CACHE_END?"plot":"splot", - LINESPOINTS); - fprintf (f, "set terminal x11\nreplot\n"); - d = fopen ("x-rowmaj-rd.dat", "w"); - for (cache_size=RM_CACHE_STRT; - cache_size<=RM_CACHE_END; - cache_size+=RM_CACHE_DELT) { - for (io_percent=RM_START; io_percent<=RM_END; io_percent+=RM_DELTA) { - io_size = MAX (1, (size_t)(CH_SIZE*io_percent)); - printf ("Rowmaj-rd %8d %8.2f", (int)cache_size, io_percent); - fflush (stdout); - effic = test_rowmaj (READ, cache_size, io_size); - printf (" %8.2f\n", effic); - if (RM_CACHE_STRT==RM_CACHE_END) { - fprintf (d, "%g %g\n", io_percent, effic); - } else { - fprintf (d, "%g\n", effic); - } - } - fprintf (d, "\n"); + fprintf(f, "set terminal postscript\nset output \"x-rowmaj-rd.ps\"\n"); + fprintf(f, "%s \"x-rowmaj-rd.dat\" title \"RowMaj-Read\" with %s\n", + RM_CACHE_STRT == RM_CACHE_END ? "plot" : "splot", LINESPOINTS); + fprintf(f, "set terminal x11\nreplot\n"); + d = fopen("x-rowmaj-rd.dat", "w"); + for (cache_size = RM_CACHE_STRT; cache_size <= RM_CACHE_END; cache_size += RM_CACHE_DELT) { + for (io_percent = RM_START; io_percent <= RM_END; io_percent += RM_DELTA) { + io_size = MAX(1, (size_t)(CH_SIZE * io_percent)); + printf("Rowmaj-rd %8d %8.2f", (int)cache_size, io_percent); + fflush(stdout); + effic = test_rowmaj(READ, cache_size, io_size); + printf(" %8.2f\n", effic); + if (RM_CACHE_STRT == RM_CACHE_END) { + fprintf(d, "%g %g\n", io_percent, effic); + } + else { + fprintf(d, "%g\n", effic); + } + } + fprintf(d, "\n"); } - fclose (d); - fprintf (f, "pause -1\n"); + fclose(d); + fprintf(f, "pause -1\n"); #endif #if 1 @@ -411,138 +395,133 @@ main (void) * Test row-major writing of the dataset with various sizes of request * windows. */ - if (RM_CACHE_STRT==RM_CACHE_END) { - fprintf (f, "set yrange [0:1.2]\n"); - fprintf (f, "set ytics 0, 0.1, 1\n"); - fprintf (f, "set xlabel \"%s\"\n", - "Request size as a fraction of chunk size"); - fprintf (f, "set ylabel \"Efficiency\"\n"); - fprintf (f, "set title \"Cache %d chunks,w0=%g, " - "Size=(total=%d, chunk=%d)\"\n", - RM_CACHE_STRT, w0, DS_SIZE*CH_SIZE, CH_SIZE); - } else { - fprintf (f, "set autoscale\n"); - fprintf (f, "set hidden3d\n"); + if (RM_CACHE_STRT == RM_CACHE_END) { + fprintf(f, "set yrange [0:1.2]\n"); + fprintf(f, "set ytics 0, 0.1, 1\n"); + fprintf(f, "set xlabel \"%s\"\n", "Request size as a fraction of chunk size"); + fprintf(f, "set ylabel \"Efficiency\"\n"); + fprintf(f, + "set title \"Cache %d chunks,w0=%g, " + "Size=(total=%d, chunk=%d)\"\n", + RM_CACHE_STRT, w0, DS_SIZE * CH_SIZE, CH_SIZE); + } + else { + fprintf(f, "set autoscale\n"); + fprintf(f, "set hidden3d\n"); } - fprintf (f, "set terminal postscript\nset output \"x-rowmaj-wr.ps\"\n"); - fprintf (f, "%s \"x-rowmaj-wr.dat\" title \"RowMaj-Write\" with %s\n", - RM_CACHE_STRT==RM_CACHE_END?"plot":"splot", - LINESPOINTS); - fprintf (f, "set terminal x11\nreplot\n"); - d = fopen ("x-rowmaj-wr.dat", "w"); - for (cache_size=RM_CACHE_STRT; - cache_size<=RM_CACHE_END; - cache_size+=RM_CACHE_DELT) { - for (io_percent=RM_START; io_percent<=RM_END; io_percent+=RM_DELTA) { - io_size = MAX (1, (size_t)(CH_SIZE*io_percent)); - printf ("Rowmaj-wr %8d %8.2f", (int)cache_size, io_percent); - fflush (stdout); - effic = test_rowmaj (WRITE, cache_size, io_size); - printf (" %8.2f\n", effic); - if (RM_CACHE_STRT==RM_CACHE_END) { - fprintf (d, "%g %g\n", io_percent, effic); - } else { - fprintf (d, "%g\n", effic); - } - } - fprintf (d, "\n"); + fprintf(f, "set terminal postscript\nset output \"x-rowmaj-wr.ps\"\n"); + fprintf(f, "%s \"x-rowmaj-wr.dat\" title \"RowMaj-Write\" with %s\n", + RM_CACHE_STRT == RM_CACHE_END ? "plot" : "splot", LINESPOINTS); + fprintf(f, "set terminal x11\nreplot\n"); + d = fopen("x-rowmaj-wr.dat", "w"); + for (cache_size = RM_CACHE_STRT; cache_size <= RM_CACHE_END; cache_size += RM_CACHE_DELT) { + for (io_percent = RM_START; io_percent <= RM_END; io_percent += RM_DELTA) { + io_size = MAX(1, (size_t)(CH_SIZE * io_percent)); + printf("Rowmaj-wr %8d %8.2f", (int)cache_size, io_percent); + fflush(stdout); + effic = test_rowmaj(WRITE, cache_size, io_size); + printf(" %8.2f\n", effic); + if (RM_CACHE_STRT == RM_CACHE_END) { + fprintf(d, "%g %g\n", io_percent, effic); + } + else { + fprintf(d, "%g\n", effic); + } + } + fprintf(d, "\n"); } - fclose (d); - fprintf (f, "pause -1\n"); + fclose(d); + fprintf(f, "pause -1\n"); #endif #if 1 /* * Test diagonal read */ - if (DIAG_CACHE_STRT==DIAG_CACHE_END) { - fprintf (f, "set yrange [0:1.2]\n"); - fprintf (f, "set ytics 0, 0.1, 1\n"); - fprintf (f, "set xlabel \"%s\"\n", - "Request size as a fraction of chunk size"); - fprintf (f, "set ylabel \"Efficiency\"\n"); - fprintf (f, "set title \"Cache %d chunks,w0=%g, " - "Size=(total=%d, chunk=%d)\"\n", - DIAG_CACHE_STRT, w0, DS_SIZE*CH_SIZE, CH_SIZE); - } else { - fprintf (f, "set autoscale\n"); - fprintf (f, "set hidden3d\n"); + if (DIAG_CACHE_STRT == DIAG_CACHE_END) { + fprintf(f, "set yrange [0:1.2]\n"); + fprintf(f, "set ytics 0, 0.1, 1\n"); + fprintf(f, "set xlabel \"%s\"\n", "Request size as a fraction of chunk size"); + fprintf(f, "set ylabel \"Efficiency\"\n"); + fprintf(f, + "set title \"Cache %d chunks,w0=%g, " + "Size=(total=%d, chunk=%d)\"\n", + DIAG_CACHE_STRT, w0, DS_SIZE * CH_SIZE, CH_SIZE); + } + else { + fprintf(f, "set autoscale\n"); + fprintf(f, "set hidden3d\n"); } - fprintf (f, "set terminal postscript\nset output \"x-diag-rd.ps\"\n"); - fprintf (f, "%s \"x-diag-rd.dat\" title \"Diag-Read\" with %s\n", - DIAG_CACHE_STRT==DIAG_CACHE_END?"plot":"splot", LINESPOINTS); - fprintf (f, "set terminal x11\nreplot\n"); - d = fopen ("x-diag-rd.dat", "w"); - for (cache_size=DIAG_CACHE_STRT; - cache_size<=DIAG_CACHE_END; - cache_size+=DIAG_CACHE_DELT) { - for (io_percent=DIAG_START; io_percent<=DIAG_END; io_percent+=DIAG_DELTA) { - io_size = MAX (1, (size_t)(CH_SIZE*io_percent)); - printf ("Diag-rd %8d %8.2f", (int)cache_size, io_percent); - fflush (stdout); - effic = test_diag (READ, cache_size, io_size, MAX (1, io_size/2)); - printf (" %8.2f\n", effic); - if (DIAG_CACHE_STRT==DIAG_CACHE_END) { - fprintf (d, "%g %g\n", io_percent, effic); - } else { - fprintf (d, "%g\n", effic); - } - } - fprintf (d, "\n"); + fprintf(f, "set terminal postscript\nset output \"x-diag-rd.ps\"\n"); + fprintf(f, "%s \"x-diag-rd.dat\" title \"Diag-Read\" with %s\n", + DIAG_CACHE_STRT == DIAG_CACHE_END ? "plot" : "splot", LINESPOINTS); + fprintf(f, "set terminal x11\nreplot\n"); + d = fopen("x-diag-rd.dat", "w"); + for (cache_size = DIAG_CACHE_STRT; cache_size <= DIAG_CACHE_END; cache_size += DIAG_CACHE_DELT) { + for (io_percent = DIAG_START; io_percent <= DIAG_END; io_percent += DIAG_DELTA) { + io_size = MAX(1, (size_t)(CH_SIZE * io_percent)); + printf("Diag-rd %8d %8.2f", (int)cache_size, io_percent); + fflush(stdout); + effic = test_diag(READ, cache_size, io_size, MAX(1, io_size / 2)); + printf(" %8.2f\n", effic); + if (DIAG_CACHE_STRT == DIAG_CACHE_END) { + fprintf(d, "%g %g\n", io_percent, effic); + } + else { + fprintf(d, "%g\n", effic); + } + } + fprintf(d, "\n"); } - fclose (d); - fprintf (f, "pause -1\n"); + fclose(d); + fprintf(f, "pause -1\n"); #endif #if 1 /* * Test diagonal write */ - if (DIAG_CACHE_STRT==DIAG_CACHE_END) { - fprintf (f, "set yrange [0:1.2]\n"); - fprintf (f, "set ytics 0, 0.1, 1\n"); - fprintf (f, "set xlabel \"%s\"\n", - "Request size as a fraction of chunk size"); - fprintf (f, "set ylabel \"Efficiency\"\n"); - fprintf (f, "set title \"Cache %d chunks, w0=%g, " - "Size=(total=%d, chunk=%d)\"\n", - DIAG_CACHE_STRT, w0, DS_SIZE*CH_SIZE, CH_SIZE); - } else { - fprintf (f, "set autoscale\n"); - fprintf (f, "set hidden3d\n"); + if (DIAG_CACHE_STRT == DIAG_CACHE_END) { + fprintf(f, "set yrange [0:1.2]\n"); + fprintf(f, "set ytics 0, 0.1, 1\n"); + fprintf(f, "set xlabel \"%s\"\n", "Request size as a fraction of chunk size"); + fprintf(f, "set ylabel \"Efficiency\"\n"); + fprintf(f, + "set title \"Cache %d chunks, w0=%g, " + "Size=(total=%d, chunk=%d)\"\n", + DIAG_CACHE_STRT, w0, DS_SIZE * CH_SIZE, CH_SIZE); } - fprintf (f, "set terminal postscript\nset output \"x-diag-wr.ps\"\n"); - fprintf (f, "%s \"x-diag-wr.dat\" title \"Diag-Write\" with %s\n", - DIAG_CACHE_STRT==DIAG_CACHE_END?"plot":"splot", LINESPOINTS); - fprintf (f, "set terminal x11\nreplot\n"); - d = fopen ("x-diag-wr.dat", "w"); - for (cache_size=DIAG_CACHE_STRT; - cache_size<=DIAG_CACHE_END; - cache_size+=DIAG_CACHE_DELT) { - for (io_percent=DIAG_START; - io_percent<=DIAG_END; - io_percent+=DIAG_DELTA) { - io_size = MAX (1, (size_t)(CH_SIZE*io_percent)); - printf ("Diag-wr %8d %8.2f", (int)cache_size, io_percent); - fflush (stdout); - effic = test_diag (WRITE, cache_size, io_size, MAX (1, io_size/2)); - printf (" %8.2f\n", effic); - if (DIAG_CACHE_STRT==DIAG_CACHE_END) { - fprintf (d, "%g %g\n", io_percent, effic); - } else { - fprintf (d, "%g\n", effic); - } - } - fprintf (d, "\n"); + else { + fprintf(f, "set autoscale\n"); + fprintf(f, "set hidden3d\n"); } - fclose (d); - fprintf (f, "pause -1\n"); + fprintf(f, "set terminal postscript\nset output \"x-diag-wr.ps\"\n"); + fprintf(f, "%s \"x-diag-wr.dat\" title \"Diag-Write\" with %s\n", + DIAG_CACHE_STRT == DIAG_CACHE_END ? "plot" : "splot", LINESPOINTS); + fprintf(f, "set terminal x11\nreplot\n"); + d = fopen("x-diag-wr.dat", "w"); + for (cache_size = DIAG_CACHE_STRT; cache_size <= DIAG_CACHE_END; cache_size += DIAG_CACHE_DELT) { + for (io_percent = DIAG_START; io_percent <= DIAG_END; io_percent += DIAG_DELTA) { + io_size = MAX(1, (size_t)(CH_SIZE * io_percent)); + printf("Diag-wr %8d %8.2f", (int)cache_size, io_percent); + fflush(stdout); + effic = test_diag(WRITE, cache_size, io_size, MAX(1, io_size / 2)); + printf(" %8.2f\n", effic); + if (DIAG_CACHE_STRT == DIAG_CACHE_END) { + fprintf(d, "%g %g\n", io_percent, effic); + } + else { + fprintf(d, "%g\n", effic); + } + } + fprintf(d, "\n"); + } + fclose(d); + fprintf(f, "pause -1\n"); #endif - - H5Pclose (fapl_g); - fclose (f); + H5Pclose(fapl_g); + fclose(f); return 0; } - diff --git a/tools/test/perform/chunk_cache.c b/tools/test/perform/chunk_cache.c index 1d2e791..832447e 100644 --- a/tools/test/perform/chunk_cache.c +++ b/tools/test/perform/chunk_cache.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -19,29 +19,30 @@ */ #include "hdf5.h" #include "H5private.h" +#include "h5test.h" -#define FILENAME "chunk_cache_perf.h5" +#define FILENAME "chunk_cache_perf.h5" -#define RANK 2 +#define RANK 2 #define DSET1_NAME "partial_chunks" -#define DSET1_DIM1 9 * 1000 -#define DSET1_DIM2 9 -#define CHUNK1_DIM1 2 * 1000 -#define CHUNK1_DIM2 2 +#define DSET1_DIM1 (9 * 1000) +#define DSET1_DIM2 9 +#define CHUNK1_DIM1 (2 * 1000) +#define CHUNK1_DIM2 2 #define DSET2_NAME "hash_value" -#define DSET2_DIM1 300 -#define DSET2_DIM2 600 -#define CHUNK2_DIM1 100 -#define CHUNK2_DIM2 100 +#define DSET2_DIM1 300 +#define DSET2_DIM2 600 +#define CHUNK2_DIM1 100 +#define CHUNK2_DIM2 100 -#define RDCC_NSLOTS 5 -#define RDCC_NBYTES 1024 * 1024 * 10 -#define RDCC_W0 0.75F +#define RDCC_NSLOTS 5 +#define RDCC_NBYTES (1024 * 1024 * 10) +#define RDCC_W0 0.75 -#define FILTER_COUNTER 306 -static size_t nbytes_global; +#define FILTER_COUNTER 306 +static size_t nbytes_global; typedef struct test_time_t { long tv_sec; @@ -49,20 +50,18 @@ typedef struct test_time_t { } test_time_t; /* Local function prototypes for the dummy filter */ -static size_t -counter (unsigned flags, size_t cd_nelmts, - const unsigned *cd_values, size_t nbytes, - size_t *buf_size, void **buf); +static size_t counter(unsigned flags, size_t cd_nelmts, const unsigned *cd_values, size_t nbytes, + size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_COUNTER[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - FILTER_COUNTER, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "counter", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - counter, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER_COUNTER, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "counter", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + counter, /* The actual filter function */ }}; /*------------------------------------------------------------------------- @@ -70,32 +69,20 @@ const H5Z_class2_t H5Z_COUNTER[1] = {{ * track of the data of chunks being read from file into memory. */ static size_t -counter (unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) +counter(unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, + const unsigned H5_ATTR_UNUSED *cd_values, size_t nbytes, size_t H5_ATTR_UNUSED *buf_size, + void H5_ATTR_UNUSED **buf) { nbytes_global += nbytes; return nbytes; } /*---------------------------------------------------------------------------*/ -static double retrieve_time(void) -{ -#ifdef H5_HAVE_GETTIMEOFDAY - struct timeval t; - HDgettimeofday(&t, NULL); - return ((double)t.tv_sec + (double)t.tv_usec / 1000000); -#else - return 0.0; -#endif -} - -/*---------------------------------------------------------------------------*/ static void -cleanup (void) +cleanup(void) { - if (!getenv ("HDF5_NOCLEANUP")) { - remove (FILENAME); + if (!getenv(HDF5_NOCLEANUP)) { + remove(FILENAME); } } @@ -104,59 +91,63 @@ cleanup (void) * dataset dimension: 9000 x 9 * chunk dimension: 2000 x 2 */ -static int create_dset1(hid_t file) +static int +create_dset1(hid_t file) { - hid_t dataspace = H5I_INVALID_HID, dataset = H5I_INVALID_HID; - hid_t dcpl = H5I_INVALID_HID; - hsize_t dims[RANK] = {DSET1_DIM1, DSET1_DIM2}; - hsize_t chunk_dims[RANK] = {CHUNK1_DIM1, CHUNK1_DIM2}; - int data[DSET1_DIM1][DSET1_DIM2]; /* data for writing */ - int i, j; - + hid_t dataspace = H5I_INVALID_HID, dataset = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; + hsize_t dims[RANK] = {DSET1_DIM1, DSET1_DIM2}; + hsize_t chunk_dims[RANK] = {CHUNK1_DIM1, CHUNK1_DIM2}; + struct { + int arr[DSET1_DIM1][DSET1_DIM2]; + } *data = malloc(sizeof(*data)); + /* Create the data space. */ - if((dataspace = H5Screate_simple (RANK, dims, NULL)) < 0) + if ((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) goto error; - + /* Modify dataset creation properties, i.e. enable chunking */ - if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk (dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; - + /* Set the dummy filter simply for counting the number of bytes being read into the memory */ - if(H5Zregister(H5Z_COUNTER) < 0) + if (H5Zregister(H5Z_COUNTER) < 0) goto error; - - if(H5Pset_filter(dcpl, FILTER_COUNTER, 0, 0, NULL) < 0) + + if (H5Pset_filter(dcpl, FILTER_COUNTER, 0, 0, NULL) < 0) goto error; - + /* Create a new dataset within the file using chunk creation properties. */ - if((dataset = H5Dcreate2 (file, DSET1_NAME, H5T_NATIVE_INT, dataspace, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET1_NAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < + 0) goto error; - - for (i = 0; i < DSET1_DIM1; i++) - for (j = 0; j < DSET1_DIM2; j++) - data[i][j] = i+j; - + + /* Fill array */ + H5TEST_FILL_2D_HEAP_ARRAY(data, int); + /* Write data to dataset */ - if(H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto error; - + /* Close resources */ - H5Dclose (dataset); - H5Pclose (dcpl); - H5Sclose (dataspace); + H5Dclose(dataset); + H5Pclose(dcpl); + H5Sclose(dataspace); + HDfree(data); return 0; - + error: - H5E_BEGIN_TRY { - H5Dclose (dataset); - H5Pclose (dcpl); - H5Sclose (dataspace); - } H5E_END_TRY; - + H5E_BEGIN_TRY + { + H5Dclose(dataset); + H5Pclose(dcpl); + H5Sclose(dataspace); + } + H5E_END_TRY; + HDfree(data); + return 1; } @@ -165,128 +156,138 @@ error: * dataset dimensions: 300 x 600 * chunk dimensions: 100 x 100 */ -static int create_dset2(hid_t file) +static int +create_dset2(hid_t file) { - hid_t dataspace = H5I_INVALID_HID, dataset = H5I_INVALID_HID; - hid_t dcpl = H5I_INVALID_HID; - hsize_t dims[RANK] = {DSET2_DIM1, DSET2_DIM2}; - hsize_t chunk_dims[RANK] = {CHUNK2_DIM1, CHUNK2_DIM2}; - int data[DSET2_DIM1][DSET2_DIM2]; /* data for writing */ - int i, j; - + hid_t dataspace = H5I_INVALID_HID, dataset = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; + hsize_t dims[RANK] = {DSET2_DIM1, DSET2_DIM2}; + hsize_t chunk_dims[RANK] = {CHUNK2_DIM1, CHUNK2_DIM2}; + struct { + int arr[DSET2_DIM1][DSET2_DIM2]; + } *data = malloc(sizeof(*data)); + /* Create the data space. */ - if((dataspace = H5Screate_simple (RANK, dims, NULL)) < 0) + if ((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) goto error; - + /* Modify dataset creation properties, i.e. enable chunking */ - if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk (dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; - + /* Set the dummy filter simply for counting the number of bytes being read into the memory */ - if(H5Zregister(H5Z_COUNTER) < 0) + if (H5Zregister(H5Z_COUNTER) < 0) goto error; - if(H5Pset_filter(dcpl, FILTER_COUNTER, 0, 0, NULL) < 0) + if (H5Pset_filter(dcpl, FILTER_COUNTER, 0, 0, NULL) < 0) goto error; - + /* Create a new dataset within the file using chunk creation properties. */ - if((dataset = H5Dcreate2 (file, DSET2_NAME, H5T_NATIVE_INT, dataspace, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < + 0) goto error; - - for (i = 0; i < DSET2_DIM1; i++) - for (j = 0; j < DSET2_DIM2; j++) - data[i][j] = i+j; - + + /* Fill array */ + H5TEST_FILL_2D_HEAP_ARRAY(data, int); + /* Write data to dataset */ - if(H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto error; - + /* Close resources */ - H5Dclose (dataset); - H5Pclose (dcpl); - H5Sclose (dataspace); - + H5Dclose(dataset); + H5Pclose(dcpl); + H5Sclose(dataspace); + HDfree(data); + return 0; - + error: - H5E_BEGIN_TRY { - H5Dclose (dataset); - H5Pclose (dcpl); - H5Sclose (dataspace); - } H5E_END_TRY; - + H5E_BEGIN_TRY + { + H5Dclose(dataset); + H5Pclose(dcpl); + H5Sclose(dataspace); + } + H5E_END_TRY; + HDfree(data); + return 1; } + /*--------------------------------------------------------------------------- * Check the performance of the chunk cache when partial chunks exist * along the dataset dimensions. */ -static int check_partial_chunks_perf(hid_t file) +static int +check_partial_chunks_perf(hid_t file) { - hid_t dataset = H5I_INVALID_HID; - hid_t filespace = H5I_INVALID_HID; - hid_t memspace = H5I_INVALID_HID; - hid_t dapl = H5I_INVALID_HID; - - int rdata[DSET1_DIM2]; /* data for reading */ - int i; - - hsize_t row_rank = 1; - hsize_t row_dim[1] = {DSET1_DIM2}; - hsize_t start[RANK] = {0, 0}; - hsize_t count[RANK] = {1, DSET1_DIM2}; - double start_t, end_t; - - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + hid_t dataset = H5I_INVALID_HID; + hid_t filespace = H5I_INVALID_HID; + hid_t memspace = H5I_INVALID_HID; + hid_t dapl = H5I_INVALID_HID; + + int rdata[DSET1_DIM2]; /* data for reading */ + int i; + + hsize_t row_rank = 1; + hsize_t row_dim[1] = {DSET1_DIM2}; + hsize_t start[RANK] = {0, 0}; + hsize_t count[RANK] = {1, DSET1_DIM2}; + double start_t, end_t; + + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) goto error; - if(H5Pset_chunk_cache (dapl, RDCC_NSLOTS, RDCC_NBYTES, RDCC_W0) < 0) + if (H5Pset_chunk_cache(dapl, RDCC_NSLOTS, RDCC_NBYTES, RDCC_W0) < 0) goto error; - dataset = H5Dopen2 (file, DSET1_NAME, dapl); - - memspace = H5Screate_simple(row_rank, row_dim, NULL); + dataset = H5Dopen2(file, DSET1_NAME, dapl); + + H5_CHECK_OVERFLOW(row_rank, hsize_t, int); + memspace = H5Screate_simple((int)row_rank, row_dim, NULL); filespace = H5Dget_space(dataset); - + nbytes_global = 0; - - start_t = retrieve_time(); - + + start_t = H5_get_time(); + /* Read the data row by row */ - for(i = 0; i < DSET1_DIM1; i++) { - start[0] = i; - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, - start, NULL, count, NULL) < 0) + for (i = 0; i < DSET1_DIM1; i++) { + start[0] = (hsize_t)i; + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) goto error; - - if(H5Dread (dataset, H5T_NATIVE_INT, memspace, filespace, - H5P_DEFAULT, rdata) < 0) + + if (H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, rdata) < 0) goto error; } - - end_t = retrieve_time(); - -#ifdef H5_HAVE_GETTIMEOFDAY - printf("1. Partial chunks: total read time is %lf; number of bytes being read from file is %lu\n", (end_t -start_t), nbytes_global); -#else - printf("1. Partial chunks: no total read time because gettimeofday() is not available; number of bytes being read from file is %lu\n", nbytes_global); -#endif - - H5Dclose (dataset); - H5Sclose (filespace); - H5Sclose (memspace); - H5Pclose (dapl); - + + end_t = H5_get_time(); + + if ((end_t - start_t) > 0.0) + HDprintf("1. Partial chunks: total read time is %lf; number of bytes being read from file is %zu\n", + (end_t - start_t), nbytes_global); + else + HDprintf( + "1. Partial chunks: no total read time because timer is not available; number of bytes being " + "read from file is %zu\n", + nbytes_global); + + H5Dclose(dataset); + H5Sclose(filespace); + H5Sclose(memspace); + H5Pclose(dapl); + return 0; error: - H5E_BEGIN_TRY { - H5Dclose (dataset); - H5Sclose (filespace); - H5Sclose (memspace); - H5Pclose (dapl); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Dclose(dataset); + H5Sclose(filespace); + H5Sclose(memspace); + H5Pclose(dapl); + } + H5E_END_TRY; return 1; } @@ -295,71 +296,77 @@ error: * is smaller than the number of chunks along the fastest-growing * dimension of the dataset. */ -static int check_hash_value_perf(hid_t file) +static int +check_hash_value_perf(hid_t file) { - hid_t dataset = H5I_INVALID_HID; - hid_t filespace = H5I_INVALID_HID; - hid_t memspace = H5I_INVALID_HID; - hid_t dapl = H5I_INVALID_HID; - - int rdata[DSET2_DIM1]; /* data for reading */ - int i; - - hsize_t column_rank = 1; - hsize_t column_dim[1] = {DSET2_DIM1}; - hsize_t start[RANK] = {0, 0}; - hsize_t count[RANK] = {DSET2_DIM1, 1}; - double start_t, end_t; - - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + hid_t dataset = H5I_INVALID_HID; + hid_t filespace = H5I_INVALID_HID; + hid_t memspace = H5I_INVALID_HID; + hid_t dapl = H5I_INVALID_HID; + + int rdata[DSET2_DIM1]; /* data for reading */ + int i; + + hsize_t column_rank = 1; + hsize_t column_dim[1] = {DSET2_DIM1}; + hsize_t start[RANK] = {0, 0}; + hsize_t count[RANK] = {DSET2_DIM1, 1}; + double start_t, end_t; + + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) goto error; - if(H5Pset_chunk_cache (dapl, RDCC_NSLOTS, RDCC_NBYTES, RDCC_W0) < 0) + if (H5Pset_chunk_cache(dapl, RDCC_NSLOTS, RDCC_NBYTES, RDCC_W0) < 0) goto error; - - if((dataset = H5Dopen2 (file, DSET2_NAME, dapl)) < 0) + + if ((dataset = H5Dopen2(file, DSET2_NAME, dapl)) < 0) goto error; - if((memspace = H5Screate_simple(column_rank, column_dim, NULL)) < 0) + + H5_CHECK_OVERFLOW(column_rank, hsize_t, int); + if ((memspace = H5Screate_simple((int)column_rank, column_dim, NULL)) < 0) goto error; - if((filespace = H5Dget_space(dataset)) < 0) + if ((filespace = H5Dget_space(dataset)) < 0) goto error; - + nbytes_global = 0; - - start_t = retrieve_time(); - + + start_t = H5_get_time(); + /* Read the data column by column */ - for(i = 0; i < DSET2_DIM2; i++) { - start[1] = i; - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, - start, NULL, count, NULL) < 0) + for (i = 0; i < DSET2_DIM2; i++) { + start[1] = (hsize_t)i; + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) goto error; - - if(H5Dread (dataset, H5T_NATIVE_INT, memspace, filespace, - H5P_DEFAULT, rdata) < 0) + + if (H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, rdata) < 0) goto error; } - - end_t = retrieve_time(); - -#ifdef H5_HAVE_GETTIMEOFDAY - printf("2. Hash value: total read time is %lf; number of bytes being read from file is %lu\n", (end_t -start_t), nbytes_global); -#else - printf("2. Hash value: no total read time because gettimeofday() is not available; number of bytes being read from file is %lu\n", nbytes_global); -#endif - - H5Dclose (dataset); - H5Sclose (filespace); - H5Sclose (memspace); - H5Pclose (dapl); + + end_t = H5_get_time(); + + if ((end_t - start_t) > 0.0) + HDprintf("2. Hash value: total read time is %lf; number of bytes being read from file is %zu\n", + (end_t - start_t), nbytes_global); + else + HDprintf( + "2. Hash value: no total read time because timer is not available; number of bytes being read " + "from file is %zu\n", + nbytes_global); + + H5Dclose(dataset); + H5Sclose(filespace); + H5Sclose(memspace); + H5Pclose(dapl); return 0; - + error: - H5E_BEGIN_TRY { - H5Dclose (dataset); - H5Sclose (filespace); - H5Sclose (memspace); - H5Pclose (dapl); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Dclose(dataset); + H5Sclose(filespace); + H5Sclose(memspace); + H5Pclose(dapl); + } + H5E_END_TRY; return 1; } @@ -370,36 +377,37 @@ error: * in the fastest-growing dimension. *-------------------------------------------------------------------------------------*/ int -main (void) +main(void) { - hid_t file; /* handles */ - int nerrors = 0; - + hid_t file = H5I_INVALID_HID; /* file ID */ + int nerrors = 0; + /* Create a new file. If file exists its contents will be overwritten. */ - if((file = H5Fcreate (FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; nerrors += create_dset1(file); nerrors += create_dset2(file); - - if(H5Fclose (file) < 0) + + if (H5Fclose(file) < 0) goto error; /* Re-open the file for testing performance. */ - if((file = H5Fopen (FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((file = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) goto error; nerrors += check_partial_chunks_perf(file); nerrors += check_hash_value_perf(file); - - if(H5Fclose (file) < 0) + + if (H5Fclose(file) < 0) + goto error; + + if (nerrors > 0) goto error; - - if (nerrors>0) goto error; cleanup(); return 0; - + error: - fprintf(stderr, "*** ERRORS DETECTED ***\n"); + HDfprintf(stderr, "*** ERRORS DETECTED ***\n"); return 1; } diff --git a/tools/test/perform/direct_write_perf.c b/tools/test/perform/direct_write_perf.c index f13cd24..1d7756b 100644 --- a/tools/test/perform/direct_write_perf.c +++ b/tools/test/perform/direct_write_perf.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,216 +23,224 @@ #if !defined(WIN32) && !defined(__MINGW32__) +#include <errno.h> +#include <fcntl.h> #include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <time.h> -#ifdef H5_STDC_HEADERS -# include <errno.h> -# include <fcntl.h> -# include <stdio.h> -# include <stdlib.h> +#ifdef H5_HAVE_SYS_STAT_H +#include <sys/stat.h> #endif -#ifdef H5_HAVE_UNISTD_H -# include <sys/types.h> -# include <unistd.h> +#ifdef H5_HAVE_SYS_TIME_H +#include <sys/time.h> #endif -#ifdef H5_HAVE_SYS_STAT_H -# include <sys/stat.h> +#ifdef H5_HAVE_SYS_TYPES_H +#include <sys/types.h> #endif -#if defined(H5_TIME_WITH_SYS_TIME) -# include <sys/time.h> -# include <time.h> -#elif defined(H5_HAVE_SYS_TIME_H) -# include <sys/time.h> -#else -# include <time.h> +#ifdef H5_HAVE_UNISTD_H +#include <unistd.h> #endif -const char *FILENAME[] = { - "direct_write", - "unix.raw", - NULL -}; +const char *FILENAME[] = {"direct_write", "unix.raw", NULL}; /* * Print the current location on the standard output stream. */ -#define FUNC __func__ -#define AT() printf (" at %s:%d in %s()...\n", \ - __FILE__, __LINE__, FUNC); -#define H5_FAILED() {puts("*FAILED*");fflush(stdout);} -#define TEST_ERROR {H5_FAILED(); AT(); goto error;} -#define TESTING(WHAT) {printf("Testing %-62s",WHAT); fflush(stdout);} -#define PASSED() {puts(" PASSED");fflush(stdout);} - -#define DIRECT_UNCOMPRESSED_DSET "direct_uncompressed_dset" -#define DIRECT_COMPRESSED_DSET "direct_compressed_dset" -#define REG_COMPRESSED_DSET "reg_compressed_dset" -#define REG_NO_COMPRESS_DSET "reg_no_compress_dset" -#define RANK 3 -#define NX 100 -#define NY 1000 -#define NZ 250 -#define CHUNK_NX 1 -#define CHUNK_NY 1000 -#define CHUNK_NZ 250 - -#define DEFLATE_SIZE_ADJUST(s) (ceil(((double)(s))*1.001)+12) -char filename[1024]; +#define AT() printf(" at %s:%d in %s()...\n", __FILE__, __LINE__, __func__); +#define H5_FAILED() \ + { \ + puts("*FAILED*"); \ + fflush(stdout); \ + } +#define TEST_ERROR \ + { \ + H5_FAILED(); \ + AT(); \ + goto error; \ + } +#define TESTING(WHAT) \ + { \ + printf("Testing %-62s", WHAT); \ + fflush(stdout); \ + } +#define PASSED() \ + { \ + puts(" PASSED"); \ + fflush(stdout); \ + } + +#define DIRECT_UNCOMPRESSED_DSET "direct_uncompressed_dset" +#define DIRECT_COMPRESSED_DSET "direct_compressed_dset" +#define REG_COMPRESSED_DSET "reg_compressed_dset" +#define REG_NO_COMPRESS_DSET "reg_no_compress_dset" +#define RANK 3 +#define NX 100 +#define NY 1000 +#define NZ 250 +#define CHUNK_NX 1 +#define CHUNK_NY 1000 +#define CHUNK_NZ 250 + +#define DEFLATE_SIZE_ADJUST(s) (ceil(((double)(s)) * 1.001) + 12) +char filename[1024]; unsigned int *outbuf[NX]; -size_t data_size[NX]; -double total_size = 0.0; +size_t data_size[NX]; +double total_size = 0.0; unsigned int *direct_buf[NX]; -double MB = 1048576.0; +double MB = 1048576.0; /*-------------------------------------------------- * Function to report IO rate *-------------------------------------------------- */ -void reportTime(struct timeval start, double mbytes) +void +reportTime(struct timeval start, double mbytes) { - struct timeval timeval_stop,timeval_diff; + struct timeval timeval_stop, timeval_diff; /*end timing*/ - gettimeofday(&timeval_stop,NULL); + gettimeofday(&timeval_stop, NULL); /* Calculate the elapsed gettimeofday time */ - timeval_diff.tv_usec=timeval_stop.tv_usec-start.tv_usec; - timeval_diff.tv_sec=timeval_stop.tv_sec-start.tv_sec; + timeval_diff.tv_usec = timeval_stop.tv_usec - start.tv_usec; + timeval_diff.tv_sec = timeval_stop.tv_sec - start.tv_sec; - if(timeval_diff.tv_usec<0) { - timeval_diff.tv_usec+=1000000; + if (timeval_diff.tv_usec < 0) { + timeval_diff.tv_usec += 1000000; timeval_diff.tv_sec--; } /* end if */ -/*printf("mbytes=%lf, sec=%lf, usec=%lf\n", mbytes, (double)timeval_diff.tv_sec, (double)timeval_diff.tv_usec);*/ - printf("MBytes/second: %lf\n", (double)mbytes/((double)timeval_diff.tv_sec+((double)timeval_diff.tv_usec/(double)1000000.0))); + /*printf("mbytes=%lf, sec=%lf, usec=%lf\n", mbytes, (double)timeval_diff.tv_sec, + * (double)timeval_diff.tv_usec);*/ + printf("MBytes/second: %lf\n", (double)mbytes / ((double)timeval_diff.tv_sec + + ((double)timeval_diff.tv_usec / (double)1000000.0))); } /*-------------------------------------------------- * Create file, datasets, and initialize data *-------------------------------------------------- */ -int create_file(hid_t fapl_id) +int +create_file(hid_t fapl_id) { - hid_t file; /* handles */ - hid_t fapl; - hid_t cparms; - hid_t dataspace, dataset; - hsize_t dims[RANK] = {NX, NY, NZ}; - hsize_t chunk_dims[RANK] ={CHUNK_NX, CHUNK_NY, CHUNK_NZ}; - unsigned int aggression = 9; /* Compression aggression setting */ - int ret; - int i, j, n; + hid_t file; /* handles */ + hid_t fapl; + hid_t cparms; + hid_t dataspace, dataset; + hsize_t dims[RANK] = {NX, NY, NZ}; + hsize_t chunk_dims[RANK] = {CHUNK_NX, CHUNK_NY, CHUNK_NZ}; + unsigned int aggression = 9; /* Compression aggression setting */ + int ret; + int i, j, n; int flag; int unix_file; unsigned int *p; - size_t buf_size = CHUNK_NY*CHUNK_NZ*sizeof(unsigned int); + size_t buf_size = CHUNK_NY * CHUNK_NZ * sizeof(unsigned int); const Bytef *z_src; - Bytef *z_dst; /*destination buffer */ - uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size); - uLong z_src_nbytes = (uLong)buf_size; + Bytef * z_dst; /*destination buffer */ + uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size); + uLong z_src_nbytes = (uLong)buf_size; TESTING("Create a file and dataset"); /* * Create the data space with unlimited dimensions. */ - if((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) TEST_ERROR; /* * Create a new file. If file exists its contents will be overwritten. */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) TEST_ERROR; /* * Modify dataset creation properties, i.e. enable chunking and compression */ - if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; - if(H5Pset_chunk( cparms, RANK, chunk_dims) < 0) + if (H5Pset_chunk(cparms, RANK, chunk_dims) < 0) TEST_ERROR; /* * Create a new dataset within the file using cparms * creation properties. */ - if((dataset = H5Dcreate2(file, DIRECT_UNCOMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DIRECT_UNCOMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, + H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR; - if((dataset = H5Dcreate2(file, REG_NO_COMPRESS_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, REG_NO_COMPRESS_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, + H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR; /* Set compression */ - if(H5Pset_deflate( cparms, aggression) < 0) + if (H5Pset_deflate(cparms, aggression) < 0) TEST_ERROR; - if((dataset = H5Dcreate2(file, DIRECT_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DIRECT_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, + H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR; - - if((dataset = H5Dcreate2(file, REG_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, REG_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, + H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR; - if(H5Sclose(dataspace) < 0) + if (H5Sclose(dataspace) < 0) TEST_ERROR; - if(H5Pclose(cparms) < 0) + if (H5Pclose(cparms) < 0) TEST_ERROR; /* create a unix file*/ - flag = O_CREAT|O_TRUNC|O_WRONLY; + flag = O_CREAT | O_TRUNC | O_WRONLY; - if ((unix_file=open(FILENAME[1],flag,S_IRWXU))== -1) + if ((unix_file = open(FILENAME[1], flag, S_IRWXU)) == -1) TEST_ERROR; - if (close(unix_file) < 0) - { + if (close(unix_file) < 0) { printf(" unable to close the file\n"); TEST_ERROR; } - /* Initialize data for chunks */ - for(i = 0; i < NX; i++) { - p = direct_buf[i] = (unsigned int*)malloc(CHUNK_NY*CHUNK_NZ*sizeof(unsigned int)); - - for(j=0; j < CHUNK_NY*CHUNK_NZ; j++, p++) + for (i = 0; i < NX; i++) { + p = direct_buf[i] = (unsigned int *)malloc(CHUNK_NY * CHUNK_NZ * sizeof(unsigned int)); + + for (j = 0; j < CHUNK_NY * CHUNK_NZ; j++, p++) *p = rand() % 65000; - z_src = (const Bytef*)direct_buf[i]; + z_src = (const Bytef *)direct_buf[i]; z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size); /* Allocate output (compressed) buffer */ - outbuf[i] = (unsigned int*)malloc((size_t)z_dst_nbytes); - z_dst = (Bytef *)outbuf[i]; + outbuf[i] = (unsigned int *)malloc((size_t)z_dst_nbytes); + z_dst = (Bytef *)outbuf[i]; /* Perform compression from the source to the destination buffer */ ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression); @@ -241,70 +249,73 @@ int create_file(hid_t fapl_id) total_size += data_size[i]; /* Check for various zlib errors */ - if(Z_BUF_ERROR == ret) { + if (Z_BUF_ERROR == ret) { fprintf(stderr, "overflow"); TEST_ERROR; - } else if(Z_MEM_ERROR == ret) { - fprintf(stderr, "deflate memory error"); + } + else if (Z_MEM_ERROR == ret) { + fprintf(stderr, "deflate memory error"); TEST_ERROR; - } else if(Z_OK != ret) { - fprintf(stderr, "other deflate error"); + } + else if (Z_OK != ret) { + fprintf(stderr, "other deflate error"); TEST_ERROR; } } - PASSED(); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Sclose(dataspace); H5Pclose(cparms); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /*-------------------------------------------------- - * Benchmark the performance of the new function + * Benchmark the performance of the new function * with precompressed data. *-------------------------------------------------- */ int test_direct_write_uncompressed_data(hid_t fapl_id) { - hid_t file; /* handles */ - hid_t dataspace, dataset; - hid_t dxpl; - herr_t status; - int i; + hid_t file; /* handles */ + hid_t dataspace, dataset; + hid_t dxpl; + herr_t status; + int i; + + unsigned filter_mask = 0; + hsize_t offset[RANK] = {0, 0, 0}; - unsigned filter_mask = 0; - hsize_t offset[RANK] = {0, 0, 0}; + struct timeval timeval_start; - struct timeval timeval_start; - TESTING("H5Dwrite_chunk for uncompressed data"); - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; /* Start the timer */ - gettimeofday(&timeval_start,NULL); + gettimeofday(&timeval_start, NULL); /* Reopen the file and dataset */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR; - if((dataset = H5Dopen2(file, DIRECT_UNCOMPRESSED_DSET, H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DIRECT_UNCOMPRESSED_DSET, H5P_DEFAULT)) < 0) TEST_ERROR; - - /* Write the compressed chunk data repeatedly to cover all the chunks in the - * dataset, using the direct writing function. */ - for(i=0; i<NX; i++) { - status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, CHUNK_NY*CHUNK_NZ*sizeof(unsigned int), direct_buf[i]); + /* Write the compressed chunk data repeatedly to cover all the chunks in the + * dataset, using the direct writing function. */ + for (i = 0; i < NX; i++) { + status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, + CHUNK_NY * CHUNK_NZ * sizeof(unsigned int), direct_buf[i]); (offset[0])++; } @@ -315,60 +326,60 @@ test_direct_write_uncompressed_data(hid_t fapl_id) H5Pclose(dxpl); H5Fclose(file); - /* Report the performance */ - reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB)); + /* Report the performance */ + reportTime(timeval_start, (double)(NX * NY * NZ * sizeof(unsigned int) / MB)); PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Pclose(dxpl); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } - /*-------------------------------------------------- - * Benchmark the performance of the new function + * Benchmark the performance of the new function * with precompressed data. *-------------------------------------------------- */ int test_direct_write_compressed_data(hid_t fapl_id) { - hid_t file; /* handles */ - hid_t dataspace, dataset; - hid_t dxpl; - herr_t status; - int i; + hid_t file; /* handles */ + hid_t dataspace, dataset; + hid_t dxpl; + herr_t status; + int i; + + unsigned filter_mask = 0; + hsize_t offset[RANK] = {0, 0, 0}; - unsigned filter_mask = 0; - hsize_t offset[RANK] = {0, 0, 0}; + struct timeval timeval_start; - struct timeval timeval_start; - TESTING("H5DOwrite_chunk for pre-compressed data"); - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; /* Start the timer */ - gettimeofday(&timeval_start,NULL); + gettimeofday(&timeval_start, NULL); /* Reopen the file and dataset */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR; - if((dataset = H5Dopen2(file, DIRECT_COMPRESSED_DSET, H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DIRECT_COMPRESSED_DSET, H5P_DEFAULT)) < 0) TEST_ERROR; - - /* Write the compressed chunk data repeatedly to cover all the chunks in the - * dataset, using the direct writing function. */ - for(i=0; i<NX; i++) { + /* Write the compressed chunk data repeatedly to cover all the chunks in the + * dataset, using the direct writing function. */ + for (i = 0; i < NX; i++) { status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, data_size[i], outbuf[i]); (offset[0])++; } @@ -379,19 +390,21 @@ test_direct_write_compressed_data(hid_t fapl_id) H5Dclose(dataset); H5Pclose(dxpl); H5Fclose(file); - - /* Report the performance */ - reportTime(timeval_start, (double)(total_size/MB)); + + /* Report the performance */ + reportTime(timeval_start, (double)(total_size / MB)); PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Pclose(dxpl); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } @@ -403,57 +416,59 @@ error: int test_compressed_write(hid_t fapl_id) { - hid_t file; /* handles */ - hid_t dataspace, dataset; - hid_t mem_space; - hsize_t chunk_dims[RANK] ={CHUNK_NX, CHUNK_NY, CHUNK_NZ}; - hid_t dxpl; - herr_t status; - int i; + hid_t file; /* handles */ + hid_t dataspace, dataset; + hid_t mem_space; + hsize_t chunk_dims[RANK] = {CHUNK_NX, CHUNK_NY, CHUNK_NZ}; + hid_t dxpl; + herr_t status; + int i; hsize_t start[RANK]; /* Start of hyperslab */ hsize_t stride[RANK]; /* Stride of hyperslab */ hsize_t count[RANK]; /* Block count */ hsize_t block[RANK]; /* Block sizes */ - struct timeval timeval_start; + struct timeval timeval_start; TESTING("H5Dwrite with compression enabled"); - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; - if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) + if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) TEST_ERROR; /* Start the timer */ - gettimeofday(&timeval_start,NULL); + gettimeofday(&timeval_start, NULL); /* Reopen the file and dataset */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR; - if((dataset = H5Dopen2(file, REG_COMPRESSED_DSET, H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, REG_COMPRESSED_DSET, H5P_DEFAULT)) < 0) TEST_ERROR; - if((dataspace = H5Dget_space(dataset)) < 0) + if ((dataspace = H5Dget_space(dataset)) < 0) TEST_ERROR; - start[0] = start[1] = start[2] = 0; + start[0] = start[1] = start[2] = 0; stride[0] = stride[1] = stride[2] = 1; - count[0] = count[1] = count[2] = 1; - block[0] = CHUNK_NX; block[1] = CHUNK_NY; block[2] = CHUNK_NZ; - - for(i=0; i<NX; i++) { + count[0] = count[1] = count[2] = 1; + block[0] = CHUNK_NX; + block[1] = CHUNK_NY; + block[2] = CHUNK_NZ; + + for (i = 0; i < NX; i++) { /* * Select hyperslab for one chunk in the file */ - if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0) + if ((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0) TEST_ERROR; - (start[0])++; + (start[0])++; - if((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace, - H5P_DEFAULT, direct_buf[i])) < 0) + if ((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, direct_buf[i])) < + 0) TEST_ERROR; } @@ -465,21 +480,23 @@ test_compressed_write(hid_t fapl_id) H5Sclose(mem_space); H5Pclose(dxpl); H5Fclose(file); - - /* Report the performance */ - reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB)); - + + /* Report the performance */ + reportTime(timeval_start, (double)(NX * NY * NZ * sizeof(unsigned int) / MB)); + PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Sclose(dataspace); H5Sclose(mem_space); H5Pclose(dxpl); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } @@ -491,57 +508,59 @@ error: int test_no_compress_write(hid_t fapl_id) { - hid_t file; /* handles */ - hid_t dataspace, dataset; - hid_t mem_space; - hsize_t chunk_dims[RANK] ={CHUNK_NX, CHUNK_NY, CHUNK_NZ}; - hid_t dxpl; - herr_t status; - int i; + hid_t file; /* handles */ + hid_t dataspace, dataset; + hid_t mem_space; + hsize_t chunk_dims[RANK] = {CHUNK_NX, CHUNK_NY, CHUNK_NZ}; + hid_t dxpl; + herr_t status; + int i; hsize_t start[RANK]; /* Start of hyperslab */ hsize_t stride[RANK]; /* Stride of hyperslab */ hsize_t count[RANK]; /* Block count */ hsize_t block[RANK]; /* Block sizes */ - struct timeval timeval_start; + struct timeval timeval_start; TESTING("H5Dwrite without compression"); - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; - if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) + if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) TEST_ERROR; /* Start the timer */ - gettimeofday(&timeval_start,NULL); + gettimeofday(&timeval_start, NULL); /* Reopen the file and dataset */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR; - if((dataset = H5Dopen2(file, REG_NO_COMPRESS_DSET, H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, REG_NO_COMPRESS_DSET, H5P_DEFAULT)) < 0) TEST_ERROR; - if((dataspace = H5Dget_space(dataset)) < 0) + if ((dataspace = H5Dget_space(dataset)) < 0) TEST_ERROR; - start[0] = start[1] = start[2] = 0; + start[0] = start[1] = start[2] = 0; stride[0] = stride[1] = stride[2] = 1; - count[0] = count[1] = count[2] = 1; - block[0] = CHUNK_NX; block[1] = CHUNK_NY; block[2] = CHUNK_NZ; - - for(i=0; i<NX; i++) { + count[0] = count[1] = count[2] = 1; + block[0] = CHUNK_NX; + block[1] = CHUNK_NY; + block[2] = CHUNK_NZ; + + for (i = 0; i < NX; i++) { /* * Select hyperslab for one chunk in the file */ - if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0) + if ((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0) TEST_ERROR; - (start[0])++; + (start[0])++; - if((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace, - H5P_DEFAULT, direct_buf[i])) < 0) + if ((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, direct_buf[i])) < + 0) TEST_ERROR; } @@ -553,21 +572,23 @@ test_no_compress_write(hid_t fapl_id) H5Sclose(mem_space); H5Pclose(dxpl); H5Fclose(file); - - /* Report the performance */ - reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB)); - + + /* Report the performance */ + reportTime(timeval_start, (double)(NX * NY * NZ * sizeof(unsigned int) / MB)); + PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Sclose(dataspace); H5Sclose(mem_space); H5Pclose(dxpl); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } @@ -576,13 +597,13 @@ error: * data to a Unix file *-------------------------------------------------- */ -int +int test_unix_write(void) { - int file, flag; - ssize_t op_size; - int i; - struct timeval timeval_start; + int file, flag; + ssize_t op_size; + int i; + struct timeval timeval_start; TESTING("Write compressed data to a Unix file"); @@ -590,41 +611,38 @@ test_unix_write(void) flag = O_WRONLY; /* Start the timer */ - gettimeofday(&timeval_start,NULL); + gettimeofday(&timeval_start, NULL); - if ((file=open(FILENAME[1],flag))== -1) + if ((file = open(FILENAME[1], flag)) == -1) TEST_ERROR; - /* Write the compressed chunk data repeatedly to cover all the chunks in the - * dataset, using the direct writing function. */ - for(i=0; i<NX; i++) { - op_size = write(file, outbuf[i],data_size[i]); - if (op_size < 0) - { + /* Write the compressed chunk data repeatedly to cover all the chunks in the + * dataset, using the direct writing function. */ + for (i = 0; i < NX; i++) { + op_size = write(file, outbuf[i], data_size[i]); + if (op_size < 0) { printf(" Error in writing data to file because %s \n", strerror(errno)); TEST_ERROR; } - else if (op_size == 0) - { - printf(" unable to write sufficent data to file because %s \n", strerror(errno)); + else if (op_size == 0) { + printf(" unable to write sufficient data to file because %s \n", strerror(errno)); TEST_ERROR; } } - if (close(file) < 0) - { + if (close(file) < 0) { printf(" unable to close the file\n"); TEST_ERROR; } - /* Report the performance */ - reportTime(timeval_start, (double)(total_size/MB)); + /* Report the performance */ + reportTime(timeval_start, (double)(total_size / MB)); PASSED(); return 0; error: - return 1; + return 1; } /*-------------------------------------------------- @@ -632,12 +650,12 @@ error: *-------------------------------------------------- */ int -main (void) +main(void) { - hid_t fapl = H5P_DEFAULT; - int i; + hid_t fapl = H5P_DEFAULT; + int i; - sprintf(filename, "%s.h5", FILENAME[0]); + snprintf(filename, sizeof(filename), "%s.h5", FILENAME[0]); create_file(fapl); test_direct_write_uncompressed_data(fapl); @@ -646,11 +664,11 @@ main (void) test_compressed_write(fapl); test_unix_write(); - for(i=0; i<NX; i++) { + for (i = 0; i < NX; i++) { free(outbuf[i]); free(direct_buf[i]); } - + return 0; } @@ -665,7 +683,7 @@ main(void) #endif /* WIN32 / MINGW32 */ -#else /* !H5_HAVE_FILTER_DEFLATE */ +#else /* !H5_HAVE_FILTER_DEFLATE */ /* * Function: main @@ -680,5 +698,4 @@ main(void) return EXIT_SUCCESS; } -#endif /* !H5_HAVE_FILTER_DEFLATE */ - +#endif /* !H5_HAVE_FILTER_DEFLATE */ diff --git a/tools/test/perform/gen_report.pl b/tools/test/perform/gen_report.pl index 34b3a83..a1fbeb0 100644 --- a/tools/test/perform/gen_report.pl +++ b/tools/test/perform/gen_report.pl @@ -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. # diff --git a/tools/test/perform/iopipe.c b/tools/test/perform/iopipe.c index 2d9c44f..2aa9e25 100644 --- a/tools/test/perform/iopipe.c +++ b/tools/test/perform/iopipe.c @@ -6,13 +6,13 @@ * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke <matzke@llnl.gov> + * Programmer: Robb Matzke * Thursday, March 12, 1998 */ @@ -21,31 +21,25 @@ #include "H5private.h" -#ifdef H5_HAVE_SYS_TIMEB -#include <sys/timeb.h> -#endif - - #define RAW_FILE_NAME "iopipe.raw" -#define HDF5_FILE_NAME "iopipe.h5" -#define HEADING "%-16s" -#define PROGRESS '=' +#define HDF5_FILE_NAME "iopipe.h5" +#define HEADING "%-16s" +#define PROGRESS '=' #if 0 /* Normal testing */ #define REQUEST_SIZE_X 4579 #define REQUEST_SIZE_Y 4579 #define NREAD_REQUESTS 45 -#define NWRITE_REQUESTS 45 +#define NWRITE_REQUESTS 45 #else /* Speedy testing */ #define REQUEST_SIZE_X 1000 #define REQUEST_SIZE_Y 1000 #define NREAD_REQUESTS 45 -#define NWRITE_REQUESTS 45 +#define NWRITE_REQUESTS 45 #endif - /*------------------------------------------------------------------------- * Function: print_stats * @@ -56,62 +50,36 @@ * Programmer: Robb Matzke * Thursday, March 12, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ -#ifdef H5_HAVE_GETRUSAGE static void -print_stats (const char *prefix, - struct rusage *r_start, struct rusage *r_stop, - struct timeval *t_start, struct timeval *t_stop, - size_t nbytes) -#else /* H5_HAVE_GETRUSAGE */ -static void -print_stats (const char *prefix, - struct timeval *r_start, struct timeval *r_stop, - struct timeval *t_start, struct timeval *t_stop, - size_t nbytes) +print_stats(const char *prefix, +#ifdef H5_HAVE_GETRUSAGE + struct rusage *r_start, struct rusage *r_stop, #endif /* H5_HAVE_GETRUSAGE */ + double t_start, double t_stop, size_t nbytes) { - double e_time, bw; + double e_time; + char bw[16]; #ifdef H5_HAVE_GETRUSAGE - double u_time, s_time; + double u_time, s_time; - u_time = ((double)(r_stop->ru_utime.tv_sec)+ - (double)(r_stop->ru_utime.tv_usec)/(double)1000000.0F) - - ((double)(r_start->ru_utime.tv_sec)+ - (double)(r_start->ru_utime.tv_usec)/(double)1000000.0F); + u_time = ((double)(r_stop->ru_utime.tv_sec) + (double)(r_stop->ru_utime.tv_usec) / 1000000.0) - + ((double)(r_start->ru_utime.tv_sec) + (double)(r_start->ru_utime.tv_usec) / 1000000.0); - s_time = ((double)(r_stop->ru_stime.tv_sec)+ - (double)(r_stop->ru_stime.tv_usec)/(double)1000000.0F) - - ((double)(r_start->ru_stime.tv_sec)+ - (double)(r_start->ru_stime.tv_usec)/(double)1000000.0F); + s_time = ((double)(r_stop->ru_stime.tv_sec) + (double)(r_stop->ru_stime.tv_usec) / 1000000.0) - + ((double)(r_start->ru_stime.tv_sec) + (double)(r_start->ru_stime.tv_usec) / 1000000.0); #endif -#ifndef H5_HAVE_SYS_TIMEB - e_time = ((double)(t_stop->tv_sec)+ - (double)(t_stop->tv_usec)/(double)1000000.0F) - - ((double)(t_start->tv_sec)+ - (double)(t_start->tv_usec)/(double)1000000.0F); -#else - e_time = ((double)(t_stop->tv_sec)+ - (double)(t_stop->tv_usec)/(double)1000.0F) - - ((double)(t_start->tv_sec)+ - (double)(t_start->tv_usec)/(double)1000.0F); -#endif - bw = (double)nbytes / e_time; + e_time = t_stop - t_start; + H5_bandwidth(bw, (double)nbytes, e_time); #ifdef H5_HAVE_GETRUSAGE - printf (HEADING "%1.2fuser %1.2fsystem %1.2felapsed %1.2fMB/s\n", - prefix, u_time, s_time, e_time, bw/(1024*1024)); + HDprintf(HEADING "%1.2fuser %1.2fsystem %1.2felapsed %s\n", prefix, u_time, s_time, e_time, bw); #else - printf (HEADING "%1.2felapsed %1.2fMB/s\n", - prefix, e_time, bw/(1024*1024)); + HDprintf(HEADING "%1.2felapsed %s\n", prefix, e_time, bw); #endif - } - /*------------------------------------------------------------------------- * Function: synchronize * @@ -122,18 +90,15 @@ print_stats (const char *prefix, * Programmer: Robb Matzke * Thursday, March 12, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ static void -synchronize (void) +synchronize(void) { -#ifdef H5_HAVE_SYSTEM -#if defined(H5_HAVE_WIN32_API) && ! defined(__CYGWIN__) +#if defined(H5_HAVE_WIN32_API) && !defined(__CYGWIN__) _flushall(); #else - int status; + int H5_ATTR_NDEBUG_UNUSED status; status = HDsystem("sync"); HDassert(status >= 0); @@ -141,10 +106,8 @@ synchronize (void) status = HDsystem("df >/dev/null"); HDassert(status >= 0); #endif -#endif } - /*------------------------------------------------------------------------- * Function: main * @@ -157,350 +120,235 @@ synchronize (void) * Programmer: Robb Matzke * Thursday, March 12, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ int -main (void) +main(void) { - static hsize_t size[2] = {REQUEST_SIZE_X, REQUEST_SIZE_Y}; - static unsigned nread = NREAD_REQUESTS, nwrite = NWRITE_REQUESTS; + hsize_t size[2] = {REQUEST_SIZE_X, REQUEST_SIZE_Y}; + unsigned nread = NREAD_REQUESTS, nwrite = NWRITE_REQUESTS; - unsigned char *the_data = NULL; - hid_t file, dset, file_space = -1; - herr_t status; + unsigned char *the_data = NULL; + hid_t file, dset, file_space = H5I_INVALID_HID; #ifdef H5_HAVE_GETRUSAGE - struct rusage r_start, r_stop; -#else - struct timeval r_start, r_stop; + struct rusage r_start, r_stop; #endif - struct timeval t_start, t_stop; - int fd; - unsigned u; - hssize_t n; - off_t offset; - hsize_t start[2]; - hsize_t count[2]; - + double t_start, t_stop; + int fd; + unsigned u; + herr_t H5_ATTR_NDEBUG_UNUSED status; + hssize_t H5_ATTR_NDEBUG_UNUSED n; + off_t H5_ATTR_NDEBUG_UNUSED offset; + hsize_t start[2]; + hsize_t count[2]; -#ifdef H5_HAVE_SYS_TIMEB - struct _timeb *tbstart = malloc(sizeof(struct _timeb)); - struct _timeb *tbstop = malloc(sizeof(struct _timeb)); -#endif /* * The extra cast in the following statement is a bug workaround for the * Win32 version 5.0 compiler. * 1998-11-06 ptl */ - printf ("I/O request size is %1.1fMB\n", - (double)(hssize_t)(size[0]*size[1])/(double)1024.0F*(double)1024); + HDprintf("I/O request size is %1.1fMB\n", (double)(hssize_t)(size[0] * size[1]) / 1024.0 * 1024.0); /* Open the files */ - file = H5Fcreate (HDF5_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - assert (file>=0); - fd = HDopen (RAW_FILE_NAME, O_RDWR|O_CREAT|O_TRUNC, 0666); - assert (fd>=0); + file = H5Fcreate(HDF5_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(file >= 0); + fd = HDopen(RAW_FILE_NAME, O_RDWR | O_CREAT | O_TRUNC, 0666); + HDassert(fd >= 0); /* Create the dataset */ - file_space = H5Screate_simple (2, size, size); - assert(file_space >= 0); + file_space = H5Screate_simple(2, size, size); + HDassert(file_space >= 0); dset = H5Dcreate2(file, "dset", H5T_NATIVE_UCHAR, file_space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - assert(dset >= 0); - the_data = (unsigned char *)malloc((size_t)(size[0] * size[1])); + HDassert(dset >= 0); + the_data = (unsigned char *)HDmalloc((size_t)(size[0] * size[1])); /* initial fill for lazy malloc */ HDmemset(the_data, 0xAA, (size_t)(size[0] * size[1])); /* Fill raw */ - synchronize (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_start, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); -#endif -#endif - HDfprintf (stderr, HEADING, "fill raw"); - for(u = 0; u < nwrite; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - HDmemset(the_data, 0xAA, (size_t)(size[0]*size[1])); + t_start = H5_get_time(); + HDfprintf(stderr, HEADING, "fill raw"); + for (u = 0; u < nwrite; u++) { + HDputc(PROGRESS, stderr); + HDfflush(stderr); + HDmemset(the_data, 0xAA, (size_t)(size[0] * size[1])); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_stop, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; -#endif -#endif - putc ('\n', stderr); - print_stats ("fill raw", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); - + t_stop = H5_get_time(); + HDputc('\n', stderr); + print_stats("fill raw", +#ifdef H5_HAVE_GETRUSAGE + &r_start, &r_stop, +#endif /* H5_HAVE_GETRUSAGE */ + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Fill hdf5 */ - synchronize (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_start, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); -#endif -#endif - HDfprintf (stderr, HEADING, "fill hdf5"); - for(u = 0; u < nread; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - assert (status>=0); + t_start = H5_get_time(); + HDfprintf(stderr, HEADING, "fill hdf5"); + for (u = 0; u < nread; u++) { + HDputc(PROGRESS, stderr); + HDfflush(stderr); + status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, H5P_DEFAULT, the_data); + HDassert(status >= 0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_stop, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; -#endif -#endif - putc ('\n', stderr); - print_stats ("fill hdf5", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + t_stop = H5_get_time(); + HDputc('\n', stderr); + print_stats("fill hdf5", +#ifdef H5_HAVE_GETRUSAGE + &r_start, &r_stop, +#endif /* H5_HAVE_GETRUSAGE */ + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Write the raw dataset */ - synchronize (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_start, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); -#endif -#endif - HDfprintf (stderr, HEADING, "out raw"); - for(u = 0; u < nwrite; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - offset = HDlseek (fd, (off_t)0, SEEK_SET); - assert (0==offset); - n = HDwrite (fd, the_data, (size_t)(size[0]*size[1])); - assert (n>=0 && (size_t)n==size[0]*size[1]); + t_start = H5_get_time(); + HDfprintf(stderr, HEADING, "out raw"); + for (u = 0; u < nwrite; u++) { + HDputc(PROGRESS, stderr); + HDfflush(stderr); + offset = HDlseek(fd, (off_t)0, SEEK_SET); + HDassert(0 == offset); + n = HDwrite(fd, the_data, (size_t)(size[0] * size[1])); + HDassert(n >= 0 && (size_t)n == (size[0] * size[1])); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_stop, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; -#endif -#endif - putc ('\n', stderr); - print_stats ("out raw", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + t_stop = H5_get_time(); + HDputc('\n', stderr); + print_stats("out raw", +#ifdef H5_HAVE_GETRUSAGE + &r_start, &r_stop, +#endif /* H5_HAVE_GETRUSAGE */ + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Write the hdf5 dataset */ - synchronize (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_start, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); -#endif -#endif - HDfprintf (stderr, HEADING, "out hdf5"); - for(u = 0; u < nwrite; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - status = H5Dwrite (dset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, - H5P_DEFAULT, the_data); - assert (status>=0); + t_start = H5_get_time(); + HDfprintf(stderr, HEADING, "out hdf5"); + for (u = 0; u < nwrite; u++) { + HDputc(PROGRESS, stderr); + HDfflush(stderr); + status = H5Dwrite(dset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, the_data); + HDassert(status >= 0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_stop, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; -#endif -#endif - putc ('\n', stderr); - print_stats ("out hdf5", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + t_stop = H5_get_time(); + HDputc('\n', stderr); + print_stats("out hdf5", +#ifdef H5_HAVE_GETRUSAGE + &r_start, &r_stop, +#endif /* H5_HAVE_GETRUSAGE */ + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Read the raw dataset */ - synchronize (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_start, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); -#endif -#endif - HDfprintf (stderr, HEADING, "in raw"); - for(u = 0; u < nread; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - offset = HDlseek (fd, (off_t)0, SEEK_SET); - assert (0==offset); - n = HDread (fd, the_data, (size_t)(size[0]*size[1])); - assert (n>=0 && (size_t)n==size[0]*size[1]); + t_start = H5_get_time(); + HDfprintf(stderr, HEADING, "in raw"); + for (u = 0; u < nread; u++) { + HDputc(PROGRESS, stderr); + HDfflush(stderr); + offset = HDlseek(fd, (off_t)0, SEEK_SET); + HDassert(0 == offset); + n = HDread(fd, the_data, (size_t)(size[0] * size[1])); + HDassert(n >= 0 && (size_t)n == (size[0] * size[1])); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_stop, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; -#endif -#endif - putc ('\n', stderr); - print_stats ("in raw", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); - + t_stop = H5_get_time(); + HDputc('\n', stderr); + print_stats("in raw", +#ifdef H5_HAVE_GETRUSAGE + &r_start, &r_stop, +#endif /* H5_HAVE_GETRUSAGE */ + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Read the hdf5 dataset */ - synchronize (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_start, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); -#endif -#endif - HDfprintf (stderr, HEADING, "in hdf5"); - for(u = 0; u < nread; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - assert (status>=0); + t_start = H5_get_time(); + HDfprintf(stderr, HEADING, "in hdf5"); + for (u = 0; u < nread; u++) { + HDputc(PROGRESS, stderr); + HDfflush(stderr); + status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, H5P_DEFAULT, the_data); + HDassert(status >= 0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_stop, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; -#endif -#endif - putc ('\n', stderr); - print_stats ("in hdf5", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + t_stop = H5_get_time(); + HDputc('\n', stderr); + print_stats("in hdf5", +#ifdef H5_HAVE_GETRUSAGE + &r_start, &r_stop, +#endif /* H5_HAVE_GETRUSAGE */ + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Read hyperslab */ - assert (size[0]>20 && size[1]>20); + HDassert(size[0] > 20 && size[1] > 20); start[0] = start[1] = 10; - count[0] = count[1] = size[0]-20; - status = H5Sselect_hyperslab (file_space, H5S_SELECT_SET, start, NULL, count, NULL); - assert (status>=0); - synchronize (); + count[0] = count[1] = size[0] - 20; + status = H5Sselect_hyperslab(file_space, H5S_SELECT_SET, start, NULL, count, NULL); + HDassert(status >= 0); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_start, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); -#endif -#endif - HDfprintf (stderr, HEADING, "in hdf5 partial"); - for(u = 0; u < nread; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - assert (status>=0); + t_start = H5_get_time(); + HDfprintf(stderr, HEADING, "in hdf5 partial"); + for (u = 0; u < nread; u++) { + HDputc(PROGRESS, stderr); + HDfflush(stderr); + status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, H5P_DEFAULT, the_data); + HDassert(status >= 0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_stop, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; -#endif -#endif - putc('\n', stderr); + t_stop = H5_get_time(); + HDputc('\n', stderr); print_stats("in hdf5 partial", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*count[0]*count[1])); - - +#ifdef H5_HAVE_GETRUSAGE + &r_start, &r_stop, +#endif /* H5_HAVE_GETRUSAGE */ + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Close everything */ HDclose(fd); + H5Dclose(dset); H5Sclose(file_space); H5Fclose(file); - free(the_data); + + HDfree(the_data); return 0; } - diff --git a/tools/test/perform/overhead.c b/tools/test/perform/overhead.c index 108d9e4..c974928 100644 --- a/tools/test/perform/overhead.c +++ b/tools/test/perform/overhead.c @@ -6,13 +6,13 @@ * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke <matzke@llnl.gov> + * Programmer: Robb Matzke * Monday, September 28, 1998 * * Purpose: Creates a chunked dataset and measures the storage overhead. @@ -23,50 +23,36 @@ #include "hdf5.h" #include "H5private.h" -#ifdef H5_STDC_HEADERS -# include <ctype.h> -# include <fcntl.h> -# include <stdlib.h> -# include <sys/stat.h> -# include <string.h> -#endif - -#ifdef H5_HAVE_IO_H -# include <io.h> -#endif +#include <ctype.h> +#include <fcntl.h> +#include <stdlib.h> +#include <sys/stat.h> +#include <string.h> #ifdef H5_HAVE_UNISTD_H -# include <sys/types.h> -# include <unistd.h> +#include <sys/types.h> +#include <unistd.h> #endif /* Solaris Studio defines attribute, but for the attributes we need */ #if !defined(H5_HAVE_ATTRIBUTE) || defined __cplusplus || defined(__SUNPRO_C) -# undef __attribute__ -# define __attribute__(X) /*void*/ -# define H5_ATTR_UNUSED /*void*/ +#undef __attribute__ +#define __attribute__(X) /*void*/ +#define H5_ATTR_UNUSED /*void*/ #else -# define H5_ATTR_UNUSED __attribute__((unused)) +#define H5_ATTR_UNUSED __attribute__((unused)) #endif -#define FILE_NAME_1 "overhead.h5" +#define FILE_NAME_1 "overhead.h5" #ifndef FALSE -#define FALSE 0 +#define FALSE 0 #endif /* FALSE */ #ifndef TRUE -#define TRUE 1 +#define TRUE 1 #endif /* TRUE */ -typedef enum fill_t { - FILL_ALL, - FILL_FORWARD, - FILL_REVERSE, - FILL_INWARD, - FILL_OUTWARD, - FILL_RANDOM -} fill_t; +typedef enum fill_t { FILL_ALL, FILL_FORWARD, FILL_REVERSE, FILL_INWARD, FILL_OUTWARD, FILL_RANDOM } fill_t; - /*------------------------------------------------------------------------- * Function: usage * @@ -84,8 +70,7 @@ typedef enum fill_t { static void usage(const char *prog) { - HDfprintf(stderr, "usage: %s [STYLE|cache] [LEFT [MIDDLE [RIGHT]]]\n", - prog); + HDfprintf(stderr, "usage: %s [STYLE|cache] [LEFT [MIDDLE [RIGHT]]]\n", prog); HDfprintf(stderr, "\ STYLE is the order that the dataset is filled and should be one of:\n\ forward -- Fill the dataset from lowest address to highest\n\ @@ -117,7 +102,6 @@ usage(const char *prog) exit(1); } - /*------------------------------------------------------------------------- * Function: cleanup * @@ -133,14 +117,13 @@ usage(const char *prog) *------------------------------------------------------------------------- */ static void -cleanup (void) +cleanup(void) { - if (!getenv ("HDF5_NOCLEANUP")) { - remove (FILE_NAME_1); + if (!getenv(HDF5_NOCLEANUP)) { + remove(FILE_NAME_1); } } - /*------------------------------------------------------------------------- * Function: display_error_cb * @@ -158,15 +141,14 @@ cleanup (void) *------------------------------------------------------------------------- */ static herr_t -display_error_cb (hid_t estack, void H5_ATTR_UNUSED *client_data) +display_error_cb(hid_t estack, void H5_ATTR_UNUSED *client_data) { - puts ("*FAILED*"); + puts("*FAILED*"); H5Eprint2(estack, stdout); return 0; } - /*------------------------------------------------------------------------- * Function: test * @@ -184,92 +166,103 @@ display_error_cb (hid_t estack, void H5_ATTR_UNUSED *client_data) *------------------------------------------------------------------------- */ static int -test(fill_t fill_style, const double splits[], - hbool_t verbose, hbool_t use_rdcc) +test(fill_t fill_style, const double splits[], hbool_t verbose, hbool_t use_rdcc) { - hid_t file = (-1), fapl = (-1), dcpl = (-1), xfer = (-1), mspace = (-1), fspace = (-1), dset = (-1); - hsize_t ch_size[1] = {1}; /*chunk size */ - hsize_t cur_size[1] = {1000}; /*current dataset size */ - hsize_t max_size[1] = {H5S_UNLIMITED}; /*maximum dataset size */ - hsize_t hs_start[1]; /*hyperslab start offset*/ - hsize_t hs_count[1] = {1}; /*hyperslab nelmts */ - int fd = (-1); /*h5 file direct */ - int *had = NULL; /*for random filling */ - const char *sname=NULL; /*fill style nam */ - int mdc_nelmts; /*num meta objs to cache*/ - hsize_t i, k; - int j; - h5_stat_t sb; + hid_t file = (-1), fapl = (-1), dcpl = (-1), xfer = (-1), mspace = (-1), fspace = (-1), dset = (-1); + hsize_t ch_size[1] = {1}; /*chunk size */ + hsize_t cur_size[1] = {1000}; /*current dataset size */ + hsize_t max_size[1] = {H5S_UNLIMITED}; /*maximum dataset size */ + hsize_t hs_start[1]; /*hyperslab start offset*/ + hsize_t hs_count[1] = {1}; /*hyperslab nelmts */ + int fd = (-1); /*h5 file direct */ + int * had = NULL; /*for random filling */ + const char *sname = NULL; /*fill style nam */ + int mdc_nelmts; /*num meta objs to cache*/ + hsize_t i, k; + int j; + h5_stat_t sb; - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; - if(!use_rdcc) { - if(H5Pget_cache(fapl, &mdc_nelmts, NULL, NULL, NULL) < 0) goto error; - if(H5Pset_cache(fapl, mdc_nelmts, 0, 0, 0.0F) < 0) goto error; + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + if (!use_rdcc) { + if (H5Pget_cache(fapl, &mdc_nelmts, NULL, NULL, NULL) < 0) + goto error; + if (H5Pset_cache(fapl, mdc_nelmts, 0, 0, 0.0) < 0) + goto error; } - if((file = H5Fcreate(FILE_NAME_1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 1, ch_size) < 0) goto error; - if((xfer = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; - if(H5Pset_btree_ratios(xfer, splits[0], splits[1], splits[2]) < 0) goto error; - if((fspace = H5Screate_simple(1, cur_size, max_size)) < 0) goto error; - if((mspace = H5Screate_simple(1, ch_size, ch_size)) < 0) goto error; - if((dset = H5Dcreate2(file, "chunked", H5T_NATIVE_INT, - fspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if ((fd=HDopen(FILE_NAME_1, O_RDONLY, 0666)) < 0) goto error; + if ((file = H5Fcreate(FILE_NAME_1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dcpl, 1, ch_size) < 0) + goto error; + if ((xfer = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; + if (H5Pset_btree_ratios(xfer, splits[0], splits[1], splits[2]) < 0) + goto error; + if ((fspace = H5Screate_simple(1, cur_size, max_size)) < 0) + goto error; + if ((mspace = H5Screate_simple(1, ch_size, ch_size)) < 0) + goto error; + if ((dset = H5Dcreate2(file, "chunked", H5T_NATIVE_INT, fspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if ((fd = HDopen(FILE_NAME_1, O_RDONLY, 0666)) < 0) + goto error; - if(FILL_RANDOM==fill_style) + if (FILL_RANDOM == fill_style) had = (int *)calloc((size_t)cur_size[0], sizeof(int)); - - for (i=1; i<=cur_size[0]; i++) { + + for (i = 1; i <= cur_size[0]; i++) { /* Decide which chunk to write to */ switch (fill_style) { - case FILL_FORWARD: - hs_start[0] = i-1; - break; - case FILL_REVERSE: - hs_start[0] = cur_size[0]-i; - break; - case FILL_INWARD: - hs_start[0] = i%2 ? i/2 : cur_size[0]-i/2; - break; - case FILL_OUTWARD: - k = (cur_size[0] - i) + 1; - hs_start[0] = k % 2 ? (k / 2) : (hsize_t)((hssize_t)cur_size[0] - (hssize_t)(k / 2)); - break; - case FILL_RANDOM: - for (j=HDrand()%(int)cur_size[0]; had[j]; j=(j+1)%(int)cur_size[0]) - /*void*/; - hs_start[0] = (hsize_t)j; - had[j] = 1; - break; - case FILL_ALL: - abort(); - default: - /* unknown request */ - HDfprintf(stderr, "Unknown fill style\n"); - goto error; - break; + case FILL_FORWARD: + hs_start[0] = i - 1; + break; + case FILL_REVERSE: + hs_start[0] = cur_size[0] - i; + break; + case FILL_INWARD: + hs_start[0] = i % 2 ? i / 2 : cur_size[0] - i / 2; + break; + case FILL_OUTWARD: + k = (cur_size[0] - i) + 1; + hs_start[0] = k % 2 ? (k / 2) : (hsize_t)((hssize_t)cur_size[0] - (hssize_t)(k / 2)); + break; + case FILL_RANDOM: + for (j = HDrand() % (int)cur_size[0]; had[j]; j = (j + 1) % (int)cur_size[0]) + /*void*/; + hs_start[0] = (hsize_t)j; + had[j] = 1; + break; + case FILL_ALL: + abort(); + default: + /* unknown request */ + HDfprintf(stderr, "Unknown fill style\n"); + goto error; + break; } /* Write the chunk */ - if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_start, NULL, - hs_count, NULL) < 0) goto error; + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_start, NULL, hs_count, NULL) < 0) + goto error; if (H5Dwrite(dset, H5T_NATIVE_INT, mspace, fspace, xfer, &i) < 0) { goto error; } /* Determine overhead */ if (verbose) { - if (H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; - if (HDfstat(fd, &sb) < 0) goto error; - printf("%4lu %8.3f ***\n", - (unsigned long)i, - (double)(sb.st_size - (HDoff_t)(i * sizeof(int))) / (double)i); + if (H5Fflush(file, H5F_SCOPE_LOCAL) < 0) + goto error; + if (HDfstat(fd, &sb) < 0) + goto error; + printf("%4lu %8.3f ***\n", (unsigned long)i, + (double)(sb.st_size - (HDoff_t)(i * sizeof(int))) / (double)i); } } - if(had) { + if (had) { free(had); had = NULL; } /* end if */ @@ -283,53 +276,52 @@ test(fill_t fill_style, const double splits[], if (!verbose) { switch (fill_style) { - case FILL_FORWARD: - sname = "forward"; - break; - case FILL_REVERSE: - sname = "reverse"; - break; - case FILL_INWARD: - sname = "inward"; - break; - case FILL_OUTWARD: - sname = "outward"; - break; - case FILL_RANDOM: - sname = "random"; - break; - case FILL_ALL: - abort(); - default: - /* unknown request */ - HDfprintf(stderr, "Unknown fill style\n"); - goto error; - break; + case FILL_FORWARD: + sname = "forward"; + break; + case FILL_REVERSE: + sname = "reverse"; + break; + case FILL_INWARD: + sname = "inward"; + break; + case FILL_OUTWARD: + sname = "outward"; + break; + case FILL_RANDOM: + sname = "random"; + break; + case FILL_ALL: + abort(); + default: + /* unknown request */ + HDfprintf(stderr, "Unknown fill style\n"); + goto error; + break; } - if (HDfstat(fd, &sb) < 0) goto error; + if (HDfstat(fd, &sb) < 0) + goto error; printf("%-7s %8.3f\n", sname, - (double)(sb.st_size - (HDoff_t)(cur_size[0] * sizeof(int))) / - (double)cur_size[0]); + (double)(sb.st_size - (HDoff_t)(cur_size[0] * sizeof(int))) / (double)cur_size[0]); } HDclose(fd); return 0; - error: +error: H5Dclose(dset); H5Sclose(mspace); H5Sclose(fspace); H5Pclose(dcpl); H5Pclose(xfer); H5Fclose(file); - if(had) + if (had) free(had); HDclose(fd); return 1; } - /*------------------------------------------------------------------------- * Function: main * @@ -349,58 +341,70 @@ test(fill_t fill_style, const double splits[], int main(int argc, char *argv[]) { - hid_t xfer; + hid_t xfer; fill_t fill_style = FILL_ALL; - hbool_t use_cache = FALSE; + hbool_t use_cache = FALSE; double splits[3]; - int i, j, nerrors=0; + int i, j, nerrors = 0; /* Default split ratios */ H5Eset_auto2(H5E_DEFAULT, display_error_cb, NULL); - if((xfer = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; - if(H5Pget_btree_ratios(xfer, splits+0, splits+1, splits+2) < 0) goto error; - if(H5Pclose(xfer) < 0) goto error; + if ((xfer = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; + if (H5Pget_btree_ratios(xfer, splits + 0, splits + 1, splits + 2) < 0) + goto error; + if (H5Pclose(xfer) < 0) + goto error; /* Parse command-line options */ - for(i = 1, j = 0; i < argc; i++) { + for (i = 1, j = 0; i < argc; i++) { if (!strcmp(argv[i], "forward")) { fill_style = FILL_FORWARD; - } else if (!strcmp(argv[i], "reverse")) { + } + else if (!strcmp(argv[i], "reverse")) { fill_style = FILL_REVERSE; - } else if (!strcmp(argv[i], "inward")) { + } + else if (!strcmp(argv[i], "inward")) { fill_style = FILL_INWARD; - } else if (!strcmp(argv[i], "outward")) { + } + else if (!strcmp(argv[i], "outward")) { fill_style = FILL_OUTWARD; - } else if (!strcmp(argv[i], "random")) { + } + else if (!strcmp(argv[i], "random")) { fill_style = FILL_RANDOM; - } else if (!strcmp(argv[i], "cache")) { + } + else if (!strcmp(argv[i], "cache")) { use_cache = TRUE; - } else if (j<3 && (isdigit(argv[i][0]) || '.'==argv[i][0])) { + } + else if (j < 3 && (isdigit(argv[i][0]) || '.' == argv[i][0])) { splits[j++] = strtod(argv[i], NULL); - } else { + } + else { usage(argv[0]); } } - if (FILL_ALL==fill_style) { + if (FILL_ALL == fill_style) { printf("%-7s %8s\n", "Style", "Bytes/Chunk"); printf("%-7s %8s\n", "-----", "-----------"); nerrors += test(FILL_FORWARD, splits, FALSE, use_cache); nerrors += test(FILL_REVERSE, splits, FALSE, use_cache); - nerrors += test(FILL_INWARD, splits, FALSE, use_cache); + nerrors += test(FILL_INWARD, splits, FALSE, use_cache); nerrors += test(FILL_OUTWARD, splits, FALSE, use_cache); - nerrors += test(FILL_RANDOM, splits, FALSE, use_cache); - } + nerrors += test(FILL_RANDOM, splits, FALSE, use_cache); + } else { - if (use_cache) usage(argv[0]); - nerrors += test(fill_style, splits, TRUE, FALSE); + if (use_cache) + usage(argv[0]); + nerrors += test(fill_style, splits, TRUE, FALSE); } - if (nerrors>0) goto error; + if (nerrors > 0) + goto error; cleanup(); return 0; - error: +error: HDfprintf(stderr, "*** ERRORS DETECTED ***\n"); return 1; } diff --git a/tools/test/perform/perf.c b/tools/test/perform/perf.c deleted file mode 100644 index 34b8a2d..0000000 --- a/tools/test/perform/perf.c +++ /dev/null @@ -1,495 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Author: Albert Cheng of NCSA, May 1, 2001. - * This is derived from code given to me by Robert Ross. - * - * NOTE: This code assumes that all command line arguments make it out to all - * the processes that make up the parallel job, which isn't always the case. - * So if it doesn't work on some platform, that might be why. - */ - -#include "hdf5.h" -#include "H5private.h" -#include "h5test.h" - -#ifdef H5_HAVE_PARALLEL - -#ifdef H5_STDC_HEADERS -#include <errno.h> -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#endif - -#ifdef H5_HAVE_UNISTD_H -#include <sys/types.h> -#include <unistd.h> -#endif - -#ifdef H5_HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif - -#if defined(H5_TIME_WITH_SYS_TIME) -# include <sys/time.h> -# include <time.h> -#elif defined(H5_HAVE_SYS_TIME_H) -# include <sys/time.h> -#else -# include <time.h> -#endif - -#include <mpi.h> -#ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */ -# include <mpio.h> -#endif - -/* Macro definitions */ -/* Verify: - * if val is false (0), print mesg and if fatal is true (non-zero), die. - */ -#define H5FATAL 1 -#define VRFY(val, mesg, fatal) do { \ - if (!val) { \ - printf("Proc %d: ", mynod); \ - printf("*** Assertion failed (%s) at line %4d in %s\n", \ - mesg, (int)__LINE__, __FILE__); \ - if (fatal){ \ - fflush(stdout); \ - goto die_jar_jar_die; \ - } \ - } \ -} while(0) -#define RANK 1 -#define MAX_PATH 1024 - -hsize_t dims[RANK]; /* dataset dim sizes */ -hsize_t block[RANK], stride[RANK], count[RANK]; -hsize_t start[RANK]; -hid_t fid; /* HDF5 file ID */ -hid_t acc_tpl; /* File access templates */ -hid_t sid; /* Dataspace ID */ -hid_t file_dataspace; /* File dataspace ID */ -hid_t mem_dataspace; /* memory dataspace ID */ -hid_t dataset; /* Dataset ID */ -hsize_t opt_alignment = 1; -hsize_t opt_threshold = 1; -int opt_split_vfd = 0; -char *meta_ext, *raw_ext; /* holds the meta and raw file extension if */ - /* opt_split_vfd is set */ - - -/* DEFAULT VALUES FOR OPTIONS */ -int64_t opt_block = 1048576*16; -int opt_iter = 1; -int opt_stripe = -1; -int opt_correct = 0; -int amode = O_RDWR | O_CREAT; -char opt_file[256] = "perftest.out"; -char opt_pvfstab[256] = "notset"; -int opt_pvfstab_set = 0; - -const char *FILENAME[] = { - opt_file, - NULL -}; - -/* function prototypes */ -static int parse_args(int argc, char **argv); - -extern int errno; - -/* globals needed for getopt */ -extern char *optarg; - -int main(int argc, char **argv) -{ - char *buf, *tmp, *buf2, *tmp2, *check; - int i, j, mynod=0, nprocs=1, err, my_correct = 1, correct, myerrno; - double stim, etim; - double write_tim = 0; - double read_tim = 0; - double read_bw, write_bw; - double max_read_tim, max_write_tim; - double min_read_tim, min_write_tim; - double ave_read_tim, ave_write_tim; - int64_t iter_jump = 0; - int64_t seek_position = 0; - MPI_File fh; - MPI_Status status; - int nchars; - char filename[MAX_PATH]; - herr_t ret; /* Generic return value */ - - /* startup MPI and determine the rank of this process */ - MPI_Init(&argc,&argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &mynod); - - /* parse the command line arguments */ - parse_args(argc, argv); - - if (mynod == 0) printf("# Using hdf5-io calls.\n"); - - /* kindof a weird hack- if the location of the pvfstab file was - * specified on the command line, then spit out this location into - * the appropriate environment variable: */ - -#if H5_HAVE_SETENV -/* no setenv or unsetenv */ - if (opt_pvfstab_set) { - if((setenv("PVFSTAB_FILE", opt_pvfstab, 1)) < 0){ - perror("setenv"); - goto die_jar_jar_die; - } - } -#endif - - /* this is how much of the file data is covered on each iteration of - * the test. used to help determine the seek offset on each - * iteration */ - iter_jump = nprocs * opt_block; - - /* setup a buffer of data to write */ - if (!(tmp = (char *) malloc(opt_block + 256))) { - perror("malloc"); - goto die_jar_jar_die; - } - buf = tmp + 128 - (((long)tmp) % 128); /* align buffer */ - - if (opt_correct) { - /* do the same buffer setup for verifiable data */ - if (!(tmp2 = (char *) malloc(opt_block + 256))) { - perror("malloc2"); - goto die_jar_jar_die; - } - buf2 = tmp + 128 - (((long)tmp) % 128); - } - - /* setup file access template with parallel IO access. */ - if (opt_split_vfd){ - hid_t mpio_pl; - - mpio_pl = H5Pcreate (H5P_FILE_ACCESS); - VRFY((acc_tpl >= 0), "", H5FATAL); - ret = H5Pset_fapl_mpio(mpio_pl, MPI_COMM_WORLD, MPI_INFO_NULL); - VRFY((ret >= 0), "", H5FATAL); - - /* set optional allocation alignment */ - if (opt_alignment*opt_threshold != 1){ - ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment ); - VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL); - } - - /* setup file access template */ - acc_tpl = H5Pcreate (H5P_FILE_ACCESS); - VRFY((acc_tpl >= 0), "", H5FATAL); - ret = H5Pset_fapl_split(acc_tpl, meta_ext, mpio_pl, raw_ext, mpio_pl); - VRFY((ret >= 0), "H5Pset_fapl_split succeeded", H5FATAL); - ret = H5Pclose(mpio_pl); - VRFY((ret >= 0), "H5Pclose mpio_pl succeeded", H5FATAL); - }else{ - /* setup file access template */ - acc_tpl = H5Pcreate (H5P_FILE_ACCESS); - VRFY((acc_tpl >= 0), "", H5FATAL); - ret = H5Pset_fapl_mpio(acc_tpl, MPI_COMM_WORLD, MPI_INFO_NULL); - VRFY((ret >= 0), "", H5FATAL); - - /* set optional allocation alignment */ - if (opt_alignment*opt_threshold != 1){ - ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment ); - VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL); - } - } - - h5_fixname_no_suffix(FILENAME[0], acc_tpl, filename, sizeof filename); - - /* create the parallel file */ - fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); - VRFY((fid >= 0), "H5Fcreate succeeded", H5FATAL); - - /* define a contiquous dataset of opt_iter*nprocs*opt_block chars */ - dims[0] = opt_iter * nprocs * opt_block; - sid = H5Screate_simple(RANK, dims, NULL); - VRFY((sid >= 0), "H5Screate_simple succeeded", H5FATAL); - dataset = H5Dcreate2(fid, "Dataset1", H5T_NATIVE_CHAR, sid, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - VRFY((dataset >= 0), "H5Dcreate2 succeeded", H5FATAL); - - /* create the memory dataspace and the file dataspace */ - dims[0] = opt_block; - mem_dataspace = H5Screate_simple(RANK, dims, NULL); - VRFY((mem_dataspace >= 0), "", H5FATAL); - file_dataspace = H5Dget_space(dataset); - VRFY((file_dataspace >= 0), "H5Dget_space succeeded", H5FATAL); - - /* now each process writes a block of opt_block chars in round robbin - * fashion until the whole dataset is covered. - */ - for(j=0; j < opt_iter; j++) { - /* setup a file dataspace selection */ - start[0] = (hsize_t)((j * iter_jump) + (mynod * opt_block)); - stride[0] = block[0] = opt_block; - count[0]= 1; - ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0), "H5Sset_hyperslab succeeded", H5FATAL); - - if (opt_correct) /* fill in buffer for iteration */ { - for (i=mynod+j, check=buf; i<opt_block; i++,check++) *check=(char)i; - } - - /* discover the starting time of the operation */ - MPI_Barrier(MPI_COMM_WORLD); - stim = MPI_Wtime(); - - /* write data */ - ret = H5Dwrite(dataset, H5T_NATIVE_CHAR, mem_dataspace, file_dataspace, - H5P_DEFAULT, buf); - VRFY((ret >= 0), "H5Dwrite dataset1 succeeded", !H5FATAL); - - /* discover the ending time of the operation */ - etim = MPI_Wtime(); - - write_tim += (etim - stim); - - /* we are done with this "write" iteration */ - } - - /* close dataset and file */ - ret=H5Dclose(dataset); - VRFY((ret >= 0), "H5Dclose succeeded", H5FATAL); - ret=H5Fclose(fid); - VRFY((ret >= 0), "H5Fclose succeeded", H5FATAL); - - - - /* wait for everyone to synchronize at this point */ - MPI_Barrier(MPI_COMM_WORLD); - - /* reopen the file for reading */ - fid=H5Fopen(filename,H5F_ACC_RDONLY,acc_tpl); - VRFY((fid >= 0), "", H5FATAL); - - /* open the dataset */ - dataset = H5Dopen2(fid, "Dataset1", H5P_DEFAULT); - VRFY((dataset >= 0), "H5Dopen succeeded", H5FATAL); - - /* we can re-use the same mem_dataspace and file_dataspace - * the H5Dwrite used since the dimension size is the same. - */ - - /* we are going to repeat the read the same pattern the write used */ - for (j=0; j < opt_iter; j++) { - /* setup a file dataspace selection */ - start[0] = (hsize_t)((j * iter_jump) + (mynod * opt_block)); - stride[0] = block[0] = opt_block; - count[0]= 1; - ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0), "H5Sset_hyperslab succeeded", H5FATAL); - /* seek to the appropriate spot give the current iteration and - * rank within the MPI processes */ - - /* discover the start time */ - MPI_Barrier(MPI_COMM_WORLD); - stim = MPI_Wtime(); - - /* read in the file data */ - if (!opt_correct){ - ret = H5Dread(dataset, H5T_NATIVE_CHAR, mem_dataspace, file_dataspace, H5P_DEFAULT, buf); - } - else{ - ret = H5Dread(dataset, H5T_NATIVE_CHAR, mem_dataspace, file_dataspace, H5P_DEFAULT, buf2); - } - myerrno = errno; - - /* discover the end time */ - etim = MPI_Wtime(); - read_tim += (etim - stim); - VRFY((ret >= 0), "H5Dwrite dataset1 succeeded", !H5FATAL); - - - if (ret < 0) HDfprintf(stderr, "node %d, read error, loc = %Ld: %s\n", - mynod, mynod*opt_block, strerror(myerrno)); - - /* if the user wanted to check correctness, compare the write - * buffer to the read buffer */ - if (opt_correct && memcmp(buf, buf2, opt_block)) { - HDfprintf(stderr, "node %d, correctness test failed\n", mynod); - my_correct = 0; - MPI_Allreduce(&my_correct, &correct, 1, MPI_INT, MPI_MIN, - MPI_COMM_WORLD); - } - - /* we are done with this read iteration */ - } - - /* close dataset and file */ - ret=H5Dclose(dataset); - VRFY((ret >= 0), "H5Dclose succeeded", H5FATAL); - ret=H5Fclose(fid); - VRFY((ret >= 0), "H5Fclose succeeded", H5FATAL); - ret=H5Pclose(acc_tpl); - VRFY((ret >= 0), "H5Pclose succeeded", H5FATAL); - - /* compute the read and write times */ - MPI_Allreduce(&read_tim, &max_read_tim, 1, MPI_DOUBLE, MPI_MAX, - MPI_COMM_WORLD); - MPI_Allreduce(&read_tim, &min_read_tim, 1, MPI_DOUBLE, MPI_MIN, - MPI_COMM_WORLD); - MPI_Allreduce(&read_tim, &ave_read_tim, 1, MPI_DOUBLE, MPI_SUM, - MPI_COMM_WORLD); - - /* calculate the average from the sum */ - ave_read_tim = ave_read_tim / nprocs; - - MPI_Allreduce(&write_tim, &max_write_tim, 1, MPI_DOUBLE, MPI_MAX, - MPI_COMM_WORLD); - MPI_Allreduce(&write_tim, &min_write_tim, 1, MPI_DOUBLE, MPI_MIN, - MPI_COMM_WORLD); - MPI_Allreduce(&write_tim, &ave_write_tim, 1, MPI_DOUBLE, MPI_SUM, - MPI_COMM_WORLD); - - /* calculate the average from the sum */ - ave_write_tim = ave_write_tim / nprocs; - - /* print out the results on one node */ - if (mynod == 0) { - read_bw = ((int64_t)(opt_block*nprocs*opt_iter))/(max_read_tim*1000000.0); - write_bw = ((int64_t)(opt_block*nprocs*opt_iter))/(max_write_tim*1000000.0); - - printf("nr_procs = %d, nr_iter = %d, blk_sz = %ld\n", nprocs, - opt_iter, (long)opt_block); - - printf("# total_size = %ld\n", (long)(opt_block*nprocs*opt_iter)); - - printf("# Write: min_time = %f, max_time = %f, mean_time = %f\n", - min_write_tim, max_write_tim, ave_write_tim); - printf("# Read: min_time = %f, max_time = %f, mean_time = %f\n", - min_read_tim, max_read_tim, ave_read_tim); - - printf("Write bandwidth = %f Mbytes/sec\n", write_bw); - printf("Read bandwidth = %f Mbytes/sec\n", read_bw); - - if (opt_correct) { - printf("Correctness test %s.\n", correct ? "passed" : "failed"); - } - } - - -die_jar_jar_die: - -#if H5_HAVE_SETENV -/* no setenv or unsetenv */ - /* clear the environment variable if it was set earlier */ - if (opt_pvfstab_set){ - unsetenv("PVFSTAB_FILE"); - } -#endif - - free(tmp); - if (opt_correct) free(tmp2); - - MPI_Finalize(); - - return(0); -} - -static int -parse_args(int argc, char **argv) -{ - int c; - - while ((c = getopt(argc, argv, "s:b:i:f:p:a:2:c")) != EOF) { - switch (c) { - case 's': /* stripe */ - opt_stripe = atoi(optarg); - break; - case 'b': /* block size */ - opt_block = atoi(optarg); - break; - case 'i': /* iterations */ - opt_iter = atoi(optarg); - break; - case 'f': /* filename */ - strncpy(opt_file, optarg, 255); - FILENAME[0] = opt_file; - break; - case 'p': /* pvfstab file */ - strncpy(opt_pvfstab, optarg, 255); - opt_pvfstab_set = 1; - break; - case 'a': /* aligned allocation. - * syntax: -a<alignment>/<threshold> - * e.g., -a4096/512 allocate at 4096 bytes - * boundary if request size >= 512. - */ - { - char *p; - - opt_alignment = HDatoi(optarg); - if(NULL != (p = (char*)HDstrchr(optarg, '/'))) - opt_threshold = HDatoi(p + 1); - } - HDfprintf(stdout, - "alignment/threshold=%Hu/%Hu\n", - opt_alignment, opt_threshold); - break; - case '2': /* use 2-files, i.e., split file driver */ - opt_split_vfd=1; - /* get meta and raw file extension. */ - /* syntax is <raw_ext>,<meta_ext> */ - meta_ext = raw_ext = optarg; - while (*raw_ext != '\0'){ - if (*raw_ext == ','){ - *raw_ext = '\0'; - raw_ext++; - break; - } - raw_ext++; - } - printf("split-file-vfd used: %s,%s\n", - meta_ext, raw_ext); - break; - case 'c': /* correctness */ - opt_correct = 1; - break; - case '?': /* unknown */ - default: - break; - } - } - - return(0); -} - -/* - * Local variables: - * c-indent-level: 3 - * c-basic-offset: 3 - * tab-width: 3 - * End: - */ - -#else /* H5_HAVE_PARALLEL */ -/* dummy program since H5_HAVE_PARALLEL is not configured in */ -int -main(int H5_ATTR_UNUSED argc, char H5_ATTR_UNUSED **argv) -{ - printf("No parallel performance because parallel is not configured in\n"); - return(0); -} -#endif /* H5_HAVE_PARALLEL */ - diff --git a/tools/test/perform/perf_meta.c b/tools/test/perform/perf_meta.c index b56f074..ad76711 100644 --- a/tools/test/perform/perf_meta.c +++ b/tools/test/perform/perf_meta.c @@ -6,13 +6,13 @@ * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Raymond Lu <slu@ncsa.uiuc.edu> + * Programmer: Raymond Lu * Friday, Oct 3, 2004 * * Purpose: Tests performance of metadata @@ -21,39 +21,33 @@ #include "h5test.h" #ifdef H5_HAVE_PARALLEL -#define MAINPROCESS (!mpi_rank) /* define process 0 as main process */ -#endif /*H5_HAVE_PARALLEL*/ +#define MAINPROCESS (!mpi_rank) /* define process 0 as main process */ +#endif /*H5_HAVE_PARALLEL*/ /* File_Access_type bits */ -#define FACC_DEFAULT 0x0 /* serial as default */ -#define FACC_MPIO 0x1 /* MPIO */ +#define FACC_DEFAULT 0x0 /* serial as default */ +#define FACC_MPIO 0x1 /* MPIO */ /* Which test to run */ -int RUN_TEST = 0x0; /* all tests as default */ -int TEST_1 = 0x1; /* Test 1 */ -int TEST_2 = 0x2; /* Test 2 */ -int TEST_3 = 0x4; /* Test 3 */ - +int RUN_TEST = 0x0; /* all tests as default */ +int TEST_1 = 0x1; /* Test 1 */ +int TEST_2 = 0x2; /* Test 2 */ +int TEST_3 = 0x4; /* Test 3 */ -const char *FILENAME[] = { - "meta_perf_1", - "meta_perf_2", - "meta_perf_3", - NULL -}; +const char *FILENAME[] = {"meta_perf_1", "meta_perf_2", "meta_perf_3", NULL}; /* Default values for performance. Can be changed through command line options */ -int NUM_DSETS = 16; -int NUM_ATTRS = 8; -int BATCH_ATTRS = 2; -hbool_t flush_dset = FALSE; -hbool_t flush_attr = FALSE; -int nerrors = 0; /* errors count */ -hid_t fapl; +int NUM_DSETS = 16; +int NUM_ATTRS = 8; +int BATCH_ATTRS = 2; +hbool_t flush_dset = FALSE; +hbool_t flush_attr = FALSE; +int nerrors = 0; /* errors count */ +hid_t fapl; /* Data space IDs */ -hid_t space; -hid_t small_space; +hid_t space; +hid_t small_space; /* Performance data */ typedef struct p_time { @@ -68,11 +62,10 @@ typedef struct p_time { /*Test file access type for parallel. MPIO as default */ int facc_type = FACC_DEFAULT; -double retrieve_time(void); -void perf(p_time *perf_t, double start_t, double end_t); -void print_perf(p_time, p_time, p_time); +double retrieve_time(void); +void perf(p_time *perf_t, double start_t, double end_t); +void print_perf(p_time, p_time, p_time); - /*------------------------------------------------------------------------- * Function: parse_options * @@ -91,108 +84,108 @@ parse_options(int argc, char **argv) int t; /* Use default values */ - if(argc==1) - return(0); - - while (--argc){ - if (**(++argv) != '-'){ - break; - }else{ - switch(*(*argv+1)){ - case 'h': /* Help page */ - return(1); - - case 'd': /* Number of datasets */ - NUM_DSETS = atoi((*argv+1)+1); - if (NUM_DSETS < 0){ - nerrors++; - return(1); - } - break; - - case 'a': /* Number of attributes per dataset */ - NUM_ATTRS = atoi((*argv+1)+1); - if (NUM_ATTRS < 0){ - nerrors++; - return(1); - } - break; - - case 'n': /* Number of attributes to be created in batch */ - BATCH_ATTRS = atoi((*argv+1)+1); - if (BATCH_ATTRS < 0){ - nerrors++; - return(1); - } - break; - - case 'm': /* Use the MPI-IO driver */ - facc_type = FACC_MPIO; - break; - - case 'f': /* Call H5Fflush for each dataset or attribute */ - if(!strcmp("a", (*argv+2))) - flush_attr = TRUE; - else if(!strcmp("d", (*argv+2))) - flush_dset = TRUE; - else { - nerrors++; - return(1); - } - break; - - case 't': /* Which test to run */ - t = atoi((*argv+1)+1); - if (t < 1 || t > 3){ - nerrors++; - return(1); - } - if(t == 1) - RUN_TEST |= TEST_1; - else if(t == 2) - RUN_TEST |= TEST_2; - else - RUN_TEST |= TEST_3; - - break; - - default: nerrors++; - return(1); - } - } + if (argc == 1) + return (0); + + while (--argc) { + if (**(++argv) != '-') { + break; + } + else { + switch (*(*argv + 1)) { + case 'h': /* Help page */ + return (1); + + case 'd': /* Number of datasets */ + NUM_DSETS = atoi((*argv + 1) + 1); + if (NUM_DSETS < 0) { + nerrors++; + return (1); + } + break; + + case 'a': /* Number of attributes per dataset */ + NUM_ATTRS = atoi((*argv + 1) + 1); + if (NUM_ATTRS < 0) { + nerrors++; + return (1); + } + break; + + case 'n': /* Number of attributes to be created in batch */ + BATCH_ATTRS = atoi((*argv + 1) + 1); + if (BATCH_ATTRS < 0) { + nerrors++; + return (1); + } + break; + + case 'm': /* Use the MPI-IO driver */ + facc_type = FACC_MPIO; + break; + + case 'f': /* Call H5Fflush for each dataset or attribute */ + if (!strcmp("a", (*argv + 2))) + flush_attr = TRUE; + else if (!strcmp("d", (*argv + 2))) + flush_dset = TRUE; + else { + nerrors++; + return (1); + } + break; + + case 't': /* Which test to run */ + t = atoi((*argv + 1) + 1); + if (t < 1 || t > 3) { + nerrors++; + return (1); + } + if (t == 1) + RUN_TEST |= TEST_1; + else if (t == 2) + RUN_TEST |= TEST_2; + else + RUN_TEST |= TEST_3; + + break; + + default: + nerrors++; + return (1); + } + } } /*while*/ /* Check valid values */ #ifndef H5_HAVE_PARALLEL - if(facc_type == FACC_MPIO) - { + if (facc_type == FACC_MPIO) { nerrors++; - return(1); + return (1); } #endif /*H5_HAVE_PARALLEL*/ - if(NUM_ATTRS && !BATCH_ATTRS) + if (NUM_ATTRS && !BATCH_ATTRS) NUM_ATTRS = 0; - if(!NUM_ATTRS && BATCH_ATTRS) + if (!NUM_ATTRS && BATCH_ATTRS) BATCH_ATTRS = 0; - if(!NUM_DSETS) { + if (!NUM_DSETS) { nerrors++; - return(1); + return (1); } - if(NUM_ATTRS && BATCH_ATTRS) { - if(BATCH_ATTRS > NUM_ATTRS || NUM_ATTRS % BATCH_ATTRS) { - nerrors++; - return(1); + if (NUM_ATTRS && BATCH_ATTRS) { + if (BATCH_ATTRS > NUM_ATTRS || NUM_ATTRS % BATCH_ATTRS) { + nerrors++; + return (1); } } - return(0); + return (0); } - /*------------------------------------------------------------------------- * Function: usage * @@ -212,39 +205,38 @@ usage(void) "[-a<num_attributes>]\n" "\t[-n<batch_attributes>] [-f<option>] [-t<test>]\n"); printf("\t-h" - "\t\t\thelp page.\n"); + "\t\t\thelp page.\n"); printf("\t-m" - "\t\t\tset MPIO as the file driver when parallel HDF5\n" - "\t\t\t\tis enabled. -m must be specified\n" - "\t\t\t\twhen running parallel program.\n"); + "\t\t\tset MPIO as the file driver when parallel HDF5\n" + "\t\t\t\tis enabled. -m must be specified\n" + "\t\t\t\twhen running parallel program.\n"); printf("\t-d<num_datasets>" - "\tset number of datasets for meta data \n" - "\t\t\t\tperformance test\n"); + "\tset number of datasets for meta data \n" + "\t\t\t\tperformance test\n"); printf("\t-a<num_attributes>" - "\tset number of attributes per dataset for meta \n" - "\t\t\t\tdata performance test.\n"); + "\tset number of attributes per dataset for meta \n" + "\t\t\t\tdata performance test.\n"); printf("\t-n<batch_attributes>" - "\tset batch number of attributes for dataset \n" - "\t\t\t\tfor meta data performance test.\n"); + "\tset batch number of attributes for dataset \n" + "\t\t\t\tfor meta data performance test.\n"); printf("\t-f<option>" - "\t\tflush data to disk after closing a dataset \n" - "\t\t\t\tor attribute. Valid options are \"d\" for \n" - "\t\t\t\tdataset, \"a\" for attribute. Disabled is \n" - "\t\t\t\tthe default.\n"); + "\t\tflush data to disk after closing a dataset \n" + "\t\t\t\tor attribute. Valid options are \"d\" for \n" + "\t\t\t\tdataset, \"a\" for attribute. Disabled is \n" + "\t\t\t\tthe default.\n"); printf("\t-t<tests>" - "\t\trun specific test. Give only one number each \n" - "\t\t\t\ttime. i.e. \"-t1 -t3\" will run test 1 and 3. \n" - "\t\t\t\tDefault is all three tests. The 3 tests are: \n\n" - "\t\t\t\t1. Create <num_attributes> attributes for each \n" - "\t\t\t\t of <num_datasets> existing datasets.\n" - "\t\t\t\t2. Create <num_attributes> attributes for each \n" - "\t\t\t\t of <num_datasets> new datasets.\n" - "\t\t\t\t3. Create <batch_attributes> attributes for \n" - "\t\t\t\t each of <num_dataset> new datasets for \n" - "\t\t\t\t <num_attributes>/<batch_attributes> times.\n"); + "\t\trun specific test. Give only one number each \n" + "\t\t\t\ttime. i.e. \"-t1 -t3\" will run test 1 and 3. \n" + "\t\t\t\tDefault is all three tests. The 3 tests are: \n\n" + "\t\t\t\t1. Create <num_attributes> attributes for each \n" + "\t\t\t\t of <num_datasets> existing datasets.\n" + "\t\t\t\t2. Create <num_attributes> attributes for each \n" + "\t\t\t\t of <num_datasets> new datasets.\n" + "\t\t\t\t3. Create <batch_attributes> attributes for \n" + "\t\t\t\t each of <num_dataset> new datasets for \n" + "\t\t\t\t <num_attributes>/<batch_attributes> times.\n"); } - /*------------------------------------------------------------------------- * Function: create_dspace * @@ -264,20 +256,20 @@ usage(void) static herr_t create_dspace(void) { - hsize_t dims[2]; - hsize_t small_dims[2]; + hsize_t dims[2]; + hsize_t small_dims[2]; /* Create the data space */ dims[0] = 256; dims[1] = 512; - if((space = H5Screate_simple(2, dims, NULL)) < 0) - goto error; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + goto error; /* Create a small data space for attributes */ small_dims[0] = 16; small_dims[1] = 8; - if((small_space = H5Screate_simple(2, small_dims, NULL)) < 0) - goto error; + if ((small_space = H5Screate_simple(2, small_dims, NULL)) < 0) + goto error; return 0; @@ -285,7 +277,6 @@ error: return -1; } - /*------------------------------------------------------------------------- * Function: create_dsets * @@ -305,20 +296,20 @@ error: static herr_t create_dsets(hid_t file) { - hid_t dataset; - char dset_name[32]; - int i; + hid_t dataset; + char dset_name[32]; + int i; /* * Create a dataset using the default dataset creation properties. */ - for(i = 0; i < NUM_DSETS; i++) { - HDsprintf(dset_name, "dataset %d", i); - if((dataset = H5Dcreate2(file, dset_name, H5T_NATIVE_DOUBLE, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < NUM_DSETS; i++) { + HDsnprintf(dset_name, sizeof(dset_name), "dataset %d", i); + if ((dataset = H5Dcreate2(file, dset_name, H5T_NATIVE_DOUBLE, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) goto error; } /* end for */ @@ -326,10 +317,8 @@ create_dsets(hid_t file) error: return -1; - } - /*------------------------------------------------------------------------- * Function: create_attrs_1 * @@ -349,63 +338,62 @@ error: static herr_t create_attrs_1(void) { - hid_t file, dataset, attr; - char filename[128]; - char dset_name[64]; - char attr_name[128]; - int i, j; - p_time attr_t = {0, 0, 0, 1000000, 0, ""}; - p_time open_t = {0, 0, 0, 1000000, 0, "H5Dopen2"}; - p_time close_t = {0, 0, 0, 1000000, 0, ""}; + hid_t file, dataset, attr; + char filename[128]; + char dset_name[64]; + char attr_name[128]; + int i, j; + p_time attr_t = {0, 0, 0, 1000000, 0, ""}; + p_time open_t = {0, 0, 0, 1000000, 0, "H5Dopen2"}; + p_time close_t = {0, 0, 0, 1000000, 0, ""}; #ifdef H5_HAVE_PARALLEL /* need the rank for printing data */ - int mpi_rank; - if(facc_type == FACC_MPIO) + int mpi_rank; + if (facc_type == FACC_MPIO) MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); #endif /*H5_HAVE_PARALLEL*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, - fapl)) < 0) - goto error; + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; - if(create_dsets(file) < 0) - goto error; + if (create_dsets(file) < 0) + goto error; /* * Create all(user specifies the number) attributes for each dataset */ - for(i = 0; i < NUM_DSETS; i++) { - HDsprintf(dset_name, "dataset %d", i); + for (i = 0; i < NUM_DSETS; i++) { + HDsnprintf(dset_name, sizeof(dset_name), "dataset %d", i); open_t.start = retrieve_time(); - if((dataset = H5Dopen2(file, dset_name, H5P_DEFAULT)) < 0) - goto error; - perf(&open_t, open_t.start, retrieve_time()); + if ((dataset = H5Dopen2(file, dset_name, H5P_DEFAULT)) < 0) + goto error; + perf(&open_t, open_t.start, retrieve_time()); - for(j = 0; j < NUM_ATTRS; j++) { - HDsprintf(attr_name, "all attrs for each dset %d", j); + for (j = 0; j < NUM_ATTRS; j++) { + HDsnprintf(attr_name, sizeof(attr_name), "all attrs for each dset %d", j); attr_t.start = retrieve_time(); - if((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, - small_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, small_space, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr) < 0) + if (H5Aclose(attr) < 0) goto error; perf(&attr_t, attr_t.start, retrieve_time()); - if(flush_attr && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) + if (flush_attr && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; - } /* end for */ + } /* end for */ - close_t.start = retrieve_time(); - if(H5Dclose(dataset) < 0) + close_t.start = retrieve_time(); + if (H5Dclose(dataset) < 0) goto error; - perf(&close_t, close_t.start, retrieve_time()); - if(flush_dset && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) + perf(&close_t, close_t.start, retrieve_time()); + if (flush_dset && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; } /* end for */ - if(facc_type == FACC_MPIO) { + if (facc_type == FACC_MPIO) { #ifdef H5_HAVE_PARALLEL MPI_Barrier(MPI_COMM_WORLD); #endif /*H5_HAVE_PARALLEL*/ @@ -413,21 +401,22 @@ create_attrs_1(void) #ifdef H5_HAVE_PARALLEL if (facc_type == FACC_DEFAULT || (facc_type != FACC_DEFAULT && MAINPROCESS)) /* only process 0 reports */ -#endif /*H5_HAVE_PARALLEL*/ +#endif /*H5_HAVE_PARALLEL*/ { /* Calculate the average time */ open_t.avg = open_t.total / NUM_DSETS; close_t.avg = close_t.total / NUM_DSETS; - if(NUM_ATTRS) - attr_t.avg = attr_t.total / (NUM_ATTRS*NUM_DSETS); + if (NUM_ATTRS) + attr_t.avg = attr_t.total / (NUM_ATTRS * NUM_DSETS); /* Print out the performance result */ - HDfprintf(stderr, "1. Create %d attributes for each of %d existing datasets\n", - NUM_ATTRS, NUM_DSETS); + HDfprintf(stderr, "1. Create %d attributes for each of %d existing datasets\n", NUM_ATTRS, + NUM_DSETS); print_perf(open_t, close_t, attr_t); } - if (H5Fclose(file) < 0) goto error; + if (H5Fclose(file) < 0) + goto error; return 0; @@ -435,7 +424,6 @@ error: return -1; } - /*------------------------------------------------------------------------- * Function: create_attrs_2 * @@ -455,61 +443,61 @@ error: static herr_t create_attrs_2(void) { - hid_t file, dataset, attr; - char filename[128]; - char dset_name[64]; - char attr_name[128]; - int i, j; - p_time attr_t = {0, 0, 0, 1000000, 0, ""}; - p_time create_t = {0, 0, 0, 1000000, 0, "H5Dcreate2"}; - p_time close_t = {0, 0, 0, 1000000, 0, ""}; + hid_t file, dataset, attr; + char filename[128]; + char dset_name[64]; + char attr_name[128]; + int i, j; + p_time attr_t = {0, 0, 0, 1000000, 0, ""}; + p_time create_t = {0, 0, 0, 1000000, 0, "H5Dcreate2"}; + p_time close_t = {0, 0, 0, 1000000, 0, ""}; #ifdef H5_HAVE_PARALLEL /* need the rank for printing data */ - int mpi_rank; - if(facc_type == FACC_MPIO) + int mpi_rank; + if (facc_type == FACC_MPIO) MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); #endif /*H5_HAVE_PARALLEL*/ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - goto error; + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; /* * Create all(user specifies the number) attributes for each new dataset */ - for(i = 0; i < NUM_DSETS; i++) { - HDsprintf(dset_name, "dataset %d", i); + for (i = 0; i < NUM_DSETS; i++) { + HDsnprintf(dset_name, sizeof(dset_name), "dataset %d", i); create_t.start = retrieve_time(); - if((dataset = H5Dcreate2(file, dset_name, H5T_NATIVE_DOUBLE, - space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, dset_name, H5T_NATIVE_DOUBLE, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; - perf(&create_t, create_t.start, retrieve_time()); + perf(&create_t, create_t.start, retrieve_time()); - for(j = 0; j < NUM_ATTRS; j++) { - HDsprintf(attr_name, "all attrs for each dset %d", j); + for (j = 0; j < NUM_ATTRS; j++) { + HDsnprintf(attr_name, sizeof(attr_name), "all attrs for each dset %d", j); attr_t.start = retrieve_time(); - if((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, - small_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, small_space, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr) < 0) + if (H5Aclose(attr) < 0) goto error; perf(&attr_t, attr_t.start, retrieve_time()); - if(flush_attr && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) + if (flush_attr && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; - } /* end for */ + } /* end for */ - close_t.start = retrieve_time(); - if(H5Dclose(dataset) < 0) + close_t.start = retrieve_time(); + if (H5Dclose(dataset) < 0) goto error; - perf(&close_t, close_t.start, retrieve_time()); - if(flush_dset && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) + perf(&close_t, close_t.start, retrieve_time()); + if (flush_dset && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; } /* end for */ #ifdef H5_HAVE_PARALLEL - if(facc_type == FACC_MPIO) + if (facc_type == FACC_MPIO) MPI_Barrier(MPI_COMM_WORLD); #endif /*H5_HAVE_PARALLEL*/ @@ -521,16 +509,16 @@ create_attrs_2(void) /* Calculate the average time */ create_t.avg = create_t.total / NUM_DSETS; close_t.avg = close_t.total / NUM_DSETS; - if(NUM_ATTRS) - attr_t.avg = attr_t.total / (NUM_ATTRS*NUM_DSETS); + if (NUM_ATTRS) + attr_t.avg = attr_t.total / (NUM_ATTRS * NUM_DSETS); /* Print out the performance result */ - HDfprintf(stderr, "2. Create %d attributes for each of %d new datasets\n", - NUM_ATTRS, NUM_DSETS); + HDfprintf(stderr, "2. Create %d attributes for each of %d new datasets\n", NUM_ATTRS, NUM_DSETS); print_perf(create_t, close_t, attr_t); } - if (H5Fclose(file) < 0) goto error; + if (H5Fclose(file) < 0) + goto error; return 0; @@ -538,7 +526,6 @@ error: return -1; } - /*------------------------------------------------------------------------- * Function: create_attrs_3 * @@ -559,70 +546,69 @@ error: static herr_t create_attrs_3(void) { - hid_t file, dataset, attr; - char filename[128]; - char dset_name[64]; - char attr_name[128]; - int loop_num; - int i, j, k; - p_time attr_t = {0, 0, 0, 1000000, 0, ""}; - p_time open_t = {0, 0, 0, 1000000, 0, "H5Dopen2"}; - p_time close_t = {0, 0, 0, 1000000, 0, ""}; + hid_t file, dataset, attr; + char filename[128]; + char dset_name[64]; + char attr_name[128]; + int loop_num; + int i, j, k; + p_time attr_t = {0, 0, 0, 1000000, 0, ""}; + p_time open_t = {0, 0, 0, 1000000, 0, "H5Dopen2"}; + p_time close_t = {0, 0, 0, 1000000, 0, ""}; #ifdef H5_HAVE_PARALLEL /* need the rank for printing data */ - int mpi_rank; - if(facc_type == FACC_MPIO) + int mpi_rank; + if (facc_type == FACC_MPIO) MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); #endif /*H5_HAVE_PARALLEL*/ h5_fixname(FILENAME[2], fapl, filename, sizeof filename); - if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, - fapl)) < 0) - goto error; + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; - if(create_dsets(file) < 0) - goto error; + if (create_dsets(file) < 0) + goto error; /* * Create some(user specifies the number) attributes for each dataset * in a loop */ - loop_num = NUM_ATTRS/BATCH_ATTRS; + loop_num = NUM_ATTRS / BATCH_ATTRS; - for(i = 0; i < loop_num; i++) { - for(j = 0; j < NUM_DSETS; j++) { - HDsprintf(dset_name, "dataset %d", j); + for (i = 0; i < loop_num; i++) { + for (j = 0; j < NUM_DSETS; j++) { + HDsnprintf(dset_name, sizeof(dset_name), "dataset %d", j); open_t.start = retrieve_time(); - if((dataset = H5Dopen2(file, dset_name, H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, dset_name, H5P_DEFAULT)) < 0) goto error; perf(&open_t, open_t.start, retrieve_time()); - for(k = 0; k < BATCH_ATTRS; k++) { - HDsprintf(attr_name, "some attrs for each dset %d %d", i, k); + for (k = 0; k < BATCH_ATTRS; k++) { + HDsnprintf(attr_name, sizeof(attr_name), "some attrs for each dset %d %d", i, k); attr_t.start = retrieve_time(); - if((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, - small_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, small_space, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr) < 0) + if (H5Aclose(attr) < 0) goto error; perf(&attr_t, attr_t.start, retrieve_time()); - if(flush_attr && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) + if (flush_attr && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; } /* end for */ close_t.start = retrieve_time(); - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) goto error; perf(&close_t, close_t.start, retrieve_time()); - if(flush_dset && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) + if (flush_dset && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ #ifdef H5_HAVE_PARALLEL - if(facc_type == FACC_MPIO) + if (facc_type == FACC_MPIO) MPI_Barrier(MPI_COMM_WORLD); #endif /*H5_HAVE_PARALLEL*/ @@ -632,17 +618,18 @@ create_attrs_3(void) #endif /*H5_HAVE_PARALLEL*/ { /* Calculate the average time */ - open_t.avg = open_t.total / (loop_num*NUM_DSETS); - close_t.avg = close_t.total / (loop_num*NUM_DSETS); - attr_t.avg = attr_t.total / (NUM_ATTRS*NUM_DSETS); + open_t.avg = open_t.total / (loop_num * NUM_DSETS); + close_t.avg = close_t.total / (loop_num * NUM_DSETS); + attr_t.avg = attr_t.total / (NUM_ATTRS * NUM_DSETS); /* Print out the performance result */ HDfprintf(stderr, "3. Create %d attributes for each of %d existing datasets for %d times\n", - BATCH_ATTRS, NUM_DSETS, loop_num); + BATCH_ATTRS, NUM_DSETS, loop_num); print_perf(open_t, close_t, attr_t); } - if (H5Fclose(file) < 0) goto error; + if (H5Fclose(file) < 0) + goto error; return 0; @@ -650,7 +637,6 @@ error: return -1; } - /*------------------------------------------------------------------------- * Function: retrieve_time * @@ -663,22 +649,23 @@ error: * *------------------------------------------------------------------------- */ -double retrieve_time(void) +double +retrieve_time(void) { #ifdef H5_HAVE_PARALLEL - if(facc_type == FACC_DEFAULT) { + if (facc_type == FACC_DEFAULT) { #endif /*H5_HAVE_PARALLEL*/ struct timeval t; HDgettimeofday(&t, NULL); return ((double)t.tv_sec + (double)t.tv_usec / 1000000); #ifdef H5_HAVE_PARALLEL - } else { + } + else { return MPI_Wtime(); } #endif /*H5_HAVE_PARALLEL*/ } - /*------------------------------------------------------------------------- * Function: perf * @@ -692,12 +679,13 @@ double retrieve_time(void) * *------------------------------------------------------------------------- */ -void perf(p_time *perf_t, double start_t, double end_t) +void +perf(p_time *perf_t, double start_t, double end_t) { - double t = end_t - start_t; + double t = end_t - start_t; #ifdef H5_HAVE_PARALLEL - if(facc_type == FACC_MPIO) { + if (facc_type == FACC_MPIO) { double reduced_t; double t_max, t_min; int mpi_size, mpi_rank; @@ -706,36 +694,33 @@ void perf(p_time *perf_t, double start_t, double end_t) MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); MPI_Barrier(MPI_COMM_WORLD); - MPI_Reduce(&t, &reduced_t, 1, MPI_DOUBLE, MPI_SUM, 0, - MPI_COMM_WORLD); + MPI_Reduce(&t, &reduced_t, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); reduced_t /= mpi_size; - MPI_Reduce(&t, &t_max, 1, MPI_DOUBLE, MPI_MAX, 0, - MPI_COMM_WORLD); - MPI_Reduce(&t, &t_min, 1, MPI_DOUBLE, MPI_MIN, 0, - MPI_COMM_WORLD); + MPI_Reduce(&t, &t_max, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + MPI_Reduce(&t, &t_min, 1, MPI_DOUBLE, MPI_MIN, 0, MPI_COMM_WORLD); if (MAINPROCESS) { perf_t->total += reduced_t; - if(t_max > perf_t->max) - perf_t->max = t_max; - if(t_min < perf_t->min) - perf_t->min = t_min; + if (t_max > perf_t->max) + perf_t->max = t_max; + if (t_min < perf_t->min) + perf_t->min = t_min; } - } else + } + else #endif /*H5_HAVE_PARALLEL*/ { - perf_t->total += t; + perf_t->total += t; - if(t > perf_t->max) - perf_t->max = t; - if(t < perf_t->min) - perf_t->min = t; + if (t > perf_t->max) + perf_t->max = t; + if (t < perf_t->min) + perf_t->min = t; } } - /*------------------------------------------------------------------------- * Function: print_perf * @@ -748,18 +733,18 @@ void perf(p_time *perf_t, double start_t, double end_t) * *------------------------------------------------------------------------- */ -void print_perf(p_time open_t, p_time close_t, p_time attr_t) +void +print_perf(p_time open_t, p_time close_t, p_time attr_t) { - HDfprintf(stderr, "\t%s:\t\tavg=%.6fs;\tmax=%.6fs;\tmin=%.6fs\n", - open_t.func, open_t.avg, open_t.max, open_t.min); - HDfprintf(stderr, "\tH5Dclose:\t\tavg=%.6fs;\tmax=%.6fs;\tmin=%.6fs\n", - close_t.avg, close_t.max, close_t.min); - if(NUM_ATTRS) - HDfprintf(stderr, "\tH5A(create & close):\tavg=%.6fs;\tmax=%.6fs;\tmin=%.6fs\n", - attr_t.avg, attr_t.max, attr_t.min); + HDfprintf(stderr, "\t%s:\t\tavg=%.6fs;\tmax=%.6fs;\tmin=%.6fs\n", open_t.func, open_t.avg, open_t.max, + open_t.min); + HDfprintf(stderr, "\tH5Dclose:\t\tavg=%.6fs;\tmax=%.6fs;\tmin=%.6fs\n", close_t.avg, close_t.max, + close_t.min); + if (NUM_ATTRS) + HDfprintf(stderr, "\tH5A(create & close):\tavg=%.6fs;\tmax=%.6fs;\tmin=%.6fs\n", attr_t.avg, + attr_t.max, attr_t.min); } - /*------------------------------------------------------------------------- * Function: main * @@ -780,16 +765,16 @@ int main(int argc, char **argv) { #ifdef H5_HAVE_PARALLEL - int mpi_size, mpi_rank; /* mpi variables */ -#endif /*H5_HAVE_PARALLEL*/ + int mpi_size, mpi_rank; /* mpi variables */ +#endif /*H5_HAVE_PARALLEL*/ - if(parse_options(argc, argv) != 0) { - usage(); - return 0; + if (parse_options(argc, argv) != 0) { + usage(); + return 0; } #ifdef H5_HAVE_PARALLEL - if(facc_type == FACC_MPIO) { + if (facc_type == FACC_MPIO) { MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); @@ -801,48 +786,51 @@ main(int argc, char **argv) #endif /*H5_HAVE_PARALLEL*/ HDfprintf(stderr, "\t\tPerformance result of metadata for datasets and attributes\n\n"); - fapl = H5Pcreate (H5P_FILE_ACCESS); + fapl = H5Pcreate(H5P_FILE_ACCESS); #ifdef H5_HAVE_PARALLEL - if(facc_type == FACC_MPIO) + if (facc_type == FACC_MPIO) H5Pset_fapl_mpio(fapl, MPI_COMM_WORLD, MPI_INFO_NULL); #endif /*H5_HAVE_PARALLEL*/ - nerrors += create_dspace() < 0 ?1:0; + nerrors += create_dspace() < 0 ? 1 : 0; - if((RUN_TEST & TEST_1) || !RUN_TEST) - nerrors += create_attrs_1() < 0 ?1:0; - if((RUN_TEST & TEST_2) || !RUN_TEST) - nerrors += create_attrs_2() < 0 ?1:0; - if(((RUN_TEST & TEST_3) || !RUN_TEST) && BATCH_ATTRS && NUM_ATTRS) - nerrors += create_attrs_3() < 0 ?1:0; + if ((RUN_TEST & TEST_1) || !RUN_TEST) + nerrors += create_attrs_1() < 0 ? 1 : 0; + if ((RUN_TEST & TEST_2) || !RUN_TEST) + nerrors += create_attrs_2() < 0 ? 1 : 0; + if (((RUN_TEST & TEST_3) || !RUN_TEST) && BATCH_ATTRS && NUM_ATTRS) + nerrors += create_attrs_3() < 0 ? 1 : 0; - if (H5Sclose(space) < 0) goto error; - if (H5Sclose(small_space) < 0) goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Sclose(small_space) < 0) + goto error; h5_clean_files(FILENAME, fapl); #ifdef H5_HAVE_PARALLEL - if(facc_type == FACC_MPIO) + if (facc_type == FACC_MPIO) /* MPI_Finalize must be called AFTER H5close which may use MPI calls */ MPI_Finalize(); #endif /*H5_HAVE_PARALLEL*/ - if (nerrors) goto error; + if (nerrors) + goto error; #ifdef H5_HAVE_PARALLEL if (facc_type != FACC_DEFAULT && MAINPROCESS) -#endif /*H5_HAVE_PARALLEL*/ printf("All metadata performance tests passed.\n"); +#else + printf("All metadata performance tests passed.\n"); +#endif /*H5_HAVE_PARALLEL*/ return 0; - error: +error: nerrors = MAX(1, nerrors); #ifdef H5_HAVE_PARALLEL if (facc_type != FACC_DEFAULT && MAINPROCESS) #endif /*H5_HAVE_PARALLEL*/ - printf("***** %d PERFORMANCE TEST%s FAILED! *****\n", - nerrors, 1 == nerrors ? "" : "S"); + printf("***** %d PERFORMANCE TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); return 1; } - diff --git a/tools/test/perform/pio_engine.c b/tools/test/perform/pio_engine.c deleted file mode 100644 index 77c04ab..0000000 --- a/tools/test/perform/pio_engine.c +++ /dev/null @@ -1,2685 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * 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://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Author: Albert Cheng of NCSA, Oct 24, 2001. - */ - -#include "hdf5.h" - -#ifdef H5_STDC_HEADERS -#include <errno.h> -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#endif - -#ifdef H5_HAVE_UNISTD_H -#include <sys/types.h> -#include <unistd.h> -#endif - -#ifdef H5_HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif - -#ifdef H5_HAVE_PARALLEL - -#include <mpi.h> - -#ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */ -# include <mpio.h> -#endif /* !MPI_FILE_NULL */ - -#include "pio_perf.h" - -/* Macro definitions */ - -#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 6 -# define H5DCREATE(fd, name, type, space, dcpl) H5Dcreate(fd, name, type, space, dcpl) -# define H5DOPEN(fd, name) H5Dopen(fd, name) -#else -# define H5DCREATE(fd, name, type, space, dcpl) H5Dcreate2(fd, name, type, space, H5P_DEFAULT, dcpl, H5P_DEFAULT) -# define H5DOPEN(fd, name) H5Dopen2(fd, name, H5P_DEFAULT) -#endif - -/* sizes of various items. these sizes won't change during program execution */ -/* The following three must have the same type */ -#define ELMT_SIZE (sizeof(unsigned char)) /* we're doing bytes */ -#define ELMT_MPI_TYPE MPI_BYTE -#define ELMT_H5_TYPE H5T_NATIVE_UCHAR - -#define GOTOERROR(errcode) { ret_code = errcode; goto done; } -#define GOTODONE { goto done; } -#define ERRMSG(mesg) { \ - HDfprintf(stderr, "Proc %d: ", pio_mpi_rank_g); \ - HDfprintf(stderr, "*** Assertion failed (%s) at line %4d in %s\n", \ - mesg, (int)__LINE__, __FILE__); \ -} - -#define MSG(mesg) { \ - HDfprintf(stderr, "Proc %d: ", pio_mpi_rank_g); \ - HDfprintf(stderr, "(%s) at line %4d in %s\n", \ - mesg, (int)__LINE__, __FILE__); \ -} - -/* verify: if val is false (0), print mesg. */ -#define VRFY(val, mesg) do { \ - if (!val) { \ - ERRMSG(mesg); \ - GOTOERROR(FAIL); \ - } \ -} while(0) - - -/* POSIX I/O macros */ -#ifdef H5_HAVE_WIN32_API -/* Can't link against the library, so this test will use the older, non-Unicode - * _open() call on Windows. - */ -#define HDopen(S,F,...) _open(S, F | _O_BINARY, __VA_ARGS__) -#endif /* H5_HAVE_WIN32_API */ -#define POSIXCREATE(fn) HDopen(fn, O_CREAT|O_TRUNC|O_RDWR, 0600) -#define POSIXOPEN(fn, F) HDopen(fn, F, 0600) -#define POSIXCLOSE(F) HDclose(F) -#define POSIXSEEK(F,L) HDlseek(F, L, SEEK_SET) -#define POSIXWRITE(F,B,S) HDwrite(F,B,S) -#define POSIXREAD(F,B,S) HDread(F,B,S) - -enum { - PIO_CREATE = 1, - PIO_WRITE = 2, - PIO_READ = 4 -}; - -/* Global variables */ -static int clean_file_g = -1; /*whether to cleanup temporary test */ -/*files. -1 is not defined; */ -/*0 is no cleanup; 1 is do cleanup */ - -/* - * In a parallel machine, the filesystem suitable for compiling is - * unlikely a parallel file system that is suitable for parallel I/O. - * There is no standard pathname for the parallel file system. /tmp - * is about the best guess. - */ -#ifndef HDF5_PARAPREFIX -# define HDF5_PARAPREFIX "" -#endif /* !HDF5_PARAPREFIX */ - -#ifndef MIN -# define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif /* !MIN */ - -/* the different types of file descriptors we can expect */ -typedef union _file_descr { - int posixfd; /* POSIX file handle*/ - MPI_File mpifd; /* MPI file */ - hid_t h5fd; /* HDF5 file */ -} file_descr; - -/* local functions */ -static char *pio_create_filename(iotype iot, const char *base_name, - char *fullname, size_t size); -static herr_t do_write(results *res, file_descr *fd, parameters *parms, - long ndsets, off_t nelmts, size_t buf_size, void *buffer); -static herr_t do_read(results *res, file_descr *fd, parameters *parms, - long ndsets, off_t nelmts, size_t buf_size, void *buffer /*out*/); -static herr_t do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, - int flags); -static herr_t do_fclose(iotype iot, file_descr *fd); -static void do_cleanupfile(iotype iot, char *fname); - -/* - * Function: do_pio - * Purpose: PIO Engine where Parallel IO are executed. - * Return: results - * Programmer: Albert Cheng, Bill Wendling 2001/12/12 - * Modifications: - * Added 2D testing (Christian Chilan, 10. August 2005) - */ - results -do_pio(parameters param) -{ - /* return codes */ - herr_t ret_code = 0; /*return code */ - results res; - - file_descr fd; - iotype iot; - - char fname[FILENAME_MAX]; - long nf; - long ndsets; - off_t nbytes; /*number of bytes per dataset */ - off_t snbytes; /*general dataset size */ - /*for 1D, it is the actual dataset size */ - /*for 2D, it is the size of a side of the dataset square */ - char *buffer = NULL; /*data buffer pointer */ - size_t buf_size; /*general buffer size in bytes */ - /*for 1D, it is the actual buffer size */ - /*for 2D, it is the length of the buffer rectangle */ - size_t blk_size; /*data block size in bytes */ - size_t bsize; /*actual buffer size */ - - /* HDF5 variables */ - herr_t hrc; /*HDF5 return code */ - - /* Sanity check parameters */ - - /* IO type */ - iot = param.io_type; - - switch (iot) { - case MPIO: - fd.mpifd = MPI_FILE_NULL; - res.timers = io_time_new(MPI_CLOCK); - break; - case POSIXIO: - fd.posixfd = -1; - res.timers = io_time_new(MPI_CLOCK); - break; - case PHDF5: - fd.h5fd = -1; - res.timers = io_time_new(MPI_CLOCK); - break; - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", iot); - GOTOERROR(FAIL); - } - - ndsets = param.num_dsets; /* number of datasets per file */ - nbytes = param.num_bytes; /* number of bytes per dataset */ - buf_size = param.buf_size; - blk_size = param.blk_size; - - if (!param.dim2d){ - snbytes = nbytes; /* General dataset size */ - bsize = buf_size; /* Actual buffer size */ - } - else { - snbytes = (off_t)sqrt(nbytes); /* General dataset size */ - bsize = buf_size * blk_size; /* Actual buffer size */ - } - - if (param.num_files < 0 ) { - HDfprintf(stderr, - "number of files must be >= 0 (%ld)\n", - param.num_files); - GOTOERROR(FAIL); - } - - if (ndsets < 0 ) { - HDfprintf(stderr, - "number of datasets per file must be >= 0 (%ld)\n", - ndsets); - GOTOERROR(FAIL); - } - - if (param.num_procs <= 0 ) { - HDfprintf(stderr, - "maximum number of process to use must be > 0 (%d)\n", - param.num_procs); - GOTOERROR(FAIL); - } - - /* Validate transfer buffer size & block size*/ - if(blk_size<=0) { - HDfprintf(stderr, - "Transfer block size (%zu) must be > 0\n", blk_size); - GOTOERROR(FAIL); - } - if(buf_size<=0) { - HDfprintf(stderr, - "Transfer buffer size (%zu) must be > 0\n", buf_size); - GOTOERROR(FAIL); - } - if ((buf_size % blk_size) != 0){ - HDfprintf(stderr, - "Transfer buffer size (%zu) must be a multiple of the " - "interleaved I/O block size (%zu)\n", - buf_size, blk_size); - GOTOERROR(FAIL); - } - if((snbytes%pio_mpi_nprocs_g)!=0) { - HDfprintf(stderr, - "Dataset size (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " - "number of processes (%d)\n", - (long long)snbytes, pio_mpi_nprocs_g); - GOTOERROR(FAIL); - } - - if (!param.dim2d){ - if(((snbytes/pio_mpi_nprocs_g)%buf_size)!=0) { - HDfprintf(stderr, - "Dataset size/process (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " - "trasfer buffer size (%zu)\n", - (long long)(snbytes/pio_mpi_nprocs_g), buf_size); - GOTOERROR(FAIL); - } - } - else { - if((snbytes%buf_size)!=0) { - HDfprintf(stderr, - "Dataset side size (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " - "trasfer buffer size (%zu)\n", - (long long)snbytes, buf_size); - GOTOERROR(FAIL); - } - } - - /* Allocate transfer buffer */ - if ((buffer = malloc(bsize)) == NULL){ - HDfprintf(stderr, "malloc for transfer buffer size (%zu) failed\n", - bsize); - GOTOERROR(FAIL); - } - - if (pio_debug_level >= 4) { - int myrank; - - MPI_Comm_rank(pio_comm_g, &myrank); - - /* output all of the times for all iterations */ - if (myrank == 0) - HDfprintf(output, "Timer details:\n"); - } - - for (nf = 1; nf <= param.num_files; nf++) { - /* - * Write performance measurement - */ - /* Open file for write */ - char base_name[256]; - - HDsprintf(base_name, "#pio_tmp_%lu", nf); - pio_create_filename(iot, base_name, fname, sizeof(fname)); - if (pio_debug_level > 0) - HDfprintf(output, "rank %d: data filename=%s\n", - pio_mpi_rank_g, fname); - - /* Need barrier to make sure everyone starts at the same time */ - MPI_Barrier(pio_comm_g); - - io_time_set(res.timers, HDF5_GROSS_WRITE_FIXED_DIMS, TSTART); - hrc = do_fopen(¶m, fname, &fd, PIO_CREATE | PIO_WRITE); - - VRFY((hrc == SUCCESS), "do_fopen failed"); - - io_time_set(res.timers, HDF5_FINE_WRITE_FIXED_DIMS, TSTART); - hrc = do_write(&res, &fd, ¶m, ndsets, nbytes, buf_size, buffer); - io_time_set(res.timers, HDF5_FINE_WRITE_FIXED_DIMS, TSTOP); - - VRFY((hrc == SUCCESS), "do_write failed"); - - /* Close file for write */ - hrc = do_fclose(iot, &fd); - - io_time_set(res.timers, HDF5_GROSS_WRITE_FIXED_DIMS, TSTOP); - VRFY((hrc == SUCCESS), "do_fclose failed"); - - if (!param.h5_write_only) { - /* - * Read performance measurement - */ - /* Need barrier to make sure everyone is done writing and has - * closed the file. Also to make sure everyone starts reading - * at the same time. - */ - MPI_Barrier(pio_comm_g); - - /* Open file for read */ - io_time_set(res.timers, HDF5_GROSS_READ_FIXED_DIMS, TSTART); - hrc = do_fopen(¶m, fname, &fd, PIO_READ); - - VRFY((hrc == SUCCESS), "do_fopen failed"); - - io_time_set(res.timers, HDF5_FINE_READ_FIXED_DIMS, TSTART); - hrc = do_read(&res, &fd, ¶m, ndsets, nbytes, buf_size, buffer); - io_time_set(res.timers, HDF5_FINE_READ_FIXED_DIMS, TSTOP); - VRFY((hrc == SUCCESS), "do_read failed"); - - /* Close file for read */ - hrc = do_fclose(iot, &fd); - - io_time_set(res.timers, HDF5_GROSS_READ_FIXED_DIMS, TSTOP); - VRFY((hrc == SUCCESS), "do_fclose failed"); - } - - /* Need barrier to make sure everyone is done with the file */ - /* before it may be removed by do_cleanupfile */ - MPI_Barrier(pio_comm_g); - do_cleanupfile(iot, fname); - } - -done: - /* clean up */ - /* release HDF5 objects */ - - /* close any opened files */ - /* no remove(fname) because that should have happened normally. */ - switch (iot) { - case POSIXIO: - if (fd.posixfd != -1) - hrc = do_fclose(iot, &fd); - break; - case MPIO: - if (fd.mpifd != MPI_FILE_NULL) - hrc = do_fclose(iot, &fd); - break; - case PHDF5: - if (fd.h5fd != -1) - hrc = do_fclose(iot, &fd); - break; - } - - /* release generic resources */ - if(buffer) - HDfree(buffer); - res.ret_code = ret_code; - return res; -} - -/* - * Function: pio_create_filename - * Purpose: Create a new filename to write to. Determine the correct - * suffix to append to the filename by the type of I/O we're - * doing. Also, place in the /tmp/{$USER,$LOGIN} directory if - * USER or LOGIN are specified in the environment. - * Return: Pointer to filename or NULL - * Programmer: Bill Wendling, 21. November 2001 - * Modifications: - */ - static char * -pio_create_filename(iotype iot, const char *base_name, char *fullname, size_t size) -{ - const char *prefix, *suffix = ""; - char *ptr, last = '\0'; - size_t i, j; - - if (!base_name || !fullname || size < 1) - return NULL; - - HDmemset(fullname, 0, size); - - switch (iot) { - case POSIXIO: - suffix = ".posix"; - break; - case MPIO: - suffix = ".mpio"; - break; - case PHDF5: - suffix = ".h5"; - break; - } - - /* First use the environment variable and then try the constant */ - prefix = HDgetenv("HDF5_PARAPREFIX"); - -#ifdef HDF5_PARAPREFIX - if (!prefix) - prefix = HDF5_PARAPREFIX; -#endif /* HDF5_PARAPREFIX */ - - /* Prepend the prefix value to the base name */ - if (prefix && *prefix) { - /* If the prefix specifies the HDF5_PARAPREFIX directory, then - * default to using the "/tmp/$USER" or "/tmp/$LOGIN" - * directory instead. */ - register char *user, *login, *subdir; - - user = HDgetenv("USER"); - login = HDgetenv("LOGIN"); - subdir = (user ? user : login); - - if (subdir) { - for (i = 0; i < size-1 && prefix[i]; i++) - fullname[i] = prefix[i]; - - fullname[i++] = '/'; - - for (j = 0; i < size && subdir[j]; i++, j++) - fullname[i] = subdir[j]; - } - else { - /* We didn't append the prefix yet */ - HDstrncpy(fullname, prefix, size); - fullname[size - 1] = '\0'; - } - - if ((HDstrlen(fullname) + HDstrlen(base_name) + 1) < size) { - /* Append the base_name with a slash first. Multiple slashes are - * handled below. */ - h5_stat_t buf; - - if (HDstat(fullname, &buf) < 0) - /* The directory doesn't exist just yet */ - if (HDmkdir(fullname, (mode_t) 0755) < 0 && errno != EEXIST) { - /* We couldn't make the "/tmp/${USER,LOGIN}" subdirectory. - * Default to PREFIX's original prefix value. */ - HDstrcpy(fullname, prefix); - } - - HDstrcat(fullname, "/"); - HDstrcat(fullname, base_name); - } - else { - /* Buffer is too small */ - return NULL; - } - } - else if (HDstrlen(base_name) >= size) { - /* Buffer is too small */ - return NULL; - } - else { - HDstrcpy(fullname, base_name); - } - - /* Append a suffix */ - if (suffix) { - if (HDstrlen(fullname) + HDstrlen(suffix) >= size) - return NULL; - - HDstrcat(fullname, suffix); - } - - /* Remove any double slashes in the filename */ - for (ptr = fullname, i = j = 0; ptr && i < size; i++, ptr++) { - if (*ptr != '/' || last != '/') - fullname[j++] = *ptr; - - last = *ptr; - } - - return fullname; -} - -/* - * Function: do_write - * Purpose: Write the required amount of data to the file. - * Return: SUCCESS or FAIL - * Programmer: Albert Cheng, Bill Wendling, 2001/12/13 - * Modifications: - * Added 2D testing (Christian Chilan, 10. August 2005) - */ - static herr_t -do_write(results *res, file_descr *fd, parameters *parms, long ndsets, - off_t nbytes, size_t buf_size, void *buffer) -{ - int ret_code = SUCCESS; - int rc; /*routine return code */ - long ndset; - size_t blk_size; /* The block size to subdivide the xfer buffer into */ - off_t nbytes_xfer; /* Total number of bytes transferred so far */ - size_t nbytes_xfer_advance; /* Number of bytes transferred in a single I/O operation */ - size_t nbytes_toxfer; /* Number of bytes to transfer a particular time */ - char dname[64]; - off_t dset_offset=0; /*dataset offset in a file */ - off_t bytes_begin[2]; /*first elmt this process transfer */ - off_t bytes_count; /*number of elmts this process transfer */ - off_t snbytes=0; /*size of a side of the dataset square */ - unsigned char *buf_p; /* Current buffer pointer */ - - /* POSIX variables */ - off_t file_offset; /* File offset of the next transfer */ - off_t file_offset_advance; /* File offset advance after each I/O operation */ - off_t posix_file_offset; /* Base file offset of the next transfer */ - - /* MPI variables */ - MPI_Offset mpi_file_offset; /* Base file offset of the next transfer*/ - MPI_Offset mpi_offset; /* Offset in MPI file */ - MPI_Offset mpi_offset_advance; /* Offset advance after each I/O operation */ - MPI_Datatype mpi_file_type; /* MPI derived type for 1D file */ - MPI_Datatype mpi_blk_type; /* MPI derived type for 1D buffer */ - MPI_Datatype mpi_cont_type; /* MPI derived type for 2D contiguous file */ - MPI_Datatype mpi_partial_buffer_cont; /* MPI derived type for partial 2D contiguous buffer */ - MPI_Datatype mpi_inter_type; /* MPI derived type for 2D interleaved file */ - MPI_Datatype mpi_partial_buffer_inter; /* MPI derived type for partial 2D interleaved buffer */ - MPI_Datatype mpi_full_buffer; /* MPI derived type for 2D full buffer */ - MPI_Datatype mpi_full_chunk; /* MPI derived type for 2D full chunk */ - MPI_Datatype mpi_chunk_inter_type; /* MPI derived type for 2D chunk interleaved file */ - MPI_Datatype mpi_collective_type; /* Generic MPI derived type for 2D collective access */ - MPI_Status mpi_status; - int mrc; /* MPI return code */ - - /* HDF5 variables */ - herr_t hrc; /*HDF5 return code */ - hsize_t h5dims[2]; /*dataset dim sizes */ - hid_t h5dset_space_id = -1; /*dataset space ID */ - hid_t h5mem_space_id = -1; /*memory dataspace ID */ - hid_t h5ds_id = -1; /*dataset handle */ - hsize_t h5block[2]; /*dataspace selection */ - hsize_t h5stride[2]; - hsize_t h5count[2]; - hsize_t h5start[2]; - hssize_t h5offset[2]; /* Selection offset within dataspace */ - hid_t h5dcpl = -1; /* Dataset creation property list */ - hid_t h5dxpl = -1; /* Dataset transfer property list */ - - /* Get the parameters from the parameter block */ - blk_size=parms->blk_size; - - /* There are two kinds of transfer patterns, contiguous and interleaved. - * Let 0,1,2,...,n be data accessed by process 0,1,2,...,n - * where n is rank of the last process. - * In contiguous pattern, data are accessed as - * 000...111...222...nnn... - * In interleaved pattern, data are accessed as - * 012...n012...n... - * These are all in the scope of one dataset. - */ - - /* 1D dataspace */ - if (!parms->dim2d){ - /* Contiguous Pattern: */ - if (!parms->interleaved) { - bytes_begin[0] = (off_t)(((double)nbytes*pio_mpi_rank_g)/pio_mpi_nprocs_g); - } /* end if */ - /* Interleaved Pattern: */ - else { - bytes_begin[0] = (off_t)(blk_size*pio_mpi_rank_g); - } /* end else */ - - /* Prepare buffer for verifying data */ - if (parms->verify) - memset(buffer,pio_mpi_rank_g+1,buf_size); - }/* end if */ - /* 2D dataspace */ - else { - /* nbytes is always the number of bytes per dataset (1D or 2D). If the - dataspace is 2D, snbytes is the size of a side of the dataset square. - */ - snbytes = (off_t)sqrt(nbytes); - - /* Contiguous Pattern: */ - if (!parms->interleaved) { - bytes_begin[0] = (off_t)((double)snbytes*pio_mpi_rank_g / pio_mpi_nprocs_g); - bytes_begin[1] = 0; - } /* end if */ - /* Interleaved Pattern: */ - else { - bytes_begin[0] = 0; - - if(!parms->h5_use_chunks || parms->io_type==PHDF5) - bytes_begin[1] = (off_t)(blk_size*pio_mpi_rank_g); - else - bytes_begin[1] = (off_t)(blk_size*blk_size*pio_mpi_rank_g); - } /* end else */ - - /* Prepare buffer for verifying data */ - if (parms->verify) - HDmemset(buffer,pio_mpi_rank_g+1,buf_size*blk_size); - } /* end else */ - - - /* Calculate the total number of bytes (bytes_count) to be - * transferred by this process. It may be different for different - * transfer pattern due to rounding to integral values. - */ - /* - * Calculate the beginning bytes of this process and the next. - * bytes_count is the difference between these two beginnings. - * This way, it eliminates any rounding errors. - * (This is tricky, don't mess with the formula, rounding errors - * can easily get introduced) */ - bytes_count = (off_t)(((double)nbytes*(pio_mpi_rank_g+1)) / pio_mpi_nprocs_g) - - (off_t)(((double)nbytes*pio_mpi_rank_g) / pio_mpi_nprocs_g); - - /* debug */ - if (pio_debug_level >= 4) { - HDprint_rank(output); - if (!parms->dim2d) { - HDfprintf(output, "Debug(do_write): " - "buf_size=%zu, bytes_begin=%" H5_PRINTF_LL_WIDTH "d, bytes_count=%" H5_PRINTF_LL_WIDTH "d\n", - buf_size, (long long)bytes_begin[0], - (long long)bytes_count); - } else { - HDfprintf(output, "Debug(do_write): " - "linear buf_size=%zu, bytes_begin=(%" H5_PRINTF_LL_WIDTH "d,%" H5_PRINTF_LL_WIDTH "d), bytes_count=%" H5_PRINTF_LL_WIDTH "d\n", - buf_size*blk_size, (long long)bytes_begin[0], - (long long)bytes_begin[1], (long long)bytes_count); - } - } - - /* I/O Access specific setup */ - switch (parms->io_type) { - case POSIXIO: - /* No extra setup */ - break; - - case MPIO: /* MPI-I/O setup */ - /* 1D dataspace */ - if (!parms->dim2d){ - /* Build block's derived type */ - mrc = MPI_Type_contiguous((int)blk_size, - MPI_BYTE, &mpi_blk_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Build file's derived type */ - mrc = MPI_Type_vector((int)(buf_size/blk_size), (int)1, - (int)pio_mpi_nprocs_g, mpi_blk_type, &mpi_file_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit file type */ - mrc = MPI_Type_commit( &mpi_file_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Commit buffer type */ - mrc = MPI_Type_commit( &mpi_blk_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - } /* end if */ - /* 2D dataspace */ - else { - /* Build partial buffer derived type for contiguous access */ - - mrc = MPI_Type_contiguous((int)buf_size, MPI_BYTE, - &mpi_partial_buffer_cont); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit partial buffer derived type */ - mrc = MPI_Type_commit(&mpi_partial_buffer_cont); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build contiguous file's derived type */ - mrc = MPI_Type_vector((int)blk_size, (int)1, (int)(snbytes/buf_size), - mpi_partial_buffer_cont, &mpi_cont_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit contiguous file type */ - mrc = MPI_Type_commit(&mpi_cont_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build partial buffer derived type for interleaved access */ - mrc = MPI_Type_contiguous((int)blk_size, MPI_BYTE, - &mpi_partial_buffer_inter); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit partial buffer derived type */ - mrc = MPI_Type_commit(&mpi_partial_buffer_inter); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build interleaved file's derived type */ - mrc = MPI_Type_vector((int)buf_size, (int)1, (int)(snbytes/blk_size), - mpi_partial_buffer_inter, &mpi_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit interleaved file type */ - mrc = MPI_Type_commit(&mpi_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build full buffer derived type */ - mrc = MPI_Type_contiguous((int)(blk_size*buf_size), MPI_BYTE, - &mpi_full_buffer); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit full buffer derived type */ - mrc = MPI_Type_commit(&mpi_full_buffer); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build full chunk derived type */ - mrc = MPI_Type_contiguous((int)(blk_size*blk_size), MPI_BYTE, - &mpi_full_chunk); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit full chunk derived type */ - mrc = MPI_Type_commit(&mpi_full_chunk); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build chunk interleaved file's derived type */ - mrc = MPI_Type_vector((int)(buf_size/blk_size), (int)1, (int)(snbytes/blk_size), - mpi_full_chunk, &mpi_chunk_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit chunk interleaved file type */ - mrc = MPI_Type_commit(&mpi_chunk_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - } /* end else */ - break; - - case PHDF5: /* HDF5 setup */ - /* 1D dataspace */ - if (!parms->dim2d){ - if(nbytes>0) { - /* define a contiguous dataset of nbytes native bytes */ - h5dims[0] = nbytes; - h5dset_space_id = H5Screate_simple(1, h5dims, NULL); - VRFY((h5dset_space_id >= 0), "H5Screate_simple"); - - /* Set up the file dset space id to select the pattern to access */ - if (!parms->interleaved){ - /* Contiguous pattern */ - h5start[0] = bytes_begin[0]; - h5stride[0] = h5block[0] = blk_size; - h5count[0] = buf_size/blk_size; - } /* end if */ - else { - /* Interleaved access pattern */ - /* Skip offset over blocks of other processes */ - h5start[0] = bytes_begin[0]; - h5stride[0] = blk_size*pio_mpi_nprocs_g; - h5block[0] = blk_size; - h5count[0] = buf_size/blk_size; - } /* end else */ - hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, - h5start, h5stride, h5count, h5block); - VRFY((hrc >= 0), "H5Sselect_hyperslab"); - } /* end if */ - else { - h5dset_space_id = H5Screate(H5S_SCALAR); - VRFY((h5dset_space_id >= 0), "H5Screate"); - } /* end else */ - - /* Create the memory dataspace that corresponds to the xfer buffer */ - if(buf_size>0) { - h5dims[0] = buf_size; - h5mem_space_id = H5Screate_simple(1, h5dims, NULL); - VRFY((h5mem_space_id >= 0), "H5Screate_simple"); - } /* end if */ - else { - h5mem_space_id = H5Screate(H5S_SCALAR); - VRFY((h5mem_space_id >= 0), "H5Screate"); - } /* end else */ - } /* end if */ - /* 2D dataspace */ - else { - if(nbytes>0) { - /* define a contiguous dataset of nbytes native bytes */ - h5dims[0] = snbytes; - h5dims[1] = snbytes; - h5dset_space_id = H5Screate_simple(2, h5dims, NULL); - VRFY((h5dset_space_id >= 0), "H5Screate_simple"); - - /* Set up the file dset space id to select the pattern to access */ - if (!parms->interleaved){ - /* Contiguous pattern */ - h5start[0] = bytes_begin[0]; - h5start[1] = bytes_begin[1]; - h5stride[0] = 1; - h5stride[1] = h5block[0] = h5block[1] = blk_size; - h5count[0] = 1; - h5count[1] = buf_size/blk_size; - } /* end if */ - else { - /* Interleaved access pattern */ - /* Skip offset over blocks of other processes */ - h5start[0] = bytes_begin[0]; - h5start[1] = bytes_begin[1]; - h5stride[0] = blk_size; - h5stride[1] = blk_size*pio_mpi_nprocs_g; - h5block[0] = h5block[1] = blk_size; - h5count[0] = buf_size/blk_size; - h5count[1] = 1; - } /* end else */ - hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, - h5start, h5stride, h5count, h5block); - VRFY((hrc >= 0), "H5Sselect_hyperslab"); - } /* end if */ - else { - h5dset_space_id = H5Screate(H5S_SCALAR); - VRFY((h5dset_space_id >= 0), "H5Screate"); - } /* end else */ - - /* Create the memory dataspace that corresponds to the xfer buffer */ - if(buf_size>0) { - if (!parms->interleaved){ - h5dims[0] = blk_size; - h5dims[1] = buf_size; - }else{ - h5dims[0] = buf_size; - h5dims[1] = blk_size; - } - h5mem_space_id = H5Screate_simple(2, h5dims, NULL); - VRFY((h5mem_space_id >= 0), "H5Screate_simple"); - } /* end if */ - else { - h5mem_space_id = H5Screate(H5S_SCALAR); - VRFY((h5mem_space_id >= 0), "H5Screate"); - } /* end else */ - } /* end else */ - - /* Create the dataset transfer property list */ - h5dxpl = H5Pcreate(H5P_DATASET_XFER); - if (h5dxpl < 0) { - HDfprintf(stderr, "HDF5 Property List Create failed\n"); - GOTOERROR(FAIL); - } - - /* Change to collective I/O, if asked */ - if(parms->collective) { - hrc = H5Pset_dxpl_mpio(h5dxpl, H5FD_MPIO_COLLECTIVE); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Property List Set failed\n"); - GOTOERROR(FAIL); - } /* end if */ - } /* end if */ - break; - } /* end switch */ - - for (ndset = 1; ndset <= ndsets; ++ndset) { - - /* Calculate dataset offset within a file */ - - /* create dataset */ - switch (parms->io_type) { - case POSIXIO: - case MPIO: - /* both posix and mpi io just need dataset offset in file*/ - dset_offset = (ndset - 1) * nbytes; - break; - - case PHDF5: - h5dcpl = H5Pcreate(H5P_DATASET_CREATE); - if (h5dcpl < 0) { - HDfprintf(stderr, "HDF5 Property List Create failed\n"); - GOTOERROR(FAIL); - } - /* 1D dataspace */ - if (!parms->dim2d){ - /* Make the dataset chunked if asked */ - if(parms->h5_use_chunks) { - /* Set the chunk size to be the same as the buffer size */ - h5dims[0] = blk_size; - hrc = H5Pset_chunk(h5dcpl, 1, h5dims); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Property List Set failed\n"); - GOTOERROR(FAIL); - } /* end if */ - } /* end if */ - }/* end if */ - else{ - /* 2D dataspace */ - if(parms->h5_use_chunks) { - /* Set the chunk size to be the same as the block size */ - h5dims[0] = blk_size; - h5dims[1] = blk_size; - hrc = H5Pset_chunk(h5dcpl, 2, h5dims); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Property List Set failed\n"); - GOTOERROR(FAIL); - } /* end if */ - } /* end if */ - }/* end else */ - - HDsprintf(dname, "Dataset_%ld", ndset); - h5ds_id = H5DCREATE(fd->h5fd, dname, ELMT_H5_TYPE, - h5dset_space_id, h5dcpl); - - if (h5ds_id < 0) { - HDfprintf(stderr, "HDF5 Dataset Create failed\n"); - GOTOERROR(FAIL); - } - - hrc = H5Pclose(h5dcpl); - /* verifying the close of the dcpl */ - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Property List Close failed\n"); - GOTOERROR(FAIL); - } - break; - } - - /* The task is to transfer bytes_count bytes, starting at - * bytes_begin position, using transfer buffer of buf_size bytes. - * If interleaved, select buf_size at a time, in round robin - * fashion, according to number of process. Otherwise, select - * all bytes_count in contiguous. - */ - nbytes_xfer = 0 ; - - /* 1D dataspace */ - if (!parms->dim2d){ - /* Set base file offset for all I/O patterns and POSIX access */ - posix_file_offset = dset_offset + bytes_begin[0]; - - /* Set base file offset for all I/O patterns and MPI access */ - mpi_file_offset = (MPI_Offset)(dset_offset + bytes_begin[0]); - } /* end if */ - else { - /* Set base file offset for all I/O patterns and POSIX access */ - posix_file_offset=dset_offset + bytes_begin[0]*snbytes+ - bytes_begin[1]; - - /* Set base file offset for all I/O patterns and MPI access */ - mpi_file_offset=(MPI_Offset)(dset_offset + bytes_begin[0]*snbytes+ - bytes_begin[1]); - } /* end else */ - - /* Start "raw data" write timer */ - io_time_set(res->timers, HDF5_RAW_WRITE_FIXED_DIMS, TSTART); - - while (nbytes_xfer < bytes_count){ - /* Write */ - /* Calculate offset of write within a dataset/file */ - switch (parms->io_type) { - case POSIXIO: - /* 1D dataspace */ - if (!parms->dim2d){ - /* Contiguous pattern */ - if (!parms->interleaved) { - /* Compute file offset */ - file_offset = posix_file_offset + (off_t)nbytes_xfer; - - /* only care if seek returns error */ - rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; - VRFY((rc==0), "POSIXSEEK"); - - /* check if all bytes are written */ - rc = ((ssize_t)buf_size == - POSIXWRITE(fd->posixfd, buffer, buf_size)); - VRFY((rc != 0), "POSIXWRITE"); - - /* Advance global offset in dataset */ - nbytes_xfer+=buf_size; - } /* end if */ - /* Interleaved access pattern */ - else { - /* Set the base of user's buffer */ - buf_p=(unsigned char *)buffer; - - /* Set the number of bytes to transfer this time */ - nbytes_toxfer = buf_size; - - /* Loop over the buffers to write */ - while(nbytes_toxfer>0) { - /* Skip offset over blocks of other processes */ - file_offset = posix_file_offset + - (off_t)(nbytes_xfer*pio_mpi_nprocs_g); - - /* only care if seek returns error */ - rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; - VRFY((rc==0), "POSIXSEEK"); - - /* check if all bytes are written */ - rc = ((ssize_t)blk_size == - POSIXWRITE(fd->posixfd, buf_p, blk_size)); - VRFY((rc != 0), "POSIXWRITE"); - - /* Advance location in buffer */ - buf_p+=blk_size; - - /* Advance global offset in dataset */ - nbytes_xfer+=blk_size; - - /* Decrement number of bytes left this time */ - nbytes_toxfer-=blk_size; - } /* end while */ - } /* end else */ - } /* end if */ - /* 2D dataspace */ - else { - /* Contiguous storage */ - if (!parms->h5_use_chunks) { - /* Contiguous access pattern */ - if (!parms->interleaved) { - /* Compute file offset */ - file_offset=posix_file_offset+(off_t)(((nbytes_xfer/blk_size) - /snbytes)*(blk_size*snbytes)+((nbytes_xfer/blk_size)%snbytes)); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = buf_size; - - /* Global offset advance after each I/O operation */ - file_offset_advance = (off_t)snbytes; - } /* end if */ - /* Interleaved access pattern */ - else { - /* Compute file offset */ - file_offset=posix_file_offset+(off_t)((((nbytes_xfer/buf_size) - *pio_mpi_nprocs_g)/snbytes)*(buf_size*snbytes) - +((nbytes_xfer/buf_size)*pio_mpi_nprocs_g)%snbytes); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size; - - /* Global offset advance after each I/O operation */ - file_offset_advance = (off_t)snbytes; - } /* end else */ - } /* end if */ - /* Chunked storage */ - else { - /*Contiguous access pattern */ - if (!parms->interleaved) { - /* Compute file offset */ - file_offset=posix_file_offset+(off_t)nbytes_xfer; - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size * buf_size; - - /* Global offset advance after each I/O operation */ - file_offset_advance = 0; - } /* end if */ - /*Interleaved access pattern */ - else { - /* Compute file offset */ - /* Before simplification */ - /* file_offset=posix_file_offset+(off_t)((nbytes_xfer/(buf_size/blk_size) - *pio_mpi_nprocs_g)/(snbytes/blk_size*(blk_size*blk_size))*(buf_size/blk_size - *snbytes/blk_size*(blk_size*blk_size))+((nbytes_xfer/(buf_size/blk_size)) - *pio_mpi_nprocs_g)%(snbytes/blk_size*(blk_size*blk_size))); */ - - file_offset=posix_file_offset+(off_t)(((nbytes_xfer/(buf_size/blk_size) - *pio_mpi_nprocs_g)/(snbytes*blk_size))*(buf_size*snbytes)+((nbytes_xfer/(buf_size/blk_size)) - *pio_mpi_nprocs_g)%(snbytes*blk_size)); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size * blk_size; - - /* Global offset advance after each I/O operation */ - /* file_offset_advance = (off_t)(snbytes/blk_size*(blk_size*blk_size)); */ - file_offset_advance = (off_t)(snbytes*blk_size); - } /* end else */ - } /* end else */ - - /* Common code for file access */ - - /* Set the base of user's buffer */ - buf_p = (unsigned char *)buffer; - - /* Set the number of bytes to transfer this time */ - nbytes_toxfer = buf_size*blk_size; - - /* Loop over portions of the buffer to write */ - while(nbytes_toxfer>0){ - /* only care if seek returns error */ - rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; - VRFY((rc==0), "POSIXSEEK"); - - /* check if all bytes are written */ - rc = ((ssize_t)nbytes_xfer_advance == - POSIXWRITE(fd->posixfd, buf_p, nbytes_xfer_advance)); - VRFY((rc != 0), "POSIXWRITE"); - - /* Advance location in buffer */ - buf_p+=nbytes_xfer_advance; - - /* Advance global offset in dataset */ - nbytes_xfer+=nbytes_xfer_advance; - - /* Decrement number of bytes left this time */ - nbytes_toxfer-=nbytes_xfer_advance; - - /* Partially advance file offset */ - file_offset+=file_offset_advance; - } /* end while */ - - } /* end else */ - - break; - - case MPIO: - /* 1D dataspace */ - if (!parms->dim2d){ - /* Independent file access */ - if(!parms->collective) { - /* Contiguous pattern */ - if (!parms->interleaved){ - /* Compute offset in file */ - mpi_offset = mpi_file_offset + - nbytes_xfer; - - /* Perform independent write */ - mrc = MPI_File_write_at(fd->mpifd, mpi_offset, buffer, - (int)(buf_size/blk_size), mpi_blk_type, - &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_WRITE"); - - /* Advance global offset in dataset */ - nbytes_xfer+=buf_size; - } /* end if */ - /* Interleaved access pattern */ - else { - /* Set the base of user's buffer */ - buf_p=(unsigned char *)buffer; - - /* Set the number of bytes to transfer this time */ - nbytes_toxfer = buf_size; - - /* Loop over the buffers to write */ - while(nbytes_toxfer>0) { - /* Skip offset over blocks of other processes */ - mpi_offset = mpi_file_offset + - (nbytes_xfer*pio_mpi_nprocs_g); - - /* Perform independent write */ - mrc = MPI_File_write_at(fd->mpifd, mpi_offset, buf_p, - (int)1, mpi_blk_type, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_WRITE"); - - /* Advance location in buffer */ - buf_p+=blk_size; - - /* Advance global offset in dataset */ - nbytes_xfer+=blk_size; - - /* Decrement number of bytes left this time */ - nbytes_toxfer-=blk_size; - } /* end while */ - } /* end else */ - } /* end if */ - /* Collective file access */ - else { - /* Contiguous access pattern */ - if (!parms->interleaved){ - /* Compute offset in file */ - mpi_offset = mpi_file_offset + - nbytes_xfer; - - /* Perform independent write */ - mrc = MPI_File_write_at_all(fd->mpifd, mpi_offset, buffer, - (int)(buf_size/blk_size), mpi_blk_type, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_WRITE"); - - /* Advance global offset in dataset */ - nbytes_xfer+=buf_size; - } /* end if */ - /* Interleaved access pattern */ - else { - /* Compute offset in file */ - mpi_offset = mpi_file_offset + - (nbytes_xfer*pio_mpi_nprocs_g); - - /* Set the file view */ - mrc = MPI_File_set_view(fd->mpifd, mpi_offset, mpi_blk_type, - mpi_file_type, (char*)"native", h5_io_info_g); - VRFY((mrc==MPI_SUCCESS), "MPIO_VIEW"); - - /* Perform write */ - mrc = MPI_File_write_at_all(fd->mpifd, 0, buffer, - (int)(buf_size/blk_size), mpi_blk_type, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_WRITE"); - - /* Advance global offset in dataset */ - nbytes_xfer+=buf_size; - } /* end else */ - } /* end else */ - } /* end if */ - /* 2D dataspace */ - else { - /* Contiguous storage */ - if (!parms->h5_use_chunks) { - /* Contiguous access pattern */ - if (!parms->interleaved) { - /* Compute offset in file */ - mpi_offset=mpi_file_offset+((nbytes_xfer/blk_size)/snbytes)* - (blk_size*snbytes)+((nbytes_xfer/blk_size)%snbytes); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = buf_size; - - /* Global offset advance after each I/O operation */ - mpi_offset_advance = snbytes; - - /* MPI type to be used for collective access */ - mpi_collective_type = mpi_cont_type; - } /* end if */ - /* Interleaved access pattern */ - else { - /* Compute offset in file */ - mpi_offset=mpi_file_offset+(((nbytes_xfer/buf_size)*pio_mpi_nprocs_g)/snbytes)* - (buf_size*snbytes)+((nbytes_xfer/buf_size)*pio_mpi_nprocs_g)%snbytes; - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size; - - /* Global offset advance after each I/O operation */ - mpi_offset_advance = snbytes; - - /* MPI type to be used for collective access */ - mpi_collective_type = mpi_inter_type; - } /* end else */ - } /* end if */ - /* Chunked storage */ - else { - /*Contiguous access pattern */ - if (!parms->interleaved) { - /* Compute offset in file */ - mpi_offset=mpi_file_offset+nbytes_xfer; - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size * buf_size; - - /* Global offset advance after each I/O operation */ - mpi_offset_advance = 0; - - /* MPI type to be used for collective access */ - mpi_collective_type = mpi_full_buffer; - } /* end if */ - /*Interleaved access pattern */ - else { - /* Compute offset in file */ - /* Before simplification */ - /* mpi_offset=mpi_file_offset+(nbytes_xfer/(buf_size/blk_size) - *pio_mpi_nprocs_g)/(snbytes/blk_size*(blk_size*blk_size))* - (buf_size/blk_size*snbytes/blk_size*(blk_size*blk_size))+ - ((nbytes_xfer/(buf_size/blk_size))*pio_mpi_nprocs_g)%(snbytes - /blk_size*(blk_size*blk_size)); */ - mpi_offset=mpi_file_offset+((nbytes_xfer/(buf_size/blk_size) - *pio_mpi_nprocs_g)/(snbytes*blk_size))*(buf_size*snbytes) - +((nbytes_xfer/(buf_size/blk_size))*pio_mpi_nprocs_g)%(snbytes*blk_size); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size * blk_size; - - /* Global offset advance after each I/O operation */ - /* mpi_offset_advance = (MPI_Offset)(snbytes/blk_size*(blk_size*blk_size)); */ - mpi_offset_advance = (MPI_Offset)(snbytes*blk_size); - - /* MPI type to be used for collective access */ - mpi_collective_type = mpi_chunk_inter_type; - } /* end else */ - } /* end else */ - - /* Common code for independent file access */ - if (!parms->collective) { - /* Set the base of user's buffer */ - buf_p = (unsigned char *)buffer; - - /* Set the number of bytes to transfer this time */ - nbytes_toxfer = buf_size * blk_size; - - /* Loop over portions of the buffer to write */ - while(nbytes_toxfer>0){ - /* Perform independent write */ - mrc = MPI_File_write_at(fd->mpifd, mpi_offset, buf_p, - (int)nbytes_xfer_advance, MPI_BYTE, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_WRITE"); - - /* Advance location in buffer */ - buf_p+=nbytes_xfer_advance; - - /* Advance global offset in dataset */ - nbytes_xfer+=nbytes_xfer_advance; - - /* Decrement number of bytes left this time */ - nbytes_toxfer-=nbytes_xfer_advance; - - /* Partially advance global offset in dataset */ - mpi_offset+=mpi_offset_advance; - } /* end while */ - } /* end if */ - - /* Common code for collective file access */ - else { - /* Set the file view */ - mrc = MPI_File_set_view(fd->mpifd, mpi_offset, MPI_BYTE, - mpi_collective_type, (char *)"native", h5_io_info_g); - VRFY((mrc==MPI_SUCCESS), "MPIO_VIEW"); - - /* Perform write */ - MPI_File_write_at_all(fd->mpifd, 0, buffer,(int)(buf_size*blk_size), - MPI_BYTE, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_WRITE"); - - /* Advance global offset in dataset */ - nbytes_xfer+=buf_size*blk_size; - } /* end else */ - - } /* end else */ - - break; - - case PHDF5: - /* 1D dataspace */ - if (!parms->dim2d){ - /* Set up the file dset space id to move the selection to process */ - if (!parms->interleaved){ - /* Contiguous pattern */ - h5offset[0] = nbytes_xfer; - } /* end if */ - else { - /* Interleaved access pattern */ - /* Skip offset over blocks of other processes */ - h5offset[0] = (nbytes_xfer*pio_mpi_nprocs_g); - } /* end else */ - hrc = H5Soffset_simple(h5dset_space_id, h5offset); - VRFY((hrc >= 0), "H5Soffset_simple"); - - /* Write the buffer out */ - hrc = H5Dwrite(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, - h5dset_space_id, h5dxpl, buffer); - VRFY((hrc >= 0), "H5Dwrite"); - - /* Increment number of bytes transferred */ - nbytes_xfer += buf_size; - } /* end if */ - /* 2D dataspace */ - else { - /* Set up the file dset space id to move the selection to process */ - if (!parms->interleaved){ - /* Contiguous pattern */ - h5offset[0] = (nbytes_xfer/(snbytes*blk_size))*blk_size; - h5offset[1] = (nbytes_xfer%(snbytes*blk_size))/blk_size; - - } /* end if */ - else { - /* Interleaved access pattern */ - /* Skip offset over blocks of other processes */ - h5offset[0] = ((nbytes_xfer*pio_mpi_nprocs_g)/(snbytes*buf_size))*buf_size; - h5offset[1] = ((nbytes_xfer*pio_mpi_nprocs_g)%(snbytes*buf_size))/buf_size; - - } /* end else */ - hrc = H5Soffset_simple(h5dset_space_id, h5offset); - VRFY((hrc >= 0), "H5Soffset_simple"); - - /* Write the buffer out */ - hrc = H5Dwrite(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, - h5dset_space_id, h5dxpl, buffer); - VRFY((hrc >= 0), "H5Dwrite"); - - /* Increment number of bytes transferred */ - nbytes_xfer += buf_size*blk_size; - - } /* end else */ - - break; - } /* switch (parms->io_type) */ - } /* end while */ - - /* Stop "raw data" write timer */ - io_time_set(res->timers, HDF5_RAW_WRITE_FIXED_DIMS, TSTOP); - - /* Calculate write time */ - - /* Close dataset. Only HDF5 needs to do an explicit close. */ - if (parms->io_type == PHDF5) { - hrc = H5Dclose(h5ds_id); - - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Dataset Close failed\n"); - GOTOERROR(FAIL); - } - - h5ds_id = -1; - } /* end if */ - } /* end for */ - -done: - /* release MPI-I/O objects */ - if (parms->io_type == MPIO) { - /* 1D dataspace */ - if (!parms->dim2d){ - /* Free file type */ - mrc = MPI_Type_free( &mpi_file_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - - /* Free buffer type */ - mrc = MPI_Type_free( &mpi_blk_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - } /* end if */ - /* 2D dataspace */ - else { - /* Free partial buffer type for contiguous access */ - mrc = MPI_Type_free( &mpi_partial_buffer_cont ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - - /* Free contiguous file type */ - mrc = MPI_Type_free( &mpi_cont_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - - /* Free partial buffer type for interleaved access */ - mrc = MPI_Type_free( &mpi_partial_buffer_inter ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - - /* Free interleaved file type */ - mrc = MPI_Type_free( &mpi_inter_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - - /* Free full buffer type */ - mrc = MPI_Type_free(&mpi_full_buffer); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - - /* Free full chunk type */ - mrc = MPI_Type_free(&mpi_full_chunk); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - - /* Free chunk interleaved file type */ - mrc = MPI_Type_free(&mpi_chunk_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - } /* end else */ - } /* end if */ - - /* release HDF5 objects */ - if (h5dset_space_id != -1) { - hrc = H5Sclose(h5dset_space_id); - if (hrc < 0){ - HDfprintf(stderr, "HDF5 Dataset Space Close failed\n"); - ret_code = FAIL; - } else { - h5dset_space_id = -1; - } - } - - if (h5mem_space_id != -1) { - hrc = H5Sclose(h5mem_space_id); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Memory Space Close failed\n"); - ret_code = FAIL; - } else { - h5mem_space_id = -1; - } - } - - if (h5dxpl != -1) { - hrc = H5Pclose(h5dxpl); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Dataset Transfer Property List Close failed\n"); - ret_code = FAIL; - } else { - h5dxpl = -1; - } - } - - return ret_code; -} - -/* - * Function: do_read - * Purpose: read the required amount of data from the file. - * Return: SUCCESS or FAIL - * Programmer: Albert Cheng 2001/12/13 - * Modifications: - * Added 2D testing (Christian Chilan, 10. August 2005) - */ - static herr_t -do_read(results *res, file_descr *fd, parameters *parms, long ndsets, - off_t nbytes, size_t buf_size, void *buffer /*out*/) -{ - int ret_code = SUCCESS; - int rc; /*routine return code */ - long ndset; - size_t blk_size; /* The block size to subdivide the xfer buffer into */ - size_t bsize; /* Size of the actual buffer */ - off_t nbytes_xfer; /* Total number of bytes transferred so far */ - size_t nbytes_xfer_advance; /* Number of bytes transferred in a single I/O operation */ - size_t nbytes_toxfer; /* Number of bytes to transfer a particular time */ - char dname[64]; - off_t dset_offset=0; /*dataset offset in a file */ - off_t bytes_begin[2]; /*first elmt this process transfer */ - off_t bytes_count; /*number of elmts this process transfer */ - off_t snbytes=0; /*size of a side of the dataset square */ - unsigned char *buf_p; /* Current buffer pointer */ - - /* POSIX variables */ - off_t file_offset; /* File offset of the next transfer */ - off_t file_offset_advance; /* File offset advance after each I/O operation */ - off_t posix_file_offset; /* Base file offset of the next transfer */ - - /* MPI variables */ - MPI_Offset mpi_file_offset;/* Base file offset of the next transfer*/ - MPI_Offset mpi_offset; /* Offset in MPI file */ - MPI_Offset mpi_offset_advance; /* Offset advance after each I/O operation */ - MPI_Datatype mpi_file_type; /* MPI derived type for 1D file */ - MPI_Datatype mpi_blk_type; /* MPI derived type for 1D buffer */ - MPI_Datatype mpi_cont_type; /* MPI derived type for 2D contiguous file */ - MPI_Datatype mpi_partial_buffer_cont; /* MPI derived type for partial 2D contiguous buffer */ - MPI_Datatype mpi_inter_type; /* MPI derived type for 2D interleaved file */ - MPI_Datatype mpi_partial_buffer_inter; /* MPI derived type for partial 2D interleaved buffer */ - MPI_Datatype mpi_full_buffer; /* MPI derived type for 2D full buffer */ - MPI_Datatype mpi_full_chunk; /* MPI derived type for 2D full chunk */ - MPI_Datatype mpi_chunk_inter_type; /* MPI derived type for 2D chunk interleaved file */ - MPI_Datatype mpi_collective_type; /* Generic MPI derived type for 2D collective access */ - MPI_Status mpi_status; - int mrc; /* MPI return code */ - - /* HDF5 variables */ - herr_t hrc; /*HDF5 return code */ - hsize_t h5dims[2]; /*dataset dim sizes */ - hid_t h5dset_space_id = -1; /*dataset space ID */ - hid_t h5mem_space_id = -1; /*memory dataspace ID */ - hid_t h5ds_id = -1; /*dataset handle */ - hsize_t h5block[2]; /*dataspace selection */ - hsize_t h5stride[2]; - hsize_t h5count[2]; - hsize_t h5start[2]; - hssize_t h5offset[2]; /* Selection offset within dataspace */ - hid_t h5dxpl = -1; /* Dataset transfer property list */ - - /* Get the parameters from the parameter block */ - blk_size=parms->blk_size; - - /* There are two kinds of transfer patterns, contiguous and interleaved. - * Let 0,1,2,...,n be data accessed by process 0,1,2,...,n - * where n is rank of the last process. - * In contiguous pattern, data are accessed as - * 000...111...222...nnn... - * In interleaved pattern, data are accessed as - * 012...n012...n... - * These are all in the scope of one dataset. - */ - - /* 1D dataspace */ - if (!parms->dim2d){ - bsize = buf_size; - /* Contiguous Pattern: */ - if (!parms->interleaved) { - bytes_begin[0] = (off_t)(((double)nbytes*pio_mpi_rank_g)/pio_mpi_nprocs_g); - } /* end if */ - /* Interleaved Pattern: */ - else { - bytes_begin[0] = (off_t)(blk_size*pio_mpi_rank_g); - } /* end else */ - }/* end if */ - /* 2D dataspace */ - else { - /* nbytes is always the number of bytes per dataset (1D or 2D). If the - dataspace is 2D, snbytes is the size of a side of the 'dataset square'. - */ - snbytes = (off_t)sqrt(nbytes); - - bsize = buf_size * blk_size; - - /* Contiguous Pattern: */ - if (!parms->interleaved) { - bytes_begin[0] = (off_t)((double)snbytes*pio_mpi_rank_g / pio_mpi_nprocs_g); - bytes_begin[1] = 0; - } /* end if */ - /* Interleaved Pattern: */ - else { - bytes_begin[0] = 0; - - if (!parms->h5_use_chunks || parms->io_type==PHDF5) - bytes_begin[1] = (off_t)(blk_size*pio_mpi_rank_g); - else - bytes_begin[1] = (off_t)(blk_size*blk_size*pio_mpi_rank_g); - } /* end else */ - } /* end else */ - - /* Calculate the total number of bytes (bytes_count) to be - * transferred by this process. It may be different for different - * transfer pattern due to rounding to integral values. - */ - /* - * Calculate the beginning bytes of this process and the next. - * bytes_count is the difference between these two beginnings. - * This way, it eliminates any rounding errors. - * (This is tricky, don't mess with the formula, rounding errors - * can easily get introduced) */ - bytes_count = (off_t)(((double)nbytes*(pio_mpi_rank_g+1)) / pio_mpi_nprocs_g) - - (off_t)(((double)nbytes*pio_mpi_rank_g) / pio_mpi_nprocs_g); - - /* debug */ - if (pio_debug_level >= 4) { - HDprint_rank(output); - if (!parms->dim2d) { - HDfprintf(output, "Debug(do_write): " - "buf_size=%zu, bytes_begin=%" H5_PRINTF_LL_WIDTH "d, bytes_count=%" H5_PRINTF_LL_WIDTH "d\n", - buf_size, (long long)bytes_begin[0], - (long long)bytes_count); - } else { - HDfprintf(output, "Debug(do_write): " - "linear buf_size=%zu, bytes_begin=(%" H5_PRINTF_LL_WIDTH "d,%" H5_PRINTF_LL_WIDTH "d), bytes_count=%" H5_PRINTF_LL_WIDTH "d\n", - buf_size*blk_size, (long long)bytes_begin[0], - (long long)bytes_begin[1], (long long)bytes_count); - } - } - - /* I/O Access specific setup */ - switch (parms->io_type) { - case POSIXIO: - /* No extra setup */ - break; - - case MPIO: /* MPI-I/O setup */ - /* 1D dataspace */ - if (!parms->dim2d){ - /* Build block's derived type */ - mrc = MPI_Type_contiguous((int)blk_size, - MPI_BYTE, &mpi_blk_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Build file's derived type */ - mrc = MPI_Type_vector((int)(buf_size/blk_size), (int)1, - (int)pio_mpi_nprocs_g, mpi_blk_type, &mpi_file_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit file type */ - mrc = MPI_Type_commit( &mpi_file_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Commit buffer type */ - mrc = MPI_Type_commit( &mpi_blk_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - } /* end if */ - /* 2D dataspace */ - else { - /* Build partial buffer derived type for contiguous access */ - mrc = MPI_Type_contiguous((int)buf_size, MPI_BYTE, - &mpi_partial_buffer_cont); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit partial buffer derived type */ - mrc = MPI_Type_commit(&mpi_partial_buffer_cont); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build contiguous file's derived type */ - mrc = MPI_Type_vector((int)blk_size, (int)1, (int)(snbytes/buf_size), - mpi_partial_buffer_cont, &mpi_cont_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit contiguous file type */ - mrc = MPI_Type_commit(&mpi_cont_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build partial buffer derived type for interleaved access */ - mrc = MPI_Type_contiguous((int)blk_size, MPI_BYTE, - &mpi_partial_buffer_inter); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit partial buffer derived type */ - mrc = MPI_Type_commit(&mpi_partial_buffer_inter); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build interleaved file's derived type */ - mrc = MPI_Type_vector((int)buf_size, (int)1, (int)(snbytes/blk_size), - mpi_partial_buffer_inter, &mpi_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit interleaved file type */ - mrc = MPI_Type_commit(&mpi_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build full buffer derived type */ - mrc = MPI_Type_contiguous((int)(blk_size*buf_size), MPI_BYTE, - &mpi_full_buffer); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit full buffer derived type */ - mrc = MPI_Type_commit(&mpi_full_buffer); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build full chunk derived type */ - mrc = MPI_Type_contiguous((int)(blk_size*blk_size), MPI_BYTE, - &mpi_full_chunk); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit full chunk derived type */ - mrc = MPI_Type_commit(&mpi_full_chunk); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build chunk interleaved file's derived type */ - mrc = MPI_Type_vector((int)(buf_size/blk_size), (int)1, (int)(snbytes/blk_size), - mpi_full_chunk, &mpi_chunk_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit chunk interleaved file type */ - mrc = MPI_Type_commit(&mpi_chunk_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - } /* end else */ - break; - - case PHDF5: /* HDF5 setup */ - /* 1D dataspace */ - if (!parms->dim2d){ - if(nbytes>0) { - /* define a contiguous dataset of nbytes native bytes */ - h5dims[0] = nbytes; - h5dset_space_id = H5Screate_simple(1, h5dims, NULL); - VRFY((h5dset_space_id >= 0), "H5Screate_simple"); - - /* Set up the file dset space id to select the pattern to access */ - if (!parms->interleaved){ - /* Contiguous pattern */ - h5start[0] = bytes_begin[0]; - h5stride[0] = h5block[0] = blk_size; - h5count[0] = buf_size/blk_size; - } /* end if */ - else { - /* Interleaved access pattern */ - /* Skip offset over blocks of other processes */ - h5start[0] = bytes_begin[0]; - h5stride[0] = blk_size*pio_mpi_nprocs_g; - h5block[0] = blk_size; - h5count[0] = buf_size/blk_size; - } /* end else */ - hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, - h5start, h5stride, h5count, h5block); - VRFY((hrc >= 0), "H5Sselect_hyperslab"); - } /* end if */ - else { - h5dset_space_id = H5Screate(H5S_SCALAR); - VRFY((h5dset_space_id >= 0), "H5Screate"); - } /* end else */ - - /* Create the memory dataspace that corresponds to the xfer buffer */ - if(buf_size>0) { - h5dims[0] = buf_size; - h5mem_space_id = H5Screate_simple(1, h5dims, NULL); - VRFY((h5mem_space_id >= 0), "H5Screate_simple"); - } /* end if */ - else { - h5mem_space_id = H5Screate(H5S_SCALAR); - VRFY((h5mem_space_id >= 0), "H5Screate"); - } /* end else */ - } /* end if */ - /* 2D dataspace */ - else { - if(nbytes>0) { - /* define a contiguous dataset of nbytes native bytes */ - h5dims[0] = snbytes; - h5dims[1] = snbytes; - h5dset_space_id = H5Screate_simple(2, h5dims, NULL); - VRFY((h5dset_space_id >= 0), "H5Screate_simple"); - - /* Set up the file dset space id to select the pattern to access */ - if (!parms->interleaved){ - /* Contiguous pattern */ - h5start[0] = bytes_begin[0]; - h5start[1] = bytes_begin[1]; - h5stride[0] = 1; - h5stride[1] = h5block[0] = h5block[1] = blk_size; - h5count[0] = 1; - h5count[1] = buf_size/blk_size; - } /* end if */ - else { - /* Interleaved access pattern */ - /* Skip offset over blocks of other processes */ - h5start[0] = bytes_begin[0]; - h5start[1] = bytes_begin[1]; - h5stride[0] = blk_size; - h5stride[1] = blk_size*pio_mpi_nprocs_g; - h5block[0] = h5block[1] = blk_size; - h5count[0] = buf_size/blk_size; - h5count[1] = 1; - } /* end else */ - hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, - h5start, h5stride, h5count, h5block); - VRFY((hrc >= 0), "H5Sselect_hyperslab"); - } /* end if */ - else { - h5dset_space_id = H5Screate(H5S_SCALAR); - VRFY((h5dset_space_id >= 0), "H5Screate"); - } /* end else */ - - /* Create the memory dataspace that corresponds to the xfer buffer */ - if(buf_size>0) { - if (!parms->interleaved){ - h5dims[0] = blk_size; - h5dims[1] = buf_size; - }else{ - h5dims[0] = buf_size; - h5dims[1] = blk_size; - } - h5mem_space_id = H5Screate_simple(2, h5dims, NULL); - VRFY((h5mem_space_id >= 0), "H5Screate_simple"); - } /* end if */ - else { - h5mem_space_id = H5Screate(H5S_SCALAR); - VRFY((h5mem_space_id >= 0), "H5Screate"); - } /* end else */ - } /* end else */ - - /* Create the dataset transfer property list */ - h5dxpl = H5Pcreate(H5P_DATASET_XFER); - if (h5dxpl < 0) { - HDfprintf(stderr, "HDF5 Property List Create failed\n"); - GOTOERROR(FAIL); - } - - /* Change to collective I/O, if asked */ - if(parms->collective) { - hrc = H5Pset_dxpl_mpio(h5dxpl, H5FD_MPIO_COLLECTIVE); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Property List Set failed\n"); - GOTOERROR(FAIL); - } /* end if */ - } /* end if */ - break; - } /* end switch */ - - for (ndset = 1; ndset <= ndsets; ++ndset) { - - /* Calculate dataset offset within a file */ - - /* create dataset */ - switch (parms->io_type) { - case POSIXIO: - case MPIO: - /* both posix and mpi io just need dataset offset in file*/ - dset_offset = (ndset - 1) * nbytes; - break; - - case PHDF5: - HDsprintf(dname, "Dataset_%ld", ndset); - h5ds_id = H5DOPEN(fd->h5fd, dname); - if (h5ds_id < 0) { - HDfprintf(stderr, "HDF5 Dataset open failed\n"); - GOTOERROR(FAIL); - } - - break; - } - - /* The task is to transfer bytes_count bytes, starting at - * bytes_begin position, using transfer buffer of buf_size bytes. - * If interleaved, select buf_size at a time, in round robin - * fashion, according to number of process. Otherwise, select - * all bytes_count in contiguous. - */ - nbytes_xfer = 0 ; - - /* 1D dataspace */ - if (!parms->dim2d){ - /* Set base file offset for all I/O patterns and POSIX access */ - posix_file_offset = dset_offset + bytes_begin[0]; - - /* Set base file offset for all I/O patterns and MPI access */ - mpi_file_offset = (MPI_Offset)(dset_offset + bytes_begin[0]); - } /* end if */ - else { - /* Set base file offset for all I/O patterns and POSIX access */ - posix_file_offset=dset_offset + bytes_begin[0]*snbytes+ - bytes_begin[1]; - - /* Set base file offset for all I/O patterns and MPI access */ - mpi_file_offset=(MPI_Offset)(dset_offset + bytes_begin[0]*snbytes+ - bytes_begin[1]); - } /* end else */ - - /* Start "raw data" read timer */ - io_time_set(res->timers, HDF5_RAW_READ_FIXED_DIMS, TSTART); - - while (nbytes_xfer < bytes_count){ - /* Read */ - /* Calculate offset of read within a dataset/file */ - switch (parms->io_type) { - case POSIXIO: - /* 1D dataspace */ - if (!parms->dim2d){ - /* Contiguous pattern */ - if (!parms->interleaved) { - /* Compute file offset */ - file_offset = posix_file_offset + (off_t)nbytes_xfer; - - /* only care if seek returns error */ - rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; - VRFY((rc==0), "POSIXSEEK"); - - /* check if all bytes are read */ - rc = ((ssize_t)buf_size == - POSIXREAD(fd->posixfd, buffer, buf_size)); - VRFY((rc != 0), "POSIXREAD"); - - /* Advance global offset in dataset */ - nbytes_xfer+=buf_size; - } /* end if */ - /* Interleaved access pattern */ - else { - /* Set the base of user's buffer */ - buf_p=(unsigned char *)buffer; - - /* Set the number of bytes to transfer this time */ - nbytes_toxfer = buf_size; - - /* Loop over the buffers to read */ - while(nbytes_toxfer>0) { - /* Skip offset over blocks of other processes */ - file_offset = posix_file_offset + - (off_t)(nbytes_xfer*pio_mpi_nprocs_g); - - /* only care if seek returns error */ - rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; - VRFY((rc==0), "POSIXSEEK"); - - /* check if all bytes are read */ - rc = ((ssize_t)blk_size == - POSIXREAD(fd->posixfd, buf_p, blk_size)); - VRFY((rc != 0), "POSIXREAD"); - - /* Advance location in buffer */ - buf_p+=blk_size; - - /* Advance global offset in dataset */ - nbytes_xfer+=blk_size; - - /* Decrement number of bytes left this time */ - nbytes_toxfer-=blk_size; - } /* end while */ - } /* end else */ - } /* end if */ - /* 2D dataspace */ - else { - /* Contiguous storage */ - if (!parms->h5_use_chunks) { - /* Contiguous access pattern */ - if (!parms->interleaved) { - /* Compute file offset */ - file_offset=posix_file_offset+(off_t)(((nbytes_xfer/blk_size) - /snbytes)*(blk_size*snbytes)+((nbytes_xfer/blk_size)%snbytes)); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = buf_size; - - /* Global offset advance after each I/O operation */ - file_offset_advance = (off_t)snbytes; - } /* end if */ - /* Interleaved access pattern */ - else { - /* Compute file offset */ - file_offset=posix_file_offset+(off_t)((((nbytes_xfer/buf_size) - *pio_mpi_nprocs_g)/snbytes)*(buf_size*snbytes) - +((nbytes_xfer/buf_size)*pio_mpi_nprocs_g)%snbytes); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size; - - /* Global offset advance after each I/O operation */ - file_offset_advance = (off_t)snbytes; - } /* end else */ - } /* end if */ - /* Chunked storage */ - else { - /*Contiguous access pattern */ - if (!parms->interleaved) { - /* Compute file offset */ - file_offset=posix_file_offset+(off_t)nbytes_xfer; - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size * buf_size; - - /* Global offset advance after each I/O operation */ - file_offset_advance = 0; - } /* end if */ - /*Interleaved access pattern */ - else { - /* Compute file offset */ - /* Before simplification */ - /* file_offset=posix_file_offset+(off_t)((nbytes_xfer/(buf_size/blk_size) - *pio_mpi_nprocs_g)/(snbytes/blk_size*(blk_size*blk_size))*(buf_size/blk_size - *snbytes/blk_size*(blk_size*blk_size))+((nbytes_xfer/(buf_size/blk_size)) - *pio_mpi_nprocs_g)%(snbytes/blk_size*(blk_size*blk_size))); */ - - file_offset=posix_file_offset+(off_t)(((nbytes_xfer/(buf_size/blk_size) - *pio_mpi_nprocs_g)/(snbytes*blk_size))*(buf_size*snbytes)+((nbytes_xfer/(buf_size/blk_size)) - *pio_mpi_nprocs_g)%(snbytes*blk_size)); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size * blk_size; - - /* Global offset advance after each I/O operation */ - /* file_offset_advance = (off_t)(snbytes/blk_size*(blk_size*blk_size)); */ - file_offset_advance = (off_t)(snbytes*blk_size); - } /* end else */ - } /* end else */ - - /* Common code for file access */ - - /* Set the base of user's buffer */ - buf_p = (unsigned char *)buffer; - - /* Set the number of bytes to transfer this time */ - nbytes_toxfer = buf_size*blk_size; - - /* Loop over portions of the buffer to read */ - while(nbytes_toxfer>0){ - /* only care if seek returns error */ - rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; - VRFY((rc==0), "POSIXSEEK"); - - /* check if all bytes are read */ - rc = ((ssize_t)nbytes_xfer_advance == - POSIXREAD(fd->posixfd, buf_p, nbytes_xfer_advance)); - VRFY((rc != 0), "POSIXREAD"); - - /* Advance location in buffer */ - buf_p+=nbytes_xfer_advance; - - /* Advance global offset in dataset */ - nbytes_xfer+=nbytes_xfer_advance; - - /* Decrement number of bytes left this time */ - nbytes_toxfer-=nbytes_xfer_advance; - - /* Partially advance file offset */ - file_offset+=file_offset_advance; - } /* end while */ - - } /* end else */ - break; - - case MPIO: - /* 1D dataspace */ - if (!parms->dim2d){ - /* Independent file access */ - if(!parms->collective) { - /* Contiguous pattern */ - if (!parms->interleaved){ - /* Compute offset in file */ - mpi_offset = mpi_file_offset + - nbytes_xfer; - - /* Perform independent read */ - mrc = MPI_File_read_at(fd->mpifd, mpi_offset, buffer, - (int)(buf_size/blk_size), mpi_blk_type, - &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_READ"); - - /* Advance global offset in dataset */ - nbytes_xfer+=buf_size; - } /* end if */ - /* Interleaved access pattern */ - else { - /* Set the base of user's buffer */ - buf_p=(unsigned char *)buffer; - - /* Set the number of bytes to transfer this time */ - nbytes_toxfer = buf_size; - - /* Loop over the buffers to read */ - while(nbytes_toxfer>0) { - /* Skip offset over blocks of other processes */ - mpi_offset = mpi_file_offset + - (nbytes_xfer*pio_mpi_nprocs_g); - - /* Perform independent read */ - mrc = MPI_File_read_at(fd->mpifd, mpi_offset, buf_p, - (int)1, mpi_blk_type, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_READ"); - - /* Advance location in buffer */ - buf_p+=blk_size; - - /* Advance global offset in dataset */ - nbytes_xfer+=blk_size; - - /* Decrement number of bytes left this time */ - nbytes_toxfer-=blk_size; - } /* end while */ - } /* end else */ - } /* end if */ - /* Collective file access */ - else { - /* Contiguous access pattern */ - if (!parms->interleaved){ - /* Compute offset in file */ - mpi_offset = mpi_file_offset + - nbytes_xfer; - - /* Perform collective read */ - mrc = MPI_File_read_at_all(fd->mpifd, mpi_offset, buffer, - (int)(buf_size/blk_size), mpi_blk_type, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_READ"); - - /* Advance global offset in dataset */ - nbytes_xfer+=buf_size; - } /* end if */ - /* Interleaved access pattern */ - else { - /* Compute offset in file */ - mpi_offset = mpi_file_offset + - (nbytes_xfer*pio_mpi_nprocs_g); - - /* Set the file view */ - mrc = MPI_File_set_view(fd->mpifd, mpi_offset, mpi_blk_type, - mpi_file_type, (char*)"native", h5_io_info_g); - VRFY((mrc==MPI_SUCCESS), "MPIO_VIEW"); - - /* Perform collective read */ - mrc = MPI_File_read_at_all(fd->mpifd, 0, buffer, - (int)(buf_size/blk_size), mpi_blk_type, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_READ"); - - /* Advance global offset in dataset */ - nbytes_xfer+=buf_size; - } /* end else */ - } /* end else */ - } /* end if */ - /* 2D dataspace */ - else { - /* Contiguous storage */ - if (!parms->h5_use_chunks) { - /* Contiguous access pattern */ - if (!parms->interleaved) { - /* Compute offset in file */ - mpi_offset=mpi_file_offset+((nbytes_xfer/blk_size)/snbytes)* - (blk_size*snbytes)+((nbytes_xfer/blk_size)%snbytes); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = buf_size; - - /* Global offset advance after each I/O operation */ - mpi_offset_advance = snbytes; - - /* MPI type to be used for collective access */ - mpi_collective_type = mpi_cont_type; - } /* end if */ - /* Interleaved access pattern */ - else { - /* Compute offset in file */ - mpi_offset=mpi_file_offset+(((nbytes_xfer/buf_size)*pio_mpi_nprocs_g)/snbytes)* - (buf_size*snbytes)+((nbytes_xfer/buf_size)*pio_mpi_nprocs_g)%snbytes; - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size; - - /* Global offset advance after each I/O operation */ - mpi_offset_advance = snbytes; - - /* MPI type to be used for collective access */ - mpi_collective_type = mpi_inter_type; - } /* end else */ - } /* end if */ - /* Chunked storage */ - else { - /*Contiguous access pattern */ - if (!parms->interleaved) { - /* Compute offset in file */ - mpi_offset=mpi_file_offset+nbytes_xfer; - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size * buf_size; - - /* Global offset advance after each I/O operation */ - mpi_offset_advance = 0; - - /* MPI type to be used for collective access */ - mpi_collective_type = mpi_full_buffer; - } /* end if */ - /*Interleaved access pattern */ - else { - /* Compute offset in file */ - /* Before simplification */ - /* mpi_offset=mpi_file_offset+(nbytes_xfer/(buf_size/blk_size) - *pio_mpi_nprocs_g)/(snbytes/blk_size*(blk_size*blk_size))* - (buf_size/blk_size*snbytes/blk_size*(blk_size*blk_size))+ - ((nbytes_xfer/(buf_size/blk_size))*pio_mpi_nprocs_g)%(snbytes - /blk_size*(blk_size*blk_size)); */ - mpi_offset=mpi_file_offset+((nbytes_xfer/(buf_size/blk_size) - *pio_mpi_nprocs_g)/(snbytes*blk_size))*(buf_size*snbytes) - +((nbytes_xfer/(buf_size/blk_size))*pio_mpi_nprocs_g)%(snbytes*blk_size); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size * blk_size; - - /* Global offset advance after each I/O operation */ - /* mpi_offset_advance = (MPI_Offset)(snbytes/blk_size*(blk_size*blk_size)); */ - mpi_offset_advance = (MPI_Offset)(snbytes*blk_size); - - /* MPI type to be used for collective access */ - mpi_collective_type = mpi_chunk_inter_type; - } /* end else */ - } /* end else */ - - /* Common code for independent file access */ - if (!parms->collective) { - /* Set the base of user's buffer */ - buf_p = (unsigned char *)buffer; - - /* Set the number of bytes to transfer this time */ - nbytes_toxfer = buf_size * blk_size; - - /* Loop over portions of the buffer to read */ - while(nbytes_toxfer>0){ - /* Perform independent read */ - mrc = MPI_File_read_at(fd->mpifd, mpi_offset, buf_p, - (int)nbytes_xfer_advance, MPI_BYTE, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_READ"); - - /* Advance location in buffer */ - buf_p+=nbytes_xfer_advance; - - /* Advance global offset in dataset */ - nbytes_xfer+=nbytes_xfer_advance; - - /* Decrement number of bytes left this time */ - nbytes_toxfer-=nbytes_xfer_advance; - - /* Partially advance global offset in dataset */ - mpi_offset+=mpi_offset_advance; - } /* end while */ - } /* end if */ - - /* Common code for collective file access */ - else { - /* Set the file view */ - mrc = MPI_File_set_view(fd->mpifd, mpi_offset, MPI_BYTE, - mpi_collective_type, (char *)"native", h5_io_info_g); - VRFY((mrc==MPI_SUCCESS), "MPIO_VIEW"); - - /* Perform read */ - MPI_File_read_at_all(fd->mpifd, 0, buffer,(int)(buf_size*blk_size), - MPI_BYTE, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_READ"); - - /* Advance global offset in dataset */ - nbytes_xfer+=buf_size*blk_size; - } /* end else */ - - } /* end else */ - break; - - case PHDF5: - /* 1D dataspace */ - if (!parms->dim2d){ - /* Set up the file dset space id to move the selection to process */ - if (!parms->interleaved){ - /* Contiguous pattern */ - h5offset[0] = nbytes_xfer; - } /* end if */ - else { - /* Interleaved access pattern */ - /* Skip offset over blocks of other processes */ - h5offset[0] = (nbytes_xfer*pio_mpi_nprocs_g); - } /* end else */ - hrc = H5Soffset_simple(h5dset_space_id, h5offset); - VRFY((hrc >= 0), "H5Soffset_simple"); - - /* Read the buffer in */ - hrc = H5Dread(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, - h5dset_space_id, h5dxpl, buffer); - VRFY((hrc >= 0), "H5Dread"); - - /* Increment number of bytes transferred */ - nbytes_xfer += buf_size; - } /* end if */ - /* 2D dataspace */ - else { - /* Set up the file dset space id to move the selection to process */ - if (!parms->interleaved){ - /* Contiguous pattern */ - h5offset[0] = (nbytes_xfer/(snbytes*blk_size))*blk_size; - h5offset[1] = (nbytes_xfer%(snbytes*blk_size))/blk_size; - } /* end if */ - else { - /* Interleaved access pattern */ - /* Skip offset over blocks of other processes */ - h5offset[0] = ((nbytes_xfer*pio_mpi_nprocs_g)/(snbytes*buf_size))*buf_size; - h5offset[1] = ((nbytes_xfer*pio_mpi_nprocs_g)%(snbytes*buf_size))/buf_size; - - } /* end else */ - hrc = H5Soffset_simple(h5dset_space_id, h5offset); - VRFY((hrc >= 0), "H5Soffset_simple"); - - /* Write the buffer out */ - hrc = H5Dread(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, - h5dset_space_id, h5dxpl, buffer); - VRFY((hrc >= 0), "H5Dread"); - - /* Increment number of bytes transferred */ - nbytes_xfer += buf_size*blk_size; - - } /* end else */ - break; - } /* switch (parms->io_type) */ - - /* Verify raw data, if asked */ - if (parms->verify) { - /* Verify data read */ - unsigned char *ucharptr = (unsigned char *)buffer; - size_t i; - int nerror=0; - - for (i = 0; i < bsize; ++i){ - if (*ucharptr++ != pio_mpi_rank_g+1) { - if (++nerror < 20){ - /* report at most 20 errors */ - HDprint_rank(output); - HDfprintf(output, "read data error, expected (%d), " - "got (%d)\n", - pio_mpi_rank_g+1, - (int)*(ucharptr-1)); - } /* end if */ - } /* end if */ - } /* end for */ - if (nerror >= 20) { - HDprint_rank(output); - HDfprintf(output, "..."); - HDfprintf(output, "total read data errors=%d\n", - nerror); - } /* end if */ - } /* if (parms->verify) */ - - } /* end while */ - - /* Stop "raw data" read timer */ - io_time_set(res->timers, HDF5_RAW_READ_FIXED_DIMS, TSTOP); - - /* Calculate read time */ - - /* Close dataset. Only HDF5 needs to do an explicit close. */ - if (parms->io_type == PHDF5) { - hrc = H5Dclose(h5ds_id); - - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Dataset Close failed\n"); - GOTOERROR(FAIL); - } - - h5ds_id = -1; - } /* end if */ - } /* end for */ - -done: - /* release MPI-I/O objects */ - if (parms->io_type == MPIO) { - /* 1D dataspace */ - if (!parms->dim2d){ - /* Free file type */ - mrc = MPI_Type_free( &mpi_file_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - - /* Free buffer type */ - mrc = MPI_Type_free( &mpi_blk_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - } /* end if */ - /* 2D dataspace */ - else { - /* Free partial buffer type for contiguous access */ - mrc = MPI_Type_free( &mpi_partial_buffer_cont ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - - /* Free contiguous file type */ - mrc = MPI_Type_free( &mpi_cont_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - - /* Free partial buffer type for interleaved access */ - mrc = MPI_Type_free( &mpi_partial_buffer_inter ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - - /* Free interleaved file type */ - mrc = MPI_Type_free( &mpi_inter_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - - /* Free full buffer type */ - mrc = MPI_Type_free(&mpi_full_buffer); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - - /* Free full chunk type */ - mrc = MPI_Type_free(&mpi_full_chunk); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - - /* Free chunk interleaved file type */ - mrc = MPI_Type_free(&mpi_chunk_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); - } /* end else */ - } /* end if */ - - /* release HDF5 objects */ - if (h5dset_space_id != -1) { - hrc = H5Sclose(h5dset_space_id); - if (hrc < 0){ - HDfprintf(stderr, "HDF5 Dataset Space Close failed\n"); - ret_code = FAIL; - } else { - h5dset_space_id = -1; - } - } - - if (h5mem_space_id != -1) { - hrc = H5Sclose(h5mem_space_id); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Memory Space Close failed\n"); - ret_code = FAIL; - } else { - h5mem_space_id = -1; - } - } - - if (h5dxpl != -1) { - hrc = H5Pclose(h5dxpl); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Dataset Transfer Property List Close failed\n"); - ret_code = FAIL; - } else { - h5dxpl = -1; - } - } - - return ret_code; -} - -/* - * Function: do_fopen - * Purpose: Open the specified file. - * Return: SUCCESS or FAIL - * Programmer: Albert Cheng, Bill Wendling, 2001/12/13 - * Modifications: - */ - static herr_t -do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, int flags) -{ - int ret_code = SUCCESS, mrc; - hid_t acc_tpl = -1; /* file access templates */ - - switch (param->io_type) { - case POSIXIO: - if (flags & (PIO_CREATE | PIO_WRITE)) - fd->posixfd = POSIXCREATE(fname); - else - fd->posixfd = POSIXOPEN(fname, O_RDONLY); - - if (fd->posixfd < 0 ) { - HDfprintf(stderr, "POSIX File Open failed(%s)\n", fname); - GOTOERROR(FAIL); - } - - - /* The perils of POSIX I/O in a parallel environment. The problem is: - * - * - Process n opens a file with truncation and then starts - * writing to the file. - * - Process m also opens the file with truncation, but after - * process n has already started to write to the file. Thus, - * all of the stuff process n wrote is now lost. - */ - MPI_Barrier(pio_comm_g); - - break; - - case MPIO: - if (flags & (PIO_CREATE | PIO_WRITE)) { - MPI_File_delete(fname, h5_io_info_g); - mrc = MPI_File_open(pio_comm_g, fname, MPI_MODE_CREATE | MPI_MODE_RDWR, - h5_io_info_g, &fd->mpifd); - - if (mrc != MPI_SUCCESS) { - HDfprintf(stderr, "MPI File Open failed(%s)\n", fname); - GOTOERROR(FAIL); - } - - /*since MPI_File_open with MPI_MODE_CREATE does not truncate */ - /*filesize , set size to 0 explicitedly. */ - mrc = MPI_File_set_size(fd->mpifd, (MPI_Offset)0); - if (mrc != MPI_SUCCESS) { - HDfprintf(stderr, "MPI_File_set_size failed\n"); - GOTOERROR(FAIL); - } - } else { - mrc = MPI_File_open(pio_comm_g, fname, MPI_MODE_RDONLY, h5_io_info_g, &fd->mpifd); - if (mrc != MPI_SUCCESS) { - HDfprintf(stderr, "MPI File Open failed(%s)\n", fname); - GOTOERROR(FAIL); - } - } - - break; - - case PHDF5: - if ((acc_tpl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { - HDfprintf(stderr, "HDF5 Property List Create failed\n"); - GOTOERROR(FAIL); - } - - /* Set the file driver to the MPI-IO driver */ - if (H5Pset_fapl_mpio(acc_tpl, pio_comm_g, h5_io_info_g) < 0) { - HDfprintf(stderr, "HDF5 Property List Set failed\n"); - GOTOERROR(FAIL); - } - - /* Set the alignment of objects in HDF5 file */ - if (H5Pset_alignment(acc_tpl, param->h5_thresh, param->h5_align) < 0) { - HDfprintf(stderr, "HDF5 Property List Set failed\n"); - GOTOERROR(FAIL); - } - - /* create the parallel file */ - if (flags & (PIO_CREATE | PIO_WRITE)) - fd->h5fd = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); - else - fd->h5fd = H5Fopen(fname, H5F_ACC_RDONLY, acc_tpl); - if (fd->h5fd < 0) { - HDfprintf(stderr, "HDF5 File Create failed(%s)\n", fname); - GOTOERROR(FAIL); - } - - /* verifying the close of the acc_tpl */ - if (H5Pclose(acc_tpl) < 0) { - HDfprintf(stderr, "HDF5 Property List Close failed\n"); - GOTOERROR(FAIL); - } - - break; - } - -done: - return ret_code; -} - -/* - * Function: do_fclose - * Purpose: Close the specified file descriptor. - * Return: SUCCESS or FAIL - * Programmer: Albert Cheng, Bill Wendling, 2001/12/13 - * Modifications: - */ - static herr_t -do_fclose(iotype iot, file_descr *fd /*out*/) -{ - herr_t ret_code = SUCCESS, hrc; - int mrc = 0, rc = 0; - - switch (iot) { - case POSIXIO: - rc = POSIXCLOSE(fd->posixfd); - - if (rc != 0){ - HDfprintf(stderr, "POSIX File Close failed\n"); - GOTOERROR(FAIL); - } - - fd->posixfd = -1; - break; - - case MPIO: - mrc = MPI_File_close(&fd->mpifd); - - if (mrc != MPI_SUCCESS){ - HDfprintf(stderr, "MPI File close failed\n"); - GOTOERROR(FAIL); - } - - fd->mpifd = MPI_FILE_NULL; - break; - - case PHDF5: - hrc = H5Fclose(fd->h5fd); - - if (hrc < 0) { - HDfprintf(stderr, "HDF5 File Close failed\n"); - GOTOERROR(FAIL); - } - - fd->h5fd = -1; - break; - } - -done: - return ret_code; -} - - -/* - * Function: do_fclose - * Purpose: Cleanup temporary file unless HDF5_NOCLEANUP is set. - * Only Proc 0 of the PIO communicator will do the cleanup. - * Other processes just return. - * Return: void - * Programmer: Albert Cheng 2001/12/12 - * Modifications: - */ - static void -do_cleanupfile(iotype iot, char *fname) -{ - if (pio_mpi_rank_g != 0) - return; - - if (clean_file_g == -1) - clean_file_g = (getenv("HDF5_NOCLEANUP")==NULL) ? 1 : 0; - - if (clean_file_g){ - switch (iot){ - case POSIXIO: - HDremove(fname); - break; - case MPIO: - case PHDF5: - MPI_File_delete(fname, h5_io_info_g); - break; - } - } -} - -#ifdef TIME_MPI -/* instrument the MPI_File_wrirte_xxx and read_xxx calls to measure - * pure time spent in MPI_File code. - */ -int MPI_File_read_at(MPI_File fh, MPI_Offset offset, void *buf, - int count, MPI_Datatype datatype, MPI_Status *status) -{ - int err; - io_time_set(timer_g, HDF5_MPI_READ, TSTART); - err=PMPI_File_read_at(fh, offset, buf, count, datatype, status); - io_time_set(timer_g, HDF5_MPI_READ, TSTOP); - return err; -} - - -int MPI_File_read_at_all(MPI_File fh, MPI_Offset offset, void *buf, - int count, MPI_Datatype datatype, MPI_Status *status) -{ - int err; - io_time_set(timer_g, HDF5_MPI_READ, TSTART); - err=PMPI_File_read_at_all(fh, offset, buf, count, datatype, status); - io_time_set(timer_g, HDF5_MPI_READ, TSTOP); - return err; -} - -int MPI_File_write_at(MPI_File fh, MPI_Offset offset, void *buf, - int count, MPI_Datatype datatype, MPI_Status *status) -{ - int err; - io_time_set(timer_g, HDF5_MPI_WRITE, TSTART); - err=PMPI_File_write_at(fh, offset, buf, count, datatype, status); - io_time_set(timer_g, HDF5_MPI_WRITE, TSTOP); - return err; -} - -int MPI_File_write_at_all(MPI_File fh, MPI_Offset offset, void *buf, - int count, MPI_Datatype datatype, MPI_Status *status) -{ - int err; - io_time_set(timer_g, HDF5_MPI_WRITE, TSTART); - err=PMPI_File_write_at_all(fh, offset, buf, count, datatype, status); - io_time_set(timer_g, HDF5_MPI_WRITE, TSTOP); - return err; -} - -#endif /* TIME_MPI */ -#endif /* H5_HAVE_PARALLEL */ - - - - - diff --git a/tools/test/perform/pio_perf.c b/tools/test/perform/pio_perf.c deleted file mode 100644 index 9f4d116..0000000 --- a/tools/test/perform/pio_perf.c +++ /dev/null @@ -1,1692 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * 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://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Parallel HDF5 Performance Testing Code - * -------------------------------------- - * - * Portable code to test performance on the different platforms we support. - * This is what the report should look like: - * - * nprocs = Max#Procs - * IO API = POSIXIO - * # Files = 1, # of dsets = 1000, Elements per dset = 37000 - * Write Results = x MB/s - * Read Results = x MB/s - * # Files = 1, # of dsets = 3000, Elements per dset = 37000 - * Write Results = x MB/s - * Read Results = x MB/s - * - * . . . - * - * IO API = MPIO - * # Files = 1, # of dsets = 1000, Elements per dset = 37000 - * Write Results = x MB/s - * Read Results = x MB/s - * # Files = 1, # of dsets = 3000, Elements per dset = 37000 - * Write Results = x MB/s - * Read Results = x MB/s - * - * . . . - * - * IO API = PHDF5 - * # Files = 1, # of dsets = 1000, Elements per dset = 37000 - * Write Results = x MB/s - * Read Results = x MB/s - * # Files = 1, # of dsets = 3000, Elements per dset = 37000 - * Write Results = x MB/s - * Read Results = x MB/s - * - * . . . - * - * nprocs = Max#Procs / 2 - * - * . . . - * - */ - -/* system header files */ -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> - -#include "hdf5.h" - -#ifdef H5_HAVE_PARALLEL - -/* library header files */ -#include <mpi.h> - -/* our header files */ -#include "pio_perf.h" - -/* useful macros */ -#define TAB_SPACE 4 - -#define ONE_KB 1024 -#define ONE_MB (ONE_KB * ONE_KB) -#define ONE_GB (ONE_MB * ONE_KB) - -#define PIO_POSIX 0x1 -#define PIO_MPI 0x2 -#define PIO_HDF5 0x4 - -/* report 0.0 in case t is zero too */ -#define MB_PER_SEC(bytes,t) (((t)==0.0) ? 0.0 : ((((double)bytes) / ONE_MB) / (t))) - -#ifndef TRUE -#define TRUE 1 -#endif /* TRUE */ -#ifndef FALSE -#define FALSE (!TRUE) -#endif /* FALSE */ - -/* global variables */ -FILE *output; /* output file */ -int comm_world_rank_g; /* my rank in MPI_COMM_RANK */ -int comm_world_nprocs_g;/* num. of processes of MPI_COMM_WORLD */ -MPI_Comm pio_comm_g; /* Communicator to run the PIO */ -int pio_mpi_rank_g; /* MPI rank of pio_comm_g */ -int pio_mpi_nprocs_g; /* Number of processes of pio_comm_g */ -int pio_debug_level = 0;/* The debug level: - * 0 - Off - * 1 - Minimal - * 2 - Some more - * 3 - Maximal - * 4 - Maximal & then some - */ - -/* local variables */ -static const char *progname = "h5perf"; - -/* - * Command-line options: The user can specify short or long-named - * parameters. The long-named ones can be partially spelled. When - * adding more, make sure that they don't clash with each other. - */ -#if 1 -static const char *s_opts = "a:A:B:cCd:D:e:F:ghi:Imno:p:P:stT:wx:X:"; -#else -static const char *s_opts = "a:A:bB:cCd:D:e:F:ghi:Imno:p:P:stT:wx:X:"; -#endif /* 1 */ -static struct long_options l_opts[] = { - { "align", require_arg, 'a' }, - { "alig", require_arg, 'a' }, - { "ali", require_arg, 'a' }, - { "al", require_arg, 'a' }, - { "api", require_arg, 'A' }, - { "ap", require_arg, 'A' }, -#if 0 - /* a sighting of the elusive binary option */ - { "binary", no_arg, 'b' }, - { "binar", no_arg, 'b' }, - { "bina", no_arg, 'b' }, - { "bin", no_arg, 'b' }, - { "bi", no_arg, 'b' }, -#endif /* 0 */ - { "block-size", require_arg, 'B' }, - { "block-siz", require_arg, 'B' }, - { "block-si", require_arg, 'B' }, - { "block-s", require_arg, 'B' }, - { "block-", require_arg, 'B' }, - { "block", require_arg, 'B' }, - { "bloc", require_arg, 'B' }, - { "blo", require_arg, 'B' }, - { "bl", require_arg, 'B' }, - { "chunk", no_arg, 'c' }, - { "chun", no_arg, 'c' }, - { "chu", no_arg, 'c' }, - { "ch", no_arg, 'c' }, - { "collective", no_arg, 'C' }, - { "collectiv", no_arg, 'C' }, - { "collecti", no_arg, 'C' }, - { "collect", no_arg, 'C' }, - { "collec", no_arg, 'C' }, - { "colle", no_arg, 'C' }, - { "coll", no_arg, 'C' }, - { "col", no_arg, 'C' }, - { "co", no_arg, 'C' }, - { "debug", require_arg, 'D' }, - { "debu", require_arg, 'D' }, - { "deb", require_arg, 'D' }, - { "de", require_arg, 'D' }, - { "geometry", no_arg, 'g' }, - { "geometr", no_arg, 'g' }, - { "geomet", no_arg, 'g' }, - { "geome", no_arg, 'g' }, - { "geom", no_arg, 'g' }, - { "geo", no_arg, 'g' }, - { "ge", no_arg, 'g' }, - { "help", no_arg, 'h' }, - { "hel", no_arg, 'h' }, - { "he", no_arg, 'h' }, - { "interleaved", require_arg, 'I' }, - { "interleave", require_arg, 'I' }, - { "interleav", require_arg, 'I' }, - { "interlea", require_arg, 'I' }, - { "interle", require_arg, 'I' }, - { "interl", require_arg, 'I' }, - { "inter", require_arg, 'I' }, - { "inte", require_arg, 'I' }, - { "int", require_arg, 'I' }, - { "in", require_arg, 'I' }, - { "max-num-processes", require_arg, 'P' }, - { "max-num-processe", require_arg, 'P' }, - { "max-num-process", require_arg, 'P' }, - { "max-num-proces", require_arg, 'P' }, - { "max-num-proce", require_arg, 'P' }, - { "max-num-proc", require_arg, 'P' }, - { "max-num-pro", require_arg, 'P' }, - { "max-num-pr", require_arg, 'P' }, - { "max-num-p", require_arg, 'P' }, - { "min-num-processes", require_arg, 'p' }, - { "min-num-processe", require_arg, 'p' }, - { "min-num-process", require_arg, 'p' }, - { "min-num-proces", require_arg, 'p' }, - { "min-num-proce", require_arg, 'p' }, - { "min-num-proc", require_arg, 'p' }, - { "min-num-pro", require_arg, 'p' }, - { "min-num-pr", require_arg, 'p' }, - { "min-num-p", require_arg, 'p' }, - { "max-xfer-size", require_arg, 'X' }, - { "max-xfer-siz", require_arg, 'X' }, - { "max-xfer-si", require_arg, 'X' }, - { "max-xfer-s", require_arg, 'X' }, - { "max-xfer", require_arg, 'X' }, - { "max-xfe", require_arg, 'X' }, - { "max-xf", require_arg, 'X' }, - { "max-x", require_arg, 'X' }, - { "min-xfer-size", require_arg, 'x' }, - { "min-xfer-siz", require_arg, 'x' }, - { "min-xfer-si", require_arg, 'x' }, - { "min-xfer-s", require_arg, 'x' }, - { "min-xfer", require_arg, 'x' }, - { "min-xfe", require_arg, 'x' }, - { "min-xf", require_arg, 'x' }, - { "min-x", require_arg, 'x' }, - { "num-bytes", require_arg, 'e' }, - { "num-byte", require_arg, 'e' }, - { "num-byt", require_arg, 'e' }, - { "num-by", require_arg, 'e' }, - { "num-b", require_arg, 'e' }, - { "num-dsets", require_arg, 'd' }, - { "num-dset", require_arg, 'd' }, - { "num-dse", require_arg, 'd' }, - { "num-ds", require_arg, 'd' }, - { "num-d", require_arg, 'd' }, - { "num-files", require_arg, 'F' }, - { "num-file", require_arg, 'F' }, - { "num-fil", require_arg, 'F' }, - { "num-fi", require_arg, 'F' }, - { "num-f", require_arg, 'F' }, - { "num-iterations", require_arg, 'i' }, - { "num-iteration", require_arg, 'i' }, - { "num-iteratio", require_arg, 'i' }, - { "num-iterati", require_arg, 'i' }, - { "num-iterat", require_arg, 'i' }, - { "num-itera", require_arg, 'i' }, - { "num-iter", require_arg, 'i' }, - { "num-ite", require_arg, 'i' }, - { "num-it", require_arg, 'i' }, - { "num-i", require_arg, 'i' }, - { "output", require_arg, 'o' }, - { "outpu", require_arg, 'o' }, - { "outp", require_arg, 'o' }, - { "out", require_arg, 'o' }, - { "ou", require_arg, 'o' }, - { "threshold", require_arg, 'T' }, - { "threshol", require_arg, 'T' }, - { "thresho", require_arg, 'T' }, - { "thresh", require_arg, 'T' }, - { "thres", require_arg, 'T' }, - { "thre", require_arg, 'T' }, - { "thr", require_arg, 'T' }, - { "th", require_arg, 'T' }, - { "write-only", require_arg, 'w' }, - { "write-onl", require_arg, 'w' }, - { "write-on", require_arg, 'w' }, - { "write-o", require_arg, 'w' }, - { "write", require_arg, 'w' }, - { "writ", require_arg, 'w' }, - { "wri", require_arg, 'w' }, - { "wr", require_arg, 'w' }, - { NULL, 0, '\0' } -}; - -struct options { - long io_types; /* bitmask of which I/O types to test */ - const char *output_file; /* file to print report to */ - long num_dsets; /* number of datasets */ - long num_files; /* number of files */ - off_t num_bpp; /* number of bytes per proc per dset */ - int num_iters; /* number of iterations */ - int max_num_procs; /* maximum number of processes to use */ - int min_num_procs; /* minimum number of processes to use */ - size_t max_xfer_size; /* maximum transfer buffer size */ - size_t min_xfer_size; /* minimum transfer buffer size */ - size_t blk_size; /* Block size */ - unsigned interleaved; /* Interleaved vs. contiguous blocks */ - unsigned collective; /* Collective vs. independent I/O */ - unsigned dim2d; /* 1D vs. 2D geometry */ - int print_times; /* print times as well as throughputs */ - int print_raw; /* print raw data throughput info */ - off_t h5_alignment; /* alignment in HDF5 file */ - off_t h5_threshold; /* threshold for alignment in HDF5 file */ - int h5_use_chunks; /* Make HDF5 dataset chunked */ - int h5_write_only; /* Perform the write tests only */ - int verify; /* Verify data correctness */ -}; - -typedef struct _minmax { - double min; - double max; - double sum; - int num; -} minmax; - -/* local functions */ -static off_t parse_size_directive(const char *size); -static struct options *parse_command_line(int argc, char *argv[]); -static void run_test_loop(struct options *options); -static int run_test(iotype iot, parameters parms, struct options *opts); -static void output_all_info(minmax *mm, int count, int indent_level); -static void get_minmax(minmax *mm, double val); -static minmax accumulate_minmax_stuff(minmax *mm, int count); -static int create_comm_world(int num_procs, int *doing_pio); -static int destroy_comm_world(void); -static void output_results(const struct options *options, const char *name, - minmax *table, int table_size, off_t data_size); -static void output_times(const struct options *options, const char *name, - minmax *table, int table_size); -static void output_report(const char *fmt, ...); -static void print_indent(register int indent); -static void usage(const char *prog); -static void report_parameters(struct options *opts); - -/* - * Function: main - * Purpose: Start things up. Initialize MPI and then call the test looping - * function. - * Return: EXIT_SUCCESS or EXIT_FAILURE - * Programmer: Bill Wendling, 30. October 2001 - * Modifications: - */ -int -main(int argc, char **argv) -{ - int ret; - int exit_value = EXIT_SUCCESS; - struct options *opts = NULL; - -#ifndef STANDALONE - /* Initialize h5tools lib */ - h5tools_init(); -#endif - - output = stdout; - - /* initialize MPI and get the maximum num of processors we started with */ - MPI_Init(&argc, &argv); - ret = MPI_Comm_size(MPI_COMM_WORLD, &comm_world_nprocs_g); - - if (ret != MPI_SUCCESS) { - HDfprintf(stderr, "%s: MPI_Comm_size call failed\n", progname); - - if (ret == MPI_ERR_COMM) - HDfprintf(stderr, "invalid MPI communicator\n"); - else - HDfprintf(stderr, "invalid argument\n"); - - exit_value = EXIT_FAILURE; - goto finish; - } - - ret = MPI_Comm_rank(MPI_COMM_WORLD, &comm_world_rank_g); - - if (ret != MPI_SUCCESS) { - HDfprintf(stderr, "%s: MPI_Comm_rank call failed\n", progname); - - if (ret == MPI_ERR_COMM) - HDfprintf(stderr, "invalid MPI communicator\n"); - else - HDfprintf(stderr, "invalid argument\n"); - - exit_value = EXIT_FAILURE; - goto finish; - } - - pio_comm_g = MPI_COMM_WORLD; - - h5_set_info_object(); - opts = parse_command_line(argc, argv); - - if (!opts) { - exit_value = EXIT_FAILURE; - goto finish; - } - - if (opts->output_file) { - if ((output = HDfopen(opts->output_file, "w")) == NULL) { - HDfprintf(stderr, "%s: cannot open output file\n", progname); - perror(opts->output_file); - goto finish; - } - } - - if ((pio_debug_level == 0 && comm_world_rank_g == 0) || pio_debug_level > 0) - report_parameters(opts); - - run_test_loop(opts); - -finish: - MPI_Finalize(); - free(opts); - return exit_value; -} - -/* - * Function: run_test_loop - * Purpose: Run the I/O tests. Write the results to OUTPUT. - * - * - The slowest changing part of the test is the number of - * processors to use. For each loop iteration, we divide that - * number by 2 and rerun the test. - * - * - The second slowest is what type of IO API to perform. We have - * three choices: POSIXIO, MPI-IO, and PHDF5. - * - * - Then we change the size of the buffer. This information is - * inferred from the number of datasets to create and the number - * of integers to put into each dataset. The backend code figures - * this out. - * - * Return: Nothing - * Programmer: Bill Wendling, 30. October 2001 - * Modifications: - * Added 2D testing (Christian Chilan, 10. August 2005) - */ -static void -run_test_loop(struct options *opts) -{ - parameters parms; - int num_procs; - int doing_pio; /* if this process is doing PIO */ - - parms.num_files = opts->num_files; - parms.num_dsets = opts->num_dsets; - parms.num_iters = opts->num_iters; - parms.blk_size = opts->blk_size; - parms.interleaved = opts->interleaved; - parms.collective = opts->collective; - parms.dim2d = opts->dim2d; - parms.h5_align = opts->h5_alignment; - parms.h5_thresh = opts->h5_threshold; - parms.h5_use_chunks = opts->h5_use_chunks; - parms.h5_write_only = opts->h5_write_only; - parms.verify = opts->verify; - - /* start with max_num_procs and decrement it by half for each loop. */ - /* if performance needs restart, fewer processes may be needed. */ - for (num_procs = opts->max_num_procs; - num_procs >= opts->min_num_procs; num_procs >>= 1) { - register size_t buf_size; - - parms.num_procs = num_procs; - - if (create_comm_world(parms.num_procs, &doing_pio) != SUCCESS) { - /* do something harsh */ - } - - /* only processes doing PIO will run the tests */ - if (doing_pio){ - output_report("Number of processors = %ld\n", parms.num_procs); - - /* multiply the xfer buffer size by 2 for each loop iteration */ - for (buf_size = opts->min_xfer_size; - buf_size <= opts->max_xfer_size; buf_size <<= 1) { - parms.buf_size = buf_size; - - if (parms.dim2d){ - parms.num_bytes = (off_t)pow((double)(opts->num_bpp*parms.num_procs),2); - if (parms.interleaved) - output_report("Transfer Buffer Size: %ldx%ld bytes, File size: %.2f MB\n", - buf_size, opts->blk_size, - ((double)parms.num_dsets * (double)parms.num_bytes) - / ONE_MB); - else - output_report("Transfer Buffer Size: %ldx%ld bytes, File size: %.2f MB\n", - opts->blk_size, buf_size, - ((double)parms.num_dsets * (double)parms.num_bytes) - / ONE_MB); - - print_indent(1); - output_report(" # of files: %ld, # of datasets: %ld, dataset size: %.2fx%.2f KB\n", - parms.num_files, parms.num_dsets, (double)(opts->num_bpp*parms.num_procs)/ONE_KB, - (double)(opts->num_bpp*parms.num_procs)/ONE_KB); - } - else{ - parms.num_bytes = (off_t)opts->num_bpp*parms.num_procs; - output_report("Transfer Buffer Size: %ld bytes, File size: %.2f MB\n", - buf_size,((double)parms.num_dsets * (double)parms.num_bytes) / ONE_MB); - - print_indent(1); - output_report(" # of files: %ld, # of datasets: %ld, dataset size: %.2f MB\n", - parms.num_files, parms.num_dsets, (double)(opts->num_bpp*parms.num_procs)/ONE_MB); - } - - if (opts->io_types & PIO_POSIX) - run_test(POSIXIO, parms, opts); - - if (opts->io_types & PIO_MPI) - run_test(MPIO, parms, opts); - - if (opts->io_types & PIO_HDF5) - run_test(PHDF5, parms, opts); - - /* Run the tests once if buf_size==0, but then break out */ - if(buf_size==0) - break; - } - - if (destroy_comm_world() != SUCCESS) { - /* do something harsh */ - } - } - } -} - -/* - * Function: run_test - * Purpose: Inner loop call to actually run the I/O test. - * Return: Nothing - * Programmer: Bill Wendling, 18. December 2001 - * Modifications: - */ -static int -run_test(iotype iot, parameters parms, struct options *opts) -{ - results res; - register int i, ret_value = SUCCESS; - int comm_size; - off_t raw_size; - minmax *write_mpi_mm_table=NULL; - minmax *write_mm_table=NULL; - minmax *write_gross_mm_table=NULL; - minmax *write_raw_mm_table=NULL; - minmax *read_mpi_mm_table=NULL; - minmax *read_mm_table=NULL; - minmax *read_gross_mm_table=NULL; - minmax *read_raw_mm_table=NULL; - minmax *read_open_mm_table=NULL; - minmax *read_close_mm_table=NULL; - minmax *write_open_mm_table=NULL; - minmax *write_close_mm_table=NULL; - minmax write_mpi_mm = {0.0, 0.0, 0.0, 0}; - minmax write_mm = {0.0, 0.0, 0.0, 0}; - minmax write_gross_mm = {0.0, 0.0, 0.0, 0}; - minmax write_raw_mm = {0.0, 0.0, 0.0, 0}; - minmax read_mpi_mm = {0.0, 0.0, 0.0, 0}; - minmax read_mm = {0.0, 0.0, 0.0, 0}; - minmax read_gross_mm = {0.0, 0.0, 0.0, 0}; - minmax read_raw_mm = {0.0, 0.0, 0.0, 0}; - minmax read_open_mm = {0.0, 0.0, 0.0, 0}; - minmax read_close_mm = {0.0, 0.0, 0.0, 0}; - minmax write_open_mm = {0.0, 0.0, 0.0, 0}; - minmax write_close_mm = {0.0, 0.0, 0.0, 0}; - - raw_size = parms.num_files * (off_t)parms.num_dsets * (off_t)parms.num_bytes; - parms.io_type = iot; - print_indent(2); - output_report("IO API = "); - - switch (iot) { - case POSIXIO: - output_report("POSIX\n"); - break; - case MPIO: - output_report("MPIO\n"); - break; - case PHDF5: - output_report("PHDF5 (w/MPI-IO driver)\n"); - break; - } - - MPI_Comm_size(pio_comm_g, &comm_size); - - /* allocate space for tables minmax and that it is sufficient */ - /* to initialize all elements to zeros by calloc. */ - write_mpi_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - write_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - write_gross_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - write_raw_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - write_open_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - write_close_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - if (!parms.h5_write_only) { - read_mpi_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - read_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - read_gross_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - read_raw_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - read_open_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - read_close_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - } - - /* Do IO iteration times, collecting statistics each time */ - for (i = 0; i < parms.num_iters; ++i) { - double t; - - MPI_Barrier(pio_comm_g); - res = do_pio(parms); - - /* gather all of the "mpi write" times */ - t = io_time_get(res.timers, HDF5_MPI_WRITE); - get_minmax(&write_mpi_mm, t); - - write_mpi_mm_table[i] = write_mpi_mm; - - /* gather all of the "write" times */ - t = io_time_get(res.timers, HDF5_FINE_WRITE_FIXED_DIMS); - get_minmax(&write_mm, t); - - write_mm_table[i] = write_mm; - - /* gather all of the "write" times from open to close */ - t = io_time_get(res.timers, HDF5_GROSS_WRITE_FIXED_DIMS); - get_minmax(&write_gross_mm, t); - - write_gross_mm_table[i] = write_gross_mm; - - /* gather all of the raw "write" times */ - t = io_time_get(res.timers, HDF5_RAW_WRITE_FIXED_DIMS); - get_minmax(&write_raw_mm, t); - - write_raw_mm_table[i] = write_raw_mm; - - /* gather all of the file open times (time from open to first write) */ - t = io_time_get(res.timers, HDF5_FILE_WRITE_OPEN); - get_minmax(&write_open_mm, t); - - write_open_mm_table[i] = write_open_mm; - - /* gather all of the file close times (time from last write to close) */ - t = io_time_get(res.timers, HDF5_FILE_WRITE_CLOSE); - get_minmax(&write_close_mm, t); - - write_close_mm_table[i] = write_close_mm; - - if (!parms.h5_write_only) { - /* gather all of the "mpi read" times */ - t = io_time_get(res.timers, HDF5_MPI_READ); - get_minmax(&read_mpi_mm, t); - - read_mpi_mm_table[i] = read_mpi_mm; - - /* gather all of the "read" times */ - t = io_time_get(res.timers, HDF5_FINE_READ_FIXED_DIMS); - get_minmax(&read_mm, t); - - read_mm_table[i] = read_mm; - - /* gather all of the "read" times from open to close */ - t = io_time_get(res.timers, HDF5_GROSS_READ_FIXED_DIMS); - get_minmax(&read_gross_mm, t); - - read_gross_mm_table[i] = read_gross_mm; - - /* gather all of the raw "read" times */ - t = io_time_get(res.timers, HDF5_RAW_READ_FIXED_DIMS); - get_minmax(&read_raw_mm, t); - - read_raw_mm_table[i] = read_raw_mm; - - /* gather all of the file open times (time from open to first read) */ - t = io_time_get(res.timers, HDF5_FILE_READ_OPEN); - get_minmax(&read_open_mm, t); - - read_open_mm_table[i] = read_open_mm; - - /* gather all of the file close times (time from last read to close) */ - t = io_time_get(res.timers, HDF5_FILE_READ_CLOSE); - get_minmax(&read_close_mm, t); - - read_close_mm_table[i] = read_close_mm; - - } - - io_time_destroy(res.timers); - } - - /* - * Show various statistics - */ - /* Write statistics */ - /* Print the raw data throughput if desired */ - if (opts->print_raw) { - /* accumulate and output the max, min, and average "raw write" times */ - if (pio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Raw Data Write details:\n"); - output_all_info(write_raw_mm_table, parms.num_iters, 4); - } - - output_results(opts,"Raw Data Write",write_raw_mm_table,parms.num_iters,raw_size); - } /* end if */ - - /* show mpi write statics */ - if (pio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("MPI Write details:\n"); - output_all_info(write_mpi_mm_table, parms.num_iters, 4); - } - - /* We don't currently output the MPI write results */ - - /* accumulate and output the max, min, and average "write" times */ - if (pio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Write details:\n"); - output_all_info(write_mm_table, parms.num_iters, 4); - } - - output_results(opts,"Write",write_mm_table,parms.num_iters,raw_size); - - /* accumulate and output the max, min, and average "gross write" times */ - if (pio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Write Open-Close details:\n"); - output_all_info(write_gross_mm_table, parms.num_iters, 4); - } - - output_results(opts,"Write Open-Close",write_gross_mm_table,parms.num_iters,raw_size); - - if (opts->print_times) { - output_times(opts,"Write File Open",write_open_mm_table,parms.num_iters); - output_times(opts,"Write File Close",write_close_mm_table,parms.num_iters); - } - - /* Print out time from open to first write */ - if (pio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Write file open details:\n"); - output_all_info(write_open_mm_table, parms.num_iters, 4); - } - - /* Print out time from last write to close */ - if (pio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Write file close details:\n"); - output_all_info(write_close_mm_table, parms.num_iters, 4); - } - - if (!parms.h5_write_only) { - /* Read statistics */ - /* Print the raw data throughput if desired */ - if (opts->print_raw) { - /* accumulate and output the max, min, and average "raw read" times */ - if (pio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Raw Data Read details:\n"); - output_all_info(read_raw_mm_table, parms.num_iters, 4); - } - - output_results(opts, "Raw Data Read", read_raw_mm_table, - parms.num_iters, raw_size); - } /* end if */ - - /* show mpi read statics */ - if (pio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("MPI Read details:\n"); - output_all_info(read_mpi_mm_table, parms.num_iters, 4); - } - - /* We don't currently output the MPI read results */ - - /* accumulate and output the max, min, and average "read" times */ - if (pio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Read details:\n"); - output_all_info(read_mm_table, parms.num_iters, 4); - } - - output_results(opts, "Read", read_mm_table, parms.num_iters, raw_size); - - /* accumulate and output the max, min, and average "gross read" times */ - if (pio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Read Open-Close details:\n"); - output_all_info(read_gross_mm_table, parms.num_iters, 4); - } - - output_results(opts, "Read Open-Close", read_gross_mm_table,parms.num_iters, raw_size); - - if (opts->print_times) { - output_times(opts,"Read File Open",read_open_mm_table,parms.num_iters); - output_times(opts,"Read File Close",read_close_mm_table,parms.num_iters); - } - - /* Print out time from open to first read */ - if (pio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Read file open details:\n"); - output_all_info(read_open_mm_table, parms.num_iters, 4); - } - - /* Print out time from last read to close */ - if (pio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Read file close details:\n"); - output_all_info(read_close_mm_table, parms.num_iters, 4); - } - - } - - /* clean up our mess */ - free(write_mpi_mm_table); - free(write_mm_table); - free(write_gross_mm_table); - free(write_raw_mm_table); - free(write_open_mm_table); - free(write_close_mm_table); - - if (!parms.h5_write_only) { - free(read_mpi_mm_table); - free(read_mm_table); - free(read_gross_mm_table); - free(read_raw_mm_table); - free(read_open_mm_table); - free(read_close_mm_table); - } - - return ret_value; -} - -/* - * Function: output_all_info - * Purpose: - * Return: Nothing - * Programmer: Bill Wendling, 29. January 2002 - * Modifications: - */ -static void -output_all_info(minmax *mm, int count, int indent_level) -{ - int i; - - for (i = 0; i < count; ++i) { - print_indent(indent_level); - output_report("Iteration %d:\n", i + 1); - print_indent(indent_level + 1); - output_report("Minimum Time: %.2fs\n", mm[i].min); - print_indent(indent_level + 1); - output_report("Maximum Time: %.2fs\n", mm[i].max); - } -} - -/* - * Function: get_minmax - * Purpose: Gather all the min, max and total of val. - * Return: Nothing - * Programmer: Bill Wendling, 21. December 2001 - * Modifications: - * Use MPI_Allreduce to do it. -akc, 2002/01/11 - */ -static void -get_minmax(minmax *mm, double val) -{ - int myrank; - - MPI_Comm_rank(pio_comm_g, &myrank); - MPI_Comm_size(pio_comm_g, &mm->num); - - MPI_Allreduce(&val, &mm->max, 1, MPI_DOUBLE, MPI_MAX, pio_comm_g); - MPI_Allreduce(&val, &mm->min, 1, MPI_DOUBLE, MPI_MIN, pio_comm_g); - MPI_Allreduce(&val, &mm->sum, 1, MPI_DOUBLE, MPI_SUM, pio_comm_g); -} - -/* - * Function: accumulate_minmax_stuff - * Purpose: Accumulate the minimum, maximum, and average of the times - * across all processes. - * Return: TOTAL_MM - the total of all of these. - * Programmer: Bill Wendling, 21. December 2001 - * Modifications: - * Changed to use seconds instead of MB/s - QAK, 5/9/02 - */ -static minmax -accumulate_minmax_stuff(minmax *mm, int count) -{ - int i; - minmax total_mm; - - total_mm.sum = 0.0; - total_mm.max = -DBL_MAX; - total_mm.min = DBL_MAX; - total_mm.num = count; - - for (i = 0; i < count; ++i) { - double m = mm[i].max; - - total_mm.sum += m; - - if (m < total_mm.min) - total_mm.min = m; - - if (m > total_mm.max) - total_mm.max = m; - } - - return total_mm; -} - -/* - * Function: create_comm_world - * Purpose: Create an MPI Comm world and store it in pio_comm_g, which - * is a global variable. - * Return: SUCCESS on success. - * FAIL otherwise. - * Programmer: Bill Wendling, 19. December 2001 - * Modifications: - */ -static int -create_comm_world(int num_procs, int *doing_pio) -{ - /* MPI variables */ - int mrc; /* return values */ - int color; /* for communicator creation */ - int myrank, nprocs; - - pio_comm_g = MPI_COMM_NULL; - - /* - * Create a sub communicator for this PIO run. Easier to use the first N - * processes. - */ - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - - if (num_procs > nprocs) { - HDfprintf(stderr, - "number of process(%d) must be <= number of processes in MPI_COMM_WORLD(%d)\n", - num_procs, nprocs); - goto error_done; - } - - MPI_Comm_rank(MPI_COMM_WORLD, &myrank); - color = (myrank < num_procs); - mrc = MPI_Comm_split(MPI_COMM_WORLD, color, myrank, &pio_comm_g); - - if (mrc != MPI_SUCCESS) { - HDfprintf(stderr, "MPI_Comm_split failed\n"); - goto error_done; - } - - if (!color) { - /* not involved in this run */ - mrc = destroy_comm_world(); - goto done; - } - - /* determine the MPI rank in the PIO communicator */ - MPI_Comm_size(pio_comm_g, &pio_mpi_nprocs_g); - MPI_Comm_rank(pio_comm_g, &pio_mpi_rank_g); - -done: - *doing_pio = color; - return SUCCESS; - -error_done: - destroy_comm_world(); - return FAIL; -} - -/* - * Function: destroy_comm_world - * Purpose: Destroy the created MPI Comm world which is stored in the - * pio_comm_g global variable. - * Return: SUCCESS on success. - * FAIL otherwise. - * Programmer: Bill Wendling, 19. December 2001 - * Modifications: - */ -static int -destroy_comm_world(void) -{ - int mrc = SUCCESS; /* return code */ - - /* release MPI resources */ - if (pio_comm_g != MPI_COMM_NULL) - mrc = (MPI_Comm_free(&pio_comm_g) == MPI_SUCCESS ? SUCCESS : FAIL); - - return mrc; -} - -/* - * Function: output_results - * Purpose: Print information about the time & bandwidth for a given - * minmax & # of iterations. - * Return: Nothing - * Programmer: Quincey Koziol, 9. May 2002 - * Modifications: - */ -static void -output_results(const struct options *opts, const char *name, minmax *table, - int table_size,off_t data_size) -{ - minmax total_mm; - - total_mm = accumulate_minmax_stuff(table, table_size); - - print_indent(3); - output_report("%s (%d iteration(s)):\n", name,table_size); - - /* Note: The maximum throughput uses the minimum amount of time & vice versa */ - - print_indent(4); - output_report("Maximum Throughput: %6.2f MB/s", MB_PER_SEC(data_size,total_mm.min)); - if(opts->print_times) - output_report(" (%7.3f s)\n", total_mm.min); - else - output_report("\n"); - - print_indent(4); - output_report("Average Throughput: %6.2f MB/s", - MB_PER_SEC(data_size,total_mm.sum / total_mm.num)); - if(opts->print_times) - output_report(" (%7.3f s)\n", (total_mm.sum / total_mm.num)); - else - output_report("\n"); - - print_indent(4); - output_report("Minimum Throughput: %6.2f MB/s", MB_PER_SEC(data_size,total_mm.max)); - if(opts->print_times) - output_report(" (%7.3f s)\n", total_mm.max); - else - output_report("\n"); - -} - -static void -output_times(const struct options *opts, const char *name, minmax *table, - int table_size) -{ - minmax total_mm; - - total_mm = accumulate_minmax_stuff(table, table_size); - - print_indent(3); - output_report("%s (%d iteration(s)):\n", name,table_size); - - /* Note: The maximum throughput uses the minimum amount of time & vice versa */ - - print_indent(4); - output_report("Minimum Accumulated Time using %d file(s): %7.5f s\n", opts->num_files,(total_mm.min)); - - print_indent(4); - output_report("Average Accumulated Time using %d file(s): %7.5f s\n", opts->num_files,(total_mm.sum / total_mm.num)); - - print_indent(4); - output_report("Maximum Accumulated Time using %d file(s): %7.5f s\n", opts->num_files,(total_mm.max)); -} - -/* - * Function: output_report - * Purpose: Print a line of the report. Only do so if I'm the 0 process. - * Return: Nothing - * Programmer: Bill Wendling, 19. December 2001 - * Modifications: - */ -static void -output_report(const char *fmt, ...) -{ - int myrank; - - MPI_Comm_rank(pio_comm_g, &myrank); - - if (myrank == 0) { - va_list ap; - - HDva_start(ap, fmt); - HDvfprintf(output, fmt, ap); - HDva_end(ap); - } -} - -/* - * Function: print_indent - * Purpose: Print spaces to indent a new line of text for pretty printing - * things. - * Return: Nothing - * Programmer: Bill Wendling, 29. October 2001 - * Modifications: - */ -static void -print_indent(register int indent) -{ - int myrank; - - MPI_Comm_rank(pio_comm_g, &myrank); - - if (myrank == 0) { - indent *= TAB_SPACE; - - for (; indent > 0; --indent) - HDfputc(' ', output); - } -} - -static void -recover_size_and_print(long long val, const char *end) -{ - if (val >= ONE_KB && (val % ONE_KB) == 0) { - if (val >= ONE_MB && (val % ONE_MB) == 0) { - if (val >= ONE_GB && (val % ONE_GB) == 0) - HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""GB%s", val / ONE_GB, end); - else - HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""MB%s", val / ONE_MB, end); - } else { - HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""KB%s", val / ONE_KB, end); - } - } else { - HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""%s", val, end); - } -} - -static void -print_io_api(long io_types) -{ - if (io_types & PIO_POSIX) - HDfprintf(output, "posix "); - if (io_types & PIO_MPI) - HDfprintf(output, "mpiio "); - if (io_types & PIO_HDF5) - HDfprintf(output, "phdf5 "); - HDfprintf(output, "\n"); -} - -static void -report_parameters(struct options *opts) -{ - int rank = comm_world_rank_g; - - print_version("HDF5 Library"); /* print library version */ - HDfprintf(output, "rank %d: ==== Parameters ====\n", rank); - - HDfprintf(output, "rank %d: IO API=", rank); - print_io_api(opts->io_types); - - HDfprintf(output, "rank %d: Number of files=%ld\n", rank, - opts->num_files); - HDfprintf(output, "rank %d: Number of datasets=%ld\n", rank, - opts->num_dsets); - HDfprintf(output, "rank %d: Number of iterations=%d\n", rank, - opts->num_iters); - HDfprintf(output, "rank %d: Number of processes=%d:%d\n", rank, - opts->min_num_procs, opts->max_num_procs); - - if (opts->dim2d){ - HDfprintf(output, "rank %d: Number of bytes per process per dataset=", rank); - recover_size_and_print((long long)(opts->num_bpp * opts->num_bpp * opts->min_num_procs), ":"); - recover_size_and_print((long long)(opts->num_bpp * opts->num_bpp * opts->max_num_procs), "\n"); - - HDfprintf(output, "rank %d: Size of dataset(s)=", rank); - recover_size_and_print((long long)(opts->num_bpp * opts->min_num_procs), "x"); - recover_size_and_print((long long)(opts->num_bpp * opts->min_num_procs), ":"); - recover_size_and_print((long long)(opts->num_bpp * opts->max_num_procs), "x"); - recover_size_and_print((long long)(opts->num_bpp * opts->max_num_procs), "\n"); - - HDfprintf(output, "rank %d: File size=", rank); - recover_size_and_print((long long)(pow(opts->num_bpp * opts->min_num_procs,2) - * opts->num_dsets), ":"); - recover_size_and_print((long long)(pow(opts->num_bpp * opts->max_num_procs,2) - * opts->num_dsets), "\n"); - - HDfprintf(output, "rank %d: Transfer buffer size=", rank); - if(opts->interleaved){ - recover_size_and_print((long long)opts->min_xfer_size, "x"); - recover_size_and_print((long long)opts->blk_size, ":"); - recover_size_and_print((long long)opts->max_xfer_size, "x"); - recover_size_and_print((long long)opts->blk_size, "\n"); - } - else{ - recover_size_and_print((long long)opts->blk_size, "x"); - recover_size_and_print((long long)opts->min_xfer_size, ":"); - recover_size_and_print((long long)opts->blk_size, "x"); - recover_size_and_print((long long)opts->max_xfer_size, "\n"); - } - HDfprintf(output, "rank %d: Block size=", rank); - recover_size_and_print((long long)opts->blk_size, "x"); - recover_size_and_print((long long)opts->blk_size, "\n"); - } - else{ - HDfprintf(output, "rank %d: Number of bytes per process per dataset=", rank); - recover_size_and_print((long long)opts->num_bpp, "\n"); - - HDfprintf(output, "rank %d: Size of dataset(s)=", rank); - recover_size_and_print((long long)(opts->num_bpp * opts->min_num_procs), ":"); - recover_size_and_print((long long)(opts->num_bpp * opts->max_num_procs), "\n"); - - HDfprintf(output, "rank %d: File size=", rank); - recover_size_and_print((long long)(opts->num_bpp * opts->min_num_procs - * opts->num_dsets), ":"); - recover_size_and_print((long long)(opts->num_bpp * opts->max_num_procs - * opts->num_dsets), "\n"); - - HDfprintf(output, "rank %d: Transfer buffer size=", rank); - recover_size_and_print((long long)opts->min_xfer_size, ":"); - recover_size_and_print((long long)opts->max_xfer_size, "\n"); - HDfprintf(output, "rank %d: Block size=", rank); - recover_size_and_print((long long)opts->blk_size, "\n"); - } - - HDfprintf(output, "rank %d: Block Pattern in Dataset=", rank); - if(opts->interleaved) - HDfprintf(output, "Interleaved\n"); - else - HDfprintf(output, "Contiguous\n"); - - HDfprintf(output, "rank %d: I/O Method for MPI and HDF5=", rank); - if(opts->collective) - HDfprintf(output, "Collective\n"); - else - HDfprintf(output, "Independent\n"); - - HDfprintf(output, "rank %d: Geometry=", rank); - if(opts->dim2d) - HDfprintf(output, "2D\n"); - else - HDfprintf(output, "1D\n"); - - HDfprintf(output, "rank %d: VFL used for HDF5 I/O=%s\n", rank, "MPI-IO driver"); - - HDfprintf(output, "rank %d: Data storage method in HDF5=", rank); - if(opts->h5_use_chunks) - HDfprintf(output, "Chunked\n"); - else - HDfprintf(output, "Contiguous\n"); - - { - char *prefix = HDgetenv("HDF5_PARAPREFIX"); - - HDfprintf(output, "rank %d: Env HDF5_PARAPREFIX=%s\n", rank, - (prefix ? prefix : "not set")); - } - - HDfprintf(output, "rank %d: ", rank); - h5_dump_info_object(h5_io_info_g); - - HDfprintf(output, "rank %d: ==== End of Parameters ====\n", rank); - HDfprintf(output, "\n"); -} - -/* - * Function: parse_command_line - * Purpose: Parse the command line options and return a STRUCT OPTIONS - * structure which will need to be freed by the calling function. - * Return: Pointer to an OPTIONS structure - * Programmer: Bill Wendling, 31. October 2001 - * Modifications: - * Added 2D testing (Christian Chilan, 10. August 2005) - */ -static struct options * -parse_command_line(int argc, char *argv[]) -{ - register int opt; - struct options *cl_opts; - - cl_opts = (struct options *)malloc(sizeof(struct options)); - - cl_opts->output_file = NULL; - cl_opts->io_types = 0; /* will set default after parsing options */ - cl_opts->num_dsets = 1; - cl_opts->num_files = 1; - cl_opts->num_bpp = 0; - cl_opts->num_iters = 1; - cl_opts->max_num_procs = comm_world_nprocs_g; - cl_opts->min_num_procs = 1; - cl_opts->max_xfer_size = 0; - cl_opts->min_xfer_size = 0; - cl_opts->blk_size = 0; - cl_opts->interleaved = 0; /* Default to contiguous blocks in dataset */ - cl_opts->collective = 0; /* Default to independent I/O access */ - cl_opts->dim2d = 0; /* Default to 1D */ - cl_opts->print_times = FALSE; /* Printing times is off by default */ - cl_opts->print_raw = FALSE; /* Printing raw data throughput is off by default */ - cl_opts->h5_alignment = 1; /* No alignment for HDF5 objects by default */ - cl_opts->h5_threshold = 1; /* No threshold for aligning HDF5 objects by default */ - cl_opts->h5_use_chunks = FALSE; /* Don't chunk the HDF5 dataset by default */ - cl_opts->h5_write_only = FALSE; /* Do both read and write by default */ - cl_opts->verify = FALSE; /* No Verify data correctness by default */ - - while ((opt = get_option(argc, (const char **)argv, s_opts, l_opts)) != EOF) { - switch ((char)opt) { - case 'a': - cl_opts->h5_alignment = parse_size_directive(opt_arg); - break; - case 'A': - { - const char *end = opt_arg; - - while (end && *end != '\0') { - char buf[10]; - int i; - - HDmemset(buf, '\0', sizeof(buf)); - - for (i = 0; *end != '\0' && *end != ','; ++end) - if (isalnum(*end) && i < 10) - buf[i++] = *end; - - if (!HDstrcasecmp(buf, "phdf5")) { - cl_opts->io_types |= PIO_HDF5; - } else if (!HDstrcasecmp(buf, "mpiio")) { - cl_opts->io_types |= PIO_MPI; - } else if (!HDstrcasecmp(buf, "posix")) { - cl_opts->io_types |= PIO_POSIX; - } else { - HDfprintf(stderr, "pio_perf: invalid --api option %s\n", - buf); - HDexit(EXIT_FAILURE); - } - - if (*end == '\0') - break; - - end++; - } - } - - break; -#if 0 - case 'b': - /* the future "binary" option */ - break; -#endif /* 0 */ - case 'B': - cl_opts->blk_size = parse_size_directive(opt_arg); - break; - case 'c': - /* Turn on chunked HDF5 dataset creation */ - cl_opts->h5_use_chunks = TRUE; - break; - case 'C': - cl_opts->collective = 1; - break; - case 'd': - cl_opts->num_dsets = atoi(opt_arg); - break; - case 'D': - { - const char *end = opt_arg; - - while (end && *end != '\0') { - char buf[10]; - int i; - - HDmemset(buf, '\0', sizeof(buf)); - - for (i = 0; *end != '\0' && *end != ','; ++end) - if (HDisalnum(*end) && i < 10) - buf[i++] = *end; - - if (HDstrlen(buf) > 1 || HDisdigit(buf[0])) { - size_t j; - - for (j = 0; j < 10 && buf[j] != '\0'; ++j) - if (!isdigit(buf[j])) { - HDfprintf(stderr, "pio_perf: invalid --debug option %s\n", - buf); - HDexit(EXIT_FAILURE); - } - - pio_debug_level = atoi(buf); - - if (pio_debug_level > 4) - pio_debug_level = 4; - else if (pio_debug_level < 0) - pio_debug_level = 0; - } else { - switch (*buf) { - case 'r': - /* Turn on raw data throughput info */ - cl_opts->print_raw = TRUE; - break; - case 't': - /* Turn on time printing */ - cl_opts->print_times = TRUE; - break; - case 'v': - /* Turn on verify data correctness*/ - cl_opts->verify = TRUE; - break; - default: - HDfprintf(stderr, "pio_perf: invalid --debug option %s\n", buf); - HDexit(EXIT_FAILURE); - } - } - - if (*end == '\0') - break; - - end++; - } - } - - break; - case 'e': - cl_opts->num_bpp = parse_size_directive(opt_arg); - break; - case 'F': - cl_opts->num_files = HDatoi(opt_arg); - break; - case 'g': - cl_opts->dim2d = 1; - break; - case 'i': - cl_opts->num_iters = HDatoi(opt_arg); - break; - case 'I': - cl_opts->interleaved = 1; - break; - case 'o': - cl_opts->output_file = opt_arg; - break; - case 'p': - cl_opts->min_num_procs = HDatoi(opt_arg); - break; - case 'P': - cl_opts->max_num_procs = HDatoi(opt_arg); - break; - case 'T': - cl_opts->h5_threshold = parse_size_directive(opt_arg); - break; - case 'w': - cl_opts->h5_write_only = TRUE; - break; - case 'x': - cl_opts->min_xfer_size = parse_size_directive(opt_arg); - break; - case 'X': - cl_opts->max_xfer_size = parse_size_directive(opt_arg); - break; - case 'h': - case '?': - default: - usage(progname); - HDfree(cl_opts); - return NULL; - } - } - - - if (cl_opts->num_bpp == 0){ - if (cl_opts->dim2d == 0) - cl_opts->num_bpp = 256 * ONE_KB; - else - cl_opts->num_bpp = 8 * ONE_KB; - } - - if (cl_opts->max_xfer_size == 0) - cl_opts->max_xfer_size = cl_opts->num_bpp; - - if (cl_opts->min_xfer_size == 0) - cl_opts->min_xfer_size = (cl_opts->num_bpp)/2; - - if (cl_opts->blk_size == 0) - cl_opts->blk_size = (cl_opts->num_bpp)/2; - - - /* set default if none specified yet */ - if (!cl_opts->io_types) - cl_opts->io_types = PIO_HDF5 | PIO_MPI | PIO_POSIX; /* run all API */ - - /* verify parameters sanity. Adjust if needed. */ - /* cap xfer_size with bytes per process */ - if (!cl_opts->dim2d) { - if (cl_opts->min_xfer_size > cl_opts->num_bpp) - cl_opts->min_xfer_size = cl_opts->num_bpp; - if (cl_opts->max_xfer_size > cl_opts->num_bpp) - cl_opts->max_xfer_size = cl_opts->num_bpp; - } - if (cl_opts->min_xfer_size > cl_opts->max_xfer_size) - cl_opts->min_xfer_size = cl_opts->max_xfer_size; - if (cl_opts->blk_size > cl_opts->num_bpp ) - cl_opts->blk_size = cl_opts->num_bpp; - /* check range of number of processes */ - if (cl_opts->min_num_procs <= 0) - cl_opts->min_num_procs = 1; - if (cl_opts->max_num_procs <= 0) - cl_opts->max_num_procs = 1; - if (cl_opts->min_num_procs > cl_opts->max_num_procs) - cl_opts->min_num_procs = cl_opts->max_num_procs; - /* check iteration */ - if (cl_opts->num_iters <= 0) - cl_opts->num_iters = 1; - - return cl_opts; -} - -/* - * Function: parse_size_directive - * Purpose: Parse the size directive passed on the commandline. The size - * directive is an integer followed by a size indicator: - * - * K, k - Kilobyte - * M, m - Megabyte - * G, g - Gigabyte - * - * Return: The size as a off_t because this is related to file size. - * If an unknown size indicator is used, then the program will - * exit with EXIT_FAILURE as the return value. - * Programmer: Bill Wendling, 18. December 2001 - * Modifications: - */ -static off_t -parse_size_directive(const char *size) -{ - off_t s; - char *endptr; - - s = HDstrtol(size, &endptr, 10); - - if (endptr && *endptr) { - while (*endptr != '\0' && (*endptr == ' ' || *endptr == '\t')) - ++endptr; - - switch (*endptr) { - case 'K': - case 'k': - s *= ONE_KB; - break; - case 'M': - case 'm': - s *= ONE_MB; - break; - case 'G': - case 'g': - s *= ONE_GB; - break; - default: - HDfprintf(stderr, "Illegal size specifier '%c'\n", *endptr); - HDexit(EXIT_FAILURE); - } - } - - return s; -} - -/* - * Function: usage - * Purpose: Print a usage message and then exit. - * Return: Nothing - * Programmer: Bill Wendling, 31. October 2001 - * Modifications: - * Added 2D testing (Christian Chilan, 10. August 2005) - */ -static void -usage(const char *prog) -{ - int myrank; - - MPI_Comm_rank(pio_comm_g, &myrank); - - if (myrank == 0) { - print_version(prog); - HDprintf("usage: %s [OPTIONS]\n", prog); - HDprintf(" OPTIONS\n"); - HDprintf(" -h, --help Print a usage message and exit\n"); - HDprintf(" -a S, --align=S Alignment of objects in HDF5 file [default: 1]\n"); - HDprintf(" -A AL, --api=AL Which APIs to test [default: all of them]\n"); -#if 0 - HDprintf(" -b, --binary The elusive binary option\n"); -#endif /* 0 */ - HDprintf(" -B S, --block-size=S Block size within transfer buffer\n"); - HDprintf(" (see below for description)\n"); - HDprintf(" [default: half the number of bytes per process\n"); - HDprintf(" per dataset]\n"); - HDprintf(" -c, --chunk Create HDF5 datasets using chunked storage\n"); - HDprintf(" [default: contiguous storage]\n"); - HDprintf(" -C, --collective Use collective I/O for MPI and HDF5 APIs\n"); - HDprintf(" [default: independent I/O)\n"); - HDprintf(" -d N, --num-dsets=N Number of datasets per file [default: 1]\n"); - HDprintf(" -D DL, --debug=DL Indicate the debugging level\n"); - HDprintf(" [default: no debugging]\n"); - HDprintf(" -e S, --num-bytes=S Number of bytes per process per dataset\n"); - HDprintf(" (see below for description)\n"); - HDprintf(" [default: 256K for 1D, 8K for 2D]\n"); - HDprintf(" -F N, --num-files=N Number of files [default: 1]\n"); - HDprintf(" -g, --geometry Use 2D geometry [default: 1D geometry]\n"); - HDprintf(" -i N, --num-iterations=N Number of iterations to perform [default: 1]\n"); - HDprintf(" -I, --interleaved Interleaved access pattern\n"); - HDprintf(" (see below for example)\n"); - HDprintf(" [default: Contiguous access pattern]\n"); - HDprintf(" -o F, --output=F Output raw data into file F [default: none]\n"); - HDprintf(" -p N, --min-num-processes=N Minimum number of processes to use [default: 1]\n"); - HDprintf(" -P N, --max-num-processes=N Maximum number of processes to use\n"); - HDprintf(" [default: all MPI_COMM_WORLD processes ]\n"); - HDprintf(" -T S, --threshold=S Threshold for alignment of objects in HDF5 file\n"); - HDprintf(" [default: 1]\n"); - HDprintf(" -w, --write-only Perform write tests not the read tests\n"); - HDprintf(" -x S, --min-xfer-size=S Minimum transfer buffer size\n"); - HDprintf(" (see below for description)\n"); - HDprintf(" [default: half the number of bytes per process\n"); - HDprintf(" per dataset]\n"); - HDprintf(" -X S, --max-xfer-size=S Maximum transfer buffer size\n"); - HDprintf(" [default: the number of bytes per process per\n"); - HDprintf(" dataset]\n"); - HDprintf("\n"); - HDprintf(" F - is a filename.\n"); - HDprintf(" N - is an integer >=0.\n"); - HDprintf(" S - is a size specifier, an integer >=0 followed by a size indicator:\n"); - HDprintf(" K - Kilobyte (%d)\n", ONE_KB); - HDprintf(" M - Megabyte (%d)\n", ONE_MB); - HDprintf(" G - Gigabyte (%d)\n", ONE_GB); - HDprintf("\n"); - HDprintf(" Example: '37M' is 37 megabytes or %d bytes\n", 37*ONE_MB); - HDprintf("\n"); - HDprintf(" AL - is an API list. Valid values are:\n"); - HDprintf(" phdf5 - Parallel HDF5\n"); - HDprintf(" mpiio - MPI-I/O\n"); - HDprintf(" posix - POSIX\n"); - HDprintf("\n"); - HDprintf(" Example: --api=mpiio,phdf5\n"); - HDprintf("\n"); - HDprintf(" Dataset size:\n"); - HDprintf(" Depending on the selected geometry, each test dataset is either a linear\n"); - HDprintf(" array of size bytes-per-process * num-processes, or a square array of size\n"); - HDprintf(" (bytes-per-process * num-processes) x (bytes-per-process * num-processes).\n"); - HDprintf("\n"); - HDprintf(" Block size vs. Transfer buffer size:\n"); - HDprintf(" buffer-size controls the size of the memory buffer, which is broken into\n"); - HDprintf(" blocks and written to the file. Depending on the selected geometry, each\n"); - HDprintf(" block can be a linear array of size block-size or a square array of size\n"); - HDprintf(" block-size x block-size. The arrangement in which blocks are written is\n"); - HDprintf(" determined by the access pattern.\n"); - HDprintf("\n"); - HDprintf(" In 1D geometry, the transfer buffer is a linear array of size buffer-size.\n"); - HDprintf(" In 2D geometry, it is a rectangular array of size block-size x buffer-size\n"); - HDprintf(" or buffer-size x block-size if interleaved pattern is selected.\n"); - HDprintf("\n"); - HDprintf(" Interleaved and Contiguous patterns in 1D geometry:\n"); - HDprintf(" When contiguous access pattern is chosen, the dataset is evenly divided\n"); - HDprintf(" into num-processes regions and each process writes data to its own region.\n"); - HDprintf(" When interleaved blocks are written to a dataset, space for the first\n"); - HDprintf(" block of the first process is allocated in the dataset, then space is\n"); - HDprintf(" allocated for the first block of the second process, etc. until space is\n"); - HDprintf(" allocated for the first block of each process, then space is allocated for\n"); - HDprintf(" the second block of the first process, the second block of the second\n"); - HDprintf(" process, etc.\n"); - HDprintf("\n"); - HDprintf(" For example, with a 3 process run, 512KB bytes-per-process, 256KB transfer\n"); - HDprintf(" buffer size, and 64KB block size, each process must issue 2 transfer\n"); - HDprintf(" requests to complete access to the dataset.\n"); - HDprintf(" Contiguous blocks of the first transfer request are written like so:\n"); - HDprintf(" 1111----2222----3333----\n"); - HDprintf(" Interleaved blocks of the first transfer request are written like so:\n"); - HDprintf(" 123123123123------------\n"); - HDprintf(" The actual number of I/O operations involved in a transfer request\n"); - HDprintf(" depends on the access pattern and communication mode.\n"); - HDprintf(" When using independent I/O with interleaved pattern, each process\n"); - HDprintf(" performs 4 small non-contiguous I/O operations per transfer request.\n"); - HDprintf(" If collective I/O is turned on, the combined content of the buffers of\n"); - HDprintf(" the 3 processes will be written using one collective I/O operation\n"); - HDprintf(" per transfer request.\n"); - HDprintf("\n"); - HDprintf(" For information about access patterns in 2D geometry, please refer to the\n"); - HDprintf(" HDF5 Reference Manual.\n"); - HDprintf("\n"); - HDprintf(" DL - is a list of debugging flags. Valid values are:\n"); - HDprintf(" 1 - Minimal\n"); - HDprintf(" 2 - Not quite everything\n"); - HDprintf(" 3 - Everything\n"); - HDprintf(" 4 - The kitchen sink\n"); - HDprintf(" r - Raw data I/O throughput information\n"); - HDprintf(" t - Times as well as throughputs\n"); - HDprintf(" v - Verify data correctness\n"); - HDprintf("\n"); - HDprintf(" Example: --debug=2,r,t\n"); - HDprintf("\n"); - HDprintf(" Environment variables:\n"); - HDprintf(" HDF5_NOCLEANUP Do not remove data files if set [default remove]\n"); - HDprintf(" HDF5_MPI_INFO MPI INFO object key=value separated by ;\n"); - HDprintf(" HDF5_PARAPREFIX Paralllel data files prefix\n"); - fflush(stdout); - } /* end if */ -} /* end usage() */ - -#else /* H5_HAVE_PARALLEL */ - -/* - * Function: main - * Purpose: Dummy main() function for if HDF5 was configured without - * parallel stuff. - * Return: EXIT_SUCCESS - * Programmer: Bill Wendling, 14. November 2001 - */ -int -main(void) -{ - HDprintf("No parallel IO performance because parallel is not configured\n"); - return EXIT_SUCCESS; -} /* end main */ - -#endif /* !H5_HAVE_PARALLEL */ diff --git a/tools/test/perform/pio_perf.h b/tools/test/perform/pio_perf.h deleted file mode 100644 index 7605f20..0000000 --- a/tools/test/perform/pio_perf.h +++ /dev/null @@ -1,101 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * 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://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef PIO_PERF_H__ -#define PIO_PERF_H__ - -#include "io_timer.h" -#ifndef STANDALONE -#include "h5test.h" -#include "h5tools.h" -#include "h5tools_utils.h" -#else -#include "pio_standalone.h" -#endif - -/* setup the dataset no fill option if this is v1.5 or more */ -#if H5_VERS_MAJOR > 1 || H5_VERS_MINOR > 4 -#define H5_HAVE_NOFILL 1 -#endif - -typedef enum iotype_ { - POSIXIO, - MPIO, - PHDF5 - /*NUM_TYPES*/ -} iotype; - -typedef struct parameters_ { - iotype io_type; /* The type of IO test to perform */ - int num_procs; /* Maximum number of processes to use */ - long num_files; /* Number of files to create */ - long num_dsets; /* Number of datasets to create */ - off_t num_bytes; /* Number of bytes in each dset */ - int num_iters; /* Number of times to loop doing the IO */ - size_t buf_size; /* Buffer size */ - size_t blk_size; /* Block size */ - unsigned interleaved; /* Interleaved vs. contiguous blocks */ - unsigned collective; /* Collective vs. independent I/O */ - unsigned dim2d; /* 1D vs. 2D */ - hsize_t h5_align; /* HDF5 object alignment */ - hsize_t h5_thresh; /* HDF5 object alignment threshold */ - int h5_use_chunks; /* Make HDF5 dataset chunked */ - int h5_write_only; /* Perform the write tests only */ - int verify; /* Verify data correctness */ -} parameters; - -typedef struct results_ { - herr_t ret_code; - io_time_t *timers; -} results; - -#ifndef SUCCESS -#define SUCCESS 0 -#endif /* !SUCCESS */ - -#ifndef FAIL -#define FAIL -1 -#endif /* !FAIL */ - -extern FILE *output; /* output file */ -extern io_time_t *timer_g; /* timer: global for stub functions */ -extern int comm_world_rank_g; /* my rank in MPI_COMM_RANK */ -extern int comm_world_nprocs_g;/* num. of processes of MPI_COMM_WORLD */ -extern MPI_Comm pio_comm_g; /* Communicator to run the PIO */ -extern int pio_mpi_rank_g; /* MPI rank of pio_comm_g */ -extern int pio_mpi_nprocs_g; /* number of processes of pio_comm_g */ -extern int pio_debug_level; /* The debug level: - * 0 - Off - * 1 - Minimal - * 2 - Some more - * 3 - Maximal - * 4 - Even More Debugging (timer stuff) - */ - -#define HDprint_rank(f) /* print rank in MPI_COMM_WORLD */ \ - HDfprintf(f, "%d: ", comm_world_rank_g); -#define HDprint_size(f) /* print size of MPI_COMM_WORLD */ \ - HDfprintf(f, "%d", comm_world_nprocs_g); -#define HDprint_rank_size(f) /* print rank/size of MPI_COMM_WORLD */ \ - HDfprintf(f, "%d/%d: ", comm_world_rank_g, comm_world_nprocs_g); - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -extern results do_pio(parameters param); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* PIO_PERF_H__ */ diff --git a/tools/test/perform/pio_standalone.c b/tools/test/perform/pio_standalone.c index 022e390..a074d2c 100644 --- a/tools/test/perform/pio_standalone.c +++ b/tools/test/perform/pio_standalone.c @@ -5,12 +5,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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /* This file contains the definition of functions required to build h5perf in * STANDALONE mode. * Created: Christian Chilan, 2005/5/18. @@ -18,38 +17,32 @@ #include "pio_perf.h" - /** From h5tools_utils.c **/ /* global variables */ -int nCols = 80; - -/* ``get_option'' variables */ -int opt_err = 1; /*get_option prints errors if this is on */ -int opt_ind = 1; /*token pointer */ -const char *opt_arg; /*flag argument (or value) */ - +int nCols = 80; int -get_option(int argc, const char **argv, const char *opts, const struct long_options *l_opts) +get_option(int argc, const char **argv, const char *opts, const struct h5_long_options *l_opts) { - static int sp = 1; /* character index in current token */ - int opt_opt = '?'; /* option character passed back to user */ + static int sp = 1; /* character index in current token */ + int opt_opt = '?'; /* option character passed back to user */ if (sp == 1) { /* check for more flag-like tokens */ - if (opt_ind >= argc || argv[opt_ind][0] != '-' || argv[opt_ind][1] == '\0') { + if (H5_optind >= argc || argv[H5_optind][0] != '-' || argv[H5_optind][1] == '\0') { return EOF; - } else if (HDstrcmp(argv[opt_ind], "--") == 0) { - opt_ind++; + } + else if (HDstrcmp(argv[H5_optind], "--") == 0) { + H5_optind++; return EOF; } } - if (sp == 1 && argv[opt_ind][0] == '-' && argv[opt_ind][1] == '-') { + if (sp == 1 && argv[H5_optind][0] == '-' && argv[H5_optind][1] == '-') { /* long command line option */ - const char *arg = &argv[opt_ind][2]; - int i; + const char *arg = &argv[H5_optind][2]; + int i; for (i = 0; l_opts && l_opts[i].name; i++) { size_t len = HDstrlen(l_opts[i].name); @@ -60,28 +53,27 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (l_opts[i].has_arg != no_arg) { if (arg[len] == '=') { - opt_arg = &arg[len + 1]; - } else if (opt_ind < (argc - 1) && argv[opt_ind + 1][0] != '-') { - opt_arg = argv[++opt_ind]; - } else if (l_opts[i].has_arg == require_arg) { - if (opt_err) - HDfprintf(stderr, - "%s: option required for \"--%s\" flag\n", - argv[0], arg); + H5_optarg = &arg[len + 1]; + } + else if (H5_optind < (argc - 1) && argv[H5_optind + 1][0] != '-') { + H5_optarg = argv[++H5_optind]; + } + else if (l_opts[i].has_arg == require_arg) { + if (H5_opterr) + HDfprintf(stderr, "%s: option required for \"--%s\" flag\n", argv[0], arg); opt_opt = '?'; } - } else { + } + else { if (arg[len] == '=') { - if (opt_err) - HDfprintf(stderr, - "%s: no option required for \"%s\" flag\n", - argv[0], arg); + if (H5_opterr) + HDfprintf(stderr, "%s: no option required for \"%s\" flag\n", argv[0], arg); opt_opt = '?'; } - opt_arg = NULL; + H5_optarg = NULL; } break; @@ -90,29 +82,29 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (l_opts[i].name == NULL) { /* exhausted all of the l_opts we have and still didn't match */ - if (opt_err) + if (H5_opterr) HDfprintf(stderr, "%s: unknown option \"%s\"\n", argv[0], arg); opt_opt = '?'; } - opt_ind++; + H5_optind++; sp = 1; - } else { - register char *cp; /* pointer into current token */ + } + else { + char *cp; /* pointer into current token */ /* short command line option */ - opt_opt = argv[opt_ind][sp]; + opt_opt = argv[H5_optind][sp]; if (opt_opt == ':' || (cp = strchr(opts, opt_opt)) == 0) { - if (opt_err) - HDfprintf(stderr, "%s: unknown option \"%c\"\n", - argv[0], opt_opt); + if (H5_opterr) + HDfprintf(stderr, "%s: unknown option \"%c\"\n", argv[0], opt_opt); /* if no chars left in this token, move to next token */ - if (argv[opt_ind][++sp] == '\0') { - opt_ind++; + if (argv[H5_optind][++sp] == '\0') { + H5_optind++; sp = 1; } @@ -121,31 +113,32 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (*++cp == ':') { /* if a value is expected, get it */ - if (argv[opt_ind][sp + 1] != '\0') { + if (argv[H5_optind][sp + 1] != '\0') { /* flag value is rest of current token */ - opt_arg = &argv[opt_ind++][sp + 1]; - } else if (++opt_ind >= argc) { - if (opt_err) - HDfprintf(stderr, - "%s: value expected for option \"%c\"\n", - argv[0], opt_opt); + H5_optarg = &argv[H5_optind++][sp + 1]; + } + else if (++H5_optind >= argc) { + if (H5_opterr) + HDfprintf(stderr, "%s: value expected for option \"%c\"\n", argv[0], opt_opt); opt_opt = '?'; - } else { + } + else { /* flag value is next token */ - opt_arg = argv[opt_ind++]; + H5_optarg = argv[H5_optind++]; } sp = 1; - } else { + } + else { /* set up to look at next char in token, next time */ - if (argv[opt_ind][++sp] == '\0') { + if (argv[H5_optind][++sp] == '\0') { /* no more in current token, so setup next token */ - opt_ind++; + H5_optind++; sp = 1; } - opt_arg = NULL; + H5_optarg = NULL; } } @@ -153,17 +146,9 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti return opt_opt; } - void print_version(const char *progname) { - printf("%s: Version %u.%u.%u%s%s\n", - progname, H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, + printf("%s: Version %u.%u.%u%s%s\n", progname, H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, H5_VERS_SUBRELEASE[0] ? "-" : "", H5_VERS_SUBRELEASE); } - -#ifdef H5_HAVE_PARALLEL -MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */ -#endif - - diff --git a/tools/test/perform/pio_standalone.h b/tools/test/perform/pio_standalone.h index e6db2e8..e64a765 100644 --- a/tools/test/perform/pio_standalone.h +++ b/tools/test/perform/pio_standalone.h @@ -5,13 +5,13 @@ * 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 PIO_STANDALONE_H__ -#define PIO_PERF_H__ +#ifndef PIO_STANDALONE_H +#define PIO_STANDALONE_H /* Header file for building h5perf by standalone mode. * Created: Christian Chilan, 2005/5/18. @@ -19,450 +19,415 @@ /** From H5private.h **/ -#include "H5public.h" /* Include Public Definitions */ +#include "H5public.h" /* Include Public Definitions */ - -/* - * Include ANSI-C header files. - */ -#ifdef H5_STDC_HEADERS -# include <assert.h> -# include <ctype.h> -# include <errno.h> -# include <fcntl.h> -# include <float.h> -# include <limits.h> -# include <math.h> -# include <signal.h> -# include <stdarg.h> -# include <stdio.h> -# include <stdlib.h> -# include <string.h> -#endif +#include <assert.h> +#include <ctype.h> +#include <errno.h> +#include <fcntl.h> +#include <float.h> +#include <limits.h> +#include <math.h> +#include <signal.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> /* * Redefine all the POSIX functions. We should never see a POSIX * function (or any other non-HDF5 function) in the source! */ -#define HDabort() abort() -#define HDabs(X) abs(X) +#define HDabort() abort() +#define HDabs(X) abs(X) #ifdef H5_HAVE_WIN32_API -#define HDaccess(F,M) _access(F, M) -#define R_OK 4 /* Test for read permission. */ -#define W_OK 2 /* Test for write permission. */ -#define X_OK 1 /* Test for execute permission. */ -#define F_OK 0 /* Test for existence. */ -#else /* H5_HAVE_WIN32_API */ -#define HDaccess(F,M) access(F, M) +#define HDaccess(F, M) _access(F, M) +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +#define X_OK 1 /* Test for execute permission. */ +#define F_OK 0 /* Test for existence. */ +#else /* H5_HAVE_WIN32_API */ +#define HDaccess(F, M) access(F, M) #ifndef F_OK -#define F_OK 00 +#define F_OK 00 #define W_OK 02 #define R_OK 04 #endif #endif /* H5_HAVE_WIN32_API */ -#define HDacos(X) acos(X) +#define HDacos(X) acos(X) #ifdef H5_HAVE_ALARM -#define HDalarm(N) alarm(N) +#define HDalarm(N) alarm(N) #else /* H5_HAVE_ALARM */ -#define HDalarm(N) (0) +#define HDalarm(N) (0) #endif /* H5_HAVE_ALARM */ -#define HDasctime(T) asctime(T) -#define HDasin(X) asin(X) -#define HDasprintf asprintf /*varargs*/ -#define HDassert(X) assert(X) -#define HDatan(X) atan(X) -#define HDatan2(X,Y) atan2(X,Y) -#define HDatexit(F) atexit(F) -#define HDatof(S) atof(S) -#define HDatoi(S) atoi(S) -#define HDatol(S) atol(S) -#define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F) -#define HDcalloc(N,Z) calloc(N,Z) -#define HDceil(X) ceil(X) -#define HDcfgetispeed(T) cfgetispeed(T) -#define HDcfgetospeed(T) cfgetospeed(T) -#define HDcfsetispeed(T,S) cfsetispeed(T,S) -#define HDcfsetospeed(T,S) cfsetospeed(T,S) -#define HDchdir(S) chdir(S) -#define HDchmod(S,M) chmod(S,M) -#define HDchown(S,O,G) chown(S,O,G) -#define HDclearerr(F) clearerr(F) -#define HDclock() clock() -#define HDclose(F) close(F) -#define HDclosedir(D) closedir(D) -#define HDcos(X) cos(X) -#define HDcosh(X) cosh(X) -#define HDcreat(S,M) creat(S,M) -#define HDctermid(S) ctermid(S) -#define HDctime(T) ctime(T) -#define HDcuserid(S) cuserid(S) -#ifdef H5_HAVE_DIFFTIME -#define HDdifftime(X,Y) difftime(X,Y) -#else -#define HDdifftime(X,Y) ((double)(X)-(double)(Y)) -#endif -#define HDdiv(X,Y) div(X,Y) -#define HDdup(F) dup(F) -#define HDdup2(F,I) dup2(F,I) -/* execl() variable arguments */ -/* execle() variable arguments */ -/* execlp() variable arguments */ -#define HDexecv(S,AV) execv(S,AV) -#define HDexecve(S,AV,E) execve(S,AV,E) -#define HDexecvp(S,AV) execvp(S,AV) -#define HDexit(N) exit(N) -#define HD_exit(N) _exit(N) -#define HDexp(X) exp(X) -#define HDfabs(X) fabs(X) -/* use ABS() because fabsf() fabsl() are not common yet. */ -#define HDfabsf(X) ABS(X) -#define HDfabsl(X) ABS(X) -#define HDfclose(F) fclose(F) +#define HDasctime(T) asctime(T) +#define HDasin(X) asin(X) +#define HDasprintf asprintf /*varargs*/ +#define HDassert(X) assert(X) +#define HDatan(X) atan(X) +#define HDatan2(X, Y) atan2(X, Y) +#define HDatexit(F) atexit(F) +#define HDatof(S) atof(S) +#define HDatoi(S) atoi(S) +#define HDatol(S) atol(S) +#define HDbsearch(K, B, N, Z, F) bsearch(K, B, N, Z, F) +#define HDcalloc(N, Z) calloc(N, Z) +#define HDceil(X) ceil(X) +#define HDcfgetispeed(T) cfgetispeed(T) +#define HDcfgetospeed(T) cfgetospeed(T) +#define HDcfsetispeed(T, S) cfsetispeed(T, S) +#define HDcfsetospeed(T, S) cfsetospeed(T, S) +#define HDchdir(S) chdir(S) +#define HDchmod(S, M) chmod(S, M) +#define HDchown(S, O, G) chown(S, O, G) +#define HDclearerr(F) clearerr(F) +#define HDclock() clock() +#define HDclose(F) close(F) +#define HDclosedir(D) closedir(D) +#define HDcos(X) cos(X) +#define HDcosh(X) cosh(X) +#define HDcreat(S, M) creat(S, M) +#define HDctermid(S) ctermid(S) +#define HDctime(T) ctime(T) +#define HDcuserid(S) cuserid(S) +#define HDdifftime(X, Y) difftime(X, Y) +#define HDdiv(X, Y) div(X, Y) +#define HDdup(F) dup(F) +#define HDdup2(F, I) dup2(F, I) +#define HDexecv(S, AV) execv(S, AV) +#define HDexecve(S, AV, E) execve(S, AV, E) +#define HDexecvp(S, AV) execvp(S, AV) +#define HDexit(N) exit(N) +#define HD_exit(N) _exit(N) +#define HDexp(X) exp(X) +#define HDfabs(X) fabs(X) +#define HDfabsf(X) fabsf(X) +#define HDfabsl(X) fabsl(X) +#define HDfclose(F) fclose(F) /* fcntl() variable arguments */ -#define HDfdopen(N,S) fdopen(N,S) -#define HDfeof(F) feof(F) -#define HDferror(F) ferror(F) -#define HDfflush(F) fflush(F) -#define HDfgetc(F) fgetc(F) -#define HDfgetpos(F,P) fgetpos(F,P) -#define HDfgets(S,N,F) fgets(S,N,F) +#define HDfdopen(N, S) fdopen(N, S) +#define HDfeof(F) feof(F) +#define HDferror(F) ferror(F) +#define HDfflush(F) fflush(F) +#define HDfgetc(F) fgetc(F) +#define HDfgetpos(F, P) fgetpos(F, P) +#define HDfgets(S, N, F) fgets(S, N, F) #ifdef H5_HAVE_WIN32_API -#define HDfileno(F) _fileno(F) +#define HDfileno(F) _fileno(F) #else /* H5_HAVE_WIN32_API */ -#define HDfileno(F) fileno(F) +#define HDfileno(F) fileno(F) #endif /* H5_HAVE_WIN32_API */ -#define HDfloor(X) floor(X) -#define HDfmod(X,Y) fmod(X,Y) -#define HDfopen(S,M) fopen(S,M) -#define HDfork() fork() -#define HDfpathconf(F,N) fpathconf(F,N) -H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); -#define HDfputc(C,F) fputc(C,F) -#define HDfputs(S,F) fputs(S,F) -#define HDfread(M,Z,N,F) fread(M,Z,N,F) -#define HDfree(M) free(M) -#define HDfreopen(S,M,F) freopen(S,M,F) -#define HDfrexp(X,N) frexp(X,N) -/* Check for Cray-specific 'frexpf()' and 'frexpl()' routines */ -#ifdef H5_HAVE_FREXPF -#define HDfrexpf(X,N) frexpf(X,N) -#else /* H5_HAVE_FREXPF */ -#define HDfrexpf(X,N) frexp(X,N) -#endif /* H5_HAVE_FREXPF */ -#ifdef H5_HAVE_FREXPL -#define HDfrexpl(X,N) frexpl(X,N) -#else /* H5_HAVE_FREXPL */ -#define HDfrexpl(X,N) frexp(X,N) -#endif /* H5_HAVE_FREXPL */ +#define HDfloor(X) floor(X) +#define HDfmod(X, Y) fmod(X, Y) +#define HDfopen(S, M) fopen(S, M) +#define HDfork() fork() +#define HDfpathconf(F, N) fpathconf(F, N) +#define HDfprintf fprintf +#define HDfputc(C, F) fputc(C, F) +#define HDfputs(S, F) fputs(S, F) +#define HDfread(M, Z, N, F) fread(M, Z, N, F) +#define HDfree(M) free(M) +#define HDfreopen(S, M, F) freopen(S, M, F) +#define HDfrexp(X, N) frexp(X, N) +#define HDfrexpf(X, N) frexpf(X, N) +#define HDfrexpl(X, N) frexpl(X, N) /* fscanf() variable arguments */ #ifdef H5_HAVE_FSEEKO - #define HDfseek(F,O,W) fseeko(F,O,W) +#define HDfseek(F, O, W) fseeko(F, O, W) #else - #define HDfseek(F,O,W) fseek(F,O,W) +#define HDfseek(F, O, W) fseek(F, O, W) #endif -#define HDfsetpos(F,P) fsetpos(F,P) +#define HDfsetpos(F, P) fsetpos(F, P) /* definitions related to the file stat utilities. * Windows have its own function names. * For Unix, if off_t is not 64bit big, try use the pseudo-standard * xxx64 versions if available. */ #ifdef H5_HAVE_WIN32_API - #define HDfstat(F,B) _fstati64(F,B) - #define HDlstat(S,B) _lstati64(S,B) - #define HDstat(S,B) _stati64(S,B) - typedef struct _stati64 h5_stat_t; - typedef __int64 h5_stat_size_t; - #define HDoff_t __int64 -#elif H5_SIZEOF_OFF_T!=8 && H5_SIZEOF_OFF64_T==8 && defined(H5_HAVE_STAT64) - #define HDfstat(F,B) fstat64(F,B) - #define HDlstat(S,B) lstat64(S,B) - #define HDstat(S,B) stat64(S,B) - typedef struct stat64 h5_stat_t; - typedef off64_t h5_stat_size_t; - #define HDoff_t off64_t +#define HDfstat(F, B) _fstati64(F, B) +#define HDlstat(S, B) _lstati64(S, B) +#define HDstat(S, B) _stati64(S, B) +typedef struct _stati64 h5_stat_t; +typedef __int64 h5_stat_size_t; +#define HDoff_t __int64 +#elif H5_SIZEOF_OFF_T != 8 && H5_SIZEOF_OFF64_T == 8 && defined(H5_HAVE_STAT64) +#define HDfstat(F, B) fstat64(F, B) +#define HDlstat(S, B) lstat64(S, B) +#define HDstat(S, B) stat64(S, B) +typedef struct stat64 h5_stat_t; +typedef off64_t h5_stat_size_t; +#define HDoff_t off64_t #else - #define HDfstat(F,B) fstat(F,B) - #define HDlstat(S,B) lstat(S,B) - #define HDstat(S,B) stat(S,B) - typedef struct stat h5_stat_t; - typedef off_t h5_stat_size_t; - #define HDoff_t off_t +#define HDfstat(F, B) fstat(F, B) +#define HDlstat(S, B) lstat(S, B) +#define HDstat(S, B) stat(S, B) +typedef struct stat h5_stat_t; +typedef off_t h5_stat_size_t; +#define HDoff_t off_t #endif -#define HDftell(F) ftell(F) -#define HDftruncate(F,L) ftruncate(F,L) -#define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F) -#define HDgetc(F) getc(F) -#define HDgetchar() getchar() -#define HDgetcwd(S,Z) getcwd(S,Z) -#define HDgetegid() getegid() -#define HDgetenv(S) getenv(S) -#define HDgeteuid() geteuid() -#define HDgetgid() getgid() -#define HDgetgrgid(G) getgrgid(G) -#define HDgetgrnam(S) getgrnam(S) -#define HDgetgroups(Z,G) getgroups(Z,G) +#define HDftell(F) ftell(F) +#define HDftruncate(F, L) ftruncate(F, L) +#define HDfwrite(M, Z, N, F) fwrite(M, Z, N, F) +#define HDgetc(F) getc(F) +#define HDgetchar() getchar() +#define HDgetcwd(S, Z) getcwd(S, Z) +#define HDgetegid() getegid() +#define HDgetenv(S) getenv(S) +#define HDgeteuid() geteuid() +#define HDgetgid() getgid() +#define HDgetgrgid(G) getgrgid(G) +#define HDgetgrnam(S) getgrnam(S) +#define HDgetgroups(Z, G) getgroups(Z, G) #ifdef H5_HAVE_WIN32_API -#define HDgetlogin() Wgetlogin() +#define HDgetlogin() Wgetlogin() #else /* H5_HAVE_WIN32_API */ -#define HDgetlogin() getlogin() +#define HDgetlogin() getlogin() #endif /* H5_HAVE_WIN32_API */ -#define HDgetpgrp() getpgrp() -#define HDgetpid() getpid() -#define HDgetppid() getppid() -#define HDgetpwnam(S) getpwnam(S) -#define HDgetpwuid(U) getpwuid(U) -#define HDgetrusage(X,S) getrusage(X,S) -#define HDgets(S) gets(S) +#define HDgetpgrp() getpgrp() +#define HDgetpid() getpid() +#define HDgetppid() getppid() +#define HDgetpwnam(S) getpwnam(S) +#define HDgetpwuid(U) getpwuid(U) +#define HDgetrusage(X, S) getrusage(X, S) +/* Don't define a macro for gets() - it was removed in C11 */ #ifdef H5_HAVE_WIN32_API - H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); -#define HDgettimeofday(V,Z) Wgettimeofday(V,Z) +H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); +#define HDgettimeofday(V, Z) Wgettimeofday(V, Z) #else /* H5_HAVE_WIN32_API */ -#define HDgettimeofday(S,P) gettimeofday(S,P) +#define HDgettimeofday(S, P) gettimeofday(S, P) #endif /* H5_HAVE_WIN32_API */ -#define HDgetuid() getuid() -#define HDgmtime(T) gmtime(T) -#define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ -#define HDisalpha(C) isalpha((int)(C)) /*cast for solaris warning*/ -#define HDisatty(F) isatty(F) -#define HDiscntrl(C) iscntrl((int)(C)) /*cast for solaris warning*/ -#define HDisdigit(C) isdigit((int)(C)) /*cast for solaris warning*/ -#define HDisgraph(C) isgraph((int)(C)) /*cast for solaris warning*/ -#define HDislower(C) islower((int)(C)) /*cast for solaris warning*/ -#define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/ -#define HDispunct(C) ispunct((int)(C)) /*cast for solaris warning*/ -#define HDisspace(C) isspace((int)(C)) /*cast for solaris warning*/ -#define HDisupper(C) isupper((int)(C)) /*cast for solaris warning*/ -#define HDisxdigit(C) isxdigit((int)(C)) /*cast for solaris warning*/ -#define HDkill(P,S) kill(P,S) -#define HDlabs(X) labs(X) -#define HDldexp(X,N) ldexp(X,N) -#define HDldiv(X,Y) ldiv(X,Y) -#define HDlink(OLD,NEW) link(OLD,NEW) -#define HDlocaleconv() localeconv() -#define HDlocaltime(T) localtime(T) -#define HDlog(X) log(X) -#define HDlog10(X) log10(X) -#define HDlongjmp(J,N) longjmp(J,N) +#define HDgetuid() getuid() +#define HDgmtime(T) gmtime(T) +#define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ +#define HDisalpha(C) isalpha((int)(C)) /*cast for solaris warning*/ +#define HDisatty(F) isatty(F) +#define HDiscntrl(C) iscntrl((int)(C)) /*cast for solaris warning*/ +#define HDisdigit(C) isdigit((int)(C)) /*cast for solaris warning*/ +#define HDisgraph(C) isgraph((int)(C)) /*cast for solaris warning*/ +#define HDislower(C) islower((int)(C)) /*cast for solaris warning*/ +#define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/ +#define HDispunct(C) ispunct((int)(C)) /*cast for solaris warning*/ +#define HDisspace(C) isspace((int)(C)) /*cast for solaris warning*/ +#define HDisupper(C) isupper((int)(C)) /*cast for solaris warning*/ +#define HDisxdigit(C) isxdigit((int)(C)) /*cast for solaris warning*/ +#define HDkill(P, S) kill(P, S) +#define HDlabs(X) labs(X) +#define HDldexp(X, N) ldexp(X, N) +#define HDldiv(X, Y) ldiv(X, Y) +#define HDlink(OLD, NEW) link(OLD, NEW) +#define HDlocaleconv() localeconv() +#define HDlocaltime(T) localtime(T) +#define HDlog(X) log(X) +#define HDlog10(X) log10(X) +#define HDlongjmp(J, N) longjmp(J, N) #ifdef H5_HAVE_WIN32_API - #define HDlseek(F,O,W) _lseeki64(F,O,W) +#define HDlseek(F, O, W) _lseeki64(F, O, W) #else - #ifdef H5_HAVE_LSEEK64 - #define HDlseek(F,O,W) lseek64(F,O,W) - #else - #define HDlseek(F,O,W) lseek(F,O,W) - #endif +#ifdef H5_HAVE_LSEEK64 +#define HDlseek(F, O, W) lseek64(F, O, W) +#else +#define HDlseek(F, O, W) lseek(F, O, W) +#endif #endif -#define HDmalloc(Z) malloc(Z) -#define HDposix_memalign(P,A,Z) posix_memalign(P,A,Z) -#define HDmblen(S,N) mblen(S,N) -#define HDmbstowcs(P,S,Z) mbstowcs(P,S,Z) -#define HDmbtowc(P,S,Z) mbtowc(P,S,Z) -#define HDmemchr(S,C,Z) memchr(S,C,Z) -#define HDmemcmp(X,Y,Z) memcmp(X,Y,Z) +#define HDmalloc(Z) malloc(Z) +#define HDposix_memalign(P, A, Z) posix_memalign(P, A, Z) +#define HDmblen(S, N) mblen(S, N) +#define HDmbstowcs(P, S, Z) mbstowcs(P, S, Z) +#define HDmbtowc(P, S, Z) mbtowc(P, S, Z) +#define HDmemchr(S, C, Z) memchr(S, C, Z) +#define HDmemcmp(X, Y, Z) memcmp(X, Y, Z) /* * The (char*) casts are required for the DEC when optimizations are turned * on and the source and/or destination are not aligned. */ -#define HDmemcpy(X,Y,Z) memcpy((char*)(X),(const char*)(Y),Z) -#define HDmemmove(X,Y,Z) memmove((char*)(X),(const char*)(Y),Z) +#define HDmemcpy(X, Y, Z) memcpy((char *)(X), (const char *)(Y), Z) +#define HDmemmove(X, Y, Z) memmove((char *)(X), (const char *)(Y), Z) /* * The (void*) cast just avoids a compiler warning in H5_HAVE_VISUAL_STUDIO */ #ifdef H5_HAVE_VISUAL_STUDIO -#define HDmemset(X,C,Z) memset((void*)(X),C,Z) +#define HDmemset(X, C, Z) memset((void *)(X), C, Z) #else /* H5_HAVE_VISUAL_STUDIO */ -#define HDmemset(X,C,Z) memset(X,C,Z) +#define HDmemset(X, C, Z) memset(X, C, Z) #endif /* H5_HAVE_VISUAL_STUDIO */ #ifdef H5_HAVE_WIN32_API -#define HDmkdir(S,M) _mkdir(S) +#define HDmkdir(S, M) _mkdir(S) #else /* H5_HAVE_WIN32_API */ -#define HDmkdir(S,M) mkdir(S,M) +#define HDmkdir(S, M) mkdir(S, M) #endif /* H5_HAVE_WIN32_API */ -#define HDmkfifo(S,M) mkfifo(S,M) -#define HDmktime(T) mktime(T) -#define HDmodf(X,Y) modf(X,Y) +#define HDmkfifo(S, M) mkfifo(S, M) +#define HDmktime(T) mktime(T) +#define HDmodf(X, Y) modf(X, Y) #ifdef _O_BINARY -#define HDopen(S,F,M) open(S,F|_O_BINARY,M) +#define HDopen(S, F, M) open(S, F | _O_BINARY, M) #else -#define HDopen(S,F,M) open(S,F,M) +#define HDopen(S, F, M) open(S, F, M) #endif -#define HDopendir(S) opendir(S) -#define HDpathconf(S,N) pathconf(S,N) -#define HDpause() pause() -#define HDperror(S) perror(S) -#define HDpipe(F) pipe(F) -#define HDpow(X,Y) pow(X,Y) +#define HDopendir(S) opendir(S) +#define HDpathconf(S, N) pathconf(S, N) +#define HDpause() pause() +#define HDperror(S) perror(S) +#define HDpipe(F) pipe(F) +#define HDpow(X, Y) pow(X, Y) /* printf() variable arguments */ -#define HDprintf(...) HDfprintf(stdout, __VA_ARGS__) -#define HDputc(C,F) putc(C,F) -#define HDputchar(C) putchar(C) -#define HDputs(S) puts(S) -#define HDqsort(M,N,Z,F) qsort(M,N,Z,F) -#define HDraise(N) raise(N) +#define HDprintf(...) HDfprintf(stdout, __VA_ARGS__) +#define HDputc(C, F) putc(C, F) +#define HDputchar(C) putchar(C) +#define HDputs(S) puts(S) +#define HDqsort(M, N, Z, F) qsort(M, N, Z, F) +#define HDraise(N) raise(N) #ifdef H5_HAVE_RAND_R -#define HDrandom() HDrand() +#define HDrandom() HDrand() H5_DLL int HDrand(void); #elif H5_HAVE_RANDOM -#define HDrand() random() -#define HDrandom() random() +#define HDrand() random() +#define HDrandom() random() #else -#define HDrand() rand() -#define HDrandom() rand() +#define HDrand() rand() +#define HDrandom() rand() #endif -#define HDread(F,M,Z) read(F,M,Z) -#define HDreaddir(D) readdir(D) -#define HDrealloc(M,Z) realloc(M,Z) -#define HDremove(S) remove(S) -#define HDrename(OLD,NEW) rename(OLD,NEW) -#define HDrewind(F) rewind(F) -#define HDrewinddir(D) rewinddir(D) -#define HDrmdir(S) rmdir(S) +#define HDread(F, M, Z) read(F, M, Z) +#define HDreaddir(D) readdir(D) +#define HDrealloc(M, Z) realloc(M, Z) +#define HDremove(S) remove(S) +#define HDrename(OLD, NEW) rename(OLD, NEW) +#define HDrewind(F) rewind(F) +#define HDrewinddir(D) rewinddir(D) +#define HDrmdir(S) rmdir(S) /* scanf() variable arguments */ -#define HDsetbuf(F,S) setbuf(F,S) -#define HDsetgid(G) setgid(G) -#define HDsetjmp(J) setjmp(J) -#define HDsetlocale(N,S) setlocale(N,S) -#define HDsetpgid(P,PG) setpgid(P,PG) -#define HDsetsid() setsid() -#define HDsetuid(U) setuid(U) +#define HDsetbuf(F, S) setbuf(F, S) +#define HDsetgid(G) setgid(G) +#define HDsetjmp(J) setjmp(J) +#define HDsetlocale(N, S) setlocale(N, S) +#define HDsetpgid(P, PG) setpgid(P, PG) +#define HDsetsid() setsid() +#define HDsetuid(U) setuid(U) /* Windows does not permit setting the buffer size to values less than 2. */ #ifndef H5_HAVE_WIN32_API -#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z) -#else -#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,(Z>1?Z:2)) -#endif -#define HDsigaddset(S,N) sigaddset(S,N) -#define HDsigdelset(S,N) sigdelset(S,N) -#define HDsigemptyset(S) sigemptyset(S) -#define HDsigfillset(S) sigfillset(S) -#define HDsigismember(S,N) sigismember(S,N) -#define HDsiglongjmp(J,N) siglongjmp(J,N) -#define HDsignal(N,F) signal(N,F) -#define HDsigpending(S) sigpending(S) -#define HDsigprocmask(H,S,O) sigprocmask(H,S,O) -#define HDsigsetjmp(J,N) sigsetjmp(J,N) -#define HDsigsuspend(S) sigsuspend(S) -#define HDsin(X) sin(X) -#define HDsinh(X) sinh(X) -#define HDsleep(N) sleep(N) -#ifdef H5_HAVE_WIN32_API -H5_DLL int c99_snprintf(char* str, size_t size, const char* format, ...); -#define HDsnprintf c99_snprintf /*varargs*/ +#define HDsetvbuf(F, S, M, Z) setvbuf(F, S, M, Z) #else -#define HDsnprintf snprintf /*varargs*/ +#define HDsetvbuf(F, S, M, Z) setvbuf(F, S, M, (Z > 1 ? Z : 2)) #endif -/* sprintf() variable arguments */ -#define HDsprintf sprintf /*varargs*/ -#define HDsqrt(X) sqrt(X) +#define HDsigaddset(S, N) sigaddset(S, N) +#define HDsigdelset(S, N) sigdelset(S, N) +#define HDsigemptyset(S) sigemptyset(S) +#define HDsigfillset(S) sigfillset(S) +#define HDsigismember(S, N) sigismember(S, N) +#define HDsiglongjmp(J, N) siglongjmp(J, N) +#define HDsignal(N, F) signal(N, F) +#define HDsigpending(S) sigpending(S) +#define HDsigprocmask(H, S, O) sigprocmask(H, S, O) +#define HDsigsetjmp(J, N) sigsetjmp(J, N) +#define HDsigsuspend(S) sigsuspend(S) +#define HDsin(X) sin(X) +#define HDsinh(X) sinh(X) +#define HDsleep(N) sleep(N) +#define HDsnprintf snprintf /*varargs*/ +#define HDsprintf sprintf /*varargs*/ +#define HDsqrt(X) sqrt(X) #ifdef H5_HAVE_RAND_R H5_DLL void HDsrand(unsigned int seed); -#define HDsrandom(S) HDsrand(S) +#define HDsrandom(S) HDsrand(S) #elif H5_HAVE_RANDOM -#define HDsrand(S) srandom(S) -#define HDsrandom(S) srandom(S) +#define HDsrand(S) srandom(S) +#define HDsrandom(S) srandom(S) #else -#define HDsrand(S) srand(S) -#define HDsrandom(S) srand(S) +#define HDsrand(S) srand(S) +#define HDsrandom(S) srand(S) #endif -/* sscanf() variable arguments */ #ifdef H5_HAVE_WIN32_API -#define HDstrcasecmp(A,B) _stricmp(A,B) +#define HDstrcasecmp(A, B) _stricmp(A, B) #else -#define HDstrcasecmp(X,Y) strcasecmp(X,Y) +#define HDstrcasecmp(X, Y) strcasecmp(X, Y) #endif -#define HDstrcat(X,Y) strcat(X,Y) -#define HDstrchr(S,C) strchr(S,C) -#define HDstrcmp(X,Y) strcmp(X,Y) -#define HDstrcoll(X,Y) strcoll(X,Y) -#define HDstrcpy(X,Y) strcpy(X,Y) -#define HDstrcspn(X,Y) strcspn(X,Y) -#define HDstrerror(N) strerror(N) -#define HDstrftime(S,Z,F,T) strftime(S,Z,F,T) -#define HDstrlen(S) strlen(S) -#define HDstrncat(X,Y,Z) strncat(X,Y,Z) -#define HDstrncmp(X,Y,Z) strncmp(X,Y,Z) -#define HDstrncpy(X,Y,Z) strncpy(X,Y,Z) -#define HDstrpbrk(X,Y) strpbrk(X,Y) -#define HDstrrchr(S,C) strrchr(S,C) -#define HDstrspn(X,Y) strspn(X,Y) -#define HDstrstr(X,Y) strstr(X,Y) -#define HDstrtod(S,R) strtod(S,R) -#define HDstrtok(X,Y) strtok(X,Y) -#define HDstrtol(S,R,N) strtol(S,R,N) -H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); -#define HDstrtoul(S,R,N) strtoul(S,R,N) +#define HDstrcat(X, Y) strcat(X, Y) +#define HDstrchr(S, C) strchr(S, C) +#define HDstrcmp(X, Y) strcmp(X, Y) +#define HDstrcoll(X, Y) strcoll(X, Y) +#define HDstrcpy(X, Y) strcpy(X, Y) +#define HDstrcspn(X, Y) strcspn(X, Y) +#define HDstrerror(N) strerror(N) +#define HDstrftime(S, Z, F, T) strftime(S, Z, F, T) +#define HDstrlen(S) strlen(S) +#define HDstrncat(X, Y, Z) strncat(X, Y, Z) +#define HDstrncmp(X, Y, Z) strncmp(X, Y, Z) +#define HDstrncpy(X, Y, Z) strncpy(X, Y, Z) +#define HDstrpbrk(X, Y) strpbrk(X, Y) +#define HDstrrchr(S, C) strrchr(S, C) +#define HDstrspn(X, Y) strspn(X, Y) +#define HDstrstr(X, Y) strstr(X, Y) +#define HDstrtod(S, R) strtod(S, R) +#define HDstrtok(X, Y) strtok(X, Y) +#define HDstrtol(S, R, N) strtol(S, R, N) +H5_DLL int64_t HDstrtoll(const char *s, const char **rest, int base); +#define HDstrtoul(S, R, N) strtoul(S, R, N) #ifdef H5_HAVE_WIN32_API -#define HDstrtoull(S,R,N) _strtoui64(S,R,N) +#define HDstrtoull(S, R, N) _strtoui64(S, R, N) #else -#define HDstrtoull(S,R,N) strtoull(S,R,N) +#define HDstrtoull(S, R, N) strtoull(S, R, N) #endif -#define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z) -#define HDsysconf(N) sysconf(N) -#define HDsystem(S) system(S) -#define HDtan(X) tan(X) -#define HDtanh(X) tanh(X) -#define HDtcdrain(F) tcdrain(F) -#define HDtcflow(F,A) tcflow(F,A) -#define HDtcflush(F,N) tcflush(F,N) -#define HDtcgetattr(F,T) tcgetattr(F,T) -#define HDtcgetpgrp(F) tcgetpgrp(F) -#define HDtcsendbreak(F,N) tcsendbreak(F,N) -#define HDtcsetattr(F,O,T) tcsetattr(F,O,T) -#define HDtcsetpgrp(F,N) tcsetpgrp(F,N) -#define HDtime(T) time(T) -#define HDtimes(T) times(T) -#define HDtmpfile() tmpfile() -#define HDtmpnam(S) tmpnam(S) -#define HDtolower(C) tolower(C) -#define HDtoupper(C) toupper(C) -#define HDttyname(F) ttyname(F) -#define HDtzset() tzset() -#define HDumask(N) umask(N) -#define HDuname(S) uname(S) -#define HDungetc(C,F) ungetc(C,F) +#define HDstrxfrm(X, Y, Z) strxfrm(X, Y, Z) +#define HDsysconf(N) sysconf(N) +#define HDsystem(S) system(S) +#define HDtan(X) tan(X) +#define HDtanh(X) tanh(X) +#define HDtcdrain(F) tcdrain(F) +#define HDtcflow(F, A) tcflow(F, A) +#define HDtcflush(F, N) tcflush(F, N) +#define HDtcgetattr(F, T) tcgetattr(F, T) +#define HDtcgetpgrp(F) tcgetpgrp(F) +#define HDtcsendbreak(F, N) tcsendbreak(F, N) +#define HDtcsetattr(F, O, T) tcsetattr(F, O, T) +#define HDtcsetpgrp(F, N) tcsetpgrp(F, N) +#define HDtime(T) time(T) +#define HDtimes(T) times(T) +#define HDtmpfile() tmpfile() +#define HDtmpnam(S) tmpnam(S) +#define HDtolower(C) tolower(C) +#define HDtoupper(C) toupper(C) +#define HDttyname(F) ttyname(F) +#define HDtzset() tzset() +#define HDumask(N) umask(N) +#define HDuname(S) uname(S) +#define HDungetc(C, F) ungetc(C, F) #ifdef H5_HAVE_WIN32_API -#define HDunlink(S) _unlink(S) +#define HDunlink(S) _unlink(S) #else -#define HDunlink(S) unlink(S) +#define HDunlink(S) unlink(S) #endif -#define HDutime(S,T) utime(S,T) -#define HDva_arg(A,T) va_arg(A,T) -#define HDva_end(A) va_end(A) -#define HDva_start(A,P) va_start(A,P) -#define HDvasprintf(RET,FMT,A) vasprintf(RET,FMT,A) -#define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A) -#define HDvprintf(FMT,A) vprintf(FMT,A) -#define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A) -#ifdef H5_HAVE_WIN32_API -H5_DLL int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap); -#define HDvsnprintf c99_vsnprintf -#else -# define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A) -#endif -#define HDwait(W) wait(W) -#define HDwaitpid(P,W,O) waitpid(P,W,O) -#define HDwcstombs(S,P,Z) wcstombs(S,P,Z) -#define HDwctomb(S,C) wctomb(S,C) -#define HDwrite(F,M,Z) write(F,M,Z) +#define HDutime(S, T) utime(S, T) +#define HDva_arg(A, T) va_arg(A, T) +#define HDva_end(A) va_end(A) +#define HDva_start(A, P) va_start(A, P) +#define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A) +#define HDvfprintf(F, FMT, A) vfprintf(F, FMT, A) +#define HDvprintf(FMT, A) vprintf(FMT, A) +#define HDvsprintf(S, FMT, A) vsprintf(S, FMT, A) +#define HDvsnprintf(S, N, FMT, A) vsnprintf(S, N, FMT, A) +#define HDwait(W) wait(W) +#define HDwaitpid(P, W, O) waitpid(P, W, O) +#define HDwcstombs(S, P, Z) wcstombs(S, P, Z) +#define HDwctomb(S, C) wctomb(S, C) +#define HDwrite(F, M, Z) write(F, M, Z) /* * And now for a couple non-Posix functions... Watch out for systems that * define these in terms of macros. */ #ifdef H5_HAVE_WIN32_API -#define HDstrdup(S) _strdup(S) +#define HDstrdup(S) _strdup(S) #else /* H5_HAVE_WIN32_API */ #if !defined strdup && !defined H5_HAVE_STRDUP -extern char *strdup(const char *s); +extern char * strdup(const char *s); #endif -#define HDstrdup(S) strdup(S) +#define HDstrdup(S) strdup(S) #endif /* H5_HAVE_WIN32_API */ @@ -470,52 +435,38 @@ extern char *strdup(const char *s); * HDF Boolean type. */ #ifndef FALSE -# define FALSE false +#define FALSE false #endif #ifndef TRUE -# define TRUE true -#endif - -/** From h5test.h **/ - -#ifdef H5_HAVE_PARALLEL -extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */ -#endif - -#ifdef H5_HAVE_PARALLEL -H5TEST_DLL int h5_set_info_object(void); -H5TEST_DLL void h5_dump_info_object(MPI_Info info); +#define TRUE true #endif - - /** From h5tools_utils.h **/ -extern int opt_err; /* getoption prints errors if this is on */ -extern int opt_ind; /* token pointer */ -extern const char *opt_arg; /* flag argument (or value) */ +H5_DLLVAR int H5_opterr; /* getoption prints errors if this is on */ +H5_DLLVAR int H5_optind; /* token pointer */ +H5_DLLVAR const char *H5_optarg; /* flag argument (or value) */ - -enum { - no_arg = 0, /* doesn't take an argument */ - require_arg, /* requires an argument */ - optional_arg /* argument is optional */ +enum h5_arg_level { + no_arg = 0, /* doesn't take an argument */ + require_arg, /* requires an argument */ + optional_arg /* argument is optional */ }; +struct h5_long_options { + const char * name; /* Name of the long option */ + enum h5_arg_level has_arg; /* Whether we should look for an arg */ + char shortval; /* The shortname equivalent of long arg + * this gets returned from get_option + */ +}; -typedef struct long_options { - const char *name; /* name of the long option */ - int has_arg; /* whether we should look for an arg */ - char shortval; /* the shortname equivalent of long arg - * this gets returned from get_option */ -} long_options; - -extern int get_option(int argc, const char **argv, const char *opt, - const struct long_options *l_opt); +extern int H5_get_option(int argc, const char *const *argv, const char *opt, + const struct h5_long_options *l_opt); -extern int nCols; /*max number of columns for outputting */ +extern int nCols; /*max number of columns for outputting */ /* Definitions of useful routines */ -extern void print_version(const char *progname); +extern void print_version(const char *progname); #endif diff --git a/tools/test/perform/sio_engine.c b/tools/test/perform/sio_engine.c deleted file mode 100644 index 07a39cb..0000000 --- a/tools/test/perform/sio_engine.c +++ /dev/null @@ -1,1335 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * 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://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Author: Christian Chilan, April 2008 - */ - -#include "hdf5.h" - -#ifdef H5_STDC_HEADERS -#include <errno.h> -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#endif - -#ifdef H5_HAVE_UNISTD_H -#include <sys/types.h> -#include <unistd.h> -#endif - -#ifdef H5_HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif - -#include "sio_perf.h" - -/* Macro definitions */ - -/* sizes of various items. these sizes won't change during program execution */ -#define ELMT_H5_TYPE H5T_NATIVE_UCHAR - -#define GOTOERROR(errcode) { ret_code = errcode; goto done; } -#define ERRMSG(mesg) { \ - HDfprintf(stderr, "*** Assertion failed (%s) at line %4d in %s\n", \ - mesg, (int)__LINE__, __FILE__); \ -} - -/* verify: if val is false (0), print mesg. */ -#define VRFY(val, mesg) do { \ - if (!val) { \ - ERRMSG(mesg); \ - GOTOERROR(FAIL); \ - } \ -} while(0) - -/* POSIX I/O macros */ -#ifdef H5_HAVE_WIN32_API -/* Can't link against the library, so this test will use the older, non-Unicode - * _open() call on Windows. - */ -#define HDopen(S,F,...) _open(S, F | _O_BINARY, __VA_ARGS__) -#endif /* H5_HAVE_WIN32_API */ -#define POSIXCREATE(fn) HDopen(fn, O_CREAT|O_TRUNC|O_RDWR, 0600) -#define POSIXOPEN(fn, F) HDopen(fn, F, 0600) -#define POSIXCLOSE(F) HDclose(F) -#define POSIXSEEK(F,L) HDlseek(F, L, SEEK_SET) -#define POSIXWRITE(F,B,S) HDwrite(F,B,S) -#define POSIXREAD(F,B,S) HDread(F,B,S) - -enum { - SIO_CREATE = 1, - SIO_WRITE = 2, - SIO_READ = 4 -}; - -/* Global variables */ -static int clean_file_g = -1; /*whether to cleanup temporary test */ -/*files. -1 is not defined; */ -/*0 is no cleanup; 1 is do cleanup */ - -/* the different types of file descriptors we can expect */ -typedef union _file_descr { - int posixfd; /* POSIX file handle*/ - hid_t h5fd; /* HDF5 file */ -} file_descr; - -/* local functions */ -static char *sio_create_filename(iotype iot, const char *base_name, - char *fullname, size_t size, parameters *param); -static herr_t do_write(results *res, file_descr *fd, parameters *parms, void *buffer); -static herr_t do_read(results *res, file_descr *fd, parameters *parms, void *buffer); -static herr_t dset_write(int local_dim, file_descr *fd, parameters *parms, void *buffer); -static herr_t posix_buffer_write(int local_dim, file_descr *fd, parameters *parms, void *buffer); -static herr_t dset_read(int localrank, file_descr *fd, parameters *parms, void *buffer, const char *buffer2); -static herr_t posix_buffer_read(int local_dim, file_descr *fd, parameters *parms, void *buffer); -static herr_t do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, - int flags); -hid_t set_vfd(parameters *param); -static herr_t do_fclose(iotype iot, file_descr *fd); -static void do_cleanupfile(iotype iot, char *fname); - -/* global variables */ -static HDoff_t offset[MAX_DIMS]; /* dataset size in bytes */ -static size_t buf_offset[MAX_DIMS]; /* dataset size in bytes */ -static int order[MAX_DIMS]; /* dimension access order */ -static size_t linear_buf_size; /* linear buffer size */ -static int cont_dim; /* lowest dimension for contiguous POSIX - access */ -static size_t cont_size; /* size of contiguous POSIX access */ -static hid_t fapl; /* file access list */ -static unsigned char *buf_p; /* buffer pointer */ -static const char *multi_letters = "msbrglo"; /* string for multi driver */ - -/* HDF5 global variables */ -static hsize_t h5count[MAX_DIMS]; /*selection count */ -static hssize_t h5offset[MAX_DIMS]; /* Selection offset within dataspace */ -static hid_t h5dset_space_id = -1; /*dataset space ID */ -static hid_t h5mem_space_id = -1; /*memory dataspace ID */ -static hid_t h5ds_id = -1; /*dataset handle */ -static hid_t h5dcpl = -1; /* Dataset creation property list */ -static hid_t h5dxpl = -1; /* Dataset transfer property list */ - -/* - * Function: do_sio - * Purpose: SIO Engine where IO are executed. - * Return: results - * Programmer: Christian Chilan, April, 2008 - * Modifications: - */ -void -do_sio(parameters param, results *res) -{ - char *buffer = NULL; /*data buffer pointer */ - size_t buf_size[MAX_DIMS]; /* general buffer size in bytes */ - file_descr fd; /* file handles */ - iotype iot; /* API type */ - char base_name[256]; /* test file base name */ - /* return codes */ - herr_t ret_code = 0; /*return code */ - - char fname[FILENAME_MAX]; /* test file name */ - int i; - /* HDF5 variables */ - herr_t hrc; /*HDF5 return code */ - - /* Sanity check parameters */ - - /* IO type */ - iot = param.io_type; - - switch (iot) { - case POSIXIO: - fd.posixfd = -1; - res->timers = io_time_new(SYS_CLOCK); - break; - case HDF5: - fd.h5fd = -1; - res->timers = io_time_new(SYS_CLOCK); - break; - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot); - GOTOERROR(FAIL); - } - - linear_buf_size = 1; - - for (i=0; i<param.rank; i++){ - buf_size[i] = param.buf_size[i]; - order[i] = param.order[i]; - linear_buf_size *= buf_size[i]; - buf_offset[i] = 0; - offset[i] = 0; - - /* Validate transfer buffer size */ - if (param.buf_size[i]<=0) { - HDfprintf(stderr, - "Transfer buffer size[%d] (%zu) must be > 0\n", i,buf_size[i]); - GOTOERROR(FAIL); - } - - if ((param.dset_size[i]%param.buf_size[i])!=0) { - HDfprintf(stderr, - "Dataset size[%d] (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " - "trasfer buffer size[%d] (%zu)\n",param.rank, - (long long)param.dset_size[i], param.rank, param.buf_size[i]); - GOTOERROR(FAIL); - } - - } - - /* Allocate transfer buffer */ - if ((buffer = (char *)malloc(linear_buf_size)) == NULL){ - HDfprintf(stderr, "malloc for transfer buffer size (%zu) failed\n", linear_buf_size); - GOTOERROR(FAIL); - } - - if (sio_debug_level >= 4) - - /* output all of the times for all iterations */ - HDfprintf(output, "Timer details:\n"); - - /* - * Write performance measurement - */ - /* Open file for write */ - - HDstrcpy(base_name, "#sio_tmp"); - sio_create_filename(iot, base_name, fname, sizeof(fname), ¶m); - - if (sio_debug_level > 0) - HDfprintf(output, "data filename=%s\n", - fname); - - io_time_set(res->timers, HDF5_GROSS_WRITE_FIXED_DIMS, TSTART); - hrc = do_fopen(¶m, fname, &fd, SIO_CREATE | SIO_WRITE); - VRFY((hrc == SUCCESS), "do_fopen failed"); - - io_time_set(res->timers, HDF5_FINE_WRITE_FIXED_DIMS, TSTART); - hrc = do_write(res, &fd, ¶m, buffer); - io_time_set(res->timers, HDF5_FINE_WRITE_FIXED_DIMS, TSTOP); - VRFY((hrc == SUCCESS), "do_write failed"); - - /* Close file for write */ - hrc = do_fclose(iot, &fd); - io_time_set(res->timers, HDF5_GROSS_WRITE_FIXED_DIMS, TSTOP); - VRFY((hrc == SUCCESS), "do_fclose failed"); - - if (!param.h5_write_only) { - /* - * Read performance measurement - */ - - /* Open file for read */ - io_time_set(res->timers, HDF5_GROSS_READ_FIXED_DIMS, TSTART); - hrc = do_fopen(¶m, fname, &fd, SIO_READ); - VRFY((hrc == SUCCESS), "do_fopen failed"); - - io_time_set(res->timers, HDF5_FINE_READ_FIXED_DIMS, TSTART); - hrc = do_read(res, &fd, ¶m, buffer); - io_time_set(res->timers, HDF5_FINE_READ_FIXED_DIMS, TSTOP); - VRFY((hrc == SUCCESS), "do_read failed"); - - /* Close file for read */ - hrc = do_fclose(iot, &fd); - - io_time_set(res->timers, HDF5_GROSS_READ_FIXED_DIMS, TSTOP); - VRFY((hrc == SUCCESS), "do_fclose failed"); - } - - do_cleanupfile(iot, fname); - -done: - /* clean up */ - /* release HDF5 objects */ - - /* close any opened files */ - /* no remove(fname) because that should have happened normally. */ - switch (iot) { - case POSIXIO: - if (fd.posixfd != -1) - hrc = do_fclose(iot, &fd); - break; - case HDF5: - if (fd.h5fd != -1) - hrc = do_fclose(iot, &fd); - break; - default: - /* unknown request */ - HDassert(0 && "Unknown IO type"); - break; - } - - /* release generic resources */ - if (buffer) - free(buffer); - - res->ret_code = ret_code; -} - -/* - * Function: sio_create_filename - * Purpose: Create a new filename to write to. Determine the correct - * suffix to append to the filename by the type of I/O we're - * doing. Also, place in the /tmp/{$USER,$LOGIN} directory if - * USER or LOGIN are specified in the environment. - * Return: Pointer to filename or NULL - * Programmer: Bill Wendling, 21. November 2001 - * Modifications: Support for file drivers. Christian Chilan, April, 2008 - */ - static char * -sio_create_filename(iotype iot, const char *base_name, char *fullname, size_t size, parameters *param) -{ - const char *prefix, *suffix=""; - char *ptr, last = '\0'; - size_t i, j; - vfdtype vfd; - vfd = param->vfd; - - if (!base_name || !fullname || size < 1) - return NULL; - - memset(fullname, 0, size); - - switch (iot) { - case POSIXIO: - suffix = ".posix"; - break; - case HDF5: - suffix = ".h5"; - if (vfd == family) - suffix = "%05d.h5"; - else if (vfd == multi) - suffix = NULL; - break; - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot); - HDassert(0 && "Unknown IO type"); - break; - } - - /* First use the environment variable and then try the constant */ - prefix = HDgetenv("HDF5_PREFIX"); - -#ifdef HDF5_PREFIX - if (!prefix) - prefix = HDF5_PREFIX; -#endif /* HDF5_PREFIX */ - - /* Prepend the prefix value to the base name */ - if (prefix && *prefix) { - /* If the prefix specifies the HDF5_PREFIX directory, then - * default to using the "/tmp/$USER" or "/tmp/$LOGIN" - * directory instead. */ - register char *user, *login, *subdir; - - user = HDgetenv("USER"); - login = HDgetenv("LOGIN"); - subdir = (user ? user : login); - - if (subdir) { - for (i = 0; i < size-1 && prefix[i]; i++) - fullname[i] = prefix[i]; - - fullname[i++] = '/'; - - for (j = 0; i < size && subdir[j]; i++, j++) - fullname[i] = subdir[j]; - } else { - /* We didn't append the prefix yet */ - HDstrncpy(fullname, prefix, size); - fullname[size - 1] = '\0'; - } - - if ((HDstrlen(fullname) + HDstrlen(base_name) + 1) < size) { - /* Append the base_name with a slash first. Multiple slashes are - * handled below. */ - h5_stat_t buf; - - if (HDstat(fullname, &buf) < 0) - /* The directory doesn't exist just yet */ - if (HDmkdir(fullname, 0755) < 0 && errno != EEXIST) { - /* We couldn't make the "/tmp/${USER,LOGIN}" subdirectory. - * Default to PREFIX's original prefix value. */ - HDstrcpy(fullname, prefix); - } - - HDstrcat(fullname, "/"); - HDstrcat(fullname, base_name); - } else { - /* Buffer is too small */ - return NULL; - } - } else if (strlen(base_name) >= size) { - /* Buffer is too small */ - return NULL; - } else { - HDstrcpy(fullname, base_name); - } - - /* Append a suffix */ - if (suffix) { - if (HDstrlen(fullname) + HDstrlen(suffix) >= size) - return NULL; - - HDstrcat(fullname, suffix); - } - - /* Remove any double slashes in the filename */ - for (ptr = fullname, i = j = 0; ptr && (i < size); i++, ptr++) { - if (*ptr != '/' || last != '/') - fullname[j++] = *ptr; - - last = *ptr; - } - - return fullname; -} - -/* - * Function: do_write - * Purpose: Write the required amount of data to the file. - * Return: SUCCESS or FAIL - * Programmer: Christian Chilan, April, 2008 - * Modifications: - */ -static herr_t -do_write(results *res, file_descr *fd, parameters *parms, void *buffer) -{ - int ret_code = SUCCESS; - char dname[64]; - int i; - size_t u; - /* HDF5 variables */ - herr_t hrc; /*HDF5 return code */ - hsize_t h5dims[MAX_DIMS]; /*dataset dim sizes */ - hsize_t h5chunk[MAX_DIMS]; /*dataset dim sizes */ - hsize_t h5block[MAX_DIMS]; /*dataspace selection */ - hsize_t h5stride[MAX_DIMS]; /*selection stride */ - hsize_t h5start[MAX_DIMS]; /*selection start */ - hsize_t h5maxdims[MAX_DIMS]; - int rank; /*rank of dataset */ - - /* Prepare buffer for verifying data */ -/* if (parms->verify) - memset(buffer,1,linear_buf_size); */ - - buf_p=(unsigned char *)buffer; - - for(u = 0; u < linear_buf_size; u++) - buf_p[u] = u % 128; - - rank = parms->rank; - - for(i = 0; i < rank; i++) - h5offset[i] = offset[i] = 0; - - /* I/O Access specific setup */ - switch (parms->io_type) { - case POSIXIO: - - /* determine lowest dimension for contiguous POSIX access */ - cont_dim = rank; - - for (i=rank-1; i>=0; i--) { - if (parms->buf_size[i]==parms->dset_size[i]) - cont_dim = i; - else - break; - } - - /* determine size of the contiguous POSIX access */ - cont_size = (!cont_dim)? 1 : parms->buf_size[cont_dim-1]; - for (i=cont_dim; i<rank; i++) - cont_size *= parms->buf_size[i]; - - break; - - case HDF5: /* HDF5 setup */ - - for (i=0; i < rank; i++){ - h5dims[i] = parms->dset_size[i]; - h5start[i] = 0; - h5stride[i] = 1; - h5block[i] = 1; - h5count[i] = parms->buf_size[i]; - h5chunk[i] = parms->chk_size[i]; - h5maxdims[i] = H5S_UNLIMITED; - - } - - if (parms->h5_use_chunks && parms->h5_extendable) { - h5dset_space_id = H5Screate_simple(rank, h5count, h5maxdims); - VRFY((h5dset_space_id >= 0), "H5Screate_simple"); - } - else { - h5dset_space_id = H5Screate_simple(rank, h5dims, NULL); - VRFY((h5dset_space_id >= 0), "H5Screate_simple"); - } - - hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, - h5start, h5stride, h5count, h5block); - VRFY((hrc >= 0), "H5Sselect_hyperslab"); - - /* Create the memory dataspace that corresponds to the xfer buffer */ - h5mem_space_id = H5Screate_simple(rank, h5count, NULL); - VRFY((h5mem_space_id >= 0), "H5Screate_simple"); - - /* Create the dataset transfer property list */ - h5dxpl = H5Pcreate(H5P_DATASET_XFER); - if (h5dxpl < 0) { - HDfprintf(stderr, "HDF5 Property List Create failed\n"); - GOTOERROR(FAIL); - } - - break; - - default: - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); - GOTOERROR(FAIL); - break; - } /* end switch */ - - - /* create dataset */ - switch (parms->io_type) { - case POSIXIO: - break; - - case HDF5: - h5dcpl = H5Pcreate(H5P_DATASET_CREATE); - - if (h5dcpl < 0) { - HDfprintf(stderr, "HDF5 Property List Create failed\n"); - GOTOERROR(FAIL); - } - - if(parms->h5_use_chunks) { - /* Set the chunk size to be the same as the buffer size */ - hrc = H5Pset_chunk(h5dcpl, rank, h5chunk); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Property List Set failed\n"); - GOTOERROR(FAIL); - } /* end if */ - } /* end if */ - - HDsprintf(dname, "Dataset_%ld", (unsigned long)parms->num_bytes); - h5ds_id = H5Dcreate2(fd->h5fd, dname, ELMT_H5_TYPE, - h5dset_space_id, H5P_DEFAULT, h5dcpl, H5P_DEFAULT); - - if (h5ds_id < 0) { - HDfprintf(stderr, "HDF5 Dataset Create failed\n"); - GOTOERROR(FAIL); - } - - hrc = H5Pclose(h5dcpl); - /* verifying the close of the dcpl */ - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Property List Close failed\n"); - GOTOERROR(FAIL); - } - break; - - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); - GOTOERROR(FAIL); - break; - } - - /* Start "raw data" write timer */ - io_time_set(res->timers, HDF5_RAW_WRITE_FIXED_DIMS, TSTART); - - /* Perform write */ - hrc = dset_write(rank-1, fd, parms, buffer); - - if (hrc < 0) { - HDfprintf(stderr, "Error in dataset write\n"); - GOTOERROR(FAIL); - } - - - /* Stop "raw data" write timer */ - io_time_set(res->timers, HDF5_RAW_WRITE_FIXED_DIMS, TSTOP); - - /* Calculate write time */ - - /* Close dataset. Only HDF5 needs to do an explicit close. */ - if (parms->io_type == HDF5) { - hrc = H5Dclose(h5ds_id); - - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Dataset Close failed\n"); - GOTOERROR(FAIL); - } - - h5ds_id = -1; - } /* end if */ - -done: - - /* release HDF5 objects */ - if (h5dset_space_id != -1) { - hrc = H5Sclose(h5dset_space_id); - if (hrc < 0){ - HDfprintf(stderr, "HDF5 Dataset Space Close failed\n"); - ret_code = FAIL; - } else { - h5dset_space_id = -1; - } - } - - if (h5mem_space_id != -1) { - hrc = H5Sclose(h5mem_space_id); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Memory Space Close failed\n"); - ret_code = FAIL; - } else { - h5mem_space_id = -1; - } - } - - if (h5dxpl != -1) { - hrc = H5Pclose(h5dxpl); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Dataset Transfer Property List Close failed\n"); - ret_code = FAIL; - } else { - h5dxpl = -1; - } - } - - return ret_code; -} - -/* - * Function: dset_write - * Purpose: Write buffer into the dataset. - * Return: SUCCESS or FAIL - * Programmer: Christian Chilan, April, 2008 - * Modifications: - */ -static herr_t -dset_write(int local_dim, file_descr *fd, parameters *parms, void *buffer) -{ - int cur_dim = order[local_dim]-1; - int ret_code = SUCCESS; - int k; - hsize_t dims[MAX_DIMS], maxdims[MAX_DIMS]; - hsize_t i; - int j; - herr_t hrc; - - /* iterates according to the dimensions in order array */ - for (i=0; i < parms->dset_size[cur_dim]; i += parms->buf_size[cur_dim]){ - - h5offset[cur_dim] = (hssize_t)i; - offset[cur_dim] = (HDoff_t)i; - - if (local_dim > 0){ - - dset_write(local_dim-1, fd, parms, buffer); - - }else{ - - switch (parms->io_type) { - - case POSIXIO: - /* initialize POSIX offset in the buffer */ - for(j = 0; j < parms->rank; j++) - buf_offset[j] = 0; - buf_p = (unsigned char *)buffer; - /* write POSIX buffer */ - posix_buffer_write(0, fd, parms, buffer); - break; - - case HDF5: - /* if dimensions are extendable, extend them as needed during access */ - if (parms->h5_use_chunks && parms->h5_extendable) { - - hrc=H5Sget_simple_extent_dims(h5dset_space_id,dims,maxdims); - VRFY((hrc >= 0), "H5Sget_simple_extent_dims"); - - for (k=0; k < parms->rank; k++){ - - HDassert(h5offset[k] >= 0); - if (dims[k] <= (hsize_t)h5offset[k]) { - dims[k] = dims[k]+h5count[k]; - hrc=H5Sset_extent_simple(h5dset_space_id,parms->rank,dims,maxdims); - VRFY((hrc >= 0), "H5Sset_extent_simple"); - hrc=H5Dset_extent(h5ds_id,dims); - VRFY((hrc >= 0), "H5Dextend"); - } - } - } - /* applies offset */ - hrc = H5Soffset_simple(h5dset_space_id, h5offset); - VRFY((hrc >= 0), "H5Soffset_simple"); - - /* Write the buffer out */ - hrc=H5Sget_simple_extent_dims(h5dset_space_id,dims,maxdims); - hrc = H5Dwrite(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, - h5dset_space_id, h5dxpl, buffer); - VRFY((hrc >= 0), "H5Dwrite"); - - break; - - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); - HDassert(0 && "Unknown IO type"); - break; - } /* switch (parms->io_type) */ - } - } -done: - return ret_code; -} - -/* - * Function: posix_buffer_write - * Purpose: Write buffer into the POSIX file considering contiguity. - * Return: SUCCESS or FAIL - * Programmer: Christian Chilan, April, 2008 - * Modifications: - */ - -static herr_t -posix_buffer_write(int local_dim, file_descr *fd, parameters *parms, void *buffer) -{ - int ret_code = SUCCESS; - - /* if dimension is not contiguous, call recursively */ - if (local_dim < parms->rank-1 && local_dim != cont_dim) { - size_t u; - - for(u = 0; u < parms->buf_size[local_dim]; u ++) { - buf_offset[local_dim] = u; - posix_buffer_write(local_dim+1, fd, parms, buffer); - - /* if next dimension is cont_dim, it will fill out the buffer - traversing the entire dimension local_dim without the need - of performing iteration */ - if (local_dim+1==cont_dim) - break; - } - /* otherwise, perform contiguous POSIX access */ - } else { - HDoff_t d_offset; - HDoff_t linear_dset_offset = 0; - int i, j, rc; - - buf_offset[local_dim] = 0; - - /* determine offset in the buffer */ - for(i = 0; i < parms->rank; i++) { - d_offset = 1; - - for(j = i + 1; j < parms->rank; j++) - d_offset *= (HDoff_t)parms->dset_size[j]; - - linear_dset_offset += (offset[i] + (HDoff_t)buf_offset[i]) * d_offset; - } - - /* only care if seek returns error */ - rc = POSIXSEEK(fd->posixfd, linear_dset_offset) < 0 ? -1 : 0; - VRFY((rc==0), "POSIXSEEK"); - /* check if all bytes are written */ - rc = ((ssize_t)cont_size == - POSIXWRITE(fd->posixfd, buf_p, cont_size)); - VRFY((rc != 0), "POSIXWRITE"); - - /* Advance location in buffer */ - buf_p += cont_size; - - } - -done: - return ret_code; -} - -/* - * Function: do_read - * Purpose: Read the required amount of data to the file. - * Return: SUCCESS or FAIL - * Programmer: Christian Chilan, April, 2008 - * Modifications: - */ -static herr_t -do_read(results *res, file_descr *fd, parameters *parms, void *buffer) -{ - char *buffer2 = NULL; /* Buffer for data verification */ - int ret_code = SUCCESS; - char dname[64]; - int i; - size_t u; - /* HDF5 variables */ - herr_t hrc; /*HDF5 return code */ - hsize_t h5dims[MAX_DIMS]; /*dataset dim sizes */ - hsize_t h5block[MAX_DIMS]; /*dataspace selection */ - hsize_t h5stride[MAX_DIMS]; /*selection stride */ - hsize_t h5start[MAX_DIMS]; /*selection start */ - int rank; - - /* Allocate data verification buffer */ - if(NULL == (buffer2 = (char *)malloc(linear_buf_size))) { - HDfprintf(stderr, "malloc for data verification buffer size (%Zu) failed\n", linear_buf_size); - GOTOERROR(FAIL); - } /* end if */ - - /* Prepare buffer for verifying data */ - for(u = 0; u < linear_buf_size; u++) - buffer2[u] = (char)(u % 128); - - rank = parms->rank; - for(i = 0; i < rank; i++) - h5offset[i] = offset[i] = 0; - - /* I/O Access specific setup */ - switch (parms->io_type) { - case POSIXIO: - cont_dim = rank; - - for (i=rank-1; i>=0; i--) { - if (parms->buf_size[i]==parms->dset_size[i]) - cont_dim = i; - else - break; - } - cont_size = (!cont_dim)? 1 : parms->buf_size[cont_dim-1]; - for (i=cont_dim; i<rank; i++) - cont_size *= parms->buf_size[i]; - - break; - - case HDF5: /* HDF5 setup */ - for (i=0; i < rank; i++){ - h5dims[i] = parms->dset_size[i]; - h5start[i] = 0; - h5stride[i] = 1; - h5block[i] = 1; - h5count[i] = parms->buf_size[i]; - } - - h5dset_space_id = H5Screate_simple(rank, h5dims, NULL); - VRFY((h5dset_space_id >= 0), "H5Screate_simple"); - - hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, - h5start, h5stride, h5count, h5block); - VRFY((hrc >= 0), "H5Sselect_hyperslab"); - - /* Create the memory dataspace that corresponds to the xfer buffer */ - h5mem_space_id = H5Screate_simple(rank, h5count, NULL); - VRFY((h5mem_space_id >= 0), "H5Screate_simple"); - - /* Create the dataset transfer property list */ - h5dxpl = H5Pcreate(H5P_DATASET_XFER); - if (h5dxpl < 0) { - HDfprintf(stderr, "HDF5 Property List Create failed\n"); - GOTOERROR(FAIL); - } - break; - - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); - GOTOERROR(FAIL); - break; - } /* end switch */ - - - /* create dataset */ - switch (parms->io_type) { - case POSIXIO: - break; - - case HDF5: - HDsprintf(dname, "Dataset_%ld", (long)parms->num_bytes); - h5ds_id = H5Dopen2(fd->h5fd, dname, H5P_DEFAULT); - if (h5ds_id < 0) { - HDfprintf(stderr, "HDF5 Dataset open failed\n"); - GOTOERROR(FAIL); - } - break; - - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); - GOTOERROR(FAIL); - break; - } /* end switch */ - - /* Start "raw data" read timer */ - io_time_set(res->timers, HDF5_RAW_READ_FIXED_DIMS, TSTART); - hrc = dset_read(rank-1, fd, parms, buffer, buffer2); - - if (hrc < 0) { - HDfprintf(stderr, "Error in dataset read\n"); - GOTOERROR(FAIL); - } - - /* Stop "raw data" read timer */ - io_time_set(res->timers, HDF5_RAW_READ_FIXED_DIMS, TSTOP); - - /* Calculate read time */ - - /* Close dataset. Only HDF5 needs to do an explicit close. */ - if (parms->io_type == HDF5) { - hrc = H5Dclose(h5ds_id); - - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Dataset Close failed\n"); - GOTOERROR(FAIL); - } - - h5ds_id = -1; - } /* end if */ - -done: - - /* release HDF5 objects */ - if (h5dset_space_id != -1) { - hrc = H5Sclose(h5dset_space_id); - if (hrc < 0){ - HDfprintf(stderr, "HDF5 Dataset Space Close failed\n"); - ret_code = FAIL; - } else { - h5dset_space_id = -1; - } - } - - if (h5mem_space_id != -1) { - hrc = H5Sclose(h5mem_space_id); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Memory Space Close failed\n"); - ret_code = FAIL; - } else { - h5mem_space_id = -1; - } - } - - if (h5dxpl != -1) { - hrc = H5Pclose(h5dxpl); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Dataset Transfer Property List Close failed\n"); - ret_code = FAIL; - } else { - h5dxpl = -1; - } - } - - /* release generic resources */ - if(buffer2) - free(buffer2); - - return ret_code; -} - -/* - * Function: dset_read - * Purpose: Read buffer into the dataset. - * Return: SUCCESS or FAIL - * Programmer: Christian Chilan, April, 2008 - * Modifications: - */ - -static herr_t -dset_read(int local_dim, file_descr *fd, parameters *parms, void *buffer, - const char *buffer2) -{ - int cur_dim = order[local_dim]-1; - hsize_t i; - int j; - herr_t hrc; - int ret_code = SUCCESS; - - /* iterate on the current dimension */ - for (i=0; i < parms->dset_size[cur_dim]; i += parms->buf_size[cur_dim]){ - - h5offset[cur_dim] = (hssize_t)i; - offset[cur_dim] = (HDoff_t)i; - - /* if traverse in order array is incomplete, recurse */ - if (local_dim > 0){ - - ret_code = dset_read(local_dim-1, fd, parms, buffer, buffer2); - - /* otherwise, write buffer into dataset */ - }else{ - - switch (parms->io_type) { - - case POSIXIO: - for (j=0; j<parms->rank; j++) { - buf_offset[j] = 0; - } - buf_p = (unsigned char*)buffer; - posix_buffer_read(0, fd, parms, buffer); - break; - - case HDF5: - hrc = H5Soffset_simple(h5dset_space_id, h5offset); - VRFY((hrc >= 0), "H5Soffset_simple"); - /* Read the buffer out */ - hrc = H5Dread(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, - h5dset_space_id, h5dxpl, buffer); - VRFY((hrc >= 0), "H5Dread"); - break; - - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); - HDassert(0 && "Unknown IO type"); - break; - } /* switch (parms->io_type) */ - } - } -done: - return ret_code; -} - -/* - * Function: posix_buffer_read - * Purpose: Read buffer into the POSIX file considering contiguity. - * Return: SUCCESS or FAIL - * Programmer: Christian Chilan, April, 2008 - * Modifications: - */ - -static herr_t -posix_buffer_read(int local_dim, file_descr *fd, parameters *parms, void *buffer) -{ - int ret_code = SUCCESS; - - /* if local dimension is not contiguous, recurse */ - if (local_dim < parms->rank-1 && local_dim != cont_dim) { - size_t u; - - for(u = 0; u < parms->buf_size[local_dim]; u++) { - buf_offset[local_dim] = u; - ret_code = posix_buffer_read(local_dim+1, fd, parms, buffer); - if (local_dim+1==cont_dim) - break; - } - /* otherwise, perform contiguous POSIX access */ - } else { - HDoff_t d_offset; - HDoff_t linear_dset_offset = 0; - int i, j, rc; - - buf_offset[local_dim] = 0; - /* determine offset in buffer */ - for (i=0; i<parms->rank; i++){ - d_offset=1; - - for (j=i+1; j<parms->rank; j++) - d_offset *= (HDoff_t)parms->dset_size[j]; - - linear_dset_offset += (offset[i] + (HDoff_t)buf_offset[i]) * d_offset; - } - - /* only care if seek returns error */ - rc = POSIXSEEK(fd->posixfd, linear_dset_offset) < 0 ? -1 : 0; - VRFY((rc==0), "POSIXSEEK"); - /* check if all bytes are read */ - rc = ((ssize_t)cont_size == - POSIXREAD(fd->posixfd, buf_p, cont_size)); - VRFY((rc != 0), "POSIXREAD"); - - /* Advance location in buffer */ - buf_p += cont_size; - - } -done: - return ret_code; -} - - -/* - * Function: do_fopen - * Purpose: Open the specified file. - * Return: SUCCESS or FAIL - * Programmer: Albert Cheng, Bill Wendling, 2001/12/13 - * Modifications: Support for file drivers, Christian Chilan, April, 2008 - */ - static herr_t -do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, int flags) -{ - int ret_code = SUCCESS; - hid_t fcpl; - - switch (param->io_type) { - case POSIXIO: - if (flags & (SIO_CREATE | SIO_WRITE)) - fd->posixfd = POSIXCREATE(fname); - else - fd->posixfd = POSIXOPEN(fname, O_RDONLY); - - if (fd->posixfd < 0 ) { - HDfprintf(stderr, "POSIX File Open failed(%s)\n", fname); - GOTOERROR(FAIL); - } - - break; - - case HDF5: - - fapl = set_vfd(param); - - if (fapl < 0) { - HDfprintf(stderr, "HDF5 Property List Create failed\n"); - GOTOERROR(FAIL); - } - - fcpl = H5Pcreate(H5P_FILE_CREATE); - if(param->page_size) { - H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, (hsize_t)1); - H5Pset_file_space_page_size(fcpl, param->page_size); - if(param->page_buffer_size) - H5Pset_page_buffer_size(fapl, param->page_buffer_size, 0, 0); - } - - /* create the parallel file */ - if (flags & (SIO_CREATE | SIO_WRITE)) { - fd->h5fd = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl); - } else { - fd->h5fd = H5Fopen(fname, H5F_ACC_RDONLY, fapl); - } - - - if (fd->h5fd < 0) { - HDfprintf(stderr, "HDF5 File Create failed(%s)\n", fname); - GOTOERROR(FAIL); - } - break; - - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)param->io_type); - GOTOERROR(FAIL); - break; - } - -done: - return ret_code; -} - -/* - * Function: set_vfd - * Purpose: Sets file driver. - * Return: SUCCESS or FAIL - * Programmer: Christian Chilan, April, 2008 - * Modifications: - */ - -hid_t -set_vfd(parameters *param) -{ - hid_t my_fapl = -1; - vfdtype vfd; - - vfd = param->vfd; - - if ((my_fapl=H5Pcreate(H5P_FILE_ACCESS))<0) return -1; - - if (vfd == sec2) { - /* Unix read() and write() system calls */ - if (H5Pset_fapl_sec2(my_fapl)<0) return -1; - } else if (vfd == stdio) { - /* Standard C fread() and fwrite() system calls */ - if (H5Pset_fapl_stdio(my_fapl)<0) return -1; - } else if (vfd == core) { - /* In-core temporary file with 1MB increment */ - if (H5Pset_fapl_core(my_fapl, (size_t)1024*1024, TRUE)<0) return -1; - } else if (vfd == split) { - /* Split meta data and raw data each using default driver */ - if (H5Pset_fapl_split(my_fapl, - "-m.h5", H5P_DEFAULT, - "-r.h5", H5P_DEFAULT)<0) - return -1; - } else if (vfd == multi) { - /* Multi-file driver, general case of the split driver */ - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; - const char *memb_name[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][1024]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - H5FD_mem_t mt; - - HDmemset(memb_map, 0, sizeof memb_map); - HDmemset(memb_fapl, 0, sizeof memb_fapl); - HDmemset(memb_name, 0, sizeof memb_name); - HDmemset(memb_addr, 0, sizeof memb_addr); - - HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); - for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { - memb_fapl[mt] = H5P_DEFAULT; - HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); - memb_name[mt] = sv[mt]; - memb_addr[mt] = (haddr_t)MAX(mt - 1,0) * (HADDR_MAX / 10); - } - - if (H5Pset_fapl_multi(my_fapl, memb_map, memb_fapl, memb_name, - memb_addr, FALSE)<0) { - return -1; - } - } else if (vfd == family) { - hsize_t fam_size = 1*1024*1024; /*100 MB*/ - - /* Family of files, each 1MB and using the default driver */ - /* if ((val=HDstrtok(NULL, " \t\n\r"))) - fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); */ - if (H5Pset_fapl_family(my_fapl, fam_size, H5P_DEFAULT)<0) - return -1; - } else if (vfd == direct) { -#ifdef H5_HAVE_DIRECT - /* Linux direct read() and write() system calls. Set memory boundary, file block size, - * and copy buffer size to the default values. */ - if (H5Pset_fapl_direct(my_fapl, 1024, 4096, 8*4096)<0) return -1; -#endif - } else { - /* Unknown driver */ - return -1; - } - - return my_fapl; -} - -/* - * Function: do_fclose - * Purpose: Close the specified file descriptor. - * Return: SUCCESS or FAIL - * Programmer: Albert Cheng, Bill Wendling, 2001/12/13 - * Modifications: - */ - static herr_t -do_fclose(iotype iot, file_descr *fd /*out*/) -{ - herr_t ret_code = SUCCESS, hrc; - int rc = 0; - - switch (iot) { - case POSIXIO: - rc = POSIXCLOSE(fd->posixfd); - - if (rc != 0){ - HDfprintf(stderr, "POSIX File Close failed\n"); - GOTOERROR(FAIL); - } - - fd->posixfd = -1; - break; - - case HDF5: - hrc = H5Fclose(fd->h5fd); - - if (hrc < 0) { - HDfprintf(stderr, "HDF5 File Close failed\n"); - GOTOERROR(FAIL); - } - - fd->h5fd = -1; - break; - - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot); - GOTOERROR(FAIL); - break; - } - -done: - return ret_code; -} - - -/* - * Function: do_cleanupfile - * Purpose: Cleanup temporary file unless HDF5_NOCLEANUP is set. - * Return: void - * Programmer: Albert Cheng 2001/12/12 - * Modifications: Support for file drivers. Christian Chilan, April, 2008 - */ -/* Disable warning for "format not a string literal" here -QAK */ -/* - * This pragma only needs to surround the snprintf() calls with - * 'temp' in the code below, but early (4.4.7, at least) gcc only - * allows diagnostic pragmas to be toggled outside of functions. - */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat-nonliteral" -static void -do_cleanupfile(iotype iot, char *filename) -{ - char temp[2048]; - int j; - hid_t driver; - - if (clean_file_g == -1) - clean_file_g = (HDgetenv("HDF5_NOCLEANUP")==NULL) ? 1 : 0; - - if (clean_file_g){ - - switch (iot) { - case POSIXIO: - HDremove(filename); - break; - - case HDF5: - driver = H5Pget_driver(fapl); - - if (driver == H5FD_FAMILY) { - for (j = 0; /*void*/; j++) { - HDsnprintf(temp, sizeof temp, filename, j); - - if (HDaccess(temp, F_OK) < 0) - break; - - HDremove(temp); - } - } else if (driver == H5FD_CORE) { - hbool_t backing; /* Whether the core file has backing store */ - - H5Pget_fapl_core(fapl,NULL,&backing); - - /* If the file was stored to disk with bacing store, remove it */ - if(backing) - HDremove(filename); - - } else if (driver == H5FD_MULTI) { - H5FD_mem_t mt; - assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); - - for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { - HDsnprintf(temp, sizeof temp, "%s-%c.h5", - filename, multi_letters[mt]); - HDremove(temp); /*don't care if it fails*/ - } - } else { - HDremove(filename); - } - H5Pclose(fapl); - break; - - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot); - HDassert(0 && "Unknown IO type"); - break; - } - } -} -#pragma GCC diagnostic pop - diff --git a/tools/test/perform/sio_perf.c b/tools/test/perform/sio_perf.c deleted file mode 100644 index a56558e..0000000 --- a/tools/test/perform/sio_perf.c +++ /dev/null @@ -1,1428 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * 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://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Serial HDF5 Performance Testing Code - * -------------------------------------- - * - * Portable code to test performance on the different platforms we support. - * This is what the report should look like: - * - * nprocs = Max#Procs - * IO API = POSIXIO - * # Files = 1, # of dsets = 1000, Elements per dset = 37000 - * Write Results = x MB/s - * Read Results = x MB/s - * # Files = 1, # of dsets = 3000, Elements per dset = 37000 - * Write Results = x MB/s - * Read Results = x MB/s - * - * . . . - * - * - * IO API = HDF5 - * # Files = 1, # of dsets = 1000, Elements per dset = 37000 - * Write Results = x MB/s - * Read Results = x MB/s - * # Files = 1, # of dsets = 3000, Elements per dset = 37000 - * Write Results = x MB/s - * Read Results = x MB/s - * - * . . . - * - * - * . . . - * - */ - -/* system header files */ -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> - -#include "hdf5.h" - - -/* our header files */ -#include "sio_perf.h" - -/* useful macros */ -#define TAB_SPACE 4 - -#define ONE_KB 1024 -#define ONE_MB (ONE_KB * ONE_KB) -#define ONE_GB (ONE_MB * ONE_KB) - -#define SIO_POSIX 0x1 -#define SIO_HDF5 0x4 - -/* report 0.0 in case t is zero too */ -#define MB_PER_SEC(bytes,t) (H5_DBL_ABS_EQUAL(t, (double)0.0F) ? (double)0.0F : ((((double)bytes) / (double)ONE_MB) / (t))) - -#ifndef TRUE -#define TRUE 1 -#endif /* TRUE */ -#ifndef FALSE -#define FALSE (!TRUE) -#endif /* FALSE */ - -/* global variables */ -FILE *output; /* output file */ -int sio_debug_level = 0;/* The debug level: - * 0 - Off - * 1 - Minimal - * 2 - Some more - * 3 - Maximal - * 4 - Maximal & then some - */ - -/* local variables */ -static const char *progname = "h5perf_serial"; - -/* - * Command-line options: The user can specify short or long-named - * parameters. The long-named ones can be partially spelled. When - * adding more, make sure that they don't clash with each other. - */ - -/* - * It seems that only the options that accept additional information - * such as dataset size (-e) require the colon next to it. - */ -static const char *s_opts = "a:A:B:c:Cd:D:e:F:ghi:Imno:p:P:r:stT:v:wx:X:"; -static struct long_options l_opts[] = { - { "align", require_arg, 'a' }, - { "alig", require_arg, 'a' }, - { "ali", require_arg, 'a' }, - { "al", require_arg, 'a' }, - { "api", require_arg, 'A' }, - { "ap", require_arg, 'A' }, -#if 0 - /* a sighting of the elusive binary option */ - { "binary", no_arg, 'b' }, - { "binar", no_arg, 'b' }, - { "bina", no_arg, 'b' }, - { "bin", no_arg, 'b' }, - { "bi", no_arg, 'b' }, -#endif /* 0 */ - { "block-size", require_arg, 'B' }, - { "block-siz", require_arg, 'B' }, - { "block-si", require_arg, 'B' }, - { "block-s", require_arg, 'B' }, - { "block-", require_arg, 'B' }, - { "block", require_arg, 'B' }, - { "bloc", require_arg, 'B' }, - { "blo", require_arg, 'B' }, - { "bl", require_arg, 'B' }, - { "chunk", no_arg, 'c' }, - { "chun", no_arg, 'c' }, - { "chu", no_arg, 'c' }, - { "ch", no_arg, 'c' }, - { "collective", no_arg, 'C' }, - { "collectiv", no_arg, 'C' }, - { "collecti", no_arg, 'C' }, - { "collect", no_arg, 'C' }, - { "collec", no_arg, 'C' }, - { "colle", no_arg, 'C' }, - { "coll", no_arg, 'C' }, - { "col", no_arg, 'C' }, - { "co", no_arg, 'C' }, - { "debug", require_arg, 'D' }, - { "debu", require_arg, 'D' }, - { "deb", require_arg, 'D' }, - { "de", require_arg, 'D' }, - { "file-driver", require_arg, 'v' }, - { "file-drive", require_arg, 'v' }, - { "file-driv", require_arg, 'v' }, - { "file-dri", require_arg, 'v' }, - { "file-dr", require_arg, 'v' }, - { "file-d", require_arg, 'v' }, - { "file-", require_arg, 'v' }, - { "file", require_arg, 'v' }, - { "fil", require_arg, 'v' }, - { "fi", require_arg, 'v' }, - { "geometry", no_arg, 'g' }, - { "geometr", no_arg, 'g' }, - { "geomet", no_arg, 'g' }, - { "geome", no_arg, 'g' }, - { "geom", no_arg, 'g' }, - { "geo", no_arg, 'g' }, - { "ge", no_arg, 'g' }, - { "help", no_arg, 'h' }, - { "hel", no_arg, 'h' }, - { "he", no_arg, 'h' }, - { "interleaved", require_arg, 'I' }, - { "interleave", require_arg, 'I' }, - { "interleav", require_arg, 'I' }, - { "interlea", require_arg, 'I' }, - { "interle", require_arg, 'I' }, - { "interl", require_arg, 'I' }, - { "inter", require_arg, 'I' }, - { "inte", require_arg, 'I' }, - { "int", require_arg, 'I' }, - { "in", require_arg, 'I' }, - { "max-num-processes", require_arg, 'P' }, - { "max-num-processe", require_arg, 'P' }, - { "max-num-process", require_arg, 'P' }, - { "max-num-proces", require_arg, 'P' }, - { "max-num-proce", require_arg, 'P' }, - { "max-num-proc", require_arg, 'P' }, - { "max-num-pro", require_arg, 'P' }, - { "max-num-pr", require_arg, 'P' }, - { "max-num-p", require_arg, 'P' }, - { "min-num-processes", require_arg, 'p' }, - { "min-num-processe", require_arg, 'p' }, - { "min-num-process", require_arg, 'p' }, - { "min-num-proces", require_arg, 'p' }, - { "min-num-proce", require_arg, 'p' }, - { "min-num-proc", require_arg, 'p' }, - { "min-num-pro", require_arg, 'p' }, - { "min-num-pr", require_arg, 'p' }, - { "min-num-p", require_arg, 'p' }, - { "max-xfer-size", require_arg, 'X' }, - { "max-xfer-siz", require_arg, 'X' }, - { "max-xfer-si", require_arg, 'X' }, - { "max-xfer-s", require_arg, 'X' }, - { "max-xfer", require_arg, 'X' }, - { "max-xfe", require_arg, 'X' }, - { "max-xf", require_arg, 'X' }, - { "max-x", require_arg, 'X' }, - { "min-xfer-size", require_arg, 'x' }, - { "min-xfer-siz", require_arg, 'x' }, - { "min-xfer-si", require_arg, 'x' }, - { "min-xfer-s", require_arg, 'x' }, - { "min-xfer", require_arg, 'x' }, - { "min-xfe", require_arg, 'x' }, - { "min-xf", require_arg, 'x' }, - { "min-x", require_arg, 'x' }, - { "num-bytes", require_arg, 'e' }, - { "num-byte", require_arg, 'e' }, - { "num-byt", require_arg, 'e' }, - { "num-by", require_arg, 'e' }, - { "num-b", require_arg, 'e' }, - { "num-dsets", require_arg, 'd' }, - { "num-dset", require_arg, 'd' }, - { "num-dse", require_arg, 'd' }, - { "num-ds", require_arg, 'd' }, - { "num-d", require_arg, 'd' }, - { "num-files", require_arg, 'F' }, - { "num-file", require_arg, 'F' }, - { "num-fil", require_arg, 'F' }, - { "num-fi", require_arg, 'F' }, - { "num-f", require_arg, 'F' }, - { "num-iterations", require_arg, 'i' }, - { "num-iteration", require_arg, 'i' }, - { "num-iteratio", require_arg, 'i' }, - { "num-iterati", require_arg, 'i' }, - { "num-iterat", require_arg, 'i' }, - { "num-itera", require_arg, 'i' }, - { "num-iter", require_arg, 'i' }, - { "num-ite", require_arg, 'i' }, - { "num-it", require_arg, 'i' }, - { "num-i", require_arg, 'i' }, - { "order", require_arg, 'r' }, - { "orde", require_arg, 'r' }, - { "ord", require_arg, 'r' }, - { "or", require_arg, 'r' }, - { "output", require_arg, 'o' }, - { "outpu", require_arg, 'o' }, - { "outp", require_arg, 'o' }, - { "out", require_arg, 'o' }, - { "ou", require_arg, 'o' }, - { "extendable", no_arg, 't' }, - { "extendabl", no_arg, 't' }, - { "extendab", no_arg, 't' }, - { "extenda", no_arg, 't' }, - { "extend", no_arg, 't' }, - { "exten", no_arg, 't' }, - { "exte", no_arg, 't' }, - { "ext", no_arg, 't' }, - { "ex", no_arg, 't' }, - { "threshold", require_arg, 'T' }, - { "threshol", require_arg, 'T' }, - { "thresho", require_arg, 'T' }, - { "thresh", require_arg, 'T' }, - { "thres", require_arg, 'T' }, - { "thre", require_arg, 'T' }, - { "thr", require_arg, 'T' }, - { "th", require_arg, 'T' }, - { "write-only", require_arg, 'w' }, - { "write-onl", require_arg, 'w' }, - { "write-on", require_arg, 'w' }, - { "write-o", require_arg, 'w' }, - { "write", require_arg, 'w' }, - { "writ", require_arg, 'w' }, - { "wri", require_arg, 'w' }, - { "wr", require_arg, 'w' }, - { NULL, 0, '\0' } -}; - -struct options { - long io_types; /* bitmask of which I/O types to test */ - const char *output_file; /* file to print report to */ - long num_dsets; /* number of datasets */ - long num_files; /* number of files */ - off_t num_bpp; /* number of bytes per proc per dset */ - int num_iters; /* number of iterations */ - hsize_t dset_size[MAX_DIMS]; /* Dataset size */ - size_t buf_size[MAX_DIMS]; /* Buffer size */ - size_t chk_size[MAX_DIMS]; /* Chunk size */ - int order[MAX_DIMS]; /* Dimension access order */ - int dset_rank; /* Rank */ - int buf_rank; /* Rank */ - int order_rank; /* Rank */ - int chk_rank; /* Rank */ - int print_times; /* print times as well as throughputs */ - int print_raw; /* print raw data throughput info */ - hsize_t h5_alignment; /* alignment in HDF5 file */ - hsize_t h5_threshold; /* threshold for alignment in HDF5 file */ - int h5_use_chunks; /* Make HDF5 dataset chunked */ - int h5_write_only; /* Perform the write tests only */ - int h5_extendable; /* Perform the write tests only */ - int verify; /* Verify data correctness */ - vfdtype vfd; /* File driver */ - size_t page_buffer_size; - size_t page_size; -}; - -typedef struct _minmax { - double min; - double max; - double sum; - int num; -} minmax; - -/* local functions */ -static hsize_t parse_size_directive(const char *size); -static struct options *parse_command_line(int argc, char *argv[]); -static void run_test_loop(struct options *options); -static int run_test(iotype iot, parameters parms, struct options *opts); -static void output_all_info(minmax *mm, int count, int indent_level); -static void get_minmax(minmax *mm, double val); -static void accumulate_minmax_stuff(const minmax *mm, int count, minmax *total_mm); -static void output_results(const struct options *options, const char *name, - minmax *table, int table_size, off_t data_size); -static void output_report(const char *fmt, ...); -static void print_indent(register int indent); -static void usage(const char *prog); -static void report_parameters(struct options *opts); - -/* - * Function: main - * Purpose: Start things up. - * Return: EXIT_SUCCESS or EXIT_FAILURE - * Programmer: Bill Wendling, 30. October 2001 - * Modifications: - */ -int -main(int argc, char **argv) -{ - int exit_value = EXIT_SUCCESS; - struct options *opts = NULL; - -#ifndef STANDALONE - /* Initialize h5tools lib */ - h5tools_init(); -#endif - - output = stdout; - - opts = parse_command_line(argc, argv); - - if (!opts) { - exit_value = EXIT_FAILURE; - goto finish; - } - - if (opts->output_file) { - if ((output = HDfopen(opts->output_file, "w")) == NULL) { - HDfprintf(stderr, "%s: cannot open output file\n", progname); - HDperror(opts->output_file); - goto finish; - } - } - - report_parameters(opts); - - run_test_loop(opts); - -finish: - HDfree(opts); - return exit_value; -} - -/* - * Function: run_test_loop - * Purpose: Run the I/O tests. Write the results to OUTPUT. - * - * - The slowest changing part of the test is the number of - * processors to use. For each loop iteration, we divide that - * number by 2 and rerun the test. - * - * - The second slowest is what type of IO API to perform. We have - * three choices: POSIXIO, and HDF5. - * - * - Then we change the size of the buffer. This information is - * inferred from the number of datasets to create and the number - * of integers to put into each dataset. The backend code figures - * this out. - * - * Return: Nothing - * Programmer: Bill Wendling, 30. October 2001 - * Modifications: - * Added multidimensional testing (Christian Chilan, April, 2008) - */ -static void -run_test_loop(struct options *opts) -{ - parameters parms; - int i; - size_t buf_bytes; - - /* load options into parameter structure */ - parms.num_files = opts->num_files; - parms.num_dsets = opts->num_dsets; - parms.num_iters = opts->num_iters; - parms.rank = opts->dset_rank; - parms.h5_align = opts->h5_alignment; - parms.h5_thresh = opts->h5_threshold; - parms.h5_use_chunks = opts->h5_use_chunks; - parms.h5_extendable = opts->h5_extendable; - parms.h5_write_only = opts->h5_write_only; - parms.verify = opts->verify; - parms.vfd = opts->vfd; - parms.page_buffer_size = opts->page_buffer_size; - parms.page_size = opts->page_size; - - /* load multidimensional options */ - parms.num_bytes = 1; - buf_bytes = 1; - for (i=0; i<parms.rank; i++){ - parms.buf_size[i] = opts->buf_size[i]; - parms.dset_size[i] = opts->dset_size[i]; - parms.chk_size[i] = opts->chk_size[i]; - parms.order[i] = opts->order[i]; - parms.num_bytes *= opts->dset_size[i]; - buf_bytes *= opts->buf_size[i]; - } - - /* print size information */ - output_report("Transfer Buffer Size (bytes): %d\n", buf_bytes); - output_report("File Size(MB): %.2f\n",((double)parms.num_bytes) / ONE_MB); - - print_indent(0); - if (opts->io_types & SIO_POSIX) - run_test(POSIXIO, parms, opts); - - print_indent(0); - if (opts->io_types & SIO_HDF5) - run_test(HDF5, parms, opts); -} - -/* - * Function: run_test - * Purpose: Inner loop call to actually run the I/O test. - * Return: Nothing - * Programmer: Bill Wendling, 18. December 2001 - * Modifications: - */ -static int -run_test(iotype iot, parameters parms, struct options *opts) -{ - results res; - register int i, ret_value = SUCCESS; - off_t raw_size; - minmax *write_sys_mm_table=NULL; - minmax *write_mm_table=NULL; - minmax *write_gross_mm_table=NULL; - minmax *write_raw_mm_table=NULL; - minmax *read_sys_mm_table=NULL; - minmax *read_mm_table=NULL; - minmax *read_gross_mm_table=NULL; - minmax *read_raw_mm_table=NULL; - minmax write_sys_mm = {0.0F, 0.0F, 0.0F, 0}; - minmax write_mm = {0.0F, 0.0F, 0.0F, 0}; - minmax write_gross_mm = {0.0F, 0.0F, 0.0F, 0}; - minmax write_raw_mm = {0.0F, 0.0F, 0.0F, 0}; - minmax read_sys_mm = {0.0F, 0.0F, 0.0F, 0}; - minmax read_mm = {0.0F, 0.0F, 0.0F, 0}; - minmax read_gross_mm = {0.0F, 0.0F, 0.0F, 0}; - minmax read_raw_mm = {0.0F, 0.0F, 0.0F, 0}; - - raw_size = (off_t)parms.num_bytes; - parms.io_type = iot; - print_indent(2); - output_report("IO API = "); - - switch (iot) { - case POSIXIO: - output_report("POSIX\n"); - break; - case HDF5: - output_report("HDF5\n"); - break; - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot); - HDassert(0 && "Unknown IO tpe"); - break; - } - - /* allocate space for tables minmax and that it is sufficient */ - /* to initialize all elements to zeros by calloc. */ - write_sys_mm_table = (minmax *)calloc((size_t)parms.num_iters , sizeof(minmax)); - write_mm_table = (minmax *)calloc((size_t)parms.num_iters , sizeof(minmax)); - write_gross_mm_table = (minmax *)calloc((size_t)parms.num_iters , sizeof(minmax)); - write_raw_mm_table = (minmax *)calloc((size_t)parms.num_iters , sizeof(minmax)); - - if (!parms.h5_write_only) { - read_sys_mm_table = (minmax *)calloc((size_t)parms.num_iters , sizeof(minmax)); - read_mm_table = (minmax *)calloc((size_t)parms.num_iters , sizeof(minmax)); - read_gross_mm_table = (minmax *)calloc((size_t)parms.num_iters , sizeof(minmax)); - read_raw_mm_table = (minmax *)calloc((size_t)parms.num_iters , sizeof(minmax)); - } - - /* Do IO iteration times, collecting statistics each time */ - for (i = 0; i < parms.num_iters; ++i) { - double t; - - do_sio(parms, &res); - - /* gather all of the "sys write" times */ - t = io_time_get(res.timers, HDF5_MPI_WRITE); - get_minmax(&write_sys_mm, t); - - write_sys_mm_table[i] = write_sys_mm; - - /* gather all of the "write" times */ - t = io_time_get(res.timers, HDF5_FINE_WRITE_FIXED_DIMS); - get_minmax(&write_mm, t); - - write_mm_table[i] = write_mm; - - /* gather all of the "write" times from open to close */ - t = io_time_get(res.timers, HDF5_GROSS_WRITE_FIXED_DIMS); - get_minmax(&write_gross_mm, t); - - write_gross_mm_table[i] = write_gross_mm; - - /* gather all of the raw "write" times */ - t = io_time_get(res.timers, HDF5_RAW_WRITE_FIXED_DIMS); - get_minmax(&write_raw_mm, t); - - write_raw_mm_table[i] = write_raw_mm; - - if (!parms.h5_write_only) { - /* gather all of the "mpi read" times */ - t = io_time_get(res.timers, HDF5_MPI_READ); - get_minmax(&read_sys_mm, t); - - read_sys_mm_table[i] = read_sys_mm; - - /* gather all of the "read" times */ - t = io_time_get(res.timers, HDF5_FINE_READ_FIXED_DIMS); - get_minmax(&read_mm, t); - - read_mm_table[i] = read_mm; - - /* gather all of the "read" times from open to close */ - t = io_time_get(res.timers, HDF5_GROSS_READ_FIXED_DIMS); - get_minmax(&read_gross_mm, t); - - read_gross_mm_table[i] = read_gross_mm; - - /* gather all of the raw "read" times */ - t = io_time_get(res.timers, HDF5_RAW_READ_FIXED_DIMS); - get_minmax(&read_raw_mm, t); - - read_raw_mm_table[i] = read_gross_mm; - } - io_time_destroy(res.timers); - } - - /* - * Show various statistics - */ - /* Write statistics */ - /* Print the raw data throughput if desired */ - if (opts->print_raw) { - /* accumulate and output the max, min, and average "raw write" times */ - if (sio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Raw Data Write details:\n"); - output_all_info(write_raw_mm_table, parms.num_iters, 4); - } - - output_results(opts,"Raw Data Write",write_raw_mm_table,parms.num_iters,raw_size); - } /* end if */ - - /* show sys write statics */ -#if 0 - if (sio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("MPI Write details:\n"); - output_all_info(write_sys_mm_table, parms.num_iters, 4); - } -#endif - /* We don't currently output the MPI write results */ - - /* accumulate and output the max, min, and average "write" times */ - if (sio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Write details:\n"); - output_all_info(write_mm_table, parms.num_iters, 4); - } - - output_results(opts,"Write",write_mm_table,parms.num_iters,raw_size); - - /* accumulate and output the max, min, and average "gross write" times */ - if (sio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Write Open-Close details:\n"); - output_all_info(write_gross_mm_table, parms.num_iters, 4); - } - - output_results(opts,"Write Open-Close",write_gross_mm_table,parms.num_iters,raw_size); - - if (!parms.h5_write_only) { - /* Read statistics */ - /* Print the raw data throughput if desired */ - if (opts->print_raw) { - /* accumulate and output the max, min, and average "raw read" times */ - if (sio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Raw Data Read details:\n"); - output_all_info(read_raw_mm_table, parms.num_iters, 4); - } - - output_results(opts, "Raw Data Read", read_raw_mm_table, - parms.num_iters, raw_size); - } /* end if */ - - /* show mpi read statics */ -#if 0 - if (sio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("MPI Read details:\n"); - output_all_info(read_sys_mm_table, parms.num_iters, 4); - } -#endif - /* We don't currently output the MPI read results */ - - /* accumulate and output the max, min, and average "read" times */ - if (sio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Read details:\n"); - output_all_info(read_mm_table, parms.num_iters, 4); - } - - output_results(opts, "Read", read_mm_table, parms.num_iters, raw_size); - - /* accumulate and output the max, min, and average "gross read" times */ - if (sio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Read Open-Close details:\n"); - output_all_info(read_gross_mm_table, parms.num_iters, 4); - } - - output_results(opts, "Read Open-Close", read_gross_mm_table, - parms.num_iters, raw_size); - } - - /* clean up our mess */ - HDfree(write_sys_mm_table); - HDfree(write_mm_table); - HDfree(write_gross_mm_table); - HDfree(write_raw_mm_table); - - if (!parms.h5_write_only) { - HDfree(read_sys_mm_table); - HDfree(read_mm_table); - HDfree(read_gross_mm_table); - HDfree(read_raw_mm_table); - } - - return ret_value; -} - -/* - * Function: output_all_info - * Purpose: - * Return: Nothing - * Programmer: Bill Wendling, 29. January 2002 - * Modifications: - */ -static void -output_all_info(minmax *mm, int count, int indent_level) -{ - int i; - - for (i = 0; i < count; ++i) { - print_indent(indent_level); - output_report("Iteration %d:\n", i + 1); - print_indent(indent_level + 1); - output_report("Minimum Time: %.2fs\n", mm[i].min); - print_indent(indent_level + 1); - output_report("Maximum Time: %.2fs\n", mm[i].max); - } -} - -/* - * Function: get_minmax - * Purpose: Gather all the min, max and total of val. - * Return: Nothing - * Programmer: Bill Wendling, 21. December 2001 - * Modifications: - * Use MPI_Allreduce to do it. -akc, 2002/01/11 - */ - -static void -get_minmax(minmax *mm, double val) -{ - mm->max = val; - mm->min = val; - mm->sum = val; -} - -/* - * Function: accumulate_minmax_stuff - * Purpose: Accumulate the minimum, maximum, and average of the times - * across all processes. - * Return: TOTAL_MM - the total of all of these. - * Programmer: Bill Wendling, 21. December 2001 - * Modifications: - * Changed to use seconds instead of MB/s - QAK, 5/9/02 - */ -static void -accumulate_minmax_stuff(const minmax *mm, int count, minmax *total_mm) -{ - int i; - - total_mm->sum = 0.0F; - total_mm->max = -DBL_MAX; - total_mm->min = DBL_MAX; - total_mm->num = count; - - for (i = 0; i < count; ++i) { - double m = mm[i].max; - - total_mm->sum += m; - - if (m < total_mm->min) - total_mm->min = m; - - if (m > total_mm->max) - total_mm->max = m; - } -} - - -/* - * Function: output_results - * Purpose: Print information about the time & bandwidth for a given - * minmax & # of iterations. - * Return: Nothing - * Programmer: Quincey Koziol, 9. May 2002 - * Modifications: - */ -static void -output_results(const struct options *opts, const char *name, minmax *table, - int table_size,off_t data_size) -{ - minmax total_mm; - - accumulate_minmax_stuff(table, table_size, &total_mm); - - print_indent(3); - output_report("%s (%d iteration(s)):\n", name,table_size); - - /* Note: The maximum throughput uses the minimum amount of time & vice versa */ - - print_indent(4); - output_report("Maximum Throughput: %6.2f MB/s", MB_PER_SEC(data_size,total_mm.min)); - if(opts->print_times) - output_report(" (%7.3f s)\n", total_mm.min); - else - output_report("\n"); - - print_indent(4); - output_report("Average Throughput: %6.2f MB/s", - MB_PER_SEC(data_size,total_mm.sum / total_mm.num)); - if(opts->print_times) - output_report(" (%7.3f s)\n", (total_mm.sum / total_mm.num)); - else - output_report("\n"); - - print_indent(4); - output_report("Minimum Throughput: %6.2f MB/s", MB_PER_SEC(data_size,total_mm.max)); - if(opts->print_times) - output_report(" (%7.3f s)\n", total_mm.max); - else - output_report("\n"); -} - -/* - * Function: output_report - * Purpose: Print a line of the report. Only do so if I'm the 0 process. - * Return: Nothing - * Programmer: Bill Wendling, 19. December 2001 - * Modifications: - */ -static void -output_report(const char *fmt, ...) -{ - va_list ap; - - HDva_start(ap, fmt); - HDvfprintf(output, fmt, ap); - HDva_end(ap); -} - -/* - * Function: print_indent - * Purpose: Print spaces to indent a new line of text for pretty printing - * things. - * Return: Nothing - * Programmer: Bill Wendling, 29. October 2001 - * Modifications: - */ -static void -print_indent(register int indent) -{ - indent *= TAB_SPACE; - - for (; indent > 0; --indent) - HDfputc(' ', output); -} - -static void -recover_size_and_print(long long val, const char *end) -{ - if (val >= ONE_KB && (val % ONE_KB) == 0) { - if (val >= ONE_MB && (val % ONE_MB) == 0) { - if (val >= ONE_GB && (val % ONE_GB) == 0) - HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""GB%s", val / ONE_GB, end); - else - HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""MB%s", val / ONE_MB, end); - } else { - HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""KB%s", val / ONE_KB, end); - } - } else { - HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""%s", val, end); - } -} - -static void -print_io_api(long io_types) -{ - if (io_types & SIO_POSIX) - HDfprintf(output, "posix "); - if (io_types & SIO_HDF5) - HDfprintf(output, "hdf5 "); - HDfprintf(output, "\n"); -} - -static void -report_parameters(struct options *opts) -{ - int i, rank; - rank = opts->dset_rank; - - print_version("HDF5 Library"); /* print library version */ - HDfprintf(output, "==== Parameters ====\n"); - - HDfprintf(output, "IO API="); - print_io_api(opts->io_types); - - HDfprintf(output, "Number of iterations=%d\n", - opts->num_iters); - - HDfprintf(output, "Dataset size="); - - for (i=0; i<rank; i++) - recover_size_and_print((long long)opts->dset_size[i], " "); - HDfprintf(output, "\n"); - - - HDfprintf(output, "Transfer buffer size="); - for (i=0; i<rank; i++) - recover_size_and_print((long long)opts->buf_size[i], " "); - HDfprintf(output, "\n"); - - if(opts->page_size) { - HDfprintf(output, "Page Aggregation Enabled. Page size = %ld\n", opts->page_size); - if(opts->page_buffer_size) - HDfprintf(output, "Page Buffering Enabled. Page Buffer size = %ld\n", opts->page_buffer_size); - else - HDfprintf(output, "Page Buffering Disabled\n"); - } - else - HDfprintf(output, "Page Aggregation Disabled\n"); - - HDfprintf(output, "Dimension access order="); - for (i=0; i<rank; i++) - recover_size_and_print((long long)opts->order[i], " "); - HDfprintf(output, "\n"); - - if (opts->io_types & SIO_HDF5) { - - HDfprintf(output, "HDF5 data storage method="); - - if (opts->h5_use_chunks){ - - HDfprintf(output, "Chunked\n"); - HDfprintf(output, "HDF5 chunk size="); - for (i=0; i<rank; i++) - recover_size_and_print((long long)opts->chk_size[i], " "); - HDfprintf(output, "\n"); - - HDfprintf(output, "HDF5 dataset dimensions="); - if (opts->h5_extendable) { - HDfprintf(output, "Extendable\n"); - } - else { - HDfprintf(output, "Fixed\n"); - } - } - else { - HDfprintf(output, "Contiguous\n"); - } - - HDfprintf(output, "HDF5 file driver="); - if (opts->vfd==sec2) { - HDfprintf(output, "sec2\n"); - } else if (opts->vfd==stdio) { - HDfprintf(output, "stdio\n"); - } else if (opts->vfd==core) { - HDfprintf(output, "core\n"); - } else if (opts->vfd==split) { - HDfprintf(output, "split\n"); - } else if (opts->vfd==multi) { - HDfprintf(output, "multi\n"); - } else if (opts->vfd==family) { - HDfprintf(output, "family\n"); - } else if (opts->vfd==direct) { - HDfprintf(output, "direct\n"); - } - } - - { - char *prefix = HDgetenv("HDF5_PREFIX"); - - HDfprintf(output, "Env HDF5_PREFIX=%s\n", - (prefix ? prefix : "not set")); - } - - HDfprintf(output, "==== End of Parameters ====\n"); - HDfprintf(output, "\n"); -} - -/* - * Function: parse_command_line - * Purpose: Parse the command line options and return a STRUCT OPTIONS - * structure which will need to be freed by the calling function. - * Return: Pointer to an OPTIONS structure - * Programmer: Bill Wendling, 31. October 2001 - * Modifications: - * Added multidimensional testing (Christian Chilan, April, 2008) - */ -static struct options * -parse_command_line(int argc, char *argv[]) -{ - int opt; - struct options *cl_opts; - int i, default_rank, actual_rank, ranks[4]; - - cl_opts = (struct options *)HDmalloc(sizeof(struct options)); - - cl_opts->page_buffer_size = 0; - cl_opts->page_size = 0; - - cl_opts->output_file = NULL; - cl_opts->io_types = 0; /* will set default after parsing options */ - cl_opts->num_iters = 1; - - default_rank = 2; - - cl_opts->dset_rank = 0; - cl_opts->buf_rank = 0; - cl_opts->chk_rank = 0; - cl_opts->order_rank = 0; - - for(i = 0; i < MAX_DIMS; i++) { - cl_opts->buf_size[i] = (size_t)((i + 1) * 10); - cl_opts->dset_size[i] = (hsize_t)((i + 1) * 100); - cl_opts->chk_size[i] = (size_t)((i + 1) * 10); - cl_opts->order[i] = i + 1; - } - - cl_opts->vfd = sec2; - - cl_opts->print_times = FALSE; /* Printing times is off by default */ - cl_opts->print_raw = FALSE; /* Printing raw data throughput is off by default */ - cl_opts->h5_alignment = 1; /* No alignment for HDF5 objects by default */ - cl_opts->h5_threshold = 1; /* No threshold for aligning HDF5 objects by default */ - cl_opts->h5_use_chunks = FALSE; /* Don't chunk the HDF5 dataset by default */ - cl_opts->h5_write_only = FALSE; /* Do both read and write by default */ - cl_opts->h5_extendable = FALSE; /* Use extendable dataset */ - cl_opts->verify = FALSE; /* No Verify data correctness by default */ - - while ((opt = get_option(argc, (const char **)argv, s_opts, l_opts)) != EOF) { - switch ((char)opt) { - case 'a': - cl_opts->h5_alignment = parse_size_directive(opt_arg); - break; - case 'G': - cl_opts->page_size = parse_size_directive(opt_arg); - break; - case 'b': - cl_opts->page_buffer_size = parse_size_directive(opt_arg); - break; - case 'A': - { - const char *end = opt_arg; - while (end && *end != '\0') { - char buf[10]; - - HDmemset(buf, '\0', sizeof(buf)); - - for (i = 0; *end != '\0' && *end != ','; ++end) - if (HDisalnum(*end) && i < 10) - buf[i++] = *end; - - if (!HDstrcasecmp(buf, "hdf5")) { - cl_opts->io_types |= SIO_HDF5; - } else if (!HDstrcasecmp(buf, "posix")) { - cl_opts->io_types |= SIO_POSIX; - } else { - HDfprintf(stderr, "sio_perf: invalid --api option %s\n", - buf); - HDexit(EXIT_FAILURE); - } - - if (*end == '\0') - break; - - end++; - } - } - - break; -#if 0 - case 'b': - /* the future "binary" option */ - break; -#endif /* 0 */ - case 'c': - /* Turn on chunked HDF5 dataset creation */ - cl_opts->h5_use_chunks = 1; - { - const char *end = opt_arg; - int j = 0; - - while (end && *end != '\0') { - char buf[10]; - - HDmemset(buf, '\0', sizeof(buf)); - - for (i = 0; *end != '\0' && *end != ','; ++end) - if (HDisalnum(*end) && i < 10) - buf[i++] = *end; - - cl_opts->chk_size[j] = parse_size_directive(buf); - - j++; - - if (*end == '\0') - break; - - end++; - } - cl_opts->chk_rank = j; - } - - break; - - - case 'D': - { - const char *end = opt_arg; - - while (end && *end != '\0') { - char buf[10]; - - HDmemset(buf, '\0', sizeof(buf)); - - for (i = 0; *end != '\0' && *end != ','; ++end) - if (HDisalnum(*end) && i < 10) - buf[i++] = *end; - - if (HDstrlen(buf) > 1 || HDisdigit(buf[0])) { - size_t j; - - for (j = 0; j < 10 && buf[j] != '\0'; ++j) - if (!HDisdigit(buf[j])) { - HDfprintf(stderr, "sio_perf: invalid --debug option %s\n", - buf); - HDexit(EXIT_FAILURE); - } - - sio_debug_level = atoi(buf); - - if (sio_debug_level > 4) - sio_debug_level = 4; - else if (sio_debug_level < 0) - sio_debug_level = 0; - } else { - switch (*buf) { - case 'r': - /* Turn on raw data throughput info */ - cl_opts->print_raw = TRUE; - break; - case 't': - /* Turn on time printing */ - cl_opts->print_times = TRUE; - break; - case 'v': - /* Turn on verify data correctness*/ - cl_opts->verify = TRUE; - break; - default: - HDfprintf(stderr, "sio_perf: invalid --debug option %s\n", buf); - HDexit(EXIT_FAILURE); - } - } - - if (*end == '\0') - break; - - end++; - } - } - - break; - case 'e': - { - const char *end = opt_arg; - int j = 0; - - while (end && *end != '\0') { - char buf[10]; - - HDmemset(buf, '\0', sizeof(buf)); - - for (i = 0; *end != '\0' && *end != ','; ++end) - if (HDisalnum(*end) && i < 10) - buf[i++] = *end; - - cl_opts->dset_size[j] = parse_size_directive(buf); - - j++; - - if (*end == '\0') - break; - - end++; - } - cl_opts->dset_rank = j; - } - - break; - - case 'i': - cl_opts->num_iters = HDatoi(opt_arg); - break; - case 'o': - cl_opts->output_file = opt_arg; - break; - case 'T': - cl_opts->h5_threshold = parse_size_directive(opt_arg); - break; - case 'v': - if (!HDstrcasecmp(opt_arg, "sec2")) { - cl_opts->vfd=sec2; - } else if (!HDstrcasecmp(opt_arg, "stdio")) { - cl_opts->vfd=stdio; - } else if (!HDstrcasecmp(opt_arg, "core")) { - cl_opts->vfd=core; - } else if (!HDstrcasecmp(opt_arg, "split")) { - cl_opts->vfd=split; - } else if (!HDstrcasecmp(opt_arg, "multi")) { - cl_opts->vfd=multi; - } else if (!HDstrcasecmp(opt_arg, "family")) { - cl_opts->vfd=family; - } else if (!HDstrcasecmp(opt_arg, "direct")) { - cl_opts->vfd=direct; - } else { - HDfprintf(stderr, "sio_perf: invalid --api option %s\n", - opt_arg); - HDexit(EXIT_FAILURE); - } - break; - case 'w': - cl_opts->h5_write_only = TRUE; - break; - case 't': - cl_opts->h5_extendable = TRUE; - break; - case 'x': - { - const char *end = opt_arg; - int j = 0; - - while (end && *end != '\0') { - char buf[10]; - - HDmemset(buf, '\0', sizeof(buf)); - - for (i = 0; *end != '\0' && *end != ','; ++end) - if (HDisalnum(*end) && i < 10) - buf[i++] = *end; - - cl_opts->buf_size[j] = parse_size_directive(buf); - - j++; - - if (*end == '\0') - break; - - end++; - } - cl_opts->buf_rank = j; - } - - break; - - case 'r': - { - const char *end = opt_arg; - int j = 0; - - while (end && *end != '\0') { - char buf[10]; - - HDmemset(buf, '\0', sizeof(buf)); - - for (i = 0; *end != '\0' && *end != ','; ++end) - if (HDisalnum(*end) && i < 10) - buf[i++] = *end; - - cl_opts->order[j] = (int)parse_size_directive(buf); - - j++; - - if (*end == '\0') - break; - - end++; - } - - cl_opts->order_rank = j; - } - - break; - - case 'h': - case '?': - default: - usage(progname); - HDfree(cl_opts); - return NULL; - } - } - - /* perform rank consistency analysis */ - actual_rank = 0; - - ranks[0] = cl_opts->dset_rank; - ranks[1] = cl_opts->buf_rank; - ranks[2] = cl_opts->order_rank; - ranks[3] = cl_opts->chk_rank; - - for (i=0; i<4; i++) { - if (ranks[i]>0) { - if (!actual_rank) { - actual_rank = ranks[i]; - } - else { - if (actual_rank != ranks[i]) - exit(EXIT_FAILURE); - } - } - } - - if (!actual_rank) - actual_rank = default_rank; - - cl_opts->dset_rank = actual_rank; - cl_opts->buf_rank = actual_rank; - cl_opts->order_rank = actual_rank; - cl_opts->chk_rank = actual_rank; - - for (i=0; i<actual_rank; i++) { - if (cl_opts->order[i] > actual_rank) { - exit(EXIT_FAILURE); - } - } - - /* set default if none specified yet */ - if (!cl_opts->io_types) - cl_opts->io_types = SIO_HDF5 | SIO_POSIX; /* run all API */ - - /* verify parameters sanity. Adjust if needed. */ - /* cap xfer_size with bytes per process */ - if (cl_opts->num_iters <= 0) - cl_opts->num_iters = 1; - - return cl_opts; -} - -/* - * Function: parse_size_directive - * Purpose: Parse the size directive passed on the commandline. The size - * directive is an integer followed by a size indicator: - * - * K, k - Kilobyte - * M, m - Megabyte - * G, g - Gigabyte - * - * Return: The size as a off_t because this is related to file size. - * If an unknown size indicator is used, then the program will - * exit with EXIT_FAILURE as the return value. - * Programmer: Bill Wendling, 18. December 2001 - * Modifications: - */ - -static hsize_t -parse_size_directive(const char *size) -{ - hsize_t s; - char *endptr; - - s = HDstrtoull(size, &endptr, 10); - - if (endptr && *endptr) { - while (*endptr != '\0' && (*endptr == ' ' || *endptr == '\t')) - ++endptr; - - switch (*endptr) { - case 'K': - case 'k': - s *= ONE_KB; - break; - - case 'M': - case 'm': - s *= ONE_MB; - break; - - case 'G': - case 'g': - s *= ONE_GB; - break; - - default: - HDfprintf(stderr, "Illegal size specifier '%c'\n", *endptr); - HDexit(EXIT_FAILURE); - } - } - - return s; -} - -/* - * Function: usage - * Purpose: Print a usage message and then exit. - * Return: Nothing - * Programmer: Bill Wendling, 31. October 2001 - * Modifications: - */ -static void -usage(const char *prog) -{ - print_version(prog); - HDprintf("usage: %s [OPTIONS]\n", prog); - HDprintf(" OPTIONS\n"); - HDprintf(" -h Print an usage message and exit\n"); - HDprintf(" -A AL Which APIs to test\n"); - HDprintf(" [default: all of them]\n"); - HDprintf(" -c SL Selects chunked storage and defines chunks dimensions\n"); - HDprintf(" and sizes\n"); - HDprintf(" [default: Off]\n"); - HDprintf(" -e SL Dimensions and sizes of dataset\n"); - HDprintf(" [default: 100,200]\n"); - HDprintf(" -i N Number of iterations to perform\n"); - HDprintf(" [default: 1]\n"); - HDprintf(" -r NL Dimension access order (see below for description)\n"); - HDprintf(" [default: 1,2]\n"); - HDprintf(" -t Selects extendable dimensions for HDF5 dataset\n"); - HDprintf(" [default: Off]\n"); - HDprintf(" -v VFD Selects file driver for HDF5 access\n"); - HDprintf(" [default: sec2]\n"); - HDprintf(" -w Perform write tests, not the read tests\n"); - HDprintf(" [default: Off]\n"); - HDprintf(" -x SL Dimensions and sizes of the transfer buffer\n"); - HDprintf(" [default: 10,20]\n"); - HDprintf("\n"); - HDprintf(" N - is an integer > 0.\n"); - HDprintf("\n"); - HDprintf(" S - is a size specifier, an integer > 0 followed by a size indicator:\n"); - HDprintf(" K - Kilobyte (%d)\n", ONE_KB); - HDprintf(" M - Megabyte (%d)\n", ONE_MB); - HDprintf(" G - Gigabyte (%d)\n", ONE_GB); - HDprintf("\n"); - HDprintf(" Example: '37M' is 37 megabytes or %d bytes\n", 37*ONE_MB); - HDprintf("\n"); - HDprintf(" AL - is an API list. Valid values are:\n"); - HDprintf(" hdf5 - HDF5\n"); - HDprintf(" posix - POSIX\n"); - HDprintf("\n"); - HDprintf(" Example: -A posix,hdf5\n"); - HDprintf("\n"); - HDprintf(" NL - is list of integers (N) separated by commas.\n"); - HDprintf("\n"); - HDprintf(" Example: 1,2,3\n"); - HDprintf("\n"); - HDprintf(" SL - is list of size specifiers (S) separated by commas.\n"); - HDprintf("\n"); - HDprintf(" Example: 2K,2K,3K\n"); - HDprintf("\n"); - HDprintf(" The example defines an object (dataset, tranfer buffer) with three\n"); - HDprintf(" dimensions. Be aware that as the number of dimensions increases, the\n"); - HDprintf(" the total size of the object increases exponentially.\n"); - HDprintf("\n"); - HDprintf(" VFD - is an HDF5 file driver specifier. Valid values are:\n"); - HDprintf(" sec2, stdio, core, split, multi, family, direct\n"); - HDprintf("\n"); - HDprintf(" Dimension access order:\n"); - HDprintf(" Data access starts at the cardinal origin of the dataset using the\n"); - HDprintf(" transfer buffer. The next access occurs on a dataset region next to\n"); - HDprintf(" the previous one. For a multidimensional dataset, there are several\n"); - HDprintf(" directions as to where to proceed. This can be specified in the dimension\n"); - HDprintf(" access order. For example, -r 1,2 states that the tool should traverse\n"); - HDprintf(" dimension 1 first, and then dimension 2.\n"); - HDprintf("\n"); - HDprintf(" Environment variables:\n"); - HDprintf(" HDF5_NOCLEANUP Do not remove data files if set [default remove]\n"); - HDprintf(" HDF5_PREFIX Data file prefix\n"); - HDprintf("\n"); - HDfflush(stdout); -} /* end usage() */ - diff --git a/tools/test/perform/sio_perf.h b/tools/test/perform/sio_perf.h deleted file mode 100644 index 83caf54..0000000 --- a/tools/test/perform/sio_perf.h +++ /dev/null @@ -1,103 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * 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://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef SIO_PERF_H__ -#define SIO_PERF_H__ - -#include "io_timer.h" -#ifndef STANDALONE -#include "h5test.h" -#include "h5tools.h" -#include "h5tools_utils.h" -#else -#include "sio_standalone.h" -#endif - -/* setup the dataset no fill option if this is v1.5 or more */ -#if H5_VERS_MAJOR > 1 || H5_VERS_MINOR > 4 -#define H5_HAVE_NOFILL 1 -#endif - -#define MAX_DIMS 32 - -typedef enum iotype_ { - POSIXIO, - HDF5 - /*NUM_TYPES*/ -} iotype; - -typedef enum vfdtype_ { - sec2, - stdio, - core, - split, - multi, - family, - direct - /*NUM_TYPES*/ -} vfdtype; - -typedef struct parameters_ { - iotype io_type; /* The type of IO test to perform */ - vfdtype vfd; - long num_files; /* Number of files to create */ - long num_dsets; /* Number of datasets to create */ - hsize_t num_bytes; /* Number of bytes in each dset */ - int num_iters; /* Number of times to loop doing the IO */ - int rank; /* Rank of dataset */ - hsize_t dset_size[MAX_DIMS]; /* Dataset size */ - size_t buf_size[MAX_DIMS]; /* Buffer size */ - size_t chk_size[MAX_DIMS]; /* Chunk size */ - int order[MAX_DIMS]; /* Buffer size */ - hsize_t h5_align; /* HDF5 object alignment */ - hsize_t h5_thresh; /* HDF5 object alignment threshold */ - int h5_use_chunks; /* Make HDF5 dataset chunked */ - int h5_extendable; /* Make HDF5 dataset chunked */ - int h5_write_only; /* Perform the write tests only */ - int verify; /* Verify data correctness */ - size_t page_size; - size_t page_buffer_size; -} parameters; - -typedef struct results_ { - herr_t ret_code; - io_time_t *timers; -} results; - -#ifndef SUCCESS -#define SUCCESS 0 -#endif /* !SUCCESS */ - -#ifndef FAIL -#define FAIL -1 -#endif /* !FAIL */ - -extern FILE *output; /* output file */ -extern io_time_t *timer_g; /* timer: global for stub functions */ -extern int sio_debug_level; /* The debug level: - * 0 - Off - * 1 - Minimal - * 2 - Some more - * 3 - Maximal - * 4 - Even More Debugging (timer stuff) - */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -extern void do_sio(parameters param, results *res); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* PIO_PERF_H__ */ diff --git a/tools/test/perform/sio_standalone.c b/tools/test/perform/sio_standalone.c index ac191e5..353dad3 100644 --- a/tools/test/perform/sio_standalone.c +++ b/tools/test/perform/sio_standalone.c @@ -5,12 +5,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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /* This file contains the definition of functions required to build h5perf in * STANDALONE mode. * Created: Christian Chilan, 2005/5/18. @@ -18,38 +17,32 @@ #include "sio_perf.h" - /** From h5tools_utils.c **/ /* global variables */ -int nCols = 80; - -/* ``get_option'' variables */ -int opt_err = 1; /*get_option prints errors if this is on */ -int opt_ind = 1; /*token pointer */ -const char *opt_arg; /*flag argument (or value) */ - +int nCols = 80; int -get_option(int argc, const char **argv, const char *opts, const struct long_options *l_opts) +get_option(int argc, const char **argv, const char *opts, const struct h5_long_options *l_opts) { - static int sp = 1; /* character index in current token */ - int opt_opt = '?'; /* option character passed back to user */ + static int sp = 1; /* character index in current token */ + int opt_opt = '?'; /* option character passed back to user */ if (sp == 1) { /* check for more flag-like tokens */ - if (opt_ind >= argc || argv[opt_ind][0] != '-' || argv[opt_ind][1] == '\0') { + if (H5_optind >= argc || argv[H5_optind][0] != '-' || argv[H5_optind][1] == '\0') { return EOF; - } else if (HDstrcmp(argv[opt_ind], "--") == 0) { - opt_ind++; + } + else if (HDstrcmp(argv[H5_optind], "--") == 0) { + H5_optind++; return EOF; } } - if (sp == 1 && argv[opt_ind][0] == '-' && argv[opt_ind][1] == '-') { + if (sp == 1 && argv[H5_optind][0] == '-' && argv[H5_optind][1] == '-') { /* long command line option */ - const char *arg = &argv[opt_ind][2]; - int i; + const char *arg = &argv[H5_optind][2]; + int i; for (i = 0; l_opts && l_opts[i].name; i++) { size_t len = HDstrlen(l_opts[i].name); @@ -60,28 +53,27 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (l_opts[i].has_arg != no_arg) { if (arg[len] == '=') { - opt_arg = &arg[len + 1]; - } else if (opt_ind < (argc - 1) && argv[opt_ind + 1][0] != '-') { - opt_arg = argv[++opt_ind]; - } else if (l_opts[i].has_arg == require_arg) { - if (opt_err) - HDfprintf(stderr, - "%s: option required for \"--%s\" flag\n", - argv[0], arg); + H5_optarg = &arg[len + 1]; + } + else if (H5_optind < (argc - 1) && argv[H5_optind + 1][0] != '-') { + H5_optarg = argv[++H5_optind]; + } + else if (l_opts[i].has_arg == require_arg) { + if (H5_opterr) + HDfprintf(stderr, "%s: option required for \"--%s\" flag\n", argv[0], arg); opt_opt = '?'; } - } else { + } + else { if (arg[len] == '=') { - if (opt_err) - HDfprintf(stderr, - "%s: no option required for \"%s\" flag\n", - argv[0], arg); + if (H5_opterr) + HDfprintf(stderr, "%s: no option required for \"%s\" flag\n", argv[0], arg); opt_opt = '?'; } - opt_arg = NULL; + H5_optarg = NULL; } break; @@ -90,29 +82,29 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (l_opts[i].name == NULL) { /* exhausted all of the l_opts we have and still didn't match */ - if (opt_err) + if (H5_opterr) HDfprintf(stderr, "%s: unknown option \"%s\"\n", argv[0], arg); opt_opt = '?'; } - opt_ind++; + H5_optind++; sp = 1; - } else { - register char *cp; /* pointer into current token */ + } + else { + char *cp; /* pointer into current token */ /* short command line option */ - opt_opt = argv[opt_ind][sp]; + opt_opt = argv[H5_optind][sp]; if (opt_opt == ':' || (cp = strchr(opts, opt_opt)) == 0) { - if (opt_err) - HDfprintf(stderr, "%s: unknown option \"%c\"\n", - argv[0], opt_opt); + if (H5_opterr) + HDfprintf(stderr, "%s: unknown option \"%c\"\n", argv[0], opt_opt); /* if no chars left in this token, move to next token */ - if (argv[opt_ind][++sp] == '\0') { - opt_ind++; + if (argv[H5_optind][++sp] == '\0') { + H5_optind++; sp = 1; } @@ -121,31 +113,32 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (*++cp == ':') { /* if a value is expected, get it */ - if (argv[opt_ind][sp + 1] != '\0') { + if (argv[H5_optind][sp + 1] != '\0') { /* flag value is rest of current token */ - opt_arg = &argv[opt_ind++][sp + 1]; - } else if (++opt_ind >= argc) { - if (opt_err) - HDfprintf(stderr, - "%s: value expected for option \"%c\"\n", - argv[0], opt_opt); + H5_optarg = &argv[H5_optind++][sp + 1]; + } + else if (++H5_optind >= argc) { + if (H5_opterr) + HDfprintf(stderr, "%s: value expected for option \"%c\"\n", argv[0], opt_opt); opt_opt = '?'; - } else { + } + else { /* flag value is next token */ - opt_arg = argv[opt_ind++]; + H5_optarg = argv[H5_optind++]; } sp = 1; - } else { + } + else { /* set up to look at next char in token, next time */ - if (argv[opt_ind][++sp] == '\0') { + if (argv[H5_optind][++sp] == '\0') { /* no more in current token, so setup next token */ - opt_ind++; + H5_optind++; sp = 1; } - opt_arg = NULL; + H5_optarg = NULL; } } @@ -153,12 +146,9 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti return opt_opt; } - void print_version(const char *progname) { - printf("%s: Version %u.%u.%u%s%s\n", - progname, H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, + printf("%s: Version %u.%u.%u%s%s\n", progname, H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, H5_VERS_SUBRELEASE[0] ? "-" : "", H5_VERS_SUBRELEASE); } - diff --git a/tools/test/perform/sio_standalone.h b/tools/test/perform/sio_standalone.h index 5ce922b..57180e5 100644 --- a/tools/test/perform/sio_standalone.h +++ b/tools/test/perform/sio_standalone.h @@ -5,13 +5,13 @@ * 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 SIO_STANDALONE_H__ -#define SIO_PERF_H__ +#ifndef SIO_STANDALONE_H +#define SIO_STANDALONE_H /* Header file for building h5perf by standalone mode. * Created: Christian Chilan, 2005/5/18. @@ -19,472 +19,430 @@ /** From H5private.h **/ -#include "H5public.h" /* Include Public Definitions */ - - -/* - * Include ANSI-C header files. - */ -#ifdef H5_STDC_HEADERS -# include <assert.h> -# include <ctype.h> -# include <errno.h> -# include <fcntl.h> -# include <float.h> -# include <limits.h> -# include <math.h> -# include <signal.h> -# include <stdarg.h> -# include <stdio.h> -# include <stdlib.h> -# include <string.h> -#endif +#include "H5public.h" /* Include Public Definitions */ + +#include <assert.h> +#include <ctype.h> +#include <errno.h> +#include <fcntl.h> +#include <float.h> +#include <limits.h> +#include <math.h> +#include <signal.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> /* maximum of two, three, or four values */ #undef MAX -#define MAX(a,b) (((a)>(b)) ? (a) : (b)) -#define MAX2(a,b) MAX(a,b) -#define MAX3(a,b,c) MAX(a,MAX(b,c)) -#define MAX4(a,b,c,d) MAX(MAX(a,b),MAX(c,d)) +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#define MAX2(a, b) MAX(a, b) +#define MAX3(a, b, c) MAX(a, MAX(b, c)) +#define MAX4(a, b, c, d) MAX(MAX(a, b), MAX(c, d)) -/* - * A macro to portably increment enumerated types. - */ -#ifndef H5_INC_ENUM -# define H5_INC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)+1)) -#endif +#define H5_FLT_ABS_EQUAL(X, Y) (HDfabsf((X) - (Y)) < FLT_EPSILON) +#define H5_DBL_ABS_EQUAL(X, Y) (HDfabs((X) - (Y)) < DBL_EPSILON) +#define H5_LDBL_ABS_EQUAL(X, Y) (HDfabsl((X) - (Y)) < LDBL_EPSILON) -#define H5_FLT_ABS_EQUAL(X,Y) (HDfabsf((X)-(Y)) < FLT_EPSILON) -#define H5_DBL_ABS_EQUAL(X,Y) (HDfabs ((X)-(Y)) < DBL_EPSILON) -#define H5_LDBL_ABS_EQUAL(X,Y) (HDfabsl((X)-(Y)) < LDBL_EPSILON) - -#define H5_FLT_REL_EQUAL(X,Y,M) (HDfabsf(((Y)-(X)) / (X)) < (M)) -#define H5_DBL_REL_EQUAL(X,Y,M) (HDfabs (((Y)-(X)) / (X)) < (M)) -#define H5_LDBL_REL_EQUAL(X,Y,M) (HDfabsl(((Y)-(X)) / (X)) < (M)) +#define H5_FLT_REL_EQUAL(X, Y, M) (HDfabsf(((Y) - (X)) / (X)) < (M)) +#define H5_DBL_REL_EQUAL(X, Y, M) (HDfabs(((Y) - (X)) / (X)) < (M)) +#define H5_LDBL_REL_EQUAL(X, Y, M) (HDfabsl(((Y) - (X)) / (X)) < (M)) /* * Redefine all the POSIX functions. We should never see a POSIX * function (or any other non-HDF5 function) in the source! */ -#define HDabort() abort() -#define HDabs(X) abs(X) +#define HDabort() abort() +#define HDabs(X) abs(X) #ifdef H5_HAVE_WIN32_API -#define HDaccess(F,M) _access(F, M) -#define R_OK 4 /* Test for read permission. */ -#define W_OK 2 /* Test for write permission. */ -#define X_OK 1 /* Test for execute permission. */ -#define F_OK 0 /* Test for existence. */ -#else /* H5_HAVE_WIN32_API */ -#define HDaccess(F,M) access(F, M) +#define HDaccess(F, M) _access(F, M) +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +#define X_OK 1 /* Test for execute permission. */ +#define F_OK 0 /* Test for existence. */ +#else /* H5_HAVE_WIN32_API */ +#define HDaccess(F, M) access(F, M) #ifndef F_OK -#define F_OK 00 +#define F_OK 00 #define W_OK 02 #define R_OK 04 #endif #endif /* H5_HAVE_WIN32_API */ -#define HDacos(X) acos(X) +#define HDacos(X) acos(X) #ifdef H5_HAVE_ALARM -#define HDalarm(N) alarm(N) +#define HDalarm(N) alarm(N) #else /* H5_HAVE_ALARM */ -#define HDalarm(N) (0) +#define HDalarm(N) (0) #endif /* H5_HAVE_ALARM */ -#define HDasctime(T) asctime(T) -#define HDasin(X) asin(X) -#define HDasprintf asprintf /*varargs*/ -#define HDassert(X) assert(X) -#define HDatan(X) atan(X) -#define HDatan2(X,Y) atan2(X,Y) -#define HDatexit(F) atexit(F) -#define HDatof(S) atof(S) -#define HDatoi(S) atoi(S) -#define HDatol(S) atol(S) -#define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F) -#define HDcalloc(N,Z) calloc(N,Z) -#define HDceil(X) ceil(X) -#define HDcfgetispeed(T) cfgetispeed(T) -#define HDcfgetospeed(T) cfgetospeed(T) -#define HDcfsetispeed(T,S) cfsetispeed(T,S) -#define HDcfsetospeed(T,S) cfsetospeed(T,S) -#define HDchdir(S) chdir(S) -#define HDchmod(S,M) chmod(S,M) -#define HDchown(S,O,G) chown(S,O,G) -#define HDclearerr(F) clearerr(F) -#define HDclock() clock() -#define HDclose(F) close(F) -#define HDclosedir(D) closedir(D) -#define HDcos(X) cos(X) -#define HDcosh(X) cosh(X) -#define HDcreat(S,M) creat(S,M) -#define HDctermid(S) ctermid(S) -#define HDctime(T) ctime(T) -#define HDcuserid(S) cuserid(S) -#ifdef H5_HAVE_DIFFTIME -#define HDdifftime(X,Y) difftime(X,Y) -#else -#define HDdifftime(X,Y) ((double)(X)-(double)(Y)) -#endif -#define HDdiv(X,Y) div(X,Y) -#define HDdup(F) dup(F) -#define HDdup2(F,I) dup2(F,I) -/* execl() variable arguments */ -/* execle() variable arguments */ -/* execlp() variable arguments */ -#define HDexecv(S,AV) execv(S,AV) -#define HDexecve(S,AV,E) execve(S,AV,E) -#define HDexecvp(S,AV) execvp(S,AV) -#define HDexit(N) exit(N) -#define HD_exit(N) _exit(N) -#define HDexp(X) exp(X) -#define HDfabs(X) fabs(X) -/* use ABS() because fabsf() fabsl() are not common yet. */ -#define HDfabsf(X) ABS(X) -#define HDfabsl(X) ABS(X) -#define HDfclose(F) fclose(F) +#define HDasctime(T) asctime(T) +#define HDasin(X) asin(X) +#define HDasprintf asprintf /*varargs*/ +#define HDassert(X) assert(X) +#define HDatan(X) atan(X) +#define HDatan2(X, Y) atan2(X, Y) +#define HDatexit(F) atexit(F) +#define HDatof(S) atof(S) +#define HDatoi(S) atoi(S) +#define HDatol(S) atol(S) +#define HDbsearch(K, B, N, Z, F) bsearch(K, B, N, Z, F) +#define HDcalloc(N, Z) calloc(N, Z) +#define HDceil(X) ceil(X) +#define HDcfgetispeed(T) cfgetispeed(T) +#define HDcfgetospeed(T) cfgetospeed(T) +#define HDcfsetispeed(T, S) cfsetispeed(T, S) +#define HDcfsetospeed(T, S) cfsetospeed(T, S) +#define HDchdir(S) chdir(S) +#define HDchmod(S, M) chmod(S, M) +#define HDchown(S, O, G) chown(S, O, G) +#define HDclearerr(F) clearerr(F) +#define HDclock() clock() +#define HDclose(F) close(F) +#define HDclosedir(D) closedir(D) +#define HDcos(X) cos(X) +#define HDcosh(X) cosh(X) +#define HDcreat(S, M) creat(S, M) +#define HDctermid(S) ctermid(S) +#define HDctime(T) ctime(T) +#define HDcuserid(S) cuserid(S) +#define HDdifftime(X, Y) difftime(X, Y) +#define HDdiv(X, Y) div(X, Y) +#define HDdup(F) dup(F) +#define HDdup2(F, I) dup2(F, I) +#define HDexecv(S, AV) execv(S, AV) +#define HDexecve(S, AV, E) execve(S, AV, E) +#define HDexecvp(S, AV) execvp(S, AV) +#define HDexit(N) exit(N) +#define HD_exit(N) _exit(N) +#define HDexp(X) exp(X) +#define HDfabs(X) fabs(X) +#define HDfabsf(X) fabsf(X) +#define HDfabsl(X) fabsl(X) +#define HDfclose(F) fclose(F) /* fcntl() variable arguments */ -#define HDfdopen(N,S) fdopen(N,S) -#define HDfeof(F) feof(F) -#define HDferror(F) ferror(F) -#define HDfflush(F) fflush(F) -#define HDfgetc(F) fgetc(F) -#define HDfgetpos(F,P) fgetpos(F,P) -#define HDfgets(S,N,F) fgets(S,N,F) +#define HDfdopen(N, S) fdopen(N, S) +#define HDfeof(F) feof(F) +#define HDferror(F) ferror(F) +#define HDfflush(F) fflush(F) +#define HDfgetc(F) fgetc(F) +#define HDfgetpos(F, P) fgetpos(F, P) +#define HDfgets(S, N, F) fgets(S, N, F) #ifdef H5_HAVE_WIN32_API -#define HDfileno(F) _fileno(F) +#define HDfileno(F) _fileno(F) #else /* H5_HAVE_WIN32_API */ -#define HDfileno(F) fileno(F) +#define HDfileno(F) fileno(F) #endif /* H5_HAVE_WIN32_API */ -#define HDfloor(X) floor(X) -#define HDfmod(X,Y) fmod(X,Y) -#define HDfopen(S,M) fopen(S,M) -#define HDfork() fork() -#define HDfpathconf(F,N) fpathconf(F,N) -H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); -#define HDfputc(C,F) fputc(C,F) -#define HDfputs(S,F) fputs(S,F) -#define HDfread(M,Z,N,F) fread(M,Z,N,F) -#define HDfree(M) free(M) -#define HDfreopen(S,M,F) freopen(S,M,F) -#define HDfrexp(X,N) frexp(X,N) -/* Check for Cray-specific 'frexpf()' and 'frexpl()' routines */ -#ifdef H5_HAVE_FREXPF -#define HDfrexpf(X,N) frexpf(X,N) -#else /* H5_HAVE_FREXPF */ -#define HDfrexpf(X,N) frexp(X,N) -#endif /* H5_HAVE_FREXPF */ -#ifdef H5_HAVE_FREXPL -#define HDfrexpl(X,N) frexpl(X,N) -#else /* H5_HAVE_FREXPL */ -#define HDfrexpl(X,N) frexp(X,N) -#endif /* H5_HAVE_FREXPL */ +#define HDfloor(X) floor(X) +#define HDfmod(X, Y) fmod(X, Y) +#define HDfopen(S, M) fopen(S, M) +#define HDfork() fork() +#define HDfpathconf(F, N) fpathconf(F, N) +#define HDfprintf fprintf +#define HDfputc(C, F) fputc(C, F) +#define HDfputs(S, F) fputs(S, F) +#define HDfread(M, Z, N, F) fread(M, Z, N, F) +#define HDfree(M) free(M) +#define HDfreopen(S, M, F) freopen(S, M, F) +#define HDfrexp(X, N) frexp(X, N) +#define HDfrexpf(X, N) frexpf(X, N) +#define HDfrexpl(X, N) frexpl(X, N) /* fscanf() variable arguments */ #ifdef H5_HAVE_FSEEKO - #define HDfseek(F,O,W) fseeko(F,O,W) +#define HDfseek(F, O, W) fseeko(F, O, W) #else - #define HDfseek(F,O,W) fseek(F,O,W) +#define HDfseek(F, O, W) fseek(F, O, W) #endif -#define HDfsetpos(F,P) fsetpos(F,P) +#define HDfsetpos(F, P) fsetpos(F, P) /* definitions related to the file stat utilities. * Windows have its own function names. * For Unix, if off_t is not 64bit big, try use the pseudo-standard * xxx64 versions if available. */ #ifdef H5_HAVE_WIN32_API - #define HDfstat(F,B) _fstati64(F,B) - #define HDlstat(S,B) _lstati64(S,B) - #define HDstat(S,B) _stati64(S,B) - typedef struct _stati64 h5_stat_t; - typedef __int64 h5_stat_size_t; - #define HDoff_t __int64 -#elif H5_SIZEOF_OFF_T!=8 && H5_SIZEOF_OFF64_T==8 && defined(H5_HAVE_STAT64) - #define HDfstat(F,B) fstat64(F,B) - #define HDlstat(S,B) lstat64(S,B) - #define HDstat(S,B) stat64(S,B) - typedef struct stat64 h5_stat_t; - typedef off64_t h5_stat_size_t; - #define HDoff_t off64_t +#define HDfstat(F, B) _fstati64(F, B) +#define HDlstat(S, B) _lstati64(S, B) +#define HDstat(S, B) _stati64(S, B) +typedef struct _stati64 h5_stat_t; +typedef __int64 h5_stat_size_t; +#define HDoff_t __int64 +#elif H5_SIZEOF_OFF_T != 8 && H5_SIZEOF_OFF64_T == 8 && defined(H5_HAVE_STAT64) +#define HDfstat(F, B) fstat64(F, B) +#define HDlstat(S, B) lstat64(S, B) +#define HDstat(S, B) stat64(S, B) +typedef struct stat64 h5_stat_t; +typedef off64_t h5_stat_size_t; +#define HDoff_t off64_t #else - #define HDfstat(F,B) fstat(F,B) - #define HDlstat(S,B) lstat(S,B) - #define HDstat(S,B) stat(S,B) - typedef struct stat h5_stat_t; - typedef off_t h5_stat_size_t; - #define HDoff_t off_t +#define HDfstat(F, B) fstat(F, B) +#define HDlstat(S, B) lstat(S, B) +#define HDstat(S, B) stat(S, B) +typedef struct stat h5_stat_t; +typedef off_t h5_stat_size_t; +#define HDoff_t off_t #endif -#define HDftell(F) ftell(F) -#define HDftruncate(F,L) ftruncate(F,L) -#define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F) -#define HDgetc(F) getc(F) -#define HDgetchar() getchar() -#define HDgetcwd(S,Z) getcwd(S,Z) -#define HDgetegid() getegid() -#define HDgetenv(S) getenv(S) -#define HDgeteuid() geteuid() -#define HDgetgid() getgid() -#define HDgetgrgid(G) getgrgid(G) -#define HDgetgrnam(S) getgrnam(S) -#define HDgetgroups(Z,G) getgroups(Z,G) +#define HDftell(F) ftell(F) +#define HDftruncate(F, L) ftruncate(F, L) +#define HDfwrite(M, Z, N, F) fwrite(M, Z, N, F) +#define HDgetc(F) getc(F) +#define HDgetchar() getchar() +#define HDgetcwd(S, Z) getcwd(S, Z) +#define HDgetegid() getegid() +#define HDgetenv(S) getenv(S) +#define HDgeteuid() geteuid() +#define HDgetgid() getgid() +#define HDgetgrgid(G) getgrgid(G) +#define HDgetgrnam(S) getgrnam(S) +#define HDgetgroups(Z, G) getgroups(Z, G) #ifdef H5_HAVE_WIN32_API -#define HDgetlogin() Wgetlogin() +#define HDgetlogin() Wgetlogin() #else /* H5_HAVE_WIN32_API */ -#define HDgetlogin() getlogin() +#define HDgetlogin() getlogin() #endif /* H5_HAVE_WIN32_API */ -#define HDgetpgrp() getpgrp() -#define HDgetpid() getpid() -#define HDgetppid() getppid() -#define HDgetpwnam(S) getpwnam(S) -#define HDgetpwuid(U) getpwuid(U) -#define HDgetrusage(X,S) getrusage(X,S) -#define HDgets(S) gets(S) +#define HDgetpgrp() getpgrp() +#define HDgetpid() getpid() +#define HDgetppid() getppid() +#define HDgetpwnam(S) getpwnam(S) +#define HDgetpwuid(U) getpwuid(U) +#define HDgetrusage(X, S) getrusage(X, S) +/* Don't define a macro for gets() - it was removed in C11 */ #ifdef H5_HAVE_WIN32_API - H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); -#define HDgettimeofday(V,Z) Wgettimeofday(V,Z) +H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); +#define HDgettimeofday(V, Z) Wgettimeofday(V, Z) #else /* H5_HAVE_WIN32_API */ -#define HDgettimeofday(S,P) gettimeofday(S,P) +#define HDgettimeofday(S, P) gettimeofday(S, P) #endif /* H5_HAVE_WIN32_API */ -#define HDgetuid() getuid() -#define HDgmtime(T) gmtime(T) -#define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ -#define HDisalpha(C) isalpha((int)(C)) /*cast for solaris warning*/ -#define HDisatty(F) isatty(F) -#define HDiscntrl(C) iscntrl((int)(C)) /*cast for solaris warning*/ -#define HDisdigit(C) isdigit((int)(C)) /*cast for solaris warning*/ -#define HDisgraph(C) isgraph((int)(C)) /*cast for solaris warning*/ -#define HDislower(C) islower((int)(C)) /*cast for solaris warning*/ -#define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/ -#define HDispunct(C) ispunct((int)(C)) /*cast for solaris warning*/ -#define HDisspace(C) isspace((int)(C)) /*cast for solaris warning*/ -#define HDisupper(C) isupper((int)(C)) /*cast for solaris warning*/ -#define HDisxdigit(C) isxdigit((int)(C)) /*cast for solaris warning*/ -#define HDkill(P,S) kill(P,S) -#define HDlabs(X) labs(X) -#define HDldexp(X,N) ldexp(X,N) -#define HDldiv(X,Y) ldiv(X,Y) -#define HDlink(OLD,NEW) link(OLD,NEW) -#define HDlocaleconv() localeconv() -#define HDlocaltime(T) localtime(T) -#define HDlog(X) log(X) -#define HDlog10(X) log10(X) -#define HDlongjmp(J,N) longjmp(J,N) +#define HDgetuid() getuid() +#define HDgmtime(T) gmtime(T) +#define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ +#define HDisalpha(C) isalpha((int)(C)) /*cast for solaris warning*/ +#define HDisatty(F) isatty(F) +#define HDiscntrl(C) iscntrl((int)(C)) /*cast for solaris warning*/ +#define HDisdigit(C) isdigit((int)(C)) /*cast for solaris warning*/ +#define HDisgraph(C) isgraph((int)(C)) /*cast for solaris warning*/ +#define HDislower(C) islower((int)(C)) /*cast for solaris warning*/ +#define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/ +#define HDispunct(C) ispunct((int)(C)) /*cast for solaris warning*/ +#define HDisspace(C) isspace((int)(C)) /*cast for solaris warning*/ +#define HDisupper(C) isupper((int)(C)) /*cast for solaris warning*/ +#define HDisxdigit(C) isxdigit((int)(C)) /*cast for solaris warning*/ +#define HDkill(P, S) kill(P, S) +#define HDlabs(X) labs(X) +#define HDldexp(X, N) ldexp(X, N) +#define HDldiv(X, Y) ldiv(X, Y) +#define HDlink(OLD, NEW) link(OLD, NEW) +#define HDlocaleconv() localeconv() +#define HDlocaltime(T) localtime(T) +#define HDlog(X) log(X) +#define HDlog10(X) log10(X) +#define HDlongjmp(J, N) longjmp(J, N) #ifdef H5_HAVE_WIN32_API - #define HDlseek(F,O,W) _lseeki64(F,O,W) +#define HDlseek(F, O, W) _lseeki64(F, O, W) #else - #ifdef H5_HAVE_LSEEK64 - #define HDlseek(F,O,W) lseek64(F,O,W) - #else - #define HDlseek(F,O,W) lseek(F,O,W) - #endif +#ifdef H5_HAVE_LSEEK64 +#define HDlseek(F, O, W) lseek64(F, O, W) +#else +#define HDlseek(F, O, W) lseek(F, O, W) +#endif #endif -#define HDmalloc(Z) malloc(Z) -#define HDposix_memalign(P,A,Z) posix_memalign(P,A,Z) -#define HDmblen(S,N) mblen(S,N) -#define HDmbstowcs(P,S,Z) mbstowcs(P,S,Z) -#define HDmbtowc(P,S,Z) mbtowc(P,S,Z) -#define HDmemchr(S,C,Z) memchr(S,C,Z) -#define HDmemcmp(X,Y,Z) memcmp(X,Y,Z) +#define HDmalloc(Z) malloc(Z) +#define HDposix_memalign(P, A, Z) posix_memalign(P, A, Z) +#define HDmblen(S, N) mblen(S, N) +#define HDmbstowcs(P, S, Z) mbstowcs(P, S, Z) +#define HDmbtowc(P, S, Z) mbtowc(P, S, Z) +#define HDmemchr(S, C, Z) memchr(S, C, Z) +#define HDmemcmp(X, Y, Z) memcmp(X, Y, Z) /* * The (char*) casts are required for the DEC when optimizations are turned * on and the source and/or destination are not aligned. */ -#define HDmemcpy(X,Y,Z) memcpy((char*)(X),(const char*)(Y),Z) -#define HDmemmove(X,Y,Z) memmove((char*)(X),(const char*)(Y),Z) +#define HDmemcpy(X, Y, Z) memcpy((char *)(X), (const char *)(Y), Z) +#define HDmemmove(X, Y, Z) memmove((char *)(X), (const char *)(Y), Z) /* * The (void*) cast just avoids a compiler warning in H5_HAVE_VISUAL_STUDIO */ #ifdef H5_HAVE_VISUAL_STUDIO -#define HDmemset(X,C,Z) memset((void*)(X),C,Z) +#define HDmemset(X, C, Z) memset((void *)(X), C, Z) #else /* H5_HAVE_VISUAL_STUDIO */ -#define HDmemset(X,C,Z) memset(X,C,Z) +#define HDmemset(X, C, Z) memset(X, C, Z) #endif /* H5_HAVE_VISUAL_STUDIO */ #ifdef H5_HAVE_WIN32_API -#define HDmkdir(S,M) _mkdir(S) +#define HDmkdir(S, M) _mkdir(S) #else /* H5_HAVE_WIN32_API */ -#define HDmkdir(S,M) mkdir(S,M) +#define HDmkdir(S, M) mkdir(S, M) #endif /* H5_HAVE_WIN32_API */ -#define HDmkfifo(S,M) mkfifo(S,M) -#define HDmktime(T) mktime(T) -#define HDmodf(X,Y) modf(X,Y) +#define HDmkfifo(S, M) mkfifo(S, M) +#define HDmktime(T) mktime(T) +#define HDmodf(X, Y) modf(X, Y) #ifdef _O_BINARY -#define HDopen(S,F,M) open(S,F|_O_BINARY,M) +#define HDopen(S, F, M) open(S, F | _O_BINARY, M) #else -#define HDopen(S,F,M) open(S,F,M) +#define HDopen(S, F, M) open(S, F, M) #endif -#define HDopendir(S) opendir(S) -#define HDpathconf(S,N) pathconf(S,N) -#define HDpause() pause() -#define HDperror(S) perror(S) -#define HDpipe(F) pipe(F) -#define HDpow(X,Y) pow(X,Y) +#define HDopendir(S) opendir(S) +#define HDpathconf(S, N) pathconf(S, N) +#define HDpause() pause() +#define HDperror(S) perror(S) +#define HDpipe(F) pipe(F) +#define HDpow(X, Y) pow(X, Y) /* printf() variable arguments */ -#define HDprintf(...) HDfprintf(stdout, __VA_ARGS__) -#define HDputc(C,F) putc(C,F) -#define HDputchar(C) putchar(C) -#define HDputs(S) puts(S) -#define HDqsort(M,N,Z,F) qsort(M,N,Z,F) -#define HDraise(N) raise(N) +#define HDprintf(...) HDfprintf(stdout, __VA_ARGS__) +#define HDputc(C, F) putc(C, F) +#define HDputchar(C) putchar(C) +#define HDputs(S) puts(S) +#define HDqsort(M, N, Z, F) qsort(M, N, Z, F) +#define HDraise(N) raise(N) #ifdef H5_HAVE_RAND_R -#define HDrandom() HDrand() +#define HDrandom() HDrand() H5_DLL int HDrand(void); #elif H5_HAVE_RANDOM -#define HDrand() random() -#define HDrandom() random() +#define HDrand() random() +#define HDrandom() random() #else -#define HDrand() rand() -#define HDrandom() rand() +#define HDrand() rand() +#define HDrandom() rand() #endif -#define HDread(F,M,Z) read(F,M,Z) -#define HDreaddir(D) readdir(D) -#define HDrealloc(M,Z) realloc(M,Z) -#define HDremove(S) remove(S) -#define HDrename(OLD,NEW) rename(OLD,NEW) -#define HDrewind(F) rewind(F) -#define HDrewinddir(D) rewinddir(D) -#define HDrmdir(S) rmdir(S) +#define HDread(F, M, Z) read(F, M, Z) +#define HDreaddir(D) readdir(D) +#define HDrealloc(M, Z) realloc(M, Z) +#define HDremove(S) remove(S) +#define HDrename(OLD, NEW) rename(OLD, NEW) +#define HDrewind(F) rewind(F) +#define HDrewinddir(D) rewinddir(D) +#define HDrmdir(S) rmdir(S) /* scanf() variable arguments */ -#define HDsetbuf(F,S) setbuf(F,S) -#define HDsetgid(G) setgid(G) -#define HDsetjmp(J) setjmp(J) -#define HDsetlocale(N,S) setlocale(N,S) -#define HDsetpgid(P,PG) setpgid(P,PG) -#define HDsetsid() setsid() -#define HDsetuid(U) setuid(U) +#define HDsetbuf(F, S) setbuf(F, S) +#define HDsetgid(G) setgid(G) +#define HDsetjmp(J) setjmp(J) +#define HDsetlocale(N, S) setlocale(N, S) +#define HDsetpgid(P, PG) setpgid(P, PG) +#define HDsetsid() setsid() +#define HDsetuid(U) setuid(U) /* Windows does not permit setting the buffer size to values less than 2. */ #ifndef H5_HAVE_WIN32_API -#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z) +#define HDsetvbuf(F, S, M, Z) setvbuf(F, S, M, Z) #else -#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,(Z>1?Z:2)) +#define HDsetvbuf(F, S, M, Z) setvbuf(F, S, M, (Z > 1 ? Z : 2)) #endif -#define HDsigaddset(S,N) sigaddset(S,N) -#define HDsigdelset(S,N) sigdelset(S,N) -#define HDsigemptyset(S) sigemptyset(S) -#define HDsigfillset(S) sigfillset(S) -#define HDsigismember(S,N) sigismember(S,N) -#define HDsiglongjmp(J,N) siglongjmp(J,N) -#define HDsignal(N,F) signal(N,F) -#define HDsigpending(S) sigpending(S) -#define HDsigprocmask(H,S,O) sigprocmask(H,S,O) -#define HDsigsetjmp(J,N) sigsetjmp(J,N) -#define HDsigsuspend(S) sigsuspend(S) -#define HDsin(X) sin(X) -#define HDsinh(X) sinh(X) -#define HDsleep(N) sleep(N) -#ifdef H5_HAVE_WIN32_API -H5_DLL int c99_snprintf(char* str, size_t size, const char* format, ...); -#define HDsnprintf c99_snprintf /*varargs*/ -#else -#define HDsnprintf snprintf /*varargs*/ -#endif -/* sprintf() variable arguments */ -#define HDsprintf sprintf /*varargs*/ -#define HDsqrt(X) sqrt(X) +#define HDsigaddset(S, N) sigaddset(S, N) +#define HDsigdelset(S, N) sigdelset(S, N) +#define HDsigemptyset(S) sigemptyset(S) +#define HDsigfillset(S) sigfillset(S) +#define HDsigismember(S, N) sigismember(S, N) +#define HDsiglongjmp(J, N) siglongjmp(J, N) +#define HDsignal(N, F) signal(N, F) +#define HDsigpending(S) sigpending(S) +#define HDsigprocmask(H, S, O) sigprocmask(H, S, O) +#define HDsigsetjmp(J, N) sigsetjmp(J, N) +#define HDsigsuspend(S) sigsuspend(S) +#define HDsin(X) sin(X) +#define HDsinh(X) sinh(X) +#define HDsleep(N) sleep(N) +#define HDsnprintf snprintf /*varargs*/ +#define HDsprintf sprintf /*varargs*/ +#define HDsqrt(X) sqrt(X) #ifdef H5_HAVE_RAND_R H5_DLL void HDsrand(unsigned int seed); -#define HDsrandom(S) HDsrand(S) +#define HDsrandom(S) HDsrand(S) #elif H5_HAVE_RANDOM -#define HDsrand(S) srandom(S) -#define HDsrandom(S) srandom(S) +#define HDsrand(S) srandom(S) +#define HDsrandom(S) srandom(S) #else -#define HDsrand(S) srand(S) -#define HDsrandom(S) srand(S) +#define HDsrand(S) srand(S) +#define HDsrandom(S) srand(S) #endif -/* sscanf() variable arguments */ #ifdef H5_HAVE_WIN32_API -#define HDstrcasecmp(A,B) _stricmp(A,B) +#define HDstrcasecmp(A, B) _stricmp(A, B) #else -#define HDstrcasecmp(X,Y) strcasecmp(X,Y) +#define HDstrcasecmp(X, Y) strcasecmp(X, Y) #endif -#define HDstrcat(X,Y) strcat(X,Y) -#define HDstrchr(S,C) strchr(S,C) -#define HDstrcmp(X,Y) strcmp(X,Y) -#define HDstrcoll(X,Y) strcoll(X,Y) -#define HDstrcpy(X,Y) strcpy(X,Y) -#define HDstrcspn(X,Y) strcspn(X,Y) -#define HDstrerror(N) strerror(N) -#define HDstrftime(S,Z,F,T) strftime(S,Z,F,T) -#define HDstrlen(S) strlen(S) -#define HDstrncat(X,Y,Z) strncat(X,Y,Z) -#define HDstrncmp(X,Y,Z) strncmp(X,Y,Z) -#define HDstrncpy(X,Y,Z) strncpy(X,Y,Z) -#define HDstrpbrk(X,Y) strpbrk(X,Y) -#define HDstrrchr(S,C) strrchr(S,C) -#define HDstrspn(X,Y) strspn(X,Y) -#define HDstrstr(X,Y) strstr(X,Y) -#define HDstrtod(S,R) strtod(S,R) -#define HDstrtok(X,Y) strtok(X,Y) -#define HDstrtol(S,R,N) strtol(S,R,N) -H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); -#define HDstrtoul(S,R,N) strtoul(S,R,N) +#define HDstrcat(X, Y) strcat(X, Y) +#define HDstrchr(S, C) strchr(S, C) +#define HDstrcmp(X, Y) strcmp(X, Y) +#define HDstrcoll(X, Y) strcoll(X, Y) +#define HDstrcpy(X, Y) strcpy(X, Y) +#define HDstrcspn(X, Y) strcspn(X, Y) +#define HDstrerror(N) strerror(N) +#define HDstrftime(S, Z, F, T) strftime(S, Z, F, T) +#define HDstrlen(S) strlen(S) +#define HDstrncat(X, Y, Z) strncat(X, Y, Z) +#define HDstrncmp(X, Y, Z) strncmp(X, Y, Z) +#define HDstrncpy(X, Y, Z) strncpy(X, Y, Z) +#define HDstrpbrk(X, Y) strpbrk(X, Y) +#define HDstrrchr(S, C) strrchr(S, C) +#define HDstrspn(X, Y) strspn(X, Y) +#define HDstrstr(X, Y) strstr(X, Y) +#define HDstrtod(S, R) strtod(S, R) +#define HDstrtok(X, Y) strtok(X, Y) +#define HDstrtol(S, R, N) strtol(S, R, N) +H5_DLL int64_t HDstrtoll(const char *s, const char **rest, int base); +#define HDstrtoul(S, R, N) strtoul(S, R, N) #ifdef H5_HAVE_WIN32_API -#define HDstrtoull(S,R,N) _strtoui64(S,R,N) +#define HDstrtoull(S, R, N) _strtoui64(S, R, N) #else -#define HDstrtoull(S,R,N) strtoull(S,R,N) +#define HDstrtoull(S, R, N) strtoull(S, R, N) #endif -#define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z) -#define HDsysconf(N) sysconf(N) -#define HDsystem(S) system(S) -#define HDtan(X) tan(X) -#define HDtanh(X) tanh(X) -#define HDtcdrain(F) tcdrain(F) -#define HDtcflow(F,A) tcflow(F,A) -#define HDtcflush(F,N) tcflush(F,N) -#define HDtcgetattr(F,T) tcgetattr(F,T) -#define HDtcgetpgrp(F) tcgetpgrp(F) -#define HDtcsendbreak(F,N) tcsendbreak(F,N) -#define HDtcsetattr(F,O,T) tcsetattr(F,O,T) -#define HDtcsetpgrp(F,N) tcsetpgrp(F,N) -#define HDtime(T) time(T) -#define HDtimes(T) times(T) -#define HDtmpfile() tmpfile() -#define HDtmpnam(S) tmpnam(S) -#define HDtolower(C) tolower(C) -#define HDtoupper(C) toupper(C) -#define HDttyname(F) ttyname(F) -#define HDtzset() tzset() -#define HDumask(N) umask(N) -#define HDuname(S) uname(S) -#define HDungetc(C,F) ungetc(C,F) +#define HDstrxfrm(X, Y, Z) strxfrm(X, Y, Z) +#define HDsysconf(N) sysconf(N) +#define HDsystem(S) system(S) +#define HDtan(X) tan(X) +#define HDtanh(X) tanh(X) +#define HDtcdrain(F) tcdrain(F) +#define HDtcflow(F, A) tcflow(F, A) +#define HDtcflush(F, N) tcflush(F, N) +#define HDtcgetattr(F, T) tcgetattr(F, T) +#define HDtcgetpgrp(F) tcgetpgrp(F) +#define HDtcsendbreak(F, N) tcsendbreak(F, N) +#define HDtcsetattr(F, O, T) tcsetattr(F, O, T) +#define HDtcsetpgrp(F, N) tcsetpgrp(F, N) +#define HDtime(T) time(T) +#define HDtimes(T) times(T) +#define HDtmpfile() tmpfile() +#define HDtmpnam(S) tmpnam(S) +#define HDtolower(C) tolower(C) +#define HDtoupper(C) toupper(C) +#define HDttyname(F) ttyname(F) +#define HDtzset() tzset() +#define HDumask(N) umask(N) +#define HDuname(S) uname(S) +#define HDungetc(C, F) ungetc(C, F) #ifdef H5_HAVE_WIN32_API -#define HDunlink(S) _unlink(S) +#define HDunlink(S) _unlink(S) #else -#define HDunlink(S) unlink(S) +#define HDunlink(S) unlink(S) #endif -#define HDutime(S,T) utime(S,T) -#define HDva_arg(A,T) va_arg(A,T) -#define HDva_end(A) va_end(A) -#define HDva_start(A,P) va_start(A,P) -#define HDvasprintf(RET,FMT,A) vasprintf(RET,FMT,A) -#define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A) -#define HDvprintf(FMT,A) vprintf(FMT,A) -#define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A) -#ifdef H5_HAVE_WIN32_API -H5_DLL int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap); -#define HDvsnprintf c99_vsnprintf -#else -# define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A) -#endif -#define HDwait(W) wait(W) -#define HDwaitpid(P,W,O) waitpid(P,W,O) -#define HDwcstombs(S,P,Z) wcstombs(S,P,Z) -#define HDwctomb(S,C) wctomb(S,C) -#define HDwrite(F,M,Z) write(F,M,Z) +#define HDutime(S, T) utime(S, T) +#define HDva_arg(A, T) va_arg(A, T) +#define HDva_end(A) va_end(A) +#define HDva_start(A, P) va_start(A, P) +#define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A) +#define HDvfprintf(F, FMT, A) vfprintf(F, FMT, A) +#define HDvprintf(FMT, A) vprintf(FMT, A) +#define HDvsprintf(S, FMT, A) vsprintf(S, FMT, A) +#define HDvsnprintf(S, N, FMT, A) vsnprintf(S, N, FMT, A) +#define HDwait(W) wait(W) +#define HDwaitpid(P, W, O) waitpid(P, W, O) +#define HDwcstombs(S, P, Z) wcstombs(S, P, Z) +#define HDwctomb(S, C) wctomb(S, C) +#define HDwrite(F, M, Z) write(F, M, Z) /* * And now for a couple non-Posix functions... Watch out for systems that * define these in terms of macros. */ #ifdef H5_HAVE_WIN32_API -#define HDstrdup(S) _strdup(S) +#define HDstrdup(S) _strdup(S) #else /* H5_HAVE_WIN32_API */ #if !defined strdup && !defined H5_HAVE_STRDUP -extern char *strdup(const char *s); +extern char * strdup(const char *s); #endif -#define HDstrdup(S) strdup(S) +#define HDstrdup(S) strdup(S) #endif /* H5_HAVE_WIN32_API */ @@ -492,46 +450,38 @@ extern char *strdup(const char *s); * HDF Boolean type. */ #ifndef FALSE -# define FALSE false +#define FALSE false #endif #ifndef TRUE -# define TRUE true -#endif - -/** From h5test.h **/ - -#ifdef H5_HAVE_PARALLEL -extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */ -#endif - -#ifdef H5_HAVE_PARALLEL -H5TEST_DLL int h5_set_info_object(void); -H5TEST_DLL void h5_dump_info_object(MPI_Info info); +#define TRUE true #endif - - /** From h5tools_utils.h **/ -extern int opt_err; /* getoption prints errors if this is on */ -extern int opt_ind; /* token pointer */ -extern const char *opt_arg; /* flag argument (or value) */ +H5_DLLVAR int H5_opterr; /* getoption prints errors if this is on */ +H5_DLLVAR int H5_optind; /* token pointer */ +H5_DLLVAR const char *H5_optarg; /* flag argument (or value) */ +enum h5_arg_level { + no_arg = 0, /* doesn't take an argument */ + require_arg, /* requires an argument */ + optional_arg /* argument is optional */ +}; -enum { - no_arg = 0, /* doesn't take an argument */ - require_arg, /* requires an argument */ - optional_arg /* argument is optional */ +struct h5_long_options { + const char * name; /* Name of the long option */ + enum h5_arg_level has_arg; /* Whether we should look for an arg */ + char shortval; /* The shortname equivalent of long arg + * this gets returned from get_option + */ }; +extern int H5_get_option(int argc, const char *const *argv, const char *opt, + const struct h5_long_options *l_opt); + +extern int nCols; /*max number of columns for outputting */ -typedef struct long_options { - const char *name; /* name of the long option */ - int has_arg; /* whether we should look for an arg */ - char shortval; /* the shortname equivalent of long arg - * this gets returned from get_option */ -} long_options; +/* Definitions of useful routines */ +extern void print_version(const char *progname); -extern int get_option(int argc, const char **argv, const char *opt, - const struct long_options *l_opt); #endif diff --git a/tools/test/perform/zip_perf.c b/tools/test/perform/zip_perf.c index e301bb3..87a7122 100644 --- a/tools/test/perform/zip_perf.c +++ b/tools/test/perform/zip_perf.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -28,105 +28,51 @@ #include <zlib.h> -#define ONE_KB 1024 -#define ONE_MB (ONE_KB * ONE_KB) -#define ONE_GB (ONE_MB * ONE_KB) +#define ONE_KB 1024 +#define ONE_MB (ONE_KB * ONE_KB) +#define ONE_GB (ONE_MB * ONE_KB) -#define MICROSECOND 1000000.0F +#define MICROSECOND 1000000.0 /* report 0.0 in case t is zero too */ -#define MB_PER_SEC(bytes,t) ((fabs(t) < (double)0.0000000001F) ? (double)0.0F : ((((double)bytes) / (double)ONE_MB) / (t))) +#define MB_PER_SEC(bytes, t) ((fabs(t) < 0.0000000001) ? 0.0 : ((((double)(bytes)) / (double)ONE_MB) / (t))) #ifndef TRUE -#define TRUE 1 -#endif /* TRUE */ +#define TRUE 1 +#endif /* TRUE */ #ifndef FALSE -#define FALSE (!TRUE) -#endif /* FALSE */ +#define FALSE (!TRUE) +#endif /* FALSE */ #ifndef S_IRWXU -#define S_IRWXU (_S_IREAD|_S_IWRITE) +#define S_IRWXU (_S_IREAD | _S_IWRITE) #endif /* internal variables */ -static const char *prog=NULL; -static const char *option_prefix=NULL; -static char *filename=NULL; -static int compress_percent = 0; -static int compress_level = Z_DEFAULT_COMPRESSION; -static int output, random_test = FALSE; -static int report_once_flag; -static double compression_time; +static const char *prog = NULL; +static const char *option_prefix = NULL; +static char * filename = NULL; +static int compress_percent = 0; +static int compress_level = Z_DEFAULT_COMPRESSION; +static int output, random_test = FALSE; +static int report_once_flag; +static double compression_time; /* internal functions */ static void error(const char *fmt, ...); -static void compress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, - uLong sourceLen); +static void compress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); /* commandline options : long and short form */ -static const char *s_opts = "hB:b:c:p:rs:0123456789"; -static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "compressability", require_arg, 'c' }, - { "compressabilit", require_arg, 'c' }, - { "compressabili", require_arg, 'c' }, - { "compressabil", require_arg, 'c' }, - { "compressabi", require_arg, 'c' }, - { "compressab", require_arg, 'c' }, - { "compressa", require_arg, 'c' }, - { "compress", require_arg, 'c' }, - { "compres", require_arg, 'c' }, - { "compre", require_arg, 'c' }, - { "compr", require_arg, 'c' }, - { "comp", require_arg, 'c' }, - { "com", require_arg, 'c' }, - { "co", require_arg, 'c' }, - { "file-size", require_arg, 's' }, - { "file-siz", require_arg, 's' }, - { "file-si", require_arg, 's' }, - { "file-s", require_arg, 's' }, - { "file", require_arg, 's' }, - { "fil", require_arg, 's' }, - { "fi", require_arg, 's' }, - { "max-buffer-size", require_arg, 'B' }, - { "max-buffer-siz", require_arg, 'B' }, - { "max-buffer-si", require_arg, 'B' }, - { "max-buffer-s", require_arg, 'B' }, - { "max-buffer", require_arg, 'B' }, - { "max-buffe", require_arg, 'B' }, - { "max-buff", require_arg, 'B' }, - { "max-buf", require_arg, 'B' }, - { "max-bu", require_arg, 'B' }, - { "max-b", require_arg, 'B' }, - { "max", require_arg, 'B' }, - { "min-buffer-size", require_arg, 'b' }, - { "min-buffer-siz", require_arg, 'b' }, - { "min-buffer-si", require_arg, 'b' }, - { "min-buffer-s", require_arg, 'b' }, - { "min-buffer", require_arg, 'b' }, - { "min-buffe", require_arg, 'b' }, - { "min-buff", require_arg, 'b' }, - { "min-buf", require_arg, 'b' }, - { "min-bu", require_arg, 'b' }, - { "min-b", require_arg, 'b' }, - { "min", require_arg, 'b' }, - { "prefix", require_arg, 'p' }, - { "prefi", require_arg, 'p' }, - { "pref", require_arg, 'p' }, - { "pre", require_arg, 'p' }, - { "pr", require_arg, 'p' }, - { "random-test", no_arg, 'r' }, - { "random-tes", no_arg, 'r' }, - { "random-te", no_arg, 'r' }, - { "random-t", no_arg, 'r' }, - { "random", no_arg, 'r' }, - { "rando", no_arg, 'r' }, - { "rand", no_arg, 'r' }, - { "ran", no_arg, 'r' }, - { "ra", no_arg, 'r' }, - { NULL, 0, '\0' } -}; +static const char * s_opts = "hB:b:c:p:rs:0123456789"; +static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'}, + {"compressability", require_arg, 'c'}, + {"file-size", require_arg, 's'}, + {"max-buffer-size", require_arg, 'B'}, + {"min-buffer-size", require_arg, 'b'}, + {"prefix", require_arg, 'p'}, + {"random-test", no_arg, 'r'}, + {NULL, 0, '\0'}}; /* * Function: error @@ -157,7 +103,7 @@ error(const char *fmt, ...) static void cleanup(void) { - if (!HDgetenv("HDF5_NOCLEANUP")) + if (!HDgetenv(HDF5_NOCLEANUP)) HDunlink(filename); HDfree(filename); } @@ -165,14 +111,14 @@ cleanup(void) static void write_file(Bytef *source, uLongf sourceLen) { - Bytef *d_ptr, *dest; - uLongf d_len, destLen; + Bytef * d_ptr, *dest; + uLongf d_len, destLen; struct timeval timer_start, timer_stop; /* destination buffer needs to be at least 0.1% larger than sourceLen * plus 12 bytes */ - destLen = (uLongf)((double)sourceLen + ((double)sourceLen * (double)0.1F)) + 12; - dest = (Bytef *)HDmalloc(destLen); + destLen = (uLongf)((double)sourceLen + ((double)sourceLen * 0.1)) + 12; + dest = (Bytef *)HDmalloc(destLen); if (!dest) error("out of memory"); @@ -181,10 +127,8 @@ write_file(Bytef *source, uLongf sourceLen) compress_buffer(dest, &destLen, source, sourceLen); HDgettimeofday(&timer_stop, NULL); - compression_time += ((double)timer_stop.tv_sec + - ((double)timer_stop.tv_usec) / (double)MICROSECOND) - - ((double)timer_start.tv_sec + - ((double)timer_start.tv_usec) / (double)MICROSECOND); + compression_time += ((double)timer_stop.tv_sec + ((double)timer_stop.tv_usec) / MICROSECOND) - + ((double)timer_start.tv_sec + ((double)timer_start.tv_usec) / MICROSECOND); if (report_once_flag) { HDfprintf(stdout, "\tCompression Ratio: %g\n", ((double)destLen) / (double)sourceLen); @@ -222,8 +166,7 @@ write_file(Bytef *source, uLongf sourceLen) * Modifications: */ static void -compress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, - uLong sourceLen) +compress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) { int rc = compress2(dest, destLen, source, sourceLen, compress_level); @@ -232,18 +175,18 @@ compress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, cleanup(); switch (rc) { - case Z_MEM_ERROR: - error("not enough memory"); - break; - case Z_BUF_ERROR: - error("not enough room in the output buffer"); - break; - case Z_STREAM_ERROR: - error("level parameter (%d) is invalid", compress_level); - break; - default: - error("unknown compression error"); - break; + case Z_MEM_ERROR: + error("not enough memory"); + break; + case Z_BUF_ERROR: + error("not enough room in the output buffer"); + break; + case Z_STREAM_ERROR: + error("level parameter (%d) is invalid", compress_level); + break; + default: + error("unknown compression error"); + break; } } } @@ -260,8 +203,7 @@ compress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, * Modifications: */ static int -uncompress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, - uLong sourceLen) +uncompress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) { int rc = uncompress(dest, destLen, source, sourceLen); @@ -282,7 +224,7 @@ static void get_unique_name(void) { const char *prefix = NULL; - const char *env = HDgetenv("HDF5_PREFIX"); + const char *env = HDgetenv("HDF5_PREFIX"); if (env) prefix = env; @@ -292,15 +234,15 @@ get_unique_name(void) if (prefix) /* 2 = 1 for '/' + 1 for null terminator */ - filename = (char *) HDmalloc(HDstrlen(prefix) + HDstrlen(ZIP_PERF_FILE) + 2); + filename = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(ZIP_PERF_FILE) + 2); else - filename = (char *) HDmalloc(HDstrlen(ZIP_PERF_FILE) + 1); + filename = (char *)HDmalloc(HDstrlen(ZIP_PERF_FILE) + 1); if (!filename) error("out of memory"); filename[0] = 0; - if (prefix){ + if (prefix) { HDstrcpy(filename, prefix); HDstrcat(filename, "/"); } @@ -325,7 +267,7 @@ usage(void) HDfprintf(stdout, " data you want [default: 0]"); HDfprintf(stdout, " -s S, --file-size=S Maximum size of uncompressed file [default: 64M]\n"); HDfprintf(stdout, " -B S, --max-buffer_size=S Maximum size of buffer [default: 1M]\n"); - HDfprintf(stdout, " -b S, --min-buffer_size=S Minumum size of buffer [default: 128K]\n"); + HDfprintf(stdout, " -b S, --min-buffer_size=S Minimum size of buffer [default: 128K]\n"); HDfprintf(stdout, " -p D, --prefix=D The directory prefix to place the file\n"); HDfprintf(stdout, " -r, --random-test Use random data to write to the file\n"); HDfprintf(stdout, " [default: no]\n"); @@ -361,7 +303,7 @@ static unsigned long parse_size_directive(const char *size) { unsigned long s; - char *endptr; + char * endptr; s = HDstrtoul(size, &endptr, 10); @@ -394,13 +336,13 @@ parse_size_directive(const char *size) static void fill_with_random_data(Bytef *src, uLongf src_len) { - register unsigned u; + unsigned u; h5_stat_t stat_buf; if (HDstat("/dev/urandom", &stat_buf) == 0) { uLongf len = src_len; Bytef *buf = src; - int fd = HDopen("/dev/urandom", O_RDONLY, 0); + int fd = HDopen("/dev/urandom", O_RDONLY, 0); HDfprintf(stdout, "Using /dev/urandom for random data\n"); @@ -436,26 +378,25 @@ fill_with_random_data(Bytef *src, uLongf src_len) } static void -do_write_test(unsigned long file_size, unsigned long min_buf_size, - unsigned long max_buf_size) +do_write_test(unsigned long file_size, unsigned long min_buf_size, unsigned long max_buf_size) { - uLongf src_len, total_len; + uLongf src_len, total_len; struct timeval timer_start, timer_stop; - double total_time; - Bytef *src; + double total_time; + Bytef * src; for (src_len = min_buf_size; src_len <= max_buf_size; src_len <<= 1) { - register unsigned long i, iters; + unsigned long i, iters; iters = file_size / src_len; - src = (Bytef *)HDcalloc(1, sizeof(Bytef) * src_len); + src = (Bytef *)HDcalloc(1, sizeof(Bytef) * src_len); if (!src) { cleanup(); error("out of memory"); } - compression_time = 0.0F; + compression_time = 0.0; if (random_test) fill_with_random_data(src, src_len); @@ -465,10 +406,12 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, if (src_len >= ONE_KB && (src_len % ONE_KB) == 0) { if (src_len >= ONE_MB && (src_len % ONE_MB) == 0) { HDfprintf(stdout, "%ldMB", src_len / ONE_MB); - } else { + } + else { HDfprintf(stdout, "%ldKB", src_len / ONE_KB); } - } else { + } + else { HDfprintf(stdout, "%ld", src_len); } @@ -483,7 +426,7 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, for (i = 0; i <= iters; ++i) { Bytef *s_ptr = src; - uLong s_len = src_len; + uLong s_len = src_len; /* loop to make sure we write everything out that we want to write */ for (;;) { @@ -503,14 +446,11 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, HDclose(output); HDgettimeofday(&timer_stop, NULL); - total_time = ((double)timer_stop.tv_sec + - ((double)timer_stop.tv_usec) / (double)MICROSECOND) - - ((double)timer_start.tv_sec + - ((double)timer_start.tv_usec) / (double)MICROSECOND); + total_time = ((double)timer_stop.tv_sec + ((double)timer_stop.tv_usec) / (double)MICROSECOND) - + ((double)timer_start.tv_sec + ((double)timer_start.tv_usec) / (double)MICROSECOND); HDfprintf(stdout, "\tUncompressed Write Time: %.2fs\n", total_time); - HDfprintf(stdout, "\tUncompressed Write Throughput: %.2fMB/s\n", - MB_PER_SEC(file_size, total_time)); + HDfprintf(stdout, "\tUncompressed Write Throughput: %.2fMB/s\n", MB_PER_SEC(file_size, total_time)); HDunlink(filename); @@ -529,14 +469,11 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, HDclose(output); HDgettimeofday(&timer_stop, NULL); - total_time = ((double)timer_stop.tv_sec + - ((double)timer_stop.tv_usec) / (double)MICROSECOND) - - ((double)timer_start.tv_sec + - ((double)timer_start.tv_usec) / (double)MICROSECOND); + total_time = ((double)timer_stop.tv_sec + ((double)timer_stop.tv_usec) / (double)MICROSECOND) - + ((double)timer_start.tv_sec + ((double)timer_start.tv_usec) / (double)MICROSECOND); HDfprintf(stdout, "\tCompressed Write Time: %.2fs\n", total_time); - HDfprintf(stdout, "\tCompressed Write Throughput: %.2fMB/s\n", - MB_PER_SEC(file_size, total_time)); + HDfprintf(stdout, "\tCompressed Write Throughput: %.2fMB/s\n", MB_PER_SEC(file_size, total_time)); HDfprintf(stdout, "\tCompression Time: %gs\n", compression_time); HDunlink(filename); @@ -552,64 +489,69 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, * Modifications: */ int -main(int argc, char **argv) +main(int argc, char *argv[]) { unsigned long min_buf_size = 128 * ONE_KB, max_buf_size = ONE_MB; unsigned long file_size = 64 * ONE_MB; - int opt; + int opt; prog = argv[0]; /* Initialize h5tools lib */ h5tools_init(); - while ((opt = get_option(argc, (const char **)argv, s_opts, l_opts)) > 0) { + while ((opt = H5_get_option(argc, (const char *const *)argv, s_opts, l_opts)) > 0) { switch ((char)opt) { - case '0': case '1': case '2': - case '3': case '4': case '5': - case '6': case '7': case '8': - case '9': - compress_level = opt - '0'; - break; - case 'B': - max_buf_size = parse_size_directive(opt_arg); - break; - case 'b': - min_buf_size = parse_size_directive(opt_arg); - break; - case 'c': - compress_percent = (int)HDstrtol(opt_arg, NULL, 10); + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + compress_level = opt - '0'; + break; + case 'B': + max_buf_size = parse_size_directive(H5_optarg); + break; + case 'b': + min_buf_size = parse_size_directive(H5_optarg); + break; + case 'c': + compress_percent = (int)HDstrtol(H5_optarg, NULL, 10); - if (compress_percent < 0) - compress_percent = 0; - else if (compress_percent > 100) - compress_percent = 100; + if (compress_percent < 0) + compress_percent = 0; + else if (compress_percent > 100) + compress_percent = 100; - break; - case 'p': - option_prefix = opt_arg; - break; - case 'r': - random_test = TRUE; - break; - case 's': - file_size = parse_size_directive(opt_arg); - break; - case '?': - usage(); - exit(EXIT_FAILURE); - break; - case 'h': - default: - usage(); - exit(EXIT_SUCCESS); - break; + break; + case 'p': + option_prefix = H5_optarg; + break; + case 'r': + random_test = TRUE; + break; + case 's': + file_size = parse_size_directive(H5_optarg); + break; + case '?': + usage(); + exit(EXIT_FAILURE); + break; + case 'h': + default: + usage(); + exit(EXIT_SUCCESS); + break; } } if (min_buf_size > max_buf_size) - error("minmum buffer size (%d) exceeds maximum buffer size (%d)", - min_buf_size, max_buf_size); + error("minimum buffer size (%d) exceeds maximum buffer size (%d)", min_buf_size, max_buf_size); HDfprintf(stdout, "Filesize: %ld\n", file_size); @@ -641,4 +583,4 @@ main(void) return EXIT_SUCCESS; } -#endif /* !H5_HAVE_FILTER_DEFLATE */ +#endif /* !H5_HAVE_FILTER_DEFLATE */ |