Changeset 532 for XIOS


Ignore:
Timestamp:
12/10/14 14:27:09 (9 years ago)
Author:
rlacroix
Message:

Add a new attribute type for dates and use it for the context's start_date and time_origin.

The "xios_date" type should now be used to get/set date attributes through the Fortran interface. This avoids using strings to manipulate dates.

Location:
XIOS/trunk/src
Files:
52 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/attribute_template_decl.cpp

    r501 r532  
    22#include "attribute_template_specialisation.hpp" 
    33#include <string> 
     4#include "date.hpp" 
    45 
    56namespace xios 
     
    910  template class CAttributeTemplate<bool> ; 
    1011  template class CAttributeTemplate<string> ; 
     12  template class CAttributeTemplate<CDate> ; 
    1113} 
  • XIOS/trunk/src/calendar.cpp

    r501 r532  
    1414      {   } 
    1515 
    16       CCalendar::CCalendar(const StdString & id) 
     16      CCalendar::CCalendar(const StdString& id) 
    1717               : CObject(id) 
    1818               , initDate(*this) 
     
    2121      { } 
    2222       
    23       CCalendar::CCalendar(const StdString & id, 
     23      CCalendar::CCalendar(const StdString& id, 
    2424                           int yr, int mth, int d  , 
    2525                           int hr, int min, int sec) 
     
    3232      } 
    3333 
    34       CCalendar::CCalendar(const StdString & id, const StdString & dateStr) 
     34      CCalendar::CCalendar(const StdString& id, const CDate& startDate) 
    3535               : CObject(id) 
    36                , initDate(CDate::FromString(dateStr, *this)) 
    37                , timeOrigin(initDate) 
    38                , currentDate(initDate) 
    39       {  
    40         initializeDate(dateStr) ; 
     36               , initDate(startDate) 
     37               , timeOrigin(startDate) 
     38               , currentDate(startDate) 
     39      { 
     40        // Initialize the dates only in the derivated classes 
     41        // since we want to use the overloaded virtual functions 
    4142      } 
    4243 
    43       CCalendar::CCalendar(const StdString & id, const StdString & dateStr, const StdString & timeOriginStr) 
     44      CCalendar::CCalendar(const StdString& id, const CDate& startDate, const CDate& timeOrigin) 
    4445               : CObject(id) 
    45                , initDate(*this) 
    46                , timeOrigin(*this) 
    47                , currentDate(*this) 
    48       {  
    49         initializeDate(dateStr, timeOriginStr) ; 
     46               , initDate(startDate) 
     47               , timeOrigin(timeOrigin) 
     48               , currentDate(startDate) 
     49      { 
     50        // Initialize the dates only in the derivated classes 
     51        // since we want to use the overloaded virtual functions 
    5052      } 
    5153 
     54      void CCalendar::initializeDate() 
     55      { 
     56        if (!initDate.setRelCalendar(*this)) 
     57          ERROR("CCalendar::initializeDate()", 
     58                "initDate: Bad format or date not conform to the calendar"); 
     59        if (!timeOrigin.setRelCalendar(*this)) 
     60          ERROR("CCalendar::initializeDate()", 
     61                "timeOrigin: Bad format or date not conform to the calendar"); 
     62        if (!currentDate.setRelCalendar(*this)) 
     63          ERROR("CCalendar::initializeDate()", 
     64                "currentDate: Bad format or date not conform to the calendar"); 
     65      } 
    5266 
    53       void CCalendar::initializeDate( int yr, int mth, int d  , 
    54                                  int hr, int min, int sec) 
    55       {  
     67      void CCalendar::initializeDate(int yr, int mth, int d, 
     68                                     int hr, int min, int sec) 
     69      { 
    5670        initDate=CDate(*this,yr, mth, d, hr, min, sec) ; 
    5771        timeOrigin=initDate; 
     
    5973      } 
    6074 
    61       void CCalendar::initializeDate(const StdString & dateStr) 
     75      void CCalendar::initializeDate(const StdString& dateStr) 
    6276      {  
    6377        initDate=CDate::FromString(dateStr, *this) ; 
     
    6680      } 
    6781 
    68       void CCalendar::initializeDate(const StdString & dateStr, const StdString & timeOriginStr) 
     82      void CCalendar::initializeDate(const StdString& dateStr, const StdString& timeOriginStr) 
    6983      {  
    7084        initDate=CDate::FromString(dateStr, *this) ; 
  • XIOS/trunk/src/calendar.hpp

    r501 r532  
    3333            /// Constructeurs /// 
    3434            CCalendar(void); 
    35             CCalendar(const StdString & id) ; 
    36             CCalendar(const StdString & id, 
     35            CCalendar(const StdString& id) ; 
     36            CCalendar(const StdString& id, 
    3737                      int yr, int mth, int d, 
    3838                      int hr = 0, int min = 0, int sec = 0); 
    39             CCalendar(const StdString & id, const StdString & dateStr); 
    40             CCalendar(const StdString & id, const StdString & dateStr, const StdString & timeOrigin); 
     39            CCalendar(const StdString& id, const CDate& startDate); 
     40            CCalendar(const StdString& id, const CDate& startDate, const CDate& timeOrigin); 
    4141 
    42             CCalendar(const CCalendar & calendar);       // Not implemented yet. 
    43             CCalendar(const CCalendar * const calendar); // Not implemented yet. 
     42            CCalendar(const CCalendar& calendar);       // Not implemented yet. 
     43            CCalendar(const CCalendar* const calendar); // Not implemented yet. 
    4444 
    4545         public : 
     
    8787            //------------------------------------------------------------ 
    8888 
     89         protected: 
     90             
     91            //!< Associate the dates to the calendar and check their validity 
     92            void initializeDate(); 
     93 
     94            //------------------------------------------------------------ 
     95 
    8996         private : 
    9097 
  • XIOS/trunk/src/config/context_attribute.conf

    r526 r532  
    11DECLARE_ENUM5(calendar_type, D360, AllLeap, NoLeap, Julian, Gregorian) 
    2 DECLARE_ATTRIBUTE(StdString, start_date) 
    3 DECLARE_ATTRIBUTE(StdString, time_origin) 
     2DECLARE_ATTRIBUTE(CDate, start_date) 
     3DECLARE_ATTRIBUTE(CDate, time_origin) 
    44DECLARE_ATTRIBUTE(StdString, timestep) 
    55DECLARE_ATTRIBUTE(StdString, output_dir) 
  • XIOS/trunk/src/date.cpp

    r501 r532  
    1111{ 
    1212      /// ////////////////////// Définitions ////////////////////// /// 
    13       CDate::CDate(const CCalendar& calendar) 
    14          : relCalendar(calendar) 
     13      CDate::CDate(void) 
     14         : relCalendar(NULL) 
    1515         , year(0), month(1) , day(1) 
    1616         , hour(0), minute(0), second(0) 
    17       {   } 
     17      {} 
     18 
     19      CDate::CDate(const CCalendar& calendar) 
     20         : relCalendar(&calendar) 
     21         , year(0), month(1) , day(1) 
     22         , hour(0), minute(0), second(0) 
     23      {} 
    1824       
    1925      CDate::CDate(const CCalendar& calendar, 
    2026                   int yr, int mth, int d, 
    2127                   int hr, int min, int sec) 
    22          : relCalendar(calendar) 
     28         : relCalendar(&calendar) 
    2329         , year(yr), month(mth) , day(d) 
    2430         , hour(hr), minute(min), second(sec) 
     
    3137      } 
    3238 
    33       CDate::CDate(const CDate & date) 
    34             : relCalendar(date.getRelCalendar()), 
     39      CDate::CDate(const CDate& date) 
     40            : relCalendar(date.relCalendar), 
    3541              year(date.year), month(date.month)  , day(date.day), 
    3642              hour(date.hour), minute(date.minute), second(date.second) 
    3743      { 
    38          if(!this->checkDate()) 
    39          { 
    40             DEBUG(<< "La date initialisée a été modifiée " 
    41                   << "car elle était incorrecte par rapport au calendrier souhaité."); 
    42          } 
     44        // Delay the verification until we get a calendar we can compare the date to 
     45        if (relCalendar && !checkDate()) 
     46        { 
     47          DEBUG(<< "La date initialisée a été modifiée " 
     48                << "car elle était incorrecte par rapport au calendrier souhaité."); 
     49        } 
    4350      } 
    4451 
     
    5057      CDate & CDate::operator=(const CDate & date) 
    5158      { 
    52          // relCalendar = d.getRelCalendar(); << inutile si fonction bien utilisée 
     59         relCalendar = date.relCalendar; 
    5360         year = date.year; month  = date.month ; day    = date.day; 
    5461         hour = date.hour; minute = date.minute; second = date.second; 
     
    103110                if (c==sep) 
    104111                { 
    105                   in>>date.second ; 
    106                   if(!date.checkDate()) 
    107                     ERROR("StdIStream & operator >> (StdIStream & in, CDate & date)",<<"Bad date format or not conform to calendar" ); 
    108                     return (in); 
     112                  in >> date.second; 
     113                  // Delay the verification until we get a calendar we can compare the date to 
     114                  if (date.relCalendar && !date.checkDate()) 
     115                    ERROR("StdIStream & operator >> (StdIStream & in, CDate & date)", 
     116                          << "Bad date format or not conform to calendar"); 
     117                  return (in); 
    109118                } 
    110119              } 
     
    118127      CDate::operator Time(void) const // Non vérifiée, pas optimisée ... 
    119128      { 
     129         // This will check that a calendar was correctly associated to the date 
     130         const CCalendar& c = getRelCalendar(); 
     131 
    120132         // Todo : Tester si la date courante est supérieure à la date initiale. 
    121          Time retvalue = - relCalendar.getNbSecond(relCalendar.getInitDate()) 
    122                          + relCalendar.getNbSecond(*this); 
    123  
    124          if ((relCalendar.getId().compare("D360")    == 0) || 
    125              (relCalendar.getId().compare("AllLeap") == 0) || 
    126              (relCalendar.getId().compare("NoLeap")  == 0)) 
    127          return (retvalue + (getYear() - relCalendar.getTimeOrigin().getYear()) 
    128                                        * relCalendar.getYearTotalLength(*this)); 
    129  
    130          for(CDate _d(relCalendar.getTimeOrigin()); 
     133         Time retvalue = - c.getNbSecond(c.getInitDate()) 
     134                         + c.getNbSecond(*this); 
     135 
     136         if ((c.getId().compare("D360")    == 0) || 
     137             (c.getId().compare("AllLeap") == 0) || 
     138             (c.getId().compare("NoLeap")  == 0)) 
     139         return (retvalue + (getYear() - c.getTimeOrigin().getYear()) 
     140                                       * c.getYearTotalLength(*this)); 
     141 
     142         for(CDate _d(c.getTimeOrigin()); 
    131143            _d.getYear() < getYear(); _d.setYear(_d.getYear()+1)) 
    132             retvalue += relCalendar.getYearTotalLength(_d); 
     144            retvalue += c.getYearTotalLength(_d); 
    133145         return (retvalue); 
    134146      } 
     
    140152         bool retValue = true; 
    141153 
    142          // Vérificatio de la valeur du mois. 
     154         // This will check that a calendar was correctly associated to the date 
     155         const CCalendar& c = getRelCalendar(); 
     156 
     157         // Vérification de la valeur du mois. 
    143158         if (month  < 1) { retValue = false; month  = 1; } 
    144          if (month  > relCalendar.getYearLength()) 
    145          { retValue = false; month = relCalendar.getYearLength(); } 
     159         if (month  > c.getYearLength()) 
     160         { retValue = false; month = c.getYearLength(); } 
    146161 
    147162         // Vérification de la valeur du jour. 
    148          if (day    < 1) { retValue = false; month  = 1; } 
    149          if (day    > (&relCalendar)->getMonthLength(*this)) 
    150          { retValue = false; day = (&relCalendar)->getMonthLength(*this); } 
     163         if (day    < 1) { retValue = false; day  = 1; } 
     164         if (day    > c.getMonthLength(*this)) 
     165         { retValue = false; day = c.getMonthLength(*this); } 
    151166 
    152167         // Vérification de la valeur de l'heure. 
    153168         if (hour   < 0) { retValue = false; hour  = 0; } 
    154          if (hour   >= relCalendar.getDayLength()) 
    155          { retValue = false; hour = relCalendar.getDayLength()-1; } 
     169         if (hour   >= c.getDayLength()) 
     170         { retValue = false; hour = c.getDayLength() - 1; } 
    156171 
    157172         // Vérification de la valeur des minutes. 
    158173         if (minute < 0) { retValue = false; minute = 0; } 
    159          if (minute >= relCalendar.getHourLength()) 
    160          { retValue = false; minute = relCalendar.getHourLength()-1; } 
     174         if (minute >= c.getHourLength()) 
     175         { retValue = false; minute = c.getHourLength() - 1; } 
    161176 
    162177         // Vérification de la valeur des secondes. 
    163          if (second < 0) { retValue = false; month = 0; } 
    164          if (second >= relCalendar.getMinuteLength()) 
    165          { retValue = false; second = relCalendar.getMinuteLength()-1; } 
     178         if (second < 0) { retValue = false; second = 0; } 
     179         if (second >= c.getMinuteLength()) 
     180         { retValue = false; second = c.getMinuteLength() - 1; } 
    166181 
    167182         return retValue; 
     
    179194      //---------------------------------------------------------------- 
    180195 
    181       const CCalendar & CDate::getRelCalendar(void) const 
    182       { return (this->relCalendar); } 
    183  
    184       //---------------------------------------------------------------- 
    185  
    186       void CDate::setYear  (int newyear)  { this->year  = newyear; } 
    187       void CDate::setMonth (int newmonth) { this->month = newmonth; } 
    188       void CDate::setDay (int newday) { this->day = newday; } 
     196      const CCalendar& CDate::getRelCalendar(void) const 
     197      { 
     198        if (!this->relCalendar) 
     199          ERROR("const CCalendar& CDate::getRelCalendar(void) const", 
     200                "Invalid state: The date is not associated with any calendar."); 
     201        return (*this->relCalendar); 
     202      } 
     203 
     204      bool CDate::hasRelCalendar(void) const 
     205      { return (this->relCalendar != NULL); } 
     206 
     207      //---------------------------------------------------------------- 
     208 
     209      void CDate::setYear  (int newyear)   { this->year   = newyear; } 
     210      void CDate::setMonth (int newmonth)  { this->month  = newmonth; } 
     211      void CDate::setDay   (int newday)    { this->day    = newday; } 
     212      void CDate::setHour  (int newhour)   { this->hour   = newhour; } 
     213      void CDate::setMinute(int newminute) { this->minute = newminute; } 
     214      void CDate::setSecond(int newsecond) { this->second = newsecond; } 
     215 
     216      void CDate::setDate(int yr, int mth, int d, int hr, int min, int sec) 
     217      { 
     218        this->year   = yr; 
     219        this->month  = mth; 
     220        this->day    = d; 
     221        this->hour   = hr; 
     222        this->minute = min; 
     223        this->second = sec; 
     224      } 
    189225 
    190226      //---------------------------------------------------------------- 
     
    195231         if (this->month == 13) { year++; this->month = 1 ; } 
    196232         if (this->month == 0 ) { year--; this->month = 12; } 
     233      } 
     234 
     235      //---------------------------------------------------------------- 
     236 
     237      bool CDate::setRelCalendar(const CCalendar& relCalendar) 
     238      { 
     239        this->relCalendar = &relCalendar; 
     240        return this->checkDate(); 
    197241      } 
    198242 
  • XIOS/trunk/src/date.hpp

    r501 r532  
    1717 
    1818            /// Constructeurs /// 
    19             CDate(void);                      // Not implemented yet 
     19            //!< Create an empty date associated to no calendar 
     20            CDate(void); 
     21            //!< Create an empty date associated to the specified calendar 
    2022            CDate(const CCalendar & cal); 
    21             CDate(const CCalendar & cal,int yr, int mth, int d, 
    22                                         int hr = 0, int min = 0, int sec = 0); 
     23            //!< Create a date associated to the specified calendar 
     24            CDate(const CCalendar & cal, int yr, int mth, int d, 
     25                                         int hr = 0, int min = 0, int sec = 0); 
    2326            CDate(const CDate & odate); 
    2427            CDate(const CDate * const odate); // Not implemented yet 
     
    4548            int getSecond(void) const; 
    4649 
    47             const CCalendar & getRelCalendar(void) const; 
     50            //!< Get the calendar associated to the date 
     51            const CCalendar& getRelCalendar(void) const; 
     52            bool hasRelCalendar(void) const; 
    4853 
    4954            /// Mutateurs /// 
    5055            void setYear  (int newyear); 
    5156            void setMonth (int newmonth); 
    52             void setDay (int newday); 
     57            void setDay   (int newday); 
     58            void setHour  (int newhour); 
     59            void setMinute(int newminute); 
     60            void setSecond(int newsecond); 
     61 
     62            void setDate(int yr, int mth, int d, 
     63                         int hr = 0, int min = 0, int sec = 0); 
    5364 
    5465            void addMonth (int value); 
     66 
     67            //!< Set the calendar associated to the date 
     68            bool setRelCalendar(const CCalendar& relCalendar); 
    5569 
    5670            /// Autres /// 
     
    6781 
    6882            /// Propriétés privées /// 
    69             const CCalendar & relCalendar; // Calendrier lié à la Date. 
     83            const CCalendar* relCalendar; //!< Calendar associated to the date 
    7084            int year, month, day, hour, minute, second; // Année, mois, ... 
    7185 
  • XIOS/trunk/src/date/allleap.cpp

    r501 r532  
    55      /// ////////////////////// Définitions ////////////////////// /// 
    66 
    7       CAllLeapCalendar::CAllLeapCalendar(const StdString & dateStr) 
    8          : CCalendar("AllLeap") 
    9       { initializeDate(dateStr); } 
     7      CAllLeapCalendar::CAllLeapCalendar(const CDate& startDate) 
     8         : CCalendar("AllLeap", startDate) 
     9      { 
     10         // This will check that the dates are conform with the calendar. 
     11         // We cannot call this from the parent constructor because we 
     12         // want the methods of this class to be used 
     13         initializeDate(); 
     14      } 
    1015 
    11       CAllLeapCalendar::CAllLeapCalendar(const StdString & dateStr,const StdString & timeOriginStr) 
    12          : CCalendar("AllLeap") 
    13       { initializeDate(dateStr, timeOriginStr); } 
     16      CAllLeapCalendar::CAllLeapCalendar(const CDate& startDate, const CDate& timeOrigin) 
     17         : CCalendar("AllLeap", startDate, timeOrigin) 
     18      { 
     19         // This will check that the dates are conform with the calendar. 
     20         // We cannot call this from the parent constructor because we 
     21         // want the methods of this class to be used 
     22         initializeDate(); 
     23      } 
    1424 
    1525      CAllLeapCalendar::CAllLeapCalendar(int yr, int mth, int d, 
  • XIOS/trunk/src/date/allleap.hpp

    r501 r532  
    1818            /// Constructeur /// 
    1919//            CAllLeapCalendar(void);                                   // Not implemented yet. 
    20             CAllLeapCalendar(const StdString & dateStr); 
    21             CAllLeapCalendar(const StdString & dateStr,const StdString & timeOriginStr); 
     20            CAllLeapCalendar(const CDate& startDate); 
     21            CAllLeapCalendar(const CDate& startDate, const CDate& timeOriginStr); 
    2222            CAllLeapCalendar(int yr = 0, int mth = 1, int d   = 1, 
    23                             int hr = 0, int min = 0, int sec = 0); 
    24             CAllLeapCalendar(const CAllLeapCalendar & calendar);       // Not implemented yet. 
    25             CAllLeapCalendar(const CAllLeapCalendar * calendar);       // Not implemented yet. 
     23                             int hr = 0, int min = 0, int sec = 0); 
     24            CAllLeapCalendar(const CAllLeapCalendar& calendar);       // Not implemented yet. 
     25            CAllLeapCalendar(const CAllLeapCalendar* calendar);       // Not implemented yet. 
    2626 
    2727            /// Accesseurs /// 
  • XIOS/trunk/src/date/d360.cpp

    r501 r532  
    55      /// ////////////////////// Définitions ////////////////////// /// 
    66 
    7       CD360Calendar::CD360Calendar(const StdString & dateStr) 
    8          : CCalendar("D360") 
    9       { initializeDate(dateStr); } 
     7      CD360Calendar::CD360Calendar(const CDate& startDate) 
     8         : CCalendar("D360", startDate) 
     9      { 
     10         // This will check that the dates are conform with the calendar. 
     11         // We cannot call this from the parent constructor because we 
     12         // want the methods of this class to be used 
     13         initializeDate(); 
     14      } 
    1015 
    11       CD360Calendar::CD360Calendar(const StdString & dateStr,const StdString & timeOriginStr) 
    12          : CCalendar("D360", dateStr) 
    13       { initializeDate(dateStr, timeOriginStr); } 
     16      CD360Calendar::CD360Calendar(const CDate& startDate, const CDate& timeOrigin) 
     17         : CCalendar("D360", startDate, timeOrigin) 
     18      { 
     19         // This will check that the dates are conform with the calendar. 
     20         // We cannot call this from the parent constructor because we 
     21         // want the methods of this class to be used 
     22         initializeDate(); 
     23      } 
    1424 
    1525      CD360Calendar::CD360Calendar(int yr, int mth, int d, 
  • XIOS/trunk/src/date/d360.hpp

    r501 r532  
    1818            /// Constructeur /// 
    1919            CD360Calendar(void);                                   // Not implemented yet. 
    20             CD360Calendar(const StdString & dateStr); 
    21             CD360Calendar(const StdString & dateStr,const StdString & timeOriginStr); 
     20            CD360Calendar(const CDate& startDate); 
     21            CD360Calendar(const CDate& startDate, const CDate& timeOrigin); 
    2222            CD360Calendar(int yr = 0, int mth = 1, int d   = 1, 
    2323                          int hr = 0, int min = 0, int sec = 0); 
    24             CD360Calendar(const CD360Calendar & calendar);       // Not implemented yet. 
    25             CD360Calendar(const CD360Calendar * calendar);       // Not implemented yet. 
     24            CD360Calendar(const CD360Calendar& calendar);       // Not implemented yet. 
     25            CD360Calendar(const CD360Calendar* calendar);       // Not implemented yet. 
    2626 
    2727            /// Accesseurs /// 
  • XIOS/trunk/src/date/gregorian.cpp

    r501 r532  
    55      /// ////////////////////// Définitions ////////////////////// /// 
    66 
    7       CGregorianCalendar::CGregorianCalendar(const StdString & dateStr) 
    8          : CCalendar("Gregorian") 
    9       { initializeDate(dateStr); } 
     7      CGregorianCalendar::CGregorianCalendar(const CDate& startDate) 
     8         : CCalendar("Gregorian", startDate) 
     9      { 
     10         // This will check that the dates are conform with the calendar. 
     11         // We cannot call this from the parent constructor because we 
     12         // want the methods of this class to be used 
     13         initializeDate(); 
     14      } 
    1015 
    11       CGregorianCalendar::CGregorianCalendar(const StdString & dateStr,const StdString & timeOriginStr) 
    12          : CCalendar("Gregorian") 
    13       { initializeDate(dateStr, timeOriginStr); } 
     16      CGregorianCalendar::CGregorianCalendar(const CDate& startDate, const CDate& timeOrigin) 
     17         : CCalendar("Gregorian", startDate, timeOrigin) 
     18      { 
     19         // This will check that the dates are conform with the calendar. 
     20         // We cannot call this from the parent constructor because we 
     21         // want the methods of this class to be used 
     22         initializeDate(); 
     23      } 
    1424 
    1525      CGregorianCalendar::CGregorianCalendar(int yr, int mth, int d, 
  • XIOS/trunk/src/date/gregorian.hpp

    r501 r532  
    1818            /// Constructeur /// 
    1919//            CGregorianCalendar(void);                                   // Not implemented yet. 
    20             CGregorianCalendar(const StdString & dateStr); 
    21             CGregorianCalendar(const StdString & dateStr,const StdString & timeOriginStr); 
     20            CGregorianCalendar(const CDate& startDate); 
     21            CGregorianCalendar(const CDate& startDate, const CDate& timeOrigin); 
    2222            CGregorianCalendar(int yr = 0, int mth = 1, int d   = 1, 
    2323                               int hr = 0, int min = 0, int sec = 0); 
    24             CGregorianCalendar(const CGregorianCalendar & calendar);       // Not implemented yet. 
    25             CGregorianCalendar(const CGregorianCalendar * calendar);       // Not implemented yet. 
     24            CGregorianCalendar(const CGregorianCalendar& calendar);       // Not implemented yet. 
     25            CGregorianCalendar(const CGregorianCalendar* calendar);       // Not implemented yet. 
    2626 
    2727            /// Accesseurs /// 
  • XIOS/trunk/src/date/julian.cpp

    r501 r532  
    55      /// ////////////////////// Définitions ////////////////////// /// 
    66 
    7       CJulianCalendar::CJulianCalendar(const StdString & dateStr) 
    8          : CCalendar("Julian") 
    9       { initializeDate(dateStr); } 
     7      CJulianCalendar::CJulianCalendar(const CDate& startDate) 
     8         : CCalendar("Julian", startDate) 
     9      { 
     10         // This will check that the dates are conform with the calendar. 
     11         // We cannot call this from the parent constructor because we 
     12         // want the methods of this class to be used 
     13         initializeDate(); 
     14      } 
    1015 
    11       CJulianCalendar::CJulianCalendar(const StdString & dateStr,const StdString & timeOriginStr) 
    12          : CCalendar("Julian") 
    13       { initializeDate(dateStr, timeOriginStr); } 
     16      CJulianCalendar::CJulianCalendar(const CDate& startDate, const CDate& timeOrigin) 
     17         : CCalendar("Julian", startDate, timeOrigin) 
     18      { 
     19         // This will check that the dates are conform with the calendar. 
     20         // We cannot call this from the parent constructor because we 
     21         // want the methods of this class to be used 
     22         initializeDate(); 
     23      } 
    1424 
    1525      CJulianCalendar::CJulianCalendar(int yr, int mth, int d, 
  • XIOS/trunk/src/date/julian.hpp

    r501 r532  
    1818            /// Constructeur /// 
    1919//            CJulianCalendar(void);                                   // Not implemented yet. 
    20             CJulianCalendar(const StdString & dateStr); 
    21             CJulianCalendar(const StdString & dateStr,const StdString & timeOriginStr); 
     20            CJulianCalendar(const CDate& startDate); 
     21            CJulianCalendar(const CDate& startDate, const CDate& timeOrigin); 
    2222            CJulianCalendar(int yr = 0, int mth = 1, int d   = 1, 
    2323                            int hr = 0, int min = 0, int sec = 0); 
    24             CJulianCalendar(const CJulianCalendar & calendar);       // Not implemented yet. 
    25             CJulianCalendar(const CJulianCalendar * calendar);       // Not implemented yet. 
     24            CJulianCalendar(const CJulianCalendar& calendar);       // Not implemented yet. 
     25            CJulianCalendar(const CJulianCalendar* calendar);       // Not implemented yet. 
    2626 
    2727            /// Accesseurs /// 
  • XIOS/trunk/src/date/noleap.cpp

    r501 r532  
    66      /// ////////////////////// Définitions ////////////////////// /// 
    77 
    8       CNoLeapCalendar::CNoLeapCalendar(const StdString & dateStr) 
    9          : CCalendar("NoLeap", dateStr) 
    10       { initializeDate(dateStr); } 
     8      CNoLeapCalendar::CNoLeapCalendar(const CDate& startDate) 
     9         : CCalendar("NoLeap", startDate) 
     10      { 
     11         // This will check that the dates are conform with the calendar. 
     12         // We cannot call this from the parent constructor because we 
     13         // want the methods of this class to be used 
     14         initializeDate(); 
     15      } 
    1116 
    12       CNoLeapCalendar::CNoLeapCalendar(const StdString & dateStr,const StdString & timeOriginStr) 
    13          : CCalendar("NoLeap", dateStr, timeOriginStr) 
    14       { initializeDate(dateStr, timeOriginStr); } 
     17      CNoLeapCalendar::CNoLeapCalendar(const CDate& startDate, const CDate& timeOrigin) 
     18         : CCalendar("NoLeap", startDate, timeOrigin) 
     19      { 
     20         // This will check that the dates are conform with the calendar. 
     21         // We cannot call this from the parent constructor because we 
     22         // want the methods of this class to be used 
     23         initializeDate(); 
     24      } 
    1525 
    1626      CNoLeapCalendar::CNoLeapCalendar(int yr, int mth, int d, 
  • XIOS/trunk/src/date/noleap.hpp

    r501 r532  
    1818            /// Constructeur /// 
    1919//            CNoLeapCalendar(void);                                   // Not implemented yet. 
    20             CNoLeapCalendar(const StdString & dateStr); 
    21             CNoLeapCalendar(const StdString & dateStr,const StdString & timeOriginStr); 
     20            CNoLeapCalendar(const CDate& startDate); 
     21            CNoLeapCalendar(const CDate& startDate, const CDate& timeOrigin); 
    2222            CNoLeapCalendar(int yr = 0, int mth = 1, int d   = 1, 
    2323                            int hr = 0, int min = 0, int sec = 0); 
    24             CNoLeapCalendar(const CNoLeapCalendar & calendar);       // Not implemented yet. 
    25             CNoLeapCalendar(const CNoLeapCalendar * calendar);       // Not implemented yet. 
     24            CNoLeapCalendar(const CNoLeapCalendar& calendar);       // Not implemented yet. 
     25            CNoLeapCalendar(const CNoLeapCalendar* calendar);       // Not implemented yet. 
    2626 
    2727            /// Accesseurs /// 
  • XIOS/trunk/src/generate_interface_decl.cpp

    r501 r532  
    1919  macro(int) 
    2020  macro(double) 
     21  macro(CDate) 
    2122} 
  • XIOS/trunk/src/generate_interface_impl.hpp

    r509 r532  
    88#include "enum.hpp" 
    99#include "array_new.hpp" 
     10#include "date.hpp" 
    1011 
    1112namespace xios 
     
    1516  template<> string CInterface::getStrFortranType<double>(void) {return string("REAL") ;} 
    1617  template<> string CInterface::getStrFortranType<float>(void) {return string("REAL") ;} 
     18  template<> string CInterface::getStrFortranType<CDate>(void) {return string("TYPE(txios(date))") ;} 
    1719 
    1820  template<> string CInterface::getStrFortranKind<int>(void) {return string("") ;} 
     
    2022  template<> string CInterface::getStrFortranKind<double>(void) {return string("(KIND=8)") ;} 
    2123  template<> string CInterface::getStrFortranKind<float>(void) {return string("(KIND=4)") ;} 
     24  template<> string CInterface::getStrFortranKind<CDate>(void) {return string("") ;} 
    2225 
    2326  template<> string CInterface::getStrFortranKindC<int>(void) {return string("(KIND=C_INT)") ;} 
     
    2528  template<> string CInterface::getStrFortranKindC<double>(void) {return string("(KIND=C_DOUBLE)") ;} 
    2629  template<> string CInterface::getStrFortranKindC<float>(void) {return string("(KIND=C_FLOAT)") ;} 
     30  template<> string CInterface::getStrFortranKindC<CDate>(void) {return string("") ;} 
    2731 
    2832  template<> bool CInterface::matchingTypeCFortran<int>(void) { return true ; } 
     
    3034  template<> bool CInterface::matchingTypeCFortran<double>(void) { return true; } 
    3135  template<> bool CInterface::matchingTypeCFortran<float>(void) { return true; } 
     36  template<> bool CInterface::matchingTypeCFortran<CDate>(void) { return true; } 
    3237 
    3338 
     
    125130//     if (!array_copy(domain_hdl->mask.getValue(), mask, extent1, extent2)) 
    126131//        ERROR("cxios_get_domain_mask(XDomainPtr domain_hdl, bool * mask, int extent1, int extent2)",<<"Output array size is not conform to array size attribut") ; 
     132 
     133  template<> 
     134  void CInterface::AttributeCInterface<CDate>(ostream& oss, const string& className,const string& name) 
     135  { 
     136    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, cxios_date " << name << "_c)" << iendl; 
     137    oss << "{" << iendl; 
     138    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; 
     139    oss << "  " << className << "_hdl->" << name << ".allocate();" << iendl; 
     140    oss << "  CDate& " << name <<" = " << className << "_hdl->" << name << ".get();" << iendl; 
     141    oss << "  " << name << ".setDate(" << name << "_c.year," << iendl; 
     142    oss << "                         " << name << "_c.month," << iendl; 
     143    oss << "                         " << name << "_c.day," << iendl; 
     144    oss << "                         " << name << "_c.hour," << iendl; 
     145    oss << "                         " << name << "_c.minute," << iendl; 
     146    oss << "                         " << name << "_c.second);" << iendl; 
     147    oss << "  if (" << name << ".hasRelCalendar())" << iendl; 
     148    oss << "    " << name << ".checkDate();" << iendl; 
     149    oss << "  CTimer::get(\"XIOS\").suspend();" << iendl; 
     150    oss << "}" << iendl; 
     151 
     152    oss << iendl; 
     153 
     154    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, cxios_date* " << name << "_c)" << iendl; 
     155    oss << "{" << iendl; 
     156    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; 
     157    oss << "  CDate " << name <<" = " << className << "_hdl->" << name << ".getInheritedValue();" << iendl; 
     158    oss << "  " << name << "_c->year = " << name << ".getYear();" << iendl; 
     159    oss << "  " << name << "_c->month = " << name << ".getMonth();" << iendl; 
     160    oss << "  " << name << "_c->day = " << name << ".getDay();" << iendl; 
     161    oss << "  " << name << "_c->hour = " << name << ".getHour();" << iendl; 
     162    oss << "  " << name << "_c->minute = " << name << ".getMinute();" << iendl; 
     163    oss << "  " << name << "_c->second = " << name << ".getSecond();" << iendl; 
     164    oss << "  CTimer::get(\"XIOS\").suspend();" << iendl; 
     165    oss << "}" << iendl; 
     166    oss << iendl; 
     167  } 
    127168 
    128169/* 
     
    256297     oss<<iendl ; 
    257298   } 
     299 
     300  template <> 
     301  void CInterface::AttributeFortran2003Interface<CDate>(ostream& oss, const string& className, const string& name) 
     302  { 
     303    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; 
     304    oss << "  USE ISO_C_BINDING" << iendl; 
     305    oss << "  USE IDATE" << iendl; 
     306    oss << "  INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; 
     307    oss << "  TYPE(xios_date), VALUE :: " << name << iendl; 
     308    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << iendl; 
     309    oss << iendl; 
     310    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; 
     311    oss << "  USE ISO_C_BINDING" << iendl; 
     312    oss << "  USE IDATE" << iendl; 
     313    oss << "  INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; 
     314    oss << "  TYPE(txios(date)) :: " << name << iendl; 
     315    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << iendl; 
     316    oss << iendl; 
     317  } 
    258318 
    259319/* 
  • XIOS/trunk/src/interface/c_attr/icaxis_attr.cpp

    r509 r532  
    1010#include "group_template.hpp" 
    1111#include "icutil.hpp" 
     12#include "icdate.hpp" 
    1213#include "timer.hpp" 
    1314#include "node_type.hpp" 
  • XIOS/trunk/src/interface/c_attr/icaxisgroup_attr.cpp

    r509 r532  
    1010#include "group_template.hpp" 
    1111#include "icutil.hpp" 
     12#include "icdate.hpp" 
    1213#include "timer.hpp" 
    1314#include "node_type.hpp" 
  • XIOS/trunk/src/interface/c_attr/iccontext_attr.cpp

    r526 r532  
    1010#include "group_template.hpp" 
    1111#include "icutil.hpp" 
     12#include "icdate.hpp" 
    1213#include "timer.hpp" 
    1314#include "node_type.hpp" 
     
    6970   
    7071   
    71   void cxios_set_context_start_date(context_Ptr context_hdl, const char * start_date, int start_date_size) 
     72  void cxios_set_context_start_date(context_Ptr context_hdl, cxios_date start_date_c) 
    7273  { 
    73     std::string start_date_str; 
    74     if(!cstr2string(start_date, start_date_size, start_date_str)) return; 
    75      CTimer::get("XIOS").resume(); 
    76     context_hdl->start_date.setValue(start_date_str); 
    77      CTimer::get("XIOS").suspend(); 
     74    CTimer::get("XIOS").resume(); 
     75    context_hdl->start_date.allocate(); 
     76    CDate& start_date = context_hdl->start_date.get(); 
     77    start_date.setDate(start_date_c.year, 
     78                           start_date_c.month, 
     79                           start_date_c.day, 
     80                           start_date_c.hour, 
     81                           start_date_c.minute, 
     82                           start_date_c.second); 
     83    if (start_date.hasRelCalendar()) 
     84      start_date.checkDate(); 
     85    CTimer::get("XIOS").suspend(); 
    7886  } 
    7987   
    80   void cxios_get_context_start_date(context_Ptr context_hdl, char * start_date, int start_date_size) 
     88  void cxios_get_context_start_date(context_Ptr context_hdl, cxios_date* start_date_c) 
    8189  { 
    82      CTimer::get("XIOS").resume(); 
    83     if(!string_copy(context_hdl->start_date.getInheritedValue(),start_date , start_date_size)) 
    84       ERROR("void cxios_get_context_start_date(context_Ptr context_hdl, char * start_date, int start_date_size)", <<"Input string is to short"); 
    85      CTimer::get("XIOS").suspend(); 
     90    CTimer::get("XIOS").resume(); 
     91    CDate start_date = context_hdl->start_date.getInheritedValue(); 
     92    start_date_c->year = start_date.getYear(); 
     93    start_date_c->month = start_date.getMonth(); 
     94    start_date_c->day = start_date.getDay(); 
     95    start_date_c->hour = start_date.getHour(); 
     96    start_date_c->minute = start_date.getMinute(); 
     97    start_date_c->second = start_date.getSecond(); 
     98    CTimer::get("XIOS").suspend(); 
    8699  } 
    87100   
     
    95108   
    96109   
    97   void cxios_set_context_time_origin(context_Ptr context_hdl, const char * time_origin, int time_origin_size) 
     110  void cxios_set_context_time_origin(context_Ptr context_hdl, cxios_date time_origin_c) 
    98111  { 
    99     std::string time_origin_str; 
    100     if(!cstr2string(time_origin, time_origin_size, time_origin_str)) return; 
    101      CTimer::get("XIOS").resume(); 
    102     context_hdl->time_origin.setValue(time_origin_str); 
    103      CTimer::get("XIOS").suspend(); 
     112    CTimer::get("XIOS").resume(); 
     113    context_hdl->time_origin.allocate(); 
     114    CDate& time_origin = context_hdl->time_origin.get(); 
     115    time_origin.setDate(time_origin_c.year, 
     116                           time_origin_c.month, 
     117                           time_origin_c.day, 
     118                           time_origin_c.hour, 
     119                           time_origin_c.minute, 
     120                           time_origin_c.second); 
     121    if (time_origin.hasRelCalendar()) 
     122      time_origin.checkDate(); 
     123    CTimer::get("XIOS").suspend(); 
    104124  } 
    105125   
    106   void cxios_get_context_time_origin(context_Ptr context_hdl, char * time_origin, int time_origin_size) 
     126  void cxios_get_context_time_origin(context_Ptr context_hdl, cxios_date* time_origin_c) 
    107127  { 
    108      CTimer::get("XIOS").resume(); 
    109     if(!string_copy(context_hdl->time_origin.getInheritedValue(),time_origin , time_origin_size)) 
    110       ERROR("void cxios_get_context_time_origin(context_Ptr context_hdl, char * time_origin, int time_origin_size)", <<"Input string is to short"); 
    111      CTimer::get("XIOS").suspend(); 
     128    CTimer::get("XIOS").resume(); 
     129    CDate time_origin = context_hdl->time_origin.getInheritedValue(); 
     130    time_origin_c->year = time_origin.getYear(); 
     131    time_origin_c->month = time_origin.getMonth(); 
     132    time_origin_c->day = time_origin.getDay(); 
     133    time_origin_c->hour = time_origin.getHour(); 
     134    time_origin_c->minute = time_origin.getMinute(); 
     135    time_origin_c->second = time_origin.getSecond(); 
     136    CTimer::get("XIOS").suspend(); 
    112137  } 
    113138   
  • XIOS/trunk/src/interface/c_attr/icdomain_attr.cpp

    r509 r532  
    1010#include "group_template.hpp" 
    1111#include "icutil.hpp" 
     12#include "icdate.hpp" 
    1213#include "timer.hpp" 
    1314#include "node_type.hpp" 
  • XIOS/trunk/src/interface/c_attr/icdomaingroup_attr.cpp

    r509 r532  
    1010#include "group_template.hpp" 
    1111#include "icutil.hpp" 
     12#include "icdate.hpp" 
    1213#include "timer.hpp" 
    1314#include "node_type.hpp" 
  • XIOS/trunk/src/interface/c_attr/icfield_attr.cpp

    r509 r532  
    1010#include "group_template.hpp" 
    1111#include "icutil.hpp" 
     12#include "icdate.hpp" 
    1213#include "timer.hpp" 
    1314#include "node_type.hpp" 
  • XIOS/trunk/src/interface/c_attr/icfieldgroup_attr.cpp

    r509 r532  
    1010#include "group_template.hpp" 
    1111#include "icutil.hpp" 
     12#include "icdate.hpp" 
    1213#include "timer.hpp" 
    1314#include "node_type.hpp" 
  • XIOS/trunk/src/interface/c_attr/icfile_attr.cpp

    r528 r532  
    1010#include "group_template.hpp" 
    1111#include "icutil.hpp" 
     12#include "icdate.hpp" 
    1213#include "timer.hpp" 
    1314#include "node_type.hpp" 
  • XIOS/trunk/src/interface/c_attr/icfilegroup_attr.cpp

    r528 r532  
    1010#include "group_template.hpp" 
    1111#include "icutil.hpp" 
     12#include "icdate.hpp" 
    1213#include "timer.hpp" 
    1314#include "node_type.hpp" 
  • XIOS/trunk/src/interface/c_attr/icgrid_attr.cpp

    r509 r532  
    1010#include "group_template.hpp" 
    1111#include "icutil.hpp" 
     12#include "icdate.hpp" 
    1213#include "timer.hpp" 
    1314#include "node_type.hpp" 
  • XIOS/trunk/src/interface/c_attr/icgridgroup_attr.cpp

    r509 r532  
    1010#include "group_template.hpp" 
    1111#include "icutil.hpp" 
     12#include "icdate.hpp" 
    1213#include "timer.hpp" 
    1314#include "node_type.hpp" 
  • XIOS/trunk/src/interface/c_attr/icvariable_attr.cpp

    r527 r532  
    1010#include "group_template.hpp" 
    1111#include "icutil.hpp" 
     12#include "icdate.hpp" 
    1213#include "timer.hpp" 
    1314#include "node_type.hpp" 
  • XIOS/trunk/src/interface/c_attr/icvariablegroup_attr.cpp

    r527 r532  
    1010#include "group_template.hpp" 
    1111#include "icutil.hpp" 
     12#include "icdate.hpp" 
    1213#include "timer.hpp" 
    1314#include "node_type.hpp" 
  • XIOS/trunk/src/interface/fortran/idate.F90

    r501 r532  
    66   INTEGER(kind = C_INT), PARAMETER :: D360 = 0 , ALLLEAP = 1 , NOLEAP = 2 , JULIAN = 3 , GREGORIAN = 4 
    77 
    8    TYPE txios(date) 
    9       INTEGER :: year, month, day, hour, minute, second 
     8   TYPE, BIND(C) :: txios(date) 
     9      INTEGER(kind = C_INT) :: year, month, day, hour, minute, second 
    1010   END TYPE txios(date) 
    1111 
  • XIOS/trunk/src/interface/fortran_attr/axis_interface_attr.F90

    r531 r532  
    22! *               Interface auto generated - do not modify                     * 
    33! * ************************************************************************** * 
     4#include "../fortran/xios_fortran_prefix.hpp" 
    45 
    56MODULE axis_interface_attr 
  • XIOS/trunk/src/interface/fortran_attr/axisgroup_interface_attr.F90

    r531 r532  
    22! *               Interface auto generated - do not modify                     * 
    33! * ************************************************************************** * 
     4#include "../fortran/xios_fortran_prefix.hpp" 
    45 
    56MODULE axisgroup_interface_attr 
  • XIOS/trunk/src/interface/fortran_attr/context_interface_attr.F90

    r531 r532  
    22! *               Interface auto generated - do not modify                     * 
    33! * ************************************************************************** * 
     4#include "../fortran/xios_fortran_prefix.hpp" 
    45 
    56MODULE context_interface_attr 
     
    5152     
    5253     
    53     SUBROUTINE cxios_set_context_start_date(context_hdl, start_date, start_date_size) BIND(C) 
     54    SUBROUTINE cxios_set_context_start_date(context_hdl, start_date) BIND(C) 
    5455      USE ISO_C_BINDING 
     56      USE IDATE 
    5557      INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    56       CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: start_date 
    57       INTEGER  (kind = C_INT)     , VALUE        :: start_date_size 
     58      TYPE(xios_date), VALUE :: start_date 
    5859    END SUBROUTINE cxios_set_context_start_date 
    5960     
    60     SUBROUTINE cxios_get_context_start_date(context_hdl, start_date, start_date_size) BIND(C) 
     61    SUBROUTINE cxios_get_context_start_date(context_hdl, start_date) BIND(C) 
    6162      USE ISO_C_BINDING 
     63      USE IDATE 
    6264      INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    63       CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: start_date 
    64       INTEGER  (kind = C_INT)     , VALUE        :: start_date_size 
     65      TYPE(txios(date)) :: start_date 
    6566    END SUBROUTINE cxios_get_context_start_date 
    6667     
     
    7273     
    7374     
    74     SUBROUTINE cxios_set_context_time_origin(context_hdl, time_origin, time_origin_size) BIND(C) 
     75    SUBROUTINE cxios_set_context_time_origin(context_hdl, time_origin) BIND(C) 
    7576      USE ISO_C_BINDING 
     77      USE IDATE 
    7678      INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    77       CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: time_origin 
    78       INTEGER  (kind = C_INT)     , VALUE        :: time_origin_size 
     79      TYPE(xios_date), VALUE :: time_origin 
    7980    END SUBROUTINE cxios_set_context_time_origin 
    8081     
    81     SUBROUTINE cxios_get_context_time_origin(context_hdl, time_origin, time_origin_size) BIND(C) 
     82    SUBROUTINE cxios_get_context_time_origin(context_hdl, time_origin) BIND(C) 
    8283      USE ISO_C_BINDING 
     84      USE IDATE 
    8385      INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    84       CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: time_origin 
    85       INTEGER  (kind = C_INT)     , VALUE        :: time_origin_size 
     86      TYPE(txios(date)) :: time_origin 
    8687    END SUBROUTINE cxios_get_context_time_origin 
    8788     
  • XIOS/trunk/src/interface/fortran_attr/domain_interface_attr.F90

    r531 r532  
    22! *               Interface auto generated - do not modify                     * 
    33! * ************************************************************************** * 
     4#include "../fortran/xios_fortran_prefix.hpp" 
    45 
    56MODULE domain_interface_attr 
  • XIOS/trunk/src/interface/fortran_attr/domaingroup_interface_attr.F90

    r531 r532  
    22! *               Interface auto generated - do not modify                     * 
    33! * ************************************************************************** * 
     4#include "../fortran/xios_fortran_prefix.hpp" 
    45 
    56MODULE domaingroup_interface_attr 
  • XIOS/trunk/src/interface/fortran_attr/field_interface_attr.F90

    r531 r532  
    22! *               Interface auto generated - do not modify                     * 
    33! * ************************************************************************** * 
     4#include "../fortran/xios_fortran_prefix.hpp" 
    45 
    56MODULE field_interface_attr 
  • XIOS/trunk/src/interface/fortran_attr/fieldgroup_interface_attr.F90

    r531 r532  
    22! *               Interface auto generated - do not modify                     * 
    33! * ************************************************************************** * 
     4#include "../fortran/xios_fortran_prefix.hpp" 
    45 
    56MODULE fieldgroup_interface_attr 
  • XIOS/trunk/src/interface/fortran_attr/file_interface_attr.F90

    r531 r532  
    22! *               Interface auto generated - do not modify                     * 
    33! * ************************************************************************** * 
     4#include "../fortran/xios_fortran_prefix.hpp" 
    45 
    56MODULE file_interface_attr 
  • XIOS/trunk/src/interface/fortran_attr/filegroup_interface_attr.F90

    r531 r532  
    22! *               Interface auto generated - do not modify                     * 
    33! * ************************************************************************** * 
     4#include "../fortran/xios_fortran_prefix.hpp" 
    45 
    56MODULE filegroup_interface_attr 
  • XIOS/trunk/src/interface/fortran_attr/grid_interface_attr.F90

    r531 r532  
    22! *               Interface auto generated - do not modify                     * 
    33! * ************************************************************************** * 
     4#include "../fortran/xios_fortran_prefix.hpp" 
    45 
    56MODULE grid_interface_attr 
  • XIOS/trunk/src/interface/fortran_attr/gridgroup_interface_attr.F90

    r531 r532  
    22! *               Interface auto generated - do not modify                     * 
    33! * ************************************************************************** * 
     4#include "../fortran/xios_fortran_prefix.hpp" 
    45 
    56MODULE gridgroup_interface_attr 
  • XIOS/trunk/src/interface/fortran_attr/icontext_attr.F90

    r501 r532  
    1919      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: calendar_type 
    2020      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: output_dir 
    21       CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: start_date 
    22       CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: time_origin 
     21      TYPE(txios(date)) , OPTIONAL, INTENT(IN) :: start_date 
     22      TYPE(txios(date)) , OPTIONAL, INTENT(IN) :: time_origin 
    2323      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: timestep 
    2424       
     
    3636      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: calendar_type 
    3737      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: output_dir 
    38       CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: start_date 
    39       CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: time_origin 
     38      TYPE(txios(date)) , OPTIONAL, INTENT(IN) :: start_date 
     39      TYPE(txios(date)) , OPTIONAL, INTENT(IN) :: time_origin 
    4040      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: timestep 
    4141       
     
    5252      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: calendar_type_ 
    5353      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: output_dir_ 
    54       CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: start_date_ 
    55       CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: time_origin_ 
     54      TYPE(txios(date)) , OPTIONAL, INTENT(IN) :: start_date_ 
     55      TYPE(txios(date)) , OPTIONAL, INTENT(IN) :: time_origin_ 
    5656      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: timestep_ 
    5757       
     
    6565       
    6666      IF (PRESENT(start_date_)) THEN 
    67         CALL cxios_set_context_start_date(context_hdl%daddr, start_date_, len(start_date_)) 
     67        CALL cxios_set_context_start_date(context_hdl%daddr, start_date_) 
    6868      ENDIF 
    6969       
    7070      IF (PRESENT(time_origin_)) THEN 
    71         CALL cxios_set_context_time_origin(context_hdl%daddr, time_origin_, len(time_origin_)) 
     71        CALL cxios_set_context_time_origin(context_hdl%daddr, time_origin_) 
    7272      ENDIF 
    7373       
     
    8888      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: calendar_type 
    8989      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: output_dir 
    90       CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: start_date 
    91       CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: time_origin 
     90      TYPE(txios(date)) , OPTIONAL, INTENT(OUT) :: start_date 
     91      TYPE(txios(date)) , OPTIONAL, INTENT(OUT) :: time_origin 
    9292      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: timestep 
    9393       
     
    105105      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: calendar_type 
    106106      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: output_dir 
    107       CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: start_date 
    108       CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: time_origin 
     107      TYPE(txios(date)) , OPTIONAL, INTENT(OUT) :: start_date 
     108      TYPE(txios(date)) , OPTIONAL, INTENT(OUT) :: time_origin 
    109109      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: timestep 
    110110       
     
    121121      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: calendar_type_ 
    122122      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: output_dir_ 
    123       CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: start_date_ 
    124       CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: time_origin_ 
     123      TYPE(txios(date)) , OPTIONAL, INTENT(OUT) :: start_date_ 
     124      TYPE(txios(date)) , OPTIONAL, INTENT(OUT) :: time_origin_ 
    125125      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: timestep_ 
    126126       
     
    134134       
    135135      IF (PRESENT(start_date_)) THEN 
    136         CALL cxios_get_context_start_date(context_hdl%daddr, start_date_, len(start_date_)) 
     136        CALL cxios_get_context_start_date(context_hdl%daddr, start_date_) 
    137137      ENDIF 
    138138       
    139139      IF (PRESENT(time_origin_)) THEN 
    140         CALL cxios_get_context_time_origin(context_hdl%daddr, time_origin_, len(time_origin_)) 
     140        CALL cxios_get_context_time_origin(context_hdl%daddr, time_origin_) 
    141141      ENDIF 
    142142       
  • XIOS/trunk/src/interface/fortran_attr/variable_interface_attr.F90

    r531 r532  
    22! *               Interface auto generated - do not modify                     * 
    33! * ************************************************************************** * 
     4#include "../fortran/xios_fortran_prefix.hpp" 
    45 
    56MODULE variable_interface_attr 
  • XIOS/trunk/src/interface/fortran_attr/variablegroup_interface_attr.F90

    r531 r532  
    22! *               Interface auto generated - do not modify                     * 
    33! * ************************************************************************** * 
     4#include "../fortran/xios_fortran_prefix.hpp" 
    45 
    56MODULE variablegroup_interface_attr 
  • XIOS/trunk/src/node/context.cpp

    r526 r532  
    7474      this->calendar = newCalendar; 
    7575      calendar_type.fromString(this->calendar->getId()); 
    76       start_date.setValue(this->calendar->getInitDate().toString()); 
     76      start_date.setValue(this->calendar->getInitDate()); 
    7777   } 
    7878 
     
    8787               << "Impossible to define a calendar (an attribute is missing)."); 
    8888 
    89 #define DECLARE_CALENDAR(MType, eType)                                              \ 
    90    if (calendar_type.getValue() == eType)                                           \ 
    91    {                                                                                \ 
    92       if (time_origin.isEmpty())                                                    \ 
    93         this->calendar = boost::shared_ptr<CCalendar>                               \ 
    94             (new C##MType##Calendar(start_date.getValue()));                        \ 
    95       else this->calendar = boost::shared_ptr<CCalendar>                            \ 
    96             (new C##MType##Calendar(start_date.getValue(),time_origin.getValue())); \ 
    97       if (!this->timestep.isEmpty())                                                \ 
    98         this->calendar->setTimeStep                                                 \ 
    99             (CDuration::FromString(this->timestep.getValue()));                     \ 
    100       return;                                                                       \ 
    101    } 
     89#define DECLARE_CALENDAR(MType, eType)                                             \ 
     90  if (calendar_type.getValue() == eType)                                           \ 
     91  {                                                                                \ 
     92    if (time_origin.isEmpty())                                                     \ 
     93      this->calendar = boost::shared_ptr<CCalendar>                                \ 
     94          (new C##MType##Calendar(start_date.getValue()));                         \ 
     95    else this->calendar = boost::shared_ptr<CCalendar>                             \ 
     96          (new C##MType##Calendar(start_date.getValue(), time_origin.getValue())); \ 
     97                                                                                   \ 
     98    if (!start_date.getValue().setRelCalendar(*this->calendar))                    \ 
     99      ERROR("CContext::solveCalendar(void)",                                       \ 
     100            "start_date: Bad format or date not conform to the calendar");         \ 
     101    if (!time_origin.getValue().setRelCalendar(*this->calendar))                   \ 
     102      ERROR("CContext::solveCalendar(void)",                                       \ 
     103            "time_origin: Bad format or date not conform to the calendar");        \ 
     104                                                                                   \ 
     105    if (!this->timestep.isEmpty())                                                 \ 
     106      this->calendar->setTimeStep                                                  \ 
     107          (CDuration::FromString(this->timestep.getValue()));                      \ 
     108    return;                                                                        \ 
     109  } 
    102110#include "calendar_type.conf" 
    103111#undef DECLARE_CALENDAR 
  • XIOS/trunk/src/object_template_impl.hpp

    r511 r532  
    335335     oss<<"#include \"group_template.hpp\""<<iendl ; 
    336336     oss<<"#include \"icutil.hpp\""<<iendl ; 
     337     oss<<"#include \"icdate.hpp\""<<iendl ; 
    337338     oss<<"#include \"timer.hpp\""<<iendl ; 
    338339     oss<<"#include \"node_type.hpp\""<<iendl ; 
     
    357358     oss<<"! *               Interface auto generated - do not modify                     *"<<iendl ; 
    358359     oss<<"! * ************************************************************************** *"<<iendl; 
     360     oss<<"#include \"../fortran/xios_fortran_prefix.hpp\""<<iendl ; 
    359361     oss<<iendl ; 
    360362     oss<<"MODULE "<<className<<"_interface_attr"<<iendl++ ; 
  • XIOS/trunk/src/test/test_complete.f90

    r501 r532  
    1111  CHARACTER(len=*),PARAMETER :: id="client" 
    1212  INTEGER :: comm 
     13  TYPE(xios_date)      :: start_date, time_origin 
    1314  TYPE(xios_time)      :: dtime 
    1415  TYPE(xios_context) :: ctx_hdl 
     
    8384  CALL xios_set_current_context(ctx_hdl) 
    8485   
    85   CALL xios_set_context_attr("atmosphere",calendar_type="Gregorian")  
    86   CALL xios_set_context_attr("atmosphere",start_date="2000-01-01 00:00:00") 
    87   CALL xios_set_context_attr("atmosphere",time_origin="1999-01-01 15:00:00") 
     86  CALL xios_set_context_attr("atmosphere",calendar_type="Gregorian") 
     87  start_date = xios_date(2000, 01, 01, 00, 00, 00) 
     88  CALL xios_set_context_attr("atmosphere",start_date=start_date) 
     89  time_origin = xios_date(1999, 01, 01, 15, 00, 00) 
     90  CALL xios_set_context_attr("atmosphere",time_origin=time_origin) 
    8891 
    8992  CALL xios_set_axis_attr("axis_atm",size=llm ,value=lval) ; 
     
    171174  CALL xios_set_current_context(ctx_hdl) 
    172175   
    173   CALL xios_set_context_attr("surface",calendar_type="Gregorian")  
    174   CALL xios_set_context_attr("surface",start_date="2000-01-01 00:00:00") 
    175   CALL xios_set_context_attr("surface",time_origin="1999-01-01 15:00:00") 
     176  CALL xios_set_context_attr("surface",calendar_type="Gregorian") 
     177  start_date = xios_date(2000, 01, 01, 00, 00, 00) 
     178  CALL xios_set_context_attr("surface",start_date=start_date) 
     179  time_origin = xios_date(1999, 01, 01, 15, 00, 00) 
     180  CALL xios_set_context_attr("surface",time_origin=time_origin) 
    176181 
    177182  CALL xios_set_axis_attr("axis_srf",size=llm ,value=lval) ; 
  • XIOS/trunk/src/test/test_xios_interface.f90

    r510 r532  
    1212  CHARACTER(len=*),PARAMETER :: id="client" 
    1313  INTEGER :: comm 
     14  TYPE(xios_date)      :: start_date, time_origin 
    1415  TYPE(xios_time)      :: dtime 
    1516  TYPE(xios_context) :: ctx_hdl 
     
    9697 
    9798  CALL xios_set_context_attr("atmosphere",calendar_type="Gregorian") 
    98   CALL xios_set_context_attr("atmosphere",start_date="2000-01-01 00:00:00") 
    99   CALL xios_set_context_attr("atmosphere",time_origin="1999-01-01 15:00:00") 
     99  start_date = xios_date(2000, 01, 01, 00, 00, 00) 
     100  CALL xios_set_context_attr("atmosphere",start_date=start_date) 
     101  time_origin = xios_date(1999, 01, 01, 15, 00, 00) 
     102  CALL xios_set_context_attr("atmosphere",time_origin=time_origin) 
    100103 
    101104  CALL xios_set_axis_attr("axis_atm",size=llm ,value=lval) ; 
     
    181184 
    182185  CALL xios_set_context_attr("surface",calendar_type="Gregorian") 
    183   CALL xios_set_context_attr("surface",start_date="2000-01-01 00:00:00") 
    184   CALL xios_set_context_attr("surface",time_origin="1999-01-01 15:00:00") 
     186  start_date = xios_date(2000, 01, 01, 00, 00, 00) 
     187  CALL xios_set_context_attr("surface",start_date=start_date) 
     188  time_origin = xios_date(1999, 01, 01, 15, 00, 00) 
     189  CALL xios_set_context_attr("surface",time_origin=time_origin) 
    185190 
    186191  CALL xios_set_axis_attr("axis_srf",size=llm ,value=lval) ; 
  • XIOS/trunk/src/type/type_decl.cpp

    r501 r532  
    44#include "type_specialisation.hpp" 
    55#include <string> ; 
     6#include "date.hpp" 
    67#include "xmlioserver_spl.hpp" 
    78 
     
    2324  template CMessage& operator<< <decl_type> (CMessage& msg, decl_type& type) ; 
    2425   
    25   macro(string)  
    26   macro(int)  
     26  macro(string) 
     27  macro(int) 
    2728  macro(double) 
    28   macro(bool)   
    29   macro(StdSize)  
    30  
     29  macro(bool) 
     30  macro(StdSize) 
     31  macro(CDate) 
    3132} 
  • XIOS/trunk/src/type/type_specialisation.hpp

    r501 r532  
    99#include <string> 
    1010#include <boost/algorithm/string.hpp> 
     11#include "date.hpp" 
    1112  
    1213namespace xios 
     
    165166    return ret ; 
    166167  }      
     168 
     169// template specializations for CDate 
     170 
     171  template <> 
     172  size_t CType<CDate>::_size() const 
     173  { 
     174    return 6 * sizeof(int); 
     175  } 
     176 
     177  template <> 
     178  size_t CType_ref<CDate>::_size() const 
     179  { 
     180    return 6 * sizeof(int); 
     181  } 
     182   
     183  /*template <> 
     184  void CType<CDate>::_fromString(const string& str) 
     185  { 
     186    allocate() ; 
     187    *ptrValue=str ; 
     188  }   
     189 
     190  template <> 
     191  void CType_ref<CDate>::_fromString(const string& str) 
     192  { 
     193    checkEmpty() ; 
     194    *ptrValue=str ; 
     195  }   
     196 
     197  template <> 
     198  void CType_ref<CDate>::_fromString(const string& str) const 
     199  { 
     200    checkEmpty() ; 
     201    *ptrValue=str ; 
     202  }*/  
     203   
     204  template <> 
     205  bool CType<CDate>::_toBuffer(CBufferOut& buffer) const 
     206  { 
     207    if (buffer.remain() < size()) return false; 
     208    else 
     209    { 
     210      bool ret = true; 
     211      if (ret) ret &= buffer.put(ptrValue->getYear()); 
     212      if (ret) ret &= buffer.put(ptrValue->getMonth()); 
     213      if (ret) ret &= buffer.put(ptrValue->getDay()); 
     214      if (ret) ret &= buffer.put(ptrValue->getHour()); 
     215      if (ret) ret &= buffer.put(ptrValue->getMinute()); 
     216      if (ret) ret &= buffer.put(ptrValue->getSecond()); 
     217      return ret; 
     218    } 
     219  } 
     220   
     221  template <> 
     222  bool CType_ref<CDate>::_toBuffer(CBufferOut& buffer) const 
     223  { 
     224    if (buffer.remain() < size()) return false; 
     225    else 
     226    { 
     227      bool ret = true; 
     228      if (ret) ret &= buffer.put(ptrValue->getYear()); 
     229      if (ret) ret &= buffer.put(ptrValue->getMonth()); 
     230      if (ret) ret &= buffer.put(ptrValue->getDay()); 
     231      if (ret) ret &= buffer.put(ptrValue->getHour()); 
     232      if (ret) ret &= buffer.put(ptrValue->getMinute()); 
     233      if (ret) ret &= buffer.put(ptrValue->getSecond()); 
     234      return ret; 
     235    } 
     236  } 
     237 
     238  template <> 
     239  bool CType<CDate>::_fromBuffer(CBufferIn& buffer) 
     240  { 
     241    allocate(); 
     242    bool ret = true; 
     243 
     244    int year, month, day, hour, min, sec; 
     245    if (ret) ret &= buffer.get(year); 
     246    if (ret) ret &= buffer.get(month); 
     247    if (ret) ret &= buffer.get(day); 
     248    if (ret) ret &= buffer.get(hour); 
     249    if (ret) ret &= buffer.get(min); 
     250    if (ret) ret &= buffer.get(sec); 
     251    if (ret) 
     252    { 
     253      ptrValue->setYear(year); 
     254      ptrValue->setMonth(month); 
     255      ptrValue->setDay(day); 
     256      ptrValue->setHour(hour); 
     257      ptrValue->setMinute(min); 
     258      ptrValue->setSecond(sec); 
     259    } 
     260 
     261    return ret; 
     262  } 
     263 
     264  template <> 
     265  bool CType_ref<CDate>::_fromBuffer(CBufferIn& buffer) const 
     266  { 
     267    bool ret = true; 
     268     
     269    int year, month, day, hour, min, sec; 
     270    if (ret) ret &= buffer.get(year); 
     271    if (ret) ret &= buffer.get(month); 
     272    if (ret) ret &= buffer.get(day); 
     273    if (ret) ret &= buffer.get(hour); 
     274    if (ret) ret &= buffer.get(min); 
     275    if (ret) ret &= buffer.get(sec); 
     276    if (ret) 
     277    { 
     278      ptrValue->setYear(year); 
     279      ptrValue->setMonth(month); 
     280      ptrValue->setDay(day); 
     281      ptrValue->setHour(hour); 
     282      ptrValue->setMinute(min); 
     283      ptrValue->setSecond(sec); 
     284    } 
     285 
     286    return ret; 
     287  } 
     288 
     289  template <> 
     290  bool CType_ref<CDate>::_fromBuffer(CBufferIn& buffer) 
     291  { 
     292    bool ret = true; 
     293     
     294    int year, month, day, hour, min, sec; 
     295    if (ret) ret &= buffer.get(year); 
     296    if (ret) ret &= buffer.get(month); 
     297    if (ret) ret &= buffer.get(day); 
     298    if (ret) ret &= buffer.get(hour); 
     299    if (ret) ret &= buffer.get(min); 
     300    if (ret) ret &= buffer.get(sec); 
     301    if (ret) 
     302    { 
     303      ptrValue->setYear(year); 
     304      ptrValue->setMonth(month); 
     305      ptrValue->setDay(day); 
     306      ptrValue->setHour(hour); 
     307      ptrValue->setMinute(min); 
     308      ptrValue->setSecond(sec); 
     309    } 
     310 
     311    return ret; 
     312  } 
     313 
    167314  // template specialisation for CArray 
    168315/* 
Note: See TracChangeset for help on using the changeset viewer.