Index: /XIOS/dev/dev_olga/src/client_client_dht_template_impl.hpp
===================================================================
--- /XIOS/dev/dev_olga/src/client_client_dht_template_impl.hpp	(revision 1029)
+++ /XIOS/dev/dev_olga/src/client_client_dht_template_impl.hpp	(revision 1030)
@@ -307,4 +307,5 @@
 
   indexToInfoMappingLevel_.swap(indexToInfoMapping);
+
   if (0 != recvNbIndexCount) delete [] recvIndexBuff;
   for (boost::unordered_map<int,size_t*>::const_iterator it = client2ClientIndex.begin();
Index: /XIOS/dev/dev_olga/src/client_server_mapping.hpp
===================================================================
--- /XIOS/dev/dev_olga/src/client_server_mapping.hpp	(revision 1029)
+++ /XIOS/dev/dev_olga/src/client_server_mapping.hpp	(revision 1030)
@@ -26,4 +26,5 @@
 public:
   typedef boost::unordered_map<int, std::vector<size_t> > GlobalIndexMap;
+//  typedef boost::map<int, std::vector<size_t> > GlobalIndexMap;
   public:
     /** Default constructor */
Index: /XIOS/dev/dev_olga/src/distribution_server.cpp
===================================================================
--- /XIOS/dev/dev_olga/src/distribution_server.cpp	(revision 1029)
+++ /XIOS/dev/dev_olga/src/distribution_server.cpp	(revision 1030)
@@ -134,7 +134,7 @@
       globalIndex = globalIndexOnEachDimension[0](i);
 
-      for (int k = 1; k < nbDim; ++k)
-      {
-        mulDim *= nbGlobal[k-1];
+      for (int k = 0; k < nbDim; ++k)
+      {
+        mulDim *= nbGlobal[k];
         globalIndex += (currentIndex[k])*mulDim;
       }
Index: /XIOS/dev/dev_olga/src/group_template_impl.hpp
===================================================================
--- /XIOS/dev/dev_olga/src/group_template_impl.hpp	(revision 1029)
+++ /XIOS/dev/dev_olga/src/group_template_impl.hpp	(revision 1030)
@@ -445,5 +445,6 @@
     {
       // Use correct context client to send message
-      int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+      // 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)
       {
Index: /XIOS/dev/dev_olga/src/io/nc4_data_output.cpp
===================================================================
--- /XIOS/dev/dev_olga/src/io/nc4_data_output.cpp	(revision 1029)
+++ /XIOS/dev/dev_olga/src/io/nc4_data_output.cpp	(revision 1030)
@@ -1044,115 +1044,110 @@
         CContext* context = CContext::getCurrent();
 
-        int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
-        for (int i = 0; i < nbSrvPools; ++i)
+        if (axis->IsWritten(this->filename)) return;
+        axis->checkAttributes();
+
+        int local_size_write  = axis->getLocalWriteSize();
+        int global_size_write = axis->getGlobalWriteSize();
+        int start_write = axis->getStartWriteIndex();
+        int count_write = axis->getCountWriteIndex();
+
+        if ((0 == local_size_write) && (MULTI_FILE == SuperClass::type)) return;
+
+        std::vector<StdString> dims;
+        StdString axisid = axis->getAxisOutputName();
+        if (isWrittenAxis(axisid)) return ;
+        else setWrittenAxis(axisid);
+
+        try
         {
-          CContextServer* server = (context->hasServer) ? context->server : context->serverPrimServer[i];
-
-          if (axis->IsWritten(this->filename)) return;
-          axis->checkAttributes();
-
-          int local_size_write  = axis->getLocalWriteSize();
-          int global_size_write = axis->getGlobalWriteSize();
-          int start_write = axis->getStartWriteIndex();
-          int count_write = axis->getCountWriteIndex();
-
-          if ((0 == local_size_write) && (MULTI_FILE == SuperClass::type)) return;
-
-          std::vector<StdString> dims;
-          StdString axisid = axis->getAxisOutputName();
-          if (isWrittenAxis(axisid)) return ;
-          else setWrittenAxis(axisid);
-
-          try
+          SuperClassWriter::addDimension(axisid, global_size_write);
+          if (axis->hasValue)
           {
-            SuperClassWriter::addDimension(axisid, global_size_write);
-            if (axis->hasValue)
+            dims.push_back(axisid);
+            SuperClassWriter::addVariable(axisid, NC_FLOAT, dims);
+
+            if (!axis->name.isEmpty())
+              SuperClassWriter::addAttribute("name", axis->name.getValue(), &axisid);
+
+            if (!axis->standard_name.isEmpty())
+              SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisid);
+
+            if (!axis->long_name.isEmpty())
+              SuperClassWriter::addAttribute("long_name", axis->long_name.getValue(), &axisid);
+
+            if (!axis->unit.isEmpty())
+              SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisid);
+
+            if (!axis->positive.isEmpty())
             {
-              dims.push_back(axisid);
-              SuperClassWriter::addVariable(axisid, NC_FLOAT, dims);
-
-              if (!axis->name.isEmpty())
-                SuperClassWriter::addAttribute("name", axis->name.getValue(), &axisid);
-
-              if (!axis->standard_name.isEmpty())
-                SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisid);
-
-              if (!axis->long_name.isEmpty())
-                SuperClassWriter::addAttribute("long_name", axis->long_name.getValue(), &axisid);
-
-              if (!axis->unit.isEmpty())
-                SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisid);
-
-              if (!axis->positive.isEmpty())
+              SuperClassWriter::addAttribute("axis", string("Z"), &axisid);
+              SuperClassWriter::addAttribute("positive",
+                                             (axis->positive == CAxis::positive_attr::up) ? string("up") : string("down"),
+                                             &axisid);
+            }
+
+            StdString axisBoundsId = axisid + "_bounds";
+            if (!axis->bounds.isEmpty())
+            {
+              dims.push_back("axis_nbounds");
+              SuperClassWriter::addVariable(axisBoundsId, NC_FLOAT, dims);
+              SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid);
+            }
+
+            SuperClassWriter::definition_end();
+
+            switch (SuperClass::type)
+            {
+              case MULTI_FILE:
               {
-                SuperClassWriter::addAttribute("axis", string("Z"), &axisid);
-                SuperClassWriter::addAttribute("positive",
-                                               (axis->positive == CAxis::positive_attr::up) ? string("up") : string("down"),
-                                               &axisid);
+                CArray<double,1> axis_value(local_size_write);
+                for (int i = 0; i < local_size_write; i++) axis_value(i) = axis->value(i);
+                SuperClassWriter::writeData(axis_value, axisid, isCollective, 0);
+
+                if (!axis->bounds.isEmpty())
+                  SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0);
+
+                SuperClassWriter::definition_start();
+
+                break;
               }
-
-              StdString axisBoundsId = axisid + "_bounds";
-              if (!axis->bounds.isEmpty())
+              case ONE_FILE:
               {
-                dims.push_back("axis_nbounds");
-                SuperClassWriter::addVariable(axisBoundsId, NC_FLOAT, dims);
-                SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid);
+                CArray<double,1> axis_value(count_write);
+                axis_value = axis->value;
+
+                std::vector<StdSize> start(1), startBounds(2) ;
+                std::vector<StdSize> count(1), countBounds(2) ;
+                start[0] = startBounds[0] = start_write;
+                count[0] = countBounds[0] = count_write;
+                startBounds[1] = 0;
+                countBounds[1] = 2;
+                SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count);
+
+                if (!axis->bounds.isEmpty())
+                  SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds);
+
+                SuperClassWriter::definition_start();
+
+                break;
               }
-
-              SuperClassWriter::definition_end();
-
-              switch (SuperClass::type)
-              {
-                case MULTI_FILE:
-                {
-                  CArray<double,1> axis_value(local_size_write);
-                  for (int i = 0; i < local_size_write; i++) axis_value(i) = axis->value(i);
-                  SuperClassWriter::writeData(axis_value, axisid, isCollective, 0);
-
-                  if (!axis->bounds.isEmpty())
-                    SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0);
-
-                  SuperClassWriter::definition_start();
-
-                  break;
-                }
-                case ONE_FILE:
-                {
-                  CArray<double,1> axis_value(count_write);
-                  axis_value = axis->value;
-
-                  std::vector<StdSize> start(1), startBounds(2) ;
-                  std::vector<StdSize> count(1), countBounds(2) ;
-                  start[0] = startBounds[0] = start_write;
-                  count[0] = countBounds[0] = count_write;
-                  startBounds[1] = 0;
-                  countBounds[1] = 2;
-                  SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count);
-
-                  if (!axis->bounds.isEmpty())
-                    SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds);
-
-                  SuperClassWriter::definition_start();
-
-                  break;
-                }
-                default :
-                  ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)",
-                        << "[ type = " << SuperClass::type << "]"
-                        << " not implemented yet !");
-              }
+              default :
+                ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)",
+                      << "[ type = " << SuperClass::type << "]"
+                      << " not implemented yet !");
             }
           }
-          catch (CNetCdfException& e)
-          {
-            StdString msg("On writing the axis : ");
-            msg.append(axisid); msg.append("\n");
-            msg.append("In the context : ");
-            CContext* context = CContext::getCurrent() ;
-            msg.append(context->getId()); msg.append("\n");
-            msg.append(e.what());
-            ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", << msg);
-          }
-      } // loop over nbSrvPools
+        }
+        catch (CNetCdfException& e)
+        {
+          StdString msg("On writing the axis : ");
+          msg.append(axisid); msg.append("\n");
+          msg.append("In the context : ");
+          CContext* context = CContext::getCurrent() ;
+          msg.append(context->getId()); msg.append("\n");
+          msg.append(e.what());
+          ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", << msg);
+        }
+      
       axis->addRelFile(this->filename);
      }
Index: /XIOS/dev/dev_olga/src/io/netCdfInterface_impl.hpp
===================================================================
--- /XIOS/dev/dev_olga/src/io/netCdfInterface_impl.hpp	(revision 1029)
+++ /XIOS/dev/dev_olga/src/io/netCdfInterface_impl.hpp	(revision 1030)
@@ -121,4 +121,16 @@
       inqVarName(ncid, varId, varName);
       sstr << "Unable to write data given the location id: " << ncid << " and the variable whose id: " << varId << " and name: " << varName << std::endl;
+//      if (status == NC_ENOTVAR )
+//        sstr <<   "Variable not found. "<< std::endl;
+//      else if (status == NC_EINVALCOORDS)
+//        sstr <<   "Index exceeds dimension bound. "<< std::endl;
+//      else if (status == NC_EEDGE)
+//        sstr <<   " Start+count exceeds dimension bound. "<< std::endl;
+//      else if (status == NC_ERANGE)
+//        sstr <<   " One or more of the values are out of range. "<< std::endl;
+//      else if (status == NC_EINDEFINE)
+//        sstr <<   " Operation not allowed in define mode. "<< std::endl;
+//      else if (status == NC_EBADID)
+//        sstr <<   "Bad ncid. "<< std::endl;
       throw CNetCdfException(sstr.str());
     }
Index: /XIOS/dev/dev_olga/src/node/axis.cpp
===================================================================
--- /XIOS/dev/dev_olga/src/node/axis.cpp	(revision 1029)
+++ /XIOS/dev/dev_olga/src/node/axis.cpp	(revision 1030)
@@ -453,5 +453,6 @@
   {
     CContext* context = CContext::getCurrent();
-    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    // 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)
     {
@@ -748,6 +749,6 @@
   {
     CContext* context = CContext::getCurrent();
-    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
-    
+    // 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)
     {
@@ -854,6 +855,6 @@
     int ns, n, i, j, ind, nv, idx;
     CContext* context = CContext::getCurrent();
-    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
-
+    //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)
     {
Index: /XIOS/dev/dev_olga/src/node/context.cpp
===================================================================
--- /XIOS/dev/dev_olga/src/node/context.cpp	(revision 1029)
+++ /XIOS/dev/dev_olga/src/node/context.cpp	(revision 1030)
@@ -520,5 +520,6 @@
    {
       // Use correct context client to send message
-     int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1;
+     // int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1;
+    int nbSrvPools = (this->hasServer) ? (this->hasClient ? this->clientPrimServer.size() : 0) : 1;
      for (int i = 0; i < nbSrvPools; ++i)
      {
@@ -693,4 +694,9 @@
      {
        this->enabledFiles[i]->generateNewTransformationGridDest();
+     }
+
+     for (int i = 0; i < size; ++i)
+     {
+       //this->enabledFiles[i]->checkGridOfEnabledFields();
      }
    }
@@ -898,5 +904,6 @@
    {
      // Use correct context client to send message
-     int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1;
+     // int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1;
+     int nbSrvPools = (this->hasServer) ? (this->hasClient ? this->clientPrimServer.size() : 0) : 1;
      for (int i = 0; i < nbSrvPools; ++i)
      {
@@ -926,8 +933,4 @@
       *buffer>>id;
       get(id)->closeDefinition();
-      // if (get(id)->hasClient && get(id)->hasServer)
-      // {        
-      //   get(id)->sendCloseDefinition();
-      // }
    }
 
@@ -937,5 +940,6 @@
      // Use correct context client to send message
 //     CContextClient* contextClientTmp = (0 != clientPrimServer) ? clientPrimServer : client;
-     int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1;
+     // int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1;
+    int nbSrvPools = (this->hasServer) ? (this->hasClient ? this->clientPrimServer.size() : 0) : 1;
      for (int i = 0; i < nbSrvPools; ++i)
      {
@@ -984,5 +988,6 @@
    {
      // Use correct context client to send message
-     int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1;
+     // int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1;
+     int nbSrvPools = (this->hasServer) ? (this->hasClient ? this->clientPrimServer.size() : 0) : 1;
      for (int i = 0; i < nbSrvPools; ++i)
      {
@@ -1032,5 +1037,6 @@
    {
       // Use correct context client to send message
-     int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1;
+     // int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1;
+     int nbSrvPools = (this->hasServer) ? (this->hasClient ? this->clientPrimServer.size() : 0) : 1;
      for (int i = 0; i < nbSrvPools; ++i)
      {
@@ -1064,5 +1070,6 @@
    {
       // Use correct context client to send message
-     int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1;
+     // int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1;
+     int nbSrvPools = (this->hasServer) ? (this->hasClient ? this->clientPrimServer.size() : 0) : 1;
      for (int i = 0; i < nbSrvPools; ++i)
      {
@@ -1568,5 +1575,6 @@
 
     // Use correct context client to send message
-    int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1;
+    // int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1;
+    int nbSrvPools = (this->hasServer) ? (this->hasClient ? this->clientPrimServer.size() : 0) : 1;
     for (int i = 0; i < nbSrvPools; ++i)
     {
Index: /XIOS/dev/dev_olga/src/node/domain.cpp
===================================================================
--- /XIOS/dev/dev_olga/src/node/domain.cpp	(revision 1029)
+++ /XIOS/dev/dev_olga/src/node/domain.cpp	(revision 1030)
@@ -1442,15 +1442,16 @@
     CContext* context = CContext::getCurrent();
      // Use correct context client to send message
-    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
     for (int i = 0; i < nbSrvPools; ++i)
     {
-       CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i]
+      CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i]
                                                                          : context->client;    
       int nbServer = contextClientTmp->serverSize;
-    std::vector<int> nGlobDomain(2);
-    nGlobDomain[0] = this->ni_glo;
-    nGlobDomain[1] = this->nj_glo;
-
-    CServerDistributionDescription serverDescription(nGlobDomain, nbServer);
+      std::vector<int> nGlobDomain(2);
+      nGlobDomain[0] = this->ni_glo;
+      nGlobDomain[1] = this->nj_glo;
+
+      CServerDistributionDescription serverDescription(nGlobDomain, nbServer);
       if (isUnstructed_) serverDescription.computeServerDistribution(false, 0);
       else serverDescription.computeServerDistribution(false, 1);
@@ -1495,5 +1496,6 @@
   {
     CContext* context=CContext::getCurrent() ;
-    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
     for (int i = 0; i < nbSrvPools; ++i)
     {
@@ -1666,4 +1668,7 @@
       for (it = globalIndexDomainOnServer.begin(); it != ite; ++it) {
         connectedServerRank_.push_back(it->first);
+//        std::vector<size_t> vec = it->second;
+//        std::sort(vec.begin(), vec.end());
+//        indSrv_[it->first] = vec;
       }
 
@@ -1710,5 +1715,6 @@
     int ns, n, i, j, ind, nv, idx;
     CContext* context = CContext::getCurrent();
-    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
     for (int i = 0; i < nbSrvPools; ++i)
     {
@@ -1780,5 +1786,6 @@
     int ns, n, i, j, ind, nv, idx;
     CContext* context = CContext::getCurrent();
-    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
     for (int i = 0; i < nbSrvPools; ++i)
     {
@@ -1826,5 +1833,6 @@
     int ns, n, i, j, ind, nv, idx;
     CContext* context = CContext::getCurrent();
-    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
     for (int i = 0; i < nbSrvPools; ++i)
     {
@@ -1875,5 +1883,6 @@
     int ns, n, i, j, ind, nv, idx;
     CContext* context = CContext::getCurrent();
-    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
     for (int i = 0; i < nbSrvPools; ++i)
     {
@@ -1960,5 +1969,6 @@
     int ns, n, i, j, ind, nv, idx;
     CContext* context = CContext::getCurrent();
-    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
     for (int i = 0; i < nbSrvPools; ++i)
     {
@@ -2150,6 +2160,6 @@
       {
          index = tmp(ind);
-         i_index(nbIndGlob) = index / ni_glo;
-         j_index(nbIndGlob) = index % ni_glo;
+         i_index(nbIndGlob) = index % ni_glo;
+         j_index(nbIndGlob) = index / ni_glo;
          ++nbIndGlob;
       } 
@@ -2172,6 +2182,6 @@
       {
          index = tmp(ind);
-         zoom_i_index(nbZoomInd) = index / ni_glo;
-         zoom_j_index(nbZoomInd) = index % ni_glo;
+         zoom_i_index(nbZoomInd) = index % ni_glo;
+         zoom_j_index(nbZoomInd) = index / ni_glo;
          ++nbZoomInd;
       } 
@@ -2201,4 +2211,28 @@
         count_write_index_[0] = nbIZoom;
         count_write_index_[1] = nbJZoom;
+
+        // Reoder the zoom_index
+        for (int j = 0; j < nbJZoom; ++j)
+          for (int i = 0; i < nbIZoom; ++i)
+          {
+            idx = nbIZoom * j + i;
+            if (idx < ni_zoom)
+            {
+              zoom_i_index(idx) = ibegin + i;
+              zoom_j_index(idx) = jbegin + j;
+            }
+          }  
+
+        // Reorder the global index
+        for (int j = 0; j < nj; ++j)
+          for (int i = 0; i < ni; ++i)
+          {
+            idx = ni * j + i;
+            if (idx < nbIndGlob)
+            {
+              i_index(idx) = ibegin + i;
+              j_index(idx) = jbegin + j;
+            }
+          }         
       }
             
Index: /XIOS/dev/dev_olga/src/node/field.cpp
===================================================================
--- /XIOS/dev/dev_olga/src/node/field.cpp	(revision 1029)
+++ /XIOS/dev/dev_olga/src/node/field.cpp	(revision 1030)
@@ -124,5 +124,6 @@
     CContext* context = CContext::getCurrent();
 //    CContextClient* client = context->client;
-    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
     for (int i = 0; i < nbSrvPools; ++i)
     {
Index: /XIOS/dev/dev_olga/src/node/grid.cpp
===================================================================
--- /XIOS/dev/dev_olga/src/node/grid.cpp	(revision 1029)
+++ /XIOS/dev/dev_olga/src/node/grid.cpp	(revision 1030)
@@ -273,63 +273,43 @@
    {
      CContext* context = CContext::getCurrent();
-     int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
-
+     // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+     int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;   
+     nbSrvPools = 1;  
      for (int i = 0; i < nbSrvPools; ++i)
-     {
-       CContextClient* client= context->hasServer ? context->clientPrimServer[i] : context->client;
+     {       
        if (isScalarGrid())
-       {
-         // if (context->hasClient && !context->hasServer)
-        if (context->hasClient)
-          if (this->isChecked && doSendingIndex && !isIndexSent) { sendIndexScalarGrid(); this->isIndexSent = true; }
-
-         if (this->isChecked) return;
-         // if (context->hasClient && !context->hasServer)
-         if (context->hasClient)
-         {
-          this->computeIndexScalarGrid();
-         }
-
-  //         this->isChecked = true;
-           if (!(this->hasTransform() && !this->isTransformed()))
-            this->isChecked = true;
-         return;
-       }
-
-       // if (context->hasClient && !context->hasServer)
-      // if (context->hasClient)
-      //   if (doSendingIndex && !isIndexSent)
-        {
-        if (context->hasClient)
-        {
-          if (this->isChecked && doSendingIndex && !isIndexSent)
-            {sendIndex(); this->isIndexSent = true;}
-        }
-
-        if (this->isChecked) return;
-        this->checkAttributesAfterTransformation();
-        this->checkMask();
-        this->computeIndex();
-    //       this->isChecked = true;
+       {  
+          if (context->hasClient)
+            if (this->isChecked && doSendingIndex && !isIndexSent) { sendIndexScalarGrid(); this->isIndexSent = true; }
+
+          if (this->isChecked) continue;
+  
+          if (context->hasClient)
+          {
+            this->computeIndexScalarGrid();
+          }
+  
          if (!(this->hasTransform() && !this->isTransformed()))
           this->isChecked = true;
-
-         if (!(this->hasTransform() && (!this->isGenerated())))
-          this->isChecked = true;
-
-
-        }
-
-      //  if (this->isChecked) return;
-
-      //  // if (context->hasClient && !context->hasServer)
-      // // if (context->hasClient)
-      //  {
-      //     this->checkAttributesAfterTransformation();
-      //     this->checkMask();
-      //     this->computeIndex();
-      //  }
-      //  this->isChecked = true;
-      }
+         continue;
+       }
+
+       if (context->hasClient)
+       {
+         if (this->isChecked && doSendingIndex && !isIndexSent)
+            {sendIndex(); this->isIndexSent = true;}
+       }
+     }
+    
+     if (this->isChecked) return;
+     this->checkAttributesAfterTransformation();
+     this->checkMask();
+     this->computeIndex();
+
+     if (!(this->hasTransform() && !this->isTransformed()))
+      this->isChecked = true;
+
+     if (!(this->hasTransform() && (!this->isGenerated())))
+      this->isChecked = true;
    }
 
@@ -521,10 +501,17 @@
      CContext* context = CContext::getCurrent();
 
-     int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+     // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+     // int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1;
+     // This needs to change one day
+     // It works only for the same number of procs on secondary pools
+     int nbSrvPools = 1; 
+
      for (int i = 0; i < nbSrvPools; ++i)
      {
-       CContextClient* client = (context->hasServer) ? context->clientPrimServer[i] : context->client;
-       CContextServer* server = (context->hasServer) ? context->server : 0 ;
-       int rank = (server && !client) ? server->intraCommRank : client->clientRank;
+       CContextClient* client = (context->hasServer) ? (context->hasClient ? context->clientPrimServer[i] : context->client) : context->client;
+       // CContextClient* client = (context->hasServer) ? context->clientPrimServer[i] : context->client;
+       // CContextServer* server = (context->hasServer) ? context->server : 0 ;
+       // int rank = (server && !client) ? server->intraCommRank : client->clientRank;
+       int rank = client->clientRank;
 
        // First of all, compute distribution on client side
@@ -538,6 +525,7 @@
        int nbStoreIndex = storeIndex_client.numElements();
        for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx];
-       isDataDistributed_= clientDistribution_->isDataDistributed();
-     }
+       if (0 == serverDistribution_) 
+        isDataDistributed_= clientDistribution_->isDataDistributed();
+      }
    }
 
@@ -545,5 +533,7 @@
    {
      CContext* context = CContext::getCurrent();
-     int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+     // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+     int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1;
+     // int nbSrvPools = 1;
      for (int i = 0; i < nbSrvPools; ++i)
      {
@@ -636,12 +626,10 @@
      // isDataDistributed_= clientDistribution_->isDataDistributed();
 
-     int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
-     for (int i = 0; i < nbSrvPools; ++i)
-     {
-       CContextClient* client = (context->hasServer) ? context->clientPrimServer[i] : context->client;
-       computeClientIndex();
-       if (context->hasClient)
-        computeConnectedClients();
-	 }
+     // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+
+     computeClientIndex();
+     if (context->hasClient)
+      computeConnectedClients();
+
 
      // connectedServerRank_.clear();
@@ -715,5 +703,7 @@
    {
      CContext* context = CContext::getCurrent();
-     int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+     // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+     int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1;
+     nbSrvPools = 1;
      for (int i = 0; i < nbSrvPools; ++i)
      {
@@ -1109,11 +1099,12 @@
    void CGrid::restoreField_arr(const CArray<double, 1>& stored, double* const data) const
    {
-      // const StdSize size = storeIndex_client.numElements();
-
-      // for(StdSize i = 0; i < size; i++) data[storeIndex_client(i)] = stored(i);
-      
-      const StdSize size = indexFromClients.numElements();
-
-      for(StdSize i = 0; i < size; i++) data[indexFromClients(i)] = stored(i);
+      const StdSize size = storeIndex_client.numElements();
+
+      for(StdSize i = 0; i < size; i++) data[storeIndex_client(i)] = stored(i);
+
+     // This is a solution for multilevel server      
+      // const StdSize size = indexFromClients.numElements();
+
+      // for(StdSize i = 0; i < size; i++) data[indexFromClients(i)] = stored(i);
 
    }
@@ -1122,5 +1113,6 @@
   {
     CContext* context = CContext::getCurrent();
-    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    // 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)
     {
@@ -1182,5 +1174,6 @@
   {
     CContext* context = CContext::getCurrent();
-    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
     for (int i = 0; i < nbSrvPools; ++i)
     {
@@ -1241,5 +1234,6 @@
     CContext* context = CContext::getCurrent();
 //    CContextClient* client = context->client;
-    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    // 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)
     {
@@ -1251,6 +1245,7 @@
       list<CArray<size_t,1> > listOutIndex;
       const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = clientDistribution_->getGlobalLocalDataSendToServer();
-      CDistributionClient::GlobalLocalDataMap::const_iterator itIndex = globalLocalIndexSendToServer.begin(),
-                                                             iteIndex = globalLocalIndexSendToServer.end();
+      CDistributionClient::GlobalLocalDataMap::const_iterator itbIndex = globalLocalIndexSendToServer.begin(), itIndex,
+                                                              iteIndex = globalLocalIndexSendToServer.end();
+      itIndex = itbIndex;                                                              
 
       if (!doGridHaveDataDistributed())
@@ -1300,15 +1295,15 @@
       else
       {
-        CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itGlobalMap;
-        itGlobalMap = globalIndexOnServer_.begin();
+        CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itGlobalMap, itbGlobalMap;
+        itbGlobalMap = globalIndexOnServer_.begin(), itGlobalMap;
         iteGlobalMap = globalIndexOnServer_.end();
-
-        std::map<int,std::vector<int> >localIndexTmp;
-        std::map<int,std::vector<size_t> > globalIndexTmp;
-        for (; itGlobalMap != iteGlobalMap; ++itGlobalMap)
+        
+        std::map<int,int > nbGlobalLocalTmp;
+        for (itGlobalMap = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap)
         {
           int serverRank = itGlobalMap->first;
-          int indexSize = itGlobalMap->second.size();
+          nbGlobalLocalTmp[serverRank] = 0;
           const std::vector<size_t>& indexVec = itGlobalMap->second;
+          int indexSize = indexVec.size();          
           for (int idx = 0; idx < indexSize; ++idx)
           {
@@ -1316,6 +1311,33 @@
             if (iteIndex != itIndex)
             {
-              globalIndexTmp[serverRank].push_back(itIndex->first);
-              localIndexTmp[serverRank].push_back(itIndex->second);
+              ++nbGlobalLocalTmp[serverRank];
+            }
+          }
+        }
+
+        std::map<int,std::vector<int> >localIndexTmp;
+        std::map<int,std::vector<size_t> > globalIndexTmp;
+        for (std::map<int,int>::iterator it = nbGlobalLocalTmp.begin(); it != nbGlobalLocalTmp.end(); ++it)
+        {
+          localIndexTmp[it->first].resize(it->second);
+          globalIndexTmp[it->first].resize(it->second);
+          it->second = 0;
+        }
+
+        for (itGlobalMap = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap)
+        {
+          int serverRank = itGlobalMap->first;          
+          const std::vector<size_t>& indexVec = itGlobalMap->second;
+          int indexSize = indexVec.size();          
+          int ind = 0;
+          for (int idx = 0; idx < indexSize; ++idx)
+          {
+            itIndex = globalLocalIndexSendToServer.find(indexVec[idx]);
+            if (iteIndex != itIndex)
+            {              
+              ind = nbGlobalLocalTmp[serverRank];
+              globalIndexTmp[serverRank][ind] = itIndex->first;
+              localIndexTmp[serverRank][ind]  = itIndex->second;
+              ++nbGlobalLocalTmp[serverRank];
             }
           }
@@ -1373,5 +1395,6 @@
   {
     CContext* context = CContext::getCurrent();
-    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1;
+    nbSrvPools = 1;
     for (int i = 0; i < nbSrvPools; ++i)
     {
Index: /XIOS/dev/dev_olga/src/node/variable.cpp
===================================================================
--- /XIOS/dev/dev_olga/src/node/variable.cpp	(revision 1029)
+++ /XIOS/dev/dev_olga/src/node/variable.cpp	(revision 1030)
@@ -86,5 +86,6 @@
      {
        // Use correct context client to send message
-       int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+       // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+      int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
        for (int i = 0; i < nbSrvPools; ++i)
        {
Index: /XIOS/dev/dev_olga/src/object_template_impl.hpp
===================================================================
--- /XIOS/dev/dev_olga/src/object_template_impl.hpp	(revision 1029)
+++ /XIOS/dev/dev_olga/src/object_template_impl.hpp	(revision 1030)
@@ -166,5 +166,6 @@
      // Use correct context client to send message
      CContext* context = CContext::getCurrent();
-     int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+     // 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)
      {
@@ -275,5 +276,6 @@
     if (context->hasClient)
     {
-      int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+      // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+      int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
       for (int i = 0; i < nbSrvPools; ++i)
       {
@@ -349,5 +351,6 @@
     {
       // Use correct context client to send message
-      int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+      // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
+      int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
       for (int i = 0; i < nbSrvPools; ++i)
       {
Index: /XIOS/dev/dev_olga/src/test/test_client.f90
===================================================================
--- /XIOS/dev/dev_olga/src/test/test_client.f90	(revision 1029)
+++ /XIOS/dev/dev_olga/src/test/test_client.f90	(revision 1030)
@@ -19,5 +19,5 @@
   INTEGER,PARAMETER :: ni_glo=4
   INTEGER,PARAMETER :: nj_glo=4
-  INTEGER,PARAMETER :: llm=5
+  INTEGER,PARAMETER :: llm=2
   DOUBLE PRECISION  :: lval(llm)=1
   TYPE(xios_field) :: field_hdl
@@ -133,5 +133,5 @@
   DO ts=1,40
     CALL xios_update_calendar(ts)
-    ! CALL xios_send_field("field_A",field_A)
+    CALL xios_send_field("field_A",field_A)
     ! CALL xios_send_field("field_Axis",axisValue)
     ! CALL xios_send_field("field_Axis",lval)
