Changeset 1357


Ignore:
Timestamp:
12/06/17 08:34:31 (6 years ago)
Author:
rlacroix
Message:

Add some extra checks when switching to the next timestep.

Location:
XIOS
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/calendar.cpp

    r561 r1357  
    99      CCalendar::CCalendar(void) 
    1010         : CObject() 
     11         , step(0) 
    1112         , initDate(*this) 
    1213         , timeOrigin(*this) 
     
    1617      CCalendar::CCalendar(const StdString& id) 
    1718               : CObject(id) 
     19               , step(0) 
    1820               , initDate(*this) 
    1921               , timeOrigin(*this) 
     
    2527                           int hr /*= 0*/, int min /*= 0*/, int sec /*= 0*/) 
    2628               : CObject(id) 
     29               , step(0) 
    2730               , initDate(*this) 
    2831               , timeOrigin(*this) 
     
    3437      CCalendar::CCalendar(const StdString& id, const CDate& startDate) 
    3538               : CObject(id) 
     39               , step(0) 
    3640               , initDate(startDate) 
    3741               , timeOrigin(startDate) 
     
    4448      CCalendar::CCalendar(const StdString& id, const CDate& startDate, const CDate& timeOrigin) 
    4549               : CObject(id) 
     50               , step(0) 
    4651               , initDate(startDate) 
    4752               , timeOrigin(timeOrigin) 
     
    115120      } 
    116121 
     122      int CCalendar::getStep(void) const 
     123      { 
     124        return step; 
     125      } 
     126 
    117127      const CDate& CCalendar::update(int step) 
    118128      { 
    119129        info(20) << "update step : " << step << " timestep " << this->timestep << std::endl; 
     130        this->step = step; 
    120131        return (this->currentDate = this->getInitDate() + step * this->timestep); 
    121132      } 
  • XIOS/dev/XIOS_DEV_CMIP6/src/calendar.hpp

    r591 r1357  
    7070            virtual StdString getType(void) const; 
    7171 
     72            int getStep(void) const; 
     73 
    7274            virtual int getMonthLength(const CDate& date) const; 
    7375 
     
    112114 
    113115         private : 
     116            int step; 
    114117 
    115118            /// Propriétés privées /// 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/context.cpp

    r1349 r1357  
    18331833   void CContext::updateCalendar(int step) 
    18341834   { 
    1835       info(50) << "updateCalendar : before : " << calendar->getCurrentDate() << endl; 
    1836       calendar->update(step); 
    1837       info(50) << "updateCalendar : after : " << calendar->getCurrentDate() << endl; 
    1838 #ifdef XIOS_MEMTRACK_LIGHT 
    1839       info(50) << " Current memory used by XIOS : "<<  MemTrack::getCurrentMemorySize()*1.0/(1024*1024)<<" Mbyte, at timestep "<<step<<" of context "<<this->getId()<<endl ; 
    1840 #endif 
    1841       //if (hasClient)  
    1842       if (hasClient && !hasServer) // For now we only use server level 1 to read data 
     1835      int prevStep = calendar->getStep(); 
     1836 
     1837      if (prevStep < step) 
    18431838      { 
    1844         doPostTimestepOperationsForEnabledReadModeFiles(); 
    1845         garbageCollector.invalidate(calendar->getCurrentDate()); 
     1839        info(50) << "updateCalendar : before : " << calendar->getCurrentDate() << endl; 
     1840        calendar->update(step); 
     1841        info(50) << "updateCalendar : after : " << calendar->getCurrentDate() << endl; 
     1842  #ifdef XIOS_MEMTRACK_LIGHT 
     1843        info(50) << " Current memory used by XIOS : "<<  MemTrack::getCurrentMemorySize()*1.0/(1024*1024)<<" Mbyte, at timestep "<<step<<" of context "<<this->getId()<<endl ; 
     1844  #endif 
     1845 
     1846        if (hasClient && !hasServer) // For now we only use server level 1 to read data 
     1847        { 
     1848          doPostTimestepOperationsForEnabledReadModeFiles(); 
     1849          garbageCollector.invalidate(calendar->getCurrentDate()); 
     1850        } 
    18461851      } 
     1852      else if (prevStep == step) 
     1853        info(50) << "updateCalendar: already at step " << step << ", no operation done." << endl; 
     1854      else // if (prevStep > step) 
     1855        ERROR("void CContext::updateCalendar(int step)", 
     1856              << "Illegal calendar update: previous step was " << prevStep << ", new step " << step << "is in the past!") 
    18471857   } 
    18481858 
  • XIOS/trunk/src/calendar.cpp

    r561 r1357  
    99      CCalendar::CCalendar(void) 
    1010         : CObject() 
     11         , step(0) 
    1112         , initDate(*this) 
    1213         , timeOrigin(*this) 
     
    1617      CCalendar::CCalendar(const StdString& id) 
    1718               : CObject(id) 
     19               , step(0) 
    1820               , initDate(*this) 
    1921               , timeOrigin(*this) 
     
    2527                           int hr /*= 0*/, int min /*= 0*/, int sec /*= 0*/) 
    2628               : CObject(id) 
     29               , step(0) 
    2730               , initDate(*this) 
    2831               , timeOrigin(*this) 
     
    3437      CCalendar::CCalendar(const StdString& id, const CDate& startDate) 
    3538               : CObject(id) 
     39               , step(0) 
    3640               , initDate(startDate) 
    3741               , timeOrigin(startDate) 
     
    4448      CCalendar::CCalendar(const StdString& id, const CDate& startDate, const CDate& timeOrigin) 
    4549               : CObject(id) 
     50               , step(0) 
    4651               , initDate(startDate) 
    4752               , timeOrigin(timeOrigin) 
     
    115120      } 
    116121 
     122      int CCalendar::getStep(void) const 
     123      { 
     124        return step; 
     125      } 
     126 
    117127      const CDate& CCalendar::update(int step) 
    118128      { 
    119129        info(20) << "update step : " << step << " timestep " << this->timestep << std::endl; 
     130        this->step = step; 
    120131        return (this->currentDate = this->getInitDate() + step * this->timestep); 
    121132      } 
  • XIOS/trunk/src/calendar.hpp

    r591 r1357  
    7070            virtual StdString getType(void) const; 
    7171 
     72            int getStep(void) const; 
     73 
    7274            virtual int getMonthLength(const CDate& date) const; 
    7375 
     
    112114 
    113115         private : 
     116            int step; 
    114117 
    115118            /// Propriétés privées /// 
  • XIOS/trunk/src/node/context.cpp

    r1318 r1357  
    12021202   void CContext::updateCalendar(int step) 
    12031203   { 
    1204       info(50) << "updateCalendar : before : " << calendar->getCurrentDate() << endl; 
    1205       calendar->update(step); 
    1206       info(50) << "updateCalendar : after : " << calendar->getCurrentDate() << endl; 
    1207 #ifdef XIOS_MEMTRACK_LIGHT 
    1208       info(50) << " Current memory used by XIOS : "<<  MemTrack::getCurrentMemorySize()*1.0/(1024*1024)<<" Mbyte, at timestep "<<step<<" of context "<<this->getId()<<endl ; 
    1209 #endif 
    1210       if (hasClient) 
     1204      int prevStep = calendar->getStep(); 
     1205 
     1206      if (prevStep < step) 
    12111207      { 
    1212         doPostTimestepOperationsForEnabledReadModeFiles(); 
    1213         garbageCollector.invalidate(calendar->getCurrentDate()); 
     1208        info(50) << "updateCalendar : before : " << calendar->getCurrentDate() << endl; 
     1209        calendar->update(step); 
     1210        info(50) << "updateCalendar : after : " << calendar->getCurrentDate() << endl; 
     1211  #ifdef XIOS_MEMTRACK_LIGHT 
     1212        info(50) << " Current memory used by XIOS : "<<  MemTrack::getCurrentMemorySize()*1.0/(1024*1024)<<" Mbyte, at timestep "<<step<<" of context "<<this->getId()<<endl ; 
     1213  #endif 
     1214 
     1215        if (hasClient) 
     1216        { 
     1217          doPostTimestepOperationsForEnabledReadModeFiles(); 
     1218          garbageCollector.invalidate(calendar->getCurrentDate()); 
     1219        } 
    12141220      } 
     1221      else if (prevStep == step) 
     1222        info(50) << "updateCalendar: already at step " << step << ", no operation done." << endl; 
     1223      else // if (prevStep > step) 
     1224        ERROR("void CContext::updateCalendar(int step)", 
     1225              << "Illegal calendar update: previous step was " << prevStep << ", new step " << step << "is in the past!") 
    12151226   } 
    12161227 
Note: See TracChangeset for help on using the changeset viewer.