Ignore:
Timestamp:
12/17/14 11:14:05 (9 years ago)
Author:
rlacroix
Message:

Expose the calendar operations through the Fortran interface.

  • Add arithmetic operations on the xios_duration and xios_date types:
    • xios_duration + xios_duration = xios_duration
    • xios_duration - xios_duration = xios_duration
    • scalar * xios_duration = xios_duration * scalar = xios_duration
    • - xios_duration = xios_duration
    • xios_date + xios_duration = xios_date
    • xios_date - xios_duration = xios_date
    • xios_date - xios_date = xios_duration
  • Add comparison operations on the xios_duration and xios_date types:
    • xios_duration: ==, /=
    • xios_date: ==, /=, <, <=, >, >=
  • Add a new function "xios_date_convert_to_seconds" to convert a date into the number of seconds since the time origin of the calendar
  • Define some constant durations "xios_second", "xios_minute", "xios_hour", "xios_day", "xios_month", "xios_year" et "xios_timestep" to ease the definition of new durations (for example, 10h is just 10 * xios_hour)
  • Add a new function "xios_set_calendar" so that one can manually create the calendar attached to the current context and thus use the calendar operations before calling "xios_close_context_definition". This function can accept optional parameters so that the calendar attributes (calendar_type, start_date, time_origin and timestep) can be easily overwritten. Note that you cannot define a new calendar after one was already created (either because "xios_set_calendar" or "xios_close_context_definition" was used)
  • Readd the function "xios_set_timestep" as a simplified alias of "xios_set_context_attr(context, timestep)" for the current context
File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/test/test_client.f90

    r537 r545  
    1212  INTEGER :: comm 
    1313  TYPE(xios_duration) :: dtime 
     14  TYPE(xios_date) :: date 
    1415  TYPE(xios_context) :: ctx_hdl 
    1516  INTEGER,PARAMETER :: ni_glo=100 
     
    8788     
    8889  
    89     dtime%second=3600 
    90     CALL xios_set_context_attr("test", timestep=dtime) 
    91      
    92     ni=0 ; lonvalue(:)=0 
    93     CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue=lonvalue) 
    94      
    95     print *,"ni",ni 
    96     print *,"lonvalue",lonvalue ; 
     90  dtime%second = 3600 
     91  CALL xios_set_context_attr("test", timestep=dtime) 
    9792 
    98     CALL xios_is_defined_field_attr("field_A",enabled=ok) 
    99     PRINT *,"field_A : attribute enabled is defined ? ",ok 
    100     CALL xios_close_context_definition() 
    101      
    102     PRINT*,"field field_A is active ? ",xios_field_is_active("field_A") 
    103     DO ts=1,24*10 
    104       CALL xios_update_calendar(ts) 
    105       CALL xios_send_field("field_A",field_A) 
    106       CALL wait_us(5000) ; 
    107     ENDDO 
     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) 
     97  PRINT *, "time_origin = ", date 
     98  dtime%timestep = 1 
     99  dtime = 0.5 * dtime 
     100  PRINT *, "duration = ", dtime 
     101  date = date + 3 * (dtime + dtime) 
     102  PRINT *, "date = time_origin + 3 * (duration + duration) = ", date 
     103  PRINT *, "xios_date_convert_to_seconds(date) = ", xios_date_convert_to_seconds(date) 
     104  PRINT *, "xios_date_convert_to_seconds(date - 2.5h) = ", xios_date_convert_to_seconds(date - 2.5 * xios_hour) 
    108105   
    109     CALL xios_context_finalize() 
    110     CALL xios_finalize() 
     106  ni=0 ; lonvalue(:)=0 
     107  CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue=lonvalue) 
     108   
     109  print *,"ni",ni 
     110  print *,"lonvalue",lonvalue ; 
     111 
     112  CALL xios_is_defined_field_attr("field_A",enabled=ok) 
     113  PRINT *,"field_A : attribute enabled is defined ? ",ok 
     114  CALL xios_close_context_definition() 
     115   
     116  PRINT*,"field field_A is active ? ",xios_field_is_active("field_A") 
     117  DO ts=1,24*10 
     118    CALL xios_update_calendar(ts) 
     119    CALL xios_send_field("field_A",field_A) 
     120    CALL wait_us(5000) ; 
     121  ENDDO 
     122 
     123  CALL xios_context_finalize() 
     124  CALL xios_finalize() 
    111125   
    112126  CALL MPI_FINALIZE(ierr) 
Note: See TracChangeset for help on using the changeset viewer.