gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
dccaldateeval.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 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 Evaluate date
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 Evaluate and set date with elapsed seconds
24!> @details
25!> Evaluate and set date.
26!>
27!> If an optional argument `date` is omitted,
28!> the date setting is stored to a "dc_calendar_types#DC_CAL_DATE"
29!> variable that is saved in the "dc_calendar".
30!> When `date` is omitted in subsequent procedures, the internal date
31!> is used.
32!> If `date` is not omitted, the settings is stored to the `date`.
33!> In order to use the date setting, use the "dc_calendar_types#DC_CAL_DATE"
34!> variable to subsequent procedures.
35!>
36!> If an optional argument `cal` is omitted,
37!> information of calendar that is stored in the "dc_calendar"
38!> is used for conversion of elapsed seconds `elapse_sec` into
39!> year-month-day etc.
40!> If `cal` is not omitted, information of the variable is used.
41!>
42!> @param[in] year Year of origin
43!> @param[in] month Month of origin
44!> @param[in] day Day of origin
45!> @param[in] hour Hour of origin
46!> @param[in] min Minute of origin
47!> @param[in] sec Second of origin
48!> @param[in] elapse_sec Elapsed seconds from `year` -- `sec`
49!> @param[in] cal An object that stores information of calendar
50!> @param[out] date An object that stores information of date and time after elapsed time
51!> @param[out] err Exception handling flag
52!> @enden
53!>
54!> @ja
55!> @brief 経過秒数から日時を算出・設定
56!> @details
57!> 日時の算出と設定を行います.
58!>
59!> 省略可能引数 `date` が省略された場合には, dc_calendar 内部で
60!> 保持される "dc_calendar_types#DC_CAL_DATE" 型の変数に日時が
61!> 設定されます. その後の手続きで `date` を省略した場合には
62!> この日時が使用されます.
63!> `date` が省略されない場合にはその変数に日時が設定されます.
64!> その日時を使用する場合, 手続きにその "dc_calendar_types#DC_CAL_DATE" 型の変数
65!> を与えてください.
66!>
67!> 省略可能引数 `cal` が省略された場合には, 経過秒数 `elapse_sec`
68!> の年月日時分への変換に dc_calendar 内部で保持される暦が用いられます.
69!> `cal` が省略されない場合にはその変数に設定された暦が用いられます.
70!>
71!> @param[in] year 起点の年
72!> @param[in] month 起点の月
73!> @param[in] day 起点の日
74!> @param[in] hour 起点の時
75!> @param[in] min 起点の分
76!> @param[in] sec 起点の秒
77!> @param[in] elapse_sec `year` 〜 `sec` からの経過秒数
78!> @param[in] cal 暦情報を収めたオブジェクト
79!> @param[out] date 経過時間後の日時情報を収めたオブジェクト
80!> @param[out] err 例外処理用フラグ.
81!> デフォルトでは, この手続き内でエラーが生じた場合,
82!> プログラムは強制終了します.
83!> 引数 `err` が与えられる場合, プログラムは強制終了せず,
84!> 代わりに `err` に .true. が代入されます.
85!> @endja
87 & year, month, day, hour, min, sec, elapse_sec, cal, date, err )
88
93 use dc_message, only: messagenotify
94 use dc_trace, only: beginsub, endsub
97 use dc_types, only: string, dp
98 implicit none
99 integer, intent(in):: year
100 integer, intent(in):: month
101 integer, intent(in):: day
102 integer, intent(in):: hour
103 integer, intent(in):: min
104 real(DP), intent(in):: sec
105 real(DP), intent(in):: elapse_sec
106 type(dc_cal), intent(in), optional, target:: cal
107 type(dc_cal_date), intent(out), optional, target:: date
108 logical, intent(out), optional:: err
109
110 ! 作業変数
111 ! Work variables
112 !
113 integer:: wyear, wmonth, wday, whour, wmin
114 real(DP):: wsec
115 type(dc_cal_date), pointer:: datep =>null()
116 type(dc_cal), pointer:: calp =>null()
117 character(STRING):: e_date_str, e_cal_str
118 integer:: stat
119 character(STRING):: cause_c
120 character(*), parameter:: subname = 'DCCalDateEvalYMDHMS1'
121continue
122 call beginsub( subname )
123 stat = dc_noerr
124 cause_c = ''
125
126 ! オブジェクトのポインタ割付
127 ! Associate pointer of an object
128 !
129 if ( present( date ) ) then
130 datep => date
131 else
132 datep => default_date
133 end if
134
135 if ( present( cal ) ) then
136 calp => cal
137 else
138 calp => default_cal
139 if ( .not. calp % initialized ) call default_cal_set
140 end if
141
142 ! 初期設定のチェック
143 ! Check initialization
144 !
145!!$ if ( .not. datep % initialized ) then
146!!$ stat = DC_ENOTINIT
147!!$ cause_c = 'DC_CAL_DATE'
148!!$ goto 999
149!!$ end if
150
151 if ( .not. calp % initialized ) then
152 stat = dc_enotinit
153 cause_c = 'DC_CAL'
154 goto 999
155 end if
156
157 ! 各要素への値の参照
158 ! Refer elements
159 !
160 wyear = year
161 wmonth = month
162 wday = day
163 whour = hour
164 wmin = min
165 wsec = sec
166
167 ! 経過時間(秒)の追加
168 ! Add elapsed time (seconds)
169 !
170!!$ if ( elapse_sec < 0.0_DP ) then
171!!$ stat = DC_ENEGATIVE
172!!$ cause_c = 'elapse_sec'
173!!$ goto 999
174!!$ end if
175
176 wsec = wsec + elapse_sec
177
178 ! 日時の正規化
179 ! Normalize date and time
180 !
181 stat = dccaldate_normalize( wyear, wmonth, wday, whour, wmin, wsec, & ! (inout)
182 & calp ) ! (in)
183 if ( stat == dc_einconsistcaldate ) then
184 e_cal_str = dccaltochar( calp )
185 e_date_str = dccaldatetochar( wyear, wmonth, wday, whour, wmin, wsec, zone = "" )
186 call messagenotify('W', subname, 'cal=<%c> and date=<%c> are inconsistency', &
187 & c1 = trim(e_cal_str), c2 = trim(e_date_str) )
188 goto 999
189 end if
190
191 ! オブジェクトの作成
192 ! Create an object
193 !
194 call dccaldatecreate( &
195 & wyear, wmonth, wday, whour, wmin, wsec, & ! (in)
196 & datep, zone = "", err = err ) ! (out) optional
197 if ( present(err) ) then
198 if ( err ) then
199 stat = dc_ebaddate
200 goto 999
201 end if
202 end if
203
204 ! 終了処理, 例外処理
205 ! Termination and Exception handling
206 !
207999 continue
208 nullify( calp, datep )
209 call storeerror( stat, subname, err, cause_c )
210 call endsub( subname )
211end subroutine dccaldateevalymdhms1
212
213!-----------------------------------------------------------
214
215!> @en
216!> @brief Evaluate and set date with elapsed time and units
217!> @details
218!> Evaluate and set date.
219!>
220!> If an optional argument `date` is omitted,
221!> the date setting is stored to a "dc_calendar_types#DC_CAL_DATE"
222!> variable that is saved in the "dc_calendar".
223!> When `date` is omitted in subsequent procedures, the internal date
224!> is used.
225!> If `date` is not omitted, the settings is stored to the `date`.
226!> In order to use the date setting, use the "dc_calendar_types#DC_CAL_DATE"
227!> variable to subsequent procedures.
228!>
229!> If an optional argument `cal` is omitted,
230!> information of calendar that is stored in the "dc_calendar"
231!> is used for conversion of elapsed time `elapse_time` into
232!> year-month-day etc.
233!> If `cal` is not omitted, information of the variable is used.
234!>
235!> @param[in] year Year of origin
236!> @param[in] month Month of origin
237!> @param[in] day Day of origin
238!> @param[in] hour Hour of origin
239!> @param[in] min Minute of origin
240!> @param[in] sec Second of origin
241!> @param[in] elapse_time Elapsed time from `year` -- `sec`. Unit is specified as `units`.
242!> @param[in] units Unit of `elapse_time`
243!> @param[in] cal An object that stores information of calendar
244!> @param[out] date An object that stores information of date and time after elapsed time
245!> @param[out] err Exception handling flag
246!> @enden
247!>
248!> @ja
249!> @brief 経過時間と単位から日時を算出・設定
250!> @details
251!> 日時の算出と設定を行います.
252!>
253!> 省略可能引数 `date` が省略された場合には, dc_calendar 内部で
254!> 保持される "dc_calendar_types#DC_CAL_DATE" 型の変数に日時が
255!> 設定されます. その後の手続きで `date` を省略した場合には
256!> この日時が使用されます.
257!> `date` が省略されない場合にはその変数に日時が設定されます.
258!> その日時を使用する場合, 手続きにその "dc_calendar_types#DC_CAL_DATE" 型の変数
259!> を与えてください.
260!>
261!> 省略可能引数 `cal` が省略された場合には, 経過時間 `elapse_time`
262!> の年月日時分への変換に dc_calendar 内部で保持される暦が用いられます.
263!> `cal` が省略されない場合にはその変数に設定された暦が用いられます.
264!>
265!> @param[in] year 起点の年
266!> @param[in] month 起点の月
267!> @param[in] day 起点の日
268!> @param[in] hour 起点の時
269!> @param[in] min 起点の分
270!> @param[in] sec 起点の秒
271!> @param[in] elapse_time `year` 〜 `sec` からの経過時間. 単位は `units` で指定する.
272!> @param[in] units `elapse_time` の単位
273!> @param[in] cal 暦情報を収めたオブジェクト
274!> @param[out] date 経過時間後の日時情報を収めたオブジェクト
275!> @param[out] err 例外処理用フラグ
276!> @endja
278 & year, month, day, hour, min, sec, elapse_time, units, cal, date, err )
279
285 use dc_message, only: messagenotify
286 use dc_trace, only: beginsub, endsub
289 use dc_types, only: string, dp
290 implicit none
291 integer, intent(in):: year
292 integer, intent(in):: month
293 integer, intent(in):: day
294 integer, intent(in):: hour
295 integer, intent(in):: min
296 real(DP), intent(in):: sec
297 real(DP), intent(in):: elapse_time
298 character(*), intent(in):: units
299 type(dc_cal), intent(in), optional, target:: cal
300 type(dc_cal_date), intent(out), optional, target:: date
301 logical, intent(out), optional:: err
302
303 ! 作業変数
304 ! Work variables
305 !
306 integer:: wyear, wmonth, wday, whour, wmin
307 real(DP):: wsec
308 type(dc_cal_date), pointer:: datep =>null()
309 type(dc_cal), pointer:: calp =>null()
310 character(STRING):: e_date_str, e_cal_str
311 integer:: tusym
312 integer:: stat
313 character(STRING):: cause_c
314 character(*), parameter:: subname = 'DCCalDateEvalYMDHMS2'
315continue
316 call beginsub( subname )
317 stat = dc_noerr
318 cause_c = ''
319
320 ! オブジェクトのポインタ割付
321 ! Associate pointer of an object
322 !
323 if ( present( date ) ) then
324 datep => date
325 else
326 datep => default_date
327 end if
328
329 if ( present( cal ) ) then
330 calp => cal
331 else
332 calp => default_cal
333 if ( .not. calp % initialized ) call default_cal_set
334 end if
335
336 ! 初期設定のチェック
337 ! Check initialization
338 !
339!!$ if ( .not. datep % initialized ) then
340!!$ stat = DC_ENOTINIT
341!!$ cause_c = 'DC_CAL_DATE'
342!!$ goto 999
343!!$ end if
344
345 if ( .not. calp % initialized ) then
346 stat = dc_enotinit
347 cause_c = 'DC_CAL'
348 goto 999
349 end if
350
351 ! 各要素への値の参照
352 ! Refer elements
353 !
354 wyear = year
355 wmonth = month
356 wday = day
357 whour = hour
358 wmin = min
359 wsec = sec
360
361 ! 経過時間(秒)の追加
362 ! Add elapsed time (seconds)
363 !
364!!$ if ( elapse_time < 0.0_DP ) then
365!!$ stat = DC_ENEGATIVE
366!!$ cause_c = 'elapse_time'
367!!$ goto 999
368!!$ end if
369
370 tusym = dccaldate_str2usym(units)
371 select case(tusym)
372 case(unit_symbol_day)
373 wsec = wsec + elapse_time * calp % hour_in_day &
374 & * calp % min_in_hour &
375 & * calp % sec_in_min
376 case(unit_symbol_hour)
377 wsec = wsec + elapse_time * calp % min_in_hour &
378 & * calp % sec_in_min
379 case(unit_symbol_min)
380 wsec = wsec + elapse_time * calp % sec_in_min
381 case(unit_symbol_sec)
382 wsec = wsec + elapse_time
383 case default
384 cause_c = units
385 call messagenotify('W', subname, 'units=<%c> is invalid. (ONLY day,hrs,min,sec are valid)', &
386 & c1 = trim(units) )
387 stat = dc_ebadunit
388 goto 999
389 end select
390
391 ! 日時の正規化
392 ! Normalize date and time
393 !
394 stat = dccaldate_normalize( wyear, wmonth, wday, whour, wmin, wsec, & ! (inout)
395 & calp ) ! (in)
396 if ( stat == dc_einconsistcaldate ) then
397 e_cal_str = dccaltochar( calp )
398 e_date_str = dccaldatetochar( wyear, wmonth, wday, whour, wmin, wsec, zone = "" )
399 call messagenotify('W', subname, 'cal=<%c> and date=<%c> are inconsistency', &
400 & c1 = trim(e_cal_str), c2 = trim(e_date_str) )
401 goto 999
402 end if
403
404 ! オブジェクトの作成
405 ! Create an object
406 !
407 call dccaldatecreate( &
408 & wyear, wmonth, wday, whour, wmin, wsec, & ! (in)
409 & datep, zone = "", err = err ) ! (out) optional
410 if ( present(err) ) then
411 if ( err ) then
412 stat = dc_ebaddate
413 goto 999
414 end if
415 end if
416
417 ! 終了処理, 例外処理
418 ! Termination and Exception handling
419 !
420999 continue
421 nullify( calp, datep )
422 call storeerror( stat, subname, err, cause_c )
423 call endsub( subname )
424end subroutine dccaldateevalymdhms2
425
426!-----------------------------------------------------------
427
428!> @en
429!> @brief Evaluate and set date from initial date object with elapsed seconds
430!> @details
431!> Evaluate and set date.
432!>
433!> If an optional argument `date` is omitted,
434!> the date setting is stored to a "dc_calendar_types#DC_CAL_DATE"
435!> variable that is saved in the "dc_calendar".
436!> When `date` is omitted in subsequent procedures, the internal date
437!> is used.
438!> If `date` is not omitted, the settings is stored to the `date`.
439!> In order to use the date setting, use the "dc_calendar_types#DC_CAL_DATE"
440!> variable to subsequent procedures.
441!>
442!> If an optional argument `cal` is omitted,
443!> information of calendar that is stored in the "dc_calendar"
444!> is used for conversion of elapsed seconds `elapse_sec` into
445!> year-month-day etc.
446!> If `cal` is not omitted, information of the variable is used.
447!>
448!> @param[in] init_date An object that stores information of date of origin
449!> @param[in] elapse_sec Elapsed seconds from `init_date`
450!> @param[in] cal An object that stores information of calendar
451!> @param[out] date An object that stores information of date and time after elapsed time
452!> @param[out] err Exception handling flag
453!> @enden
454!>
455!> @ja
456!> @brief 初期日時オブジェクトと経過秒数から日時を算出・設定
457!> @details
458!> 日時の算出と設定を行います.
459!>
460!> 省略可能引数 `date` が省略された場合には, dc_calendar 内部で
461!> 保持される "dc_calendar_types#DC_CAL_DATE" 型の変数に日時が
462!> 設定されます. その後の手続きで `date` を省略した場合には
463!> この日時が使用されます.
464!> `date` が省略されない場合にはその変数に日時が設定されます.
465!> その日時を使用する場合, 手続きにその "dc_calendar_types#DC_CAL_DATE" 型の変数
466!> を与えてください.
467!>
468!> 省略可能引数 `cal` が省略された場合には, 経過秒数 `elapse_sec`
469!> の年月日時分への変換に dc_calendar 内部で保持される暦が用いられます.
470!> `cal` が省略されない場合にはその変数に設定された暦が用いられます.
471!>
472!> @param[in] init_date 起点となる日時情報を収めたオブジェクト
473!> @param[in] elapse_sec `init_date` からの経過秒数
474!> @param[in] cal 暦情報を収めたオブジェクト
475!> @param[out] date 経過時間後の日時情報を収めたオブジェクト
476!> @param[out] err 例外処理用フラグ
477!> @endja
478subroutine dccaldateevalid1( init_date, elapse_sec, cal, date, err )
479
484 use dc_message, only: messagenotify
485 use dc_trace, only: beginsub, endsub
488 use dc_types, only: string, dp, token
489 implicit none
490 type(dc_cal_date), intent(in):: init_date
491 real(DP), intent(in):: elapse_sec
492 type(dc_cal), intent(in), optional, target:: cal
493 type(dc_cal_date), intent(out), optional, target:: date
494 logical, intent(out), optional:: err
495
496 ! 作業変数
497 ! Work variables
498 !
499 integer:: wyear, wmonth, wday, whour, wmin
500 real(DP):: wsec
501 character(TOKEN):: wzone
502 type(dc_cal_date), pointer:: datep =>null()
503 type(dc_cal), pointer:: calp =>null()
504 character(STRING):: e_date_str, e_cal_str
505 integer:: stat
506 character(STRING):: cause_c
507 character(*), parameter:: subname = 'DCCalDateEvalID1'
508continue
509 call beginsub( subname )
510 stat = dc_noerr
511 cause_c = ''
512
513 ! オブジェクトのポインタ割付
514 ! Associate pointer of an object
515 !
516 if ( present( date ) ) then
517 datep => date
518 else
519 datep => default_date
520 end if
521
522 if ( present( cal ) ) then
523 calp => cal
524 else
525 calp => default_cal
526 if ( .not. calp % initialized ) call default_cal_set
527 end if
528
529 ! 初期設定のチェック
530 ! Check initialization
531 !
532!!$ if ( .not. datep % initialized ) then
533!!$ stat = DC_ENOTINIT
534!!$ cause_c = 'DC_CAL_DATE'
535!!$ goto 999
536!!$ end if
537
538 if ( .not. calp % initialized ) then
539 stat = dc_enotinit
540 cause_c = 'DC_CAL'
541 goto 999
542 end if
543
544 ! 各要素への値の参照
545 ! Refer elements
546 !
547 wyear = init_date % year
548 wmonth = init_date % month
549 wday = init_date % day
550 whour = init_date % hour
551 wmin = init_date % min
552 wsec = init_date % sec
553 wzone = init_date % zone
554
555 ! 経過時間(秒)の追加
556 ! Add elapsed time (seconds)
557 !
558!!$ if ( elapse_sec < 0.0_DP ) then
559!!$ stat = DC_ENEGATIVE
560!!$ cause_c = 'elapse_sec'
561!!$ goto 999
562!!$ end if
563
564 wsec = wsec + elapse_sec
565
566 ! 日時の正規化
567 ! Normalize date and time
568 !
569 stat = dccaldate_normalize( wyear, wmonth, wday, whour, wmin, wsec, & ! (inout)
570 & calp ) ! (in)
571 if ( stat == dc_einconsistcaldate ) then
572 e_cal_str = dccaltochar( calp )
573 e_date_str = dccaldatetochar( wyear, wmonth, wday, whour, wmin, wsec, zone = "" )
574 call messagenotify('W', subname, 'cal=<%c> and date=<%c> are inconsistency', &
575 & c1 = trim(e_cal_str), c2 = trim(e_date_str) )
576 goto 999
577 end if
578
579 ! オブジェクトの作成
580 ! Create an object
581 !
582 call dccaldatecreate( &
583 & wyear, wmonth, wday, whour, wmin, wsec, & ! (in)
584 & datep, zone = wzone, err = err ) ! (out) optional
585 if ( present(err) ) then
586 if ( err ) then
587 stat = dc_ebaddate
588 goto 999
589 end if
590 end if
591
592 ! 終了処理, 例外処理
593 ! Termination and Exception handling
594 !
595999 continue
596 nullify( calp, datep )
597 call storeerror( stat, subname, err, cause_c )
598 call endsub( subname )
599end subroutine dccaldateevalid1
600
601!-----------------------------------------------------------
602
603!> @en
604!> @brief Evaluate and set date from initial date object with elapsed time and units
605!> @details
606!> Evaluate and set date.
607!>
608!> If an optional argument `date` is omitted,
609!> the date setting is stored to a "dc_calendar_types#DC_CAL_DATE"
610!> variable that is saved in the "dc_calendar".
611!> When `date` is omitted in subsequent procedures, the internal date
612!> is used.
613!> If `date` is not omitted, the settings is stored to the `date`.
614!> In order to use the date setting, use the "dc_calendar_types#DC_CAL_DATE"
615!> variable to subsequent procedures.
616!>
617!> If an optional argument `cal` is omitted,
618!> information of calendar that is stored in the "dc_calendar"
619!> is used for conversion of elapsed time `elapse_time` into
620!> year-month-day etc.
621!> If `cal` is not omitted, information of the variable is used.
622!>
623!> @param[in] init_date An object that stores information of date of origin
624!> @param[in] elapse_time Elapsed time from `init_date`. Unit is specified as `units`.
625!> @param[in] units Unit of `elapse_time`
626!> @param[in] cal An object that stores information of calendar
627!> @param[out] date An object that stores information of date and time after elapsed time
628!> @param[out] err Exception handling flag
629!> @enden
630!>
631!> @ja
632!> @brief 初期日時オブジェクトと経過時間・単位から日時を算出・設定
633!> @details
634!> 日時の算出と設定を行います.
635!>
636!> 省略可能引数 `date` が省略された場合には, dc_calendar 内部で
637!> 保持される "dc_calendar_types#DC_CAL_DATE" 型の変数に日時が
638!> 設定されます. その後の手続きで `date` を省略した場合には
639!> この日時が使用されます.
640!> `date` が省略されない場合にはその変数に日時が設定されます.
641!> その日時を使用する場合, 手続きにその "dc_calendar_types#DC_CAL_DATE" 型の変数
642!> を与えてください.
643!>
644!> 省略可能引数 `cal` が省略された場合には, 経過時間 `elapse_time`
645!> の年月日時分への変換に dc_calendar 内部で保持される暦が用いられます.
646!> `cal` が省略されない場合にはその変数に設定された暦が用いられます.
647!>
648!> @param[in] init_date 起点となる日時情報を収めたオブジェクト
649!> @param[in] elapse_time `init_date` からの経過時間. 単位は `units` で指定する.
650!> @param[in] units `elapse_time` の単位
651!> @param[in] cal 暦情報を収めたオブジェクト
652!> @param[out] date 経過時間後の日時情報を収めたオブジェクト
653!> @param[out] err 例外処理用フラグ
654!> @endja
655subroutine dccaldateevalid2( init_date, elapse_time, units, cal, date, err )
661 use dc_message, only: messagenotify
662 use dc_trace, only: beginsub, endsub
665 use dc_types, only: string, dp, token
666 implicit none
667 type(dc_cal_date), intent(in):: init_date
668 real(DP), intent(in):: elapse_time
669 character(*), intent(in):: units
670 type(dc_cal), intent(in), optional, target:: cal
671 type(dc_cal_date), intent(out), optional, target:: date
672 logical, intent(out), optional:: err
673
674 ! 作業変数
675 ! Work variables
676 !
677 integer:: wyear, wmonth, wday, whour, wmin
678 real(DP):: wsec
679 character(TOKEN):: wzone
680 type(dc_cal_date), pointer:: datep =>null()
681 type(dc_cal), pointer:: calp =>null()
682 character(STRING):: e_date_str, e_cal_str
683 integer:: tusym
684 integer:: stat
685 character(STRING):: cause_c
686 character(*), parameter:: subname = 'DCCalDateEvalID2'
687continue
688 call beginsub( subname )
689 stat = dc_noerr
690 cause_c = ''
691
692 ! オブジェクトのポインタ割付
693 ! Associate pointer of an object
694 !
695 if ( present( date ) ) then
696 datep => date
697 else
698 datep => default_date
699 end if
700
701 if ( present( cal ) ) then
702 calp => cal
703 else
704 calp => default_cal
705 if ( .not. calp % initialized ) call default_cal_set
706 end if
707
708 ! 初期設定のチェック
709 ! Check initialization
710 !
711!!$ if ( .not. datep % initialized ) then
712!!$ stat = DC_ENOTINIT
713!!$ cause_c = 'DC_CAL_DATE'
714!!$ goto 999
715!!$ end if
716
717 if ( .not. calp % initialized ) then
718 stat = dc_enotinit
719 cause_c = 'DC_CAL'
720 goto 999
721 end if
722
723 ! 各要素への値の参照
724 ! Refer elements
725 !
726 wyear = init_date % year
727 wmonth = init_date % month
728 wday = init_date % day
729 whour = init_date % hour
730 wmin = init_date % min
731 wsec = init_date % sec
732 wzone = init_date % zone
733
734 ! 経過時間(秒)の追加
735 ! Add elapsed time (seconds)
736 !
737!!$ if ( elapse_time < 0.0_DP ) then
738!!$ stat = DC_ENEGATIVE
739!!$ cause_c = 'elapse_time'
740!!$ goto 999
741!!$ end if
742
743 tusym = dccaldate_str2usym(units)
744 select case(tusym)
745 case(unit_symbol_day)
746 wsec = wsec + elapse_time * calp % hour_in_day &
747 & * calp % min_in_hour &
748 & * calp % sec_in_min
749 case(unit_symbol_hour)
750 wsec = wsec + elapse_time * calp % min_in_hour &
751 & * calp % sec_in_min
752 case(unit_symbol_min)
753 wsec = wsec + elapse_time * calp % sec_in_min
754 case(unit_symbol_sec)
755 wsec = wsec + elapse_time
756 case default
757 cause_c = units
758 call messagenotify('W', subname, 'units=<%c> is invalid. (ONLY day,hrs,min,sec are valid)', &
759 & c1 = trim(units) )
760 stat = dc_ebadunit
761 goto 999
762 end select
763
764 ! 日時の正規化
765 ! Normalize date and time
766 !
767 stat = dccaldate_normalize( wyear, wmonth, wday, whour, wmin, wsec, & ! (inout)
768 & calp ) ! (in)
769 if ( stat == dc_einconsistcaldate ) then
770 e_cal_str = dccaltochar( calp )
771 e_date_str = dccaldatetochar( wyear, wmonth, wday, whour, wmin, wsec, zone = "" )
772 call messagenotify('W', subname, 'cal=<%c> and date=<%c> are inconsistency', &
773 & c1 = trim(e_cal_str), c2 = trim(e_date_str) )
774 goto 999
775 end if
776
777 ! オブジェクトの作成
778 ! Create an object
779 !
780 call dccaldatecreate( &
781 & wyear, wmonth, wday, whour, wmin, wsec, & ! (in)
782 & datep, zone = wzone, err = err ) ! (out) optional
783 if ( present(err) ) then
784 if ( err ) then
785 stat = dc_ebaddate
786 goto 999
787 end if
788 end if
789
790 ! 終了処理, 例外処理
791 ! Termination and Exception handling
792 !
793999 continue
794 nullify( calp, datep )
795 call storeerror( stat, subname, err, cause_c )
796 call endsub( subname )
797end subroutine dccaldateevalid2
798
799!-----------------------------------------------------------
800
801!> @en
802!> @brief Evaluate date and return as individual variables with elapsed seconds
803!> @details
804!> Evaluate and set date.
805!>
806!> If an optional argument `cal` is omitted,
807!> information of calendar that is stored in the "dc_calendar"
808!> is used for conversion of elapsed seconds `elapse_sec` into
809!> year-month-day etc.
810!> If `cal` is not omitted, information of the variable is used.
811!>
812!> @param[in] year1 Year of origin
813!> @param[in] month1 Month of origin
814!> @param[in] day1 Day of origin
815!> @param[in] hour1 Hour of origin
816!> @param[in] min1 Minute of origin
817!> @param[in] sec1 Second of origin
818!> @param[in] elapse_sec Elapsed seconds from `year1` -- `sec1`
819!> @param[out] year2 Year after elapsed time
820!> @param[out] month2 Month after elapsed time
821!> @param[out] day2 Day after elapsed time
822!> @param[out] hour2 Hour after elapsed time
823!> @param[out] min2 Minute after elapsed time
824!> @param[out] sec2 Second after elapsed time
825!> @param[in] cal An object that stores information of calendar
826!> @param[out] err Exception handling flag
827!> @enden
828!>
829!> @ja
830!> @brief 経過秒数から日時を算出し個別変数で返す
831!> @details
832!> 日時の算出と設定を行います.
833!>
834!> 省略可能引数 `cal` が省略された場合には, 経過秒数 `elapse_sec`
835!> の年月日時分への変換に dc_calendar 内部で保持される暦が用いられます.
836!> `cal` が省略されない場合にはその変数に設定された暦が用いられます.
837!>
838!> @param[in] year1 起点の年
839!> @param[in] month1 起点の月
840!> @param[in] day1 起点の日
841!> @param[in] hour1 起点の時
842!> @param[in] min1 起点の分
843!> @param[in] sec1 起点の秒
844!> @param[in] elapse_sec `year1` 〜 `sec1` からの経過秒数
845!> @param[out] year2 経過時間後の年
846!> @param[out] month2 経過時間後の月
847!> @param[out] day2 経過時間後の日
848!> @param[out] hour2 経過時間後の時
849!> @param[out] min2 経過時間後の分
850!> @param[out] sec2 経過時間後の秒
851!> @param[in] cal 暦情報を収めたオブジェクト
852!> @param[out] err 例外処理用フラグ
853!> @endja
855 & year1, month1, day1, hour1, min1, sec1, &
856 & elapse_sec, &
857 & year2, month2, day2, hour2, min2, sec2, &
858 & cal, err )
863 use dc_message, only: messagenotify
864 use dc_trace, only: beginsub, endsub
867 use dc_types, only: string, dp
868 implicit none
869 integer, intent(in):: year1
870 integer, intent(in):: month1
871 integer, intent(in):: day1
872 integer, intent(in):: hour1
873 integer, intent(in):: min1
874 real(DP), intent(in):: sec1
875 real(DP), intent(in):: elapse_sec
876 integer, intent(out):: year2
877 integer, intent(out):: month2
878 integer, intent(out):: day2
879 integer, intent(out):: hour2
880 integer, intent(out):: min2
881 real(DP), intent(out):: sec2
882 type(dc_cal), intent(in), optional, target:: cal
883 logical, intent(out), optional:: err
884
885 ! 作業変数
886 ! Work variables
887 !
888 type(dc_cal), pointer:: calp =>null()
889 character(STRING):: e_date_str, e_cal_str
890 integer:: stat
891 character(STRING):: cause_c
892 character(*), parameter:: subname = 'DCCalDateEvalYM2YM1'
893continue
894 call beginsub( subname )
895 stat = dc_noerr
896 cause_c = ''
897
898 ! オブジェクトのポインタ割付
899 ! Associate pointer of an object
900 !
901 if ( present( cal ) ) then
902 calp => cal
903 else
904 calp => default_cal
905 if ( .not. calp % initialized ) call default_cal_set
906 end if
907
908 ! 初期設定のチェック
909 ! Check initialization
910 !
911!!$ if ( .not. datep % initialized ) then
912!!$ stat = DC_ENOTINIT
913!!$ cause_c = 'DC_CAL_DATE'
914!!$ goto 999
915!!$ end if
916
917 if ( .not. calp % initialized ) then
918 stat = dc_enotinit
919 cause_c = 'DC_CAL'
920 goto 999
921 end if
922
923 ! 各要素への値の参照
924 ! Refer elements
925 !
926 year2 = year1
927 month2 = month1
928 day2 = day1
929 hour2 = hour1
930 min2 = min1
931 sec2 = sec1
932
933 ! 経過時間(秒)の追加
934 ! Add elapsed time (seconds)
935 !
936!!$ if ( elapse_sec < 0.0_DP ) then
937!!$ stat = DC_ENEGATIVE
938!!$ cause_c = 'elapse_sec'
939!!$ goto 999
940!!$ end if
941
942 sec2 = sec2 + elapse_sec
943
944 ! 日時の正規化
945 ! Normalize date and time
946 !
947 stat = dccaldate_normalize( year2, month2, day2, hour2, min2, sec2, & ! (inout)
948 & calp ) ! (in)
949 if ( stat == dc_einconsistcaldate ) then
950 e_cal_str = dccaltochar( calp )
951 e_date_str = dccaldatetochar( year2, month2, day2, hour2, min2, sec2, zone = "" )
952 call messagenotify('W', subname, 'cal=<%c> and date=<%c> are inconsistency', &
953 & c1 = trim(e_cal_str), c2 = trim(e_date_str) )
954 goto 999
955 end if
956
957 ! 終了処理, 例外処理
958 ! Termination and Exception handling
959 !
960999 continue
961 nullify( calp )
962 call storeerror( stat, subname, err, cause_c )
963 call endsub( subname )
964end subroutine dccaldateevalym2ym1
965
966!-----------------------------------------------------------
967
968!> @en
969!> @brief Evaluate date and return as individual variables with elapsed time and units
970!> @details
971!> Evaluate and set date.
972!>
973!> If an optional argument `cal` is omitted,
974!> information of calendar that is stored in the "dc_calendar"
975!> is used for conversion of elapsed time `elapse_time` into
976!> year-month-day etc.
977!> If `cal` is not omitted, information of the variable is used.
978!>
979!> @param[in] year1 Year of origin
980!> @param[in] month1 Month of origin
981!> @param[in] day1 Day of origin
982!> @param[in] hour1 Hour of origin
983!> @param[in] min1 Minute of origin
984!> @param[in] sec1 Second of origin
985!> @param[in] elapse_time Elapsed time from `year1` -- `sec1`. Unit is specified as `units`.
986!> @param[in] units Unit of `elapse_time`
987!> @param[out] year2 Year after elapsed time
988!> @param[out] month2 Month after elapsed time
989!> @param[out] day2 Day after elapsed time
990!> @param[out] hour2 Hour after elapsed time
991!> @param[out] min2 Minute after elapsed time
992!> @param[out] sec2 Second after elapsed time
993!> @param[in] cal An object that stores information of calendar
994!> @param[out] err Exception handling flag
995!> @enden
996!>
997!> @ja
998!> @brief 経過時間と単位から日時を算出し個別変数で返す
999!> @details
1000!> 日時の算出と設定を行います.
1001!>
1002!> 省略可能引数 `cal` が省略された場合には, 経過時間 `elapse_time`
1003!> の年月日時分への変換に dc_calendar 内部で保持される暦が用いられます.
1004!> `cal` が省略されない場合にはその変数に設定された暦が用いられます.
1005!>
1006!> @param[in] year1 起点の年
1007!> @param[in] month1 起点の月
1008!> @param[in] day1 起点の日
1009!> @param[in] hour1 起点の時
1010!> @param[in] min1 起点の分
1011!> @param[in] sec1 起点の秒
1012!> @param[in] elapse_time `year1` 〜 `sec1` からの経過時間. 単位は `units` で指定する.
1013!> @param[in] units `elapse_time` の単位
1014!> @param[out] year2 経過時間後の年
1015!> @param[out] month2 経過時間後の月
1016!> @param[out] day2 経過時間後の日
1017!> @param[out] hour2 経過時間後の時
1018!> @param[out] min2 経過時間後の分
1019!> @param[out] sec2 経過時間後の秒
1020!> @param[in] cal 暦情報を収めたオブジェクト
1021!> @param[out] err 例外処理用フラグ
1022!> @endja
1024 & year1, month1, day1, hour1, min1, sec1, &
1025 & elapse_time, units, &
1026 & year2, month2, day2, hour2, min2, sec2, &
1027 & cal, err )
1028 use dc_calendar_types, only: dc_cal, dc_cal_date, &
1033 use dc_message, only: messagenotify
1034 use dc_trace, only: beginsub, endsub
1035 use dc_error, only: storeerror, dc_noerr, dc_enotinit, &
1037 use dc_types, only: string, dp
1038 implicit none
1039
1040 integer, intent(in):: year1
1041 integer, intent(in):: month1
1042 integer, intent(in):: day1
1043 integer, intent(in):: hour1
1044 integer, intent(in):: min1
1045 real(DP), intent(in):: sec1
1046 real(DP), intent(in):: elapse_time
1047 character(*), intent(in):: units
1048 integer, intent(out):: year2
1049 integer, intent(out):: month2
1050 integer, intent(out):: day2
1051 integer, intent(out):: hour2
1052 integer, intent(out):: min2
1053 real(DP), intent(out):: sec2
1054 type(dc_cal), intent(in), optional, target:: cal
1055 logical, intent(out), optional:: err
1056
1057 ! 作業変数
1058 ! Work variables
1059 !
1060 type(dc_cal), pointer:: calp =>null()
1061 character(STRING):: e_date_str, e_cal_str
1062 integer:: tusym
1063 integer:: stat
1064 character(STRING):: cause_c
1065 character(*), parameter:: subname = 'DCCalDateEvalYM2YM1'
1066continue
1067 call beginsub( subname )
1068 stat = dc_noerr
1069 cause_c = ''
1070
1071 ! オブジェクトのポインタ割付
1072 ! Associate pointer of an object
1073 !
1074 if ( present( cal ) ) then
1075 calp => cal
1076 else
1077 calp => default_cal
1078 if ( .not. calp % initialized ) call default_cal_set
1079 end if
1080
1081 ! 初期設定のチェック
1082 ! Check initialization
1083 !
1084!!$ if ( .not. datep % initialized ) then
1085!!$ stat = DC_ENOTINIT
1086!!$ cause_c = 'DC_CAL_DATE'
1087!!$ goto 999
1088!!$ end if
1089
1090 if ( .not. calp % initialized ) then
1091 stat = dc_enotinit
1092 cause_c = 'DC_CAL'
1093 goto 999
1094 end if
1095
1096 ! 各要素への値の参照
1097 ! Refer elements
1098 !
1099 year2 = year1
1100 month2 = month1
1101 day2 = day1
1102 hour2 = hour1
1103 min2 = min1
1104 sec2 = sec1
1105
1106 ! 経過時間(秒)の追加
1107 ! Add elapsed time (seconds)
1108 !
1109!!$ if ( elapse_time < 0.0_DP ) then
1110!!$ stat = DC_ENEGATIVE
1111!!$ cause_c = 'elapse_time'
1112!!$ goto 999
1113!!$ end if
1114
1115 tusym = dccaldate_str2usym(units)
1116 select case(tusym)
1117 case(unit_symbol_day)
1118 sec2 = sec2 + elapse_time * calp % hour_in_day &
1119 & * calp % min_in_hour &
1120 & * calp % sec_in_min
1121 case(unit_symbol_hour)
1122 sec2 = sec2 + elapse_time * calp % min_in_hour &
1123 & * calp % sec_in_min
1124 case(unit_symbol_min)
1125 sec2 = sec2 + elapse_time * calp % sec_in_min
1126 case(unit_symbol_sec)
1127 sec2 = sec2 + elapse_time
1128 case default
1129 cause_c = units
1130 call messagenotify('W', subname, 'units=<%c> is invalid. (ONLY day,hour,min,sec are valid)', &
1131 & c1 = trim(units) )
1132 stat = dc_ebadunit
1133 goto 999
1134 end select
1135
1136 ! 日時の正規化
1137 ! Normalize date and time
1138 !
1139 stat = dccaldate_normalize( year2, month2, day2, hour2, min2, sec2, & ! (inout)
1140 & calp ) ! (in)
1141 if ( stat == dc_einconsistcaldate ) then
1142 e_cal_str = dccaltochar( calp )
1143 e_date_str = dccaldatetochar( year2, month2, day2, hour2, min2, sec2, zone = "" )
1144 call messagenotify('W', subname, 'cal=<%c> and date=<%c> are inconsistency', &
1145 & c1 = trim(e_cal_str), c2 = trim(e_date_str) )
1146 goto 999
1147 end if
1148
1149 ! 終了処理, 例外処理
1150 ! Termination and Exception handling
1151 !
1152999 continue
1153 nullify( calp )
1154 call storeerror( stat, subname, err, cause_c )
1155 call endsub( subname )
1156end subroutine dccaldateevalym2ym2
1157
1158!-----------------------------------------------------------
1159
1160!> @en
1161!> @brief Evaluate second of year
1162!> @details
1163!> Evaluate second of year.
1164!>
1165!> If an optional argument `date` is omitted,
1166!> information of date that is stored in the "dc_calendar"
1167!> is used as date of origin.
1168!> If `date` is not omitted, information of the variable is used as
1169!> date of origin.
1170!>
1171!> If an optional argument `cal` is omitted,
1172!> information of calendar that is stored in the "dc_calendar"
1173!> is used for conversion of elapsed seconds `elapse_sec` into
1174!> year-month-day etc.
1175!> If `cal` is not omitted, information of the variable is used.
1176!>
1177!> @param[in] elapse_sec Elapsed seconds from `date`
1178!> @param[in] date An object that stores information of date of origin
1179!> @param[in] cal An object that stores information of calendar
1180!> @return Second of year
1181!> @enden
1182!>
1183!> @ja
1184!> @brief 年始めからの通秒を算出
1185!> @details
1186!> 年始めからの通秒を算出します.
1187!>
1188!> 省略可能引数 `date` が省略された場合には, dc_calendar 内部で
1189!> 保持される日時が起点の日時として用いられます.
1190!> `date` が省略されない場合にはその変数に設定された日時が
1191!> 起点の日時として用いられます.
1192!>
1193!> 省略可能引数 `cal` が省略された場合には, 経過秒数 `elapse_sec`
1194!> の年月日時分への変換に dc_calendar 内部で保持される暦が用いられます.
1195!> `cal` が省略されない場合にはその変数に設定された暦が用いられます.
1196!>
1197!> @param[in] elapse_sec `date` からの経過秒数
1198!> @param[in] date 起点となる日時情報を収めたオブジェクト
1199!> @param[in] cal 暦情報を収めたオブジェクト
1200!> @return 年始めからの通秒
1201!> @endja
1202function dccaldateevalsecofyear1( elapse_sec, date, cal ) result(result)
1207 use dc_types, only: dp
1208 implicit none
1209 real(dp), intent(in):: elapse_sec
1210 type(dc_cal_date), intent(in), optional, target:: date
1211 type(dc_cal), intent(in), optional, target:: cal
1212 real(dp):: result
1213
1214 ! 作業変数
1215 ! Work variables
1216 !
1217 real(dp):: day_of_year
1218 type(dc_cal_date), pointer:: datep =>null()
1219 type(dc_cal), pointer:: calp =>null()
1220 integer:: year, month, day, hour, min
1221 integer:: stat
1222 real(dp):: sec
1223continue
1224
1225 ! オブジェクトのポインタ割付
1226 ! Associate pointer of an object
1227 !
1228 if ( present( date ) ) then
1229 datep => date
1230 else
1231 datep => default_date
1232 end if
1233
1234 if ( present( cal ) ) then
1235 calp => cal
1236 else
1237 calp => default_cal
1238 if ( .not. calp % initialized ) call default_cal_set
1239 end if
1240
1241 ! 初期設定のチェック
1242 ! Check initialization
1243 !
1244 result = 0.0
1245 if ( .not. datep % initialized ) return
1246 if ( .not. calp % initialized ) return
1247
1248 ! 経過時間を与えた場合の日時を取得
1249 ! Inquire date and time when elapse time is given
1250 !
1251 call dccaldateinquire( year, month, day, hour, min, sec, & ! (out)
1252 & elapse_sec = elapse_sec, date = date , cal = calp ) ! (in)
1253
1254 ! 年初めからの通日を取得
1255 ! Day of year is inquire
1256 !
1257 stat = dccaldate_ym2d( year, month, day, calp, & ! (in)
1258 & day_of_year ) ! (out)
1259 if ( stat /= 0 ) return
1260
1261 ! 通秒へ変換
1262 ! Convert into sec of year
1263 !
1264 result = ( day_of_year - 1 ) * calp % hour_in_day &
1265 & * calp % min_in_hour &
1266 & * calp % sec_in_min &
1267 & + hour * calp % min_in_hour &
1268 & * calp % sec_in_min &
1269 & + min * calp % sec_in_min &
1270 & + sec
1271
1272end function dccaldateevalsecofyear1
1273
1274!-----------------------------------------------------------
1275
1276!> @en
1277!> @brief Evaluate day of year
1278!> @details
1279!> Evaluate day of year.
1280!>
1281!> If an optional argument `date` is omitted,
1282!> information of date that is stored in the "dc_calendar"
1283!> is used as date of origin.
1284!> If `date` is not omitted, information of the variable is used as
1285!> date of origin.
1286!>
1287!> If an optional argument `cal` is omitted,
1288!> information of calendar that is stored in the "dc_calendar"
1289!> is used for conversion of elapsed seconds `elapse_sec` into
1290!> year-month-day etc.
1291!> If `cal` is not omitted, information of the variable is used.
1292!>
1293!> @param[in] elapse_sec Elapsed seconds from `date`
1294!> @param[in] date An object that stores information of date of origin
1295!> @param[in] cal An object that stores information of calendar
1296!> @return Day of year
1297!> @enden
1298!>
1299!> @ja
1300!> @brief 年始めからの通日を算出
1301!> @details
1302!> 年始めからの通日を算出します.
1303!>
1304!> 省略可能引数 `date` が省略された場合には, dc_calendar 内部で
1305!> 保持される日時が起点の日時として用いられます.
1306!> `date` が省略されない場合にはその変数に設定された日時が
1307!> 起点の日時として用いられます.
1308!>
1309!> 省略可能引数 `cal` が省略された場合には, 経過秒数 `elapse_sec`
1310!> の年月日時分への変換に dc_calendar 内部で保持される暦が用いられます.
1311!> `cal` が省略されない場合にはその変数に設定された暦が用いられます.
1312!>
1313!> @param[in] elapse_sec `date` からの経過秒数
1314!> @param[in] date 起点となる日時情報を収めたオブジェクト
1315!> @param[in] cal 暦情報を収めたオブジェクト
1316!> @return 年始めからの通日
1317!> @endja
1318function dccaldateevaldayofyear1( elapse_sec, date, cal ) result(result)
1323 use dc_types, only: dp
1324 implicit none
1325 real(dp), intent(in):: elapse_sec
1326 type(dc_cal_date), intent(in), optional, target:: date
1327 type(dc_cal), intent(in), optional, target:: cal
1328 real(dp):: result
1329
1330 ! 作業変数
1331 ! Work variables
1332 !
1333 integer:: year, month, day, hour, min
1334 integer:: stat
1335 real(dp):: sec
1336 type(dc_cal_date), pointer:: datep =>null()
1337 type(dc_cal), pointer:: calp =>null()
1338
1339continue
1340
1341 ! オブジェクトのポインタ割付
1342 ! Associate pointer of an object
1343 !
1344 if ( present( date ) ) then
1345 datep => date
1346 else
1347 datep => default_date
1348 end if
1349
1350 if ( present( cal ) ) then
1351 calp => cal
1352 else
1353 calp => default_cal
1354 if ( .not. calp % initialized ) call default_cal_set
1355 end if
1356
1357 ! 初期設定のチェック
1358 ! Check initialization
1359 !
1360 result = 0.0
1361 if ( .not. datep % initialized ) return
1362 if ( .not. calp % initialized ) return
1363
1364 ! 経過時間を与えた場合の日時を取得
1365 ! Inquire date and time when elapse time is given
1366 !
1367 call dccaldateinquire( year, month, day, hour, min, sec, & ! (out)
1368 & elapse_sec = elapse_sec, date = date , cal = calp ) ! (in)
1369
1370 ! 年初めからの通日を取得
1371 ! Day of year is inquire
1372 !
1373 stat = dccaldate_ym2d( year, month, day, calp, & ! (in)
1374 & result ) ! (out)
1375 if ( stat /= 0 ) return
1376
1377end function dccaldateevaldayofyear1
1378
1379!-----------------------------------------------------------
1380
1381!> @en
1382!> @brief Evaluate second of day
1383!> @details
1384!> Evaluate second of day.
1385!>
1386!> If an optional argument `date` is omitted,
1387!> information of date that is stored in the "dc_calendar"
1388!> is used as date of origin.
1389!> If `date` is not omitted, information of the variable is used as
1390!> date of origin.
1391!>
1392!> If an optional argument `cal` is omitted,
1393!> information of calendar that is stored in the "dc_calendar"
1394!> is used for conversion of elapsed seconds `elapse_sec` into
1395!> year-month-day etc.
1396!> If `cal` is not omitted, information of the variable is used.
1397!>
1398!> @param[in] elapse_sec Elapsed seconds from `date`
1399!> @param[in] date An object that stores information of date of origin
1400!> @param[in] cal An object that stores information of calendar
1401!> @return Second of day
1402!> @enden
1403!>
1404!> @ja
1405!> @brief 日始めからの通秒を算出
1406!> @details
1407!> 日始めからの通秒を算出します.
1408!>
1409!> 省略可能引数 `date` が省略された場合には, dc_calendar 内部で
1410!> 保持される日時が起点の日時として用いられます.
1411!> `date` が省略されない場合にはその変数に設定された日時が
1412!> 起点の日時として用いられます.
1413!>
1414!> 省略可能引数 `cal` が省略された場合には, 経過秒数 `elapse_sec`
1415!> の年月日時分への変換に dc_calendar 内部で保持される暦が用いられます.
1416!> `cal` が省略されない場合にはその変数に設定された暦が用いられます.
1417!>
1418!> @param[in] elapse_sec `date` からの経過秒数
1419!> @param[in] date 起点となる日時情報を収めたオブジェクト
1420!> @param[in] cal 暦情報を収めたオブジェクト
1421!> @return 日始めからの通秒
1422!> @endja
1423function dccaldateevalsecofday1( elapse_sec, date, cal ) result(result)
1428 use dc_types, only: dp
1429 implicit none
1430 real(dp), intent(in):: elapse_sec
1431 type(dc_cal_date), intent(in), optional, target:: date
1432 type(dc_cal), intent(in), optional, target:: cal
1433 real(dp):: result
1434
1435 ! 作業変数
1436 ! Work variables
1437 !
1438 type(dc_cal_date), pointer:: datep =>null()
1439 type(dc_cal), pointer:: calp =>null()
1440 integer:: year, month, day, hour, min
1441 real(dp):: sec
1442continue
1443
1444 ! オブジェクトのポインタ割付
1445 ! Associate pointer of an object
1446 !
1447 if ( present( date ) ) then
1448 datep => date
1449 else
1450 datep => default_date
1451 end if
1452
1453 if ( present( cal ) ) then
1454 calp => cal
1455 else
1456 calp => default_cal
1457 if ( .not. calp % initialized ) call default_cal_set
1458 end if
1459
1460 ! 初期設定のチェック
1461 ! Check initialization
1462 !
1463 result = 0.0
1464 if ( .not. datep % initialized ) return
1465 if ( .not. calp % initialized ) return
1466
1467 ! 経過時間を与えた場合の日時を取得
1468 ! Inquire date and time when elapse time is given
1469 !
1470 call dccaldateinquire( year, month, day, hour, min, sec, & ! (out)
1471 & elapse_sec = elapse_sec, date = date , cal = calp ) ! (in)
1472
1473 ! 通秒へ変換
1474 ! Convert into sec of year
1475 !
1476 result = &
1477 & hour * calp % min_in_hour &
1478 & * calp % sec_in_min &
1479 & + min * calp % sec_in_min &
1480 & + sec
1481
1482end function dccaldateevalsecofday1
subroutine dccaldateevalymdhms2(year, month, day, hour, min, sec, elapse_time, units, cal, date, err)
real(dp) function dccaldateevaldayofyear1(elapse_sec, date, cal)
subroutine dccaldateevalid2(init_date, elapse_time, units, cal, date, err)
real(dp) function dccaldateevalsecofyear1(elapse_sec, date, cal)
subroutine dccaldateevalymdhms1(year, month, day, hour, min, sec, elapse_sec, cal, date, err)
日時の算出
subroutine dccaldateevalym2ym1(year1, month1, day1, hour1, min1, sec1, elapse_sec, year2, month2, day2, hour2, min2, sec2, cal, err)
subroutine dccaldateevalym2ym2(year1, month1, day1, hour1, min1, sec1, elapse_time, units, year2, month2, day2, hour2, min2, sec2, cal, err)
subroutine dccaldateevalid1(init_date, elapse_sec, cal, date, err)
real(dp) function dccaldateevalsecofday1(elapse_sec, date, cal)
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)
integer function, public dccaldate_ym2d(year, month, day, cal, day_of_year)
subroutine, public default_cal_set
integer function, public dccaldate_str2usym(str)
暦と日時に関する構造データ型と定数
integer, parameter, public unit_symbol_sec
integer, parameter, public unit_symbol_hour
integer, parameter, public unit_symbol_day
integer, parameter, public unit_symbol_min
エラー処理用モジュール
Definition dc_error.f90:454
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:891
integer, parameter, public dc_ebadunit
Definition dc_error.f90:536
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_ebaddate
Definition dc_error.f90:552
integer, parameter, public dc_einconsistcaldate
Definition dc_error.f90:553
メッセージの出力
デバッグ時の追跡用モジュール
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