Ignore:
Timestamp:
01/16/14 14:28:23 (10 years ago)
Author:
ymipsl
Message:

Add new parsing expression functionnalities
(modified files)

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/field_impl.hpp

    r436 r459  
    1313namespace xios { 
    1414 
    15    template <int N> 
    16    void CField::setData(const CArray<double, N>& _data) 
    17    { 
    18      const std::vector<CField*>& refField=getAllReference(); 
    19      std::vector<CField*>::const_iterator  it = refField.begin(), end = refField.end(); 
    20       
    21      for (; it != end; it++) (*it)->updateData(_data) ; 
     15  template <int N> 
     16  void CField::setData(const CArray<double, N>& _data) 
     17  { 
     18    if (hasInstantData)  
     19    { 
     20      grid->inputField(_data, instantData);  
     21      for(list< pair<CField *,int> >::iterator it=fieldDependency.begin(); it!=fieldDependency.end(); ++it)  it->first->setSlot(it->second) ; 
    2222    } 
    2323     
     24    if (!hasExpression) 
     25    { 
     26      const std::vector<CField*>& refField=getAllReference(); 
     27      std::vector<CField*>::const_iterator  it = refField.begin(), end = refField.end(); 
     28      
     29      for (; it != end; it++) (*it)->setData(_data) ; 
     30      if (hasOutputFile) updateData(_data) ; 
     31    } 
     32      
     33  } 
     34 
     35 
    2436   template <int N> 
    25       bool CField::updateData(const CArray<double, N>& _data) 
     37   bool CField::updateData(const CArray<double, N>& _data) 
    2638   {         
    2739      CContext* context=CContext::getCurrent(); 
    2840      const CDate & currDate = context->getCalendar()->getCurrentDate(); 
    2941      const CDate opeDate      = *last_operation + freq_operation; 
    30       const CDate writeDate    = *last_Write     + freq_write; 
     42      const CDate writeDate    = *last_Write     + freq_write;        
    3143      bool doOperation, doWrite;  
    32           
    3344 
    3445    
    3546      info(50) << "CField::updateData " << currDate <<  " : send data to " << this->getBaseFieldId() << std::endl; 
    3647      info(50) << "Next operation "  << opeDate<<std::endl; 
    37        
     48 
    3849      doOperation = (opeDate <= currDate) ; 
    3950      if (isOnceOperation) 
    4051        if (isFirstOperation) doOperation=true ; 
    4152        else doOperation=false ; 
    42        
     53 
    4354      if (doOperation) 
    4455      { 
     
    5566         info(50) << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl;  
    5667      } 
     68 
     69      doWrite = (writeDate < (currDate + freq_operation)) ; 
     70      if (isOnceOperation) 
     71      {  
     72        if(isFirstOperation)  
     73        { 
     74          doWrite=true ; 
     75          isFirstOperation=false ; 
     76        } 
     77        else doWrite=false ; 
     78      } 
    5779       
    58        
     80      if (doWrite) 
     81      { 
     82         this->foperation->final(); 
     83         *last_Write = writeDate; 
     84         info(50) << "(*last_Write = currDate) : " << *last_Write << " = " << currDate << std::endl; 
     85         CTimer::get("XIOS Send Data").resume() ; 
     86         sendUpdateData() ; 
     87         CTimer::get("XIOS Send Data").suspend() ; 
     88         return (true);         
     89      } 
     90 
     91      return (false); 
     92   } 
     93    
     94   bool CField::updateDataFromExpression(const CArray<double, 1>& _data) 
     95   {         
     96      CContext* context=CContext::getCurrent(); 
     97      const CDate & currDate = context->getCalendar()->getCurrentDate(); 
     98      const CDate opeDate      = *last_operation + freq_operation; 
     99      const CDate writeDate    = *last_Write     + freq_write;        
     100      bool doOperation, doWrite;  
     101 
     102    
     103      info(50) << "CField::updateData " << currDate <<  " : send data to " << this->getBaseFieldId() << std::endl; 
     104      info(50) << "Next operation "  << opeDate<<std::endl; 
     105 
     106      doOperation = (opeDate <= currDate) ; 
     107      if (isOnceOperation) 
     108        if (isFirstOperation) doOperation=true ; 
     109        else doOperation=false ; 
     110 
     111      if (doOperation) 
     112      { 
     113         if (this->data.numElements() != this->grid->storeIndex_client.numElements()) 
     114         { 
     115            this->data.resize(this->grid->storeIndex_client.numElements()); 
     116         } 
     117             
     118        (*this->foperation)(_data); 
     119          
     120         *last_operation = currDate; 
     121         info(50) << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl;  
     122      } 
     123 
    59124      doWrite = (writeDate < (currDate + freq_operation)) ; 
    60125      if (isOnceOperation) 
Note: See TracChangeset for help on using the changeset viewer.