Index: /XIOS/trunk/src/distribution_client.cpp
===================================================================
--- /XIOS/trunk/src/distribution_client.cpp	(revision 1563)
+++ /XIOS/trunk/src/distribution_client.cpp	(revision 1564)
@@ -68,23 +68,23 @@
       break;
     case 1:
-      readGridMaskInfo(grid->mask_1d);
+      if (!grid->mask_1d.isEmpty()) readGridMaskInfo(grid->mask_1d);
       break;
     case 2:
-      readGridMaskInfo(grid->mask_2d);
+      if (!grid->mask_2d.isEmpty()) readGridMaskInfo(grid->mask_2d);
       break;
     case 3:
-      readGridMaskInfo(grid->mask_3d);
+      if (!grid->mask_3d.isEmpty()) readGridMaskInfo(grid->mask_3d);
       break;
     case 4:
-      readGridMaskInfo(grid->mask_4d);
+      if (!grid->mask_4d.isEmpty()) readGridMaskInfo(grid->mask_4d);
       break;
     case 5:
-      readGridMaskInfo(grid->mask_5d);
+      if (!grid->mask_5d.isEmpty()) readGridMaskInfo(grid->mask_5d);
       break;
     case 6:
-      readGridMaskInfo(grid->mask_6d);
+      if (!grid->mask_6d.isEmpty()) readGridMaskInfo(grid->mask_6d);
       break;
     case 7:
-      readGridMaskInfo(grid->mask_7d);
+      if (!grid->mask_7d.isEmpty()) readGridMaskInfo(grid->mask_7d);
       break;
     default:
@@ -411,4 +411,5 @@
   size_t idx = 0, indexLocalDataOnClientCount = 0;
   size_t ssize = 1;
+
   for (int i = 0; i < numElement_; ++i) ssize *= eachElementSize[i];
   while (idx < ssize)
@@ -436,13 +437,35 @@
       int gridMaskIndex = 0;
       currentIndex[0] = elementLocalIndex_[0](i);
-      for (int k = 0; k < this->numElement_; ++k)
-      {
-        gridMaskIndex += (currentIndex[k])*elementNLocal_[k];
-      }
-
-      if (gridMask_(gridMaskIndex))
-      {
-        ++indexLocalDataOnClientCount;
-      }
+
+      // If defined, iterate on grid mask
+      if (!gridMask_.isEmpty())
+      {
+        for (int k = 0; k < this->numElement_; ++k)
+        {
+          gridMaskIndex += (currentIndex[k])*elementNLocal_[k];
+        }
+        if (gridMask_(gridMaskIndex)) ++indexLocalDataOnClientCount;
+      }
+      // If grid mask is not defined, iterate on elements' mask
+      else
+      {
+        bool maskTmp = true;
+        int idxDomain = 0, idxAxis = 0;
+        for (int elem = 0; elem < numElement_; ++elem)
+        {
+          if (2 == axisDomainOrder_(elem))
+          {
+            maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]);
+            ++idxDomain;
+          }
+          else if (1 == axisDomainOrder_(elem))
+          {
+            maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]);
+            ++idxAxis;
+          }
+        }
+        if (maskTmp) ++indexLocalDataOnClientCount;
+      }
+
     }
     idxLoop[0] += innerLoopSize;
@@ -518,5 +541,30 @@
           }
 
-          if (gridMask_(gridMaskIndex))
+          bool maskTmp = true;
+          // If defined, apply grid mask
+         if (!gridMask_.isEmpty())
+          {
+            maskTmp =  gridMask_(gridMaskIndex);
+          }
+          // If grid mask is not defined, apply elements' mask
+          else
+          {
+            int idxDomain = 0, idxAxis = 0;
+            for (int elem = 0; elem < numElement_; ++elem)
+            {
+              if (2 == axisDomainOrder_(elem))
+              {
+                maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]);
+                ++idxDomain;
+              }
+              else if (1 == axisDomainOrder_(elem))
+              {
+                maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]);
+                ++idxAxis;
+              }
+            }
+          }
+
+          if (maskTmp)
           {
             size_t globalIndex = 0;
Index: /XIOS/trunk/src/node/grid.hpp
===================================================================
--- /XIOS/trunk/src/node/grid.hpp	(revision 1563)
+++ /XIOS/trunk/src/node/grid.hpp	(revision 1564)
@@ -19,5 +19,5 @@
 namespace xios {
 
-   /// ////////////////////// Dï¿œï¿œclarations ////////////////////// ///
+   /// ////////////////////// Declarations ////////////////////// ///
 
    class CGridGroup;
@@ -91,5 +91,5 @@
          StdSize  getDataSize(void) const;
 
-         /// Entrï¿œï¿œes-sorties de champs
+         /// Entrees-sorties de champs
          template <int n>
          void inputField(const CArray<double,n>& field, CArray<double,1>& stored) const;
@@ -417,98 +417,101 @@
                              bool createMask)
    {
-     int idx = 0;
-     int numElement = axisDomainOrder.numElements();
-     int dim = domainMasks.size() * 2 + axisMasks.size();
-     std::vector<CDomain*> domainP = this->getDomains();
-     std::vector<CAxis*> axisP = this->getAxis();
-
-     std::vector<int> idxLoop(dim,0), indexMap(numElement), eachDimSize(dim);
-     std::vector<int> currentIndex(dim);
-     int idxDomain = 0, idxAxis = 0;
-    for (int i = 0; i < numElement; ++i)
-    {
-      indexMap[i] = idx;
-      if (2 == axisDomainOrder(i)) {
-          eachDimSize[indexMap[i]]   = domainP[idxDomain]->ni;
-          eachDimSize[indexMap[i]+1] = domainP[idxDomain]->nj;
-          idx += 2; ++idxDomain;
+     if (!gridMask.isEmpty() || createMask)
+     {
+       int idx = 0;
+       int numElement = axisDomainOrder.numElements();
+       int dim = domainMasks.size() * 2 + axisMasks.size();
+       std::vector<CDomain*> domainP = this->getDomains();
+       std::vector<CAxis*> axisP = this->getAxis();
+
+       std::vector<int> idxLoop(dim,0), indexMap(numElement), eachDimSize(dim);
+       std::vector<int> currentIndex(dim);
+       int idxDomain = 0, idxAxis = 0;
+      for (int i = 0; i < numElement; ++i)
+      {
+        indexMap[i] = idx;
+        if (2 == axisDomainOrder(i)) {
+            eachDimSize[indexMap[i]]   = domainP[idxDomain]->ni;
+            eachDimSize[indexMap[i]+1] = domainP[idxDomain]->nj;
+            idx += 2; ++idxDomain;
+        }
+        else if (1 == axisDomainOrder(i)) {
+  //        eachDimSize[indexMap[i]] = axisMasks[idxAxis]->numElements();
+          eachDimSize[indexMap[i]] = axisP[idxAxis]->n;
+          ++idx; ++idxAxis;
+        }
+        else {};
       }
-      else if (1 == axisDomainOrder(i)) {
-//        eachDimSize[indexMap[i]] = axisMasks[idxAxis]->numElements();
-        eachDimSize[indexMap[i]] = axisP[idxAxis]->n;
-        ++idx; ++idxAxis;
-      }
-      else {};
-    }
-
-    if (!gridMask.isEmpty() && !createMask)
-    {
-      for (int i = 0; i < dim; ++i)
+
+//      if (!gridMask.isEmpty() && !createMask)
+      if (!createMask)
       {
-        if (gridMask.extent(i) != eachDimSize[i])
-          ERROR("CGrid::checkMask(void)",
-                << "The mask has one dimension whose size is different from the one of the local grid." << std::endl
-                << "Local size of dimension " << i << " is " << eachDimSize[i] << "." << std::endl
-                << "Mask size for dimension " << i << " is " << gridMask.extent(i) << "." << std::endl
-                << "Grid = " << this->getId())
-      }
-    }
-    else {
-        CArrayBoolTraits<CArray<bool,N> >::resizeArray(gridMask,eachDimSize);
-        gridMask = true;
-    }
-
-    int ssize = gridMask.numElements();
-    idx = 0;
-    while (idx < ssize)
-    {
-      for (int i = 0; i < dim-1; ++i)
-      {
-        if (idxLoop[i] == eachDimSize[i])
+        for (int i = 0; i < dim; ++i)
         {
-          idxLoop[i] = 0;
-          ++idxLoop[i+1];
+          if (gridMask.extent(i) != eachDimSize[i])
+            ERROR("CGrid::checkMask(void)",
+                  << "The mask has one dimension whose size is different from the one of the local grid." << std::endl
+                  << "Local size of dimension " << i << " is " << eachDimSize[i] << "." << std::endl
+                  << "Mask size for dimension " << i << " is " << gridMask.extent(i) << "." << std::endl
+                  << "Grid = " << this->getId())
         }
       }
-
-      // Find out outer index
-      idxDomain = idxAxis = 0;
-      bool maskValue = true;
-      for (int i = 0; i < numElement; ++i)
+      else {
+          CArrayBoolTraits<CArray<bool,N> >::resizeArray(gridMask,eachDimSize);
+          gridMask = true;
+      }
+
+      int ssize = gridMask.numElements();
+      idx = 0;
+      while (idx < ssize)
       {
-        if (2 == axisDomainOrder(i))
+        for (int i = 0; i < dim-1; ++i)
         {
-          int idxTmp = idxLoop[indexMap[i]] + idxLoop[indexMap[i]+1] * eachDimSize[indexMap[i]];
-          if (idxTmp < (*domainMasks[idxDomain]).numElements())
-            maskValue = maskValue && (*domainMasks[idxDomain])(idxTmp);
-          else
-            maskValue = false;
-          ++idxDomain;
+          if (idxLoop[i] == eachDimSize[i])
+          {
+            idxLoop[i] = 0;
+            ++idxLoop[i+1];
+          }
         }
-        else if (1 == axisDomainOrder(i))
+
+        // Find out outer index
+        idxDomain = idxAxis = 0;
+        bool maskValue = true;
+        for (int i = 0; i < numElement; ++i)
         {
-          int idxTmp = idxLoop[indexMap[i]];
-          if (idxTmp < (*axisMasks[idxAxis]).numElements())
-            maskValue = maskValue && (*axisMasks[idxAxis])(idxTmp);
-          else
-            maskValue = false;
-
-          ++idxAxis;
+          if (2 == axisDomainOrder(i))
+          {
+            int idxTmp = idxLoop[indexMap[i]] + idxLoop[indexMap[i]+1] * eachDimSize[indexMap[i]];
+            if (idxTmp < (*domainMasks[idxDomain]).numElements())
+              maskValue = maskValue && (*domainMasks[idxDomain])(idxTmp);
+            else
+              maskValue = false;
+            ++idxDomain;
+          }
+          else if (1 == axisDomainOrder(i))
+          {
+            int idxTmp = idxLoop[indexMap[i]];
+            if (idxTmp < (*axisMasks[idxAxis]).numElements())
+              maskValue = maskValue && (*axisMasks[idxAxis])(idxTmp);
+            else
+              maskValue = false;
+
+            ++idxAxis;
+          }
         }
+
+        int maskIndex = idxLoop[0];
+        int mulDim = 1;
+        for (int k = 1; k < dim; ++k)
+        {
+          mulDim *= eachDimSize[k-1];
+          maskIndex += idxLoop[k]*mulDim;
+        }
+        *(gridMask.dataFirst()+maskIndex) &= maskValue;
+
+        ++idxLoop[0];
+        ++idx;
       }
-
-      int maskIndex = idxLoop[0];
-      int mulDim = 1;
-      for (int k = 1; k < dim; ++k)
-      {
-        mulDim *= eachDimSize[k-1];
-        maskIndex += idxLoop[k]*mulDim;
-      }
-      *(gridMask.dataFirst()+maskIndex) &= maskValue;
-
-      ++idxLoop[0];
-      ++idx;
-    }
-
+     }
    }
 
