[bugfix] Make sure MPI_FInalize is called before the return in main.

A correct MPI program should do that.

As MPI_Finalize is part of the destructor of MainObject we need to
make sure that it's destructor is called before the return statement.
We do that manually  by resetting the unique_ptr that we now use to
store the MainObject,
This commit is contained in:
Markus Blatt
2023-07-19 13:20:03 +02:00
parent 7551229e77
commit 859e00254e
34 changed files with 170 additions and 68 deletions

View File

@@ -53,8 +53,11 @@ int flowEbosBrineMain(int argc, char** argv, bool outputCout, bool outputFiles)
int flowEbosBrineMainStandalone(int argc, char** argv)
{
using TypeTag = Properties::TTag::EclFlowBrineProblem;
auto mainObject = Opm::Main(argc, argv);
return mainObject.runStatic<TypeTag>();
auto mainObject = std::make_unique<Opm::Main>(argc, argv);
auto ret = mainObject->runStatic<TypeTag>();
// Destruct mainObject as the destructor calls MPI_Finalize!
mainObject.reset();
return ret;
}
}