Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/buffer_client.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/buffer_client.cpp	(revision 2258)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/buffer_client.cpp	(revision 2259)
@@ -14,5 +14,5 @@
   size_t CClientBuffer::maxRequestSize = 0;
 
-  CClientBuffer::CClientBuffer(MPI_Comm interComm, vector<MPI_Win>& windows, int clientRank, int serverRank, StdSize bufferSize, StdSize estimatedMaxEventSize)
+  CClientBuffer::CClientBuffer(MPI_Comm interComm, int serverRank, StdSize bufferSize, StdSize estimatedMaxEventSize)
     : interComm(interComm)
     , clientRank_(0)
@@ -25,8 +25,9 @@
     , pending(false)
     , hasWindows(false) 
-    , windows_(windows)
-  {
-    if (windows[0]==MPI_WIN_NULL && windows[1]==MPI_WIN_NULL) hasWindows=false ;
-    else hasWindows=true ;
+  {
+     /*
+      if (windows[0]==MPI_WIN_NULL && windows[1]==MPI_WIN_NULL) hasWindows=false ;
+      else hasWindows=true ;
+     */
 
       MPI_Alloc_mem(bufferSize+headerSize_, MPI_INFO_NULL, &bufferHeader[0]) ;
@@ -86,11 +87,42 @@
   MPI_Aint CClientBuffer::getWinAddress(int i)
   {
-     MPI_Aint address ;
-     
-     if (hasWindows) MPI_Get_address(bufferHeader[i], &address) ;
-     else address=0 ;
-
-     return address ;
-  }
+    MPI_Aint address ;
+    MPI_Get_address(bufferHeader[i], &address) ;
+    return address ;
+  }
+
+  void CClientBuffer::attachWindows(vector<MPI_Win>& windows)
+  {
+    windows_=windows ;
+    if (windows_[0]==MPI_WIN_NULL && windows_[1]==MPI_WIN_NULL) hasWindows=false ;
+    else hasWindows=true ;
+
+    if (hasWindows)
+    {  
+      MPI_Aint buffSize=bufferSize+headerSize_ ;
+      MPI_Win_attach(windows_[0], bufferHeader[0], buffSize) ;
+      MPI_Win_attach(windows_[1], bufferHeader[1], buffSize) ;
+    
+      MPI_Group group ;
+      int groupSize,groupRank ;
+      MPI_Win_get_group(windows_[0], &group) ;
+      MPI_Group_size(group, &groupSize) ;
+      MPI_Group_rank(group, &groupRank) ;
+      if (groupRank!=clientRank_) ERROR("CClientBuffer::CClientBuffer",<< " ClientRank != groupRank "<<clientRank_<<" "<<groupRank);
+
+      MPI_Win_get_group(windows_[1], &group) ;
+      MPI_Group_size(group, &groupSize) ;
+      MPI_Group_rank(group, &groupRank) ;
+      if (groupRank!=clientRank_) ERROR("CClientBuffer::CClientBuffer",<< " ClientRank != groupRank "<<clientRank_<<" "<<groupRank);
+
+      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, clientRank_, 0, windows_[0]) ;
+      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, clientRank_, 0, windows_[1]) ;
+
+      MPI_Win_unlock(clientRank_, windows_[1]) ;
+      MPI_Win_unlock(clientRank_, windows_[0]) ;
+    } 
+
+  }
+
 
   CClientBuffer::~CClientBuffer()
@@ -217,10 +249,13 @@
     int flag;
     
-    MPI_Win_lock(MPI_LOCK_EXCLUSIVE, clientRank_, 0, windows_[0]) ;
-    MPI_Win_unlock(clientRank_, windows_[0]) ;
-
-    MPI_Win_lock(MPI_LOCK_EXCLUSIVE, clientRank_, 0, windows_[1]) ;
-    MPI_Win_unlock(clientRank_, windows_[1]) ;
-
+    if (hasWindows)
+    { 
+      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, clientRank_, 0, windows_[0]) ;
+      MPI_Win_unlock(clientRank_, windows_[0]) ;
+
+      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, clientRank_, 0, windows_[1]) ;
+      MPI_Win_unlock(clientRank_, windows_[1]) ;
+    }
+    
     if (pending)
     {
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/buffer_client.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/buffer_client.hpp	(revision 2258)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/buffer_client.hpp	(revision 2259)
@@ -15,5 +15,5 @@
       static size_t maxRequestSize;
 
-      CClientBuffer(MPI_Comm intercomm, vector<MPI_Win>& windows, int clientRank, int serverRank, StdSize bufferSize, StdSize estimatedMaxEventSize);
+      CClientBuffer(MPI_Comm intercomm, int serverRank, StdSize bufferSize, StdSize estimatedMaxEventSize);
       ~CClientBuffer();
 //      void createWindows(MPI_Comm oneSidedComm) ;
@@ -33,4 +33,5 @@
       void fixBufferSize(size_t bufferSize) { newBufferSize_=bufferSize ; isGrowableBuffer_=false ; resizingBufferStep_=1 ;}
       void fixBuffer(void) { isGrowableBuffer_=false ;}
+      void attachWindows(vector<MPI_Win>& windows) ;
     private:
        void resizeBuffer(size_t newSize) ;
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/context_client.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/context_client.cpp	(revision 2258)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/context_client.cpp	(revision 2259)
@@ -50,34 +50,7 @@
       computeLeader(clientRank, clientSize, serverSize, ranksServerLeader, ranksServerNotLeader);
 
-      if (flag) MPI_Intercomm_merge(interComm_,false, &interCommMerged) ;
-      
-      if (!isAttachedModeEnabled())
-      {  
-
-        CTimer::get("create Windows").resume() ;
-
-        // We create dummy pair of intercommunicator between clients and server
-        // Why ? Just because on openMPI, it reduce the creation time of windows otherwhise which increase quadratically
-        // We don't know the reason
-        double time ;
-        MPI_Comm commSelf ;
-        MPI_Comm_split(intraComm_,clientRank,clientRank, &commSelf) ;
-        MPI_Comm interComm ;
-        winComm_.resize(serverSize) ;
-        windows_.resize(serverSize) ;
-        for(int rank=0; rank<serverSize; rank++) 
-        {
-          time=MPI_Wtime() ;
-          MPI_Intercomm_create(commSelf, 0, interCommMerged, clientSize+rank, 0, &interComm) ;
-          MPI_Intercomm_merge(interComm, false, &winComm_[rank]) ;
-          windows_[rank].resize(2) ;
-          MPI_Win_create_dynamic(MPI_INFO_NULL, winComm_[rank], &windows_[rank][0]);
-          MPI_Win_create_dynamic(MPI_INFO_NULL, winComm_[rank], &windows_[rank][1]);  
-          time=MPI_Wtime()-time ;
-          info(100)<< "MPI_Win_create_dynamic : client to server rank "<<rank<<" => "<<time/1e-6<<" us"<<endl ;
-        }
-        MPI_Comm_free(&commSelf) ;
-        CTimer::get("create Windows").resume() ;
-     }
+      if (flag) MPI_Intercomm_merge(interComm_,false, &interCommMerged_) ;
+      
+      MPI_Comm_split(intraComm_,clientRank,clientRank, &commSelf_) ; // for windows
 
       auto time=chrono::system_clock::now().time_since_epoch().count() ;
@@ -338,8 +311,5 @@
       }
       
-      vector<MPI_Win> Wins(2,MPI_WIN_NULL) ;
-      if (!isAttachedModeEnabled()) Wins=windows_[rank] ;
-  
-      CClientBuffer* buffer = buffers[rank] = new CClientBuffer(interComm, Wins, clientRank, rank, mapBufferSize_[rank], maxEventSizes[rank]);
+      CClientBuffer* buffer = buffers[rank] = new CClientBuffer(interComm, rank, mapBufferSize_[rank], maxEventSizes[rank]);
       if (isGrowableBuffer_) buffer->setGrowableBuffer(1.2) ;
       else buffer->fixBuffer() ;
@@ -354,5 +324,26 @@
       bufOut->put(sendBuff, 4); 
       buffer->checkBuffer(true);
-
+      
+       // create windows dynamically for one-sided
+      if (!isAttachedModeEnabled())
+      { 
+        CTimer::get("create Windows").resume() ;
+        MPI_Comm interComm ;
+        MPI_Intercomm_create(commSelf_, 0, interCommMerged_, clientSize+rank, 0, &interComm) ;
+        MPI_Intercomm_merge(interComm, false, &winComm_[rank]) ;
+        MPI_Comm_free(&interComm) ;
+        windows_[rank].resize(2) ;
+        MPI_Win_create_dynamic(MPI_INFO_NULL, winComm_[rank], &windows_[rank][0]);
+        MPI_Win_create_dynamic(MPI_INFO_NULL, winComm_[rank], &windows_[rank][1]);   
+        CTimer::get("create Windows").suspend() ;
+      }
+      else
+      {
+        winComm_[rank] = MPI_COMM_NULL ;
+        windows_[rank].resize(2) ;
+        windows_[rank][0] = MPI_WIN_NULL ;
+        windows_[rank][1] = MPI_WIN_NULL ;
+      }
+      buffer->attachWindows(windows_[rank]) ;
    }
 
@@ -384,6 +375,7 @@
       if (!isAttachedModeEnabled())
       {  
-        for(int rank=0; rank<serverSize; rank++)
-        {
+        for(auto& it : winComm_)
+        {
+          int rank = it.first ;
           MPI_Win_free(&windows_[rank][0]);
           MPI_Win_free(&windows_[rank][1]);
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/context_client.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/context_client.hpp	(revision 2258)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/context_client.hpp	(revision 2259)
@@ -90,5 +90,6 @@
       MPI_Comm interComm; //!< Communicator of server group (interCommunicator)
 
-      MPI_Comm interCommMerged; //!< Communicator of the client group + server group (intraCommunicator) needed for one sided communication.
+      MPI_Comm interCommMerged_; //!< Communicator of the client group + server group (intraCommunicator) needed for one sided communication.
+      MPI_Comm commSelf_ ; //!< Communicator for proc alone from interCommMerged 
 
       MPI_Comm intraComm; //!< Communicator of client group
@@ -120,6 +121,6 @@
       std::list<int> ranksServerNotLeader;
 
-      std::vector<MPI_Comm> winComm_ ; //! Window communicators
-      std::vector<std::vector<MPI_Win> >windows_ ; //! one sided mpi windows to expose client buffers to servers == windows[nbServers][2]
+      std::map<int, MPI_Comm> winComm_ ; //! Window communicators
+      std::map<int, std::vector<MPI_Win> >windows_ ; //! one sided mpi windows to expose client buffers to servers == windows[nbServers][2]
       bool isAttached_ ;
       CContextServer* associatedServer_ ; //!< The server associated to the pair client/server
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/context_server.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/context_server.cpp	(revision 2258)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/context_server.cpp	(revision 2259)
@@ -73,42 +73,6 @@
 
 
-    if (!isAttachedModeEnabled())
-    {
-      CTimer::get("create Windows").resume() ;
-
-      MPI_Intercomm_merge(interComm_,true,&interCommMerged) ;
-
-      double time ;
-      windows_.resize(clientSize_) ;
-      MPI_Comm commSelf ;
-      MPI_Comm_split(intraComm_, intraCommRank, intraCommRank, &commSelf) ;
-      MPI_Comm interComm ;
-      winComm_.resize(clientSize_) ;
-      for(int rank=0; rank<clientSize_ ; rank++) 
-      {
-        time=MPI_Wtime() ;
-        MPI_Intercomm_create(commSelf, 0, interCommMerged, rank, 0 , &interComm) ;
-        MPI_Intercomm_merge(interComm, true, &winComm_[rank]) ;
-        windows_[rank].resize(2) ;
-        MPI_Win_create_dynamic(MPI_INFO_NULL, winComm_[rank], &windows_[rank][0]);
-        MPI_Win_create_dynamic(MPI_INFO_NULL, winComm_[rank], &windows_[rank][1]);  
-        time=MPI_Wtime()-time ;
-        info(100)<< "MPI_Win_create_dynamic : server to client rank "<<rank<<" => "<<time/1e-6<<" us"<<endl ;
-      }
-      MPI_Comm_free(&commSelf) ;
-      CTimer::get("create Windows").suspend() ;
-    }
-    else 
-    {
-      winComm_.resize(clientSize_) ;
-      windows_.resize(clientSize_) ;
-      for(int rank=0; rank<clientSize_ ; rank++) 
-      {
-        winComm_[rank] = MPI_COMM_NULL ;
-        windows_[rank].resize(2) ;
-        windows_[rank][0]=MPI_WIN_NULL ;
-        windows_[rank][1]=MPI_WIN_NULL ;
-      }
-    }
+    if (!isAttachedModeEnabled()) MPI_Intercomm_merge(interComm_,true,&interCommMerged_) ;
+    MPI_Comm_split(intraComm_, intraCommRank, intraCommRank, &commSelf_) ; // for windows
     
     itLastTimeLine=lastTimeLine.begin() ;
@@ -183,15 +147,37 @@
     if (it==buffers.end()) // Receive the buffer size and allocate the buffer
     {
-       MPI_Aint recvBuff[4] ;
-       MPI_Mrecv(recvBuff, 4, MPI_AINT,  &message, &status);
-       remoteHashId_ = recvBuff[0] ;
-       StdSize buffSize = recvBuff[1];
-       vector<MPI_Aint> winAdress(2) ;
-       winAdress[0]=recvBuff[2] ; winAdress[1]=recvBuff[3] ;
-       mapBufferSize_.insert(std::make_pair(rank, buffSize));
-       it=(buffers.insert(pair<int,CServerBuffer*>(rank,new CServerBuffer(windows_[rank], winAdress, 0, buffSize)))).first;
-       lastTimeLine[rank]=0 ;
-       itLastTimeLine=lastTimeLine.begin() ;
-       return true;
+      MPI_Aint recvBuff[4] ;
+      MPI_Mrecv(recvBuff, 4, MPI_AINT,  &message, &status);
+      remoteHashId_ = recvBuff[0] ;
+      StdSize buffSize = recvBuff[1];
+      vector<MPI_Aint> winAdress(2) ;
+      winAdress[0]=recvBuff[2] ; winAdress[1]=recvBuff[3] ;
+      mapBufferSize_.insert(std::make_pair(rank, buffSize));
+
+      // create windows dynamically for one-sided
+      if (!isAttachedModeEnabled())
+      { 
+        CTimer::get("create Windows").resume() ;
+        MPI_Comm interComm ;
+        MPI_Intercomm_create(commSelf_, 0, interCommMerged_, rank, 0 , &interComm) ;
+        MPI_Intercomm_merge(interComm, true, &winComm_[rank]) ;
+        windows_[rank].resize(2) ;
+        MPI_Win_create_dynamic(MPI_INFO_NULL, winComm_[rank], &windows_[rank][0]);
+        MPI_Win_create_dynamic(MPI_INFO_NULL, winComm_[rank], &windows_[rank][1]);
+        CTimer::get("create Windows").suspend() ;
+      }
+      else
+      {
+        winComm_[rank] = MPI_COMM_NULL ;
+        windows_[rank].resize(2) ;
+        windows_[rank][0] = MPI_WIN_NULL ;
+        windows_[rank][1] = MPI_WIN_NULL ;
+      }   
+
+      it=(buffers.insert(pair<int,CServerBuffer*>(rank,new CServerBuffer(windows_[rank], winAdress, 0, buffSize)))).first;
+      lastTimeLine[rank]=0 ;
+      itLastTimeLine=lastTimeLine.begin() ;
+
+      return true;
     }
     else
@@ -425,6 +411,7 @@
     if (!isAttachedModeEnabled())
     {
-      for(int rank=0; rank<clientSize_; rank++)
-      {
+      for(auto& it : winComm_)
+      {
+        int rank = it.first ;
         MPI_Win_free(&windows_[rank][0]);
         MPI_Win_free(&windows_[rank][1]);
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/context_server.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/context_server.hpp	(revision 2258)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/context_server.hpp	(revision 2259)
@@ -44,5 +44,6 @@
     int clientSize_ ;
 
-    MPI_Comm interCommMerged; //!< Communicator of the client group + server group (intraCommunicator) needed for one sided communication.
+    MPI_Comm interCommMerged_; //!< Communicator of the client group + server group (intraCommunicator) needed for one sided communication.
+    MPI_Comm commSelf_ ; //!< Communicator for proc alone from interCommMerged 
 
     map<int,CServerBuffer*> buffers ;
@@ -71,8 +72,8 @@
 
     private:
-
+  
       std::map<int, StdSize> mapBufferSize_;
-      std::vector<MPI_Comm>winComm_ ; //! Window communicators
-      std::vector<std::vector<MPI_Win> >windows_ ; //! one sided mpi windows to expose client buffers to servers ; No memory will be attached on server side.
+      std::map<int,MPI_Comm> winComm_ ; //! Window communicators
+      std::map<int,std::vector<MPI_Win> >windows_ ; //! one sided mpi windows to expose client buffers to servers ; No memory will be attached on server side.
       CEventScheduler* eventScheduler_ ;
       bool isProcessingEvent_ ;
