Somewhat confusingly, setting AMReX_FPE=ON in the CMake options turns on compiler-specific flags that are not always equivalent to setting the amrex.fpe_trap_* ParmParse parameters.
I think it would be more consistent to have AMReX_FPE change the defaults for the runtime parameters, so that the behavior is exactly consistent. Otherwise, the documentation (https://amrex-codes.github.io/amrex/docs_html/Debugging.html) should be changed to make it very clear that these two options are not equivalent.
Somewhat confusingly, setting
AMReX_FPE=ON
in the CMake options turns on compiler-specific flags that are not always equivalent to setting theamrex.fpe_trap_*
ParmParse parameters.For instance, when using gcc,
AMReX_FPE=ON
adds-ftrapv
to the compile flags, which appears to only detect signed integer overflow (and also is broken in several gcc releases: https://blog.robertelder.org/gcc-signed-overflow-trapping-ftrapv-doesnt-work/)https://github.com/AMReX-Codes/amrex/blob/39f46ae30a4997003e6f49a4ca08a8708f8dc5de/Tools/CMake/AMReXFlagsTargets.cmake#L137
Whereas the runtime options change the FPU state explicitly for specified FPU exceptions: https://github.com/AMReX-Codes/amrex/blob/39f46ae30a4997003e6f49a4ca08a8708f8dc5de/Src/Base/AMReX.cpp#L563
I think it would be more consistent to have AMReX_FPE change the defaults for the runtime parameters, so that the behavior is exactly consistent. Otherwise, the documentation (https://amrex-codes.github.io/amrex/docs_html/Debugging.html) should be changed to make it very clear that these two options are not equivalent.