Index: XIOS/dev/dev_trunk_omp/src/cxios.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/src/cxios.cpp	(revision 1669)
+++ XIOS/dev/dev_trunk_omp/src/cxios.cpp	(revision 1670)
@@ -357,2 +357,3 @@
   }
 }
+
Index: XIOS/dev/dev_trunk_omp/src/filter/file_writer_filter.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/src/filter/file_writer_filter.cpp	(revision 1669)
+++ XIOS/dev/dev_trunk_omp/src/filter/file_writer_filter.cpp	(revision 1670)
@@ -16,6 +16,14 @@
     if (buildWorkflowGraph)
     {
-      filterId = InvalidableObject::count;
-      InvalidableObject::count++;
+      if(InvalidableObject::count_ptr == 0) InvalidableObject::count_ptr = new std::map< StdString, int>;
+      if(InvalidableObject::count_ptr->find(CWorkflowGraph::my_filename) == InvalidableObject::count_ptr->end())
+      {
+        (*InvalidableObject::count_ptr)[CWorkflowGraph::my_filename] = 0; 
+      }
+      //filterId = InvalidableObject::count;
+      filterId = (*InvalidableObject::count_ptr)[CWorkflowGraph::my_filename];
+      printf("file_writer_filter ================ filterId = %d\n", (*InvalidableObject::count_ptr)[CWorkflowGraph::my_filename]);
+      (*InvalidableObject::count_ptr)[CWorkflowGraph::my_filename]++;
+      //InvalidableObject::count++;
     }
   }
Index: XIOS/dev/dev_trunk_omp/src/filter/garbage_collector.hpp
===================================================================
--- XIOS/dev/dev_trunk_omp/src/filter/garbage_collector.hpp	(revision 1669)
+++ XIOS/dev/dev_trunk_omp/src/filter/garbage_collector.hpp	(revision 1670)
@@ -20,4 +20,7 @@
      */
     void virtual invalidate(Time timestamp) = 0;
+
+    static std::map<StdString, int> *count_ptr;
+    #pragma omp threadprivate(count_ptr)
   
     static int count; //!< Counter used to identify a filter in case building workflow graph
Index: XIOS/dev/dev_trunk_omp/src/filter/output_pin.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/src/filter/output_pin.cpp	(revision 1669)
+++ XIOS/dev/dev_trunk_omp/src/filter/output_pin.cpp	(revision 1670)
@@ -12,6 +12,16 @@
     if (buildWorkflowGraph)
     {
-      filterId = InvalidableObject::count;
-      InvalidableObject::count++;
+      if(InvalidableObject::count_ptr == 0) InvalidableObject::count_ptr = new std::map< StdString, int>;
+      if(InvalidableObject::count_ptr->find(CWorkflowGraph::my_filename) == InvalidableObject::count_ptr->end())
+      {
+        (*InvalidableObject::count_ptr)[CWorkflowGraph::my_filename] = 0; 
+      }
+  
+      filterId = (*InvalidableObject::count_ptr)[CWorkflowGraph::my_filename];
+      printf("output_pin ================ filterId = %d, CWorkflowGraph::my_filename = %s\n", (*InvalidableObject::count_ptr)[CWorkflowGraph::my_filename], CWorkflowGraph::my_filename.c_str());
+      (*InvalidableObject::count_ptr)[CWorkflowGraph::my_filename]++;
+
+      //filterId = InvalidableObject::count;
+      //InvalidableObject::count++;
     }
   }
@@ -42,8 +52,8 @@
     if (buildWorkflowGraph)
     {
-    	if(CWorkflowGraph::mapFilterTimestamps_ptr==0) CWorkflowGraph::mapFilterTimestamps_ptr = new std::unordered_map <int, vector<Time> >;
-      if(CWorkflowGraph::timestamps_ptr==0) CWorkflowGraph::timestamps_ptr = new set<Time>;
-      (*CWorkflowGraph::mapFilterTimestamps_ptr)[this->getFilterId()].push_back(packet->timestamp);
-    	CWorkflowGraph::timestamps_ptr->insert(packet->timestamp);
+    	if(CWorkflowGraph::mapFilterTimestamps_ptr==0) CWorkflowGraph::mapFilterTimestamps_ptr = new std::unordered_map<StdString, std::unordered_map <int, vector<Time> > >; 
+      if(CWorkflowGraph::timestamps_ptr==0) CWorkflowGraph::timestamps_ptr = new std::unordered_map< StdString, set<Time> >;
+      (*CWorkflowGraph::mapFilterTimestamps_ptr)[CWorkflowGraph::my_filename][this->getFilterId()].push_back(packet->timestamp);
+      (*CWorkflowGraph::timestamps_ptr)[CWorkflowGraph::my_filename].insert(packet->timestamp);
     }
 
Index: XIOS/dev/dev_trunk_omp/src/filter/spatial_transform_filter.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/src/filter/spatial_transform_filter.cpp	(revision 1669)
+++ XIOS/dev/dev_trunk_omp/src/filter/spatial_transform_filter.cpp	(revision 1670)
@@ -56,14 +56,14 @@
         if (buildWorkflowGraph)
         {
-          if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map <int, StdString>;
-          if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map <StdString, vector <int> >;
+          if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map< StdString, std::unordered_map <int, StdString> >;
+          if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map< StdString, std::unordered_map <StdString, vector <int> > >;
           int filterOut = (std::static_pointer_cast<COutputPin>(filter))->getFilterId();
           int filterIn = (std::static_pointer_cast<COutputPin>(firstFilter))->getFilterId();
           // PASS field's id here
-          (*CWorkflowGraph::mapFieldToFilters_ptr)["XXX"].push_back(filterOut);
-          (*CWorkflowGraph::mapFieldToFilters_ptr)["XXX"].push_back(filterIn);
-          (*CWorkflowGraph::mapFilters_ptr)[filterOut] = "Spatial transform filter";
-          (*CWorkflowGraph::mapFilters_ptr)[filterIn] = "Spatial transform filter";
-          std::cout<<"CSpatialTransformFilter::CSpatialTransformFilter CWorkflowGraph::mapFieldToFilters_ptr->size = "<<CWorkflowGraph::mapFieldToFilters_ptr->size()<<std::endl;
+          (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename]["XXX"].push_back(filterOut);
+          (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename]["XXX"].push_back(filterIn);
+          (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterOut] = "Spatial transform filter";
+          (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterIn] = "Spatial transform filter";
+          //std::cout<<"CSpatialTransformFilter::CSpatialTransformFilter CWorkflowGraph::mapFieldToFilters_ptr->size = "<<CWorkflowGraph::mapFieldToFilters_ptr->size()<<std::endl;
         }
       }
Index: XIOS/dev/dev_trunk_omp/src/graphviz.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/src/graphviz.cpp	(revision 1669)
+++ XIOS/dev/dev_trunk_omp/src/graphviz.cpp	(revision 1670)
@@ -11,4 +11,6 @@
    *
    */
+  
+
   void CGraphviz::buildStaticWorkflowGraph()
   TRY
@@ -16,47 +18,51 @@
     if (CWorkflowGraph::mapFieldToFilters_ptr !=0 && !CWorkflowGraph::mapFieldToFilters_ptr->empty())
     {
-      CWorkflowGraph::buildStaticWorkflow();
+      int NB_graph_files = CWorkflowGraph::mapFieldToFilters_ptr->size();
+      std::unordered_map < StdString, std::unordered_map <StdString, vector <int> > >::iterator it;
+      for(it=CWorkflowGraph::mapFieldToFilters_ptr->begin(); it!=CWorkflowGraph::mapFieldToFilters_ptr->end(); it++)
+      {
+        CWorkflowGraph::buildStaticWorkflow_forfile(it->first);
     
-      typedef boost::property<boost::edge_name_t, std::string> EdgeProperty;
-      typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, boost::no_property, EdgeProperty> Graph;
+        typedef boost::property<boost::edge_name_t, std::string> EdgeProperty;
+        typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, boost::no_property, EdgeProperty> Graph;
 
-      // Input 1: nodes (=filters)
-      vector<StdString>& nodes = CWorkflowGraph::filters;
-      const int nbNodes = nodes.size();
+        // Input 1: nodes (=filters)
+        vector<StdString>& nodes = CWorkflowGraph::filters;
+        const int nbNodes = nodes.size();
 
-      // Input 2: edges (=fields)
-      vector<StdString>& edges = CWorkflowGraph::fields;
+        // Input 2: edges (=fields)
+        vector<StdString>& edges = CWorkflowGraph::fields;
 
-      // Input 3: nodes to edges connectivity
-      vector<pair<int, int> >& nodesToEdges = CWorkflowGraph::fieldsToFilters;
-      const int nbEdges = nodesToEdges.size();
+        // Input 3: nodes to edges connectivity
+        vector<pair<int, int> >& nodesToEdges = CWorkflowGraph::fieldsToFilters;
+        const int nbEdges = nodesToEdges.size();
 
-      // Declare a graph object, adding the edges and edge properties
-      Graph g(nbNodes);
-      for (int j = 0; j < nbEdges; ++j)
-      {
-        graph_traits<Graph>::edge_descriptor e;
-        bool inserted;
-        boost::tie(e, inserted) = boost::add_edge(nodesToEdges[j].first, nodesToEdges[j].second, edges[j], g);
-      }
+        // Declare a graph object, adding the edges and edge properties
+        Graph g(nbNodes);
+        for (int j = 0; j < nbEdges; ++j)
+        {
+          graph_traits<Graph>::edge_descriptor e;
+          bool inserted;
+          boost::tie(e, inserted) = boost::add_edge(nodesToEdges[j].first, nodesToEdges[j].second, edges[j], g);
+        }
 
-      std::for_each(vertices(g).first, vertices(g).second, exercise_vertex<Graph>(g));
+        std::for_each(vertices(g).first, vertices(g).second, exercise_vertex<Graph>(g));
 
-      std::map<std::string,std::string> graph_attr, vertex_attr, edge_attr;
-      graph_attr["size"] = "5,5";
-      graph_attr["rankdir"] = "LR";
-      graph_attr["ratio"] = "fill";
-      vertex_attr["shape"] = "record";
-      vertex_attr["width"] = "2.2";
-      vertex_attr["fontsize"] = "16";
+        std::map<std::string,std::string> graph_attr, vertex_attr, edge_attr;
+        graph_attr["size"] = "5,5";
+        graph_attr["rankdir"] = "LR";
+        graph_attr["ratio"] = "fill";
+        vertex_attr["shape"] = "record";
+        vertex_attr["width"] = "2.2";
+        vertex_attr["fontsize"] = "16";
 
-      const std::string filename = "graph.dot";
-      std::ofstream file (filename.c_str());
+        const std::string filename = it->first + ".static_graph.dot";
+        std::ofstream file (filename.c_str());
 
-      boost::write_graphviz(file, g,
+        boost::write_graphviz(file, g,
           boost::make_label_writer(&nodes[0]),
           boost::make_label_writer(get(edge_name, g)),
           boost::make_graph_attributes_writer(graph_attr, vertex_attr, edge_attr));
-         
+      }
     }
   }
@@ -72,2 +78,3 @@
   CATCH
 }
+
Index: XIOS/dev/dev_trunk_omp/src/graphviz.hpp
===================================================================
--- XIOS/dev/dev_trunk_omp/src/graphviz.hpp	(revision 1669)
+++ XIOS/dev/dev_trunk_omp/src/graphviz.hpp	(revision 1670)
@@ -33,2 +33,3 @@
 
 #endif
+
Index: XIOS/dev/dev_trunk_omp/src/node/field.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/src/node/field.cpp	(revision 1669)
+++ XIOS/dev/dev_trunk_omp/src/node/field.cpp	(revision 1670)
@@ -1197,12 +1197,14 @@
                if (buildWorkflowGraph)
                {
-                 if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map <int, StdString>;
-                 if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map <StdString, vector <int> >;
+                 if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map< StdString, std::unordered_map <int, StdString> >;
+                 if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map< StdString, std::unordered_map <StdString, vector <int> > >;
                  int filterOut = filter->getFilterId();
                  int filterIn = (std::static_pointer_cast<COutputPin>(filters.second))->getFilterId();
-                 (*CWorkflowGraph::mapFieldToFilters_ptr)[this->getOId()].push_back(filterOut);
-                 (*CWorkflowGraph::mapFieldToFilters_ptr)[this->getOId()].push_back(filterIn);
-                 (*CWorkflowGraph::mapFilters_ptr)[filterOut] = filter->GetName();
-                 (*CWorkflowGraph::mapFilters_ptr)[filterIn] = filters.second->GetName();
+                 (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename][this->getOId()].push_back(filterOut);
+                 (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename][this->getOId()].push_back(filterIn);
+                 (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterOut] = filter->GetName();
+                 (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterIn] = filters.second->GetName();
+                 std::cout<<"CField::buildFilterGraph1 filterIn["<<filterIn<< "] = "<<filters.second->GetName()<< std::endl;
+                 std::cout<<"CField::buildFilterGraph1 filterOut["<<filterOut<< "] = "<<filter->GetName()<< std::endl;
                }
                filter = filters.second;
@@ -1232,6 +1234,8 @@
             if (buildWorkflowGraph) 
             {
-              if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map <int, StdString>;
-              (*CWorkflowGraph::mapFilters_ptr)[instantDataFilter->getFilterId()] = instantDataFilter->GetName();
+              //CWorkflowGraph::my_filename = file->name;
+              if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map< StdString, std::unordered_map <int, StdString> >;
+              (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][instantDataFilter->getFilterId()] = instantDataFilter->GetName();
+              std::cout<<"CField::buildFilterGraph1.else filter["<<instantDataFilter->getFilterId()<< "] = "<<instantDataFilter->GetName()<< std::endl;
             }  
          }
@@ -1254,13 +1258,15 @@
            if (buildWorkflowGraph)
            {
-             if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map <int, StdString>;
-             if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map <StdString, vector <int> >;
+             CWorkflowGraph::my_filename = file->name;
+             if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map< StdString, std::unordered_map <int, StdString> >;
+             if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map< StdString, std::unordered_map <StdString, vector <int> > >;
              int filterOut = getTemporalDataFilter(gc, file->output_freq)->getFilterId();
              int filterIn = fileWriterFilter->getFilterId();
-             (*CWorkflowGraph::mapFieldToFilters_ptr)[this->getOId()].push_back(filterOut);
-             (*CWorkflowGraph::mapFieldToFilters_ptr)[this->getOId()].push_back(filterIn);
-             (*CWorkflowGraph::mapFilters_ptr)[filterOut] = "Temporal filter";
-             (*CWorkflowGraph::mapFilters_ptr)[filterIn] = fileWriterFilter->GetName();
-             std::cout<<"CField::buildFilterGraph this->getId() = "<<this->getId() <<" ; this->getOId() = "<<this->getOId()<< std::endl;
+             (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename][this->getOId()].push_back(filterOut);
+             (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename][this->getOId()].push_back(filterIn);
+             (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterOut] = "Temporal filter";
+             (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterIn] = fileWriterFilter->GetName();
+             std::cout<<"CField::buildFilterGraph2 filterIn["<<filterIn<< "] = "<<fileWriterFilter->GetName()<< std::endl;
+             std::cout<<"CField::buildFilterGraph2 filterOut["<<filterOut<< "] = "<<"Temporal filter"<< std::endl;
            }
          }
@@ -1270,4 +1276,158 @@
    CATCH_DUMP_ATTR
 
+   void CField::buildFilterGraph(CGarbageCollector& gc, bool enableOutput, StdString output_filename)
+   TRY
+   {     
+    CWorkflowGraph::my_filename = output_filename;
+    if (!isReferenceSolvedAndTransformed) solveAllEnabledFieldsAndTransform();
+    if (!isGridChecked) checkGridOfEnabledFields();
+
+     const bool detectMissingValues = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true);
+     const bool buildWorkflowGraph = (!build_workflow_graph.isEmpty() && build_workflow_graph == true);
+     const double defaultValue  = detectMissingValues ? default_value : (!default_value.isEmpty() ? default_value : 0.0);
+
+     CContext* context = CContext::getCurrent();
+     bool hasWriterServer = context->hasServer && !context->hasClient;
+     bool hasIntermediateServer = context->hasServer && context->hasClient;
+
+     if (hasWriterServer)
+     {
+        if (!instantDataFilter)
+          instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, false));
+
+
+       // If the field data is to be read by the client or/and written to a file
+       if (enableOutput && !storeFilter && !fileWriterFilter)
+       {
+         if (file && (file->mode.isEmpty() || file->mode == CFile::mode_attr::write))
+         {
+           fileServerWriterFilter = std::shared_ptr<CFileServerWriterFilter>(new CFileServerWriterFilter(gc, this));
+           instantDataFilter->connectOutput(fileServerWriterFilter, 0);
+         }
+       }
+     }
+     else if (hasIntermediateServer)
+     {
+       if (!instantDataFilter)
+         instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, false, false));
+
+             // If the field data is to be read by the client or/and written to a file
+       if (enableOutput && !storeFilter && !fileWriterFilter)
+       {
+         if (file && (file->mode.isEmpty() || file->mode == CFile::mode_attr::write))
+         {
+           fileWriterFilter = std::shared_ptr<CFileWriterFilter>(new CFileWriterFilter(gc, this));
+           instantDataFilter->connectOutput(fileWriterFilter, 0);
+         }
+       }
+     }
+     else
+     {
+       // Start by building a filter which can provide the field's instant data
+       if (!instantDataFilter)
+       {
+         // Check if we have an expression to parse
+         if (hasExpression())
+         {
+           boost::scoped_ptr<IFilterExprNode> expr(parseExpr(getExpression() + '\0'));
+           std::shared_ptr<COutputPin> filter = expr->reduce(gc, *this);
+
+           // Check if a spatial transformation is needed
+           if (!field_ref.isEmpty())
+           {
+             CField* fieldRef = CField::get(field_ref);
+             fieldRef->build_workflow_graph.setValue(buildWorkflowGraph);
+             CGrid* gridRef = fieldRef->grid;
+
+             if (grid && grid != gridRef && grid->hasTransform())
+             {
+               std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = CSpatialTransformFilter::buildFilterGraph(gc, gridRef, grid,
+                                                                                         detectMissingValues, defaultValue, buildWorkflowGraph);
+
+               filter->connectOutput(filters.first, 0);
+
+               if (buildWorkflowGraph)
+               { 
+                 CWorkflowGraph::my_filename = output_filename;
+                 if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map< StdString, std::unordered_map <int, StdString> >;
+                 if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map< StdString, std::unordered_map <StdString, vector <int> > >;
+                 int filterOut = filter->getFilterId();
+                 int filterIn = (std::static_pointer_cast<COutputPin>(filters.second))->getFilterId();
+                 (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename][this->getOId()].push_back(filterOut);
+                 (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename][this->getOId()].push_back(filterIn);
+                 (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterOut] = filter->GetName();
+                 (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterIn] = filters.second->GetName();
+                 std::cout<<"***CField::buildFilterGraph1 filterIn["<<filterIn<< "] = "<<filters.second->GetName()<< std::endl;
+                 std::cout<<"***CField::buildFilterGraph1 filterOut["<<filterOut<< "] = "<<filter->GetName()<< std::endl;
+               }
+               filter = filters.second;
+             }
+           }
+
+           instantDataFilter = filter;
+         }
+         // Check if we have a reference on another field
+         else if (!field_ref.isEmpty())
+         {
+           CField::get(field_ref)->build_workflow_graph.setValue(buildWorkflowGraph);
+           //instantDataFilter = getFieldReference2(gc, output_filename);
+           instantDataFilter = getFieldReference(gc, output_filename);
+         }
+         // Check if the data is to be read from a file
+         else if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read)
+         {
+           checkTimeAttributes();
+           instantDataFilter = serverSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, false, freq_offset, true,
+                                                                                                       detectMissingValues, defaultValue, buildWorkflowGraph));
+         }
+         else // The data might be passed from the model
+         {
+            if (check_if_active.isEmpty()) check_if_active = false; 
+            instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, false, true, NoneDu, false,
+                                                                                                      detectMissingValues, defaultValue, buildWorkflowGraph));
+            if (buildWorkflowGraph) 
+            {
+              CWorkflowGraph::my_filename = output_filename;//CWorkflowGraph::my_filename = file->name;
+              printf("*** *** my_filename = %s\n", CWorkflowGraph::my_filename.c_str());
+              if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map< StdString, std::unordered_map <int, StdString> >;
+              (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][instantDataFilter->getFilterId()] = instantDataFilter->GetName();
+              std::cout<<"***CField::buildFilterGraph1.else filter["<<instantDataFilter->getFilterId()<< "] = "<<instantDataFilter->GetName()<< std::endl;
+            }  
+         }
+       }
+
+       // 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)
+         {
+           storeFilter = std::shared_ptr<CStoreFilter>(new CStoreFilter(gc, CContext::getCurrent(), grid,
+                                                                          detectMissingValues, defaultValue));
+           instantDataFilter->connectOutput(storeFilter, 0);
+         }
+
+         if (file && (file->mode.isEmpty() || file->mode == CFile::mode_attr::write))
+         {
+           fileWriterFilter = std::shared_ptr<CFileWriterFilter>(new CFileWriterFilter(gc, this, buildWorkflowGraph));
+           getTemporalDataFilter(gc, file->output_freq)->connectOutput(fileWriterFilter, 0);
+           if (buildWorkflowGraph)
+           {
+             CWorkflowGraph::my_filename = output_filename;//CWorkflowGraph::my_filename = file->name;
+             if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map< StdString, std::unordered_map <int, StdString> >;
+             if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map< StdString, std::unordered_map <StdString, vector <int> > >;
+             int filterOut = getTemporalDataFilter(gc, file->output_freq)->getFilterId();
+             int filterIn = fileWriterFilter->getFilterId();
+             (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename][this->getOId()].push_back(filterOut);
+             (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename][this->getOId()].push_back(filterIn);
+             (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterOut] = "Temporal filter";
+             (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterIn] = fileWriterFilter->GetName();
+             std::cout<<"***CField::buildFilterGraph2 filterIn["<<filterIn<< "] = "<<fileWriterFilter->GetName()<< std::endl;
+             std::cout<<"***CField::buildFilterGraph2 filterOut["<<filterOut<< "] = "<<"Temporal filter"<< std::endl;
+           }
+         }
+       }
+     }
+   }
+   CATCH_DUMP_ATTR
    /*!
     * Returns the filter needed to handle the field reference.
@@ -1305,17 +1465,65 @@
      if (buildWorkflowGraph)
      {
-       if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map <int, StdString>;
-       if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map <StdString, vector <int> >;
+       CWorkflowGraph::my_filename = file->name;
+       if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map<StdString, std::unordered_map <int, StdString> >;
+       if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map< StdString, std::unordered_map <StdString, vector <int> > >; 
        int filterOut = fieldRef->instantDataFilter->getFilterId();
        int filterIn = (std::static_pointer_cast<COutputPin>(filters.first))->getFilterId();
-       (*CWorkflowGraph::mapFieldToFilters_ptr)[fieldRef->getOId()].push_back(filterOut);
-       (*CWorkflowGraph::mapFieldToFilters_ptr)[fieldRef->getOId()].push_back(filterIn);
-       (*CWorkflowGraph::mapFilters_ptr)[filterOut] = fieldRef->getInstantDataFilter()->GetName();
-       (*CWorkflowGraph::mapFilters_ptr)[filterIn] = filters.first->GetName();
+       (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename][fieldRef->getOId()].push_back(filterOut);
+       (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename][fieldRef->getOId()].push_back(filterIn);
+       (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterOut] = fieldRef->getInstantDataFilter()->GetName();
+       (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterIn] = filters.first->GetName();
+       std::cout<<"CField::getFieldReference filterIn["<<filterIn<< "] = "<<filters.first->GetName()<< std::endl;
+       std::cout<<"CField::getFieldReference filterOut["<<filterOut<< "] = "<<fieldRef->getInstantDataFilter()->GetName()<< std::endl;
      }
      return filters.second;
    }
    CATCH_DUMP_ATTR
-
+  
+   std::shared_ptr<COutputPin> CField::getFieldReference(CGarbageCollector& gc, StdString output_filename)
+   TRY
+   {
+     CWorkflowGraph::my_filename = output_filename;
+     if (instantDataFilter || field_ref.isEmpty())
+       ERROR("COutputPin* CField::getFieldReference(CGarbageCollector& gc)",
+             "Impossible to get the field reference for a field which has already been parsed or which does not have a field_ref.");
+
+     CField* fieldRef = CField::get(field_ref);
+     //fieldRef->buildFilterGraph2(gc, false, output_filename);
+     fieldRef->buildFilterGraph(gc, false, output_filename);
+     bool buildWorkflowGraph = (!build_workflow_graph.isEmpty() && build_workflow_graph == true);
+
+     std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters;
+     // Check if a spatial transformation is needed
+     if (grid && grid != fieldRef->grid && 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);                                
+       filters = CSpatialTransformFilter::buildFilterGraph(gc, fieldRef->grid, grid, hasMissingValue, defaultValue, buildWorkflowGraph);
+     }
+     else
+     {
+       filters.first = filters.second = std::shared_ptr<CFilter>(new CPassThroughFilter(gc, buildWorkflowGraph));
+     }
+
+     fieldRef->getInstantDataFilter()->connectOutput(filters.first, 0);
+
+     if (buildWorkflowGraph)
+     {
+       CWorkflowGraph::my_filename = output_filename;
+       if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map<StdString, std::unordered_map <int, StdString> >;
+       if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map< StdString, std::unordered_map <StdString, vector <int> > >; 
+       int filterOut = fieldRef->instantDataFilter->getFilterId();
+       int filterIn = (std::static_pointer_cast<COutputPin>(filters.first))->getFilterId();
+       (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename][fieldRef->getOId()].push_back(filterOut);
+       (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename][fieldRef->getOId()].push_back(filterIn);
+       (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterOut] = fieldRef->getInstantDataFilter()->GetName();
+       (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterIn] = filters.first->GetName();
+       std::cout<<"CField::getFieldReference filterIn["<<filterIn<< "] = "<<filters.first->GetName()<< std::endl;
+       std::cout<<"CField::getFieldReference filterOut["<<filterOut<< "] = "<<fieldRef->getInstantDataFilter()->GetName()<< std::endl;
+     }
+     return filters.second;
+   }
+   CATCH_DUMP_ATTR
    /*!
     * Returns the filter needed to handle a self reference in the field's expression.
@@ -1405,12 +1613,14 @@
        if (buildWorkflowGraph)
        {
-         if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map <int, StdString>;
-         if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map <StdString, vector <int> >;
+         if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map< StdString, std::unordered_map <int, StdString> >;
+         if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map<StdString, std::unordered_map <StdString, vector <int> > >;
          int filterOut = instantDataFilter->getFilterId();
          int filterIn = (std::static_pointer_cast<COutputPin>(temporalFilter))->getFilterId();
-         (*CWorkflowGraph::mapFieldToFilters_ptr)[this->getOId()].push_back(filterOut);
-         (*CWorkflowGraph::mapFieldToFilters_ptr)[this->getOId()].push_back(filterIn);
-         (*CWorkflowGraph::mapFilters_ptr)[filterOut] = getInstantDataFilter()->GetName();
-         (*CWorkflowGraph::mapFilters_ptr)[filterIn] = temporalFilter->GetName();
+         (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename][this->getOId()].push_back(filterOut);
+         (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename][this->getOId()].push_back(filterIn);
+         (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterOut] = getInstantDataFilter()->GetName();
+         (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterIn] = temporalFilter->GetName();
+         std::cout<<"CField::getTemporalDataFilter filterIn["<<filterIn<< "] = "<<temporalFilter->GetName()<< std::endl;
+         std::cout<<"CField::getTemporalDataFilter filterOut["<<filterOut<< "] = "<<getInstantDataFilter()->GetName()<< std::endl;
        }
 
@@ -1459,12 +1669,14 @@
 
        {
-         if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map <int, StdString>;
-         if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map <StdString, vector <int> >;
+         if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map<StdString, std::unordered_map <int, StdString> >;
+         if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map< StdString, std::unordered_map <StdString, vector <int> > >;
          int filterOut = selfReferenceFilter->getFilterId();
          int filterIn = (std::static_pointer_cast<COutputPin>(temporalFilter))->getFilterId();
-         (*CWorkflowGraph::mapFieldToFilters_ptr)[this->getOId()].push_back(filterOut);
-         (*CWorkflowGraph::mapFieldToFilters_ptr)[this->getOId()].push_back(filterIn);
-         (*CWorkflowGraph::mapFilters_ptr)[filterOut] = selfReferenceFilter->GetName();
-         (*CWorkflowGraph::mapFilters_ptr)[filterIn] = temporalFilter->GetName();
+         (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename][this->getOId()].push_back(filterOut);
+         (*CWorkflowGraph::mapFieldToFilters_ptr)[CWorkflowGraph::my_filename][this->getOId()].push_back(filterIn);
+         (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterOut] = selfReferenceFilter->GetName();
+         (*CWorkflowGraph::mapFilters_ptr)[CWorkflowGraph::my_filename][filterIn] = temporalFilter->GetName();
+         std::cout<<"CField::getSelfTemporalDataFilter filterIn["<<filterIn<< "] = "<<temporalFilter->GetName()<< std::endl;
+         std::cout<<"CField::getSelfTemporalDataFilter filterOut["<<filterOut<< "] = "<<selfReferenceFilter->GetName()<< std::endl;
        }
 
@@ -1993,2 +2205,3 @@
    DEFINE_REF_FUNC(Field,field)
 } // namespace xios
+
Index: XIOS/dev/dev_trunk_omp/src/node/field.hpp
===================================================================
--- XIOS/dev/dev_trunk_omp/src/node/field.hpp	(revision 1669)
+++ XIOS/dev/dev_trunk_omp/src/node/field.hpp	(revision 1670)
@@ -143,8 +143,10 @@
 
          void buildFilterGraph(CGarbageCollector& gc, bool enableOutput);
+         void buildFilterGraph(CGarbageCollector& gc, bool enableOutput, StdString out_filename);
          size_t getGlobalWrittenSize(void) ;
          
          
          std::shared_ptr<COutputPin> getFieldReference(CGarbageCollector& gc);
+         std::shared_ptr<COutputPin> getFieldReference(CGarbageCollector& gc, StdString out_filename);
          std::shared_ptr<COutputPin> getSelfReference(CGarbageCollector& gc);
          std::shared_ptr<COutputPin> getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq);
@@ -295,2 +297,3 @@
 
 #endif // __XIOS_CField__
+
Index: XIOS/dev/dev_trunk_omp/src/node/file.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/src/node/file.cpp	(revision 1669)
+++ XIOS/dev/dev_trunk_omp/src/node/file.cpp	(revision 1670)
@@ -983,5 +983,7 @@
      for (int i = 0; i < size; ++i)
      {
-       this->enabledFields[i]->buildFilterGraph(gc, true);
+       //this->enabledFields[i]->buildFilterGraph(gc, true);
+       //this->enabledFields[i]->buildFilterGraph2(gc, true, this->name);
+      this->enabledFields[i]->buildFilterGraph(gc, true, this->name);
      }
    }
Index: XIOS/dev/dev_trunk_omp/src/test/test_omp.f90
===================================================================
--- XIOS/dev/dev_trunk_omp/src/test/test_omp.f90	(revision 1669)
+++ XIOS/dev/dev_trunk_omp/src/test/test_omp.f90	(revision 1670)
@@ -169,5 +169,5 @@
    PRINT*,"field field_A is active ? ",xios_field_is_active("field_A")
 
-   DO ts=1,4
+   DO ts=1,1
     CALL xios_update_calendar(ts)
     CALL xios_send_field("field_A",field_A)
Index: XIOS/dev/dev_trunk_omp/src/workflow_graph.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/src/workflow_graph.cpp	(revision 1669)
+++ XIOS/dev/dev_trunk_omp/src/workflow_graph.cpp	(revision 1670)
@@ -4,14 +4,14 @@
 {
 
-  std::unordered_map <StdString, vector <int > > *CWorkflowGraph::mapFieldToFilters_ptr = 0;
+  std::unordered_map < StdString, std::unordered_map <StdString, vector <int> >    > *CWorkflowGraph::mapFieldToFilters_ptr = 0;
   #pragma omp threadprivate(CWorkflowGraph::mapFieldToFilters_ptr)
 
-  std::unordered_map <int, StdString> *CWorkflowGraph::mapFilters_ptr = 0;
+  std::unordered_map < StdString, std::unordered_map <int, StdString>  > *CWorkflowGraph::mapFilters_ptr = 0;
   #pragma omp threadprivate(CWorkflowGraph::mapFilters_ptr)
 
-  std::unordered_map <int,vector<Time> > *CWorkflowGraph::mapFilterTimestamps_ptr = 0;
+  std::unordered_map < StdString, std::unordered_map <int, vector<Time> >  > *CWorkflowGraph::mapFilterTimestamps_ptr = 0;
   #pragma omp threadprivate(CWorkflowGraph::mapFilterTimestamps_ptr)
 
-  set<Time>  *CWorkflowGraph::timestamps_ptr = 0;
+  std::unordered_map< StdString, set<Time> >  *CWorkflowGraph::timestamps_ptr = 0;
   #pragma omp threadprivate(CWorkflowGraph::timestamps_ptr)
 
@@ -19,4 +19,10 @@
   vector <StdString> CWorkflowGraph::fields;
   vector <pair<int, int> > CWorkflowGraph::fieldsToFilters;
+
+  StdString CWorkflowGraph::my_filename = "my_filename";
+  #pragma omp threadprivate(CWorkflowGraph::my_filename)
+
+  std::map< StdString, int> *InvalidableObject::count_ptr=0;
+  #pragma omp threadprivate(InvalidableObject::count_ptr)
 
   CWorkflowGraph::CWorkflowGraph()
@@ -26,4 +32,6 @@
    * Reorganize information collected by XIOS for visualization.
    */
+  /*
+
   void CWorkflowGraph::buildStaticWorkflow()
   TRY
@@ -50,4 +58,34 @@
   }
   CATCH
+*/
+
+  void CWorkflowGraph::buildStaticWorkflow_forfile(StdString filename)
+  TRY
+  {
+    // Create a list of filters (graph nodes)
+    //if(mapFilters_ptr==0) mapFilters_ptr = new std::unordered_map <int, StdString>;
+    //if(mapFieldToFilters_ptr==0) mapFieldToFilters_ptr = new std::unordered_map <StdString, vector <int > >;
+    size_t filterIdx = 0;
+    filters.resize((*mapFilters_ptr)[filename].size());
+    fieldsToFilters.clear();
+    fields.clear();
+
+
+    for (std::unordered_map <int, StdString>::iterator it=(*mapFilters_ptr)[filename].begin(); it != (*mapFilters_ptr)[filename].end(); it++)
+    {
+      filters[it->first]=it->second;
+    }
+
+    // Create a list of fields and their filter connectivity (graph edges and edge-to-node connectivity)
+    for (std::unordered_map <StdString, vector <int > >::iterator it=(*mapFieldToFilters_ptr)[filename].begin(); it != (*mapFieldToFilters_ptr)[filename].end(); it++)
+    {
+      for (size_t i = 0; i < (it->second.size() - 1); i+=2)
+      {
+        fieldsToFilters.push_back(make_pair(it->second[i],it->second[i+1]));
+        fields.push_back(it->first);
+      }
+    }
+  }
+  CATCH
 
 
@@ -58,5 +96,6 @@
     for (auto it=mapFilters_ptr->begin(); it != mapFilters_ptr->end(); it++)
     {
-      std::cout<<"mapFilters_ptr["<<it->first<<"]="<<it->second<<std::endl;
+      for (auto it2=mapFilters_ptr->at(it->first).begin(); it2 != mapFilters_ptr->at(it->first).end(); it2++)
+        std::cout<<"mapFilters_ptr["<<it->first<<"]="<<it2->first<<"   "<<it2->second<<std::endl;
     }
     else std::cout<<"mapFilters_ptr empty"<<std::endl;
@@ -65,11 +104,12 @@
     for (auto it=mapFieldToFilters_ptr->begin(); it != mapFieldToFilters_ptr->end(); it++)
     {
-      for (size_t i = 0; i < it->second.size(); i++)
+      for (auto it2=mapFieldToFilters_ptr->at(it->first).begin(); it2 != mapFieldToFilters_ptr->at(it->first).end(); it2++)
       {
-        std::cout<<"mapFieldToFilters_ptr["<<it->first<<"]["<<i<<"] = "<<it->second[i]<<std::endl;
+        for (size_t i = 0; i < it2->second.size(); i++)
+          std::cout<<"mapFieldToFilters_ptr["<<it->first<<"]["<<it2->first<<"]["<<i<<"] = "<<it2->second[i]<<std::endl;
       }
     }
     else std::cout<<"mapFieldToFilters_ptr empty"<<mapFieldToFilters_ptr<<std::endl;
-
+/*
     if(mapFilterTimestamps_ptr!=0 && !mapFilterTimestamps_ptr->empty())
     for (auto it=mapFilterTimestamps_ptr->begin(); it != mapFilterTimestamps_ptr->end(); it++)
@@ -88,7 +128,8 @@
     }
     else std::cout<<"timestamps_ptr empty"<<std::endl;
-
+*/
   }
   CATCH
 
 }
+
Index: XIOS/dev/dev_trunk_omp/src/workflow_graph.hpp
===================================================================
--- XIOS/dev/dev_trunk_omp/src/workflow_graph.hpp	(revision 1669)
+++ XIOS/dev/dev_trunk_omp/src/workflow_graph.hpp	(revision 1670)
@@ -21,5 +21,5 @@
        * It is filled up during reconstruction of a workflow (in function CField::buildFilterGraph()).
       */
-      static std::unordered_map <StdString, vector <int> > *mapFieldToFilters_ptr;
+      static std::unordered_map < StdString, std::unordered_map <StdString, vector <int> >    >  *mapFieldToFilters_ptr;
       #pragma omp threadprivate(mapFieldToFilters_ptr)
 
@@ -27,5 +27,5 @@
        * It is filled up during reconstruction of a workflow (in function CField::buildFilterGraph()).
        */
-      static std::unordered_map <int, StdString> *mapFilters_ptr;
+      static std::unordered_map < StdString, std::unordered_map <int, StdString>  >   *mapFilters_ptr;
       #pragma omp threadprivate(mapFilters_ptr)
 
@@ -33,5 +33,5 @@
        * Timestamps are added into the map at the exit of a filter (in function COutputPin::onOutputReady)
        */
-      static std::unordered_map <int, vector<Time> > *mapFilterTimestamps_ptr;
+      static std::unordered_map < StdString, std::unordered_map <int, vector<Time> >  > *mapFilterTimestamps_ptr;
       #pragma omp threadprivate(mapFilterTimestamps_ptr)
 
@@ -39,6 +39,9 @@
        * Timestamps are added at the exit of a filter (in function COutputPin::onOutputReady)
        */
-      static set<Time> *timestamps_ptr;
+      static std::unordered_map< StdString, set<Time> > *timestamps_ptr;
       #pragma omp threadprivate(timestamps_ptr)
+
+      static StdString my_filename;
+      #pragma omp threadprivate(my_filename)
 
     private:
@@ -54,4 +57,5 @@
 
       static void buildStaticWorkflow();
+      static void buildStaticWorkflow_forfile(StdString filename);
       static void showStaticWorkflow();
 
@@ -61,2 +65,3 @@
 
 #endif
+
