Index: XIOS/dev/branch_yushan/extern/remap/src/mapper.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/remap/src/mapper.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/remap/src/mapper.cpp	(revision 1053)
@@ -12,4 +12,5 @@
 
 #include "mapper.hpp"
+
 
 namespace sphereRemap {
Index: XIOS/dev/branch_yushan/extern/remap/src/mapper.hpp
===================================================================
--- XIOS/dev/branch_yushan/extern/remap/src/mapper.hpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/remap/src/mapper.hpp	(revision 1053)
@@ -3,4 +3,8 @@
 #include "parallel_tree.hpp"
 #include "mpi.hpp"
+
+#ifdef _usingEP
+#include "ep_declaration.hpp"
+#endif
 
 namespace sphereRemap {
@@ -18,5 +22,5 @@
 {
 public:
-       Mapper(MPI_Comm comm=MPI_COMM_WORLD) : communicator(comm), verbose(SILENT), neighbourElements(NULL), sstree(comm) {}
+       Mapper(ep_lib::MPI_Comm comm=MPI_COMM_WORLD) : communicator(comm), verbose(SILENT), neighbourElements(NULL), sstree(comm) {}
        ~Mapper();
        void setVerbosity(verbosity v) {verbose=v ;}
@@ -67,5 +71,5 @@
 
        CParallelTree sstree;
-       MPI_Comm communicator ;
+       ep_lib::MPI_Comm communicator ;
        std::vector<Elt>  sourceElements ;
        std::vector<Node> sourceMesh ;
Index: XIOS/dev/branch_yushan/extern/remap/src/mpi_routing.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/remap/src/mpi_routing.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/remap/src/mpi_routing.cpp	(revision 1053)
@@ -5,4 +5,7 @@
 #include "timerRemap.hpp"
 #include <iostream>
+#ifdef _usingEP
+#include "ep_declaration.hpp"
+#endif
 
 namespace sphereRemap {
@@ -122,6 +125,8 @@
 	CTimer::get("CMPIRouting::init(reduce_scatter)").print();
 
-	MPI_Alloc_mem(nbTarget *sizeof(int), MPI_INFO_NULL, &targetRank);
-	MPI_Alloc_mem(nbSource *sizeof(int), MPI_INFO_NULL, &sourceRank);
+	MPI_Info info_null;
+
+	MPI_Alloc_mem(nbTarget *sizeof(int), info_null, &targetRank);
+	MPI_Alloc_mem(nbSource *sizeof(int), info_null, &sourceRank);
 
 	targetRankToIndex = new int[mpiSize];
Index: XIOS/dev/branch_yushan/extern/remap/src/parallel_tree.hpp
===================================================================
--- XIOS/dev/branch_yushan/extern/remap/src/parallel_tree.hpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/remap/src/parallel_tree.hpp	(revision 1053)
@@ -6,4 +6,7 @@
 #include "mpi_cascade.hpp"
 #include "mpi.hpp"
+#ifdef _usingEP
+#include "ep_declaration.hpp"
+#endif
 
 namespace sphereRemap {
@@ -12,5 +15,5 @@
 {
 public:
-	CParallelTree(MPI_Comm comm);
+	CParallelTree(ep_lib::MPI_Comm comm);
 	~CParallelTree();
 
@@ -34,5 +37,5 @@
 	vector<CSampleTree> treeCascade; // first for sample tree, then for routing tree
 	CMPICascade cascade;
-  MPI_Comm communicator ;
+  ep_lib::MPI_Comm communicator ;
 
 };
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_alltoall.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_alltoall.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_alltoall.cpp	(revision 1053)
@@ -11,5 +11,5 @@
   {
     ::MPI_Aint typesize, llb;
-    ::MPI_Type_get_extent(sendtype, &llb, &typesize);
+    ::MPI_Type_get_extent(static_cast< ::MPI_Datatype>(sendtype), &llb, &typesize);
 
     for(int i=0; i<comm.ep_comm_ptr->size_rank_info[0].second; i++)
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_declaration.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_declaration.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_declaration.cpp	(revision 1053)
@@ -21,4 +21,12 @@
 #undef MPI_COMM_NULL
 
+#undef MPI_STATUS_IGNORE
+//#undef MPI_INFO_NULL
+#undef MPI_REQUEST_NULL
+
+#ifdef _openmpi
+//#undef MPI_Fint
+#endif
+
 // _STD defined in ep_type.cpp
 
@@ -38,4 +46,8 @@
 extern ::MPI_Comm MPI_COMM_NULL_STD;
 
+extern ::MPI_Status MPI_STATUS_IGNORE_STD;
+//extern ::MPI_Info MPI_INFO_NULL_STD;
+extern ::MPI_Request MPI_REQUEST_NULL_STD;
+
 ep_lib::MPI_Datatype MPI_INT = MPI_INT_STD;
 ep_lib::MPI_Datatype MPI_FLOAT = MPI_FLOAT_STD;
@@ -53,4 +65,9 @@
 ep_lib::MPI_Comm MPI_COMM_NULL(MPI_COMM_NULL_STD);
 
+//ep_lib::MPI_Info MPI_INFO_NULL(MPI_INFO_NULL_STD);
+ep_lib::MPI_Request MPI_REQUEST_NULL(MPI_REQUEST_NULL_STD);
+
+//ep_lib::MPI_Status MPI_STATUS_IGNORE_STD = MPI_STATUS_IGNORE_STD;
+
 //ep_lib::MPI_Comm EP_COMM_WORLD;
 //ep_lib::MPI_Comm EP_COMM_NULL;
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_declaration.hpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_declaration.hpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_declaration.hpp	(revision 1053)
@@ -17,4 +17,8 @@
 extern ::MPI_Comm MPI_COMM_NULL_STD;
 
+extern ::MPI_Status MPI_STATUS_IGNORE_STD;
+//extern ::MPI_Info MPI_INFO_NULL_STD;
+extern ::MPI_Request MPI_REQUEST_NULL_STD;
+
 #undef MPI_INT
 #undef MPI_FLOAT
@@ -31,4 +35,13 @@
 #undef MPI_COMM_WORLD
 #undef MPI_COMM_NULL
+
+//#undef MPI_INFO_NULL
+#undef MPI_REQUEST_NULL
+
+#ifdef _openmpi
+//#undef MPI_Fint
+#endif
+
+#undef MPI_STATUS_IGNORE
 
 extern ep_lib::MPI_Datatype MPI_INT;
@@ -47,6 +60,7 @@
 extern ep_lib::MPI_Comm MPI_COMM_NULL;
 
-
-
+extern ep_lib::MPI_Status MPI_STATUS_IGNORE;
+//extern ep_lib::MPI_Info MPI_INFO_NULL;
+extern ep_lib::MPI_Request MPI_REQUEST_NULL;
 
 #endif // EP_DECLARATION_HPP_INCLUDED
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_exscan.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_exscan.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_exscan.cpp	(revision 1053)
@@ -435,5 +435,5 @@
     if(!comm.is_ep)
     {
-      ::MPI_Exscan(sendbuf, recvbuf, count, static_cast< ::MPI_Datatype>(datatype),
+      ::MPI_Exscan(const_cast<void*>(sendbuf), recvbuf, count, static_cast< ::MPI_Datatype>(datatype),
                    static_cast< ::MPI_Op>(op), static_cast< ::MPI_Comm>(comm.mpi_comm));
       return 0;
@@ -481,7 +481,4 @@
     if(ep_rank_loc == 0)
     {
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Exscan(local_sum, mpi_scan_recvbuf, count, static_cast< ::MPI_Datatype>(datatype), static_cast< ::MPI_Op>(op), static_cast< ::MPI_Comm>(comm.mpi_comm));
     }
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_finalize.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_finalize.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_finalize.cpp	(revision 1053)
@@ -15,7 +15,4 @@
     if(id == 0)
     {
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Finalize();
     }
@@ -30,8 +27,4 @@
     {
       ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm >(comm.mpi_comm);
-
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Abort(mpi_comm, errorcode);
     }
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_fortran.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_fortran.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_fortran.cpp	(revision 1053)
@@ -4,11 +4,64 @@
 #include <map>
 #include <utility>
+
+#ifdef _intelmpi
 #undef MPI_Comm_f2c(comm)
 #undef MPI_Comm_c2f(comm)
+#endif
 
+#ifdef _openmpi
+//#undef MPI_Fint
+#endif
 
 namespace ep_lib
 {
 
+  int EP_Comm_c2f(MPI_Comm comm)
+  {
+    Debug("MPI_Comm_c2f");
+    int fint;
+    #ifdef _intelmpi
+    fint = (::MPI_Fint)(comm.mpi_comm);
+    #elif _openmpi
+    fint = ::MPI_Comm_c2f(static_cast< ::MPI_Comm>(comm.mpi_comm));
+    #endif
+    std::map<std::pair<int, int>, MPI_Comm  > ::iterator it;
+    
+    it = fc_comm_map.find(std::make_pair(fint, omp_get_thread_num()));
+    if(it == fc_comm_map.end())
+    {
+      fc_comm_map.insert(std::make_pair( std::make_pair( fint, omp_get_thread_num()) , comm));
+      printf("MAP insert: %d, %d, %p\n", fint, omp_get_thread_num(), &comm);
+    }
+    
+    
+    return fint;
+    
+  }
+
+  MPI_Comm EP_Comm_f2c(int comm)
+  {
+    Debug("MPI_Comm_f2c");
+    
+    
+    std::map<std::pair<int, int>, MPI_Comm  > ::iterator it;
+    
+    it = fc_comm_map.find(std::make_pair(comm, omp_get_thread_num()));
+    if(it != fc_comm_map.end())
+    {
+      MPI_Comm comm_ptr;
+      comm_ptr =  it->second;
+      printf("MAP find: %d, %d, %p\n", it->first.first, it->first.second, &comm_ptr);
+      return  comm_ptr;
+    }
+    else
+    {      
+      MPI_Comm return_comm;
+      return_comm.mpi_comm = ::MPI_Comm_f2c(comm);
+      return return_comm;
+    }
+  }
+
+  #ifdef _intelmpi
 
   MPI_Fint MPI_Comm_c2f(MPI_Comm comm)
@@ -32,4 +85,6 @@
     
   }
+
+  
 
 
@@ -57,4 +112,51 @@
   }
 
+  
+
+  #elif _openmpi
+  
+  int MPI_Comm_c2f(MPI_Comm comm)
+  {
+    Debug("MPI_Comm_c2f");
+    int fint;
+    fint = ::MPI_Comm_c2f(static_cast< ::MPI_Comm>(comm.mpi_comm));
+    
+    std::map<std::pair<int, int>, MPI_Comm  > ::iterator it;
+    
+    it = fc_comm_map.find(std::make_pair(fint, omp_get_thread_num()));
+    if(it == fc_comm_map.end())
+    {
+      fc_comm_map.insert(std::make_pair( std::make_pair( fint, omp_get_thread_num()) , comm));
+      printf("MAP insert: %d, %d, %p\n", fint, omp_get_thread_num(), &comm);
+    }
+    
+    return fint;
+    
+  }
+
+  ep_lib::MPI_Comm MPI_Comm_f2c(MPI_Fint comm)
+  {
+    Debug("MPI_Comm_f2c");
+    
+    
+    std::map<std::pair<int, int>, MPI_Comm  > ::iterator it;
+    
+    it = fc_comm_map.find(std::make_pair(comm, omp_get_thread_num()));
+    if(it != fc_comm_map.end())
+    {
+      MPI_Comm comm_ptr;
+      comm_ptr =  it->second;
+      printf("MAP find: %d, %d, %p\n", it->first.first, it->first.second, &comm_ptr);
+      return  comm_ptr;
+    }
+    else
+    {      
+      MPI_Comm return_comm;
+      return_comm.mpi_comm = (::MPI_Comm)(comm);
+      return return_comm;
+    }
+  }
+  #endif
+
 }
 
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_free.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_free.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_free.cpp	(revision 1053)
@@ -10,7 +10,5 @@
   int MPI_Comm_free(MPI_Comm *comm)
   {
-    //return 0;
-    
-    if(comm == NULL) return 0;
+    //if(comm == NULL) return 0;
 
     MPI_Barrier(*comm);
@@ -19,5 +17,5 @@
     if(! comm->is_ep)
     {
-      if(comm->mpi_comm)
+      if(comm->mpi_comm != MPI_COMM_NULL_STD)
       {
         ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(comm->mpi_comm);
@@ -31,5 +29,5 @@
     else
     {
-      if(! comm->mpi_comm) return 0;
+      if(comm->mpi_comm == MPI_COMM_NULL_STD ) return 0;
 
       int ep_rank, ep_rank_loc, mpi_rank;
@@ -47,5 +45,5 @@
 
       #pragma omp critical (memory_free)
-      if(comm->is_intercomm && comm->ep_comm_ptr->intercomm)
+      if(comm->is_intercomm && comm->ep_comm_ptr->intercomm != NULL)
       {
         if(comm->ep_comm_ptr->intercomm->local_rank_map) comm->ep_comm_ptr->intercomm->local_rank_map->clear();
@@ -62,15 +60,15 @@
 
 /*
-        if(comm->my_buffer)
+        if(comm->my_buffer != NULL)
         {
-          if(comm->my_buffer->buf_int) delete[] comm->my_buffer->buf_int; Debug("buf_int freed\n");
-          if(comm->my_buffer->buf_float) delete[] comm->my_buffer->buf_float; Debug("buf_float freed\n");
-          if(comm->my_buffer->buf_double) delete[] comm->my_buffer->buf_double; Debug("buf_double freed\n");
-          if(comm->my_buffer->buf_long) delete[] comm->my_buffer->buf_long; Debug("buf_long freed\n");
-          if(comm->my_buffer->buf_ulong) delete[] comm->my_buffer->buf_ulong; Debug("buf_ulong freed\n");
-          if(comm->my_buffer->buf_char) delete[] comm->my_buffer->buf_char; Debug("buf_char freed\n");
+          if(comm->my_buffer->buf_int != NULL) delete[] comm->my_buffer->buf_int; Debug("buf_int freed\n");
+          if(comm->my_buffer->buf_float != NULL) delete[] comm->my_buffer->buf_float; Debug("buf_float freed\n");
+          if(comm->my_buffer->buf_double != NULL) delete[] comm->my_buffer->buf_double; Debug("buf_double freed\n");
+          if(comm->my_buffer->buf_long != NULL) delete[] comm->my_buffer->buf_long; Debug("buf_long freed\n");
+          if(comm->my_buffer->buf_ulong != NULL) delete[] comm->my_buffer->buf_ulong; Debug("buf_ulong freed\n");
+          if(comm->my_buffer->buf_char != NULL) delete[] comm->my_buffer->buf_char; Debug("buf_char freed\n");
         }
 */
-        if(comm->ep_barrier)
+        if(comm->ep_barrier != NULL)
         {
           comm->ep_barrier->~OMPbarrier();
@@ -79,5 +77,5 @@
 
 
-        if(comm->rank_map)
+        if(comm->rank_map != NULL)
         {
           comm->rank_map->clear();
@@ -86,10 +84,10 @@
 
 
-        if(comm->is_intercomm && comm->ep_comm_ptr->intercomm->mpi_inter_comm)
+        if(comm->is_intercomm && comm->ep_comm_ptr->intercomm->mpi_inter_comm != MPI_COMM_NULL_STD)
         {
           ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(comm->ep_comm_ptr->intercomm->mpi_inter_comm);
 
           ::MPI_Comm_free(&mpi_comm);
-          comm->ep_comm_ptr->intercomm->mpi_inter_comm = NULL;
+          //comm->ep_comm_ptr->intercomm->mpi_inter_comm = NULL;
           Debug("mpi_intercomm freed\n");
         }
@@ -99,5 +97,5 @@
         for(int i=0; i<num_ep; i++)
         {
-          if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue)
+          if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue != NULL)
           {
             comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue->clear();
@@ -105,5 +103,5 @@
           }
 
-          if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr)
+          if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr != NULL)
           {
             delete comm->ep_comm_ptr->comm_list[i].ep_comm_ptr;
@@ -112,16 +110,13 @@
         }
 
-        if(comm->mpi_comm)
+        if(comm->mpi_comm != MPI_COMM_NULL_STD)
         {
           ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(comm->mpi_comm);
-          #ifdef _serialized
-          #pragma omp critical (_mpi_call)
-          #endif // _serialized
           ::MPI_Comm_free(&mpi_comm);
-          comm->mpi_comm = NULL;
+          //comm->mpi_comm = NULL;
 //          printf("label = %d, mpi_comm freed\n", comm->ep_comm_ptr->comm_label);
         }
 
-       if(comm) {delete[] comm->ep_comm_ptr->comm_list; Debug("comm freed\n");}
+       if(comm != NULL) {delete[] comm->ep_comm_ptr->comm_list; Debug("comm freed\n");}
 
       }
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_gather.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_gather.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_gather.cpp	(revision 1053)
@@ -320,8 +320,5 @@
     if(!comm.is_ep && comm.mpi_comm)
     {
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
-      ::MPI_Gather(sendbuf, sendcount, static_cast< ::MPI_Datatype>(sendtype), recvbuf, recvcount, static_cast< ::MPI_Datatype>(recvtype),
+      ::MPI_Gather(const_cast<void*>(sendbuf), sendcount, static_cast< ::MPI_Datatype>(sendtype), recvbuf, recvcount, static_cast< ::MPI_Datatype>(recvtype),
                    root, static_cast< ::MPI_Comm>(comm.mpi_comm));
       return 0;
@@ -351,7 +348,5 @@
 
     ::MPI_Aint datasize, lb;
-    #ifdef _serialized
-    #pragma omp critical (_mpi_call)
-    #endif // _serialized
+
     ::MPI_Type_get_extent(static_cast< ::MPI_Datatype>(datatype), &lb, &datasize);
 
@@ -377,7 +372,5 @@
       gatherv_displs = new int[mpi_size];
 
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
+
       ::MPI_Allgather(&gatherv_cnt, 1, MPI_INT_STD, gatherv_recvcnt, 1, MPI_INT_STD, static_cast< ::MPI_Comm>(comm.mpi_comm));
 
@@ -388,7 +381,5 @@
       }
 
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
+
       ::MPI_Gatherv(local_gather_recvbuf, count*num_ep, static_cast< ::MPI_Datatype>(datatype), recvbuf, gatherv_recvcnt,
                     gatherv_displs, static_cast< ::MPI_Datatype>(datatype), root_mpi_rank, static_cast< ::MPI_Comm>(comm.mpi_comm));
@@ -442,8 +433,5 @@
     if(!comm.is_ep && comm.mpi_comm)
     {
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
-      ::MPI_Allgather(sendbuf, sendcount, static_cast< ::MPI_Datatype>(sendtype), recvbuf, recvcount, static_cast< ::MPI_Datatype>(recvtype),
+      ::MPI_Allgather(const_cast<void*>(sendbuf), sendcount, static_cast< ::MPI_Datatype>(sendtype), recvbuf, recvcount, static_cast< ::MPI_Datatype>(recvtype),
                       static_cast< ::MPI_Comm>(comm.mpi_comm));
       return 0;
@@ -469,7 +457,5 @@
 
     ::MPI_Aint datasize, lb;
-    #ifdef _serialized
-    #pragma omp critical (_mpi_call)
-    #endif // _serialized
+
     ::MPI_Type_get_extent(static_cast< ::MPI_Datatype>(datatype), &lb, &datasize);
 
@@ -495,7 +481,4 @@
       gatherv_displs = new int[mpi_size];
 
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Allgather(&gatherv_cnt, 1, MPI_INT_STD, gatherv_recvcnt, 1, MPI_INT_STD, static_cast< ::MPI_Comm>(comm.mpi_comm));
 
@@ -506,7 +489,4 @@
       }
 
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Allgatherv(local_gather_recvbuf, count*num_ep, static_cast< ::MPI_Datatype>(datatype), recvbuf, gatherv_recvcnt,
                     gatherv_displs, static_cast< ::MPI_Datatype>(datatype), static_cast< ::MPI_Comm>(comm.mpi_comm));
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_gatherv.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_gatherv.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_gatherv.cpp	(revision 1053)
@@ -328,8 +328,5 @@
     if(!comm.is_ep && comm.mpi_comm)
     {
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
-      ::MPI_Gatherv(sendbuf, sendcount, static_cast< ::MPI_Datatype>(sendtype), recvbuf, recvcounts, displs,
+      ::MPI_Gatherv(const_cast<void*>(sendbuf), sendcount, static_cast< ::MPI_Datatype>(sendtype), recvbuf, const_cast<int*>(recvcounts), const_cast<int*>(displs),
                     static_cast< ::MPI_Datatype>(recvtype), root, static_cast< ::MPI_Comm>(comm.mpi_comm));
       return 0;
@@ -362,7 +359,5 @@
 
     ::MPI_Aint datasize, lb;
-    #ifdef _serialized
-    #pragma omp critical (_mpi_call)
-    #endif // _serialized
+
     ::MPI_Type_get_extent(static_cast< ::MPI_Datatype>(datatype), &lb, &datasize);
 
@@ -395,7 +390,5 @@
       //gatherv_displs = new int[mpi_size];
 
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
+
       ::MPI_Allgather(&gatherv_cnt, 1, MPI_INT_STD, gatherv_recvcnt, 1, MPI_INT_STD, static_cast< ::MPI_Comm>(comm.mpi_comm));
 
@@ -406,7 +399,5 @@
       }
 
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
+
       ::MPI_Gatherv(local_gather_recvbuf, gatherv_cnt, static_cast< ::MPI_Datatype>(datatype), recvbuf, gatherv_recvcnt,
                     gatherv_displs, static_cast< ::MPI_Datatype>(datatype), root_mpi_rank, static_cast< ::MPI_Comm>(comm.mpi_comm));
@@ -462,7 +453,4 @@
     if(!comm.is_ep && comm.mpi_comm)
     {
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Allgatherv(sendbuf, sendcount, static_cast< ::MPI_Datatype>(sendtype), recvbuf, recvcounts, displs,
                        static_cast< ::MPI_Datatype>(recvtype), static_cast< ::MPI_Comm>(comm.mpi_comm));
@@ -493,7 +481,5 @@
 
     ::MPI_Aint datasize, lb;
-    #ifdef _serialized
-    #pragma omp critical (_mpi_call)
-    #endif // _serialized
+
     ::MPI_Type_get_extent(static_cast< ::MPI_Datatype>(datatype), &lb, &datasize);
 
@@ -525,7 +511,4 @@
       gatherv_displs = new int[mpi_size];
 
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Allgather(&gatherv_cnt, 1, MPI_INT_STD, gatherv_recvcnt, 1, MPI_INT_STD, static_cast< ::MPI_Comm>(comm.mpi_comm));
       gatherv_displs[0] = displs[0];
@@ -534,7 +517,5 @@
         gatherv_displs[i] = gatherv_recvcnt[i-1] + gatherv_displs[i-1];
       }
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
+
       ::MPI_Allgatherv(local_gather_recvbuf, gatherv_cnt, static_cast< ::MPI_Datatype>(datatype), recvbuf, gatherv_recvcnt,
                     gatherv_displs, static_cast< ::MPI_Datatype>(datatype), static_cast< ::MPI_Comm>(comm.mpi_comm));
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_init.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_init.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_init.cpp	(revision 1053)
@@ -11,5 +11,5 @@
   int MPI_Init_thread(int *argc, char*** argv, int required, int*provided)
   {
-    printf("MPI_Init_thread\n");
+    //printf("MPI_Init_thread\n");
 
     int id = omp_get_thread_num();
@@ -24,5 +24,5 @@
   int MPI_Init(int *argc, char ***argv)
   {
-    printf("MPI_init called\n");
+    //printf("MPI_init called\n");
     int id = omp_get_thread_num();
 
@@ -36,5 +36,5 @@
   int MPI_Initialized(int *flag)
   {
-    printf("MPI_initialized called\n");
+    //printf("MPI_initialized called\n");
 
     ::MPI_Initialized(flag);
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_intercomm.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_intercomm.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_intercomm.cpp	(revision 1053)
@@ -143,7 +143,4 @@
         if(ep_rank == new_local_leader)
         {
-          #ifdef _serialized
-          #pragma omp critical (_mpi_call)
-          #endif // _serialized
           ::MPI_Comm_rank(MPI_COMM_WORLD_STD, &leader_in_world[0]);
         }
@@ -190,4 +187,5 @@
   int MPI_Comm_test_inter(MPI_Comm comm, int *flag)
   {
+    *flag = false;
     if(comm.is_ep)
     {
@@ -195,13 +193,12 @@
       return 0;
     } 
-    else
+    else if(comm.mpi_comm != MPI_COMM_NULL_STD)
     {
       ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm> (comm.mpi_comm);
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif
+      
       ::MPI_Comm_test_inter(mpi_comm, flag);
       return 0;  
     }
+    return 0;
   }
 
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_intercomm_kernel.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_intercomm_kernel.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_intercomm_kernel.cpp	(revision 1053)
@@ -35,11 +35,8 @@
     ::MPI_Comm local_mpi_comm = static_cast< ::MPI_Comm>(local_comm.mpi_comm);
 
-    #ifdef _serialized
-    #pragma omp critical (_mpi_call)
-    #endif // _serialized
-    {
-      ::MPI_Comm_rank(MPI_COMM_WORLD_STD, &rank_in_world);
-      ::MPI_Comm_rank(static_cast< ::MPI_Comm>(local_comm.mpi_comm), &rank_in_local_parent);
-    }
+    
+    ::MPI_Comm_rank(MPI_COMM_WORLD_STD, &rank_in_world);
+    ::MPI_Comm_rank(static_cast< ::MPI_Comm>(local_comm.mpi_comm), &rank_in_local_parent);
+    
 
     bool is_proc_master = false;
@@ -83,7 +80,4 @@
       send_buf[2] = num_ep;
 
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Allgather(send_buf.data(), 3, MPI_INT_STD, recv_buf.data(), 3, MPI_INT_STD, local_mpi_comm);
 
@@ -100,7 +94,4 @@
         leader_info[1] = remote_leader;
 
-        #ifdef _serialized
-        #pragma omp critical (_mpi_call)
-        #endif // _serialized
         ::MPI_Comm_rank(static_cast< ::MPI_Comm>(peer_comm.mpi_comm), &rank_in_peer_mpi[0]);
 
@@ -126,7 +117,4 @@
       send_buf[4] = rank_in_peer_mpi[1];
 
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Bcast(send_buf.data(), 5, MPI_INT_STD, local_comm.rank_map->at(local_leader).second, local_mpi_comm);
 
@@ -156,10 +144,6 @@
         MPI_Send(send_buf.data(), 3*size_info[0], MPI_INT_STD, remote_leader, tag, peer_comm);
         MPI_Recv(recv_buf.data(), 3*size_info[1], MPI_INT_STD, remote_leader, tag, peer_comm, &status);
-
-      }
-
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
+      }
+
       ::MPI_Bcast(recv_buf.data(), 3*size_info[1], MPI_INT_STD, local_comm.rank_map->at(local_leader).second, local_mpi_comm);
 
@@ -283,7 +267,4 @@
       }
 
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Bcast(&size_info[2], 2, MPI_INT_STD, local_comm.rank_map->at(local_leader).second, local_mpi_comm);
 
@@ -307,8 +288,4 @@
       }
 
-
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Bcast(recv_buf.data(),   3*size_info[3], MPI_INT_STD, local_comm.rank_map->at(local_leader).second, local_mpi_comm);
 
@@ -330,17 +307,8 @@
       ::MPI_Comm intercomm;
 
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Comm_group(local_mpi_comm, &local_group);
 
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Group_incl(local_group, size_info[2], new_rank_info[1].data(), &new_group);
 
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Comm_create(local_mpi_comm, new_group, &new_comm);
 
@@ -349,13 +317,7 @@
       if(is_local_leader)
       {
-        #ifdef _serialized
-        #pragma omp critical (_mpi_call)
-        #endif // _serialized
         ::MPI_Comm_rank(new_comm, &leader_info[2]);
       }
 
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Bcast(&leader_info[2], 1, MPI_INT_STD, local_comm.rank_map->at(local_leader).second, local_mpi_comm);
 
@@ -363,18 +325,10 @@
       {
 
-        #ifdef _serialized
-        #pragma omp critical (_mpi_call)
-        #endif // _serialized
         ::MPI_Barrier(new_comm);
 
-        #ifdef _serialized
-        #pragma omp critical (_mpi_call)
-        #endif // _serialized
         ::MPI_Intercomm_create(new_comm, leader_info[2], static_cast< ::MPI_Comm>(peer_comm.mpi_comm), rank_in_peer_mpi[1], tag, &intercomm);
 
         int id;
-        #ifdef _serialized
-        #pragma omp critical (_mpi_call)
-        #endif // _serialized
+
         ::MPI_Comm_rank(new_comm, &id);
         int my_num_ep = new_ep_info[0][id];
@@ -604,7 +558,4 @@
     int rank_in_peer_mpi[2];
 
-    #ifdef _serialized
-    #pragma omp critical (_mpi_call)
-    #endif // _serialized
     ::MPI_Comm_rank(MPI_COMM_WORLD_STD, &rank_in_world);
 
@@ -663,8 +614,5 @@
       {
         ::MPI_Comm mpi_dup;
-
-        #ifdef _serialized
-        #pragma omp critical (_mpi_call)
-        #endif // _serialized
+        
         ::MPI_Comm_dup(static_cast< ::MPI_Comm>(local_comm.mpi_comm), &mpi_dup);
 
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_intercomm_world.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_intercomm_world.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_intercomm_world.cpp	(revision 1053)
@@ -281,6 +281,6 @@
         std::copy ( new_ep_info[0].data(),   new_ep_info[0].data()   + size_info[0], send_buf.begin() + 2*size_info[2] );
 
-        MPI_Send(send_buf.data(), 3*size_info[2], MPI_INT_STD, mpi_remote_leader, tag, peer_comm);
-        MPI_Recv(recv_buf.data(), 3*size_info[3], MPI_INT_STD, mpi_remote_leader, tag, peer_comm, &mpi_status);
+        ::MPI_Send(send_buf.data(), 3*size_info[2], MPI_INT_STD, mpi_remote_leader, tag, peer_comm);
+        ::MPI_Recv(recv_buf.data(), 3*size_info[3], MPI_INT_STD, mpi_remote_leader, tag, peer_comm, &mpi_status);
 
       }
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_lib.hpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_lib.hpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_lib.hpp	(revision 1053)
@@ -20,6 +20,11 @@
 #endif
 
+#ifdef _intelmpi
   #define MPI_ANY_SOURCE -2 
   #define MPI_ANY_TAG -1 
+#elif _openmpi
+  #define MPI_ANY_SOURCE -1 
+  #define MPI_ANY_TAG -1 
+#endif
 
   int MPI_Init_thread(int* argc, char*** argv, int required, int*provided);
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_lib_fortran.hpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_lib_fortran.hpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_lib_fortran.hpp	(revision 1053)
@@ -7,12 +7,18 @@
 {
   
+  #ifdef _intelmpi
+  
+  MPI_Fint MPI_Comm_c2f(MPI_Comm comm);
+  MPI_Comm MPI_Comm_f2c(MPI_Fint comm);
+  
+  #elif _openmpi
+  
+  int MPI_Comm_c2f(MPI_Comm comm);
+  ep_lib::MPI_Comm MPI_Comm_f2c(MPI_Fint comm);
+  
+  #endif
 
-  MPI_Fint MPI_Comm_c2f(MPI_Comm comm);
-  //int MPI_Comm_c2f(MPI_Comm comm);
-
-
-  MPI_Comm MPI_Comm_f2c(MPI_Fint comm);
-  //void MPI_Comm_f2c(MPI_Fint comm);
-
+  int EP_Comm_c2f(MPI_Comm comm);
+  MPI_Comm EP_Comm_f2c(int comm);
 }
 
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_memory.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_memory.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_memory.cpp	(revision 1053)
@@ -10,8 +10,5 @@
   int MPI_Alloc_mem(MPI_Aint size, MPI_Info info, void *baseptr)
   {
-    #ifdef _serialized
-    #pragma omp critical (_mpi_call)
-    #endif // _serialized
-    ::MPI_Alloc_mem(size.mpi_aint, info.mpi_info, baseptr);
+    ::MPI_Alloc_mem(size.mpi_aint, static_cast< ::MPI_Info>(info.mpi_info), baseptr);
     return 0;
    }
@@ -19,10 +16,7 @@
   int MPI_Alloc_mem(unsigned long size, MPI_Info info, void *baseptr)
   {
-    #ifdef _serialized
-    #pragma omp critical (_mpi_call)
-    #endif // _serialized
-    ::MPI_Alloc_mem(size, info.mpi_info, baseptr);
+    ::MPI_Alloc_mem(size, static_cast< ::MPI_Info>(info.mpi_info), baseptr);
     return 0;
-   }
+  }
 
 
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_merge.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_merge.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_merge.cpp	(revision 1053)
@@ -39,4 +39,123 @@
     local_mpi_size = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[2].second;
 
+
+    if(local_ep_rank == 0)
+    {
+      MPI_Status status;
+      MPI_Request req_s, req_r;
+      MPI_Isend(&local_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &req_s);
+      MPI_Irecv(&remote_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &req_r);
+
+      MPI_Wait(&req_s, &status);
+      MPI_Wait(&req_r, &status);
+    }
+
+
+    MPI_Bcast(&remote_high, 1, MPI_INT, 0, *(inter_comm.ep_comm_ptr->intercomm->local_comm));
+
+//    printf("%d, %d, %d, %d\n", local_ep_size, remote_ep_size, local_high, remote_high);
+
+
+    MPI_Comm_dup(inter_comm, newintracomm);
+
+    int my_ep_rank = local_high<remote_high? local_ep_rank: local_ep_rank+remote_ep_size;
+
+
+    int intra_ep_rank, intra_ep_rank_loc, intra_mpi_rank;
+    int intra_ep_size, intra_num_ep, intra_mpi_size;
+
+    intra_ep_rank = newintracomm->ep_comm_ptr->size_rank_info[0].first;
+    intra_ep_rank_loc = newintracomm->ep_comm_ptr->size_rank_info[1].first;
+    intra_mpi_rank = newintracomm->ep_comm_ptr->size_rank_info[2].first;
+    intra_ep_size = newintracomm->ep_comm_ptr->size_rank_info[0].second;
+    intra_num_ep = newintracomm->ep_comm_ptr->size_rank_info[1].second;
+    intra_mpi_size = newintracomm->ep_comm_ptr->size_rank_info[2].second;
+
+
+    MPI_Barrier_local(*newintracomm);
+
+
+    int *reorder;
+    if(intra_ep_rank_loc == 0)
+    {
+      reorder = new int[intra_ep_size];
+    }
+
+
+    MPI_Gather(&my_ep_rank, 1, MPI_INT, reorder, 1, MPI_INT, 0, *newintracomm);
+    if(intra_ep_rank_loc == 0)
+    {
+      ::MPI_Bcast(reorder, intra_ep_size, MPI_INT_STD, 0, static_cast< ::MPI_Comm>(newintracomm->mpi_comm));
+
+      vector< pair<int, int> > tmp_rank_map(intra_ep_size);
+
+
+      for(int i=0; i<intra_ep_size; i++)
+      {
+        tmp_rank_map[reorder[i]] = newintracomm->rank_map->at(i) ;
+      }
+
+      newintracomm->rank_map->swap(tmp_rank_map);
+
+      tmp_rank_map.clear();
+    }
+
+    MPI_Barrier_local(*newintracomm);
+
+    (*newintracomm).ep_comm_ptr->size_rank_info[0].first = my_ep_rank;
+
+    if(intra_ep_rank_loc == 0)
+    {
+      delete[] reorder;
+    }
+
+    return MPI_SUCCESS;
+  }
+
+
+
+
+
+  int MPI_Intercomm_merge(MPI_Comm inter_comm, bool high, MPI_Comm *newintracomm)
+  {
+
+    assert(inter_comm.is_intercomm);
+
+    if(inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->comm_label == -99)
+    {
+        return MPI_Intercomm_merge_unique_leader(inter_comm, high, newintracomm);
+    }
+
+
+    Debug("intercomm_merge kernel\n");
+
+    int ep_rank, ep_rank_loc, mpi_rank;
+    int ep_size, num_ep, mpi_size;
+
+    ep_rank = inter_comm.ep_comm_ptr->size_rank_info[0].first;
+    ep_rank_loc = inter_comm.ep_comm_ptr->size_rank_info[1].first;
+    mpi_rank = inter_comm.ep_comm_ptr->size_rank_info[2].first;
+    ep_size = inter_comm.ep_comm_ptr->size_rank_info[0].second;
+    num_ep = inter_comm.ep_comm_ptr->size_rank_info[1].second;
+    mpi_size = inter_comm.ep_comm_ptr->size_rank_info[2].second;
+
+
+    int local_ep_rank, local_ep_rank_loc, local_mpi_rank;
+    int local_ep_size, local_num_ep, local_mpi_size;
+
+
+    local_ep_rank = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[0].first;
+    local_ep_rank_loc = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[1].first;
+    local_mpi_rank = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[2].first;
+    local_ep_size = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[0].second;
+    local_num_ep = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[1].second;
+    local_mpi_size = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[2].second;
+
+    int remote_ep_size = inter_comm.ep_comm_ptr->intercomm->remote_rank_map->size();
+
+    int local_high = high;
+    int remote_high;
+
+    MPI_Barrier(inter_comm);
 
 //    if(local_ep_rank == 0 && high == false)
@@ -65,14 +184,36 @@
     }
 
-
     MPI_Bcast(&remote_high, 1, MPI_INT, 0, *(inter_comm.ep_comm_ptr->intercomm->local_comm));
 
-//    printf("%d, %d, %d, %d\n", local_ep_size, remote_ep_size, local_high, remote_high);
-
-
-    MPI_Comm_dup(inter_comm, newintracomm);
+    int intercomm_high;
+    if(ep_rank == 0) intercomm_high = local_high;
+    MPI_Bcast(&intercomm_high, 1, MPI_INT, 0, inter_comm);
+
+    //printf("remote_ep_size = %d, local_high = %d, remote_high = %d, intercomm_high = %d\n", remote_ep_size, local_high, remote_high, intercomm_high);
+
+
+    ::MPI_Comm mpi_intracomm;
+    MPI_Comm *ep_intracomm;
+
+    if(ep_rank_loc == 0)
+    {
+
+      ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(inter_comm.ep_comm_ptr->intercomm->mpi_inter_comm);
+
+      ::MPI_Intercomm_merge(mpi_comm, intercomm_high, &mpi_intracomm);
+      MPI_Info info;
+      MPI_Comm_create_endpoints(mpi_intracomm, num_ep, info, ep_intracomm);
+
+      inter_comm.ep_comm_ptr->comm_list->mem_bridge = ep_intracomm;
+
+    }
+
+
+
+    MPI_Barrier_local(inter_comm);
+
+    *newintracomm = inter_comm.ep_comm_ptr->comm_list->mem_bridge[ep_rank_loc];
 
     int my_ep_rank = local_high<remote_high? local_ep_rank: local_ep_rank+remote_ep_size;
-
 
     int intra_ep_rank, intra_ep_rank_loc, intra_mpi_rank;
@@ -87,4 +228,5 @@
 
 
+
     MPI_Barrier_local(*newintracomm);
 
@@ -97,10 +239,9 @@
 
 
+
     MPI_Gather(&my_ep_rank, 1, MPI_INT, reorder, 1, MPI_INT, 0, *newintracomm);
     if(intra_ep_rank_loc == 0)
     {
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
+
       ::MPI_Bcast(reorder, intra_ep_size, MPI_INT_STD, 0, static_cast< ::MPI_Comm>(newintracomm->mpi_comm));
 
@@ -122,166 +263,4 @@
     (*newintracomm).ep_comm_ptr->size_rank_info[0].first = my_ep_rank;
 
-    if(intra_ep_rank_loc == 0)
-    {
-      delete[] reorder;
-    }
-
-    return MPI_SUCCESS;
-  }
-
-
-
-
-
-  int MPI_Intercomm_merge(MPI_Comm inter_comm, bool high, MPI_Comm *newintracomm)
-  {
-
-    assert(inter_comm.is_intercomm);
-
-    if(inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->comm_label == -99)
-    {
-        return MPI_Intercomm_merge_unique_leader(inter_comm, high, newintracomm);
-    }
-
-
-    Debug("intercomm_merge kernel\n");
-
-    int ep_rank, ep_rank_loc, mpi_rank;
-    int ep_size, num_ep, mpi_size;
-
-    ep_rank = inter_comm.ep_comm_ptr->size_rank_info[0].first;
-    ep_rank_loc = inter_comm.ep_comm_ptr->size_rank_info[1].first;
-    mpi_rank = inter_comm.ep_comm_ptr->size_rank_info[2].first;
-    ep_size = inter_comm.ep_comm_ptr->size_rank_info[0].second;
-    num_ep = inter_comm.ep_comm_ptr->size_rank_info[1].second;
-    mpi_size = inter_comm.ep_comm_ptr->size_rank_info[2].second;
-
-
-    int local_ep_rank, local_ep_rank_loc, local_mpi_rank;
-    int local_ep_size, local_num_ep, local_mpi_size;
-
-
-    local_ep_rank = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[0].first;
-    local_ep_rank_loc = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[1].first;
-    local_mpi_rank = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[2].first;
-    local_ep_size = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[0].second;
-    local_num_ep = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[1].second;
-    local_mpi_size = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[2].second;
-
-    int remote_ep_size = inter_comm.ep_comm_ptr->intercomm->remote_rank_map->size();
-
-    int local_high = high;
-    int remote_high;
-
-    MPI_Barrier(inter_comm);
-
-//    if(local_ep_rank == 0 && high == false)
-//    {
-//      MPI_Status status;
-//      MPI_Send(&local_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm);
-//      MPI_Recv(&remote_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &status);
-//    }
-//
-//    if(local_ep_rank == 0 && high == true)
-//    {
-//      MPI_Status status;
-//      MPI_Recv(&remote_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &status);
-//      MPI_Send(&local_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm);
-//    }
-
-    if(local_ep_rank == 0)
-    {
-      MPI_Status status;
-      MPI_Request req_s, req_r;
-      MPI_Isend(&local_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &req_s);
-      MPI_Irecv(&remote_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &req_r);
-
-      MPI_Wait(&req_s, &status);
-      MPI_Wait(&req_r, &status);
-    }
-
-    MPI_Bcast(&remote_high, 1, MPI_INT, 0, *(inter_comm.ep_comm_ptr->intercomm->local_comm));
-
-    int intercomm_high;
-    if(ep_rank == 0) intercomm_high = local_high;
-    MPI_Bcast(&intercomm_high, 1, MPI_INT, 0, inter_comm);
-
-    //printf("remote_ep_size = %d, local_high = %d, remote_high = %d, intercomm_high = %d\n", remote_ep_size, local_high, remote_high, intercomm_high);
-
-
-    ::MPI_Comm mpi_intracomm;
-    MPI_Comm *ep_intracomm;
-
-    if(ep_rank_loc == 0)
-    {
-
-      ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(inter_comm.ep_comm_ptr->intercomm->mpi_inter_comm);
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
-      ::MPI_Intercomm_merge(mpi_comm, intercomm_high, &mpi_intracomm);
-      MPI_Info info;
-      MPI_Comm_create_endpoints(mpi_intracomm, num_ep, info, ep_intracomm);
-
-      inter_comm.ep_comm_ptr->comm_list->mem_bridge = ep_intracomm;
-
-    }
-
-
-
-    MPI_Barrier_local(inter_comm);
-
-    *newintracomm = inter_comm.ep_comm_ptr->comm_list->mem_bridge[ep_rank_loc];
-
-    int my_ep_rank = local_high<remote_high? local_ep_rank: local_ep_rank+remote_ep_size;
-
-    int intra_ep_rank, intra_ep_rank_loc, intra_mpi_rank;
-    int intra_ep_size, intra_num_ep, intra_mpi_size;
-
-    intra_ep_rank = newintracomm->ep_comm_ptr->size_rank_info[0].first;
-    intra_ep_rank_loc = newintracomm->ep_comm_ptr->size_rank_info[1].first;
-    intra_mpi_rank = newintracomm->ep_comm_ptr->size_rank_info[2].first;
-    intra_ep_size = newintracomm->ep_comm_ptr->size_rank_info[0].second;
-    intra_num_ep = newintracomm->ep_comm_ptr->size_rank_info[1].second;
-    intra_mpi_size = newintracomm->ep_comm_ptr->size_rank_info[2].second;
-
-
-
-    MPI_Barrier_local(*newintracomm);
-
-
-    int *reorder;
-    if(intra_ep_rank_loc == 0)
-    {
-      reorder = new int[intra_ep_size];
-    }
-
-
-
-    MPI_Gather(&my_ep_rank, 1, MPI_INT, reorder, 1, MPI_INT, 0, *newintracomm);
-    if(intra_ep_rank_loc == 0)
-    {
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
-      ::MPI_Bcast(reorder, intra_ep_size, MPI_INT_STD, 0, static_cast< ::MPI_Comm>(newintracomm->mpi_comm));
-
-      vector< pair<int, int> > tmp_rank_map(intra_ep_size);
-
-
-      for(int i=0; i<intra_ep_size; i++)
-      {
-        tmp_rank_map[reorder[i]] = newintracomm->rank_map->at(i) ;
-      }
-
-      newintracomm->rank_map->swap(tmp_rank_map);
-
-      tmp_rank_map.clear();
-    }
-
-    MPI_Barrier_local(*newintracomm);
-
-    (*newintracomm).ep_comm_ptr->size_rank_info[0].first = my_ep_rank;
-
 
     if(intra_ep_rank_loc == 0)
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_probe.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_probe.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_probe.cpp	(revision 1053)
@@ -34,5 +34,6 @@
 
     #pragma omp flush
-    #pragma critical (_query)
+
+    #pragma omp critical (_query)
     if(comm.ep_comm_ptr->message_queue->size() > 0)
     {
@@ -104,5 +105,6 @@
 
     #pragma omp flush
-    #pragma critical (_query)
+
+    #pragma omp critical (_query)
     if(comm.ep_comm_ptr->message_queue->size() > 0)
     {
@@ -127,5 +129,5 @@
           message->ep_src = it->ep_src;
 
-          #pragma omp critical (_query)
+          #pragma omp critical (_query2)
           {              
             //printf("local message erased. src = %d, dest = %d, tag = %d\n", it->ep_src, it->ep_dest, it->ep_tag);     
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_rank.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_rank.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_rank.cpp	(revision 1053)
@@ -28,5 +28,5 @@
 
 
-    if(comm.mpi_comm)
+    if(comm != MPI_COMM_NULL)
     {
       ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm > (comm.mpi_comm);
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_recv.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_recv.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_recv.cpp	(revision 1053)
@@ -68,5 +68,5 @@
 		
 
-		request->mpi_request = NULL;
+		request->mpi_request = MPI_REQUEST_NULL_STD;
 		request->buf = buf;
     request->comm = comm;
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_reduce.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_reduce.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_reduce.cpp	(revision 1053)
@@ -447,7 +447,4 @@
     if(!comm.is_ep && comm.mpi_comm)
     {
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Reduce(sendbuf, recvbuf, count, static_cast< ::MPI_Datatype>(datatype), static_cast< ::MPI_Op>(op), root,
                    static_cast< ::MPI_Comm>(comm.mpi_comm));
@@ -473,7 +470,5 @@
 
     ::MPI_Aint recvsize, lb;
-    #ifdef _serialized
-    #pragma omp critical (_mpi_call)
-    #endif // _serialized
+
     ::MPI_Type_get_extent(static_cast< ::MPI_Datatype>(datatype), &lb, &recvsize);
 
@@ -489,7 +484,4 @@
     if(ep_rank_loc==0)
     {
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Reduce(local_recvbuf, recvbuf, count, static_cast< ::MPI_Datatype>(datatype), static_cast< ::MPI_Op>(op), root_mpi_rank, static_cast< ::MPI_Comm>(comm.mpi_comm));
     }
@@ -522,7 +514,4 @@
     if(!comm.is_ep && comm.mpi_comm)
     {
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Allreduce(sendbuf, recvbuf, count, static_cast< ::MPI_Datatype>(datatype), static_cast< ::MPI_Op>(op),
                       static_cast< ::MPI_Comm>(comm.mpi_comm));
@@ -545,7 +534,5 @@
 
     ::MPI_Aint recvsize, lb;
-    #ifdef _serialized
-    #pragma omp critical (_mpi_call)
-    #endif // _serialized
+
     ::MPI_Type_get_extent(static_cast< ::MPI_Datatype>(datatype), &lb, &recvsize);
 
@@ -561,7 +548,4 @@
     if(ep_rank_loc==0)
     {
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Allreduce(local_recvbuf, recvbuf, count, static_cast< ::MPI_Datatype>(datatype), static_cast< ::MPI_Op>(op), static_cast< ::MPI_Comm>(comm.mpi_comm));
     }
@@ -590,7 +574,4 @@
     if(!comm.is_ep && comm.mpi_comm)
     {
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Reduce_scatter(sendbuf, recvbuf, recvcounts, static_cast< ::MPI_Datatype>(datatype), static_cast< ::MPI_Op>(op),
                            static_cast< ::MPI_Comm>(comm.mpi_comm));
@@ -616,7 +597,5 @@
 
     ::MPI_Aint datasize, lb;
-    #ifdef _serialized
-    #pragma omp critical (_mpi_call)
-    #endif // _serialized
+
     ::MPI_Type_get_extent(static_cast< ::MPI_Datatype>(datatype), &lb, &datasize);
 
@@ -636,7 +615,5 @@
         local_recvcnt[i] = accumulate(recvcounts+ep_rank, recvcounts+ep_rank+num_ep, 0);
       }
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
+
       ::MPI_Reduce_scatter(local_buf, local_buf2, local_recvcnt, static_cast< ::MPI_Datatype>(datatype),
                          static_cast< ::MPI_Op>(op), static_cast< ::MPI_Comm>(comm.mpi_comm));
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_scan.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_scan.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_scan.cpp	(revision 1053)
@@ -432,7 +432,5 @@
     if(!comm.is_ep)
     {
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
+
       ::MPI_Scan(sendbuf, recvbuf, count, static_cast< ::MPI_Datatype>(datatype),
                  static_cast< ::MPI_Op>(op), static_cast< ::MPI_Comm>(comm.mpi_comm));
@@ -455,7 +453,5 @@
 
     ::MPI_Aint datasize, lb;
-    #ifdef _serialized
-    #pragma omp critical (_mpi_call)
-    #endif // _serialized
+
     ::MPI_Type_get_extent(static_cast< ::MPI_Datatype>(datatype), &lb, &datasize);
 
@@ -484,7 +480,4 @@
     if(ep_rank_loc == 0)
     {
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Exscan(local_sum, mpi_scan_recvbuf, count, static_cast< ::MPI_Datatype>(datatype), static_cast< ::MPI_Op>(op), static_cast< ::MPI_Comm>(comm.mpi_comm));
     }
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_scatter.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_scatter.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_scatter.cpp	(revision 1053)
@@ -287,7 +287,4 @@
     if(!comm.is_ep)
     {
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Scatter(sendbuf, sendcount, static_cast< ::MPI_Datatype>(sendtype), recvbuf, recvcount, static_cast< ::MPI_Datatype>(recvtype),
                     root, static_cast< ::MPI_Comm>(comm.mpi_comm));
@@ -317,7 +314,5 @@
 
     ::MPI_Aint datasize, lb;
-    #ifdef _serialized
-    #pragma omp critical (_mpi_call)
-    #endif // _serialized
+
     ::MPI_Type_get_extent(static_cast< ::MPI_Datatype>(datatype), &lb, &datasize);
 
@@ -343,7 +338,4 @@
       local_recvbuf = new void*[datasize*mpi_sendcnt];
 
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Gather(&mpi_sendcnt, 1, MPI_INT_STD, mpi_scatterv_sendcnt, 1, MPI_INT_STD, root_mpi_rank, static_cast< ::MPI_Comm>(comm.mpi_comm));
 
@@ -355,7 +347,4 @@
       if(root_ep_loc!=0)
       {
-        #ifdef _serialized
-        #pragma omp critical (_mpi_call)
-        #endif // _serialized
         ::MPI_Scatterv(master_sendbuf, mpi_scatterv_sendcnt, displs, static_cast< ::MPI_Datatype>(datatype),
                      local_recvbuf, mpi_sendcnt, static_cast< ::MPI_Datatype>(datatype), root_mpi_rank, static_cast< ::MPI_Comm>(comm.mpi_comm));
@@ -363,7 +352,4 @@
       else
       {
-        #ifdef _serialized
-        #pragma omp critical (_mpi_call)
-        #endif // _serialized
         ::MPI_Scatterv(sendbuf, mpi_scatterv_sendcnt, displs, static_cast< ::MPI_Datatype>(datatype),
                      local_recvbuf, mpi_sendcnt, static_cast< ::MPI_Datatype>(datatype), root_mpi_rank, static_cast< ::MPI_Comm>(comm.mpi_comm));
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_scatterv.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_scatterv.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_scatterv.cpp	(revision 1053)
@@ -296,7 +296,4 @@
     if(!comm.is_ep)
     {
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Scatterv(sendbuf, sendcounts, displs, static_cast< ::MPI_Datatype>(sendtype), recvbuf, recvcount,
                      static_cast< ::MPI_Datatype>(recvtype), root, static_cast< ::MPI_Comm>(comm.mpi_comm));
@@ -329,7 +326,5 @@
 
     ::MPI_Aint datasize, lb;
-    #ifdef _serialized
-    #pragma omp critical (_mpi_call)
-    #endif // _serialized
+
     ::MPI_Type_get_extent(static_cast< ::MPI_Datatype>(datatype), &lb, &datasize);
 
@@ -358,7 +353,4 @@
       local_recvbuf = new void*[datasize*mpi_sendcnt];
 
-      #ifdef _serialized
-      #pragma omp critical (_mpi_call)
-      #endif // _serialized
       ::MPI_Gather(&mpi_sendcnt, 1, MPI_INT_STD, mpi_scatterv_sendcnt, 1, MPI_INT_STD, root_mpi_rank, static_cast< ::MPI_Comm>(comm.mpi_comm));
 
@@ -370,7 +362,4 @@
       if(root_ep_loc!=0)
       {
-        #ifdef _serialized
-        #pragma omp critical (_mpi_call)
-        #endif // _serialized
         ::MPI_Scatterv(master_sendbuf, mpi_scatterv_sendcnt, mpi_displs, static_cast< ::MPI_Datatype>(datatype),
                      local_recvbuf, mpi_sendcnt, static_cast< ::MPI_Datatype>(datatype), root_mpi_rank, static_cast< ::MPI_Comm>(comm.mpi_comm));
@@ -378,7 +367,4 @@
       else
       {
-        #ifdef _serialized
-        #pragma omp critical (_mpi_call)
-        #endif // _serialized
         ::MPI_Scatterv(sendbuf, mpi_scatterv_sendcnt, mpi_displs, static_cast< ::MPI_Datatype>(datatype),
                      local_recvbuf, mpi_sendcnt, static_cast< ::MPI_Datatype>(datatype), root_mpi_rank, static_cast< ::MPI_Comm>(comm.mpi_comm));
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_send.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_send.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_send.cpp	(revision 1053)
@@ -82,5 +82,5 @@
     // EP intracomm
 
-    check_sum_send(buf, count, datatype, dest, tag, comm, 1);
+    //check_sum_send(buf, count, datatype, dest, tag, comm, 1);
 
     int ep_src_loc = comm.ep_comm_ptr->size_rank_info[1].first;
@@ -139,5 +139,5 @@
     // EP intracomm
 
-    check_sum_send(buf, count, datatype, dest, tag, comm, 1);
+    //check_sum_send(buf, count, datatype, dest, tag, comm, 1);
 
     int ep_src_loc = comm.ep_comm_ptr->size_rank_info[1].first;
@@ -171,5 +171,5 @@
     Debug("MPI_Isend with intercomm\n");
 
-    check_sum_send(buf, count, datatype, dest, tag, comm, 1);
+    //check_sum_send(buf, count, datatype, dest, tag, comm, 1);
 
     int dest_remote_ep_rank    = comm.ep_comm_ptr->intercomm->remote_rank_map->at(dest).first;
@@ -244,5 +244,5 @@
     Debug("MPI_Issend with intercomm\n");
 
-    check_sum_send(buf, count, datatype, dest, tag, comm, 1);
+    //check_sum_send(buf, count, datatype, dest, tag, comm, 1);
 
     int dest_remote_ep_rank    = comm.ep_comm_ptr->intercomm->remote_rank_map->at(dest).first;
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_size.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_size.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_size.cpp	(revision 1053)
@@ -31,5 +31,5 @@
     Debug("Calling EP_Comm_size\n");
 
-    if(comm.mpi_comm)
+    if(comm.mpi_comm != MPI_COMM_NULL_STD)
     {
       ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm > (comm.mpi_comm); 
@@ -54,10 +54,7 @@
     if(!comm.is_ep)
     {
-      if(comm.mpi_comm)
+      if(comm.mpi_comm != MPI_COMM_NULL_STD)
       {
         ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm > (comm.mpi_comm); 
-        #ifdef _serialized
-        #pragma omp critical (_mpi_call)
-        #endif // _serialized
         ::MPI_Comm_remote_size(mpi_comm, size);
         return 0;
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_split.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_split.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_split.cpp	(revision 1053)
@@ -144,7 +144,5 @@
         int master_color = 1;
         if(matched_number_loc[j] == 0) master_color = MPI_UNDEFINED;
-        #ifdef _serialized
-        #pragma omp critical (_mpi_call)
-        #endif // _serialized
+
         ::MPI_Comm_split(static_cast< ::MPI_Comm>(comm.mpi_comm), master_color, mpi_rank, &split_mpi_comm[j]);
         
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_test.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_test.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_test.cpp	(revision 1053)
@@ -63,9 +63,9 @@
         status->mpi_status = new ::MPI_Status(mpi_status);
         status->ep_src = request->ep_src;
-      status->ep_tag = request->ep_tag;
-      status->ep_datatype = request->ep_datatype;
+        status->ep_tag = request->ep_tag;
+        status->ep_datatype = request->ep_datatype;
         int count;
         MPI_Get_count(status, request->ep_datatype, &count);
-        check_sum_recv(request->buf, count, request->ep_datatype, request->ep_src, request->ep_tag, request->comm, 2);
+        //check_sum_recv(request->buf, count, request->ep_datatype, request->ep_src, request->ep_tag, request->comm, 2);
       }
 
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_type.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_type.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_type.cpp	(revision 1053)
@@ -6,10 +6,15 @@
 
 ::MPI_Comm MPI_COMM_WORLD_STD = MPI_COMM_WORLD;
-//#undef MPI_COMM_WORLD
+#undef MPI_COMM_WORLD
 
 
 ::MPI_Comm MPI_COMM_NULL_STD = MPI_COMM_NULL;
-//#undef MPI_COMM_NULL
+#undef MPI_COMM_NULL
 
+//::MPI_Info MPI_INFO_NULL_STD = MPI_INFO_NULL;
+//#undef MPI_INFO_NULL
+
+::MPI_Request MPI_REQUEST_NULL_STD = MPI_REQUEST_NULL;
+#undef MPI_REQUEST_NULL
 
 ::MPI_Datatype MPI_INT_STD = MPI_INT;
@@ -30,14 +35,4 @@
 
 
-//ep_lib::MPI_Datatype MPI_INT = MPI_INT_STD;
-//ep_lib::MPI_Datatype MPI_FLOAT = MPI_FLOAT_STD;
-//ep_lib::MPI_Datatype MPI_DOUBLE = MPI_DOUBLE_STD;
-//ep_lib::MPI_Datatype MPI_LONG = MPI_LONG_STD;
-//ep_lib::MPI_Datatype MPI_CHAR = MPI_CHAR_STD;
-//ep_lib::MPI_Datatype MPI_UNSIGNED_LONG = MPI_UNSIGNED_LONG_STD;
-
-
-
-
 ::MPI_Op MPI_SUM_STD = MPI_SUM;
 ::MPI_Op MPI_MAX_STD = MPI_MAX;
@@ -48,43 +43,7 @@
 #undef MPI_MIN
 
-//ep_lib::MPI_Op MPI_SUM = MPI_SUM_STD;
-//ep_lib::MPI_Op MPI_MAX = MPI_MAX_STD;
-//ep_lib::MPI_Op MPI_MIN = MPI_MIN_STD;
-
-//  ep_lib::MPI_Comm::MPI_Comm(const MPI_Comm & comm)
-//  {
-//    printf("calling MPI_Comm copy constructor\n");
-//    is_ep = comm.is_ep;
-//    is_intercomm = comm.is_intercomm;
-
-//    int my_rank = comm.ep_comm_ptr->size_rank_info[1].first;
-//    int num_ep  = comm.ep_comm_ptr->size_rank_info[1].second;
-
-
-//    if(0 == my_rank)
-//    {
-//      MPI_Info info;
-//      MPI_Comm *out_comm;
-//      ::MPI_Comm mpi_dup;
-
-//      ::MPI_Comm in_comm = static_cast< ::MPI_Comm>(comm.mpi_comm);
-
-//      ::MPI_Comm_dup(in_comm, &mpi_dup);
-
-//      MPI_Comm_create_endpoints(mpi_dup, num_ep, info, out_comm);
-//      comm.ep_comm_ptr->comm_list->mem_bridge = out_comm;
-//    }
-
-//    MPI_Barrier(comm);
-
-//    *this = (comm.ep_comm_ptr->comm_list->mem_bridge[my_rank]);
-// //       // my_buffer = NULL;
-// //       // ep_barrier = NULL;
-// //       // rank_map = NULL;
-// //       // ep_comm_ptr = NULL;
-// //       // mem_bridge = NULL;
-// //       // mpi_bridge = NULL;
-// //       // mpi_comm = comm;
-// }
+#ifdef _openmpi
+//#undef MPI_Fint
+#endif
 
 
@@ -97,2 +56,3 @@
 
 
+
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_type.hpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_type.hpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_type.hpp	(revision 1053)
@@ -12,5 +12,5 @@
 #include <numeric>
 #include <bitset>
-#include <memory.h>
+//#include <memory.h>
 #include <algorithm>
 #include <assert.h>
@@ -42,6 +42,6 @@
 {
   #define MPI_UNDEFINED -32766
-  #define MPI_STATUS_IGNORE NULL
-  #define MPI_INFO_NULL MPI_Info()
+  //#define MPI_STATUS_IGNORE NULL
+  //#define MPI_INFO_NULL MPI_Info(MPI_INFO_NULL_STD)
 
   class ep_communicator;
@@ -84,9 +84,10 @@
       void* mpi_status;
 
-      MPI_Message()
-      {
-        mpi_message = 0;
-        mpi_status = 0;
-      }
+      MPI_Message() {}
+      #ifdef _intelmpi
+      MPI_Message(int message): mpi_message(message) {}
+      #elif _openmpi
+      MPI_Message(void* message): mpi_message(message) {}
+      #endif
   };
 
@@ -289,7 +290,7 @@
       mem_bridge = NULL;
       mpi_bridge = NULL;
-      mpi_comm = 0;
-    }
-
+    }
+
+    #ifdef _intelmpi
     MPI_Comm(int comm)
     {
@@ -305,5 +306,19 @@
     }
 
-    //MPI_Comm(const MPI_Comm &comm);
+    #elif _openmpi
+
+    MPI_Comm(void* comm)
+    {
+      is_ep = false;
+      is_intercomm = false;
+      my_buffer = NULL;
+      ep_barrier = NULL;
+      rank_map = NULL;
+      ep_comm_ptr = NULL;
+      mem_bridge = NULL;
+      mpi_bridge = NULL;
+      mpi_comm = comm;
+    }
+    #endif
 
 
@@ -338,8 +353,11 @@
       #endif
 
-      MPI_Info()
-      {
-        mpi_info = 0;
-      }
+      MPI_Info() {}
+      
+      #ifdef _intelmpi
+      MPI_Info(int info): mpi_info(info) {}
+      #elif _openmpi
+      MPI_Info(void* info): mpi_info(info) {}
+      #endif
   };
 
@@ -368,8 +386,22 @@
       MPI_Comm comm;	//! EP communicator related to the communication
 
-      MPI_Request()
-      {
-        mpi_request = 0;
-      }
+      MPI_Request() {}
+
+      #ifdef _intelmpi
+      MPI_Request(int request): mpi_request(request) {}
+      #elif _openmpi
+      MPI_Request(void* request): mpi_request(request) {}
+      #endif
+  };
+
+  
+  class MPI_Aint
+  {
+    public:
+
+    unsigned long mpi_aint;
+
+    MPI_Aint() {}
+    MPI_Aint(int a): mpi_aint(a) {}
   };
 
@@ -379,11 +411,8 @@
 
     int mpi_fint;
-  };
-
-  class MPI_Aint
-  {
-    public:
-
-    unsigned long mpi_aint;
+
+    MPI_Fint() {}
+    MPI_Fint(int f): mpi_fint(f) {}
+    
   };
 
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_wait.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_wait.cpp	(revision 1037)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_wait.cpp	(revision 1053)
@@ -52,5 +52,5 @@
       status->ep_datatype = request->ep_datatype;
 
-      check_sum_recv(request->buf, count, request->ep_datatype, request->ep_src, request->ep_tag, request->comm, 2);
+      //check_sum_recv(request->buf, count, request->ep_datatype, request->ep_src, request->ep_tag, request->comm, 2);
 
       return 0;
@@ -70,5 +70,5 @@
       int count;
       MPI_Get_count(status, request->ep_datatype, &count);
-      check_sum_recv(request->buf, count, request->ep_datatype, request->ep_src, request->ep_tag, request->comm, 2);
+      //check_sum_recv(request->buf, count, request->ep_datatype, request->ep_src, request->ep_tag, request->comm, 2);
     }
 	  return MPI_SUCCESS;
@@ -106,5 +106,5 @@
               int check_count;
               MPI_Get_count(&array_of_statuses[i], array_of_requests[i].ep_datatype, &check_count);
-              check_sum_recv(array_of_requests[i].buf, count, array_of_requests[i].ep_datatype, array_of_requests[i].ep_src, array_of_requests[i].ep_tag, array_of_requests[i].comm, 2);
+              //check_sum_recv(array_of_requests[i].buf, count, array_of_requests[i].ep_datatype, array_of_requests[i].ep_src, array_of_requests[i].ep_tag, array_of_requests[i].comm, 2);
             }
             finished++;
@@ -124,5 +124,5 @@
               MPI_Get_count(&array_of_statuses[i], array_of_requests[i].ep_datatype, &recv_count);
               MPI_Mrecv(array_of_requests[i].buf, recv_count, array_of_requests[i].ep_datatype, &message, &array_of_statuses[i]);
-              check_sum_recv(array_of_requests[i].buf, recv_count, array_of_requests[i].ep_datatype, array_of_requests[i].ep_src, array_of_requests[i].ep_tag, array_of_requests[i].comm, 2);
+              //check_sum_recv(array_of_requests[i].buf, recv_count, array_of_requests[i].ep_datatype, array_of_requests[i].ep_src, array_of_requests[i].ep_tag, array_of_requests[i].comm, 2);
 
               finished++;
