diff --git a/cmake/Modules/SetFortranFlags.cmake b/cmake/Modules/SetFortranFlags.cmake index ce7f3149b..0d06920de 100644 --- a/cmake/Modules/SetFortranFlags.cmake +++ b/cmake/Modules/SetFortranFlags.cmake @@ -75,6 +75,12 @@ SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" Fortran "-fno-underscoring" # GNU ) +# Compile code assuming that IEEE signaling NaNs may generate user-visible traps during floating-point operations. +# Setting this option disables optimizations that may change the number of exceptions visible with signaling NaNs. +SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" + Fortran "-fsignaling-nans " # GNU + ) + # Determines whether the current Fortran Standard behavior of the compiler is fully implemented. SET_COMPILE_FLAG(CMAKE_Fortran_Flags "${CMAKE_Fortran_FLAGS}" @@ -208,6 +214,7 @@ SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" Fortran "-init=snan,arrays" # Intel "/Qinit:snan,arrays" # Intel Windows + "-finit-real=snan" # GNU ) # Does not generate an interface block for each routine in a source file @@ -342,6 +349,11 @@ SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" SET_COMPILE_FLAG(STRICTMATH_FLAGS "${STRICTMATH_FLAGS}" Fortran "-fp-model=precise" # Intel "/fp:precise" # Intel Windows + "-fno-unsafe-math-optimizations" # GNU + ) +# Disable transformations and optimizations that assume default floating-point rounding behavior. +SET_COMPILE_FLAG(STRICTMATH_FLAGS "${STRICTMATH_FLAGS}" + Fortran "-frounding-math" ) SET_COMPILE_FLAG(STRICTMATH_FLAGS "${STRICTMATH_FLAGS}" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ef23fadc8..e241d3360 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,6 +14,8 @@ # Add the source files SET(STRICT_MATH_FILES ${SRC}/collision/collision_generate.f90 + ${SRC}/collision/collision_io.f90 + ${SRC}/collision/collision_util.f90 ${SRC}/fraggle/fraggle_generate.f90 ${SRC}/fraggle/fraggle_util.f90 ${SRC}/fraggle/fraggle_module.f90 @@ -31,6 +33,7 @@ SET(STRICT_MATH_FILES ${SRC}/rmvs/rmvs_step.f90 ${SRC}/swiftest/swiftest_drift.f90 ${SRC}/swiftest/swiftest_gr.f90 + ${SRC}/swiftest/swiftest_io.f90 ${SRC}/swiftest/swiftest_kick.f90 ${SRC}/swiftest/swiftest_user.f90 ${SRC}/swiftest/swiftest_obl.f90 @@ -60,10 +63,8 @@ SET(FAST_MATH_FILES ${SRC}/helio/helio_module.f90 ${SRC}/symba/symba_module.f90 ${SRC}/collision/collision_check.f90 - ${SRC}/collision/collision_io.f90 ${SRC}/collision/collision_regime.f90 ${SRC}/collision/collision_resolve.f90 - ${SRC}/collision/collision_util.f90 ${SRC}/encounter/encounter_check.f90 ${SRC}/encounter/encounter_io.f90 ${SRC}/encounter/encounter_util.f90 @@ -73,7 +74,6 @@ SET(FAST_MATH_FILES ${SRC}/rmvs/rmvs_encounter_check.f90 ${SRC}/rmvs/rmvs_util.f90 ${SRC}/swiftest/swiftest_discard.f90 - ${SRC}/swiftest/swiftest_io.f90 ${SRC}/swiftest/swiftest_util.f90 ${SRC}/symba/symba_discard.f90 ${SRC}/symba/symba_encounter_check.f90 diff --git a/src/swiftest/swiftest_io.f90 b/src/swiftest/swiftest_io.f90 index c3061858b..921ea8308 100644 --- a/src/swiftest/swiftest_io.f90 +++ b/src/swiftest/swiftest_io.f90 @@ -1067,7 +1067,7 @@ module subroutine swiftest_io_netcdf_get_valid_masks(self, plmask, tpmask) if (status == NF90_NOERR) then allocate(body_status(idmax)) call netcdf_io_check( nf90_get_var(self%id, self%status_varid, body_status, start=[1, tslot], count=[idmax,1]), "swiftest_io_netcdf_get_valid_masks nf90_getvar status_varid" ) - lvalid(:) = body_status /= INACTIVE + lvalid(:) = body_status(:) /= INACTIVE else status = nf90_inq_varid(self%id, self%rh_varname, self%rh_varid) if (status == NF90_NOERR) then