Index: XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.cpp
===================================================================
--- XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.cpp	(revision 1345)
+++ XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.cpp	(revision 1346)
@@ -530,108 +530,109 @@
       int rank = client->clientRank;
 
-      size_t ni = this->n.getValue();
-      size_t ibegin = this->begin.getValue();
-      size_t global_zoom_end = global_zoom_begin+global_zoom_n-1;
-      size_t nZoomCount = 0;
-      size_t nbIndex = index.numElements();
-
-      // First of all, we should compute the mapping of the global index and local index of the current client
-      if (globalLocalIndexMap_.empty())
-      {
-        for (size_t idx = 0; idx < nbIndex; ++idx)
-        {
-          globalLocalIndexMap_[index(idx)] = idx;
-        }
-      }
-
-      // Calculate the compressed index if any
-      std::set<int> writtenInd;
-      if (isCompressible_)
-      {
-        for (int idx = 0; idx < data_index.numElements(); ++idx)
-        {
-          int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni);
-
-          if (ind >= 0 && ind < ni && mask(ind))
+      if (connectedServerRank_.find(nbServer) == connectedServerRank_.end())
+      {
+        size_t ni = this->n.getValue();
+        size_t ibegin = this->begin.getValue();
+        size_t global_zoom_end = global_zoom_begin+global_zoom_n-1;
+        size_t nZoomCount = 0;
+        size_t nbIndex = index.numElements();
+
+        // First of all, we should compute the mapping of the global index and local index of the current client
+        if (globalLocalIndexMap_.empty())
+        {
+          for (size_t idx = 0; idx < nbIndex; ++idx)
           {
-            ind += ibegin;
-            if (ind >= global_zoom_begin && ind <= global_zoom_end)
-              writtenInd.insert(ind);
+            globalLocalIndexMap_[index(idx)] = idx;
           }
         }
-      }
-
-      // Compute the global index of the current client (process) hold
-      std::vector<int> nGlobAxis(1);
-      nGlobAxis[0] = n_glo.getValue();
-
-      size_t globalSizeIndex = 1, indexBegin, indexEnd;
-      for (int i = 0; i < nGlobAxis.size(); ++i) globalSizeIndex *= nGlobAxis[i];
-      indexBegin = 0;
-      if (globalSizeIndex <= clientSize)
-      {
-        indexBegin = rank%globalSizeIndex;
-        indexEnd = indexBegin;
-      }
-      else
-      {
-        for (int i = 0; i < clientSize; ++i)
-        {
-          range = globalSizeIndex / clientSize;
-          if (i < (globalSizeIndex%clientSize)) ++range;
-          if (i == client->clientRank) break;
-          indexBegin += range;
-        }
-        indexEnd = indexBegin + range - 1;
-      }
-
-      CArray<size_t,1> globalIndex(index.numElements());
-      for (size_t idx = 0; idx < globalIndex.numElements(); ++idx)
-        globalIndex(idx) = index(idx);
-
-      // Describe the distribution of server side
-
-      CServerDistributionDescription serverDescription(nGlobAxis, nbServer, distType);
+
+        // Calculate the compressed index if any
+        std::set<int> writtenInd;
+        if (isCompressible_)
+        {
+          for (int idx = 0; idx < data_index.numElements(); ++idx)
+          {
+            int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni);
+
+            if (ind >= 0 && ind < ni && mask(ind))
+            {
+              ind += ibegin;
+              if (ind >= global_zoom_begin && ind <= global_zoom_end)
+                writtenInd.insert(ind);
+            }
+          }
+        }
+
+        // Compute the global index of the current client (process) hold
+        std::vector<int> nGlobAxis(1);
+        nGlobAxis[0] = n_glo.getValue();
+
+        size_t globalSizeIndex = 1, indexBegin, indexEnd;
+        for (int i = 0; i < nGlobAxis.size(); ++i) globalSizeIndex *= nGlobAxis[i];
+        indexBegin = 0;
+        if (globalSizeIndex <= clientSize)
+        {
+          indexBegin = rank%globalSizeIndex;
+          indexEnd = indexBegin;
+        }
+        else
+        {
+          for (int i = 0; i < clientSize; ++i)
+          {
+            range = globalSizeIndex / clientSize;
+            if (i < (globalSizeIndex%clientSize)) ++range;
+            if (i == client->clientRank) break;
+            indexBegin += range;
+          }
+          indexEnd = indexBegin + range - 1;
+        }
+
+        CArray<size_t,1> globalIndex(index.numElements());
+        for (size_t idx = 0; idx < globalIndex.numElements(); ++idx)
+          globalIndex(idx) = index(idx);
+
+        // Describe the distribution of server side
+
+        CServerDistributionDescription serverDescription(nGlobAxis, nbServer, distType);
       
-      std::vector<int> serverZeroIndex;
-      serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0);      
-
-      std::list<int> serverZeroIndexLeader;
-      std::list<int> serverZeroIndexNotLeader; 
-      CContextClient::computeLeader(client->clientRank, client->clientSize, serverZeroIndex.size(), serverZeroIndexLeader, serverZeroIndexNotLeader);
-      for (std::list<int>::iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it)
-        *it = serverZeroIndex[*it];
-
-      // Find out the connection between client and server side
-      CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm);
-      clientServerMap->computeServerIndexMapping(globalIndex, nbServer);
-      CClientServerMapping::GlobalIndexMap& globalIndexAxisOnServer = clientServerMap->getGlobalIndexOnServer();      
-
-
-      indSrv_[nbServer].swap(globalIndexAxisOnServer);
-
-      if (distType==CServerDistributionDescription::ROOT_DISTRIBUTION)
-      {
-        for(int i=1; i<nbServer; ++i) indSrv_[nbServer].insert(pair<int, vector<size_t> >(i,indSrv_[nbServer][0]) ) ;
-        serverZeroIndexLeader.clear() ;
-      }
+        std::vector<int> serverZeroIndex;
+        serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0);      
+
+        std::list<int> serverZeroIndexLeader;
+        std::list<int> serverZeroIndexNotLeader; 
+        CContextClient::computeLeader(client->clientRank, client->clientSize, serverZeroIndex.size(), serverZeroIndexLeader, serverZeroIndexNotLeader);
+        for (std::list<int>::iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it)
+          *it = serverZeroIndex[*it];
+
+        // Find out the connection between client and server side
+        CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm);
+        clientServerMap->computeServerIndexMapping(globalIndex, nbServer);
+        CClientServerMapping::GlobalIndexMap& globalIndexAxisOnServer = clientServerMap->getGlobalIndexOnServer();      
+
+        indSrv_[nbServer].swap(globalIndexAxisOnServer);
+
+        if (distType==CServerDistributionDescription::ROOT_DISTRIBUTION)
+        {
+          for(int i=1; i<nbServer; ++i) indSrv_[nbServer].insert(pair<int, vector<size_t> >(i,indSrv_[nbServer][0]) ) ;
+          serverZeroIndexLeader.clear() ;
+        }
          
-      CClientServerMapping::GlobalIndexMap::const_iterator it  = indSrv_[nbServer].begin(),
-                                                           ite = indSrv_[nbServer].end();
-
-      for (it = indSrv_[nbServer].begin(); it != ite; ++it) connectedServerRank_[nbServer].push_back(it->first);
-
-      for (std::list<int>::const_iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it)
-        connectedServerRank_[nbServer].push_back(*it);
-
-       // Even if a client has no index, it must connect to at least one server and 
-       // send an "empty" data to this server
-       if (connectedServerRank_[nbServer].empty())
-        connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize);
-
-//       nbSenders[client] = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[client]);
-       nbSenders[nbServer] = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]);
-
-      delete clientServerMap;
+        CClientServerMapping::GlobalIndexMap::const_iterator it  = indSrv_[nbServer].begin(),
+                                                             ite = indSrv_[nbServer].end();
+
+        for (it = indSrv_[nbServer].begin(); it != ite; ++it) connectedServerRank_[nbServer].push_back(it->first);
+
+        for (std::list<int>::const_iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it)
+          connectedServerRank_[nbServer].push_back(*it);
+
+         // Even if a client has no index, it must connect to at least one server and 
+         // send an "empty" data to this server
+         if (connectedServerRank_[nbServer].empty())
+          connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize);
+
+         nbSenders[nbServer] = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]);
+
+        delete clientServerMap;
+      }
     }
   }
Index: XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.cpp
===================================================================
--- XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.cpp	(revision 1345)
+++ XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.cpp	(revision 1346)
@@ -1718,22 +1718,25 @@
       bool doComputeGlobalIndexServer = true;
 
-      if (indSrv_.find(nbServer) == indSrv_.end())
-      {
-         int i,j,i_ind,j_ind, nbIndex, nbIndexZoom;
-         int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1;
-         int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1;
-
-         // Precompute number of index
-         int globalIndexCountZoom = 0;
-         nbIndex = i_index.numElements();
-
-         if (doZoomByIndex_)
-         {
-            globalIndexCountZoom = zoom_i_index.numElements();
-         }
-         else
-         {
-            for (i = 0; i < nbIndex; ++i)
-            {
+      if (connectedServerRank_.find(nbServer) == connectedServerRank_.end())
+      {
+
+        if (indSrv_.find(nbServer) == indSrv_.end())
+        {
+          int i,j,i_ind,j_ind, nbIndex, nbIndexZoom;
+          int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1;
+          int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1;
+
+           // Precompute number of index
+           int globalIndexCountZoom = 0;
+           nbIndex = i_index.numElements();
+
+           if (doZoomByIndex_)
+           {
+             globalIndexCountZoom = zoom_i_index.numElements();
+           }
+           else
+           {
+             for (i = 0; i < nbIndex; ++i)
+             {
                i_ind=i_index(i);
                j_ind=j_index(i);
@@ -1743,36 +1746,35 @@
                   ++globalIndexCountZoom;
                }
-            }
-         }
-
-
-         // Fill in index
-         CArray<size_t,1> globalIndexDomainZoom(globalIndexCountZoom);
-         CArray<size_t,1> localIndexDomainZoom(globalIndexCountZoom);
-         CArray<size_t,1> globalIndexDomain(nbIndex);
-         size_t globalIndex;
-         int globalIndexCount = 0;
-
-         for (i = 0; i < nbIndex; ++i)
-         {
-            i_ind=i_index(i);
-            j_ind=j_index(i);
-            globalIndex = i_ind + j_ind * ni_glo;
-            globalIndexDomain(i) = globalIndex;
-         }
-
-         if (globalLocalIndexMap_.empty())
-         {
-            for (i = 0; i < nbIndex; ++i)
+             }
+           }
+
+           // Fill in index
+           CArray<size_t,1> globalIndexDomainZoom(globalIndexCountZoom);
+           CArray<size_t,1> localIndexDomainZoom(globalIndexCountZoom);
+           CArray<size_t,1> globalIndexDomain(nbIndex);
+           size_t globalIndex;
+           int globalIndexCount = 0;
+
+           for (i = 0; i < nbIndex; ++i)
+           {
+             i_ind=i_index(i);
+             j_ind=j_index(i);
+             globalIndex = i_ind + j_ind * ni_glo;
+             globalIndexDomain(i) = globalIndex;
+           }
+
+           if (globalLocalIndexMap_.empty())
+           {
+             for (i = 0; i < nbIndex; ++i)
                globalLocalIndexMap_[globalIndexDomain(i)] = i;
-         }
-
-         globalIndexCountZoom = 0;
-         if (doZoomByIndex_)
-         {
-            int nbIndexZoom = zoom_i_index.numElements();
-
-            for (i = 0; i < nbIndexZoom; ++i)
-            {
+           }
+
+           globalIndexCountZoom = 0;
+           if (doZoomByIndex_)
+           {
+             int nbIndexZoom = zoom_i_index.numElements();
+
+             for (i = 0; i < nbIndexZoom; ++i)
+             {
                i_ind=zoom_i_index(i);
                j_ind=zoom_j_index(i);
@@ -1780,12 +1782,12 @@
                globalIndexDomainZoom(globalIndexCountZoom) = globalIndex;
                ++globalIndexCountZoom;
-            }
-         }
-         else
-         {
-            int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1;
-            int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1;
-            for (i = 0; i < nbIndex; ++i)
-            {
+             }
+           }
+           else
+           {
+             int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1;
+             int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1;
+             for (i = 0; i < nbIndex; ++i)
+             {
                i_ind=i_index(i);
                j_ind=j_index(i);
@@ -1796,86 +1798,77 @@
                   ++globalIndexCountZoom;
                }
-            }
-
-            int iend = ibegin + ni -1;
-            int jend = jbegin + nj -1;
-            zoom_ibegin = global_zoom_ibegin > ibegin ? global_zoom_ibegin : ibegin;
-            int zoom_iend  = global_zoom_iend < iend ? zoom_iend : iend ;
-            zoom_ni     = zoom_iend-zoom_ibegin+1 ;
-
-            zoom_jbegin = global_zoom_jbegin > jbegin ? global_zoom_jbegin : jbegin ;
-            int zoom_jend   = global_zoom_jend < jend ? zoom_jend : jend;
-            zoom_nj     = zoom_jend-zoom_jbegin+1;
-         }
-
-
-         size_t globalSizeIndex = 1, indexBegin, indexEnd;
-         int range, clientSize = client->clientSize;
-         std::vector<int> nGlobDomain(2);
-         nGlobDomain[0] = this->ni_glo;
-         nGlobDomain[1] = this->nj_glo;
-         for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i];
-         indexBegin = 0;
-         if (globalSizeIndex <= clientSize)
-         {
-            indexBegin = rank%globalSizeIndex;
-            indexEnd = indexBegin;
-         }
-         else
-         {
-            for (int i = 0; i < clientSize; ++i)
-            {
+             }
+
+             int iend = ibegin + ni -1;
+             int jend = jbegin + nj -1;
+             zoom_ibegin = global_zoom_ibegin > ibegin ? global_zoom_ibegin : ibegin;
+             int zoom_iend  = global_zoom_iend < iend ? zoom_iend : iend ;
+             zoom_ni     = zoom_iend-zoom_ibegin+1 ;
+
+             zoom_jbegin = global_zoom_jbegin > jbegin ? global_zoom_jbegin : jbegin ;
+             int zoom_jend   = global_zoom_jend < jend ? zoom_jend : jend;
+             zoom_nj     = zoom_jend-zoom_jbegin+1;
+           }
+
+           size_t globalSizeIndex = 1, indexBegin, indexEnd;
+           int range, clientSize = client->clientSize;
+           std::vector<int> nGlobDomain(2);
+           nGlobDomain[0] = this->ni_glo;
+           nGlobDomain[1] = this->nj_glo;
+           for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i];
+           indexBegin = 0;
+           if (globalSizeIndex <= clientSize)
+           {
+             indexBegin = rank%globalSizeIndex;
+             indexEnd = indexBegin;
+           }
+           else
+           {
+             for (int i = 0; i < clientSize; ++i)
+             {
                range = globalSizeIndex / clientSize;
                if (i < (globalSizeIndex%clientSize)) ++range;
                if (i == client->clientRank) break;
                indexBegin += range;
-            }
-            indexEnd = indexBegin + range - 1;
-         }
-
-         // Even if servers have no index, they must received something from client
-         // We only use several client to send "empty" message to these servers
-         CServerDistributionDescription serverDescription(nGlobDomain, nbServer);
-         std::vector<int> serverZeroIndex;
-         if (isUnstructed_) serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0);
-         else serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 1);
-
-         std::list<int> serverZeroIndexLeader;
-         std::list<int> serverZeroIndexNotLeader;
-         CContextClient::computeLeader(client->clientRank, client->clientSize, serverZeroIndex.size(), serverZeroIndexLeader, serverZeroIndexNotLeader);
-         for (std::list<int>::iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it)
-            *it = serverZeroIndex[*it];
-
-         CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(),
-               client->intraComm);
-         clientServerMap->computeServerIndexMapping(globalIndexDomain, nbServer);
-         CClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer();
-
-         CClientServerMapping::GlobalIndexMap::const_iterator it  = globalIndexDomainOnServer.begin(),
-               ite = globalIndexDomainOnServer.end();
-//         indSrv_[client].swap(globalIndexDomainOnServer);
-//         connectedServerRank_[client].clear();
-//         for (it = indSrv_[client].begin(); it != ite; ++it)
-//            connectedServerRank_[client].push_back(it->first);
-         indSrv_[nbServer].swap(globalIndexDomainOnServer);
-         connectedServerRank_[nbServer].clear();
-         for (it = indSrv_[nbServer].begin(); it != ite; ++it)
-            connectedServerRank_[nbServer].push_back(it->first);
-
-         for (std::list<int>::const_iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it)
-            connectedServerRank_[nbServer].push_back(*it);
-
-         // Even if a client has no index, it must connect to at least one server and
-        // send an "empty" data to this server
-         if (connectedServerRank_[nbServer].empty())
-            connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize);
-
-         nbSenders[nbServer] = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]);
-//         if (connectedServerRank_[client].empty())
-//            connectedServerRank_[client].push_back(client->clientRank % client->serverSize);
-//
-//         nbSenders[client] = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[client]);
-
-         delete clientServerMap;
+             }
+             indexEnd = indexBegin + range - 1;
+           }
+
+           // Even if servers have no index, they must received something from client
+           // We only use several client to send "empty" message to these servers
+           CServerDistributionDescription serverDescription(nGlobDomain, nbServer);
+           std::vector<int> serverZeroIndex;
+           if (isUnstructed_) serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0);
+           else serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 1);
+
+           std::list<int> serverZeroIndexLeader;
+           std::list<int> serverZeroIndexNotLeader;
+           CContextClient::computeLeader(client->clientRank, client->clientSize, serverZeroIndex.size(), serverZeroIndexLeader, serverZeroIndexNotLeader);
+           for (std::list<int>::iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it)
+              *it = serverZeroIndex[*it];
+
+           CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(),
+                 client->intraComm);
+           clientServerMap->computeServerIndexMapping(globalIndexDomain, nbServer);
+           CClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer();
+
+           CClientServerMapping::GlobalIndexMap::const_iterator it  = globalIndexDomainOnServer.begin(),
+                 ite = globalIndexDomainOnServer.end();
+           indSrv_[nbServer].swap(globalIndexDomainOnServer);
+           connectedServerRank_[nbServer].clear();
+           for (it = indSrv_[nbServer].begin(); it != ite; ++it)
+             connectedServerRank_[nbServer].push_back(it->first);
+
+           for (std::list<int>::const_iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it)
+              connectedServerRank_[nbServer].push_back(*it);
+
+           // Even if a client has no index, it must connect to at least one server and
+           // send an "empty" data to this server
+           if (connectedServerRank_[nbServer].empty())
+              connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize);
+
+           nbSenders[nbServer] = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]);
+           delete clientServerMap;
+        }
       }
     }
