Index: XIOS/trunk/src/node/context.cpp
===================================================================
--- XIOS/trunk/src/node/context.cpp	(revision 639)
+++ XIOS/trunk/src/node/context.cpp	(revision 640)
@@ -46,4 +46,5 @@
 
    //----------------------------------------------------------------
+
    /*!
    \brief Get context group (context root)
@@ -56,6 +57,6 @@
    }
 
-
    //----------------------------------------------------------------
+
    /*!
    \brief Get calendar of a context
@@ -68,4 +69,5 @@
 
    //----------------------------------------------------------------
+
    /*!
    \brief Set a context with a calendar
@@ -386,7 +388,9 @@
     if (hasClient)
     {
+      //this->buildAllExpressionOfEnabledFields();
+      //buildAllExpressionOfFieldsWithReadAccess();
+      this->buildFilterGraphOfEnabledFields();
+      buildFilterGraphOfFieldsWithReadAccess();
       this->solveAllRefOfEnabledFields(true);
-      this->buildAllExpressionOfEnabledFields();
-      buildAllExpressionOfFieldsWithReadAccess();
     }
 
@@ -426,4 +430,13 @@
      {
        this->enabledFiles[i]->buildAllExpressionOfEnabledFields();
+     }
+   }
+
+   void CContext::buildFilterGraphOfEnabledFields()
+   {
+     int size = this->enabledFiles.size();
+     for (int i = 0; i < size; ++i)
+     {
+       this->enabledFiles[i]->buildFilterGraphOfEnabledFields(garbageCollector);
      }
    }
@@ -474,4 +487,10 @@
     for (size_t i = 0; i < fieldsWithReadAccess.size(); ++i)
       fieldsWithReadAccess[i]->buildAllExpressionEnabledField();
+  }
+
+  void CContext::buildFilterGraphOfFieldsWithReadAccess()
+  {
+    for (size_t i = 0; i < fieldsWithReadAccess.size(); ++i)
+      fieldsWithReadAccess[i]->buildFilterGraph(garbageCollector, true);
   }
 
Index: XIOS/trunk/src/node/context.hpp
===================================================================
--- XIOS/trunk/src/node/context.hpp	(revision 639)
+++ XIOS/trunk/src/node/context.hpp	(revision 640)
@@ -112,4 +112,5 @@
          void solveAllRefOfEnabledFields(bool sendToServer);
          void buildAllExpressionOfEnabledFields();
+         void buildFilterGraphOfEnabledFields();
          void startPrefetchingOfEnabledReadModeFiles();
          void checkPrefetchingOfEnabledReadModeFiles();
@@ -117,4 +118,5 @@
          void solveAllRefOfFieldsWithReadAccess();
          void buildAllExpressionOfFieldsWithReadAccess();
+         void buildFilterGraphOfFieldsWithReadAccess();
          void postProcessing();
 
Index: XIOS/trunk/src/node/field.cpp
===================================================================
--- XIOS/trunk/src/node/field.cpp	(revision 639)
+++ XIOS/trunk/src/node/field.cpp	(revision 640)
@@ -14,4 +14,8 @@
 #include "context_server.hpp"
 #include <set>
+#include "garbage_collector.hpp"
+#include "source_filter.hpp"
+#include "store_filter.hpp"
+#include "file_writer_filter.hpp"
 
 namespace xios{
@@ -31,5 +35,5 @@
       , isReadDataRequestPending(false)
       , filterSources_()
-      { setVirtualVariableGroup(); }
+   { setVirtualVariableGroup(); }
 
    CField::CField(const StdString& id)
@@ -456,5 +460,24 @@
     CContext* context = CContext::getCurrent();
     StdSize record;
+    std::map<int, CArray<double,1> > data;
+
     for (int i = 0; i < ranks.size(); i++)
+    {
+      int rank = ranks[i];
+      *buffers[i] >> record;
+      isEOF = (record == size_t(-1));
+
+      if (!isEOF)
+        *buffers[i] >> data[rank];
+      else
+        break;
+    }
+
+    if (isEOF)
+      serverSourceFilter->signalEndOfStream(lastDataRequestedFromServer);
+    else
+      serverSourceFilter->streamDataFromServer(lastDataRequestedFromServer, data);
+
+    /*for (int i = 0; i < ranks.size(); i++)
     {
       int rank = ranks[i];
@@ -487,5 +510,5 @@
         if (hasFieldOut) updateDataFromExpression(instantData);
       }
-    }
+    }*/
 
     isReadDataRequestPending = false;
@@ -633,5 +656,7 @@
       using namespace func;
 
-      if (!hasOutputFile && !hasFieldOut) return;
+      CContext* context = CContext::getCurrent();
+
+      if (!context->hasServer || !hasOutputFile) return;
 
       StdString id;
@@ -639,6 +664,4 @@
       else if (!name.isEmpty()) id = name;
       else if (hasDirectFieldReference()) id = baseRefObject->getId();
-
-      CContext* context = CContext::getCurrent();
 
       if (freq_op.isEmpty()) freq_op.setValue(TimeStep);
@@ -722,4 +745,43 @@
                << "The operation is not defined !");
 //      }
+   }
+
+   //----------------------------------------------------------------
+
+   /*!
+    * Constructs the graph filter for the field, enabling or not the data output.
+    * This method should not be called more than once with enableOutput equal to true.
+    *
+    * \param gc the garbage collector to use when building the filter graph
+    * \param enableOutput must be true when the field data is to be
+    *                     read by the client or/and written to a file
+    */
+   void CField::buildFilterGraph(CGarbageCollector& gc, bool enableOutput)
+   {
+     // Start by building a filter which can provide the field's instant data
+     if (!instantDataFilter)
+     {
+       // Check if the data is to be read from a file
+       if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read)
+         instantDataFilter = serverSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid));
+       else // The data might be passed from the model
+         instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid));
+     }
+
+     // If the field data is to be read by the client or/and written to a file
+     if (enableOutput && !storeFilter && !fileWriterFilter)
+     {
+       if (!read_access.isEmpty() && read_access.getValue())
+       {
+         storeFilter = boost::shared_ptr<CStoreFilter>(new CStoreFilter(gc, CContext::getCurrent(), grid));
+         instantDataFilter->connectOutput(storeFilter, 0);
+       }
+
+       if (file && (file->mode.isEmpty() || file->mode == CFile::mode_attr::write))
+       {
+         fileWriterFilter = boost::shared_ptr<CFileWriterFilter>(new CFileWriterFilter(gc, this));
+         instantDataFilter->connectOutput(fileWriterFilter, 0);
+       }
+     }
    }
 
Index: XIOS/trunk/src/node/field.hpp
===================================================================
--- XIOS/trunk/src/node/field.hpp	(revision 639)
+++ XIOS/trunk/src/node/field.hpp	(revision 640)
@@ -28,6 +28,12 @@
    class CFile;
    class CGrid;
-   class CContext ;
+   class CContext;
    class CGenericFilter;
+
+   class CGarbageCollector;
+   class COutputPin;
+   class CSourceFilter;
+   class CStoreFilter;
+   class CFileWriterFilter;
 
    ///--------------------------------------------------------------
@@ -124,4 +130,6 @@
          void solveTransformedGrid();
          CGrid* getGridRefOfBaseReference();
+
+         void buildFilterGraph(CGarbageCollector& gc, bool enableOutput);
 
 //         virtual void fromBinary(StdIStream & is);
@@ -233,4 +241,15 @@
          DECLARE_REF_FUNC(Field,field)
 
+      private:
+         //! The output pin of the filter providing the instant data for the field
+         boost::shared_ptr<COutputPin> instantDataFilter;
+         //! The source filter for data provided by the client
+         boost::shared_ptr<CSourceFilter> clientSourceFilter;
+         //! The source filter for data provided by the server
+         boost::shared_ptr<CSourceFilter> serverSourceFilter;
+         //! The terminal filter which stores the instant data
+         boost::shared_ptr<CStoreFilter> storeFilter;
+         //! The terminal filter which writes the data to file
+         boost::shared_ptr<CFileWriterFilter> fileWriterFilter;
    }; // class CField
 
Index: XIOS/trunk/src/node/field_impl.hpp
===================================================================
--- XIOS/trunk/src/node/field_impl.hpp	(revision 639)
+++ XIOS/trunk/src/node/field_impl.hpp	(revision 640)
@@ -9,4 +9,6 @@
 #include "timer.hpp"
 #include "array_new.hpp"
+#include "source_filter.hpp"
+#include "store_filter.hpp"
 
 
@@ -16,5 +18,11 @@
   void CField::setData(const CArray<double, N>& _data)
   {
-    if (hasInstantData)
+    if (clientSourceFilter)
+      clientSourceFilter->streamData(CContext::getCurrent()->getCalendar()->getCurrentDate(), _data);
+    else if (!field_ref.isEmpty() || !content.empty())
+      ERROR("void CField::setData(const CArray<double, N>& _data)",
+            << "Impossible to receive data from the model for a field [ id = " << getId() << " ] with a reference or an arithmetic operation.");
+
+    /*if (hasInstantData)
     {
       grid->inputField(_data, instantData);
@@ -52,5 +60,5 @@
       }
       if (hasOutputFile || hasFieldOut) updateData(_data);
-    }
+    }*/
   }
 
@@ -279,7 +287,13 @@
   void CField::getData(CArray<double, N>& _data) const
   {
-    if (!read_access.isEmpty() && read_access.getValue() && hasInstantData)
-    {
-      CContext* context = CContext::getCurrent();
+    if (storeFilter)
+    {
+      CDataPacket::StatusCode status = storeFilter->getData(CContext::getCurrent()->getCalendar()->getCurrentDate(), _data);
+
+      if (status == CDataPacket::END_OF_STREAM)
+        ERROR("void CField::getData(CArray<double, N>& _data) const",
+              << "Impossible to access field data, all the records of the field [ id = " << getId() << " ] have been already read.");
+
+      /*CContext* context = CContext::getCurrent();
       const CDate& currentDate = context->getCalendar()->getCurrentDate();
 
@@ -291,5 +305,5 @@
               << "Impossible to access field data, all the records of the field [ id = " << getId() << " ] have been already read.");
 
-      grid->outputField(instantData, _data);
+      grid->outputField(instantData, _data);*/
     }
     else
Index: XIOS/trunk/src/node/file.cpp
===================================================================
--- XIOS/trunk/src/node/file.cpp	(revision 639)
+++ XIOS/trunk/src/node/file.cpp	(revision 640)
@@ -622,4 +622,18 @@
 
    /*!
+    * Constructs the filter graph for each active field.
+    *
+    * \param gc the garbage collector to use when building the filter graph
+    */
+   void CFile::buildFilterGraphOfEnabledFields(CGarbageCollector& gc)
+   {
+     int size = this->enabledFields.size();
+     for (int i = 0; i < size; ++i)
+     {
+       this->enabledFields[i]->buildFilterGraph(gc, true);
+     }
+   }
+
+   /*!
      Prefetching the data for enabled fields read from file.
    */
Index: XIOS/trunk/src/node/file.hpp
===================================================================
--- XIOS/trunk/src/node/file.hpp	(revision 639)
+++ XIOS/trunk/src/node/file.hpp	(revision 640)
@@ -22,4 +22,6 @@
    class CFileAttributes;
    class CFile;
+
+   class CGarbageCollector;
 
    ///--------------------------------------------------------------
@@ -108,4 +110,5 @@
          void solveAllRefOfEnabledFields(bool sendToServer);
          void buildAllExpressionOfEnabledFields();
+         void buildFilterGraphOfEnabledFields(CGarbageCollector& gc);
          void prefetchEnabledReadModeFields();
          void prefetchEnabledReadModeFieldsIfNeeded();
