From 14469c023b4c254811e01c20a53c5866d7781ee8 Mon Sep 17 00:00:00 2001 From: Ben Wibking Date: Wed, 10 Jul 2024 19:34:02 -0400 Subject: [PATCH] enable FPE traps in CI (#611) ### Description Enables signal handling and floating-point exception (FPE) traps for NANs when running the test suite, so it will stop and report an error when NANs are encountered. (This only works on CPUs.) In order for this to work, we change the signal handling settings back to AMReX defaults. We also have to suppress FPEs when importing `numpy` (see https://github.com/numpy/numpy/issues/20504). By default, many compilers perform optimizations that assume that floating-point exceptions are disabled, and will often produce spurious FPEs for vectorized code (however, this does not affect the results in any way). There are compiler-specific options to disable this behavior for Intel and Clang. Note that `AMReX_FPE=ON` only sets the compiler option `-ftrapv` (or similar). We instead add the runtime options `amrex.fpe_trap_invalid=1`, `amrex.fpe_trap_zero=1`, and `amrex.fpe_trap_overflow=1` to the command-line arguments for each test. These options can also be added to the input file (or command line) to debug individual problems. **Depends on:** * https://github.com/quokka-astro/quokka/pull/667 * https://github.com/quokka-astro/quokka/pull/668 * https://github.com/quokka-astro/quokka/pull/671 ### Related issues Partially resolves https://github.com/quokka-astro/quokka/issues/556. ### Checklist _Before this pull request can be reviewed, all of these tasks should be completed. Denote completed tasks with an `x` inside the square brackets `[ ]` in the Markdown source below:_ - [x] I have added a description (see above). - [x] I have added a link to any related issues see (see above). - [x] I have read the [Contributing Guide](https://github.com/quokka-astro/quokka/blob/development/CONTRIBUTING.md). - [ ] I have added tests for any new physics that this PR adds to the code. - [x] I have tested this PR on my local computer and all tests pass. - [x] I have manually triggered the GPU tests with the magic comment `/azp run`. - [x] I have requested a reviewer for this PR. --------- Co-authored-by: Piyush Sharda <34922596+psharda@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/cmake-macos.yml | 1 + .github/workflows/intel.yml | 2 +- CMakeLists.txt | 1 + src/Advection/CMakeLists.txt | 2 +- src/Advection2D/CMakeLists.txt | 2 +- src/AdvectionSemiellipse/CMakeLists.txt | 2 +- src/AdvectionSimulation.hpp | 9 +++---- src/BinaryOrbitCIC/CMakeLists.txt | 2 +- src/CMakeLists.txt | 7 +++++ src/FCQuantities/CMakeLists.txt | 2 +- src/HydroBlast3D/CMakeLists.txt | 2 +- src/HydroContact/CMakeLists.txt | 2 +- src/HydroHighMach/CMakeLists.txt | 2 +- src/HydroLeblanc/CMakeLists.txt | 2 +- src/HydroQuirk/CMakeLists.txt | 2 +- src/HydroSMS/CMakeLists.txt | 2 +- src/HydroShocktube/CMakeLists.txt | 2 +- src/HydroShocktubeCMA/CMakeLists.txt | 2 +- src/HydroShuOsher/CMakeLists.txt | 2 +- src/HydroVacuum/CMakeLists.txt | 2 +- src/HydroWave/CMakeLists.txt | 2 +- src/NSCBC/CMakeLists.txt | 2 +- src/ODEIntegration/CMakeLists.txt | 2 +- src/PassiveScalar/CMakeLists.txt | 2 +- src/PopIII/CMakeLists.txt | 6 ++--- src/PrimordialChem/CMakeLists.txt | 2 +- src/RadForce/CMakeLists.txt | 2 +- src/RadMarshak/CMakeLists.txt | 2 +- src/RadMarshakAsymptotic/CMakeLists.txt | 2 +- src/RadMarshakCGS/CMakeLists.txt | 2 +- src/RadMatterCoupling/CMakeLists.txt | 2 +- src/RadMatterCouplingRSLA/CMakeLists.txt | 2 +- src/RadPulse/CMakeLists.txt | 2 +- src/RadStreaming/CMakeLists.txt | 2 +- src/RadStreamingY/CMakeLists.txt | 2 +- src/RadSuOlson/CMakeLists.txt | 2 +- src/RadSuOlson/test_radiation_SuOlson.cpp | 6 +++++ src/RadTube/CMakeLists.txt | 2 +- src/RadTube/test_radiation_tube.cpp | 1 + src/RadhydroPulse/CMakeLists.txt | 2 +- src/RadhydroPulseDyn/CMakeLists.txt | 2 +- src/RadhydroPulseGrey/CMakeLists.txt | 2 +- src/RadhydroPulseMG/CMakeLists.txt | 2 +- src/RadhydroPulseMGint/CMakeLists.txt | 2 +- src/RadhydroShock/CMakeLists.txt | 2 +- src/RadhydroShockCGS/CMakeLists.txt | 2 +- src/RadhydroShockMultigroup/CMakeLists.txt | 2 +- src/RadhydroSimulation.hpp | 5 +++- src/RadhydroUniformAdvecting/CMakeLists.txt | 2 +- src/SphericalCollapse/CMakeLists.txt | 2 +- src/StarCluster/CMakeLists.txt | 6 ++--- src/main.cpp | 10 ------- src/matplotlibcpp.h | 30 ++++++++++++--------- 53 files changed, 89 insertions(+), 77 deletions(-) diff --git a/.github/workflows/cmake-macos.yml b/.github/workflows/cmake-macos.yml index a9be31917..84ff685a5 100644 --- a/.github/workflows/cmake-macos.yml +++ b/.github/workflows/cmake-macos.yml @@ -54,6 +54,7 @@ jobs: # access regardless of the host operating system shell: bash working-directory: ${{runner.workspace}}/build + env: {CXXFLAGS: "-ffp-exception-behavior=strict"} run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE - name: Build diff --git a/.github/workflows/intel.yml b/.github/workflows/intel.yml index 9303b5891..94971544e 100644 --- a/.github/workflows/intel.yml +++ b/.github/workflows/intel.yml @@ -36,7 +36,7 @@ jobs: ccache-${{ github.workflow }}-${{ github.job }}-git- - name: Build & Install - env: {CXXFLAGS: "-ffp-model=precise -fno-operator-names"} + env: {CXXFLAGS: "-ffp-model=precise -ffp-exception-behavior=strict -fno-operator-names"} run: | export CCACHE_COMPRESS=1 export CCACHE_COMPRESSLEVEL=10 diff --git a/CMakeLists.txt b/CMakeLists.txt index d0b58a3cd..92425756d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,7 @@ option(QUOKKA_PYTHON "Compile with Python support (on/off)" ON) option(DISABLE_FMAD "Disable fused multiply-add instructions on GPU (on/off)" ON) option(ENABLE_ASAN "Enable AddressSanitizer and UndefinedBehaviorSanitizer" OFF) option(ENABLE_HWASAN "Enable HWAddressSanitizer" OFF) +option(ENABLE_TESTS_FPE "Enable floating-point exceptions when running tests" ON) option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF) option(QUOKKA_OPENPMD "Enable OpenPMD output (on/off)" OFF) diff --git a/src/Advection/CMakeLists.txt b/src/Advection/CMakeLists.txt index 6e6552314..5b473f8c8 100644 --- a/src/Advection/CMakeLists.txt +++ b/src/Advection/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_advection) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME ScalarAdvection COMMAND test_advection advection_sawtooth.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME ScalarAdvection COMMAND test_advection advection_sawtooth.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/Advection2D/CMakeLists.txt b/src/Advection2D/CMakeLists.txt index 1e5e1f35c..bec3e75d0 100644 --- a/src/Advection2D/CMakeLists.txt +++ b/src/Advection2D/CMakeLists.txt @@ -4,5 +4,5 @@ if (AMReX_SPACEDIM GREATER_EQUAL 2) setup_target_for_cuda_compilation(test_advection2d) endif() - add_test(NAME Advection2D COMMAND test_advection2d advection2d_amr.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + add_test(NAME Advection2D COMMAND test_advection2d advection2d_amr.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) endif() diff --git a/src/AdvectionSemiellipse/CMakeLists.txt b/src/AdvectionSemiellipse/CMakeLists.txt index b47351d5e..0545fd821 100644 --- a/src/AdvectionSemiellipse/CMakeLists.txt +++ b/src/AdvectionSemiellipse/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_advection_se) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME ScalarAdvectionSemiEllipse COMMAND test_advection_se advection_semiellipse.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME ScalarAdvectionSemiEllipse COMMAND test_advection_se advection_semiellipse.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/AdvectionSimulation.hpp b/src/AdvectionSimulation.hpp index b0ff5583e..5c1e1c1da 100644 --- a/src/AdvectionSimulation.hpp +++ b/src/AdvectionSimulation.hpp @@ -207,14 +207,13 @@ template void AdvectionSimulation::computeAfterE { // compute reference solution const int ncomp = state_new_cc_[0].nComp(); - const int nghost = state_new_cc_[0].nGrow(); - amrex::MultiFab state_ref_level0(boxArray(0), DistributionMap(0), ncomp, nghost); + amrex::MultiFab state_ref_level0(boxArray(0), DistributionMap(0), ncomp, 0); computeReferenceSolution(state_ref_level0, geom[0].CellSizeArray(), geom[0].ProbLoArray(), geom[0].ProbHiArray()); // compute error norm - amrex::MultiFab residual(boxArray(0), DistributionMap(0), ncomp, nghost); - amrex::MultiFab::Copy(residual, state_ref_level0, 0, 0, ncomp, nghost); - amrex::MultiFab::Saxpy(residual, -1., state_new_cc_[0], 0, 0, ncomp, nghost); + amrex::MultiFab residual(boxArray(0), DistributionMap(0), ncomp, 0); + amrex::MultiFab::Copy(residual, state_ref_level0, 0, 0, ncomp, 0); + amrex::MultiFab::Saxpy(residual, -1., state_new_cc_[0], 0, 0, ncomp, 0); amrex::Real sol_norm = 0.; amrex::Real err_norm = 0.; diff --git a/src/BinaryOrbitCIC/CMakeLists.txt b/src/BinaryOrbitCIC/CMakeLists.txt index 166171f73..6518e73ac 100644 --- a/src/BinaryOrbitCIC/CMakeLists.txt +++ b/src/BinaryOrbitCIC/CMakeLists.txt @@ -4,5 +4,5 @@ if (AMReX_SPACEDIM EQUAL 3) setup_target_for_cuda_compilation(binary_orbit) endif() - add_test(NAME BinaryOrbitCIC COMMAND binary_orbit BinaryOrbit.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + add_test(NAME BinaryOrbitCIC COMMAND binary_orbit BinaryOrbit.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 50b7bd34e..e6930ae0b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -86,6 +86,13 @@ else() message(STATUS "Fused multiply-add (FMAD) is *enabled* for device code. Exact direction symmetry will NOT be preserved.") endif(DISABLE_FMAD) +if(ENABLE_TESTS_FPE) + set(QuokkaTestParams "amrex.fpe_trap_invalid=1 amrex.fpe_trap_overflow=1 amrex.fpe_trap_zero=1") +else() + set(QuokkaTestParams "") + message(STATUS "WARNING: Floating-point exceptions are *DISABLED* when running the test suite.") +endif(ENABLE_TESTS_FPE) + # emit error if warnings are produced if(WARNINGS_AS_ERRORS) add_compile_options(-Werror -Wall -Wextra -Wno-unused-parameter -Wno-unknown-pragmas -Wno-strict-aliasing) diff --git a/src/FCQuantities/CMakeLists.txt b/src/FCQuantities/CMakeLists.txt index 723c70cb4..933a05607 100644 --- a/src/FCQuantities/CMakeLists.txt +++ b/src/FCQuantities/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_fc_quantities) endif() -add_test(NAME FCQuantities COMMAND test_fc_quantities fc_hydro_wave.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME FCQuantities COMMAND test_fc_quantities fc_hydro_wave.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/HydroBlast3D/CMakeLists.txt b/src/HydroBlast3D/CMakeLists.txt index 6f8b88173..51b03108f 100644 --- a/src/HydroBlast3D/CMakeLists.txt +++ b/src/HydroBlast3D/CMakeLists.txt @@ -4,5 +4,5 @@ if (AMReX_SPACEDIM EQUAL 3) setup_target_for_cuda_compilation(test_hydro3d_blast) endif() - add_test(NAME HydroBlast3D COMMAND test_hydro3d_blast blast_unigrid_128.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + add_test(NAME HydroBlast3D COMMAND test_hydro3d_blast blast_unigrid_128.in ${QuokkaTestParams} ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) endif() diff --git a/src/HydroContact/CMakeLists.txt b/src/HydroContact/CMakeLists.txt index b4ab180a4..d54ec5a74 100644 --- a/src/HydroContact/CMakeLists.txt +++ b/src/HydroContact/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_hydro_contact) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME HydroContact COMMAND test_hydro_contact contact_wave.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME HydroContact COMMAND test_hydro_contact contact_wave.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/HydroHighMach/CMakeLists.txt b/src/HydroHighMach/CMakeLists.txt index bd55f1dfc..f6b12cf53 100644 --- a/src/HydroHighMach/CMakeLists.txt +++ b/src/HydroHighMach/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_hydro_highmach) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME HydroHighMach COMMAND test_hydro_highmach HighMach.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME HydroHighMach COMMAND test_hydro_highmach HighMach.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/HydroLeblanc/CMakeLists.txt b/src/HydroLeblanc/CMakeLists.txt index ceeb7eec6..b5e14f11d 100644 --- a/src/HydroLeblanc/CMakeLists.txt +++ b/src/HydroLeblanc/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_hydro_leblanc) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME HydroLeblanc COMMAND test_hydro_leblanc leblanc.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME HydroLeblanc COMMAND test_hydro_leblanc leblanc.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/HydroQuirk/CMakeLists.txt b/src/HydroQuirk/CMakeLists.txt index ab63744d1..11dbd75d3 100644 --- a/src/HydroQuirk/CMakeLists.txt +++ b/src/HydroQuirk/CMakeLists.txt @@ -4,5 +4,5 @@ if (AMReX_SPACEDIM GREATER_EQUAL 2) setup_target_for_cuda_compilation(test_quirk) endif() - add_test(NAME HydroQuirk COMMAND test_quirk quirk.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + add_test(NAME HydroQuirk COMMAND test_quirk quirk.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) endif() diff --git a/src/HydroSMS/CMakeLists.txt b/src/HydroSMS/CMakeLists.txt index 727f45f29..9127cbc3d 100644 --- a/src/HydroSMS/CMakeLists.txt +++ b/src/HydroSMS/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_hydro_sms) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME HydroSlowMovingShock COMMAND test_hydro_sms SlowMovingShock.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME HydroSlowMovingShock COMMAND test_hydro_sms SlowMovingShock.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/HydroShocktube/CMakeLists.txt b/src/HydroShocktube/CMakeLists.txt index d2df0c931..f90ff28b4 100644 --- a/src/HydroShocktube/CMakeLists.txt +++ b/src/HydroShocktube/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_hydro_shocktube) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME HydroShocktube COMMAND test_hydro_shocktube shocktube.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME HydroShocktube COMMAND test_hydro_shocktube shocktube.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/HydroShocktubeCMA/CMakeLists.txt b/src/HydroShocktubeCMA/CMakeLists.txt index 8dc0fd18f..4208b2294 100644 --- a/src/HydroShocktubeCMA/CMakeLists.txt +++ b/src/HydroShocktubeCMA/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_hydro_shocktube_cma) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME HydroShocktubeCMA COMMAND test_hydro_shocktube_cma shocktube_cma.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME HydroShocktubeCMA COMMAND test_hydro_shocktube_cma shocktube_cma.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/HydroShuOsher/CMakeLists.txt b/src/HydroShuOsher/CMakeLists.txt index f71e7ea69..c72567641 100644 --- a/src/HydroShuOsher/CMakeLists.txt +++ b/src/HydroShuOsher/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_hydro_shuosher) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME ShuOsher COMMAND test_hydro_shuosher ShuOsher.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME ShuOsher COMMAND test_hydro_shuosher ShuOsher.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/HydroVacuum/CMakeLists.txt b/src/HydroVacuum/CMakeLists.txt index 80cf953b4..1a8e2b7d4 100644 --- a/src/HydroVacuum/CMakeLists.txt +++ b/src/HydroVacuum/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_hydro_vacuum) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME HydroVacuum COMMAND test_hydro_vacuum vacuum.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME HydroVacuum COMMAND test_hydro_vacuum vacuum.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/HydroWave/CMakeLists.txt b/src/HydroWave/CMakeLists.txt index f82ddaf55..6a4fc65d9 100644 --- a/src/HydroWave/CMakeLists.txt +++ b/src/HydroWave/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_hydro_wave) endif() -add_test(NAME HydroWave COMMAND test_hydro_wave hydro_wave.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME HydroWave COMMAND test_hydro_wave hydro_wave.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/NSCBC/CMakeLists.txt b/src/NSCBC/CMakeLists.txt index d77f52f21..a3cc99eb3 100644 --- a/src/NSCBC/CMakeLists.txt +++ b/src/NSCBC/CMakeLists.txt @@ -4,7 +4,7 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_channel_flow) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME ChannelFlow COMMAND test_channel_flow NSCBC_Channel.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME ChannelFlow COMMAND test_channel_flow NSCBC_Channel.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) if (AMReX_SPACEDIM GREATER_EQUAL 2) add_executable(test_vortex vortex.cpp ${QuokkaObjSources}) diff --git a/src/ODEIntegration/CMakeLists.txt b/src/ODEIntegration/CMakeLists.txt index f597ec1dc..152ecea8e 100644 --- a/src/ODEIntegration/CMakeLists.txt +++ b/src/ODEIntegration/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_ode) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME ODEIntegration COMMAND test_ode ODE.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME ODEIntegration COMMAND test_ode ODE.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/PassiveScalar/CMakeLists.txt b/src/PassiveScalar/CMakeLists.txt index e7759df84..9cde91912 100644 --- a/src/PassiveScalar/CMakeLists.txt +++ b/src/PassiveScalar/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_scalars) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME PassiveScalar COMMAND test_scalars PassiveScalar.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME PassiveScalar COMMAND test_scalars PassiveScalar.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/PopIII/CMakeLists.txt b/src/PopIII/CMakeLists.txt index 0a5a1dc9d..a98f2a1e3 100644 --- a/src/PopIII/CMakeLists.txt +++ b/src/PopIII/CMakeLists.txt @@ -68,11 +68,11 @@ if (AMReX_SPACEDIM EQUAL 3) endif() - add_test(NAME ComputePerturbations COMMAND python3 ${CMAKE_SOURCE_DIR}/src/perturbation.py --kmin=2 --kmax=${result} --size=${first_digits} --alpha=1.8 --f_solenoidal=0.66667 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) - add_test(NAME PopIII COMMAND popiii PopIII.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + add_test(NAME ComputePerturbations COMMAND python3 ${CMAKE_SOURCE_DIR}/src/perturbation.py --kmin=2 --kmax=${result} --size=${first_digits} --alpha=1.8 --f_solenoidal=0.66667 ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + add_test(NAME PopIII COMMAND popiii PopIII.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) set_tests_properties(ComputePerturbations PROPERTIES FIXTURES_SETUP PopIII_fixture) set_tests_properties(PopIII PROPERTIES FIXTURES_REQUIRED PopIII_fixture) # AMR test only works on Setonix because Gadi and avatar do not have enough memory per GPU - # add_test(NAME PopIIIAMR COMMAND popiii popiii_AMR.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + # add_test(NAME PopIIIAMR COMMAND popiii popiii_AMR.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) endif() diff --git a/src/PrimordialChem/CMakeLists.txt b/src/PrimordialChem/CMakeLists.txt index bf577daca..e1a69f7e2 100644 --- a/src/PrimordialChem/CMakeLists.txt +++ b/src/PrimordialChem/CMakeLists.txt @@ -14,4 +14,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_primordial_chem) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME PrimordialChem COMMAND test_primordial_chem primordial_chem.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME PrimordialChem COMMAND test_primordial_chem primordial_chem.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/RadForce/CMakeLists.txt b/src/RadForce/CMakeLists.txt index 751dc9389..e3e832668 100644 --- a/src/RadForce/CMakeLists.txt +++ b/src/RadForce/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_radiation_force) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME RadForce COMMAND test_radiation_force RadForce.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME RadForce COMMAND test_radiation_force RadForce.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/RadMarshak/CMakeLists.txt b/src/RadMarshak/CMakeLists.txt index 7db8e9084..3c8d33030 100644 --- a/src/RadMarshak/CMakeLists.txt +++ b/src/RadMarshak/CMakeLists.txt @@ -5,4 +5,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_radiation_marshak) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME MarshakWave COMMAND test_radiation_marshak Marshak.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME MarshakWave COMMAND test_radiation_marshak Marshak.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/RadMarshakAsymptotic/CMakeLists.txt b/src/RadMarshakAsymptotic/CMakeLists.txt index 507b2b4ff..204e8d2a8 100644 --- a/src/RadMarshakAsymptotic/CMakeLists.txt +++ b/src/RadMarshakAsymptotic/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_radiation_marshak_asymptotic) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME MarshakWaveAsymptoticDiffusion COMMAND test_radiation_marshak_asymptotic MarshakAsymptotic.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME MarshakWaveAsymptoticDiffusion COMMAND test_radiation_marshak_asymptotic MarshakAsymptotic.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/RadMarshakCGS/CMakeLists.txt b/src/RadMarshakCGS/CMakeLists.txt index f42e782bd..8ad808956 100644 --- a/src/RadMarshakCGS/CMakeLists.txt +++ b/src/RadMarshakCGS/CMakeLists.txt @@ -5,4 +5,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_radiation_marshak_cgs) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME MarshakWaveCGS COMMAND test_radiation_marshak_cgs MarshakCGS.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME MarshakWaveCGS COMMAND test_radiation_marshak_cgs MarshakCGS.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/RadMatterCoupling/CMakeLists.txt b/src/RadMatterCoupling/CMakeLists.txt index 1f36fb53c..4ca008232 100644 --- a/src/RadMatterCoupling/CMakeLists.txt +++ b/src/RadMatterCoupling/CMakeLists.txt @@ -5,4 +5,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_radiation_matter_coupling) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME MatterEnergyExchange COMMAND test_radiation_matter_coupling energyexchange.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME MatterEnergyExchange COMMAND test_radiation_matter_coupling energyexchange.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/RadMatterCouplingRSLA/CMakeLists.txt b/src/RadMatterCouplingRSLA/CMakeLists.txt index 13dc7880c..86a3dc8e6 100644 --- a/src/RadMatterCouplingRSLA/CMakeLists.txt +++ b/src/RadMatterCouplingRSLA/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_radiation_matter_coupling_rsla) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME MatterEnergyExchangeRSLA COMMAND test_radiation_matter_coupling_rsla MatterEnergyExchangeRSLA.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME MatterEnergyExchangeRSLA COMMAND test_radiation_matter_coupling_rsla MatterEnergyExchangeRSLA.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/RadPulse/CMakeLists.txt b/src/RadPulse/CMakeLists.txt index 00a127eb5..0115e12ce 100644 --- a/src/RadPulse/CMakeLists.txt +++ b/src/RadPulse/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_radiation_pulse) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME RadiationPulse COMMAND test_radiation_pulse RadPulse.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME RadiationPulse COMMAND test_radiation_pulse RadPulse.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/RadStreaming/CMakeLists.txt b/src/RadStreaming/CMakeLists.txt index 18460b38e..9914b8353 100644 --- a/src/RadStreaming/CMakeLists.txt +++ b/src/RadStreaming/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_radiation_streaming) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME RadiationStreaming COMMAND test_radiation_streaming RadStreaming.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME RadiationStreaming COMMAND test_radiation_streaming RadStreaming.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/RadStreamingY/CMakeLists.txt b/src/RadStreamingY/CMakeLists.txt index 2ddc62d1e..67a0ec25a 100644 --- a/src/RadStreamingY/CMakeLists.txt +++ b/src/RadStreamingY/CMakeLists.txt @@ -5,5 +5,5 @@ if (AMReX_SPACEDIM GREATER_EQUAL 2) setup_target_for_cuda_compilation(test_radiation_streaming_y) endif(AMReX_GPU_BACKEND MATCHES "CUDA") - add_test(NAME RadiationStreamingY COMMAND test_radiation_streaming_y RadStreamingY.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + add_test(NAME RadiationStreamingY COMMAND test_radiation_streaming_y RadStreamingY.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) endif() diff --git a/src/RadSuOlson/CMakeLists.txt b/src/RadSuOlson/CMakeLists.txt index 539d0f803..7762132be 100644 --- a/src/RadSuOlson/CMakeLists.txt +++ b/src/RadSuOlson/CMakeLists.txt @@ -5,4 +5,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_radiation_SuOlson) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME SuOlsonTest COMMAND test_radiation_SuOlson SuOlson.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME SuOlsonTest COMMAND test_radiation_SuOlson SuOlson.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/RadSuOlson/test_radiation_SuOlson.cpp b/src/RadSuOlson/test_radiation_SuOlson.cpp index aa3f95792..8fec6c527 100644 --- a/src/RadSuOlson/test_radiation_SuOlson.cpp +++ b/src/RadSuOlson/test_radiation_SuOlson.cpp @@ -52,6 +52,12 @@ template <> struct RadSystem_Traits { static constexpr int beta_order = 0; }; +template <> struct quokka::EOS_Traits { + static constexpr double mean_molecular_weight = 1.0; + static constexpr double boltzmann_constant = 1.0; + static constexpr double gamma = 5. / 3.; +}; + template <> struct Physics_Traits { // cell-centred static constexpr bool is_hydro_enabled = false; diff --git a/src/RadTube/CMakeLists.txt b/src/RadTube/CMakeLists.txt index 67360d7d2..7d52f6e7b 100644 --- a/src/RadTube/CMakeLists.txt +++ b/src/RadTube/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_radiation_tube) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME RadiationPressureTube COMMAND test_radiation_tube RadTube.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME RadiationPressureTube COMMAND test_radiation_tube RadTube.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/RadTube/test_radiation_tube.cpp b/src/RadTube/test_radiation_tube.cpp index 847d63263..229438ad5 100644 --- a/src/RadTube/test_radiation_tube.cpp +++ b/src/RadTube/test_radiation_tube.cpp @@ -158,6 +158,7 @@ template <> void RadhydroSimulation::setInitialConditionsOnGrid(quo amrex::Real const Pgas = interpolate_value(x, x_ptr, Pgas_ptr, x_size); amrex::Real const Erad = interpolate_value(x, x_ptr, Erad_ptr, x_size); amrex::Real const Tgas = Pgas / C::k_B * mu / rho; + AMREX_ASSERT(!std::isnan(rho)); // calculate radEnergyFractions based on the boundary conditions auto radEnergyFractions = RadSystem::ComputePlanckEnergyFractions(radBoundaries_g, Tgas); diff --git a/src/RadhydroPulse/CMakeLists.txt b/src/RadhydroPulse/CMakeLists.txt index 0cc17b65f..829448ba8 100644 --- a/src/RadhydroPulse/CMakeLists.txt +++ b/src/RadhydroPulse/CMakeLists.txt @@ -5,5 +5,5 @@ if (AMReX_SPACEDIM EQUAL 1) setup_target_for_cuda_compilation(test_radhydro_pulse) endif(AMReX_GPU_BACKEND MATCHES "CUDA") - add_test(NAME RadhydroPulse COMMAND test_radhydro_pulse RadhydroPulse.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + add_test(NAME RadhydroPulse COMMAND test_radhydro_pulse RadhydroPulse.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) endif() diff --git a/src/RadhydroPulseDyn/CMakeLists.txt b/src/RadhydroPulseDyn/CMakeLists.txt index 20f5bd11c..f2183e1a3 100644 --- a/src/RadhydroPulseDyn/CMakeLists.txt +++ b/src/RadhydroPulseDyn/CMakeLists.txt @@ -5,5 +5,5 @@ if (AMReX_SPACEDIM EQUAL 1) setup_target_for_cuda_compilation(test_radhydro_pulse_dyn) endif(AMReX_GPU_BACKEND MATCHES "CUDA") - add_test(NAME RadhydroPulseDyn COMMAND test_radhydro_pulse_dyn RadhydroPulseDyn.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + add_test(NAME RadhydroPulseDyn COMMAND test_radhydro_pulse_dyn RadhydroPulseDyn.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) endif() diff --git a/src/RadhydroPulseGrey/CMakeLists.txt b/src/RadhydroPulseGrey/CMakeLists.txt index 7733a1d36..9d13b017c 100644 --- a/src/RadhydroPulseGrey/CMakeLists.txt +++ b/src/RadhydroPulseGrey/CMakeLists.txt @@ -5,5 +5,5 @@ if (AMReX_SPACEDIM EQUAL 1) setup_target_for_cuda_compilation(test_radhydro_pulse_grey) endif(AMReX_GPU_BACKEND MATCHES "CUDA") - add_test(NAME RadhydroPulseGrey COMMAND test_radhydro_pulse_grey RadhydroPulseGrey.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + add_test(NAME RadhydroPulseGrey COMMAND test_radhydro_pulse_grey RadhydroPulseGrey.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) endif() diff --git a/src/RadhydroPulseMG/CMakeLists.txt b/src/RadhydroPulseMG/CMakeLists.txt index e11f4b6c5..3b9994821 100644 --- a/src/RadhydroPulseMG/CMakeLists.txt +++ b/src/RadhydroPulseMG/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_radhydro_pulse_MG) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME RadhydroPulseMG COMMAND test_radhydro_pulse_MG RadhydroPulse.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME RadhydroPulseMG COMMAND test_radhydro_pulse_MG RadhydroPulse.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/RadhydroPulseMGint/CMakeLists.txt b/src/RadhydroPulseMGint/CMakeLists.txt index d88db2ae9..4a1bcf004 100644 --- a/src/RadhydroPulseMGint/CMakeLists.txt +++ b/src/RadhydroPulseMGint/CMakeLists.txt @@ -10,4 +10,4 @@ endif(AMReX_GPU_BACKEND MATCHES "CUDA") # mkdir -p WORK_PATH # file(MAKE_DIRECTORY ${WORK_PATH}) -add_test(NAME RadhydroPulseMGint COMMAND test_radhydro_pulse_MG_int RadhydroPulse.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME RadhydroPulseMGint COMMAND test_radhydro_pulse_MG_int RadhydroPulse.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/RadhydroShock/CMakeLists.txt b/src/RadhydroShock/CMakeLists.txt index 5862d34a7..279fb6edb 100644 --- a/src/RadhydroShock/CMakeLists.txt +++ b/src/RadhydroShock/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_radhydro_shock) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME RadhydroShock COMMAND test_radhydro_shock radshock_dimensionless.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME RadhydroShock COMMAND test_radhydro_shock radshock_dimensionless.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/RadhydroShockCGS/CMakeLists.txt b/src/RadhydroShockCGS/CMakeLists.txt index 40ac5ae71..70c5b0138 100644 --- a/src/RadhydroShockCGS/CMakeLists.txt +++ b/src/RadhydroShockCGS/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_radhydro_shock_cgs) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME RadhydroShockCGS COMMAND test_radhydro_shock_cgs radshock.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME RadhydroShockCGS COMMAND test_radhydro_shock_cgs radshock.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/RadhydroShockMultigroup/CMakeLists.txt b/src/RadhydroShockMultigroup/CMakeLists.txt index 8c379acce..0e160e1e4 100644 --- a/src/RadhydroShockMultigroup/CMakeLists.txt +++ b/src/RadhydroShockMultigroup/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_radhydro_shock_multigroup) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME RadhydroShockMultigroup COMMAND test_radhydro_shock_multigroup radshockMG.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME RadhydroShockMultigroup COMMAND test_radhydro_shock_multigroup radshockMG.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/RadhydroSimulation.hpp b/src/RadhydroSimulation.hpp index ef78e7aa2..191e854be 100644 --- a/src/RadhydroSimulation.hpp +++ b/src/RadhydroSimulation.hpp @@ -601,7 +601,10 @@ template void RadhydroSimulation::computeAfterEv } amrex::Real const abs_err = (Etot - Etot0); - amrex::Real const rel_err = abs_err / Etot0; + amrex::Real rel_err = NAN; + if (Etot0 != 0) { + rel_err = abs_err / Etot0; + } amrex::Print() << "\nInitial gas+radiation energy = " << Etot0 << '\n'; amrex::Print() << "Final gas+radiation energy = " << Etot << '\n'; diff --git a/src/RadhydroUniformAdvecting/CMakeLists.txt b/src/RadhydroUniformAdvecting/CMakeLists.txt index 8ee64e60a..2a95b93ff 100644 --- a/src/RadhydroUniformAdvecting/CMakeLists.txt +++ b/src/RadhydroUniformAdvecting/CMakeLists.txt @@ -4,4 +4,4 @@ if(AMReX_GPU_BACKEND MATCHES "CUDA") setup_target_for_cuda_compilation(test_radhydro_uniform_advecting) endif(AMReX_GPU_BACKEND MATCHES "CUDA") -add_test(NAME RadhydroUniformAdvecting COMMAND test_radhydro_uniform_advecting RadhydroUniformAdvecting.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) +add_test(NAME RadhydroUniformAdvecting COMMAND test_radhydro_uniform_advecting RadhydroUniformAdvecting.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) diff --git a/src/SphericalCollapse/CMakeLists.txt b/src/SphericalCollapse/CMakeLists.txt index 660ce1e5b..cf926fbdf 100644 --- a/src/SphericalCollapse/CMakeLists.txt +++ b/src/SphericalCollapse/CMakeLists.txt @@ -4,5 +4,5 @@ if (AMReX_SPACEDIM EQUAL 3) setup_target_for_cuda_compilation(spherical_collapse) endif() - add_test(NAME SphericalCollapse COMMAND spherical_collapse SphericalCollapse.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + add_test(NAME SphericalCollapse COMMAND spherical_collapse SphericalCollapse.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) endif() diff --git a/src/StarCluster/CMakeLists.txt b/src/StarCluster/CMakeLists.txt index 796f1f1c8..e117cf9a4 100644 --- a/src/StarCluster/CMakeLists.txt +++ b/src/StarCluster/CMakeLists.txt @@ -12,11 +12,11 @@ if (AMReX_SPACEDIM EQUAL 3) OUTPUT_QUIET ) - add_test(NAME ComputeStarClusterPerturbations COMMAND python3 ${CMAKE_SOURCE_DIR}/src/perturbation.py --kmin=2 --kmax=64 --size=128 --alpha=2 --f_solenoidal=1.0 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) - add_test(NAME StarCluster COMMAND star_cluster StarCluster.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + add_test(NAME ComputeStarClusterPerturbations COMMAND python3 ${CMAKE_SOURCE_DIR}/src/perturbation.py --kmin=2 --kmax=64 --size=128 --alpha=2 --f_solenoidal=1.0 ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + add_test(NAME StarCluster COMMAND star_cluster StarCluster.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) set_tests_properties(ComputeStarClusterPerturbations PROPERTIES FIXTURES_SETUP StarCluster_fixture) set_tests_properties(StarCluster PROPERTIES FIXTURES_REQUIRED StarCluster_fixture) # AMR test only works on Setonix because Gadi and avatar do not have enough memory per GPU - # add_test(NAME StarClusterAMR COMMAND star_cluster StarCluster_AMR.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + # add_test(NAME StarClusterAMR COMMAND star_cluster StarCluster_AMR.in ${QuokkaTestParams} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) endif() diff --git a/src/main.cpp b/src/main.cpp index a54e2c905..21b3be6bd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,16 +21,6 @@ auto main(int argc, char **argv) -> int amrex::Initialize(argc, argv, true, MPI_COMM_WORLD, []() { amrex::ParmParse pp("amrex"); - // Set the defaults so that we throw an exception instead of attempting - // to generate backtrace files. However, if the user has explicitly set - // these options in their input files respect those settings. - if (!pp.contains("throw_exception")) { - pp.add("throw_exception", 1); - } - if (!pp.contains("signal_handling")) { - pp.add("signal_handling", 0); - } - // Set GPU memory handling defaults: // since performance is terrible if we have to swap pages between device and // host memory due to exceeding the size of device memory, we crash the code diff --git a/src/matplotlibcpp.h b/src/matplotlibcpp.h index fd70a3791..d792feaf4 100644 --- a/src/matplotlibcpp.h +++ b/src/matplotlibcpp.h @@ -2,6 +2,7 @@ #include #include +#include #include // requires c++11 support #include #include @@ -119,27 +120,19 @@ struct _interpreter { private: #ifndef WITHOUT_NUMPY -#if PY_MAJOR_VERSION >= 3 - void *import_numpy() { - import_array(); // initialize C-API - return NULL; - } + fenv_t orig_feenv; + feholdexcept(&orig_feenv); // disable FPE for importing numpy + import_array(); // initialize C-API + fesetenv(&orig_feenv); // restore FPE -#else - - void import_numpy() - { - import_array(); // initialize C-API + return NULL; } - -#endif #endif _interpreter() { - // optional but recommended #if PY_MAJOR_VERSION >= 3 wchar_t name[] = L"plotting"; @@ -1682,7 +1675,13 @@ inline void save(const std::string &filename) PyObject *args = PyTuple_New(1); PyTuple_SetItem(args, 0, pyfilename); + fenv_t orig_feenv; + feholdexcept(&orig_feenv); // disable FPE + PyObject *res = PyObject_CallObject(detail::_interpreter::get().s_python_function_save, args); + + fesetenv(&orig_feenv); // restore FPE + if (!res) throw std::runtime_error("Call to save() failed."); @@ -1746,8 +1745,13 @@ inline std::vector> ginput(const int numClicks = 1, const // Actually, is there any reason not to call this automatically for every plot? inline void tight_layout() { + fenv_t orig_feenv; + feholdexcept(&orig_feenv); // disable FPE + PyObject *res = PyObject_CallObject(detail::_interpreter::get().s_python_function_tight_layout, detail::_interpreter::get().s_python_empty_tuple); + fesetenv(&orig_feenv); // restore FPE + if (!res) throw std::runtime_error("Call to tight_layout() failed.");