Index: /XIOS/dev/dev_olga/src/context_client.cpp
===================================================================
--- /XIOS/dev/dev_olga/src/context_client.cpp	(revision 1183)
+++ /XIOS/dev/dev_olga/src/context_client.cpp	(revision 1184)
@@ -94,5 +94,5 @@
         list<CBufferOut*> buffList;
         bool couldBuffer = getBuffers(ranks, sizes, buffList, (!CXios::isClient && (CServer::serverLevel == 0) ));
-        //bool couldBuffer = getBuffers(ranks, sizes, buffList, false );
+//        bool couldBuffer = getBuffers(ranks, sizes, buffList, CXios::isServer );
 
         if (couldBuffer)
Index: /XIOS/dev/dev_olga/src/node/context.cpp
===================================================================
--- /XIOS/dev/dev_olga/src/node/context.cpp	(revision 1183)
+++ /XIOS/dev/dev_olga/src/node/context.cpp	(revision 1184)
@@ -289,5 +289,5 @@
    }
 
-   void CContext::setClientServerBuffer()
+   void CContext::setClientServerBuffer(CContextClient* contextClient)
    {
      size_t minBufferSize = CXios::minBufferSize;
@@ -300,6 +300,6 @@
 
      std::map<int, StdSize> maxEventSize;
-     std::map<int, StdSize> bufferSize = getAttributesBufferSize(maxEventSize);
-     std::map<int, StdSize> dataBufferSize = getDataBufferSize(maxEventSize);
+     std::map<int, StdSize> bufferSize = getAttributesBufferSize(maxEventSize, contextClient);
+     std::map<int, StdSize> dataBufferSize = getDataBufferSize(maxEventSize, contextClient);
 
      std::map<int, StdSize>::iterator it, ite = dataBufferSize.end();
@@ -319,26 +319,12 @@
        if (it->second < minBufferSize) it->second = minBufferSize;
 
-     if (client->isServerLeader())
-     {
-       const std::list<int>& ranks = client->getRanksServerLeader();
+     if (contextClient->isServerLeader())
+     {
+       const std::list<int>& ranks = contextClient->getRanksServerLeader();
        for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
          if (!bufferSize.count(*itRank)) bufferSize[*itRank] = maxEventSize[*itRank] = minBufferSize;
      }
-     client->setBufferSize(bufferSize, maxEventSize);
-
-     // If it is primary server pool, also set buffer for clientPrimServer.
-     if (hasClient && hasServer)
-     {
-       for (int i = 0; i < clientPrimServer.size(); ++i)
-       {
-         if (clientPrimServer[i]->isServerLeader())
-         {
-           const std::list<int>& ranks = clientPrimServer[i]->getRanksServerLeader();
-           for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-             if (!bufferSize.count(*itRank)) bufferSize[*itRank] = maxEventSize[*itRank] = minBufferSize;
-         }
-         clientPrimServer[i]->setBufferSize(bufferSize, maxEventSize);
-       }
-     }
+     contextClient->setBufferSize(bufferSize, maxEventSize);
+
    }
 
@@ -536,5 +522,9 @@
      checkGridEnabledFields();    
 
-     setClientServerBuffer();
+     setClientServerBuffer(client);
+     if (hasServer)
+       for (int i = 0; i < clientPrimServer.size(); ++i)
+         setClientServerBuffer(clientPrimServer[i]);
+
 
      if (hasClient)
@@ -1197,5 +1187,5 @@
     * \param maxEventSize [in/out] the size of the bigger event for each connected server
     */
-   std::map<int, StdSize> CContext::getAttributesBufferSize(std::map<int, StdSize>& maxEventSize)
+   std::map<int, StdSize> CContext::getAttributesBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient)
    {
      std::map<int, StdSize> attributesSize;
@@ -1207,20 +1197,22 @@
        {
          CFile* file = this->enabledFiles[i];
-
-         std::vector<CField*> enabledFields = file->getEnabledFields();
-         size_t numEnabledFields = enabledFields.size();
-         for (size_t j = 0; j < numEnabledFields; ++j)
+         if (file->getContextClient() == contextClient)
          {
-           const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize();
-           std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end();
-           for (; it != itE; ++it)
+           std::vector<CField*> enabledFields = file->getEnabledFields();
+           size_t numEnabledFields = enabledFields.size();
+           for (size_t j = 0; j < numEnabledFields; ++j)
            {
-             // If attributesSize[it->first] does not exist, it will be zero-initialized
-             // so we can use it safely without checking for its existance
-             if (attributesSize[it->first] < it->second)
-               attributesSize[it->first] = it->second;
-
-             if (maxEventSize[it->first] < it->second)
-               maxEventSize[it->first] = it->second;
+             const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize();
+             std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end();
+             for (; it != itE; ++it)
+             {
+               // If attributesSize[it->first] does not exist, it will be zero-initialized
+               // so we can use it safely without checking for its existance
+               if (attributesSize[it->first] < it->second)
+                 attributesSize[it->first] = it->second;
+
+               if (maxEventSize[it->first] < it->second)
+                 maxEventSize[it->first] = it->second;
+             }
            }
          }
@@ -1236,5 +1228,5 @@
     * \param maxEventSize [in/out] the size of the bigger event for each connected server
     */
-   std::map<int, StdSize> CContext::getDataBufferSize(std::map<int, StdSize>& maxEventSize)
+   std::map<int, StdSize> CContext::getDataBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient)
    {
      CFile::mode_attr::t_enum mode = hasClient ? CFile::mode_attr::write : CFile::mode_attr::read;
@@ -1247,27 +1239,30 @@
      {
        CFile* file = this->enabledFiles[i];
-       CFile::mode_attr::t_enum fileMode = file->mode.isEmpty() ? CFile::mode_attr::write : file->mode.getValue();
-
-       if (fileMode == mode)
+       if (file->getContextClient() == contextClient)
        {
-         std::vector<CField*> enabledFields = file->getEnabledFields();
-         size_t numEnabledFields = enabledFields.size();
-         for (size_t j = 0; j < numEnabledFields; ++j)
+         CFile::mode_attr::t_enum fileMode = file->mode.isEmpty() ? CFile::mode_attr::write : file->mode.getValue();
+
+         if (fileMode == mode)
          {
-           const std::vector<std::map<int, StdSize> > mapSize = enabledFields[j]->getGridDataBufferSize();
-           for (size_t c = 0; c < mapSize.size(); ++c)
+           std::vector<CField*> enabledFields = file->getEnabledFields();
+           size_t numEnabledFields = enabledFields.size();
+           for (size_t j = 0; j < numEnabledFields; ++j)
            {
-             std::map<int, StdSize>::const_iterator it = mapSize[c].begin(), itE = mapSize[c].end();
-             for (; it != itE; ++it)
+             const std::vector<std::map<int, StdSize> > mapSize = enabledFields[j]->getGridDataBufferSize();
+             for (size_t c = 0; c < mapSize.size(); ++c)
              {
-               // If dataSize[it->first] does not exist, it will be zero-initialized
-               // so we can use it safely without checking for its existance
-               if (CXios::isOptPerformance)
-                 dataSize[it->first] += it->second;
-               else if (dataSize[it->first] < it->second)
-                 dataSize[it->first] = it->second;
-
-               if (maxEventSize[it->first] < it->second)
-                 maxEventSize[it->first] = it->second;
+               std::map<int, StdSize>::const_iterator it = mapSize[c].begin(), itE = mapSize[c].end();
+               for (; it != itE; ++it)
+               {
+                 // If dataSize[it->first] does not exist, it will be zero-initialized
+                 // so we can use it safely without checking for its existance
+                 if (CXios::isOptPerformance)
+                   dataSize[it->first] += it->second;
+                 else if (dataSize[it->first] < it->second)
+                   dataSize[it->first] = it->second;
+
+                 if (maxEventSize[it->first] < it->second)
+                   maxEventSize[it->first] = it->second;
+               }
              }
            }
Index: /XIOS/dev/dev_olga/src/node/context.hpp
===================================================================
--- /XIOS/dev/dev_olga/src/node/context.hpp	(revision 1183)
+++ /XIOS/dev/dev_olga/src/node/context.hpp	(revision 1184)
@@ -131,7 +131,10 @@
          void sendGridEnabledFields();
 
-         std::map<int, StdSize> getAttributesBufferSize(std::map<int, StdSize>& maxEventSize);
-         std::map<int, StdSize> getDataBufferSize(std::map<int, StdSize>& maxEventSize);
-         void setClientServerBuffer();
+//         std::map<int, StdSize> getAttributesBufferSize(std::map<int, StdSize>& maxEventSize);
+//         std::map<int, StdSize> getDataBufferSize(std::map<int, StdSize>& maxEventSize);
+//         void setClientServerBuffer();
+         std::map<int, StdSize> getAttributesBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient);
+         std::map<int, StdSize> getDataBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient);
+         void setClientServerBuffer(CContextClient* contextClient);
 
          // Send context close definition
Index: /XIOS/dev/dev_olga/src/server.cpp
===================================================================
--- /XIOS/dev/dev_olga/src/server.cpp	(revision 1183)
+++ /XIOS/dev/dev_olga/src/server.cpp	(revision 1184)
@@ -267,8 +267,8 @@
           interCommLeft.push_back(newComm) ;
         }
-        delete [] srvGlobalRanks ;
-
-	      oasis_enddef() ;
+        if (CXios::usingServer2) delete [] srvGlobalRanks ;
+        oasis_enddef() ;
       }
+
 
       MPI_Comm_rank(intraComm, &rank) ;
