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

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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/context.cpp

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