Date and time

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
TYPE date

    logical :: is_init     = .false.
    logical :: is_day_init = .false.

    integer(ip) :: year             = 0_ip
    integer(ip) :: month            = 0_ip
    integer(ip) :: day              = 0_ip
    integer(ip) :: hour             = 0_ip
    integer(ip) :: minute           = 0_ip
    integer(ip) :: second           = 0_ip
    integer(ip) :: julian_day       = 0_ip
    integer(ip) :: julian_cnes_day  = 0_ip
    real(rp)    :: julian_date      = 0._rp
    real(rp)    :: julian_cnes_date = 0._rp

    character(len=:), allocatable :: cdate

CONTAINS

    procedure, pass( self ) :: set => set_date
    procedure, pass( self ) :: date_to_julian
    procedure, pass( self ) :: julian_to_date
    procedure, pass( self ) :: julian_to_cnes
    procedure, pass( self ) :: cnes_to_julian
    procedure, pass( self ) :: julian_cnes_day_to_date
    procedure, pass( self ) :: day_to_julian_cnes_day
    procedure, pass( self ) :: to_char => date_to_char
    procedure, pass( self ) :: output => output_date

END TYPE date

TYPE time

    real(rp)                      :: seconds
    real(rp)                      :: minutes
    real(rp)                      :: hours
    real(rp)                      :: days
    character(len=:), allocatable :: ctime

CONTAINS

    procedure, pass(self) :: set_time_from_char
    procedure, pass(self) :: set_time_from_real

    generic :: set => set_time_from_char , &
                    set_time_from_real

END TYPE time

TYPE date_time

    !================================================================================================================!
    !  Format
    !================================================================================================================!

    integer(ip) :: format

    !================================================================================================================!
    !  Dates
    !================================================================================================================!

    type(date) :: date_start
    type(date) :: date_end
    type(date) :: date_current

    !================================================================================================================!
    !  Times
    !================================================================================================================!

    type(time) :: time_start
    type(time) :: time_end
    type(time) :: time_current

    !================================================================================================================!
    !  Control parameters
    !================================================================================================================!

    integer(ip) :: nt
    real(rp)    :: dt

CONTAINS

    procedure, pass(self) :: init    => init_date_and_time
    procedure, pass(self) :: advance => advance_date_and_time

END TYPE date_time
Back to top