Ignore:
Timestamp:
09/25/17 12:19:49 (7 years ago)
Author:
oabramkina
Message:

Adding a check on field attributes. For now it only concerns freq_op and freq_offset.
It is done so to avoid changing its values on client after the attributes have already been sent to servers.

Location:
XIOS/dev/XIOS_DEV_CMIP6/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/filter/temporal_filter.cpp

    r1272 r1278  
    1414    , isOnceOperation(functor->timeType() == func::CFunctor::once) 
    1515    , isInstantOperation(functor->timeType() == func::CFunctor::instant) 
    16     // If we can optimize the sampling when dealing with an instant functor we do it 
    17     , samplingOffset((isInstantOperation && samplingFreq == NoneDu && samplingOffset == NoneDu) ? opFreq - initDate.getRelCalendar().getTimeStep() : samplingOffset) 
    18     , samplingFreq((samplingFreq == NoneDu ? (isInstantOperation ? opFreq : initDate.getRelCalendar().getTimeStep()) : samplingFreq)) 
     16    , samplingFreq(samplingFreq) 
     17    , samplingOffset(samplingOffset) 
    1918    , opFreq(opFreq) 
    2019    , nextSamplingDate(initDate + this->samplingOffset + initDate.getRelCalendar().getTimeStep()) 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/field.cpp

    r1272 r1278  
    11441144               << "An operation must be defined for field \"" << getId() << "\"."); 
    11451145 
    1146        if (freq_op.isEmpty()) 
    1147 //         freq_op.setValue(TimeStep); 
    1148          freq_op.setValue(NoneDu); 
    1149        if (freq_offset.isEmpty()) 
    1150          freq_offset.setValue(NoneDu); 
    1151  
    11521146       const bool detectMissingValues = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true); 
    11531147        
     
    11561150                                                                             freq_op, freq_offset, outFreq, 
    11571151                                                                             detectMissingValues, detectMissingValues ? default_value : 0.0)); 
     1152 
    11581153       instantDataFilter->connectOutput(temporalFilter, 0); 
    11591154 
     
    11871182               << "An operation must be defined for field \"" << getId() << "\"."); 
    11881183 
    1189        if (freq_op.isEmpty()) freq_op.setValue(TimeStep); 
    1190        if (freq_offset.isEmpty()) freq_offset.setValue(NoneDu); 
    1191  
    11921184       const bool detectMissingValues = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true); 
    11931185 
     
    11961188                                                                             freq_op, freq_offset, outFreq, 
    11971189                                                                             detectMissingValues, detectMissingValues ? default_value : 0.0)); 
     1190 
    11981191       selfReferenceFilter->connectOutput(temporalFilter, 0); 
    11991192       return temporalFilter ; 
     
    15661559 
    15671560   /*! 
     1561    * Check on freq_off and freq_op attributes. 
     1562    */ 
     1563   void CField::checkAttributes(void) 
     1564   { 
     1565     if (freq_op.isEmpty()) 
     1566     { 
     1567       if (!freq_offset.isEmpty()) 
     1568         ERROR("CField::checkAttributes(void)", 
     1569               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     1570               << "Attribute freq_offset cannot be defined if attribute freq_op is not defined. " 
     1571               << "Please define freq_op.") 
     1572       else 
     1573       { 
     1574         CContext* context = CContext::getCurrent(); 
     1575         if (operation.getValue()=="instant") 
     1576         { 
     1577           freq_op.setValue(file->output_freq.getValue()); 
     1578           freq_offset.setValue(file->output_freq.getValue() - TimeStep); 
     1579         } 
     1580         else 
     1581         { 
     1582           freq_op.setValue(TimeStep); 
     1583           freq_op.setValue(NoneDu); 
     1584         } 
     1585       } 
     1586     } 
     1587     else 
     1588     { 
     1589       if (freq_offset.isEmpty()) 
     1590         freq_op.setValue(NoneDu); 
     1591     } 
     1592   } 
     1593 
     1594   /*! 
    15681595    * Returns string arithmetic expression associated to the field. 
    15691596    * \return if content is defined return content string, otherwise, if "expr" attribute is defined, return expr string. 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/field.hpp

    r1239 r1278  
    130130         void checkGridOfEnabledFields(); 
    131131         void sendGridOfEnabledFields(); 
    132          void sendGridComponentOfEnabledFields();    
     132         void sendGridComponentOfEnabledFields(); 
     133 
     134         /// Vérifications /// 
     135         void checkAttributes(void); 
    133136 
    134137         void buildFilterGraph(CGarbageCollector& gc, bool enableOutput); 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/file.cpp

    r1239 r1278  
    11291129       CField* field = this->enabledFields[i]; 
    11301130       this->sendAddField(field->getId(), client); 
     1131       field->checkAttributes(); 
    11311132       field->sendAllAttributesToServer(client); 
    11321133       field->sendAddAllVariables(client); 
Note: See TracChangeset for help on using the changeset viewer.