Index: /XIOS/dev/XIOS_DEV_CMIP6/src/config/grid_attribute.conf
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/config/grid_attribute.conf	(revision 1249)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/config/grid_attribute.conf	(revision 1250)
@@ -2,12 +2,14 @@
 DECLARE_ATTRIBUTE(StdString, description)
 
-DECLARE_ARRAY(bool, 1, mask_1d)
-DECLARE_ARRAY(bool, 2, mask_2d)
-DECLARE_ARRAY(bool, 3, mask_3d)
-DECLARE_ARRAY(bool, 4, mask_4d)
-DECLARE_ARRAY(bool, 5, mask_5d)
-DECLARE_ARRAY(bool, 6, mask_6d)
-DECLARE_ARRAY(bool, 7, mask_7d)
+DECLARE_ARRAY(bool, 1, mask_1d, false)
+DECLARE_ARRAY(bool, 2, mask_2d, false)
+DECLARE_ARRAY(bool, 3, mask_3d, false)
+DECLARE_ARRAY(bool, 4, mask_4d, false)
+DECLARE_ARRAY(bool, 5, mask_5d, false)
+DECLARE_ARRAY(bool, 6, mask_6d, false)
+DECLARE_ARRAY(bool, 7, mask_7d, false)
 
+// Meaningless, only server for coherent purpose (for scalar grid)
+DECLARE_ARRAY(bool, 1, mask_0d, false)
 
 // An array contains order of axis and domains composing of the grid
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/distribution_client.cpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/distribution_client.cpp	(revision 1249)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/distribution_client.cpp	(revision 1250)
@@ -478,4 +478,5 @@
   localDataIndex_.resize(indexLocalDataOnClientCount);
   localMaskIndex_.resize(indexSend2ServerCount);
+  localMaskedDataIndex_.resize(indexSend2ServerCount);
   globalDataIndex_.rehash(std::ceil(indexLocalDataOnClientCount/globalDataIndex_.max_load_factor())); //globalLocalDataSendToServerMap_.reserve(indexSend2ServerCount);
   globalLocalDataSendToServerMap_.rehash(std::ceil(indexSend2ServerCount/globalLocalDataSendToServerMap_.max_load_factor())); //globalLocalDataSendToServerMap_.reserve(indexSend2ServerCount);
@@ -561,4 +562,5 @@
               globalLocalDataSendToServerMap_[globalIndex] = indexLocalDataOnClientCount;
               localMaskIndex_[indexSend2ServerCount] = gridMaskIndex;
+              localMaskedDataIndex_[indexSend2ServerCount] = indexLocalDataOnClientCount;
               ++indexSend2ServerCount;
             }
@@ -653,3 +655,12 @@
 }
 
+/*!
+  Return local mask index of client
+*/
+const std::vector<int>& CDistributionClient::getLocalMaskedDataIndexOnClient()
+{
+  if (!isComputed_) createGlobalIndexSendToServer();
+  return localMaskedDataIndex_;
+}
+
 } // namespace xios
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/distribution_client.hpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/distribution_client.hpp	(revision 1249)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/distribution_client.hpp	(revision 1250)
@@ -45,4 +45,5 @@
     GlobalLocalDataMap& getGlobalDataIndexOnClient();
     const std::vector<int>& getLocalMaskIndexOnClient();
+    const std::vector<int>& getLocalMaskedDataIndexOnClient();
 
     std::vector<int> getNGlob() { return nGlob_; }
@@ -82,4 +83,5 @@
     std::vector<int> localDataIndex_;
     std::vector<int> localMaskIndex_;
+    std::vector<int> localMaskedDataIndex_;
 
   private:
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/filter/source_filter.cpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/filter/source_filter.cpp	(revision 1249)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/filter/source_filter.cpp	(revision 1250)
@@ -32,6 +32,16 @@
     packet->status = CDataPacket::NO_ERROR;
 
-    packet->data.resize(grid->storeIndex_client.numElements());
-    grid->inputField(data, packet->data) ;
+    packet->data.resize(grid->storeIndex_client.numElements());    
+    
+    if (compression)
+    {
+      packet->data = defaultValue;
+      grid->uncompressField(data, packet->data);    
+    }
+    else
+      grid->inputField(data, packet->data);
+
+    
+    
     // if (compression) grid->inputField(data, packet->data) ;
     // else
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/field.cpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/field.cpp	(revision 1249)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/field.cpp	(revision 1250)
@@ -950,5 +950,5 @@
      {
         if (!instantDataFilter)
-          instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid,false));
+          instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid,true));
 
              // If the field data is to be read by the client or/and written to a file
@@ -965,5 +965,5 @@
      {
        if (!instantDataFilter)
-         instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, false));
+         instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true));
 
              // If the field data is to be read by the client or/and written to a file
@@ -1016,5 +1016,5 @@
          {
             if (check_if_active.isEmpty()) check_if_active = false; 
-            instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, NoneDu, false,
+            instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, false, NoneDu, false,
                                                                                                         detectMissingValues, defaultValue));
          }
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.cpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.cpp	(revision 1249)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.cpp	(revision 1250)
@@ -89,5 +89,5 @@
      {
        std::vector<int> dataNindex = clientDistribution_->getDataNIndex();
-       for (int i = 0; i < dataNindex.size(); ++i) retvalue *= dataNindex[i];
+       for (int i = 0; i < dataNindex.size(); ++i) retvalue *= dataNindex[i];       
      }
      return retvalue;
@@ -339,5 +339,5 @@
 
      // TODO: Transfer grid attributes
-     if (!context->hasClient && context->hasServer) this->createMask();
+     //if (!context->hasClient && context->hasServer) this->createMask();
      this->computeIndex();
 
@@ -447,4 +447,7 @@
 
       switch (dim) {
+        case 0:
+          modifyGridMask(mask_0d, indexToModify, modifyValue);
+          break;
         case 1:
           modifyGridMask(mask_1d, indexToModify, modifyValue);
@@ -485,4 +488,7 @@
 
       switch (dim) {
+        case 0:
+          modifyGridMaskSize(mask_0d, newDimensionSize, newValue);
+          break;
         case 1:
           modifyGridMaskSize(mask_1d, newDimensionSize, newValue);
@@ -1253,4 +1259,12 @@
    }
 
+   void CGrid::uncompressField_arr(const double* const data, CArray<double, 1>& out) const
+   {
+      const std::vector<int>& localMaskedDataIndex = clientDistribution_->getLocalMaskedDataIndexOnClient();
+      const int size = localMaskedDataIndex.size();
+      
+      for(int i = 0; i < size; ++i) out(localMaskedDataIndex[i]) = data[i];
+   }
+
   void CGrid::computeClientIndexScalarGrid()
   {
@@ -1261,4 +1275,8 @@
       CContextClient* client = (context->hasServer) ? (context->hasClient ? context->clientPrimServer[p] : context->client) 
                                                     : context->client;
+
+      int rank = client->clientRank;
+
+      clientDistribution_ = new CDistributionClient(rank, this);
 
       storeIndex_client.resize(1);
@@ -1688,42 +1706,51 @@
           }
           else // scalar
-          { 
+          {  
           }
         }
         
-        modifyMaskSize(nSize, true);
+        if (nSize.empty()) // Scalar grid
+        {
+          nBegin.push_back(0);
+          nSize.push_back(1);
+          nBeginGlobal.push_back(0);              
+          nGlob.push_back(1);  
+        }
+
+        modifyMaskSize(nSize, false);
+
         // These below codes are reserved for future
-        // CDistributionServer srvDist(server->intraCommRank, nBegin, nSize, nBeginGlobal, nGlob); 
-        // map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient.begin(),
-        //                                        ite = outGlobalIndexFromClient.end(), it;  
-        // const CDistributionServer::GlobalLocalMap&  globalLocalMask = srvDist.getGlobalLocalIndex();
-        // CDistributionServer::GlobalLocalMap::const_iterator itSrv;
-        // size_t nb = 0;
-        // for (it = itb; it != ite; ++it)
-        // {
-        //   CArray<size_t,1>& globalInd = it->second;
-        //   for (size_t idx = 0; idx < globalInd.numElements(); ++idx)
-        //   {
-        //     if (globalLocalMask.end() != globalLocalMask.find(globalInd(idx))) ++nb;
-        //   }
-        // }
+        CDistributionServer srvDist(server->intraCommRank, nBegin, nSize, nBeginGlobal, nGlob); 
+        map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient.begin(),
+                                               ite = outGlobalIndexFromClient.end(), it;  
+        const CDistributionServer::GlobalLocalMap&  globalLocalMask = srvDist.getGlobalLocalIndex();
+        CDistributionServer::GlobalLocalMap::const_iterator itSrv;
+        size_t nb = 0;
+        for (it = itb; it != ite; ++it)
+        {
+          CArray<size_t,1>& globalInd = it->second;
+          for (size_t idx = 0; idx < globalInd.numElements(); ++idx)
+          {
+            if (globalLocalMask.end() != globalLocalMask.find(globalInd(idx))) ++nb;
+          }
+        }
         
-        // CArray<int,1> indexToModify(nb);
-        // nb = 0;    
-        // for (it = itb; it != ite; ++it)
-        // {
-        //   CArray<size_t,1>& globalInd = it->second;
-        //   for (size_t idx = 0; idx < globalInd.numElements(); ++idx)
-        //   {
-        //     itSrv = globalLocalMask.find(globalInd(idx));
-        //     if (globalLocalMask.end() != itSrv) 
-        //     {
-        //       indexToModify(nb) = itSrv->second;
-        //       ++nb;
-        //     }
-        //   }
-        // }
-
-        // modifyMask(indexToModify, true);
+        CArray<int,1> indexToModify(nb);
+        nb = 0;    
+        for (it = itb; it != ite; ++it)
+        {
+          CArray<size_t,1>& globalInd = it->second;
+          for (size_t idx = 0; idx < globalInd.numElements(); ++idx)
+          {
+            itSrv = globalLocalMask.find(globalInd(idx));
+            if (globalLocalMask.end() != itSrv) 
+            {
+              indexToModify(nb) = itSrv->second;
+              ++nb;
+            }
+          }
+        }
+
+        modifyMask(indexToModify, true);
       }
 
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.hpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.hpp	(revision 1249)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.hpp	(revision 1250)
@@ -95,5 +95,7 @@
          void inputField(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;      
+         void outputField(const CArray<double,1>& stored, CArray<double,n>& field) const;  
+         template <int n>
+         void uncompressField(const CArray<double,n>& data, CArray<double,1>& outData) const; 
 
          virtual void parse(xml::CXMLNode& node);
@@ -252,4 +254,5 @@
         void storeField_arr(const double* const data, CArray<double, 1>& stored) const;
         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 setVirtualDomainGroup(CDomainGroup* newVDomainGroup);
@@ -353,4 +356,16 @@
                 << "Grid = " << this->GetName())
       this->restoreField_arr(stored, field.dataFirst());
+   }
+
+   /*!
+     This function removes the effect of mask on received data on the server.
+     This function only serve for the checking purpose. TODO: Something must be done to seperate mask and data_index from each other in received data
+     \data data received data with masking effect on the server
+     \outData data without masking effect
+   */
+   template <int N>
+   void CGrid::uncompressField(const CArray<double,N>& data, CArray<double,1>& outData) const
+   {      
+     uncompressField_arr(data.dataFirst(), outData);
    }
 
