Index: /XIOS/branchs/xios-1.0/inputs/COMPLETE/context_surface.xml
===================================================================
--- /XIOS/branchs/xios-1.0/inputs/COMPLETE/context_surface.xml	(revision 561)
+++ /XIOS/branchs/xios-1.0/inputs/COMPLETE/context_surface.xml	(revision 562)
@@ -1,52 +1,57 @@
 <!-- Context surface -->
-  
+
 <context id="surface" calendar_type="Julian" start_date="2012-03-01 15:00:00" time_origin="2012-02-29 15:00:00">
 
   <field_definition level="1" enabled=".TRUE." domain_ref="domain_srf"  axis_ref="axis_srf" operation="average" freq_op="1ts" default_value="9.96921e+36" prec="4">
     <field id="field_A_srf"  name="field_A_srf" long_name="Champ en degC" operation="average" unit="degC" />
+    <field id="field_A_srf_2" field_ref="field_A_srf" />
     <field id="field_A_srf_K" name="field_A_srf_K" field_ref="field_A_srf" long_name="Champ en degK" unit="degK"> field_A_srf + 273.15 </field>
+    <field id="field_A_srf_K_2" field_ref="field_A_srf_K" />
     <field id="field_A_srf_max" name="field_A_srf_max" field_ref="field_A_srf" long_name="maximum field_A_srf" operation="maximum" />
-    <field id="field_D_srf" name="field_D_srf" long_name="Somme champ A et C" > field_A_srf + field_C_srf </field>
-    
+    <field id="field_D_srf" name="field_D_srf" long_name="Somme champ A et C"> field_A_srf + field_C_srf </field>
   </field_definition>
-    
+
   <file_definition type="multiple_file" par_access="collective" output_level="10" enabled=".TRUE.">
-    <file id="output_surface" name="output_surface_6h" output_freq="6h" > 
-      <field field_ref="field_A_srf" >
-	<variable id="my_attribute1" type="string" >surf_att</variable>
-	<variable id="my_attribute2" type="integer" > 10 </variable>
-	<variable id="my_attribute3" type="float" >6.8</variable>
-	<variable id="my_attribute4" type="double" >100.201</variable>
+    <file id="output_surface" name="output_surface_6h" output_freq="6h">
+      <field field_ref="field_A_srf">
+        <variable id="my_attribute1" type="string">surf_att</variable>
+        <variable id="my_attribute2" type="integer"> 10 </variable>
+        <variable id="my_attribute3" type="float">6.8</variable>
+        <variable id="my_attribute4" type="double">100.201</variable>
+      </field>
+      <field field_ref="field_A_srf_K" />
+      <field field_ref="field_A_srf_K_2" name="field_A_srf_K_2" /> <!-- Should be identical to field_A_srf_K -->
+      <field field_ref="field_A_srf_K" name="field_A_srf_K_3">field_A_srf_K</field> <!-- Should be identical to field_A_srf_K -->
+      <field field_ref="field_A_srf_K_2" name="field_A_srf_K_max_mean" long_name="Maximum of hourly average over 6h" operation="maximum" freq_op="1h"> @field_A_srf_K </field>
+      <field field_ref="field_A_srf" name="field_A_srf_min" operation="minimum" />
+      <field field_ref="field_A_srf_2" name="field_A_srf_min_2" operation="minimum" /> <!-- Should be identical to field_A_srf_min -->
+      <field field_ref="field_A_srf" name="field_A_srf_max" operation="maximum" />
+      <field field_ref="field_A_srf" name="field_A_srf_prec4" prec="8" />
+      <field field_ref="field_A_srf_max" name="field_A_srf_mean_max" long_name="Average of hourly maximum over 6h" operation="average" freq_op="1h"> @field_A_srf_max </field>
+      <variable id="my_global_attribute_xml" type="string">file_6h</variable>
+    </file>
+
+    <file type="one_file" id="output_surface_1d" name="output_surface_1d" output_freq="1d">
+      <field field_ref="field_A_srf">
+        <variable id="my_attribute1" type="string">surf_att</variable>
+        <variable id="my_attribute2" type="integer">10</variable>
+        <variable id="my_attribute3" type="float">6.8</variable>
+        <variable id="my_attribute4" type="double">100.201</variable>
       </field>
       <field field_ref="field_A_srf_K" />
       <field field_ref="field_A_srf" name="field_A_srf_min" operation="minimum" />
       <field field_ref="field_A_srf" name="field_A_srf_max" operation="maximum" />
-      <field field_ref="field_A_srf" name="field_A_srf_prec4" prec="8"/>
-      <field field_ref="field_A_srf_max" name="field_A_srf_mean_max" long_name="Average of hourly maximum over 6h" operation="average" freq_op="1h" > @field_A_srf_max </field>
-      <variable id="my_global_attribute_xml" type="string" >file_6h</variable>
-    </file>
-
-    <file type="one_file" id="output_surface_1d" name="output_surface_1d" output_freq="1d" > 
-      <field field_ref="field_A_srf" >
-	<variable id="my_attribute1" type="string" >surf_att</variable>
-	<variable id="my_attribute2" type="integer" >10</variable>
-	<variable id="my_attribute3" type="float" >6.8</variable>
-	<variable id="my_attribute4" type="double" >100.201</variable>
-      </field>
-      <field field_ref="field_A_srf_K" />
-      <field field_ref="field_A_srf" name="field_A_srf_min" operation="minimum" />
-      <field field_ref="field_A_srf" name="field_A_srf_max" operation="maximum" />
-      <field field_ref="field_A_srf" name="field_A_srf_prec4" prec="8"/>
-      <field field_ref="field_A_srf_max" name="field_A_srf_mean_max" long_name="Average of hourly maximum over 1d" operation="average" freq_op="1h" > @field_A_srf_max </field>
+      <field field_ref="field_A_srf" name="field_A_srf_prec4" prec="8" />
+      <field field_ref="field_A_srf_max" name="field_A_srf_mean_max" long_name="Average of hourly maximum over 1d" operation="average" freq_op="1h"> @field_A_srf_max </field>
     </file>
   </file_definition>
- 
-   <axis_definition>
-     <axis id="axis_srf"/>
-   </axis_definition>
-    
-   <domain_definition>
-     <domain id="domain_srf" />
-   </domain_definition>    
-  
+
+  <axis_definition>
+    <axis id="axis_srf" />
+  </axis_definition>
+
+  <domain_definition>
+    <domain id="domain_srf" />
+  </domain_definition>
+
 </context>
Index: /XIOS/branchs/xios-1.0/src/node/field.cpp
===================================================================
--- /XIOS/branchs/xios-1.0/src/node/field.cpp	(revision 561)
+++ /XIOS/branchs/xios-1.0/src/node/field.cpp	(revision 562)
@@ -14,5 +14,5 @@
 
 namespace xios{
-   
+
    /// ////////////////////// DÃ©finitions ////////////////////// ///
 
@@ -27,7 +27,7 @@
       , active(false) , hasOutputFile(false),hasFieldOut(false), slotUpdateDate(NULL)
       , processed(false)
-      { setVirtualVariableGroup() ; }
-
-   CField::CField(const StdString & id)
+      { setVirtualVariableGroup(); }
+
+   CField::CField(const StdString& id)
       : CObjectTemplate<CField>(id), CFieldAttributes()
       , refObject(), baseRefObject()
@@ -39,63 +39,61 @@
       , active(false), hasOutputFile(false), hasFieldOut(false), slotUpdateDate(NULL)
       , processed(false)
-   { setVirtualVariableGroup() ; }
+   { setVirtualVariableGroup(); }
 
    CField::~CField(void)
    {
-//      this->grid.reset() ;
-//      this->file.reset() ;
-      this->foperation.reset() ;
-      if (hasExpression) delete expression ;
-      if (slotUpdateDate!=NULL) delete slotUpdateDate ;
-        
-   }
-
+//      this->grid.reset();
+//      this->file.reset();
+      this->foperation.reset();
+      if (hasExpression) delete expression;
+      if (slotUpdateDate != NULL) delete slotUpdateDate;
+
+   }
 
   //----------------------------------------------------------------
 
    void CField::setVirtualVariableGroup(CVariableGroup* newVVariableGroup)
-   { 
-      this->vVariableGroup = newVVariableGroup; 
-   }
- 
+   {
+      this->vVariableGroup = newVVariableGroup;
+   }
+
    void CField::setVirtualVariableGroup(void)
    {
       this->setVirtualVariableGroup(CVariableGroup::create());
    }
-  
+
    CVariableGroup* CField::getVirtualVariableGroup(void) const
    {
-      return (this->vVariableGroup);
-   }
-
- 
+      return this->vVariableGroup;
+   }
+
    std::vector<CVariable*> CField::getAllVariables(void) const
    {
-      return (this->vVariableGroup->getAllChildren());
-   }
-   
-   void CField::solveDescInheritance(bool apply, const CAttributeMap * const parent)
+      return this->vVariableGroup->getAllChildren();
+   }
+
+   void CField::solveDescInheritance(bool apply, const CAttributeMap* const parent)
    {
       SuperClassAttribute::setAttributes(parent,apply);
       this->getVirtualVariableGroup()->solveDescInheritance(apply, NULL);
    }
-   //----------------------------------------------------------------
+
    //----------------------------------------------------------------
 
    bool CField::updateDataServer
-      (const CDate & currDate,
+      (const CDate& currDate,
        const std::deque< CArray<double, 1>* > storedClient)
    {
       const CDate opeDate      = *last_operation + freq_operation;
-      const CDate writeDate    = *last_Write     + freq_write; 
-      
+      const CDate writeDate    = *last_Write     + freq_write;
+
       if (opeDate <= currDate)
       {
          if (this->data.numElements() != this->grid->storeIndex[0]->numElements())
          {
-            this->data.resize(this->grid->storeIndex[0] ->numElements());
-         }  
-         CArray<double,1> input(data.numElements()) ;
-         this->grid->inputFieldServer(storedClient, input);          
+            this->data.resize(this->grid->storeIndex[0]->numElements());
+         }
+         CArray<double,1> input(data.numElements());
+         this->grid->inputFieldServer(storedClient, input);
          (*this->foperation)(input);
          *last_operation = currDate;
@@ -106,13 +104,13 @@
          this->incrementNStep();
          *last_Write = writeDate;
-         return (true);        
-      }
-      return (false);
-   }
-   
+         return true;
+      }
+      return false;
+   }
+
    bool CField::dispatchEvent(CEventServer& event)
   {
-     
-    if (SuperClass::dispatchEvent(event)) return true ;
+
+    if (SuperClass::dispatchEvent(event)) return true;
     else
     {
@@ -120,121 +118,119 @@
       {
         case EVENT_ID_UPDATE_DATA :
-          recvUpdateData(event) ;
-          return true ;
-          break ;
+          recvUpdateData(event);
+          return true;
+          break;
 
             case EVENT_ID_ADD_VARIABLE :
-             recvAddVariable(event) ;
-             return true ;
-             break ;
-         
+             recvAddVariable(event);
+             return true;
+             break;
+
            case EVENT_ID_ADD_VARIABLE_GROUP :
-             recvAddVariableGroup(event) ;
-             return true ;
-             break ; 
- 
+             recvAddVariableGroup(event);
+             return true;
+             break;
+
         default :
-          ERROR("bool CField::dispatchEvent(CEventServer& event)",<<"Unknown Event") ;
-          return false ;
-      }
-    }
-  }
-  
+          ERROR("bool CField::dispatchEvent(CEventServer& event)", << "Unknown Event");
+          return false;
+      }
+    }
+  }
+
   void CField::sendUpdateData(void)
   {
-    CContext* context = CContext::getCurrent() ;
-    CContextClient* client=context->client ;
-    
-    CEventClient event(getType(),EVENT_ID_UPDATE_DATA) ;
-    
-    map<int,CArray<int, 1>* >::iterator it ;
-    list<shared_ptr<CMessage> > list_msg ;
-    list< CArray<double,1>* > list_data ;
-    
-    for(it=grid->storeIndex_toSrv.begin();it!=grid->storeIndex_toSrv.end();it++)
-    {
-      int rank=(*it).first ;
-      CArray<int,1>& index = *(it->second) ;
-      CArray<double,1> data_tmp(index.numElements()) ;
-      
-      for(int n=0;n<data_tmp.numElements();n++) data_tmp(n)=data(index(n)) ;
-      list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ;
-      list_data.push_back(new CArray<double,1>(data_tmp)) ;
-      *list_msg.back()<<getId()<<*list_data.back() ;
-      event.push(rank,grid->nbSenders[rank],*list_msg.back()) ;
-    }
-    client->sendEvent(event) ;
-    
-    for(list< CArray<double,1>* >::iterator it=list_data.begin();it!=list_data.end();it++) delete *it ;
-  }
-  
+    CContext* context = CContext::getCurrent();
+    CContextClient* client = context->client;
+
+    CEventClient event(getType(),EVENT_ID_UPDATE_DATA);
+
+    map<int,CArray<int, 1>* >::iterator it;
+    list<shared_ptr<CMessage> > list_msg;
+    list< CArray<double,1>* > list_data;
+
+    for (it = grid->storeIndex_toSrv.begin(); it != grid->storeIndex_toSrv.end(); it++)
+    {
+      int rank = (*it).first;
+      CArray<int,1>& index = *(it->second);
+      CArray<double,1> data_tmp(index.numElements());
+
+      for (int n = 0; n < data_tmp.numElements(); n++) data_tmp(n) = data(index(n));
+      list_msg.push_back(shared_ptr<CMessage>(new CMessage));
+      list_data.push_back(new CArray<double,1>(data_tmp));
+      *list_msg.back() << getId() << *list_data.back();
+      event.push(rank,grid->nbSenders[rank],*list_msg.back());
+    }
+    client->sendEvent(event);
+
+    for (list< CArray<double,1>* >::iterator it = list_data.begin(); it != list_data.end(); it++) delete *it;
+  }
+
   void CField::recvUpdateData(CEventServer& event)
   {
-    vector<int> ranks ;
-    vector<CBufferIn*> buffers ;
-      
-    list<CEventServer::SSubEvent>::iterator it ;
-    string fieldId ;
-
-    for (it=event.subEvents.begin();it!=event.subEvents.end();++it)
-    {
-      int rank=it->rank;
-      CBufferIn* buffer=it->buffer;
-      *buffer>>fieldId ;
-      ranks.push_back(rank) ;
-      buffers.push_back(buffer) ;
-    }
-    get(fieldId)->recvUpdateData(ranks,buffers) ;   
-  }
-  
+    vector<int> ranks;
+    vector<CBufferIn*> buffers;
+
+    list<CEventServer::SSubEvent>::iterator it;
+    string fieldId;
+
+    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it)
+    {
+      int rank = it->rank;
+      CBufferIn* buffer = it->buffer;
+      *buffer >> fieldId;
+      ranks.push_back(rank);
+      buffers.push_back(buffer);
+    }
+    get(fieldId)->recvUpdateData(ranks,buffers);
+  }
+
   void  CField::recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers)
   {
-    
+
     if (data_srv.empty())
     {
-      for(map<int, CArray<int, 1>* >::iterator it=grid->out_i_fromClient.begin();it!=grid->out_i_fromClient.end();it++)
-      {
-        int rank=it->first ;
-        CArray<double,1> data_tmp(it->second->numElements()) ;
-        data_srv.insert( pair<int, CArray<double,1>* >(rank, new CArray<double,1>(data_tmp) ) ) ;
-        foperation_srv.insert(pair<int,boost::shared_ptr<func::CFunctor> >(rank,boost::shared_ptr<func::CFunctor>(new func::CInstant(*data_srv[rank])))) ;
-      }
-    }
-
-    CContext* context = CContext::getCurrent() ;
-    const CDate & currDate = context->getCalendar()->getCurrentDate();
+      for (map<int, CArray<int, 1>* >::iterator it = grid->out_i_fromClient.begin(); it != grid->out_i_fromClient.end(); it++)
+      {
+        int rank = it->first;
+        CArray<double,1> data_tmp(it->second->numElements());
+        data_srv.insert( pair<int, CArray<double,1>* >(rank, new CArray<double,1>(data_tmp)));
+        foperation_srv.insert(pair<int,boost::shared_ptr<func::CFunctor> >(rank,boost::shared_ptr<func::CFunctor>(new func::CInstant(*data_srv[rank]))));
+      }
+    }
+
+    CContext* context = CContext::getCurrent();
+    const CDate& currDate = context->getCalendar()->getCurrentDate();
     const CDate opeDate      = *last_operation_srv + freq_operation_srv;
-    const CDate writeDate    = *last_Write_srv     + freq_write_srv; 
-    
-
-    
+    const CDate writeDate    = *last_Write_srv     + freq_write_srv;
+
     if (opeDate <= currDate)
     {
-      for(int n=0;n<ranks.size();n++)
-      {
-        CArray<double,1> data_tmp ;
-        *buffers[n]>>data_tmp ;
-        (*foperation_srv[ranks[n]])(data_tmp) ;
+      for (int n = 0; n < ranks.size(); n++)
+      {
+        CArray<double,1> data_tmp;
+        *buffers[n] >> data_tmp;
+        (*foperation_srv[ranks[n]])(data_tmp);
       }
       *last_operation_srv = currDate;
     }
-     
+
     if (writeDate < (currDate + freq_operation_srv))
     {
-      for(int n=0;n<ranks.size();n++)
+      for (int n = 0; n < ranks.size(); n++)
       {
         this->foperation_srv[ranks[n]]->final();
       }
-      
+
       *last_Write_srv = writeDate;
-      writeField() ;
-      *lastlast_Write_srv=*last_Write_srv;
-    }
-  }
-  
+      writeField();
+      *lastlast_Write_srv = *last_Write_srv;
+    }
+  }
+
   void CField::writeField(void)
   {
-    if (! getRelFile()->allDomainEmpty )
-      if (! grid->domain->isEmpty() || getRelFile()->type == CFile::type_attr::one_file)
+    if (!getRelFile()->allDomainEmpty)
+      if (!grid->domain->isEmpty() || getRelFile()->type == CFile::type_attr::one_file)
       {
         getRelFile()->checkFile();
@@ -246,20 +242,20 @@
 
    void CField::setRelFile(CFile* _file)
-   { 
+   {
       this->file = _file;
-      hasOutputFile=true ; 
-   }
-
-   //----------------------------------------------------------------
-
-   StdString CField::GetName(void)   { return (StdString("field")); }
-   StdString CField::GetDefName(void){ return (CField::GetName()); }
-   ENodeType CField::GetType(void)   { return (eField); }
+      hasOutputFile = true;
+   }
+
+   //----------------------------------------------------------------
+
+   StdString CField::GetName(void)    { return StdString("field"); }
+   StdString CField::GetDefName(void) { return CField::GetName(); }
+   ENodeType CField::GetType(void)    { return eField; }
 
    //----------------------------------------------------------------
 
    CGrid* CField::getRelGrid(void) const
-   { 
-      return (this->grid); 
+   {
+      return this->grid;
    }
 
@@ -267,21 +263,21 @@
 
    CFile* CField::getRelFile(void) const
-   { 
-      return (this->file);
-   }
-   
+   {
+      return this->file;
+   }
+
    StdSize CField::getNStep(void) const
    {
-      return (this->nstep);
-   }
-   
+      return this->nstep;
+   }
+
    void CField::incrementNStep(void)
    {
       this->nstep++;
    }
- 
+
    void CField::resetNStep(void)
    {
-      this->nstep=0;
+      this->nstep = 0;
    }
 
@@ -291,12 +287,12 @@
    {
       if (this->field_ref.isEmpty())
-         return (this->getBaseFieldReference());
-
-      if (! CField::has(this->field_ref.getValue()))
+         return this->getBaseFieldReference();
+
+      if (!CField::has(this->field_ref.getValue()))
          ERROR("CField::getDirectFieldReference(void)",
                << "[ ref_name = " << this->field_ref.getValue() << "]"
                << " invalid field name !");
 
-      return (CField::get(this->field_ref.getValue()));
+      return CField::get(this->field_ref.getValue());
    }
 
@@ -304,40 +300,40 @@
 
    CField* CField::getBaseFieldReference(void) const
-   { 
-      return (baseRefObject); 
-   }
-
-   //----------------------------------------------------------------
-
-   const std::vector<CField*>& CField::getAllReference(void) const 
-   { 
-      return (refObject);
-   }
-
-   //----------------------------------------------------------------
-
-   const StdString & CField::getBaseFieldId(void) const
-   { 
-      return (this->getBaseFieldReference()->getId());
-   }
-   
-   //----------------------------------------------------------------
-   
-   const CDuration & CField::getFreqOperation(void) const
-   {
-      return (this->freq_operation);
-   }
-   
-   //----------------------------------------------------------------
-   const CDuration & CField::getFreqWrite(void) const
-   {
-      return (this->freq_write);
-   }
-   
-   //----------------------------------------------------------------
-         
+   {
+      return baseRefObject;
+   }
+
+   //----------------------------------------------------------------
+
+   const std::vector<CField*>& CField::getAllReference(void) const
+   {
+      return refObject;
+   }
+
+   //----------------------------------------------------------------
+
+   const StdString& CField::getBaseFieldId(void) const
+   {
+      return this->getBaseFieldReference()->getId();
+   }
+
+   //----------------------------------------------------------------
+
+   const CDuration& CField::getFreqOperation(void) const
+   {
+      return this->freq_operation;
+   }
+
+   //----------------------------------------------------------------
+   const CDuration& CField::getFreqWrite(void) const
+   {
+      return this->freq_write;
+   }
+
+   //----------------------------------------------------------------
+
    boost::shared_ptr<func::CFunctor> CField::getFieldOperation(void) const
    {
-      return (this->foperation);
+      return this->foperation;
    }
 
@@ -345,14 +341,14 @@
 
    bool CField::hasDirectFieldReference(void) const
-   { 
-     return (!this->field_ref.isEmpty()); 
-   }
-   
+   {
+     return !this->field_ref.isEmpty();
+   }
+
    bool CField::isActive(void) const
-   { 
-      return (!this->refObject.empty()); 
-   }
-   //----------------------------------------------------------------
-   
+   {
+      return !this->refObject.empty();
+   }
+   //----------------------------------------------------------------
+
    CArray<double, 1> CField::getData(void) const
    {
@@ -380,13 +376,13 @@
       if (!processed)
       {
-        processed=true ;
-        solveRefInheritance(true) ;
-        solveBaseReference() ;
-        solveOperation() ;
-        solveGridReference() ;
-      
-        if (hasDirectFieldReference()) baseRefObject->processEnabledField() ;
-        buildExpression(); 
-        active=true;
+        processed = true;
+        solveRefInheritance(true);
+        solveBaseReference();
+        solveOperation();
+        solveGridReference();
+
+        if (hasDirectFieldReference()) baseRefObject->processEnabledField();
+        buildExpression();
+        active = true;
       }
     }
@@ -396,6 +392,6 @@
       std::set<CField *> sset;
       CField* refer_sptr;
-      CField * refer_ptr = this;
-     
+      CField* refer_ptr = this;
+
       while (refer_ptr->hasDirectFieldReference())
       {
@@ -413,5 +409,4 @@
          sset.insert(refer_ptr);
       }
-      
    }
 
@@ -420,9 +415,9 @@
       std::set<CField *> sset;
       CField* refer_sptr;
-      CField * refer_ptr = this;
-      
+      CField* refer_ptr = this;
+
       if (this->hasDirectFieldReference())  baseRefObject = getDirectFieldReference();
       else  baseRefObject = CField::get(this);
-      
+
       while (refer_ptr->hasDirectFieldReference())
       {
@@ -439,8 +434,8 @@
          sset.insert(refer_ptr);
       }
-      
-      if (hasDirectFieldReference()) baseRefObject->addReference(this) ;
-   }
-   
+
+      if (hasDirectFieldReference()) baseRefObject->addReference(this);
+   }
+
    //----------------------------------------------------------------
 
@@ -448,17 +443,17 @@
    {
       using namespace func;
-      
-      if (!hasOutputFile && !hasFieldOut) return ;
-      
-      StdString id ;
-      if (hasId()) id=getId();
-      else if (!name.isEmpty()) id=name ;
-      else if (hasDirectFieldReference()) id=baseRefObject->getId() ;
-      
+
+      if (!hasOutputFile && !hasFieldOut) return;
+
+      StdString id;
+      if (hasId()) id = getId();
+      else if (!name.isEmpty()) id = name;
+      else if (hasDirectFieldReference()) id = baseRefObject->getId();
+
       CContext* context = CContext::getCurrent();
-      
-      if (freq_op.isEmpty()) freq_op=string("1ts") ;
-      
-      if (operation.isEmpty() )
+
+      if (freq_op.isEmpty()) freq_op = string("1ts");
+
+      if (operation.isEmpty())
       {
          ERROR("CField::solveOperation(void)",
@@ -466,5 +461,5 @@
                << "Impossible to define an operation for this field !");
       }
-      
+
       CDuration freq_offset_ = NoneDu;
       if (!freq_offset.isEmpty())
@@ -475,12 +470,12 @@
       {
          freq_offset.setValue(NoneDu.toString());
-      }  
+      }
 
 //      if (CXIOSManager::GetStatus() == CXIOSManager::LOC_SERVER)
       if (context->hasServer)
       {
-         if (hasOutputFile) 
+         if (hasOutputFile)
          {
-           this->freq_operation_srv =CDuration::FromString(this->file->output_freq.getValue());
+           this->freq_operation_srv = CDuration::FromString(this->file->output_freq.getValue());
            this->freq_write_srv = CDuration::FromString(this->file->output_freq.getValue());
          }
@@ -493,17 +488,17 @@
 //         this->foperation_srv     =
 //             boost::shared_ptr<func::CFunctor>(new CInstant(this->data_srv));
-             
-         if (hasOutputFile) 
+
+         if (hasOutputFile)
          {
-           const CDuration toffset = this->freq_operation_srv - freq_offset_ - context->getCalendar()->getTimeStep(); 
+           const CDuration toffset = this->freq_operation_srv - freq_offset_ - context->getCalendar()->getTimeStep();
            *this->last_operation_srv   = *this->last_operation_srv - toffset;
          }
       }
-      
+
 //      if (context->hasClient)
-//      {                  
+//      {
          this->freq_operation = CDuration::FromString(freq_op.getValue());
          if (hasOutputFile) this->freq_write     = CDuration::FromString(this->file->output_freq.getValue());
-         if (hasFieldOut) 
+         if (hasFieldOut)
          {
            this->freq_write = CDuration::FromString(this->fieldOut->freq_op.getValue());
@@ -513,17 +508,16 @@
          this->last_operation = boost::shared_ptr<CDate>
                         (new CDate(context->getCalendar()->getInitDate()));
-                        
-         const CDuration toffset = this->freq_operation - freq_offset_ - context->getCalendar()->getTimeStep(); 
-         *this->last_operation   = *this->last_operation - toffset;  
-      
-        if (operation.get()=="once") isOnceOperation=true ;
-        else isOnceOperation=false;
-        isFirstOperation=true;
-        
-          
-#define DECLARE_FUNCTOR(MType, mtype)              \
-   if  (operation.getValue().compare(#mtype) == 0) \
-   {                                               \
-      if (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value==true) \
+
+         const CDuration toffset = this->freq_operation - freq_offset_ - context->getCalendar()->getTimeStep();
+         *this->last_operation   = *this->last_operation - toffset;
+
+        if (operation.get() == "once") isOnceOperation = true;
+        else isOnceOperation = false;
+        isFirstOperation = true;
+
+#define DECLARE_FUNCTOR(MType, mtype) \
+   if (operation.getValue().compare(#mtype) == 0) \
+   { \
+      if (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true) \
       { \
         boost::shared_ptr<func::CFunctor> foperation_(new C##MType(this->data,default_value)); \
@@ -533,22 +527,20 @@
       { \
         boost::shared_ptr<func::CFunctor> foperation_(new C##MType(this->data)); \
-        this->foperation = foperation_;  \
+        this->foperation = foperation_; \
       } \
-      return;                                      \
-   }
-   
+      return; \
+   }
+
 #include "functor_type.conf"
-         
+
          ERROR("CField::solveOperation(void)",
                << "[ operation = " << operation.getValue() << "]"
                << "The operation is not defined !");
 //      }
-      
-
-   }
-   
+   }
+
    //----------------------------------------------------------------
 /*
-   void CField::fromBinary(StdIStream & is)
+   void CField::fromBinary(StdIStream& is)
    {
       SuperClass::fromBinary(is);
@@ -572,9 +564,9 @@
       {
          if (CDomain::has(domain_ref.getValue()))
-            domain = CDomain::get(domain_ref.getValue()) ;
+            domain = CDomain::get(domain_ref.getValue());
          else
             ERROR("CField::solveGridReference(void)",
                   << "Reference to the domain \'"
-                  << domain_ref.getValue() << "\' is wrong") ;
+                  << domain_ref.getValue() << "\' is wrong");
       }
 
@@ -582,9 +574,9 @@
       {
          if (CAxis::has(axis_ref.getValue()))
-            axis = CAxis::get(axis_ref.getValue()) ;
+            axis = CAxis::get(axis_ref.getValue());
          else
             ERROR("CField::solveGridReference(void)",
                   << "Reference to the axis \'"
-                  << axis_ref.getValue() <<"\' is wrong") ;
+                  << axis_ref.getValue() <<"\' is wrong");
       }
 
@@ -592,5 +584,5 @@
       {
          if (CGrid::has(grid_ref.getValue()))
-            this->grid = CGrid::get(grid_ref.getValue()) ;
+            this->grid = CGrid::get(grid_ref.getValue());
          else
             ERROR("CField::solveGridReference(void)",
@@ -598,5 +590,5 @@
                   << grid_ref.getValue() << "\' is wrong");
       }
-      
+
       if (grid_ref.isEmpty() &&  domain_ref.isEmpty())
       {
@@ -605,66 +597,64 @@
 
      }
-     
-     CType<string> goodDomain ;
-     CType<string> goodAxis ;
+
+     CType<string> goodDomain;
+     CType<string> goodAxis;
      if (!grid_ref.isEmpty())
      {
-       if (!grid->domain_ref.isEmpty()) goodDomain=grid->domain_ref ;
-       if (!grid->axis_ref.isEmpty()) goodAxis=grid->axis_ref ;
+       if (!grid->domain_ref.isEmpty()) goodDomain = grid->domain_ref;
+       if (!grid->axis_ref.isEmpty()) goodAxis = grid->axis_ref;
      }
-     if (!domain_ref.isEmpty()) goodDomain=domain_ref ;
-     if (!axis_ref.isEmpty()) goodAxis=axis_ref ;
-     
-     
-     if (goodDomain.isEmpty()) 
+     if (!domain_ref.isEmpty()) goodDomain = domain_ref;
+     if (!axis_ref.isEmpty()) goodAxis = axis_ref;
+
+     if (goodDomain.isEmpty())
      {
        ERROR("CField::solveGridReference(void)", << "The horizontal domain for this field is not defined");
      }
-     else 
+     else
      {
-       if (CDomain::has(goodDomain)) domain = CDomain::get(goodDomain) ;
-       else ERROR("CField::solveGridReference(void)",<< "Reference to the domain \'"<<goodDomain.get() << "\' is wrong") ;
+       if (CDomain::has(goodDomain)) domain = CDomain::get(goodDomain);
+       else ERROR("CField::solveGridReference(void)",<< "Reference to the domain \'" << goodDomain.get() << "\' is wrong");
      }
- 
+
      if (!goodAxis.isEmpty())
      {
-       if (CAxis::has(goodAxis))  axis = CAxis::get(goodAxis) ;
-       else  ERROR("CField::solveGridReference(void)", << "Reference to the axis \'"
-                  << goodAxis.get() <<"\' is wrong") ;
-     } 
-    
-     bool nothingToDo=false ;
-     
+       if (CAxis::has(goodAxis)) axis = CAxis::get(goodAxis);
+       else ERROR("CField::solveGridReference(void)", << "Reference to the axis \'"
+                  << goodAxis.get() <<"\' is wrong");
+     }
+
+     bool nothingToDo = false;
+
      if (!grid_ref.isEmpty())
      {
        if (!grid->domain_ref.isEmpty() && goodDomain.get() == grid->domain_ref.get())
-         if (goodAxis.isEmpty()) nothingToDo=true ;
-         else if (!grid->axis_ref.isEmpty()) 
-                 if (grid->axis_ref.get()==goodAxis.get()) nothingToDo=true ;
+         if (goodAxis.isEmpty()) nothingToDo = true;
+         else if (!grid->axis_ref.isEmpty())
+                 if (grid->axis_ref.get() == goodAxis.get()) nothingToDo = true;
      }
-     
+
      if (!nothingToDo)
      {
        if (!goodAxis.isEmpty())
        {
-         this->grid = CGrid::createGrid(domain, axis) ;
+         this->grid = CGrid::createGrid(domain, axis);
          this->grid_ref.setValue(this->grid->getId());
        }
        else
        {
-         this->grid = CGrid::createGrid(domain) ;
+         this->grid = CGrid::createGrid(domain);
          this->grid_ref.setValue(this->grid->getId());
-       }    
+       }
      }
 
-     grid->solveReference() ;
-
-   }
-
+     grid->solveReference();
+
+   }
 
    ///-------------------------------------------------------------------
 
    template <>
-      void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void)
+   void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void)
    {
       if (this->group_ref.isEmpty()) return;
@@ -680,44 +670,44 @@
 
       std::vector<CField*> allChildren  = group->getAllChildren();
-      std::vector<CField*>::iterator 
-         it = allChildren.begin(), end = allChildren.end();
-      
+      std::vector<CField*>::iterator it = allChildren.begin(), end = allChildren.end();
+
       for (; it != end; it++)
       {
          CField* child = *it;
-         if (child->hasId()) owner->createChild()->field_ref.setValue(child->getId()) ;
-            
-      }
-   }
-   
+         if (child->hasId()) owner->createChild()->field_ref.setValue(child->getId());
+
+      }
+   }
+
    void CField::scaleFactorAddOffset(double scaleFactor, double addOffset)
    {
      map<int, CArray<double,1>* >::iterator it;
-     for(it=data_srv.begin();it!=data_srv.end();it++) *it->second = (*it->second -addOffset) * 1./scaleFactor  ;
-   }
-   
+     for (it = data_srv.begin(); it != data_srv.end(); it++) *it->second = (*it->second - addOffset) / scaleFactor;
+   }
+
    void CField::outputField(CArray<double,3>& fieldOut)
    {
       map<int, CArray<double,1>* >::iterator it;
-      for(it=data_srv.begin();it!=data_srv.end();it++)
-         grid->outputField(it->first,*it->second, fieldOut) ;
-      
-   }
-   
+      for (it = data_srv.begin(); it != data_srv.end(); it++)
+         grid->outputField(it->first,*it->second, fieldOut);
+
+   }
+
    void CField::outputField(CArray<double,2>& fieldOut)
    {
       map<int, CArray<double,1>* >::iterator it;
 
-      for(it=data_srv.begin();it!=data_srv.end();it++)
-      {
-         grid->outputField(it->first,*it->second, fieldOut) ;
-      }
-   }
+      for (it = data_srv.begin(); it != data_srv.end(); it++)
+      {
+         grid->outputField(it->first,*it->second, fieldOut);
+      }
+   }
+
    ///-------------------------------------------------------------------
 
-   void CField::parse(xml::CXMLNode & node)
+   void CField::parse(xml::CXMLNode& node)
    {
       SuperClass::parse(node);
-      if (! node.getContent(this->content)) 
+      if (!node.getContent(this->content))
       {
         if (node.goToChildElement())
@@ -725,226 +715,221 @@
           do
           {
-            if (node.getElementName()=="variable" || node.getElementName()=="variable_group") this->getVirtualVariableGroup()->parseChild(node);
-          } while (node.goToNextElement()) ;
+            if (node.getElementName() == "variable" || node.getElementName() == "variable_group") this->getVirtualVariableGroup()->parseChild(node);
+          } while (node.goToNextElement());
           node.goToParentElement();
         }
       }
     }
-    
+
   CArray<double,1>* CField::getInstantData(void)
   {
-    if (!hasInstantData) 
-    {
-      instantData.resize(grid->storeIndex_client.numElements()) ;
-      hasInstantData=true ;
-    }
-    return &instantData ;
-  }
-  
+    if (!hasInstantData)
+    {
+      instantData.resize(grid->storeIndex_client.numElements());
+      hasInstantData = true;
+    }
+    return &instantData;
+  }
+
   void CField::addReference(CField* field)
   {
-    refObject.push_back(field) ;
-  }
-  
+    refObject.push_back(field);
+  }
+
   void CField::addDependency(CField* field, int slotId)
   {
-    fieldDependency.push_back(pair<CField*,int>(field,slotId)) ;
-  }
-  
+    fieldDependency.push_back(pair<CField*,int>(field,slotId));
+  }
+
   void CField::buildExpression(void)
   {
-    if (content.size() > 0) 
-    {
-      CSimpleNodeExpr* simpleExpr=parseExpr(content+'\0') ;
-      expression=CFieldNode::newNode(simpleExpr) ;
-      delete simpleExpr ;
-      set<string> instantFieldIds ;
-      map<string,CField*> associatedInstantFieldIds ;
-      expression->getInstantFieldIds(instantFieldIds) ;
-      for (set<string>::iterator it=instantFieldIds.begin() ; it!=instantFieldIds.end();++it) 
-      {
-        if (*it!="this") 
+    if (content.size() > 0)
+    {
+      CSimpleNodeExpr* simpleExpr = parseExpr(content+'\0');
+      expression = CFieldNode::newNode(simpleExpr);
+      delete simpleExpr;
+      set<string> instantFieldIds;
+      map<string,CField*> associatedInstantFieldIds;
+      expression->getInstantFieldIds(instantFieldIds);
+      for (set<string>::iterator it = instantFieldIds.begin(); it != instantFieldIds.end(); ++it)
+      {
+        if (*it != "this")
         {
-          if (CField::has(*it)) 
+          if (CField::has(*it))
           {
-            CField* field=CField::get(*it) ;
-            field->processEnabledField() ;
-            associatedInstantFieldIds[*it]=field ;
+            CField* field = CField::get(*it);
+            field->processEnabledField();
+            associatedInstantFieldIds[*it] = field;
           }
-          else  ERROR("void CField::buildExpression(void)",<<" Field "<<*it<<" does not exist") ;
+          else  ERROR("void CField::buildExpression(void)", << " Field " << *it << " does not exist");
         }
       }
-      
-      set<string> averageFieldIds ;
-      map<string,CField*> associatedAverageFieldIds ;
-
-      expression->getAverageFieldIds(averageFieldIds) ;
-      for (set<string>::iterator it=averageFieldIds.begin() ; it!=averageFieldIds.end();++it) 
-      {      
-        if (CField::has(*it)) 
+
+      set<string> averageFieldIds;
+      map<string,CField*> associatedAverageFieldIds;
+
+      expression->getAverageFieldIds(averageFieldIds);
+      for (set<string>::iterator it = averageFieldIds.begin(); it != averageFieldIds.end(); ++it)
+      {
+        if (CField::has(*it))
         {
-           CFieldGroup* root=CFieldGroup::get("field_definition") ;
-           CField* averageField=root->createChild() ;
-           CField* instantField=root->createChild() ;
-           averageField->field_ref=*it ;
-           averageField->hasFieldOut=true ;
-           averageField->fieldOut=instantField ;
-           instantField->freq_op=freq_op ;
-           averageField-> processEnabledField() ;
+           CFieldGroup* root = CFieldGroup::get("field_definition");
+           CField* averageField = root->createChild();
+           CField* instantField = root->createChild();
+           averageField->field_ref = *it;
+           averageField->hasFieldOut = true;
+           averageField->fieldOut = instantField;
+           instantField->freq_op = freq_op;
+           averageField-> processEnabledField();
            instantField->SuperClassAttribute::setAttributes(averageField, true);
-           instantField->field_ref.reset() ;
-           instantField->operation.reset() ;
-
-           instantField-> processEnabledField() ;
-           associatedAverageFieldIds[*it]=instantField  ;
+           instantField->field_ref.reset();
+           instantField->operation.reset();
+
+           instantField-> processEnabledField();
+           associatedAverageFieldIds[*it] = instantField;
         }
-        else ERROR("void CField::buildExpression(void)",<<" Field "<<*it<<" does not exist") ;
-      }
-
-      expression->reduce(this,associatedInstantFieldIds,associatedAverageFieldIds) ;
-
-      slots.resize(instantFieldIds.size()+averageFieldIds.size()) ;
-      resetSlots() ;
-      int slotId=0 ;
-      set<CField*> fields ;
-      expression->getFields(fields) ;
-      for (set<CField*>::iterator it=fields.begin() ; it!=fields.end();++it,++slotId) (*it)->addDependency(this,slotId) ;
-      hasExpression=true; 
-    }
-  }
-  
+        else ERROR("void CField::buildExpression(void)", << " Field " << *it << " does not exist");
+      }
+
+      expression->reduce(this,associatedInstantFieldIds,associatedAverageFieldIds);
+
+      slots.resize(instantFieldIds.size() + averageFieldIds.size());
+      resetSlots();
+      int slotId = 0;
+      set<CField*> fields;
+      expression->getFields(fields);
+      for (set<CField*>::iterator it = fields.begin(); it != fields.end(); ++it, ++slotId) (*it)->addDependency(this,slotId);
+      hasExpression = true;
+    }
+  }
+
   void CField::resetSlots(void)
   {
-    for(vector<bool>::iterator it=slots.begin();it!=slots.end();++it) *it=false ;
-  }
-  
+    for (vector<bool>::iterator it = slots.begin(); it != slots.end(); ++it) *it = false;
+  }
+
   bool CField::slotsFull(void)
   {
-    bool ret=true ;
-    for(vector<bool>::iterator it=slots.begin();it!=slots.end();++it) ret &= *it;
-    return ret ;
-  }
-
-  
+    bool ret = true;
+    for (vector<bool>::iterator it = slots.begin(); it != slots.end(); ++it) ret &= *it;
+    return ret;
+  }
+
   void CField::setSlot(int slotId)
   {
-    CContext* context = CContext::getCurrent() ;
-    const CDate & currDate = context->getCalendar()->getCurrentDate();
-    if (slotUpdateDate==NULL || currDate!=*slotUpdateDate) 
-    {
-      resetSlots() ;
-      if (slotUpdateDate==NULL) slotUpdateDate=new CDate(currDate) ;
-      else *slotUpdateDate=currDate ;
-    }
-    slots[slotId]=true ;
+    CContext* context = CContext::getCurrent();
+    const CDate& currDate = context->getCalendar()->getCurrentDate();
+    if (slotUpdateDate == NULL || currDate != *slotUpdateDate)
+    {
+      resetSlots();
+      if (slotUpdateDate == NULL) slotUpdateDate = new CDate(currDate);
+      else *slotUpdateDate = currDate;
+    }
+    slots[slotId] = true;
     if (slotsFull())
     {
-      CArray<double,1> expr(expression->compute()) ;
-      
-      if (hasInstantData) 
-      {
-        instantData=expr ;
-        for(list< pair<CField *,int> >::iterator it=fieldDependency.begin(); it!=fieldDependency.end(); ++it)  
-          if (it->first!=this) it->first->setSlot(it->second) ;
-      }
-      
-      if (hasOutputFile) updateDataFromExpression(expr) ;
-      
-    }
-  }
-
-
+      CArray<double,1> expr(expression->compute());
+
+      if (hasInstantData)
+      {
+        instantData = expr;
+        for (list< pair<CField *,int> >::iterator it = fieldDependency.begin(); it != fieldDependency.end(); ++it)
+          if (it->first != this) it->first->setSlot(it->second);
+      }
+
+      if (hasOutputFile) updateDataFromExpression(expr);
+
+      const std::vector<CField*>& refField = getAllReference();
+      for (std::vector<CField*>::const_iterator it = refField.begin(); it != refField.end(); it++)
+      {
+        if (!(*it)->hasExpression)
+          (*it)->setDataFromExpression(expr);
+      }
+    }
+  }
 
    CVariable* CField::addVariable(const string& id)
    {
-     return vVariableGroup->createChild(id) ;
+     return vVariableGroup->createChild(id);
    }
 
    CVariableGroup* CField::addVariableGroup(const string& id)
    {
-     return vVariableGroup->createChildGroup(id) ;
-   }
-
+     return vVariableGroup->createChildGroup(id);
+   }
 
    void CField::sendAddVariable(const string& id)
    {
-    CContext* context=CContext::getCurrent() ;
-    
-    if (! context->hasServer )
-    {
-       CContextClient* client=context->client ;
-
-       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE) ;   
+    CContext* context = CContext::getCurrent();
+
+    if (!context->hasServer)
+    {
+       CContextClient* client = context->client;
+
+       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE);
        if (client->isServerLeader())
        {
-         CMessage msg ;
-         msg<<this->getId() ;
-         msg<<id ;
-         event.push(client->getServerLeader(),1,msg) ;
-         client->sendEvent(event) ;
+         CMessage msg;
+         msg << this->getId();
+         msg << id;
+         event.push(client->getServerLeader(),1,msg);
+         client->sendEvent(event);
        }
-       else client->sendEvent(event) ;
-    }
-      
-   }
- 
-   
+       else client->sendEvent(event);
+    }
+
+   }
+
    void CField::sendAddVariableGroup(const string& id)
    {
-    CContext* context=CContext::getCurrent() ;
-    if (! context->hasServer )
-    {
-       CContextClient* client=context->client ;
-
-       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP) ;   
+    CContext* context = CContext::getCurrent();
+    if (!context->hasServer)
+    {
+       CContextClient* client = context->client;
+
+       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP);
        if (client->isServerLeader())
        {
-         CMessage msg ;
-         msg<<this->getId() ;
-         msg<<id ;
-         event.push(client->getServerLeader(),1,msg) ;
-         client->sendEvent(event) ;
+         CMessage msg;
+         msg << this->getId();
+         msg << id;
+         event.push(client->getServerLeader(),1,msg);
+         client->sendEvent(event);
        }
-       else client->sendEvent(event) ;
-    }
-      
-   }
-   
+       else client->sendEvent(event);
+    }
+
+   }
+
    void CField::recvAddVariable(CEventServer& event)
    {
-      
-      CBufferIn* buffer=event.subEvents.begin()->buffer;
+
+      CBufferIn* buffer = event.subEvents.begin()->buffer;
       string id;
-      *buffer>>id ;
-      get(id)->recvAddVariable(*buffer) ;
-   }
-   
-   
+      *buffer >> id;
+      get(id)->recvAddVariable(*buffer);
+   }
+
    void CField::recvAddVariable(CBufferIn& buffer)
    {
-      string id ;
-      buffer>>id ;
-      addVariable(id) ;
+      string id;
+      buffer >> id;
+      addVariable(id);
    }
 
    void CField::recvAddVariableGroup(CEventServer& event)
    {
-      
-      CBufferIn* buffer=event.subEvents.begin()->buffer;
+
+      CBufferIn* buffer = event.subEvents.begin()->buffer;
       string id;
-      *buffer>>id ;
-      get(id)->recvAddVariableGroup(*buffer) ;
-   }
-   
-   
+      *buffer >> id;
+      get(id)->recvAddVariableGroup(*buffer);
+   }
+
    void CField::recvAddVariableGroup(CBufferIn& buffer)
    {
-      string id ;
-      buffer>>id ;
-      addVariableGroup(id) ;
-   }
-
-
-
-  
+      string id;
+      buffer >> id;
+      addVariableGroup(id);
+   }
 } // namespace xios
Index: /XIOS/trunk/inputs/COMPLETE/context_surface.xml
===================================================================
--- /XIOS/trunk/inputs/COMPLETE/context_surface.xml	(revision 561)
+++ /XIOS/trunk/inputs/COMPLETE/context_surface.xml	(revision 562)
@@ -1,55 +1,60 @@
 <!-- Context surface -->
-  
+
 <context id="surface">
 
   <field_definition level="1" enabled=".TRUE." domain_ref="domain_srf"  axis_ref="axis_srf" operation="average" freq_op="1ts" default_value="9.96921e+36" prec="4">
     <field id="field_A_srf"  name="field_A_srf" long_name="Champ en degC" operation="average" unit="degC" />
+    <field id="field_A_srf_2" field_ref="field_A_srf" />
     <field id="field_A_srf_K" name="field_A_srf_K" field_ref="field_A_srf" long_name="Champ en degK" unit="degK"> field_A_srf + 273.15 </field>
+    <field id="field_A_srf_K_2" field_ref="field_A_srf_K" />
     <field id="field_A_srf_max" name="field_A_srf_max" field_ref="field_A_srf" long_name="maximum field_A_srf" operation="maximum" />
-    <field id="field_D_srf" name="field_D_srf" long_name="Somme champ A et C" > field_A_srf + field_C_srf </field>
-    
+    <field id="field_D_srf" name="field_D_srf" long_name="Somme champ A et C"> field_A_srf + field_C_srf </field>
   </field_definition>
-    
+
   <file_definition type="multiple_file" par_access="collective" output_level="10" enabled=".TRUE.">
-    <file id="output_surface" name="output_surface_6h" output_freq="6h" > 
-      <field field_ref="field_A_srf" >
-	<variable id="my_attribute1" type="string" >surf_att</variable>
-	<variable id="my_attribute2" type="int" > 10 </variable>
-	<variable id="my_attribute3" type="float" >6.8</variable>
-	<variable id="my_attribute5" type="double" >100.201</variable>
+    <file id="output_surface" name="output_surface_6h" output_freq="6h">
+      <field field_ref="field_A_srf">
+        <variable id="my_attribute1" type="string">surf_att</variable>
+        <variable id="my_attribute2" type="int"> 10 </variable>
+        <variable id="my_attribute3" type="float">6.8</variable>
+        <variable id="my_attribute5" type="double">100.201</variable>
+      </field>
+      <field field_ref="field_A_srf_K" />
+      <field field_ref="field_A_srf_K_2" name="field_A_srf_K_2" /> <!-- Should be identical to field_A_srf_K -->
+      <field field_ref="field_A_srf_K" name="field_A_srf_K_3">field_A_srf_K</field> <!-- Should be identical to field_A_srf_K -->
+      <field field_ref="field_A_srf_K_2" name="field_A_srf_K_max_mean" long_name="Maximum of hourly average over 6h" operation="maximum" freq_op="1h"> @field_A_srf_K </field>
+      <field field_ref="field_A_srf" name="field_A_srf_min" operation="minimum" />
+      <field field_ref="field_A_srf_2" name="field_A_srf_min_2" operation="minimum" /> <!-- Should be identical to field_A_srf_min -->
+      <field field_ref="field_A_srf" name="field_A_srf_max" operation="maximum" />
+      <field field_ref="field_A_srf" name="field_A_srf_prec4" prec="8" />
+      <field field_ref="field_A_srf_max" name="field_A_srf_mean_max" long_name="Average of hourly maximum over 6h" operation="average" freq_op="1h"> @field_A_srf_max </field>
+      <variable id="my_global_attribute" type="string">file_6h</variable>
+    </file>
+
+    <file type="one_file" id="output_surface_1d" name="output_surface_1d" output_freq="1d">
+      <field field_ref="field_A_srf">
+        <variable id="my_attribute1" type="string">surf_att</variable>
+        <variable id="my_attribute2" type="int">10</variable>
+        <variable id="my_attribute3" type="float">6.8</variable>
+        <variable id="my_attribute4" type="double">100.201</variable>
       </field>
       <field field_ref="field_A_srf_K" />
       <field field_ref="field_A_srf" name="field_A_srf_min" operation="minimum" />
       <field field_ref="field_A_srf" name="field_A_srf_max" operation="maximum" />
-      <field field_ref="field_A_srf" name="field_A_srf_prec4" prec="8"/>
-      <field field_ref="field_A_srf_max" name="field_A_srf_mean_max" long_name="Average of hourly maximum over 6h" operation="average" freq_op="1h" > @field_A_srf_max </field>
-      <variable id="my_global_attribute" type="string" >file_6h</variable>
-    </file>
-
-    <file type="one_file" id="output_surface_1d" name="output_surface_1d" output_freq="1d" > 
-      <field field_ref="field_A_srf" >
-	<variable id="my_attribute1" type="string" >surf_att</variable>
-	<variable id="my_attribute2" type="int" >10</variable>
-	<variable id="my_attribute3" type="float" >6.8</variable>
-	<variable id="my_attribute4" type="double" >100.201</variable>
-      </field>
-      <field field_ref="field_A_srf_K" />
-      <field field_ref="field_A_srf" name="field_A_srf_min" operation="minimum" />
-      <field field_ref="field_A_srf" name="field_A_srf_max" operation="maximum" />
-      <field field_ref="field_A_srf" name="field_A_srf_prec4" prec="8"/>
-      <field field_ref="field_A_srf_max" name="field_A_srf_mean_max" long_name="Average of hourly maximum over 1d" operation="average" freq_op="1h" > @field_A_srf_max </field>
+      <field field_ref="field_A_srf" name="field_A_srf_prec4" prec="8" />
+      <field field_ref="field_A_srf_max" name="field_A_srf_mean_max" long_name="Average of hourly maximum over 1d" operation="average" freq_op="1h"> @field_A_srf_max </field>
       <variable id="my_global_attribute" type="string" >file_1d</variable>
     </file>
   </file_definition>
- 
-   <axis_definition>
-     <axis id="axis_srf"/>
-   </axis_definition>
-    
-   <domain_definition>
-     <domain id="domain_srf" />
-   </domain_definition>    
-  
-   <grid_definition />    
-  
+
+  <axis_definition>
+    <axis id="axis_srf" />
+  </axis_definition>
+
+  <domain_definition>
+    <domain id="domain_srf" />
+  </domain_definition>
+
+  <grid_definition />
+
 </context>
Index: /XIOS/trunk/src/node/field.cpp
===================================================================
--- /XIOS/trunk/src/node/field.cpp	(revision 561)
+++ /XIOS/trunk/src/node/field.cpp	(revision 562)
@@ -26,8 +26,8 @@
       , foperation(), hasInstantData(false), hasExpression(false)
       , active(false) , hasOutputFile(false),hasFieldOut(false), slotUpdateDate(NULL)
-      , processed(false), domAxisIds_("",""), areAllReferenceSolved(false), areAllExpressionBuilt(false)
-      { setVirtualVariableGroup() ; }
-
-   CField::CField(const StdString & id)
+      , processed(false), domAxisIds_("", ""), areAllReferenceSolved(false), areAllExpressionBuilt(false)
+      { setVirtualVariableGroup(); }
+
+   CField::CField(const StdString& id)
       : CObjectTemplate<CField>(id), CFieldAttributes()
       , refObject(), baseRefObject()
@@ -38,14 +38,14 @@
       , foperation(), hasInstantData(false), hasExpression(false)
       , active(false), hasOutputFile(false), hasFieldOut(false), slotUpdateDate(NULL)
-      , processed(false), domAxisIds_("",""), areAllReferenceSolved(false), areAllExpressionBuilt(false)
-   { setVirtualVariableGroup() ; }
+      , processed(false), domAxisIds_("", ""), areAllReferenceSolved(false), areAllExpressionBuilt(false)
+   { setVirtualVariableGroup(); }
 
    CField::~CField(void)
    {
-//      this->grid.reset() ;
-//      this->file.reset() ;
-      this->foperation.reset() ;
-      if (hasExpression) delete expression ;
-      if (slotUpdateDate!=NULL) delete slotUpdateDate ;
+//      this->grid.reset();
+//      this->file.reset();
+      this->foperation.reset();
+      if (hasExpression) delete expression;
+      if (slotUpdateDate != NULL) delete slotUpdateDate;
 
    }
@@ -66,5 +66,5 @@
    CVariableGroup* CField::getVirtualVariableGroup(void) const
    {
-      return (this->vVariableGroup);
+      return this->vVariableGroup;
    }
 
@@ -72,10 +72,10 @@
    std::vector<CVariable*> CField::getAllVariables(void) const
    {
-      return (this->vVariableGroup->getAllChildren());
-   }
-
-   void CField::solveDescInheritance(bool apply, const CAttributeMap * const parent)
-   {
-      SuperClassAttribute::setAttributes(parent,apply);
+      return this->vVariableGroup->getAllChildren();
+   }
+
+   void CField::solveDescInheritance(bool apply, const CAttributeMap* const parent)
+   {
+      SuperClassAttribute::setAttributes(parent, apply);
       this->getVirtualVariableGroup()->solveDescInheritance(apply, NULL);
    }
@@ -84,5 +84,5 @@
 
    bool CField::updateDataServer
-      (const CDate & currDate,
+      (const CDate& currDate,
        const std::deque< CArray<double, 1>* > storedClient)
    {
@@ -94,7 +94,7 @@
          if (this->data.numElements() != this->grid->storeIndex[0]->numElements())
          {
-            this->data.resize(this->grid->storeIndex[0] ->numElements());
+            this->data.resize(this->grid->storeIndex[0]->numElements());
          }
-         CArray<double,1> input(data.numElements()) ;
+         CArray<double,1> input(data.numElements());
          this->grid->inputFieldServer(storedClient, input);
          (*this->foperation)(input);
@@ -106,7 +106,7 @@
          this->incrementNStep();
          *last_Write = writeDate;
-         return (true);
-      }
-      return (false);
+         return true;
+      }
+      return false;
    }
 
@@ -114,5 +114,5 @@
   {
 
-    if (SuperClass::dispatchEvent(event)) return true ;
+    if (SuperClass::dispatchEvent(event)) return true;
     else
     {
@@ -120,21 +120,21 @@
       {
         case EVENT_ID_UPDATE_DATA :
-          recvUpdateData(event) ;
-          return true ;
-          break ;
+          recvUpdateData(event);
+          return true;
+          break;
 
             case EVENT_ID_ADD_VARIABLE :
-             recvAddVariable(event) ;
-             return true ;
-             break ;
+             recvAddVariable(event);
+             return true;
+             break;
 
            case EVENT_ID_ADD_VARIABLE_GROUP :
-             recvAddVariableGroup(event) ;
-             return true ;
-             break ;
+             recvAddVariableGroup(event);
+             return true;
+             break;
 
         default :
-          ERROR("bool CField::dispatchEvent(CEventServer& event)",<<"Unknown Event") ;
-          return false ;
+          ERROR("bool CField::dispatchEvent(CEventServer& event)", << "Unknown Event");
+          return false;
       }
     }
@@ -143,46 +143,46 @@
   void CField::sendUpdateData(void)
   {
-    CContext* context = CContext::getCurrent() ;
-    CContextClient* client=context->client ;
-
-    CEventClient event(getType(),EVENT_ID_UPDATE_DATA) ;
-
-    map<int,CArray<int, 1>* >::iterator it ;
-    list<shared_ptr<CMessage> > list_msg ;
-    list< CArray<double,1>* > list_data ;
-
-     for(it=grid->storeIndex_toSrv.begin();it!=grid->storeIndex_toSrv.end();it++)
-    {
-      int rank=(*it).first ;
-      CArray<int,1>& index = *(it->second) ;
-      CArray<double,1> data_tmp(index.numElements()) ;
-      for(int n=0;n<data_tmp.numElements();n++) data_tmp(n)=data(index(n)) ;
-      list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ;
-      list_data.push_back(new CArray<double,1>(data_tmp)) ;
-      *list_msg.back()<<getId()<<*list_data.back() ;
-      event.push(rank,grid->nbSenders[rank],*list_msg.back()) ;
-    }
-    client->sendEvent(event) ;
-
-    for(list< CArray<double,1>* >::iterator it=list_data.begin();it!=list_data.end();it++) delete *it ;
+    CContext* context = CContext::getCurrent();
+    CContextClient* client = context->client;
+
+    CEventClient event(getType(),EVENT_ID_UPDATE_DATA);
+
+    map<int,CArray<int, 1>* >::iterator it;
+    list<shared_ptr<CMessage> > list_msg;
+    list< CArray<double,1>* > list_data;
+
+     for (it = grid->storeIndex_toSrv.begin(); it != grid->storeIndex_toSrv.end(); it++)
+    {
+      int rank = (*it).first;
+      CArray<int,1>& index = *(it->second);
+      CArray<double,1> data_tmp(index.numElements());
+      for (int n = 0; n < data_tmp.numElements(); n++) data_tmp(n) = data(index(n));
+      list_msg.push_back(shared_ptr<CMessage>(new CMessage));
+      list_data.push_back(new CArray<double,1>(data_tmp));
+      *list_msg.back() << getId() << *list_data.back();
+      event.push(rank,grid->nbSenders[rank],*list_msg.back());
+    }
+    client->sendEvent(event);
+
+    for (list< CArray<double,1>* >::iterator it = list_data.begin(); it != list_data.end(); it++) delete *it;
   }
 
   void CField::recvUpdateData(CEventServer& event)
   {
-    vector<int> ranks ;
-    vector<CBufferIn*> buffers ;
-
-    list<CEventServer::SSubEvent>::iterator it ;
-    string fieldId ;
-
-    for (it=event.subEvents.begin();it!=event.subEvents.end();++it)
-    {
-      int rank=it->rank;
-      CBufferIn* buffer=it->buffer;
-      *buffer>>fieldId ;
-      ranks.push_back(rank) ;
-      buffers.push_back(buffer) ;
-    }
-    get(fieldId)->recvUpdateData(ranks,buffers) ;
+    vector<int> ranks;
+    vector<CBufferIn*> buffers;
+
+    list<CEventServer::SSubEvent>::iterator it;
+    string fieldId;
+
+    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it)
+    {
+      int rank = it->rank;
+      CBufferIn* buffer = it->buffer;
+      *buffer >> fieldId;
+      ranks.push_back(rank);
+      buffers.push_back(buffer);
+    }
+    get(fieldId)->recvUpdateData(ranks,buffers);
   }
 
@@ -192,28 +192,26 @@
     if (data_srv.empty())
     {
-//      for(map<int, CArray<int, 1>* >::iterator it=grid->out_i_fromClient.begin();it!=grid->out_i_fromClient.end();it++)
-      for(map<int, CArray<size_t, 1>* >::iterator it=grid->outIndexFromClient.begin();it!=grid->outIndexFromClient.end();++it)
-      {
-        int rank=it->first ;
-        CArray<double,1> data_tmp(it->second->numElements()) ;
-        data_srv.insert( pair<int, CArray<double,1>* >(rank, new CArray<double,1>(data_tmp) ) ) ;
-        foperation_srv.insert(pair<int,boost::shared_ptr<func::CFunctor> >(rank,boost::shared_ptr<func::CFunctor>(new func::CInstant(*data_srv[rank])))) ;
-      }
-    }
-
-    CContext* context = CContext::getCurrent() ;
-    const CDate & currDate = context->getCalendar()->getCurrentDate();
+//      for (map<int, CArray<int, 1>* >::iterator it = grid->out_i_fromClient.begin(); it != grid->out_i_fromClient.end(); it++)
+      for (map<int, CArray<size_t, 1>* >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it)
+      {
+        int rank = it->first;
+        CArray<double,1> data_tmp(it->second->numElements());
+        data_srv.insert( pair<int, CArray<double,1>* >(rank, new CArray<double,1>(data_tmp)));
+        foperation_srv.insert(pair<int,boost::shared_ptr<func::CFunctor> >(rank,boost::shared_ptr<func::CFunctor>(new func::CInstant(*data_srv[rank]))));
+      }
+    }
+
+    CContext* context = CContext::getCurrent();
+    const CDate& currDate = context->getCalendar()->getCurrentDate();
     const CDate opeDate      = *last_operation_srv + freq_operation_srv;
     const CDate writeDate    = *last_Write_srv     + freq_write_srv;
 
-
-
     if (opeDate <= currDate)
     {
-      for(int n=0;n<ranks.size();n++)
-      {
-        CArray<double,1> data_tmp ;
-        *buffers[n]>>data_tmp ;
-        (*foperation_srv[ranks[n]])(data_tmp) ;
+      for (int n = 0; n < ranks.size(); n++)
+      {
+        CArray<double,1> data_tmp;
+        *buffers[n] >> data_tmp;
+        (*foperation_srv[ranks[n]])(data_tmp);
       }
       *last_operation_srv = currDate;
@@ -222,5 +220,5 @@
     if (writeDate < (currDate + freq_operation_srv))
     {
-      for(int n=0;n<ranks.size();n++)
+      for (int n = 0; n < ranks.size(); n++)
       {
         this->foperation_srv[ranks[n]]->final();
@@ -228,6 +226,6 @@
 
       *last_Write_srv = writeDate;
-      writeField() ;
-      *lastlast_Write_srv=*last_Write_srv;
+      writeField();
+      *lastlast_Write_srv = *last_Write_srv;
     }
   }
@@ -235,6 +233,6 @@
   void CField::writeField(void)
   {
-    if (! getRelFile()->allDomainEmpty )
-      if (! grid->domain->isEmpty() || getRelFile()->type == CFile::type_attr::one_file)
+    if (!getRelFile()->allDomainEmpty)
+      if (!grid->domain->isEmpty() || getRelFile()->type == CFile::type_attr::one_file)
       {
         getRelFile()->checkFile();
@@ -243,4 +241,5 @@
       }
   }
+
    //----------------------------------------------------------------
 
@@ -248,12 +247,12 @@
    {
       this->file = _file;
-      hasOutputFile=true ;
-   }
-
-   //----------------------------------------------------------------
-
-   StdString CField::GetName(void)   { return (StdString("field")); }
-   StdString CField::GetDefName(void){ return (CField::GetName()); }
-   ENodeType CField::GetType(void)   { return (eField); }
+      hasOutputFile = true;
+   }
+
+   //----------------------------------------------------------------
+
+   StdString CField::GetName(void)    { return StdString("field"); }
+   StdString CField::GetDefName(void) { return CField::GetName(); }
+   ENodeType CField::GetType(void)    { return eField; }
 
    //----------------------------------------------------------------
@@ -261,5 +260,5 @@
    CGrid* CField::getRelGrid(void) const
    {
-      return (this->grid);
+      return this->grid;
    }
 
@@ -268,10 +267,10 @@
    CFile* CField::getRelFile(void) const
    {
-      return (this->file);
+      return this->file;
    }
 
    StdSize CField::getNStep(void) const
    {
-      return (this->nstep);
+      return this->nstep;
    }
 
@@ -283,18 +282,19 @@
    void CField::resetNStep(void)
    {
-      this->nstep=0;
-   }
-
-   //----------------------------------------------------------------
-
-   const CDuration & CField::getFreqOperation(void) const
-   {
-      return (this->freq_operation);
-   }
-
-   //----------------------------------------------------------------
-   const CDuration & CField::getFreqWrite(void) const
-   {
-      return (this->freq_write);
+      this->nstep = 0;
+   }
+
+   //----------------------------------------------------------------
+
+   const CDuration& CField::getFreqOperation(void) const
+   {
+      return this->freq_operation;
+   }
+
+   //----------------------------------------------------------------
+
+   const CDuration& CField::getFreqWrite(void) const
+   {
+      return this->freq_write;
    }
 
@@ -303,12 +303,12 @@
    boost::shared_ptr<func::CFunctor> CField::getFieldOperation(void) const
    {
-      return (this->foperation);
-   }
-
+      return this->foperation;
+   }
 
    bool CField::isActive(void) const
    {
-      return (!this->refObject.empty());
-   }
+      return !this->refObject.empty();
+   }
+
    //----------------------------------------------------------------
 
@@ -338,13 +338,13 @@
 //      if (!processed)
 //      {
-//        processed=true ;
-//        solveRefInheritance(true) ;
-//        solveBaseReference() ;
-//        solveOperation() ;
-//        solveGridReference() ;
-//
-//        if (hasDirectFieldReference()) baseRefObject->processEnabledField() ;
+//        processed = true;
+//        solveRefInheritance(true);
+//        solveBaseReference();
+//        solveOperation();
+//        solveGridReference();
+//
+//        if (hasDirectFieldReference()) baseRefObject->processEnabledField();
 //        buildExpression();
-//        active=true;
+//        active = true;
 //      }
 //    }
@@ -384,5 +384,5 @@
        if (hasDirectFieldReference()) baseRefObject->buildAllExpressionEnabledField();
        buildExpression();
-       active=true;
+       active = true;
      }
    }
@@ -394,10 +394,10 @@
       using namespace func;
 
-      if (!hasOutputFile && !hasFieldOut) return ;
-
-      StdString id ;
-      if (hasId()) id=getId();
-      else if (!name.isEmpty()) id=name ;
-      else if (hasDirectFieldReference()) id=baseRefObject->getId() ;
+      if (!hasOutputFile && !hasFieldOut) return;
+
+      StdString id;
+      if (hasId()) id = getId();
+      else if (!name.isEmpty()) id = name;
+      else if (hasDirectFieldReference()) id = baseRefObject->getId();
 
       CContext* context = CContext::getCurrent();
@@ -405,5 +405,5 @@
       if (freq_op.isEmpty()) freq_op.setValue(TimeStep);
 
-      if (operation.isEmpty() )
+      if (operation.isEmpty())
       {
          ERROR("CField::solveOperation(void)",
@@ -455,13 +455,12 @@
          *this->last_operation   = *this->last_operation - toffset;
 
-        if (operation.get()=="once") isOnceOperation=true ;
-        else isOnceOperation=false;
-        isFirstOperation=true;
-
-
-#define DECLARE_FUNCTOR(MType, mtype)              \
-   if  (operation.getValue().compare(#mtype) == 0) \
-   {                                               \
-      if (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value==true) \
+        if (operation.get() == "once") isOnceOperation = true;
+        else isOnceOperation = false;
+        isFirstOperation = true;
+
+#define DECLARE_FUNCTOR(MType, mtype) \
+   if (operation.getValue().compare(#mtype) == 0) \
+   { \
+      if (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true) \
       { \
         boost::shared_ptr<func::CFunctor> foperation_(new C##MType(this->data,default_value)); \
@@ -471,7 +470,7 @@
       { \
         boost::shared_ptr<func::CFunctor> foperation_(new C##MType(this->data)); \
-        this->foperation = foperation_;  \
+        this->foperation = foperation_; \
       } \
-      return;                                      \
+      return; \
    }
 
@@ -482,11 +481,9 @@
                << "The operation is not defined !");
 //      }
-
-
    }
 
    //----------------------------------------------------------------
 /*
-   void CField::fromBinary(StdIStream & is)
+   void CField::fromBinary(StdIStream& is)
    {
       SuperClass::fromBinary(is);
@@ -514,5 +511,5 @@
          if (CDomain::has(domain_ref.getValue()))
          {
-           domain = CDomain::get(domain_ref.getValue()) ;
+           domain = CDomain::get(domain_ref.getValue());
            vecDom.push_back(domain);
          }
@@ -520,5 +517,5 @@
             ERROR("CField::solveGridReference(void)",
                   << "Reference to the domain \'"
-                  << domain_ref.getValue() << "\' is wrong") ;
+                  << domain_ref.getValue() << "\' is wrong");
       }
 
@@ -527,5 +524,5 @@
          if (CAxis::has(axis_ref.getValue()))
          {
-           axis = CAxis::get(axis_ref.getValue()) ;
+           axis = CAxis::get(axis_ref.getValue());
            vecAxis.push_back(axis);
          }
@@ -533,5 +530,5 @@
             ERROR("CField::solveGridReference(void)",
                   << "Reference to the axis \'"
-                  << axis_ref.getValue() <<"\' is wrong") ;
+                  << axis_ref.getValue() <<"\' is wrong");
       }
 
@@ -540,5 +537,5 @@
          if (CGrid::has(grid_ref.getValue()))
          {
-           this->grid = CGrid::get(grid_ref.getValue()) ;
+           this->grid = CGrid::get(grid_ref.getValue());
            domList = grid->getDomainList();
            axisList = grid->getAxisList();
@@ -550,5 +547,5 @@
       }
 
-      if (grid_ref.isEmpty() &&  domain_ref.isEmpty() && axis_ref.isEmpty())
+      if (grid_ref.isEmpty() && domain_ref.isEmpty() && axis_ref.isEmpty())
       {
             ERROR("CField::solveGridReference(void)",
@@ -562,13 +559,13 @@
 //     }
 
-//     CType<string> goodDomain ;
-//     CType<string> goodAxis ;
+//     CType<string> goodDomain;
+//     CType<string> goodAxis;
 //     if (!grid_ref.isEmpty())
 //     {
-//       if (!grid->domain_ref.isEmpty()) goodDomain=grid->domain_ref ;
-//       if (!grid->axis_ref.isEmpty()) goodAxis=grid->axis_ref ;
+//       if (!grid->domain_ref.isEmpty()) goodDomain = grid->domain_ref;
+//       if (!grid->axis_ref.isEmpty()) goodAxis = grid->axis_ref;
 //     }
-//     if (!domain_ref.isEmpty()) goodDomain=domain_ref ;
-//     if (!axis_ref.isEmpty()) goodAxis=axis_ref ;
+//     if (!domain_ref.isEmpty()) goodDomain = domain_ref;
+//     if (!axis_ref.isEmpty()) goodAxis = axis_ref;
 
 //     CArray<std::string,1> domListTmp = grid->domainList.getValue();
@@ -590,8 +587,8 @@
 //     else
 //     {
-//       if (CDomain::has(goodDomain)) domain = CDomain::get(goodDomain) ;
+//       if (CDomain::has(goodDomain)) domain = CDomain::get(goodDomain);
 //       else ERROR("CField::solveGridReference(void)",<< "Reference to the domain \'"
-//                  <<goodDomain << "\' is wrong") ;
-////                  <<goodDomain.get() << "\' is wrong") ;
+//                  << goodDomain << "\' is wrong");
+////                << goodDomain.get() << "\' is wrong");
 //     }
 //
@@ -599,18 +596,18 @@
 //     if (!goodAxis.empty())
 //     {
-//       if (CAxis::has(goodAxis))  axis = CAxis::get(goodAxis) ;
+//       if (CAxis::has(goodAxis))  axis = CAxis::get(goodAxis);
 //       else  ERROR("CField::solveGridReference(void)", << "Reference to the axis \'"
-//                  << goodAxis <<"\' is wrong") ;
-//                  << goodAxis.get() <<"\' is wrong") ;
+//                   << goodAxis <<"\' is wrong");
+//                   << goodAxis.get() <<"\' is wrong");
 //     }
 
-//     bool nothingToDo=false ;
+//     bool nothingToDo = false;
 //
 //     if (!grid_ref.isEmpty())
 //     {
 //       if (!grid->domain_ref.isEmpty() && goodDomain.get() == grid->domain_ref.get())
-//         if (goodAxis.isEmpty()) nothingToDo=true ;
+//         if (goodAxis.isEmpty()) nothingToDo = true;
 //         else if (!grid->axis_ref.isEmpty())
-//                 if (grid->axis_ref.get()==goodAxis.get()) nothingToDo=true ;
+//                 if (grid->axis_ref.get() == goodAxis.get()) nothingToDo = true;
 //     }
 //
@@ -620,15 +617,15 @@
 //       if (!goodAxis.isEmpty())
 //       {
-//         this->grid = CGrid::createGrid(domain, axis) ;
+//         this->grid = CGrid::createGrid(domain, axis);
 //         this->grid_ref.setValue(this->grid->getId());
 //       }
 //       else
 //       {
-//         this->grid = CGrid::createGrid(domain) ;
+//         this->grid = CGrid::createGrid(domain);
 //         this->grid_ref.setValue(this->grid->getId());
 //       }
 //     }
 
-//     grid->solveReference() ;
+//     grid->solveReference();
 //     grid->solveDomainAxisRef();
 //     grid->checkMaskIndex();
@@ -648,5 +645,5 @@
 
    template <>
-      void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void)
+   void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void)
    {
       if (this->group_ref.isEmpty()) return;
@@ -662,11 +659,10 @@
 
       std::vector<CField*> allChildren  = group->getAllChildren();
-      std::vector<CField*>::iterator
-         it = allChildren.begin(), end = allChildren.end();
+      std::vector<CField*>::iterator it = allChildren.begin(), end = allChildren.end();
 
       for (; it != end; it++)
       {
          CField* child = *it;
-         if (child->hasId()) owner->createChild()->field_ref.setValue(child->getId()) ;
+         if (child->hasId()) owner->createChild()->field_ref.setValue(child->getId());
 
       }
@@ -676,5 +672,5 @@
    {
      map<int, CArray<double,1>* >::iterator it;
-     for(it=data_srv.begin();it!=data_srv.end();it++) *it->second = (*it->second -addOffset) * 1./scaleFactor  ;
+     for (it = data_srv.begin(); it != data_srv.end(); it++) *it->second = (*it->second - addOffset) / scaleFactor;
    }
 
@@ -682,11 +678,10 @@
    {
       map<int, CArray<double,1>* >::iterator it;
-      for(it=data_srv.begin();it!=data_srv.end();it++)
-      {
-        grid->outputField(it->first,*it->second, fieldOut.dataFirst()) ;
-      }
-
-//         grid->outputField(it->first,*it->second, fieldOut.) ;
-
+      for (it = data_srv.begin(); it != data_srv.end(); it++)
+      {
+        grid->outputField(it->first,*it->second, fieldOut.dataFirst());
+      }
+
+//         grid->outputField(it->first,*it->second, fieldOut.);
    }
 
@@ -695,7 +690,7 @@
       map<int, CArray<double,1>* >::iterator it;
 
-      for(it=data_srv.begin();it!=data_srv.end();it++)
-      {
-         grid->outputField(it->first,*it->second, fieldOut) ;
+      for (it = data_srv.begin(); it != data_srv.end(); it++)
+      {
+         grid->outputField(it->first, *it->second, fieldOut);
       }
    }
@@ -703,8 +698,8 @@
    ///-------------------------------------------------------------------
 
-   void CField::parse(xml::CXMLNode & node)
+   void CField::parse(xml::CXMLNode& node)
    {
       SuperClass::parse(node);
-      if (! node.getContent(this->content))
+      if (!node.getContent(this->content))
       {
         if (node.goToChildElement())
@@ -712,6 +707,6 @@
           do
           {
-            if (node.getElementName()=="variable" || node.getElementName()=="variable_group") this->getVirtualVariableGroup()->parseChild(node);
-          } while (node.goToNextElement()) ;
+            if (node.getElementName() == "variable" || node.getElementName() == "variable_group") this->getVirtualVariableGroup()->parseChild(node);
+          } while (node.goToNextElement());
           node.goToParentElement();
         }
@@ -723,13 +718,13 @@
     if (!hasInstantData)
     {
-      instantData.resize(grid->storeIndex_client.numElements()) ;
-      hasInstantData=true ;
-    }
-    return &instantData ;
+      instantData.resize(grid->storeIndex_client.numElements());
+      hasInstantData = true;
+    }
+    return &instantData;
   }
 
   void CField::addDependency(CField* field, int slotId)
   {
-    fieldDependency.push_back(pair<CField*,int>(field,slotId)) ;
+    fieldDependency.push_back(pair<CField*,int>(field,slotId));
   }
 
@@ -738,62 +733,62 @@
     if (content.size() > 0)
     {
-      CSimpleNodeExpr* simpleExpr=parseExpr(content+'\0') ;
-      expression=CFieldNode::newNode(simpleExpr) ;
-      delete simpleExpr ;
-      set<string> instantFieldIds ;
-      map<string,CField*> associatedInstantFieldIds ;
-      expression->getInstantFieldIds(instantFieldIds) ;
-      for (set<string>::iterator it=instantFieldIds.begin() ; it!=instantFieldIds.end();++it)
-      {
-        if (*it!="this")
+      CSimpleNodeExpr* simpleExpr = parseExpr(content+'\0');
+      expression = CFieldNode::newNode(simpleExpr);
+      delete simpleExpr;
+      set<string> instantFieldIds;
+      map<string,CField*> associatedInstantFieldIds;
+      expression->getInstantFieldIds(instantFieldIds);
+      for (set<string>::iterator it = instantFieldIds.begin(); it != instantFieldIds.end(); ++it)
+      {
+        if (*it != "this")
         {
           if (CField::has(*it))
           {
-            CField* field=CField::get(*it) ;
-//            field->processEnabledField() ;
+            CField* field = CField::get(*it);
+//            field->processEnabledField();
             field->buildAllExpressionEnabledField();
-            associatedInstantFieldIds[*it]=field ;
+            associatedInstantFieldIds[*it] = field;
           }
-          else  ERROR("void CField::buildExpression(void)",<<" Field "<<*it<<" does not exist") ;
+          else  ERROR("void CField::buildExpression(void)", << " Field " << *it << " does not exist");
         }
       }
 
-      set<string> averageFieldIds ;
-      map<string,CField*> associatedAverageFieldIds ;
-
-      expression->getAverageFieldIds(averageFieldIds) ;
-      for (set<string>::iterator it=averageFieldIds.begin() ; it!=averageFieldIds.end();++it)
+      set<string> averageFieldIds;
+      map<string,CField*> associatedAverageFieldIds;
+
+      expression->getAverageFieldIds(averageFieldIds);
+      for (set<string>::iterator it = averageFieldIds.begin(); it != averageFieldIds.end(); ++it)
       {
         if (CField::has(*it))
         {
-           CFieldGroup* root=CFieldGroup::get("field_definition") ;
-           CField* averageField=root->createChild() ;
-           CField* instantField=root->createChild() ;
-           averageField->field_ref=*it ;
-           averageField->hasFieldOut=true ;
-           averageField->fieldOut=instantField ;
-           instantField->freq_op=freq_op ;
-//           averageField-> processEnabledField() ;
+           CFieldGroup* root = CFieldGroup::get("field_definition");
+           CField* averageField = root->createChild();
+           CField* instantField = root->createChild();
+           averageField->field_ref = *it;
+           averageField->hasFieldOut = true;
+           averageField->fieldOut = instantField;
+           instantField->freq_op = freq_op;
+//           averageField-> processEnabledField();
            averageField->buildAllExpressionEnabledField();
            instantField->SuperClassAttribute::setAttributes(averageField, true);
-           instantField->field_ref.reset() ;
-           instantField->operation.reset() ;
-
-//           instantField-> processEnabledField() ;
+           instantField->field_ref.reset();
+           instantField->operation.reset();
+
+//           instantField-> processEnabledField();
            instantField->buildAllExpressionEnabledField();
-           associatedAverageFieldIds[*it]=instantField  ;
+           associatedAverageFieldIds[*it] = instantField;
         }
-        else ERROR("void CField::buildExpression(void)",<<" Field "<<*it<<" does not exist") ;
-      }
-
-      expression->reduce(this,associatedInstantFieldIds,associatedAverageFieldIds) ;
-
-      slots.resize(instantFieldIds.size()+averageFieldIds.size()) ;
-      resetSlots() ;
-      int slotId=0 ;
-      set<CField*> fields ;
-      expression->getFields(fields) ;
-      for (set<CField*>::iterator it=fields.begin() ; it!=fields.end();++it,++slotId) (*it)->addDependency(this,slotId) ;
-      hasExpression=true;
+        else ERROR("void CField::buildExpression(void)", << " Field " << *it << " does not exist");
+      }
+
+      expression->reduce(this,associatedInstantFieldIds,associatedAverageFieldIds);
+
+      slots.resize(instantFieldIds.size() + averageFieldIds.size());
+      resetSlots();
+      int slotId = 0;
+      set<CField*> fields;
+      expression->getFields(fields);
+      for (set<CField*>::iterator it = fields.begin(); it != fields.end(); ++it, ++slotId) (*it)->addDependency(this,slotId);
+      hasExpression = true;
     }
   }
@@ -801,39 +796,44 @@
   void CField::resetSlots(void)
   {
-    for(vector<bool>::iterator it=slots.begin();it!=slots.end();++it) *it=false ;
+    for (vector<bool>::iterator it = slots.begin(); it != slots.end(); ++it) *it = false;
   }
 
   bool CField::slotsFull(void)
   {
-    bool ret=true ;
-    for(vector<bool>::iterator it=slots.begin();it!=slots.end();++it) ret &= *it;
-    return ret ;
+    bool ret = true;
+    for (vector<bool>::iterator it = slots.begin(); it != slots.end(); ++it) ret &= *it;
+    return ret;
   }
-
 
   void CField::setSlot(int slotId)
   {
-    CContext* context = CContext::getCurrent() ;
-    const CDate & currDate = context->getCalendar()->getCurrentDate();
-    if (slotUpdateDate==NULL || currDate!=*slotUpdateDate)
-    {
-      resetSlots() ;
-      if (slotUpdateDate==NULL) slotUpdateDate=new CDate(currDate) ;
-      else *slotUpdateDate=currDate ;
-    }
-    slots[slotId]=true ;
+    CContext* context = CContext::getCurrent();
+    const CDate& currDate = context->getCalendar()->getCurrentDate();
+    if (slotUpdateDate == NULL || currDate != *slotUpdateDate)
+    {
+      resetSlots();
+      if (slotUpdateDate == NULL) slotUpdateDate = new CDate(currDate);
+      else *slotUpdateDate = currDate;
+    }
+    slots[slotId] = true;
     if (slotsFull())
     {
-      CArray<double,1> expr(expression->compute()) ;
+      CArray<double,1> expr(expression->compute());
 
       if (hasInstantData)
       {
-        instantData=expr ;
-        for(list< pair<CField *,int> >::iterator it=fieldDependency.begin(); it!=fieldDependency.end(); ++it)
-          if (it->first!=this) it->first->setSlot(it->second) ;
-      }
-
-      if (hasOutputFile) updateDataFromExpression(expr) ;
-
+        instantData = expr;
+        for (list< pair<CField *,int> >::iterator it = fieldDependency.begin(); it != fieldDependency.end(); ++it)
+          if (it->first != this) it->first->setSlot(it->second);
+      }
+
+      if (hasOutputFile) updateDataFromExpression(expr);
+
+      const std::vector<CField*>& refField = getAllReference();
+      for (std::vector<CField*>::const_iterator it = refField.begin(); it != refField.end(); it++)
+      {
+        if (!(*it)->hasExpression)
+          (*it)->setDataFromExpression(expr);
+      }
     }
   }
@@ -853,17 +853,16 @@
      }
 
-     return (domAxisIds_);
+     return domAxisIds_;
    }
 
    CVariable* CField::addVariable(const string& id)
    {
-     return vVariableGroup->createChild(id) ;
+     return vVariableGroup->createChild(id);
    }
 
    CVariableGroup* CField::addVariableGroup(const string& id)
    {
-     return vVariableGroup->createChildGroup(id) ;
-   }
-
+     return vVariableGroup->createChildGroup(id);
+   }
 
    void CField::sendAddAllVariables()
@@ -890,44 +889,41 @@
    void CField::sendAddVariable(const string& id)
    {
-    CContext* context=CContext::getCurrent() ;
-
-    if (! context->hasServer )
-    {
-       CContextClient* client=context->client ;
-
-       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE) ;
+    CContext* context = CContext::getCurrent();
+
+    if (!context->hasServer)
+    {
+       CContextClient* client = context->client;
+
+       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE);
        if (client->isServerLeader())
        {
-         CMessage msg ;
-         msg<<this->getId() ;
-         msg<<id ;
-         event.push(client->getServerLeader(),1,msg) ;
-         client->sendEvent(event) ;
+         CMessage msg;
+         msg << this->getId();
+         msg << id;
+         event.push(client->getServerLeader(),1,msg);
+         client->sendEvent(event);
        }
-       else client->sendEvent(event) ;
-    }
-
-   }
-
+       else client->sendEvent(event);
+    }
+   }
 
    void CField::sendAddVariableGroup(const string& id)
    {
-    CContext* context=CContext::getCurrent() ;
-    if (! context->hasServer )
-    {
-       CContextClient* client=context->client ;
-
-       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP) ;
+    CContext* context = CContext::getCurrent();
+    if (!context->hasServer)
+    {
+       CContextClient* client = context->client;
+
+       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP);
        if (client->isServerLeader())
        {
-         CMessage msg ;
-         msg<<this->getId() ;
-         msg<<id ;
-         event.push(client->getServerLeader(),1,msg) ;
-         client->sendEvent(event) ;
+         CMessage msg;
+         msg << this->getId();
+         msg << id;
+         event.push(client->getServerLeader(),1,msg);
+         client->sendEvent(event);
        }
-       else client->sendEvent(event) ;
-    }
-
+       else client->sendEvent(event);
+    }
    }
 
@@ -935,16 +931,15 @@
    {
 
-      CBufferIn* buffer=event.subEvents.begin()->buffer;
+      CBufferIn* buffer = event.subEvents.begin()->buffer;
       string id;
-      *buffer>>id ;
-      get(id)->recvAddVariable(*buffer) ;
-   }
-
+      *buffer >> id;
+      get(id)->recvAddVariable(*buffer);
+   }
 
    void CField::recvAddVariable(CBufferIn& buffer)
    {
-      string id ;
-      buffer>>id ;
-      addVariable(id) ;
+      string id;
+      buffer >> id;
+      addVariable(id);
    }
 
@@ -952,16 +947,15 @@
    {
 
-      CBufferIn* buffer=event.subEvents.begin()->buffer;
+      CBufferIn* buffer = event.subEvents.begin()->buffer;
       string id;
-      *buffer>>id ;
-      get(id)->recvAddVariableGroup(*buffer) ;
-   }
-
+      *buffer >> id;
+      get(id)->recvAddVariableGroup(*buffer);
+   }
 
    void CField::recvAddVariableGroup(CBufferIn& buffer)
    {
-      string id ;
-      buffer>>id ;
-      addVariableGroup(id) ;
+      string id;
+      buffer >> id;
+      addVariableGroup(id);
    }
 
@@ -970,5 +964,5 @@
 //  void CField::addReference(CField* field)
 //  {
-//    refObject.push_back(field) ;
+//    refObject.push_back(field);
 //  }
 //
@@ -977,14 +971,13 @@
 //   bool CField::hasDirectFieldReference(void) const
 //   {
-//     return (!this->field_ref.isEmpty());
+//     return !this->field_ref.isEmpty();
 //   }
 //
 //   //----------------------------------------------------------------
 //
-//   const StdString & CField::getBaseFieldId(void) const
+//   const StdString& CField::getBaseFieldId(void) const
 //   {
-//      return (this->getBaseFieldReference()->getId());
+//      return this->getBaseFieldReference()->getId();
 //   }
-//
 //
 //   //----------------------------------------------------------------
@@ -996,12 +989,12 @@
 //   {
 //      if (this->field_ref.isEmpty())
-//         return (this->getBaseFieldReference());
-//
-//      if (! CField::has(this->field_ref.getValue()))
+//         return this->getBaseFieldReference();
+//
+//      if (!CField::has(this->field_ref.getValue()))
 //         ERROR("CField::getDirectFieldReference(void)",
 //               << "[ ref_name = " << this->field_ref.getValue() << "]"
 //               << " invalid field name !");
 //
-//      return (CField::get(this->field_ref.getValue()));
+//      return CField::get(this->field_ref.getValue());
 //   }
 //
@@ -1010,5 +1003,5 @@
 //   CField* CField::getBaseFieldReference(void) const
 //   {
-//      return (baseRefObject);
+//      return baseRefObject;
 //   }
 //
@@ -1017,7 +1010,6 @@
 //   const std::vector<CField*>& CField::getAllReference(void) const
 //   {
-//      return (refObject);
+//      return refObject;
 //   }
-//
 //
 //   /*!
@@ -1033,5 +1025,5 @@
 //      std::set<CField *> sset;
 //      CField* refer_sptr;
-//      CField * refer_ptr = this;
+//      CField* refer_ptr = this;
 //
 //      while (refer_ptr->hasDirectFieldReference())
@@ -1067,5 +1059,5 @@
 //      std::set<CField *> sset;
 //      CField* refer_sptr;
-//      CField * refer_ptr = this;
+//      CField* refer_ptr = this;
 //
 //      if (this->hasDirectFieldReference())  baseRefObject = getDirectFieldReference();
@@ -1087,7 +1079,5 @@
 //      }
 //
-//      if (hasDirectFieldReference()) baseRefObject->addReference(this) ;
+//      if (hasDirectFieldReference()) baseRefObject->addReference(this);
 //   }
-//
-
 } // namespace xios
