gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
dccaldateinquire.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine dccaldateinquire1 (year, month, day, hour, min, sec, zone, elapse_sec, date, cal, err)
 日時情報の問い合わせ
subroutine dccaldateinquire2 (date_str, elapse_sec, date, cal, err)

Function/Subroutine Documentation

◆ dccaldateinquire1()

subroutine dccaldateinquire1 ( integer, intent(out), optional year,
integer, intent(out), optional month,
integer, intent(out), optional day,
integer, intent(out), optional hour,
integer, intent(out), optional min,
real(dp), intent(out), optional sec,
character(*), intent(out), optional zone,
real(dp), intent(in), optional elapse_sec,
type(dc_cal_date), intent(in), optional, target date,
type(dc_cal), intent(in), optional, target cal,
logical, intent(out), optional err )

日時情報の問い合わせ

Author
Yasuhiro MORIKAWA

このファイルに記載される手続き群は dc_calendar モジュールから提供されます.

日時情報を個別変数で問い合わせ

日時情報の問い合わせを行います.

問い合わせの結果を YYYY-MM-DDThh:mm:ss.sTZD のような文字列 (YYYY は年, MM は月, DD は日, hh は時, mm は分, ss.s は秒, TZD はタイムゾーン) で受け取りたい場合には, 下記の同名のサブルーチンを使用して下さい.

省略可能引数 date が省略された場合には, dc_calendar 内部で 保持される日時に関する情報が得られます. date が省略されない場合にはその変数に設定された日時の情報が得られます.

省略可能引数 cal が省略された場合には, 経過秒数 elapse_sec の年月日時分への変換に dc_calendar 内部で保持される暦が用いられます. cal が省略されない場合にはその変数に設定された暦が用いられます.

Parameters
[out]year
[out]month
[out]day
[out]hour
[out]min
[out]sec
[out]zoneUTC からの時差
[in]elapse_secdate からの経過秒数
[in]date日時情報を収めたオブジェクト
[in]cal暦情報を収めたオブジェクト
[out]err例外処理用フラグ. デフォルトでは, この手続き内でエラーが生じた場合, プログラムは強制終了します. 引数 err が与えられる場合, プログラムは強制終了せず, 代わりに err に .true. が代入されます.

Definition at line 94 of file dccaldateinquire.f90.

96
101 use dc_message, only: messagenotify
102 use dc_string, only: lchar
103 use dc_trace, only: beginsub, endsub
106 use dc_types, only: string, dp, token
107 implicit none
108 integer, intent(out), optional:: year
109 integer, intent(out), optional:: month
110 integer, intent(out), optional:: day
111 integer, intent(out), optional:: hour
112 integer, intent(out), optional:: min
113 real(DP), intent(out), optional:: sec
114 character(*), intent(out), optional:: zone
115 real(DP), intent(in), optional:: elapse_sec
116 type(DC_CAL_DATE), intent(in), optional, target:: date
117 type(DC_CAL), intent(in), optional, target:: cal
118 logical, intent(out), optional:: err
119
120 ! 作業変数
121 ! Work variables
122 !
123 integer:: wyear, wmonth, wday, whour, wmin
124 real(DP):: wsec
125 character(TOKEN):: wzone
126 type(DC_CAL_DATE), pointer:: datep =>null()
127 type(DC_CAL), pointer:: calp =>null()
128 character(STRING):: e_date_str, e_cal_str
129 integer:: stat
130 character(STRING):: cause_c
131 character(*), parameter:: subname = 'DCCalInquire1'
132continue
133 call beginsub( subname )
134 stat = dc_noerr
135 cause_c = ''
136
137 ! オブジェクトのポインタ割付
138 ! Associate pointer of an object
139 !
140 if ( present( date ) ) then
141 datep => date
142 else
143 datep => default_date
144 end if
145
146 if ( present( cal ) ) then
147 calp => cal
148 else
149 calp => default_cal
150 if ( .not. calp % initialized ) call default_cal_set
151 end if
152
153 ! 初期設定のチェック
154 ! Check initialization
155 !
156 if ( .not. datep % initialized ) then
157 stat = dc_enotinit
158 cause_c = 'DC_CAL_DATE'
159 goto 999
160 end if
161
162 if ( .not. calp % initialized ) then
163 stat = dc_enotinit
164 cause_c = 'DC_CAL'
165 goto 999
166 end if
167
168 ! 各要素への値の参照
169 ! Refer elements
170 !
171 wyear = datep % year
172 wmonth = datep % month
173 wday = datep % day
174 whour = datep % hour
175 wmin = datep % min
176 wsec = datep % sec
177 wzone = datep % zone
178
179 ! 経過時間(秒)の追加
180 ! Add elapsed time (seconds)
181 !
182 if ( present( elapse_sec ) ) then
183!!$ if ( elapse_sec < 0.0_DP ) then
184!!$ stat = DC_ENEGATIVE
185!!$ cause_c = 'elapse_sec'
186!!$ goto 999
187!!$ end if
188
189 wsec = wsec + elapse_sec
190 end if
191
192 ! 日時の正規化
193 ! Normalize date and time
194 !
195 stat = dccaldate_normalize( wyear, wmonth, wday, whour, wmin, wsec, & ! (inout)
196 & calp ) ! (in)
197 if ( stat == dc_einconsistcaldate ) then
198 e_cal_str = dccaltochar( calp )
199 e_date_str = dccaldatetochar( wyear, wmonth, wday, whour, wmin, wsec, wzone )
200 call messagenotify('W', subname, 'cal=<%c> and date=<%c> are inconsistency', &
201 & c1 = trim(e_cal_str), c2 = trim(e_date_str) )
202 goto 999
203 end if
204
205 ! 引数への代入
206 ! Substitute arguments
207 !
208 if ( present(year ) ) year = wyear
209 if ( present(month) ) month = wmonth
210 if ( present(day ) ) day = wday
211 if ( present(hour ) ) hour = whour
212 if ( present(min ) ) min = wmin
213 if ( present(sec ) ) sec = wsec
214 if ( present(zone ) ) zone = wzone
215
216 ! 終了処理, 例外処理
217 ! Termination and Exception handling
218 !
219999 continue
220 nullify( calp, datep )
221 call storeerror( stat, subname, err, cause_c )
222 call endsub( subname )
dc_calendar 手続のインターフェース宣言
dc_calendar用の内部モジュール
type(dc_cal), target, save, public default_cal
デフォルトの暦. DCCal で始まる手続のうち, DC_CAL 型の省略可能引数が与えられない 場合にはこの暦が設定もしくは利用される.
type(dc_cal_date), target, save, public default_date
デフォルトの日時. DCCalDate で始まる手続のうち, DC_CAL_DATE 型の省略可能引数が 与えられない場合にはこの日時が設定もしくは利用される.
integer function, public dccaldate_normalize(year, month, day, hour, min, sec, cal)
subroutine, public default_cal_set
暦と日時に関する構造データ型と定数
エラー処理用モジュール
Definition dc_error.f90:454
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:891
integer, parameter, public dc_enotinit
-400 以下: dc ユーティリティのエラー
Definition dc_error.f90:534
integer, parameter, public dc_noerr
エラー等を保持
Definition dc_error.f90:468
integer, parameter, public dc_einconsistcaldate
Definition dc_error.f90:553
メッセージの出力
文字型変数の操作
Definition dc_string.f90:83
デバッグ時の追跡用モジュール
Definition dc_trace.f90:150
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
Definition dc_trace.f90:476
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:599
種別型パラメタを提供します。
Definition dc_types.f90:55
integer, parameter, public token
単語やキーワードを保持する文字型変数の種別型パラメタ
Definition dc_types.f90:128
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:137
integer, parameter, public dp
倍精度実数型変数
Definition dc_types.f90:92

References dc_trace::beginsub(), dc_error::dc_einconsistcaldate, dc_error::dc_enotinit, dc_error::dc_noerr, dc_calendar_internal::dccaldate_normalize(), dc_calendar_internal::default_cal, dc_calendar_internal::default_cal_set(), dc_calendar_internal::default_date, dc_types::dp, dc_trace::endsub(), dc_error::storeerror(), dc_types::string, and dc_types::token.

Here is the call graph for this function:

◆ dccaldateinquire2()

subroutine dccaldateinquire2 ( character(*), intent(out) date_str,
real(dp), intent(in), optional elapse_sec,
type(dc_cal_date), intent(in), optional, target date,
type(dc_cal), intent(in), optional, target cal,
logical, intent(out), optional err )

日時情報を文字列で問い合わせ

日時情報の問い合わせを行います. 問い合わせ結果は YYYY-MM-DDThh:mm:ss.sTZD のような文字列 (YYYY は年, MM は月, DD は日, hh は時, mm は分, ss.s は秒, TZD はタイムゾーン) で返ります. 日時の文字列形式は gtool4 netCDF 規約「5.5 日時形式」に準拠しています.

問い合わせの結果を年月日時分秒で各個変数で受け取りたい場合は 上記の同名のサブルーチンを使用して下さい.

省略可能引数 date が省略された場合には, dc_calendar 内部で 保持される日時に関する情報が得られます. date が省略されない場合にはその変数に設定された日時の情報が得られます.

省略可能引数 cal が省略された場合には, 経過秒数 elapse_sec の年月日時分への変換に dc_calendar 内部で保持される暦が用いられます. cal が省略されない場合にはその変数に設定された暦が用いられます.

Parameters
[out]date_str日時情報を表す文字列. 表示形式については gtool4 netCDF 規約 5.5 日時形式を参照のこと.
[in]elapse_secdate からの経過秒数
[in]date日時情報を収めたオブジェクト
[in]cal暦情報を収めたオブジェクト
[out]err例外処理用フラグ. デフォルトでは, この手続き内でエラーが生じた場合, プログラムは強制終了します. 引数 err が与えられる場合, プログラムは強制終了せず, 代わりに err に .true. が代入されます.

Definition at line 292 of file dccaldateinquire.f90.

293
299 use dc_message, only: messagenotify
300 use dc_string, only: lchar
301 use dc_trace, only: beginsub, endsub
304 use dc_types, only: string, dp, token
305 implicit none
306 character(*), intent(out):: date_str
307 real(DP), intent(in), optional:: elapse_sec
308 type(DC_CAL_DATE), intent(in), optional, target:: date
309 type(DC_CAL), intent(in), optional, target:: cal
310 logical, intent(out), optional:: err
311
312 ! 作業変数
313 ! Work variables
314 !
315 integer:: year, month, day, hour, min
316 real(DP):: sec
317 character(TOKEN):: zone
318 type(DC_CAL_DATE), pointer:: datep =>null()
319 type(DC_CAL), pointer:: calp =>null()
320 character(STRING):: e_date_str, e_cal_str
321 integer:: stat
322 character(STRING):: cause_c
323 character(*), parameter:: subname = 'DCCalInquire2'
324continue
325 call beginsub( subname )
326 stat = dc_noerr
327 cause_c = ''
328
329 ! オブジェクトのポインタ割付
330 ! Associate pointer of an object
331 !
332 if ( present( date ) ) then
333 datep => date
334 else
335 datep => default_date
336 end if
337
338 if ( present( cal ) ) then
339 calp => cal
340 else
341 calp => default_cal
342 if ( .not. calp % initialized ) call default_cal_set
343 end if
344
345 ! 初期設定のチェック
346 ! Check initialization
347 !
348 if ( .not. datep % initialized ) then
349 stat = dc_enotinit
350 cause_c = 'DC_CAL_DATE'
351 goto 999
352 end if
353
354 if ( .not. calp % initialized ) then
355 stat = dc_enotinit
356 cause_c = 'DC_CAL'
357 goto 999
358 end if
359
360 ! 各要素の取得
361 ! Get elements
362 !
363 year = datep % year
364 month = datep % month
365 day = datep % day
366 hour = datep % hour
367 min = datep % min
368 sec = datep % sec
369 zone = datep % zone
370
371
372 ! 経過時間(秒)の追加
373 ! Add elapsed time (seconds)
374 !
375 if ( present( elapse_sec ) ) then
376!!$ if ( elapse_sec < 0.0_DP ) then
377!!$ stat = DC_ENEGATIVE
378!!$ cause_c = 'elapse_sec'
379!!$ goto 999
380!!$ end if
381
382 sec = sec + elapse_sec
383 end if
384
385 ! 日時の正規化
386 ! Normalize date and time
387 !
388 stat = dccaldate_normalize( year, month, day, hour, min, sec, & ! (inout)
389 & calp ) ! (in)
390 if ( stat == dc_einconsistcaldate ) then
391 e_cal_str = dccaltochar( calp )
392 e_date_str = dccaldatetochar( year, month, day, hour, min, sec, zone )
393 call messagenotify('W', subname, 'cal=<%c> and date=<%c> are inconsistency', &
394 & c1 = trim(e_cal_str), c2 = trim(e_date_str) )
395 goto 999
396 end if
397
398 ! 日時表記(gtool4 netCDF 規約 5.5 日時形式)への変換
399 ! Convert expression of date (gtool4 netCDF Convention 5.5 Expression of date and time)
400 !
401 date_str = dccaldatetochar( year, month, day, hour, min, sec, zone )
402
403 ! 終了処理, 例外処理
404 ! Termination and Exception handling
405 !
406999 continue
407 nullify( calp, datep )
408 call storeerror( stat, subname, err, cause_c )
409 call endsub( subname )

References dc_trace::beginsub(), dc_error::dc_einconsistcaldate, dc_error::dc_enotinit, dc_error::dc_noerr, dc_calendar_internal::dccaldate_normalize(), dc_calendar_internal::default_cal, dc_calendar_internal::default_cal_set(), dc_calendar_internal::default_date, dc_types::dp, dc_trace::endsub(), dc_error::storeerror(), dc_types::string, and dc_types::token.

Here is the call graph for this function: