Ignore:
Timestamp:
03/22/18 10:43:20 (6 years ago)
Author:
yushan
Message:

branch_openmp merged with XIOS_DEV_CMIP6@1459

File:
1 edited

Legend:

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

    r1328 r1460  
    55namespace xios 
    66{ 
    7   static func::CFunctor* createFunctor(const std::string& opId, bool ignoreMissingValue, double missingValue, CArray<double, 1>& tmpData); 
     7  static func::CFunctor* createFunctor(const std::string& opId, bool ignoreMissingValue, CArray<double, 1>& tmpData); 
    88 
    99  CTemporalFilter::CTemporalFilter(CGarbageCollector& gc, const std::string& opId, 
    1010                                   const CDate& initDate, const CDuration samplingFreq, const CDuration samplingOffset, const CDuration opFreq, 
    11                                    bool ignoreMissingValue /*= false*/, double missingValue /*= 0.0*/) 
     11                                   bool ignoreMissingValue /*= false*/) 
    1212    : CFilter(gc, 1, this) 
    13     , functor(createFunctor(opId, ignoreMissingValue, missingValue, tmpData)) 
     13    , functor(createFunctor(opId, ignoreMissingValue, tmpData)) 
    1414    , isOnceOperation(functor->timeType() == func::CFunctor::once) 
    1515    , isInstantOperation(functor->timeType() == func::CFunctor::instant) 
     
    1717    , samplingOffset(samplingOffset) 
    1818    , opFreq(opFreq) 
    19     , nextSamplingDate(initDate + this->samplingOffset + initDate.getRelCalendar().getTimeStep()) 
    20     , nextOperationDate(initDate + this->samplingOffset + opFreq) 
     19    , offsetMonth({0, this->samplingOffset.month, 0, 0, 0, 0, 0}) 
     20    , offsetAllButMonth({this->samplingOffset.year, 0 , this->samplingOffset.day, 
     21                       this->samplingOffset.hour, this->samplingOffset.minute, 
     22                       this->samplingOffset.second, this->samplingOffset.timestep}) 
     23    , initDate(initDate) 
     24    , nextSamplingDate(initDate + (this->samplingOffset + initDate.getRelCalendar().getTimeStep())) 
     25    , nbOperationDates(1) 
     26//    , nextOperationDate(initDate + opFreq + this->samplingOffset) 
    2127    , isFirstOperation(true) 
    2228  { 
     
    3541      { 
    3642        usePacket = (data[0]->date >= nextSamplingDate); 
    37         outputResult = (data[0]->date + samplingFreq > nextOperationDate); 
     43//        outputResult = (data[0]->date + samplingFreq > nextOperationDate); 
     44        outputResult = (data[0]->date  > initDate + nbOperationDates*opFreq - samplingFreq + offsetMonth + offsetAllButMonth); 
    3845        copyLess = (isInstantOperation && usePacket && outputResult); 
    3946      } 
     
    5461      if (outputResult) 
    5562      { 
     63        nbOperationDates ++; 
    5664        if (!copyLess) 
    5765        { 
     
    6977 
    7078        isFirstOperation = false; 
    71         nextOperationDate = nextOperationDate + samplingFreq + opFreq - samplingFreq; 
     79//        nextOperationDate = initDate + samplingFreq + nbOperationDates*opFreq - samplingFreq + offsetMonth + offsetAllButMonth; 
    7280      } 
    7381    } 
     
    7684  } 
    7785 
     86  bool CTemporalFilter::mustAutoTrigger() const 
     87  { 
     88    return true; 
     89  } 
     90 
    7891  bool CTemporalFilter::isDataExpected(const CDate& date) const 
    7992  { 
    80     return isOnceOperation ? isFirstOperation : (date >= nextSamplingDate || date + samplingFreq > nextOperationDate); 
     93//    return isOnceOperation ? isFirstOperation : (date >= nextSamplingDate || date + samplingFreq > nextOperationDate); 
     94    return isOnceOperation ? isFirstOperation : (date >= nextSamplingDate || date > initDate + nbOperationDates*opFreq - samplingFreq + offsetMonth + offsetAllButMonth); 
    8195  } 
    8296 
    83   static func::CFunctor* createFunctor(const std::string& opId, bool ignoreMissingValue, double missingValue, CArray<double, 1>& tmpData) 
     97  static func::CFunctor* createFunctor(const std::string& opId, bool ignoreMissingValue, CArray<double, 1>& tmpData) 
    8498  { 
    8599    func::CFunctor* functor = NULL; 
    86100 
    87     double defaultValue = ignoreMissingValue ? std::numeric_limits<double>::quiet_NaN() : missingValue; 
     101    double defaultValue = std::numeric_limits<double>::quiet_NaN(); 
    88102 
    89103#define DECLARE_FUNCTOR(MType, mtype) \ 
Note: See TracChangeset for help on using the changeset viewer.