Changeset 562


Ignore:
Timestamp:
02/24/15 09:50:14 (9 years ago)
Author:
rlacroix
Message:

Fix incorrect output values when using a field_ref or the @ operator on a field computed from an operation.

The computed values were never transmitted from the source field to the destination field.

Location:
XIOS
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • XIOS/branchs/xios-1.0/inputs/COMPLETE/context_surface.xml

    r529 r562  
    11<!-- Context surface --> 
    2    
     2 
    33<context id="surface" calendar_type="Julian" start_date="2012-03-01 15:00:00" time_origin="2012-02-29 15:00:00"> 
    44 
    55  <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"> 
    66    <field id="field_A_srf"  name="field_A_srf" long_name="Champ en degC" operation="average" unit="degC" /> 
     7    <field id="field_A_srf_2" field_ref="field_A_srf" /> 
    78    <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> 
     9    <field id="field_A_srf_K_2" field_ref="field_A_srf_K" /> 
    810    <field id="field_A_srf_max" name="field_A_srf_max" field_ref="field_A_srf" long_name="maximum field_A_srf" operation="maximum" /> 
    9     <field id="field_D_srf" name="field_D_srf" long_name="Somme champ A et C" > field_A_srf + field_C_srf </field> 
    10      
     11    <field id="field_D_srf" name="field_D_srf" long_name="Somme champ A et C"> field_A_srf + field_C_srf </field> 
    1112  </field_definition> 
    12      
     13 
    1314  <file_definition type="multiple_file" par_access="collective" output_level="10" enabled=".TRUE."> 
    14     <file id="output_surface" name="output_surface_6h" output_freq="6h" >  
    15       <field field_ref="field_A_srf" > 
    16         <variable id="my_attribute1" type="string" >surf_att</variable> 
    17         <variable id="my_attribute2" type="integer" > 10 </variable> 
    18         <variable id="my_attribute3" type="float" >6.8</variable> 
    19         <variable id="my_attribute4" type="double" >100.201</variable> 
     15    <file id="output_surface" name="output_surface_6h" output_freq="6h"> 
     16      <field field_ref="field_A_srf"> 
     17        <variable id="my_attribute1" type="string">surf_att</variable> 
     18        <variable id="my_attribute2" type="integer"> 10 </variable> 
     19        <variable id="my_attribute3" type="float">6.8</variable> 
     20        <variable id="my_attribute4" type="double">100.201</variable> 
     21      </field> 
     22      <field field_ref="field_A_srf_K" /> 
     23      <field field_ref="field_A_srf_K_2" name="field_A_srf_K_2" /> <!-- Should be identical to field_A_srf_K --> 
     24      <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 --> 
     25      <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> 
     26      <field field_ref="field_A_srf" name="field_A_srf_min" operation="minimum" /> 
     27      <field field_ref="field_A_srf_2" name="field_A_srf_min_2" operation="minimum" /> <!-- Should be identical to field_A_srf_min --> 
     28      <field field_ref="field_A_srf" name="field_A_srf_max" operation="maximum" /> 
     29      <field field_ref="field_A_srf" name="field_A_srf_prec4" prec="8" /> 
     30      <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> 
     31      <variable id="my_global_attribute_xml" type="string">file_6h</variable> 
     32    </file> 
     33 
     34    <file type="one_file" id="output_surface_1d" name="output_surface_1d" output_freq="1d"> 
     35      <field field_ref="field_A_srf"> 
     36        <variable id="my_attribute1" type="string">surf_att</variable> 
     37        <variable id="my_attribute2" type="integer">10</variable> 
     38        <variable id="my_attribute3" type="float">6.8</variable> 
     39        <variable id="my_attribute4" type="double">100.201</variable> 
    2040      </field> 
    2141      <field field_ref="field_A_srf_K" /> 
    2242      <field field_ref="field_A_srf" name="field_A_srf_min" operation="minimum" /> 
    2343      <field field_ref="field_A_srf" name="field_A_srf_max" operation="maximum" /> 
    24       <field field_ref="field_A_srf" name="field_A_srf_prec4" prec="8"/> 
    25       <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> 
    26       <variable id="my_global_attribute_xml" type="string" >file_6h</variable> 
    27     </file> 
    28  
    29     <file type="one_file" id="output_surface_1d" name="output_surface_1d" output_freq="1d" >  
    30       <field field_ref="field_A_srf" > 
    31         <variable id="my_attribute1" type="string" >surf_att</variable> 
    32         <variable id="my_attribute2" type="integer" >10</variable> 
    33         <variable id="my_attribute3" type="float" >6.8</variable> 
    34         <variable id="my_attribute4" type="double" >100.201</variable> 
    35       </field> 
    36       <field field_ref="field_A_srf_K" /> 
    37       <field field_ref="field_A_srf" name="field_A_srf_min" operation="minimum" /> 
    38       <field field_ref="field_A_srf" name="field_A_srf_max" operation="maximum" /> 
    39       <field field_ref="field_A_srf" name="field_A_srf_prec4" prec="8"/> 
    40       <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> 
     44      <field field_ref="field_A_srf" name="field_A_srf_prec4" prec="8" /> 
     45      <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> 
    4146    </file> 
    4247  </file_definition> 
    43   
    44    <axis_definition> 
    45      <axis id="axis_srf"/> 
    46    </axis_definition> 
    47      
    48    <domain_definition> 
    49      <domain id="domain_srf" /> 
    50    </domain_definition>     
    51    
     48 
     49  <axis_definition> 
     50    <axis id="axis_srf" /> 
     51  </axis_definition> 
     52 
     53  <domain_definition> 
     54    <domain id="domain_srf" /> 
     55  </domain_definition> 
     56 
    5257</context> 
  • XIOS/branchs/xios-1.0/src/node/field.cpp

    r501 r562  
    1414 
    1515namespace xios{ 
    16     
     16 
    1717   /// ////////////////////// Définitions ////////////////////// /// 
    1818 
     
    2727      , active(false) , hasOutputFile(false),hasFieldOut(false), slotUpdateDate(NULL) 
    2828      , processed(false) 
    29       { setVirtualVariableGroup() ; } 
    30  
    31    CField::CField(const StdString & id) 
     29      { setVirtualVariableGroup(); } 
     30 
     31   CField::CField(const StdString& id) 
    3232      : CObjectTemplate<CField>(id), CFieldAttributes() 
    3333      , refObject(), baseRefObject() 
     
    3939      , active(false), hasOutputFile(false), hasFieldOut(false), slotUpdateDate(NULL) 
    4040      , processed(false) 
    41    { setVirtualVariableGroup() ; } 
     41   { setVirtualVariableGroup(); } 
    4242 
    4343   CField::~CField(void) 
    4444   { 
    45 //      this->grid.reset() ; 
    46 //      this->file.reset() ; 
    47       this->foperation.reset() ; 
    48       if (hasExpression) delete expression ; 
    49       if (slotUpdateDate!=NULL) delete slotUpdateDate ; 
    50          
    51    } 
    52  
     45//      this->grid.reset(); 
     46//      this->file.reset(); 
     47      this->foperation.reset(); 
     48      if (hasExpression) delete expression; 
     49      if (slotUpdateDate != NULL) delete slotUpdateDate; 
     50 
     51   } 
    5352 
    5453  //---------------------------------------------------------------- 
    5554 
    5655   void CField::setVirtualVariableGroup(CVariableGroup* newVVariableGroup) 
    57    {  
    58       this->vVariableGroup = newVVariableGroup;  
    59    } 
    60   
     56   { 
     57      this->vVariableGroup = newVVariableGroup; 
     58   } 
     59 
    6160   void CField::setVirtualVariableGroup(void) 
    6261   { 
    6362      this->setVirtualVariableGroup(CVariableGroup::create()); 
    6463   } 
    65    
     64 
    6665   CVariableGroup* CField::getVirtualVariableGroup(void) const 
    6766   { 
    68       return (this->vVariableGroup); 
    69    } 
    70  
    71   
     67      return this->vVariableGroup; 
     68   } 
     69 
    7270   std::vector<CVariable*> CField::getAllVariables(void) const 
    7371   { 
    74       return (this->vVariableGroup->getAllChildren()); 
    75    } 
    76     
    77    void CField::solveDescInheritance(bool apply, const CAttributeMap * const parent) 
     72      return this->vVariableGroup->getAllChildren(); 
     73   } 
     74 
     75   void CField::solveDescInheritance(bool apply, const CAttributeMap* const parent) 
    7876   { 
    7977      SuperClassAttribute::setAttributes(parent,apply); 
    8078      this->getVirtualVariableGroup()->solveDescInheritance(apply, NULL); 
    8179   } 
    82    //---------------------------------------------------------------- 
     80 
    8381   //---------------------------------------------------------------- 
    8482 
    8583   bool CField::updateDataServer 
    86       (const CDate & currDate, 
     84      (const CDate& currDate, 
    8785       const std::deque< CArray<double, 1>* > storedClient) 
    8886   { 
    8987      const CDate opeDate      = *last_operation + freq_operation; 
    90       const CDate writeDate    = *last_Write     + freq_write;  
    91        
     88      const CDate writeDate    = *last_Write     + freq_write; 
     89 
    9290      if (opeDate <= currDate) 
    9391      { 
    9492         if (this->data.numElements() != this->grid->storeIndex[0]->numElements()) 
    9593         { 
    96             this->data.resize(this->grid->storeIndex[0] ->numElements()); 
    97          }   
    98          CArray<double,1> input(data.numElements()) ; 
    99          this->grid->inputFieldServer(storedClient, input);           
     94            this->data.resize(this->grid->storeIndex[0]->numElements()); 
     95         } 
     96         CArray<double,1> input(data.numElements()); 
     97         this->grid->inputFieldServer(storedClient, input); 
    10098         (*this->foperation)(input); 
    10199         *last_operation = currDate; 
     
    106104         this->incrementNStep(); 
    107105         *last_Write = writeDate; 
    108          return (true);         
    109       } 
    110       return (false); 
    111    } 
    112     
     106         return true; 
     107      } 
     108      return false; 
     109   } 
     110 
    113111   bool CField::dispatchEvent(CEventServer& event) 
    114112  { 
    115       
    116     if (SuperClass::dispatchEvent(event)) return true ; 
     113 
     114    if (SuperClass::dispatchEvent(event)) return true; 
    117115    else 
    118116    { 
     
    120118      { 
    121119        case EVENT_ID_UPDATE_DATA : 
    122           recvUpdateData(event) ; 
    123           return true ; 
    124           break ; 
     120          recvUpdateData(event); 
     121          return true; 
     122          break; 
    125123 
    126124            case EVENT_ID_ADD_VARIABLE : 
    127              recvAddVariable(event) ; 
    128              return true ; 
    129              break ; 
    130           
     125             recvAddVariable(event); 
     126             return true; 
     127             break; 
     128 
    131129           case EVENT_ID_ADD_VARIABLE_GROUP : 
    132              recvAddVariableGroup(event) ; 
    133              return true ; 
    134              break ;  
    135   
     130             recvAddVariableGroup(event); 
     131             return true; 
     132             break; 
     133 
    136134        default : 
    137           ERROR("bool CField::dispatchEvent(CEventServer& event)",<<"Unknown Event") ; 
    138           return false ; 
    139       } 
    140     } 
    141   } 
    142    
     135          ERROR("bool CField::dispatchEvent(CEventServer& event)", << "Unknown Event"); 
     136          return false; 
     137      } 
     138    } 
     139  } 
     140 
    143141  void CField::sendUpdateData(void) 
    144142  { 
    145     CContext* context = CContext::getCurrent() ; 
    146     CContextClient* client=context->client ; 
    147      
    148     CEventClient event(getType(),EVENT_ID_UPDATE_DATA) ; 
    149      
    150     map<int,CArray<int, 1>* >::iterator it ; 
    151     list<shared_ptr<CMessage> > list_msg ; 
    152     list< CArray<double,1>* > list_data ; 
    153      
    154     for(it=grid->storeIndex_toSrv.begin();it!=grid->storeIndex_toSrv.end();it++) 
    155     { 
    156       int rank=(*it).first ; 
    157       CArray<int,1>& index = *(it->second) ; 
    158       CArray<double,1> data_tmp(index.numElements()) ; 
    159        
    160       for(int n=0;n<data_tmp.numElements();n++) data_tmp(n)=data(index(n)) ; 
    161       list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; 
    162       list_data.push_back(new CArray<double,1>(data_tmp)) ; 
    163       *list_msg.back()<<getId()<<*list_data.back() ; 
    164       event.push(rank,grid->nbSenders[rank],*list_msg.back()) ; 
    165     } 
    166     client->sendEvent(event) ; 
    167      
    168     for(list< CArray<double,1>* >::iterator it=list_data.begin();it!=list_data.end();it++) delete *it ; 
    169   } 
    170    
     143    CContext* context = CContext::getCurrent(); 
     144    CContextClient* client = context->client; 
     145 
     146    CEventClient event(getType(),EVENT_ID_UPDATE_DATA); 
     147 
     148    map<int,CArray<int, 1>* >::iterator it; 
     149    list<shared_ptr<CMessage> > list_msg; 
     150    list< CArray<double,1>* > list_data; 
     151 
     152    for (it = grid->storeIndex_toSrv.begin(); it != grid->storeIndex_toSrv.end(); it++) 
     153    { 
     154      int rank = (*it).first; 
     155      CArray<int,1>& index = *(it->second); 
     156      CArray<double,1> data_tmp(index.numElements()); 
     157 
     158      for (int n = 0; n < data_tmp.numElements(); n++) data_tmp(n) = data(index(n)); 
     159      list_msg.push_back(shared_ptr<CMessage>(new CMessage)); 
     160      list_data.push_back(new CArray<double,1>(data_tmp)); 
     161      *list_msg.back() << getId() << *list_data.back(); 
     162      event.push(rank,grid->nbSenders[rank],*list_msg.back()); 
     163    } 
     164    client->sendEvent(event); 
     165 
     166    for (list< CArray<double,1>* >::iterator it = list_data.begin(); it != list_data.end(); it++) delete *it; 
     167  } 
     168 
    171169  void CField::recvUpdateData(CEventServer& event) 
    172170  { 
    173     vector<int> ranks ; 
    174     vector<CBufferIn*> buffers ; 
    175        
    176     list<CEventServer::SSubEvent>::iterator it ; 
    177     string fieldId ; 
    178  
    179     for (it=event.subEvents.begin();it!=event.subEvents.end();++it) 
    180     { 
    181       int rank=it->rank; 
    182       CBufferIn* buffer=it->buffer; 
    183       *buffer>>fieldId ; 
    184       ranks.push_back(rank) ; 
    185       buffers.push_back(buffer) ; 
    186     } 
    187     get(fieldId)->recvUpdateData(ranks,buffers) ;    
    188   } 
    189    
     171    vector<int> ranks; 
     172    vector<CBufferIn*> buffers; 
     173 
     174    list<CEventServer::SSubEvent>::iterator it; 
     175    string fieldId; 
     176 
     177    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
     178    { 
     179      int rank = it->rank; 
     180      CBufferIn* buffer = it->buffer; 
     181      *buffer >> fieldId; 
     182      ranks.push_back(rank); 
     183      buffers.push_back(buffer); 
     184    } 
     185    get(fieldId)->recvUpdateData(ranks,buffers); 
     186  } 
     187 
    190188  void  CField::recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) 
    191189  { 
    192      
     190 
    193191    if (data_srv.empty()) 
    194192    { 
    195       for(map<int, CArray<int, 1>* >::iterator it=grid->out_i_fromClient.begin();it!=grid->out_i_fromClient.end();it++) 
    196       { 
    197         int rank=it->first ; 
    198         CArray<double,1> data_tmp(it->second->numElements()) ; 
    199         data_srv.insert( pair<int, CArray<double,1>* >(rank, new CArray<double,1>(data_tmp) ) ) ; 
    200         foperation_srv.insert(pair<int,boost::shared_ptr<func::CFunctor> >(rank,boost::shared_ptr<func::CFunctor>(new func::CInstant(*data_srv[rank])))) ; 
    201       } 
    202     } 
    203  
    204     CContext* context = CContext::getCurrent() ; 
    205     const CDate & currDate = context->getCalendar()->getCurrentDate(); 
     193      for (map<int, CArray<int, 1>* >::iterator it = grid->out_i_fromClient.begin(); it != grid->out_i_fromClient.end(); it++) 
     194      { 
     195        int rank = it->first; 
     196        CArray<double,1> data_tmp(it->second->numElements()); 
     197        data_srv.insert( pair<int, CArray<double,1>* >(rank, new CArray<double,1>(data_tmp))); 
     198        foperation_srv.insert(pair<int,boost::shared_ptr<func::CFunctor> >(rank,boost::shared_ptr<func::CFunctor>(new func::CInstant(*data_srv[rank])))); 
     199      } 
     200    } 
     201 
     202    CContext* context = CContext::getCurrent(); 
     203    const CDate& currDate = context->getCalendar()->getCurrentDate(); 
    206204    const CDate opeDate      = *last_operation_srv + freq_operation_srv; 
    207     const CDate writeDate    = *last_Write_srv     + freq_write_srv;  
    208      
    209  
    210      
     205    const CDate writeDate    = *last_Write_srv     + freq_write_srv; 
     206 
    211207    if (opeDate <= currDate) 
    212208    { 
    213       for(int n=0;n<ranks.size();n++) 
    214       { 
    215         CArray<double,1> data_tmp ; 
    216         *buffers[n]>>data_tmp ; 
    217         (*foperation_srv[ranks[n]])(data_tmp) ; 
     209      for (int n = 0; n < ranks.size(); n++) 
     210      { 
     211        CArray<double,1> data_tmp; 
     212        *buffers[n] >> data_tmp; 
     213        (*foperation_srv[ranks[n]])(data_tmp); 
    218214      } 
    219215      *last_operation_srv = currDate; 
    220216    } 
    221       
     217 
    222218    if (writeDate < (currDate + freq_operation_srv)) 
    223219    { 
    224       for(int n=0;n<ranks.size();n++) 
     220      for (int n = 0; n < ranks.size(); n++) 
    225221      { 
    226222        this->foperation_srv[ranks[n]]->final(); 
    227223      } 
    228        
     224 
    229225      *last_Write_srv = writeDate; 
    230       writeField() ; 
    231       *lastlast_Write_srv=*last_Write_srv; 
    232     } 
    233   } 
    234    
     226      writeField(); 
     227      *lastlast_Write_srv = *last_Write_srv; 
     228    } 
     229  } 
     230 
    235231  void CField::writeField(void) 
    236232  { 
    237     if (! getRelFile()->allDomainEmpty ) 
    238       if (! grid->domain->isEmpty() || getRelFile()->type == CFile::type_attr::one_file) 
     233    if (!getRelFile()->allDomainEmpty) 
     234      if (!grid->domain->isEmpty() || getRelFile()->type == CFile::type_attr::one_file) 
    239235      { 
    240236        getRelFile()->checkFile(); 
     
    246242 
    247243   void CField::setRelFile(CFile* _file) 
    248    {  
     244   { 
    249245      this->file = _file; 
    250       hasOutputFile=true ;  
    251    } 
    252  
    253    //---------------------------------------------------------------- 
    254  
    255    StdString CField::GetName(void)   { return (StdString("field")); } 
    256    StdString CField::GetDefName(void){ return (CField::GetName()); } 
    257    ENodeType CField::GetType(void)   { return (eField); } 
     246      hasOutputFile = true; 
     247   } 
     248 
     249   //---------------------------------------------------------------- 
     250 
     251   StdString CField::GetName(void)    { return StdString("field"); } 
     252   StdString CField::GetDefName(void) { return CField::GetName(); } 
     253   ENodeType CField::GetType(void)    { return eField; } 
    258254 
    259255   //---------------------------------------------------------------- 
    260256 
    261257   CGrid* CField::getRelGrid(void) const 
    262    {  
    263       return (this->grid);  
     258   { 
     259      return this->grid; 
    264260   } 
    265261 
     
    267263 
    268264   CFile* CField::getRelFile(void) const 
    269    {  
    270       return (this->file); 
    271    } 
    272     
     265   { 
     266      return this->file; 
     267   } 
     268 
    273269   StdSize CField::getNStep(void) const 
    274270   { 
    275       return (this->nstep); 
    276    } 
    277     
     271      return this->nstep; 
     272   } 
     273 
    278274   void CField::incrementNStep(void) 
    279275   { 
    280276      this->nstep++; 
    281277   } 
    282   
     278 
    283279   void CField::resetNStep(void) 
    284280   { 
    285       this->nstep=0; 
     281      this->nstep = 0; 
    286282   } 
    287283 
     
    291287   { 
    292288      if (this->field_ref.isEmpty()) 
    293          return (this->getBaseFieldReference()); 
    294  
    295       if (! CField::has(this->field_ref.getValue())) 
     289         return this->getBaseFieldReference(); 
     290 
     291      if (!CField::has(this->field_ref.getValue())) 
    296292         ERROR("CField::getDirectFieldReference(void)", 
    297293               << "[ ref_name = " << this->field_ref.getValue() << "]" 
    298294               << " invalid field name !"); 
    299295 
    300       return (CField::get(this->field_ref.getValue())); 
     296      return CField::get(this->field_ref.getValue()); 
    301297   } 
    302298 
     
    304300 
    305301   CField* CField::getBaseFieldReference(void) const 
    306    {  
    307       return (baseRefObject);  
    308    } 
    309  
    310    //---------------------------------------------------------------- 
    311  
    312    const std::vector<CField*>& CField::getAllReference(void) const  
    313    {  
    314       return (refObject); 
    315    } 
    316  
    317    //---------------------------------------------------------------- 
    318  
    319    const StdString & CField::getBaseFieldId(void) const 
    320    {  
    321       return (this->getBaseFieldReference()->getId()); 
    322    } 
    323     
    324    //---------------------------------------------------------------- 
    325     
    326    const CDuration & CField::getFreqOperation(void) const 
    327    { 
    328       return (this->freq_operation); 
    329    } 
    330     
    331    //---------------------------------------------------------------- 
    332    const CDuration & CField::getFreqWrite(void) const 
    333    { 
    334       return (this->freq_write); 
    335    } 
    336     
    337    //---------------------------------------------------------------- 
    338           
     302   { 
     303      return baseRefObject; 
     304   } 
     305 
     306   //---------------------------------------------------------------- 
     307 
     308   const std::vector<CField*>& CField::getAllReference(void) const 
     309   { 
     310      return refObject; 
     311   } 
     312 
     313   //---------------------------------------------------------------- 
     314 
     315   const StdString& CField::getBaseFieldId(void) const 
     316   { 
     317      return this->getBaseFieldReference()->getId(); 
     318   } 
     319 
     320   //---------------------------------------------------------------- 
     321 
     322   const CDuration& CField::getFreqOperation(void) const 
     323   { 
     324      return this->freq_operation; 
     325   } 
     326 
     327   //---------------------------------------------------------------- 
     328   const CDuration& CField::getFreqWrite(void) const 
     329   { 
     330      return this->freq_write; 
     331   } 
     332 
     333   //---------------------------------------------------------------- 
     334 
    339335   boost::shared_ptr<func::CFunctor> CField::getFieldOperation(void) const 
    340336   { 
    341       return (this->foperation); 
     337      return this->foperation; 
    342338   } 
    343339 
     
    345341 
    346342   bool CField::hasDirectFieldReference(void) const 
    347    {  
    348      return (!this->field_ref.isEmpty());  
    349    } 
    350     
     343   { 
     344     return !this->field_ref.isEmpty(); 
     345   } 
     346 
    351347   bool CField::isActive(void) const 
    352    {  
    353       return (!this->refObject.empty());  
    354    } 
    355    //---------------------------------------------------------------- 
    356     
     348   { 
     349      return !this->refObject.empty(); 
     350   } 
     351   //---------------------------------------------------------------- 
     352 
    357353   CArray<double, 1> CField::getData(void) const 
    358354   { 
     
    380376      if (!processed) 
    381377      { 
    382         processed=true ; 
    383         solveRefInheritance(true) ; 
    384         solveBaseReference() ; 
    385         solveOperation() ; 
    386         solveGridReference() ; 
    387        
    388         if (hasDirectFieldReference()) baseRefObject->processEnabledField() ; 
    389         buildExpression();  
    390         active=true; 
     378        processed = true; 
     379        solveRefInheritance(true); 
     380        solveBaseReference(); 
     381        solveOperation(); 
     382        solveGridReference(); 
     383 
     384        if (hasDirectFieldReference()) baseRefObject->processEnabledField(); 
     385        buildExpression(); 
     386        active = true; 
    391387      } 
    392388    } 
     
    396392      std::set<CField *> sset; 
    397393      CField* refer_sptr; 
    398       CField * refer_ptr = this; 
    399       
     394      CField* refer_ptr = this; 
     395 
    400396      while (refer_ptr->hasDirectFieldReference()) 
    401397      { 
     
    413409         sset.insert(refer_ptr); 
    414410      } 
    415        
    416411   } 
    417412 
     
    420415      std::set<CField *> sset; 
    421416      CField* refer_sptr; 
    422       CField * refer_ptr = this; 
    423        
     417      CField* refer_ptr = this; 
     418 
    424419      if (this->hasDirectFieldReference())  baseRefObject = getDirectFieldReference(); 
    425420      else  baseRefObject = CField::get(this); 
    426        
     421 
    427422      while (refer_ptr->hasDirectFieldReference()) 
    428423      { 
     
    439434         sset.insert(refer_ptr); 
    440435      } 
    441        
    442       if (hasDirectFieldReference()) baseRefObject->addReference(this) ; 
    443    } 
    444     
     436 
     437      if (hasDirectFieldReference()) baseRefObject->addReference(this); 
     438   } 
     439 
    445440   //---------------------------------------------------------------- 
    446441 
     
    448443   { 
    449444      using namespace func; 
    450        
    451       if (!hasOutputFile && !hasFieldOut) return ; 
    452        
    453       StdString id ; 
    454       if (hasId()) id=getId(); 
    455       else if (!name.isEmpty()) id=name ; 
    456       else if (hasDirectFieldReference()) id=baseRefObject->getId() ; 
    457        
     445 
     446      if (!hasOutputFile && !hasFieldOut) return; 
     447 
     448      StdString id; 
     449      if (hasId()) id = getId(); 
     450      else if (!name.isEmpty()) id = name; 
     451      else if (hasDirectFieldReference()) id = baseRefObject->getId(); 
     452 
    458453      CContext* context = CContext::getCurrent(); 
    459        
    460       if (freq_op.isEmpty()) freq_op=string("1ts") ; 
    461        
    462       if (operation.isEmpty() ) 
     454 
     455      if (freq_op.isEmpty()) freq_op = string("1ts"); 
     456 
     457      if (operation.isEmpty()) 
    463458      { 
    464459         ERROR("CField::solveOperation(void)", 
     
    466461               << "Impossible to define an operation for this field !"); 
    467462      } 
    468        
     463 
    469464      CDuration freq_offset_ = NoneDu; 
    470465      if (!freq_offset.isEmpty()) 
     
    475470      { 
    476471         freq_offset.setValue(NoneDu.toString()); 
    477       }   
     472      } 
    478473 
    479474//      if (CXIOSManager::GetStatus() == CXIOSManager::LOC_SERVER) 
    480475      if (context->hasServer) 
    481476      { 
    482          if (hasOutputFile)  
     477         if (hasOutputFile) 
    483478         { 
    484            this->freq_operation_srv =CDuration::FromString(this->file->output_freq.getValue()); 
     479           this->freq_operation_srv = CDuration::FromString(this->file->output_freq.getValue()); 
    485480           this->freq_write_srv = CDuration::FromString(this->file->output_freq.getValue()); 
    486481         } 
     
    493488//         this->foperation_srv     = 
    494489//             boost::shared_ptr<func::CFunctor>(new CInstant(this->data_srv)); 
    495               
    496          if (hasOutputFile)  
     490 
     491         if (hasOutputFile) 
    497492         { 
    498            const CDuration toffset = this->freq_operation_srv - freq_offset_ - context->getCalendar()->getTimeStep();  
     493           const CDuration toffset = this->freq_operation_srv - freq_offset_ - context->getCalendar()->getTimeStep(); 
    499494           *this->last_operation_srv   = *this->last_operation_srv - toffset; 
    500495         } 
    501496      } 
    502        
     497 
    503498//      if (context->hasClient) 
    504 //      {                   
     499//      { 
    505500         this->freq_operation = CDuration::FromString(freq_op.getValue()); 
    506501         if (hasOutputFile) this->freq_write     = CDuration::FromString(this->file->output_freq.getValue()); 
    507          if (hasFieldOut)  
     502         if (hasFieldOut) 
    508503         { 
    509504           this->freq_write = CDuration::FromString(this->fieldOut->freq_op.getValue()); 
     
    513508         this->last_operation = boost::shared_ptr<CDate> 
    514509                        (new CDate(context->getCalendar()->getInitDate())); 
    515                          
    516          const CDuration toffset = this->freq_operation - freq_offset_ - context->getCalendar()->getTimeStep();  
    517          *this->last_operation   = *this->last_operation - toffset;   
    518        
    519         if (operation.get()=="once") isOnceOperation=true ; 
    520         else isOnceOperation=false; 
    521         isFirstOperation=true; 
    522          
    523            
    524 #define DECLARE_FUNCTOR(MType, mtype)              \ 
    525    if  (operation.getValue().compare(#mtype) == 0) \ 
    526    {                                               \ 
    527       if (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value==true) \ 
     510 
     511         const CDuration toffset = this->freq_operation - freq_offset_ - context->getCalendar()->getTimeStep(); 
     512         *this->last_operation   = *this->last_operation - toffset; 
     513 
     514        if (operation.get() == "once") isOnceOperation = true; 
     515        else isOnceOperation = false; 
     516        isFirstOperation = true; 
     517 
     518#define DECLARE_FUNCTOR(MType, mtype) \ 
     519   if (operation.getValue().compare(#mtype) == 0) \ 
     520   { \ 
     521      if (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true) \ 
    528522      { \ 
    529523        boost::shared_ptr<func::CFunctor> foperation_(new C##MType(this->data,default_value)); \ 
     
    533527      { \ 
    534528        boost::shared_ptr<func::CFunctor> foperation_(new C##MType(this->data)); \ 
    535         this->foperation = foperation_;  \ 
     529        this->foperation = foperation_; \ 
    536530      } \ 
    537       return;                                      \ 
    538    } 
    539     
     531      return; \ 
     532   } 
     533 
    540534#include "functor_type.conf" 
    541           
     535 
    542536         ERROR("CField::solveOperation(void)", 
    543537               << "[ operation = " << operation.getValue() << "]" 
    544538               << "The operation is not defined !"); 
    545539//      } 
    546        
    547  
    548    } 
    549     
     540   } 
     541 
    550542   //---------------------------------------------------------------- 
    551543/* 
    552    void CField::fromBinary(StdIStream & is) 
     544   void CField::fromBinary(StdIStream& is) 
    553545   { 
    554546      SuperClass::fromBinary(is); 
     
    572564      { 
    573565         if (CDomain::has(domain_ref.getValue())) 
    574             domain = CDomain::get(domain_ref.getValue()) ; 
     566            domain = CDomain::get(domain_ref.getValue()); 
    575567         else 
    576568            ERROR("CField::solveGridReference(void)", 
    577569                  << "Reference to the domain \'" 
    578                   << domain_ref.getValue() << "\' is wrong") ; 
     570                  << domain_ref.getValue() << "\' is wrong"); 
    579571      } 
    580572 
     
    582574      { 
    583575         if (CAxis::has(axis_ref.getValue())) 
    584             axis = CAxis::get(axis_ref.getValue()) ; 
     576            axis = CAxis::get(axis_ref.getValue()); 
    585577         else 
    586578            ERROR("CField::solveGridReference(void)", 
    587579                  << "Reference to the axis \'" 
    588                   << axis_ref.getValue() <<"\' is wrong") ; 
     580                  << axis_ref.getValue() <<"\' is wrong"); 
    589581      } 
    590582 
     
    592584      { 
    593585         if (CGrid::has(grid_ref.getValue())) 
    594             this->grid = CGrid::get(grid_ref.getValue()) ; 
     586            this->grid = CGrid::get(grid_ref.getValue()); 
    595587         else 
    596588            ERROR("CField::solveGridReference(void)", 
     
    598590                  << grid_ref.getValue() << "\' is wrong"); 
    599591      } 
    600        
     592 
    601593      if (grid_ref.isEmpty() &&  domain_ref.isEmpty()) 
    602594      { 
     
    605597 
    606598     } 
    607       
    608      CType<string> goodDomain ; 
    609      CType<string> goodAxis ; 
     599 
     600     CType<string> goodDomain; 
     601     CType<string> goodAxis; 
    610602     if (!grid_ref.isEmpty()) 
    611603     { 
    612        if (!grid->domain_ref.isEmpty()) goodDomain=grid->domain_ref ; 
    613        if (!grid->axis_ref.isEmpty()) goodAxis=grid->axis_ref ; 
     604       if (!grid->domain_ref.isEmpty()) goodDomain = grid->domain_ref; 
     605       if (!grid->axis_ref.isEmpty()) goodAxis = grid->axis_ref; 
    614606     } 
    615      if (!domain_ref.isEmpty()) goodDomain=domain_ref ; 
    616      if (!axis_ref.isEmpty()) goodAxis=axis_ref ; 
    617       
    618       
    619      if (goodDomain.isEmpty())  
     607     if (!domain_ref.isEmpty()) goodDomain = domain_ref; 
     608     if (!axis_ref.isEmpty()) goodAxis = axis_ref; 
     609 
     610     if (goodDomain.isEmpty()) 
    620611     { 
    621612       ERROR("CField::solveGridReference(void)", << "The horizontal domain for this field is not defined"); 
    622613     } 
    623      else  
     614     else 
    624615     { 
    625        if (CDomain::has(goodDomain)) domain = CDomain::get(goodDomain) ; 
    626        else ERROR("CField::solveGridReference(void)",<< "Reference to the domain \'"<<goodDomain.get() << "\' is wrong") ; 
     616       if (CDomain::has(goodDomain)) domain = CDomain::get(goodDomain); 
     617       else ERROR("CField::solveGridReference(void)",<< "Reference to the domain \'" << goodDomain.get() << "\' is wrong"); 
    627618     } 
    628   
     619 
    629620     if (!goodAxis.isEmpty()) 
    630621     { 
    631        if (CAxis::has(goodAxis))  axis = CAxis::get(goodAxis) ; 
    632        else  ERROR("CField::solveGridReference(void)", << "Reference to the axis \'" 
    633                   << goodAxis.get() <<"\' is wrong") ; 
    634      }  
    635      
    636      bool nothingToDo=false ; 
    637       
     622       if (CAxis::has(goodAxis)) axis = CAxis::get(goodAxis); 
     623       else ERROR("CField::solveGridReference(void)", << "Reference to the axis \'" 
     624                  << goodAxis.get() <<"\' is wrong"); 
     625     } 
     626 
     627     bool nothingToDo = false; 
     628 
    638629     if (!grid_ref.isEmpty()) 
    639630     { 
    640631       if (!grid->domain_ref.isEmpty() && goodDomain.get() == grid->domain_ref.get()) 
    641          if (goodAxis.isEmpty()) nothingToDo=true ; 
    642          else if (!grid->axis_ref.isEmpty())  
    643                  if (grid->axis_ref.get()==goodAxis.get()) nothingToDo=true ; 
     632         if (goodAxis.isEmpty()) nothingToDo = true; 
     633         else if (!grid->axis_ref.isEmpty()) 
     634                 if (grid->axis_ref.get() == goodAxis.get()) nothingToDo = true; 
    644635     } 
    645       
     636 
    646637     if (!nothingToDo) 
    647638     { 
    648639       if (!goodAxis.isEmpty()) 
    649640       { 
    650          this->grid = CGrid::createGrid(domain, axis) ; 
     641         this->grid = CGrid::createGrid(domain, axis); 
    651642         this->grid_ref.setValue(this->grid->getId()); 
    652643       } 
    653644       else 
    654645       { 
    655          this->grid = CGrid::createGrid(domain) ; 
     646         this->grid = CGrid::createGrid(domain); 
    656647         this->grid_ref.setValue(this->grid->getId()); 
    657        }     
     648       } 
    658649     } 
    659650 
    660      grid->solveReference() ; 
    661  
    662    } 
    663  
     651     grid->solveReference(); 
     652 
     653   } 
    664654 
    665655   ///------------------------------------------------------------------- 
    666656 
    667657   template <> 
    668       void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void) 
     658   void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void) 
    669659   { 
    670660      if (this->group_ref.isEmpty()) return; 
     
    680670 
    681671      std::vector<CField*> allChildren  = group->getAllChildren(); 
    682       std::vector<CField*>::iterator  
    683          it = allChildren.begin(), end = allChildren.end(); 
    684        
     672      std::vector<CField*>::iterator it = allChildren.begin(), end = allChildren.end(); 
     673 
    685674      for (; it != end; it++) 
    686675      { 
    687676         CField* child = *it; 
    688          if (child->hasId()) owner->createChild()->field_ref.setValue(child->getId()) ; 
    689              
    690       } 
    691    } 
    692     
     677         if (child->hasId()) owner->createChild()->field_ref.setValue(child->getId()); 
     678 
     679      } 
     680   } 
     681 
    693682   void CField::scaleFactorAddOffset(double scaleFactor, double addOffset) 
    694683   { 
    695684     map<int, CArray<double,1>* >::iterator it; 
    696      for(it=data_srv.begin();it!=data_srv.end();it++) *it->second = (*it->second -addOffset) * 1./scaleFactor  ; 
    697    } 
    698     
     685     for (it = data_srv.begin(); it != data_srv.end(); it++) *it->second = (*it->second - addOffset) / scaleFactor; 
     686   } 
     687 
    699688   void CField::outputField(CArray<double,3>& fieldOut) 
    700689   { 
    701690      map<int, CArray<double,1>* >::iterator it; 
    702       for(it=data_srv.begin();it!=data_srv.end();it++) 
    703          grid->outputField(it->first,*it->second, fieldOut) ; 
    704        
    705    } 
    706     
     691      for (it = data_srv.begin(); it != data_srv.end(); it++) 
     692         grid->outputField(it->first,*it->second, fieldOut); 
     693 
     694   } 
     695 
    707696   void CField::outputField(CArray<double,2>& fieldOut) 
    708697   { 
    709698      map<int, CArray<double,1>* >::iterator it; 
    710699 
    711       for(it=data_srv.begin();it!=data_srv.end();it++) 
    712       { 
    713          grid->outputField(it->first,*it->second, fieldOut) ; 
    714       } 
    715    } 
     700      for (it = data_srv.begin(); it != data_srv.end(); it++) 
     701      { 
     702         grid->outputField(it->first,*it->second, fieldOut); 
     703      } 
     704   } 
     705 
    716706   ///------------------------------------------------------------------- 
    717707 
    718    void CField::parse(xml::CXMLNode & node) 
     708   void CField::parse(xml::CXMLNode& node) 
    719709   { 
    720710      SuperClass::parse(node); 
    721       if (! node.getContent(this->content))  
     711      if (!node.getContent(this->content)) 
    722712      { 
    723713        if (node.goToChildElement()) 
     
    725715          do 
    726716          { 
    727             if (node.getElementName()=="variable" || node.getElementName()=="variable_group") this->getVirtualVariableGroup()->parseChild(node); 
    728           } while (node.goToNextElement()) ; 
     717            if (node.getElementName() == "variable" || node.getElementName() == "variable_group") this->getVirtualVariableGroup()->parseChild(node); 
     718          } while (node.goToNextElement()); 
    729719          node.goToParentElement(); 
    730720        } 
    731721      } 
    732722    } 
    733      
     723 
    734724  CArray<double,1>* CField::getInstantData(void) 
    735725  { 
    736     if (!hasInstantData)  
    737     { 
    738       instantData.resize(grid->storeIndex_client.numElements()) ; 
    739       hasInstantData=true ; 
    740     } 
    741     return &instantData ; 
    742   } 
    743    
     726    if (!hasInstantData) 
     727    { 
     728      instantData.resize(grid->storeIndex_client.numElements()); 
     729      hasInstantData = true; 
     730    } 
     731    return &instantData; 
     732  } 
     733 
    744734  void CField::addReference(CField* field) 
    745735  { 
    746     refObject.push_back(field) ; 
    747   } 
    748    
     736    refObject.push_back(field); 
     737  } 
     738 
    749739  void CField::addDependency(CField* field, int slotId) 
    750740  { 
    751     fieldDependency.push_back(pair<CField*,int>(field,slotId)) ; 
    752   } 
    753    
     741    fieldDependency.push_back(pair<CField*,int>(field,slotId)); 
     742  } 
     743 
    754744  void CField::buildExpression(void) 
    755745  { 
    756     if (content.size() > 0)  
    757     { 
    758       CSimpleNodeExpr* simpleExpr=parseExpr(content+'\0') ; 
    759       expression=CFieldNode::newNode(simpleExpr) ; 
    760       delete simpleExpr ; 
    761       set<string> instantFieldIds ; 
    762       map<string,CField*> associatedInstantFieldIds ; 
    763       expression->getInstantFieldIds(instantFieldIds) ; 
    764       for (set<string>::iterator it=instantFieldIds.begin() ; it!=instantFieldIds.end();++it)  
    765       { 
    766         if (*it!="this")  
     746    if (content.size() > 0) 
     747    { 
     748      CSimpleNodeExpr* simpleExpr = parseExpr(content+'\0'); 
     749      expression = CFieldNode::newNode(simpleExpr); 
     750      delete simpleExpr; 
     751      set<string> instantFieldIds; 
     752      map<string,CField*> associatedInstantFieldIds; 
     753      expression->getInstantFieldIds(instantFieldIds); 
     754      for (set<string>::iterator it = instantFieldIds.begin(); it != instantFieldIds.end(); ++it) 
     755      { 
     756        if (*it != "this") 
    767757        { 
    768           if (CField::has(*it))  
     758          if (CField::has(*it)) 
    769759          { 
    770             CField* field=CField::get(*it) ; 
    771             field->processEnabledField() ; 
    772             associatedInstantFieldIds[*it]=field ; 
     760            CField* field = CField::get(*it); 
     761            field->processEnabledField(); 
     762            associatedInstantFieldIds[*it] = field; 
    773763          } 
    774           else  ERROR("void CField::buildExpression(void)",<<" Field "<<*it<<" does not exist") ; 
     764          else  ERROR("void CField::buildExpression(void)", << " Field " << *it << " does not exist"); 
    775765        } 
    776766      } 
    777        
    778       set<string> averageFieldIds ; 
    779       map<string,CField*> associatedAverageFieldIds ; 
    780  
    781       expression->getAverageFieldIds(averageFieldIds) ; 
    782       for (set<string>::iterator it=averageFieldIds.begin() ; it!=averageFieldIds.end();++it)  
    783       {       
    784         if (CField::has(*it))  
     767 
     768      set<string> averageFieldIds; 
     769      map<string,CField*> associatedAverageFieldIds; 
     770 
     771      expression->getAverageFieldIds(averageFieldIds); 
     772      for (set<string>::iterator it = averageFieldIds.begin(); it != averageFieldIds.end(); ++it) 
     773      { 
     774        if (CField::has(*it)) 
    785775        { 
    786            CFieldGroup* root=CFieldGroup::get("field_definition") ; 
    787            CField* averageField=root->createChild() ; 
    788            CField* instantField=root->createChild() ; 
    789            averageField->field_ref=*it ; 
    790            averageField->hasFieldOut=true ; 
    791            averageField->fieldOut=instantField ; 
    792            instantField->freq_op=freq_op ; 
    793            averageField-> processEnabledField() ; 
     776           CFieldGroup* root = CFieldGroup::get("field_definition"); 
     777           CField* averageField = root->createChild(); 
     778           CField* instantField = root->createChild(); 
     779           averageField->field_ref = *it; 
     780           averageField->hasFieldOut = true; 
     781           averageField->fieldOut = instantField; 
     782           instantField->freq_op = freq_op; 
     783           averageField-> processEnabledField(); 
    794784           instantField->SuperClassAttribute::setAttributes(averageField, true); 
    795            instantField->field_ref.reset() ; 
    796            instantField->operation.reset() ; 
    797  
    798            instantField-> processEnabledField() ; 
    799            associatedAverageFieldIds[*it]=instantField  ; 
     785           instantField->field_ref.reset(); 
     786           instantField->operation.reset(); 
     787 
     788           instantField-> processEnabledField(); 
     789           associatedAverageFieldIds[*it] = instantField; 
    800790        } 
    801         else ERROR("void CField::buildExpression(void)",<<" Field "<<*it<<" does not exist") ; 
    802       } 
    803  
    804       expression->reduce(this,associatedInstantFieldIds,associatedAverageFieldIds) ; 
    805  
    806       slots.resize(instantFieldIds.size()+averageFieldIds.size()) ; 
    807       resetSlots() ; 
    808       int slotId=0 ; 
    809       set<CField*> fields ; 
    810       expression->getFields(fields) ; 
    811       for (set<CField*>::iterator it=fields.begin() ; it!=fields.end();++it,++slotId) (*it)->addDependency(this,slotId) ; 
    812       hasExpression=true;  
    813     } 
    814   } 
    815    
     791        else ERROR("void CField::buildExpression(void)", << " Field " << *it << " does not exist"); 
     792      } 
     793 
     794      expression->reduce(this,associatedInstantFieldIds,associatedAverageFieldIds); 
     795 
     796      slots.resize(instantFieldIds.size() + averageFieldIds.size()); 
     797      resetSlots(); 
     798      int slotId = 0; 
     799      set<CField*> fields; 
     800      expression->getFields(fields); 
     801      for (set<CField*>::iterator it = fields.begin(); it != fields.end(); ++it, ++slotId) (*it)->addDependency(this,slotId); 
     802      hasExpression = true; 
     803    } 
     804  } 
     805 
    816806  void CField::resetSlots(void) 
    817807  { 
    818     for(vector<bool>::iterator it=slots.begin();it!=slots.end();++it) *it=false ; 
    819   } 
    820    
     808    for (vector<bool>::iterator it = slots.begin(); it != slots.end(); ++it) *it = false; 
     809  } 
     810 
    821811  bool CField::slotsFull(void) 
    822812  { 
    823     bool ret=true ; 
    824     for(vector<bool>::iterator it=slots.begin();it!=slots.end();++it) ret &= *it; 
    825     return ret ; 
    826   } 
    827  
    828    
     813    bool ret = true; 
     814    for (vector<bool>::iterator it = slots.begin(); it != slots.end(); ++it) ret &= *it; 
     815    return ret; 
     816  } 
     817 
    829818  void CField::setSlot(int slotId) 
    830819  { 
    831     CContext* context = CContext::getCurrent() ; 
    832     const CDate & currDate = context->getCalendar()->getCurrentDate(); 
    833     if (slotUpdateDate==NULL || currDate!=*slotUpdateDate)  
    834     { 
    835       resetSlots() ; 
    836       if (slotUpdateDate==NULL) slotUpdateDate=new CDate(currDate) ; 
    837       else *slotUpdateDate=currDate ; 
    838     } 
    839     slots[slotId]=true ; 
     820    CContext* context = CContext::getCurrent(); 
     821    const CDate& currDate = context->getCalendar()->getCurrentDate(); 
     822    if (slotUpdateDate == NULL || currDate != *slotUpdateDate) 
     823    { 
     824      resetSlots(); 
     825      if (slotUpdateDate == NULL) slotUpdateDate = new CDate(currDate); 
     826      else *slotUpdateDate = currDate; 
     827    } 
     828    slots[slotId] = true; 
    840829    if (slotsFull()) 
    841830    { 
    842       CArray<double,1> expr(expression->compute()) ; 
    843        
    844       if (hasInstantData)  
    845       { 
    846         instantData=expr ; 
    847         for(list< pair<CField *,int> >::iterator it=fieldDependency.begin(); it!=fieldDependency.end(); ++it)   
    848           if (it->first!=this) it->first->setSlot(it->second) ; 
    849       } 
    850        
    851       if (hasOutputFile) updateDataFromExpression(expr) ; 
    852        
    853     } 
    854   } 
    855  
    856  
     831      CArray<double,1> expr(expression->compute()); 
     832 
     833      if (hasInstantData) 
     834      { 
     835        instantData = expr; 
     836        for (list< pair<CField *,int> >::iterator it = fieldDependency.begin(); it != fieldDependency.end(); ++it) 
     837          if (it->first != this) it->first->setSlot(it->second); 
     838      } 
     839 
     840      if (hasOutputFile) updateDataFromExpression(expr); 
     841 
     842      const std::vector<CField*>& refField = getAllReference(); 
     843      for (std::vector<CField*>::const_iterator it = refField.begin(); it != refField.end(); it++) 
     844      { 
     845        if (!(*it)->hasExpression) 
     846          (*it)->setDataFromExpression(expr); 
     847      } 
     848    } 
     849  } 
    857850 
    858851   CVariable* CField::addVariable(const string& id) 
    859852   { 
    860      return vVariableGroup->createChild(id) ; 
     853     return vVariableGroup->createChild(id); 
    861854   } 
    862855 
    863856   CVariableGroup* CField::addVariableGroup(const string& id) 
    864857   { 
    865      return vVariableGroup->createChildGroup(id) ; 
    866    } 
    867  
     858     return vVariableGroup->createChildGroup(id); 
     859   } 
    868860 
    869861   void CField::sendAddVariable(const string& id) 
    870862   { 
    871     CContext* context=CContext::getCurrent() ; 
    872      
    873     if (! context->hasServer ) 
    874     { 
    875        CContextClient* client=context->client ; 
    876  
    877        CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE) ;    
     863    CContext* context = CContext::getCurrent(); 
     864 
     865    if (!context->hasServer) 
     866    { 
     867       CContextClient* client = context->client; 
     868 
     869       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE); 
    878870       if (client->isServerLeader()) 
    879871       { 
    880          CMessage msg ; 
    881          msg<<this->getId() ; 
    882          msg<<id ; 
    883          event.push(client->getServerLeader(),1,msg) ; 
    884          client->sendEvent(event) ; 
     872         CMessage msg; 
     873         msg << this->getId(); 
     874         msg << id; 
     875         event.push(client->getServerLeader(),1,msg); 
     876         client->sendEvent(event); 
    885877       } 
    886        else client->sendEvent(event) ; 
    887     } 
    888        
    889    } 
    890   
    891     
     878       else client->sendEvent(event); 
     879    } 
     880 
     881   } 
     882 
    892883   void CField::sendAddVariableGroup(const string& id) 
    893884   { 
    894     CContext* context=CContext::getCurrent() ; 
    895     if (! context->hasServer ) 
    896     { 
    897        CContextClient* client=context->client ; 
    898  
    899        CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP) ;    
     885    CContext* context = CContext::getCurrent(); 
     886    if (!context->hasServer) 
     887    { 
     888       CContextClient* client = context->client; 
     889 
     890       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP); 
    900891       if (client->isServerLeader()) 
    901892       { 
    902          CMessage msg ; 
    903          msg<<this->getId() ; 
    904          msg<<id ; 
    905          event.push(client->getServerLeader(),1,msg) ; 
    906          client->sendEvent(event) ; 
     893         CMessage msg; 
     894         msg << this->getId(); 
     895         msg << id; 
     896         event.push(client->getServerLeader(),1,msg); 
     897         client->sendEvent(event); 
    907898       } 
    908        else client->sendEvent(event) ; 
    909     } 
    910        
    911    } 
    912     
     899       else client->sendEvent(event); 
     900    } 
     901 
     902   } 
     903 
    913904   void CField::recvAddVariable(CEventServer& event) 
    914905   { 
    915        
    916       CBufferIn* buffer=event.subEvents.begin()->buffer; 
     906 
     907      CBufferIn* buffer = event.subEvents.begin()->buffer; 
    917908      string id; 
    918       *buffer>>id ; 
    919       get(id)->recvAddVariable(*buffer) ; 
    920    } 
    921     
    922     
     909      *buffer >> id; 
     910      get(id)->recvAddVariable(*buffer); 
     911   } 
     912 
    923913   void CField::recvAddVariable(CBufferIn& buffer) 
    924914   { 
    925       string id ; 
    926       buffer>>id ; 
    927       addVariable(id) ; 
     915      string id; 
     916      buffer >> id; 
     917      addVariable(id); 
    928918   } 
    929919 
    930920   void CField::recvAddVariableGroup(CEventServer& event) 
    931921   { 
    932        
    933       CBufferIn* buffer=event.subEvents.begin()->buffer; 
     922 
     923      CBufferIn* buffer = event.subEvents.begin()->buffer; 
    934924      string id; 
    935       *buffer>>id ; 
    936       get(id)->recvAddVariableGroup(*buffer) ; 
    937    } 
    938     
    939     
     925      *buffer >> id; 
     926      get(id)->recvAddVariableGroup(*buffer); 
     927   } 
     928 
    940929   void CField::recvAddVariableGroup(CBufferIn& buffer) 
    941930   { 
    942       string id ; 
    943       buffer>>id ; 
    944       addVariableGroup(id) ; 
    945    } 
    946  
    947  
    948  
    949    
     931      string id; 
     932      buffer >> id; 
     933      addVariableGroup(id); 
     934   } 
    950935} // namespace xios 
  • XIOS/trunk/inputs/COMPLETE/context_surface.xml

    r549 r562  
    11<!-- Context surface --> 
    2    
     2 
    33<context id="surface"> 
    44 
    55  <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"> 
    66    <field id="field_A_srf"  name="field_A_srf" long_name="Champ en degC" operation="average" unit="degC" /> 
     7    <field id="field_A_srf_2" field_ref="field_A_srf" /> 
    78    <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> 
     9    <field id="field_A_srf_K_2" field_ref="field_A_srf_K" /> 
    810    <field id="field_A_srf_max" name="field_A_srf_max" field_ref="field_A_srf" long_name="maximum field_A_srf" operation="maximum" /> 
    9     <field id="field_D_srf" name="field_D_srf" long_name="Somme champ A et C" > field_A_srf + field_C_srf </field> 
    10      
     11    <field id="field_D_srf" name="field_D_srf" long_name="Somme champ A et C"> field_A_srf + field_C_srf </field> 
    1112  </field_definition> 
    12      
     13 
    1314  <file_definition type="multiple_file" par_access="collective" output_level="10" enabled=".TRUE."> 
    14     <file id="output_surface" name="output_surface_6h" output_freq="6h" >  
    15       <field field_ref="field_A_srf" > 
    16         <variable id="my_attribute1" type="string" >surf_att</variable> 
    17         <variable id="my_attribute2" type="int" > 10 </variable> 
    18         <variable id="my_attribute3" type="float" >6.8</variable> 
    19         <variable id="my_attribute5" type="double" >100.201</variable> 
     15    <file id="output_surface" name="output_surface_6h" output_freq="6h"> 
     16      <field field_ref="field_A_srf"> 
     17        <variable id="my_attribute1" type="string">surf_att</variable> 
     18        <variable id="my_attribute2" type="int"> 10 </variable> 
     19        <variable id="my_attribute3" type="float">6.8</variable> 
     20        <variable id="my_attribute5" type="double">100.201</variable> 
     21      </field> 
     22      <field field_ref="field_A_srf_K" /> 
     23      <field field_ref="field_A_srf_K_2" name="field_A_srf_K_2" /> <!-- Should be identical to field_A_srf_K --> 
     24      <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 --> 
     25      <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> 
     26      <field field_ref="field_A_srf" name="field_A_srf_min" operation="minimum" /> 
     27      <field field_ref="field_A_srf_2" name="field_A_srf_min_2" operation="minimum" /> <!-- Should be identical to field_A_srf_min --> 
     28      <field field_ref="field_A_srf" name="field_A_srf_max" operation="maximum" /> 
     29      <field field_ref="field_A_srf" name="field_A_srf_prec4" prec="8" /> 
     30      <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> 
     31      <variable id="my_global_attribute" type="string">file_6h</variable> 
     32    </file> 
     33 
     34    <file type="one_file" id="output_surface_1d" name="output_surface_1d" output_freq="1d"> 
     35      <field field_ref="field_A_srf"> 
     36        <variable id="my_attribute1" type="string">surf_att</variable> 
     37        <variable id="my_attribute2" type="int">10</variable> 
     38        <variable id="my_attribute3" type="float">6.8</variable> 
     39        <variable id="my_attribute4" type="double">100.201</variable> 
    2040      </field> 
    2141      <field field_ref="field_A_srf_K" /> 
    2242      <field field_ref="field_A_srf" name="field_A_srf_min" operation="minimum" /> 
    2343      <field field_ref="field_A_srf" name="field_A_srf_max" operation="maximum" /> 
    24       <field field_ref="field_A_srf" name="field_A_srf_prec4" prec="8"/> 
    25       <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> 
    26       <variable id="my_global_attribute" type="string" >file_6h</variable> 
    27     </file> 
    28  
    29     <file type="one_file" id="output_surface_1d" name="output_surface_1d" output_freq="1d" >  
    30       <field field_ref="field_A_srf" > 
    31         <variable id="my_attribute1" type="string" >surf_att</variable> 
    32         <variable id="my_attribute2" type="int" >10</variable> 
    33         <variable id="my_attribute3" type="float" >6.8</variable> 
    34         <variable id="my_attribute4" type="double" >100.201</variable> 
    35       </field> 
    36       <field field_ref="field_A_srf_K" /> 
    37       <field field_ref="field_A_srf" name="field_A_srf_min" operation="minimum" /> 
    38       <field field_ref="field_A_srf" name="field_A_srf_max" operation="maximum" /> 
    39       <field field_ref="field_A_srf" name="field_A_srf_prec4" prec="8"/> 
    40       <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> 
     44      <field field_ref="field_A_srf" name="field_A_srf_prec4" prec="8" /> 
     45      <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> 
    4146      <variable id="my_global_attribute" type="string" >file_1d</variable> 
    4247    </file> 
    4348  </file_definition> 
    44   
    45    <axis_definition> 
    46      <axis id="axis_srf"/> 
    47    </axis_definition> 
    48      
    49    <domain_definition> 
    50      <domain id="domain_srf" /> 
    51    </domain_definition>     
    52    
    53    <grid_definition />     
    54    
     49 
     50  <axis_definition> 
     51    <axis id="axis_srf" /> 
     52  </axis_definition> 
     53 
     54  <domain_definition> 
     55    <domain id="domain_srf" /> 
     56  </domain_definition> 
     57 
     58  <grid_definition /> 
     59 
    5560</context> 
  • XIOS/trunk/src/node/field.cpp

    r551 r562  
    2626      , foperation(), hasInstantData(false), hasExpression(false) 
    2727      , active(false) , hasOutputFile(false),hasFieldOut(false), slotUpdateDate(NULL) 
    28       , processed(false), domAxisIds_("",""), areAllReferenceSolved(false), areAllExpressionBuilt(false) 
    29       { setVirtualVariableGroup() ; } 
    30  
    31    CField::CField(const StdString & id) 
     28      , processed(false), domAxisIds_("", ""), areAllReferenceSolved(false), areAllExpressionBuilt(false) 
     29      { setVirtualVariableGroup(); } 
     30 
     31   CField::CField(const StdString& id) 
    3232      : CObjectTemplate<CField>(id), CFieldAttributes() 
    3333      , refObject(), baseRefObject() 
     
    3838      , foperation(), hasInstantData(false), hasExpression(false) 
    3939      , active(false), hasOutputFile(false), hasFieldOut(false), slotUpdateDate(NULL) 
    40       , processed(false), domAxisIds_("",""), areAllReferenceSolved(false), areAllExpressionBuilt(false) 
    41    { setVirtualVariableGroup() ; } 
     40      , processed(false), domAxisIds_("", ""), areAllReferenceSolved(false), areAllExpressionBuilt(false) 
     41   { setVirtualVariableGroup(); } 
    4242 
    4343   CField::~CField(void) 
    4444   { 
    45 //      this->grid.reset() ; 
    46 //      this->file.reset() ; 
    47       this->foperation.reset() ; 
    48       if (hasExpression) delete expression ; 
    49       if (slotUpdateDate!=NULL) delete slotUpdateDate ; 
     45//      this->grid.reset(); 
     46//      this->file.reset(); 
     47      this->foperation.reset(); 
     48      if (hasExpression) delete expression; 
     49      if (slotUpdateDate != NULL) delete slotUpdateDate; 
    5050 
    5151   } 
     
    6666   CVariableGroup* CField::getVirtualVariableGroup(void) const 
    6767   { 
    68       return (this->vVariableGroup); 
     68      return this->vVariableGroup; 
    6969   } 
    7070 
     
    7272   std::vector<CVariable*> CField::getAllVariables(void) const 
    7373   { 
    74       return (this->vVariableGroup->getAllChildren()); 
    75    } 
    76  
    77    void CField::solveDescInheritance(bool apply, const CAttributeMap * const parent) 
    78    { 
    79       SuperClassAttribute::setAttributes(parent,apply); 
     74      return this->vVariableGroup->getAllChildren(); 
     75   } 
     76 
     77   void CField::solveDescInheritance(bool apply, const CAttributeMap* const parent) 
     78   { 
     79      SuperClassAttribute::setAttributes(parent, apply); 
    8080      this->getVirtualVariableGroup()->solveDescInheritance(apply, NULL); 
    8181   } 
     
    8484 
    8585   bool CField::updateDataServer 
    86       (const CDate & currDate, 
     86      (const CDate& currDate, 
    8787       const std::deque< CArray<double, 1>* > storedClient) 
    8888   { 
     
    9494         if (this->data.numElements() != this->grid->storeIndex[0]->numElements()) 
    9595         { 
    96             this->data.resize(this->grid->storeIndex[0] ->numElements()); 
     96            this->data.resize(this->grid->storeIndex[0]->numElements()); 
    9797         } 
    98          CArray<double,1> input(data.numElements()) ; 
     98         CArray<double,1> input(data.numElements()); 
    9999         this->grid->inputFieldServer(storedClient, input); 
    100100         (*this->foperation)(input); 
     
    106106         this->incrementNStep(); 
    107107         *last_Write = writeDate; 
    108          return (true); 
    109       } 
    110       return (false); 
     108         return true; 
     109      } 
     110      return false; 
    111111   } 
    112112 
     
    114114  { 
    115115 
    116     if (SuperClass::dispatchEvent(event)) return true ; 
     116    if (SuperClass::dispatchEvent(event)) return true; 
    117117    else 
    118118    { 
     
    120120      { 
    121121        case EVENT_ID_UPDATE_DATA : 
    122           recvUpdateData(event) ; 
    123           return true ; 
    124           break ; 
     122          recvUpdateData(event); 
     123          return true; 
     124          break; 
    125125 
    126126            case EVENT_ID_ADD_VARIABLE : 
    127              recvAddVariable(event) ; 
    128              return true ; 
    129              break ; 
     127             recvAddVariable(event); 
     128             return true; 
     129             break; 
    130130 
    131131           case EVENT_ID_ADD_VARIABLE_GROUP : 
    132              recvAddVariableGroup(event) ; 
    133              return true ; 
    134              break ; 
     132             recvAddVariableGroup(event); 
     133             return true; 
     134             break; 
    135135 
    136136        default : 
    137           ERROR("bool CField::dispatchEvent(CEventServer& event)",<<"Unknown Event") ; 
    138           return false ; 
     137          ERROR("bool CField::dispatchEvent(CEventServer& event)", << "Unknown Event"); 
     138          return false; 
    139139      } 
    140140    } 
     
    143143  void CField::sendUpdateData(void) 
    144144  { 
    145     CContext* context = CContext::getCurrent() ; 
    146     CContextClient* client=context->client ; 
    147  
    148     CEventClient event(getType(),EVENT_ID_UPDATE_DATA) ; 
    149  
    150     map<int,CArray<int, 1>* >::iterator it ; 
    151     list<shared_ptr<CMessage> > list_msg ; 
    152     list< CArray<double,1>* > list_data ; 
    153  
    154      for(it=grid->storeIndex_toSrv.begin();it!=grid->storeIndex_toSrv.end();it++) 
    155     { 
    156       int rank=(*it).first ; 
    157       CArray<int,1>& index = *(it->second) ; 
    158       CArray<double,1> data_tmp(index.numElements()) ; 
    159       for(int n=0;n<data_tmp.numElements();n++) data_tmp(n)=data(index(n)) ; 
    160       list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; 
    161       list_data.push_back(new CArray<double,1>(data_tmp)) ; 
    162       *list_msg.back()<<getId()<<*list_data.back() ; 
    163       event.push(rank,grid->nbSenders[rank],*list_msg.back()) ; 
    164     } 
    165     client->sendEvent(event) ; 
    166  
    167     for(list< CArray<double,1>* >::iterator it=list_data.begin();it!=list_data.end();it++) delete *it ; 
     145    CContext* context = CContext::getCurrent(); 
     146    CContextClient* client = context->client; 
     147 
     148    CEventClient event(getType(),EVENT_ID_UPDATE_DATA); 
     149 
     150    map<int,CArray<int, 1>* >::iterator it; 
     151    list<shared_ptr<CMessage> > list_msg; 
     152    list< CArray<double,1>* > list_data; 
     153 
     154     for (it = grid->storeIndex_toSrv.begin(); it != grid->storeIndex_toSrv.end(); it++) 
     155    { 
     156      int rank = (*it).first; 
     157      CArray<int,1>& index = *(it->second); 
     158      CArray<double,1> data_tmp(index.numElements()); 
     159      for (int n = 0; n < data_tmp.numElements(); n++) data_tmp(n) = data(index(n)); 
     160      list_msg.push_back(shared_ptr<CMessage>(new CMessage)); 
     161      list_data.push_back(new CArray<double,1>(data_tmp)); 
     162      *list_msg.back() << getId() << *list_data.back(); 
     163      event.push(rank,grid->nbSenders[rank],*list_msg.back()); 
     164    } 
     165    client->sendEvent(event); 
     166 
     167    for (list< CArray<double,1>* >::iterator it = list_data.begin(); it != list_data.end(); it++) delete *it; 
    168168  } 
    169169 
    170170  void CField::recvUpdateData(CEventServer& event) 
    171171  { 
    172     vector<int> ranks ; 
    173     vector<CBufferIn*> buffers ; 
    174  
    175     list<CEventServer::SSubEvent>::iterator it ; 
    176     string fieldId ; 
    177  
    178     for (it=event.subEvents.begin();it!=event.subEvents.end();++it) 
    179     { 
    180       int rank=it->rank; 
    181       CBufferIn* buffer=it->buffer; 
    182       *buffer>>fieldId ; 
    183       ranks.push_back(rank) ; 
    184       buffers.push_back(buffer) ; 
    185     } 
    186     get(fieldId)->recvUpdateData(ranks,buffers) ; 
     172    vector<int> ranks; 
     173    vector<CBufferIn*> buffers; 
     174 
     175    list<CEventServer::SSubEvent>::iterator it; 
     176    string fieldId; 
     177 
     178    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
     179    { 
     180      int rank = it->rank; 
     181      CBufferIn* buffer = it->buffer; 
     182      *buffer >> fieldId; 
     183      ranks.push_back(rank); 
     184      buffers.push_back(buffer); 
     185    } 
     186    get(fieldId)->recvUpdateData(ranks,buffers); 
    187187  } 
    188188 
     
    192192    if (data_srv.empty()) 
    193193    { 
    194 //      for(map<int, CArray<int, 1>* >::iterator it=grid->out_i_fromClient.begin();it!=grid->out_i_fromClient.end();it++) 
    195       for(map<int, CArray<size_t, 1>* >::iterator it=grid->outIndexFromClient.begin();it!=grid->outIndexFromClient.end();++it) 
    196       { 
    197         int rank=it->first ; 
    198         CArray<double,1> data_tmp(it->second->numElements()) ; 
    199         data_srv.insert( pair<int, CArray<double,1>* >(rank, new CArray<double,1>(data_tmp) ) ) ; 
    200         foperation_srv.insert(pair<int,boost::shared_ptr<func::CFunctor> >(rank,boost::shared_ptr<func::CFunctor>(new func::CInstant(*data_srv[rank])))) ; 
    201       } 
    202     } 
    203  
    204     CContext* context = CContext::getCurrent() ; 
    205     const CDate & currDate = context->getCalendar()->getCurrentDate(); 
     194//      for (map<int, CArray<int, 1>* >::iterator it = grid->out_i_fromClient.begin(); it != grid->out_i_fromClient.end(); it++) 
     195      for (map<int, CArray<size_t, 1>* >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 
     196      { 
     197        int rank = it->first; 
     198        CArray<double,1> data_tmp(it->second->numElements()); 
     199        data_srv.insert( pair<int, CArray<double,1>* >(rank, new CArray<double,1>(data_tmp))); 
     200        foperation_srv.insert(pair<int,boost::shared_ptr<func::CFunctor> >(rank,boost::shared_ptr<func::CFunctor>(new func::CInstant(*data_srv[rank])))); 
     201      } 
     202    } 
     203 
     204    CContext* context = CContext::getCurrent(); 
     205    const CDate& currDate = context->getCalendar()->getCurrentDate(); 
    206206    const CDate opeDate      = *last_operation_srv + freq_operation_srv; 
    207207    const CDate writeDate    = *last_Write_srv     + freq_write_srv; 
    208208 
    209  
    210  
    211209    if (opeDate <= currDate) 
    212210    { 
    213       for(int n=0;n<ranks.size();n++) 
    214       { 
    215         CArray<double,1> data_tmp ; 
    216         *buffers[n]>>data_tmp ; 
    217         (*foperation_srv[ranks[n]])(data_tmp) ; 
     211      for (int n = 0; n < ranks.size(); n++) 
     212      { 
     213        CArray<double,1> data_tmp; 
     214        *buffers[n] >> data_tmp; 
     215        (*foperation_srv[ranks[n]])(data_tmp); 
    218216      } 
    219217      *last_operation_srv = currDate; 
     
    222220    if (writeDate < (currDate + freq_operation_srv)) 
    223221    { 
    224       for(int n=0;n<ranks.size();n++) 
     222      for (int n = 0; n < ranks.size(); n++) 
    225223      { 
    226224        this->foperation_srv[ranks[n]]->final(); 
     
    228226 
    229227      *last_Write_srv = writeDate; 
    230       writeField() ; 
    231       *lastlast_Write_srv=*last_Write_srv; 
     228      writeField(); 
     229      *lastlast_Write_srv = *last_Write_srv; 
    232230    } 
    233231  } 
     
    235233  void CField::writeField(void) 
    236234  { 
    237     if (! getRelFile()->allDomainEmpty ) 
    238       if (! grid->domain->isEmpty() || getRelFile()->type == CFile::type_attr::one_file) 
     235    if (!getRelFile()->allDomainEmpty) 
     236      if (!grid->domain->isEmpty() || getRelFile()->type == CFile::type_attr::one_file) 
    239237      { 
    240238        getRelFile()->checkFile(); 
     
    243241      } 
    244242  } 
     243 
    245244   //---------------------------------------------------------------- 
    246245 
     
    248247   { 
    249248      this->file = _file; 
    250       hasOutputFile=true ; 
    251    } 
    252  
    253    //---------------------------------------------------------------- 
    254  
    255    StdString CField::GetName(void)   { return (StdString("field")); } 
    256    StdString CField::GetDefName(void){ return (CField::GetName()); } 
    257    ENodeType CField::GetType(void)   { return (eField); } 
     249      hasOutputFile = true; 
     250   } 
     251 
     252   //---------------------------------------------------------------- 
     253 
     254   StdString CField::GetName(void)    { return StdString("field"); } 
     255   StdString CField::GetDefName(void) { return CField::GetName(); } 
     256   ENodeType CField::GetType(void)    { return eField; } 
    258257 
    259258   //---------------------------------------------------------------- 
     
    261260   CGrid* CField::getRelGrid(void) const 
    262261   { 
    263       return (this->grid); 
     262      return this->grid; 
    264263   } 
    265264 
     
    268267   CFile* CField::getRelFile(void) const 
    269268   { 
    270       return (this->file); 
     269      return this->file; 
    271270   } 
    272271 
    273272   StdSize CField::getNStep(void) const 
    274273   { 
    275       return (this->nstep); 
     274      return this->nstep; 
    276275   } 
    277276 
     
    283282   void CField::resetNStep(void) 
    284283   { 
    285       this->nstep=0; 
    286    } 
    287  
    288    //---------------------------------------------------------------- 
    289  
    290    const CDuration & CField::getFreqOperation(void) const 
    291    { 
    292       return (this->freq_operation); 
    293    } 
    294  
    295    //---------------------------------------------------------------- 
    296    const CDuration & CField::getFreqWrite(void) const 
    297    { 
    298       return (this->freq_write); 
     284      this->nstep = 0; 
     285   } 
     286 
     287   //---------------------------------------------------------------- 
     288 
     289   const CDuration& CField::getFreqOperation(void) const 
     290   { 
     291      return this->freq_operation; 
     292   } 
     293 
     294   //---------------------------------------------------------------- 
     295 
     296   const CDuration& CField::getFreqWrite(void) const 
     297   { 
     298      return this->freq_write; 
    299299   } 
    300300 
     
    303303   boost::shared_ptr<func::CFunctor> CField::getFieldOperation(void) const 
    304304   { 
    305       return (this->foperation); 
    306    } 
    307  
     305      return this->foperation; 
     306   } 
    308307 
    309308   bool CField::isActive(void) const 
    310309   { 
    311       return (!this->refObject.empty()); 
    312    } 
     310      return !this->refObject.empty(); 
     311   } 
     312 
    313313   //---------------------------------------------------------------- 
    314314 
     
    338338//      if (!processed) 
    339339//      { 
    340 //        processed=true ; 
    341 //        solveRefInheritance(true) ; 
    342 //        solveBaseReference() ; 
    343 //        solveOperation() ; 
    344 //        solveGridReference() ; 
    345 // 
    346 //        if (hasDirectFieldReference()) baseRefObject->processEnabledField() ; 
     340//        processed = true; 
     341//        solveRefInheritance(true); 
     342//        solveBaseReference(); 
     343//        solveOperation(); 
     344//        solveGridReference(); 
     345// 
     346//        if (hasDirectFieldReference()) baseRefObject->processEnabledField(); 
    347347//        buildExpression(); 
    348 //        active=true; 
     348//        active = true; 
    349349//      } 
    350350//    } 
     
    384384       if (hasDirectFieldReference()) baseRefObject->buildAllExpressionEnabledField(); 
    385385       buildExpression(); 
    386        active=true; 
     386       active = true; 
    387387     } 
    388388   } 
     
    394394      using namespace func; 
    395395 
    396       if (!hasOutputFile && !hasFieldOut) return ; 
    397  
    398       StdString id ; 
    399       if (hasId()) id=getId(); 
    400       else if (!name.isEmpty()) id=name ; 
    401       else if (hasDirectFieldReference()) id=baseRefObject->getId() ; 
     396      if (!hasOutputFile && !hasFieldOut) return; 
     397 
     398      StdString id; 
     399      if (hasId()) id = getId(); 
     400      else if (!name.isEmpty()) id = name; 
     401      else if (hasDirectFieldReference()) id = baseRefObject->getId(); 
    402402 
    403403      CContext* context = CContext::getCurrent(); 
     
    405405      if (freq_op.isEmpty()) freq_op.setValue(TimeStep); 
    406406 
    407       if (operation.isEmpty() ) 
     407      if (operation.isEmpty()) 
    408408      { 
    409409         ERROR("CField::solveOperation(void)", 
     
    455455         *this->last_operation   = *this->last_operation - toffset; 
    456456 
    457         if (operation.get()=="once") isOnceOperation=true ; 
    458         else isOnceOperation=false; 
    459         isFirstOperation=true; 
    460  
    461  
    462 #define DECLARE_FUNCTOR(MType, mtype)              \ 
    463    if  (operation.getValue().compare(#mtype) == 0) \ 
    464    {                                               \ 
    465       if (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value==true) \ 
     457        if (operation.get() == "once") isOnceOperation = true; 
     458        else isOnceOperation = false; 
     459        isFirstOperation = true; 
     460 
     461#define DECLARE_FUNCTOR(MType, mtype) \ 
     462   if (operation.getValue().compare(#mtype) == 0) \ 
     463   { \ 
     464      if (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true) \ 
    466465      { \ 
    467466        boost::shared_ptr<func::CFunctor> foperation_(new C##MType(this->data,default_value)); \ 
     
    471470      { \ 
    472471        boost::shared_ptr<func::CFunctor> foperation_(new C##MType(this->data)); \ 
    473         this->foperation = foperation_;  \ 
     472        this->foperation = foperation_; \ 
    474473      } \ 
    475       return;                                      \ 
     474      return; \ 
    476475   } 
    477476 
     
    482481               << "The operation is not defined !"); 
    483482//      } 
    484  
    485  
    486483   } 
    487484 
    488485   //---------------------------------------------------------------- 
    489486/* 
    490    void CField::fromBinary(StdIStream & is) 
     487   void CField::fromBinary(StdIStream& is) 
    491488   { 
    492489      SuperClass::fromBinary(is); 
     
    514511         if (CDomain::has(domain_ref.getValue())) 
    515512         { 
    516            domain = CDomain::get(domain_ref.getValue()) ; 
     513           domain = CDomain::get(domain_ref.getValue()); 
    517514           vecDom.push_back(domain); 
    518515         } 
     
    520517            ERROR("CField::solveGridReference(void)", 
    521518                  << "Reference to the domain \'" 
    522                   << domain_ref.getValue() << "\' is wrong") ; 
     519                  << domain_ref.getValue() << "\' is wrong"); 
    523520      } 
    524521 
     
    527524         if (CAxis::has(axis_ref.getValue())) 
    528525         { 
    529            axis = CAxis::get(axis_ref.getValue()) ; 
     526           axis = CAxis::get(axis_ref.getValue()); 
    530527           vecAxis.push_back(axis); 
    531528         } 
     
    533530            ERROR("CField::solveGridReference(void)", 
    534531                  << "Reference to the axis \'" 
    535                   << axis_ref.getValue() <<"\' is wrong") ; 
     532                  << axis_ref.getValue() <<"\' is wrong"); 
    536533      } 
    537534 
     
    540537         if (CGrid::has(grid_ref.getValue())) 
    541538         { 
    542            this->grid = CGrid::get(grid_ref.getValue()) ; 
     539           this->grid = CGrid::get(grid_ref.getValue()); 
    543540           domList = grid->getDomainList(); 
    544541           axisList = grid->getAxisList(); 
     
    550547      } 
    551548 
    552       if (grid_ref.isEmpty() &&  domain_ref.isEmpty() && axis_ref.isEmpty()) 
     549      if (grid_ref.isEmpty() && domain_ref.isEmpty() && axis_ref.isEmpty()) 
    553550      { 
    554551            ERROR("CField::solveGridReference(void)", 
     
    562559//     } 
    563560 
    564 //     CType<string> goodDomain ; 
    565 //     CType<string> goodAxis ; 
     561//     CType<string> goodDomain; 
     562//     CType<string> goodAxis; 
    566563//     if (!grid_ref.isEmpty()) 
    567564//     { 
    568 //       if (!grid->domain_ref.isEmpty()) goodDomain=grid->domain_ref ; 
    569 //       if (!grid->axis_ref.isEmpty()) goodAxis=grid->axis_ref ; 
     565//       if (!grid->domain_ref.isEmpty()) goodDomain = grid->domain_ref; 
     566//       if (!grid->axis_ref.isEmpty()) goodAxis = grid->axis_ref; 
    570567//     } 
    571 //     if (!domain_ref.isEmpty()) goodDomain=domain_ref ; 
    572 //     if (!axis_ref.isEmpty()) goodAxis=axis_ref ; 
     568//     if (!domain_ref.isEmpty()) goodDomain = domain_ref; 
     569//     if (!axis_ref.isEmpty()) goodAxis = axis_ref; 
    573570 
    574571//     CArray<std::string,1> domListTmp = grid->domainList.getValue(); 
     
    590587//     else 
    591588//     { 
    592 //       if (CDomain::has(goodDomain)) domain = CDomain::get(goodDomain) ; 
     589//       if (CDomain::has(goodDomain)) domain = CDomain::get(goodDomain); 
    593590//       else ERROR("CField::solveGridReference(void)",<< "Reference to the domain \'" 
    594 //                  <<goodDomain << "\' is wrong") ; 
    595 ////                  <<goodDomain.get() << "\' is wrong") ; 
     591//                  << goodDomain << "\' is wrong"); 
     592////                << goodDomain.get() << "\' is wrong"); 
    596593//     } 
    597594// 
     
    599596//     if (!goodAxis.empty()) 
    600597//     { 
    601 //       if (CAxis::has(goodAxis))  axis = CAxis::get(goodAxis) ; 
     598//       if (CAxis::has(goodAxis))  axis = CAxis::get(goodAxis); 
    602599//       else  ERROR("CField::solveGridReference(void)", << "Reference to the axis \'" 
    603 //                  << goodAxis <<"\' is wrong") ; 
    604 //                  << goodAxis.get() <<"\' is wrong") ; 
     600//                   << goodAxis <<"\' is wrong"); 
     601//                   << goodAxis.get() <<"\' is wrong"); 
    605602//     } 
    606603 
    607 //     bool nothingToDo=false ; 
     604//     bool nothingToDo = false; 
    608605// 
    609606//     if (!grid_ref.isEmpty()) 
    610607//     { 
    611608//       if (!grid->domain_ref.isEmpty() && goodDomain.get() == grid->domain_ref.get()) 
    612 //         if (goodAxis.isEmpty()) nothingToDo=true ; 
     609//         if (goodAxis.isEmpty()) nothingToDo = true; 
    613610//         else if (!grid->axis_ref.isEmpty()) 
    614 //                 if (grid->axis_ref.get()==goodAxis.get()) nothingToDo=true ; 
     611//                 if (grid->axis_ref.get() == goodAxis.get()) nothingToDo = true; 
    615612//     } 
    616613// 
     
    620617//       if (!goodAxis.isEmpty()) 
    621618//       { 
    622 //         this->grid = CGrid::createGrid(domain, axis) ; 
     619//         this->grid = CGrid::createGrid(domain, axis); 
    623620//         this->grid_ref.setValue(this->grid->getId()); 
    624621//       } 
    625622//       else 
    626623//       { 
    627 //         this->grid = CGrid::createGrid(domain) ; 
     624//         this->grid = CGrid::createGrid(domain); 
    628625//         this->grid_ref.setValue(this->grid->getId()); 
    629626//       } 
    630627//     } 
    631628 
    632 //     grid->solveReference() ; 
     629//     grid->solveReference(); 
    633630//     grid->solveDomainAxisRef(); 
    634631//     grid->checkMaskIndex(); 
     
    648645 
    649646   template <> 
    650       void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void) 
     647   void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void) 
    651648   { 
    652649      if (this->group_ref.isEmpty()) return; 
     
    662659 
    663660      std::vector<CField*> allChildren  = group->getAllChildren(); 
    664       std::vector<CField*>::iterator 
    665          it = allChildren.begin(), end = allChildren.end(); 
     661      std::vector<CField*>::iterator it = allChildren.begin(), end = allChildren.end(); 
    666662 
    667663      for (; it != end; it++) 
    668664      { 
    669665         CField* child = *it; 
    670          if (child->hasId()) owner->createChild()->field_ref.setValue(child->getId()) ; 
     666         if (child->hasId()) owner->createChild()->field_ref.setValue(child->getId()); 
    671667 
    672668      } 
     
    676672   { 
    677673     map<int, CArray<double,1>* >::iterator it; 
    678      for(it=data_srv.begin();it!=data_srv.end();it++) *it->second = (*it->second -addOffset) * 1./scaleFactor  ; 
     674     for (it = data_srv.begin(); it != data_srv.end(); it++) *it->second = (*it->second - addOffset) / scaleFactor; 
    679675   } 
    680676 
     
    682678   { 
    683679      map<int, CArray<double,1>* >::iterator it; 
    684       for(it=data_srv.begin();it!=data_srv.end();it++) 
    685       { 
    686         grid->outputField(it->first,*it->second, fieldOut.dataFirst()) ; 
    687       } 
    688  
    689 //         grid->outputField(it->first,*it->second, fieldOut.) ; 
    690  
     680      for (it = data_srv.begin(); it != data_srv.end(); it++) 
     681      { 
     682        grid->outputField(it->first,*it->second, fieldOut.dataFirst()); 
     683      } 
     684 
     685//         grid->outputField(it->first,*it->second, fieldOut.); 
    691686   } 
    692687 
     
    695690      map<int, CArray<double,1>* >::iterator it; 
    696691 
    697       for(it=data_srv.begin();it!=data_srv.end();it++) 
    698       { 
    699          grid->outputField(it->first,*it->second, fieldOut) ; 
     692      for (it = data_srv.begin(); it != data_srv.end(); it++) 
     693      { 
     694         grid->outputField(it->first, *it->second, fieldOut); 
    700695      } 
    701696   } 
     
    703698   ///------------------------------------------------------------------- 
    704699 
    705    void CField::parse(xml::CXMLNode & node) 
     700   void CField::parse(xml::CXMLNode& node) 
    706701   { 
    707702      SuperClass::parse(node); 
    708       if (! node.getContent(this->content)) 
     703      if (!node.getContent(this->content)) 
    709704      { 
    710705        if (node.goToChildElement()) 
     
    712707          do 
    713708          { 
    714             if (node.getElementName()=="variable" || node.getElementName()=="variable_group") this->getVirtualVariableGroup()->parseChild(node); 
    715           } while (node.goToNextElement()) ; 
     709            if (node.getElementName() == "variable" || node.getElementName() == "variable_group") this->getVirtualVariableGroup()->parseChild(node); 
     710          } while (node.goToNextElement()); 
    716711          node.goToParentElement(); 
    717712        } 
     
    723718    if (!hasInstantData) 
    724719    { 
    725       instantData.resize(grid->storeIndex_client.numElements()) ; 
    726       hasInstantData=true ; 
    727     } 
    728     return &instantData ; 
     720      instantData.resize(grid->storeIndex_client.numElements()); 
     721      hasInstantData = true; 
     722    } 
     723    return &instantData; 
    729724  } 
    730725 
    731726  void CField::addDependency(CField* field, int slotId) 
    732727  { 
    733     fieldDependency.push_back(pair<CField*,int>(field,slotId)) ; 
     728    fieldDependency.push_back(pair<CField*,int>(field,slotId)); 
    734729  } 
    735730 
     
    738733    if (content.size() > 0) 
    739734    { 
    740       CSimpleNodeExpr* simpleExpr=parseExpr(content+'\0') ; 
    741       expression=CFieldNode::newNode(simpleExpr) ; 
    742       delete simpleExpr ; 
    743       set<string> instantFieldIds ; 
    744       map<string,CField*> associatedInstantFieldIds ; 
    745       expression->getInstantFieldIds(instantFieldIds) ; 
    746       for (set<string>::iterator it=instantFieldIds.begin() ; it!=instantFieldIds.end();++it) 
    747       { 
    748         if (*it!="this") 
     735      CSimpleNodeExpr* simpleExpr = parseExpr(content+'\0'); 
     736      expression = CFieldNode::newNode(simpleExpr); 
     737      delete simpleExpr; 
     738      set<string> instantFieldIds; 
     739      map<string,CField*> associatedInstantFieldIds; 
     740      expression->getInstantFieldIds(instantFieldIds); 
     741      for (set<string>::iterator it = instantFieldIds.begin(); it != instantFieldIds.end(); ++it) 
     742      { 
     743        if (*it != "this") 
    749744        { 
    750745          if (CField::has(*it)) 
    751746          { 
    752             CField* field=CField::get(*it) ; 
    753 //            field->processEnabledField() ; 
     747            CField* field = CField::get(*it); 
     748//            field->processEnabledField(); 
    754749            field->buildAllExpressionEnabledField(); 
    755             associatedInstantFieldIds[*it]=field ; 
     750            associatedInstantFieldIds[*it] = field; 
    756751          } 
    757           else  ERROR("void CField::buildExpression(void)",<<" Field "<<*it<<" does not exist") ; 
     752          else  ERROR("void CField::buildExpression(void)", << " Field " << *it << " does not exist"); 
    758753        } 
    759754      } 
    760755 
    761       set<string> averageFieldIds ; 
    762       map<string,CField*> associatedAverageFieldIds ; 
    763  
    764       expression->getAverageFieldIds(averageFieldIds) ; 
    765       for (set<string>::iterator it=averageFieldIds.begin() ; it!=averageFieldIds.end();++it) 
     756      set<string> averageFieldIds; 
     757      map<string,CField*> associatedAverageFieldIds; 
     758 
     759      expression->getAverageFieldIds(averageFieldIds); 
     760      for (set<string>::iterator it = averageFieldIds.begin(); it != averageFieldIds.end(); ++it) 
    766761      { 
    767762        if (CField::has(*it)) 
    768763        { 
    769            CFieldGroup* root=CFieldGroup::get("field_definition") ; 
    770            CField* averageField=root->createChild() ; 
    771            CField* instantField=root->createChild() ; 
    772            averageField->field_ref=*it ; 
    773            averageField->hasFieldOut=true ; 
    774            averageField->fieldOut=instantField ; 
    775            instantField->freq_op=freq_op ; 
    776 //           averageField-> processEnabledField() ; 
     764           CFieldGroup* root = CFieldGroup::get("field_definition"); 
     765           CField* averageField = root->createChild(); 
     766           CField* instantField = root->createChild(); 
     767           averageField->field_ref = *it; 
     768           averageField->hasFieldOut = true; 
     769           averageField->fieldOut = instantField; 
     770           instantField->freq_op = freq_op; 
     771//           averageField-> processEnabledField(); 
    777772           averageField->buildAllExpressionEnabledField(); 
    778773           instantField->SuperClassAttribute::setAttributes(averageField, true); 
    779            instantField->field_ref.reset() ; 
    780            instantField->operation.reset() ; 
    781  
    782 //           instantField-> processEnabledField() ; 
     774           instantField->field_ref.reset(); 
     775           instantField->operation.reset(); 
     776 
     777//           instantField-> processEnabledField(); 
    783778           instantField->buildAllExpressionEnabledField(); 
    784            associatedAverageFieldIds[*it]=instantField  ; 
     779           associatedAverageFieldIds[*it] = instantField; 
    785780        } 
    786         else ERROR("void CField::buildExpression(void)",<<" Field "<<*it<<" does not exist") ; 
    787       } 
    788  
    789       expression->reduce(this,associatedInstantFieldIds,associatedAverageFieldIds) ; 
    790  
    791       slots.resize(instantFieldIds.size()+averageFieldIds.size()) ; 
    792       resetSlots() ; 
    793       int slotId=0 ; 
    794       set<CField*> fields ; 
    795       expression->getFields(fields) ; 
    796       for (set<CField*>::iterator it=fields.begin() ; it!=fields.end();++it,++slotId) (*it)->addDependency(this,slotId) ; 
    797       hasExpression=true; 
     781        else ERROR("void CField::buildExpression(void)", << " Field " << *it << " does not exist"); 
     782      } 
     783 
     784      expression->reduce(this,associatedInstantFieldIds,associatedAverageFieldIds); 
     785 
     786      slots.resize(instantFieldIds.size() + averageFieldIds.size()); 
     787      resetSlots(); 
     788      int slotId = 0; 
     789      set<CField*> fields; 
     790      expression->getFields(fields); 
     791      for (set<CField*>::iterator it = fields.begin(); it != fields.end(); ++it, ++slotId) (*it)->addDependency(this,slotId); 
     792      hasExpression = true; 
    798793    } 
    799794  } 
     
    801796  void CField::resetSlots(void) 
    802797  { 
    803     for(vector<bool>::iterator it=slots.begin();it!=slots.end();++it) *it=false ; 
     798    for (vector<bool>::iterator it = slots.begin(); it != slots.end(); ++it) *it = false; 
    804799  } 
    805800 
    806801  bool CField::slotsFull(void) 
    807802  { 
    808     bool ret=true ; 
    809     for(vector<bool>::iterator it=slots.begin();it!=slots.end();++it) ret &= *it; 
    810     return ret ; 
     803    bool ret = true; 
     804    for (vector<bool>::iterator it = slots.begin(); it != slots.end(); ++it) ret &= *it; 
     805    return ret; 
    811806  } 
    812  
    813807 
    814808  void CField::setSlot(int slotId) 
    815809  { 
    816     CContext* context = CContext::getCurrent() ; 
    817     const CDate & currDate = context->getCalendar()->getCurrentDate(); 
    818     if (slotUpdateDate==NULL || currDate!=*slotUpdateDate) 
    819     { 
    820       resetSlots() ; 
    821       if (slotUpdateDate==NULL) slotUpdateDate=new CDate(currDate) ; 
    822       else *slotUpdateDate=currDate ; 
    823     } 
    824     slots[slotId]=true ; 
     810    CContext* context = CContext::getCurrent(); 
     811    const CDate& currDate = context->getCalendar()->getCurrentDate(); 
     812    if (slotUpdateDate == NULL || currDate != *slotUpdateDate) 
     813    { 
     814      resetSlots(); 
     815      if (slotUpdateDate == NULL) slotUpdateDate = new CDate(currDate); 
     816      else *slotUpdateDate = currDate; 
     817    } 
     818    slots[slotId] = true; 
    825819    if (slotsFull()) 
    826820    { 
    827       CArray<double,1> expr(expression->compute()) ; 
     821      CArray<double,1> expr(expression->compute()); 
    828822 
    829823      if (hasInstantData) 
    830824      { 
    831         instantData=expr ; 
    832         for(list< pair<CField *,int> >::iterator it=fieldDependency.begin(); it!=fieldDependency.end(); ++it) 
    833           if (it->first!=this) it->first->setSlot(it->second) ; 
    834       } 
    835  
    836       if (hasOutputFile) updateDataFromExpression(expr) ; 
    837  
     825        instantData = expr; 
     826        for (list< pair<CField *,int> >::iterator it = fieldDependency.begin(); it != fieldDependency.end(); ++it) 
     827          if (it->first != this) it->first->setSlot(it->second); 
     828      } 
     829 
     830      if (hasOutputFile) updateDataFromExpression(expr); 
     831 
     832      const std::vector<CField*>& refField = getAllReference(); 
     833      for (std::vector<CField*>::const_iterator it = refField.begin(); it != refField.end(); it++) 
     834      { 
     835        if (!(*it)->hasExpression) 
     836          (*it)->setDataFromExpression(expr); 
     837      } 
    838838    } 
    839839  } 
     
    853853     } 
    854854 
    855      return (domAxisIds_); 
     855     return domAxisIds_; 
    856856   } 
    857857 
    858858   CVariable* CField::addVariable(const string& id) 
    859859   { 
    860      return vVariableGroup->createChild(id) ; 
     860     return vVariableGroup->createChild(id); 
    861861   } 
    862862 
    863863   CVariableGroup* CField::addVariableGroup(const string& id) 
    864864   { 
    865      return vVariableGroup->createChildGroup(id) ; 
    866    } 
    867  
     865     return vVariableGroup->createChildGroup(id); 
     866   } 
    868867 
    869868   void CField::sendAddAllVariables() 
     
    890889   void CField::sendAddVariable(const string& id) 
    891890   { 
    892     CContext* context=CContext::getCurrent() ; 
    893  
    894     if (! context->hasServer ) 
    895     { 
    896        CContextClient* client=context->client ; 
    897  
    898        CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE) ; 
     891    CContext* context = CContext::getCurrent(); 
     892 
     893    if (!context->hasServer) 
     894    { 
     895       CContextClient* client = context->client; 
     896 
     897       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE); 
    899898       if (client->isServerLeader()) 
    900899       { 
    901          CMessage msg ; 
    902          msg<<this->getId() ; 
    903          msg<<id ; 
    904          event.push(client->getServerLeader(),1,msg) ; 
    905          client->sendEvent(event) ; 
     900         CMessage msg; 
     901         msg << this->getId(); 
     902         msg << id; 
     903         event.push(client->getServerLeader(),1,msg); 
     904         client->sendEvent(event); 
    906905       } 
    907        else client->sendEvent(event) ; 
    908     } 
    909  
    910    } 
    911  
     906       else client->sendEvent(event); 
     907    } 
     908   } 
    912909 
    913910   void CField::sendAddVariableGroup(const string& id) 
    914911   { 
    915     CContext* context=CContext::getCurrent() ; 
    916     if (! context->hasServer ) 
    917     { 
    918        CContextClient* client=context->client ; 
    919  
    920        CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP) ; 
     912    CContext* context = CContext::getCurrent(); 
     913    if (!context->hasServer) 
     914    { 
     915       CContextClient* client = context->client; 
     916 
     917       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP); 
    921918       if (client->isServerLeader()) 
    922919       { 
    923          CMessage msg ; 
    924          msg<<this->getId() ; 
    925          msg<<id ; 
    926          event.push(client->getServerLeader(),1,msg) ; 
    927          client->sendEvent(event) ; 
     920         CMessage msg; 
     921         msg << this->getId(); 
     922         msg << id; 
     923         event.push(client->getServerLeader(),1,msg); 
     924         client->sendEvent(event); 
    928925       } 
    929        else client->sendEvent(event) ; 
    930     } 
    931  
     926       else client->sendEvent(event); 
     927    } 
    932928   } 
    933929 
     
    935931   { 
    936932 
    937       CBufferIn* buffer=event.subEvents.begin()->buffer; 
     933      CBufferIn* buffer = event.subEvents.begin()->buffer; 
    938934      string id; 
    939       *buffer>>id ; 
    940       get(id)->recvAddVariable(*buffer) ; 
    941    } 
    942  
     935      *buffer >> id; 
     936      get(id)->recvAddVariable(*buffer); 
     937   } 
    943938 
    944939   void CField::recvAddVariable(CBufferIn& buffer) 
    945940   { 
    946       string id ; 
    947       buffer>>id ; 
    948       addVariable(id) ; 
     941      string id; 
     942      buffer >> id; 
     943      addVariable(id); 
    949944   } 
    950945 
     
    952947   { 
    953948 
    954       CBufferIn* buffer=event.subEvents.begin()->buffer; 
     949      CBufferIn* buffer = event.subEvents.begin()->buffer; 
    955950      string id; 
    956       *buffer>>id ; 
    957       get(id)->recvAddVariableGroup(*buffer) ; 
    958    } 
    959  
     951      *buffer >> id; 
     952      get(id)->recvAddVariableGroup(*buffer); 
     953   } 
    960954 
    961955   void CField::recvAddVariableGroup(CBufferIn& buffer) 
    962956   { 
    963       string id ; 
    964       buffer>>id ; 
    965       addVariableGroup(id) ; 
     957      string id; 
     958      buffer >> id; 
     959      addVariableGroup(id); 
    966960   } 
    967961 
     
    970964//  void CField::addReference(CField* field) 
    971965//  { 
    972 //    refObject.push_back(field) ; 
     966//    refObject.push_back(field); 
    973967//  } 
    974968// 
     
    977971//   bool CField::hasDirectFieldReference(void) const 
    978972//   { 
    979 //     return (!this->field_ref.isEmpty()); 
     973//     return !this->field_ref.isEmpty(); 
    980974//   } 
    981975// 
    982976//   //---------------------------------------------------------------- 
    983977// 
    984 //   const StdString & CField::getBaseFieldId(void) const 
     978//   const StdString& CField::getBaseFieldId(void) const 
    985979//   { 
    986 //      return (this->getBaseFieldReference()->getId()); 
     980//      return this->getBaseFieldReference()->getId(); 
    987981//   } 
    988 // 
    989982// 
    990983//   //---------------------------------------------------------------- 
     
    996989//   { 
    997990//      if (this->field_ref.isEmpty()) 
    998 //         return (this->getBaseFieldReference()); 
    999 // 
    1000 //      if (! CField::has(this->field_ref.getValue())) 
     991//         return this->getBaseFieldReference(); 
     992// 
     993//      if (!CField::has(this->field_ref.getValue())) 
    1001994//         ERROR("CField::getDirectFieldReference(void)", 
    1002995//               << "[ ref_name = " << this->field_ref.getValue() << "]" 
    1003996//               << " invalid field name !"); 
    1004997// 
    1005 //      return (CField::get(this->field_ref.getValue())); 
     998//      return CField::get(this->field_ref.getValue()); 
    1006999//   } 
    10071000// 
     
    10101003//   CField* CField::getBaseFieldReference(void) const 
    10111004//   { 
    1012 //      return (baseRefObject); 
     1005//      return baseRefObject; 
    10131006//   } 
    10141007// 
     
    10171010//   const std::vector<CField*>& CField::getAllReference(void) const 
    10181011//   { 
    1019 //      return (refObject); 
     1012//      return refObject; 
    10201013//   } 
    1021 // 
    10221014// 
    10231015//   /*! 
     
    10331025//      std::set<CField *> sset; 
    10341026//      CField* refer_sptr; 
    1035 //      CField * refer_ptr = this; 
     1027//      CField* refer_ptr = this; 
    10361028// 
    10371029//      while (refer_ptr->hasDirectFieldReference()) 
     
    10671059//      std::set<CField *> sset; 
    10681060//      CField* refer_sptr; 
    1069 //      CField * refer_ptr = this; 
     1061//      CField* refer_ptr = this; 
    10701062// 
    10711063//      if (this->hasDirectFieldReference())  baseRefObject = getDirectFieldReference(); 
     
    10871079//      } 
    10881080// 
    1089 //      if (hasDirectFieldReference()) baseRefObject->addReference(this) ; 
     1081//      if (hasDirectFieldReference()) baseRefObject->addReference(this); 
    10901082//   } 
    1091 // 
    1092  
    10931083} // namespace xios 
Note: See TracChangeset for help on using the changeset viewer.