Skip to content
Snippets Groups Projects
Commit d7a14f78 authored by Steffen Müthing's avatar Steffen Müthing
Browse files

[MPI] Check that MPI was initialized when constructing a CollectiveCommunication

This check was added to improve the error message returned when using
MPI without correctly initializing it (e.g. by creating a parallel
grid), see FS#1612 for further information.
parent 8a479606
Branches
No related tags found
No related merge requests found
......@@ -150,6 +150,10 @@ namespace Dune
: communicator(c)
{
if(communicator!=MPI_COMM_NULL) {
int initialized = 0;
MPI_Initialized(&initialized);
if (!initialized)
DUNE_THROW(ParallelError,"You must call MPIHelper::instance(argc,argv) in your main() function before using the MPI CollectiveCommunication!");
MPI_Comm_rank(communicator,&me);
MPI_Comm_size(communicator,&procs);
}else{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment