Index: /XIOS/trunk/src/filter/file_writer_filter.cpp
===================================================================
--- /XIOS/trunk/src/filter/file_writer_filter.cpp	(revision 1185)
+++ /XIOS/trunk/src/filter/file_writer_filter.cpp	(revision 1186)
@@ -17,19 +17,21 @@
   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)
+    CDataPacketPtr packet = data[0];
+
+    const bool detectMissingValue = (!field->detect_missing_value.isEmpty()
+                                      && !field->default_value.isEmpty()
+                                      && field->detect_missing_value == true);
+    if (detectMissingValue)
     {
-      double missingValue = field->default_value;
-      size_t nbData = data[0]->data.numElements();
+      const double missingValue = field->default_value;
+      const size_t nbData = packet->data.numElements();
       for (size_t idx = 0; idx < nbData; ++idx)
       {
-        if (NumTraits<double>::isnan(data[0]->data(idx)))
-          data[0]->data(idx) = missingValue;
+        if (NumTraits<double>::isnan(packet->data(idx)))
+          packet->data(idx) = missingValue;
       }
-    }    
+    }
 
-    field->sendUpdateData(data[0]->data);
+    field->sendUpdateData(packet->data);
   }
 
Index: /XIOS/trunk/src/filter/source_filter.cpp
===================================================================
--- /XIOS/trunk/src/filter/source_filter.cpp	(revision 1185)
+++ /XIOS/trunk/src/filter/source_filter.cpp	(revision 1186)
@@ -37,6 +37,6 @@
     if (hasMissingValue)
     {
-      double nanValue = std::numeric_limits<double>::quiet_NaN();
-      size_t nbData = packet->data.numElements();
+      const double nanValue = std::numeric_limits<double>::quiet_NaN();
+      const size_t nbData = packet->data.numElements();
       for (size_t idx = 0; idx < nbData; ++idx)
       {
@@ -82,4 +82,16 @@
     }
 
+    // Convert missing values to NaN
+    if (hasMissingValue)
+    {
+      const double nanValue = std::numeric_limits<double>::quiet_NaN();
+      const 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 1185)
+++ /XIOS/trunk/src/filter/source_filter.hpp	(revision 1186)
@@ -62,6 +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;
+      const bool hasMissingValue;
+      const double defaultValue;
   }; // class CSourceFilter
 } // namespace xios
Index: /XIOS/trunk/src/filter/store_filter.cpp
===================================================================
--- /XIOS/trunk/src/filter/store_filter.cpp	(revision 1185)
+++ /XIOS/trunk/src/filter/store_filter.cpp	(revision 1186)
@@ -6,9 +6,12 @@
 namespace xios
 {
-  CStoreFilter::CStoreFilter(CGarbageCollector& gc, CContext* context, CGrid* grid)
+  CStoreFilter::CStoreFilter(CGarbageCollector& gc, CContext* context, CGrid* grid,
+                             bool detectMissingValues /*= false*/, double missingValue /*= 0.0*/)
     : CInputPin(gc, 1)
     , gc(gc)
     , context(context)
     , grid(grid)
+    , detectMissingValues(detectMissingValues)
+    , missingValue(missingValue)
   {
     if (!context)
@@ -75,8 +78,20 @@
   void CStoreFilter::onInputReady(std::vector<CDataPacketPtr> data)
   {
-    packets.insert(std::make_pair(data[0]->timestamp, data[0]));
+    CDataPacketPtr packet = data[0];
+
+    packets.insert(std::make_pair(packet->timestamp, packet));
     // The packet is always destroyed by the garbage collector
     // so we register but never unregister
-    gc.registerObject(this, data[0]->timestamp);
+    gc.registerObject(this, packet->timestamp);
+
+    if (detectMissingValues)
+    {
+      const size_t nbData = packet->data.numElements();
+      for (size_t idx = 0; idx < nbData; ++idx)
+      {
+        if (NumTraits<double>::isnan(packet->data(idx)))
+          packet->data(idx) = missingValue;
+      }
+    }
   }
 
Index: /XIOS/trunk/src/filter/store_filter.hpp
===================================================================
--- /XIOS/trunk/src/filter/store_filter.hpp	(revision 1185)
+++ /XIOS/trunk/src/filter/store_filter.hpp	(revision 1186)
@@ -22,6 +22,9 @@
        * \param context the context to which the data belongs
        * \param grid the grid to which the data is attached
+       * \param detectMissingValues whether missing values should be detected
+       * \param missingValue the value to use to replace missing values
        */
-      CStoreFilter(CGarbageCollector& gc, CContext* context, CGrid* grid);
+      CStoreFilter(CGarbageCollector& gc, CContext* context, CGrid* grid,
+                   bool detectMissingValues = false, double missingValue = 0.0);
 
       /*!
@@ -75,4 +78,6 @@
       CContext* context; //!< The context to which the data belongs
       CGrid* grid; //!< The grid attached to the data the filter can accept
+      const bool detectMissingValues; //!< Whether missing values should be detected
+      const double missingValue; //!< The value to use to replace missing values
       std::map<Time, CDataPacketPtr> packets; //<! The stored packets
   }; // class CStoreFilter
Index: /XIOS/trunk/src/node/field.cpp
===================================================================
--- /XIOS/trunk/src/node/field.cpp	(revision 1185)
+++ /XIOS/trunk/src/node/field.cpp	(revision 1186)
@@ -788,4 +788,7 @@
      if (!areAllReferenceSolved) solveAllReferenceEnabledField(false);
 
+     const bool detectMissingValues = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true);
+     const double defaultValue  = detectMissingValues ? default_value : (!default_value.isEmpty() ? default_value : 0.0);
+
      // Start by building a filter which can provide the field's instant data
      if (!instantDataFilter)
@@ -804,7 +807,5 @@
            if (grid && grid != gridRef && grid->hasTransform())
            {
-             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);
+             std::pair<boost::shared_ptr<CFilter>, boost::shared_ptr<CFilter> > filters = CSpatialTransformFilter::buildFilterGraph(gc, gridRef, grid, detectMissingValues, defaultValue);
 
              filter->connectOutput(filters.first, 0);
@@ -822,12 +823,12 @@
          instantDataFilter = serverSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid,
                                                                                                      freq_offset.isEmpty() ? NoneDu : freq_offset,
-                                                                                                     true));
+                                                                                                     true,
+                                                                                                     detectMissingValues, defaultValue));
        else // The data might be passed from the model
        {
           if (check_if_active.isEmpty()) check_if_active = false;
-          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));       }
+                                                                                                      detectMissingValues, defaultValue));
+       }
      }
 
@@ -837,5 +838,6 @@
        if (!read_access.isEmpty() && read_access)
        {
-         storeFilter = boost::shared_ptr<CStoreFilter>(new CStoreFilter(gc, CContext::getCurrent(), grid));
+         storeFilter = boost::shared_ptr<CStoreFilter>(new CStoreFilter(gc, CContext::getCurrent(), grid,
+                                                                        detectMissingValues, defaultValue));
          instantDataFilter->connectOutput(storeFilter, 0);
        }
@@ -898,4 +900,7 @@
      if (!selfReferenceFilter)
      {
+       const bool detectMissingValues = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true);
+       const double defaultValue  = detectMissingValues ? default_value : (!default_value.isEmpty() ? default_value : 0.0);
+
        if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read)
        {
@@ -903,5 +908,6 @@
            serverSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid,
                                                                                    freq_offset.isEmpty() ? NoneDu : freq_offset,
-                                                                                   true));
+                                                                                   true,
+                                                                                   detectMissingValues, defaultValue));
 
          selfReferenceFilter = serverSourceFilter;
@@ -918,8 +924,6 @@
          {
            if (check_if_active.isEmpty()) check_if_active = false;
-           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));
+                                                                                   detectMissingValues, defaultValue));
          }
 
@@ -955,10 +959,10 @@
          freq_offset.setValue(NoneDu);
 
-       const bool ignoreMissingValue = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true);
+       const bool detectMissingValues = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true);
        
        boost::shared_ptr<CTemporalFilter> temporalFilter(new CTemporalFilter(gc, operation,
                                                                              CContext::getCurrent()->getCalendar()->getInitDate(),
                                                                              freq_op, freq_offset, outFreq,
-                                                                             ignoreMissingValue, ignoreMissingValue ? default_value : 0.0));
+                                                                             detectMissingValues, detectMissingValues ? default_value : 0.0));
        instantDataFilter->connectOutput(temporalFilter, 0);
 
@@ -995,10 +999,10 @@
        if (freq_offset.isEmpty()) freq_offset.setValue(NoneDu);
 
-       const bool ignoreMissingValue = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true);
+       const bool detectMissingValues = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true);
 
        boost::shared_ptr<CTemporalFilter> temporalFilter(new CTemporalFilter(gc, operation,
                                                                              CContext::getCurrent()->getCalendar()->getInitDate(),
                                                                              freq_op, freq_offset, outFreq,
-                                                                             ignoreMissingValue, ignoreMissingValue ? default_value : 0.0));
+                                                                             detectMissingValues, detectMissingValues ? default_value : 0.0));
        selfReferenceFilter->connectOutput(temporalFilter, 0);
        return temporalFilter ;
