source: XMLIO_V2/dev/dev_rv/src/xmlio/fortran/icontext.f90 @ 270

Last change on this file since 270 was 270, checked in by hozdoba, 13 years ago

Début nouvelle interface fortran

File size: 3.6 KB
Line 
1MODULE ICONTEXT
2   USE, INTRINSIC :: ISO_C_BINDING
3   USE CONTEXT_INTERFACE
4   USE IDATE
5   
6   TYPE XContextHandle
7      INTEGER(kind = C_INTPTR_T) :: daddr
8   END TYPE XContextHandle
9     
10   !----------------------------------------------------------------------------
11   INTERFACE set_context_attributes
12      MODULE PROCEDURE set_context_attributes_id,set_context_attributes_hdl
13   END INTERFACE 
14   !----------------------------------------------------------------------------
15   
16   CONTAINS ! Fonctions disponibles pour les utilisateurs.
17   
18   SUBROUTINE set_context_attributes_id( context_id, calendar_type_, start_date_, output_dir_)
19      IMPLICIT NONE
20      TYPE(XContextHandle)                       :: context_hdl
21      CHARACTER(len = *)            , INTENT(IN) :: context_id
22      CHARACTER(len = *)  , OPTIONAL, INTENT(IN) :: calendar_type_
23      CHARACTER(len = *)  , OPTIONAL, INTENT(IN) :: start_date_
24      CHARACTER(len = *)  , OPTIONAL, INTENT(IN) :: output_dir_
25         
26      CALL context_handle_create(context_hdl, context_id)
27      CALL set_context_attributes_hdl( context_hdl, calendar_type_, start_date_, output_dir_)
28   END SUBROUTINE set_context_attributes_id
29
30   SUBROUTINE set_context_attributes_hdl( context_hdl, calendar_type_, start_date_, output_dir_)
31      IMPLICIT NONE
32      TYPE(XContextHandle)          , INTENT(IN) :: context_hdl
33      CHARACTER(len = *)  , OPTIONAL, INTENT(IN) :: calendar_type_
34      CHARACTER(len = *)  , OPTIONAL, INTENT(IN) :: start_date_
35      CHARACTER(len = *)  , OPTIONAL, INTENT(IN) :: output_dir_   
36         
37      IF (PRESENT(calendar_type_)) THEN
38         CALL xios_set_context_calendar_type(context_hdl%daddr, calendar_type_, len(calendar_type_))
39      END IF
40      IF (PRESENT(start_date_))    THEN
41         CALL xios_set_context_start_date(context_hdl%daddr, start_date_, len(start_date_))
42      END IF
43      IF (PRESENT(output_dir_))    THEN
44         CALL xios_set_context_output_dir(context_hdl%daddr, output_dir_, len(output_dir_))
45      END IF
46   END SUBROUTINE set_context_attributes_hdl
47
48   SUBROUTINE context_handle_create(ret, idt)
49      IMPLICIT NONE
50      TYPE(XContextHandle), INTENT(OUT):: ret
51      CHARACTER(len = *)  , INTENT(IN) :: idt     
52      CALL xios_context_handle_create(ret%daddr, idt, len(idt))           
53   END SUBROUTINE context_handle_create
54   
55   SUBROUTINE context_set_current(context, withswap)
56      TYPE(XContextHandle)          , INTENT(IN) :: context
57      LOGICAL             , OPTIONAL, INTENT(IN) :: withswap
58      LOGICAL (kind = 1)                       :: wswap
59      IF (PRESENT(withswap)) THEN
60         wswap = withswap
61      ELSE
62         wswap = .FALSE.
63      END IF
64      CALL xios_context_set_current(context%daddr, wswap)
65   END SUBROUTINE context_set_current
66   
67   SUBROUTINE context_create(context_hdl, context_id, calendar_type, init_date)
68      TYPE(XContextHandle)          , INTENT(OUT) :: context_hdl
69      CHARACTER(len = *)            , INTENT(IN)  :: context_id
70      INTEGER                       , INTENT(IN)  :: calendar_type
71      TYPE(XDate)         , OPTIONAL, INTENT(IN)  :: init_date
72      IF (PRESENT(init_date)) THEN
73         CALL xios_context_create(context_hdl%daddr, context_id, len(context_id), calendar_type, &
74                                  init_date%year, init_date%month, init_date%day, &
75                                  init_date%hour, init_date%minute, init_date%second)
76      ELSE
77         CALL xios_context_create(context_hdl%daddr, context_id, len(context_id), calendar_type, &
78                                 0, 1, 1, 0, 0, 0)
79      END IF
80   END SUBROUTINE context_create
81   
82END MODULE ICONTEXT
Note: See TracBrowser for help on using the repository browser.