1 | #LyX 2.1 created this file. For more info see http://www.lyx.org/ |
---|
2 | \lyxformat 474 |
---|
3 | \begin_document |
---|
4 | \begin_header |
---|
5 | \textclass book |
---|
6 | \begin_preamble |
---|
7 | \usepackage{MnSymbol} |
---|
8 | \end_preamble |
---|
9 | \use_default_options true |
---|
10 | \begin_modules |
---|
11 | logicalmkup |
---|
12 | \end_modules |
---|
13 | \maintain_unincluded_children false |
---|
14 | \language english |
---|
15 | \language_package default |
---|
16 | \inputencoding auto |
---|
17 | \fontencoding global |
---|
18 | \font_roman default |
---|
19 | \font_sans default |
---|
20 | \font_typewriter default |
---|
21 | \font_math auto |
---|
22 | \font_default_family default |
---|
23 | \use_non_tex_fonts false |
---|
24 | \font_sc false |
---|
25 | \font_osf false |
---|
26 | \font_sf_scale 100 |
---|
27 | \font_tt_scale 100 |
---|
28 | \graphics default |
---|
29 | \default_output_format default |
---|
30 | \output_sync 0 |
---|
31 | \bibtex_command default |
---|
32 | \index_command default |
---|
33 | \paperfontsize default |
---|
34 | \spacing single |
---|
35 | \use_hyperref false |
---|
36 | \papersize a4paper |
---|
37 | \use_geometry false |
---|
38 | \use_package amsmath 1 |
---|
39 | \use_package amssymb 1 |
---|
40 | \use_package cancel 1 |
---|
41 | \use_package esint 1 |
---|
42 | \use_package mathdots 1 |
---|
43 | \use_package mathtools 1 |
---|
44 | \use_package mhchem 1 |
---|
45 | \use_package stackrel 1 |
---|
46 | \use_package stmaryrd 1 |
---|
47 | \use_package undertilde 1 |
---|
48 | \cite_engine basic |
---|
49 | \cite_engine_type default |
---|
50 | \biblio_style plain |
---|
51 | \use_bibtopic false |
---|
52 | \use_indices false |
---|
53 | \paperorientation portrait |
---|
54 | \suppress_date false |
---|
55 | \justification true |
---|
56 | \use_refstyle 0 |
---|
57 | \index Index |
---|
58 | \shortcut idx |
---|
59 | \color #008000 |
---|
60 | \end_index |
---|
61 | \secnumdepth 3 |
---|
62 | \tocdepth 3 |
---|
63 | \paragraph_separation indent |
---|
64 | \paragraph_indentation default |
---|
65 | \quotes_language english |
---|
66 | \papercolumns 1 |
---|
67 | \papersides 1 |
---|
68 | \paperpagestyle default |
---|
69 | \tracking_changes false |
---|
70 | \output_changes false |
---|
71 | \html_math_output 0 |
---|
72 | \html_css_as_file 0 |
---|
73 | \html_be_strict false |
---|
74 | \end_header |
---|
75 | |
---|
76 | \begin_body |
---|
77 | |
---|
78 | \begin_layout Title |
---|
79 | XIOS User Guide |
---|
80 | \end_layout |
---|
81 | |
---|
82 | \begin_layout Author |
---|
83 | Draft |
---|
84 | \end_layout |
---|
85 | |
---|
86 | \begin_layout Chapter |
---|
87 | Calendar |
---|
88 | \end_layout |
---|
89 | |
---|
90 | \begin_layout Section |
---|
91 | How to define a calendar |
---|
92 | \end_layout |
---|
93 | |
---|
94 | \begin_layout Standard |
---|
95 | XIOS has an embedded calendar module which needs to be configured before |
---|
96 | you can run your simulation. |
---|
97 | \begin_inset Newline newline |
---|
98 | \end_inset |
---|
99 | |
---|
100 | |
---|
101 | \begin_inset Newline newline |
---|
102 | \end_inset |
---|
103 | |
---|
104 | Only the calendar type and the time step used by your simulation are mandatory |
---|
105 | to have a well defined calendar. |
---|
106 | For example, a minimal calendar definition could be: |
---|
107 | \end_layout |
---|
108 | |
---|
109 | \begin_layout Itemize |
---|
110 | from the XML configuration file: |
---|
111 | \begin_inset Newline newline |
---|
112 | \end_inset |
---|
113 | |
---|
114 | |
---|
115 | \begin_inset listings |
---|
116 | lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}" |
---|
117 | inline false |
---|
118 | status open |
---|
119 | |
---|
120 | \begin_layout Plain Layout |
---|
121 | |
---|
122 | <?xml version="1.0"?> |
---|
123 | \end_layout |
---|
124 | |
---|
125 | \begin_layout Plain Layout |
---|
126 | |
---|
127 | <simulation> |
---|
128 | \end_layout |
---|
129 | |
---|
130 | \begin_layout Plain Layout |
---|
131 | |
---|
132 | <context id="test"> |
---|
133 | \end_layout |
---|
134 | |
---|
135 | \begin_layout Plain Layout |
---|
136 | |
---|
137 | <calendar type="Gregorian" timestep="1.5h" /> |
---|
138 | \end_layout |
---|
139 | |
---|
140 | \begin_layout Plain Layout |
---|
141 | |
---|
142 | </context> |
---|
143 | \end_layout |
---|
144 | |
---|
145 | \begin_layout Plain Layout |
---|
146 | |
---|
147 | </simulation> |
---|
148 | \end_layout |
---|
149 | |
---|
150 | \end_inset |
---|
151 | |
---|
152 | |
---|
153 | \end_layout |
---|
154 | |
---|
155 | \begin_layout Itemize |
---|
156 | from the Fortran interface: |
---|
157 | \begin_inset Newline newline |
---|
158 | \end_inset |
---|
159 | |
---|
160 | |
---|
161 | \begin_inset listings |
---|
162 | lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}" |
---|
163 | inline false |
---|
164 | status open |
---|
165 | |
---|
166 | \begin_layout Plain Layout |
---|
167 | |
---|
168 | ! ... |
---|
169 | \end_layout |
---|
170 | |
---|
171 | \begin_layout Plain Layout |
---|
172 | |
---|
173 | TYPE(xios_context) :: ctx_hdl |
---|
174 | \end_layout |
---|
175 | |
---|
176 | \begin_layout Plain Layout |
---|
177 | |
---|
178 | ! ... |
---|
179 | \end_layout |
---|
180 | |
---|
181 | \begin_layout Plain Layout |
---|
182 | |
---|
183 | ! Context initialization ommited, see the corresponding section of this |
---|
184 | user manual and of the reference manual |
---|
185 | \end_layout |
---|
186 | |
---|
187 | \begin_layout Plain Layout |
---|
188 | |
---|
189 | CALL xios_get_handle("test",ctx_hdl) |
---|
190 | \end_layout |
---|
191 | |
---|
192 | \begin_layout Plain Layout |
---|
193 | |
---|
194 | CALL xios_set_current_context(ctx_hdl) |
---|
195 | \end_layout |
---|
196 | |
---|
197 | \begin_layout Plain Layout |
---|
198 | |
---|
199 | CALL xios_define_calendar(type="Gregorian", timestep=1.5*xios_hour) |
---|
200 | \end_layout |
---|
201 | |
---|
202 | \end_inset |
---|
203 | |
---|
204 | |
---|
205 | \end_layout |
---|
206 | |
---|
207 | \begin_layout Standard |
---|
208 | The calendar type definition is done once and for all, either from the XML |
---|
209 | configuration file or the Fortran interface, and cannot be modified. |
---|
210 | However there is no such restriction regarding the time step which can |
---|
211 | be defined at a different time than the calendar type and even redefined |
---|
212 | multiple times. |
---|
213 | \begin_inset Newline newline |
---|
214 | \end_inset |
---|
215 | |
---|
216 | |
---|
217 | \begin_inset Newline newline |
---|
218 | \end_inset |
---|
219 | |
---|
220 | For example, it is possible to the achieve the same minimal configuration |
---|
221 | as above by using both the XML configuration file: |
---|
222 | \end_layout |
---|
223 | |
---|
224 | \begin_layout Standard |
---|
225 | \begin_inset listings |
---|
226 | lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}" |
---|
227 | inline false |
---|
228 | status open |
---|
229 | |
---|
230 | \begin_layout Plain Layout |
---|
231 | |
---|
232 | <?xml version="1.0"?> |
---|
233 | \end_layout |
---|
234 | |
---|
235 | \begin_layout Plain Layout |
---|
236 | |
---|
237 | <simulation> |
---|
238 | \end_layout |
---|
239 | |
---|
240 | \begin_layout Plain Layout |
---|
241 | |
---|
242 | <context id="test"> |
---|
243 | \end_layout |
---|
244 | |
---|
245 | \begin_layout Plain Layout |
---|
246 | |
---|
247 | <calendar type="Gregorian" /> |
---|
248 | \end_layout |
---|
249 | |
---|
250 | \begin_layout Plain Layout |
---|
251 | |
---|
252 | </context> |
---|
253 | \end_layout |
---|
254 | |
---|
255 | \begin_layout Plain Layout |
---|
256 | |
---|
257 | </simulation> |
---|
258 | \end_layout |
---|
259 | |
---|
260 | \end_inset |
---|
261 | |
---|
262 | and the Fortran interface: |
---|
263 | \end_layout |
---|
264 | |
---|
265 | \begin_layout Standard |
---|
266 | \begin_inset listings |
---|
267 | lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}" |
---|
268 | inline false |
---|
269 | status open |
---|
270 | |
---|
271 | \begin_layout Plain Layout |
---|
272 | |
---|
273 | ! ... |
---|
274 | \end_layout |
---|
275 | |
---|
276 | \begin_layout Plain Layout |
---|
277 | |
---|
278 | TYPE(xios_context) :: ctx_hdl |
---|
279 | \end_layout |
---|
280 | |
---|
281 | \begin_layout Plain Layout |
---|
282 | |
---|
283 | ! ... |
---|
284 | \end_layout |
---|
285 | |
---|
286 | \begin_layout Plain Layout |
---|
287 | |
---|
288 | ! Context initialization ommited, see the corresponding section of this |
---|
289 | user manual and of the reference manual |
---|
290 | \end_layout |
---|
291 | |
---|
292 | \begin_layout Plain Layout |
---|
293 | |
---|
294 | CALL xios_get_handle("test",ctx_hdl) |
---|
295 | \end_layout |
---|
296 | |
---|
297 | \begin_layout Plain Layout |
---|
298 | |
---|
299 | CALL xios_set_current_context(ctx_hdl) |
---|
300 | \end_layout |
---|
301 | |
---|
302 | \begin_layout Plain Layout |
---|
303 | |
---|
304 | ! xios_define_calendar cannot be used here because the type was already |
---|
305 | defined in the configuration file. |
---|
306 | \end_layout |
---|
307 | |
---|
308 | \begin_layout Plain Layout |
---|
309 | |
---|
310 | ! Ommiting the following line would lead to an error because the timestep |
---|
311 | would be undefined. |
---|
312 | \end_layout |
---|
313 | |
---|
314 | \begin_layout Plain Layout |
---|
315 | |
---|
316 | CALL xios_set_timestep(timestep=1.5*xios_hour) |
---|
317 | \end_layout |
---|
318 | |
---|
319 | \end_inset |
---|
320 | |
---|
321 | The calendar also has two optional date parameters: |
---|
322 | \end_layout |
---|
323 | |
---|
324 | \begin_layout Itemize |
---|
325 | the start date which corresponds to the beginning of the simulation |
---|
326 | \end_layout |
---|
327 | |
---|
328 | \begin_layout Itemize |
---|
329 | the time origin which corresponds to the origin of the time axis. |
---|
330 | \end_layout |
---|
331 | |
---|
332 | \begin_layout Standard |
---|
333 | If they are undefined, those parameters are set by default to |
---|
334 | \begin_inset Quotes eld |
---|
335 | \end_inset |
---|
336 | |
---|
337 | |
---|
338 | \series bold |
---|
339 | \emph on |
---|
340 | 0000-01-01 00:00:00 |
---|
341 | \series default |
---|
342 | \emph default |
---|
343 | |
---|
344 | \begin_inset Quotes erd |
---|
345 | \end_inset |
---|
346 | |
---|
347 | . |
---|
348 | If you are not interested in specific dates, you can ignore those parameters |
---|
349 | completely. |
---|
350 | However if you wish to set them, please note that they must not be set |
---|
351 | before the calendar is defined. |
---|
352 | Thus the following XML configuration file would be for example invalid: |
---|
353 | \end_layout |
---|
354 | |
---|
355 | \begin_layout Standard |
---|
356 | \begin_inset listings |
---|
357 | lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}" |
---|
358 | inline false |
---|
359 | status open |
---|
360 | |
---|
361 | \begin_layout Plain Layout |
---|
362 | |
---|
363 | <?xml version="1.0"?> |
---|
364 | \end_layout |
---|
365 | |
---|
366 | \begin_layout Plain Layout |
---|
367 | |
---|
368 | <simulation> |
---|
369 | \end_layout |
---|
370 | |
---|
371 | \begin_layout Plain Layout |
---|
372 | |
---|
373 | <context id="test"> |
---|
374 | \end_layout |
---|
375 | |
---|
376 | \begin_layout Plain Layout |
---|
377 | |
---|
378 | <!-- Invalid because the calendar type cannot be known at that point --> |
---|
379 | \end_layout |
---|
380 | |
---|
381 | \begin_layout Plain Layout |
---|
382 | |
---|
383 | <calendar start_date="2011-11-11 13:37:42" /> |
---|
384 | \end_layout |
---|
385 | |
---|
386 | \begin_layout Plain Layout |
---|
387 | |
---|
388 | </context> |
---|
389 | \end_layout |
---|
390 | |
---|
391 | \begin_layout Plain Layout |
---|
392 | |
---|
393 | </simulation> |
---|
394 | \end_layout |
---|
395 | |
---|
396 | \end_inset |
---|
397 | |
---|
398 | while the following configuration file would be valid: |
---|
399 | \end_layout |
---|
400 | |
---|
401 | \begin_layout Standard |
---|
402 | \begin_inset listings |
---|
403 | lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}" |
---|
404 | inline false |
---|
405 | status open |
---|
406 | |
---|
407 | \begin_layout Plain Layout |
---|
408 | |
---|
409 | <?xml version="1.0"?> |
---|
410 | \end_layout |
---|
411 | |
---|
412 | \begin_layout Plain Layout |
---|
413 | |
---|
414 | <simulation> |
---|
415 | \end_layout |
---|
416 | |
---|
417 | \begin_layout Plain Layout |
---|
418 | |
---|
419 | <context id="test"> |
---|
420 | \end_layout |
---|
421 | |
---|
422 | \begin_layout Plain Layout |
---|
423 | |
---|
424 | <!-- The order of the arguments does not matter so this is valid --> |
---|
425 | \end_layout |
---|
426 | |
---|
427 | \begin_layout Plain Layout |
---|
428 | |
---|
429 | <calendar time_origin="2011-11-11 13:37:42" type="Gregorian" /> |
---|
430 | \end_layout |
---|
431 | |
---|
432 | \begin_layout Plain Layout |
---|
433 | |
---|
434 | </context> |
---|
435 | \end_layout |
---|
436 | |
---|
437 | \begin_layout Plain Layout |
---|
438 | |
---|
439 | </simulation> |
---|
440 | \end_layout |
---|
441 | |
---|
442 | \end_inset |
---|
443 | |
---|
444 | Of course, it is always possible to define or redefine those parameters |
---|
445 | from the Fortran interface, directly when defining the calendar: |
---|
446 | \end_layout |
---|
447 | |
---|
448 | \begin_layout Standard |
---|
449 | \begin_inset listings |
---|
450 | lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}" |
---|
451 | inline false |
---|
452 | status open |
---|
453 | |
---|
454 | \begin_layout Plain Layout |
---|
455 | |
---|
456 | ! ... |
---|
457 | \end_layout |
---|
458 | |
---|
459 | \begin_layout Plain Layout |
---|
460 | |
---|
461 | TYPE(xios_context) :: ctx_hdl |
---|
462 | \end_layout |
---|
463 | |
---|
464 | \begin_layout Plain Layout |
---|
465 | |
---|
466 | ! ... |
---|
467 | \end_layout |
---|
468 | |
---|
469 | \begin_layout Plain Layout |
---|
470 | |
---|
471 | ! Context initialization ommited, see the corresponding section of this |
---|
472 | user manual and of the reference manual |
---|
473 | \end_layout |
---|
474 | |
---|
475 | \begin_layout Plain Layout |
---|
476 | |
---|
477 | CALL xios_get_handle("test",ctx_hdl) |
---|
478 | \end_layout |
---|
479 | |
---|
480 | \begin_layout Plain Layout |
---|
481 | |
---|
482 | CALL xios_set_current_context(ctx_hdl) |
---|
483 | \end_layout |
---|
484 | |
---|
485 | \begin_layout Plain Layout |
---|
486 | |
---|
487 | CALL xios_define_calendar(type="Gregorian", time_origin=xios_date(1977, |
---|
488 | 10, 19, 00, 00, 00), start_date=xios_date(2011, 11, 11, 13, 37, 42)) |
---|
489 | \end_layout |
---|
490 | |
---|
491 | \end_inset |
---|
492 | |
---|
493 | or at a later time: |
---|
494 | \end_layout |
---|
495 | |
---|
496 | \begin_layout Standard |
---|
497 | \begin_inset listings |
---|
498 | lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}" |
---|
499 | inline false |
---|
500 | status open |
---|
501 | |
---|
502 | \begin_layout Plain Layout |
---|
503 | |
---|
504 | ! ... |
---|
505 | \end_layout |
---|
506 | |
---|
507 | \begin_layout Plain Layout |
---|
508 | |
---|
509 | TYPE(xios_context) :: ctx_hdl |
---|
510 | \end_layout |
---|
511 | |
---|
512 | \begin_layout Plain Layout |
---|
513 | |
---|
514 | ! ... |
---|
515 | \end_layout |
---|
516 | |
---|
517 | \begin_layout Plain Layout |
---|
518 | |
---|
519 | ! Context initialization ommited, see the corresponding section of this |
---|
520 | user manual and of the reference manual |
---|
521 | \end_layout |
---|
522 | |
---|
523 | \begin_layout Plain Layout |
---|
524 | |
---|
525 | CALL xios_get_handle("test",ctx_hdl) |
---|
526 | \end_layout |
---|
527 | |
---|
528 | \begin_layout Plain Layout |
---|
529 | |
---|
530 | CALL xios_set_current_context(ctx_hdl) |
---|
531 | \end_layout |
---|
532 | |
---|
533 | \begin_layout Plain Layout |
---|
534 | |
---|
535 | CALL xios_define_calendar(type="Gregorian") |
---|
536 | \end_layout |
---|
537 | |
---|
538 | \begin_layout Plain Layout |
---|
539 | |
---|
540 | CALL xios_set_time_origin(time_origin=xios_date(1977, 10, 19, 00, 00, 00)) |
---|
541 | \end_layout |
---|
542 | |
---|
543 | \begin_layout Plain Layout |
---|
544 | |
---|
545 | CALL xios_set_start_date(start_date=xios_date(2011, 11, 11, 13, 37, 42)) |
---|
546 | \end_layout |
---|
547 | |
---|
548 | \end_inset |
---|
549 | |
---|
550 | To simplify the use of dates in the XML configuration files, it is possible |
---|
551 | to partially define a date as long as the omitted parts are the rightmost. |
---|
552 | In this case the remainder of the date is initialized as in the default |
---|
553 | date. |
---|
554 | For example, it would be valid to write: |
---|
555 | \begin_inset Flex Code |
---|
556 | status open |
---|
557 | |
---|
558 | \begin_layout Plain Layout |
---|
559 | start_date="1977-10-19" |
---|
560 | \end_layout |
---|
561 | |
---|
562 | \end_inset |
---|
563 | |
---|
564 | instead of |
---|
565 | \begin_inset Flex Code |
---|
566 | status open |
---|
567 | |
---|
568 | \begin_layout Plain Layout |
---|
569 | start_date="1977-10-19 00:00:00" |
---|
570 | \end_layout |
---|
571 | |
---|
572 | \end_inset |
---|
573 | |
---|
574 | or even |
---|
575 | \begin_inset Flex Code |
---|
576 | status open |
---|
577 | |
---|
578 | \begin_layout Plain Layout |
---|
579 | time_origin="1789" |
---|
580 | \end_layout |
---|
581 | |
---|
582 | \end_inset |
---|
583 | |
---|
584 | instead of |
---|
585 | \begin_inset Flex Code |
---|
586 | status open |
---|
587 | |
---|
588 | \begin_layout Plain Layout |
---|
589 | time_origin="1789-01-01 00:00:00" |
---|
590 | \end_layout |
---|
591 | |
---|
592 | \end_inset |
---|
593 | |
---|
594 | . |
---|
595 | Similarly, it is possible to express a date with an optional duration offset |
---|
596 | in the configuration file by using the |
---|
597 | \begin_inset Flex Code |
---|
598 | status open |
---|
599 | |
---|
600 | \begin_layout Plain Layout |
---|
601 | date + duration |
---|
602 | \end_layout |
---|
603 | |
---|
604 | \end_inset |
---|
605 | |
---|
606 | notation, with |
---|
607 | \begin_inset Flex Code |
---|
608 | status open |
---|
609 | |
---|
610 | \begin_layout Plain Layout |
---|
611 | date |
---|
612 | \end_layout |
---|
613 | |
---|
614 | \end_inset |
---|
615 | |
---|
616 | potentially partially defined or even completely omitted. |
---|
617 | Consequently the following examples are all valid in the XML configuration |
---|
618 | file: |
---|
619 | \end_layout |
---|
620 | |
---|
621 | \begin_layout Itemize |
---|
622 | \begin_inset Flex Code |
---|
623 | status open |
---|
624 | |
---|
625 | \begin_layout Plain Layout |
---|
626 | time_origin="2011-11-11 13:37:00 + 42s" |
---|
627 | \end_layout |
---|
628 | |
---|
629 | \end_inset |
---|
630 | |
---|
631 | |
---|
632 | \end_layout |
---|
633 | |
---|
634 | \begin_layout Itemize |
---|
635 | \begin_inset Flex Code |
---|
636 | status open |
---|
637 | |
---|
638 | \begin_layout Plain Layout |
---|
639 | time_origin="2014 + 1y 2d" |
---|
640 | \end_layout |
---|
641 | |
---|
642 | \end_inset |
---|
643 | |
---|
644 | |
---|
645 | \end_layout |
---|
646 | |
---|
647 | \begin_layout Itemize |
---|
648 | \begin_inset Flex Code |
---|
649 | status open |
---|
650 | |
---|
651 | \begin_layout Plain Layout |
---|
652 | start_date="+ 36h" |
---|
653 | \end_layout |
---|
654 | |
---|
655 | \end_inset |
---|
656 | |
---|
657 | . |
---|
658 | \end_layout |
---|
659 | |
---|
660 | \begin_layout Section |
---|
661 | How to define a user defined calendar |
---|
662 | \end_layout |
---|
663 | |
---|
664 | \begin_layout Standard |
---|
665 | Predefined calendars might not be enough for your needs if you simulate |
---|
666 | phenomenons on another planet than the Earth. |
---|
667 | For this reason, XIOS can let you configure a completely user defined calendar |
---|
668 | by setting the |
---|
669 | \series bold |
---|
670 | type |
---|
671 | \series default |
---|
672 | attribute to |
---|
673 | \begin_inset Quotes eld |
---|
674 | \end_inset |
---|
675 | |
---|
676 | |
---|
677 | \series bold |
---|
678 | \emph on |
---|
679 | user_defined |
---|
680 | \series default |
---|
681 | \emph default |
---|
682 | |
---|
683 | \begin_inset Quotes erd |
---|
684 | \end_inset |
---|
685 | |
---|
686 | . |
---|
687 | In that case, the calendar type alone is not sufficient to define the calendar |
---|
688 | and other parameters should be provided since the duration of a day or |
---|
689 | a year are not known in advance. |
---|
690 | \begin_inset Newline newline |
---|
691 | \end_inset |
---|
692 | |
---|
693 | |
---|
694 | \begin_inset Newline newline |
---|
695 | \end_inset |
---|
696 | |
---|
697 | Two approaches are possible depending on whether you want that your custom |
---|
698 | calendar to have months or not: either use the |
---|
699 | \series bold |
---|
700 | month_lengths |
---|
701 | \series default |
---|
702 | attribute to define the duration of each months in days or use the |
---|
703 | \series bold |
---|
704 | year_length |
---|
705 | \series default |
---|
706 | attribute to define the duration of the year in seconds. |
---|
707 | In both cases, you have to define |
---|
708 | \series bold |
---|
709 | day_length |
---|
710 | \series default |
---|
711 | , the duration of a day in seconds. |
---|
712 | Those attributes have to be defined at the same time than the calendar |
---|
713 | type, either from the XML configuration file or the Fortran interface, |
---|
714 | for example: |
---|
715 | \begin_inset Newline newline |
---|
716 | \end_inset |
---|
717 | |
---|
718 | |
---|
719 | \begin_inset listings |
---|
720 | lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}" |
---|
721 | inline false |
---|
722 | status open |
---|
723 | |
---|
724 | \begin_layout Plain Layout |
---|
725 | |
---|
726 | <?xml version="1.0"?> |
---|
727 | \end_layout |
---|
728 | |
---|
729 | \begin_layout Plain Layout |
---|
730 | |
---|
731 | <simulation> |
---|
732 | \end_layout |
---|
733 | |
---|
734 | \begin_layout Plain Layout |
---|
735 | |
---|
736 | <context id="test"> |
---|
737 | \end_layout |
---|
738 | |
---|
739 | \begin_layout Plain Layout |
---|
740 | |
---|
741 | <calendar type="user_defined" day_length="86400" month_lengths="(1, 12) |
---|
742 | [31 28 31 30 31 30 31 31 30 31 30 31]" /> |
---|
743 | \end_layout |
---|
744 | |
---|
745 | \begin_layout Plain Layout |
---|
746 | |
---|
747 | </context> |
---|
748 | \end_layout |
---|
749 | |
---|
750 | \begin_layout Plain Layout |
---|
751 | |
---|
752 | </simulation> |
---|
753 | \end_layout |
---|
754 | |
---|
755 | \end_inset |
---|
756 | |
---|
757 | or |
---|
758 | \end_layout |
---|
759 | |
---|
760 | \begin_layout Standard |
---|
761 | \begin_inset listings |
---|
762 | lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}" |
---|
763 | inline false |
---|
764 | status open |
---|
765 | |
---|
766 | \begin_layout Plain Layout |
---|
767 | |
---|
768 | ! ... |
---|
769 | \end_layout |
---|
770 | |
---|
771 | \begin_layout Plain Layout |
---|
772 | |
---|
773 | TYPE(xios_context) :: ctx_hdl |
---|
774 | \end_layout |
---|
775 | |
---|
776 | \begin_layout Plain Layout |
---|
777 | |
---|
778 | ! ... |
---|
779 | \end_layout |
---|
780 | |
---|
781 | \begin_layout Plain Layout |
---|
782 | |
---|
783 | ! Context initialization ommited, see the corresponding section of this |
---|
784 | user manual and of the reference manual |
---|
785 | \end_layout |
---|
786 | |
---|
787 | \begin_layout Plain Layout |
---|
788 | |
---|
789 | CALL xios_get_handle("test",ctx_hdl) |
---|
790 | \end_layout |
---|
791 | |
---|
792 | \begin_layout Plain Layout |
---|
793 | |
---|
794 | CALL xios_set_current_context(ctx_hdl) |
---|
795 | \end_layout |
---|
796 | |
---|
797 | \begin_layout Plain Layout |
---|
798 | |
---|
799 | CALL xios_define_calendar(type="Gregorian", day_length=86400, year_length=315576 |
---|
800 | 00) |
---|
801 | \end_layout |
---|
802 | |
---|
803 | \end_inset |
---|
804 | |
---|
805 | Note that if no months are defined, the format of the dates is modified |
---|
806 | in the XML configuration file since the month must be omitted. |
---|
807 | For example, |
---|
808 | \begin_inset Flex Code |
---|
809 | status open |
---|
810 | |
---|
811 | \begin_layout Plain Layout |
---|
812 | "2015-71 13:37:42" |
---|
813 | \end_layout |
---|
814 | |
---|
815 | \end_inset |
---|
816 | |
---|
817 | would be the correct way to refer to the 71st day of the year 2015 at 13:37:42. |
---|
818 | If you use the Fortran interface, the month cannot be omitted but you have |
---|
819 | to make sure to always set it to |
---|
820 | \begin_inset Flex Code |
---|
821 | status open |
---|
822 | |
---|
823 | \begin_layout Plain Layout |
---|
824 | 1 |
---|
825 | \end_layout |
---|
826 | |
---|
827 | \end_inset |
---|
828 | |
---|
829 | in that case. |
---|
830 | For example, use |
---|
831 | \begin_inset Flex Code |
---|
832 | status open |
---|
833 | |
---|
834 | \begin_layout Plain Layout |
---|
835 | xios_date(2015, 01, 71, 13, 37, 42) |
---|
836 | \end_layout |
---|
837 | |
---|
838 | \end_inset |
---|
839 | |
---|
840 | for |
---|
841 | \begin_inset Flex Code |
---|
842 | status open |
---|
843 | |
---|
844 | \begin_layout Plain Layout |
---|
845 | "2015-71 13:37:42" |
---|
846 | \end_layout |
---|
847 | |
---|
848 | \end_inset |
---|
849 | |
---|
850 | . |
---|
851 | Moreover, it is possible that the duration of the day is greater than the |
---|
852 | duration of the year on some planets. |
---|
853 | In this case, it obviously not possible to define months so you have to |
---|
854 | use the |
---|
855 | \series bold |
---|
856 | year_length |
---|
857 | \series default |
---|
858 | attribute. |
---|
859 | Additionally the day must also be omitted from the dates in the configuration |
---|
860 | file (for example |
---|
861 | \begin_inset Flex Code |
---|
862 | status open |
---|
863 | |
---|
864 | \begin_layout Plain Layout |
---|
865 | "2015 13:37:42" |
---|
866 | \end_layout |
---|
867 | |
---|
868 | \end_inset |
---|
869 | |
---|
870 | ) and must always be set to |
---|
871 | \begin_inset Flex Code |
---|
872 | status open |
---|
873 | |
---|
874 | \begin_layout Plain Layout |
---|
875 | 1 |
---|
876 | \end_layout |
---|
877 | |
---|
878 | \end_inset |
---|
879 | |
---|
880 | when using the Fortran interface (for example |
---|
881 | \begin_inset Flex Code |
---|
882 | status open |
---|
883 | |
---|
884 | \begin_layout Plain Layout |
---|
885 | xios_date(2015, 01, 01, 13, 37, 42) |
---|
886 | \end_layout |
---|
887 | |
---|
888 | \end_inset |
---|
889 | |
---|
890 | ). |
---|
891 | \begin_inset Newline newline |
---|
892 | \end_inset |
---|
893 | |
---|
894 | |
---|
895 | \begin_inset Newline newline |
---|
896 | \end_inset |
---|
897 | |
---|
898 | If months have been defined, you might want to have leap years to correct |
---|
899 | the drift between the calendar year and the astronomical year. |
---|
900 | This can be achieved by using the |
---|
901 | \series bold |
---|
902 | leap_year_drift |
---|
903 | \series default |
---|
904 | and |
---|
905 | \series bold |
---|
906 | leap_year_month |
---|
907 | \series default |
---|
908 | attributes and optionally the |
---|
909 | \series bold |
---|
910 | leap_year_drift_offset |
---|
911 | \series default |
---|
912 | attribute. |
---|
913 | The idea is to define |
---|
914 | \series bold |
---|
915 | leap_year_drift |
---|
916 | \series default |
---|
917 | , the yearly drift between the calendar year and the astronomical year as |
---|
918 | a fraction of a day. |
---|
919 | This yearly drift is summed each year to know the current drift and each |
---|
920 | time the current drift is greater or equal to one day, the year is considered |
---|
921 | a leap year. |
---|
922 | In that case, an extra day is added to the month defined by |
---|
923 | \series bold |
---|
924 | leap_year_month |
---|
925 | \series default |
---|
926 | and one day is subtracted to the current drift. |
---|
927 | The initial drift is null by default but it can be fixed by the |
---|
928 | \series bold |
---|
929 | leap_year_drift_offset |
---|
930 | \series default |
---|
931 | attribute. |
---|
932 | \begin_inset Newline newline |
---|
933 | \end_inset |
---|
934 | |
---|
935 | |
---|
936 | \begin_inset Newline newline |
---|
937 | \end_inset |
---|
938 | |
---|
939 | The following configuration file defines a simplified Gregorian calendar |
---|
940 | using the user calendar feature: |
---|
941 | \end_layout |
---|
942 | |
---|
943 | \begin_layout Standard |
---|
944 | \begin_inset listings |
---|
945 | lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}" |
---|
946 | inline false |
---|
947 | status open |
---|
948 | |
---|
949 | \begin_layout Plain Layout |
---|
950 | |
---|
951 | <?xml version="1.0"?> |
---|
952 | \end_layout |
---|
953 | |
---|
954 | \begin_layout Plain Layout |
---|
955 | |
---|
956 | <simulation> |
---|
957 | \end_layout |
---|
958 | |
---|
959 | \begin_layout Plain Layout |
---|
960 | |
---|
961 | <context id="test"> |
---|
962 | \end_layout |
---|
963 | |
---|
964 | \begin_layout Plain Layout |
---|
965 | |
---|
966 | <calendar type="user_defined" |
---|
967 | \end_layout |
---|
968 | |
---|
969 | \begin_layout Plain Layout |
---|
970 | |
---|
971 | day_length="86400" |
---|
972 | \end_layout |
---|
973 | |
---|
974 | \begin_layout Plain Layout |
---|
975 | |
---|
976 | month_lengths="(1, 12) [31 28 31 30 31 30 31 31 30 31 30 31]" |
---|
977 | \end_layout |
---|
978 | |
---|
979 | \begin_layout Plain Layout |
---|
980 | |
---|
981 | leap_year_month="2" |
---|
982 | \end_layout |
---|
983 | |
---|
984 | \begin_layout Plain Layout |
---|
985 | |
---|
986 | leap_year_drift="0.25" |
---|
987 | \end_layout |
---|
988 | |
---|
989 | \begin_layout Plain Layout |
---|
990 | |
---|
991 | leap_year_drift_offset="0.75" |
---|
992 | \end_layout |
---|
993 | |
---|
994 | \begin_layout Plain Layout |
---|
995 | |
---|
996 | time_origin="2012-02-29 15:00:00" |
---|
997 | \end_layout |
---|
998 | |
---|
999 | \begin_layout Plain Layout |
---|
1000 | |
---|
1001 | start_date="2012-03-01 15:00:00" /> |
---|
1002 | \end_layout |
---|
1003 | |
---|
1004 | \begin_layout Plain Layout |
---|
1005 | |
---|
1006 | </context> |
---|
1007 | \end_layout |
---|
1008 | |
---|
1009 | \begin_layout Plain Layout |
---|
1010 | |
---|
1011 | </simulation> |
---|
1012 | \end_layout |
---|
1013 | |
---|
1014 | \end_inset |
---|
1015 | |
---|
1016 | As you know, the astronomical year on Earth is approximately a quarter of |
---|
1017 | day longer than the Gregorian calendar year so we have to define the yearly |
---|
1018 | drift as 0.25 day. |
---|
1019 | In case of a leap year, an extra day is added at the end of February which |
---|
1020 | is the second month of the year so |
---|
1021 | \series bold |
---|
1022 | leap_year_month |
---|
1023 | \series default |
---|
1024 | should be set to 2. |
---|
1025 | We start our time axis in 2012 which was a leap year in the Gregorian calendar. |
---|
1026 | This means there was previously three non-leap years in a row so the current |
---|
1027 | drift was (approximately) |
---|
1028 | \begin_inset Formula $3\times0.25$ |
---|
1029 | \end_inset |
---|
1030 | |
---|
1031 | days, hence |
---|
1032 | \series bold |
---|
1033 | leap_year_drift_offset |
---|
1034 | \series default |
---|
1035 | should be set to 0.75. |
---|
1036 | At the beginning of 2013, the drift would have been |
---|
1037 | \begin_inset Formula $0.75+0.25=1$ |
---|
1038 | \end_inset |
---|
1039 | |
---|
1040 | day so 2012 will be a leap year as expected. |
---|
1041 | \end_layout |
---|
1042 | |
---|
1043 | \begin_layout Section |
---|
1044 | How to use the calendar |
---|
1045 | \end_layout |
---|
1046 | |
---|
1047 | \begin_layout Standard |
---|
1048 | The calendar is created immediately after the calendar type has been defined |
---|
1049 | and thus can be used even before the context definition has been closed. |
---|
1050 | \begin_inset Newline newline |
---|
1051 | \end_inset |
---|
1052 | |
---|
1053 | |
---|
1054 | \begin_inset Newline newline |
---|
1055 | \end_inset |
---|
1056 | |
---|
1057 | Once the calendar is created, you have to keep it updated so that it is |
---|
1058 | in sync with your simulation. |
---|
1059 | To do that, you have to call the |
---|
1060 | \series bold |
---|
1061 | xios_update_calendar |
---|
1062 | \series default |
---|
1063 | subroutine for each iteration of your code: |
---|
1064 | \end_layout |
---|
1065 | |
---|
1066 | \begin_layout Standard |
---|
1067 | \begin_inset listings |
---|
1068 | lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}" |
---|
1069 | inline false |
---|
1070 | status open |
---|
1071 | |
---|
1072 | \begin_layout Plain Layout |
---|
1073 | |
---|
1074 | ! ... |
---|
1075 | \end_layout |
---|
1076 | |
---|
1077 | \begin_layout Plain Layout |
---|
1078 | |
---|
1079 | INTEGER :: ts |
---|
1080 | \end_layout |
---|
1081 | |
---|
1082 | \begin_layout Plain Layout |
---|
1083 | |
---|
1084 | ! ... |
---|
1085 | \end_layout |
---|
1086 | |
---|
1087 | \begin_layout Plain Layout |
---|
1088 | |
---|
1089 | DO ts=1,end |
---|
1090 | \end_layout |
---|
1091 | |
---|
1092 | \begin_layout Plain Layout |
---|
1093 | |
---|
1094 | CALL xios_update_calendar(ts) |
---|
1095 | \end_layout |
---|
1096 | |
---|
1097 | \begin_layout Plain Layout |
---|
1098 | |
---|
1099 | ! Do useful stuff |
---|
1100 | \end_layout |
---|
1101 | |
---|
1102 | \begin_layout Plain Layout |
---|
1103 | |
---|
1104 | ENDDO |
---|
1105 | \end_layout |
---|
1106 | |
---|
1107 | \end_inset |
---|
1108 | |
---|
1109 | The current date is updated to |
---|
1110 | \begin_inset Formula $start\_date+ts\times timestep$ |
---|
1111 | \end_inset |
---|
1112 | |
---|
1113 | after each call. |
---|
1114 | \begin_inset Newline newline |
---|
1115 | \end_inset |
---|
1116 | |
---|
1117 | |
---|
1118 | \begin_inset Newline newline |
---|
1119 | \end_inset |
---|
1120 | |
---|
1121 | Many other calendar operations are available, including: |
---|
1122 | \end_layout |
---|
1123 | |
---|
1124 | \begin_layout Itemize |
---|
1125 | accessing various calendar related information like the time step, the time |
---|
1126 | origin, the start date, the duration of a day or a year, the current date, |
---|
1127 | etc. |
---|
1128 | |
---|
1129 | \end_layout |
---|
1130 | |
---|
1131 | \begin_layout Itemize |
---|
1132 | doing arithmetic and comparison operations on date: |
---|
1133 | \begin_inset Newline newline |
---|
1134 | \end_inset |
---|
1135 | |
---|
1136 | |
---|
1137 | \begin_inset listings |
---|
1138 | lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}" |
---|
1139 | inline false |
---|
1140 | status open |
---|
1141 | |
---|
1142 | \begin_layout Plain Layout |
---|
1143 | |
---|
1144 | TYPE(xios_date) :: date1, date2 |
---|
1145 | \end_layout |
---|
1146 | |
---|
1147 | \begin_layout Plain Layout |
---|
1148 | |
---|
1149 | TYPE(xios_duration) :: duration |
---|
1150 | \end_layout |
---|
1151 | |
---|
1152 | \begin_layout Plain Layout |
---|
1153 | |
---|
1154 | LOGICAL :: res |
---|
1155 | \end_layout |
---|
1156 | |
---|
1157 | \begin_layout Plain Layout |
---|
1158 | |
---|
1159 | ! we suppose a calendar is defined |
---|
1160 | \end_layout |
---|
1161 | |
---|
1162 | \begin_layout Plain Layout |
---|
1163 | |
---|
1164 | CALL xios_get_current_date(date1) |
---|
1165 | \end_layout |
---|
1166 | |
---|
1167 | \begin_layout Plain Layout |
---|
1168 | |
---|
1169 | duration = xios_duration(0, 0, 1, 0, 0, 0, 0, 0) + 12 * xios_hour |
---|
1170 | \end_layout |
---|
1171 | |
---|
1172 | \begin_layout Plain Layout |
---|
1173 | |
---|
1174 | date2 = date1 + duration + 0.5 * xios_hour |
---|
1175 | \end_layout |
---|
1176 | |
---|
1177 | \begin_layout Plain Layout |
---|
1178 | |
---|
1179 | res = date2 > date1 |
---|
1180 | \end_layout |
---|
1181 | |
---|
1182 | \begin_layout Plain Layout |
---|
1183 | |
---|
1184 | duration = date2 - date1 |
---|
1185 | \end_layout |
---|
1186 | |
---|
1187 | \end_inset |
---|
1188 | |
---|
1189 | |
---|
1190 | \end_layout |
---|
1191 | |
---|
1192 | \begin_layout Itemize |
---|
1193 | converting dates to |
---|
1194 | \end_layout |
---|
1195 | |
---|
1196 | \begin_deeper |
---|
1197 | \begin_layout Itemize |
---|
1198 | the number of seconds since the time origin, the beginning of the year or |
---|
1199 | the beginning of the day, |
---|
1200 | \end_layout |
---|
1201 | |
---|
1202 | \begin_layout Itemize |
---|
1203 | the number of days since the beginning of the year, |
---|
1204 | \end_layout |
---|
1205 | |
---|
1206 | \begin_layout Itemize |
---|
1207 | the fraction of the day or the year. |
---|
1208 | \end_layout |
---|
1209 | |
---|
1210 | \end_deeper |
---|
1211 | \begin_layout Standard |
---|
1212 | For more detailed about the calendar attributes and operations, see the |
---|
1213 | XIOS reference guide. |
---|
1214 | \end_layout |
---|
1215 | |
---|
1216 | \begin_layout Standard |
---|
1217 | \begin_inset CommandInset include |
---|
1218 | LatexCommand include |
---|
1219 | filename "inputs/user/Grid.lyx" |
---|
1220 | |
---|
1221 | \end_inset |
---|
1222 | |
---|
1223 | |
---|
1224 | \end_layout |
---|
1225 | |
---|
1226 | \begin_layout Standard |
---|
1227 | \begin_inset CommandInset include |
---|
1228 | LatexCommand include |
---|
1229 | filename "inputs/user/Domain.lyx" |
---|
1230 | |
---|
1231 | \end_inset |
---|
1232 | |
---|
1233 | |
---|
1234 | \end_layout |
---|
1235 | |
---|
1236 | \begin_layout Standard |
---|
1237 | \begin_inset CommandInset include |
---|
1238 | LatexCommand include |
---|
1239 | filename "inputs/user/Axis.lyx" |
---|
1240 | |
---|
1241 | \end_inset |
---|
1242 | |
---|
1243 | |
---|
1244 | \end_layout |
---|
1245 | |
---|
1246 | \end_body |
---|
1247 | \end_document |
---|