From 20f4c08f2e9b241c42be123de3e13d5edb81cb6c Mon Sep 17 00:00:00 2001 From: Alexander Sinn <64009254+AlexanderSinn@users.noreply.github.com> Date: Mon, 23 Sep 2024 19:58:48 +0200 Subject: [PATCH 1/2] Fix amrex::Finalize --- src/ImpactX.cpp | 3 --- src/main.cpp | 5 +++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ImpactX.cpp b/src/ImpactX.cpp index 7466356af..f164ae961 100644 --- a/src/ImpactX.cpp +++ b/src/ImpactX.cpp @@ -54,9 +54,6 @@ namespace impactx { // this one last amr_data.reset(); - if (amrex::Initialized()) - amrex::Finalize(); - // only finalize once m_grids_initialized = false; } diff --git a/src/main.cpp b/src/main.cpp index 4d6aeb315..6fa77c0cf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,8 +28,8 @@ int main(int argc, char* argv[]) // it here so users can pass command line arguments impactx::initialization::default_init_AMReX(argc, argv); - BL_PROFILE_VAR("main()", pmain); { + BL_PROFILE("main()"); impactx::ImpactX impactX; impactX.init_grids(); impactX.initBeamDistributionFromInputs(); @@ -37,7 +37,8 @@ int main(int argc, char* argv[]) impactX.evolve(); impactX.finalize(); } - BL_PROFILE_VAR_STOP(pmain); + + amrex::Finalize(); #if defined(AMREX_USE_MPI) AMREX_ALWAYS_ASSERT(MPI_SUCCESS == MPI_Finalize()); From 8d73e05a25da0c884951cc752e8ec22dba861532 Mon Sep 17 00:00:00 2001 From: Alexander Sinn <64009254+AlexanderSinn@users.noreply.github.com> Date: Mon, 23 Sep 2024 22:43:50 +0200 Subject: [PATCH 2/2] Use old finalize location --- src/ImpactX.cpp | 3 +++ src/main.cpp | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ImpactX.cpp b/src/ImpactX.cpp index f164ae961..7466356af 100644 --- a/src/ImpactX.cpp +++ b/src/ImpactX.cpp @@ -54,6 +54,9 @@ namespace impactx { // this one last amr_data.reset(); + if (amrex::Initialized()) + amrex::Finalize(); + // only finalize once m_grids_initialized = false; } diff --git a/src/main.cpp b/src/main.cpp index 6fa77c0cf..aa3c973f8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,17 +29,16 @@ int main(int argc, char* argv[]) impactx::initialization::default_init_AMReX(argc, argv); { - BL_PROFILE("main()"); + BL_PROFILE_VAR("main()", pmain); impactx::ImpactX impactX; impactX.init_grids(); impactX.initBeamDistributionFromInputs(); impactX.initLatticeElementsFromInputs(); impactX.evolve(); + BL_PROFILE_VAR_STOP(pmain); impactX.finalize(); } - amrex::Finalize(); - #if defined(AMREX_USE_MPI) AMREX_ALWAYS_ASSERT(MPI_SUCCESS == MPI_Finalize()); #endif