-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimulationTimeType.F90
More file actions
82 lines (68 loc) · 2.49 KB
/
Copy pathSimulationTimeType.F90
File metadata and controls
82 lines (68 loc) · 2.49 KB
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
module SimulationTimeType
implicit none
type, public :: simulation_time_type
integer(kind=8),private :: year
integer(kind=8),private :: doy
integer(kind=8),private :: startyr
integer(kind=8),private :: nyr_forc
real(kind=8) ,private :: dt
contains
procedure, public :: init
procedure, public :: tick_time
procedure, public :: get_curr_time
procedure, public :: is_endof_forcing
procedure, public :: is_startof_forcing
procedure, public :: is_endof_year
procedure, public :: is_startof_year
procedure, public :: get_dtime
end type simulation_time_type
contains
subroutine init(this,year,startyr,nyr_forc,dt)
class(simulation_time_type) :: this
integer(kind=8),intent(in) :: year
integer(kind=8),intent(in) :: startyr
integer(kind=8),intent(in) :: nyr_forc
real(kind=8),intent(in) :: dt
this%year = year
this%doy = 1
this%startyr = startyr
this%nyr_forc = nyr_forc
this%dt = dt
end subroutine init
subroutine get_curr_time(this, year, doy)
class(simulation_time_type) :: this
integer(kind=8),intent(out) :: year
integer(kind=8),intent(out) :: doy
year = this%year
doy = this%doy
end subroutine get_curr_time
subroutine tick_time(this)
class(simulation_time_type) :: this
this%doy = this%doy + 1
if(this%doy .gt. 365)then
print*,'year',this%year
this%year = this%year + 1
this%doy = this%doy - 365
end if
end subroutine tick_time
logical function is_endof_forcing(this)
class(simulation_time_type) :: this
is_endof_forcing = mod(this%year-this%startyr+1,this%nyr_forc) .eq. 0 .and. this%is_endof_year()
end function is_endof_forcing
logical function is_startof_forcing(this)
class(simulation_time_type) :: this
is_startof_forcing = mod(this%year-this%startyr,this%nyr_forc) .eq. 0 .and. this%is_startof_year()
end function is_startof_forcing
logical function is_endof_year(this)
class(simulation_time_type) :: this
is_endof_year = this%doy .eq. 365
end function is_endof_year
logical function is_startof_year(this)
class(simulation_time_type) :: this
is_startof_year = this%doy .eq. 1
end function is_startof_year
real(kind=8) function get_dtime(this)
class(simulation_time_type) :: this
get_dtime = this%dt
end function get_dtime
end module SimulationTimeType