Index: /XIOS/dev/XIOS_DEV_CMIP6/src/cxios.cpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/cxios.cpp	(revision 1329)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/cxios.cpp	(revision 1330)
@@ -158,5 +158,5 @@
     // Initialize all aspects MPI
     CServer::initialize();
-    if (CServer::getRank()==0) globalRegistry = new CRegistry(CServer::intraComm) ;
+    if (CServer::getRank()==0 && CServer::serverLevel != 1) globalRegistry = new CRegistry(CServer::intraComm) ;
     
     if (printLogs2Files)
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.cpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.cpp	(revision 1329)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.cpp	(revision 1330)
@@ -153,12 +153,8 @@
     * \return A map associating the server rank with its minimum buffer size.
     */
-   std::map<int, StdSize> CAxis::getAttributesBufferSize(CContextClient* client)
-   {
-     // For now the assumption is that secondary server pools consist of the same number of procs.
-     // CHANGE the line below if the assumption changes.
-     // CContext* context = CContext::getCurrent();
-     // CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client;
-
-     std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes();
+   std::map<int, StdSize> CAxis::getAttributesBufferSize(CContextClient* client, bool bufferForWriting /*= false*/)
+   {
+
+     std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(client);
 
      bool isNonDistributed = (n = n_glo);     
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.hpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.hpp	(revision 1329)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.hpp	(revision 1330)
@@ -74,5 +74,5 @@
          CArray<int, 1>& getCompressedIndexToWriteOnServer(MPI_Comm writtenCom);
 
-         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client);
+         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, bool bufferForWriting = false);
 
          /// Test ///
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/context.cpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/context.cpp	(revision 1329)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/context.cpp	(revision 1330)
@@ -297,5 +297,11 @@
    }
 
-   void CContext::setClientServerBuffer(CContextClient* contextClient)
+   /*!
+    Sets client buffers.
+    \param [in] contextClient
+    \param [in] bufferForWriting True if buffers are used for sending data for writing
+    This flag is only true for client and server-1 for communication with server-2
+  */
+   void CContext::setClientServerBuffer(CContextClient* contextClient, bool bufferForWriting)
    {
       // Estimated minimum event size for small events (10 is an arbitrary constant just for safety)
@@ -314,6 +320,6 @@
      // Compute the buffer sizes needed to send the attributes and data corresponding to fields
      std::map<int, StdSize> maxEventSize;
-     std::map<int, StdSize> bufferSize = getAttributesBufferSize(maxEventSize, contextClient);
-     std::map<int, StdSize> dataBufferSize = getDataBufferSize(maxEventSize, contextClient);
+     std::map<int, StdSize> bufferSize = getAttributesBufferSize(maxEventSize, contextClient, bufferForWriting);
+     std::map<int, StdSize> dataBufferSize = getDataBufferSize(maxEventSize, contextClient, bufferForWriting);
 
      std::map<int, StdSize>::iterator it, ite = dataBufferSize.end();
@@ -544,7 +550,7 @@
      distributeFiles();
 
-     setClientServerBuffer(client);
+     setClientServerBuffer(client, (hasClient && !hasServer));
      for (int i = 0; i < clientPrimServer.size(); ++i)
-         setClientServerBuffer(clientPrimServer[i]);
+         setClientServerBuffer(clientPrimServer[i], true);
 
      if (hasClient)
@@ -1334,18 +1340,24 @@
    /*!
     * Compute the required buffer size to send the attributes (mostly those grid related).
-    *
     * \param maxEventSize [in/out] the size of the bigger event for each connected server
+    * \param [in] contextClient
+    * \param [in] bufferForWriting True if buffers are used for sending data for writing
+      This flag is only true for client and server-1 for communication with server-2
     */
-   std::map<int, StdSize> CContext::getAttributesBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient)
+   std::map<int, StdSize> CContext::getAttributesBufferSize(std::map<int, StdSize>& maxEventSize,
+                                                           CContextClient* contextClient, bool bufferForWriting /*= "false"*/)
    {
      std::map<int, StdSize> attributesSize;
 
-     if (hasClient)
-     {
-       size_t numEnabledFiles = this->enabledWriteModeFiles.size();
+//     if (hasClient)
+     {
+       std::vector<CFile*>& fileList = bufferForWriting ? this->enabledWriteModeFiles : this->enabledReadModeFiles;
+//       size_t numEnabledFiles = this->enabledWriteModeFiles.size();
+       size_t numEnabledFiles = fileList.size();
        for (size_t i = 0; i < numEnabledFiles; ++i)
        {
-         CFile* file = this->enabledWriteModeFiles[i];
-         // if (file->getContextClient() == contextClient)
+//           CFile* file = this->enabledWriteModeFiles[i];
+         CFile* file = fileList[i];
+//         if (file->getContextClient() == contextClient)
          {
            std::vector<CField*> enabledFields = file->getEnabledFields();
@@ -1353,10 +1365,10 @@
            for (size_t j = 0; j < numEnabledFields; ++j)
            {
-             const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize(contextClient);
+             const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize(contextClient, bufferForWriting);
              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
+               // so we can use it safely without checking for its existence
                if (attributesSize[it->first] < it->second)
                  attributesSize[it->first] = it->second;
@@ -1369,32 +1381,32 @@
        }
 
-      // Not a good approach here, duplicate code
-       if (!hasServer)
-       {
-         size_t numEnabledFiles = this->enabledReadModeFiles.size();
-         for (size_t i = 0; i < numEnabledFiles; ++i)
-         {
-           CFile* file = this->enabledReadModeFiles[i];  
-           {
-             std::vector<CField*> enabledFields = file->getEnabledFields();
-             size_t numEnabledFields = enabledFields.size();
-             for (size_t j = 0; j < numEnabledFields; ++j)
-             {
-               const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize(contextClient);
-               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;
-               }
-             }
-           }
-         }
-       }
+//      // Not a good approach here, duplicate code
+//       if (!hasServer)
+//       {
+//         size_t numEnabledFiles = this->enabledReadModeFiles.size();
+//         for (size_t i = 0; i < numEnabledFiles; ++i)
+//         {
+//           CFile* file = this->enabledReadModeFiles[i];
+//           {
+//             std::vector<CField*> enabledFields = file->getEnabledFields();
+//             size_t numEnabledFields = enabledFields.size();
+//             for (size_t j = 0; j < numEnabledFields; ++j)
+//             {
+//               const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize(contextClient);
+//               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;
+//               }
+//             }
+//           }
+//         }
+//       }
      }
 
@@ -1404,23 +1416,29 @@
    /*!
     * Compute the required buffer size to send the fields data.
-    *
     * \param maxEventSize [in/out] the size of the bigger event for each connected server
+    * \param [in] contextClient
+    * \param [in] bufferForWriting True if buffers are used for sending data for writing
+      This flag is only true for client and server-1 for communication with server-2
     */
-   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;
+   std::map<int, StdSize> CContext::getDataBufferSize(std::map<int, StdSize>& maxEventSize,
+                                                      CContextClient* contextClient, bool bufferForWriting /*= "false"*/)
+   {
+//     CFile::mode_attr::t_enum mode = hasClient ? CFile::mode_attr::write : CFile::mode_attr::read;
 
      std::map<int, StdSize> dataSize;
 
      // Find all reference domain and axis of all active fields
-     size_t numEnabledFiles = this->enabledFiles.size();
+     std::vector<CFile*>& fileList = bufferForWriting ? this->enabledWriteModeFiles : this->enabledReadModeFiles;
+     size_t numEnabledFiles = fileList.size();
+//     size_t numEnabledFiles = this->enabledFiles.size();
      for (size_t i = 0; i < numEnabledFiles; ++i)
      {
-       CFile* file = this->enabledFiles[i];
+//       CFile* file = this->enabledFiles[i];
+       CFile* file = fileList[i];
        if (file->getContextClient() == contextClient)
        {
-         CFile::mode_attr::t_enum fileMode = file->mode.isEmpty() ? CFile::mode_attr::write : file->mode.getValue();
-
-         if (fileMode == mode)
+//         CFile::mode_attr::t_enum fileMode = file->mode.isEmpty() ? CFile::mode_attr::write : file->mode.getValue();
+//         if (fileMode == mode)
+
          {
            std::vector<CField*> enabledFields = file->getEnabledFields();
@@ -1429,5 +1447,5 @@
            {
              // const std::vector<std::map<int, StdSize> > mapSize = enabledFields[j]->getGridDataBufferSize(contextClient);
-            const std::map<int, StdSize> mapSize = enabledFields[j]->getGridDataBufferSize(contextClient);
+            const std::map<int, StdSize> mapSize = enabledFields[j]->getGridDataBufferSize(contextClient,bufferForWriting);
              // for (size_t c = 0; c < mapSize.size(); ++c)
              // {
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/context.hpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/context.hpp	(revision 1329)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/context.hpp	(revision 1330)
@@ -134,10 +134,7 @@
          void sendGridComponentEnabledFieldsInFiles(const std::vector<CFile*>& activeFiles)       ;
 
-//         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);
+         std::map<int, StdSize> getAttributesBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient, bool bufferForWriting = false);
+         std::map<int, StdSize> getDataBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient, bool bufferForWriting = false);
+         void setClientServerBuffer(CContextClient* contextClient, bool bufferForWriting = false);
 
          // Distribute files (in write mode) among secondary-server pools according to the estimated data flux
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.cpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.cpp	(revision 1329)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.cpp	(revision 1330)
@@ -129,12 +129,8 @@
     * \return A map associating the server rank with its minimum buffer size.
     */
-   std::map<int, StdSize> CDomain::getAttributesBufferSize(CContextClient* client)
-   {
-     CContext* context = CContext::getCurrent();
-     // For now the assumption is that secondary server pools consist of the same number of procs.
-     // CHANGE the line below if the assumption changes.
-     // CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client;
-
-     std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes();
+   std::map<int, StdSize> CDomain::getAttributesBufferSize(CContextClient* client, bool bufferForWriting /*= false*/)
+   {
+
+     std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(client);
 
      if (client->isServerLeader())
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.hpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.hpp	(revision 1329)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.hpp	(revision 1330)
@@ -97,5 +97,5 @@
          CArray<int,1>& getCompressedIndexToWriteOnServer(MPI_Comm writtenCom);
 
-         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client);
+         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, bool bufferForWriting = false);
 
          bool isEmpty(void) const;
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/field.cpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/field.cpp	(revision 1329)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/field.cpp	(revision 1330)
@@ -911,12 +911,12 @@
    }
 
-   std::map<int, StdSize> CField::getGridAttributesBufferSize(CContextClient* client)
-   {
-     return grid->getAttributesBufferSize(client);
-   }
-
-   std::map<int, StdSize> CField::getGridDataBufferSize(CContextClient* client)
-   {
-     return grid->getDataBufferSize(client, getId());
+   std::map<int, StdSize> CField::getGridAttributesBufferSize(CContextClient* client, bool bufferForWriting /*= "false"*/)
+   {
+     return grid->getAttributesBufferSize(client, bufferForWriting);
+   }
+
+   std::map<int, StdSize> CField::getGridDataBufferSize(CContextClient* client, bool bufferForWriting /*= "false"*/)
+   {
+     return grid->getDataBufferSize(client, getId(), bufferForWriting);
    }
 
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/field.hpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/field.hpp	(revision 1329)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/field.hpp	(revision 1330)
@@ -100,6 +100,7 @@
          void resetNStepMax();
 
-         std::map<int, StdSize> getGridAttributesBufferSize(CContextClient* client);
-         std::map<int, StdSize> getGridDataBufferSize(CContextClient* client); // Grid data buffer size for each connection of contextclient
+         std::map<int, StdSize> getGridAttributesBufferSize(CContextClient* client, bool bufferForWriting = false);
+         // Grid data buffer size for each connection of contextclient
+         std::map<int, StdSize> getGridDataBufferSize(CContextClient* client, bool bufferForWriting = false);
 
          void setContextClient(CContextClient* newContextClient);
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.cpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.cpp	(revision 1329)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.cpp	(revision 1330)
@@ -31,5 +31,6 @@
       , clientDistribution_(0), isIndexSent(false) , serverDistribution_(0), clientServerMap_(0)
       , writtenDataSize_(0), numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0)
-      , connectedDataSize_(), connectedServerRank_(), isDataDistributed_(true), isCompressible_(false)
+      , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_()
+	  , isDataDistributed_(true), isCompressible_(false)
       , transformations_(0), isTransformed_(false)
       , axisPositionInGrid_(), hasDomainAxisBaseRef_(false)
@@ -51,5 +52,6 @@
       , clientDistribution_(0), isIndexSent(false) , serverDistribution_(0), clientServerMap_(0)
       , writtenDataSize_(0), numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0)
-      , connectedDataSize_(), connectedServerRank_(), isDataDistributed_(true), isCompressible_(false)
+      , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_()
+	  , isDataDistributed_(true), isCompressible_(false)
       , transformations_(0), isTransformed_(false)
       , axisPositionInGrid_(), hasDomainAxisBaseRef_(false)
@@ -102,10 +104,10 @@
     * TODO: Refactor code
     */
-   std::map<int, StdSize> CGrid::getAttributesBufferSize(CContextClient* client)
-   {
-     std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes();
+   std::map<int, StdSize> CGrid::getAttributesBufferSize(CContextClient* client, bool bufferForWriting)
+   {
+     std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(client);
 
      // The grid indexes require a similar size as the actual data
-     std::map<int, StdSize> dataSizes = getDataBufferSize(client);
+     std::map<int, StdSize> dataSizes = getDataBufferSize(client, "", bufferForWriting);
      // for (size_t i = 0; i < dataSizes.size(); ++i)
      // {
@@ -151,7 +153,8 @@
     * \param client contextClient used to determine the size of connected receivers
     * \param id the id used to tag the data
+    * \param bufferForWriting flag indicating if a buffer is used to send data for writing
     * \return A map associating the sender rank with its minimum buffer size.
     */
-   std::map<int, StdSize> CGrid::getDataBufferSize(CContextClient* client, const std::string& id /*= ""*/)
+   std::map<int, StdSize> CGrid::getDataBufferSize(CContextClient* client, const std::string& id /*= ""*/, bool bufferForWriting /*= "false"*/)
    {     
      // The record index is sometimes sent along with the data but we always
@@ -160,28 +163,15 @@
                                                        + 2 * sizeof(size_t) 
                                                        + sizeof(size_t);
-     // CContext* context = CContext::getCurrent();
-     // int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
-     // std::vector<std::map<int, StdSize> > dataSizes(nbSrvPools);
-     // for (int p = 0; p < nbSrvPools; ++p) 
-     // {
-     //   std::map<int, size_t>::const_iterator itEnd = connectedDataSize_[client].end();
-     //   for (size_t k = 0; k < connectedServerRank_[p].size(); ++k)
-     //   {
-     //     int rank = connectedServerRank_[p][k];
-     //     std::map<int, size_t>::const_iterator it = connectedDataSize_[client].find(rank);
-     //     size_t count = (it != itEnd) ? it->second : 0;
-
-     //     dataSizes[p].insert(std::make_pair(rank, extraSize + CArray<double,1>::size(count)));
-     //   }
-       
-     // }
 
      std::map<int, StdSize> dataSizes;
      int receiverSize = client->serverSize;
-     std::map<int, size_t>::const_iterator itEnd = connectedDataSize_[receiverSize].end();
-     for (size_t k = 0; k < connectedServerRank_[receiverSize].size(); ++k)
+     std::map<int,size_t>& dataSizeMap = bufferForWriting ? connectedDataSize_[receiverSize]: connectedDataSizeRead_;
+     std::vector<int>& connectedServerRanks = bufferForWriting ? connectedServerRank_[receiverSize] : connectedServerRankRead_;
+
+     std::map<int, size_t>::const_iterator itEnd = dataSizeMap.end();
+     for (size_t k = 0; k < connectedServerRanks.size(); ++k)
      {
-       int rank = connectedServerRank_[receiverSize][k];
-       std::map<int, size_t>::const_iterator it = connectedDataSize_[receiverSize].find(rank);
+       int rank = connectedServerRanks[k];
+       std::map<int, size_t>::const_iterator it = dataSizeMap.find(rank);
        size_t count = (it != itEnd) ? it->second : 0;
 
@@ -1551,4 +1541,5 @@
   {
     CContext* context = CContext::getCurrent();
+    connectedServerRankRead_ = ranks;
 
     int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1;
@@ -1659,5 +1650,6 @@
         CArray<size_t,1> outIndex;
         buffer >> outIndex;
-        outGlobalIndexFromClient.insert(std::make_pair(rank, outIndex));        
+        outGlobalIndexFromClient.insert(std::make_pair(rank, outIndex));
+        connectedDataSizeRead_[rank] = outIndex.numElements();
 
         if (doGridHaveDataDistributed(client))
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.hpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.hpp	(revision 1329)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.hpp	(revision 1330)
@@ -166,6 +166,6 @@
          void computeDomConServer();
          std::map<int, int> getDomConServerSide();
-         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client);
-         std::map<int, StdSize> getDataBufferSize(CContextClient* client, const std::string& id = "");
+         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, bool bufferForWriting = false);
+         std::map<int, StdSize> getDataBufferSize(CContextClient* client, const std::string& id = "", bool bufferForWriting = false);
          std::vector<StdString> getDomainList();
          std::vector<StdString> getAxisList();
@@ -326,9 +326,17 @@
         int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
 
-/** Map storing local ranks of connected receivers. Key = size of receiver's intracomm */
+/** Map storing local ranks of connected receivers. Key = size of receiver's intracomm.
+  * It is calculated in computeConnectedClients(). */
         std::map<int, std::vector<int> > connectedServerRank_;
 
-/** Map storing the size of data to be send. Key = size of receiver's intracomm */
+/** Map storing the size of data to be send. Key = size of receiver's intracomm
+  * It is calculated in computeConnectedClients(). */
         std::map<int, std::map<int,size_t> > connectedDataSize_;
+
+/** Ranks of connected receivers in case of reading. It is calculated in recvIndex(). */
+        std::vector<int> connectedServerRankRead_;
+
+/** Size of data to be send in case of reading. It is calculated in recvIndex(). */
+        std::map<int,size_t> connectedDataSizeRead_;
 
         bool isDataDistributed_;        
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/object_template.hpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/object_template.hpp	(revision 1329)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/object_template.hpp	(revision 1330)
@@ -55,5 +55,5 @@
          /// Traitement statique ///
          static void ClearAllAttributes(void);
-         std::map<int, size_t> getMinimumBufferSizeForAttributes();
+         std::map<int, size_t> getMinimumBufferSizeForAttributes(CContextClient* client);
          void sendAttributToServer(const string& id);
          void sendAttributToServer(const string& id, CContextClient* client);
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/object_template_impl.hpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/object_template_impl.hpp	(revision 1329)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/object_template_impl.hpp	(revision 1330)
@@ -181,44 +181,36 @@
 
    template<typename T>
-   std::map<int, size_t> CObjectTemplate<T>::getMinimumBufferSizeForAttributes()
-   {
-     // Use correct context client to send message
-     CContext* context = CContext::getCurrent();
-     // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
-     int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1;
-     for (int i = 0; i < nbSrvPools; ++i)
+   std::map<int, size_t> CObjectTemplate<T>::getMinimumBufferSizeForAttributes(CContextClient* client)
+   {
+     std::map<int, size_t> minimumSizes;
+
+     if (client->isServerLeader())
      {
-       CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i] : context->client;
-
-       std::map<int, size_t> minimumSizes;
-
-       if (contextClientTmp->isServerLeader())
+       size_t minimumSize = 0;
+       CAttributeMap& attrMap = *this;
+       CAttributeMap::const_iterator it = attrMap.begin(), itE = attrMap.end();
+       for (; it != itE; ++it)
        {
-         size_t minimumSize = 0;
-         CAttributeMap& attrMap = *this;
-         CAttributeMap::const_iterator it = attrMap.begin(), itE = attrMap.end();
-         for (; it != itE; ++it)
+         if (!it->second->isEmpty())
          {
-           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 = contextClientTmp->getRanksServerLeader();
-           for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-             minimumSizes.insert(std::make_pair(*itRank, minimumSize));
+           size_t size = it->second->getName().size() + sizeof(size_t) + it->second->size();
+           if (size > minimumSize)
+             minimumSize = size;
          }
        }
-       return minimumSizes;
+
+       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;
+   }
+
 
    template<typename T>
