gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
dccalconverttohour.f90
Go to the documentation of this file.
1! -*- mode: f90; coding: utf-8 -*-
2!-----------------------------------------------------------------------
3! Copyright (c) 2000-2026 Gtool Development Group. All rights reserved.
4!-----------------------------------------------------------------------
5!>
6!> @author Youhei SASAKI, Yasuhiro MORIKAWA
7!> @copyright Copyright (C) GFD Dennou Club, 2009-2026. All rights reserved. <br/>
8!> License is BSD-2-Clause. see [COPYRIGHT](@ref COPYRIGHT) in detail
9!> @en
10!> @brief Convert time to hour unit
11!> @details
12!> Procedures described in this file are provided from "dc_calendar" module.
13!> @enden
14!>
15!> @ja
16!> @brief 時間を時の単位に変換
17!> @details
18!> このファイルに記載される手続き群は dc_calendar モジュールから提供されます.
19!> @endja
20!>
21
22!> @en
23!> @brief Convert time from arbitrary unit to hour (string version)
24!> @details
25!> Convert of unit from arbitrary time units (day, hour, minute, second)
26!> into hour.
27!>
28!> Valid strings as units of time are follows.
29!>
30!> | Parameter | Description |
31!> |--------------------------------|-------------------|
32!> | dc_calendar_types#UNIT_SEC | Units of second |
33!> | dc_calendar_types#UNIT_MIN | Units of minute |
34!> | dc_calendar_types#UNIT_HOUR | Units of hour |
35!> | dc_calendar_types#UNIT_DAY | Units of day |
36!>
37!> If an optional argument `cal` is omitted,
38!> unit is converted with information of a calendar
39!> that is stored in the "dc_calendar".
40!> If `cal` is not omitted, unit is converted with information of the variable.
41!>
42!> @param[in] in_time Numerical value of time before conversion
43!> @param[in] in_unit Units of time before conversion (string)
44!> @param[in] cal An object that stores information of calendar
45!> @return Numerical value of time after conversion (in hours)
46!> @enden
47!>
48!> @ja
49!> @brief 任意の単位から時への変換 (文字列版)
50!> @details
51!> 任意の時間単位 (日時分秒) から時への単位の変換を行います.
52!>
53!> 時間の単位として有効な文字列については以下を参照下さい.
54!>
55!> | パラメータ | 説明 |
56!> |--------------------------------|-------------------|
57!> | dc_calendar_types#UNIT_SEC | 秒の単位 |
58!> | dc_calendar_types#UNIT_MIN | 分の単位 |
59!> | dc_calendar_types#UNIT_HOUR | 時間の単位 |
60!> | dc_calendar_types#UNIT_DAY | 日の単位 |
61!>
62!> 省略可能引数 `cal` が省略された場合には, dc_calendar 内部で
63!> 保持される暦に関する情報を用いた単位の変換が行われます.
64!> `cal` が省略されない場合にはその変数に設定された暦の情報を
65!> 用いて単位の変換が行われます.
66!>
67!> @param[in] in_time 変換前の時間の数値
68!> @param[in] in_unit 変換前の時間の単位 (文字列)
69!> @param[in] cal 暦情報を収めたオブジェクト
70!> @return 変換後の時間の数値 (時単位)
71!> @endja
72function dccalconverttohour1( in_time, in_unit, cal ) result( out_time )
73
78 use dc_message, only: messagenotify
79 use dc_types, only: dp
80 implicit none
81 real(dp):: out_time
82 real(dp), intent(in):: in_time
83 character(*), intent(in):: in_unit
84 type(dc_cal), intent(in), optional, target:: cal
85
86 ! 作業変数
87 ! Work variables
88 !
89 type(dc_cal), pointer:: calp =>null()
90 integer:: in_unit_sym, out_unit_sym
91 character(*), parameter:: subname = 'DCCalConvertToHour1'
92continue
93
94 out_time = -1.0
95
96 ! オブジェクトのポインタ割付
97 ! Associate pointer of an object
98 !
99 if ( present( cal ) ) then
100 calp => cal
101 else
102 calp => default_cal
103 if ( .not. calp % initialized ) call default_cal_set
104 end if
105
106 ! 初期設定のチェック
107 ! Check initialization
108 !
109 if ( .not. calp % initialized ) then
110 call messagenotify('W', subname, '"cal" is not initialized. <-1> is returned.' )
111 goto 999
112 end if
113
114 ! 単位の解釈
115 ! Parse units
116 !
117 in_unit_sym = dccaldate_str2usym( in_unit )
118 out_unit_sym = unit_symbol_hour
119
120 ! 数値の変換
121 ! Convert a value
122 !
123 out_time = dccalconvertbyunit( in_time, in_unit_sym, out_unit_sym, cal )
124
125 ! 終了処理, 例外処理
126 ! Termination and Exception handling
127 !
128999 continue
129 nullify( calp )
130end function dccalconverttohour1
131
132!---------------------------------------------------------------------
133
134!> @en
135!> @brief Convert time from arbitrary unit to hour (symbol version)
136!> @details
137!> Convert of unit from arbitrary time units (day, hour, minute, second)
138!> into hour.
139!>
140!> Valid integer variables as units of time are follows.
141!> Do not specify integer directly, but specify following variables.
142!>
143!> | Parameter | Description |
144!> |-------------------------------------|-------------------|
145!> | dc_calendar_types#UNIT_SYMBOL_SEC | Units of second |
146!> | dc_calendar_types#UNIT_SYMBOL_MIN | Units of minute |
147!> | dc_calendar_types#UNIT_SYMBOL_HOUR | Units of hour |
148!> | dc_calendar_types#UNIT_SYMBOL_DAY | Units of day |
149!>
150!> If an optional argument `cal` is omitted,
151!> unit is converted with information of a calendar
152!> that is stored in the "dc_calendar".
153!> If `cal` is not omitted, unit is converted with information of the variable.
154!>
155!> @param[in] in_time Numerical value of time before conversion
156!> @param[in] in_unit Units of time before conversion (integer symbol)
157!> @param[in] cal An object that stores information of calendar
158!> @return Numerical value of time after conversion (in hours)
159!> @enden
160!>
161!> @ja
162!> @brief 任意の単位から時への変換 (シンボル版)
163!> @details
164!> 任意の時間単位 (日時分秒) から時への単位の変換を行います.
165!>
166!> 時間の単位として有効な整数型変数については以下を参照下さい.
167!> 単位として整数値を直接与えることはせず, 以下の変数を与えてください.
168!>
169!> | パラメータ | 説明 |
170!> |-------------------------------------|-------------------|
171!> | dc_calendar_types#UNIT_SYMBOL_SEC | 秒の単位 |
172!> | dc_calendar_types#UNIT_SYMBOL_MIN | 分の単位 |
173!> | dc_calendar_types#UNIT_SYMBOL_HOUR | 時間の単位 |
174!> | dc_calendar_types#UNIT_SYMBOL_DAY | 日の単位 |
175!>
176!> 省略可能引数 `cal` が省略された場合には, dc_calendar 内部で
177!> 保持される暦に関する情報を用いた単位の変換が行われます.
178!> `cal` が省略されない場合にはその変数に設定された暦の情報を
179!> 用いて単位の変換が行われます.
180!>
181!> @param[in] in_time 変換前の時間の数値
182!> @param[in] in_unit 変換前の時間の単位 (整数シンボル)
183!> @param[in] cal 暦情報を収めたオブジェクト
184!> @return 変換後の時間の数値 (時単位)
185!> @endja
186function dccalconverttohour2( in_time, in_unit, cal ) result( out_time )
187
191 use dc_message, only: messagenotify
192 use dc_types, only: dp
193 implicit none
194 real(dp):: out_time
195 real(dp), intent(in):: in_time
196 integer, intent(in):: in_unit
197 type(dc_cal), intent(in), optional, target:: cal
198
199 ! 作業変数
200 ! Work variables
201 !
202 type(dc_cal), pointer:: calp =>null()
203 integer:: out_unit
204 character(*), parameter:: subname = 'DCCalConvertToHour2'
205continue
206
207 out_time = -1.0
208
209 ! オブジェクトのポインタ割付
210 ! Associate pointer of an object
211 !
212 if ( present( cal ) ) then
213 calp => cal
214 else
215 calp => default_cal
216 if ( .not. calp % initialized ) call default_cal_set
217 end if
218
219 ! 初期設定のチェック
220 ! Check initialization
221 !
222 if ( .not. calp % initialized ) then
223 call messagenotify('W', subname, '"cal" is not initialized. <-1> is returned.' )
224 goto 999
225 end if
226
227 ! 単位の解釈
228 ! Parse units
229 !
230 out_unit = unit_symbol_hour
231
232 ! 数値の変換
233 ! Convert a value
234 !
235 out_time = dccalconvertbyunit( in_time, in_unit, out_unit, cal )
236
237 ! 終了処理, 例外処理
238 ! Termination and Exception handling
239 !
240999 continue
241 nullify( calp )
242end function dccalconverttohour2
real(dp) function dccalconverttohour2(in_time, in_unit, cal)
real(dp) function dccalconverttohour1(in_time, in_unit, cal)
時間を時の単位に変換
dc_calendar 手続のインターフェース宣言
dc_calendar用の内部モジュール
type(dc_cal), target, save, public default_cal
デフォルトの暦. DCCal で始まる手続のうち, DC_CAL 型の省略可能引数が与えられない 場合にはこの暦が設定もしくは利用される.
subroutine, public default_cal_set
integer function, public dccaldate_str2usym(str)
暦と日時に関する構造データ型と定数
integer, parameter, public unit_symbol_hour
メッセージの出力
種別型パラメタを提供します。
Definition dc_types.f90:55
integer, parameter, public dp
倍精度実数型変数
Definition dc_types.f90:92