source: XIOS/trunk/src/interface/fortran/icontext.F90 @ 545

Last change on this file since 545 was 545, checked in by rlacroix, 9 years ago

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
  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 1.6 KB
Line 
1#include "xios_fortran_prefix.hpp"
2
3MODULE ICONTEXT
4   USE, INTRINSIC :: ISO_C_BINDING
5   USE CONTEXT_INTERFACE
6   USE IDATE
7   USE IDURATION
8!   USE icontext_attr
9
10
11   TYPE txios(context)
12      INTEGER(kind = C_INTPTR_T) :: daddr
13   END TYPE txios(context)
14
15
16   CONTAINS ! Fonctions disponibles pour les utilisateurs.
17
18   SUBROUTINE xios(get_context_handle)(idt,ret)
19      IMPLICIT NONE
20      CHARACTER(len = *)  , INTENT(IN)  :: idt
21      TYPE(txios(context)), INTENT(OUT):: ret
22
23      CALL cxios_context_handle_create(ret%daddr, idt, len(idt))
24   END SUBROUTINE xios(get_context_handle)
25
26   SUBROUTINE xios(get_current_context)(context)
27      IMPLICIT NONE
28
29      TYPE(txios(context)), INTENT(IN) :: context
30
31      CALL cxios_context_get_current(context%daddr)
32
33   END SUBROUTINE xios(get_current_context)
34
35   SUBROUTINE xios(set_current_context)(context, withswap)
36      IMPLICIT NONE
37
38      TYPE(txios(context))          , INTENT(IN) :: context
39      LOGICAL             , OPTIONAL, INTENT(IN) :: withswap
40      LOGICAL (kind = 1)                         :: wswap
41
42      IF (PRESENT(withswap)) THEN
43         wswap = withswap
44      ELSE
45         wswap = .FALSE.
46      END IF
47      CALL cxios_context_set_current(context%daddr, wswap)
48
49   END SUBROUTINE xios(set_current_context)
50
51   LOGICAL FUNCTION xios(is_valid_context)(idt)
52      IMPLICIT NONE
53      CHARACTER(len  = *)    , INTENT(IN) :: idt
54      LOGICAL  (kind = 1)                 :: val
55
56      CALL cxios_context_valid_id(val, idt, len(idt));
57      xios(is_valid_context) = val
58
59   END FUNCTION  xios(is_valid_context)
60
61
62END MODULE ICONTEXT
Note: See TracBrowser for help on using the repository browser.