From 9a69d0f1404c6ea9b5f4ae504db9cd9b96992852 Mon Sep 17 00:00:00 2001 From: Robert Kloefkorn <robertk@posteo.net> Date: Fri, 18 Jul 2014 12:32:56 +0200 Subject: [PATCH] added MPI initialized check. --- dune/alugrid/impl/parallel/mpAccess_MPI_inline.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dune/alugrid/impl/parallel/mpAccess_MPI_inline.h b/dune/alugrid/impl/parallel/mpAccess_MPI_inline.h index d008c7f32..dc38b0739 100644 --- a/dune/alugrid/impl/parallel/mpAccess_MPI_inline.h +++ b/dune/alugrid/impl/parallel/mpAccess_MPI_inline.h @@ -13,6 +13,17 @@ namespace ALUGrid { inline MpAccessMPI::MinMaxSumIF* MpAccessMPI::copyMPIComm ( MPI_Comm mpicomm ) { + int wasInitialized = 0; + // check if MPI was initialized, otherwise exit + MPI_Initialized( &wasInitialized ); + if( ! wasInitialized ) + { + std::cerr << "ERROR: MPI was not initialized at the beginning of the program." + << " Please add the corresponding call to MPI_Init, e.g. by adding `Dune::MPIHelper::instance( argc, argv );`" + << " as a first line of the main routine." << std::endl; + std::abort(); + } + // duplicate mpi communicator MY_INT_TEST MPI_Comm_dup ( mpicomm, &_mpiComm); alugrid_assert (test == MPI_SUCCESS); -- GitLab