Index: XIOS/trunk/inputs/REMAP/iodef.xml
===================================================================
--- XIOS/trunk/inputs/REMAP/iodef.xml	(revision 1017)
+++ XIOS/trunk/inputs/REMAP/iodef.xml	(revision 1018)
@@ -6,17 +6,19 @@
    <field_definition level="1" >
     <field_group id="fields_src" operation="instant">
-       <field id="src_field_2D" domain_ref="src_domain"/>
+       <field id="src_field_2D" domain_ref="src_domain" />
        <field id="src_field_2D_clone" domain_ref="src_domain_clone"/>
-       <field id="src_field_3D" domain_ref="src_domain" axis_ref="src_axis"/>       
-       <field id="src_field_3D_pression" grid_ref="src_grid_3D"/>
-       <field id="src_field_4D" grid_ref="grid_4D"/>       
+       <field id="src_field_3D" domain_ref="src_domain" axis_ref="src_axis"  />
+       <field id="src_field_3D_clone" grid_ref="src_grid_3D" detect_missing_value=".TRUE." default_value="100000" />       
+       <field id="src_field_3D_pression" grid_ref="src_grid_3D"  />
+       <field id="src_field_4D" grid_ref="src_grid_4D" detect_missing_value=".TRUE." default_value="100000"/>       
     </field_group>
     <field_group  id="fields_dst">
       <field id="dst_field_2D" field_ref="src_field_2D" domain_ref="dst_domain"/>
       <field id="dst_field_2D_regular_pole" field_ref="src_field_2D" domain_ref="dst_domain_regular_pole"/>
+      <field id="dst_field_2D_clone" field_ref="src_field_2D_clone" domain_ref="dst_domain"/>
+      <field id="dst_field_2D_extract" field_ref="src_field_3D_clone" grid_ref="dst_grid_2D_extract"/>
       <field id="dst_field_3D" field_ref="src_field_3D" grid_ref="dst_grid_3D"/>
       <field id="dst_field_3D_interp" field_ref="src_field_3D" axis_ref="dst_axis"/>       
-      <field id="dst_field_4D_extract" field_ref="src_field_4D" grid_ref="grid_4D_extract"/>      
-      <field id="dst_field_2D_clone" field_ref="src_field_2D_clone" domain_ref="dst_domain"/>
+      <field id="dst_field_4D_extract" field_ref="src_field_4D" grid_ref="dst_grid_4D_extract"/> 
     </field_group>
     <field_group id="read_fields" operation="instant">
@@ -35,10 +37,11 @@
         <file id="output_2D" name="output_2D" >
           <field field_ref="src_field_2D" name="field_src" />
-          <field field_ref="src_field_2D" name="field_dst_regular_0"  domain_ref="dst_domain_regular_pole" default_value="10.e+5"/>
+          <field field_ref="src_field_2D" name="field_dst_regular_0"  domain_ref="dst_domain_regular_pole" />
           <field field_ref="dst_field_2D" name="field_dst_regular_1" />
           <field field_ref="dst_field_2D_regular_pole" name="field_dst_regular_2" />
           <field field_ref="dst_field_2D_clone" name="field_dst_regular_3" />
+          <field field_ref="dst_field_2D_extract" name="field_dst_regular_4" />
         </file> 
-       <file id="output_3D" name="output_3D" >
+       <file id="output_3D" name="output_3D" enabled=".TRUE." >
           <field field_ref="src_field_3D" name="field_src" />
           <field field_ref="src_field_3D_pression" name="field" />
@@ -46,5 +49,5 @@
           <field field_ref="dst_field_3D_interp" name="field_dst_interp_domain_axis" domain_ref="dst_domain_regular_pole"/>  
        </file>
-       <file id="output_4D" name="output_4D" >
+       <file id="output_4D" name="output_4D" enabled=".FALSE.">
           <field field_ref="src_field_4D" name="field_4D" />
           <field field_ref="dst_field_4D_extract" name="field_4D_extract" />
@@ -76,4 +79,14 @@
      </file_group>
    </file_definition>
+
+   <scalar_definition>
+    <scalar_group id="scalar_src">
+    </scalar_group>
+    <scalar_group id="scalar_dst">
+     <scalar id="scalar_extract">
+       <reduce_axis operation="sum"/>
+     </scalar>
+    </scalar_group>
+   </scalar_definition>
 
    <axis_definition>
@@ -109,10 +122,10 @@
     <domain_group id="domain_dst">
      <domain id="dst_domain">
-       <interpolate_domain write_weight="true" />
+       <interpolate_domain write_weight="false" />
      </domain>
      <domain id="dst_domain_regular_pole" ni_glo="90" nj_glo="45" type="rectilinear">
        <generate_rectilinear_domain id="domain_regular_pole"/>
        <interpolate_domain write_weight="false"/>       
-       <zoom_domain ibegin="0" ni="45" jbegin="0" nj="45" />
+       <!-- <zoom_domain ibegin="0" ni="45" jbegin="0" nj="45" /> -->
      </domain>
      <domain id="dst_domain_regular" ni_glo="90" nj_glo="45" type="rectilinear">
@@ -142,5 +155,5 @@
         <axis axis_ref="src_axis"/>
       </grid>
-      <grid id="grid_4D">
+      <grid id="src_grid_4D">
         <domain domain_ref="src_domain"/>
         <axis axis_ref="src_axis"/>
@@ -153,13 +166,21 @@
         <domain domain_ref="dst_domain_regular"/>
       </grid>
+      <grid id="dst_grid_2D_extract">
+        <domain domain_ref="dst_domain_regular"/>
+        <scalar >          
+          <reduce_axis operation="min"/>
+          <!-- <extract_axis position="2"/> -->
+        </scalar>
+      </grid>
       <grid id="dst_grid_3D">
         <domain domain_ref="src_domain"/>
         <axis axis_ref="dst_axis"/>
       </grid>
-      <grid id="grid_4D_extract">
+      <grid id="dst_grid_4D_extract">
         <domain domain_ref="dst_domain_regular_pole"/>      
         <axis axis_ref="src_axis"/>        
         <scalar >
-          <extract_axis position="1"/>
+          <!-- <extract_axis position="1"/> -->
+          <reduce_axis operation="sum"/>
         </scalar>      
       </grid>
Index: XIOS/trunk/src/filter/file_writer_filter.cpp
===================================================================
--- XIOS/trunk/src/filter/file_writer_filter.cpp	(revision 1017)
+++ XIOS/trunk/src/filter/file_writer_filter.cpp	(revision 1018)
@@ -2,4 +2,5 @@
 #include "exception.hpp"
 #include "field.hpp"
+#include "utils.hpp"
 
 namespace xios
@@ -16,4 +17,18 @@
   void CFileWriterFilter::onInputReady(std::vector<CDataPacketPtr> data)
   {
+    bool ignoreMissingValue = (!field->detect_missing_value.isEmpty() && 
+                               !field->default_value.isEmpty() && 
+                               field->detect_missing_value == true);
+    if (ignoreMissingValue)
+    {
+      double missingValue = field->default_value;
+      size_t nbData = data[0]->data.numElements();
+      for (size_t idx = 0; idx < nbData; ++idx)
+      {
+        if (NumTraits<double>::isnan(data[0]->data(idx)))
+          data[0]->data(idx) = missingValue;
+      }
+    }    
+
     field->sendUpdateData(data[0]->data);
   }
Index: XIOS/trunk/src/filter/source_filter.cpp
===================================================================
--- XIOS/trunk/src/filter/source_filter.cpp	(revision 1017)
+++ XIOS/trunk/src/filter/source_filter.cpp	(revision 1018)
@@ -3,12 +3,16 @@
 #include "exception.hpp"
 #include "calendar_util.hpp"
+#include <limits> 
 
 namespace xios
 {
   CSourceFilter::CSourceFilter(CGarbageCollector& gc, CGrid* grid,
-                               const CDuration offset /*= NoneDu*/, bool manualTrigger /*= false*/)
+                               const CDuration offset /*= NoneDu*/, bool manualTrigger /*= false*/,
+                               bool hasMissingValue /*= false*/,
+                               double defaultValue /*= 0.0*/)
     : COutputPin(gc, manualTrigger)
     , grid(grid)
     , offset(offset)
+    , hasMissingValue(hasMissingValue), defaultValue(defaultValue)
   {
     if (!grid)
@@ -29,4 +33,16 @@
     packet->data.resize(grid->storeIndex_client.numElements());
     grid->inputField(data, packet->data);
+
+    // Convert missing values to NaN
+    if (hasMissingValue)
+    {
+      double nanValue = std::numeric_limits<double>::quiet_NaN();
+      size_t nbData = packet->data.numElements();
+      for (size_t idx = 0; idx < nbData; ++idx)
+      {
+        if (defaultValue == packet->data(idx))
+          packet->data(idx) = nanValue;
+      }
+    }
 
     onOutputReady(packet);
Index: XIOS/trunk/src/filter/source_filter.hpp
===================================================================
--- XIOS/trunk/src/filter/source_filter.hpp	(revision 1017)
+++ XIOS/trunk/src/filter/source_filter.hpp	(revision 1018)
@@ -23,7 +23,11 @@
        * \param offset the offset applied to the timestamp of all packets
        * \param manualTrigger whether the output should be triggered manually
+       * \param hasMissingValue whether data has missing value
+       * \param defaultValue missing value to detect
        */
       CSourceFilter(CGarbageCollector& gc, CGrid* grid,
-                    const CDuration offset = NoneDu, bool manualTrigger = false);
+                    const CDuration offset = NoneDu, bool manualTrigger = false,
+                    bool hasMissingValue = false,
+                    double defaultValue = 0.0);
 
       /*!
@@ -58,4 +62,6 @@
       CGrid* grid; //!< The grid attached to the data the filter can accept
       const CDuration offset; //!< The offset applied to the timestamp of all packets
+      bool hasMissingValue;
+      double defaultValue;
   }; // class CSourceFilter
 } // namespace xios
Index: XIOS/trunk/src/filter/spatial_transform_filter.cpp
===================================================================
--- XIOS/trunk/src/filter/spatial_transform_filter.cpp	(revision 1017)
+++ XIOS/trunk/src/filter/spatial_transform_filter.cpp	(revision 1018)
@@ -11,5 +11,5 @@
 
   std::pair<boost::shared_ptr<CSpatialTransformFilter>, boost::shared_ptr<CSpatialTransformFilter> >
-  CSpatialTransformFilter::buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, double defaultValue)
+  CSpatialTransformFilter::buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, bool hasMissingValue, double missingValue)
   {
     if (!srcGrid || !destGrid)
@@ -26,4 +26,5 @@
       const std::vector<StdString>& auxInputs = gridTransformation->getAuxInputs();
       size_t inputCount = 1 + (auxInputs.empty() ? 0 : auxInputs.size());
+      double defaultValue  = (hasMissingValue) ? std::numeric_limits<double>::quiet_NaN() : missingValue;
       boost::shared_ptr<CSpatialTransformFilter> filter(new CSpatialTransformFilter(gc, engine, defaultValue, inputCount));
 
@@ -103,5 +104,6 @@
       }
       packet->data.resize(gridTransformation->getGridDestination()->storeIndex_client.numElements());
-      packet->data = defaultValue;
+      if (0 != packet->data.numElements())
+        (packet->data)(0) = defaultValue;
       apply(data[0]->data, packet->data);
     }
Index: XIOS/trunk/src/filter/spatial_transform_filter.hpp
===================================================================
--- XIOS/trunk/src/filter/spatial_transform_filter.hpp	(revision 1017)
+++ XIOS/trunk/src/filter/spatial_transform_filter.hpp	(revision 1018)
@@ -32,8 +32,10 @@
        * \param srcGrid the source grid
        * \param destGrid the destination grid
+       * \param hasMissingValue whether field source has missing value
+       * \param defaultValue default value
        * \return the first and the last filters of the filter graph
        */
       static std::pair<boost::shared_ptr<CSpatialTransformFilter>, boost::shared_ptr<CSpatialTransformFilter> >
-      buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, double defaultValue);
+      buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, bool hasMissingValue, double defaultValue);
 
     protected:
Index: XIOS/trunk/src/filter/temporal_filter.cpp
===================================================================
--- XIOS/trunk/src/filter/temporal_filter.cpp	(revision 1017)
+++ XIOS/trunk/src/filter/temporal_filter.cpp	(revision 1018)
@@ -15,4 +15,6 @@
     , isFirstOperation(true)
   {
+    double defaultValue = ignoreMissingValue ? std::numeric_limits<double>::quiet_NaN() : missingValue;
+    
 #define DECLARE_FUNCTOR(MType, mtype) \
     if (opId.compare(#mtype) == 0) \
@@ -20,5 +22,5 @@
       if (ignoreMissingValue) \
       { \
-        functor.reset(new func::C##MType(tmpData, missingValue)); \
+        functor.reset(new func::C##MType(tmpData, defaultValue)); \
       } \
       else \
Index: XIOS/trunk/src/functor/accumulate.cpp
===================================================================
--- XIOS/trunk/src/functor/accumulate.cpp	(revision 1017)
+++ XIOS/trunk/src/functor/accumulate.cpp	(revision 1018)
@@ -1,4 +1,5 @@
 #include "accumulate.hpp"
 #include "array_new.hpp"
+#include "utils.hpp"
 
 namespace xios
@@ -33,7 +34,7 @@
             double* out=_doutput.dataFirst();
             for (i=0; i<n; ++i,++in,++out) 
-              if (*in!=missingValue)
+              if (!NumTraits<double>::isnan(*in))
               {
-                if(*out!=missingValue) *out  += *in;
+                if(!NumTraits<double>::isnan(*out)) *out  += *in;
                 else *out=*in ;
               }
Index: XIOS/trunk/src/functor/average.cpp
===================================================================
--- XIOS/trunk/src/functor/average.cpp	(revision 1017)
+++ XIOS/trunk/src/functor/average.cpp	(revision 1018)
@@ -1,4 +1,5 @@
 #include "average.hpp"
 #include "array_new.hpp"
+#include "utils.hpp"
 
 namespace xios
@@ -42,5 +43,5 @@
             int* nc=nbcalls.dataFirst() ;
             for (i=0; i<n; ++i,++nc,++in) 
-              if (*in!=missingValue) (*nc) ++;
+              if (!NumTraits<double>::isnan(*in)) (*nc) ++;
           }
         }
@@ -54,5 +55,5 @@
             int* nc=nbcalls.dataFirst() ;
             for (i=0; i<n; ++i,++in,++out,++nc) 
-              if (*in!=missingValue) 
+              if (!NumTraits<double>::isnan(*in)) 
               {
                 if (*nc != 0) (*out)  += *in;
Index: XIOS/trunk/src/functor/maximum.cpp
===================================================================
--- XIOS/trunk/src/functor/maximum.cpp	(revision 1017)
+++ XIOS/trunk/src/functor/maximum.cpp	(revision 1018)
@@ -1,6 +1,5 @@
 #include "maximum.hpp"
 #include "array_new.hpp"
-
-
+#include "utils.hpp"
 
 namespace xios
@@ -35,7 +34,7 @@
            { 
              for (; it1 != end1; it1++, it++) 
-               if (*it1 != missingValue)
+               if (!NumTraits<double>::isnan(*it1))
                {
-                 if ( *it != missingValue) *it = std::max(*it1, *it);
+                 if (!NumTraits<double>::isnan(*it)) *it = std::max(*it1, *it);
                  else *it=*it1 ;  
                }
Index: XIOS/trunk/src/functor/minimum.cpp
===================================================================
--- XIOS/trunk/src/functor/minimum.cpp	(revision 1017)
+++ XIOS/trunk/src/functor/minimum.cpp	(revision 1018)
@@ -2,4 +2,5 @@
 #include "array_new.hpp"
 #include <algorithm>
+#include "utils.hpp"
 
 namespace xios
@@ -26,5 +27,5 @@
       {
         const double * it1  = _dinput.dataFirst(),
-                      * end1 = _dinput.dataFirst() + _dinput.numElements();
+                      *end1 = _dinput.dataFirst() + _dinput.numElements();
         double * it   = _doutput.dataFirst();
         
@@ -35,7 +36,7 @@
           { 
             for (; it1 != end1; it1++, it++) 
-              if (*it1!=missingValue)
+              if (!NumTraits<double>::isnan(*it1))
               {
-                if (*it != missingValue) *it = std::min(*it1, *it);
+                if (!NumTraits<double>::isnan(*it)) *it = std::min(*it1, *it);
                 else *it=*it1 ;
               }
Index: XIOS/trunk/src/node/field.cpp
===================================================================
--- XIOS/trunk/src/node/field.cpp	(revision 1017)
+++ XIOS/trunk/src/node/field.cpp	(revision 1018)
@@ -795,6 +795,7 @@
            if (grid && grid != gridRef && grid->hasTransform())
            {
-             double defaultValue = !default_value.isEmpty() ? default_value : 0.0;
-             std::pair<boost::shared_ptr<CFilter>, boost::shared_ptr<CFilter> > filters = CSpatialTransformFilter::buildFilterGraph(gc, gridRef, grid, defaultValue);
+             bool hasMissingValue = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true);
+             double defaultValue  = hasMissingValue ? default_value : (!default_value.isEmpty() ? default_value : 0.0);
+             std::pair<boost::shared_ptr<CFilter>, boost::shared_ptr<CFilter> > filters = CSpatialTransformFilter::buildFilterGraph(gc, gridRef, grid, hasMissingValue, defaultValue);
 
              filter->connectOutput(filters.first, 0);
@@ -814,5 +815,9 @@
                                                                                                      true));
        else // The data might be passed from the model
-         instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid));
+       {
+          bool ignoreMissingValue = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true);
+          double defaultValue  = ignoreMissingValue ? default_value : (!default_value.isEmpty() ? default_value : 0.0);
+          instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, NoneDu, false,
+                                                                                                      ignoreMissingValue, defaultValue));       }
      }
 
@@ -853,7 +858,8 @@
      // Check if a spatial transformation is needed
      if (grid && grid != fieldRef->grid && grid->hasTransform())
-     {
-       double defaultValue = !default_value.isEmpty() ? default_value : 0.0;
-       filters = CSpatialTransformFilter::buildFilterGraph(gc, fieldRef->grid, grid, defaultValue);
+     {       
+       bool hasMissingValue = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true);
+       double defaultValue  = hasMissingValue ? default_value : (!default_value.isEmpty() ? default_value : 0.0);                                
+       filters = CSpatialTransformFilter::buildFilterGraph(gc, fieldRef->grid, grid, hasMissingValue, defaultValue);
      }
      else
@@ -900,5 +906,10 @@
        {
          if (!clientSourceFilter)
-           clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid));
+         {
+           bool ignoreMissingValue = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true);
+           double defaultValue  = ignoreMissingValue ? default_value : (!default_value.isEmpty() ? default_value : 0.0); 
+           clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, NoneDu, false,
+                                                                                   ignoreMissingValue, defaultValue));
+         }
 
          selfReferenceFilter = clientSourceFilter;
@@ -934,5 +945,5 @@
 
        const bool ignoreMissingValue = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true);
-
+       
        boost::shared_ptr<CTemporalFilter> temporalFilter(new CTemporalFilter(gc, operation,
                                                                              CContext::getCurrent()->getCalendar()->getInitDate(),
Index: XIOS/trunk/src/test/test_remap.f90
===================================================================
--- XIOS/trunk/src/test/test_remap.f90	(revision 1017)
+++ XIOS/trunk/src/test/test_remap.f90	(revision 1018)
@@ -91,6 +91,7 @@
     IF (MOD(i,10)==0) THEN
       src_mask_2D(i)=.FALSE.
+      src_field_2D(i) = 100000
     ELSE
-      src_mask_2D(i)=.TRUE.
+      src_mask_2D(i)=.TRUE.      
     ENDIF
   ENDDO
@@ -99,9 +100,16 @@
     lval(i) = i*100
     src_field_pression(:,i) = i * 100
-    src_field_3D(:,i) = src_field_3D(:,i) + i * 10    
+    IF (MOD(i,3)==0) THEN
+      ! src_field_pression(:,i) = 100000
+      src_field_3D(:,i) = 100000
+    ELSE
+      ! src_field_pression(:,i) = i * 100
+      src_field_3D(:,i) = src_field_3D(:,i) + i * 10 
+    ENDIF
+    ! src_field_3D(:,i) = src_field_3D(:,i) + i * 10    
   ENDDO
 
   DO i=1,llm2
-    src_field_4D(:,:,i) = src_field_3D(:,:)
+    src_field_4D(:,:,i) = src_field_3D(:,:) + i * 100
   ENDDO
 
@@ -184,4 +192,5 @@
     CALL xios_send_field("src_field_2D_clone",src_field_2D)
     CALL xios_send_field("src_field_3D",src_field_3D)
+    CALL xios_send_field("src_field_3D_clone",src_field_3D)
     CALL xios_send_field("src_field_4D",src_field_4D)
     CALL xios_send_field("src_field_3D_pression",src_field_pression)
Index: XIOS/trunk/src/transformation/Functions/average_reduction.cpp
===================================================================
--- XIOS/trunk/src/transformation/Functions/average_reduction.cpp	(revision 1017)
+++ XIOS/trunk/src/transformation/Functions/average_reduction.cpp	(revision 1018)
@@ -3,9 +3,10 @@
    \author Ha NGUYEN
    \since 8 Sep 2016
-   \date 8 Sep 2016
+   \date 9 Jan 2017
 
    \brief average reduction
  */
 #include "average_reduction.hpp"
+#include "utils.hpp"
 
 namespace xios {
@@ -29,25 +30,54 @@
                                        const double* dataInput,
                                        CArray<double,1>& dataOut,
-                                       std::vector<bool>& flagInitial)
+                                       std::vector<bool>& flagInitial,
+                                       const double& defaultValue)
 {
   if (resetWeight_) { weights_.resize(flagInitial.size()); weights_ = 1.0; resetWeight_ = false; }
+  bool hasMissingValue = NumTraits<double>::isnan(defaultValue);
 
-  int nbLocalIndex = localIndex.size();
-  int currentlocalIndex = 0;
-  double currentWeight  = 0.0;
-  for (int idx = 0; idx < nbLocalIndex; ++idx)
+  if (hasMissingValue)
   {
-    currentlocalIndex = localIndex[idx].first;
-    currentWeight     = localIndex[idx].second;
+    int nbLocalIndex = localIndex.size();
+    int currentlocalIndex = 0;
+    double currentWeight  = 0.0;
+    for (int idx = 0; idx < nbLocalIndex; ++idx)
+    {
+      currentlocalIndex = localIndex[idx].first;
+      currentWeight     = localIndex[idx].second;
+      if (!NumTraits<double>::isnan(*(dataInput + idx)))
+      {
+        if (flagInitial[currentlocalIndex])
+        {
+          dataOut(currentlocalIndex) = *(dataInput + idx);
+          flagInitial[currentlocalIndex] = false;
+        }
+        else
+        {
+          dataOut(currentlocalIndex)  += *(dataInput + idx);
+          weights_(currentlocalIndex) += 1.0;
+        }
+      }
+    }
+  }
+  else
+  {
+    int nbLocalIndex = localIndex.size();
+    int currentlocalIndex = 0;
+    double currentWeight  = 0.0;
+    for (int idx = 0; idx < nbLocalIndex; ++idx)
+    {
+      currentlocalIndex = localIndex[idx].first;
+      currentWeight     = localIndex[idx].second;
 
-    if (flagInitial[currentlocalIndex])
-    {
-      dataOut(currentlocalIndex) = *(dataInput + idx);
-      flagInitial[currentlocalIndex] = false;
-    }
-    else
-    {
-      dataOut(currentlocalIndex)  += *(dataInput + idx);
-      weights_(currentlocalIndex) += 1.0;
+      if (flagInitial[currentlocalIndex])
+      {
+        dataOut(currentlocalIndex) = *(dataInput + idx);
+        flagInitial[currentlocalIndex] = false;
+      }
+      else
+      {
+        dataOut(currentlocalIndex)  += *(dataInput + idx);
+        weights_(currentlocalIndex) += 1.0;
+      }
     }
   }
Index: XIOS/trunk/src/transformation/Functions/average_reduction.hpp
===================================================================
--- XIOS/trunk/src/transformation/Functions/average_reduction.hpp	(revision 1017)
+++ XIOS/trunk/src/transformation/Functions/average_reduction.hpp	(revision 1018)
@@ -26,5 +26,6 @@
                      const double* dataInput,
                      CArray<double,1>& dataOut,
-                     std::vector<bool>& flagInitial);
+                     std::vector<bool>& flagInitial,
+                     const double& defaultValue);
 
   virtual void updateData(CArray<double,1>& dataOut);
Index: XIOS/trunk/src/transformation/Functions/extract.cpp
===================================================================
--- XIOS/trunk/src/transformation/Functions/extract.cpp	(revision 1017)
+++ XIOS/trunk/src/transformation/Functions/extract.cpp	(revision 1018)
@@ -29,5 +29,6 @@
                                        const double* dataInput,
                                        CArray<double,1>& dataOut,
-                                       std::vector<bool>& flagInitial)
+                                       std::vector<bool>& flagInitial,
+                                       const double& defaultValue)
 {
   int nbLocalIndex = localIndex.size();
Index: XIOS/trunk/src/transformation/Functions/extract.hpp
===================================================================
--- XIOS/trunk/src/transformation/Functions/extract.hpp	(revision 1017)
+++ XIOS/trunk/src/transformation/Functions/extract.hpp	(revision 1018)
@@ -26,5 +26,6 @@
                      const double* dataInput,
                      CArray<double,1>& dataOut,
-                     std::vector<bool>& flagInitial);
+                     std::vector<bool>& flagInitial,
+                     const double& defaultValue);
 
   virtual ~CExtractReductionAlgorithm() {}
Index: XIOS/trunk/src/transformation/Functions/max_reduction.cpp
===================================================================
--- XIOS/trunk/src/transformation/Functions/max_reduction.cpp	(revision 1017)
+++ XIOS/trunk/src/transformation/Functions/max_reduction.cpp	(revision 1018)
@@ -8,4 +8,5 @@
  */
 #include "max_reduction.hpp"
+#include "utils.hpp"
 
 namespace xios {
@@ -29,21 +30,46 @@
                                    const double* dataInput,
                                    CArray<double,1>& dataOut,
-                                   std::vector<bool>& flagInitial)
+                                   std::vector<bool>& flagInitial,
+                                   const double& defaultValue)
 {
-  int nbLocalIndex = localIndex.size();
-  int currentlocalIndex = 0;
-  double currentWeight  = 0.0;
-  for (int idx = 0; idx < nbLocalIndex; ++idx)
+  bool hasMissingValue = NumTraits<double>::isnan(defaultValue);
+
+  if (hasMissingValue)
   {
-    currentlocalIndex = localIndex[idx].first;
-    currentWeight     = localIndex[idx].second;
-    if (flagInitial[currentlocalIndex])
+    int nbLocalIndex = localIndex.size();
+    int currentlocalIndex = 0;    
+    for (int idx = 0; idx < nbLocalIndex; ++idx)
     {
-      dataOut(currentlocalIndex) = *(dataInput + idx);
-      flagInitial[currentlocalIndex] = false;
+      currentlocalIndex = localIndex[idx].first;      
+      if (!NumTraits<double>::isnan(*(dataInput + idx)))
+      {
+        if (flagInitial[currentlocalIndex])
+        {
+          dataOut(currentlocalIndex) = *(dataInput + idx);
+          flagInitial[currentlocalIndex] = false;
+        }
+        else
+        {
+          dataOut(currentlocalIndex) = std::max(*(dataInput + idx), dataOut(currentlocalIndex));
+        }
+      }
     }
-    else
+  }
+  else
+  {
+    int nbLocalIndex = localIndex.size();
+    int currentlocalIndex = 0;    
+    for (int idx = 0; idx < nbLocalIndex; ++idx)
     {
-      dataOut(currentlocalIndex) = std::max(*(dataInput + idx), dataOut(currentlocalIndex));
+      currentlocalIndex = localIndex[idx].first;      
+      if (flagInitial[currentlocalIndex])
+      {
+        dataOut(currentlocalIndex) = *(dataInput + idx);
+        flagInitial[currentlocalIndex] = false;
+      }
+      else
+      {
+        dataOut(currentlocalIndex) = std::max(*(dataInput + idx), dataOut(currentlocalIndex));
+      }
     }
   }
Index: XIOS/trunk/src/transformation/Functions/max_reduction.hpp
===================================================================
--- XIOS/trunk/src/transformation/Functions/max_reduction.hpp	(revision 1017)
+++ XIOS/trunk/src/transformation/Functions/max_reduction.hpp	(revision 1018)
@@ -26,5 +26,6 @@
                      const double* dataInput,
                      CArray<double,1>& dataOut,
-                     std::vector<bool>& flagInitial);
+                     std::vector<bool>& flagInitial,
+                     const double& defaultValue);
 
   virtual ~CMaxReductionAlgorithm() {}
Index: XIOS/trunk/src/transformation/Functions/min_reduction.cpp
===================================================================
--- XIOS/trunk/src/transformation/Functions/min_reduction.cpp	(revision 1017)
+++ XIOS/trunk/src/transformation/Functions/min_reduction.cpp	(revision 1018)
@@ -3,9 +3,10 @@
    \author Ha NGUYEN
    \since 27 June 2016
-   \date 27 June 2016
+   \date 9 Jan 2017
 
    \brief min reduction
  */
 #include "min_reduction.hpp"
+#include "utils.hpp"
 
 namespace xios {
@@ -29,19 +30,46 @@
                                    const double* dataInput,
                                    CArray<double,1>& dataOut,
-                                   std::vector<bool>& flagInitial)
+                                   std::vector<bool>& flagInitial,
+                                   const double& defaultValue)
 {
-  int nbLocalIndex = localIndex.size();
-  int currentlocalIndex = 0;
-  for (int idx = 0; idx < nbLocalIndex; ++idx)
+  bool hasMissingValue = NumTraits<double>::isnan(defaultValue);
+
+  if (hasMissingValue)
   {
-    currentlocalIndex = localIndex[idx].first;
-    if (flagInitial[currentlocalIndex])
+    int nbLocalIndex = localIndex.size();
+    int currentlocalIndex = 0;
+    for (int idx = 0; idx < nbLocalIndex; ++idx)
     {
-      dataOut(currentlocalIndex) = *(dataInput + idx);
-      flagInitial[currentlocalIndex] = false;
+      currentlocalIndex = localIndex[idx].first;
+      if (!NumTraits<double>::isnan(*(dataInput + idx)))
+      {
+        if (flagInitial[currentlocalIndex])
+        {
+          dataOut(currentlocalIndex) = *(dataInput + idx);
+          flagInitial[currentlocalIndex] = false;
+        }
+        else
+        {
+          dataOut(currentlocalIndex) = std::min(*(dataInput + idx), dataOut(currentlocalIndex));
+        }
+      }
     }
-    else
+  }
+  else
+  {
+    int nbLocalIndex = localIndex.size();
+    int currentlocalIndex = 0;
+    for (int idx = 0; idx < nbLocalIndex; ++idx)
     {
-      dataOut(currentlocalIndex) = std::min(*(dataInput + idx), dataOut(currentlocalIndex));
+      currentlocalIndex = localIndex[idx].first;
+      if (flagInitial[currentlocalIndex])
+      {
+        dataOut(currentlocalIndex) = *(dataInput + idx);
+        flagInitial[currentlocalIndex] = false;
+      }
+      else
+      {
+        dataOut(currentlocalIndex) = std::min(*(dataInput + idx), dataOut(currentlocalIndex));
+      }
     }
   }
Index: XIOS/trunk/src/transformation/Functions/min_reduction.hpp
===================================================================
--- XIOS/trunk/src/transformation/Functions/min_reduction.hpp	(revision 1017)
+++ XIOS/trunk/src/transformation/Functions/min_reduction.hpp	(revision 1018)
@@ -26,5 +26,6 @@
                      const double* dataInput,
                      CArray<double,1>& dataOut,
-                     std::vector<bool>& flagInitial);
+                     std::vector<bool>& flagInitial,
+                     const double& defaultValue);
 
   virtual ~CMinReductionAlgorithm() {}
Index: XIOS/trunk/src/transformation/Functions/reduction.hpp
===================================================================
--- XIOS/trunk/src/transformation/Functions/reduction.hpp	(revision 1017)
+++ XIOS/trunk/src/transformation/Functions/reduction.hpp	(revision 1018)
@@ -45,5 +45,6 @@
                      const double* dataInput,
                      CArray<double,1>& dataOut,
-                     std::vector<bool>& flagInitial) = 0;
+                     std::vector<bool>& flagInitial,
+                     const double& defaultValue) = 0;
   /*!
     Update local data 
Index: XIOS/trunk/src/transformation/Functions/sum_reduction.cpp
===================================================================
--- XIOS/trunk/src/transformation/Functions/sum_reduction.cpp	(revision 1017)
+++ XIOS/trunk/src/transformation/Functions/sum_reduction.cpp	(revision 1018)
@@ -3,9 +3,10 @@
    \author Ha NGUYEN
    \since 27 June 2016
-   \date 27 June 2016
+   \date 9 Jan 2017
 
    \brief sum reduction
  */
 #include "sum_reduction.hpp"
+#include "utils.hpp"
 
 namespace xios {
@@ -29,21 +30,45 @@
                                    const double* dataInput,
                                    CArray<double,1>& dataOut,
-                                   std::vector<bool>& flagInitial)
+                                   std::vector<bool>& flagInitial,
+                                   const double& defaultValue)
 {
-  int nbLocalIndex = localIndex.size();
-  int currentlocalIndex = 0;
-  double currentWeight  = 0.0;
-  for (int idx = 0; idx < nbLocalIndex; ++idx)
+  bool hasMissingValue = NumTraits<double>::isnan(defaultValue);
+  if (hasMissingValue)
   {
-    currentlocalIndex = localIndex[idx].first;
-    currentWeight     = localIndex[idx].second;
-    if (flagInitial[currentlocalIndex])
+    int nbLocalIndex = localIndex.size();
+    int currentlocalIndex = 0;    
+    for (int idx = 0; idx < nbLocalIndex; ++idx)
     {
-      dataOut(currentlocalIndex) = *(dataInput + idx);
-      flagInitial[currentlocalIndex] = false;
-    }
-    else
+      currentlocalIndex = localIndex[idx].first;   
+      if (!NumTraits<double>::isnan(*(dataInput + idx)))
+      {   
+        if (flagInitial[currentlocalIndex])
+        {
+          dataOut(currentlocalIndex) = *(dataInput + idx);
+          flagInitial[currentlocalIndex] = false;
+        }
+        else
+        {
+          dataOut(currentlocalIndex) += *(dataInput + idx);
+        }
+      }
+    }    
+  }
+  else
+  {
+    int nbLocalIndex = localIndex.size();
+    int currentlocalIndex = 0;    
+    for (int idx = 0; idx < nbLocalIndex; ++idx)
     {
-      dataOut(currentlocalIndex) += *(dataInput + idx);
+      currentlocalIndex = localIndex[idx].first;      
+      if (flagInitial[currentlocalIndex])
+      {
+        dataOut(currentlocalIndex) = *(dataInput + idx);
+        flagInitial[currentlocalIndex] = false;
+      }
+      else
+      {
+        dataOut(currentlocalIndex) += *(dataInput + idx);
+      }
     }
   }
Index: XIOS/trunk/src/transformation/Functions/sum_reduction.hpp
===================================================================
--- XIOS/trunk/src/transformation/Functions/sum_reduction.hpp	(revision 1017)
+++ XIOS/trunk/src/transformation/Functions/sum_reduction.hpp	(revision 1018)
@@ -26,5 +26,6 @@
                      const double* dataInput,
                      CArray<double,1>& dataOut,
-                     std::vector<bool>& flagInitial);
+                     std::vector<bool>& flagInitial,
+                     const double& defaultValue);
 
   virtual ~CSumReductionAlgorithm() {}
Index: XIOS/trunk/src/transformation/axis_algorithm_extract_domain.cpp
===================================================================
--- XIOS/trunk/src/transformation/axis_algorithm_extract_domain.cpp	(revision 1017)
+++ XIOS/trunk/src/transformation/axis_algorithm_extract_domain.cpp	(revision 1018)
@@ -71,5 +71,5 @@
                                         const double& defaultValue)
 {
-  reduction_->apply(localIndex, dataInput, dataOut, flagInitial);
+  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, defaultValue);
 }
 
Index: XIOS/trunk/src/transformation/axis_algorithm_reduce_domain.cpp
===================================================================
--- XIOS/trunk/src/transformation/axis_algorithm_reduce_domain.cpp	(revision 1017)
+++ XIOS/trunk/src/transformation/axis_algorithm_reduce_domain.cpp	(revision 1018)
@@ -79,5 +79,5 @@
                                        const double& defaultValue)
 {
-  reduction_->apply(localIndex, dataInput, dataOut, flagInitial);
+  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, defaultValue);
 }
 
Index: XIOS/trunk/src/transformation/generic_algorithm_transformation.cpp
===================================================================
--- XIOS/trunk/src/transformation/generic_algorithm_transformation.cpp	(revision 1017)
+++ XIOS/trunk/src/transformation/generic_algorithm_transformation.cpp	(revision 1018)
@@ -11,4 +11,5 @@
 #include "context_client.hpp"
 #include "client_client_dht_template.hpp"
+#include "utils.hpp"
 
 namespace xios {
@@ -31,11 +32,11 @@
                                             const double& defaultValue)
 {
-  int nbLocalIndex = localIndex.size();
-  bool hasMissingValue = (0.0 != defaultValue) ? true : false;
+  int nbLocalIndex = localIndex.size();  
+  bool hasMissingValue = NumTraits<double>::isnan(defaultValue);  
   if (hasMissingValue)
   {
     for (int idx = 0; idx < nbLocalIndex; ++idx)
     {
-      if (defaultValue == *(dataInput + idx))
+      if (NumTraits<double>::isnan(*(dataInput + idx)))
       {
         flagInitial[localIndex[idx].first] = false;
Index: XIOS/trunk/src/transformation/scalar_algorithm_extract_axis.cpp
===================================================================
--- XIOS/trunk/src/transformation/scalar_algorithm_extract_axis.cpp	(revision 1017)
+++ XIOS/trunk/src/transformation/scalar_algorithm_extract_axis.cpp	(revision 1018)
@@ -58,5 +58,5 @@
                                          const double& defaultValue)
 {
-  reduction_->apply(localIndex, dataInput, dataOut, flagInitial);
+  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, defaultValue);
 }
 
Index: XIOS/trunk/src/transformation/scalar_algorithm_reduce_axis.cpp
===================================================================
--- XIOS/trunk/src/transformation/scalar_algorithm_reduce_axis.cpp	(revision 1017)
+++ XIOS/trunk/src/transformation/scalar_algorithm_reduce_axis.cpp	(revision 1018)
@@ -90,5 +90,5 @@
                                          const double& defaultValue)
 {
-  reduction_->apply(localIndex, dataInput, dataOut, flagInitial);
+  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, defaultValue);
 }
 
Index: XIOS/trunk/src/transformation/scalar_algorithm_reduce_domain.cpp
===================================================================
--- XIOS/trunk/src/transformation/scalar_algorithm_reduce_domain.cpp	(revision 1017)
+++ XIOS/trunk/src/transformation/scalar_algorithm_reduce_domain.cpp	(revision 1018)
@@ -84,5 +84,5 @@
                                          const double& defaultValue)
 {
-  reduction_->apply(localIndex, dataInput, dataOut, flagInitial);
+  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, defaultValue);
 }
 
Index: XIOS/trunk/src/utils.hpp
===================================================================
--- XIOS/trunk/src/utils.hpp	(revision 1017)
+++ XIOS/trunk/src/utils.hpp	(revision 1018)
@@ -257,4 +257,7 @@
     return 1e-12;
   }
+  static inline bool isnan(const Scalar& v) {
+    return (v != v);
+  }
 };
 
