Changeset 532
- Timestamp:
- 12/10/14 14:27:09 (10 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 52 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/attribute_template_decl.cpp
r501 r532 2 2 #include "attribute_template_specialisation.hpp" 3 3 #include <string> 4 #include "date.hpp" 4 5 5 6 namespace xios … … 9 10 template class CAttributeTemplate<bool> ; 10 11 template class CAttributeTemplate<string> ; 12 template class CAttributeTemplate<CDate> ; 11 13 } -
XIOS/trunk/src/calendar.cpp
r501 r532 14 14 { } 15 15 16 CCalendar::CCalendar(const StdString 16 CCalendar::CCalendar(const StdString& id) 17 17 : CObject(id) 18 18 , initDate(*this) … … 21 21 { } 22 22 23 CCalendar::CCalendar(const StdString 23 CCalendar::CCalendar(const StdString& id, 24 24 int yr, int mth, int d , 25 25 int hr, int min, int sec) … … 32 32 } 33 33 34 CCalendar::CCalendar(const StdString & id, const StdString & dateStr)34 CCalendar::CCalendar(const StdString& id, const CDate& startDate) 35 35 : 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 41 42 } 42 43 43 CCalendar::CCalendar(const StdString & id, const StdString & dateStr, const StdString & timeOriginStr)44 CCalendar::CCalendar(const StdString& id, const CDate& startDate, const CDate& timeOrigin) 44 45 : 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 50 52 } 51 53 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 } 52 66 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 { 56 70 initDate=CDate(*this,yr, mth, d, hr, min, sec) ; 57 71 timeOrigin=initDate; … … 59 73 } 60 74 61 void CCalendar::initializeDate(const StdString 75 void CCalendar::initializeDate(const StdString& dateStr) 62 76 { 63 77 initDate=CDate::FromString(dateStr, *this) ; … … 66 80 } 67 81 68 void CCalendar::initializeDate(const StdString & dateStr, const StdString& timeOriginStr)82 void CCalendar::initializeDate(const StdString& dateStr, const StdString& timeOriginStr) 69 83 { 70 84 initDate=CDate::FromString(dateStr, *this) ; -
XIOS/trunk/src/calendar.hpp
r501 r532 33 33 /// Constructeurs /// 34 34 CCalendar(void); 35 CCalendar(const StdString 36 CCalendar(const StdString 35 CCalendar(const StdString& id) ; 36 CCalendar(const StdString& id, 37 37 int yr, int mth, int d, 38 38 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); 41 41 42 CCalendar(const CCalendar 43 CCalendar(const CCalendar 42 CCalendar(const CCalendar& calendar); // Not implemented yet. 43 CCalendar(const CCalendar* const calendar); // Not implemented yet. 44 44 45 45 public : … … 87 87 //------------------------------------------------------------ 88 88 89 protected: 90 91 //!< Associate the dates to the calendar and check their validity 92 void initializeDate(); 93 94 //------------------------------------------------------------ 95 89 96 private : 90 97 -
XIOS/trunk/src/config/context_attribute.conf
r526 r532 1 1 DECLARE_ENUM5(calendar_type, D360, AllLeap, NoLeap, Julian, Gregorian) 2 DECLARE_ATTRIBUTE( StdString, start_date)3 DECLARE_ATTRIBUTE( StdString, time_origin)2 DECLARE_ATTRIBUTE(CDate, start_date) 3 DECLARE_ATTRIBUTE(CDate, time_origin) 4 4 DECLARE_ATTRIBUTE(StdString, timestep) 5 5 DECLARE_ATTRIBUTE(StdString, output_dir) -
XIOS/trunk/src/date.cpp
r501 r532 11 11 { 12 12 /// ////////////////////// Définitions ////////////////////// /// 13 CDate::CDate( const CCalendar& calendar)14 : relCalendar( calendar)13 CDate::CDate(void) 14 : relCalendar(NULL) 15 15 , year(0), month(1) , day(1) 16 16 , 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 {} 18 24 19 25 CDate::CDate(const CCalendar& calendar, 20 26 int yr, int mth, int d, 21 27 int hr, int min, int sec) 22 : relCalendar( calendar)28 : relCalendar(&calendar) 23 29 , year(yr), month(mth) , day(d) 24 30 , hour(hr), minute(min), second(sec) … … 31 37 } 32 38 33 CDate::CDate(const CDate 34 : relCalendar(date. getRelCalendar()),39 CDate::CDate(const CDate& date) 40 : relCalendar(date.relCalendar), 35 41 year(date.year), month(date.month) , day(date.day), 36 42 hour(date.hour), minute(date.minute), second(date.second) 37 43 { 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 } 43 50 } 44 51 … … 50 57 CDate & CDate::operator=(const CDate & date) 51 58 { 52 // relCalendar = d.getRelCalendar(); << inutile si fonction bien utilisée59 relCalendar = date.relCalendar; 53 60 year = date.year; month = date.month ; day = date.day; 54 61 hour = date.hour; minute = date.minute; second = date.second; … … 103 110 if (c==sep) 104 111 { 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); 109 118 } 110 119 } … … 118 127 CDate::operator Time(void) const // Non vérifiée, pas optimisée ... 119 128 { 129 // This will check that a calendar was correctly associated to the date 130 const CCalendar& c = getRelCalendar(); 131 120 132 // 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()); 131 143 _d.getYear() < getYear(); _d.setYear(_d.getYear()+1)) 132 retvalue += relCalendar.getYearTotalLength(_d);144 retvalue += c.getYearTotalLength(_d); 133 145 return (retvalue); 134 146 } … … 140 152 bool retValue = true; 141 153 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. 143 158 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(); } 146 161 147 162 // 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); } 151 166 152 167 // Vérification de la valeur de l'heure. 153 168 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; } 156 171 157 172 // Vérification de la valeur des minutes. 158 173 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; } 161 176 162 177 // 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; } 166 181 167 182 return retValue; … … 179 194 //---------------------------------------------------------------- 180 195 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 } 189 225 190 226 //---------------------------------------------------------------- … … 195 231 if (this->month == 13) { year++; this->month = 1 ; } 196 232 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(); 197 241 } 198 242 -
XIOS/trunk/src/date.hpp
r501 r532 17 17 18 18 /// 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 20 22 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); 23 26 CDate(const CDate & odate); 24 27 CDate(const CDate * const odate); // Not implemented yet … … 45 48 int getSecond(void) const; 46 49 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; 48 53 49 54 /// Mutateurs /// 50 55 void setYear (int newyear); 51 56 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); 53 64 54 65 void addMonth (int value); 66 67 //!< Set the calendar associated to the date 68 bool setRelCalendar(const CCalendar& relCalendar); 55 69 56 70 /// Autres /// … … 67 81 68 82 /// Propriétés privées /// 69 const CCalendar & relCalendar; // Calendrier lié à la Date.83 const CCalendar* relCalendar; //!< Calendar associated to the date 70 84 int year, month, day, hour, minute, second; // Année, mois, ... 71 85 -
XIOS/trunk/src/date/allleap.cpp
r501 r532 5 5 /// ////////////////////// Définitions ////////////////////// /// 6 6 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 } 10 15 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 } 14 24 15 25 CAllLeapCalendar::CAllLeapCalendar(int yr, int mth, int d, -
XIOS/trunk/src/date/allleap.hpp
r501 r532 18 18 /// Constructeur /// 19 19 // 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); 22 22 CAllLeapCalendar(int yr = 0, int mth = 1, int d = 1, 23 int hr = 0, int min = 0, int sec = 0);24 CAllLeapCalendar(const CAllLeapCalendar 25 CAllLeapCalendar(const CAllLeapCalendar 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. 26 26 27 27 /// Accesseurs /// -
XIOS/trunk/src/date/d360.cpp
r501 r532 5 5 /// ////////////////////// Définitions ////////////////////// /// 6 6 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 } 10 15 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 } 14 24 15 25 CD360Calendar::CD360Calendar(int yr, int mth, int d, -
XIOS/trunk/src/date/d360.hpp
r501 r532 18 18 /// Constructeur /// 19 19 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); 22 22 CD360Calendar(int yr = 0, int mth = 1, int d = 1, 23 23 int hr = 0, int min = 0, int sec = 0); 24 CD360Calendar(const CD360Calendar 25 CD360Calendar(const CD360Calendar 24 CD360Calendar(const CD360Calendar& calendar); // Not implemented yet. 25 CD360Calendar(const CD360Calendar* calendar); // Not implemented yet. 26 26 27 27 /// Accesseurs /// -
XIOS/trunk/src/date/gregorian.cpp
r501 r532 5 5 /// ////////////////////// Définitions ////////////////////// /// 6 6 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 } 10 15 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 } 14 24 15 25 CGregorianCalendar::CGregorianCalendar(int yr, int mth, int d, -
XIOS/trunk/src/date/gregorian.hpp
r501 r532 18 18 /// Constructeur /// 19 19 // 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); 22 22 CGregorianCalendar(int yr = 0, int mth = 1, int d = 1, 23 23 int hr = 0, int min = 0, int sec = 0); 24 CGregorianCalendar(const CGregorianCalendar 25 CGregorianCalendar(const CGregorianCalendar 24 CGregorianCalendar(const CGregorianCalendar& calendar); // Not implemented yet. 25 CGregorianCalendar(const CGregorianCalendar* calendar); // Not implemented yet. 26 26 27 27 /// Accesseurs /// -
XIOS/trunk/src/date/julian.cpp
r501 r532 5 5 /// ////////////////////// Définitions ////////////////////// /// 6 6 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 } 10 15 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 } 14 24 15 25 CJulianCalendar::CJulianCalendar(int yr, int mth, int d, -
XIOS/trunk/src/date/julian.hpp
r501 r532 18 18 /// Constructeur /// 19 19 // 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); 22 22 CJulianCalendar(int yr = 0, int mth = 1, int d = 1, 23 23 int hr = 0, int min = 0, int sec = 0); 24 CJulianCalendar(const CJulianCalendar 25 CJulianCalendar(const CJulianCalendar 24 CJulianCalendar(const CJulianCalendar& calendar); // Not implemented yet. 25 CJulianCalendar(const CJulianCalendar* calendar); // Not implemented yet. 26 26 27 27 /// Accesseurs /// -
XIOS/trunk/src/date/noleap.cpp
r501 r532 6 6 /// ////////////////////// Définitions ////////////////////// /// 7 7 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 } 11 16 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 } 15 25 16 26 CNoLeapCalendar::CNoLeapCalendar(int yr, int mth, int d, -
XIOS/trunk/src/date/noleap.hpp
r501 r532 18 18 /// Constructeur /// 19 19 // 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); 22 22 CNoLeapCalendar(int yr = 0, int mth = 1, int d = 1, 23 23 int hr = 0, int min = 0, int sec = 0); 24 CNoLeapCalendar(const CNoLeapCalendar 25 CNoLeapCalendar(const CNoLeapCalendar 24 CNoLeapCalendar(const CNoLeapCalendar& calendar); // Not implemented yet. 25 CNoLeapCalendar(const CNoLeapCalendar* calendar); // Not implemented yet. 26 26 27 27 /// Accesseurs /// -
XIOS/trunk/src/generate_interface_decl.cpp
r501 r532 19 19 macro(int) 20 20 macro(double) 21 macro(CDate) 21 22 } -
XIOS/trunk/src/generate_interface_impl.hpp
r509 r532 8 8 #include "enum.hpp" 9 9 #include "array_new.hpp" 10 #include "date.hpp" 10 11 11 12 namespace xios … … 15 16 template<> string CInterface::getStrFortranType<double>(void) {return string("REAL") ;} 16 17 template<> string CInterface::getStrFortranType<float>(void) {return string("REAL") ;} 18 template<> string CInterface::getStrFortranType<CDate>(void) {return string("TYPE(txios(date))") ;} 17 19 18 20 template<> string CInterface::getStrFortranKind<int>(void) {return string("") ;} … … 20 22 template<> string CInterface::getStrFortranKind<double>(void) {return string("(KIND=8)") ;} 21 23 template<> string CInterface::getStrFortranKind<float>(void) {return string("(KIND=4)") ;} 24 template<> string CInterface::getStrFortranKind<CDate>(void) {return string("") ;} 22 25 23 26 template<> string CInterface::getStrFortranKindC<int>(void) {return string("(KIND=C_INT)") ;} … … 25 28 template<> string CInterface::getStrFortranKindC<double>(void) {return string("(KIND=C_DOUBLE)") ;} 26 29 template<> string CInterface::getStrFortranKindC<float>(void) {return string("(KIND=C_FLOAT)") ;} 30 template<> string CInterface::getStrFortranKindC<CDate>(void) {return string("") ;} 27 31 28 32 template<> bool CInterface::matchingTypeCFortran<int>(void) { return true ; } … … 30 34 template<> bool CInterface::matchingTypeCFortran<double>(void) { return true; } 31 35 template<> bool CInterface::matchingTypeCFortran<float>(void) { return true; } 36 template<> bool CInterface::matchingTypeCFortran<CDate>(void) { return true; } 32 37 33 38 … … 125 130 // if (!array_copy(domain_hdl->mask.getValue(), mask, extent1, extent2)) 126 131 // 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 } 127 168 128 169 /* … … 256 297 oss<<iendl ; 257 298 } 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 } 258 318 259 319 /* -
XIOS/trunk/src/interface/c_attr/icaxis_attr.cpp
r509 r532 10 10 #include "group_template.hpp" 11 11 #include "icutil.hpp" 12 #include "icdate.hpp" 12 13 #include "timer.hpp" 13 14 #include "node_type.hpp" -
XIOS/trunk/src/interface/c_attr/icaxisgroup_attr.cpp
r509 r532 10 10 #include "group_template.hpp" 11 11 #include "icutil.hpp" 12 #include "icdate.hpp" 12 13 #include "timer.hpp" 13 14 #include "node_type.hpp" -
XIOS/trunk/src/interface/c_attr/iccontext_attr.cpp
r526 r532 10 10 #include "group_template.hpp" 11 11 #include "icutil.hpp" 12 #include "icdate.hpp" 12 13 #include "timer.hpp" 13 14 #include "node_type.hpp" … … 69 70 70 71 71 void cxios_set_context_start_date(context_Ptr context_hdl, c onst char * start_date, int start_date_size)72 void cxios_set_context_start_date(context_Ptr context_hdl, cxios_date start_date_c) 72 73 { 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(); 78 86 } 79 87 80 void cxios_get_context_start_date(context_Ptr context_hdl, c har * start_date, int start_date_size)88 void cxios_get_context_start_date(context_Ptr context_hdl, cxios_date* start_date_c) 81 89 { 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(); 86 99 } 87 100 … … 95 108 96 109 97 void cxios_set_context_time_origin(context_Ptr context_hdl, c onst char * time_origin, int time_origin_size)110 void cxios_set_context_time_origin(context_Ptr context_hdl, cxios_date time_origin_c) 98 111 { 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(); 104 124 } 105 125 106 void cxios_get_context_time_origin(context_Ptr context_hdl, c har * time_origin, int time_origin_size)126 void cxios_get_context_time_origin(context_Ptr context_hdl, cxios_date* time_origin_c) 107 127 { 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(); 112 137 } 113 138 -
XIOS/trunk/src/interface/c_attr/icdomain_attr.cpp
r509 r532 10 10 #include "group_template.hpp" 11 11 #include "icutil.hpp" 12 #include "icdate.hpp" 12 13 #include "timer.hpp" 13 14 #include "node_type.hpp" -
XIOS/trunk/src/interface/c_attr/icdomaingroup_attr.cpp
r509 r532 10 10 #include "group_template.hpp" 11 11 #include "icutil.hpp" 12 #include "icdate.hpp" 12 13 #include "timer.hpp" 13 14 #include "node_type.hpp" -
XIOS/trunk/src/interface/c_attr/icfield_attr.cpp
r509 r532 10 10 #include "group_template.hpp" 11 11 #include "icutil.hpp" 12 #include "icdate.hpp" 12 13 #include "timer.hpp" 13 14 #include "node_type.hpp" -
XIOS/trunk/src/interface/c_attr/icfieldgroup_attr.cpp
r509 r532 10 10 #include "group_template.hpp" 11 11 #include "icutil.hpp" 12 #include "icdate.hpp" 12 13 #include "timer.hpp" 13 14 #include "node_type.hpp" -
XIOS/trunk/src/interface/c_attr/icfile_attr.cpp
r528 r532 10 10 #include "group_template.hpp" 11 11 #include "icutil.hpp" 12 #include "icdate.hpp" 12 13 #include "timer.hpp" 13 14 #include "node_type.hpp" -
XIOS/trunk/src/interface/c_attr/icfilegroup_attr.cpp
r528 r532 10 10 #include "group_template.hpp" 11 11 #include "icutil.hpp" 12 #include "icdate.hpp" 12 13 #include "timer.hpp" 13 14 #include "node_type.hpp" -
XIOS/trunk/src/interface/c_attr/icgrid_attr.cpp
r509 r532 10 10 #include "group_template.hpp" 11 11 #include "icutil.hpp" 12 #include "icdate.hpp" 12 13 #include "timer.hpp" 13 14 #include "node_type.hpp" -
XIOS/trunk/src/interface/c_attr/icgridgroup_attr.cpp
r509 r532 10 10 #include "group_template.hpp" 11 11 #include "icutil.hpp" 12 #include "icdate.hpp" 12 13 #include "timer.hpp" 13 14 #include "node_type.hpp" -
XIOS/trunk/src/interface/c_attr/icvariable_attr.cpp
r527 r532 10 10 #include "group_template.hpp" 11 11 #include "icutil.hpp" 12 #include "icdate.hpp" 12 13 #include "timer.hpp" 13 14 #include "node_type.hpp" -
XIOS/trunk/src/interface/c_attr/icvariablegroup_attr.cpp
r527 r532 10 10 #include "group_template.hpp" 11 11 #include "icutil.hpp" 12 #include "icdate.hpp" 12 13 #include "timer.hpp" 13 14 #include "node_type.hpp" -
XIOS/trunk/src/interface/fortran/idate.F90
r501 r532 6 6 INTEGER(kind = C_INT), PARAMETER :: D360 = 0 , ALLLEAP = 1 , NOLEAP = 2 , JULIAN = 3 , GREGORIAN = 4 7 7 8 TYPE txios(date)9 INTEGER :: year, month, day, hour, minute, second8 TYPE, BIND(C) :: txios(date) 9 INTEGER(kind = C_INT) :: year, month, day, hour, minute, second 10 10 END TYPE txios(date) 11 11 -
XIOS/trunk/src/interface/fortran_attr/axis_interface_attr.F90
r531 r532 2 2 ! * Interface auto generated - do not modify * 3 3 ! * ************************************************************************** * 4 #include "../fortran/xios_fortran_prefix.hpp" 4 5 5 6 MODULE axis_interface_attr -
XIOS/trunk/src/interface/fortran_attr/axisgroup_interface_attr.F90
r531 r532 2 2 ! * Interface auto generated - do not modify * 3 3 ! * ************************************************************************** * 4 #include "../fortran/xios_fortran_prefix.hpp" 4 5 5 6 MODULE axisgroup_interface_attr -
XIOS/trunk/src/interface/fortran_attr/context_interface_attr.F90
r531 r532 2 2 ! * Interface auto generated - do not modify * 3 3 ! * ************************************************************************** * 4 #include "../fortran/xios_fortran_prefix.hpp" 4 5 5 6 MODULE context_interface_attr … … 51 52 52 53 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) 54 55 USE ISO_C_BINDING 56 USE IDATE 55 57 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 58 59 END SUBROUTINE cxios_set_context_start_date 59 60 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) 61 62 USE ISO_C_BINDING 63 USE IDATE 62 64 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 65 66 END SUBROUTINE cxios_get_context_start_date 66 67 … … 72 73 73 74 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) 75 76 USE ISO_C_BINDING 77 USE IDATE 76 78 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 79 80 END SUBROUTINE cxios_set_context_time_origin 80 81 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) 82 83 USE ISO_C_BINDING 84 USE IDATE 83 85 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 86 87 END SUBROUTINE cxios_get_context_time_origin 87 88 -
XIOS/trunk/src/interface/fortran_attr/domain_interface_attr.F90
r531 r532 2 2 ! * Interface auto generated - do not modify * 3 3 ! * ************************************************************************** * 4 #include "../fortran/xios_fortran_prefix.hpp" 4 5 5 6 MODULE domain_interface_attr -
XIOS/trunk/src/interface/fortran_attr/domaingroup_interface_attr.F90
r531 r532 2 2 ! * Interface auto generated - do not modify * 3 3 ! * ************************************************************************** * 4 #include "../fortran/xios_fortran_prefix.hpp" 4 5 5 6 MODULE domaingroup_interface_attr -
XIOS/trunk/src/interface/fortran_attr/field_interface_attr.F90
r531 r532 2 2 ! * Interface auto generated - do not modify * 3 3 ! * ************************************************************************** * 4 #include "../fortran/xios_fortran_prefix.hpp" 4 5 5 6 MODULE field_interface_attr -
XIOS/trunk/src/interface/fortran_attr/fieldgroup_interface_attr.F90
r531 r532 2 2 ! * Interface auto generated - do not modify * 3 3 ! * ************************************************************************** * 4 #include "../fortran/xios_fortran_prefix.hpp" 4 5 5 6 MODULE fieldgroup_interface_attr -
XIOS/trunk/src/interface/fortran_attr/file_interface_attr.F90
r531 r532 2 2 ! * Interface auto generated - do not modify * 3 3 ! * ************************************************************************** * 4 #include "../fortran/xios_fortran_prefix.hpp" 4 5 5 6 MODULE file_interface_attr -
XIOS/trunk/src/interface/fortran_attr/filegroup_interface_attr.F90
r531 r532 2 2 ! * Interface auto generated - do not modify * 3 3 ! * ************************************************************************** * 4 #include "../fortran/xios_fortran_prefix.hpp" 4 5 5 6 MODULE filegroup_interface_attr -
XIOS/trunk/src/interface/fortran_attr/grid_interface_attr.F90
r531 r532 2 2 ! * Interface auto generated - do not modify * 3 3 ! * ************************************************************************** * 4 #include "../fortran/xios_fortran_prefix.hpp" 4 5 5 6 MODULE grid_interface_attr -
XIOS/trunk/src/interface/fortran_attr/gridgroup_interface_attr.F90
r531 r532 2 2 ! * Interface auto generated - do not modify * 3 3 ! * ************************************************************************** * 4 #include "../fortran/xios_fortran_prefix.hpp" 4 5 5 6 MODULE gridgroup_interface_attr -
XIOS/trunk/src/interface/fortran_attr/icontext_attr.F90
r501 r532 19 19 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: calendar_type 20 20 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: output_dir 21 CHARACTER(len = *), OPTIONAL, INTENT(IN) :: start_date22 CHARACTER(len = *), OPTIONAL, INTENT(IN) :: time_origin21 TYPE(txios(date)) , OPTIONAL, INTENT(IN) :: start_date 22 TYPE(txios(date)) , OPTIONAL, INTENT(IN) :: time_origin 23 23 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: timestep 24 24 … … 36 36 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: calendar_type 37 37 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: output_dir 38 CHARACTER(len = *), OPTIONAL, INTENT(IN) :: start_date39 CHARACTER(len = *), OPTIONAL, INTENT(IN) :: time_origin38 TYPE(txios(date)) , OPTIONAL, INTENT(IN) :: start_date 39 TYPE(txios(date)) , OPTIONAL, INTENT(IN) :: time_origin 40 40 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: timestep 41 41 … … 52 52 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: calendar_type_ 53 53 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_ 56 56 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: timestep_ 57 57 … … 65 65 66 66 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_) 68 68 ENDIF 69 69 70 70 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_) 72 72 ENDIF 73 73 … … 88 88 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: calendar_type 89 89 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: output_dir 90 CHARACTER(len = *), OPTIONAL, INTENT(OUT) :: start_date91 CHARACTER(len = *), OPTIONAL, INTENT(OUT) :: time_origin90 TYPE(txios(date)) , OPTIONAL, INTENT(OUT) :: start_date 91 TYPE(txios(date)) , OPTIONAL, INTENT(OUT) :: time_origin 92 92 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: timestep 93 93 … … 105 105 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: calendar_type 106 106 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: output_dir 107 CHARACTER(len = *), OPTIONAL, INTENT(OUT) :: start_date108 CHARACTER(len = *), OPTIONAL, INTENT(OUT) :: time_origin107 TYPE(txios(date)) , OPTIONAL, INTENT(OUT) :: start_date 108 TYPE(txios(date)) , OPTIONAL, INTENT(OUT) :: time_origin 109 109 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: timestep 110 110 … … 121 121 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: calendar_type_ 122 122 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_ 125 125 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: timestep_ 126 126 … … 134 134 135 135 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_) 137 137 ENDIF 138 138 139 139 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_) 141 141 ENDIF 142 142 -
XIOS/trunk/src/interface/fortran_attr/variable_interface_attr.F90
r531 r532 2 2 ! * Interface auto generated - do not modify * 3 3 ! * ************************************************************************** * 4 #include "../fortran/xios_fortran_prefix.hpp" 4 5 5 6 MODULE variable_interface_attr -
XIOS/trunk/src/interface/fortran_attr/variablegroup_interface_attr.F90
r531 r532 2 2 ! * Interface auto generated - do not modify * 3 3 ! * ************************************************************************** * 4 #include "../fortran/xios_fortran_prefix.hpp" 4 5 5 6 MODULE variablegroup_interface_attr -
XIOS/trunk/src/node/context.cpp
r526 r532 74 74 this->calendar = newCalendar; 75 75 calendar_type.fromString(this->calendar->getId()); 76 start_date.setValue(this->calendar->getInitDate() .toString());76 start_date.setValue(this->calendar->getInitDate()); 77 77 } 78 78 … … 87 87 << "Impossible to define a calendar (an attribute is missing)."); 88 88 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 } 102 110 #include "calendar_type.conf" 103 111 #undef DECLARE_CALENDAR -
XIOS/trunk/src/object_template_impl.hpp
r511 r532 335 335 oss<<"#include \"group_template.hpp\""<<iendl ; 336 336 oss<<"#include \"icutil.hpp\""<<iendl ; 337 oss<<"#include \"icdate.hpp\""<<iendl ; 337 338 oss<<"#include \"timer.hpp\""<<iendl ; 338 339 oss<<"#include \"node_type.hpp\""<<iendl ; … … 357 358 oss<<"! * Interface auto generated - do not modify *"<<iendl ; 358 359 oss<<"! * ************************************************************************** *"<<iendl; 360 oss<<"#include \"../fortran/xios_fortran_prefix.hpp\""<<iendl ; 359 361 oss<<iendl ; 360 362 oss<<"MODULE "<<className<<"_interface_attr"<<iendl++ ; -
XIOS/trunk/src/test/test_complete.f90
r501 r532 11 11 CHARACTER(len=*),PARAMETER :: id="client" 12 12 INTEGER :: comm 13 TYPE(xios_date) :: start_date, time_origin 13 14 TYPE(xios_time) :: dtime 14 15 TYPE(xios_context) :: ctx_hdl … … 83 84 CALL xios_set_current_context(ctx_hdl) 84 85 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) 88 91 89 92 CALL xios_set_axis_attr("axis_atm",size=llm ,value=lval) ; … … 171 174 CALL xios_set_current_context(ctx_hdl) 172 175 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) 176 181 177 182 CALL xios_set_axis_attr("axis_srf",size=llm ,value=lval) ; -
XIOS/trunk/src/test/test_xios_interface.f90
r510 r532 12 12 CHARACTER(len=*),PARAMETER :: id="client" 13 13 INTEGER :: comm 14 TYPE(xios_date) :: start_date, time_origin 14 15 TYPE(xios_time) :: dtime 15 16 TYPE(xios_context) :: ctx_hdl … … 96 97 97 98 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) 100 103 101 104 CALL xios_set_axis_attr("axis_atm",size=llm ,value=lval) ; … … 181 184 182 185 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) 185 190 186 191 CALL xios_set_axis_attr("axis_srf",size=llm ,value=lval) ; -
XIOS/trunk/src/type/type_decl.cpp
r501 r532 4 4 #include "type_specialisation.hpp" 5 5 #include <string> ; 6 #include "date.hpp" 6 7 #include "xmlioserver_spl.hpp" 7 8 … … 23 24 template CMessage& operator<< <decl_type> (CMessage& msg, decl_type& type) ; 24 25 25 macro(string) 26 macro(int) 26 macro(string) 27 macro(int) 27 28 macro(double) 28 macro(bool) 29 macro(StdSize) 30 29 macro(bool) 30 macro(StdSize) 31 macro(CDate) 31 32 } -
XIOS/trunk/src/type/type_specialisation.hpp
r501 r532 9 9 #include <string> 10 10 #include <boost/algorithm/string.hpp> 11 #include "date.hpp" 11 12 12 13 namespace xios … … 165 166 return ret ; 166 167 } 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 167 314 // template specialisation for CArray 168 315 /*
Note: See TracChangeset
for help on using the changeset viewer.