Index: /XIOS/dev/branch_openmp/bld.cfg
===================================================================
--- /XIOS/dev/branch_openmp/bld.cfg	(revision 1532)
+++ /XIOS/dev/branch_openmp/bld.cfg	(revision 1533)
@@ -32,7 +32,7 @@
 #src::src_ep_dev $PWD/extern/ep_dev
 bld::lib xios
-bld::target libxios.a 
+#bld::target libxios.a 
 #bld::target generate_fortran_interface.exe 
-bld::target xios_server.exe 
+#bld::target xios_server.exe 
 #bld::target test_regular.exe
 #bld::target test_expand_domain.exe
@@ -40,8 +40,8 @@
 #bld::target test_unstruct_complete.exe 
 bld::target test_omp.exe 
-bld::target test_complete_omp.exe 
+#bld::target test_complete_omp.exe 
 #bld::target test_remap.exe 
 #bld::target test_remap_ref.exe 
-bld::target test_remap_omp.exe 
+#bld::target test_remap_omp.exe 
 #bld::target test_unstruct_omp.exe
 #bld::target test_netcdf_omp.exe
@@ -52,5 +52,5 @@
 #bld::target test_connectivity_expand.exe
 #bld::target toy_cmip6.exe
-bld::target toy_cmip6_omp.exe
+#bld::target toy_cmip6_omp.exe
 bld::exe_dep
 
Index: /XIOS/dev/branch_openmp/extern/ep_dev/ep_intercomm.cpp
===================================================================
--- /XIOS/dev/branch_openmp/extern/ep_dev/ep_intercomm.cpp	(revision 1532)
+++ /XIOS/dev/branch_openmp/extern/ep_dev/ep_intercomm.cpp	(revision 1533)
@@ -296,5 +296,5 @@
     
 
-    int remote_num_ep;
+    int remote_num_ep = 0;
     for(int i=0; i<remote_mpi_size; i++)
     {
Index: /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_free.cpp
===================================================================
--- /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_free.cpp	(revision 1532)
+++ /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_free.cpp	(revision 1533)
@@ -118,4 +118,5 @@
     int newcomm_num_ep = (*comm)->ep_comm_ptr->intercomm->size_rank_info[1].second;
 
+    return 0;
     MPI_Barrier(*comm);
 
Index: /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_init.cpp
===================================================================
--- /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_init.cpp	(revision 1532)
+++ /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_init.cpp	(revision 1533)
@@ -28,4 +28,9 @@
     }
   }
+  
+  int EP_group_init()
+  {
+  
+  }
 
   int MPI_Initialized(int *flag)
Index: /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_lib.hpp
===================================================================
--- /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_lib.hpp	(revision 1532)
+++ /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_lib.hpp	(revision 1533)
@@ -82,6 +82,10 @@
 
   int Request_Check();
+  
+  void show_EP_PendingRequests(std::list< ep_lib::MPI_Request* > * EP_PendingRequest);
 
   int test_sendrecv(MPI_Comm comm);
+  
+  int EP_group_init();
 
 
Index: /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_message.cpp
===================================================================
--- /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_message.cpp	(revision 1532)
+++ /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_message.cpp	(revision 1533)
@@ -23,4 +23,6 @@
     
     if(EP_PendingRequests->size() == 0) return 0;
+    
+    show_EP_PendingRequests(EP_PendingRequests);
     
     MPI_Status status;
@@ -30,13 +32,53 @@
     std::list<MPI_Request* >::iterator it;
     
+//    show_EP_PendingRequests(EP_PendingRequests);
+    
     
     for(it = EP_PendingRequests->begin(); it!=EP_PendingRequests->end(); it++)
     { 
+      if(*(*it) == 0)
+      {
+        EP_PendingRequests->erase(it);
+        
+        memcheck("EP_PendingRequests["<<ep_rank<<"]->size() = " << EP_PendingRequests->size());
+        it = EP_PendingRequests->begin();
+        continue;
+      }
+      
+      if((*(*it))->state == 2)
+      {
+        EP_PendingRequests->erase(it);
+        
+        memcheck("EP_PendingRequests["<<ep_rank<<"]->size() = " << EP_PendingRequests->size());
+        it = EP_PendingRequests->begin();
+        continue;
+      }
+      
       Message_Check(((*(*it))->comm));
     }
+    
+    
 
 
     for(it = EP_PendingRequests->begin(); it!=EP_PendingRequests->end(); )
     {
+      if(*(*it) == 0)
+      {
+        EP_PendingRequests->erase(it);
+        
+        memcheck("EP_PendingRequests["<<ep_rank<<"]->size() = " << EP_PendingRequests->size());
+        it = EP_PendingRequests->begin();
+        continue;
+      }
+      
+      if((*(*it))->state == 2)
+      {
+        EP_PendingRequests->erase(it);
+        
+        memcheck("EP_PendingRequests["<<ep_rank<<"]->size() = " << EP_PendingRequests->size());
+        it = EP_PendingRequests->begin();
+        continue;
+      }
+      
       if((*(*it))->state == 0)
       {
@@ -81,25 +123,8 @@
       }
       
-      if((*(*it))->state == 2)
-      {
-        int ep_rank = ((*(*it))->comm)->ep_comm_ptr->size_rank_info[0].first;
-        memcheck("delete "<< (*(*it)) <<" : in ep_lib::Request_Check, delete (*(*it))");
-        
-        
-        int world_rank;
-        MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
-        if(world_rank==2) 
-        {
-          printf("ep %d erased one pending request %p\n", world_rank,*(*it));
-        }
-        
-        EP_PendingRequests->erase(it);
-        
-        memcheck("EP_PendingRequests["<<ep_rank<<"]->size() = " << EP_PendingRequests->size());
-        it = EP_PendingRequests->begin();
-        continue;
-      }
-      else it++;
-    }
+      it++;
+    }
+    
+    show_EP_PendingRequests(EP_PendingRequests);
   }
   
@@ -178,9 +203,4 @@
     return MPI_SUCCESS;
   }
-
-
-  
-  
-  
 
 
@@ -249,4 +269,41 @@
     return MPI_SUCCESS;
   }
+  
+  
+  
+  void show_EP_PendingRequests(std::list< ep_lib::MPI_Request* > * EP_PendingRequest)
+  {
+#ifdef _showinfo
+    std::list<MPI_Request* >::iterator it;
+    
+    int i=0;
+    
+    for(it = EP_PendingRequests->begin(); it!=EP_PendingRequests->end(); it++)
+    { 
+      if(*(*it) == 0)
+      {
+        EP_PendingRequests->erase(it);
+            
+        memcheck("EP_PendingRequests["<<ep_rank<<"]->size() = " << EP_PendingRequests->size());
+        it = EP_PendingRequests->begin();
+        continue;
+      }
+      
+      if((*(*it))->state == 2)
+      {
+        EP_PendingRequests->erase(it);
+        
+        memcheck("EP_PendingRequests["<<ep_rank<<"]->size() = " << EP_PendingRequests->size());
+        it = EP_PendingRequests->begin();
+        continue;
+      }
+          
+      if((*(*it))->ep_src>6)
+        printf("EP_PendingRequests[%d] : ep_src = %d, ep_tag = %d, type = %d, state = %d, comm = %d\n", i, (*(*it))->ep_src, (*(*it))->ep_tag, (*(*it))->type, (*(*it))->state, to_mpi_comm(((*(*it))->comm)->mpi_comm));
+      i++;
+    }
+#endif
+
+  }
 
   
Index: /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_recv.cpp
===================================================================
--- /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_recv.cpp	(revision 1532)
+++ /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_recv.cpp	(revision 1533)
@@ -65,12 +65,7 @@
     EP_PendingRequests->push_back(request);  
     
-    int world_rank;
-    MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
-    if(world_rank==2) 
-    {
-      printf("ep %d inserted one pending request %p\n", world_rank, *request);
-    }
+    memcheck("EP_PendingRequests["<<ep_rank<<"]->size() = " << EP_PendingRequests->size());    
     
-    memcheck("EP_PendingRequests["<<ep_rank<<"]->size() = " << EP_PendingRequests->size());    
+    show_EP_PendingRequests(EP_PendingRequests);
 
 #ifdef _showinfo
Index: /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_test.cpp
===================================================================
--- /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_test.cpp	(revision 1532)
+++ /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_test.cpp	(revision 1533)
@@ -9,4 +9,5 @@
 #include <mpi.h>
 #include "ep_declaration.hpp"
+#include "ep_mpi.hpp"
 
 using namespace std;
@@ -18,49 +19,32 @@
   {
     Debug("MPI_Test with EP");
-
-    *flag = false;
     
-
-    if((*request)->type == 1)      // isend
+    if(*request==0) return *flag=true;
+    
+    if((*request)->type !=1 && (*request)->type !=2 && (*request)->type !=3) 
     {
-      ::MPI_Status mpi_status;
-      ::MPI_Test(static_cast< ::MPI_Request*>((*request)->mpi_request), flag, &mpi_status);
-      
-      if(*flag) 
-      {
-        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;
-        (*request)->state = 2;
-        delete (*request)->mpi_request;
-        delete *request;
-      }
-
-      return 0;
+      printf("MPI_Test : Error in request type\n");
+ 
+      exit(1);
     }
 
     if((*request)->type == 2)   // irecv message not probed
     {
-      Request_Check();
+      *flag = false;
+      return Request_Check();
+    }
+    
+    else //(*request)->type == 1 || (*request)->type == 3      // isend or imrecv
+    {
       
-      #pragma omp flush
-      
-    }
-
-    if((*request)->type == 3)  // imrecv
-    {
-      if((*request)->state == 2)
-      {
-        return *flag = true;
-      }
       ::MPI_Status mpi_status;
       
-      ::MPI_Test(static_cast< ::MPI_Request*>((*request)->mpi_request), flag, &mpi_status);
       
+      ::MPI_Test(to_mpi_request_ptr(*request), flag, &mpi_status);
       
-      if(*flag)
+      if(*flag) 
       {
-        status->mpi_status = new ::MPI_Status(mpi_status);
+
+        status->mpi_status=new ::MPI_Status(mpi_status);
         status->ep_src = (*request)->ep_src;
         status->ep_tag = (*request)->ep_tag;
@@ -68,14 +52,13 @@
         
         (*request)->state = 2;
-        
+                
+        memcheck("delete "<< (*request)->mpi_request << " : in ep_lib::MPI_Test, delete (*request)->mpi_request");
         delete (*request)->mpi_request;
         delete *request;
-        //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);
-      }  
-
-      return Request_Check();
+        *request=0;
+      }
     }
+    
+    return Request_Check();
 
   }
@@ -85,5 +68,17 @@
   {
     Debug("MPI_Testall with EP");
-
+    *flag = false;
+   
+    int rank = array_of_requests[0]->comm->ep_comm_ptr->size_rank_info[0].first;
+    
+    for(int i=0; i<count; i++)
+    {
+      if(array_of_requests[i]->type == 2)
+      {
+        *flag=false;
+        return Request_Check();
+      }
+    }
+    
     ::MPI_Request* mpi_request = new ::MPI_Request[count];
     ::MPI_Status* mpi_status = new ::MPI_Status[count];
@@ -101,5 +96,5 @@
       for(int i=0; i<count; i++)
       {
-        array_of_statuses[i].mpi_status = &mpi_status[i];
+        array_of_statuses[i].mpi_status = new ::MPI_Status(mpi_status[i]);
         array_of_statuses[i].ep_src = array_of_requests[i]->ep_src;
         array_of_statuses[i].ep_tag = array_of_requests[i]->ep_tag;
@@ -108,12 +103,15 @@
         array_of_requests[i]->state = 2;
       
-        memcheck("delete "<< array_of_requests[i]->mpi_request <<" : in ep_lib::MPI_Waitall, array_of_requests["<<i<<"]->mpi_request");
+        memcheck("delete "<< array_of_requests[i]->mpi_request <<" : in ep_lib::MPI_Testall, array_of_requests["<<i<<"]->mpi_request");
         delete array_of_requests[i]->mpi_request;
-        delete array_of_requests[i]; 
+        delete array_of_requests[i];
+        array_of_requests[i]=0;
+        
       }
       
     }
+    
+    return Request_Check();
 
-    return Request_Check();
   }
 
Index: /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_wait.cpp
===================================================================
--- /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_wait.cpp	(revision 1532)
+++ /XIOS/dev/branch_openmp/extern/src_ep_dev/ep_wait.cpp	(revision 1533)
@@ -25,5 +25,5 @@
     if((*request)->type !=1 && (*request)->type !=2 && (*request)->type !=3) 
     {
-      printf("Error in request type\n");
+      printf("MPI_Wait : Error in request type\n");
  
       exit(1);
@@ -32,7 +32,9 @@
     while((*request)->type == 2) Request_Check();
     
-    ::MPI_Wait(to_mpi_request_ptr(*request), to_mpi_status_ptr(status));
+    ::MPI_Status mpi_status;
+    
+    ::MPI_Wait(to_mpi_request_ptr(*request), &mpi_status);
 
-    
+    status->mpi_status = new ::MPI_Status(mpi_status);
     status->ep_src = (*request)->ep_src;
     status->ep_tag = (*request)->ep_tag;
@@ -42,8 +44,9 @@
 
     memcheck("delete "<< (*request)->mpi_request << " : in ep_lib::MPI_Wait, delete (*request)->mpi_request");
+
     delete (*request)->mpi_request;
     delete *request;
+    *request=0;
     
-
     return Request_Check();
 
@@ -87,5 +90,5 @@
     for(int i=0; i<count; i++)
     {
-      array_of_statuses[i].mpi_status = &mpi_status[i];
+      array_of_statuses[i].mpi_status = new ::MPI_Status(mpi_status[i]);
       array_of_statuses[i].ep_src = array_of_requests[i]->ep_src;
       array_of_statuses[i].ep_tag = array_of_requests[i]->ep_tag;
@@ -97,4 +100,5 @@
       delete array_of_requests[i]->mpi_request;
       delete array_of_requests[i];
+      array_of_requests[i] = 0;
     }
 
Index: /XIOS/dev/branch_openmp/src/cxios.cpp
===================================================================
--- /XIOS/dev/branch_openmp/src/cxios.cpp	(revision 1532)
+++ /XIOS/dev/branch_openmp/src/cxios.cpp	(revision 1533)
@@ -107,5 +107,7 @@
       MPI_Comm *ep_comm;
       MPI_Comm_create_endpoints(MPI_COMM_WORLD->mpi_comm, num_ep, info, ep_comm);  // servers should reach here too.
-      passage = ep_comm;  
+      passage = ep_comm; 
+      EP_group_init();
+      //::MPI_Comm_group(to_mpi_comm(MPI_COMM_WORLD->mpi_comm), &MPI_GROUP_WORLD); 
     }
         
Index: /XIOS/dev/branch_openmp/src/event_scheduler.cpp
===================================================================
--- /XIOS/dev/branch_openmp/src/event_scheduler.cpp	(revision 1532)
+++ /XIOS/dev/branch_openmp/src/event_scheduler.cpp	(revision 1533)
@@ -140,5 +140,4 @@
       if (received)
       {
-        printf("probed a message coming from parent\n"),
         recvRequest=new SPendingRequest ;
         MPI_Irecv(recvRequest->buffer, 3, MPI_UNSIGNED_LONG, -2, 1, communicator, &(recvRequest->request)) ;
Index: /XIOS/dev/branch_openmp/src/server.cpp
===================================================================
--- /XIOS/dev/branch_openmp/src/server.cpp	(revision 1532)
+++ /XIOS/dev/branch_openmp/src/server.cpp	(revision 1533)
@@ -658,6 +658,8 @@
          MPI_Get_count(&status,MPI_CHAR,&(counts.back())) ;
          buffers.push_back(new char[counts.back()]) ;
+         //requests.push_back(request);
+         //MPI_Irecv((void*)(buffers.back()),counts.back(),MPI_CHAR,root,2,intraComm,&(requests.back())) ;
+         MPI_Irecv((void*)(buffers.back()),counts.back(),MPI_CHAR,root,2,intraComm,&request) ;
          requests.push_back(request);
-         MPI_Irecv((void*)(buffers.back()),counts.back(),MPI_CHAR,root,2,intraComm,&(requests.back())) ;
          isEventRegistered.push_back(false);
          isEventQueued.push_back(false);
@@ -668,5 +670,5 @@
        {
          // (2) If context id is received, register an event
-         MPI_Test(&requests[ctxNb],&flag,&status) ;
+         if(!isEventRegistered[ctxNb]) MPI_Test(&requests[ctxNb],&flag,&status) ;
          if (flag==true && !isEventRegistered[ctxNb])
          {
