Loading...
Searching...
No Matches
dccaldatecurrent.f90
Go to the documentation of this file.
1subroutine dccaldatecurrent1( date, err )
2 !
3 ! 実時間を dc_calendar_types#DC_CAL_DATE 型の
4 ! date に返します.
5 ! 実時間は Fortran 90 以降の組み込みサブルーチンである
6 ! date_and_time から得られます.
7 !
8 ! Return actual time +date+ (type "dc_calendar_types#DC_CAL_DATE").
9 ! The actual time is acquired by "date_and_time" that is
10 ! a built-in subroutine of Fortran 90 or more.
11 !
15 use dc_message, only: messagenotify
16 use dc_types, only: dp, token
17 use dc_trace, only: beginsub, endsub
19 use dc_types, only: string
20 implicit none
21 type(dc_cal_date), intent(out):: date
22 ! 実時間の日時情報を収めたオブジェクト.
23 !
24 ! An object that stores information of
25 ! date and time of actual time.
26 logical, intent(out), optional:: err
27 ! 例外処理用フラグ.
28 ! デフォルトでは, この手続き内でエラーが
29 ! 生じた場合, プログラムは強制終了します.
30 ! 引数 *err* が与えられる場合,
31 ! プログラムは強制終了せず, 代わりに
32 ! *err* に .true. が代入されます.
33 !
34 ! Exception handling flag.
35 ! By default, when error occur in
36 ! this procedure, the program aborts.
37 ! If this *err* argument is given,
38 ! .true. is substituted to *err* and
39 ! the program does not abort.
40
41
42 ! 作業変数
43 ! Work variables
44 !
45 integer :: date_time_values(1:8)
46 character(5) :: zone_raw
47
48 integer:: year ! 年. Year.
49 integer:: month ! 月. Month.
50 integer:: day ! 日. Day.
51 integer:: hour ! 時. Hour.
52 integer:: min ! 分. Minute.
53 real(DP):: sec ! 秒. Second.
54 character(TOKEN):: zone
55 ! UTC からの時差. Time-zone.
56 integer:: stat
57 character(STRING):: cause_c
58 character(*), parameter:: subname = 'DCCalDateCurrent1'
59continue
60 call beginsub( subname )
61 stat = dc_noerr
62 cause_c = ''
63
64!!$ ! 初期設定のチェック
65!!$ ! Check initialization
66!!$ !
67!!$ if ( datep % initialized ) then
68!!$ stat = DC_EALREADYINIT
69!!$ cause_c = 'DC_CAL_DATE'
70!!$ goto 999
71!!$ end if
72
73
74 ! date_and_time 組み込みサブルーチンを用いて, 現在
75 ! 時刻と UTC からの時差を取得.
76 !
77 call date_and_time(zone=zone_raw, values=date_time_values)
78 zone = zone_raw(1:3) // ":" // zone_raw(4:5)
79
80
81 ! オブジェクトの作成
82 ! Create an object
83 !
84 call dccaldatecreate( &
85 & date_time_values(1), date_time_values(2), date_time_values(3), & ! (in)
86 & date_time_values(5), date_time_values(6), & ! (in)
87 & real( date_time_values(7), dp ), & ! (in)
88 & date, zone, err = err ) ! (out) optional
89 if ( present(err) ) then
90 if ( err ) then
91 stat = dc_ebaddate
92 goto 999
93 end if
94 end if
95
96 ! 終了処理, 例外処理
97 ! Termination and Exception handling
98 !
99999 continue
100 call storeerror( stat, subname, err, cause_c )
101 call endsub( subname )
102end subroutine dccaldatecurrent1
subroutine dccaldatecurrent1(date, err)
type(dc_cal_date), target, save, public default_date
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:830
integer, parameter, public dc_ealreadyinit
Definition dc_error.f90:558
integer, parameter, public dc_noerr
Definition dc_error.f90:509
integer, parameter, public dc_ebaddate
Definition dc_error.f90:575
種別型パラメタを提供します。
Definition dc_types.f90:49
integer, parameter, public token
単語やキーワードを保持する文字型変数の種別型パラメタ
Definition dc_types.f90:109
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:118
integer, parameter, public dp
倍精度実数型変数
Definition dc_types.f90:83