Index: XIOS/dev/dev_trunk_omp/src/node/field.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/src/node/field.cpp	(revision 1671)
+++ XIOS/dev/dev_trunk_omp/src/node/field.cpp	(revision 1677)
@@ -70,4 +70,5 @@
 
   //----------------------------------------------------------------
+
 
    const StdString& CField::getOId(void)
@@ -1128,6 +1129,6 @@
    TRY
    {     
-    if (!isReferenceSolvedAndTransformed) solveAllEnabledFieldsAndTransform();
-    if (!isGridChecked) checkGridOfEnabledFields();
+     if (!isReferenceSolvedAndTransformed) solveAllEnabledFieldsAndTransform();
+     if (!isGridChecked) checkGridOfEnabledFields();
 
      const bool detectMissingValues = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true);
@@ -1166,5 +1167,5 @@
          {
            fileWriterFilter = std::shared_ptr<CFileWriterFilter>(new CFileWriterFilter(gc, this));
-           instantDataFilter->connectOutput(fileWriterFilter, 0);
+           instantDataFilter->connectOutput(fileWriterFilter, 0);        
          }
        }
@@ -1180,4 +1181,5 @@
            boost::scoped_ptr<IFilterExprNode> expr(parseExpr(getExpression() + '\0'));
            std::shared_ptr<COutputPin> filter = expr->reduce(gc, *this);
+           filter->output_field_id = this->getId();
 
            // Check if a spatial transformation is needed
@@ -1194,22 +1196,27 @@
 
                filter->connectOutput(filters.first, 0);
-
-               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> >;
-                 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();
-                 std::cout<<"CField::buildFilterGraph (*CWorkflowGraph::mapFilters_ptr)["<<filterOut<<"] = "<<filter->GetName()<<std::endl;
-               }
+               filters.second->output_field_id = this->getId();
+
+
                filter = filters.second;
+               
              }
            }
 
            instantDataFilter = filter;
+           instantDataFilter->output_field_id = this->getId();
+           filter->output_field_id = this->getId();
+           filter->tag = buildWorkflowGraph;
+           // std::cout<<"=====1============= output_field_id = "<<this->getId()<<" =========== tag="<<filter->tag<<std::endl;
+           for(int i=0; i<filter->parent_filters.size(); i++)
+           {
+             // std::cout<<"transforme filter cout= "<<std::shared_ptr<COutputPin>(filter)<<" parent filter = "<<filter->parent_filters[i]<<std::endl; 
+             filter->tag = filter->tag || filter->parent_filters[i]->tag;
+           }
+           
+           
+
+
+
          }
          // Check if we have a reference on another field
@@ -1218,4 +1225,5 @@
            CField::get(field_ref)->build_workflow_graph.setValue(buildWorkflowGraph);
            instantDataFilter = getFieldReference(gc);
+           instantDataFilter->tag = buildWorkflowGraph;
          }
          // Check if the data is to be read from a file
@@ -1225,4 +1233,5 @@
            instantDataFilter = serverSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, false, freq_offset, true,
                                                                                                        detectMissingValues, defaultValue, buildWorkflowGraph));
+           instantDataFilter->tag = buildWorkflowGraph;
          }
          else // The data might be passed from the model
@@ -1230,11 +1239,8 @@
             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) 
-            {
-              if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map <int, StdString>;
-              (*CWorkflowGraph::mapFilters_ptr)[instantDataFilter->getFilterId()] = instantDataFilter->GetName();
-              std::cout<<"CField::buildFilterGraph2 (*CWorkflowGraph::mapFilters_ptr)["<<instantDataFilter->getFilterId()<<"] = "<<instantDataFilter->GetName()<<std::endl;
-            }  
+                                                                                                      detectMissingValues, defaultValue, buildWorkflowGraph)); 
+            instantDataFilter->tag = buildWorkflowGraph;
+            // std::cout<<"=====4============= output_field_id = "<<this->getId()<<" =========== tag="<<instantDataFilter->tag<<std::endl;
+            // std::cout<<"Source filter cout = "<<std::shared_ptr<COutputPin>(clientSourceFilter)<<std::endl;
          }
        }
@@ -1248,4 +1254,7 @@
                                                                           detectMissingValues, defaultValue));
            instantDataFilter->connectOutput(storeFilter, 0);
+
+           storeFilter->tag = (instantDataFilter->tag || buildWorkflowGraph);
+           instantDataFilter->setParentFiltersTag();
          }
 
@@ -1254,15 +1263,10 @@
            fileWriterFilter = std::shared_ptr<CFileWriterFilter>(new CFileWriterFilter(gc, this, buildWorkflowGraph));
            getTemporalDataFilter(gc, file->output_freq)->connectOutput(fileWriterFilter, 0);
-           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> >;
-             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<<"=====10============= output_field_id = "<<this->name<<std::endl;
+           // std::cout<<"CFileWriterFilter filter = "<<fileWriterFilter<<" parent filter = "<<std::shared_ptr<COutputPin>(getTemporalDataFilter(gc, file->output_freq))<<std::endl;
+           
+           fileWriterFilter->tag = (getTemporalDataFilter(gc, file->output_freq)->tag || buildWorkflowGraph);
+           fileWriterFilter->output_field_id = this->name;
+           getTemporalDataFilter(gc, file->output_freq)->setParentFiltersTag();
          }
        }
@@ -1296,24 +1300,37 @@
        double defaultValue  = hasMissingValue ? default_value : (!default_value.isEmpty() ? default_value : 0.0);                                
        filters = CSpatialTransformFilter::buildFilterGraph(gc, fieldRef->grid, grid, hasMissingValue, defaultValue, buildWorkflowGraph);
+
+       fieldRef->getInstantDataFilter()->connectOutput(filters.first, 0);
+
+       filters.second->output_field_id = this->getId();
+     
+
+       filters.second->parent_filters.resize(1);
+       filters.second->parent_filters[0]= fieldRef->getInstantDataFilter();
+
+       filters.second->tag = (buildWorkflowGraph || filters.second->parent_filters[0]->tag);
+
+       // std::cout<<"=====5============= output_field_id = "<<this->getId()<<std::endl;
+       // std::cout<<"CSpatialTransformFilter first filter cout = "<<std::shared_ptr<COutputPin>(filters.first)<<"  second filter cout = "<<std::shared_ptr<COutputPin>(filters.second)<< " parent filter = "<<fieldRef->getInstantDataFilter()<<std::endl;
+       
      }
      else
      {
        filters.first = filters.second = std::shared_ptr<CFilter>(new CPassThroughFilter(gc, buildWorkflowGraph));
-     }
-
-     fieldRef->getInstantDataFilter()->connectOutput(filters.first, 0);
-
-     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> >;
-       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();
-       std::cout<<"CField::getFieldReference (*CWorkflowGraph::mapFilters_ptr)["<<filterOut<<"] = "<<fieldRef->getInstantDataFilter()->GetName()<<std::endl;
-     }
+
+       fieldRef->getInstantDataFilter()->connectOutput(filters.first, 0);
+       filters.second->output_field_id = this->getId();
+     
+
+       filters.second->parent_filters.resize(1);
+       filters.second->parent_filters[0]= fieldRef->getInstantDataFilter();
+
+       filters.second->tag = buildWorkflowGraph || filters.second->parent_filters[0]->tag;
+
+       // std::cout<<"=====6============= output_field_id = "<<this->getId()<<" =========== tag="<<filters.second->tag<<std::endl;
+       // std::cout<<"Pass through filter cout = "<<std::shared_ptr<COutputPin>(filters.second)<<" parent filter = "<<filters.second->parent_filters[0]<<std::endl;
+
+     }
+
      return filters.second;
    }
@@ -1335,4 +1352,6 @@
        ERROR("COutputPin* CField::getSelfReference(CGarbageCollector& gc)",
              "Impossible to add a self reference to a field which has already been parsed or which does not have an expression.");
+     
+     bool buildWorkflowGraph = (!build_workflow_graph.isEmpty() && build_workflow_graph == true);
 
      if (!selfReferenceFilter)
@@ -1368,7 +1387,8 @@
 
          selfReferenceFilter = clientSourceFilter;
-       }
-     }
-
+       }    
+     }
+
+     selfReferenceFilter->tag = buildWorkflowGraph;
      return selfReferenceFilter;
    }
@@ -1388,5 +1408,5 @@
    {
      std::map<CDuration, std::shared_ptr<COutputPin> >::iterator it = temporalDataFilters.find(outFreq);
-     const bool buildWorkflowGraph = (!build_workflow_graph.isEmpty() && build_workflow_graph == true);
+     bool buildWorkflowGraph = buildWorkflowGraph = (!build_workflow_graph.isEmpty() && build_workflow_graph == true);
 
      if (it == temporalDataFilters.end())
@@ -1404,17 +1424,14 @@
 
        instantDataFilter->connectOutput(temporalFilter, 0);
-
-       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> >;
-         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();
-         std::cout<<"CField::getTemporalDataFilter (*CWorkflowGraph::mapFilters_ptr)["<<filterOut<<"] = "<<getInstantDataFilter()->GetName()<<std::endl;
-       }
+       temporalFilter->output_field_id = this->getId();
+       temporalFilter->tag = buildWorkflowGraph;
+       
+       temporalFilter->parent_filters.resize(1);
+       temporalFilter->parent_filters[0] = instantDataFilter;
+       
+
+       // std::cout<<"=====8============= output_field_id = "<<this->getId()<<" =========== tag="<<temporalFilter->tag<<std::endl;
+       // std::cout<<"Temporal filter cout = "<<std::shared_ptr<COutputPin>(temporalFilter)<<" parent filter = "<<temporalFilter->parent_filters[0]<<std::endl;
+       if(temporalFilter->parent_filters[0]->tag) temporalFilter->tag=true;
 
        it = temporalDataFilters.insert(std::make_pair(outFreq, temporalFilter)).first;
@@ -1452,5 +1469,5 @@
 
        const bool detectMissingValues = (!detect_missing_value.isEmpty() && detect_missing_value == true);
-       const bool buildWorkflowGraph = (!build_workflow_graph.isEmpty() && build_workflow_graph == true);
+       bool buildWorkflowGraph = buildWorkflowGraph = (!build_workflow_graph.isEmpty() && build_workflow_graph == true);
        std::shared_ptr<CTemporalFilter> temporalFilter(new CTemporalFilter(gc, operation,
                                                                            CContext::getCurrent()->getCalendar()->getInitDate(),
@@ -1459,17 +1476,7 @@
 
        selfReferenceFilter->connectOutput(temporalFilter, 0);
-       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> >;
-         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();
-         std::cout<<"CField::getSelfTemporalDataFilter (*CWorkflowGraph::mapFilters_ptr)["<<filterOut<<"] = "<<selfReferenceFilter->GetName()<<std::endl;
-       }
+       temporalFilter->output_field_id = this->getId();
+       temporalFilter->tag = buildWorkflowGraph;
+       // std::cout<<"=====9============= output_field_id = "<<this->getId()<<" =========== tag="<<temporalFilter->tag<<std::endl;
 
        return temporalFilter ;
