Index: XIOS/dev/branch_openmp/extern/src_ep_dev/ep_message.cpp
===================================================================
--- XIOS/dev/branch_openmp/extern/src_ep_dev/ep_message.cpp	(revision 1220)
+++ XIOS/dev/branch_openmp/extern/src_ep_dev/ep_message.cpp	(revision 1287)
@@ -9,4 +9,5 @@
 #include <mpi.h>
 #include "ep_declaration.hpp"
+#include "ep_mpi.hpp"
 
 using namespace std;
@@ -20,7 +21,4 @@
   int Message_Check(MPI_Comm comm)
   {
-    int myRank;
-    MPI_Comm_rank(comm, &myRank);
-
     if(!comm.is_ep) return 0;
 
@@ -38,9 +36,10 @@
     {
       Debug("Message probing for intracomm\n");
-      ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm> (comm.mpi_comm);
+      
+
       #ifdef _openmpi
       #pragma omp critical (_mpi_call)
       {
-        ::MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, mpi_comm, &flag, &status);
+        ::MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, to_mpi_comm(comm.mpi_comm), &flag, &status);
         if(flag)
         {
@@ -48,11 +47,10 @@
           mpi_source = status.MPI_SOURCE;
           int tag = status.MPI_TAG;
-          ::MPI_Mprobe(mpi_source, tag, mpi_comm, &message, &status);
+          ::MPI_Mprobe(mpi_source, tag, to_mpi_comm(comm.mpi_comm), &message, &status);
 
         }
       }
       #elif _intelmpi
-      #pragma omp critical (_mpi_call)
-      ::MPI_Improbe(MPI_ANY_SOURCE, MPI_ANY_TAG, mpi_comm, &flag, &message, &status); 
+      ::MPI_Improbe(MPI_ANY_SOURCE, MPI_ANY_TAG, to_mpi_comm(comm.mpi_comm), &flag, &message, &status); 
       #endif
       
@@ -68,6 +66,4 @@
              
         msg_block->ep_src  = get_ep_rank(comm, src_loc,  src_mpi);       
-        int dest_mpi = comm.ep_comm_ptr->size_rank_info[2].first;
-        int ep_dest = get_ep_rank(comm, dest_loc, dest_mpi);
         msg_block->mpi_status = new ::MPI_Status(status);
 
@@ -79,6 +75,5 @@
         {
           #pragma omp flush
-          ptr_comm_target->ep_comm_ptr->message_queue->push_back(*msg_block);  
-    
+          comm.ep_comm_ptr->comm_list[dest_loc].ep_comm_ptr->message_queue->push_back(*msg_block);      
           #pragma omp flush
         }
@@ -110,10 +105,9 @@
     {
       Debug("Message probing for intracomm\n");
-      ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm> (comm.ep_comm_ptr->intercomm->mpi_inter_comm);  // => mpi_intercomm
-      
+
       #ifdef _openmpi
       #pragma omp critical (_mpi_call)
       {
-        ::MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, mpi_comm, &flag, &status);
+        ::MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, to_mpi_comm(comm.ep_comm_ptr->intercomm->mpi_inter_comm), &flag, &status);
         if(flag)
         {
@@ -121,11 +115,10 @@
           mpi_source = status.MPI_SOURCE;
           int tag = status.MPI_TAG;
-          ::MPI_Mprobe(mpi_source, tag, mpi_comm, &message, &status);
+          ::MPI_Mprobe(mpi_source, tag, to_mpi_comm(comm.ep_comm_ptr->intercomm->mpi_inter_comm), &message, &status);
 
         }
       }
       #elif _intelmpi
-      #pragma omp critical (_mpi_call)
-      ::MPI_Improbe(MPI_ANY_SOURCE, MPI_ANY_TAG, mpi_comm, &flag, &message, &status);       
+      ::MPI_Improbe(MPI_ANY_SOURCE, MPI_ANY_TAG, to_mpi_comm(comm.ep_comm_ptr->intercomm->mpi_inter_comm), &flag, &message, &status);       
       #endif
 
@@ -153,5 +146,5 @@
         {
           #pragma omp flush
-          ptr_comm_target->ep_comm_ptr->message_queue->push_back(*msg_block);
+          comm.ep_comm_ptr->comm_list[dest_loc].ep_comm_ptr->message_queue->push_back(*msg_block);
           #pragma omp flush
         }
@@ -167,9 +160,9 @@
     {
       Debug("Message probing for intracomm\n");
-      ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm> (comm.mpi_comm);
+     
       #ifdef _openmpi
       #pragma omp critical (_mpi_call)
       {
-        ::MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, mpi_comm, &flag, &status);
+        ::MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, to_mpi_comm(comm.mpi_comm), &flag, &status);
         if(flag)
         {
@@ -177,11 +170,10 @@
           mpi_source = status.MPI_SOURCE;
           int tag = status.MPI_TAG;
-          ::MPI_Mprobe(mpi_source, tag, mpi_comm, &message, &status);
+          ::MPI_Mprobe(mpi_source, tag, to_mpi_comm(comm.mpi_comm), &message, &status);
 
         }
       }
       #elif _intelmpi
-      #pragma omp critical (_mpi_call)
-      ::MPI_Improbe(MPI_ANY_SOURCE, MPI_ANY_TAG, mpi_comm, &flag, &message, &status);       
+      ::MPI_Improbe(MPI_ANY_SOURCE, MPI_ANY_TAG, to_mpi_comm(comm.mpi_comm), &flag, &message, &status);       
       #endif
 
@@ -196,5 +188,4 @@
         int dest_loc      = bitset<8> (status.MPI_TAG)	    .to_ulong();
         int src_mpi       = status.MPI_SOURCE;
-        int current_inter = comm.ep_comm_ptr->intercomm->local_rank_map->at(current_ep_rank).first;
         
         msg_block->ep_src  = get_ep_rank_intercomm(comm, src_loc, src_mpi);
@@ -209,5 +200,5 @@
         {
           #pragma omp flush
-          ptr_comm_target->ep_comm_ptr->message_queue->push_back(*msg_block);
+          comm.ep_comm_ptr->comm_list[dest_loc].ep_comm_ptr->message_queue->push_back(*msg_block);
           #pragma omp flush
         }
