gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
dccaldatecurrent.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 Get current date and time
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 Get current actual time
24!> @details
25!> Return actual time `date` (type "dc_calendar_types#DC_CAL_DATE").
26!> The actual time is acquired by "date_and_time" that is
27!> a built-in subroutine of Fortran 90 or more.
28!>
29!> @param[out] date An object that stores information of date and time of actual time.
30!> @param[out] err Exception handling flag.
31!> By default, when error occur in this procedure, the program aborts.
32!> If this `err` argument is given, .true. is substituted to `err` and
33!> the program does not abort.
34!> @enden
35!>
36!> @ja
37!> @brief 実時間の現在日時を取得
38!> @details
39!> 実時間を dc_calendar_types#DC_CAL_DATE 型の
40!> date に返します.
41!> 実時間は Fortran 90 以降の組み込みサブルーチンである
42!> date_and_time から得られます.
43!>
44!> @param[out] date 実時間の日時情報を収めたオブジェクト.
45!> @param[out] err 例外処理用フラグ.
46!> デフォルトでは, この手続き内でエラーが生じた場合,
47!> プログラムは強制終了します.
48!> 引数 `err` が与えられる場合, プログラムは強制終了せず,
49!> 代わりに `err` に .true. が代入されます.
50!> @endja
51subroutine dccaldatecurrent1( date, err )
54 use dc_message, only: messagenotify
55 use dc_types, only: dp, token
56 use dc_trace, only: beginsub, endsub
58 use dc_types, only: string
59 implicit none
60 type(dc_cal_date), intent(out):: date
61 logical, intent(out), optional:: err
62
63 ! 作業変数
64 ! Work variables
65 !
66 integer :: date_time_values(1:8)
67 character(5) :: zone_raw
68
69 character(TOKEN):: zone
70 integer:: stat
71 character(STRING):: cause_c
72 character(*), parameter:: subname = 'DCCalDateCurrent1'
73continue
74 call beginsub( subname )
75 stat = dc_noerr
76 cause_c = ''
77
78!!$ ! 初期設定のチェック
79!!$ ! Check initialization
80!!$ !
81!!$ if ( datep % initialized ) then
82!!$ stat = DC_EALREADYINIT
83!!$ cause_c = 'DC_CAL_DATE'
84!!$ goto 999
85!!$ end if
86
87
88 ! date_and_time 組み込みサブルーチンを用いて, 現在
89 ! 時刻と UTC からの時差を取得.
90 !
91 call date_and_time(zone=zone_raw, values=date_time_values)
92 zone = zone_raw(1:3) // ":" // zone_raw(4:5)
93
94
95 ! オブジェクトの作成
96 ! Create an object
97 !
98 call dccaldatecreate( &
99 & date_time_values(1), date_time_values(2), date_time_values(3), & ! (in)
100 & date_time_values(5), date_time_values(6), & ! (in)
101 & real( date_time_values(7), dp ), & ! (in)
102 & date, zone, err = err ) ! (out) optional
103 if ( present(err) ) then
104 if ( err ) then
105 stat = dc_ebaddate
106 goto 999
107 end if
108 end if
109
110 ! 終了処理, 例外処理
111 ! Termination and Exception handling
112 !
113999 continue
114 call storeerror( stat, subname, err, cause_c )
115 call endsub( subname )
116end subroutine dccaldatecurrent1
subroutine dccaldatecurrent1(date, err)
Get current date and time.
Interface declarations for dc_calendar procedures.
Derived types and parameters of calendar and date.
Error handling module.
Definition dc_error.f90:454
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:891
integer, parameter, public dc_noerr
Error storage variables
Definition dc_error.f90:468
integer, parameter, public dc_ebaddate
Definition dc_error.f90:552
Message output module.
Debug tracing module.
Definition dc_trace.f90:150
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
Definition dc_trace.f90:457
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:580
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public token
Character length for word, token
Definition dc_types.f90:128
integer, parameter, public string
Character length for string
Definition dc_types.f90:137
integer, parameter, public dp
Double Precision Real number
Definition dc_types.f90:92