add collective communication to generic vanguard

This commit is contained in:
Arne Morten Kvarving
2021-05-12 10:24:53 +02:00
parent ac4ee51a5f
commit d99f642dff
3 changed files with 36 additions and 12 deletions

View File

@@ -98,11 +98,6 @@ namespace Opm {
// with incorrect locale settings.
resetLocale();
# if HAVE_DUNE_FEM
Dune::Fem::MPIManager::initialize(argc, argv);
# else
Dune::MPIHelper::instance(argc, argv);
# endif
FlowMainEbos<TypeTag> mainfunc(argc, argv, outputCout, outputFiles);
return mainfunc.execute();
}
@@ -152,6 +147,14 @@ namespace Opm
{
}
~Main()
{
#if HAVE_MPI && !HAVE_DUNE_FEM
EclGenericVanguard::setCommunication(nullptr);
MPI_Finalize();
#endif
}
int runDynamic()
{
int exitCode = EXIT_SUCCESS;
@@ -361,12 +364,11 @@ namespace Opm
Dune::Fem::MPIManager::initialize(argc_, argv_);
int mpiRank = Dune::Fem::MPIManager::rank();
#else
// the design of the plain dune MPIHelper class is quite flawed: there is no way to
// get the instance without having the argc and argv parameters available and it is
// not possible to determine the MPI rank and size without an instance. (IOW: the
// rank() and size() methods are supposed to be static.)
const auto& mpiHelper = Dune::MPIHelper::instance(argc_, argv_);
int mpiRank = mpiHelper.rank();
#if HAVE_MPI
MPI_Init(&argc_, &argv_);
#endif
EclGenericVanguard::setCommunication(std::make_unique<EclGenericVanguard::CommunicationType>());
int mpiRank = EclGenericVanguard::comm().rank();
#endif
// we always want to use the default locale, and thus spare us the trouble