Ignore:
Timestamp:
01/20/14 11:16:48 (11 years ago)
Author:
ymipsl
Message:

New functionnalities : expression may combine fields after temporal operation (averaging, min, max ...) using the operator @

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/field.cpp

    r459 r460  
    2525      , last_Write(), last_operation() 
    2626      , foperation(), hasInstantData(false), hasExpression(false) 
    27       , active(false) , hasOutputFile(false), slotUpdateDate(NULL) 
     27      , active(false) , hasOutputFile(false),hasFieldOut(false), slotUpdateDate(NULL) 
    2828      , processed(false) 
    2929      { /* Ne rien faire de plus */ } 
     
    3737      , last_Write(), last_operation() 
    3838      , foperation(), hasExpression(false) 
    39       , active(false), hasOutputFile(false), slotUpdateDate(NULL) 
     39      , active(false), hasOutputFile(false), hasFieldOut(false), slotUpdateDate(NULL) 
    4040      , processed(false) 
    4141   { /* Ne rien faire de plus */ } 
     
    387387      using namespace func; 
    388388       
    389       if (!hasOutputFile) return ; 
     389      if (!hasOutputFile && !hasFieldOut) return ; 
    390390       
    391391      StdString id ; 
     
    418418      if (context->hasServer) 
    419419      { 
    420          this->freq_operation_srv = 
    421              CDuration::FromString(this->file->output_freq.getValue()); 
    422          this->freq_write_srv     = 
    423              CDuration::FromString(this->file->output_freq.getValue()); 
     420         if (hasOutputFile)  
     421         { 
     422           this->freq_operation_srv =CDuration::FromString(this->file->output_freq.getValue()); 
     423           this->freq_write_srv = CDuration::FromString(this->file->output_freq.getValue()); 
     424         } 
    424425         this->lastlast_Write_srv     = boost::shared_ptr<CDate> 
    425426                        (new CDate(context->getCalendar()->getInitDate())); 
     
    431432//             boost::shared_ptr<func::CFunctor>(new CInstant(this->data_srv)); 
    432433              
    433          const CDuration toffset = this->freq_operation_srv - freq_offset_ - context->getCalendar()->getTimeStep();  
    434          *this->last_operation_srv   = *this->last_operation_srv - toffset;  
     434         if (hasOutputFile)  
     435         { 
     436           const CDuration toffset = this->freq_operation_srv - freq_offset_ - context->getCalendar()->getTimeStep();  
     437           *this->last_operation_srv   = *this->last_operation_srv - toffset; 
     438         } 
    435439      } 
    436440       
     
    438442//      {                   
    439443         this->freq_operation = CDuration::FromString(freq_op.getValue()); 
    440          this->freq_write     = CDuration::FromString(this->file->output_freq.getValue()); 
     444         if (hasOutputFile) this->freq_write     = CDuration::FromString(this->file->output_freq.getValue()); 
     445         if (hasFieldOut)  
     446         { 
     447           this->freq_write = CDuration::FromString(this->fieldOut->freq_op.getValue()); 
     448         } 
    441449         this->last_Write     = boost::shared_ptr<CDate> 
    442450                        (new CDate(context->getCalendar()->getInitDate())); 
     
    665673      expression=CFieldNode::newNode(simpleExpr) ; 
    666674      delete simpleExpr ; 
    667       set<string> fieldIds ; 
    668       expression->getFieldIds(fieldIds) ; 
    669       for (set<string>::iterator it=fieldIds.begin() ; it!=fieldIds.end();++it) if (*it!="this") CField::get(*it)->processEnabledField() ; 
    670        
    671       expression->reduce(this) ; 
    672  
    673       slots.resize(fieldIds.size()) ; 
     675      set<string> instantFieldIds ; 
     676      map<string,CField*> associatedInstantFieldIds ; 
     677      expression->getInstantFieldIds(instantFieldIds) ; 
     678      for (set<string>::iterator it=instantFieldIds.begin() ; it!=instantFieldIds.end();++it)  
     679      { 
     680        if (*it!="this")  
     681        { 
     682          if (CField::has(*it))  
     683          { 
     684            CField* field=CField::get(*it) ; 
     685            field->processEnabledField() ; 
     686            associatedInstantFieldIds[*it]=field ; 
     687          } 
     688          else  ERROR("void CField::buildExpression(void)",<<" Field "<<*it<<" does not exist") ; 
     689        } 
     690      } 
     691       
     692      set<string> averageFieldIds ; 
     693      map<string,CField*> associatedAverageFieldIds ; 
     694 
     695      expression->getAverageFieldIds(averageFieldIds) ; 
     696      for (set<string>::iterator it=averageFieldIds.begin() ; it!=averageFieldIds.end();++it)  
     697      {       
     698        if (CField::has(*it))  
     699        { 
     700           CFieldGroup* root=CFieldGroup::get("field_definition") ; 
     701           CField* averageField=root->createChild() ; 
     702           CField* instantField=root->createChild() ; 
     703           averageField->field_ref=*it ; 
     704           averageField->hasFieldOut=true ; 
     705           averageField->fieldOut=instantField ; 
     706           instantField->freq_op=freq_op ; 
     707           averageField-> processEnabledField() ; 
     708           cout<<" outputfreq of averageField "<<  freq_op <<"  "<<instantField->freq_op<<"  "<< averageField->freq_write << endl ; 
     709           instantField->SuperClassAttribute::setAttributes(averageField, true); 
     710           instantField->field_ref.reset() ; 
     711           instantField->operation.reset() ; 
     712 
     713           instantField-> processEnabledField() ; 
     714           associatedAverageFieldIds[*it]=instantField  ; 
     715        } 
     716        else ERROR("void CField::buildExpression(void)",<<" Field "<<*it<<" does not exist") ; 
     717      } 
     718 
     719      expression->reduce(this,associatedInstantFieldIds,associatedAverageFieldIds) ; 
     720 
     721      slots.resize(instantFieldIds.size()+averageFieldIds.size()) ; 
    674722      resetSlots() ; 
    675723      int slotId=0 ; 
Note: See TracChangeset for help on using the changeset viewer.