summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt53
-rw-r--r--examples/CMakeTests.cmake214
-rw-r--r--examples/Makefile.am6
-rw-r--r--examples/Makefile.in32
-rw-r--r--examples/README2
-rw-r--r--examples/h5_attribute.c374
-rw-r--r--examples/h5_chunk_read.c105
-rw-r--r--examples/h5_cmprss.c142
-rw-r--r--examples/h5_compound.c58
-rw-r--r--examples/h5_crtatt.c59
-rw-r--r--examples/h5_crtdat.c45
-rw-r--r--examples/h5_crtgrp.c28
-rw-r--r--examples/h5_crtgrpar.c40
-rw-r--r--examples/h5_crtgrpd.c101
-rw-r--r--examples/h5_drivers.c21
-rw-r--r--examples/h5_dtransform.c100
-rw-r--r--examples/h5_elink_unix2win.c128
-rw-r--r--examples/h5_extend.c143
-rw-r--r--examples/h5_extend_write.c104
-rw-r--r--examples/h5_extlink.c260
-rw-r--r--examples/h5_group.c107
-rw-r--r--examples/h5_interm_group.c76
-rw-r--r--examples/h5_mount.c200
-rw-r--r--examples/h5_rdwt.c46
-rw-r--r--examples/h5_read.c106
-rw-r--r--examples/h5_ref2reg.c95
-rw-r--r--examples/h5_reference.c241
-rw-r--r--examples/h5_select.c226
-rw-r--r--examples/h5_shared_mesg.c205
-rw-r--r--examples/h5_subset.c165
-rw-r--r--examples/h5_write.c40
-rw-r--r--examples/ph5example.c868
-rwxr-xr-xexamples/run-all-ex.sh2
-rw-r--r--examples/run-c-ex.sh.in31
-rw-r--r--examples/testh5cc.sh.in5
35 files changed, 2156 insertions, 2272 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index d643f35..467dfa4 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,10 +1,5 @@
-cmake_minimum_required (VERSION 3.10)
-PROJECT (HDF5_EXAMPLES)
-
-#-----------------------------------------------------------------------------
-# Apply Definitions to compiler in this directory and below
-#-----------------------------------------------------------------------------
-add_definitions (${HDF_EXTRA_C_FLAGS})
+cmake_minimum_required (VERSION 3.12)
+project (HDF5_EXAMPLES C)
#-----------------------------------------------------------------------------
# Define Sources
@@ -38,30 +33,44 @@ set (examples
foreach (example ${examples})
add_executable (${example} ${HDF5_EXAMPLES_SOURCE_DIR}/${example}.c)
- TARGET_C_PROPERTIES (${example} STATIC " " " ")
- target_link_libraries (${example} ${HDF5_LIB_TARGET})
+ target_include_directories (${example} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ if (NOT BUILD_SHARED_LIBS)
+ TARGET_C_PROPERTIES (${example} STATIC)
+ target_link_libraries (${example} PRIVATE ${HDF5_LIB_TARGET})
+ else ()
+ TARGET_C_PROPERTIES (${example} SHARED)
+ target_link_libraries (${example} PRIVATE ${HDF5_LIBSH_TARGET})
+ endif ()
set_target_properties (${example} PROPERTIES FOLDER examples)
- if (BUILD_SHARED_LIBS)
- add_executable (${example}-shared ${HDF5_EXAMPLES_SOURCE_DIR}/${example}.c)
- TARGET_C_PROPERTIES (${example}-shared SHARED " " " ")
- target_link_libraries (${example}-shared ${HDF5_LIBSH_TARGET})
- set_target_properties (${example}-shared PROPERTIES FOLDER examples)
+
+ #-----------------------------------------------------------------------------
+ # Add Target to clang-format
+ #-----------------------------------------------------------------------------
+ if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_EXAMPLES_${example}_FORMAT ${example})
endif ()
endforeach ()
if (H5_HAVE_PARALLEL)
add_executable (ph5example ${HDF5_EXAMPLES_SOURCE_DIR}/ph5example.c)
- TARGET_C_PROPERTIES (ph5example STATIC " " " ")
- target_link_libraries (ph5example ${HDF5_LIB_TARGET} ${MPI_C_LIBRARIES})
+ target_include_directories (ph5example PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ if (NOT BUILD_SHARED_LIBS)
+ TARGET_C_PROPERTIES (ph5example STATIC)
+ target_link_libraries (ph5example PRIVATE ${HDF5_LIB_TARGET} ${MPI_C_LIBRARIES})
+ else ()
+ TARGET_C_PROPERTIES (ph5example SHARED)
+ target_link_libraries (ph5example PRIVATE ${HDF5_LIBSH_TARGET} ${MPI_C_LIBRARIES})
+ endif ()
set_target_properties (ph5example PROPERTIES FOLDER examples)
- if (BUILD_SHARED_LIBS)
- add_executable (ph5example-shared ${HDF5_EXAMPLES_SOURCE_DIR}/ph5example.c)
- TARGET_C_PROPERTIES (ph5example-shared SHARED " " " ")
- target_link_libraries (ph5example-shared ${HDF5_LIBSH_TARGET} ${MPI_C_LIBRARIES})
- set_target_properties (ph5example-shared PROPERTIES FOLDER examples)
+
+ #-----------------------------------------------------------------------------
+ # Add Target to clang-format
+ #-----------------------------------------------------------------------------
+ if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_EXAMPLES_ph5example_FORMAT ph5example)
endif ()
endif ()
-if (BUILD_TESTING)
+if (BUILD_TESTING AND HDF5_TEST_EXAMPLES)
include (CMakeTests.cmake)
endif ()
diff --git a/examples/CMakeTests.cmake b/examples/CMakeTests.cmake
index 592f762..d2b7e56 100644
--- a/examples/CMakeTests.cmake
+++ b/examples/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.
#
@@ -15,59 +15,56 @@
### T E S T I N G ###
##############################################################################
##############################################################################
- file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/red ${PROJECT_BINARY_DIR}/blue ${PROJECT_BINARY_DIR}/u2w)
- if (BUILD_SHARED_LIBS)
- file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5EX-shared")
- file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/H5EX-shared/red ${PROJECT_BINARY_DIR}/H5EX-shared/blue ${PROJECT_BINARY_DIR}/H5EX-shared/u2w)
- endif ()
+file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/red ${PROJECT_BINARY_DIR}/blue ${PROJECT_BINARY_DIR}/u2w)
+
+set (test_ex_CLEANFILES
+ Attributes.h5
+ btrees_file.h5
+ cmprss.h5
+ default_file.h5
+ dset.h5
+ extend.h5
+ extlink_prefix_source.h5
+ extlink_source.h5
+ extlink_target.h5
+ group.h5
+ groups.h5
+ hard_link.h5
+ mount1.h5
+ mount2.h5
+ one_index_file.h5
+ only_dspaces_and_attrs_file.h5
+ only_huge_mesgs_file.h5
+ REF_REG.h5
+ refere.h5
+ SDS.h5
+ SDScompound.h5
+ SDSextendible.h5
+ Select.h5
+ separate_indexes_file.h5
+ small_lists_file.h5
+ soft_link.h5
+ subset.h5
+ unix2win.h5
+ blue/prefix_target.h5
+ red/prefix_target.h5
+ u2w/u2w_target.h5
+)
+if (HDF5_TEST_SERIAL)
# Remove any output file left over from previous test run
add_test (
NAME EXAMPLES-clear-objects
- COMMAND ${CMAKE_COMMAND}
- -E remove
- Attributes.h5
- btrees_file.h5
- cmprss.h5
- default_file.h5
- dset.h5
- extend.h5
- extlink_prefix_source.h5
- extlink_source.h5
- extlink_target.h5
- group.h5
- groups.h5
- hard_link.h5
- mount1.h5
- mount2.h5
- one_index_file.h5
- only_dspaces_and_attrs_file.h5
- only_huge_mesgs_file.h5
- REF_REG.h5
- refere.h5
- SDS.h5
- SDScompound.h5
- SDSextendible.h5
- Select.h5
- separate_indexes_file.h5
- small_lists_file.h5
- soft_link.h5
- subset.h5
- unix2win.h5
- blue/prefix_target.h5
- red/prefix_target.h5
- u2w/u2w_target.h5
+ COMMAND ${CMAKE_COMMAND} -E remove ${test_ex_CLEANFILES}
)
- if (NOT "${last_test}" STREQUAL "")
- set_tests_properties (EXAMPLES-clear-objects PROPERTIES DEPENDS ${last_test})
- endif ()
- set (last_test "EXAMPLES-clear-objects")
+ set_tests_properties (EXAMPLES-clear-objects PROPERTIES FIXTURES_SETUP clear_EXAMPLES)
foreach (example ${examples})
if (HDF5_ENABLE_USING_MEMCHECKER)
- add_test (NAME EXAMPLES-${example} COMMAND $<TARGET_FILE:${example}>)
+ add_test (NAME EXAMPLES-${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:${example}>)
else ()
add_test (NAME EXAMPLES-${example} COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
-D "TEST_PROGRAM=$<TARGET_FILE:${example}>"
-D "TEST_ARGS:STRING="
-D "TEST_EXPECT=0"
@@ -78,119 +75,32 @@
-P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
)
endif ()
- if (NOT "${last_test}" STREQUAL "")
+ set_tests_properties (EXAMPLES-${example} PROPERTIES FIXTURES_REQUIRED clear_EXAMPLES)
+ if (last_test)
set_tests_properties (EXAMPLES-${example} PROPERTIES DEPENDS ${last_test})
endif ()
set (last_test "EXAMPLES-${example}")
endforeach ()
+endif ()
- if (BUILD_SHARED_LIBS)
- # Remove any output file left over from previous test run
- add_test (
- NAME EXAMPLES-shared-clear-objects
- COMMAND ${CMAKE_COMMAND}
- -E remove
- Attributes.h5
- btrees_file.h5
- cmprss.h5
- default_file.h5
- dset.h5
- extend.h5
- extlink_prefix_source.h5
- extlink_source.h5
- extlink_target.h5
- group.h5
- groups.h5
- hard_link.h5
- mount1.h5
- mount2.h5
- one_index_file.h5
- only_dspaces_and_attrs_file.h5
- only_huge_mesgs_file.h5
- REF_REG.h5
- refere.h5
- SDS.h5
- SDScompound.h5
- SDSextendible.h5
- Select.h5
- separate_indexes_file.h5
- small_lists_file.h5
- soft_link.h5
- subset.h5
- unix2win.h5
- blue/prefix_target.h5
- red/prefix_target.h5
- u2w/u2w_target.h5
- WORKING_DIRECTORY
- ${PROJECT_BINARY_DIR}/H5EX-shared
+### Windows pops up a modal permission dialog on this test
+if (H5_HAVE_PARALLEL AND HDF5_TEST_PARALLEL AND NOT WIN32)
+ if (HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (NAME MPI_TEST_EXAMPLES-ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $<TARGET_FILE:ph5example> ${MPIEXEC_POSTFLAGS})
+ else ()
+ add_test (NAME MPI_TEST_EXAMPLES-ph5example COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_PROGRAM=${MPIEXEC_EXECUTABLE};${MPIEXEC_NUMPROC_FLAG};${MPIEXEC_MAX_NUMPROCS};${MPIEXEC_PREFLAGS};$<TARGET_FILE:ph5example>;${MPIEXEC_POSTFLAGS}"
+ -D "TEST_ARGS:STRING="
+ -D "TEST_EXPECT=0"
+ -D "TEST_OUTPUT=ph5example.out"
+ -D "TEST_REFERENCE:STRING=PHDF5 tests finished with no errors"
+ -D "TEST_FILTER:STRING=PHDF5 tests finished with no errors"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
+ -P "${HDF_RESOURCES_EXT_DIR}/grepTest.cmake"
)
- if (NOT "${last_test}" STREQUAL "")
- set_tests_properties (EXAMPLES-shared-clear-objects PROPERTIES DEPENDS ${last_test})
- endif ()
- set (last_test "EXAMPLES-shared-clear-objects")
-
- foreach (example ${examples})
- if (HDF5_ENABLE_USING_MEMCHECKER)
- add_test (NAME EXAMPLES-shared-${example} COMMAND $<TARGET_FILE:${example}-shared>)
- else ()
- add_test (NAME EXAMPLES-shared-${example} COMMAND "${CMAKE_COMMAND}"
- -D "TEST_PROGRAM=$<TARGET_FILE:${example}>"
- -D "TEST_ARGS:STRING="
- -D "TEST_EXPECT=0"
- -D "TEST_SKIP_COMPARE=TRUE"
- -D "TEST_OUTPUT=${example}.txt"
- #-D "TEST_REFERENCE=${example}.out"
- -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5EX-shared"
- -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
- )
- endif ()
- set_tests_properties (EXAMPLES-shared-${example} PROPERTIES WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/H5EX-shared)
- if (NOT "${last_test}" STREQUAL "")
- set_tests_properties (EXAMPLES-shared-${example} PROPERTIES DEPENDS ${last_test})
- endif ()
- set (last_test "EXAMPLES-shared-${example}")
- endforeach ()
endif ()
-
-### Windows pops up a modal permission dialog on this test
- if (H5_HAVE_PARALLEL AND NOT WIN32)
- if (HDF5_ENABLE_USING_MEMCHECKER)
- add_test (NAME EXAMPLES-ph5example COMMAND $<TARGET_FILE:ph5example>)
- else ()
- add_test (NAME EXAMPLES-ph5example COMMAND "${CMAKE_COMMAND}"
- -D "TEST_PROGRAM=$<TARGET_FILE:ph5example>"
- -D "TEST_ARGS:STRING="
- -D "TEST_EXPECT=0"
- -D "TEST_SKIP_COMPARE=TRUE"
- -D "TEST_OUTPUT=ph5example.txt"
- #-D "TEST_REFERENCE=ph5example.out"
- -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
- -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
- )
- endif ()
- if (NOT "${last_test}" STREQUAL "")
- set_tests_properties (EXAMPLES-ph5example PROPERTIES DEPENDS ${last_test})
- endif ()
- set (last_test "EXAMPLES-ph5example")
- if (BUILD_SHARED_LIBS)
- if (HDF5_ENABLE_USING_MEMCHECKER)
- add_test (NAME EXAMPLES-shared-ph5example COMMAND $<TARGET_FILE:ph5example-shared>)
- else ()
- add_test (NAME EXAMPLES-shared-ph5example COMMAND "${CMAKE_COMMAND}"
- -D "TEST_PROGRAM=$<TARGET_FILE:ph5example-shared>"
- -D "TEST_ARGS:STRING="
- -D "TEST_EXPECT=0"
- -D "TEST_SKIP_COMPARE=TRUE"
- -D "TEST_OUTPUT=ph5example-shared.txt"
- #-D "TEST_REFERENCE=ph5example-shared.out"
- -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5EX-shared"
- -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
- )
- endif ()
- set_tests_properties (EXAMPLES-shared-ph5example PROPERTIES WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/H5EX-shared)
- if (NOT "${last_test}" STREQUAL "")
- set_tests_properties (EXAMPLES-shared-ph5example PROPERTIES DEPENDS ${last_test})
- endif ()
- set (last_test "EXAMPLES-shared-ph5example")
- endif ()
+ if (last_test)
+ set_tests_properties (MPI_TEST_EXAMPLES-ph5example PROPERTIES DEPENDS ${last_test})
endif ()
+ set (last_test "MPI_TEST_EXAMPLES-ph5example")
+endif ()
diff --git a/examples/Makefile.am b/examples/Makefile.am
index f737814..4f004bf 100644
--- a/examples/Makefile.am
+++ b/examples/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.
##
@@ -80,8 +80,8 @@ CHECK_CLEANFILES+=$(EXTLINK_DIRS)
# Example directory
# Note: no '/' after DESTDIR. Explanation in commence.am
-EXAMPLEDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples/c
-EXAMPLETOPDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples
+EXAMPLEDIR=$(examplesdir)/c
+EXAMPLETOPDIR=$(examplesdir)
# List dependencies for each program. Normally, automake would take
# care of this for us, but if we tell automake about the programs it
diff --git a/examples/Makefile.in b/examples/Makefile.in
index 76cf389..dfe4e14 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -22,7 +22,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
@@ -353,9 +353,9 @@ AMTAR = @AMTAR@
# AM_CFLAGS is an automake construct which should be used by Makefiles
# instead of CFLAGS, as CFLAGS is reserved solely for the user to define.
# This applies to FCFLAGS, CXXFLAGS, CPPFLAGS, and LDFLAGS as well.
-AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@
+AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ @H5_ECFLAGS@
AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@
-AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@
+AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ @H5_ECXXFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@
AM_LDFLAGS = @AM_LDFLAGS@ @H5_LDFLAGS@
@@ -370,6 +370,7 @@ CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_VERSION = @CC_VERSION@
CFLAGS = @CFLAGS@
+CLANG_SANITIZE_CHECKS = @CLANG_SANITIZE_CHECKS@
CLEARFILEBUF = @CLEARFILEBUF@
CODESTACK = @CODESTACK@
CONFIG_DATE = @CONFIG_DATE@
@@ -388,6 +389,7 @@ DEFAULT_API_VERSION = @DEFAULT_API_VERSION@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@
+DEV_WARNINGS = @DEV_WARNINGS@
DIRECT_VFD = @DIRECT_VFD@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
@@ -415,6 +417,8 @@ GREP = @GREP@
H5_CFLAGS = @H5_CFLAGS@
H5_CPPFLAGS = @H5_CPPFLAGS@
H5_CXXFLAGS = @H5_CXXFLAGS@
+H5_ECFLAGS = @H5_ECFLAGS@
+H5_ECXXFLAGS = @H5_ECXXFLAGS@
H5_FCFLAGS = @H5_FCFLAGS@
H5_FORTRAN_SHARED = @H5_FORTRAN_SHARED@
H5_LDFLAGS = @H5_LDFLAGS@
@@ -422,9 +426,12 @@ H5_VERSION = @H5_VERSION@
HADDR_T = @HADDR_T@
HAVE_DMALLOC = @HAVE_DMALLOC@
HAVE_FORTRAN_2003 = @HAVE_FORTRAN_2003@
+HAVE_LIBHDFS = @HAVE_LIBHDFS@
HAVE_PTHREAD = @HAVE_PTHREAD@
HDF5_HL = @HDF5_HL@
HDF5_INTERFACES = @HDF5_INTERFACES@
+HDF5_TESTS = @HDF5_TESTS@
+HDF5_TOOLS = @HDF5_TOOLS@
HDF_CXX = @HDF_CXX@
HDF_FORTRAN = @HDF_FORTRAN@
HDF_FORTRAN2003 = @HDF_FORTRAN2003@
@@ -440,6 +447,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INSTRUMENT = @INSTRUMENT@
INSTRUMENT_LIBRARY = @INSTRUMENT_LIBRARY@
+JNI_LDFLAGS = @JNI_LDFLAGS@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
@@ -461,6 +469,7 @@ NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJECT_NAMELEN_DEFAULT_F = @OBJECT_NAMELEN_DEFAULT_F@
OBJEXT = @OBJEXT@
+OPTIMIZATION = @OPTIMIZATION@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
@@ -473,8 +482,10 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PARALLEL = @PARALLEL@
PATH_SEPARATOR = @PATH_SEPARATOR@
PERL = @PERL@
+PROFILING = @PROFILING@
RANLIB = @RANLIB@
ROOT = @ROOT@
+ROS3_VFD = @ROS3_VFD@
RUNPARALLEL = @RUNPARALLEL@
RUNSERIAL = @RUNSERIAL@
R_INTEGER = @R_INTEGER@
@@ -488,6 +499,7 @@ STATIC_EXEC = @STATIC_EXEC@
STATIC_SHARED = @STATIC_SHARED@
STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@
STRIP = @STRIP@
+SYMBOLS = @SYMBOLS@
TESTPARALLEL = @TESTPARALLEL@
THREADSAFE = @THREADSAFE@
TIME = @TIME@
@@ -529,6 +541,7 @@ docdir = $(exec_prefix)/doc
dvidir = @dvidir@
enable_shared = @enable_shared@
enable_static = @enable_static@
+examplesdir = @examplesdir@
exec_prefix = @exec_prefix@
fortran_linux_linker_option = @fortran_linux_linker_option@
host = @host@
@@ -647,8 +660,8 @@ EXTLINK_DIRS = red blue u2w
# Example directory
# Note: no '/' after DESTDIR. Explanation in commence.am
-EXAMPLEDIR = ${DESTDIR}$(exec_prefix)/share/hdf5_examples/c
-EXAMPLETOPDIR = ${DESTDIR}$(exec_prefix)/share/hdf5_examples
+EXAMPLEDIR = $(examplesdir)/c
+EXAMPLETOPDIR = $(examplesdir)
@BUILD_SHARED_SZIP_CONDITIONAL_TRUE@LD_LIBRARY_PATH = $(LL_PATH)
# Assume that all tests in this directory are examples, and tell
@@ -659,11 +672,11 @@ EXTRA_PROG = $(EXAMPLE_PROG) $(EXAMPLE_PROG_PARA)
MOSTLYCLEANFILES = *.raw *.meta *.o
CLEANFILES = $(EXAMPLE_PROG) $(EXAMPLE_PROG_PARA)
-# Automake needs to be taught how to build lib, dyn, progs, and tests targets.
+# Automake needs to be taught how to build lib, progs and tests targets.
# These will be filled in automatically for the most part (e.g.,
# lib_LIBRARIES are built for lib target), but EXTRA_LIB, EXTRA_PROG, and
# EXTRA_TEST variables are supplied to allow the user to force targets to
-# be built at certain times.
+# be built at certain times.
LIB = $(lib_LIBRARIES) $(lib_LTLIBRARIES) $(noinst_LIBRARIES) \
$(noinst_LTLIBRARIES) $(check_LIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LIB)
@@ -1162,6 +1175,7 @@ installcheck-local:
(cd $(EXAMPLEDIR); \
/bin/sh ./$(TEST_EXAMPLES_SCRIPT);) \
fi
+
# lib/progs/tests targets recurse into subdirectories. build-* targets
# build files in this directory.
build-lib: $(LIB)
@@ -1197,7 +1211,7 @@ all-local: $(EXTRA_LIB) $(EXTRA_PROG) $(chk_TESTS)
# make install-doc doesn't do anything outside of doc directory, but
# Makefiles should recognize it.
# UPDATE: docs no longer reside in this build tree, so this target
-# is depreciated.
+# is deprecated.
install-doc uninstall-doc:
@echo "Nothing to be done."
@@ -1358,7 +1372,7 @@ build-check-p: $(LIB) $(PROGS) $(chk_TESTS)
echo "**** Hint ****"; \
echo "Parallel test files reside in the current directory" \
"by default."; \
- echo "Set HDF5_PARAPREFIX to use another directory. E.g.,"; \
+ echo "Set HDF5_PARAPREFIX to use another directory. e.g.,"; \
echo " HDF5_PARAPREFIX=/PFS/user/me"; \
echo " export HDF5_PARAPREFIX"; \
echo " make check"; \
diff --git a/examples/README b/examples/README
index 0550b15..e0a3364 100644
--- a/examples/README
+++ b/examples/README
@@ -2,7 +2,7 @@
This directory contains example programs for the installed APIs and scripts to
compile and run them. Examples in the c and hl/c subdirectories are always
-installed, and those in fortan, hl/fortran, c++ and hl/c++ will be installed
+installed, and those in fortran, hl/fortran, c++ and hl/c++ will be installed
when fortran or c++ are enabled.
Running the run-all-ex.sh script in this directory will run the scripts and in
diff --git a/examples/h5_attribute.c b/examples/h5_attribute.c
index 335f9c2..d88f589 100644
--- a/examples/h5_attribute.c
+++ b/examples/h5_attribute.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,193 +29,192 @@
#define H5FILE_NAME "Attributes.h5"
-#define RANK 1 /* Rank and size of the dataset */
-#define SIZE 7
+#define RANK 1 /* Rank and size of the dataset */
+#define SIZE 7
-#define ARANK 2 /* Rank and dimension sizes of the first dataset attribute */
+#define ARANK 2 /* Rank and dimension sizes of the first dataset attribute */
#define ADIM1 2
#define ADIM2 3
-#define ANAME "Float attribute" /* Name of the array attribute */
+#define ANAME "Float attribute" /* Name of the array attribute */
#define ANAMES "Character attribute" /* Name of the string attribute */
static herr_t attr_info(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *opdata);
- /* Operator function */
+/* Operator function */
int
-main (void)
+main(void)
{
- hid_t file, dataset; /* File and dataset identifiers */
-
- hid_t fid; /* Dataspace identifier */
- hid_t attr1, attr2, attr3; /* Attribute identifiers */
- hid_t attr;
- hid_t aid1, aid2, aid3; /* Attribute dataspace identifiers */
- hid_t atype, atype_mem; /* Attribute type */
- H5T_class_t type_class;
-
- hsize_t fdim[] = {SIZE};
- hsize_t adim[] = {ADIM1, ADIM2}; /* Dimensions of the first attribute */
-
- float matrix[ADIM1][ADIM2]; /* Attribute data */
-
- herr_t ret; /* Return value */
- H5O_info_t oinfo; /* Object info */
- unsigned i, j; /* Counters */
- char string_out[80]; /* Buffer to read string attribute back */
- int point_out; /* Buffer to read scalar attribute back */
-
- /*
- * Data initialization.
- */
- int vector[] = {1, 2, 3, 4, 5, 6, 7}; /* Dataset data */
- int point = 1; /* Value of the scalar attribute */
- char string[] = "ABCD"; /* Value of the string attribute */
-
-
- for (i=0; i < ADIM1; i++) { /* Values of the array attribute */
- for (j=0; j < ADIM2; j++)
- matrix[i][j] = -1.;
- }
-
- /*
- * Create a file.
- */
- file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
- /*
- * Create the dataspace for the dataset in the file.
- */
- fid = H5Screate(H5S_SIMPLE);
- ret = H5Sset_extent_simple(fid, RANK, fdim, NULL);
-
- /*
- * Create the dataset in the file.
- */
- dataset = H5Dcreate2(file, "Dataset", H5T_NATIVE_INT, fid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
-
- /*
- * Write data to the dataset.
- */
- ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT, vector);
-
- /*
- * Create dataspace for the first attribute.
- */
- aid1 = H5Screate(H5S_SIMPLE);
- ret = H5Sset_extent_simple(aid1, ARANK, adim, NULL);
-
- /*
- * Create array attribute.
- */
- attr1 = H5Acreate2(dataset, ANAME, H5T_NATIVE_FLOAT, aid1, H5P_DEFAULT, H5P_DEFAULT);
-
- /*
- * Write array attribute.
- */
- ret = H5Awrite(attr1, H5T_NATIVE_FLOAT, matrix);
-
- /*
- * Create scalar attribute.
- */
- aid2 = H5Screate(H5S_SCALAR);
- attr2 = H5Acreate2(dataset, "Integer attribute", H5T_NATIVE_INT, aid2,
- H5P_DEFAULT, H5P_DEFAULT);
-
- /*
- * Write scalar attribute.
- */
- ret = H5Awrite(attr2, H5T_NATIVE_INT, &point);
-
- /*
- * Create string attribute.
- */
- aid3 = H5Screate(H5S_SCALAR);
- atype = H5Tcopy(H5T_C_S1);
- H5Tset_size(atype, 5);
- H5Tset_strpad(atype,H5T_STR_NULLTERM);
- attr3 = H5Acreate2(dataset, ANAMES, atype, aid3, H5P_DEFAULT, H5P_DEFAULT);
-
- /*
- * Write string attribute.
- */
- ret = H5Awrite(attr3, atype, string);
-
- /*
- * Close attribute and file dataspaces, and datatype.
- */
- ret = H5Sclose(aid1);
- ret = H5Sclose(aid2);
- ret = H5Sclose(aid3);
- ret = H5Sclose(fid);
- ret = H5Tclose(atype);
-
- /*
- * Close the attributes.
- */
- ret = H5Aclose(attr1);
- ret = H5Aclose(attr2);
- ret = H5Aclose(attr3);
-
- /*
- * Close the dataset.
- */
- ret = H5Dclose(dataset);
-
- /*
- * Close the file.
- */
- ret = H5Fclose(file);
-
- /*
- * Reopen the file.
- */
- file = H5Fopen(H5FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT);
-
- /*
- * Open the dataset.
- */
- dataset = H5Dopen2(file, "Dataset", H5P_DEFAULT);
-
- /*
- * Attach to the scalar attribute using attribute name, then read and
- * display its value.
- */
- attr = H5Aopen(dataset, "Integer attribute", H5P_DEFAULT);
- ret = H5Aread(attr, H5T_NATIVE_INT, &point_out);
- printf("The value of the attribute \"Integer attribute\" is %d \n", point_out);
- ret = H5Aclose(attr);
-
- /*
- * Find string attribute by iterating through all attributes
- */
- ret = H5Oget_info(dataset, &oinfo);
- for(i = 0; i < (unsigned)oinfo.num_attrs; i++) {
- attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)i, H5P_DEFAULT, H5P_DEFAULT);
- atype = H5Aget_type(attr);
- type_class = H5Tget_class(atype);
- if (type_class == H5T_STRING) {
- atype_mem = H5Tget_native_type(atype, H5T_DIR_ASCEND);
- ret = H5Aread(attr, atype_mem, string_out);
- printf("Found string attribute; its index is %d , value = %s \n", i, string_out);
- ret = H5Tclose(atype_mem);
- }
- ret = H5Aclose(attr);
- ret = H5Tclose(atype);
+ hid_t file, dataset; /* File and dataset identifiers */
+
+ hid_t fid; /* Dataspace identifier */
+ hid_t attr1, attr2, attr3; /* Attribute identifiers */
+ hid_t attr;
+ hid_t aid1, aid2, aid3; /* Attribute dataspace identifiers */
+ hid_t atype, atype_mem; /* Attribute type */
+ H5T_class_t type_class;
+
+ hsize_t fdim[] = {SIZE};
+ hsize_t adim[] = {ADIM1, ADIM2}; /* Dimensions of the first attribute */
+
+ float matrix[ADIM1][ADIM2]; /* Attribute data */
+
+ herr_t ret; /* Return value */
+ H5O_info_t oinfo; /* Object info */
+ unsigned i, j; /* Counters */
+ char string_out[80]; /* Buffer to read string attribute back */
+ int point_out; /* Buffer to read scalar attribute back */
+
+ /*
+ * Data initialization.
+ */
+ int vector[] = {1, 2, 3, 4, 5, 6, 7}; /* Dataset data */
+ int point = 1; /* Value of the scalar attribute */
+ char string[] = "ABCD"; /* Value of the string attribute */
+
+ for (i = 0; i < ADIM1; i++) { /* Values of the array attribute */
+ for (j = 0; j < ADIM2; j++)
+ matrix[i][j] = -1.;
+ }
+
+ /*
+ * Create a file.
+ */
+ file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Create the dataspace for the dataset in the file.
+ */
+ fid = H5Screate(H5S_SIMPLE);
+ ret = H5Sset_extent_simple(fid, RANK, fdim, NULL);
+
+ /*
+ * Create the dataset in the file.
+ */
+ dataset = H5Dcreate2(file, "Dataset", H5T_NATIVE_INT, fid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Write data to the dataset.
+ */
+ ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, vector);
+
+ /*
+ * Create dataspace for the first attribute.
+ */
+ aid1 = H5Screate(H5S_SIMPLE);
+ ret = H5Sset_extent_simple(aid1, ARANK, adim, NULL);
+
+ /*
+ * Create array attribute.
+ */
+ attr1 = H5Acreate2(dataset, ANAME, H5T_NATIVE_FLOAT, aid1, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Write array attribute.
+ */
+ ret = H5Awrite(attr1, H5T_NATIVE_FLOAT, matrix);
+
+ /*
+ * Create scalar attribute.
+ */
+ aid2 = H5Screate(H5S_SCALAR);
+ attr2 = H5Acreate2(dataset, "Integer attribute", H5T_NATIVE_INT, aid2, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Write scalar attribute.
+ */
+ ret = H5Awrite(attr2, H5T_NATIVE_INT, &point);
+
+ /*
+ * Create string attribute.
+ */
+ aid3 = H5Screate(H5S_SCALAR);
+ atype = H5Tcopy(H5T_C_S1);
+ H5Tset_size(atype, 5);
+ H5Tset_strpad(atype, H5T_STR_NULLTERM);
+ attr3 = H5Acreate2(dataset, ANAMES, atype, aid3, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Write string attribute.
+ */
+ ret = H5Awrite(attr3, atype, string);
+
+ /*
+ * Close attribute and file dataspaces, and datatype.
+ */
+ ret = H5Sclose(aid1);
+ ret = H5Sclose(aid2);
+ ret = H5Sclose(aid3);
+ ret = H5Sclose(fid);
+ ret = H5Tclose(atype);
+
+ /*
+ * Close the attributes.
+ */
+ ret = H5Aclose(attr1);
+ ret = H5Aclose(attr2);
+ ret = H5Aclose(attr3);
+
+ /*
+ * Close the dataset.
+ */
+ ret = H5Dclose(dataset);
+
+ /*
+ * Close the file.
+ */
+ ret = H5Fclose(file);
+
+ /*
+ * Reopen the file.
+ */
+ file = H5Fopen(H5FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT);
+
+ /*
+ * Open the dataset.
+ */
+ dataset = H5Dopen2(file, "Dataset", H5P_DEFAULT);
+
+ /*
+ * Attach to the scalar attribute using attribute name, then read and
+ * display its value.
+ */
+ attr = H5Aopen(dataset, "Integer attribute", H5P_DEFAULT);
+ ret = H5Aread(attr, H5T_NATIVE_INT, &point_out);
+ printf("The value of the attribute \"Integer attribute\" is %d \n", point_out);
+ ret = H5Aclose(attr);
+
+ /*
+ * Find string attribute by iterating through all attributes
+ */
+ ret = H5Oget_info(dataset, &oinfo);
+ for (i = 0; i < (unsigned)oinfo.num_attrs; i++) {
+ attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)i, H5P_DEFAULT,
+ H5P_DEFAULT);
+ atype = H5Aget_type(attr);
+ type_class = H5Tget_class(atype);
+ if (type_class == H5T_STRING) {
+ atype_mem = H5Tget_native_type(atype, H5T_DIR_ASCEND);
+ ret = H5Aread(attr, atype_mem, string_out);
+ printf("Found string attribute; its index is %d , value = %s \n", i, string_out);
+ ret = H5Tclose(atype_mem);
+ }
+ ret = H5Aclose(attr);
+ ret = H5Tclose(atype);
}
- /*
- * Get attribute info using iteration function.
- */
+ /*
+ * Get attribute info using iteration function.
+ */
ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_info, NULL);
- /*
- * Close the dataset and the file.
- */
- H5Dclose(dataset);
- H5Fclose(file);
+ /*
+ * Close the dataset and the file.
+ */
+ H5Dclose(dataset);
+ H5Fclose(file);
- return 0;
+ return 0;
}
/*
@@ -224,13 +223,13 @@ main (void)
static herr_t
attr_info(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *opdata)
{
- hid_t attr, atype, aspace; /* Attribute, datatype and dataspace identifiers */
- int rank;
+ hid_t attr, atype, aspace; /* Attribute, datatype and dataspace identifiers */
+ int rank;
hsize_t sdim[64];
- herr_t ret;
- int i;
- size_t npoints; /* Number of elements in the array attribute. */
- float *float_array; /* Pointer to the array attribute. */
+ herr_t ret;
+ int i;
+ size_t npoints; /* Number of elements in the array attribute. */
+ float * float_array; /* Pointer to the array attribute. */
/* avoid warnings */
opdata = opdata;
@@ -250,17 +249,17 @@ attr_info(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *opdata)
*/
atype = H5Aget_type(attr);
aspace = H5Aget_space(attr);
- rank = H5Sget_simple_extent_ndims(aspace);
- ret = H5Sget_simple_extent_dims(aspace, sdim, NULL);
+ rank = H5Sget_simple_extent_ndims(aspace);
+ ret = H5Sget_simple_extent_dims(aspace, sdim, NULL);
/*
* Display rank and dimension sizes for the array attribute.
*/
- if(rank > 0) {
+ if (rank > 0) {
printf("Rank : %d \n", rank);
printf("Dimension sizes : ");
- for (i=0; i< rank; i++)
+ for (i = 0; i < rank; i++)
printf("%d ", (int)sdim[i]);
printf("\n");
}
@@ -271,11 +270,11 @@ attr_info(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *opdata)
if (H5T_FLOAT == H5Tget_class(atype)) {
printf("Type : FLOAT \n");
- npoints = H5Sget_simple_extent_npoints(aspace);
- float_array = (float *)malloc(sizeof(float)*(int)npoints);
- ret = H5Aread(attr, atype, float_array);
+ npoints = H5Sget_simple_extent_npoints(aspace);
+ float_array = (float *)malloc(sizeof(float) * (int)npoints);
+ ret = H5Aread(attr, atype, float_array);
printf("Values : ");
- for( i = 0; i < (int)npoints; i++)
+ for (i = 0; i < (int)npoints; i++)
printf("%f ", float_array[i]);
printf("\n");
free(float_array);
@@ -290,4 +289,3 @@ attr_info(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *opdata)
return 0;
}
-
diff --git a/examples/h5_chunk_read.c b/examples/h5_chunk_read.c
index c3455f4..408a844 100644
--- a/examples/h5_chunk_read.c
+++ b/examples/h5_chunk_read.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,68 +18,66 @@
#include "hdf5.h"
-#define H5FILE_NAME "SDSextendible.h5"
+#define H5FILE_NAME "SDSextendible.h5"
#define DATASETNAME "ExtendibleArray"
-#define RANK 2
-#define RANKC 1
-#define NX 10
-#define NY 5
+#define RANK 2
+#define RANKC 1
+#define NX 10
+#define NY 5
int
-main (void)
+main(void)
{
- hid_t file; /* handles */
- hid_t dataset;
- hid_t filespace;
- hid_t memspace;
- hid_t cparms;
- hsize_t dims[2]; /* dataset and chunk dimensions*/
- hsize_t chunk_dims[2];
- hsize_t col_dims[1];
- hsize_t count[2];
- hsize_t offset[2];
-
- herr_t status, status_n;
-
- int data_out[NX][NY]; /* buffer for dataset to be read */
- int chunk_out[2][5]; /* buffer for chunk to be read */
- int column[10]; /* buffer for column to be read */
- int rank, rank_chunk;
- int i, j;
-
-
+ hid_t file; /* handles */
+ hid_t dataset;
+ hid_t filespace;
+ hid_t memspace;
+ hid_t cparms;
+ hsize_t dims[2]; /* dataset and chunk dimensions*/
+ hsize_t chunk_dims[2];
+ hsize_t col_dims[1];
+ hsize_t count[2];
+ hsize_t offset[2];
+
+ herr_t status, status_n;
+
+ int data_out[NX][NY]; /* buffer for dataset to be read */
+ int chunk_out[2][5]; /* buffer for chunk to be read */
+ int column[10]; /* buffer for column to be read */
+ int rank, rank_chunk;
+ int i, j;
/*
* Open the file and the dataset.
*/
- file = H5Fopen(H5FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT);
+ file = H5Fopen(H5FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT);
dataset = H5Dopen2(file, DATASETNAME, H5P_DEFAULT);
/*
* Get dataset rank and dimension.
*/
- filespace = H5Dget_space(dataset); /* Get filespace handle first. */
+ filespace = H5Dget_space(dataset); /* Get filespace handle first. */
rank = H5Sget_simple_extent_ndims(filespace);
status_n = H5Sget_simple_extent_dims(filespace, dims, NULL);
- printf("dataset rank %d, dimensions %lu x %lu\n",
- rank, (unsigned long)(dims[0]), (unsigned long)(dims[1]));
+ printf("dataset rank %d, dimensions %lu x %lu\n", rank, (unsigned long)(dims[0]),
+ (unsigned long)(dims[1]));
/*
* Define the memory space to read dataset.
*/
- memspace = H5Screate_simple(RANK,dims,NULL);
+ memspace = H5Screate_simple(RANK, dims, NULL);
/*
* Read dataset back and display.
*/
- status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace,
- H5P_DEFAULT, data_out);
+ status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, data_out);
printf("\n");
printf("Dataset: \n");
for (j = 0; j < dims[0]; j++) {
- for (i = 0; i < dims[1]; i++) printf("%d ", data_out[j][i]);
- printf("\n");
+ for (i = 0; i < dims[1]; i++)
+ printf("%d ", data_out[j][i]);
+ printf("\n");
}
/*
@@ -110,7 +108,7 @@ main (void)
* and read it into column array.
*/
col_dims[0] = 10;
- memspace = H5Screate_simple(RANKC, col_dims, NULL);
+ memspace = H5Screate_simple(RANKC, col_dims, NULL);
/*
* Define the column (hyperslab) to read.
@@ -119,14 +117,12 @@ main (void)
offset[1] = 2;
count[0] = 10;
count[1] = 1;
- status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
- count, NULL);
- status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace,
- H5P_DEFAULT, column);
+ status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, count, NULL);
+ status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, column);
printf("\n");
printf("Third column: \n");
for (i = 0; i < 10; i++) {
- printf("%d \n", column[i]);
+ printf("%d \n", column[i]);
}
/*
@@ -153,19 +149,19 @@ main (void)
*/
cparms = H5Dget_create_plist(dataset); /* Get properties handle first. */
- if (H5D_CHUNKED == H5Pget_layout(cparms)) {
+ if (H5D_CHUNKED == H5Pget_layout(cparms)) {
- /*
- * Get chunking information: rank and dimensions
- */
- rank_chunk = H5Pget_chunk(cparms, 2, chunk_dims);
- printf("chunk rank %d, dimensions %lu x %lu\n", rank_chunk,
- (unsigned long)(chunk_dims[0]), (unsigned long)(chunk_dims[1]));
+ /*
+ * Get chunking information: rank and dimensions
+ */
+ rank_chunk = H5Pget_chunk(cparms, 2, chunk_dims);
+ printf("chunk rank %d, dimensions %lu x %lu\n", rank_chunk, (unsigned long)(chunk_dims[0]),
+ (unsigned long)(chunk_dims[1]));
/*
* Define the memory space to read a chunk.
*/
- memspace = H5Screate_simple(rank_chunk,chunk_dims,NULL);
+ memspace = H5Screate_simple(rank_chunk, chunk_dims, NULL);
/*
* Define chunk in the file (hyperslab) to read.
@@ -174,18 +170,17 @@ main (void)
offset[1] = 0;
count[0] = chunk_dims[0];
count[1] = chunk_dims[1];
- status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
- count, NULL);
+ status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, count, NULL);
/*
* Read chunk back and display.
*/
- status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace,
- H5P_DEFAULT, chunk_out);
+ status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, chunk_out);
printf("\n");
printf("Chunk: \n");
for (j = 0; j < chunk_dims[0]; j++) {
- for (i = 0; i < chunk_dims[1]; i++) printf("%d ", chunk_out[j][i]);
+ for (i = 0; i < chunk_dims[1]; i++)
+ printf("%d ", chunk_out[j][i]);
printf("\n");
}
/*
diff --git a/examples/h5_cmprss.c b/examples/h5_cmprss.c
index ebc7712..59a59f5 100644
--- a/examples/h5_cmprss.c
+++ b/examples/h5_cmprss.c
@@ -6,118 +6,116 @@
* 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 example illustrates how to create a compressed dataset.
* It is used in the HDF5 Tutorial.
- */
+ */
#include "hdf5.h"
-#define FILE "cmprss.h5"
-#define RANK 2
-#define DIM0 100
-#define DIM1 20
-
-int main () {
+#define FILE "cmprss.h5"
+#define RANK 2
+#define DIM0 100
+#define DIM1 20
- hid_t file_id, dataset_id, dataspace_id; /* identifiers */
- hid_t plist_id;
+int
+main()
+{
- size_t nelmts;
- unsigned flags, filter_info;
+ hid_t file_id, dataset_id, dataspace_id; /* identifiers */
+ hid_t plist_id;
+
+ size_t nelmts;
+ unsigned flags, filter_info;
H5Z_filter_t filter_type;
- herr_t status;
- hsize_t dims[2];
- hsize_t cdims[2];
-
- int idx;
- int i,j, numfilt;
- int buf[DIM0][DIM1];
- int rbuf [DIM0][DIM1];
+ herr_t status;
+ hsize_t dims[2];
+ hsize_t cdims[2];
+
+ int i, j, numfilt;
+ int buf[DIM0][DIM1];
+ int rbuf[DIM0][DIM1];
- /* Uncomment these variables to use SZIP compression
+ /* Uncomment these variables to use SZIP compression
unsigned szip_options_mask;
unsigned szip_pixels_per_block;
*/
/* Create a file. */
- file_id = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
+ file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/* Create dataset "Compressed Data" in the group using absolute name. */
- dims[0] = DIM0;
- dims[1] = DIM1;
- dataspace_id = H5Screate_simple (RANK, dims, NULL);
+ dims[0] = DIM0;
+ dims[1] = DIM1;
+ dataspace_id = H5Screate_simple(RANK, dims, NULL);
- plist_id = H5Pcreate (H5P_DATASET_CREATE);
+ plist_id = H5Pcreate(H5P_DATASET_CREATE);
/* Dataset must be chunked for compression */
cdims[0] = 20;
cdims[1] = 20;
- status = H5Pset_chunk (plist_id, 2, cdims);
+ status = H5Pset_chunk(plist_id, 2, cdims);
/* Set ZLIB / DEFLATE Compression using compression level 6.
- * To use SZIP Compression comment out these lines.
- */
- status = H5Pset_deflate (plist_id, 6);
+ * To use SZIP Compression comment out these lines.
+ */
+ status = H5Pset_deflate(plist_id, 6);
- /* Uncomment these lines to set SZIP Compression
+ /* Uncomment these lines to set SZIP Compression
szip_options_mask = H5_SZIP_NN_OPTION_MASK;
szip_pixels_per_block = 16;
status = H5Pset_szip (plist_id, szip_options_mask, szip_pixels_per_block);
*/
-
- dataset_id = H5Dcreate2 (file_id, "Compressed_Data", H5T_STD_I32BE,
- dataspace_id, H5P_DEFAULT, plist_id, H5P_DEFAULT);
- for (i = 0; i< DIM0; i++)
- for (j=0; j<DIM1; j++)
- buf[i][j] = i+j;
+ dataset_id = H5Dcreate2(file_id, "Compressed_Data", H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, plist_id,
+ H5P_DEFAULT);
- status = H5Dwrite (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
+ for (i = 0; i < DIM0; i++)
+ for (j = 0; j < DIM1; j++)
+ buf[i][j] = i + j;
- status = H5Sclose (dataspace_id);
- status = H5Dclose (dataset_id);
- status = H5Pclose (plist_id);
- status = H5Fclose (file_id);
+ status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
+
+ status = H5Sclose(dataspace_id);
+ status = H5Dclose(dataset_id);
+ status = H5Pclose(plist_id);
+ status = H5Fclose(file_id);
/* Now reopen the file and dataset in the file. */
- file_id = H5Fopen (FILE, H5F_ACC_RDWR, H5P_DEFAULT);
- dataset_id = H5Dopen2 (file_id, "Compressed_Data", H5P_DEFAULT);
+ file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT);
+ dataset_id = H5Dopen2(file_id, "Compressed_Data", H5P_DEFAULT);
/* Retrieve filter information. */
- plist_id = H5Dget_create_plist (dataset_id);
-
- numfilt = H5Pget_nfilters (plist_id);
- printf ("Number of filters associated with dataset: %i\n", numfilt);
-
- for (i=0; i<numfilt; i++) {
- nelmts = 0;
- filter_type = H5Pget_filter2 (plist_id, 0, &flags, &nelmts, NULL, 0, NULL,
- &filter_info);
- printf ("Filter Type: ");
- switch (filter_type) {
- case H5Z_FILTER_DEFLATE:
- printf ("H5Z_FILTER_DEFLATE\n");
- break;
- case H5Z_FILTER_SZIP:
- printf ("H5Z_FILTER_SZIP\n");
- break;
- default:
- printf ("Other filter type included.\n");
- }
+ plist_id = H5Dget_create_plist(dataset_id);
+
+ numfilt = H5Pget_nfilters(plist_id);
+ printf("Number of filters associated with dataset: %i\n", numfilt);
+
+ for (i = 0; i < numfilt; i++) {
+ nelmts = 0;
+ filter_type = H5Pget_filter2(plist_id, 0, &flags, &nelmts, NULL, 0, NULL, &filter_info);
+ printf("Filter Type: ");
+ switch (filter_type) {
+ case H5Z_FILTER_DEFLATE:
+ printf("H5Z_FILTER_DEFLATE\n");
+ break;
+ case H5Z_FILTER_SZIP:
+ printf("H5Z_FILTER_SZIP\n");
+ break;
+ default:
+ printf("Other filter type included.\n");
+ }
}
- status = H5Dread (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- H5P_DEFAULT, rbuf);
-
- status = H5Dclose (dataset_id);
- status = H5Pclose (plist_id);
- status = H5Fclose (file_id);
+ status = H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf);
+
+ status = H5Dclose(dataset_id);
+ status = H5Pclose(plist_id);
+ status = H5Fclose(file_id);
}
diff --git a/examples/h5_compound.c b/examples/h5_compound.c
index b3b3a4a..093852d 100644
--- a/examples/h5_compound.c
+++ b/examples/h5_compound.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,10 +19,10 @@
#include "hdf5.h"
-#define H5FILE_NAME "SDScompound.h5"
-#define DATASETNAME "ArrayOfStructures"
-#define LENGTH 10
-#define RANK 1
+#define H5FILE_NAME "SDScompound.h5"
+#define DATASETNAME "ArrayOfStructures"
+#define LENGTH 10
+#define RANK 1
int
main(void)
@@ -30,38 +30,37 @@ main(void)
/* First structure and dataset*/
typedef struct s1_t {
- int a;
- float b;
- double c;
+ int a;
+ float b;
+ double c;
} s1_t;
- s1_t s1[LENGTH];
- hid_t s1_tid; /* File datatype identifier */
+ s1_t s1[LENGTH];
+ hid_t s1_tid; /* File datatype identifier */
/* Second structure (subset of s1_t) and dataset*/
typedef struct s2_t {
- double c;
- int a;
+ double c;
+ int a;
} s2_t;
- s2_t s2[LENGTH];
- hid_t s2_tid; /* Memory datatype handle */
+ s2_t s2[LENGTH];
+ hid_t s2_tid; /* Memory datatype handle */
/* Third "structure" ( will be used to read float field of s1) */
- hid_t s3_tid; /* Memory datatype handle */
- float s3[LENGTH];
-
- int i;
- hid_t file, dataset, space; /* Handles */
- herr_t status;
- hsize_t dim[] = {LENGTH}; /* Dataspace dimensions */
+ hid_t s3_tid; /* Memory datatype handle */
+ float s3[LENGTH];
+ int i;
+ hid_t file, dataset, space; /* Handles */
+ herr_t status;
+ hsize_t dim[] = {LENGTH}; /* Dataspace dimensions */
/*
* Initialize the data
*/
- for (i = 0; i< LENGTH; i++) {
+ for (i = 0; i < LENGTH; i++) {
s1[i].a = i;
- s1[i].b = i*i;
- s1[i].c = 1./(i+1);
+ s1[i].b = i * i;
+ s1[i].c = 1. / (i + 1);
}
/*
@@ -77,7 +76,7 @@ main(void)
/*
* Create the memory data type.
*/
- s1_tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t));
+ s1_tid = H5Tcreate(H5T_COMPOUND, sizeof(s1_t));
H5Tinsert(s1_tid, "a_name", HOFFSET(s1_t, a), H5T_NATIVE_INT);
H5Tinsert(s1_tid, "c_name", HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE);
H5Tinsert(s1_tid, "b_name", HOFFSET(s1_t, b), H5T_NATIVE_FLOAT);
@@ -126,12 +125,14 @@ main(void)
*/
printf("\n");
printf("Field c : \n");
- for( i = 0; i < LENGTH; i++) printf("%.4f ", s2[i].c);
+ for (i = 0; i < LENGTH; i++)
+ printf("%.4f ", s2[i].c);
printf("\n");
printf("\n");
printf("Field a : \n");
- for( i = 0; i < LENGTH; i++) printf("%d ", s2[i].a);
+ for (i = 0; i < LENGTH; i++)
+ printf("%d ", s2[i].a);
printf("\n");
/*
@@ -151,7 +152,8 @@ main(void)
*/
printf("\n");
printf("Field b : \n");
- for( i = 0; i < LENGTH; i++) printf("%.4f ", s3[i]);
+ for (i = 0; i < LENGTH; i++)
+ printf("%.4f ", s3[i]);
printf("\n");
/*
diff --git a/examples/h5_crtatt.c b/examples/h5_crtatt.c
index ade17ba..3edc75d 100644
--- a/examples/h5_crtatt.c
+++ b/examples/h5_crtatt.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,43 +19,44 @@
#include "hdf5.h"
#define FILE "dset.h5"
-int main() {
+int
+main()
+{
- hid_t file_id, dataset_id, attribute_id, dataspace_id; /* identifiers */
- hsize_t dims;
- int attr_data[2];
- herr_t status;
+ hid_t file_id, dataset_id, attribute_id, dataspace_id; /* identifiers */
+ hsize_t dims;
+ int attr_data[2];
+ herr_t status;
- /* Initialize the attribute data. */
- attr_data[0] = 100;
- attr_data[1] = 200;
+ /* Initialize the attribute data. */
+ attr_data[0] = 100;
+ attr_data[1] = 200;
- /* Open an existing file. */
- file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT);
+ /* Open an existing file. */
+ file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT);
- /* Open an existing dataset. */
- dataset_id = H5Dopen2(file_id, "/dset", H5P_DEFAULT);
+ /* Open an existing dataset. */
+ dataset_id = H5Dopen2(file_id, "/dset", H5P_DEFAULT);
- /* Create the data space for the attribute. */
- dims = 2;
- dataspace_id = H5Screate_simple(1, &dims, NULL);
+ /* Create the data space for the attribute. */
+ dims = 2;
+ dataspace_id = H5Screate_simple(1, &dims, NULL);
- /* Create a dataset attribute. */
- attribute_id = H5Acreate2 (dataset_id, "Units", H5T_STD_I32BE, dataspace_id,
- H5P_DEFAULT, H5P_DEFAULT);
+ /* Create a dataset attribute. */
+ attribute_id = H5Acreate2(dataset_id, "Units", H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT);
- /* Write the attribute data. */
- status = H5Awrite(attribute_id, H5T_NATIVE_INT, attr_data);
+ /* Write the attribute data. */
+ status = H5Awrite(attribute_id, H5T_NATIVE_INT, attr_data);
- /* Close the attribute. */
- status = H5Aclose(attribute_id);
+ /* Close the attribute. */
+ status = H5Aclose(attribute_id);
- /* Close the dataspace. */
- status = H5Sclose(dataspace_id);
+ /* Close the dataspace. */
+ status = H5Sclose(dataspace_id);
- /* Close to the dataset. */
- status = H5Dclose(dataset_id);
+ /* Close to the dataset. */
+ status = H5Dclose(dataset_id);
- /* Close the file. */
- status = H5Fclose(file_id);
+ /* Close the file. */
+ status = H5Fclose(file_id);
}
diff --git a/examples/h5_crtdat.c b/examples/h5_crtdat.c
index 4a876d2..4450367 100644
--- a/examples/h5_crtdat.c
+++ b/examples/h5_crtdat.c
@@ -6,44 +6,45 @@
* 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 example illustrates how to create a dataset that is a 4 x 6
+ * This example illustrates how to create a dataset that is a 4 x 6
* array. It is used in the HDF5 Tutorial.
*/
#include "hdf5.h"
#define FILE "dset.h5"
-int main() {
+int
+main()
+{
- hid_t file_id, dataset_id, dataspace_id; /* identifiers */
- hsize_t dims[2];
- herr_t status;
+ hid_t file_id, dataset_id, dataspace_id; /* identifiers */
+ hsize_t dims[2];
+ herr_t status;
- /* Create a new file using default properties. */
- file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ /* Create a new file using default properties. */
+ file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- /* Create the data space for the dataset. */
- dims[0] = 4;
- dims[1] = 6;
- dataspace_id = H5Screate_simple(2, dims, NULL);
+ /* Create the data space for the dataset. */
+ dims[0] = 4;
+ dims[1] = 6;
+ dataspace_id = H5Screate_simple(2, dims, NULL);
- /* Create the dataset. */
- dataset_id = H5Dcreate2(file_id, "/dset", H5T_STD_I32BE, dataspace_id,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ /* Create the dataset. */
+ dataset_id =
+ H5Dcreate2(file_id, "/dset", H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- /* End access to the dataset and release resources used by it. */
- status = H5Dclose(dataset_id);
+ /* End access to the dataset and release resources used by it. */
+ status = H5Dclose(dataset_id);
- /* Terminate access to the data space. */
- status = H5Sclose(dataspace_id);
+ /* Terminate access to the data space. */
+ status = H5Sclose(dataspace_id);
- /* Close the file. */
- status = H5Fclose(file_id);
+ /* Close the file. */
+ status = H5Fclose(file_id);
}
-
diff --git a/examples/h5_crtgrp.c b/examples/h5_crtgrp.c
index 89bddce..abddf09 100644
--- a/examples/h5_crtgrp.c
+++ b/examples/h5_crtgrp.c
@@ -6,33 +6,35 @@
* 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 example illustrates how to create and close a group.
+ * This example illustrates how to create and close a group.
* It is used in the HDF5 Tutorial.
*/
#include "hdf5.h"
#define FILE "group.h5"
-int main() {
+int
+main()
+{
- hid_t file_id, group_id; /* identifiers */
- herr_t status;
+ hid_t file_id, group_id; /* identifiers */
+ herr_t status;
- /* Create a new file using default properties. */
- file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ /* Create a new file using default properties. */
+ file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- /* Create a group named "/MyGroup" in the file. */
- group_id = H5Gcreate2(file_id, "/MyGroup", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ /* Create a group named "/MyGroup" in the file. */
+ group_id = H5Gcreate2(file_id, "/MyGroup", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- /* Close the group. */
- status = H5Gclose(group_id);
+ /* Close the group. */
+ status = H5Gclose(group_id);
- /* Terminate access to the file. */
- status = H5Fclose(file_id);
+ /* Terminate access to the file. */
+ status = H5Fclose(file_id);
}
diff --git a/examples/h5_crtgrpar.c b/examples/h5_crtgrpar.c
index 6f8c6e8..a4d5f38 100644
--- a/examples/h5_crtgrpar.c
+++ b/examples/h5_crtgrpar.c
@@ -6,41 +6,43 @@
* 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 example illustrates the creation of groups using absolute and
+ * This example illustrates the creation of groups using absolute and
* relative names. It is used in the HDF5 Tutorial.
*/
#include "hdf5.h"
#define FILE "groups.h5"
-int main() {
+int
+main()
+{
- hid_t file_id, group1_id, group2_id, group3_id; /* identifiers */
- herr_t status;
+ hid_t file_id, group1_id, group2_id, group3_id; /* identifiers */
+ herr_t status;
- /* Create a new file using default properties. */
- file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ /* Create a new file using default properties. */
+ file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- /* Create group "MyGroup" in the root group using absolute name. */
- group1_id = H5Gcreate2(file_id, "/MyGroup", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ /* Create group "MyGroup" in the root group using absolute name. */
+ group1_id = H5Gcreate2(file_id, "/MyGroup", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- /* Create group "Group_A" in group "MyGroup" using absolute name. */
- group2_id = H5Gcreate2(file_id, "/MyGroup/Group_A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ /* Create group "Group_A" in group "MyGroup" using absolute name. */
+ group2_id = H5Gcreate2(file_id, "/MyGroup/Group_A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- /* Create group "Group_B" in group "MyGroup" using relative name. */
- group3_id = H5Gcreate2(group1_id, "Group_B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ /* Create group "Group_B" in group "MyGroup" using relative name. */
+ group3_id = H5Gcreate2(group1_id, "Group_B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- /* Close groups. */
- status = H5Gclose(group1_id);
- status = H5Gclose(group2_id);
- status = H5Gclose(group3_id);
+ /* Close groups. */
+ status = H5Gclose(group1_id);
+ status = H5Gclose(group2_id);
+ status = H5Gclose(group3_id);
- /* Close the file. */
- status = H5Fclose(file_id);
+ /* Close the file. */
+ status = H5Fclose(file_id);
}
diff --git a/examples/h5_crtgrpd.c b/examples/h5_crtgrpd.c
index 35c4389..3095aa0 100644
--- a/examples/h5_crtgrpd.c
+++ b/examples/h5_crtgrpd.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,71 +19,70 @@
#include "hdf5.h"
#define FILE "groups.h5"
-int main() {
+int
+main()
+{
- hid_t file_id, group_id, dataset_id, dataspace_id; /* identifiers */
- hsize_t dims[2];
- herr_t status;
- int i, j, dset1_data[3][3], dset2_data[2][10];
+ hid_t file_id, group_id, dataset_id, dataspace_id; /* identifiers */
+ hsize_t dims[2];
+ herr_t status;
+ int i, j, dset1_data[3][3], dset2_data[2][10];
- /* Initialize the first dataset. */
- for (i = 0; i < 3; i++)
- for (j = 0; j < 3; j++)
- dset1_data[i][j] = j + 1;
+ /* Initialize the first dataset. */
+ for (i = 0; i < 3; i++)
+ for (j = 0; j < 3; j++)
+ dset1_data[i][j] = j + 1;
- /* Initialize the second dataset. */
- for (i = 0; i < 2; i++)
- for (j = 0; j < 10; j++)
- dset2_data[i][j] = j + 1;
+ /* Initialize the second dataset. */
+ for (i = 0; i < 2; i++)
+ for (j = 0; j < 10; j++)
+ dset2_data[i][j] = j + 1;
- /* Open an existing file. */
- file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT);
+ /* Open an existing file. */
+ file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT);
- /* Create the data space for the first dataset. */
- dims[0] = 3;
- dims[1] = 3;
- dataspace_id = H5Screate_simple(2, dims, NULL);
+ /* Create the data space for the first dataset. */
+ dims[0] = 3;
+ dims[1] = 3;
+ dataspace_id = H5Screate_simple(2, dims, NULL);
- /* Create a dataset in group "MyGroup". */
- dataset_id = H5Dcreate2(file_id, "/MyGroup/dset1", H5T_STD_I32BE, dataspace_id,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ /* Create a dataset in group "MyGroup". */
+ dataset_id = H5Dcreate2(file_id, "/MyGroup/dset1", H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT,
+ H5P_DEFAULT);
- /* Write the first dataset. */
- status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
- dset1_data);
+ /* Write the first dataset. */
+ status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1_data);
- /* Close the data space for the first dataset. */
- status = H5Sclose(dataspace_id);
+ /* Close the data space for the first dataset. */
+ status = H5Sclose(dataspace_id);
- /* Close the first dataset. */
- status = H5Dclose(dataset_id);
+ /* Close the first dataset. */
+ status = H5Dclose(dataset_id);
- /* Open an existing group of the specified file. */
- group_id = H5Gopen2(file_id, "/MyGroup/Group_A", H5P_DEFAULT);
+ /* Open an existing group of the specified file. */
+ group_id = H5Gopen2(file_id, "/MyGroup/Group_A", H5P_DEFAULT);
- /* Create the data space for the second dataset. */
- dims[0] = 2;
- dims[1] = 10;
- dataspace_id = H5Screate_simple(2, dims, NULL);
+ /* Create the data space for the second dataset. */
+ dims[0] = 2;
+ dims[1] = 10;
+ dataspace_id = H5Screate_simple(2, dims, NULL);
- /* Create the second dataset in group "Group_A". */
- dataset_id = H5Dcreate2(group_id, "dset2", H5T_STD_I32BE, dataspace_id,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ /* Create the second dataset in group "Group_A". */
+ dataset_id =
+ H5Dcreate2(group_id, "dset2", H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- /* Write the second dataset. */
- status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
- dset2_data);
+ /* Write the second dataset. */
+ status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_data);
- /* Close the data space for the second dataset. */
- status = H5Sclose(dataspace_id);
+ /* Close the data space for the second dataset. */
+ status = H5Sclose(dataspace_id);
- /* Close the second dataset */
- status = H5Dclose(dataset_id);
+ /* Close the second dataset */
+ status = H5Dclose(dataset_id);
- /* Close the group. */
- status = H5Gclose(group_id);
+ /* Close the group. */
+ status = H5Gclose(group_id);
- /* Close the file. */
- status = H5Fclose(file_id);
+ /* Close the file. */
+ status = H5Fclose(file_id);
}
-
diff --git a/examples/h5_drivers.c b/examples/h5_drivers.c
index 43c1fc7..bd57004 100644
--- a/examples/h5_drivers.c
+++ b/examples/h5_drivers.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,13 +22,12 @@
#include "stdlib.h"
/* global variables */
-int cleanup_g = -1; /* whether to clean. Init to not set. */
+int cleanup_g = -1; /* whether to clean. Init to not set. */
/* prototypes */
void cleanup(const char *);
void split_file(void);
-
/*
* Cleanup a file unless $HDF5_NOCLEANUP is set.
*/
@@ -36,12 +35,11 @@ void
cleanup(const char *filename)
{
if (cleanup_g == -1)
- cleanup_g = getenv("HDF5_NOCLEANUP") ? 0 : 1;
+ cleanup_g = getenv("HDF5_NOCLEANUP") ? 0 : 1;
if (cleanup_g)
- remove(filename);
+ remove(filename);
}
-
/*
* This shows how to use the split file driver.
*/
@@ -55,7 +53,7 @@ split_file(void)
/* the metadata and rawdata files. */
fapl = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT);
- fid=H5Fcreate("Station1",H5F_ACC_TRUNC,H5P_DEFAULT,fapl);
+ fid = H5Fcreate("Station1", H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
/* using the file ... */
H5Fclose(fid);
H5Pclose(fapl);
@@ -68,7 +66,7 @@ split_file(void)
/* the metadata and rawdata files. */
fapl = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "/tmp/%s-r.h5", H5P_DEFAULT);
- fid=H5Fcreate("PointA",H5F_ACC_TRUNC,H5P_DEFAULT,fapl);
+ fid = H5Fcreate("PointA", H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
/* using the file ... */
H5Fclose(fid);
H5Pclose(fapl);
@@ -81,7 +79,7 @@ split_file(void)
/* the metadata and rawdata files. */
fapl = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_fapl_split(fapl, NULL, H5P_DEFAULT, NULL, H5P_DEFAULT);
- fid=H5Fcreate("Measure",H5F_ACC_TRUNC,H5P_DEFAULT,fapl);
+ fid = H5Fcreate("Measure", H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
/* using the file ... */
H5Fclose(fid);
H5Pclose(fapl);
@@ -90,13 +88,12 @@ split_file(void)
cleanup("Measure.raw");
}
-
/* Main Body */
int
-main (void)
+main(void)
{
split_file();
- return(0);
+ return (0);
}
diff --git a/examples/h5_dtransform.c b/examples/h5_dtransform.c
index 0b718ad..a364ec1 100644
--- a/examples/h5_dtransform.c
+++ b/examples/h5_dtransform.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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -33,50 +33,48 @@
#include "hdf5.h"
-#define ROWS 12
-#define COLS 18
+#define ROWS 12
+#define COLS 18
+/* clang-format off */
const float windchillF[ROWS][COLS] =
- { {36.0, 31.0, 25.0, 19.0, 13.0, 7.0, 1.0, -5.0, -11.0, -16.0, -22.0, -28.0, -34.0, -40.0, -46.0, -52.0, -57.0, -63.0 },
- {34.0, 27.0, 21.0, 15.0, 9.0, 3.0, -4.0, -10.0, -16.0, -22.0, -28.0, -35.0, -41.0, -47.0, -53.0, -59.0, -66.0, -72.0 } ,
- {32.0, 25.0, 19.0, 13.0, 6.0, 0.0, -7.0, -13.0, -19.0, -26.0, -32.0, -39.0, -45.0, -51.0, -58.0, -64.0, -71.0, -77.0 },
- {30.0, 24.0, 17.0, 11.0, 4.0, -2.0, -9.0, -15.0, -22.0, -29.0, -35.0, -42.0, -48.0, -55.0, -61.0, -68.0, -74.0, -81.0 },
- {29.0, 23.0, 16.0, 9.0, 3.0, -4.0, -11.0, -17.0, -24.0, -31.0, -37.0, -44.0, -51.0, -58.0, -64.0, -71.0, -78.0, -84.0 },
- {28.0, 22.0, 15.0, 8.0, 1.0, -5.0, -12.0, -19.0, -26.0, -33.0, -39.0, -46.0, -53.0, -60.0, -67.0, -73.0, -80.0, -87.0 },
- {28.0, 21.0, 14.0, 7.0, 0.0, -7.0, -14.0, -21.0, -27.0, -34.0, -41.0, -48.0, -55.0, -62.0, -69.0, -76.0, -82.0, -89.0 },
- {27.0, 20.0, 13.0, 6.0, -1.0, -8.0, -15.0, -22.0, -29.0, -36.0, -43.0, -50.0, -57.0, -64.0, -71.0, -78.0, -84.0, -91.0 },
- {26.0, 19.0, 12.0, 5.0, -2.0, -9.0, -16.0, -23.0, -30.0, -37.0, -44.0, -51.0, -58.0, -65.0, -72.0, -79.0, -86.0, -93.0 },
+ { {36.0, 31.0, 25.0, 19.0, 13.0, 7.0, 1.0, -5.0, -11.0, -16.0, -22.0, -28.0, -34.0, -40.0, -46.0, -52.0, -57.0, -63.0},
+ {34.0, 27.0, 21.0, 15.0, 9.0, 3.0, -4.0, -10.0, -16.0, -22.0, -28.0, -35.0, -41.0, -47.0, -53.0, -59.0, -66.0, -72.0},
+ {32.0, 25.0, 19.0, 13.0, 6.0, 0.0, -7.0, -13.0, -19.0, -26.0, -32.0, -39.0, -45.0, -51.0, -58.0, -64.0, -71.0, -77.0},
+ {30.0, 24.0, 17.0, 11.0, 4.0, -2.0, -9.0, -15.0, -22.0, -29.0, -35.0, -42.0, -48.0, -55.0, -61.0, -68.0, -74.0, -81.0},
+ {29.0, 23.0, 16.0, 9.0, 3.0, -4.0, -11.0, -17.0, -24.0, -31.0, -37.0, -44.0, -51.0, -58.0, -64.0, -71.0, -78.0, -84.0},
+ {28.0, 22.0, 15.0, 8.0, 1.0, -5.0, -12.0, -19.0, -26.0, -33.0, -39.0, -46.0, -53.0, -60.0, -67.0, -73.0, -80.0, -87.0},
+ {28.0, 21.0, 14.0, 7.0, 0.0, -7.0, -14.0, -21.0, -27.0, -34.0, -41.0, -48.0, -55.0, -62.0, -69.0, -76.0, -82.0, -89.0},
+ {27.0, 20.0, 13.0, 6.0, -1.0, -8.0, -15.0, -22.0, -29.0, -36.0, -43.0, -50.0, -57.0, -64.0, -71.0, -78.0, -84.0, -91.0},
+ {26.0, 19.0, 12.0, 5.0, -2.0, -9.0, -16.0, -23.0, -30.0, -37.0, -44.0, -51.0, -58.0, -65.0, -72.0, -79.0, -86.0, -93.0},
{26.0, 19.0, 12.0, 4.0, -3.0, -10.0, -17.0, -24.0, -31.0, -38.0, -45.0, -52.0, -60.0, -67.0, -74.0, -81.0, -88.0, -95.0},
{25.0, 18.0, 11.0, 4.0, -3.0, -11.0, -18.0, -25.0, -32.0, -39.0, -46.0, -54.0, -61.0, -68.0, -75.0, -82.0, -89.0, -97.0},
{25.0, 17.0, 10.0, 3.0, -4.0, -11.0, -19.0, -26.0, -33.0, -40.0, -48.0, -55.0, -62.0, -69.0, -76.0, -84.0, -91.0, -98.0}
};
+/* clang-format on */
-#define PRINT(array) \
-{ \
- for(i=0; i<ROWS; i++) \
- { \
- for(j=0; j<COLS; j++) \
- printf("%6.2f ", array[i][j]); \
- printf("\n"); \
- } \
-}
-
-
-
+#define PRINT(array) \
+ { \
+ for (i = 0; i < ROWS; i++) { \
+ for (j = 0; j < COLS; j++) \
+ printf("%6.2f ", array[i][j]); \
+ printf("\n"); \
+ } \
+ }
int
-main (void)
+main(void)
{
- hid_t file, dataset; /* file and dataset handles */
- hid_t dataspace; /* handles */
- hsize_t dimsf[2]; /* dataset dimensions */
+ hid_t file, dataset; /* file and dataset handles */
+ hid_t dataspace; /* handles */
+ hsize_t dimsf[2]; /* dataset dimensions */
herr_t status;
- hid_t dxpl_id_f_to_c, dxpl_id_c_to_f; /* data transform handles */
- const char* f_to_c = "(5/9.0)*(x-32)";
- const char* c_to_f = "(9/5.0)*x + 32";
- char* transform;
- float windchillC[ROWS][COLS];
- int i,j, transform_size;
+ hid_t dxpl_id_f_to_c, dxpl_id_c_to_f; /* data transform handles */
+ const char *f_to_c = "(5/9.0)*(x-32)";
+ const char *c_to_f = "(9/5.0)*x + 32";
+ char * transform;
+ float windchillC[ROWS][COLS];
+ int i, j, transform_size;
/*
* Create a new file using H5F_ACC_TRUNC access,
@@ -89,28 +87,25 @@ main (void)
* Describe the size of the array and create the data space for fixed
* size dataset.
*/
- dimsf[0] = ROWS;
- dimsf[1] = COLS;
+ dimsf[0] = ROWS;
+ dimsf[1] = COLS;
dataspace = H5Screate_simple(2, dimsf, NULL);
/*
* Create a new dataset within the file using defined dataspace and
* datatype and default dataset creation properties.
*/
- dataset = H5Dcreate2(file, "data_no_trans", H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset =
+ H5Dcreate2(file, "data_no_trans", H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
printf("\nOriginal Data: \n");
PRINT(windchillF);
-
-
-
-/**************** PART 1 **************/
+ /**************** PART 1 **************/
/*
* Write the data to the dataset using default transfer properties (ie, no transform set)
*/
- status = H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
- H5P_DEFAULT, windchillF);
+ status = H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, windchillF);
/* Create the dataset transfer property list */
dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER);
@@ -125,13 +120,11 @@ main (void)
printf("\nData with no write transform, but a read transform: \n");
PRINT(windchillC);
-
-/**************** PART 2 **************/
+ /**************** PART 2 **************/
/*
* Write the data to the dataset with the f_to_c transform set
*/
- status = H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
- dxpl_id_f_to_c, windchillF);
+ status = H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillF);
/* Read out the data with the default transfer list (ie, no transform set) */
H5Dread(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, windchillC);
@@ -140,8 +133,7 @@ main (void)
printf("\nData with write transform, but no read transform: \n");
PRINT(windchillC);
-/************** PART 3 ***************/
-
+ /************** PART 3 ***************/
/* Create the dataset transfer property list */
dxpl_id_c_to_f = H5Pcreate(H5P_DATASET_XFER);
@@ -149,12 +141,10 @@ main (void)
/* Set the data transform to be used on the read*/
H5Pset_data_transform(dxpl_id_c_to_f, c_to_f);
-
/*
* Write the data to the dataset using the f_to_c transform
*/
- status = H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
- dxpl_id_f_to_c, windchillF);
+ status = H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillF);
/* Read the data with the c_to_f data transform */
H5Dread(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f, windchillC);
@@ -163,10 +153,10 @@ main (void)
printf("\nData with both read and write data transform: \n");
PRINT(windchillC);
-/************** PART 4 **************/
+ /************** PART 4 **************/
transform_size = H5Pget_data_transform(dxpl_id_f_to_c, NULL, 0);
- transform = (char*) malloc(transform_size+1);
- H5Pget_data_transform(dxpl_id_f_to_c, transform, transform_size+1);
+ transform = (char *)malloc(transform_size + 1);
+ H5Pget_data_transform(dxpl_id_f_to_c, transform, transform_size + 1);
printf("\nTransform string (from dxpl_id_f_to_c) is: %s\n", transform);
diff --git a/examples/h5_elink_unix2win.c b/examples/h5_elink_unix2win.c
index df52015..bc2e246 100644
--- a/examples/h5_elink_unix2win.c
+++ b/examples/h5_elink_unix2win.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,7 +27,6 @@
#include <stdlib.h>
#include <string.h>
-
/* "Windows to Unix" traversal function for external links
*
* Translates a filename stored in Unix format to Windows format by replacing
@@ -37,45 +36,44 @@
* Note that this may not be necessary on your system; many Windows systems can
* understand Unix paths.
*/
-static hid_t elink_unix2win_trav(const char *link_name, hid_t cur_group,
- const void *udata, size_t udata_size, hid_t lapl_id)
+static hid_t
+elink_unix2win_trav(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size,
+ hid_t lapl_id)
{
- hid_t fid;
- const char *file_name;
- const char *obj_name;
- char *new_fname = NULL; /* Buffer allocated to hold Unix file path */
- ssize_t prefix_len; /* External link prefix length */
- size_t fname_len;
- size_t start_pos; /* Initial position in new_fname buffer */
- size_t x; /* Counter variable */
- hid_t ret_value = -1;
+ hid_t fid;
+ const char *file_name;
+ const char *obj_name;
+ char * new_fname = NULL; /* Buffer allocated to hold Unix file path */
+ ssize_t prefix_len; /* External link prefix length */
+ size_t fname_len;
+ size_t start_pos; /* Initial position in new_fname buffer */
+ size_t x; /* Counter variable */
+ hid_t ret_value = -1;
printf("Converting Unix path to Windows path.\n");
- if(H5Lunpack_elink_val(udata, udata_size, NULL, &file_name, &obj_name) < 0)
+ if (H5Lunpack_elink_val(udata, udata_size, NULL, &file_name, &obj_name) < 0)
goto error;
fname_len = strlen(file_name);
/* See if the external link prefix property is set */
- if((prefix_len = H5Pget_elink_prefix(lapl_id, NULL, 0)) < 0)
+ if ((prefix_len = H5Pget_elink_prefix(lapl_id, NULL, 0)) < 0)
goto error;
/* If so, prepend it to the filename. We assume that the prefix
* is in the correct format for the current file system.
*/
- if(prefix_len > 0)
- {
+ if (prefix_len > 0) {
/* Allocate a buffer to hold the filename plus prefix */
new_fname = malloc(prefix_len + fname_len + 1);
/* Copy the prefix into the buffer */
- if(H5Pget_elink_prefix(lapl_id, new_fname, (size_t)(prefix_len + 1)) < 0)
+ if (H5Pget_elink_prefix(lapl_id, new_fname, (size_t)(prefix_len + 1)) < 0)
goto error;
start_pos = prefix_len;
}
- else
- {
+ else {
/* Allocate a buffer to hold just the filename */
new_fname = malloc(fname_len + 1);
start_pos = 0;
@@ -84,9 +82,8 @@ static hid_t elink_unix2win_trav(const char *link_name, hid_t cur_group,
/* We should now copy file_name into new_fname starting at position pos.
* We'll convert '/' characters into '\' characters as we go.
*/
- for(x=0; file_name[x] != '\0'; x++)
- {
- if(file_name[x] == '/')
+ for (x = 0; file_name[x] != '\0'; x++) {
+ if (file_name[x] == '/')
new_fname[x + start_pos] = '\\';
else
new_fname[x + start_pos] = file_name[x];
@@ -94,38 +91,37 @@ static hid_t elink_unix2win_trav(const char *link_name, hid_t cur_group,
new_fname[x + start_pos] = '\0';
/* Now open the file and object within it */
- if((fid = H5Fopen(new_fname, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ if ((fid = H5Fopen(new_fname, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
goto error;
ret_value = H5Oopen(fid, obj_name, lapl_id); /* If this fails, our return value will be negative. */
- if(H5Fclose(fid) < 0)
+ if (H5Fclose(fid) < 0)
goto error;
/* Free file name if it's been allocated */
- if(new_fname)
+ if (new_fname)
free(new_fname);
return ret_value;
error:
/* Free file name if it's been allocated */
- if(new_fname)
+ if (new_fname)
free(new_fname);
return -1;
}
const H5L_class_t elink_unix2win_class[1] = {{
- H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */
- H5L_TYPE_EXTERNAL, /* Link type id number */
- "unix2win external link", /* Link class name for debugging */
- NULL, /* Creation callback */
- NULL, /* Move callback */
- NULL, /* Copy callback */
- elink_unix2win_trav, /* The actual traversal function */
- NULL, /* Deletion callback */
- NULL /* Query callback */
+ H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */
+ H5L_TYPE_EXTERNAL, /* Link type id number */
+ "unix2win external link", /* Link class name for debugging */
+ NULL, /* Creation callback */
+ NULL, /* Move callback */
+ NULL, /* Copy callback */
+ elink_unix2win_trav, /* The actual traversal function */
+ NULL, /* Deletion callback */
+ NULL /* Query callback */
}};
-
/* The example function.
* Creates a file named "unix2win.h5" with an external link pointing to
* the file "u2w/u2w_target.h5".
@@ -136,55 +132,65 @@ const H5L_class_t elink_unix2win_class[1] = {{
static int
unix2win_example(void)
{
- hid_t fid = (-1); /* File ID */
- hid_t gid = (-1); /* Group ID */
+ hid_t fid = (-1); /* File ID */
+ hid_t gid = (-1); /* Group ID */
/* Create the target file. */
#ifdef H5_HAVE_WIN32_API
- if((fid=H5Fcreate("u2w\\u2w_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
+ if ((fid = H5Fcreate("u2w\\u2w_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
#else
- if((fid=H5Fcreate("u2w/u2w_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
+ if ((fid = H5Fcreate("u2w/u2w_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
#endif
- if(H5Fclose(fid) < 0) goto error;
+ if (H5Fclose(fid) < 0)
+ goto error;
/* Create the source file with an external link in Windows format */
- if((fid=H5Fcreate("unix2win.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
+ if ((fid = H5Fcreate("unix2win.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
/* Create the external link */
- if(H5Lcreate_external("u2w/../u2w/u2w_target.h5", "/", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) goto error;
+ if (H5Lcreate_external("u2w/../u2w/u2w_target.h5", "/", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto error;
- /* If we are not on Windows, assume we are on a Unix-y filesystem and
- * follow the external link normally.
- * If we are on Windows, register the unix2win traversal function so
- * that external links can be traversed.
- */
+ /* If we are not on Windows, assume we are on a Unix-y filesystem and
+ * follow the external link normally.
+ * If we are on Windows, register the unix2win traversal function so
+ * that external links can be traversed.
+ */
#ifdef H5_HAVE_WIN32_API
/* Register the elink_unix2win class defined above to replace default
* external links
*/
- if(H5Lregister(elink_unix2win_class) < 0) goto error;
+ if (H5Lregister(elink_unix2win_class) < 0)
+ goto error;
#endif
/* Now follow the link */
- if((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) goto error;
+ if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0)
+ goto error;
printf("Successfully followed external link.\n");
/* Close the group and the file */
- if(H5Gclose(gid) <0) goto error;
- if(H5Fclose(fid) <0) goto error;
+ if (H5Gclose(gid) < 0)
+ goto error;
+ if (H5Fclose(fid) < 0)
+ goto error;
return 0;
- error:
+error:
printf("Error!\n");
- H5E_BEGIN_TRY {
- H5Gclose (gid);
- H5Fclose (fid);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY
+ {
+ H5Gclose(gid);
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
return -1;
}
-
/* Main function
*
@@ -193,12 +199,10 @@ unix2win_example(void)
int
main(void)
{
- int ret;
+ int ret;
printf("Testing unix2win external links.\n");
ret = unix2win_example();
return ret;
}
-
-
diff --git a/examples/h5_extend.c b/examples/h5_extend.c
index 6e3cff2..5807694 100644
--- a/examples/h5_extend.c
+++ b/examples/h5_extend.c
@@ -6,139 +6,126 @@
* 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 example how to work with extendible datasets. The dataset
+ * This example how to work with extendible datasets. The dataset
* must be chunked in order to be extendible.
- *
+ *
* It is used in the HDF5 Tutorial.
*/
-
#include "hdf5.h"
#define FILENAME "extend.h5"
#define DATASETNAME "ExtendibleArray"
-#define RANK 2
+#define RANK 2
int
-main (void)
+main(void)
{
- hid_t file; /* handles */
- hid_t dataspace, dataset;
- hid_t filespace, memspace;
- hid_t prop;
-
- hsize_t dims[2] = {3, 3}; /* dataset dimensions at creation time */
- hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
- herr_t status;
- hsize_t chunk_dims[2] = {2, 5};
- int data[3][3] = { {1, 1, 1}, /* data to write */
- {1, 1, 1},
- {1, 1, 1} };
+ hid_t file; /* handles */
+ hid_t dataspace, dataset;
+ hid_t filespace, memspace;
+ hid_t prop;
+
+ hsize_t dims[2] = {3, 3}; /* dataset dimensions at creation time */
+ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
+ herr_t status;
+ hsize_t chunk_dims[2] = {2, 5};
+ int data[3][3] = {{1, 1, 1}, /* data to write */
+ {1, 1, 1},
+ {1, 1, 1}};
/* Variables used in extending and writing to the extended portion of dataset */
- hsize_t size[2];
- hsize_t offset[2];
- hsize_t dimsext[2] = {7, 3}; /* extend dimensions */
- int dataext[7][3] = { {2, 3, 4},
- {2, 3, 4},
- {2, 3, 4},
- {2, 3, 4},
- {2, 3, 4},
- {2, 3, 4},
- {2, 3, 4} };
+ hsize_t size[2];
+ hsize_t offset[2];
+ hsize_t dimsext[2] = {7, 3}; /* extend dimensions */
+ int dataext[7][3] = {{2, 3, 4}, {2, 3, 4}, {2, 3, 4}, {2, 3, 4}, {2, 3, 4}, {2, 3, 4}, {2, 3, 4}};
/* Variables used in reading data back */
- hsize_t chunk_dimsr[2];
- hsize_t dimsr[2];
- hsize_t i, j;
- int rdata[10][3];
- herr_t status_n;
- int rank, rank_chunk;
+ hsize_t chunk_dimsr[2];
+ hsize_t dimsr[2];
+ hsize_t i, j;
+ int rdata[10][3];
+ herr_t status_n;
+ int rank, rank_chunk;
/* Create the data space with unlimited dimensions. */
- dataspace = H5Screate_simple (RANK, dims, maxdims);
+ dataspace = H5Screate_simple(RANK, dims, maxdims);
/* Create a new file. If file exists its contents will be overwritten. */
- file = H5Fcreate (FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/* Modify dataset creation properties, i.e. enable chunking */
- prop = H5Pcreate (H5P_DATASET_CREATE);
- status = H5Pset_chunk (prop, RANK, chunk_dims);
+ prop = H5Pcreate(H5P_DATASET_CREATE);
+ status = H5Pset_chunk(prop, RANK, chunk_dims);
- /* Create a new dataset within the file using chunk
+ /* Create a new dataset within the file using chunk
creation properties. */
- dataset = H5Dcreate2 (file, DATASETNAME, H5T_NATIVE_INT, dataspace,
- H5P_DEFAULT, prop, H5P_DEFAULT);
+ dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, prop, H5P_DEFAULT);
/* Write data to dataset */
- status = H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- H5P_DEFAULT, data);
+ status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
/* Extend the dataset. Dataset becomes 10 x 3 */
- size[0] = dims[0]+ dimsext[0];
+ size[0] = dims[0] + dimsext[0];
size[1] = dims[1];
- status = H5Dset_extent (dataset, size);
+ status = H5Dset_extent(dataset, size);
/* Select a hyperslab in extended portion of dataset */
- filespace = H5Dget_space (dataset);
+ filespace = H5Dget_space(dataset);
offset[0] = 3;
offset[1] = 0;
- status = H5Sselect_hyperslab (filespace, H5S_SELECT_SET, offset, NULL,
- dimsext, NULL);
+ status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dimsext, NULL);
/* Define memory space */
- memspace = H5Screate_simple (RANK, dimsext, NULL);
+ memspace = H5Screate_simple(RANK, dimsext, NULL);
/* Write the data to the extended portion of dataset */
- status = H5Dwrite (dataset, H5T_NATIVE_INT, memspace, filespace,
- H5P_DEFAULT, dataext);
+ status = H5Dwrite(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, dataext);
/* Close resources */
- status = H5Dclose (dataset);
- status = H5Pclose (prop);
- status = H5Sclose (dataspace);
- status = H5Sclose (memspace);
- status = H5Sclose (filespace);
- status = H5Fclose (file);
+ status = H5Dclose(dataset);
+ status = H5Pclose(prop);
+ status = H5Sclose(dataspace);
+ status = H5Sclose(memspace);
+ status = H5Sclose(filespace);
+ status = H5Fclose(file);
/********************************************
* Re-open the file and read the data back. *
********************************************/
- file = H5Fopen (FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT);
- dataset = H5Dopen2 (file, DATASETNAME, H5P_DEFAULT);
+ file = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT);
+ dataset = H5Dopen2(file, DATASETNAME, H5P_DEFAULT);
- filespace = H5Dget_space (dataset);
- rank = H5Sget_simple_extent_ndims (filespace);
- status_n = H5Sget_simple_extent_dims (filespace, dimsr, NULL);
+ filespace = H5Dget_space(dataset);
+ rank = H5Sget_simple_extent_ndims(filespace);
+ status_n = H5Sget_simple_extent_dims(filespace, dimsr, NULL);
- prop = H5Dget_create_plist (dataset);
+ prop = H5Dget_create_plist(dataset);
- if (H5D_CHUNKED == H5Pget_layout (prop))
- rank_chunk = H5Pget_chunk (prop, rank, chunk_dimsr);
+ if (H5D_CHUNKED == H5Pget_layout(prop))
+ rank_chunk = H5Pget_chunk(prop, rank, chunk_dimsr);
- memspace = H5Screate_simple (rank, dimsr, NULL);
- status = H5Dread (dataset, H5T_NATIVE_INT, memspace, filespace,
- H5P_DEFAULT, rdata);
+ memspace = H5Screate_simple(rank, dimsr, NULL);
+ status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, rdata);
printf("\n");
printf("Dataset: \n");
- for (j = 0; j < dimsr[0]; j++)
- {
- for (i = 0; i < dimsr[1]; i++)
- printf("%d ", rdata[j][i]);
- printf("\n");
+ for (j = 0; j < dimsr[0]; j++) {
+ for (i = 0; i < dimsr[1]; i++)
+ printf("%d ", rdata[j][i]);
+ printf("\n");
}
- status = H5Pclose (prop);
- status = H5Dclose (dataset);
- status = H5Sclose (filespace);
- status = H5Sclose (memspace);
- status = H5Fclose (file);
+ status = H5Pclose(prop);
+ status = H5Dclose(dataset);
+ status = H5Sclose(filespace);
+ status = H5Sclose(memspace);
+ status = H5Fclose(file);
}
diff --git a/examples/h5_extend_write.c b/examples/h5_extend_write.c
index 4abda30..f5db1cf 100644
--- a/examples/h5_extend_write.c
+++ b/examples/h5_extend_write.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,43 +20,42 @@
#include "hdf5.h"
-#define H5FILE_NAME "SDSextendible.h5"
+#define H5FILE_NAME "SDSextendible.h5"
#define DATASETNAME "ExtendibleArray"
-#define RANK 2
-#define NX 10
-#define NY 5
+#define RANK 2
+#define NX 10
+#define NY 5
int
-main (void)
+main(void)
{
- hid_t file; /* handles */
- hid_t dataspace, dataset;
- hid_t filespace;
- hid_t cparms;
- hsize_t dims[2] = { 3, 3}; /*
- * dataset dimensions
- * at the creation time
- */
- hsize_t dims1[2] = { 3, 3}; /* data1 dimensions */
- hsize_t dims2[2] = { 7, 1}; /* data2 dimensions */
- hsize_t dims3[2] = { 2, 2}; /* data3 dimensions */
+ hid_t file; /* handles */
+ hid_t dataspace, dataset;
+ hid_t filespace;
+ hid_t cparms;
+ hsize_t dims[2] = {3, 3}; /*
+ * dataset dimensions
+ * at the creation time
+ */
+ hsize_t dims1[2] = {3, 3}; /* data1 dimensions */
+ hsize_t dims2[2] = {7, 1}; /* data2 dimensions */
+ hsize_t dims3[2] = {2, 2}; /* data3 dimensions */
- hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
- hsize_t chunk_dims[2] ={2, 5};
- hsize_t size[2];
- hsize_t offset[2];
+ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
+ hsize_t chunk_dims[2] = {2, 5};
+ hsize_t size[2];
+ hsize_t offset[2];
- herr_t status;
+ herr_t status;
- int data1[3][3] = { {1, 1, 1}, /* data to write */
- {1, 1, 1},
- {1, 1, 1} };
+ int data1[3][3] = {{1, 1, 1}, /* data to write */
+ {1, 1, 1},
+ {1, 1, 1}};
- int data2[7] = { 2, 2, 2, 2, 2, 2, 2};
+ int data2[7] = {2, 2, 2, 2, 2, 2, 2};
- int data3[2][2] = { {3, 3},
- {3, 3} };
- int fillvalue = 0;
+ int data3[2][2] = {{3, 3}, {3, 3}};
+ int fillvalue = 0;
/*
* Create the data space with unlimited dimensions.
@@ -72,22 +71,21 @@ main (void)
* Modify dataset creation properties, i.e. enable chunking.
*/
cparms = H5Pcreate(H5P_DATASET_CREATE);
- status = H5Pset_chunk( cparms, RANK, chunk_dims);
- status = H5Pset_fill_value (cparms, H5T_NATIVE_INT, &fillvalue );
+ status = H5Pset_chunk(cparms, RANK, chunk_dims);
+ status = H5Pset_fill_value(cparms, H5T_NATIVE_INT, &fillvalue);
/*
* Create a new dataset within the file using cparms
* creation properties.
*/
- dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
- cparms, H5P_DEFAULT);
+ dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT);
/*
* Extend the dataset. This call assures that dataset is at least 3 x 3.
*/
- size[0] = 3;
- size[1] = 3;
- status = H5Dset_extent(dataset, size);
+ size[0] = 3;
+ size[1] = 3;
+ status = H5Dset_extent(dataset, size);
/*
* Select a hyperslab.
@@ -95,22 +93,20 @@ main (void)
filespace = H5Dget_space(dataset);
offset[0] = 0;
offset[1] = 0;
- status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
- dims1, NULL);
+ status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dims1, NULL);
/*
* Write the data to the hyperslab.
*/
- status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace,
- H5P_DEFAULT, data1);
+ status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, H5P_DEFAULT, data1);
/*
* Extend the dataset. Dataset becomes 10 x 3.
*/
- dims[0] = dims1[0] + dims2[0];
- size[0] = dims[0];
- size[1] = dims[1];
- status = H5Dset_extent(dataset, size);
+ dims[0] = dims1[0] + dims2[0];
+ size[0] = dims[0];
+ size[1] = dims[1];
+ status = H5Dset_extent(dataset, size);
/*
* Select a hyperslab.
@@ -118,8 +114,7 @@ main (void)
filespace = H5Dget_space(dataset);
offset[0] = 3;
offset[1] = 0;
- status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
- dims2, NULL);
+ status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dims2, NULL);
/*
* Define memory space
@@ -129,16 +124,15 @@ main (void)
/*
* Write the data to the hyperslab.
*/
- status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace,
- H5P_DEFAULT, data2);
+ status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, H5P_DEFAULT, data2);
/*
* Extend the dataset. Dataset becomes 10 x 5.
*/
- dims[1] = dims1[1] + dims3[1];
- size[0] = dims[0];
- size[1] = dims[1];
- status = H5Dset_extent(dataset, size);
+ dims[1] = dims1[1] + dims3[1];
+ size[0] = dims[0];
+ size[1] = dims[1];
+ status = H5Dset_extent(dataset, size);
/*
* Select a hyperslab
@@ -146,8 +140,7 @@ main (void)
filespace = H5Dget_space(dataset);
offset[0] = 0;
offset[1] = 3;
- status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
- dims3, NULL);
+ status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dims3, NULL);
/*
* Define memory space.
@@ -157,8 +150,7 @@ main (void)
/*
* Write the data to the hyperslab.
*/
- status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace,
- H5P_DEFAULT, data3);
+ status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, H5P_DEFAULT, data3);
/*
* Resulting dataset
diff --git a/examples/h5_extlink.c b/examples/h5_extlink.c
index ba632f5..341bea5 100644
--- a/examples/h5_extlink.c
+++ b/examples/h5_extlink.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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -26,37 +26,36 @@
#define PREFIX_SOURCE_FILE "extlink_prefix_source.h5"
-#define SOFT_LINK_FILE "soft_link.h5"
-#define SOFT_LINK_NAME "soft_link_to_group"
+#define SOFT_LINK_FILE "soft_link.h5"
+#define SOFT_LINK_NAME "soft_link_to_group"
#define UD_SOFT_LINK_NAME "ud_soft_link"
-#define TARGET_GROUP "target_group"
+#define TARGET_GROUP "target_group"
#define UD_SOFT_CLASS 65
-#define HARD_LINK_FILE "hard_link.h5"
-#define HARD_LINK_NAME "hard_link_to_group"
+#define HARD_LINK_FILE "hard_link.h5"
+#define HARD_LINK_NAME "hard_link_to_group"
#define UD_HARD_LINK_NAME "ud_hard_link"
#define UD_HARD_CLASS 66
#define PLIST_LINK_PROP "plist_link_prop"
-#define UD_PLIST_CLASS 66
+#define UD_PLIST_CLASS 66
-
-
/* Basic external link example
*
* Creates two files and uses an external link to access an object in the
* second file from the first file.
*/
-static void extlink_example(void)
+static void
+extlink_example(void)
{
hid_t source_file_id, targ_file_id;
hid_t group_id, group2_id;
/* Create two files, a source and a target */
source_file_id = H5Fcreate(SOURCE_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- targ_file_id = H5Fcreate(TARGET_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ targ_file_id = H5Fcreate(TARGET_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/* Create a group in the target file for the external link to point to. */
group_id = H5Gcreate2(targ_file_id, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
@@ -96,7 +95,6 @@ static void extlink_example(void)
*/
}
-
/* External link prefix example
*
* Uses a group access property list to set a "prefix" for the filenames
@@ -109,7 +107,8 @@ static void extlink_example(void)
* where it is run (so to run this example on Unix, first mkdir red and mkdir
* blue).
*/
-static void extlink_prefix_example(void)
+static void
+extlink_prefix_example(void)
{
hid_t source_file_id, red_file_id, blue_file_id;
hid_t group_id, group2_id;
@@ -119,14 +118,15 @@ static void extlink_prefix_example(void)
* the same name, but one will be located in the red directory and one will
* be located in the blue directory */
source_file_id = H5Fcreate(PREFIX_SOURCE_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- red_file_id = H5Fcreate("red/prefix_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- blue_file_id = H5Fcreate("blue/prefix_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ red_file_id = H5Fcreate("red/prefix_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ blue_file_id = H5Fcreate("blue/prefix_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/* This test needs a red and a blue directory in the filesystem. If they're not present,
* trying to create the files above will fail.
*/
- if(red_file_id < 0 || blue_file_id < 0)
- printf("This test requires directories named 'red' and 'blue' to exist. Did you forget to create them?\n");
+ if (red_file_id < 0 || blue_file_id < 0)
+ printf("This test requires directories named 'red' and 'blue' to exist. Did you forget to create "
+ "them?\n");
/* Create an external link in the source file pointing to the root group of
* a file named prefix_target.h5. This file doesn't exist in the current
@@ -163,7 +163,7 @@ static void extlink_prefix_example(void)
* directory.
*/
H5Pset_elink_prefix(gapl_id, "blue/");
- group_id = H5Gopen2(source_file_id, "ext_link", gapl_id);
+ group_id = H5Gopen2(source_file_id, "ext_link", gapl_id);
group2_id = H5Gcreate2(group_id, "sky blue", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Close both groups. */
@@ -171,7 +171,7 @@ static void extlink_prefix_example(void)
H5Gclose(group_id);
/* Each file has had a group created inside it using the same external link. */
- group_id = H5Gopen2(red_file_id, "pink", H5P_DEFAULT);
+ group_id = H5Gopen2(red_file_id, "pink", H5P_DEFAULT);
group2_id = H5Gopen2(blue_file_id, "sky blue", H5P_DEFAULT);
/* Clean up our open IDs */
@@ -189,7 +189,6 @@ static void extlink_prefix_example(void)
*/
}
-
/* Soft Link example
*
* Create a new class of user-defined links that behave like HDF5's built-in
@@ -207,10 +206,11 @@ static void extlink_prefix_example(void)
* We might also have wanted to supply a creation callback that checks
* that a path was supplied in the udata.
*/
-static hid_t UD_soft_traverse(const char *link_name, hid_t cur_group,
- const void *udata, size_t udata_size, hid_t lapl_id);
+static hid_t UD_soft_traverse(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size,
+ hid_t lapl_id);
-static void soft_link_example(void)
+static void
+soft_link_example(void)
{
hid_t file_id;
hid_t group_id;
@@ -220,27 +220,26 @@ static void soft_link_example(void)
* callback.
*/
const H5L_class_t UD_soft_class[1] = {{
- H5L_LINK_CLASS_T_VERS, /* Version number for this struct.
- * This field is always H5L_LINK_CLASS_T_VERS */
- (H5L_type_t)UD_SOFT_CLASS, /* Link class id number. This can be any
- * value between H5L_TYPE_UD_MIN (64) and
- * H5L_TYPE_MAX (255). It should be a
- * value that isn't already being used by
- * another kind of link. We'll use 65. */
- "UD_soft_link", /* Link class name for debugging */
- NULL, /* Creation callback */
- NULL, /* Move callback */
- NULL, /* Copy callback */
- UD_soft_traverse, /* The actual traversal function */
- NULL, /* Deletion callback */
- NULL /* Query callback */
+ H5L_LINK_CLASS_T_VERS, /* Version number for this struct.
+ * This field is always H5L_LINK_CLASS_T_VERS */
+ (H5L_type_t)UD_SOFT_CLASS, /* Link class id number. This can be any
+ * value between H5L_TYPE_UD_MIN (64) and
+ * H5L_TYPE_MAX (255). It should be a
+ * value that isn't already being used by
+ * another kind of link. We'll use 65. */
+ "UD_soft_link", /* Link class name for debugging */
+ NULL, /* Creation callback */
+ NULL, /* Move callback */
+ NULL, /* Copy callback */
+ UD_soft_traverse, /* The actual traversal function */
+ NULL, /* Deletion callback */
+ NULL /* Query callback */
}};
-
/* First, create a file and an object within the file for the link to
* point to.
*/
- file_id = H5Fcreate(SOFT_LINK_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ file_id = H5Fcreate(SOFT_LINK_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
group_id = H5Gcreate2(file_id, TARGET_GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
H5Gclose(group_id);
@@ -275,12 +274,12 @@ static void soft_link_example(void)
* The actual traversal function simply needs to open the correct object by
* name and return its ID.
*/
-
-static hid_t UD_soft_traverse(const char *link_name, hid_t cur_group,
- const void *udata, size_t udata_size, hid_t lapl_id)
+
+static hid_t
+UD_soft_traverse(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size, hid_t lapl_id)
{
- const char *target = (const char *) udata;
- hid_t ret_value;
+ const char *target = (const char *)udata;
+ hid_t ret_value;
/* Pass the udata straight through to HDF5. If it's invalid, let HDF5
* return an error.
@@ -289,7 +288,6 @@ static hid_t UD_soft_traverse(const char *link_name, hid_t cur_group,
return ret_value;
}
-
/* Hard Link example
*
* Create a new class of user-defined links that behave like HDF5's built-in
@@ -305,17 +303,17 @@ static hid_t UD_soft_traverse(const char *link_name, hid_t cur_group,
* To keep the example simple, these links don't have a query callback.
* Generally, real link classes should always be query-able.
*/
-static herr_t UD_hard_create(const char *link_name, hid_t loc_group,
- const void *udata, size_t udata_size, hid_t lcpl_id);
-static herr_t UD_hard_delete(const char *link_name, hid_t loc_group,
- const void *udata, size_t udata_size);
-static hid_t UD_hard_traverse(const char *link_name, hid_t cur_group,
- const void *udata, size_t udata_size, hid_t lapl_id);
-
-static void hard_link_example(void)
+static herr_t UD_hard_create(const char *link_name, hid_t loc_group, const void *udata, size_t udata_size,
+ hid_t lcpl_id);
+static herr_t UD_hard_delete(const char *link_name, hid_t loc_group, const void *udata, size_t udata_size);
+static hid_t UD_hard_traverse(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size,
+ hid_t lapl_id);
+
+static void
+hard_link_example(void)
{
- hid_t file_id;
- hid_t group_id;
+ hid_t file_id;
+ hid_t group_id;
H5L_info_t li;
/* Define the link class that we'll use to register "user-defined hard
* links" using the callbacks we defined above.
@@ -323,27 +321,26 @@ static void hard_link_example(void)
* callback.
*/
const H5L_class_t UD_hard_class[1] = {{
- H5L_LINK_CLASS_T_VERS, /* Version number for this struct.
- * This field is always H5L_LINK_CLASS_T_VERS */
- (H5L_type_t)UD_HARD_CLASS, /* Link class id number. This can be any
- * value between H5L_TYPE_UD_MIN (64) and
- * H5L_TYPE_MAX (255). It should be a
- * value that isn't already being used by
- * another kind of link. We'll use 66. */
- "UD_hard_link", /* Link class name for debugging */
- UD_hard_create, /* Creation callback */
- NULL, /* Move callback */
- NULL, /* Copy callback */
- UD_hard_traverse, /* The actual traversal function */
- UD_hard_delete, /* Deletion callback */
- NULL /* Query callback */
+ H5L_LINK_CLASS_T_VERS, /* Version number for this struct.
+ * This field is always H5L_LINK_CLASS_T_VERS */
+ (H5L_type_t)UD_HARD_CLASS, /* Link class id number. This can be any
+ * value between H5L_TYPE_UD_MIN (64) and
+ * H5L_TYPE_MAX (255). It should be a
+ * value that isn't already being used by
+ * another kind of link. We'll use 66. */
+ "UD_hard_link", /* Link class name for debugging */
+ UD_hard_create, /* Creation callback */
+ NULL, /* Move callback */
+ NULL, /* Copy callback */
+ UD_hard_traverse, /* The actual traversal function */
+ UD_hard_delete, /* Deletion callback */
+ NULL /* Query callback */
}};
-
/* First, create a file and an object within the file for the link to
* point to.
*/
- file_id = H5Fcreate(HARD_LINK_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ file_id = H5Fcreate(HARD_LINK_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
group_id = H5Gcreate2(file_id, TARGET_GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
H5Gclose(group_id);
@@ -366,8 +363,8 @@ static void hard_link_example(void)
/* Now create a user-defined link. We give it the group's address
* as its udata.
*/
- H5Lcreate_ud(file_id, UD_HARD_LINK_NAME, (H5L_type_t)UD_HARD_CLASS, &(li.u.address),
- sizeof(li.u.address), H5P_DEFAULT, H5P_DEFAULT);
+ H5Lcreate_ud(file_id, UD_HARD_LINK_NAME, (H5L_type_t)UD_HARD_CLASS, &(li.u.address), sizeof(li.u.address),
+ H5P_DEFAULT, H5P_DEFAULT);
/* The UD hard link has now incremented the group's reference count
* like a normal hard link would. This means that we can unlink the
@@ -401,42 +398,39 @@ static void hard_link_example(void)
* If this function returns a negative value, the call to H5Lcreate_ud()
* will also return failure and the link will not be created.
*/
-static herr_t UD_hard_create(const char *link_name, hid_t loc_group,
- const void *udata, size_t udata_size, hid_t lcpl_id)
+static herr_t
+UD_hard_create(const char *link_name, hid_t loc_group, const void *udata, size_t udata_size, hid_t lcpl_id)
{
haddr_t addr;
- hid_t target_obj = -1;
- herr_t ret_value = 0;
+ hid_t target_obj = -1;
+ herr_t ret_value = 0;
/* Make sure that the address passed in looks valid */
- if(udata_size != sizeof(haddr_t))
- {
- ret_value = -1;
- goto done;
+ if (udata_size != sizeof(haddr_t)) {
+ ret_value = -1;
+ goto done;
}
- addr = *((const haddr_t *) udata);
+ addr = *((const haddr_t *)udata);
/* Open the object this link points to so that we can increment
* its reference count. This also ensures that the address passed
* in points to a real object (although this check is not perfect!) */
- target_obj= H5Oopen_by_addr(loc_group, addr);
- if(target_obj < 0)
- {
- ret_value = -1;
- goto done;
+ target_obj = H5Oopen_by_addr(loc_group, addr);
+ if (target_obj < 0) {
+ ret_value = -1;
+ goto done;
}
/* Increment the reference count of the target object */
- if(H5Oincr_refcount(target_obj) < 0)
- {
- ret_value = -1;
- goto done;
+ if (H5Oincr_refcount(target_obj) < 0) {
+ ret_value = -1;
+ goto done;
}
done:
/* Close the target object if we opened it */
- if(target_obj >= 0)
+ if (target_obj >= 0)
H5Oclose(target_obj);
return ret_value;
}
@@ -445,42 +439,39 @@ done:
* Since the creation function increments the object's reference count, it's
* important to decrement it again when the link is deleted.
*/
-static herr_t UD_hard_delete(const char *link_name, hid_t loc_group,
- const void *udata, size_t udata_size)
+static herr_t
+UD_hard_delete(const char *link_name, hid_t loc_group, const void *udata, size_t udata_size)
{
haddr_t addr;
- hid_t target_obj = -1;
- herr_t ret_value = 0;
+ hid_t target_obj = -1;
+ herr_t ret_value = 0;
/* Sanity check; we have already verified the udata's size in the creation
* callback.
*/
- if(udata_size != sizeof(haddr_t))
- {
- ret_value = -1;
- goto done;
+ if (udata_size != sizeof(haddr_t)) {
+ ret_value = -1;
+ goto done;
}
- addr = *((const haddr_t *) udata);
+ addr = *((const haddr_t *)udata);
/* Open the object this link points to */
- target_obj= H5Oopen_by_addr(loc_group, addr);
- if(target_obj < 0)
- {
- ret_value = -1;
- goto done;
+ target_obj = H5Oopen_by_addr(loc_group, addr);
+ if (target_obj < 0) {
+ ret_value = -1;
+ goto done;
}
/* Decrement the reference count of the target object */
- if(H5Odecr_refcount(target_obj) < 0)
- {
- ret_value = -1;
- goto done;
+ if (H5Odecr_refcount(target_obj) < 0) {
+ ret_value = -1;
+ goto done;
}
done:
/* Close the target object if we opened it */
- if(target_obj >= 0)
+ if (target_obj >= 0)
H5Oclose(target_obj);
return ret_value;
}
@@ -489,19 +480,19 @@ done:
* The actual traversal function simply needs to open the correct object and
* return its ID.
*/
-static hid_t UD_hard_traverse(const char *link_name, hid_t cur_group,
- const void *udata, size_t udata_size, hid_t lapl_id)
+static hid_t
+UD_hard_traverse(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size, hid_t lapl_id)
{
- haddr_t addr;
- hid_t ret_value = -1;
+ haddr_t addr;
+ hid_t ret_value = -1;
/* Sanity check; we have already verified the udata's size in the creation
* callback.
*/
- if(udata_size != sizeof(haddr_t))
- return -1;
+ if (udata_size != sizeof(haddr_t))
+ return -1;
- addr = *((const haddr_t *) udata);
+ addr = *((const haddr_t *)udata);
/* Open the object by address. If H5Oopen_by_addr fails, ret_value will
* be negative to indicate that the traversal function failed.
@@ -511,8 +502,6 @@ static hid_t UD_hard_traverse(const char *link_name, hid_t cur_group,
return ret_value;
}
-
-
/* Plist example
*
* Create a new class of user-defined links that open objects within a file
@@ -526,10 +515,11 @@ static hid_t UD_hard_traverse(const char *link_name, hid_t cur_group,
* These are defined after the example below.
* These links have no udata, so they don't need a query function.
*/
-static hid_t UD_plist_traverse(const char *link_name, hid_t cur_group,
- const void *udata, size_t udata_size, hid_t lapl_id);
+static hid_t UD_plist_traverse(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size,
+ hid_t lapl_id);
-static void plist_link_example(void)
+static void
+plist_link_example(void)
{
hid_t file_id;
hid_t group_id, group2_id;
@@ -558,11 +548,10 @@ static void plist_link_example(void)
NULL /* Query callback */
}};
-
/* First, create a file and two objects within the file for the link to
* point to.
*/
- file_id = H5Fcreate(HARD_LINK_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ file_id = H5Fcreate(HARD_LINK_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
group_id = H5Gcreate2(file_id, "group_1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
H5Gclose(group_id);
group_id = H5Gcreate2(file_id, "group_1/group_2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
@@ -570,8 +559,7 @@ static void plist_link_example(void)
/* Register "plist links" and create one. It has no udata at all. */
H5Lregister(UD_plist_class);
- H5Lcreate_ud(file_id, "plist_link", (H5L_type_t)UD_PLIST_CLASS, NULL, 0,
- H5P_DEFAULT, H5P_DEFAULT);
+ H5Lcreate_ud(file_id, "plist_link", (H5L_type_t)UD_PLIST_CLASS, NULL, 0, H5P_DEFAULT, H5P_DEFAULT);
/* Create a group access property list to pass in the target for the
* plist link.
@@ -617,17 +605,17 @@ static void plist_link_example(void)
/* UD_plist_traverse
* Open a path passed in through the property list.
*/
-static hid_t UD_plist_traverse(const char *link_name, hid_t cur_group,
- const void *udata, size_t udata_size, hid_t lapl_id)
+static hid_t
+UD_plist_traverse(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size, hid_t lapl_id)
{
- char * path;
- hid_t ret_value = -1;
+ char *path;
+ hid_t ret_value = -1;
/* If the link property isn't set or can't be found, traversal fails. */
- if(H5Pexist(lapl_id, PLIST_LINK_PROP) < 0)
+ if (H5Pexist(lapl_id, PLIST_LINK_PROP) < 0)
goto error;
- if(H5Pget(lapl_id, PLIST_LINK_PROP, &path) < 0)
+ if (H5Pget(lapl_id, PLIST_LINK_PROP, &path) < 0)
goto error;
/* Open the object by address. If H5Oopen_by_addr fails, ret_value will
@@ -641,13 +629,11 @@ error:
return -1;
}
-
-
/* Main function
*
* Invokes the example functions.
*/
- int
+int
main(void)
{
printf("Testing basic external links.\n");
@@ -667,5 +653,3 @@ main(void)
return 0;
}
-
-
diff --git a/examples/h5_group.c b/examples/h5_group.c
index 8e89165..59b0422 100644
--- a/examples/h5_group.c
+++ b/examples/h5_group.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,31 +19,29 @@
* in the root group and in the created group.
*/
-
#include "hdf5.h"
-
-#define H5FILE_NAME "group.h5"
-#define RANK 2
+#define H5FILE_NAME "group.h5"
+#define RANK 2
static herr_t file_info(hid_t loc_id, const char *name, const H5L_info_t *linfo,
- void *opdata); /* Link iteration operator function */
+ void *opdata); /* Link iteration operator function */
static herr_t group_info(hid_t loc_id, const char *name, const H5L_info_t *linfo,
- void *opdata); /* Link iteration operator function */
+ void *opdata); /* Link iteration operator function */
int
main(void)
{
- hid_t file;
- hid_t grp;
- hid_t dataset, dataspace;
- hid_t plist;
+ hid_t file;
+ hid_t grp;
+ hid_t dataset, dataspace;
+ hid_t plist;
- herr_t status;
- hsize_t dims[2];
- hsize_t cdims[2];
+ herr_t status;
+ hsize_t dims[2];
+ hsize_t cdims[2];
- int idx_f, idx_g;
+ int idx_f, idx_g;
/*
* Create a file.
@@ -61,16 +59,16 @@ main(void)
* GZIP compression with the compression effort set to 6.
* Note that compression can be used only when dataset is chunked.
*/
- dims[0] = 1000;
- dims[1] = 20;
- cdims[0] = 20;
- cdims[1] = 20;
+ dims[0] = 1000;
+ dims[1] = 20;
+ cdims[0] = 20;
+ cdims[1] = 20;
dataspace = H5Screate_simple(RANK, dims, NULL);
plist = H5Pcreate(H5P_DATASET_CREATE);
- H5Pset_chunk(plist, 2, cdims);
- H5Pset_deflate( plist, 6);
- dataset = H5Dcreate2(file, "/Data/Compressed_Data", H5T_NATIVE_INT,
- dataspace, H5P_DEFAULT, plist, H5P_DEFAULT);
+ H5Pset_chunk(plist, 2, cdims);
+ H5Pset_deflate(plist, 6);
+ dataset =
+ H5Dcreate2(file, "/Data/Compressed_Data", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, plist, H5P_DEFAULT);
/*
* Close the first dataset .
*/
@@ -80,11 +78,11 @@ main(void)
/*
* Create the second dataset.
*/
- dims[0] = 500;
- dims[1] = 20;
+ dims[0] = 500;
+ dims[1] = 20;
dataspace = H5Screate_simple(RANK, dims, NULL);
- dataset = H5Dcreate2(file, "/Data/Float_Data", H5T_NATIVE_FLOAT,
- dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(file, "/Data/Float_Data", H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, H5P_DEFAULT,
+ H5P_DEFAULT);
/*
*Close the second dataset and file.
@@ -105,7 +103,8 @@ main(void)
* Access "Compressed_Data" dataset in the group.
*/
dataset = H5Dopen2(grp, "Compressed_Data", H5P_DEFAULT);
- if( dataset < 0) printf(" Dataset 'Compressed-Data' is not found. \n");
+ if (dataset < 0)
+ printf(" Dataset 'Compressed-Data' is not found. \n");
printf("\"/Data/Compressed_Data\" dataset is open \n");
/*
@@ -123,7 +122,8 @@ main(void)
* hard link "Data_new".
*/
dataset = H5Dopen2(file, "/Data_new/Compressed_Data", H5P_DEFAULT);
- if( dataset < 0) printf(" Dataset is not found. \n");
+ if (dataset < 0)
+ printf(" Dataset is not found. \n");
printf("\"/Data_new/Compressed_Data\" dataset is open \n");
/*
@@ -131,7 +131,6 @@ main(void)
*/
status = H5Dclose(dataset);
-
/*
* Use iterator to see the names of the objects in the root group.
*/
@@ -141,10 +140,10 @@ main(void)
* Unlink name "Data" and use iterator to see the names
* of the objects in the file root direvtory.
*/
- if(H5Ldelete(file, "Data", H5P_DEFAULT) < 0)
- printf(" H5Ldelete failed \n");
+ if (H5Ldelete(file, "Data", H5P_DEFAULT) < 0)
+ printf(" H5Ldelete failed \n");
else
- printf("\"Data\" is unlinked \n");
+ printf("\"Data\" is unlinked \n");
idx_f = H5Literate(file, H5_INDEX_NAME, H5_ITER_INC, NULL, file_info, NULL);
@@ -152,7 +151,8 @@ main(void)
* Use iterator to see the names of the objects in the group
* /Data_new.
*/
- idx_g = H5Literate_by_name(grp, "/Data_new", H5_INDEX_NAME, H5_ITER_INC, NULL, group_info, NULL, H5P_DEFAULT);
+ idx_g =
+ H5Literate_by_name(grp, "/Data_new", H5_INDEX_NAME, H5_ITER_INC, NULL, group_info, NULL, H5P_DEFAULT);
/*
* Close the file.
@@ -173,7 +173,7 @@ file_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *opdata)
/* avoid compiler warnings */
loc_id = loc_id;
opdata = opdata;
- linfo = linfo;
+ linfo = linfo;
/*
* Display group name. The name is passed to the function by
@@ -184,23 +184,22 @@ file_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *opdata)
return 0;
}
-
/*
* Operator function.
*/
static herr_t
group_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *opdata)
{
- hid_t did; /* dataset identifier */
- hid_t tid; /* datatype identifier */
+ hid_t did; /* dataset identifier */
+ hid_t tid; /* datatype identifier */
H5T_class_t t_class;
- hid_t pid; /* data_property identifier */
- hsize_t chunk_dims_out[2];
- int rank_chunk;
+ hid_t pid; /* data_property identifier */
+ hsize_t chunk_dims_out[2];
+ int rank_chunk;
/* avoid warnings */
opdata = opdata;
- linfo = linfo;
+ linfo = linfo;
/*
* Open the datasets using their names.
@@ -215,38 +214,37 @@ group_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *opdata
/*
* Display dataset information.
*/
- tid = H5Dget_type(did); /* get datatype*/
+ tid = H5Dget_type(did); /* get datatype*/
pid = H5Dget_create_plist(did); /* get creation property list */
/*
* Check if dataset is chunked.
*/
- if(H5D_CHUNKED == H5Pget_layout(pid)) {
+ if (H5D_CHUNKED == H5Pget_layout(pid)) {
/*
* get chunking information: rank and dimensions.
*/
rank_chunk = H5Pget_chunk(pid, 2, chunk_dims_out);
- printf("chunk rank %d, dimensions %lu x %lu\n", rank_chunk,
- (unsigned long)(chunk_dims_out[0]),
- (unsigned long)(chunk_dims_out[1]));
+ printf("chunk rank %d, dimensions %lu x %lu\n", rank_chunk, (unsigned long)(chunk_dims_out[0]),
+ (unsigned long)(chunk_dims_out[1]));
}
else {
t_class = H5Tget_class(tid);
- if(t_class < 0) {
+ if (t_class < 0) {
puts(" Invalid datatype.\n");
}
else {
- if(t_class == H5T_INTEGER)
+ if (t_class == H5T_INTEGER)
puts(" Datatype is 'H5T_NATIVE_INTEGER'.\n");
- if(t_class == H5T_FLOAT)
+ if (t_class == H5T_FLOAT)
puts(" Datatype is 'H5T_NATIVE_FLOAT'.\n");
- if(t_class == H5T_STRING)
+ if (t_class == H5T_STRING)
puts(" Datatype is 'H5T_NATIVE_STRING'.\n");
- if(t_class == H5T_BITFIELD)
+ if (t_class == H5T_BITFIELD)
puts(" Datatype is 'H5T_NATIVE_BITFIELD'.\n");
- if(t_class == H5T_OPAQUE)
+ if (t_class == H5T_OPAQUE)
puts(" Datatype is 'H5T_NATIVE_OPAQUE'.\n");
- if(t_class == H5T_COMPOUND)
+ if (t_class == H5T_COMPOUND)
puts(" Datatype is 'H5T_NATIVE_COMPOUND'.\n");
}
}
@@ -256,4 +254,3 @@ group_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *opdata
H5Tclose(tid);
return 0;
}
-
diff --git a/examples/h5_interm_group.c b/examples/h5_interm_group.c
index 6507fd1..c2cafa6 100644
--- a/examples/h5_interm_group.c
+++ b/examples/h5_interm_group.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,27 +16,24 @@
* all intermediate groups.
*/
-
#include "hdf5.h"
-
-#define H5FILE_NAME "interm_group.h5"
-#define TRUE 1
-#define FALSE 0
+#define H5FILE_NAME "interm_group.h5"
+#define TRUE 1
+#define FALSE 0
int
main(void)
{
- hid_t file;
- hid_t g1_id, g2_id, g3_id;
- hid_t grp_crt_plist;
+ hid_t file;
+ hid_t g1_id, g2_id, g3_id;
+ hid_t grp_crt_plist;
H5G_info_t g2_info;
- char name[3];
-
- herr_t status;
- int i;
+ char name[3];
+ herr_t status;
+ int i;
/*
* Create a file using the default properties.
@@ -59,53 +56,44 @@ main(void)
/*
* Check if group /G1 exists in the file.
*/
- if(H5Lexists(file, "/G1", H5P_DEFAULT) !=FALSE)
- printf("Group /G1 exists in the file\n");
+ if (H5Lexists(file, "/G1", H5P_DEFAULT) != FALSE)
+ printf("Group /G1 exists in the file\n");
/*
* Check that group G2/G3 exists in /G1 and if not create it using
* intermediate group creation property.
*/
g1_id = H5Gopen2(file, "/G1", H5P_DEFAULT);
-/* Next commented call causes error stack to be printed out; the next one
- * works fine; is it a bug or a feature? EIP 04-25-07
-*/
-/* if (H5Lexists(g1_id, "G2/G3", H5P_DEFAULT) !=TRUE) { */
- if (H5Lexists(g1_id, "G2", H5P_DEFAULT) !=TRUE) {
-
- grp_crt_plist = H5Pcreate(H5P_LINK_CREATE);
-
- /* Set flag for intermediate group creation */
- status = H5Pset_create_intermediate_group(grp_crt_plist, TRUE);
- g3_id = H5Gcreate2(g1_id, "G2/G3", grp_crt_plist, H5P_DEFAULT, H5P_DEFAULT);
- H5Gclose(g3_id);
+ /* Next commented call causes error stack to be printed out; the next one
+ * works fine; is it a bug or a feature? EIP 04-25-07
+ */
+ /* if (H5Lexists(g1_id, "G2/G3", H5P_DEFAULT) !=TRUE) { */
+ if (H5Lexists(g1_id, "G2", H5P_DEFAULT) != TRUE) {
+
+ grp_crt_plist = H5Pcreate(H5P_LINK_CREATE);
+
+ /* Set flag for intermediate group creation */
+ status = H5Pset_create_intermediate_group(grp_crt_plist, TRUE);
+ g3_id = H5Gcreate2(g1_id, "G2/G3", grp_crt_plist, H5P_DEFAULT, H5P_DEFAULT);
+ H5Gclose(g3_id);
}
H5Gclose(g1_id);
-
/* Now check if group /G1/G2 exists in the file, then open it and print
* its members names
*/
if (H5Lexists(file, "/G1/G2", H5P_DEFAULT)) {
- g2_id = H5Gopen2(file, "/G1/G2", H5P_DEFAULT);
- status = H5Gget_info(g2_id, &g2_info);
- printf("Group /G1/G2 has %d member(s)\n", (int)g2_info.nlinks);
+ g2_id = H5Gopen2(file, "/G1/G2", H5P_DEFAULT);
+ status = H5Gget_info(g2_id, &g2_info);
+ printf("Group /G1/G2 has %d member(s)\n", (int)g2_info.nlinks);
- for (i=0; i < (int)g2_info.nlinks; i++) {
- H5Lget_name_by_idx(g2_id, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)i,
- name, 3, H5P_DEFAULT);
- printf("Object's name is %s\n", name);
-
- }
- H5Gclose(g2_id);
+ for (i = 0; i < (int)g2_info.nlinks; i++) {
+ H5Lget_name_by_idx(g2_id, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)i, name, 3, H5P_DEFAULT);
+ printf("Object's name is %s\n", name);
+ }
+ H5Gclose(g2_id);
}
H5Fclose(file);
return 0;
}
-
-
-
-
-
-
diff --git a/examples/h5_mount.c b/examples/h5_mount.c
index a2e16c5..e984d5b 100644
--- a/examples/h5_mount.c
+++ b/examples/h5_mount.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,107 +25,105 @@
#define FILE2 "mount2.h5"
#define RANK 2
-#define NX 4
-#define NY 5
+#define NX 4
+#define NY 5
-int main(void)
+int
+main(void)
{
- hid_t fid1, fid2, gid; /* Files and group identifiers */
- hid_t did, tid, sid; /* Dataset and datatype identifiers */
-
- herr_t status;
- hsize_t dims[] = {NX,NY}; /* Dataset dimensions */
-
- int i, j;
- int bm[NX][NY], bm_out[NX][NY]; /* Data buffers */
-
- /*
- * Initialization of buffer matrix "bm"
- */
- for(i =0; i < NX; i++)
- for(j = 0; j < NY; j++)
- bm[i][j] = i + j;
-
- /*
- * Create first file and a group in it.
- */
- fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- gid = H5Gcreate2(fid1, "/G", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
-
- /*
- * Close group and file
- */
- H5Gclose(gid);
- H5Fclose(fid1);
-
- /*
- * Create second file and dataset "D" in it.
- */
- fid2 = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- dims[0] = NX;
- dims[1] = NY;
- sid = H5Screate_simple(RANK, dims, NULL);
- did = H5Dcreate2(fid2, "D", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
-
- /*
- * Write data to the dataset.
- */
- status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, bm);
-
- /*
- * Close all identifiers.
- */
- H5Sclose(sid);
- H5Dclose(did);
- H5Fclose(fid2);
-
- /*
- * Reopen both files
- */
- fid1 = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT);
- fid2 = H5Fopen(FILE2, H5F_ACC_RDONLY, H5P_DEFAULT);
-
- /*
- * Mount second file under G in the first file.
- */
- H5Fmount(fid1, "/G", fid2, H5P_DEFAULT);
-
- /*
- * Access dataset D in the first file under /G/D name.
- */
- did = H5Dopen2(fid1, "/G/D", H5P_DEFAULT);
- tid = H5Dget_type(did);
- status = H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, bm_out);
-
- /*
- * Print out the data.
- */
- for(i=0; i<NX; i++){
- for(j=0; j<NY; j++)
- printf(" %d", bm_out[i][j]);
- printf("\n");
- }
-
- /*
- * Close all identifers
- */
- H5Tclose(tid);
- H5Dclose(did);
-
- /*
- * Unmounting second file
- */
- H5Funmount(fid1, "/G");
-
- /*
- * Close both files
- */
- H5Fclose(fid1);
- H5Fclose(fid2);
-
- return 0;
+ hid_t fid1, fid2, gid; /* Files and group identifiers */
+ hid_t did, tid, sid; /* Dataset and datatype identifiers */
+
+ herr_t status;
+ hsize_t dims[] = {NX, NY}; /* Dataset dimensions */
+
+ int i, j;
+ int bm[NX][NY], bm_out[NX][NY]; /* Data buffers */
+
+ /*
+ * Initialization of buffer matrix "bm"
+ */
+ for (i = 0; i < NX; i++)
+ for (j = 0; j < NY; j++)
+ bm[i][j] = i + j;
+
+ /*
+ * Create first file and a group in it.
+ */
+ fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ gid = H5Gcreate2(fid1, "/G", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Close group and file
+ */
+ H5Gclose(gid);
+ H5Fclose(fid1);
+
+ /*
+ * Create second file and dataset "D" in it.
+ */
+ fid2 = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ dims[0] = NX;
+ dims[1] = NY;
+ sid = H5Screate_simple(RANK, dims, NULL);
+ did = H5Dcreate2(fid2, "D", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Write data to the dataset.
+ */
+ status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, bm);
+
+ /*
+ * Close all identifiers.
+ */
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Fclose(fid2);
+
+ /*
+ * Reopen both files
+ */
+ fid1 = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT);
+ fid2 = H5Fopen(FILE2, H5F_ACC_RDONLY, H5P_DEFAULT);
+
+ /*
+ * Mount second file under G in the first file.
+ */
+ H5Fmount(fid1, "/G", fid2, H5P_DEFAULT);
+
+ /*
+ * Access dataset D in the first file under /G/D name.
+ */
+ did = H5Dopen2(fid1, "/G/D", H5P_DEFAULT);
+ tid = H5Dget_type(did);
+ status = H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, bm_out);
+
+ /*
+ * Print out the data.
+ */
+ for (i = 0; i < NX; i++) {
+ for (j = 0; j < NY; j++)
+ printf(" %d", bm_out[i][j]);
+ printf("\n");
+ }
+
+ /*
+ * Close all identifers
+ */
+ H5Tclose(tid);
+ H5Dclose(did);
+
+ /*
+ * Unmounting second file
+ */
+ H5Funmount(fid1, "/G");
+
+ /*
+ * Close both files
+ */
+ H5Fclose(fid1);
+ H5Fclose(fid2);
+
+ return 0;
}
-
-
-
diff --git a/examples/h5_rdwt.c b/examples/h5_rdwt.c
index 6cd7f0f..ba5ddae 100644
--- a/examples/h5_rdwt.c
+++ b/examples/h5_rdwt.c
@@ -6,12 +6,12 @@
* 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 example illustrates how to write and read data in an existing
* dataset. It is used in the HDF5 Tutorial.
*/
@@ -19,33 +19,33 @@
#include "hdf5.h"
#define FILE "dset.h5"
-int main() {
+int
+main()
+{
- hid_t file_id, dataset_id; /* identifiers */
- herr_t status;
- int i, j, dset_data[4][6];
+ hid_t file_id, dataset_id; /* identifiers */
+ herr_t status;
+ int i, j, dset_data[4][6];
- /* Initialize the dataset. */
- for (i = 0; i < 4; i++)
- for (j = 0; j < 6; j++)
- dset_data[i][j] = i * 6 + j + 1;
+ /* Initialize the dataset. */
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < 6; j++)
+ dset_data[i][j] = i * 6 + j + 1;
- /* Open an existing file. */
- file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT);
+ /* Open an existing file. */
+ file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT);
- /* Open an existing dataset. */
- dataset_id = H5Dopen2(file_id, "/dset", H5P_DEFAULT);
+ /* Open an existing dataset. */
+ dataset_id = H5Dopen2(file_id, "/dset", H5P_DEFAULT);
- /* Write the dataset. */
- status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
- dset_data);
+ /* Write the dataset. */
+ status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data);
- status = H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
- dset_data);
+ status = H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data);
- /* Close the dataset. */
- status = H5Dclose(dataset_id);
+ /* Close the dataset. */
+ status = H5Dclose(dataset_id);
- /* Close the file. */
- status = H5Fclose(file_id);
+ /* Close the file. */
+ status = H5Fclose(file_id);
}
diff --git a/examples/h5_read.c b/examples/h5_read.c
index 7fd8ad4..afd3b14 100644
--- a/examples/h5_read.c
+++ b/examples/h5_read.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,71 +20,73 @@
#include "hdf5.h"
-#define H5FILE_NAME "SDS.h5"
+#define H5FILE_NAME "SDS.h5"
#define DATASETNAME "IntArray"
-#define NX_SUB 3 /* hyperslab dimensions */
-#define NY_SUB 4
-#define NX 7 /* output buffer dimensions */
-#define NY 7
-#define NZ 3
-#define RANK 2
-#define RANK_OUT 3
+#define NX_SUB 3 /* hyperslab dimensions */
+#define NY_SUB 4
+#define NX 7 /* output buffer dimensions */
+#define NY 7
+#define NZ 3
+#define RANK 2
+#define RANK_OUT 3
int
-main (void)
+main(void)
{
- hid_t file, dataset; /* handles */
+ hid_t file, dataset; /* handles */
hid_t datatype, dataspace;
hid_t memspace;
- H5T_class_t t_class; /* data type class */
- H5T_order_t order; /* data order */
- size_t size; /*
- * size of the data element
- * stored in file
- */
- hsize_t dimsm[3]; /* memory space dimensions */
- hsize_t dims_out[2]; /* dataset dimensions */
- herr_t status;
-
- int data_out[NX][NY][NZ ]; /* output buffer */
-
- hsize_t count[2]; /* size of the hyperslab in the file */
- hsize_t offset[2]; /* hyperslab offset in the file */
- hsize_t count_out[3]; /* size of the hyperslab in memory */
- hsize_t offset_out[3]; /* hyperslab offset in memory */
- int i, j, k, status_n, rank;
+ H5T_class_t t_class; /* data type class */
+ H5T_order_t order; /* data order */
+ size_t size; /*
+ * size of the data element
+ * stored in file
+ */
+ hsize_t dimsm[3]; /* memory space dimensions */
+ hsize_t dims_out[2]; /* dataset dimensions */
+ herr_t status;
+
+ int data_out[NX][NY][NZ]; /* output buffer */
+
+ hsize_t count[2]; /* size of the hyperslab in the file */
+ hsize_t offset[2]; /* hyperslab offset in the file */
+ hsize_t count_out[3]; /* size of the hyperslab in memory */
+ hsize_t offset_out[3]; /* hyperslab offset in memory */
+ int i, j, k, status_n, rank;
for (j = 0; j < NX; j++) {
- for (i = 0; i < NY; i++) {
- for (k = 0; k < NZ ; k++)
- data_out[j][i][k] = 0;
- }
+ for (i = 0; i < NY; i++) {
+ for (k = 0; k < NZ; k++)
+ data_out[j][i][k] = 0;
+ }
}
/*
* Open the file and the dataset.
*/
- file = H5Fopen(H5FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT);
+ file = H5Fopen(H5FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT);
dataset = H5Dopen2(file, DATASETNAME, H5P_DEFAULT);
/*
* Get datatype and dataspace handles and then query
* dataset class, order, size, rank and dimensions.
*/
- datatype = H5Dget_type(dataset); /* datatype handle */
- t_class = H5Tget_class(datatype);
- if (t_class == H5T_INTEGER) printf("Data set has INTEGER type \n");
- order = H5Tget_order(datatype);
- if (order == H5T_ORDER_LE) printf("Little endian order \n");
-
- size = H5Tget_size(datatype);
+ datatype = H5Dget_type(dataset); /* datatype handle */
+ t_class = H5Tget_class(datatype);
+ if (t_class == H5T_INTEGER)
+ printf("Data set has INTEGER type \n");
+ order = H5Tget_order(datatype);
+ if (order == H5T_ORDER_LE)
+ printf("Little endian order \n");
+
+ size = H5Tget_size(datatype);
printf(" Data size is %d \n", (int)size);
- dataspace = H5Dget_space(dataset); /* dataspace handle */
+ dataspace = H5Dget_space(dataset); /* dataspace handle */
rank = H5Sget_simple_extent_ndims(dataspace);
status_n = H5Sget_simple_extent_dims(dataspace, dims_out, NULL);
- printf("rank %d, dimensions %lu x %lu \n", rank,
- (unsigned long)(dims_out[0]), (unsigned long)(dims_out[1]));
+ printf("rank %d, dimensions %lu x %lu \n", rank, (unsigned long)(dims_out[0]),
+ (unsigned long)(dims_out[1]));
/*
* Define hyperslab in the dataset.
@@ -93,16 +95,15 @@ main (void)
offset[1] = 2;
count[0] = NX_SUB;
count[1] = NY_SUB;
- status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, offset, NULL,
- count, NULL);
+ status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, offset, NULL, count, NULL);
/*
* Define the memory dataspace.
*/
dimsm[0] = NX;
dimsm[1] = NY;
- dimsm[2] = NZ ;
- memspace = H5Screate_simple(RANK_OUT,dimsm,NULL);
+ dimsm[2] = NZ;
+ memspace = H5Screate_simple(RANK_OUT, dimsm, NULL);
/*
* Define memory hyperslab.
@@ -113,18 +114,17 @@ main (void)
count_out[0] = NX_SUB;
count_out[1] = NY_SUB;
count_out[2] = 1;
- status = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, offset_out, NULL,
- count_out, NULL);
+ status = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, offset_out, NULL, count_out, NULL);
/*
* Read data from hyperslab in the file into the hyperslab in
* memory and display.
*/
- status = H5Dread(dataset, H5T_NATIVE_INT, memspace, dataspace,
- H5P_DEFAULT, data_out);
+ status = H5Dread(dataset, H5T_NATIVE_INT, memspace, dataspace, H5P_DEFAULT, data_out);
for (j = 0; j < NX; j++) {
- for (i = 0; i < NY; i++) printf("%d ", data_out[j][i][0]);
- printf("\n");
+ for (i = 0; i < NY; i++)
+ printf("%d ", data_out[j][i][0]);
+ printf("\n");
}
/*
* 0 0 0 0 0 0 0
diff --git a/examples/h5_ref2reg.c b/examples/h5_ref2reg.c
index d045db1..6e635b6 100644
--- a/examples/h5_ref2reg.c
+++ b/examples/h5_ref2reg.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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -26,33 +26,34 @@
#include "hdf5.h"
-#define filename "REF_REG.h5"
+#define filename "REF_REG.h5"
#define dsetnamev "MATRIX"
#define dsetnamer "REGION_REFERENCES"
-int main(void)
+int
+main(void)
{
- hid_t file_id; /* file identifier */
- hid_t space_id; /* dataspace identifiers */
- hid_t spacer_id;
- hid_t dsetv_id; /*dataset identifiers*/
- hid_t dsetr_id;
- hsize_t dims[2] = {2,9};
- hsize_t dimsr[1] = {2};
- int rank = 2;
- int rankr =1;
- herr_t status;
+ hid_t file_id; /* file identifier */
+ hid_t space_id; /* dataspace identifiers */
+ hid_t spacer_id;
+ hid_t dsetv_id; /*dataset identifiers*/
+ hid_t dsetr_id;
+ hsize_t dims[2] = {2, 9};
+ hsize_t dimsr[1] = {2};
+ int rank = 2;
+ int rankr = 1;
+ herr_t status;
hdset_reg_ref_t ref[2];
hdset_reg_ref_t ref_out[2];
- int data[2][9] = {{1,1,2,3,3,4,5,5,6},{1,2,2,3,4,4,5,6,6}};
- int data_out[2][9] = {{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0}};
- hsize_t start[2];
- hsize_t count[2];
- hsize_t coord[2][3] = {{0, 0, 1}, {6, 0, 8}};
- unsigned num_points = 3;
- int i, j;
- size_t name_size1, name_size2;
- char buf1[10], buf2[10];
+ int data[2][9] = {{1, 1, 2, 3, 3, 4, 5, 5, 6}, {1, 2, 2, 3, 4, 4, 5, 6, 6}};
+ int data_out[2][9] = {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}};
+ hsize_t start[2];
+ hsize_t count[2];
+ hsize_t coord[2][3] = {{0, 0, 1}, {6, 0, 8}};
+ unsigned num_points = 3;
+ int i, j;
+ size_t name_size1, name_size2;
+ char buf1[10], buf2[10];
/*
* Create file with default file access and file creation properties.
@@ -62,24 +63,26 @@ int main(void)
/*
* Create dataspace for datasets.
*/
- space_id = H5Screate_simple(rank, dims, NULL);
+ space_id = H5Screate_simple(rank, dims, NULL);
spacer_id = H5Screate_simple(rankr, dimsr, NULL);
/*
* Create integer dataset.
*/
- dsetv_id = H5Dcreate2(file_id, dsetnamev, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dsetv_id =
+ H5Dcreate2(file_id, dsetnamev, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/*
* Write data to the dataset.
*/
- status = H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT,data);
+ status = H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
status = H5Dclose(dsetv_id);
/*
* Dataset with references.
*/
- dsetr_id = H5Dcreate2(file_id, dsetnamer, H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dsetr_id =
+ H5Dcreate2(file_id, dsetnamer, H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/*
* Create a reference to the hyperslab.
@@ -88,8 +91,8 @@ int main(void)
start[1] = 3;
count[0] = 2;
count[1] = 3;
- status = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, NULL, count, NULL);
- status = H5Rcreate(&ref[0], file_id, dsetnamev, H5R_DATASET_REGION, space_id);
+ status = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, NULL, count, NULL);
+ status = H5Rcreate(&ref[0], file_id, dsetnamev, H5R_DATASET_REGION, space_id);
/*
* Create a reference to elements selection.
@@ -101,7 +104,7 @@ int main(void)
/*
* Write dataset with the references.
*/
- status = H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT,ref);
+ status = H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref);
/*
* Close all objects.
@@ -114,7 +117,7 @@ int main(void)
/*
* Reopen the file to read selections back.
*/
- file_id = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
+ file_id = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
/*
* Reopen the dataset with object references and read references
@@ -122,8 +125,7 @@ int main(void)
*/
dsetr_id = H5Dopen2(file_id, dsetnamer, H5P_DEFAULT);
- status = H5Dread(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL,
- H5P_DEFAULT, ref_out);
+ status = H5Dread(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_out);
/*
* Dereference the first reference.
@@ -133,26 +135,26 @@ int main(void)
* Get name of the dataset the first region reference points to
* using H5Rget_name
*/
- name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[0], (char*)buf1, 10);
- printf(" Dataset's name (returned by H5Rget_name) the reference points to is %s, name length is %d\n", buf1, (int)name_size1);
+ name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[0], (char *)buf1, 10);
+ printf(" Dataset's name (returned by H5Rget_name) the reference points to is %s, name length is %d\n",
+ buf1, (int)name_size1);
/*
* Get name of the dataset the first region reference points to
* using H5Iget_name
*/
- name_size2 = H5Iget_name(dsetv_id, (char*)buf2, 10);
- printf(" Dataset's name (returned by H5Iget_name) the reference points to is %s, name length is %d\n", buf2, (int)name_size2);
+ name_size2 = H5Iget_name(dsetv_id, (char *)buf2, 10);
+ printf(" Dataset's name (returned by H5Iget_name) the reference points to is %s, name length is %d\n",
+ buf2, (int)name_size2);
- space_id = H5Rget_region(dsetr_id, H5R_DATASET_REGION,&ref_out[0]);
+ space_id = H5Rget_region(dsetr_id, H5R_DATASET_REGION, &ref_out[0]);
/*
* Read and display hyperslab selection from the dataset.
*/
- status = H5Dread(dsetv_id, H5T_NATIVE_INT, H5S_ALL, space_id,
- H5P_DEFAULT, data_out);
+ status = H5Dread(dsetv_id, H5T_NATIVE_INT, H5S_ALL, space_id, H5P_DEFAULT, data_out);
printf("Selected hyperslab: ");
- for (i = 0; i <= 1; i++)
- {
+ for (i = 0; i <= 1; i++) {
printf("\n");
for (j = 0; j <= 8; j++)
printf("%d ", data_out[i][j]);
@@ -176,17 +178,15 @@ int main(void)
* Dereference the second reference.
*/
dsetv_id = H5Rdereference(dsetr_id, H5R_DATASET_REGION, &ref_out[1]);
- space_id = H5Rget_region(dsetv_id, H5R_DATASET_REGION,&ref_out[1]);
+ space_id = H5Rget_region(dsetv_id, H5R_DATASET_REGION, &ref_out[1]);
/*
* Read selected data from the dataset.
*/
- status = H5Dread(dsetv_id, H5T_NATIVE_INT, H5S_ALL, space_id,
- H5P_DEFAULT, data_out);
+ status = H5Dread(dsetv_id, H5T_NATIVE_INT, H5S_ALL, space_id, H5P_DEFAULT, data_out);
printf("Selected points: ");
- for (i = 0; i <= 1; i++)
- {
+ for (i = 0; i <= 1; i++) {
printf("\n");
for (j = 0; j <= 8; j++)
printf("%d ", data_out[i][j]);
@@ -203,6 +203,3 @@ int main(void)
return 0;
}
-
-
-
diff --git a/examples/h5_reference.c b/examples/h5_reference.c
index c73ce89..72cc8a3 100644
--- a/examples/h5_reference.c
+++ b/examples/h5_reference.c
@@ -6,20 +6,20 @@
* 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 program illustrates how references to objects can be used.
- * Program creates a dataset and a group in a file. It also creates
- * second dataset, and references to the first dataset and the group
- * are stored in it.
- * Program reopens the file and reads dataset with the references.
- * References are used to open the objects. Information about the
- * objects is displayed.
- */
+/*
+ * This program illustrates how references to objects can be used.
+ * Program creates a dataset and a group in a file. It also creates
+ * second dataset, and references to the first dataset and the group
+ * are stored in it.
+ * Program reopens the file and reads dataset with the references.
+ * References are used to open the objects. Information about the
+ * objects is displayed.
+ */
#include <stdlib.h>
@@ -28,120 +28,119 @@
#define H5FILE_NAME "refere.h5"
int
-main(void) {
- hid_t fid; /* File, group, datasets, datatypes */
- hid_t gid_a; /* and dataspaces identifiers */
- hid_t did_b, sid_b, tid_b;
- hid_t did_r, tid_r, sid_r;
- H5O_type_t obj_type;
- herr_t status;
-
- hobj_ref_t *wbuf; /* buffer to write to disk */
- hobj_ref_t *rbuf; /* buffer to read from disk */
-
-
- hsize_t dim_r[1];
- hsize_t dim_b[2];
-
- /*
- * Create a file using default properties.
- */
- fid = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
- /*
- * Create group "A" in the file.
- */
- gid_a = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
-
- /*
- * Create dataset "B" in the file.
- */
- dim_b[0] = 2;
- dim_b[1] = 6;
- sid_b = H5Screate_simple(2, dim_b, NULL);
- did_b = H5Dcreate2(fid, "B", H5T_NATIVE_FLOAT, sid_b, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
-
- /*
- * Create dataset "R" to store references to the objects "A" and "B".
- */
- dim_r[0] = 2;
- sid_r = H5Screate_simple(1, dim_r, NULL);
- tid_r = H5Tcopy(H5T_STD_REF_OBJ);
- did_r = H5Dcreate2(fid, "R", tid_r, sid_r, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
-
- /*
- * Allocate write and read buffers.
- */
- wbuf = (hobj_ref_t *)malloc(sizeof(hobj_ref_t) * 2);
- rbuf = (hobj_ref_t *)malloc(sizeof(hobj_ref_t) * 2);
-
- /*
- * Create references to the group "A" and dataset "B"
- * and store them in the wbuf.
- */
- H5Rcreate(&wbuf[0], fid, "A", H5R_OBJECT, (hid_t)-1);
- H5Rcreate(&wbuf[1], fid, "B", H5R_OBJECT, (hid_t)-1);
-
- /*
- * Write dataset R using default transfer properties.
- */
- status = H5Dwrite(did_r, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf);
-
- /*
- * Close all objects.
- */
- H5Gclose(gid_a);
-
- H5Sclose(sid_b);
- H5Dclose(did_b);
-
- H5Tclose(tid_r);
- H5Sclose(sid_r);
- H5Dclose(did_r);
-
- H5Fclose(fid);
-
- /*
- * Reopen the file.
- */
- fid = H5Fopen(H5FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
-
- /*
- * Open and read dataset "R".
- */
- did_r = H5Dopen2(fid, "R", H5P_DEFAULT);
- status = H5Dread(did_r, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf);
-
- /*
- * Find the type of referenced objects.
- */
+main(void)
+{
+ hid_t fid; /* File, group, datasets, datatypes */
+ hid_t gid_a; /* and dataspaces identifiers */
+ hid_t did_b, sid_b, tid_b;
+ hid_t did_r, tid_r, sid_r;
+ H5O_type_t obj_type;
+ herr_t status;
+
+ hobj_ref_t *wbuf; /* buffer to write to disk */
+ hobj_ref_t *rbuf; /* buffer to read from disk */
+
+ hsize_t dim_r[1];
+ hsize_t dim_b[2];
+
+ /*
+ * Create a file using default properties.
+ */
+ fid = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Create group "A" in the file.
+ */
+ gid_a = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Create dataset "B" in the file.
+ */
+ dim_b[0] = 2;
+ dim_b[1] = 6;
+ sid_b = H5Screate_simple(2, dim_b, NULL);
+ did_b = H5Dcreate2(fid, "B", H5T_NATIVE_FLOAT, sid_b, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Create dataset "R" to store references to the objects "A" and "B".
+ */
+ dim_r[0] = 2;
+ sid_r = H5Screate_simple(1, dim_r, NULL);
+ tid_r = H5Tcopy(H5T_STD_REF_OBJ);
+ did_r = H5Dcreate2(fid, "R", tid_r, sid_r, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Allocate write and read buffers.
+ */
+ wbuf = (hobj_ref_t *)malloc(sizeof(hobj_ref_t) * 2);
+ rbuf = (hobj_ref_t *)malloc(sizeof(hobj_ref_t) * 2);
+
+ /*
+ * Create references to the group "A" and dataset "B"
+ * and store them in the wbuf.
+ */
+ H5Rcreate(&wbuf[0], fid, "A", H5R_OBJECT, (hid_t)-1);
+ H5Rcreate(&wbuf[1], fid, "B", H5R_OBJECT, (hid_t)-1);
+
+ /*
+ * Write dataset R using default transfer properties.
+ */
+ status = H5Dwrite(did_r, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf);
+
+ /*
+ * Close all objects.
+ */
+ H5Gclose(gid_a);
+
+ H5Sclose(sid_b);
+ H5Dclose(did_b);
+
+ H5Tclose(tid_r);
+ H5Sclose(sid_r);
+ H5Dclose(did_r);
+
+ H5Fclose(fid);
+
+ /*
+ * Reopen the file.
+ */
+ fid = H5Fopen(H5FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
+
+ /*
+ * Open and read dataset "R".
+ */
+ did_r = H5Dopen2(fid, "R", H5P_DEFAULT);
+ status = H5Dread(did_r, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf);
+
+ /*
+ * Find the type of referenced objects.
+ */
status = H5Rget_obj_type2(did_r, H5R_OBJECT, &rbuf[0], &obj_type);
- if(obj_type == H5O_TYPE_GROUP)
+ if (obj_type == H5O_TYPE_GROUP)
printf("First dereferenced object is a group. \n");
status = H5Rget_obj_type2(did_r, H5R_OBJECT, &rbuf[1], &obj_type);
- if(obj_type == H5O_TYPE_DATASET)
+ if (obj_type == H5O_TYPE_DATASET)
printf("Second dereferenced object is a dataset. \n");
- /*
- * Get datatype of the dataset "B"
- */
- did_b = H5Rdereference(did_r, H5R_OBJECT, &rbuf[1]);
- tid_b = H5Dget_type(did_b);
- if(H5Tequal(tid_b, H5T_NATIVE_FLOAT))
- printf("Datatype of the dataset is H5T_NATIVE_FLOAT.\n");
- printf("\n");
-
- /*
- * Close all objects and free memory buffers.
- */
- H5Dclose(did_r);
- H5Dclose(did_b);
- H5Tclose(tid_b);
- H5Fclose(fid);
- free(rbuf);
- free(wbuf);
-
- return 0;
- }
-
+ /*
+ * Get datatype of the dataset "B"
+ */
+ did_b = H5Rdereference(did_r, H5R_OBJECT, &rbuf[1]);
+ tid_b = H5Dget_type(did_b);
+ if (H5Tequal(tid_b, H5T_NATIVE_FLOAT))
+ printf("Datatype of the dataset is H5T_NATIVE_FLOAT.\n");
+ printf("\n");
+
+ /*
+ * Close all objects and free memory buffers.
+ */
+ H5Dclose(did_r);
+ H5Dclose(did_b);
+ H5Tclose(tid_b);
+ H5Fclose(fid);
+ free(rbuf);
+ free(wbuf);
+
+ return 0;
+}
diff --git a/examples/h5_select.c b/examples/h5_select.c
index bbc877c..e8aeb50 100644
--- a/examples/h5_select.c
+++ b/examples/h5_select.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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -26,78 +26,80 @@
#define H5FILE_NAME "Select.h5"
-#define MSPACE1_RANK 1 /* Rank of the first dataset in memory */
-#define MSPACE1_DIM 50 /* Dataset size in memory */
+#define MSPACE1_RANK 1 /* Rank of the first dataset in memory */
+#define MSPACE1_DIM 50 /* Dataset size in memory */
-#define MSPACE2_RANK 1 /* Rank of the second dataset in memory */
-#define MSPACE2_DIM 4 /* Dataset size in memory */
+#define MSPACE2_RANK 1 /* Rank of the second dataset in memory */
+#define MSPACE2_DIM 4 /* Dataset size in memory */
-#define FSPACE_RANK 2 /* Dataset rank as it is stored in the file */
-#define FSPACE_DIM1 8 /* Dimension sizes of the dataset as it is
- stored in the file */
-#define FSPACE_DIM2 12
+#define FSPACE_RANK 2 /* Dataset rank as it is stored in the file */
+#define FSPACE_DIM1 \
+ 8 /* Dimension sizes of the dataset as it is \
+ stored in the file */
+#define FSPACE_DIM2 12
- /* We will read dataset back from the file
- to the dataset in memory with these
- dataspace parameters. */
-#define MSPACE_RANK 2
-#define MSPACE_DIM1 8
-#define MSPACE_DIM2 9
+/* We will read dataset back from the file
+ to the dataset in memory with these
+ dataspace parameters. */
+#define MSPACE_RANK 2
+#define MSPACE_DIM1 8
+#define MSPACE_DIM2 9
-#define NPOINTS 4 /* Number of points that will be selected
- and overwritten */
+#define NPOINTS \
+ 4 /* Number of points that will be selected \
+ and overwritten */
int
-main (void)
+main(void)
{
- hid_t file, dataset; /* File and dataset identifiers */
- hid_t mid1, mid2, mid, fid; /* Dataspace identifiers */
- hid_t plist; /* Dataset property list identifier */
+ hid_t file, dataset; /* File and dataset identifiers */
+ hid_t mid1, mid2, mid, fid; /* Dataspace identifiers */
+ hid_t plist; /* Dataset property list identifier */
- hsize_t dim1[] = {MSPACE1_DIM}; /* Dimension size of the first dataset
+ hsize_t dim1[] = {MSPACE1_DIM}; /* Dimension size of the first dataset
(in memory) */
- hsize_t dim2[] = {MSPACE2_DIM}; /* Dimension size of the second dataset
+ hsize_t dim2[] = {MSPACE2_DIM}; /* Dimension size of the second dataset
(in memory */
- hsize_t fdim[] = {FSPACE_DIM1, FSPACE_DIM2};
- /* Dimension sizes of the dataset (on disk) */
- hsize_t mdim[] = {MSPACE_DIM1, MSPACE_DIM2}; /* Dimension sizes of the
- dataset in memory when we
- read selection from the
- dataset on the disk */
-
- hsize_t start[2]; /* Start of hyperslab */
- hsize_t stride[2]; /* Stride of hyperslab */
- hsize_t count[2]; /* Block count */
- hsize_t block[2]; /* Block sizes */
-
- hsize_t coord[NPOINTS][FSPACE_RANK]; /* Array to store selected points
- from the file dataspace */
- herr_t ret;
- unsigned i,j;
- int fillvalue = 0; /* Fill value for the dataset */
-
- int matrix_out[MSPACE_DIM1][MSPACE_DIM2]; /* Buffer to read from the
- dataset */
- int vector[MSPACE1_DIM];
- int values[] = {53, 59, 61, 67}; /* New values to be written */
-
- /*
- * Buffers' initialization.
- */
- vector[0] = vector[MSPACE1_DIM - 1] = -1;
- for(i = 1; i < MSPACE1_DIM - 1; i++)
- vector[i] = i;
-
- /*
- * Create a file.
- */
- file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
- /*
- * Create property list for a dataset and set up fill values.
- */
- plist = H5Pcreate(H5P_DATASET_CREATE);
- ret = H5Pset_fill_value(plist, H5T_NATIVE_INT, &fillvalue);
+ hsize_t fdim[] = {FSPACE_DIM1, FSPACE_DIM2};
+ /* Dimension sizes of the dataset (on disk) */
+ hsize_t mdim[] = {MSPACE_DIM1, MSPACE_DIM2}; /* Dimension sizes of the
+ dataset in memory when we
+ read selection from the
+ dataset on the disk */
+
+ hsize_t start[2]; /* Start of hyperslab */
+ hsize_t stride[2]; /* Stride of hyperslab */
+ hsize_t count[2]; /* Block count */
+ hsize_t block[2]; /* Block sizes */
+
+ hsize_t coord[NPOINTS][FSPACE_RANK]; /* Array to store selected points
+ from the file dataspace */
+ herr_t ret;
+ unsigned i, j;
+ int fillvalue = 0; /* Fill value for the dataset */
+
+ int matrix_out[MSPACE_DIM1][MSPACE_DIM2]; /* Buffer to read from the
+ dataset */
+ int vector[MSPACE1_DIM];
+ int values[] = {53, 59, 61, 67}; /* New values to be written */
+
+ /*
+ * Buffers' initialization.
+ */
+ vector[0] = vector[MSPACE1_DIM - 1] = -1;
+ for (i = 1; i < MSPACE1_DIM - 1; i++)
+ vector[i] = i;
+
+ /*
+ * Create a file.
+ */
+ file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Create property list for a dataset and set up fill values.
+ */
+ plist = H5Pcreate(H5P_DATASET_CREATE);
+ ret = H5Pset_fill_value(plist, H5T_NATIVE_INT, &fillvalue);
/*
* Create dataspace for the dataset in the file.
@@ -114,11 +116,15 @@ main (void)
* Select hyperslab for the dataset in the file, using 3x2 blocks,
* (4,3) stride and (2,4) count starting at the position (0,1).
*/
- start[0] = 0; start[1] = 1;
- stride[0] = 4; stride[1] = 3;
- count[0] = 2; count[1] = 4;
- block[0] = 3; block[1] = 2;
- ret = H5Sselect_hyperslab(fid, H5S_SELECT_SET, start, stride, count, block);
+ start[0] = 0;
+ start[1] = 1;
+ stride[0] = 4;
+ stride[1] = 3;
+ count[0] = 2;
+ count[1] = 4;
+ block[0] = 3;
+ block[1] = 2;
+ ret = H5Sselect_hyperslab(fid, H5S_SELECT_SET, start, stride, count, block);
/*
* Create dataspace for the first dataset.
@@ -134,7 +140,7 @@ main (void)
stride[0] = 1;
count[0] = 48;
block[0] = 1;
- ret = H5Sselect_hyperslab(mid1, H5S_SELECT_SET, start, stride, count, block);
+ ret = H5Sselect_hyperslab(mid1, H5S_SELECT_SET, start, stride, count, block);
/*
* Write selection from the vector buffer to the dataset in the file.
@@ -149,7 +155,7 @@ main (void)
* 0 41 42 0 43 44 0 45 46 0 47 48
* 0 0 0 0 0 0 0 0 0 0 0 0
*/
- ret = H5Dwrite(dataset, H5T_NATIVE_INT, mid1, fid, H5P_DEFAULT, vector);
+ ret = H5Dwrite(dataset, H5T_NATIVE_INT, mid1, fid, H5P_DEFAULT, vector);
/*
* Reset the selection for the file dataspace fid.
@@ -164,10 +170,14 @@ main (void)
/*
* Select sequence of NPOINTS points in the file dataspace.
*/
- coord[0][0] = 0; coord[0][1] = 0;
- coord[1][0] = 3; coord[1][1] = 3;
- coord[2][0] = 3; coord[2][1] = 5;
- coord[3][0] = 5; coord[3][1] = 6;
+ coord[0][0] = 0;
+ coord[0][1] = 0;
+ coord[1][0] = 3;
+ coord[1][1] = 3;
+ coord[2][0] = 3;
+ coord[2][1] = 5;
+ coord[3][0] = 5;
+ coord[3][1] = 6;
ret = H5Sselect_elements(fid, H5S_SELECT_SET, NPOINTS, (const hsize_t *)coord);
@@ -229,11 +239,15 @@ main (void)
* 0 59 0 61
*
*/
- start[0] = 1; start[1] = 2;
- block[0] = 1; block[1] = 1;
- stride[0] = 1; stride[1] = 1;
- count[0] = 3; count[1] = 4;
- ret = H5Sselect_hyperslab(fid, H5S_SELECT_SET, start, stride, count, block);
+ start[0] = 1;
+ start[1] = 2;
+ block[0] = 1;
+ block[1] = 1;
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = 3;
+ count[1] = 4;
+ ret = H5Sselect_hyperslab(fid, H5S_SELECT_SET, start, stride, count, block);
/*
* Add second selected hyperslab to the selection.
@@ -248,11 +262,15 @@ main (void)
* 19 20
* 0 61
*/
- start[0] = 2; start[1] = 4;
- block[0] = 1; block[1] = 1;
- stride[0] = 1; stride[1] = 1;
- count[0] = 6; count[1] = 5;
- ret = H5Sselect_hyperslab(fid, H5S_SELECT_OR, start, stride, count, block);
+ start[0] = 2;
+ start[1] = 4;
+ block[0] = 1;
+ block[1] = 1;
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = 6;
+ count[1] = 5;
+ ret = H5Sselect_hyperslab(fid, H5S_SELECT_OR, start, stride, count, block);
/*
* Create memory dataspace.
@@ -263,30 +281,37 @@ main (void)
* Select two hyperslabs in memory. Hyperslabs has the same
* size and shape as the selected hyperslabs for the file dataspace.
*/
- start[0] = 0; start[1] = 0;
- block[0] = 1; block[1] = 1;
- stride[0] = 1; stride[1] = 1;
- count[0] = 3; count[1] = 4;
- ret = H5Sselect_hyperslab(mid, H5S_SELECT_SET, start, stride, count, block);
-
- start[0] = 1; start[1] = 2;
- block[0] = 1; block[1] = 1;
- stride[0] = 1; stride[1] = 1;
- count[0] = 6; count[1] = 5;
- ret = H5Sselect_hyperslab(mid, H5S_SELECT_OR, start, stride, count, block);
+ start[0] = 0;
+ start[1] = 0;
+ block[0] = 1;
+ block[1] = 1;
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = 3;
+ count[1] = 4;
+ ret = H5Sselect_hyperslab(mid, H5S_SELECT_SET, start, stride, count, block);
+
+ start[0] = 1;
+ start[1] = 2;
+ block[0] = 1;
+ block[1] = 1;
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = 6;
+ count[1] = 5;
+ ret = H5Sselect_hyperslab(mid, H5S_SELECT_OR, start, stride, count, block);
/*
* Initialize data buffer.
*/
for (i = 0; i < MSPACE_DIM1; i++) {
- for (j = 0; j < MSPACE_DIM2; j++)
+ for (j = 0; j < MSPACE_DIM2; j++)
matrix_out[i][j] = 0;
}
/*
* Read data back to the buffer matrix_out.
*/
- ret = H5Dread(dataset, H5T_NATIVE_INT, mid, fid,
- H5P_DEFAULT, matrix_out);
+ ret = H5Dread(dataset, H5T_NATIVE_INT, mid, fid, H5P_DEFAULT, matrix_out);
/*
* Display the result. Memory dataset is:
@@ -300,8 +325,8 @@ main (void)
* 0 0 0 0 0 0 0 0 0
* 0 0 0 0 0 0 0 0 0
*/
- for(i = 0; i < MSPACE_DIM1; i++) {
- for(j = 0; j < MSPACE_DIM2; j++)
+ for (i = 0; i < MSPACE_DIM1; i++) {
+ for (j = 0; j < MSPACE_DIM2; j++)
printf("%3d ", matrix_out[i][j]);
printf("\n");
}
@@ -329,4 +354,3 @@ main (void)
return 0;
}
-
diff --git a/examples/h5_shared_mesg.c b/examples/h5_shared_mesg.c
index 4e1f92a..0f623b9 100644
--- a/examples/h5_shared_mesg.c
+++ b/examples/h5_shared_mesg.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,29 +27,13 @@
#include "hdf5.h"
#define NUM_DATASETS 40
-const char* DSETNAME[] = {
- "dataset0", "dataset1",
- "dataset2", "dataset3",
- "dataset4", "dataset5",
- "dataset6", "dataset7",
- "dataset8", "dataset9",
- "dataset10", "dataset11",
- "dataset12", "dataset13",
- "dataset14", "dataset15",
- "dataset16", "dataset17",
- "dataset18", "dataset19",
- "dataset20", "dataset21",
- "dataset22", "dataset23",
- "dataset24", "dataset25",
- "dataset26", "dataset27",
- "dataset28", "dataset29",
- "dataset30", "dataset31",
- "dataset32", "dataset33",
- "dataset34", "dataset35",
- "dataset36", "dataset37",
- "dataset38", "dataset39",
- NULL
-};
+const char *DSETNAME[] = {"dataset0", "dataset1", "dataset2", "dataset3", "dataset4", "dataset5",
+ "dataset6", "dataset7", "dataset8", "dataset9", "dataset10", "dataset11",
+ "dataset12", "dataset13", "dataset14", "dataset15", "dataset16", "dataset17",
+ "dataset18", "dataset19", "dataset20", "dataset21", "dataset22", "dataset23",
+ "dataset24", "dataset25", "dataset26", "dataset27", "dataset28", "dataset29",
+ "dataset30", "dataset31", "dataset32", "dataset33", "dataset34", "dataset35",
+ "dataset36", "dataset37", "dataset38", "dataset39", NULL};
herr_t create_standard_file(const char *filename, hid_t fcpl);
@@ -61,21 +45,24 @@ herr_t create_standard_file(const char *filename, hid_t fcpl);
*
*-------------------------------------------------------------------------
*/
-int main(void)
+int
+main(void)
{
- hid_t fcpl_id;
+ hid_t fcpl_id;
herr_t ret;
/* Create a file creation property list */
fcpl_id = H5Pcreate(H5P_FILE_CREATE);
- if(fcpl_id < 0) goto error;
+ if (fcpl_id < 0)
+ goto error;
/* The file creation property list is the default list right now.
* Create a file using it (this is the same as creating a file with
* H5P_DEFAULT). Implicit shared messages will be disabled.
*/
ret = create_standard_file("default_file.h5", fcpl_id);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
/* There are five kinds of messages that can be shared: datatypes,
* dataspaces, attributes, fill values, and filter pipelines.
@@ -86,7 +73,8 @@ int main(void)
*/
/* To begin with, use only one index. */
ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
/* Each index has a "minimum message size" for a message of that
* type to be shared. Since sharing a message creates some overhead,
@@ -111,7 +99,8 @@ int main(void)
* shared in this single index.
*/
ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ALL_FLAG, 40);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
/* The other property that can be set for shared messages is the
* list/B-tree cutoff for the indexes.
@@ -128,7 +117,8 @@ int main(void)
* second the minimum B-tree size.
*/
ret = H5Pset_shared_mesg_phase_change(fcpl_id, 30, 20);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
/* Now create a file with this property list. After the FCPL is used,
* everything is automatic; messages will be shared and this will be
@@ -137,7 +127,8 @@ int main(void)
* written later.
*/
ret = create_standard_file("one_index_file.h5", fcpl_id);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
/* Now try some variations on this. The FCPL hasn't been closed, so
* we don't need to re-create it.
@@ -147,36 +138,42 @@ int main(void)
* overhead).
*/
ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ALL_FLAG, 1000);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
ret = create_standard_file("only_huge_mesgs_file.h5", fcpl_id);
- if(ret < 0) goto error;
-
+ if (ret < 0)
+ goto error;
/* Or, suppose we only wanted to shared dataspaces and
* attributes (which might make sense if we were going to use committed
* datatypes). We could change the flags on the index:
*/
ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_ATTR_FLAG, 40);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
ret = create_standard_file("only_dspaces_and_attrs_file.h5", fcpl_id);
- if(ret < 0) goto error;
-
+ if (ret < 0)
+ goto error;
/* We could create a second index and put attributes in it to separate them
* from datatypes and dataspaces (and then run some performance metrics to
* see whether this improved caching performance).
*/
ret = H5Pset_shared_mesg_nindexes(fcpl_id, 2);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_DTYPE_FLAG | H5O_SHMESG_SDSPACE_FLAG, 40);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
ret = H5Pset_shared_mesg_index(fcpl_id, 1, H5O_SHMESG_ATTR_FLAG, 40);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
ret = create_standard_file("separate_indexes_file.h5", fcpl_id);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
/* We can try twiddling the "phase change" values and see what it does to
* the file size. Since there's only a few different messages (two
@@ -184,25 +181,30 @@ int main(void)
* save some space.
*/
ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ALL_FLAG, 40);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
ret = H5Pset_shared_mesg_phase_change(fcpl_id, 5, 0);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
ret = create_standard_file("small_lists_file.h5", fcpl_id);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
/* Or we could create indexes that are never lists, but are created as
* B-trees. We do this by setting the "maximum list size" to zero.
*/
ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
ret = create_standard_file("btrees_file.h5", fcpl_id);
- if(ret < 0) goto error;
-
+ if (ret < 0)
+ goto error;
/* Obviously there are a lot more permutations of these options possible.
* Performance will often be a tradeoff of speed for space, but will
@@ -212,10 +214,10 @@ int main(void)
* Please let The HDF Group (help@hdfgroup.org) know what you find!
*/
-
/* Close the property list */
ret = H5Pclose(fcpl_id);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
return 0;
error:
@@ -238,21 +240,22 @@ error:
herr_t
create_standard_file(const char *filename, hid_t fcpl_id)
{
- hid_t file_id=-1;
- hid_t type_id=-1, temp_type_id=-1;
- hsize_t dims[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
- hid_t space_id=-1;
- hid_t attr_type_id = -1;
- hid_t attr_space_id = -1;
- int attr_data[] = {1,2,3,4,5,6,7,8,9,0};
- hid_t dset_id=-1;
- hid_t attr_id=-1;
- int x;
- herr_t ret;
+ hid_t file_id = -1;
+ hid_t type_id = -1, temp_type_id = -1;
+ hsize_t dims[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
+ hid_t space_id = -1;
+ hid_t attr_type_id = -1;
+ hid_t attr_space_id = -1;
+ int attr_data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
+ hid_t dset_id = -1;
+ hid_t attr_id = -1;
+ int x;
+ herr_t ret;
/* Create the file */
file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT);
- if(file_id < 0) goto error;
+ if (file_id < 0)
+ goto error;
/* Create the datatype we'll be using. Generally, sharing messages
* is most useful when the message is complex and takes more space on
@@ -260,66 +263,80 @@ create_standard_file(const char *filename, hid_t fcpl_id)
* However, any type can be shared.
*/
temp_type_id = H5Tarray_create2(H5T_NATIVE_INT, 2, dims);
- if(temp_type_id < 0) goto error;
- type_id = H5Tarray_create2(temp_type_id, 2, dims);
- if(type_id < 0) goto error;
+ if (temp_type_id < 0)
+ goto error;
+ type_id = H5Tarray_create2(temp_type_id, 2, dims);
+ if (type_id < 0)
+ goto error;
ret = H5Tclose(temp_type_id);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
/* Create the dataspace we'll be using.
* Again, create a more complex dataspace so that more space will
* be saved when we share it.
*/
space_id = H5Screate_simple(10, dims, dims);
- if(space_id < 0) goto error;
+ if (space_id < 0)
+ goto error;
/* Create a datatype and dataspace for the attributes we'll be creating.
* The datatype will be a single integer, and each attribute will hold
* 10 integers.
*/
attr_type_id = H5Tcopy(H5T_NATIVE_INT);
- if(attr_type_id < 0) goto error;
+ if (attr_type_id < 0)
+ goto error;
attr_space_id = H5Screate_simple(1, dims, dims);
- if(attr_space_id < 0) goto error;
-
+ if (attr_space_id < 0)
+ goto error;
/* Begin using the messages many times. Do this by creating datasets
* that use this datatype, dataspace, and have this attribute.
*/
- for(x = 0; x < NUM_DATASETS; ++x) {
- /* Create a dataset */
- dset_id = H5Dcreate2(file_id, DSETNAME[x], type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- if(dset_id < 0) goto error;
-
- /* Create an attribute on the dataset */
- attr_id = H5Acreate2(dset_id, "attr_name", attr_type_id, attr_space_id, H5P_DEFAULT, H5P_DEFAULT);
- if(attr_id < 0) goto error;
-
- /* Write data to the attribute */
- ret = H5Awrite(attr_id, H5T_NATIVE_INT, attr_data);
- if(ret < 0) goto error;
-
- ret = H5Aclose(attr_id);
- if(ret < 0) goto error;
- ret = H5Dclose(dset_id);
- if(ret < 0) goto error;
+ for (x = 0; x < NUM_DATASETS; ++x) {
+ /* Create a dataset */
+ dset_id = H5Dcreate2(file_id, DSETNAME[x], type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (dset_id < 0)
+ goto error;
+
+ /* Create an attribute on the dataset */
+ attr_id = H5Acreate2(dset_id, "attr_name", attr_type_id, attr_space_id, H5P_DEFAULT, H5P_DEFAULT);
+ if (attr_id < 0)
+ goto error;
+
+ /* Write data to the attribute */
+ ret = H5Awrite(attr_id, H5T_NATIVE_INT, attr_data);
+ if (ret < 0)
+ goto error;
+
+ ret = H5Aclose(attr_id);
+ if (ret < 0)
+ goto error;
+ ret = H5Dclose(dset_id);
+ if (ret < 0)
+ goto error;
}
/* Close all open IDs */
ret = H5Tclose(attr_type_id);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
ret = H5Sclose(attr_space_id);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
ret = H5Tclose(type_id);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
ret = H5Sclose(space_id);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
ret = H5Fclose(file_id);
- if(ret < 0) goto error;
+ if (ret < 0)
+ goto error;
return 0;
error:
return -1;
}
-
diff --git a/examples/h5_subset.c b/examples/h5_subset.c
index 904d3f8..3580046 100644
--- a/examples/h5_subset.c
+++ b/examples/h5_subset.c
@@ -6,102 +6,97 @@
* 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 example illustrates how to read/write a subset of data (a slab)
+/*
+ * This example illustrates how to read/write a subset of data (a slab)
* from/to a dataset in an HDF5 file. It is used in the HDF5 Tutorial.
*/
-
+
#include "hdf5.h"
#define FILE "subset.h5"
-#define DATASETNAME "IntArray"
-#define RANK 2
-
-#define DIM0_SUB 3 /* subset dimensions */
-#define DIM1_SUB 4
+#define DATASETNAME "IntArray"
+#define RANK 2
+#define DIM0_SUB 3 /* subset dimensions */
+#define DIM1_SUB 4
-#define DIM0 8 /* size of dataset */
-#define DIM1 10
+#define DIM0 8 /* size of dataset */
+#define DIM1 10
int
-main (void)
+main(void)
{
- hsize_t dims[2], dimsm[2];
- int data[DIM0][DIM1]; /* data to write */
- int sdata[DIM0_SUB][DIM1_SUB]; /* subset to write */
- int rdata[DIM0][DIM1]; /* buffer for read */
-
- hid_t file_id, dataset_id; /* handles */
- hid_t dataspace_id, memspace_id;
-
- herr_t status;
-
- hsize_t count[2]; /* size of subset in the file */
- hsize_t offset[2]; /* subset offset in the file */
- hsize_t stride[2];
- hsize_t block[2];
- int i, j;
-
-
+ hsize_t dims[2], dimsm[2];
+ int data[DIM0][DIM1]; /* data to write */
+ int sdata[DIM0_SUB][DIM1_SUB]; /* subset to write */
+ int rdata[DIM0][DIM1]; /* buffer for read */
+
+ hid_t file_id, dataset_id; /* handles */
+ hid_t dataspace_id, memspace_id;
+
+ herr_t status;
+
+ hsize_t count[2]; /* size of subset in the file */
+ hsize_t offset[2]; /* subset offset in the file */
+ hsize_t stride[2];
+ hsize_t block[2];
+ int i, j;
+
/*****************************************************************
* Create a new file with default creation and access properties.*
* Then create a dataset and write data to it and close the file *
* and dataset. *
*****************************************************************/
- file_id = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
- dims[0] = DIM0;
- dims[1] = DIM1;
- dataspace_id = H5Screate_simple (RANK, dims, NULL);
+ file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- dataset_id = H5Dcreate2 (file_id, DATASETNAME, H5T_STD_I32BE, dataspace_id,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dims[0] = DIM0;
+ dims[1] = DIM1;
+ dataspace_id = H5Screate_simple(RANK, dims, NULL);
+ dataset_id =
+ H5Dcreate2(file_id, DATASETNAME, H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for (j = 0; j < DIM0; j++) {
- for (i = 0; i < DIM1; i++)
- if (i< (DIM1/2))
- data[j][i] = 1;
+ for (i = 0; i < DIM1; i++)
+ if (i < (DIM1 / 2))
+ data[j][i] = 1;
else
- data[j][i] = 2;
- }
+ data[j][i] = 2;
+ }
- status = H5Dwrite (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- H5P_DEFAULT, data);
+ status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
- printf ("\nData Written to File:\n");
- for (i = 0; i<DIM0; i++){
- for (j = 0; j<DIM1; j++)
- printf (" %i", data[i][j]);
- printf ("\n");
+ printf("\nData Written to File:\n");
+ for (i = 0; i < DIM0; i++) {
+ for (j = 0; j < DIM1; j++)
+ printf(" %i", data[i][j]);
+ printf("\n");
}
- status = H5Sclose (dataspace_id);
- status = H5Dclose (dataset_id);
- status = H5Fclose (file_id);
-
+ status = H5Sclose(dataspace_id);
+ status = H5Dclose(dataset_id);
+ status = H5Fclose(file_id);
/*****************************************************
* Reopen the file and dataset and write a subset of *
- * values to the dataset.
+ * values to the dataset.
*****************************************************/
- file_id = H5Fopen (FILE, H5F_ACC_RDWR, H5P_DEFAULT);
- dataset_id = H5Dopen2 (file_id, DATASETNAME, H5P_DEFAULT);
+ file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT);
+ dataset_id = H5Dopen2(file_id, DATASETNAME, H5P_DEFAULT);
/* Specify size and shape of subset to write. */
offset[0] = 1;
offset[1] = 2;
- count[0] = DIM0_SUB;
- count[1] = DIM1_SUB;
+ count[0] = DIM0_SUB;
+ count[1] = DIM1_SUB;
stride[0] = 1;
stride[1] = 1;
@@ -109,43 +104,39 @@ main (void)
block[0] = 1;
block[1] = 1;
- /* Create memory space with size of subset. Get file dataspace
+ /* Create memory space with size of subset. Get file dataspace
and select subset from file dataspace. */
- dimsm[0] = DIM0_SUB;
- dimsm[1] = DIM1_SUB;
- memspace_id = H5Screate_simple (RANK, dimsm, NULL);
+ dimsm[0] = DIM0_SUB;
+ dimsm[1] = DIM1_SUB;
+ memspace_id = H5Screate_simple(RANK, dimsm, NULL);
- dataspace_id = H5Dget_space (dataset_id);
- status = H5Sselect_hyperslab (dataspace_id, H5S_SELECT_SET, offset,
- stride, count, block);
+ dataspace_id = H5Dget_space(dataset_id);
+ status = H5Sselect_hyperslab(dataspace_id, H5S_SELECT_SET, offset, stride, count, block);
- /* Write a subset of data to the dataset, then read the
+ /* Write a subset of data to the dataset, then read the
entire dataset back from the file. */
- printf ("\nWrite subset to file specifying:\n");
- printf (" offset=1x2 stride=1x1 count=3x4 block=1x1\n");
+ printf("\nWrite subset to file specifying:\n");
+ printf(" offset=1x2 stride=1x1 count=3x4 block=1x1\n");
for (j = 0; j < DIM0_SUB; j++) {
- for (i = 0; i < DIM1_SUB; i++)
- sdata[j][i] = 5;
- }
-
- status = H5Dwrite (dataset_id, H5T_NATIVE_INT, memspace_id,
- dataspace_id, H5P_DEFAULT, sdata);
-
- status = H5Dread (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- H5P_DEFAULT, rdata);
-
- printf ("\nData in File after Subset is Written:\n");
- for (i = 0; i<DIM0; i++){
- for (j = 0; j<DIM1; j++)
- printf (" %i", rdata[i][j]);
- printf ("\n");
+ for (i = 0; i < DIM1_SUB; i++)
+ sdata[j][i] = 5;
+ }
+
+ status = H5Dwrite(dataset_id, H5T_NATIVE_INT, memspace_id, dataspace_id, H5P_DEFAULT, sdata);
+
+ status = H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
+
+ printf("\nData in File after Subset is Written:\n");
+ for (i = 0; i < DIM0; i++) {
+ for (j = 0; j < DIM1; j++)
+ printf(" %i", rdata[i][j]);
+ printf("\n");
}
- status = H5Sclose (memspace_id);
- status = H5Sclose (dataspace_id);
- status = H5Dclose (dataset_id);
- status = H5Fclose (file_id);
-
+ status = H5Sclose(memspace_id);
+ status = H5Sclose(dataspace_id);
+ status = H5Dclose(dataset_id);
+ status = H5Fclose(file_id);
}
diff --git a/examples/h5_write.c b/examples/h5_write.c
index 1a7cfe7..c2bf136 100644
--- a/examples/h5_write.c
+++ b/examples/h5_write.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,28 +18,28 @@
#include "hdf5.h"
-#define H5FILE_NAME "SDS.h5"
+#define H5FILE_NAME "SDS.h5"
#define DATASETNAME "IntArray"
-#define NX 5 /* dataset dimensions */
-#define NY 6
-#define RANK 2
+#define NX 5 /* dataset dimensions */
+#define NY 6
+#define RANK 2
int
-main (void)
+main(void)
{
- hid_t file, dataset; /* file and dataset handles */
- hid_t datatype, dataspace; /* handles */
- hsize_t dimsf[2]; /* dataset dimensions */
- herr_t status;
- int data[NX][NY]; /* data to write */
- int i, j;
+ hid_t file, dataset; /* file and dataset handles */
+ hid_t datatype, dataspace; /* handles */
+ hsize_t dimsf[2]; /* dataset dimensions */
+ herr_t status;
+ int data[NX][NY]; /* data to write */
+ int i, j;
/*
* Data and output buffer initialization.
*/
- for(j = 0; j < NX; j++)
- for(i = 0; i < NY; i++)
- data[j][i] = i + j;
+ for (j = 0; j < NX; j++)
+ for (i = 0; i < NY; i++)
+ data[j][i] = i + j;
/*
* 0 1 2 3 4 5
* 1 2 3 4 5 6
@@ -59,8 +59,8 @@ main (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(RANK, dimsf, NULL);
/*
@@ -68,14 +68,13 @@ main (void)
* 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);
/*
* Create a new dataset within the file using defined dataspace and
* datatype and default dataset creation properties.
*/
- dataset = H5Dcreate2(file, DATASETNAME, datatype, dataspace,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(file, DATASETNAME, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/*
* Write the data to the dataset using default transfer properties.
@@ -92,4 +91,3 @@ main (void)
return 0;
}
-
diff --git a/examples/ph5example.c b/examples/ph5example.c
index d718479..a5f3c75 100644
--- a/examples/ph5example.c
+++ b/examples/ph5example.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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -46,69 +46,73 @@
/* Define some handy debugging shorthands, routines, ... */
/* debugging tools */
-#define MESG(x)\
- if (verbose) printf("%s\n", x);\
-
-#define MPI_BANNER(mesg)\
- {printf("--------------------------------\n");\
- printf("Proc %d: ", mpi_rank); \
- printf("*** %s\n", mesg);\
- printf("--------------------------------\n");}
+#define MESG(x) \
+ if (verbose) \
+ printf("%s\n", x);
+
+#define MPI_BANNER(mesg) \
+ { \
+ printf("--------------------------------\n"); \
+ printf("Proc %d: ", mpi_rank); \
+ printf("*** %s\n", mesg); \
+ printf("--------------------------------\n"); \
+ }
-#define SYNC(comm)\
- {MPI_BANNER("doing a SYNC"); MPI_Barrier(comm); MPI_BANNER("SYNC DONE");}
+#define SYNC(comm) \
+ { \
+ MPI_BANNER("doing a SYNC"); \
+ MPI_Barrier(comm); \
+ MPI_BANNER("SYNC DONE"); \
+ }
/* End of Define some handy debugging shorthands, routines, ... */
/* Constants definitions */
/* 24 is a multiple of 2, 3, 4, 6, 8, 12. Neat for parallel tests. */
-#define SPACE1_DIM1 24
-#define SPACE1_DIM2 24
-#define SPACE1_RANK 2
-#define DATASETNAME1 "Data1"
-#define DATASETNAME2 "Data2"
-#define DATASETNAME3 "Data3"
+#define SPACE1_DIM1 24
+#define SPACE1_DIM2 24
+#define SPACE1_RANK 2
+#define DATASETNAME1 "Data1"
+#define DATASETNAME2 "Data2"
+#define DATASETNAME3 "Data3"
/* hyperslab layout styles */
-#define BYROW 1 /* divide into slabs of rows */
-#define BYCOL 2 /* divide into blocks of columns */
-
-#define PARAPREFIX "HDF5_PARAPREFIX" /* file prefix environment variable name */
+#define BYROW 1 /* divide into slabs of rows */
+#define BYCOL 2 /* divide into blocks of columns */
+#define PARAPREFIX "HDF5_PARAPREFIX" /* file prefix environment variable name */
/* dataset data type. Int's can be easily octo dumped. */
typedef int DATATYPE;
/* global variables */
-int nerrors = 0; /* errors count */
+int nerrors = 0; /* errors count */
#ifndef PATH_MAX
-#define PATH_MAX 512
-#endif /* !PATH_MAX */
-char testfiles[2][PATH_MAX];
+#define PATH_MAX 512
+#endif /* !PATH_MAX */
+char testfiles[2][PATH_MAX];
-
-int mpi_size, mpi_rank; /* mpi variables */
+int mpi_size, mpi_rank; /* mpi variables */
/* option flags */
-int verbose = 0; /* verbose, default as no. */
-int doread=1; /* read test */
-int dowrite=1; /* write test */
-int docleanup=1; /* cleanup */
+int verbose = 0; /* verbose, default as no. */
+int doread = 1; /* read test */
+int dowrite = 1; /* write test */
+int docleanup = 1; /* cleanup */
/* Prototypes */
void slab_set(hsize_t start[], hsize_t count[], hsize_t stride[], int mode);
-void dataset_fill(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE * dataset);
-void dataset_print(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE * dataset);
-int dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset, DATATYPE *original);
+void dataset_fill(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset);
+void dataset_print(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset);
+int dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset, DATATYPE *original);
void phdf5writeInd(char *filename);
void phdf5readInd(char *filename);
void phdf5writeAll(char *filename);
void phdf5readAll(char *filename);
void test_split_comm_access(char filenames[][PATH_MAX]);
-int parse_options(int argc, char **argv);
+int parse_options(int argc, char **argv);
void usage(void);
-int mkfilenames(char *prefix);
+int mkfilenames(char *prefix);
void cleanup(void);
-
/*
* Setup the dimensions of the hyperslab.
* Two modes--by rows or by columns.
@@ -117,113 +121,110 @@ void cleanup(void);
void
slab_set(hsize_t start[], hsize_t count[], hsize_t stride[], int mode)
{
- switch (mode){
- case BYROW:
- /* Each process takes a slabs of rows. */
- stride[0] = 1;
- stride[1] = 1;
- count[0] = SPACE1_DIM1/mpi_size;
- count[1] = SPACE1_DIM2;
- start[0] = mpi_rank*count[0];
- start[1] = 0;
- break;
- case BYCOL:
- /* Each process takes a block of columns. */
- stride[0] = 1;
- stride[1] = 1;
- count[0] = SPACE1_DIM1;
- count[1] = SPACE1_DIM2/mpi_size;
- start[0] = 0;
- start[1] = mpi_rank*count[1];
- break;
- default:
- /* Unknown mode. Set it to cover the whole dataset. */
- printf("unknown slab_set mode (%d)\n", mode);
- stride[0] = 1;
- stride[1] = 1;
- count[0] = SPACE1_DIM1;
- count[1] = SPACE1_DIM2;
- start[0] = 0;
- start[1] = 0;
- break;
+ switch (mode) {
+ case BYROW:
+ /* Each process takes a slabs of rows. */
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = SPACE1_DIM1 / mpi_size;
+ count[1] = SPACE1_DIM2;
+ start[0] = mpi_rank * count[0];
+ start[1] = 0;
+ break;
+ case BYCOL:
+ /* Each process takes a block of columns. */
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = SPACE1_DIM1;
+ count[1] = SPACE1_DIM2 / mpi_size;
+ start[0] = 0;
+ start[1] = mpi_rank * count[1];
+ break;
+ default:
+ /* Unknown mode. Set it to cover the whole dataset. */
+ printf("unknown slab_set mode (%d)\n", mode);
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = SPACE1_DIM1;
+ count[1] = SPACE1_DIM2;
+ start[0] = 0;
+ start[1] = 0;
+ break;
}
}
-
/*
* Fill the dataset with trivial data for testing.
* Assume dimension rank is 2 and data is stored contiguous.
*/
void
-dataset_fill(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE * dataset)
+dataset_fill(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset)
{
DATATYPE *dataptr = dataset;
- hsize_t i, j;
+ hsize_t i, j;
/* put some trivial data in the data_array */
- for (i=0; i < count[0]; i++){
- for (j=0; j < count[1]; j++){
- *dataptr++ = (i*stride[0]+start[0])*100 + (j*stride[1]+start[1]+1);
- }
+ for (i = 0; i < count[0]; i++) {
+ for (j = 0; j < count[1]; j++) {
+ *dataptr++ = (i * stride[0] + start[0]) * 100 + (j * stride[1] + start[1] + 1);
+ }
}
}
-
/*
* Print the content of the dataset.
*/
-void dataset_print(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE * dataset)
+void
+dataset_print(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset)
{
DATATYPE *dataptr = dataset;
- hsize_t i, j;
+ hsize_t i, j;
/* print the slab read */
- for (i=0; i < count[0]; i++){
- printf("Row %lu: ", (unsigned long)(i*stride[0]+start[0]));
- for (j=0; j < count[1]; j++){
- printf("%03d ", *dataptr++);
- }
- printf("\n");
+ for (i = 0; i < count[0]; i++) {
+ printf("Row %lu: ", (unsigned long)(i * stride[0] + start[0]));
+ for (j = 0; j < count[1]; j++) {
+ printf("%03d ", *dataptr++);
+ }
+ printf("\n");
}
}
-
/*
* Print the content of the dataset.
*/
-int dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset, DATATYPE *original)
+int
+dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset, DATATYPE *original)
{
-#define MAX_ERR_REPORT 10 /* Maximum number of errors reported */
+#define MAX_ERR_REPORT 10 /* Maximum number of errors reported */
hsize_t i, j;
- int nerr;
+ int nerr;
/* print it if verbose */
if (verbose)
- dataset_print(start, count, stride, dataset);
+ dataset_print(start, count, stride, dataset);
nerr = 0;
- for (i=0; i < count[0]; i++){
- for (j=0; j < count[1]; j++){
- if (*dataset++ != *original++){
- nerr++;
- if (nerr <= MAX_ERR_REPORT){
- printf("Dataset Verify failed at [%lu][%lu](row %lu, col %lu): expect %d, got %d\n",
- (unsigned long)i, (unsigned long)j,
- (unsigned long)(i*stride[0]+start[0]), (unsigned long)(j*stride[1]+start[1]),
- *(dataset-1), *(original-1));
- }
- }
- }
+ for (i = 0; i < count[0]; i++) {
+ for (j = 0; j < count[1]; j++) {
+ if (*dataset++ != *original++) {
+ nerr++;
+ if (nerr <= MAX_ERR_REPORT) {
+ printf("Dataset Verify failed at [%lu][%lu](row %lu, col %lu): expect %d, got %d\n",
+ (unsigned long)i, (unsigned long)j, (unsigned long)(i * stride[0] + start[0]),
+ (unsigned long)(j * stride[1] + start[1]), *(dataset - 1), *(original - 1));
+ }
+ }
+ }
}
if (nerr > MAX_ERR_REPORT)
- printf("[more errors ...]\n");
+ printf("[more errors ...]\n");
if (nerr)
- printf("%d errors found in dataset_vrfy\n", nerr);
- return(nerr);
+ printf("%d errors found in dataset_vrfy\n", nerr);
+ return (nerr);
}
-
/*
* Example of using the parallel HDF5 library to create two datasets
* in one HDF5 files with parallel MPIO access support.
@@ -235,32 +236,31 @@ int dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *d
void
phdf5writeInd(char *filename)
{
- hid_t fid1; /* HDF5 file IDs */
- hid_t acc_tpl1; /* File access templates */
- hid_t sid1; /* Dataspace ID */
- hid_t file_dataspace; /* File dataspace ID */
- hid_t mem_dataspace; /* memory dataspace ID */
- hid_t dataset1, dataset2; /* Dataset ID */
- hsize_t dims1[SPACE1_RANK] =
- {SPACE1_DIM1,SPACE1_DIM2}; /* dataspace dim sizes */
- DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */
+ hid_t fid1; /* HDF5 file IDs */
+ hid_t acc_tpl1; /* File access templates */
+ hid_t sid1; /* Dataspace ID */
+ hid_t file_dataspace; /* File dataspace ID */
+ hid_t mem_dataspace; /* memory dataspace ID */
+ hid_t dataset1, dataset2; /* Dataset ID */
+ hsize_t dims1[SPACE1_RANK] = {SPACE1_DIM1, SPACE1_DIM2}; /* dataspace dim sizes */
+ DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */
- hsize_t start[SPACE1_RANK]; /* for hyperslab setting */
- hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */
+ hsize_t start[SPACE1_RANK]; /* for hyperslab setting */
+ hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */
- herr_t ret; /* Generic return value */
+ herr_t ret; /* Generic return value */
MPI_Comm comm = MPI_COMM_WORLD;
MPI_Info info = MPI_INFO_NULL;
if (verbose)
- printf("Independent write test on file %s\n", filename);
+ printf("Independent write test on file %s\n", filename);
/* -------------------
* START AN HDF5 FILE
* -------------------*/
/* setup file access template with parallel IO access. */
- acc_tpl1 = H5Pcreate (H5P_FILE_ACCESS);
+ acc_tpl1 = H5Pcreate(H5P_FILE_ACCESS);
assert(acc_tpl1 != FAIL);
MESG("H5Pcreate access succeed");
/* set Parallel access with communicator */
@@ -277,70 +277,60 @@ phdf5writeInd(char *filename)
ret = H5Pclose(acc_tpl1);
assert(ret != FAIL);
-
/* --------------------------
* Define the dimensions of the overall datasets
* and the slabs local to the MPI process.
* ------------------------- */
/* setup dimensionality object */
sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
- assert (sid1 != FAIL);
+ assert(sid1 != FAIL);
MESG("H5Screate_simple succeed");
-
/* create a dataset collectively */
- dataset1 = H5Dcreate2(fid1, DATASETNAME1, H5T_NATIVE_INT, sid1,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset1 = H5Dcreate2(fid1, DATASETNAME1, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
assert(dataset1 != FAIL);
MESG("H5Dcreate2 succeed");
/* create another dataset collectively */
- dataset2 = H5Dcreate2(fid1, DATASETNAME2, H5T_NATIVE_INT, sid1,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset2 = H5Dcreate2(fid1, DATASETNAME2, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
assert(dataset2 != FAIL);
MESG("H5Dcreate2 succeed");
-
-
/* set up dimensions of the slab this process accesses */
- start[0] = mpi_rank*SPACE1_DIM1/mpi_size;
- start[1] = 0;
- count[0] = SPACE1_DIM1/mpi_size;
- count[1] = SPACE1_DIM2;
+ start[0] = mpi_rank * SPACE1_DIM1 / mpi_size;
+ start[1] = 0;
+ count[0] = SPACE1_DIM1 / mpi_size;
+ count[1] = SPACE1_DIM2;
stride[0] = 1;
- stride[1] =1;
-if (verbose)
- printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n",
- (unsigned long)start[0], (unsigned long)start[1],
- (unsigned long)count[0], (unsigned long)count[1],
- (unsigned long)(count[0]*count[1]));
+ stride[1] = 1;
+ if (verbose)
+ printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", (unsigned long)start[0],
+ (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1],
+ (unsigned long)(count[0] * count[1]));
/* put some trivial data in the data_array */
dataset_fill(start, count, stride, &data_array1[0][0]);
MESG("data_array initialized");
/* create a file dataspace independently */
- file_dataspace = H5Dget_space (dataset1);
+ file_dataspace = H5Dget_space(dataset1);
assert(file_dataspace != FAIL);
MESG("H5Dget_space succeed");
- ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride,
- count, NULL);
+ ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, NULL);
assert(ret != FAIL);
MESG("H5Sset_hyperslab succeed");
/* create a memory dataspace independently */
- mem_dataspace = H5Screate_simple (SPACE1_RANK, count, NULL);
- assert (mem_dataspace != FAIL);
+ mem_dataspace = H5Screate_simple(SPACE1_RANK, count, NULL);
+ assert(mem_dataspace != FAIL);
/* write data independently */
- ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace,
- H5P_DEFAULT, data_array1);
+ ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1);
assert(ret != FAIL);
MESG("H5Dwrite succeed");
/* write data independently */
- ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace,
- H5P_DEFAULT, data_array1);
+ ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1);
assert(ret != FAIL);
MESG("H5Dwrite succeed");
@@ -348,10 +338,10 @@ if (verbose)
H5Sclose(file_dataspace);
/* close dataset collectively */
- ret=H5Dclose(dataset1);
+ ret = H5Dclose(dataset1);
assert(ret != FAIL);
MESG("H5Dclose1 succeed");
- ret=H5Dclose(dataset2);
+ ret = H5Dclose(dataset2);
assert(ret != FAIL);
MESG("H5Dclose2 succeed");
@@ -366,39 +356,38 @@ if (verbose)
void
phdf5readInd(char *filename)
{
- hid_t fid1; /* HDF5 file IDs */
- hid_t acc_tpl1; /* File access templates */
- hid_t file_dataspace; /* File dataspace ID */
- hid_t mem_dataspace; /* memory dataspace ID */
- hid_t dataset1, dataset2; /* Dataset ID */
- DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */
- DATATYPE data_origin1[SPACE1_DIM1][SPACE1_DIM2]; /* expected data buffer */
+ hid_t fid1; /* HDF5 file IDs */
+ hid_t acc_tpl1; /* File access templates */
+ hid_t file_dataspace; /* File dataspace ID */
+ hid_t mem_dataspace; /* memory dataspace ID */
+ hid_t dataset1, dataset2; /* Dataset ID */
+ DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */
+ DATATYPE data_origin1[SPACE1_DIM1][SPACE1_DIM2]; /* expected data buffer */
- hsize_t start[SPACE1_RANK]; /* for hyperslab setting */
- hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */
+ hsize_t start[SPACE1_RANK]; /* for hyperslab setting */
+ hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */
- herr_t ret; /* Generic return value */
+ herr_t ret; /* Generic return value */
MPI_Comm comm = MPI_COMM_WORLD;
MPI_Info info = MPI_INFO_NULL;
if (verbose)
- printf("Independent read test on file %s\n", filename);
+ printf("Independent read test on file %s\n", filename);
/* setup file access template */
- acc_tpl1 = H5Pcreate (H5P_FILE_ACCESS);
+ acc_tpl1 = H5Pcreate(H5P_FILE_ACCESS);
assert(acc_tpl1 != FAIL);
/* set Parallel access with communicator */
ret = H5Pset_fapl_mpio(acc_tpl1, comm, info);
assert(ret != FAIL);
-
/* open the file collectively */
- fid1=H5Fopen(filename,H5F_ACC_RDWR,acc_tpl1);
+ fid1 = H5Fopen(filename, H5F_ACC_RDWR, acc_tpl1);
assert(fid1 != FAIL);
/* Release file-access template */
- ret=H5Pclose(acc_tpl1);
+ ret = H5Pclose(acc_tpl1);
assert(ret != FAIL);
/* open the dataset1 collectively */
@@ -409,37 +398,33 @@ phdf5readInd(char *filename)
dataset2 = H5Dopen2(fid1, DATASETNAME1, H5P_DEFAULT);
assert(dataset2 != FAIL);
-
/* set up dimensions of the slab this process accesses */
- start[0] = mpi_rank*SPACE1_DIM1/mpi_size;
- start[1] = 0;
- count[0] = SPACE1_DIM1/mpi_size;
- count[1] = SPACE1_DIM2;
+ start[0] = mpi_rank * SPACE1_DIM1 / mpi_size;
+ start[1] = 0;
+ count[0] = SPACE1_DIM1 / mpi_size;
+ count[1] = SPACE1_DIM2;
stride[0] = 1;
- stride[1] =1;
-if (verbose)
- printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n",
- (unsigned long)start[0], (unsigned long)start[1],
- (unsigned long)count[0], (unsigned long)count[1],
- (unsigned long)(count[0]*count[1]));
+ stride[1] = 1;
+ if (verbose)
+ printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", (unsigned long)start[0],
+ (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1],
+ (unsigned long)(count[0] * count[1]));
/* create a file dataspace independently */
- file_dataspace = H5Dget_space (dataset1);
+ file_dataspace = H5Dget_space(dataset1);
assert(file_dataspace != FAIL);
- ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride,
- count, NULL);
+ ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, NULL);
assert(ret != FAIL);
/* create a memory dataspace independently */
- mem_dataspace = H5Screate_simple (SPACE1_RANK, count, NULL);
- assert (mem_dataspace != FAIL);
+ mem_dataspace = H5Screate_simple(SPACE1_RANK, count, NULL);
+ assert(mem_dataspace != FAIL);
/* fill dataset with test data */
dataset_fill(start, count, stride, &data_origin1[0][0]);
/* read data independently */
- ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace,
- H5P_DEFAULT, data_array1);
+ ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1);
assert(ret != FAIL);
/* verify the read data with original expected data */
@@ -447,8 +432,7 @@ if (verbose)
assert(ret != FAIL);
/* read data independently */
- ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace,
- H5P_DEFAULT, data_array1);
+ ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1);
assert(ret != FAIL);
/* verify the read data with original expected data */
@@ -456,9 +440,9 @@ if (verbose)
assert(ret == 0);
/* close dataset collectively */
- ret=H5Dclose(dataset1);
+ ret = H5Dclose(dataset1);
assert(ret != FAIL);
- ret=H5Dclose(dataset2);
+ ret = H5Dclose(dataset2);
assert(ret != FAIL);
/* release all IDs created */
@@ -468,7 +452,6 @@ if (verbose)
H5Fclose(fid1);
}
-
/*
* Example of using the parallel HDF5 library to create two datasets
* in one HDF5 file with collective parallel access support.
@@ -481,33 +464,32 @@ if (verbose)
void
phdf5writeAll(char *filename)
{
- hid_t fid1; /* HDF5 file IDs */
- hid_t acc_tpl1; /* File access templates */
- hid_t xfer_plist; /* Dataset transfer properties list */
- hid_t sid1; /* Dataspace ID */
- hid_t file_dataspace; /* File dataspace ID */
- hid_t mem_dataspace; /* memory dataspace ID */
- hid_t dataset1, dataset2; /* Dataset ID */
- hsize_t dims1[SPACE1_RANK] =
- {SPACE1_DIM1,SPACE1_DIM2}; /* dataspace dim sizes */
- DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */
-
- hsize_t start[SPACE1_RANK]; /* for hyperslab setting */
- hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */
-
- herr_t ret; /* Generic return value */
+ hid_t fid1; /* HDF5 file IDs */
+ hid_t acc_tpl1; /* File access templates */
+ hid_t xfer_plist; /* Dataset transfer properties list */
+ hid_t sid1; /* Dataspace ID */
+ hid_t file_dataspace; /* File dataspace ID */
+ hid_t mem_dataspace; /* memory dataspace ID */
+ hid_t dataset1, dataset2; /* Dataset ID */
+ hsize_t dims1[SPACE1_RANK] = {SPACE1_DIM1, SPACE1_DIM2}; /* dataspace dim sizes */
+ DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */
+
+ hsize_t start[SPACE1_RANK]; /* for hyperslab setting */
+ hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */
+
+ herr_t ret; /* Generic return value */
MPI_Comm comm = MPI_COMM_WORLD;
MPI_Info info = MPI_INFO_NULL;
if (verbose)
- printf("Collective write test on file %s\n", filename);
+ printf("Collective write test on file %s\n", filename);
/* -------------------
* START AN HDF5 FILE
* -------------------*/
/* setup file access template with parallel IO access. */
- acc_tpl1 = H5Pcreate (H5P_FILE_ACCESS);
+ acc_tpl1 = H5Pcreate(H5P_FILE_ACCESS);
assert(acc_tpl1 != FAIL);
MESG("H5Pcreate access succeed");
/* set Parallel access with communicator */
@@ -516,25 +498,23 @@ phdf5writeAll(char *filename)
MESG("H5Pset_fapl_mpio succeed");
/* create the file collectively */
- fid1=H5Fcreate(filename,H5F_ACC_TRUNC,H5P_DEFAULT,acc_tpl1);
+ fid1 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl1);
assert(fid1 != FAIL);
MESG("H5Fcreate succeed");
/* Release file-access template */
- ret=H5Pclose(acc_tpl1);
+ ret = H5Pclose(acc_tpl1);
assert(ret != FAIL);
-
/* --------------------------
* Define the dimensions of the overall datasets
* and create the dataset
* ------------------------- */
/* setup dimensionality object */
- sid1 = H5Screate_simple (SPACE1_RANK, dims1, NULL);
- assert (sid1 != FAIL);
+ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
+ assert(sid1 != FAIL);
MESG("H5Screate_simple succeed");
-
/* create a dataset collectively */
dataset1 = H5Dcreate2(fid1, DATASETNAME1, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
assert(dataset1 != FAIL);
@@ -551,43 +531,40 @@ phdf5writeAll(char *filename)
/* Dataset1: each process takes a block of rows. */
slab_set(start, count, stride, BYROW);
-if (verbose)
- printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n",
- (unsigned long)start[0], (unsigned long)start[1],
- (unsigned long)count[0], (unsigned long)count[1],
- (unsigned long)(count[0]*count[1]));
+ if (verbose)
+ printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", (unsigned long)start[0],
+ (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1],
+ (unsigned long)(count[0] * count[1]));
/* create a file dataspace independently */
- file_dataspace = H5Dget_space (dataset1);
+ file_dataspace = H5Dget_space(dataset1);
assert(file_dataspace != FAIL);
MESG("H5Dget_space succeed");
- ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride,
- count, NULL);
+ ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, NULL);
assert(ret != FAIL);
MESG("H5Sset_hyperslab succeed");
/* create a memory dataspace independently */
- mem_dataspace = H5Screate_simple (SPACE1_RANK, count, NULL);
- assert (mem_dataspace != FAIL);
+ mem_dataspace = H5Screate_simple(SPACE1_RANK, count, NULL);
+ assert(mem_dataspace != FAIL);
/* fill the local slab with some trivial data */
dataset_fill(start, count, stride, &data_array1[0][0]);
MESG("data_array initialized");
- if (verbose){
- MESG("data_array created");
- dataset_print(start, count, stride, &data_array1[0][0]);
+ if (verbose) {
+ MESG("data_array created");
+ dataset_print(start, count, stride, &data_array1[0][0]);
}
/* set up the collective transfer properties list */
- xfer_plist = H5Pcreate (H5P_DATASET_XFER);
+ xfer_plist = H5Pcreate(H5P_DATASET_XFER);
assert(xfer_plist != FAIL);
- ret=H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
+ ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
assert(ret != FAIL);
MESG("H5Pcreate xfer succeed");
/* write data collectively */
- ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace,
- xfer_plist, data_array1);
+ ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1);
assert(ret != FAIL);
MESG("H5Dwrite succeed");
@@ -600,51 +577,48 @@ if (verbose)
/* Dataset2: each process takes a block of columns. */
slab_set(start, count, stride, BYCOL);
-if (verbose)
- printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n",
- (unsigned long)start[0], (unsigned long)start[1],
- (unsigned long)count[0], (unsigned long)count[1],
- (unsigned long)(count[0]*count[1]));
+ if (verbose)
+ printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", (unsigned long)start[0],
+ (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1],
+ (unsigned long)(count[0] * count[1]));
/* put some trivial data in the data_array */
dataset_fill(start, count, stride, &data_array1[0][0]);
MESG("data_array initialized");
- if (verbose){
- MESG("data_array created");
- dataset_print(start, count, stride, &data_array1[0][0]);
+ if (verbose) {
+ MESG("data_array created");
+ dataset_print(start, count, stride, &data_array1[0][0]);
}
/* create a file dataspace independently */
- file_dataspace = H5Dget_space (dataset1);
+ file_dataspace = H5Dget_space(dataset1);
assert(file_dataspace != FAIL);
MESG("H5Dget_space succeed");
- ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride,
- count, NULL);
+ ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, NULL);
assert(ret != FAIL);
MESG("H5Sset_hyperslab succeed");
/* create a memory dataspace independently */
- mem_dataspace = H5Screate_simple (SPACE1_RANK, count, NULL);
- assert (mem_dataspace != FAIL);
+ mem_dataspace = H5Screate_simple(SPACE1_RANK, count, NULL);
+ assert(mem_dataspace != FAIL);
/* fill the local slab with some trivial data */
dataset_fill(start, count, stride, &data_array1[0][0]);
MESG("data_array initialized");
- if (verbose){
- MESG("data_array created");
- dataset_print(start, count, stride, &data_array1[0][0]);
+ if (verbose) {
+ MESG("data_array created");
+ dataset_print(start, count, stride, &data_array1[0][0]);
}
/* set up the collective transfer properties list */
- xfer_plist = H5Pcreate (H5P_DATASET_XFER);
+ xfer_plist = H5Pcreate(H5P_DATASET_XFER);
assert(xfer_plist != FAIL);
- ret=H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
+ ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
assert(ret != FAIL);
MESG("H5Pcreate xfer succeed");
/* write data independently */
- ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace,
- xfer_plist, data_array1);
+ ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1);
assert(ret != FAIL);
MESG("H5Dwrite succeed");
@@ -653,14 +627,13 @@ if (verbose)
H5Sclose(mem_dataspace);
H5Pclose(xfer_plist);
-
/*
* All writes completed. Close datasets collectively
*/
- ret=H5Dclose(dataset1);
+ ret = H5Dclose(dataset1);
assert(ret != FAIL);
MESG("H5Dclose1 succeed");
- ret=H5Dclose(dataset2);
+ ret = H5Dclose(dataset2);
assert(ret != FAIL);
MESG("H5Dclose2 succeed");
@@ -683,31 +656,31 @@ if (verbose)
void
phdf5readAll(char *filename)
{
- hid_t fid1; /* HDF5 file IDs */
- hid_t acc_tpl1; /* File access templates */
- hid_t xfer_plist; /* Dataset transfer properties list */
- hid_t file_dataspace; /* File dataspace ID */
- hid_t mem_dataspace; /* memory dataspace ID */
- hid_t dataset1, dataset2; /* Dataset ID */
- DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */
- DATATYPE data_origin1[SPACE1_DIM1][SPACE1_DIM2]; /* expected data buffer */
+ hid_t fid1; /* HDF5 file IDs */
+ hid_t acc_tpl1; /* File access templates */
+ hid_t xfer_plist; /* Dataset transfer properties list */
+ hid_t file_dataspace; /* File dataspace ID */
+ hid_t mem_dataspace; /* memory dataspace ID */
+ hid_t dataset1, dataset2; /* Dataset ID */
+ DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */
+ DATATYPE data_origin1[SPACE1_DIM1][SPACE1_DIM2]; /* expected data buffer */
- hsize_t start[SPACE1_RANK]; /* for hyperslab setting */
- hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */
+ hsize_t start[SPACE1_RANK]; /* for hyperslab setting */
+ hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */
- herr_t ret; /* Generic return value */
+ herr_t ret; /* Generic return value */
MPI_Comm comm = MPI_COMM_WORLD;
MPI_Info info = MPI_INFO_NULL;
if (verbose)
- printf("Collective read test on file %s\n", filename);
+ printf("Collective read test on file %s\n", filename);
/* -------------------
* OPEN AN HDF5 FILE
* -------------------*/
/* setup file access template with parallel IO access. */
- acc_tpl1 = H5Pcreate (H5P_FILE_ACCESS);
+ acc_tpl1 = H5Pcreate(H5P_FILE_ACCESS);
assert(acc_tpl1 != FAIL);
MESG("H5Pcreate access succeed");
/* set Parallel access with communicator */
@@ -716,15 +689,14 @@ phdf5readAll(char *filename)
MESG("H5Pset_fapl_mpio succeed");
/* open the file collectively */
- fid1=H5Fopen(filename,H5F_ACC_RDWR,acc_tpl1);
+ fid1 = H5Fopen(filename, H5F_ACC_RDWR, acc_tpl1);
assert(fid1 != FAIL);
MESG("H5Fopen succeed");
/* Release file-access template */
- ret=H5Pclose(acc_tpl1);
+ ret = H5Pclose(acc_tpl1);
assert(ret != FAIL);
-
/* --------------------------
* Open the datasets in it
* ------------------------- */
@@ -744,43 +716,40 @@ phdf5readAll(char *filename)
/* Dataset1: each process takes a block of columns. */
slab_set(start, count, stride, BYCOL);
-if (verbose)
- printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n",
- (unsigned long)start[0], (unsigned long)start[1],
- (unsigned long)count[0], (unsigned long)count[1],
- (unsigned long)(count[0]*count[1]));
+ if (verbose)
+ printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", (unsigned long)start[0],
+ (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1],
+ (unsigned long)(count[0] * count[1]));
/* create a file dataspace independently */
- file_dataspace = H5Dget_space (dataset1);
+ file_dataspace = H5Dget_space(dataset1);
assert(file_dataspace != FAIL);
MESG("H5Dget_space succeed");
- ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride,
- count, NULL);
+ ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, NULL);
assert(ret != FAIL);
MESG("H5Sset_hyperslab succeed");
/* create a memory dataspace independently */
- mem_dataspace = H5Screate_simple (SPACE1_RANK, count, NULL);
- assert (mem_dataspace != FAIL);
+ mem_dataspace = H5Screate_simple(SPACE1_RANK, count, NULL);
+ assert(mem_dataspace != FAIL);
/* fill dataset with test data */
dataset_fill(start, count, stride, &data_origin1[0][0]);
MESG("data_array initialized");
- if (verbose){
- MESG("data_array created");
- dataset_print(start, count, stride, &data_array1[0][0]);
+ if (verbose) {
+ MESG("data_array created");
+ dataset_print(start, count, stride, &data_array1[0][0]);
}
/* set up the collective transfer properties list */
- xfer_plist = H5Pcreate (H5P_DATASET_XFER);
+ xfer_plist = H5Pcreate(H5P_DATASET_XFER);
assert(xfer_plist != FAIL);
- ret=H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
+ ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
assert(ret != FAIL);
MESG("H5Pcreate xfer succeed");
/* read data collectively */
- ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace,
- xfer_plist, data_array1);
+ ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1);
assert(ret != FAIL);
MESG("H5Dread succeed");
@@ -797,43 +766,40 @@ if (verbose)
/* Dataset2: each process takes a block of rows. */
slab_set(start, count, stride, BYROW);
-if (verbose)
- printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n",
- (unsigned long)start[0], (unsigned long)start[1],
- (unsigned long)count[0], (unsigned long)count[1],
- (unsigned long)(count[0]*count[1]));
+ if (verbose)
+ printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", (unsigned long)start[0],
+ (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1],
+ (unsigned long)(count[0] * count[1]));
/* create a file dataspace independently */
- file_dataspace = H5Dget_space (dataset1);
+ file_dataspace = H5Dget_space(dataset1);
assert(file_dataspace != FAIL);
MESG("H5Dget_space succeed");
- ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride,
- count, NULL);
+ ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, NULL);
assert(ret != FAIL);
MESG("H5Sset_hyperslab succeed");
/* create a memory dataspace independently */
- mem_dataspace = H5Screate_simple (SPACE1_RANK, count, NULL);
- assert (mem_dataspace != FAIL);
+ mem_dataspace = H5Screate_simple(SPACE1_RANK, count, NULL);
+ assert(mem_dataspace != FAIL);
/* fill dataset with test data */
dataset_fill(start, count, stride, &data_origin1[0][0]);
MESG("data_array initialized");
- if (verbose){
- MESG("data_array created");
- dataset_print(start, count, stride, &data_array1[0][0]);
+ if (verbose) {
+ MESG("data_array created");
+ dataset_print(start, count, stride, &data_array1[0][0]);
}
/* set up the collective transfer properties list */
- xfer_plist = H5Pcreate (H5P_DATASET_XFER);
+ xfer_plist = H5Pcreate(H5P_DATASET_XFER);
assert(xfer_plist != FAIL);
- ret=H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
+ ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
assert(ret != FAIL);
MESG("H5Pcreate xfer succeed");
/* read data independently */
- ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace,
- xfer_plist, data_array1);
+ ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1);
assert(ret != FAIL);
MESG("H5Dread succeed");
@@ -846,14 +812,13 @@ if (verbose)
H5Sclose(mem_dataspace);
H5Pclose(xfer_plist);
-
/*
* All reads completed. Close datasets collectively
*/
- ret=H5Dclose(dataset1);
+ ret = H5Dclose(dataset1);
assert(ret != FAIL);
MESG("H5Dclose1 succeed");
- ret=H5Dclose(dataset2);
+ ret = H5Dclose(dataset2);
assert(ret != FAIL);
MESG("H5Dclose2 succeed");
@@ -877,51 +842,51 @@ test_split_comm_access(char filenames[][PATH_MAX])
{
MPI_Comm comm;
MPI_Info info = MPI_INFO_NULL;
- int color, mrc;
- int newrank, newprocs;
- hid_t fid; /* file IDs */
- hid_t acc_tpl; /* File access properties */
- herr_t ret; /* generic return value */
+ int color, mrc;
+ int newrank, newprocs;
+ hid_t fid; /* file IDs */
+ hid_t acc_tpl; /* File access properties */
+ herr_t ret; /* generic return value */
if (verbose)
- printf("Independent write test on file %s %s\n",
- filenames[0], filenames[1]);
-
- color = mpi_rank%2;
- mrc = MPI_Comm_split (MPI_COMM_WORLD, color, mpi_rank, &comm);
- assert(mrc==MPI_SUCCESS);
- MPI_Comm_size(comm,&newprocs);
- MPI_Comm_rank(comm,&newrank);
-
- if (color){
- /* odd-rank processes */
- mrc = MPI_Barrier(comm);
- assert(mrc==MPI_SUCCESS);
- }else{
- /* even-rank processes */
- /* setup file access template */
- acc_tpl = H5Pcreate (H5P_FILE_ACCESS);
- assert(acc_tpl != FAIL);
-
- /* set Parallel access with communicator */
- ret = H5Pset_fapl_mpio(acc_tpl, comm, info);
- assert(ret != FAIL);
-
- /* create the file collectively */
- fid=H5Fcreate(filenames[color],H5F_ACC_TRUNC,H5P_DEFAULT,acc_tpl);
- assert(fid != FAIL);
- MESG("H5Fcreate succeed");
-
- /* Release file-access template */
- ret=H5Pclose(acc_tpl);
- assert(ret != FAIL);
-
- ret=H5Fclose(fid);
- assert(ret != FAIL);
+ printf("Independent write test on file %s %s\n", filenames[0], filenames[1]);
+
+ color = mpi_rank % 2;
+ mrc = MPI_Comm_split(MPI_COMM_WORLD, color, mpi_rank, &comm);
+ assert(mrc == MPI_SUCCESS);
+ MPI_Comm_size(comm, &newprocs);
+ MPI_Comm_rank(comm, &newrank);
+
+ if (color) {
+ /* odd-rank processes */
+ mrc = MPI_Barrier(comm);
+ assert(mrc == MPI_SUCCESS);
}
- if (mpi_rank == 0){
- mrc = MPI_File_delete(filenames[color], info);
- assert(mrc==MPI_SUCCESS);
+ else {
+ /* even-rank processes */
+ /* setup file access template */
+ acc_tpl = H5Pcreate(H5P_FILE_ACCESS);
+ assert(acc_tpl != FAIL);
+
+ /* set Parallel access with communicator */
+ ret = H5Pset_fapl_mpio(acc_tpl, comm, info);
+ assert(ret != FAIL);
+
+ /* create the file collectively */
+ fid = H5Fcreate(filenames[color], H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl);
+ assert(fid != FAIL);
+ MESG("H5Fcreate succeed");
+
+ /* Release file-access template */
+ ret = H5Pclose(acc_tpl);
+ assert(ret != FAIL);
+
+ ret = H5Fclose(fid);
+ assert(ret != FAIL);
+ }
+ if (mpi_rank == 0) {
+ mrc = MPI_File_delete(filenames[color], info);
+ assert(mrc == MPI_SUCCESS);
}
}
@@ -944,7 +909,6 @@ usage(void)
printf("\n");
}
-
/*
* compose the test filename with the prefix supplied.
* return code: 0 if no error
@@ -953,88 +917,93 @@ usage(void)
int
mkfilenames(char *prefix)
{
- int i, n;
+ int i, n;
size_t strsize;
/* filename will be prefix/ParaEgN.h5 where N is 0 to 9. */
/* So, string must be big enough to hold the prefix, / and 10 more chars */
/* and the terminating null. */
strsize = strlen(prefix) + 12;
- if (strsize > PATH_MAX){
- printf("File prefix too long; Use a short path name.\n");
- return(1);
+ if (strsize > PATH_MAX) {
+ printf("File prefix too long; Use a short path name.\n");
+ return (1);
}
- n = sizeof(testfiles)/sizeof(testfiles[0]);
- if (n > 9){
- printf("Warning: Too many entries in testfiles. "
- "Need to adjust the code to accommodate the large size.\n");
+ n = sizeof(testfiles) / sizeof(testfiles[0]);
+ if (n > 9) {
+ printf("Warning: Too many entries in testfiles. "
+ "Need to adjust the code to accommodate the large size.\n");
}
- for (i=0; i<n; i++){
- sprintf(testfiles[i], "%s/ParaEg%d.h5", prefix, i);
+ for (i = 0; i < n; i++) {
+ sprintf(testfiles[i], "%s/ParaEg%d.h5", prefix, i);
}
- return(0);
-
+ return (0);
}
-
/*
* parse the command line options
*/
int
-parse_options(int argc, char **argv){
+parse_options(int argc, char **argv)
+{
int i, n;
/* initialize testfiles to nulls */
- n = sizeof(testfiles)/sizeof(testfiles[0]);
- for (i=0; i<n; i++){
- testfiles[i][0] = '\0';
+ n = sizeof(testfiles) / sizeof(testfiles[0]);
+ for (i = 0; i < n; i++) {
+ testfiles[i][0] = '\0';
}
- while (--argc){
- if (**(++argv) != '-'){
- break;
- }else{
- switch(*(*argv+1)){
- case 'f': ++argv;
- if (--argc < 1){
- usage();
- nerrors++;
- return(1);
- }
- if (mkfilenames(*argv)){
- nerrors++;
- return(1);
- }
- break;
- case 'c': docleanup = 0; /* no cleanup */
- break;
- case 'r': doread = 0;
- break;
- case 'w': dowrite = 0;
- break;
- case 'v': verbose = 1;
- break;
- default: usage();
- nerrors++;
- return(1);
- }
- }
+ while (--argc) {
+ if (**(++argv) != '-') {
+ break;
+ }
+ else {
+ switch (*(*argv + 1)) {
+ case 'f':
+ ++argv;
+ if (--argc < 1) {
+ usage();
+ nerrors++;
+ return (1);
+ }
+ if (mkfilenames(*argv)) {
+ nerrors++;
+ return (1);
+ }
+ break;
+ case 'c':
+ docleanup = 0; /* no cleanup */
+ break;
+ case 'r':
+ doread = 0;
+ break;
+ case 'w':
+ dowrite = 0;
+ break;
+ case 'v':
+ verbose = 1;
+ break;
+ default:
+ usage();
+ nerrors++;
+ return (1);
+ }
+ }
}
/* check the file prefix */
- if (testfiles[0][0] == '\0'){
- /* try get it from environment variable HDF5_PARAPREFIX */
- char *env;
- char *env_default = "."; /* default to current directory */
- if ((env=getenv(PARAPREFIX))==NULL){
- env = env_default;
- }
- mkfilenames(env);
+ if (testfiles[0][0] == '\0') {
+ /* try get it from environment variable HDF5_PARAPREFIX */
+ char *env;
+ char *env_default = "."; /* default to current directory */
+ if ((env = getenv(PARAPREFIX)) == NULL) {
+ env = env_default;
+ }
+ mkfilenames(env);
}
- return(0);
+ return (0);
}
-
/*
* cleanup test files created
*/
@@ -1043,88 +1012,87 @@ cleanup(void)
{
int i, n;
- n = sizeof(testfiles)/sizeof(testfiles[0]);
- for (i=0; i<n; i++){
- MPI_File_delete(testfiles[i], MPI_INFO_NULL);
+ n = sizeof(testfiles) / sizeof(testfiles[0]);
+ for (i = 0; i < n; i++) {
+ MPI_File_delete(testfiles[i], MPI_INFO_NULL);
}
}
-
/* Main Program */
int
main(int argc, char **argv)
{
- int mpi_namelen;
+ int mpi_namelen;
char mpi_name[MPI_MAX_PROCESSOR_NAME];
- int i, n;
+ int i, n;
- MPI_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&mpi_size);
- MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank);
- MPI_Get_processor_name(mpi_name,&mpi_namelen);
+ MPI_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
+ MPI_Get_processor_name(mpi_name, &mpi_namelen);
/* Make sure datasets can be divided into equal chunks by the processes */
- if ((SPACE1_DIM1 % mpi_size) || (SPACE1_DIM2 % mpi_size)){
- printf("DIM1(%d) and DIM2(%d) must be multiples of processes (%d)\n",
- SPACE1_DIM1, SPACE1_DIM2, mpi_size);
- nerrors++;
- goto finish;
+ if ((SPACE1_DIM1 % mpi_size) || (SPACE1_DIM2 % mpi_size)) {
+ printf("DIM1(%d) and DIM2(%d) must be multiples of processes (%d)\n", SPACE1_DIM1, SPACE1_DIM2,
+ mpi_size);
+ nerrors++;
+ goto finish;
}
if (parse_options(argc, argv) != 0)
- goto finish;
+ goto finish;
/* show test file names */
- if (mpi_rank == 0){
- n = sizeof(testfiles)/sizeof(testfiles[0]);
- printf("Parallel test files are:\n");
- for (i=0; i<n; i++){
- printf(" %s\n", testfiles[i]);
- }
+ if (mpi_rank == 0) {
+ n = sizeof(testfiles) / sizeof(testfiles[0]);
+ printf("Parallel test files are:\n");
+ for (i = 0; i < n; i++) {
+ printf(" %s\n", testfiles[i]);
+ }
}
- if (dowrite){
- MPI_BANNER("testing PHDF5 dataset using split communicators...");
- test_split_comm_access(testfiles);
- MPI_BANNER("testing PHDF5 dataset independent write...");
- phdf5writeInd(testfiles[0]);
- MPI_BANNER("testing PHDF5 dataset collective write...");
- phdf5writeAll(testfiles[1]);
+ if (dowrite) {
+ MPI_BANNER("testing PHDF5 dataset using split communicators...");
+ test_split_comm_access(testfiles);
+ MPI_BANNER("testing PHDF5 dataset independent write...");
+ phdf5writeInd(testfiles[0]);
+ MPI_BANNER("testing PHDF5 dataset collective write...");
+ phdf5writeAll(testfiles[1]);
}
- if (doread){
- MPI_BANNER("testing PHDF5 dataset independent read...");
- phdf5readInd(testfiles[0]);
- MPI_BANNER("testing PHDF5 dataset collective read...");
- phdf5readAll(testfiles[1]);
+ if (doread) {
+ MPI_BANNER("testing PHDF5 dataset independent read...");
+ phdf5readInd(testfiles[0]);
+ MPI_BANNER("testing PHDF5 dataset collective read...");
+ phdf5readAll(testfiles[1]);
}
- if (!(dowrite || doread)){
- usage();
- nerrors++;
+ if (!(dowrite || doread)) {
+ usage();
+ nerrors++;
}
finish:
- if (mpi_rank == 0){ /* only process 0 reports */
- if (nerrors)
- printf("***PHDF5 tests detected %d errors***\n", nerrors);
- else{
- printf("===================================\n");
- printf("PHDF5 tests finished with no errors\n");
- printf("===================================\n");
- }
+ if (mpi_rank == 0) { /* only process 0 reports */
+ if (nerrors)
+ printf("***PHDF5 tests detected %d errors***\n", nerrors);
+ else {
+ printf("===================================\n");
+ printf("PHDF5 tests finished with no errors\n");
+ printf("===================================\n");
+ }
}
if (docleanup)
- cleanup();
+ cleanup();
MPI_Finalize();
- return(nerrors);
+ return (nerrors);
}
-#else /* H5_HAVE_PARALLEL */
+#else /* H5_HAVE_PARALLEL */
/* dummy program since H5_HAVE_PARALLE is not configured in */
int
main(void)
{
-printf("No PHDF5 example because parallel is not configured in\n");
-return(0);
+ printf("No PHDF5 example because parallel is not configured in\n");
+ return (0);
}
#endif /* H5_HAVE_PARALLEL */
diff --git a/examples/run-all-ex.sh b/examples/run-all-ex.sh
index 878e0f8..afd4308 100755
--- a/examples/run-all-ex.sh
+++ b/examples/run-all-ex.sh
@@ -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/examples/run-c-ex.sh.in b/examples/run-c-ex.sh.in
index a684a38..dc3f7ae 100644
--- a/examples/run-c-ex.sh.in
+++ b/examples/run-c-ex.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.
@@ -18,7 +18,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# This script will compile and run the c examples from source files installed #
-# in .../share/hdf5_examples/c using h5cc or h5pc. The order for running #
+# in @examplesdir@/c using h5cc or h5pc. The order for running #
# programs with RunTest in the MAIN section below is taken from the Makefile. #
# The order is important since some of the test programs use data files created #
# by earlier test programs. Any future additions should be placed accordingly. #
@@ -28,10 +28,33 @@
# Initializations
EXIT_SUCCESS=0
EXIT_FAILURE=1
-
+
+#
+# Try to derive the path to the installation $prefix established
+# by ./configure relative to the examples directory established by
+# ./configure. If successful, set `prefix_relto_examplesdir` to the
+# relative path. Otherwise, set `prefix_relto_examplesdir` to the
+# absolute installation $prefix.
+#
+# This script uses the value of `prefix` in the user's environment, if
+# it is set, below. The content of $() is evaluated in a sub-shell, so
+# if `prefix` is set in the user's environment, the shell statements in
+# $() won't clobbered it.
+#
+prefix_relto_examplesdir=$(
+prefix=@prefix@
+examplesdir=@examplesdir@
+if [ ${examplesdir##${prefix}/} != ${examplesdir} ]; then
+ echo $(echo ${examplesdir##${prefix}/} | \
+ sed 's,[^/][^/]*,..,g')
+else
+ echo $prefix
+fi
+)
+
# Where the tool is installed.
# default is relative path to installed location of the tools
-prefix="${prefix:-../../../}"
+prefix="${prefix:-../${prefix_relto_examplesdir}}"
PARALLEL=@PARALLEL@ # Am I in parallel mode?
AR="@AR@"
RANLIB="@RANLIB@"
diff --git a/examples/testh5cc.sh.in b/examples/testh5cc.sh.in
index 4e898c1..71254d2 100644
--- a/examples/testh5cc.sh.in
+++ b/examples/testh5cc.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.
#
@@ -29,8 +29,7 @@ EXIT_SUCCESS=0
EXIT_FAILURE=1
# Where the tool is installed.
-# Note: no '/' after DESTDIR. Explanation in commence.am
-prefix="${prefix:-${DESTDIR}@prefix@}"
+prefix="${prefix:-@prefix@}"
PARALLEL=@PARALLEL@ # Am I in parallel mode?
AR="@AR@"
RANLIB="@RANLIB@"