Index: XIOS/dev/branch_openmp/src/node/grid.hpp
===================================================================
--- XIOS/dev/branch_openmp/src/node/grid.hpp	(revision 1545)
+++ XIOS/dev/branch_openmp/src/node/grid.hpp	(revision 1642)
@@ -19,5 +19,5 @@
 namespace xios {
 
-   /// ////////////////////// Dï¿œï¿œclarations ////////////////////// ///
+   /// ////////////////////// Declarations ////////////////////// ///
 
    class CGridGroup;
@@ -91,7 +91,9 @@
          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;
+         template <int n>
+         void maskField(const CArray<double,n>& field, CArray<double,1>& stored) const;
          template <int n>
          void outputField(const CArray<double,1>& stored, CArray<double,n>& field) const;  
@@ -203,9 +205,7 @@
          bool hasTransform();
          size_t getGlobalWrittenSize(void) ;
-         void getLocalMask(CArray<bool,1>& localMask) ;
-         template<int N>
-         void getLocalMask(const CArray<bool,N>& gridMask, CArray<bool,1>& localMask) ;
       public:
          CArray<int, 1> storeIndex_client;
+         CArray<bool, 1> storeMask_client;
 
 /** Map containing indexes that will be sent in sendIndex(). */
@@ -247,4 +247,5 @@
          CArray<size_t,1> indexFromClients;
 
+         bool hasMask(void) const;
          void checkMask(void);
          void createMask(void);
@@ -273,4 +274,5 @@
         void restoreField_arr(const CArray<double, 1>& stored, double* const data) const;
         void uncompressField_arr(const double* const data, CArray<double, 1>& outData) const;
+        void maskField_arr(const double* const data, CArray<double, 1>& stored) const;
 
         void setVirtualDomainGroup(CDomainGroup* newVDomainGroup);
@@ -372,4 +374,5 @@
    template <int n>
    void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored) const
+   TRY
    {
 //#ifdef __XIOS_DEBUG
@@ -383,7 +386,23 @@
       this->storeField_arr(field.dataFirst(), stored);
    }
+   CATCH
+
+   template <int n>
+   void CGrid::maskField(const CArray<double,n>& field, CArray<double,1>& stored) const
+   {
+//#ifdef __XIOS_DEBUG
+      if (this->getDataSize() != field.numElements())
+         ERROR("void CGrid::inputField(const  CArray<double,n>& field, CArray<double,1>& stored) const",
+                << "[ Awaiting data of size = " << this->getDataSize() << ", "
+                << "Received data size = "      << field.numElements() << " ] "
+                << "The data array does not have the right size! "
+                << "Grid = " << this->getId())
+//#endif
+      this->maskField_arr(field.dataFirst(), stored);
+   }
 
    template <int n>
    void CGrid::outputField(const CArray<double,1>& stored, CArray<double,n>& field) const
+   TRY
    {
 //#ifdef __XIOS_DEBUG
@@ -397,4 +416,5 @@
       this->restoreField_arr(stored, field.dataFirst());
    }
+   CATCH
 
    /*!
@@ -406,7 +426,9 @@
    template <int N>
    void CGrid::uncompressField(const CArray<double,N>& data, CArray<double,1>& outData) const
+   TRY
    {      
      uncompressField_arr(data.dataFirst(), outData);
    }
+   CATCH
 
    template<int N>
@@ -416,4 +438,5 @@
                              const CArray<int,1>& axisDomainOrder,
                              bool createMask)
+   TRY
    {
      int idx = 0;
@@ -510,6 +533,6 @@
       ++idx;
     }
-
-   }
+   }
+   CATCH_DUMP_ATTR
 
    template<int N>
@@ -517,4 +540,5 @@
                                   const std::vector<int>& eachDimSize,
                                   bool newValue)
+   TRY
    {
       if (N != eachDimSize.size())
@@ -531,4 +555,5 @@
       gridMask = newValue;
    }
+   CATCH_DUMP_ATTR
                                  
 
@@ -540,4 +565,5 @@
    template<int N>
    void CGrid::modifyGridMask(CArray<bool,N>& gridMask, const CArray<int,1>& indexToModify, bool valueToModify)
+   TRY
    {     
      int num = indexToModify.numElements();
@@ -547,48 +573,9 @@
      }
    }
+   CATCH_DUMP_ATTR
+
    ///--------------------------------------------------------------
 
 
-/*!
-  A grid can have multiple dimension, so can its mask in the form of multi-dimension array.
-It's not a good idea to store all multi-dimension arrays corresponding to each mask.
-One of the ways is to convert this array into 1-dimension one and every process is taken place on it.
-  \param [in] multi-dimension array grid mask
-*/
-template<int N>
-void CGrid::getLocalMask(const CArray<bool,N>& gridMask, CArray<bool,1>& localMask)
-{
-  if (gridMask.isEmpty()) return ;
-  int dim = gridMask.dimensions();
-  std::vector<int> dimensionSizes(dim);
-  for (int i = 0; i < dim; ++i) dimensionSizes[i] = gridMask.extent(i);
-
-  std::vector<int> idxLoop(dim,0);
-  int ssize = gridMask.numElements(), idx = 0;
-  localMask.resize(ssize);
-  while (idx < ssize)
-  {
-    for (int i = 0; i < dim-1; ++i)
-    {
-      if (idxLoop[i] == dimensionSizes[i])
-      {
-        idxLoop[i] = 0;
-        ++idxLoop[i+1];
-      }
-    }
-
-    int maskIndex = idxLoop[0];
-    int mulDim = 1;
-    for (int k = 1; k < dim; ++k)
-    {
-      mulDim *= dimensionSizes[k-1];
-      maskIndex += idxLoop[k]*mulDim;
-    }
-    localMask(maskIndex) = *(gridMask.dataFirst()+maskIndex);
-
-    ++idxLoop[0];
-    ++idx;
-  }
-}
 
    // Declare/Define CGridGroup and CGridDefinition
