Changeset 549
- Timestamp:
- 01/26/15 14:39:26 (10 years ago)
- Location:
- XIOS/trunk
- Files:
-
- 9 added
- 38 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/inputs/COMPLETE/context_atmosphere.xml
r486 r549 1 1 <!-- Context atm --> 2 2 3 <context id="atmopshere" calendar_type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-29 15:00:00">3 <context id="atmopshere"> 4 4 5 5 <field_definition level="1" enabled=".FALSE." default_value="9.96921e+36"> -
XIOS/trunk/inputs/COMPLETE/context_surface.xml
r527 r549 1 1 <!-- Context surface --> 2 2 3 <context id="surface" calendar_type="Julian" start_date="2012-03-01 15:00:00" time_origin="2012-02-29 15:00:00">3 <context id="surface"> 4 4 5 5 <field_definition level="1" enabled=".TRUE." domain_ref="domain_srf" axis_ref="axis_srf" operation="average" freq_op="1ts" default_value="9.96921e+36" prec="4"> -
XIOS/trunk/inputs/Version2/iodef.xml
r542 r549 2 2 <simulation> 3 3 4 <context id="test" calendar_type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-29 15:00:00"> 4 <context id="test"> 5 <calendar type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-29 15:00:00" /> 5 6 6 7 -
XIOS/trunk/inputs/iodef.xml
r527 r549 2 2 <simulation> 3 3 4 <context id="test" calendar_type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-29 15:00:00"> 5 4 <context id="test"> 5 <calendar type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-28 15:00:00 + 1d" /> 6 6 7 7 8 <field_definition level="1" enabled=".FALSE."> -
XIOS/trunk/src/calendar.cpp
r532 r549 12 12 , timeOrigin(*this) 13 13 , currentDate(*this) 14 { 14 {} 15 15 16 16 CCalendar::CCalendar(const StdString& id) … … 19 19 , timeOrigin(*this) 20 20 , currentDate(*this) 21 { 22 21 {} 22 23 23 CCalendar::CCalendar(const StdString& id, 24 int yr, int mth, int d 25 int hr , int min, int sec)24 int yr, int mth, int d, 25 int hr /*= 0*/, int min /*= 0*/, int sec /*= 0*/) 26 26 : CObject(id) 27 27 , initDate(*this) 28 28 , timeOrigin(*this) 29 29 , currentDate(*this) 30 { 31 initializeDate(yr, mth, d, hr, min, sec) 30 { 31 initializeDate(yr, mth, d, hr, min, sec); 32 32 } 33 33 … … 66 66 67 67 void CCalendar::initializeDate(int yr, int mth, int d, 68 int hr , int min, int sec)68 int hr /*= 0*/, int min /*= 0*/, int sec /*= 0*/) 69 69 { 70 initDate =CDate(*this,yr, mth, d, hr, min, sec);71 timeOrigin =initDate;72 currentDate =initDate;70 initDate = CDate(*this, yr, mth, d, hr, min, sec); 71 timeOrigin = initDate; 72 currentDate = initDate; 73 73 } 74 74 75 75 void CCalendar::initializeDate(const StdString& dateStr) 76 { 77 initDate =CDate::FromString(dateStr, *this);78 timeOrigin =initDate;79 currentDate =initDate;76 { 77 initDate = CDate::FromString(dateStr, *this); 78 timeOrigin = initDate; 79 currentDate = initDate; 80 80 } 81 81 82 82 void CCalendar::initializeDate(const StdString& dateStr, const StdString& timeOriginStr) 83 { 84 initDate =CDate::FromString(dateStr, *this);85 timeOrigin =CDate::FromString(timeOriginStr, *this);86 currentDate =initDate;83 { 84 initDate = CDate::FromString(dateStr, *this); 85 timeOrigin = CDate::FromString(timeOriginStr, *this); 86 currentDate = initDate; 87 87 } 88 89 88 90 89 CCalendar::~CCalendar(void) … … 102 101 } 103 102 104 void CCalendar::fromString(const StdString 103 void CCalendar::fromString(const StdString& str) 105 104 { ERROR("CCalendar::fromString(str)", 106 105 << "[ str = " << str << "] Not implemented yet !"); } … … 108 107 //----------------------------------------------------------------- 109 108 110 void CCalendar::setTimeStep(const CDuration & duration) 111 { this->timestep = duration; } 109 void CCalendar::setTimeStep(const CDuration& timestep) 110 { 111 if (timestep.timestep) 112 ERROR("CCalendar::setTimeStep(const CDuration& timestep)", 113 << "Circular definition of the timestep: the timestep cannot refer to itself."); 114 this->timestep = timestep; 115 } 112 116 113 CDate 114 { 115 info(20) << "update step : " << step <<" timestep "<<this->timestep << std::endl;116 117 CDate& CCalendar::update(int step) 118 { 119 info(20) << "update step : " << step << " timestep " << this->timestep << std::endl; 120 return (this->getCurrentDate() = this->getInitDate() + step * this->timestep); 117 121 } 118 122 119 123 //----------------------------------------------------------------- 120 124 121 const CDuration & CCalendar::getTimeStep(void) const { return (this->timestep); } 122 const CDate & CCalendar::getInitDate(void) const { return (this->initDate); } 123 const CDate & CCalendar::getTimeOrigin(void) const { return (this->timeOrigin); } 124 CDate & CCalendar::getCurrentDate(void) { return (this->currentDate); } 125 void CCalendar::setInitDate(const CDate& initDate) 126 { 127 if (&initDate.getRelCalendar() != this) 128 ERROR("CCalendar::setInitDate(const CDate& initDate)", 129 << "The init date cannot be attached to another calendar."); 130 this->initDate = initDate; 131 } 132 133 void CCalendar::setTimeOrigin(const CDate& timeOrigin) 134 { 135 if (&timeOrigin.getRelCalendar() != this) 136 ERROR("CCalendar::setInitDate(const CDate& timeOrigin)", 137 << "The time origin cannot be attached to another calendar."); 138 this->timeOrigin = timeOrigin; 139 } 125 140 126 141 //----------------------------------------------------------------- 127 142 128 int CCalendar::getMonthLength(const CDate & date) const 143 const CDuration& CCalendar::getTimeStep(void) const { return this->timestep; } 144 const CDate& CCalendar::getInitDate(void) const { return this->initDate; } 145 const CDate& CCalendar::getTimeOrigin(void) const { return this->timeOrigin; } 146 CDate& CCalendar::getCurrentDate(void) { return this->currentDate; } 147 148 //----------------------------------------------------------------- 149 150 int CCalendar::getMonthLength(const CDate& date) const 129 151 { // Retourne la durée du mois en jour. 130 131 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};132 return (NoLeapMonthLength[date.getMonth()-1]);152 static const int NoLeapMonthLength[] = 153 { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 154 return NoLeapMonthLength[date.getMonth() - 1]; 133 155 } 134 156 135 StdString CCalendar::getType(void) const { return (StdString(this->getId())); }157 StdString CCalendar::getType(void) const { return StdString(this->getId()); } 136 158 137 int CCalendar::getYearTotalLength(const CDate 159 int CCalendar::getYearTotalLength(const CDate& date) const { return (365 * 86400); } 138 160 139 int CCalendar::getYearLength (void) const { return (12); } 140 int CCalendar::getDayLength (void) const { return (24); } 141 int CCalendar::getHourLength (void) const { return (60); } 142 int CCalendar::getMinuteLength(void) const { return (60); } 161 int CCalendar::getYearLength (void) const { return 12; } 162 int CCalendar::getDayLength (void) const { return 24; } 163 int CCalendar::getHourLength (void) const { return 60; } 164 int CCalendar::getMinuteLength(void) const { return 60; } 165 int CCalendar::getDayLengthInSeconds(void) const { return getDayLength() * getHourLength() * getMinuteLength(); } 143 166 144 int CCalendar::getNbSecond(const CDate & date) const 145 { // Retourne le nombre de secondes écoulées depuis le début de l'année. 146 CDate _d0(date); int nbday = 0; 147 148 for(_d0.setMonth(1); _d0.getMonth() < date.getMonth(); _d0.setMonth(_d0.getMonth()+1)) 149 nbday += getMonthLength(_d0); 150 return ((((nbday + date.getDay()) * getDayLength() + date.getHour()) * getHourLength() 151 + date.getMinute()) * getMinuteLength() + date.getSecond()); 167 StdString CCalendar::getMonthName(int monthId) const 168 { 169 static const StdString MonthNames[] = 170 { "january", "february", "march", "april" , "may", "june", 171 "july", "august", "september", "october", "november", "december" }; 172 return MonthNames[monthId - 1]; 152 173 } 153 174 154 StdString CCalendar::getMonthName(int month_id) const 155 { 156 static const StdString Monthname_str[] = 157 { "january", "february", "march" , "april" , "may" , "june" , 158 "july" , "august" , "september", "october", "november", "december" }; 159 return(Monthname_str[month_id-1]); 160 } 161 162 const StdString CCalendar::getMonthShortName(int month_id) const 163 { StdString value = this->getMonthName(month_id); value.resize(3); return (value); } 175 const StdString CCalendar::getMonthShortName(int monthId) const 176 { StdString value = this->getMonthName(monthId); value.resize(3); return value; } 164 177 165 178 ///---------------------------------------------------------------- -
XIOS/trunk/src/calendar.hpp
r532 r549 33 33 /// Constructeurs /// 34 34 CCalendar(void); 35 CCalendar(const StdString& id) 35 CCalendar(const StdString& id); 36 36 CCalendar(const StdString& id, 37 37 int yr, int mth, int d, … … 49 49 /// Autres /// 50 50 virtual StdString toString(void) const; 51 virtual void fromString(const StdString 51 virtual void fromString(const StdString& str); 52 52 53 53 /// Mutateur /// 54 void setTimeStep(const CDuration & duration); 54 void setTimeStep(const CDuration& timestep); 55 void setInitDate(const CDate& initDate); 56 void setTimeOrigin(const CDate& timeOrigin); 55 57 56 58 /// Traitemants /// 57 CDate 59 CDate& update(int step); 58 60 59 61 /// Accesseurs /// 60 const CDuration 61 const CDate 62 const CDate 63 CDate& getCurrentDate(void);64 62 const CDuration& getTimeStep(void) const; 63 const CDate& getInitDate(void) const; 64 const CDate& getTimeOrigin(void) const; 65 CDate& getCurrentDate(void); 66 65 67 public : 66 68 67 69 //------------------------------------------------------------ 68 virtual int getMonthLength(const CDate & date) const;70 virtual int getMonthLength(const CDate& date) const; 69 71 70 72 virtual StdString getType(void) const; 71 73 72 virtual int getYearTotalLength(const CDate & date) const; // Retourne la durée d'une année en seconde.74 virtual int getYearTotalLength(const CDate& date) const; // Retourne la durée d'une année en seconde. 73 75 74 76 virtual int getYearLength (void) const; // Retourne la durée d'une année en mois. … … 76 78 virtual int getHourLength (void) const; // Retourne la durée d'une heure en minute. 77 79 virtual int getMinuteLength(void) const; // Retourne la durée d'une minute en secondes. 80 //!< Returns the day length expressed in seconds 81 virtual int getDayLengthInSeconds(void) const; 78 82 79 virtual int getNbSecond(const CDate & date) const;80 83 virtual StdString getMonthName(int month_id) const; 81 84 82 85 virtual const StdString getMonthShortName(int month_id) const; 83 void initializeDate(int yr, int mth, int d, int hr = 0, int min = 0, int sec = 0) 84 void initializeDate(const StdString 85 void initializeDate(const StdString & dateStr, const StdString& timeOrigin);86 void initializeDate(int yr, int mth, int d, int hr = 0, int min = 0, int sec = 0); 87 void initializeDate(const StdString& dateStr); 88 void initializeDate(const StdString& dateStr, const StdString& timeOrigin); 86 89 87 90 //------------------------------------------------------------ 88 91 89 92 protected: 90 93 91 94 //!< Associate the dates to the calendar and check their validity 92 95 void initializeDate(); -
XIOS/trunk/src/calendar_util.cpp
r545 r549 5 5 /// ////////////////////// Définitions ////////////////////// /// 6 6 7 CDuration operator*(const double & scal, const CDuration& ddr)7 CDuration operator*(const double& scal, const CDuration& ddr) 8 8 { return (ddr * scal); } 9 9 10 CDuration operator-(const CDuration & ddr , const CDuration& dr)11 { 12 CDuration dur(ddr); 13 dur.year -= dr.year; dur.month -= dr.month 10 CDuration operator-(const CDuration& ddr , const CDuration& dr) 11 { 12 CDuration dur(ddr); 13 dur.year -= dr.year; dur.month -= dr.month; dur.day -= dr.day; 14 14 dur.hour -= dr.hour; dur.minute -= dr.minute; dur.second -= dr.second; dur.timestep -= dr.timestep; 15 15 return (dur); 16 16 } 17 17 18 CDuration operator+(const CDuration & ddr , const CDuration& dr)19 { 20 CDuration dur(ddr); 21 dur.year += dr.year; dur.month += dr.month 18 CDuration operator+(const CDuration& ddr , const CDuration& dr) 19 { 20 CDuration dur(ddr); 21 dur.year += dr.year; dur.month += dr.month; dur.day += dr.day; 22 22 dur.hour += dr.hour; dur.minute += dr.minute; dur.second += dr.second; dur.timestep += dr.timestep; 23 23 return (dur); 24 24 } 25 25 26 CDuration operator*(const CDuration & ddr , const double& scal)26 CDuration operator*(const CDuration& ddr , const double& scal) 27 27 { 28 28 CDuration dur(ddr); … … 32 32 } 33 33 34 CDuration operator-(const CDuration 34 CDuration operator-(const CDuration& ddr) 35 35 { 36 36 CDuration dur(ddr); … … 47 47 //----------------------------------------------------------------- 48 48 49 CDate operator+(const CDate & dt, const CDuration& dr)50 { 51 CDuration drr 49 CDate operator+(const CDate& dt, const CDuration& dr) 50 { 51 CDuration drr(dr); 52 52 int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0; 53 const CCalendar & c = dt.getRelCalendar(); 54 55 drr.timestep=0 ; 56 drr=drr+dr.timestep*dt.getRelCalendar().getTimeStep() ; 57 58 drr.resolve(dt.getRelCalendar()); 53 const CCalendar& c = dt.getRelCalendar(); 54 55 drr.timestep = 0; 56 if (dr.timestep) 57 { 58 if (c.getTimeStep() == NoneDu) 59 ERROR("operator+(const CDate& dt, const CDuration& dr)", 60 << "Impossible to use the timestep before it is set."); 61 drr = drr + dr.timestep * c.getTimeStep(); 62 } 63 64 drr.resolve(c); 59 65 60 66 // Ajustement des minutes par rapport aux secondes. 61 67 second += dt.getSecond() + drr.second; 62 if (second < 0) { minute--; second += c.getMinuteLength(); }63 if (second >= c.getMinuteLength()) { minute 68 if (second < 0) { minute--; second += c.getMinuteLength(); } 69 if (second >= c.getMinuteLength()) { minute++; second -= c.getMinuteLength(); } 64 70 65 71 // Ajustement des heures en fonction des minutes. 66 72 minute += dt.getMinute() + drr.minute; 67 if (minute < 0) { hour 68 if (minute >= c.getHourLength()) { hour 73 if (minute < 0) { hour--; minute += c.getHourLength(); } 74 if (minute >= c.getHourLength()) { hour++; minute -= c.getHourLength(); } 69 75 70 76 // Ajustement des jours en fonction des heures. 71 77 hour += dt.getHour() + drr.hour; 72 if (hour < 0) { drr.day--; hour += c.getDayLength(); }73 if (hour >= c.getDayLength()) { drr.day 78 if (hour < 0) { drr.day--; hour += c.getDayLength(); } 79 if (hour >= c.getDayLength()) { drr.day++; hour -= c.getDayLength(); } 74 80 75 81 // Ajustement des mois en fonction des jours. 76 CDate dtt(dt); 77 drr.day +=dtt.getDay()-1;78 dtt.setDay(1) ;79 80 if ( drr.day >= 0)81 { 82 for(; c.getMonthLength(dtt) <= drr.day; dtt.addMonth 83 { drr.day -= c.getMonthLength(dtt); drr.month += 1; }84 85 day = drr.day +1;86 } 87 else 88 { 89 dtt.addMonth(-1) 90 drr.month -=1;91 for(; c.getMonthLength(dtt) < -drr.day; dtt.addMonth 92 { drr.day +=c.getMonthLength(dtt) ; drr.month-=1; }93 day =c.getMonthLength(dtt)+drr.day+1;94 } 95 82 CDate dtt(dt); 83 drr.day += dtt.getDay() - 1; 84 dtt.setDay(1); 85 86 if (drr.day >= 0) 87 { 88 for(; c.getMonthLength(dtt) <= drr.day; dtt.addMonth(1)) 89 { drr.day -= c.getMonthLength(dtt); drr.month += 1; } 90 91 day = drr.day + 1; 92 } 93 else 94 { 95 dtt.addMonth(-1); 96 drr.month -= 1; 97 for(; c.getMonthLength(dtt) < -drr.day; dtt.addMonth(-1)) 98 { drr.day += c.getMonthLength(dtt); drr.month -= 1; } 99 day = c.getMonthLength(dtt) + drr.day + 1; 100 } 101 96 102 /* 97 103 if (day < 0) { drr.month --; day += c.getMonthLength(dtt); } 98 104 if (day > c.getMonthLength(dtt)) { drr.month ++; day -= c.getMonthLength(dtt); } // << ProblÚme ici 99 105 if (day == 0){ day = c.getMonthLength(dtt); drr.month --; } 100 */ 101 drr.resolve( dt.getRelCalendar());106 */ 107 drr.resolve(c); 102 108 103 109 // Ajustement des années en fonction des mois. 104 110 month += dt.getMonth() + drr.month; 105 if (month < 0) { drr.year--; month += c.getYearLength(); }106 if (month > c.getYearLength()) { drr.year++; month -= c.getYearLength(); }111 if (month < 0) { drr.year--; month += c.getYearLength(); } 112 if (month > c.getYearLength()) { drr.year++; month -= c.getYearLength(); } 107 113 if (month == 0){ month = c.getYearLength(); drr.year--; } 108 114 109 115 year += dt.getYear() + drr.year; 110 116 111 return (CDate( dt.getRelCalendar(), year, month, day, hour, minute, second));112 } 113 114 CDate operator-(const CDate & dt, const CDuration& dr) { return (dt + (-dr)); }115 116 //----------------------------------------------------------------- 117 118 CDuration operator-(const CDate & dt0, const CDate& dt1)117 return (CDate(c, year, month, day, hour, minute, second)); 118 } 119 120 CDate operator-(const CDate& dt, const CDuration& dr) { return (dt + (-dr)); } 121 122 //----------------------------------------------------------------- 123 124 CDuration operator-(const CDate& dt0, const CDate& dt1) 119 125 { 120 126 // TODO :: Vérifier que les deux dates (dt0 et dt1) ont une référence vers le même calendrier. … … 131 137 bool operator==(const CDuration& ddr, const CDuration& dr) 132 138 { 133 return ((ddr.year == dr.year) && (ddr.month == dr.month) && (dr.day == ddr.day)&&134 (ddr.hour == dr.hour) && (ddr.minute == dr.minute) && (dr.second == ddr.second)&&139 return ((ddr.year == dr.year)&& (ddr.month == dr.month) && (dr.day == ddr.day)&& 140 (ddr.hour == dr.hour)&& (ddr.minute == dr.minute)&& (dr.second == ddr.second)&& 135 141 (ddr.timestep == dr.timestep)); 136 142 } … … 144 150 { 145 151 // TODO :: Vérifier que les deux dates (dt0 et dt1) ont une référence vers le même calendrier. 146 return ((dt0.getYear() == dt1.getYear()) && (dt0.getMonth() == dt1.getMonth()) && (dt1.getDay() == dt0.getDay())&&147 (dt0.getHour() == dt1.getHour()) && (dt0.getMinute() == dt1.getMinute())&& (dt1.getSecond() == dt0.getSecond()));152 return ((dt0.getYear() == dt1.getYear())&& (dt0.getMonth() == dt1.getMonth()) && (dt1.getDay() == dt0.getDay())&& 153 (dt0.getHour() == dt1.getHour())&& (dt0.getMinute() == dt1.getMinute())&& (dt1.getSecond() == dt0.getSecond())); 148 154 } 149 155 … … 152 158 // TODO :: Vérifier que les deux dates (dt0 et dt1) ont une référence vers le même calendrier. 153 159 if (dt0.getYear() < dt1.getYear()) 154 { 160 { 155 161 return true; 156 162 } 157 163 else if (dt0.getYear() == dt1.getYear()) 158 { 164 { 159 165 if (dt0.getMonth() < dt1.getMonth()) 160 166 { … … 174 180 } 175 181 else if (dt0.getHour() == dt1.getHour()) 176 { 182 { 177 183 if (dt0.getMinute() < dt1.getMinute()) 178 184 { … … 193 199 //----------------------------------------------------------------- 194 200 195 bool operator!=(const CDate & dt0, const CDate& dt1){ return !(dt1 == dt0); }196 bool operator> (const CDate & dt0, const CDate& dt1){ return (dt1 < dt0); }197 bool operator>=(const CDate & dt0, const CDate& dt1){ return ((dt0 > dt1) || (dt1 == dt0)); }198 bool operator<=(const CDate & dt0, const CDate& dt1){ return ((dt0 < dt1) || (dt1 == dt0)); }201 bool operator!=(const CDate& dt0, const CDate& dt1){ return !(dt1 == dt0); } 202 bool operator> (const CDate& dt0, const CDate& dt1){ return (dt1 < dt0); } 203 bool operator>=(const CDate& dt0, const CDate& dt1){ return ((dt0 > dt1) || (dt1 == dt0)); } 204 bool operator<=(const CDate& dt0, const CDate& dt1){ return ((dt0 < dt1) || (dt1 == dt0)); } 199 205 200 206 ///---------------------------------------------------------------- -
XIOS/trunk/src/calendar_util.hpp
r545 r549 11 11 /// ////////////////////// Déclarations ////////////////////// /// 12 12 13 CDuration operator*(const double & scal, const CDuration& ddr);14 CDuration operator-(const CDuration & ddr , const CDuration& dr);15 CDuration operator+(const CDuration & ddr , const CDuration& dr);16 CDuration operator*(const CDuration & ddr , const double& scal);17 CDuration operator-(const CDuration 13 CDuration operator*(const double& scal, const CDuration& ddr); 14 CDuration operator-(const CDuration& ddr, const CDuration& dr); 15 CDuration operator+(const CDuration& ddr, const CDuration& dr); 16 CDuration operator*(const CDuration& ddr, const double& scal); 17 CDuration operator-(const CDuration& ddr); 18 18 19 CDate operator+(const CDate & dt, const CDuration& dr); // Non testée.20 CDate operator-(const CDate & dt, const CDuration& dr);19 CDate operator+(const CDate& dt, const CDuration& dr); // Non testée. 20 CDate operator-(const CDate& dt, const CDuration& dr); 21 21 22 CDuration operator-(const CDate & dt0, const CDate& dt1);22 CDuration operator-(const CDate& dt0, const CDate& dt1); 23 23 24 24 /// Les opérateurs de comparaison. (Non testés pour le moment) … … 29 29 bool operator< (const CDate& dt0, const CDate& dt1); 30 30 31 bool operator!=(const CDate & dt0, const CDate& dt1);32 bool operator> (const CDate & dt0, const CDate& dt1);33 bool operator>=(const CDate & dt0, const CDate& dt1);34 bool operator<=(const CDate & dt0, const CDate& dt1);31 bool operator!=(const CDate& dt0, const CDate& dt1); 32 bool operator> (const CDate& dt0, const CDate& dt1); 33 bool operator>=(const CDate& dt0, const CDate& dt1); 34 bool operator<=(const CDate& dt0, const CDate& dt1); 35 35 36 36 ///--------------------------------------------------------------- -
XIOS/trunk/src/config/calendar_type.conf
r526 r549 1 1 #ifdef __XMLIO_CAllLeapCalendar__ 2 DECLARE_CALENDAR(AllLeap, calendar_type_attr::AllLeap)2 DECLARE_CALENDAR(AllLeap, AllLeap) 3 3 #endif //__XMLIO_CAllLeapCalendar__ 4 4 5 5 #ifdef __XMLIO_CD360Calendar__ 6 DECLARE_CALENDAR(D360, calendar_type_attr::D360)6 DECLARE_CALENDAR(D360, D360) 7 7 #endif //__XMLIO_CD360Calendar__ 8 8 9 9 #ifdef __XMLIO_CGregorianCalendar__ 10 DECLARE_CALENDAR(Gregorian, calendar_type_attr::Gregorian)10 DECLARE_CALENDAR(Gregorian, Gregorian) 11 11 #endif //__XMLIO_CGregorianCalendar__ 12 12 13 13 #ifdef __XMLIO_CJulianCalendar__ 14 DECLARE_CALENDAR(Julian, calendar_type_attr::Julian)14 DECLARE_CALENDAR(Julian, Julian) 15 15 #endif //__XMLIO_CJulianCalendar__ 16 16 17 17 #ifdef __XMLIO_CNoLeapCalendar__ 18 DECLARE_CALENDAR(NoLeap, calendar_type_attr::NoLeap)18 DECLARE_CALENDAR(NoLeap, NoLeap) 19 19 #endif //__XMLIO_CNoLeapCalendar__ -
XIOS/trunk/src/config/context_attribute.conf
r537 r549 1 DECLARE_ENUM5(calendar_type, D360, AllLeap, NoLeap, Julian, Gregorian)2 DECLARE_ATTRIBUTE(CDate, start_date)3 DECLARE_ATTRIBUTE(CDate, time_origin)4 DECLARE_ATTRIBUTE(CDuration, timestep)5 1 DECLARE_ATTRIBUTE(StdString, output_dir) 6 -
XIOS/trunk/src/config/node_type.conf
r501 r549 27 27 #endif //__XMLIO_CVariable__ 28 28 29 #ifdef __XMLIO_CCalendarWrapper__ 30 DECLARE_NODE(CalendarWrapper, calendarwrapper) 31 #endif //__XMLIO_CCalendarWrapper__ 32 29 33 #ifdef __XMLIO_CContext__ 30 34 DECLARE_NODE_PAR(Context, context) -
XIOS/trunk/src/context_server.cpp
r511 r549 25 25 CContextServer::CContextServer(CContext* parent,MPI_Comm intraComm_,MPI_Comm interComm_) 26 26 { 27 context=parent 28 intraComm=intraComm_ 29 MPI_Comm_size(intraComm,&intraCommSize) 30 MPI_Comm_rank(intraComm,&intraCommRank) 31 interComm=interComm_ 32 int flag 33 MPI_Comm_test_inter(interComm,&flag) 27 context=parent; 28 intraComm=intraComm_; 29 MPI_Comm_size(intraComm,&intraCommSize); 30 MPI_Comm_rank(intraComm,&intraCommRank); 31 interComm=interComm_; 32 int flag; 33 MPI_Comm_test_inter(interComm,&flag); 34 34 if (flag) MPI_Comm_remote_size(interComm,&commSize); 35 else MPI_Comm_size(interComm,&commSize) 36 currentTimeLine=0 37 scheduled=false 38 finished=false 39 40 boost::hash<string> hashString 41 hashId=hashString(context->getId()) 35 else MPI_Comm_size(interComm,&commSize); 36 currentTimeLine=0; 37 scheduled=false; 38 finished=false; 39 40 boost::hash<string> hashString; 41 hashId=hashString(context->getId()); 42 42 43 43 } 44 44 void CContextServer::setPendingEvent(void) 45 45 { 46 pendingEvent=true 46 pendingEvent=true; 47 47 } 48 48 49 49 bool CContextServer::hasPendingEvent(void) 50 50 { 51 return pendingEvent 51 return pendingEvent; 52 52 } 53 53 54 54 bool CContextServer::eventLoop(void) 55 55 { 56 listen() 57 checkPendingRequest() 58 processEvents() 59 return finished 56 listen(); 57 checkPendingRequest(); 58 processEvents(); 59 return finished; 60 60 } 61 61 … … 63 63 { 64 64 int rank; 65 int flag 66 int count 67 char * addr 65 int flag; 66 int count; 67 char * addr; 68 68 MPI_Status status; 69 69 map<int,CServerBuffer*>::iterator it; … … 73 73 if (pendingRequest.find(rank)==pendingRequest.end()) 74 74 { 75 traceOff() 75 traceOff(); 76 76 MPI_Iprobe(rank,20,interComm,&flag,&status); 77 traceOn() 77 traceOn(); 78 78 if (flag==true) 79 79 { 80 it=buffers.find(rank) 80 it=buffers.find(rank); 81 81 if (it==buffers.end()) 82 82 { … … 84 84 MPI_Recv(&buffSize, 1, MPI_LONG, rank, 20, interComm, &status); 85 85 mapBufferSize_.insert(std::make_pair(rank, buffSize)); 86 it=(buffers.insert(pair<int,CServerBuffer*>(rank,new CServerBuffer(buffSize)))).first 86 it=(buffers.insert(pair<int,CServerBuffer*>(rank,new CServerBuffer(buffSize)))).first; 87 87 } 88 88 else 89 89 { 90 MPI_Get_count(&status,MPI_CHAR,&count) 90 MPI_Get_count(&status,MPI_CHAR,&count); 91 91 if (it->second->isBufferFree(count)) 92 92 { 93 addr=(char*)it->second->getBuffer(count) 94 MPI_Irecv(addr,count,MPI_CHAR,rank,20,interComm,&pendingRequest[rank]) 95 bufferRequest[rank]=addr 93 addr=(char*)it->second->getBuffer(count); 94 MPI_Irecv(addr,count,MPI_CHAR,rank,20,interComm,&pendingRequest[rank]); 95 bufferRequest[rank]=addr; 96 96 } 97 97 } … … 104 104 { 105 105 map<int,MPI_Request>::iterator it; 106 list<int> recvRequest 106 list<int> recvRequest; 107 107 list<int>::iterator itRecv; 108 int rank 109 int flag 110 int count 111 MPI_Status status 108 int rank; 109 int flag; 110 int count; 111 MPI_Status status; 112 112 113 113 for(it=pendingRequest.begin();it!=pendingRequest.end();it++) 114 114 { 115 rank=it->first 116 traceOff() 117 MPI_Test(& it->second, &flag, &status) 118 traceOn() 115 rank=it->first; 116 traceOff(); 117 MPI_Test(& it->second, &flag, &status); 118 traceOn(); 119 119 if (flag==true) 120 120 { 121 recvRequest.push_back(rank) 122 MPI_Get_count(&status,MPI_CHAR,&count) 123 processRequest(rank,bufferRequest[rank],count) 121 recvRequest.push_back(rank); 122 MPI_Get_count(&status,MPI_CHAR,&count); 123 processRequest(rank,bufferRequest[rank],count); 124 124 } 125 125 } … … 127 127 for(itRecv=recvRequest.begin();itRecv!=recvRequest.end();itRecv++) 128 128 { 129 pendingRequest.erase(*itRecv) 130 bufferRequest.erase(*itRecv) 129 pendingRequest.erase(*itRecv); 130 bufferRequest.erase(*itRecv); 131 131 } 132 132 } … … 135 135 { 136 136 137 CBufferIn buffer(buff,count) 138 char* startBuffer,endBuffer 139 int size, offset 140 size_t timeLine 141 map<size_t,CEventServer*>::iterator it 137 CBufferIn buffer(buff,count); 138 char* startBuffer,endBuffer; 139 int size, offset; 140 size_t timeLine; 141 map<size_t,CEventServer*>::iterator it; 142 142 143 143 while(count>0) 144 144 { 145 char* startBuffer=(char*)buffer.ptr() 146 CBufferIn newBuffer(startBuffer,buffer.remain()) 147 newBuffer>>size>>timeLine 148 149 it=events.find(timeLine) 150 if (it==events.end()) it=events.insert(pair<int,CEventServer*>(timeLine,new CEventServer)).first 151 it->second->push(rank,buffers[rank],startBuffer,size) 152 153 buffer.advance(size) 154 count=buffer.remain() 145 char* startBuffer=(char*)buffer.ptr(); 146 CBufferIn newBuffer(startBuffer,buffer.remain()); 147 newBuffer>>size>>timeLine; 148 149 it=events.find(timeLine); 150 if (it==events.end()) it=events.insert(pair<int,CEventServer*>(timeLine,new CEventServer)).first; 151 it->second->push(rank,buffers[rank],startBuffer,size); 152 153 buffer.advance(size); 154 count=buffer.remain(); 155 155 } 156 156 … … 159 159 void CContextServer::processEvents(void) 160 160 { 161 map<size_t,CEventServer*>::iterator it 162 CEventServer* event 163 164 it=events.find(currentTimeLine) 161 map<size_t,CEventServer*>::iterator it; 162 CEventServer* event; 163 164 it=events.find(currentTimeLine); 165 165 if (it!=events.end()) 166 166 { 167 event=it->second 167 event=it->second; 168 168 169 169 if (event->isFull()) … … 171 171 if (!scheduled && !CXios::isServer) 172 172 { 173 CServer::eventScheduler->registerEvent(currentTimeLine,hashId) 174 scheduled=true 173 CServer::eventScheduler->registerEvent(currentTimeLine,hashId); 174 scheduled=true; 175 175 } 176 176 else if (CXios::isServer || CServer::eventScheduler->queryEvent(currentTimeLine,hashId) ) 177 177 { 178 CTimer::get("Process events").resume() 179 dispatchEvent(*event) 180 CTimer::get("Process events").suspend() 181 pendingEvent=false 182 delete event 183 events.erase(it) 184 currentTimeLine++ 185 scheduled = false 178 CTimer::get("Process events").resume(); 179 dispatchEvent(*event); 180 CTimer::get("Process events").suspend(); 181 pendingEvent=false; 182 delete event; 183 events.erase(it); 184 currentTimeLine++; 185 scheduled = false; 186 186 } 187 187 } … … 191 191 CContextServer::~CContextServer() 192 192 { 193 map<int,CServerBuffer*>::iterator it 194 for(it=buffers.begin();it!=buffers.end();++it) delete it->second 193 map<int,CServerBuffer*>::iterator it; 194 for(it=buffers.begin();it!=buffers.end();++it) delete it->second; 195 195 } 196 196 … … 198 198 void CContextServer::dispatchEvent(CEventServer& event) 199 199 { 200 string contextName 201 string buff 202 int MsgSize 203 int rank 204 list<CEventServer::SSubEvent>::iterator it 205 CContext::setCurrent(context->getId()) 200 string contextName; 201 string buff; 202 int MsgSize; 203 int rank; 204 list<CEventServer::SSubEvent>::iterator it; 205 CContext::setCurrent(context->getId()); 206 206 207 207 if (event.classId==CContext::GetType() && event.type==CContext::EVENT_ID_CONTEXT_FINALIZE) 208 208 { 209 info(20)<<"Server Side context <"<<context->getId()<<"> finalized"<<endl 209 info(20)<<"Server Side context <"<<context->getId()<<"> finalized"<<endl; 210 210 std::map<int, StdSize>::const_iterator itbMap = mapBufferSize_.begin(), 211 211 iteMap = mapBufferSize_.end(), itMap; … … 217 217 totalBuf += itMap->second; 218 218 } 219 context->finalize() ; 220 finished=true ; 221 report(0)<< " Memory report : Context <"<<context->getId()<<"> : server side : total memory used for buffer "<<totalBuf<<" bytes"<<endl ; 222 } 223 else if (event.classId==CContext::GetType()) CContext::dispatchEvent(event) ; 224 else if (event.classId==CContextGroup::GetType()) CContextGroup::dispatchEvent(event) ; 225 else if (event.classId==CDomain::GetType()) CDomain::dispatchEvent(event) ; 226 else if (event.classId==CDomainGroup::GetType()) CDomainGroup::dispatchEvent(event) ; 227 else if (event.classId==CAxis::GetType()) CAxis::dispatchEvent(event) ; 228 else if (event.classId==CAxisGroup::GetType()) CAxisGroup::dispatchEvent(event) ; 229 else if (event.classId==CGrid::GetType()) CGrid::dispatchEvent(event) ; 230 else if (event.classId==CGridGroup::GetType()) CGridGroup::dispatchEvent(event) ; 231 else if (event.classId==CField::GetType()) CField::dispatchEvent(event) ; 232 else if (event.classId==CFieldGroup::GetType()) CFieldGroup::dispatchEvent(event) ; 233 else if (event.classId==CFile::GetType()) CFile::dispatchEvent(event) ; 234 else if (event.classId==CFileGroup::GetType()) CFileGroup::dispatchEvent(event) ; 235 else if (event.classId==CVariable::GetType()) CVariable::dispatchEvent(event) ; 219 context->finalize(); 220 finished=true; 221 report(0)<< " Memory report : Context <"<<context->getId()<<"> : server side : total memory used for buffer "<<totalBuf<<" bytes"<<endl; 222 } 223 else if (event.classId==CContext::GetType()) CContext::dispatchEvent(event); 224 else if (event.classId==CContextGroup::GetType()) CContextGroup::dispatchEvent(event); 225 else if (event.classId==CCalendarWrapper::GetType()) CCalendarWrapper::dispatchEvent(event); 226 else if (event.classId==CDomain::GetType()) CDomain::dispatchEvent(event); 227 else if (event.classId==CDomainGroup::GetType()) CDomainGroup::dispatchEvent(event); 228 else if (event.classId==CAxis::GetType()) CAxis::dispatchEvent(event); 229 else if (event.classId==CAxisGroup::GetType()) CAxisGroup::dispatchEvent(event); 230 else if (event.classId==CGrid::GetType()) CGrid::dispatchEvent(event); 231 else if (event.classId==CGridGroup::GetType()) CGridGroup::dispatchEvent(event); 232 else if (event.classId==CField::GetType()) CField::dispatchEvent(event); 233 else if (event.classId==CFieldGroup::GetType()) CFieldGroup::dispatchEvent(event); 234 else if (event.classId==CFile::GetType()) CFile::dispatchEvent(event); 235 else if (event.classId==CFileGroup::GetType()) CFileGroup::dispatchEvent(event); 236 else if (event.classId==CVariable::GetType()) CVariable::dispatchEvent(event); 236 237 else 237 238 { 238 ERROR("void CContextServer::dispatchEvent(CEventServer& event)",<<" Bad event class Id"<<endl) 239 ERROR("void CContextServer::dispatchEvent(CEventServer& event)",<<" Bad event class Id"<<endl); 239 240 } 240 241 } -
XIOS/trunk/src/date.cpp
r544 r549 2 2 #include "calendar.hpp" 3 3 #include "calendar_type.hpp" 4 #include "calendar_util.hpp" 4 5 #include <boost/date_time/gregorian/gregorian.hpp> 5 6 #include <boost/date_time/posix_time/posix_time.hpp> 6 7 7 using namespace boost::posix_time 8 using namespace boost::gregorian 8 using namespace boost::posix_time; 9 using namespace boost::gregorian; 9 10 10 11 namespace xios … … 12 13 /// ////////////////////// Définitions ////////////////////// /// 13 14 CDate::CDate(void) 14 : relCalendar(NULL) 15 , year(0), month(1) , day(1) 15 : relCalendar(NULL) 16 , year(0), month(1), day(1) 17 , hour(0), minute(0), second(0) 18 {} 19 20 CDate::CDate(const CCalendar& calendar) 21 : relCalendar(&calendar) 22 , year(0), month(1), day(1) 16 23 , hour(0), minute(0), second(0) 17 24 {} 18 25 19 CDate::CDate(const CCalendar& calendar)20 : relCalendar(&calendar)21 , year(0), month(1) , day(1)22 , hour(0), minute(0), second(0)23 {}24 25 26 CDate::CDate(const CCalendar& calendar, 26 27 int yr, int mth, int d, 27 28 int hr, int min, int sec) 28 29 : relCalendar(&calendar) 29 , year(yr), month(mth) ,day(d)30 , year(yr), month(mth), day(d) 30 31 , hour(hr), minute(min), second(sec) 31 32 { 32 if (!this->checkDate())33 if (!this->checkDate()) 33 34 { 34 35 DEBUG(<< "La date initialisée a été modifiée " … … 38 39 39 40 CDate::CDate(const CDate& date) 40 : relCalendar(date.relCalendar),41 year(date.year), month(date.month) , day(date.day),42 41 : relCalendar(date.relCalendar) 42 , year(date.year), month(date.month), day(date.day) 43 , hour(date.hour), minute(date.minute), second(date.second) 43 44 { 44 45 // Delay the verification until we get a calendar we can compare the date to … … 55 56 ///--------------------------------------------------------------- 56 57 57 CDate & CDate::operator=(const CDate& date)58 CDate& CDate::operator=(const CDate& date) 58 59 { 59 60 relCalendar = date.relCalendar; 60 year = date.year; month = date.month 61 year = date.year; month = date.month; day = date.day; 61 62 hour = date.hour; minute = date.minute; second = date.second; 62 63 return (*this); 63 64 } 64 65 65 StdOStream & operator<<(StdOStream & out, const CDate & date) 66 { 67 std::streamsize s ; 68 char c ; 69 70 71 int width=4 ; 72 double maxSize=10000 ; 73 while(date.year>=maxSize) 74 { 75 maxSize*=10 ; 76 width++ ; 77 } 78 s = out.width (width); c = out.fill ('0') ; out << date.year << '-'; 79 80 s = out.width (2); c = out.fill ('0') ; out << date.month << '-'; 81 s = out.width (2); c = out.fill ('0') ; out << date.day << ' '; 82 s = out.width (2); c = out.fill ('0') ; out << date.hour << ':'; 83 s = out.width (2); c = out.fill ('0') ; out << date.minute << ':'; 84 s = out.width (2); c = out.fill ('0') ; out << date.second ; 85 86 return (out); 87 } 88 89 StdIStream & operator>>(StdIStream & in, CDate & date) // Non testée. 66 StdOStream& operator<<(StdOStream& out, const CDate& date) 67 { 68 std::streamsize s; 69 char c; 70 71 int width=4; 72 double maxSize=10000; 73 while (date.year>=maxSize) 74 { 75 maxSize*=10; 76 width++; 77 } 78 s = out.width(width); c = out.fill('0'); out << date.year << '-'; 79 80 s = out.width(2); c = out.fill('0'); out << date.month << '-'; 81 s = out.width(2); c = out.fill('0'); out << date.day << ' '; 82 s = out.width(2); c = out.fill('0'); out << date.hour << ':'; 83 s = out.width(2); c = out.fill('0'); out << date.minute << ':'; 84 s = out.width(2); c = out.fill('0'); out << date.second; 85 86 return out; 87 } 88 89 StdIStream& operator>>(StdIStream& in, CDate& date) // Non testée. 90 90 { 91 91 char sep = '-'; // Le caractÚre c est utilisé pour "recueillir" les séparateurs "/" et ":". 92 char c ; 93 94 in >> date.year >> c ; 95 if (c==sep) 92 char c; 93 94 // Default initialize the date 95 date.year = 0; 96 date.month = 1; 97 date.day = 1; 98 date.hour = 0; 99 date.minute = 0; 100 date.second = 0; 101 102 in >> date.year >> c; 103 if (c == sep) 96 104 { 97 in >> date.month >> c 98 if (c ==sep)105 in >> date.month >> c; 106 if (c == sep) 99 107 { 100 in >> date.day 101 c =in.get();102 sep =' ';103 if (c ==sep)108 in >> date.day; 109 c = in.get(); 110 sep = ' '; 111 if (c == sep) 104 112 { 105 in >> date.hour >> c 106 sep =':';107 if (c ==sep)113 in >> date.hour >> c; 114 sep = ':'; 115 if (c == sep) 108 116 { 109 117 in>>date.minute >> c; 110 if (c ==sep)118 if (c == sep) 111 119 { 112 120 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); 121 in >> c; 118 122 } 119 123 } … … 121 125 } 122 126 } 123 ERROR("StdIStream & operator >> (StdIStream & in, CDate & date)",<<"Bad date format or not conform to calendar" ); 124 return (in); 127 128 // Delay the verification until we get a calendar we can compare the date to 129 if (date.relCalendar && !date.checkDate()) 130 ERROR("StdIStream& operator >> (StdIStream& in, CDate& date)", 131 << "Bad date format or not conform to calendar"); 132 133 if (c == '+') // We will be adding a duration to the date 134 { 135 CDuration dur; 136 in >> dur; 137 date = date + dur; 138 } 139 else if (!in.eof()) 140 ERROR("StdIStream& operator >> (StdIStream& in, CDate& date)", 141 << "Invalid date format: unexpected trailing character(s)"); 142 143 return in; 125 144 } 126 145 127 146 CDate::operator Time(void) const // Non vérifiée, pas optimisée ... 128 147 { 129 // This will check that a calendar was correctly associated to the date 130 const CCalendar& c = getRelCalendar(); 131 132 // Todo : Tester si la date courante est supérieure à la date initiale. 133 Time retvalue = - c.getNbSecond(c.getTimeOrigin()) 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()); 143 _d.getYear() < getYear(); _d.setYear(_d.getYear()+1)) 144 retvalue += c.getYearTotalLength(_d); 145 return (retvalue); 148 // This will check that a calendar was correctly associated to the date 149 const CCalendar& c = getRelCalendar(); 150 151 // Todo : Tester si la date courante est supérieure à la date initiale. 152 Time retvalue = getSecondOfYear() - c.getTimeOrigin().getSecondOfYear(); 153 154 if ((c.getId().compare("D360") == 0) || 155 (c.getId().compare("AllLeap") == 0) || 156 (c.getId().compare("NoLeap") == 0)) 157 return (retvalue + (getYear() - c.getTimeOrigin().getYear()) 158 * c.getYearTotalLength(*this)); 159 160 for (CDate _d(c.getTimeOrigin()); _d.getYear() < getYear(); _d.setYear(_d.getYear() + 1)) 161 retvalue += c.getYearTotalLength(_d); 162 163 return retvalue; 146 164 } 147 165 … … 150 168 bool CDate::checkDate(void) 151 169 { 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 170 bool retValue = true; 171 172 // This will check that a calendar was correctly associated to the date 173 const CCalendar& c = getRelCalendar(); 174 175 // Vérification de la valeur du mois. 176 if (month < 1) { retValue = false; month = 1; } 177 if (month > c.getYearLength()) 178 { retValue = false; month = c.getYearLength(); } 179 180 // Vérification de la valeur du jour. 181 if (day < 1) { retValue = false; day = 1; } 182 if (day > c.getMonthLength(*this)) 183 { retValue = false; day = c.getMonthLength(*this); } 184 185 // Vérification de la valeur de l'heure. 186 if (hour < 0) { retValue = false; hour = 0; } 187 if (hour >= c.getDayLength()) 188 { retValue = false; hour = c.getDayLength() - 1; } 189 190 // Vérification de la valeur des minutes. 191 if (minute < 0) { retValue = false; minute = 0; } 192 if (minute >= c.getHourLength()) 193 { retValue = false; minute = c.getHourLength() - 1; } 194 195 // Vérification de la valeur des secondes. 196 if (second < 0) { retValue = false; second = 0; } 197 if (second >= c.getMinuteLength()) 198 { retValue = false; second = c.getMinuteLength() - 1; } 199 200 return retValue; 183 201 } 184 202 … … 207 225 //---------------------------------------------------------------- 208 226 227 /*! 228 Get the number of seconds since the beginning of the year. 229 \return the number of seconds since the beginning of the year. 230 */ 231 int CDate::getSecondOfYear() const 232 { 233 CDate yearStart(*this); 234 const CCalendar& c = getRelCalendar(); 235 int nbDay = 0; 236 237 for (yearStart.setMonth(1); yearStart.getMonth() < getMonth(); yearStart.setMonth(yearStart.getMonth() + 1)) 238 nbDay += c.getMonthLength(yearStart); 239 240 return ((((nbDay + getDay() - 1) * c.getDayLength() + getHour()) * c.getHourLength() 241 + getMinute()) * c.getMinuteLength() + getSecond()); 242 } 243 244 /*! 245 Get the number of days (expressed as a real number) since the beginning of the year. 246 \return the number of days (expressed as a real number) since the beginning of the year. 247 */ 248 double CDate::getDayOfYear() const 249 { 250 return double(getSecondOfYear()) / getRelCalendar().getDayLengthInSeconds(); 251 } 252 253 /*! 254 Get the fraction of the current year as a real number between 0 and 1. 255 \return the fraction of the current year. 256 */ 257 double CDate::getFractionOfYear() const 258 { 259 return double(getSecondOfYear()) / getRelCalendar().getYearTotalLength(*this); 260 } 261 262 /*! 263 Get the number of seconds since the beginning of the day. 264 \return the number of seconds since the beginning of the day. 265 */ 266 int CDate::getSecondOfDay() const 267 { 268 const CCalendar& c = getRelCalendar(); 269 return ((getHour() * c.getHourLength() + getMinute()) * c.getMinuteLength() + getSecond()); 270 } 271 272 /*! 273 Get the fraction of the current day as a real number between 0 and 1. 274 \return the fraction of the current day. 275 */ 276 double CDate::getFractionOfDay() const 277 { 278 return double(getSecondOfDay()) / getRelCalendar().getDayLengthInSeconds(); 279 } 280 281 //---------------------------------------------------------------- 282 209 283 void CDate::setYear (int newyear) { this->year = newyear; } 210 284 void CDate::setMonth (int newmonth) { this->month = newmonth; } … … 226 300 //---------------------------------------------------------------- 227 301 228 void CDate::addMonth 302 void CDate::addMonth(int value) 229 303 {// Value doit être égale à 1 ou -1. 230 231 if (this->month == 13) { year++; this->month = 1; }232 if (this->month == 0 ){ year--; this->month = 12; }304 this->month += value; 305 if (this->month == 13) { year++; this->month = 1; } 306 if (this->month == 0) { year--; this->month = 12; } 233 307 } 234 308 … … 243 317 //---------------------------------------------------------------- 244 318 245 CDate CDate::FromString(const StdString & str, const CCalendar& calendar)246 { 247 248 249 250 251 } 252 253 //---------------------------------------------------------------- 254 319 CDate CDate::FromString(const StdString& str, const CCalendar& calendar) 320 { 321 CDate dt(calendar); 322 StdIStringStream iss(str); 323 iss >> dt; 324 return dt; 325 } 326 327 //---------------------------------------------------------------- 328 255 329 StdString CDate::getStryyyymmdd(void) const 256 { 257 std::streamsize s ; 258 char c ; 259 260 ostringstream oss ; 261 262 s = oss.width (4); c = oss.fill ('0') ; oss << year ; 263 s = oss.width (2); c = oss.fill ('0') ; oss << month; 264 s = oss.width (2); c = oss.fill ('0') ; oss << day ; 265 266 return oss.str(); 267 } 268 330 { 331 std::streamsize s; 332 char c; 333 334 ostringstream oss; 335 336 s = oss.width(4); c = oss.fill('0'); oss << year; 337 s = oss.width(2); c = oss.fill('0'); oss << month; 338 s = oss.width(2); c = oss.fill('0'); oss << day; 339 340 return oss.str(); 341 } 269 342 270 343 string CDate::getStr(const string& str) const 271 344 { 272 ostringstream oss 345 ostringstream oss; 273 346 int level; 274 275 level=0 347 348 level=0; 276 349 for(string::const_iterator it=str.begin();it!=str.end();++it) 277 350 { 278 351 if (level==0) 279 352 { 280 if (*it=='%') level++ 281 else oss<<*it 353 if (*it=='%') level++; 354 else oss<<*it; 282 355 } 283 356 else if (level==1) … … 286 359 { 287 360 case 'y' : 288 oss.width (4); oss.fill ('0') ; oss << year;289 level=0 290 break 361 oss.width(4); oss.fill('0'); oss << year; 362 level=0; 363 break; 291 364 case 'm' : // month or minute 292 level++ 293 break 365 level++; 366 break; 294 367 case 'd' : 295 oss.width (2); oss.fill ('0') ; oss << day;296 level=0; 297 break 368 oss.width(2); oss.fill('0'); oss << day; 369 level=0; 370 break; 298 371 case 'h' : 299 oss.width (2); oss.fill ('0') ; oss << hour;300 level=0; 301 break 372 oss.width(2); oss.fill('0'); oss << hour; 373 level=0; 374 break; 302 375 case 's' : 303 oss.width (2); oss.fill ('0') ; oss << second ; 304 level=0 ; 376 oss.width(2); oss.fill('0'); oss << second; 377 level=0; 378 break; 379 case 'S' : // seconds since time origin 380 oss.width(0); oss << Time(*this); 381 level=0; 382 break; 383 case 'D' : // days since time origin 384 oss.width(0); oss << Time(*this) / getRelCalendar().getDayLengthInSeconds(); 385 level=0; 305 386 break; 306 387 default : 307 oss<<'%'<<*it 308 level=0 388 oss<<'%'<<*it; 389 level=0; 309 390 } 310 391 } … … 314 395 { 315 396 case 'o' : // month 316 oss.width (2); oss.fill ('0') ; oss << month;317 level=0 318 break 397 oss.width(2); oss.fill('0'); oss << month; 398 level=0; 399 break; 319 400 case 'i' : //minute 320 oss.width (2); oss.fill ('0') ; oss << minute;321 level=0 322 break 401 oss.width(2); oss.fill('0'); oss << minute; 402 level=0; 403 break; 323 404 default : 324 oss<<"%m"<<*it 325 level=0 405 oss<<"%m"<<*it; 406 level=0; 326 407 } 327 408 } … … 329 410 return oss.str(); 330 411 } 331 412 332 413 StdString CDate::toString(void) const 333 { 334 335 oss << (*this);336 return (oss.str());414 { 415 StdOStringStream oss; 416 oss << *this; 417 return oss.str(); 337 418 } 338 419 -
XIOS/trunk/src/date.hpp
r544 r549 20 20 CDate(void); 21 21 //!< Create an empty date associated to the specified calendar 22 CDate(const CCalendar 22 CDate(const CCalendar& cal); 23 23 //!< Create a date associated to the specified calendar 24 CDate(const CCalendar 25 26 CDate(const CDate 27 CDate(const CDate 24 CDate(const CCalendar& cal, int yr, int mth, int d, 25 int hr = 0, int min = 0, int sec = 0); 26 CDate(const CDate& odate); 27 CDate(const CDate* const odate); // Not implemented yet 28 28 29 29 /// Destructeur /// … … 31 31 32 32 /// Opérateurs /// 33 CDate & operator=(const CDate& date);34 friend StdOStream & operator<<(StdOStream & out, const CDate& date);35 friend StdIStream & operator>>(StdIStream & in, CDate& date); // Non testée.33 CDate& operator=(const CDate& date); 34 friend StdOStream& operator<<(StdOStream& out, const CDate& date); 35 friend StdIStream& operator>>(StdIStream& in, CDate& date); // Non testée. 36 36 37 37 //!< Return the number of seconds since the time origin fixed when creating the calendar … … 52 52 const CCalendar& getRelCalendar(void) const; 53 53 bool hasRelCalendar(void) const; 54 55 //!< Get the number of seconds since the beginning of the year 56 int getSecondOfYear() const; 57 //!< Get the number of days (expressed as a real number) since the beginning of the year 58 double getDayOfYear() const; 59 //!< Get the fraction of the current year as a real number between 0 and 1 60 double getFractionOfYear() const; 61 //!< Get the number of seconds since the beginning of the day 62 int getSecondOfDay() const; 63 //!< Get the fraction of the current day as a real number between 0 and 1 64 double getFractionOfDay() const; 54 65 55 66 /// Mutateurs /// … … 77 88 public : /* static */ 78 89 79 static CDate FromString(const StdString & str, const CCalendar& calendar);90 static CDate FromString(const StdString& str, const CCalendar& calendar); 80 91 81 92 private : -
XIOS/trunk/src/date/d360.hpp
r532 r549 17 17 18 18 /// Constructeur /// 19 CD360Calendar(void); // Not implemented yet.19 //CD360Calendar(void); // Not implemented yet. 20 20 CD360Calendar(const CDate& startDate); 21 21 CD360Calendar(const CDate& startDate, const CDate& timeOrigin); -
XIOS/trunk/src/generate_fortran_interface.cpp
r531 r549 10 10 int main (int argc, char ** argv, char ** UNUSED (env)) 11 11 { 12 // string path="./src/attr_interface/" ; 13 string path="./interface/" ; 14 15 CContext* context=CContext::create("interface") ; 16 CAxis axis ; 17 CAxisGroup axisgroup ; 12 // string path="./src/attr_interface/"; 13 string path="./interface/"; 14 15 CContext* context=CContext::create("interface"); 16 CCalendarWrapper calendarWrapper; 17 CAxis axis; 18 CAxisGroup axisgroup; 18 19 CField field; 19 CFieldGroup fieldgroup 20 CFieldGroup fieldgroup; 20 21 CVariable variable; 21 CVariableGroup variablegroup 22 CDomain domain 23 CDomainGroup domaingroup 24 CGrid grid 25 CGridGroup gridgroup 26 22 CVariableGroup variablegroup; 23 CDomain domain; 24 CDomainGroup domaingroup; 25 CGrid grid; 26 CGridGroup gridgroup; 27 27 28 CFile afile; 28 29 CFileGroup filegroup; 29 30 ostringstream oss 30 31 ostringstream oss; 31 32 ofstream file; 32 33 file.open((path+"axis_interface_attr.F90").c_str()); 34 axis.generateFortran2003Interface(file) ; 35 file.close(); 36 37 file.open((path+"icaxis_attr.cpp").c_str()); 38 axis.generateCInterface(file) ; 39 file.close(); 40 41 file.open((path+"iaxis_attr.F90").c_str()); 42 axis.generateFortranInterface(file) ; 43 file.close(); 44 45 file.open((path+"axisgroup_interface_attr.F90").c_str()); 46 axisgroup.generateFortran2003Interface(file) ; 47 file.close(); 48 49 file.open((path+"icaxisgroup_attr.cpp").c_str()); 50 axisgroup.generateCInterface(file) ; 51 file.close(); 52 53 file.open((path+"iaxisgroup_attr.F90").c_str()); 54 axisgroup.generateFortranInterface(file) ; 55 file.close(); 56 57 file.open((path+"domain_interface_attr.F90").c_str()); 58 domain.generateFortran2003Interface(file) ; 59 file.close(); 60 61 file.open((path+"icdomain_attr.cpp").c_str()); 62 domain.generateCInterface(file) ; 63 file.close(); 64 65 file.open((path+"idomain_attr.F90").c_str()); 66 domain.generateFortranInterface(file) ; 67 file.close(); 68 69 file.open((path+"domaingroup_interface_attr.F90").c_str()); 70 domaingroup.generateFortran2003Interface(file) ; 71 file.close(); 72 73 file.open((path+"icdomaingroup_attr.cpp").c_str()); 74 domaingroup.generateCInterface(file) ; 75 file.close(); 76 77 file.open((path+"idomaingroup_attr.F90").c_str()); 78 domaingroup.generateFortranInterface(file) ; 79 file.close(); 80 81 82 file.open((path+"grid_interface_attr.F90").c_str()); 83 grid.generateFortran2003Interface(file) ; 84 file.close(); 85 86 file.open((path+"icgrid_attr.cpp").c_str()); 87 grid.generateCInterface(file) ; 88 file.close(); 89 90 file.open((path+"igrid_attr.F90").c_str()); 91 grid.generateFortranInterface(file) ; 92 file.close(); 93 94 file.open((path+"gridgroup_interface_attr.F90").c_str()); 95 gridgroup.generateFortran2003Interface(file) ; 96 file.close(); 97 98 file.open((path+"icgridgroup_attr.cpp").c_str()); 99 gridgroup.generateCInterface(file) ; 100 file.close(); 101 102 file.open((path+"igridgroup_attr.F90").c_str()); 103 gridgroup.generateFortranInterface(file) ; 104 file.close(); 105 106 107 file.open((path+"field_interface_attr.F90").c_str()); 108 field.generateFortran2003Interface(file) ; 109 file.close(); 110 111 file.open((path+"icfield_attr.cpp").c_str()); 112 field.generateCInterface(file) ; 113 file.close(); 114 115 file.open((path+"ifield_attr.F90").c_str()); 116 field.generateFortranInterface(file) ; 117 file.close(); 118 119 file.open((path+"fieldgroup_interface_attr.F90").c_str()); 120 fieldgroup.generateFortran2003Interface(file) ; 121 file.close(); 122 123 file.open((path+"icfieldgroup_attr.cpp").c_str()); 124 fieldgroup.generateCInterface(file) ; 125 file.close(); 126 127 file.open((path+"ifieldgroup_attr.F90").c_str()); 128 fieldgroup.generateFortranInterface(file) ; 129 file.close(); 130 131 132 133 file.open((path+"variable_interface_attr.F90").c_str()); 134 variable.generateFortran2003Interface(file) ; 135 file.close(); 136 137 file.open((path+"icvariable_attr.cpp").c_str()); 138 variable.generateCInterface(file) ; 139 file.close(); 140 141 file.open((path+"ivariable_attr.F90").c_str()); 142 variable.generateFortranInterface(file) ; 143 file.close(); 144 145 file.open((path+"variablegroup_interface_attr.F90").c_str()); 146 variablegroup.generateFortran2003Interface(file) ; 147 file.close(); 148 149 file.open((path+"icvariablegroup_attr.cpp").c_str()); 150 variablegroup.generateCInterface(file) ; 151 file.close(); 152 153 file.open((path+"ivariablegroup_attr.F90").c_str()); 154 variablegroup.generateFortranInterface(file) ; 155 file.close(); 156 157 158 159 file.open((path+"file_interface_attr.F90").c_str()); 160 afile.generateFortran2003Interface(file) ; 161 file.close(); 162 163 file.open((path+"icfile_attr.cpp").c_str()); 164 afile.generateCInterface(file) ; 165 file.close(); 166 167 file.open((path+"ifile_attr.F90").c_str()); 168 afile.generateFortranInterface(file) ; 169 file.close(); 170 171 file.open((path+"filegroup_interface_attr.F90").c_str()); 172 filegroup.generateFortran2003Interface(file) ; 173 file.close(); 174 175 file.open((path+"icfilegroup_attr.cpp").c_str()); 176 filegroup.generateCInterface(file) ; 177 file.close(); 178 179 file.open((path+"ifilegroup_attr.F90").c_str()); 180 filegroup.generateFortranInterface(file) ; 181 file.close(); 182 183 184 file.open((path+"context_interface_attr.F90").c_str()); 185 context->generateFortran2003Interface(file) ; 186 file.close(); 187 188 file.open((path+"iccontext_attr.cpp").c_str()); 189 context->generateCInterface(file) ; 190 file.close(); 191 192 file.open((path+"icontext_attr.F90").c_str()); 193 context->generateFortranInterface(file) ; 194 file.close(); 195 33 34 file.open((path+"axis_interface_attr.F90").c_str()); 35 axis.generateFortran2003Interface(file); 36 file.close(); 37 38 file.open((path+"icaxis_attr.cpp").c_str()); 39 axis.generateCInterface(file); 40 file.close(); 41 42 file.open((path+"iaxis_attr.F90").c_str()); 43 axis.generateFortranInterface(file); 44 file.close(); 45 46 file.open((path+"axisgroup_interface_attr.F90").c_str()); 47 axisgroup.generateFortran2003Interface(file); 48 file.close(); 49 50 file.open((path+"icaxisgroup_attr.cpp").c_str()); 51 axisgroup.generateCInterface(file); 52 file.close(); 53 54 file.open((path+"iaxisgroup_attr.F90").c_str()); 55 axisgroup.generateFortranInterface(file); 56 file.close(); 57 58 file.open((path+"domain_interface_attr.F90").c_str()); 59 domain.generateFortran2003Interface(file); 60 file.close(); 61 62 file.open((path+"icdomain_attr.cpp").c_str()); 63 domain.generateCInterface(file); 64 file.close(); 65 66 file.open((path+"idomain_attr.F90").c_str()); 67 domain.generateFortranInterface(file); 68 file.close(); 69 70 file.open((path+"domaingroup_interface_attr.F90").c_str()); 71 domaingroup.generateFortran2003Interface(file); 72 file.close(); 73 74 file.open((path+"icdomaingroup_attr.cpp").c_str()); 75 domaingroup.generateCInterface(file); 76 file.close(); 77 78 file.open((path+"idomaingroup_attr.F90").c_str()); 79 domaingroup.generateFortranInterface(file); 80 file.close(); 81 82 83 file.open((path+"grid_interface_attr.F90").c_str()); 84 grid.generateFortran2003Interface(file); 85 file.close(); 86 87 file.open((path+"icgrid_attr.cpp").c_str()); 88 grid.generateCInterface(file); 89 file.close(); 90 91 file.open((path+"igrid_attr.F90").c_str()); 92 grid.generateFortranInterface(file); 93 file.close(); 94 95 file.open((path+"gridgroup_interface_attr.F90").c_str()); 96 gridgroup.generateFortran2003Interface(file); 97 file.close(); 98 99 file.open((path+"icgridgroup_attr.cpp").c_str()); 100 gridgroup.generateCInterface(file); 101 file.close(); 102 103 file.open((path+"igridgroup_attr.F90").c_str()); 104 gridgroup.generateFortranInterface(file); 105 file.close(); 106 107 108 file.open((path+"field_interface_attr.F90").c_str()); 109 field.generateFortran2003Interface(file); 110 file.close(); 111 112 file.open((path+"icfield_attr.cpp").c_str()); 113 field.generateCInterface(file); 114 file.close(); 115 116 file.open((path+"ifield_attr.F90").c_str()); 117 field.generateFortranInterface(file); 118 file.close(); 119 120 file.open((path+"fieldgroup_interface_attr.F90").c_str()); 121 fieldgroup.generateFortran2003Interface(file); 122 file.close(); 123 124 file.open((path+"icfieldgroup_attr.cpp").c_str()); 125 fieldgroup.generateCInterface(file); 126 file.close(); 127 128 file.open((path+"ifieldgroup_attr.F90").c_str()); 129 fieldgroup.generateFortranInterface(file); 130 file.close(); 131 132 133 134 file.open((path+"variable_interface_attr.F90").c_str()); 135 variable.generateFortran2003Interface(file); 136 file.close(); 137 138 file.open((path+"icvariable_attr.cpp").c_str()); 139 variable.generateCInterface(file); 140 file.close(); 141 142 file.open((path+"ivariable_attr.F90").c_str()); 143 variable.generateFortranInterface(file); 144 file.close(); 145 146 file.open((path+"variablegroup_interface_attr.F90").c_str()); 147 variablegroup.generateFortran2003Interface(file); 148 file.close(); 149 150 file.open((path+"icvariablegroup_attr.cpp").c_str()); 151 variablegroup.generateCInterface(file); 152 file.close(); 153 154 file.open((path+"ivariablegroup_attr.F90").c_str()); 155 variablegroup.generateFortranInterface(file); 156 file.close(); 157 158 159 160 file.open((path+"file_interface_attr.F90").c_str()); 161 afile.generateFortran2003Interface(file); 162 file.close(); 163 164 file.open((path+"icfile_attr.cpp").c_str()); 165 afile.generateCInterface(file); 166 file.close(); 167 168 file.open((path+"ifile_attr.F90").c_str()); 169 afile.generateFortranInterface(file); 170 file.close(); 171 172 file.open((path+"filegroup_interface_attr.F90").c_str()); 173 filegroup.generateFortran2003Interface(file); 174 file.close(); 175 176 file.open((path+"icfilegroup_attr.cpp").c_str()); 177 filegroup.generateCInterface(file); 178 file.close(); 179 180 file.open((path+"ifilegroup_attr.F90").c_str()); 181 filegroup.generateFortranInterface(file); 182 file.close(); 183 184 185 file.open((path+"calendar_wrapper_interface_attr.F90").c_str()); 186 calendarWrapper.generateFortran2003Interface(file); 187 file.close(); 188 189 file.open((path+"iccalendar_wrapper_attr.cpp").c_str()); 190 calendarWrapper.generateCInterface(file); 191 file.close(); 192 193 file.open((path+"icalendar_wrapper_attr.F90").c_str()); 194 calendarWrapper.generateFortranInterface(file); 195 file.close(); 196 197 198 file.open((path+"context_interface_attr.F90").c_str()); 199 context->generateFortran2003Interface(file); 200 file.close(); 201 202 file.open((path+"iccontext_attr.cpp").c_str()); 203 context->generateCInterface(file); 204 file.close(); 205 206 file.open((path+"icontext_attr.F90").c_str()); 207 context->generateFortranInterface(file); 208 file.close(); 209 196 210 } -
XIOS/trunk/src/interface/c/iccalendar.cpp
r545 r549 1 1 #include "xmlioserver.hpp" 2 2 3 #include "icdate.hpp" 3 4 #include "exception.hpp" 4 5 #include "timer.hpp" … … 8 9 extern "C" 9 10 { 10 void cxios_create_calendar()11 {12 CTimer::get("XIOS").resume();13 xios::CContext* context = CContext::getCurrent();14 if (context->hasClient)15 context->solveCalendar();16 CTimer::get("XIOS").suspend();17 }18 19 11 void cxios_update_calendar(int step) 20 12 { … … 26 18 CTimer::get("XIOS").suspend(); 27 19 } 20 21 void cxios_get_current_date(cxios_date* current_date_c) 22 { 23 CTimer::get("XIOS").resume(); 24 const xios::CContext* context = CContext::getCurrent(); 25 const boost::shared_ptr<xios::CCalendar> cal = context->getCalendar(); 26 if (!cal) 27 ERROR("void cxios_get_current_date(cxios_date* current_date_c)", 28 << "Impossible to get the current date: no calendar was defined."); 29 const CDate& currentDate = cal->getCurrentDate(); 30 current_date_c->year = currentDate.getYear(); 31 current_date_c->month = currentDate.getMonth(); 32 current_date_c->day = currentDate.getDay(); 33 current_date_c->hour = currentDate.getHour(); 34 current_date_c->minute = currentDate.getMinute(); 35 current_date_c->second = currentDate.getSecond(); 36 CTimer::get("XIOS").suspend(); 37 } 38 39 int cxios_get_year_length_in_seconds(int year) 40 { 41 CTimer::get("XIOS").resume(); 42 const boost::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar(); 43 if (!cal) 44 ERROR("int cxios_get_year_length_in_seconds(int year)", 45 << "Impossible to get the year length: no calendar was defined."); 46 int length = cal->getYearTotalLength(CDate(*cal, year, 01, 01)); 47 CTimer::get("XIOS").suspend(); 48 49 return length; 50 } 51 52 int cxios_get_day_length_in_seconds() 53 { 54 CTimer::get("XIOS").resume(); 55 const boost::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar(); 56 if (!cal) 57 ERROR("int cxios_get_day_length_in_seconds()", 58 << "Impossible to get the day length: no calendar was defined."); 59 int length = cal->getDayLengthInSeconds(); 60 CTimer::get("XIOS").suspend(); 61 62 return length; 63 } 28 64 } -
XIOS/trunk/src/interface/c/icdate.cpp
r545 r549 144 144 return (date1 >= date2); 145 145 } 146 147 int cxios_date_get_second_of_year(cxios_date date_c) 148 { 149 xios::CDate date = xios::CDate(getCalendar("int cxios_date_get_second_of_year(cxios_date date_c)"), 150 date_c.year, date_c.month, date_c.day, 151 date_c.hour, date_c.minute, date_c.second); 152 return date.getSecondOfYear(); 153 } 154 155 double cxios_date_get_day_of_year(cxios_date date_c) 156 { 157 xios::CDate date = xios::CDate(getCalendar("int cxios_date_get_day_of_year(cxios_date date_c)"), 158 date_c.year, date_c.month, date_c.day, 159 date_c.hour, date_c.minute, date_c.second); 160 return date.getDayOfYear(); 161 } 162 163 double cxios_date_get_fraction_of_year(cxios_date date_c) 164 { 165 xios::CDate date = xios::CDate(getCalendar("int cxios_date_get_fraction_of_year(cxios_date date_c)"), 166 date_c.year, date_c.month, date_c.day, 167 date_c.hour, date_c.minute, date_c.second); 168 return date.getFractionOfYear(); 169 } 170 171 int cxios_date_get_second_of_day(cxios_date date_c) 172 { 173 xios::CDate date = xios::CDate(getCalendar("int cxios_date_get_second_of_day(cxios_date date_c)"), 174 date_c.year, date_c.month, date_c.day, 175 date_c.hour, date_c.minute, date_c.second); 176 return date.getSecondOfDay(); 177 } 178 179 double cxios_date_get_fraction_of_day(cxios_date date_c) 180 { 181 xios::CDate date = xios::CDate(getCalendar("int cxios_date_get_fraction_of_day(cxios_date date_c)"), 182 date_c.year, date_c.month, date_c.day, 183 date_c.hour, date_c.minute, date_c.second); 184 return date.getFractionOfDay(); 185 } 146 186 } // extern "C" -
XIOS/trunk/src/interface/c_attr/iccontext_attr.cpp
r537 r549 17 17 { 18 18 typedef xios::CContext* context_Ptr; 19 20 void cxios_set_context_calendar_type(context_Ptr context_hdl, const char * calendar_type, int calendar_type_size)21 {22 std::string calendar_type_str;23 if(!cstr2string(calendar_type, calendar_type_size, calendar_type_str)) return;24 CTimer::get("XIOS").resume();25 context_hdl->calendar_type.fromString(calendar_type_str);26 CTimer::get("XIOS").suspend();27 }28 29 void cxios_get_context_calendar_type(context_Ptr context_hdl, char * calendar_type, int calendar_type_size)30 {31 CTimer::get("XIOS").resume();32 if(!string_copy(context_hdl->calendar_type.getInheritedStringValue(),calendar_type , calendar_type_size))33 ERROR("void cxios_get_context_calendar_type(context_Ptr context_hdl, char * calendar_type, int calendar_type_size)", <<"Input string is to short");34 CTimer::get("XIOS").suspend();35 }36 37 bool cxios_is_defined_context_calendar_type(context_Ptr context_hdl )38 {39 CTimer::get("XIOS").resume();40 return context_hdl->calendar_type.hasInheritedValue();41 CTimer::get("XIOS").suspend();42 }43 44 45 19 46 20 void cxios_set_context_output_dir(context_Ptr context_hdl, const char * output_dir, int output_dir_size) … … 70 44 71 45 72 void cxios_set_context_start_date(context_Ptr context_hdl, cxios_date start_date_c)73 {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();86 }87 88 void cxios_get_context_start_date(context_Ptr context_hdl, cxios_date* start_date_c)89 {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();99 }100 101 bool cxios_is_defined_context_start_date(context_Ptr context_hdl )102 {103 CTimer::get("XIOS").resume();104 return context_hdl->start_date.hasInheritedValue();105 CTimer::get("XIOS").suspend();106 }107 108 109 110 void cxios_set_context_time_origin(context_Ptr context_hdl, cxios_date time_origin_c)111 {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();124 }125 126 void cxios_get_context_time_origin(context_Ptr context_hdl, cxios_date* time_origin_c)127 {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();137 }138 139 bool cxios_is_defined_context_time_origin(context_Ptr context_hdl )140 {141 CTimer::get("XIOS").resume();142 return context_hdl->time_origin.hasInheritedValue();143 CTimer::get("XIOS").suspend();144 }145 146 147 148 void cxios_set_context_timestep(context_Ptr context_hdl, cxios_duration timestep_c)149 {150 CTimer::get("XIOS").resume();151 context_hdl->timestep.allocate();152 CDuration& timestep = context_hdl->timestep.get();153 timestep.year = timestep_c.year;154 timestep.month = timestep_c.month;155 timestep.day = timestep_c.day;156 timestep.hour = timestep_c.hour;157 timestep.minute = timestep_c.minute;158 timestep.second = timestep_c.second;159 timestep.timestep = timestep_c.timestep;160 CTimer::get("XIOS").suspend();161 }162 163 void cxios_get_context_timestep(context_Ptr context_hdl, cxios_duration* timestep_c)164 {165 CTimer::get("XIOS").resume();166 CDuration timestep = context_hdl->timestep.getInheritedValue();167 timestep_c->year = timestep.year;168 timestep_c->month = timestep.month;169 timestep_c->day = timestep.day;170 timestep_c->hour = timestep.hour;171 timestep_c->minute = timestep.minute;172 timestep_c->second = timestep.second;173 timestep_c->timestep = timestep.timestep;174 CTimer::get("XIOS").suspend();175 }176 177 bool cxios_is_defined_context_timestep(context_Ptr context_hdl )178 {179 CTimer::get("XIOS").resume();180 return context_hdl->timestep.hasInheritedValue();181 CTimer::get("XIOS").suspend();182 }183 184 185 186 46 187 47 } -
XIOS/trunk/src/interface/fortran/calendar_interface.F90
r545 r549 1 #include "xios_fortran_prefix.hpp" 2 1 3 MODULE CALENDAR_INTERFACE 2 4 USE, INTRINSIC :: ISO_C_BINDING 3 5 4 6 INTERFACE ! Ne pas appeler directement/Interface FORTRAN 2003 <-> C99 5 6 SUBROUTINE cxios_create_calendar() BIND(C)7 END SUBROUTINE cxios_create_calendar8 7 9 8 SUBROUTINE cxios_update_calendar(step) BIND(C) … … 12 11 END SUBROUTINE cxios_update_calendar 13 12 13 SUBROUTINE cxios_get_current_date(current_date) BIND(C) 14 USE IDATE 15 TYPE(txios(date)) :: current_date 16 END SUBROUTINE cxios_get_current_date 17 18 INTEGER(kind = C_INT) FUNCTION cxios_get_year_length_in_seconds(year) BIND(C) 19 USE ISO_C_BINDING 20 INTEGER(kind = C_INT), VALUE :: year 21 END FUNCTION cxios_get_year_length_in_seconds 22 23 INTEGER(kind = C_INT) FUNCTION cxios_get_day_length_in_seconds() BIND(C) 24 USE ISO_C_BINDING 25 END FUNCTION cxios_get_day_length_in_seconds 26 14 27 END INTERFACE 15 28 16 29 END MODULE CALENDAR_INTERFACE -
XIOS/trunk/src/interface/fortran/date_interface.F90
r545 r549 7 7 INTEGER(kind = C_INT) :: year, month, day, hour, minute, second 8 8 END TYPE txios(date) 9 9 10 10 INTERFACE ! Ne pas appeler directement/Interface FORTRAN 2003 <-> C99 11 11 … … 75 75 END FUNCTION cxios_date_ge 76 76 77 INTEGER(kind = C_INT) FUNCTION cxios_date_get_second_of_year(date) BIND(C) 78 USE ISO_C_BINDING 79 IMPORT :: txios(date) 80 TYPE(txios(date)), VALUE :: date 81 END FUNCTION cxios_date_get_second_of_year 82 83 REAL(kind = C_DOUBLE) FUNCTION cxios_date_get_day_of_year(date) BIND(C) 84 USE ISO_C_BINDING 85 IMPORT :: txios(date) 86 TYPE(txios(date)), VALUE :: date 87 END FUNCTION cxios_date_get_day_of_year 88 89 REAL(kind = C_DOUBLE) FUNCTION cxios_date_get_fraction_of_year(date) BIND(C) 90 USE ISO_C_BINDING 91 IMPORT :: txios(date) 92 TYPE(txios(date)), VALUE :: date 93 END FUNCTION cxios_date_get_fraction_of_year 94 95 INTEGER(kind = C_INT) FUNCTION cxios_date_get_second_of_day(date) BIND(C) 96 USE ISO_C_BINDING 97 IMPORT :: txios(date) 98 TYPE(txios(date)), VALUE :: date 99 END FUNCTION cxios_date_get_second_of_day 100 101 REAL(kind = C_DOUBLE) FUNCTION cxios_date_get_fraction_of_day(date) BIND(C) 102 USE ISO_C_BINDING 103 IMPORT :: txios(date) 104 TYPE(txios(date)), VALUE :: date 105 END FUNCTION cxios_date_get_fraction_of_day 106 77 107 END INTERFACE 78 108 79 109 END MODULE DATE_INTERFACE -
XIOS/trunk/src/interface/fortran/icalendar.F90
r545 r549 3 3 USE, INTRINSIC :: ISO_C_BINDING 4 4 USE CALENDAR_INTERFACE 5 USE ICALENDAR_WRAPPER 5 6 USE IDATE 6 7 USE IDURATION … … 9 10 INTEGER(kind = C_INT), PARAMETER :: D360 = 0 , ALLLEAP = 1 , NOLEAP = 2 , JULIAN = 3 , GREGORIAN = 4 10 11 12 INTERFACE xios(set_start_date) 13 MODULE PROCEDURE xios(set_start_date_date), xios(set_start_date_dur) 14 END INTERFACE xios(set_start_date) 15 16 INTERFACE xios(set_time_origin) 17 MODULE PROCEDURE xios(set_time_origin_date), xios(set_time_origin_dur) 18 END INTERFACE xios(set_time_origin) 19 11 20 CONTAINS ! Fonctions disponibles pour les utilisateurs. 12 21 13 SUBROUTINE xios(set_calendar)(calendar_type, start_date, time_origin, timestep) 14 USE ICONTEXT, ONLY : txios(context), xios(get_current_context) 15 USE icontext_attr, ONLY : xios(set_context_attr_hdl) 16 USE IDATE, ONLY : txios(date) 17 USE IDURATION, ONLY : txios(duration) 18 IMPLICIT NONE 19 CHARACTER(len = *), OPTIONAL, INTENT(IN) :: calendar_type 22 SUBROUTINE xios(define_calendar)(type, timestep, start_date, time_origin) 23 USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) 24 USE icalendar_wrapper_attr, ONLY : xios(set_calendar_wrapper_attr_hdl) 25 USE IDURATION, ONLY : txios(duration) 26 USE IDATE, ONLY : txios(date) 27 IMPLICIT NONE 28 CHARACTER(len = *), INTENT(IN) :: type 29 TYPE(txios(duration)), OPTIONAL, INTENT(IN) :: timestep 20 30 TYPE(txios(date)), OPTIONAL, INTENT(IN) :: start_date 21 31 TYPE(txios(date)), OPTIONAL, INTENT(IN) :: time_origin 22 TYPE(txios(duration)), OPTIONAL, INTENT(IN) :: timestep 23 TYPE(txios(context)) :: context 24 25 CALL xios(get_current_context)(context) 26 27 IF (PRESENT(calendar_type)) THEN 28 CALL xios(set_context_attr_hdl)(context, calendar_type=calendar_type) 29 END IF 32 TYPE(txios(calendar_wrapper)) :: calendar_wrapper 33 34 CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) 35 36 CALL xios(set_calendar_wrapper_attr_hdl)(calendar_wrapper, type=type) 37 IF (PRESENT(timestep)) THEN 38 CALL xios(set_calendar_wrapper_attr_hdl)(calendar_wrapper, timestep=timestep) 39 END IF 40 41 CALL xios(create_calendar)(calendar_wrapper) 42 30 43 IF (PRESENT(start_date)) THEN 31 CALL xios(set_ context_attr_hdl)(context, start_date=start_date)44 CALL xios(set_start_date_hdl)(calendar_wrapper, start_date=start_date) 32 45 END IF 33 46 IF (PRESENT(time_origin)) THEN 34 CALL xios(set_context_attr_hdl)(context, time_origin=time_origin) 35 END IF 36 IF (PRESENT(time_origin)) THEN 37 CALL xios(set_context_attr_hdl)(context, timestep=timestep) 38 END IF 39 40 CALL cxios_create_calendar() 41 END SUBROUTINE xios(set_calendar) 47 CALL xios(set_time_origin_hdl)(calendar_wrapper, time_origin=time_origin) 48 END IF 49 END SUBROUTINE xios(define_calendar) 50 51 SUBROUTINE xios(get_calendar_type)(calendar_type) 52 USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) 53 USE icalendar_wrapper_attr, ONLY : xios(get_calendar_wrapper_attr_hdl) 54 IMPLICIT NONE 55 CHARACTER(len = *), INTENT(OUT) :: calendar_type 56 TYPE(txios(calendar_wrapper)) :: calendar_wrapper 57 58 CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) 59 60 CALL xios(get_calendar_wrapper_attr_hdl)(calendar_wrapper, type=calendar_type) 61 END SUBROUTINE xios(get_calendar_type) 42 62 43 63 SUBROUTINE xios(set_timestep)(timestep) 44 USE IC ONTEXT, ONLY : txios(context), xios(get_current_context)45 USE ic ontext_attr, ONLY : xios(set_context_attr_hdl)64 USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) 65 USE icalendar_wrapper_attr, ONLY : xios(set_calendar_wrapper_attr_hdl) 46 66 USE IDURATION, ONLY : txios(duration) 47 67 IMPLICIT NONE 48 68 TYPE(txios(duration)), INTENT(IN) :: timestep 49 TYPE(txios(context)) :: context 50 51 CALL xios(get_current_context)(context) 52 53 CALL xios(set_context_attr_hdl)(context, timestep=timestep) 69 TYPE(txios(calendar_wrapper)) :: calendar_wrapper 70 71 CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) 72 73 CALL xios(set_calendar_wrapper_attr_hdl)(calendar_wrapper, timestep=timestep) 74 75 CALL xios(update_calendar_timestep)(calendar_wrapper) 54 76 END SUBROUTINE xios(set_timestep) 55 77 78 SUBROUTINE xios(get_timestep)(timestep) 79 USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) 80 USE icalendar_wrapper_attr, ONLY : xios(get_calendar_wrapper_attr_hdl) 81 USE IDURATION, ONLY : txios(duration) 82 IMPLICIT NONE 83 TYPE(txios(duration)), INTENT(OUT) :: timestep 84 TYPE(txios(calendar_wrapper)) :: calendar_wrapper 85 86 CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) 87 88 CALL xios(get_calendar_wrapper_attr_hdl)(calendar_wrapper, timestep=timestep) 89 END SUBROUTINE xios(get_timestep) 90 91 SUBROUTINE xios(set_start_date_date)(start_date) 92 USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) 93 USE IDATE, ONLY : txios(date) 94 IMPLICIT NONE 95 TYPE(txios(date)), INTENT(IN) :: start_date 96 TYPE(txios(calendar_wrapper)) :: calendar_wrapper 97 98 CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) 99 100 CALL xios(set_start_date_hdl)(calendar_wrapper, start_date) 101 END SUBROUTINE xios(set_start_date_date) 102 103 SUBROUTINE xios(set_start_date_dur)(start_date) 104 USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) 105 USE IDURATION, ONLY : txios(duration) 106 USE IDATE, ONLY : txios(date) 107 IMPLICIT NONE 108 TYPE(txios(duration)), INTENT(IN) :: start_date 109 TYPE(txios(calendar_wrapper)) :: calendar_wrapper 110 TYPE(txios(date)) :: start_date_date 111 112 CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) 113 114 start_date_date = start_date 115 CALL xios(set_start_date_hdl)(calendar_wrapper, start_date_date) 116 END SUBROUTINE xios(set_start_date_dur) 117 118 SUBROUTINE xios(get_start_date)(start_date) 119 USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) 120 USE IDATE, ONLY : txios(date) 121 IMPLICIT NONE 122 TYPE(txios(date)), INTENT(OUT) :: start_date 123 TYPE(txios(calendar_wrapper)) :: calendar_wrapper 124 125 CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) 126 127 CALL xios(get_start_date_hdl)(calendar_wrapper, start_date) 128 END SUBROUTINE xios(get_start_date) 129 130 SUBROUTINE xios(set_time_origin_date)(time_origin) 131 USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) 132 USE IDATE, ONLY : txios(date) 133 IMPLICIT NONE 134 TYPE(txios(date)), INTENT(IN) :: time_origin 135 TYPE(txios(calendar_wrapper)) :: calendar_wrapper 136 137 CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) 138 139 CALL xios(set_time_origin_hdl)(calendar_wrapper, time_origin) 140 END SUBROUTINE xios(set_time_origin_date) 141 142 SUBROUTINE xios(set_time_origin_dur)(time_origin) 143 USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) 144 USE IDURATION, ONLY : txios(duration) 145 USE IDATE, ONLY : txios(date) 146 IMPLICIT NONE 147 TYPE(txios(duration)), INTENT(IN) :: time_origin 148 TYPE(txios(calendar_wrapper)) :: calendar_wrapper 149 TYPE(txios(date)) :: time_origin_date 150 151 CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) 152 153 time_origin_date = time_origin 154 CALL xios(set_time_origin_hdl)(calendar_wrapper, time_origin_date) 155 END SUBROUTINE xios(set_time_origin_dur) 156 157 SUBROUTINE xios(get_time_origin)(time_origin) 158 USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) 159 USE IDATE, ONLY : txios(date) 160 IMPLICIT NONE 161 TYPE(txios(date)), INTENT(OUT) :: time_origin 162 TYPE(txios(calendar_wrapper)) :: calendar_wrapper 163 164 CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) 165 166 CALL xios(get_time_origin_hdl)(calendar_wrapper, time_origin) 167 END SUBROUTINE xios(get_time_origin) 168 56 169 SUBROUTINE xios(update_calendar)(step) 57 170 IMPLICIT NONE 58 171 INTEGER, INTENT(IN) :: step 59 172 60 173 IF (step < 0) THEN 61 174 PRINT *, "L'argument 'step' ne peut être négatif" … … 65 178 END SUBROUTINE xios(update_calendar) 66 179 180 SUBROUTINE xios(get_current_date)(current_date) 181 USE IDATE, ONLY : txios(date) 182 IMPLICIT NONE 183 TYPE(txios(date)), INTENT(OUT) :: current_date 184 185 CALL cxios_get_current_date(current_date) 186 END SUBROUTINE xios(get_current_date) 187 188 FUNCTION xios(get_year_length_in_seconds)(year) RESULT(res) 189 IMPLICIT NONE 190 INTEGER(kind = C_INT), INTENT(IN) :: year 191 INTEGER(kind = C_INT) :: res 192 193 res = cxios_get_year_length_in_seconds(year) 194 END FUNCTION xios(get_year_length_in_seconds) 195 196 FUNCTION xios(get_day_length_in_seconds)() RESULT(res) 197 IMPLICIT NONE 198 INTEGER(kind = C_INT) :: res 199 200 res = cxios_get_day_length_in_seconds() 201 END FUNCTION xios(get_day_length_in_seconds) 202 67 203 END MODULE ICALENDAR -
XIOS/trunk/src/interface/fortran/idate.F90
r545 r549 37 37 END INTERFACE 38 38 39 INTERFACE ASSIGNMENT(=) 40 MODULE PROCEDURE xios(date_assign_duration) 41 END INTERFACE 42 39 43 CONTAINS ! Fonctions disponibles pour les utilisateurs. 40 44 … … 140 144 END FUNCTION xios(date_ge) 141 145 146 SUBROUTINE xios(date_assign_duration)(date, dur) 147 USE DATE_INTERFACE, only : txios(date) 148 USE IDURATION, only : txios(duration) 149 IMPLICIT NONE 150 TYPE(txios(date)), INTENT(OUT) :: date 151 TYPE(txios(duration)), INTENT(IN) :: dur 152 153 date = txios(date)(0, 1, 1, 0, 0, 0) + dur 154 END SUBROUTINE xios(date_assign_duration) 155 156 FUNCTION xios(date_get_second_of_year)(date) RESULT(res) 157 USE DATE_INTERFACE, only : txios(date) 158 IMPLICIT NONE 159 TYPE(txios(date)), INTENT(OUT) :: date 160 INTEGER(kind = C_INT) :: res 161 162 res = cxios_date_get_second_of_year(date) 163 END FUNCTION xios(date_get_second_of_year) 164 165 FUNCTION xios(date_get_day_of_year)(date) RESULT(res) 166 USE DATE_INTERFACE, only : txios(date) 167 IMPLICIT NONE 168 TYPE(txios(date)), INTENT(OUT) :: date 169 REAL(kind = C_DOUBLE) :: res 170 171 res = cxios_date_get_day_of_year(date) 172 END FUNCTION xios(date_get_day_of_year) 173 174 FUNCTION xios(date_get_fraction_of_year)(date) RESULT(res) 175 USE DATE_INTERFACE, only : txios(date) 176 IMPLICIT NONE 177 TYPE(txios(date)), INTENT(OUT) :: date 178 REAL(kind = C_DOUBLE) :: res 179 180 res = cxios_date_get_fraction_of_year(date) 181 END FUNCTION xios(date_get_fraction_of_year) 182 183 FUNCTION xios(date_get_second_of_day)(date) RESULT(res) 184 USE DATE_INTERFACE, only : txios(date) 185 IMPLICIT NONE 186 TYPE(txios(date)), INTENT(OUT) :: date 187 INTEGER(kind = C_INT) :: res 188 189 res = cxios_date_get_second_of_day(date) 190 END FUNCTION xios(date_get_second_of_day) 191 192 FUNCTION xios(date_get_fraction_of_day)(date) RESULT(res) 193 USE DATE_INTERFACE, only : txios(date) 194 IMPLICIT NONE 195 TYPE(txios(date)), INTENT(OUT) :: date 196 REAL(kind = C_DOUBLE) :: res 197 198 res = cxios_date_get_fraction_of_day(date) 199 END FUNCTION xios(date_get_fraction_of_day) 200 142 201 END MODULE IDATE -
XIOS/trunk/src/interface/fortran/ixios.F90
r545 r549 3 3 MODULE XIOS 4 4 5 USE icalendar, ONLY : xios(set_calendar), xios(set_timestep), xios(update_calendar) 5 USE icalendar, ONLY : xios(define_calendar), xios(set_timestep), xios(set_start_date), xios(set_time_origin), & 6 xios(get_calendar_type), xios(get_timestep), xios(get_start_date), xios(get_time_origin), & 7 xios(update_calendar), xios(get_current_date), & 8 xios(get_year_length_in_seconds), xios(get_day_length_in_seconds) 6 9 7 10 USE icontext, ONLY : txios(context), xios(get_context_handle), xios(set_current_context), & … … 24 27 xios(date_add_duration), xios(date_sub_duration), xios(date_sub), & 25 28 xios(date_eq), xios(date_neq), xios(date_lt), xios(date_le), xios(date_gt), xios(date_ge), & 29 xios(date_get_second_of_year), xios(date_get_day_of_year), xios(date_get_fraction_of_year), & 30 xios(date_get_second_of_day), xios(date_get_fraction_of_day), & 26 31 OPERATOR(+), OPERATOR(-), & 27 OPERATOR(==), OPERATOR(/=), OPERATOR(<), OPERATOR(<=), OPERATOR(>), OPERATOR(>=) 32 OPERATOR(==), OPERATOR(/=), OPERATOR(<), OPERATOR(<=), OPERATOR(>), OPERATOR(>=), & 33 ASSIGNMENT(=) 28 34 29 35 USE idomain, ONLY : txios(domain), txios(domaingroup), xios(get_domain_handle), & … … 200 206 xios(field_is_active) 201 207 202 PUBLIC :: xios(set_calendar), xios(set_timestep), xios(update_calendar) 208 PUBLIC :: xios(define_calendar), xios(set_timestep), xios(set_start_date), xios(set_time_origin), & 209 xios(get_calendar_type), xios(get_timestep), xios(get_start_date), xios(get_time_origin), & 210 xios(update_calendar), xios(get_current_date), & 211 xios(get_year_length_in_seconds), xios(get_day_length_in_seconds) 203 212 204 213 PUBLIC :: xios(year), xios(month), xios(day), xios(hour), xios(minute), xios(second), xios(timestep), & … … 208 217 PUBLIC :: xios(date_convert_to_seconds), & 209 218 xios(date_add_duration), xios(date_sub_duration), xios(date_sub), & 210 xios(date_eq), xios(date_neq), xios(date_lt), xios(date_le), xios(date_gt), xios(date_ge) 219 xios(date_eq), xios(date_neq), xios(date_lt), xios(date_le), xios(date_gt), xios(date_ge), & 220 xios(date_get_second_of_year), xios(date_get_day_of_year), xios(date_get_fraction_of_year), & 221 xios(date_get_second_of_day), xios(date_get_fraction_of_day) 211 222 212 223 PUBLIC :: OPERATOR(+), OPERATOR(-), OPERATOR(*), & 213 OPERATOR(==), OPERATOR(/=), OPERATOR(<), OPERATOR(<=), OPERATOR(>), OPERATOR(>=) 224 OPERATOR(==), OPERATOR(/=), OPERATOR(<), OPERATOR(<=), OPERATOR(>), OPERATOR(>=), & 225 ASSIGNMENT(=) 214 226 215 227 PUBLIC :: xios(getVar) -
XIOS/trunk/src/interface/fortran_attr/context_interface_attr.F90
r545 r549 8 8 9 9 INTERFACE ! Do not call directly / interface FORTRAN 2003 <-> C99 10 11 12 SUBROUTINE cxios_set_context_calendar_type(context_hdl, calendar_type, calendar_type_size) BIND(C)13 USE ISO_C_BINDING14 INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl15 CHARACTER(kind = C_CHAR) , DIMENSION(*) :: calendar_type16 INTEGER (kind = C_INT) , VALUE :: calendar_type_size17 END SUBROUTINE cxios_set_context_calendar_type18 19 SUBROUTINE cxios_get_context_calendar_type(context_hdl, calendar_type, calendar_type_size) BIND(C)20 USE ISO_C_BINDING21 INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl22 CHARACTER(kind = C_CHAR) , DIMENSION(*) :: calendar_type23 INTEGER (kind = C_INT) , VALUE :: calendar_type_size24 END SUBROUTINE cxios_get_context_calendar_type25 26 FUNCTION cxios_is_defined_context_calendar_type(context_hdl ) BIND(C)27 USE ISO_C_BINDING28 LOGICAL(kind=C_BOOL) :: cxios_is_defined_context_calendar_type29 INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl30 END FUNCTION cxios_is_defined_context_calendar_type31 10 32 11 … … 52 31 53 32 54 SUBROUTINE cxios_set_context_start_date(context_hdl, start_date) BIND(C)55 USE ISO_C_BINDING56 USE IDATE57 INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl58 TYPE(txios(date)), VALUE :: start_date59 END SUBROUTINE cxios_set_context_start_date60 61 SUBROUTINE cxios_get_context_start_date(context_hdl, start_date) BIND(C)62 USE ISO_C_BINDING63 USE IDATE64 INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl65 TYPE(txios(date)) :: start_date66 END SUBROUTINE cxios_get_context_start_date67 68 FUNCTION cxios_is_defined_context_start_date(context_hdl ) BIND(C)69 USE ISO_C_BINDING70 LOGICAL(kind=C_BOOL) :: cxios_is_defined_context_start_date71 INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl72 END FUNCTION cxios_is_defined_context_start_date73 74 75 SUBROUTINE cxios_set_context_time_origin(context_hdl, time_origin) BIND(C)76 USE ISO_C_BINDING77 USE IDATE78 INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl79 TYPE(txios(date)), VALUE :: time_origin80 END SUBROUTINE cxios_set_context_time_origin81 82 SUBROUTINE cxios_get_context_time_origin(context_hdl, time_origin) BIND(C)83 USE ISO_C_BINDING84 USE IDATE85 INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl86 TYPE(txios(date)) :: time_origin87 END SUBROUTINE cxios_get_context_time_origin88 89 FUNCTION cxios_is_defined_context_time_origin(context_hdl ) BIND(C)90 USE ISO_C_BINDING91 LOGICAL(kind=C_BOOL) :: cxios_is_defined_context_time_origin92 INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl93 END FUNCTION cxios_is_defined_context_time_origin94 95 96 SUBROUTINE cxios_set_context_timestep(context_hdl, timestep) BIND(C)97 USE ISO_C_BINDING98 USE IDURATION99 INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl100 TYPE(txios(duration)), VALUE :: timestep101 END SUBROUTINE cxios_set_context_timestep102 103 SUBROUTINE cxios_get_context_timestep(context_hdl, timestep) BIND(C)104 USE ISO_C_BINDING105 USE IDURATION106 INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl107 TYPE(txios(duration)) :: timestep108 END SUBROUTINE cxios_get_context_timestep109 110 FUNCTION cxios_is_defined_context_timestep(context_hdl ) BIND(C)111 USE ISO_C_BINDING112 LOGICAL(kind=C_BOOL) :: cxios_is_defined_context_timestep113 INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl114 END FUNCTION cxios_is_defined_context_timestep115 116 117 33 END INTERFACE 118 34 -
XIOS/trunk/src/interface/fortran_attr/icontext_attr.F90
r537 r549 12 12 13 13 SUBROUTINE xios(set_context_attr) & 14 ( context_id, calendar_type, output_dir, start_date, time_origin, timestep)14 ( context_id, output_dir ) 15 15 16 16 IMPLICIT NONE 17 17 TYPE(txios(context)) :: context_hdl 18 18 CHARACTER(LEN=*), INTENT(IN) ::context_id 19 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: calendar_type20 19 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: output_dir 21 TYPE(txios(date)) , OPTIONAL, INTENT(IN) :: start_date22 TYPE(txios(date)) , OPTIONAL, INTENT(IN) :: time_origin23 TYPE(txios(duration)) , OPTIONAL, INTENT(IN) :: timestep24 20 25 21 CALL xios(get_context_handle)(context_id,context_hdl) 26 22 CALL xios(set_context_attr_hdl_) & 27 ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep)23 ( context_hdl, output_dir ) 28 24 29 25 END SUBROUTINE xios(set_context_attr) 30 26 31 27 SUBROUTINE xios(set_context_attr_hdl) & 32 ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep)28 ( context_hdl, output_dir ) 33 29 34 30 IMPLICIT NONE 35 31 TYPE(txios(context)) , INTENT(IN) :: context_hdl 36 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: calendar_type37 32 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: output_dir 38 TYPE(txios(date)) , OPTIONAL, INTENT(IN) :: start_date39 TYPE(txios(date)) , OPTIONAL, INTENT(IN) :: time_origin40 TYPE(txios(duration)) , OPTIONAL, INTENT(IN) :: timestep41 33 42 34 CALL xios(set_context_attr_hdl_) & 43 ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep)35 ( context_hdl, output_dir ) 44 36 45 37 END SUBROUTINE xios(set_context_attr_hdl) 46 38 47 39 SUBROUTINE xios(set_context_attr_hdl_) & 48 ( context_hdl, calendar_type_, output_dir_, start_date_, time_origin_, timestep_ )40 ( context_hdl, output_dir_ ) 49 41 50 42 IMPLICIT NONE 51 43 TYPE(txios(context)) , INTENT(IN) :: context_hdl 52 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: calendar_type_53 44 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: output_dir_ 54 TYPE(txios(date)) , OPTIONAL, INTENT(IN) :: start_date_55 TYPE(txios(date)) , OPTIONAL, INTENT(IN) :: time_origin_56 TYPE(txios(duration)) , OPTIONAL, INTENT(IN) :: timestep_57 58 IF (PRESENT(calendar_type_)) THEN59 CALL cxios_set_context_calendar_type(context_hdl%daddr, calendar_type_, len(calendar_type_))60 ENDIF61 45 62 46 IF (PRESENT(output_dir_)) THEN 63 47 CALL cxios_set_context_output_dir(context_hdl%daddr, output_dir_, len(output_dir_)) 64 ENDIF65 66 IF (PRESENT(start_date_)) THEN67 CALL cxios_set_context_start_date(context_hdl%daddr, start_date_)68 ENDIF69 70 IF (PRESENT(time_origin_)) THEN71 CALL cxios_set_context_time_origin(context_hdl%daddr, time_origin_)72 ENDIF73 74 IF (PRESENT(timestep_)) THEN75 CALL cxios_set_context_timestep(context_hdl%daddr, timestep_)76 48 ENDIF 77 49 … … 81 53 82 54 SUBROUTINE xios(get_context_attr) & 83 ( context_id, calendar_type, output_dir, start_date, time_origin, timestep)55 ( context_id, output_dir ) 84 56 85 57 IMPLICIT NONE 86 58 TYPE(txios(context)) :: context_hdl 87 59 CHARACTER(LEN=*), INTENT(IN) ::context_id 88 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: calendar_type89 60 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: output_dir 90 TYPE(txios(date)) , OPTIONAL, INTENT(OUT) :: start_date91 TYPE(txios(date)) , OPTIONAL, INTENT(OUT) :: time_origin92 TYPE(txios(duration)) , OPTIONAL, INTENT(OUT) :: timestep93 61 94 62 CALL xios(get_context_handle)(context_id,context_hdl) 95 63 CALL xios(get_context_attr_hdl_) & 96 ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep)64 ( context_hdl, output_dir ) 97 65 98 66 END SUBROUTINE xios(get_context_attr) 99 67 100 68 SUBROUTINE xios(get_context_attr_hdl) & 101 ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep)69 ( context_hdl, output_dir ) 102 70 103 71 IMPLICIT NONE 104 72 TYPE(txios(context)) , INTENT(IN) :: context_hdl 105 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: calendar_type106 73 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: output_dir 107 TYPE(txios(date)) , OPTIONAL, INTENT(OUT) :: start_date108 TYPE(txios(date)) , OPTIONAL, INTENT(OUT) :: time_origin109 TYPE(txios(duration)) , OPTIONAL, INTENT(OUT) :: timestep110 74 111 75 CALL xios(get_context_attr_hdl_) & 112 ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep)76 ( context_hdl, output_dir ) 113 77 114 78 END SUBROUTINE xios(get_context_attr_hdl) 115 79 116 80 SUBROUTINE xios(get_context_attr_hdl_) & 117 ( context_hdl, calendar_type_, output_dir_, start_date_, time_origin_, timestep_ )81 ( context_hdl, output_dir_ ) 118 82 119 83 IMPLICIT NONE 120 84 TYPE(txios(context)) , INTENT(IN) :: context_hdl 121 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: calendar_type_122 85 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: output_dir_ 123 TYPE(txios(date)) , OPTIONAL, INTENT(OUT) :: start_date_124 TYPE(txios(date)) , OPTIONAL, INTENT(OUT) :: time_origin_125 TYPE(txios(duration)) , OPTIONAL, INTENT(OUT) :: timestep_126 127 IF (PRESENT(calendar_type_)) THEN128 CALL cxios_get_context_calendar_type(context_hdl%daddr, calendar_type_, len(calendar_type_))129 ENDIF130 86 131 87 IF (PRESENT(output_dir_)) THEN 132 88 CALL cxios_get_context_output_dir(context_hdl%daddr, output_dir_, len(output_dir_)) 133 ENDIF134 135 IF (PRESENT(start_date_)) THEN136 CALL cxios_get_context_start_date(context_hdl%daddr, start_date_)137 ENDIF138 139 IF (PRESENT(time_origin_)) THEN140 CALL cxios_get_context_time_origin(context_hdl%daddr, time_origin_)141 ENDIF142 143 IF (PRESENT(timestep_)) THEN144 CALL cxios_get_context_timestep(context_hdl%daddr, timestep_)145 89 ENDIF 146 90 … … 150 94 151 95 SUBROUTINE xios(is_defined_context_attr) & 152 ( context_id, calendar_type, output_dir, start_date, time_origin, timestep)96 ( context_id, output_dir ) 153 97 154 98 IMPLICIT NONE 155 99 TYPE(txios(context)) :: context_hdl 156 100 CHARACTER(LEN=*), INTENT(IN) ::context_id 157 LOGICAL, OPTIONAL, INTENT(OUT) :: calendar_type158 LOGICAL(KIND=C_BOOL) :: calendar_type_tmp159 101 LOGICAL, OPTIONAL, INTENT(OUT) :: output_dir 160 102 LOGICAL(KIND=C_BOOL) :: output_dir_tmp 161 LOGICAL, OPTIONAL, INTENT(OUT) :: start_date162 LOGICAL(KIND=C_BOOL) :: start_date_tmp163 LOGICAL, OPTIONAL, INTENT(OUT) :: time_origin164 LOGICAL(KIND=C_BOOL) :: time_origin_tmp165 LOGICAL, OPTIONAL, INTENT(OUT) :: timestep166 LOGICAL(KIND=C_BOOL) :: timestep_tmp167 103 168 104 CALL xios(get_context_handle)(context_id,context_hdl) 169 105 CALL xios(is_defined_context_attr_hdl_) & 170 ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep)106 ( context_hdl, output_dir ) 171 107 172 108 END SUBROUTINE xios(is_defined_context_attr) 173 109 174 110 SUBROUTINE xios(is_defined_context_attr_hdl) & 175 ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep)111 ( context_hdl, output_dir ) 176 112 177 113 IMPLICIT NONE 178 114 TYPE(txios(context)) , INTENT(IN) :: context_hdl 179 LOGICAL, OPTIONAL, INTENT(OUT) :: calendar_type180 LOGICAL(KIND=C_BOOL) :: calendar_type_tmp181 115 LOGICAL, OPTIONAL, INTENT(OUT) :: output_dir 182 116 LOGICAL(KIND=C_BOOL) :: output_dir_tmp 183 LOGICAL, OPTIONAL, INTENT(OUT) :: start_date184 LOGICAL(KIND=C_BOOL) :: start_date_tmp185 LOGICAL, OPTIONAL, INTENT(OUT) :: time_origin186 LOGICAL(KIND=C_BOOL) :: time_origin_tmp187 LOGICAL, OPTIONAL, INTENT(OUT) :: timestep188 LOGICAL(KIND=C_BOOL) :: timestep_tmp189 117 190 118 CALL xios(is_defined_context_attr_hdl_) & 191 ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep)119 ( context_hdl, output_dir ) 192 120 193 121 END SUBROUTINE xios(is_defined_context_attr_hdl) 194 122 195 123 SUBROUTINE xios(is_defined_context_attr_hdl_) & 196 ( context_hdl, calendar_type_, output_dir_, start_date_, time_origin_, timestep_ )124 ( context_hdl, output_dir_ ) 197 125 198 126 IMPLICIT NONE 199 127 TYPE(txios(context)) , INTENT(IN) :: context_hdl 200 LOGICAL, OPTIONAL, INTENT(OUT) :: calendar_type_201 LOGICAL(KIND=C_BOOL) :: calendar_type__tmp202 128 LOGICAL, OPTIONAL, INTENT(OUT) :: output_dir_ 203 129 LOGICAL(KIND=C_BOOL) :: output_dir__tmp 204 LOGICAL, OPTIONAL, INTENT(OUT) :: start_date_205 LOGICAL(KIND=C_BOOL) :: start_date__tmp206 LOGICAL, OPTIONAL, INTENT(OUT) :: time_origin_207 LOGICAL(KIND=C_BOOL) :: time_origin__tmp208 LOGICAL, OPTIONAL, INTENT(OUT) :: timestep_209 LOGICAL(KIND=C_BOOL) :: timestep__tmp210 211 IF (PRESENT(calendar_type_)) THEN212 calendar_type__tmp=cxios_is_defined_context_calendar_type(context_hdl%daddr)213 calendar_type_=calendar_type__tmp214 ENDIF215 130 216 131 IF (PRESENT(output_dir_)) THEN 217 132 output_dir__tmp=cxios_is_defined_context_output_dir(context_hdl%daddr) 218 133 output_dir_=output_dir__tmp 219 ENDIF220 221 IF (PRESENT(start_date_)) THEN222 start_date__tmp=cxios_is_defined_context_start_date(context_hdl%daddr)223 start_date_=start_date__tmp224 ENDIF225 226 IF (PRESENT(time_origin_)) THEN227 time_origin__tmp=cxios_is_defined_context_time_origin(context_hdl%daddr)228 time_origin_=time_origin__tmp229 ENDIF230 231 IF (PRESENT(timestep_)) THEN232 timestep__tmp=cxios_is_defined_context_timestep(context_hdl%daddr)233 timestep_=timestep__tmp234 134 ENDIF 235 135 -
XIOS/trunk/src/node/context.cpp
r545 r549 17 17 namespace xios { 18 18 19 shared_ptr<CContextGroup> CContext::root 19 shared_ptr<CContextGroup> CContext::root; 20 20 21 21 /// ////////////////////// Définitions ////////////////////// /// … … 33 33 CContext::~CContext(void) 34 34 { 35 if (hasClient) delete client 36 if (hasServer) delete server 35 if (hasClient) delete client; 36 if (hasServer) delete server; 37 37 } 38 38 … … 50 50 CContextGroup* CContext::getRoot(void) 51 51 { 52 if (root.get()==NULL) root=shared_ptr<CContextGroup>(new CContextGroup(xml::CXMLNode::GetRootName())) 52 if (root.get()==NULL) root=shared_ptr<CContextGroup>(new CContextGroup(xml::CXMLNode::GetRootName())); 53 53 return root.get(); 54 54 } … … 73 73 { 74 74 this->calendar = newCalendar; 75 calendar_type.fromString(this->calendar->getId());76 start_date.setValue(this->calendar->getInitDate());77 }78 79 //----------------------------------------------------------------80 //! Process all information of calendar81 void CContext::solveCalendar(void)82 {83 if (calendar_type.isEmpty())84 ERROR(" CContext::solveCalendar(void)",85 << "[ context id = " << this->getId() << " ] "86 << "Impossible to define a calendar: the calendar type is missing.");87 if (start_date.isEmpty())88 ERROR(" CContext::solveCalendar(void)",89 << "[ context id = " << this->getId() << " ] "90 << "Impossible to define a calendar: the start date is missing.");91 if (timestep.isEmpty())92 ERROR(" CContext::solveCalendar(void)",93 << "[ context id = " << this->getId() << " ] "94 << "Impossible to define a calendar: the timestep is missing.");95 96 if (this->calendar)97 {98 if (this->calendar->getId() != calendar_type.getStringValue()99 || this->calendar->getInitDate() != start_date.getValue()100 || (time_origin.isEmpty() && this->calendar->getTimeOrigin() != start_date.getValue())101 || (!time_origin.isEmpty() && this->calendar->getTimeOrigin() != time_origin.getValue())102 || this->calendar->getTimeStep() != timestep.getValue())103 ERROR(" CContext::solveCalendar(void)",104 << "[ context id = " << this->getId() << " ] "105 << "Impossible to define a calendar again with new parameters.");106 return;107 }108 109 #define DECLARE_CALENDAR(MType, eType) \110 if (calendar_type.getValue() == eType) \111 { \112 if (time_origin.isEmpty()) \113 this->calendar = boost::shared_ptr<CCalendar> \114 (new C##MType##Calendar(start_date.getValue())); \115 else this->calendar = boost::shared_ptr<CCalendar> \116 (new C##MType##Calendar(start_date.getValue(), time_origin.getValue())); \117 \118 if (!start_date.getValue().setRelCalendar(*this->calendar)) \119 ERROR("CContext::solveCalendar(void)", \120 "start_date: Bad format or date not conform to the calendar"); \121 if (!time_origin.getValue().setRelCalendar(*this->calendar)) \122 ERROR("CContext::solveCalendar(void)", \123 "time_origin: Bad format or date not conform to the calendar"); \124 \125 this->calendar->setTimeStep(this->timestep.getValue()); \126 \127 return; \128 }129 #include "calendar_type.conf"130 #undef DECLARE_CALENDAR131 132 ERROR("CContext::solveCalendar(void)",133 << "[ calendar_type = " << calendar_type.getStringValue() << " ] "134 << "The calendar is not properly handled!");135 75 } 136 76 … … 182 122 #define DECLARE_NODE(Name_, name_) \ 183 123 if (name.compare(C##Name_##Definition::GetDefName()) == 0) \ 184 { C##Name_##Definition::create(C##Name_##Definition::GetDefName()) -> parse(node) 124 { C##Name_##Definition::create(C##Name_##Definition::GetDefName()) -> parse(node); continue; } 185 125 #define DECLARE_NODE_PAR(Name_, name_) 186 126 #include "node_type.conf" … … 200 140 void CContext::ShowTree(StdOStream & out) 201 141 { 202 StdString currentContextId = CContext::getCurrent() -> getId() 142 StdString currentContextId = CContext::getCurrent() -> getId(); 203 143 std::vector<CContext*> def_vector = 204 144 CContext::getRoot()->getChildList(); … … 285 225 // { 286 226 // if (!this->hasId()) return; 287 // vector<CField*> allField = CField::getAll() 227 // vector<CField*> allField = CField::getAll(); 288 228 //// = CObjectTemplate<CField>::GetAllVectobject(this->getId()); 289 229 // std::vector<CField*>::iterator … … 301 241 void CContext::CleanTree(void) 302 242 { 303 #define DECLARE_NODE(Name_, name_) C##Name_## Group::ClearAllAttributes();243 #define DECLARE_NODE(Name_, name_) C##Name_##Definition::ClearAllAttributes(); 304 244 #define DECLARE_NODE_PAR(Name_, name_) 305 245 #include "node_type.conf" … … 310 250 void CContext::initClient(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtServer) 311 251 { 312 hasClient=true 313 client = new CContextClient(this,intraComm, interComm, cxtServer) 252 hasClient=true; 253 client = new CContextClient(this,intraComm, interComm, cxtServer); 314 254 } 315 255 … … 325 265 bool CContext::isInitialized(void) 326 266 { 327 return hasClient 267 return hasClient; 328 268 } 329 269 … … 331 271 void CContext::initServer(MPI_Comm intraComm,MPI_Comm interComm) 332 272 { 333 hasServer=true 334 server = new CContextServer(this,intraComm,interComm) 273 hasServer=true; 274 server = new CContextServer(this,intraComm,interComm); 335 275 } 336 276 … … 338 278 bool CContext::eventLoop(void) 339 279 { 340 return server->eventLoop() 280 return server->eventLoop(); 341 281 } 342 282 … … 346 286 if (hasClient && !hasServer) 347 287 { 348 client->finalize() 288 client->finalize(); 349 289 } 350 290 if (hasServer) 351 291 { 352 closeAllFile() 292 closeAllFile(); 353 293 } 354 294 } … … 385 325 this->sendAllAttributesToServer(); 386 326 327 // Send all attributes of current calendar 328 CCalendarWrapper::get(CCalendarWrapper::GetDefName())->sendAllAttributesToServer(); 329 387 330 // We have enough information to send to server 388 331 // First of all, send all enabled files … … 428 371 //// this->findEnabledFiles(); 429 372 // 430 // this->processEnabledFiles() 373 // this->processEnabledFiles(); 431 374 // 432 375 // this->solveAllGridRef(); … … 445 388 // 446 389 // 447 // this->processEnabledFiles() 390 // this->processEnabledFiles(); 448 391 449 392 /* … … 464 407 if (hasClient && !hasServer) CleanTree(); // Only on client side?? 465 408 // if (hasClient) CleanTree(); 466 if (hasClient) sendCreateFileHeader() 409 if (hasClient) sendCreateFileHeader(); 467 410 } 468 411 … … 523 466 524 467 // Résolution des héritages par référence au niveau des fichiers. 525 const vector<CFile*> allFiles=CFile::getAll() 468 const vector<CFile*> allFiles=CFile::getAll(); 526 469 const vector<CGrid*> allGrids= CGrid::getAll(); 527 470 … … 580 523 { 581 524 582 if (SuperClass::dispatchEvent(event)) return true 525 if (SuperClass::dispatchEvent(event)) return true; 583 526 else 584 527 { … … 586 529 { 587 530 case EVENT_ID_CLOSE_DEFINITION : 588 recvCloseDefinition(event) 589 return true 590 break 531 recvCloseDefinition(event); 532 return true; 533 break; 591 534 case EVENT_ID_UPDATE_CALENDAR : 592 recvUpdateCalendar(event) 593 return true 594 break 535 recvUpdateCalendar(event); 536 return true; 537 break; 595 538 case EVENT_ID_CREATE_FILE_HEADER : 596 recvCreateFileHeader(event) 597 return true 598 break 539 recvCreateFileHeader(event); 540 return true; 541 break; 599 542 case EVENT_ID_POST_PROCESS: 600 recvPostProcessing(event) 601 return true 602 break 543 recvPostProcessing(event); 544 return true; 545 break; 603 546 default : 604 547 ERROR("bool CContext::dispatchEvent(CEventServer& event)", 605 <<"Unknown Event") 606 return false 548 <<"Unknown Event"); 549 return false; 607 550 } 608 551 } … … 612 555 void CContext::sendCloseDefinition(void) 613 556 { 614 CEventClient event(getType(),EVENT_ID_CLOSE_DEFINITION) 557 CEventClient event(getType(),EVENT_ID_CLOSE_DEFINITION); 615 558 if (client->isServerLeader()) 616 559 { 617 CMessage msg 618 msg<<this->getIdServer() 619 event.push(client->getServerLeader(),1,msg) 620 client->sendEvent(event) 621 } 622 else client->sendEvent(event) 560 CMessage msg; 561 msg<<this->getIdServer(); 562 event.push(client->getServerLeader(),1,msg); 563 client->sendEvent(event); 564 } 565 else client->sendEvent(event); 623 566 } 624 567 … … 629 572 CBufferIn* buffer=event.subEvents.begin()->buffer; 630 573 string id; 631 *buffer>>id 574 *buffer>>id; 632 575 get(id)->closeDefinition(); 633 576 } … … 638 581 if (!hasServer) 639 582 { 640 CEventClient event(getType(),EVENT_ID_UPDATE_CALENDAR) 583 CEventClient event(getType(),EVENT_ID_UPDATE_CALENDAR); 641 584 if (client->isServerLeader()) 642 585 { 643 CMessage msg 644 msg<<this->getIdServer()<<step 645 event.push(client->getServerLeader(),1,msg) 646 client->sendEvent(event) 586 CMessage msg; 587 msg<<this->getIdServer()<<step; 588 event.push(client->getServerLeader(),1,msg); 589 client->sendEvent(event); 647 590 } 648 else client->sendEvent(event) 591 else client->sendEvent(event); 649 592 } 650 593 } … … 656 599 CBufferIn* buffer=event.subEvents.begin()->buffer; 657 600 string id; 658 *buffer>>id 659 get(id)->recvUpdateCalendar(*buffer) 601 *buffer>>id; 602 get(id)->recvUpdateCalendar(*buffer); 660 603 } 661 604 … … 663 606 void CContext::recvUpdateCalendar(CBufferIn& buffer) 664 607 { 665 int step 666 buffer>>step 667 updateCalendar(step) 608 int step; 609 buffer>>step; 610 updateCalendar(step); 668 611 } 669 612 … … 671 614 void CContext::sendCreateFileHeader(void) 672 615 { 673 CEventClient event(getType(),EVENT_ID_CREATE_FILE_HEADER) 616 CEventClient event(getType(),EVENT_ID_CREATE_FILE_HEADER); 674 617 if (client->isServerLeader()) 675 618 { 676 CMessage msg 677 msg<<this->getIdServer() 678 event.push(client->getServerLeader(),1,msg) 679 client->sendEvent(event) 680 } 681 else client->sendEvent(event) 619 CMessage msg; 620 msg<<this->getIdServer(); 621 event.push(client->getServerLeader(),1,msg); 622 client->sendEvent(event); 623 } 624 else client->sendEvent(event); 682 625 } 683 626 … … 687 630 CBufferIn* buffer=event.subEvents.begin()->buffer; 688 631 string id; 689 *buffer>>id 690 get(id)->recvCreateFileHeader(*buffer) 632 *buffer>>id; 633 get(id)->recvCreateFileHeader(*buffer); 691 634 } 692 635 … … 694 637 void CContext::recvCreateFileHeader(CBufferIn& buffer) 695 638 { 696 createFileHeader() 639 createFileHeader(); 697 640 } 698 641 … … 702 645 if (!hasServer) 703 646 { 704 CEventClient event(getType(),EVENT_ID_POST_PROCESS) 647 CEventClient event(getType(),EVENT_ID_POST_PROCESS); 705 648 if (client->isServerLeader()) 706 649 { 707 CMessage msg 650 CMessage msg; 708 651 msg<<this->getIdServer(); 709 event.push(client->getServerLeader(),1,msg) 710 client->sendEvent(event) 652 event.push(client->getServerLeader(),1,msg); 653 client->sendEvent(event); 711 654 } 712 else client->sendEvent(event) 655 else client->sendEvent(event); 713 656 } 714 657 } … … 726 669 void CContext::recvPostProcessing(CBufferIn& buffer) 727 670 { 671 CCalendarWrapper::get(CCalendarWrapper::GetDefName())->createCalendar(); 728 672 postProcessing(); 729 673 // std::cout << "server context " << *this << std::endl; … … 751 695 if (isPostProcessed) return; 752 696 753 // Solve calendar for both side: client and server 754 this->solveCalendar(); 697 // Make sure the calendar was correctly created 698 if (!calendar) 699 ERROR("CContext::postProcessing()", << "A calendar must be defined for the context \"" << getId() << "!\"") 700 else if (calendar->getTimeStep() == NoneDu) 701 ERROR("CContext::postProcessing()", << "A timestep must be defined for the context \"" << getId() << "!\"") 755 702 756 703 // Find all inheritance in xml structure … … 932 879 void CContext::updateCalendar(int step) 933 880 { 934 info(50)<<"updateCalendar : before : "<<calendar->getCurrentDate()<<endl 935 calendar->update(step) 936 info(50)<<"updateCalendar : after : "<<calendar->getCurrentDate()<<endl 881 info(50)<<"updateCalendar : before : "<<calendar->getCurrentDate()<<endl; 882 calendar->update(step); 883 info(50)<<"updateCalendar : after : "<<calendar->getCurrentDate()<<endl; 937 884 } 938 885 … … 940 887 void CContext::createFileHeader(void ) 941 888 { 942 vector<CFile*>::const_iterator it 889 vector<CFile*>::const_iterator it; 943 890 944 891 for (it=enabledFiles.begin(); it != enabledFiles.end(); it++) … … 951 898 CContext* CContext::getCurrent(void) 952 899 { 953 return CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()).get() 900 return CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()).get(); 954 901 } 955 902 … … 971 918 CContext* CContext::create(const StdString& id) 972 919 { 973 CContext::setCurrent(id) 920 CContext::setCurrent(id); 974 921 975 922 bool hasctxt = CContext::has(id); 976 923 CContext* context = CObjectFactory::CreateObject<CContext>(id).get(); 977 getRoot() 924 getRoot(); 978 925 if (!hasctxt) CGroupFactory::AddChild(root, context->getShared()); 979 926 -
XIOS/trunk/src/node/context.hpp
r511 r549 5 5 #include "xmlioserver_spl.hpp" 6 6 //#include "node_type.hpp" 7 #include "calendar .hpp"7 #include "calendar_wrapper.hpp" 8 8 9 9 #include "declare_group.hpp" … … 16 16 17 17 namespace xios { 18 class CContextClient 19 class CContextServer 18 class CContextClient; 19 class CContextServer; 20 20 21 21 … … 51 51 EVENT_ID_CREATE_FILE_HEADER,EVENT_ID_CONTEXT_FINALIZE, 52 52 EVENT_ID_POST_PROCESS 53 } 53 }; 54 54 55 55 /// typedef /// … … 87 87 public : 88 88 // Initialize server or client 89 void initServer(MPI_Comm intraComm, MPI_Comm interComm) 90 void initClient(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtServer=0) 91 bool isInitialized(void) 89 void initServer(MPI_Comm intraComm, MPI_Comm interComm); 90 void initClient(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtServer=0); 91 bool isInitialized(void); 92 92 93 93 // Put sever or client into loop state 94 bool eventLoop(void) ; 95 bool serverLoop(void) ; 96 void clientLoop(void) ; 97 98 // Process all information of calendar 99 void solveCalendar(void); 94 bool eventLoop(void); 95 bool serverLoop(void); 96 void clientLoop(void); 100 97 101 98 // Finalize a context 102 void finalize(void) 103 void closeDefinition(void) 99 void finalize(void); 100 void closeDefinition(void); 104 101 105 102 // Some functions to process context 106 103 void findAllEnabledFields(void); 107 void processEnabledFiles(void) 108 void solveAllInheritance(bool apply=true) 104 void processEnabledFiles(void); 105 void solveAllInheritance(bool apply=true); 109 106 void findEnabledFiles(void); 110 void closeAllFile(void) 111 void updateCalendar(int step) 112 void createFileHeader(void ) 107 void closeAllFile(void); 108 void updateCalendar(int step); 109 void createFileHeader(void ); 113 110 void solveAllRefOfEnabledFields(bool sendToServer); 114 111 void buildAllExpressionOfEnabledFields(); … … 119 116 120 117 // Send context close definition 121 void sendCloseDefinition(void) 118 void sendCloseDefinition(void); 122 119 // There are something to send on closing context defintion 123 void sendUpdateCalendar(int step) 124 void sendCreateFileHeader(void) 120 void sendUpdateCalendar(int step); 121 void sendCreateFileHeader(void); 125 122 void sendEnabledFiles(); 126 123 void sendEnabledFields(); … … 132 129 133 130 // Client side: Receive and process messages 134 static void recvUpdateCalendar(CEventServer& event) 135 void recvUpdateCalendar(CBufferIn& buffer) 136 static void recvCloseDefinition(CEventServer& event) 137 static void recvCreateFileHeader(CEventServer& event) 138 void recvCreateFileHeader(CBufferIn& buffer) 131 static void recvUpdateCalendar(CEventServer& event); 132 void recvUpdateCalendar(CBufferIn& buffer); 133 static void recvCloseDefinition(CEventServer& event); 134 static void recvCreateFileHeader(CEventServer& event); 135 void recvCreateFileHeader(CBufferIn& buffer); 139 136 static void recvSolveInheritanceContext(CEventServer& event); 140 137 void recvSolveInheritanceContext(CBufferIn& buffer); … … 143 140 144 141 // dispatch event 145 static bool dispatchEvent(CEventServer& event) 142 static bool dispatchEvent(CEventServer& event); 146 143 147 144 public: … … 191 188 192 189 // Context root 193 static shared_ptr<CContextGroup> root 190 static shared_ptr<CContextGroup> root; 194 191 195 192 // Determine context on client or not 196 bool hasClient 193 bool hasClient; 197 194 198 195 // Determine context on server or not 199 bool hasServer 196 bool hasServer; 200 197 201 198 // Concrete context server 202 CContextServer* server 199 CContextServer* server; 203 200 204 201 // Concrete contex client 205 CContextClient* client 202 CContextClient* client; 206 203 207 204 private: -
XIOS/trunk/src/node/node_enum.hpp
r501 r549 17 17 eGrid,gGrid, 18 18 eVariable,gVariable, 19 eContext,gContext 19 eContext,gContext, 20 eCalendarWrapper 20 21 21 22 //#include "node_type.conf" -
XIOS/trunk/src/object_factory_decl.cpp
r501 r549 14 14 template bool CObjectFactory::HasObject<U>(const StdString& context,const StdString & id); \ 15 15 template boost::shared_ptr<U> CObjectFactory::CreateObject<U>(const StdString & id ); \ 16 template StdString CObjectFactory::GenUId<U>(void) ;17 16 template StdString CObjectFactory::GenUId<U>(void); 17 18 18 macro(CField) 19 19 macro(CFile) … … 22 22 macro(CDomain) 23 23 macro(CContext) 24 macro(CCalendarWrapper) 24 25 macro(CVariable) 25 26 -
XIOS/trunk/src/object_template_decl.cpp
r501 r549 12 12 namespace xios 13 13 { 14 template class CObjectTemplate<CContext> ; 15 template class CObjectTemplate<CField> ; 16 template class CObjectTemplate<CFile> ; 17 template class CObjectTemplate<CDomain> ; 18 template class CObjectTemplate<CGrid> ; 19 template class CObjectTemplate<CAxis> ; 20 template class CObjectTemplate<CVariable> ; 21 22 template class CObjectTemplate<CContextGroup> ; 23 template class CObjectTemplate<CFieldGroup> ; 24 template class CObjectTemplate<CFileGroup> ; 25 template class CObjectTemplate<CDomainGroup> ; 26 template class CObjectTemplate<CGridGroup> ; 27 template class CObjectTemplate<CAxisGroup> ; 28 template class CObjectTemplate<CVariableGroup> ; 29 } 14 template class CObjectTemplate<CContext>; 15 template class CObjectTemplate<CCalendarWrapper>; 16 template class CObjectTemplate<CField>; 17 template class CObjectTemplate<CFile>; 18 template class CObjectTemplate<CDomain>; 19 template class CObjectTemplate<CGrid>; 20 template class CObjectTemplate<CAxis>; 21 template class CObjectTemplate<CVariable>; 22 23 template class CObjectTemplate<CContextGroup>; 24 template class CObjectTemplate<CFieldGroup>; 25 template class CObjectTemplate<CFileGroup>; 26 template class CObjectTemplate<CDomainGroup>; 27 template class CObjectTemplate<CGridGroup>; 28 template class CObjectTemplate<CAxisGroup>; 29 template class CObjectTemplate<CVariableGroup>; 30 } -
XIOS/trunk/src/object_template_impl.hpp
r532 r549 141 141 void CObjectTemplate<T>::solveDescInheritance(bool apply, const CAttributeMap * const parent) 142 142 { 143 SuperClassMap::setAttributes(parent, apply); 143 if (parent != NULL) 144 SuperClassMap::setAttributes(parent, apply); 144 145 } 145 146 … … 149 150 void CObjectTemplate<T>::ClearAllAttributes(void) 150 151 { 151 vector<T*> avect = CObjectTemplate<T>::getAll() 152 vector<T*> avect = CObjectTemplate<T>::getAll(); 152 153 typename vector<T*>::iterator 153 154 it = avect.begin(), end = avect.end(); … … 176 177 { 177 178 CAttributeMap & attrMap = *this; 178 CAttribute* attr=attrMap[id] 179 sendAttributToServer(*attr) 179 CAttribute* attr=attrMap[id]; 180 sendAttributToServer(*attr); 180 181 } 181 182 … … 183 184 void CObjectTemplate<T>::sendAttributToServer(CAttribute& attr) 184 185 { 185 CContext* context=CContext::getCurrent() 186 CContext* context=CContext::getCurrent(); 186 187 187 188 if (!context->hasServer) 188 189 { 189 CContextClient* client=context->client 190 191 CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE) 190 CContextClient* client=context->client; 191 192 CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE); 192 193 if (client->isServerLeader()) 193 194 { 194 CMessage msg 195 // msg<<this->getId() 195 CMessage msg; 196 // msg<<this->getId(); 196 197 msg<<this->getIdServer(); 197 msg<<attr.getName() 198 msg<<attr 199 event.push(client->getServerLeader(),1,msg) 200 client->sendEvent(event) 198 msg<<attr.getName(); 199 msg<<attr; 200 event.push(client->getServerLeader(),1,msg); 201 client->sendEvent(event); 201 202 } 202 else client->sendEvent(event) 203 else client->sendEvent(event); 203 204 } 204 205 … … 211 212 CBufferIn* buffer=event.subEvents.begin()->buffer; 212 213 string id,attrId; 213 *buffer>>id 214 *buffer>>id; 214 215 CAttributeMap & attrMap = *get(id); 215 *buffer>>attrId 216 CAttribute* attr=attrMap[attrId] 217 info(50)<<"attribut recu "<<attrId<<" " 218 if (attr->isEmpty()) info(50)<<"--> empty"<<endl 219 else info(50) /*<attr->getValue()*/<<endl 220 *buffer>>*attr 221 info(50)<<"attribut recu "<<attrId<<" " 222 if (attr->isEmpty()) info(50)<<"--> empty"<<endl 223 else info(50) /*attr->getValue()*/<<endl 216 *buffer>>attrId; 217 CAttribute* attr=attrMap[attrId]; 218 info(50)<<"attribut recu "<<attrId<<" "; 219 if (attr->isEmpty()) info(50)<<"--> empty"<<endl; 220 else info(50) /*<attr->getValue()*/<<endl; 221 *buffer>>*attr; 222 info(50)<<"attribut recu "<<attrId<<" "; 223 if (attr->isEmpty()) info(50)<<"--> empty"<<endl; 224 else info(50) /*attr->getValue()*/<<endl; 224 225 } 225 226 … … 230 231 { 231 232 case EVENT_ID_SEND_ATTRIBUTE : 232 recvAttributFromClient(event) 233 return true 234 break 233 recvAttributFromClient(event); 234 return true; 235 break; 235 236 236 237 default : 237 return false 238 return false; 238 239 // ERROR("void CObjectTemplate<T>::recvEvent(CEventServer& event)", 239 // <<"Unknown Event") 240 // <<"Unknown Event"); 240 241 } 241 242 } … … 244 245 bool CObjectTemplate<T>::has(const string & id) 245 246 { 246 return CObjectFactory::HasObject<T>(id) 247 return CObjectFactory::HasObject<T>(id); 247 248 } 248 249 … … 250 251 bool CObjectTemplate<T>::has(const string& contextId, const string & id) 251 252 { 252 return CObjectFactory::HasObject<T>(contextId,id) 253 return CObjectFactory::HasObject<T>(contextId,id); 253 254 } 254 255 … … 256 257 T* CObjectTemplate<T>::get(const string & id) 257 258 { 258 return CObjectFactory::GetObject<T>(id).get() 259 return CObjectFactory::GetObject<T>(id).get(); 259 260 } 260 261 … … 262 263 T* CObjectTemplate<T>::get(const T* ptr) 263 264 { 264 return CObjectFactory::GetObject<T>(ptr).get() 265 return CObjectFactory::GetObject<T>(ptr).get(); 265 266 } 266 267 … … 268 269 shared_ptr<T> CObjectTemplate<T>::getShared(const T* ptr) 269 270 { 270 return CObjectFactory::GetObject<T>(ptr) 271 return CObjectFactory::GetObject<T>(ptr); 271 272 } 272 273 … … 274 275 shared_ptr<T> CObjectTemplate<T>::getShared(void) 275 276 { 276 return CObjectFactory::GetObject<T>((T*)this) 277 return CObjectFactory::GetObject<T>((T*)this); 277 278 } 278 279 … … 281 282 { 282 283 const vector< shared_ptr<T> >& shared_vect= CObjectFactory::GetObjectVector<T>(); 283 vector<T*> vect 284 vector<T*> vect; 284 285 285 286 typename vector<shared_ptr<T> >::const_iterator it; 286 for(it=shared_vect.begin();it!=shared_vect.end();++it) vect.push_back(it->get()) 287 return vect 287 for(it=shared_vect.begin();it!=shared_vect.end();++it) vect.push_back(it->get()); 288 return vect; 288 289 } 289 290 … … 292 293 { 293 294 const vector< shared_ptr<T> >& shared_vect= CObjectFactory::GetObjectVector<T>(id); 294 vector<T*> vect 295 vector<T*> vect; 295 296 296 297 typename vector<shared_ptr<T> >::const_iterator it; 297 for(it=shared_vect.begin();it!=shared_vect.end();++it) vect.push_back(it->get()) 298 return vect 298 for(it=shared_vect.begin();it!=shared_vect.end();++it) vect.push_back(it->get()); 299 return vect; 299 300 } 300 301 … … 302 303 T* CObjectTemplate<T>::get(const string& contextId, const string & id) 303 304 { 304 return CObjectFactory::GetObject<T>(contextId,id).get() 305 return CObjectFactory::GetObject<T>(contextId,id).get(); 305 306 } 306 307 … … 308 309 T* CObjectTemplate<T>::create(const string & id) 309 310 { 310 return CObjectFactory::CreateObject<T>(id).get() 311 return CObjectFactory::CreateObject<T>(id).get(); 311 312 } ///-------------------------------------------------------------- 312 313 … … 314 315 T* CObjectTemplate<T>::get(void) 315 316 { 316 return CObjectFactory::GetObject<T>((T*)this).get() 317 return CObjectFactory::GetObject<T>((T*)this).get(); 317 318 } 318 319 … … 320 321 void CObjectTemplate<T>::generateCInterface(ostream& oss) 321 322 { 322 string className=getName() 323 int found=className. find_first_of("_");324 if (found!=string::npos) className.replace(found,1,0,'x') 325 326 oss<<"/* ************************************************************************** *"<<iendl 327 oss<<" * Interface auto generated - do not modify *"<<iendl 323 string className=getName(); 324 int found=className.rfind("_group"); 325 if (found!=string::npos) className.replace(found,1,0,'x'); 326 327 oss<<"/* ************************************************************************** *"<<iendl; 328 oss<<" * Interface auto generated - do not modify *"<<iendl; 328 329 oss<<" * ************************************************************************** */"<<iendl; 329 oss<<iendl 330 oss<<"#include <boost/multi_array.hpp>"<<iendl 331 oss<<"#include <boost/shared_ptr.hpp>"<<iendl 330 oss<<iendl; 331 oss<<"#include <boost/multi_array.hpp>"<<iendl; 332 oss<<"#include <boost/shared_ptr.hpp>"<<iendl; 332 333 oss<<"#include \"xmlioserver.hpp\""<<iendl; 333 oss<<"#include \"attribute_template.hpp\""<<iendl 334 oss<<"#include \"attribute_template.hpp\""<<iendl; 334 335 oss<<"#include \"object_template.hpp\""<<iendl; 335 oss<<"#include \"group_template.hpp\""<<iendl 336 oss<<"#include \"icutil.hpp\""<<iendl 337 oss<<"#include \"icdate.hpp\""<<iendl 338 oss<<"#include \"timer.hpp\""<<iendl 339 oss<<"#include \"node_type.hpp\""<<iendl 340 oss<<iendl 341 oss<<"extern \"C\""<<iendl 342 oss<<"{"<<iendl++ 336 oss<<"#include \"group_template.hpp\""<<iendl; 337 oss<<"#include \"icutil.hpp\""<<iendl; 338 oss<<"#include \"icdate.hpp\""<<iendl; 339 oss<<"#include \"timer.hpp\""<<iendl; 340 oss<<"#include \"node_type.hpp\""<<iendl; 341 oss<<iendl; 342 oss<<"extern \"C\""<<iendl; 343 oss<<"{"<<iendl++; 343 344 oss<<"typedef xios::"<<getStrType<T>()<<"* "<<className<<"_Ptr;"<<iendl; 344 oss<<iendl 345 SuperClassMap::generateCInterface(oss,className) 346 oss<<iendl-- 347 oss<<"}"<<iendl 345 oss<<iendl; 346 SuperClassMap::generateCInterface(oss,className); 347 oss<<iendl--; 348 oss<<"}"<<iendl; 348 349 } 349 350 … … 351 352 void CObjectTemplate<T>::generateFortran2003Interface(ostream& oss) 352 353 { 353 string className=getName() ; 354 int found=className.find_first_of("_") ; 355 if (found!=string::npos) className.replace(found,1,0,'x') ; 356 357 oss<<"! * ************************************************************************** *"<<iendl ; 358 oss<<"! * Interface auto generated - do not modify *"<<iendl ; 354 string className=getName(); 355 int found=className.rfind("_group"); 356 if (found!=string::npos) className.replace(found,1,0,'x'); 357 359 358 oss<<"! * ************************************************************************** *"<<iendl; 360 oss<<"#include \"../fortran/xios_fortran_prefix.hpp\""<<iendl ; 361 oss<<iendl ; 362 oss<<"MODULE "<<className<<"_interface_attr"<<iendl++ ; 363 oss<<"USE, INTRINSIC :: ISO_C_BINDING"<<iendl ; 364 oss<<iendl ; 365 oss<<"INTERFACE ! Do not call directly / interface FORTRAN 2003 <-> C99"<<iendl++ ; 366 oss<<iendl ; 367 oss<<iendl ; 368 SuperClassMap::generateFortran2003Interface(oss,className) ; 369 oss<<"END INTERFACE"<<iendl-- ; 370 oss<<iendl-- ; 371 oss<<"END MODULE "<<className<<"_interface_attr"<<iendl ; 359 oss<<"! * Interface auto generated - do not modify *"<<iendl; 360 oss<<"! * ************************************************************************** *"<<iendl; 361 oss<<"#include \"../fortran/xios_fortran_prefix.hpp\""<<iendl; 362 oss<<iendl; 363 oss<<"MODULE "<<className<<"_interface_attr"<<iendl++; 364 oss<<"USE, INTRINSIC :: ISO_C_BINDING"<<iendl; 365 oss<<iendl; 366 oss<<"INTERFACE ! Do not call directly / interface FORTRAN 2003 <-> C99"<<iendl++; 367 oss<<iendl; 368 oss<<iendl; 369 SuperClassMap::generateFortran2003Interface(oss,className); 370 oss<<"END INTERFACE"<<iendl--; 371 oss<<iendl--; 372 oss<<"END MODULE "<<className<<"_interface_attr"<<iendl; 372 373 } 373 374 … … 375 376 void CObjectTemplate<T>::generateFortranInterface(ostream& oss) 376 377 { 377 string className=getName() 378 int found=className. find_first_of('_');379 if (found!=string::npos) className.erase(found,1) 378 string className=getName(); 379 int found=className.rfind("_group"); 380 if (found!=string::npos) className.erase(found,1); 380 381 string superClassName=getName(); 381 found=superClassName.find("_group") ; 382 if (found!=string::npos) superClassName.erase(found,6) ; 383 384 oss<<"! * ************************************************************************** *"<<iendl ; 385 oss<<"! * Interface auto generated - do not modify *"<<iendl ; 382 found=superClassName.find("_group"); 383 if (found!=string::npos) superClassName.erase(found,6); 384 386 385 oss<<"! * ************************************************************************** *"<<iendl; 387 oss<<"#include \"xios_fortran_prefix.hpp\""<<iendl ; 388 oss<<iendl ; 389 oss<<"MODULE i"<<className<<"_attr"<<iendl++ ; 390 oss<<"USE, INTRINSIC :: ISO_C_BINDING"<<iendl ; 391 oss<<"USE i"<<superClassName<<iendl ; 392 oss<<"USE "<<className<<"_interface_attr"<<iendl ; 393 // oss<<"TYPE txios("<<className<<")"<<iendl ; 394 // oss<<" INTEGER(kind = C_INTPTR_T) :: daddr"<<iendl ; 395 // oss<<"END TYPE txios("<<className<<")"<<iendl ; 396 oss<<iendl-- ; 397 oss<<"CONTAINS"<<iendl++ ; 398 oss<<iendl ; 399 SuperClassMap::generateFortranInterface_id(oss,className) ; 400 oss<<iendl ; 401 SuperClassMap::generateFortranInterface_hdl(oss,className) ; 402 oss<<iendl ; 403 SuperClassMap::generateFortranInterface_hdl_(oss,className) ; 404 oss<<iendl ; 405 SuperClassMap::generateFortranInterfaceGet_id(oss,className) ; 406 oss<<iendl ; 407 SuperClassMap::generateFortranInterfaceGet_hdl(oss,className) ; 408 oss<<iendl ; 409 SuperClassMap::generateFortranInterfaceGet_hdl_(oss,className) ; 410 oss<<iendl ; 411 SuperClassMap::generateFortranInterfaceIsDefined_id(oss,className) ; 412 oss<<iendl ; 413 SuperClassMap::generateFortranInterfaceIsDefined_hdl(oss,className) ; 414 oss<<iendl ; 415 SuperClassMap::generateFortranInterfaceIsDefined_hdl_(oss,className) ; 416 oss<<iendl-- ; 417 oss<<"END MODULE i"<<className<<"_attr"<<iendl ; 386 oss<<"! * Interface auto generated - do not modify *"<<iendl; 387 oss<<"! * ************************************************************************** *"<<iendl; 388 oss<<"#include \"xios_fortran_prefix.hpp\""<<iendl; 389 oss<<iendl; 390 oss<<"MODULE i"<<className<<"_attr"<<iendl++; 391 oss<<"USE, INTRINSIC :: ISO_C_BINDING"<<iendl; 392 oss<<"USE i"<<superClassName<<iendl; 393 oss<<"USE "<<className<<"_interface_attr"<<iendl; 394 // oss<<"TYPE txios("<<className<<")"<<iendl; 395 // oss<<" INTEGER(kind = C_INTPTR_T) :: daddr"<<iendl; 396 // oss<<"END TYPE txios("<<className<<")"<<iendl; 397 oss<<iendl--; 398 oss<<"CONTAINS"<<iendl++; 399 oss<<iendl; 400 SuperClassMap::generateFortranInterface_id(oss,className); 401 oss<<iendl; 402 SuperClassMap::generateFortranInterface_hdl(oss,className); 403 oss<<iendl; 404 SuperClassMap::generateFortranInterface_hdl_(oss,className); 405 oss<<iendl; 406 SuperClassMap::generateFortranInterfaceGet_id(oss,className); 407 oss<<iendl; 408 SuperClassMap::generateFortranInterfaceGet_hdl(oss,className); 409 oss<<iendl; 410 SuperClassMap::generateFortranInterfaceGet_hdl_(oss,className); 411 oss<<iendl; 412 SuperClassMap::generateFortranInterfaceIsDefined_id(oss,className); 413 oss<<iendl; 414 SuperClassMap::generateFortranInterfaceIsDefined_hdl(oss,className); 415 oss<<iendl; 416 SuperClassMap::generateFortranInterfaceIsDefined_hdl_(oss,className); 417 oss<<iendl--; 418 oss<<"END MODULE i"<<className<<"_attr"<<iendl; 418 419 } 419 420 -
XIOS/trunk/src/test/test_client.f90
r545 r549 8 8 INTEGER :: size 9 9 INTEGER :: ierr 10 10 11 11 CHARACTER(len=*),PARAMETER :: id="client" 12 12 INTEGER :: comm 13 13 TYPE(xios_duration) :: dtime 14 14 TYPE(xios_date) :: date 15 CHARACTER(len=10) :: calendar_type 15 16 TYPE(xios_context) :: ctx_hdl 16 17 INTEGER,PARAMETER :: ni_glo=100 17 INTEGER,PARAMETER :: nj_glo=100 18 INTEGER,PARAMETER :: llm=5 18 INTEGER,PARAMETER :: nj_glo=100 19 INTEGER,PARAMETER :: llm=5 19 20 DOUBLE PRECISION :: lval(llm)=1 20 21 TYPE(xios_field) :: field_hdl … … 22 23 TYPE(xios_file) :: file_hdl 23 24 LOGICAL :: ok 24 25 25 26 DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo 26 27 DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm) … … 32 33 33 34 CALL MPI_INIT(ierr) 34 35 35 36 CALL init_wait 36 37 37 38 !!! XIOS Initialization (get the local communicator) 38 39 … … 40 41 41 42 CALL MPI_COMM_RANK(comm,rank,ierr) 42 CALL MPI_COMM_SIZE(comm,size,ierr) 43 43 CALL MPI_COMM_SIZE(comm,size,ierr) 44 44 45 DO j=1,nj_glo 45 46 DO i=1,ni_glo … … 57 58 nj=nj_glo/size 58 59 IF (n<MOD(nj_glo,size)) nj=nj+1 59 IF (n==rank) exit 60 IF (n==rank) exit 60 61 jbegin=jbegin+nj 61 62 ENDDO 62 63 63 64 iend=ibegin+ni-1 ; jend=jbegin+nj-1 64 65 … … 67 68 lat(:,:)=lat_glo(ibegin:iend,jbegin:jend) 68 69 field_A(1:ni,1:nj,:)=field_A_glo(ibegin:iend,jbegin:jend,:) 69 70 70 71 CALL xios_context_initialize("test",comm) 71 72 CALL xios_get_handle("test",ctx_hdl) 72 73 CALL xios_set_current_context(ctx_hdl) 73 74 CALL xios_set_context_attr("test",calendar_type="Gregorian") 74 75 CALL xios_get_calendar_type(calendar_type) 76 PRINT *, "calendar_type = ", calendar_type 77 75 78 CALL xios_set_axis_attr("axis_A",size=llm ,value=lval) ; 76 79 CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj) … … 78 81 CALL xios_set_domain_attr("domain_A",lonvalue=RESHAPE(lon,(/ni*nj/)),latvalue=RESHAPE(lat,(/ni*nj/))) 79 82 CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) 80 83 81 84 CALL xios_get_handle("field_definition",fieldgroup_hdl) 82 85 CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B") 83 86 CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_B") 84 87 85 88 CALL xios_get_handle("output",file_hdl) 86 89 CALL xios_add_child(file_hdl,field_hdl) 87 90 CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_C") 88 89 91 90 92 dtime%second = 3600 91 CALL xios_set_ context_attr("test", timestep=dtime)93 CALL xios_set_timestep(dtime) 92 94 93 ! Create the calendar before closing the context definition 94 ! so that calendar operations can be used 95 CALL xios_set_calendar() 96 CALL xios_get_context_attr("test", time_origin=date) 95 ! The calendar is created as soon as the calendar type is defined. This way 96 ! calendar operations can be used before the context definition is closed 97 CALL xios_get_time_origin(date) 98 PRINT *, "--> year length = ", xios_get_year_length_in_seconds(date%year) 99 PRINT *, "--> day length = ", xios_get_day_length_in_seconds() 97 100 PRINT *, "time_origin = ", date 101 PRINT *, "xios_date_get_second_of_year(time_origin) = ", xios_date_get_second_of_year(date) 102 PRINT *, "xios_date_get_day_of_year(time_origin) = ", xios_date_get_day_of_year(date) 103 PRINT *, "xios_date_get_fraction_of_year(time_origin) = ", xios_date_get_fraction_of_year(date) 104 PRINT *, "xios_date_get_second_of_day(time_origin) = ", xios_date_get_second_of_day(date) 105 PRINT *, "xios_date_get_fraction_of_day(time_origin) = ", xios_date_get_fraction_of_day(date) 98 106 dtime%timestep = 1 99 107 dtime = 0.5 * dtime … … 103 111 PRINT *, "xios_date_convert_to_seconds(date) = ", xios_date_convert_to_seconds(date) 104 112 PRINT *, "xios_date_convert_to_seconds(date - 2.5h) = ", xios_date_convert_to_seconds(date - 2.5 * xios_hour) 105 113 106 114 ni=0 ; lonvalue(:)=0 107 115 CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue=lonvalue) 108 116 109 117 print *,"ni",ni 110 118 print *,"lonvalue",lonvalue ; … … 113 121 PRINT *,"field_A : attribute enabled is defined ? ",ok 114 122 CALL xios_close_context_definition() 115 123 116 124 PRINT*,"field field_A is active ? ",xios_field_is_active("field_A") 117 125 DO ts=1,24*10 … … 123 131 CALL xios_context_finalize() 124 132 CALL xios_finalize() 125 133 126 134 CALL MPI_FINALIZE(ierr) 127 135 128 136 END PROGRAM test_client 129 137 130 138 131 132 139 133 140 141 -
XIOS/trunk/src/test/test_complete.f90
r537 r549 8 8 INTEGER :: size_loc 9 9 INTEGER :: ierr 10 10 11 11 CHARACTER(len=*),PARAMETER :: id="client" 12 12 INTEGER :: comm 13 TYPE(xios_date) :: start_date, time_origin14 13 TYPE(xios_duration) :: dtime 15 14 TYPE(xios_context) :: ctx_hdl 16 15 INTEGER,PARAMETER :: ni_glo=100 17 INTEGER,PARAMETER :: nj_glo=100 18 INTEGER,PARAMETER :: llm=5 16 INTEGER,PARAMETER :: nj_glo=100 17 INTEGER,PARAMETER :: llm=5 19 18 DOUBLE PRECISION :: lval(llm)=1 20 19 TYPE(xios_field) :: field_hdl … … 34 33 35 34 CALL MPI_INIT(ierr) 36 35 37 36 CALL init_wait 38 37 39 38 !!! XIOS Initialization (get the local communicator) 40 39 … … 42 41 43 42 CALL MPI_COMM_RANK(comm,rank,ierr) 44 CALL MPI_COMM_SIZE(comm,size_loc,ierr) 45 43 CALL MPI_COMM_SIZE(comm,size_loc,ierr) 44 46 45 47 46 !########################################################################### … … 66 65 nj=nj_glo/size_loc 67 66 IF (n<MOD(nj_glo,size_loc)) nj=nj+1 68 IF (n==rank) exit 67 IF (n==rank) exit 69 68 jbegin=jbegin+nj 70 69 ENDDO 71 70 72 71 iend=ibegin+ni-1 ; jend=jbegin+nj-1 73 72 … … 76 75 lat(:,:)=lat_glo(ibegin:iend,jbegin:jend) 77 76 field_A_atm(1:ni,1:nj,:)=field_A_glo(ibegin:iend,jbegin:jend,:) 78 77 79 78 80 79 !!! Context ATMOSPHERE … … 83 82 CALL xios_get_handle("atmosphere",ctx_hdl) 84 83 CALL xios_set_current_context(ctx_hdl) 85 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) 84 85 CALL xios_define_calendar(type="Gregorian", & 86 start_date=xios_date(2000, 01, 01, 00, 00, 00), & 87 time_origin=xios_date(1999, 01, 01, 15, 00, 00)) 91 88 92 89 CALL xios_set_axis_attr("axis_atm",size=llm ,value=lval) ; … … 104 101 CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) 105 102 106 !!! Création d un nouveau champ 103 !!! Création d un nouveau champ 107 104 108 105 CALL xios_get_handle("field_definition",fieldgroup_hdl) … … 112 109 113 110 CALL xios_set_attr(field_hdl,field_ref="field_A_atm",name="field_B_atm") 114 111 115 112 !!! Affectation de ce nouveau champ au fichier avec un nouveau nom 116 113 … … 118 115 CALL xios_add_child(file_hdl,field_hdl) 119 116 CALL xios_set_attr(field_hdl,field_ref="field_B_atm",name="field_C_atm") 120 117 121 118 !!! Definition du timestep 122 119 123 120 dtime%second=3600 124 CALL xios_set_ context_attr("atmosphere",timestep=dtime)125 121 CALL xios_set_timestep(timestep=dtime) 122 126 123 !!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalité) 127 124 128 125 ni=0 ; lonvalue(:)=0 129 126 CALL xios_get_domain_attr("domain_atm",ni=ni,lonvalue=lonvalue) 130 127 131 128 PRINT *,"ni",ni 132 129 PRINT *,"lonvalue",lonvalue ; … … 137 134 138 135 !!! Test des valeurs des champs/fichiers 139 140 !!! Attribut defini ? 136 137 !!! Attribut defini ? 141 138 142 139 CALL xios_is_defined_field_attr("field_A_atm",enabled=ok) … … 144 141 145 142 !!! Recuperer la valeur d un attribut 146 143 147 144 CALL xios_get_field_attr("field_A_atm",name=crname) 148 145 PRINT *,"field_A_atm : attribute name is : ",TRIM(crname) 149 146 150 !!! Champ actif (besoin de fournir la valeur) ? 147 !!! Champ actif (besoin de fournir la valeur) ? 151 148 152 149 PRINT*,"field field_A_atm is active ? ",xios_field_is_active("field_A_atm") … … 173 170 CALL xios_get_handle("surface",ctx_hdl) 174 171 CALL xios_set_current_context(ctx_hdl) 175 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) 172 173 CALL xios_define_calendar(type="Gregorian", & 174 start_date=xios_date(2000, 01, 01, 00, 00, 00), & 175 time_origin=xios_date(1999, 01, 01, 15, 00, 00)) 181 176 182 177 CALL xios_set_axis_attr("axis_srf",size=llm ,value=lval) ; … … 186 181 CALL xios_set_domain_attr("domain_srf",lonvalue=RESHAPE(lon,(/ni*nj/)),latvalue=RESHAPE(lat,(/ni*nj/))) 187 182 188 !!! Création d un nouveau champ 183 !!! Création d un nouveau champ 189 184 190 185 CALL xios_get_handle("field_definition",fieldgroup_hdl) … … 194 189 195 190 CALL xios_set_attr(field_hdl,field_ref="field_A_srf",name="field_B_srf") 196 191 197 192 !!! Affectation de ce nouveau champ au fichier avec un nouveau nom 198 193 … … 200 195 CALL xios_add_child(file_hdl,field_hdl) 201 196 CALL xios_set_attr(field_hdl,field_ref="field_B_srf",name="field_C_srf") 202 197 203 198 !!! Definition du timestep 204 199 205 200 dtime%second=1800 206 CALL xios_set_ context_attr("surface",timestep=dtime)207 201 CALL xios_set_timestep(timestep=dtime) 202 208 203 !!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalité) 209 204 210 205 ni=0 ; lonvalue(:)=0 211 206 CALL xios_get_domain_attr("domain_srf",ni=ni,lonvalue=lonvalue) 212 207 213 208 PRINT *,"ni",ni 214 209 PRINT *,"lonvalue",lonvalue ; … … 226 221 227 222 CALL xios_get_handle("atmosphere",ctx_hdl) 228 CALL xios_set_current_context(ctx_hdl) 223 CALL xios_set_current_context(ctx_hdl) 229 224 230 225 !!! Mise a jour du pas de temps … … 239 234 240 235 CALL xios_get_handle("surface",ctx_hdl) 241 CALL xios_set_current_context(ctx_hdl) 236 CALL xios_set_current_context(ctx_hdl) 242 237 243 238 !!! Mise a jour du pas de temps … … 257 252 258 253 !!! Fin des contextes 259 254 260 255 CALL xios_context_finalize() 261 256 CALL xios_get_handle("atmosphere",ctx_hdl) 262 CALL xios_set_current_context(ctx_hdl) 257 CALL xios_set_current_context(ctx_hdl) 263 258 CALL xios_context_finalize() 264 259 265 260 !!! Fin de XIOS 266 261 267 262 CALL xios_finalize() 268 263 269 264 CALL MPI_FINALIZE(ierr) 270 265 271 266 END PROGRAM test_complete 272 267 273 268 274 269 275 276 277 270 271 272 -
XIOS/trunk/src/test/test_cs.f90
r537 r549 5 5 INTEGER :: size 6 6 INTEGER :: ierr 7 7 8 8 CALL MPI_INIT(ierr) 9 9 CALL MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr) 10 10 CALL MPI_COMM_SIZE(MPI_COMM_WORLD,size,ierr) 11 11 12 12 IF (rank<11) THEN 13 13 CALL client("client",rank,11) 14 ELSE 14 ELSE 15 15 CALL server 16 16 ENDIF 17 18 17 18 19 19 CALL MPI_FINALIZE(ierr) 20 20 21 21 END PROGRAM test_cs 22 22 … … 32 32 TYPE(xios_duration) :: dtime 33 33 TYPE(xios_context) :: ctx_hdl 34 INTEGER,PARAMETER :: ni_glo=100 35 INTEGER,PARAMETER :: nj_glo=100 36 INTEGER,PARAMETER :: llm=3 34 INTEGER,PARAMETER :: ni_glo=100 35 INTEGER,PARAMETER :: nj_glo=100 36 INTEGER,PARAMETER :: llm=3 37 37 DOUBLE PRECISION :: lval(llm)=(/1.0,2.0,3.0/) 38 38 TYPE(xios_field) :: field_hdl 39 39 TYPE(xios_fieldgroup) :: fieldgroup_hdl 40 40 TYPE(xios_file) :: file_hdl 41 42 41 42 43 43 DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo 44 44 DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm) … … 47 47 INTEGER :: ni,ibegin,iend,nj,jbegin,jend,data_ibegin,data_ni 48 48 INTEGER :: i,j,k,l,ts,n,nij_begin 49 50 49 50 51 51 CALL init_wait 52 53 52 53 54 54 DO j=1,nj_glo 55 55 DO i=1,ni_glo … … 63 63 ni=ni_glo ; ibegin=1 64 64 65 65 66 66 nij_begin=1 67 67 DO n=0,size-1 … … 70 70 IF (n==rank) THEN 71 71 ibegin=1 ; iend=ni_glo ; ni=iend-ibegin+1 72 jbegin=(nij_begin-1)/ni_glo +1 72 jbegin=(nij_begin-1)/ni_glo +1 73 73 jend=MOD(nij_begin-1 + data_ni-1,ni_glo) +1 74 74 nj = jend-jbegin+1 … … 79 79 ENDIF 80 80 ENDDO 81 81 82 82 83 83 ALLOCATE(lon(ni),lat(nj),field_A(data_ni,llm),lonvalue(ni*nj)) … … 92 92 field_A(k,:)=field_A_glo(i,j,:) 93 93 ENDDO 94 94 95 95 mask(:,:)=.TRUE. 96 96 mask(1:ni,6)=.TRUE. 97 97 98 98 99 99 CALL xios_initialize(id,return_comm=comm) … … 102 102 CALL xios_get_handle("test",ctx_hdl) 103 103 CALL xios_set_current_context(ctx_hdl) 104 105 CALL xios_set_context_attr("test",calendar_type="Gregorian") 106 CALL xios_set_context_attr("test",calendar_type="Gregorian") 107 CALL xios_set_context_attr("test",calendar_type="Gregorian") 108 ! CALL xios_set_context_attr("test",start_date="01/01/2000 - 00:00:00") 109 CALL xios_set_context_attr("test",calendar_type="Gregorian") 104 105 ! CALL xios_define_calendar(type="Gregorian") 106 ! CALL xios_set_start_date(start_date=xios_date(2000, 01, 01, 00, 00, 00)) 110 107 CALL xios_set_axis_attr("axis_A",size=llm ,value=lval) ; 111 108 CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, iend=iend,jbegin=jbegin,jend=jend) 112 ! 109 ! CALL xios_set_domain_attr("domain_A",zoom_ni=10,zoom_ibegin=5,zoom_nj=nj_glo,zoom_jbegin=1) 113 110 CALL xios_set_domain_attr("domain_A",data_dim=1, data_ibegin=data_ibegin, data_ni=data_ni) 114 111 CALL xios_set_domain_attr("domain_A",lonvalue=lon,latvalue=lat) 115 ! 112 ! CALL xios_set_domain_attr("domain_A",mask=mask) 116 113 CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) 117 114 118 115 CALL xios_get_handle("field_definition",fieldgroup_hdl) 119 116 CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B") 120 117 CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_B") 121 118 122 119 CALL xios_get_handle("output",file_hdl) 123 120 CALL xios_add_child(file_hdl,field_hdl) 124 121 CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_C") 125 126 122 123 127 124 dtime%second=3600 128 CALL xios_set_ context_attr("test",timestep=dtime)129 125 CALL xios_set_timestep(timestep=dtime) 126 130 127 ! ni=0 ; lonvalue(:)=0 131 128 ! CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue=lonvalue) 132 129 133 130 ! print *,"ni",ni 134 131 ! print *,"lonvalue",lonvalue ; 135 132 136 133 CALL xios_close_context_definition() 137 134 138 135 PRINT*,"field field_A is active ? ",xios_field_is_active("field_A") 139 136 DO ts=1,24*10 … … 142 139 CALL wait_us(5000) ; 143 140 ENDDO 144 141 145 142 CALL xios_context_finalize() 146 143 CALL xios_finalize() 147 144 148 145 END SUBROUTINE client 149 150 146 151 147 148 152 149 SUBROUTINE server 153 150 USE xios 154 151 IMPLICIT NONE 155 152 156 153 CALL xios_init_server 157 154 158 155 END SUBROUTINE server 159 160 156 161 157 158 -
XIOS/trunk/src/test/test_new_features.f90
r543 r549 69 69 70 70 ALLOCATE(lon(ni,nj),lat(ni,nj),field_A(0:ni+1,-1:nj+2,llm),lonvalue(ni*nj)) 71 ! 71 ! ALLOCATE(lon(ni,nj),lat(ni,nj),field_A(0:ni+1,-1:nj+2,llm,llm),lonvalue(ni*nj)) 72 72 lon(:,:)=lon_glo(ibegin:iend,jbegin:jend) 73 73 lat(:,:)=lat_glo(ibegin:iend,jbegin:jend) … … 78 78 CALL xios_set_current_context(ctx_hdl) 79 79 80 CALL xios_set_context_attr("test",calendar_type="Gregorian")80 ! CALL xios_define_calendar(type="Gregorian") 81 81 CALL xios_set_axis_attr("axis_A",size=llm ,value=lval) ; 82 ! 82 ! CALL xios_set_axis_attr("axis_B",size=llm ,value=lval2) ; 83 83 CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj) 84 84 CALL xios_set_domain_attr("domain_A",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4) … … 96 96 97 97 dtime%second=3600 98 CALL xios_set_context_attr("test",timestep=dtime)98 ! CALL xios_set_timestep(timestep=dtime) 99 99 100 100 ni=0 ; lonvalue(:)=0 -
XIOS/trunk/src/test/test_unstruct_complete.f90
r537 r549 8 8 INTEGER :: mpi_size 9 9 INTEGER :: ierr 10 10 11 11 CHARACTER(len=*),PARAMETER :: id="client" 12 12 INTEGER :: comm 13 13 TYPE(xios_duration) :: dtime 14 14 TYPE(xios_context) :: ctx_hdl 15 INTEGER, PARAMETER :: nlon=60 15 INTEGER, PARAMETER :: nlon=60 16 16 INTEGER, PARAMETER :: nlat=30 17 17 INTEGER,PARAMETER :: ni_glo=100 18 INTEGER,PARAMETER :: nj_glo=100 19 INTEGER,PARAMETER :: llm=5 18 INTEGER,PARAMETER :: nj_glo=100 19 INTEGER,PARAMETER :: llm=5 20 20 DOUBLE PRECISION :: lval(llm)=1 21 21 TYPE(xios_field) :: field_hdl … … 23 23 TYPE(xios_file) :: file_hdl 24 24 LOGICAL :: ok 25 25 26 26 DOUBLE PRECISION,ALLOCATABLE :: lon_glo(:),lat_glo(:) 27 27 DOUBLE PRECISION,ALLOCATABLE :: bounds_lon_glo(:,:),bounds_lat_glo(:,:) … … 42 42 INTEGER,ALLOCATABLE :: data_i_index(:) 43 43 DOUBLE PRECISION,ALLOCATABLE :: field_A_compressed(:,:) 44 44 45 45 CALL xios_initialize(id,return_comm=comm) 46 46 CALL MPI_COMM_RANK(comm,mpi_rank,ierr) 47 47 CALL MPI_COMM_SIZE(comm,mpi_size,ierr) 48 48 49 49 CALL init_wait 50 50 51 51 ncell_glo=0 52 52 DO j=1,nlat … … 55 55 ncell_glo=ncell_glo+n 56 56 ENDDO 57 57 58 58 ALLOCATE(lon_glo(ncell_glo)) 59 59 ALLOCATE(lat_glo(ncell_glo)) … … 63 63 ALLOCATE(field_A_glo(ncell_glo,llm)) 64 64 ALLOCATE(mask_glo(ncell_glo)) 65 65 66 66 ind=0 67 67 DO j=1,nlat … … 70 70 if (j==nlat) PRINT*,"--- ",n 71 71 IF (n<8) n=8 72 72 73 73 DO i=1,n 74 74 ind=ind+1 … … 76 76 ilon=i-0.5 77 77 ilat=j-0.5 78 78 79 79 lat_glo(ind)= 90-(ilat*180./nlat) 80 80 lon_glo(ind)= (ilon*360./n) 81 82 81 82 83 83 bounds_lat_glo(1,ind)= 90-((ilat-0.5)*180./nlat) 84 84 bounds_lon_glo(1,ind)=((ilon-0.5)*360./n) 85 85 86 86 bounds_lat_glo(2,ind)= 90-((ilat-0.5)*180./nlat) 87 bounds_lon_glo(2,ind)=((ilon+0.5)*360./n) 88 87 bounds_lon_glo(2,ind)=((ilon+0.5)*360./n) 88 89 89 bounds_lat_glo(3,ind)= 90-((ilat+0.5)*180./nlat) 90 bounds_lon_glo(3,ind)=((ilon+0.5)*360./n) 90 bounds_lon_glo(3,ind)=((ilon+0.5)*360./n) 91 91 92 92 bounds_lat_glo(4,ind)= 90-((ilat+0.5)*180./nlat) 93 93 bounds_lon_glo(4,ind)=((ilon-0.5)*360./n) 94 94 95 95 ENDDO 96 96 ENDDO … … 99 99 rank=(mpi_size-1)/2 100 100 ncell_x=sqrt(ncell_glo*1./mpi_size) 101 101 102 102 j1=nlat/2 103 103 DO WHILE(rank>=0) … … 106 106 n=NINT(COS(Pi/2-(j-0.5)*PI/nlat)*nlon) 107 107 np = MIN(n/ncell_x,rank+1) ; 108 if (j2==1) np=rank+1 109 108 if (j2==1) np=rank+1 109 110 110 PRINT *,"domain ",j2,j1,rank,np ; 111 DO j=j2,j1 111 DO j=j2,j1 112 112 n=NINT(COS(Pi/2-(j-0.5)*PI/nlat)*nlon) 113 113 IF (n<8) n=8 114 114 DO i=1,n 115 115 ind=list_ind(i,j) 116 IF ( (i-1) < MOD(n,np)*(n/np+1)) THEN 116 IF ( (i-1) < MOD(n,np)*(n/np+1)) THEN 117 117 i_index_glo(ind) = rank - (i-1)/(n/np+1) 118 ELSE 118 ELSE 119 119 i_index_glo(ind) = rank-(MOD(n,np)+ (i-1-MOD(n,np)*(n/np+1))/(n/np)) 120 120 ENDIF … … 124 124 j1=j2-1 125 125 ENDDO 126 126 127 127 rank=(mpi_size-1)/2+1 128 128 ncell_x=sqrt(ncell_glo*1./mpi_size) 129 129 130 130 j1=nlat/2+1 131 131 DO WHILE(rank<=mpi_size-1) … … 134 134 n=NINT(COS(Pi/2-(j-0.5)*PI/nlat)*nlon) 135 135 np = MIN(n/ncell_x,mpi_size-rank) ; 136 if (j2==nlat) np=mpi_size-rank 137 136 if (j2==nlat) np=mpi_size-rank 137 138 138 PRINT *,"domain ",j2,j1,rank,np ; 139 DO j=j1,j2 139 DO j=j1,j2 140 140 n=NINT(COS(Pi/2-(j-0.5)*PI/nlat)*nlon) 141 141 IF (n<8) n=8 142 142 DO i=1,n 143 143 ind=list_ind(i,j) 144 IF ( (i-1) < MOD(n,np)*(n/np+1)) THEN 144 IF ( (i-1) < MOD(n,np)*(n/np+1)) THEN 145 145 i_index_glo(ind) = rank + (i-1)/(n/np+1) 146 ELSE 146 ELSE 147 147 i_index_glo(ind) = rank+(MOD(n,np)+ (i-1-MOD(n,np)*(n/np+1))/(n/np)) 148 148 ENDIF … … 152 152 j1=j2+1 153 153 ENDDO 154 154 155 155 ncell=0 156 156 DO ind=1,ncell_glo … … 183 183 ENDIF 184 184 ENDDO 185 185 186 186 ALLOCATE(field_A_compressed(data_n_index,llm)) 187 187 ALLOCATE(data_i_index(data_n_index)) … … 194 194 ENDIF 195 195 ENDDO 196 197 198 196 199 197 CALL xios_context_initialize("surface",comm) 200 198 CALL xios_get_handle("surface",ctx_hdl) 201 199 CALL xios_set_current_context(ctx_hdl) 202 200 201 CALL xios_define_calendar(type="Julian", & 202 start_date=xios_date(2012, 03, 01, 15, 00, 00), & 203 time_origin=xios_date(2012, 02, 29, 15, 00, 00)) 204 203 205 CALL xios_set_axis_attr("axis_srf",size=llm ,value=lval) ; 204 206 CALL xios_set_domain_attr("domain_srf",ni_glo=ncell_glo, ni=ncell, ibegin=1, i_index=RESHAPE(i_index,(/ncell,1/) )) … … 206 208 CALL xios_set_domain_attr("domain_srf",lonvalue=lon,latvalue=lat) 207 209 CALL xios_set_domain_attr("domain_srf", nvertex=4, bounds_lon=bounds_lon, bounds_lat=bounds_lat ) 208 209 210 211 210 212 dtime%second=3600 211 213 CALL xios_set_context_attr("surface", timestep=dtime) 212 214 CALL xios_close_context_definition() 213 215 214 216 DO ts=1,24*10 215 217 CALL xios_update_calendar(ts) 216 218 CALL xios_send_field("field_A_srf",field_A_compressed) 217 219 ENDDO 218 220 219 221 CALL xios_context_finalize() 220 222 CALL xios_finalize() 221 223 222 224 END PROGRAM test_unstruct_complete 223 225 224 226 225 226 227 227 228 229 -
XIOS/trunk/src/test/test_xios_interface.f90
r537 r549 96 96 CALL xios_set_current_context(ctx_hdl) 97 97 98 CALL xios_set_context_attr("atmosphere",calendar_type="Gregorian") 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) 98 CALL xios_define_calendar(type="Gregorian", & 99 start_date=xios_date(2000, 01, 01, 00, 00, 00), & 100 time_origin=xios_date(1999, 01, 01, 15, 00, 00)) 103 101 104 102 CALL xios_set_axis_attr("axis_atm",size=llm ,value=lval) ; … … 131 129 132 130 dtime%second=3600 133 CALL xios_set_ context_attr("atmosphere",timestep=dtime)131 CALL xios_set_timestep(timestep=dtime) 134 132 135 133 !!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalité) … … 183 181 CALL xios_set_current_context(ctx_hdl) 184 182 185 CALL xios_set_context_attr("surface",calendar_type="Gregorian") 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) 183 CALL xios_define_calendar(type="Gregorian", & 184 start_date=xios_date(2000, 01, 01, 00, 00, 00), & 185 time_origin=xios_date(1999, 01, 01, 15, 00, 00)) 190 186 191 187 CALL xios_set_axis_attr("axis_srf",size=llm ,value=lval) ; … … 213 209 214 210 dtime%second=1800 215 CALL xios_set_ context_attr("surface",timestep=dtime)211 CALL xios_set_timestep(timestep=dtime) 216 212 217 213 !!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalité) -
XIOS/trunk/src/type/type_util.hpp
r501 r549 5 5 namespace xios 6 6 { 7 class CDomain 7 class CDomain; 8 8 class CDomainGroup; 9 9 class CField; … … 17 17 class CContext; 18 18 class CContextGroup; 19 class CVariable ; 20 class CVariableGroup ; 21 22 template <typename T> inline string getStrType(void) ; 23 24 #define macro(T) template <> inline string getStrType<T>(void) { return std::string(#T) ; } 19 class CCalendarWrapper; 20 class CVariable; 21 class CVariableGroup; 22 23 template <typename T> inline string getStrType(void); 24 25 #define macro(T) template <> inline string getStrType<T>(void) { return std::string(#T); } 25 26 26 27 macro(short) … … 38 39 macro(bool) 39 40 #undef macro 40 41 #define macro(T) template <> inline string getStrType<T>(void) { return std::string(#T) 41 42 #define macro(T) template <> inline string getStrType<T>(void) { return std::string(#T); } 42 43 macro(CDomain) 43 44 macro(CDomainGroup) … … 52 53 macro(CContext) 53 54 macro(CContextGroup) 55 macro(CCalendarWrapper) 54 56 macro(CVariable) 55 57 macro(CVariableGroup) 56 57 58 58 59 #undef macro 59 60 60 } 61 61
Note: See TracChangeset
for help on using the changeset viewer.