Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_barrier.cpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_barrier.cpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_barrier.cpp	(revision 1499)
@@ -61,4 +61,5 @@
   int MPI_Barrier_local(MPI_Comm comm)
   {
+    //Message_Check(comm);
     comm.ep_barrier->wait();
   }
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_create.cpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_create.cpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_create.cpp	(revision 1499)
@@ -14,4 +14,168 @@
 
 namespace ep_lib {
+
+  /*!
+    Dynamic creation of endpoints for each MPI process.
+    The output of this function is an array of communicator handles of length num_ep, where each handle
+    corresponds to a nez local randk in the output communicator.
+    Once created, endpoints behave as MPI processes.
+    \param [in] mpi_comm Parent MPI communicator.
+    \param [in] num_ep Number of endpoints per process.
+    \param [out] info Information of the EP creation.
+    \param [out] out_comm_hdls Handles of EP communicators.
+  */
+  // #ifdef _intelmpi
+  // int MPI_Comm_create_endpoints(int base_comm_ptr, int num_ep, MPI_Info info, MPI_Comm *& out_comm_hdls)
+  // {
+  //   int base_rank;
+  //   int base_size;
+
+  //   ::MPI_Comm mpi_base_comm = static_cast< ::MPI_Comm> (base_comm_ptr);
+
+  //   ::MPI_Comm_size(mpi_base_comm, &base_size);  // ep_lib::mpi_comm_size
+  //   ::MPI_Comm_rank(mpi_base_comm, &base_rank);  // ep_lib::mpi_comm_rank
+		// 							  // parent_comm can also be endpoints communicators
+
+  //   std::vector<int> recv_num_ep(base_size);
+
+  //   out_comm_hdls = new MPI_Comm[num_ep];
+
+  //   for (int idx = 0; idx < num_ep; ++idx)
+  //   {
+  //     out_comm_hdls[idx].is_ep = true;
+  //     out_comm_hdls[idx].is_intercomm = false;
+  //     out_comm_hdls[idx].ep_comm_ptr = new ep_communicator;
+  //     out_comm_hdls[idx].mpi_comm = base_comm_ptr;
+  //     out_comm_hdls[idx].ep_comm_ptr->comm_list = out_comm_hdls;
+  //     out_comm_hdls[idx].ep_comm_ptr->comm_label = 0;
+  //   }
+
+  //   ::MPI_Allgather(&num_ep, 1, static_cast< ::MPI_Datatype>(MPI_INT), &recv_num_ep[0], 1, static_cast< ::MPI_Datatype>(MPI_INT), mpi_base_comm);
+
+
+  //   int sum = 0;  // representing total ep number of process with smaller rank
+  //   for (int i = 0; i < base_rank; ++i) {sum += recv_num_ep[i]; }
+
+  //   int ep_size = std::accumulate(recv_num_ep.begin(), recv_num_ep.end(), 0);
+
+  //   out_comm_hdls[0].ep_barrier = new OMPbarrier(num_ep);
+
+  //   out_comm_hdls[0].my_buffer = new BUFFER;
+
+  //   out_comm_hdls[0].rank_map = new RANK_MAP;
+  //   out_comm_hdls[0].rank_map->resize(ep_size);
+
+
+  //   for (int i = 1; i < num_ep; i++)
+  //   {
+  //     out_comm_hdls[i].ep_barrier = out_comm_hdls[0].ep_barrier;
+  //     out_comm_hdls[i].my_buffer  = out_comm_hdls[0].my_buffer;
+  //     out_comm_hdls[i].rank_map   = out_comm_hdls[0].rank_map;
+  //   }
+
+
+  //   for (int i = 0; i < num_ep; i++)
+  //   {
+  //     out_comm_hdls[i].ep_comm_ptr->size_rank_info[0] = std::make_pair(sum+i, ep_size);
+  //     out_comm_hdls[i].ep_comm_ptr->size_rank_info[1] = std::make_pair(i, num_ep);
+  //     out_comm_hdls[i].ep_comm_ptr->size_rank_info[2] = std::make_pair(base_rank, base_size);
+
+  //     out_comm_hdls[i].ep_comm_ptr->message_queue = new Message_list;
+  //   }
+
+
+  //   int ind = 0;
+
+  //   for(int i=0; i<base_size; i++)
+  //   {
+  //     for(int j=0; j<recv_num_ep[i]; j++)
+  //     {
+  //       out_comm_hdls[0].rank_map->at(ind) = make_pair(j, i);
+  //       ind++;
+  //     }
+  //   }
+
+
+
+  //   return 0;
+
+  // } //MPI_Comm_create_endpoints
+
+  // #elif _openmpi
+  // int MPI_Comm_create_endpoints(void* base_comm_ptr, int num_ep, MPI_Info info, MPI_Comm *& out_comm_hdls)
+  // {
+
+  //   int base_rank;
+  //   int base_size;
+
+  //   ::MPI_Comm mpi_base_comm = static_cast< ::MPI_Comm> (base_comm_ptr);
+
+  //   ::MPI_Comm_size(mpi_base_comm, &base_size);  // ep_lib::mpi_comm_size
+  //   ::MPI_Comm_rank(mpi_base_comm, &base_rank);  // ep_lib::mpi_comm_rank
+  //                                                // parent_comm can also be endpoints communicators ?
+  //   std::vector<int> recv_num_ep(base_size);
+
+  //   out_comm_hdls = new MPI_Comm[num_ep];
+
+  //   for (int idx = 0; idx < num_ep; ++idx)
+  //   {
+  //     out_comm_hdls[idx].is_ep = true;
+  //     out_comm_hdls[idx].is_intercomm = false;
+  //     out_comm_hdls[idx].ep_comm_ptr = new ep_communicator;
+  //     out_comm_hdls[idx].mpi_comm = base_comm_ptr;
+  //     out_comm_hdls[idx].ep_comm_ptr->comm_list = out_comm_hdls;
+  //     out_comm_hdls[idx].ep_comm_ptr->comm_label = 0;
+  //   }
+
+  //   ::MPI_Allgather(&num_ep, 1, static_cast< ::MPI_Datatype> (MPI_INT), 
+  //                  &recv_num_ep[0], 1, static_cast< ::MPI_Datatype> (MPI_INT), mpi_base_comm);
+
+  //   int sum = 0;  // representing total ep number of process with smaller rank
+  //   for (int i = 0; i < base_rank; ++i) {sum += recv_num_ep[i]; }
+
+  //   int ep_size = std::accumulate(recv_num_ep.begin(), recv_num_ep.end(), 0);
+
+  //   out_comm_hdls[0].ep_barrier = new OMPbarrier(num_ep);
+  //   out_comm_hdls[0].my_buffer = new BUFFER;
+
+  //   out_comm_hdls[0].rank_map = new RANK_MAP;
+  //   out_comm_hdls[0].rank_map->resize(ep_size);
+
+
+  //   for (int i = 1; i < num_ep; i++)
+  //   {
+  //     out_comm_hdls[i].ep_barrier = out_comm_hdls[0].ep_barrier;
+  //     out_comm_hdls[i].my_buffer  = out_comm_hdls[0].my_buffer;
+  //     out_comm_hdls[i].rank_map   = out_comm_hdls[0].rank_map;
+  //   }
+
+
+  //   for (int i = 0; i < num_ep; i++)
+  //   {
+  //     out_comm_hdls[i].ep_comm_ptr->size_rank_info[0] = std::make_pair(sum+i, ep_size);
+  //     out_comm_hdls[i].ep_comm_ptr->size_rank_info[1] = std::make_pair(i, num_ep);
+  //     out_comm_hdls[i].ep_comm_ptr->size_rank_info[2] = std::make_pair(base_rank, base_size);
+
+  //     out_comm_hdls[i].ep_comm_ptr->message_queue = new Message_list;
+  //   }
+
+
+  //   int ind = 0;
+
+  //   for(int i=0; i<base_size; i++)
+  //   {
+  //     for(int j=0; j<recv_num_ep[i]; j++)
+  //     {
+  //       out_comm_hdls[0].rank_map->at(ind) = make_pair(j, i);
+  //       ind++;
+  //     }
+  //   }
+
+  //   return 0;
+
+  // } //MPI_Comm_create_endpoints
+
+  // #endif
+  
   
   int MPI_Comm_create_endpoints(void* base_comm_ptr, int num_ep, MPI_Info info, MPI_Comm *& out_comm_hdls)
@@ -26,8 +190,6 @@
     ::MPI_Comm_rank(mpi_base_comm, &base_rank);  // ep_lib::mpi_comm_rank
                     // parent_comm can also be endpoints communicators
-    
+
     std::vector<int> recv_num_ep(base_size);
-
-
 
     out_comm_hdls = new MPI_Comm[num_ep];
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_declaration.cpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_declaration.cpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_declaration.cpp	(revision 1499)
@@ -24,4 +24,6 @@
 ::MPI_Datatype MPI_UNSIGNED_LONG_STD = MPI_UNSIGNED_LONG;
 ::MPI_Datatype MPI_UNSIGNED_CHAR_STD = MPI_UNSIGNED_CHAR;
+::MPI_Datatype MPI_UINT64_T_STD = MPI_UINT64_T;
+::MPI_Datatype MPI_LONG_LONG_INT_STD = MPI_LONG_LONG_INT;
 
 #undef MPI_INT
@@ -32,4 +34,6 @@
 #undef MPI_UNSIGNED_LONG
 #undef MPI_UNSIGNED_CHAR
+#undef MPI_UINT64_T
+#undef MPI_LONG_LONG_INT
 
 
@@ -37,4 +41,5 @@
 ::MPI_Op MPI_MAX_STD = MPI_MAX;
 ::MPI_Op MPI_MIN_STD = MPI_MIN;
+::MPI_Op MPI_LOR_STD = MPI_LOR;
 ::MPI_Op MPI_REPLACE_STD = MPI_REPLACE;
 
@@ -42,6 +47,6 @@
 #undef MPI_MAX
 #undef MPI_MIN
+#undef MPI_LOR
 #undef MPI_REPLACE
-
 
 
@@ -55,8 +60,12 @@
 extern ::MPI_Datatype MPI_UNSIGNED_LONG_STD;
 extern ::MPI_Datatype MPI_UNSIGNED_CHAR_STD;
+extern ::MPI_Datatype MPI_UINT64_T_STD;
+extern ::MPI_Datatype MPI_LONG_LONG_INT_STD;
+
 
 extern ::MPI_Op MPI_SUM_STD;
 extern ::MPI_Op MPI_MAX_STD;
 extern ::MPI_Op MPI_MIN_STD;
+extern ::MPI_Op MPI_LOR_STD;
 extern ::MPI_Op MPI_REPLACE_STD;
 
@@ -75,8 +84,12 @@
 ep_lib::MPI_Datatype MPI_UNSIGNED_LONG = &MPI_UNSIGNED_LONG_STD;
 ep_lib::MPI_Datatype MPI_UNSIGNED_CHAR = &MPI_UNSIGNED_CHAR_STD;
+ep_lib::MPI_Datatype MPI_UINT64_T = &MPI_UINT64_T_STD;
+ep_lib::MPI_Datatype MPI_LONG_LONG_INT = &MPI_LONG_LONG_INT_STD;
+
 
 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_Op MPI_LOR = &MPI_LOR_STD;
 ep_lib::MPI_Op MPI_REPLACE = &MPI_REPLACE_STD;
 
@@ -88,19 +101,4 @@
 
 
-int MPI_MODE_NOPRECEDE_STD = MPI_MODE_NOPRECEDE;
-int MPI_MODE_NOCHECK_STD   = MPI_MODE_NOCHECK;
-int MPI_MODE_NOPUT_STD     = MPI_MODE_NOPUT;
-int MPI_MODE_NOSTORE_STD   = MPI_MODE_NOSTORE;
-int MPI_MODE_NOSUCCEED_STD = MPI_MODE_NOSUCCEED;
 
-#undef MPI_MODE_NOPRECEDE
-#undef MPI_MODE_NOCHECK
-#undef MPI_MODE_NOPUT
-#undef MPI_MODE_NOSTORE
-#undef MPI_MODE_NOSUCCEED
 
-int MPI_MODE_NOPRECEDE = MPI_MODE_NOPRECEDE_STD;
-int MPI_MODE_NOCHECK = MPI_MODE_NOCHECK_STD;
-int MPI_MODE_NOPUT = MPI_MODE_NOPUT_STD;
-int MPI_MODE_NOSTORE = MPI_MODE_NOSTORE_STD;
-int MPI_MODE_NOSUCCEED = MPI_MODE_NOSUCCEED_STD;
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_declaration.hpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_declaration.hpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_declaration.hpp	(revision 1499)
@@ -9,8 +9,11 @@
 #undef MPI_UNSIGNED_LONG
 #undef MPI_UNSIGNED_CHAR
+#undef MPI_UINT64_T
+#undef MPI_LONG_LONG_INT
 
 #undef MPI_SUM
 #undef MPI_MAX
 #undef MPI_MIN
+#undef MPI_LOR
 #undef MPI_REPLACE
 
@@ -29,8 +32,11 @@
 extern ep_lib::MPI_Datatype MPI_UNSIGNED_LONG;
 extern ep_lib::MPI_Datatype MPI_UNSIGNED_CHAR;
+extern ep_lib::MPI_Datatype MPI_UINT64_T;
+extern ep_lib::MPI_Datatype MPI_LONG_LONG_INT;
 
 extern ep_lib::MPI_Op MPI_SUM;
 extern ep_lib::MPI_Op MPI_MAX;
 extern ep_lib::MPI_Op MPI_MIN;
+extern ep_lib::MPI_Op MPI_LOR;
 extern ep_lib::MPI_Op MPI_REPLACE;
 
@@ -43,6 +49,4 @@
 
 
-
-
 #endif // EP_DECLARATION_HPP_INCLUDED
 
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_dup.cpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_dup.cpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_dup.cpp	(revision 1499)
@@ -94,7 +94,24 @@
         out_comm[i].ep_comm_ptr->intercomm->remote_rank_map = new RANK_MAP;
 
-        out_comm[i].ep_comm_ptr->intercomm->intercomm_rank_map = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->intercomm_rank_map;
-        out_comm[i].ep_comm_ptr->intercomm->local_rank_map = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->local_rank_map;
-        out_comm[i].ep_comm_ptr->intercomm->remote_rank_map = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->remote_rank_map;
+        int map_size = 0;
+        map_size = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->intercomm_rank_map->size();
+        out_comm[i].ep_comm_ptr->intercomm->intercomm_rank_map->resize(map_size);
+        for(int ii=0; ii<map_size; ii++)
+          out_comm[i].ep_comm_ptr->intercomm->intercomm_rank_map->at(ii) = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->intercomm_rank_map->at(ii);
+
+        map_size = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->local_rank_map->size();
+        out_comm[i].ep_comm_ptr->intercomm->local_rank_map->resize(map_size);
+        for(int ii=0; ii<map_size; ii++)
+          out_comm[i].ep_comm_ptr->intercomm->local_rank_map->at(ii) = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->local_rank_map->at(ii);
+
+        map_size = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->remote_rank_map->size();
+        out_comm[i].ep_comm_ptr->intercomm->remote_rank_map->resize(map_size);
+        for(int ii=0; ii<map_size; ii++)
+          out_comm[i].ep_comm_ptr->intercomm->remote_rank_map->at(ii) = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->remote_rank_map->at(ii);
+
+
+        //out_comm[i].ep_comm_ptr->intercomm->intercomm_rank_map = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->intercomm_rank_map;
+        //out_comm[i].ep_comm_ptr->intercomm->local_rank_map = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->local_rank_map;
+        //out_comm[i].ep_comm_ptr->intercomm->remote_rank_map = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->remote_rank_map;
 
         out_comm[i].ep_comm_ptr->intercomm->local_comm = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->local_comm;        
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_free.cpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_free.cpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_free.cpp	(revision 1499)
@@ -9,5 +9,4 @@
   int MPI_Comm_free(MPI_Comm *comm)
   {
-
     if(! comm->is_ep)
     {
@@ -53,4 +52,5 @@
         {
           comm->rank_map->clear();
+          delete comm->rank_map;
           Debug("rank_map emptied\n");
         }
@@ -59,4 +59,5 @@
         {
           comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue->clear();
+          delete comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue;
           Debug("message queue freed\n");
           
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_gather.cpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_gather.cpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_gather.cpp	(revision 1499)
@@ -35,4 +35,6 @@
       for(int i=0; i<num_ep; i++)
         memcpy(recvbuf + datasize * i * count, comm.my_buffer->void_buffer[i], datasize * count);
+
+      //printf("local_recvbuf = %d %d \n", static_cast<int*>(recvbuf)[0], static_cast<int*>(recvbuf)[1] );
     }
 
@@ -101,4 +103,9 @@
     if(is_root)
     {
+      // printf("tmp_recvbuf = %d %d %d %d %d %d %d %d\n", static_cast<int*>(tmp_recvbuf)[0], static_cast<int*>(tmp_recvbuf)[1],
+      //                                                   static_cast<int*>(tmp_recvbuf)[2], static_cast<int*>(tmp_recvbuf)[3],
+      //                                                   static_cast<int*>(tmp_recvbuf)[4], static_cast<int*>(tmp_recvbuf)[5],
+      //                                                   static_cast<int*>(tmp_recvbuf)[6], static_cast<int*>(tmp_recvbuf)[7] );
+
       int offset;
       for(int i=0; i<ep_size; i++)
@@ -106,4 +113,6 @@
         offset = displs[comm.rank_map->at(i).second] + comm.rank_map->at(i).first * sendcount; 
         memcpy(recvbuf + i*sendcount*datasize, tmp_recvbuf+offset*datasize, sendcount*datasize);
+
+
       }
 
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_init.cpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_init.cpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_init.cpp	(revision 1499)
@@ -11,4 +11,6 @@
   int MPI_Init_thread(int *argc, char*** argv, int required, int*provided)
   {
+    //printf("MPI_Init_thread\n");
+
     int id = omp_get_thread_num();
 
@@ -22,4 +24,5 @@
   int MPI_Init(int *argc, char ***argv)
   {
+    //printf("MPI_init called\n");
     int id = omp_get_thread_num();
 
@@ -33,4 +36,6 @@
   int MPI_Initialized(int *flag)
   {
+    //printf("MPI_initialized called\n");
+
     ::MPI_Initialized(flag);
     
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_intercomm.cpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_intercomm.cpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_intercomm.cpp	(revision 1499)
@@ -24,4 +24,6 @@
 
     MPI_Barrier(local_comm);
+
+
 
     int leader_ranks[6]; //! 0: rank in world, 1: mpi_size, 2: rank_in_peer.
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_intercomm_kernel.cpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_intercomm_kernel.cpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_intercomm_kernel.cpp	(revision 1499)
@@ -116,4 +116,6 @@
 
       }
+
+
 
       send_buf[0] = size_info[1];
@@ -366,4 +368,5 @@
         #pragma omp critical (write_to_tag_list)
         tag_list.push_back(make_pair( make_pair(tag, min(leader_info[0], leader_info[1])) , ep_intercomm));
+        //printf("tag_list size = %lu\n", tag_list.size());
       }
     }
@@ -568,4 +571,10 @@
 //          (*newintercomm).rank_map->at(i).first, (*newintercomm).rank_map->at(i).second);
 
+//    MPI_Comm *test_comm = newintercomm->ep_comm_ptr->intercomm->local_comm;
+//    int test_rank;
+//    MPI_Comm_rank(*test_comm, &test_rank);
+//    printf("=================test_rank = %d\n", test_rank);
+    
+    
 
     return MPI_SUCCESS;
@@ -620,4 +629,6 @@
       MPI_Status status;
 
+
+
       MPI_Comm_rank(peer_comm, &leader_rank_in_peer[0]);
 
@@ -714,4 +725,5 @@
             *newintercomm =  iter->second[my_position];
             found = true;
+            // tag_list.erase(iter);
             break;
           }
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_intercomm_world.cpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_intercomm_world.cpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_intercomm_world.cpp	(revision 1499)
@@ -9,4 +9,533 @@
 {
 
+  // #ifdef _openmpi
+
+  // int MPI_Intercomm_create_from_world(MPI_Comm local_comm, int local_leader, void* peer_comm_ptr, int mpi_remote_leader, int tag, MPI_Comm *newintercomm)
+  // {
+
+  //   int ep_rank, ep_rank_loc, mpi_rank;
+  //   int ep_size, num_ep, mpi_size;
+
+  //   ep_rank = local_comm.ep_comm_ptr->size_rank_info[0].first;
+  //   ep_rank_loc = local_comm.ep_comm_ptr->size_rank_info[1].first;
+  //   mpi_rank = local_comm.ep_comm_ptr->size_rank_info[2].first;
+  //   ep_size = local_comm.ep_comm_ptr->size_rank_info[0].second;
+  //   num_ep = local_comm.ep_comm_ptr->size_rank_info[1].second;
+  //   mpi_size = local_comm.ep_comm_ptr->size_rank_info[2].second;
+
+
+  //   std::vector<int> rank_info[4];  //! 0->rank_in_world of local_comm,  1->rank_in_local_parent of local_comm
+  //                                   //! 2->rank_in_world of remote_comm, 3->rank_in_local_parent of remote_comm
+
+  //   int rank_in_world;
+  //   int rank_in_local_parent;
+
+  //   int local_ep_size = ep_size;
+  //   int remote_ep_size;
+
+  //   ::MPI_Comm peer_comm = to_mpi_comm(peer_comm_ptr);
+  //   ::MPI_Comm local_mpi_comm = to_mpi_comm(local_comm.mpi_comm);
+
+  //   ::MPI_Comm_rank(peer_comm, &rank_in_world);
+
+  //   ::MPI_Comm_rank(local_mpi_comm, &rank_in_local_parent);
+
+  //   bool is_proc_master = false;
+  //   bool is_local_leader = false;
+  //   bool is_final_master = false;
+
+
+  //   if(ep_rank == local_leader) { is_proc_master = true; is_local_leader = true; is_final_master = true;}
+  //   if(ep_rank_loc == 0 && mpi_rank != local_comm.rank_map->at(local_leader).second) is_proc_master = true;
+
+
+  //   int size_info[4]; //! used for choose size of rank_info 0-> mpi_size of local_comm, 1-> mpi_size of remote_comm
+
+  //   int leader_info[4]; //! 0->world rank of local_leader, 1->world rank of remote leader
+
+
+  //   std::vector<int> ep_info[2]; //! 0-> num_ep in local_comm, 1->num_ep in remote_comm
+
+  //   std::vector<int> new_rank_info[4];
+  //   std::vector<int> new_ep_info[2];
+
+  //   std::vector<int> offset;
+
+  //   if(is_proc_master)
+  //   {
+
+  //     size_info[0] = mpi_size;
+
+  //     rank_info[0].resize(size_info[0]);
+  //     rank_info[1].resize(size_info[0]);
+
+
+
+  //     ep_info[0].resize(size_info[0]);
+
+  //     vector<int> send_buf(6);
+  //     vector<int> recv_buf(3*size_info[0]);
+
+  //     send_buf[0] = rank_in_world;
+  //     send_buf[1] = rank_in_local_parent;
+  //     send_buf[2] = num_ep;
+
+  //     ::MPI_Allgather(send_buf.data(), 3, to_mpi_type(MPI_INT), recv_buf.data(), 3, to_mpi_type(MPI_INT), local_mpi_comm);
+
+  //     for(int i=0; i<size_info[0]; i++)
+  //     {
+  //       rank_info[0][i] = recv_buf[3*i];
+  //       rank_info[1][i] = recv_buf[3*i+1];
+  //       ep_info[0][i]   = recv_buf[3*i+2];
+  //     }
+
+  //     if(is_local_leader)
+  //     {
+  //       leader_info[0] = rank_in_world;
+  //       leader_info[1] = mpi_remote_leader;
+
+  //       ::MPI_Status mpi_status;
+
+  //       send_buf[0] = size_info[0];
+  //       send_buf[1] = local_ep_size;
+
+  //       ::MPI_Send(send_buf.data(), 2, to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm);
+
+  //       ::MPI_Recv(recv_buf.data(), 2, to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm, &mpi_status);
+
+  //       recv_buf[2] = rank_in_world;
+  //       recv_buf[3] = mpi_remote_leader;
+
+  //     }
+
+  //     ::MPI_Bcast(recv_buf.data(), 4, to_mpi_type(MPI_INT), local_comm.rank_map->at(local_leader).second, local_mpi_comm);
+
+  //     size_info[1] = recv_buf[0];
+  //     remote_ep_size = recv_buf[1];
+  //     leader_info[0] = recv_buf[2];
+  //     leader_info[1] = recv_buf[3];
+
+  //     rank_info[2].resize(size_info[1]);
+  //     rank_info[3].resize(size_info[1]);
+
+  //     ep_info[1].resize(size_info[1]);
+
+  //     send_buf.resize(3*size_info[0]);
+  //     recv_buf.resize(3*size_info[1]);
+
+  //     if(is_local_leader)
+  //     {
+  //       ::MPI_Status mpi_status;
+
+
+  //       std::copy ( rank_info[0].data(), rank_info[0].data() + size_info[0], send_buf.begin() );
+  //       std::copy ( rank_info[1].data(), rank_info[1].data() + size_info[0], send_buf.begin() + size_info[0] );
+  //       std::copy ( ep_info[0].data(),   ep_info[0].data()   + size_info[0], send_buf.begin() + 2*size_info[0] );
+
+  //       ::MPI_Send(send_buf.data(), 3*size_info[0], to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm);
+
+  //       ::MPI_Recv(recv_buf.data(), 3*size_info[1], to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm, &mpi_status);
+
+  //     }
+
+  //     ::MPI_Bcast(recv_buf.data(), 3*size_info[1], to_mpi_type(MPI_INT), local_comm.rank_map->at(local_leader).second, local_mpi_comm);
+
+  //     std::copy ( recv_buf.data(), recv_buf.data() + size_info[1], rank_info[2].begin() );
+  //     std::copy ( recv_buf.data() + size_info[1], recv_buf.data() + 2*size_info[1], rank_info[3].begin()  );
+  //     std::copy ( recv_buf.data() + 2*size_info[1], recv_buf.data() + 3*size_info[1], ep_info[1].begin() );
+
+  //     offset.resize(size_info[0]);
+
+  //     if(leader_info[0]<leader_info[1]) // erase all ranks doubled with remote_comm, except the local leader
+  //     {
+
+  //       bool found = false;
+  //       int ep_tmp;
+  //       int ep_local;
+  //       int ep_remote;
+  //       for(int i=0; i<size_info[0]; i++)
+  //       {
+  //         int target = rank_info[0][i];
+  //         found = false;
+  //         for(int j=0; j<size_info[1]; j++)
+  //         {
+  //           if(target == rank_info[2][j])
+  //           {
+  //             found = true;
+  //             ep_tmp = ep_info[1][j];
+  //             ep_local = ep_info[0][j];
+  //             ep_remote = ep_info[1][j];
+  //             break;
+  //           }
+  //         }
+  //         if(found)
+  //         {
+
+  //           if(target == leader_info[0]) // the leader is doubled in remote
+  //           {
+  //             new_rank_info[0].push_back(target);
+  //             new_rank_info[1].push_back(rank_info[1][i]);
+
+  //             new_ep_info[0].push_back(ep_local + ep_remote);
+  //             offset[i] = 0;
+  //           }
+  //           else
+  //           {
+  //             offset[i] = ep_local;
+  //           }
+  //         }
+  //         else
+  //         {
+  //           new_rank_info[0].push_back(target);
+  //           new_rank_info[1].push_back(rank_info[1][i]);
+
+  //           new_ep_info[0].push_back(ep_info[0][i]);
+
+  //           offset[i] = 0;
+  //         }
+
+  //       }
+  //     }
+
+  //     else // erase rank doubled with remote leader
+  //     {
+
+  //       bool found = false;
+  //       int ep_tmp;
+  //       int ep_local;
+  //       int ep_remote;
+  //       for(int i=0; i<size_info[0]; i++)
+  //       {
+  //         int target = rank_info[0][i];
+  //         found = false;
+  //         for(int j=0; j<size_info[1]; j++)
+  //         {
+
+  //           if(target == rank_info[2][j])
+  //           {
+  //             found = true;
+  //             ep_tmp = ep_info[1][j];
+  //             ep_local = ep_info[0][j];
+  //             ep_remote = ep_info[1][j];
+  //             break;
+  //           }
+  //         }
+  //         if(found)
+  //         {
+  //           if(target != leader_info[1])
+  //           {
+  //             new_rank_info[0].push_back(target);
+  //             new_rank_info[1].push_back(rank_info[1][i]);
+
+  //             new_ep_info[0].push_back(ep_local + ep_remote);
+  //             offset[i] = 0;
+  //           }
+  //           else // found remote leader
+  //           {
+  //             offset[i] = ep_remote;
+  //           }
+  //         }
+  //         else
+  //         {
+  //           new_rank_info[0].push_back(target);
+  //           new_rank_info[1].push_back(rank_info[1][i]);
+
+  //           new_ep_info[0].push_back(ep_info[0][i]);
+  //           offset[i] = 0;
+  //         }
+  //       }
+  //     }
+
+  //     if(offset[mpi_rank] == 0)
+  //     {
+  //       is_final_master = true;
+  //     }
+
+
+  //     // size_info[4]: 2->size of new_ep_info for local, 3->size of new_ep_info for remote
+
+  //     if(is_local_leader)
+  //     {
+  //       size_info[2] = new_ep_info[0].size();
+  //       ::MPI_Status mpi_status;
+
+  //       ::MPI_Send(&size_info[2], 1, to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm);
+
+  //       ::MPI_Recv(&size_info[3], 1, to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm, &mpi_status);
+  //     }
+
+  //     ::MPI_Bcast(&size_info[2], 2, to_mpi_type(MPI_INT), local_comm.rank_map->at(local_leader).second, local_mpi_comm);
+
+  //     new_rank_info[2].resize(size_info[3]);
+  //     new_rank_info[3].resize(size_info[3]);
+  //     new_ep_info[1].resize(size_info[3]);
+
+  //     send_buf.resize(size_info[2]);
+  //     recv_buf.resize(size_info[3]);
+
+  //     if(is_local_leader)
+  //     {
+  //       ::MPI_Status mpi_status;
+
+  //       std::copy ( new_rank_info[0].data(), new_rank_info[0].data() + size_info[2], send_buf.begin() );
+  //       std::copy ( new_rank_info[1].data(), new_rank_info[1].data() + size_info[2], send_buf.begin() + size_info[2] );
+  //       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], to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm);
+  //       ::MPI_Recv(recv_buf.data(), 3*size_info[3], to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm, &mpi_status);
+
+  //     }
+
+  //     ::MPI_Bcast(recv_buf.data(),   3*size_info[3], to_mpi_type(MPI_INT), local_comm.rank_map->at(local_leader).second, local_mpi_comm);
+
+  //     std::copy ( recv_buf.data(), recv_buf.data() + size_info[3], new_rank_info[2].begin() );
+  //     std::copy ( recv_buf.data() + size_info[3], recv_buf.data() + 2*size_info[3], new_rank_info[3].begin()  );
+  //     std::copy ( recv_buf.data() + 2*size_info[3], recv_buf.data() + 3*size_info[3], new_ep_info[1].begin() );
+
+  //   }
+
+
+
+  //   if(is_proc_master)
+  //   {
+  //     // leader_info[4]: 2-> rank of local leader in new_group generated comm;
+  //                     // 3-> rank of remote leader in new_group generated comm;
+  //     ::MPI_Group local_group;
+  //     ::MPI_Group new_group;
+  //     ::MPI_Comm *new_comm = new ::MPI_Comm;
+  //     ::MPI_Comm *intercomm = new ::MPI_Comm;
+
+  //     ::MPI_Comm_group(local_mpi_comm, &local_group);
+
+  //     ::MPI_Group_incl(local_group, size_info[2], new_rank_info[1].data(), &new_group);
+
+  //     ::MPI_Comm_create(local_mpi_comm, new_group, new_comm);
+
+
+
+  //     if(is_local_leader)
+  //     {
+  //       ::MPI_Comm_rank(*new_comm, &leader_info[2]);
+  //     }
+
+  //     ::MPI_Bcast(&leader_info[2], 1, to_mpi_type(MPI_INT), local_comm.rank_map->at(local_leader).second, local_mpi_comm);
+
+  //     if(new_comm != static_cast< ::MPI_Comm*>(MPI_COMM_NULL.mpi_comm))
+  //     {
+  //       ::MPI_Barrier(*new_comm);
+
+  //       ::MPI_Intercomm_create(*new_comm, leader_info[2], peer_comm, leader_info[1], tag, intercomm);
+
+  //       int id;
+  //       ::MPI_Comm_rank(*new_comm, &id);
+  //       int my_num_ep = new_ep_info[0][id];
+
+  //       MPI_Comm *ep_intercomm;
+  //       MPI_Info info;
+  //       MPI_Comm_create_endpoints(new_comm, my_num_ep, info, ep_intercomm);
+
+
+
+  //       for(int i= 0; i<my_num_ep; i++)
+  //       {
+  //         ep_intercomm[i].is_intercomm = true;
+
+  //         ep_intercomm[i].ep_comm_ptr->intercomm = new ep_lib::ep_intercomm;
+  //         ep_intercomm[i].ep_comm_ptr->intercomm->mpi_inter_comm = intercomm;
+  //         ep_intercomm[i].ep_comm_ptr->comm_label = leader_info[0];
+  //       }
+
+  //       #pragma omp critical (write_to_tag_list)
+  //       tag_list.push_back(make_pair( make_pair(tag, min(leader_info[0], leader_info[1])) , ep_intercomm));
+  //     }
+
+
+  //   }
+
+
+  //   MPI_Barrier_local(local_comm);
+
+  //   vector<int> bcast_buf(8);
+  //   if(is_local_leader)
+  //   {
+  //     std::copy(size_info, size_info+4, bcast_buf.begin());
+  //     std::copy(leader_info, leader_info+4, bcast_buf.begin()+4);
+  //   }
+
+  //   MPI_Bcast(bcast_buf.data(), 8, MPI_INT, local_leader, local_comm);
+
+  //   if(!is_local_leader)
+  //   {
+  //     std::copy(bcast_buf.begin(), bcast_buf.begin()+4, size_info);
+  //     std::copy(bcast_buf.begin()+4, bcast_buf.begin()+8, leader_info);
+  //   }
+
+  //   if(!is_local_leader)
+  //   {
+  //     new_rank_info[1].resize(size_info[2]);
+  //     ep_info[1].resize(size_info[1]);
+  //     offset.resize(size_info[0]);
+  //   }
+
+  //   bcast_buf.resize(size_info[2]+size_info[1]+size_info[0]+1);
+
+  //   if(is_local_leader)
+  //   {
+  //     bcast_buf[0] = remote_ep_size;
+  //     std::copy(new_rank_info[1].data(), new_rank_info[1].data()+size_info[2], bcast_buf.begin()+1);
+  //     std::copy(ep_info[1].data(), ep_info[1].data()+size_info[1], bcast_buf.begin()+size_info[2]+1);
+  //     std::copy(offset.data(), offset.data()+size_info[0], bcast_buf.begin()+size_info[2]+size_info[1]+1);
+  //   }
+
+  //   MPI_Bcast(bcast_buf.data(), size_info[2]+size_info[1]+size_info[0]+1, MPI_INT, local_leader, local_comm);
+
+  //   if(!is_local_leader)
+  //   {
+  //     remote_ep_size = bcast_buf[0];
+  //     std::copy(bcast_buf.data()+1, bcast_buf.data()+1+size_info[2], new_rank_info[1].begin());
+  //     std::copy(bcast_buf.data()+1+size_info[2], bcast_buf.data()+1+size_info[2]+size_info[1], ep_info[1].begin());
+  //     std::copy(bcast_buf.data()+1+size_info[2]+size_info[1], bcast_buf.data()+1+size_info[2]+size_info[1]+size_info[0], offset.begin());
+  //   }
+
+
+  //   int my_position = offset[rank_in_local_parent]+ep_rank_loc;
+
+
+  //   MPI_Barrier_local(local_comm);
+  //   #pragma omp flush
+
+
+  //   #pragma omp critical (read_from_tag_list)
+  //   {
+  //     bool found = false;
+  //     while(!found)
+  //     {
+  //       for(std::list<std::pair < std::pair<int,int>, MPI_Comm* > >::iterator iter = tag_list.begin(); iter!=tag_list.end(); iter++)
+  //       {
+  //         if((*iter).first == make_pair(tag, min(leader_info[0], leader_info[1])))
+  //         {
+  //           *newintercomm =  iter->second[my_position];
+
+  //           found = true;
+  //           //tag_list.erase(iter);
+  //           break;
+  //         }
+  //       }
+  //     }
+  //   }
+
+  //   MPI_Barrier(local_comm);
+
+  //   if(is_local_leader)
+  //   {
+  //     int local_flag = true;
+  //     int remote_flag = false;
+  //     ::MPI_Status mpi_status;
+      
+  //     ::MPI_Send(&local_flag, 1, to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm);
+
+  //     ::MPI_Recv(&remote_flag, 1, to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm, &mpi_status);
+  //   }
+
+  //   MPI_Barrier(local_comm);
+
+  //   if(is_proc_master)
+  //   {
+  //     for(std::list<std::pair < std::pair<int,int>, MPI_Comm* > >::iterator iter = tag_list.begin(); iter!=tag_list.end(); iter++)
+  //     {
+  //       if((*iter).first == make_pair(tag, min(leader_info[0], leader_info[1])))
+  //       {
+  //         tag_list.erase(iter);
+  //         break;
+  //       }
+  //     }
+  //   }
+
+    
+
+  //   int intercomm_ep_rank, intercomm_ep_rank_loc, intercomm_mpi_rank;
+  //   int intercomm_ep_size, intercomm_num_ep, intercomm_mpi_size;
+
+  //   intercomm_ep_rank = newintercomm->ep_comm_ptr->size_rank_info[0].first;
+  //   intercomm_ep_rank_loc = newintercomm->ep_comm_ptr->size_rank_info[1].first;
+  //   intercomm_mpi_rank = newintercomm->ep_comm_ptr->size_rank_info[2].first;
+  //   intercomm_ep_size = newintercomm->ep_comm_ptr->size_rank_info[0].second;
+  //   intercomm_num_ep = newintercomm->ep_comm_ptr->size_rank_info[1].second;
+  //   intercomm_mpi_size = newintercomm->ep_comm_ptr->size_rank_info[2].second;
+
+  //   MPI_Bcast(&remote_ep_size, 1, MPI_INT, local_leader, local_comm);
+
+  //   int my_rank_map_elem[2];
+
+
+  //   my_rank_map_elem[0] = intercomm_ep_rank;
+
+  //   my_rank_map_elem[1] = (*newintercomm).ep_comm_ptr->comm_label;
+
+  //   vector<pair<int, int> > local_rank_map_array;
+  //   vector<pair<int, int> > remote_rank_map_array;
+
+
+  //   (*newintercomm).ep_comm_ptr->intercomm->local_rank_map = new RANK_MAP;
+  //   (*newintercomm).ep_comm_ptr->intercomm->local_rank_map->resize(local_ep_size);
+
+  //   MPI_Allgather2(my_rank_map_elem, 2, MPI_INT, (*newintercomm).ep_comm_ptr->intercomm->local_rank_map->data(), 2, MPI_INT, local_comm);
+
+  //   (*newintercomm).ep_comm_ptr->intercomm->remote_rank_map = new RANK_MAP;
+  //   (*newintercomm).ep_comm_ptr->intercomm->remote_rank_map->resize(remote_ep_size);
+
+  //   int local_intercomm_size = intercomm_ep_size;
+  //   int remote_intercomm_size;
+
+
+
+
+  //   if(is_local_leader)
+  //   {
+  //     ::MPI_Status status;
+
+  //     ::MPI_Send((*newintercomm).ep_comm_ptr->intercomm->local_rank_map->data(), 2*local_ep_size, to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm);
+
+  //     ::MPI_Recv((*newintercomm).ep_comm_ptr->intercomm->remote_rank_map->data(), 2*remote_ep_size, to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm, &status);
+
+  //     ::MPI_Send(&local_intercomm_size, 1, to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm);
+
+  //     ::MPI_Recv(&remote_intercomm_size, 1, to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm, &status);
+  //   }
+
+  //   MPI_Bcast((*newintercomm).ep_comm_ptr->intercomm->remote_rank_map->data(), 2*remote_ep_size, MPI_INT, local_leader, local_comm);
+  //   MPI_Bcast(&remote_intercomm_size, 1, MPI_INT, 0, *newintercomm);
+
+
+  //   (*newintercomm).ep_comm_ptr->intercomm->intercomm_rank_map = new RANK_MAP;
+  //   (*newintercomm).ep_comm_ptr->intercomm->intercomm_rank_map->resize(remote_intercomm_size);
+
+  //   (*newintercomm).ep_comm_ptr->intercomm->size_rank_info[0] = local_comm.ep_comm_ptr->size_rank_info[0];
+  //   (*newintercomm).ep_comm_ptr->intercomm->size_rank_info[1] = local_comm.ep_comm_ptr->size_rank_info[1];
+  //   (*newintercomm).ep_comm_ptr->intercomm->size_rank_info[2] = local_comm.ep_comm_ptr->size_rank_info[2];
+
+
+  //   if(is_local_leader)
+  //   {
+  //     ::MPI_Status status;
+
+  //     ::MPI_Send((*newintercomm).rank_map->data(), 2*local_intercomm_size, to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm);
+
+  //     ::MPI_Recv((*newintercomm).ep_comm_ptr->intercomm->intercomm_rank_map->data(), 2*remote_intercomm_size, to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm, &status);
+  //   }
+
+  //   MPI_Bcast((*newintercomm).ep_comm_ptr->intercomm->intercomm_rank_map->data(), 2*remote_intercomm_size, to_mpi_type(MPI_INT), 0, *newintercomm);
+
+  //   (*newintercomm).ep_comm_ptr->intercomm->local_comm = &(local_comm.ep_comm_ptr->comm_list[ep_rank_loc]);
+  //   (*newintercomm).ep_comm_ptr->intercomm->intercomm_tag = local_comm.ep_comm_ptr->comm_label;
+
+
+  //   return MPI_SUCCESS;
+
+  // }
+
+
+
+  // #elif _intelmpi
   int MPI_Intercomm_create_from_world(MPI_Comm local_comm, int local_leader, void* peer_comm_ptr, int mpi_remote_leader, int tag, MPI_Comm *newintercomm)
   {
@@ -526,4 +1055,6 @@
   }
 
+  // #endif
+
 }
 
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_lib.cpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_lib.cpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_lib.cpp	(revision 1499)
@@ -62,4 +62,5 @@
       if(  comm.ep_comm_ptr->intercomm->remote_rank_map->at(i).first  == inter_rank  )
       {
+        //printf("get_ep_rank for intercomm, ep_rank_loc = %d, mpi_rank = %d => ep_src = %d\n", ep_rank_loc, mpi_rank, i);
         return i;
       }
@@ -210,5 +211,6 @@
        || datatype == MPI_CHAR 
        || datatype == MPI_LONG 
-       || datatype == MPI_UNSIGNED_LONG)
+       || datatype == MPI_UNSIGNED_LONG
+       || datatype == MPI_UINT64_T)
     {
       return true;
@@ -223,5 +225,6 @@
     if(   op == MPI_MAX 
        || op == MPI_MIN
-       || op == MPI_SUM)
+       || op == MPI_SUM
+       || op == MPI_LOR)
     {
       return true;
@@ -272,4 +275,2 @@
 
 
-
-
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_lib.hpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_lib.hpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_lib.hpp	(revision 1499)
@@ -9,6 +9,4 @@
 #include "ep_lib_fortran.hpp"
 #include "ep_lib_win.hpp"
-
-#include "ep_global.hpp"
 
 namespace ep_lib
@@ -37,4 +35,10 @@
   int MPI_Get_count(const MPI_Status *status, MPI_Datatype datatype, int *count);
 
+  // #ifdef _openmpi
+  // int MPI_Comm_create_endpoints(void* mpi_comm, int num_ep, MPI_Info info, MPI_Comm *& out_comm_hdls); // from MPI to create endpoints
+  // #elif _intelmpi
+  // int MPI_Comm_create_endpoints(int mpi_comm, int num_ep, MPI_Info info, MPI_Comm *& out_comm_hdls); // from MPI to create endpoints
+  // #endif
+  
   int MPI_Comm_create_endpoints(void* base_comm_ptr, int num_ep, MPI_Info info, MPI_Comm *& out_comm_hdls); // from EP to create endpoints
 
@@ -80,4 +84,6 @@
 }
 
+//MPI_Datatype to_mpi(ep_lib::MPI_Datatype type);
+
 
 #endif // EP_LIB_HPP_INCLUDED
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_lib_collective.hpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_lib_collective.hpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_lib_collective.hpp	(revision 1499)
@@ -26,5 +26,4 @@
 
   int MPI_Gather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm);
-  
   int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm);
 
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_lib_intercomm.hpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_lib_intercomm.hpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_lib_intercomm.hpp	(revision 1499)
@@ -32,4 +32,10 @@
   int MPI_Intercomm_create_kernel(MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm *newintercomm);
   
+  // #ifdef _intelmpi
+  // int MPI_Intercomm_create_from_world(MPI_Comm local_comm, int local_leader, int peer_comm_ptr, int mpi_remote_leader, int tag, MPI_Comm *newintercomm);
+  // #elif _openmpi
+  // int MPI_Intercomm_create_from_world(MPI_Comm local_comm, int local_leader, void* peer_comm_ptr, int mpi_remote_leader, int tag, MPI_Comm *newintercomm);
+  // #endif
+
   int MPI_Intercomm_create_from_world(MPI_Comm local_comm, int local_leader, void* peer_comm_ptr, int mpi_remote_leader, int tag, MPI_Comm *newintercomm);
   
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_reduce.cpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_reduce.cpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_reduce.cpp	(revision 1499)
@@ -29,4 +29,10 @@
 
   template<typename T>
+  T lor_op(T a, T b)
+  {
+    return a||b;
+  }
+
+  template<typename T>
   void reduce_max(const T * buffer, T* recvbuf, int count)
   {
@@ -44,4 +50,10 @@
   {
     transform(buffer, buffer+count, recvbuf, recvbuf, std::plus<T>());
+  }
+
+  template<typename T>
+  void reduce_lor(const T * buffer, T* recvbuf, int count)
+  {
+    transform(buffer, buffer+count, recvbuf, recvbuf, lor_op<T>);
   }
 
@@ -112,4 +124,18 @@
         }
 
+        else if(datatype == MPI_UINT64_T)
+        {
+          assert(datasize == sizeof(uint64_t));
+          for(int i=1; i<num_ep; i++)
+            reduce_max<uint64_t>(static_cast<uint64_t*>(comm.my_buffer->void_buffer[i]), static_cast<uint64_t*>(recvbuf), count);
+        }
+        
+        else if(datatype == MPI_LONG_LONG_INT)
+        {
+          assert(datasize == sizeof(long long));
+          for(int i=1; i<num_ep; i++)
+            reduce_max<long long>(static_cast<long long*>(comm.my_buffer->void_buffer[i]), static_cast<long long*>(recvbuf), count);
+        }
+
         else printf("datatype Error\n");
 
@@ -160,4 +186,18 @@
         }
 
+        else if(datatype == MPI_UINT64_T)
+        {
+          assert(datasize == sizeof(uint64_t));
+          for(int i=1; i<num_ep; i++)
+            reduce_min<uint64_t>(static_cast<uint64_t*>(comm.my_buffer->void_buffer[i]), static_cast<uint64_t*>(recvbuf), count);
+        }
+        
+        else if(datatype == MPI_LONG_LONG_INT)
+        {
+          assert(datasize == sizeof(long long));
+          for(int i=1; i<num_ep; i++)
+            reduce_min<long long>(static_cast<long long*>(comm.my_buffer->void_buffer[i]), static_cast<long long*>(recvbuf), count);
+        }
+
         else printf("datatype Error\n");
 
@@ -209,6 +249,32 @@
         }
 
+        else if(datatype ==MPI_UINT64_T)
+        {
+          assert(datasize == sizeof(uint64_t));
+          for(int i=1; i<num_ep; i++)
+            reduce_sum<uint64_t>(static_cast<uint64_t*>(comm.my_buffer->void_buffer[i]), static_cast<uint64_t*>(recvbuf), count);
+        }
+        
+        else if(datatype ==MPI_LONG_LONG_INT)
+        {
+          assert(datasize == sizeof(long long));
+          for(int i=1; i<num_ep; i++)
+            reduce_sum<long long>(static_cast<long long*>(comm.my_buffer->void_buffer[i]), static_cast<long long*>(recvbuf), count);
+        }
+
         else printf("datatype Error\n");
 
+      }
+
+      if(op == MPI_LOR)
+      {
+        if(datatype != MPI_INT)
+          printf("datatype Error, must be MPI_INT\n");
+        else
+        {
+          assert(datasize == sizeof(int));
+          for(int i=1; i<num_ep; i++)
+            reduce_lor<int>(static_cast<int*>(comm.my_buffer->void_buffer[i]), static_cast<int*>(recvbuf), count);
+        }
       }
     }
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_size.cpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_size.cpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_size.cpp	(revision 1499)
@@ -32,5 +32,5 @@
     Debug("Calling EP_Comm_size\n");
 
-    if(to_mpi_comm(comm.mpi_comm) != *static_cast< ::MPI_Comm*>(MPI_COMM_NULL.mpi_comm))
+    if(comm.mpi_comm != static_cast< ::MPI_Comm*>(MPI_COMM_NULL.mpi_comm))
     {
       ::MPI_Comm mpi_comm = to_mpi_comm(comm.mpi_comm); 
@@ -38,5 +38,5 @@
 
       ::MPI_Comm_size(mpi_comm, &mpi_size);
-      Debug("============ ep comm size called for non ep comm\n");
+      printf("============ ep comm size called for non ep comm, %d\n", mpi_size);
       *size = mpi_size;
       return 0;
@@ -46,5 +46,5 @@
     {
       *size = MPI_UNDEFINED;
-      Debug("============ ep comm size called for non ep comm not defined\n");
+      printf("============ ep comm size called for non ep comm not defined\n");
       return 0;
     }
@@ -55,5 +55,5 @@
     if(!comm.is_ep)
     {
-      if(to_mpi_comm(comm.mpi_comm) != *static_cast< ::MPI_Comm*>(MPI_COMM_NULL.mpi_comm))
+      if(comm.mpi_comm != static_cast< ::MPI_Comm*>(MPI_COMM_NULL.mpi_comm))
       {
         ::MPI_Comm mpi_comm = to_mpi_comm(comm.mpi_comm); 
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_type.hpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_type.hpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_type.hpp	(revision 1499)
@@ -184,5 +184,5 @@
   struct BUFFER
   {
-    void * void_buffer[16];
+    void * void_buffer[12];
   };
 
@@ -248,4 +248,5 @@
 
   
+
   class MPI_Aint
   {
@@ -264,23 +265,24 @@
   {
     public:
-
+  
     void* mpi_fint;
-
+    
     MPI_Fint() {}
     MPI_Fint(void* fint);
     //MPI_Fint(int f): mpi_fint(f) {}
-    
-  };
-
+                                 
+  };
+ 
   class MPI_Win
   {
     public:
-      bool is_ep;
-      MPI_Comm comm;
-
-      void* server_win[16];
-      void* client_win;
-      void* null_win[16];
-  };
+    bool is_ep;
+    MPI_Comm comm;
+
+    void* server_win[16];
+    void* client_win;
+    void* null_win[16];
+  };
+
 
   static MPI_Comm *passage;
@@ -295,5 +297,5 @@
 //  #pragma omp threadprivate(fc_comm_map_ptr)
 //            //    <MPI_Fint,thread_num>   EP_Comm
-  
+
 }
 
Index: XIOS/dev/branch_openmp/extern/ep_dev/ep_wait.cpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/ep_wait.cpp	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/ep_wait.cpp	(revision 1499)
@@ -31,6 +31,13 @@
     while(request->type == 2) Request_Check();
 
+
+    //::MPI_Request mpi_request = static_cast< ::MPI_Request >(request->mpi_request);
     ::MPI_Status mpi_status;
     ::MPI_Wait(static_cast< ::MPI_Request*>(request->mpi_request), &mpi_status);
+
+   
+           
+ 
+    // request->mpi_request = mpi_request;
 
     status->mpi_status = &mpi_status;
@@ -39,4 +46,6 @@
     status->ep_datatype = request->ep_datatype;
     
+
+
     return MPI_SUCCESS;
 
@@ -71,4 +80,5 @@
         {
           finished.at(i) = 1;
+          //mpi_request[i] = static_cast< ::MPI_Request >(array_of_requests[i].mpi_request);
           mpi_request[i] = *static_cast< ::MPI_Request*>(array_of_requests[i].mpi_request);
         }
Index: XIOS/dev/branch_openmp/extern/ep_dev/makefile
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/makefile	(revision 1482)
+++ XIOS/dev/branch_openmp/extern/ep_dev/makefile	(revision 1499)
@@ -1,5 +1,5 @@
 appname := EP_test
 
-CXX := mpiicc -D_intelmpi -openmp
+CXX := mpiicc -D_intelmpi -qopenmp
 CXXFLAGS := -std=c++11  -g
 #CXXFLAGS := -std=c++11  -g
