Index: XIOS/trunk/src/node/context.cpp
===================================================================
--- XIOS/trunk/src/node/context.cpp	(revision 583)
+++ XIOS/trunk/src/node/context.cpp	(revision 584)
@@ -220,21 +220,4 @@
 }
 
-//   //----------------------------------------------------------------
-//
-//   void CContext::solveFieldRefInheritance(bool apply)
-//   {
-//      if (!this->hasId()) return;
-//      vector<CField*> allField = CField::getAll();
-////              = CObjectTemplate<CField>::GetAllVectobject(this->getId());
-//      std::vector<CField*>::iterator
-//         it = allField.begin(), end = allField.end();
-//
-//      for (; it != end; it++)
-//      {
-//         CField* field = *it;
-//         field->solveRefInheritance(apply);
-//      }
-//   }
-
    //----------------------------------------------------------------
 
@@ -258,5 +241,5 @@
      if (hasClient)
      {
-       size_t bufferSizeMin = 1;
+       size_t bufferSizeMin = 10*sizeof(size_t)*1024;
 #define DECLARE_NODE(Name_, name_)    \
    bufferSizeMin = (bufferSizeMin < sizeof(C##Name_##Definition)) ?  sizeof(C##Name_##Definition) : bufferSizeMin;
@@ -264,4 +247,14 @@
 #include "node_type.conf"
        std::map<int, StdSize> bufferSize = getDataSize();
+       if (bufferSize.empty())
+       {
+         if (client->isServerLeader())
+         {
+           bufferSize[client->getServerLeader()] = bufferSizeMin;
+         }
+         else
+          return;
+       }
+
        std::map<int, StdSize>::iterator  it = bufferSize.begin(),
                                         ite = bufferSize.end();
@@ -315,10 +308,10 @@
    void CContext::closeDefinition(void)
    {
-
+     // There is nothing client need to send to server
      if (hasClient)
      {
        // After xml is parsed, there are some more works with post processing
        postProcessing();
-//
+
        setClientServerBuffer();
      }
@@ -353,5 +346,4 @@
 
     // There are some processings that should be done after all of above. For example: check mask or index
-//    if (hasClient && !hasServer)
     if (hasClient)
     {
@@ -361,53 +353,8 @@
 
 
-
-//      if (hasClient)
-//      {
-//        //solveCalendar();
-//
-//        // RÃ©solution des hÃ©ritages pour le context actuel.
-////        this->solveAllInheritance();
-//
-//
-////        //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers Ã  sortir.
-////        this->findEnabledFiles();
-//
-//        this->processEnabledFiles();
-//
-//        this->solveAllGridRef();
-//      }
-
-
-
-
-//      solveCalendar();
-//
-//      // RÃ©solution des hÃ©ritages pour le context actuel.
-//      this->solveAllInheritance();
-//
-//      //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers Ã  sortir.
-//      this->findEnabledFiles();
-//
-//
-//      this->processEnabledFiles();
-
-/*
-      //Recherche des champs Ã  sortir (enable Ã  true + niveau de sortie correct)
-      // pour chaque fichier prÃ©cÃ©demment listÃ©.
-      this->findAllEnabledFields();
-
-      // RÃ©solution des rÃ©fÃ©rences de grilles pour chacun des champs.
-      this->solveAllGridRef();
-
-      // Traitement des opÃ©rations.
-      this->solveAllOperation();
-
-      // Traitement des expressions.
-      this->solveAllExpression();
-*/
-      // Nettoyage de l'arborescence
-      if (hasClient && !hasServer) CleanTree(); // Only on client side??
-//      if (hasClient) CleanTree();
-      if (hasClient) sendCreateFileHeader();
+    // Nettoyage de l'arborescence
+    if (hasClient && !hasServer) CleanTree(); // Only on client side??
+
+    if (hasClient) sendCreateFileHeader();
    }
 
@@ -509,5 +456,5 @@
              return true;
              break;
-           case EVENT_ID_UPDATE_CALENDAR :
+           case EVENT_ID_UPDATE_CALENDAR:
              recvUpdateCalendar(event);
              return true;
@@ -521,4 +468,5 @@
              return true;
              break;
+
            default :
              ERROR("bool CContext::dispatchEvent(CEventServer& event)",
Index: XIOS/trunk/src/node/distribution_client.cpp
===================================================================
--- XIOS/trunk/src/node/distribution_client.cpp	(revision 583)
+++ XIOS/trunk/src/node/distribution_client.cpp	(revision 584)
@@ -17,5 +17,5 @@
    dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_(), domainMasks_(), axisMasks_(),
    gridMask_(), localDomainIndex_(), localAxisIndex_(), indexMap_(), indexDomainData_(), indexAxisData_(),
-   isDataDistributed_(true), axisNum_(0), domainNum_(0), localDataIndexSendToServer_(0)
+   isDataDistributed_(true), axisNum_(0), domainNum_(0), localDataIndexSendToServer_(0), nIndexDomain_(), nIndexAxis_()
 {
 }
@@ -27,12 +27,14 @@
    dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_(), domainMasks_(), axisMasks_(),
    gridMask_(), localDomainIndex_(), localAxisIndex_(), indexMap_(), indexDomainData_(), indexAxisData_(),
-   isDataDistributed_(true), axisNum_(0), domainNum_(0), localDataIndexSendToServer_(0)
+   isDataDistributed_(true), axisNum_(0), domainNum_(0), localDataIndexSendToServer_(0), nIndexDomain_(), nIndexAxis_()
 {
   readDistributionInfo(grid);
   createGlobalIndex();
+  createGlobalIndexSendToServer();
 }
 
 CDistributionClient::~CDistributionClient()
 {
+  if (0 != globalDataSendToServer_) delete globalDataSendToServer_;
   if (0 != localDataIndex_) delete localDataIndex_;
   if (0 != localDataIndexSendToServer_) delete localDataIndexSendToServer_;
@@ -77,4 +79,35 @@
 }
 
+void CDistributionClient::readDomainIndex(const std::vector<CDomain*>& domList)
+{
+  int domainSize = domList.size();
+  nIndexDomain_.resize(domainSize);
+
+  for (int k = 0; k < domainSize; ++k)
+  {
+    nIndexDomain_[k].resize(2);
+    int ni = domList[k]->ni;
+    int nj = domList[k]->nj;
+    nIndexDomain_[k][0].resize(ni,nj);
+    nIndexDomain_[k][1].resize(ni,nj);
+    nIndexDomain_[k][0] = domList[k]->i_index;
+    nIndexDomain_[k][1] = domList[k]->j_index;
+  }
+}
+
+void CDistributionClient::readAxisIndex(const std::vector<CAxis*>& axisList)
+{
+  int axisSize = axisList.size();
+  nIndexAxis_.resize(axisSize);
+
+  for (int k = 0; k < axisSize; ++k)
+  {
+    int n = axisList[k]->ni;
+    nIndexAxis_[k].resize(n);
+    for (int i = 0; i < n; ++i)
+      nIndexAxis_[k](i) = i;
+  }
+}
+
 /*!
   Read information from domain(s) and axis to generate distribution.
@@ -204,4 +237,6 @@
     ++idx;
   }
+  readDomainIndex(domList);
+  readAxisIndex(axisList);
 
   // Grid has only one axis and it is not distributed
@@ -288,4 +323,41 @@
 }
 
+void CDistributionClient::createGlobalIndex()
+{
+  size_t ssize = 1, idx = 0;
+  for (int i = 0; i < this->dims_; ++i)
+    ssize *= nLocal_[i];
+
+  this->globalIndex_ = new CArray<size_t,1>(ssize);
+  std::vector<int> idxLoop(this->dims_,0);
+  int innnerLoopSize = nLocal_[0];
+  while (idx < ssize)
+  {
+    for (int i = 0; i < this->dims_; ++i)
+    {
+      if (idxLoop[i] == nLocal_[i])
+      {
+        idxLoop[i] = 0;
+        ++idxLoop[i+1];
+      }
+    }
+
+    for (int i = 0; i < innnerLoopSize; ++i)
+    {
+      size_t globalIndex = idxLoop[0] + nBeginGlobal_[0];
+      size_t mulDim = 1;
+      for (int k = 1; k < this->dims_; ++k)
+      {
+        mulDim *= nGlob_[k-1];
+        globalIndex += (idxLoop[k] + nBeginGlobal_[k])*mulDim;
+      }
+      (*this->globalIndex_)(idx) = globalIndex;
+      ++idxLoop[0];
+      ++idx;
+    }
+  }
+}
+
+
 /*!
    Create global index on client
@@ -296,5 +368,5 @@
 take into account of C-convention, the rightmost dimension varies faster.
 */
-void CDistributionClient::createGlobalIndex()
+void CDistributionClient::createGlobalIndexSendToServer()
 {
   createLocalDomainDataIndex();
@@ -397,5 +469,5 @@
 
   // Now allocate these arrays
-  this->globalIndex_ = new CArray<size_t,1>(indexSend2ServerCount);
+  this->globalDataSendToServer_ = new CArray<size_t,1>(indexSend2ServerCount);
   localDataIndex_ = new CArray<int,1>(indexLocalDataOnClientCount);
   localDataIndexSendToServer_ = new CArray<int,1>(indexSend2ServerCount);
@@ -507,5 +579,5 @@
             globalIndex += (currentIndex[k] + nBeginGlobal_[k])*mulDim;
           }
-          (*this->globalIndex_)(indexSend2ServerCount) = globalIndex;
+          (*this->globalDataSendToServer_)(indexSend2ServerCount) = globalIndex;
           (*localDataIndexSendToServer_)(indexSend2ServerCount) = indexLocalDataOnClientCount;
           ++indexSend2ServerCount;
@@ -562,4 +634,9 @@
 }
 
+const CArray<size_t,1>& CDistributionClient::getGlobalDataIndexSendToServer() const
+{
+  return (*globalDataSendToServer_);
+}
+
 /*!
   Return local data index of client
@@ -573,5 +650,5 @@
   Return local data index on client which are sent to servers
 */
-const CArray<int,1>& CDistributionClient::getLocalDataIndexSendToServerOnClient() const
+const CArray<int,1>& CDistributionClient::getLocalDataIndexSendToServer() const
 {
   return (*localDataIndexSendToServer_);
Index: XIOS/trunk/src/node/distribution_client.hpp
===================================================================
--- XIOS/trunk/src/node/distribution_client.hpp	(revision 583)
+++ XIOS/trunk/src/node/distribution_client.hpp	(revision 584)
@@ -37,5 +37,6 @@
 
     virtual const CArray<int,1>& getLocalDataIndexOnClient() const;
-    virtual const CArray<int,1>& getLocalDataIndexSendToServerOnClient() const;
+    virtual const CArray<int,1>& getLocalDataIndexSendToServer() const;
+    const CArray<size_t,1>& getGlobalDataIndexSendToServer() const;
 
     std::vector<int> getNGlob() { return nGlob_; }
@@ -45,8 +46,11 @@
   protected:
     void createGlobalIndex();
+    void createGlobalIndexSendToServer();
     void readDistributionInfo(CGrid* grid);
     void readDistributionInfo(const std::vector<CDomain*>& domList,
                               const std::vector<CAxis*>& axisList,
                               const CArray<bool,1>& axisDomainOrder);
+    void readDomainIndex(const std::vector<CDomain*>& domList);
+    void readAxisIndex(const std::vector<CAxis*>& axisList);
   private:
     //! Create local index of a domain
@@ -66,4 +70,5 @@
   private:
     //!< LocalData index on client
+    CArray<size_t,1>* globalDataSendToServer_;
     CArray<int,1>* localDataIndex_;
     CArray<int,1>* localDataIndexSendToServer_;
@@ -81,4 +86,6 @@
     std::vector<int> nZoomBegin_; //!< Begin index of zoom of each dimension
     std::vector<int> nZoomEnd_; //!< End index of zoom of each dimension
+    std::vector<std::vector<CArray<int,2> > > nIndexDomain_; //!< Local index of each domain dimension (e.x: i_index, j_index)
+    std::vector<CArray<int,1> > nIndexAxis_;
 
     // Data_n_index of domain or axis (For now, axis uses its size as data_n_index
Index: XIOS/trunk/src/node/domain.cpp
===================================================================
--- XIOS/trunk/src/node/domain.cpp	(revision 583)
+++ XIOS/trunk/src/node/domain.cpp	(revision 584)
@@ -23,10 +23,10 @@
    CDomain::CDomain(void)
       : CObjectTemplate<CDomain>(), CDomainAttributes()
-      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_()
+      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_()
    { /* Ne rien faire de plus */ }
 
    CDomain::CDomain(const StdString & id)
       : CObjectTemplate<CDomain>(id), CDomainAttributes()
-      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_()
+      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_()
          { /* Ne rien faire de plus */ }
 
@@ -449,6 +449,11 @@
       StdSize dm = zoom_ni_client * zoom_nj_client;
 
-      lonvalue.resize(dm);
-      latvalue.resize(dm);
+      // Make sure that this attribute is non-empty for every client.
+      if (0 != dm)
+      {
+        lonvalue.resize(dm);
+        latvalue.resize(dm);
+      }
+
 
       for (int i = 0; i < zoom_ni_client; i++)
@@ -668,7 +673,6 @@
     int zoom_jend=zoom_jbegin+zoom_nj-1 ;
 
-
     // Precompute number of index
-    int globalIndexCount = 0;
+    int globalIndexCountZoom = 0;
     for(j=0;j<nj;j++)
       for(i=0;i<ni;i++)
@@ -679,12 +683,14 @@
         if (i_ind >= zoom_ibegin && i_ind <= zoom_iend && j_ind >= zoom_jbegin && j_ind <= zoom_jend)
         {
-          ++globalIndexCount;
+          ++globalIndexCountZoom;
         }
       }
 
     // Fill in index
-    CArray<size_t,1> globalIndexDomain(globalIndexCount);
+    CArray<size_t,1> globalIndexDomainZoom(globalIndexCountZoom);
+    CArray<size_t,1> globalIndexDomain(ni*nj);
     size_t globalIndex;
-    globalIndexCount = 0;
+    int globalIndexCount = 0;
+    globalIndexCountZoom = 0;
 
     for(j=0;j<nj;j++)
@@ -694,9 +700,11 @@
         j_ind=jbegin+j_index(i,j) ;
 
+        globalIndex = i_ind + j_ind * ni_glo;
+        globalIndexDomain(globalIndexCount) = globalIndex;
+        ++globalIndexCount;
         if (i_ind >= zoom_ibegin && i_ind <= zoom_iend && j_ind >= zoom_jbegin && j_ind <= zoom_jend)
         {
-          globalIndex = i_ind + j_ind * ni_glo;
-          globalIndexDomain(globalIndexCount) = globalIndex;
-          ++globalIndexCount;
+          globalIndexDomainZoom(globalIndexCountZoom) = globalIndex;
+          ++globalIndexCountZoom;
         }
       }
@@ -724,10 +732,35 @@
     clientServerMap->computeServerIndexMapping(globalIndexDomain);
     const std::map<int, std::vector<size_t> >& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer();
-    std::vector<int> connectedServerRank;
-    for (std::map<int, std::vector<size_t> >::const_iterator it = globalIndexDomainOnServer.begin(); it != globalIndexDomainOnServer.end(); ++it) {
-      connectedServerRank.push_back(it->first);
+
+    std::map<int, std::vector<size_t> >::const_iterator it = globalIndexDomainOnServer.begin(),
+                                                       ite = globalIndexDomainOnServer.end();
+    indSrv_.clear();
+    for (; it != ite; ++it)
+    {
+      int rank = it->first;
+      std::vector<size_t>::const_iterator itbVec  = (it->second).begin(),
+                                           iteVec = (it->second).end();
+      int nb = globalIndexDomainZoom.numElements();
+      for (int i = 0; i < nb; ++i)
+      {
+        if (std::binary_search(itbVec, iteVec, globalIndexDomainZoom(i)))
+        {
+          indSrv_[rank].push_back(globalIndexDomainZoom(i));
+        }
+      }
     }
-    nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank);
-    indSrv_ = globalIndexDomainOnServer;
+
+    connectedServerRank_.clear();
+    for (it = globalIndexDomainOnServer.begin(); it != ite; ++it) {
+      connectedServerRank_.push_back(it->first);
+    }
+
+    if (!indSrv_.empty())
+    {
+      connectedServerRank_.clear();
+      for (it = indSrv_.begin(); it != indSrv_.end(); ++it)
+        connectedServerRank_.push_back(it->first);
+    }
+    nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_);
 
     delete clientServerMap;
@@ -753,8 +786,12 @@
     itbMap = indSrv_.begin();
     iteMap = indSrv_.end();
-    for (it = itbMap; it != iteMap; ++it)
+    for (int k = 0; k < connectedServerRank_.size(); ++k)
     {
-      int rank = it->first;
-      int nbData = (it->second).size();
+      int nbData = 0;
+      int rank = connectedServerRank_[k];
+      it = indSrv_.find(rank);
+      if (iteMap != it)
+        nbData = (it->second).size();
+
       CArray<int,1> indi(nbData) ;
       CArray<int,1> indj(nbData) ;
@@ -807,4 +844,5 @@
         *list_msgLat.back()<<*list_boundslat.back();
       }
+
       eventLon.push(rank,nbConnectedClients_[rank],*list_msgLon.back()) ;
       eventLat.push(rank,nbConnectedClients_[rank],*list_msgLat.back()) ;
Index: XIOS/trunk/src/node/domain.hpp
===================================================================
--- XIOS/trunk/src/node/domain.hpp	(revision 583)
+++ XIOS/trunk/src/node/domain.hpp	(revision 584)
@@ -156,4 +156,5 @@
          std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server
          std::map<int, vector<size_t> > indSrv_; // Global index of each client sent to server
+         std::vector<int> connectedServerRank_;
 
          DECLARE_REF_FUNC(Domain,domain)
Index: XIOS/trunk/src/node/grid.cpp
===================================================================
--- XIOS/trunk/src/node/grid.cpp	(revision 583)
+++ XIOS/trunk/src/node/grid.cpp	(revision 584)
@@ -24,4 +24,5 @@
       , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false)
       , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_(0), writtenDataSize_(0), globalDim_()
+      , connectedDataSize_(), connectedServerRank_()
    {
      setVirtualDomainGroup();
@@ -34,4 +35,5 @@
       , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false)
       , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_(0), writtenDataSize_(0), globalDim_()
+      , connectedDataSize_(), connectedServerRank_()
    {
      setVirtualDomainGroup();
@@ -175,9 +177,8 @@
      StdSize retVal;
      std::map<int, StdSize> ret;
-     const std::map<int, std::vector<int> >& distribution = clientServerMap_->getLocalIndexSendToServer();
-     std::map<int, std::vector<int> >::const_iterator it = distribution.begin(), itE = distribution.end();
+     std::map<int, size_t >::const_iterator it = connectedDataSize_.begin(), itE = connectedDataSize_.end();
      for (; it != itE; ++it)
      {
-        retVal = it->second.size();
+        retVal = it->second;
         retVal *= secureFactor;
         ret.insert(std::make_pair<int,StdSize>(it->first, retVal));
@@ -192,6 +193,6 @@
      if (this->isDomainAxisChecked) return;
 
+     this->solveAxisRef(areAttributesChecked);
      this->solveDomainRef(areAttributesChecked);
-     this->solveAxisRef(areAttributesChecked);
 
      this->isDomainAxisChecked = areAttributesChecked;
@@ -337,13 +338,42 @@
                                                             client->intraComm);
 
-     clientServerMap_->computeServerIndexMapping(clientDistribution_->getGlobalIndex(),
-                                                 clientDistribution_->getLocalDataIndexSendToServerOnClient());
-
+     clientServerMap_->computeServerIndexMapping(clientDistribution_->getGlobalIndex());
      const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_->getGlobalIndexOnServer();
-     std::vector<int> connectedServerRank;
-     for (std::map<int, std::vector<size_t> >::const_iterator it = globalIndexOnServer.begin(); it != globalIndexOnServer.end(); ++it) {
-       connectedServerRank.push_back(it->first);
-     }
-     nbSenders = clientServerMap_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank);
+     const CArray<size_t,1>& globalIndexSendToServer = clientDistribution_->getGlobalDataIndexSendToServer();
+
+     std::map<int, std::vector<size_t> >::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap;
+     itbGlobalMap = itGlobalMap = globalIndexOnServer.begin();
+     iteGlobalMap = globalIndexOnServer.end();
+
+     int nbGlobalIndex = globalIndexSendToServer.numElements();
+    for (; itGlobalMap != iteGlobalMap; ++itGlobalMap)
+    {
+      int serverRank = itGlobalMap->first;
+      std::vector<size_t>::const_iterator itbVecGlobal = (itGlobalMap->second).begin(), itVecGlobal,
+                                          iteVecGlobal = (itGlobalMap->second).end();
+      for (int i = 0; i < nbGlobalIndex; ++i)
+      {
+        if (iteVecGlobal != std::find(itbVecGlobal, iteVecGlobal, globalIndexSendToServer(i)))
+        {
+          if (connectedDataSize_.end() == connectedDataSize_.find(serverRank))
+            connectedDataSize_[serverRank] = 0;
+          else
+            ++connectedDataSize_[serverRank];
+        }
+      }
+    }
+
+   connectedServerRank_.clear();
+   for (std::map<int, std::vector<size_t> >::const_iterator it = globalIndexOnServer.begin(); it != globalIndexOnServer.end(); ++it) {
+     connectedServerRank_.push_back(it->first);
+   }
+   if (!connectedDataSize_.empty())
+   {
+     connectedServerRank_.clear();
+     for (std::map<int,size_t>::const_iterator it = connectedDataSize_.begin(); it != connectedDataSize_.end(); ++it)
+       connectedServerRank_.push_back(it->first);
+   }
+
+    nbSenders = clientServerMap_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_);
 
      // Get local data index on client
@@ -443,45 +473,65 @@
     list< CArray<size_t,1>* > listOutIndex;
     const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_->getGlobalIndexOnServer();
-    const std::map<int, std::vector<int> >& localIndexSendToServer  = clientServerMap_->getLocalIndexSendToServer();
-
-    std::map<int, std::vector<size_t> >::const_iterator iteMap, itbMap, itGlobal;
-    std::map<int, std::vector<int> >::const_iterator itLocal;
-    itbMap = itGlobal = globalIndexOnServer.begin();
-    iteMap = globalIndexOnServer.end();
-    itLocal = localIndexSendToServer.begin();
+    const CArray<int,1>& localIndexSendToServer = clientDistribution_->getLocalDataIndexSendToServer();
+    const CArray<size_t,1>& globalIndexSendToServer = clientDistribution_->getGlobalDataIndexSendToServer();
+
+    std::map<int, std::vector<size_t> >::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap;
+    itbGlobalMap = itGlobalMap = globalIndexOnServer.begin();
+    iteGlobalMap = globalIndexOnServer.end();
+
+    int nbGlobalIndex = globalIndexSendToServer.numElements();
+    std::map<int,std::vector<int> >localIndexTmp;
+    std::map<int,std::vector<size_t> > globalIndexTmp;
+    for (; itGlobalMap != iteGlobalMap; ++itGlobalMap)
+    {
+      int serverRank = itGlobalMap->first;
+      std::vector<size_t>::const_iterator itbVecGlobal = (itGlobalMap->second).begin(),
+                                          iteVecGlobal = (itGlobalMap->second).end();
+      for (int i = 0; i < nbGlobalIndex; ++i)
+      {
+        if (iteVecGlobal != std::find(itbVecGlobal, iteVecGlobal, globalIndexSendToServer(i)))
+        {
+          globalIndexTmp[serverRank].push_back(globalIndexSendToServer(i));
+          localIndexTmp[serverRank].push_back(localIndexSendToServer(i));
+        }
+      }
+    }
+
 
     if (!doGridHaveDataDistributed())
     {
-      if (0 == client->clientRank)
-      {
-       for (int ns = 0; itGlobal != iteMap; ++itGlobal, ++itLocal, ++ns)
-        {
-          rank = itGlobal->first;
-          int nb = (itGlobal->second).size();
-
-          CArray<size_t, 1> outGlobalIndexOnServer(nb);
-          CArray<int, 1> outLocalIndexToServer(nb);
-          for (int k = 0; k < nb; ++k)
-          {
-            outGlobalIndexOnServer(k) = itGlobal->second.at(k);
-            outLocalIndexToServer(k)  = itLocal->second.at(k);
-          }
-
-          storeIndex_toSrv.insert( pair<int,CArray<int,1>* >(rank,new CArray<int,1>(outLocalIndexToServer) ));
-          listOutIndex.push_back(new CArray<size_t,1>(outGlobalIndexOnServer));
-
-          list_msg.push_back(shared_ptr<CMessage>(new CMessage));
-          *list_msg.back()<<getId()<<*listOutIndex.back();
-          event.push(rank, 1, *list_msg.back());
-        }
-        client->sendEvent(event);
-      } else client->sendEvent(event);
+//      if (0 == client->clientRank)
+//      {
+//       for (int ns = 0; itGlobal != iteMap; ++itGlobal, ++itLocal, ++ns)
+//        {
+//          rank = itGlobal->first;
+//          int nb = (itGlobal->second).size();
+//
+//          CArray<size_t, 1> outGlobalIndexOnServer(nb);
+//          CArray<int, 1> outLocalIndexToServer(nb);
+//          for (int k = 0; k < nb; ++k)
+//          {
+//            outGlobalIndexOnServer(k) = itGlobal->second.at(k);
+//            outLocalIndexToServer(k)  = itLocal->second.at(k);
+//          }
+//
+//          storeIndex_toSrv.insert( pair<int,CArray<int,1>* >(rank,new CArray<int,1>(outLocalIndexToServer) ));
+//          listOutIndex.push_back(new CArray<size_t,1>(outGlobalIndexOnServer));
+//
+//          list_msg.push_back(shared_ptr<CMessage>(new CMessage));
+//          *list_msg.back()<<getId()<<*listOutIndex.back();
+//          event.push(rank, 1, *list_msg.back());
+//        }
+//        client->sendEvent(event);
+//      } else client->sendEvent(event);
     }
     else
     {
-      for (int ns = 0; itGlobal != iteMap; ++itGlobal, ++itLocal, ++ns)
-      {
-        rank = itGlobal->first;
-        int nb = (itGlobal->second).size();
+      for (int ns = 0; ns < connectedServerRank_.size(); ++ns)
+      {
+        rank = connectedServerRank_[ns];
+        int nb = 0;
+        if (globalIndexTmp.end() != globalIndexTmp.find(rank))
+          nb = globalIndexTmp[rank].size();
 
         CArray<size_t, 1> outGlobalIndexOnServer(nb);
@@ -489,6 +539,6 @@
         for (int k = 0; k < nb; ++k)
         {
-          outGlobalIndexOnServer(k) = itGlobal->second.at(k);
-          outLocalIndexToServer(k)  = itLocal->second.at(k);
+          outGlobalIndexOnServer(k) = globalIndexTmp[rank].at(k);
+          outLocalIndexToServer(k)  = localIndexTmp[rank].at(k);
         }
 
@@ -498,6 +548,8 @@
         list_msg.push_back(shared_ptr<CMessage>(new CMessage));
         *list_msg.back()<<getId()<<*listOutIndex.back();
+
         event.push(rank, nbSenders[rank], *list_msg.back());
       }
+
       client->sendEvent(event);
     }
@@ -555,5 +607,6 @@
   bool CGrid::doGridHaveDataToWrite()
   {
-    return (0 != serverDistribution_);
+//    return (0 != serverDistribution_);
+    return (0 != writtenDataSize_);
   }
 
Index: XIOS/trunk/src/node/grid.hpp
===================================================================
--- XIOS/trunk/src/node/grid.hpp	(revision 583)
+++ XIOS/trunk/src/node/grid.hpp	(revision 584)
@@ -223,4 +223,6 @@
         CClientServerMapping* clientServerMap_;
         size_t writtenDataSize_;
+        std::map<int,size_t> connectedDataSize_;
+        std::vector<int> connectedServerRank_;
    }; // class CGrid
 
