From 3c63e935377eaddb9d7944e30bf77cbfe660d218 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Sat, 23 Nov 2024 08:43:35 +0100 Subject: [PATCH] [BL/MPI] Wrap MPI_Init and Finalize calls --- BaseLib/MPI.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/BaseLib/MPI.h b/BaseLib/MPI.h index 3d60e44a61b..649769740e6 100644 --- a/BaseLib/MPI.h +++ b/BaseLib/MPI.h @@ -21,6 +21,26 @@ namespace BaseLib::MPI { +struct Setup +{ + Setup(int argc, char* argv[]) + { +#ifdef USE_PETSC + MPI_Init(&argc, &argv); +#else + (void)argc; + (void)argv; +#endif // USE_PETSC + } + + ~Setup() + { +#ifdef USE_PETSC + MPI_Finalize(); +#endif // USE_PETSC + } +}; + #ifdef USE_PETSC struct Mpi { -- GitLab