Ignore:
Timestamp:
12/11/14 14:32:37 (9 years ago)
Author:
rlacroix
Message:

Add a new attribute type for durations and use it for the context's timestep.

Note that the "xios_time" type and the "xios_set_timestep" procedure have been removed from the Fortran interface. Instead, the "xios_duration" type and the "xios_get_context_attr"/"xios_set_context_attr" procedures should now be used to get/set the timestep.

Location:
XIOS/trunk/src/interface
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/interface/c/icdate.cpp

    r509 r537  
    2323// /////////////////////////////// Définitions ////////////////////////////// // 
    2424 
    25    void cxios_set_timestep(double ts_year, double ts_month,  double ts_day, 
    26                           double ts_hour, double ts_minute, double ts_second) 
    27    { 
    28       try 
    29       { 
    30          CTimer::get("XIOS").resume() ; 
    31          CDuration dur = {ts_year, ts_month, ts_day, ts_hour, ts_minute, ts_second, 0}; 
    32          xios::CContext* context = CContext::getCurrent() ; 
    33          context->timestep.setValue(dur.toString()); 
    34          CTimer::get("XIOS").suspend() ; 
    35       } 
    36       catch (xios::CException & exc) 
    37       { 
    38          std::cerr << exc.getMessage() << std::endl; 
    39          exit (EXIT_FAILURE); 
    40       } 
    41    } 
    42  
    4325   void cxios_update_calendar(int step) 
    4426   { 
  • XIOS/trunk/src/interface/c/icdate.hpp

    r533 r537  
    44 
    55  typedef struct { int year, month, day, hour, minute, second; } cxios_date; 
     6  typedef struct { double year, month, day, hour, minute, second, timestep; } cxios_duration; 
    67} // extern "C" 
  • XIOS/trunk/src/interface/c_attr/iccontext_attr.cpp

    r532 r537  
    146146   
    147147   
    148   void cxios_set_context_timestep(context_Ptr context_hdl, const char * timestep, int timestep_size) 
     148  void cxios_set_context_timestep(context_Ptr context_hdl, cxios_duration timestep_c) 
    149149  { 
    150     std::string timestep_str; 
    151     if(!cstr2string(timestep, timestep_size, timestep_str)) return; 
    152      CTimer::get("XIOS").resume(); 
    153     context_hdl->timestep.setValue(timestep_str); 
    154      CTimer::get("XIOS").suspend(); 
     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(); 
    155161  } 
    156162   
    157   void cxios_get_context_timestep(context_Ptr context_hdl, char * timestep, int timestep_size) 
     163  void cxios_get_context_timestep(context_Ptr context_hdl, cxios_duration* timestep_c) 
    158164  { 
    159      CTimer::get("XIOS").resume(); 
    160     if(!string_copy(context_hdl->timestep.getInheritedValue(),timestep , timestep_size)) 
    161       ERROR("void cxios_get_context_timestep(context_Ptr context_hdl, char * timestep, int timestep_size)", <<"Input string is to short"); 
    162      CTimer::get("XIOS").suspend(); 
     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(); 
    163175  } 
    164176   
  • XIOS/trunk/src/interface/fortran/idate.F90

    r532 r537  
    1010   END TYPE txios(date) 
    1111 
    12    TYPE txios(time) 
    13       REAL(kind = 8) :: year=0, month=0, day=0, hour=0, minute=0, second=0 
    14    END TYPE txios(time)    
     12   TYPE, BIND(C) :: txios(duration) 
     13      REAL(kind = C_DOUBLE) :: year=0, month=0, day=0, hour=0, minute=0, second=0, timestep=0 
     14   END TYPE txios(duration) 
    1515 
    1616   INTERFACE ! Ne pas appeler directement/Interface FORTRAN 2003 <-> C99 
    17     
    18       SUBROUTINE cxios_set_timestep(ts_year, ts_month, ts_day, ts_hour, ts_minute, ts_second) BIND(C) 
    19          IMPORT C_DOUBLE 
    20          REAL (kind = C_DOUBLE), VALUE :: ts_year, ts_month , ts_day   , & 
    21                                           ts_hour, ts_minute, ts_second 
    22       END SUBROUTINE cxios_set_timestep 
    2317 
    2418      SUBROUTINE cxios_update_calendar(step) BIND(C) 
     
    2620         INTEGER (kind = C_INT), VALUE :: step 
    2721      END SUBROUTINE cxios_update_calendar 
    28        
     22 
    2923   END INTERFACE 
    3024    
    3125   CONTAINS ! Fonctions disponibles pour les utilisateurs. 
    3226 
    33  
    34    SUBROUTINE xios(set_timestep)(timestep) 
    35       IMPLICIT NONE 
    36       TYPE(txios(time)), INTENT(IN):: timestep 
    37  
    38       CALL cxios_set_timestep(timestep%year, timestep%month , timestep%day, & 
    39                              timestep%hour, timestep%minute, timestep%second) 
    40  
    41    END SUBROUTINE xios(set_timestep) 
    42  
    43  
    44     
    4527   SUBROUTINE xios(update_calendar)(step) 
    4628     IMPLICIT NONE 
     
    5234      END IF 
    5335      CALL cxios_update_calendar(step) 
    54        
    5536   END SUBROUTINE xios(update_calendar) 
    5637 
    57     
    5838END MODULE IDATE 
  • XIOS/trunk/src/interface/fortran/ixios.F90

    r529 r537  
    1919                  xios(setVar_logic), xios(setVar_char) 
    2020 
    21 USE idate, ONLY : txios(date),txios(time), xios(set_timestep),xios(update_calendar) 
     21USE idate, ONLY : txios(date), txios(duration), xios(update_calendar) 
    2222 
    2323USE idomain, ONLY : txios(domain), txios(domaingroup), xios(get_domain_handle),  & 
     
    158158 PUBLIC :: txios(domain), txios(domaingroup),txios(field), txios(fieldgroup),txios(file), txios(filegroup), & 
    159159          txios(grid), txios(gridgroup), txios(axis), txios(axisgroup),txios(context), txios(date),         & 
    160           txios(time), txios(variable) 
     160          txios(duration), txios(variable) 
    161161 
    162162 PUBLIC :: xios(set_attr), xios(set_domain_attr), xios(set_domaingroup_attr), xios(set_fieldgroup_attr), & 
     
    184184 
    185185 PUBLIC :: xios(set_current_context) 
    186  PUBLIC :: xios(set_timestep),xios(update_calendar) 
     186 PUBLIC :: xios(update_calendar) 
    187187 PUBLIC :: xios(initialize), xios(init_server), xios(finalize), xios(context_initialize),xios(context_is_initialized), & 
    188188           xios(solve_inheritance), xios(close_context_definition), xios(context_finalize), xios(send_field),          & 
  • XIOS/trunk/src/interface/fortran_attr/context_interface_attr.F90

    r532 r537  
    5656      USE IDATE 
    5757      INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    58       TYPE(xios_date), VALUE :: start_date 
     58      TYPE(txios(date)), VALUE :: start_date 
    5959    END SUBROUTINE cxios_set_context_start_date 
    6060     
     
    7777      USE IDATE 
    7878      INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    79       TYPE(xios_date), VALUE :: time_origin 
     79      TYPE(txios(date)), VALUE :: time_origin 
    8080    END SUBROUTINE cxios_set_context_time_origin 
    8181     
     
    9494     
    9595     
    96     SUBROUTINE cxios_set_context_timestep(context_hdl, timestep, timestep_size) BIND(C) 
     96    SUBROUTINE cxios_set_context_timestep(context_hdl, timestep) BIND(C) 
    9797      USE ISO_C_BINDING 
     98      USE IDATE 
    9899      INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    99       CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: timestep 
    100       INTEGER  (kind = C_INT)     , VALUE        :: timestep_size 
     100      TYPE(txios(duration)), VALUE :: timestep 
    101101    END SUBROUTINE cxios_set_context_timestep 
    102102     
    103     SUBROUTINE cxios_get_context_timestep(context_hdl, timestep, timestep_size) BIND(C) 
     103    SUBROUTINE cxios_get_context_timestep(context_hdl, timestep) BIND(C) 
    104104      USE ISO_C_BINDING 
     105      USE IDATE 
    105106      INTEGER (kind = C_INTPTR_T), VALUE :: context_hdl 
    106       CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: timestep 
    107       INTEGER  (kind = C_INT)     , VALUE        :: timestep_size 
     107      TYPE(txios(duration)) :: timestep 
    108108    END SUBROUTINE cxios_get_context_timestep 
    109109     
  • XIOS/trunk/src/interface/fortran_attr/icontext_attr.F90

    r532 r537  
    2121      TYPE(txios(date))  , OPTIONAL, INTENT(IN) :: start_date 
    2222      TYPE(txios(date))  , OPTIONAL, INTENT(IN) :: time_origin 
    23       CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: timestep 
     23      TYPE(txios(duration)) , OPTIONAL, INTENT(IN) :: timestep 
    2424       
    2525      CALL xios(get_context_handle)(context_id,context_hdl) 
     
    3838      TYPE(txios(date))  , OPTIONAL, INTENT(IN) :: start_date 
    3939      TYPE(txios(date))  , OPTIONAL, INTENT(IN) :: time_origin 
    40       CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: timestep 
     40      TYPE(txios(duration)) , OPTIONAL, INTENT(IN) :: timestep 
    4141       
    4242      CALL xios(set_context_attr_hdl_)  & 
     
    5454      TYPE(txios(date))  , OPTIONAL, INTENT(IN) :: start_date_ 
    5555      TYPE(txios(date))  , OPTIONAL, INTENT(IN) :: time_origin_ 
    56       CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: timestep_ 
     56      TYPE(txios(duration)) , OPTIONAL, INTENT(IN) :: timestep_ 
    5757       
    5858      IF (PRESENT(calendar_type_)) THEN 
     
    7373       
    7474      IF (PRESENT(timestep_)) THEN 
    75         CALL cxios_set_context_timestep(context_hdl%daddr, timestep_, len(timestep_)) 
     75        CALL cxios_set_context_timestep(context_hdl%daddr, timestep_) 
    7676      ENDIF 
    7777       
     
    9090      TYPE(txios(date))  , OPTIONAL, INTENT(OUT) :: start_date 
    9191      TYPE(txios(date))  , OPTIONAL, INTENT(OUT) :: time_origin 
    92       CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: timestep 
     92      TYPE(txios(duration)) , OPTIONAL, INTENT(OUT) :: timestep 
    9393       
    9494      CALL xios(get_context_handle)(context_id,context_hdl) 
     
    107107      TYPE(txios(date))  , OPTIONAL, INTENT(OUT) :: start_date 
    108108      TYPE(txios(date))  , OPTIONAL, INTENT(OUT) :: time_origin 
    109       CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: timestep 
     109      TYPE(txios(duration)) , OPTIONAL, INTENT(OUT) :: timestep 
    110110       
    111111      CALL xios(get_context_attr_hdl_)  & 
     
    123123      TYPE(txios(date))  , OPTIONAL, INTENT(OUT) :: start_date_ 
    124124      TYPE(txios(date))  , OPTIONAL, INTENT(OUT) :: time_origin_ 
    125       CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: timestep_ 
     125      TYPE(txios(duration)) , OPTIONAL, INTENT(OUT) :: timestep_ 
    126126       
    127127      IF (PRESENT(calendar_type_)) THEN 
     
    142142       
    143143      IF (PRESENT(timestep_)) THEN 
    144         CALL cxios_get_context_timestep(context_hdl%daddr, timestep_, len(timestep_)) 
     144        CALL cxios_get_context_timestep(context_hdl%daddr, timestep_) 
    145145      ENDIF 
    146146       
Note: See TracChangeset for help on using the changeset viewer.