Index: XIOS/trunk/bld.cfg
===================================================================
--- XIOS/trunk/bld.cfg	(revision 991)
+++ XIOS/trunk/bld.cfg	(revision 993)
@@ -32,7 +32,9 @@
 bld::target libxios.a 
 #bld::target generate_fortran_interface.exe 
-bld::target xios_server.exe test_remap.exe
-bld::target test_new_features.exe test_unstruct_complete.exe 
-bld::target test_client.exe test_complete.exe
+bld::target xios_server.exe 
+#test_remap.exe
+bld::target test_regular.exe
+#bld::target test_new_features.exe test_unstruct_complete.exe 
+#bld::target test_client.exe test_complete.exe
 bld::exe_dep
 
Index: XIOS/trunk/src/io/nc4_data_output.cpp
===================================================================
--- XIOS/trunk/src/io/nc4_data_output.cpp	(revision 991)
+++ XIOS/trunk/src/io/nc4_data_output.cpp	(revision 993)
@@ -1458,126 +1458,127 @@
       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();
+
+        CDomain* domain = CDomain::get(domainList[idxDomain]);
+
+        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))
+          {
+            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 */
-           }
-         }
+          }
+        }
 
 /*
@@ -1589,51 +1590,51 @@
                              : 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();
+        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
-         {
+          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);
 
@@ -1650,5 +1651,20 @@
                  ("units", field->unit.getValue(), &fieldid);
 
-            if (!field->valid_min.isEmpty())
+           // Ugrid field attributes "mesh" and "location"
+           if (!SuperClassWriter::useCFConvention)
+           {
+             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);
Index: XIOS/trunk/src/node/mesh.cpp
===================================================================
--- XIOS/trunk/src/node/mesh.cpp	(revision 991)
+++ XIOS/trunk/src/node/mesh.cpp	(revision 993)
@@ -11,14 +11,14 @@
 /// ////////////////////// DÃ©finitions ////////////////////// ///
 
-  CMesh::CMesh(void) :  nbNodesGlo{0}, nbEdgesGlo{0}
-            ,  node_start{0}, node_count{0}
-            ,  edge_start{0}, edge_count{0}
-            ,  nbFaces_{0}, nbNodes_{0}, nbEdges_{0}
-            ,  nodesAreWritten{false}, edgesAreWritten{false}, facesAreWritten{false}
+  CMesh::CMesh(void) :  nbNodesGlo(0), nbEdgesGlo(0)
+            ,  node_start(0), node_count(0)
+            ,  edge_start(0), edge_count(0)
+            ,  nbFaces_(0), nbNodes_(0), nbEdges_(0)
+            ,  nodesAreWritten(false), edgesAreWritten(false), facesAreWritten(false)
             ,  node_lon(), node_lat()
             ,  edge_lon(), edge_lat(), edge_nodes()
             ,  face_lon(), face_lat()
             ,  face_nodes()
-            ,  pNodeGlobalIndex{NULL}, pEdgeGlobalIndex{NULL}
+            ,  pNodeGlobalIndex(NULL), pEdgeGlobalIndex(NULL)
   {
   }
Index: XIOS/trunk/src/test/test_regular.f90
===================================================================
--- XIOS/trunk/src/test/test_regular.f90	(revision 991)
+++ XIOS/trunk/src/test/test_regular.f90	(revision 993)
@@ -18,8 +18,8 @@
   INTEGER :: comm  
   INTEGER :: ierr
-  INTEGER :: size, rank
+  INTEGER :: sizeComm, rank    ! SIZE is a fortran function
 
-  INTEGER :: nlon = 100 
-  INTEGER :: nlat = 100
+  INTEGER :: nlon = 5 !100 
+  INTEGER :: nlat = 5 !100
   INTEGER :: ncell 
   INTEGER :: ilat, ilon, ind
@@ -94,19 +94,19 @@
 
   CALL MPI_COMM_RANK(comm,rank,ierr)
-  CALL MPI_COMM_SIZE(comm,size,ierr)
+  CALL MPI_COMM_SIZE(comm,sizeComm,ierr)
 
-  IF (MOD(ncell, size) == 0) THEN
-    ni = ncell/size
+  IF (MOD(ncell, sizeComm) == 0) THEN
+    ni = ncell/sizeComm
     ibegin = rank*ni
   ELSE
-    IF (rank < MOD(ncell, size)) THEN
-      ni = ncell/size + 1
-      ibegin = rank*(ncell/size + 1)
+    IF (rank < MOD(ncell, sizeComm)) THEN
+      ni = ncell/sizeComm + 1
+      ibegin = rank*(ncell/sizeComm + 1)
     ELSE
-      ni = ncell/size
-      IF (rank == MOD(ncell, size)) THEN
-        ibegin = rank*(ncell/size + 1)
+      ni = ncell/sizeComm
+      IF (rank == MOD(ncell, sizeComm)) THEN
+        ibegin = rank*(ncell/sizeComm + 1)
       ELSE
-        ibegin = MOD(ncell,size)*(ncell/size + 1) + (rank-MOD(ncell,size))*ncell/size
+        ibegin = MOD(ncell,sizeComm)*(ncell/sizeComm + 1) + (rank-MOD(ncell,sizeComm))*ncell/sizeComm
       END IF
     END IF
@@ -118,8 +118,8 @@
   ALLOCATE(bounds_lat(4,ni))
   ALLOCATE(field_temp(ni,ntime)) 
-  lon = lon_glo(1+ibegin:1+ibegin+ni)
-  lat = lat_glo(1+ibegin:1+ibegin+ni)
-  bounds_lon(:,:) = bounds_lon_glo(:,1+ibegin:1+ibegin+ni)
-  bounds_lat(:,:) = bounds_lat_glo(:,1+ibegin:1+ibegin+ni)
+  lon = lon_glo(1+ibegin:ibegin+ni)
+  lat = lat_glo(1+ibegin:ibegin+ni)
+  bounds_lon(:,:) = bounds_lon_glo(:,1+ibegin:ibegin+ni)
+  bounds_lat(:,:) = bounds_lat_glo(:,1+ibegin:ibegin+ni)
   field_temp(:,:) = rank
 
