Loading...
Searching...
No Matches
dc_date_types.f90
Go to the documentation of this file.
1!== 日付・時刻に関する構造データ型
2!== Data types for date and time
3!
4! Authors:: Yasuhiro MORIKAWA, Eizi TOYODA
5! Version:: $Id: dc_date_types.f90,v 1.1 2009-03-20 09:09:53 morikawa Exp $
6! Tag Name:: $Name: $
7! Copyright:: Copyright (C) GFD Dennou Club, 2000-2005. All rights reserved.
8! License:: See COPYRIGHT[link:../../COPYRIGHT]
9
11 !
12 ! <b>Note that Japanese and English are described in parallel.</b>
13 !
14 ! dc_date で用いられる構造体や変数, 定数を定義しているモジュールです.
15 !
16 ! また暦法に関する情報も管理されています.
17 !
18 ! Derived types, variables, parameters for "dc_date" are defined
19 ! in this module.
20 !
21 ! Information of calender are managed too.
22 !
23 !== Derived types List
24 !
25 ! DC_DATETIME :: 通日と通秒の対で日付時刻を表現します.
26 ! DC_DIFFTIME :: X ヶ月後, X 日前, などを表現します.
27 !
28 !== Characters list for unit
29 !
30 ! UNIT_NONDIM :: .
31 ! UNIT_SEC :: .
32 ! UNIT_MIN :: .
33 ! UNIT_HOUR :: .
34 ! UNIT_DAY :: .
35 ! UNIT_MONTH :: .
36 ! UNIT_YEAR :: .
37 !
38 !== Symbols for unit
39 !
40 ! UNIT_SYMBOL_NONDIM :: .
41 ! UNIT_SYMBOL_SEC :: .
42 ! UNIT_SYMBOL_MIN :: .
43 ! UNIT_SYMBOL_HOUR :: .
44 ! UNIT_SYMBOL_DAY :: .
45 ! UNIT_SYMBOL_MONTH :: .
46 ! UNIT_SYMBOL_YEAR :: .
47 ! UNIT_SYMBOL_ERR :: .
48 !
49 !== Parameters for calender
50 !
51 ! CAL_CYCLIC :: .
52 ! CAL_NOLEAP :: .
53 ! CAL_JULIAN :: .
54 ! CAL_GREGORIAN :: .
55 !
56 !== Parameters for conversion of year-month-day-hour-min-sec
57 !
58 ! CYCLIC_MDAYS :: .
59 ! DAY_SECONDS_EARTH :: .
60 ! MIN_SECONDS :: .
61 ! HOUR_SECONDS :: .
62 ! YEAR_MONTHS :: .
63 ! YEAR_DAYS :: .
64 ! FOUR_YEARS :: .
65 ! FOUR_CENTURY :: .
66 ! PREPARED_CALTYPES :: .
67 !
68 !
69 use dc_types, only: dp, string
71
72 implicit none
73
74 private
75 public:: dc_datetime, dc_difftime
79 public:: unit_symbol_err
83 public:: prepared_caltypes
85
86 !-------
87 ! 暦法
88
89 integer, parameter:: cal_cyclic = 1 ! 1 ヵ月を 30.6 日 (CYCLIC_MDAYS)
90 ! とする暦.
91 ! (例: 0 ヶ月目は 1 〜 30 (30.6),
92 ! 1 ヶ月目は 1 〜 31 (61.2),
93 ! 2 ヶ月目は 1 〜 30 (91.8),
94 ! 3 ヶ月目は 1 〜 31 (122.4),
95 ! 4 ヶ月目は 1 〜 31 (153.0) ...)
96 !
97 ! 仮想的な時間で実験を行う
98 ! 場合に使用することを想定してい
99 ! ます.
100 !
101 integer, parameter:: cal_noleap = 2 ! 1 年 365 日の暦
102 !
103 integer, parameter:: cal_julian = 3 ! ユリウス暦
104 !
105 integer, parameter:: cal_gregorian = 4! グレゴリオ暦
106 !
107 integer, parameter:: prepared_caltypes(0:3) = &
108 & (/CAL_CYCLIC, CAL_NOLEAP, CAL_JULIAN, CAL_GREGORIAN/)
109
110 integer, save:: caltype = cal_gregorian ! デフォルトの暦
111
112 !-------
113 ! 日時の単位間の関係
114
115 real(dp), parameter:: cyclic_mdays = 30.6_dp ! CAL_CYCLIC で使用される
116 ! 1 ヶ月の日数.
117 ! また DC_DIFFTIME の
118 ! 1 ヶ月の日数にも
119 ! 使用します.
120
121 integer, parameter:: min_seconds = 60 ! 1 分の秒数
122 integer, parameter:: hour_seconds = 3600 ! 1 時間の秒数
123 real(dp), parameter:: day_seconds_earth = 86400.0_dp
124 ! 地球の 1 日の秒数
126 ! 1 日の秒数
128 ! 1 日の秒数
129 logical, save :: flag_set_day_seconds_scl = .false.
130 ! 1 日の秒数
131 integer, parameter:: year_days = 365 ! 1 年 (非閏年) の日数
132 integer, parameter:: year_months = 12 ! 1 年の月数
133 integer, parameter:: four_years = year_days * 4 + 1
134 ! 4 年の日数
135 integer, parameter:: four_century = year_days * 400 + 97
136 ! 1 世紀の日数
137
138 !-------
139 ! 日時の単位として認識される文字列
140
141 character(*), parameter, dimension(1) :: unit_nondim = (/ &
142 & '1' /) ! 無次元時間の単位を示す文字列
143
144 character(*), parameter, dimension(8) :: unit_sec = (/ &
145 & 'seconds', 'second ', 'secs. ', 'secs ', &
146 & 'sec. ', 'sec ', 's. ', 's '/) ! 秒の単位を示す文字列
147
148 character(*), parameter, dimension(4) :: unit_min = (/ &
149 & 'minutes', 'minute ', 'min. ', 'min '/) ! 分の単位を示す文字列
150 character(*), parameter, dimension(8) :: unit_hour = (/ &
151 & 'hours', 'hour ', 'hrs. ', 'hrs ', &
152 & 'hr. ', 'hr ', 'h. ', 'h '/) ! 時の単位を示す文字列
153 character(*), parameter, dimension(4) :: unit_day = (/ &
154 & 'days', 'day ', 'd. ', 'd '/) ! 日の単位を示す文字列
155 character(*), parameter, dimension(6) :: unit_month = (/ &
156 & 'months', 'month ', 'mon. ', &
157 & 'mon ', 'mo. ', 'mo '/) ! 月の単位を示す文字列
158 character(*), parameter, dimension(4) :: unit_year = (/ &
159 & 'years', 'year ', 'yr. ', 'yr '/) ! 年の単位を示す文字列
160
161 !-------
162 ! 日時の単位のシンボル
163
164 integer, parameter:: unit_symbol_err = -1 ! 無効な単位を示すシンボル
165 integer, parameter:: unit_symbol_nondim = 1 ! 無時限時間の単位を示すシンボル
166 integer, parameter:: unit_symbol_sec = 2 ! 秒の単位を示すシンボル
167 integer, parameter:: unit_symbol_min = 3 ! 分の単位を示すシンボル
168 integer, parameter:: unit_symbol_hour = 4 ! 時間の単位を示すシンボル
169 integer, parameter:: unit_symbol_day = 5 ! 日の単位を示すシンボル
170 integer, parameter:: unit_symbol_month = 6 ! 月の単位を示すシンボル
171 integer, parameter:: unit_symbol_year = 7 ! 年の単位を示すシンボル
172
174 ! 通日と通秒の対で日付時刻を表現します.
175 !
176 ! この構造データ型の変数を使用する際は必ず変数を
177 ! dc_date#Create または dc_date#assignment(=)
178 ! によって初期化してください. また, *day*, *sec* などの内部変数は
179 ! 直接変更しないでください.
180 !
181 ! 利用法は dc_date の "List" および "Usage" を参照してください.
182 !
183 sequence
184 integer :: caltype = cal_gregorian ! 暦法
185 type(dc_scaled_sec):: day ! 日
186 type(dc_scaled_sec):: sec ! 秒
187 logical:: dummy = .false.
188 ! 境界を埋めるためのダミー変数.
189 ! Dummy variable for boundary alignment
190 type(dc_scaled_sec):: day_seconds ! 1 日の秒数
191 character(STRING) :: zone = '+00:00' ! UTC からの時差
192 end type dc_datetime
193
195 ! X ヶ月後, X 日前, などを表現するためのデータ型です.
196 !
197 ! この構造データ型の変数を使用する際は必ず変数を
198 ! dc_date#Create または dc_date#assignment(=)
199 ! によって初期化してください. また, *day*, *sec* などの内部変数は
200 ! 直接変更しないでください.
201 !
202 ! 利用法は dc_date の "List" および "Usage" を参照してください.
203 !
204 ! なお, 1 ヶ月は dc_date_types#CYCLIC_MDAYS と換算します.
205 !
206 !--
207 !== 開発者向け情報
208 !
209 ! 「1ヵ月後」という概念に対応するため、month 欄を持ちます。
210 !
211 ! 注意: 日付と違って月を normalize することはできません。
212 !++
213 sequence
214 type(dc_scaled_sec):: mon ! 月. Month
215 type(dc_scaled_sec):: day ! 日. Day
216 type(dc_scaled_sec):: sec ! 秒 または無次元時間. Seconds or nondimensional time
217 logical:: dummy0 = .false.
218 ! 境界を埋めるためのダミー変数.
219 ! Dummy variable for boundary alignment
220 type(dc_scaled_sec):: day_seconds ! 1 日の秒数
221 ! 1 日の秒数. Seconds of day
222 logical:: nondim_flag = .false.
223 ! 無次元数を示すフラグ.
224 ! Flag for nondimensional number
225 logical:: dummy1 = .false.
226 ! 境界を埋めるためのダミー変数.
227 ! Dummy variable for boundary alignment
228
229!!$ real(DP):: sec_scale_factor
230!!$ ! 1.0 以下の sec が与えられた際に,
231!!$ ! 丸め誤差によって
232!!$ ! sec がずれるのを防ぐためのファクター
233!!$ ! (実験的機能)
234 end type dc_difftime
235
236end module dc_date_types
character(*), dimension(6), parameter, public unit_month
integer, parameter, public unit_symbol_err
integer, parameter, public unit_symbol_hour
integer, parameter, public unit_symbol_min
integer, parameter, public cal_noleap
real(dp), parameter, public cyclic_mdays
integer, parameter, public hour_seconds
integer, parameter, public unit_symbol_month
character(*), dimension(1), parameter, public unit_nondim
integer, parameter, public four_years
integer, parameter, public cal_cyclic
real(dp), save, public day_seconds
integer, save, public caltype
integer, parameter, public unit_symbol_sec
integer, parameter, public unit_symbol_nondim
type(dc_scaled_sec), save, public day_seconds_scl
character(*), dimension(4), parameter, public unit_day
logical, save, public flag_set_day_seconds_scl
integer, parameter, public year_days
integer, parameter, public year_months
integer, parameter, public cal_gregorian
integer, parameter, public four_century
integer, dimension(0:3), parameter, public prepared_caltypes
integer, parameter, public min_seconds
character(*), dimension(8), parameter, public unit_sec
character(*), dimension(8), parameter, public unit_hour
real(dp), parameter, public day_seconds_earth
integer, parameter, public unit_symbol_day
character(*), dimension(4), parameter, public unit_year
integer, parameter, public unit_symbol_year
character(*), dimension(4), parameter, public unit_min
integer, parameter, public cal_julian
種別型パラメタを提供します。
Definition dc_types.f90:49
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:118
integer, parameter, public dp
倍精度実数型変数
Definition dc_types.f90:83