SCALE-RM
dc_calendar.f90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
13 !-------------------------------------------------------------------------------
14 ! Warning: This file was generated from dc_calendar.f90.erb.
15 ! Do not edit this file.
16 !-------------------------------------------------------------------------------
18  !-----------------------------------------------------------------------------
19  !
20  !++ used modules
21  !
22  use dc_log, only: &
23  log_lmsg, &
24  log
25  use dc_types, only: &
26  sp, &
27  dp
28  !-----------------------------------------------------------------------------
29  implicit none
30  private
31  !-----------------------------------------------------------------------------
32  !
33  !++ Public procedure
34  !
35  public :: calendarinit
36  public :: calendarymdhms2sec
37  public :: calendarsec2ymdhms
38 
39  interface calendarymdhms2sec
40  module procedure calendarymdhms2secsp
41  module procedure calendarymdhms2secdp
42  end interface calendarymdhms2sec
43 
44  interface calendarsec2ymdhms
45  module procedure calendarsec2ymdhmssp
46  module procedure calendarsec2ymdhmsdp
47  end interface calendarsec2ymdhms
48 
49  !-----------------------------------------------------------------------------
50  !
51  !++ Public parameters & variables
52  !
53  !-----------------------------------------------------------------------------
54  !
55  !++ Private procedure
56  !
57  !-----------------------------------------------------------------------------
58  !
59  !++ Private parameters & variables
60  !
61  real(DP), private, parameter :: TIME_HOUR = 24.d0
62  real(DP), private, parameter :: TIME_MIN = 60.d0
63  real(DP), private, parameter :: TIME_SEC = 60.d0
64 
65  character(len=LOG_LMSG), private :: message
66  !-----------------------------------------------------------------------------
67 contains
68 
69  !-----------------------------------------------------------------------------
71  !-----------------------------------------------------------------------------
72  subroutine calendarinit
73  implicit none
74 
75  return
76  end subroutine calendarinit
77 
78  !-----------------------------------------------------------------------------
79  ! interface CalendarYmdhms2sec
80  !-----------------------------------------------------------------------------
82  !@todo fit to gregorian calendar
83  !-----------------------------------------------------------------------------
84  subroutine calendarymdhms2secsp( &
85  second, &
86  value, &
87  unit )
88  implicit none
89 
90  real(SP), intent(out) :: second
91  real(SP), intent( in) :: value
92  character(len=*), intent( in) :: unit
93  !---------------------------------------------------------------------------
94 
95  select case(trim(unit))
96  case('MSEC','msec')
97  second = value * 1.0e-3_sp
98  case('SEC','sec','s')
99  second = value
100  case('MIN','min')
101  second = value * time_sec
102  case('HOUR','hour','h')
103  second = value * time_sec * time_min
104  case('DAY','day')
105  second = value * time_sec * time_min * time_hour
106  case default
107  write(message,*) ' xxx Unsupported UNIT:', trim(unit), value
108  call log('E', message)
109  endselect
110 
111  return
112  end subroutine calendarymdhms2secsp
113  subroutine calendarymdhms2secdp( &
114  second, &
115  value, &
116  unit )
117  implicit none
118 
119  real(DP), intent(out) :: second
120  real(DP), intent( in) :: value
121  character(len=*), intent( in) :: unit
122  !---------------------------------------------------------------------------
123 
124  select case(trim(unit))
125  case('MSEC','msec')
126  second = value * 1.0e-3_dp
127  case('SEC','sec','s')
128  second = value
129  case('MIN','min')
130  second = value * time_sec
131  case('HOUR','hour','h')
132  second = value * time_sec * time_min
133  case('DAY','day')
134  second = value * time_sec * time_min * time_hour
135  case default
136  write(message,*) ' xxx Unsupported UNIT:', trim(unit), value
137  call log('E', message)
138  endselect
139 
140  return
141  end subroutine calendarymdhms2secdp
142 
143  !-----------------------------------------------------------------------------
144  ! interface CalendarSec2ymdhms
145  !-----------------------------------------------------------------------------
147  !@todo fit to gregorian calendar
148  !-----------------------------------------------------------------------------
149  subroutine calendarsec2ymdhmssp( &
150  value, &
151  second, &
152  unit )
153  implicit none
154 
155  real(SP), intent(out) :: value
156  real(SP), intent( in) :: second
157  character(len=*), intent( in) :: unit
158  !---------------------------------------------------------------------------
159 
160  select case(trim(unit))
161  case('MSEC', 'msec')
162  value = second / 1.0e-3_sp
163  case('SEC', 'seconds', 'sec', 's')
164  value = second
165  case('MIN', 'mins', 'min')
166  value = second / time_sec
167  case('HOUR', 'hours', 'hour', 'h')
168  value = second / (time_sec * time_min)
169  case('DAY', 'days', 'day')
170  value = second / (time_sec * time_min * time_hour)
171  case default
172  write(message,*) ' xxx Unsupported UNIT:', trim(unit), value
173  call log('E', message)
174  endselect
175 
176  return
177  end subroutine calendarsec2ymdhmssp
178  subroutine calendarsec2ymdhmsdp( &
179  value, &
180  second, &
181  unit )
182  implicit none
183 
184  real(DP), intent(out) :: value
185  real(DP), intent( in) :: second
186  character(len=*), intent( in) :: unit
187  !---------------------------------------------------------------------------
188 
189  select case(trim(unit))
190  case('MSEC', 'msec')
191  value = second / 1.0e-3_dp
192  case('SEC', 'seconds', 'sec', 's')
193  value = second
194  case('MIN', 'mins', 'min')
195  value = second / time_sec
196  case('HOUR', 'hours', 'hour', 'h')
197  value = second / (time_sec * time_min)
198  case('DAY', 'days', 'day')
199  value = second / (time_sec * time_min * time_hour)
200  case default
201  write(message,*) ' xxx Unsupported UNIT:', trim(unit), value
202  call log('E', message)
203  endselect
204 
205  return
206  end subroutine calendarsec2ymdhmsdp
207 
208  !-----------------------------------------------------------------------------
209 end module dc_calendar
210 !-------------------------------------------------------------------------------
211 
212 
213 !--
214 ! vi:set readonly sw=4 ts=8
215 !
216 !Local Variables:
217 !mode: f90
218 !buffer-read-only: t
219 !End:
220 !
221 !++
module TIME
Definition: dc_calendar.f90:17
module DC_Log
Definition: dc_log.f90:14
integer, parameter, public log_lmsg
Definition: dc_log.f90:48
integer, parameter, public dp
Definition: dc_types.f90:27
subroutine, public log(type, message)
Definition: dc_log.f90:165
integer, parameter, public sp
Definition: dc_types.f90:30
subroutine, public calendarinit
Setup time.
Definition: dc_calendar.f90:73