From 61185cad14c5b3f0ba722f852143cd4a560c2671 Mon Sep 17 00:00:00 2001
From: Christian Engwer <christi@dune-project.org>
Date: Fri, 12 Mar 2010 07:46:11 +0000
Subject: [PATCH] - use empty struct as fake_mpi_communicator type. this avoids
 accidential compatibility with a real mpi implementation. - call MPI_Init
 only once.

[[Imported from SVN: r5924]]
---
 dune/common/mpihelper.hh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/dune/common/mpihelper.hh b/dune/common/mpihelper.hh
index 8d7d8e80e..bf6460125 100644
--- a/dune/common/mpihelper.hh
+++ b/dune/common/mpihelper.hh
@@ -77,7 +77,7 @@ namespace Dune
     /**
      * @brief The type of the mpi communicator.
      */
-    typedef int MPICommunicator;
+    struct MPICommunicator {};
 
     /**
      * @brief Get the default communicator.
@@ -86,7 +86,8 @@ namespace Dune
      */
     static MPICommunicator getCommunicator()
     {
-      return -1;
+      static MPICommunicator comm();
+      return comm;
     }
 
     static CollectiveCommunication<MPICommunicator>
@@ -208,7 +209,7 @@ namespace Dune
     {
       rank_ = -1;
       size_ = -1;
-      MPI_Init(&argc, &argv);
+      static int is_initialized = MPI_Init(&argc, &argv);
       MPI_Comm_rank(MPI_COMM_WORLD,&rank_);
       MPI_Comm_size(MPI_COMM_WORLD,&size_);
 
-- 
GitLab