Make sure MPI_Type_free is not called if MPI hasn't been initialized

This commit is contained in:
Paul Romano 2019-09-03 21:49:32 -05:00
parent d9c66fc13f
commit bbe5b7ba5e
2 changed files with 5 additions and 3 deletions

View file

@ -127,7 +127,9 @@ int openmc_finalize()
// Free all MPI types
#ifdef OPENMC_MPI
MPI_Type_free(&mpi::bank);
int init_called;
MPI_Initialized(&init_called);
if (init_called) MPI_Type_free(&mpi::bank);
#endif
return 0;

View file

@ -8,8 +8,8 @@ int n_procs {1};
bool master {true};
#ifdef OPENMC_MPI
MPI_Comm intracomm;
MPI_Datatype bank;
MPI_Comm intracomm {MPI_COMM_NULL};
MPI_Datatype bank {MPI_DATATYPE_NULL};
#endif
extern "C" bool openmc_master() { return mpi::master; }