Index: XIOS/trunk/src/node/domain.cpp
===================================================================
--- XIOS/trunk/src/node/domain.cpp	(revision 569)
+++ 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()) ;
