Index: XIOS/dev/XIOS_DEV_CMIP6/src/transformation/generic_algorithm_transformation.cpp
===================================================================
--- XIOS/dev/XIOS_DEV_CMIP6/src/transformation/generic_algorithm_transformation.cpp	(revision 1419)
+++ XIOS/dev/XIOS_DEV_CMIP6/src/transformation/generic_algorithm_transformation.cpp	(revision 1420)
@@ -995,6 +995,9 @@
   gridSrc->getLocalMask(localMaskOnSrcGrid) ;
 // intermediate grid, mask is not initialized => set up mask to true
-  if (localMaskOnSrcGrid.isEmpty()) localMaskOnSrcGrid.resize(nlocalIndexSrc) ;
-  localMaskOnSrcGrid=true ;
+  if (localMaskOnSrcGrid.isEmpty())
+  {
+    localMaskOnSrcGrid.resize(nlocalIndexSrc) ;
+    localMaskOnSrcGrid=true ;
+  }
   
 
@@ -1024,7 +1027,7 @@
   int currentInd ;
   int t=0 ;  
-
-  
-  nonDistributedrecursiveFunct(nElement-1,elementPositionInGrid,maskSrc,maskDst, srcInd, nIndexSrc, t, dstIndWeight,  
+  int srcIndCompressed=0 ;
+  
+  nonDistributedrecursiveFunct(nElement-1,true,elementPositionInGrid,maskSrc,maskDst, srcInd, srcIndCompressed, nIndexSrc, t, dstIndWeight,  
                                currentInd,localSrc,localDst,weight, localMaskOnSrcGrid, localMaskOnGridDest );
                
@@ -1032,5 +1035,5 @@
 
 
-void CGenericAlgorithmTransformation::nonDistributedrecursiveFunct(int currentPos, int elementPositionInGrid, vector< CArray<bool,1>* >& maskSrc, vector< CArray<bool,1>* >& maskDst, int& srcInd, vector<int>& nIndexSrc, int& t, vector<vector<vector<pair<int,double> > > >& dstIndWeight, int currentInd,
+void CGenericAlgorithmTransformation::nonDistributedrecursiveFunct(int currentPos, bool masked, int elementPositionInGrid, vector< CArray<bool,1>* >& maskSrc, vector< CArray<bool,1>* >& maskDst, int& srcInd, int& srcIndCompressed, vector<int>& nIndexSrc, int& t, vector<vector<vector<pair<int,double> > > >& dstIndWeight, int currentInd,
                     vector<int>& localSrc, vector<int>& localDst, vector<double>& weight,  CArray<bool,1>& localMaskOnGridSrc, vector<bool>& localMaskOnGridDest )
 {
@@ -1043,8 +1046,6 @@
       for(int i=0;i<nIndexSrc[currentPos];i++)
       {
-        if (mask(i))
-        {
-          nonDistributedrecursiveFunct(currentPos-1, elementPositionInGrid, maskSrc, maskDst, srcInd, nIndexSrc, t, dstIndWeight, currentInd, localSrc, localDst, weight, localMaskOnGridSrc, localMaskOnGridDest) ;
-        }
+        if (!mask(i)) masked=false ;
+        nonDistributedrecursiveFunct(currentPos-1, masked, elementPositionInGrid, maskSrc, maskDst, srcInd, srcIndCompressed, nIndexSrc, t, dstIndWeight, currentInd, localSrc, localDst, weight, localMaskOnGridSrc, localMaskOnGridDest) ;
       }
     }
@@ -1054,5 +1055,5 @@
       for(int i=0;i<nIndexSrc[currentPos];i++)
       {
-        if (mask(i))
+        if (masked && mask(i))
         {
           if (dstIndWeight[t][currentInd].size()>0)
@@ -1062,5 +1063,5 @@
               if (localMaskOnGridSrc(srcInd))
               {
-                localSrc.push_back(srcInd) ;
+                localSrc.push_back(srcIndCompressed) ;
                 localDst.push_back(it->first) ;
                 weight.push_back(it->second) ;
@@ -1069,8 +1070,9 @@
               (it->first)++ ;
             }
+            if (localMaskOnGridSrc(srcInd)) srcIndCompressed ++ ;
           }
-          srcInd++ ;
           if (t < dstIndWeight.size()-1) t++ ;
         }
+        srcInd++ ;
       }
     }
@@ -1086,8 +1088,6 @@
       {
         t=0 ;
-        if (mask(i))
-        {
-          nonDistributedrecursiveFunct(currentPos-1, elementPositionInGrid, maskSrc, maskDst, srcInd, nIndexSrc, t, dstIndWeight , i,  localSrc, localDst, weight, localMaskOnGridSrc, localMaskOnGridDest) ;
-        }
+        if (!mask(i)) masked=false ; 
+        nonDistributedrecursiveFunct(currentPos-1, masked, elementPositionInGrid, maskSrc, maskDst, srcInd, srcIndCompressed, nIndexSrc, t, dstIndWeight , i,  localSrc, localDst, weight, localMaskOnGridSrc, localMaskOnGridDest) ;
       }
     }
@@ -1096,21 +1096,25 @@
       for(int i=0;i<nIndexSrc[currentPos];i++)
       {
-        t=0 ;        
-        if (dstIndWeight[t][i].size()>0)
-        {
-          for(vector<pair<int,double> >::iterator it = dstIndWeight[t][i].begin(); it!=dstIndWeight[t][i].end(); ++it)
+        if (masked)
+        {
+          t=0 ;        
+          if (dstIndWeight[t][i].size()>0)
           {
-            if (localMaskOnGridSrc(srcInd))
+            for(vector<pair<int,double> >::iterator it = dstIndWeight[t][i].begin(); it!=dstIndWeight[t][i].end(); ++it)
             {
-              localSrc.push_back(srcInd) ;
-              localDst.push_back(it->first) ;
-              weight.push_back(it->second) ;
-              localMaskOnGridDest[it->first]=true ;
+              if (localMaskOnGridSrc(srcInd))
+              {
+                localSrc.push_back(srcIndCompressed) ;
+                localDst.push_back(it->first) ;
+                weight.push_back(it->second) ;
+                localMaskOnGridDest[it->first]=true ;
+              }
+              (it->first)++ ;
             }
-            (it->first)++ ;
+            if (localMaskOnGridSrc(srcInd)) srcIndCompressed ++ ;
           }
+          if (t < dstIndWeight.size()-1) t++ ;
         }
         srcInd++ ;
-        if (t < dstIndWeight.size()-1) t++ ;
       }
     }
Index: XIOS/dev/XIOS_DEV_CMIP6/src/transformation/generic_algorithm_transformation.hpp
===================================================================
--- XIOS/dev/XIOS_DEV_CMIP6/src/transformation/generic_algorithm_transformation.hpp	(revision 1419)
+++ XIOS/dev/XIOS_DEV_CMIP6/src/transformation/generic_algorithm_transformation.hpp	(revision 1420)
@@ -89,5 +89,5 @@
   void computeTransformationMappingNonDistributed(int elementPositionInGrid, CGrid* gridSrc, CGrid* gridDst,
                                                   vector<int>& localSrc, vector<int>& localDst, vector<double>& weight, vector<bool>& localMaskOnGridDest);
-  void nonDistributedrecursiveFunct(int currentPos, int elementPositionInGrid,  vector< CArray<bool,1>* >& maskSrc, vector< CArray<bool,1>* >& maskDst, int& srcInd, vector<int>& nIndexSrc, int& t, vector<vector<vector<pair<int,double> > > >& dstIndWeight, int currentInd,
+  void nonDistributedrecursiveFunct(int currentPos, bool masked, int elementPositionInGrid,  vector< CArray<bool,1>* >& maskSrc, vector< CArray<bool,1>* >& maskDst, int& srcInd, int& srcIndCompressed, vector<int>& nIndexSrc, int& t, vector<vector<vector<pair<int,double> > > >& dstIndWeight, int currentInd,
                                      vector<int>& localSrc, vector<int>& localDst, vector<double>& weight, CArray<bool,1>& localMaskOnGridSrc, vector<bool>& localMaskOnGridDest) ;
 
