Changeset 549


Ignore:
Timestamp:
01/26/15 14:39:26 (9 years ago)
Author:
rlacroix
Message:

Revised calendar functionalities:

  • the calendar is now configured from a specific calendar child node of the context in the XML configuration file. Example: <calendar type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-29 15:00:00" timestep="1h" />
  • the calendar type should now be configured when defining the start time and/or the time origin.
  • the start time and the time origin are now optional, 0000-01-01 00:00:00 will be used by default. It is also possible to define them partially. For example, 2015 and 2014-12 are valid dates corresponding respectively to 2015-01-01 00:00:00 and 2014-12-01 00:00:00.
  • an optional duration offset can be added to the start date and time origin. For example, it's possible to define the date 2015-01-12 12:00:00 as 2015-01-11 + 36h or 2015-01-11 12:00:00 + 1d. The duration format is the same as the time step. Being that the date is optional, it is possible to only use a duration (for example + 42s is the same as 0000-01-01 00:00:00 + 42s). An error will be raised if a duration based on the time step is used before the time step was configured. For example, the following would cause an error: <calendar type="Gregorian" start_date="+ 1ts" /> but <calendar type="Gregorian" start_date="+ 1ts" timestep="0.5h" /> would not.
  • new Fortran interface to define the calendar:
    • xios_define_calendar(type[, timestep, start_date, time_origin]) will create a calendar when none had previously been defined. Only the type argument is mandatory, the rest is optional. Calendar operations on dates and durations are possible as soon as the calendar is created (either using this procedure or directly from the XML configuration file).
    • the following getter and setter procedures are available: xios_set_timestep, xios_set_start_date, xios_set_time_origin, xios_get_calendar_type, xios_get_timestep, xios_get_start_date, xios_get_time_origin.
  • new Fortran interface to interact with the calendar: xios_update_calendar, xios_get_current_date, xios_get_year_length_in_seconds, xios_get_day_length_in_seconds.
  • new Fortran interface for date conversion: xios_date_get_second_of_year, xios_date_get_day_of_year, xios_date_get_fraction_of_year, xios_date_get_second_of_day, xios_date_get_fraction_of_day.
  • two new placeholders are available to format the file name when splitting the output (split_freq_format attribute):
    • %S the number of seconds since the time origin
    • %D the integral number of days since the time origin
Location:
XIOS/trunk
Files:
9 added
38 edited
1 moved

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/inputs/COMPLETE/context_atmosphere.xml

    r486 r549  
    11<!-- Context atm --> 
    22   
    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"> 
    44 
    55  <field_definition level="1" enabled=".FALSE." default_value="9.96921e+36"> 
  • XIOS/trunk/inputs/COMPLETE/context_surface.xml

    r527 r549  
    11<!-- Context surface --> 
    22   
    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"> 
    44 
    55  <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  
    22<simulation> 
    33 
    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" /> 
    56 
    67 
  • XIOS/trunk/inputs/iodef.xml

    r527 r549  
    22<simulation>  
    33 
    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 
    67 
    78   <field_definition level="1" enabled=".FALSE."> 
  • XIOS/trunk/src/calendar.cpp

    r532 r549  
    1212         , timeOrigin(*this) 
    1313         , currentDate(*this) 
    14       {   } 
     14      {} 
    1515 
    1616      CCalendar::CCalendar(const StdString& id) 
     
    1919               , timeOrigin(*this) 
    2020               , currentDate(*this) 
    21       { } 
    22        
     21      {} 
     22 
    2323      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*/) 
    2626               : CObject(id) 
    2727               , initDate(*this) 
    2828               , timeOrigin(*this) 
    2929               , currentDate(*this) 
    30       {  
    31         initializeDate(yr, mth, d, hr, min, sec) ; 
     30      { 
     31        initializeDate(yr, mth, d, hr, min, sec); 
    3232      } 
    3333 
     
    6666 
    6767      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*/) 
    6969      { 
    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; 
    7373      } 
    7474 
    7575      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; 
    8080      } 
    8181 
    8282      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; 
    8787      } 
    88        
    8988 
    9089      CCalendar::~CCalendar(void) 
     
    102101      } 
    103102 
    104       void CCalendar::fromString(const StdString & str) 
     103      void CCalendar::fromString(const StdString& str) 
    105104      { ERROR("CCalendar::fromString(str)", 
    106105               << "[ str = " << str << "] Not implemented yet !"); } 
     
    108107      //----------------------------------------------------------------- 
    109108 
    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      } 
    112116 
    113       CDate & CCalendar::update(int step) 
    114       {  
    115          info(20) << "update step : " << step <<" timestep "<<this->timestep << std::endl; 
    116          return (this->getCurrentDate() = this->getInitDate() + step * this->timestep); 
     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); 
    117121      } 
    118122 
    119123      //----------------------------------------------------------------- 
    120124 
    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      } 
    125140 
    126141      //----------------------------------------------------------------- 
    127142 
    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 
    129151      { // Retourne la durée du mois en jour. 
    130          static const int NoLeapMonthLength[] = 
    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]; 
    133155      } 
    134156 
    135       StdString CCalendar::getType(void) const { return (StdString(this->getId())); } 
     157      StdString CCalendar::getType(void) const { return StdString(this->getId()); } 
    136158 
    137       int CCalendar::getYearTotalLength(const CDate & date) const { return (365 * 86400); } 
     159      int CCalendar::getYearTotalLength(const CDate& date) const { return (365 * 86400); } 
    138160 
    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(); } 
    143166 
    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]; 
    152173      } 
    153174 
    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; } 
    164177 
    165178      ///---------------------------------------------------------------- 
  • XIOS/trunk/src/calendar.hpp

    r532 r549  
    3333            /// Constructeurs /// 
    3434            CCalendar(void); 
    35             CCalendar(const StdString& id) ; 
     35            CCalendar(const StdString& id); 
    3636            CCalendar(const StdString& id, 
    3737                      int yr, int mth, int d, 
     
    4949            /// Autres /// 
    5050            virtual StdString toString(void) const; 
    51             virtual void fromString(const StdString & str); 
     51            virtual void fromString(const StdString& str); 
    5252 
    5353            /// 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); 
    5557 
    5658            /// Traitemants /// 
    57             CDate & update(int step); 
     59            CDate& update(int step); 
    5860 
    5961            /// Accesseurs /// 
    60             const CDuration & getTimeStep(void) const; 
    61             const CDate & getInitDate(void) const; 
    62             const CDate & getTimeOrigin(void) const; 
    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 
    6567         public : 
    66           
     68 
    6769            //------------------------------------------------------------ 
    68             virtual int getMonthLength(const CDate & date) const ; 
     70            virtual int getMonthLength(const CDate& date) const; 
    6971 
    7072            virtual StdString getType(void) const; 
    7173 
    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. 
    7375 
    7476            virtual int getYearLength  (void) const; // Retourne la durée d'une année en mois. 
     
    7678            virtual int getHourLength  (void) const; // Retourne la durée d'une heure en minute. 
    7779            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; 
    7882 
    79             virtual int getNbSecond(const CDate & date) const; 
    8083            virtual StdString getMonthName(int month_id) const; 
    8184 
    8285            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 & dateStr); 
    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); 
    8689 
    8790            //------------------------------------------------------------ 
    8891 
    8992         protected: 
    90              
     93 
    9194            //!< Associate the dates to the calendar and check their validity 
    9295            void initializeDate(); 
  • XIOS/trunk/src/calendar_util.cpp

    r545 r549  
    55      /// ////////////////////// Définitions ////////////////////// /// 
    66 
    7       CDuration operator*(const double & scal, const CDuration & ddr) 
     7      CDuration operator*(const double& scal, const CDuration& ddr) 
    88      { return (ddr * scal); } 
    99 
    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; 
     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; 
    1414         dur.hour -= dr.hour;  dur.minute -= dr.minute; dur.second -= dr.second; dur.timestep -= dr.timestep; 
    1515         return (dur); 
    1616      } 
    1717 
    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; 
     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; 
    2222         dur.hour += dr.hour;  dur.minute += dr.minute; dur.second += dr.second; dur.timestep += dr.timestep; 
    2323         return (dur); 
    2424      } 
    2525 
    26       CDuration operator*(const CDuration & ddr , const double & scal) 
     26      CDuration operator*(const CDuration& ddr , const double& scal) 
    2727      { 
    2828         CDuration dur(ddr); 
     
    3232      } 
    3333 
    34       CDuration operator-(const CDuration & ddr) 
     34      CDuration operator-(const CDuration& ddr) 
    3535      { 
    3636         CDuration dur(ddr); 
     
    4747      //----------------------------------------------------------------- 
    4848 
    49       CDate operator+(const CDate & dt, const CDuration & dr) 
    50       { 
    51          CDuration drr (dr); 
     49      CDate operator+(const CDate& dt, const CDuration& dr) 
     50      { 
     51         CDuration drr(dr); 
    5252         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); 
    5965 
    6066         // Ajustement des minutes par rapport aux secondes. 
    6167         second += dt.getSecond() + drr.second; 
    62          if (second <  0) { minute --; second += c.getMinuteLength(); } 
    63          if (second >= c.getMinuteLength()) { minute ++; second -= c.getMinuteLength(); } 
     68         if (second < 0) { minute--; second += c.getMinuteLength(); } 
     69         if (second >= c.getMinuteLength()) { minute++; second -= c.getMinuteLength(); } 
    6470 
    6571         // Ajustement des heures en fonction des minutes. 
    6672         minute += dt.getMinute() + drr.minute; 
    67          if (minute < 0) { hour --; minute += c.getHourLength(); } 
    68          if (minute >= c.getHourLength()) { hour ++; minute -= c.getHourLength(); } 
     73         if (minute < 0) { hour--; minute += c.getHourLength(); } 
     74         if (minute >= c.getHourLength()) { hour++; minute -= c.getHourLength(); } 
    6975 
    7076         // Ajustement des jours en fonction des heures. 
    7177         hour += dt.getHour() + drr.hour; 
    72          if (hour <  0) { drr.day --; hour += c.getDayLength(); } 
    73          if (hour >= c.getDayLength()) { drr.day ++; hour -= c.getDayLength(); } 
     78         if (hour < 0) { drr.day--; hour += c.getDayLength(); } 
     79         if (hour >= c.getDayLength()) { drr.day++; hour -= c.getDayLength(); } 
    7480 
    7581         // 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 (1)) 
    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 (-1)) 
    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 
    96102/* 
    97103         if (day <  0) { drr.month --; day += c.getMonthLength(dtt); } 
    98104         if (day > c.getMonthLength(dtt)) { drr.month ++; day -= c.getMonthLength(dtt); } // << ProblÚme ici 
    99105         if (day == 0){ day = c.getMonthLength(dtt); drr.month --; } 
    100 */          
    101          drr.resolve(dt.getRelCalendar()); 
     106*/ 
     107         drr.resolve(c); 
    102108 
    103109         // Ajustement des années en fonction des mois. 
    104110         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(); } 
    107113         if (month == 0){ month = c.getYearLength(); drr.year--; } 
    108114 
    109115         year += dt.getYear() + drr.year; 
    110116 
    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) 
    119125      { 
    120126         // TODO :: Vérifier que les deux dates (dt0 et dt1) ont une référence vers le même calendrier. 
     
    131137      bool operator==(const CDuration& ddr, const CDuration& dr) 
    132138      { 
    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)&& 
    135141                 (ddr.timestep == dr.timestep)); 
    136142      } 
     
    144150      { 
    145151         // 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())); 
    148154      } 
    149155 
     
    152158         // TODO :: Vérifier que les deux dates (dt0 et dt1) ont une référence vers le même calendrier. 
    153159         if   (dt0.getYear()  < dt1.getYear()) 
    154          {  
     160         { 
    155161            return true; 
    156162         } 
    157163         else if (dt0.getYear() == dt1.getYear()) 
    158          {  
     164         { 
    159165            if   (dt0.getMonth()  < dt1.getMonth()) 
    160166            { 
     
    174180                  } 
    175181                  else if (dt0.getHour() == dt1.getHour()) 
    176                   {  
     182                  { 
    177183                     if   (dt0.getMinute()  < dt1.getMinute()) 
    178184                     { 
     
    193199      //----------------------------------------------------------------- 
    194200 
    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)); } 
    199205 
    200206      ///---------------------------------------------------------------- 
  • XIOS/trunk/src/calendar_util.hpp

    r545 r549  
    1111      /// ////////////////////// Déclarations ////////////////////// /// 
    1212 
    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); 
     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); 
    1818 
    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); 
    2121 
    22       CDuration operator-(const CDate & dt0, const CDate & dt1); 
     22      CDuration operator-(const CDate& dt0, const CDate& dt1); 
    2323 
    2424      /// Les opérateurs de comparaison. (Non testés pour le moment) 
     
    2929      bool operator< (const CDate& dt0, const CDate& dt1); 
    3030 
    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); 
    3535 
    3636      ///--------------------------------------------------------------- 
  • XIOS/trunk/src/config/calendar_type.conf

    r526 r549  
    11#ifdef __XMLIO_CAllLeapCalendar__ 
    2    DECLARE_CALENDAR(AllLeap, calendar_type_attr::AllLeap) 
     2   DECLARE_CALENDAR(AllLeap, AllLeap) 
    33#endif //__XMLIO_CAllLeapCalendar__ 
    44 
    55#ifdef __XMLIO_CD360Calendar__ 
    6    DECLARE_CALENDAR(D360, calendar_type_attr::D360) 
     6   DECLARE_CALENDAR(D360, D360) 
    77#endif //__XMLIO_CD360Calendar__ 
    88 
    99#ifdef __XMLIO_CGregorianCalendar__ 
    10    DECLARE_CALENDAR(Gregorian, calendar_type_attr::Gregorian) 
     10   DECLARE_CALENDAR(Gregorian, Gregorian) 
    1111#endif //__XMLIO_CGregorianCalendar__ 
    1212 
    1313#ifdef __XMLIO_CJulianCalendar__ 
    14    DECLARE_CALENDAR(Julian, calendar_type_attr::Julian) 
     14   DECLARE_CALENDAR(Julian, Julian) 
    1515#endif //__XMLIO_CJulianCalendar__ 
    1616 
    1717#ifdef __XMLIO_CNoLeapCalendar__ 
    18    DECLARE_CALENDAR(NoLeap, calendar_type_attr::NoLeap) 
     18   DECLARE_CALENDAR(NoLeap, NoLeap) 
    1919#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) 
    51DECLARE_ATTRIBUTE(StdString, output_dir) 
    6  
  • XIOS/trunk/src/config/node_type.conf

    r501 r549  
    2727#endif //__XMLIO_CVariable__ 
    2828 
     29#ifdef __XMLIO_CCalendarWrapper__ 
     30   DECLARE_NODE(CalendarWrapper, calendarwrapper) 
     31#endif //__XMLIO_CCalendarWrapper__ 
     32 
    2933#ifdef __XMLIO_CContext__ 
    3034   DECLARE_NODE_PAR(Context, context) 
  • XIOS/trunk/src/context_server.cpp

    r511 r549  
    2525  CContextServer::CContextServer(CContext* parent,MPI_Comm intraComm_,MPI_Comm interComm_) 
    2626  { 
    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); 
    3434    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()); 
    4242 
    4343  } 
    4444  void CContextServer::setPendingEvent(void) 
    4545  { 
    46     pendingEvent=true ; 
     46    pendingEvent=true; 
    4747  } 
    4848 
    4949  bool CContextServer::hasPendingEvent(void) 
    5050  { 
    51     return pendingEvent ; 
     51    return pendingEvent; 
    5252  } 
    5353 
    5454  bool CContextServer::eventLoop(void) 
    5555  { 
    56     listen() ; 
    57     checkPendingRequest() ; 
    58     processEvents() ; 
    59     return finished ; 
     56    listen(); 
     57    checkPendingRequest(); 
     58    processEvents(); 
     59    return finished; 
    6060  } 
    6161 
     
    6363  { 
    6464    int rank; 
    65     int flag ; 
    66     int count ; 
    67     char * addr ; 
     65    int flag; 
     66    int count; 
     67    char * addr; 
    6868    MPI_Status status; 
    6969    map<int,CServerBuffer*>::iterator it; 
     
    7373      if (pendingRequest.find(rank)==pendingRequest.end()) 
    7474      { 
    75         traceOff() ; 
     75        traceOff(); 
    7676        MPI_Iprobe(rank,20,interComm,&flag,&status); 
    77         traceOn() ; 
     77        traceOn(); 
    7878        if (flag==true) 
    7979        { 
    80           it=buffers.find(rank) ; 
     80          it=buffers.find(rank); 
    8181          if (it==buffers.end()) 
    8282          { 
     
    8484            MPI_Recv(&buffSize, 1, MPI_LONG, rank, 20, interComm, &status); 
    8585            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; 
    8787          } 
    8888          else 
    8989          { 
    90             MPI_Get_count(&status,MPI_CHAR,&count) ; 
     90            MPI_Get_count(&status,MPI_CHAR,&count); 
    9191            if (it->second->isBufferFree(count)) 
    9292            { 
    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; 
    9696            } 
    9797          } 
     
    104104  { 
    105105    map<int,MPI_Request>::iterator it; 
    106     list<int> recvRequest ; 
     106    list<int> recvRequest; 
    107107    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; 
    112112 
    113113    for(it=pendingRequest.begin();it!=pendingRequest.end();it++) 
    114114    { 
    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(); 
    119119      if (flag==true) 
    120120      { 
    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); 
    124124      } 
    125125    } 
     
    127127    for(itRecv=recvRequest.begin();itRecv!=recvRequest.end();itRecv++) 
    128128    { 
    129       pendingRequest.erase(*itRecv) ; 
    130       bufferRequest.erase(*itRecv) ; 
     129      pendingRequest.erase(*itRecv); 
     130      bufferRequest.erase(*itRecv); 
    131131    } 
    132132  } 
     
    135135  { 
    136136 
    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; 
    142142 
    143143    while(count>0) 
    144144    { 
    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(); 
    155155    } 
    156156 
     
    159159  void CContextServer::processEvents(void) 
    160160  { 
    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); 
    165165    if (it!=events.end()) 
    166166    { 
    167       event=it->second ; 
     167      event=it->second; 
    168168 
    169169      if (event->isFull()) 
     
    171171        if (!scheduled && !CXios::isServer) 
    172172        { 
    173           CServer::eventScheduler->registerEvent(currentTimeLine,hashId) ; 
    174           scheduled=true ; 
     173          CServer::eventScheduler->registerEvent(currentTimeLine,hashId); 
     174          scheduled=true; 
    175175        } 
    176176        else if (CXios::isServer || CServer::eventScheduler->queryEvent(currentTimeLine,hashId) ) 
    177177        { 
    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; 
    186186        } 
    187187      } 
     
    191191  CContextServer::~CContextServer() 
    192192  { 
    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; 
    195195  } 
    196196 
     
    198198  void CContextServer::dispatchEvent(CEventServer& event) 
    199199  { 
    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()); 
    206206 
    207207    if (event.classId==CContext::GetType() && event.type==CContext::EVENT_ID_CONTEXT_FINALIZE) 
    208208    { 
    209       info(20)<<"Server Side context <"<<context->getId()<<"> finalized"<<endl ; 
     209      info(20)<<"Server Side context <"<<context->getId()<<"> finalized"<<endl; 
    210210      std::map<int, StdSize>::const_iterator itbMap = mapBufferSize_.begin(), 
    211211                                             iteMap = mapBufferSize_.end(), itMap; 
     
    217217        totalBuf += itMap->second; 
    218218      } 
    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); 
    236237    else 
    237238    { 
    238       ERROR("void CContextServer::dispatchEvent(CEventServer& event)",<<" Bad event class Id"<<endl) ; 
     239      ERROR("void CContextServer::dispatchEvent(CEventServer& event)",<<" Bad event class Id"<<endl); 
    239240    } 
    240241  } 
  • XIOS/trunk/src/date.cpp

    r544 r549  
    22#include "calendar.hpp" 
    33#include "calendar_type.hpp" 
     4#include "calendar_util.hpp" 
    45#include <boost/date_time/gregorian/gregorian.hpp> 
    56#include <boost/date_time/posix_time/posix_time.hpp> 
    67 
    7 using namespace boost::posix_time ; 
    8 using namespace boost::gregorian ; 
     8using namespace boost::posix_time; 
     9using namespace boost::gregorian; 
    910 
    1011namespace xios 
     
    1213      /// ////////////////////// Définitions ////////////////////// /// 
    1314      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) 
    1623         , hour(0), minute(0), second(0) 
    1724      {} 
    1825 
    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        
    2526      CDate::CDate(const CCalendar& calendar, 
    2627                   int yr, int mth, int d, 
    2728                   int hr, int min, int sec) 
    2829         : relCalendar(&calendar) 
    29          , year(yr), month(mth) , day(d) 
     30         , year(yr), month(mth), day(d) 
    3031         , hour(hr), minute(min), second(sec) 
    3132      { 
    32          if(!this->checkDate()) 
     33         if (!this->checkDate()) 
    3334         { 
    3435            DEBUG(<< "La date initialisée a été modifiée " 
     
    3839 
    3940      CDate::CDate(const CDate& date) 
    40             : relCalendar(date.relCalendar), 
    41               year(date.year), month(date.month)  , day(date.day), 
    42               hour(date.hour), minute(date.minute), second(date.second) 
     41        : relCalendar(date.relCalendar) 
     42        , year(date.year), month(date.month),   day(date.day) 
     43        , hour(date.hour), minute(date.minute), second(date.second) 
    4344      { 
    4445        // Delay the verification until we get a calendar we can compare the date to 
     
    5556      ///--------------------------------------------------------------- 
    5657 
    57       CDate & CDate::operator=(const CDate & date) 
     58      CDate& CDate::operator=(const CDate& date) 
    5859      { 
    5960         relCalendar = date.relCalendar; 
    60          year = date.year; month  = date.month ; day    = date.day; 
     61         year = date.year; month  = date.month; day    = date.day; 
    6162         hour = date.hour; minute = date.minute; second = date.second; 
    6263         return (*this); 
    6364      } 
    6465 
    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. 
    9090      { 
    9191        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) 
    96104        { 
    97           in >> date.month >> c ; 
    98           if (c==sep) 
     105          in >> date.month >> c; 
     106          if (c == sep) 
    99107          { 
    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) 
    104112            { 
    105               in >> date.hour >> c ; 
    106               sep=':' ; 
    107               if (c==sep)  
     113              in >> date.hour >> c; 
     114              sep = ':'; 
     115              if (c == sep) 
    108116              { 
    109117                in>>date.minute >> c; 
    110                 if (c==sep) 
     118                if (c == sep) 
    111119                { 
    112120                  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; 
    118122                } 
    119123              } 
     
    121125          } 
    122126        } 
    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; 
    125144      } 
    126145 
    127146      CDate::operator Time(void) const // Non vérifiée, pas optimisée ... 
    128147      { 
    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; 
    146164      } 
    147165 
     
    150168      bool CDate::checkDate(void) 
    151169      { 
    152          bool retValue = true; 
    153  
    154          // This will check that a calendar was correctly associated to the date 
    155          const CCalendar& c = getRelCalendar(); 
    156  
    157          // Vérification de la valeur du mois. 
    158          if (month  < 1) { retValue = false; month  = 1; } 
    159          if (month  > c.getYearLength()) 
    160          { retValue = false; month = c.getYearLength(); } 
    161  
    162          // Vérification de la valeur du jour. 
    163          if (day    < 1) { retValue = false; day  = 1; } 
    164          if (day    > c.getMonthLength(*this)) 
    165          { retValue = false; day = c.getMonthLength(*this); } 
    166  
    167          // Vérification de la valeur de l'heure. 
    168          if (hour   < 0) { retValue = false; hour  = 0; } 
    169          if (hour   >= c.getDayLength()) 
    170          { retValue = false; hour = c.getDayLength() - 1; } 
    171  
    172          // Vérification de la valeur des minutes. 
    173          if (minute < 0) { retValue = false; minute = 0; } 
    174          if (minute >= c.getHourLength()) 
    175          { retValue = false; minute = c.getHourLength() - 1; } 
    176  
    177          // Vérification de la valeur des secondes. 
    178          if (second < 0) { retValue = false; second = 0; } 
    179          if (second >= c.getMinuteLength()) 
    180          { retValue = false; second = c.getMinuteLength() - 1; } 
    181  
    182          return retValue; 
     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; 
    183201      } 
    184202 
     
    207225      //---------------------------------------------------------------- 
    208226 
     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 
    209283      void CDate::setYear  (int newyear)   { this->year   = newyear; } 
    210284      void CDate::setMonth (int newmonth)  { this->month  = newmonth; } 
     
    226300      //---------------------------------------------------------------- 
    227301 
    228       void CDate::addMonth (int value) 
     302      void CDate::addMonth(int value) 
    229303      {// Value doit être égale à 1 ou -1. 
    230          this->month += value; 
    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; } 
    233307      } 
    234308 
     
    243317      //---------------------------------------------------------------- 
    244318 
    245       CDate CDate::FromString(const StdString & str, const CCalendar & calendar) 
    246       { 
    247          CDate dt(calendar); 
    248          StdIStringStream iss(str); 
    249          iss >> dt; 
    250          return dt; 
    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 
    255329      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      } 
    269342 
    270343      string CDate::getStr(const string& str) const 
    271344      { 
    272         ostringstream oss ; 
     345        ostringstream oss; 
    273346        int level; 
    274          
    275         level=0 ; 
     347 
     348        level=0; 
    276349        for(string::const_iterator it=str.begin();it!=str.end();++it) 
    277350        { 
    278351          if (level==0) 
    279352          { 
    280             if (*it=='%') level++ ; 
    281             else oss<<*it ; 
     353            if (*it=='%') level++; 
     354            else oss<<*it; 
    282355          } 
    283356          else if (level==1) 
     
    286359            { 
    287360              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; 
    291364              case 'm' : // month or minute 
    292                 level++ ; 
    293                 break ; 
     365                level++; 
     366                break; 
    294367              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; 
    298371              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; 
    302375              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; 
    305386                break; 
    306387              default : 
    307                 oss<<'%'<<*it ; 
    308                 level=0 ; 
     388                oss<<'%'<<*it; 
     389                level=0; 
    309390            } 
    310391          } 
     
    314395            { 
    315396              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; 
    319400              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; 
    323404              default : 
    324                 oss<<"%m"<<*it ; 
    325                 level=0 ; 
     405                oss<<"%m"<<*it; 
     406                level=0; 
    326407            } 
    327408          } 
     
    329410        return oss.str(); 
    330411      } 
    331        
     412 
    332413      StdString CDate::toString(void) const 
    333       {  
    334          StdOStringStream oss; 
    335          oss << (*this); 
    336          return (oss.str());  
     414      { 
     415        StdOStringStream oss; 
     416        oss << *this; 
     417        return oss.str(); 
    337418      } 
    338419 
  • XIOS/trunk/src/date.hpp

    r544 r549  
    2020            CDate(void); 
    2121            //!< Create an empty date associated to the specified calendar 
    22             CDate(const CCalendar & cal); 
     22            CDate(const CCalendar& cal); 
    2323            //!< Create a date associated to the specified calendar 
    24             CDate(const CCalendar & cal, int yr, int mth, int d, 
    25                                          int hr = 0, int min = 0, int sec = 0); 
    26             CDate(const CDate & odate); 
    27             CDate(const CDate * const odate); // Not implemented yet 
     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 
    2828 
    2929            /// Destructeur /// 
     
    3131 
    3232            /// 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. 
    3636 
    3737            //!< Return the number of seconds since the time origin fixed when creating the calendar 
     
    5252            const CCalendar& getRelCalendar(void) const; 
    5353            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; 
    5465 
    5566            /// Mutateurs /// 
     
    7788         public : /* static */ 
    7889 
    79             static CDate FromString(const StdString & str, const CCalendar & calendar); 
     90            static CDate FromString(const StdString& str, const CCalendar& calendar); 
    8091 
    8192         private : 
  • XIOS/trunk/src/date/d360.hpp

    r532 r549  
    1717 
    1818            /// Constructeur /// 
    19             CD360Calendar(void);                                   // Not implemented yet. 
     19            //CD360Calendar(void);                                   // Not implemented yet. 
    2020            CD360Calendar(const CDate& startDate); 
    2121            CD360Calendar(const CDate& startDate, const CDate& timeOrigin); 
  • XIOS/trunk/src/generate_fortran_interface.cpp

    r531 r549  
    1010int main (int argc, char ** argv, char ** UNUSED (env)) 
    1111{ 
    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; 
    1819  CField field; 
    19   CFieldGroup fieldgroup ; 
     20  CFieldGroup fieldgroup; 
    2021  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 
    2728  CFile afile; 
    2829  CFileGroup filegroup; 
    29    
    30   ostringstream oss ; 
     30 
     31  ostringstream oss; 
    3132  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 
    196210} 
  • XIOS/trunk/src/interface/c/iccalendar.cpp

    r545 r549  
    11#include "xmlioserver.hpp" 
    22 
     3#include "icdate.hpp" 
    34#include "exception.hpp" 
    45#include "timer.hpp" 
     
    89extern "C" 
    910{ 
    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  
    1911  void cxios_update_calendar(int step) 
    2012  { 
     
    2618    CTimer::get("XIOS").suspend(); 
    2719  } 
     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  } 
    2864} 
  • XIOS/trunk/src/interface/c/icdate.cpp

    r545 r549  
    144144    return (date1 >= date2); 
    145145  } 
     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  } 
    146186} // extern "C" 
  • XIOS/trunk/src/interface/c_attr/iccontext_attr.cpp

    r537 r549  
    1717{ 
    1818  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    
    4519   
    4620  void cxios_set_context_output_dir(context_Ptr context_hdl, const char * output_dir, int output_dir_size) 
     
    7044   
    7145   
    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    
    18646   
    18747} 
  • XIOS/trunk/src/interface/fortran/calendar_interface.F90

    r545 r549  
     1#include "xios_fortran_prefix.hpp" 
     2 
    13MODULE CALENDAR_INTERFACE 
    24   USE, INTRINSIC :: ISO_C_BINDING 
    3       
     5 
    46   INTERFACE ! Ne pas appeler directement/Interface FORTRAN 2003 <-> C99 
    5  
    6       SUBROUTINE cxios_create_calendar() BIND(C) 
    7       END SUBROUTINE cxios_create_calendar 
    87 
    98      SUBROUTINE cxios_update_calendar(step) BIND(C) 
     
    1211      END SUBROUTINE cxios_update_calendar 
    1312 
     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 
    1427   END INTERFACE 
    15       
     28 
    1629END MODULE CALENDAR_INTERFACE 
  • XIOS/trunk/src/interface/fortran/date_interface.F90

    r545 r549  
    77      INTEGER(kind = C_INT) :: year, month, day, hour, minute, second 
    88   END TYPE txios(date) 
    9       
     9 
    1010   INTERFACE ! Ne pas appeler directement/Interface FORTRAN 2003 <-> C99 
    1111 
     
    7575      END FUNCTION cxios_date_ge 
    7676 
     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 
    77107   END INTERFACE 
    78       
     108 
    79109END MODULE DATE_INTERFACE 
  • XIOS/trunk/src/interface/fortran/icalendar.F90

    r545 r549  
    33   USE, INTRINSIC :: ISO_C_BINDING 
    44   USE CALENDAR_INTERFACE 
     5   USE ICALENDAR_WRAPPER 
    56   USE IDATE 
    67   USE IDURATION 
     
    910   INTEGER(kind = C_INT), PARAMETER :: D360 = 0 , ALLLEAP = 1 , NOLEAP = 2 , JULIAN = 3 , GREGORIAN = 4 
    1011 
     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 
    1120   CONTAINS ! Fonctions disponibles pour les utilisateurs. 
    1221 
    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 
    2030      TYPE(txios(date)),     OPTIONAL, INTENT(IN) :: start_date 
    2131      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 
    3043      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) 
    3245      END IF 
    3346      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) 
    4262 
    4363   SUBROUTINE xios(set_timestep)(timestep) 
    44       USE ICONTEXT, ONLY : txios(context), xios(get_current_context) 
    45       USE icontext_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) 
    4666      USE IDURATION, ONLY : txios(duration) 
    4767      IMPLICIT NONE 
    4868      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) 
    5476   END SUBROUTINE xios(set_timestep) 
    5577 
     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 
    56169   SUBROUTINE xios(update_calendar)(step) 
    57170      IMPLICIT NONE 
    58171      INTEGER, INTENT(IN) :: step 
    59        
     172 
    60173      IF (step < 0) THEN 
    61174         PRINT *, "L'argument 'step' ne peut être négatif" 
     
    65178   END SUBROUTINE xios(update_calendar) 
    66179 
     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 
    67203END MODULE ICALENDAR 
  • XIOS/trunk/src/interface/fortran/idate.F90

    r545 r549  
    3737   END INTERFACE 
    3838 
     39   INTERFACE ASSIGNMENT(=) 
     40      MODULE PROCEDURE xios(date_assign_duration) 
     41   END INTERFACE 
     42 
    3943   CONTAINS ! Fonctions disponibles pour les utilisateurs. 
    4044 
     
    140144   END FUNCTION xios(date_ge) 
    141145 
     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 
    142201END MODULE IDATE 
  • XIOS/trunk/src/interface/fortran/ixios.F90

    r545 r549  
    33MODULE XIOS 
    44 
    5 USE icalendar, ONLY : xios(set_calendar), xios(set_timestep), xios(update_calendar) 
     5USE 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) 
    69 
    710USE icontext, ONLY : txios(context), xios(get_context_handle), xios(set_current_context),    & 
     
    2427                  xios(date_add_duration), xios(date_sub_duration), xios(date_sub), & 
    2528                  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), & 
    2631                  OPERATOR(+), OPERATOR(-), & 
    27                   OPERATOR(==), OPERATOR(/=), OPERATOR(<), OPERATOR(<=), OPERATOR(>), OPERATOR(>=) 
     32                  OPERATOR(==), OPERATOR(/=), OPERATOR(<), OPERATOR(<=), OPERATOR(>), OPERATOR(>=), & 
     33                  ASSIGNMENT(=) 
    2834 
    2935USE idomain, ONLY : txios(domain), txios(domaingroup), xios(get_domain_handle),  & 
     
    200206           xios(field_is_active) 
    201207 
    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) 
    203212 
    204213 PUBLIC :: xios(year), xios(month), xios(day), xios(hour), xios(minute), xios(second), xios(timestep), & 
     
    208217 PUBLIC :: xios(date_convert_to_seconds), & 
    209218           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) 
    211222 
    212223 PUBLIC :: OPERATOR(+), OPERATOR(-), OPERATOR(*), & 
    213            OPERATOR(==), OPERATOR(/=), OPERATOR(<), OPERATOR(<=), OPERATOR(>), OPERATOR(>=) 
     224           OPERATOR(==), OPERATOR(/=), OPERATOR(<), OPERATOR(<=), OPERATOR(>), OPERATOR(>=), & 
     225           ASSIGNMENT(=) 
    214226 
    215227 PUBLIC :: xios(getVar) 
  • XIOS/trunk/src/interface/fortran_attr/context_interface_attr.F90

    r545 r549  
    88   
    99  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_BINDING 
    14       INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    15       CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: calendar_type 
    16       INTEGER  (kind = C_INT)     , VALUE        :: calendar_type_size 
    17     END SUBROUTINE cxios_set_context_calendar_type 
    18      
    19     SUBROUTINE cxios_get_context_calendar_type(context_hdl, calendar_type, calendar_type_size) BIND(C) 
    20       USE ISO_C_BINDING 
    21       INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    22       CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: calendar_type 
    23       INTEGER  (kind = C_INT)     , VALUE        :: calendar_type_size 
    24     END SUBROUTINE cxios_get_context_calendar_type 
    25      
    26     FUNCTION cxios_is_defined_context_calendar_type(context_hdl ) BIND(C) 
    27       USE ISO_C_BINDING 
    28       LOGICAL(kind=C_BOOL) :: cxios_is_defined_context_calendar_type 
    29       INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    30     END FUNCTION cxios_is_defined_context_calendar_type 
    3110     
    3211     
     
    5231     
    5332     
    54     SUBROUTINE cxios_set_context_start_date(context_hdl, start_date) BIND(C) 
    55       USE ISO_C_BINDING 
    56       USE IDATE 
    57       INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    58       TYPE(txios(date)), VALUE :: start_date 
    59     END SUBROUTINE cxios_set_context_start_date 
    60      
    61     SUBROUTINE cxios_get_context_start_date(context_hdl, start_date) BIND(C) 
    62       USE ISO_C_BINDING 
    63       USE IDATE 
    64       INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    65       TYPE(txios(date)) :: start_date 
    66     END SUBROUTINE cxios_get_context_start_date 
    67      
    68     FUNCTION cxios_is_defined_context_start_date(context_hdl ) BIND(C) 
    69       USE ISO_C_BINDING 
    70       LOGICAL(kind=C_BOOL) :: cxios_is_defined_context_start_date 
    71       INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    72     END FUNCTION cxios_is_defined_context_start_date 
    73      
    74      
    75     SUBROUTINE cxios_set_context_time_origin(context_hdl, time_origin) BIND(C) 
    76       USE ISO_C_BINDING 
    77       USE IDATE 
    78       INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    79       TYPE(txios(date)), VALUE :: time_origin 
    80     END SUBROUTINE cxios_set_context_time_origin 
    81      
    82     SUBROUTINE cxios_get_context_time_origin(context_hdl, time_origin) BIND(C) 
    83       USE ISO_C_BINDING 
    84       USE IDATE 
    85       INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    86       TYPE(txios(date)) :: time_origin 
    87     END SUBROUTINE cxios_get_context_time_origin 
    88      
    89     FUNCTION cxios_is_defined_context_time_origin(context_hdl ) BIND(C) 
    90       USE ISO_C_BINDING 
    91       LOGICAL(kind=C_BOOL) :: cxios_is_defined_context_time_origin 
    92       INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    93     END FUNCTION cxios_is_defined_context_time_origin 
    94      
    95      
    96     SUBROUTINE cxios_set_context_timestep(context_hdl, timestep) BIND(C) 
    97       USE ISO_C_BINDING 
    98       USE IDURATION 
    99       INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    100       TYPE(txios(duration)), VALUE :: timestep 
    101     END SUBROUTINE cxios_set_context_timestep 
    102      
    103     SUBROUTINE cxios_get_context_timestep(context_hdl, timestep) BIND(C) 
    104       USE ISO_C_BINDING 
    105       USE IDURATION 
    106       INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    107       TYPE(txios(duration)) :: timestep 
    108     END SUBROUTINE cxios_get_context_timestep 
    109      
    110     FUNCTION cxios_is_defined_context_timestep(context_hdl ) BIND(C) 
    111       USE ISO_C_BINDING 
    112       LOGICAL(kind=C_BOOL) :: cxios_is_defined_context_timestep 
    113       INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    114     END FUNCTION cxios_is_defined_context_timestep 
    115      
    116      
    11733    END INTERFACE 
    11834   
  • XIOS/trunk/src/interface/fortran_attr/icontext_attr.F90

    r537 r549  
    1212   
    1313  SUBROUTINE xios(set_context_attr)  & 
    14     ( context_id, calendar_type, output_dir, start_date, time_origin, timestep ) 
     14    ( context_id, output_dir ) 
    1515     
    1616    IMPLICIT NONE 
    1717      TYPE(txios(context))  :: context_hdl 
    1818      CHARACTER(LEN=*), INTENT(IN) ::context_id 
    19       CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: calendar_type 
    2019      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: output_dir 
    21       TYPE(txios(date))  , OPTIONAL, INTENT(IN) :: start_date 
    22       TYPE(txios(date))  , OPTIONAL, INTENT(IN) :: time_origin 
    23       TYPE(txios(duration))  , OPTIONAL, INTENT(IN) :: timestep 
    2420       
    2521      CALL xios(get_context_handle)(context_id,context_hdl) 
    2622      CALL xios(set_context_attr_hdl_)   & 
    27       ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep ) 
     23      ( context_hdl, output_dir ) 
    2824     
    2925  END SUBROUTINE xios(set_context_attr) 
    3026   
    3127  SUBROUTINE xios(set_context_attr_hdl)  & 
    32     ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep ) 
     28    ( context_hdl, output_dir ) 
    3329     
    3430    IMPLICIT NONE 
    3531      TYPE(txios(context)) , INTENT(IN) :: context_hdl 
    36       CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: calendar_type 
    3732      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: output_dir 
    38       TYPE(txios(date))  , OPTIONAL, INTENT(IN) :: start_date 
    39       TYPE(txios(date))  , OPTIONAL, INTENT(IN) :: time_origin 
    40       TYPE(txios(duration))  , OPTIONAL, INTENT(IN) :: timestep 
    4133       
    4234      CALL xios(set_context_attr_hdl_)  & 
    43       ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep ) 
     35      ( context_hdl, output_dir ) 
    4436     
    4537  END SUBROUTINE xios(set_context_attr_hdl) 
    4638   
    4739  SUBROUTINE xios(set_context_attr_hdl_)   & 
    48     ( context_hdl, calendar_type_, output_dir_, start_date_, time_origin_, timestep_ ) 
     40    ( context_hdl, output_dir_ ) 
    4941     
    5042    IMPLICIT NONE 
    5143      TYPE(txios(context)) , INTENT(IN) :: context_hdl 
    52       CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: calendar_type_ 
    5344      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_)) THEN 
    59         CALL cxios_set_context_calendar_type(context_hdl%daddr, calendar_type_, len(calendar_type_)) 
    60       ENDIF 
    6145       
    6246      IF (PRESENT(output_dir_)) THEN 
    6347        CALL cxios_set_context_output_dir(context_hdl%daddr, output_dir_, len(output_dir_)) 
    64       ENDIF 
    65        
    66       IF (PRESENT(start_date_)) THEN 
    67         CALL cxios_set_context_start_date(context_hdl%daddr, start_date_) 
    68       ENDIF 
    69        
    70       IF (PRESENT(time_origin_)) THEN 
    71         CALL cxios_set_context_time_origin(context_hdl%daddr, time_origin_) 
    72       ENDIF 
    73        
    74       IF (PRESENT(timestep_)) THEN 
    75         CALL cxios_set_context_timestep(context_hdl%daddr, timestep_) 
    7648      ENDIF 
    7749       
     
    8153   
    8254  SUBROUTINE xios(get_context_attr)  & 
    83     ( context_id, calendar_type, output_dir, start_date, time_origin, timestep ) 
     55    ( context_id, output_dir ) 
    8456     
    8557    IMPLICIT NONE 
    8658      TYPE(txios(context))  :: context_hdl 
    8759      CHARACTER(LEN=*), INTENT(IN) ::context_id 
    88       CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: calendar_type 
    8960      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: output_dir 
    90       TYPE(txios(date))  , OPTIONAL, INTENT(OUT) :: start_date 
    91       TYPE(txios(date))  , OPTIONAL, INTENT(OUT) :: time_origin 
    92       TYPE(txios(duration))  , OPTIONAL, INTENT(OUT) :: timestep 
    9361       
    9462      CALL xios(get_context_handle)(context_id,context_hdl) 
    9563      CALL xios(get_context_attr_hdl_)   & 
    96       ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep ) 
     64      ( context_hdl, output_dir ) 
    9765     
    9866  END SUBROUTINE xios(get_context_attr) 
    9967   
    10068  SUBROUTINE xios(get_context_attr_hdl)  & 
    101     ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep ) 
     69    ( context_hdl, output_dir ) 
    10270     
    10371    IMPLICIT NONE 
    10472      TYPE(txios(context)) , INTENT(IN) :: context_hdl 
    105       CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: calendar_type 
    10673      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: output_dir 
    107       TYPE(txios(date))  , OPTIONAL, INTENT(OUT) :: start_date 
    108       TYPE(txios(date))  , OPTIONAL, INTENT(OUT) :: time_origin 
    109       TYPE(txios(duration))  , OPTIONAL, INTENT(OUT) :: timestep 
    11074       
    11175      CALL xios(get_context_attr_hdl_)  & 
    112       ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep ) 
     76      ( context_hdl, output_dir ) 
    11377     
    11478  END SUBROUTINE xios(get_context_attr_hdl) 
    11579   
    11680  SUBROUTINE xios(get_context_attr_hdl_)   & 
    117     ( context_hdl, calendar_type_, output_dir_, start_date_, time_origin_, timestep_ ) 
     81    ( context_hdl, output_dir_ ) 
    11882     
    11983    IMPLICIT NONE 
    12084      TYPE(txios(context)) , INTENT(IN) :: context_hdl 
    121       CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: calendar_type_ 
    12285      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_)) THEN 
    128         CALL cxios_get_context_calendar_type(context_hdl%daddr, calendar_type_, len(calendar_type_)) 
    129       ENDIF 
    13086       
    13187      IF (PRESENT(output_dir_)) THEN 
    13288        CALL cxios_get_context_output_dir(context_hdl%daddr, output_dir_, len(output_dir_)) 
    133       ENDIF 
    134        
    135       IF (PRESENT(start_date_)) THEN 
    136         CALL cxios_get_context_start_date(context_hdl%daddr, start_date_) 
    137       ENDIF 
    138        
    139       IF (PRESENT(time_origin_)) THEN 
    140         CALL cxios_get_context_time_origin(context_hdl%daddr, time_origin_) 
    141       ENDIF 
    142        
    143       IF (PRESENT(timestep_)) THEN 
    144         CALL cxios_get_context_timestep(context_hdl%daddr, timestep_) 
    14589      ENDIF 
    14690       
     
    15094   
    15195  SUBROUTINE xios(is_defined_context_attr)  & 
    152     ( context_id, calendar_type, output_dir, start_date, time_origin, timestep ) 
     96    ( context_id, output_dir ) 
    15397     
    15498    IMPLICIT NONE 
    15599      TYPE(txios(context))  :: context_hdl 
    156100      CHARACTER(LEN=*), INTENT(IN) ::context_id 
    157       LOGICAL, OPTIONAL, INTENT(OUT) :: calendar_type 
    158       LOGICAL(KIND=C_BOOL) :: calendar_type_tmp 
    159101      LOGICAL, OPTIONAL, INTENT(OUT) :: output_dir 
    160102      LOGICAL(KIND=C_BOOL) :: output_dir_tmp 
    161       LOGICAL, OPTIONAL, INTENT(OUT) :: start_date 
    162       LOGICAL(KIND=C_BOOL) :: start_date_tmp 
    163       LOGICAL, OPTIONAL, INTENT(OUT) :: time_origin 
    164       LOGICAL(KIND=C_BOOL) :: time_origin_tmp 
    165       LOGICAL, OPTIONAL, INTENT(OUT) :: timestep 
    166       LOGICAL(KIND=C_BOOL) :: timestep_tmp 
    167103       
    168104      CALL xios(get_context_handle)(context_id,context_hdl) 
    169105      CALL xios(is_defined_context_attr_hdl_)   & 
    170       ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep ) 
     106      ( context_hdl, output_dir ) 
    171107     
    172108  END SUBROUTINE xios(is_defined_context_attr) 
    173109   
    174110  SUBROUTINE xios(is_defined_context_attr_hdl)  & 
    175     ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep ) 
     111    ( context_hdl, output_dir ) 
    176112     
    177113    IMPLICIT NONE 
    178114      TYPE(txios(context)) , INTENT(IN) :: context_hdl 
    179       LOGICAL, OPTIONAL, INTENT(OUT) :: calendar_type 
    180       LOGICAL(KIND=C_BOOL) :: calendar_type_tmp 
    181115      LOGICAL, OPTIONAL, INTENT(OUT) :: output_dir 
    182116      LOGICAL(KIND=C_BOOL) :: output_dir_tmp 
    183       LOGICAL, OPTIONAL, INTENT(OUT) :: start_date 
    184       LOGICAL(KIND=C_BOOL) :: start_date_tmp 
    185       LOGICAL, OPTIONAL, INTENT(OUT) :: time_origin 
    186       LOGICAL(KIND=C_BOOL) :: time_origin_tmp 
    187       LOGICAL, OPTIONAL, INTENT(OUT) :: timestep 
    188       LOGICAL(KIND=C_BOOL) :: timestep_tmp 
    189117       
    190118      CALL xios(is_defined_context_attr_hdl_)  & 
    191       ( context_hdl, calendar_type, output_dir, start_date, time_origin, timestep ) 
     119      ( context_hdl, output_dir ) 
    192120     
    193121  END SUBROUTINE xios(is_defined_context_attr_hdl) 
    194122   
    195123  SUBROUTINE xios(is_defined_context_attr_hdl_)   & 
    196     ( context_hdl, calendar_type_, output_dir_, start_date_, time_origin_, timestep_ ) 
     124    ( context_hdl, output_dir_ ) 
    197125     
    198126    IMPLICIT NONE 
    199127      TYPE(txios(context)) , INTENT(IN) :: context_hdl 
    200       LOGICAL, OPTIONAL, INTENT(OUT) :: calendar_type_ 
    201       LOGICAL(KIND=C_BOOL) :: calendar_type__tmp 
    202128      LOGICAL, OPTIONAL, INTENT(OUT) :: output_dir_ 
    203129      LOGICAL(KIND=C_BOOL) :: output_dir__tmp 
    204       LOGICAL, OPTIONAL, INTENT(OUT) :: start_date_ 
    205       LOGICAL(KIND=C_BOOL) :: start_date__tmp 
    206       LOGICAL, OPTIONAL, INTENT(OUT) :: time_origin_ 
    207       LOGICAL(KIND=C_BOOL) :: time_origin__tmp 
    208       LOGICAL, OPTIONAL, INTENT(OUT) :: timestep_ 
    209       LOGICAL(KIND=C_BOOL) :: timestep__tmp 
    210        
    211       IF (PRESENT(calendar_type_)) THEN 
    212         calendar_type__tmp=cxios_is_defined_context_calendar_type(context_hdl%daddr) 
    213         calendar_type_=calendar_type__tmp 
    214       ENDIF 
    215130       
    216131      IF (PRESENT(output_dir_)) THEN 
    217132        output_dir__tmp=cxios_is_defined_context_output_dir(context_hdl%daddr) 
    218133        output_dir_=output_dir__tmp 
    219       ENDIF 
    220        
    221       IF (PRESENT(start_date_)) THEN 
    222         start_date__tmp=cxios_is_defined_context_start_date(context_hdl%daddr) 
    223         start_date_=start_date__tmp 
    224       ENDIF 
    225        
    226       IF (PRESENT(time_origin_)) THEN 
    227         time_origin__tmp=cxios_is_defined_context_time_origin(context_hdl%daddr) 
    228         time_origin_=time_origin__tmp 
    229       ENDIF 
    230        
    231       IF (PRESENT(timestep_)) THEN 
    232         timestep__tmp=cxios_is_defined_context_timestep(context_hdl%daddr) 
    233         timestep_=timestep__tmp 
    234134      ENDIF 
    235135       
  • XIOS/trunk/src/node/context.cpp

    r545 r549  
    1717namespace xios { 
    1818 
    19   shared_ptr<CContextGroup> CContext::root ; 
     19  shared_ptr<CContextGroup> CContext::root; 
    2020 
    2121   /// ////////////////////// Définitions ////////////////////// /// 
     
    3333   CContext::~CContext(void) 
    3434   { 
    35      if (hasClient) delete client ; 
    36      if (hasServer) delete server ; 
     35     if (hasClient) delete client; 
     36     if (hasServer) delete server; 
    3737   } 
    3838 
     
    5050   CContextGroup* CContext::getRoot(void) 
    5151   { 
    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())); 
    5353      return root.get(); 
    5454   } 
     
    7373   { 
    7474      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 calendar 
    81    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_CALENDAR 
    131  
    132       ERROR("CContext::solveCalendar(void)", 
    133             << "[ calendar_type = " << calendar_type.getStringValue() << " ] " 
    134             << "The calendar is not properly handled!"); 
    13575   } 
    13676 
     
    182122#define DECLARE_NODE(Name_, name_)    \ 
    183123   if (name.compare(C##Name_##Definition::GetDefName()) == 0) \ 
    184    { C##Name_##Definition::create(C##Name_##Definition::GetDefName()) -> parse(node) ; continue; } 
     124   { C##Name_##Definition::create(C##Name_##Definition::GetDefName()) -> parse(node); continue; } 
    185125#define DECLARE_NODE_PAR(Name_, name_) 
    186126#include "node_type.conf" 
     
    200140   void CContext::ShowTree(StdOStream & out) 
    201141   { 
    202       StdString currentContextId = CContext::getCurrent() -> getId() ; 
     142      StdString currentContextId = CContext::getCurrent() -> getId(); 
    203143      std::vector<CContext*> def_vector = 
    204144         CContext::getRoot()->getChildList(); 
     
    285225//   { 
    286226//      if (!this->hasId()) return; 
    287 //      vector<CField*> allField = CField::getAll() ; 
     227//      vector<CField*> allField = CField::getAll(); 
    288228////              = CObjectTemplate<CField>::GetAllVectobject(this->getId()); 
    289229//      std::vector<CField*>::iterator 
     
    301241   void CContext::CleanTree(void) 
    302242   { 
    303 #define DECLARE_NODE(Name_, name_) C##Name_##Group::ClearAllAttributes(); 
     243#define DECLARE_NODE(Name_, name_) C##Name_##Definition::ClearAllAttributes(); 
    304244#define DECLARE_NODE_PAR(Name_, name_) 
    305245#include "node_type.conf" 
     
    310250   void CContext::initClient(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtServer) 
    311251   { 
    312      hasClient=true ; 
    313      client = new CContextClient(this,intraComm, interComm, cxtServer) ; 
     252     hasClient=true; 
     253     client = new CContextClient(this,intraComm, interComm, cxtServer); 
    314254   } 
    315255 
     
    325265   bool CContext::isInitialized(void) 
    326266   { 
    327      return hasClient ; 
     267     return hasClient; 
    328268   } 
    329269 
     
    331271   void CContext::initServer(MPI_Comm intraComm,MPI_Comm interComm) 
    332272   { 
    333      hasServer=true ; 
    334      server = new CContextServer(this,intraComm,interComm) ; 
     273     hasServer=true; 
     274     server = new CContextServer(this,intraComm,interComm); 
    335275   } 
    336276 
     
    338278   bool CContext::eventLoop(void) 
    339279   { 
    340      return server->eventLoop() ; 
     280     return server->eventLoop(); 
    341281   } 
    342282 
     
    346286      if (hasClient && !hasServer) 
    347287      { 
    348          client->finalize() ; 
     288         client->finalize(); 
    349289      } 
    350290      if (hasServer) 
    351291      { 
    352         closeAllFile() ; 
     292        closeAllFile(); 
    353293      } 
    354294   } 
     
    385325      this->sendAllAttributesToServer(); 
    386326 
     327      // Send all attributes of current calendar 
     328      CCalendarWrapper::get(CCalendarWrapper::GetDefName())->sendAllAttributesToServer(); 
     329 
    387330      // We have enough information to send to server 
    388331      // First of all, send all enabled files 
     
    428371////        this->findEnabledFiles(); 
    429372// 
    430 //        this->processEnabledFiles() ; 
     373//        this->processEnabledFiles(); 
    431374// 
    432375//        this->solveAllGridRef(); 
     
    445388// 
    446389// 
    447 //      this->processEnabledFiles() ; 
     390//      this->processEnabledFiles(); 
    448391 
    449392/* 
     
    464407      if (hasClient && !hasServer) CleanTree(); // Only on client side?? 
    465408//      if (hasClient) CleanTree(); 
    466       if (hasClient) sendCreateFileHeader() ; 
     409      if (hasClient) sendCreateFileHeader(); 
    467410   } 
    468411 
     
    523466 
    524467     // 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(); 
    526469      const vector<CGrid*> allGrids= CGrid::getAll(); 
    527470 
     
    580523   { 
    581524 
    582       if (SuperClass::dispatchEvent(event)) return true ; 
     525      if (SuperClass::dispatchEvent(event)) return true; 
    583526      else 
    584527      { 
     
    586529        { 
    587530           case EVENT_ID_CLOSE_DEFINITION : 
    588              recvCloseDefinition(event) ; 
    589              return true ; 
    590              break ; 
     531             recvCloseDefinition(event); 
     532             return true; 
     533             break; 
    591534           case EVENT_ID_UPDATE_CALENDAR : 
    592              recvUpdateCalendar(event) ; 
    593              return true ; 
    594              break ; 
     535             recvUpdateCalendar(event); 
     536             return true; 
     537             break; 
    595538           case EVENT_ID_CREATE_FILE_HEADER : 
    596              recvCreateFileHeader(event) ; 
    597              return true ; 
    598              break ; 
     539             recvCreateFileHeader(event); 
     540             return true; 
     541             break; 
    599542           case EVENT_ID_POST_PROCESS: 
    600              recvPostProcessing(event) ; 
    601              return true ; 
    602              break ; 
     543             recvPostProcessing(event); 
     544             return true; 
     545             break; 
    603546           default : 
    604547             ERROR("bool CContext::dispatchEvent(CEventServer& event)", 
    605                     <<"Unknown Event") ; 
    606            return false ; 
     548                    <<"Unknown Event"); 
     549           return false; 
    607550         } 
    608551      } 
     
    612555   void CContext::sendCloseDefinition(void) 
    613556   { 
    614      CEventClient event(getType(),EVENT_ID_CLOSE_DEFINITION) ; 
     557     CEventClient event(getType(),EVENT_ID_CLOSE_DEFINITION); 
    615558     if (client->isServerLeader()) 
    616559     { 
    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); 
    623566   } 
    624567 
     
    629572      CBufferIn* buffer=event.subEvents.begin()->buffer; 
    630573      string id; 
    631       *buffer>>id ; 
     574      *buffer>>id; 
    632575      get(id)->closeDefinition(); 
    633576   } 
     
    638581     if (!hasServer) 
    639582     { 
    640        CEventClient event(getType(),EVENT_ID_UPDATE_CALENDAR) ; 
     583       CEventClient event(getType(),EVENT_ID_UPDATE_CALENDAR); 
    641584       if (client->isServerLeader()) 
    642585       { 
    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); 
    647590       } 
    648        else client->sendEvent(event) ; 
     591       else client->sendEvent(event); 
    649592     } 
    650593   } 
     
    656599      CBufferIn* buffer=event.subEvents.begin()->buffer; 
    657600      string id; 
    658       *buffer>>id ; 
    659       get(id)->recvUpdateCalendar(*buffer) ; 
     601      *buffer>>id; 
     602      get(id)->recvUpdateCalendar(*buffer); 
    660603   } 
    661604 
     
    663606   void CContext::recvUpdateCalendar(CBufferIn& buffer) 
    664607   { 
    665       int step ; 
    666       buffer>>step ; 
    667       updateCalendar(step) ; 
     608      int step; 
     609      buffer>>step; 
     610      updateCalendar(step); 
    668611   } 
    669612 
     
    671614   void CContext::sendCreateFileHeader(void) 
    672615   { 
    673      CEventClient event(getType(),EVENT_ID_CREATE_FILE_HEADER) ; 
     616     CEventClient event(getType(),EVENT_ID_CREATE_FILE_HEADER); 
    674617     if (client->isServerLeader()) 
    675618     { 
    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); 
    682625   } 
    683626 
     
    687630      CBufferIn* buffer=event.subEvents.begin()->buffer; 
    688631      string id; 
    689       *buffer>>id ; 
    690       get(id)->recvCreateFileHeader(*buffer) ; 
     632      *buffer>>id; 
     633      get(id)->recvCreateFileHeader(*buffer); 
    691634   } 
    692635 
     
    694637   void CContext::recvCreateFileHeader(CBufferIn& buffer) 
    695638   { 
    696       createFileHeader() ; 
     639      createFileHeader(); 
    697640   } 
    698641 
     
    702645     if (!hasServer) 
    703646     { 
    704        CEventClient event(getType(),EVENT_ID_POST_PROCESS) ; 
     647       CEventClient event(getType(),EVENT_ID_POST_PROCESS); 
    705648       if (client->isServerLeader()) 
    706649       { 
    707          CMessage msg ; 
     650         CMessage msg; 
    708651         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); 
    711654       } 
    712        else client->sendEvent(event) ; 
     655       else client->sendEvent(event); 
    713656     } 
    714657   } 
     
    726669   void CContext::recvPostProcessing(CBufferIn& buffer) 
    727670   { 
     671      CCalendarWrapper::get(CCalendarWrapper::GetDefName())->createCalendar(); 
    728672      postProcessing(); 
    729673//      std::cout << "server context " << *this << std::endl; 
     
    751695     if (isPostProcessed) return; 
    752696 
    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() << "!\"") 
    755702 
    756703      // Find all inheritance in xml structure 
     
    932879   void CContext::updateCalendar(int step) 
    933880   { 
    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; 
    937884   } 
    938885 
     
    940887   void CContext::createFileHeader(void ) 
    941888   { 
    942       vector<CFile*>::const_iterator it ; 
     889      vector<CFile*>::const_iterator it; 
    943890 
    944891      for (it=enabledFiles.begin(); it != enabledFiles.end(); it++) 
     
    951898   CContext* CContext::getCurrent(void) 
    952899   { 
    953      return CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()).get() ; 
     900     return CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()).get(); 
    954901   } 
    955902 
     
    971918  CContext* CContext::create(const StdString& id) 
    972919  { 
    973     CContext::setCurrent(id) ; 
     920    CContext::setCurrent(id); 
    974921 
    975922    bool hasctxt = CContext::has(id); 
    976923    CContext* context = CObjectFactory::CreateObject<CContext>(id).get(); 
    977     getRoot() ; 
     924    getRoot(); 
    978925    if (!hasctxt) CGroupFactory::AddChild(root, context->getShared()); 
    979926 
  • XIOS/trunk/src/node/context.hpp

    r511 r549  
    55#include "xmlioserver_spl.hpp" 
    66//#include "node_type.hpp" 
    7 #include "calendar.hpp" 
     7#include "calendar_wrapper.hpp" 
    88 
    99#include "declare_group.hpp" 
     
    1616 
    1717namespace xios { 
    18    class CContextClient ; 
    19    class CContextServer ; 
     18   class CContextClient; 
     19   class CContextServer; 
    2020 
    2121 
     
    5151           EVENT_ID_CREATE_FILE_HEADER,EVENT_ID_CONTEXT_FINALIZE, 
    5252           EVENT_ID_POST_PROCESS 
    53          } ; 
     53         }; 
    5454 
    5555         /// typedef /// 
     
    8787      public : 
    8888         // 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); 
    9292 
    9393         // 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); 
    10097 
    10198         // Finalize a context 
    102          void finalize(void) ; 
    103          void closeDefinition(void) ; 
     99         void finalize(void); 
     100         void closeDefinition(void); 
    104101 
    105102         // Some functions to process context 
    106103         void findAllEnabledFields(void); 
    107          void processEnabledFiles(void) ; 
    108          void solveAllInheritance(bool apply=true) ; 
     104         void processEnabledFiles(void); 
     105         void solveAllInheritance(bool apply=true); 
    109106         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 ); 
    113110         void solveAllRefOfEnabledFields(bool sendToServer); 
    114111         void buildAllExpressionOfEnabledFields(); 
     
    119116 
    120117         // Send context close definition 
    121          void sendCloseDefinition(void) ; 
     118         void sendCloseDefinition(void); 
    122119         // 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); 
    125122         void sendEnabledFiles(); 
    126123         void sendEnabledFields(); 
     
    132129 
    133130         // 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); 
    139136         static void recvSolveInheritanceContext(CEventServer& event); 
    140137         void recvSolveInheritanceContext(CBufferIn& buffer); 
     
    143140 
    144141         // dispatch event 
    145          static bool dispatchEvent(CEventServer& event) ; 
     142         static bool dispatchEvent(CEventServer& event); 
    146143 
    147144      public: 
     
    191188 
    192189         // Context root 
    193          static shared_ptr<CContextGroup> root ; 
     190         static shared_ptr<CContextGroup> root; 
    194191 
    195192         // Determine context on client or not 
    196          bool hasClient ; 
     193         bool hasClient; 
    197194 
    198195         // Determine context on server or not 
    199          bool hasServer ; 
     196         bool hasServer; 
    200197 
    201198         // Concrete context server 
    202          CContextServer* server ; 
     199         CContextServer* server; 
    203200 
    204201         // Concrete contex client 
    205          CContextClient* client ; 
     202         CContextClient* client; 
    206203 
    207204      private: 
  • XIOS/trunk/src/node/node_enum.hpp

    r501 r549  
    1717         eGrid,gGrid, 
    1818         eVariable,gVariable, 
    19          eContext,gContext 
     19         eContext,gContext, 
     20         eCalendarWrapper 
    2021 
    2122//#include "node_type.conf" 
  • XIOS/trunk/src/object_factory_decl.cpp

    r501 r549  
    1414  template bool CObjectFactory::HasObject<U>(const StdString& context,const StdString & id); \ 
    1515  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 
    1818  macro(CField) 
    1919  macro(CFile) 
     
    2222  macro(CDomain) 
    2323  macro(CContext) 
     24  macro(CCalendarWrapper) 
    2425  macro(CVariable) 
    2526 
  • XIOS/trunk/src/object_template_decl.cpp

    r501 r549  
    1212namespace xios 
    1313{ 
    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  
    141141      void CObjectTemplate<T>::solveDescInheritance(bool apply, const CAttributeMap * const parent) 
    142142   { 
    143       SuperClassMap::setAttributes(parent, apply); 
     143      if (parent != NULL) 
     144         SuperClassMap::setAttributes(parent, apply); 
    144145   } 
    145146 
     
    149150      void CObjectTemplate<T>::ClearAllAttributes(void) 
    150151   { 
    151       vector<T*> avect = CObjectTemplate<T>::getAll() ; 
     152      vector<T*> avect = CObjectTemplate<T>::getAll(); 
    152153      typename vector<T*>::iterator 
    153154            it = avect.begin(), end = avect.end(); 
     
    176177   { 
    177178      CAttributeMap & attrMap = *this; 
    178       CAttribute* attr=attrMap[id] ; 
    179       sendAttributToServer(*attr) ; 
     179      CAttribute* attr=attrMap[id]; 
     180      sendAttributToServer(*attr); 
    180181   } 
    181182 
     
    183184  void CObjectTemplate<T>::sendAttributToServer(CAttribute& attr) 
    184185  { 
    185     CContext* context=CContext::getCurrent() ; 
     186    CContext* context=CContext::getCurrent(); 
    186187 
    187188    if (!context->hasServer) 
    188189    { 
    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); 
    192193       if (client->isServerLeader()) 
    193194       { 
    194          CMessage msg ; 
    195 //         msg<<this->getId() ; 
     195         CMessage msg; 
     196//         msg<<this->getId(); 
    196197         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); 
    201202       } 
    202        else client->sendEvent(event) ; 
     203       else client->sendEvent(event); 
    203204    } 
    204205 
     
    211212    CBufferIn* buffer=event.subEvents.begin()->buffer; 
    212213    string id,attrId; 
    213     *buffer>>id ; 
     214    *buffer>>id; 
    214215    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; 
    224225  } 
    225226 
     
    230231      { 
    231232         case EVENT_ID_SEND_ATTRIBUTE : 
    232            recvAttributFromClient(event) ; 
    233            return true ; 
    234            break ; 
     233           recvAttributFromClient(event); 
     234           return true; 
     235           break; 
    235236 
    236237         default : 
    237          return false ; 
     238         return false; 
    238239//           ERROR("void CObjectTemplate<T>::recvEvent(CEventServer& event)", 
    239 //                 <<"Unknown Event") ; 
     240//                 <<"Unknown Event"); 
    240241      } 
    241242   } 
     
    244245   bool CObjectTemplate<T>::has(const string & id) 
    245246   { 
    246      return CObjectFactory::HasObject<T>(id) ; 
     247     return CObjectFactory::HasObject<T>(id); 
    247248   } 
    248249 
     
    250251   bool CObjectTemplate<T>::has(const string& contextId, const string & id) 
    251252   { 
    252      return CObjectFactory::HasObject<T>(contextId,id) ; 
     253     return CObjectFactory::HasObject<T>(contextId,id); 
    253254   } 
    254255 
     
    256257   T* CObjectTemplate<T>::get(const string & id) 
    257258   { 
    258      return CObjectFactory::GetObject<T>(id).get() ; 
     259     return CObjectFactory::GetObject<T>(id).get(); 
    259260   } 
    260261 
     
    262263   T* CObjectTemplate<T>::get(const T* ptr) 
    263264   { 
    264      return CObjectFactory::GetObject<T>(ptr).get() ; 
     265     return CObjectFactory::GetObject<T>(ptr).get(); 
    265266   } 
    266267 
     
    268269   shared_ptr<T> CObjectTemplate<T>::getShared(const T* ptr) 
    269270   { 
    270      return CObjectFactory::GetObject<T>(ptr) ; 
     271     return CObjectFactory::GetObject<T>(ptr); 
    271272   } 
    272273 
     
    274275   shared_ptr<T> CObjectTemplate<T>::getShared(void) 
    275276   { 
    276      return CObjectFactory::GetObject<T>((T*)this) ; 
     277     return CObjectFactory::GetObject<T>((T*)this); 
    277278   } 
    278279 
     
    281282   { 
    282283     const vector< shared_ptr<T> >& shared_vect= CObjectFactory::GetObjectVector<T>(); 
    283      vector<T*> vect ; 
     284     vector<T*> vect; 
    284285 
    285286     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; 
    288289   } 
    289290 
     
    292293   { 
    293294     const vector< shared_ptr<T> >& shared_vect= CObjectFactory::GetObjectVector<T>(id); 
    294      vector<T*> vect ; 
     295     vector<T*> vect; 
    295296 
    296297     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; 
    299300   } 
    300301 
     
    302303   T* CObjectTemplate<T>::get(const string& contextId, const string & id) 
    303304   { 
    304      return CObjectFactory::GetObject<T>(contextId,id).get() ; 
     305     return CObjectFactory::GetObject<T>(contextId,id).get(); 
    305306   } 
    306307 
     
    308309   T* CObjectTemplate<T>::create(const string & id) 
    309310   { 
    310      return CObjectFactory::CreateObject<T>(id).get() ; 
     311     return CObjectFactory::CreateObject<T>(id).get(); 
    311312   }   ///-------------------------------------------------------------- 
    312313 
     
    314315  T* CObjectTemplate<T>::get(void) 
    315316  { 
    316     return CObjectFactory::GetObject<T>((T*)this).get() ; 
     317    return CObjectFactory::GetObject<T>((T*)this).get(); 
    317318  } 
    318319 
     
    320321   void CObjectTemplate<T>::generateCInterface(ostream& oss) 
    321322   { 
    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; 
    328329     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; 
    332333     oss<<"#include \"xmlioserver.hpp\""<<iendl; 
    333      oss<<"#include \"attribute_template.hpp\""<<iendl ; 
     334     oss<<"#include \"attribute_template.hpp\""<<iendl; 
    334335     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++; 
    343344     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; 
    348349   } 
    349350 
     
    351352   void CObjectTemplate<T>::generateFortran2003Interface(ostream& oss) 
    352353   { 
    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 
    359358     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; 
    372373   } 
    373374 
     
    375376   void CObjectTemplate<T>::generateFortranInterface(ostream& oss) 
    376377   { 
    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); 
    380381     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 
    386385     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; 
    418419   } 
    419420 
  • XIOS/trunk/src/test/test_client.f90

    r545 r549  
    88  INTEGER :: size 
    99  INTEGER :: ierr 
    10    
     10 
    1111  CHARACTER(len=*),PARAMETER :: id="client" 
    1212  INTEGER :: comm 
    1313  TYPE(xios_duration) :: dtime 
    1414  TYPE(xios_date) :: date 
     15  CHARACTER(len=10) :: calendar_type 
    1516  TYPE(xios_context) :: ctx_hdl 
    1617  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 
    1920  DOUBLE PRECISION  :: lval(llm)=1 
    2021  TYPE(xios_field) :: field_hdl 
     
    2223  TYPE(xios_file) :: file_hdl 
    2324  LOGICAL :: ok 
    24    
     25 
    2526  DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo 
    2627  DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm) 
     
    3233 
    3334  CALL MPI_INIT(ierr) 
    34    
     35 
    3536  CALL init_wait 
    36   
     37 
    3738!!! XIOS Initialization (get the local communicator) 
    3839 
     
    4041 
    4142  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 
    4445  DO j=1,nj_glo 
    4546    DO i=1,ni_glo 
     
    5758    nj=nj_glo/size 
    5859    IF (n<MOD(nj_glo,size)) nj=nj+1 
    59     IF (n==rank) exit  
     60    IF (n==rank) exit 
    6061    jbegin=jbegin+nj 
    6162  ENDDO 
    62    
     63 
    6364  iend=ibegin+ni-1 ; jend=jbegin+nj-1 
    6465 
     
    6768  lat(:,:)=lat_glo(ibegin:iend,jbegin:jend) 
    6869  field_A(1:ni,1:nj,:)=field_A_glo(ibegin:iend,jbegin:jend,:) 
    69    
     70 
    7071  CALL xios_context_initialize("test",comm) 
    7172  CALL xios_get_handle("test",ctx_hdl) 
    7273  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 
    7578  CALL xios_set_axis_attr("axis_A",size=llm ,value=lval) ; 
    7679  CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj) 
     
    7881  CALL xios_set_domain_attr("domain_A",lonvalue=RESHAPE(lon,(/ni*nj/)),latvalue=RESHAPE(lat,(/ni*nj/))) 
    7982  CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) 
    80    
     83 
    8184  CALL xios_get_handle("field_definition",fieldgroup_hdl) 
    8285  CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B") 
    8386  CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_B") 
    84    
     87 
    8588  CALL xios_get_handle("output",file_hdl) 
    8689  CALL xios_add_child(file_hdl,field_hdl) 
    8790  CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_C") 
    88      
    89   
     91 
    9092  dtime%second = 3600 
    91   CALL xios_set_context_attr("test", timestep=dtime) 
     93  CALL xios_set_timestep(dtime) 
    9294 
    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() 
    97100  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) 
    98106  dtime%timestep = 1 
    99107  dtime = 0.5 * dtime 
     
    103111  PRINT *, "xios_date_convert_to_seconds(date) = ", xios_date_convert_to_seconds(date) 
    104112  PRINT *, "xios_date_convert_to_seconds(date - 2.5h) = ", xios_date_convert_to_seconds(date - 2.5 * xios_hour) 
    105    
     113 
    106114  ni=0 ; lonvalue(:)=0 
    107115  CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue=lonvalue) 
    108    
     116 
    109117  print *,"ni",ni 
    110118  print *,"lonvalue",lonvalue ; 
     
    113121  PRINT *,"field_A : attribute enabled is defined ? ",ok 
    114122  CALL xios_close_context_definition() 
    115    
     123 
    116124  PRINT*,"field field_A is active ? ",xios_field_is_active("field_A") 
    117125  DO ts=1,24*10 
     
    123131  CALL xios_context_finalize() 
    124132  CALL xios_finalize() 
    125    
     133 
    126134  CALL MPI_FINALIZE(ierr) 
    127    
     135 
    128136END PROGRAM test_client 
    129137 
    130138 
    131    
    132139 
    133    
     140 
     141 
  • XIOS/trunk/src/test/test_complete.f90

    r537 r549  
    88  INTEGER :: size_loc 
    99  INTEGER :: ierr 
    10    
     10 
    1111  CHARACTER(len=*),PARAMETER :: id="client" 
    1212  INTEGER :: comm 
    13   TYPE(xios_date)      :: start_date, time_origin 
    1413  TYPE(xios_duration)  :: dtime 
    1514  TYPE(xios_context) :: ctx_hdl 
    1615  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 
    1918  DOUBLE PRECISION  :: lval(llm)=1 
    2019  TYPE(xios_field) :: field_hdl 
     
    3433 
    3534  CALL MPI_INIT(ierr) 
    36    
     35 
    3736  CALL init_wait 
    38   
     37 
    3938!!! XIOS Initialization (get the local communicator) 
    4039 
     
    4241 
    4342  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 
    4645 
    4746!########################################################################### 
     
    6665    nj=nj_glo/size_loc 
    6766    IF (n<MOD(nj_glo,size_loc)) nj=nj+1 
    68     IF (n==rank) exit  
     67    IF (n==rank) exit 
    6968    jbegin=jbegin+nj 
    7069  ENDDO 
    71    
     70 
    7271  iend=ibegin+ni-1 ; jend=jbegin+nj-1 
    7372 
     
    7675  lat(:,:)=lat_glo(ibegin:iend,jbegin:jend) 
    7776  field_A_atm(1:ni,1:nj,:)=field_A_glo(ibegin:iend,jbegin:jend,:) 
    78   
     77 
    7978 
    8079!!! Context ATMOSPHERE 
     
    8382  CALL xios_get_handle("atmosphere",ctx_hdl) 
    8483  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)) 
    9188 
    9289  CALL xios_set_axis_attr("axis_atm",size=llm ,value=lval) ; 
     
    104101  CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) 
    105102 
    106 !!! Création d un nouveau champ  
     103!!! Création d un nouveau champ 
    107104 
    108105  CALL xios_get_handle("field_definition",fieldgroup_hdl) 
     
    112109 
    113110  CALL xios_set_attr(field_hdl,field_ref="field_A_atm",name="field_B_atm") 
    114    
     111 
    115112!!! Affectation de ce nouveau champ au fichier avec un nouveau nom 
    116113 
     
    118115  CALL xios_add_child(file_hdl,field_hdl) 
    119116  CALL xios_set_attr(field_hdl,field_ref="field_B_atm",name="field_C_atm") 
    120      
     117 
    121118!!! Definition du timestep 
    122119 
    123120  dtime%second=3600 
    124   CALL xios_set_context_attr("atmosphere", timestep=dtime) 
    125      
     121  CALL xios_set_timestep(timestep=dtime) 
     122 
    126123!!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalité) 
    127124 
    128125  ni=0 ; lonvalue(:)=0 
    129126  CALL xios_get_domain_attr("domain_atm",ni=ni,lonvalue=lonvalue) 
    130      
     127 
    131128  PRINT *,"ni",ni 
    132129  PRINT *,"lonvalue",lonvalue ; 
     
    137134 
    138135!!! Test des valeurs des champs/fichiers 
    139    
    140   !!! Attribut defini ?  
     136 
     137  !!! Attribut defini ? 
    141138 
    142139  CALL xios_is_defined_field_attr("field_A_atm",enabled=ok) 
     
    144141 
    145142  !!! Recuperer la valeur d un attribut 
    146    
     143 
    147144  CALL xios_get_field_attr("field_A_atm",name=crname) 
    148145  PRINT *,"field_A_atm : attribute name is : ",TRIM(crname) 
    149146 
    150   !!! Champ actif (besoin de fournir la valeur) ?  
     147  !!! Champ actif (besoin de fournir la valeur) ? 
    151148 
    152149    PRINT*,"field field_A_atm is active ? ",xios_field_is_active("field_A_atm") 
     
    173170  CALL xios_get_handle("surface",ctx_hdl) 
    174171  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)) 
    181176 
    182177  CALL xios_set_axis_attr("axis_srf",size=llm ,value=lval) ; 
     
    186181  CALL xios_set_domain_attr("domain_srf",lonvalue=RESHAPE(lon,(/ni*nj/)),latvalue=RESHAPE(lat,(/ni*nj/))) 
    187182 
    188 !!! Création d un nouveau champ  
     183!!! Création d un nouveau champ 
    189184 
    190185  CALL xios_get_handle("field_definition",fieldgroup_hdl) 
     
    194189 
    195190  CALL xios_set_attr(field_hdl,field_ref="field_A_srf",name="field_B_srf") 
    196    
     191 
    197192!!! Affectation de ce nouveau champ au fichier avec un nouveau nom 
    198193 
     
    200195  CALL xios_add_child(file_hdl,field_hdl) 
    201196  CALL xios_set_attr(field_hdl,field_ref="field_B_srf",name="field_C_srf") 
    202      
     197 
    203198!!! Definition du timestep 
    204199 
    205200  dtime%second=1800 
    206   CALL xios_set_context_attr("surface", timestep=dtime) 
    207      
     201  CALL xios_set_timestep(timestep=dtime) 
     202 
    208203!!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalité) 
    209204 
    210205  ni=0 ; lonvalue(:)=0 
    211206  CALL xios_get_domain_attr("domain_srf",ni=ni,lonvalue=lonvalue) 
    212      
     207 
    213208  PRINT *,"ni",ni 
    214209  PRINT *,"lonvalue",lonvalue ; 
     
    226221 
    227222      CALL xios_get_handle("atmosphere",ctx_hdl) 
    228       CALL xios_set_current_context(ctx_hdl)     
     223      CALL xios_set_current_context(ctx_hdl) 
    229224 
    230225!!! Mise a jour du pas de temps 
     
    239234 
    240235      CALL xios_get_handle("surface",ctx_hdl) 
    241       CALL xios_set_current_context(ctx_hdl)     
     236      CALL xios_set_current_context(ctx_hdl) 
    242237 
    243238!!! Mise a jour du pas de temps 
     
    257252 
    258253!!! Fin des contextes 
    259      
     254 
    260255    CALL xios_context_finalize() 
    261256    CALL xios_get_handle("atmosphere",ctx_hdl) 
    262     CALL xios_set_current_context(ctx_hdl)     
     257    CALL xios_set_current_context(ctx_hdl) 
    263258    CALL xios_context_finalize() 
    264      
     259 
    265260!!! Fin de XIOS 
    266261 
    267262    CALL xios_finalize() 
    268    
     263 
    269264    CALL MPI_FINALIZE(ierr) 
    270    
     265 
    271266  END PROGRAM test_complete 
    272267 
    273268 
    274269 
    275    
    276  
    277    
     270 
     271 
     272 
  • XIOS/trunk/src/test/test_cs.f90

    r537 r549  
    55  INTEGER :: size 
    66  INTEGER :: ierr 
    7    
     7 
    88  CALL MPI_INIT(ierr) 
    99  CALL MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr) 
    1010  CALL MPI_COMM_SIZE(MPI_COMM_WORLD,size,ierr) 
    11    
     11 
    1212  IF (rank<11) THEN 
    1313   CALL client("client",rank,11) 
    14   ELSE  
     14  ELSE 
    1515    CALL server 
    1616  ENDIF 
    17    
    18    
     17 
     18 
    1919  CALL MPI_FINALIZE(ierr) 
    20    
     20 
    2121END PROGRAM test_cs 
    2222 
     
    3232  TYPE(xios_duration) :: dtime 
    3333  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 
    3737  DOUBLE PRECISION  :: lval(llm)=(/1.0,2.0,3.0/) 
    3838  TYPE(xios_field) :: field_hdl 
    3939  TYPE(xios_fieldgroup) :: fieldgroup_hdl 
    4040  TYPE(xios_file) :: file_hdl 
    41    
    42    
     41 
     42 
    4343  DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo 
    4444  DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm) 
     
    4747  INTEGER :: ni,ibegin,iend,nj,jbegin,jend,data_ibegin,data_ni 
    4848  INTEGER :: i,j,k,l,ts,n,nij_begin 
    49    
    50    
     49 
     50 
    5151  CALL init_wait 
    52    
    53    
     52 
     53 
    5454  DO j=1,nj_glo 
    5555    DO i=1,ni_glo 
     
    6363  ni=ni_glo ; ibegin=1 
    6464 
    65    
     65 
    6666  nij_begin=1 
    6767  DO n=0,size-1 
     
    7070    IF (n==rank) THEN 
    7171      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 
    7373      jend=MOD(nij_begin-1 + data_ni-1,ni_glo) +1 
    7474      nj = jend-jbegin+1 
     
    7979    ENDIF 
    8080  ENDDO 
    81    
     81 
    8282 
    8383  ALLOCATE(lon(ni),lat(nj),field_A(data_ni,llm),lonvalue(ni*nj)) 
     
    9292    field_A(k,:)=field_A_glo(i,j,:) 
    9393  ENDDO 
    94    
     94 
    9595  mask(:,:)=.TRUE. 
    9696  mask(1:ni,6)=.TRUE. 
    97    
     97 
    9898 
    9999  CALL xios_initialize(id,return_comm=comm) 
     
    102102  CALL xios_get_handle("test",ctx_hdl) 
    103103  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)) 
    110107  CALL xios_set_axis_attr("axis_A",size=llm ,value=lval) ; 
    111108  CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, iend=iend,jbegin=jbegin,jend=jend) 
    112 !  CALL xios_set_domain_attr("domain_A",zoom_ni=10,zoom_ibegin=5,zoom_nj=nj_glo,zoom_jbegin=1) 
     109! CALL xios_set_domain_attr("domain_A",zoom_ni=10,zoom_ibegin=5,zoom_nj=nj_glo,zoom_jbegin=1) 
    113110  CALL xios_set_domain_attr("domain_A",data_dim=1, data_ibegin=data_ibegin, data_ni=data_ni) 
    114111  CALL xios_set_domain_attr("domain_A",lonvalue=lon,latvalue=lat) 
    115 !  CALL xios_set_domain_attr("domain_A",mask=mask) 
     112! CALL xios_set_domain_attr("domain_A",mask=mask) 
    116113  CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) 
    117    
     114 
    118115  CALL xios_get_handle("field_definition",fieldgroup_hdl) 
    119116  CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B") 
    120117  CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_B") 
    121    
     118 
    122119  CALL xios_get_handle("output",file_hdl) 
    123120  CALL xios_add_child(file_hdl,field_hdl) 
    124121  CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_C") 
    125      
    126   
     122 
     123 
    127124    dtime%second=3600 
    128     CALL xios_set_context_attr("test", timestep=dtime) 
    129      
     125    CALL xios_set_timestep(timestep=dtime) 
     126 
    130127!    ni=0 ; lonvalue(:)=0 
    131128!    CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue=lonvalue) 
    132      
     129 
    133130!    print *,"ni",ni 
    134131!    print *,"lonvalue",lonvalue ; 
    135132 
    136133    CALL xios_close_context_definition() 
    137      
     134 
    138135    PRINT*,"field field_A is active ? ",xios_field_is_active("field_A") 
    139136    DO ts=1,24*10 
     
    142139      CALL wait_us(5000) ; 
    143140    ENDDO 
    144    
     141 
    145142    CALL xios_context_finalize() 
    146143    CALL xios_finalize() 
    147       
     144 
    148145  END SUBROUTINE client 
    149    
    150146 
    151    
     147 
     148 
    152149  SUBROUTINE server 
    153150  USE xios 
    154151  IMPLICIT NONE 
    155    
     152 
    156153    CALL xios_init_server 
    157   
     154 
    158155  END SUBROUTINE server 
    159    
    160156 
    161    
     157 
     158 
  • XIOS/trunk/src/test/test_new_features.f90

    r543 r549  
    6969 
    7070  ALLOCATE(lon(ni,nj),lat(ni,nj),field_A(0:ni+1,-1:nj+2,llm),lonvalue(ni*nj)) 
    71 !  ALLOCATE(lon(ni,nj),lat(ni,nj),field_A(0:ni+1,-1:nj+2,llm,llm),lonvalue(ni*nj)) 
     71! ALLOCATE(lon(ni,nj),lat(ni,nj),field_A(0:ni+1,-1:nj+2,llm,llm),lonvalue(ni*nj)) 
    7272  lon(:,:)=lon_glo(ibegin:iend,jbegin:jend) 
    7373  lat(:,:)=lat_glo(ibegin:iend,jbegin:jend) 
     
    7878  CALL xios_set_current_context(ctx_hdl) 
    7979 
    80   CALL xios_set_context_attr("test",calendar_type="Gregorian") 
     80! CALL xios_define_calendar(type="Gregorian") 
    8181  CALL xios_set_axis_attr("axis_A",size=llm ,value=lval) ; 
    82 !  CALL xios_set_axis_attr("axis_B",size=llm ,value=lval2) ; 
     82! CALL xios_set_axis_attr("axis_B",size=llm ,value=lval2) ; 
    8383  CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj) 
    8484  CALL xios_set_domain_attr("domain_A",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4) 
     
    9696 
    9797    dtime%second=3600 
    98     CALL xios_set_context_attr("test", timestep=dtime) 
     98!   CALL xios_set_timestep(timestep=dtime) 
    9999 
    100100    ni=0 ; lonvalue(:)=0 
  • XIOS/trunk/src/test/test_unstruct_complete.f90

    r537 r549  
    88  INTEGER :: mpi_size 
    99  INTEGER :: ierr 
    10    
     10 
    1111  CHARACTER(len=*),PARAMETER :: id="client" 
    1212  INTEGER :: comm 
    1313  TYPE(xios_duration) :: dtime 
    1414  TYPE(xios_context) :: ctx_hdl 
    15   INTEGER, PARAMETER :: nlon=60  
     15  INTEGER, PARAMETER :: nlon=60 
    1616  INTEGER, PARAMETER :: nlat=30 
    1717  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 
    2020  DOUBLE PRECISION  :: lval(llm)=1 
    2121  TYPE(xios_field) :: field_hdl 
     
    2323  TYPE(xios_file) :: file_hdl 
    2424  LOGICAL :: ok 
    25    
     25 
    2626  DOUBLE PRECISION,ALLOCATABLE :: lon_glo(:),lat_glo(:) 
    2727  DOUBLE PRECISION,ALLOCATABLE :: bounds_lon_glo(:,:),bounds_lat_glo(:,:) 
     
    4242  INTEGER,ALLOCATABLE :: data_i_index(:) 
    4343  DOUBLE PRECISION,ALLOCATABLE :: field_A_compressed(:,:) 
    44    
     44 
    4545  CALL xios_initialize(id,return_comm=comm) 
    4646  CALL MPI_COMM_RANK(comm,mpi_rank,ierr) 
    4747  CALL MPI_COMM_SIZE(comm,mpi_size,ierr) 
    48    
     48 
    4949  CALL init_wait 
    50    
     50 
    5151  ncell_glo=0 
    5252  DO j=1,nlat 
     
    5555    ncell_glo=ncell_glo+n 
    5656  ENDDO 
    57    
     57 
    5858  ALLOCATE(lon_glo(ncell_glo)) 
    5959  ALLOCATE(lat_glo(ncell_glo)) 
     
    6363  ALLOCATE(field_A_glo(ncell_glo,llm)) 
    6464  ALLOCATE(mask_glo(ncell_glo)) 
    65     
     65 
    6666  ind=0 
    6767  DO j=1,nlat 
     
    7070    if (j==nlat) PRINT*,"--- ",n 
    7171    IF (n<8) n=8 
    72      
     72 
    7373    DO i=1,n 
    7474      ind=ind+1 
     
    7676      ilon=i-0.5 
    7777      ilat=j-0.5 
    78        
     78 
    7979      lat_glo(ind)= 90-(ilat*180./nlat) 
    8080      lon_glo(ind)= (ilon*360./n) 
    81        
    82   
     81 
     82 
    8383      bounds_lat_glo(1,ind)= 90-((ilat-0.5)*180./nlat) 
    8484      bounds_lon_glo(1,ind)=((ilon-0.5)*360./n) 
    85        
     85 
    8686      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 
    8989      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) 
    9191 
    9292      bounds_lat_glo(4,ind)= 90-((ilat+0.5)*180./nlat) 
    9393      bounds_lon_glo(4,ind)=((ilon-0.5)*360./n) 
    94        
     94 
    9595    ENDDO 
    9696  ENDDO 
     
    9999  rank=(mpi_size-1)/2 
    100100  ncell_x=sqrt(ncell_glo*1./mpi_size) 
    101    
     101 
    102102  j1=nlat/2 
    103103  DO WHILE(rank>=0) 
     
    106106    n=NINT(COS(Pi/2-(j-0.5)*PI/nlat)*nlon) 
    107107    np = MIN(n/ncell_x,rank+1) ; 
    108     if (j2==1) np=rank+1  
    109      
     108    if (j2==1) np=rank+1 
     109 
    110110    PRINT *,"domain ",j2,j1,rank,np ; 
    111     DO j=j2,j1   
     111    DO j=j2,j1 
    112112      n=NINT(COS(Pi/2-(j-0.5)*PI/nlat)*nlon) 
    113113      IF (n<8) n=8 
    114114      DO i=1,n 
    115115        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 
    117117          i_index_glo(ind) = rank - (i-1)/(n/np+1) 
    118         ELSE  
     118        ELSE 
    119119          i_index_glo(ind) = rank-(MOD(n,np)+ (i-1-MOD(n,np)*(n/np+1))/(n/np)) 
    120120        ENDIF 
     
    124124    j1=j2-1 
    125125  ENDDO 
    126          
     126 
    127127  rank=(mpi_size-1)/2+1 
    128128  ncell_x=sqrt(ncell_glo*1./mpi_size) 
    129    
     129 
    130130  j1=nlat/2+1 
    131131  DO WHILE(rank<=mpi_size-1) 
     
    134134    n=NINT(COS(Pi/2-(j-0.5)*PI/nlat)*nlon) 
    135135    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 
    138138    PRINT *,"domain ",j2,j1,rank,np ; 
    139     DO j=j1,j2   
     139    DO j=j1,j2 
    140140      n=NINT(COS(Pi/2-(j-0.5)*PI/nlat)*nlon) 
    141141      IF (n<8) n=8 
    142142      DO i=1,n 
    143143        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 
    145145          i_index_glo(ind) = rank + (i-1)/(n/np+1) 
    146         ELSE  
     146        ELSE 
    147147          i_index_glo(ind) = rank+(MOD(n,np)+ (i-1-MOD(n,np)*(n/np+1))/(n/np)) 
    148148        ENDIF 
     
    152152    j1=j2+1 
    153153  ENDDO 
    154      
     154 
    155155  ncell=0 
    156156  DO ind=1,ncell_glo 
     
    183183    ENDIF 
    184184  ENDDO 
    185    
     185 
    186186  ALLOCATE(field_A_compressed(data_n_index,llm)) 
    187187  ALLOCATE(data_i_index(data_n_index)) 
     
    194194    ENDIF 
    195195  ENDDO 
    196        
    197    
    198    
     196 
    199197  CALL xios_context_initialize("surface",comm) 
    200198  CALL xios_get_handle("surface",ctx_hdl) 
    201199  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 
    203205  CALL xios_set_axis_attr("axis_srf",size=llm ,value=lval) ; 
    204206  CALL xios_set_domain_attr("domain_srf",ni_glo=ncell_glo, ni=ncell, ibegin=1, i_index=RESHAPE(i_index,(/ncell,1/) )) 
     
    206208  CALL xios_set_domain_attr("domain_srf",lonvalue=lon,latvalue=lat) 
    207209  CALL xios_set_domain_attr("domain_srf", nvertex=4, bounds_lon=bounds_lon, bounds_lat=bounds_lat ) 
    208      
    209   
     210 
     211 
    210212  dtime%second=3600 
    211213  CALL xios_set_context_attr("surface", timestep=dtime) 
    212214  CALL xios_close_context_definition() 
    213      
     215 
    214216   DO ts=1,24*10 
    215217     CALL xios_update_calendar(ts) 
    216218     CALL xios_send_field("field_A_srf",field_A_compressed) 
    217219    ENDDO 
    218    
     220 
    219221    CALL xios_context_finalize() 
    220222    CALL xios_finalize() 
    221    
     223 
    222224  END PROGRAM test_unstruct_complete 
    223225 
    224226 
    225    
    226  
    227    
     227 
     228 
     229 
  • XIOS/trunk/src/test/test_xios_interface.f90

    r537 r549  
    9696  CALL xios_set_current_context(ctx_hdl) 
    9797 
    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)) 
    103101 
    104102  CALL xios_set_axis_attr("axis_atm",size=llm ,value=lval) ; 
     
    131129 
    132130  dtime%second=3600 
    133   CALL xios_set_context_attr("atmosphere", timestep=dtime) 
     131  CALL xios_set_timestep(timestep=dtime) 
    134132 
    135133!!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalité) 
     
    183181  CALL xios_set_current_context(ctx_hdl) 
    184182 
    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)) 
    190186 
    191187  CALL xios_set_axis_attr("axis_srf",size=llm ,value=lval) ; 
     
    213209 
    214210  dtime%second=1800 
    215   CALL xios_set_context_attr("surface", timestep=dtime) 
     211  CALL xios_set_timestep(timestep=dtime) 
    216212 
    217213!!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalité) 
  • XIOS/trunk/src/type/type_util.hpp

    r501 r549  
    55namespace xios 
    66{ 
    7     class CDomain ; 
     7    class CDomain; 
    88    class CDomainGroup; 
    99    class CField; 
     
    1717    class CContext; 
    1818    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); } 
    2526 
    2627  macro(short) 
     
    3839  macro(bool) 
    3940#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); } 
    4243  macro(CDomain) 
    4344  macro(CDomainGroup) 
     
    5253  macro(CContext) 
    5354  macro(CContextGroup) 
     55  macro(CCalendarWrapper) 
    5456  macro(CVariable) 
    5557  macro(CVariableGroup) 
    56    
    57   
     58 
    5859#undef macro 
    59  
    6060} 
    6161 
Note: See TracChangeset for help on using the changeset viewer.