Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_declaration.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_declaration.cpp	(revision 1067)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_declaration.cpp	(revision 1068)
@@ -4,5 +4,4 @@
 
 #include <mpi.h>
-//#include "ep_declaration.hpp"
 
 #undef MPI_INT
@@ -22,10 +21,8 @@
 
 #undef MPI_STATUS_IGNORE
-//#undef MPI_INFO_NULL
 #undef MPI_REQUEST_NULL
+#undef MPI_INFO_NULL
 
-#ifdef _openmpi
-//#undef MPI_Fint
-#endif
+
 
 // _STD defined in ep_type.cpp
@@ -47,6 +44,6 @@
 
 extern ::MPI_Status MPI_STATUS_IGNORE_STD;
-//extern ::MPI_Info MPI_INFO_NULL_STD;
 extern ::MPI_Request MPI_REQUEST_NULL_STD;
+extern ::MPI_Info MPI_INFO_NULL_STD;
 
 ep_lib::MPI_Datatype MPI_INT = MPI_INT_STD;
@@ -65,12 +62,8 @@
 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;
+ep_lib::MPI_Info MPI_INFO_NULL(MPI_INFO_NULL_STD);
 
 
 
+
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_declaration.hpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_declaration.hpp	(revision 1067)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_declaration.hpp	(revision 1068)
@@ -18,6 +18,6 @@
 
 extern ::MPI_Status MPI_STATUS_IGNORE_STD;
-//extern ::MPI_Info MPI_INFO_NULL_STD;
 extern ::MPI_Request MPI_REQUEST_NULL_STD;
+extern ::MPI_Info MPI_INFO_NULL_STD;
 
 #undef MPI_INT
@@ -36,10 +36,7 @@
 #undef MPI_COMM_NULL
 
-//#undef MPI_INFO_NULL
 #undef MPI_REQUEST_NULL
 
-#ifdef _openmpi
-//#undef MPI_Fint
-#endif
+
 
 #undef MPI_STATUS_IGNORE
@@ -61,6 +58,6 @@
 
 extern ep_lib::MPI_Status MPI_STATUS_IGNORE;
+extern ep_lib::MPI_Request MPI_REQUEST_NULL;
 //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_fortran.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_fortran.cpp	(revision 1067)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_fortran.cpp	(revision 1068)
@@ -6,12 +6,4 @@
 #include "ep_declaration.hpp"
 
-#ifdef _intelmpi
-#undef MPI_Comm_f2c(comm)
-#undef MPI_Comm_c2f(comm)
-#endif
-
-#ifdef _openmpi
-//#undef MPI_Fint
-#endif
 
 namespace ep_lib
@@ -61,5 +53,10 @@
       if(omp_get_thread_num() == 0)
       {
+        #ifdef _openmpi
         ::MPI_Comm base_comm = ::MPI_Comm_f2c(comm);
+        #elif _intelmpi
+        ::MPI_Comm base_comm = (::MPI_Comm)(comm);
+        #endif
+
         if(base_comm != MPI_COMM_NULL_STD)
         {
@@ -78,99 +75,99 @@
   }
 
-  #ifdef _intelmpi
+  // #ifdef _intelmpi
 
-  MPI_Fint MPI_Comm_c2f(MPI_Comm comm)
-  {
-    Debug("MPI_Comm_c2f");
-    int fint;
-    fint = (::MPI_Fint)(comm.mpi_comm);
+  // MPI_Fint MPI_Comm_c2f(MPI_Comm comm)
+  // {
+  //   Debug("MPI_Comm_c2f");
+  //   int fint;
+  //   fint = (::MPI_Fint)(comm.mpi_comm);
     
-    std::map<std::pair<int, int>, MPI_Comm  > ::iterator it;
+  //   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);
-    }
+  //   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);
+  //   }
     
-    MPI_Fint Fint;
-    Fint.mpi_fint = fint;
-    return Fint;
+  //   MPI_Fint Fint;
+  //   Fint.mpi_fint = fint;
+  //   return Fint;
     
-  }
+  // }
 
   
 
 
-  MPI_Comm MPI_Comm_f2c(MPI_Fint comm)
-  {
-    Debug("MPI_Comm_f2c");
+  // MPI_Comm MPI_Comm_f2c(MPI_Fint comm)
+  // {
+  //   Debug("MPI_Comm_f2c");
     
     
-    std::map<std::pair<int, int>, MPI_Comm  > ::iterator it;
+  //   std::map<std::pair<int, int>, MPI_Comm  > ::iterator it;
     
-    it = fc_comm_map.find(std::make_pair(comm.mpi_fint, 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.mpi_fint);
-      return return_comm;
-    }
-  }
+  //   it = fc_comm_map.find(std::make_pair(comm.mpi_fint, 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.mpi_fint);
+  //     return return_comm;
+  //   }
+  // }
 
   
 
-  #elif _openmpi
+  // #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));
+  // 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;
+  //   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);
-    }
+  //   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;
+  //   return fint;
     
-  }
+  // }
 
-  ep_lib::MPI_Comm MPI_Comm_f2c(MPI_Fint comm)
-  {
-    Debug("MPI_Comm_f2c");
+  // ep_lib::MPI_Comm MPI_Comm_f2c(MPI_Fint comm)
+  // {
+  //   Debug("MPI_Comm_f2c");
     
     
-    std::map<std::pair<int, int>, MPI_Comm > ::iterator it;
+  //   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
+  //   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_intercomm_kernel.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_intercomm_kernel.cpp	(revision 1067)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_intercomm_kernel.cpp	(revision 1068)
@@ -351,5 +351,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());
+        //printf("tag_list size = %lu\n", tag_list.size());
       }
 
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_lib.hpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_lib.hpp	(revision 1067)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_lib.hpp	(revision 1068)
@@ -15,13 +15,9 @@
   typedef int MPI_Datatype;
   typedef int MPI_Op;
+  #define MPI_ANY_SOURCE -2 
+  #define MPI_ANY_TAG -1 
 #elif _openmpi
   typedef void* MPI_Datatype;
   typedef void* MPI_Op;
-#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 
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 1067)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_lib_fortran.hpp	(revision 1068)
@@ -7,15 +7,15 @@
 {
   
-  #ifdef _intelmpi
+  // #ifdef _intelmpi
   
-  MPI_Fint MPI_Comm_c2f(MPI_Comm comm);
-  MPI_Comm MPI_Comm_f2c(MPI_Fint comm);
+  // MPI_Fint MPI_Comm_c2f(MPI_Comm comm);
+  // MPI_Comm MPI_Comm_f2c(MPI_Fint comm);
   
-  #elif _openmpi
+  // #elif _openmpi
   
-  int MPI_Comm_c2f(MPI_Comm comm);
-  ep_lib::MPI_Comm MPI_Comm_f2c(MPI_Fint comm);
+  // int MPI_Comm_c2f(MPI_Comm comm);
+  // ep_lib::MPI_Comm MPI_Comm_f2c(MPI_Fint comm);
   
-  #endif
+  // #endif
 
   int EP_Comm_c2f(MPI_Comm comm);
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_message.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_message.cpp	(revision 1067)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_message.cpp	(revision 1068)
@@ -20,5 +20,4 @@
     MPI_Comm_rank(comm, &myRank);
 
-    //printf("myRank = %d, comm.is_ep = %d, comm.is_intercomm = %d\n", myRank, comm.is_ep, comm.is_intercomm);
     if(!comm.is_ep) return 0;
 
@@ -53,5 +52,4 @@
       //::MPI_Improbe(MPI_ANY_SOURCE, MPI_ANY_TAG, mpi_comm, &flag, &message, &status); 
       ::MPI_Improbe(-2, -1, mpi_comm, &flag, &message, &status); 
-      //printf("myRank = %d, ::MPI_Improbe flag = %d\n", myRank, flag);     
       #endif
 
@@ -159,5 +157,4 @@
           #pragma omp flush
           ptr_comm_target->ep_comm_ptr->message_queue->push_back(*msg_block);
-          //printf("probed one message, ep_src = %d, ep_dest = %d, tag = %d, queue = %p, message = %d\n", msg_block->ep_src, msg_block->ep_dest, msg_block->ep_tag, ptr_comm_target->ep_comm_ptr->message_queue, msg_block->mpi_message);
           #pragma omp flush
         }
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_type.cpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_type.cpp	(revision 1067)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_type.cpp	(revision 1068)
@@ -12,9 +12,10 @@
 #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_Info MPI_INFO_NULL_STD = MPI_INFO_NULL;
+#undef MPI_INFO_NULL
 
 ::MPI_Datatype MPI_INT_STD = MPI_INT;
@@ -43,7 +44,4 @@
 #undef MPI_MIN
 
-#ifdef _openmpi
-//#undef MPI_Fint
-#endif
 
 
Index: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_type.hpp
===================================================================
--- XIOS/dev/branch_yushan/extern/src_ep_dev/ep_type.hpp	(revision 1067)
+++ XIOS/dev/branch_yushan/extern/src_ep_dev/ep_type.hpp	(revision 1068)
@@ -42,6 +42,4 @@
 {
   #define MPI_UNDEFINED -32766
-  //#define MPI_STATUS_IGNORE NULL
-  //#define MPI_INFO_NULL MPI_Info(MPI_INFO_NULL_STD)
 
   class ep_communicator;
@@ -85,4 +83,5 @@
 
       MPI_Message() {}
+
       #ifdef _intelmpi
       MPI_Message(int message): mpi_message(message) {}
@@ -354,5 +353,5 @@
       #endif
 
-      MPI_Info() {}
+      MPI_Info(){ }
       
       #ifdef _intelmpi
Index: XIOS/dev/branch_yushan/src/client.cpp
===================================================================
--- XIOS/dev/branch_yushan/src/client.cpp	(revision 1067)
+++ XIOS/dev/branch_yushan/src/client.cpp	(revision 1068)
@@ -230,5 +230,5 @@
       MPI_Comm_rank(intraComm,&rank) ;
       
-      printf("CClient::finalize called isServer = %d\n", CXios::isServer);
+      //printf("CClient::finalize called isServer = %d\n", CXios::isServer);
  
       if (!CXios::isServer)
@@ -238,5 +238,5 @@
         {
           MPI_Send(&msg,1,MPI_INT,0,0,interComm) ;
-          printf(" CClient : send finalize sign to server 0\n");
+          //printf(" CClient : send finalize sign to server 0\n");
         }
       }
Index: XIOS/dev/branch_yushan/src/cxios.cpp
===================================================================
--- XIOS/dev/branch_yushan/src/cxios.cpp	(revision 1067)
+++ XIOS/dev/branch_yushan/src/cxios.cpp	(revision 1068)
@@ -77,7 +77,13 @@
     MPI_Info info;
     MPI_Comm *ep_comm;
-    MPI_Comm_create_endpoints(MPI_COMM_WORLD, num_ep, info, ep_comm);  // servers should reach here too.
-      
-    globalComm = ep_comm[0];
+    if(omp_get_thread_num()==0)
+    {
+      MPI_Comm_create_endpoints(MPI_COMM_WORLD, num_ep, info, ep_comm);  // servers should reach here too.
+      passage = ep_comm;  
+    }
+    
+    #pragma omp barrier
+      
+    globalComm = passage[omp_get_thread_num()];
     
     int tmp_size;
Index: XIOS/dev/branch_yushan/src/interface/c/icdata.cpp
===================================================================
--- XIOS/dev/branch_yushan/src/interface/c/icdata.cpp	(revision 1067)
+++ XIOS/dev/branch_yushan/src/interface/c/icdata.cpp	(revision 1068)
@@ -64,14 +64,20 @@
       MPI_Initialized(&initialized);
 
+      #ifdef _usingEP
       if (initialized) local_comm = ep_lib::EP_Comm_f2c(static_cast< int >(*f_local_comm));
       else local_comm = MPI_COMM_NULL;
-      
+      #else
+      if (initialized) local_comm=MPI_Comm_f2c(*f_local_comm);
+      else local_comm = MPI_COMM_NULL;
+      #endif
      
 
       CXios::initClientSide(str, local_comm, return_comm);
 
+      #ifdef _usingEP
       *f_return_comm = ep_lib::EP_Comm_c2f(return_comm);
-
-      //printf("in icdata.cpp, f_return_comm = %d\n", *f_return_comm);
+      #else
+      *f_return_comm = MPI_Comm_c2f(return_comm);
+      #endif
 
       CTimer::get("XIOS init").suspend();
@@ -89,10 +95,8 @@
      comm = ep_lib::EP_Comm_f2c(static_cast< int >(*f_comm));
 
-     //ep_lib::MPI_Comm ctx_comm;
-     //ep_lib::MPI_Comm_dup(comm, &ctx_comm);
     
      CClient::registerContext(str,comm);
      
-     printf("icdata.cpp: client register context %s : %p\n", context_id, &comm);
+     //printf("icdata.cpp: client register context %s : %p\n", context_id, &comm);
      
      CTimer::get("XIOS init context").suspend();
Index: XIOS/dev/branch_yushan/src/interface/c/oasis_cinterface.cpp
===================================================================
--- XIOS/dev/branch_yushan/src/interface/c/oasis_cinterface.cpp	(revision 1067)
+++ XIOS/dev/branch_yushan/src/interface/c/oasis_cinterface.cpp	(revision 1068)
@@ -26,5 +26,9 @@
     
     fxios_oasis_get_localcomm(&f_comm) ;
-    //comm=MPI_Comm_f2c(f_comm) ;
+    #ifdef _usingEP
+    comm=EP_Comm_f2c(f_comm.mpi_fint) ;
+    #else
+    comm=MPI_Comm_f2c(f_comm) ;
+    #endif
   }
  
@@ -34,5 +38,9 @@
     
     fxios_oasis_get_intracomm(&f_comm,server_id.data(),server_id.size()) ;
-    //comm_client_server=MPI_Comm_f2c(f_comm) ;
+    #ifdef _usingEP
+    comm_client_server=EP_Comm_f2c(f_comm.mpi_fint) ;
+    #else
+    comm_client_server=MPI_Comm_f2c(f_comm) ;
+    #endif
   }
  
@@ -42,5 +50,9 @@
     
     fxios_oasis_get_intercomm(&f_comm,server_id.data(),server_id.size()) ;
-    //comm_client_server=MPI_Comm_f2c(f_comm) ;
+    #ifdef _usingEP
+    comm_client_server=EP_Comm_f2c(f_comm.mpi_fint) ;
+    #else
+    comm_client_server=MPI_Comm_f2c(f_comm) ;
+    #endif
   }
 }
Index: XIOS/dev/branch_yushan/src/io/onetcdf4.cpp
===================================================================
--- XIOS/dev/branch_yushan/src/io/onetcdf4.cpp	(revision 1067)
+++ XIOS/dev/branch_yushan/src/io/onetcdf4.cpp	(revision 1068)
@@ -47,5 +47,5 @@
          wmpi = comm && !multifile;
          
-         ep_lib::MPI_Info info_null;
+         //ep_lib::MPI_Info info_null;
 
          if (wmpi)
@@ -57,6 +57,8 @@
             if (wmpi)
             {
-               CNetCdfInterface::createPar(filename, mode, static_cast<MPI_Comm>(comm->mpi_comm), static_cast<MPI_Info>(info_null.mpi_info), this->ncidp);
-               printf("creating file with createPar\n");
+               // printf("start creating file with createPar\n");
+               //CNetCdfInterface::createPar(filename, mode, static_cast<MPI_Comm>(comm->mpi_comm), static_cast<MPI_Info>(info_null.mpi_info), this->ncidp);
+               CNetCdfInterface::createPar(filename, mode, static_cast<MPI_Comm>(comm->mpi_comm), MPI_INFO_NULL_STD, this->ncidp);
+               // printf("creating file with createPar\n");
             }
             else
@@ -74,6 +76,8 @@
             if (wmpi)
             {
-               CNetCdfInterface::openPar(filename, mode, static_cast<MPI_Comm>(comm->mpi_comm), static_cast<MPI_Info>(info_null.mpi_info), this->ncidp);
-               printf("opening file with openPar\n");
+//               printf("start opening file with openPar\n");
+               // CNetCdfInterface::openPar(filename, mode, static_cast<MPI_Comm>(comm->mpi_comm), static_cast<MPI_Info>(info_null.mpi_info), this->ncidp);
+               CNetCdfInterface::openPar(filename, mode, static_cast<MPI_Comm>(comm->mpi_comm), MPI_INFO_NULL_STD, this->ncidp);
+//               printf("opening file with openPar\n");
             }
             else
