added: bool param to flag that Main.hpp should not initialize/finalize MPI

needed for tests
This commit is contained in:
Arne Morten Kvarving 2023-12-19 10:34:24 +01:00 committed by Atgeirr Flø Rasmussen
parent 093b346426
commit c95cd5b147
2 changed files with 13 additions and 6 deletions

View File

@ -40,10 +40,12 @@
namespace Opm {
Main::Main(int argc, char** argv)
: argc_(argc), argv_(argv)
Main::Main(int argc, char** argv, bool ownMPI)
: argc_(argc), argv_(argv), ownMPI_(ownMPI)
{
initMPI();
if (ownMPI_) {
initMPI();
}
}
Main::Main(const std::string& filename)
@ -83,7 +85,9 @@ Main::~Main()
}
#endif // HAVE_MPI
EclGenericVanguard::setCommunication(nullptr);
if (ownMPI_) {
EclGenericVanguard::setCommunication(nullptr);
}
#if HAVE_DAMARIS
if (enableDamarisOutput_) {
@ -102,7 +106,9 @@ Main::~Main()
#endif // HAVE_DAMARIS
#if HAVE_MPI && !HAVE_DUNE_FEM
MPI_Finalize();
if (ownMPI_) {
MPI_Finalize();
}
#endif
}

View File

@ -127,7 +127,7 @@ int flowEbosMain(int argc, char** argv, bool outputCout, bool outputFiles)
class Main
{
public:
Main(int argc, char** argv);
Main(int argc, char** argv, bool ownMPI = true);
// This constructor can be called from Python
Main(const std::string& filename);
@ -727,6 +727,7 @@ private:
int argc_{0};
char** argv_{nullptr};
bool ownMPI_{true}; //!< True if we "own" MPI and should init / finalize
bool outputCout_{false};
bool outputFiles_{false};
double setupTime_{0.0};