Index: XIOS3/trunk/src/manager/pool_ressource.cpp
===================================================================
--- XIOS3/trunk/src/manager/pool_ressource.cpp	(revision 2362)
+++ XIOS3/trunk/src/manager/pool_ressource.cpp	(revision 2404)
@@ -27,5 +27,5 @@
     
     winNotify_->lockWindow(commRank,0) ;
-    winNotify_->updateToWindow(commRank, this, &CPoolRessource::createServiceDumpOut) ;  
+    winNotify_->updateToWindow(commRank, this, &CPoolRessource::notificationsDumpOut) ;
     winNotify_->unlockWindow(commRank,0) ;       
     MPI_Barrier(poolComm_) ;
@@ -60,5 +60,18 @@
   }
 
-  
+  void CPoolRessource::createServiceOnto(const std::string& serviceId, int type, const std::string& onServiceId)
+  {
+    // for now suppose nbPartitions=1
+    
+    auto it=occupancy_.begin() ;
+    int commSize ;
+    MPI_Comm_size(poolComm_, &commSize) ;
+    
+    info(40)<<"CPoolRessource::createService  : notify createServiceOnto to all pool members ; serviceId : "<<serviceId
+            <<"  onto service Id  :"<< serviceId<<endl ;
+    for(int rank=0; rank<commSize; rank++) createServiceOntoNotify(rank, serviceId, type, onServiceId) ;
+  }
+
+/*  
   void CPoolRessource::createServiceNotify(int rank, const std::string& serviceId, int type, int size, int nbPartitions, 
                                            bool in)
@@ -70,6 +83,90 @@
     winNotify_->unlockWindow(rank,0) ;   
   }
-
-
+*/
+  
+  void CPoolRessource::createServiceNotify(int rank, const string& serviceId, int type, int size, int nbPartitions, bool in)
+  {
+    notifyType_=NOTIFY_CREATE_SERVICE ;
+    notifyCreateService_=make_tuple(serviceId, type, size, nbPartitions, in ) ;
+    sendNotification(rank) ;
+  }
+
+
+  void CPoolRessource::createServiceOntoNotify(int rank, const string& serviceId, int type, const string& onServiceId)
+  {
+    notifyType_=NOTIFY_CREATE_SERVICE_ONTO ;
+    notifyCreateServiceOnto_=make_tuple(serviceId, type, onServiceId) ;
+    sendNotification(rank) ;
+  }
+
+
+  void CPoolRessource::sendNotification(int rank)
+  {
+    winNotify_->lockWindowExclusive(rank) ;
+    winNotify_->pushToLockedWindow(rank, this, &CPoolRessource::notificationsDumpOut) ;
+    winNotify_->unlockWindow(rank) ;
+  }
+
+  void CPoolRessource::checkNotifications(void)
+  {
+    int commRank ;
+    MPI_Comm_rank(poolComm_, &commRank) ;
+    winNotify_->lockWindowExclusive(commRank) ;
+    winNotify_->popFromLockedWindow(commRank, this, &CPoolRessource::notificationsDumpIn) ;
+    winNotify_->unlockWindow(commRank) ;
+    if (notifyType_==NOTIFY_CREATE_SERVICE) createService() ;
+    else if (notifyType_==NOTIFY_CREATE_SERVICE_ONTO) createServiceOnto() ;
+  }
+
+
+  void CPoolRessource::notificationsDumpOut(CBufferOut& buffer)
+  {
+
+    buffer.realloc(maxBufferSize_) ;
+    
+    if (notifyType_==NOTIFY_CREATE_SERVICE)
+    {
+      auto& arg=notifyCreateService_ ;
+      buffer << notifyType_<< get<0>(arg) << get<1>(arg) << std::get<2>(arg) << get<3>(arg) << get<4>(arg);
+    }
+    else if (notifyType_==NOTIFY_CREATE_SERVICE_ONTO)
+    {
+      auto& arg=notifyCreateServiceOnto_ ;
+      buffer << notifyType_<< get<0>(arg) << get<1>(arg)<< get<2>(arg)  ;
+    }
+  }
+
+  void CPoolRessource::notificationsDumpIn(CBufferIn& buffer)
+  {
+    if (buffer.bufferSize() == 0) notifyType_= NOTIFY_NOTHING ;
+    else
+    {
+      buffer>>notifyType_;
+      if (notifyType_==NOTIFY_CREATE_SERVICE)
+      {
+        auto& arg=notifyCreateService_ ;
+        buffer >> get<0>(arg) >> get<1>(arg) >> std::get<2>(arg)>> get<3>(arg)>> get<4>(arg) ;
+      }
+      else if (notifyType_==NOTIFY_CREATE_SERVICE_ONTO)
+      {
+        auto& arg=notifyCreateServiceOnto_ ;
+        buffer >> get<0>(arg) >> get<1>(arg) >> get<2>(arg) ;
+      }
+    }
+  }  
+
+  void CPoolRessource::createService(void)
+  {
+    auto& arg = notifyCreateService_ ;
+    createNewService(get<0>(arg), get<1>(arg), get<2>(arg), get<3>(arg), get<4>(arg)) ;
+  }
+  
+  void CPoolRessource::createServiceOnto(void)
+  {
+    auto& arg = notifyCreateServiceOnto_ ;
+    createNewServiceOnto(get<0>(arg), get<1>(arg), get<2>(arg)) ;
+  }
+
+/*
   void CPoolRessource::createServiceDumpOut(CBufferOut& buffer)
   {
@@ -82,5 +179,7 @@
   }
 
-
+*/
+
+/*
   void CPoolRessource::createServiceDumpIn(CBufferIn& buffer)
   {
@@ -100,4 +199,5 @@
     }
   }
+*/
 
   bool CPoolRessource::eventLoop(bool serviceOnly)
@@ -110,5 +210,6 @@
     if (time-lastEventLoop_ > eventLoopLatency_) 
     {
-      checkCreateServiceNotification() ;
+      //checkCreateServiceNotification() ;
+      checkNotifications() ;
       lastEventLoop_=time ;
     }
@@ -128,5 +229,5 @@
     else return false ;
   }
-
+/*
   void CPoolRessource::checkCreateServiceNotification(void)
   {
@@ -146,4 +247,5 @@
 
   }
+*/
 
   void CPoolRessource::createNewService(const std::string& serviceId, int type, int size, int nbPartitions, bool in)
@@ -186,4 +288,27 @@
      MPI_Comm_free(&serviceComm) ;
   }
+  
+  void CPoolRessource::createNewServiceOnto(const std::string& serviceId, int type, const std::string& onServiceId)
+  {
+     
+    info(40)<<"CPoolRessource::createNewServiceOnto  : receive createServiceOnto notification ; serviceId : "
+            <<serviceId<<"  ontoServiceId : "<<onServiceId<<endl ;
+    for(auto& service : services_) 
+    {
+      if (std::get<0>(service.first)==onServiceId)
+      {
+        const MPI_Comm& serviceComm = service.second->getCommunicator() ;
+        MPI_Comm newServiceComm ;
+        MPI_Comm_dup(serviceComm, &newServiceComm) ;
+        int nbPartitions = service.second->getNbPartitions() ;
+        int partitionId = service.second->getPartitionId() ;
+        shared_ptr<CEventScheduler>  eventScheduler = service.second->getEventScheduler() ;
+        info(40)<<"CPoolRessource::createNewServiceOnto ; found onServiceId : "<<onServiceId<<endl  ;
+        services_[std::make_tuple(serviceId,partitionId)] = new CService(newServiceComm, Id_, serviceId, partitionId, type,
+                                                                         nbPartitions, eventScheduler) ;       
+      }
+    }
+    
+  }
 
   void CPoolRessource::createService(MPI_Comm serviceComm, const std::string& serviceId, int partitionId, int type, int nbPartitions) // for clients & attached
