check if mpi is initialized

This commit is contained in:
Joachim Schöberl 2020-09-15 23:15:50 +02:00
parent 2763285b46
commit 8b5675a8e2

View File

@ -67,6 +67,17 @@ namespace ngcore
NgMPI_Comm (MPI_Comm _comm, bool owns = false) NgMPI_Comm (MPI_Comm _comm, bool owns = false)
: comm(_comm), valid_comm(true) : comm(_comm), valid_comm(true)
{ {
int flag;
MPI_Initialized (&flag);
if (!flag)
{
valid_comm = false;
refcount = nullptr;
rank = 0;
size = 1;
return;
}
if (!owns) if (!owns)
refcount = nullptr; refcount = nullptr;
else else