Index: XIOS/dev/dev_olga/src/io/nc4_data_output.cpp
===================================================================
--- XIOS/dev/dev_olga/src/io/nc4_data_output.cpp	(revision 1144)
+++ XIOS/dev/dev_olga/src/io/nc4_data_output.cpp	(revision 1158)
@@ -11,19 +11,21 @@
 #include "netCdfException.hpp"
 #include "exception.hpp"
-
+#include "timer.hpp"
+#include "uuid.hpp"
 namespace xios
 {
       /// ////////////////////// Dfinitions ////////////////////// ///
       CNc4DataOutput::CNc4DataOutput
-         (const StdString & filename, bool exist)
+         (CFile* file, const StdString & filename, bool exist)
             : SuperClass()
             , SuperClassWriter(filename, exist)
             , filename(filename)
-      {
-    SuperClass::type = MULTI_FILE;
+            , file(file),hasTimeInstant(false),hasTimeCentered(false), timeCounterType(none)
+      {
+        SuperClass::type = MULTI_FILE;
       }
 
       CNc4DataOutput::CNc4DataOutput
-         (const StdString & filename, bool exist, bool useClassicFormat, bool useCFConvention,
+         (CFile* file, const StdString & filename, bool exist, bool useClassicFormat, bool useCFConvention,
           MPI_Comm comm_file, bool multifile, bool isCollective, const StdString& timeCounterName)
             : SuperClass()
@@ -32,6 +34,7 @@
             , filename(filename)
             , isCollective(isCollective)
-      {
-    SuperClass::type = (multifile) ? MULTI_FILE : ONE_FILE;
+            , file(file),hasTimeInstant(false),hasTimeCentered(false), timeCounterType(none)
+      {
+        SuperClass::type = (multifile) ? MULTI_FILE : ONE_FILE;
       }
 
@@ -60,5 +63,4 @@
         }
 
-        
          CContext* context = CContext::getCurrent() ;
          CContextServer* server=context->server ;
@@ -78,6 +80,12 @@
          int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex;
 
-         StdString dimXid, dimYid ;
-
+
+        StdString dimXid, dimYid ;
+
+        nc_type typePrec ;
+        if (domain->prec.isEmpty()) typePrec =  NC_FLOAT ;
+        else if (domain->prec==4)  typePrec =  NC_FLOAT ;
+        else if (domain->prec==8)   typePrec =  NC_DOUBLE ;
+         
          bool isRegularDomain = (domain->type == CDomain::type_attr::rectilinear);
          switch (domain->type)
@@ -209,10 +217,10 @@
                    {
                      case CDomain::type_attr::curvilinear :
-                       SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
-                       SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0);
+                       SuperClassWriter::addVariable(latid, typePrec, dim0);
+                       SuperClassWriter::addVariable(lonid, typePrec, dim0);
                        break ;
                       case CDomain::type_attr::rectilinear :
-                        SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
-                        SuperClassWriter::addVariable(lonid, NC_FLOAT, dim1);
+                        SuperClassWriter::addVariable(latid, typePrec, dim0);
+                        SuperClassWriter::addVariable(lonid, typePrec, dim1);
                         break ;
                    }
@@ -230,6 +238,6 @@
                      dim0.push_back(dimXid);
                      dim0.push_back(dimVertId);
-                     SuperClassWriter::addVariable(bounds_lonid, NC_FLOAT, dim0);
-                     SuperClassWriter::addVariable(bounds_latid, NC_FLOAT, dim0);
+                     SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0);
+                     SuperClassWriter::addVariable(bounds_latid, typePrec, dim0);
                    }
                  }
@@ -256,5 +264,5 @@
                  if (domain->hasArea)
                  {
-                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0);
+                   SuperClassWriter::addVariable(areaId, typePrec, dim0);
                    SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId);
                    SuperClassWriter::addAttribute("units", StdString("m2"), &areaId);
@@ -311,6 +319,6 @@
                        lonid = StdString("nav_lon").append(appendDomid);
                        latid = StdString("nav_lat").append(appendDomid);
-                       SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
-                       SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0);
+                       SuperClassWriter::addVariable(latid, typePrec, dim0);
+                       SuperClassWriter::addVariable(lonid, typePrec, dim0);
                        break;
 
@@ -320,6 +328,6 @@
                        lonid = StdString("lon").append(appendDomid);
                        latid = StdString("lat").append(appendDomid);
-                       SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
-                       SuperClassWriter::addVariable(lonid, NC_FLOAT, dim1);
+                       SuperClassWriter::addVariable(latid, typePrec, dim0);
+                       SuperClassWriter::addVariable(lonid, typePrec, dim1);
                        break;
                    }
@@ -342,6 +350,6 @@
                      dim0.push_back(dimXid);
                      dim0.push_back(dimVertId);
-                     SuperClassWriter::addVariable(bounds_lonid, NC_FLOAT, dim0);
-                     SuperClassWriter::addVariable(bounds_latid, NC_FLOAT, dim0);
+                     SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0);
+                     SuperClassWriter::addVariable(bounds_latid, typePrec, dim0);
                    }
                  }
@@ -351,5 +359,5 @@
                    dim0.clear();
                    dim0.push_back(dimYid); dim0.push_back(dimXid);
-                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0);
+                   SuperClassWriter::addVariable(areaId, typePrec, dim0);
                    SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId);
                    SuperClassWriter::addAttribute("units", StdString("m2"), &areaId);
@@ -492,4 +500,9 @@
         if (SuperClass::type==MULTI_FILE) return ;
 
+     nc_type typePrec ;
+     if (domain->prec.isEmpty()) typePrec =  NC_FLOAT ;
+     else if (domain->prec==4)  typePrec =  NC_FLOAT ;
+     else if (domain->prec==8)   typePrec =  NC_DOUBLE ;
+
       std::vector<StdString> dim0;
       StdString domid = domain->getDomainOutputName();
@@ -543,9 +556,9 @@
                 dim0.clear();
                 dim0.push_back(dimNode);
-                SuperClassWriter::addVariable(node_x, NC_FLOAT, dim0);
+                SuperClassWriter::addVariable(node_x, typePrec, dim0);
                 SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x);
                 SuperClassWriter::addAttribute("long_name", StdString("Longitude of mesh nodes."), &node_x);
                 SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x);
-                SuperClassWriter::addVariable(node_y, NC_FLOAT, dim0);
+                SuperClassWriter::addVariable(node_y, typePrec, dim0);
                 SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y);
                 SuperClassWriter::addAttribute("long_name", StdString("Latitude of mesh nodes."), &node_y);
@@ -562,9 +575,9 @@
                 dim0.clear();
                 dim0.push_back(dimNode);
-                SuperClassWriter::addVariable(node_x, NC_FLOAT, dim0);
+                SuperClassWriter::addVariable(node_x, typePrec, dim0);
                 SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x);
                 SuperClassWriter::addAttribute("long_name", StdString("Longitude of mesh nodes."), &node_x);
                 SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x);
-                SuperClassWriter::addVariable(node_y, NC_FLOAT, dim0);
+                SuperClassWriter::addVariable(node_y, typePrec, dim0);
                 SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y);
                 SuperClassWriter::addAttribute("long_name", StdString("Latitude of mesh nodes."), &node_y);
@@ -576,9 +589,9 @@
               dim0.clear();
               dim0.push_back(dimEdge);
-              SuperClassWriter::addVariable(edge_x, NC_FLOAT, dim0);
+              SuperClassWriter::addVariable(edge_x, typePrec, dim0);
               SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &edge_x);
               SuperClassWriter::addAttribute("long_name", StdString("Characteristic longitude of mesh edges."), &edge_x);
               SuperClassWriter::addAttribute("units", StdString("degrees_east"), &edge_x);
-              SuperClassWriter::addVariable(edge_y, NC_FLOAT, dim0);
+              SuperClassWriter::addVariable(edge_y, typePrec, dim0);
               SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &edge_y);
               SuperClassWriter::addAttribute("long_name", StdString("Characteristic latitude of mesh edges."), &edge_y);
@@ -602,9 +615,9 @@
                 dim0.clear();
                 dim0.push_back(dimNode);
-                SuperClassWriter::addVariable(node_x, NC_FLOAT, dim0);
+                SuperClassWriter::addVariable(node_x, typePrec, dim0);
                 SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x);
                 SuperClassWriter::addAttribute("long_name", StdString("Longitude of mesh nodes."), &node_x);
                 SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x);
-                SuperClassWriter::addVariable(node_y, NC_FLOAT, dim0);
+                SuperClassWriter::addVariable(node_y, typePrec, dim0);
                 SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y);
                 SuperClassWriter::addAttribute("long_name", StdString("Latitude of mesh nodes."), &node_y);
@@ -618,9 +631,9 @@
                 dim0.clear();
                 dim0.push_back(dimEdge);
-                SuperClassWriter::addVariable(edge_x, NC_FLOAT, dim0);
+                SuperClassWriter::addVariable(edge_x, typePrec, dim0);
                 SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &edge_x);
                 SuperClassWriter::addAttribute("long_name", StdString("Characteristic longitude of mesh edges."), &edge_x);
                 SuperClassWriter::addAttribute("units", StdString("degrees_east"), &edge_x);
-                SuperClassWriter::addVariable(edge_y, NC_FLOAT, dim0);
+                SuperClassWriter::addVariable(edge_y, typePrec, dim0);
                 SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &edge_y);
                 SuperClassWriter::addAttribute("long_name", StdString("Characteristic latitude of mesh edges."), &edge_y);
@@ -640,9 +653,9 @@
               dim0.clear();
               dim0.push_back(dimFace);
-              SuperClassWriter::addVariable(face_x, NC_FLOAT, dim0);
+              SuperClassWriter::addVariable(face_x, typePrec, dim0);
               SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &face_x);
               SuperClassWriter::addAttribute("long_name", StdString("Characteristic longitude of mesh faces."), &face_x);
               SuperClassWriter::addAttribute("units", StdString("degrees_east"), &face_x);
-              SuperClassWriter::addVariable(face_y, NC_FLOAT, dim0);
+              SuperClassWriter::addVariable(face_y, typePrec, dim0);
               SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &face_y);
               SuperClassWriter::addAttribute("long_name", StdString("Characteristic latitude of mesh faces."), &face_y);
@@ -906,4 +919,9 @@
          string areaId = "area" + appendDomid;
 
+         nc_type typePrec ;
+         if (domain->prec.isEmpty()) typePrec =  NC_FLOAT ;
+         else if (domain->prec==4)  typePrec =  NC_FLOAT ;
+         else if (domain->prec==8)   typePrec =  NC_DOUBLE ;
+
          int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex;
 
@@ -965,6 +983,6 @@
                  if (domain->hasLonLat)
                  {
-                   SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
-                   SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0);
+                   SuperClassWriter::addVariable(latid, typePrec, dim0);
+                   SuperClassWriter::addVariable(lonid, typePrec, dim0);
                    this->writeAxisAttributes(lonid, "", "longitude", "Longitude", "degrees_east", domid);
                    if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_lonid, &lonid);
@@ -978,6 +996,6 @@
                    dim0.push_back(dimXid);
                    dim0.push_back(dimVertId);
-                   SuperClassWriter::addVariable(bounds_lonid, NC_FLOAT, dim0);
-                   SuperClassWriter::addVariable(bounds_latid, NC_FLOAT, dim0);
+                   SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0);
+                   SuperClassWriter::addVariable(bounds_latid, typePrec, dim0);
                  }
 
@@ -986,5 +1004,5 @@
                  if (domain->hasArea)
                  {
-                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0);
+                   SuperClassWriter::addVariable(areaId, typePrec, dim0);
                    SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId);
                    SuperClassWriter::addAttribute("units", StdString("m2"), &areaId);
@@ -1021,6 +1039,6 @@
                  if (domain->hasLonLat)
                  {
-                   SuperClassWriter::addVariable(latid, NC_FLOAT, dim0);
-                   SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0);
+                   SuperClassWriter::addVariable(latid, typePrec, dim0);
+                   SuperClassWriter::addVariable(lonid, typePrec, dim0);
 
                    this->writeAxisAttributes(lonid, "", "longitude", "Longitude", "degrees_east", domid);
@@ -1036,6 +1054,6 @@
                    dim0.push_back(dimXid);
                    dim0.push_back(dimVertId);
-                   SuperClassWriter::addVariable(bounds_lonid, NC_FLOAT, dim0);
-                   SuperClassWriter::addVariable(bounds_latid, NC_FLOAT, dim0);
+                   SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0);
+                   SuperClassWriter::addVariable(bounds_latid, typePrec, dim0);
                  }
 
@@ -1044,5 +1062,5 @@
                    dim0.clear();
                    dim0.push_back(dimXid);
-                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0);
+                   SuperClassWriter::addVariable(areaId, typePrec, dim0);
                    SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId);
                    SuperClassWriter::addAttribute("units", StdString("m2"), &areaId);
@@ -1111,6 +1129,4 @@
       void CNc4DataOutput::writeAxis_(CAxis* axis)
       {
-        CContext* context = CContext::getCurrent();
-
         if (axis->IsWritten(this->filename)) return;
         axis->checkAttributes();
@@ -1130,11 +1146,20 @@
         else setWrittenAxis(axisid);
 
+        nc_type typePrec ;
+        if (axis->prec.isEmpty()) typePrec =  NC_FLOAT ;
+        else if (axis->prec==4)  typePrec =  NC_FLOAT ;
+        else if (axis->prec==8)   typePrec =  NC_DOUBLE ;
+         
+        if (!axis->label.isEmpty()) typePrec = NC_CHAR ;
+        string strId="str_len" ;
         try
         {
           SuperClassWriter::addDimension(axisid, zoom_size);
+          if (!axis->label.isEmpty()) SuperClassWriter::addDimension(strId, stringArrayLen);
           if (axis->hasValue)
           {
             dims.push_back(axisid);
-            SuperClassWriter::addVariable(axisid, NC_FLOAT, dims);
+            if (!axis->label.isEmpty()) dims.push_back(strId);
+            SuperClassWriter::addVariable(axisid, typePrec, dims);
 
             if (!axis->name.isEmpty())
@@ -1162,5 +1187,5 @@
             {
               dims.push_back("axis_nbounds");
-              SuperClassWriter::addVariable(axisBoundsId, NC_FLOAT, dims);
+              SuperClassWriter::addVariable(axisBoundsId, typePrec, dims);
               SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid);
             }
@@ -1178,19 +1203,17 @@
               case MULTI_FILE:
               {
-                // CArray<double,1> axis_value(axis->zoom_n);
-                // for (int i = 0; i < axis->zoom_n; i++) axis_value(i) = axis->value(i);
                 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0);
 
-                if (!axis->bounds.isEmpty())
+                if (!axis->bounds.isEmpty() && axis->label.isEmpty())
                   SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0);
 
+                // Need to check after
+                if (! axis->label.isEmpty())  SuperClassWriter::writeData(axis->label_srv, axisid, isCollective, 0);
+ 
                 SuperClassWriter::definition_start();
-
                 break;
               }
               case ONE_FILE:
               {
-                // CArray<double,1> axis_value(axis->zoom_n);
-                // axis_value = axis->value;
                 std::vector<StdSize> start(1), startBounds(2) ;
                 std::vector<StdSize> count(1), countBounds(2) ;
@@ -1201,5 +1224,5 @@
                 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count);
 
-                if (!axis->bounds.isEmpty())
+                if (!axis->bounds.isEmpty()&& axis->label.isEmpty())
                 {
                   axis_bounds.resize(2, indexToWrite.numElements());
@@ -1211,4 +1234,7 @@
                   SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds);
                 }
+
+                // Need to check after
+                if (! axis->label.isEmpty())  SuperClassWriter::writeData(axis->label_srv, axisid, isCollective, 0);
 
                 SuperClassWriter::definition_start();
@@ -1233,6 +1259,5 @@
           ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", << msg);
         }
-      
-      axis->addRelFile(this->filename);
+        axis->addRelFile(this->filename);
      }
 
@@ -1247,4 +1272,10 @@
         else setWrittenAxis(scalaId);
 
+        nc_type typePrec ;
+        if (scalar->prec.isEmpty()) typePrec =  NC_FLOAT ;
+        else if (scalar->prec==4)  typePrec =  NC_FLOAT ;
+        else if (scalar->prec==8)   typePrec =  NC_DOUBLE ;
+
+        
         try
         {
@@ -1253,5 +1284,5 @@
 //            dims.push_back(scalaId);
             std::vector<StdString> dims;
-            SuperClassWriter::addVariable(scalaId, NC_FLOAT, dims);
+            SuperClassWriter::addVariable(scalaId, typePrec, dims);
 
             if (!scalar->name.isEmpty())
@@ -1550,182 +1581,169 @@
       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())
+        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<int,1> axisDomainOrder = grid->axis_domain_order;
-         int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0, idxScalar = 0;
-         std::vector<StdString> domainList = grid->getDomainList();
-         std::vector<StdString> axisList   = grid->getAxisList();
-         std::vector<StdString> scalarList = grid->getScalarList();
-
-         StdString timeid  = getTimeCounterName();
-         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 (2 == axisDomainOrder(i))
-           {
-             CDomain* domain = CDomain::get(domainList[idxDomain]);
-             StdString domId = domain->getDomainOutputName();
-             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:
-               {
-           if (SuperClassWriter::useCFConvention)
-           {
-            dimXid     = StdString("cell").append(appendDomId);
-            dimIdList.push_back(dimXid);
-            dimCoordList.push_back(StdString("lon").append(appendDomId));
-            dimCoordList.push_back(StdString("lat").append(appendDomId));
+        CArray<int,1> axisDomainOrder = grid->axis_domain_order;
+        int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0, idxScalar = 0;
+        std::vector<StdString> domainList = grid->getDomainList();
+        std::vector<StdString> axisList   = grid->getAxisList();
+        std::vector<StdString> scalarList = grid->getScalarList();        
+
+        StdString timeid  = getTimeCounterName();
+        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 (2 == axisDomainOrder(i))
+          {
+            CDomain* domain = CDomain::get(domainList[idxDomain]);
+            StdString domId = domain->getDomainOutputName();
+            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:
+              {
+                if (SuperClassWriter::useCFConvention)
+                {
+                  dimXid     = StdString("cell").append(appendDomId);
+                  dimIdList.push_back(dimXid);
+                  dimCoordList.push_back(StdString("lon").append(appendDomId));
+                  dimCoordList.push_back(StdString("lat").append(appendDomId));
+                }
+                else
+                {
+                  StdString domainName = domain->name;
+                  if (domain->nvertex == 1)
+                  {
+                    dimXid     = "n" + domainName + "_node";
+                    dimIdList.push_back(dimXid);
+                    dimCoordList.push_back(StdString(domainName + "_node_x"));
+                    dimCoordList.push_back(StdString(domainName + "_node_y"));
+                  }
+                  else if (domain->nvertex == 2)
+                  {
+                    dimXid     = "n" + domainName + "_edge";
+                    dimIdList.push_back(dimXid);
+                    dimCoordList.push_back(StdString(domainName + "_edge_x"));
+                    dimCoordList.push_back(StdString(domainName + "_edge_y"));
+                  }
+                  else
+                  {
+                    dimXid     = "n" + domainName + "_face";
+                    dimIdList.push_back(dimXid);
+                    dimCoordList.push_back(StdString(domainName + "_face_x"));
+                    dimCoordList.push_back(StdString(domainName + "_face_y"));
+                  }
+                }  // ugrid convention
+              }  // case unstructured domain
+            }
+
+            if (domain->hasArea)
+            {
+              hasArea = true;
+              cellMeasures += " area" + appendDomId;
+            }
+            ++idxDomain;
           }
-           else
-           {
-            StdString domainName = domain->name;
-            if (domain->nvertex == 1)
+          else if (1 == axisDomainOrder(i))
+          {
+            CAxis* axis = CAxis::get(axisList[idxAxis]);
+            StdString axisId = axis->getAxisOutputName();
+
+            if (compressedOutput && axis->isCompressible())
             {
-              dimXid     = "n" + domainName + "_node";
-              dimIdList.push_back(dimXid);
-              dimCoordList.push_back(StdString(domainName + "_node_x"));
-              dimCoordList.push_back(StdString(domainName + "_node_y"));
-            }
-            else if (domain->nvertex == 2)
-            {
-              dimXid     = "n" + domainName + "_edge";
-              dimIdList.push_back(dimXid);
-              dimCoordList.push_back(StdString(domainName + "_edge_x"));
-              dimCoordList.push_back(StdString(domainName + "_edge_y"));
+              dimIdList.push_back(axisId + "_points");
+              field->setUseCompressedOutput();
             }
             else
-            {
-              dimXid     = "n" + domainName + "_face";
-              dimIdList.push_back(dimXid);
-              dimCoordList.push_back(StdString(domainName + "_face_x"));
-              dimCoordList.push_back(StdString(domainName + "_face_y"));
-            }
-          }  // ugrid convention
-        }  // case unstructured domain
-             }
-
-             if (domain->hasArea)
-             {
-               hasArea = true;
-               cellMeasures += " area" + appendDomId;
-             }
-             ++idxDomain;
-           }
-           else if (1 == axisDomainOrder(i))
-           {
-             CAxis* axis = CAxis::get(axisList[idxAxis]);
-             StdString axisId = axis->getAxisOutputName();
-
-             if (compressedOutput && axis->isCompressible())
-             {
-               dimIdList.push_back(axisId + "_points");
-               field->setUseCompressedOutput();
-             }
-             else
-               dimIdList.push_back(axisId);
-
-             dimCoordList.push_back(axisId);
-             ++idxAxis;
-           }
-           else // scalar
-           {
+              dimIdList.push_back(axisId);
+
+            dimCoordList.push_back(axisId);
+            ++idxAxis;
+          }
+          else // scalar
+          {
              /* Do nothing here */
-           }
-         }
-
-/*
-         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->getFieldOutputName();
-
-         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
-         {
+          }
+        }
+
+        StdString fieldid = field->getFieldOutputName();
+
+        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)
+        {
+          if (field->hasTimeInstant && hasTimeInstant) coodinates.push_back(string("time_instant"));
+          else if (field->hasTimeCentered && hasTimeCentered)  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);
 
@@ -1742,5 +1760,25 @@
                  ("units", field->unit.getValue(), &fieldid);
 
-            if (!field->valid_min.isEmpty())
+           // Ugrid field attributes "mesh" and "location"
+           if (!SuperClassWriter::useCFConvention)
+           {
+            if (!domainList.empty())
+            {
+              CDomain* domain = CDomain::get(domainList[0]); // Suppose that we have only domain
+              StdString mesh = domain->name;
+              SuperClassWriter::addAttribute("mesh", mesh, &fieldid);
+              StdString location;
+              if (domain->nvertex == 1)
+                location = "node";
+              else if (domain->nvertex == 2)
+                location = "edge";
+              else if (domain->nvertex > 2)
+                location = "face";
+              SuperClassWriter::addAttribute("location", location, &fieldid);
+            }
+
+           }
+
+           if (!field->valid_min.isEmpty())
               SuperClassWriter::addAttribute
                  ("valid_min", field->valid_min.getValue(), &fieldid);
@@ -1771,29 +1809,29 @@
            if (!field->cell_methods.isEmpty())
            {
-             StdString cellMethodString = field->cell_methods;
-             if (field->cell_methods_mode.isEmpty() ||
+              StdString cellMethodString = field->cell_methods;
+              if (field->cell_methods_mode.isEmpty() ||
                  (CField::cell_methods_mode_attr::overwrite == field->cell_methods_mode))
-             {
-               SuperClassWriter::addAttribute("cell_methods", cellMethodString, &fieldid);
-               alreadyAddCellMethod = true;
-             }
-             else
-             {
-               switch (field->cell_methods_mode)
-               {
-               case (CField::cell_methods_mode_attr::prefix):
-                 cellMethodsPrefix = cellMethodString;
-                 cellMethodsPrefix += " ";
-                 break;
-               case (CField::cell_methods_mode_attr::suffix):
-                 cellMethodsSuffix = " ";
-                 cellMethodsSuffix += cellMethodString;
-                 break;
-               case (CField::cell_methods_mode_attr::none):
-                 break;
-               default:
-                 break;
-               }
-             }
+              {
+                SuperClassWriter::addAttribute("cell_methods", cellMethodString, &fieldid);
+                alreadyAddCellMethod = true;
+              }
+              else
+              {
+                switch (field->cell_methods_mode)
+                {
+                  case (CField::cell_methods_mode_attr::prefix):
+                    cellMethodsPrefix = cellMethodString;
+                    cellMethodsPrefix += " ";
+                    break;
+                  case (CField::cell_methods_mode_attr::suffix):
+                    cellMethodsSuffix = " ";
+                    cellMethodsSuffix += cellMethodString;
+                    break;
+                  case (CField::cell_methods_mode_attr::none):
+                    break;
+                  default:
+                    break;
+                }
+              }
            }
 
@@ -1881,17 +1919,18 @@
          singleDomain = (file->nbDomains == 1);
 
+         StdString conv_str ;
+         if (file->convention_str.isEmpty())
+         {
+            if (SuperClassWriter::useCFConvention) conv_str="CF-1.6" ;
+            else conv_str="UGRID" ;
+         }
+         else conv_str=file->convention_str ;
+           
          try
          {
-       if (SuperClassWriter::useCFConvention)
-             this->writeFileAttributes(filename, description,
-                                       StdString("CF-1.5"),
-                                       StdString("An IPSL model"),
-                                       this->getTimeStamp());
-           else
-             this->writeFileAttributes(filename, description,
-                                       StdString("UGRID"),
-                                       StdString("An IPSL model"),
-                                       this->getTimeStamp());
-
+           this->writeFileAttributes(filename, description,
+                                      conv_str,
+                                      StdString("An IPSL model"),
+                                      this->getTimeStamp());
 
            if (!appendMode)
@@ -2017,8 +2056,13 @@
          struct tm * timeinfo = NULL;
          char buffer [buffer_size];
-
+         StdString formatStr;
+         if (file->time_stamp_format.isEmpty()) formatStr="%Y-%b-%d %H:%M:%S %Z" ;
+         else formatStr=file->time_stamp_format;
+
+//         time ( &rawtime );
+//         timeinfo = localtime ( &rawtime );
          time ( &rawtime );
-         timeinfo = localtime ( &rawtime );
-         strftime (buffer, buffer_size, "%Y-%b-%d %H:%M:%S %Z", timeinfo);
+         timeinfo = gmtime ( &rawtime );
+         strftime (buffer, buffer_size, formatStr.c_str(), timeinfo);
 
          return (StdString(buffer));
@@ -2033,8 +2077,14 @@
         CGrid* grid = field->grid;
 
-        if (field->getNStep()<1) return ;
+        if (field->getNStep()<1) 
+        {
+          return;
+        }
         
         if (!grid->doGridHaveDataToWrite())
-          if (SuperClass::type == MULTI_FILE || !isCollective) return;
+          if (SuperClass::type == MULTI_FILE || !isCollective)
+          {
+            return;
+          }
 
         StdString fieldid = field->getFieldOutputName();
@@ -2042,19 +2092,23 @@
         StdOStringStream oss;
         string timeAxisId;
-        if (field->getOperationTimeType() == func::CFunctor::instant) timeAxisId = "time_instant";
-        else if (field->getOperationTimeType() == func::CFunctor::centered) timeAxisId = "time_centered";
+        if (field->hasTimeInstant) timeAxisId = "time_instant";
+        else if (field->hasTimeCentered) timeAxisId = "time_centered";
 
         StdString timeBoundId = getTimeCounterName() + "_bounds";
 
         StdString timeAxisBoundId;
-        if (field->getOperationTimeType() == func::CFunctor::instant) timeAxisBoundId = "time_instant_bounds";
-        else if (field->getOperationTimeType() == func::CFunctor::centered) timeAxisBoundId = "time_centered_bounds";
+        if (field->hasTimeInstant) timeAxisBoundId = "time_instant_bounds";
+        else if (field->hasTimeCentered) timeAxisBoundId = "time_centered_bounds";
 
         if (!field->wasWritten())
         {
-          if (appendMode && field->file->record_offset.isEmpty() &&
-               field->getOperationTimeType() != func::CFunctor::once)
+          if (appendMode && field->file->record_offset.isEmpty() && 
+              field->getOperationTimeType() != func::CFunctor::once)
           {
-            field->resetNStep(getRecordFromTime(field->last_Write_srv) + 1);
+            double factorUnit;
+            if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days)
+            factorUnit=context->getCalendar()->getDayLengthInSeconds() ;
+            else factorUnit=1 ;
+            field->resetNStep(getRecordFromTime(field->last_Write_srv,factorUnit) + 1);
           }
 
@@ -2069,4 +2123,7 @@
 
         bool wtime = (field->getOperationTimeType() != func::CFunctor::once);
+        bool wtimeCounter =false ;
+        bool wtimeData =false ;
+        
 
         if (wtime)
@@ -2075,34 +2132,48 @@
           Time lastLastWrite = field->lastlast_Write_srv;
 
-          if (field->getOperationTimeType() == func::CFunctor::instant)
-            time_data(0) = lastWrite;
-          else if (field->getOperationTimeType() == func::CFunctor::centered)
+          
+          if (field->hasTimeInstant)
+          {
+            time_data(0) = time_data_bound(1) = lastWrite;
+            time_data_bound(0) = time_data_bound(1) = lastWrite;
+            if (timeCounterType==instant)
+            {
+              time_counter(0) = time_data(0);
+              time_counter_bound(0) = time_data_bound(0);
+              time_counter_bound(1) = time_data_bound(1);
+              wtimeCounter=true ;
+            }
+            if (hasTimeInstant) wtimeData=true ;
+          }
+          else if (field->hasTimeCentered)
+          {
             time_data(0) = (lastWrite + lastLastWrite) / 2;
-
-          if (field->getOperationTimeType() == func::CFunctor::instant)
-            time_data_bound(0) = time_data_bound(1) = lastWrite;
-          else if (field->getOperationTimeType() == func::CFunctor::centered)
-          {
             time_data_bound(0) = lastLastWrite;
             time_data_bound(1) = lastWrite;
+            if (timeCounterType==centered)
+            {
+              time_counter(0) = time_data(0) ;
+              time_counter_bound(0) = time_data_bound(0) ;
+              time_counter_bound(1) = time_data_bound(1) ;
+              wtimeCounter=true ;
+            }
+            if (hasTimeCentered) wtimeData=true ;
           }
 
-          if (field->file->time_counter == CFile::time_counter_attr::instant)
-            time_counter(0) = lastWrite;
-          else if (field->file->time_counter == CFile::time_counter_attr::centered)
-            time_counter(0) = (lastWrite + lastLastWrite) / 2;
-          else if (field->file->time_counter == CFile::time_counter_attr::record)
+          if (timeCounterType==record)
+          {
             time_counter(0) = field->getNStep() - 1;
-
-
-          if (field->file->time_counter == CFile::time_counter_attr::instant)
-            time_counter_bound(0) = time_counter_bound(1) = lastWrite;
-          else if (field->file->time_counter == CFile::time_counter_attr::centered)
+            time_counter_bound(0) = time_counter_bound(1) = field->getNStep() - 1;
+            wtimeCounter=true ;
+          }
+
+          if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days)
           {
-            time_counter_bound(0) = lastLastWrite;
-            time_counter_bound(1) = lastWrite;
+            double secByDay=context->getCalendar()->getDayLengthInSeconds() ;
+            time_data/=secByDay;
+            time_data_bound/=secByDay;
+            time_counter/=secByDay;
+            time_counter_bound/=secByDay;
           }
-          else if (field->file->time_counter == CFile::time_counter_attr::record)
-            time_counter_bound(0) = time_counter_bound(1) = field->getNStep() - 1;
         }
 
@@ -2140,15 +2211,25 @@
               case (MULTI_FILE) :
               {
+                 CTimer::get("Files : writing data").resume();
                  SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep() - 1);
+                 CTimer::get("Files : writing data").suspend();
                  if (wtime)
                  {
-                   SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep() - 1);
-                   SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1);
-                   if (field->file->time_counter != CFile::time_counter_attr::none)
+                   CTimer::get("Files : writing time axis").resume();
+                   if ( wtimeData)
                    {
-                     SuperClassWriter::writeData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1);
-                     if (field->file->time_counter != CFile::time_counter_attr::record)
-                       SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1);
+//                     SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep() - 1);
+//                     SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1);
+                       SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot);
+                       SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot);
+                  }
+                   if (wtimeCounter)
+                   {
+//                     SuperClassWriter::writeData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1);
+//                     if (timeCounterType!=record) SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1);
+                     SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1,isRoot);
+                     if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot);
                    }
+                   CTimer::get("Files : writing time axis").suspend();
                  }
                  break;
@@ -2227,5 +2308,5 @@
                       }
                     }
-                  }                
+                  }
                 }
                 else
@@ -2278,16 +2359,29 @@
                 }
 
+
+                CTimer::get("Files : writing data").resume();
                 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_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot);
-                   if (field->file->time_counter != CFile::time_counter_attr::none)
+                CTimer::get("Files : writing data").suspend();
+
+                 if (wtime)
+                 {
+                   CTimer::get("Files : writing time axis").resume();
+                   if ( wtimeData)
                    {
-                     SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1, isRoot);
-                     if (field->file->time_counter != CFile::time_counter_attr::record)
-                       SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot);
+//                     SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep() - 1);
+//                     SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1);
+                     SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot);
+                     SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot);
                    }
-                }
+                   if (wtimeCounter)
+                   {
+//                     SuperClassWriter::writeData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1);
+//                     if (timeCounterType!=record) SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1);
+                     SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1,isRoot);
+                     if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot);
+
+                   }
+                   CTimer::get("Files : writing time axis").suspend();  
+                 }
 
                 break;
@@ -2313,74 +2407,199 @@
       {
          StdOStringStream oss;
-
+         bool createInstantAxis=false ;
+         bool createCenteredAxis=false ;
+         bool createTimeCounterAxis=false ;
+         
          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 axisId ;
+         StdString axisBoundId;
          StdString timeid(getTimeCounterName());
          StdString timeBoundId("axis_nbounds");
 
-         if (field->getOperationTimeType() == func::CFunctor::instant)
-         {
-            axisid = "time_instant";
-            axisBoundId = "time_instant_bounds";
-         }
-
+         StdString strTimeUnits ;
+         if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) strTimeUnits="days since " ;
+         else  strTimeUnits="seconds since " ;
+ 
+         if (field->getOperationTimeType() == func::CFunctor::instant) field->hasTimeInstant = true;
+         if (field->getOperationTimeType() == func::CFunctor::centered) field->hasTimeCentered = true;
+
+
+         if (field->file->time_counter.isEmpty())
+         {
+           if (timeCounterType==none) createTimeCounterAxis=true ;
+           if (field->hasTimeCentered)
+           {
+             timeCounterType=centered ;
+             if (!hasTimeCentered) createCenteredAxis=true ;
+           }
+           if (field->hasTimeInstant)
+           {
+             if (timeCounterType==none) timeCounterType=instant ;
+             if (!hasTimeInstant) createInstantAxis=true ;
+           }
+         }
+         else if (field->file->time_counter==CFile::time_counter_attr::instant)
+         {
+           if (field->hasTimeCentered)
+           {
+             if (!hasTimeCentered) createCenteredAxis=true ;
+           }
+           if (field->hasTimeInstant)
+           {
+             if (timeCounterType==none) createTimeCounterAxis=true ;
+             timeCounterType=instant ;
+             if (!hasTimeInstant) createInstantAxis=true ;
+           }
+         }
+         else if (field->file->time_counter==CFile::time_counter_attr::centered)
+         {
+           if (field->hasTimeCentered)
+           {
+             if (timeCounterType==none) createTimeCounterAxis=true ;
+             timeCounterType=centered ;
+             if (!hasTimeCentered) createCenteredAxis=true ;
+           }
+           if (field->hasTimeInstant)
+           {
+             if (!hasTimeInstant) createInstantAxis=true ;
+           }
+         }
+         else if (field->file->time_counter==CFile::time_counter_attr::instant_exclusive)
+         {
+           if (field->hasTimeCentered)
+           {
+             if (!hasTimeCentered) createCenteredAxis=true ;
+           }
+           if (field->hasTimeInstant)
+           {
+             if (timeCounterType==none) createTimeCounterAxis=true ;
+             timeCounterType=instant ;
+           }
+         }
+         else if (field->file->time_counter==CFile::time_counter_attr::centered_exclusive)
+         {
+           if (field->hasTimeCentered)
+           {
+             if (timeCounterType==none) createTimeCounterAxis=true ;
+             timeCounterType=centered ;
+           }
+           if (field->hasTimeInstant)
+           {
+             if (!hasTimeInstant) createInstantAxis=true ;
+           }
+         }
+         else if (field->file->time_counter==CFile::time_counter_attr::exclusive)
+         {
+           if (field->hasTimeCentered)
+           {
+             if (timeCounterType==none) createTimeCounterAxis=true ;
+             if (timeCounterType==instant) createInstantAxis=true ;
+             timeCounterType=centered ;
+           }
+           if (field->hasTimeInstant)
+           {
+             if (timeCounterType==none)
+             {
+               createTimeCounterAxis=true ;
+               timeCounterType=instant ;
+             }
+             if (timeCounterType==centered)
+             {
+               if (!hasTimeInstant) createInstantAxis=true ;
+             }
+           }
+         }
+         else if (field->file->time_counter==CFile::time_counter_attr::none)
+         {
+           if (field->hasTimeCentered)
+           {
+             if (!hasTimeCentered) createCenteredAxis=true ;
+           }
+           if (field->hasTimeInstant)
+           {
+             if (!hasTimeInstant) createInstantAxis=true ;
+           }
+         }
+         else if (field->file->time_counter==CFile::time_counter_attr::record)
+         {
+           if (timeCounterType==none) createTimeCounterAxis=true ;
+           timeCounterType=record ;
+           if (field->hasTimeCentered)
+           {
+             if (!hasTimeCentered) createCenteredAxis=true ;
+           }
+           if (field->hasTimeInstant)
+           {
+             if (!hasTimeInstant) createInstantAxis=true ;
+           }
+         }
+         
+         if (createInstantAxis)
+         {
+           axisId="time_instant" ;
+           axisBoundId="time_instant_bounds";
+           hasTimeInstant=true ;
+         }
+
+         if (createCenteredAxis)
+         {
+           axisId="time_centered" ;
+           axisBoundId="time_centered_bounds";
+           hasTimeCentered=true ;
+         }
+
+         
          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() ;
+            std::vector<StdString> dims;
+            
+            if (createInstantAxis || createCenteredAxis)
+            {
+              // Adding time_instant or time_centered
               dims.push_back(timeid);
-              dims.push_back(timeBoundId);
-              SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims);
-           }
-
-           if (field->file->time_counter != CFile::time_counter_attr::none)
+              if (!SuperClassWriter::varExist(axisId))
+              {
+                SuperClassWriter::addVariable(axisId, NC_DOUBLE, dims);
+
+                CDate timeOrigin=cal->getTimeOrigin() ;
+                StdOStringStream oss2;
+                StdString strInitdate=oss2.str() ;
+                StdString strTimeOrigin=timeOrigin.toString() ;
+                this->writeTimeAxisAttributes(axisId, cal->getType(),strTimeUnits+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);
+             }
+           }
+
+           if (createTimeCounterAxis)
            {
              // Adding time_counter
-             axisid = getTimeCounterName();
+             axisId = getTimeCounterName();
              axisBoundId = getTimeCounterName() + "_bounds";
              dims.clear();
              dims.push_back(timeid);
-             if (!SuperClassWriter::varExist(axisid))
+             if (!SuperClassWriter::varExist(axisId))
              {
-                SuperClassWriter::addVariable(axisid, NC_DOUBLE, dims);
-                SuperClassWriter::addAttribute("axis", string("T"), &axisid);
-
-                if (field->file->time_counter != CFile::time_counter_attr::record)
+                SuperClassWriter::addVariable(axisId, NC_DOUBLE, dims);
+                SuperClassWriter::addAttribute("axis", string("T"), &axisId);
+
+                if (field->file->time_counter.isEmpty() || 
+                   (field->file->time_counter != CFile::time_counter_attr::record))
                 {
                   CDate timeOrigin = cal->getTimeOrigin();
                   StdString strTimeOrigin = timeOrigin.toString();
 
-                  this->writeTimeAxisAttributes(axisid, cal->getType(),
-                                                StdString("seconds since ").append(strTimeOrigin),
+                  this->writeTimeAxisAttributes(axisId, cal->getType(),
+                                                strTimeUnits+strTimeOrigin,
                                                 strTimeOrigin, axisBoundId);
                 }
@@ -2388,5 +2607,5 @@
 
              // Adding time_counter_bound dimension
-             if (field->file->time_counter != CFile::time_counter_attr::record)
+             if (field->file->time_counter.isEmpty() || (field->file->time_counter != CFile::time_counter_attr::record))
              {
                 if (!SuperClassWriter::varExist(axisBoundId))
@@ -2563,6 +2782,18 @@
            SuperClassWriter::addAttribute("title"      , description);
            SuperClassWriter::addAttribute("Conventions", conventions);
-           SuperClassWriter::addAttribute("production" , production);
-           SuperClassWriter::addAttribute("timeStamp"  , timeStamp);
+           // SuperClassWriter::addAttribute("production" , production);
+
+           StdString timeStampStr ;
+           if (file->time_stamp_name.isEmpty()) timeStampStr="timeStamp" ;
+           else timeStampStr=file->time_stamp_name ;
+           SuperClassWriter::addAttribute(timeStampStr, timeStamp);
+
+           StdString uuidName ;
+           if (file->uuid_name.isEmpty()) uuidName="uuid" ;
+           else uuidName=file->uuid_name ;
+
+           if (file->uuid_format.isEmpty()) SuperClassWriter::addAttribute(uuidName, getUuidStr());
+           else SuperClassWriter::addAttribute(uuidName, getUuidStr(file->uuid_format));
+          
          }
          catch (CNetCdfException& e)
@@ -2616,5 +2847,5 @@
       ///--------------------------------------------------------------
 
-      StdSize CNc4DataOutput::getRecordFromTime(Time time)
+      StdSize CNc4DataOutput::getRecordFromTime(Time time, double factorUnit)
       {
         std::map<Time, StdSize>::const_iterator it = timeToRecordCache.find(time);
@@ -2622,15 +2853,17 @@
         {
           StdString timeAxisBoundsId(getTimeCounterName() + "_bounds");
-          if (!SuperClassWriter::varExist(timeAxisBoundsId))
-            timeAxisBoundsId = "time_instant_bounds";
+          if (!SuperClassWriter::varExist(timeAxisBoundsId)) timeAxisBoundsId = "time_centered_bounds";
+          if (!SuperClassWriter::varExist(timeAxisBoundsId)) timeAxisBoundsId = "time_instant_bounds";
 
           CArray<double,2> timeAxisBounds;
-          SuperClassWriter::getTimeAxisBounds(timeAxisBounds, timeAxisBoundsId, isCollective);
-
+          std::vector<StdSize> dimSize(SuperClassWriter::getDimensions(timeAxisBoundsId)) ;
+          
           StdSize record = 0;
           double dtime(time);
-          for (int n = timeAxisBounds.extent(1) - 1; n >= 0; n--)
+          for (int n = dimSize[0] - 1; n >= 0; n--)
           {
-            if (timeAxisBounds(1, n) < dtime)
+            SuperClassWriter::getTimeAxisBounds(timeAxisBounds, timeAxisBoundsId, isCollective, n);
+            timeAxisBounds*=factorUnit ;
+            if (timeAxisBounds(1, 0) < dtime)
             {
               record = n + 1;
