Index: XIOS/dev/dev_olga/src/group_template_impl.hpp
===================================================================
--- XIOS/dev/dev_olga/src/group_template_impl.hpp	(revision 983)
+++ XIOS/dev/dev_olga/src/group_template_impl.hpp	(revision 987)
@@ -373,23 +373,43 @@
    void CGroupTemplate<U, V, W>::sendCreateChild(const string& id)
    {
-    CContext* context=CContext::getCurrent() ;
-    
-    if (! context->hasServer )
+    CContext* context=CContext::getCurrent() ;  
+
+    if (context->hasClient)
+    // if (!context->hasServer )
     {
-       CContextClient* client=context->client ;
+      // Use correct context client to send message
+       CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client;
 
        CEventClient event(this->getType(),EVENT_ID_CREATE_CHILD) ;   
-       if (client->isServerLeader())
+       if (contextClientTmp->isServerLeader())
        {
          CMessage msg ;
          msg<<this->getId() ;
          msg<<id ;
-         const std::list<int>& ranks = client->getRanksServerLeader();
+         const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();
          for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
            event.push(*itRank,1,msg) ;
-         client->sendEvent(event) ;
+         contextClientTmp->sendEvent(event) ;
        }
-       else client->sendEvent(event) ;
+       else contextClientTmp->sendEvent(event) ;
     }
+
+    // if (! context->hasServer )
+    // {
+    //    CContextClient* client=context->client ;
+
+    //    CEventClient event(this->getType(),EVENT_ID_CREATE_CHILD) ;   
+    //    if (client->isServerLeader())
+    //    {
+    //      CMessage msg ;
+    //      msg<<this->getId() ;
+    //      msg<<id ;
+    //      const std::list<int>& ranks = client->getRanksServerLeader();
+    //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+    //        event.push(*itRank,1,msg) ;
+    //      client->sendEvent(event) ;
+    //    }
+    //    else client->sendEvent(event) ;
+    // }
       
    }
@@ -399,21 +419,42 @@
    {
     CContext* context=CContext::getCurrent() ;
-    if (! context->hasServer )
+
+        // if (! context->hasServer )
+    if (context->hasClient)
     {
-       CContextClient* client=context->client ;
+        // Use correct context client to send message
+       CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client;
 
        CEventClient event(this->getType(),EVENT_ID_CREATE_CHILD_GROUP) ;   
-       if (client->isServerLeader())
+       if (contextClientTmp->isServerLeader())
        {
          CMessage msg ;
          msg<<this->getId() ;
          msg<<id ;
-         const std::list<int>& ranks = client->getRanksServerLeader();
+         const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();
          for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
            event.push(*itRank,1,msg) ;
-         client->sendEvent(event) ;
+         contextClientTmp->sendEvent(event) ;
        }
-       else client->sendEvent(event) ;
+       else contextClientTmp->sendEvent(event) ;
     }
+
+    // if (! context->hasServer )
+    // {
+    //    CContextClient* client=context->client ;
+
+    //    CEventClient event(this->getType(),EVENT_ID_CREATE_CHILD_GROUP) ;   
+    //    if (client->isServerLeader())
+    //    {
+    //      CMessage msg ;
+    //      msg<<this->getId() ;
+    //      msg<<id ;
+    //      const std::list<int>& ranks = client->getRanksServerLeader();
+    //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+    //        event.push(*itRank,1,msg) ;
+    //      client->sendEvent(event) ;
+    //    }
+    //    else client->sendEvent(event) ;
+    // }
       
    }
Index: XIOS/dev/dev_olga/src/node/axis.cpp
===================================================================
--- XIOS/dev/dev_olga/src/node/axis.cpp	(revision 983)
+++ XIOS/dev/dev_olga/src/node/axis.cpp	(revision 987)
@@ -845,10 +845,54 @@
   }
 
+  // void CAxis::sendServerAttribut(const std::vector<int>& globalDim, int orderPositionInGrid,
+  //                                CServerDistributionDescription::ServerDistributionType distType)
+  // {
+  //   CContext* context = CContext::getCurrent();
+  //   CContextClient* client = context->client;
+  //   int nbServer = client->serverSize;
+
+  //   CServerDistributionDescription serverDescription(globalDim, nbServer);
+  //   serverDescription.computeServerDistribution();
+
+  //   std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin();
+  //   std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes();
+
+  //   CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT);
+  //   if (client->isServerLeader())
+  //   {
+  //     std::list<CMessage> msgs;
+
+  //     const std::list<int>& ranks = client->getRanksServerLeader();
+  //     for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+  //     {
+  //       // Use const int to ensure CMessage holds a copy of the value instead of just a reference
+  //       const int begin = serverIndexBegin[*itRank][orderPositionInGrid];
+  //       const int ni    = serverDimensionSizes[*itRank][orderPositionInGrid];
+  //       const int end   = begin + ni - 1;
+
+  //       msgs.push_back(CMessage());
+  //       CMessage& msg = msgs.back();
+  //       msg << this->getId();
+  //       msg << ni << begin << end;
+  //       msg << global_zoom_begin.getValue() << global_zoom_n.getValue();
+  //       msg << isCompressible_;
+
+  //       event.push(*itRank,1,msg);
+  //     }
+  //     client->sendEvent(event);
+  //   }
+  //   else client->sendEvent(event);
+  // }
+
   void CAxis::sendServerAttribut(const std::vector<int>& globalDim, int orderPositionInGrid,
                                  CServerDistributionDescription::ServerDistributionType distType)
   {
     CContext* context = CContext::getCurrent();
-    CContextClient* client = context->client;
-    int nbServer = client->serverSize;
+
+    CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer 
+                                                                        : context->client;
+
+    
+    int nbServer = contextClientTmp->serverSize;
 
     CServerDistributionDescription serverDescription(globalDim, nbServer);
@@ -858,10 +902,13 @@
     std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes();
 
+    globalDimGrid.resize(globalDim.size());
+    for (int idx = 0; idx < globalDim.size(); ++idx) globalDimGrid(idx) = globalDim[idx];
+
     CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT);
-    if (client->isServerLeader())
+    if (contextClientTmp->isServerLeader())
     {
       std::list<CMessage> msgs;
 
-      const std::list<int>& ranks = client->getRanksServerLeader();
+      const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();
       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
       {
@@ -877,10 +924,12 @@
         msg << global_zoom_begin.getValue() << global_zoom_n.getValue();
         msg << isCompressible_;
+        msg << orderPositionInGrid;
+        msg << globalDimGrid;
 
         event.push(*itRank,1,msg);
       }
-      client->sendEvent(event);
-    }
-    else client->sendEvent(event);
+      contextClientTmp->sendEvent(event);
+    }
+    else contextClientTmp->sendEvent(event);
   }
 
@@ -891,4 +940,13 @@
     *buffer >> axisId;
     get(axisId)->recvServerAttribut(*buffer);
+
+    CContext* context = CContext::getCurrent();
+    if (context->hasClient && context->hasServer)
+    {
+      std::vector<int> globalDim(get(axisId)->globalDimGrid.numElements());
+      for (int idx = 0; idx < globalDim.size(); ++idx) globalDim[idx] = get(axisId)->globalDimGrid(idx);
+      get(axisId)->sendServerAttribut(globalDim, get(axisId)->orderPosInGrid, 
+                                      CServerDistributionDescription::BAND_DISTRIBUTION);
+    }
   }
 
@@ -900,4 +958,7 @@
     buffer >> global_zoom_begin_tmp >> global_zoom_n_tmp;
     buffer >> isCompressible_;
+    buffer >> orderPosInGrid;
+    buffer >> globalDimGrid;
+
     global_zoom_begin = global_zoom_begin_tmp;
     global_zoom_n  = global_zoom_n_tmp;
Index: XIOS/dev/dev_olga/src/node/axis.hpp
===================================================================
--- XIOS/dev/dev_olga/src/node/axis.hpp	(revision 983)
+++ XIOS/dev/dev_olga/src/node/axis.hpp	(revision 987)
@@ -38,4 +38,9 @@
       , public CAxisAttributes
    {
+               /// typedef ///
+         typedef CObjectTemplate<CAxis>   SuperClass;
+         typedef CAxisAttributes SuperClassAttribute;
+         
+      public :
          enum EEventId
          {
@@ -46,7 +51,5 @@
          } ;
 
-         /// typedef ///
-         typedef CObjectTemplate<CAxis>   SuperClass;
-         typedef CAxisAttributes SuperClassAttribute;
+
 
       public :
@@ -124,4 +127,6 @@
         CArray<double,2> bound_srv;
         bool hasValue;
+        CArray<int,1> globalDimGrid;
+        int orderPosInGrid;
 
       private:
Index: XIOS/dev/dev_olga/src/node/context.cpp
===================================================================
--- XIOS/dev/dev_olga/src/node/context.cpp	(revision 983)
+++ XIOS/dev/dev_olga/src/node/context.cpp	(revision 987)
@@ -521,10 +521,10 @@
      }
 
+    // We have a xml tree on the server side and now, it should be also processed
+   // if (hasClient && !hasServer) sendPostProcessing();
+
 //     // Now tell server that it can process all messages from client
 // //    if (hasClient && !hasServer) this->sendCloseDefinition();
      if (hasClient) this->sendCloseDefinition();
-
-    // We have a xml tree on the server side and now, it should be also processed
-//    if (hasClient && !hasServer) sendPostProcessing();
 
     // There are some processings that should be done after all of above. For example: check mask or index
@@ -536,4 +536,6 @@
       this->solveAllRefOfEnabledFields(true);
     }
+
+
 
 //    // Now tell server that it can process all messages from client
@@ -763,32 +765,46 @@
    void CContext::sendCloseDefinition(void)
    {
+     // Use correct context client to send message
+     CContextClient* contextClientTmp = (0 != clientPrimServer) ? clientPrimServer : client;
      CEventClient event(getType(),EVENT_ID_CLOSE_DEFINITION);
-     if (!hasServer)
-     {
-       if (client->isServerLeader())
-       {
-         CMessage msg;
-         msg<<this->getIdServer();
-         const std::list<int>& ranks = client->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-           event.push(*itRank,1,msg);
-         client->sendEvent(event);
-       }
-       else client->sendEvent(event);
-     }
-     else
-     {
-       if (clientPrimServer->isServerLeader())
-       {
-         CMessage msg;
-         msg<<this->getIdServer();
-         const std::list<int>& ranks = clientPrimServer->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-           event.push(*itRank,1,msg);
-         clientPrimServer->sendEvent(event);
-       }
-       else clientPrimServer->sendEvent(event);
-
-     }
+
+     if (contextClientTmp->isServerLeader())
+     {
+       CMessage msg;
+       msg<<this->getIdServer();
+       const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();
+       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+         event.push(*itRank,1,msg);
+       contextClientTmp->sendEvent(event);
+     }
+     else contextClientTmp->sendEvent(event);
+
+     // if (!hasServer)
+     // {
+     //   if (client->isServerLeader())
+     //   {
+     //     CMessage msg;
+     //     msg<<this->getIdServer();
+     //     const std::list<int>& ranks = client->getRanksServerLeader();
+     //     for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+     //       event.push(*itRank,1,msg);
+     //     client->sendEvent(event);
+     //   }
+     //   else client->sendEvent(event);
+     // }
+     // else
+     // {
+     //   if (clientPrimServer->isServerLeader())
+     //   {
+     //     CMessage msg;
+     //     msg<<this->getIdServer();
+     //     const std::list<int>& ranks = clientPrimServer->getRanksServerLeader();
+     //     for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+     //       event.push(*itRank,1,msg);
+     //     clientPrimServer->sendEvent(event);
+     //   }
+     //   else clientPrimServer->sendEvent(event);
+
+     // }
    }
 
@@ -796,9 +812,12 @@
    void CContext::recvCloseDefinition(CEventServer& event)
    {
-
       CBufferIn* buffer=event.subEvents.begin()->buffer;
       string id;
       *buffer>>id;
       get(id)->closeDefinition();
+      if (get(id)->hasClient && get(id)->hasServer)
+      {        
+        get(id)->sendCloseDefinition();
+      }
    }
 
@@ -806,31 +825,45 @@
    void CContext::sendUpdateCalendar(int step)
    {
+     // Use correct context client to send message
+     CContextClient* contextClientTmp = (0 != clientPrimServer) ? clientPrimServer : client;
      CEventClient event(getType(),EVENT_ID_UPDATE_CALENDAR);
-     if (!hasServer)
-     {
-       if (client->isServerLeader())
+
+       if (contextClientTmp->isServerLeader())
        {
          CMessage msg;
          msg<<this->getIdServer()<<step;
-         const std::list<int>& ranks = client->getRanksServerLeader();
+         const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();
          for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
            event.push(*itRank,1,msg);
-         client->sendEvent(event);
+         contextClientTmp->sendEvent(event);
        }
-       else client->sendEvent(event);
-     }
-     else
-     {
-       if (clientPrimServer->isServerLeader())
-       {
-         CMessage msg;
-         msg<<this->getIdServer()<<step;
-         const std::list<int>& ranks = clientPrimServer->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-           event.push(*itRank,1,msg);
-         clientPrimServer->sendEvent(event);
-       }
-       else clientPrimServer->sendEvent(event);
-     }
+       else contextClientTmp->sendEvent(event);
+
+     // if (!hasServer)
+     // {
+     //   if (client->isServerLeader())
+     //   {
+     //     CMessage msg;
+     //     msg<<this->getIdServer()<<step;
+     //     const std::list<int>& ranks = client->getRanksServerLeader();
+     //     for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+     //       event.push(*itRank,1,msg);
+     //     client->sendEvent(event);
+     //   }
+     //   else client->sendEvent(event);
+     // }
+     // else
+     // {
+     //   if (clientPrimServer->isServerLeader())
+     //   {
+     //     CMessage msg;
+     //     msg<<this->getIdServer()<<step;
+     //     const std::list<int>& ranks = clientPrimServer->getRanksServerLeader();
+     //     for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+     //       event.push(*itRank,1,msg);
+     //     clientPrimServer->sendEvent(event);
+     //   }
+     //   else clientPrimServer->sendEvent(event);
+     // }
    }
 
@@ -850,4 +883,8 @@
       buffer>>step;
       updateCalendar(step);
+      if (hasClient && hasServer)
+      {        
+        sendUpdateCalendar(step);
+      }
    }
 
@@ -855,32 +892,45 @@
    void CContext::sendCreateFileHeader(void)
    {
+     // Use correct context client to send message
+     CContextClient* contextClientTmp = (0 != clientPrimServer) ? clientPrimServer : client;
      CEventClient event(getType(),EVENT_ID_CREATE_FILE_HEADER);
 
-     if (!hasServer)
-     {
-       if (client->isServerLeader())
-       {
-         CMessage msg;
-         msg<<this->getIdServer();
-         const std::list<int>& ranks = client->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-           event.push(*itRank,1,msg) ;
-         client->sendEvent(event);
-       }
-       else client->sendEvent(event);
-     }
-     else
-     {
-       if (clientPrimServer->isServerLeader())
-       {
-         CMessage msg;
-         msg<<this->getIdServer();
-         const std::list<int>& ranks = clientPrimServer->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-           event.push(*itRank,1,msg) ;
-         clientPrimServer->sendEvent(event);
-       }
-       else clientPrimServer->sendEvent(event);
-     }
+     if (contextClientTmp->isServerLeader())
+     {
+       CMessage msg;
+       msg<<this->getIdServer();
+       const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();
+       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+         event.push(*itRank,1,msg) ;
+       contextClientTmp->sendEvent(event);
+     }
+     else contextClientTmp->sendEvent(event);
+
+     // if (!hasServer)
+     // {
+     //   if (client->isServerLeader())
+     //   {
+     //     CMessage msg;
+     //     msg<<this->getIdServer();
+     //     const std::list<int>& ranks = client->getRanksServerLeader();
+     //     for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+     //       event.push(*itRank,1,msg) ;
+     //     client->sendEvent(event);
+     //   }
+     //   else client->sendEvent(event);
+     // }
+     // else
+     // {
+     //   if (clientPrimServer->isServerLeader())
+     //   {
+     //     CMessage msg;
+     //     msg<<this->getIdServer();
+     //     const std::list<int>& ranks = clientPrimServer->getRanksServerLeader();
+     //     for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+     //       event.push(*itRank,1,msg) ;
+     //     clientPrimServer->sendEvent(event);
+     //   }
+     //   else clientPrimServer->sendEvent(event);
+     // }
    }
 
@@ -897,5 +947,12 @@
    void CContext::recvCreateFileHeader(CBufferIn& buffer)
    {
-      createFileHeader();
+     // The creation of header file should be delegated to server2, for now
+      if (hasClient && hasServer)
+      {        
+        sendCreateFileHeader();
+      }
+      
+      if (!hasClient && hasServer) 
+        createFileHeader();
    }
 
@@ -903,35 +960,50 @@
    void CContext::sendPostProcessing()
    {
-     if (hasClient)
-     {
-       if (!hasServer)
-       {
-         CEventClient event(getType(),EVENT_ID_POST_PROCESS);
-         if (client->isServerLeader())
-         {
-           CMessage msg;
-           msg<<this->getIdServer();
-           const std::list<int>& ranks = client->getRanksServerLeader();
-           for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-             event.push(*itRank,1,msg);
-           client->sendEvent(event);
-         }
-         else client->sendEvent(event);
-       }
-       else
-       {
-         CEventClient event(getType(),EVENT_ID_POST_PROCESS);
-         if (clientPrimServer->isServerLeader())
-         {
-           CMessage msg;
-           msg<<this->getIdServer();
-           const std::list<int>& ranks = clientPrimServer->getRanksServerLeader();
-           for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-             event.push(*itRank,1,msg);
-           clientPrimServer->sendEvent(event);
-         }
-         else clientPrimServer->sendEvent(event);
-       }
-     }
+      // Use correct context client to send message
+     CContextClient* contextClientTmp = (0 != clientPrimServer) ? clientPrimServer : client;
+     CEventClient event(getType(),EVENT_ID_POST_PROCESS);
+
+     if (contextClientTmp->isServerLeader())
+     {
+       CMessage msg;
+       msg<<this->getIdServer();
+       const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();
+       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+         event.push(*itRank,1,msg);
+       contextClientTmp->sendEvent(event);
+     }
+     else contextClientTmp->sendEvent(event);
+
+     // if (hasClient)
+     // {
+     //   if (!hasServer)
+     //   {
+     //     CEventClient event(getType(),EVENT_ID_POST_PROCESS);
+     //     if (client->isServerLeader())
+     //     {
+     //       CMessage msg;
+     //       msg<<this->getIdServer();
+     //       const std::list<int>& ranks = client->getRanksServerLeader();
+     //       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+     //         event.push(*itRank,1,msg);
+     //       client->sendEvent(event);
+     //     }
+     //     else client->sendEvent(event);
+     //   }
+     //   else
+     //   {
+     //     CEventClient event(getType(),EVENT_ID_POST_PROCESS);
+     //     if (clientPrimServer->isServerLeader())
+     //     {
+     //       CMessage msg;
+     //       msg<<this->getIdServer();
+     //       const std::list<int>& ranks = clientPrimServer->getRanksServerLeader();
+     //       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+     //         event.push(*itRank,1,msg);
+     //       clientPrimServer->sendEvent(event);
+     //     }
+     //     else clientPrimServer->sendEvent(event);
+     //   }
+     // }
    }
 
@@ -1388,37 +1460,50 @@
 
   void CContext::sendRegistry(void)
-  {
+  {    
     registryOut->hierarchicalGatherRegistry() ;
 
+          // Use correct context client to send message
+     CContextClient* contextClientTmp = (0 != clientPrimServer) ? clientPrimServer : client;
     CEventClient event(CContext::GetType(), CContext::EVENT_ID_SEND_REGISTRY);
-    if (!hasServer)
-    {
-      if (client->isServerLeader())
+          if (contextClientTmp->isServerLeader())
       {
          CMessage msg ;
          msg<<this->getIdServer();
-         if (client->clientRank==0) msg<<*registryOut ;
+         if (contextClientTmp->clientRank==0) msg<<*registryOut ;
          const std::list<int>& ranks = client->getRanksServerLeader();
          for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
            event.push(*itRank,1,msg);
-         client->sendEvent(event);
+         contextClientTmp->sendEvent(event);
        }
-       else client->sendEvent(event);
-    }
-    else
-    {
-      if (clientPrimServer->isServerLeader())
-      {
-         CMessage msg ;
-         msg<<this->getIdServer();
-         if (clientPrimServer->clientRank==0) msg<<*registryOut ;
-         const std::list<int>& ranks = clientPrimServer->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-           event.push(*itRank,1,msg);
-         clientPrimServer->sendEvent(event);
-       }
-       else clientPrimServer->sendEvent(event);
-
-    }
+       else contextClientTmp->sendEvent(event);
+
+    // if (!hasServer)
+    // {
+    //   if (client->isServerLeader())
+    //   {
+    //      CMessage msg ;
+    //      msg<<this->getIdServer();
+    //      if (client->clientRank==0) msg<<*registryOut ;
+    //      const std::list<int>& ranks = client->getRanksServerLeader();
+    //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+    //        event.push(*itRank,1,msg);
+    //      client->sendEvent(event);
+    //    }
+    //    else client->sendEvent(event);
+    // }
+    // else
+    // {
+    //   if (clientPrimServer->isServerLeader())
+    //   {
+    //      CMessage msg ;
+    //      msg<<this->getIdServer();
+    //      if (clientPrimServer->clientRank==0) msg<<*registryOut ;
+    //      const std::list<int>& ranks = clientPrimServer->getRanksServerLeader();
+    //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+    //        event.push(*itRank,1,msg);
+    //      clientPrimServer->sendEvent(event);
+    //    }
+    //    else clientPrimServer->sendEvent(event);
+    // }
   }
 
Index: XIOS/dev/dev_olga/src/node/domain.cpp
===================================================================
--- XIOS/dev/dev_olga/src/node/domain.cpp	(revision 983)
+++ XIOS/dev/dev_olga/src/node/domain.cpp	(revision 987)
@@ -1395,6 +1395,10 @@
   {
     CContext* context = CContext::getCurrent();
-    CContextClient* client = context->client;
-    int nbServer = client->serverSize;
+     // Use correct context client to send message
+     CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer 
+                                                                         : context->client;
+
+    // CContextClient* client = context->client;
+    int nbServer = contextClientTmp->serverSize;
 
     CServerDistributionDescription serverDescription(nGlobDomain_, nbServer);
@@ -1406,9 +1410,9 @@
 
     CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT);
-    if (client->isServerLeader())
+    if (contextClientTmp->isServerLeader())
     {
       std::list<CMessage> msgs;
 
-      const std::list<int>& ranks = client->getRanksServerLeader();
+      const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();
       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
       {
@@ -1430,7 +1434,7 @@
         event.push(*itRank,1,msg);
       }
-      client->sendEvent(event);
-    }
-    else client->sendEvent(event);
+      contextClientTmp->sendEvent(event);
+    }
+    else contextClientTmp->sendEvent(event);
   }
 
@@ -1852,4 +1856,11 @@
     *buffer>>domainId ;
     get(domainId)->recvServerAttribut(*buffer) ;
+    
+    CContext* context = CContext::getCurrent();
+    if (context->hasClient && context->hasServer)
+    {
+      get(domainId)->sendServerAttribut();
+    }
+
   }
 
Index: XIOS/dev/dev_olga/src/node/domain.hpp
===================================================================
--- XIOS/dev/dev_olga/src/node/domain.hpp	(revision 983)
+++ XIOS/dev/dev_olga/src/node/domain.hpp	(revision 987)
@@ -42,5 +42,9 @@
       , public CDomainAttributes
    {
-
+               /// typedef ///
+         typedef CObjectTemplate<CDomain>   SuperClass;
+         typedef CDomainAttributes SuperClassAttribute;
+         
+      public :
          enum EEventId
          {
@@ -48,7 +52,5 @@
          } ;
 
-         /// typedef ///
-         typedef CObjectTemplate<CDomain>   SuperClass;
-         typedef CDomainAttributes SuperClassAttribute;
+
 
       public:
Index: XIOS/dev/dev_olga/src/node/field.cpp
===================================================================
--- XIOS/dev/dev_olga/src/node/field.cpp	(revision 983)
+++ XIOS/dev/dev_olga/src/node/field.cpp	(revision 987)
@@ -1251,45 +1251,47 @@
    void CField::sendAddVariable(const string& id)
    {
-    CContext* context = CContext::getCurrent();
-
-    if (!context->hasServer)
-    {
-       CContextClient* client = context->client;
-
-       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE);
-       if (client->isServerLeader())
-       {
-         CMessage msg;
-         msg << this->getId();
-         msg << id;
-         const std::list<int>& ranks = client->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-           event.push(*itRank,1,msg);
-         client->sendEvent(event);
-       }
-       else client->sendEvent(event);
-    }
+      sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE);
+    // CContext* context = CContext::getCurrent();
+
+    // if (!context->hasServer)
+    // {
+    //    CContextClient* client = context->client;
+
+    //    CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE);
+    //    if (client->isServerLeader())
+    //    {
+    //      CMessage msg;
+    //      msg << this->getId();
+    //      msg << id;
+    //      const std::list<int>& ranks = client->getRanksServerLeader();
+    //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+    //        event.push(*itRank,1,msg);
+    //      client->sendEvent(event);
+    //    }
+    //    else client->sendEvent(event);
+    // }
    }
 
    void CField::sendAddVariableGroup(const string& id)
    {
-    CContext* context = CContext::getCurrent();
-    if (!context->hasServer)
-    {
-       CContextClient* client = context->client;
-
-       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP);
-       if (client->isServerLeader())
-       {
-         CMessage msg;
-         msg << this->getId();
-         msg << id;
-         const std::list<int>& ranks = client->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-           event.push(*itRank,1,msg);
-         client->sendEvent(event);
-       }
-       else client->sendEvent(event);
-    }
+      sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE_GROUP);
+    // CContext* context = CContext::getCurrent();
+    // if (!context->hasServer)
+    // {
+    //    CContextClient* client = context->client;
+
+    //    CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP);
+    //    if (client->isServerLeader())
+    //    {
+    //      CMessage msg;
+    //      msg << this->getId();
+    //      msg << id;
+    //      const std::list<int>& ranks = client->getRanksServerLeader();
+    //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+    //        event.push(*itRank,1,msg);
+    //      client->sendEvent(event);
+    //    }
+    //    else client->sendEvent(event);
+    // }
    }
 
Index: XIOS/dev/dev_olga/src/node/file.cpp
===================================================================
--- XIOS/dev/dev_olga/src/node/file.cpp	(revision 983)
+++ XIOS/dev/dev_olga/src/node/file.cpp	(revision 987)
@@ -826,23 +826,24 @@
    void CFile::sendAddField(const string& id)
    {
-    CContext* context = CContext::getCurrent();
-
-    if (! context->hasServer )
-    {
-       CContextClient* client = context->client;
-
-       CEventClient event(this->getType(),EVENT_ID_ADD_FIELD);
-       if (client->isServerLeader())
-       {
-         CMessage msg;
-         msg << this->getId();
-         msg << id;
-         const std::list<int>& ranks = client->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-           event.push(*itRank,1,msg);
-         client->sendEvent(event);
-       }
-       else client->sendEvent(event);
-    }
+      sendAddItem(id, EVENT_ID_ADD_FIELD);
+    // CContext* context = CContext::getCurrent();
+
+    // if (! context->hasServer )
+    // {
+    //    CContextClient* client = context->client;
+
+    //    CEventClient event(this->getType(),EVENT_ID_ADD_FIELD);
+    //    if (client->isServerLeader())
+    //    {
+    //      CMessage msg;
+    //      msg << this->getId();
+    //      msg << id;
+    //      const std::list<int>& ranks = client->getRanksServerLeader();
+    //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+    //        event.push(*itRank,1,msg);
+    //      client->sendEvent(event);
+    //    }
+    //    else client->sendEvent(event);
+    // }
 
    }
@@ -854,22 +855,23 @@
    void CFile::sendAddFieldGroup(const string& id)
    {
-    CContext* context = CContext::getCurrent();
-    if (! context->hasServer )
-    {
-       CContextClient* client = context->client;
-
-       CEventClient event(this->getType(),EVENT_ID_ADD_FIELD_GROUP);
-       if (client->isServerLeader())
-       {
-         CMessage msg;
-         msg << this->getId();
-         msg << id;
-         const std::list<int>& ranks = client->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-           event.push(*itRank,1,msg);
-         client->sendEvent(event);
-       }
-       else client->sendEvent(event);
-    }
+      sendAddItem(id, (int)EVENT_ID_ADD_FIELD_GROUP);
+    // CContext* context = CContext::getCurrent();
+    // if (! context->hasServer )
+    // {
+    //    CContextClient* client = context->client;
+
+    //    CEventClient event(this->getType(),EVENT_ID_ADD_FIELD_GROUP);
+    //    if (client->isServerLeader())
+    //    {
+    //      CMessage msg;
+    //      msg << this->getId();
+    //      msg << id;
+    //      const std::list<int>& ranks = client->getRanksServerLeader();
+    //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+    //        event.push(*itRank,1,msg);
+    //      client->sendEvent(event);
+    //    }
+    //    else client->sendEvent(event);
+    // }
 
    }
@@ -950,23 +952,24 @@
    void CFile::sendAddVariable(const string& id)
    {
-    CContext* context = CContext::getCurrent();
-
-    if (! context->hasServer )
-    {
-       CContextClient* client = context->client;
-
-       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE);
-       if (client->isServerLeader())
-       {
-         CMessage msg;
-         msg << this->getId();
-         msg << id;
-         const std::list<int>& ranks = client->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-           event.push(*itRank,1,msg);
-         client->sendEvent(event);
-       }
-       else client->sendEvent(event);
-    }
+      sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE);
+    // CContext* context = CContext::getCurrent();
+
+    // if (! context->hasServer )
+    // {
+    //    CContextClient* client = context->client;
+
+    //    CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE);
+    //    if (client->isServerLeader())
+    //    {
+    //      CMessage msg;
+    //      msg << this->getId();
+    //      msg << id;
+    //      const std::list<int>& ranks = client->getRanksServerLeader();
+    //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+    //        event.push(*itRank,1,msg);
+    //      client->sendEvent(event);
+    //    }
+    //    else client->sendEvent(event);
+    // }
 
    }
@@ -978,22 +981,23 @@
    void CFile::sendAddVariableGroup(const string& id)
    {
-    CContext* context = CContext::getCurrent();
-    if (! context->hasServer )
-    {
-       CContextClient* client = context->client;
-
-       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP);
-       if (client->isServerLeader())
-       {
-         CMessage msg;
-         msg << this->getId();
-         msg << id;
-         const std::list<int>& ranks = client->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-           event.push(*itRank,1,msg);
-         client->sendEvent(event);
-       }
-       else client->sendEvent(event);
-    }
+      sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE_GROUP);
+    // CContext* context = CContext::getCurrent();
+    // if (! context->hasServer )
+    // {
+    //    CContextClient* client = context->client;
+
+    //    CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP);
+    //    if (client->isServerLeader())
+    //    {
+    //      CMessage msg;
+    //      msg << this->getId();
+    //      msg << id;
+    //      const std::list<int>& ranks = client->getRanksServerLeader();
+    //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+    //        event.push(*itRank,1,msg);
+    //      client->sendEvent(event);
+    //    }
+    //    else client->sendEvent(event);
+    // }
 
    }
Index: XIOS/dev/dev_olga/src/node/grid.cpp
===================================================================
--- XIOS/dev/dev_olga/src/node/grid.cpp	(revision 983)
+++ XIOS/dev/dev_olga/src/node/grid.cpp	(revision 987)
@@ -1514,23 +1514,24 @@
    void CGrid::sendAddDomain(const string& id)
    {
-    CContext* context=CContext::getCurrent();
-
-    if (! context->hasServer )
-    {
-       CContextClient* client=context->client;
-
-       CEventClient event(this->getType(),EVENT_ID_ADD_DOMAIN);
-       if (client->isServerLeader())
-       {
-         CMessage msg;
-         msg<<this->getId();
-         msg<<id;
-         const std::list<int>& ranks = client->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-           event.push(*itRank,1,msg);
-         client->sendEvent(event);
-       }
-       else client->sendEvent(event);
-    }
+      sendAddItem(id, (int)EVENT_ID_ADD_DOMAIN);
+    // CContext* context=CContext::getCurrent();
+
+    // if (! context->hasServer )
+    // {
+    //    CContextClient* client=context->client;
+
+    //    CEventClient event(this->getType(),EVENT_ID_ADD_DOMAIN);
+    //    if (client->isServerLeader())
+    //    {
+    //      CMessage msg;
+    //      msg<<this->getId();
+    //      msg<<id;
+    //      const std::list<int>& ranks = client->getRanksServerLeader();
+    //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+    //        event.push(*itRank,1,msg);
+    //      client->sendEvent(event);
+    //    }
+    //    else client->sendEvent(event);
+    // }
    }
 
@@ -1541,23 +1542,24 @@
    void CGrid::sendAddAxis(const string& id)
    {
-    CContext* context=CContext::getCurrent();
-
-    if (! context->hasServer )
-    {
-       CContextClient* client=context->client;
-
-       CEventClient event(this->getType(),EVENT_ID_ADD_AXIS);
-       if (client->isServerLeader())
-       {
-         CMessage msg;
-         msg<<this->getId();
-         msg<<id;
-         const std::list<int>& ranks = client->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-           event.push(*itRank,1,msg);
-         client->sendEvent(event);
-       }
-       else client->sendEvent(event);
-    }
+      sendAddItem(id, (int)EVENT_ID_ADD_AXIS);
+    // CContext* context=CContext::getCurrent();
+
+    // if (! context->hasServer )
+    // {
+    //    CContextClient* client=context->client;
+
+    //    CEventClient event(this->getType(),EVENT_ID_ADD_AXIS);
+    //    if (client->isServerLeader())
+    //    {
+    //      CMessage msg;
+    //      msg<<this->getId();
+    //      msg<<id;
+    //      const std::list<int>& ranks = client->getRanksServerLeader();
+    //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+    //        event.push(*itRank,1,msg);
+    //      client->sendEvent(event);
+    //    }
+    //    else client->sendEvent(event);
+    // }
    }
 
@@ -1568,23 +1570,24 @@
    void CGrid::sendAddScalar(const string& id)
    {
-    CContext* context=CContext::getCurrent();
-
-    if (! context->hasServer )
-    {
-       CContextClient* client=context->client;
-
-       CEventClient event(this->getType(),EVENT_ID_ADD_SCALAR);
-       if (client->isServerLeader())
-       {
-         CMessage msg;
-         msg<<this->getId();
-         msg<<id;
-         const std::list<int>& ranks = client->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-           event.push(*itRank,1,msg);
-         client->sendEvent(event);
-       }
-       else client->sendEvent(event);
-    }
+      sendAddItem(id, (int)EVENT_ID_ADD_SCALAR);
+    // CContext* context=CContext::getCurrent();
+
+    // if (! context->hasServer )
+    // {
+    //    CContextClient* client=context->client;
+
+    //    CEventClient event(this->getType(),EVENT_ID_ADD_SCALAR);
+    //    if (client->isServerLeader())
+    //    {
+    //      CMessage msg;
+    //      msg<<this->getId();
+    //      msg<<id;
+    //      const std::list<int>& ranks = client->getRanksServerLeader();
+    //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+    //        event.push(*itRank,1,msg);
+    //      client->sendEvent(event);
+    //    }
+    //    else client->sendEvent(event);
+    // }
    }
 
Index: XIOS/dev/dev_olga/src/node/variable.cpp
===================================================================
--- XIOS/dev/dev_olga/src/node/variable.cpp	(revision 983)
+++ XIOS/dev/dev_olga/src/node/variable.cpp	(revision 987)
@@ -82,21 +82,43 @@
    {
      CContext* context=CContext::getCurrent() ;
-     if (!context->hasServer)
+
+     if (context->hasClient)
      {
-       CContextClient* client=context->client ;
+           // Use correct context client to send message
+       CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer 
+                                                                           : context->client;
 
        CEventClient event(this->getType(),EVENT_ID_VARIABLE_VALUE) ;
-       if (client->isServerLeader())
+       if (contextClientTmp->isServerLeader())
        {
          CMessage msg ;
          msg<<this->getId() ;
          msg<<content ;
-         const std::list<int>& ranks = client->getRanksServerLeader();
+         const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();
          for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
            event.push(*itRank,1,msg);
-         client->sendEvent(event) ;
+         contextClientTmp->sendEvent(event) ;
        }
-       else client->sendEvent(event) ;
+       else contextClientTmp->sendEvent(event) ;
     }
+
+
+    //  if (!context->hasServer)
+    //  {
+    //    CContextClient* client=context->client ;
+
+    //    CEventClient event(this->getType(),EVENT_ID_VARIABLE_VALUE) ;
+    //    if (client->isServerLeader())
+    //    {
+    //      CMessage msg ;
+    //      msg<<this->getId() ;
+    //      msg<<content ;
+    //      const std::list<int>& ranks = client->getRanksServerLeader();
+    //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+    //        event.push(*itRank,1,msg);
+    //      client->sendEvent(event) ;
+    //    }
+    //    else client->sendEvent(event) ;
+    // }
    }
 
Index: XIOS/dev/dev_olga/src/node/variable.hpp
===================================================================
--- XIOS/dev/dev_olga/src/node/variable.hpp	(revision 983)
+++ XIOS/dev/dev_olga/src/node/variable.hpp	(revision 987)
@@ -31,12 +31,13 @@
          , public CVariableAttributes
       {
+                     /// typedef ///
+            typedef CObjectTemplate<CVariable>   SuperClass;
+            typedef CVariableAttributes SuperClassAttribute;
+            
+         public :
             enum EEventId
             {
              EVENT_ID_VARIABLE_VALUE
             };
-
-            /// typedef ///
-            typedef CObjectTemplate<CVariable>   SuperClass;
-            typedef CVariableAttributes SuperClassAttribute;
 
             friend class CVariableGroup;
Index: XIOS/dev/dev_olga/src/object_template.hpp
===================================================================
--- XIOS/dev/dev_olga/src/object_template.hpp	(revision 983)
+++ XIOS/dev/dev_olga/src/object_template.hpp	(revision 987)
@@ -58,4 +58,5 @@
          void sendAttributToServer(CAttribute& attr) ;
          void sendAllAttributesToServer();
+         void sendAddItem(const string& id, int itemType);
          static void recvAttributFromClient(CEventServer& event) ;
          static bool dispatchEvent(CEventServer& event) ;
Index: XIOS/dev/dev_olga/src/object_template_impl.hpp
===================================================================
--- XIOS/dev/dev_olga/src/object_template_impl.hpp	(revision 983)
+++ XIOS/dev/dev_olga/src/object_template_impl.hpp	(revision 987)
@@ -164,8 +164,13 @@
    std::map<int, size_t> CObjectTemplate<T>::getMinimumBufferSizeForAttributes()
    {
-     CContextClient* client = CContext::getCurrent()->client;
+     // CContextClient* client = CContext::getCurrent()->client;
+     CContext* context = CContext::getCurrent();
+
+          // Use correct context client to send message
+     CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client;
+
      std::map<int, size_t> minimumSizes;
 
-     if (client->isServerLeader())
+     if (contextClientTmp->isServerLeader())
      {
        size_t minimumSize = 0;
@@ -187,9 +192,35 @@
          minimumSize += CEventClient::headerSize + getIdServer().size() + sizeof(size_t);
 
-         const std::list<int>& ranks = client->getRanksServerLeader();
+         const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();
          for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
            minimumSizes.insert(std::make_pair(*itRank, minimumSize));
        }
      }
+
+     // if (client->isServerLeader())
+     // {
+     //   size_t minimumSize = 0;
+     //   CAttributeMap& attrMap = *this;
+     //   CAttributeMap::const_iterator it = attrMap.begin(), itE = attrMap.end();
+     //   for (; it != itE; ++it)
+     //   {
+     //     if (!it->second->isEmpty())
+     //     {
+     //       size_t size = it->second->getName().size() + sizeof(size_t) + it->second->size();
+     //       if (size > minimumSize)
+     //         minimumSize = size;
+     //     }
+     //   }
+
+     //   if (minimumSize)
+     //   {
+     //     // Account for extra header info
+     //     minimumSize += CEventClient::headerSize + getIdServer().size() + sizeof(size_t);
+
+     //     const std::list<int>& ranks = client->getRanksServerLeader();
+     //     for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+     //       minimumSizes.insert(std::make_pair(*itRank, minimumSize));
+     //   }
+     // }
 
      return minimumSizes;
@@ -220,10 +251,14 @@
     CContext* context=CContext::getCurrent();
 
-    if (!context->hasServer)
+     // Use correct context client to send message
+     CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client;
+
+    // if (!context->hasServer)
+    if (context->hasClient)
     {
-       CContextClient* client=context->client;
+       // CContextClient* contextClientTmp=context->contextClientTmp;
 
        CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE);
-       if (client->isServerLeader())
+       if (contextClientTmp->isServerLeader())
        {
          CMessage msg;
@@ -232,12 +267,63 @@
          msg << attr.getName();
          msg << attr;
-         const std::list<int>& ranks = client->getRanksServerLeader();
+         const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();
          for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
            event.push(*itRank,1,msg);
-         client->sendEvent(event);
+         contextClientTmp->sendEvent(event);
        }
-       else client->sendEvent(event);
+       else contextClientTmp->sendEvent(event);
     }
 
+//     // if (!context->hasServer)
+//     if (context->hasClient)
+//     {
+//        CContextClient* client=context->client;
+
+//        CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE);
+//        if (client->isServerLeader())
+//        {
+//          CMessage msg;
+// //       msg << this->getId();
+//          msg << this->getIdServer();
+//          msg << attr.getName();
+//          msg << attr;
+//          const std::list<int>& ranks = client->getRanksServerLeader();
+//          for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+//            event.push(*itRank,1,msg);
+//          client->sendEvent(event);
+//        }
+//        else client->sendEvent(event);
+//     }
+
+  }
+
+  /*!
+    This generic funtion only provides instance for sending, for receving, each 
+    child class must define itself.
+    \param [in] id Id of added item
+    \param [in] itemType type of added item
+  */
+  template<class T>
+  void CObjectTemplate<T>::sendAddItem(const StdString& id, int itemType)
+  {
+    CContext* context = CContext::getCurrent();
+    typedef typename T::EEventId ItemType;
+    if (context->hasClient)
+    {
+       // Use correct context client to send message
+       CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client;
+       CEventClient event(this->getType(),ItemType(itemType));
+       if (contextClientTmp->isServerLeader())
+       {
+         CMessage msg;
+         msg << this->getId();
+         msg << id;
+         const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();
+         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+           event.push(*itRank,1,msg);
+         contextClientTmp->sendEvent(event);
+       }
+       else contextClientTmp->sendEvent(event);
+    }
   }
 
Index: XIOS/dev/dev_olga/src/server.hpp
===================================================================
--- XIOS/dev/dev_olga/src/server.hpp	(revision 983)
+++ XIOS/dev/dev_olga/src/server.hpp	(revision 987)
@@ -14,4 +14,5 @@
       public:
         static void initialize(void);
+        static void initialize(const StdString& serverId);
         static void finalize(void);
         static void eventLoop(void);
Index: XIOS/dev/dev_olga/src/test/test_client.f90
===================================================================
--- XIOS/dev/dev_olga/src/test/test_client.f90	(revision 983)
+++ XIOS/dev/dev_olga/src/test/test_client.f90	(revision 987)
@@ -128,5 +128,5 @@
 
   PRINT*,"field field_A is active ? ",xios_field_is_active("field_A")
-  DO ts=1,24*10
+  DO ts=1,24
     CALL xios_update_calendar(ts)
     CALL xios_send_field("field_A",field_A)
Index: XIOS/dev/dev_olga/src/xios_server1.f90
===================================================================
--- XIOS/dev/dev_olga/src/xios_server1.f90	(revision 987)
+++ XIOS/dev/dev_olga/src/xios_server1.f90	(revision 987)
@@ -0,0 +1,13 @@
+PROGRAM server_main1
+  USE xios
+  IMPLICIT NONE
+  INCLUDE "mpif.h"
+  INTEGER :: ierr
+  INTEGER            :: server_level = 0  
+  ! 0 in case of a single server pool 
+  ! 1 for primary server in case of two server pools
+  ! 2 for secondary server in case of two server pools
+
+  CALL xios_init_server(1)
+
+END PROGRAM server_main1
Index: XIOS/dev/dev_olga/src/xios_server2.f90
===================================================================
--- XIOS/dev/dev_olga/src/xios_server2.f90	(revision 987)
+++ XIOS/dev/dev_olga/src/xios_server2.f90	(revision 987)
@@ -0,0 +1,13 @@
+PROGRAM server_main2
+  USE xios
+  IMPLICIT NONE
+  INCLUDE "mpif.h"
+  INTEGER :: ierr
+  INTEGER            :: server_level = 0  
+  ! 0 in case of a single server pool 
+  ! 1 for primary server in case of two server pools
+  ! 2 for secondary server in case of two server pools
+
+  CALL xios_init_server(2)
+
+END PROGRAM server_main2
