gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
dccalconvertbyunit.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

real(dp) function dccalconvertbyunit1 (in_time, in_unit, out_unit, cal)
 Unit conversion functions for calendar.
real(dp) function dccalconvertbyunit2 (in_time, in_unit, out_unit, cal)

Function/Subroutine Documentation

◆ dccalconvertbyunit1()

real(dp) function dccalconvertbyunit1 ( real(dp), intent(in) in_time,
character(*), intent(in) in_unit,
character(*), intent(in) out_unit,
type(dc_cal), intent(in), optional, target cal )

Unit conversion functions for calendar.

Author
Youhei SASAKI, Yasuhiro MORIKAWA

Procedures described in this file are provided from "dc_calendar" module.

Convert time value between different units (string version)

Convert of unit.

Valid strings as units of time are follows.

Parameter Description
dc_calendar_types#UNIT_SEC Units of second
dc_calendar_types#UNIT_MIN Units of minute
dc_calendar_types#UNIT_HOUR Units of hour
dc_calendar_types#UNIT_DAY Units of day

If an optional argument cal is omitted, unit is converted with information of a calendar that is stored in the "dc_calendar". If cal is not omitted, unit is converted with information of the variable.

Parameters
[in]in_timeNumerical value of time before conversion
[in]in_unitUnits of time before conversion (string)
[in]out_unitUnits of time after conversion (string)
[in]calAn object that stores information of calendar
Returns
Numerical value of time after conversion

Definition at line 73 of file dccalconvertbyunit.f90.

74
77 use dc_calendar_types, only: dc_cal
79 use dc_message, only: messagenotify
80 use dc_types, only: dp
81 implicit none
82 real(DP):: out_time
83 real(DP), intent(in):: in_time
84 character(*), intent(in):: in_unit
85 character(*), intent(in):: out_unit
86 type(DC_CAL), intent(in), optional, target:: cal
87
88 ! 作業変数
89 ! Work variables
90 !
91 type(DC_CAL), pointer:: calp =>null()
92 integer:: in_unit_sym, out_unit_sym
93 character(*), parameter:: subname = 'DCCalConvertByUnit1'
94continue
95
96 out_time = -1.0
97
98 ! オブジェクトのポインタ割付
99 ! Associate pointer of an object
100 !
101 if ( present( cal ) ) then
102 calp => cal
103 else
104 calp => default_cal
105 if ( .not. calp % initialized ) call default_cal_set
106 end if
107
108 ! 初期設定のチェック
109 ! Check initialization
110 !
111 if ( .not. calp % initialized ) then
112 call messagenotify('W', subname, '"cal" is not initialized. <-1> is returned.' )
113 goto 999
114 end if
115
116 ! 単位の解釈
117 ! Parse units
118 !
119 in_unit_sym = dccaldate_str2usym( in_unit )
120 out_unit_sym = dccaldate_str2usym( out_unit )
121
122 ! 数値の変換
123 ! Convert a value
124 !
125 out_time = dccalconvertbyunit( in_time, in_unit_sym, out_unit_sym, cal )
126
127 ! 終了処理, 例外処理
128 ! Termination and Exception handling
129 !
130999 continue
131 nullify( calp )
Interface declarations for dc_calendar procedures.
Internal module for dc_calendar.
type(dc_cal), target, save, public default_cal
Default calendar object
subroutine, public default_cal_set
integer function, public dccaldate_str2usym(str)
Derived types and parameters of calendar and date.
Message output module.
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public dp
Double Precision Real number
Definition dc_types.f90:92

References dc_calendar_internal::dccaldate_str2usym(), dc_calendar_internal::default_cal, dc_calendar_internal::default_cal_set(), and dc_types::dp.

Here is the call graph for this function:

◆ dccalconvertbyunit2()

real(dp) function dccalconvertbyunit2 ( real(dp), intent(in) in_time,
integer, intent(in) in_unit,
integer, intent(in) out_unit,
type(dc_cal), intent(in), optional, target cal )

Convert time value between different units (symbol version)

Convert of unit.

Valid integer variables as units of time are follows. Do not specify integer directly, but specify following variables.

Parameter Description
dc_calendar_types#UNIT_SYMBOL_SEC Units of second
dc_calendar_types#UNIT_SYMBOL_MIN Units of minute
dc_calendar_types#UNIT_SYMBOL_HOUR Units of hour
dc_calendar_types#UNIT_SYMBOL_DAY Units of day

If an optional argument cal is omitted, unit is converted with information of a calendar that is stored in the "dc_calendar". If cal is not omitted, unit is converted with information of the variable.

Parameters
[in]in_timeNumerical value of time before conversion
[in]in_unitUnits of time before conversion (integer symbol)
[in]out_unitUnits of time after conversion (integer symbol)
[in]calAn object that stores information of calendar
Returns
Numerical value of time after conversion

Definition at line 189 of file dccalconvertbyunit.f90.

190
192 use dc_calendar_types, only: dc_cal, &
194 use dc_message, only: messagenotify
195 use dc_types, only: dp
196 implicit none
197 real(DP):: out_time
198 real(DP), intent(in):: in_time
199 integer, intent(in):: in_unit
200 integer, intent(in):: out_unit
201 type(DC_CAL), intent(in), optional, target:: cal
202
203 ! 作業変数
204 ! Work variables
205 !
206 type(DC_CAL), pointer:: calp =>null()
207 real(DP):: in_timew
208 character(*), parameter:: subname = 'DCCalConvertByUnit2'
209continue
210
211 out_time = -1.0
212
213 ! オブジェクトのポインタ割付
214 ! Associate pointer of an object
215 !
216 if ( present( cal ) ) then
217 calp => cal
218 else
219 calp => default_cal
220 if ( .not. calp % initialized ) call default_cal_set
221 end if
222
223 ! 初期設定のチェック
224 ! Check initialization
225 !
226 if ( .not. calp % initialized ) then
227 call messagenotify('W', subname, '"cal" is not initialized. <-1> is returned.' )
228 goto 999
229 end if
230
231 ! 数値の変換
232 ! Convert a value
233 !
234 select case(in_unit)
235 case(unit_symbol_day)
236 in_timew = in_time * calp % hour_in_day &
237 & * calp % min_in_hour &
238 & * calp % sec_in_min
239 case(unit_symbol_hour)
240 in_timew = in_time * calp % min_in_hour &
241 & * calp % sec_in_min
242 case(unit_symbol_min)
243 in_timew = in_time * calp % sec_in_min
244 case(unit_symbol_sec)
245 in_timew = in_time
246 case default
247 call messagenotify('W', subname, 'in_unit=<%d> is invalid. (ONLY day,hour,min,sec are valid).' // &
248 & ' <-1> is returned.', &
249 & i = (/ in_unit /) )
250 goto 999
251 end select
252
253 select case(out_unit)
254 case(unit_symbol_day)
255 out_time = in_timew / calp % hour_in_day &
256 & / calp % min_in_hour &
257 & / calp % sec_in_min
258 case(unit_symbol_hour)
259 out_time = in_timew / calp % min_in_hour &
260 & / calp % sec_in_min
261 case(unit_symbol_min)
262 out_time = in_timew / calp % sec_in_min
263 case(unit_symbol_sec)
264 out_time = in_timew
265 case default
266 call messagenotify('W', subname, 'out_unit=<%d> is invalid. (ONLY day,hour,min,sec are valid).' // &
267 & ' <-1> is returned.', &
268 & i = (/ out_unit /) )
269 goto 999
270 end select
271
272 ! 終了処理, 例外処理
273 ! Termination and Exception handling
274 !
275999 continue
276 nullify( calp )
integer, parameter, public unit_symbol_sec
integer, parameter, public unit_symbol_hour
integer, parameter, public unit_symbol_day
integer, parameter, public unit_symbol_min

References dc_calendar_internal::default_cal, dc_calendar_internal::default_cal_set(), dc_types::dp, dc_calendar_types::unit_symbol_day, dc_calendar_types::unit_symbol_hour, dc_calendar_types::unit_symbol_min, and dc_calendar_types::unit_symbol_sec.

Here is the call graph for this function: