diff options
80 files changed, 3402 insertions, 2095 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d86d29e..aff3f86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -274,10 +274,10 @@ SET (H5_ENABLE_SHARED_LIB NO) SET (H5_ENABLE_STATIC_LIB NO) IF (BUILD_SHARED_LIBS) SET (LIB_TYPE SHARED) - ADD_DEFINITIONS (-DH5_BUILT_AS_DYNAMIC_LIB) + SET (H5_BUILT_AS_DYNAMIC_LIB 1) SET (H5_ENABLE_SHARED_LIB YES) ELSE (BUILD_SHARED_LIBS) - ADD_DEFINITIONS (-DH5_BUILT_AS_STATIC_LIB) + SET (H5_BUILT_AS_STATIC_LIB 1) SET (H5_ENABLE_STATIC_LIB YES) IF (NOT WIN32) # should this be a user setting : Everyone uses it anyway ? @@ -666,7 +666,7 @@ IF (WIN32 AND NOT CYGWIN) IF (HDF5_ENABLE_THREADSAFE) # check for unsupported options IF (HDF5_ENABLE_PARALLEL) - MESSAGE (FATAL " **** Parallel and Threadsafe options are mutually exclusive **** ") + MESSAGE (FATAL_ERROR " **** Parallel and Threadsafe options are mutually exclusive **** ") ENDIF (HDF5_ENABLE_PARALLEL) SET (H5_HAVE_THREADSAFE 1) IF (H5_HAVE_IOEO) @@ -675,7 +675,7 @@ IF (WIN32 AND NOT CYGWIN) ELSE (H5_HAVE_IOEO) IF (NOT H5_HAVE_PTHREAD_H) SET (H5_HAVE_THREADSAFE 0) - MESSAGE (FATAL " **** Threadsafe option requires thread library **** ") + MESSAGE (FATAL_ERROR " **** Threadsafe option requires thread library **** ") ENDIF (NOT H5_HAVE_PTHREAD_H) ENDIF (H5_HAVE_IOEO) ENDIF (HDF5_ENABLE_THREADSAFE) @@ -757,6 +757,9 @@ SET (H5_FC_FUNC_ "H5_FC_FUNC_(name,NAME) name ## _") IF (EXISTS "${HDF5_SOURCE_DIR}/fortran" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/fortran") OPTION (HDF5_BUILD_FORTRAN "Build FORTRAN support" OFF) IF (HDF5_BUILD_FORTRAN) + IF (BUILD_SHARED_LIBS AND APPLE) + MESSAGE (FATAL_ERROR " **** Shared FORTRAN libraries are unsupported **** ") + ENDIF (BUILD_SHARED_LIBS AND APPLE) OPTION (HDF5_ENABLE_F2003 "Enable FORTRAN 2003 Standard" OFF) INCLUDE (${HDF5_RESOURCES_DIR}/HDF5UseFortran.cmake) IF (HDF5_ENABLE_F2003) @@ -798,7 +801,7 @@ IF (EXISTS "${HDF5_SOURCE_DIR}/c++" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/c++") IF (HDF5_BUILD_CPP_LIB) # check for unsupported options IF (HDF5_ENABLE_PARALLEL) - MESSAGE (FATAL " **** Parallel and C++ options are mutually exclusive **** ") + MESSAGE (FATAL_ERROR " **** Parallel and C++ options are mutually exclusive **** ") ENDIF (HDF5_ENABLE_PARALLEL) IF (CMAKE_NO_STD_NAMESPACE) SET (H5_NO_STD 1) @@ -999,7 +1002,6 @@ IF (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) SET (CPACK_PACKAGE_VENDOR "HDF_Group") SET (CPACK_PACKAGE_NAME "${HDF5_PACKAGE_NAME}") SET (CPACK_PACKAGE_INSTALL_DIRECTORY "${HDF5_PACKAGE_NAME}") - SET (CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${HDF5_PACKAGE_NAME}-${HDF5_PACKAGE_VERSION}-${LIB_TYPE}") SET (CPACK_PACKAGE_VERSION "${HDF5_PACKAGE_VERSION}") SET (CPACK_PACKAGE_VERSION_MAJOR "${HDF5_PACKAGE_VERSION_MAJOR}") SET (CPACK_PACKAGE_VERSION_MINOR "${HDF5_PACKAGE_VERSION_MINOR}") @@ -1012,10 +1014,15 @@ IF (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) SET (CPACK_PACKAGE_RELOCATABLE TRUE) IF (WIN32) + SET (CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${HDF5_PACKAGE_NAME}-${HDF5_PACKAGE_VERSION}-${LIB_TYPE}") SET (CPACK_MONOLITHIC_INSTALL ON) SET (CPACK_NSIS_CONTACT "${HDF5_PACKAGE_BUGREPORT}") SET (CPACK_NSIS_MODIFY_PATH ON) SET (CPACK_NSIS_PACKAGE_NAME "HDF5 ${HDF5_PACKAGE_VERSION}") + ELSEIF (APPLE) + SET (CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE ON) + SET (CPACK_PACKAGE_DEFAULT_LOCATION "/opt/${CPACK_PACKAGE_NAME}") + SET (CPACK_PACKAGING_INSTALL_PREFIX "/") ELSE (WIN32) SET (CPACK_PACKAGING_INSTALL_PREFIX "/usr") SET (CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE ON) @@ -46,6 +46,7 @@ ./bin/chkconfigure _DO_NOT_DISTRIBUTE_ ./bin/chkcopyright _DO_NOT_DISTRIBUTE_ ./bin/chkmanifest +./bin/cmakehdf5 ./bin/compile ./bin/config.guess ./bin/config.sub @@ -121,6 +122,15 @@ ./examples/Makefile.in ./examples/h5_chunk_read.c ./examples/h5_compound.c +./examples/h5_crtgrpd.c +./examples/h5_subset.c +./examples/h5_cmprss.c +./examples/h5_rdwt.c +./examples/h5_crtgrpar.c +./examples/h5_extend.c +./examples/h5_crtatt.c +./examples/h5_crtgrp.c +./examples/h5_crtdat.c ./examples/h5_drivers.c ./examples/h5_dtransform.c ./examples/h5_elink_unix2win.c @@ -238,22 +248,24 @@ ./fortran/examples/Makefile.am ./fortran/examples/Makefile.in -./fortran/examples/attrexample.f90 ./fortran/examples/compound.f90 ./fortran/examples/compound_fortran2003.f90 ./fortran/examples/compound_complex_fortran2003.f90 -./fortran/examples/dsetexample.f90 -./fortran/examples/fileexample.f90 -./fortran/examples/groupexample.f90 -./fortran/examples/grpdsetexample.f90 -./fortran/examples/grpsexample.f90 +./fortran/examples/h5_cmprss.f90 +./fortran/examples/h5_crtatt.f90 +./fortran/examples/h5_crtdat.f90 +./fortran/examples/h5_crtgrp.f90 +./fortran/examples/h5_crtgrpar.f90 +./fortran/examples/h5_crtgrpd.f90 +./fortran/examples/h5_extend.f90 +./fortran/examples/h5_rdwt.f90 +./fortran/examples/h5_subset.f90 ./fortran/examples/hyperslab.f90 ./fortran/examples/mountexample.f90 ./fortran/examples/ph5example.f90 ./fortran/examples/refobjexample.f90 ./fortran/examples/refregexample.f90 ./fortran/examples/run-fortran-ex.sh.in -./fortran/examples/rwdsetexample.f90 ./fortran/examples/selectele.f90 ./fortran/examples/testh5fc.sh.in ./fortran/examples/nested_derived_type.f90 @@ -1072,8 +1084,8 @@ ./test/tvltypes.c ./test/unlink.c ./test/vfd.c -./test/test_filters_le.hdf5 -./test/test_filters_be.hdf5 +./test/test_filters_le.h5 +./test/test_filters_be.h5 ./test/gen_filters.c ./test/chunk_info.c @@ -2142,7 +2154,6 @@ ./hl/examples/image8.txt ./hl/examples/pal_rgb.h ./hl/examples/ptExampleFL.c -./hl/examples/ptExampleVL.c ./hl/examples/run-hl-ex.sh ./hl/examples/run-hlc-ex.sh.in ./hl/src/COPYING @@ -2200,9 +2211,9 @@ ./hl/test/test_table.c ./hl/test/test_ds_le.h5 ./hl/test/test_ds_be.h5 -./hl/test/test_table_le.hdf5 -./hl/test/test_table_be.hdf5 -./hl/test/test_table_cray.hdf5 +./hl/test/test_table_le.h5 +./hl/test/test_table_be.h5 +./hl/test/test_table_cray.h5 ./hl/test/usa.wri # tools @@ -2260,7 +2271,6 @@ ./hl/c++/examples/Makefile.am ./hl/c++/examples/Makefile.in ./hl/c++/examples/ptExampleFL.cpp -./hl/c++/examples/ptExampleVL.cpp ./hl/c++/examples/run-hlc++-ex.sh.in ./hl/c++/src/H5PacketTable.h ./hl/c++/src/H5PacketTable.cpp @@ -1,4 +1,4 @@ -HDF5 version 1.9.136 currently under development +HDF5 version 1.9.140 currently under development Please refer to the release_docs/INSTALL file for installation instructions. ------------------------------------------------------------------------------ diff --git a/bin/cmakehdf5 b/bin/cmakehdf5 new file mode 100755 index 0000000..622788f --- /dev/null +++ b/bin/cmakehdf5 @@ -0,0 +1,206 @@ +#! /bin/sh +# Build and Test HDF5 using cmake. +# Author: Allen Byrne +# Albert Cheng +# Creation Date: Nov 2012 + +# Copyright: The HDF Group, 2012 + +# Debug: remove the comment hash if you want DPRINT to do echo +DPRINT=: +#DPRINT=echo + +# variable names +progname=`basename $0` # program name +cminfile="cmakemin.$$" # Cmake minimum file +cfgfile=$progname.$$ # configure file +$DPRINT $cfgfile + +# Remove temporary generated files if exit 0 +trap "rm -f $cminfile $cfgfile" 0 + +#========== +# main +#========== +# First generate the two needed input files, the $cimnfile and $cfgfile. +# Then use ctest to use the two input files. + +# This works only in Jam for now. +# Exit if not running in Jam. +if [ `hostname` != jam ]; then + echo This is known to work in Jam for now. + echo It may fail in other machines. + echo Support for more platforms is coming. + echo +fi + + +#========== +# create the configure file +#========== +# Create the cmake minimum required file to be used by the following +# configure file. Though not absolute needed, it is better to generate +# this file before the configure file. Quote the EOF to preven substitution +# in the text. +#========== +#========== +cat > $cfgfile <<'EOF' +cmake_minimum_required(VERSION 2.8.6 FATAL_ERROR) +######################################################## +# This dashboard is maintained by The HDF Group +# For any comments please contact cdashhelp@hdfgroup.org +# +######################################################## + +set (CTEST_DASHBOARD_ROOT ${CTEST_SCRIPT_DIRECTORY}) +set (CTEST_SOURCE_DIRECTORY "../hdf5") +set (CTEST_BINARY_DIRECTORY ".") +set (CTEST_CMAKE_GENERATOR "Unix Makefiles") +set (CTEST_BUILD_CONFIGURATION "Release") + +# -- CDash variables +#set (LOCAL_NO_SUBMIT TRUE) +set (MODEL "Experimental") +set (CDASH_LOCAL TRUE) +set (SITE_BUILDNAME_SUFFIX "SHARED") + +# -- URL set for internal check, default is to not update +set (LOCAL_SKIP_UPDATE TRUE) +set (REPOSITORY_URL "http://svn.hdfgroup.uiuc.edu/hdf5/branches/hdf5_1_8") +# -- Standard build options +set (ADD_BUILD_OPTIONS "-DCMAKE_INSTALL_PREFIX:PATH=/usr/local/hdf5.1.8 -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING=\"SVN\" -DHDF5_PACKAGE_EXTLIBS:BOOL=ON") + +# Use multiple CPU cores to build +SET (CTEST_BUILD_FLAGS "-j4") + +# ----------------------------------------------------------- +# -- Get environment +# ----------------------------------------------------------- + ## -- set hostname + ## -------------------------- + find_program (HOSTNAME_CMD NAMES hostname) + exec_program (${HOSTNAME_CMD} ARGS OUTPUT_VARIABLE HOSTNAME) + set (CTEST_SITE "${HOSTNAME}${CTEST_SITE_EXT}") + find_program (UNAME NAMES uname) + macro (getuname name flag) + exec_program ("${UNAME}" ARGS "${flag}" OUTPUT_VARIABLE "${name}") + endmacro (getuname) + + getuname (osname -s) + getuname (osrel -r) + getuname (cpu -m) + + if (SITE_BUILDNAME_SUFFIX) + set (CTEST_BUILD_NAME "${osname}-${osrel}-${cpu}-${SITE_BUILDNAME_SUFFIX}") + else (SITE_BUILDNAME_SUFFIX) + set (CTEST_BUILD_NAME "${osname}-${osrel}-${cpu}") + endif (SITE_BUILDNAME_SUFFIX) +# ----------------------------------------------------------- + +set (BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DSITE:STRING=${CTEST_SITE} -DBUILDNAME:STRING=${CTEST_BUILD_NAME}") + +#----------------------------------------------------------------------------- +# MAC machines need special option +#----------------------------------------------------------------------------- +if (APPLE) + # Compiler choice + execute_process(COMMAND xcrun --find cc OUTPUT_VARIABLE XCODE_CC OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND xcrun --find c++ OUTPUT_VARIABLE XCODE_CXX OUTPUT_STRIP_TRAILING_WHITESPACE) + SET(ENV{CC} "${XCODE_CC}") + SET(ENV{CXX} "${XCODE_CXX}") + # Shared fortran is not supported, build static + set (BUILD_OPTIONS "${BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_ANSI_CFLAGS:STRING=-fPIC") + set (BUILD_OPTIONS "${BUILD_OPTIONS} -DCTEST_USE_LAUNCHERS:BOOL=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF") +endif (APPLE) + + +# ----------------------------------------------------------- +find_package (Subversion) +set (CTEST_UPDATE_COMMAND "${Subversion_SVN_EXECUTABLE}") +# -- Only clean build folder if LOCAL_CLEAR_BUILD is set +if (LOCAL_CLEAR_BUILD) + set (CTEST_START_WITH_EMPTY_BINARY_DIRECTORY TRUE) + ctest_empty_binary_directory (${CTEST_BINARY_DIRECTORY}) +endif (LOCAL_CLEAR_BUILD) + +#----------------------------------------------------------------------------- +# Send the main script as a note. +list (APPEND CTEST_NOTES_FILES + "${CMAKE_CURRENT_LIST_FILE}" + "${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake" + ) + +# Check for required variables. +foreach (req + CTEST_CMAKE_GENERATOR + CTEST_SITE + CTEST_BUILD_NAME + ) + if (NOT DEFINED ${req}) + message(FATAL_ERROR "The containing script must set ${req}") + endif (NOT DEFINED ${req}) +endforeach (req) + +## -- set output to english +set($ENV{LC_MESSAGES} "en_EN") + +#----------------------------------------------------------------------------- +# Initialize the CTEST commands +#------------------------------ +SET (CTEST_CMAKE_COMMAND "\"${CMAKE_COMMAND}\"") +SET (CTEST_CONFIGURE_COMMAND + "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_SOURCE_DIRECTORY}\"") + +# Print summary information. +foreach (v + CTEST_SITE + CTEST_BUILD_NAME + CTEST_SOURCE_DIRECTORY + CTEST_BINARY_DIRECTORY + CTEST_CMAKE_GENERATOR + CTEST_BUILD_CONFIGURATION + CTEST_CONFIGURE_COMMAND + CTEST_SCRIPT_DIRECTORY + ) + set (vars "${vars} ${v}=[${${v}}]\n") +endforeach (v) +message ("Dashboard script configuration:\n${vars}\n") + +CTEST_START (${MODEL} TRACK ${MODEL}) +if (NOT LOCAL_SKIP_UPDATE) + CTEST_UPDATE (SOURCE "${CTEST_SOURCE_DIRECTORY}") +endif (NOT LOCAL_SKIP_UPDATE) +CTEST_CONFIGURE (BUILD "${CTEST_BINARY_DIRECTORY}") +message ("Configure DONE") +CTEST_READ_CUSTOM_FILES ("${CTEST_BINARY_DIRECTORY}") +if (NOT LOCAL_NO_SUBMIT) + CTEST_SUBMIT (PARTS Update Configure Notes) +endif (NOT LOCAL_NO_SUBMIT) +CTEST_BUILD (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND) +if (NOT LOCAL_NO_SUBMIT) + CTEST_SUBMIT (PARTS Build) +endif (NOT LOCAL_NO_SUBMIT) +message ("build DONE") +if (NOT LOCAL_SKIP_TEST) + CTEST_TEST (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND) + if (NOT LOCAL_NO_SUBMIT) + CTEST_SUBMIT (PARTS Test) + endif (NOT LOCAL_NO_SUBMIT) + message ("test DONE") +endif (NOT LOCAL_SKIP_TEST) + +message ("DONE") +EOF + + +# Run ctest +date +ctest -S $cfgfile -C Release -O testhdf.log +exit_code=$? +if [ $exit_code = 0 ]; then + echo Complete without error +else + echo Error encountered +fi +date +exit $exit_code diff --git a/c++/src/Makefile.in b/c++/src/Makefile.in index 52e32ff..9d14b76 100644 --- a/c++/src/Makefile.in +++ b/c++/src/Makefile.in @@ -467,7 +467,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 126 +LT_VERS_REVISION = 130 LT_VERS_AGE = 0 # Include src directory diff --git a/config/cmake/CPack.cmake b/config/cmake/CPack.cmake index 2e6b23a..d96fe43 100644 --- a/config/cmake/CPack.cmake +++ b/config/cmake/CPack.cmake @@ -1,5 +1,7 @@ -# - Build binary and source package installers -# +##section Variables common to all CPack generators +##end +##module +# - Build binary and source package installers. # The CPack module generates binary and source installers in a variety # of formats using the cpack program. Inclusion of the CPack module # adds two new targets to the resulting makefiles, package and @@ -29,16 +31,16 @@ # on a per-generator basis. It only need contain overrides. # # Here's how it works: -# - cpack runs -# - it includes CPackConfig.cmake -# - it iterates over the generators listed in that file's -# CPACK_GENERATOR list variable (unless told to use just a -# specific one via -G on the command line...) +# - cpack runs +# - it includes CPackConfig.cmake +# - it iterates over the generators listed in that file's +# CPACK_GENERATOR list variable (unless told to use just a +# specific one via -G on the command line...) # -# - foreach generator, it then -# - sets CPACK_GENERATOR to the one currently being iterated -# - includes the CPACK_PROJECT_CONFIG_FILE -# - produces the package for that generator +# - foreach generator, it then +# - sets CPACK_GENERATOR to the one currently being iterated +# - includes the CPACK_PROJECT_CONFIG_FILE +# - produces the package for that generator # # This is the key: For each generator listed in CPACK_GENERATOR # in CPackConfig.cmake, cpack will *reset* CPACK_GENERATOR @@ -48,174 +50,225 @@ # Before including this CPack module in your CMakeLists.txt file, # there are a variety of variables that can be set to customize # the resulting installers. The most commonly-used variables are: -# -# CPACK_PACKAGE_NAME - The name of the package (or application). If -# not specified, defaults to the project name. -# -# CPACK_PACKAGE_VENDOR - The name of the package vendor (e.g., -# "Kitware"). -# -# CPACK_PACKAGE_VERSION_MAJOR - Package major Version -# -# CPACK_PACKAGE_VERSION_MINOR - Package minor Version -# -# CPACK_PACKAGE_VERSION_PATCH - Package patch Version -# -# CPACK_PACKAGE_DESCRIPTION_FILE - A text file used to describe the -# project. Used, for example, the introduction screen of a -# CPack-generated Windows installer to describe the project. -# -# CPACK_PACKAGE_DESCRIPTION_SUMMARY - Short description of the -# project (only a few words). -# -# CPACK_PACKAGE_FILE_NAME - The name of the package file to generate, -# not including the extension. For example, cmake-2.6.1-Linux-i686. -# -# CPACK_PACKAGE_INSTALL_DIRECTORY - Installation directory on the -# target system, e.g., "CMake 2.5". -# -# CPACK_PROJECT_CONFIG_FILE - File included at cpack time, once per -# generator after setting CPACK_GENERATOR to the actual generator -# being used. Allows per-generator setting of CPACK_* variables at -# cpack time. -# -# CPACK_RESOURCE_FILE_LICENSE - License file for the project, which -# will typically be displayed to the user (often with an explicit -# "Accept" button, for graphical installers) prior to installation. -# -# CPACK_RESOURCE_FILE_README - ReadMe file for the project, which -# typically describes in some detail -# -# CPACK_RESOURCE_FILE_WELCOME - Welcome file for the project, which -# welcomes users to this installer. Typically used in the graphical -# installers on Windows and Mac OS X. -# -# CPACK_MONOLITHIC_INSTALL - Disables the component-based -# installation mechanism, so that all components are always installed. -# -# CPACK_GENERATOR - List of CPack generators to use. If not -# specified, CPack will create a set of options (e.g., -# CPACK_BINARY_NSIS) allowing the user to enable/disable individual -# generators. -# -# CPACK_OUTPUT_CONFIG_FILE - The name of the CPack configuration file -# for binary installers that will be generated by the CPack -# module. Defaults to CPackConfig.cmake. -# -# CPACK_PACKAGE_EXECUTABLES - Lists each of the executables along -# with a text label, to be used to create Start Menu shortcuts on -# Windows. For example, setting this to the list ccmake;CMake will -# create a shortcut named "CMake" that will execute the installed -# executable ccmake. -# -# CPACK_STRIP_FILES - List of files to be stripped. Starting with -# CMake 2.6.0 CPACK_STRIP_FILES will be a boolean variable which -# enables stripping of all files (a list of files evaluates to TRUE -# in CMake, so this change is compatible). -# -# The following CPack variables are specific to source packages, and +##end +# +##variable +# CPACK_PACKAGE_NAME - The name of the package (or application). If +# not specified, defaults to the project name. +##end +# +##variable +# CPACK_PACKAGE_VENDOR - The name of the package vendor. (e.g., +# "Kitware"). +##end +# +##variable +# CPACK_PACKAGE_DIRECTORY - The directory in which CPack is doing its +# packaging. If it is not set then this will default (internally) to the +# build dir. This variable may be defined in CPack config file or from +# the cpack command line option "-B". If set the command line option +# override the value found in the config file. +##end +# +##variable +# CPACK_PACKAGE_VERSION_MAJOR - Package major Version +##end +# +##variable +# CPACK_PACKAGE_VERSION_MINOR - Package minor Version +##end +# +##variable +# CPACK_PACKAGE_VERSION_PATCH - Package patch Version +##end +# +##variable +# CPACK_PACKAGE_DESCRIPTION_FILE - A text file used to describe the +# project. Used, for example, the introduction screen of a +# CPack-generated Windows installer to describe the project. +##end +# +##variable +# CPACK_PACKAGE_DESCRIPTION_SUMMARY - Short description of the +# project (only a few words). +##end +# +##variable +# CPACK_PACKAGE_FILE_NAME - The name of the package file to generate, +# not including the extension. For example, cmake-2.6.1-Linux-i686. +# The default value is +# +# ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}. +##end +# +##variable +# CPACK_PACKAGE_INSTALL_DIRECTORY - Installation directory on the +# target system. This may be used by some CPack generators +# like NSIS to create an installation directory e.g., "CMake 2.5" +# below the installation prefix. All installed element will be +# put inside this directory. +##end +# +##variable +# CPACK_PACKAGE_ICON - A branding image that will be displayed inside +# the installer (used by GUI installers). +##end +# +##variable +# CPACK_PROJECT_CONFIG_FILE - CPack-time project CPack configuration +# file. This file included at cpack time, once per +# generator after CPack has set CPACK_GENERATOR to the actual generator +# being used. It allows per-generator setting of CPACK_* variables at +# cpack time. +##end +# +##variable +# CPACK_RESOURCE_FILE_LICENSE - License to be embedded in the installer. It +# will typically be displayed to the user by the produced installer +# (often with an explicit "Accept" button, for graphical installers) +# prior to installation. This license file is NOT added to installed +# file but is used by some CPack generators like NSIS. If you want +# to install a license file (may be the same as this one) +# along with your project you must add an appropriate CMake INSTALL +# command in your CMakeLists.txt. +##end +# +##variable +# CPACK_RESOURCE_FILE_README - ReadMe file to be embedded in the installer. It +# typically describes in some detail the purpose of the project +# during the installation. Not all CPack generators uses +# this file. +##end +# +##variable +# CPACK_RESOURCE_FILE_WELCOME - Welcome file to be embedded in the +# installer. It welcomes users to this installer. +# Typically used in the graphical installers on Windows and Mac OS X. +##end +# +##variable +# CPACK_MONOLITHIC_INSTALL - Disables the component-based +# installation mechanism. When set the component specification is ignored +# and all installed items are put in a single "MONOLITHIC" package. +# Some CPack generators do monolithic packaging by default and +# may be asked to do component packaging by setting +# CPACK_<GENNAME>_COMPONENT_INSTALL to 1/TRUE. +##end +# +##variable +# CPACK_GENERATOR - List of CPack generators to use. If not +# specified, CPack will create a set of options CPACK_BINARY_<GENNAME> (e.g., +# CPACK_BINARY_NSIS) allowing the user to enable/disable individual +# generators. This variable may be used on the command line +# as well as in: +# +# cpack -D CPACK_GENERATOR="ZIP;TGZ" /path/to/build/tree +##end +# +##variable +# CPACK_OUTPUT_CONFIG_FILE - The name of the CPack binary configuration +# file. This file is the CPack configuration generated by the CPack module +# for binary installers. Defaults to CPackConfig.cmake. +##end +# +##variable +# CPACK_PACKAGE_EXECUTABLES - Lists each of the executables and associated +# text label to be used to create Start Menu shortcuts. For example, +# setting this to the list ccmake;CMake will +# create a shortcut named "CMake" that will execute the installed +# executable ccmake. Not all CPack generators use it (at least NSIS and +# OSXX11 do). +##end +# +##variable +# CPACK_STRIP_FILES - List of files to be stripped. Starting with +# CMake 2.6.0 CPACK_STRIP_FILES will be a boolean variable which +# enables stripping of all files (a list of files evaluates to TRUE +# in CMake, so this change is compatible). +##end +# +# The following CPack variables are specific to source packages, and # will not affect binary packages: # -# CPACK_SOURCE_PACKAGE_FILE_NAME - The name of the source package, -# e.g., cmake-2.6.1 -# -# CPACK_SOURCE_STRIP_FILES - List of files in the source tree that -# will be stripped. Starting with CMake 2.6.0 -# CPACK_SOURCE_STRIP_FILES will be a boolean variable which enables -# stripping of all files (a list of files evaluates to TRUE in CMake, -# so this change is compatible). -# -# CPACK_SOURCE_GENERATOR - List of generators used for the source -# packages. As with CPACK_GENERATOR, if this is not specified then -# CPack will create a set of options (e.g., CPACK_SOURCE_ZIP) -# allowing users to select which packages will be generated. -# -# CPACK_SOURCE_OUTPUT_CONFIG_FILE - The name of the CPack -# configuration file for source installers that will be generated by -# the CPack module. Defaults to CPackSourceConfig.cmake. -# -# CPACK_SOURCE_IGNORE_FILES - Pattern of files in the source tree -# that won't be packaged when building a source package. This is a -# list of patterns, e.g., /CVS/;/\\.svn/;\\.swp$;\\.#;/#;.*~;cscope.* -# -# The following variables are specific to the DragNDrop installers -# built on Mac OS X: -# -# CPACK_DMG_VOLUME_NAME - The volume name of the generated disk -# image. Defaults to CPACK_PACKAGE_FILE_NAME. -# -# CPACK_DMG_FORMAT - The disk image format. Common values are UDRO -# (UDIF read-only), UDZO (UDIF zlib-compressed) or UDBZ (UDIF -# bzip2-compressed). Refer to hdiutil(1) for more information on -# other available formats. -# -# CPACK_DMG_DS_STORE - Path to a custom .DS_Store file which e.g. -# can be used to specify the Finder window position/geometry and -# layout (such as hidden toolbars, placement of the icons etc.). -# This file has to be generated by the Finder (either manually or -# through OSA-script) using a normal folder from which the .DS_Store -# file can then be extracted. -# -# CPACK_DMG_BACKGROUND_IMAGE - Path to an image file which is to be -# used as the background for the Finder Window when the disk image -# is opened. By default no background image is set. The background -# image is applied after applying the custom .DS_Store file. -# -# CPACK_COMMAND_HDIUTIL - Path to the hdiutil(1) command used to -# operate on disk image files on Mac OS X. This variable can be used -# to override the automatically detected command (or specify its -# location if the auto-detection fails to find it.) -# -# CPACK_COMMAND_SETFILE - Path to the SetFile(1) command used to set -# extended attributes on files and directories on Mac OS X. This -# variable can be used to override the automatically detected -# command (or specify its location if the auto-detection fails to -# find it.) -# -# CPACK_COMMAND_REZ - Path to the Rez(1) command used to compile -# resources on Mac OS X. This variable can be used to override the -# automatically detected command (or specify its location if the -# auto-detection fails to find it.) -# -# The following variable is specific to installers build on Mac OS X -# using PackageMaker: -# -# CPACK_OSX_PACKAGE_VERSION - The version of Mac OS X that the -# resulting PackageMaker archive should be compatible -# with. Different versions of Mac OS X support different -# features. For example, CPack can only build component-based -# installers for Mac OS X 10.4 or newer, and can only build -# installers that download component son-the-fly for Mac OS X 10.5 -# or newer. If left blank, this value will be set to the minimum -# version of Mac OS X that supports the requested features. Set this -# variable to some value (e.g., 10.4) only if you want to guarantee -# that your installer will work on that version of Mac OS X, and -# don't mind missing extra features available in the installer -# shipping with later versions of Mac OS X. +##variable +# CPACK_SOURCE_PACKAGE_FILE_NAME - The name of the source package. For +# example cmake-2.6.1. +##end +# +##variable +# CPACK_SOURCE_STRIP_FILES - List of files in the source tree that +# will be stripped. Starting with CMake 2.6.0 +# CPACK_SOURCE_STRIP_FILES will be a boolean variable which enables +# stripping of all files (a list of files evaluates to TRUE in CMake, +# so this change is compatible). +##end +# +##variable +# CPACK_SOURCE_GENERATOR - List of generators used for the source +# packages. As with CPACK_GENERATOR, if this is not specified then +# CPack will create a set of options (e.g., CPACK_SOURCE_ZIP) +# allowing users to select which packages will be generated. +##end +# +##variable +# CPACK_SOURCE_OUTPUT_CONFIG_FILE - The name of the CPack source +# configuration file. This file is the CPack configuration generated by the +# CPack module for source installers. Defaults to CPackSourceConfig.cmake. +##end +# +##variable +# CPACK_SOURCE_IGNORE_FILES - Pattern of files in the source tree +# that won't be packaged when building a source package. This is a +# list of regular expression patterns (that must be properly escaped), +# e.g., /CVS/;/\\.svn/;\\.swp$;\\.#;/#;.*~;cscope.* +##end # # The following variables are for advanced uses of CPack: # -# CPACK_CMAKE_GENERATOR - What CMake generator should be used if the -# project is CMake project. Defaults to the value of CMAKE_GENERATOR; -# few users will want to change this setting. -# -# CPACK_INSTALL_CMAKE_PROJECTS - List of four values that specify -# what project to install. The four values are: Build directory, -# Project Name, Project Component, Directory. If omitted, CPack will -# build an installer that installers everything. -# -# CPACK_SYSTEM_NAME - System name, defaults to the value of -# ${CMAKE_SYSTEM_NAME}. -# -# CPACK_PACKAGE_VERSION - Package full version, used internally. By -# default, this is built from CPACK_PACKAGE_VERSION_MAJOR, -# CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH. -# -# CPACK_TOPLEVEL_TAG - Directory for the installed files. -# -# CPACK_INSTALL_COMMANDS - Extra commands to install components. -# -# CPACK_INSTALLED_DIRECTORIES - Extra directories to install. +##variable +# CPACK_CMAKE_GENERATOR - What CMake generator should be used if the +# project is CMake project. Defaults to the value of CMAKE_GENERATOR +# few users will want to change this setting. +##end +# +##variable +# CPACK_INSTALL_CMAKE_PROJECTS - List of four values that specify +# what project to install. The four values are: Build directory, +# Project Name, Project Component, Directory. If omitted, CPack will +# build an installer that installers everything. +##end +# +##variable +# CPACK_SYSTEM_NAME - System name, defaults to the value of +# ${CMAKE_SYSTEM_NAME}. +##end +# +##variable +# CPACK_PACKAGE_VERSION - Package full version, used internally. By +# default, this is built from CPACK_PACKAGE_VERSION_MAJOR, +# CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH. +##end +# +##variable +# CPACK_TOPLEVEL_TAG - Directory for the installed files. +##end +# +##variable +# CPACK_INSTALL_COMMANDS - Extra commands to install components. +##end +# +##variable +# CPACK_INSTALLED_DIRECTORIES - Extra directories to install. +##end +# +##variable +# CPACK_PACKAGE_INSTALL_REGISTRY_KEY - Registry key used when +# installing this project. This is only used +# by installer for Windows. +##end +##variable +# CPACK_CREATE_DESKTOP_LINKS - List of desktop links to create. +##end # #============================================================================= @@ -232,48 +285,48 @@ # License text for the above reference.) # Define this var in order to avoid (or warn) concerning multiple inclusion -IF(CPack_CMake_INCLUDED) - MESSAGE(WARNING "CPack.cmake has already been included!!") -ELSE(CPack_CMake_INCLUDED) - SET(CPack_CMake_INCLUDED 1) -ENDIF(CPack_CMake_INCLUDED) +if(CPack_CMake_INCLUDED) + message(WARNING "CPack.cmake has already been included!!") +else() + set(CPack_CMake_INCLUDED 1) +endif() # Pick a configuration file -SET(cpack_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in") -IF(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in") - SET(cpack_input_file "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in") -ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in") -SET(cpack_source_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in") -IF(EXISTS "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in") - SET(cpack_source_input_file "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in") -ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in") +set(cpack_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in") +if(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in") + set(cpack_input_file "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in") +endif() +set(cpack_source_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in") +if(EXISTS "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in") + set(cpack_source_input_file "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in") +endif() # Backward compatibility # Include CPackComponent macros if it has not already been included before. include(CPackComponent) # Macro for setting values if a user did not overwrite them -MACRO(cpack_set_if_not_set name value) - IF(NOT DEFINED "${name}") - SET(${name} "${value}") - ENDIF(NOT DEFINED "${name}") -ENDMACRO(cpack_set_if_not_set) +macro(cpack_set_if_not_set name value) + if(NOT DEFINED "${name}") + set(${name} "${value}") + endif() +endmacro() -# Macro to encode variables for the configuration file +# cpack_encode_variables - Macro to encode variables for the configuration file # find any variable that starts with CPACK and create a variable # _CPACK_OTHER_VARIABLES_ that contains SET commands for # each cpack variable. _CPACK_OTHER_VARIABLES_ is then # used as an @ replacment in configure_file for the CPackConfig. -MACRO(cpack_encode_variables) - SET(_CPACK_OTHER_VARIABLES_) - GET_CMAKE_PROPERTY(res VARIABLES) - FOREACH(var ${res}) - IF("xxx${var}" MATCHES "xxxCPACK") - SET(_CPACK_OTHER_VARIABLES_ +macro(cpack_encode_variables) + set(_CPACK_OTHER_VARIABLES_) + get_cmake_property(res VARIABLES) + foreach(var ${res}) + if("xxx${var}" MATCHES "xxxCPACK") + set(_CPACK_OTHER_VARIABLES_ "${_CPACK_OTHER_VARIABLES_}\nSET(${var} \"${${var}}\")") - ENDIF("xxx${var}" MATCHES "xxxCPACK") - ENDFOREACH(var ${res}) -ENDMACRO(cpack_encode_variables) + endif() + endforeach() +endmacro() # Set the package name cpack_set_if_not_set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}") @@ -297,27 +350,31 @@ cpack_set_if_not_set(CPACK_RESOURCE_FILE_WELCOME cpack_set_if_not_set(CPACK_MODULE_PATH "${CMAKE_MODULE_PATH}") -IF(CPACK_NSIS_MODIFY_PATH) - SET(CPACK_NSIS_MODIFY_PATH ON) -ENDIF(CPACK_NSIS_MODIFY_PATH) - -SET(__cpack_system_name ${CMAKE_SYSTEM_NAME}) -IF(${__cpack_system_name} MATCHES Windows) - IF(CMAKE_CL_64) - SET(__cpack_system_name win64) - ELSE(CMAKE_CL_64) - SET(__cpack_system_name win32) - ENDIF(CMAKE_CL_64) -ENDIF(${__cpack_system_name} MATCHES Windows) +if(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL) + set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON) +endif() + +if(CPACK_NSIS_MODIFY_PATH) + set(CPACK_NSIS_MODIFY_PATH ON) +endif() + +set(__cpack_system_name ${CMAKE_SYSTEM_NAME}) +if(${__cpack_system_name} MATCHES Windows) + if(CMAKE_CL_64) + set(__cpack_system_name win64) + else() + set(__cpack_system_name win32) + endif() +endif() cpack_set_if_not_set(CPACK_SYSTEM_NAME "${__cpack_system_name}") # Root dir: default value should be the string literal "$PROGRAMFILES" # for backwards compatibility. Projects may set this value to anything. if(CMAKE_CL_64) set(__cpack_root_default "$PROGRAMFILES64") -else(CMAKE_CL_64) +else() set(__cpack_root_default "$PROGRAMFILES") -endif(CMAKE_CL_64) +endif() cpack_set_if_not_set(CPACK_NSIS_INSTALL_ROOT "${__cpack_root_default}") # <project>-<major>.<minor>.<patch>-<release>-<platform>.<pkgtype> @@ -333,15 +390,15 @@ cpack_set_if_not_set(CPACK_PACKAGE_RELOCATABLE "true") # always force to exactly "true" or "false" for CPack.Info.plist.in: if(CPACK_PACKAGE_RELOCATABLE) set(CPACK_PACKAGE_RELOCATABLE "true") -else(CPACK_PACKAGE_RELOCATABLE) +else() set(CPACK_PACKAGE_RELOCATABLE "false") -endif(CPACK_PACKAGE_RELOCATABLE) +endif() macro(cpack_check_file_exists file description) if(NOT EXISTS "${file}") message(SEND_ERROR "CPack ${description} file: \"${file}\" could not be found.") - endif(NOT EXISTS "${file}") -endmacro(cpack_check_file_exists) + endif() +endmacro() cpack_check_file_exists("${CPACK_PACKAGE_DESCRIPTION_FILE}" "package description") cpack_check_file_exists("${CPACK_RESOURCE_FILE_LICENSE}" "license resource") @@ -351,9 +408,15 @@ cpack_check_file_exists("${CPACK_RESOURCE_FILE_WELCOME}" "welcome resource") macro(cpack_optional_append _list _cond _item) if(${_cond}) set(${_list} ${${_list}} ${_item}) - endif(${_cond}) -endmacro(cpack_optional_append _list _cond _item) - + endif() +endmacro() + +##variable +# CPACK_BINARY_<GENNAME> - CPack generated options for binary generators. The +# CPack.cmake module generates (when CPACK_GENERATOR is not set) +# a set of CMake options (see CMake option command) which may then be used to +# select the CPack generator(s) to be used when launching the package target. +##end # Provide options to choose generators # we might check here if the required tools for the generates exist # and set the defaults according to the results @@ -361,27 +424,27 @@ if(NOT CPACK_GENERATOR) if(UNIX) if(CYGWIN) option(CPACK_BINARY_CYGWIN "Enable to build Cygwin binary packages" ON) - else(CYGWIN) + else() if(APPLE) option(CPACK_BINARY_BUNDLE "Enable to build OSX bundles" OFF) option(CPACK_BINARY_DRAGNDROP "Enable to build OSX Drag And Drop package" OFF) option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages" ON) option(CPACK_BINARY_OSXX11 "Enable to build OSX X11 packages" OFF) - else(APPLE) + else() option(CPACK_BINARY_TZ "Enable to build TZ packages" ON) - endif(APPLE) + endif() option(CPACK_BINARY_STGZ "Enable to build STGZ packages" ON) option(CPACK_BINARY_TGZ "Enable to build TGZ packages" ON) option(CPACK_BINARY_TBZ2 "Enable to build TBZ2 packages" OFF) option(CPACK_BINARY_DEB "Enable to build Debian packages" OFF) option(CPACK_BINARY_RPM "Enable to build RPM packages" OFF) option(CPACK_BINARY_NSIS "Enable to build NSIS packages" OFF) - endif(CYGWIN) - else(UNIX) + endif() + else() option(CPACK_BINARY_NSIS "Enable to build NSIS packages" ON) option(CPACK_BINARY_ZIP "Enable to build ZIP packages" OFF) - endif(UNIX) - + endif() + cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_BUNDLE Bundle) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_DRAGNDROP DragNDrop) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PACKAGEMAKER PackageMaker) @@ -395,37 +458,37 @@ if(NOT CPACK_GENERATOR) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TBZ2 TBZ2) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TZ TZ) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_ZIP ZIP) - -endif(NOT CPACK_GENERATOR) + +endif() # Provide options to choose source generators if(NOT CPACK_SOURCE_GENERATOR) if(UNIX) if(CYGWIN) option(CPACK_SOURCE_CYGWIN "Enable to build Cygwin source packages" ON) - else(CYGWIN) + else() option(CPACK_SOURCE_TBZ2 "Enable to build TBZ2 source packages" ON) option(CPACK_SOURCE_TGZ "Enable to build TGZ source packages" ON) option(CPACK_SOURCE_TZ "Enable to build TZ source packages" ON) option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" OFF) - endif(CYGWIN) - else(UNIX) + endif() + else() option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" ON) - endif(UNIX) + endif() cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_CYGWIN CygwinSource) cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TGZ TGZ) cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TBZ2 TBZ2) cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TZ TZ) cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_ZIP ZIP) -endif(NOT CPACK_SOURCE_GENERATOR) +endif() # mark the above options as advanced mark_as_advanced(CPACK_BINARY_CYGWIN CPACK_BINARY_PACKAGEMAKER CPACK_BINARY_OSXX11 - CPACK_BINARY_STGZ CPACK_BINARY_TGZ CPACK_BINARY_TBZ2 - CPACK_BINARY_DEB CPACK_BINARY_RPM CPACK_BINARY_TZ + CPACK_BINARY_STGZ CPACK_BINARY_TGZ CPACK_BINARY_TBZ2 + CPACK_BINARY_DEB CPACK_BINARY_RPM CPACK_BINARY_TZ CPACK_BINARY_NSIS CPACK_BINARY_ZIP CPACK_BINARY_BUNDLE - CPACK_SOURCE_CYGWIN CPACK_SOURCE_TBZ2 CPACK_SOURCE_TGZ + CPACK_SOURCE_CYGWIN CPACK_SOURCE_TBZ2 CPACK_SOURCE_TGZ CPACK_SOURCE_TZ CPACK_SOURCE_ZIP CPACK_BINARY_DRAGNDROP) # Set some other variables @@ -435,16 +498,16 @@ cpack_set_if_not_set(CPACK_CMAKE_GENERATOR "${CMAKE_GENERATOR}") cpack_set_if_not_set(CPACK_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}") # if the user has set CPACK_NSIS_DISPLAY_NAME remember it if(DEFINED CPACK_NSIS_DISPLAY_NAME) - SET(CPACK_NSIS_DISPLAY_NAME_SET TRUE) + set(CPACK_NSIS_DISPLAY_NAME_SET TRUE) endif() # if the user has set CPACK_NSIS_DISPLAY # explicitly, then use that as the default # value of CPACK_NSIS_PACKAGE_NAME instead -# of CPACK_PACKAGE_INSTALL_DIRECTORY +# of CPACK_PACKAGE_INSTALL_DIRECTORY cpack_set_if_not_set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}") if(CPACK_NSIS_DISPLAY_NAME_SET) - string(REPLACE "\\" "\\\\" + string(REPLACE "\\" "\\\\" _NSIS_DISPLAY_NAME_TMP "${CPACK_NSIS_DISPLAY_NAME}") cpack_set_if_not_set(CPACK_NSIS_PACKAGE_NAME "${_NSIS_DISPLAY_NAME_TMP}") else() @@ -463,31 +526,31 @@ cpack_set_if_not_set(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") cpack_set_if_not_set(CPACK_NSIS_INSTALLER_ICON_CODE "") cpack_set_if_not_set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "") -IF(DEFINED CPACK_COMPONENTS_ALL) - IF(CPACK_MONOLITHIC_INSTALL) - MESSAGE("CPack warning: both CPACK_COMPONENTS_ALL and CPACK_MONOLITHIC_INSTALL have been set.\nDefaulting to a monolithic installation.") - SET(CPACK_COMPONENTS_ALL) - ELSE(CPACK_MONOLITHIC_INSTALL) +if(DEFINED CPACK_COMPONENTS_ALL) + if(CPACK_MONOLITHIC_INSTALL) + message("CPack warning: both CPACK_COMPONENTS_ALL and CPACK_MONOLITHIC_INSTALL have been set.\nDefaulting to a monolithic installation.") + set(CPACK_COMPONENTS_ALL) + else() # The user has provided the set of components to be installed as # part of a component-based installation; trust her. - SET(CPACK_COMPONENTS_ALL_SET_BY_USER TRUE) - ENDIF(CPACK_MONOLITHIC_INSTALL) -ELSE(DEFINED CPACK_COMPONENTS_ALL) + set(CPACK_COMPONENTS_ALL_SET_BY_USER TRUE) + endif() +else() # If the user has not specifically requested a monolithic installer # but has specified components in various "install" commands, tell # CPack about those components. - IF(NOT CPACK_MONOLITHIC_INSTALL) - GET_CMAKE_PROPERTY(CPACK_COMPONENTS_ALL COMPONENTS) - LIST(LENGTH CPACK_COMPONENTS_ALL CPACK_COMPONENTS_LEN) - IF(CPACK_COMPONENTS_LEN EQUAL 1) + if(NOT CPACK_MONOLITHIC_INSTALL) + get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS) + list(LENGTH CPACK_COMPONENTS_ALL CPACK_COMPONENTS_LEN) + if(CPACK_COMPONENTS_LEN EQUAL 1) # Only one component: this is not a component-based installation # (at least, it isn't a component-based installation, but may # become one later if the user uses the cpack_add_* commands). - SET(CPACK_COMPONENTS_ALL) - ENDIF(CPACK_COMPONENTS_LEN EQUAL 1) - SET(CPACK_COMPONENTS_LEN) - ENDIF(NOT CPACK_MONOLITHIC_INSTALL) -ENDIF(DEFINED CPACK_COMPONENTS_ALL) + set(CPACK_COMPONENTS_ALL) + endif() + set(CPACK_COMPONENTS_LEN) + endif() +endif() # CMake always generates a component named "Unspecified", which is # used to install everything that doesn't have an explicitly-provided @@ -507,13 +570,13 @@ cpack_set_if_not_set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Source") cpack_set_if_not_set(CPACK_SOURCE_IGNORE_FILES "/CVS/;/\\\\\\\\.svn/;/\\\\\\\\.bzr/;/\\\\\\\\.hg/;/\\\\\\\\.git/;\\\\\\\\.swp$;\\\\\\\\.#;/#") -SET(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_SOURCE_INSTALL_CMAKE_PROJECTS}") -SET(CPACK_INSTALLED_DIRECTORIES "${CPACK_SOURCE_INSTALLED_DIRECTORIES}") -SET(CPACK_GENERATOR "${CPACK_SOURCE_GENERATOR}") -SET(CPACK_TOPLEVEL_TAG "${CPACK_SOURCE_TOPLEVEL_TAG}") -SET(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}") -SET(CPACK_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}") -SET(CPACK_STRIP_FILES "${CPACK_SOURCE_STRIP_FILES}") +set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_SOURCE_INSTALL_CMAKE_PROJECTS}") +set(CPACK_INSTALLED_DIRECTORIES "${CPACK_SOURCE_INSTALLED_DIRECTORIES}") +set(CPACK_GENERATOR "${CPACK_SOURCE_GENERATOR}") +set(CPACK_TOPLEVEL_TAG "${CPACK_SOURCE_TOPLEVEL_TAG}") +set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}") +set(CPACK_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}") +set(CPACK_STRIP_FILES "${CPACK_SOURCE_STRIP_FILES}") cpack_encode_variables() configure_file("${cpack_source_input_file}" diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index 4f4f759..6db6d78 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -14,7 +14,7 @@ INCLUDE (${CMAKE_ROOT}/Modules/TestBigEndian.cmake) INCLUDE (${CMAKE_ROOT}/Modules/TestForSTDNamespace.cmake) #----------------------------------------------------------------------------- -# Always SET this for now IF we are on an OS X box +# APPLE/Darwin setup #----------------------------------------------------------------------------- IF (APPLE) LIST(LENGTH CMAKE_OSX_ARCHITECTURES ARCH_LENGTH) @@ -28,6 +28,11 @@ IF (APPLE) SET (H5_AC_APPLE_UNIVERSAL_BUILD 0) ENDIF (APPLE) +# Check for Darwin (not just Apple - we also want to catch OpenDarwin) +IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + SET (H5_HAVE_DARWIN 1) +ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + #----------------------------------------------------------------------------- # Option to Clear File Buffers before write --enable-clear-file-buffers #----------------------------------------------------------------------------- diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 6fca1ae..d9f0997 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -111,6 +111,9 @@ /* Define if the function stack tracing code is to be compiled in */ #cmakedefine H5_HAVE_CODESTACK @H5_HAVE_CODESTACK@ +/* Define if Darwin or Mac OS X */ +#cmakedefine H5_HAVE_DARWIN @H5_HAVE_DARWIN@ + /* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. */ #cmakedefine H5_HAVE_DECL_TZNAME @H5_HAVE_DECL_TZNAME@ diff --git a/config/cmake/HDF5UseFortran.cmake b/config/cmake/HDF5UseFortran.cmake index 323c9ef..8fa76b8 100644 --- a/config/cmake/HDF5UseFortran.cmake +++ b/config/cmake/HDF5UseFortran.cmake @@ -110,6 +110,9 @@ CHECK_FORTRAN_FEATURE(RealIsNotDouble FORTRAN_DEFAULT_REAL_NOT_DOUBLE ) +#----------------------------------------------------------------------------- +# Checks if the ISO_C_BINDING module meets all the requirements +#----------------------------------------------------------------------------- CHECK_FORTRAN_FEATURE(iso_c_binding " PROGRAM main @@ -117,6 +120,7 @@ CHECK_FORTRAN_FEATURE(iso_c_binding IMPLICIT NONE TYPE(C_PTR) :: ptr TYPE(C_FUNPTR) :: funptr + INTEGER(C_INT64_T) :: c_int64_type CHARACTER(LEN=80, KIND=c_char), TARGET :: ichr ptr = C_LOC(ichr(1:1)) END PROGRAM diff --git a/config/cmake/prunTest.cmake b/config/cmake/prunTest.cmake index 261f8a4..b9ead6f 100644 --- a/config/cmake/prunTest.cmake +++ b/config/cmake/prunTest.cmake @@ -1,5 +1,6 @@ # runTest.cmake executes a command and captures the output in a file. File is then compared # against a reference file. Exit status of command can also be compared. +cmake_policy(SET CMP0007 NEW) # arguments checking IF (NOT TEST_PROGRAM) @@ -103,24 +104,33 @@ IF (NOT TEST_SKIP_COMPARE) ENDIF (WIN32 AND NOT MINGW) # now compare the output with the reference + EXECUTE_PROCESS ( + COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_FOLDER}/P_${TEST_REFERENCE} + RESULT_VARIABLE TEST_RESULT + ) + IF (NOT ${TEST_RESULT} STREQUAL 0) SET (TEST_RESULT 0) FILE (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} test_act) - LIST (LENGTH "${test_act}" len_act) + LIST (LENGTH test_act len_act) FILE (STRINGS ${TEST_FOLDER}/P_${TEST_REFERENCE} test_ref) - LIST (LENGTH "${test_ref}" len_ref) - MATH (EXPR _FP_LEN "${len_ref} - 1") - FOREACH (line RANGE 0 ${_FP_LEN}) - LIST (GET "${test_act}" ${line} str_act) - LIST (GET "${test_ref}" ${line} str_ref) - STRING (COMPARE NOTEQUAL ${str_act} ${str_ref} str_res) - IF (${str_res}) - SET (TEST_RESULT 1) - MESSAGE ("line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}") - ENDIF (${str_res}) - ENDFOREACH (line RANGE 0 ${_FP_LEN}) + LIST (LENGTH test_ref len_ref) + IF (NOT ${len_act} STREQUAL "0") + MATH (EXPR _FP_LEN "${len_ref} - 1") + FOREACH (line RANGE 0 ${_FP_LEN}) + LIST (GET test_act ${line} str_act) + LIST (GET test_ref ${line} str_ref) + IF (NOT "${str_act}" STREQUAL "${str_ref}") + IF (NOT "${str_act}" STREQUAL "") + SET (TEST_RESULT 1) + MESSAGE ("line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n") + ENDIF (NOT "${str_act}" STREQUAL "") + ENDIF (NOT "${str_act}" STREQUAL "${str_ref}") + ENDFOREACH (line RANGE 0 ${_FP_LEN}) + ENDIF (NOT ${len_act} STREQUAL "0") IF (NOT ${len_act} STREQUAL ${len_ref}) SET (TEST_RESULT 1) ENDIF (NOT ${len_act} STREQUAL ${len_ref}) + ENDIF (NOT ${TEST_RESULT} STREQUAL 0) MESSAGE (STATUS "COMPARE Result: ${TEST_RESULT}") diff --git a/config/cmake/runTest.cmake b/config/cmake/runTest.cmake index 78ccf9f..0a80873 100644 --- a/config/cmake/runTest.cmake +++ b/config/cmake/runTest.cmake @@ -1,5 +1,6 @@ # runTest.cmake executes a command and captures the output in a file. File is then compared # against a reference file. Exit status of command can also be compared. +cmake_policy(SET CMP0007 NEW) # arguments checking IF (NOT TEST_PROGRAM) @@ -108,24 +109,33 @@ IF (NOT TEST_SKIP_COMPARE) ENDIF (WIN32 AND NOT MINGW) # now compare the output with the reference + EXECUTE_PROCESS ( + COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_FOLDER}/${TEST_REFERENCE} + RESULT_VARIABLE TEST_RESULT + ) + IF (NOT ${TEST_RESULT} STREQUAL 0) SET (TEST_RESULT 0) FILE (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} test_act) - LIST (LENGTH "${test_act}" len_act) + LIST (LENGTH test_act len_act) FILE (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} test_ref) - LIST (LENGTH "${test_ref}" len_ref) - MATH (EXPR _FP_LEN "${len_ref} - 1") - FOREACH (line RANGE 0 ${_FP_LEN}) - LIST (GET "${test_act}" ${line} str_act) - LIST (GET "${test_ref}" ${line} str_ref) - STRING (COMPARE NOTEQUAL ${str_act} ${str_ref} str_res) - IF (${str_res}) - SET (TEST_RESULT 1) - MESSAGE ("line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}") - ENDIF (${str_res}) - ENDFOREACH (line RANGE 0 ${_FP_LEN}) + LIST (LENGTH test_ref len_ref) + IF (NOT ${len_act} STREQUAL "0") + MATH (EXPR _FP_LEN "${len_ref} - 1") + FOREACH (line RANGE 0 ${_FP_LEN}) + LIST (GET test_act ${line} str_act) + LIST (GET test_ref ${line} str_ref) + IF (NOT "${str_act}" STREQUAL "${str_ref}") + IF (NOT "${str_act}" STREQUAL "") + SET (TEST_RESULT 1) + MESSAGE ("line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n") + ENDIF (NOT "${str_act}" STREQUAL "") + ENDIF (NOT "${str_act}" STREQUAL "${str_ref}") + ENDFOREACH (line RANGE 0 ${_FP_LEN}) + ENDIF (NOT ${len_act} STREQUAL "0") IF (NOT ${len_act} STREQUAL ${len_ref}) SET (TEST_RESULT 1) ENDIF (NOT ${len_act} STREQUAL ${len_ref}) + ENDIF (NOT ${TEST_RESULT} STREQUAL 0) MESSAGE (STATUS "COMPARE Result: ${TEST_RESULT}") @@ -141,24 +151,34 @@ IF (NOT TEST_SKIP_COMPARE) ENDIF (WIN32 AND NOT MINGW) # now compare the error output with the error reference + EXECUTE_PROCESS ( + COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_FOLDER}/${TEST_OUTPUT}.err ${TEST_FOLDER}/${TEST_ERRREF} + RESULT_VARIABLE TEST_RESULT + ) + IF (NOT ${TEST_RESULT} STREQUAL 0) SET (TEST_RESULT 0) FILE (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT}.err test_act) - LIST (LENGTH "${test_act}" len_act) + LIST (LENGTH test_act len_act) FILE (STRINGS ${TEST_FOLDER}/${TEST_ERRREF} test_ref) - LIST (LENGTH "${test_ref}" len_ref) + LIST (LENGTH test_ref len_ref) MATH (EXPR _FP_LEN "${len_ref} - 1") - FOREACH (line RANGE 0 ${_FP_LEN}) - LIST (GET "${test_act}" ${line} str_act) - LIST (GET "${test_ref}" ${line} str_ref) - STRING (COMPARE NOTEQUAL ${str_act} ${str_ref} str_res) - IF (${str_res}) - SET (TEST_RESULT 1) - MESSAGE ("line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}") - ENDIF (${str_res}) - ENDFOREACH (line RANGE 0 ${_FP_LEN}) + IF (NOT ${len_act} STREQUAL "0") + MATH (EXPR _FP_LEN "${len_ref} - 1") + FOREACH (line RANGE 0 ${_FP_LEN}) + LIST (GET test_act ${line} str_act) + LIST (GET test_ref ${line} str_ref) + IF (NOT "${str_act}" STREQUAL "${str_ref}") + IF (NOT "${str_act}" STREQUAL "") + SET (TEST_RESULT 1) + MESSAGE ("line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n") + ENDIF (NOT "${str_act}" STREQUAL "") + ENDIF (NOT "${str_act}" STREQUAL "${str_ref}") + ENDFOREACH (line RANGE 0 ${_FP_LEN}) + ENDIF (NOT ${len_act} STREQUAL "0") IF (NOT ${len_act} STREQUAL ${len_ref}) SET (TEST_RESULT 1) ENDIF (NOT ${len_act} STREQUAL ${len_ref}) + ENDIF (NOT ${TEST_RESULT} STREQUAL 0) MESSAGE (STATUS "COMPARE Result: ${TEST_RESULT}") @@ -171,4 +191,3 @@ ENDIF (NOT TEST_SKIP_COMPARE) # everything went fine... MESSAGE ("Passed: The output of ${TEST_PROGRAM} matches ${TEST_REFERENCE}") - diff --git a/config/lt_vers.am b/config/lt_vers.am index d0944fa..42aa24d 100644 --- a/config/lt_vers.am +++ b/config/lt_vers.am @@ -17,7 +17,7 @@ # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 126 +LT_VERS_REVISION = 130 LT_VERS_AGE = 0 ## If the API changes *at all*, increment LT_VERS_INTERFACE and @@ -1,7 +1,7 @@ #! /bin/sh -# From configure.ac Id: configure.ac 22697 2012-08-19 14:35:47Z hdftest . +# From configure.ac Id: configure.ac 23142 2013-01-08 02:19:17Z derobins . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for HDF5 1.9.136. +# Generated by GNU Autoconf 2.69 for HDF5 1.8.11-snap7. # # Report bugs to <help@hdfgroup.org>. # @@ -591,8 +591,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='HDF5' PACKAGE_TARNAME='hdf5' -PACKAGE_VERSION='1.9.136' -PACKAGE_STRING='HDF5 1.9.136' +PACKAGE_VERSION='1.8.11-snap7' +PACKAGE_STRING='HDF5 1.8.11-snap7' PACKAGE_BUGREPORT='help@hdfgroup.org' PACKAGE_URL='' @@ -1484,7 +1484,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures HDF5 1.9.136 to adapt to many kinds of systems. +\`configure' configures HDF5 1.8.11-snap7 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1554,7 +1554,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of HDF5 1.9.136:";; + short | recursive ) echo "Configuration of HDF5 1.8.11-snap7:";; esac cat <<\_ACEOF @@ -1750,7 +1750,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -HDF5 configure 1.9.136 +HDF5 configure 1.8.11-snap7 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2844,7 +2844,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by HDF5 $as_me 1.9.136, which was +It was created by HDF5 $as_me 1.8.11-snap7, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3676,7 +3676,7 @@ fi # Define the identity of the package. PACKAGE='hdf5' - VERSION='1.9.136' + VERSION='1.8.11-snap7' cat >>confdefs.h <<_ACEOF @@ -22754,6 +22754,14 @@ fi done +## Also need to detect Darwin for pubconf +case $host_os in + darwin*) + +$as_echo "#define HAVE_DARWIN 1" >>confdefs.h + + ;; +esac ## Windows case "`uname`" in @@ -27152,19 +27160,12 @@ if ${hdf5_cv_lone_colon+:} false; then : else echo "int main(int argc, char * argv) {return 0;}" > conftest.c - $CC $CFLAGS conftest.c > /dev/null 2> /dev/null -case "`uname`" in - CYGWIN*) - echo "./a.exe :" > conftest.sh - ;; - *) - echo "./a.out :" > conftest.sh - ;; -esac + $CC $CFLAGS conftest.c -o a.out> /dev/null 2> /dev/null + echo "./a.out :" > conftest.sh chmod 700 conftest.sh ./conftest.sh 2> conftest.out - rm -f a.out a.exe + rm -f a.out TEST_OUTPUT=`cat conftest.out` if test "X$TEST_OUTPUT" = "X"; then @@ -31722,7 +31723,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by HDF5 $as_me 1.9.136, which was +This file was extended by HDF5 $as_me 1.8.11-snap7, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -31788,7 +31789,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -HDF5 config.status 1.9.136 +HDF5 config.status 1.8.11-snap7 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -34561,7 +34562,7 @@ Usage: $0 [OPTIONS] Report bugs to <bug-libtool@gnu.org>." lt_cl_version="\ -HDF5 config.lt 1.9.136 +HDF5 config.lt 1.8.11-snap7 configured by $0, generated by GNU Autoconf 2.69. Copyright (C) 2011 Free Software Foundation, Inc. diff --git a/configure.ac b/configure.ac index 7b5cf92..65aa21b 100644 --- a/configure.ac +++ b/configure.ac @@ -16,7 +16,7 @@ ## ---------------------------------------------------------------------- ## Initialize configure. ## -AC_REVISION($Id: configure.ac 22697 2012-08-19 14:35:47Z hdftest $) +AC_REVISION($Id: configure.ac 23142 2013-01-08 02:19:17Z derobins $) AC_PREREQ([2.69]) ## AC_INIT takes the name of the package, the version number, and an @@ -26,7 +26,7 @@ AC_PREREQ([2.69]) ## NOTE: Do not forget to change the version number here when we do a ## release!!! ## -AC_INIT([HDF5], [1.9.136], [help@hdfgroup.org]) +AC_INIT([HDF5], [1.8.11-snap7], [help@hdfgroup.org]) AC_CONFIG_SRCDIR([src/H5.c]) AC_CONFIG_HEADER([src/H5config.h]) @@ -1278,6 +1278,12 @@ AC_CHECK_HEADERS([stdint.h], [C9x=yes]) ## Darwin AC_CHECK_HEADERS([mach/mach_time.h]) +## Also need to detect Darwin for pubconf +case $host_os in + darwin*) + AC_DEFINE([HAVE_DARWIN], [1], [Define if Darwin or Mac OS X]) + ;; +esac ## Windows case "`uname`" in @@ -2232,19 +2238,12 @@ AC_CACHE_CHECK([if lone colon can be used as an argument], [hdf5_cv_lone_colon], [ echo "int main(int argc, char * argv[]) {return 0;}" > conftest.c - $CC $CFLAGS conftest.c > /dev/null 2> /dev/null -case "`uname`" in - CYGWIN*) - echo "./a.exe :" > conftest.sh - ;; - *) - echo "./a.out :" > conftest.sh - ;; -esac + $CC $CFLAGS conftest.c -o a.out> /dev/null 2> /dev/null + echo "./a.out :" > conftest.sh chmod 700 conftest.sh ./conftest.sh 2> conftest.out - rm -f a.out a.exe + rm -f a.out TEST_OUTPUT=`cat conftest.out` if test "X$TEST_OUTPUT" = "X"; then diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b23c6f8..d7fc67a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -10,6 +10,15 @@ ADD_DEFINITIONS (${HDF5_EXTRA_C_FLAGS}) # Define Sources #----------------------------------------------------------------------------- SET (examples + h5_crtdat + h5_rdwt + h5_crtatt + h5_crtgrp + h5_crtgrpar + h5_crtgrpd + h5_cmprss + h5_extend + h5_subset h5_write h5_read h5_extend_write @@ -51,11 +60,15 @@ IF (BUILD_TESTING) -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 @@ -71,6 +84,7 @@ IF (BUILD_TESTING) separate_indexes_file.h5 small_lists_file.h5 soft_link.h5 + subset.h5 unix2win.h5 ) IF (NOT "${last_test}" STREQUAL "") diff --git a/examples/Makefile.am b/examples/Makefile.am index 58f50e7..d8eac95 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -29,7 +29,9 @@ endif # Don't tell automake about them, because if it knew they were programs, # it would try to compile them instead of using the h5cc script. # Use the boilerplate in config/examples.am instead. -EXAMPLE_PROG = h5_write h5_read h5_extend_write h5_chunk_read h5_compound \ +EXAMPLE_PROG = h5_write h5_read h5_extend_write h5_chunk_read h5_compound \ + h5_crtgrpd h5_subset h5_cmprss h5_rdwt h5_crtgrpar h5_extend \ + h5_crtatt h5_crtgrp h5_crtdat \ h5_group h5_select h5_attribute h5_mount h5_reference h5_drivers \ h5_ref2reg h5_extlink h5_elink_unix2win h5_shared_mesg TEST_SCRIPT=testh5cc.sh @@ -37,6 +39,8 @@ TEST_SCRIPT=testh5cc.sh # Install files # List all file that should be installed in examples directory INSTALL_FILES = h5_write.c h5_read.c h5_extend_write.c h5_chunk_read.c \ + h5_crtgrpd.c h5_subset.c h5_cmprss.c h5_rdwt.c h5_crtgrpar.c \ + h5_extend.c h5_crtatt.c h5_crtgrp.c h5_crtdat.c \ h5_compound.c h5_group.c h5_select.c h5_attribute.c h5_mount.c \ h5_reference.c h5_drivers.c h5_extlink.c h5_elink_unix2win.c \ h5_ref2reg.c h5_shared_mesg.c ph5example.c @@ -55,9 +59,14 @@ $(EXTRA_PROG): $(H5CC) $(H5CC) $(H5CCFLAGS) $(CFLAGS) -o $@ $(srcdir)/$@.c; endif -# Two of the examples depend on files created by other examples. +# Some examples depend on files created by other examples. h5_read.chkexe_: h5_write.chkexe_ h5_chunk_read.chkexe_: h5_extend_write.chkexe_ +h5_crtgrpd.chkexe_: h5_crtgrpar.chkexe_ +# h5_rdwt and h5_crtatt both modify the same file created by +# h5_crtdat. Serialize them. +h5_rdwt.chkexe_: h5_crtdat.chkexe_ +h5_crtatt.chkexe_: h5_rdwt.chkexe_ # The external link examples demonstrate how to use paths; they need # directories to be created to do this. @@ -82,6 +91,15 @@ EXAMPLETOPDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples # library above. h5_chunk_read: $(srcdir)/h5_chunk_read.c h5_compound: $(srcdir)/h5_compound.c +h5_crtgrpd: $(srcdir)/h5_crtgrpd.c +h5_subset: $(srcdir)/h5_subset.c +h5_cmprss: $(srcdir)/h5_cmprss.c +h5_rdwt: $(srcdir)/h5_rdwt.c +h5_crtgrpar: $(srcdir)/h5_crtgrpar.c +h5_extend: $(srcdir)/h5_extend.c +h5_crtatt: $(srcdir)/h5_crtatt.c +h5_crtgrp: $(srcdir)/h5_crtgrp.c +h5_crtdat: $(srcdir)/h5_crtdat.c h5_extend_write: $(srcdir)/h5_extend_write.c h5_group: $(srcdir)/h5_group.c h5_write: $(srcdir)/h5_write.c diff --git a/examples/Makefile.in b/examples/Makefile.in index 04c010d..b6dfab5 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -394,7 +394,9 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog $(EXTLINK_DIRS) *.h5 # Don't tell automake about them, because if it knew they were programs, # it would try to compile them instead of using the h5cc script. # Use the boilerplate in config/examples.am instead. -EXAMPLE_PROG = h5_write h5_read h5_extend_write h5_chunk_read h5_compound \ +EXAMPLE_PROG = h5_write h5_read h5_extend_write h5_chunk_read h5_compound \ + h5_crtgrpd h5_subset h5_cmprss h5_rdwt h5_crtgrpar h5_extend \ + h5_crtatt h5_crtgrp h5_crtdat \ h5_group h5_select h5_attribute h5_mount h5_reference h5_drivers \ h5_ref2reg h5_extlink h5_elink_unix2win h5_shared_mesg @@ -403,6 +405,8 @@ TEST_SCRIPT = testh5cc.sh # Install files # List all file that should be installed in examples directory INSTALL_FILES = h5_write.c h5_read.c h5_extend_write.c h5_chunk_read.c \ + h5_crtgrpd.c h5_subset.c h5_cmprss.c h5_rdwt.c h5_crtgrpar.c \ + h5_extend.c h5_crtatt.c h5_crtgrp.c h5_crtdat.c \ h5_compound.c h5_group.c h5_select.c h5_attribute.c h5_mount.c \ h5_reference.c h5_drivers.c h5_extlink.c h5_elink_unix2win.c \ h5_ref2reg.c h5_shared_mesg.c ph5example.c @@ -668,9 +672,14 @@ help: @BUILD_PARALLEL_CONDITIONAL_FALSE@$(EXTRA_PROG): $(H5CC) @BUILD_PARALLEL_CONDITIONAL_FALSE@ $(H5CC) $(H5CCFLAGS) $(CFLAGS) -o $@ $(srcdir)/$@.c; -# Two of the examples depend on files created by other examples. +# Some examples depend on files created by other examples. h5_read.chkexe_: h5_write.chkexe_ h5_chunk_read.chkexe_: h5_extend_write.chkexe_ +h5_crtgrpd.chkexe_: h5_crtgrpar.chkexe_ +# h5_rdwt and h5_crtatt both modify the same file created by +# h5_crtdat. Serialize them. +h5_rdwt.chkexe_: h5_crtdat.chkexe_ +h5_crtatt.chkexe_: h5_rdwt.chkexe_ $(EXTLINK_DIRS): echo $(mkdir_p) $@ @@ -684,6 +693,15 @@ $(EXTLINK_DIRS): # library above. h5_chunk_read: $(srcdir)/h5_chunk_read.c h5_compound: $(srcdir)/h5_compound.c +h5_crtgrpd: $(srcdir)/h5_crtgrpd.c +h5_subset: $(srcdir)/h5_subset.c +h5_cmprss: $(srcdir)/h5_cmprss.c +h5_rdwt: $(srcdir)/h5_rdwt.c +h5_crtgrpar: $(srcdir)/h5_crtgrpar.c +h5_extend: $(srcdir)/h5_extend.c +h5_crtatt: $(srcdir)/h5_crtatt.c +h5_crtgrp: $(srcdir)/h5_crtgrp.c +h5_crtdat: $(srcdir)/h5_crtdat.c h5_extend_write: $(srcdir)/h5_extend_write.c h5_group: $(srcdir)/h5_group.c h5_write: $(srcdir)/h5_write.c diff --git a/examples/h5_cmprss.c b/examples/h5_cmprss.c new file mode 100644 index 0000000..4a2f982 --- /dev/null +++ b/examples/h5_cmprss.c @@ -0,0 +1,125 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. 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 () {
+
+ 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];
+
+ /* 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);
+
+
+ /* Create dataset "Compressed Data" in the group using absolute name. */
+ dims[0] = DIM0;
+ dims[1] = DIM1;
+ dataspace_id = H5Screate_simple (RANK, dims, NULL);
+
+ 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);
+
+ /* Set ZLIB / DEFLATE Compression using compression level 6.
+ * To use SZIP Compression comment out these lines.
+ */
+ status = H5Pset_deflate (plist_id, 6);
+
+ /* 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;
+
+ 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);
+
+ /* 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");
+ }
+ }
+
+ 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_crtatt.c b/examples/h5_crtatt.c new file mode 100644 index 0000000..416839f --- /dev/null +++ b/examples/h5_crtatt.c @@ -0,0 +1,63 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * This example illustrates how to create an attribute attached to a
+ * dataset. It is used in the HDF5 Tutorial.
+ */
+
+#include "hdf5.h"
+#define FILE "dset.h5"
+
+int main() {
+
+ 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;
+
+ /* 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);
+
+ /* 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);
+
+ /* Write the attribute data. */
+ status = H5Awrite(attribute_id, H5T_NATIVE_INT, attr_data);
+
+ /* Close the attribute. */
+ status = H5Aclose(attribute_id);
+
+ /* Close the dataspace. */
+ status = H5Sclose(dataspace_id);
+
+ /* Close to the dataset. */
+ status = H5Dclose(dataset_id);
+
+ /* Close the file. */
+ status = H5Fclose(file_id);
+}
diff --git a/examples/h5_crtdat.c b/examples/h5_crtdat.c new file mode 100644 index 0000000..bbb29b2 --- /dev/null +++ b/examples/h5_crtdat.c @@ -0,0 +1,51 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. 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
+ * array. It is used in the HDF5 Tutorial.
+ */
+
+#include "hdf5.h"
+#define FILE "dset.h5"
+
+int main() {
+
+ 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 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);
+
+ /* 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);
+
+ /* Close the file. */
+ status = H5Fclose(file_id);
+}
+
diff --git a/examples/h5_crtgrp.c b/examples/h5_crtgrp.c new file mode 100644 index 0000000..3a94a8f --- /dev/null +++ b/examples/h5_crtgrp.c @@ -0,0 +1,40 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. 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.
+ * It is used in the HDF5 Tutorial.
+ */
+
+#include "hdf5.h"
+#define FILE "group.h5"
+
+int main() {
+
+ 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 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);
+
+ /* Terminate access to the file. */
+ status = H5Fclose(file_id);
+}
diff --git a/examples/h5_crtgrpar.c b/examples/h5_crtgrpar.c new file mode 100644 index 0000000..9e6fc40 --- /dev/null +++ b/examples/h5_crtgrpar.c @@ -0,0 +1,48 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. 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
+ * relative names. It is used in the HDF5 Tutorial.
+ */
+
+#include "hdf5.h"
+#define FILE "groups.h5"
+
+int main() {
+
+ 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 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_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 the file. */
+ status = H5Fclose(file_id);
+}
diff --git a/examples/h5_crtgrpd.c b/examples/h5_crtgrpd.c new file mode 100644 index 0000000..9c45928 --- /dev/null +++ b/examples/h5_crtgrpd.c @@ -0,0 +1,91 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. 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 in a group.
+ * It is used in the HDF5 Tutorial.
+ */
+
+#include "hdf5.h"
+#define FILE "groups.h5"
+
+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];
+
+ /* 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;
+
+ /* 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 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);
+
+ /* Close the data space for the first dataset. */
+ status = H5Sclose(dataspace_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);
+
+ /* 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);
+
+ /* 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 second dataset */
+ status = H5Dclose(dataset_id);
+
+ /* Close the group. */
+ status = H5Gclose(group_id);
+
+ /* Close the file. */
+ status = H5Fclose(file_id);
+}
+
diff --git a/examples/h5_extend.c b/examples/h5_extend.c new file mode 100644 index 0000000..105e553 --- /dev/null +++ b/examples/h5_extend.c @@ -0,0 +1,146 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. 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 + * 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 + +int +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} }; + + /* 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} }; + + /* 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; + + /* Create the data space with unlimited dimensions. */ + 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); + + /* Modify dataset creation properties, i.e. enable chunking */ + prop = H5Pcreate (H5P_DATASET_CREATE); + status = H5Pset_chunk (prop, RANK, chunk_dims); + + /* Create a new dataset within the file using chunk + creation properties. */ + 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); + + /* Extend the dataset. Dataset becomes 10 x 3 */ + size[0] = dims[0]+ dimsext[0]; + size[1] = dims[1]; + status = H5Dset_extent (dataset, size); + + /* Select a hyperslab in extended portion of dataset */ + filespace = H5Dget_space (dataset); + offset[0] = 3; + offset[1] = 0; + status = H5Sselect_hyperslab (filespace, H5S_SELECT_SET, offset, NULL, + dimsext, NULL); + + /* Define memory space */ + 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); + + /* Close resources */ + 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); + + filespace = H5Dget_space (dataset); + rank = H5Sget_simple_extent_ndims (filespace); + status_n = H5Sget_simple_extent_dims (filespace, dimsr, NULL); + + prop = H5Dget_create_plist (dataset); + + 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); + + 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"); + } + + status = H5Pclose (prop); + status = H5Dclose (dataset); + status = H5Sclose (filespace); + status = H5Sclose (memspace); + status = H5Fclose (file); +} diff --git a/examples/h5_rdwt.c b/examples/h5_rdwt.c new file mode 100644 index 0000000..d5444e0 --- /dev/null +++ b/examples/h5_rdwt.c @@ -0,0 +1,53 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. 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.
+ */
+
+#include "hdf5.h"
+#define FILE "dset.h5"
+
+int main() {
+
+ 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;
+
+ /* 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);
+
+ /* 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);
+
+ /* Close the dataset. */
+ status = H5Dclose(dataset_id);
+
+ /* Close the file. */
+ status = H5Fclose(file_id);
+}
diff --git a/examples/h5_subset.c b/examples/h5_subset.c new file mode 100644 index 0000000..66872ea --- /dev/null +++ b/examples/h5_subset.c @@ -0,0 +1,153 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. 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) + * 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 DIM0 8 /* size of dataset */ +#define DIM1 10 + +int +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; + + + /***************************************************************** + * 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); + + 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; + else + data[j][i] = 2; + } + + 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"); + } + 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. + *****************************************************/ + + 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; + + stride[0] = 1; + stride[1] = 1; + + block[0] = 1; + block[1] = 1; + + /* 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); + + 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 + entire dataset back from the file. */ + + 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"); + } + + status = H5Sclose (memspace_id); + status = H5Sclose (dataspace_id); + status = H5Dclose (dataset_id); + status = H5Fclose (file_id); + +} diff --git a/examples/run-c-ex.sh.in b/examples/run-c-ex.sh.in index 8d0bdcd..9b2a2bb 100644 --- a/examples/run-c-ex.sh.in +++ b/examples/run-c-ex.sh.in @@ -78,7 +78,25 @@ fi # Run tests if [ $? -eq 0 ] then - if (RunTest h5_write &&\ + if (RunTest h5_crtdat &&\ + rm h5_crtdat &&\ + RunTest h5_extend &&\ + rm h5_extend &&\ + RunTest h5_rdwt &&\ + rm h5_rdwt &&\ + RunTest h5_crtatt &&\ + rm h5_crtatt &&\ + RunTest h5_crtgrp &&\ + rm h5_crtgrp &&\ + RunTest h5_crtgrpar &&\ + rm h5_crtgrpar &&\ + RunTest h5_crtgrpd &&\ + rm h5_crtgrpd &&\ + RunTest h5_subset &&\ + rm h5_subset &&\ + RunTest h5_cmprss &&\ + rm h5_cmprss &&\ + RunTest h5_write &&\ rm h5_write &&\ RunTest h5_read &&\ rm h5_read &&\ diff --git a/fortran/examples/CMakeLists.txt b/fortran/examples/CMakeLists.txt index 0825f81..6154387 100644 --- a/fortran/examples/CMakeLists.txt +++ b/fortran/examples/CMakeLists.txt @@ -14,13 +14,15 @@ INCLUDE_DIRECTORIES (${CMAKE_Fortran_MODULE_DIRECTORY} ${HDF5_F90_BINARY_DIR} ${ # Define Sources #----------------------------------------------------------------------------- SET (examples - dsetexample - fileexample - rwdsetexample - attrexample - groupexample - grpsexample - grpdsetexample + h5_cmprss + h5_crtdat + h5_rdwt + h5_crtatt + h5_crtgrp + h5_crtgrpar + h5_crtgrpd + h5_extend + h5_subset hyperslab selectele refobjexample diff --git a/fortran/examples/Makefile.am b/fortran/examples/Makefile.am index 310c4e2..e994d4e 100644 --- a/fortran/examples/Makefile.am +++ b/fortran/examples/Makefile.am @@ -32,15 +32,15 @@ endif # We don't tell automake about these programs so that it doesn't try to # compile them with the regular fortran compiler. -EXAMPLE_PROG=dsetexample fileexample rwdsetexample attrexample groupexample \ - grpsexample grpdsetexample hyperslab selectele refobjexample \ - refregexample mountexample compound +EXAMPLE_PROG=h5_crtdat h5_rdwt h5_crtatt h5_crtgrp \ + h5_crtgrpar h5_crtgrpd h5_extend h5_subset h5_cmprss hyperslab selectele \ + refobjexample refregexample mountexample compound # List files to be installed here -INSTALL_FILES=dsetexample.f90 fileexample.f90 rwdsetexample.f90 \ - attrexample.f90 groupexample.f90 grpsexample.f90 grpdsetexample.f90 \ - hyperslab.f90 selectele.f90 refobjexample.f90 \ - refregexample.f90 mountexample.f90 compound.f90 ph5example.f90 +INSTALL_FILES=h5_crtdat.f90 h5_rdwt.f90 \ + h5_crtatt.f90 h5_crtgrp.f90 h5_crtgrpar.f90 h5_crtgrpd.f90 \ + h5_extend.f90 h5_subset.f90 h5_cmprss.f90 hyperslab.f90 selectele.f90 refobjexample.f90 \ + refregexample.f90 mountexample.f90 compound.f90 ph5example.f90 INSTALL_SCRIPT_FILES = run-fortran-ex.sh @@ -57,12 +57,12 @@ TEST_SCRIPT=testh5fc.sh FORTRAN_API=yes # Some examples depend on files created by other examples. -grpdsetexample.chkexe_: grpsexample.chkexe_ +h5_crtgrpd.chkexe_: h5_crtgrpar.chkexe_ refregexample.chkexe_: refobjexample.chkexe_ -# rwdsetexample and attrexample both modify the same file created by -# dsetexample. Serialize them. -rwdsetexample.chkexe_: dsetexample.chkexe_ -attrexample.chkexe_: rwdsetexample.chkexe_ +# h5_rdwt and h5_crtatt both modify the same file created by +# h5_crtdat. Serialize them. +h5_rdwt.chkexe_: h5_crtdat.chkexe_ +h5_crtatt.chkexe_: h5_rdwt.chkexe_ # Tell automake how to build examples using h5fc # Additional dependencies for the examples are listed below @@ -84,13 +84,15 @@ EXAMPLEDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples/fortran # an inelegant way of solving the problem. # All programs share the same build rule and a dependency on the main hdf5 # and fortran libraries above. -dsetexample: dsetexample.f90 -fileexample: fileexample.f90 -rwdsetexample: rwdsetexample.f90 -attrexample: attrexample.f90 -groupexample: groupexample.f90 -grpsexample: grpsexample.f90 -grpdsetexample: grpdsetexample.f90 +h5_crtdat: h5_crtdat.f90 +h5_extend: h5_extend.f90 +h5_subset: h5_subset.f90 +h5_rdwt: h5_rdwt.f90 +h5_crtatt: h5_crtatt.f90 +h5_crtgrp: h5_crtgrp.f90 +h5_crtgrpar: h5_crtgrpar.f90 +h5_crtgrpd: h5_crtgrpd.f90 +h5_cmprss: h5_cmprss.f90 hyperslab: hyperslab.f90 selectele: selectele.f90 refobjexample: refobjexample.f90 diff --git a/fortran/examples/Makefile.in b/fortran/examples/Makefile.in index 21adf62..5f6124c 100644 --- a/fortran/examples/Makefile.in +++ b/fortran/examples/Makefile.in @@ -405,17 +405,17 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.h5 # be run. # We don't tell automake about these programs so that it doesn't try to # compile them with the regular fortran compiler. -EXAMPLE_PROG = dsetexample fileexample rwdsetexample attrexample \ - groupexample grpsexample grpdsetexample hyperslab selectele \ +EXAMPLE_PROG = h5_crtdat h5_rdwt h5_crtatt h5_crtgrp h5_crtgrpar \ + h5_crtgrpd h5_extend h5_subset h5_cmprss hyperslab selectele \ refobjexample refregexample mountexample compound \ $(am__append_1) # List files to be installed here -INSTALL_FILES = dsetexample.f90 fileexample.f90 rwdsetexample.f90 \ - attrexample.f90 groupexample.f90 grpsexample.f90 \ - grpdsetexample.f90 hyperslab.f90 selectele.f90 \ - refobjexample.f90 refregexample.f90 mountexample.f90 \ - compound.f90 ph5example.f90 $(am__append_2) +INSTALL_FILES = h5_crtdat.f90 h5_rdwt.f90 h5_crtatt.f90 h5_crtgrp.f90 \ + h5_crtgrpar.f90 h5_crtgrpd.f90 h5_extend.f90 h5_subset.f90 \ + h5_cmprss.f90 hyperslab.f90 selectele.f90 refobjexample.f90 \ + refregexample.f90 mountexample.f90 compound.f90 ph5example.f90 \ + $(am__append_2) INSTALL_SCRIPT_FILES = run-fortran-ex.sh TEST_SCRIPT = testh5fc.sh @@ -668,12 +668,12 @@ help: @$(top_srcdir)/bin/makehelp # Some examples depend on files created by other examples. -grpdsetexample.chkexe_: grpsexample.chkexe_ +h5_crtgrpd.chkexe_: h5_crtgrpar.chkexe_ refregexample.chkexe_: refobjexample.chkexe_ -# rwdsetexample and attrexample both modify the same file created by -# dsetexample. Serialize them. -rwdsetexample.chkexe_: dsetexample.chkexe_ -attrexample.chkexe_: rwdsetexample.chkexe_ +# h5_rdwt and h5_crtatt both modify the same file created by +# h5_crtdat. Serialize them. +h5_rdwt.chkexe_: h5_crtdat.chkexe_ +h5_crtatt.chkexe_: h5_rdwt.chkexe_ # Tell automake how to build examples using h5fc # Additional dependencies for the examples are listed below @@ -688,13 +688,15 @@ attrexample.chkexe_: rwdsetexample.chkexe_ # an inelegant way of solving the problem. # All programs share the same build rule and a dependency on the main hdf5 # and fortran libraries above. -dsetexample: dsetexample.f90 -fileexample: fileexample.f90 -rwdsetexample: rwdsetexample.f90 -attrexample: attrexample.f90 -groupexample: groupexample.f90 -grpsexample: grpsexample.f90 -grpdsetexample: grpdsetexample.f90 +h5_crtdat: h5_crtdat.f90 +h5_extend: h5_extend.f90 +h5_subset: h5_subset.f90 +h5_rdwt: h5_rdwt.f90 +h5_crtatt: h5_crtatt.f90 +h5_crtgrp: h5_crtgrp.f90 +h5_crtgrpar: h5_crtgrpar.f90 +h5_crtgrpd: h5_crtgrpd.f90 +h5_cmprss: h5_cmprss.f90 hyperslab: hyperslab.f90 selectele: selectele.f90 refobjexample: refobjexample.f90 diff --git a/fortran/examples/attrexample.f90 b/fortran/examples/attrexample.f90 deleted file mode 100644 index ffbeabe..0000000 --- a/fortran/examples/attrexample.f90 +++ /dev/null @@ -1,117 +0,0 @@ -! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -! Copyright by The HDF Group. * -! Copyright by the Board of Trustees of the University of Illinois. * -! All rights reserved. * -! * -! This file is part of HDF5. The full HDF5 copyright notice, including * -! terms governing use, modification, and redistribution, is contained in * -! the files COPYING and Copyright.html. COPYING can be found at the root * -! of the source code distribution tree; Copyright.html can be found at the * -! root level of an installed copy of the electronic HDF5 document set and * -! is linked from the top-level documents page. It can also be found at * -! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * -! access to either file, you may request a copy from help@hdfgroup.org. * -! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -! -! This example shows how to create and write a dataset attribute. -! It opens the existing file 'dset.h5', obtains the identifier of -! the dataset "/dset", defines attribute's dataspace, -! creates dataset attribute, writes the attribute, and then closes -! the attribute's dataspace, attribute, dataset, and file. - - PROGRAM ATTREXAMPLE - - - USE HDF5 ! This module contains all necessary modules - - IMPLICIT NONE - - CHARACTER(LEN=8), PARAMETER :: filename = "dsetf.h5" ! File name - CHARACTER(LEN=4), PARAMETER :: dsetname = "dset" ! Dataset name - CHARACTER(LEN=9), PARAMETER :: aname = "attr_long" ! Attribute name - - INTEGER(HID_T) :: file_id ! File identifier - INTEGER(HID_T) :: dset_id ! Dataset identifier - INTEGER(HID_T) :: attr_id ! Attribute identifier - INTEGER(HID_T) :: aspace_id ! Attribute Dataspace identifier - INTEGER(HID_T) :: atype_id ! Attribute Dataspace identifier - INTEGER(HSIZE_T), DIMENSION(1) :: adims = (/2/) ! Attribute dimension - INTEGER :: arank = 1 ! Attribure rank - INTEGER(SIZE_T) :: attrlen ! Length of the attribute string - - CHARACTER(LEN=80), DIMENSION(2) :: attr_data ! Attribute data - - INTEGER :: error ! Error flag - INTEGER(HSIZE_T), DIMENSION(1) :: data_dims - - - ! - ! Initialize attribute's data - ! - attr_data(1) = "Dataset character attribute" - attr_data(2) = "Some other string here " - attrlen = 80 - ! - ! Initialize FORTRAN interface. - ! - CALL h5open_f(error) - - ! - ! Open an existing file. - ! - CALL h5fopen_f (filename, H5F_ACC_RDWR_F, file_id, error) - - ! - ! Open an existing dataset. - ! - CALL h5dopen_f(file_id, dsetname, dset_id, error) - - ! - ! Create scalar data space for the attribute. - ! - CALL h5screate_simple_f(arank, adims, aspace_id, error) - ! - ! Create datatype for the attribute. - ! - CALL h5tcopy_f(H5T_NATIVE_CHARACTER, atype_id, error) - CALL h5tset_size_f(atype_id, attrlen, error) - - ! - ! Create dataset attribute. - ! - CALL h5acreate_f(dset_id, aname, atype_id, aspace_id, & - attr_id, error) - - ! - ! Write the attribute data. - ! - data_dims(1) = 2 - CALL h5awrite_f(attr_id, atype_id, attr_data, data_dims, error) - - ! - ! Close the attribute. - ! - CALL h5aclose_f(attr_id, error) - - ! - ! Terminate access to the data space. - ! - CALL h5sclose_f(aspace_id, error) - - ! - ! End access to the dataset and release resources used by it. - ! - CALL h5dclose_f(dset_id, error) - - ! - ! Close the file. - ! - CALL h5fclose_f(file_id, error) - - ! - ! Close FORTRAN interface. - ! - CALL h5close_f(error) - - END PROGRAM ATTREXAMPLE - diff --git a/fortran/examples/dsetexample.f90 b/fortran/examples/dsetexample.f90 deleted file mode 100644 index 209a516..0000000 --- a/fortran/examples/dsetexample.f90 +++ /dev/null @@ -1,85 +0,0 @@ -! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -! Copyright by The HDF Group. * -! Copyright by the Board of Trustees of the University of Illinois. * -! All rights reserved. * -! * -! This file is part of HDF5. The full HDF5 copyright notice, including * -! terms governing use, modification, and redistribution, is contained in * -! the files COPYING and Copyright.html. COPYING can be found at the root * -! of the source code distribution tree; Copyright.html can be found at the * -! root level of an installed copy of the electronic HDF5 document set and * -! is linked from the top-level documents page. It can also be found at * -! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * -! access to either file, you may request a copy from help@hdfgroup.org. * -! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -! -! -! The following example shows how to create an empty dataset. -! It creates a file called 'dsetf.h5', defines the -! dataset dataspace, creates a dataset which is a 4x6 integer array, -! and then closes the dataspace, the dataset, and the file. -! - - PROGRAM DSETEXAMPLE - - USE HDF5 ! This module contains all necessary modules - - IMPLICIT NONE - - CHARACTER(LEN=8), PARAMETER :: filename = "dsetf.h5" ! File name - CHARACTER(LEN=4), PARAMETER :: dsetname = "dset" ! Dataset name - - INTEGER(HID_T) :: file_id ! File identifier - INTEGER(HID_T) :: dset_id ! Dataset identifier - INTEGER(HID_T) :: dspace_id ! Dataspace identifier - - - INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/4,6/) ! Dataset dimensions - INTEGER :: rank = 2 ! Dataset rank - - INTEGER :: error ! Error flag - - ! - ! Initialize FORTRAN interface. - ! - CALL h5open_f(error) - - ! - ! Create a new file using default properties. - ! - CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error) - - ! - ! Create the dataspace. - ! - CALL h5screate_simple_f(rank, dims, dspace_id, error) - - ! - ! Create the dataset with default properties. - ! - CALL h5dcreate_f(file_id, dsetname, H5T_NATIVE_INTEGER, dspace_id, & - dset_id, error) - - ! - ! End access to the dataset and release resources used by it. - ! - CALL h5dclose_f(dset_id, error) - - ! - ! Terminate access to the data space. - ! - CALL h5sclose_f(dspace_id, error) - - ! - ! Close the file. - ! - CALL h5fclose_f(file_id, error) - - ! - ! Close FORTRAN interface. - ! - CALL h5close_f(error) - - END PROGRAM DSETEXAMPLE - - diff --git a/fortran/examples/fileexample.f90 b/fortran/examples/fileexample.f90 deleted file mode 100644 index 87119d2..0000000 --- a/fortran/examples/fileexample.f90 +++ /dev/null @@ -1,49 +0,0 @@ -! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -! Copyright by The HDF Group. * -! Copyright by the Board of Trustees of the University of Illinois. * -! All rights reserved. * -! * -! This file is part of HDF5. The full HDF5 copyright notice, including * -! terms governing use, modification, and redistribution, is contained in * -! the files COPYING and Copyright.html. COPYING can be found at the root * -! of the source code distribution tree; Copyright.html can be found at the * -! root level of an installed copy of the electronic HDF5 document set and * -! is linked from the top-level documents page. It can also be found at * -! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * -! access to either file, you may request a copy from help@hdfgroup.org. * -! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -! -! -! The following example demonstrates how to create and close an HDF5 file. -! It creates a file called 'file.h5', and then closes the file. -! - - PROGRAM FILEEXAMPLE - - USE HDF5 ! This module contains all necessary modules - - IMPLICIT NONE - - CHARACTER(LEN=8), PARAMETER :: filename = "filef.h5" ! File name - INTEGER(HID_T) :: file_id ! File identifier - - INTEGER :: error ! Error flag - -! -! Initialize FORTRAN interface. -! - CALL h5open_f (error) - ! - ! Create a new file using default properties. - ! - CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error) - - ! - ! Terminate access to the file. - ! - CALL h5fclose_f(file_id, error) -! -! Close FORTRAN interface. -! - CALL h5close_f(error) - END PROGRAM FILEEXAMPLE diff --git a/fortran/examples/grpdsetexample.f90 b/fortran/examples/grpdsetexample.f90 deleted file mode 100644 index 19fc660..0000000 --- a/fortran/examples/grpdsetexample.f90 +++ /dev/null @@ -1,156 +0,0 @@ -! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -! Copyright by The HDF Group. * -! Copyright by the Board of Trustees of the University of Illinois. * -! All rights reserved. * -! * -! This file is part of HDF5. The full HDF5 copyright notice, including * -! terms governing use, modification, and redistribution, is contained in * -! the files COPYING and Copyright.html. COPYING can be found at the root * -! of the source code distribution tree; Copyright.html can be found at the * -! root level of an installed copy of the electronic HDF5 document set and * -! is linked from the top-level documents page. It can also be found at * -! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * -! access to either file, you may request a copy from help@hdfgroup.org. * -! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -! -! -! This example shows how to create a dataset in a particular group. -! It opens the file created in the previous example and creates two datasets. -! Absolute and relative dataset names are used. -! - - - PROGRAM GRPDSETEXAMPLE - - USE HDF5 ! This module contains all necessary modules - - IMPLICIT NONE - - CHARACTER(LEN=10), PARAMETER :: filename = "groupsf.h5" ! File name - CHARACTER(LEN=15), PARAMETER :: groupname = "MyGroup/Group_A" ! Group name - CHARACTER(LEN=13), PARAMETER :: dsetname1 = "MyGroup/dset1" ! Dataset name - CHARACTER(LEN=5), PARAMETER :: dsetname2 = "dset2" ! dataset name - - INTEGER(HID_T) :: file_id ! File identifier - INTEGER(HID_T) :: group_id ! Group identifier - INTEGER(HID_T) :: dataset_id ! Dataset identifier - INTEGER(HID_T) :: dataspace_id ! Data space identifier - - INTEGER :: i, j - INTEGER :: error ! Error flag - - INTEGER, DIMENSION(3,3) :: dset1_data ! Data arrays - INTEGER, DIMENSION(2,10) :: dset2_data ! - - INTEGER(HSIZE_T), DIMENSION(2) :: dims1 = (/3,3/) ! Datasets dimensions - INTEGER(HSIZE_T), DIMENSION(2) :: dims2 = (/2,10/)! - INTEGER(HSIZE_T), DIMENSION(2) :: data_dims - - INTEGER :: rank = 2 ! Datasets rank - - ! - !Initialize dset1_data array - ! - do i = 1, 3 - do j = 1, 3 - dset1_data(i,j) = j; - end do - end do - - - ! - !Initialize dset2_data array - ! - do i = 1, 2 - do j = 1, 10 - dset2_data(i,j) = j; - end do - end do - - ! - ! Initialize FORTRAN interface. - ! - CALL h5open_f(error) - - ! - ! Open an existing file. - ! - CALL h5fopen_f (filename, H5F_ACC_RDWR_F, file_id, error) - - ! - ! Create the data space for the first dataset. - ! - CALL h5screate_simple_f(rank, dims1, dataspace_id, error) - - ! - ! Create a dataset in group "MyGroup" with default properties. - ! - CALL h5dcreate_f(file_id, dsetname1, H5T_NATIVE_INTEGER, dataspace_id, & - dataset_id, error) - - ! - ! Write the first dataset. - ! - data_dims(1) = 3 - data_dims(2) = 3 - CALL h5dwrite_f(dataset_id, H5T_NATIVE_INTEGER, dset1_data, data_dims, error) - - ! - ! Close the dataspace for the first dataset. - ! - CALL h5sclose_f(dataspace_id, error) - - ! - ! Close the first dataset. - ! - CALL h5dclose_f(dataset_id, error) - - ! - ! Open an existing group in the specified file. - ! - CALL h5gopen_f(file_id, groupname, group_id, error) - - ! - !Create the data space for the second dataset. - ! - CALL h5screate_simple_f(rank, dims2, dataspace_id, error) - - ! - ! Create the second dataset in group "Group_A" with default properties. - ! - CALL h5dcreate_f(group_id, dsetname2, H5T_NATIVE_INTEGER, dataspace_id, & - dataset_id, error) - - ! - ! Write the second dataset. - ! - data_dims(1) = 2 - data_dims(1) = 10 - CALL h5dwrite_f(dataset_id, H5T_NATIVE_INTEGER, dset2_data, data_dims, error) - - ! - ! Close the dataspace for the second dataset. - ! - CALL h5sclose_f(dataspace_id, error) - - ! - ! Close the second dataset. - ! - CALL h5dclose_f(dataset_id, error) - - ! - ! Close the group. - ! - CALL h5gclose_f(group_id, error) - - ! - ! Close the file. - ! - CALL h5fclose_f(file_id, error) - - ! - ! Close FORTRAN interface. - ! - CALL h5close_f(error) - - END PROGRAM GRPDSETEXAMPLE diff --git a/fortran/examples/grpsexample.f90 b/fortran/examples/grpsexample.f90 deleted file mode 100644 index 0f694e9..0000000 --- a/fortran/examples/grpsexample.f90 +++ /dev/null @@ -1,83 +0,0 @@ -! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -! Copyright by The HDF Group. * -! Copyright by the Board of Trustees of the University of Illinois. * -! All rights reserved. * -! * -! This file is part of HDF5. The full HDF5 copyright notice, including * -! terms governing use, modification, and redistribution, is contained in * -! the files COPYING and Copyright.html. COPYING can be found at the root * -! of the source code distribution tree; Copyright.html can be found at the * -! root level of an installed copy of the electronic HDF5 document set and * -! is linked from the top-level documents page. It can also be found at * -! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * -! access to either file, you may request a copy from help@hdfgroup.org. * -! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -! -! -! The following example code shows how to create groups -! using absolute and relative names. It creates three groups: -! the first two groups are created using the file identifier and -! the group absolute names, and the third group is created using -! a group identifier and the name relative to the specified group. -! - - - PROGRAM GRPSEXAMPLE - - USE HDF5 ! This module contains all necessary modules - - IMPLICIT NONE - - CHARACTER(LEN=10), PARAMETER :: filename = "groupsf.h5" ! File name - CHARACTER(LEN=8), PARAMETER :: groupname1 = "/MyGroup" ! Group name - CHARACTER(LEN=16), PARAMETER :: groupname2 = "/MyGroup/Group_A" - ! Group name - CHARACTER(LEN=7), PARAMETER :: groupname3 = "Group_B" ! Group name - - INTEGER(HID_T) :: file_id ! File identifier - INTEGER(HID_T) :: group1_id, group2_id, group3_id ! Group identifiers - - INTEGER :: error ! Error flag - ! - ! Initialize FORTRAN interface. - ! - CALL h5open_f(error) - - ! - ! Create a new file using default properties. - ! - CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error) - - ! - ! Create group "MyGroup" in the root group using absolute name. - ! - CALL h5gcreate_f(file_id, groupname1, group1_id, error) - - ! - ! Create group "Group_A" in group "MyGroup" using absolute name. - ! - CALL h5gcreate_f(file_id, groupname2, group2_id, error) - - ! - ! Create group "Group_B" in group "MyGroup" using relative name. - ! - CALL h5gcreate_f(group1_id, groupname3, group3_id, error) - - ! - ! Close the groups. - ! - CALL h5gclose_f(group1_id, error) - CALL h5gclose_f(group2_id, error) - CALL h5gclose_f(group3_id, error) - - ! - ! Terminate access to the file. - ! - CALL h5fclose_f(file_id, error) - - ! - ! Close FORTRAN interface. - ! - CALL h5close_f(error) - - END PROGRAM GRPSEXAMPLE diff --git a/fortran/examples/h5_cmprss.f90 b/fortran/examples/h5_cmprss.f90 new file mode 100644 index 0000000..847a922 --- /dev/null +++ b/fortran/examples/h5_cmprss.f90 @@ -0,0 +1,131 @@ +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+! Copyright by The HDF Group. *
+! Copyright by the Board of Trustees of the University of Illinois. *
+! All rights reserved. *
+! *
+! This file is part of HDF5. The full HDF5 copyright notice, including *
+! terms governing use, modification, and redistribution, is contained in *
+! the files COPYING and Copyright.html. COPYING can be found at the root *
+! of the source code distribution tree; Copyright.html can be found at the *
+! root level of an installed copy of the electronic HDF5 document set and *
+! is linked from the top-level documents page. It can also be found at *
+! http://hdfgroup.org/HDF5/doc/Copyright.html. 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.
+!
+PROGRAM h5_cmprss
+
+ USE HDF5 ! This module contains all necessary modules
+
+ IMPLICIT NONE
+ !
+ ! The dataset is stored in file "h5_cmprss.h5"
+ !
+ CHARACTER(LEN=12), PARAMETER :: filename = "h5_cmprss.h5"
+ INTEGER, PARAMETER :: rank = 2 ! Rank of the data set
+ INTEGER, PARAMETER :: dim0 = 100 ! Data set sizes
+ INTEGER, PARAMETER :: dim1 = 20
+
+ INTEGER(hid_t) :: file_id, dataset_id, dataspace_id ! Identifiers
+ INTEGER(hid_t) :: plist_id ! Property list identifier
+
+ INTEGER :: error
+ INTEGER(hsize_t), DIMENSION(1:rank) :: dims ! dimensions of data
+ INTEGER(hsize_t), DIMENSION(1:rank) :: cdims ! sizes of chunked data
+
+ INTEGER :: i,j, numfilt
+ INTEGER, DIMENSION(1:dim0,1:dim1) :: buf ! write buffer
+ INTEGER, DIMENSION(1:dim0,1:dim1) :: rbuf ! read buffer
+ INTEGER(HSIZE_T), DIMENSION(1:rank) :: data_dims ! dimensions of data buffers
+
+ INTEGER, DIMENSION(1:1) :: cd_values ! Auxiliary data for the filter
+ INTEGER(size_t) :: nelmts ! Number of elements in cd_values
+ INTEGER :: flags ! Bit vector specifying certain general properties of the filter
+ INTEGER(SIZE_T) :: namelen = 180 ! Anticipated number of characters in name
+ CHARACTER(LEN=180) :: name ! Name of the filter
+ INTEGER :: filter_id ! Filter identification number
+
+ ! Uncomment these variables to use SZIP compression
+ !INTEGER :: szip_options_mask
+ !INTEGER :: szip_pixels_per_block
+
+ !
+ !Initialize FORTRAN predifined datatypes
+ !
+ CALL h5open_f(error)
+ !
+ ! Create a file
+ CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error)
+ !
+ ! Create dataset "Compressed Data" in the group using absolute name.
+ dims(1:2) = (/dim0, dim1/)
+ CALL h5screate_simple_f(rank, dims, dataspace_id, error)
+ CALL h5pcreate_f(H5P_DATASET_CREATE_F, plist_id, error)
+ !
+ ! Dataset must be chunked for compression
+ cdims(1:2) = 20
+ CALL h5pset_chunk_f(plist_id, 2, cdims, error)
+
+ ! Set ZLIB / DEFLATE Compression using compression level 6.
+ ! To use SZIP Compression comment out these lines.
+ CALL h5pset_deflate_f(plist_id, 6, error)
+
+ ! Uncomment these lines to set SZIP Compression
+ !szip_options_mask = H5_SZIP_NN_OM_F
+ !szip_pixels_per_block = 16
+ !CALL H5Pset_szip_f(plist_id, szip_options_mask, szip_pixels_per_block, error)
+
+ ! Create data set
+ CALL h5dcreate_f(file_id, "Compressed_Data", H5T_NATIVE_INTEGER, dataspace_id, &
+ dataset_id, error, dcpl_id=plist_id)
+
+ DO j = 1, dim1
+ DO i = 1, dim0
+ buf(i,j) = i+j
+ ENDDO
+ ENDDO
+
+ data_dims(1:2) = (/dim0,dim1/)
+ CALL h5dwrite_f(dataset_id, H5T_NATIVE_INTEGER, buf, data_dims, error)
+
+ ! Close resources
+ CALL h5sclose_f(dataspace_id, error)
+ CALL h5pclose_f(plist_id, error)
+ CALL h5dclose_f(dataset_id, error)
+ CALL h5fclose_f(file_id, error)
+
+ ! Now reopen the file and dataset in the file.
+ CALL h5fopen_f(filename, H5F_ACC_RDONLY_F, file_id, error)
+ CALL h5dopen_f(file_id, "Compressed_Data", dataset_id, error)
+
+ ! Retrieve filter information.
+ CALL h5dget_create_plist_f(dataset_id, plist_id, error)
+
+ CALL h5pget_nfilters_f(plist_id, numfilt, error)
+ WRITE(*,'(A, I0)') "Number of filters associated with dataset: ", numfilt
+
+ DO i = 1, numfilt
+ nelmts = 1
+ CALL h5pget_filter_f(plist_id, 0, flags, nelmts, cd_values, &
+ namelen, name, filter_id, error)
+
+ WRITE(*,'(30X,A)', ADVANCE='NO')"Filter Type: "
+ IF(filter_id.EQ.H5Z_FILTER_DEFLATE_F)THEN
+ WRITE(*,'(A)') "H5Z_FILTER_DEFLATE"
+ ELSEIF (filter_id.EQ.H5Z_FILTER_SZIP_F)THEN
+ WRITE(*,'(A)') "H5Z_FILTER_SZIP"
+ ELSE
+ WRITE(*,'(A)') "Other filter type included"
+ ENDIF
+ ENDDO
+ data_dims(1:2) = (/dim0,dim1/)
+ CALL h5dread_f(dataset_id, H5T_NATIVE_INTEGER, rbuf, data_dims, error)
+
+ CALL h5dclose_f(dataset_id, error)
+ CALL h5pclose_f(plist_id, error)
+ CALL h5fclose_f(file_id, error)
+
+END PROGRAM h5_cmprss
diff --git a/fortran/examples/h5_crtatt.f90 b/fortran/examples/h5_crtatt.f90 new file mode 100644 index 0000000..79bc576 --- /dev/null +++ b/fortran/examples/h5_crtatt.f90 @@ -0,0 +1,106 @@ +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! Copyright by The HDF Group. * +! Copyright by the Board of Trustees of the University of Illinois. * +! All rights reserved. * +! * +! This file is part of HDF5. The full HDF5 copyright notice, including * +! terms governing use, modification, and redistribution, is contained in * +! the files COPYING and Copyright.html. COPYING can be found at the root * +! of the source code distribution tree; Copyright.html can be found at the * +! root level of an installed copy of the electronic HDF5 document set and * +! is linked from the top-level documents page. It can also be found at * +! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +! access to either file, you may request a copy from help@hdfgroup.org. * +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! +! This example shows how to create and write a dataset attribute. +! It opens the existing file 'dset.h5', obtains the identifier of +! the dataset "/dset", defines attribute's dataspace, +! creates dataset attribute, writes the attribute, and then closes +! the attribute's dataspace, attribute, dataset, and file. +! +! This example is used in the HDF5 Tutorial. + +PROGRAM H5_CRTATT + + USE HDF5 ! This module contains all necessary modules + + IMPLICIT NONE + + CHARACTER(LEN=8), PARAMETER :: filename = "dsetf.h5" ! File name + CHARACTER(LEN=4), PARAMETER :: dsetname = "dset" ! Dataset name + CHARACTER(LEN=9), PARAMETER :: aname = "attr_long" ! Attribute name + + INTEGER(HID_T) :: file_id ! File identifier + INTEGER(HID_T) :: dset_id ! Dataset identifier + INTEGER(HID_T) :: attr_id ! Attribute identifier + INTEGER(HID_T) :: aspace_id ! Attribute Dataspace identifier + INTEGER(HID_T) :: atype_id ! Attribute Dataspace identifier + INTEGER(HSIZE_T), DIMENSION(1) :: adims = (/2/) ! Attribute dimension + INTEGER :: arank = 1 ! Attribure rank + INTEGER(SIZE_T) :: attrlen ! Length of the attribute string + + CHARACTER(LEN=80), DIMENSION(2) :: attr_data ! Attribute data + + INTEGER :: error ! Error flag + INTEGER(HSIZE_T), DIMENSION(1) :: data_dims + + ! + ! Initialize attribute's data + ! + attr_data(1) = "Dataset character attribute" + attr_data(2) = "Some other string here " + attrlen = 80 + ! + ! Initialize FORTRAN interface. + ! + CALL h5open_f(error) + ! + ! Open an existing file. + ! + CALL h5fopen_f (filename, H5F_ACC_RDWR_F, file_id, error) + ! + ! Open an existing dataset. + ! + CALL h5dopen_f(file_id, dsetname, dset_id, error) + ! + ! Create scalar data space for the attribute. + ! + CALL h5screate_simple_f(arank, adims, aspace_id, error) + ! + ! Create datatype for the attribute. + ! + CALL h5tcopy_f(H5T_NATIVE_CHARACTER, atype_id, error) + CALL h5tset_size_f(atype_id, attrlen, error) + ! + ! Create dataset attribute. + ! + CALL h5acreate_f(dset_id, aname, atype_id, aspace_id, attr_id, error) + ! + ! Write the attribute data. + ! + data_dims(1) = 2 + CALL h5awrite_f(attr_id, atype_id, attr_data, data_dims, error) + ! + ! Close the attribute. + ! + CALL h5aclose_f(attr_id, error) + ! + ! Terminate access to the data space. + ! + CALL h5sclose_f(aspace_id, error) + ! + ! End access to the dataset and release resources used by it. + ! + CALL h5dclose_f(dset_id, error) + ! + ! Close the file. + ! + CALL h5fclose_f(file_id, error) + ! + ! Close FORTRAN interface. + ! + CALL h5close_f(error) + +END PROGRAM H5_CRTATT + diff --git a/fortran/examples/h5_crtdat.f90 b/fortran/examples/h5_crtdat.f90 new file mode 100644 index 0000000..6e4c3a4 --- /dev/null +++ b/fortran/examples/h5_crtdat.f90 @@ -0,0 +1,86 @@ +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! Copyright by The HDF Group. * +! Copyright by the Board of Trustees of the University of Illinois. * +! All rights reserved. * +! * +! This file is part of HDF5. The full HDF5 copyright notice, including * +! terms governing use, modification, and redistribution, is contained in * +! the files COPYING and Copyright.html. COPYING can be found at the root * +! of the source code distribution tree; Copyright.html can be found at the * +! root level of an installed copy of the electronic HDF5 document set and * +! is linked from the top-level documents page. It can also be found at * +! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +! access to either file, you may request a copy from help@hdfgroup.org. * +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! +! +! The following example shows how to create an empty dataset. +! It creates a file called 'dsetf.h5', defines the +! dataset dataspace, creates a dataset which is a 4x6 integer array, +! and then closes the dataspace, the dataset, and the file. +! +! This example is used in the HDF5 Tutorial. + +PROGRAM H5_CRTDAT + + USE HDF5 ! This module contains all necessary modules + + IMPLICIT NONE + + CHARACTER(LEN=8), PARAMETER :: filename = "dsetf.h5" ! File name + CHARACTER(LEN=4), PARAMETER :: dsetname = "dset" ! Dataset name + + INTEGER(HID_T) :: file_id ! File identifier + INTEGER(HID_T) :: dset_id ! Dataset identifier + INTEGER(HID_T) :: dspace_id ! Dataspace identifier + + + INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/4,6/) ! Dataset dimensions + INTEGER :: rank = 2 ! Dataset rank + + INTEGER :: error ! Error flag + + ! + ! Initialize FORTRAN interface. + ! + CALL h5open_f(error) + + ! + ! Create a new file using default properties. + ! + CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error) + + ! + ! Create the dataspace. + ! + CALL h5screate_simple_f(rank, dims, dspace_id, error) + + ! + ! Create the dataset with default properties. + ! + CALL h5dcreate_f(file_id, dsetname, H5T_NATIVE_INTEGER, dspace_id, & + dset_id, error) + + ! + ! End access to the dataset and release resources used by it. + ! + CALL h5dclose_f(dset_id, error) + + ! + ! Terminate access to the data space. + ! + CALL h5sclose_f(dspace_id, error) + + ! + ! Close the file. + ! + CALL h5fclose_f(file_id, error) + + ! + ! Close FORTRAN interface. + ! + CALL h5close_f(error) + +END PROGRAM H5_CRTDAT + + diff --git a/fortran/examples/groupexample.f90 b/fortran/examples/h5_crtgrp.f90 index 91ebc50..278d175 100644 --- a/fortran/examples/groupexample.f90 +++ b/fortran/examples/h5_crtgrp.f90 @@ -18,47 +18,47 @@ ! It creates a file called 'group.h5', creates a group ! called MyGroup in the root group, and then closes the group and file. ! +! This example is used in the HDF5 Tutorial. +PROGRAM H5_CRTGRP - PROGRAM GROUPEXAMPLE + USE HDF5 ! This module contains all necessary modules - USE HDF5 ! This module contains all necessary modules + IMPLICIT NONE - IMPLICIT NONE + CHARACTER(LEN=9), PARAMETER :: filename = "groupf.h5" ! File name + CHARACTER(LEN=7), PARAMETER :: groupname = "MyGroup" ! Group name - CHARACTER(LEN=9), PARAMETER :: filename = "groupf.h5" ! File name - CHARACTER(LEN=7), PARAMETER :: groupname = "MyGroup" ! Group name + INTEGER(HID_T) :: file_id ! File identifier + INTEGER(HID_T) :: group_id ! Group identifier - INTEGER(HID_T) :: file_id ! File identifier - INTEGER(HID_T) :: group_id ! Group identifier + INTEGER :: error ! Error flag + ! + ! Initialize FORTRAN interface. + ! + CALL h5open_f(error) + ! + ! Create a new file using default properties. + ! + CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error) - INTEGER :: error ! Error flag -! -! Initialize FORTRAN interface. -! - CALL h5open_f(error) - ! - ! Create a new file using default properties. - ! - CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error) - - ! - ! Create a group named "/MyGroup" in the file. - ! - CALL h5gcreate_f(file_id, groupname, group_id, error) + ! + ! Create a group named "/MyGroup" in the file. + ! + CALL h5gcreate_f(file_id, groupname, group_id, error) - ! - ! Close the group. - ! - CALL h5gclose_f(group_id, error) + ! + ! Close the group. + ! + CALL h5gclose_f(group_id, error) - ! - ! Terminate access to the file. - ! - CALL h5fclose_f(file_id, error) -! -! Close FORTRAN interface. -! - CALL h5close_f(error) + ! + ! Terminate access to the file. + ! + CALL h5fclose_f(file_id, error) + ! + ! Close FORTRAN interface. + ! + CALL h5close_f(error) - END PROGRAM GROUPEXAMPLE +END PROGRAM H5_CRTGRP diff --git a/fortran/examples/h5_crtgrpar.f90 b/fortran/examples/h5_crtgrpar.f90 new file mode 100644 index 0000000..4ef008a --- /dev/null +++ b/fortran/examples/h5_crtgrpar.f90 @@ -0,0 +1,83 @@ +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! Copyright by The HDF Group. * +! Copyright by the Board of Trustees of the University of Illinois. * +! All rights reserved. * +! * +! This file is part of HDF5. The full HDF5 copyright notice, including * +! terms governing use, modification, and redistribution, is contained in * +! the files COPYING and Copyright.html. COPYING can be found at the root * +! of the source code distribution tree; Copyright.html can be found at the * +! root level of an installed copy of the electronic HDF5 document set and * +! is linked from the top-level documents page. It can also be found at * +! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +! access to either file, you may request a copy from help@hdfgroup.org. * +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! +! +! The following example code shows how to create groups +! using absolute and relative names. It creates three groups: +! the first two groups are created using the file identifier and +! the group absolute names, and the third group is created using +! a group identifier and the name relative to the specified group. +! +! This example is used in the HDF5 Tutorial. + +PROGRAM H5_CRTGRPAR + + USE HDF5 ! This module contains all necessary modules + + IMPLICIT NONE + + CHARACTER(LEN=10), PARAMETER :: filename = "groupsf.h5" ! File name + CHARACTER(LEN=8), PARAMETER :: groupname1 = "/MyGroup" ! Group name + CHARACTER(LEN=16), PARAMETER :: groupname2 = "/MyGroup/Group_A" + ! Group name + CHARACTER(LEN=7), PARAMETER :: groupname3 = "Group_B" ! Group name + + INTEGER(HID_T) :: file_id ! File identifier + INTEGER(HID_T) :: group1_id, group2_id, group3_id ! Group identifiers + + INTEGER :: error ! Error flag + ! + ! Initialize FORTRAN interface. + ! + CALL h5open_f(error) + + ! + ! Create a new file using default properties. + ! + CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error) + + ! + ! Create group "MyGroup" in the root group using absolute name. + ! + CALL h5gcreate_f(file_id, groupname1, group1_id, error) + + ! + ! Create group "Group_A" in group "MyGroup" using absolute name. + ! + CALL h5gcreate_f(file_id, groupname2, group2_id, error) + + ! + ! Create group "Group_B" in group "MyGroup" using relative name. + ! + CALL h5gcreate_f(group1_id, groupname3, group3_id, error) + + ! + ! Close the groups. + ! + CALL h5gclose_f(group1_id, error) + CALL h5gclose_f(group2_id, error) + CALL h5gclose_f(group3_id, error) + + ! + ! Terminate access to the file. + ! + CALL h5fclose_f(file_id, error) + + ! + ! Close FORTRAN interface. + ! + CALL h5close_f(error) + +END PROGRAM H5_CRTGRPAR diff --git a/fortran/examples/h5_crtgrpd.f90 b/fortran/examples/h5_crtgrpd.f90 new file mode 100644 index 0000000..d35f03d --- /dev/null +++ b/fortran/examples/h5_crtgrpd.f90 @@ -0,0 +1,155 @@ +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! Copyright by The HDF Group. * +! Copyright by the Board of Trustees of the University of Illinois. * +! All rights reserved. * +! * +! This file is part of HDF5. The full HDF5 copyright notice, including * +! terms governing use, modification, and redistribution, is contained in * +! the files COPYING and Copyright.html. COPYING can be found at the root * +! of the source code distribution tree; Copyright.html can be found at the * +! root level of an installed copy of the electronic HDF5 document set and * +! is linked from the top-level documents page. It can also be found at * +! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +! access to either file, you may request a copy from help@hdfgroup.org. * +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! +! +! This example shows how to create a dataset in a particular group. +! It opens the file created in the previous example and creates two datasets. +! Absolute and relative dataset names are used. +! +! This example is used in the HDF5 Tutorial. + +PROGRAM H5_CRTGRPD + + USE HDF5 ! This module contains all necessary modules + + IMPLICIT NONE + + CHARACTER(LEN=10), PARAMETER :: filename = "groupsf.h5" ! File name + CHARACTER(LEN=15), PARAMETER :: groupname = "MyGroup/Group_A" ! Group name + CHARACTER(LEN=13), PARAMETER :: dsetname1 = "MyGroup/dset1" ! Dataset name + CHARACTER(LEN=5), PARAMETER :: dsetname2 = "dset2" ! dataset name + + INTEGER(HID_T) :: file_id ! File identifier + INTEGER(HID_T) :: group_id ! Group identifier + INTEGER(HID_T) :: dataset_id ! Dataset identifier + INTEGER(HID_T) :: dataspace_id ! Data space identifier + + INTEGER :: i, j + INTEGER :: error ! Error flag + + INTEGER, DIMENSION(3,3) :: dset1_data ! Data arrays + INTEGER, DIMENSION(2,10) :: dset2_data ! + + INTEGER(HSIZE_T), DIMENSION(2) :: dims1 = (/3,3/) ! Datasets dimensions + INTEGER(HSIZE_T), DIMENSION(2) :: dims2 = (/2,10/)! + INTEGER(HSIZE_T), DIMENSION(2) :: data_dims + + INTEGER :: rank = 2 ! Datasets rank + + ! + !Initialize dset1_data array + ! + DO i = 1, 3 + DO j = 1, 3 + dset1_data(i,j) = j; + END DO + END DO + + ! + !Initialize dset2_data array + ! + DO i = 1, 2 + DO j = 1, 10 + dset2_data(i,j) = j; + END DO + END DO + + ! + ! Initialize FORTRAN interface. + ! + CALL h5open_f(error) + + ! + ! Open an existing file. + ! + CALL h5fopen_f (filename, H5F_ACC_RDWR_F, file_id, error) + + ! + ! Create the data space for the first dataset. + ! + CALL h5screate_simple_f(rank, dims1, dataspace_id, error) + + ! + ! Create a dataset in group "MyGroup" with default properties. + ! + CALL h5dcreate_f(file_id, dsetname1, H5T_NATIVE_INTEGER, dataspace_id, & + dataset_id, error) + + ! + ! Write the first dataset. + ! + data_dims(1) = 3 + data_dims(2) = 3 + CALL h5dwrite_f(dataset_id, H5T_NATIVE_INTEGER, dset1_data, data_dims, error) + + ! + ! Close the dataspace for the first dataset. + ! + CALL h5sclose_f(dataspace_id, error) + + ! + ! Close the first dataset. + ! + CALL h5dclose_f(dataset_id, error) + + ! + ! Open an existing group in the specified file. + ! + CALL h5gopen_f(file_id, groupname, group_id, error) + + ! + !Create the data space for the second dataset. + ! + CALL h5screate_simple_f(rank, dims2, dataspace_id, error) + + ! + ! Create the second dataset in group "Group_A" with default properties. + ! + CALL h5dcreate_f(group_id, dsetname2, H5T_NATIVE_INTEGER, dataspace_id, & + dataset_id, error) + + ! + ! Write the second dataset. + ! + data_dims(1) = 2 + data_dims(1) = 10 + CALL h5dwrite_f(dataset_id, H5T_NATIVE_INTEGER, dset2_data, data_dims, error) + + ! + ! Close the dataspace for the second dataset. + ! + CALL h5sclose_f(dataspace_id, error) + + ! + ! Close the second dataset. + ! + CALL h5dclose_f(dataset_id, error) + + ! + ! Close the group. + ! + CALL h5gclose_f(group_id, error) + + ! + ! Close the file. + ! + CALL h5fclose_f(file_id, error) + + ! + ! Close FORTRAN interface. + ! + CALL h5close_f(error) + +END PROGRAM H5_CRTGRPD diff --git a/fortran/examples/h5_extend.f90 b/fortran/examples/h5_extend.f90 new file mode 100644 index 0000000..1316281 --- /dev/null +++ b/fortran/examples/h5_extend.f90 @@ -0,0 +1,233 @@ +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! Copyright by The HDF Group. * +! Copyright by the Board of Trustees of the University of Illinois. * +! All rights reserved. * +! * +! This file is part of HDF5. The full HDF5 copyright notice, including * +! terms governing use, modification, and redistribution, is contained in * +! the files COPYING and Copyright.html. COPYING can be found at the root * +! of the source code distribution tree; Copyright.html can be found at the * +! root level of an installed copy of the electronic HDF5 document set and * +! is linked from the top-level documents page. It can also be found at * +! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +! access to either file, you may request a copy from help@hdfgroup.org. * +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! +! This example extends an HDF5 dataset. It is used in the HDF5 Tutorial. + +PROGRAM H5_EXTEND + + USE HDF5 ! This module contains all necessary modules + + IMPLICIT NONE + + ! + !the dataset is stored in file "extend.h5" + ! + CHARACTER(LEN=9), PARAMETER :: filename = "extend.h5" + + ! + !dataset rank is 2 and name is "ExtendibleArray" + ! + CHARACTER(LEN=15), PARAMETER :: dsetname = "ExtendibleArray" + INTEGER :: RANK = 2 + + INTEGER(HID_T) :: file_id ! File identifier + INTEGER(HID_T) :: dset_id ! Dataset identifier + INTEGER(HID_T) :: dataspace ! Dataspace identifier + INTEGER(HID_T) :: memspace ! Memory dataspace identifier + INTEGER(HID_T) :: crp_list ! Dataset creation property identifier + + ! + !dataset dimensions at creation time + ! + INTEGER(HSIZE_T), DIMENSION(1:2) :: dims = (/3,3/) + + ! + !data dimensions + ! + INTEGER(HSIZE_T), DIMENSION(1:2) :: dimsc = (/2,5/) + INTEGER(HSIZE_T), DIMENSION(1:2) :: dimsm = (/3,7/) + + ! + !Maximum dimensions + ! + INTEGER(HSIZE_T), DIMENSION(1:2) :: maxdims + + INTEGER(HSIZE_T), DIMENSION(1:2) :: offset + INTEGER(HSIZE_T), DIMENSION(1:2) :: count + + ! + ! Variables for reading and writing + ! + INTEGER, DIMENSION(1:3,1:3) :: data1 + INTEGER, DIMENSION(1:21) :: data2 = & + (/2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4/) + INTEGER(HSIZE_T), DIMENSION(1:2) :: data_dims + + ! + !Size of data in the file + ! + INTEGER(HSIZE_T), DIMENSION(1:2) :: size + + ! + !general purpose integer + ! + INTEGER :: i, j + + ! + !flag to check operation success + ! + INTEGER :: error + + ! + !Variables used in reading data back + ! + INTEGER(HSIZE_T), DIMENSION(1:2) :: dimsr, maxdimsr + INTEGER :: rankr + INTEGER, DIMENSION(1:3,1:10) :: rdata + + ! + !Initialize FORTRAN predifined datatypes + ! + CALL h5open_f(error) + + ! + !Create a new file using default properties. + ! + CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error) + + ! + !Create the data space with unlimited dimensions. + ! + maxdims = (/H5S_UNLIMITED_F, H5S_UNLIMITED_F/) + + CALL h5screate_simple_f(RANK, dims, dataspace, error, maxdims) + + ! + !Modify dataset creation properties, i.e. enable chunking + ! + CALL h5pcreate_f(H5P_DATASET_CREATE_F, crp_list, error) + + CALL h5pset_chunk_f(crp_list, RANK, dimsc, error) + + ! + !Create a dataset with 3X3 dimensions using cparms creation propertie . + ! + CALL h5dcreate_f(file_id, dsetname, H5T_NATIVE_INTEGER, dataspace, & + dset_id, error, crp_list ) + CALL h5sclose_f(dataspace, error) + + ! + !Fill data array with 1's + ! + DO i = 1, dims(1) + DO j = 1, dims(2) + data1(i,j) = 1 + END DO + END DO + + ! + !Write data array to dataset + ! + data_dims(1:2) = (/3,3/) + CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, data1, data_dims, error) + + ! + !Extend the dataset. Dataset becomes 10 x 3. + ! + size(1:2) = (/3,10/) + CALL h5dset_extent_f(dset_id, size, error) + + offset(1:2) = (/0,3/) + count(1:2) = (/3,7/) + + CALL h5screate_simple_f (2, dimsm, memspace, error) + + ! + !Write to 3x7 extended part of dataset + ! + CALL h5dget_space_f(dset_id, dataspace, error) + CALL h5sselect_hyperslab_f(dataspace, H5S_SELECT_SET_F, & + offset, count, error) + + data_dims(1:2) = (/3,7/) + CALL H5dwrite_f(dset_id, H5T_NATIVE_INTEGER, data2, data_dims, error, & + memspace, dataspace) + + ! + !Close the objects that were opened. + ! + CALL h5sclose_f(dataspace, error) + CALL h5pclose_f(crp_list, error) + CALL h5dclose_f(dset_id, error) + CALL h5fclose_f(file_id, error) + + ! + !read the data back + ! + !Open the file. + ! + CALL h5fopen_f (filename, H5F_ACC_RDONLY_F, file_id, error) + + ! + !Open the dataset. + ! + CALL h5dopen_f(file_id, dsetname, dset_id, error) + + ! + !Get dataset's dataspace handle. + ! + CALL h5dget_space_f(dset_id, dataspace, error) + + ! + !Get dataspace's rank. + ! + CALL h5sget_simple_extent_ndims_f(dataspace, rankr, error) + + ! + !Get dataspace's dimensions. + ! + CALL h5sget_simple_extent_dims_f(dataspace, dimsr, maxdimsr, error) + + ! + !Get creation property list. + ! + CALL h5dget_create_plist_f(dset_id, crp_list, error) + + ! + ! Fill read buffer with zeroes + ! + rdata(1:dimsr(1),1:dimsr(2)) = 0 + + ! + !create memory dataspace + ! + CALL h5screate_simple_f(rankr, dimsr, memspace, error) + + ! + !Read data + ! + data_dims(1:2) = (/3,10/) + CALL H5dread_f(dset_id, H5T_NATIVE_INTEGER, rdata, data_dims, & + error, memspace, dataspace) + + WRITE(*,'(A)') "Dataset:" + DO i = 1, dimsr(1) + WRITE(*,'(100(I0,1X))') rdata(i,1:dimsr(2)) + END DO + + ! + !Close the objects that were opened. + ! + CALL h5sclose_f(dataspace, error) + CALL h5sclose_f(memspace, error) + CALL h5pclose_f(crp_list, error) + CALL h5dclose_f(dset_id, error) + CALL h5fclose_f(file_id, error) + + !Close FORTRAN predefined datatypes + ! + CALL h5close_f(error) + +END PROGRAM H5_EXTEND diff --git a/fortran/examples/h5_rdwt.f90 b/fortran/examples/h5_rdwt.f90 new file mode 100644 index 0000000..ba05b2f --- /dev/null +++ b/fortran/examples/h5_rdwt.f90 @@ -0,0 +1,96 @@ +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! Copyright by The HDF Group. * +! Copyright by the Board of Trustees of the University of Illinois. * +! All rights reserved. * +! * +! This file is part of HDF5. The full HDF5 copyright notice, including * +! terms governing use, modification, and redistribution, is contained in * +! the files COPYING and Copyright.html. COPYING can be found at the root * +! of the source code distribution tree; Copyright.html can be found at the * +! root level of an installed copy of the electronic HDF5 document set and * +! is linked from the top-level documents page. It can also be found at * +! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +! access to either file, you may request a copy from help@hdfgroup.org. * +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! +! +! The following example shows how to write and read to/from an existing dataset. +! It opens the file created in the previous example, obtains the dataset +! identifier, writes the data to the dataset in the file, +! then reads the dataset to memory. +! +! This example is used in the HDF5 Tutorial. + +PROGRAM H5_RDWT + + USE HDF5 ! This module contains all necessary modules + + IMPLICIT NONE + + CHARACTER(LEN=8), PARAMETER :: filename = "dsetf.h5" ! File name + CHARACTER(LEN=4), PARAMETER :: dsetname = "dset" ! Dataset name + + INTEGER(HID_T) :: file_id ! File identifier + INTEGER(HID_T) :: dset_id ! Dataset identifier + + INTEGER :: error ! Error flag + INTEGER :: i, j + + INTEGER, DIMENSION(4,6) :: dset_data, data_out ! Data buffers + INTEGER(HSIZE_T), DIMENSION(2) :: data_dims + + ! + ! Initialize the dset_data array. + ! + DO i = 1, 4 + DO j = 1, 6 + dset_data(i,j) = (i-1)*6 + j + END DO + END DO + + ! + ! Initialize FORTRAN interface. + ! + CALL h5open_f(error) + + ! + ! Open an existing file. + ! + CALL h5fopen_f (filename, H5F_ACC_RDWR_F, file_id, error) + + ! + ! Open an existing dataset. + ! + CALL h5dopen_f(file_id, dsetname, dset_id, error) + + ! + ! Write the dataset. + ! + data_dims(1) = 4 + data_dims(2) = 6 + CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, dset_data, data_dims, error) + + ! + ! Read the dataset. + ! + CALL h5dread_f(dset_id, H5T_NATIVE_INTEGER, data_out, data_dims, error) + + ! + ! Close the dataset. + ! + CALL h5dclose_f(dset_id, error) + + ! + ! Close the file. + ! + CALL h5fclose_f(file_id, error) + + ! + ! Close FORTRAN interface. + ! + CALL h5close_f(error) + +END PROGRAM H5_RDWT + + + diff --git a/fortran/examples/h5_subset.f90 b/fortran/examples/h5_subset.f90 new file mode 100644 index 0000000..6cb8f7a --- /dev/null +++ b/fortran/examples/h5_subset.f90 @@ -0,0 +1,184 @@ +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! Copyright by The HDF Group. * +! Copyright by the Board of Trustees of the University of Illinois. * +! All rights reserved. * +! * +! This file is part of HDF5. The full HDF5 copyright notice, including * +! terms governing use, modification, and redistribution, is contained in * +! the files COPYING and Copyright.html. COPYING can be found at the root * +! of the source code distribution tree; Copyright.html can be found at the * +! root level of an installed copy of the electronic HDF5 document set and * +! is linked from the top-level documents page. It can also be found at * +! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +! access to either file, you may request a copy from help@hdfgroup.org. * +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! +! This example shows how to write and read a hyperslab. +! It is used in the HDF5 Tutorial. +! + +PROGRAM H5_SUBSET + + USE HDF5 ! This module contains all necessary modules + + IMPLICIT NONE + + CHARACTER(LEN=9), PARAMETER :: filename = "subset.h5" ! File name + CHARACTER(LEN=8), PARAMETER :: dsetname = "IntArray" ! Dataset name + + INTEGER(HID_T) :: file_id ! File identifier + INTEGER(HID_T) :: dset_id ! Dataset identifier + INTEGER(HID_T) :: dataspace ! Dataspace identifier + INTEGER(HID_T) :: memspace ! memspace identifier + + ! + ! To change the subset size, modify size of dimsm, sdata, dim0_sub, + ! dim1_sub, and count + ! + INTEGER(HSIZE_T), DIMENSION(1:2) :: dimsm = (/4,3/) ! Dataset dimensions + INTEGER, DIMENSION(1:4,1:3) :: sdata ! Subset buffer + INTEGER :: dim0_sub = 4 + INTEGER :: dim1_sub = 3 + INTEGER(HSIZE_T), DIMENSION(1:2) :: count = (/4,3/) ! Size of hyperslab + INTEGER(HSIZE_T), DIMENSION(1:2) :: offset = (/2,1/) ! Hyperslab offset + INTEGER(HSIZE_T), DIMENSION(1:2) :: stride = (/1,1/) ! Hyperslab stride + INTEGER(HSIZE_T), DIMENSION(1:2) :: block = (/1,1/) ! Hyperslab block size + + INTEGER(HSIZE_T), DIMENSION(1:2) :: dimsf = (/10,8/) ! Dataset dimensions + + + INTEGER, DIMENSION(1:10,1:8) :: data ! Data to write + INTEGER, DIMENSION(1:10,1:8) :: rdata ! Data to read + + INTEGER :: rank = 2 ! Dataset rank ( in file ) + INTEGER :: dim0 = 10 ! Dataset size in file + INTEGER :: dim1 = 8 + + INTEGER :: i, j + + INTEGER :: error ! Error flag + INTEGER(HSIZE_T), DIMENSION(2) :: data_dims + + ! + ! Write data to the HDF5 file. + ! + + ! + ! Data initialization. + ! + DO i = 1, dim0 + DO j = 1, dim1 + IF (i .LE. (dim0 / 2)) THEN + data(i,j) = 1 + ELSE + data(i,j) = 2 + END IF + END DO + END DO + + ! + ! Initialize FORTRAN interface. + ! + CALL h5open_f(error) + + ! + ! Create a new file using default properties. + ! + CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error) + + ! + ! Create the data space for the dataset. + ! + CALL h5screate_simple_f(rank, dimsf, dataspace, error) + + ! + ! Create the dataset with default properties. + ! + CALL h5dcreate_f(file_id, dsetname, H5T_NATIVE_INTEGER, dataspace, & + dset_id, error) + + ! + ! Write the dataset. + ! + data_dims(1) = dim0 + data_dims(2) = dim1 + CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, data, data_dims, error) + + ! + ! Data Written to File + ! + WRITE(*,'(/,A)') "Original Data Written to File:" + DO i = 1, dim0 + WRITE(*,'(100(1X,I0,1X))') DATA(i,1:dim1) + END DO + + ! + ! + ! Close the dataspace, dataset, and file. + ! + CALL h5sclose_f(dataspace, error) + CALL h5dclose_f(dset_id, error) + CALL h5fclose_f(file_id, error) + + ! + ! Initialize subset data array. + ! + sdata(1:dim0_sub,1:dim1_sub) = 5 + + ! + ! Open the file. + ! + CALL h5fopen_f(filename, H5F_ACC_RDWR_F, file_id, error) + + ! + ! Open the dataset. + ! + CALL h5dopen_f(file_id, dsetname, dset_id, error) + + ! + ! Get dataset's dataspace identifier and select subset. + ! + CALL h5dget_space_f(dset_id, dataspace, error) + CALL h5sselect_hyperslab_f(dataspace, H5S_SELECT_SET_F, & + offset, count, error, stride, BLOCK) + ! + ! Create memory dataspace. + ! + CALL h5screate_simple_f(rank, dimsm, memspace, error) + + WRITE(*,'(/,A)') "Write subset to file specifying:" + WRITE(*,'(A,/)') " offset=2x1 stride=1x1 count=4x3 block=1x1" + + ! + ! Write subset to dataset + ! + data_dims(1:2) = (/dim0_sub, dim1_sub/) + CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, sdata, data_dims, error, & + memspace, dataspace) + + data_dims(1:2) = (/dim0, dim1/) + CALL h5dread_f(dset_id, H5T_NATIVE_INTEGER, rdata, data_dims, error) + + ! + ! Read entire dataset back + ! + WRITE(*,'(A)') "Data in File after Subset Written:" + DO i = 1, dim0 + WRITE(*,'(100(1X,I0,1X))') rdata(i,1:dim1) + END DO + PRINT *, " " + + ! + ! Close everything opened. + ! + CALL h5sclose_f(dataspace, error) + CALL h5sclose_f(memspace, error) + CALL h5dclose_f(dset_id, error) + CALL h5fclose_f(file_id, error) + + ! + ! Close FORTRAN interface. + ! + CALL h5close_f(error) + +END PROGRAM H5_SUBSET diff --git a/fortran/examples/run-fortran-ex.sh.in b/fortran/examples/run-fortran-ex.sh.in index 873669f..c5c379e 100644 --- a/fortran/examples/run-fortran-ex.sh.in +++ b/fortran/examples/run-fortran-ex.sh.in @@ -70,20 +70,24 @@ RunTest() # Run tests if [ $? -eq 0 ] then - if (RunTest dsetexample &&\ - rm dsetexample &&\ - RunTest fileexample &&\ - rm fileexample &&\ - RunTest rwdsetexample &&\ - rm rwdsetexample &&\ - RunTest attrexample &&\ - rm attrexample &&\ - RunTest groupexample &&\ - rm groupexample &&\ - RunTest grpsexample &&\ - rm grpsexample &&\ - RunTest grpdsetexample &&\ - rm grpdsetexample &&\ + if (RunTest h5_cmprss &&\ + rm h5_cmprss &&\ + RunTest h5_crtdat &&\ + rm h5_crtdat &&\ + RunTest h5_extend &&\ + rm h5_extend &&\ + RunTest h5_rdwt &&\ + rm h5_rdwt &&\ + RunTest h5_crtatt &&\ + rm h5_crtatt &&\ + RunTest h5_crtgrp &&\ + rm h5_crtgrp &&\ + RunTest h5_crtgrpar &&\ + rm h5_crtgrpar &&\ + RunTest h5_crtgrpd &&\ + rm h5_crtgrpd &&\ + RunTest h5_subset &&\ + rm h5_subset &&\ RunTest hyperslab &&\ rm hyperslab &&\ RunTest selectele &&\ diff --git a/fortran/examples/rwdsetexample.f90 b/fortran/examples/rwdsetexample.f90 deleted file mode 100644 index 1e84e23..0000000 --- a/fortran/examples/rwdsetexample.f90 +++ /dev/null @@ -1,96 +0,0 @@ -! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -! Copyright by The HDF Group. * -! Copyright by the Board of Trustees of the University of Illinois. * -! All rights reserved. * -! * -! This file is part of HDF5. The full HDF5 copyright notice, including * -! terms governing use, modification, and redistribution, is contained in * -! the files COPYING and Copyright.html. COPYING can be found at the root * -! of the source code distribution tree; Copyright.html can be found at the * -! root level of an installed copy of the electronic HDF5 document set and * -! is linked from the top-level documents page. It can also be found at * -! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * -! access to either file, you may request a copy from help@hdfgroup.org. * -! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -! -! -! The following example shows how to write and read to/from an existing dataset. -! It opens the file created in the previous example, obtains the dataset -! identifier, writes the data to the dataset in the file, -! then reads the dataset to memory. -! - - - PROGRAM RWDSETEXAMPLE - - USE HDF5 ! This module contains all necessary modules - - IMPLICIT NONE - - CHARACTER(LEN=8), PARAMETER :: filename = "dsetf.h5" ! File name - CHARACTER(LEN=4), PARAMETER :: dsetname = "dset" ! Dataset name - - INTEGER(HID_T) :: file_id ! File identifier - INTEGER(HID_T) :: dset_id ! Dataset identifier - - INTEGER :: error ! Error flag - INTEGER :: i, j - - INTEGER, DIMENSION(4,6) :: dset_data, data_out ! Data buffers - INTEGER(HSIZE_T), DIMENSION(2) :: data_dims - - ! - ! Initialize the dset_data array. - ! - do i = 1, 4 - do j = 1, 6 - dset_data(i,j) = (i-1)*6 + j; - end do - end do - - ! - ! Initialize FORTRAN interface. - ! - CALL h5open_f(error) - - ! - ! Open an existing file. - ! - CALL h5fopen_f (filename, H5F_ACC_RDWR_F, file_id, error) - - ! - ! Open an existing dataset. - ! - CALL h5dopen_f(file_id, dsetname, dset_id, error) - - ! - ! Write the dataset. - ! - data_dims(1) = 4 - data_dims(2) = 6 - CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, dset_data, data_dims, error) - - ! - ! Read the dataset. - ! - CALL h5dread_f(dset_id, H5T_NATIVE_INTEGER, data_out, data_dims, error) - - ! - ! Close the dataset. - ! - CALL h5dclose_f(dset_id, error) - - ! - ! Close the file. - ! - CALL h5fclose_f(file_id, error) - - ! - ! Close FORTRAN interface. - ! - CALL h5close_f(error) - - END PROGRAM RWDSETEXAMPLE - - - diff --git a/fortran/src/H5test_kind_SIZEOF.f90 b/fortran/src/H5test_kind_SIZEOF.f90 index ba982ee..867ec1e 100644 --- a/fortran/src/H5test_kind_SIZEOF.f90 +++ b/fortran/src/H5test_kind_SIZEOF.f90 @@ -15,7 +15,9 @@ ! NOTES ! This program is used in place of H5test_kind.f90 when the Fortran intrinsic ! function SIZEOF is available. It generates code that makes use of SIZEOF in -! H5fortran_detect.f90 which is a portable solution. +! H5fortran_detect.f90 which is a portable solution but is not standard +! compliant. The program H5test_kind_C_SIZEOF uses F2008 standard intrinsic +! function instead, which is the preferred method. ! ! The availability of SIZEOF is checked at configure time and the TRUE/FALSE ! condition is set in the configure variable "FORTRAN_HAVE_SIZEOF". diff --git a/fortran/src/Makefile.in b/fortran/src/Makefile.in index ced33d9..d9df257 100644 --- a/fortran/src/Makefile.in +++ b/fortran/src/Makefile.in @@ -517,7 +517,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 126 +LT_VERS_REVISION = 130 LT_VERS_AGE = 0 # Include src directory in both Fortran and C flags (C compiler is used diff --git a/hl/c++/examples/CMakeLists.txt b/hl/c++/examples/CMakeLists.txt index 3034a78..bba06e9 100644 --- a/hl/c++/examples/CMakeLists.txt +++ b/hl/c++/examples/CMakeLists.txt @@ -20,17 +20,6 @@ TARGET_LINK_LIBRARIES ( ) SET_TARGET_PROPERTIES (ptExampleFL PROPERTIES FOLDER examples/hl/cpp) -ADD_EXECUTABLE (ptExampleVL ${HDF5_HL_CPP_EXAMPLES_SOURCE_DIR}/ptExampleVL.cpp) -TARGET_NAMING (ptExampleVL ${LIB_TYPE}) -TARGET_LINK_LIBRARIES ( - ptExampleVL - ${HDF5_HL_CPP_LIB_TARGET} - ${HDF5_HL_LIB_TARGET} - ${HDF5_LIB_TARGET} -) -SET_TARGET_PROPERTIES (ptExampleVL PROPERTIES FOLDER examples/hl/cpp) - IF (BUILD_TESTING) ADD_TEST (NAME cpp_hl_ex_ptExampleFL COMMAND $<TARGET_FILE:ptExampleFL>) - ADD_TEST (NAME cpp_hl_ex_ptExampleVL COMMAND $<TARGET_FILE:ptExampleVL>) ENDIF (BUILD_TESTING) diff --git a/hl/c++/examples/Makefile.am b/hl/c++/examples/Makefile.am index 5dd5a75..df15257 100644 --- a/hl/c++/examples/Makefile.am +++ b/hl/c++/examples/Makefile.am @@ -23,10 +23,10 @@ include $(top_srcdir)/config/commence.am # These are the programs that 'make all' or 'make prog' will build and # which 'make check' will run. List them in the order they should be run. -EXAMPLE_PROG=ptExampleFL ptExampleVL +EXAMPLE_PROG=ptExampleFL # These are the example files to be installed -INSTALL_FILES=ptExampleFL.cpp ptExampleVL.cpp +INSTALL_FILES=ptExampleFL.cpp INSTALL_SCRIPT_FILES = run-hlc++-ex.sh # Tell conclude.am that these are C++ tests. @@ -45,7 +45,6 @@ $(EXTRA_PROG): $(H5CPP) # will try to build them with the normal C++ compiler, not h5c++. This is # an inelegant way of solving the problem, unfortunately. ptExampleFL: ptExampleFL.cpp -ptExampleVL: ptExampleVL.cpp include $(top_srcdir)/config/examples.am include $(top_srcdir)/config/conclude.am diff --git a/hl/c++/examples/Makefile.in b/hl/c++/examples/Makefile.in index bd0edf0..f617fec 100644 --- a/hl/c++/examples/Makefile.in +++ b/hl/c++/examples/Makefile.in @@ -390,10 +390,10 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.h5 # These are the programs that 'make all' or 'make prog' will build and # which 'make check' will run. List them in the order they should be run. -EXAMPLE_PROG = ptExampleFL ptExampleVL +EXAMPLE_PROG = ptExampleFL # These are the example files to be installed -INSTALL_FILES = ptExampleFL.cpp ptExampleVL.cpp +INSTALL_FILES = ptExampleFL.cpp INSTALL_SCRIPT_FILES = run-hlc++-ex.sh # Tell conclude.am that these are C++ tests. @@ -651,7 +651,6 @@ $(EXTRA_PROG): $(H5CPP) # will try to build them with the normal C++ compiler, not h5c++. This is # an inelegant way of solving the problem, unfortunately. ptExampleFL: ptExampleFL.cpp -ptExampleVL: ptExampleVL.cpp # How to create EXAMPLEDIR if it doesn't already exist $(EXAMPLEDIR): diff --git a/hl/c++/examples/ptExampleVL.cpp b/hl/c++/examples/ptExampleVL.cpp deleted file mode 100644 index c3feccd..0000000 --- a/hl/c++/examples/ptExampleVL.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include "H5PacketTable.h" - -/*------------------------------------------------------------------------- - * Packet Table Variable-Length Example - * - * Example program that creates a packet table and performs - * writes and reads. - * - *------------------------------------------------------------------------- - */ - -int main(void) -{ -#ifdef VLPT_REMOVED - herr_t err; /* Return value from function calls */ - hid_t fileID; /* HDF5 identifier for file */ - hsize_t count; /* Number of records in table */ - int x; /* Loop variable */ - - /* This example has two different sizes of "record": longs and shorts */ - long longBuffer[5]; - short shortBuffer[5]; - - /* Buffer of hvl_t structs to read back records */ - hvl_t readBuffer[5]; - - /* Initialize buffers */ - for(x=0; x<5; x++) - { - longBuffer[x] = -x; - shortBuffer[x] = x; - } - - /* Create a new HDF5 file */ - fileID = H5Fcreate("PTcppexampleVL.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if(fileID <0) - fprintf(stderr, "Couldn't create file.\n"); - - /* Create a variable-length packet table. */ - VL_PacketTable ptable(fileID, "/examplePacketTable", 1); - - if(! ptable.IsValid()) - fprintf(stderr, "Unable to create packet table."); - - /* Append five packets to the packet table. */ - /* In C++, there is no need to package data into hvl_t structs. */ - err = ptable.AppendPacket( &(longBuffer[0]), sizeof(long)); - if(err < 0) - fprintf(stderr, "Error adding record."); - err = ptable.AppendPacket( &(shortBuffer[1]), sizeof(short)); - if(err < 0) - fprintf(stderr, "Error adding record."); - err = ptable.AppendPacket( &(longBuffer[2]), sizeof(long)); - if(err < 0) - fprintf(stderr, "Error adding record."); - err = ptable.AppendPacket( &(longBuffer[3]), sizeof(long)); - if(err < 0) - fprintf(stderr, "Error adding record."); - err = ptable.AppendPacket( &(shortBuffer[4]), sizeof(short)); - if(err < 0) - fprintf(stderr, "Error adding record."); - - /* Get the number of packets in the packet table. This should be five. */ - count = ptable.GetPacketCount(err); - if(err < 0) - fprintf(stderr, "Error getting packet count."); - - printf("Number of packets in packet table after five appends: %d\n", count); - - /* Initialize packet table's "current record" */ - ptable.ResetIndex(); - - /* Iterate through packets, read each one back */ - for(x=0; x<5; x++) - { - err = ptable.GetNextPacket( &(readBuffer[x]) ); - if(err < 0) - fprintf(stderr, "Error reading record."); - - printf("Packet %d's length is %d.\n", x, readBuffer[x].len); - if(readBuffer[x].len == sizeof(long)) - printf("Packet %d's value is %d.\n", x, *((long *) readBuffer[x].p) ); - else - printf("Packet %d's value is %d.\n", x, *((short *) readBuffer[x].p) ); - } - - /* The packet table will close automatically when its object goes */ - /* out of scope. */ - - err = H5Fclose(fileID); - if( err < 0 ) - fprintf(stderr, "Failed to close file.\n"); - -#endif /* VLPT_REMOVED */ - return 0; -} - diff --git a/hl/c++/examples/run-hlc++-ex.sh.in b/hl/c++/examples/run-hlc++-ex.sh.in index 7742f99..103dd76 100644 --- a/hl/c++/examples/run-hlc++-ex.sh.in +++ b/hl/c++/examples/run-hlc++-ex.sh.in @@ -64,9 +64,7 @@ RunTest() if [ $? -eq 0 ] then if (RunTest ptExampleFL &&\ - rm ptExampleFL &&\ - RunTest ptExampleVL &&\ - rm ptExampleVL); then + rm ptExampleFL); then EXIT_VALUE=${EXIT_SUCCESS} else EXIT_VALUE=${EXIT_FAILURE} diff --git a/hl/c++/src/Makefile.in b/hl/c++/src/Makefile.in index 4dceeb2..fef6449 100644 --- a/hl/c++/src/Makefile.in +++ b/hl/c++/src/Makefile.in @@ -458,7 +458,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 126 +LT_VERS_REVISION = 130 LT_VERS_AGE = 0 # Include src directory diff --git a/hl/examples/CMakeLists.txt b/hl/examples/CMakeLists.txt index c95322c..f9c8922 100644 --- a/hl/examples/CMakeLists.txt +++ b/hl/examples/CMakeLists.txt @@ -23,7 +23,6 @@ SET (examples ex_lite2 ex_lite3 ptExampleFL - ptExampleVL ex_image1 ex_image2 ex_table_01 diff --git a/hl/examples/Makefile.am b/hl/examples/Makefile.am index 1c51f05..5108c5e 100644 --- a/hl/examples/Makefile.am +++ b/hl/examples/Makefile.am @@ -34,7 +34,7 @@ EXAMPLETOPDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples/hl # Don't tell automake about them, because if it knew they were programs, # it would try to compile them instead of using the h5cc script. # Use the boilerplate in config/examples.am instead. -EXAMPLE_PROG = ex_lite1 ex_lite2 ex_lite3 ptExampleFL ptExampleVL \ +EXAMPLE_PROG = ex_lite1 ex_lite2 ex_lite3 ptExampleFL \ ex_image1 ex_image2 \ ex_table_01 ex_table_02 ex_table_03 ex_table_04 \ ex_table_05 ex_table_06 ex_table_07 ex_table_08 \ @@ -43,7 +43,7 @@ EXAMPLE_PROG = ex_lite1 ex_lite2 ex_lite3 ptExampleFL ptExampleVL \ # Install files # List all file that should be installed in examples directory -INSTALL_FILES = ex_lite1.c ex_lite2.c ex_lite3.c ptExampleFL.c ptExampleVL.c \ +INSTALL_FILES = ex_lite1.c ex_lite2.c ex_lite3.c ptExampleFL.c \ ex_image1.c ex_image2.c \ ex_table_01.c ex_table_02.c ex_table_03.c ex_table_04.c \ ex_table_05.c ex_table_06.c ex_table_07.c ex_table_08.c \ @@ -75,7 +75,6 @@ ex_lite1: $(srcdir)/ex_lite1.c ex_lite2: $(srcdir)/ex_lite2.c ex_lite3: $(srcdir)/ex_lite3.c ptExampleFL: $(srcdir)/ptExampleFL.c -ptExampleVL: $(srcdir)/ptExampleVL.c ex_image1: $(srcdir)/ex_image1.c ex_image2: $(srcdir)/ex_image2.c ex_table01: $(srcdir)/ex_table01.c diff --git a/hl/examples/Makefile.in b/hl/examples/Makefile.in index 1794e38..f6126d4 100644 --- a/hl/examples/Makefile.in +++ b/hl/examples/Makefile.in @@ -398,7 +398,7 @@ EXAMPLETOPDIR = ${DESTDIR}$(exec_prefix)/share/hdf5_examples/hl # Don't tell automake about them, because if it knew they were programs, # it would try to compile them instead of using the h5cc script. # Use the boilerplate in config/examples.am instead. -EXAMPLE_PROG = ex_lite1 ex_lite2 ex_lite3 ptExampleFL ptExampleVL \ +EXAMPLE_PROG = ex_lite1 ex_lite2 ex_lite3 ptExampleFL \ ex_image1 ex_image2 \ ex_table_01 ex_table_02 ex_table_03 ex_table_04 \ ex_table_05 ex_table_06 ex_table_07 ex_table_08 \ @@ -408,7 +408,7 @@ EXAMPLE_PROG = ex_lite1 ex_lite2 ex_lite3 ptExampleFL ptExampleVL \ # Install files # List all file that should be installed in examples directory -INSTALL_FILES = ex_lite1.c ex_lite2.c ex_lite3.c ptExampleFL.c ptExampleVL.c \ +INSTALL_FILES = ex_lite1.c ex_lite2.c ex_lite3.c ptExampleFL.c \ ex_image1.c ex_image2.c \ ex_table_01.c ex_table_02.c ex_table_03.c ex_table_04.c \ ex_table_05.c ex_table_06.c ex_table_07.c ex_table_08.c \ @@ -677,7 +677,6 @@ ex_lite1: $(srcdir)/ex_lite1.c ex_lite2: $(srcdir)/ex_lite2.c ex_lite3: $(srcdir)/ex_lite3.c ptExampleFL: $(srcdir)/ptExampleFL.c -ptExampleVL: $(srcdir)/ptExampleVL.c ex_image1: $(srcdir)/ex_image1.c ex_image2: $(srcdir)/ex_image2.c ex_table01: $(srcdir)/ex_table01.c diff --git a/hl/examples/ptExampleVL.c b/hl/examples/ptExampleVL.c deleted file mode 100644 index 310aa07..0000000 --- a/hl/examples/ptExampleVL.c +++ /dev/null @@ -1,126 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include "hdf5.h" -#include "hdf5_hl.h" -#include <stdlib.h> - -/*------------------------------------------------------------------------- - * Packet Table Variable-Length Example - * - * Example program that creates a variable-length packet table and performs - * writes and reads. - * - *------------------------------------------------------------------------- - */ - -int main(void) -{ -#ifdef VLPT_REMOVED - hid_t fid; /* File identifier */ - hid_t ptable; /* Packet table identifier */ - - herr_t err; /* Function return status */ - hsize_t count; /* Number of records in the table */ - int x; /* Loop variable */ - - /* Buffers to hold data */ - hvl_t writeBuffer[5]; - hvl_t readBuffer[5]; - - /* This example has two different sizes of "record": longs and shorts */ - long longBuffer[5]; - short shortBuffer[5]; - - /* Initialize buffers */ - for(x=0; x<5; x++) - { - longBuffer[x] = -x; - shortBuffer[x] = x; - } - - /* Fill the write buffer with a mix of longs and shorts */ - /* We need to supply the length of each record and a pointer to */ - /* the beginning of each record. */ - writeBuffer[0].len = sizeof(long); - writeBuffer[0].p = &(longBuffer[0]); - writeBuffer[1].len = sizeof(short); - writeBuffer[1].p = &(shortBuffer[1]); - writeBuffer[2].len = sizeof(long); - writeBuffer[2].p = &(longBuffer[2]); - writeBuffer[3].len = sizeof(long); - writeBuffer[3].p = &(longBuffer[3]); - writeBuffer[4].len = sizeof(short); - writeBuffer[4].p = &(shortBuffer[4]); - - /* Create a file using default properties */ - fid=H5Fcreate("packet_table_VLexample.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT); - - /* Create a variable-length packet table within the file */ - ptable = H5PTcreate_vl(fid, "Packet Test Dataset", (hsize_t)1); - if(ptable == H5I_INVALID_HID) - goto out; - - /* Write the entire buffer to the packet table */ - err = H5PTappend(ptable, (hsize_t)5, writeBuffer ); - if(err < 0) - goto out; - - /* Get the number of packets in the packet table. This should be five. */ - err = H5PTget_num_packets(ptable, &count); - if(err < 0) - goto out; - - printf("Number of packets in packet table after five appends: %d\n", count); - - /* Read all five packets back */ - err = H5PTread_packets(ptable, (hsize_t)0, (hsize_t)5, readBuffer ); - if(err < 0) - goto out; - - for(x=0; x<5; x++) - { - printf("Packet %d's length is %d\n", x, readBuffer[x].len); - if(readBuffer[x].len == sizeof(long)) - printf("Packet %d's value is %d\n", x, *( (long *) readBuffer[x].p) ); - else - printf("Packet %d's value is %d\n", x, *( (short *) readBuffer[x].p) ); - } - - /* Before we close the packet table, we must free the memory that */ - /* the pointers in readBuffer point to. */ - err = H5PTfree_vlen_readbuff(ptable, (hsize_t)5, readBuffer); - if(err < 0) - goto out; - - /* Close the packet table */ - err = H5PTclose(ptable); - if(err < 0) - goto out; - - /* Close the file */ - H5Fclose(fid); -#endif /* VLPT_REMOVED */ - - return 0; - -#ifdef VLPT_REMOVED - out: /* An error has occurred. Clean up and exit. */ - fprintf(stderr, "An error has occurred!\n"); - H5PTclose(ptable); - H5Fclose(fid); - return -1; -#endif /* VLPT_REMOVED */ -} diff --git a/hl/examples/run-hlc-ex.sh.in b/hl/examples/run-hlc-ex.sh.in index a82e591..a79f67a 100644 --- a/hl/examples/run-hlc-ex.sh.in +++ b/hl/examples/run-hlc-ex.sh.in @@ -76,8 +76,6 @@ then rm ex_lite3 &&\ RunTest ptExampleFL &&\ rm ptExampleFL &&\ - RunTest ptExampleVL &&\ - rm ptExampleVL &&\ RunTest ex_image1 &&\ rm ex_image1 &&\ RunTest ex_image2 &&\ diff --git a/hl/fortran/src/Makefile.in b/hl/fortran/src/Makefile.in index 3cd2b38..85faf98 100644 --- a/hl/fortran/src/Makefile.in +++ b/hl/fortran/src/Makefile.in @@ -474,7 +474,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 126 +LT_VERS_REVISION = 130 LT_VERS_AGE = 0 INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/hl/src -I$(top_builddir)/hl/src \ -I$(top_srcdir)/fortran/src -I$(top_builddir)/fortran/src diff --git a/hl/src/Makefile.in b/hl/src/Makefile.in index 84ff1ef..1be8e50 100644 --- a/hl/src/Makefile.in +++ b/hl/src/Makefile.in @@ -457,7 +457,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 126 +LT_VERS_REVISION = 130 LT_VERS_AGE = 0 # This library is our main target. diff --git a/hl/test/CMakeLists.txt b/hl/test/CMakeLists.txt index b22d99e..a85d271 100644 --- a/hl/test/CMakeLists.txt +++ b/hl/test/CMakeLists.txt @@ -81,7 +81,7 @@ HL_ADD_TEST (test_dset_opt "") HL_ADD_TEST (test_image "image8.txt;sepia.pal;earth.pal;image24pixel.txt;image24plane.txt;usa.wri") HL_ADD_TEST (test_lite "dtype_file.txt") HL_ADD_TEST (test_packet "") -HL_ADD_TEST (test_table "test_table_be.hdf5;test_table_cray.hdf5;test_table_le.hdf5") +HL_ADD_TEST (test_table "test_table_be.h5;test_table_cray.h5;test_table_le.h5") # -------------------------------------------------------------------- # This executable is used to generate test files for the test_ds test. diff --git a/hl/test/test_table.c b/hl/test/test_table.c index cdae768..488cbe2 100644 --- a/hl/test/test_table.c +++ b/hl/test/test_table.c @@ -19,9 +19,9 @@ #include "H5srcdir.h" #include "H5TBpublic.h" -#define TEST_FILE_BE "test_table_be.hdf5" -#define TEST_FILE_LE "test_table_le.hdf5" -#define TEST_FILE_CRAY "test_table_cray.hdf5" +#define TEST_FILE_BE "test_table_be.h5" +#define TEST_FILE_LE "test_table_le.h5" +#define TEST_FILE_CRAY "test_table_cray.h5" /*------------------------------------------------------------------------- diff --git a/hl/test/test_table_be.hdf5 b/hl/test/test_table_be.h5 Binary files differindex 3639695..3639695 100644 --- a/hl/test/test_table_be.hdf5 +++ b/hl/test/test_table_be.h5 diff --git a/hl/test/test_table_cray.hdf5 b/hl/test/test_table_cray.h5 Binary files differindex d22dce3..d22dce3 100644 --- a/hl/test/test_table_cray.hdf5 +++ b/hl/test/test_table_cray.h5 diff --git a/hl/test/test_table_le.hdf5 b/hl/test/test_table_le.h5 Binary files differindex 6c330fd..6c330fd 100644 --- a/hl/test/test_table_le.hdf5 +++ b/hl/test/test_table_le.h5 diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index a2b226a..a5138ee 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -1,4 +1,4 @@ -HDF5 version 1.9.136 currently under development +HDF5 version 1.9.140 currently under development ================================================================================ diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 07f4551..03cc15e 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -17,57 +17,40 @@ * Programmer: Robb Matzke <matzke@llnl.gov> * Tuesday, August 10, 1999 * - * Purpose: A driver which stores the HDF5 data in main memory using - * only the HDF5 public API. This driver is useful for fast - * access to small, temporary hdf5 files. + * Purpose: A driver which stores the HDF5 data in main memory using + * only the HDF5 public API. This driver is useful for fast + * access to small, temporary hdf5 files. */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5FD_core_init_interface -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDcore.h" /* Core file driver */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDcore.h" /* Core file driver */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_CORE_g = 0; -/* Since Windows doesn't follow the rest of the world when it comes - * to POSIX I/O types, some typedefs and constants are needed to avoid - * making the code messy with #ifdefs. - * NOTE: These are only used when writing data to the backing store on - * file close. - */ -#ifdef H5_HAVE_WIN32_API -typedef unsigned int h5_core_io_t; -typedef int h5_core_io_ret_t; -static int H5_CORE_MAX_IO_BYTES_g = INT_MAX; -#else -/* Unix, everyone else */ -typedef size_t h5_core_io_t; -typedef ssize_t h5_core_io_ret_t; -static size_t H5_CORE_MAX_IO_BYTES_g = SSIZET_MAX; -#endif /* H5_HAVE_WIN32_API */ - -/* The description of a file belonging to this driver. The `eoa' and `eof' +/* The description of a file belonging to this driver. The 'eoa' and 'eof' * determine the amount of hdf5 address space in use and the high-water mark * of the file (the current size of the underlying memory). */ typedef struct H5FD_core_t { - H5FD_t pub; /*public stuff, must be first */ - char *name; /*for equivalence testing */ - unsigned char *mem; /*the underlying memory */ - haddr_t eoa; /*end of allocated region */ - haddr_t eof; /*current allocated size */ - size_t increment; /*multiples for mem allocation */ - hbool_t backing_store; /*write to file name on flush */ - int fd; /*backing store file descriptor */ + H5FD_t pub; /* public stuff, must be first */ + char *name; /* for equivalence testing */ + unsigned char *mem; /* the underlying memory */ + haddr_t eoa; /* end of allocated region */ + haddr_t eof; /* current allocated size */ + size_t increment; /* multiples for mem allocation */ + hbool_t backing_store; /* write to file name on flush */ + int fd; /* backing store file descriptor */ /* Information for determining uniqueness of a file with a backing store */ #ifndef H5_HAVE_WIN32_API /* On most systems the combination of device and i-node number uniquely @@ -100,44 +83,44 @@ typedef struct H5FD_core_t { HANDLE hFile; /* Native windows file handle */ #endif /* H5_HAVE_WIN32_API */ - hbool_t dirty; /*changes not saved? */ - H5FD_file_image_callbacks_t fi_callbacks; /* file image callbacks */ + hbool_t dirty; /* changes not saved? */ + H5FD_file_image_callbacks_t fi_callbacks; /* file image callbacks */ } H5FD_core_t; /* Driver-specific file access properties */ typedef struct H5FD_core_fapl_t { - size_t increment; /*how much to grow memory */ - hbool_t backing_store; /*write to file name on flush */ + size_t increment; /* how much to grow memory */ + hbool_t backing_store; /* write to file name on flush */ } H5FD_core_fapl_t; /* Allocate memory in multiples of this size by default */ -#define H5FD_CORE_INCREMENT 8192 +#define H5FD_CORE_INCREMENT 8192 /* These macros check for overflow of various quantities. These macros * assume that file_offset_t is signed and haddr_t and size_t are unsigned. * - * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' - * is too large to be represented by the second argument - * of the file seek function. + * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' + * is too large to be represented by the second argument + * of the file seek function. * - * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too - * large to be represented by the `size_t' type. + * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too + * large to be represented by the `size_t' type. * - * REGION_OVERFLOW: Checks whether an address and size pair describe data - * which can be addressed entirely in memory. + * REGION_OVERFLOW: Checks whether an address and size pair describe data + * which can be addressed entirely in memory. */ -#define MAXADDR ((haddr_t)((~(size_t)0)-1)) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || (A) > (haddr_t)MAXADDR) -#define SIZE_OVERFLOW(Z) ((Z) > (hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || \ - (size_t)((A)+(Z))<(size_t)(A)) +#define MAXADDR ((haddr_t)((~(size_t)0)-1)) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || (A) > (haddr_t)MAXADDR) +#define SIZE_OVERFLOW(Z) ((Z) > (hsize_t)MAXADDR) +#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ + HADDR_UNDEF==(A)+(Z) || \ + (size_t)((A)+(Z))<(size_t)(A)) /* Prototypes */ static herr_t H5FD_core_term(void); static void *H5FD_core_fapl_get(H5FD_t *_file); static H5FD_t *H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); + haddr_t maxaddr); static herr_t H5FD_core_close(H5FD_t *_file); static int H5FD_core_cmp(const H5FD_t *_f1, const H5FD_t *_f2); static herr_t H5FD_core_query(const H5FD_t *_f1, unsigned long *flags); @@ -146,61 +129,58 @@ static herr_t H5FD_core_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_core_get_eof(const H5FD_t *_file); static herr_t H5FD_core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); static herr_t H5FD_core_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); + size_t size, void *buf); static herr_t H5FD_core_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); + size_t size, const void *buf); static herr_t H5FD_core_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing); static herr_t H5FD_core_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); static const H5FD_class_t H5FD_core_g = { - "core", /*name */ - MAXADDR, /*maxaddr */ - H5F_CLOSE_WEAK, /*fc_degree */ - H5FD_core_term, /*terminate */ - NULL, /*sb_size */ - NULL, /*sb_encode */ - NULL, /*sb_decode */ - sizeof(H5FD_core_fapl_t), /*fapl_size */ - H5FD_core_fapl_get, /*fapl_get */ - NULL, /*fapl_copy */ - NULL, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_core_open, /*open */ - H5FD_core_close, /*close */ - H5FD_core_cmp, /*cmp */ - H5FD_core_query, /*query */ - NULL, /*get_type_map */ - NULL, /*alloc */ - NULL, /*free */ - H5FD_core_get_eoa, /*get_eoa */ - H5FD_core_set_eoa, /*set_eoa */ - H5FD_core_get_eof, /*get_eof */ - H5FD_core_get_handle, /*get_handle */ - H5FD_core_read, /*read */ - H5FD_core_write, /*write */ - H5FD_core_flush, /*flush */ - H5FD_core_truncate, /*truncate */ - NULL, /*lock */ - NULL, /*unlock */ - H5FD_FLMAP_DICHOTOMY /*fl_map */ + "core", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_core_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + sizeof(H5FD_core_fapl_t), /* fapl_size */ + H5FD_core_fapl_get, /* fapl_get */ + NULL, /* fapl_copy */ + NULL, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD_core_open, /* open */ + H5FD_core_close, /* close */ + H5FD_core_cmp, /* cmp */ + H5FD_core_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD_core_get_eoa, /* get_eoa */ + H5FD_core_set_eoa, /* set_eoa */ + H5FD_core_get_eof, /* get_eof */ + H5FD_core_get_handle, /* get_handle */ + H5FD_core_read, /* read */ + H5FD_core_write, /* write */ + H5FD_core_flush, /* flush */ + H5FD_core_truncate, /* truncate */ + NULL, /* lock */ + NULL, /* unlock */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; -/*-------------------------------------------------------------------------- -NAME - H5FD_core_init_interface -- Initialize interface-specific information -USAGE - herr_t H5FD_core_init_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5FD_core_init currently). - ---------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * Function: H5FD_core_init_interface + * + * Purpose: Initializes any interface-specific data or routines. + * + * Return: Success: The driver ID for the core driver. + * Failure: Negative. + * + *------------------------------------------------------------------------- + */ static herr_t H5FD_core_init_interface(void) { @@ -211,16 +191,15 @@ H5FD_core_init_interface(void) /*------------------------------------------------------------------------- - * Function: H5FD_core_init - * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Function: H5FD_core_init * - * Return: Success: The driver ID for the core driver. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Failure: Negative. + * Return: Success: The driver ID for the core driver. + * Failure: Negative. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -228,15 +207,15 @@ H5FD_core_init_interface(void) hid_t H5FD_core_init(void) { - hid_t ret_value=H5FD_CORE_g; /* Return value */ + hid_t ret_value = H5FD_CORE_g; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if (H5I_VFL!=H5Iget_type(H5FD_CORE_g)) + if(H5I_VFL != H5Iget_type(H5FD_CORE_g)) H5FD_CORE_g = H5FD_register(&H5FD_core_g,sizeof(H5FD_class_t),FALSE); /* Set return value */ - ret_value=H5FD_CORE_g; + ret_value = H5FD_CORE_g; done: FUNC_LEAVE_NOAPI(ret_value) @@ -244,11 +223,11 @@ done: /*--------------------------------------------------------------------------- - * Function: H5FD_core_term + * Function: H5FD_core_term * - * Purpose: Shut down the VFD + * Purpose: Shut down the VFD * - * Returns: Non-negative on success or negative on failure + * Returns: SUCCEED (Can't fail) * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 @@ -261,32 +240,32 @@ H5FD_core_term(void) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Reset VFL ID */ - H5FD_CORE_g=0; + H5FD_CORE_g = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_core_term() */ /*------------------------------------------------------------------------- - * Function: H5Pset_fapl_core + * Function: H5Pset_fapl_core * - * Purpose: Modify the file access property list to use the H5FD_CORE - * driver defined in this source file. The INCREMENT specifies - * how much to grow the memory each time we need more. + * Purpose: Modify the file access property list to use the H5FD_CORE + * driver defined in this source file. The INCREMENT specifies + * how much to grow the memory each time we need more. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * - * Programmer: Robb Matzke - * Thursday, February 19, 1998 + * Programmer: Robb Matzke + * Thursday, February 19, 1998 * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store) { - H5FD_core_fapl_t fa; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value; + H5FD_core_fapl_t fa; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE3("e", "izb", fapl_id, increment, backing_store); @@ -306,26 +285,23 @@ done: /*------------------------------------------------------------------------- - * Function: H5Pget_fapl_core + * Function: H5Pget_fapl_core * - * Purpose: Queries properties set by the H5Pset_fapl_core() function. + * Purpose: Queries properties set by the H5Pset_fapl_core() function. * - * Return: Success: Non-negative + * Return: SUCCEED/FAIL * - * Failure: Negative - * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Tuesday, August 10, 1999 * *------------------------------------------------------------------------- */ herr_t -H5Pget_fapl_core(hid_t fapl_id, size_t *increment/*out*/, - hbool_t *backing_store/*out*/) +H5Pget_fapl_core(hid_t fapl_id, size_t *increment /*out*/, hbool_t *backing_store /*out*/) { - H5FD_core_fapl_t *fa; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* Return value */ + H5FD_core_fapl_t *fa; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", fapl_id, increment, backing_store); @@ -348,15 +324,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_fapl_get + * Function: H5FD_core_fapl_get * - * Purpose: Returns a copy of the file access properties. + * Purpose: Returns a copy of the file access properties. * - * Return: Success: Ptr to new file access properties. + * Return: Success: Ptr to new file access properties. * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, August 13, 1999 * *------------------------------------------------------------------------- @@ -364,9 +340,9 @@ done: static void * H5FD_core_fapl_get(H5FD_t *_file) { - H5FD_core_t *file = (H5FD_core_t*)_file; - H5FD_core_fapl_t *fa; - void *ret_value; /* Return value */ + H5FD_core_t *file = (H5FD_core_t*)_file; + H5FD_core_fapl_t *fa; + void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -377,7 +353,7 @@ H5FD_core_fapl_get(H5FD_t *_file) fa->backing_store = (hbool_t)(file->fd >= 0); /* Set return value */ - ret_value=fa; + ret_value = fa; done: FUNC_LEAVE_NOAPI(ret_value) @@ -385,36 +361,35 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_open + * Function: H5FD_core_open * - * Purpose: Create memory as an HDF5 file. + * Purpose: Create memory as an HDF5 file. * - * Return: Success: A pointer to a new file data structure. The - * public fields will be initialized by the - * caller, which is always H5FD_open(). + * Return: Success: A pointer to a new file data structure. The + * public fields will be initialized by the + * caller, which is always H5FD_open(). * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- */ static H5FD_t * -H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr) +H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - int o_flags; - H5FD_core_t *file=NULL; - H5FD_core_fapl_t *fa=NULL; - H5P_genplist_t *plist; /* Property list pointer */ + int o_flags; + H5FD_core_t *file = NULL; + H5FD_core_fapl_t *fa = NULL; + H5P_genplist_t *plist; /* Property list pointer */ #ifdef H5_HAVE_WIN32_API struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif - h5_stat_t sb; - int fd=-1; - H5FD_file_image_info_t file_image_info; - H5FD_t *ret_value; + h5_stat_t sb; + int fd = -1; + H5FD_file_image_info_t file_image_info; + H5FD_t *ret_value; FUNC_ENTER_NOAPI_NOINIT @@ -554,20 +529,23 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, /* Read in existing data, being careful of interrupted system calls, * partial results, and the end of the file. */ + + uint8_t *mem = file->mem; /* memory pointer for writes */ + while(size > 0) { - h5_core_io_t bytes_in = 0; /* # of bytes to read */ - h5_core_io_ret_t bytes_read = -1; /* # of bytes actually read */ + h5_posix_io_t bytes_in = 0; /* # of bytes to read */ + h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ /* Trying to read more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_CORE_MAX_IO_BYTES_g) - bytes_in = H5_CORE_MAX_IO_BYTES_g; + if(size > H5_POSIX_MAX_IO_BYTES) + bytes_in = H5_POSIX_MAX_IO_BYTES; else - bytes_in = (h5_core_io_t)size; + bytes_in = (h5_posix_io_t)size; do { - bytes_read = HDread(file->fd, file->mem, bytes_in); + bytes_read = HDread(file->fd, mem, bytes_in); } while(-1 == bytes_read && EINTR == errno); if(-1 == bytes_read) { /* error */ @@ -575,12 +553,13 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, time_t mytime = HDtime(NULL); HDoff_t myoffset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - HGOTO_ERROR(H5E_IO, H5E_READERROR, NULL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', file->mem = %p, size = %lu, offset = %llu", HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), file->mem, (unsigned long)size, (unsigned long long)myoffset); + HGOTO_ERROR(H5E_IO, H5E_READERROR, NULL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', file->mem = %p, total read size = %llu, bytes this sub-read = %llu, bytes actually read = %llu, offset = %llu", HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), file->mem, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)myoffset); } /* end if */ HDassert(bytes_read >= 0); HDassert((size_t)bytes_read <= size); + mem += bytes_read; size -= (size_t)bytes_read; } /* end while */ } /* end else */ @@ -596,15 +575,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_close - * - * Purpose: Closes the file. + * Function: H5FD_core_close * - * Return: Success: 0 + * Purpose: Closes the file. * - * Failure: -1 + * Return: SUCCEED/FAIL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -612,8 +589,8 @@ done: static herr_t H5FD_core_close(H5FD_t *_file) { - H5FD_core_t *file = (H5FD_core_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t*)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -644,19 +621,19 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_cmp + * Function: H5FD_core_cmp * - * Purpose: Compares two files belonging to this driver by name. If one - * file doesn't have a name then it is less than the other file. - * If neither file has a name then the comparison is by file - * address. + * Purpose: Compares two files belonging to this driver by name. If one + * file doesn't have a name then it is less than the other file. + * If neither file has a name then the comparison is by file + * address. * - * Return: Success: A value like strcmp() + * Return: Success: A value like strcmp() * - * Failure: never fails (arguments were checked by the - * caller). + * Failure: never fails (arguments were checked by the + * caller). * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -664,9 +641,9 @@ done: static int H5FD_core_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_core_t *f1 = (const H5FD_core_t*)_f1; - const H5FD_core_t *f2 = (const H5FD_core_t*)_f2; - int ret_value = 0; + const H5FD_core_t *f1 = (const H5FD_core_t*)_f1; + const H5FD_core_t *f2 = (const H5FD_core_t*)_f2; + int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -728,15 +705,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_query + * Function: H5FD_core_query * - * Purpose: Set the flags that this VFL driver is capable of supporting. + * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * - * Return: Success: non-negative - * Failure: negative + * Return: SUCCEED (Can't fail) * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, October 7, 2008 * *------------------------------------------------------------------------- @@ -744,7 +720,7 @@ done: static herr_t H5FD_core_query(const H5FD_t * _file, unsigned long *flags /* out */) { - const H5FD_core_t *file = (const H5FD_core_t*)_file; + const H5FD_core_t *file = (const H5FD_core_t*)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -768,17 +744,15 @@ H5FD_core_query(const H5FD_t * _file, unsigned long *flags /* out */) /*------------------------------------------------------------------------- - * Function: H5FD_core_get_eoa + * Function: H5FD_core_get_eoa * - * Purpose: Gets the end-of-address marker for the file. The EOA marker - * is the first address past the last byte allocated in the - * format address space. + * Purpose: Gets the end-of-address marker for the file. The EOA marker + * is the first address past the last byte allocated in the + * format address space. * - * Return: Success: The end-of-address marker. + * Return: The end-of-address marker. (Can't fail) * - * Failure: HADDR_UNDEF - * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 2, 1999 * *------------------------------------------------------------------------- @@ -786,7 +760,7 @@ H5FD_core_query(const H5FD_t * _file, unsigned long *flags /* out */) static haddr_t H5FD_core_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) { - const H5FD_core_t *file = (const H5FD_core_t*)_file; + const H5FD_core_t *file = (const H5FD_core_t*)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -795,17 +769,15 @@ H5FD_core_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) /*------------------------------------------------------------------------- - * Function: H5FD_core_set_eoa - * - * Purpose: Set the end-of-address marker for the file. This function is - * called shortly after an existing HDF5 file is opened in order - * to tell the driver where the end of the HDF5 data is located. + * Function: H5FD_core_set_eoa * - * Return: Success: 0 + * Purpose: Set the end-of-address marker for the file. This function is + * called shortly after an existing HDF5 file is opened in order + * to tell the driver where the end of the HDF5 data is located. * - * Failure: -1 + * Return: SUCCEED/FAIL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -813,8 +785,8 @@ H5FD_core_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) static herr_t H5FD_core_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) { - H5FD_core_t *file = (H5FD_core_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t*)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -829,19 +801,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_get_eof + * Function: H5FD_core_get_eof * - * Purpose: Returns the end-of-file marker, which is the greater of - * either the size of the underlying memory or the HDF5 - * end-of-address markers. + * Purpose: Returns the end-of-file marker, which is the greater of + * either the size of the underlying memory or the HDF5 + * end-of-address markers. * - * Return: Success: End of file address, the first address past - * the end of the "file", either the memory - * or the HDF5 file. + * Return: End of file address, the first address past + * the end of the "file", either the memory + * or the HDF5 file. (Can't fail) * - * Failure: HADDR_UNDEF - * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -849,7 +819,7 @@ done: static haddr_t H5FD_core_get_eof(const H5FD_t *_file) { - const H5FD_core_t *file = (const H5FD_core_t*)_file; + const H5FD_core_t *file = (const H5FD_core_t*)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -860,9 +830,9 @@ H5FD_core_get_eof(const H5FD_t *_file) /*------------------------------------------------------------------------- * Function: H5FD_core_get_handle * - * Purpose: Returns the file handle of CORE file driver. + * Purpose: Gets the file handle of CORE file driver. * - * Returns: Non-negative if succeed or negative if fails. + * Returns: SUCCEED/FAIL * * Programmer: Raymond Lu * Sept. 16, 2002 @@ -873,7 +843,7 @@ static herr_t H5FD_core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) { H5FD_core_t *file = (H5FD_core_t *)_file; /* core VFD info */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -918,26 +888,25 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_read + * Function: H5FD_core_read * - * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR - * into buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR + * into buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero. Result is stored in caller-supplied - * buffer BUF. + * Return: Success: SUCCEED. Result is stored in caller-supplied + * buffer BUF. * - * Failure: -1, Contents of buffer BUF are undefined. + * Failure: FAIL, Contents of buffer BUF are undefined. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5FD_core_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, - size_t size, void *buf/*out*/) + size_t size, void *buf/*out*/) { H5FD_core_t *file = (H5FD_core_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ @@ -984,28 +953,25 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_write + * Function: H5FD_core_write * - * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR - * from buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR + * from buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero + * Return: SUCCEED/FAIL * - * Failure: -1 - * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5FD_core_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, - size_t size, const void *buf) + size_t size, const void *buf) { H5FD_core_t *file = (H5FD_core_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1044,7 +1010,7 @@ H5FD_core_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had } /* end else */ #ifdef H5_CLEAR_MEMORY -HDmemset(x + file->eof, 0, (size_t)(new_eof - file->eof)); + HDmemset(x + file->eof, 0, (size_t)(new_eof - file->eof)); #endif /* H5_CLEAR_MEMORY */ file->mem = x; @@ -1063,49 +1029,46 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_flush - * - * Purpose: Flushes the file to backing store if there is any and if the - * dirty flag is set. + * Function: H5FD_core_flush * - * Return: Success: 0 + * Purpose: Flushes the file to backing store if there is any and if the + * dirty flag is set. * - * Failure: -1 + * Return: SUCCEED/FAIL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, October 15, 1999 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5FD_core_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned UNUSED closing) { - H5FD_core_t *file = (H5FD_core_t*)_file; - herr_t ret_value=SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t*)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Write to backing store */ - if (file->dirty && file->fd>=0 && file->backing_store) { + if (file->dirty && file->fd >= 0 && file->backing_store) { haddr_t size = file->eof; unsigned char *ptr = file->mem; - if (0!=HDlseek(file->fd, (off_t)0, SEEK_SET)) + if(0 != HDlseek(file->fd, (off_t)0, SEEK_SET)) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "error seeking in backing store") while (size > 0) { - h5_core_io_t bytes_in = 0; /* # of bytes to write */ - h5_core_io_ret_t bytes_wrote = -1; /* # of bytes written */ + h5_posix_io_t bytes_in = 0; /* # of bytes to write */ + h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ /* Trying to write more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_CORE_MAX_IO_BYTES_g) - bytes_in = H5_CORE_MAX_IO_BYTES_g; + if(size > H5_POSIX_MAX_IO_BYTES) + bytes_in = H5_POSIX_MAX_IO_BYTES; else - bytes_in = (h5_core_io_t)size; + bytes_in = (h5_posix_io_t)size; do { bytes_wrote = HDwrite(file->fd, ptr, bytes_in); @@ -1116,7 +1079,7 @@ H5FD_core_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned UNUSED closing) time_t mytime = HDtime(NULL); HDoff_t myoffset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write to backing store failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', ptr = %p, size = %lu, offset = %llu", HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), ptr, (unsigned long)size, (unsigned long long)myoffset); + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write to backing store failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', ptr = %p, total write size = %llu, bytes this sub-write = %llu, bytes actually written = %llu, offset = %llu", HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), ptr, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)myoffset); } /* end if */ HDassert(bytes_wrote > 0); @@ -1136,42 +1099,40 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_truncate + * Function: H5FD_core_truncate * - * Purpose: Makes sure that the true file size is the same (or larger) - * than the end-of-address. + * Purpose: Makes sure that the true file size is the same (or larger) + * than the end-of-address. * - * Addendum -- 12/2/11 - * For file images opened with the core file driver, it is - * necessary that we avoid reallocating the core file driver's - * buffer uneccessarily. + * Addendum -- 12/2/11 + * For file images opened with the core file driver, it is + * necessary that we avoid reallocating the core file driver's + * buffer uneccessarily. * - * To this end, I have made the following functional changes - * to this function. + * To this end, I have made the following functional changes + * to this function. * - * If we are closing, and there is no backing store, this - * function becomes a no-op. + * If we are closing, and there is no backing store, this + * function becomes a no-op. * - * If we are closing, and there is backing store, we set the - * eof to equal the eoa, and truncate the backing store to - * the new eof + * If we are closing, and there is backing store, we set the + * eof to equal the eoa, and truncate the backing store to + * the new eof * - * If we are not closing, we realloc the buffer to size equal - * to the smallest multiple of the allocation increment that - * equals or exceeds the eoa and set the eof accordingly. - * Note that we no longer truncate the backing store to the - * new eof if applicable. - * -- JRM + * If we are not closing, we realloc the buffer to size equal + * to the smallest multiple of the allocation increment that + * equals or exceeds the eoa and set the eof accordingly. + * Note that we no longer truncate the backing store to the + * new eof if applicable. + * -- JRM * - * Return: Success: Non-negative - * Failure: Negative + * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, October 7, 2008 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5FD_core_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t closing) { @@ -1262,4 +1223,3 @@ H5FD_core_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t closing) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_core_truncate() */ - diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 9f4abd3..81d050d 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -14,50 +14,35 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu> + * Programmer: Quincey Koziol <koziol@hdfgroup.org> * Monday, April 17, 2000 * - * Purpose: The POSIX unbuffered file driver using only the HDF5 public - * API and with a few optimizations: the lseek() call is made - * only when the current file position is unknown or needs to be - * changed based on previous I/O through this driver (don't mix - * I/O from this driver with I/O from other parts of the - * application to the same file). - * With custom modifications... + * Purpose: The POSIX unbuffered file driver using only the HDF5 public + * API and with a few optimizations: the lseek() call is made + * only when the current file position is unknown or needs to be + * changed based on previous I/O through this driver (don't mix + * I/O from this driver with I/O from other parts of the + * application to the same file). + * With custom modifications... */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5FD_log_init_interface -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDlog.h" /* Logging file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDlog.h" /* Logging file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_LOG_g = 0; -/* Since Windows doesn't follow the rest of the world when it comes - * to POSIX I/O types, some typedefs and constants are needed to avoid - * making the code messy with #ifdefs. - */ -#ifdef H5_HAVE_WIN32_API -typedef unsigned int h5_log_io_t; -typedef int h5_log_io_ret_t; -static int H5_LOG_MAX_IO_BYTES_g = INT_MAX; -#else -/* Unix, everyone else */ -typedef size_t h5_log_io_t; -typedef ssize_t h5_log_io_ret_t; -static size_t H5_LOG_MAX_IO_BYTES_g = SSIZET_MAX; -#endif /* H5_HAVE_WIN32_API */ - /* Driver-specific file access properties */ typedef struct H5FD_log_fapl_t { char *logfile; /* Allocated log file name */ @@ -161,24 +146,23 @@ typedef struct H5FD_log_t { * These macros check for overflow of various quantities. These macros * assume that HDoff_t is signed and haddr_t and size_t are unsigned. * - * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' - * is too large to be represented by the second argument - * of the file seek function. + * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' + * is too large to be represented by the second argument + * of the file seek function. * - * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too - * large to be represented by the `size_t' type. + * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too + * large to be represented by the `size_t' type. * - * REGION_OVERFLOW: Checks whether an address and size pair describe data - * which can be addressed entirely by the second - * argument of the file seek function. + * REGION_OVERFLOW: Checks whether an address and size pair describe data + * which can be addressed entirely by the second + * argument of the file seek function. */ -#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ - ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || \ - (HDoff_t)((A)+(Z))<(HDoff_t)(A)) +#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ + HADDR_UNDEF==(A)+(Z) || \ + (HDoff_t)((A)+(Z))<(HDoff_t)(A)) /* Prototypes */ static herr_t H5FD_log_term(void); @@ -186,7 +170,7 @@ static void *H5FD_log_fapl_get(H5FD_t *file); static void *H5FD_log_fapl_copy(const void *_old_fa); static herr_t H5FD_log_fapl_free(void *_fa); static H5FD_t *H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); + haddr_t maxaddr); static herr_t H5FD_log_close(H5FD_t *_file); static int H5FD_log_cmp(const H5FD_t *_f1, const H5FD_t *_f2); static herr_t H5FD_log_query(const H5FD_t *_f1, unsigned long *flags); @@ -196,9 +180,9 @@ static herr_t H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_log_get_eof(const H5FD_t *_file); static herr_t H5FD_log_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); static herr_t H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); + size_t size, void *buf); static herr_t H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); + size_t size, const void *buf); static herr_t H5FD_log_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); static const H5FD_class_t H5FD_log_g = { @@ -240,19 +224,16 @@ static const H5FD_class_t H5FD_log_g = { H5FL_DEFINE_STATIC(H5FD_log_t); -/*-------------------------------------------------------------------------- -NAME - H5FD_log_init_interface -- Initialize interface-specific information -USAGE - herr_t H5FD_log_init_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5FD_log_init currently). - ---------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * Function: H5FD_log_init_interface + * + * Purpose: Initializes any interface-specific data or routines. + * + * Return: Success: The driver ID for the log driver. + * Failure: Negative. + * + *------------------------------------------------------------------------- + */ static herr_t H5FD_log_init_interface(void) { @@ -263,15 +244,15 @@ H5FD_log_init_interface(void) /*------------------------------------------------------------------------- - * Function: H5FD_log_init + * Function: H5FD_log_init * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Return: Success: The driver ID for the log driver. - * Failure: Negative. + * Return: Success: The driver ID for the log driver. + * Failure: Negative. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -295,11 +276,11 @@ done: /*--------------------------------------------------------------------------- - * Function: H5FD_log_term + * Function: H5FD_log_term * - * Purpose: Shut down the VFD + * Purpose: Shut down the VFD * - * Returns: Non-negative on success or negative on failure + * Returns: SUCCEED (Can't fail) * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 @@ -319,15 +300,15 @@ H5FD_log_term(void) /*------------------------------------------------------------------------- - * Function: H5Pset_fapl_log + * Function: H5Pset_fapl_log * - * Purpose: Modify the file access property list to use the H5FD_LOG - * driver defined in this source file. + * Purpose: Modify the file access property list to use the H5FD_LOG + * driver defined in this source file. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * - * Programmer: Robb Matzke - * Thursday, February 19, 1998 + * Programmer: Robb Matzke + * Thursday, February 19, 1998 * *------------------------------------------------------------------------- */ @@ -360,17 +341,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_log_fapl_get + * Function: H5FD_log_fapl_get * - * Purpose: Returns a file access property list which indicates how the - * specified file is being accessed. The return list could be - * used to access another file the same way. + * Purpose: Returns a file access property list which indicates how the + * specified file is being accessed. The return list could be + * used to access another file the same way. * - * Return: Success: Ptr to new file access property list with all - * members copied from the file struct. - * Failure: NULL + * Return: Success: Ptr to new file access property list with all + * members copied from the file struct. + * Failure: NULL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, April 20, 2000 * *------------------------------------------------------------------------- @@ -378,8 +359,8 @@ done: static void * H5FD_log_fapl_get(H5FD_t *_file) { - H5FD_log_t *file = (H5FD_log_t *)_file; - void *ret_value; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; + void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -391,14 +372,14 @@ H5FD_log_fapl_get(H5FD_t *_file) /*------------------------------------------------------------------------- - * Function: H5FD_log_fapl_copy + * Function: H5FD_log_fapl_copy * - * Purpose: Copies the log-specific file access properties. + * Purpose: Copies the log-specific file access properties. * - * Return: Success: Ptr to a new property list - * Failure: NULL + * Return: Success: Ptr to a new property list + * Failure: NULL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, April 20, 2000 * *------------------------------------------------------------------------- @@ -406,9 +387,9 @@ H5FD_log_fapl_get(H5FD_t *_file) static void * H5FD_log_fapl_copy(const void *_old_fa) { - const H5FD_log_fapl_t *old_fa = (const H5FD_log_fapl_t*)_old_fa; - H5FD_log_fapl_t *new_fa = NULL; /* New FAPL info */ - void *ret_value; /* Return value */ + const H5FD_log_fapl_t *old_fa = (const H5FD_log_fapl_t*)_old_fa; + H5FD_log_fapl_t *new_fa = NULL; /* New FAPL info */ + void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -442,14 +423,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_log_fapl_free + * Function: H5FD_log_fapl_free * - * Purpose: Frees the log-specific file access properties. + * Purpose: Frees the log-specific file access properties. * - * Return: Success: 0 - * Failure: -1 + * Return: SUCCEED (Can't fail) * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, April 20, 2000 * *------------------------------------------------------------------------- @@ -471,16 +451,16 @@ H5FD_log_fapl_free(void *_fa) /*------------------------------------------------------------------------- - * Function: H5FD_log_open + * Function: H5FD_log_open * - * Purpose: Create and/or opens a file as an HDF5 file. + * Purpose: Create and/or opens a file as an HDF5 file. * - * Return: Success: A pointer to a new file data structure. The - * public fields will be initialized by the - * caller, which is always H5FD_open(). - * Failure: NULL + * Return: Success: A pointer to a new file data structure. The + * public fields will be initialized by the + * caller, which is always H5FD_open(). + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -488,11 +468,11 @@ H5FD_log_fapl_free(void *_fa) static H5FD_t * H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_log_t *file = NULL; - H5P_genplist_t *plist; /* Property list */ - H5FD_log_fapl_t *fa; /* File access property list information */ - int fd = (-1); /* File descriptor */ - int o_flags; /* Flags for open() call */ + H5FD_log_t *file = NULL; + H5P_genplist_t *plist; /* Property list */ + H5FD_log_fapl_t *fa; /* File access property list information */ + int fd = -1; /* File descriptor */ + int o_flags; /* Flags for open() call */ #ifdef H5_HAVE_WIN32_API struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif @@ -501,8 +481,8 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) struct timeval open_timeval_diff; struct timeval stat_timeval_diff; #endif /* H5_HAVE_GETTIMEOFDAY */ - h5_stat_t sb; - H5FD_t *ret_value; /* Return value */ + h5_stat_t sb; + H5FD_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -679,14 +659,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_log_close + * Function: H5FD_log_close * - * Purpose: Closes an HDF5 file. + * Purpose: Closes an HDF5 file. * - * Return: Success: 0 - * Failure: -1, file not closed. + * Return: Success: SUCCEED + * Failure: FAIL, file not closed. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -827,16 +807,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_log_cmp + * Function: H5FD_log_cmp * - * Purpose: Compares two files belonging to this driver using an - * arbitrary (but consistent) ordering. + * Purpose: Compares two files belonging to this driver using an + * arbitrary (but consistent) ordering. * - * Return: Success: A value like strcmp() - * Failure: never fails (arguments were checked by the - * caller). + * Return: Success: A value like strcmp() + * Failure: never fails (arguments were checked by the + * caller). * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -844,8 +824,8 @@ done: static int H5FD_log_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_log_t *f1 = (const H5FD_log_t *)_f1; - const H5FD_log_t *f2 = (const H5FD_log_t *)_f2; + const H5FD_log_t *f1 = (const H5FD_log_t *)_f1; + const H5FD_log_t *f2 = (const H5FD_log_t *)_f2; int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -888,15 +868,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_log_query + * Function: H5FD_log_query * - * Purpose: Set the flags that this VFL driver is capable of supporting. + * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * - * Return: Success: non-negative - * Failure: negative + * Return: SUCCEED (Can't fail) * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Friday, August 25, 2000 * *------------------------------------------------------------------------- @@ -904,7 +883,7 @@ done: static herr_t H5FD_log_query(const H5FD_t *_file, unsigned long *flags /* out */) { - const H5FD_log_t *file = (const H5FD_log_t *)_file; + const H5FD_log_t *file = (const H5FD_log_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -927,19 +906,18 @@ H5FD_log_query(const H5FD_t *_file, unsigned long *flags /* out */) /*------------------------------------------------------------------------- - * Function: H5FD_log_alloc + * Function: H5FD_log_alloc * - * Purpose: Allocate file memory. + * Purpose: Allocate file memory. * - * Return: Success: Address of new memory - * Failure: HADDR_UNDEF + * Return: Success: Address of new memory + * Failure: HADDR_UNDEF * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, April 17, 2000 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static haddr_t H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, hsize_t size) { @@ -981,16 +959,16 @@ H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, hsize_t siz /*------------------------------------------------------------------------- - * Function: H5FD_log_get_eoa + * Function: H5FD_log_get_eoa * - * Purpose: Gets the end-of-address marker for the file. The EOA marker - * is the first address past the last byte allocated in the - * format address space. + * Purpose: Gets the end-of-address marker for the file. The EOA marker + * is the first address past the last byte allocated in the + * format address space. * - * Return: Success: The end-of-address marker. - * Failure: HADDR_UNDEF + * Return: Success: The end-of-address marker. + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 2, 1999 * *------------------------------------------------------------------------- @@ -998,7 +976,7 @@ H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, hsize_t siz static haddr_t H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) { - const H5FD_log_t *file = (const H5FD_log_t *)_file; + const H5FD_log_t *file = (const H5FD_log_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1007,16 +985,15 @@ H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) /*------------------------------------------------------------------------- - * Function: H5FD_log_set_eoa + * Function: H5FD_log_set_eoa * - * Purpose: Set the end-of-address marker for the file. This function is - * called shortly after an existing HDF5 file is opened in order - * to tell the driver where the end of the HDF5 data is located. + * Purpose: Set the end-of-address marker for the file. This function is + * called shortly after an existing HDF5 file is opened in order + * to tell the driver where the end of the HDF5 data is located. * - * Return: Success: 0 - * Failure: -1 + * Return: SUCCEED (Can't fail) * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -1024,25 +1001,25 @@ H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) static herr_t H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) { - H5FD_log_t *file = (H5FD_log_t *)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR if(file->fa.flags != 0) { - if(H5F_addr_gt(addr, file->eoa) && H5F_addr_gt(addr, 0)) { - hsize_t size = addr - file->eoa; + if(H5F_addr_gt(addr, file->eoa) && H5F_addr_gt(addr, 0)) { + hsize_t size = addr - file->eoa; /* Retain the flavor of the space allocated by the extension */ - if(file->fa.flags & H5FD_LOG_FLAVOR) { - HDassert(addr < file->iosize); - H5_CHECK_OVERFLOW(size, hsize_t, size_t); - HDmemset(&file->flavor[file->eoa], (int)type, (size_t)size); - } /* end if */ + if(file->fa.flags & H5FD_LOG_FLAVOR) { + HDassert(addr < file->iosize); + H5_CHECK_OVERFLOW(size, hsize_t, size_t); + HDmemset(&file->flavor[file->eoa], (int)type, (size_t)size); + } /* end if */ /* Log the extension like an allocation */ - if(file->fa.flags & H5FD_LOG_ALLOC) - HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Allocated\n", file->eoa, addr, size, flavors[type]); - } /* end if */ + if(file->fa.flags & H5FD_LOG_ALLOC) + HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Allocated\n", file->eoa, addr, size, flavors[type]); + } /* end if */ } /* end if */ file->eoa = addr; @@ -1052,18 +1029,18 @@ H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) /*------------------------------------------------------------------------- - * Function: H5FD_log_get_eof + * Function: H5FD_log_get_eof * - * Purpose: Returns the end-of-file marker, which is the greater of - * either the filesystem end-of-file or the HDF5 end-of-address - * markers. + * Purpose: Returns the end-of-file marker, which is the greater of + * either the filesystem end-of-file or the HDF5 end-of-address + * markers. * - * Return: Success: End of file address, the first address past - * the end of the "file", either the filesystem file - * or the HDF5 file. - * Failure: HADDR_UNDEF + * Return: Success: End of file address, the first address past + * the end of the "file", either the filesystem file + * or the HDF5 file. + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -1084,14 +1061,13 @@ H5FD_log_get_eof(const H5FD_t *_file) * * Purpose: Returns the file handle of LOG file driver. * - * Returns: Non-negative if succeed or negative if fails. + * Returns: SUCCEED/FAIL * * Programmer: Raymond Lu * Sept. 16, 2002 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5FD_log_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void **file_handle) { @@ -1111,27 +1087,26 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_log_read + * Function: H5FD_log_read * - * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR - * into buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR + * into buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero. Result is stored in caller-supplied - * buffer BUF. - * Failure: -1, Contents of buffer BUF are undefined. + * Return: Success: SUCCEED. Result is stored in caller-supplied + * buffer BUF. + * Failure: FAIL, Contents of buffer BUF are undefined. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr, - size_t size, void *buf/*out*/) + size_t size, void *buf/*out*/) { - H5FD_log_t *file = (H5FD_log_t *)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; size_t orig_size = size; /* Save the original size for later */ haddr_t orig_addr = addr; #ifdef H5_HAVE_GETTIMEOFDAY @@ -1219,16 +1194,16 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr #endif /* H5_HAVE_GETTIMEOFDAY */ while(size > 0) { - h5_log_io_t bytes_in = 0; /* # of bytes to read */ - h5_log_io_ret_t bytes_read = -1; /* # of bytes actually read */ + h5_posix_io_t bytes_in = 0; /* # of bytes to read */ + h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ /* Trying to read more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_LOG_MAX_IO_BYTES_g) - bytes_in = H5_LOG_MAX_IO_BYTES_g; + if(size > H5_POSIX_MAX_IO_BYTES) + bytes_in = H5_POSIX_MAX_IO_BYTES; else - bytes_in = (h5_log_io_t)size; + bytes_in = (h5_posix_io_t)size; do { bytes_read = HDread(file->fd, buf, bytes_in); @@ -1242,7 +1217,7 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr if(file->fa.flags & H5FD_LOG_LOC_READ) HDfprintf(file->logfp, "Error! Reading: %10a-%10a (%10Zu bytes)\n", orig_addr, (orig_addr + orig_size) - 1, orig_size); - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, size = %lu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long)size, (unsigned long long)myoffset); + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, bytes actually read = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)myoffset); } /* end if */ if(0 == bytes_read) { @@ -1313,26 +1288,24 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_log_write + * Function: H5FD_log_write * - * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR - * from buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR + * from buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero - * Failure: -1 + * Return: SUCCEED/FAIL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr, - size_t size, const void *buf) + size_t size, const void *buf) { - H5FD_log_t *file = (H5FD_log_t *)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; size_t orig_size = size; /* Save the original size for later */ haddr_t orig_addr = addr; #ifdef H5_HAVE_GETTIMEOFDAY @@ -1425,16 +1398,16 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add #endif /* H5_HAVE_GETTIMEOFDAY */ while(size > 0) { - h5_log_io_t bytes_in = 0; /* # of bytes to write */ - h5_log_io_ret_t bytes_wrote = -1; /* # of bytes written */ + h5_posix_io_t bytes_in = 0; /* # of bytes to write */ + h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ /* Trying to write more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_LOG_MAX_IO_BYTES_g) - bytes_in = H5_LOG_MAX_IO_BYTES_g; + if(size > H5_POSIX_MAX_IO_BYTES) + bytes_in = H5_POSIX_MAX_IO_BYTES; else - bytes_in = (h5_log_io_t)size; + bytes_in = (h5_posix_io_t)size; do { bytes_wrote = HDwrite(file->fd, buf, bytes_in); @@ -1448,7 +1421,7 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add if(file->fa.flags & H5FD_LOG_LOC_WRITE) HDfprintf(file->logfp, "Error! Writing: %10a-%10a (%10Zu bytes)\n", orig_addr, (orig_addr + orig_size) - 1, orig_size); - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, size = %lu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long)size, (unsigned long long)myoffset); + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = %llu, bytes actually written = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)myoffset); } /* end if */ HDassert(bytes_wrote > 0); @@ -1518,25 +1491,23 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_log_truncate + * Function: H5FD_log_truncate * - * Purpose: Makes sure that the true file size is the same (or larger) - * than the end-of-address. + * Purpose: Makes sure that the true file size is the same (or larger) + * than the end-of-address. * - * Return: Success: Non-negative - * Failure: Negative + * Return: SUCCEED/FAIL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5FD_log_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) { - H5FD_log_t *file = (H5FD_log_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1597,4 +1568,3 @@ H5FD_log_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_truncate() */ - diff --git a/src/H5FDmpiposix.c b/src/H5FDmpiposix.c index 092cd24..978494e 100644 --- a/src/H5FDmpiposix.c +++ b/src/H5FDmpiposix.c @@ -71,21 +71,6 @@ */ static hid_t H5FD_MPIPOSIX_g = 0; -/* Since Windows doesn't follow the rest of the world when it comes - * to POSIX I/O types, some typedefs and constants are needed to avoid - * making the code messy with #ifdefs. - */ -#ifdef H5_HAVE_WIN32_API -typedef unsigned int h5_mpiposix_io_t; -typedef int h5_mpiposix_io_ret_t; -static int H5_MPIPOSIX_MAX_IO_BYTES_g = INT_MAX; -#else -/* Unix, everyone else */ -typedef size_t h5_mpiposix_io_t; -typedef ssize_t h5_mpiposix_io_ret_t; -static size_t H5_MPIPOSIX_MAX_IO_BYTES_g = SSIZET_MAX; -#endif /* H5_HAVE_WIN32_API */ - /* * The description of a file belonging to this driver. * The EOF value is only used just after the file is opened in order for the @@ -238,19 +223,16 @@ static const H5FD_class_mpi_t H5FD_mpiposix_g = { }; -/*-------------------------------------------------------------------------- -NAME - H5FD_mpiposix_init_interface -- Initialize interface-specific information -USAGE - herr_t H5FD_mpiposix_init_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5FD_mpiposix_init currently). - ---------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * Function: H5FD_mpiposix_init_interface + * + * Purpose: Initializes any interface-specific data or routines. + * + * Return: Success: The driver ID for the mpiposix driver. + * Failure: Negative. + * + *------------------------------------------------------------------------- + */ static herr_t H5FD_mpiposix_init_interface(void) { @@ -1081,16 +1063,16 @@ H5FD_mpiposix_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, */ while(size > 0) { - h5_mpiposix_io_t bytes_in = 0; /* # of bytes to read */ - h5_mpiposix_io_ret_t bytes_read = -1; /* # of bytes actually read */ + h5_posix_io_t bytes_in = 0; /* # of bytes to read */ + h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ /* Trying to read more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_MPIPOSIX_MAX_IO_BYTES_g) - bytes_in = H5_MPIPOSIX_MAX_IO_BYTES_g; + if(size > H5_POSIX_MAX_IO_BYTES) + bytes_in = H5_POSIX_MAX_IO_BYTES; else - bytes_in = (h5_mpiposix_io_t)size; + bytes_in = (h5_posix_io_t)size; do { bytes_read = HDread(file->fd, buf, bytes_in); @@ -1101,7 +1083,7 @@ H5FD_mpiposix_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, time_t mytime = HDtime(NULL); HDoff_t myoffset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, file descriptor = %d, errno = %d, error message = '%s', buf = %p, size = %lu, offset = %llu", HDctime(&mytime), file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long)size, (unsigned long long)myoffset); + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, file descriptor = %d, errno = %d, error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, bytes actually read = %llu, offset = %llu", HDctime(&mytime), file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)myoffset); } /* end if */ if(0 == bytes_read) { @@ -1265,16 +1247,16 @@ H5FD_mpiposix_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, */ while(size > 0) { - h5_mpiposix_io_t bytes_in = 0; /* # of bytes to write */ - h5_mpiposix_io_ret_t bytes_wrote = -1; /* # of bytes actually written */ + h5_posix_io_t bytes_in = 0; /* # of bytes to write */ + h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes actually written */ /* Trying to write more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_MPIPOSIX_MAX_IO_BYTES_g) - bytes_in = H5_MPIPOSIX_MAX_IO_BYTES_g; + if(size > H5_POSIX_MAX_IO_BYTES) + bytes_in = H5_POSIX_MAX_IO_BYTES; else - bytes_in = (h5_mpiposix_io_t)size; + bytes_in = (h5_posix_io_t)size; do { bytes_wrote = HDwrite(file->fd, buf, bytes_in); @@ -1285,7 +1267,7 @@ H5FD_mpiposix_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, time_t mytime = HDtime(NULL); HDoff_t myoffset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file write failed: time = %s, file descriptor = %d, errno = %d, error message = '%s', buf = %p, size = %lu, offset = %llu", HDctime(&mytime), file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long)size, (unsigned long long)myoffset); + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file write failed: time = %s, file descriptor = %d, errno = %d, error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = %llu, bytes actually written = %llu, offset = %llu", HDctime(&mytime), file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)myoffset); } /* end if */ if(0 == bytes_wrote) { diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 241609d..ca5127e 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -17,56 +17,41 @@ * Programmer: Robb Matzke <matzke@llnl.gov> * Thursday, July 29, 1999 * - * Purpose: The POSIX unbuffered file driver using only the HDF5 public - * API and with a few optimizations: the lseek() call is made - * only when the current file position is unknown or needs to be - * changed based on previous I/O through this driver (don't mix - * I/O from this driver with I/O from other parts of the - * application to the same file). + * Purpose: The POSIX unbuffered file driver using only the HDF5 public + * API and with a few optimizations: the lseek() call is made + * only when the current file position is unknown or needs to be + * changed based on previous I/O through this driver (don't mix + * I/O from this driver with I/O from other parts of the + * application to the same file). */ /* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FD_sec2_init_interface +#define H5_INTERFACE_INIT_FUNC H5FD_sec2_init_interface -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDsec2.h" /* Sec2 file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDsec2.h" /* Sec2 file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_SEC2_g = 0; -/* Since Windows doesn't follow the rest of the world when it comes - * to POSIX I/O types, some typedefs and constants are needed to avoid - * making the code messy with #ifdefs. - */ -#ifdef H5_HAVE_WIN32_API -typedef unsigned int h5_sec2_io_t; -typedef int h5_sec2_io_ret_t; -static int H5_SEC2_MAX_IO_BYTES_g = INT_MAX; -#else -/* Unix, everyone else */ -typedef size_t h5_sec2_io_t; -typedef ssize_t h5_sec2_io_ret_t; -static size_t H5_SEC2_MAX_IO_BYTES_g = SSIZET_MAX; -#endif /* H5_HAVE_WIN32_API */ - -/* The description of a file belonging to this driver. The `eoa' and `eof' +/* The description of a file belonging to this driver. The 'eoa' and 'eof' * determine the amount of hdf5 address space in use and the high-water mark * of the file (the current size of the underlying filesystem file). The - * `pos' value is used to eliminate file position updates when they would be a + * 'pos' value is used to eliminate file position updates when they would be a * no-op. Unfortunately we've found systems that use separate file position * indicators for reading and writing so the lseek can only be eliminated if * the current operation is the same as the previous operation. When opening - * a file the `eof' will be set to the current file size, `eoa' will be set - * to zero, `pos' will be set to H5F_ADDR_UNDEF (as it is when an error - * occurs), and `op' will be set to H5F_OP_UNKNOWN. + * a file the 'eof' will be set to the current file size, `eoa' will be set + * to zero, 'pos' will be set to H5F_ADDR_UNDEF (as it is when an error + * occurs), and 'op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_sec2_t { H5FD_t pub; /* public stuff, must be first */ @@ -123,29 +108,28 @@ typedef struct H5FD_sec2_t { * These macros check for overflow of various quantities. These macros * assume that HDoff_t is signed and haddr_t and size_t are unsigned. * - * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' - * is too large to be represented by the second argument - * of the file seek function. + * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' + * is too large to be represented by the second argument + * of the file seek function. * - * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too - * large to be represented by the `size_t' type. + * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too + * large to be represented by the `size_t' type. * - * REGION_OVERFLOW: Checks whether an address and size pair describe data - * which can be addressed entirely by the second - * argument of the file seek function. + * REGION_OVERFLOW: Checks whether an address and size pair describe data + * which can be addressed entirely by the second + * argument of the file seek function. */ #define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ - ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || \ - (HDoff_t)((A)+(Z))<(HDoff_t)(A)) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ + HADDR_UNDEF==(A)+(Z) || \ + (HDoff_t)((A)+(Z))<(HDoff_t)(A)) /* Prototypes */ static herr_t H5FD_sec2_term(void); static H5FD_t *H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); + haddr_t maxaddr); static herr_t H5FD_sec2_close(H5FD_t *_file); static int H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2); static herr_t H5FD_sec2_query(const H5FD_t *_f1, unsigned long *flags); @@ -154,63 +138,60 @@ static herr_t H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_sec2_get_eof(const H5FD_t *_file); static herr_t H5FD_sec2_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); static herr_t H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); + size_t size, void *buf); static herr_t H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); + size_t size, const void *buf); static herr_t H5FD_sec2_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); static const H5FD_class_t H5FD_sec2_g = { - "sec2", /*name */ - MAXADDR, /*maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_sec2_term, /*terminate */ - NULL, /*sb_size */ - NULL, /*sb_encode */ - NULL, /*sb_decode */ - 0, /*fapl_size */ - NULL, /*fapl_get */ - NULL, /*fapl_copy */ - NULL, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_sec2_open, /*open */ - H5FD_sec2_close, /*close */ - H5FD_sec2_cmp, /*cmp */ - H5FD_sec2_query, /*query */ - NULL, /*get_type_map */ - NULL, /*alloc */ - NULL, /*free */ - H5FD_sec2_get_eoa, /*get_eoa */ - H5FD_sec2_set_eoa, /*set_eoa */ - H5FD_sec2_get_eof, /*get_eof */ - H5FD_sec2_get_handle, /*get_handle */ - H5FD_sec2_read, /*read */ - H5FD_sec2_write, /*write */ - NULL, /*flush */ - H5FD_sec2_truncate, /*truncate */ - NULL, /*lock */ - NULL, /*unlock */ - H5FD_FLMAP_DICHOTOMY /*fl_map */ + "sec2", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_sec2_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + 0, /* fapl_size */ + NULL, /* fapl_get */ + NULL, /* fapl_copy */ + NULL, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD_sec2_open, /* open */ + H5FD_sec2_close, /* close */ + H5FD_sec2_cmp, /* cmp */ + H5FD_sec2_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD_sec2_get_eoa, /* get_eoa */ + H5FD_sec2_set_eoa, /* set_eoa */ + H5FD_sec2_get_eof, /* get_eof */ + H5FD_sec2_get_handle, /* get_handle */ + H5FD_sec2_read, /* read */ + H5FD_sec2_write, /* write */ + NULL, /* flush */ + H5FD_sec2_truncate, /* truncate */ + NULL, /* lock */ + NULL, /* unlock */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Declare a free list to manage the H5FD_sec2_t struct */ H5FL_DEFINE_STATIC(H5FD_sec2_t); -/*-------------------------------------------------------------------------- -NAME - H5FD_sec2_init_interface -- Initialize interface-specific information -USAGE - herr_t H5FD_sec2_init_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5FD_sec2_init currently). - ---------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * Function: H5FD_sec2_init_interface + * + * Purpose: Initializes any interface-specific data or routines. + * + * Return: Success: The driver ID for the sec2 driver. + * Failure: Negative + * + *------------------------------------------------------------------------- + */ static herr_t H5FD_sec2_init_interface(void) { @@ -221,15 +202,15 @@ H5FD_sec2_init_interface(void) /*------------------------------------------------------------------------- - * Function: H5FD_sec2_init + * Function: H5FD_sec2_init * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Return: Success: The driver ID for the sec2 driver. - * Failure: Negative. + * Return: Success: The driver ID for the sec2 driver. + * Failure: Negative * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -253,11 +234,11 @@ done: /*--------------------------------------------------------------------------- - * Function: H5FD_sec2_term + * Function: H5FD_sec2_term * - * Purpose: Shut down the VFD + * Purpose: Shut down the VFD * - * Returns: Non-negative on success or negative on failure + * Returns: SUCCEED (Can't fail) * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 @@ -277,16 +258,16 @@ H5FD_sec2_term(void) /*------------------------------------------------------------------------- - * Function: H5Pset_fapl_sec2 + * Function: H5Pset_fapl_sec2 * - * Purpose: Modify the file access property list to use the H5FD_SEC2 - * driver defined in this source file. There are no driver - * specific properties. + * Purpose: Modify the file access property list to use the H5FD_SEC2 + * driver defined in this source file. There are no driver + * specific properties. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * - * Programmer: Robb Matzke - * Thursday, February 19, 1998 + * Programmer: Robb Matzke + * Thursday, February 19, 1998 * *------------------------------------------------------------------------- */ @@ -310,16 +291,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_sec2_open + * Function: H5FD_sec2_open * - * Purpose: Create and/or opens a file as an HDF5 file. + * Purpose: Create and/or opens a file as an HDF5 file. * - * Return: Success: A pointer to a new file data structure. The - * public fields will be initialized by the - * caller, which is always H5FD_open(). - * Failure: NULL + * Return: Success: A pointer to a new file data structure. The + * public fields will be initialized by the + * caller, which is always H5FD_open(). + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -435,14 +416,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_sec2_close + * Function: H5FD_sec2_close * - * Purpose: Closes an HDF5 file. + * Purpose: Closes an HDF5 file. * - * Return: Success: 0 - * Failure: -1, file not closed. + * Return: Success: SUCCEED + * Failure: FAIL, file not closed. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -450,8 +431,8 @@ done: static herr_t H5FD_sec2_close(H5FD_t *_file) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -471,16 +452,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_sec2_cmp + * Function: H5FD_sec2_cmp * - * Purpose: Compares two files belonging to this driver using an - * arbitrary (but consistent) ordering. + * Purpose: Compares two files belonging to this driver using an + * arbitrary (but consistent) ordering. * - * Return: Success: A value like strcmp() - * Failure: never fails (arguments were checked by the - * caller). + * Return: Success: A value like strcmp() + * Failure: never fails (arguments were checked by the + * caller). * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -488,8 +469,8 @@ done: static int H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_sec2_t *f1 = (const H5FD_sec2_t *)_f1; - const H5FD_sec2_t *f2 = (const H5FD_sec2_t *)_f2; + const H5FD_sec2_t *f1 = (const H5FD_sec2_t *)_f1; + const H5FD_sec2_t *f2 = (const H5FD_sec2_t *)_f2; int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -530,15 +511,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_sec2_query + * Function: H5FD_sec2_query * - * Purpose: Set the flags that this VFL driver is capable of supporting. + * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * - * Return: Success: non-negative - * Failure: negative + * Return: SUCCEED (Can't fail) * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Friday, August 25, 2000 * *------------------------------------------------------------------------- @@ -569,21 +549,19 @@ H5FD_sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) /*------------------------------------------------------------------------- - * Function: H5FD_sec2_get_eoa + * Function: H5FD_sec2_get_eoa * - * Purpose: Gets the end-of-address marker for the file. The EOA marker - * is the first address past the last byte allocated in the - * format address space. + * Purpose: Gets the end-of-address marker for the file. The EOA marker + * is the first address past the last byte allocated in the + * format address space. * - * Return: Success: The end-of-address marker. - * Failure: HADDR_UNDEF + * Return: The end-of-address marker. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 2, 1999 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static haddr_t H5FD_sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) { @@ -596,21 +574,19 @@ H5FD_sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) /*------------------------------------------------------------------------- - * Function: H5FD_sec2_set_eoa + * Function: H5FD_sec2_set_eoa * - * Purpose: Set the end-of-address marker for the file. This function is - * called shortly after an existing HDF5 file is opened in order - * to tell the driver where the end of the HDF5 data is located. + * Purpose: Set the end-of-address marker for the file. This function is + * called shortly after an existing HDF5 file is opened in order + * to tell the driver where the end of the HDF5 data is located. * - * Return: Success: 0 - * Failure: -1 + * Return: SUCCEED (Can't fail) * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) { @@ -625,18 +601,16 @@ H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) /*------------------------------------------------------------------------- - * Function: H5FD_sec2_get_eof + * Function: H5FD_sec2_get_eof * - * Purpose: Returns the end-of-file marker, which is the greater of - * either the filesystem end-of-file or the HDF5 end-of-address - * markers. + * Purpose: Returns the end-of-file marker, which is the greater of + * either the filesystem end-of-file or the HDF5 end-of-address + * markers. * - * Return: Success: End of file address, the first address past - * the end of the "file", either the filesystem file - * or the HDF5 file. - * Failure: HADDR_UNDEF + * Return: End of file address, the first address past the end of the + * "file", either the filesystem file or the HDF5 file. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -644,7 +618,7 @@ H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) static haddr_t H5FD_sec2_get_eof(const H5FD_t *_file) { - const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; + const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -657,14 +631,13 @@ H5FD_sec2_get_eof(const H5FD_t *_file) * * Purpose: Returns the file handle of sec2 file driver. * - * Returns: Non-negative if succeed or negative if fails. + * Returns: SUCCEED/FAIL * * Programmer: Raymond Lu * Sept. 16, 2002 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5FD_sec2_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void **file_handle) { @@ -684,22 +657,21 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_sec2_read + * Function: H5FD_sec2_read * - * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR - * into buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR + * into buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero. Result is stored in caller-supplied - * buffer BUF. - * Failure: -1, Contents of buffer BUF are undefined. + * Return: Success: SUCCEED. Result is stored in caller-supplied + * buffer BUF. + * Failure: FAIL, Contents of buffer BUF are undefined. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, void *buf /*out*/) @@ -732,16 +704,16 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, */ while(size > 0) { - h5_sec2_io_t bytes_in = 0; /* # of bytes to read */ - h5_sec2_io_ret_t bytes_read = -1; /* # of bytes actually read */ + h5_posix_io_t bytes_in = 0; /* # of bytes to read */ + h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ /* Trying to read more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_SEC2_MAX_IO_BYTES_g) - bytes_in = H5_SEC2_MAX_IO_BYTES_g; + if(size > H5_POSIX_MAX_IO_BYTES) + bytes_in = H5_POSIX_MAX_IO_BYTES; else - bytes_in = (h5_sec2_io_t)size; + bytes_in = (h5_posix_io_t)size; do { bytes_read = HDread(file->fd, buf, bytes_in); @@ -752,7 +724,7 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, time_t mytime = HDtime(NULL); HDoff_t myoffset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, size = %lu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long)size, (unsigned long long)myoffset); + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, bytes actually read = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)myoffset); } /* end if */ if(0 == bytes_read) { @@ -785,21 +757,19 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_sec2_write + * Function: H5FD_sec2_write * - * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR - * from buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR + * from buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero - * Failure: -1 + * Return: SUCCEED/FAIL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, const void *buf) @@ -831,16 +801,16 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, */ while(size > 0) { - h5_sec2_io_t bytes_in = 0; /* # of bytes to write */ - h5_sec2_io_ret_t bytes_wrote = -1; /* # of bytes written */ + h5_posix_io_t bytes_in = 0; /* # of bytes to write */ + h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ /* Trying to write more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_SEC2_MAX_IO_BYTES_g) - bytes_in = H5_SEC2_MAX_IO_BYTES_g; + if(size > H5_POSIX_MAX_IO_BYTES) + bytes_in = H5_POSIX_MAX_IO_BYTES; else - bytes_in = (h5_sec2_io_t)size; + bytes_in = (h5_posix_io_t)size; do { bytes_wrote = HDwrite(file->fd, buf, bytes_in); @@ -851,7 +821,7 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, time_t mytime = HDtime(NULL); HDoff_t myoffset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, size = %lu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long)size, (unsigned long long)myoffset); + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = %llu, bytes actually written = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)myoffset); } /* end if */ HDassert(bytes_wrote > 0); @@ -880,20 +850,18 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_sec2_truncate + * Function: H5FD_sec2_truncate * - * Purpose: Makes sure that the true file size is the same (or larger) - * than the end-of-address. + * Purpose: Makes sure that the true file size is the same (or larger) + * than the end-of-address. * - * Return: Success: Non-negative - * Failure: Negative + * Return: SUCCEED/FAIL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5FD_sec2_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) { @@ -954,4 +922,3 @@ H5FD_sec2_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_sec2_truncate() */ - diff --git a/src/H5config.h.in b/src/H5config.h.in index fdbcd49..0308b38 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -74,6 +74,9 @@ /* Define if the function stack tracing code is to be compiled in */ #undef HAVE_CODESTACK +/* Define if Darwin or Mac OS X */ +#undef HAVE_DARWIN + /* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. */ #undef HAVE_DECL_TZNAME diff --git a/src/H5private.h b/src/H5private.h index 7dfd349..bff4e59 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -430,6 +430,24 @@ #define HSSIZET_MIN (~(HSSIZET_MAX)) /* + * Types and max sizes for POSIX I/O. + * OS X (Darwin) is odd since the max I/O size does not match the types. + */ +#if defined(H5_HAVE_WIN32_API) +# define h5_posix_io_t unsigned int +# define h5_posix_io_ret_t int +# define H5_POSIX_MAX_IO_BYTES INT_MAX +#elif defined(H5_HAVE_DARWIN) +# define h5_posix_io_t size_t +# define h5_posix_io_ret_t ssize_t +# define H5_POSIX_MAX_IO_BYTES INT_MAX +#else +# define h5_posix_io_t size_t +# define h5_posix_io_ret_t ssize_t +# define H5_POSIX_MAX_IO_BYTES SSIZET_MAX +#endif + +/* * A macro to portably increment enumerated types. */ #ifndef H5_INC_ENUM diff --git a/src/H5public.h b/src/H5public.h index 5d9e3ef..24f49a7 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -75,10 +75,10 @@ extern "C" { /* Version numbers */ #define H5_VERS_MAJOR 1 /* For major interface/format changes */ #define H5_VERS_MINOR 9 /* For minor interface/format changes */ -#define H5_VERS_RELEASE 136 /* For tweaks, bug-fixes, or development */ +#define H5_VERS_RELEASE 140 /* For tweaks, bug-fixes, or development */ #define H5_VERS_SUBRELEASE "" /* For pre-releases like snap0 */ /* Empty string for real releases. */ -#define H5_VERS_INFO "HDF5 library version: 1.9.136" /* Full version string */ +#define H5_VERS_INFO "HDF5 library version: 1.9.140" /* Full version string */ #define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ H5_VERS_RELEASE) diff --git a/src/Makefile.in b/src/Makefile.in index fc89be5..e4a29e7 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -522,7 +522,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 126 +LT_VERS_REVISION = 130 LT_VERS_AGE = 0 H5detect_CFLAGS = -g $(AM_CFLAGS) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5551fa3..8d40c25 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -148,8 +148,8 @@ SET (HDF5_REFERENCE_TEST_FILES tarrold.h5 tbad_msg_count.h5 tbogus.h5 - test_filters_be.hdf5 - test_filters_le.hdf5 + test_filters_be.h5 + test_filters_le.h5 th5s.h5 tlayouto.h5 tmtimen.h5 diff --git a/test/dsets.c b/test/dsets.c index 3b081da..838ef48 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -6571,7 +6571,7 @@ test_filters_endianess(void) hid_t dsid=-1; /* dataset ID */ hid_t sid=-1; /* dataspace ID */ hid_t dcpl=-1; /* dataset creation property list ID */ - const char *data_file = H5_get_srcdir_filename("test_filters_le.hdf5"); /* Corrected test file name */ + const char *data_file = H5_get_srcdir_filename("test_filters_le.h5"); /* Corrected test file name */ TESTING("filters with big-endian/little-endian data"); @@ -6596,7 +6596,7 @@ test_filters_endianess(void) */ /* compose the name of the file to open, using the srcdir, if appropriate */ - data_file = H5_get_srcdir_filename("test_filters_be.hdf5"); /* Corrected test file name */ + data_file = H5_get_srcdir_filename("test_filters_be.h5"); /* Corrected test file name */ /* open */ if((fid = H5Fopen(data_file, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR diff --git a/test/test_filters_be.hdf5 b/test/test_filters_be.h5 Binary files differindex c4c127b..c4c127b 100644 --- a/test/test_filters_be.hdf5 +++ b/test/test_filters_be.h5 diff --git a/test/test_filters_le.hdf5 b/test/test_filters_le.h5 Binary files differindex ff8b846..ff8b846 100644 --- a/test/test_filters_le.hdf5 +++ b/test/test_filters_le.h5 diff --git a/vms/src/h5pubconf.h b/vms/src/h5pubconf.h index f0d6962..22662ba 100644 --- a/vms/src/h5pubconf.h +++ b/vms/src/h5pubconf.h @@ -502,7 +502,7 @@ #define H5_PACKAGE_NAME "HDF5" /* Define to the full name and version of this package. */ -#define H5_PACKAGE_STRING "HDF5 1.9.136" +#define H5_PACKAGE_STRING "HDF5 1.9.140" /* Define to the one symbol short name of this package. */ #define H5_PACKAGE_TARNAME "hdf5" @@ -511,7 +511,7 @@ #define H5_PACKAGE_URL "" /* Define to the version of this package. */ -#define H5_PACKAGE_VERSION "1.9.136" +#define H5_PACKAGE_VERSION "1.9.140" /* Width for printf() for type `long long' or `__int64', use `ll' */ #define H5_PRINTF_LL_WIDTH "ll" @@ -674,7 +674,7 @@ /* #undef H5_USING_MEMCHECKER */ /* Version number of package */ -#define H5_VERSION "1.9.136" +#define H5_VERSION "1.9.140" /* Define if vsnprintf() returns the correct value for formatted strings that don't fit into size allowed */ |