Index: XIOS/trunk/inputs/COMPLETE/context_atmosphere.xml
===================================================================
--- XIOS/trunk/inputs/COMPLETE/context_atmosphere.xml	(revision 632)
+++ XIOS/trunk/inputs/COMPLETE/context_atmosphere.xml	(revision 633)
@@ -26,5 +26,7 @@
   <domain_definition>
     <domain id="domain_atm" />
-    <domain id="domain_atm_zoom" />
+    <domain id="domain_atm_zoom" domain_ref="domain_atm">
+      <zoom_domain zoom_ibegin="39" zoom_ni="20" zoom_jbegin="39" zoom_nj="5"/>
+    </domain>
   </domain_definition>
 
@@ -35,5 +37,5 @@
    </grid>
    <grid id="grid_A_atm_zoom">
-     <domain domain_ref="domain_atm" />
+     <domain domain_ref="domain_atm_zoom" />
      <axis axis_ref="axis_atm_zoom" />
    </grid>
Index: XIOS/trunk/inputs/Version2/iodef.xml
===================================================================
--- XIOS/trunk/inputs/Version2/iodef.xml	(revision 632)
+++ XIOS/trunk/inputs/Version2/iodef.xml	(revision 633)
@@ -11,5 +11,5 @@
      <field id="field_Two_Axis"  operation="average" freq_op="3600s" grid_ref="grid_Two_Axis" />
      <field id="field_All_Axis" operation="average" freq_op="3600s" grid_ref="grid_All_Axis" />
-     <field id="field_Axis_transformed"  operation="average" freq_op="3600s" field_ref="field_A" grid_ref="grid_Axis_tranformed" />
+     <field id="field_Axis_transformed"  operation="average" freq_op="3600s" field_ref="field_Two_Axis" grid_ref="grid_Axis_tranformed" />
      <field id="field_Axis_transformed_Interpolated"  operation="average" freq_op="3600s" field_ref="field_Axis" grid_ref="grid_Axis_tranformed_Interpolated" />
      <field id="field_Scalar" operation="average" freq_op="3600s" grid_ref="ScalarGrid" />
@@ -17,5 +17,5 @@
 
    <file_definition type="multiple_file" par_access="collective" output_freq="6h" output_level="10" enabled=".TRUE.">
-     <file id="output" name="output">
+     <file id="output" name="output" type="one_file">
         <field field_ref="field_A" />
      </file>
@@ -26,5 +26,5 @@
         <field field_ref="field_All_Axis" />
      </file>
-     <file id="output_Axis_transformed" name="output_Axis_transformed">
+     <file id="output_Axis_transformed" name="output_Axis_transformed" type="one_file">
         <field field_ref="field_Axis_transformed" />
      </file>
@@ -87,8 +87,8 @@
        <grid id="grid_Axis_tranformed">
 <!--         <domain domain_ref="domain_A" />-->
-         <domain domain_ref="domain_A_zoom" />
-         <axis axis_ref="axis_H" />
-<!--         <axis axis_ref="axis_E" />-->
-<!--         <axis axis_ref="axis_F" />-->
+<!--         <domain domain_ref="domain_A_zoom" />-->
+<!--         <axis axis_ref="axis_H" />-->
+         <axis axis_ref="axis_E" />
+         <axis axis_ref="axis_F" />
        </grid>
        <grid id="grid_Axis_tranformed_Interpolated">
Index: XIOS/trunk/src/config/axis_attribute.conf
===================================================================
--- XIOS/trunk/src/config/axis_attribute.conf	(revision 632)
+++ XIOS/trunk/src/config/axis_attribute.conf	(revision 633)
@@ -10,4 +10,6 @@
 DECLARE_ATTRIBUTE(int,       zoom_size)
 DECLARE_ENUM2(positive, up, down)
+
+/* LOCAL */
 DECLARE_ARRAY(double, 1, value)
 
Index: XIOS/trunk/src/node/axis.cpp
===================================================================
--- XIOS/trunk/src/node/axis.cpp	(revision 632)
+++ XIOS/trunk/src/node/axis.cpp	(revision 633)
@@ -12,4 +12,6 @@
 #include "zoom_axis.hpp"
 #include "interpolate_axis.hpp"
+#include "server_distribution_description.hpp"
+#include "client_server_mapping_distributed.hpp"
 
 namespace xios {
@@ -20,5 +22,5 @@
       : CObjectTemplate<CAxis>()
       , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject(), areClientAttributesChecked_(false)
-      , isDistributed_(false)
+      , isDistributed_(false), hasBounds_(false)
       , transformationMap_(), global_zoom_begin(0), global_zoom_size(0)
    {
@@ -28,5 +30,5 @@
       : CObjectTemplate<CAxis>(id)
       , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject(), areClientAttributesChecked_(false)
-      , isDistributed_(false)
+      , isDistributed_(false), hasBounds_(false)
       , transformationMap_(), global_zoom_begin(0), global_zoom_size(0)
    {
@@ -99,22 +101,13 @@
       else this->ni.setValue(size);
 
-//      StdSize true_size = value.numElements();
-//      if (this->ni.getValue() != true_size)
-//         ERROR("CAxis::checkAttributes(void)",
-//               << "The array \'value\' of axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] has a different size that the one defined by the \'size\' attribute");
-
+      StdSize true_size = value.numElements();
+      if (this->ni.getValue() != true_size)
+         ERROR("CAxis::checkAttributes(void)",
+               << "The array \'value\' of axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] has a different size that the one defined by the \'size\' attribute");
 
       this->checkData();
+      this->checkZoom();
       this->checkMask();
-      this->checkZoom();
-
-      if (!bounds.isEmpty())
-      {
-        if (bounds.extent(0) != size || bounds.extent(1) != 2)
-            ERROR("CAxis::checkAttributes(void)",
-                  << "The bounds array of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be of dimension axis size x 2" << endl
-                  << "Axis size is " << size << endl
-                  << "Bounds size is "<< bounds.extent(0) << " x " << bounds.extent(1));
-      }
+      this->checkBounds();
    }
 
@@ -185,4 +178,19 @@
    }
 
+  void CAxis::checkBounds()
+  {
+    if (!bounds.isEmpty())
+    {
+      if (bounds.extent(0) != ni || bounds.extent(1) != 2)
+          ERROR("CAxis::checkAttributes(void)",
+                << "The bounds array of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be of dimension axis size x 2" << endl
+                << "Axis size is " << ni << endl
+                << "Bounds size is "<< bounds.extent(0) << " x " << bounds.extent(1));
+      hasBounds_ = true;
+    }
+    else hasBounds_ = false;
+  }
+
+
   bool CAxis::dispatchEvent(CEventServer& event)
    {
@@ -196,4 +204,16 @@
              return true;
              break;
+           case EVENT_ID_INDEX:
+            recvIndex(event);
+            return true;
+            break;
+          case EVENT_ID_DISTRIBUTED_VALUE:
+            recvDistributedValue(event);
+            return true;
+            break;
+          case EVENT_ID_NON_DISTRIBUTED_VALUE:
+            recvNonDistributedValue(event);
+            return true;
+            break;
            default :
              ERROR("bool CContext::dispatchEvent(CEventServer& event)",
@@ -227,8 +247,292 @@
      {
        sendServerAttribut(globalDim, orderPositionInGrid, distType);
+       sendValue();
      }
 
      this->isChecked = true;
    }
+
+  void CAxis::sendValue()
+  {
+     if (ni.getValue() == size.getValue())
+     {
+       sendNonDistributedValue();
+     }
+     else
+     {
+       computeConnectedServer();
+       sendDistributedValue();
+     }
+  }
+
+  void CAxis::computeConnectedServer()
+  {
+    CContext* context = CContext::getCurrent();
+    CContextClient* client = context->client;
+    int nbServer = client->serverSize;
+    int range, clientSize = client->clientSize;
+
+    CArray<size_t,1> globalIndexAxis(ni);
+    size_t ibegin = this->ibegin.getValue();
+    int zoom_end = global_zoom_begin+global_zoom_size-1;
+    std::vector<size_t> globalAxisZoom;
+    for (size_t idx = 0; idx < ni; ++idx)
+    {
+      size_t globalIndex = ibegin + idx;
+      globalIndexAxis(idx) = globalIndex;
+      if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) globalAxisZoom.push_back(globalIndex);
+    }
+
+    std::vector<int> nGlobDomain(1);
+    nGlobDomain[0] = size.getValue();
+
+    size_t globalSizeIndex = 1, indexBegin, indexEnd;
+    for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i];
+    indexBegin = 0;
+    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;
+
+    CServerDistributionDescription serverDescription(nGlobDomain);
+    serverDescription.computeServerGlobalIndexInRange(nbServer, std::make_pair<size_t,size_t>(indexBegin, indexEnd));
+    CClientServerMappingDistributed clientServerMap(serverDescription.getGlobalIndexRange(), client->intraComm);
+    clientServerMap.computeServerIndexMapping(globalIndexAxis);
+    const std::map<int, std::vector<size_t> >& globalIndexAxisOnServer = clientServerMap.getGlobalIndexOnServer();
+
+    std::map<int, std::vector<size_t> >::const_iterator it = globalIndexAxisOnServer.begin(),
+                                                       ite = globalIndexAxisOnServer.end();
+    std::vector<size_t>::const_iterator itbVec = (globalAxisZoom).begin(),
+                                        iteVec = (globalAxisZoom).end();
+    indSrv_.clear();
+    for (; it != ite; ++it)
+    {
+      int rank = it->first;
+      const std::vector<size_t>& globalIndexTmp = it->second;
+      int nb = globalIndexTmp.size();
+
+      for (int i = 0; i < nb; ++i)
+      {
+        if (std::binary_search(itbVec, iteVec, globalIndexTmp[i]))
+        {
+          indSrv_[rank].push_back(globalIndexTmp[i]);
+        }
+      }
+    }
+
+    connectedServerRank_.clear();
+    for (it = globalIndexAxisOnServer.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_);
+
+  }
+
+  void CAxis::sendNonDistributedValue()
+  {
+    CContext* context = CContext::getCurrent();
+    CContextClient* client = context->client;
+    CEventClient event(getType(),EVENT_ID_NON_DISTRIBUTED_VALUE);
+
+    int zoom_end = global_zoom_begin+global_zoom_size-1;
+    int nb =0;
+    for (size_t idx = 0; idx < ni; ++idx)
+    {
+      size_t globalIndex = ibegin + idx;
+      if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) ++nb;
+    }
+
+    CArray<double,1> val(nb);
+    nb = 0;
+    for (size_t idx = 0; idx < ni; ++idx)
+    {
+      size_t globalIndex = ibegin + idx;
+      if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end)
+      {
+        val(nb) = value(idx);
+        ++nb;
+      }
+    }
+
+    if (client->isServerLeader())
+    {
+      std::list<CMessage> msgs;
+
+      const std::list<int>& ranks = client->getRanksServerLeader();
+      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
+      {
+        // Use const int to ensure CMessage holds a copy of the value instead of just a reference
+        msgs.push_back(CMessage());
+        CMessage& msg = msgs.back();
+        msg << this->getId();
+        msg << val;
+        event.push(*itRank,1,msg);
+      }
+      client->sendEvent(event);
+    }
+    else client->sendEvent(event);
+  }
+
+  void CAxis::sendDistributedValue(void)
+  {
+    int ns, n, i, j, ind, nv, idx;
+    CContext* context = CContext::getCurrent();
+    CContextClient* client=context->client;
+
+    // send value for each connected server
+    CEventClient eventIndex(getType(), EVENT_ID_INDEX);
+    CEventClient eventVal(getType(), EVENT_ID_DISTRIBUTED_VALUE);
+
+    list<CMessage> list_msgsIndex, list_msgsVal;
+    list<CArray<int,1> > list_indi;
+    list<CArray<double,1> > list_val;
+    list<CArray<double,2> > list_bounds;
+
+    std::map<int, std::vector<size_t> >::const_iterator it, iteMap;
+    iteMap = indSrv_.end();
+    for (int k = 0; k < connectedServerRank_.size(); ++k)
+    {
+      int nbData = 0;
+      int rank = connectedServerRank_[k];
+      it = indSrv_.find(rank);
+      if (iteMap != it)
+        nbData = it->second.size();
+
+      list_indi.push_back(CArray<int,1>(nbData));
+      list_val.push_back(CArray<double,1>(nbData));
+
+      if (hasBounds_)
+      {
+        list_bounds.push_back(CArray<double,2>(2,nbData));
+      }
+
+      CArray<int,1>& indi = list_indi.back();
+      CArray<double,1>& val = list_val.back();
+
+      for (n = 0; n < nbData; ++n)
+      {
+        idx = static_cast<int>(it->second[n]);
+        ind = idx - ibegin;
+
+        val(n) = value(ind);
+        indi(n) = idx;
+
+        if (hasBounds_)
+        {
+          CArray<double,2>& boundsVal = list_bounds.back();
+          boundsVal(0, n) = bounds(0,n);
+          boundsVal(1, n) = bounds(1,n);
+        }
+      }
+
+      list_msgsIndex.push_back(CMessage());
+      list_msgsIndex.back() << this->getId() << list_indi.back();
+
+      list_msgsVal.push_back(CMessage());
+      list_msgsVal.back() << this->getId() << list_val.back();
+
+      if (hasBounds_)
+      {
+        list_msgsVal.back() << list_bounds.back();
+      }
+
+      eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back());
+      eventVal.push(rank, nbConnectedClients_[rank], list_msgsVal.back());
+    }
+
+    client->sendEvent(eventIndex);
+    client->sendEvent(eventVal);
+  }
+
+  void CAxis::recvIndex(CEventServer& event)
+  {
+    list<CEventServer::SSubEvent>::iterator it;
+    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it)
+    {
+      CBufferIn* buffer = it->buffer;
+      string domainId;
+      *buffer >> domainId;
+      get(domainId)->recvIndex(it->rank, *buffer);
+    }
+  }
+
+  void CAxis::recvIndex(int rank, CBufferIn& buffer)
+  {
+    buffer >> indiSrv_[rank];
+  }
+
+  void CAxis::recvDistributedValue(CEventServer& event)
+  {
+    list<CEventServer::SSubEvent>::iterator it;
+    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it)
+    {
+      CBufferIn* buffer = it->buffer;
+      string domainId;
+      *buffer >> domainId;
+      get(domainId)->recvDistributedValue(it->rank, *buffer);
+    }
+  }
+
+  void CAxis::recvDistributedValue(int rank, CBufferIn& buffer)
+  {
+    CArray<int,1> &indi = indiSrv_[rank];
+    CArray<double,1> val;
+    CArray<double,2> boundsVal;
+
+    buffer >> val;
+    if (hasBounds_) buffer >> boundsVal;
+
+    int i, j, ind_srv;
+    for (int ind = 0; ind < indi.numElements(); ++ind)
+    {
+      i = indi(ind);
+      ind_srv = i - zoom_begin_srv;
+      value_srv(ind_srv) = val(ind);
+      if (hasBounds_)
+      {
+        bound_srv(0,ind_srv) = boundsVal(0, ind);
+        bound_srv(1,ind_srv) = boundsVal(1, ind);
+      }
+    }
+  }
+
+   void CAxis::recvNonDistributedValue(CEventServer& event)
+  {
+    list<CEventServer::SSubEvent>::iterator it;
+    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it)
+    {
+      CBufferIn* buffer = it->buffer;
+      string domainId;
+      *buffer >> domainId;
+      get(domainId)->recvNonDistributedValue(it->rank, *buffer);
+    }
+  }
+
+  void CAxis::recvNonDistributedValue(int rank, CBufferIn& buffer)
+  {
+    CArray<double,1> val;
+    buffer >> val;
+
+    for (int ind = 0; ind < val.numElements(); ++ind)
+    {
+      value_srv(ind) = val(ind);
+      if (hasBounds_)
+      {
+        bound_srv(0,ind) = bounds(0,ind);
+        bound_srv(1,ind) = bounds(1,ind);
+      }
+    }
+  }
 
   void CAxis::sendServerAttribut(const std::vector<int>& globalDim, int orderPositionInGrid,
@@ -263,5 +567,5 @@
         msg << this->getId();
         msg << ni << begin << end;
-        msg<<global_zoom_begin<<global_zoom_size;
+        msg << global_zoom_begin << global_zoom_size;
 
         event.push(*itRank,1,msg);
@@ -304,4 +608,6 @@
       zoom_size_srv  = zoom_end_srv - zoom_begin_srv + 1;
     }
+    value_srv.resize(zoom_size_srv);
+    bound_srv.resize(2,zoom_size_srv);
   }
 
Index: XIOS/trunk/src/node/axis.hpp
===================================================================
--- XIOS/trunk/src/node/axis.hpp	(revision 632)
+++ XIOS/trunk/src/node/axis.hpp	(revision 633)
@@ -39,5 +39,8 @@
          enum EEventId
          {
-           EVENT_ID_SERVER_ATTRIBUT
+           EVENT_ID_SERVER_ATTRIBUT,
+           EVENT_ID_INDEX,
+           EVENT_ID_DISTRIBUTED_VALUE,
+           EVENT_ID_NON_DISTRIBUTED_VALUE
          } ;
 
@@ -102,12 +105,25 @@
         int ni_srv, begin_srv, end_srv;
         int global_zoom_begin, global_zoom_size;  // The real global zoom begin and zoom size after axis is transformed (zoomed)
+        CArray<double,1> value_srv;
+        CArray<double,2> bound_srv;
       private :
          void checkData();
          void checkMask();
          void checkZoom();
+         void checkBounds();
          void checkTransformations();
          void computeServerIndex(const std::vector<int>& globalDim, int orderPositionInGrid,
                                  CServerDistributionDescription::ServerDistributionType disType);
+         void sendValue();
+         void computeConnectedServer(void);
+         void sendDistributedValue();
+         void sendNonDistributedValue();
 
+         static void recvIndex(CEventServer& event);
+         static void recvDistributedValue(CEventServer& event);
+         static void recvNonDistributedValue(CEventServer& event);
+         void recvIndex(int rank, CBufferIn& buffer);
+         void recvDistributedValue(int rank, CBufferIn& buffer);
+         void recvNonDistributedValue(int rank, CBufferIn& buffer);
 
          void setTransformations(const TransMapTypes&);
@@ -118,5 +134,9 @@
          TransMapTypes transformationMap_;
          bool isDistributed_;
-
+         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_;
+         std::map<int, CArray<int,1> > indiSrv_;
+         bool hasBounds_;
          DECLARE_REF_FUNC(Axis,axis)
    }; // class CAxis
Index: XIOS/trunk/src/node/domain.cpp
===================================================================
--- XIOS/trunk/src/node/domain.cpp	(revision 632)
+++ XIOS/trunk/src/node/domain.cpp	(revision 633)
@@ -563,19 +563,5 @@
       zoom_jend_client = jend_client < global_zoom_jend ? jend_client : global_zoom_jend ;
       zoom_nj_client=zoom_jend_client-zoom_jbegin_client+1 ;
-      if (zoom_nj_client<0) zoom_nj_client=0 ;
-
-//      int zoom_iend=zoom_ibegin+zoom_ni-1 ;
-//      zoom_ibegin_client = ibegin_client > zoom_ibegin ? ibegin_client : zoom_ibegin ;
-//      zoom_iend_client = iend_client < zoom_iend ? iend_client : zoom_iend ;
-//      zoom_ni_client=zoom_iend_client-zoom_ibegin_client+1 ;
-//      if (zoom_ni_client<0) zoom_ni_client=0 ;
-//
-//
-//      int zoom_jend=zoom_jbegin+zoom_nj-1 ;
-//      zoom_jbegin_client = jbegin_client > zoom_jbegin ? jbegin_client : zoom_jbegin ;
-//      zoom_jend_client = jend_client < zoom_jend ? jend_client : zoom_jend ;
-//      zoom_nj_client=zoom_jend_client-zoom_jbegin_client+1 ;
-//      if (zoom_nj_client<0) zoom_nj_client=0 ;
-
+      if (zoom_nj_client<0) zoom_nj_client=0;
    }
 
@@ -615,5 +601,4 @@
 
       this->checkDomain();
-//      this->checkZoom();
       this->checkBounds();
       this->checkArea();
@@ -624,6 +609,4 @@
          this->checkDomainData();
          this->checkCompression();
-//         this->completeLonLatClient();
-//         this->computeConnectedServer() ;
       }
       else
Index: XIOS/trunk/src/output/nc4_data_output.cpp
===================================================================
--- XIOS/trunk/src/output/nc4_data_output.cpp	(revision 632)
+++ XIOS/trunk/src/output/nc4_data_output.cpp	(revision 633)
@@ -603,9 +603,10 @@
         int zoom_size_srv  = axis->zoom_size_srv;
         int zoom_begin_srv = axis->zoom_begin_srv;
-        StdSize zoom_size  = (MULTI_FILE == SuperClass::type) ? zoom_size_srv
+        int zoom_size  = (MULTI_FILE == SuperClass::type) ? zoom_size_srv
                                                               : axis->global_zoom_size;
-        StdSize zoom_begin = (MULTI_FILE == SuperClass::type) ? zoom_begin_srv
+        int zoom_begin = (MULTI_FILE == SuperClass::type) ? zoom_begin_srv
                                                               : axis->global_zoom_begin;
 
+        if ((0 == zoom_size_srv) && (MULTI_FILE == SuperClass::type)) return;
 
         std::vector<StdString> dims;
@@ -615,55 +616,78 @@
           SuperClassWriter::addDimension(axisid, zoom_size);
           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:
+            {
+              CArray<double,1> axis_value(zoom_size_srv);
+              for (int i = 0; i < zoom_size_srv; i++) axis_value(i) = axis->value_srv(i);
+              SuperClassWriter::writeData(axis_value, axisid, isCollective, 0);
+
+              if (!axis->bounds.isEmpty())
+              {
+                CArray<double,2> axisBounds(2, zoom_size_srv);
+                for (int i = 0; i < zoom_size_srv; i++)
+                {
+                  axisBounds(0, i) = axis->bound_srv(i, 0);
+                  axisBounds(1, i) = axis->bound_srv(i, 1);
+                }
+                SuperClassWriter::writeData(axisBounds, axisBoundsId, isCollective, 0);
+              }
+
+              SuperClassWriter::definition_start();
+
+              break;
+            }
             case ONE_FILE:
             {
-              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";
+              CArray<double,1> axis_value(zoom_size_srv);
+              axis_value = axis->value_srv;
+
+              std::vector<StdSize> start(1) ;
+              std::vector<StdSize> count(1) ;
+              start[0] = zoom_begin_srv-axis->global_zoom_begin;
+              count[0] = zoom_size_srv;
+              SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count);
+
               if (!axis->bounds.isEmpty())
               {
-                dims.push_back("axis_nbounds");
-                SuperClassWriter::addVariable(axisBoundsId, NC_FLOAT, dims);
-                SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid);
-              }
-
-              SuperClassWriter::definition_end();
-
-              CArray<double,1> axis_value(zoom_size);
-              for (int i = 0; i < zoom_size_srv; i++) axis_value(i) = axis->value(i + zoom_begin_srv);
-              SuperClassWriter::writeData(axis_value, axisid, isCollective, 0);
-
-              if (!axis->bounds.isEmpty())
-              {
-                CArray<double,2> axisBounds(2, zoom_size);
-                for (int i = 0; i < zoom_size_srv; i++)
+                CArray<double,2> axisBounds(2, zoom_size_srv);
+                for (int i = 0; i < zoom_size_srv; ++i)
                 {
-                  axisBounds(0, i) = axis->bounds(i + zoom_begin_srv, 0);
-                  axisBounds(1, i) = axis->bounds(i + zoom_begin_srv, 1);
+                  axisBounds(0, i+zoom_begin_srv) = axis->bound_srv(i, 0);
+                  axisBounds(1, i+zoom_begin_srv) = axis->bound_srv(i, 1);
                 }
-                SuperClassWriter::writeData(axisBounds, axisBoundsId, isCollective, 0);
+                SuperClassWriter::writeData(axisBounds, axisBoundsId, isCollective, 0, &start, &count);
               }
 
@@ -940,205 +964,4 @@
       }
 
-
-//      void CNc4DataOutput::writeField_(CField* field)
-//      {
-//         CContext* context = CContext::getCurrent() ;
-//         CContextServer* server=context->server ;
-//
-//         std::vector<StdString> dims, coodinates;
-//         CGrid* grid = field->grid;
-//         CDomain* domain = grid->domain;
-//
-//         if (domain->isEmpty())
-//           if (SuperClass::type==MULTI_FILE) return ;
-//
-//         StdString timeid    = StdString("time_counter");
-//         StdString domid     = (!domain->name.isEmpty())
-//                             ? domain->name.getValue() : domain->getId();
-//         StdString appendDomid  = (singleDomain) ? "" : "_"+domid ;
-//
-////         bool isCurvilinear = domain->isCurvilinear ;
-////         bool isCurvilinear = (domain->type == CDomain::type_attr::curvilinear) ;
-//
-//         StdString dimXid,dimYid ;
-//
-//         switch (domain->type)
-//         {
-//           case CDomain::type_attr::curvilinear :
-//             dimXid     = StdString("x").append(appendDomid);
-//             dimYid     = StdString("y").append(appendDomid);
-//             break ;
-//           case CDomain::type_attr::regular :
-//             dimXid     = StdString("lon").append(appendDomid);
-//             dimYid     = StdString("lat").append(appendDomid);
-//             break ;
-//           case CDomain::type_attr::unstructured :
-//             dimXid     = StdString("cell").append(appendDomid);
-//             break ;
-//        }
-//
-///*
-//         StdString lonid_loc = (server->intraCommSize > 1)
-//                             ? StdString("lon").append(appendDomid).append("_local")
-//                             : lonid;
-//         StdString latid_loc = (server->intraCommSize > 1)
-//                             ? StdString("lat").append(appendDomid).append("_local")
-//                             : latid;
-//*/
-//         StdString fieldid   = (!field->name.isEmpty())
-//                             ? field->name.getValue() : field->getBaseFieldReference()->getId();
-//
-////         unsigned int ssize = domain->zoom_ni_loc.getValue() * domain->zoom_nj_loc.getValue();
-////         bool isCurvilinear = (domain->lonvalue.getValue()->size() == ssize);
-////          bool isCurvilinear = domain->isCurvilinear ;
-//
-//         nc_type type ;
-//         if (field->prec.isEmpty()) type =  NC_FLOAT ;
-//         else
-//         {
-//           if (field->prec==2) type = NC_SHORT ;
-//           else if (field->prec==4)  type =  NC_FLOAT ;
-//           else if (field->prec==8)   type =  NC_DOUBLE ;
-//         }
-//
-//         bool wtime   = !(!field->operation.isEmpty() && field->foperation->timeType() == func::CFunctor::once);
-//
-//         if (wtime)
-//         {
-//
-//            //StdOStringStream oss;
-//           // oss << "time_" << field->operation.getValue()
-//           //     << "_" << field->getRelFile()->output_freq.getValue();
-//          //oss
-//            if (field->foperation->timeType() == func::CFunctor::instant) coodinates.push_back(string("time_instant"));
-//            else if (field->foperation->timeType() == func::CFunctor::centered) coodinates.push_back(string("time_centered"));
-//            dims.push_back(timeid);
-//         }
-//
-//         std::vector<StdString> axisList = grid->getAxisList();
-//         if (!axisList.empty())
-//         {
-//           std::vector<StdString>::const_iterator itAxis = axisList.begin(), iteAxis = axisList.end();
-//           for (; itAxis != iteAxis; ++itAxis)
-//           {
-//             CAxis* axis = CAxis::get(*itAxis);
-//             StdString axisid = (!axis->name.isEmpty())
-//                                ? axis->name.getValue() : axis->getId();
-//
-//             dims.push_back(axisid);
-//             coodinates.push_back(axisid);
-//           }
-//         }
-//
-//         switch (domain->type)
-//         {
-//           case CDomain::type_attr::curvilinear :
-//             coodinates.push_back(StdString("nav_lon").append(appendDomid));
-//             coodinates.push_back(StdString("nav_lat").append(appendDomid));
-//             break;
-//           case CDomain::type_attr::regular :
-//           case CDomain::type_attr::unstructured :
-//            coodinates.push_back(StdString("lon").append(appendDomid));
-//            coodinates.push_back(StdString("lat").append(appendDomid));
-//             break;
-//         }
-//
-//         if ( domain->type == CDomain::type_attr::curvilinear || domain->type == CDomain::type_attr::regular)dims.push_back(dimYid);
-//         dims.push_back(dimXid);
-//
-//         try
-//         {
-//           SuperClassWriter::addVariable(fieldid, type, dims);
-//
-//           if (!field->standard_name.isEmpty())
-//              SuperClassWriter::addAttribute
-//                 ("standard_name",  field->standard_name.getValue(), &fieldid);
-//
-//           if (!field->long_name.isEmpty())
-//              SuperClassWriter::addAttribute
-//                 ("long_name", field->long_name.getValue(), &fieldid);
-//
-//           if (!field->unit.isEmpty())
-//              SuperClassWriter::addAttribute
-//                 ("units", field->unit.getValue(), &fieldid);
-//
-//            if (!field->valid_min.isEmpty())
-//              SuperClassWriter::addAttribute
-//                 ("valid_min", field->valid_min.getValue(), &fieldid);
-//
-//           if (!field->valid_max.isEmpty())
-//              SuperClassWriter::addAttribute
-//                 ("valid_max", field->valid_max.getValue(), &fieldid);
-//
-//            if (!field->scale_factor.isEmpty())
-//              SuperClassWriter::addAttribute
-//                 ("scale_factor", field->scale_factor.getValue(), &fieldid);
-//
-//             if (!field->add_offset.isEmpty())
-//              SuperClassWriter::addAttribute
-//                 ("add_offset", field->add_offset.getValue(), &fieldid);
-//
-//           SuperClassWriter::addAttribute
-//                 ("online_operation", field->operation.getValue(), &fieldid);
-//
-//          // write child variables as attributes
-//
-//
-//           vector<CVariable*> listVars = field->getAllVariables() ;
-//           for (vector<CVariable*>::iterator it = listVars.begin() ;it != listVars.end(); it++) writeAttribute_(*it, fieldid) ;
-//
-//
-//           if (wtime)
-//           {
-//              CDuration duration = field->freq_op.getValue();
-//              duration.solveTimeStep(*(context->calendar));
-//              SuperClassWriter::addAttribute("interval_operation", duration.toStringUDUnits(), &fieldid);
-//
-//              duration = field->getRelFile()->output_freq.getValue();
-//              duration.solveTimeStep(*(context->calendar));
-//              SuperClassWriter::addAttribute("interval_write", duration.toStringUDUnits(), &fieldid);
-//           }
-//
-//           if (!field->default_value.isEmpty())
-//           {
-//              double default_value = field->default_value.getValue();
-//              float fdefault_value = (float)default_value;
-//              if (type == NC_DOUBLE)
-//                 SuperClassWriter::setDefaultValue(fieldid, &default_value);
-//              else
-//                 SuperClassWriter::setDefaultValue(fieldid, &fdefault_value);
-//           }
-//           else
-//              SuperClassWriter::setDefaultValue(fieldid, (double*)NULL);
-//
-//           {  // Ecriture des coordonnÃ©es
-//
-//              StdString coordstr; //boost::algorithm::join(coodinates, " ")
-//              std::vector<StdString>::iterator
-//                 itc = coodinates.begin(), endc = coodinates.end();
-//
-//              for (; itc!= endc; itc++)
-//              {
-//                 StdString & coord = *itc;
-//                 if (itc+1 != endc)
-//                       coordstr.append(coord).append(" ");
-//                 else  coordstr.append(coord);
-//              }
-//
-//              SuperClassWriter::addAttribute("coordinates", coordstr, &fieldid);
-//
-//           }
-//         }
-//         catch (CNetCdfException& e)
-//         {
-//           StdString msg("On writing field : ");
-//           msg.append(fieldid); msg.append("\n");
-//           msg.append("In the context : ");
-//           msg.append(context->getId()); msg.append("\n");
-//           msg.append(e.what());
-//           ERROR("CNc4DataOutput::writeField_(CField* field)", << msg);
-//         }
-//      }
-
       //--------------------------------------------------------------
 
@@ -1422,185 +1245,4 @@
       }
 
-//      //---------------------------------------------------------------
-//
-//      void CNc4DataOutput::writeFieldData_ (CField*  field)
-//      {
-//         CContext* context = CContext::getCurrent() ;
-////          if (field->getRelFile()->isSyncTime()) SuperClassWriter::sync() ;
-//         CContextServer* server=context->server ;
-//
-//         CGrid* grid = field->grid ;
-//         CDomain* domain = grid->domain ;
-//
-//         if(SuperClass::type==MULTI_FILE || !isCollective) if (domain->isEmpty()) return;
-//
-//
-//         StdString fieldid   = (!field->name.isEmpty())
-//                             ? field->name.getValue()
-//                             : field->getBaseFieldReference()->getId();
-//
-//         StdOStringStream oss;
-//         string timeAxisId ;
-//         if (field->foperation->timeType() == func::CFunctor::instant)  timeAxisId="time_instant" ;
-//         else if (field->foperation->timeType() == func::CFunctor::centered)  timeAxisId="time_centered" ;
-//
-//         StdString timeBoundId("time_counter_bounds");
-//
-//         StdString timeAxisBoundId;
-//         if (field->foperation->timeType() == func::CFunctor::instant)  timeAxisBoundId="time_instant_bounds" ;
-//         else if (field->foperation->timeType() == func::CFunctor::centered)  timeAxisBoundId="time_centered_bounds" ;
-//
-//         CArray<double,1> time_data(1) ;
-//         CArray<double,1> time_counter(1) ;
-//         CArray<double,1> time_counter_bound(2);
-//         CArray<double,1> time_data_bound(2);
-//
-//        bool wtime   = !(!field->operation.isEmpty() && (field->foperation->timeType() == func::CFunctor::once));
-//
-//        if (wtime)
-//        {
-//          time_counter(0)= (Time(*field->last_Write_srv) + Time(*field->lastlast_Write_srv)) / 2;
-//          if (field->foperation->timeType() == func::CFunctor::instant)
-//            time_data(0) = Time(*field->last_Write_srv);
-//          else if (field->foperation->timeType() == func::CFunctor::centered) time_data(0) = time_counter(0);
-//
-//          time_counter_bound(0) = Time(*field->lastlast_Write_srv);
-//          time_counter_bound(1) = Time(*field->last_Write_srv);
-//          if (field->foperation->timeType() == func::CFunctor::instant)
-//            time_data_bound(0) = time_data_bound(1) = Time(*field->last_Write_srv);
-//          else if (field->foperation->timeType() == func::CFunctor::centered)
-//          {
-//            time_data_bound(0) = time_counter_bound(0);
-//            time_data_bound(1) = time_counter_bound(1);
-//          }
-//         }
-//
-//         bool isRoot ;
-//         if (server->intraCommRank==0) isRoot=true ;
-//         else isRoot=false ;
-//
-//         if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty())
-//         {
-//           double scaleFactor=1. ;
-//           double addOffset=0. ;
-//           if (!field->scale_factor.isEmpty()) scaleFactor=field->scale_factor ;
-//           if (!field->add_offset.isEmpty()) addOffset=field->add_offset ;
-//           field->scaleFactorAddOffset(scaleFactor,addOffset) ;
-//         }
-//
-//         try
-//         {
-//           if (grid->hasAxis()) // 3D
-//           {
-//              CAxis* axis = grid->axis ;
-//              CArray<double,3> field_data3D(domain->zoom_ni_srv,domain->zoom_nj_srv,axis->zoom_size) ;
-//              if (!field->default_value.isEmpty()) field_data3D = field->default_value ;
-//
-//              field->outputField(field_data3D);
-//
-//              if (!field->prec.isEmpty() && field->prec==2) field_data3D=round(field_data3D) ;
-//
-//              switch (SuperClass::type)
-//             {
-//                case (MULTI_FILE) :
-//                {
-//                   SuperClassWriter::writeData(field_data3D, fieldid, isCollective, field->getNStep()-1);
-//                   if (wtime)
-//                   {
-//                     SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep()-1);
-//                     SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep()-1);
-//                     SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1);
-//                     SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1);
-//                   }
-//                   break ;
-//                }
-//                case (ONE_FILE) :
-//                {
-//                   std::vector<StdSize> start(3) ;
-//                   std::vector<StdSize> count(3) ;
-//                   if (domain->isEmpty())
-//                   {
-//                     start[0]=0 ; start[1]=0 ; start[2]=0 ;
-//                     count[0]=0 ; count[1]=0 ; start[2]=0 ;
-//                   }
-//                   else
-//                   {
-//  //                 start[2]=domain->zoom_ibegin_loc.getValue()-domain->zoom_ibegin.getValue() ; start [1]=domain->zoom_jbegin_loc.getValue()-domain->zoom_jbegin.getValue() ; start[0]=0 ;
-//                     start[2]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; start [1]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ; start[0]=0 ;
-//                     count[2]=domain->zoom_ni_srv ; count[1]=domain->zoom_nj_srv ; count[0] = axis->zoom_size.getValue();
-//                   }
-//                   SuperClassWriter::writeData(field_data3D, fieldid, isCollective, field->getNStep()-1,&start,&count );
-//                   if (wtime)
-//                   {
-//                     SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()-1,isRoot );
-//                     SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep()-1,isRoot );
-//                     SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1, isRoot );
-//                     SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1, isRoot);
-//                   }
-//                   break;
-//                }
-//              }
-//
-//           }
-//           else // 2D
-//           {
-//              CArray<double,2> field_data2D(domain->zoom_ni_srv,domain->zoom_nj_srv) ;
-//              if (!field->default_value.isEmpty()) field_data2D = field->default_value ;
-//              field->outputField(field_data2D);
-//              if (!field->prec.isEmpty() && field->prec==2) field_data2D=round(field_data2D) ;
-//              switch (SuperClass::type)
-//              {
-//                case (MULTI_FILE) :
-//                {
-//                  SuperClassWriter::writeData(field_data2D, fieldid, isCollective, field->getNStep()-1);
-//                  if (wtime)
-//                  {
-//                    SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep()-1);
-//                    SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep()-1);
-//                    SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1);
-//                    SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1);
-//                  }
-//                  break;
-//                }
-//                case (ONE_FILE) :
-//                {
-//                   std::vector<StdSize> start(2) ;
-//                   std::vector<StdSize> count(2) ;
-//                   if (domain->isEmpty())
-//                   {
-//                     start[0]=0 ; start[1]=0 ;
-//                     count[0]=0 ; count[1]=0 ;
-//                   }
-//                   else
-//                   {
-//                     start[1]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; start[0]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ;
-//                     count[1]=domain->zoom_ni_srv ; count[0]=domain->zoom_nj_srv ;
-//                   }
-//
-//                   SuperClassWriter::writeData(field_data2D, fieldid, isCollective, field->getNStep()-1,&start,&count);
-//                   if (wtime)
-//                   {
-//                     SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()-1,isRoot);
-//                     SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep()-1,isRoot);
-//                     SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1, isRoot);
-//                     SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1, isRoot);
-//                   }
-//                   break;
-//
-//                }
-//              }
-//           }
-//         }
-//         catch (CNetCdfException& e)
-//         {
-//           StdString msg("On writing field data: ");
-//           msg.append(fieldid); msg.append("\n");
-//           msg.append("In the context : ");
-//           msg.append(context->getId()); msg.append("\n");
-//           msg.append(e.what());
-//           ERROR("CNc4DataOutput::writeFieldData_ (CField*  field)", << msg);
-//         }
-//      }
-
       //---------------------------------------------------------------
 
Index: XIOS/trunk/src/test/test_new_features.f90
===================================================================
--- XIOS/trunk/src/test/test_new_features.f90	(revision 632)
+++ XIOS/trunk/src/test/test_new_features.f90	(revision 633)
@@ -17,5 +17,5 @@
   INTEGER,PARAMETER :: ni_glo=5
   INTEGER,PARAMETER :: nj_glo=5
-  INTEGER,PARAMETER :: llm=10
+  INTEGER,PARAMETER :: llm=5
   INTEGER,PARAMETER :: llmInterPolated=5
   DOUBLE PRECISION  :: lval(llm)=1, tsTemp, lvalInterPolated(llmInterPolated)=1
