1 | #include "xios_fortran_prefix.hpp" |
---|
2 | MODULE ICALENDAR |
---|
3 | USE, INTRINSIC :: ISO_C_BINDING |
---|
4 | USE CALENDAR_INTERFACE |
---|
5 | USE ICALENDAR_WRAPPER |
---|
6 | USE IDATE |
---|
7 | USE IDURATION |
---|
8 | |
---|
9 | ! enum XCalendarType |
---|
10 | INTEGER(kind = C_INT), PARAMETER :: D360 = 0 , ALLLEAP = 1 , NOLEAP = 2 , JULIAN = 3 , GREGORIAN = 4 |
---|
11 | |
---|
12 | INTERFACE xios(set_start_date) |
---|
13 | MODULE PROCEDURE xios(set_start_date_date), xios(set_start_date_dur) |
---|
14 | END INTERFACE xios(set_start_date) |
---|
15 | |
---|
16 | INTERFACE xios(set_time_origin) |
---|
17 | MODULE PROCEDURE xios(set_time_origin_date), xios(set_time_origin_dur) |
---|
18 | END INTERFACE xios(set_time_origin) |
---|
19 | |
---|
20 | CONTAINS ! Fonctions disponibles pour les utilisateurs. |
---|
21 | |
---|
22 | SUBROUTINE xios(define_calendar)(type, timestep, start_date, time_origin) |
---|
23 | USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) |
---|
24 | USE icalendar_wrapper_attr, ONLY : xios(set_calendar_wrapper_attr_hdl) |
---|
25 | USE IDURATION, ONLY : txios(duration) |
---|
26 | USE IDATE, ONLY : txios(date) |
---|
27 | IMPLICIT NONE |
---|
28 | CHARACTER(len = *), INTENT(IN) :: type |
---|
29 | TYPE(txios(duration)), OPTIONAL, INTENT(IN) :: timestep |
---|
30 | TYPE(txios(date)), OPTIONAL, INTENT(IN) :: start_date |
---|
31 | TYPE(txios(date)), OPTIONAL, INTENT(IN) :: time_origin |
---|
32 | TYPE(txios(calendar_wrapper)) :: calendar_wrapper |
---|
33 | |
---|
34 | CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) |
---|
35 | |
---|
36 | CALL xios(set_calendar_wrapper_attr_hdl)(calendar_wrapper, type=type) |
---|
37 | IF (PRESENT(timestep)) THEN |
---|
38 | CALL xios(set_calendar_wrapper_attr_hdl)(calendar_wrapper, timestep=timestep) |
---|
39 | END IF |
---|
40 | |
---|
41 | CALL xios(create_calendar)(calendar_wrapper) |
---|
42 | |
---|
43 | IF (PRESENT(start_date)) THEN |
---|
44 | CALL xios(set_start_date_hdl)(calendar_wrapper, start_date=start_date) |
---|
45 | END IF |
---|
46 | IF (PRESENT(time_origin)) THEN |
---|
47 | CALL xios(set_time_origin_hdl)(calendar_wrapper, time_origin=time_origin) |
---|
48 | END IF |
---|
49 | END SUBROUTINE xios(define_calendar) |
---|
50 | |
---|
51 | SUBROUTINE xios(get_calendar_type)(calendar_type) |
---|
52 | USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) |
---|
53 | USE icalendar_wrapper_attr, ONLY : xios(get_calendar_wrapper_attr_hdl) |
---|
54 | IMPLICIT NONE |
---|
55 | CHARACTER(len = *), INTENT(OUT) :: calendar_type |
---|
56 | TYPE(txios(calendar_wrapper)) :: calendar_wrapper |
---|
57 | |
---|
58 | CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) |
---|
59 | |
---|
60 | CALL xios(get_calendar_wrapper_attr_hdl)(calendar_wrapper, type=calendar_type) |
---|
61 | END SUBROUTINE xios(get_calendar_type) |
---|
62 | |
---|
63 | SUBROUTINE xios(set_timestep)(timestep) |
---|
64 | USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) |
---|
65 | USE icalendar_wrapper_attr, ONLY : xios(set_calendar_wrapper_attr_hdl) |
---|
66 | USE IDURATION, ONLY : txios(duration) |
---|
67 | IMPLICIT NONE |
---|
68 | TYPE(txios(duration)), INTENT(IN) :: timestep |
---|
69 | TYPE(txios(calendar_wrapper)) :: calendar_wrapper |
---|
70 | |
---|
71 | CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) |
---|
72 | |
---|
73 | CALL xios(set_calendar_wrapper_attr_hdl)(calendar_wrapper, timestep=timestep) |
---|
74 | |
---|
75 | CALL xios(update_calendar_timestep)(calendar_wrapper) |
---|
76 | END SUBROUTINE xios(set_timestep) |
---|
77 | |
---|
78 | SUBROUTINE xios(get_timestep)(timestep) |
---|
79 | USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) |
---|
80 | USE icalendar_wrapper_attr, ONLY : xios(get_calendar_wrapper_attr_hdl) |
---|
81 | USE IDURATION, ONLY : txios(duration) |
---|
82 | IMPLICIT NONE |
---|
83 | TYPE(txios(duration)), INTENT(OUT) :: timestep |
---|
84 | TYPE(txios(calendar_wrapper)) :: calendar_wrapper |
---|
85 | |
---|
86 | CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) |
---|
87 | |
---|
88 | CALL xios(get_calendar_wrapper_attr_hdl)(calendar_wrapper, timestep=timestep) |
---|
89 | END SUBROUTINE xios(get_timestep) |
---|
90 | |
---|
91 | SUBROUTINE xios(set_start_date_date)(start_date) |
---|
92 | USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) |
---|
93 | USE IDATE, ONLY : txios(date) |
---|
94 | IMPLICIT NONE |
---|
95 | TYPE(txios(date)), INTENT(IN) :: start_date |
---|
96 | TYPE(txios(calendar_wrapper)) :: calendar_wrapper |
---|
97 | |
---|
98 | CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) |
---|
99 | |
---|
100 | CALL xios(set_start_date_hdl)(calendar_wrapper, start_date) |
---|
101 | END SUBROUTINE xios(set_start_date_date) |
---|
102 | |
---|
103 | SUBROUTINE xios(set_start_date_dur)(start_date) |
---|
104 | USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) |
---|
105 | USE IDURATION, ONLY : txios(duration) |
---|
106 | USE IDATE, ONLY : txios(date) |
---|
107 | IMPLICIT NONE |
---|
108 | TYPE(txios(duration)), INTENT(IN) :: start_date |
---|
109 | TYPE(txios(calendar_wrapper)) :: calendar_wrapper |
---|
110 | TYPE(txios(date)) :: start_date_date |
---|
111 | |
---|
112 | CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) |
---|
113 | |
---|
114 | start_date_date = start_date |
---|
115 | CALL xios(set_start_date_hdl)(calendar_wrapper, start_date_date) |
---|
116 | END SUBROUTINE xios(set_start_date_dur) |
---|
117 | |
---|
118 | SUBROUTINE xios(get_start_date)(start_date) |
---|
119 | USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) |
---|
120 | USE IDATE, ONLY : txios(date) |
---|
121 | IMPLICIT NONE |
---|
122 | TYPE(txios(date)), INTENT(OUT) :: start_date |
---|
123 | TYPE(txios(calendar_wrapper)) :: calendar_wrapper |
---|
124 | |
---|
125 | CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) |
---|
126 | |
---|
127 | CALL xios(get_start_date_hdl)(calendar_wrapper, start_date) |
---|
128 | END SUBROUTINE xios(get_start_date) |
---|
129 | |
---|
130 | SUBROUTINE xios(set_time_origin_date)(time_origin) |
---|
131 | USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) |
---|
132 | USE IDATE, ONLY : txios(date) |
---|
133 | IMPLICIT NONE |
---|
134 | TYPE(txios(date)), INTENT(IN) :: time_origin |
---|
135 | TYPE(txios(calendar_wrapper)) :: calendar_wrapper |
---|
136 | |
---|
137 | CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) |
---|
138 | |
---|
139 | CALL xios(set_time_origin_hdl)(calendar_wrapper, time_origin) |
---|
140 | END SUBROUTINE xios(set_time_origin_date) |
---|
141 | |
---|
142 | SUBROUTINE xios(set_time_origin_dur)(time_origin) |
---|
143 | USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) |
---|
144 | USE IDURATION, ONLY : txios(duration) |
---|
145 | USE IDATE, ONLY : txios(date) |
---|
146 | IMPLICIT NONE |
---|
147 | TYPE(txios(duration)), INTENT(IN) :: time_origin |
---|
148 | TYPE(txios(calendar_wrapper)) :: calendar_wrapper |
---|
149 | TYPE(txios(date)) :: time_origin_date |
---|
150 | |
---|
151 | CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) |
---|
152 | |
---|
153 | time_origin_date = time_origin |
---|
154 | CALL xios(set_time_origin_hdl)(calendar_wrapper, time_origin_date) |
---|
155 | END SUBROUTINE xios(set_time_origin_dur) |
---|
156 | |
---|
157 | SUBROUTINE xios(get_time_origin)(time_origin) |
---|
158 | USE ICALENDAR_WRAPPER, ONLY : txios(calendar_wrapper), xios(get_default_calendar_wrapper_handle) |
---|
159 | USE IDATE, ONLY : txios(date) |
---|
160 | IMPLICIT NONE |
---|
161 | TYPE(txios(date)), INTENT(OUT) :: time_origin |
---|
162 | TYPE(txios(calendar_wrapper)) :: calendar_wrapper |
---|
163 | |
---|
164 | CALL xios(get_default_calendar_wrapper_handle)(calendar_wrapper) |
---|
165 | |
---|
166 | CALL xios(get_time_origin_hdl)(calendar_wrapper, time_origin) |
---|
167 | END SUBROUTINE xios(get_time_origin) |
---|
168 | |
---|
169 | SUBROUTINE xios(update_calendar)(step) |
---|
170 | IMPLICIT NONE |
---|
171 | INTEGER, INTENT(IN) :: step |
---|
172 | |
---|
173 | IF (step < 0) THEN |
---|
174 | PRINT *, "L'argument 'step' ne peut être négatif" |
---|
175 | STOP |
---|
176 | END IF |
---|
177 | CALL cxios_update_calendar(step) |
---|
178 | END SUBROUTINE xios(update_calendar) |
---|
179 | |
---|
180 | SUBROUTINE xios(get_current_date)(current_date) |
---|
181 | USE IDATE, ONLY : txios(date) |
---|
182 | IMPLICIT NONE |
---|
183 | TYPE(txios(date)), INTENT(OUT) :: current_date |
---|
184 | |
---|
185 | CALL cxios_get_current_date(current_date) |
---|
186 | END SUBROUTINE xios(get_current_date) |
---|
187 | |
---|
188 | FUNCTION xios(get_year_length_in_seconds)(year) RESULT(res) |
---|
189 | IMPLICIT NONE |
---|
190 | INTEGER(kind = C_INT), INTENT(IN) :: year |
---|
191 | INTEGER(kind = C_INT) :: res |
---|
192 | |
---|
193 | res = cxios_get_year_length_in_seconds(year) |
---|
194 | END FUNCTION xios(get_year_length_in_seconds) |
---|
195 | |
---|
196 | FUNCTION xios(get_day_length_in_seconds)() RESULT(res) |
---|
197 | IMPLICIT NONE |
---|
198 | INTEGER(kind = C_INT) :: res |
---|
199 | |
---|
200 | res = cxios_get_day_length_in_seconds() |
---|
201 | END FUNCTION xios(get_day_length_in_seconds) |
---|
202 | |
---|
203 | END MODULE ICALENDAR |
---|