From 0ba705cae71c5944325733709f644943290216c5 Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Wed, 11 Oct 2023 11:16:59 -0500 Subject: [PATCH] fixes stopping on exceptions when using nagfor --- config/cmake/HDFFortranCompilerFlags.cmake | 4 ++++ config/linux-gnulibc1 | 2 +- fortran/examples/CMakeLists.txt | 15 ++++++++++++--- hl/fortran/examples/CMakeLists.txt | 1 + release_docs/RELEASE.txt | 6 ++++++ 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake index 425b6aa109e..ffffe6c2456 100644 --- a/config/cmake/HDFFortranCompilerFlags.cmake +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -55,6 +55,10 @@ if (CMAKE_Fortran_COMPILER_ID STREQUAL "NAG") message (STATUS "... Select IEEE floating-point mode full") list (APPEND HDF5_CMAKE_Fortran_FLAGS "-ieee=full") endif () +if (CMAKE_Fortran_COMPILER_ID STREQUAL "NAG") + message (STATUS "... Select IEEE floating-point mode full") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "-ieee=full") +endif () if (NOT MSVC AND NOT MINGW) # General flags diff --git a/config/linux-gnulibc1 b/config/linux-gnulibc1 index 95d7d644fcc..1b1999382f5 100644 --- a/config/linux-gnulibc1 +++ b/config/linux-gnulibc1 @@ -163,7 +163,7 @@ case $FC_BASENAME in # NOTE: The default is -ieee=stop, which will cause problems # when the H5T module performs floating-point type # introspection - H5_FCFLAGS="$H5_FCFLAGS -ieee=full" + AM_FCFLAGS="$AM_FCFLAGS -ieee=full" FSEARCH_DIRS="" # Production diff --git a/fortran/examples/CMakeLists.txt b/fortran/examples/CMakeLists.txt index 3a16c23a0c1..6cbe8d6daac 100644 --- a/fortran/examples/CMakeLists.txt +++ b/fortran/examples/CMakeLists.txt @@ -35,7 +35,10 @@ set (F2003_examples foreach (example ${examples}) add_executable (f90_ex_${example} ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90) - target_compile_options(f90_ex_${example} PRIVATE $<$:${WIN_COMPILE_FLAGS}>) + target_compile_options(f90_ex_${example} + PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" + $<$:${WIN_COMPILE_FLAGS}>) # set_property(TARGET f90_ex_${example} APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) # set_property(TARGET f90_ex_${example} APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) @@ -76,7 +79,10 @@ endforeach () foreach (example ${F2003_examples}) add_executable (f03_ex_${example} ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90) - target_compile_options(f03_ex_${example} PRIVATE $<$:${WIN_COMPILE_FLAGS}>) + target_compile_options(f03_ex_${example} + PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" + $<$:${WIN_COMPILE_FLAGS}>) # set_property(TARGET f03_ex_${example} APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) # set_property(TARGET f03_ex_${example} APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) @@ -117,7 +123,10 @@ endforeach () if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) add_executable (f90_ex_ph5example ${HDF5_F90_EXAMPLES_SOURCE_DIR}/ph5example.f90) - target_compile_options(f90_ex_ph5example PRIVATE $<$:${WIN_COMPILE_FLAGS}>) + target_compile_options(f90_ex_ph5example + PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" + $<$:${WIN_COMPILE_FLAGS}>) # set_property(TARGET f90_ex_ph5example APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) # set_property(TARGET f90_ex_ph5example APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) diff --git a/hl/fortran/examples/CMakeLists.txt b/hl/fortran/examples/CMakeLists.txt index 293bc2b096f..caa5e78ec02 100644 --- a/hl/fortran/examples/CMakeLists.txt +++ b/hl/fortran/examples/CMakeLists.txt @@ -10,6 +10,7 @@ foreach (example ${examples}) add_executable (hl_f90_ex_${example} ${HDF5_HL_F90_EXAMPLES_SOURCE_DIR}/${example}.f90) target_compile_options(hl_f90_ex_${example} PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" $<$:${WIN_COMPILE_FLAGS}> ) # set_property(TARGET hl_f90_ex_${example} APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 8bb32fb1078..bcc91df70d2 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -1002,6 +1002,12 @@ Platforms Tested Known Problems ============== + IEEE standard arithmetic enables software to raise exceptions such as overflow, + division by zero, and other illegal operations without interrupting or halting + the program flow. The HDF5 C library intentionally performs these exceptions. + Therefore, the "-ieee=full" nagfor switch is necessary when compiling a program + to avoid stopping on an exception. + CMake files do not behave correctly with paths containing spaces. Do not use spaces in paths because the required escaping for handling spaces results in very complex and fragile build files.