Index: XIOS/trunk/src/input/inetcdf4.cpp
===================================================================
--- XIOS/trunk/src/input/inetcdf4.cpp	(revision 684)
+++ 	(revision )
@@ -1,814 +1,0 @@
-#include "inetcdf4.hpp"
-#include "netCdfInterface.hpp"
-
-#include <boost/algorithm/string.hpp>
-
-namespace xios
-{
-  CINetCDF4::CINetCDF4(const StdString& filename, const MPI_Comm* comm /*= NULL*/, bool multifile /*= true*/)
-    : mpi(comm != NULL && !multifile)
-  {
-    if (comm != NULL)
-    {
-      if (!multifile) CNetCdfInterface::openPar(filename, NC_NOWRITE, *comm, MPI_INFO_NULL, this->ncidp);
-      else CNetCdfInterface::open(filename, NC_NOWRITE, this->ncidp);
-    }
-      else CNetCdfInterface::open(filename, NC_NOWRITE, this->ncidp);
-  }
-
-  CINetCDF4::~CINetCDF4(void)
-  { /* Nothing to do */ }
-
-  ///--------------------------------------------------------------
-
-  void CINetCDF4::CheckError(int status)
-  {
-    if (status != NC_NOERR)
-    {
-      StdString errormsg(nc_strerror(status)); // fuite mÃ©moire ici ?
-      ERROR("CINetCDF4::CheckError(int status)",
-            << "[ status = " << status << " ] " << errormsg);
-    }
-  }
-
-  //---------------------------------------------------------------
-
-  void CINetCDF4::close(void)
-  {
-    CheckError(nc_close(this->ncidp));
-  }
-
-  //---------------------------------------------------------------
-
-  int CINetCDF4::getGroup(const CVarPath* const path)
-  {
-    int retvalue = this->ncidp;
-    if (path == NULL) return retvalue;
-    CVarPath::const_iterator it = path->begin(), end = path->end();
-
-    for (; it != end; it++)
-    {
-      const StdString& groupid = *it;
-      CheckError(nc_inq_ncid(retvalue, const_cast<char*>(groupid.c_str()), &retvalue));
-    }
-
-    return retvalue;
-  }
-
-  int CINetCDF4::getVariable(const StdString& varname,
-                             const CVarPath* const path)
-  {
-    int varid = 0;
-    int grpid = this->getGroup(path);
-    CheckError(nc_inq_varid(grpid, varname.c_str(), &varid));
-    return varid;
-  }
-
-  int CINetCDF4::getDimension(const StdString& dimname,
-                              const CVarPath* const path)
-  {
-    int dimid = 0;
-    int grpid = this->getGroup(path);
-    CheckError(nc_inq_dimid(grpid, dimname.c_str(), &dimid));
-    return dimid;
-  }
-
-  std::pair<nc_type, StdSize> CINetCDF4::getAttribute(const StdString& attname,
-                                                      const StdString* const var,
-                                                      const CVarPath* const path)
-  {
-    std::pair<nc_type, StdSize> retvalue;
-    int grpid = this->getGroup(path);
-    int varid = (var != NULL) ? this->getVariable(*var, path) : NC_GLOBAL;
-    CheckError(nc_inq_att(grpid, varid, attname.c_str(),
-                          &retvalue.first, &retvalue.second));
-    return retvalue;
-  }
-
-  int CINetCDF4::getUnlimitedDimension(const CVarPath* const path)
-  {
-    int dimid = 0;
-    int grpid = this->getGroup(path);
-    CheckError(nc_inq_unlimdim(grpid, &dimid));
-    return dimid;
-  }
-
-  StdString CINetCDF4::getUnlimitedDimensionName(const CVarPath* const path)
-  {
-    char full_name_in[NC_MAX_NAME +1];
-    int grpid = this->getGroup(path);
-    int dimid = this->getUnlimitedDimension(path);
-    CheckError(nc_inq_dimname(grpid, dimid, full_name_in));
-
-    StdString dimname(full_name_in);
-    return dimname;
-  }
-
-  //---------------------------------------------------------------
-  StdSize CINetCDF4::getNbVertex(const StdString& name,
-                                 const CVarPath* const path)
-  {
-
-    if (this->isRectilinear(name, path) ||
-       this->isCurvilinear(name, path))
-    {
-      if (this->is3Dim(name, path)) return 8;
-      else return 4;
-    }
-    if (this->isUnstructured(name, path))
-    {
-      StdString bound = this->getBoundsId
-            (this->getCoordinatesIdList(name, path).back(), path);
-      StdString dim = this->getDimensionsList(&bound, path).back();
-      return (this->getDimensions(&bound, path)[dim]);
-    }
-    return size_t(-1);
-  }
-
-  //---------------------------------------------------------------
-
-  std::list<StdString> CINetCDF4::getGroups(const CVarPath* const path)
-  {
-    StdSize strlen = 0;
-    char full_name_in[NC_MAX_NAME +1];
-    int nbgroup = 0, *groupid = NULL;
-    int grpid = this->getGroup(path);
-    std::list<StdString> retvalue;
-
-    CheckError(nc_inq_grps(grpid, &nbgroup, NULL));
-    groupid = new int[nbgroup]();
-    CheckError(nc_inq_grps(grpid, NULL, groupid));
-
-    for (int i = 0; i < nbgroup; i++)
-    {
-      CheckError(nc_inq_grpname_full(groupid[i], &strlen, full_name_in));
-      StdString groupname(full_name_in, strlen);
-      retvalue.push_back(groupname);
-    }
-
-    delete [] groupid;
-    return retvalue;
-  }
-
-  std::list<StdString> CINetCDF4::getVariables(const CVarPath* const path)
-  {
-    char full_name_in[NC_MAX_NAME +1];
-    int nbvar = 0, *varid = NULL;
-    int grpid = this->getGroup(path);
-    std::list<StdString> retvalue;
-
-    CheckError(nc_inq_varids(grpid, &nbvar, NULL));
-    varid = new int[nbvar]();
-    CheckError(nc_inq_varids(grpid, NULL, varid));
-
-    for (int i = 0; i < nbvar; i++)
-    {
-      CheckError(nc_inq_varname(grpid, varid[i], full_name_in));
-      StdString varname(full_name_in);
-      retvalue.push_back(varname);
-    }
-
-    delete [] varid;
-    return retvalue;
-  }
-
-  StdSize CINetCDF4::getNbOfTimestep(const CVarPath* const path)
-  {
-    return (this->getDimensions(NULL, path)[this->getUnlimitedDimensionName(path)]);
-  }
-
-  std::set<StdString> CINetCDF4::getBoundVariables(const CVarPath* const path)
-  {
-    std::set<StdString> retvalue;
-    std::list<StdString> variables = this->getVariables(path);
-    std::list<StdString>::const_iterator it = variables.begin(), end = variables.end();
-    for (; it != end; it++)
-    {
-      const StdString& var = *it;
-      if (this->hasBounds(var, path))
-        retvalue.insert(retvalue.end(), this->getBoundsId(var, path));
-    }
-    return retvalue;
-  }
-
-  std::set<StdString> CINetCDF4::getCoordVariables(const CVarPath* const path)
-  {
-    std::set<StdString> retvalue;
-    std::list<StdString> variables = this->getVariables(path);
-    std::list<StdString>::const_iterator it = variables.begin(), end = variables.end();
-    for (; it != end; it++)
-    {
-      const StdString& var = *it;
-      std::list<StdString> coords = this->getCoordinatesIdList(var, path);
-      std::list<StdString>::const_iterator it = coords.begin(), end = coords.end();
-      for (; it != end; it++)
-      {
-        const StdString& coord = *it;
-        if (this->hasVariable(coord, path))
-          retvalue.insert(retvalue.end(), coord);
-      }
-    }
-    return retvalue;
-  }
-
-  std::list<StdString> CINetCDF4::getDimensionsList(const StdString* const var, const CVarPath* const path)
-  {
-    char full_name_in[NC_MAX_NAME +1];
-    int nbdim = 0, *dimid = NULL;
-    int grpid = this->getGroup(path);
-    int varid = (var != NULL) ? this->getVariable(*var, path) : NC_GLOBAL;
-    std::list<StdString> retvalue;
-
-    if (var != NULL)
-    {
-      CheckError(nc_inq_varndims(grpid, varid, &nbdim));
-      dimid = new int[nbdim]();
-      CheckError(nc_inq_vardimid(grpid, varid, dimid));
-    }
-    else
-    {
-      CheckError(nc_inq_dimids(grpid, &nbdim, NULL, 1));
-      dimid = new int[nbdim]();
-      CheckError(nc_inq_dimids(grpid, NULL, dimid, 1));
-    }
-
-    for (int i = 0; i < nbdim; i++)
-    {
-      CheckError(nc_inq_dimname(grpid, dimid[i], full_name_in));
-      StdString dimname(full_name_in);
-      retvalue.push_back(dimname);
-    }
-    delete [] dimid;
-
-    return retvalue;
-  }
-
-  std::map<StdString, StdSize> CINetCDF4::getDimensions(const StdString* const var, const CVarPath* const path)
-  {
-    StdSize size = 0;
-    char full_name_in[NC_MAX_NAME + 1];
-    int nbdim = 0, *dimid = NULL;
-    int grpid = this->getGroup(path);
-    int varid = (var != NULL) ? this->getVariable(*var, path) : NC_GLOBAL;
-    std::map<StdString, StdSize> retvalue;
-
-    if (var != NULL)
-    {
-      CheckError(nc_inq_varndims(grpid, varid, &nbdim));
-      dimid = new int[nbdim]();
-      CheckError(nc_inq_vardimid(grpid, varid, dimid));
-    }
-    else
-    {
-      CheckError(nc_inq_dimids(grpid, &nbdim, NULL, 1));
-      dimid = new int[nbdim]();
-      CheckError(nc_inq_dimids(grpid, NULL, dimid, 1));
-    }
-
-    for (int i = 0; i < nbdim; i++)
-    {
-      CheckError(nc_inq_dimname(grpid, dimid[i], full_name_in));
-      CheckError(nc_inq_dimlen (grpid, dimid[i], &size));
-
-      StdString dimname(full_name_in);
-      retvalue.insert(retvalue.end(), std::make_pair(dimname, size));
-    }
-    delete [] dimid;
-
-    return retvalue;
-  }
-
-  std::list<StdString> CINetCDF4::getAttributes(const StdString* const var, const CVarPath* const path )
-  {
-    int nbatt = 0;
-    char full_name_in[NC_MAX_NAME +1];
-    std::list<StdString> retvalue;
-    int grpid = this->getGroup(path);
-    int varid = (var != NULL) ? this->getVariable(*var, path) : NC_GLOBAL;
-
-    if (var != NULL)
-      CheckError(nc_inq_varnatts(grpid, varid, &nbatt));
-    else
-      CheckError(nc_inq_natts(grpid, &nbatt));
-
-    for (int i = 0; i < nbatt; i++)
-    {
-      CheckError(nc_inq_attname(grpid, varid, i, full_name_in));
-      StdString attname(full_name_in);
-      retvalue.push_back(attname);
-    }
-    return retvalue;
-  }
-
-  int CINetCDF4::getAttributeId(const StdString& name,
-                                const StdString* const var,
-                                const CVarPath* const path)
-  {
-    int retvalue = 0;
-    std::list<StdString> atts = this->getAttributes(var, path);
-    std::list<StdString>::const_iterator it = atts.begin(), end = atts.end();
-    for (; it != end; it++)
-    {
-      const StdString& attname = *it;
-      if (attname.compare(name) == 0)
-        return retvalue;
-      retvalue++;
-    }
-    return -1;
-  }
-
-  //---------------------------------------------------------------
-
-  bool CINetCDF4::hasMissingValue(const StdString& name,
-                                  const CVarPath* const path)
-  {
-    return (this->hasAttribute("missing_value", &name, path) ||
-          this->hasAttribute("_FillValue", &name, path));
-  }
-
-  bool CINetCDF4::hasAttribute(const StdString& name,
-                               const StdString* const var ,
-                               const CVarPath* const path)
-  {
-    std::list<StdString> atts = this->getAttributes(var, path);
-    std::list<StdString>::const_iterator it = atts.begin(), end = atts.end();
-    for (; it != end; it++)
-    {
-      const StdString& attname = *it;
-      if (attname.compare(name) == 0) return true;
-    }
-    return false;
-  }
-
-  bool CINetCDF4::hasVariable(const StdString& name,
-                              const CVarPath* const path)
-  {
-    std::list<StdString> variables = this->getVariables(path);
-    std::list<StdString>::const_iterator it = variables.begin(), end = variables.end();
-    for (; it != end; it++)
-    {
-      const StdString& varname = *it;
-      if (varname.compare(name) == 0) return true;
-    }
-    return false;
-  }
-
-  bool CINetCDF4::hasCoordinates(const StdString& name,
-                                 const CVarPath* const path)
-  {
-    return (this->hasAttribute("coordinates", &name, path));
-  }
-
-  bool CINetCDF4::hasBounds(const StdString& name,
-                            const CVarPath* const path)
-  {
-    return (this->hasAttribute("bounds", &name, path));
-  }
-
-  bool CINetCDF4::hasTemporalDim(const CVarPath* const path)
-  {
-    return (this->getUnlimitedDimension(path) != -1);
-  }
-
-  //---------------------------------------------------------------
-
-#define GET_ATTRIBUTE_VALUE(type, func_ext, type_enum)                              \
-  template <>                                                                       \
-  std::vector<type> CINetCDF4::getAttributeValue(const StdString& name,             \
-                                                 const StdString* const var,        \
-                                                 const CVarPath* const path)        \
-  {                                                                                 \
-    int grpid = this->getGroup(path);                                               \
-    int varid = (var != NULL) ? this->getVariable(*var, path) : NC_GLOBAL;          \
-    std::pair<nc_type , StdSize> attinfos = this->getAttribute(name, var, path);    \
-    std::vector<type> retvalue(attinfos.second);                                    \
-    if (attinfos.first != type_enum)                                                \
-      ERROR("CINetCDF4::getAttributeValue<double>(name, var, path",                 \
-            << "[ name : " << name                                                  \
-            << ", type requested :" << attinfos.first                               \
-            << ", type stored : " << type_enum << "]"                               \
-            << " Invalid type !");                                                  \
-    CheckError(nc_get_att_##func_ext(grpid, varid, name.c_str(), &(retvalue[0])));  \
-    return retvalue;                                                                \
-  }
-
-  GET_ATTRIBUTE_VALUE(double, double, NC_DOUBLE)
-  GET_ATTRIBUTE_VALUE(float,  float,  NC_FLOAT)
-  GET_ATTRIBUTE_VALUE(int,    int ,   NC_INT)
-  GET_ATTRIBUTE_VALUE(char,   text,   NC_CHAR)
-
-  template <>
-  StdString CINetCDF4::getAttributeValue(const StdString& name,
-                                         const StdString* const var,
-                                         const CVarPath* const path)
-  {
-    std::vector<char> chart = this->getAttributeValue<std::vector<char> >(name, var, path);
-    StdString retvalue(&(chart[0]), chart.size());
-    return retvalue;
-  }
-
-  template <>
-  int CINetCDF4::getMissingValue(const StdString& name,
-                                 const CVarPath* const path)
-  {
-    if (this->hasAttribute("missing_value", &name, path))
-      return (this->getAttributeValue<std::vector<int> >("missing_value", &name, path)[0]);
-    if (this->hasAttribute("_FillValue", &name, path))
-      return (this->getAttributeValue<std::vector<int> >("_FillValue", &name, path)[0]);
-    return 0;
-  }
-
-  template <>
-  double CINetCDF4::getMissingValue(const StdString& name,
-                                    const CVarPath* const path)
-  {
-    if (this->hasAttribute("missing_value", &name, path))
-      return (this->getAttributeValue<std::vector<double> >("missing_value", &name, path)[0]);
-    if (this->hasAttribute("_FillValue", &name, path))
-      return (this->getAttributeValue<std::vector<double> >("_FillValue", &name, path)[0]);
-    return 0;
-  }
-
-  template <>
-  float CINetCDF4::getMissingValue(const StdString& name,
-                                   const CVarPath* const path)
-  {
-    if (this->hasAttribute("missing_value", &name, path))
-      return (this->getAttributeValue<std::vector<float> >("missing_value", &name, path)[0]);
-    if (this->hasAttribute("_FillValue", &name, path))
-      return (this->getAttributeValue<std::vector<float> >("_FillValue", &name, path)[0]);
-    return 0;
-  }
-
-  //---------------------------------------------------------------
-
-  std::list<StdString> CINetCDF4::getCoordinatesIdList(const StdString& name, const CVarPath* const path)
-  {
-    std::list<StdString> retvalue;
-    StdString value = this->getCoordinatesId(name, path);
-
-    boost::split(retvalue, value, boost::is_any_of(" "));
-
-    std::list<StdString>::iterator it = retvalue.begin(), end = retvalue.end();
-    for (; it != end; it++)
-    {
-      StdString& coord = *it;
-      coord.assign(coord.data());
-    }
-    return retvalue;
-  }
-
-  StdString CINetCDF4::getCoordinatesId(const StdString& name, const CVarPath* const path)
-  {
-    StdString retvalue;
-    if (this->hasAttribute("coordinates", &name, path))
-    {
-      return (this->getAttributeValue<StdString>("coordinates", &name, path));
-    }
-    else
-    {
-      std::list<StdString> dims = this->getDimensionsList(&name, path);
-      std::list<StdString>::const_iterator it = dims.begin(), end = dims.end();
-      for (; it != end; it++)
-      {
-        const StdString& value = *it;
-        retvalue.append(value).push_back(' ');
-      }
-      retvalue.erase(retvalue.end() - 1) ;
-    }
-
-    return retvalue;
-  }
-
-  StdString CINetCDF4::getBoundsId(const StdString& name,
-                                   const CVarPath* const path)
-  {
-    StdString retvalue;
-    if (this->hasAttribute("bounds", &name, path))
-      return (this->getAttributeValue<StdString>("bounds", &name, path));
-    return retvalue;
-  }
-
-  //---------------------------------------------------------------
-
-  bool CINetCDF4::isBound(const StdString& name,
-                          const CVarPath* const path)
-  {
-    std::set<StdString> bounds = this->getBoundVariables(path);
-    return (bounds.find(name) != bounds.end());
-  }
-
-  bool CINetCDF4::isCoordinate(const StdString& name,
-                               const CVarPath* const path)
-  {
-    std::set<StdString> coords = this->getCoordVariables(path);
-    return (coords.find(name) != coords.end());
-  }
-
-  bool CINetCDF4::isRectilinear(const StdString& name, const CVarPath* const path)
-  {
-    std::list<StdString> coords = this->getCoordinatesIdList(name, path);
-    std::list<StdString>::const_iterator it = coords.begin(), end = coords.end();
-    for (; it != end; it++)
-    {
-      const StdString& coord = *it;
-      if (this->hasVariable(coord, path) && !this->isTemporal(coord, path))
-      {
-        std::map<StdString, StdSize> dimvar = this->getDimensions(&coord, path);
-        if ((dimvar.size() == 1) && (dimvar.find(coord) != dimvar.end()))
-          continue;
-        else
-          return false;
-      }
-    }
-    return true;
-  }
-
-  bool CINetCDF4::isCurvilinear(const StdString& name, const CVarPath* const path)
-  {
-    if (this->isRectilinear(name, path) || !this->hasCoordinates(name, path))
-      return false;
-
-    std::list<StdString> coords = this->getCoordinatesIdList(name, path);
-    std::list<StdString>::const_iterator it = coords.begin(), end = coords.end();
-    for (; it != end; it++)
-    {
-      const StdString& coord = *it;
-      if (this->hasVariable(coord, path))
-      {
-        std::map<StdString, StdSize> dimvar = this->getDimensions(&coord, path);
-        if (dimvar.size() != 2) return false;
-      }
-      else return false;
-    }
-    return true;
-  }
-
-  bool CINetCDF4::isUnstructured(const StdString& name, const CVarPath* const path)
-  {
-    if (this->isRectilinear(name, path) ||
-        this->isCurvilinear(name, path) ||
-        !this->hasCoordinates(name, path))
-       return false;
-
-    StdString dimname = this->getDimensionsList(&name, path).back();
-
-    std::list<StdString> coords = this->getCoordinatesIdList(name, path);
-    std::list<StdString>::const_iterator it = coords.begin(), end = coords.end();
-    for (; it != end; it++)
-    {
-      const StdString& coord = *it;
-      if (this->hasVariable(coord, path))
-      {
-        std::map<StdString, StdSize> dimvar = this->getDimensions(&coord, path);
-        if ((dimvar.size() == 1) &&
-            (dimvar.find(dimname) != dimvar.end()))
-          continue;
-        else
-          return false;
-      }
-      else return false;
-    }
-
-    return true;
-  }
-
-  bool CINetCDF4::isUnknown(const StdString& name, const CVarPath* const path)
-  {
-    return !(this->isRectilinear(name, path) || this->isCurvilinear(name, path) || this->isUnstructured(name, path));
-  }
-
-  bool CINetCDF4::isTemporal(const StdString& name, const CVarPath* const path)
-  {
-    if (!this->hasTemporalDim(path)) return false;
-    std::map<StdString, StdSize> dims = this->getDimensions(&name, path);
-    if (dims.find(this->getUnlimitedDimensionName(path)) != dims.end())
-      return true;
-    return false;
-  }
-
-  bool CINetCDF4::is3Dim(const StdString& name, const CVarPath* const path)
-  {
-    int i = 0;
-    std::list<StdString> coords = this->getCoordinatesIdList(name, path);
-    std::list<StdString>::const_iterator it = coords.begin(), end = coords.end();
-    for (; it != end; it++)
-    {
-      const StdString& coord = *it;
-      if (this->hasVariable(coord, path))
-      {
-        if (this->isTemporal(coord, path))
-          continue;
-        i++;
-      }
-      else
-      {
-        if (coord.compare(this->getUnlimitedDimensionName()) == 0)
-          continue;
-        i++;
-      }
-    }
-    return (i == 3);
-  }
-
-  bool CINetCDF4::isCellGrid(const StdString& name, const CVarPath* const path)
-  {
-    if (this->isCoordinate(name, path))
-    {
-      return (this->hasBounds(name, path));
-    }
-    else
-    {
-      std::list<StdString> coords = this->getCoordinatesIdList(name, path);
-      std::list<StdString>::const_iterator it = coords.begin(), end = coords.end();
-      for (; it != end; it++)
-      {
-        const StdString& coord = *it;
-        if (this->hasVariable(coord, path))
-        {
-          if (this->isTemporal(coord, path))
-            continue;
-          if (this->isCellGrid(coord, path))
-            continue;
-          return false;
-        }
-        else
-        {
-          if (coord.compare(this->getUnlimitedDimensionName()) == 0)
-            continue;
-          return false;
-        }
-      }
-    }
-
-    return true;
-  }
-
-  //---------------------------------------------------------------
-
-  std::list<StdString> CINetCDF4::getDataVariables(bool _is3D,       bool _isRecti,
-                                                   bool _isCurvi,    bool _isUnstr,
-                                                   bool _isCellData, bool _isTemporal,
-                                                   const CVarPath* const path)
-  {
-    std::list<StdString> retvalue;
-    std::list<StdString> allvars  = this->getVariables(path);
-    std::set<StdString> allcoords = this->getCoordVariables(path);
-
-    std::list<StdString>::const_iterator it = allvars.begin(), end = allvars.end();
-    for (; it != end; it++)
-    {
-      const StdString& var = *it;
-      if (this->isCoordinate(var, path)) continue;
-
-      if (!_isRecti && this->isRectilinear(var, path))  continue;
-      if (!_isCurvi && this->isCurvilinear(var, path))  continue;
-      if (!_isUnstr && this->isUnstructured(var, path)) continue;
-
-      if (!_isTemporal && this->isTemporal(var, path)) continue;
-      if (!_is3D       && this->is3Dim(var, path))     continue;
-      if (!_isCellData && this->isCellGrid(var, path)) continue;
-
-      if (this->isUnknown(var, path)) continue;
-
-      retvalue.push_back(var);
-    }
-    return retvalue;
-  }
-
-  //---------------------------------------------------------------
-
-  void CINetCDF4::getDataInfo(const StdString& var, const CVarPath* const path, StdSize record,
-                              std::vector<StdSize>& sstart, std::vector<StdSize>& scount, StdSize& array_size,
-                              const std::vector<StdSize>* start /*= NULL*/, const std::vector<StdSize>* count /*= NULL*/)
-  {
-    std::list<StdString> dimlist = this->getDimensionsList(&var, path);
-    std::map<StdString, StdSize> dimmap = this->getDimensions(&var, path);
-    std::list<StdString>::iterator it = dimlist.begin();
-    if (this->isTemporal(var, path))
-    {
-      if (record != UNLIMITED_DIM)
-        sstart.push_back(record);
-      else
-        sstart.push_back(0);
-      scount.push_back(1);
-      it++;
-    }
-    for (int i = 0; it != dimlist.end(); it++, i++)
-    {
-      if (start && count)
-      {
-        sstart.push_back((*start)[i]);
-        scount.push_back((*count)[i]);
-        array_size *= (*count)[i];
-      }
-      else
-      {
-        sstart.push_back(0);
-        scount.push_back(dimmap[*it]);
-        array_size *= dimmap[*it];
-      }
-    }
-  }
-
-  template <>
-  void CINetCDF4::getData(CArray<int, 1>& data, const StdString& var,
-                          const CVarPath* const path, StdSize record)
-  {
-
-    std::vector<StdSize> start, count;
-    int grpid = this->getGroup(path);
-    int varid = this->getVariable(var, path);
-    StdSize array_size = 1;
-    this->getDataInfo(var, path, record, start, count, array_size);
-    data.resize(array_size);
-    CheckError(nc_get_vara_int(grpid, varid, &(start[0]), &(count[0]), data.dataFirst()));
-  }
-
-  template <>
-  void CINetCDF4::getData(CArray<double, 1>& data, const StdString& var,
-                          const CVarPath* const path, StdSize record)
-  {
-    std::vector<StdSize> start, count;
-    int grpid = this->getGroup(path);
-    int varid = this->getVariable(var, path);
-    StdSize array_size = 1;
-    this->getDataInfo(var, path, record, start, count, array_size);
-    data.resize(array_size);
-    CheckError(nc_get_vara_double(grpid, varid, &(start[0]), &(count[0]), data.dataFirst()));
-  }
-
-  template <>
-  void CINetCDF4::getData(CArray<float, 1>& data, const StdString& var,
-                          const CVarPath* const path, StdSize record)
-  {
-    std::vector<StdSize> start, count;
-    int grpid = this->getGroup(path);
-    int varid = this->getVariable(var, path);
-    StdSize array_size = 1;
-    this->getDataInfo(var, path, record, start, count, array_size);
-    data.resize(array_size);
-    CheckError(nc_get_vara_float(grpid, varid, &(start[0]), &(count[0]), data.dataFirst()));
-  }
-
-  template <>
-  void CINetCDF4::getData(CArray<double, 1>& data, const StdString& var,
-                          bool collective, StdSize record,
-                          const std::vector<StdSize>* start /*= NULL*/,
-                          const std::vector<StdSize>* count /*= NULL*/)
-  {
-    int varid = this->getVariable(var);
-
-    if (this->mpi && collective)
-      CNetCdfInterface::varParAccess(ncidp, varid, NC_COLLECTIVE);
-    if (this->mpi && !collective)
-      CNetCdfInterface::varParAccess(ncidp, varid, NC_INDEPENDENT);
-
-    std::vector<StdSize> sstart, scount;
-    StdSize array_size = 1;
-    this->getDataInfo(var, NULL, record, sstart, scount, array_size, start, count);
-
-    if (data.numElements() != array_size)
-    {
-      ERROR("CONetCDF4::getData(...)",
-            << "[ Array size = " << data.numElements()
-            << ", Data size = "  << array_size
-            << " ] Invalid array size");
-    }
-
-    CheckError(nc_get_vara_double(ncidp, varid, &(sstart[0]), &(scount[0]), data.dataFirst()));
-  }
-
-  //---------------------------------------------------------------
-
-  StdString CINetCDF4::getLonCoordName(const StdString& varname,
-                                       const CVarPath* const path)
-  {
-    std::list<StdString> clist = this->getCoordinatesIdList(varname, path);
-    if (this->hasCoordinates(varname, path))
-      return (*clist.begin());
-    else
-      return (*clist.rbegin());
-  }
-
-  StdString CINetCDF4::getLatCoordName(const StdString& varname,
-                                       const CVarPath* const path)
-  {
-    std::list<StdString> clist = this->getCoordinatesIdList(varname, path);
-    if (this->hasCoordinates(varname, path))
-      return (*(++clist.begin()));
-    else
-      return (*(++clist.rbegin()));
-  }
-
-  StdString CINetCDF4::getVertCoordName(const StdString& varname,
-                                        const CVarPath* const path)
-  {
-    if (!this->is3Dim(varname, path)) return "";
-    std::list<StdString> clist = this->getCoordinatesIdList(varname, path);
-    if (this->hasCoordinates(varname, path))
-      return (*(++(++clist.begin())));
-    else
-      return (*(++(++clist.rbegin())));
-  }
-} // namespace xios
Index: XIOS/trunk/src/input/inetcdf4.hpp
===================================================================
--- XIOS/trunk/src/input/inetcdf4.hpp	(revision 684)
+++ 	(revision )
@@ -1,212 +1,0 @@
-#ifndef __XIOS_INETCDF4__
-#define __XIOS_INETCDF4__
-
-/// XIOS headers ///
-#include "xios_spl.hpp"
-#include "exception.hpp"
-#include "array_new.hpp"
-
-#include "mpi.hpp"
-#include "netcdf.hpp"
-
-#ifndef UNLIMITED_DIM
-#define UNLIMITED_DIM (size_t)(-1)
-#endif  // UNLIMITED_DIM
-
-namespace xios
-{
-  typedef std::vector<StdString> CVarPath;
-
-  class CINetCDF4
-  {
-    public:
-      /// Constructors ///
-      CINetCDF4(const StdString& filename, const MPI_Comm* comm = NULL, bool multifile = true);
-      CINetCDF4(const CINetCDF4& inetcdf4);       // Not implemented.
-      CINetCDF4(const CINetCDF4* const inetcdf4); // Not implemented.
-
-      //-------------------------------------------------------------
-
-      /// Destructor ///
-      virtual ~CINetCDF4(void);
-
-      //-------------------------------------------------------------
-
-      void close(void);
-
-      //-------------------------------------------------------------
-
-      /// Getters ///
-      StdSize getNbOfTimestep(const CVarPath* const path = NULL);
-
-      StdString getUnlimitedDimensionName(const CVarPath* const path = NULL);
-
-      StdString getCoordinatesId(const StdString& name, const CVarPath* const path = NULL);
-
-      StdString getBoundsId(const StdString& name, const CVarPath* const path = NULL);
-
-      StdString getLonCoordName(const StdString& varname, const CVarPath* const path = NULL);
-      StdString getLatCoordName(const StdString& varname, const CVarPath* const path = NULL);
-      StdString getVertCoordName(const StdString& varname, const CVarPath* const path = NULL);
-
-      std::set<StdString> getCoordVariables(const CVarPath* const path = NULL);
-      std::set<StdString> getBoundVariables(const CVarPath* const path = NULL);
-
-      std::list<StdString> getGroups   (const CVarPath* const path = NULL);
-      std::list<StdString> getVariables(const CVarPath* const path = NULL);
-
-      std::list<StdString> getDataVariables(bool _is3D       = true,
-                                            bool _isRecti    = true,
-                                            bool _isCurvi    = true,
-                                            bool _isUnstr    = true,
-                                            bool _isCellData = true,
-                                            bool _isTemporal = true,
-                                            const CVarPath* const path = NULL);
-
-      std::list<StdString> getAttributes(const StdString* const var  = NULL,
-                                         const CVarPath* const path = NULL);
-
-      std::list<StdString> getDimensionsList(const StdString* const var  = NULL,
-                                             const CVarPath* const path = NULL);
-
-      std::list<StdString> getCoordinatesIdList(const StdString& name,
-                                                const CVarPath* const path = NULL);
-
-      std::map<StdString, StdSize> getDimensions(const StdString* const var  = NULL,
-                                                 const CVarPath* const path = NULL);
-
-      StdSize getNbVertex(const StdString& name, const CVarPath* const path = NULL);
-
-      //-------------------------------------------------------------
-
-      template <class T>
-      T getMissingValue(const StdString& name, const CVarPath* const path = NULL);
-
-      template <class T>
-      T getAttributeValue(const StdString& name,
-                          const StdString* const var  = NULL,
-                          const CVarPath* const path = NULL);
-
-      template <class T>
-      void getData(CArray<T, 1>& data,
-                   const StdString& var,
-                   const CVarPath* const path = NULL,
-                   StdSize record = UNLIMITED_DIM);
-
-      template <class T>
-      void getData(CArray<T, 1>& data, const StdString& var,
-                   bool collective, StdSize record,
-                   const std::vector<StdSize>* start = NULL,
-                   const std::vector<StdSize>* count = NULL);
-
-      //-------------------------------------------------------------
-
-      /// Tests ///
-      bool hasMissingValue(const StdString& name, const CVarPath* const path = NULL);
-
-      bool hasAttribute(const StdString& name, const StdString* const var  = NULL, const CVarPath* const path = NULL);
-
-      bool hasVariable(const StdString& name, const CVarPath* const path = NULL);
-
-      bool hasCoordinates(const StdString& name, const CVarPath* const path = NULL);
-
-      bool hasTemporalDim(const CVarPath* const path = NULL);
-
-      bool hasBounds(const StdString& name, const CVarPath* const path = NULL);
-
-      //-------------------------------------------------------------
-
-      bool isBound(const StdString& name, const CVarPath* const path = NULL);
-      bool isCoordinate(const StdString& name, const CVarPath* const path = NULL);
-      bool isRectilinear(const StdString& name, const CVarPath* const path = NULL);
-      bool isCurvilinear(const StdString& name, const CVarPath* const path = NULL);
-      bool isUnknown(const StdString& name, const CVarPath* const path = NULL);
-      bool isUnstructured(const StdString& name, const CVarPath* const path = NULL);
-
-      bool isTemporal(const StdString& name, const CVarPath* const path = NULL);
-      bool is3Dim(const StdString& name, const CVarPath* const path = NULL);
-      bool isCellGrid(const StdString& name, const CVarPath* const path = NULL);
-
-    protected:
-      /// Getters ///
-      int getGroup   (const CVarPath* const path = NULL);
-      int getVariable(const StdString& varname, const CVarPath* const path = NULL);
-      int getDimension(const StdString& dimname, const CVarPath* const path = NULL);
-      int getUnlimitedDimension(const CVarPath* const path = NULL);
-      int getAttributeId(const StdString& name,
-                         const StdString* const var = NULL,
-                         const CVarPath* const path = NULL);
-
-      std::pair<nc_type , StdSize> getAttribute(const StdString& attname,
-                                                const StdString* const var  = NULL,
-                                                const CVarPath* const path = NULL);
-
-      //-------------------------------------------------------------
-
-      void getDataInfo(const StdString& var, const CVarPath* const path, StdSize record,
-                       std::vector<StdSize>& sstart, std::vector<StdSize>& scount, StdSize& array_size,
-                       const std::vector<StdSize>* start = NULL, const std::vector<StdSize>* count = NULL);
-
-    private:
-      /// VÃ©rification des erreurs NetCDF ///
-      static void CheckError(int status);
-
-      int ncidp; // Identifiant de fichier netcdf.
-      bool mpi; //< Whether parallel file access is used
-  }; // class CINetCDF4
-
-  ///--------------------------------------------------------------
-
-  template <>
-  StdString CINetCDF4::getAttributeValue(const StdString& name, const StdString* const var,
-                                         const CVarPath* const path);
-
-  template <>
-  std::vector<double> CINetCDF4::getAttributeValue(const StdString& name, const StdString* const var,
-                                                   const CVarPath* const path);
-
-  template <>
-  std::vector<float> CINetCDF4::getAttributeValue(const StdString& name, const StdString* const var,
-                                                  const CVarPath* const path);
-
-  template <>
-  std::vector<int> CINetCDF4::getAttributeValue(const StdString& name, const StdString* const var,
-                                                const CVarPath* const path);
-
-  template <>
-  std::vector<char> CINetCDF4::getAttributeValue(const StdString& name, const StdString* const var,
-                                                 const CVarPath* const path);
-
-  //---------------------------------------------------------------
-
-  template <>
-  int CINetCDF4::getMissingValue(const StdString& name, const CVarPath* const path);
-
-  template <>
-  double CINetCDF4::getMissingValue(const StdString& name, const CVarPath* const path);
-
-  template <>
-  float CINetCDF4::getMissingValue(const StdString& name, const CVarPath* const path);
-
-  //---------------------------------------------------------------
-
-  template <>
-  void CINetCDF4::getData(CArray<int, 1>& data, const StdString& var,
-                          const CVarPath* const path, StdSize record);
-
-  template <>
-  void CINetCDF4::getData(CArray<double, 1>& data, const StdString& var,
-                          const CVarPath* const path, StdSize record);
-
-  template <>
-  void CINetCDF4::getData(CArray<float, 1>& data, const StdString& var,
-                          const CVarPath* const path, StdSize record);
-
-  template <>
-  void CINetCDF4::getData(CArray<double, 1>& data, const StdString& var,
-                          bool collective, StdSize record,
-                          const std::vector<StdSize>* start /*= NULL*/,
-                          const std::vector<StdSize>* count /*= NULL*/);
-} // namespace xios
-
-#endif //__XIOS_INETCDF4__
Index: XIOS/trunk/src/input/nc4_data_input.cpp
===================================================================
--- XIOS/trunk/src/input/nc4_data_input.cpp	(revision 684)
+++ 	(revision )
@@ -1,90 +1,0 @@
-#include "nc4_data_input.hpp"
-
-#include "context.hpp"
-#include "context_server.hpp"
-
-namespace xios
-{
-  CNc4DataInput::CNc4DataInput(const StdString& filename, MPI_Comm comm_file, bool multifile, bool isCollective /*= true*/)
-    : SuperClass()
-    , SuperClassWriter(filename, &comm_file, multifile)
-    , comm_file(comm_file)
-    , filename(filename)
-    , isCollective(isCollective)
-  {
-    SuperClass::type = multifile ? MULTI_FILE : ONE_FILE;
-  }
-
-  CNc4DataInput::~CNc4DataInput(void)
-  { /* Nothing more to do */ }
-
-  StdSize CNc4DataInput::getFieldNbRecords_(CField* field)
-  {
-    StdString fieldId = !field->name.isEmpty() ? field->name.getValue() : field->getBaseFieldReference()->getId();
-
-    if (SuperClassWriter::isTemporal(fieldId))
-    {
-      return SuperClassWriter::getDimensions(&fieldId)[SuperClassWriter::getUnlimitedDimensionName()];
-    }
-
-    return 1;
-  }
-
-  void CNc4DataInput::readFieldData_(CField* field)
-  {
-    CContext* context = CContext::getCurrent();
-    CContextServer* server = context->server;
-
-    CGrid* grid = field->grid;
-
-    if (!grid->doGridHaveDataToWrite())
-      if (SuperClass::type==MULTI_FILE || !isCollective) return;
-
-    StdString fieldId = !field->name.isEmpty() ? field->name.getValue() : field->getBaseFieldReference()->getId();
-
-    CArray<double,1> fieldData(grid->getWrittenDataSize());
-    if (!field->default_value.isEmpty()) fieldData = field->default_value;
-
-    switch (SuperClass::type)
-    {
-      case MULTI_FILE:
-        SuperClassWriter::getData(fieldData, fieldId, isCollective, field->getNStep() - 1);
-        break;
-      case ONE_FILE:
-      {
-        std::vector<int> nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal();
-        std::vector<int> nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer();
-        std::vector<int> nZoomSizeServer  = grid->getDistributionServer()->getZoomSizeServer();
-
-        int ssize = nZoomBeginGlobal.size();
-
-        std::vector<StdSize> start(ssize);
-        std::vector<StdSize> count(ssize);
-
-        for (int i = 0; i < ssize; ++i)
-        {
-          start[i] = nZoomBeginServer[ssize - i - 1] - nZoomBeginGlobal[ssize - i - 1];
-          count[i] = nZoomSizeServer[ssize - i - 1];
-        }
-
-        SuperClassWriter::getData(fieldData, fieldId, isCollective, field->getNStep() - 1, &start, &count);
-        break;
-      }
-    }
-
-    field->inputField(fieldData);
-
-    if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty())
-    {
-      double scaleFactor = 1.0, addOffset = 0.0;
-      if (!field->scale_factor.isEmpty()) scaleFactor = field->scale_factor;
-      if (!field->add_offset.isEmpty()) addOffset = field->add_offset;
-      field->invertScaleFactorAddOffset(scaleFactor, addOffset);
-    }
-  }
-
-  void CNc4DataInput::closeFile_(void)
-  {
-    SuperClassWriter::close();
-  }
-} // namespace xios
Index: XIOS/trunk/src/input/nc4_data_input.hpp
===================================================================
--- XIOS/trunk/src/input/nc4_data_input.hpp	(revision 684)
+++ 	(revision )
@@ -1,45 +1,0 @@
-#ifndef __XIOS_NC4_DATA_INPUT__
-#define __XIOS_NC4_DATA_INPUT__
-
-/// XIOS headers ///
-#include "xios_spl.hpp"
-#include "data_input.hpp"
-#include "inetcdf4.hpp"
-
-namespace xios
-{
-  class CNc4DataInput
-    : protected CINetCDF4
-    , public virtual CDataInput
-  {
-  public:
-    /// Type definitions ///
-    typedef CINetCDF4  SuperClassWriter;
-    typedef CDataInput SuperClass;
-
-    /// Constructors ///
-    CNc4DataInput(const StdString& filename, MPI_Comm comm_file, bool multifile, bool isCollective = true);
-    CNc4DataInput(const CNc4DataInput& dataInput);       // Not implemented.
-    CNc4DataInput(const CNc4DataInput* const dataInput); // Not implemented.
-
-    /// Destructor ///
-    virtual ~CNc4DataInput(void);
-
-    /// Getters ///
-    const StdString& getFileName(void) const;
-
-  protected:
-    // Read methods
-    virtual StdSize getFieldNbRecords_(CField* field);
-    virtual void readFieldData_(CField* field);
-    virtual void closeFile_(void);
-
-  private:
-    /// Private attributes ///
-    MPI_Comm comm_file;
-    const StdString filename;
-    bool isCollective;
-  }; // class CNc4DataInput
-} // namespace xios
-
-#endif //__XIOS_NC4_DATA_INPUT__
Index: XIOS/trunk/src/io/inetcdf4.cpp
===================================================================
--- XIOS/trunk/src/io/inetcdf4.cpp	(revision 685)
+++ XIOS/trunk/src/io/inetcdf4.cpp	(revision 685)
@@ -0,0 +1,814 @@
+#include "inetcdf4.hpp"
+#include "netCdfInterface.hpp"
+
+#include <boost/algorithm/string.hpp>
+
+namespace xios
+{
+  CINetCDF4::CINetCDF4(const StdString& filename, const MPI_Comm* comm /*= NULL*/, bool multifile /*= true*/)
+    : mpi(comm != NULL && !multifile)
+  {
+    if (comm != NULL)
+    {
+      if (!multifile) CNetCdfInterface::openPar(filename, NC_NOWRITE, *comm, MPI_INFO_NULL, this->ncidp);
+      else CNetCdfInterface::open(filename, NC_NOWRITE, this->ncidp);
+    }
+      else CNetCdfInterface::open(filename, NC_NOWRITE, this->ncidp);
+  }
+
+  CINetCDF4::~CINetCDF4(void)
+  { /* Nothing to do */ }
+
+  ///--------------------------------------------------------------
+
+  void CINetCDF4::CheckError(int status)
+  {
+    if (status != NC_NOERR)
+    {
+      StdString errormsg(nc_strerror(status)); // fuite mÃ©moire ici ?
+      ERROR("CINetCDF4::CheckError(int status)",
+            << "[ status = " << status << " ] " << errormsg);
+    }
+  }
+
+  //---------------------------------------------------------------
+
+  void CINetCDF4::close(void)
+  {
+    CheckError(nc_close(this->ncidp));
+  }
+
+  //---------------------------------------------------------------
+
+  int CINetCDF4::getGroup(const CVarPath* const path)
+  {
+    int retvalue = this->ncidp;
+    if (path == NULL) return retvalue;
+    CVarPath::const_iterator it = path->begin(), end = path->end();
+
+    for (; it != end; it++)
+    {
+      const StdString& groupid = *it;
+      CheckError(nc_inq_ncid(retvalue, const_cast<char*>(groupid.c_str()), &retvalue));
+    }
+
+    return retvalue;
+  }
+
+  int CINetCDF4::getVariable(const StdString& varname,
+                             const CVarPath* const path)
+  {
+    int varid = 0;
+    int grpid = this->getGroup(path);
+    CheckError(nc_inq_varid(grpid, varname.c_str(), &varid));
+    return varid;
+  }
+
+  int CINetCDF4::getDimension(const StdString& dimname,
+                              const CVarPath* const path)
+  {
+    int dimid = 0;
+    int grpid = this->getGroup(path);
+    CheckError(nc_inq_dimid(grpid, dimname.c_str(), &dimid));
+    return dimid;
+  }
+
+  std::pair<nc_type, StdSize> CINetCDF4::getAttribute(const StdString& attname,
+                                                      const StdString* const var,
+                                                      const CVarPath* const path)
+  {
+    std::pair<nc_type, StdSize> retvalue;
+    int grpid = this->getGroup(path);
+    int varid = (var != NULL) ? this->getVariable(*var, path) : NC_GLOBAL;
+    CheckError(nc_inq_att(grpid, varid, attname.c_str(),
+                          &retvalue.first, &retvalue.second));
+    return retvalue;
+  }
+
+  int CINetCDF4::getUnlimitedDimension(const CVarPath* const path)
+  {
+    int dimid = 0;
+    int grpid = this->getGroup(path);
+    CheckError(nc_inq_unlimdim(grpid, &dimid));
+    return dimid;
+  }
+
+  StdString CINetCDF4::getUnlimitedDimensionName(const CVarPath* const path)
+  {
+    char full_name_in[NC_MAX_NAME +1];
+    int grpid = this->getGroup(path);
+    int dimid = this->getUnlimitedDimension(path);
+    CheckError(nc_inq_dimname(grpid, dimid, full_name_in));
+
+    StdString dimname(full_name_in);
+    return dimname;
+  }
+
+  //---------------------------------------------------------------
+  StdSize CINetCDF4::getNbVertex(const StdString& name,
+                                 const CVarPath* const path)
+  {
+
+    if (this->isRectilinear(name, path) ||
+       this->isCurvilinear(name, path))
+    {
+      if (this->is3Dim(name, path)) return 8;
+      else return 4;
+    }
+    if (this->isUnstructured(name, path))
+    {
+      StdString bound = this->getBoundsId
+            (this->getCoordinatesIdList(name, path).back(), path);
+      StdString dim = this->getDimensionsList(&bound, path).back();
+      return (this->getDimensions(&bound, path)[dim]);
+    }
+    return size_t(-1);
+  }
+
+  //---------------------------------------------------------------
+
+  std::list<StdString> CINetCDF4::getGroups(const CVarPath* const path)
+  {
+    StdSize strlen = 0;
+    char full_name_in[NC_MAX_NAME +1];
+    int nbgroup = 0, *groupid = NULL;
+    int grpid = this->getGroup(path);
+    std::list<StdString> retvalue;
+
+    CheckError(nc_inq_grps(grpid, &nbgroup, NULL));
+    groupid = new int[nbgroup]();
+    CheckError(nc_inq_grps(grpid, NULL, groupid));
+
+    for (int i = 0; i < nbgroup; i++)
+    {
+      CheckError(nc_inq_grpname_full(groupid[i], &strlen, full_name_in));
+      StdString groupname(full_name_in, strlen);
+      retvalue.push_back(groupname);
+    }
+
+    delete [] groupid;
+    return retvalue;
+  }
+
+  std::list<StdString> CINetCDF4::getVariables(const CVarPath* const path)
+  {
+    char full_name_in[NC_MAX_NAME +1];
+    int nbvar = 0, *varid = NULL;
+    int grpid = this->getGroup(path);
+    std::list<StdString> retvalue;
+
+    CheckError(nc_inq_varids(grpid, &nbvar, NULL));
+    varid = new int[nbvar]();
+    CheckError(nc_inq_varids(grpid, NULL, varid));
+
+    for (int i = 0; i < nbvar; i++)
+    {
+      CheckError(nc_inq_varname(grpid, varid[i], full_name_in));
+      StdString varname(full_name_in);
+      retvalue.push_back(varname);
+    }
+
+    delete [] varid;
+    return retvalue;
+  }
+
+  StdSize CINetCDF4::getNbOfTimestep(const CVarPath* const path)
+  {
+    return (this->getDimensions(NULL, path)[this->getUnlimitedDimensionName(path)]);
+  }
+
+  std::set<StdString> CINetCDF4::getBoundVariables(const CVarPath* const path)
+  {
+    std::set<StdString> retvalue;
+    std::list<StdString> variables = this->getVariables(path);
+    std::list<StdString>::const_iterator it = variables.begin(), end = variables.end();
+    for (; it != end; it++)
+    {
+      const StdString& var = *it;
+      if (this->hasBounds(var, path))
+        retvalue.insert(retvalue.end(), this->getBoundsId(var, path));
+    }
+    return retvalue;
+  }
+
+  std::set<StdString> CINetCDF4::getCoordVariables(const CVarPath* const path)
+  {
+    std::set<StdString> retvalue;
+    std::list<StdString> variables = this->getVariables(path);
+    std::list<StdString>::const_iterator it = variables.begin(), end = variables.end();
+    for (; it != end; it++)
+    {
+      const StdString& var = *it;
+      std::list<StdString> coords = this->getCoordinatesIdList(var, path);
+      std::list<StdString>::const_iterator it = coords.begin(), end = coords.end();
+      for (; it != end; it++)
+      {
+        const StdString& coord = *it;
+        if (this->hasVariable(coord, path))
+          retvalue.insert(retvalue.end(), coord);
+      }
+    }
+    return retvalue;
+  }
+
+  std::list<StdString> CINetCDF4::getDimensionsList(const StdString* const var, const CVarPath* const path)
+  {
+    char full_name_in[NC_MAX_NAME +1];
+    int nbdim = 0, *dimid = NULL;
+    int grpid = this->getGroup(path);
+    int varid = (var != NULL) ? this->getVariable(*var, path) : NC_GLOBAL;
+    std::list<StdString> retvalue;
+
+    if (var != NULL)
+    {
+      CheckError(nc_inq_varndims(grpid, varid, &nbdim));
+      dimid = new int[nbdim]();
+      CheckError(nc_inq_vardimid(grpid, varid, dimid));
+    }
+    else
+    {
+      CheckError(nc_inq_dimids(grpid, &nbdim, NULL, 1));
+      dimid = new int[nbdim]();
+      CheckError(nc_inq_dimids(grpid, NULL, dimid, 1));
+    }
+
+    for (int i = 0; i < nbdim; i++)
+    {
+      CheckError(nc_inq_dimname(grpid, dimid[i], full_name_in));
+      StdString dimname(full_name_in);
+      retvalue.push_back(dimname);
+    }
+    delete [] dimid;
+
+    return retvalue;
+  }
+
+  std::map<StdString, StdSize> CINetCDF4::getDimensions(const StdString* const var, const CVarPath* const path)
+  {
+    StdSize size = 0;
+    char full_name_in[NC_MAX_NAME + 1];
+    int nbdim = 0, *dimid = NULL;
+    int grpid = this->getGroup(path);
+    int varid = (var != NULL) ? this->getVariable(*var, path) : NC_GLOBAL;
+    std::map<StdString, StdSize> retvalue;
+
+    if (var != NULL)
+    {
+      CheckError(nc_inq_varndims(grpid, varid, &nbdim));
+      dimid = new int[nbdim]();
+      CheckError(nc_inq_vardimid(grpid, varid, dimid));
+    }
+    else
+    {
+      CheckError(nc_inq_dimids(grpid, &nbdim, NULL, 1));
+      dimid = new int[nbdim]();
+      CheckError(nc_inq_dimids(grpid, NULL, dimid, 1));
+    }
+
+    for (int i = 0; i < nbdim; i++)
+    {
+      CheckError(nc_inq_dimname(grpid, dimid[i], full_name_in));
+      CheckError(nc_inq_dimlen (grpid, dimid[i], &size));
+
+      StdString dimname(full_name_in);
+      retvalue.insert(retvalue.end(), std::make_pair(dimname, size));
+    }
+    delete [] dimid;
+
+    return retvalue;
+  }
+
+  std::list<StdString> CINetCDF4::getAttributes(const StdString* const var, const CVarPath* const path )
+  {
+    int nbatt = 0;
+    char full_name_in[NC_MAX_NAME +1];
+    std::list<StdString> retvalue;
+    int grpid = this->getGroup(path);
+    int varid = (var != NULL) ? this->getVariable(*var, path) : NC_GLOBAL;
+
+    if (var != NULL)
+      CheckError(nc_inq_varnatts(grpid, varid, &nbatt));
+    else
+      CheckError(nc_inq_natts(grpid, &nbatt));
+
+    for (int i = 0; i < nbatt; i++)
+    {
+      CheckError(nc_inq_attname(grpid, varid, i, full_name_in));
+      StdString attname(full_name_in);
+      retvalue.push_back(attname);
+    }
+    return retvalue;
+  }
+
+  int CINetCDF4::getAttributeId(const StdString& name,
+                                const StdString* const var,
+                                const CVarPath* const path)
+  {
+    int retvalue = 0;
+    std::list<StdString> atts = this->getAttributes(var, path);
+    std::list<StdString>::const_iterator it = atts.begin(), end = atts.end();
+    for (; it != end; it++)
+    {
+      const StdString& attname = *it;
+      if (attname.compare(name) == 0)
+        return retvalue;
+      retvalue++;
+    }
+    return -1;
+  }
+
+  //---------------------------------------------------------------
+
+  bool CINetCDF4::hasMissingValue(const StdString& name,
+                                  const CVarPath* const path)
+  {
+    return (this->hasAttribute("missing_value", &name, path) ||
+          this->hasAttribute("_FillValue", &name, path));
+  }
+
+  bool CINetCDF4::hasAttribute(const StdString& name,
+                               const StdString* const var ,
+                               const CVarPath* const path)
+  {
+    std::list<StdString> atts = this->getAttributes(var, path);
+    std::list<StdString>::const_iterator it = atts.begin(), end = atts.end();
+    for (; it != end; it++)
+    {
+      const StdString& attname = *it;
+      if (attname.compare(name) == 0) return true;
+    }
+    return false;
+  }
+
+  bool CINetCDF4::hasVariable(const StdString& name,
+                              const CVarPath* const path)
+  {
+    std::list<StdString> variables = this->getVariables(path);
+    std::list<StdString>::const_iterator it = variables.begin(), end = variables.end();
+    for (; it != end; it++)
+    {
+      const StdString& varname = *it;
+      if (varname.compare(name) == 0) return true;
+    }
+    return false;
+  }
+
+  bool CINetCDF4::hasCoordinates(const StdString& name,
+                                 const CVarPath* const path)
+  {
+    return (this->hasAttribute("coordinates", &name, path));
+  }
+
+  bool CINetCDF4::hasBounds(const StdString& name,
+                            const CVarPath* const path)
+  {
+    return (this->hasAttribute("bounds", &name, path));
+  }
+
+  bool CINetCDF4::hasTemporalDim(const CVarPath* const path)
+  {
+    return (this->getUnlimitedDimension(path) != -1);
+  }
+
+  //---------------------------------------------------------------
+
+#define GET_ATTRIBUTE_VALUE(type, func_ext, type_enum)                              \
+  template <>                                                                       \
+  std::vector<type> CINetCDF4::getAttributeValue(const StdString& name,             \
+                                                 const StdString* const var,        \
+                                                 const CVarPath* const path)        \
+  {                                                                                 \
+    int grpid = this->getGroup(path);                                               \
+    int varid = (var != NULL) ? this->getVariable(*var, path) : NC_GLOBAL;          \
+    std::pair<nc_type , StdSize> attinfos = this->getAttribute(name, var, path);    \
+    std::vector<type> retvalue(attinfos.second);                                    \
+    if (attinfos.first != type_enum)                                                \
+      ERROR("CINetCDF4::getAttributeValue<double>(name, var, path",                 \
+            << "[ name : " << name                                                  \
+            << ", type requested :" << attinfos.first                               \
+            << ", type stored : " << type_enum << "]"                               \
+            << " Invalid type !");                                                  \
+    CheckError(nc_get_att_##func_ext(grpid, varid, name.c_str(), &(retvalue[0])));  \
+    return retvalue;                                                                \
+  }
+
+  GET_ATTRIBUTE_VALUE(double, double, NC_DOUBLE)
+  GET_ATTRIBUTE_VALUE(float,  float,  NC_FLOAT)
+  GET_ATTRIBUTE_VALUE(int,    int ,   NC_INT)
+  GET_ATTRIBUTE_VALUE(char,   text,   NC_CHAR)
+
+  template <>
+  StdString CINetCDF4::getAttributeValue(const StdString& name,
+                                         const StdString* const var,
+                                         const CVarPath* const path)
+  {
+    std::vector<char> chart = this->getAttributeValue<std::vector<char> >(name, var, path);
+    StdString retvalue(&(chart[0]), chart.size());
+    return retvalue;
+  }
+
+  template <>
+  int CINetCDF4::getMissingValue(const StdString& name,
+                                 const CVarPath* const path)
+  {
+    if (this->hasAttribute("missing_value", &name, path))
+      return (this->getAttributeValue<std::vector<int> >("missing_value", &name, path)[0]);
+    if (this->hasAttribute("_FillValue", &name, path))
+      return (this->getAttributeValue<std::vector<int> >("_FillValue", &name, path)[0]);
+    return 0;
+  }
+
+  template <>
+  double CINetCDF4::getMissingValue(const StdString& name,
+                                    const CVarPath* const path)
+  {
+    if (this->hasAttribute("missing_value", &name, path))
+      return (this->getAttributeValue<std::vector<double> >("missing_value", &name, path)[0]);
+    if (this->hasAttribute("_FillValue", &name, path))
+      return (this->getAttributeValue<std::vector<double> >("_FillValue", &name, path)[0]);
+    return 0;
+  }
+
+  template <>
+  float CINetCDF4::getMissingValue(const StdString& name,
+                                   const CVarPath* const path)
+  {
+    if (this->hasAttribute("missing_value", &name, path))
+      return (this->getAttributeValue<std::vector<float> >("missing_value", &name, path)[0]);
+    if (this->hasAttribute("_FillValue", &name, path))
+      return (this->getAttributeValue<std::vector<float> >("_FillValue", &name, path)[0]);
+    return 0;
+  }
+
+  //---------------------------------------------------------------
+
+  std::list<StdString> CINetCDF4::getCoordinatesIdList(const StdString& name, const CVarPath* const path)
+  {
+    std::list<StdString> retvalue;
+    StdString value = this->getCoordinatesId(name, path);
+
+    boost::split(retvalue, value, boost::is_any_of(" "));
+
+    std::list<StdString>::iterator it = retvalue.begin(), end = retvalue.end();
+    for (; it != end; it++)
+    {
+      StdString& coord = *it;
+      coord.assign(coord.data());
+    }
+    return retvalue;
+  }
+
+  StdString CINetCDF4::getCoordinatesId(const StdString& name, const CVarPath* const path)
+  {
+    StdString retvalue;
+    if (this->hasAttribute("coordinates", &name, path))
+    {
+      return (this->getAttributeValue<StdString>("coordinates", &name, path));
+    }
+    else
+    {
+      std::list<StdString> dims = this->getDimensionsList(&name, path);
+      std::list<StdString>::const_iterator it = dims.begin(), end = dims.end();
+      for (; it != end; it++)
+      {
+        const StdString& value = *it;
+        retvalue.append(value).push_back(' ');
+      }
+      retvalue.erase(retvalue.end() - 1) ;
+    }
+
+    return retvalue;
+  }
+
+  StdString CINetCDF4::getBoundsId(const StdString& name,
+                                   const CVarPath* const path)
+  {
+    StdString retvalue;
+    if (this->hasAttribute("bounds", &name, path))
+      return (this->getAttributeValue<StdString>("bounds", &name, path));
+    return retvalue;
+  }
+
+  //---------------------------------------------------------------
+
+  bool CINetCDF4::isBound(const StdString& name,
+                          const CVarPath* const path)
+  {
+    std::set<StdString> bounds = this->getBoundVariables(path);
+    return (bounds.find(name) != bounds.end());
+  }
+
+  bool CINetCDF4::isCoordinate(const StdString& name,
+                               const CVarPath* const path)
+  {
+    std::set<StdString> coords = this->getCoordVariables(path);
+    return (coords.find(name) != coords.end());
+  }
+
+  bool CINetCDF4::isRectilinear(const StdString& name, const CVarPath* const path)
+  {
+    std::list<StdString> coords = this->getCoordinatesIdList(name, path);
+    std::list<StdString>::const_iterator it = coords.begin(), end = coords.end();
+    for (; it != end; it++)
+    {
+      const StdString& coord = *it;
+      if (this->hasVariable(coord, path) && !this->isTemporal(coord, path))
+      {
+        std::map<StdString, StdSize> dimvar = this->getDimensions(&coord, path);
+        if ((dimvar.size() == 1) && (dimvar.find(coord) != dimvar.end()))
+          continue;
+        else
+          return false;
+      }
+    }
+    return true;
+  }
+
+  bool CINetCDF4::isCurvilinear(const StdString& name, const CVarPath* const path)
+  {
+    if (this->isRectilinear(name, path) || !this->hasCoordinates(name, path))
+      return false;
+
+    std::list<StdString> coords = this->getCoordinatesIdList(name, path);
+    std::list<StdString>::const_iterator it = coords.begin(), end = coords.end();
+    for (; it != end; it++)
+    {
+      const StdString& coord = *it;
+      if (this->hasVariable(coord, path))
+      {
+        std::map<StdString, StdSize> dimvar = this->getDimensions(&coord, path);
+        if (dimvar.size() != 2) return false;
+      }
+      else return false;
+    }
+    return true;
+  }
+
+  bool CINetCDF4::isUnstructured(const StdString& name, const CVarPath* const path)
+  {
+    if (this->isRectilinear(name, path) ||
+        this->isCurvilinear(name, path) ||
+        !this->hasCoordinates(name, path))
+       return false;
+
+    StdString dimname = this->getDimensionsList(&name, path).back();
+
+    std::list<StdString> coords = this->getCoordinatesIdList(name, path);
+    std::list<StdString>::const_iterator it = coords.begin(), end = coords.end();
+    for (; it != end; it++)
+    {
+      const StdString& coord = *it;
+      if (this->hasVariable(coord, path))
+      {
+        std::map<StdString, StdSize> dimvar = this->getDimensions(&coord, path);
+        if ((dimvar.size() == 1) &&
+            (dimvar.find(dimname) != dimvar.end()))
+          continue;
+        else
+          return false;
+      }
+      else return false;
+    }
+
+    return true;
+  }
+
+  bool CINetCDF4::isUnknown(const StdString& name, const CVarPath* const path)
+  {
+    return !(this->isRectilinear(name, path) || this->isCurvilinear(name, path) || this->isUnstructured(name, path));
+  }
+
+  bool CINetCDF4::isTemporal(const StdString& name, const CVarPath* const path)
+  {
+    if (!this->hasTemporalDim(path)) return false;
+    std::map<StdString, StdSize> dims = this->getDimensions(&name, path);
+    if (dims.find(this->getUnlimitedDimensionName(path)) != dims.end())
+      return true;
+    return false;
+  }
+
+  bool CINetCDF4::is3Dim(const StdString& name, const CVarPath* const path)
+  {
+    int i = 0;
+    std::list<StdString> coords = this->getCoordinatesIdList(name, path);
+    std::list<StdString>::const_iterator it = coords.begin(), end = coords.end();
+    for (; it != end; it++)
+    {
+      const StdString& coord = *it;
+      if (this->hasVariable(coord, path))
+      {
+        if (this->isTemporal(coord, path))
+          continue;
+        i++;
+      }
+      else
+      {
+        if (coord.compare(this->getUnlimitedDimensionName()) == 0)
+          continue;
+        i++;
+      }
+    }
+    return (i == 3);
+  }
+
+  bool CINetCDF4::isCellGrid(const StdString& name, const CVarPath* const path)
+  {
+    if (this->isCoordinate(name, path))
+    {
+      return (this->hasBounds(name, path));
+    }
+    else
+    {
+      std::list<StdString> coords = this->getCoordinatesIdList(name, path);
+      std::list<StdString>::const_iterator it = coords.begin(), end = coords.end();
+      for (; it != end; it++)
+      {
+        const StdString& coord = *it;
+        if (this->hasVariable(coord, path))
+        {
+          if (this->isTemporal(coord, path))
+            continue;
+          if (this->isCellGrid(coord, path))
+            continue;
+          return false;
+        }
+        else
+        {
+          if (coord.compare(this->getUnlimitedDimensionName()) == 0)
+            continue;
+          return false;
+        }
+      }
+    }
+
+    return true;
+  }
+
+  //---------------------------------------------------------------
+
+  std::list<StdString> CINetCDF4::getDataVariables(bool _is3D,       bool _isRecti,
+                                                   bool _isCurvi,    bool _isUnstr,
+                                                   bool _isCellData, bool _isTemporal,
+                                                   const CVarPath* const path)
+  {
+    std::list<StdString> retvalue;
+    std::list<StdString> allvars  = this->getVariables(path);
+    std::set<StdString> allcoords = this->getCoordVariables(path);
+
+    std::list<StdString>::const_iterator it = allvars.begin(), end = allvars.end();
+    for (; it != end; it++)
+    {
+      const StdString& var = *it;
+      if (this->isCoordinate(var, path)) continue;
+
+      if (!_isRecti && this->isRectilinear(var, path))  continue;
+      if (!_isCurvi && this->isCurvilinear(var, path))  continue;
+      if (!_isUnstr && this->isUnstructured(var, path)) continue;
+
+      if (!_isTemporal && this->isTemporal(var, path)) continue;
+      if (!_is3D       && this->is3Dim(var, path))     continue;
+      if (!_isCellData && this->isCellGrid(var, path)) continue;
+
+      if (this->isUnknown(var, path)) continue;
+
+      retvalue.push_back(var);
+    }
+    return retvalue;
+  }
+
+  //---------------------------------------------------------------
+
+  void CINetCDF4::getDataInfo(const StdString& var, const CVarPath* const path, StdSize record,
+                              std::vector<StdSize>& sstart, std::vector<StdSize>& scount, StdSize& array_size,
+                              const std::vector<StdSize>* start /*= NULL*/, const std::vector<StdSize>* count /*= NULL*/)
+  {
+    std::list<StdString> dimlist = this->getDimensionsList(&var, path);
+    std::map<StdString, StdSize> dimmap = this->getDimensions(&var, path);
+    std::list<StdString>::iterator it = dimlist.begin();
+    if (this->isTemporal(var, path))
+    {
+      if (record != UNLIMITED_DIM)
+        sstart.push_back(record);
+      else
+        sstart.push_back(0);
+      scount.push_back(1);
+      it++;
+    }
+    for (int i = 0; it != dimlist.end(); it++, i++)
+    {
+      if (start && count)
+      {
+        sstart.push_back((*start)[i]);
+        scount.push_back((*count)[i]);
+        array_size *= (*count)[i];
+      }
+      else
+      {
+        sstart.push_back(0);
+        scount.push_back(dimmap[*it]);
+        array_size *= dimmap[*it];
+      }
+    }
+  }
+
+  template <>
+  void CINetCDF4::getData(CArray<int, 1>& data, const StdString& var,
+                          const CVarPath* const path, StdSize record)
+  {
+
+    std::vector<StdSize> start, count;
+    int grpid = this->getGroup(path);
+    int varid = this->getVariable(var, path);
+    StdSize array_size = 1;
+    this->getDataInfo(var, path, record, start, count, array_size);
+    data.resize(array_size);
+    CheckError(nc_get_vara_int(grpid, varid, &(start[0]), &(count[0]), data.dataFirst()));
+  }
+
+  template <>
+  void CINetCDF4::getData(CArray<double, 1>& data, const StdString& var,
+                          const CVarPath* const path, StdSize record)
+  {
+    std::vector<StdSize> start, count;
+    int grpid = this->getGroup(path);
+    int varid = this->getVariable(var, path);
+    StdSize array_size = 1;
+    this->getDataInfo(var, path, record, start, count, array_size);
+    data.resize(array_size);
+    CheckError(nc_get_vara_double(grpid, varid, &(start[0]), &(count[0]), data.dataFirst()));
+  }
+
+  template <>
+  void CINetCDF4::getData(CArray<float, 1>& data, const StdString& var,
+                          const CVarPath* const path, StdSize record)
+  {
+    std::vector<StdSize> start, count;
+    int grpid = this->getGroup(path);
+    int varid = this->getVariable(var, path);
+    StdSize array_size = 1;
+    this->getDataInfo(var, path, record, start, count, array_size);
+    data.resize(array_size);
+    CheckError(nc_get_vara_float(grpid, varid, &(start[0]), &(count[0]), data.dataFirst()));
+  }
+
+  template <>
+  void CINetCDF4::getData(CArray<double, 1>& data, const StdString& var,
+                          bool collective, StdSize record,
+                          const std::vector<StdSize>* start /*= NULL*/,
+                          const std::vector<StdSize>* count /*= NULL*/)
+  {
+    int varid = this->getVariable(var);
+
+    if (this->mpi && collective)
+      CNetCdfInterface::varParAccess(ncidp, varid, NC_COLLECTIVE);
+    if (this->mpi && !collective)
+      CNetCdfInterface::varParAccess(ncidp, varid, NC_INDEPENDENT);
+
+    std::vector<StdSize> sstart, scount;
+    StdSize array_size = 1;
+    this->getDataInfo(var, NULL, record, sstart, scount, array_size, start, count);
+
+    if (data.numElements() != array_size)
+    {
+      ERROR("CONetCDF4::getData(...)",
+            << "[ Array size = " << data.numElements()
+            << ", Data size = "  << array_size
+            << " ] Invalid array size");
+    }
+
+    CheckError(nc_get_vara_double(ncidp, varid, &(sstart[0]), &(scount[0]), data.dataFirst()));
+  }
+
+  //---------------------------------------------------------------
+
+  StdString CINetCDF4::getLonCoordName(const StdString& varname,
+                                       const CVarPath* const path)
+  {
+    std::list<StdString> clist = this->getCoordinatesIdList(varname, path);
+    if (this->hasCoordinates(varname, path))
+      return (*clist.begin());
+    else
+      return (*clist.rbegin());
+  }
+
+  StdString CINetCDF4::getLatCoordName(const StdString& varname,
+                                       const CVarPath* const path)
+  {
+    std::list<StdString> clist = this->getCoordinatesIdList(varname, path);
+    if (this->hasCoordinates(varname, path))
+      return (*(++clist.begin()));
+    else
+      return (*(++clist.rbegin()));
+  }
+
+  StdString CINetCDF4::getVertCoordName(const StdString& varname,
+                                        const CVarPath* const path)
+  {
+    if (!this->is3Dim(varname, path)) return "";
+    std::list<StdString> clist = this->getCoordinatesIdList(varname, path);
+    if (this->hasCoordinates(varname, path))
+      return (*(++(++clist.begin())));
+    else
+      return (*(++(++clist.rbegin())));
+  }
+} // namespace xios
Index: XIOS/trunk/src/io/inetcdf4.hpp
===================================================================
--- XIOS/trunk/src/io/inetcdf4.hpp	(revision 685)
+++ XIOS/trunk/src/io/inetcdf4.hpp	(revision 685)
@@ -0,0 +1,212 @@
+#ifndef __XIOS_INETCDF4__
+#define __XIOS_INETCDF4__
+
+/// XIOS headers ///
+#include "xios_spl.hpp"
+#include "exception.hpp"
+#include "array_new.hpp"
+
+#include "mpi.hpp"
+#include "netcdf.hpp"
+
+#ifndef UNLIMITED_DIM
+#define UNLIMITED_DIM (size_t)(-1)
+#endif  // UNLIMITED_DIM
+
+namespace xios
+{
+  typedef std::vector<StdString> CVarPath;
+
+  class CINetCDF4
+  {
+    public:
+      /// Constructors ///
+      CINetCDF4(const StdString& filename, const MPI_Comm* comm = NULL, bool multifile = true);
+      CINetCDF4(const CINetCDF4& inetcdf4);       // Not implemented.
+      CINetCDF4(const CINetCDF4* const inetcdf4); // Not implemented.
+
+      //-------------------------------------------------------------
+
+      /// Destructor ///
+      virtual ~CINetCDF4(void);
+
+      //-------------------------------------------------------------
+
+      void close(void);
+
+      //-------------------------------------------------------------
+
+      /// Getters ///
+      StdSize getNbOfTimestep(const CVarPath* const path = NULL);
+
+      StdString getUnlimitedDimensionName(const CVarPath* const path = NULL);
+
+      StdString getCoordinatesId(const StdString& name, const CVarPath* const path = NULL);
+
+      StdString getBoundsId(const StdString& name, const CVarPath* const path = NULL);
+
+      StdString getLonCoordName(const StdString& varname, const CVarPath* const path = NULL);
+      StdString getLatCoordName(const StdString& varname, const CVarPath* const path = NULL);
+      StdString getVertCoordName(const StdString& varname, const CVarPath* const path = NULL);
+
+      std::set<StdString> getCoordVariables(const CVarPath* const path = NULL);
+      std::set<StdString> getBoundVariables(const CVarPath* const path = NULL);
+
+      std::list<StdString> getGroups   (const CVarPath* const path = NULL);
+      std::list<StdString> getVariables(const CVarPath* const path = NULL);
+
+      std::list<StdString> getDataVariables(bool _is3D       = true,
+                                            bool _isRecti    = true,
+                                            bool _isCurvi    = true,
+                                            bool _isUnstr    = true,
+                                            bool _isCellData = true,
+                                            bool _isTemporal = true,
+                                            const CVarPath* const path = NULL);
+
+      std::list<StdString> getAttributes(const StdString* const var  = NULL,
+                                         const CVarPath* const path = NULL);
+
+      std::list<StdString> getDimensionsList(const StdString* const var  = NULL,
+                                             const CVarPath* const path = NULL);
+
+      std::list<StdString> getCoordinatesIdList(const StdString& name,
+                                                const CVarPath* const path = NULL);
+
+      std::map<StdString, StdSize> getDimensions(const StdString* const var  = NULL,
+                                                 const CVarPath* const path = NULL);
+
+      StdSize getNbVertex(const StdString& name, const CVarPath* const path = NULL);
+
+      //-------------------------------------------------------------
+
+      template <class T>
+      T getMissingValue(const StdString& name, const CVarPath* const path = NULL);
+
+      template <class T>
+      T getAttributeValue(const StdString& name,
+                          const StdString* const var  = NULL,
+                          const CVarPath* const path = NULL);
+
+      template <class T>
+      void getData(CArray<T, 1>& data,
+                   const StdString& var,
+                   const CVarPath* const path = NULL,
+                   StdSize record = UNLIMITED_DIM);
+
+      template <class T>
+      void getData(CArray<T, 1>& data, const StdString& var,
+                   bool collective, StdSize record,
+                   const std::vector<StdSize>* start = NULL,
+                   const std::vector<StdSize>* count = NULL);
+
+      //-------------------------------------------------------------
+
+      /// Tests ///
+      bool hasMissingValue(const StdString& name, const CVarPath* const path = NULL);
+
+      bool hasAttribute(const StdString& name, const StdString* const var  = NULL, const CVarPath* const path = NULL);
+
+      bool hasVariable(const StdString& name, const CVarPath* const path = NULL);
+
+      bool hasCoordinates(const StdString& name, const CVarPath* const path = NULL);
+
+      bool hasTemporalDim(const CVarPath* const path = NULL);
+
+      bool hasBounds(const StdString& name, const CVarPath* const path = NULL);
+
+      //-------------------------------------------------------------
+
+      bool isBound(const StdString& name, const CVarPath* const path = NULL);
+      bool isCoordinate(const StdString& name, const CVarPath* const path = NULL);
+      bool isRectilinear(const StdString& name, const CVarPath* const path = NULL);
+      bool isCurvilinear(const StdString& name, const CVarPath* const path = NULL);
+      bool isUnknown(const StdString& name, const CVarPath* const path = NULL);
+      bool isUnstructured(const StdString& name, const CVarPath* const path = NULL);
+
+      bool isTemporal(const StdString& name, const CVarPath* const path = NULL);
+      bool is3Dim(const StdString& name, const CVarPath* const path = NULL);
+      bool isCellGrid(const StdString& name, const CVarPath* const path = NULL);
+
+    protected:
+      /// Getters ///
+      int getGroup   (const CVarPath* const path = NULL);
+      int getVariable(const StdString& varname, const CVarPath* const path = NULL);
+      int getDimension(const StdString& dimname, const CVarPath* const path = NULL);
+      int getUnlimitedDimension(const CVarPath* const path = NULL);
+      int getAttributeId(const StdString& name,
+                         const StdString* const var = NULL,
+                         const CVarPath* const path = NULL);
+
+      std::pair<nc_type , StdSize> getAttribute(const StdString& attname,
+                                                const StdString* const var  = NULL,
+                                                const CVarPath* const path = NULL);
+
+      //-------------------------------------------------------------
+
+      void getDataInfo(const StdString& var, const CVarPath* const path, StdSize record,
+                       std::vector<StdSize>& sstart, std::vector<StdSize>& scount, StdSize& array_size,
+                       const std::vector<StdSize>* start = NULL, const std::vector<StdSize>* count = NULL);
+
+    private:
+      /// VÃ©rification des erreurs NetCDF ///
+      static void CheckError(int status);
+
+      int ncidp; // Identifiant de fichier netcdf.
+      bool mpi; //< Whether parallel file access is used
+  }; // class CINetCDF4
+
+  ///--------------------------------------------------------------
+
+  template <>
+  StdString CINetCDF4::getAttributeValue(const StdString& name, const StdString* const var,
+                                         const CVarPath* const path);
+
+  template <>
+  std::vector<double> CINetCDF4::getAttributeValue(const StdString& name, const StdString* const var,
+                                                   const CVarPath* const path);
+
+  template <>
+  std::vector<float> CINetCDF4::getAttributeValue(const StdString& name, const StdString* const var,
+                                                  const CVarPath* const path);
+
+  template <>
+  std::vector<int> CINetCDF4::getAttributeValue(const StdString& name, const StdString* const var,
+                                                const CVarPath* const path);
+
+  template <>
+  std::vector<char> CINetCDF4::getAttributeValue(const StdString& name, const StdString* const var,
+                                                 const CVarPath* const path);
+
+  //---------------------------------------------------------------
+
+  template <>
+  int CINetCDF4::getMissingValue(const StdString& name, const CVarPath* const path);
+
+  template <>
+  double CINetCDF4::getMissingValue(const StdString& name, const CVarPath* const path);
+
+  template <>
+  float CINetCDF4::getMissingValue(const StdString& name, const CVarPath* const path);
+
+  //---------------------------------------------------------------
+
+  template <>
+  void CINetCDF4::getData(CArray<int, 1>& data, const StdString& var,
+                          const CVarPath* const path, StdSize record);
+
+  template <>
+  void CINetCDF4::getData(CArray<double, 1>& data, const StdString& var,
+                          const CVarPath* const path, StdSize record);
+
+  template <>
+  void CINetCDF4::getData(CArray<float, 1>& data, const StdString& var,
+                          const CVarPath* const path, StdSize record);
+
+  template <>
+  void CINetCDF4::getData(CArray<double, 1>& data, const StdString& var,
+                          bool collective, StdSize record,
+                          const std::vector<StdSize>* start /*= NULL*/,
+                          const std::vector<StdSize>* count /*= NULL*/);
+} // namespace xios
+
+#endif //__XIOS_INETCDF4__
Index: XIOS/trunk/src/io/nc4_data_input.cpp
===================================================================
--- XIOS/trunk/src/io/nc4_data_input.cpp	(revision 685)
+++ XIOS/trunk/src/io/nc4_data_input.cpp	(revision 685)
@@ -0,0 +1,90 @@
+#include "nc4_data_input.hpp"
+
+#include "context.hpp"
+#include "context_server.hpp"
+
+namespace xios
+{
+  CNc4DataInput::CNc4DataInput(const StdString& filename, MPI_Comm comm_file, bool multifile, bool isCollective /*= true*/)
+    : SuperClass()
+    , SuperClassWriter(filename, &comm_file, multifile)
+    , comm_file(comm_file)
+    , filename(filename)
+    , isCollective(isCollective)
+  {
+    SuperClass::type = multifile ? MULTI_FILE : ONE_FILE;
+  }
+
+  CNc4DataInput::~CNc4DataInput(void)
+  { /* Nothing more to do */ }
+
+  StdSize CNc4DataInput::getFieldNbRecords_(CField* field)
+  {
+    StdString fieldId = !field->name.isEmpty() ? field->name.getValue() : field->getBaseFieldReference()->getId();
+
+    if (SuperClassWriter::isTemporal(fieldId))
+    {
+      return SuperClassWriter::getDimensions(&fieldId)[SuperClassWriter::getUnlimitedDimensionName()];
+    }
+
+    return 1;
+  }
+
+  void CNc4DataInput::readFieldData_(CField* field)
+  {
+    CContext* context = CContext::getCurrent();
+    CContextServer* server = context->server;
+
+    CGrid* grid = field->grid;
+
+    if (!grid->doGridHaveDataToWrite())
+      if (SuperClass::type==MULTI_FILE || !isCollective) return;
+
+    StdString fieldId = !field->name.isEmpty() ? field->name.getValue() : field->getBaseFieldReference()->getId();
+
+    CArray<double,1> fieldData(grid->getWrittenDataSize());
+    if (!field->default_value.isEmpty()) fieldData = field->default_value;
+
+    switch (SuperClass::type)
+    {
+      case MULTI_FILE:
+        SuperClassWriter::getData(fieldData, fieldId, isCollective, field->getNStep() - 1);
+        break;
+      case ONE_FILE:
+      {
+        std::vector<int> nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal();
+        std::vector<int> nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer();
+        std::vector<int> nZoomSizeServer  = grid->getDistributionServer()->getZoomSizeServer();
+
+        int ssize = nZoomBeginGlobal.size();
+
+        std::vector<StdSize> start(ssize);
+        std::vector<StdSize> count(ssize);
+
+        for (int i = 0; i < ssize; ++i)
+        {
+          start[i] = nZoomBeginServer[ssize - i - 1] - nZoomBeginGlobal[ssize - i - 1];
+          count[i] = nZoomSizeServer[ssize - i - 1];
+        }
+
+        SuperClassWriter::getData(fieldData, fieldId, isCollective, field->getNStep() - 1, &start, &count);
+        break;
+      }
+    }
+
+    field->inputField(fieldData);
+
+    if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty())
+    {
+      double scaleFactor = 1.0, addOffset = 0.0;
+      if (!field->scale_factor.isEmpty()) scaleFactor = field->scale_factor;
+      if (!field->add_offset.isEmpty()) addOffset = field->add_offset;
+      field->invertScaleFactorAddOffset(scaleFactor, addOffset);
+    }
+  }
+
+  void CNc4DataInput::closeFile_(void)
+  {
+    SuperClassWriter::close();
+  }
+} // namespace xios
Index: XIOS/trunk/src/io/nc4_data_input.hpp
===================================================================
--- XIOS/trunk/src/io/nc4_data_input.hpp	(revision 685)
+++ XIOS/trunk/src/io/nc4_data_input.hpp	(revision 685)
@@ -0,0 +1,45 @@
+#ifndef __XIOS_NC4_DATA_INPUT__
+#define __XIOS_NC4_DATA_INPUT__
+
+/// XIOS headers ///
+#include "xios_spl.hpp"
+#include "data_input.hpp"
+#include "inetcdf4.hpp"
+
+namespace xios
+{
+  class CNc4DataInput
+    : protected CINetCDF4
+    , public virtual CDataInput
+  {
+  public:
+    /// Type definitions ///
+    typedef CINetCDF4  SuperClassWriter;
+    typedef CDataInput SuperClass;
+
+    /// Constructors ///
+    CNc4DataInput(const StdString& filename, MPI_Comm comm_file, bool multifile, bool isCollective = true);
+    CNc4DataInput(const CNc4DataInput& dataInput);       // Not implemented.
+    CNc4DataInput(const CNc4DataInput* const dataInput); // Not implemented.
+
+    /// Destructor ///
+    virtual ~CNc4DataInput(void);
+
+    /// Getters ///
+    const StdString& getFileName(void) const;
+
+  protected:
+    // Read methods
+    virtual StdSize getFieldNbRecords_(CField* field);
+    virtual void readFieldData_(CField* field);
+    virtual void closeFile_(void);
+
+  private:
+    /// Private attributes ///
+    MPI_Comm comm_file;
+    const StdString filename;
+    bool isCollective;
+  }; // class CNc4DataInput
+} // namespace xios
+
+#endif //__XIOS_NC4_DATA_INPUT__
Index: XIOS/trunk/src/io/nc4_data_output.cpp
===================================================================
--- XIOS/trunk/src/io/nc4_data_output.cpp	(revision 685)
+++ XIOS/trunk/src/io/nc4_data_output.cpp	(revision 685)
@@ -0,0 +1,1895 @@
+
+#include "nc4_data_output.hpp"
+
+#include <boost/lexical_cast.hpp>
+#include "attribute_template.hpp"
+#include "group_template.hpp"
+
+#include "file.hpp"
+#include "calendar.hpp"
+#include "context.hpp"
+#include "context_server.hpp"
+#include "netCdfException.hpp"
+#include "exception.hpp"
+
+namespace xios
+{
+      /// ////////////////////// DÃ©finitions ////////////////////// ///
+      CNc4DataOutput::CNc4DataOutput
+         (const StdString & filename, bool exist)
+            : SuperClass()
+            , SuperClassWriter(filename, exist)
+            , filename(filename)
+      {
+         StdString timeid = StdString("time_counter");
+         SuperClass::type = MULTI_FILE;
+//         if (!exist)
+//            SuperClassWriter::addDimension(timeid);
+      }
+
+      CNc4DataOutput::CNc4DataOutput
+         (const StdString & filename, bool exist, bool useClassicFormat,
+          MPI_Comm comm_file,bool multifile, bool isCollective)
+            : SuperClass()
+            , SuperClassWriter(filename, exist, useClassicFormat, &comm_file, multifile)
+            , comm_file(comm_file)
+            , filename(filename)
+            , isCollective(isCollective)
+      {
+         StdString timeid = StdString("time_counter");
+
+         SuperClass::type = (multifile) ? MULTI_FILE : ONE_FILE;
+
+ //        if (!exist)
+//            SuperClassWriter::addDimension(timeid);
+      }
+
+
+      CNc4DataOutput::~CNc4DataOutput(void)
+      { /* Ne rien faire de plus */ }
+
+      ///--------------------------------------------------------------
+
+      const StdString & CNc4DataOutput::getFileName(void) const
+      {
+         return (this->filename);
+      }
+
+      //---------------------------------------------------------------
+
+      void CNc4DataOutput::writeDomain_(CDomain* domain)
+      {
+         if (domain->type == CDomain::type_attr::unstructured)
+         {
+           writeUnstructuredDomain(domain) ;
+           return ;
+         }
+
+         CContext* context = CContext::getCurrent() ;
+         CContextServer* server=context->server ;
+
+         if (domain->IsWritten(this->filename)) return;
+         domain->checkAttributes();
+
+         if (domain->isEmpty())
+           if (SuperClass::type==MULTI_FILE) return ;
+
+         std::vector<StdString> dim0, dim1;
+         StdString domid     = (!domain->name.isEmpty())
+                             ? domain->name.getValue() : domain->getId();
+         StdString appendDomid  = (singleDomain) ? "" : "_"+domid ;
+
+
+         StdString dimXid, dimYid ;
+
+         bool isRegularDomain = (domain->type == CDomain::type_attr::rectilinear);
+         switch (domain->type)
+         {
+           case CDomain::type_attr::curvilinear :
+             dimXid     = StdString("x").append(appendDomid);
+             dimYid     = StdString("y").append(appendDomid);
+             break ;
+           case CDomain::type_attr::rectilinear :
+             dimXid     = StdString("lon").append(appendDomid);
+             dimYid     = StdString("lat").append(appendDomid);
+             break;
+         }
+
+         StdString dimVertId = StdString("nvertex").append(appendDomid);
+
+         string lonid,latid,bounds_lonid,bounds_latid ;
+         string areaId = "area" + appendDomid;
+/*
+         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;
+*/
+
+         try
+         {
+           switch (SuperClass::type)
+           {
+              case (MULTI_FILE) :
+              {
+  //               if (domain->isEmpty()) return;
+
+                 if (server->intraCommSize > 1)
+                 {
+  //                 SuperClassWriter::addDimension(lonid, domain->zoom_ni.getValue());
+  //                 SuperClassWriter::addDimension(latid, domain->zoom_nj.getValue());
+                 }
+
+                 switch (domain->type)
+                 {
+                   case CDomain::type_attr::curvilinear :
+                     dim0.push_back(dimYid); dim0.push_back(dimXid);
+                     lonid = StdString("nav_lon").append(appendDomid);
+                     latid = StdString("nav_lat").append(appendDomid);
+                     break ;
+                   case CDomain::type_attr::rectilinear :
+                     lonid = StdString("lon").append(appendDomid);
+                     latid = StdString("lat").append(appendDomid);
+                     dim0.push_back(dimYid);
+                     dim1.push_back(dimXid);
+                     break;
+                 }
+
+                 bounds_lonid = StdString("bounds_lon").append(appendDomid);
+                 bounds_latid = StdString("bounds_lat").append(appendDomid);
+
+                 SuperClassWriter::addDimension(dimXid, domain->zoom_ni_srv);
+                 SuperClassWriter::addDimension(dimYid, domain->zoom_nj_srv);
+
+                 if (domain->hasBounds)
+                   SuperClassWriter::addDimension(dimVertId, domain->nvertex);
+
+                 if (server->intraCommSize > 1)
+                 {
+                   this->writeLocalAttributes(domain->zoom_ibegin_srv,
+                                              domain->zoom_ni_srv,
+                                              domain->zoom_jbegin_srv,
+                                              domain->zoom_nj_srv,
+                                              appendDomid);
+
+                   if (singleDomain)
+                    this->writeLocalAttributes_IOIPSL(dimXid, dimYid,
+                                                      domain->zoom_ibegin_srv,
+                                                      domain->zoom_ni_srv,
+                                                      domain->zoom_jbegin_srv,
+                                                      domain->zoom_nj_srv,
+                                                      domain->ni_glo,domain->nj_glo,
+                                                      server->intraCommRank,server->intraCommSize);
+                 }
+
+                 if (domain->hasLonLat)
+                 {
+                   switch (domain->type)
+                   {
+                     case CDomain::type_attr::curvilinear :
+                       SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
+                       SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0);
+                       break ;
+                      case CDomain::type_attr::rectilinear :
+                        SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
+                        SuperClassWriter::addVariable(lonid, NC_FLOAT, dim1);
+                        break ;
+                   }
+
+                   this->writeAxisAttributes(lonid, isRegularDomain ? "X" : "", "longitude", "Longitude", "degrees_east", domid);
+                   this->writeAxisAttributes(latid, isRegularDomain ? "Y" : "", "latitude", "Latitude", "degrees_north", domid);
+
+                   if (domain->hasBounds)
+                   {
+                     SuperClassWriter::addAttribute("bounds", bounds_lonid, &lonid);
+                     SuperClassWriter::addAttribute("bounds", bounds_latid, &latid);
+
+                     dim0.clear();
+                     dim0.push_back(dimYid);
+                     dim0.push_back(dimXid);
+                     dim0.push_back(dimVertId);
+                     SuperClassWriter::addVariable(bounds_lonid, NC_FLOAT, dim0);
+                     SuperClassWriter::addVariable(bounds_latid, NC_FLOAT, dim0);
+                   }
+                 }
+
+                 dim0.clear();
+                 dim0.push_back(dimYid);
+                 dim0.push_back(dimXid);
+
+
+  // supress mask               if (server->intraCommSize > 1)
+  // supress mask               {
+  // supress mask                  SuperClassWriter::addVariable(maskid, NC_INT, dim0);
+  // supress mask
+  // supress mask                  this->writeMaskAttributes(maskid,
+  // supress mask                     domain->data_dim.getValue()/*,
+  // supress mask                     domain->data_ni.getValue(),
+  // supress mask                     domain->data_nj.getValue(),
+  // supress mask                     domain->data_ibegin.getValue(),
+  // supress mask                     domain->data_jbegin.getValue()*/);
+  // supress mask               }
+
+                 //SuperClassWriter::setDefaultValue(maskid, &dvm);
+
+                 if (domain->hasArea)
+                 {
+                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0);
+                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId);
+                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId);
+                 }
+
+                 SuperClassWriter::definition_end();
+
+                 if (domain->hasLonLat)
+                 {
+                   switch (domain->type)
+                   {
+                     case CDomain::type_attr::curvilinear :
+                       SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0);
+                       SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0);
+                       break;
+                     case CDomain::type_attr::rectilinear :
+                       CArray<double,1> lat = domain->latvalue_srv(Range(fromStart,toEnd,domain->zoom_ni_srv)) ;
+                       SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0);
+                       CArray<double,1> lon=domain->lonvalue_srv(Range(0,domain->zoom_ni_srv-1)) ;
+                       SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0);
+                       break;
+                   }
+
+                   if (domain->hasBounds)
+                   {
+                     SuperClassWriter::writeData(domain->bounds_lon_srv, bounds_lonid, isCollective, 0);
+                     SuperClassWriter::writeData(domain->bounds_lat_srv, bounds_latid, isCollective, 0);
+                   }
+                 }
+
+                 if (domain->hasArea)
+                   SuperClassWriter::writeData(domain->area_srv, areaId, isCollective, 0);
+
+                 SuperClassWriter::definition_start();
+
+                 break;
+              }
+              case (ONE_FILE) :
+              {
+                 SuperClassWriter::addDimension(dimXid, domain->global_zoom_ni);
+                 SuperClassWriter::addDimension(dimYid, domain->global_zoom_nj);
+
+                 if (domain->hasBounds)
+                   SuperClassWriter::addDimension(dimVertId, domain->nvertex);
+
+                 if (domain->hasLonLat)
+                 {
+                   switch (domain->type)
+                   {
+                     case CDomain::type_attr::curvilinear :
+                       dim0.push_back(dimYid); dim0.push_back(dimXid);
+                       lonid = StdString("nav_lon").append(appendDomid);
+                       latid = StdString("nav_lat").append(appendDomid);
+                       SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
+                       SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0);
+                       break;
+
+                     case CDomain::type_attr::rectilinear :
+                       dim0.push_back(dimYid);
+                       dim1.push_back(dimXid);
+                       lonid = StdString("lon").append(appendDomid);
+                       latid = StdString("lat").append(appendDomid);
+                       SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
+                       SuperClassWriter::addVariable(lonid, NC_FLOAT, dim1);
+                       break;
+                   }
+
+                   bounds_lonid = StdString("bounds_lon").append(appendDomid);
+                   bounds_latid = StdString("bounds_lat").append(appendDomid);
+
+                   this->writeAxisAttributes
+                      (lonid, isRegularDomain ? "X" : "", "longitude", "Longitude", "degrees_east", domid);
+                   this->writeAxisAttributes
+                      (latid, isRegularDomain ? "Y" : "", "latitude", "Latitude", "degrees_north", domid);
+
+                   if (domain->hasBounds)
+                   {
+                     SuperClassWriter::addAttribute("bounds", bounds_lonid, &lonid);
+                     SuperClassWriter::addAttribute("bounds", bounds_latid, &latid);
+
+                     dim0.clear();
+                     dim0.push_back(dimYid);
+                     dim0.push_back(dimXid);
+                     dim0.push_back(dimVertId);
+                     SuperClassWriter::addVariable(bounds_lonid, NC_FLOAT, dim0);
+                     SuperClassWriter::addVariable(bounds_latid, NC_FLOAT, dim0);
+                   }
+                 }
+
+                 if (domain->hasArea)
+                 {
+                   dim0.clear();
+                   dim0.push_back(dimYid); dim0.push_back(dimXid);
+                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0);
+                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId);
+                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId);
+                   dim0.clear();
+                 }
+
+                 SuperClassWriter::definition_end();
+
+                 switch (domain->type)
+                 {
+                   case CDomain::type_attr::curvilinear :
+                   {
+                     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->global_zoom_ibegin;
+                       start[0]=domain->zoom_jbegin_srv-domain->global_zoom_jbegin;
+                       count[1]=domain->zoom_ni_srv ; count[0]=domain->zoom_nj_srv ;
+                     }
+
+                     if (domain->hasLonLat)
+                     {
+                       SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0,&start,&count);
+                       SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0,&start,&count);
+                     }
+                     break;
+                   }
+                   case CDomain::type_attr::rectilinear :
+                   {
+                     if (domain->hasLonLat)
+                     {
+                       std::vector<StdSize> start(1) ;
+                       std::vector<StdSize> count(1) ;
+                       if (domain->isEmpty())
+                       {
+                         start[0]=0 ;
+                         count[0]=0 ;
+                         SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0,&start,&count);
+                         SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0,&start,&count);
+
+                       }
+                       else
+                       {
+                         start[0]=domain->zoom_jbegin_srv-domain->global_zoom_jbegin;
+                         count[0]=domain->zoom_nj_srv ;
+                         CArray<double,1> lat = domain->latvalue_srv(Range(fromStart,toEnd,domain->zoom_ni_srv)) ;
+                         SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0,&start,&count);
+
+                         start[0]=domain->zoom_ibegin_srv-domain->global_zoom_ibegin;
+                         count[0]=domain->zoom_ni_srv ;
+                         CArray<double,1> lon=domain->lonvalue_srv(Range(0,domain->zoom_ni_srv-1)) ;
+                         SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0,&start,&count);
+                       }
+                     }
+                     break;
+                   }
+                 }
+
+                 if (domain->hasBounds)
+                 {
+                   std::vector<StdSize> start(3);
+                   std::vector<StdSize> count(3);
+                   if (domain->isEmpty())
+                   {
+                     start[2] = start[1] = start[0] = 0;
+                     count[2] = count[1] = count[0] = 0;
+                   }
+                   else
+                   {
+                     start[2] = 0;
+                     start[1] = domain->zoom_ibegin_srv - domain->global_zoom_ibegin;
+                     start[0] = domain->zoom_jbegin_srv - domain->global_zoom_jbegin;
+                     count[2] = domain->nvertex;
+                     count[1] = domain->zoom_ni_srv;
+                     count[0] = domain->zoom_nj_srv;
+                   }
+
+                   SuperClassWriter::writeData(domain->bounds_lon_srv, bounds_lonid, isCollective, 0, &start, &count);
+                   SuperClassWriter::writeData(domain->bounds_lat_srv, bounds_latid, isCollective, 0, &start, &count);
+                 }
+
+                 if (domain->hasArea)
+                 {
+                   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->global_zoom_ibegin;
+                     start[0] = domain->zoom_jbegin_srv - domain->global_zoom_jbegin;
+                     count[1] = domain->zoom_ni_srv;
+                     count[0] = domain->zoom_nj_srv;
+                   }
+
+                   SuperClassWriter::writeData(domain->area_srv, areaId, isCollective, 0, &start, &count);
+                 }
+
+                 SuperClassWriter::definition_start();
+                 break;
+              }
+              default :
+                 ERROR("CNc4DataOutput::writeDomain(domain)",
+                       << "[ type = " << SuperClass::type << "]"
+                       << " not implemented yet !");
+           }
+         }
+         catch (CNetCdfException& e)
+         {
+           StdString msg("On writing the domain : ");
+           msg.append(domid); msg.append("\n");
+           msg.append("In the context : ");
+           msg.append(context->getId()); msg.append("\n");
+           msg.append(e.what());
+           ERROR("CNc4DataOutput::writeDomain_(CDomain* domain)", << msg);
+         }
+
+         domain->addRelFile(this->filename);
+      }
+
+      void CNc4DataOutput::writeUnstructuredDomain(CDomain* domain)
+      {
+         CContext* context = CContext::getCurrent() ;
+         CContextServer* server=context->server ;
+
+         if (domain->IsWritten(this->filename)) return;
+         domain->checkAttributes();
+
+         if (domain->isEmpty())
+           if (SuperClass::type==MULTI_FILE) return ;
+
+         std::vector<StdString> dim0, dim1;
+         StdString domid     = (!domain->name.isEmpty())
+                             ? domain->name.getValue() : domain->getId();
+         StdString appendDomid  = (singleDomain) ? "" : "_"+domid ;
+
+
+         StdString dimXid = StdString("cell").append(appendDomid);
+         StdString dimVertId = StdString("nvertex").append(appendDomid);
+
+         string lonid,latid,bounds_lonid,bounds_latid ;
+         string areaId = "area" + appendDomid;
+
+         try
+         {
+           switch (SuperClass::type)
+           {
+              case (MULTI_FILE) :
+              {
+                 dim0.push_back(dimXid);
+                 SuperClassWriter::addDimension(dimXid, domain->zoom_ni_srv);
+
+                 lonid = StdString("lon").append(appendDomid);
+                 latid = StdString("lat").append(appendDomid);
+                 bounds_lonid = StdString("bounds_lon").append(appendDomid);
+                 bounds_latid = StdString("bounds_lat").append(appendDomid);
+                 if (domain->hasLonLat)
+                 {
+                   SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
+                   SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0);
+                   this->writeAxisAttributes(lonid, "", "longitude", "Longitude", "degrees_east", domid);
+                   if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_lonid, &lonid);
+                   this->writeAxisAttributes(latid, "", "latitude", "Latitude", "degrees_north", domid);
+                   if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_latid, &latid);
+                   if (domain->hasBounds) SuperClassWriter::addDimension(dimVertId, domain->nvertex);
+                 }
+
+                 dim0.clear();
+                 if (domain->hasBounds)
+                 {
+                   dim0.push_back(dimXid);
+                   dim0.push_back(dimVertId);
+                   SuperClassWriter::addVariable(bounds_lonid, NC_FLOAT, dim0);
+                   SuperClassWriter::addVariable(bounds_latid, NC_FLOAT, dim0);
+                 }
+
+                 dim0.clear();
+                 dim0.push_back(dimXid);
+                 if (domain->hasArea)
+                 {
+                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0);
+                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId);
+                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId);
+                 }
+
+                 SuperClassWriter::definition_end();
+
+                 if (domain->hasLonLat)
+                 {
+                   SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0);
+                   SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0);
+                   if (domain->hasBounds)
+                   {
+                     SuperClassWriter::writeData(domain->bounds_lon_srv, bounds_lonid, isCollective, 0);
+                     SuperClassWriter::writeData(domain->bounds_lat_srv, bounds_latid, isCollective, 0);
+                   }
+                 }
+
+                 if (domain->hasArea)
+                   SuperClassWriter::writeData(domain->area_srv, areaId, isCollective, 0);
+
+                 SuperClassWriter::definition_start();
+                 break ;
+              }
+
+              case (ONE_FILE) :
+              {
+                 lonid = StdString("lon").append(appendDomid);
+                 latid = StdString("lat").append(appendDomid);
+                 bounds_lonid = StdString("bounds_lon").append(appendDomid);
+                 bounds_latid = StdString("bounds_lat").append(appendDomid);
+                 dim0.push_back(dimXid);
+                 SuperClassWriter::addDimension(dimXid, domain->nj_glo);
+                 if (domain->hasLonLat)
+                 {
+                   SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
+                   SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0);
+
+                   this->writeAxisAttributes(lonid, "", "longitude", "Longitude", "degrees_east", domid);
+                   if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_lonid, &lonid);
+                   this->writeAxisAttributes(latid, "", "latitude", "Latitude", "degrees_north", domid);
+                   if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_latid, &latid);
+                   if (domain->hasBounds) SuperClassWriter::addDimension(dimVertId, domain->nvertex);
+                 }
+                 dim0.clear();
+
+                 if (domain->hasBounds)
+                 {
+                   dim0.push_back(dimXid);
+                   dim0.push_back(dimVertId);
+                   SuperClassWriter::addVariable(bounds_lonid, NC_FLOAT, dim0);
+                   SuperClassWriter::addVariable(bounds_latid, NC_FLOAT, dim0);
+                 }
+
+                 if (domain->hasArea)
+                 {
+                   dim0.clear();
+                   dim0.push_back(dimXid);
+                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0);
+                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId);
+                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId);
+                 }
+
+                 SuperClassWriter::definition_end();
+
+                 std::vector<StdSize> start(1), startBounds(2) ;
+                 std::vector<StdSize> count(1), countBounds(2) ;
+                 if (domain->isEmpty())
+                 {
+                   start[0]=0 ;
+                   count[0]=0 ;
+                   startBounds[1]=0 ;
+                   countBounds[1]=domain->nvertex ;
+                   startBounds[0]=0 ;
+                   countBounds[0]=0 ;
+                 }
+                 else
+                 {
+                   start[0]=domain->zoom_jbegin_srv-domain->global_zoom_jbegin;
+                   count[0]=domain->zoom_nj_srv ;
+                   startBounds[0]=domain->zoom_jbegin_srv-domain->global_zoom_jbegin;
+                   startBounds[1]=0 ;
+                   countBounds[0]=domain->zoom_nj_srv ;
+                   countBounds[1]=domain->nvertex ;
+                 }
+
+                 if (domain->hasLonLat)
+                 {
+                   SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0,&start,&count);
+                   SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0,&start,&count);
+                   if (domain->hasBounds)
+                   {
+                     SuperClassWriter::writeData(domain->bounds_lon_srv, bounds_lonid, isCollective, 0,&startBounds,&countBounds);
+                     SuperClassWriter::writeData(domain->bounds_lat_srv, bounds_latid, isCollective, 0,&startBounds,&countBounds);
+                   }
+                 }
+
+                 if (domain->hasArea)
+                   SuperClassWriter::writeData(domain->area_srv, areaId, isCollective, 0, &start, &count);
+
+                 SuperClassWriter::definition_start();
+
+                 break;
+              }
+              default :
+                 ERROR("CNc4DataOutput::writeDomain(domain)",
+                       << "[ type = " << SuperClass::type << "]"
+                       << " not implemented yet !");
+           }
+         }
+         catch (CNetCdfException& e)
+         {
+           StdString msg("On writing the domain : ");
+           msg.append(domid); msg.append("\n");
+           msg.append("In the context : ");
+           msg.append(context->getId()); msg.append("\n");
+           msg.append(e.what());
+           ERROR("CNc4DataOutput::writeUnstructuredDomain(CDomain* domain)", << msg);
+         }
+         domain->addRelFile(this->filename);
+      }
+      //--------------------------------------------------------------
+
+      void CNc4DataOutput::writeAxis_(CAxis* axis)
+      {
+        if (axis->IsWritten(this->filename)) return;
+        axis->checkAttributes();
+        int zoom_size_srv  = axis->zoom_size_srv;
+        int zoom_begin_srv = axis->zoom_begin_srv;
+        int zoom_size  = (MULTI_FILE == SuperClass::type) ? zoom_size_srv
+                                                              : axis->global_zoom_size;
+        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;
+        StdString axisid = !axis->name.isEmpty() ? axis->name.getValue() : axis->getId();
+        try
+        {
+          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:
+            {
+              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())
+              {
+                CArray<double,2> axisBounds(2, zoom_size_srv);
+                for (int i = 0; i < zoom_size_srv; ++i)
+                {
+                  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, &start, &count);
+              }
+
+              SuperClassWriter::definition_start();
+
+              break;
+            }
+            default :
+              ERROR("CNc4DataOutput::writeDomain(domain)",
+                    << "[ 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);
+        }
+        axis->addRelFile(this->filename);
+     }
+
+     //--------------------------------------------------------------
+
+     void CNc4DataOutput::writeGridCompressed_(CGrid* grid)
+     {
+       if (grid->isScalarGrid() || grid->isWrittenCompressed(this->filename)) return;
+
+       try
+       {
+         CArray<bool,1> axisDomainOrder = grid->axis_domain_order;
+         std::vector<StdString> domainList = grid->getDomainList();
+         std::vector<StdString> axisList   = grid->getAxisList();
+         int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0;
+
+         std::vector<StdString> dims;
+
+         if (grid->isCompressible())
+         {
+           StdString varId = grid->getId() + "_points";
+
+           int nbIndexes = (SuperClass::type == MULTI_FILE) ? grid->getNumberWrittenIndexes() : grid->getTotalNumberWrittenIndexes();
+           SuperClassWriter::addDimension(varId, nbIndexes);
+
+           dims.push_back(varId);
+           SuperClassWriter::addVariable(varId, NC_INT, dims);
+
+           StdOStringStream compress;
+           for (int i = numElement - 1; i >= 0; --i)
+           {
+             if (axisDomainOrder(i))
+             {
+               CDomain* domain = CDomain::get(domainList[domainList.size() - idxDomain - 1]);
+               StdString domId = !domain->name.isEmpty() ? domain->name.getValue() : domain->getId();
+               StdString appendDomId  = singleDomain ? "" : "_" + domId;
+
+               switch (domain->type)
+               {
+                 case CDomain::type_attr::curvilinear:
+                   compress << "y" << appendDomId << " x" << appendDomId;
+                   break;
+                 case CDomain::type_attr::rectilinear:
+                   compress << "lat" << appendDomId << " lon" << appendDomId;
+                   break;
+                 case CDomain::type_attr::unstructured:
+                   compress << "cell" << appendDomId;
+                   break;
+               }
+               ++idxDomain;
+             }
+             else
+             {
+               CAxis* axis = CAxis::get(axisList[axisList.size() - idxAxis - 1]);
+               compress << (!axis->name.isEmpty() ? axis->name.getValue() : axis->getId());
+               ++idxAxis;
+             }
+
+             if (i != 0) compress << ' ';
+           }
+           SuperClassWriter::addAttribute("compress", compress.str(), &varId);
+
+           grid->computeCompressedIndex();
+
+           CArray<int, 1> indexes(grid->getNumberWrittenIndexes());
+           std::map<int, CArray<size_t, 1> >::const_iterator it;
+           for (it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it)
+           {
+             const CArray<size_t, 1> compressedIndexes = grid->compressedOutIndexFromClient[it->first];
+             for (int i = 0; i < it->second.numElements(); i++)
+               indexes(compressedIndexes(i)) = it->second(i);
+           }
+
+           switch (SuperClass::type)
+           {
+             case (MULTI_FILE):
+             {
+               SuperClassWriter::writeData(indexes, varId, isCollective, 0);
+               break;
+             }
+             case (ONE_FILE):
+             {
+               if (grid->doGridHaveDataDistributed())
+                 grid->getDistributionServer()->computeGlobalIndex(indexes);
+
+               std::vector<StdSize> start, count;
+               start.push_back(grid->getOffsetWrittenIndexes());
+               count.push_back(grid->getNumberWrittenIndexes());
+
+               SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count);
+               break;
+             }
+           }
+         }
+         else
+         {
+           for (int i = 0; i < numElement; ++i)
+           {
+             StdString varId, compress;
+             CArray<int, 1> indexes;
+             bool isDistributed;
+             StdSize nbIndexes, totalNbIndexes, offset;
+             int firstGlobalIndex;
+
+             if (axisDomainOrder(i))
+             {
+               CDomain* domain = CDomain::get(domainList[idxDomain]);
+               if (!domain->isCompressible()
+                    || domain->type == CDomain::type_attr::unstructured
+                    || domain->isWrittenCompressed(this->filename))
+                 continue;
+
+               StdString domId = !domain->name.isEmpty() ? domain->name.getValue() : domain->getId();
+               StdString appendDomId  = singleDomain ? "" : "_" + domId;
+
+               varId = domId + "_points";
+               switch (domain->type)
+               {
+                 case CDomain::type_attr::curvilinear:
+                   compress = "y" + appendDomId + " x" + appendDomId;
+                   break;
+                 case CDomain::type_attr::rectilinear:
+                   compress = "lat" + appendDomId + " lon" + appendDomId;
+                   break;
+               }
+
+               const std::vector<int>& indexesToWrite = domain->getIndexesToWrite();
+               indexes.resize(indexesToWrite.size());
+               for (int n = 0; n < indexes.numElements(); ++n)
+                 indexes(n) = indexesToWrite[n];
+
+               isDistributed = domain->isDistributed();
+               nbIndexes = domain->getNumberWrittenIndexes();
+               totalNbIndexes = domain->getTotalNumberWrittenIndexes();
+               offset = domain->getOffsetWrittenIndexes();
+               firstGlobalIndex = domain->ibegin + domain->jbegin * domain->ni_glo;
+
+               domain->addRelFileCompressed(this->filename);
+               ++idxDomain;
+             }
+             else
+             {
+               CAxis* axis = CAxis::get(axisList[idxAxis]);
+               if (!axis->isCompressible() || axis->isWrittenCompressed(this->filename))
+                 continue;
+
+               StdString axisId = !axis->name.isEmpty() ? axis->name.getValue() : axis->getId();
+               varId = axisId + "_points";
+               compress = axisId;
+
+               const std::vector<int>& indexesToWrite = axis->getIndexesToWrite();
+               indexes.resize(indexesToWrite.size());
+               for (int n = 0; n < indexes.numElements(); ++n)
+                 indexes(n) = indexesToWrite[n];
+
+               isDistributed = axis->isDistributed();
+               nbIndexes = axis->getNumberWrittenIndexes();
+               totalNbIndexes = axis->getTotalNumberWrittenIndexes();
+               offset = axis->getOffsetWrittenIndexes();
+               firstGlobalIndex = axis->begin;
+
+               axis->addRelFileCompressed(this->filename);
+               ++idxAxis;
+             }
+
+             if (!varId.empty())
+             {
+               SuperClassWriter::addDimension(varId, (SuperClass::type == MULTI_FILE) ? nbIndexes : totalNbIndexes);
+
+               dims.clear();
+               dims.push_back(varId);
+               SuperClassWriter::addVariable(varId, NC_INT, dims);
+
+               SuperClassWriter::addAttribute("compress", compress, &varId);
+
+               switch (SuperClass::type)
+               {
+                 case (MULTI_FILE):
+                 {
+                   indexes -= firstGlobalIndex;
+                   SuperClassWriter::writeData(indexes, varId, isCollective, 0);
+                   break;
+                 }
+                 case (ONE_FILE):
+                 {
+                   std::vector<StdSize> start, count;
+                   start.push_back(offset);
+                   count.push_back(nbIndexes);
+
+                   SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count);
+                   break;
+                 }
+               }
+             }
+           }
+
+           if (!dims.empty())
+             grid->computeCompressedIndex();
+         }
+
+         grid->addRelFileCompressed(this->filename);
+       }
+       catch (CNetCdfException& e)
+       {
+         StdString msg("On writing compressed grid : ");
+         msg.append(grid->getId()); 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::writeGridCompressed_(CGrid* grid)", << msg);
+       }
+     }
+
+     //--------------------------------------------------------------
+
+     void CNc4DataOutput::writeTimeDimension_(void)
+     {
+       try
+       {
+        SuperClassWriter::addDimension("time_counter");
+       }
+       catch (CNetCdfException& e)
+       {
+         StdString msg("On writing time dimension : time_couter\n");
+         msg.append("In the context : ");
+         CContext* context = CContext::getCurrent() ;
+         msg.append(context->getId()); msg.append("\n");
+         msg.append(e.what());
+         ERROR("CNc4DataOutput::writeTimeDimension_(void)", << msg);
+       }
+     }
+
+      //--------------------------------------------------------------
+
+      void CNc4DataOutput::writeField_(CField* field)
+      {
+         CContext* context = CContext::getCurrent() ;
+         CContextServer* server=context->server ;
+
+         std::vector<StdString> dims, coodinates;
+         CGrid* grid = field->grid;
+         if (!grid->doGridHaveDataToWrite())
+          if (SuperClass::type==MULTI_FILE) return ;
+
+         CArray<bool,1> axisDomainOrder = grid->axis_domain_order;
+         int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0;
+         std::vector<StdString> domainList = grid->getDomainList();
+         std::vector<StdString> axisList   = grid->getAxisList();
+
+         StdString timeid  = StdString("time_counter");
+         StdString dimXid,dimYid;
+         std::deque<StdString> dimIdList, dimCoordList;
+         bool hasArea = false;
+         StdString cellMeasures = "area:";
+         bool compressedOutput = !field->indexed_output.isEmpty() && field->indexed_output;
+
+         for (int i = 0; i < numElement; ++i)
+         {
+           if (axisDomainOrder(i))
+           {
+             CDomain* domain = CDomain::get(domainList[idxDomain]);
+             StdString domId = !domain->name.isEmpty() ? domain->name.getValue() : domain->getId();
+             StdString appendDomId  = singleDomain ? "" : "_" + domId ;
+
+             if (compressedOutput && domain->isCompressible() && domain->type != CDomain::type_attr::unstructured)
+             {
+               dimIdList.push_back(domId + "_points");
+               field->setUseCompressedOutput();
+             }
+
+             switch (domain->type)
+             {
+               case CDomain::type_attr::curvilinear:
+                 if (!compressedOutput || !domain->isCompressible())
+                 {
+                   dimXid     = StdString("x").append(appendDomId);
+                   dimIdList.push_back(dimXid);
+                   dimYid     = StdString("y").append(appendDomId);
+                   dimIdList.push_back(dimYid);
+                 }
+                 dimCoordList.push_back(StdString("nav_lon").append(appendDomId));
+                 dimCoordList.push_back(StdString("nav_lat").append(appendDomId));
+                 break ;
+               case CDomain::type_attr::rectilinear:
+                 if (!compressedOutput || !domain->isCompressible())
+                 {
+                   dimXid     = StdString("lon").append(appendDomId);
+                   dimIdList.push_back(dimXid);
+                   dimYid     = StdString("lat").append(appendDomId);
+                   dimIdList.push_back(dimYid);
+                 }
+                 break ;
+               case CDomain::type_attr::unstructured:
+                 dimXid     = StdString("cell").append(appendDomId);
+                 dimIdList.push_back(dimXid);
+                 dimCoordList.push_back(StdString("lon").append(appendDomId));
+                 dimCoordList.push_back(StdString("lat").append(appendDomId));
+                 break ;
+             }
+             if (domain->hasArea)
+             {
+               hasArea = true;
+               cellMeasures += " area" + appendDomId;
+             }
+             ++idxDomain;
+           }
+           else
+           {
+             CAxis* axis = CAxis::get(axisList[idxAxis]);
+             StdString axisId = !axis->name.isEmpty() ? axis->name.getValue() : axis->getId();
+
+             if (compressedOutput && axis->isCompressible())
+             {
+               dimIdList.push_back(axisId + "_points");
+               field->setUseCompressedOutput();
+             }
+             else
+               dimIdList.push_back(axisId);
+
+             dimCoordList.push_back(axisId);
+             ++idxAxis;
+           }
+         }
+
+/*
+         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->getOperationTimeType() == func::CFunctor::once);
+
+         if (wtime)
+         {
+
+            //StdOStringStream oss;
+           // oss << "time_" << field->operation.getValue()
+           //     << "_" << field->getRelFile()->output_freq.getValue();
+          //oss
+            if (field->getOperationTimeType() == func::CFunctor::instant) coodinates.push_back(string("time_instant"));
+            else if (field->getOperationTimeType() == func::CFunctor::centered) coodinates.push_back(string("time_centered"));
+            dims.push_back(timeid);
+         }
+
+         if (compressedOutput && grid->isCompressible())
+         {
+           dims.push_back(grid->getId() + "_points");
+           field->setUseCompressedOutput();
+         }
+         else
+         {
+           while (!dimIdList.empty())
+           {
+             dims.push_back(dimIdList.back());
+             dimIdList.pop_back();
+           }
+         }
+
+         while (!dimCoordList.empty())
+         {
+           coodinates.push_back(dimCoordList.back());
+           dimCoordList.pop_back();
+         }
+
+         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 freqOp = field->freq_op.getValue();
+              freqOp.solveTimeStep(*context->calendar);
+              StdString freqOpStr = freqOp.toStringUDUnits();
+              SuperClassWriter::addAttribute("interval_operation", freqOpStr, &fieldid);
+
+              CDuration freqOut = field->getRelFile()->output_freq.getValue();
+              freqOut.solveTimeStep(*context->calendar);
+              SuperClassWriter::addAttribute("interval_write", freqOut.toStringUDUnits(), &fieldid);
+
+              StdString cellMethods = "time: ";
+              if (field->operation.getValue() == "instant") cellMethods += "point";
+              else if (field->operation.getValue() == "average") cellMethods += "mean";
+              else if (field->operation.getValue() == "accumulate") cellMethods += "sum";
+              else cellMethods += field->operation;
+              if (freqOp.resolve(*context->calendar) != freqOut.resolve(*context->calendar))
+                cellMethods += " (interval: " + freqOpStr + ")";
+              SuperClassWriter::addAttribute("cell_methods", cellMethods, &fieldid);
+           }
+
+           if (hasArea)
+             SuperClassWriter::addAttribute("cell_measures", cellMeasures, &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);
+
+            if (field->compression_level.isEmpty())
+              field->compression_level = field->file->compression_level.isEmpty() ? 0 : field->file->compression_level;
+            SuperClassWriter::setCompressionLevel(fieldid, field->compression_level);
+
+           {  // 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);
+         }
+      }
+
+      //--------------------------------------------------------------
+
+      void CNc4DataOutput::writeFile_ (CFile* file)
+      {
+         StdString filename = (!file->name.isEmpty())
+                            ? file->name.getValue() : file->getId();
+         StdString description = (!file->description.isEmpty())
+                               ? file->description.getValue()
+                               : StdString("Created by xios");
+
+         singleDomain = (file->nbDomains == 1);
+
+         try
+         {
+           this->writeFileAttributes(filename, description,
+                                     StdString("CF-1.5"),
+                                     StdString("An IPSL model"),
+                                     this->getTimeStamp());
+
+           SuperClassWriter::addDimension("axis_nbounds", 2);
+         }
+         catch (CNetCdfException& e)
+         {
+           StdString msg("On writing file : ");
+           msg.append(filename); 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::writeFile_ (CFile* file)", << msg);
+         }
+      }
+
+      void CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId)
+      {
+        string name ;
+        if (!var->name.isEmpty()) name=var->name ;
+        else if (var->hasId()) name=var->getId() ;
+        else return ;
+
+        try
+        {
+          if (var->type.getValue() == CVariable::type_attr::t_int || var->type.getValue() == CVariable::type_attr::t_int32)
+            addAttribute(name, var->getData<int>(), &fieldId);
+          else if (var->type.getValue() == CVariable::type_attr::t_int16)
+            addAttribute(name, var->getData<short int>(), &fieldId);
+          else if (var->type.getValue() == CVariable::type_attr::t_float)
+            addAttribute(name, var->getData<float>(), &fieldId);
+          else if (var->type.getValue() == CVariable::type_attr::t_double)
+            addAttribute(name, var->getData<double>(), &fieldId);
+          else if (var->type.getValue() == CVariable::type_attr::t_string)
+            addAttribute(name, var->getData<string>(), &fieldId);
+          else
+            ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId)",
+                  << "Unsupported variable of type " << var->type.getStringValue());
+        }
+       catch (CNetCdfException& e)
+       {
+         StdString msg("On writing attributes of variable with name : ");
+         msg.append(name); msg.append("in the field "); msg.append(fieldId); 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::writeAttribute_ (CVariable* var, const string& fieldId)", << msg);
+       }
+     }
+
+     void CNc4DataOutput::writeAttribute_ (CVariable* var)
+     {
+        string name ;
+        if (!var->name.isEmpty()) name=var->name ;
+        else if (var->hasId()) name=var->getId() ;
+        else return ;
+        try
+        {
+          if (var->type.getValue() == CVariable::type_attr::t_int || var->type.getValue() == CVariable::type_attr::t_int32)
+            addAttribute(name, var->getData<int>());
+          else if (var->type.getValue() == CVariable::type_attr::t_int16)
+            addAttribute(name, var->getData<short int>());
+          else if (var->type.getValue() == CVariable::type_attr::t_float)
+            addAttribute(name, var->getData<float>());
+          else if (var->type.getValue() == CVariable::type_attr::t_double)
+            addAttribute(name, var->getData<double>());
+          else if (var->type.getValue() == CVariable::type_attr::t_string)
+            addAttribute(name, var->getData<string>());
+          else
+            ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var)",
+                  << "Unsupported variable of type " << var->type.getStringValue());
+        }
+       catch (CNetCdfException& e)
+       {
+         StdString msg("On writing attributes of variable with name : ");
+         msg.append(name); 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::writeAttribute_ (CVariable* var)", << msg);
+       }
+     }
+
+      void CNc4DataOutput::syncFile_ (void)
+      {
+        try
+        {
+          SuperClassWriter::sync() ;
+        }
+        catch (CNetCdfException& e)
+        {
+         StdString msg("On synchronizing the write among processes");
+         msg.append("In the context : ");
+         CContext* context = CContext::getCurrent() ;
+         msg.append(context->getId()); msg.append("\n");
+         msg.append(e.what());
+         ERROR("CNc4DataOutput::syncFile_ (void)", << msg);
+        }
+      }
+
+      void CNc4DataOutput::closeFile_ (void)
+      {
+        try
+        {
+          SuperClassWriter::close() ;
+        }
+        catch (CNetCdfException& e)
+        {
+         StdString msg("On closing file");
+         msg.append("In the context : ");
+         CContext* context = CContext::getCurrent() ;
+         msg.append(context->getId()); msg.append("\n");
+         msg.append(e.what());
+         ERROR("CNc4DataOutput::syncFile_ (void)", << msg);
+        }
+
+      }
+
+      //---------------------------------------------------------------
+
+      StdString CNc4DataOutput::getTimeStamp(void) const
+      {
+         const int buffer_size = 100;
+         time_t rawtime;
+         struct tm * timeinfo = NULL;
+         char buffer [buffer_size];
+
+         time ( &rawtime );
+         timeinfo = localtime ( &rawtime );
+         strftime (buffer, buffer_size, "%Y-%b-%d %H:%M:%S %Z", timeinfo);
+
+         return (StdString(buffer));
+      }
+
+      //---------------------------------------------------------------
+
+      void CNc4DataOutput::writeFieldData_ (CField*  field)
+      {
+         CContext* context = CContext::getCurrent() ;
+//          if (field->getRelFile()->isSyncTime()) SuperClassWriter::sync() ;
+         CContextServer* server=context->server ;
+
+         CGrid* grid = field->grid ;
+
+         if (!grid->doGridHaveDataToWrite())
+          if (SuperClass::type==MULTI_FILE || !isCollective) return ;
+
+         StdString fieldid   = (!field->name.isEmpty())
+                             ? field->name.getValue()
+                             : field->getBaseFieldReference()->getId();
+
+         StdOStringStream oss;
+         string timeAxisId ;
+         if (field->getOperationTimeType() == func::CFunctor::instant)  timeAxisId="time_instant" ;
+         else if (field->getOperationTimeType() == func::CFunctor::centered)  timeAxisId="time_centered" ;
+
+         StdString timeBoundId("time_counter_bounds");
+
+         StdString timeAxisBoundId;
+         if (field->getOperationTimeType() == func::CFunctor::instant)  timeAxisBoundId="time_instant_bounds" ;
+         else if (field->getOperationTimeType() == 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->getOperationTimeType() == func::CFunctor::once));
+
+        if (wtime)
+        {
+          time_counter(0)= (Time(field->last_Write_srv) + Time(field->lastlast_Write_srv)) / 2;
+          if (field->getOperationTimeType() == func::CFunctor::instant)
+            time_data(0) = Time(field->last_Write_srv);
+          else if (field->getOperationTimeType() == 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->getOperationTimeType() == func::CFunctor::instant)
+            time_data_bound(0) = time_data_bound(1) = Time(field->last_Write_srv);
+          else if (field->getOperationTimeType() == 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
+         {
+           size_t writtenSize;
+           if (field->getUseCompressedOutput())
+             writtenSize = grid->getNumberWrittenIndexes();
+           else
+             writtenSize = grid->getWrittenDataSize();
+
+           CArray<double,1> fieldData(writtenSize);
+           if (!field->default_value.isEmpty()) fieldData = field->default_value;
+
+           if (field->getUseCompressedOutput())
+             field->outputCompressedField(fieldData);
+           else
+             field->outputField(fieldData);
+
+           if (!field->prec.isEmpty() && field->prec==2) fieldData=round(fieldData) ;
+
+           switch (SuperClass::type)
+           {
+              case (MULTI_FILE) :
+              {
+                 SuperClassWriter::writeData(fieldData, 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) :
+              {
+                const std::vector<int>& nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal();
+                const std::vector<int>& nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer();
+                const std::vector<int>& nZoomSizeServer  = grid->getDistributionServer()->getZoomSizeServer();
+
+                std::vector<StdSize> start, count;
+
+                if (field->getUseCompressedOutput())
+                {
+                  if (grid->isCompressible())
+                  {
+                    start.push_back(grid->getOffsetWrittenIndexes());
+                    count.push_back(grid->getNumberWrittenIndexes());
+                  }
+                  else
+                  {
+                    CArray<bool,1> axisDomainOrder = grid->axis_domain_order;
+                    std::vector<StdString> domainList = grid->getDomainList();
+                    std::vector<StdString> axisList   = grid->getAxisList();
+                    int numElement = axisDomainOrder.numElements();
+                    int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1;
+                    int idx = nZoomBeginGlobal.size() - 1;
+
+                    start.reserve(nZoomBeginGlobal.size());
+                    count.reserve(nZoomBeginGlobal.size());
+
+
+                    for (int i = numElement - 1; i >= 0; --i)
+                    {
+                      if (axisDomainOrder(i))
+                      {
+                        CDomain* domain = CDomain::get(domainList[idxDomain]);
+
+                        if (domain->isCompressible())
+                        {
+                          start.push_back(domain->getOffsetWrittenIndexes());
+                          count.push_back(domain->getNumberWrittenIndexes());
+                        }
+                        else
+                        {
+                          start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]);
+                          count.push_back(nZoomSizeServer[idx]);
+                          start.push_back(nZoomBeginServer[idx - 1] - nZoomBeginGlobal[idx - 1]);
+                          count.push_back(nZoomSizeServer[idx - 1]);
+                        }
+
+                        --idxDomain;
+                        idx -= 2;
+                      }
+                      else
+                      {
+                        CAxis* axis = CAxis::get(axisList[idxAxis]);
+
+                        if (axis->isCompressible())
+                        {
+                          start.push_back(axis->getOffsetWrittenIndexes());
+                          count.push_back(axis->getNumberWrittenIndexes());
+                        }
+                        else
+                        {
+                          start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]);
+                          count.push_back(nZoomSizeServer[idx]);
+                        }
+
+                        --idxAxis;
+                        --idx;
+                      }
+                    }
+                  }
+                }
+                else
+                {
+                  int ssize = nZoomBeginGlobal.size();
+
+                  start.resize(ssize);
+                  count.resize(ssize);
+
+                  for (int i = 0; i < ssize; ++i)
+                  {
+                    start[i] = nZoomBeginServer[ssize - i - 1] - nZoomBeginGlobal[ssize - i - 1];
+                    count[i] = nZoomSizeServer[ssize - i - 1];
+                  }
+                }
+
+                SuperClassWriter::writeData(fieldData, 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);
+         }
+      }
+
+      //---------------------------------------------------------------
+
+      void CNc4DataOutput::writeTimeAxis_
+                  (CField*    field,
+                   const boost::shared_ptr<CCalendar> cal)
+      {
+         StdOStringStream oss;
+
+         if (field->getOperationTimeType() == func::CFunctor::once) return ;
+
+//         oss << "time_" << field->operation.getValue()
+//             << "_" << field->getRelFile()->output_freq.getValue();
+
+//         StdString axisid = oss.str();
+//         if (field->getOperationTimeType() == func::CFunctor::centered) axisid="time_centered" ;
+//         else if (field->getOperationTimeType() == func::CFunctor::instant) axisid="time_instant" ;
+
+         StdString axisid("time_centered") ;
+         StdString axisBoundId("time_centered_bounds");
+         StdString timeid("time_counter");
+         StdString timeBoundId("axis_nbounds");
+
+         if (field->getOperationTimeType() == func::CFunctor::instant)
+         {
+            axisid = "time_instant";
+            axisBoundId = "time_instant_bounds";
+         }
+
+         try
+         {
+          // Adding time_instant or time_centered
+           std::vector<StdString> dims;
+           dims.push_back(timeid);
+           if (!SuperClassWriter::varExist(axisid))
+           {
+              SuperClassWriter::addVariable(axisid, NC_DOUBLE, dims);
+
+              CDate timeOrigin=cal->getTimeOrigin() ;
+              StdOStringStream oss2;
+  //            oss2<<initDate.getYear()<<"-"<<initDate.getMonth()<<"-"<<initDate.getDay()<<" "
+  //                <<initDate.getHour()<<"-"<<initDate.getMinute()<<"-"<<initDate.getSecond() ;
+              StdString strInitdate=oss2.str() ;
+              StdString strTimeOrigin=timeOrigin.toString() ;
+              this->writeTimeAxisAttributes
+                 (axisid, cal->getType(),
+                  StdString("seconds since ").append(strTimeOrigin),
+                  strTimeOrigin, axisBoundId);
+           }
+
+           // Adding time_instant_bounds or time_centered_bounds variables
+           if (!SuperClassWriter::varExist(axisBoundId))
+           {
+              dims.clear() ;
+              dims.push_back(timeid);
+              dims.push_back(timeBoundId);
+              SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims);
+           }
+
+           // Adding time_counter
+           axisid = "time_counter" ;
+           axisBoundId = "time_counter_bounds" ;
+           dims.clear() ;
+           dims.push_back(timeid);
+           if (!SuperClassWriter::varExist(axisid))
+           {
+              SuperClassWriter::addVariable(axisid, NC_DOUBLE, dims);
+              SuperClassWriter::addAttribute("axis", string("T"), &axisid);
+              CDate timeOrigin=cal->getTimeOrigin() ;
+              StdString strTimeOrigin=timeOrigin.toString() ;
+
+              this->writeTimeAxisAttributes
+                 (axisid, cal->getType(),
+                  StdString("seconds since ").append(strTimeOrigin),
+                  strTimeOrigin, axisBoundId);
+           }
+
+           // Adding time_counter_bound dimension
+           if (!SuperClassWriter::varExist(axisBoundId))
+           {
+              dims.clear();
+              dims.push_back(timeid);
+              dims.push_back(timeBoundId);
+              SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims);
+           }
+         }
+         catch (CNetCdfException& e)
+         {
+           StdString msg("On writing time axis data: ");
+           msg.append("In the context : ");
+           CContext* context = CContext::getCurrent() ;
+           msg.append(context->getId()); msg.append("\n");
+           msg.append(e.what());
+           ERROR("CNc4DataOutput::writeTimeAxis_ (CField*    field, \
+                  const boost::shared_ptr<CCalendar> cal)", << msg);
+         }
+      }
+
+      //---------------------------------------------------------------
+
+      void CNc4DataOutput::writeTimeAxisAttributes(const StdString & axis_name,
+                                                   const StdString & calendar,
+                                                   const StdString & units,
+                                                   const StdString & time_origin,
+                                                   const StdString & time_bounds,
+                                                   const StdString & standard_name,
+                                                   const StdString & long_name)
+      {
+         try
+         {
+           SuperClassWriter::addAttribute("standard_name", standard_name, &axis_name);
+           SuperClassWriter::addAttribute("long_name",     long_name    , &axis_name);
+           SuperClassWriter::addAttribute("calendar",      calendar     , &axis_name);
+           SuperClassWriter::addAttribute("units",         units        , &axis_name);
+           SuperClassWriter::addAttribute("time_origin",   time_origin  , &axis_name);
+           SuperClassWriter::addAttribute("bounds",        time_bounds  , &axis_name);
+         }
+         catch (CNetCdfException& e)
+         {
+           StdString msg("On writing time axis Attribute: ");
+           msg.append("In the context : ");
+           CContext* context = CContext::getCurrent() ;
+           msg.append(context->getId()); msg.append("\n");
+           msg.append(e.what());
+           ERROR("CNc4DataOutput::writeTimeAxisAttributes(const StdString & axis_name, \
+                                                          const StdString & calendar,\
+                                                          const StdString & units, \
+                                                          const StdString & time_origin, \
+                                                          const StdString & time_bounds, \
+                                                          const StdString & standard_name, \
+                                                          const StdString & long_name)", << msg);
+         }
+      }
+
+      //---------------------------------------------------------------
+
+      void CNc4DataOutput::writeAxisAttributes(const StdString & axis_name,
+                                               const StdString & axis,
+                                               const StdString & standard_name,
+                                               const StdString & long_name,
+                                               const StdString & units,
+                                               const StdString & nav_model)
+      {
+         try
+         {
+          if (!axis.empty())
+            SuperClassWriter::addAttribute("axis"       , axis         , &axis_name);
+
+          SuperClassWriter::addAttribute("standard_name", standard_name, &axis_name);
+          SuperClassWriter::addAttribute("long_name"    , long_name    , &axis_name);
+          SuperClassWriter::addAttribute("units"        , units        , &axis_name);
+          SuperClassWriter::addAttribute("nav_model"    , nav_model    , &axis_name);
+         }
+         catch (CNetCdfException& e)
+         {
+           StdString msg("On writing Axis Attribute: ");
+           msg.append("In the context : ");
+           CContext* context = CContext::getCurrent() ;
+           msg.append(context->getId()); msg.append("\n");
+           msg.append(e.what());
+           ERROR("CNc4DataOutput::writeAxisAttributes(const StdString & axis_name, \
+                                                      const StdString & axis, \
+                                                      const StdString & standard_name, \
+                                                      const StdString & long_name, \
+                                                      const StdString & units, \
+                                                      const StdString & nav_model)", << msg);
+         }
+      }
+
+      //---------------------------------------------------------------
+
+      void CNc4DataOutput::writeLocalAttributes
+         (int ibegin, int ni, int jbegin, int nj, StdString domid)
+      {
+        try
+        {
+         SuperClassWriter::addAttribute(StdString("ibegin").append(domid), ibegin);
+         SuperClassWriter::addAttribute(StdString("ni"    ).append(domid), ni);
+         SuperClassWriter::addAttribute(StdString("jbegin").append(domid), jbegin);
+         SuperClassWriter::addAttribute(StdString("nj"    ).append(domid), nj);
+        }
+        catch (CNetCdfException& e)
+        {
+           StdString msg("On writing Local Attributes: ");
+           msg.append("In the context : ");
+           CContext* context = CContext::getCurrent() ;
+           msg.append(context->getId()); msg.append("\n");
+           msg.append(e.what());
+           ERROR("CNc4DataOutput::writeLocalAttributes \
+                  (int ibegin, int ni, int jbegin, int nj, StdString domid)", << msg);
+        }
+
+      }
+
+      void CNc4DataOutput::writeLocalAttributes_IOIPSL(const StdString& dimXid, const StdString& dimYid,
+                                                       int ibegin, int ni, int jbegin, int nj, int ni_glo, int nj_glo, int rank, int size)
+      {
+         CArray<int,1> array(2) ;
+
+         try
+         {
+           SuperClassWriter::addAttribute("DOMAIN_number_total",size ) ;
+           SuperClassWriter::addAttribute("DOMAIN_number", rank) ;
+           array = SuperClassWriter::getDimension(dimXid) + 1, SuperClassWriter::getDimension(dimYid) + 1;
+           SuperClassWriter::addAttribute("DOMAIN_dimensions_ids",array) ;
+           array=ni_glo,nj_glo ;
+           SuperClassWriter::addAttribute("DOMAIN_size_global", array) ;
+           array=ni,nj ;
+           SuperClassWriter::addAttribute("DOMAIN_size_local", array) ;
+           array=ibegin,jbegin ;
+           SuperClassWriter::addAttribute("DOMAIN_position_first", array) ;
+           array=ibegin+ni-1,jbegin+nj-1 ;
+           SuperClassWriter::addAttribute("DOMAIN_position_last",array) ;
+           array=0,0 ;
+           SuperClassWriter::addAttribute("DOMAIN_halo_size_start", array) ;
+           SuperClassWriter::addAttribute("DOMAIN_halo_size_end", array);
+           SuperClassWriter::addAttribute("DOMAIN_type",string("box")) ;
+  /*
+           SuperClassWriter::addAttribute("DOMAIN_DIM_N001",string("x")) ;
+           SuperClassWriter::addAttribute("DOMAIN_DIM_N002",string("y")) ;
+           SuperClassWriter::addAttribute("DOMAIN_DIM_N003",string("axis_A")) ;
+           SuperClassWriter::addAttribute("DOMAIN_DIM_N004",string("time_counter")) ;
+  */
+         }
+         catch (CNetCdfException& e)
+         {
+           StdString msg("On writing Local Attributes IOIPSL \n");
+           msg.append("In the context : ");
+           CContext* context = CContext::getCurrent() ;
+           msg.append(context->getId()); msg.append("\n");
+           msg.append(e.what());
+           ERROR("CNc4DataOutput::writeLocalAttributes_IOIPSL \
+                  (int ibegin, int ni, int jbegin, int nj, int ni_glo, int nj_glo, int rank, int size)", << msg);
+         }
+      }
+      //---------------------------------------------------------------
+
+      void CNc4DataOutput:: writeFileAttributes(const StdString & name,
+                                                const StdString & description,
+                                                const StdString & conventions,
+                                                const StdString & production,
+                                                const StdString & timeStamp)
+      {
+         try
+         {
+           SuperClassWriter::addAttribute("name"       , name);
+           SuperClassWriter::addAttribute("description", description);
+           SuperClassWriter::addAttribute("title"      , description);
+           SuperClassWriter::addAttribute("Conventions", conventions);
+           SuperClassWriter::addAttribute("production" , production);
+           SuperClassWriter::addAttribute("timeStamp"  , timeStamp);
+         }
+         catch (CNetCdfException& e)
+         {
+           StdString msg("On writing File Attributes \n ");
+           msg.append("In the context : ");
+           CContext* context = CContext::getCurrent() ;
+           msg.append(context->getId()); msg.append("\n");
+           msg.append(e.what());
+           ERROR("CNc4DataOutput:: writeFileAttributes(const StdString & name, \
+                                                const StdString & description, \
+                                                const StdString & conventions, \
+                                                const StdString & production, \
+                                                const StdString & timeStamp)", << msg);
+         }
+      }
+
+      //---------------------------------------------------------------
+
+      void CNc4DataOutput::writeMaskAttributes(const StdString & mask_name,
+                                               int data_dim,
+                                               int data_ni,
+                                               int data_nj,
+                                               int data_ibegin,
+                                               int data_jbegin)
+      {
+         try
+         {
+           SuperClassWriter::addAttribute("data_dim"   , data_dim   , &mask_name);
+           SuperClassWriter::addAttribute("data_ni"    , data_ni    , &mask_name);
+           SuperClassWriter::addAttribute("data_nj"    , data_nj    , &mask_name);
+           SuperClassWriter::addAttribute("data_ibegin", data_ibegin, &mask_name);
+           SuperClassWriter::addAttribute("data_jbegin", data_jbegin, &mask_name);
+         }
+         catch (CNetCdfException& e)
+         {
+           StdString msg("On writing Mask Attributes \n ");
+           msg.append("In the context : ");
+           CContext* context = CContext::getCurrent() ;
+           msg.append(context->getId()); msg.append("\n");
+           msg.append(e.what());
+           ERROR("CNc4DataOutput::writeMaskAttributes(const StdString & mask_name, \
+                                               int data_dim, \
+                                               int data_ni, \
+                                               int data_nj, \
+                                               int data_ibegin, \
+                                               int data_jbegin)", << msg);
+         }
+      }
+
+      ///--------------------------------------------------------------
+
+} // namespace xios
Index: XIOS/trunk/src/io/nc4_data_output.hpp
===================================================================
--- XIOS/trunk/src/io/nc4_data_output.hpp	(revision 685)
+++ XIOS/trunk/src/io/nc4_data_output.hpp	(revision 685)
@@ -0,0 +1,103 @@
+#ifndef __XIOS_NC4_DATA_OUTPUT__
+#define __XIOS_NC4_DATA_OUTPUT__
+
+/// XIOS headers ///
+#include "xios_spl.hpp"
+#include "onetcdf4.hpp"
+#include "data_output.hpp"
+
+namespace xios
+{
+      /// ////////////////////// DÃ©clarations ////////////////////// ///
+
+      class CNc4DataOutput
+         : protected CONetCDF4
+         , public virtual CDataOutput
+      {
+         public :
+
+            /// DÃ©finition de type ///
+            typedef CONetCDF4   SuperClassWriter;
+            typedef CDataOutput SuperClass;
+
+            /// Constructeurs ///
+            CNc4DataOutput
+               (const StdString & filename, bool exist);
+            CNc4DataOutput
+               (const StdString & filename, bool exist, bool useClassicFormat,
+                MPI_Comm comm_file, bool multifile, bool isCollective=true);
+
+            CNc4DataOutput(const CNc4DataOutput & dataoutput);       // Not implemented.
+            CNc4DataOutput(const CNc4DataOutput * const dataoutput); // Not implemented.
+
+            /// Accesseur ///
+            const StdString & getFileName(void) const;
+
+            /// Destructeur ///
+            virtual ~CNc4DataOutput(void);
+            bool singleDomain ;
+            bool isCollective ;
+         protected :
+
+            /// Ecriture ///
+            virtual void writeDomain_   (CDomain* domain);
+            virtual void writeAxis_     (CAxis* axis);
+            virtual void writeGridCompressed_(CGrid* grid);
+            virtual void writeTimeDimension_(void);
+            virtual void writeField_    (CField* field);
+            virtual void writeAttribute_(CVariable* var);
+            virtual void writeAttribute_(CVariable* var, const string& fieldId);
+            virtual void writeFieldData_(CField* field);
+            virtual void writeFile_     (CFile* file);
+            virtual void closeFile_     (void);
+            virtual void syncFile_      (void);
+            virtual void writeTimeAxis_ (CField* field,
+                                         const boost::shared_ptr<CCalendar> cal);
+
+         protected :
+            void writeUnstructuredDomain (CDomain* domain);
+            void writeLocalAttributes(int ibegin, int ni, int jbegin, int nj, StdString domid);
+            void writeLocalAttributes_IOIPSL(const StdString& dimXid, const StdString& dimYid,
+                                             int ibegin, int ni, int jbegin, int nj, int ni_glo, int nj_glo, int rank, int size);
+            void writeTimeAxisAttributes(const StdString & axis_name,
+                                         const StdString & calendar,
+                                         const StdString & units,
+                                         const StdString & time_origin,
+                                         const StdString & time_bounds   = StdString("bounds"),
+                                         const StdString & standard_name = StdString("time"),
+                                         const StdString & long_name     = StdString("Time axis"));
+
+            void writeFileAttributes(const StdString & name,
+                                     const StdString & description,
+                                     const StdString & conventions,
+                                     const StdString & production,
+                                     const StdString & timeStamp);
+
+            void writeMaskAttributes(const StdString & mask_name,
+                                     int data_dim,
+                                     int data_ni     = 0,
+                                     int data_nj     = 0,
+                                     int data_ibegin = 0,
+                                     int data_jbegin = 0);
+
+            void writeAxisAttributes(const StdString & axis_name,
+                                     const StdString & axis,
+                                     const StdString & standard_name,
+                                     const StdString & long_name,
+                                     const StdString & units,
+                                     const StdString & nav_model);
+
+         private :
+
+            /// Traitement ///
+            StdString getTimeStamp(void) const;
+
+            /// PropriÃ©tÃ©s privÃ©es ///
+            MPI_Comm comm_file;
+            const StdString filename;
+
+      }; // class CNc4DataOutput
+
+} // namespace xios
+
+#endif //__XIOS_NC4_DATA_OUTPUT__
Index: XIOS/trunk/src/io/netCdfException.hpp
===================================================================
--- XIOS/trunk/src/io/netCdfException.hpp	(revision 685)
+++ XIOS/trunk/src/io/netCdfException.hpp	(revision 685)
@@ -0,0 +1,34 @@
+/*!
+   \file netCdfException.hpp
+   \author Ha NGUYEN
+   \date 08 Oct 2014
+   \since 07 Oct 2014
+
+   \brief Exception management.
+ */
+#ifndef __NETCDF_EXCEPTION_HPP__
+#define __NETCDF_EXCEPTION_HPP__
+
+#include <iostream>
+#include <exception>
+
+namespace xios
+{
+/*!
+\class CNetCdfException
+ This class manages exceptions risen by CNetCdfInterface
+*/
+class CNetCdfException : public virtual std::exception
+{
+public:
+  CNetCdfException(const std::string& ss) : exStr_(ss) {}
+  CNetCdfException(const CNetCdfException& netEx) : exStr_(netEx.exStr_) {}
+  ~CNetCdfException() throw() {}
+  const char* what() const throw() { return exStr_.c_str();}
+protected:
+  std::string exStr_;
+};
+
+}
+
+#endif // __NETCDF_EXCEPTION_HPP__
Index: XIOS/trunk/src/io/netCdfInterface.cpp
===================================================================
--- XIOS/trunk/src/io/netCdfInterface.cpp	(revision 685)
+++ XIOS/trunk/src/io/netCdfInterface.cpp	(revision 685)
@@ -0,0 +1,804 @@
+/*!
+   \file netCdfInterface.cpp
+   \author Ha NGUYEN
+   \date 08 Oct 2014
+   \since 03 Oct 2014
+
+   \brief Wrapper of netcdf functions.
+ */
+
+#include "netCdfInterface.hpp"
+#include "netCdfException.hpp"
+
+namespace xios
+{
+/*!
+This function creates a new netcdf file and return its id
+\param [in] fileName Name of the file
+\param [in] cMode create mode
+\param [in/out] ncId id of the created file
+\return Status code
+*/
+int CNetCdfInterface::create(const StdString& fileName, int cMode, int& ncId)
+{
+  int status = nc_create((fileName.c_str()), cMode, &ncId);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+    sstr << "Error in calling function : nc_create((fileName.c_str()), cMode, &ncId) " << std::endl
+         << errormsg << std::endl
+         << "Unable to create file, given its name : " << fileName
+         << "and its creation mode " << creationMode2String(cMode) << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function creates a new netcdf file on parallel file system
+\param [in] fileName Name of the file
+\param [in] cMode create mode
+\param [in] comm MPI communicator
+\param [in] info MPI information
+\param [in/out] ncId id of the created file
+\return Status code
+*/
+int CNetCdfInterface::createPar(const StdString& fileName, int cMode, MPI_Comm comm, MPI_Info info, int& ncId)
+{
+  int status = xios::nc_create_par((fileName.c_str()), cMode, comm, info, &ncId);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+    sstr << "Error in calling function : nc_create_par((fileName.c_str()), cMode, comm, info, &ncId) " << std::endl
+         << errormsg << std::endl
+         << "Unable to create file on parallel filesys, given its name : " << std::endl
+         << "and its creation mode " << creationMode2String(cMode) << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function opens a netcdf file, given its name and open mode, return its id
+\param [in] fileName Name of the file
+\param [in] oMode open mode
+\param [in/out] ncId id of the opening file
+\return Status code
+*/
+int CNetCdfInterface::open(const StdString& fileName, int oMode, int& ncId)
+{
+  int status = nc_open((fileName.c_str()), oMode, &ncId);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+    sstr << "Error in calling function : nc_open((fileName.c_str()), oMode, &ncId) "<< std::endl
+         << errormsg << std::endl
+         << "Unable to open file, given its name : " << fileName
+         << "and its open mode " << openMode2String(oMode) << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+
+/*!
+This function opens a new netcdf file on parallel file system
+\param [in] fileName Name of the file
+\param [in] oMode open mode
+\param [in] comm MPI communicator
+\param [in] info MPI information
+\param [in/out] ncId id of the opened file
+\return Status code
+*/
+int CNetCdfInterface::openPar(const StdString& fileName, int oMode, MPI_Comm comm, MPI_Info info, int& ncId)
+{
+  int status = xios::nc_open_par((fileName.c_str()), oMode, comm, info, &ncId);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+    sstr << "Error in calling function " << "nc_open_par((fileName.c_str()), oMode, comm, info, &ncId) " << std::endl
+         << errormsg << std::endl
+         << "Unable to open file on parallel filesys, given its name : " << fileName
+         << "and its open mode " << openMode2String(oMode) << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function closes a netcdf file, given its id
+\param [in] ncId id of the opening netcdf file
+\return Status code
+*/
+int CNetCdfInterface::close(int ncId)
+{
+  int status = nc_close(ncId);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+    sstr << "Error in calling function " << "nc_close(ncId)" << std::endl
+         << errormsg << std::endl
+         << "Unable to close file, given its id : " << ncId << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function put a netcdf file into define mode, given its id
+\param [in] ncId id of the opening netcdf file to be put into define mode
+\return Status code
+*/
+int CNetCdfInterface::reDef(int ncId)
+{
+  int status = nc_redef(ncId);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+    sstr << "Error in calling function " << "nc_redef(ncId)" << std::endl
+      << errormsg << std::endl
+      << "Unable to put this file into define mode given its id : " << ncId << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function ends a netcdf file define mode, given its id
+\param [in] ncId id of the opening netcdf file to be put into define mode
+\return Status code
+*/
+int CNetCdfInterface::endDef(int ncId)
+{
+  int status = nc_enddef(ncId);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << "nc_enddef(ncId)" << std::endl
+         << errormsg << std::endl
+         << "Unable to end define mode of this file, given its id : " << ncId << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function makes a request to netcdf with ncid and group name then return ncid of the named group
+\param [in] ncid Groupd id (or File Id)
+\param [in] grpName Name of the desired group (or file)
+\param [in/out] grpId Group id if the group is found
+\return Status code
+*/
+int CNetCdfInterface::inqNcId(int ncid, const StdString& grpName, int& grpId)
+{
+  int status = nc_inq_ncid(ncid, (grpName.c_str()), &grpId);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << "nc_inq_ncid(ncid, (grpName.c_str()), &grpId)" << std::endl
+         << errormsg << std::endl
+         << "Unable to get id of a group (File), given its name : " << grpName << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+
+/*!
+This function makes a request to netcdf with ncid and variable name then return ncid of the named variable
+\param [in] ncid Groupd id (or File Id)
+\param [in] varName Name of the desired variable
+\param [in/out] varId Variable id if this variable is found
+\return Status code
+*/
+int CNetCdfInterface::inqVarId(int ncid,const StdString& varName, int& varId)
+{
+  int status = nc_inq_varid(ncid, (varName.c_str()), &varId);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function : nc_inq_varid(ncid, (varName.c_str()), &varId)" << std::endl
+         << (errormsg) << std::endl
+         << "Unable to get id of variable with name : " << varName << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function makes a request to netcdf with a netCdf dimension name then return ncid of the named dimension
+\param [in] ncid Groupd id (or File Id)
+\param [in] dimName Name of the desired dimension
+\param [in/out] dimId Dimension id if this dimension is found
+\return Status code
+*/
+int CNetCdfInterface::inqDimId(int ncid,const StdString& dimName, int& dimId)
+{
+  int status = nc_inq_dimid(ncid, (dimName.c_str()), &dimId);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << "nc_inq_dimid(ncid, (dimName.c_str()), &dimId)" << std::endl
+         << errormsg << std::endl
+         << "Unable to get id of dimension, given its name : " << dimName << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function makes a request to netcdf with a netCdf dimension name then return ncid of the named dimension
+\param [in] ncid Groupd id (or File Id)
+\param [in/out] dimId Dimension id if this dimension is found
+\return Status code
+*/
+int CNetCdfInterface::inqUnLimDim(int ncid, int& dimId)
+{
+  int status = nc_inq_unlimdim(ncid, &dimId);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << "nc_inq_dimid" << std::endl
+      << errormsg << std::endl
+      << "Unable to get id of unlimited dimension " << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+ }
+
+  return status;
+}
+
+/*!
+This function makes a request to netcdf, returns name of a dimension, given its id
+\param [in] ncid Groupd id (or File Id)
+\param [in] dimId Id of desired dimension
+\param [in/out] dimName Name of desired dimension
+\return Status code
+*/
+int CNetCdfInterface::inqDimName(int ncid, int dimId, StdString& dimName)
+{
+  char fullNameIn[NC_MAX_NAME +1];
+  int status = nc_inq_dimname(ncid, dimId, fullNameIn);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << "nc_inq_dimname(ncid, dimId, fullNameIn)" << std::endl
+         << errormsg << std::endl
+         << "Unable to get dimension name from its id : " << dimId << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+  dimName = StdString(fullNameIn);
+  return status;
+}
+
+/*!
+This function makes a request to netcdf, returns length of a dimension, given its id
+\param [in] ncid Groupd id (or File Id)
+\param [in] dimId Id of desired dimension
+\param [in/out] dimLen Length of desired dimension
+\return Status code
+*/
+int CNetCdfInterface::inqDimLen(int ncid, int dimId, StdSize& dimLen)
+{
+  int status = nc_inq_dimlen(ncid, dimId, &dimLen);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << "nc_inq_dimlen(ncid, dimId, &dimLen)" << std::endl
+         << errormsg << std::endl
+         << "Unable to get dimension length from its id: " << dimId << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function makes a request to netcdf, returns number of dimensions of a variable, given its id
+\param [in] ncid Groupd id (or File Id)
+\param [in] varId Id of variable
+\param [in/out] ndims number of dimension of the variable
+\return Status code
+*/
+int CNetCdfInterface::inqVarNDims(int ncid, int varId, int& nDims)
+{
+  int status = nc_inq_varndims(ncid, varId, &nDims);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << "nc_inq_varndims(ncid, varId, &nDims)" << std::endl
+         << errormsg << std::endl
+         << "Unable to get the number of dimension of variable with Id : " << varId << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function makes a request to netcdf, returns a list of dimension ID describing the shape of the variable, given its id
+\param [in] ncid Groupd id (or File Id)
+\param [in] varId Id of variable
+\param [in/out] dimIds list of dimension of the variable
+\return Status code
+*/
+int CNetCdfInterface::inqVarDimId(int ncid, int varId, int* dimIds)
+{
+  int status = nc_inq_vardimid(ncid, varId, dimIds);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << "nc_inq_vardimid(ncid, varId, dimIds)" << std::endl
+         << errormsg << std::endl
+         << "Unable to get list of dimension id of the variable with id " << varId << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function makes a request to netcdf, to find all dimension in a group
+\param [in] ncid Groupd id (or File Id)
+\param [in/out] nDims number of list of dimension
+\param [in/out] dimIds list of dimension in a group or any of its parent
+\param [in] includeParents number of parents
+\return Status code
+*/
+int CNetCdfInterface::inqDimIds(int ncid, int& nDims, int* dimIds, int includeParents)
+{
+  int status = nc_inq_dimids(ncid, &nDims, dimIds, includeParents);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << "nc_inq_dimids(ncid, &nDims, dimIds, includeParents)" << std::endl;
+    sstr << errormsg << std::endl;
+    sstr << "Unable to retrieve number of dimension in the group with id : " << ncid << std::endl;
+    sstr << "With number of Parents " << includeParents << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function makes a request to netcdf with a id of a prent groupd and then return id of the created group, given its name
+\param [in] parentNcid Id of parent groupd(or File Id)
+\param [in] grpName Name of the desired group
+\param [in/out] grpId Group id if this group is created sucessfully
+\return Status code
+*/
+int CNetCdfInterface::defGrp(int parentNcid, const StdString& grpName, int& grpId)
+{
+  int status = nc_def_grp(parentNcid, (grpName.c_str()), &grpId);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << "nc_def_grp(parentNcid, (grpName.c_str()), &grpId)" << std::endl;
+    sstr << errormsg << std::endl;
+    sstr << "Unable to create group Id, given its name : " << grpName << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function makes a request to netcdf, add a new dimension to an open netcdf in define mode
+\param [in] ncid Id of groupd(or File Id)
+\param [in] dimName Name of the desired dimension
+\param [in/out] grpId Group id if this group is created sucessfully
+\return Status code
+*/
+int CNetCdfInterface::defDim(int ncid, const StdString& dimName, StdSize dimLen, int& dimId)
+{
+  int status = nc_def_dim(ncid, (dimName.c_str()), dimLen, &dimId);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << "nc_def_dim(ncid, (dimName.c_str()), dimLen, &dimId)" << std::endl;
+    sstr << errormsg << std::endl;
+    sstr << "Unable to create dimension with name : " << dimName
+         << " and with length " << dimLen << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function makes a request to netcdf with its id, to add a new variable to an open netCdf in define mode,
+return a variable id, given its name, type, the number of dimensions and list of dimension id
+\param [in] ncid Id of groupd(or File Id)
+\param [in] varName Name of the desired dimension
+\param [in] xtypes One of the set of predefined netCDF data types
+\param [in] nDims Number of dimension for the variable
+\param [in] dimIds List of ndims dimension ids corresponding to the variable dimensions
+\param [in/out] varId Variable id if it is added sucessfully
+\return Status code
+*/
+int CNetCdfInterface::defVar(int ncid,const StdString& varName, nc_type xtype,
+                            int nDims, const int dimIds[], int& varId)
+{
+  int status = nc_def_var(ncid, (varName.c_str()), xtype, nDims, dimIds, &varId);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << " nc_def_var(ncid, (varName.c_str()), xtype, nDims, dimIds, &varId)" << std::endl;
+    sstr << errormsg << std::endl;
+    sstr << "Unable to add a new variable with name : " << varName
+         << " with type " << xtype
+         << " and number of dimension " << nDims << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function makes a request to netcdf with a ncid, to set the chunking size of a variable,
+given variable id and type of storage
+\param [in] ncid Id groupd(or File Id)
+\param [in] varId Id of the variable
+\param [in] storage Type of storage (It can be : NC_CONTIGUOUS, NC_CHUNKED)
+\param [in/out] chunkSize array list of chunk sizes
+\return Status code
+*/
+int CNetCdfInterface::defVarChunking(int ncid, int varId, int storage, StdSize chunkSize[])
+{
+  int status = nc_def_var_chunking(ncid, varId, storage, chunkSize);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << "nc_def_var_chunking(ncid, varId, storage, chunkSize)" << std::endl;
+    sstr << errormsg << std::endl;
+    sstr << "Unable to set chunk size of the variable with id : " << varId
+      << " and storage type " << storage << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function sets the compression level to the specified variable
+\param [in] ncid Groud id (or file id)
+\param [in] varId Id of the variable
+\param [in] compressionLevel The compression level from 0 to 9 (0 disables the compression, 9 is the higher compression)
+\return Status code
+*/
+int CNetCdfInterface::defVarDeflate(int ncid, int varId, int compressionLevel)
+{
+  int status = nc_def_var_deflate(ncid, varId, false, (compressionLevel > 0), compressionLevel);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << "nc_def_var_deflate(ncid, varId, false, (compressionLevel > 0), compressionLevel)" << std::endl;
+    sstr << errormsg << std::endl;
+    sstr << "Unable to set the compression level of the variable with id: " << varId
+         << " and compression level: " << compressionLevel << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+Set or unset the fill mode for a NetCDF file specified by its file id.
+\param [in] ncid File id
+\param [in] fill Define whether the fill mode should be enabled or not
+\return Status code
+*/
+int CNetCdfInterface::setFill(int ncid, bool fill)
+{
+  int old_fill_mode;
+  int status = nc_set_fill(ncid, fill ? NC_FILL : NC_NOFILL, &old_fill_mode);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error when calling function nc_set_fill(ncid, fill ? NC_FILL : NC_NOFILL, &old_fill_mode)" << std::endl;
+    sstr << errormsg << std::endl;
+    sstr << "Unable to set the fill mode to : " << (fill ? "NC_FILL" : "NC_NOFILL") << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function makes a request to netcdf with a ncid, to set the fill parameters for a variable,
+given variable id and type of fill
+\param [in] ncid Id groupd(or File Id)
+\param [in] varId Id of the variable
+\param [in] noFill turn on/off nofill mode on a variable
+\param [in/out] fillValue
+\return Status code
+*/
+int CNetCdfInterface::defVarFill(int ncid, int varId, int noFill, void* fillValue)
+{
+  int status = nc_def_var_fill(ncid, varId, noFill, fillValue);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << "nc_def_var_fill(ncid, varId, noFill, fillValue)" << std::endl;
+    sstr << errormsg << std::endl;
+    sstr << "Unable to set fill parameters of the variable with id : " << varId
+      << " and fill option " << noFill << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function makes a request to netcdf with a ncid, to change the way read/write operations are performed
+collectively or independently on the variable.
+\param [in] ncid Id groupd(or File Id)
+\param [in] varId Id of the variable
+\param [in] noFill turn on/off nofill mode on a variable
+\param [in/out] fillValue
+\return Status code
+*/
+int CNetCdfInterface::varParAccess(int ncid, int varId, int access)
+{
+  int status = nc_var_par_access(ncid, varId, access);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << "nc_var_par_access(ncid, varId, access)" << std::endl;
+    sstr << errormsg << std::endl;
+    sstr << "Unable to change read/write option of the variable with id : " << varId << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function makes a synchronisation of the disk copy of a netCDF dataset.
+\param [in] ncid Id groupd(or File Id)
+\return Status code
+*/
+int CNetCdfInterface::sync(int ncid)
+{
+  int status = nc_sync(ncid);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << "nc_sync(ncid)" << std::endl;
+    sstr << errormsg << std::endl;
+    sstr << "Unable to make a synchronization of a netCDF file with id : " << ncid << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+/*!
+This function makes a request to netcdf with its id, to add or change a variable attribute or gloabl attribute,
+given its name, type, number of values provided for attribute
+\param [in] ncid Id of groupd(or File Id)
+\param [in] varId Id of the variable
+\param [in] attrName Name of the attribute
+\param [in] xtypes One of the set of predefined netCDF data types
+\param [in] numVal Number of values
+\param [in] op Array of values provided for attribute
+\return Status code
+*/
+int CNetCdfInterface::putAtt(int ncid, int varId, const StdString& attrName, nc_type xtype,
+                            StdSize numVal, const void* op)
+{
+  int status = nc_put_att(ncid, varId, (attrName.c_str()), xtype, numVal, op);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+
+    sstr << "Error in calling function " << "nc_put_att(ncid, varId, (attrName.c_str()), xtype, numVal, op)" << std::endl;
+    sstr << errormsg << std::endl;
+    sstr << "Unable to set attribute " << attrName << " for a variable with id : " << varId
+         << " with number of attribute  " << numVal
+         << " with type " << xtype << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+
+  return status;
+}
+
+ // Some specilization of putAttributeType
+template<>
+int CNetCdfInterface::ncPutAttType(int ncid, int varid, const char* attrName,
+                                 StdSize numVal, const double* op)
+{
+  return (nc_put_att_double(ncid, varid, attrName, NC_DOUBLE, numVal, op));
+}
+
+template<>
+int CNetCdfInterface::ncPutAttType(int ncid, int varid, const char* attrName,
+                                   StdSize numVal, const float* op)
+{
+  return (nc_put_att_float(ncid, varid, attrName, NC_FLOAT, numVal, op));
+}
+
+template<>
+int CNetCdfInterface::ncPutAttType(int ncid, int varid, const char* attrName,
+                                   StdSize numVal, const int* op)
+{
+  return (nc_put_att_int(ncid, varid, attrName, NC_INT, numVal, op));
+}
+
+template<>
+int CNetCdfInterface::ncPutAttType(int ncid, int varid, const char* attrName,
+                                   StdSize numVal, const long* op)
+{
+  return (nc_put_att_long(ncid, varid, attrName, NC_LONG, numVal, op));
+}
+
+template<>
+int CNetCdfInterface::ncPutAttType(int ncid, int varid, const char* attrName,
+                                   StdSize numVal, const short* op)
+{
+  return (nc_put_att_short(ncid, varid, attrName, NC_SHORT, numVal, op));
+}
+
+
+// Some specilization of putVariableType
+template<>
+int CNetCdfInterface::ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const double* op)
+{
+  return (nc_put_vara_double(ncid, varid, start, count, op));
+}
+
+template<>
+int CNetCdfInterface::ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const float* op)
+{
+  return (nc_put_vara_float(ncid, varid, start, count, op));
+}
+
+template<>
+int CNetCdfInterface::ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const int* op)
+{
+  return (nc_put_vara_int(ncid, varid, start, count, op));
+}
+
+ /*!
+ This function verifies an existence of a variable by using its name.
+ Be careful, althoug false means variable doens't exist, it could show that netCDF file doesn't either
+ \param [in] ncid Id of groupd(or File Id)
+ \param [in] attrName Name of the variable
+ \return Existence of variable
+ */
+bool CNetCdfInterface::isVarExisted(int ncId, const StdString& varName)
+{
+   int varId = 0;
+   return (NC_NOERR == (nc_inq_varid(ncId, varName.c_str(), &varId)));
+}
+
+StdString CNetCdfInterface::openMode2String(int oMode)
+{
+  StdString modeMes;
+  switch (oMode)
+  {
+  case NC_NOWRITE:
+    modeMes = StdString("NC_NOWRITE : Opening netCDF file with read-only access with buffering and caching access");
+    break;
+  case NC_SHARE:
+    modeMes = StdString("NC_SHARE : Several processes can read the file concurrently");
+    break;
+  case NC_WRITE:
+    modeMes = StdString("NC_WRITE : NetCDF file is readable and writable");
+    break;
+  default:
+    modeMes = StdString("In the composed opening mode");
+    break;
+  }
+  return modeMes;
+}
+
+StdString CNetCdfInterface::creationMode2String(int cMode)
+{
+  StdString modeMes;
+  switch (cMode)
+  {
+  case NC_NOCLOBBER:
+    modeMes = StdString("NC_NOCLOBBER : Not overwrite an exisiting netCDF file ");
+    break;
+  case NC_SHARE:
+    modeMes = StdString("NC_SHARE : Several processes can read from and write into the file concurrently");
+    break;
+  case NC_64BIT_OFFSET:
+    modeMes = StdString("NC_64BIT_OFFSET : NetCDF file is 64-bit offset");
+    break;
+  case NC_NETCDF4:
+    modeMes = StdString("NC_NETCDF4 : NetCDF file is HDF5/NetCDF-4");
+    break;
+  case NC_CLASSIC_MODEL:
+    modeMes = StdString("NC_CLASSIC_MODEL : NetCDF file is classical model");
+    break;
+  default:
+    modeMes = StdString("In the composed creation mode");
+    break;
+  }
+  return modeMes;
+}
+
+}
Index: XIOS/trunk/src/io/netCdfInterface.hpp
===================================================================
--- XIOS/trunk/src/io/netCdfInterface.hpp	(revision 685)
+++ XIOS/trunk/src/io/netCdfInterface.hpp	(revision 685)
@@ -0,0 +1,143 @@
+/*!
+   \file netCdfInterface.hpp
+   \author Ha NGUYEN
+   \date 08 Oct 2014
+   \since 03 Oct 2014
+
+   \brief Wrapper of netcdf functions.
+ */
+#ifndef __NETCDF_INTERFACE_HPP_
+#define __NETCDF_INTERFACE_HPP_
+
+#include "xios_spl.hpp"
+
+#if !defined(USING_NETCDF_PAR)
+#include "exception.hpp"
+#endif
+
+#include "mpi.hpp"
+#include "netcdf.hpp"
+
+namespace xios
+{
+  /*!
+  \class CNetCdfInterface
+   This class is  wrapper of some common used functions of netCdf in Xios
+  */
+  class CNetCdfInterface
+  {
+  public:
+    //! Create a netcdf file
+    static int create(const StdString& path, int cmode, int& ncId);
+
+    //! Create a netcdf file on a parallel file system
+    static int createPar(const StdString& path, int cmode, MPI_Comm comm, MPI_Info info, int& ncId);
+
+    //! Open a netcdf file
+    static int open(const StdString& path, int oMode, int& ncId);
+
+    //! Open a netcdf file
+    static int openPar(const StdString& path, int cmode, MPI_Comm comm, MPI_Info info, int& ncId);
+
+    //! Close a netcdf file
+    static int close(int ncId);
+
+    //! Put netcdf file into define mode
+    static int reDef(int ncId);
+
+    //! End define mode of a netcdf file
+    static int endDef(int ncId);
+
+    //! Query identity of a named group
+    static int inqNcId(int ncid, const StdString& grpName, int& grpId);
+
+    //! Query identity of a named variable
+    static int inqVarId(int ncid, const StdString& varName, int& varId);
+
+    //! Query identity of a named dimension
+    static int inqDimId(int ncid,const StdString& dimName, int& dimId);
+
+    //! Query identity of unlimited dimension
+    static int inqUnLimDim(int ncid, int& dimId);
+
+    //! Query name of a dimension with its id
+    static int inqDimName(int ncid, int dimId, StdString& dimName);
+
+    //! Query length of dimension with its id
+    static int inqDimLen(int ncid, int dimId, StdSize& dimLen);
+
+    //! Query number of dimension of a variable with its id
+    static int inqVarNDims(int ncid, int varId, int& nDims);
+
+    //! Query list of dimension of a variable with its id
+    static int inqVarDimId(int, int, int*);
+
+    //! Query dimensions of a group
+    static int inqDimIds(int ncid, int& nDims, int* dimIds, int includeParents);
+
+
+    //! Define a group
+    static int defGrp(int parentNcid,const StdString& grpName, int& grpId);
+
+    //! Define a dimension
+    static int defDim(int ncid,const StdString& dimName, StdSize dimLen, int& dimId);
+
+    //! Define a variable
+    static int defVar(int ncid,const StdString& varName, nc_type xtype,
+                      int nDims, const int dimIds[], int& varId);
+
+    //! Define variable chunking size
+    static int defVarChunking(int ncid, int varId, int storage, StdSize chunkSize[]);
+
+    //! Define variable compression level
+    static int defVarDeflate(int ncid, int varId, int compressionLevel);
+
+    //! Set or unset the fill mode
+    static int setFill(int ncid, bool fill);
+
+    //! Define variable fill parameters
+    static int defVarFill(int ncid, int varId, int noFill, void* fillValue);
+
+
+    //! Change access type of a variable
+    static int varParAccess(int ncid, int varid, int access);
+
+    //! Syn
+    static int sync(int ncId);
+
+    //! Put attribute into variable
+    static int putAtt(int ncid, int varid, const StdString& attrName, nc_type xtype,
+                      StdSize numVal, const void* op);
+
+
+    //! Put attribute into variable with specific type
+    template<typename T>
+    static int putAttType(int ncid, int varid, const StdString& attrName, StdSize numVal, const T* op);
+
+    //! Put value into a variable with a specific type
+    template<typename T>
+    static int putVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const T* op);
+
+  private:
+    template<typename T>
+    static int ncPutAttType(int ncid, int varid, const char* attrName, StdSize numVal, const T* op);
+
+    template<typename T>
+    static int ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const T* op);
+
+  private:
+    static StdString openMode2String(int oMode);
+
+    static StdString creationMode2String(int cMode);
+
+
+  public:
+    // Some functions dedude from several special cases
+    //! Query the existence of a variable
+    static bool isVarExisted(int ncId, const StdString& varName);
+
+  };
+}
+
+
+#endif // NETCDFINTERFACE_HPP_
Index: XIOS/trunk/src/io/netCdfInterface_decl.cpp
===================================================================
--- XIOS/trunk/src/io/netCdfInterface_decl.cpp	(revision 685)
+++ XIOS/trunk/src/io/netCdfInterface_decl.cpp	(revision 685)
@@ -0,0 +1,30 @@
+/*!
+   \file netCdfInterface_impl.hpp
+   \author Ha NGUYEN
+   \date 06 Oct 2014
+   \since 06 Oct 2014
+
+   \brief Implemention of some templated functions in netCdfInterface
+ */
+
+#include "netCdfInterface_impl.hpp"
+
+namespace xios
+{
+#define  macroPutAtt(type) \
+  template int CNetCdfInterface::putAttType(int ncid, int varid, const StdString& attrName, \
+                                            StdSize numVal, const type* op);
+
+  macroPutAtt(double);
+  macroPutAtt(float);
+  macroPutAtt(int);
+  macroPutAtt(long);
+  macroPutAtt(short);
+
+#define  macroPutVar(type) \
+ template int CNetCdfInterface::putVaraType(int ncid, int varId, const StdSize* start, \
+                                            const StdSize* count, const type* op);
+  macroPutVar(double);
+  macroPutVar(float);
+  macroPutVar(int);
+}
Index: XIOS/trunk/src/io/netCdfInterface_impl.hpp
===================================================================
--- XIOS/trunk/src/io/netCdfInterface_impl.hpp	(revision 685)
+++ XIOS/trunk/src/io/netCdfInterface_impl.hpp	(revision 685)
@@ -0,0 +1,77 @@
+/*!
+   \file netCdfInterface_impl.hpp
+   \author Ha NGUYEN
+   \date 08 Oct 2014
+   \since 06 Oct 2014
+
+   \brief Implemention of some templated functions in netCdfInterface
+ */
+
+#ifndef __NETCDF_INTERFACE_IMPL_HPP__
+#define __NETCDF_INTERFACE_IMPL_HPP__
+
+#include "netCdfInterface.hpp"
+#include "netCdfException.hpp"
+
+namespace xios
+{
+   /*!
+   This function makes a request to netcdf with its id, to add or change a variable attribute or gloabl attribute,
+   given its name, type, number of values provided for attribute
+   \param [in] ncid Id of groupd(or File Id)
+   \param [in] varId Id of the variable
+   \param [in] attrName Name of the attribute
+   \param [in] numVal Number of values
+   \param [in] op Array of values provided for attribute
+   \return Error code
+   */
+  template<typename T>
+  int CNetCdfInterface::putAttType(int ncid, int varId, const StdString& attrName,
+                                   StdSize numVal, const T* op)
+  {
+    int status = ncPutAttType(ncid, varId, attrName.c_str(), numVal, op);
+    if (NC_NOERR != status)
+     {
+       StdString errormsg(nc_strerror(status));
+       StdStringStream sstr;
+       sstr << "Error in calling function " << "ncPutAttType(ncid, varId, attrName.c_str(), numVal, op)" << std::endl;
+       sstr << errormsg << std::endl;
+       sstr << "Unable to set attribute " << attrName << " for a variable with id : " << varId
+         << " with number of attribute  " << numVal << std::endl;
+       StdString e = sstr.str();
+       throw CNetCdfException(e);
+     }
+
+     return status;
+  }
+
+   /*!
+   This function makes a request to netcdf with its id, to write variable values into netcdf file,
+   \param [in] ncid Id of groupd(or File Id)
+   \param [in] varId Id of the variable
+   \param [in] start Array specifying the index in the variable where the first data value will be written
+   \param [in] count Array specifying the edge lengths along each dimension of block data
+   \param [in] op Array of values provided for attribute
+   \return Error code
+   */
+  template<typename T>
+  int CNetCdfInterface::putVaraType(int ncid, int varId, const StdSize* start, const StdSize* count, const T* op)
+  {
+    int status = ncPutVaraType(ncid, varId, start, count, op);
+    if (NC_NOERR != status)
+     {
+       StdString errormsg(nc_strerror(status));
+       StdStringStream sstr;
+       sstr << "Error in calling function " << "ncPutVaraType(ncid, varId, start, count, op)" << std::endl;
+       sstr << errormsg << std::endl;
+       sstr << "Unable to write value of a variable with id : " << varId << std::endl;
+       StdString e = sstr.str();
+       throw CNetCdfException(e);
+     }
+
+     return status;
+  }
+
+}
+
+#endif // __NETCDF_INTERFACE_IMPL_HPP__
Index: XIOS/trunk/src/io/netcdf.hpp
===================================================================
--- XIOS/trunk/src/io/netcdf.hpp	(revision 685)
+++ XIOS/trunk/src/io/netcdf.hpp	(revision 685)
@@ -0,0 +1,67 @@
+#ifndef __XIOS_NETCDF_HPP__
+#define __XIOS_NETCDF_HPP__
+#include "mpi.hpp"
+#define MPI_INCLUDED
+#include <netcdf.h>
+
+#if defined(USING_NETCDF_INTERNAL)
+  const bool using_netcdf_internal=true ;
+#else
+  const bool using_netcdf_internal=false ;
+#endif
+
+#include "netcdf_version.hpp"
+
+#if NETCDF_VERSION >= 4110
+
+#  if defined(USING_NETCDF_PAR)
+extern "C"
+{
+#  include <netcdf_par.h>
+}
+#  endif
+#endif
+
+#if !defined(USING_NETCDF_PAR)
+#define NC_INDEPENDENT 0
+#define NC_COLLECTIVE  1
+#endif
+
+namespace xios
+{
+  inline int nc_create_par(const char *path, int cmode, MPI_Comm comm, MPI_Info info,int *ncidp)
+  {
+#if defined(USING_NETCDF_PAR)
+    return ::nc_create_par(path, cmode, comm, info, ncidp) ;
+#else
+    ERROR("int nc_create_par(const char *path, int cmode, MPI_Comm comm, MPI_Info info,int *ncidp)",
+           << "must not be use with netcdf sequential version") ;
+    return -1 ;
+#endif
+  }
+
+  inline int nc_open_par(const char *path, int mode, MPI_Comm comm, MPI_Info info,int *ncidp)
+  {
+#if defined(USING_NETCDF_PAR)
+    return ::nc_open_par(path, mode, comm, info, ncidp) ;
+#else
+    ERROR("int nc_open_par(const char *path, int mode, MPI_Comm comm, MPI_Info info,int *ncidp)",
+           << "must not be use with netcdf sequential version") ;
+    return -1 ;
+#endif
+  }
+
+  inline int nc_var_par_access(int ncid, int varid, int par_access)
+  {
+#if defined(USING_NETCDF_PAR)
+    return ::nc_var_par_access(ncid, varid, par_access) ;
+#else
+    ERROR("int nc_var_par_access(int ncid, int varid, int par_access)",
+           << "must not be use with netcdf sequential version") ;
+    return -1 ;
+#endif
+  }
+}
+
+
+#endif
Index: XIOS/trunk/src/io/netcdf_version.hpp
===================================================================
--- XIOS/trunk/src/io/netcdf_version.hpp	(revision 685)
+++ XIOS/trunk/src/io/netcdf_version.hpp	(revision 685)
@@ -0,0 +1,34 @@
+#ifndef __XIOS_NETCDF_VERSION_HPP__
+#define __XIOS_NETCDF_VERSION_HPP__
+
+#if defined(NC_DISKLESS) && defined (NC_MMAP)
+
+#  define NETCDF_VERSION 4211
+
+#elif defined(NC_ETRANSLATION)
+
+# define NETCDF_VERSION 4130
+
+#elif defined(NC_EURL) && defined(NC_ECONSTRAINT)
+
+#  define NETCDF_VERSION 4120
+
+#elif defined (NC_PNETCDF)
+
+#  define NETCDF_VERSION 4110
+
+#elif defined(NC_CHUNKED) && defined(NC_CONTIGUOUS)
+
+# define NETCDF_VERSION 4010
+
+#elif defined(NC_NETCDF4)
+
+# define NETCDF_VERSION 4000
+
+#else
+
+#  error "netcdf version prior 4.0 incompatible with XIOS"
+ 
+#endif
+
+#endif
Index: XIOS/trunk/src/io/onetcdf4.cpp
===================================================================
--- XIOS/trunk/src/io/onetcdf4.cpp	(revision 685)
+++ XIOS/trunk/src/io/onetcdf4.cpp	(revision 685)
@@ -0,0 +1,578 @@
+#include <fstream>
+
+#include "onetcdf4.hpp"
+#include "group_template.hpp"
+#include "mpi.hpp"
+#include "netcdf.hpp"
+#include "netCdfInterface.hpp"
+#include "netCdfException.hpp"
+
+namespace xios
+{
+      /// ////////////////////// DÃ©finitions ////////////////////// ///
+
+      CONetCDF4::CONetCDF4
+         (const StdString & filename, bool append, bool useClassicFormat, const MPI_Comm* comm, bool multifile)
+            : path()
+            , wmpi(false)
+            , useClassicFormat(useClassicFormat)
+            , recordOffset(0)
+      {
+         this->initialize(filename, append, useClassicFormat, comm,multifile);
+      }
+
+      //---------------------------------------------------------------
+
+
+      CONetCDF4::~CONetCDF4(void)
+      {
+//         CheckError(nc_close(this->ncidp));
+      }
+
+      ///--------------------------------------------------------------
+
+      void CONetCDF4::initialize
+         (const StdString & filename, bool append, bool useClassicFormat, const MPI_Comm* comm, bool multifile)
+      {
+         this->useClassicFormat = useClassicFormat;
+
+         int mode = useClassicFormat ? 0 : NC_NETCDF4;
+
+         // Don't use parallel mode if there is only one process
+         if (comm)
+         {
+            int commSize = 0;
+            MPI_Comm_size(*comm, &commSize);
+            if (commSize <= 1)
+               comm = NULL;
+         }
+         wmpi = comm && !multifile;
+
+         if (wmpi)
+            mode |= useClassicFormat ? NC_PNETCDF : NC_MPIIO;
+
+         // If the file does not exist, we always create it
+         if (!append || !std::ifstream(filename.c_str()))
+         {
+            if (wmpi)
+               CNetCdfInterface::createPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp);
+            else
+               CNetCdfInterface::create(filename, mode, this->ncidp);
+
+            this->appendMode = false;
+            this->recordOffset = 0;
+         }
+         else
+         {
+            mode |= NC_WRITE;
+            if (wmpi)
+               CNetCdfInterface::openPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp);
+            else
+               CNetCdfInterface::open(filename, mode, this->ncidp);
+
+            this->appendMode = true;
+            // Find out how many temporal records have been written already to the file we are opening
+            int ncUnlimitedDimId;
+            CNetCdfInterface::inqUnLimDim(this->ncidp, ncUnlimitedDimId);
+            if (ncUnlimitedDimId != -1)
+               CNetCdfInterface::inqDimLen(this->ncidp, ncUnlimitedDimId, this->recordOffset);
+            else
+               this->recordOffset = 0;
+         }
+
+         // If the classic NetCDF format is used, we enable the "no-fill mode" globally.
+         // This is done per variable for the NetCDF4 format.
+         if (useClassicFormat)
+            CNetCdfInterface::setFill(this->ncidp, false);
+      }
+
+      void CONetCDF4::close()
+      {
+        (CNetCdfInterface::close(this->ncidp));
+      }
+
+      //---------------------------------------------------------------
+
+      void CONetCDF4::definition_start(void)
+      {
+         (CNetCdfInterface::reDef(this->ncidp));
+      }
+
+      //---------------------------------------------------------------
+
+      void CONetCDF4::definition_end(void)
+      {
+         (CNetCdfInterface::endDef(this->ncidp));
+      }
+
+      //---------------------------------------------------------------
+
+// Don't need it anymore?
+//      void CONetCDF4::CheckError(int status)
+//      {
+//         if (status != NC_NOERR)
+//         {
+//            StdString errormsg (nc_strerror(status)); // fuite mÃ©moire ici ?
+//            ERROR("CONetCDF4::CheckError(int status)",
+//                  << "[ status = " << status << " ] " << errormsg);
+//         }
+//      }
+
+      //---------------------------------------------------------------
+
+      int CONetCDF4::getCurrentGroup(void)
+      {
+         return (this->getGroup(this->getCurrentPath()));
+      }
+
+      //---------------------------------------------------------------
+
+      int CONetCDF4::getGroup(const CONetCDF4Path & path)
+      {
+         int retvalue = this->ncidp;
+
+         CONetCDF4Path::const_iterator
+            it  = path.begin(), end = path.end();
+
+         for (;it != end; it++)
+         {
+            const StdString & groupid = *it;
+            (CNetCdfInterface::inqNcId(retvalue, groupid, retvalue));
+         }
+         return (retvalue);
+      }
+
+      //---------------------------------------------------------------
+
+      int CONetCDF4::getVariable(const StdString & varname)
+      {
+         int varid = 0;
+         int grpid = this->getCurrentGroup();
+         (CNetCdfInterface::inqVarId(grpid, varname, varid));
+         return (varid);
+      }
+
+      //---------------------------------------------------------------
+
+      int CONetCDF4::getDimension(const StdString & dimname)
+      {
+         int dimid = 0;
+         int grpid = this->getCurrentGroup();
+         (CNetCdfInterface::inqDimId(grpid, dimname, dimid));
+         return (dimid);
+      }
+
+      //---------------------------------------------------------------
+
+      int CONetCDF4::getUnlimitedDimension(void)
+      {
+         int dimid = 0;
+         int grpid = this->getCurrentGroup();
+         (CNetCdfInterface::inqUnLimDim(grpid, dimid));
+         return (dimid);
+      }
+
+      StdString CONetCDF4::getUnlimitedDimensionName(void)
+      {
+         int grpid = this->getGroup(path);
+         int dimid = this->getUnlimitedDimension();
+
+         if (dimid == -1) return (std::string());
+         StdString dimname;
+         (CNetCdfInterface::inqDimName(grpid, dimid, dimname));
+
+         return (dimname);
+      }
+
+      //---------------------------------------------------------------
+
+      std::vector<StdSize> CONetCDF4::getDimensions(const StdString & varname)
+      {
+         StdSize size = 0;
+         std::vector<StdSize> retvalue;
+         int grpid = this->getCurrentGroup();
+         int varid = this->getVariable(varname);
+         int nbdim = 0, *dimid = NULL;
+
+         (CNetCdfInterface::inqVarNDims(grpid, varid, nbdim));
+         dimid = new int[nbdim]();
+         (CNetCdfInterface::inqVarDimId(grpid, varid, dimid));
+
+         for (int i = 0; i < nbdim; i++)
+         {
+            (CNetCdfInterface::inqDimLen(grpid, dimid[i], size));
+            if (size == NC_UNLIMITED)
+                size = UNLIMITED_DIM;
+            retvalue.push_back(size);
+         }
+         delete [] dimid;
+         return (retvalue);
+      }
+
+      std::vector<std::string> CONetCDF4::getDimensionsIdList (const std::string * _varname)
+      {
+         int nDimNull = 0;
+         int nbdim = 0, *dimid = NULL;
+         int grpid = this->getCurrentGroup();
+         int varid = (_varname != NULL) ? this->getVariable(*_varname) : NC_GLOBAL;
+         std::vector<std::string> retvalue;
+
+         if (_varname != NULL)
+         {
+            (CNetCdfInterface::inqVarNDims(grpid, varid, nbdim));
+            dimid = new int[nbdim]();
+            (CNetCdfInterface::inqVarDimId(grpid, varid, dimid));
+         }
+         else
+         {
+            (CNetCdfInterface::inqDimIds(grpid, nbdim, NULL, 1));
+            dimid = new int[nbdim]();
+            (CNetCdfInterface::inqDimIds(grpid, nDimNull, dimid, 1));
+         }
+
+         for (int i = 0; i < nbdim; i++)
+         {
+            std::string dimname;
+            (CNetCdfInterface::inqDimName(grpid, dimid[i], dimname));
+            retvalue.push_back(dimname);
+         }
+         delete [] dimid;
+
+         return (retvalue);
+      }
+
+
+      //---------------------------------------------------------------
+
+      const CONetCDF4::CONetCDF4Path & CONetCDF4::getCurrentPath(void) const
+      { return (this->path); }
+
+      void CONetCDF4::setCurrentPath(const CONetCDF4Path & path)
+      { this->path = path; }
+
+      //---------------------------------------------------------------
+
+      int CONetCDF4::addGroup(const StdString & name)
+      {
+         int retvalue = 0;
+         int grpid = this->getCurrentGroup();
+         (CNetCdfInterface::defGrp(grpid, name, retvalue));
+         return (retvalue);
+      }
+
+      //---------------------------------------------------------------
+
+      int CONetCDF4::addDimension(const StdString& name, const StdSize size)
+      {
+         int retvalue = 0;
+         int grpid = this->getCurrentGroup();
+         if (size != UNLIMITED_DIM)
+            (CNetCdfInterface::defDim(grpid, name, size, retvalue));
+         else
+            (CNetCdfInterface::defDim(grpid, name, NC_UNLIMITED, retvalue));
+         return (retvalue);
+      }
+
+      //---------------------------------------------------------------
+
+      int CONetCDF4::addVariable(const StdString & name, nc_type type,
+                                 const std::vector<StdString> & dim)
+      {
+         int varid = 0;
+         std::vector<int> dimids;
+         std::vector<StdSize> dimsizes;
+         StdSize size;
+         StdSize totalSize;
+         StdSize maxSize = 1024 * 1024 * 256; // == 2GB/8 if output double
+
+         int grpid = this->getCurrentGroup();
+
+         std::vector<StdString>::const_iterator it = dim.begin(), end = dim.end();
+
+         for (; it != end; it++)
+         {
+            const StdString & dimid = *it;
+            dimids.push_back(this->getDimension(dimid));
+            CNetCdfInterface::inqDimLen(grpid, this->getDimension(dimid), size);
+            if (size == NC_UNLIMITED) size = 1;
+            dimsizes.push_back(size);
+         }
+
+         CNetCdfInterface::defVar(grpid, name, type, dimids.size(), &dimids[0], varid);
+
+         // The classic NetCDF format does not support chunking nor fill parameters
+         if (!useClassicFormat)
+         {
+            // set chunksize : size of one record
+            // but must not be > 2GB (netcdf or HDF5 problem)
+            totalSize = 1;
+            for (vector<StdSize>::reverse_iterator it = dimsizes.rbegin(); it != dimsizes.rend(); ++it)
+            {
+              totalSize *= *it;
+              if (totalSize >= maxSize) *it = 1;
+            }
+
+            CNetCdfInterface::defVarChunking(grpid, varid, NC_CHUNKED, &dimsizes[0]);
+            CNetCdfInterface::defVarFill(grpid, varid, true, NULL);
+         }
+
+         return varid;
+      }
+
+      //---------------------------------------------------------------
+
+      void CONetCDF4::setCompressionLevel(const StdString& varname, int compressionLevel)
+      {
+         if (compressionLevel < 0 || compressionLevel > 9)
+           ERROR("void CONetCDF4::setCompressionLevel(const StdString& varname, int compressionLevel)",
+                 "Invalid compression level for variable \"" << varname << "\", the value should range between 0 and 9.");
+         if (compressionLevel && wmpi)
+           ERROR("void CONetCDF4::setCompressionLevel(const StdString& varname, int compressionLevel)",
+                 "Impossible to use compression for variable \"" << varname << "\" when using parallel mode.");
+
+         int grpid = this->getCurrentGroup();
+         int varid = this->getVariable(varname);
+         CNetCdfInterface::defVarDeflate(grpid, varid, compressionLevel);
+      }
+
+      //---------------------------------------------------------------
+
+      template <>
+         void CONetCDF4::addAttribute
+            (const StdString & name, const StdString & value, const StdString * varname )
+      {
+         int grpid = this->getCurrentGroup();
+         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
+         (CNetCdfInterface::putAtt(grpid, varid, name, NC_CHAR, value.size(), value.c_str()));
+         //CheckError(nc_put_att_string(grpid, varid, name.c_str(), 1, &str));
+      }
+
+      //---------------------------------------------------------------
+
+      template <>
+         void CONetCDF4::addAttribute
+            (const StdString & name, const double & value, const StdString * varname )
+      {
+         int grpid = this->getCurrentGroup();
+         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
+         (CNetCdfInterface::putAttType(grpid, varid, name, 1, &value));
+      }
+
+       template <>
+         void CONetCDF4::addAttribute
+            (const StdString & name, const CArray<double,1>& value, const StdString * varname )
+      {
+         int grpid = this->getCurrentGroup();
+         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
+         (CNetCdfInterface::putAttType(grpid, varid, name, value.numElements(), value.dataFirst()));
+      }
+      //---------------------------------------------------------------
+
+      template <>
+         void CONetCDF4::addAttribute
+            (const StdString & name, const float & value, const StdString * varname )
+      {
+         int grpid = this->getCurrentGroup();
+         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
+         (CNetCdfInterface::putAttType(grpid, varid, name, 1, &value));
+      }
+
+       template <>
+         void CONetCDF4::addAttribute
+            (const StdString & name, const CArray<float,1>& value, const StdString * varname )
+      {
+         int grpid = this->getCurrentGroup();
+         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
+         (CNetCdfInterface::putAttType(grpid, varid, name, value.numElements(), value.dataFirst()));
+      }
+
+      //---------------------------------------------------------------
+
+      template <>
+         void CONetCDF4::addAttribute
+            (const StdString & name, const int & value, const StdString * varname )
+      {
+         int grpid = this->getCurrentGroup();
+         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
+         (CNetCdfInterface::putAttType(grpid, varid, name, 1, &value));
+      }
+
+       template <>
+         void CONetCDF4::addAttribute
+            (const StdString & name, const CArray<int,1>& value, const StdString * varname )
+      {
+         int grpid = this->getCurrentGroup();
+         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
+         (CNetCdfInterface::putAttType(grpid, varid, name, value.numElements(), value.dataFirst()));
+      }
+
+      template <>
+         void CONetCDF4::addAttribute
+            (const StdString & name, const short int & value, const StdString * varname )
+      {
+         int grpid = this->getCurrentGroup();
+         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
+         (CNetCdfInterface::putAttType(grpid, varid, name, 1, &value));
+      }
+
+       template <>
+         void CONetCDF4::addAttribute
+            (const StdString & name, const CArray<short int,1>& value, const StdString * varname )
+      {
+         int grpid = this->getCurrentGroup();
+         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
+         (CNetCdfInterface::putAttType(grpid, varid, name, value.numElements(), value.dataFirst()));
+      }
+
+
+
+      template <>
+         void CONetCDF4::addAttribute
+            (const StdString & name, const long int & value, const StdString * varname )
+      {
+         int grpid = this->getCurrentGroup();
+         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
+         (CNetCdfInterface::putAttType(grpid, varid, name, 1, &value));
+      }
+
+       template <>
+         void CONetCDF4::addAttribute
+            (const StdString & name, const CArray<long int,1>& value, const StdString * varname )
+      {
+         int grpid = this->getCurrentGroup();
+         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
+         (CNetCdfInterface::putAttType(grpid, varid, name, value.numElements(), value.dataFirst()));
+      }
+
+
+
+                //---------------------------------------------------------------
+
+      void CONetCDF4::getWriteDataInfos(const StdString & name, StdSize record, StdSize & array_size,
+                                        std::vector<StdSize> & sstart,
+                                        std::vector<StdSize> & scount,
+                                        const std::vector<StdSize> * start,
+                                        const std::vector<StdSize> * count)
+      {
+         std::vector<std::size_t> sizes  = this->getDimensions(name);
+         std::vector<std::string> iddims = this->getDimensionsIdList (&name);
+         std::vector<std::size_t>::const_iterator
+            it  = sizes.begin(), end = sizes.end();
+         int i = 0;
+
+         if (iddims.begin()->compare(this->getUnlimitedDimensionName()) == 0)
+         {
+            sstart.push_back(record + recordOffset);
+            scount.push_back(1);
+            if ((start == NULL) &&
+                (count == NULL)) i++;
+            it++;
+         }
+
+         for (;it != end; it++)
+         {
+            if ((start != NULL) && (count != NULL))
+            {
+               sstart.push_back((*start)[i]);
+               scount.push_back((*count)[i]);
+               array_size *= (*count)[i];
+               i++;
+            }
+            else
+            {
+               sstart.push_back(0);
+               scount.push_back(sizes[i]);
+               array_size *= sizes[i];
+               i++;
+            }
+         }
+
+      }
+
+
+
+      template <>
+         void CONetCDF4::writeData_(int grpid, int varid,
+                                    const std::vector<StdSize> & sstart,
+                                    const std::vector<StdSize> & scount, const double * data)
+      {
+         (CNetCdfInterface::putVaraType(grpid, varid, &(sstart[0]), &(scount[0]), data));
+//         sync() ;
+      }
+
+      //---------------------------------------------------------------
+
+      template <>
+         void CONetCDF4::writeData_(int grpid, int varid,
+                                    const std::vector<StdSize> & sstart,
+                                    const std::vector<StdSize> & scount, const int * data)
+      {
+          (CNetCdfInterface::putVaraType(grpid, varid, &(sstart[0]), &(scount[0]), data));
+//          sync() ;
+      }
+
+      //---------------------------------------------------------------
+
+      template <>
+         void CONetCDF4::writeData_(int grpid, int varid,
+                                    const std::vector<StdSize> & sstart,
+                                    const std::vector<StdSize> & scount, const float * data)
+      {
+          (CNetCdfInterface::putVaraType(grpid, varid, &(sstart[0]), &(scount[0]), data));
+//          sync() ;
+      }
+
+      //---------------------------------------------------------------
+
+      void CONetCDF4::writeData(const CArray<int, 2>& data, const StdString & name)
+      {
+         int grpid = this->getCurrentGroup();
+         int varid = this->getVariable(name);
+         StdSize array_size = 1;
+         std::vector<StdSize> sstart, scount;
+
+         this->getWriteDataInfos(name, 0, array_size,  sstart, scount, NULL, NULL);
+         this->writeData_(grpid, varid, sstart, scount, data.dataFirst());
+      }
+
+      void CONetCDF4::writeTimeAxisData(const CArray<double, 1>& data, const StdString & name,
+                                        bool collective, StdSize record, bool isRoot)
+      {
+         int grpid = this->getCurrentGroup();
+         int varid = this->getVariable(name);
+
+         map<int,size_t>::iterator it=timeAxis.find(varid) ;
+         if (it==timeAxis.end()) timeAxis[varid]=record ;
+         else
+         {
+           if (it->second >= record) return ;
+           else it->second =record ;
+         }
+
+         StdSize array_size = 1;
+         std::vector<StdSize> sstart, scount;
+
+         if (this->wmpi && collective)
+         (CNetCdfInterface::varParAccess(grpid, varid, NC_COLLECTIVE));
+         if (this->wmpi && !collective)
+         (CNetCdfInterface::varParAccess(grpid, varid, NC_INDEPENDENT));
+
+         this->getWriteDataInfos(name, record, array_size,  sstart, scount, NULL, NULL);
+         if (using_netcdf_internal)  if (!isRoot) { sstart[0]=sstart[0]+1 ; scount[0]=0 ;}
+         this->writeData_(grpid, varid, sstart, scount, data.dataFirst());
+       }
+
+      //---------------------------------------------------------------
+
+      bool CONetCDF4::varExist(const StdString & varname)
+      {
+         int grpid = this->getCurrentGroup();
+         return (CNetCdfInterface::isVarExisted(grpid, varname));
+      }
+
+      void CONetCDF4::sync(void)
+      {
+         (CNetCdfInterface::sync(this->ncidp)) ;
+      }
+      ///--------------------------------------------------------------
+ } // namespace xios
Index: XIOS/trunk/src/io/onetcdf4.hpp
===================================================================
--- XIOS/trunk/src/io/onetcdf4.hpp	(revision 685)
+++ XIOS/trunk/src/io/onetcdf4.hpp	(revision 685)
@@ -0,0 +1,134 @@
+#ifndef __XIOS_ONETCDF4__
+#define __XIOS_ONETCDF4__
+
+/// XIOS headers ///
+#include "xios_spl.hpp"
+#include "exception.hpp"
+#include "data_output.hpp"
+#include "array_new.hpp"
+#include "mpi.hpp"
+#include "netcdf.hpp"
+
+#ifndef UNLIMITED_DIM
+   #define UNLIMITED_DIM (size_t)(-1)
+#endif  //UNLIMITED_DIM
+
+namespace xios
+{
+      /// ////////////////////// DÃ©clarations ////////////////////// ///
+      class CONetCDF4
+         : public virtual CDataOutput
+      {
+         public :
+
+            /// DÃ©finition de type ///
+            typedef std::vector<StdString> CONetCDF4Path;
+
+            /// Constructeurs ///
+            CONetCDF4(const StdString & filename, bool append, bool useClassicFormat = false,
+                      const MPI_Comm * comm = NULL, bool multifile = true);
+
+            CONetCDF4(const CONetCDF4 & onetcdf4);       // Not implemented.
+            CONetCDF4(const CONetCDF4 * const onetcdf4); // Not implemented.
+
+
+            /// Initialisation ///
+            void initialize(const StdString & filename, bool append, bool useClassicFormat,
+                            const MPI_Comm * comm, bool multifile);
+            void close(void) ;
+            void sync(void) ;
+            void definition_start(void);
+            void definition_end(void);
+
+            /// Mutateurs ///
+            void setCurrentPath(const CONetCDF4Path & path);
+
+            int addGroup(const StdString & name);
+            int addDimension(const StdString& name, const StdSize size = UNLIMITED_DIM);
+            int addVariable(const StdString & name, nc_type type,
+                            const std::vector<StdString> & dim);
+
+      //----------------------------------------------------------------
+         public :
+
+            template <class T>
+               void setDefaultValue(const StdString & varname, const T * value = NULL);
+
+            void setCompressionLevel(const StdString& varname, int compressionLevel);
+
+            template <class T>  void addAttribute (const StdString & name, const T & value, const StdString * varname = NULL);
+
+            /// Ecriture des donnÃ©es ///
+            template <class T, int ndim>
+               void writeData(const CArray<T,ndim>& data, const StdString & name,
+                              bool collective, StdSize record,
+                              const std::vector<StdSize> * start = NULL,
+                              const std::vector<StdSize> * count = NULL);
+
+            void writeData(const CArray<int, 2>& data, const StdString & name);
+            void writeTimeAxisData(const CArray<double,1>& data, const StdString & name,
+                                   bool collective, StdSize record, bool Isroot) ;
+            /// Accesseur ///
+            const CONetCDF4Path & getCurrentPath(void) const;
+
+            /// Destructeur ///
+            virtual ~CONetCDF4(void);
+
+      //----------------------------------------------------------------
+
+         protected :
+
+            /// Ecriture ///
+            virtual void writeField_ (CField*  field)  = 0;
+            virtual void writeDomain_(CDomain* domain) = 0;
+            virtual void writeAxis_  (CAxis*   axis)   = 0;
+
+            /// Accesseurs ///
+            int getCurrentGroup(void);
+            int getGroup(const CONetCDF4Path & path);
+            int getVariable(const StdString & varname);
+            int getDimension(const StdString & dimname);
+            std::vector<StdSize>   getDimensions       (const StdString & varname);
+            std::vector<StdString> getDimensionsIdList (const StdString * varname);
+            int       getUnlimitedDimension(void);
+            StdString getUnlimitedDimensionName(void);
+
+            bool varExist(const StdString & varname);
+
+            bool useClassicFormat; //!< If true, NetCDF4 will use the classic NetCDF3 format
+
+      //----------------------------------------------------------------
+
+         private :
+
+            template <class T>
+               void writeData_(int grpid, int varid,
+                               const std::vector<StdSize> & sstart,
+                               const std::vector<StdSize> & scount, T * data);
+
+            void getWriteDataInfos(const StdString & name, StdSize record, StdSize & array_size,
+                                   std::vector<StdSize> & sstart,
+                                   std::vector<StdSize> & scount,
+                                   const std::vector<StdSize> * start,
+                                   const std::vector<StdSize> * count);
+
+            /// VÃ©rification des erreurs NetCDF ///
+            void CheckError(int status);
+
+            /// PropriÃ©tÃ©s privÃ©es ///
+            CONetCDF4Path path;
+            int ncidp;
+            bool wmpi;
+            /*! Number of records already written when opening an existing file.
+             *  always 0 when creating a new file */
+            size_t recordOffset;
+            map<int,size_t> timeAxis ;
+      }; // class CONetCDF4
+
+      ///---------------------------------------------------------------
+
+
+
+} // namespace xios
+
+#endif //__XIOS_ONETCDF4__
Index: XIOS/trunk/src/io/onetcdf4_decl.cpp
===================================================================
--- XIOS/trunk/src/io/onetcdf4_decl.cpp	(revision 685)
+++ XIOS/trunk/src/io/onetcdf4_decl.cpp	(revision 685)
@@ -0,0 +1,18 @@
+#include "onetcdf4_impl.hpp"
+
+namespace xios
+{
+# define  macro(type,size) \
+  template void CONetCDF4::writeData<type,size>(const CArray<type, size>& data, const StdString & name, \
+                                               bool collective, StdSize record, \
+                                               const std::vector<StdSize> * start, \
+                                               const std::vector<StdSize> * count) ;
+ 
+  macro(int, 1)
+  macro(double, 1)
+  macro(double, 2)
+  macro(double, 3)
+ 
+  template void CONetCDF4::setDefaultValue<double>(const StdString & varname, const double* value) ;
+  template void CONetCDF4::setDefaultValue<float>(const StdString & varname, const float* value) ;
+}
Index: XIOS/trunk/src/io/onetcdf4_impl.hpp
===================================================================
--- XIOS/trunk/src/io/onetcdf4_impl.hpp	(revision 685)
+++ XIOS/trunk/src/io/onetcdf4_impl.hpp	(revision 685)
@@ -0,0 +1,69 @@
+#ifndef __ONETCDF4_IMPL_HPP__
+#define __ONETCDF4_IMPL_HPP__
+
+#include "onetcdf4.hpp"
+#include "netCdfInterface.hpp"
+
+namespace xios
+{
+  template <class T, int ndim>
+  void CONetCDF4::writeData(const CArray<T, ndim>& data, const StdString & name,
+                            bool collective, StdSize record,
+                            const std::vector<StdSize> * start,
+                            const std::vector<StdSize> * count)
+  {
+    int grpid = this->getCurrentGroup();
+    int varid = this->getVariable(name);
+    StdSize array_size = 1;
+    std::vector<StdSize> sstart, scount;
+
+    if (this->wmpi && collective)
+    CNetCdfInterface::varParAccess(grpid, varid, NC_COLLECTIVE);
+    if (this->wmpi && !collective)
+    CNetCdfInterface::varParAccess(grpid, varid, NC_INDEPENDENT);
+
+    this->getWriteDataInfos
+    (name, record, array_size,  sstart, scount, start, count);
+    if (data.numElements() != array_size)
+    {
+      ERROR("CONetCDF4::writeData(...)",
+      << "[ input array size = "  << data.numElements()
+      << ", intern array size = " << array_size
+      << " ] Invalid input data !" );
+    }
+
+    this->writeData_(grpid, varid, sstart, scount, data.dataFirst());
+  }
+
+//----------------------------------------------------------------
+
+  template <class T>
+  void CONetCDF4::setDefaultValue(const StdString & varname, const T * value)
+  {
+    int grpid = this->getCurrentGroup();
+    int varid = this->getVariable(varname);
+
+    if (value != NULL)
+    {
+      // nc_def_var_fill will automatically set the _FillValue attribute when
+      // using the NetCDF 4 format but we need to do it manually otherwise
+      if (useClassicFormat)
+        this->addAttribute(StdString("_FillValue"), *value, &varname);
+      else
+        CNetCdfInterface::defVarFill(grpid, varid, 0, (void*)value);
+      this->addAttribute(StdString("missing_value"), *value, &varname);
+    }
+    else if (!useClassicFormat)
+    {
+      // The "no-fill mode" is set globally for the classic NetCDF format
+      CNetCdfInterface::defVarFill(grpid, varid, 1, NULL);
+    }
+  }
+
+  ///---------------------------------------------------------------
+
+}
+
+
+
+#endif
Index: XIOS/trunk/src/output/nc4_data_output.cpp
===================================================================
--- XIOS/trunk/src/output/nc4_data_output.cpp	(revision 684)
+++ 	(revision )
@@ -1,1895 +1,0 @@
-
-#include "nc4_data_output.hpp"
-
-#include <boost/lexical_cast.hpp>
-#include "attribute_template.hpp"
-#include "group_template.hpp"
-
-#include "file.hpp"
-#include "calendar.hpp"
-#include "context.hpp"
-#include "context_server.hpp"
-#include "netCdfException.hpp"
-#include "exception.hpp"
-
-namespace xios
-{
-      /// ////////////////////// DÃ©finitions ////////////////////// ///
-      CNc4DataOutput::CNc4DataOutput
-         (const StdString & filename, bool exist)
-            : SuperClass()
-            , SuperClassWriter(filename, exist)
-            , filename(filename)
-      {
-         StdString timeid = StdString("time_counter");
-         SuperClass::type = MULTI_FILE;
-//         if (!exist)
-//            SuperClassWriter::addDimension(timeid);
-      }
-
-      CNc4DataOutput::CNc4DataOutput
-         (const StdString & filename, bool exist, bool useClassicFormat,
-          MPI_Comm comm_file,bool multifile, bool isCollective)
-            : SuperClass()
-            , SuperClassWriter(filename, exist, useClassicFormat, &comm_file, multifile)
-            , comm_file(comm_file)
-            , filename(filename)
-            , isCollective(isCollective)
-      {
-         StdString timeid = StdString("time_counter");
-
-         SuperClass::type = (multifile) ? MULTI_FILE : ONE_FILE;
-
- //        if (!exist)
-//            SuperClassWriter::addDimension(timeid);
-      }
-
-
-      CNc4DataOutput::~CNc4DataOutput(void)
-      { /* Ne rien faire de plus */ }
-
-      ///--------------------------------------------------------------
-
-      const StdString & CNc4DataOutput::getFileName(void) const
-      {
-         return (this->filename);
-      }
-
-      //---------------------------------------------------------------
-
-      void CNc4DataOutput::writeDomain_(CDomain* domain)
-      {
-         if (domain->type == CDomain::type_attr::unstructured)
-         {
-           writeUnstructuredDomain(domain) ;
-           return ;
-         }
-
-         CContext* context = CContext::getCurrent() ;
-         CContextServer* server=context->server ;
-
-         if (domain->IsWritten(this->filename)) return;
-         domain->checkAttributes();
-
-         if (domain->isEmpty())
-           if (SuperClass::type==MULTI_FILE) return ;
-
-         std::vector<StdString> dim0, dim1;
-         StdString domid     = (!domain->name.isEmpty())
-                             ? domain->name.getValue() : domain->getId();
-         StdString appendDomid  = (singleDomain) ? "" : "_"+domid ;
-
-
-         StdString dimXid, dimYid ;
-
-         bool isRegularDomain = (domain->type == CDomain::type_attr::rectilinear);
-         switch (domain->type)
-         {
-           case CDomain::type_attr::curvilinear :
-             dimXid     = StdString("x").append(appendDomid);
-             dimYid     = StdString("y").append(appendDomid);
-             break ;
-           case CDomain::type_attr::rectilinear :
-             dimXid     = StdString("lon").append(appendDomid);
-             dimYid     = StdString("lat").append(appendDomid);
-             break;
-         }
-
-         StdString dimVertId = StdString("nvertex").append(appendDomid);
-
-         string lonid,latid,bounds_lonid,bounds_latid ;
-         string areaId = "area" + appendDomid;
-/*
-         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;
-*/
-
-         try
-         {
-           switch (SuperClass::type)
-           {
-              case (MULTI_FILE) :
-              {
-  //               if (domain->isEmpty()) return;
-
-                 if (server->intraCommSize > 1)
-                 {
-  //                 SuperClassWriter::addDimension(lonid, domain->zoom_ni.getValue());
-  //                 SuperClassWriter::addDimension(latid, domain->zoom_nj.getValue());
-                 }
-
-                 switch (domain->type)
-                 {
-                   case CDomain::type_attr::curvilinear :
-                     dim0.push_back(dimYid); dim0.push_back(dimXid);
-                     lonid = StdString("nav_lon").append(appendDomid);
-                     latid = StdString("nav_lat").append(appendDomid);
-                     break ;
-                   case CDomain::type_attr::rectilinear :
-                     lonid = StdString("lon").append(appendDomid);
-                     latid = StdString("lat").append(appendDomid);
-                     dim0.push_back(dimYid);
-                     dim1.push_back(dimXid);
-                     break;
-                 }
-
-                 bounds_lonid = StdString("bounds_lon").append(appendDomid);
-                 bounds_latid = StdString("bounds_lat").append(appendDomid);
-
-                 SuperClassWriter::addDimension(dimXid, domain->zoom_ni_srv);
-                 SuperClassWriter::addDimension(dimYid, domain->zoom_nj_srv);
-
-                 if (domain->hasBounds)
-                   SuperClassWriter::addDimension(dimVertId, domain->nvertex);
-
-                 if (server->intraCommSize > 1)
-                 {
-                   this->writeLocalAttributes(domain->zoom_ibegin_srv,
-                                              domain->zoom_ni_srv,
-                                              domain->zoom_jbegin_srv,
-                                              domain->zoom_nj_srv,
-                                              appendDomid);
-
-                   if (singleDomain)
-                    this->writeLocalAttributes_IOIPSL(dimXid, dimYid,
-                                                      domain->zoom_ibegin_srv,
-                                                      domain->zoom_ni_srv,
-                                                      domain->zoom_jbegin_srv,
-                                                      domain->zoom_nj_srv,
-                                                      domain->ni_glo,domain->nj_glo,
-                                                      server->intraCommRank,server->intraCommSize);
-                 }
-
-                 if (domain->hasLonLat)
-                 {
-                   switch (domain->type)
-                   {
-                     case CDomain::type_attr::curvilinear :
-                       SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
-                       SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0);
-                       break ;
-                      case CDomain::type_attr::rectilinear :
-                        SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
-                        SuperClassWriter::addVariable(lonid, NC_FLOAT, dim1);
-                        break ;
-                   }
-
-                   this->writeAxisAttributes(lonid, isRegularDomain ? "X" : "", "longitude", "Longitude", "degrees_east", domid);
-                   this->writeAxisAttributes(latid, isRegularDomain ? "Y" : "", "latitude", "Latitude", "degrees_north", domid);
-
-                   if (domain->hasBounds)
-                   {
-                     SuperClassWriter::addAttribute("bounds", bounds_lonid, &lonid);
-                     SuperClassWriter::addAttribute("bounds", bounds_latid, &latid);
-
-                     dim0.clear();
-                     dim0.push_back(dimYid);
-                     dim0.push_back(dimXid);
-                     dim0.push_back(dimVertId);
-                     SuperClassWriter::addVariable(bounds_lonid, NC_FLOAT, dim0);
-                     SuperClassWriter::addVariable(bounds_latid, NC_FLOAT, dim0);
-                   }
-                 }
-
-                 dim0.clear();
-                 dim0.push_back(dimYid);
-                 dim0.push_back(dimXid);
-
-
-  // supress mask               if (server->intraCommSize > 1)
-  // supress mask               {
-  // supress mask                  SuperClassWriter::addVariable(maskid, NC_INT, dim0);
-  // supress mask
-  // supress mask                  this->writeMaskAttributes(maskid,
-  // supress mask                     domain->data_dim.getValue()/*,
-  // supress mask                     domain->data_ni.getValue(),
-  // supress mask                     domain->data_nj.getValue(),
-  // supress mask                     domain->data_ibegin.getValue(),
-  // supress mask                     domain->data_jbegin.getValue()*/);
-  // supress mask               }
-
-                 //SuperClassWriter::setDefaultValue(maskid, &dvm);
-
-                 if (domain->hasArea)
-                 {
-                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0);
-                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId);
-                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId);
-                 }
-
-                 SuperClassWriter::definition_end();
-
-                 if (domain->hasLonLat)
-                 {
-                   switch (domain->type)
-                   {
-                     case CDomain::type_attr::curvilinear :
-                       SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0);
-                       SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0);
-                       break;
-                     case CDomain::type_attr::rectilinear :
-                       CArray<double,1> lat = domain->latvalue_srv(Range(fromStart,toEnd,domain->zoom_ni_srv)) ;
-                       SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0);
-                       CArray<double,1> lon=domain->lonvalue_srv(Range(0,domain->zoom_ni_srv-1)) ;
-                       SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0);
-                       break;
-                   }
-
-                   if (domain->hasBounds)
-                   {
-                     SuperClassWriter::writeData(domain->bounds_lon_srv, bounds_lonid, isCollective, 0);
-                     SuperClassWriter::writeData(domain->bounds_lat_srv, bounds_latid, isCollective, 0);
-                   }
-                 }
-
-                 if (domain->hasArea)
-                   SuperClassWriter::writeData(domain->area_srv, areaId, isCollective, 0);
-
-                 SuperClassWriter::definition_start();
-
-                 break;
-              }
-              case (ONE_FILE) :
-              {
-                 SuperClassWriter::addDimension(dimXid, domain->global_zoom_ni);
-                 SuperClassWriter::addDimension(dimYid, domain->global_zoom_nj);
-
-                 if (domain->hasBounds)
-                   SuperClassWriter::addDimension(dimVertId, domain->nvertex);
-
-                 if (domain->hasLonLat)
-                 {
-                   switch (domain->type)
-                   {
-                     case CDomain::type_attr::curvilinear :
-                       dim0.push_back(dimYid); dim0.push_back(dimXid);
-                       lonid = StdString("nav_lon").append(appendDomid);
-                       latid = StdString("nav_lat").append(appendDomid);
-                       SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
-                       SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0);
-                       break;
-
-                     case CDomain::type_attr::rectilinear :
-                       dim0.push_back(dimYid);
-                       dim1.push_back(dimXid);
-                       lonid = StdString("lon").append(appendDomid);
-                       latid = StdString("lat").append(appendDomid);
-                       SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
-                       SuperClassWriter::addVariable(lonid, NC_FLOAT, dim1);
-                       break;
-                   }
-
-                   bounds_lonid = StdString("bounds_lon").append(appendDomid);
-                   bounds_latid = StdString("bounds_lat").append(appendDomid);
-
-                   this->writeAxisAttributes
-                      (lonid, isRegularDomain ? "X" : "", "longitude", "Longitude", "degrees_east", domid);
-                   this->writeAxisAttributes
-                      (latid, isRegularDomain ? "Y" : "", "latitude", "Latitude", "degrees_north", domid);
-
-                   if (domain->hasBounds)
-                   {
-                     SuperClassWriter::addAttribute("bounds", bounds_lonid, &lonid);
-                     SuperClassWriter::addAttribute("bounds", bounds_latid, &latid);
-
-                     dim0.clear();
-                     dim0.push_back(dimYid);
-                     dim0.push_back(dimXid);
-                     dim0.push_back(dimVertId);
-                     SuperClassWriter::addVariable(bounds_lonid, NC_FLOAT, dim0);
-                     SuperClassWriter::addVariable(bounds_latid, NC_FLOAT, dim0);
-                   }
-                 }
-
-                 if (domain->hasArea)
-                 {
-                   dim0.clear();
-                   dim0.push_back(dimYid); dim0.push_back(dimXid);
-                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0);
-                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId);
-                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId);
-                   dim0.clear();
-                 }
-
-                 SuperClassWriter::definition_end();
-
-                 switch (domain->type)
-                 {
-                   case CDomain::type_attr::curvilinear :
-                   {
-                     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->global_zoom_ibegin;
-                       start[0]=domain->zoom_jbegin_srv-domain->global_zoom_jbegin;
-                       count[1]=domain->zoom_ni_srv ; count[0]=domain->zoom_nj_srv ;
-                     }
-
-                     if (domain->hasLonLat)
-                     {
-                       SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0,&start,&count);
-                       SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0,&start,&count);
-                     }
-                     break;
-                   }
-                   case CDomain::type_attr::rectilinear :
-                   {
-                     if (domain->hasLonLat)
-                     {
-                       std::vector<StdSize> start(1) ;
-                       std::vector<StdSize> count(1) ;
-                       if (domain->isEmpty())
-                       {
-                         start[0]=0 ;
-                         count[0]=0 ;
-                         SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0,&start,&count);
-                         SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0,&start,&count);
-
-                       }
-                       else
-                       {
-                         start[0]=domain->zoom_jbegin_srv-domain->global_zoom_jbegin;
-                         count[0]=domain->zoom_nj_srv ;
-                         CArray<double,1> lat = domain->latvalue_srv(Range(fromStart,toEnd,domain->zoom_ni_srv)) ;
-                         SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0,&start,&count);
-
-                         start[0]=domain->zoom_ibegin_srv-domain->global_zoom_ibegin;
-                         count[0]=domain->zoom_ni_srv ;
-                         CArray<double,1> lon=domain->lonvalue_srv(Range(0,domain->zoom_ni_srv-1)) ;
-                         SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0,&start,&count);
-                       }
-                     }
-                     break;
-                   }
-                 }
-
-                 if (domain->hasBounds)
-                 {
-                   std::vector<StdSize> start(3);
-                   std::vector<StdSize> count(3);
-                   if (domain->isEmpty())
-                   {
-                     start[2] = start[1] = start[0] = 0;
-                     count[2] = count[1] = count[0] = 0;
-                   }
-                   else
-                   {
-                     start[2] = 0;
-                     start[1] = domain->zoom_ibegin_srv - domain->global_zoom_ibegin;
-                     start[0] = domain->zoom_jbegin_srv - domain->global_zoom_jbegin;
-                     count[2] = domain->nvertex;
-                     count[1] = domain->zoom_ni_srv;
-                     count[0] = domain->zoom_nj_srv;
-                   }
-
-                   SuperClassWriter::writeData(domain->bounds_lon_srv, bounds_lonid, isCollective, 0, &start, &count);
-                   SuperClassWriter::writeData(domain->bounds_lat_srv, bounds_latid, isCollective, 0, &start, &count);
-                 }
-
-                 if (domain->hasArea)
-                 {
-                   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->global_zoom_ibegin;
-                     start[0] = domain->zoom_jbegin_srv - domain->global_zoom_jbegin;
-                     count[1] = domain->zoom_ni_srv;
-                     count[0] = domain->zoom_nj_srv;
-                   }
-
-                   SuperClassWriter::writeData(domain->area_srv, areaId, isCollective, 0, &start, &count);
-                 }
-
-                 SuperClassWriter::definition_start();
-                 break;
-              }
-              default :
-                 ERROR("CNc4DataOutput::writeDomain(domain)",
-                       << "[ type = " << SuperClass::type << "]"
-                       << " not implemented yet !");
-           }
-         }
-         catch (CNetCdfException& e)
-         {
-           StdString msg("On writing the domain : ");
-           msg.append(domid); msg.append("\n");
-           msg.append("In the context : ");
-           msg.append(context->getId()); msg.append("\n");
-           msg.append(e.what());
-           ERROR("CNc4DataOutput::writeDomain_(CDomain* domain)", << msg);
-         }
-
-         domain->addRelFile(this->filename);
-      }
-
-      void CNc4DataOutput::writeUnstructuredDomain(CDomain* domain)
-      {
-         CContext* context = CContext::getCurrent() ;
-         CContextServer* server=context->server ;
-
-         if (domain->IsWritten(this->filename)) return;
-         domain->checkAttributes();
-
-         if (domain->isEmpty())
-           if (SuperClass::type==MULTI_FILE) return ;
-
-         std::vector<StdString> dim0, dim1;
-         StdString domid     = (!domain->name.isEmpty())
-                             ? domain->name.getValue() : domain->getId();
-         StdString appendDomid  = (singleDomain) ? "" : "_"+domid ;
-
-
-         StdString dimXid = StdString("cell").append(appendDomid);
-         StdString dimVertId = StdString("nvertex").append(appendDomid);
-
-         string lonid,latid,bounds_lonid,bounds_latid ;
-         string areaId = "area" + appendDomid;
-
-         try
-         {
-           switch (SuperClass::type)
-           {
-              case (MULTI_FILE) :
-              {
-                 dim0.push_back(dimXid);
-                 SuperClassWriter::addDimension(dimXid, domain->zoom_ni_srv);
-
-                 lonid = StdString("lon").append(appendDomid);
-                 latid = StdString("lat").append(appendDomid);
-                 bounds_lonid = StdString("bounds_lon").append(appendDomid);
-                 bounds_latid = StdString("bounds_lat").append(appendDomid);
-                 if (domain->hasLonLat)
-                 {
-                   SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
-                   SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0);
-                   this->writeAxisAttributes(lonid, "", "longitude", "Longitude", "degrees_east", domid);
-                   if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_lonid, &lonid);
-                   this->writeAxisAttributes(latid, "", "latitude", "Latitude", "degrees_north", domid);
-                   if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_latid, &latid);
-                   if (domain->hasBounds) SuperClassWriter::addDimension(dimVertId, domain->nvertex);
-                 }
-
-                 dim0.clear();
-                 if (domain->hasBounds)
-                 {
-                   dim0.push_back(dimXid);
-                   dim0.push_back(dimVertId);
-                   SuperClassWriter::addVariable(bounds_lonid, NC_FLOAT, dim0);
-                   SuperClassWriter::addVariable(bounds_latid, NC_FLOAT, dim0);
-                 }
-
-                 dim0.clear();
-                 dim0.push_back(dimXid);
-                 if (domain->hasArea)
-                 {
-                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0);
-                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId);
-                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId);
-                 }
-
-                 SuperClassWriter::definition_end();
-
-                 if (domain->hasLonLat)
-                 {
-                   SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0);
-                   SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0);
-                   if (domain->hasBounds)
-                   {
-                     SuperClassWriter::writeData(domain->bounds_lon_srv, bounds_lonid, isCollective, 0);
-                     SuperClassWriter::writeData(domain->bounds_lat_srv, bounds_latid, isCollective, 0);
-                   }
-                 }
-
-                 if (domain->hasArea)
-                   SuperClassWriter::writeData(domain->area_srv, areaId, isCollective, 0);
-
-                 SuperClassWriter::definition_start();
-                 break ;
-              }
-
-              case (ONE_FILE) :
-              {
-                 lonid = StdString("lon").append(appendDomid);
-                 latid = StdString("lat").append(appendDomid);
-                 bounds_lonid = StdString("bounds_lon").append(appendDomid);
-                 bounds_latid = StdString("bounds_lat").append(appendDomid);
-                 dim0.push_back(dimXid);
-                 SuperClassWriter::addDimension(dimXid, domain->nj_glo);
-                 if (domain->hasLonLat)
-                 {
-                   SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
-                   SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0);
-
-                   this->writeAxisAttributes(lonid, "", "longitude", "Longitude", "degrees_east", domid);
-                   if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_lonid, &lonid);
-                   this->writeAxisAttributes(latid, "", "latitude", "Latitude", "degrees_north", domid);
-                   if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_latid, &latid);
-                   if (domain->hasBounds) SuperClassWriter::addDimension(dimVertId, domain->nvertex);
-                 }
-                 dim0.clear();
-
-                 if (domain->hasBounds)
-                 {
-                   dim0.push_back(dimXid);
-                   dim0.push_back(dimVertId);
-                   SuperClassWriter::addVariable(bounds_lonid, NC_FLOAT, dim0);
-                   SuperClassWriter::addVariable(bounds_latid, NC_FLOAT, dim0);
-                 }
-
-                 if (domain->hasArea)
-                 {
-                   dim0.clear();
-                   dim0.push_back(dimXid);
-                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0);
-                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId);
-                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId);
-                 }
-
-                 SuperClassWriter::definition_end();
-
-                 std::vector<StdSize> start(1), startBounds(2) ;
-                 std::vector<StdSize> count(1), countBounds(2) ;
-                 if (domain->isEmpty())
-                 {
-                   start[0]=0 ;
-                   count[0]=0 ;
-                   startBounds[1]=0 ;
-                   countBounds[1]=domain->nvertex ;
-                   startBounds[0]=0 ;
-                   countBounds[0]=0 ;
-                 }
-                 else
-                 {
-                   start[0]=domain->zoom_jbegin_srv-domain->global_zoom_jbegin;
-                   count[0]=domain->zoom_nj_srv ;
-                   startBounds[0]=domain->zoom_jbegin_srv-domain->global_zoom_jbegin;
-                   startBounds[1]=0 ;
-                   countBounds[0]=domain->zoom_nj_srv ;
-                   countBounds[1]=domain->nvertex ;
-                 }
-
-                 if (domain->hasLonLat)
-                 {
-                   SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0,&start,&count);
-                   SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0,&start,&count);
-                   if (domain->hasBounds)
-                   {
-                     SuperClassWriter::writeData(domain->bounds_lon_srv, bounds_lonid, isCollective, 0,&startBounds,&countBounds);
-                     SuperClassWriter::writeData(domain->bounds_lat_srv, bounds_latid, isCollective, 0,&startBounds,&countBounds);
-                   }
-                 }
-
-                 if (domain->hasArea)
-                   SuperClassWriter::writeData(domain->area_srv, areaId, isCollective, 0, &start, &count);
-
-                 SuperClassWriter::definition_start();
-
-                 break;
-              }
-              default :
-                 ERROR("CNc4DataOutput::writeDomain(domain)",
-                       << "[ type = " << SuperClass::type << "]"
-                       << " not implemented yet !");
-           }
-         }
-         catch (CNetCdfException& e)
-         {
-           StdString msg("On writing the domain : ");
-           msg.append(domid); msg.append("\n");
-           msg.append("In the context : ");
-           msg.append(context->getId()); msg.append("\n");
-           msg.append(e.what());
-           ERROR("CNc4DataOutput::writeUnstructuredDomain(CDomain* domain)", << msg);
-         }
-         domain->addRelFile(this->filename);
-      }
-      //--------------------------------------------------------------
-
-      void CNc4DataOutput::writeAxis_(CAxis* axis)
-      {
-        if (axis->IsWritten(this->filename)) return;
-        axis->checkAttributes();
-        int zoom_size_srv  = axis->zoom_size_srv;
-        int zoom_begin_srv = axis->zoom_begin_srv;
-        int zoom_size  = (MULTI_FILE == SuperClass::type) ? zoom_size_srv
-                                                              : axis->global_zoom_size;
-        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;
-        StdString axisid = !axis->name.isEmpty() ? axis->name.getValue() : axis->getId();
-        try
-        {
-          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:
-            {
-              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())
-              {
-                CArray<double,2> axisBounds(2, zoom_size_srv);
-                for (int i = 0; i < zoom_size_srv; ++i)
-                {
-                  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, &start, &count);
-              }
-
-              SuperClassWriter::definition_start();
-
-              break;
-            }
-            default :
-              ERROR("CNc4DataOutput::writeDomain(domain)",
-                    << "[ 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);
-        }
-        axis->addRelFile(this->filename);
-     }
-
-     //--------------------------------------------------------------
-
-     void CNc4DataOutput::writeGridCompressed_(CGrid* grid)
-     {
-       if (grid->isScalarGrid() || grid->isWrittenCompressed(this->filename)) return;
-
-       try
-       {
-         CArray<bool,1> axisDomainOrder = grid->axis_domain_order;
-         std::vector<StdString> domainList = grid->getDomainList();
-         std::vector<StdString> axisList   = grid->getAxisList();
-         int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0;
-
-         std::vector<StdString> dims;
-
-         if (grid->isCompressible())
-         {
-           StdString varId = grid->getId() + "_points";
-
-           int nbIndexes = (SuperClass::type == MULTI_FILE) ? grid->getNumberWrittenIndexes() : grid->getTotalNumberWrittenIndexes();
-           SuperClassWriter::addDimension(varId, nbIndexes);
-
-           dims.push_back(varId);
-           SuperClassWriter::addVariable(varId, NC_INT, dims);
-
-           StdOStringStream compress;
-           for (int i = numElement - 1; i >= 0; --i)
-           {
-             if (axisDomainOrder(i))
-             {
-               CDomain* domain = CDomain::get(domainList[domainList.size() - idxDomain - 1]);
-               StdString domId = !domain->name.isEmpty() ? domain->name.getValue() : domain->getId();
-               StdString appendDomId  = singleDomain ? "" : "_" + domId;
-
-               switch (domain->type)
-               {
-                 case CDomain::type_attr::curvilinear:
-                   compress << "y" << appendDomId << " x" << appendDomId;
-                   break;
-                 case CDomain::type_attr::rectilinear:
-                   compress << "lat" << appendDomId << " lon" << appendDomId;
-                   break;
-                 case CDomain::type_attr::unstructured:
-                   compress << "cell" << appendDomId;
-                   break;
-               }
-               ++idxDomain;
-             }
-             else
-             {
-               CAxis* axis = CAxis::get(axisList[axisList.size() - idxAxis - 1]);
-               compress << (!axis->name.isEmpty() ? axis->name.getValue() : axis->getId());
-               ++idxAxis;
-             }
-
-             if (i != 0) compress << ' ';
-           }
-           SuperClassWriter::addAttribute("compress", compress.str(), &varId);
-
-           grid->computeCompressedIndex();
-
-           CArray<int, 1> indexes(grid->getNumberWrittenIndexes());
-           std::map<int, CArray<size_t, 1> >::const_iterator it;
-           for (it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it)
-           {
-             const CArray<size_t, 1> compressedIndexes = grid->compressedOutIndexFromClient[it->first];
-             for (int i = 0; i < it->second.numElements(); i++)
-               indexes(compressedIndexes(i)) = it->second(i);
-           }
-
-           switch (SuperClass::type)
-           {
-             case (MULTI_FILE):
-             {
-               SuperClassWriter::writeData(indexes, varId, isCollective, 0);
-               break;
-             }
-             case (ONE_FILE):
-             {
-               if (grid->doGridHaveDataDistributed())
-                 grid->getDistributionServer()->computeGlobalIndex(indexes);
-
-               std::vector<StdSize> start, count;
-               start.push_back(grid->getOffsetWrittenIndexes());
-               count.push_back(grid->getNumberWrittenIndexes());
-
-               SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count);
-               break;
-             }
-           }
-         }
-         else
-         {
-           for (int i = 0; i < numElement; ++i)
-           {
-             StdString varId, compress;
-             CArray<int, 1> indexes;
-             bool isDistributed;
-             StdSize nbIndexes, totalNbIndexes, offset;
-             int firstGlobalIndex;
-
-             if (axisDomainOrder(i))
-             {
-               CDomain* domain = CDomain::get(domainList[idxDomain]);
-               if (!domain->isCompressible()
-                    || domain->type == CDomain::type_attr::unstructured
-                    || domain->isWrittenCompressed(this->filename))
-                 continue;
-
-               StdString domId = !domain->name.isEmpty() ? domain->name.getValue() : domain->getId();
-               StdString appendDomId  = singleDomain ? "" : "_" + domId;
-
-               varId = domId + "_points";
-               switch (domain->type)
-               {
-                 case CDomain::type_attr::curvilinear:
-                   compress = "y" + appendDomId + " x" + appendDomId;
-                   break;
-                 case CDomain::type_attr::rectilinear:
-                   compress = "lat" + appendDomId + " lon" + appendDomId;
-                   break;
-               }
-
-               const std::vector<int>& indexesToWrite = domain->getIndexesToWrite();
-               indexes.resize(indexesToWrite.size());
-               for (int n = 0; n < indexes.numElements(); ++n)
-                 indexes(n) = indexesToWrite[n];
-
-               isDistributed = domain->isDistributed();
-               nbIndexes = domain->getNumberWrittenIndexes();
-               totalNbIndexes = domain->getTotalNumberWrittenIndexes();
-               offset = domain->getOffsetWrittenIndexes();
-               firstGlobalIndex = domain->ibegin + domain->jbegin * domain->ni_glo;
-
-               domain->addRelFileCompressed(this->filename);
-               ++idxDomain;
-             }
-             else
-             {
-               CAxis* axis = CAxis::get(axisList[idxAxis]);
-               if (!axis->isCompressible() || axis->isWrittenCompressed(this->filename))
-                 continue;
-
-               StdString axisId = !axis->name.isEmpty() ? axis->name.getValue() : axis->getId();
-               varId = axisId + "_points";
-               compress = axisId;
-
-               const std::vector<int>& indexesToWrite = axis->getIndexesToWrite();
-               indexes.resize(indexesToWrite.size());
-               for (int n = 0; n < indexes.numElements(); ++n)
-                 indexes(n) = indexesToWrite[n];
-
-               isDistributed = axis->isDistributed();
-               nbIndexes = axis->getNumberWrittenIndexes();
-               totalNbIndexes = axis->getTotalNumberWrittenIndexes();
-               offset = axis->getOffsetWrittenIndexes();
-               firstGlobalIndex = axis->begin;
-
-               axis->addRelFileCompressed(this->filename);
-               ++idxAxis;
-             }
-
-             if (!varId.empty())
-             {
-               SuperClassWriter::addDimension(varId, (SuperClass::type == MULTI_FILE) ? nbIndexes : totalNbIndexes);
-
-               dims.clear();
-               dims.push_back(varId);
-               SuperClassWriter::addVariable(varId, NC_INT, dims);
-
-               SuperClassWriter::addAttribute("compress", compress, &varId);
-
-               switch (SuperClass::type)
-               {
-                 case (MULTI_FILE):
-                 {
-                   indexes -= firstGlobalIndex;
-                   SuperClassWriter::writeData(indexes, varId, isCollective, 0);
-                   break;
-                 }
-                 case (ONE_FILE):
-                 {
-                   std::vector<StdSize> start, count;
-                   start.push_back(offset);
-                   count.push_back(nbIndexes);
-
-                   SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count);
-                   break;
-                 }
-               }
-             }
-           }
-
-           if (!dims.empty())
-             grid->computeCompressedIndex();
-         }
-
-         grid->addRelFileCompressed(this->filename);
-       }
-       catch (CNetCdfException& e)
-       {
-         StdString msg("On writing compressed grid : ");
-         msg.append(grid->getId()); 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::writeGridCompressed_(CGrid* grid)", << msg);
-       }
-     }
-
-     //--------------------------------------------------------------
-
-     void CNc4DataOutput::writeTimeDimension_(void)
-     {
-       try
-       {
-        SuperClassWriter::addDimension("time_counter");
-       }
-       catch (CNetCdfException& e)
-       {
-         StdString msg("On writing time dimension : time_couter\n");
-         msg.append("In the context : ");
-         CContext* context = CContext::getCurrent() ;
-         msg.append(context->getId()); msg.append("\n");
-         msg.append(e.what());
-         ERROR("CNc4DataOutput::writeTimeDimension_(void)", << msg);
-       }
-     }
-
-      //--------------------------------------------------------------
-
-      void CNc4DataOutput::writeField_(CField* field)
-      {
-         CContext* context = CContext::getCurrent() ;
-         CContextServer* server=context->server ;
-
-         std::vector<StdString> dims, coodinates;
-         CGrid* grid = field->grid;
-         if (!grid->doGridHaveDataToWrite())
-          if (SuperClass::type==MULTI_FILE) return ;
-
-         CArray<bool,1> axisDomainOrder = grid->axis_domain_order;
-         int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0;
-         std::vector<StdString> domainList = grid->getDomainList();
-         std::vector<StdString> axisList   = grid->getAxisList();
-
-         StdString timeid  = StdString("time_counter");
-         StdString dimXid,dimYid;
-         std::deque<StdString> dimIdList, dimCoordList;
-         bool hasArea = false;
-         StdString cellMeasures = "area:";
-         bool compressedOutput = !field->indexed_output.isEmpty() && field->indexed_output;
-
-         for (int i = 0; i < numElement; ++i)
-         {
-           if (axisDomainOrder(i))
-           {
-             CDomain* domain = CDomain::get(domainList[idxDomain]);
-             StdString domId = !domain->name.isEmpty() ? domain->name.getValue() : domain->getId();
-             StdString appendDomId  = singleDomain ? "" : "_" + domId ;
-
-             if (compressedOutput && domain->isCompressible() && domain->type != CDomain::type_attr::unstructured)
-             {
-               dimIdList.push_back(domId + "_points");
-               field->setUseCompressedOutput();
-             }
-
-             switch (domain->type)
-             {
-               case CDomain::type_attr::curvilinear:
-                 if (!compressedOutput || !domain->isCompressible())
-                 {
-                   dimXid     = StdString("x").append(appendDomId);
-                   dimIdList.push_back(dimXid);
-                   dimYid     = StdString("y").append(appendDomId);
-                   dimIdList.push_back(dimYid);
-                 }
-                 dimCoordList.push_back(StdString("nav_lon").append(appendDomId));
-                 dimCoordList.push_back(StdString("nav_lat").append(appendDomId));
-                 break ;
-               case CDomain::type_attr::rectilinear:
-                 if (!compressedOutput || !domain->isCompressible())
-                 {
-                   dimXid     = StdString("lon").append(appendDomId);
-                   dimIdList.push_back(dimXid);
-                   dimYid     = StdString("lat").append(appendDomId);
-                   dimIdList.push_back(dimYid);
-                 }
-                 break ;
-               case CDomain::type_attr::unstructured:
-                 dimXid     = StdString("cell").append(appendDomId);
-                 dimIdList.push_back(dimXid);
-                 dimCoordList.push_back(StdString("lon").append(appendDomId));
-                 dimCoordList.push_back(StdString("lat").append(appendDomId));
-                 break ;
-             }
-             if (domain->hasArea)
-             {
-               hasArea = true;
-               cellMeasures += " area" + appendDomId;
-             }
-             ++idxDomain;
-           }
-           else
-           {
-             CAxis* axis = CAxis::get(axisList[idxAxis]);
-             StdString axisId = !axis->name.isEmpty() ? axis->name.getValue() : axis->getId();
-
-             if (compressedOutput && axis->isCompressible())
-             {
-               dimIdList.push_back(axisId + "_points");
-               field->setUseCompressedOutput();
-             }
-             else
-               dimIdList.push_back(axisId);
-
-             dimCoordList.push_back(axisId);
-             ++idxAxis;
-           }
-         }
-
-/*
-         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->getOperationTimeType() == func::CFunctor::once);
-
-         if (wtime)
-         {
-
-            //StdOStringStream oss;
-           // oss << "time_" << field->operation.getValue()
-           //     << "_" << field->getRelFile()->output_freq.getValue();
-          //oss
-            if (field->getOperationTimeType() == func::CFunctor::instant) coodinates.push_back(string("time_instant"));
-            else if (field->getOperationTimeType() == func::CFunctor::centered) coodinates.push_back(string("time_centered"));
-            dims.push_back(timeid);
-         }
-
-         if (compressedOutput && grid->isCompressible())
-         {
-           dims.push_back(grid->getId() + "_points");
-           field->setUseCompressedOutput();
-         }
-         else
-         {
-           while (!dimIdList.empty())
-           {
-             dims.push_back(dimIdList.back());
-             dimIdList.pop_back();
-           }
-         }
-
-         while (!dimCoordList.empty())
-         {
-           coodinates.push_back(dimCoordList.back());
-           dimCoordList.pop_back();
-         }
-
-         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 freqOp = field->freq_op.getValue();
-              freqOp.solveTimeStep(*context->calendar);
-              StdString freqOpStr = freqOp.toStringUDUnits();
-              SuperClassWriter::addAttribute("interval_operation", freqOpStr, &fieldid);
-
-              CDuration freqOut = field->getRelFile()->output_freq.getValue();
-              freqOut.solveTimeStep(*context->calendar);
-              SuperClassWriter::addAttribute("interval_write", freqOut.toStringUDUnits(), &fieldid);
-
-              StdString cellMethods = "time: ";
-              if (field->operation.getValue() == "instant") cellMethods += "point";
-              else if (field->operation.getValue() == "average") cellMethods += "mean";
-              else if (field->operation.getValue() == "accumulate") cellMethods += "sum";
-              else cellMethods += field->operation;
-              if (freqOp.resolve(*context->calendar) != freqOut.resolve(*context->calendar))
-                cellMethods += " (interval: " + freqOpStr + ")";
-              SuperClassWriter::addAttribute("cell_methods", cellMethods, &fieldid);
-           }
-
-           if (hasArea)
-             SuperClassWriter::addAttribute("cell_measures", cellMeasures, &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);
-
-            if (field->compression_level.isEmpty())
-              field->compression_level = field->file->compression_level.isEmpty() ? 0 : field->file->compression_level;
-            SuperClassWriter::setCompressionLevel(fieldid, field->compression_level);
-
-           {  // 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);
-         }
-      }
-
-      //--------------------------------------------------------------
-
-      void CNc4DataOutput::writeFile_ (CFile* file)
-      {
-         StdString filename = (!file->name.isEmpty())
-                            ? file->name.getValue() : file->getId();
-         StdString description = (!file->description.isEmpty())
-                               ? file->description.getValue()
-                               : StdString("Created by xios");
-
-         singleDomain = (file->nbDomains == 1);
-
-         try
-         {
-           this->writeFileAttributes(filename, description,
-                                     StdString("CF-1.5"),
-                                     StdString("An IPSL model"),
-                                     this->getTimeStamp());
-
-           SuperClassWriter::addDimension("axis_nbounds", 2);
-         }
-         catch (CNetCdfException& e)
-         {
-           StdString msg("On writing file : ");
-           msg.append(filename); 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::writeFile_ (CFile* file)", << msg);
-         }
-      }
-
-      void CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId)
-      {
-        string name ;
-        if (!var->name.isEmpty()) name=var->name ;
-        else if (var->hasId()) name=var->getId() ;
-        else return ;
-
-        try
-        {
-          if (var->type.getValue() == CVariable::type_attr::t_int || var->type.getValue() == CVariable::type_attr::t_int32)
-            addAttribute(name, var->getData<int>(), &fieldId);
-          else if (var->type.getValue() == CVariable::type_attr::t_int16)
-            addAttribute(name, var->getData<short int>(), &fieldId);
-          else if (var->type.getValue() == CVariable::type_attr::t_float)
-            addAttribute(name, var->getData<float>(), &fieldId);
-          else if (var->type.getValue() == CVariable::type_attr::t_double)
-            addAttribute(name, var->getData<double>(), &fieldId);
-          else if (var->type.getValue() == CVariable::type_attr::t_string)
-            addAttribute(name, var->getData<string>(), &fieldId);
-          else
-            ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId)",
-                  << "Unsupported variable of type " << var->type.getStringValue());
-        }
-       catch (CNetCdfException& e)
-       {
-         StdString msg("On writing attributes of variable with name : ");
-         msg.append(name); msg.append("in the field "); msg.append(fieldId); 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::writeAttribute_ (CVariable* var, const string& fieldId)", << msg);
-       }
-     }
-
-     void CNc4DataOutput::writeAttribute_ (CVariable* var)
-     {
-        string name ;
-        if (!var->name.isEmpty()) name=var->name ;
-        else if (var->hasId()) name=var->getId() ;
-        else return ;
-        try
-        {
-          if (var->type.getValue() == CVariable::type_attr::t_int || var->type.getValue() == CVariable::type_attr::t_int32)
-            addAttribute(name, var->getData<int>());
-          else if (var->type.getValue() == CVariable::type_attr::t_int16)
-            addAttribute(name, var->getData<short int>());
-          else if (var->type.getValue() == CVariable::type_attr::t_float)
-            addAttribute(name, var->getData<float>());
-          else if (var->type.getValue() == CVariable::type_attr::t_double)
-            addAttribute(name, var->getData<double>());
-          else if (var->type.getValue() == CVariable::type_attr::t_string)
-            addAttribute(name, var->getData<string>());
-          else
-            ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var)",
-                  << "Unsupported variable of type " << var->type.getStringValue());
-        }
-       catch (CNetCdfException& e)
-       {
-         StdString msg("On writing attributes of variable with name : ");
-         msg.append(name); 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::writeAttribute_ (CVariable* var)", << msg);
-       }
-     }
-
-      void CNc4DataOutput::syncFile_ (void)
-      {
-        try
-        {
-          SuperClassWriter::sync() ;
-        }
-        catch (CNetCdfException& e)
-        {
-         StdString msg("On synchronizing the write among processes");
-         msg.append("In the context : ");
-         CContext* context = CContext::getCurrent() ;
-         msg.append(context->getId()); msg.append("\n");
-         msg.append(e.what());
-         ERROR("CNc4DataOutput::syncFile_ (void)", << msg);
-        }
-      }
-
-      void CNc4DataOutput::closeFile_ (void)
-      {
-        try
-        {
-          SuperClassWriter::close() ;
-        }
-        catch (CNetCdfException& e)
-        {
-         StdString msg("On closing file");
-         msg.append("In the context : ");
-         CContext* context = CContext::getCurrent() ;
-         msg.append(context->getId()); msg.append("\n");
-         msg.append(e.what());
-         ERROR("CNc4DataOutput::syncFile_ (void)", << msg);
-        }
-
-      }
-
-      //---------------------------------------------------------------
-
-      StdString CNc4DataOutput::getTimeStamp(void) const
-      {
-         const int buffer_size = 100;
-         time_t rawtime;
-         struct tm * timeinfo = NULL;
-         char buffer [buffer_size];
-
-         time ( &rawtime );
-         timeinfo = localtime ( &rawtime );
-         strftime (buffer, buffer_size, "%Y-%b-%d %H:%M:%S %Z", timeinfo);
-
-         return (StdString(buffer));
-      }
-
-      //---------------------------------------------------------------
-
-      void CNc4DataOutput::writeFieldData_ (CField*  field)
-      {
-         CContext* context = CContext::getCurrent() ;
-//          if (field->getRelFile()->isSyncTime()) SuperClassWriter::sync() ;
-         CContextServer* server=context->server ;
-
-         CGrid* grid = field->grid ;
-
-         if (!grid->doGridHaveDataToWrite())
-          if (SuperClass::type==MULTI_FILE || !isCollective) return ;
-
-         StdString fieldid   = (!field->name.isEmpty())
-                             ? field->name.getValue()
-                             : field->getBaseFieldReference()->getId();
-
-         StdOStringStream oss;
-         string timeAxisId ;
-         if (field->getOperationTimeType() == func::CFunctor::instant)  timeAxisId="time_instant" ;
-         else if (field->getOperationTimeType() == func::CFunctor::centered)  timeAxisId="time_centered" ;
-
-         StdString timeBoundId("time_counter_bounds");
-
-         StdString timeAxisBoundId;
-         if (field->getOperationTimeType() == func::CFunctor::instant)  timeAxisBoundId="time_instant_bounds" ;
-         else if (field->getOperationTimeType() == 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->getOperationTimeType() == func::CFunctor::once));
-
-        if (wtime)
-        {
-          time_counter(0)= (Time(field->last_Write_srv) + Time(field->lastlast_Write_srv)) / 2;
-          if (field->getOperationTimeType() == func::CFunctor::instant)
-            time_data(0) = Time(field->last_Write_srv);
-          else if (field->getOperationTimeType() == 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->getOperationTimeType() == func::CFunctor::instant)
-            time_data_bound(0) = time_data_bound(1) = Time(field->last_Write_srv);
-          else if (field->getOperationTimeType() == 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
-         {
-           size_t writtenSize;
-           if (field->getUseCompressedOutput())
-             writtenSize = grid->getNumberWrittenIndexes();
-           else
-             writtenSize = grid->getWrittenDataSize();
-
-           CArray<double,1> fieldData(writtenSize);
-           if (!field->default_value.isEmpty()) fieldData = field->default_value;
-
-           if (field->getUseCompressedOutput())
-             field->outputCompressedField(fieldData);
-           else
-             field->outputField(fieldData);
-
-           if (!field->prec.isEmpty() && field->prec==2) fieldData=round(fieldData) ;
-
-           switch (SuperClass::type)
-           {
-              case (MULTI_FILE) :
-              {
-                 SuperClassWriter::writeData(fieldData, 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) :
-              {
-                const std::vector<int>& nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal();
-                const std::vector<int>& nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer();
-                const std::vector<int>& nZoomSizeServer  = grid->getDistributionServer()->getZoomSizeServer();
-
-                std::vector<StdSize> start, count;
-
-                if (field->getUseCompressedOutput())
-                {
-                  if (grid->isCompressible())
-                  {
-                    start.push_back(grid->getOffsetWrittenIndexes());
-                    count.push_back(grid->getNumberWrittenIndexes());
-                  }
-                  else
-                  {
-                    CArray<bool,1> axisDomainOrder = grid->axis_domain_order;
-                    std::vector<StdString> domainList = grid->getDomainList();
-                    std::vector<StdString> axisList   = grid->getAxisList();
-                    int numElement = axisDomainOrder.numElements();
-                    int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1;
-                    int idx = nZoomBeginGlobal.size() - 1;
-
-                    start.reserve(nZoomBeginGlobal.size());
-                    count.reserve(nZoomBeginGlobal.size());
-
-
-                    for (int i = numElement - 1; i >= 0; --i)
-                    {
-                      if (axisDomainOrder(i))
-                      {
-                        CDomain* domain = CDomain::get(domainList[idxDomain]);
-
-                        if (domain->isCompressible())
-                        {
-                          start.push_back(domain->getOffsetWrittenIndexes());
-                          count.push_back(domain->getNumberWrittenIndexes());
-                        }
-                        else
-                        {
-                          start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]);
-                          count.push_back(nZoomSizeServer[idx]);
-                          start.push_back(nZoomBeginServer[idx - 1] - nZoomBeginGlobal[idx - 1]);
-                          count.push_back(nZoomSizeServer[idx - 1]);
-                        }
-
-                        --idxDomain;
-                        idx -= 2;
-                      }
-                      else
-                      {
-                        CAxis* axis = CAxis::get(axisList[idxAxis]);
-
-                        if (axis->isCompressible())
-                        {
-                          start.push_back(axis->getOffsetWrittenIndexes());
-                          count.push_back(axis->getNumberWrittenIndexes());
-                        }
-                        else
-                        {
-                          start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]);
-                          count.push_back(nZoomSizeServer[idx]);
-                        }
-
-                        --idxAxis;
-                        --idx;
-                      }
-                    }
-                  }
-                }
-                else
-                {
-                  int ssize = nZoomBeginGlobal.size();
-
-                  start.resize(ssize);
-                  count.resize(ssize);
-
-                  for (int i = 0; i < ssize; ++i)
-                  {
-                    start[i] = nZoomBeginServer[ssize - i - 1] - nZoomBeginGlobal[ssize - i - 1];
-                    count[i] = nZoomSizeServer[ssize - i - 1];
-                  }
-                }
-
-                SuperClassWriter::writeData(fieldData, 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);
-         }
-      }
-
-      //---------------------------------------------------------------
-
-      void CNc4DataOutput::writeTimeAxis_
-                  (CField*    field,
-                   const boost::shared_ptr<CCalendar> cal)
-      {
-         StdOStringStream oss;
-
-         if (field->getOperationTimeType() == func::CFunctor::once) return ;
-
-//         oss << "time_" << field->operation.getValue()
-//             << "_" << field->getRelFile()->output_freq.getValue();
-
-//         StdString axisid = oss.str();
-//         if (field->getOperationTimeType() == func::CFunctor::centered) axisid="time_centered" ;
-//         else if (field->getOperationTimeType() == func::CFunctor::instant) axisid="time_instant" ;
-
-         StdString axisid("time_centered") ;
-         StdString axisBoundId("time_centered_bounds");
-         StdString timeid("time_counter");
-         StdString timeBoundId("axis_nbounds");
-
-         if (field->getOperationTimeType() == func::CFunctor::instant)
-         {
-            axisid = "time_instant";
-            axisBoundId = "time_instant_bounds";
-         }
-
-         try
-         {
-          // Adding time_instant or time_centered
-           std::vector<StdString> dims;
-           dims.push_back(timeid);
-           if (!SuperClassWriter::varExist(axisid))
-           {
-              SuperClassWriter::addVariable(axisid, NC_DOUBLE, dims);
-
-              CDate timeOrigin=cal->getTimeOrigin() ;
-              StdOStringStream oss2;
-  //            oss2<<initDate.getYear()<<"-"<<initDate.getMonth()<<"-"<<initDate.getDay()<<" "
-  //                <<initDate.getHour()<<"-"<<initDate.getMinute()<<"-"<<initDate.getSecond() ;
-              StdString strInitdate=oss2.str() ;
-              StdString strTimeOrigin=timeOrigin.toString() ;
-              this->writeTimeAxisAttributes
-                 (axisid, cal->getType(),
-                  StdString("seconds since ").append(strTimeOrigin),
-                  strTimeOrigin, axisBoundId);
-           }
-
-           // Adding time_instant_bounds or time_centered_bounds variables
-           if (!SuperClassWriter::varExist(axisBoundId))
-           {
-              dims.clear() ;
-              dims.push_back(timeid);
-              dims.push_back(timeBoundId);
-              SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims);
-           }
-
-           // Adding time_counter
-           axisid = "time_counter" ;
-           axisBoundId = "time_counter_bounds" ;
-           dims.clear() ;
-           dims.push_back(timeid);
-           if (!SuperClassWriter::varExist(axisid))
-           {
-              SuperClassWriter::addVariable(axisid, NC_DOUBLE, dims);
-              SuperClassWriter::addAttribute("axis", string("T"), &axisid);
-              CDate timeOrigin=cal->getTimeOrigin() ;
-              StdString strTimeOrigin=timeOrigin.toString() ;
-
-              this->writeTimeAxisAttributes
-                 (axisid, cal->getType(),
-                  StdString("seconds since ").append(strTimeOrigin),
-                  strTimeOrigin, axisBoundId);
-           }
-
-           // Adding time_counter_bound dimension
-           if (!SuperClassWriter::varExist(axisBoundId))
-           {
-              dims.clear();
-              dims.push_back(timeid);
-              dims.push_back(timeBoundId);
-              SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims);
-           }
-         }
-         catch (CNetCdfException& e)
-         {
-           StdString msg("On writing time axis data: ");
-           msg.append("In the context : ");
-           CContext* context = CContext::getCurrent() ;
-           msg.append(context->getId()); msg.append("\n");
-           msg.append(e.what());
-           ERROR("CNc4DataOutput::writeTimeAxis_ (CField*    field, \
-                  const boost::shared_ptr<CCalendar> cal)", << msg);
-         }
-      }
-
-      //---------------------------------------------------------------
-
-      void CNc4DataOutput::writeTimeAxisAttributes(const StdString & axis_name,
-                                                   const StdString & calendar,
-                                                   const StdString & units,
-                                                   const StdString & time_origin,
-                                                   const StdString & time_bounds,
-                                                   const StdString & standard_name,
-                                                   const StdString & long_name)
-      {
-         try
-         {
-           SuperClassWriter::addAttribute("standard_name", standard_name, &axis_name);
-           SuperClassWriter::addAttribute("long_name",     long_name    , &axis_name);
-           SuperClassWriter::addAttribute("calendar",      calendar     , &axis_name);
-           SuperClassWriter::addAttribute("units",         units        , &axis_name);
-           SuperClassWriter::addAttribute("time_origin",   time_origin  , &axis_name);
-           SuperClassWriter::addAttribute("bounds",        time_bounds  , &axis_name);
-         }
-         catch (CNetCdfException& e)
-         {
-           StdString msg("On writing time axis Attribute: ");
-           msg.append("In the context : ");
-           CContext* context = CContext::getCurrent() ;
-           msg.append(context->getId()); msg.append("\n");
-           msg.append(e.what());
-           ERROR("CNc4DataOutput::writeTimeAxisAttributes(const StdString & axis_name, \
-                                                          const StdString & calendar,\
-                                                          const StdString & units, \
-                                                          const StdString & time_origin, \
-                                                          const StdString & time_bounds, \
-                                                          const StdString & standard_name, \
-                                                          const StdString & long_name)", << msg);
-         }
-      }
-
-      //---------------------------------------------------------------
-
-      void CNc4DataOutput::writeAxisAttributes(const StdString & axis_name,
-                                               const StdString & axis,
-                                               const StdString & standard_name,
-                                               const StdString & long_name,
-                                               const StdString & units,
-                                               const StdString & nav_model)
-      {
-         try
-         {
-          if (!axis.empty())
-            SuperClassWriter::addAttribute("axis"       , axis         , &axis_name);
-
-          SuperClassWriter::addAttribute("standard_name", standard_name, &axis_name);
-          SuperClassWriter::addAttribute("long_name"    , long_name    , &axis_name);
-          SuperClassWriter::addAttribute("units"        , units        , &axis_name);
-          SuperClassWriter::addAttribute("nav_model"    , nav_model    , &axis_name);
-         }
-         catch (CNetCdfException& e)
-         {
-           StdString msg("On writing Axis Attribute: ");
-           msg.append("In the context : ");
-           CContext* context = CContext::getCurrent() ;
-           msg.append(context->getId()); msg.append("\n");
-           msg.append(e.what());
-           ERROR("CNc4DataOutput::writeAxisAttributes(const StdString & axis_name, \
-                                                      const StdString & axis, \
-                                                      const StdString & standard_name, \
-                                                      const StdString & long_name, \
-                                                      const StdString & units, \
-                                                      const StdString & nav_model)", << msg);
-         }
-      }
-
-      //---------------------------------------------------------------
-
-      void CNc4DataOutput::writeLocalAttributes
-         (int ibegin, int ni, int jbegin, int nj, StdString domid)
-      {
-        try
-        {
-         SuperClassWriter::addAttribute(StdString("ibegin").append(domid), ibegin);
-         SuperClassWriter::addAttribute(StdString("ni"    ).append(domid), ni);
-         SuperClassWriter::addAttribute(StdString("jbegin").append(domid), jbegin);
-         SuperClassWriter::addAttribute(StdString("nj"    ).append(domid), nj);
-        }
-        catch (CNetCdfException& e)
-        {
-           StdString msg("On writing Local Attributes: ");
-           msg.append("In the context : ");
-           CContext* context = CContext::getCurrent() ;
-           msg.append(context->getId()); msg.append("\n");
-           msg.append(e.what());
-           ERROR("CNc4DataOutput::writeLocalAttributes \
-                  (int ibegin, int ni, int jbegin, int nj, StdString domid)", << msg);
-        }
-
-      }
-
-      void CNc4DataOutput::writeLocalAttributes_IOIPSL(const StdString& dimXid, const StdString& dimYid,
-                                                       int ibegin, int ni, int jbegin, int nj, int ni_glo, int nj_glo, int rank, int size)
-      {
-         CArray<int,1> array(2) ;
-
-         try
-         {
-           SuperClassWriter::addAttribute("DOMAIN_number_total",size ) ;
-           SuperClassWriter::addAttribute("DOMAIN_number", rank) ;
-           array = SuperClassWriter::getDimension(dimXid) + 1, SuperClassWriter::getDimension(dimYid) + 1;
-           SuperClassWriter::addAttribute("DOMAIN_dimensions_ids",array) ;
-           array=ni_glo,nj_glo ;
-           SuperClassWriter::addAttribute("DOMAIN_size_global", array) ;
-           array=ni,nj ;
-           SuperClassWriter::addAttribute("DOMAIN_size_local", array) ;
-           array=ibegin,jbegin ;
-           SuperClassWriter::addAttribute("DOMAIN_position_first", array) ;
-           array=ibegin+ni-1,jbegin+nj-1 ;
-           SuperClassWriter::addAttribute("DOMAIN_position_last",array) ;
-           array=0,0 ;
-           SuperClassWriter::addAttribute("DOMAIN_halo_size_start", array) ;
-           SuperClassWriter::addAttribute("DOMAIN_halo_size_end", array);
-           SuperClassWriter::addAttribute("DOMAIN_type",string("box")) ;
-  /*
-           SuperClassWriter::addAttribute("DOMAIN_DIM_N001",string("x")) ;
-           SuperClassWriter::addAttribute("DOMAIN_DIM_N002",string("y")) ;
-           SuperClassWriter::addAttribute("DOMAIN_DIM_N003",string("axis_A")) ;
-           SuperClassWriter::addAttribute("DOMAIN_DIM_N004",string("time_counter")) ;
-  */
-         }
-         catch (CNetCdfException& e)
-         {
-           StdString msg("On writing Local Attributes IOIPSL \n");
-           msg.append("In the context : ");
-           CContext* context = CContext::getCurrent() ;
-           msg.append(context->getId()); msg.append("\n");
-           msg.append(e.what());
-           ERROR("CNc4DataOutput::writeLocalAttributes_IOIPSL \
-                  (int ibegin, int ni, int jbegin, int nj, int ni_glo, int nj_glo, int rank, int size)", << msg);
-         }
-      }
-      //---------------------------------------------------------------
-
-      void CNc4DataOutput:: writeFileAttributes(const StdString & name,
-                                                const StdString & description,
-                                                const StdString & conventions,
-                                                const StdString & production,
-                                                const StdString & timeStamp)
-      {
-         try
-         {
-           SuperClassWriter::addAttribute("name"       , name);
-           SuperClassWriter::addAttribute("description", description);
-           SuperClassWriter::addAttribute("title"      , description);
-           SuperClassWriter::addAttribute("Conventions", conventions);
-           SuperClassWriter::addAttribute("production" , production);
-           SuperClassWriter::addAttribute("timeStamp"  , timeStamp);
-         }
-         catch (CNetCdfException& e)
-         {
-           StdString msg("On writing File Attributes \n ");
-           msg.append("In the context : ");
-           CContext* context = CContext::getCurrent() ;
-           msg.append(context->getId()); msg.append("\n");
-           msg.append(e.what());
-           ERROR("CNc4DataOutput:: writeFileAttributes(const StdString & name, \
-                                                const StdString & description, \
-                                                const StdString & conventions, \
-                                                const StdString & production, \
-                                                const StdString & timeStamp)", << msg);
-         }
-      }
-
-      //---------------------------------------------------------------
-
-      void CNc4DataOutput::writeMaskAttributes(const StdString & mask_name,
-                                               int data_dim,
-                                               int data_ni,
-                                               int data_nj,
-                                               int data_ibegin,
-                                               int data_jbegin)
-      {
-         try
-         {
-           SuperClassWriter::addAttribute("data_dim"   , data_dim   , &mask_name);
-           SuperClassWriter::addAttribute("data_ni"    , data_ni    , &mask_name);
-           SuperClassWriter::addAttribute("data_nj"    , data_nj    , &mask_name);
-           SuperClassWriter::addAttribute("data_ibegin", data_ibegin, &mask_name);
-           SuperClassWriter::addAttribute("data_jbegin", data_jbegin, &mask_name);
-         }
-         catch (CNetCdfException& e)
-         {
-           StdString msg("On writing Mask Attributes \n ");
-           msg.append("In the context : ");
-           CContext* context = CContext::getCurrent() ;
-           msg.append(context->getId()); msg.append("\n");
-           msg.append(e.what());
-           ERROR("CNc4DataOutput::writeMaskAttributes(const StdString & mask_name, \
-                                               int data_dim, \
-                                               int data_ni, \
-                                               int data_nj, \
-                                               int data_ibegin, \
-                                               int data_jbegin)", << msg);
-         }
-      }
-
-      ///--------------------------------------------------------------
-
-} // namespace xios
Index: XIOS/trunk/src/output/nc4_data_output.hpp
===================================================================
--- XIOS/trunk/src/output/nc4_data_output.hpp	(revision 684)
+++ 	(revision )
@@ -1,103 +1,0 @@
-#ifndef __XIOS_NC4_DATA_OUTPUT__
-#define __XIOS_NC4_DATA_OUTPUT__
-
-/// XIOS headers ///
-#include "xios_spl.hpp"
-#include "onetcdf4.hpp"
-#include "data_output.hpp"
-
-namespace xios
-{
-      /// ////////////////////// DÃ©clarations ////////////////////// ///
-
-      class CNc4DataOutput
-         : protected CONetCDF4
-         , public virtual CDataOutput
-      {
-         public :
-
-            /// DÃ©finition de type ///
-            typedef CONetCDF4   SuperClassWriter;
-            typedef CDataOutput SuperClass;
-
-            /// Constructeurs ///
-            CNc4DataOutput
-               (const StdString & filename, bool exist);
-            CNc4DataOutput
-               (const StdString & filename, bool exist, bool useClassicFormat,
-                MPI_Comm comm_file, bool multifile, bool isCollective=true);
-
-            CNc4DataOutput(const CNc4DataOutput & dataoutput);       // Not implemented.
-            CNc4DataOutput(const CNc4DataOutput * const dataoutput); // Not implemented.
-
-            /// Accesseur ///
-            const StdString & getFileName(void) const;
-
-            /// Destructeur ///
-            virtual ~CNc4DataOutput(void);
-            bool singleDomain ;
-            bool isCollective ;
-         protected :
-
-            /// Ecriture ///
-            virtual void writeDomain_   (CDomain* domain);
-            virtual void writeAxis_     (CAxis* axis);
-            virtual void writeGridCompressed_(CGrid* grid);
-            virtual void writeTimeDimension_(void);
-            virtual void writeField_    (CField* field);
-            virtual void writeAttribute_(CVariable* var);
-            virtual void writeAttribute_(CVariable* var, const string& fieldId);
-            virtual void writeFieldData_(CField* field);
-            virtual void writeFile_     (CFile* file);
-            virtual void closeFile_     (void);
-            virtual void syncFile_      (void);
-            virtual void writeTimeAxis_ (CField* field,
-                                         const boost::shared_ptr<CCalendar> cal);
-
-         protected :
-            void writeUnstructuredDomain (CDomain* domain);
-            void writeLocalAttributes(int ibegin, int ni, int jbegin, int nj, StdString domid);
-            void writeLocalAttributes_IOIPSL(const StdString& dimXid, const StdString& dimYid,
-                                             int ibegin, int ni, int jbegin, int nj, int ni_glo, int nj_glo, int rank, int size);
-            void writeTimeAxisAttributes(const StdString & axis_name,
-                                         const StdString & calendar,
-                                         const StdString & units,
-                                         const StdString & time_origin,
-                                         const StdString & time_bounds   = StdString("bounds"),
-                                         const StdString & standard_name = StdString("time"),
-                                         const StdString & long_name     = StdString("Time axis"));
-
-            void writeFileAttributes(const StdString & name,
-                                     const StdString & description,
-                                     const StdString & conventions,
-                                     const StdString & production,
-                                     const StdString & timeStamp);
-
-            void writeMaskAttributes(const StdString & mask_name,
-                                     int data_dim,
-                                     int data_ni     = 0,
-                                     int data_nj     = 0,
-                                     int data_ibegin = 0,
-                                     int data_jbegin = 0);
-
-            void writeAxisAttributes(const StdString & axis_name,
-                                     const StdString & axis,
-                                     const StdString & standard_name,
-                                     const StdString & long_name,
-                                     const StdString & units,
-                                     const StdString & nav_model);
-
-         private :
-
-            /// Traitement ///
-            StdString getTimeStamp(void) const;
-
-            /// PropriÃ©tÃ©s privÃ©es ///
-            MPI_Comm comm_file;
-            const StdString filename;
-
-      }; // class CNc4DataOutput
-
-} // namespace xios
-
-#endif //__XIOS_NC4_DATA_OUTPUT__
Index: XIOS/trunk/src/output/netCdfException.hpp
===================================================================
--- XIOS/trunk/src/output/netCdfException.hpp	(revision 684)
+++ 	(revision )
@@ -1,34 +1,0 @@
-/*!
-   \file netCdfException.hpp
-   \author Ha NGUYEN
-   \date 08 Oct 2014
-   \since 07 Oct 2014
-
-   \brief Exception management.
- */
-#ifndef __NETCDF_EXCEPTION_HPP__
-#define __NETCDF_EXCEPTION_HPP__
-
-#include <iostream>
-#include <exception>
-
-namespace xios
-{
-/*!
-\class CNetCdfException
- This class manages exceptions risen by CNetCdfInterface
-*/
-class CNetCdfException : public virtual std::exception
-{
-public:
-  CNetCdfException(const std::string& ss) : exStr_(ss) {}
-  CNetCdfException(const CNetCdfException& netEx) : exStr_(netEx.exStr_) {}
-  ~CNetCdfException() throw() {}
-  const char* what() const throw() { return exStr_.c_str();}
-protected:
-  std::string exStr_;
-};
-
-}
-
-#endif // __NETCDF_EXCEPTION_HPP__
Index: XIOS/trunk/src/output/netCdfInterface.cpp
===================================================================
--- XIOS/trunk/src/output/netCdfInterface.cpp	(revision 684)
+++ 	(revision )
@@ -1,804 +1,0 @@
-/*!
-   \file netCdfInterface.cpp
-   \author Ha NGUYEN
-   \date 08 Oct 2014
-   \since 03 Oct 2014
-
-   \brief Wrapper of netcdf functions.
- */
-
-#include "netCdfInterface.hpp"
-#include "netCdfException.hpp"
-
-namespace xios
-{
-/*!
-This function creates a new netcdf file and return its id
-\param [in] fileName Name of the file
-\param [in] cMode create mode
-\param [in/out] ncId id of the created file
-\return Status code
-*/
-int CNetCdfInterface::create(const StdString& fileName, int cMode, int& ncId)
-{
-  int status = nc_create((fileName.c_str()), cMode, &ncId);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-    sstr << "Error in calling function : nc_create((fileName.c_str()), cMode, &ncId) " << std::endl
-         << errormsg << std::endl
-         << "Unable to create file, given its name : " << fileName
-         << "and its creation mode " << creationMode2String(cMode) << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function creates a new netcdf file on parallel file system
-\param [in] fileName Name of the file
-\param [in] cMode create mode
-\param [in] comm MPI communicator
-\param [in] info MPI information
-\param [in/out] ncId id of the created file
-\return Status code
-*/
-int CNetCdfInterface::createPar(const StdString& fileName, int cMode, MPI_Comm comm, MPI_Info info, int& ncId)
-{
-  int status = xios::nc_create_par((fileName.c_str()), cMode, comm, info, &ncId);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-    sstr << "Error in calling function : nc_create_par((fileName.c_str()), cMode, comm, info, &ncId) " << std::endl
-         << errormsg << std::endl
-         << "Unable to create file on parallel filesys, given its name : " << std::endl
-         << "and its creation mode " << creationMode2String(cMode) << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function opens a netcdf file, given its name and open mode, return its id
-\param [in] fileName Name of the file
-\param [in] oMode open mode
-\param [in/out] ncId id of the opening file
-\return Status code
-*/
-int CNetCdfInterface::open(const StdString& fileName, int oMode, int& ncId)
-{
-  int status = nc_open((fileName.c_str()), oMode, &ncId);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-    sstr << "Error in calling function : nc_open((fileName.c_str()), oMode, &ncId) "<< std::endl
-         << errormsg << std::endl
-         << "Unable to open file, given its name : " << fileName
-         << "and its open mode " << openMode2String(oMode) << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-
-/*!
-This function opens a new netcdf file on parallel file system
-\param [in] fileName Name of the file
-\param [in] oMode open mode
-\param [in] comm MPI communicator
-\param [in] info MPI information
-\param [in/out] ncId id of the opened file
-\return Status code
-*/
-int CNetCdfInterface::openPar(const StdString& fileName, int oMode, MPI_Comm comm, MPI_Info info, int& ncId)
-{
-  int status = xios::nc_open_par((fileName.c_str()), oMode, comm, info, &ncId);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-    sstr << "Error in calling function " << "nc_open_par((fileName.c_str()), oMode, comm, info, &ncId) " << std::endl
-         << errormsg << std::endl
-         << "Unable to open file on parallel filesys, given its name : " << fileName
-         << "and its open mode " << openMode2String(oMode) << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function closes a netcdf file, given its id
-\param [in] ncId id of the opening netcdf file
-\return Status code
-*/
-int CNetCdfInterface::close(int ncId)
-{
-  int status = nc_close(ncId);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-    sstr << "Error in calling function " << "nc_close(ncId)" << std::endl
-         << errormsg << std::endl
-         << "Unable to close file, given its id : " << ncId << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function put a netcdf file into define mode, given its id
-\param [in] ncId id of the opening netcdf file to be put into define mode
-\return Status code
-*/
-int CNetCdfInterface::reDef(int ncId)
-{
-  int status = nc_redef(ncId);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-    sstr << "Error in calling function " << "nc_redef(ncId)" << std::endl
-      << errormsg << std::endl
-      << "Unable to put this file into define mode given its id : " << ncId << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function ends a netcdf file define mode, given its id
-\param [in] ncId id of the opening netcdf file to be put into define mode
-\return Status code
-*/
-int CNetCdfInterface::endDef(int ncId)
-{
-  int status = nc_enddef(ncId);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << "nc_enddef(ncId)" << std::endl
-         << errormsg << std::endl
-         << "Unable to end define mode of this file, given its id : " << ncId << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function makes a request to netcdf with ncid and group name then return ncid of the named group
-\param [in] ncid Groupd id (or File Id)
-\param [in] grpName Name of the desired group (or file)
-\param [in/out] grpId Group id if the group is found
-\return Status code
-*/
-int CNetCdfInterface::inqNcId(int ncid, const StdString& grpName, int& grpId)
-{
-  int status = nc_inq_ncid(ncid, (grpName.c_str()), &grpId);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << "nc_inq_ncid(ncid, (grpName.c_str()), &grpId)" << std::endl
-         << errormsg << std::endl
-         << "Unable to get id of a group (File), given its name : " << grpName << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-
-/*!
-This function makes a request to netcdf with ncid and variable name then return ncid of the named variable
-\param [in] ncid Groupd id (or File Id)
-\param [in] varName Name of the desired variable
-\param [in/out] varId Variable id if this variable is found
-\return Status code
-*/
-int CNetCdfInterface::inqVarId(int ncid,const StdString& varName, int& varId)
-{
-  int status = nc_inq_varid(ncid, (varName.c_str()), &varId);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function : nc_inq_varid(ncid, (varName.c_str()), &varId)" << std::endl
-         << (errormsg) << std::endl
-         << "Unable to get id of variable with name : " << varName << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function makes a request to netcdf with a netCdf dimension name then return ncid of the named dimension
-\param [in] ncid Groupd id (or File Id)
-\param [in] dimName Name of the desired dimension
-\param [in/out] dimId Dimension id if this dimension is found
-\return Status code
-*/
-int CNetCdfInterface::inqDimId(int ncid,const StdString& dimName, int& dimId)
-{
-  int status = nc_inq_dimid(ncid, (dimName.c_str()), &dimId);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << "nc_inq_dimid(ncid, (dimName.c_str()), &dimId)" << std::endl
-         << errormsg << std::endl
-         << "Unable to get id of dimension, given its name : " << dimName << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function makes a request to netcdf with a netCdf dimension name then return ncid of the named dimension
-\param [in] ncid Groupd id (or File Id)
-\param [in/out] dimId Dimension id if this dimension is found
-\return Status code
-*/
-int CNetCdfInterface::inqUnLimDim(int ncid, int& dimId)
-{
-  int status = nc_inq_unlimdim(ncid, &dimId);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << "nc_inq_dimid" << std::endl
-      << errormsg << std::endl
-      << "Unable to get id of unlimited dimension " << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
- }
-
-  return status;
-}
-
-/*!
-This function makes a request to netcdf, returns name of a dimension, given its id
-\param [in] ncid Groupd id (or File Id)
-\param [in] dimId Id of desired dimension
-\param [in/out] dimName Name of desired dimension
-\return Status code
-*/
-int CNetCdfInterface::inqDimName(int ncid, int dimId, StdString& dimName)
-{
-  char fullNameIn[NC_MAX_NAME +1];
-  int status = nc_inq_dimname(ncid, dimId, fullNameIn);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << "nc_inq_dimname(ncid, dimId, fullNameIn)" << std::endl
-         << errormsg << std::endl
-         << "Unable to get dimension name from its id : " << dimId << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-  dimName = StdString(fullNameIn);
-  return status;
-}
-
-/*!
-This function makes a request to netcdf, returns length of a dimension, given its id
-\param [in] ncid Groupd id (or File Id)
-\param [in] dimId Id of desired dimension
-\param [in/out] dimLen Length of desired dimension
-\return Status code
-*/
-int CNetCdfInterface::inqDimLen(int ncid, int dimId, StdSize& dimLen)
-{
-  int status = nc_inq_dimlen(ncid, dimId, &dimLen);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << "nc_inq_dimlen(ncid, dimId, &dimLen)" << std::endl
-         << errormsg << std::endl
-         << "Unable to get dimension length from its id: " << dimId << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function makes a request to netcdf, returns number of dimensions of a variable, given its id
-\param [in] ncid Groupd id (or File Id)
-\param [in] varId Id of variable
-\param [in/out] ndims number of dimension of the variable
-\return Status code
-*/
-int CNetCdfInterface::inqVarNDims(int ncid, int varId, int& nDims)
-{
-  int status = nc_inq_varndims(ncid, varId, &nDims);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << "nc_inq_varndims(ncid, varId, &nDims)" << std::endl
-         << errormsg << std::endl
-         << "Unable to get the number of dimension of variable with Id : " << varId << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function makes a request to netcdf, returns a list of dimension ID describing the shape of the variable, given its id
-\param [in] ncid Groupd id (or File Id)
-\param [in] varId Id of variable
-\param [in/out] dimIds list of dimension of the variable
-\return Status code
-*/
-int CNetCdfInterface::inqVarDimId(int ncid, int varId, int* dimIds)
-{
-  int status = nc_inq_vardimid(ncid, varId, dimIds);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << "nc_inq_vardimid(ncid, varId, dimIds)" << std::endl
-         << errormsg << std::endl
-         << "Unable to get list of dimension id of the variable with id " << varId << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function makes a request to netcdf, to find all dimension in a group
-\param [in] ncid Groupd id (or File Id)
-\param [in/out] nDims number of list of dimension
-\param [in/out] dimIds list of dimension in a group or any of its parent
-\param [in] includeParents number of parents
-\return Status code
-*/
-int CNetCdfInterface::inqDimIds(int ncid, int& nDims, int* dimIds, int includeParents)
-{
-  int status = nc_inq_dimids(ncid, &nDims, dimIds, includeParents);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << "nc_inq_dimids(ncid, &nDims, dimIds, includeParents)" << std::endl;
-    sstr << errormsg << std::endl;
-    sstr << "Unable to retrieve number of dimension in the group with id : " << ncid << std::endl;
-    sstr << "With number of Parents " << includeParents << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function makes a request to netcdf with a id of a prent groupd and then return id of the created group, given its name
-\param [in] parentNcid Id of parent groupd(or File Id)
-\param [in] grpName Name of the desired group
-\param [in/out] grpId Group id if this group is created sucessfully
-\return Status code
-*/
-int CNetCdfInterface::defGrp(int parentNcid, const StdString& grpName, int& grpId)
-{
-  int status = nc_def_grp(parentNcid, (grpName.c_str()), &grpId);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << "nc_def_grp(parentNcid, (grpName.c_str()), &grpId)" << std::endl;
-    sstr << errormsg << std::endl;
-    sstr << "Unable to create group Id, given its name : " << grpName << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function makes a request to netcdf, add a new dimension to an open netcdf in define mode
-\param [in] ncid Id of groupd(or File Id)
-\param [in] dimName Name of the desired dimension
-\param [in/out] grpId Group id if this group is created sucessfully
-\return Status code
-*/
-int CNetCdfInterface::defDim(int ncid, const StdString& dimName, StdSize dimLen, int& dimId)
-{
-  int status = nc_def_dim(ncid, (dimName.c_str()), dimLen, &dimId);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << "nc_def_dim(ncid, (dimName.c_str()), dimLen, &dimId)" << std::endl;
-    sstr << errormsg << std::endl;
-    sstr << "Unable to create dimension with name : " << dimName
-         << " and with length " << dimLen << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function makes a request to netcdf with its id, to add a new variable to an open netCdf in define mode,
-return a variable id, given its name, type, the number of dimensions and list of dimension id
-\param [in] ncid Id of groupd(or File Id)
-\param [in] varName Name of the desired dimension
-\param [in] xtypes One of the set of predefined netCDF data types
-\param [in] nDims Number of dimension for the variable
-\param [in] dimIds List of ndims dimension ids corresponding to the variable dimensions
-\param [in/out] varId Variable id if it is added sucessfully
-\return Status code
-*/
-int CNetCdfInterface::defVar(int ncid,const StdString& varName, nc_type xtype,
-                            int nDims, const int dimIds[], int& varId)
-{
-  int status = nc_def_var(ncid, (varName.c_str()), xtype, nDims, dimIds, &varId);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << " nc_def_var(ncid, (varName.c_str()), xtype, nDims, dimIds, &varId)" << std::endl;
-    sstr << errormsg << std::endl;
-    sstr << "Unable to add a new variable with name : " << varName
-         << " with type " << xtype
-         << " and number of dimension " << nDims << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function makes a request to netcdf with a ncid, to set the chunking size of a variable,
-given variable id and type of storage
-\param [in] ncid Id groupd(or File Id)
-\param [in] varId Id of the variable
-\param [in] storage Type of storage (It can be : NC_CONTIGUOUS, NC_CHUNKED)
-\param [in/out] chunkSize array list of chunk sizes
-\return Status code
-*/
-int CNetCdfInterface::defVarChunking(int ncid, int varId, int storage, StdSize chunkSize[])
-{
-  int status = nc_def_var_chunking(ncid, varId, storage, chunkSize);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << "nc_def_var_chunking(ncid, varId, storage, chunkSize)" << std::endl;
-    sstr << errormsg << std::endl;
-    sstr << "Unable to set chunk size of the variable with id : " << varId
-      << " and storage type " << storage << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function sets the compression level to the specified variable
-\param [in] ncid Groud id (or file id)
-\param [in] varId Id of the variable
-\param [in] compressionLevel The compression level from 0 to 9 (0 disables the compression, 9 is the higher compression)
-\return Status code
-*/
-int CNetCdfInterface::defVarDeflate(int ncid, int varId, int compressionLevel)
-{
-  int status = nc_def_var_deflate(ncid, varId, false, (compressionLevel > 0), compressionLevel);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << "nc_def_var_deflate(ncid, varId, false, (compressionLevel > 0), compressionLevel)" << std::endl;
-    sstr << errormsg << std::endl;
-    sstr << "Unable to set the compression level of the variable with id: " << varId
-         << " and compression level: " << compressionLevel << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-Set or unset the fill mode for a NetCDF file specified by its file id.
-\param [in] ncid File id
-\param [in] fill Define whether the fill mode should be enabled or not
-\return Status code
-*/
-int CNetCdfInterface::setFill(int ncid, bool fill)
-{
-  int old_fill_mode;
-  int status = nc_set_fill(ncid, fill ? NC_FILL : NC_NOFILL, &old_fill_mode);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error when calling function nc_set_fill(ncid, fill ? NC_FILL : NC_NOFILL, &old_fill_mode)" << std::endl;
-    sstr << errormsg << std::endl;
-    sstr << "Unable to set the fill mode to : " << (fill ? "NC_FILL" : "NC_NOFILL") << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function makes a request to netcdf with a ncid, to set the fill parameters for a variable,
-given variable id and type of fill
-\param [in] ncid Id groupd(or File Id)
-\param [in] varId Id of the variable
-\param [in] noFill turn on/off nofill mode on a variable
-\param [in/out] fillValue
-\return Status code
-*/
-int CNetCdfInterface::defVarFill(int ncid, int varId, int noFill, void* fillValue)
-{
-  int status = nc_def_var_fill(ncid, varId, noFill, fillValue);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << "nc_def_var_fill(ncid, varId, noFill, fillValue)" << std::endl;
-    sstr << errormsg << std::endl;
-    sstr << "Unable to set fill parameters of the variable with id : " << varId
-      << " and fill option " << noFill << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function makes a request to netcdf with a ncid, to change the way read/write operations are performed
-collectively or independently on the variable.
-\param [in] ncid Id groupd(or File Id)
-\param [in] varId Id of the variable
-\param [in] noFill turn on/off nofill mode on a variable
-\param [in/out] fillValue
-\return Status code
-*/
-int CNetCdfInterface::varParAccess(int ncid, int varId, int access)
-{
-  int status = nc_var_par_access(ncid, varId, access);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << "nc_var_par_access(ncid, varId, access)" << std::endl;
-    sstr << errormsg << std::endl;
-    sstr << "Unable to change read/write option of the variable with id : " << varId << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function makes a synchronisation of the disk copy of a netCDF dataset.
-\param [in] ncid Id groupd(or File Id)
-\return Status code
-*/
-int CNetCdfInterface::sync(int ncid)
-{
-  int status = nc_sync(ncid);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << "nc_sync(ncid)" << std::endl;
-    sstr << errormsg << std::endl;
-    sstr << "Unable to make a synchronization of a netCDF file with id : " << ncid << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
-/*!
-This function makes a request to netcdf with its id, to add or change a variable attribute or gloabl attribute,
-given its name, type, number of values provided for attribute
-\param [in] ncid Id of groupd(or File Id)
-\param [in] varId Id of the variable
-\param [in] attrName Name of the attribute
-\param [in] xtypes One of the set of predefined netCDF data types
-\param [in] numVal Number of values
-\param [in] op Array of values provided for attribute
-\return Status code
-*/
-int CNetCdfInterface::putAtt(int ncid, int varId, const StdString& attrName, nc_type xtype,
-                            StdSize numVal, const void* op)
-{
-  int status = nc_put_att(ncid, varId, (attrName.c_str()), xtype, numVal, op);
-  if (NC_NOERR != status)
-  {
-    StdString errormsg(nc_strerror(status));
-    StdStringStream sstr;
-
-    sstr << "Error in calling function " << "nc_put_att(ncid, varId, (attrName.c_str()), xtype, numVal, op)" << std::endl;
-    sstr << errormsg << std::endl;
-    sstr << "Unable to set attribute " << attrName << " for a variable with id : " << varId
-         << " with number of attribute  " << numVal
-         << " with type " << xtype << std::endl;
-    StdString e = sstr.str();
-    throw CNetCdfException(e);
-  }
-
-  return status;
-}
-
- // Some specilization of putAttributeType
-template<>
-int CNetCdfInterface::ncPutAttType(int ncid, int varid, const char* attrName,
-                                 StdSize numVal, const double* op)
-{
-  return (nc_put_att_double(ncid, varid, attrName, NC_DOUBLE, numVal, op));
-}
-
-template<>
-int CNetCdfInterface::ncPutAttType(int ncid, int varid, const char* attrName,
-                                   StdSize numVal, const float* op)
-{
-  return (nc_put_att_float(ncid, varid, attrName, NC_FLOAT, numVal, op));
-}
-
-template<>
-int CNetCdfInterface::ncPutAttType(int ncid, int varid, const char* attrName,
-                                   StdSize numVal, const int* op)
-{
-  return (nc_put_att_int(ncid, varid, attrName, NC_INT, numVal, op));
-}
-
-template<>
-int CNetCdfInterface::ncPutAttType(int ncid, int varid, const char* attrName,
-                                   StdSize numVal, const long* op)
-{
-  return (nc_put_att_long(ncid, varid, attrName, NC_LONG, numVal, op));
-}
-
-template<>
-int CNetCdfInterface::ncPutAttType(int ncid, int varid, const char* attrName,
-                                   StdSize numVal, const short* op)
-{
-  return (nc_put_att_short(ncid, varid, attrName, NC_SHORT, numVal, op));
-}
-
-
-// Some specilization of putVariableType
-template<>
-int CNetCdfInterface::ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const double* op)
-{
-  return (nc_put_vara_double(ncid, varid, start, count, op));
-}
-
-template<>
-int CNetCdfInterface::ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const float* op)
-{
-  return (nc_put_vara_float(ncid, varid, start, count, op));
-}
-
-template<>
-int CNetCdfInterface::ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const int* op)
-{
-  return (nc_put_vara_int(ncid, varid, start, count, op));
-}
-
- /*!
- This function verifies an existence of a variable by using its name.
- Be careful, althoug false means variable doens't exist, it could show that netCDF file doesn't either
- \param [in] ncid Id of groupd(or File Id)
- \param [in] attrName Name of the variable
- \return Existence of variable
- */
-bool CNetCdfInterface::isVarExisted(int ncId, const StdString& varName)
-{
-   int varId = 0;
-   return (NC_NOERR == (nc_inq_varid(ncId, varName.c_str(), &varId)));
-}
-
-StdString CNetCdfInterface::openMode2String(int oMode)
-{
-  StdString modeMes;
-  switch (oMode)
-  {
-  case NC_NOWRITE:
-    modeMes = StdString("NC_NOWRITE : Opening netCDF file with read-only access with buffering and caching access");
-    break;
-  case NC_SHARE:
-    modeMes = StdString("NC_SHARE : Several processes can read the file concurrently");
-    break;
-  case NC_WRITE:
-    modeMes = StdString("NC_WRITE : NetCDF file is readable and writable");
-    break;
-  default:
-    modeMes = StdString("In the composed opening mode");
-    break;
-  }
-  return modeMes;
-}
-
-StdString CNetCdfInterface::creationMode2String(int cMode)
-{
-  StdString modeMes;
-  switch (cMode)
-  {
-  case NC_NOCLOBBER:
-    modeMes = StdString("NC_NOCLOBBER : Not overwrite an exisiting netCDF file ");
-    break;
-  case NC_SHARE:
-    modeMes = StdString("NC_SHARE : Several processes can read from and write into the file concurrently");
-    break;
-  case NC_64BIT_OFFSET:
-    modeMes = StdString("NC_64BIT_OFFSET : NetCDF file is 64-bit offset");
-    break;
-  case NC_NETCDF4:
-    modeMes = StdString("NC_NETCDF4 : NetCDF file is HDF5/NetCDF-4");
-    break;
-  case NC_CLASSIC_MODEL:
-    modeMes = StdString("NC_CLASSIC_MODEL : NetCDF file is classical model");
-    break;
-  default:
-    modeMes = StdString("In the composed creation mode");
-    break;
-  }
-  return modeMes;
-}
-
-}
Index: XIOS/trunk/src/output/netCdfInterface.hpp
===================================================================
--- XIOS/trunk/src/output/netCdfInterface.hpp	(revision 684)
+++ 	(revision )
@@ -1,143 +1,0 @@
-/*!
-   \file netCdfInterface.hpp
-   \author Ha NGUYEN
-   \date 08 Oct 2014
-   \since 03 Oct 2014
-
-   \brief Wrapper of netcdf functions.
- */
-#ifndef __NETCDF_INTERFACE_HPP_
-#define __NETCDF_INTERFACE_HPP_
-
-#include "xios_spl.hpp"
-
-#if !defined(USING_NETCDF_PAR)
-#include "exception.hpp"
-#endif
-
-#include "mpi.hpp"
-#include "netcdf.hpp"
-
-namespace xios
-{
-  /*!
-  \class CNetCdfInterface
-   This class is  wrapper of some common used functions of netCdf in Xios
-  */
-  class CNetCdfInterface
-  {
-  public:
-    //! Create a netcdf file
-    static int create(const StdString& path, int cmode, int& ncId);
-
-    //! Create a netcdf file on a parallel file system
-    static int createPar(const StdString& path, int cmode, MPI_Comm comm, MPI_Info info, int& ncId);
-
-    //! Open a netcdf file
-    static int open(const StdString& path, int oMode, int& ncId);
-
-    //! Open a netcdf file
-    static int openPar(const StdString& path, int cmode, MPI_Comm comm, MPI_Info info, int& ncId);
-
-    //! Close a netcdf file
-    static int close(int ncId);
-
-    //! Put netcdf file into define mode
-    static int reDef(int ncId);
-
-    //! End define mode of a netcdf file
-    static int endDef(int ncId);
-
-    //! Query identity of a named group
-    static int inqNcId(int ncid, const StdString& grpName, int& grpId);
-
-    //! Query identity of a named variable
-    static int inqVarId(int ncid, const StdString& varName, int& varId);
-
-    //! Query identity of a named dimension
-    static int inqDimId(int ncid,const StdString& dimName, int& dimId);
-
-    //! Query identity of unlimited dimension
-    static int inqUnLimDim(int ncid, int& dimId);
-
-    //! Query name of a dimension with its id
-    static int inqDimName(int ncid, int dimId, StdString& dimName);
-
-    //! Query length of dimension with its id
-    static int inqDimLen(int ncid, int dimId, StdSize& dimLen);
-
-    //! Query number of dimension of a variable with its id
-    static int inqVarNDims(int ncid, int varId, int& nDims);
-
-    //! Query list of dimension of a variable with its id
-    static int inqVarDimId(int, int, int*);
-
-    //! Query dimensions of a group
-    static int inqDimIds(int ncid, int& nDims, int* dimIds, int includeParents);
-
-
-    //! Define a group
-    static int defGrp(int parentNcid,const StdString& grpName, int& grpId);
-
-    //! Define a dimension
-    static int defDim(int ncid,const StdString& dimName, StdSize dimLen, int& dimId);
-
-    //! Define a variable
-    static int defVar(int ncid,const StdString& varName, nc_type xtype,
-                      int nDims, const int dimIds[], int& varId);
-
-    //! Define variable chunking size
-    static int defVarChunking(int ncid, int varId, int storage, StdSize chunkSize[]);
-
-    //! Define variable compression level
-    static int defVarDeflate(int ncid, int varId, int compressionLevel);
-
-    //! Set or unset the fill mode
-    static int setFill(int ncid, bool fill);
-
-    //! Define variable fill parameters
-    static int defVarFill(int ncid, int varId, int noFill, void* fillValue);
-
-
-    //! Change access type of a variable
-    static int varParAccess(int ncid, int varid, int access);
-
-    //! Syn
-    static int sync(int ncId);
-
-    //! Put attribute into variable
-    static int putAtt(int ncid, int varid, const StdString& attrName, nc_type xtype,
-                      StdSize numVal, const void* op);
-
-
-    //! Put attribute into variable with specific type
-    template<typename T>
-    static int putAttType(int ncid, int varid, const StdString& attrName, StdSize numVal, const T* op);
-
-    //! Put value into a variable with a specific type
-    template<typename T>
-    static int putVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const T* op);
-
-  private:
-    template<typename T>
-    static int ncPutAttType(int ncid, int varid, const char* attrName, StdSize numVal, const T* op);
-
-    template<typename T>
-    static int ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const T* op);
-
-  private:
-    static StdString openMode2String(int oMode);
-
-    static StdString creationMode2String(int cMode);
-
-
-  public:
-    // Some functions dedude from several special cases
-    //! Query the existence of a variable
-    static bool isVarExisted(int ncId, const StdString& varName);
-
-  };
-}
-
-
-#endif // NETCDFINTERFACE_HPP_
Index: XIOS/trunk/src/output/netCdfInterface_decl.cpp
===================================================================
--- XIOS/trunk/src/output/netCdfInterface_decl.cpp	(revision 684)
+++ 	(revision )
@@ -1,30 +1,0 @@
-/*!
-   \file netCdfInterface_impl.hpp
-   \author Ha NGUYEN
-   \date 06 Oct 2014
-   \since 06 Oct 2014
-
-   \brief Implemention of some templated functions in netCdfInterface
- */
-
-#include "netCdfInterface_impl.hpp"
-
-namespace xios
-{
-#define  macroPutAtt(type) \
-  template int CNetCdfInterface::putAttType(int ncid, int varid, const StdString& attrName, \
-                                            StdSize numVal, const type* op);
-
-  macroPutAtt(double);
-  macroPutAtt(float);
-  macroPutAtt(int);
-  macroPutAtt(long);
-  macroPutAtt(short);
-
-#define  macroPutVar(type) \
- template int CNetCdfInterface::putVaraType(int ncid, int varId, const StdSize* start, \
-                                            const StdSize* count, const type* op);
-  macroPutVar(double);
-  macroPutVar(float);
-  macroPutVar(int);
-}
Index: XIOS/trunk/src/output/netCdfInterface_impl.hpp
===================================================================
--- XIOS/trunk/src/output/netCdfInterface_impl.hpp	(revision 684)
+++ 	(revision )
@@ -1,77 +1,0 @@
-/*!
-   \file netCdfInterface_impl.hpp
-   \author Ha NGUYEN
-   \date 08 Oct 2014
-   \since 06 Oct 2014
-
-   \brief Implemention of some templated functions in netCdfInterface
- */
-
-#ifndef __NETCDF_INTERFACE_IMPL_HPP__
-#define __NETCDF_INTERFACE_IMPL_HPP__
-
-#include "netCdfInterface.hpp"
-#include "netCdfException.hpp"
-
-namespace xios
-{
-   /*!
-   This function makes a request to netcdf with its id, to add or change a variable attribute or gloabl attribute,
-   given its name, type, number of values provided for attribute
-   \param [in] ncid Id of groupd(or File Id)
-   \param [in] varId Id of the variable
-   \param [in] attrName Name of the attribute
-   \param [in] numVal Number of values
-   \param [in] op Array of values provided for attribute
-   \return Error code
-   */
-  template<typename T>
-  int CNetCdfInterface::putAttType(int ncid, int varId, const StdString& attrName,
-                                   StdSize numVal, const T* op)
-  {
-    int status = ncPutAttType(ncid, varId, attrName.c_str(), numVal, op);
-    if (NC_NOERR != status)
-     {
-       StdString errormsg(nc_strerror(status));
-       StdStringStream sstr;
-       sstr << "Error in calling function " << "ncPutAttType(ncid, varId, attrName.c_str(), numVal, op)" << std::endl;
-       sstr << errormsg << std::endl;
-       sstr << "Unable to set attribute " << attrName << " for a variable with id : " << varId
-         << " with number of attribute  " << numVal << std::endl;
-       StdString e = sstr.str();
-       throw CNetCdfException(e);
-     }
-
-     return status;
-  }
-
-   /*!
-   This function makes a request to netcdf with its id, to write variable values into netcdf file,
-   \param [in] ncid Id of groupd(or File Id)
-   \param [in] varId Id of the variable
-   \param [in] start Array specifying the index in the variable where the first data value will be written
-   \param [in] count Array specifying the edge lengths along each dimension of block data
-   \param [in] op Array of values provided for attribute
-   \return Error code
-   */
-  template<typename T>
-  int CNetCdfInterface::putVaraType(int ncid, int varId, const StdSize* start, const StdSize* count, const T* op)
-  {
-    int status = ncPutVaraType(ncid, varId, start, count, op);
-    if (NC_NOERR != status)
-     {
-       StdString errormsg(nc_strerror(status));
-       StdStringStream sstr;
-       sstr << "Error in calling function " << "ncPutVaraType(ncid, varId, start, count, op)" << std::endl;
-       sstr << errormsg << std::endl;
-       sstr << "Unable to write value of a variable with id : " << varId << std::endl;
-       StdString e = sstr.str();
-       throw CNetCdfException(e);
-     }
-
-     return status;
-  }
-
-}
-
-#endif // __NETCDF_INTERFACE_IMPL_HPP__
Index: XIOS/trunk/src/output/netcdf.hpp
===================================================================
--- XIOS/trunk/src/output/netcdf.hpp	(revision 684)
+++ 	(revision )
@@ -1,67 +1,0 @@
-#ifndef __XIOS_NETCDF_HPP__
-#define __XIOS_NETCDF_HPP__
-#include "mpi.hpp"
-#define MPI_INCLUDED
-#include <netcdf.h>
-
-#if defined(USING_NETCDF_INTERNAL)
-  const bool using_netcdf_internal=true ;
-#else
-  const bool using_netcdf_internal=false ;
-#endif
-
-#include "netcdf_version.hpp"
-
-#if NETCDF_VERSION >= 4110
-
-#  if defined(USING_NETCDF_PAR)
-extern "C"
-{
-#  include <netcdf_par.h>
-}
-#  endif
-#endif
-
-#if !defined(USING_NETCDF_PAR)
-#define NC_INDEPENDENT 0
-#define NC_COLLECTIVE  1
-#endif
-
-namespace xios
-{
-  inline int nc_create_par(const char *path, int cmode, MPI_Comm comm, MPI_Info info,int *ncidp)
-  {
-#if defined(USING_NETCDF_PAR)
-    return ::nc_create_par(path, cmode, comm, info, ncidp) ;
-#else
-    ERROR("int nc_create_par(const char *path, int cmode, MPI_Comm comm, MPI_Info info,int *ncidp)",
-           << "must not be use with netcdf sequential version") ;
-    return -1 ;
-#endif
-  }
-
-  inline int nc_open_par(const char *path, int mode, MPI_Comm comm, MPI_Info info,int *ncidp)
-  {
-#if defined(USING_NETCDF_PAR)
-    return ::nc_open_par(path, mode, comm, info, ncidp) ;
-#else
-    ERROR("int nc_open_par(const char *path, int mode, MPI_Comm comm, MPI_Info info,int *ncidp)",
-           << "must not be use with netcdf sequential version") ;
-    return -1 ;
-#endif
-  }
-
-  inline int nc_var_par_access(int ncid, int varid, int par_access)
-  {
-#if defined(USING_NETCDF_PAR)
-    return ::nc_var_par_access(ncid, varid, par_access) ;
-#else
-    ERROR("int nc_var_par_access(int ncid, int varid, int par_access)",
-           << "must not be use with netcdf sequential version") ;
-    return -1 ;
-#endif
-  }
-}
-
-
-#endif
Index: XIOS/trunk/src/output/netcdf_version.hpp
===================================================================
--- XIOS/trunk/src/output/netcdf_version.hpp	(revision 684)
+++ 	(revision )
@@ -1,34 +1,0 @@
-#ifndef __XIOS_NETCDF_VERSION_HPP__
-#define __XIOS_NETCDF_VERSION_HPP__
-
-#if defined(NC_DISKLESS) && defined (NC_MMAP)
-
-#  define NETCDF_VERSION 4211
-
-#elif defined(NC_ETRANSLATION)
-
-# define NETCDF_VERSION 4130
-
-#elif defined(NC_EURL) && defined(NC_ECONSTRAINT)
-
-#  define NETCDF_VERSION 4120
-
-#elif defined (NC_PNETCDF)
-
-#  define NETCDF_VERSION 4110
-
-#elif defined(NC_CHUNKED) && defined(NC_CONTIGUOUS)
-
-# define NETCDF_VERSION 4010
-
-#elif defined(NC_NETCDF4)
-
-# define NETCDF_VERSION 4000
-
-#else
-
-#  error "netcdf version prior 4.0 incompatible with XIOS"
- 
-#endif
-
-#endif
Index: XIOS/trunk/src/output/onetcdf4.cpp
===================================================================
--- XIOS/trunk/src/output/onetcdf4.cpp	(revision 684)
+++ 	(revision )
@@ -1,578 +1,0 @@
-#include <fstream>
-
-#include "onetcdf4.hpp"
-#include "group_template.hpp"
-#include "mpi.hpp"
-#include "netcdf.hpp"
-#include "netCdfInterface.hpp"
-#include "netCdfException.hpp"
-
-namespace xios
-{
-      /// ////////////////////// DÃ©finitions ////////////////////// ///
-
-      CONetCDF4::CONetCDF4
-         (const StdString & filename, bool append, bool useClassicFormat, const MPI_Comm* comm, bool multifile)
-            : path()
-            , wmpi(false)
-            , useClassicFormat(useClassicFormat)
-            , recordOffset(0)
-      {
-         this->initialize(filename, append, useClassicFormat, comm,multifile);
-      }
-
-      //---------------------------------------------------------------
-
-
-      CONetCDF4::~CONetCDF4(void)
-      {
-//         CheckError(nc_close(this->ncidp));
-      }
-
-      ///--------------------------------------------------------------
-
-      void CONetCDF4::initialize
-         (const StdString & filename, bool append, bool useClassicFormat, const MPI_Comm* comm, bool multifile)
-      {
-         this->useClassicFormat = useClassicFormat;
-
-         int mode = useClassicFormat ? 0 : NC_NETCDF4;
-
-         // Don't use parallel mode if there is only one process
-         if (comm)
-         {
-            int commSize = 0;
-            MPI_Comm_size(*comm, &commSize);
-            if (commSize <= 1)
-               comm = NULL;
-         }
-         wmpi = comm && !multifile;
-
-         if (wmpi)
-            mode |= useClassicFormat ? NC_PNETCDF : NC_MPIIO;
-
-         // If the file does not exist, we always create it
-         if (!append || !std::ifstream(filename.c_str()))
-         {
-            if (wmpi)
-               CNetCdfInterface::createPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp);
-            else
-               CNetCdfInterface::create(filename, mode, this->ncidp);
-
-            this->appendMode = false;
-            this->recordOffset = 0;
-         }
-         else
-         {
-            mode |= NC_WRITE;
-            if (wmpi)
-               CNetCdfInterface::openPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp);
-            else
-               CNetCdfInterface::open(filename, mode, this->ncidp);
-
-            this->appendMode = true;
-            // Find out how many temporal records have been written already to the file we are opening
-            int ncUnlimitedDimId;
-            CNetCdfInterface::inqUnLimDim(this->ncidp, ncUnlimitedDimId);
-            if (ncUnlimitedDimId != -1)
-               CNetCdfInterface::inqDimLen(this->ncidp, ncUnlimitedDimId, this->recordOffset);
-            else
-               this->recordOffset = 0;
-         }
-
-         // If the classic NetCDF format is used, we enable the "no-fill mode" globally.
-         // This is done per variable for the NetCDF4 format.
-         if (useClassicFormat)
-            CNetCdfInterface::setFill(this->ncidp, false);
-      }
-
-      void CONetCDF4::close()
-      {
-        (CNetCdfInterface::close(this->ncidp));
-      }
-
-      //---------------------------------------------------------------
-
-      void CONetCDF4::definition_start(void)
-      {
-         (CNetCdfInterface::reDef(this->ncidp));
-      }
-
-      //---------------------------------------------------------------
-
-      void CONetCDF4::definition_end(void)
-      {
-         (CNetCdfInterface::endDef(this->ncidp));
-      }
-
-      //---------------------------------------------------------------
-
-// Don't need it anymore?
-//      void CONetCDF4::CheckError(int status)
-//      {
-//         if (status != NC_NOERR)
-//         {
-//            StdString errormsg (nc_strerror(status)); // fuite mÃ©moire ici ?
-//            ERROR("CONetCDF4::CheckError(int status)",
-//                  << "[ status = " << status << " ] " << errormsg);
-//         }
-//      }
-
-      //---------------------------------------------------------------
-
-      int CONetCDF4::getCurrentGroup(void)
-      {
-         return (this->getGroup(this->getCurrentPath()));
-      }
-
-      //---------------------------------------------------------------
-
-      int CONetCDF4::getGroup(const CONetCDF4Path & path)
-      {
-         int retvalue = this->ncidp;
-
-         CONetCDF4Path::const_iterator
-            it  = path.begin(), end = path.end();
-
-         for (;it != end; it++)
-         {
-            const StdString & groupid = *it;
-            (CNetCdfInterface::inqNcId(retvalue, groupid, retvalue));
-         }
-         return (retvalue);
-      }
-
-      //---------------------------------------------------------------
-
-      int CONetCDF4::getVariable(const StdString & varname)
-      {
-         int varid = 0;
-         int grpid = this->getCurrentGroup();
-         (CNetCdfInterface::inqVarId(grpid, varname, varid));
-         return (varid);
-      }
-
-      //---------------------------------------------------------------
-
-      int CONetCDF4::getDimension(const StdString & dimname)
-      {
-         int dimid = 0;
-         int grpid = this->getCurrentGroup();
-         (CNetCdfInterface::inqDimId(grpid, dimname, dimid));
-         return (dimid);
-      }
-
-      //---------------------------------------------------------------
-
-      int CONetCDF4::getUnlimitedDimension(void)
-      {
-         int dimid = 0;
-         int grpid = this->getCurrentGroup();
-         (CNetCdfInterface::inqUnLimDim(grpid, dimid));
-         return (dimid);
-      }
-
-      StdString CONetCDF4::getUnlimitedDimensionName(void)
-      {
-         int grpid = this->getGroup(path);
-         int dimid = this->getUnlimitedDimension();
-
-         if (dimid == -1) return (std::string());
-         StdString dimname;
-         (CNetCdfInterface::inqDimName(grpid, dimid, dimname));
-
-         return (dimname);
-      }
-
-      //---------------------------------------------------------------
-
-      std::vector<StdSize> CONetCDF4::getDimensions(const StdString & varname)
-      {
-         StdSize size = 0;
-         std::vector<StdSize> retvalue;
-         int grpid = this->getCurrentGroup();
-         int varid = this->getVariable(varname);
-         int nbdim = 0, *dimid = NULL;
-
-         (CNetCdfInterface::inqVarNDims(grpid, varid, nbdim));
-         dimid = new int[nbdim]();
-         (CNetCdfInterface::inqVarDimId(grpid, varid, dimid));
-
-         for (int i = 0; i < nbdim; i++)
-         {
-            (CNetCdfInterface::inqDimLen(grpid, dimid[i], size));
-            if (size == NC_UNLIMITED)
-                size = UNLIMITED_DIM;
-            retvalue.push_back(size);
-         }
-         delete [] dimid;
-         return (retvalue);
-      }
-
-      std::vector<std::string> CONetCDF4::getDimensionsIdList (const std::string * _varname)
-      {
-         int nDimNull = 0;
-         int nbdim = 0, *dimid = NULL;
-         int grpid = this->getCurrentGroup();
-         int varid = (_varname != NULL) ? this->getVariable(*_varname) : NC_GLOBAL;
-         std::vector<std::string> retvalue;
-
-         if (_varname != NULL)
-         {
-            (CNetCdfInterface::inqVarNDims(grpid, varid, nbdim));
-            dimid = new int[nbdim]();
-            (CNetCdfInterface::inqVarDimId(grpid, varid, dimid));
-         }
-         else
-         {
-            (CNetCdfInterface::inqDimIds(grpid, nbdim, NULL, 1));
-            dimid = new int[nbdim]();
-            (CNetCdfInterface::inqDimIds(grpid, nDimNull, dimid, 1));
-         }
-
-         for (int i = 0; i < nbdim; i++)
-         {
-            std::string dimname;
-            (CNetCdfInterface::inqDimName(grpid, dimid[i], dimname));
-            retvalue.push_back(dimname);
-         }
-         delete [] dimid;
-
-         return (retvalue);
-      }
-
-
-      //---------------------------------------------------------------
-
-      const CONetCDF4::CONetCDF4Path & CONetCDF4::getCurrentPath(void) const
-      { return (this->path); }
-
-      void CONetCDF4::setCurrentPath(const CONetCDF4Path & path)
-      { this->path = path; }
-
-      //---------------------------------------------------------------
-
-      int CONetCDF4::addGroup(const StdString & name)
-      {
-         int retvalue = 0;
-         int grpid = this->getCurrentGroup();
-         (CNetCdfInterface::defGrp(grpid, name, retvalue));
-         return (retvalue);
-      }
-
-      //---------------------------------------------------------------
-
-      int CONetCDF4::addDimension(const StdString& name, const StdSize size)
-      {
-         int retvalue = 0;
-         int grpid = this->getCurrentGroup();
-         if (size != UNLIMITED_DIM)
-            (CNetCdfInterface::defDim(grpid, name, size, retvalue));
-         else
-            (CNetCdfInterface::defDim(grpid, name, NC_UNLIMITED, retvalue));
-         return (retvalue);
-      }
-
-      //---------------------------------------------------------------
-
-      int CONetCDF4::addVariable(const StdString & name, nc_type type,
-                                 const std::vector<StdString> & dim)
-      {
-         int varid = 0;
-         std::vector<int> dimids;
-         std::vector<StdSize> dimsizes;
-         StdSize size;
-         StdSize totalSize;
-         StdSize maxSize = 1024 * 1024 * 256; // == 2GB/8 if output double
-
-         int grpid = this->getCurrentGroup();
-
-         std::vector<StdString>::const_iterator it = dim.begin(), end = dim.end();
-
-         for (; it != end; it++)
-         {
-            const StdString & dimid = *it;
-            dimids.push_back(this->getDimension(dimid));
-            CNetCdfInterface::inqDimLen(grpid, this->getDimension(dimid), size);
-            if (size == NC_UNLIMITED) size = 1;
-            dimsizes.push_back(size);
-         }
-
-         CNetCdfInterface::defVar(grpid, name, type, dimids.size(), &dimids[0], varid);
-
-         // The classic NetCDF format does not support chunking nor fill parameters
-         if (!useClassicFormat)
-         {
-            // set chunksize : size of one record
-            // but must not be > 2GB (netcdf or HDF5 problem)
-            totalSize = 1;
-            for (vector<StdSize>::reverse_iterator it = dimsizes.rbegin(); it != dimsizes.rend(); ++it)
-            {
-              totalSize *= *it;
-              if (totalSize >= maxSize) *it = 1;
-            }
-
-            CNetCdfInterface::defVarChunking(grpid, varid, NC_CHUNKED, &dimsizes[0]);
-            CNetCdfInterface::defVarFill(grpid, varid, true, NULL);
-         }
-
-         return varid;
-      }
-
-      //---------------------------------------------------------------
-
-      void CONetCDF4::setCompressionLevel(const StdString& varname, int compressionLevel)
-      {
-         if (compressionLevel < 0 || compressionLevel > 9)
-           ERROR("void CONetCDF4::setCompressionLevel(const StdString& varname, int compressionLevel)",
-                 "Invalid compression level for variable \"" << varname << "\", the value should range between 0 and 9.");
-         if (compressionLevel && wmpi)
-           ERROR("void CONetCDF4::setCompressionLevel(const StdString& varname, int compressionLevel)",
-                 "Impossible to use compression for variable \"" << varname << "\" when using parallel mode.");
-
-         int grpid = this->getCurrentGroup();
-         int varid = this->getVariable(varname);
-         CNetCdfInterface::defVarDeflate(grpid, varid, compressionLevel);
-      }
-
-      //---------------------------------------------------------------
-
-      template <>
-         void CONetCDF4::addAttribute
-            (const StdString & name, const StdString & value, const StdString * varname )
-      {
-         int grpid = this->getCurrentGroup();
-         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
-         (CNetCdfInterface::putAtt(grpid, varid, name, NC_CHAR, value.size(), value.c_str()));
-         //CheckError(nc_put_att_string(grpid, varid, name.c_str(), 1, &str));
-      }
-
-      //---------------------------------------------------------------
-
-      template <>
-         void CONetCDF4::addAttribute
-            (const StdString & name, const double & value, const StdString * varname )
-      {
-         int grpid = this->getCurrentGroup();
-         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
-         (CNetCdfInterface::putAttType(grpid, varid, name, 1, &value));
-      }
-
-       template <>
-         void CONetCDF4::addAttribute
-            (const StdString & name, const CArray<double,1>& value, const StdString * varname )
-      {
-         int grpid = this->getCurrentGroup();
-         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
-         (CNetCdfInterface::putAttType(grpid, varid, name, value.numElements(), value.dataFirst()));
-      }
-      //---------------------------------------------------------------
-
-      template <>
-         void CONetCDF4::addAttribute
-            (const StdString & name, const float & value, const StdString * varname )
-      {
-         int grpid = this->getCurrentGroup();
-         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
-         (CNetCdfInterface::putAttType(grpid, varid, name, 1, &value));
-      }
-
-       template <>
-         void CONetCDF4::addAttribute
-            (const StdString & name, const CArray<float,1>& value, const StdString * varname )
-      {
-         int grpid = this->getCurrentGroup();
-         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
-         (CNetCdfInterface::putAttType(grpid, varid, name, value.numElements(), value.dataFirst()));
-      }
-
-      //---------------------------------------------------------------
-
-      template <>
-         void CONetCDF4::addAttribute
-            (const StdString & name, const int & value, const StdString * varname )
-      {
-         int grpid = this->getCurrentGroup();
-         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
-         (CNetCdfInterface::putAttType(grpid, varid, name, 1, &value));
-      }
-
-       template <>
-         void CONetCDF4::addAttribute
-            (const StdString & name, const CArray<int,1>& value, const StdString * varname )
-      {
-         int grpid = this->getCurrentGroup();
-         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
-         (CNetCdfInterface::putAttType(grpid, varid, name, value.numElements(), value.dataFirst()));
-      }
-
-      template <>
-         void CONetCDF4::addAttribute
-            (const StdString & name, const short int & value, const StdString * varname )
-      {
-         int grpid = this->getCurrentGroup();
-         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
-         (CNetCdfInterface::putAttType(grpid, varid, name, 1, &value));
-      }
-
-       template <>
-         void CONetCDF4::addAttribute
-            (const StdString & name, const CArray<short int,1>& value, const StdString * varname )
-      {
-         int grpid = this->getCurrentGroup();
-         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
-         (CNetCdfInterface::putAttType(grpid, varid, name, value.numElements(), value.dataFirst()));
-      }
-
-
-
-      template <>
-         void CONetCDF4::addAttribute
-            (const StdString & name, const long int & value, const StdString * varname )
-      {
-         int grpid = this->getCurrentGroup();
-         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
-         (CNetCdfInterface::putAttType(grpid, varid, name, 1, &value));
-      }
-
-       template <>
-         void CONetCDF4::addAttribute
-            (const StdString & name, const CArray<long int,1>& value, const StdString * varname )
-      {
-         int grpid = this->getCurrentGroup();
-         int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
-         (CNetCdfInterface::putAttType(grpid, varid, name, value.numElements(), value.dataFirst()));
-      }
-
-
-
-                //---------------------------------------------------------------
-
-      void CONetCDF4::getWriteDataInfos(const StdString & name, StdSize record, StdSize & array_size,
-                                        std::vector<StdSize> & sstart,
-                                        std::vector<StdSize> & scount,
-                                        const std::vector<StdSize> * start,
-                                        const std::vector<StdSize> * count)
-      {
-         std::vector<std::size_t> sizes  = this->getDimensions(name);
-         std::vector<std::string> iddims = this->getDimensionsIdList (&name);
-         std::vector<std::size_t>::const_iterator
-            it  = sizes.begin(), end = sizes.end();
-         int i = 0;
-
-         if (iddims.begin()->compare(this->getUnlimitedDimensionName()) == 0)
-         {
-            sstart.push_back(record + recordOffset);
-            scount.push_back(1);
-            if ((start == NULL) &&
-                (count == NULL)) i++;
-            it++;
-         }
-
-         for (;it != end; it++)
-         {
-            if ((start != NULL) && (count != NULL))
-            {
-               sstart.push_back((*start)[i]);
-               scount.push_back((*count)[i]);
-               array_size *= (*count)[i];
-               i++;
-            }
-            else
-            {
-               sstart.push_back(0);
-               scount.push_back(sizes[i]);
-               array_size *= sizes[i];
-               i++;
-            }
-         }
-
-      }
-
-
-
-      template <>
-         void CONetCDF4::writeData_(int grpid, int varid,
-                                    const std::vector<StdSize> & sstart,
-                                    const std::vector<StdSize> & scount, const double * data)
-      {
-         (CNetCdfInterface::putVaraType(grpid, varid, &(sstart[0]), &(scount[0]), data));
-//         sync() ;
-      }
-
-      //---------------------------------------------------------------
-
-      template <>
-         void CONetCDF4::writeData_(int grpid, int varid,
-                                    const std::vector<StdSize> & sstart,
-                                    const std::vector<StdSize> & scount, const int * data)
-      {
-          (CNetCdfInterface::putVaraType(grpid, varid, &(sstart[0]), &(scount[0]), data));
-//          sync() ;
-      }
-
-      //---------------------------------------------------------------
-
-      template <>
-         void CONetCDF4::writeData_(int grpid, int varid,
-                                    const std::vector<StdSize> & sstart,
-                                    const std::vector<StdSize> & scount, const float * data)
-      {
-          (CNetCdfInterface::putVaraType(grpid, varid, &(sstart[0]), &(scount[0]), data));
-//          sync() ;
-      }
-
-      //---------------------------------------------------------------
-
-      void CONetCDF4::writeData(const CArray<int, 2>& data, const StdString & name)
-      {
-         int grpid = this->getCurrentGroup();
-         int varid = this->getVariable(name);
-         StdSize array_size = 1;
-         std::vector<StdSize> sstart, scount;
-
-         this->getWriteDataInfos(name, 0, array_size,  sstart, scount, NULL, NULL);
-         this->writeData_(grpid, varid, sstart, scount, data.dataFirst());
-      }
-
-      void CONetCDF4::writeTimeAxisData(const CArray<double, 1>& data, const StdString & name,
-                                        bool collective, StdSize record, bool isRoot)
-      {
-         int grpid = this->getCurrentGroup();
-         int varid = this->getVariable(name);
-
-         map<int,size_t>::iterator it=timeAxis.find(varid) ;
-         if (it==timeAxis.end()) timeAxis[varid]=record ;
-         else
-         {
-           if (it->second >= record) return ;
-           else it->second =record ;
-         }
-
-         StdSize array_size = 1;
-         std::vector<StdSize> sstart, scount;
-
-         if (this->wmpi && collective)
-         (CNetCdfInterface::varParAccess(grpid, varid, NC_COLLECTIVE));
-         if (this->wmpi && !collective)
-         (CNetCdfInterface::varParAccess(grpid, varid, NC_INDEPENDENT));
-
-         this->getWriteDataInfos(name, record, array_size,  sstart, scount, NULL, NULL);
-         if (using_netcdf_internal)  if (!isRoot) { sstart[0]=sstart[0]+1 ; scount[0]=0 ;}
-         this->writeData_(grpid, varid, sstart, scount, data.dataFirst());
-       }
-
-      //---------------------------------------------------------------
-
-      bool CONetCDF4::varExist(const StdString & varname)
-      {
-         int grpid = this->getCurrentGroup();
-         return (CNetCdfInterface::isVarExisted(grpid, varname));
-      }
-
-      void CONetCDF4::sync(void)
-      {
-         (CNetCdfInterface::sync(this->ncidp)) ;
-      }
-      ///--------------------------------------------------------------
- } // namespace xios
Index: XIOS/trunk/src/output/onetcdf4.hpp
===================================================================
--- XIOS/trunk/src/output/onetcdf4.hpp	(revision 684)
+++ 	(revision )
@@ -1,134 +1,0 @@
-#ifndef __XIOS_ONETCDF4__
-#define __XIOS_ONETCDF4__
-
-/// XIOS headers ///
-#include "xios_spl.hpp"
-#include "exception.hpp"
-#include "data_output.hpp"
-#include "array_new.hpp"
-#include "mpi.hpp"
-#include "netcdf.hpp"
-
-#ifndef UNLIMITED_DIM
-   #define UNLIMITED_DIM (size_t)(-1)
-#endif  //UNLIMITED_DIM
-
-namespace xios
-{
-      /// ////////////////////// DÃ©clarations ////////////////////// ///
-      class CONetCDF4
-         : public virtual CDataOutput
-      {
-         public :
-
-            /// DÃ©finition de type ///
-            typedef std::vector<StdString> CONetCDF4Path;
-
-            /// Constructeurs ///
-            CONetCDF4(const StdString & filename, bool append, bool useClassicFormat = false,
-                      const MPI_Comm * comm = NULL, bool multifile = true);
-
-            CONetCDF4(const CONetCDF4 & onetcdf4);       // Not implemented.
-            CONetCDF4(const CONetCDF4 * const onetcdf4); // Not implemented.
-
-
-            /// Initialisation ///
-            void initialize(const StdString & filename, bool append, bool useClassicFormat,
-                            const MPI_Comm * comm, bool multifile);
-            void close(void) ;
-            void sync(void) ;
-            void definition_start(void);
-            void definition_end(void);
-
-            /// Mutateurs ///
-            void setCurrentPath(const CONetCDF4Path & path);
-
-            int addGroup(const StdString & name);
-            int addDimension(const StdString& name, const StdSize size = UNLIMITED_DIM);
-            int addVariable(const StdString & name, nc_type type,
-                            const std::vector<StdString> & dim);
-
-      //----------------------------------------------------------------
-         public :
-
-            template <class T>
-               void setDefaultValue(const StdString & varname, const T * value = NULL);
-
-            void setCompressionLevel(const StdString& varname, int compressionLevel);
-
-            template <class T>  void addAttribute (const StdString & name, const T & value, const StdString * varname = NULL);
-
-            /// Ecriture des donnÃ©es ///
-            template <class T, int ndim>
-               void writeData(const CArray<T,ndim>& data, const StdString & name,
-                              bool collective, StdSize record,
-                              const std::vector<StdSize> * start = NULL,
-                              const std::vector<StdSize> * count = NULL);
-
-            void writeData(const CArray<int, 2>& data, const StdString & name);
-            void writeTimeAxisData(const CArray<double,1>& data, const StdString & name,
-                                   bool collective, StdSize record, bool Isroot) ;
-            /// Accesseur ///
-            const CONetCDF4Path & getCurrentPath(void) const;
-
-            /// Destructeur ///
-            virtual ~CONetCDF4(void);
-
-      //----------------------------------------------------------------
-
-         protected :
-
-            /// Ecriture ///
-            virtual void writeField_ (CField*  field)  = 0;
-            virtual void writeDomain_(CDomain* domain) = 0;
-            virtual void writeAxis_  (CAxis*   axis)   = 0;
-
-            /// Accesseurs ///
-            int getCurrentGroup(void);
-            int getGroup(const CONetCDF4Path & path);
-            int getVariable(const StdString & varname);
-            int getDimension(const StdString & dimname);
-            std::vector<StdSize>   getDimensions       (const StdString & varname);
-            std::vector<StdString> getDimensionsIdList (const StdString * varname);
-            int       getUnlimitedDimension(void);
-            StdString getUnlimitedDimensionName(void);
-
-            bool varExist(const StdString & varname);
-
-            bool useClassicFormat; //!< If true, NetCDF4 will use the classic NetCDF3 format
-
-      //----------------------------------------------------------------
-
-         private :
-
-            template <class T>
-               void writeData_(int grpid, int varid,
-                               const std::vector<StdSize> & sstart,
-                               const std::vector<StdSize> & scount, T * data);
-
-            void getWriteDataInfos(const StdString & name, StdSize record, StdSize & array_size,
-                                   std::vector<StdSize> & sstart,
-                                   std::vector<StdSize> & scount,
-                                   const std::vector<StdSize> * start,
-                                   const std::vector<StdSize> * count);
-
-            /// VÃ©rification des erreurs NetCDF ///
-            void CheckError(int status);
-
-            /// PropriÃ©tÃ©s privÃ©es ///
-            CONetCDF4Path path;
-            int ncidp;
-            bool wmpi;
-            /*! Number of records already written when opening an existing file.
-             *  always 0 when creating a new file */
-            size_t recordOffset;
-            map<int,size_t> timeAxis ;
-      }; // class CONetCDF4
-
-      ///---------------------------------------------------------------
-
-
-
-} // namespace xios
-
-#endif //__XIOS_ONETCDF4__
Index: XIOS/trunk/src/output/onetcdf4_decl.cpp
===================================================================
--- XIOS/trunk/src/output/onetcdf4_decl.cpp	(revision 684)
+++ 	(revision )
@@ -1,18 +1,0 @@
-#include "onetcdf4_impl.hpp"
-
-namespace xios
-{
-# define  macro(type,size) \
-  template void CONetCDF4::writeData<type,size>(const CArray<type, size>& data, const StdString & name, \
-                                               bool collective, StdSize record, \
-                                               const std::vector<StdSize> * start, \
-                                               const std::vector<StdSize> * count) ;
- 
-  macro(int, 1)
-  macro(double, 1)
-  macro(double, 2)
-  macro(double, 3)
- 
-  template void CONetCDF4::setDefaultValue<double>(const StdString & varname, const double* value) ;
-  template void CONetCDF4::setDefaultValue<float>(const StdString & varname, const float* value) ;
-}
Index: XIOS/trunk/src/output/onetcdf4_impl.hpp
===================================================================
--- XIOS/trunk/src/output/onetcdf4_impl.hpp	(revision 684)
+++ 	(revision )
@@ -1,69 +1,0 @@
-#ifndef __ONETCDF4_IMPL_HPP__
-#define __ONETCDF4_IMPL_HPP__
-
-#include "onetcdf4.hpp"
-#include "netCdfInterface.hpp"
-
-namespace xios
-{
-  template <class T, int ndim>
-  void CONetCDF4::writeData(const CArray<T, ndim>& data, const StdString & name,
-                            bool collective, StdSize record,
-                            const std::vector<StdSize> * start,
-                            const std::vector<StdSize> * count)
-  {
-    int grpid = this->getCurrentGroup();
-    int varid = this->getVariable(name);
-    StdSize array_size = 1;
-    std::vector<StdSize> sstart, scount;
-
-    if (this->wmpi && collective)
-    CNetCdfInterface::varParAccess(grpid, varid, NC_COLLECTIVE);
-    if (this->wmpi && !collective)
-    CNetCdfInterface::varParAccess(grpid, varid, NC_INDEPENDENT);
-
-    this->getWriteDataInfos
-    (name, record, array_size,  sstart, scount, start, count);
-    if (data.numElements() != array_size)
-    {
-      ERROR("CONetCDF4::writeData(...)",
-      << "[ input array size = "  << data.numElements()
-      << ", intern array size = " << array_size
-      << " ] Invalid input data !" );
-    }
-
-    this->writeData_(grpid, varid, sstart, scount, data.dataFirst());
-  }
-
-//----------------------------------------------------------------
-
-  template <class T>
-  void CONetCDF4::setDefaultValue(const StdString & varname, const T * value)
-  {
-    int grpid = this->getCurrentGroup();
-    int varid = this->getVariable(varname);
-
-    if (value != NULL)
-    {
-      // nc_def_var_fill will automatically set the _FillValue attribute when
-      // using the NetCDF 4 format but we need to do it manually otherwise
-      if (useClassicFormat)
-        this->addAttribute(StdString("_FillValue"), *value, &varname);
-      else
-        CNetCdfInterface::defVarFill(grpid, varid, 0, (void*)value);
-      this->addAttribute(StdString("missing_value"), *value, &varname);
-    }
-    else if (!useClassicFormat)
-    {
-      // The "no-fill mode" is set globally for the classic NetCDF format
-      CNetCdfInterface::defVarFill(grpid, varid, 1, NULL);
-    }
-  }
-
-  ///---------------------------------------------------------------
-
-}
-
-
-
-#endif
