summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2018-03-13 01:06:20 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2018-03-13 01:06:20 (GMT)
commitc76411768fe93ae6e8b720137bcfdbcc31639d6d (patch)
tree19e960f9cfb1ef04b11da2b4c65be12b0964722d
parent2d4d39d15763042661347e5a16de6cf154537dda (diff)
parenta8afb3ab3b32b07611fb5932303dd0594a1c9658 (diff)
downloadhdf5-c76411768fe93ae6e8b720137bcfdbcc31639d6d.zip
hdf5-c76411768fe93ae6e8b720137bcfdbcc31639d6d.tar.gz
hdf5-c76411768fe93ae6e8b720137bcfdbcc31639d6d.tar.bz2
Merge branch 'develop' of https://bitbucket.hdfgroup.org/scm/~bmribler/hdf5_bmr_cpp3 into develop
-rw-r--r--CMakeLists.txt13
-rw-r--r--MANIFEST30
-rw-r--r--c++/CMakeLists.txt2
-rw-r--r--c++/examples/CMakeLists.txt2
-rw-r--r--c++/src/CMakeLists.txt2
-rw-r--r--c++/test/CMakeLists.txt2
-rwxr-xr-xconfig/cmake/CTestScript.cmake2
-rw-r--r--config/cmake/HDF518_Examples.cmake.in2
-rw-r--r--config/cmake/HDF5_Examples.cmake.in2
-rw-r--r--config/cmake/UseJava.cmake74
-rwxr-xr-xconfig/cmake/scripts/CTestScript.cmake2
-rwxr-xr-xconfig/cmake/scripts/HDF5config.cmake2
-rw-r--r--config/cmake_ext_mod/FindMPI.cmake1514
-rw-r--r--config/cmake_ext_mod/FindMPI/fortranparam_mpi.f90.in4
-rw-r--r--config/cmake_ext_mod/FindMPI/libver_mpi.c19
-rw-r--r--config/cmake_ext_mod/FindMPI/libver_mpi.f90.in7
-rw-r--r--config/cmake_ext_mod/FindMPI/mpiver.f90.in10
-rw-r--r--config/cmake_ext_mod/FindMPI/test_mpi.c37
-rw-r--r--config/cmake_ext_mod/FindMPI/test_mpi.f90.in6
-rw-r--r--examples/CMakeLists.txt2
-rw-r--r--fortran/CMakeLists.txt2
-rw-r--r--fortran/examples/CMakeLists.txt2
-rw-r--r--fortran/src/CMakeLists.txt6
-rw-r--r--fortran/test/CMakeLists.txt2
-rw-r--r--fortran/testpar/CMakeLists.txt2
-rw-r--r--hl/CMakeLists.txt2
-rw-r--r--hl/c++/CMakeLists.txt2
-rw-r--r--hl/c++/examples/CMakeLists.txt2
-rw-r--r--hl/c++/src/CMakeLists.txt2
-rw-r--r--hl/c++/test/CMakeLists.txt2
-rw-r--r--hl/examples/CMakeLists.txt2
-rw-r--r--hl/fortran/CMakeLists.txt2
-rw-r--r--hl/fortran/examples/CMakeLists.txt2
-rw-r--r--hl/fortran/src/CMakeLists.txt46
-rw-r--r--hl/fortran/test/CMakeLists.txt2
-rw-r--r--hl/src/CMakeLists.txt2
-rw-r--r--hl/test/CMakeLists.txt2
-rw-r--r--hl/tools/CMakeLists.txt2
-rw-r--r--hl/tools/gif2h5/CMakeLists.txt2
-rw-r--r--hl/tools/h5watch/CMakeLists.txt2
-rw-r--r--java/CMakeLists.txt2
-rw-r--r--java/examples/CMakeLists.txt2
-rw-r--r--java/examples/datasets/CMakeLists.txt2
-rw-r--r--java/examples/datatypes/CMakeLists.txt2
-rw-r--r--java/examples/groups/CMakeLists.txt2
-rw-r--r--java/examples/intro/CMakeLists.txt2
-rw-r--r--java/src/CMakeLists.txt2
-rw-r--r--java/src/hdf/CMakeLists.txt2
-rw-r--r--java/src/hdf/hdf5lib/CMakeLists.txt2
-rw-r--r--java/src/jni/CMakeLists.txt2
-rw-r--r--java/test/CMakeLists.txt2
-rw-r--r--release_docs/INSTALL_CMake.txt2
-rw-r--r--release_docs/RELEASE.txt10
-rw-r--r--release_docs/USING_HDF5_CMake.txt4
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/H5F.c94
-rw-r--r--src/H5FDmpio.c154
-rw-r--r--src/H5FDprivate.h1
-rw-r--r--src/H5Fint.c50
-rw-r--r--src/H5Fpkg.h3
-rw-r--r--src/H5Fprivate.h4
-rw-r--r--src/H5Fpublic.h2
-rw-r--r--src/H5Fsuper.c112
-rw-r--r--src/H5Ocache.c39
-rw-r--r--src/H5Oint.c1
-rw-r--r--src/H5Opkg.h1
-rw-r--r--src/H5Pfapl.c21
-rw-r--r--test/CMakeLists.txt2
-rw-r--r--test/gen_bounds.c25
-rw-r--r--test/tfile.c128
-rw-r--r--testpar/CMakeLists.txt2
-rw-r--r--testpar/t_bigio.c395
-rw-r--r--testpar/t_span_tree.c9
-rw-r--r--tools/CMakeLists.txt2
-rw-r--r--tools/lib/CMakeLists.txt2
-rw-r--r--tools/src/CMakeLists.txt2
-rw-r--r--tools/src/h5copy/CMakeLists.txt2
-rw-r--r--tools/src/h5diff/CMakeLists.txt2
-rw-r--r--tools/src/h5dump/CMakeLists.txt2
-rw-r--r--tools/src/h5format_convert/CMakeLists.txt2
-rw-r--r--tools/src/h5import/CMakeLists.txt2
-rw-r--r--tools/src/h5jam/CMakeLists.txt2
-rw-r--r--tools/src/h5ls/CMakeLists.txt2
-rw-r--r--tools/src/h5repack/CMakeLists.txt2
-rw-r--r--tools/src/h5stat/CMakeLists.txt2
-rw-r--r--tools/src/misc/CMakeLists.txt2
-rw-r--r--tools/src/misc/h5clear.c158
-rw-r--r--tools/test/CMakeLists.txt2
-rw-r--r--tools/test/h5copy/CMakeLists.txt2
-rw-r--r--tools/test/h5diff/CMakeLists.txt2
-rw-r--r--tools/test/h5dump/CMakeLists.txt2
-rw-r--r--tools/test/h5format_convert/CMakeLists.txt2
-rw-r--r--tools/test/h5import/CMakeLists.txt2
-rw-r--r--tools/test/h5jam/CMakeLists.txt2
-rw-r--r--tools/test/h5ls/CMakeLists.txt2
-rw-r--r--tools/test/h5repack/CMakeLists.txt2
-rw-r--r--tools/test/h5stat/CMakeLists.txt2
-rw-r--r--tools/test/misc/CMakeLists.txt2
-rw-r--r--tools/test/misc/CMakeTestsClear.cmake100
-rw-r--r--tools/test/misc/h5clear_gentest.c369
-rw-r--r--tools/test/misc/testfiles/h5clear_equal_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_equal_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_equal.h5bin0 -> 2565 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_greater.h5bin0 -> 2565 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_less.h5bin0 -> 2565 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_noclose.h5bin0 -> 2448 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_user_equal.h5bin0 -> 3077 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_user_greater.h5bin0 -> 3077 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_user_less.h5bin0 -> 3077 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_greater_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_greater_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_less_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_less_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_missing_file.ddl10
-rw-r--r--tools/test/misc/testfiles/h5clear_noclose_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_noclose_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_status_noclose.h5bin0 -> 2448 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_status_noclose_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_usage.ddl10
-rw-r--r--tools/test/misc/testfiles/h5clear_user_equal_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_user_equal_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_user_greater_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_user_greater_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_user_less_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_user_less_before_size.ddl1
-rw-r--r--tools/test/misc/testh5clear.sh.in122
-rw-r--r--tools/test/misc/vds/CMakeLists.txt2
-rw-r--r--tools/test/perform/CMakeLists.txt2
128 files changed, 1582 insertions, 2159 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e7dda17..5ac4c60 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5 C CXX)
#-----------------------------------------------------------------------------
@@ -671,12 +671,6 @@ if (HDF5_ENABLE_THREADSAFE)
endif ()
endif ()
-# -----------------------------------------------------------------------
-# wrapper script variables
-#
-#set (CFLAGS "${C_DEFINES}")
-#set (CXXFLAGS "${CXX_DEFINES}")
-
#-----------------------------------------------------------------------------
# Add the HDF5 Library Target to the build
#-----------------------------------------------------------------------------
@@ -806,11 +800,6 @@ if (EXISTS "${HDF5_SOURCE_DIR}/fortran" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/for
endif ()
endif ()
- # -----------------------------------------------------------------------
- # wrapper script variables
- #
-# set (FCFLAGS "${Fortran_DEFINES}")
-
add_subdirectory (fortran)
if (HDF5_BUILD_HL_LIB)
if (EXISTS "${HDF5_SOURCE_DIR}/hl/fortran" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/hl/fortran")
diff --git a/MANIFEST b/MANIFEST
index 805c8d9..df368aa 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1488,15 +1488,38 @@
./tools/test/misc/testh5mkgrp.sh.in
./tools/test/misc/testh5repart.sh.in
./tools/test/misc/talign.c
+./tools/test/misc/testfiles/h5clear_equal_after_size.ddl
+./tools/test/misc/testfiles/h5clear_equal_before_size.ddl
+./tools/test/misc/testfiles/h5clear_greater_after_size.ddl
+./tools/test/misc/testfiles/h5clear_greater_before_size.ddl
+./tools/test/misc/testfiles/h5clear_less_after_size.ddl
+./tools/test/misc/testfiles/h5clear_less_before_size.ddl
./tools/test/misc/testfiles/h5clear_missing_file.ddl
+./tools/test/misc/testfiles/h5clear_noclose_after_size.ddl
+./tools/test/misc/testfiles/h5clear_noclose_before_size.ddl
./tools/test/misc/testfiles/h5clear_no_mdc_image.ddl
./tools/test/misc/testfiles/h5clear_open_fail.ddl
+./tools/test/misc/testfiles/h5clear_status_noclose_after_size.ddl
./tools/test/misc/testfiles/h5clear_usage.ddl
+./tools/test/misc/testfiles/h5clear_user_equal_after_size.ddl
+./tools/test/misc/testfiles/h5clear_user_equal_before_size.ddl
+./tools/test/misc/testfiles/h5clear_user_greater_after_size.ddl
+./tools/test/misc/testfiles/h5clear_user_greater_before_size.ddl
+./tools/test/misc/testfiles/h5clear_user_less_after_size.ddl
+./tools/test/misc/testfiles/h5clear_user_less_before_size.ddl
+./tools/test/misc/testfiles/h5clear_fsm_persist_equal.h5
+./tools/test/misc/testfiles/h5clear_fsm_persist_greater.h5
+./tools/test/misc/testfiles/h5clear_fsm_persist_less.h5
+./tools/test/misc/testfiles/h5clear_fsm_persist_noclose.h5
+./tools/test/misc/testfiles/h5clear_fsm_persist_user_equal.h5
+./tools/test/misc/testfiles/h5clear_fsm_persist_user_greater.h5
+./tools/test/misc/testfiles/h5clear_fsm_persist_user_less.h5
./tools/test/misc/testfiles/h5clear_log_v3.h5
./tools/test/misc/testfiles/h5clear_mdc_image.h5
./tools/test/misc/testfiles/h5clear_sec2_v0.h5
./tools/test/misc/testfiles/h5clear_sec2_v2.h5
./tools/test/misc/testfiles/h5clear_sec2_v3.h5
+./tools/test/misc/testfiles/h5clear_status_noclose.h5
./tools/test/misc/testfiles/latest_h5clear_log_v3.h5
./tools/test/misc/testfiles/latest_h5clear_sec2_v3.h5
./tools/test/misc/testfiles/mod_h5clear_mdc_image.h5
@@ -3101,7 +3124,6 @@
./config/cmake_ext_mod/ConfigureChecks.cmake
./config/cmake_ext_mod/CTestCustom.cmake
-./config/cmake_ext_mod/FindMPI.cmake
./config/cmake_ext_mod/FindSZIP.cmake
./config/cmake_ext_mod/GetTimeOfDayTest.cpp
./config/cmake_ext_mod/grepTest.cmake
@@ -3117,12 +3139,6 @@
./config/cmake_ext_mod/NSIS.template.in
./config/cmake_ext_mod/runTest.cmake
./config/cmake_ext_mod/version.plist.in
-./config/cmake_ext_mod/FindMPI/fortranparam_mpi.f90.in
-./config/cmake_ext_mod/FindMPI/libver_mpi.c
-./config/cmake_ext_mod/FindMPI/libver_mpi.f90.in
-./config/cmake_ext_mod/FindMPI/mpiver.f90.in
-./config/cmake_ext_mod/FindMPI/test_mpi.c
-./config/cmake_ext_mod/FindMPI/test_mpi.f90.in
# CMake-specific User Files
./config/cmake/UserMacros/Windows_MT.cmake
diff --git a/c++/CMakeLists.txt b/c++/CMakeLists.txt
index 2d3ab0f..2c161f1 100644
--- a/c++/CMakeLists.txt
+++ b/c++/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_CPP)
#-----------------------------------------------------------------------------
diff --git a/c++/examples/CMakeLists.txt b/c++/examples/CMakeLists.txt
index 397c300..22ecb19 100644
--- a/c++/examples/CMakeLists.txt
+++ b/c++/examples/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_CPP_EXAMPLES)
# --------------------------------------------------------------------
diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt
index 5d0d6b6..1136d6a 100644
--- a/c++/src/CMakeLists.txt
+++ b/c++/src/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_CPP_SRC)
#-----------------------------------------------------------------------------
diff --git a/c++/test/CMakeLists.txt b/c++/test/CMakeLists.txt
index 5194865..b4fb0fc 100644
--- a/c++/test/CMakeLists.txt
+++ b/c++/test/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_CPP_TEST)
# --------------------------------------------------------------------
# Notes: When creating unit test executables they should be prefixed
diff --git a/config/cmake/CTestScript.cmake b/config/cmake/CTestScript.cmake
index 27ae3a0..0269ba8 100755
--- a/config/cmake/CTestScript.cmake
+++ b/config/cmake/CTestScript.cmake
@@ -9,7 +9,7 @@
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
-cmake_minimum_required (VERSION 3.3.2 FATAL_ERROR)
+cmake_minimum_required (VERSION 3.10)
########################################################
# For any comments please contact cdashhelp@hdfgroup.org
#
diff --git a/config/cmake/HDF518_Examples.cmake.in b/config/cmake/HDF518_Examples.cmake.in
index 0e81217..1f4f479 100644
--- a/config/cmake/HDF518_Examples.cmake.in
+++ b/config/cmake/HDF518_Examples.cmake.in
@@ -9,7 +9,7 @@
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
-cmake_minimum_required (VERSION 3.3.2 FATAL_ERROR)
+cmake_minimum_required (VERSION 3.10)
###############################################################################################################
# This script will build and run the examples from a folder
# Execute from a command line:
diff --git a/config/cmake/HDF5_Examples.cmake.in b/config/cmake/HDF5_Examples.cmake.in
index 6453b16..eb57685 100644
--- a/config/cmake/HDF5_Examples.cmake.in
+++ b/config/cmake/HDF5_Examples.cmake.in
@@ -9,7 +9,7 @@
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
-cmake_minimum_required (VERSION 3.3.2 FATAL_ERROR)
+cmake_minimum_required (VERSION 3.10)
###############################################################################################################
# This script will build and run the examples from a folder
# Execute from a command line:
diff --git a/config/cmake/UseJava.cmake b/config/cmake/UseJava.cmake
index c70f52e..60b1758 100644
--- a/config/cmake/UseJava.cmake
+++ b/config/cmake/UseJava.cmake
@@ -19,6 +19,7 @@
# [VERSION version]
# [OUTPUT_NAME name]
# [OUTPUT_DIR dir]
+# [GENERATE_NATIVE_HEADERS target [DESTINATION dir]]
# )
#
# This command creates a <target_name>.jar. It compiles the given
@@ -34,6 +35,14 @@
# The default OUTPUT_DIR can also be changed by setting the variable
# CMAKE_JAVA_TARGET_OUTPUT_DIR.
#
+# Optionally, using option GENERATE_NATIVE_HEADERS, native header files can be generated
+# for methods declared as native. These files provide the connective glue that allow your
+# Java and C code to interact. An INTERFACE target will be created for an easy usage
+# of generated files. Sub-option DESTINATION can be used to specify output directory for
+# generated header files.
+#
+# GENERATE_NATIVE_HEADERS option requires, at least, version 1.8 of the JDK.
+#
# Additional instructions:
#
# ::
@@ -167,6 +176,22 @@
#
#
#
+# ::
+#
+# For an optimum usage of option GENERATE_NATIVE_HEADERS, it is recommended to
+# include module JNI before any call to add_jar. The produced target for native
+# headers can then be used to compile C/C++ sources with command
+# target_link_libraries.
+#
+#
+# ::
+#
+# find_package(JNI)
+# add_jar(foo foo.java GENERATE_NATIVE_HEADERS foo-native)
+# add_library(bar bar.cpp)
+# target_link_libraries(bar PRIVATE foo-native)
+#
+#
# Target Properties:
#
# ::
@@ -358,6 +383,10 @@
# Create C header files from java classes. These files provide the connective glue
# that allow your Java and C code to interact.
#
+# This command will no longer be supported starting with version 1.10 of the JDK due
+# to the `suppression of javah tool <http://openjdk.java.net/jeps/313>`_.
+# Command ``add_jar(GENERATE_NATIVE_HEADERS)`` must be used instead.
+#
# There are two main signatures for create_javah. The first signature
# returns generated files through variable specified by GENERATED_FILES option:
#
@@ -449,7 +478,7 @@ function(add_jar _TARGET_NAME)
cmake_parse_arguments(_add_jar
""
"VERSION;OUTPUT_DIR;OUTPUT_NAME;ENTRY_POINT;MANIFEST"
- "SOURCES;INCLUDE_JARS"
+ "SOURCES;INCLUDE_JARS;GENERATE_NATIVE_HEADERS"
${ARGN}
)
@@ -495,6 +524,31 @@ function(add_jar _TARGET_NAME)
get_filename_component (_MANIFEST_VALUE "${_add_jar_MANIFEST}" ABSOLUTE)
endif ()
+ unset (_GENERATE_NATIVE_HEADERS)
+ if (_add_jar_GENERATE_NATIVE_HEADERS)
+ # Raise an error if JDK version is less than 1.8 because javac -h is not supported
+ # by earlier versions.
+ if ("${Java_VERSION}" VERSION_LESS 1.8)
+ message (FATAL_ERROR "ADD_JAR: GENERATE_NATIVE_HEADERS is not supported with this version of Java.")
+ endif()
+ cmake_parse_arguments (_add_jar_GENERATE_NATIVE_HEADERS "" "DESTINATION" "" ${_add_jar_GENERATE_NATIVE_HEADERS})
+ if (NOT _add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS)
+ message (FATAL_ERROR "ADD_JAR: GENERATE_NATIVE_HEADERS: missing required argument.")
+ endif()
+ list (LENGTH _add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS length)
+ if (length GREATER 1)
+ list (REMOVE_AT _add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS 0)
+ message (FATAL_ERROR "ADD_JAR: GENERATE_NATIVE_HEADERS: ${_add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS}: unexpected argument(s).")
+ endif()
+ if (NOT _add_jar_GENERATE_NATIVE_HEADERS_DESTINATION)
+ set (_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir/native_headers")
+ endif()
+
+ set (_GENERATE_NATIVE_HEADERS_TARGET ${_add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS})
+ set (_GENERATE_NATIVE_HEADERS_OUTPUT_DIR "${_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION}")
+ set (_GENERATE_NATIVE_HEADERS -h "${_GENERATE_NATIVE_HEADERS_OUTPUT_DIR}")
+ endif()
+
if (LIBRARY_OUTPUT_PATH)
set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH})
else ()
@@ -626,6 +680,7 @@ function(add_jar _TARGET_NAME)
${CMAKE_JAVA_COMPILE_FLAGS}
-classpath "${CMAKE_JAVA_INCLUDE_PATH_FINAL}"
-d ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
+ ${_GENERATE_NATIVE_HEADERS}
${_JAVA_SOURCES_FILELISTS}
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_FILELISTS} ${_JAVA_COMPILE_DEPENDS}
@@ -736,6 +791,17 @@ function(add_jar _TARGET_NAME)
${CMAKE_JAVA_CLASS_OUTPUT_PATH}
)
+ if (_GENERATE_NATIVE_HEADERS)
+ # create an INTERFACE library encapsulating include directory for generated headers
+ add_library (${_GENERATE_NATIVE_HEADERS_TARGET} INTERFACE)
+ target_include_directories (${_GENERATE_NATIVE_HEADERS_TARGET} INTERFACE
+ "${_GENERATE_NATIVE_HEADERS_OUTPUT_DIR}"
+ ${JNI_INCLUDE_DIRS})
+ # this INTERFACE library depends on jar generation
+ add_dependencies (${_GENERATE_NATIVE_HEADERS_TARGET} ${_TARGET_NAME})
+
+ set_property (DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_GENERATE_NATIVE_HEADERS_OUTPUT_DIR}")
+ endif()
endfunction()
function(INSTALL_JAR _TARGET_NAME)
@@ -1307,6 +1373,12 @@ function(create_javadoc _target)
endfunction()
function (create_javah)
+ if ("${Java_VERSION}" VERSION_GREATER_EQUAL 1.10)
+ message (FATAL_ERROR "create_javah: not supported with this Java version. Use add_jar(GENERATE_NATIVE_HEADERS) instead.")
+ elseif ("${Java_VERSION}" VERSION_GREATER_EQUAL 1.8)
+ message (DEPRECATION "create_javah: this command will no longer be supported starting with version 1.10 of JDK. Update your project by using command add_jar(GENERATE_NATIVE_HEADERS) instead.")
+ endif()
+
cmake_parse_arguments(_create_javah
""
"TARGET;GENERATED_FILES;OUTPUT_NAME;OUTPUT_DIR"
diff --git a/config/cmake/scripts/CTestScript.cmake b/config/cmake/scripts/CTestScript.cmake
index cfad6f1..670196b 100755
--- a/config/cmake/scripts/CTestScript.cmake
+++ b/config/cmake/scripts/CTestScript.cmake
@@ -9,7 +9,7 @@
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
-cmake_minimum_required (VERSION 3.3.2 FATAL_ERROR)
+cmake_minimum_required (VERSION 3.10)
########################################################
# This dashboard is maintained by The HDF Group
# For any comments please contact cdashhelp@hdfgroup.org
diff --git a/config/cmake/scripts/HDF5config.cmake b/config/cmake/scripts/HDF5config.cmake
index 88843fa..7eaf80a 100755
--- a/config/cmake/scripts/HDF5config.cmake
+++ b/config/cmake/scripts/HDF5config.cmake
@@ -15,7 +15,7 @@
### ctest -S HDF5config.cmake,BUILD_GENERATOR=VS201764 -C Release -VV -O hdf5.log ###
#############################################################################################
-cmake_minimum_required (VERSION 3.3.2 FATAL_ERROR)
+cmake_minimum_required (VERSION 3.10)
############################################################################
# Usage:
# ctest -S HDF5config.cmake,OPTION=VALUE -C Release -VV -O test.log
diff --git a/config/cmake_ext_mod/FindMPI.cmake b/config/cmake_ext_mod/FindMPI.cmake
deleted file mode 100644
index d01dd35..0000000
--- a/config/cmake_ext_mod/FindMPI.cmake
+++ /dev/null
@@ -1,1514 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See https://cmake.org/licensing for details.
-
-#.rst:
-# FindMPI
-# -------
-#
-# Find a Message Passing Interface (MPI) implementation.
-#
-# The Message Passing Interface (MPI) is a library used to write
-# high-performance distributed-memory parallel applications, and is
-# typically deployed on a cluster. MPI is a standard interface (defined
-# by the MPI forum) for which many implementations are available.
-#
-# Variables for using MPI
-# ^^^^^^^^^^^^^^^^^^^^^^^
-#
-# The module exposes the components ``C``, ``CXX``, ``MPICXX`` and ``Fortran``.
-# Each of these controls the various MPI languages to search for.
-# The difference between ``CXX`` and ``MPICXX`` is that ``CXX`` refers to the
-# MPI C API being usable from C++, whereas ``MPICXX`` refers to the MPI-2 C++ API
-# that was removed again in MPI-3.
-#
-# Depending on the enabled components the following variables will be set:
-#
-# ``MPI_FOUND``
-# Variable indicating that MPI settings for all requested languages have been found.
-# If no components are specified, this is true if MPI settings for all enabled languages
-# were detected. Note that the ``MPICXX`` component does not affect this variable.
-# ``MPI_VERSION``
-# Minimal version of MPI detected among the requested languages, or all enabled languages
-# if no components were specified.
-#
-# This module will set the following variables per language in your
-# project, where ``<lang>`` is one of C, CXX, or Fortran:
-#
-# ``MPI_<lang>_FOUND``
-# Variable indicating the MPI settings for ``<lang>`` were found and that
-# simple MPI test programs compile with the provided settings.
-# ``MPI_<lang>_COMPILER``
-# MPI compiler for ``<lang>`` if such a program exists.
-# ``MPI_<lang>_COMPILE_OPTIONS``
-# Compilation options for MPI programs in ``<lang>``, given as a :ref:`;-list <CMake Language Lists>`.
-# ``MPI_<lang>_COMPILE_DEFINITIONS``
-# Compilation definitions for MPI programs in ``<lang>``, given as a :ref:`;-list <CMake Language Lists>`.
-# ``MPI_<lang>_INCLUDE_DIRS``
-# Include path(s) for MPI header.
-# ``MPI_<lang>_LINK_FLAGS``
-# Linker flags for MPI programs.
-# ``MPI_<lang>_LIBRARIES``
-# All libraries to link MPI programs against.
-#
-# Additionally, the following :prop_tgt:`IMPORTED` targets are defined:
-#
-# ``MPI::MPI_<lang>``
-# Target for using MPI from ``<lang>``.
-#
-# The following variables indicating which bindings are present will be defined:
-#
-# ``MPI_MPICXX_FOUND``
-# Variable indicating whether the MPI-2 C++ bindings are present (introduced in MPI-2, removed with MPI-3).
-# ``MPI_Fortran_HAVE_F77_HEADER``
-# True if the Fortran 77 header ``mpif.h`` is available.
-# ``MPI_Fortran_HAVE_F90_MODULE``
-# True if the Fortran 90 module ``mpi`` can be used for accessing MPI (MPI-2 and higher only).
-# ``MPI_Fortran_HAVE_F08_MODULE``
-# True if the Fortran 2008 ``mpi_f08`` is available to MPI programs (MPI-3 and higher only).
-#
-# If possible, the MPI version will be determined by this module. The facilities to detect the MPI version
-# were introduced with MPI-1.2, and therefore cannot be found for older MPI versions.
-#
-# ``MPI_<lang>_VERSION_MAJOR``
-# Major version of MPI implemented for ``<lang>`` by the MPI distribution.
-# ``MPI_<lang>_VERSION_MINOR``
-# Minor version of MPI implemented for ``<lang>`` by the MPI distribution.
-# ``MPI_<lang>_VERSION``
-# MPI version implemented for ``<lang>`` by the MPI distribution.
-#
-# Note that there's no variable for the C bindings being accessible through ``mpi.h``, since the MPI standards
-# always have required this binding to work in both C and C++ code.
-#
-# For running MPI programs, the module sets the following variables
-#
-# ``MPIEXEC_EXECUTABLE``
-# Executable for running MPI programs, if such exists.
-# ``MPIEXEC_NUMPROC_FLAG``
-# Flag to pass to ``mpiexec`` before giving it the number of processors to run on.
-# ``MPIEXEC_MAX_NUMPROCS``
-# Number of MPI processors to utilize. Defaults to the number
-# of processors detected on the host system.
-# ``MPIEXEC_PREFLAGS``
-# Flags to pass to ``mpiexec`` directly before the executable to run.
-# ``MPIEXEC_POSTFLAGS``
-# Flags to pass to ``mpiexec`` after other flags.
-#
-# Variables for locating MPI
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# This module performs a three step search for an MPI implementation:
-#
-# 1. Check if the compiler has MPI support built-in. This is the case if the user passed a
-# compiler wrapper as ``CMAKE_<LANG>_COMPILER`` or if they're on a Cray system.
-# 2. Attempt to find an MPI compiler wrapper and determine the compiler information from it.
-# 3. Try to find an MPI implementation that does not ship such a wrapper by guessing settings.
-# Currently, only Microsoft MPI and MPICH2 on Windows are supported.
-#
-# For controlling the second step, the following variables may be set:
-#
-# ``MPI_<lang>_COMPILER``
-# Search for the specified compiler wrapper and use it.
-# ``MPI_<lang>_COMPILER_FLAGS``
-# Flags to pass to the MPI compiler wrapper during interrogation. Some compiler wrappers
-# support linking debug or tracing libraries if a specific flag is passed and this variable
-# may be used to obtain them.
-# ``MPI_COMPILER_FLAGS``
-# Used to initialize ``MPI_<lang>_COMPILER_FLAGS`` if no language specific flag has been given.
-# Empty by default.
-# ``MPI_EXECUTABLE_SUFFIX``
-# A suffix which is appended to all names that are being looked for. For instance you may set this
-# to ``.mpich`` or ``.openmpi`` to prefer the one or the other on Debian and its derivatives.
-#
-# In order to control the guessing step, the following variable may be set:
-#
-# ``MPI_GUESS_LIBRARY_NAME``
-# Valid values are ``MSMPI`` and ``MPICH2``. If set, only the given library will be searched for.
-# By default, ``MSMPI`` will be preferred over ``MPICH2`` if both are available.
-# This also sets ``MPI_SKIP_COMPILER_WRAPPER`` to ``true``, which may be overridden.
-#
-# Each of the search steps may be skipped with the following control variables:
-#
-# ``MPI_ASSUME_NO_BUILTIN_MPI``
-# If true, the module assumes that the compiler itself does not provide an MPI implementation and
-# skips to step 2.
-# ``MPI_SKIP_COMPILER_WRAPPER``
-# If true, no compiler wrapper will be searched for.
-# ``MPI_SKIP_GUESSING``
-# If true, the guessing step will be skipped.
-#
-# Additionally, the following control variable is available to change search behavior:
-#
-# ``MPI_CXX_SKIP_MPICXX``
-# Add some definitions that will disable the MPI-2 C++ bindings.
-# Currently supported are MPICH, Open MPI, Platform MPI and derivatives thereof,
-# for example MVAPICH or Intel MPI.
-#
-# If the find procedure fails for a variable ``MPI_<lang>_WORKS``, then the settings detected by or passed to
-# the module did not work and even a simple MPI test program failed to compile.
-#
-# If all of these parameters were not sufficient to find the right MPI implementation, a user may
-# disable the entire autodetection process by specifying both a list of libraries in ``MPI_<lang>_LIBRARIES``
-# and a list of include directories in ``MPI_<lang>_ADDITIONAL_INCLUDE_DIRS``.
-# Any other variable may be set in addition to these two. The module will then validate the MPI settings and store the
-# settings in the cache.
-#
-# Cache variables for MPI
-# ^^^^^^^^^^^^^^^^^^^^^^^
-#
-# The variable ``MPI_<lang>_INCLUDE_DIRS`` will be assembled from the following variables.
-# For C and CXX:
-#
-# ``MPI_<lang>_HEADER_DIR``
-# Location of the ``mpi.h`` header on disk.
-#
-# For Fortran:
-#
-# ``MPI_Fortran_F77_HEADER_DIR``
-# Location of the Fortran 77 header ``mpif.h``, if it exists.
-# ``MPI_Fortran_MODULE_DIR``
-# Location of the ``mpi`` or ``mpi_f08`` modules, if available.
-#
-# For all languages the following variables are additionally considered:
-#
-# ``MPI_<lang>_ADDITIONAL_INCLUDE_DIRS``
-# A :ref:`;-list <CMake Language Lists>` of paths needed in addition to the normal include directories.
-# ``MPI_<include_name>_INCLUDE_DIR``
-# Path variables for include folders referred to by ``<include_name>``.
-# ``MPI_<lang>_ADDITIONAL_INCLUDE_VARS``
-# A :ref:`;-list <CMake Language Lists>` of ``<include_name>`` that will be added to the include locations of ``<lang>``.
-#
-# The variable ``MPI_<lang>_LIBRARIES`` will be assembled from the following variables:
-#
-# ``MPI_<lib_name>_LIBRARY``
-# The location of a library called ``<lib_name>`` for use with MPI.
-# ``MPI_<lang>_LIB_NAMES``
-# A :ref:`;-list <CMake Language Lists>` of ``<lib_name>`` that will be added to the include locations of ``<lang>``.
-#
-# Usage of mpiexec
-# ^^^^^^^^^^^^^^^^
-#
-# When using ``MPIEXEC_EXECUTABLE`` to execute MPI applications, you should typically
-# use all of the ``MPIEXEC_EXECUTABLE`` flags as follows:
-#
-# ::
-#
-# ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS}
-# ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS
-#
-# where ``EXECUTABLE`` is the MPI program, and ``ARGS`` are the arguments to
-# pass to the MPI program.
-#
-# Advanced variables for using MPI
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# The module can perform some advanced feature detections upon explicit request.
-#
-# **Important notice:** The following checks cannot be performed without *executing* an MPI test program.
-# Consider the special considerations for the behavior of :command:`try_run` during cross compilation.
-# Moreover, running an MPI program can cause additional issues, like a firewall notification on some systems.
-# You should only enable these detections if you absolutely need the information.
-#
-# If the following variables are set to true, the respective search will be performed:
-#
-# ``MPI_DETERMINE_Fortran_CAPABILITIES``
-# Determine for all available Fortran bindings what the values of ``MPI_SUBARRAYS_SUPPORTED`` and
-# ``MPI_ASYNC_PROTECTS_NONBLOCKING`` are and make their values available as ``MPI_Fortran_<binding>_SUBARRAYS``
-# and ``MPI_Fortran_<binding>_ASYNCPROT``, where ``<binding>`` is one of ``F77_HEADER``, ``F90_MODULE`` and
-# ``F08_MODULE``.
-# ``MPI_DETERMINE_LIBRARY_VERSION``
-# For each language, find the output of ``MPI_Get_library_version`` and make it available as ``MPI_<lang>_LIBRARY_VERSION``.
-# This information is usually tied to the runtime component of an MPI implementation and might differ depending on ``<lang>``.
-# Note that the return value is entirely implementation defined. This information might be used to identify
-# the MPI vendor and for example pick the correct one of multiple third party binaries that matches the MPI vendor.
-#
-# Backward Compatibility
-# ^^^^^^^^^^^^^^^^^^^^^^
-#
-# For backward compatibility with older versions of FindMPI, these
-# variables are set, but deprecated:
-#
-# ::
-#
-# MPI_COMPILER MPI_LIBRARY MPI_EXTRA_LIBRARY
-# MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_LINK_FLAGS
-# MPI_LIBRARIES
-#
-# In new projects, please use the ``MPI_<lang>_XXX`` equivalents.
-# Additionally, the following variables are deprecated:
-#
-# ``MPI_<lang>_COMPILE_FLAGS``
-# Use ``MPI_<lang>_COMPILE_OPTIONS`` and ``MPI_<lang>_COMPILE_DEFINITIONS`` instead.
-# ``MPI_<lang>_INCLUDE_PATH``
-# For consumption use ``MPI_<lang>_INCLUDE_DIRS`` and for specifying folders use ``MPI_<lang>_ADDITIONAL_INCLUDE_DIRS`` instead.
-# ``MPIEXEC``
-# Use ``MPIEXEC_EXECUTABLE`` instead.
-
-cmake_policy(PUSH)
-cmake_policy(SET CMP0057 NEW) # if IN_LIST
-
-# include this to handle the QUIETLY and REQUIRED arguments
-include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
-include(GetPrerequisites)
-
-# Generic compiler names
-set(_MPI_C_GENERIC_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r)
-set(_MPI_CXX_GENERIC_COMPILER_NAMES mpicxx mpiCC mpcxx mpCC mpic++ mpc++
- mpicxx_r mpiCC_r mpcxx_r mpCC_r mpic++_r mpc++_r)
-set(_MPI_Fortran_GENERIC_COMPILER_NAMES mpif95 mpif95_r mpf95 mpf95_r
- mpif90 mpif90_r mpf90 mpf90_r
- mpif77 mpif77_r mpf77 mpf77_r
- mpifc)
-
-# GNU compiler names
-set(_MPI_GNU_C_COMPILER_NAMES mpigcc mpgcc mpigcc_r mpgcc_r)
-set(_MPI_GNU_CXX_COMPILER_NAMES mpig++ mpg++ mpig++_r mpg++_r mpigxx)
-set(_MPI_GNU_Fortran_COMPILER_NAMES mpigfortran mpgfortran mpigfortran_r mpgfortran_r
- mpig77 mpig77_r mpg77 mpg77_r)
-
-# Intel MPI compiler names on Windows
-if(WIN32)
- list(APPEND _MPI_C_GENERIC_COMPILER_NAMES mpicc.bat)
- list(APPEND _MPI_CXX_GENERIC_COMPILER_NAMES mpicxx.bat)
- list(APPEND _MPI_Fortran_GENERIC_COMPILER_NAMES mpifc.bat)
-
- # Intel MPI compiler names
- set(_MPI_Intel_C_COMPILER_NAMES mpiicc.bat)
- set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc.bat)
- set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort.bat mpif77.bat mpif90.bat)
-
- # Intel MPI compiler names for MSMPI
- set(_MPI_MSVC_C_COMPILER_NAMES mpicl.bat)
- set(_MPI_MSVC_CXX_COMPILER_NAMES mpicl.bat)
-else()
- # Intel compiler names
- set(_MPI_Intel_C_COMPILER_NAMES mpiicc)
- set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc mpiicxx mpiic++)
- set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort mpiif95 mpiif90 mpiif77)
-endif()
-
-# PGI compiler names
-set(_MPI_PGI_C_COMPILER_NAMES mpipgcc mppgcc)
-set(_MPI_PGI_CXX_COMPILER_NAMES mpipgCC mppgCC)
-set(_MPI_PGI_Fortran_COMPILER_NAMES mpipgf95 mpipgf90 mppgf95 mppgf90 mpipgf77 mppgf77)
-
-# XLC MPI Compiler names
-set(_MPI_XL_C_COMPILER_NAMES mpxlc mpxlc_r mpixlc mpixlc_r)
-set(_MPI_XL_CXX_COMPILER_NAMES mpixlcxx mpixlC mpixlc++ mpxlcxx mpxlc++ mpixlc++ mpxlCC
- mpixlcxx_r mpixlC_r mpixlc++_r mpxlcxx_r mpxlc++_r mpixlc++_r mpxlCC_r)
-set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95_r
- mpixlf90 mpixlf90_r mpxlf90 mpxlf90_r
- mpixlf77 mpixlf77_r mpxlf77 mpxlf77_r
- mpixlf mpixlf_r mpxlf mpxlf_r)
-
-# Prepend vendor-specific compiler wrappers to the list. If we don't know the compiler,
-# attempt all of them.
-# By attempting vendor-specific compiler names first, we should avoid situations where the compiler wrapper
-# stems from a proprietary MPI and won't know which compiler it's being used for. For instance, Intel MPI
-# controls its settings via the I_MPI_CC environment variables if the generic name is being used.
-# If we know which compiler we're working with, we can use the most specialized wrapper there is in order to
-# pick up the right settings for it.
-foreach (LANG IN ITEMS C CXX Fortran)
- set(_MPI_${LANG}_COMPILER_NAMES "")
- foreach (id IN ITEMS GNU Intel MSVC PGI XL)
- if (NOT CMAKE_${LANG}_COMPILER_ID OR CMAKE_${LANG}_COMPILER_ID STREQUAL id)
- list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${id}_${LANG}_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX})
- endif()
- unset(_MPI_${id}_${LANG}_COMPILER_NAMES)
- endforeach()
- list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${LANG}_GENERIC_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX})
- unset(_MPI_${LANG}_GENERIC_COMPILER_NAMES)
-endforeach()
-
-# Names to try for mpiexec
-# Only mpiexec commands are guaranteed to behave as described in the standard,
-# mpirun commands are not covered by the standard in any way whatsoever.
-# lamexec is the executable for LAM/MPI, srun is for SLURM or Open MPI with SLURM support.
-# srun -n X <executable> is however a valid command, so it behaves 'like' mpiexec.
-set(_MPIEXEC_NAMES_BASE mpiexec mpiexec.hydra mpiexec.mpd mpirun lamexec srun)
-
-unset(_MPIEXEC_NAMES)
-foreach(_MPIEXEC_NAME IN LISTS _MPIEXEC_NAMES_BASE)
- list(APPEND _MPIEXEC_NAMES "${_MPIEXEC_NAME}${MPI_EXECUTABLE_SUFFIX}")
-endforeach()
-unset(_MPIEXEC_NAMES_BASE)
-
-function (_MPI_check_compiler LANG QUERY_FLAG OUTPUT_VARIABLE RESULT_VARIABLE)
- if(DEFINED MPI_${LANG}_COMPILER_FLAGS)
- separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_${LANG}_COMPILER_FLAGS}")
- else()
- separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_COMPILER_FLAGS}")
- endif()
- execute_process(
- COMMAND ${MPI_${LANG}_COMPILER} ${_MPI_COMPILER_WRAPPER_OPTIONS} ${QUERY_FLAG}
- OUTPUT_VARIABLE WRAPPER_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE
- ERROR_VARIABLE WRAPPER_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE
- RESULT_VARIABLE WRAPPER_RETURN)
- # Some compiler wrappers will yield spurious zero return values, for example
- # Intel MPI tolerates unknown arguments and if the MPI wrappers loads a shared
- # library that has invalid or missing version information there would be warning
- # messages emitted by ld.so in the compiler output. In either case, we'll treat
- # the output as invalid.
- if("${WRAPPER_OUTPUT}" MATCHES "undefined reference|unrecognized|need to set|no version information available|command not found")
- set(WRAPPER_RETURN 255)
- endif()
- # Ensure that no error output might be passed upwards.
- if(NOT WRAPPER_RETURN EQUAL 0)
- unset(WRAPPER_OUTPUT)
- endif()
- set(${OUTPUT_VARIABLE} "${WRAPPER_OUTPUT}" PARENT_SCOPE)
- set(${RESULT_VARIABLE} "${WRAPPER_RETURN}" PARENT_SCOPE)
-endfunction()
-
-function (_MPI_interrogate_compiler lang)
- unset(MPI_COMPILE_CMDLINE)
- unset(MPI_LINK_CMDLINE)
-
- unset(MPI_COMPILE_OPTIONS_WORK)
- unset(MPI_COMPILE_DEFINITIONS_WORK)
- unset(MPI_INCLUDE_DIRS_WORK)
- unset(MPI_LINK_FLAGS_WORK)
- unset(MPI_LIB_NAMES_WORK)
- unset(MPI_LIB_FULLPATHS_WORK)
-
- # Check whether the -showme:compile option works. This indicates that we have either Open MPI
- # or a newer version of LAM/MPI, and implies that -showme:link will also work.
- # Open MPI also supports -show, but separates linker and compiler information
- _MPI_check_compiler(${LANG} "-showme:compile" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN)
- if (MPI_COMPILER_RETURN EQUAL 0)
- _MPI_check_compiler(${LANG} "-showme:link" MPI_LINK_CMDLINE MPI_COMPILER_RETURN)
-
- if (NOT MPI_COMPILER_RETURN EQUAL 0)
- unset(MPI_COMPILE_CMDLINE)
- endif()
- endif()
-
- # MPICH and MVAPICH offer -compile-info and -link-info.
- # For modern versions, both do the same as -show. However, for old versions, they do differ
- # when called for mpicxx and mpif90 and it's necessary to use them over -show in order to find the
- # removed MPI C++ bindings.
- if (NOT MPI_COMPILER_RETURN EQUAL 0)
- _MPI_check_compiler(${LANG} "-compile-info" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN)
-
- if (MPI_COMPILER_RETURN EQUAL 0)
- _MPI_check_compiler(${LANG} "-link-info" MPI_LINK_CMDLINE MPI_COMPILER_RETURN)
-
- if (NOT MPI_COMPILER_RETURN EQUAL 0)
- unset(MPI_COMPILE_CMDLINE)
- endif()
- endif()
- endif()
-
- # MPICH, MVAPICH2 and Intel MPI just use "-show". Open MPI also offers this, but the
- # -showme commands are more specialized.
- if (NOT MPI_COMPILER_RETURN EQUAL 0)
- _MPI_check_compiler(${LANG} "-show" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN)
- endif()
-
- # Older versions of LAM/MPI have "-showme". Open MPI also supports this.
- # Unknown to MPICH, MVAPICH and Intel MPI.
- if (NOT MPI_COMPILER_RETURN EQUAL 0)
- _MPI_check_compiler(${LANG} "-showme" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN)
- endif()
-
- if (NOT (MPI_COMPILER_RETURN EQUAL 0) OR NOT (DEFINED MPI_COMPILE_CMDLINE))
- # Cannot interrogate this compiler, so exit.
- set(MPI_${LANG}_WRAPPER_FOUND FALSE PARENT_SCOPE)
- return()
- endif()
- unset(MPI_COMPILER_RETURN)
-
- # We have our command lines, but we might need to copy MPI_COMPILE_CMDLINE
- # into MPI_LINK_CMDLINE, if we didn't find the link line.
- if (NOT DEFINED MPI_LINK_CMDLINE)
- set(MPI_LINK_CMDLINE "${MPI_COMPILE_CMDLINE}")
- endif()
-
- # At this point, we obtained some output from a compiler wrapper that works.
- # We'll now try to parse it into variables with meaning to us.
- if("${LANG}" STREQUAL "Fortran")
- # Some MPICH-1 and MVAPICH-1 versions return a three command answer for Fortran, consisting
- # out of a symlink command for mpif.h, the actual compiler command and a deletion of the
- # created symlink. We need to detect that case, remember the include path and drop the
- # symlink/deletion operation to obtain the link/compile lines we'd usually expect.
- if("${MPI_COMPILE_CMDLINE}" MATCHES "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h")
- get_filename_component(MPI_INCLUDE_DIRS_WORK "${CMAKE_MATCH_1}" DIRECTORY)
- string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}")
- string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}")
- string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}")
- string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}")
- endif()
- endif()
-
- # The Intel MPI wrapper on Linux will emit some objcopy commands after its compile command
- # if -static_mpi was passed to the wrapper. To avoid spurious matches, we need to drop these lines.
- if(UNIX)
- string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}")
- string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}")
- endif()
-
- # Extract compile options from the compile command line.
- string(REGEX MATCHALL "(^| )-f([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_OPTIONS "${MPI_COMPILE_CMDLINE}")
-
- foreach(_MPI_COMPILE_OPTION IN LISTS MPI_ALL_COMPILE_OPTIONS)
- string(REGEX REPLACE "^ " "" _MPI_COMPILE_OPTION "${_MPI_COMPILE_OPTION}")
- # Ignore -fstack-protector directives: These occur on MPICH and MVAPICH when the libraries
- # themselves were built with this flag. However, this flag is unrelated to using MPI, and
- # we won't match the accompanying --param-ssp-size and -Wp,-D_FORTIFY_SOURCE flags and therefore
- # produce inconsistent results with the regularly flags.
- # Similarly, aliasing flags do not belong into our flag array.
- if(NOT "${_MPI_COMPILE_OPTION}" MATCHES "^-f(stack-protector|(no-|)strict-aliasing|PI[CE]|pi[ce])")
- list(APPEND MPI_COMPILE_OPTIONS_WORK "${_MPI_COMPILE_OPTION}")
- endif()
- endforeach()
-
- # Same deal, with the definitions. We also treat arguments passed to the preprocessor directly.
- string(REGEX MATCHALL "(^| )(-Wp,|-Xpreprocessor |)[-/]D([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_DEFINITIONS "${MPI_COMPILE_CMDLINE}")
-
- foreach(_MPI_COMPILE_DEFINITION IN LISTS MPI_ALL_COMPILE_DEFINITIONS)
- string(REGEX REPLACE "^ ?(-Wp,|-Xpreprocessor )?[-/]D" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}")
- string(REPLACE "\"" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}")
- if(NOT "${_MPI_COMPILE_DEFINITION}" MATCHES "^_FORTIFY_SOURCE.*")
- list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${_MPI_COMPILE_DEFINITION}")
- endif()
- endforeach()
-
- # Extract include paths from compile command line
- string(REGEX MATCHALL "(^| )[-/]I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}")
-
- # If extracting failed to work, we'll try using -showme:incdirs.
- if (NOT MPI_ALL_INCLUDE_PATHS)
- _MPI_check_compiler(${LANG} "-showme:incdirs" MPI_INCDIRS_CMDLINE MPI_INCDIRS_COMPILER_RETURN)
- if(MPI_INCDIRS_COMPILER_RETURN)
- separate_arguments(MPI_ALL_INCLUDE_PATHS NATIVE_COMMAND "${MPI_INCDIRS_CMDLINE}")
- endif()
- endif()
-
- foreach(_MPI_INCLUDE_PATH IN LISTS MPI_ALL_INCLUDE_PATHS)
- string(REGEX REPLACE "^ ?[-/]I" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}")
- string(REPLACE "\"" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}")
- get_filename_component(_MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}" REALPATH)
- list(APPEND MPI_INCLUDE_DIRS_WORK "${_MPI_INCLUDE_PATH}")
- endforeach()
-
- # Extract linker paths from the link command line
- string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker |)(-L|[/-]LIBPATH:|[/-]libpath:)([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}")
-
- # If extracting failed to work, we'll try using -showme:libdirs.
- if (NOT MPI_ALL_LINK_PATHS)
- _MPI_check_compiler(${LANG} "-showme:libdirs" MPI_LIBDIRS_CMDLINE MPI_LIBDIRS_COMPILER_RETURN)
- if(MPI_LIBDIRS_COMPILER_RETURN)
- separate_arguments(MPI_ALL_LINK_PATHS NATIVE_COMMAND "${MPI_LIBDIRS_CMDLINE}")
- endif()
- endif()
-
- foreach(_MPI_LPATH IN LISTS MPI_ALL_LINK_PATHS)
- string(REGEX REPLACE "^ ?(-Wl,|-Xlinker )?(-L|[/-]LIBPATH:|[/-]libpath:)" "" _MPI_LPATH "${_MPI_LPATH}")
- string(REPLACE "\"" "" _MPI_LPATH "${_MPI_LPATH}")
- get_filename_component(_MPI_LPATH "${_MPI_LPATH}" REALPATH)
- list(APPEND MPI_LINK_DIRECTORIES_WORK "${_MPI_LPATH}")
- endforeach()
-
- # Extract linker flags from the link command line
- string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker )([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}")
-
- foreach(_MPI_LINK_FLAG IN LISTS MPI_ALL_LINK_FLAGS)
- string(STRIP "${_MPI_LINK_FLAG}" _MPI_LINK_FLAG)
- # MPI might be marked to build with non-executable stacks but this should not propagate.
- if (NOT "${_MPI_LINK_FLAG}" MATCHES "(-Wl,|-Xlinker )-z,noexecstack")
- if (MPI_LINK_FLAGS_WORK)
- string(APPEND MPI_LINK_FLAGS_WORK " ${_MPI_LINK_FLAG}")
- else()
- set(MPI_LINK_FLAGS_WORK "${_MPI_LINK_FLAG}")
- endif()
- endif()
- endforeach()
-
- # Extract the set of libraries to link against from the link command
- # line
- string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}")
-
- foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES)
- string(REGEX REPLACE "^ ?-l" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}")
- string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}")
- get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY)
- if(NOT "${_MPI_LIB_PATH}" STREQUAL "")
- list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}")
- else()
- list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}")
- endif()
- endforeach()
-
- if(WIN32)
- # A compiler wrapper on Windows will just have the name of the
- # library to link on its link line, potentially with a full path
- string(REGEX MATCHALL "(^| )([^\" ]+\\.lib|\"[^\"]+\\.lib\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}")
- foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES)
- string(REGEX REPLACE "^ " "" _MPI_LIB_NAME "${_MPI_LIB_NAME}")
- string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}")
- get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY)
- if(NOT "${_MPI_LIB_PATH}" STREQUAL "")
- list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}")
- else()
- list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}")
- endif()
- endforeach()
- else()
- # On UNIX platforms, archive libraries can be given with full path.
- string(REGEX MATCHALL "(^| )([^\" ]+\\.a|\"[^\"]+\\.a\")" MPI_LIBFULLPATHS "${MPI_LINK_CMDLINE}")
- foreach(_MPI_LIB_NAME IN LISTS MPI_LIBFULLPATHS)
- string(REGEX REPLACE "^ " "" _MPI_LIB_NAME "${_MPI_LIB_NAME}")
- string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}")
- get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY)
- if(NOT "${_MPI_LIB_PATH}" STREQUAL "")
- list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}")
- else()
- list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}")
- endif()
- endforeach()
- endif()
-
- # An MPI compiler wrapper could have its MPI libraries in the implictly
- # linked directories of the compiler itself.
- if(DEFINED CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES)
- list(APPEND MPI_LINK_DIRECTORIES_WORK "${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES}")
- endif()
-
- # Determine full path names for all of the libraries that one needs
- # to link against in an MPI program
- unset(MPI_PLAIN_LIB_NAMES_WORK)
- foreach(_MPI_LIB_NAME IN LISTS MPI_LIB_NAMES_WORK)
- get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_NAME}" NAME_WE)
- list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}")
- find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY
- NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}"
- HINTS ${MPI_LINK_DIRECTORIES_WORK}
- DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI"
- )
- mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY)
- endforeach()
-
- # Deal with the libraries given with full path next
- unset(MPI_DIRECT_LIB_NAMES_WORK)
- foreach(_MPI_LIB_FULLPATH IN LISTS MPI_LIB_FULLPATHS_WORK)
- get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_FULLPATH}" NAME_WE)
- get_filename_component(_MPI_LIB_NAME "${_MPI_LIB_FULLPATH}" NAME)
- get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_FULLPATH}" DIRECTORY)
- list(APPEND MPI_DIRECT_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}")
- find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY
- NAMES "${_MPI_LIB_NAME}"
- HINTS ${_MPI_LIB_PATH}
- DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI"
- )
- mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY)
- endforeach()
- if(MPI_DIRECT_LIB_NAMES_WORK)
- set(MPI_PLAIN_LIB_NAMES_WORK "${MPI_DIRECT_LIB_NAMES_WORK};${MPI_PLAIN_LIB_NAMES_WORK}")
- endif()
-
- # MPI might require pthread to work. The above mechanism wouldn't detect it, but we need to
- # link it in that case. -lpthread is covered by the normal library treatment on the other hand.
- if("${MPI_COMPILE_CMDLINE}" MATCHES "-pthread")
- list(APPEND MPI_COMPILE_OPTIONS_WORK "-pthread")
- if(MPI_LINK_FLAGS_WORK)
- string(APPEND MPI_LINK_FLAGS_WORK " -pthread")
- else()
- set(MPI_LINK_FLAGS_WORK "-pthread")
- endif()
- endif()
-
- if(MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS)
- list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS}")
- endif()
- if(MPI_${LANG}_EXTRA_COMPILE_OPTIONS)
- list(APPEND MPI_COMPILE_OPTIONS_WORK "${MPI_${LANG}_EXTRA_COMPILE_OPTIONS}")
- endif()
- if(MPI_${LANG}_EXTRA_LIB_NAMES)
- list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${MPI_${LANG}_EXTRA_LIB_NAMES}")
- endif()
-
- # If we found MPI, set up all of the appropriate cache entries
- if(NOT MPI_${LANG}_COMPILE_OPTIONS)
- set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_COMPILE_OPTIONS_WORK} CACHE STRING "MPI ${LANG} compilation options" FORCE)
- endif()
- if(NOT MPI_${LANG}_COMPILE_DEFINITIONS)
- set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_COMPILE_DEFINITIONS_WORK} CACHE STRING "MPI ${LANG} compilation definitions" FORCE)
- endif()
- if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)
- set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_INCLUDE_DIRS_WORK} CACHE STRING "MPI ${LANG} additional include directories" FORCE)
- endif()
- if(NOT MPI_${LANG}_LINK_FLAGS)
- set(MPI_${LANG}_LINK_FLAGS ${MPI_LINK_FLAGS_WORK} CACHE STRING "MPI ${LANG} linker flags" FORCE)
- endif()
- if(NOT MPI_${LANG}_LIB_NAMES)
- set(MPI_${LANG}_LIB_NAMES ${MPI_PLAIN_LIB_NAMES_WORK} CACHE STRING "MPI ${LANG} libraries to link against" FORCE)
- endif()
- set(MPI_${LANG}_WRAPPER_FOUND TRUE PARENT_SCOPE)
-endfunction()
-
-function(_MPI_guess_settings LANG)
- set(MPI_GUESS_FOUND FALSE)
- # Currently only MSMPI and MPICH2 on Windows are supported, so we can skip this search if we're not targeting that.
- if(WIN32)
- # MSMPI
-
- # The environment variables MSMPI_INC and MSMPILIB32/64 are the only ways of locating the MSMPI_SDK,
- # which is installed separately from the runtime. Thus it's possible to have mpiexec but not MPI headers
- # or import libraries and vice versa.
- if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MSMPI")
- # We first attempt to locate the msmpi.lib. Should be find it, we'll assume that the MPI present is indeed
- # Microsoft MPI.
- if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
- set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB64}")
- set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x64")
- else()
- set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB32}")
- set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x86")
- endif()
-
- find_library(MPI_msmpi_LIBRARY
- NAMES msmpi
- HINTS ${MPI_MSMPI_LIB_PATH}
- DOC "Location of the msmpi library for Microsoft MPI")
- mark_as_advanced(MPI_msmpi_LIBRARY)
-
- if(MPI_msmpi_LIBRARY)
- # Next, we attempt to locate the MPI header. Note that for Fortran we know that mpif.h is a way
- # MSMPI can be used and therefore that header has to be present.
- if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)
- get_filename_component(MPI_MSMPI_INC_DIR "$ENV{MSMPI_INC}" REALPATH)
- set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MSMPI_INC_DIR}" CACHE STRING "MPI ${LANG} additional include directories" FORCE)
- unset(MPI_MSMPI_INC_DIR)
- endif()
-
- # For MSMPI, one can compile the MPI module by building the mpi.f90 shipped with the MSMPI SDK,
- # thus it might be present or provided by the user. Figuring out which is supported is done later on.
- # The PGI Fortran compiler for instance ships a prebuilt set of modules in its own include folder.
- # Should a user be employing PGI or have built its own set and provided it via cache variables, the
- # splitting routine would have located the module files.
-
- # For C and C++, we're done here (MSMPI does not ship the MPI-2 C++ bindings) - however, for Fortran
- # we need some extra library to glue Fortran support together:
- # MSMPI ships 2-4 Fortran libraries, each for different Fortran compiler behaviors. The library names
- # ending with a c are using the cdecl calling convention, whereas those ending with an s are for Fortran
- # implementations using stdcall. Therefore, the 64-bit MSMPI only ships those ending in 'c', whereas the 32-bit
- # has both variants available.
- # The second difference is the last but one letter, if it's an e(nd), the length of a string argument is
- # passed by the Fortran compiler after all other arguments on the parameter list, if it's an m(ixed),
- # it's passed immediately after the string address.
-
- # To summarize:
- # - msmpifec: CHARACTER length passed after the parameter list and using cdecl calling convention
- # - msmpifmc: CHARACTER length passed directly after string address and using cdecl calling convention
- # - msmpifes: CHARACTER length passed after the parameter list and using stdcall calling convention
- # - msmpifms: CHARACTER length passed directly after string address and using stdcall calling convention
- # 32-bit MSMPI ships all four libraries, 64-bit MSMPI ships only the first two.
-
- # As is, Intel Fortran and PGI Fortran both use the 'ec' variant of the calling convention, whereas
- # the old Compaq Visual Fortran compiler defaulted to the 'ms' version. It's possible to make Intel Fortran
- # use the CVF calling convention using /iface:cvf, but we assume - and this is also assumed in FortranCInterface -
- # this isn't the case. It's also possible to make CVF use the 'ec' variant, using /iface=(cref,nomixed_str_len_arg).
-
- # Our strategy is now to locate all libraries, but enter msmpifec into the LIB_NAMES array.
- # Should this not be adequate it's a straightforward way for a user to change the LIB_NAMES array and
- # have his library found. Still, this should not be necessary outside of exceptional cases, as reasoned.
- if ("${LANG}" STREQUAL "Fortran")
- set(MPI_MSMPI_CALLINGCONVS c)
- if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4)
- list(APPEND MPI_MSMPI_CALLINGCONVS s)
- endif()
- foreach(mpistrlenpos IN ITEMS e m)
- foreach(mpicallingconv IN LISTS MPI_MSMPI_CALLINGCONVS)
- find_library(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY
- NAMES msmpif${mpistrlenpos}${mpicallingconv}
- HINTS "${MPI_MSMPI_LIB_PATH}"
- DOC "Location of the msmpi${mpistrlenpos}${mpicallingconv} library for Microsoft MPI")
- mark_as_advanced(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY)
- endforeach()
- endforeach()
- if(NOT MPI_${LANG}_LIB_NAMES)
- set(MPI_${LANG}_LIB_NAMES "msmpi;msmpifec" CACHE STRING "MPI ${LANG} libraries to link against" FORCE)
- endif()
-
- # At this point we're *not* done. MSMPI requires an additional include file for Fortran giving the value
- # of MPI_AINT. This file is called mpifptr.h located in the x64 and x86 subfolders, respectively.
- find_path(MPI_mpifptr_INCLUDE_DIR
- NAMES "mpifptr.h"
- HINTS "${MPI_MSMPI_INC_PATH_EXTRA}"
- DOC "Location of the mpifptr.h extra header for Microsoft MPI")
- if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_VARS)
- set(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS "mpifptr" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI_<name>_INCLUDE_DIR." FORCE)
- endif()
- mark_as_advanced(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS MPI_mpifptr_INCLUDE_DIR)
- else()
- if(NOT MPI_${LANG}_LIB_NAMES)
- set(MPI_${LANG}_LIB_NAMES "msmpi" CACHE STRING "MPI ${LANG} libraries to link against" FORCE)
- endif()
- endif()
- mark_as_advanced(MPI_${LANG}_LIB_NAMES)
- set(MPI_GUESS_FOUND TRUE)
- endif()
- endif()
-
- # At this point there's not many MPIs that we could still consider.
- # OpenMPI 1.6.x and below supported Windows, but these ship compiler wrappers that still work.
- # The only other relevant MPI implementation without a wrapper is MPICH2, which had Windows support in 1.4.1p1 and older.
- if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MPICH2")
- set(MPI_MPICH_PREFIX_PATHS
- "$ENV{ProgramW6432}/MPICH2/lib"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/../lib"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH2;Path]/lib"
- )
-
- # All of C, C++ and Fortran will need mpi.lib, so we'll look for this first
- find_library(MPI_mpi_LIBRARY
- NAMES mpi
- HINTS ${MPI_MPICH_PREFIX_PATHS})
- mark_as_advanced(MPI_mpi_LIBRARY)
- # If we found mpi.lib, we detect the rest of MPICH2
- if(MPI_mpi_LIBRARY)
- set(MPI_MPICH_LIB_NAMES "mpi")
- # If MPI-2 C++ bindings are requested, we need to locate cxx.lib as well.
- # Otherwise, MPICH_SKIP_MPICXX will be defined and these bindings aren't needed.
- if("${LANG}" STREQUAL "CXX" AND NOT MPI_CXX_SKIP_MPICXX)
- find_library(MPI_cxx_LIBRARY
- NAMES cxx
- HINTS ${MPI_MPICH_PREFIX_PATHS})
- mark_as_advanced(MPI_cxx_LIBRARY)
- list(APPEND MPI_MPICH_LIB_NAMES "cxx")
- # For Fortran, MPICH2 provides three different libraries:
- # fmpich2.lib which uses uppercase symbols and cdecl,
- # fmpich2s.lib which uses uppercase symbols and stdcall (32-bit only),
- # fmpich2g.lib which uses lowercase symbols with double underscores and cdecl.
- # fmpich2s.lib would be useful for Compaq Visual Fortran, fmpich2g.lib has to be used with GNU g77 and is also
- # provided in the form of an .a archive for MinGW and Cygwin. From our perspective, fmpich2.lib is the only one
- # we need to try, and if it doesn't work with the given Fortran compiler we'd find out later on during validation
- elseif("${LANG}" STREQUAL "Fortran")
- find_library(MPI_fmpich2_LIBRARY
- NAMES fmpich2
- HINTS ${MPI_MPICH_PREFIX_PATHS})
- find_library(MPI_fmpich2s_LIBRARY
- NAMES fmpich2s
- HINTS ${MPI_MPICH_PREFIX_PATHS})
- find_library(MPI_fmpich2g_LIBRARY
- NAMES fmpich2g
- HINTS ${MPI_MPICH_PREFIX_PATHS})
- mark_as_advanced(MPI_fmpich2_LIBRARY MPI_fmpich2s_LIBRARY MPI_fmpich2g_LIBRARY)
- list(APPEND MPI_MPICH_LIB_NAMES "fmpich2")
- endif()
-
- if(NOT MPI_${LANG}_LIB_NAMES)
- set(MPI_${LANG}_LIB_NAMES "${MPI_MPICH_LIB_NAMES}" CACHE STRING "MPI ${LANG} libraries to link against" FORCE)
- endif()
- unset(MPI_MPICH_LIB_NAMES)
-
- if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)
- # For MPICH2, the include folder would be in ../include relative to the library folder.
- get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_mpi_LIBRARY}" DIRECTORY)
- get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_MPICH_ROOT_DIR}" DIRECTORY)
- if(IS_DIRECTORY "${MPI_MPICH_ROOT_DIR}/include")
- set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MPICH_ROOT_DIR}/include" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI_<name>_INCLUDE_DIR." FORCE)
- endif()
- unset(MPI_MPICH_ROOT_DIR)
- endif()
- set(MPI_GUESS_FOUND TRUE)
- endif()
- unset(MPI_MPICH_PREFIX_PATHS)
- endif()
- endif()
- set(MPI_${LANG}_GUESS_FOUND "${MPI_GUESS_FOUND}" PARENT_SCOPE)
-endfunction()
-
-function(_MPI_adjust_compile_definitions LANG)
- if("${LANG}" STREQUAL "CXX")
- # To disable the C++ bindings, we need to pass some definitions since the mpi.h header has to deal with both C and C++
- # bindings in MPI-2.
- if(MPI_CXX_SKIP_MPICXX AND NOT MPI_${LANG}_COMPILE_DEFINITIONS MATCHES "SKIP_MPICXX")
- # MPICH_SKIP_MPICXX is being used in MPICH and derivatives like MVAPICH or Intel MPI
- # OMPI_SKIP_MPICXX is being used in Open MPI
- # _MPICC_H is being used for IBM Platform MPI
- list(APPEND MPI_${LANG}_COMPILE_DEFINITIONS "MPICH_SKIP_MPICXX" "OMPI_SKIP_MPICXX" "_MPICC_H")
- set(MPI_${LANG}_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}" CACHE STRING "MPI ${LANG} compilation definitions" FORCE)
- endif()
- endif()
-endfunction()
-
-macro(_MPI_assemble_libraries LANG)
- set(MPI_${LANG}_LIBRARIES "")
- # Only for libraries do we need to check whether the compiler's linking stage is separate.
- if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS_IMPLICIT)
- foreach(mpilib IN LISTS MPI_${LANG}_LIB_NAMES)
- list(APPEND MPI_${LANG}_LIBRARIES ${MPI_${mpilib}_LIBRARY})
- endforeach()
- endif()
-endmacro()
-
-macro(_MPI_assemble_include_dirs LANG)
- if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}")
- set(MPI_${LANG}_INCLUDE_DIRS "")
- else()
- set(MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}")
- if("${LANG}" MATCHES "(C|CXX)")
- if(MPI_${LANG}_HEADER_DIR)
- list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}")
- endif()
- else() # Fortran
- if(MPI_${LANG}_F77_HEADER_DIR)
- list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_F77_HEADER_DIR}")
- endif()
- if(MPI_${LANG}_MODULE_DIR AND NOT "${MPI_${LANG}_MODULE_DIR}" IN_LIST MPI_${LANG}_INCLUDE_DIRS)
- list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_MODULE_DIR}")
- endif()
- endif()
- if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS)
- foreach(MPI_ADDITIONAL_INC_DIR IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS)
- list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${MPI_ADDITIONAL_INC_DIR}_INCLUDE_DIR}")
- endforeach()
- endif()
- endif()
-endmacro()
-
-function(_MPI_split_include_dirs LANG)
- if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}")
- return()
- endif()
- # Backwards compatibility: Search INCLUDE_PATH if given.
- if(MPI_${LANG}_INCLUDE_PATH)
- list(APPEND MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_INCLUDE_PATH}")
- endif()
-
- # We try to find the headers/modules among those paths (and system paths)
- # For C/C++, we just need to have a look for mpi.h.
- if("${LANG}" MATCHES "(C|CXX)")
- find_path(MPI_${LANG}_HEADER_DIR "mpi.h"
- HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}
- )
- mark_as_advanced(MPI_${LANG}_HEADER_DIR)
- if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)
- list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}")
- endif()
- # Fortran is more complicated here: An implementation could provide
- # any of the Fortran 77/90/2008 APIs for MPI. For example, MSMPI
- # only provides Fortran 77 and - if mpi.f90 is built - potentially
- # a Fortran 90 module.
- elseif("${LANG}" STREQUAL "Fortran")
- find_path(MPI_${LANG}_F77_HEADER_DIR "mpif.h"
- HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}
- )
- find_path(MPI_${LANG}_MODULE_DIR
- NAMES "mpi.mod" "mpi_f08.mod"
- HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}
- )
- if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)
- list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS
- "${MPI_${LANG}_F77_HEADER_DIR}"
- "${MPI_${LANG}_MODULE_DIR}"
- )
- endif()
- mark_as_advanced(MPI_${LANG}_F77_HEADER_DIR MPI_${LANG}_MODULE_DIR)
- endif()
- # Remove duplicates and default system directories from the list.
- if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)
- list(REMOVE_DUPLICATES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)
- foreach(MPI_IMPLICIT_INC_DIR IN LISTS CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES)
- list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_IMPLICIT_INC_DIR})
- endforeach()
- endif()
- set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories" FORCE)
-endfunction()
-
-macro(_MPI_create_imported_target LANG)
- if(NOT TARGET MPI::MPI_${LANG})
- add_library(MPI::MPI_${LANG} INTERFACE IMPORTED)
- endif()
-
- set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}")
- set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}")
-
- set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_LIBRARIES "")
- if(MPI_${LANG}_LINK_FLAGS)
- set_property(TARGET MPI::MPI_${LANG} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_${LANG}_LINK_FLAGS}")
- endif()
- # If the compiler links MPI implicitly, no libraries will be found as they're contained within
- # CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES already.
- if(MPI_${LANG}_LIBRARIES)
- set_property(TARGET MPI::MPI_${LANG} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_${LANG}_LIBRARIES}")
- endif()
- # Given the new design of FindMPI, INCLUDE_DIRS will always be located, even under implicit linking.
- set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${MPI_${LANG}_INCLUDE_DIRS}")
-endmacro()
-
-function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY)
- set(WORK_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI")
- set(SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/FindMPI")
- set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI/${MPI_TEST_FILE_NAME}_${LANG}.bin")
- unset(MPI_TEST_COMPILE_DEFINITIONS)
- if("${LANG}" STREQUAL "Fortran")
- if("${MODE}" STREQUAL "F90_MODULE")
- set(MPI_Fortran_INCLUDE_LINE "use mpi\n implicit none")
- elseif("${MODE}" STREQUAL "F08_MODULE")
- set(MPI_Fortran_INCLUDE_LINE "use mpi_f08\n implicit none")
- else() # F77 header
- set(MPI_Fortran_INCLUDE_LINE "implicit none\n include 'mpif.h'")
- endif()
- configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.f90.in" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90" @ONLY)
- set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90")
- elseif("${LANG}" STREQUAL "CXX")
- configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp" COPYONLY)
- set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp")
- if("${MODE}" STREQUAL "TEST_MPICXX")
- set(MPI_TEST_COMPILE_DEFINITIONS TEST_MPI_MPICXX)
- endif()
- else() # C
- set(MPI_TEST_SOURCE_FILE "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c")
- endif()
- if(RUN_BINARY)
- try_run(MPI_RUN_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}
- "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}"
- COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS}
- LINK_LIBRARIES MPI::MPI_${LANG}
- RUN_OUTPUT_VARIABLE MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE})
- set(MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} "${MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}}" PARENT_SCOPE)
- else()
- try_compile(MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}
- "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}"
- COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS}
- LINK_LIBRARIES MPI::MPI_${LANG}
- COPY_FILE "${BIN_FILE}")
- endif()
-endfunction()
-
-macro(_MPI_check_lang_works LANG)
- # For Fortran we may have by the MPI-3 standard an implementation that provides:
- # - the mpi_f08 module
- # - *both*, the mpi module and 'mpif.h'
- # Since older MPI standards (MPI-1) did not define anything but 'mpif.h', we need to check all three individually.
- if( NOT MPI_${LANG}_WORKS )
- if("${LANG}" STREQUAL "Fortran")
- set(MPI_Fortran_INTEGER_LINE "(kind=MPI_INTEGER_KIND)")
- _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER FALSE)
- _MPI_try_staged_settings(${LANG} test_mpi F90_MODULE FALSE)
- _MPI_try_staged_settings(${LANG} test_mpi F08_MODULE FALSE)
-
- set(MPI_${LANG}_WORKS FALSE)
-
- foreach(mpimethod IN ITEMS F77_HEADER F08_MODULE F90_MODULE)
- if(MPI_RESULT_${LANG}_test_mpi_${mpimethod})
- set(MPI_${LANG}_WORKS TRUE)
- set(MPI_${LANG}_HAVE_${mpimethod} TRUE)
- else()
- set(MPI_${LANG}_HAVE_${mpimethod} FALSE)
- endif()
- endforeach()
- # MPI-1 versions had no MPI_INTGER_KIND defined, so we need to try without it.
- # However, MPI-1 also did not define the Fortran 90 and 08 modules, so we only try the F77 header.
- unset(MPI_Fortran_INTEGER_LINE)
- if(NOT MPI_${LANG}_WORKS)
- _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER_NOKIND FALSE)
- if(MPI_RESULT_${LANG}_test_mpi_F77_HEADER_NOKIND)
- set(MPI_${LANG}_WORKS TRUE)
- set(MPI_${LANG}_HAVE_F77_HEADER TRUE)
- endif()
- endif()
- else()
- _MPI_try_staged_settings(${LANG} test_mpi normal FALSE)
- # If 'test_mpi' built correctly, we've found valid MPI settings. There might not be MPI-2 C++ support, but there can't
- # be MPI-2 C++ support without the C bindings being present, so checking for them is sufficient.
- set(MPI_${LANG}_WORKS "${MPI_RESULT_${LANG}_test_mpi_normal}")
- endif()
- endif()
-endmacro()
-
-# Some systems install various MPI implementations in separate folders in some MPI prefix
-# This macro enumerates all such subfolders and adds them to the list of hints that will be searched.
-macro(MPI_search_mpi_prefix_folder PREFIX_FOLDER)
- if(EXISTS "${PREFIX_FOLDER}")
- file(GLOB _MPI_folder_children RELATIVE "${PREFIX_FOLDER}" "${PREFIX_FOLDER}/*")
- foreach(_MPI_folder_child IN LISTS _MPI_folder_children)
- if(IS_DIRECTORY "${PREFIX_FOLDER}/${_MPI_folder_child}")
- list(APPEND MPI_HINT_DIRS "${PREFIX_FOLDER}/${_MPI_folder_child}")
- endif()
- endforeach()
- endif()
-endmacro()
-
-set(MPI_HINT_DIRS ${MPI_HOME} $ENV{MPI_HOME} $ENV{I_MPI_ROOT})
-if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux")
- # SUSE Linux Enterprise Server stores its MPI implementations under /usr/lib64/mpi/gcc/<name>
- # We enumerate the subfolders and append each as a prefix
- MPI_search_mpi_prefix_folder("/usr/lib64/mpi/gcc")
-elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
- # MSMPI stores its runtime in a special folder, this adds the possible locations to the hints.
- list(APPEND MPI_HINT_DIRS $ENV{MSMPI_BIN} "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MPI;InstallRoot]")
-elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "FreeBSD")
- # FreeBSD ships mpich under the normal system paths - but available openmpi implementations
- # will be found in /usr/local/mpi/<name>
- MPI_search_mpi_prefix_folder("/usr/local/mpi")
-endif()
-
-# Most MPI distributions have some form of mpiexec or mpirun which gives us something we can look for.
-# The MPI standard does not mandate the existence of either, but instead only makes requirements if a distribution
-# ships an mpiexec program (mpirun executables are not regulated by the standard).
-find_program(MPIEXEC_EXECUTABLE
- NAMES ${_MPIEXEC_NAMES}
- PATH_SUFFIXES bin sbin
- HINTS ${MPI_HINT_DIRS}
- DOC "Executable for running MPI programs.")
-
-# call get_filename_component twice to remove mpiexec and the directory it exists in (typically bin).
-# This gives us a fairly reliable base directory to search for /bin /lib and /include from.
-get_filename_component(_MPI_BASE_DIR "${MPIEXEC_EXECUTABLE}" PATH)
-get_filename_component(_MPI_BASE_DIR "${_MPI_BASE_DIR}" PATH)
-
-# According to the MPI standard, section 8.8 -n is a guaranteed, and the only guaranteed way to
-# launch an MPI process using mpiexec if such a program exists.
-set(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "Flag used by MPI to specify the number of processes for mpiexec; the next option will be the number of processes.")
-set(MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by mpiexec.")
-set(MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will be placed after all flags passed to mpiexec.")
-
-# Set the number of processes to the physical processor count
-cmake_host_system_information(RESULT _MPIEXEC_NUMPROCS QUERY NUMBER_OF_PHYSICAL_CORES)
-set(MPIEXEC_MAX_NUMPROCS "${_MPIEXEC_NUMPROCS}" CACHE STRING "Maximum number of processors available to run MPI applications.")
-unset(_MPIEXEC_NUMPROCS)
-mark_as_advanced(MPIEXEC_EXECUTABLE MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXEC_POSTFLAGS MPIEXEC_MAX_NUMPROCS)
-
-#=============================================================================
-# Backward compatibility input hacks. Propagate the FindMPI hints to C and
-# CXX if the respective new versions are not defined. Translate the old
-# MPI_LIBRARY and MPI_EXTRA_LIBRARY to respective MPI_${LANG}_LIBRARIES.
-#
-# Once we find the new variables, we translate them back into their old
-# equivalents below.
-if(NOT MPI_IGNORE_LEGACY_VARIABLES)
- foreach (LANG IN ITEMS C CXX)
- # Old input variables.
- set(_MPI_OLD_INPUT_VARS COMPILER COMPILE_FLAGS INCLUDE_PATH LINK_FLAGS)
-
- # Set new vars based on their old equivalents, if the new versions are not already set.
- foreach (var ${_MPI_OLD_INPUT_VARS})
- if (NOT MPI_${LANG}_${var} AND MPI_${var})
- set(MPI_${LANG}_${var} "${MPI_${var}}")
- endif()
- endforeach()
-
- # Chop the old compile flags into options and definitions
-
- unset(MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS)
- unset(MPI_${LANG}_EXTRA_COMPILE_OPTIONS)
- if(MPI_${LANG}_COMPILE_FLAGS)
- separate_arguments(MPI_SEPARATE_FLAGS NATIVE_COMMAND "${MPI_${LANG}_COMPILE_FLAGS}")
- foreach(_MPI_FLAG IN LISTS MPI_SEPARATE_FLAGS)
- if("${_MPI_FLAG}" MATCHES "^ *[-/D]([^ ]+)")
- list(APPEND MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS "${CMAKE_MATCH_1}")
- else()
- list(APPEND MPI_${LANG}_EXTRA_COMPILE_OPTIONS "${_MPI_FLAG}")
- endif()
- endforeach()
- unset(MPI_SEPARATE_FLAGS)
- endif()
-
- # If a list of libraries was given, we'll split it into new-style cache variables
- unset(MPI_${LANG}_EXTRA_LIB_NAMES)
- if(NOT MPI_${LANG}_LIB_NAMES)
- foreach(_MPI_LIB IN LISTS MPI_${LANG}_LIBRARIES MPI_LIBRARY MPI_EXTRA_LIBRARY)
- if(_MPI_LIB)
- get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB}" NAME_WE)
- get_filename_component(_MPI_LIB_NAME "${_MPI_LIB}" NAME)
- get_filename_component(_MPI_LIB_DIR "${_MPI_LIB}" DIRECTORY)
- list(APPEND MPI_${LANG}_EXTRA_LIB_NAMES "${_MPI_PLAIN_LIB_NAME}")
- find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY
- NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}"
- HINTS ${_MPI_LIB_DIR} $ENV{MPI_LIB}
- DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI"
- )
- mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY)
- endif()
- endforeach()
- endif()
- endforeach()
-endif()
-#=============================================================================
-
-unset(MPI_VERSION)
-unset(MPI_VERSION_MAJOR)
-unset(MPI_VERSION_MINOR)
-
-unset(_MPI_MIN_VERSION)
-
-# If the user specified a library name we assume they prefer that library over a wrapper. If not, they can disable skipping manually.
-if(NOT DEFINED MPI_SKIP_COMPILER_WRAPPER AND MPI_GUESS_LIBRARY_NAME)
- set(MPI_SKIP_COMPILER_WRAPPER TRUE)
-endif()
-
-# This loop finds the compilers and sends them off for interrogation.
-foreach(LANG IN ITEMS C CXX Fortran)
- if(CMAKE_${LANG}_COMPILER_LOADED)
- if(NOT MPI_FIND_COMPONENTS)
- set(_MPI_FIND_${LANG} TRUE)
- elseif( ${LANG} IN_LIST MPI_FIND_COMPONENTS)
- set(_MPI_FIND_${LANG} TRUE)
- elseif( ${LANG} STREQUAL CXX AND NOT MPI_CXX_SKIP_MPICXX AND MPICXX IN_LIST MPI_FIND_COMPONENTS )
- set(_MPI_FIND_${LANG} TRUE)
- else()
- set(_MPI_FIND_${LANG} FALSE)
- endif()
- else()
- set(_MPI_FIND_${LANG} FALSE)
- endif()
- if(_MPI_FIND_${LANG})
- if( ${LANG} STREQUAL CXX AND NOT MPICXX IN_LIST MPI_FIND_COMPONENTS )
- set(MPI_CXX_SKIP_MPICXX FALSE CACHE BOOL "If true, the MPI-2 C++ bindings are disabled using definitions.")
- mark_as_advanced(MPI_CXX_SKIP_MPICXX)
- endif()
- if(NOT (MPI_${LANG}_LIB_NAMES AND (MPI_${LANG}_INCLUDE_PATH OR MPI_${LANG}_INCLUDE_DIRS OR MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)))
- set(MPI_${LANG}_TRIED_IMPLICIT FALSE)
- set(MPI_${LANG}_WORKS_IMPLICIT FALSE)
- if(NOT MPI_${LANG}_COMPILER AND NOT MPI_ASSUME_NO_BUILTIN_MPI)
- # Should the imported targets be empty, we effectively try whether the compiler supports MPI on its own, which is the case on e.g.
- # Cray PrgEnv.
- _MPI_create_imported_target(${LANG})
- _MPI_check_lang_works(${LANG})
-
- # If the compiler can build MPI code on its own, it functions as an MPI compiler and we'll set the variable to point to it.
- if(MPI_${LANG}_WORKS)
- set(MPI_${LANG}_COMPILER "${CMAKE_${LANG}_COMPILER}" CACHE FILEPATH "MPI compiler for ${LANG}" FORCE)
- set(MPI_${LANG}_WORKS_IMPLICIT TRUE)
- endif()
- set(MPI_${LANG}_TRIED_IMPLICIT TRUE)
- endif()
-
- if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS)
- set(MPI_${LANG}_WRAPPER_FOUND FALSE)
- set(MPI_PINNED_COMPILER FALSE)
-
- if(NOT MPI_SKIP_COMPILER_WRAPPER)
- if(MPI_${LANG}_COMPILER)
- # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler.
- if (NOT IS_ABSOLUTE "${MPI_${LANG}_COMPILER}")
- # Get rid of our default list of names and just search for the name the user wants.
- set(_MPI_${LANG}_COMPILER_NAMES "${MPI_${LANG}_COMPILER}")
- unset(MPI_${LANG}_COMPILER CACHE)
- endif()
- # If the user specifies a compiler, we don't want to try to search libraries either.
- set(MPI_PINNED_COMPILER TRUE)
- endif()
-
- # If we have an MPI base directory, we'll try all compiler names in that one first.
- # This should prevent mixing different MPI environments
- if(_MPI_BASE_DIR)
- find_program(MPI_${LANG}_COMPILER
- NAMES ${_MPI_${LANG}_COMPILER_NAMES}
- PATH_SUFFIXES bin sbin
- HINTS ${_MPI_BASE_DIR}
- NO_DEFAULT_PATH
- DOC "MPI compiler for ${LANG}"
- )
- endif()
-
- # If the base directory did not help (for example because the mpiexec isn't in the same directory as the compilers),
- # we shall try searching in the default paths.
- find_program(MPI_${LANG}_COMPILER
- NAMES ${_MPI_${LANG}_COMPILER_NAMES}
- PATH_SUFFIXES bin sbin
- DOC "MPI compiler for ${LANG}"
- )
-
- if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}")
- set(MPI_PINNED_COMPILER TRUE)
-
- # If we haven't made the implicit compiler test yet, perform it now.
- if(NOT MPI_${LANG}_TRIED_IMPLICIT)
- _MPI_create_imported_target(${LANG})
- _MPI_check_lang_works(${LANG})
- endif()
-
- # Should the MPI compiler not work implicitly for MPI, still interrogate it.
- # Otherwise, MPI compilers for which CMake has separate linking stages, e.g. Intel MPI on Windows where link.exe is being used
- # directly during linkage instead of CMAKE_<LANG>_COMPILER will not work.
- if(NOT MPI_${LANG}_WORKS)
- set(MPI_${LANG}_WORKS_IMPLICIT FALSE)
- _MPI_interrogate_compiler(${LANG})
- else()
- set(MPI_${LANG}_WORKS_IMPLICIT TRUE)
- endif()
- elseif(MPI_${LANG}_COMPILER)
- _MPI_interrogate_compiler(${LANG})
- endif()
- endif()
-
- if(NOT MPI_SKIP_GUESSING AND NOT MPI_${LANG}_WRAPPER_FOUND AND NOT MPI_PINNED_COMPILER)
- # For C++, we may use the settings for C. Should a given compiler wrapper for C++ not exist, but one for C does, we copy over the
- # settings for C. An MPI distribution that is in this situation would be IBM Platform MPI.
- if("${LANG}" STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND)
- set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_C_COMPILE_OPTIONS} CACHE STRING "MPI ${LANG} compilation options" )
- set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_C_COMPILE_DEFINITIONS} CACHE STRING "MPI ${LANG} compilation definitions" )
- set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_C_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories")
- set(MPI_${LANG}_LINK_FLAGS ${MPI_C_LINK_FLAGS} CACHE STRING "MPI ${LANG} linker flags" )
- set(MPI_${LANG}_LIB_NAMES ${MPI_C_LIB_NAMES} CACHE STRING "MPI ${LANG} libraries to link against" )
- else()
- _MPI_guess_settings(${LANG})
- endif()
- endif()
- endif()
- endif()
-
- _MPI_split_include_dirs(${LANG})
- _MPI_assemble_include_dirs(${LANG})
- _MPI_assemble_libraries(${LANG})
-
- _MPI_adjust_compile_definitions(${LANG})
- # We always create imported targets even if they're empty
- _MPI_create_imported_target(${LANG})
-
- if(NOT MPI_${LANG}_WORKS)
- _MPI_check_lang_works(${LANG})
- endif()
-
- # Next, we'll initialize the MPI variables that have not been previously set.
- set(MPI_${LANG}_COMPILE_OPTIONS "" CACHE STRING "MPI ${LANG} compilation flags" )
- set(MPI_${LANG}_COMPILE_DEFINITIONS "" CACHE STRING "MPI ${LANG} compilation definitions" )
- set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "MPI ${LANG} additional include directories")
- set(MPI_${LANG}_LINK_FLAGS "" CACHE STRING "MPI ${LANG} linker flags" )
- if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER)
- set(MPI_${LANG}_LIB_NAMES "" CACHE STRING "MPI ${LANG} libraries to link against" )
- endif()
- mark_as_advanced(MPI_${LANG}_COMPILE_OPTIONS MPI_${LANG}_COMPILE_DEFINITIONS MPI_${LANG}_LINK_FLAGS
- MPI_${LANG}_LIB_NAMES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS MPI_${LANG}_COMPILER)
-
- # If we've found MPI, then we'll perform additional analysis: Determine the MPI version, MPI library version, supported
- # MPI APIs (i.e. MPI-2 C++ bindings). For Fortran we also need to find specific parameters if we're under MPI-3.
- if(MPI_${LANG}_WORKS)
- if("${LANG}" STREQUAL "CXX" AND NOT DEFINED MPI_MPICXX_FOUND)
- if(NOT MPI_CXX_SKIP_MPICXX AND NOT MPI_CXX_VALIDATE_SKIP_MPICXX)
- _MPI_try_staged_settings(${LANG} test_mpi MPICXX FALSE)
- if(MPI_RESULT_${LANG}_test_mpi_MPICXX)
- set(MPI_MPICXX_FOUND TRUE)
- else()
- set(MPI_MPICXX_FOUND FALSE)
- endif()
- else()
- set(MPI_MPICXX_FOUND FALSE)
- endif()
- endif()
-
- # At this point, we know the bindings present but not the MPI version or anything else.
- if(NOT DEFINED MPI_${LANG}_VERSION)
- unset(MPI_${LANG}_VERSION_MAJOR)
- unset(MPI_${LANG}_VERSION_MINOR)
- endif()
- set(MPI_BIN_FOLDER ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI)
-
- # For Fortran, we'll want to use the most modern MPI binding to test capabilities other than the
- # Fortran parameters, since those depend on the method of consumption.
- # For C++, we can always use the C bindings, and should do so, since the C++ bindings do not exist in MPI-3
- # whereas the C bindings do, and the C++ bindings never offered any feature advantage over their C counterparts.
- if("${LANG}" STREQUAL "Fortran")
- if(MPI_${LANG}_HAVE_F08_MODULE)
- set(MPI_${LANG}_HIGHEST_METHOD F08_MODULE)
- elseif(MPI_${LANG}_HAVE_F90_MODULE)
- set(MPI_${LANG}_HIGHEST_METHOD F90_MODULE)
- else()
- set(MPI_${LANG}_HIGHEST_METHOD F77_HEADER)
- endif()
-
- # Another difference between C and Fortran is that we can't use the preprocessor to determine whether MPI_VERSION
- # and MPI_SUBVERSION are provided. These defines did not exist in MPI 1.0 and 1.1 and therefore might not
- # exist. For C/C++, test_mpi.c will handle the MPI_VERSION extraction, but for Fortran, we need mpiver.f90.
- if(NOT DEFINED MPI_${LANG}_VERSION)
- _MPI_try_staged_settings(${LANG} mpiver ${MPI_${LANG}_HIGHEST_METHOD} FALSE)
- if(MPI_RESULT_${LANG}_mpiver_${MPI_${LANG}_HIGHEST_METHOD})
- file(STRINGS ${MPI_BIN_FOLDER}/mpiver_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER")
- if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*")
- set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}")
- set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}")
- set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}")
- endif()
- endif()
- endif()
-
- # Finally, we want to find out which capabilities a given interface supports, compare the MPI-3 standard.
- # This is determined by interface specific parameters MPI_SUBARRAYS_SUPPORTED and MPI_ASYNC_PROTECTS_NONBLOCKING
- # and might vary between the different methods of consumption.
- if(MPI_DETERMINE_Fortran_CAPABILITIES AND NOT MPI_Fortran_CAPABILITIES_DETERMINED)
- foreach(mpimethod IN ITEMS F08_MODULE F90_MODULE F77_HEADER)
- if(MPI_${LANG}_HAVE_${mpimethod})
- set(MPI_${LANG}_${mpimethod}_SUBARRAYS FALSE)
- set(MPI_${LANG}_${mpimethod}_ASYNCPROT FALSE)
- _MPI_try_staged_settings(${LANG} fortranparam_mpi ${mpimethod} TRUE)
- if(MPI_RESULT_${LANG}_fortranparam_mpi_${mpimethod} AND
- NOT "${MPI_RUN_RESULT_${LANG}_fortranparam_mpi_${mpimethod}}" STREQUAL "FAILED_TO_RUN")
- if("${MPI_RUN_OUTPUT_${LANG}_fortranparam_mpi_${mpimethod}}" MATCHES
- ".*INFO:SUBARRAYS\\[ *([TF]) *\\]-ASYNCPROT\\[ *([TF]) *\\].*")
- if("${CMAKE_MATCH_1}" STREQUAL "T")
- set(MPI_${LANG}_${mpimethod}_SUBARRAYS TRUE)
- endif()
- if("${CMAKE_MATCH_2}" STREQUAL "T")
- set(MPI_${LANG}_${mpimethod}_ASYNCPROT TRUE)
- endif()
- endif()
- endif()
- endif()
- endforeach()
- set(MPI_Fortran_CAPABILITIES_DETERMINED TRUE)
- endif()
- else()
- set(MPI_${LANG}_HIGHEST_METHOD normal)
-
- # By the MPI-2 standard, MPI_VERSION and MPI_SUBVERSION are valid for both C and C++ bindings.
- if(NOT DEFINED MPI_${LANG}_VERSION)
- file(STRINGS ${MPI_BIN_FOLDER}/test_mpi_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER")
- if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*")
- set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}")
- set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}")
- set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}")
- endif()
- endif()
- endif()
-
- unset(MPI_BIN_FOLDER)
-
- # At this point, we have dealt with determining the MPI version and parameters for each Fortran method available.
- # The one remaining issue is to determine which MPI library is installed.
- # Determining the version and vendor of the MPI library is only possible via MPI_Get_library_version() at runtime,
- # and therefore we cannot do this while cross-compiling (a user may still define MPI_<lang>_LIBRARY_VERSION_STRING
- # themselves and we'll attempt splitting it, which is equivalent to provide the try_run output).
- # It's also worth noting that the installed version string can depend on the language, or on the system the binary
- # runs on if MPI is not statically linked.
- if(MPI_DETERMINE_LIBRARY_VERSION AND NOT MPI_${LANG}_LIBRARY_VERSION_STRING)
- _MPI_try_staged_settings(${LANG} libver_mpi ${MPI_${LANG}_HIGHEST_METHOD} TRUE)
- if(MPI_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD} AND
- "${MPI_RUN_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" EQUAL "0")
- string(STRIP "${MPI_RUN_OUTPUT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}"
- MPI_${LANG}_LIBRARY_VERSION_STRING)
- else()
- set(MPI_${LANG}_LIBRARY_VERSION_STRING "NOTFOUND")
- endif()
- endif()
- endif()
-
- set(MPI_${LANG}_FIND_QUIETLY ${MPI_FIND_QUIETLY})
- set(MPI_${LANG}_FIND_VERSION ${MPI_FIND_VERSION})
- set(MPI_${LANG}_FIND_VERSION_EXACT ${MPI_FIND_VERSION_EXACT})
-
- unset(MPI_${LANG}_REQUIRED_VARS)
- if (NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}")
- foreach(mpilibname IN LISTS MPI_${LANG}_LIB_NAMES)
- list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpilibname}_LIBRARY")
- endforeach()
- list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_LIB_NAMES")
- if("${LANG}" STREQUAL "Fortran")
- # For Fortran we only need one of the module or header directories to have *some* support for MPI.
- if(NOT MPI_${LANG}_MODULE_DIR)
- list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_F77_HEADER_DIR")
- endif()
- if(NOT MPI_${LANG}_F77_HEADER_DIR)
- list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_MODULE_DIR")
- endif()
- else()
- list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_HEADER_DIR")
- endif()
- if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS)
- foreach(mpiincvar IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS)
- list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpiincvar}_INCLUDE_DIR")
- endforeach()
- endif()
- # Append the works variable now. If the settings did not work, this will show up properly.
- list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS")
- else()
- # If the compiler worked implicitly, use its path as output.
- # Should the compiler variable be set, we also require it to work.
- list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_COMPILER")
- if(MPI_${LANG}_COMPILER)
- list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS")
- endif()
- endif()
- find_package_handle_standard_args(MPI_${LANG} REQUIRED_VARS ${MPI_${LANG}_REQUIRED_VARS}
- VERSION_VAR MPI_${LANG}_VERSION)
-
- if(DEFINED MPI_${LANG}_VERSION)
- if(NOT _MPI_MIN_VERSION OR _MPI_MIN_VERSION VERSION_GREATER MPI_${LANG}_VERSION)
- set(_MPI_MIN_VERSION MPI_${LANG}_VERSION)
- endif()
- endif()
- endif()
-endforeach()
-
-unset(_MPI_REQ_VARS)
-foreach(LANG IN ITEMS C CXX Fortran)
- if((NOT MPI_FIND_COMPONENTS AND CMAKE_${LANG}_COMPILER_LOADED) OR LANG IN_LIST MPI_FIND_COMPONENTS)
- list(APPEND _MPI_REQ_VARS "MPI_${LANG}_FOUND")
- endif()
-endforeach()
-
-if(MPICXX IN_LIST MPI_FIND_COMPONENTS)
- list(APPEND _MPI_REQ_VARS "MPI_MPICXX_FOUND")
-endif()
-
-find_package_handle_standard_args(MPI
- REQUIRED_VARS ${_MPI_REQ_VARS}
- VERSION_VAR ${_MPI_MIN_VERSION}
- HANDLE_COMPONENTS)
-
-#=============================================================================
-# More backward compatibility stuff
-
-# For compatibility reasons, we also define MPIEXEC
-set(MPIEXEC "${MPIEXEC_EXECUTABLE}")
-
-# Copy over MPI_<LANG>_INCLUDE_PATH from the assembled INCLUDE_DIRS.
-foreach(LANG IN ITEMS C CXX Fortran)
- if(MPI_${LANG}_FOUND)
- set(MPI_${LANG}_INCLUDE_PATH "${MPI_${LANG}_INCLUDE_DIRS}")
- unset(MPI_${LANG}_COMPILE_FLAGS)
- if(MPI_${LANG}_COMPILE_OPTIONS)
- set(MPI_${LANG}_COMPILE_FLAGS "${MPI_${LANG}_COMPILE_OPTIONS}")
- endif()
- if(MPI_${LANG}_COMPILE_DEFINITIONS)
- foreach(_MPI_DEF IN LISTS MPI_${LANG}_COMPILE_DEFINITIONS)
- string(APPEND MPI_${LANG}_COMPILE_FLAGS " -D${_MPI_DEF}")
- endforeach()
- endif()
- endif()
-endforeach()
-
-# Bare MPI sans ${LANG} vars are set to CXX then C, depending on what was found.
-# This mimics the behavior of the old language-oblivious FindMPI.
-set(_MPI_OLD_VARS COMPILER INCLUDE_PATH COMPILE_FLAGS LINK_FLAGS LIBRARIES)
-if (MPI_CXX_FOUND)
- foreach (var ${_MPI_OLD_VARS})
- set(MPI_${var} ${MPI_CXX_${var}})
- endforeach()
-elseif (MPI_C_FOUND)
- foreach (var ${_MPI_OLD_VARS})
- set(MPI_${var} ${MPI_C_${var}})
- endforeach()
-endif()
-
-# Chop MPI_LIBRARIES into the old-style MPI_LIBRARY and MPI_EXTRA_LIBRARY, and set them in cache.
-if (MPI_LIBRARIES)
- list(GET MPI_LIBRARIES 0 MPI_LIBRARY_WORK)
- set(MPI_LIBRARY "${MPI_LIBRARY_WORK}")
- unset(MPI_LIBRARY_WORK)
-else()
- set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND")
-endif()
-
-list(LENGTH MPI_LIBRARIES MPI_NUMLIBS)
-if (MPI_NUMLIBS GREATER 1)
- set(MPI_EXTRA_LIBRARY_WORK "${MPI_LIBRARIES}")
- list(REMOVE_AT MPI_EXTRA_LIBRARY_WORK 0)
- set(MPI_EXTRA_LIBRARY "${MPI_EXTRA_LIBRARY_WORK}")
- unset(MPI_EXTRA_LIBRARY_WORK)
-else()
- set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND")
-endif()
-set(MPI_IGNORE_LEGACY_VARIABLES TRUE)
-#=============================================================================
-
-# unset these vars to cleanup namespace
-unset(_MPI_OLD_VARS)
-unset(_MPI_PREFIX_PATH)
-unset(_MPI_BASE_DIR)
-foreach (lang C CXX Fortran)
- unset(_MPI_${LANG}_COMPILER_NAMES)
-endforeach()
-
-cmake_policy(POP)
diff --git a/config/cmake_ext_mod/FindMPI/fortranparam_mpi.f90.in b/config/cmake_ext_mod/FindMPI/fortranparam_mpi.f90.in
deleted file mode 100644
index 30f912c..0000000
--- a/config/cmake_ext_mod/FindMPI/fortranparam_mpi.f90.in
+++ /dev/null
@@ -1,4 +0,0 @@
- program mpi_ver
- @MPI_Fortran_INCLUDE_LINE@
- print *, 'INFO:SUBARRAYS[', MPI_SUBARRAYS_SUPPORTED, ']-ASYNCPROT[', MPI_ASYNC_PROTECTS_NONBLOCKING, ']'
- end program mpi_ver
diff --git a/config/cmake_ext_mod/FindMPI/libver_mpi.c b/config/cmake_ext_mod/FindMPI/libver_mpi.c
deleted file mode 100644
index be9d19d..0000000
--- a/config/cmake_ext_mod/FindMPI/libver_mpi.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <mpi.h>
-
-#ifdef __cplusplus
-#include <cstdio>
-#else
-#include <stdio.h>
-#endif
-
-int main(int argc, char* argv[])
-{
- char mpilibver_str[MPI_MAX_LIBRARY_VERSION_STRING];
- int mpilibver_len;
- MPI_Get_library_version(mpilibver_str, &mpilibver_len);
-#ifdef __cplusplus
- std::puts(mpilibver_str);
-#else
- puts(mpilibver_str);
-#endif
-}
diff --git a/config/cmake_ext_mod/FindMPI/libver_mpi.f90.in b/config/cmake_ext_mod/FindMPI/libver_mpi.f90.in
deleted file mode 100644
index 7938587..0000000
--- a/config/cmake_ext_mod/FindMPI/libver_mpi.f90.in
+++ /dev/null
@@ -1,7 +0,0 @@
- program mpi_ver
- @MPI_Fortran_INCLUDE_LINE@
- character(len=MPI_MAX_LIBRARY_VERSION_STRING) :: mpilibver_str
- integer(kind=MPI_INTEGER_KIND) :: ierror, reslen
- call MPI_GET_LIBRARY_VERSION(mpilibver_str, reslen, ierror)
- print *, mpilibver_str
- end program mpi_ver
diff --git a/config/cmake_ext_mod/FindMPI/mpiver.f90.in b/config/cmake_ext_mod/FindMPI/mpiver.f90.in
deleted file mode 100644
index a254523..0000000
--- a/config/cmake_ext_mod/FindMPI/mpiver.f90.in
+++ /dev/null
@@ -1,10 +0,0 @@
- program mpi_ver
- @MPI_Fortran_INCLUDE_LINE@
- integer(kind=kind(MPI_VERSION)), parameter :: zero = ichar('0')
- character, dimension(17), parameter :: mpiver_str =&
- (/ 'I', 'N', 'F', 'O', ':', 'M', 'P', 'I', '-', 'V', 'E', 'R', '[', &
- char(zero + MPI_VERSION), &
- '.', &
- char(zero + MPI_SUBVERSION), ']' /)
- print *, mpiver_str
- end program mpi_ver
diff --git a/config/cmake_ext_mod/FindMPI/test_mpi.c b/config/cmake_ext_mod/FindMPI/test_mpi.c
deleted file mode 100644
index b8a308a..0000000
--- a/config/cmake_ext_mod/FindMPI/test_mpi.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include <mpi.h>
-
-#ifdef __cplusplus
-#include <cstdio>
-#else
-#include <stdio.h>
-#endif
-
-#if defined(MPI_VERSION) && defined(MPI_SUBVERSION)
-const char mpiver_str[] = { 'I', 'N',
- 'F', 'O',
- ':', 'M',
- 'P', 'I',
- '-', 'V',
- 'E', 'R',
- '[', ('0' + MPI_VERSION),
- '.', ('0' + MPI_SUBVERSION),
- ']', '\0' };
-#endif
-
-int main(int argc, char* argv[])
-{
-#if defined(MPI_VERSION) && defined(MPI_SUBVERSION)
-#ifdef __cplusplus
- std::puts(mpiver_str);
-#else
- puts(mpiver_str);
-#endif
-#endif
-#ifdef TEST_MPI_MPICXX
- MPI::MPI_Init(&argc, &argv);
- MPI::MPI_Finalize();
-#else
- MPI_Init(&argc, &argv);
- MPI_Finalize();
-#endif
-}
diff --git a/config/cmake_ext_mod/FindMPI/test_mpi.f90.in b/config/cmake_ext_mod/FindMPI/test_mpi.f90.in
deleted file mode 100644
index 4d43a04..0000000
--- a/config/cmake_ext_mod/FindMPI/test_mpi.f90.in
+++ /dev/null
@@ -1,6 +0,0 @@
- program hello
- @MPI_Fortran_INCLUDE_LINE@
- integer@MPI_Fortran_INTEGER_LINE@ ierror
- call MPI_INIT(ierror)
- call MPI_FINALIZE(ierror)
- end program
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index e9430d9..4da8405 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_EXAMPLES)
#-----------------------------------------------------------------------------
diff --git a/fortran/CMakeLists.txt b/fortran/CMakeLists.txt
index 7864f2d..8c7b8f6 100644
--- a/fortran/CMakeLists.txt
+++ b/fortran/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_F90 C CXX Fortran)
if (H5_HAVE_PARALLEL)
diff --git a/fortran/examples/CMakeLists.txt b/fortran/examples/CMakeLists.txt
index 9adf8bd..8b7333a 100644
--- a/fortran/examples/CMakeLists.txt
+++ b/fortran/examples/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_F90_EXAMPLES C CXX Fortran)
# --------------------------------------------------------------------
# Notes: When creating examples they should be prefixed
diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt
index 9bf1719..3abab4e 100644
--- a/fortran/src/CMakeLists.txt
+++ b/fortran/src/CMakeLists.txt
@@ -1,5 +1,5 @@
-cmake_minimum_required (VERSION 3.3.2)
-PROJECT (HDF5_F90_SRC C CXX Fortran)
+cmake_minimum_required (VERSION 3.10)
+project (HDF5_F90_SRC C CXX Fortran)
#-----------------------------------------------------------------------------
# configure def file for shared libs on windows
@@ -295,7 +295,7 @@ if (BUILD_SHARED_LIBS)
)
if (WIN32)
set_property (TARGET ${HDF5_F90_LIBSH_TARGET}
- APPEND PROPERTY COMPILE_DEFINITIONS "BUILD_HDF5_DLL;HDF5F90_WINDOWS"
+ APPEND PROPERTY COMPILE_DEFINITIONS "BUILD_HDF5_DLL;HDF5F90_WINDOWS"
)
endif ()
set (install_targets ${install_targets} ${HDF5_F90_LIBSH_TARGET})
diff --git a/fortran/test/CMakeLists.txt b/fortran/test/CMakeLists.txt
index 67d377f..b71a8eb 100644
--- a/fortran/test/CMakeLists.txt
+++ b/fortran/test/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_FORTRAN_TESTS C CXX Fortran)
#-----------------------------------------------------------------------------
diff --git a/fortran/testpar/CMakeLists.txt b/fortran/testpar/CMakeLists.txt
index b1cf9d2..979d305 100644
--- a/fortran/testpar/CMakeLists.txt
+++ b/fortran/testpar/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_FORTRAN_TESTPAR C CXX Fortran)
#-----------------------------------------------------------------------------
diff --git a/hl/CMakeLists.txt b/hl/CMakeLists.txt
index eac6df0..54d5976 100644
--- a/hl/CMakeLists.txt
+++ b/hl/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_HL C CXX)
#-----------------------------------------------------------------------------
diff --git a/hl/c++/CMakeLists.txt b/hl/c++/CMakeLists.txt
index c5b4a72..71e5bb3 100644
--- a/hl/c++/CMakeLists.txt
+++ b/hl/c++/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_HL_CPP)
#-----------------------------------------------------------------------------
diff --git a/hl/c++/examples/CMakeLists.txt b/hl/c++/examples/CMakeLists.txt
index bf96fba..25158f2 100644
--- a/hl/c++/examples/CMakeLists.txt
+++ b/hl/c++/examples/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_HL_CPP_EXAMPLES)
#-----------------------------------------------------------------------------
diff --git a/hl/c++/src/CMakeLists.txt b/hl/c++/src/CMakeLists.txt
index 28f860f..c0cc09e 100644
--- a/hl/c++/src/CMakeLists.txt
+++ b/hl/c++/src/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_HL_CPP_SRC)
#-----------------------------------------------------------------------------
diff --git a/hl/c++/test/CMakeLists.txt b/hl/c++/test/CMakeLists.txt
index 28b5eb8..b48d147 100644
--- a/hl/c++/test/CMakeLists.txt
+++ b/hl/c++/test/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_HL_CPP_TEST)
#-----------------------------------------------------------------------------
diff --git a/hl/examples/CMakeLists.txt b/hl/examples/CMakeLists.txt
index dd94da0..79dfee1 100644
--- a/hl/examples/CMakeLists.txt
+++ b/hl/examples/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_HL_EXAMPLES )
#-----------------------------------------------------------------------------
diff --git a/hl/fortran/CMakeLists.txt b/hl/fortran/CMakeLists.txt
index 37c5cc9..7955de2 100644
--- a/hl/fortran/CMakeLists.txt
+++ b/hl/fortran/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_HL_F90 C CXX Fortran)
#-----------------------------------------------------------------------------
diff --git a/hl/fortran/examples/CMakeLists.txt b/hl/fortran/examples/CMakeLists.txt
index ff0403a..411ceea 100644
--- a/hl/fortran/examples/CMakeLists.txt
+++ b/hl/fortran/examples/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_HL_F90_EXAMPLES C CXX Fortran)
#-----------------------------------------------------------------------------
diff --git a/hl/fortran/src/CMakeLists.txt b/hl/fortran/src/CMakeLists.txt
index 7a2eff1..6dd94fe 100644
--- a/hl/fortran/src/CMakeLists.txt
+++ b/hl/fortran/src/CMakeLists.txt
@@ -1,5 +1,5 @@
-cmake_minimum_required (VERSION 3.3.2)
-PROJECT(HDF5_HL_F90_SRC C CXX Fortran)
+cmake_minimum_required (VERSION 3.10)
+project (HDF5_HL_F90_SRC C CXX Fortran)
#-----------------------------------------------------------------------------
# configure def file for shared libs on windows
@@ -37,10 +37,10 @@ set_target_properties (H5HL_buildiface PROPERTIES
)
if (BUILD_SHARED_LIBS)
- file (MAKE_DIRECTORY "${HDF5_HL_F90_SRC_BINARY_DIR}/shared")
+ file (MAKE_DIRECTORY "${HDF5_HL_F90_BINARY_DIR}/shared")
set (MODSH_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/shared/${HDF_CFG_BUILD_TYPE})
endif ()
-file (MAKE_DIRECTORY "${HDF5_HL_F90_SRC_BINARY_DIR}/static")
+file (MAKE_DIRECTORY "${HDF5_HL_F90_BINARY_DIR}/static")
set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/static/${HDF_CFG_BUILD_TYPE})
#-----------------------------------------------------------------------------
@@ -110,34 +110,34 @@ set (HDF5_HL_F90_F_BASE_SOURCES
)
add_custom_command (
- OUTPUT ${HDF5_HL_F90_SRC_BINARY_DIR}/static/H5LTff_gen.F90 ${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90
+ OUTPUT ${HDF5_HL_F90_BINARY_DIR}/static/H5LTff_gen.F90 ${HDF5_HL_F90_BINARY_DIR}/H5TBff_gen.F90
COMMAND $<TARGET_FILE:H5HL_buildiface>
- WORKING_DIRECTORY ${HDF5_HL_F90_SRC_BINARY_DIR}/static
+ WORKING_DIRECTORY ${HDF5_HL_F90_BINARY_DIR}/static
DEPENDS ${HDF5_HL_F90_F_BASE_SOURCES}
COMMENT "Generating the H5LTff_gen.F90, H5TBff_gen.F90 files"
)
add_custom_target (H5HLgen ALL
- DEPENDS ${HDF5_HL_F90_SRC_BINARY_DIR}/static/H5LTff_gen.F90 ${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90
+ DEPENDS ${HDF5_HL_F90_BINARY_DIR}/static/H5LTff_gen.F90 ${HDF5_HL_F90_BINARY_DIR}/H5TBff_gen.F90
)
set_source_files_properties (
- ${HDF5_HL_F90_SRC_BINARY_DIR}/static/H5LTff_gen.F90
- ${HDF5_HL_F90_SRC_BINARY_DIR}/static/H5TBff_gen.F90
+ ${HDF5_HL_F90_BINARY_DIR}/static/H5LTff_gen.F90
+ ${HDF5_HL_F90_BINARY_DIR}/static/H5TBff_gen.F90
PROPERTIES GENERATED TRUE
)
if (BUILD_SHARED_LIBS)
add_custom_command (
- OUTPUT ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5LTff_gen.F90 ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5TBff_gen.F90
+ OUTPUT ${HDF5_HL_F90_BINARY_DIR}/shared/H5LTff_gen.F90 ${HDF5_HL_F90_BINARY_DIR}/shared/H5TBff_gen.F90
COMMAND $<TARGET_FILE:H5HL_buildiface>
- WORKING_DIRECTORY ${HDF5_HL_F90_SRC_BINARY_DIR}/shared
+ WORKING_DIRECTORY ${HDF5_HL_F90_BINARY_DIR}/shared
DEPENDS ${HDF5_HL_F90_F_BASE_SOURCES}
COMMENT "Generating the H5LTff_gen.F90, H5TBff_gen.F90 shared files"
)
add_custom_target (H5HLgenSH ALL
- DEPENDS ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5LTff_gen.F90 ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5TBff_gen.F90
+ DEPENDS ${HDF5_HL_F90_BINARY_DIR}/shared/H5LTff_gen.F90 ${HDF5_HL_F90_BINARY_DIR}/shared/H5TBff_gen.F90
)
set_source_files_properties (
- ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5LTff_gen.F90
- ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5TBff_gen.F90
+ ${HDF5_HL_F90_BINARY_DIR}/shared/H5LTff_gen.F90
+ ${HDF5_HL_F90_BINARY_DIR}/shared/H5TBff_gen.F90
PROPERTIES GENERATED TRUE
)
endif ()
@@ -146,8 +146,8 @@ set (HDF5_HL_F90_F_SOURCES
${HDF5_HL_F90_F_BASE_SOURCES}
# generated files
- ${HDF5_HL_F90_SRC_BINARY_DIR}/static/H5LTff_gen.F90
- ${HDF5_HL_F90_SRC_BINARY_DIR}/static/H5TBff_gen.F90
+ ${HDF5_HL_F90_BINARY_DIR}/static/H5LTff_gen.F90
+ ${HDF5_HL_F90_BINARY_DIR}/static/H5TBff_gen.F90
)
set_source_files_properties (${HDF5_HL_F90_F_SOURCES} PROPERTIES LANGUAGE Fortran)
@@ -156,8 +156,8 @@ if (BUILD_SHARED_LIBS)
${HDF5_HL_F90_F_BASE_SOURCES}
# generated files
- ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5LTff_gen.F90
- ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5TBff_gen.F90
+ ${HDF5_HL_F90_BINARY_DIR}/shared/H5LTff_gen.F90
+ ${HDF5_HL_F90_BINARY_DIR}/shared/H5TBff_gen.F90
)
set_source_files_properties (${HDF5_HL_F90_F_SOURCES_SHARED} PROPERTIES LANGUAGE Fortran)
endif ()
@@ -165,6 +165,10 @@ endif ()
add_library (${HDF5_HL_F90_LIB_TARGET} STATIC ${HDF5_HL_F90_F_SOURCES})
TARGET_FORTRAN_PROPERTIES (${HDF5_HL_F90_LIB_TARGET} STATIC " " " ")
target_link_libraries (${HDF5_HL_F90_LIB_TARGET} PUBLIC ${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_F90_LIB_TARGET})
+target_include_directories (${HDF5_HL_F90_LIB_TARGET} PUBLIC ${CMAKE_Fortran_MODULE_DIRECTORY}/static)
+if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND)
+ target_include_directories (${HDF5_HL_F90_LIB_TARGET} PUBLIC ${MPI_Fortran_INCLUDE_DIRS})
+endif ()
set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_F90_LIB_TARGET}")
H5_SET_LIB_OPTIONS (${HDF5_HL_F90_LIB_TARGET} ${HDF5_HL_F90_LIB_NAME} STATIC)
set_target_properties (${HDF5_HL_F90_LIB_TARGET} PROPERTIES
@@ -189,11 +193,17 @@ if (BUILD_SHARED_LIBS)
endif ()
TARGET_FORTRAN_PROPERTIES (${HDF5_HL_F90_LIBSH_TARGET} SHARED " " ${SHARED_LINK_FLAGS})
target_link_libraries (${HDF5_HL_F90_LIBSH_TARGET} PUBLIC ${HDF5_HL_F90_C_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET})
+ target_link_libraries (${HDF5_HL_F90_LIBSH_TARGET} PRIVATE ${LINK_Fortran_LIBS})
+ target_include_directories (${HDF5_HL_F90_LIBSH_TARGET} PUBLIC ${CMAKE_Fortran_MODULE_DIRECTORY}/shared)
+ if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND)
+ target_include_directories (${HDF5_HL_F90_LIBSH_TARGET} PUBLIC ${MPI_Fortran_INCLUDE_DIRS})
+ endif ()
set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_F90_LIBSH_TARGET}")
H5_SET_LIB_OPTIONS (${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_HL_F90_LIB_NAME} SHARED ${HDF5_HL_F_PACKAGE_SOVERSION})
set_target_properties (${HDF5_HL_F90_LIBSH_TARGET} PROPERTIES
FOLDER libraries/hl/fortran
LINKER_LANGUAGE Fortran
+ COMPILE_DEFINITIONS "H5_BUILT_AS_DYNAMIC_LIB"
INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB=1
Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared
diff --git a/hl/fortran/test/CMakeLists.txt b/hl/fortran/test/CMakeLists.txt
index 1ec4b93..5c83d03 100644
--- a/hl/fortran/test/CMakeLists.txt
+++ b/hl/fortran/test/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_HL_FORTRAN_TESTS C CXX Fortran)
#-----------------------------------------------------------------------------
diff --git a/hl/src/CMakeLists.txt b/hl/src/CMakeLists.txt
index 62e8c21..0daa86e 100644
--- a/hl/src/CMakeLists.txt
+++ b/hl/src/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_HL_SRC)
#-----------------------------------------------------------------------------
diff --git a/hl/test/CMakeLists.txt b/hl/test/CMakeLists.txt
index 1f2ea17..6b3c764 100644
--- a/hl/test/CMakeLists.txt
+++ b/hl/test/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_HL_TEST)
# --------------------------------------------------------------------
# Notes: When creating unit test executables they should be prefixed
diff --git a/hl/tools/CMakeLists.txt b/hl/tools/CMakeLists.txt
index ab71a7e..67e0ccb 100644
--- a/hl/tools/CMakeLists.txt
+++ b/hl/tools/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_HL_TOOLS C CXX)
add_subdirectory (gif2h5)
diff --git a/hl/tools/gif2h5/CMakeLists.txt b/hl/tools/gif2h5/CMakeLists.txt
index b50bbf7..2697dfd 100644
--- a/hl/tools/gif2h5/CMakeLists.txt
+++ b/hl/tools/gif2h5/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_HL_TOOLS_GIF2H5)
#-----------------------------------------------------------------------------
diff --git a/hl/tools/h5watch/CMakeLists.txt b/hl/tools/h5watch/CMakeLists.txt
index a1697cd..5de655e 100644
--- a/hl/tools/h5watch/CMakeLists.txt
+++ b/hl/tools/h5watch/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_HL_TOOLS_H5WATCH)
#-----------------------------------------------------------------------------
diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt
index d8cd358..fc057f7 100644
--- a/java/CMakeLists.txt
+++ b/java/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT ( HDF5_JAVA C Java )
set (CMAKE_MODULE_PATH "${HDF_RESOURCES_DIR};${HDF_RESOURCES_EXT_DIR}")
diff --git a/java/examples/CMakeLists.txt b/java/examples/CMakeLists.txt
index d43b49f..3d1e30e 100644
--- a/java/examples/CMakeLists.txt
+++ b/java/examples/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDFJAVA_EXAMPLES)
add_subdirectory (datasets)
diff --git a/java/examples/datasets/CMakeLists.txt b/java/examples/datasets/CMakeLists.txt
index ed4559c..6a90cd1 100644
--- a/java/examples/datasets/CMakeLists.txt
+++ b/java/examples/datasets/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDFJAVA_EXAMPLES_DATASETS Java)
set (CMAKE_VERBOSE_MAKEFILE 1)
diff --git a/java/examples/datatypes/CMakeLists.txt b/java/examples/datatypes/CMakeLists.txt
index 71cf83e..73111ed 100644
--- a/java/examples/datatypes/CMakeLists.txt
+++ b/java/examples/datatypes/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDFJAVA_EXAMPLES_DATATYPES Java)
set (CMAKE_VERBOSE_MAKEFILE 1)
diff --git a/java/examples/groups/CMakeLists.txt b/java/examples/groups/CMakeLists.txt
index dc5d834..6b55359 100644
--- a/java/examples/groups/CMakeLists.txt
+++ b/java/examples/groups/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDFJAVA_EXAMPLES_GROUPS Java)
set (CMAKE_VERBOSE_MAKEFILE 1)
diff --git a/java/examples/intro/CMakeLists.txt b/java/examples/intro/CMakeLists.txt
index 59fe48b..65db3fe 100644
--- a/java/examples/intro/CMakeLists.txt
+++ b/java/examples/intro/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDFJAVA_EXAMPLES_INTRO Java)
set (CMAKE_VERBOSE_MAKEFILE 1)
diff --git a/java/src/CMakeLists.txt b/java/src/CMakeLists.txt
index 7075d32..0c00923 100644
--- a/java/src/CMakeLists.txt
+++ b/java/src/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT ( HDF5_JAVA_SRC C Java )
#-----------------------------------------------------------------------------
diff --git a/java/src/hdf/CMakeLists.txt b/java/src/hdf/CMakeLists.txt
index 35b436d..ecff984 100644
--- a/java/src/hdf/CMakeLists.txt
+++ b/java/src/hdf/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_JAVA_HDF)
add_subdirectory (hdf5lib)
diff --git a/java/src/hdf/hdf5lib/CMakeLists.txt b/java/src/hdf/hdf5lib/CMakeLists.txt
index 1f2587e..9506fc1 100644
--- a/java/src/hdf/hdf5lib/CMakeLists.txt
+++ b/java/src/hdf/hdf5lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_JAVA_HDF_HDF5 Java)
set (CMAKE_VERBOSE_MAKEFILE 1)
diff --git a/java/src/jni/CMakeLists.txt b/java/src/jni/CMakeLists.txt
index 8ab275e..96e7035 100644
--- a/java/src/jni/CMakeLists.txt
+++ b/java/src/jni/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_JAVA_JNI C CXX)
set (HDF5_JAVA_JNI_CSRCS
diff --git a/java/test/CMakeLists.txt b/java/test/CMakeLists.txt
index 329c602..6158055 100644
--- a/java/test/CMakeLists.txt
+++ b/java/test/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_JAVA_TEST Java)
set (CMAKE_VERBOSE_MAKEFILE 1)
diff --git a/release_docs/INSTALL_CMake.txt b/release_docs/INSTALL_CMake.txt
index 923bba3..f30c1b3 100644
--- a/release_docs/INSTALL_CMake.txt
+++ b/release_docs/INSTALL_CMake.txt
@@ -648,7 +648,7 @@ adding an option (${CTEST_SCRIPT_ARG}) to the platform configuration script.
### ctest -S HDF5config.cmake,BUILD_GENERATOR=VS201764 -C Release -VV -O hdf5.log ###
#############################################################################################
-cmake_minimum_required (VERSION 3.3.2 FATAL_ERROR)
+cmake_minimum_required (VERSION 3.10)
############################################################################
# Usage:
# ctest -S HDF5config.cmake,OPTION=VALUE -C Release -VV -O test.log
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 0d739a5..36bf869 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -56,6 +56,16 @@ New Features
-------------
- CMake
+ Change minimum version to 3.10.
+
+ This change removes the need to support a copy of the FindMPI.cmake module,
+ which has been removed, along with its subfolder in the config/cmake_ext_mod
+ location.
+
+ (ADB - 2018/03/09)
+
+ - CMake
+
Add pkg-config file generation
Added pkg-config file generation for the C, C++, HL, and HL C++ libraries.
diff --git a/release_docs/USING_HDF5_CMake.txt b/release_docs/USING_HDF5_CMake.txt
index 8dd47c2..b516056 100644
--- a/release_docs/USING_HDF5_CMake.txt
+++ b/release_docs/USING_HDF5_CMake.txt
@@ -180,7 +180,7 @@ Given the preconditions in section I, create a CMakeLists.txt file at the
source root. Include the following text in the file:
##########################################################
-cmake_minimum_required (VERSION 3.10.1)
+cmake_minimum_required (VERSION 3.10)
project (HDF5MyApp C CXX)
set (LIB_TYPE STATIC) # or SHARED
@@ -229,7 +229,7 @@ your application with an installed HDF5 binary.
ctest use of HDF5_Examples.cmake and HDF5_Examples_options.cmake
========================================================================
-cmake_minimum_required (VERSION 3.3.2 FATAL_ERROR)
+cmake_minimum_required (VERSION 3.10)
###############################################################################################################
# This script will build and run the examples from a folder
# Execute from a command line:
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d10870d..c506ebb 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_SRC C CXX)
#-----------------------------------------------------------------------------
diff --git a/src/H5F.c b/src/H5F.c
index 8e5f65a..2cd65cb 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -845,8 +845,6 @@ herr_t
H5Fget_filesize(hid_t file_id, hsize_t *size)
{
H5F_t *file; /* File object for file ID */
- haddr_t eof; /* End of file address */
- haddr_t eoa; /* End of allocation address */
haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */
haddr_t base_addr; /* Base address for the file */
herr_t ret_value = SUCCEED; /* Return value */
@@ -859,11 +857,9 @@ H5Fget_filesize(hid_t file_id, hsize_t *size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
/* Go get the actual file size */
- eof = H5FD_get_eof(file->shared->lf, H5FD_MEM_DEFAULT);
- eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT);
- max_eof_eoa = MAX(eof, eoa);
- if(HADDR_UNDEF == max_eof_eoa)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file get eof/eoa requests failed")
+ if(H5F__get_max_eof_eoa(file, &max_eof_eoa) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ")
+
base_addr = H5FD_get_base_addr(file->shared->lf);
if(size)
@@ -1949,3 +1945,87 @@ done:
FUNC_LEAVE_API(ret_value)
} /* H5Fget_mdc_image_info() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5Fget_eoa
+ *
+ * Purpose: Returns the address of the first byte after the last
+ * allocated memory in the file.
+ * (See H5FDget_eoa() in H5FD.c)
+ *
+ * Return: Success: First byte after allocated memory.
+ * Failure: HADDR_UNDEF
+ *
+ * Return: Non-negative on success/Negative on errors
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Fget_eoa(hid_t file_id, haddr_t *eoa)
+{
+ H5F_t *file; /* File object for file ID */
+ haddr_t rel_eoa; /* Relative address of EOA */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "i*a", file_id, eoa);
+
+ /* Check args */
+ if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID")
+
+ /* This public routine will work only for drivers with this feature enabled.*/
+ /* We might introduce a new feature flag in the future */
+ if(!H5F_HAS_FEATURE(file, H5FD_FEAT_SUPPORTS_SWMR_IO))
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine")
+
+ /* The real work */
+ if(HADDR_UNDEF == (rel_eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get_eoa request failed")
+
+ /* (Note compensating for base address subtraction in internal routine) */
+ if(eoa)
+ *eoa = rel_eoa + H5FD_get_base_addr(file->shared->lf);
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Fget_eoa() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Fincrement_filesize
+ *
+ * Purpose: Set the EOA for the file to the maximum of (EOA, EOF) + increment
+ *
+ * Return: Non-negative on success/Negative on errors
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Fincrement_filesize(hid_t file_id, hsize_t increment)
+{
+ H5F_t *file; /* File object for file ID */
+ haddr_t max_eof_eoa; /* Maximum of the relative EOA & EOF */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "ih", file_id, increment);
+
+ /* Check args */
+ if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID")
+
+ /* This public routine will work only for drivers with this feature enabled.*/
+ /* We might introduce a new feature flag in the future */
+ if(!H5F_HAS_FEATURE(file, H5FD_FEAT_SUPPORTS_SWMR_IO))
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine")
+
+ /* Get the maximum of EOA and EOF */
+ if(H5F__get_max_eof_eoa(file, &max_eof_eoa) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ")
+
+ /* Set EOA to the maximum value + increment */
+ /* H5FD_set_eoa() will add base_addr to max_eof_eoa */
+ if(H5FD_set_eoa(file->shared->lf, H5FD_MEM_DEFAULT, max_eof_eoa + increment) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Fincrement_filesize() */
diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c
index f594d8e..08b1a3f 100644
--- a/src/H5FDmpio.c
+++ b/src/H5FDmpio.c
@@ -67,6 +67,12 @@ typedef struct H5FD_mpio_t {
haddr_t eoa; /*end-of-address marker */
haddr_t last_eoa; /* Last known end-of-address marker */
haddr_t local_eof; /* Local end-of-file address for each process */
+ herr_t do_pre_trunc_barrier; /* hack to allow us to skip */
+ /* unnecessary barriers in */
+ /* H5FD_mpio_trucate() without a VFD */
+ /* API change. This should be removed */
+ /* as soon as be make the necessary */
+ /* VFD API change. */
} H5FD_mpio_t;
/* Private Prototypes */
@@ -1039,6 +1045,9 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
file->eof = H5FD_mpi_MPIOff_to_haddr(size);
file->local_eof = file->eof;
+ /* Mark initial barriers in H5FD_mpio_truncate() as necessary */
+ file->do_pre_trunc_barrier = TRUE;
+
/* Set return value */
ret_value=(H5FD_t*)file;
@@ -1932,16 +1941,75 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5FD_mark_pre_trunc_barrier_unecessary
+ *
+ * Purpose: Hack to allow us to avoid most unnecessary barriers
+ * prior in H5FD_mpio_truncate().
+ *
+ * This function should be deleted when next we modify the
+ * VFD interface. This change should allow us to tell the
+ * truncate function to omit the initial barrier if no
+ * file I/O has occurred since the last barrier.
+ *
+ * Return: void
+ *
+ *
+ * Programmer: John Mainzer
+ * 12/14/17
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+H5FD_mpio_mark_pre_trunc_barrier_unecessary(H5FD_t *_file)
+{
+ H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ HDassert(file);
+ HDassert(H5FD_MPIO == file->pub.driver_id);
+
+ file->do_pre_trunc_barrier = FALSE;
+
+ FUNC_LEAVE_NOAPI_VOID
+
+} /* end H5FD_mpio_mark_pre_trunc_barrier_unecessary() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5FD_mpio_truncate
*
* Purpose: Make certain the file's size matches it's allocated size
*
+ * This is a little sticky in the mpio case, as it is not
+ * easy for us to track the current EOF by extracting it from
+ * write calls.
+ *
+ * Instead, we first check to see if the eoa has changed since
+ * the last call to this function. If it has, we call
+ * MPI_File_get_size() to determine the current EOF, and
+ * only call MPI_File_set_size() if this value disagrees
+ * with the current eoa.
+ *
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* January 31, 2008
*
+ * Changes: Heavily reworked to avoid unnecessary MPI_File_set_size()
+ * calls. The hope is that these calls are superfluous in the
+ * typical case, allowing us to avoid truncates most of the
+ * time.
+ *
+ * The basic idea is to query the file system to get the
+ * current eof, and only truncate if the file systems
+ * conception of the eof disagrees with our eoa.
+ *
+ * JRM -- 10/27/17
+ *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -1959,35 +2027,77 @@ H5FD_mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_
HDassert(file);
HDassert(H5FD_MPIO == file->pub.driver_id);
- /* Extend the file to make sure it's large enough, then sync.
- * Unfortunately, keeping track of EOF is an expensive operation, so
- * we can't just check whether EOF<EOA like with other drivers.
- * Therefore we'll just read the byte at EOA-1 and then write it back. */
- if(file->eoa > file->last_eoa) {
- int mpi_code; /* mpi return code */
- MPI_Offset mpi_off;
-
- if(H5FD_mpi_haddr_to_MPIOff(file->eoa, &mpi_off) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset")
-
- /* Extend the file's size */
- if(MPI_SUCCESS != (mpi_code = MPI_File_set_size(file->f, mpi_off)))
- HMPI_GOTO_ERROR(FAIL, "MPI_File_set_size failed", mpi_code)
-
- /* Don't let any proc return until all have extended the file.
- * (Prevents race condition where some processes go ahead and write
- * more data to the file before all the processes have finished making
- * it the shorter length, potentially truncating the file and dropping
- * the new data written)
+ if ( !H5F_addr_eq(file->eoa, file->last_eoa) ) {
+
+ int mpi_code; /* mpi return code */
+ MPI_Offset size;
+ MPI_Offset needed_eof;
+
+ /* In principle, it is possible for the size returned by the
+ * call to MPI_File_get_size() to depend on whether writes from
+ * all proceeses have completed at the time process 0 makes the
+ * call.
+ *
+ * In practice, most (all?) truncate calls will come after a barrier
+ * and with no interviening writes to the file (with the possible
+ * exception of sueprblock / superblock extension message updates).
+ *
+ * Unfortunately, the current VFD API doesn't let us pass in a
+ * flag indicating whether this particular call is unnecessary.
+ * To work around this, I have added the new function
+ * H5FD_mpio_mark_pre_trunc_barrier_unecessary() allow us to
+ * set a flag in H5FD_mpio_t indicating that we can skip the
+ * barrier.
+ *
+ * This is a pretty ugly hack, but until we revise the VFD API,
+ * it is about the best we can do.
*/
- if(MPI_SUCCESS != (mpi_code = MPI_Barrier(file->comm)))
- HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code)
+ if (file->do_pre_trunc_barrier) {
+ if (MPI_SUCCESS!= (mpi_code=MPI_Barrier(file->comm)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed(1)", mpi_code)
+ }
+
+ /* Only processor p0 will get the filesize and broadcast it. */
+ if (file->mpi_rank == 0) {
+ if (MPI_SUCCESS != (mpi_code=MPI_File_get_size(file->f, &size)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_get_size failed", mpi_code)
+ } /* end if */
+
+ /* Broadcast file size */
+ if(MPI_SUCCESS != (mpi_code = MPI_Bcast(&size, (int)sizeof(MPI_Offset),
+ MPI_BYTE, 0, file->comm)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_code)
+
+ if(H5FD_mpi_haddr_to_MPIOff(file->eoa, &needed_eof) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, \
+ "cannot convert from haddr_t to MPI_Offset")
+
+ if (size != needed_eof) /* eoa != eof. Set eof to eoa */ {
+
+ /* Extend the file's size */
+ if(MPI_SUCCESS != (mpi_code=MPI_File_set_size(file->f, needed_eof)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_set_size failed", mpi_code)
+
+ /* In general, we must wait until all processes have finished
+ * the truncate before any process can continue, since it is
+ * possible that a process would write at the end of the
+ * file, and this write would be discarded by the truncate.
+ *
+ * While this is an issue for a user initiated flush, it may
+ * not be an issue at file close. If so, we may be able to
+ * optimize out the following barrier in that case.
+ */
+ if(MPI_SUCCESS != (mpi_code = MPI_Barrier(file->comm)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code)
+ }
/* Update the 'last' eoa value */
file->last_eoa = file->eoa;
} /* end if */
done:
+ file->do_pre_trunc_barrier = TRUE;
+
#ifdef H5FDmpio_DEBUG
if(H5FD_mpio_Debug[(int)'t'])
HDfprintf(stdout, "Leaving %s\n", FUNC);
diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h
index e758951..f7cd931 100644
--- a/src/H5FDprivate.h
+++ b/src/H5FDprivate.h
@@ -203,6 +203,7 @@ H5_DLL int H5FD_mpi_get_rank(const H5FD_t *file);
H5_DLL int H5FD_mpi_get_size(const H5FD_t *file);
H5_DLL MPI_Comm H5FD_mpi_get_comm(const H5FD_t *_file);
H5_DLL herr_t H5FD_get_mpi_info(H5FD_t *file, void** file_info);
+H5_DLL void H5FD_mpio_mark_pre_trunc_barrier_unecessary(H5FD_t *_file);
#endif /* H5_HAVE_PARALLEL */
#endif /* !_H5FDprivate_H */
diff --git a/src/H5Fint.c b/src/H5Fint.c
index c41453a..24844a4 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -124,7 +124,6 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref)
H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */
hbool_t driver_prop_copied = FALSE; /* Whether the driver property has been set up */
unsigned efc_size = 0;
- hbool_t latest_format = FALSE; /* Always use the latest format? */
hid_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -820,7 +819,6 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t
else {
H5P_genplist_t *plist; /* Property list */
unsigned efc_size; /* External file cache size */
- hbool_t latest_format; /* Always use the latest format? */
size_t u; /* Local index variable */
HDassert(lf != NULL);
@@ -1602,7 +1600,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
} /* end if */
else if (1 == shared->nrefs) {
/* Read the superblock if it hasn't been read before. */
- if(H5F__super_read(file, meta_dxpl_id, raw_dxpl_id, TRUE) < 0)
+ if(H5F__super_read(file, meta_dxpl_id, raw_dxpl_id, fapl_id, TRUE) < 0)
HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock")
/* Create the page buffer before initializing the superblock */
@@ -1788,6 +1786,15 @@ H5F__flush_phase2(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t closi
HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache")
/* Truncate the file to the current allocated size */
+#ifdef H5_HAVE_PARALLEL
+ if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) {
+ /* Since we just returned from a call to H5AC_flush(), we just
+ * passed through a barrier. Hence we can skip the barrier on
+ * entry to the mpio file driver call below.
+ */
+ H5FD_mpio_mark_pre_trunc_barrier_unecessary(f->shared->lf);
+ }
+#endif /* H5_HAVE_PARALLEL */
if(H5FD_truncate(f->shared->lf, meta_dxpl_id, closing) < 0)
/* Push error, but keep going*/
HDONE_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "low level truncate failed")
@@ -2912,6 +2919,43 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F__set_paged_aggr() */
+/*-------------------------------------------------------------------------
+ * Function: H5F__get_max_eof_eoa
+ *
+ * Purpose: Determine the maximum of (EOA, EOF) for the file
+ *
+ * Return: Non-negative on success/Negative on failure
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F__get_max_eof_eoa(const H5F_t *f, haddr_t *max_eof_eoa)
+{
+ haddr_t eof; /* Relative address for EOF */
+ haddr_t eoa; /* Relative address for EOA */
+ haddr_t tmp_max;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Sanity checks */
+ HDassert(f);
+ HDassert(f->shared);
+
+ /* Get the relative EOA and EOF */
+ eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT);
+ eof = H5FD_get_eof(f->shared->lf, H5FD_MEM_DEFAULT);
+
+ /* Determine the maximum */
+ tmp_max = MAX(eof, eoa);
+ if(HADDR_UNDEF == tmp_max)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file get eof/eoa requests failed")
+
+ *max_eof_eoa = tmp_max;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F__get_max_eof_eoa() */
+
#ifdef H5_HAVE_PARALLEL
/*-------------------------------------------------------------------------
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index c9aba56..a4c1a24 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -412,7 +412,7 @@ H5_DLL herr_t H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nop
/* Superblock related routines */
H5_DLL herr_t H5F__super_init(H5F_t *f, hid_t dxpl_id);
-H5_DLL herr_t H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id,
+H5_DLL herr_t H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hid_t fapl_id,
hbool_t initial_read);
H5_DLL herr_t H5F__super_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_size, hsize_t *super_ext_size);
H5_DLL herr_t H5F__super_free(H5F_super_t *sblock);
@@ -457,6 +457,7 @@ H5_DLL htri_t H5F_try_extend(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type,
H5_DLL herr_t H5F__set_eoa(const H5F_t *f, H5F_mem_t type, haddr_t addr);
H5_DLL herr_t H5F__set_base_addr(const H5F_t *f, haddr_t addr);
H5_DLL herr_t H5F__set_paged_aggr(const H5F_t *f, hbool_t paged);
+H5_DLL herr_t H5F__get_max_eof_eoa(const H5F_t *f, haddr_t *max_eof_eoa);
/* Functions that flush or evict */
H5_DLL herr_t H5F__evict_cache_entries(H5F_t *f, hid_t dxpl_id);
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index 856e618..28ebbd2 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -492,6 +492,10 @@ typedef struct H5F_t H5F_t;
#define H5F_ACS_EFC_SIZE_NAME "efc_size" /* Size of external file cache */
#define H5F_ACS_FILE_IMAGE_INFO_NAME "file_image_info" /* struct containing initial file image and callback info */
#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags" /* Whether to clear superblock status_flags (private property only used by h5clear) */
+#define H5F_ACS_NULL_FSM_ADDR_NAME "null_fsm_addr" /* Nullify addresses of free-space managers */
+ /* Private property used only by h5clear */
+#define H5F_ACS_SKIP_EOF_CHECK_NAME "skip_eof_check" /* Skip EOF check */
+ /* Private property used only by h5clear */
#define H5F_ACS_USE_MDC_LOGGING_NAME "use_mdc_logging" /* Whether to use metadata cache logging */
#define H5F_ACS_MDC_LOG_LOCATION_NAME "mdc_log_location" /* Name of metadata cache log location */
#define H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME "start_mdc_log_on_access" /* Whether logging starts on file create/open */
diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h
index d333fa7..73c59f5 100644
--- a/src/H5Fpublic.h
+++ b/src/H5Fpublic.h
@@ -241,6 +241,8 @@ H5_DLL herr_t H5Fmount(hid_t loc, const char *name, hid_t child, hid_t plist);
H5_DLL herr_t H5Funmount(hid_t loc, const char *name);
H5_DLL hssize_t H5Fget_freespace(hid_t file_id);
H5_DLL herr_t H5Fget_filesize(hid_t file_id, hsize_t *size);
+H5_DLL herr_t H5Fget_eoa(hid_t file_id, haddr_t *eoa);
+H5_DLL herr_t H5Fincrement_filesize(hid_t file_id, hsize_t increment);
H5_DLL ssize_t H5Fget_file_image(hid_t file_id, void * buf_ptr, size_t buf_len);
H5_DLL herr_t H5Fget_mdc_config(hid_t file_id,
H5AC_cache_config_t * config_ptr);
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index 4250ff0..3db9b2f 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -324,7 +324,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial_read)
+H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hid_t fapl_id, hbool_t initial_read)
{
H5P_genplist_t *dxpl = NULL; /* DXPL object */
H5AC_ring_t ring, orig_ring = H5AC_RING_INV;
@@ -337,7 +337,8 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial
haddr_t eof; /* End of file address */
unsigned rw_flags; /* Read/write permissions for file */
hbool_t skip_eof_check = FALSE; /* Whether to skip checking the EOF value */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5P_genplist_t *a_plist; /* File access property list */
+ herr_t ret_value = SUCCEED; /* Return value */
#ifdef H5_HAVE_PARALLEL
int mpi_rank = 0, mpi_size = 1;
int mpi_result;
@@ -595,6 +596,20 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial
* as the file can appear truncated if only part of it has been
* been flushed to disk by the SWMR writer process.
*/
+ /* The EOF check is also skipped when the private property
+ * H5F_ACS_SKIP_EOF_CHECK_NAME exists in the fapl.
+ * This property is enabled by the tool h5clear with these
+ * two options: (1) --filesize (2) --increment
+ */
+
+ /* Check if this private property exists in fapl */
+ if(NULL == (a_plist = (H5P_genplist_t *)H5I_object(fapl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list")
+ if(H5P_exist_plist(a_plist, H5F_ACS_SKIP_EOF_CHECK_NAME) > 0) {
+ if(H5P_get(a_plist, H5F_ACS_SKIP_EOF_CHECK_NAME, &skip_eof_check) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get clearance for persisting fsm addr")
+ }
+
if(H5F_INTENT(f) & H5F_ACC_SWMR_READ) {
/*
* When the file is opened for SWMR read access, skip the check if:
@@ -757,6 +772,7 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial
if(status) {
H5O_fsinfo_t fsinfo; /* File space info message from superblock extension */
uint8_t flags; /* Message flags */
+ hbool_t null_fsm_addr = FALSE; /* Whether to drop free-space to the floor */
/* Get message flags */
if(H5O_msg_get_flags(&ext_loc, H5O_FSINFO_ID, meta_dxpl_id, &flags) < 0)
@@ -765,6 +781,13 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial
/* If message is NOT marked "unknown"--set up file space info */
if(!(flags & H5O_MSG_FLAG_WAS_UNKNOWN)) {
+ /* The tool h5clear uses this property to tell the library
+ to drop free-space to the floor */
+ if(H5P_exist_plist(a_plist, H5F_ACS_NULL_FSM_ADDR_NAME) > 0) {
+ if(H5P_get(a_plist, H5F_ACS_NULL_FSM_ADDR_NAME, &null_fsm_addr) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get clearance for persisting fsm addr")
+ }
+
/* Retrieve the 'file space info' structure */
if(NULL == H5O_msg_read(&ext_loc, H5O_FSINFO_ID, &fsinfo, meta_dxpl_id))
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get free-space manager info message")
@@ -808,13 +831,30 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial
if(f->shared->eoa_pre_fsm_fsalloc != fsinfo.eoa_pre_fsm_fsalloc)
f->shared->eoa_pre_fsm_fsalloc = fsinfo.eoa_pre_fsm_fsalloc;
- /* f->shared->eoa_pre_fsm_fsalloc must always be HADDR_UNDEF
- * in the absence of persistant free space managers.
+ /* f->shared->eoa_pre_fsm_fsalloc must always be HADDR_UNDEF
+ * in the absence of persistant free space managers.
+ */
+ /* If the following two conditions are true:
+ * (1) skipping EOF check (skip_eof_check)
+ * (2) dropping free-space to the floor (null_fsm_addr)
+ * skip the asserts as "eoa_pre_fsm_fsalloc" may be undefined
+ * for a crashed file with persistant free space managers.
+ * #1 and #2 are enabled when the tool h5clear --increment
+ * option is used.
*/
- HDassert((!f->shared->fs_persist) || (f->shared->eoa_pre_fsm_fsalloc != HADDR_UNDEF));
- HDassert(!f->shared->first_alloc_dealloc);
+ if(!skip_eof_check && !null_fsm_addr) {
+ HDassert((!f->shared->fs_persist) || (f->shared->eoa_pre_fsm_fsalloc != HADDR_UNDEF));
+ HDassert(!f->shared->first_alloc_dealloc);
+ }
- if((f->shared->eoa_pre_fsm_fsalloc != HADDR_UNDEF) &&
+ /* As "eoa_pre_fsm_fsalloc" may be undefined for a crashed file
+ * with persistant free space managers, therefore, set
+ * "first_alloc_dealloc" when the condition
+ * "dropping free-space to the floor is true.
+ * This will ensure that no action is done to settle things on file
+ * close via H5MF_settle_meta_data_fsm() and H5MF_settle_raw_data_fsm().
+ */
+ if((f->shared->eoa_pre_fsm_fsalloc != HADDR_UNDEF || null_fsm_addr) &&
(H5F_INTENT(f) & H5F_ACC_RDWR))
f->shared->first_alloc_dealloc = TRUE;
@@ -822,7 +862,20 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial
for(u = 1; u < NELMTS(f->shared->fs_addr); u++)
f->shared->fs_addr[u] = fsinfo.fs_addr[u - 1];
- if(fsinfo.mapped && (rw_flags & H5AC__READ_ONLY_FLAG) == 0) {
+ /* If the following two conditions are true:
+ * (1) file is persisting free-space
+ * (2) dropping free-space to the floor (null_fsm_addr)
+ * nullify the addresses of the FSMs
+ */
+ if(f->shared->fs_persist && null_fsm_addr) {
+ for(u = 0; u < NELMTS(fsinfo.fs_addr); u++)
+ f->shared->fs_addr[u] = fsinfo.fs_addr[u] = HADDR_UNDEF;
+ }
+
+ /* For fsinfo.mapped: remove the FSINFO message from the superblock extension
+ and write a new message to the extension */
+ /* For null_fsm_addr: just update FSINFO message in the superblock extension */
+ if(((fsinfo.mapped || null_fsm_addr) && (rw_flags & H5AC__READ_ONLY_FLAG) == 0)) {
/* Do the same kluge until we know for sure. VC */
#if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */
@@ -836,11 +889,16 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial
f->shared->sblock = sblock;
#endif /* JRM */
- if(H5F_super_ext_remove_msg(f, meta_dxpl_id, H5O_FSINFO_ID) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTDELETE, FAIL, "error in removing message from superblock extension")
+ if(null_fsm_addr) {
+ if(H5F_super_ext_write_msg(f, meta_dxpl_id, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing fsinfo message to superblock extension")
+ } else {
+ if(H5F_super_ext_remove_msg(f, meta_dxpl_id, H5O_FSINFO_ID) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTDELETE, FAIL, "error in removing message from superblock extension")
- if(H5F_super_ext_write_msg(f, meta_dxpl_id, H5O_FSINFO_ID, &fsinfo, TRUE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing fsinfo message to superblock extension")
+ if(H5F_super_ext_write_msg(f, meta_dxpl_id, H5O_FSINFO_ID, &fsinfo, TRUE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing fsinfo message to superblock extension")
+ }
#if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */
f->shared->sblock = NULL;
#endif /* JRM */
@@ -1637,13 +1695,13 @@ H5F_super_ext_write_msg(H5F_t *f, hid_t dxpl_id, unsigned id, void *mesg,
/* Open/create the superblock extension object header */
if(H5F_addr_defined(f->shared->sblock->ext_addr)) {
- if(H5F_super_ext_open(f, f->shared->sblock->ext_addr, &ext_loc) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open file's superblock extension")
+ if(H5F_super_ext_open(f, f->shared->sblock->ext_addr, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open file's superblock extension")
} /* end if */
else {
HDassert(may_create);
- if(H5F_super_ext_create(f, dxpl_id, &ext_loc) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create file's superblock extension")
+ if(H5F_super_ext_create(f, dxpl_id, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create file's superblock extension")
ext_created = TRUE;
} /* end else */
HDassert(H5F_addr_defined(ext_loc.addr));
@@ -1651,24 +1709,24 @@ H5F_super_ext_write_msg(H5F_t *f, hid_t dxpl_id, unsigned id, void *mesg,
/* Check if message with ID does not exist in the object header */
if((status = H5O_msg_exists(&ext_loc, id, dxpl_id)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check object header for message or message exists")
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check object header for message or message exists")
/* Check for creating vs. writing */
if(may_create) {
- if(status)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should not exist")
+ if(status)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should not exist")
- /* Create the message with ID in the superblock extension */
- if(H5O_msg_create(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg, dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to create the message in object header")
+ /* Create the message with ID in the superblock extension */
+ if(H5O_msg_create(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to create the message in object header")
} /* end if */
else {
- if(!status)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should exist")
+ if(!status)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should exist")
- /* Update the message with ID in the superblock extension */
- if(H5O_msg_write(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg, dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to write the message in object header")
+ /* Update the message with ID in the superblock extension */
+ if(H5O_msg_write(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to write the message in object header")
} /* end else */
done:
diff --git a/src/H5Ocache.c b/src/H5Ocache.c
index 94049ef..2260e12 100644
--- a/src/H5Ocache.c
+++ b/src/H5Ocache.c
@@ -262,12 +262,23 @@ H5O__cache_verify_chksum(const void *_image, size_t len, void *_udata)
uint32_t stored_chksum; /* Stored metadata checksum value */
uint32_t computed_chksum; /* Computed metadata checksum value */
- /* Get stored and computed checksums */
- H5F_get_checksums(image, len, &stored_chksum, &computed_chksum);
-
- if(stored_chksum != computed_chksum)
- ret_value = FALSE;
+ /* Get stored and computed checksums */
+ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum);
+
+ if(stored_chksum != computed_chksum) {
+ /* These fields are not deserialized yet in H5O__prefix_deserialize() */
+ HDassert(udata->oh->chunk == NULL);
+ HDassert(udata->oh->mesg == NULL);
+ HDassert(udata->oh->proxy == NULL);
+
+ /* Indicate that udata->oh is to be freed later
+ in H5O__prefix_deserialize() */
+ udata->free_oh = TRUE;
+ ret_value = FALSE;
+ } /* end if */
} /* end if */
+ else
+ HDassert(!(udata->common.file_intent & H5F_ACC_SWMR_WRITE));
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__cache_verify_chksum() */
@@ -1263,8 +1274,22 @@ H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata)
/* Verify object header prefix length */
HDassert((size_t)(image - _image) == (size_t)(H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh)));
- /* Save the object header for later use in 'deserialize' callback */
- udata->oh = oh;
+ /* If udata->oh is to be freed (see H5O__cache_verify_chksum),
+ save the pointer to udata->oh and free it later after setting
+ udata->oh with the new object header */
+ if(udata->free_oh) {
+ H5O_t *saved_oh = udata->oh;
+ HDassert(udata->oh);
+
+ /* Save the object header for later use in 'deserialize' callback */
+ udata->oh = oh;
+ if(H5O__free(saved_oh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't destroy object header")
+ udata->free_oh = FALSE;
+ } else
+ /* Save the object header for later use in 'deserialize' callback */
+ udata->oh = oh;
+
oh = NULL;
done:
diff --git a/src/H5Oint.c b/src/H5Oint.c
index 08eb28d..2351779 100644
--- a/src/H5Oint.c
+++ b/src/H5Oint.c
@@ -875,6 +875,7 @@ H5O_protect(const H5O_loc_t *loc, hid_t dxpl_id, unsigned prot_flags,
udata.v1_pfx_nmesgs = 0;
udata.chunk0_size = 0;
udata.oh = NULL;
+ udata.free_oh = FALSE;
udata.common.f = loc->file;
udata.common.dxpl_id = dxpl_id;
udata.common.file_intent = file_intent;
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index e970406..9392fa8 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -379,6 +379,7 @@ typedef struct H5O_cache_ud_t {
unsigned v1_pfx_nmesgs; /* Number of messages from v1 prefix header */
size_t chunk0_size; /* Size of serialized first chunk */
H5O_t *oh; /* Partially deserialized object header, for later use */
+ hbool_t free_oh; /* Whether to free the object header or not */
H5O_common_cache_ud_t common; /* Common object header cache callback info */
} H5O_cache_ud_t;
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index 148c247..eded286 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -193,6 +193,14 @@
/* Definition for status_flags in the superblock */
#define H5F_ACS_CLEAR_STATUS_FLAGS_SIZE sizeof(hbool_t)
#define H5F_ACS_CLEAR_STATUS_FLAGS_DEF FALSE
+
+/* Definition for dropping free-space to the floor when reading in the superblock */
+#define H5F_ACS_NULL_FSM_ADDR_SIZE sizeof(hbool_t)
+#define H5F_ACS_NULL_FSM_ADDR_DEF FALSE
+/* Definition for skipping EOF check when reading in the superblock */
+#define H5F_ACS_SKIP_EOF_CHECK_SIZE sizeof(hbool_t)
+#define H5F_ACS_SKIP_EOF_CHECK_DEF FALSE
+
/* Definition for 'use metadata cache logging' flag */
#define H5F_ACS_USE_MDC_LOGGING_SIZE sizeof(hbool_t)
#define H5F_ACS_USE_MDC_LOGGING_DEF FALSE
@@ -374,6 +382,9 @@ static const size_t H5F_def_core_write_tracking_page_size_g = H5F_ACS_CORE_WRITE
static const unsigned H5F_def_metadata_read_attempts_g = H5F_ACS_METADATA_READ_ATTEMPTS_DEF; /* Default setting for the # of metadata read attempts */
static const H5F_object_flush_t H5F_def_object_flush_cb_g = H5F_ACS_OBJECT_FLUSH_CB_DEF; /* Default setting for object flush callback */
static const hbool_t H5F_def_clear_status_flags_g = H5F_ACS_CLEAR_STATUS_FLAGS_DEF; /* Default to clear the superblock status_flags */
+static const hbool_t H5F_def_skip_eof_check_g = H5F_ACS_SKIP_EOF_CHECK_DEF; /* Default setting for skipping EOF check */
+static const hbool_t H5F_def_null_fsm_addr_g = H5F_ACS_NULL_FSM_ADDR_DEF; /* Default setting for dropping free-space to the floor */
+
static const hbool_t H5F_def_use_mdc_logging_g = H5F_ACS_USE_MDC_LOGGING_DEF; /* Default metadata cache logging flag */
static const char *H5F_def_mdc_log_location_g = H5F_ACS_MDC_LOG_LOCATION_DEF; /* Default mdc log location */
static const hbool_t H5F_def_start_mdc_log_on_access_g = H5F_ACS_START_MDC_LOG_ON_ACCESS_DEF; /* Default mdc log start on access flag */
@@ -565,6 +576,16 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass)
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+ /* Register the private property of whether to skip EOF check. It's used by h5clear only. */
+ if(H5P_register_real(pclass, H5F_ACS_SKIP_EOF_CHECK_NAME, H5F_ACS_SKIP_EOF_CHECK_SIZE, &H5F_def_skip_eof_check_g,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
+ /* Register the private property of whether to drop free-space to the floor. It's used by h5clear only. */
+ if(H5P_register_real(pclass, H5F_ACS_NULL_FSM_ADDR_NAME, H5F_ACS_NULL_FSM_ADDR_SIZE, &H5F_def_null_fsm_addr_g,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
/* Register the metadata cache logging flag. */
if(H5P_register_real(pclass, H5F_ACS_USE_MDC_LOGGING_NAME, H5F_ACS_USE_MDC_LOGGING_SIZE, &H5F_def_use_mdc_logging_g,
NULL, NULL, NULL, H5F_ACS_USE_MDC_LOGGING_ENC, H5F_ACS_USE_MDC_LOGGING_DEC, NULL, NULL, NULL, NULL) < 0)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index fd88b5f..b3b6f5c 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TEST)
#-----------------------------------------------------------------------------
diff --git a/test/gen_bounds.c b/test/gen_bounds.c
index 9702176..7b670f7 100644
--- a/test/gen_bounds.c
+++ b/test/gen_bounds.c
@@ -267,11 +267,13 @@ error:
/***********************************************************************
* gen_latest_latest() creates file "bounds_latest_latest.h5"
*
- * File contents:
- * - Version 3 superblock (triggered by H5Fcreate with H5F_ACC_SWMR_WRITE)
- * - A chunked dataset with layout version 4, "DS_chunked_layout_4". (H5Pset_chunk_opts)
+ * NOTE: As of March 2018, latest is 1.10.
*
- * NOTE: As of Feb 2018, latest is 1.10.
+ * File contents:
+ * - Version 3 superblock (NOTE: this can also be triggered by passing in
+ * H5F_ACC_SWMR_WRITE, in place of H5F_ACC_TRUNC, to H5Fcreate)
+ * - A chunked dataset with layout version 4, "DS_chunked_layout_4".
+ * (triggered by H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS)
*
* Return: SUCCEED/FAIL
*
@@ -279,6 +281,7 @@ error:
static herr_t gen_latest_latest(void)
{
hid_t fid = -1; /* File ID */
+ hid_t fapl = -1; /* File access property list ID */
hid_t dcpl = -1; /* Dataset creation property list ID */
hid_t space = -1; /* Dataspace ID */
hid_t dset = -1; /* Dataset ID */
@@ -289,8 +292,16 @@ static herr_t gen_latest_latest(void)
int i, j;
herr_t ret = SUCCEED; /* Generic return value */
- /* Create file with H5F_ACC_SWMR_WRITE, triggers version 3 superblock */
- fid = H5Fcreate(FILENAME_L_L, H5F_ACC_SWMR_WRITE, H5P_DEFAULT, H5P_DEFAULT);
+ /* Create file access property list */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR;
+
+ /* Set the "use the latest/latest version of the format" bounds
+ for creating objects in the file */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ TEST_ERROR;
+
+ /* Create the file with version 3 superblock */
+ fid = H5Fcreate(FILENAME_L_L, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
if (fid < 0) TEST_ERROR;
/*
@@ -351,6 +362,8 @@ error:
/***********************************************************************
* gen_v18_latest() creates file "bounds_v18_latest.h5"
*
+ * NOTE: As of March 2018, latest is 1.10.
+ *
* File contents:
* - Version 2 superblock
* - A chunked dataset with layout version 3, "DS_chunked_layout_3". (default)
diff --git a/test/tfile.c b/test/tfile.c
index f3d5a8f..80c1e11 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -134,6 +134,9 @@
#define NGROUPS 2
#define NDSETS 4
+/* Declaration for test_incr_filesize() */
+#define FILE8 "tfile8.h5" /* Test file */
+
/* Files created under 1.6 branch and 1.8 branch--used in test_filespace_compatible() */
const char *OLD_FILENAME[] = {
"filespace_1_6.h5", /* 1.6 HDF5 file */
@@ -6926,6 +6929,130 @@ test_libver_macros2(void)
/****************************************************************
**
+** test_filesize():
+** Verify H5Fincrement_filesize() and H5Fget_eoa() works as
+** indicated in the "RFC: Enhancement to the tool h5clear".
+**
+****************************************************************/
+static void
+test_incr_filesize(const char *env_h5_drvr)
+{
+ hid_t fid; /* File opened with read-write permission */
+ h5_stat_size_t filesize; /* Size of file when empty */
+ hid_t fcpl; /* File creation property list */
+ hid_t fapl; /* File access property list */
+ hid_t dspace; /* Dataspace ID */
+ hid_t dset; /* Dataset ID */
+ hid_t dcpl; /* Dataset creation property list */
+ unsigned u; /* Local index variable */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ char name[32]; /* Dataset name */
+ haddr_t stored_eoa; /* The stored EOA value */
+ hid_t driver_id = -1; /* ID for this VFD */
+ unsigned long driver_flags = 0; /* VFD feature flags */
+ herr_t ret; /* Return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing H5Fincrement_filesize() and H5Fget_eoa())\n"));
+
+ fapl = h5_fileaccess();
+ h5_fixname(FILE8, fapl, filename, sizeof filename);
+
+ /* Get the VFD feature flags */
+ driver_id = H5Pget_driver(fapl);
+ CHECK(driver_id, FAIL, "H5Pget_driver");
+
+ ret = H5FDdriver_query(driver_id, &driver_flags);
+ CHECK(ret, FAIL, "H5PDdriver_query");
+
+ /* Check whether the VFD feature flag supports these two public routines */
+ if(driver_flags & H5FD_FEAT_SUPPORTS_SWMR_IO) {
+
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ CHECK(fcpl, FAIL, "H5Pcreate");
+
+ /* Set file space strategy */
+ ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, FALSE, (hsize_t)1);
+ CHECK(ret, FAIL, "H5P_set_file_space_strategy");
+
+ /* Create the test file */
+ fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Create dataspace for datasets */
+ dspace = H5Screate(H5S_SCALAR);
+ CHECK(dspace, FAIL, "H5Screate");
+
+ /* Create a dataset creation property list */
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+
+ /* Set the space allocation time to early */
+ ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY);
+ CHECK(ret, FAIL, "H5Pset_alloc_time");
+
+ /* Create datasets in file */
+ for(u = 0; u < 10; u++) {
+ sprintf(name, "Dataset %u", u);
+ dset = H5Dcreate2(fid, name, H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ CHECK(dset, FAIL, "H5Dcreate2");
+
+ ret = H5Dclose(dset);
+ CHECK(ret, FAIL, "H5Dclose");
+ } /* end for */
+
+ /* Close dataspace */
+ ret = H5Sclose(dspace);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close dataset creation property list */
+ ret = H5Pclose(dcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Get the file size */
+ filesize = h5_get_file_size(filename, fapl);
+
+ /* Open the file */
+ fid = H5Fopen(filename, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Get the stored EOA */
+ ret = H5Fget_eoa(fid, &stored_eoa);
+ CHECK(ret, FAIL, "H5Fget_eoa");
+
+ /* Verify the stored EOA is the same as filesize */
+ VERIFY(filesize, stored_eoa, "file size");
+
+ /* Set the EOA to the MAX(EOA, EOF) + 512 */
+ ret = H5Fincrement_filesize(fid, 512);
+ CHECK(ret, FAIL, "H5Fincrement_filesize");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Get the file size */
+ filesize = h5_get_file_size(filename, fapl);
+
+ /* Verify the filesize is the previous stored_eoa + 512 */
+ VERIFY(filesize, stored_eoa+512, "file size");
+
+ /* Close the file access property list */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Close the file creation property list */
+ ret = H5Pclose(fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ }
+} /* end test_incr_filesize() */
+
+/****************************************************************
+**
** test_deprec():
** Test deprecated functionality.
**
@@ -7210,6 +7337,7 @@ test_file(void)
test_libver_bounds_low_high();
test_libver_macros(); /* Test the macros for library version comparison */
test_libver_macros2(); /* Test the macros for library version comparison */
+ test_incr_filesize(env_h5_drvr); /* Test H5Fincrement_filesize() and H5Fget_eoa() */
#ifndef H5_NO_DEPRECATED_SYMBOLS
test_deprec(); /* Test deprecated routines */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
diff --git a/testpar/CMakeLists.txt b/testpar/CMakeLists.txt
index 3cee808..b1b9ce1 100644
--- a/testpar/CMakeLists.txt
+++ b/testpar/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TEST_PAR)
#-----------------------------------------------------------------------------
diff --git a/testpar/t_bigio.c b/testpar/t_bigio.c
index 611ff1a..fdd3488 100644
--- a/testpar/t_bigio.c
+++ b/testpar/t_bigio.c
@@ -3,7 +3,10 @@
#include "testphdf5.h"
#include "H5Dprivate.h" /* For Chunk tests */
-// int TestVerbosity = VERBO_LO; /* Default Verbosity is Low */
+/* FILENAME and filenames must have the same number of names */
+const char *FILENAME[2]={ "bigio_test.h5",
+ NULL
+ };
/* Constants definitions */
#define MAX_ERR_REPORT 10 /* Maximum number of errors reported */
@@ -38,7 +41,6 @@ typedef hsize_t B_DATATYPE;
int facc_type = FACC_MPIO; /*Test file access type */
int dxfer_coll_type = DXFER_COLLECTIVE_IO;
size_t bigcount = DXFER_BIGCOUNT;
-char filename[20] = "bigio_test.h5";
int nerrors = 0;
int mpi_size, mpi_rank;
@@ -506,7 +508,7 @@ dataset_big_write(void)
H5Pset_fapl_mpio(acc_tpl, MPI_COMM_WORLD, MPI_INFO_NULL);
/* create the file collectively */
- fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl);
+ fid = H5Fcreate(FILENAME[0], H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl);
VRFY((fid >= 0), "H5Fcreate succeeded");
/* Release file-access template */
@@ -515,7 +517,8 @@ dataset_big_write(void)
/* Each process takes a slabs of rows. */
- printf("\nTesting Dataset1 write by ROW\n");
+ if (mpi_rank == 0)
+ HDprintf("\nTesting Dataset1 write by ROW\n");
/* Create a large dataset */
dims[0] = bigcount;
dims[1] = mpi_size;
@@ -563,21 +566,6 @@ dataset_big_write(void)
VRFY((ret>= 0),"set independent IO collectively succeeded");
}
- /* write data collectively */
- MESG("writeAll by Row");
- {
- int j,k =0;
- for (i=0; i < block[0]; i++){
- for (j=0; j < block[1]; j++){
- if(k < 10) {
- printf("%lld ", wdata[k]);
- k++;
- }
- }
- }
- printf("\n");
- }
-
ret = H5Dwrite(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace,
xfer_plist, wdata);
VRFY((ret >= 0), "H5Dwrite dataset1 succeeded");
@@ -591,9 +579,9 @@ dataset_big_write(void)
VRFY((ret >= 0), "H5Dclose1 succeeded");
-
/* Each process takes a slabs of cols. */
- printf("\nTesting Dataset2 write by COL\n");
+ if (mpi_rank == 0)
+ HDprintf("\nTesting Dataset2 write by COL\n");
/* Create a large dataset */
dims[0] = bigcount;
dims[1] = mpi_size;
@@ -641,21 +629,6 @@ dataset_big_write(void)
VRFY((ret>= 0),"set independent IO collectively succeeded");
}
- /* write data collectively */
- MESG("writeAll by Col");
- {
- int j,k =0;
- for (i=0; i < block[0]; i++){
- for (j=0; j < block[1]; j++){
- if(k < 10) {
- printf("%lld ", wdata[k]);
- k++;
- }
- }
- }
- printf("\n");
- }
-
ret = H5Dwrite(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace,
xfer_plist, wdata);
VRFY((ret >= 0), "H5Dwrite dataset1 succeeded");
@@ -671,7 +644,8 @@ dataset_big_write(void)
/* ALL selection */
- printf("\nTesting Dataset3 write select ALL proc 0, NONE others\n");
+ if (mpi_rank == 0)
+ HDprintf("\nTesting Dataset3 write select ALL proc 0, NONE others\n");
/* Create a large dataset */
dims[0] = bigcount;
dims[1] = 1;
@@ -685,7 +659,7 @@ dataset_big_write(void)
/* create a file dataspace independently */
file_dataspace = H5Dget_space (dataset);
VRFY((file_dataspace >= 0), "H5Dget_space succeeded");
- if(MAINPROCESS) {
+ if(mpi_rank == 0) {
ret = H5Sselect_all(file_dataspace);
VRFY((ret >= 0), "H5Sset_all succeeded");
}
@@ -697,7 +671,7 @@ dataset_big_write(void)
/* create a memory dataspace independently */
mem_dataspace = H5Screate_simple (RANK, dims, NULL);
VRFY((mem_dataspace >= 0), "");
- if(!MAINPROCESS) {
+ if(!mpi_rank == 0) {
ret = H5Sselect_none(mem_dataspace);
VRFY((ret >= 0), "H5Sset_none succeeded");
}
@@ -719,21 +693,6 @@ dataset_big_write(void)
MESG("data_array created");
}
- /* write data collectively */
- MESG("writeAll by process 0");
- {
- int j,k =0;
- for (i=0; i < block[0]; i++){
- for (j=0; j < block[1]; j++){
- if(k < 10) {
- printf("%lld ", wdata[k]);
- k++;
- }
- }
- }
- printf("\n");
- }
-
ret = H5Dwrite(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace,
xfer_plist, wdata);
VRFY((ret >= 0), "H5Dwrite dataset1 succeeded");
@@ -747,7 +706,8 @@ dataset_big_write(void)
VRFY((ret >= 0), "H5Dclose1 succeeded");
/* Point selection */
- printf("\nTesting Dataset4 write point selection\n");
+ if (mpi_rank == 0)
+ HDprintf("\nTesting Dataset4 write point selection\n");
/* Create a large dataset */
dims[0] = bigcount;
dims[1] = mpi_size * 4;
@@ -818,101 +778,7 @@ dataset_big_write(void)
ret = H5Dclose(dataset);
VRFY((ret >= 0), "H5Dclose1 succeeded");
- /* Irregular selection */
- /* Need larger memory for data buffer */
- free(wdata);
-#if 0
- wdata = (B_DATATYPE *)malloc(bigcount*4*sizeof(B_DATATYPE));
- VRFY((wdata != NULL), "wdata malloc succeeded");
-
- printf("\nTesting Dataset5 write irregular selection\n");
- /* Create a large dataset */
- dims[0] = bigcount/6;
- dims[1] = mpi_size * 4;
-
- sid = H5Screate_simple (RANK, dims, NULL);
- VRFY((sid >= 0), "H5Screate_simple succeeded");
- dataset = H5Dcreate2(fid, DATASET5, H5T_NATIVE_LLONG, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- VRFY((dataset >= 0), "H5Dcreate2 succeeded");
- H5Sclose(sid);
-
- /* first select 1 col in this procs splice */
- block[0] = dims[0];
- block[1] = 1;
- stride[0] = block[0];
- stride[1] = block[1];
- count[0] = 1;
- count[1] = 1;
- start[0] = 0;
- start[1] = mpi_rank * 4;
-
- /* create a file dataspace */
- file_dataspace = H5Dget_space (dataset);
- VRFY((file_dataspace >= 0), "H5Dget_space succeeded");
-
- // dims[1] = 4;
- /* create a memory dataspace */
- mem_dataspace = H5Screate_simple (RANK, dims, NULL);
- VRFY((mem_dataspace >= 0), "");
-
- ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block);
- VRFY((ret >= 0), "H5Sset_hyperslab succeeded");
-
- start[1] = 0;
- ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block);
- VRFY((ret >= 0), "H5Sset_hyperslab succeeded");
-
- /* select every other row in the process splice and OR it with
- the col selection to create an irregular selection */
- for(h=0 ; h<dims[0] ; h+=2) {
- block[0] = 1;
- block[1] = 4;
- stride[0] = block[0];
- stride[1] = block[1];
- count[0] = 1;
- count[1] = 1;
- start[0] = h;
- start[1] = mpi_rank * 4;
-
- ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_OR, start, stride, count, block);
- VRFY((ret >= 0), "H5Sset_hyperslab succeeded");
-
- start[1] = 0;
- ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_OR, start, stride, count, block);
- VRFY((ret >= 0), "H5Sset_hyperslab succeeded");
- }
- printf("Setting up for collective transfer\n");
- /* set up the collective transfer properties list */
- xfer_plist = H5Pcreate (H5P_DATASET_XFER);
- VRFY((xfer_plist >= 0), "H5Pcreate xfer succeeded");
- ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
- VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded");
- if(dxfer_coll_type == DXFER_INDEPENDENT_IO) {
- ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO);
- VRFY((ret>= 0),"set independent IO collectively succeeded");
- }
-
- /* fill the local slab with some trivial data */
- fill_datasets(start, dims, wdata);
- MESG("data_array initialized");
- if(VERBOSE_MED){
- MESG("data_array created");
- }
-
- ret = H5Dwrite(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace,
- xfer_plist, wdata);
- VRFY((ret >= 0), "H5Dwrite dataset1 succeeded");
-
- /* release all temporary handles. */
- H5Sclose(file_dataspace);
- H5Sclose(mem_dataspace);
- H5Pclose(xfer_plist);
-
- ret = H5Dclose(dataset);
- VRFY((ret >= 0), "H5Dclose1 succeeded");
-
free(wdata);
-#endif
H5Fclose(fid);
}
@@ -960,15 +826,16 @@ dataset_big_read(void)
H5Pset_fapl_mpio(acc_tpl, MPI_COMM_WORLD, MPI_INFO_NULL);
/* open the file collectively */
- fid=H5Fopen(filename,H5F_ACC_RDONLY,acc_tpl);
+ fid=H5Fopen(FILENAME[0],H5F_ACC_RDONLY,acc_tpl);
VRFY((fid >= 0), "H5Fopen succeeded");
/* Release file-access template */
ret = H5Pclose(acc_tpl);
VRFY((ret >= 0), "");
+ if (mpi_rank == 0)
+ HDprintf("\nRead Testing Dataset1 by COL\n");
- printf("\nRead Testing Dataset1 by COL\n");
dataset = H5Dopen2(fid, DATASET1, H5P_DEFAULT);
VRFY((dataset >= 0), "H5Dopen2 succeeded");
@@ -1016,18 +883,6 @@ dataset_big_read(void)
xfer_plist, rdata);
VRFY((ret >= 0), "H5Dread dataset1 succeeded");
- {
- for (i=0; i < block[0]; i++){
- for (j=0; j < block[1]; j++){
- if(k < 10) {
- printf("%lld ", rdata[k]);
- k++;
- }
- }
- }
- printf("\n");
- }
-
/* verify the read data with original expected data */
ret = verify_data(start, count, stride, block, rdata, wdata);
if(ret) {fprintf(stderr, "verify failed\n"); exit(1);}
@@ -1040,7 +895,8 @@ dataset_big_read(void)
VRFY((ret >= 0), "H5Dclose1 succeeded");
- printf("\nRead Testing Dataset2 by ROW\n");
+ if (mpi_rank == 0)
+ HDprintf("\nRead Testing Dataset2 by ROW\n");
memset(rdata, 0, bigcount*sizeof(B_DATATYPE));
dataset = H5Dopen2(fid, DATASET2, H5P_DEFAULT);
VRFY((dataset >= 0), "H5Dopen2 succeeded");
@@ -1089,18 +945,6 @@ dataset_big_read(void)
xfer_plist, rdata);
VRFY((ret >= 0), "H5Dread dataset2 succeeded");
- {
- for (i=0; i < block[0]; i++){
- for (j=0; j < block[1]; j++){
- if(k < 10) {
- printf("%lld ", rdata[k]);
- k++;
- }
- }
- }
- printf("\n");
- }
-
/* verify the read data with original expected data */
ret = verify_data(start, count, stride, block, rdata, wdata);
if(ret) {fprintf(stderr, "verify failed\n"); exit(1);}
@@ -1112,8 +956,8 @@ dataset_big_read(void)
ret = H5Dclose(dataset);
VRFY((ret >= 0), "H5Dclose1 succeeded");
-
- printf("\nRead Testing Dataset3 read select ALL proc 0, NONE others\n");
+ if (mpi_rank == 0)
+ HDprintf("\nRead Testing Dataset3 read select ALL proc 0, NONE others\n");
memset(rdata, 0, bigcount*sizeof(B_DATATYPE));
dataset = H5Dopen2(fid, DATASET3, H5P_DEFAULT);
VRFY((dataset >= 0), "H5Dopen2 succeeded");
@@ -1124,7 +968,7 @@ dataset_big_read(void)
/* create a file dataspace independently */
file_dataspace = H5Dget_space (dataset);
VRFY((file_dataspace >= 0), "H5Dget_space succeeded");
- if(MAINPROCESS) {
+ if(mpi_rank == 0) {
ret = H5Sselect_all(file_dataspace);
VRFY((ret >= 0), "H5Sset_all succeeded");
}
@@ -1136,7 +980,7 @@ dataset_big_read(void)
/* create a memory dataspace independently */
mem_dataspace = H5Screate_simple (RANK, dims, NULL);
VRFY((mem_dataspace >= 0), "");
- if(!MAINPROCESS) {
+ if(!mpi_rank == 0) {
ret = H5Sselect_none(mem_dataspace);
VRFY((ret >= 0), "H5Sset_none succeeded");
}
@@ -1163,19 +1007,7 @@ dataset_big_read(void)
xfer_plist, rdata);
VRFY((ret >= 0), "H5Dread dataset3 succeeded");
- {
- for (i=0; i < block[0]; i++){
- for (j=0; j < block[1]; j++){
- if(k < 10) {
- printf("%lld ", rdata[k]);
- k++;
- }
- }
- }
- printf("\n");
- }
-
- if(MAINPROCESS) {
+ if(mpi_rank == 0) {
/* verify the read data with original expected data */
ret = verify_data(start, count, stride, block, rdata, wdata);
if(ret) {fprintf(stderr, "verify failed\n"); exit(1);}
@@ -1188,7 +1020,8 @@ dataset_big_read(void)
ret = H5Dclose(dataset);
VRFY((ret >= 0), "H5Dclose1 succeeded");
- printf("\nRead Testing Dataset4 with Point selection\n");
+ if (mpi_rank == 0)
+ HDprintf("\nRead Testing Dataset4 with Point selection\n");
dataset = H5Dopen2(fid, DATASET4, H5P_DEFAULT);
VRFY((dataset >= 0), "H5Dopen2 succeeded");
@@ -1258,131 +1091,33 @@ dataset_big_read(void)
ret = H5Dclose(dataset);
VRFY((ret >= 0), "H5Dclose1 succeeded");
- printf("\nRead Testing Dataset5 with Irregular selection\n");
- /* Need larger memory for data buffer */
free(wdata);
free(rdata);
-#if 0
- wdata = (B_DATATYPE *)malloc(bigcount*4*sizeof(B_DATATYPE));
- VRFY((wdata != NULL), "wdata malloc succeeded");
- rdata = (B_DATATYPE *)malloc(bigcount*4*sizeof(B_DATATYPE));
- VRFY((rdata != NULL), "rdata malloc succeeded");
-
- dataset = H5Dopen2(fid, DATASET5, H5P_DEFAULT);
- VRFY((dataset >= 0), "H5Dopen2 succeeded");
-
- dims[0] = bigcount;
- dims[1] = mpi_size * 4;
-
- /* first select 1 col in this proc splice */
- block[0] = dims[0];
- block[1] = 1;
- stride[0] = block[0];
- stride[1] = block[1];
- count[0] = 1;
- count[1] = 1;
- start[0] = 0;
- start[1] = mpi_rank * 4;
-
- /* get file dataspace */
- file_dataspace = H5Dget_space (dataset);
- VRFY((file_dataspace >= 0), "H5Dget_space succeeded");
-
- /* create a memory dataspace */
- mem_dataspace = H5Screate_simple (RANK, dims, NULL);
- VRFY((mem_dataspace >= 0), "");
-
- ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block);
- VRFY((ret >= 0), "H5Sset_hyperslab succeeded");
-
- start[1] = 0;
- ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block);
- VRFY((ret >= 0), "H5Sset_hyperslab succeeded");
-
- /* select every other row in the process splice and OR it with
- the col selection to create an irregular selection */
- for(h=0 ; h<dims[0] ; h+=2) {
- block[0] = 1;
- block[1] = 4;
- stride[0] = block[0];
- stride[1] = block[1];
- count[0] = 1;
- count[1] = 1;
- start[0] = h;
- start[1] = mpi_rank * 4;
-
- ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_OR, start, stride, count, block);
- VRFY((ret >= 0), "H5Sset_hyperslab succeeded");
-
- start[1] = 0;
- ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_OR, start, stride, count, block);
- VRFY((ret >= 0), "H5Sset_hyperslab succeeded");
-
- //fprintf(stderr, "%d: %d - %d\n", mpi_rank, (int)h, (int)H5Sget_select_npoints(mem_dataspace));
- }
-
- /* set up the collective transfer properties list */
- xfer_plist = H5Pcreate (H5P_DATASET_XFER);
- VRFY((xfer_plist >= 0), "");
- ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
- VRFY((ret >= 0), "H5Pcreate xfer succeeded");
- if(dxfer_coll_type == DXFER_INDEPENDENT_IO) {
- ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO);
- VRFY((ret>= 0),"set independent IO collectively succeeded");
- }
-
- /* read data collectively */
- ret = H5Dread(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace,
- xfer_plist, rdata);
- VRFY((ret >= 0), "H5Dread dataset1 succeeded");
-
- /* fill dataset with test data */
- fill_datasets(start, dims, wdata);
- MESG("data_array initialized");
- if(VERBOSE_MED){
- MESG("data_array created");
- }
-
-
- /* verify the read data with original expected data */
- block[0] = dims[0];
- block[1] = 1;
- stride[0] = block[0];
- stride[1] = block[1];
- count[0] = 1;
- count[1] = 1;
- start[0] = 0;
- start[1] = 0;
- ret = verify_data(start, count, stride, block, rdata, wdata);
- if(ret) {fprintf(stderr, "verify failed\n"); exit(1);}
-
- for(h=0 ; h<dims[0] ; h+=2) {
- block[0] = 1;
- block[1] = 4;
- stride[0] = block[0];
- stride[1] = block[1];
- count[0] = 1;
- count[1] = 1;
- start[0] = h;
- start[1] = 0;
- ret = verify_data(start, count, stride, block, rdata, wdata);
- if(ret) {fprintf(stderr, "verify failed\n"); exit(1);}
- }
+ wdata = NULL;
+ rdata = NULL;
+ /* We never wrote Dataset5 in the write section, so we can't
+ * expect to read it...
+ */
+ file_dataspace = -1;
+ mem_dataspace = -1;
+ xfer_plist = -1;
+ dataset = -1;
/* release all temporary handles. */
- H5Sclose(file_dataspace);
- H5Sclose(mem_dataspace);
- H5Pclose(xfer_plist);
- ret = H5Dclose(dataset);
- VRFY((ret >= 0), "H5Dclose1 succeeded");
-
+ if (file_dataspace != -1) H5Sclose(file_dataspace);
+ if (mem_dataspace != -1) H5Sclose(mem_dataspace);
+ if (xfer_plist != -1) H5Pclose(xfer_plist);
+ if (dataset != -1) {
+ ret = H5Dclose(dataset);
+ VRFY((ret >= 0), "H5Dclose1 succeeded");
+ }
H5Fclose(fid);
/* release data buffers */
if(rdata) free(rdata);
if(wdata) free(wdata);
-#endif
+
} /* dataset_large_readAll */
@@ -1478,7 +1213,8 @@ create_faccess_plist(MPI_Comm comm, MPI_Info info, int l_facc_type)
void
coll_chunk1(void)
{
- if (MAINPROCESS)
+ const char *filename = FILENAME[0];
+ if (mpi_rank == 0)
printf("coll_chunk1\n");
coll_chunktest(filename, 1, BYROW_CONT, API_NONE, HYPER, HYPER, OUT_OF_ORDER);
@@ -1531,7 +1267,8 @@ coll_chunk1(void)
void
coll_chunk2(void)
{
- if (MAINPROCESS)
+ const char *filename = FILENAME[0];
+ if (mpi_rank == 0)
printf("coll_chunk2\n");
coll_chunktest(filename, 1, BYROW_DISCONT, API_NONE, HYPER, HYPER, OUT_OF_ORDER);
@@ -1585,8 +1322,9 @@ coll_chunk2(void)
void
coll_chunk3(void)
{
- if (MAINPROCESS)
- printf("coll_chunk3\n");
+ const char *filename = FILENAME[0];
+ if (mpi_rank == 0)
+ printf("coll_chunk3\n");
coll_chunktest(filename, mpi_size, BYROW_CONT, API_NONE, HYPER, HYPER, OUT_OF_ORDER);
coll_chunktest(filename, mpi_size, BYROW_CONT, API_NONE, HYPER, POINT, OUT_OF_ORDER);
@@ -1956,7 +1694,7 @@ coll_chunktest(const char* filename,
acc_plist = create_faccess_plist(comm, info, facc_type);
VRFY((acc_plist >= 0),"MPIO creation property list succeeded");
- file = H5Fopen(filename,H5F_ACC_RDONLY,acc_plist);
+ file = H5Fopen(FILENAME[0],H5F_ACC_RDONLY,acc_plist);
VRFY((file >= 0),"H5Fcreate succeeded");
status = H5Pclose(acc_plist);
@@ -2134,16 +1872,34 @@ int main(int argc, char **argv)
{
int ExpressMode = 0;
hsize_t newsize = 1048576;
+ /* Set the bigio processing limit to be 'newsize' bytes */
hsize_t oldsize = H5S_mpio_set_bigio_count(newsize);
+ /* Having set the bigio handling to a size that is managable,
+ * we'll set our 'bigcount' variable to be 2X that limit so
+ * that we try to ensure that our bigio handling is actually
+ * envoked and tested.
+ */
if (newsize != oldsize) {
- bigcount = newsize * 2;
+ bigcount = newsize * 2;
}
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD,&mpi_size);
MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank);
+ /* Attempt to turn off atexit post processing so that in case errors
+ * happen during the test and the process is aborted, it will not get
+ * hang in the atexit post processing in which it may try to make MPI
+ * calls. By then, MPI calls may not work.
+ */
+ if (H5dont_atexit() < 0){
+ HDprintf("Failed to turn off atexit processing. Continue.\n");
+ };
+
+ /* set alarm. */
+ ALARM_ON;
+
ExpressMode = do_express_test(mpi_rank);
dataset_big_write();
@@ -2153,7 +1909,8 @@ int main(int argc, char **argv)
MPI_Barrier(MPI_COMM_WORLD);
if (ExpressMode > 0) {
- printf("***Express test mode on. Several tests are skipped\n");
+ if (mpi_rank == 0)
+ HDprintf("***Express test mode on. Several tests are skipped\n");
}
else {
coll_chunk1();
@@ -2163,6 +1920,12 @@ int main(int argc, char **argv)
coll_chunk3();
}
+ /* turn off alarm */
+ ALARM_OFF;
+
+ if (mpi_rank == 0)
+ HDremove(FILENAME[0]);
+
/* close HDF5 library */
H5close();
diff --git a/testpar/t_span_tree.c b/testpar/t_span_tree.c
index 20bc4ac..3c836ad 100644
--- a/testpar/t_span_tree.c
+++ b/testpar/t_span_tree.c
@@ -255,7 +255,7 @@ void coll_write_test(int chunk_factor)
#endif
- int *matrix_out, *matrix_out1, *vector;
+ int *matrix_out = NULL, *matrix_out1 = NULL, *vector = NULL;
int mpi_size,mpi_rank;
@@ -662,6 +662,13 @@ void coll_write_test(int chunk_factor)
ret = H5Fclose(file);
VRFY((ret >= 0),"");
+ if (vector)
+ HDfree(vector);
+ if (matrix_out)
+ HDfree(matrix_out);
+ if (matrix_out1)
+ HDfree(matrix_out1);
+
return ;
}
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index e02d3eb..5576f5c 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS)
#-----------------------------------------------------------------------------
diff --git a/tools/lib/CMakeLists.txt b/tools/lib/CMakeLists.txt
index addaf2e..db06b9a 100644
--- a/tools/lib/CMakeLists.txt
+++ b/tools/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_LIB)
#-----------------------------------------------------------------------------
diff --git a/tools/src/CMakeLists.txt b/tools/src/CMakeLists.txt
index 5a25f76..9364658 100644
--- a/tools/src/CMakeLists.txt
+++ b/tools/src/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_SRC)
#-----------------------------------------------------------------------------
diff --git a/tools/src/h5copy/CMakeLists.txt b/tools/src/h5copy/CMakeLists.txt
index 606516f..8423e5a 100644
--- a/tools/src/h5copy/CMakeLists.txt
+++ b/tools/src/h5copy/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_SRC_H5COPY)
#-----------------------------------------------------------------------------
diff --git a/tools/src/h5diff/CMakeLists.txt b/tools/src/h5diff/CMakeLists.txt
index 2ff5817..9e9f1ea 100644
--- a/tools/src/h5diff/CMakeLists.txt
+++ b/tools/src/h5diff/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_SRC_H5DIFF)
#-----------------------------------------------------------------------------
diff --git a/tools/src/h5dump/CMakeLists.txt b/tools/src/h5dump/CMakeLists.txt
index 491ec4b..1133218 100644
--- a/tools/src/h5dump/CMakeLists.txt
+++ b/tools/src/h5dump/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_SRC_H5DUMP)
#-----------------------------------------------------------------------------
diff --git a/tools/src/h5format_convert/CMakeLists.txt b/tools/src/h5format_convert/CMakeLists.txt
index 712dd87..4acc999 100644
--- a/tools/src/h5format_convert/CMakeLists.txt
+++ b/tools/src/h5format_convert/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_SRC_H5FC)
#-----------------------------------------------------------------------------
diff --git a/tools/src/h5import/CMakeLists.txt b/tools/src/h5import/CMakeLists.txt
index efb0ad2..d628c9b 100644
--- a/tools/src/h5import/CMakeLists.txt
+++ b/tools/src/h5import/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_SRC_H5IMPORT)
#-----------------------------------------------------------------------------
diff --git a/tools/src/h5jam/CMakeLists.txt b/tools/src/h5jam/CMakeLists.txt
index 9035ed9..59caf44 100644
--- a/tools/src/h5jam/CMakeLists.txt
+++ b/tools/src/h5jam/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_SRC_H5JAM)
#-----------------------------------------------------------------------------
diff --git a/tools/src/h5ls/CMakeLists.txt b/tools/src/h5ls/CMakeLists.txt
index 71b3d1d..e9ecd44 100644
--- a/tools/src/h5ls/CMakeLists.txt
+++ b/tools/src/h5ls/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_SRC_H5LS)
#-----------------------------------------------------------------------------
diff --git a/tools/src/h5repack/CMakeLists.txt b/tools/src/h5repack/CMakeLists.txt
index 3fefd24..211c947 100644
--- a/tools/src/h5repack/CMakeLists.txt
+++ b/tools/src/h5repack/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_SRC_H5REPACK)
#-----------------------------------------------------------------------------
diff --git a/tools/src/h5stat/CMakeLists.txt b/tools/src/h5stat/CMakeLists.txt
index cc8bee2..7842aa8 100644
--- a/tools/src/h5stat/CMakeLists.txt
+++ b/tools/src/h5stat/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_SRC_H5STAT)
#-----------------------------------------------------------------------------
diff --git a/tools/src/misc/CMakeLists.txt b/tools/src/misc/CMakeLists.txt
index 78ba238..948c6d4 100644
--- a/tools/src/misc/CMakeLists.txt
+++ b/tools/src/misc/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_SRC_MISC)
#-----------------------------------------------------------------------------
diff --git a/tools/src/misc/h5clear.c b/tools/src/misc/h5clear.c
index e3b989d..5724e1b 100644
--- a/tools/src/misc/h5clear.c
+++ b/tools/src/misc/h5clear.c
@@ -12,9 +12,11 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Purpose: A tool to clear the status_flags field from the file's superblock via -s option.
- * A tool to remove cache image from the file via -m option.
- *
+ * Purpose: A tool used to do the following:
+ * (1) -s, --status: clear the status_flags field from the file's superblock
+ * (2) -m, --image: remove the metadata cache image from the file
+ * (3) --increment=C: set the file's EOA to the maximum of (EOA, EOF) + C
+ * (4) --filesize: print the file's EOA and EOF
*/
#include "hdf5.h"
#include "H5private.h"
@@ -24,18 +26,25 @@
/* Name of tool */
#define PROGRAMNAME "h5clear"
-/* Make this private property (defined in H5Fprivate.h) available to h5clear. */
-#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags"
+/* Make these private properties (defined in H5Fprivate.h) available to h5clear. */
+#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags"
+#define H5F_ACS_NULL_FSM_ADDR_NAME "null_fsm_addr"
+#define H5F_ACS_SKIP_EOF_CHECK_NAME "skip_eof_check"
+
+/* Default increment is 1 megabytes for the --increment option */
+#define DEFAULT_INCREMENT 1024*1024
static char *fname_g = NULL;
static hbool_t clear_status_flags = FALSE;
static hbool_t remove_cache_image = FALSE;
+static hbool_t print_filesize = FALSE;
+static hbool_t increment_eoa_eof = FALSE;
+static hsize_t increment = DEFAULT_INCREMENT;
/*
- * Command-line options: The user can specify short or long-named
- * parameters.
+ * Command-line options: only publicize long options
*/
-static const char *s_opts = "hVsm";
+static const char *s_opts = "hVsmzi*";
static struct long_options l_opts[] = {
{ "help", no_arg, 'h' },
{ "hel", no_arg, 'h'},
@@ -54,6 +63,21 @@ static struct long_options l_opts[] = {
{ "imag", no_arg, 'm' },
{ "ima", no_arg, 'm' },
{ "im", no_arg, 'm' },
+ { "filesize", no_arg, 'z' },
+ { "filesiz", no_arg, 'z' },
+ { "filesi", no_arg, 'z' },
+ { "files", no_arg, 'z' },
+ { "file", no_arg, 'z' },
+ { "fil", no_arg, 'z' },
+ { "fi", no_arg, 'z' },
+ { "increment", optional_arg, 'i' },
+ { "incremen", optional_arg, 'i' },
+ { "increme", optional_arg, 'i' },
+ { "increm", optional_arg, 'i' },
+ { "incre", optional_arg, 'i' },
+ { "incr", optional_arg, 'i' },
+ { "inc", optional_arg, 'i' },
+ { "in", optional_arg, 'i' },
{ NULL, 0, '\0' }
};
@@ -76,6 +100,9 @@ static void usage(const char *prog)
HDfprintf(stdout, " -V, --version Print version number and exit\n");
HDfprintf(stdout, " -s, --status Clear the status_flags field in the file's superblock\n");
HDfprintf(stdout, " -m, --image Remove the metadata cache image from the file\n");
+ HDfprintf(stdout, " --filesize Print the file's EOA and EOF\n");
+ HDfprintf(stdout, " --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for the file <file_name>\n");
+ HDfprintf(stdout, " C is >= 0; C is optional and will default to 1M when not set");
HDfprintf(stdout, "\n");
HDfprintf(stdout, "Examples of use:\n");
HDfprintf(stdout, "\n");
@@ -84,6 +111,12 @@ static void usage(const char *prog)
HDfprintf(stdout, "\n");
HDfprintf(stdout, "h5clear -m file_name\n");
HDfprintf(stdout, " Remove the metadata cache image from the HDF5 file <file_name>.\n");
+ HDfprintf(stdout, "\n");
+ HDfprintf(stdout, "h5clear --increment file_name\n");
+ HDfprintf(stdout, " Set the EOA to the maximum of (EOA, EOF) + 1M for the file <file_name>.\n");
+ HDfprintf(stdout, "\n");
+ HDfprintf(stdout, "h5clear --increment=512 file_name\n");
+ HDfprintf(stdout, " Set the EOA to the maximum of (EOA, EOF) + 512 for the file <file_name>.\n");
} /* usage() */
@@ -131,6 +164,18 @@ parse_command_line(int argc, const char **argv)
remove_cache_image = TRUE;
break;
+ case 'z':
+ print_filesize = TRUE;
+ break;
+
+ case 'i':
+ increment_eoa_eof = TRUE;
+ if(opt_arg != NULL && (increment = HDatoi(opt_arg)) < 0) {
+ usage(h5tools_getprogname());
+ goto done;
+ }
+ break;
+
default:
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_FAILURE);
@@ -176,8 +221,24 @@ leave(int ret)
/*-------------------------------------------------------------------------
* Function: main
*
- * Purpose: To clear the status_flags field in the file's superblock (-s option).
- * To remove the cache image from the file (-m option).
+ * Purpose: The options are:
+ * (1) -s, --status: clear the status_flags field from the file's superblock
+ * (2) -m, --image: remove the metadata cache image from the file
+ * (3) --increment=C: set the file's EOA to the maximum of (EOA, EOF) + C
+ * (4) --filesize: print the file's EOA and EOF
+ *
+ * The three options: -s, -m, and --increment will modify the file
+ * so the file is opened with write access.
+ * The --filesize option just prints the EOA and EOF, so the file
+ * is opened with read access.
+ *
+ * The -s option will activate the private property:
+ * --H5F_ACS_CLEAR_STATUS_FLAGS_NAME
+ * The --increment option will active these two private properties:
+ * --H5F_ACS_NULL_FSM_ADDR_NAME
+ * --H5F_ACS_SKIP_EOF_CHECK_NAME
+ * The --filesize will activate the private property:
+ * --H5F_ACS_SKIP_EOF_CHECK_NAME
*
* Return: Success: 0
* Failure: 1
@@ -187,11 +248,12 @@ leave(int ret)
int
main (int argc, const char *argv[])
{
- char *fname = NULL; /* File name */
- hid_t fapl = -1; /* File access property list */
- hid_t fid = -1; /* File ID */
+ char *fname = NULL; /* File name */
+ hid_t fapl = -1; /* File access property list */
+ hid_t fid = -1; /* File ID */
haddr_t image_addr;
hsize_t image_len;
+ unsigned flags = H5F_ACC_RDWR; /* file access flags */
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
@@ -209,12 +271,22 @@ main (int argc, const char *argv[])
if(fname_g == NULL)
goto done;
- if(!clear_status_flags && !remove_cache_image) {
+ /* Print usage/exit if not using at least one of the options */
+ if(!clear_status_flags && !remove_cache_image &&
+ !increment_eoa_eof && !print_filesize) {
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
+ /* Cannot combine the --filesize option with other options */
+ if(print_filesize &&
+ (clear_status_flags || remove_cache_image || increment_eoa_eof)) {
+ error_msg("Cannot combine --filesize with other options\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+
/* Duplicate the file name */
fname = HDstrdup(fname_g);
@@ -228,7 +300,7 @@ main (int argc, const char *argv[])
/* -s option */
if(clear_status_flags) {
/* Set to clear the status_flags in the file's superblock */
- /* This is a private property used by h5clear only */
+ /* Activate this private property */
if(H5Pset(fapl, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear_status_flags) < 0) {
error_msg("H5Pset\n");
h5tools_setstatus(EXIT_FAILURE);
@@ -236,12 +308,64 @@ main (int argc, const char *argv[])
}
}
- if((fid = h5tools_fopen(fname, H5F_ACC_RDWR, fapl, NULL, NULL, (size_t)0)) < 0) {
+ /* --increment option */
+ if(increment_eoa_eof) {
+ /* Activate this private property */
+ if(H5Pset(fapl, H5F_ACS_SKIP_EOF_CHECK_NAME, &increment_eoa_eof) < 0) {
+ error_msg("H5Pset\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ /* Activate this private property */
+ if(H5Pset(fapl, H5F_ACS_NULL_FSM_ADDR_NAME, &increment_eoa_eof) < 0) {
+ error_msg("H5Pset\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ }
+
+ /* --filesize option; open the file read-only */
+ if(print_filesize) {
+ /* Activate this private property */
+ if(H5Pset(fapl, H5F_ACS_SKIP_EOF_CHECK_NAME, &print_filesize) < 0) {
+ error_msg("H5Pset\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ flags = H5F_ACC_RDONLY;
+ }
+
+ /* Open the file */
+ if((fid = h5tools_fopen(fname, flags, fapl, NULL, NULL, (size_t)0)) < 0) {
error_msg("h5tools_fopen\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
+ /* --filesize option */
+ if(print_filesize) {
+ h5_stat_t st; /* Stat info call */
+ haddr_t eoa; /* The EOA value */
+
+ /* Get the file's EOA and EOF */
+ if(H5Fget_eoa(fid, &eoa) < 0 || HDstat(fname, &st) < 0) {
+ error_msg("H5Fget_eoa or HDstat\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ HDfprintf(stdout, "EOA is %a; EOF is %a \n", eoa, st.st_size);
+ }
+
+ /* --increment option */
+ if(increment_eoa_eof) {
+ /* Set the file's EOA to the maximum of (EOA, EOF) + increment */
+ if(H5Fincrement_filesize(fid, increment) < 0) {
+ error_msg("H5Fset_eoa\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ }
+
/* -m option */
if(remove_cache_image) {
if(H5Fget_mdc_image_info(fid, &image_addr, &image_len) < 0) {
@@ -253,7 +377,9 @@ main (int argc, const char *argv[])
warn_msg("No cache image in the file\n");
}
+
h5tools_setstatus(EXIT_SUCCESS);
+
done:
if(fname)
HDfree(fname);
diff --git a/tools/test/CMakeLists.txt b/tools/test/CMakeLists.txt
index 54dd5a2..f194d7a 100644
--- a/tools/test/CMakeLists.txt
+++ b/tools/test/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_TEST)
#-----------------------------------------------------------------------------
diff --git a/tools/test/h5copy/CMakeLists.txt b/tools/test/h5copy/CMakeLists.txt
index 2f5f314..1f817fb 100644
--- a/tools/test/h5copy/CMakeLists.txt
+++ b/tools/test/h5copy/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_TEST_H5COPY)
#-----------------------------------------------------------------------------
diff --git a/tools/test/h5diff/CMakeLists.txt b/tools/test/h5diff/CMakeLists.txt
index cedc932..aae6327 100644
--- a/tools/test/h5diff/CMakeLists.txt
+++ b/tools/test/h5diff/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_TEST_H5DIFF)
#-----------------------------------------------------------------------------
diff --git a/tools/test/h5dump/CMakeLists.txt b/tools/test/h5dump/CMakeLists.txt
index 1941764..6a12f5e 100644
--- a/tools/test/h5dump/CMakeLists.txt
+++ b/tools/test/h5dump/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_TEST_H5DUMP)
#-----------------------------------------------------------------------------
diff --git a/tools/test/h5format_convert/CMakeLists.txt b/tools/test/h5format_convert/CMakeLists.txt
index 5287ae0..a27c78a 100644
--- a/tools/test/h5format_convert/CMakeLists.txt
+++ b/tools/test/h5format_convert/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_TEST_H5FC)
#-----------------------------------------------------------------------------
diff --git a/tools/test/h5import/CMakeLists.txt b/tools/test/h5import/CMakeLists.txt
index 5492363..2cb212a 100644
--- a/tools/test/h5import/CMakeLists.txt
+++ b/tools/test/h5import/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_TEST_H5IMPORT)
#-----------------------------------------------------------------------------
diff --git a/tools/test/h5jam/CMakeLists.txt b/tools/test/h5jam/CMakeLists.txt
index 17dda3c..b623860 100644
--- a/tools/test/h5jam/CMakeLists.txt
+++ b/tools/test/h5jam/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_TEST_H5JAM)
#-----------------------------------------------------------------------------
diff --git a/tools/test/h5ls/CMakeLists.txt b/tools/test/h5ls/CMakeLists.txt
index e92533f..8549046 100644
--- a/tools/test/h5ls/CMakeLists.txt
+++ b/tools/test/h5ls/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_TEST_H5LS)
#-----------------------------------------------------------------------------
diff --git a/tools/test/h5repack/CMakeLists.txt b/tools/test/h5repack/CMakeLists.txt
index a606ac6..50eb0af 100644
--- a/tools/test/h5repack/CMakeLists.txt
+++ b/tools/test/h5repack/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_TEST_H5REPACK)
#-----------------------------------------------------------------------------
diff --git a/tools/test/h5stat/CMakeLists.txt b/tools/test/h5stat/CMakeLists.txt
index 0d07753..5f645097 100644
--- a/tools/test/h5stat/CMakeLists.txt
+++ b/tools/test/h5stat/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_TEST_H5STAT)
#-----------------------------------------------------------------------------
diff --git a/tools/test/misc/CMakeLists.txt b/tools/test/misc/CMakeLists.txt
index 178767a..084751a 100644
--- a/tools/test/misc/CMakeLists.txt
+++ b/tools/test/misc/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_TEST_MISC)
#-----------------------------------------------------------------------------
diff --git a/tools/test/misc/CMakeTestsClear.cmake b/tools/test/misc/CMakeTestsClear.cmake
index 942ae7a..5efce0a 100644
--- a/tools/test/misc/CMakeTestsClear.cmake
+++ b/tools/test/misc/CMakeTestsClear.cmake
@@ -20,11 +20,19 @@
# Copy all the HDF5 files from the source directory into the test directory
# --------------------------------------------------------------------
set (HDF5_TEST_FILES
+ h5clear_fsm_persist_equal.h5
+ h5clear_fsm_persist_greater.h5
+ h5clear_fsm_persist_less.h5
+ h5clear_fsm_persist_noclose.h5
+ h5clear_fsm_persist_user_equal.h5
+ h5clear_fsm_persist_user_greater.h5
+ h5clear_fsm_persist_user_less.h5
h5clear_log_v3.h5
h5clear_mdc_image.h5
- mod_h5clear_mdc_image.h5
+ h5clear_status_noclose.h5
latest_h5clear_log_v3.h5
latest_h5clear_sec2_v3.h5
+ mod_h5clear_mdc_image.h5
)
set (HDF5_SEC2_TEST_FILES
h5clear_sec2_v0.h5
@@ -32,10 +40,25 @@
h5clear_sec2_v3.h5
)
set (HDF5_REFERENCE_TEST_FILES
- h5clear_usage.ddl
- h5clear_open_fail.ddl
+ h5clear_equal_after_size.ddl
+ h5clear_equal_before_size.ddl
+ h5clear_greater_after_size.ddl
+ h5clear_greater_before_size.ddl
+ h5clear_less_after_size.ddl
+ h5clear_less_before_size.ddl
h5clear_missing_file.ddl
+ h5clear_noclose_after_size.ddl
+ h5clear_noclose_before_size.ddl
h5clear_no_mdc_image.ddl
+ h5clear_open_fail.ddl
+ h5clear_status_noclose_after_size.ddl
+ h5clear_usage.ddl
+ h5clear_user_equal_after_size.ddl
+ h5clear_user_equal_before_size.ddl
+ h5clear_user_greater_after_size.ddl
+ h5clear_user_greater_before_size.ddl
+ h5clear_user_less_after_size.ddl
+ h5clear_user_less_before_size.ddl
)
foreach (h5_file ${HDF5_TEST_FILES} ${HDF5_SEC2_TEST_FILES} ${HDF5_REFERENCE_TEST_FILES})
@@ -270,3 +293,74 @@ endif()
ADD_H5_TEST (latest_h5clr_log_v3 latest_h5clear_log_v3 "true")
ADD_H5_TEST (h5clr_sec2_v0 h5clear_sec2_v0 "false")
ADD_H5_TEST (h5clr_sec2_v2 h5clear_sec2_v2 "false")
+#
+#
+#
+# The following tests verify the filesize, increment the filesize, then verify the filesize again.
+#
+# (1) h5clear_status_noclose.h5
+# "h5clear --filesize h5clear_status_noclose.h5" (unable to open the file because status_flags is enabled)
+# "h5clear -s --increment=0 h5clear_status_noclose.h5" (clear status_flag, EOA = MAX(EOA, EOF) + 0)
+# (no output, check exit code)
+# "h5clear --filesize h5clear_status_noclose.h5" (print EOA/EOF after the last action)
+ ADD_H5_CMP (h5clr_open_fail_s h5clear_open_fail 1 "--filesize" h5clear_status_noclose.h5)
+ ADD_H5_RETTEST (h5clr_mdc_image "false" "-s" "--increment=0" h5clear_status_noclose.h5)
+ ADD_H5_CMP (h5clr_no_mdc_image_m h5clear_status_noclose_after_size 0 "--filesize" h5clear_status_noclose.h5)
+#
+# (2) h5clear_fsm_persist_noclose.h5
+# "h5clear --filesize h5clear_fsm_persist_noclose.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_noclose.h5" (EOA = MAX(EOA, EOF)) (no output, just check exit code)
+# "h5clear --filesize h5clear_fsm_persist_noclose.h5" (print EOA/EOF after the last action)
+ ADD_H5_CMP (h5clr_open_fail_s h5clear_noclose_before_size 0 "--filesize" h5clear_fsm_persist_noclose.h5)
+ ADD_H5_RETTEST (h5clr_mdc_image "false" "--increment=0" h5clear_fsm_persist_noclose.h5)
+ ADD_H5_CMP (h5clr_no_mdc_image_m h5clear_noclose_after_size 0 "--filesize" h5clear_fsm_persist_noclose.h5)
+#
+# (3) h5clear_fsm_persist_equal.h5
+# "h5clear --filesize h5clear_fsm_persist_equal.h5" (print EOA/EOF before the next action)
+# "h5clear --increment h5clear_fsm_persist_equal.h5" (EOA = MAX(EOA, EOF) + 1M) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_equal.h5" (print EOA/EOF after the last action)
+ ADD_H5_CMP (h5clr_equal_before_size h5clear_equal_before_size 0 "--filesize" h5clear_fsm_persist_equal.h5)
+ ADD_H5_RETTEST (h5clr_equal_incr "false" "--increment" h5clear_fsm_persist_equal.h5)
+ ADD_H5_CMP (h5clr_equal_after_size h5clear_equal_after_size 0 "--filesize" h5clear_fsm_persist_equal.h5)
+#
+# (4) h5clear_fsm_persist_greater.h5
+# "h5clear --filesize h5clear_fsm_persist_greater.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_greater.h5" (print EOA/EOF after the last action)
+ ADD_H5_CMP (h5clr_greater_before_size h5clear_greater_before_size 0 "--filesize" h5clear_fsm_persist_greater.h5)
+ ADD_H5_RETTEST (h5clr_greater_incr "false" "--increment=0" h5clear_fsm_persist_greater.h5)
+ ADD_H5_CMP (h5clr_greater_after_size h5clear_greater_after_size 0 "--filesize" h5clear_fsm_persist_greater.h5)
+#
+# (5) h5clear_fsm_persist_less.h5
+# "h5clear --filesize h5clear_fsm_persist_less.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=200 h5clear_fsm_persist_less.h5" (EOA = MAX(EOA, EOF) + 200) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_less.h5" (print EOA/EOF after the last action)
+ ADD_H5_CMP (h5clr_less_before_size h5clear_less_before_size 0 "--filesize" h5clear_fsm_persist_less.h5)
+ ADD_H5_RETTEST (h5clr_less_incr "false" "--increment=200" h5clear_fsm_persist_less.h5)
+ ADD_H5_CMP (h5clr_less_after_size h5clear_less_after_size 0 "--filesize" h5clear_fsm_persist_less.h5)
+#
+# (6) h5clear_fsm_persist_user_equal.h5
+# "h5clear --filesize h5clear_fsm_persist_user_equal.h5" (print EOA/EOF before the next action)
+# "h5clear --increment h5clear_fsm_persist_user_equal.h5" (EOA = MAX(EOA, EOF) + 1M) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_equal.h5" (print EOA/EOF after the last action)
+ ADD_H5_CMP (h5clr_user_equal_before_size h5clear_user_equal_before_size 0 "--filesize" h5clear_fsm_persist_user_equal.h5)
+ ADD_H5_RETTEST (h5clr_user_equal_incr "false" "--increment" h5clear_fsm_persist_user_equal.h5)
+ ADD_H5_CMP (h5clr_user_equal_after_size h5clear_user_equal_after_size 0 "--filesize" h5clear_fsm_persist_user_equal.h5)
+#
+# (7) h5clear_fsm_persist_user_greater.h5
+# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_user_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF after the last action)
+ ADD_H5_CMP (h5clr_user_greater_before_size h5clear_user_greater_before_size 0 "--filesize" h5clear_fsm_persist_user_greater.h5)
+ ADD_H5_RETTEST (h5clr_user_greater_incr "false" "--increment=0" h5clear_fsm_persist_user_greater.h5)
+ ADD_H5_CMP (h5clr_user_greater_after_size h5clear_user_greater_after_size 0 "--filesize" h5clear_fsm_persist_user_greater.h5)
+#
+# (8) h5clear_fsm_persist_user_less.h5
+# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_user_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF after the last action)
+ ADD_H5_CMP (h5clr_user_less_before_size h5clear_user_less_before_size 0 "--filesize" h5clear_fsm_persist_user_less.h5)
+ ADD_H5_RETTEST (h5clr_user_less_incr "false" "--increment=0" h5clear_fsm_persist_user_less.h5)
+ ADD_H5_CMP (h5clr_user_less_after_size h5clear_user_less_after_size 0 "--filesize" h5clear_fsm_persist_user_less.h5)
+#
+#
diff --git a/tools/test/misc/h5clear_gentest.c b/tools/test/misc/h5clear_gentest.c
index 326109c..ccb510f 100644
--- a/tools/test/misc/h5clear_gentest.c
+++ b/tools/test/misc/h5clear_gentest.c
@@ -21,10 +21,25 @@ const char *FILENAME[] = {
"h5clear_sec2_v2.h5" /* 3 -- sec2 file with superblock version 2 */
};
+const char *FILENAME_ENHANCE[] = {
+ "h5clear_fsm_persist_equal.h5", /* 0: persisting free-space, stored EOA = actual EOF */
+ "h5clear_fsm_persist_greater.h5", /* 1: persisting free-space, stored EOA > actual EOF */
+ "h5clear_fsm_persist_less.h5", /* 2: persisting free-space, stored EOA < actual EOF */
+ "h5clear_fsm_persist_user_equal.h5", /* 3: user block, persisting free-space, stored EOA = actual EOF */
+ "h5clear_fsm_persist_user_greater.h5", /* 4: user block, persisting free-space, stored EOA > actual EOF */
+ "h5clear_fsm_persist_user_less.h5", /* 5: user block, persisting free-space, stored EOA < actual EOF */
+ "h5clear_status_noclose.h5", /* 6 -- v3 superblock, nonzero status_flags, no flush, exit,
+ stored EOA < actual EOF */
+ "h5clear_fsm_persist_noclose.h5" /* 7 -- persisting free-space, no flush, exit, stored EOA < actual EOF */
+};
+
#define KB 1024U
#define CACHE_IMAGE_FILE "h5clear_mdc_image.h5"
#define DSET "DSET"
+#define DATASET "dset"
+#define NUM_ELMTS 100
+#define USERBLOCK 512
/*-------------------------------------------------------------------------
* Function: gen_cache_image_file
@@ -118,26 +133,224 @@ error:
H5Pclose(dcpl);
} H5E_END_TRY;
return 1;
-}
+} /* gen_cache_image_file() */
+
+/*-------------------------------------------------------------------------
+ * Function: gen_enhance_files
+ *
+ * Purpose: To create the first 6 files in FILENAME_ENHANCE[]:
+ * (0) FILENAME_ENHANCE[0]: "h5clear_fsm_persist_equal.h5"
+ * (1) FILENAME_ENHANCE[1]: "h5clear_fsm_persist_greater.h5"
+ * (2) FILENAME_ENHANCE[2]: "h5clear_fsm_persist_less.h5"
+ * (3) FILENAME_ENHANCE[3]: "h5clear_user_fsm_persist_equal.h5"
+ * (4) FILENAME_ENHANCE[4]: "h5clear_user_fsm_persist_greater.h5"
+ * (5) FILENAME_ENHANCE[5]: "h5clear_user_fsm_persist_less.h5"
+ * After creating the files for #1, #2, #4 #5, write invalid EOA
+ * value to the location where the EOA is stored in the superblock.
+ * Also modify the chksum in the superblock due to this change.
+ *
+ * The first call to this routine (without user block) will generate
+ * the first 3 files.
+ * The second call to this routine (with user block) will generate
+ * the last 3 files.
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Vailin Choi; March 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+gen_enhance_files(hbool_t user)
+{
+ hid_t fid = -1; /* File ID */
+ hid_t fcpl = -1; /* File creation property list */
+ hid_t fapl = -1; /* File access property list */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* Dataset ID */
+ hsize_t dim[1]; /* Dimension sizes */
+ int data[NUM_ELMTS]; /* Buffer for data */
+ int fd = -1; /* The file descriptor ID */
+ int64_t eoa; /* The EOA value */
+ int32_t chksum; /* The chksum value */
+ int i = 0 , j = 0, u = 0; /* Local index variable */
+
+ /* Get a copy of the default file creation property */
+ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ goto error;
+
+ /* Check to see if user block will be added */
+ if(user) {
+ if(H5Pset_userblock(fcpl, (hsize_t)USERBLOCK) < 0)
+ goto error;
+ u = 3;
+ }
+
+ /* Set file space strategy and persisting free-space */
+ if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0)
+ goto error;
+
+ /*
+ * Create the file, then write invalid EOA to the file.
+ */
+ for(i = 0+u; i < 3+u; i++) {
+
+ /* Create the file with the file space strategy and persisting free-space */
+ if((fid = H5Fcreate(FILENAME_ENHANCE[i], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0)
+ goto error;
+
+ /* Create the dataset */
+ dim[0] = NUM_ELMTS;
+ if((sid = H5Screate_simple(1, dim, NULL)) < 0)
+ goto error;
+ if((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+
+ for(j = 0; j < NUM_ELMTS; j++)
+ data[j] = j;
+
+ /* Write the dataset */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
+ goto error;
+
+ /* Closing */
+ if(H5Dclose(did) < 0)
+ goto error;
+ if(H5Sclose(sid) < 0)
+ goto error;
+ if(H5Fclose(fid) < 0)
+ goto error;
+
+ /*
+ * No further action for:
+ * --FILENAME_ENHANCE[0]: "h5clear_fsm_persist_equal.h5"
+ * --FILENAME_ENHANCE[3]: "h5clear_fsm_persist_user_equal.h5",
+ */
+ if(!(i % 3))
+ continue;
+ /*
+ * For the following files:
+ * --FILENAME_ENHANCE[1]: "h5clear_fsm_persist_greater.h5"
+ * --FILENAME_ENHANCE[2]: "h5clear_fsm_persist_less.h5"
+ * --FILENAME_ENHANCE[4]: "h5clear_fsm_persist_greater.h5"
+ * --FILENAME_ENHANCE[5]: "h5clear_fsm_persist_less.h5"
+ *
+ * Write invalid value to the location for stored eoa and
+ * update the chksum value.
+ */
+ /* Open the file */
+ if((fd = open(FILENAME_ENHANCE[i], O_RDWR, 0663)) < 0)
+ goto error;
+
+ switch(i) {
+ case 1: /* stored EOA is > EOF */
+ eoa = 3048;
+ chksum = 268376587;
+ break;
+
+ case 2: /* stored EOA is < EOF */
+ eoa = 512;
+ chksum = 372920305;
+ break;
+
+ case 4: /* with userblock, stored EOA > EOF */
+ eoa = 4000;
+ chksum = 4168810027;
+ break;
+
+ case 5: /* with userblock, stored EOA < EOF */
+ eoa = 3000;
+ chksum = 3716054346;
+ break;
+
+ default:
+ break;
+ }
+
+ /* location of "end of file address" */
+ if(lseek(fd, (off_t)(28+(user?USERBLOCK:0)), SEEK_SET) < 0)
+ goto error;
+
+ /* Write the bad eoa value to the file */
+ if(write(fd, &eoa, sizeof(eoa)) < 0)
+ goto error;
+
+ /* location of "superblock checksum" */
+ if(lseek(fd, (off_t)(44+(user?USERBLOCK:0)), SEEK_SET) < 0)
+ goto error;
+
+ /* Write the chksum value to the file */
+ if(write(fd, &chksum, sizeof(chksum)) < 0)
+ goto error;
+
+ /* Close the file */
+ if(close(fd) < 0)
+ goto error;
+
+ } /* end for */
+
+ /* Close the property list */
+ if(H5Pclose(fcpl) < 0)
+ goto error;
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Fclose(fid);
+ H5Pclose(fcpl);
+ } H5E_END_TRY;
+ return 1;
+} /* gen_enhance_files() */
/*-------------------------------------------------------------------------
* Function: main
*
- * Purpose: To create HDF5 files with non-zero status_flags in the superblock
- * via flushing and exiting without closing the library.
+ * Purpose: Generate test files used by h5clear.
*
- * Due to file locking, status_flags in the superblock will be
- * nonzero after H5Fcreate. The library will clear status_flags
- * on file closing. This program, after "H5Fcreate" the files,
- * exits without going through library closing. Thus, status_flags
- * for these files are not cleared.
- * The library will check consistency of status_flags when opening
- * a file with superblock >= v3 and will return error accordingly.
- * The library will not check status_flags when opening a file
- * with < v3 superblock.
+ * (A) gen_cache_image_file():
+ * --generate a file with cache image feature
+ * --"h5clear_mdc_image.h5"
+ * (B) gen_enhance_files():
+ * --generate the first 6 files in FILENAME_ENHANCE[]:
+ * (0) "h5clear_fsm_persist_equal.h5"
+ * (1) "h5clear_fsm_persist_greater.h5"
+ * (2) "h5clear_fsm_persist_less.h5"
+ * (3) "h5clear_fsm_persist_user_equal.h5"
+ * (4) "h5clear_fsm_persist_user_greater.h5"
+ * (5) "h5clear_fsm_persist_user_less.h5"
*
- * These files are used by "h5clear" to see if the tool clears
- * status_flags properly so users can open the files afterwards.
+ * (C) Generate the following FILENAME[] files in main():
+ * (0a) "h5clear_sec2_v3.h5"
+ * (0b) "latest_h5clear_sec2_v3.h5"
+ * (1a) "h5clear_log_v3.h5",
+ * (1b) "latest_h5clear_log_v3.h5"
+ * (2) "h5clear_sec2_v0.h5"
+ * (3) "h5clear_sec2_v2.h5"
+ *
+ * These HDF5 files are created with non-zero status_flags in
+ * the superblock via flushing and exiting without closing the
+ * library.
+ * Due to file locking, status_flags in the superblock will be
+ * nonzero after H5Fcreate. The library will clear status_flags
+ * on file closing.
+ * This program, after "H5Fcreate" the files, exits without
+ * going through library closing. Thus, status_flags for these
+ * files are not cleared.
+ * The library will check consistency of status_flags when
+ * opening a file with superblock >= v3 and will return error
+ * accordingly.
+ * The library will not check status_flags when opening a file
+ * with < v3 superblock.
+ * These files are used by "h5clear" to see if the tool clears
+ * status_flags properly so users can open the files afterwards.
+ *
+ * (D) Generate the last two files in FILENAME_ENHANCE[] in main():
+ * (6) "h5clear_status_noclose.h5",
+ * (7) "h5clear_fsm_persist_noclose.h5"
*
* Return: Success: 0
* Failure: 1
@@ -149,20 +362,30 @@ error:
int
main(void)
{
- hid_t fid; /* File ID */
- hid_t fcpl; /* File creation property list */
- hid_t fapl, new_fapl; /* File access property lists */
+ hid_t fid = -1; /* File ID */
+ hid_t fcpl = -1; /* File creation property list */
+ hid_t fapl = -1, new_fapl = -1; /* File access property lists */
char fname[512]; /* File name */
- unsigned new_format; /* To use latest library format or not */
+ unsigned new_format; /* To use latest library format or not */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* Dataset ID */
+ hsize_t dim[1]; /* Dimension sizes */
+ int data[NUM_ELMTS]; /* Buffer for data */
+ int i; /* Local index variables */
/* Generate a file with cache image feature enabled */
if(gen_cache_image_file(CACHE_IMAGE_FILE) < 0)
goto error;
+ /* Generate the first 6 files in FILENAME_ENHANCE[] */
+ if(gen_enhance_files(FALSE) < 0)
+ goto error;
+ if(gen_enhance_files(TRUE) < 0)
+ goto error;
+
/*
- * Generate files with invalid status_flags
+ * Generate files in FILENAME[]
*/
-
/* Create a copy of the file access property list */
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
goto error;
@@ -174,7 +397,11 @@ main(void)
if(H5Pset_libver_bounds(new_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
goto error;
- /* Files created within this for loop will have v3 superblock and nonzero status_flags */
+ /*
+ * Files created within this for loop will have v3 superblock and nonzero status_flags
+ * --FILENAME[0]: "h5clear_sec2_v3.h5", "latest_h5clear_sec2_v3.h5"
+ * --FILENAME[1]: "h5clear_log_v3.h5", "latest_h5clear_log_v3.h5"
+ */
for(new_format = FALSE; new_format <= TRUE; new_format++) {
hid_t fapl2, my_fapl; /* File access property lists */
@@ -228,7 +455,8 @@ main(void)
} /* end for */
/*
- * Create a sec2 file with v0 superblock but nonzero status_flags
+ * Create a sec2 file with v0 superblock but nonzero status_flags:
+ * FILENAME[2]: "h5clear_sec2_v0.h5"
*/
if((fid = H5Fcreate(FILENAME[2], H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
goto error;
@@ -239,7 +467,8 @@ main(void)
/*
- * Create a sec2 file with v2 superblock but nonzero status_flags
+ * Create a sec2 file with v2 superblock but nonzero status_flags:
+ * FILENAME[3]: "h5clear_sec2_v2.h5"
*/
if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
goto error;
@@ -264,6 +493,100 @@ main(void)
if(H5Pclose(fcpl) < 0)
goto error;
+ /*
+ * Create the last two files in FILENAME_ENHANCE[]:
+ * --FILENAME_ENHANCE[6]: h5clear_status_noclose.h5
+ * --FILENAME_ENHANCE[7]: h5clear_fsm_persist_noclose.h5
+ */
+ /*
+ * FILENAME_ENHANCE[6]: h5clear_status_noclose.h5
+ * --stored EOA < actual EOF
+ * --version 3 superblock
+ * --nonzero status_flags
+ * --does not persist free-space
+ * --does not flush the file, just exit without closing file:
+ * --this file is similar to the user-suppplied test file attached with HDFFV-10347
+ */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ goto error;
+
+ /* Set to latest format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ goto error;
+
+ /* Create file with SWMR-write access */
+ if((fid = H5Fcreate(FILENAME_ENHANCE[6], H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0)
+ goto error;
+
+ /* Create the dataset */
+ dim[0] = NUM_ELMTS;
+ if((sid = H5Screate_simple(1, dim, NULL)) < 0)
+ goto error;
+ if((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+
+ for(i = 0; i < NUM_ELMTS; i++)
+ data[i] = i;
+
+ /* Write the dataset */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
+ goto error;
+
+ /* Closing */
+ if(H5Dclose(did) < 0)
+ goto error;
+ if(H5Sclose(sid) < 0)
+ goto error;
+ if(H5Pclose(fapl) < 0)
+ goto error;
+
+ /* Does not flush and does not close the file */
+
+
+ /*
+ * FILENAME_ENHANCE[7]: h5clear_fsm_persist_noclose.h5
+ * --stored EOA < actual EOF
+ * --persisting free-space
+ * --undefined fsinfo.eoa_pre_fsm_fsalloc
+ * --undefined fsinfo.fs_addr
+ * --does not flush the file, just exit without closing
+ */
+ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ goto error;
+
+ /* Set file space strategy and persisting free-space */
+ if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0)
+ goto error;
+
+ /* Create the file with the set file space info */
+ if((fid = H5Fcreate(FILENAME_ENHANCE[7], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0)
+ goto error;
+
+ /* Create the dataset */
+ dim[0] = NUM_ELMTS;
+ if((sid = H5Screate_simple(1, dim, NULL)) < 0)
+ goto error;
+ if((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+
+ for(i = 0; i < NUM_ELMTS; i++)
+ data[i] = i;
+
+ /* Write the dataset */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
+ goto error;
+
+ /* Closing */
+ if(H5Dclose(did) < 0)
+ goto error;
+ if(H5Sclose(sid) < 0)
+ goto error;
+ if(H5Pclose(fcpl) < 0)
+ goto error;
+
+ /* Does not flush and does not close the file */
+
+
fflush(stdout);
fflush(stderr);
diff --git a/tools/test/misc/testfiles/h5clear_equal_after_size.ddl b/tools/test/misc/testfiles/h5clear_equal_after_size.ddl
new file mode 100644
index 0000000..1b9a4e4
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_equal_after_size.ddl
@@ -0,0 +1 @@
+EOA is 1051141; EOF is 1051141
diff --git a/tools/test/misc/testfiles/h5clear_equal_before_size.ddl b/tools/test/misc/testfiles/h5clear_equal_before_size.ddl
new file mode 100644
index 0000000..9beed42
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_equal_before_size.ddl
@@ -0,0 +1 @@
+EOA is 2565; EOF is 2565
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_equal.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_equal.h5
new file mode 100644
index 0000000..0577690
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_equal.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_greater.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_greater.h5
new file mode 100644
index 0000000..6358878
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_greater.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_less.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_less.h5
new file mode 100644
index 0000000..c1f3221
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_less.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_noclose.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_noclose.h5
new file mode 100644
index 0000000..57462db
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_noclose.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_user_equal.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_user_equal.h5
new file mode 100644
index 0000000..5389c41
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_user_equal.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_user_greater.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_user_greater.h5
new file mode 100644
index 0000000..f40e760
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_user_greater.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_user_less.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_user_less.h5
new file mode 100644
index 0000000..55d0cc5
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_user_less.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_greater_after_size.ddl b/tools/test/misc/testfiles/h5clear_greater_after_size.ddl
new file mode 100644
index 0000000..74c8f19
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_greater_after_size.ddl
@@ -0,0 +1 @@
+EOA is 3048; EOF is 3048
diff --git a/tools/test/misc/testfiles/h5clear_greater_before_size.ddl b/tools/test/misc/testfiles/h5clear_greater_before_size.ddl
new file mode 100644
index 0000000..03b22fb
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_greater_before_size.ddl
@@ -0,0 +1 @@
+EOA is 3048; EOF is 2565
diff --git a/tools/test/misc/testfiles/h5clear_less_after_size.ddl b/tools/test/misc/testfiles/h5clear_less_after_size.ddl
new file mode 100644
index 0000000..bedf0d2
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_less_after_size.ddl
@@ -0,0 +1 @@
+EOA is 2765; EOF is 2765
diff --git a/tools/test/misc/testfiles/h5clear_less_before_size.ddl b/tools/test/misc/testfiles/h5clear_less_before_size.ddl
new file mode 100644
index 0000000..50ba4c4
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_less_before_size.ddl
@@ -0,0 +1 @@
+EOA is 512; EOF is 2565
diff --git a/tools/test/misc/testfiles/h5clear_missing_file.ddl b/tools/test/misc/testfiles/h5clear_missing_file.ddl
index 1e5150c..13eb2c9 100644
--- a/tools/test/misc/testfiles/h5clear_missing_file.ddl
+++ b/tools/test/misc/testfiles/h5clear_missing_file.ddl
@@ -4,7 +4,9 @@ usage: h5clear [OPTIONS] file_name
-V, --version Print version number and exit
-s, --status Clear the status_flags field in the file's superblock
-m, --image Remove the metadata cache image from the file
-
+ --filesize Print the file's EOA and EOF
+ --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for the file <file_name>
+ C is >= 0; C is optional and will default to 1M when not set
Examples of use:
h5clear -s file_name
@@ -12,4 +14,10 @@ h5clear -s file_name
h5clear -m file_name
Remove the metadata cache image from the HDF5 file <file_name>.
+
+h5clear --increment file_name
+ Set the EOA to the maximum of (EOA, EOF) + 1M for the file <file_name>.
+
+h5clear --increment=512 file_name
+ Set the EOA to the maximum of (EOA, EOF) + 512 for the file <file_name>.
h5clear error: missing file name
diff --git a/tools/test/misc/testfiles/h5clear_noclose_after_size.ddl b/tools/test/misc/testfiles/h5clear_noclose_after_size.ddl
new file mode 100644
index 0000000..7846b47
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_noclose_after_size.ddl
@@ -0,0 +1 @@
+EOA is 2448; EOF is 2448
diff --git a/tools/test/misc/testfiles/h5clear_noclose_before_size.ddl b/tools/test/misc/testfiles/h5clear_noclose_before_size.ddl
new file mode 100644
index 0000000..f294a6d
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_noclose_before_size.ddl
@@ -0,0 +1 @@
+EOA is 2048; EOF is 2448
diff --git a/tools/test/misc/testfiles/h5clear_status_noclose.h5 b/tools/test/misc/testfiles/h5clear_status_noclose.h5
new file mode 100644
index 0000000..94a950d
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_status_noclose.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_status_noclose_after_size.ddl b/tools/test/misc/testfiles/h5clear_status_noclose_after_size.ddl
new file mode 100644
index 0000000..7846b47
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_status_noclose_after_size.ddl
@@ -0,0 +1 @@
+EOA is 2448; EOF is 2448
diff --git a/tools/test/misc/testfiles/h5clear_usage.ddl b/tools/test/misc/testfiles/h5clear_usage.ddl
index a399ae7..32dd549 100644
--- a/tools/test/misc/testfiles/h5clear_usage.ddl
+++ b/tools/test/misc/testfiles/h5clear_usage.ddl
@@ -4,7 +4,9 @@ usage: h5clear [OPTIONS] file_name
-V, --version Print version number and exit
-s, --status Clear the status_flags field in the file's superblock
-m, --image Remove the metadata cache image from the file
-
+ --filesize Print the file's EOA and EOF
+ --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for the file <file_name>
+ C is >= 0; C is optional and will default to 1M when not set
Examples of use:
h5clear -s file_name
@@ -12,3 +14,9 @@ h5clear -s file_name
h5clear -m file_name
Remove the metadata cache image from the HDF5 file <file_name>.
+
+h5clear --increment file_name
+ Set the EOA to the maximum of (EOA, EOF) + 1M for the file <file_name>.
+
+h5clear --increment=512 file_name
+ Set the EOA to the maximum of (EOA, EOF) + 512 for the file <file_name>.
diff --git a/tools/test/misc/testfiles/h5clear_user_equal_after_size.ddl b/tools/test/misc/testfiles/h5clear_user_equal_after_size.ddl
new file mode 100644
index 0000000..028e134
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_equal_after_size.ddl
@@ -0,0 +1 @@
+EOA is 1051653; EOF is 1051653
diff --git a/tools/test/misc/testfiles/h5clear_user_equal_before_size.ddl b/tools/test/misc/testfiles/h5clear_user_equal_before_size.ddl
new file mode 100644
index 0000000..ef7c391
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_equal_before_size.ddl
@@ -0,0 +1 @@
+EOA is 3077; EOF is 3077
diff --git a/tools/test/misc/testfiles/h5clear_user_greater_after_size.ddl b/tools/test/misc/testfiles/h5clear_user_greater_after_size.ddl
new file mode 100644
index 0000000..9d7de6f
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_greater_after_size.ddl
@@ -0,0 +1 @@
+EOA is 4000; EOF is 4000
diff --git a/tools/test/misc/testfiles/h5clear_user_greater_before_size.ddl b/tools/test/misc/testfiles/h5clear_user_greater_before_size.ddl
new file mode 100644
index 0000000..c3fe625
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_greater_before_size.ddl
@@ -0,0 +1 @@
+EOA is 4000; EOF is 3077
diff --git a/tools/test/misc/testfiles/h5clear_user_less_after_size.ddl b/tools/test/misc/testfiles/h5clear_user_less_after_size.ddl
new file mode 100644
index 0000000..02c0d2a
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_less_after_size.ddl
@@ -0,0 +1 @@
+EOA is 3277; EOF is 3277
diff --git a/tools/test/misc/testfiles/h5clear_user_less_before_size.ddl b/tools/test/misc/testfiles/h5clear_user_less_before_size.ddl
new file mode 100644
index 0000000..0651c2b
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_less_before_size.ddl
@@ -0,0 +1 @@
+EOA is 3000; EOF is 3077
diff --git a/tools/test/misc/testh5clear.sh.in b/tools/test/misc/testh5clear.sh.in
index 2966b2c..11c2ff9 100644
--- a/tools/test/misc/testh5clear.sh.in
+++ b/tools/test/misc/testh5clear.sh.in
@@ -66,6 +66,21 @@ $SRC_H5CLEAR_TESTFILES/h5clear_usage.ddl
$SRC_H5CLEAR_TESTFILES/h5clear_open_fail.ddl
$SRC_H5CLEAR_TESTFILES/h5clear_missing_file.ddl
$SRC_H5CLEAR_TESTFILES/h5clear_no_mdc_image.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_status_noclose_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_noclose_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_noclose_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_equal_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_equal_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_greater_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_greater_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_less_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_less_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_equal_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_equal_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_greater_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_greater_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_less_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_less_after_size.ddl
$SRC_H5CLEAR_TESTFILES/h5clear_sec2_v0.h5
$SRC_H5CLEAR_TESTFILES/h5clear_sec2_v2.h5
$SRC_H5CLEAR_TESTFILES/h5clear_sec2_v3.h5
@@ -74,6 +89,14 @@ $SRC_H5CLEAR_TESTFILES/latest_h5clear_log_v3.h5
$SRC_H5CLEAR_TESTFILES/latest_h5clear_sec2_v3.h5
$SRC_H5CLEAR_TESTFILES/h5clear_mdc_image.h5
$SRC_H5CLEAR_TESTFILES/mod_h5clear_mdc_image.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_status_noclose.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_noclose.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_equal.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_greater.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_less.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_user_equal.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_user_greater.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_user_less.h5
"
COPY_TESTFILES_TO_TESTDIR()
@@ -152,7 +175,8 @@ TOOLTEST_OUT() {
fname=$1
option1=$2
option2=$3
- expected=$4
+ option3=$4
+ expected=$5
# Prepare expected and actual output
expect="$TESTDIR/$expected"
actual="$TESTDIR/`basename $expected .ddl`.out"
@@ -161,10 +185,10 @@ TOOLTEST_OUT() {
actual_err_sav=${actual_err}-sav
# Run test.
- TESTING $H5CLEAR $option1 $option2 $fname
+ TESTING $H5CLEAR $option1 $option2 $option3 $option4 $fname
(
cd $TESTDIR
- $RUNSERIAL $H5CLEAR_BIN $option1 $option2 $fname
+ $RUNSERIAL $H5CLEAR_BIN $option1 $option2 $option3 $option4 $fname
) >$actual 2>$actual_err
cp $actual $actual_sav
cp $actual_err $actual_err_sav
@@ -245,17 +269,16 @@ $CP -f $TESTDIR/h5clear_sec2_v3.h5 $TESTDIR/orig_h5clear_sec2_v3.h5
# "h5clear -m -s junk.h5" (valid 2 options, nonexisting file)
# "h5clear -m orig_h5clear_sec2_v2.h5" (valid 1 option, existing file, no cache image)
# "h5clear -s -m orig_h5clear_sec2_v0.h5" (valid 2 options, existing file, no cache image)
-TOOLTEST_OUT "" -h "" h5clear_usage.ddl
-TOOLTEST_OUT "" "" "" h5clear_usage.ddl
-TOOLTEST_OUT junk.h5 "" "" h5clear_usage.ddl
-TOOLTEST_OUT orig_h5clear_sec2_v3.h5 "" "" h5clear_usage.ddl
-TOOLTEST_OUT "" -m "" h5clear_missing_file.ddl
-TOOLTEST_OUT junk.h5 -s "" h5clear_open_fail.ddl
-TOOLTEST_OUT "" -m -s h5clear_missing_file.ddl
-TOOLTEST_OUT junk.h5 -m -s h5clear_open_fail.ddl
-TOOLTEST_OUT orig_h5clear_sec2_v2.h5 -m "" h5clear_no_mdc_image.ddl
-TOOLTEST_OUT orig_h5clear_sec2_v0.h5 -s -m h5clear_no_mdc_image.ddl
-#
+TOOLTEST_OUT "" -h "" "" h5clear_usage.ddl
+TOOLTEST_OUT "" "" "" "" h5clear_usage.ddl
+TOOLTEST_OUT junk.h5 "" "" "" h5clear_usage.ddl
+TOOLTEST_OUT orig_h5clear_sec2_v3.h5 "" "" "" h5clear_usage.ddl
+TOOLTEST_OUT "" -m "" "" h5clear_missing_file.ddl
+TOOLTEST_OUT junk.h5 -s "" "" h5clear_open_fail.ddl
+TOOLTEST_OUT "" -m -s "" h5clear_missing_file.ddl
+TOOLTEST_OUT junk.h5 -m -s "" h5clear_open_fail.ddl
+TOOLTEST_OUT orig_h5clear_sec2_v2.h5 -m "" "" h5clear_no_mdc_image.ddl
+TOOLTEST_OUT orig_h5clear_sec2_v0.h5 -s -m "" h5clear_no_mdc_image.ddl
#
#
# The following are tests to verify the expected exit code from h5clear:
@@ -285,8 +308,8 @@ TOOLTEST h5clear_sec2_v0.h5 -l -m $FAIL
#
#
# h5clear_mdc_image.h5 already has cache image removed earlier, verify the expected warning from h5clear:
-TOOLTEST_OUT mod_h5clear_mdc_image.h5 -m "" h5clear_no_mdc_image.ddl
-TOOLTEST_OUT mod_h5clear_mdc_image.h5 -s -m h5clear_no_mdc_image.ddl
+TOOLTEST_OUT mod_h5clear_mdc_image.h5 -m "" "" h5clear_no_mdc_image.ddl
+TOOLTEST_OUT mod_h5clear_mdc_image.h5 -s -m "" h5clear_no_mdc_image.ddl
#
#
#
@@ -319,6 +342,73 @@ OPEN_CHK h5clear_sec2_v2.h5 $SUCCEED
#
#
#
+# (1) h5clear_status_noclose.h5
+# "h5clear --filesize h5clear_status_noclose.h5" (unable to open the file because status_flag is on)
+# "h5clear -s --increment=0 h5clear_status_noclose.h5" (clear status_flag, EOA = MAX(EOA, EOF) + 0)
+# (no output, check exit code)
+# "h5clear --filesize h5clear_status_noclose_user.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_status_noclose.h5 --filesize "" "" h5clear_open_fail.ddl
+TOOLTEST h5clear_status_noclose.h5 -s --increment=0 $SUCCEED
+TOOLTEST_OUT h5clear_status_noclose.h5 --filesize "" "" h5clear_status_noclose_after_size.ddl
+#
+# (2) h5clear_fsm_persist_noclose.h5
+# "h5clear --filesize h5clear_fsm_persist_noclose.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_noclose.h5" (EOA = MAX(EOA, EOF)) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_noclose.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_noclose.h5 --filesize "" "" h5clear_noclose_before_size.ddl
+TOOLTEST h5clear_fsm_persist_noclose.h5 --increment=0 "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_noclose.h5 --filesize "" "" h5clear_noclose_after_size.ddl
+#
+# (3) h5clear_fsm_persist_equal.h5
+# "h5clear --filesize h5clear_fsm_persist_equal.h5" (print EOA/EOF before the next action)
+# "h5clear --increment h5clear_fsm_persist_equal.h5" (EOA = MAX(EOA, EOF) + 1M) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_equal.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_equal.h5 --filesize "" "" h5clear_equal_before_size.ddl
+TOOLTEST h5clear_fsm_persist_equal.h5 --increment "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_equal.h5 --filesize "" "" h5clear_equal_after_size.ddl
+#
+# (4) h5clear_fsm_persist_greater.h5
+# "h5clear --filesize h5clear_fsm_persist_greater.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_greater.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_greater.h5 --filesize "" "" h5clear_greater_before_size.ddl
+TOOLTEST h5clear_fsm_persist_greater.h5 --increment=0 "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_greater.h5 --filesize "" "" h5clear_greater_after_size.ddl
+#
+# (5) h5clear_fsm_persist_less.h5
+# "h5clear --filesize h5clear_fsm_persist_less.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=200 h5clear_fsm_persist_less.h5" (EOA = MAX(EOA, EOF) + 200) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_less.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_less.h5 --filesize "" "" h5clear_less_before_size.ddl
+TOOLTEST h5clear_fsm_persist_less.h5 --increment=200 "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_less.h5 --filesize "" "" h5clear_less_after_size.ddl
+#
+# (6) h5clear_fsm_persist_user_equal.h5
+# "h5clear --filesize h5clear_fsm_persist_user_equal.h5" (print EOA/EOF before the next action)
+# "h5clear --increment h5clear_fsm_persist_user_equal.h5" (EOA = MAX(EOA, EOF) + 1M) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_equal.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_user_equal.h5 --filesize "" "" h5clear_user_equal_before_size.ddl
+TOOLTEST h5clear_fsm_persist_user_equal.h5 --increment "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_user_equal.h5 --filesize "" "" h5clear_user_equal_after_size.ddl
+#
+# (7) h5clear_fsm_persist_user_greater.h5
+# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_user_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_user_greater.h5 --filesize "" "" h5clear_user_greater_before_size.ddl
+TOOLTEST h5clear_fsm_persist_user_greater.h5 --increment=0 "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_user_greater.h5 --filesize "" "" h5clear_user_greater_after_size.ddl
+#
+# (8) h5clear_fsm_persist_user_less.h5
+# "h5clear --filesize h5clear_fsm_persist_user_less.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=200 h5clear_fsm_persist_user_less.h5" (EOA = MAX(EOA, EOF) + 200) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_less.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_user_less.h5 --filesize "" "" h5clear_user_less_before_size.ddl
+TOOLTEST h5clear_fsm_persist_user_less.h5 --increment=200 "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_user_less.h5 --filesize "" "" h5clear_user_less_after_size.ddl
+#
+#
+#
# Clean up test files
if test -z "$HDF5_NOCLEANUP"; then
rm -f h5clear_*.h5 latest_h5clear*.h5
diff --git a/tools/test/misc/vds/CMakeLists.txt b/tools/test/misc/vds/CMakeLists.txt
index 5b34c43..50aade4 100644
--- a/tools/test/misc/vds/CMakeLists.txt
+++ b/tools/test/misc/vds/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_TEST_MISC_VDS)
#-----------------------------------------------------------------------------
diff --git a/tools/test/perform/CMakeLists.txt b/tools/test/perform/CMakeLists.txt
index b7452e0..5104b90 100644
--- a/tools/test/perform/CMakeLists.txt
+++ b/tools/test/perform/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.3.2)
+cmake_minimum_required (VERSION 3.10)
PROJECT (HDF5_TOOLS_TEST_PERFORM )
#-----------------------------------------------------------------------------