Index: /XIOS/trunk/src/filter/spatial_transform_filter.cpp
===================================================================
--- /XIOS/trunk/src/filter/spatial_transform_filter.cpp	(revision 1260)
+++ /XIOS/trunk/src/filter/spatial_transform_filter.cpp	(revision 1261)
@@ -196,4 +196,5 @@
       std::vector<bool> localInitFlag(dataCurrentDest.numElements(), true);
       currentBuff = 0;
+      bool firstPass=true; 
       for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv)
       {
@@ -204,7 +205,8 @@
                          dataCurrentDest,
                          localInitFlag,
-                         ignoreMissingValue);
+                         ignoreMissingValue,firstPass);
 
         currentBuff += countSize;
+        firstPass=false ;
       }
 
Index: /XIOS/trunk/src/transformation/Functions/average_reduction.cpp
===================================================================
--- /XIOS/trunk/src/transformation/Functions/average_reduction.cpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/Functions/average_reduction.cpp	(revision 1261)
@@ -31,5 +31,5 @@
                                        CArray<double,1>& dataOut,
                                        std::vector<bool>& flagInitial,                     
-                                       bool ignoreMissingValue)
+                                       bool ignoreMissingValue, bool firstPass)
 {
   if (resetWeight_) { weights_.resize(flagInitial.size()); weights_ = 1.0; resetWeight_ = false; }  
@@ -39,5 +39,7 @@
     int nbLocalIndex = localIndex.size();
     int currentlocalIndex = 0;
-    double currentWeight  = 0.0;    
+    double currentWeight  = 0.0;
+
+    if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN();
 
     for (int idx = 0; idx < nbLocalIndex; ++idx)
@@ -57,9 +59,4 @@
           weights_(currentlocalIndex) += 1.0;
         }
-      }
-      else
-      {
-        if (flagInitial[currentlocalIndex]) 
-          dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN();
       }
     }
Index: /XIOS/trunk/src/transformation/Functions/average_reduction.hpp
===================================================================
--- /XIOS/trunk/src/transformation/Functions/average_reduction.hpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/Functions/average_reduction.hpp	(revision 1261)
@@ -27,5 +27,5 @@
                      CArray<double,1>& dataOut,
                      std::vector<bool>& flagInitial,                     
-                     bool ignoreMissingValue);
+                     bool ignoreMissingValue, bool firstPass);
 
   virtual void updateData(CArray<double,1>& dataOut);
Index: /XIOS/trunk/src/transformation/Functions/extract.cpp
===================================================================
--- /XIOS/trunk/src/transformation/Functions/extract.cpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/Functions/extract.cpp	(revision 1261)
@@ -30,5 +30,5 @@
                                        CArray<double,1>& dataOut,
                                        std::vector<bool>& flagInitial,
-                                       bool ignoreMissingValue)
+                                       bool ignoreMissingValue, bool firstPass)
 {
   int nbLocalIndex = localIndex.size();
Index: /XIOS/trunk/src/transformation/Functions/extract.hpp
===================================================================
--- /XIOS/trunk/src/transformation/Functions/extract.hpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/Functions/extract.hpp	(revision 1261)
@@ -27,5 +27,5 @@
                      CArray<double,1>& dataOut,
                      std::vector<bool>& flagInitial,
-                     bool ignoreMissingValue);
+                     bool ignoreMissingValue, bool firstPass);
 
   virtual ~CExtractReductionAlgorithm() {}
Index: /XIOS/trunk/src/transformation/Functions/max_reduction.cpp
===================================================================
--- /XIOS/trunk/src/transformation/Functions/max_reduction.cpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/Functions/max_reduction.cpp	(revision 1261)
@@ -31,10 +31,11 @@
                                    CArray<double,1>& dataOut,
                                    std::vector<bool>& flagInitial,
-                                   bool ignoreMissingValue)
+                                   bool ignoreMissingValue, bool firstPass)
 { 
   if (ignoreMissingValue)
   {
     int nbLocalIndex = localIndex.size();
-    int currentlocalIndex = 0;    
+    int currentlocalIndex = 0;
+    if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN();    
     for (int idx = 0; idx < nbLocalIndex; ++idx)
     {
@@ -51,9 +52,4 @@
           dataOut(currentlocalIndex) = std::max(*(dataInput + idx), dataOut(currentlocalIndex));
         }
-      }
-      else
-      {
-        if (flagInitial[currentlocalIndex]) 
-          dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN();
       }
     }
Index: /XIOS/trunk/src/transformation/Functions/max_reduction.hpp
===================================================================
--- /XIOS/trunk/src/transformation/Functions/max_reduction.hpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/Functions/max_reduction.hpp	(revision 1261)
@@ -27,5 +27,5 @@
                      CArray<double,1>& dataOut,
                      std::vector<bool>& flagInitial,
-                     bool ignoreMissingValue);
+                     bool ignoreMissingValue, bool firstPass);
 
   virtual ~CMaxReductionAlgorithm() {}
Index: /XIOS/trunk/src/transformation/Functions/min_reduction.cpp
===================================================================
--- /XIOS/trunk/src/transformation/Functions/min_reduction.cpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/Functions/min_reduction.cpp	(revision 1261)
@@ -31,10 +31,11 @@
                                    CArray<double,1>& dataOut,
                                    std::vector<bool>& flagInitial,
-                                   bool ignoreMissingValue)
+                                   bool ignoreMissingValue, bool firstPass)
 {
   if (ignoreMissingValue)
   {
     int nbLocalIndex = localIndex.size();
-    int currentlocalIndex = 0;    
+    int currentlocalIndex = 0;
+    if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN();
     for (int idx = 0; idx < nbLocalIndex; ++idx)
     {
@@ -51,9 +52,4 @@
           dataOut(currentlocalIndex) = std::min(*(dataInput + idx), dataOut(currentlocalIndex));
         }
-      }
-      else
-      {
-        if (flagInitial[currentlocalIndex]) 
-          dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN();
       }
     }
Index: /XIOS/trunk/src/transformation/Functions/min_reduction.hpp
===================================================================
--- /XIOS/trunk/src/transformation/Functions/min_reduction.hpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/Functions/min_reduction.hpp	(revision 1261)
@@ -27,5 +27,5 @@
                      CArray<double,1>& dataOut,
                      std::vector<bool>& flagInitial,                     
-                     bool ignoreMissingValue);
+                     bool ignoreMissingValue, bool firstPass);
 
   virtual ~CMinReductionAlgorithm() {}
Index: /XIOS/trunk/src/transformation/Functions/reduction.hpp
===================================================================
--- /XIOS/trunk/src/transformation/Functions/reduction.hpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/Functions/reduction.hpp	(revision 1261)
@@ -41,4 +41,5 @@
     \param [in/out] dataOut Array contains local data
     \param [in/out] flagInitial vector of boolean to mark the local index already initialized. True means there is a need for initialization
+    \param [in] firstPass indicate if it is the first time the apply funtion is called for a same transformation, in order to make a clean initialization 
   */
   virtual void apply(const std::vector<std::pair<int,double> >& localIndex,
@@ -46,5 +47,5 @@
                      CArray<double,1>& dataOut,
                      std::vector<bool>& flagInitial,                     
-                     bool ignoreMissingValue) = 0;
+                     bool ignoreMissingValue, bool firstPass) = 0;
   /*!
     Update local data 
Index: /XIOS/trunk/src/transformation/Functions/sum_reduction.cpp
===================================================================
--- /XIOS/trunk/src/transformation/Functions/sum_reduction.cpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/Functions/sum_reduction.cpp	(revision 1261)
@@ -31,10 +31,12 @@
                                    CArray<double,1>& dataOut,
                                    std::vector<bool>& flagInitial,
-                                   bool ignoreMissingValue)
+                                   bool ignoreMissingValue, bool firstPass)
 {
   if (ignoreMissingValue)
   {
     int nbLocalIndex = localIndex.size();
-    int currentlocalIndex = 0;    
+    int currentlocalIndex = 0;
+
+    if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN();
   
     for (int idx = 0; idx < nbLocalIndex; ++idx)
@@ -52,9 +54,4 @@
           dataOut(currentlocalIndex) += *(dataInput + idx);
         }
-      }
-      else
-      {
-        if (flagInitial[currentlocalIndex]) 
-          dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN();
       }
     }    
Index: /XIOS/trunk/src/transformation/Functions/sum_reduction.hpp
===================================================================
--- /XIOS/trunk/src/transformation/Functions/sum_reduction.hpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/Functions/sum_reduction.hpp	(revision 1261)
@@ -27,5 +27,5 @@
                      CArray<double,1>& dataOut,
                      std::vector<bool>& flagInitial,
-                     bool ignoreMissingValue);
+                     bool ignoreMissingValue, bool firstPass);
 
   virtual ~CSumReductionAlgorithm() {}
Index: /XIOS/trunk/src/transformation/axis_algorithm_extract_domain.cpp
===================================================================
--- /XIOS/trunk/src/transformation/axis_algorithm_extract_domain.cpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/axis_algorithm_extract_domain.cpp	(revision 1261)
@@ -69,7 +69,7 @@
                                         CArray<double,1>& dataOut,
                                         std::vector<bool>& flagInitial,                     
-                                        bool ignoreMissingValue)
+                                        bool ignoreMissingValue, bool firstPass)
 {
-  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue);
+  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass);
 }
 
Index: /XIOS/trunk/src/transformation/axis_algorithm_extract_domain.hpp
===================================================================
--- /XIOS/trunk/src/transformation/axis_algorithm_extract_domain.hpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/axis_algorithm_extract_domain.hpp	(revision 1261)
@@ -34,5 +34,5 @@
                      CArray<double,1>& dataOut,
                      std::vector<bool>& flagInitial,                     
-                     bool ignoreMissingValue);
+                     bool ignoreMissingValue, bool firstPass);
 
   virtual ~CAxisAlgorithmExtractDomain();
Index: /XIOS/trunk/src/transformation/axis_algorithm_reduce_domain.cpp
===================================================================
--- /XIOS/trunk/src/transformation/axis_algorithm_reduce_domain.cpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/axis_algorithm_reduce_domain.cpp	(revision 1261)
@@ -77,7 +77,7 @@
                                        CArray<double,1>& dataOut,
                                        std::vector<bool>& flagInitial,                     
-                                       bool ignoreMissingValue)
+                                       bool ignoreMissingValue, bool firstPass)
 {
-  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue);
+  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass);
 }
 
@@ -102,5 +102,5 @@
   CArray<int,1>& axisDstIndex = axisDest_->index;
   int ni_glo = domainSrc_->ni_glo, nj_glo = domainSrc_->nj_glo;
-  if (jDir == dir_)
+  if (iDir == dir_)
   {
     int nbAxisIdx = axisDstIndex.numElements();
@@ -117,5 +117,5 @@
     }
   }
-  else if (iDir == dir_)
+  else if (jDir == dir_)
   {
     int nbAxisIdx = axisDstIndex.numElements();
Index: /XIOS/trunk/src/transformation/axis_algorithm_reduce_domain.hpp
===================================================================
--- /XIOS/trunk/src/transformation/axis_algorithm_reduce_domain.hpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/axis_algorithm_reduce_domain.hpp	(revision 1261)
@@ -33,5 +33,5 @@
                      CArray<double,1>& dataOut,
                      std::vector<bool>& flagInitial,                     
-                     bool ignoreMissingValue);
+                     bool ignoreMissingValue, bool firstPass);
 
   virtual void updateData(CArray<double,1>& dataOut);
Index: /XIOS/trunk/src/transformation/generic_algorithm_transformation.cpp
===================================================================
--- /XIOS/trunk/src/transformation/generic_algorithm_transformation.cpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/generic_algorithm_transformation.cpp	(revision 1261)
@@ -30,5 +30,5 @@
                                             CArray<double,1>& dataOut,
                                             std::vector<bool>& flagInitial,
-                                            bool ignoreMissingValue)
+                                            bool ignoreMissingValue, bool firstPass  )
 {
   int nbLocalIndex = localIndex.size();   
Index: /XIOS/trunk/src/transformation/generic_algorithm_transformation.hpp
===================================================================
--- /XIOS/trunk/src/transformation/generic_algorithm_transformation.hpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/generic_algorithm_transformation.hpp	(revision 1261)
@@ -64,4 +64,5 @@
     \param [in/out] flagInitial vector of boolean to mark the local index already initialized. True means there is a need for initalization
     \param [in] ignoreMissingValue don't count missing value in operation if this flag is true
+    \param [in] firstPass indicate if it is the first time the apply funtion is called for a same transformation, in order to make a clean initialization 
   */
   virtual void apply(const std::vector<std::pair<int,double> >& localIndex,
@@ -69,5 +70,5 @@
                      CArray<double,1>& dataOut,
                      std::vector<bool>& flagInitial,                     
-                     bool ignoreMissingValue);
+                     bool ignoreMissingValue, bool firstPass);
 
   /*!
Index: /XIOS/trunk/src/transformation/scalar_algorithm_extract_axis.cpp
===================================================================
--- /XIOS/trunk/src/transformation/scalar_algorithm_extract_axis.cpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/scalar_algorithm_extract_axis.cpp	(revision 1261)
@@ -56,7 +56,7 @@
                                          CArray<double,1>& dataOut,
                                          std::vector<bool>& flagInitial,                     
-                                         bool ignoreMissingValue)
+                                         bool ignoreMissingValue, bool firstPass)
 {
-  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue);
+  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass);
 }
 
Index: /XIOS/trunk/src/transformation/scalar_algorithm_extract_axis.hpp
===================================================================
--- /XIOS/trunk/src/transformation/scalar_algorithm_extract_axis.hpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/scalar_algorithm_extract_axis.hpp	(revision 1261)
@@ -33,5 +33,5 @@
                      CArray<double,1>& dataOut,
                      std::vector<bool>& flagInitial,                     
-                     bool ignoreMissingValue);
+                     bool ignoreMissingValue, bool firstPass);
 
   virtual ~CScalarAlgorithmExtractAxis();
Index: /XIOS/trunk/src/transformation/scalar_algorithm_reduce_axis.cpp
===================================================================
--- /XIOS/trunk/src/transformation/scalar_algorithm_reduce_axis.cpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/scalar_algorithm_reduce_axis.cpp	(revision 1261)
@@ -84,11 +84,8 @@
 }
 
-void CScalarAlgorithmReduceAxis::apply(const std::vector<std::pair<int,double> >& localIndex,
-                                         const double* dataInput,
-                                         CArray<double,1>& dataOut,
-                                         std::vector<bool>& flagInitial,
-				       bool ignoreMissingValue)
+void CScalarAlgorithmReduceAxis::apply(const std::vector<std::pair<int,double> >& localIndex, const double* dataInput, CArray<double,1>& dataOut,
+                                         std::vector<bool>& flagInitial, bool ignoreMissingValue, bool firstPass)
 {
-  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue);
+  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass);
 }
 
Index: /XIOS/trunk/src/transformation/scalar_algorithm_reduce_axis.hpp
===================================================================
--- /XIOS/trunk/src/transformation/scalar_algorithm_reduce_axis.hpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/scalar_algorithm_reduce_axis.hpp	(revision 1261)
@@ -33,5 +33,5 @@
                      CArray<double,1>& dataOut,
                      std::vector<bool>& flagInitial,
-                     bool ignoreMissingValue);
+                     bool ignoreMissingValue, bool firstPass);
 
   virtual void updateData(CArray<double,1>& dataOut);
Index: /XIOS/trunk/src/transformation/scalar_algorithm_reduce_domain.cpp
===================================================================
--- /XIOS/trunk/src/transformation/scalar_algorithm_reduce_domain.cpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/scalar_algorithm_reduce_domain.cpp	(revision 1261)
@@ -82,7 +82,7 @@
                                          CArray<double,1>& dataOut,
                                          std::vector<bool>& flagInitial,                     
-                                         bool ignoreMissingValue)
+                                         bool ignoreMissingValue, bool firstPass)
 {
-  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue);
+  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass);
 }
 
Index: /XIOS/trunk/src/transformation/scalar_algorithm_reduce_domain.hpp
===================================================================
--- /XIOS/trunk/src/transformation/scalar_algorithm_reduce_domain.hpp	(revision 1260)
+++ /XIOS/trunk/src/transformation/scalar_algorithm_reduce_domain.hpp	(revision 1261)
@@ -33,5 +33,5 @@
                      CArray<double,1>& dataOut,
                      std::vector<bool>& flagInitial,                     
-                     bool ignoreMissingValue);
+                     bool ignoreMissingValue, bool firstPass);
 
   virtual void updateData(CArray<double,1>& dataOut);
