MPIHelper should only finalize MPI if it called init
Compare changes
@@ -233,10 +233,12 @@ namespace Dune
@@ -246,6 +248,7 @@ namespace Dune
@@ -261,10 +264,11 @@ namespace Dune
MPIHelper only calls MPI if it was not already called before MPIHelper is constructed. Finalize is however always called on destruction leading to problems with other packages calling init/finalize before/after MPIHelper is setup. Added a bool storing the information if MPIInit was called by the MPIHelper so that finalize is only called in that case.
Maybe unrelated, but what is this weird
static int is_initialized
doing here? If anything, we should check its value and throw an exception on error...Why throw an exception when we just want to discard subequent calls to MPI_Init? But we might be overprotective here as
instance
should already take care of this with thestatic MPIHelper singleton
variable.Not necessarily. It might be that it is already initialized via some other part of the code. E.g. in my python code I initialize via mpi4py and thus DUNE should avoid a second initialization.