Loading...
Searching...
No Matches
Functions/Subroutines
dccaldatecreate.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine dccaldatecreate1 (year, month, day, hour, min, sec, date, zone, err)
 
subroutine dccaldatecreate2 (date_str, date, err)
 

Function/Subroutine Documentation

◆ dccaldatecreate1()

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

Definition at line 15 of file dccaldatecreate.f90.

16 !
17 ! 日時の設定を行います.
18 !
19 ! YYYY-MM-DDThh:mm:ss.sTZD のような文字列
20 ! (YYYY は年, MM は月, DD は日, hh は時, mm は分, ss.s は秒,
21 ! TZD はタイムゾーン) で指定する場合には
22 ! 下記の同名のサブルーチンを使用して下さい.
23 !
24 ! 省略可能引数 *date* が省略された場合には, dc_calendar 内部で
25 ! 保持される "dc_calendar_types#DC_CAL_DATE" 型の変数に日時が
26 ! 設定されます. その後の手続きで *date* を省略した場合には
27 ! この日時が使用されます.
28 ! *date* が省略されない場合にはその変数に日時が設定されます.
29 ! その日時を使用する場合, 手続きにその "dc_calendar_types#DC_CAL_DATE" 型の変数
30 ! を与えてください.
31 !
32 ! Set date.
33 !
34 ! If a string like as "YYYY-MM-DDThh:mm:ss.sTZD"
35 ! (YYYY is year, MM is month, DD is day, hh is hour, mm is minute,
36 ! ss.s is second, TZD is time zone) is used,
37 ! use a following homonymous subroutine.
38 !
39 ! If an optional argument *date* is omitted,
40 ! the date setting is stored to a "dc_calendar_types#DC_CAL_DATE"
41 ! variable that is saved in the "dc_calendar".
42 ! When *date* is omitted in subsequent procedures, the internal date
43 ! is used.
44 ! If *date* is not omitted, the settings is stored to the *date*.
45 ! In order to use the date setting, use the "dc_calendar_types#DC_CAL_DATE"
46 ! varieble to subsequent procedures.
47 !
48
49
52 use dc_regex, only: match
53 use dc_message, only: messagenotify
54 use dc_string, only: lchar
55 use dc_trace, only: beginsub, endsub
57 use dc_types, only: string, dp
58 implicit none
59 integer, intent(in):: year ! 年. Year.
60 integer, intent(in):: month ! 月. Month.
61 integer, intent(in):: day ! 日. Day.
62 integer, intent(in):: hour ! 時. Hour.
63 integer, intent(in):: min ! 分. Minute.
64 real(DP), intent(in):: sec ! 秒. Second.
65 type(DC_CAL_DATE), intent(out), optional, target:: date
66 ! 日時情報を収めたオブジェクト.
67 ! 省略した場合には, デフォルトの日時として
68 ! 指定される.
69 !
70 ! An object that stores information of
71 ! date and time.
72 ! If this is omitted, these information is
73 ! set as default date and time.
74 character(*), intent(in), optional:: zone
75 ! UTC からの時差. Time-zone.
76 logical, intent(out), optional:: err
77 ! 例外処理用フラグ.
78 ! デフォルトでは, この手続き内でエラーが
79 ! 生じた場合, プログラムは強制終了します.
80 ! 引数 *err* が与えられる場合,
81 ! プログラムは強制終了せず, 代わりに
82 ! *err* に .true. が代入されます.
83 !
84 ! Exception handling flag.
85 ! By default, when error occur in
86 ! this procedure, the program aborts.
87 ! If this *err* argument is given,
88 ! .true. is substituted to *err* and
89 ! the program does not abort.
90
91
92 ! 作業変数
93 ! Work variables
94 !
95 type(DC_CAL_DATE), pointer:: datep =>null()
96 integer:: start, length
97 integer:: stat
98 character(STRING):: cause_c
99 character(*), parameter:: version = &
100 & '$Name: $' // &
101 & '$Id: dccaldatecreate.f90,v 1.3 2010-09-24 07:07:31 morikawa Exp $'
102 character(*), parameter:: subname = 'DCCalDateCreate1'
103continue
104 call beginsub( subname, version )
105 stat = dc_noerr
106 cause_c = ''
107
108 ! オブジェクトのポインタ割付
109 ! Associate pointer of an object
110 !
111 if ( present( date ) ) then
112 datep => date
113 else
114 datep => default_date
115 end if
116
117!!$ ! 初期設定のチェック
118!!$ ! Check initialization
119!!$ !
120!!$ if ( datep % initialized ) then
121!!$ stat = DC_EALREADYINIT
122!!$ cause_c = 'DC_CAL_DATE'
123!!$ goto 999
124!!$ end if
125
126 ! 日時の正当性のチェック
127 ! Validate date and time
128 !
129!!$ if ( year < 1 ) then
130!!$ stat = DC_EBADDATE
131!!$ call MessageNotify('W', subname, 'year=<%d> must be natural number', &
132!!$ & i = (/ year /) )
133!!$ goto 999
134!!$ end if
135
136 if ( month < 1 ) then
137 stat = dc_ebaddate
138 call messagenotify('W', subname, 'month=<%d> must be natural number', &
139 & i = (/ month /) )
140 goto 999
141 end if
142
143 if ( day < 1 ) then
144 stat = dc_ebaddate
145 call messagenotify('W', subname, 'day=<%d> must be natural number', &
146 & i = (/ day /) )
147 goto 999
148 end if
149
150 if ( hour < 0 ) then
151 stat = dc_ebaddate
152 call messagenotify('W', subname, 'hour=<%d> must not be negative', &
153 & i = (/ hour /) )
154 goto 999
155 end if
156
157 if ( min < 0 ) then
158 stat = dc_ebaddate
159 call messagenotify('W', subname, 'min=<%d> must not be negative', &
160 & i = (/ min /) )
161 goto 999
162 end if
163
164 if ( sec < 0.0_dp ) then
165 stat = dc_ebaddate
166 call messagenotify('W', subname, 'sec=<%f> must not be negative', &
167 & d = (/ sec /) )
168 goto 999
169 end if
170
171 call match( '^[#+-]#d+:#d+$', zone, & ! (in)
172 & start, length ) ! (out)
173 if ( length > 0 ) then
174 datep % zone = zone
175 else
176 datep % zone = ''
177 end if
178
179 ! 各要素への値の設定
180 ! Configure elements
181 !
182 datep % year = year
183 datep % month = month
184 datep % day = day
185 datep % hour = hour
186 datep % min = min
187 datep % sec = sec
188
189 ! 終了処理, 例外処理
190 ! Termination and Exception handling
191 !
192 datep % initialized = .true.
193999 continue
194 nullify( datep )
195 call storeerror( stat, subname, err, cause_c )
196 call endsub( subname )
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
シンプルな正規表現関数 'match' を提供します.
Definition dc_regex.f90:16
subroutine, public match(pattern, text, start, length)
Definition dc_regex.f90:267
種別型パラメタを提供します。
Definition dc_types.f90:49
integer, parameter, public dp
倍精度実数型変数
Definition dc_types.f90:83
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:118

References dc_error::dc_ealreadyinit, dc_error::dc_ebaddate, dc_error::dc_noerr, dc_calendar_internal::default_date, dc_types::dp, dc_regex::match(), dc_error::storeerror(), and dc_types::string.

Here is the call graph for this function:

◆ dccaldatecreate2()

subroutine dccaldatecreate2 ( character(*), intent(in)  date_str,
type(dc_cal_date), intent(out), optional, target  date,
logical, intent(out), optional  err 
)

Definition at line 199 of file dccaldatecreate.f90.

200 !
201 ! 日時の設定を行います.
202 !
203 ! *date_str* に YYYY-MM-DDThh:mm:ss.sTZD の形式の文字列
204 ! (YYYY は年, MM は月, DD は日, hh は時, mm は分, ss.s は秒,
205 ! TZD はタイムゾーン) を指定してください.
206 ! 年月日時分秒を各個変数で指定する場合には
207 ! 上記の同名のサブルーチンを使用して下さい.
208 ! 日時の文字列形式は
209 ! gtool4 netCDF 規約「5.5 日時形式」に準拠しています.
210 !
211 ! "s since 2009-06-17T11:23:45+09:00" のような文字列を与えた場合には,
212 ! "s since " の部分をサブルーチン内で自動的に切り取って,
213 ! "2009-06-17T11:23:45+09:00" の部分を設定します.
214 !
215 ! 省略可能引数 *date* が省略された場合には, dc_calendar 内部で
216 ! 保持される "dc_calendar_types#DC_CAL_DATE" 型の変数に日時が
217 ! 設定されます. その後の手続きで *date* を省略した場合には
218 ! この日時が使用されます.
219 ! *date* が省略されない場合にはその変数に日時が設定されます.
220 ! その日時を使用する場合, 手続きにその "dc_calendar_types#DC_CAL_DATE" 型の変数
221 ! を与えてください.
222 !
223 ! Set date.
224 !
225 ! Specify a string like as "YYYY-MM-DDThh:mm:ss.sTZD"
226 ! (YYYY is year, MM is month, DD is day, hh is hour, mm is minute,
227 ! ss.s is second, TZD is time zone).
228 ! If individual variables (year, month, day, hour, minute, second, zone)
229 ! are used, use a foregoing homonymous subroutine.
230 ! Format of date is conformed to gtool4 netCDF Convention "5.5 Expression of date and time"
231 !
232 ! If a string like as "s since 2009-06-17T11:23:45+09:00" is specified,
233 ! A part "s since " is truncated automatically, and
234 ! a part "2009-06-17T11:23:45+09:00" is set.
235 !
236 ! If an optional argument *date* is omitted,
237 ! the date setting is stored to a "dc_calendar_types#DC_CAL_DATE"
238 ! variable that is saved in the "dc_calendar".
239 ! When *date* is omitted in subsequent procedures, the internal date
240 ! is used.
241 ! If *date* is not omitted, the settings is stored to the *date*.
242 ! In order to use the date setting, use the "dc_calendar_types#DC_CAL_DATE"
243 ! varieble to subsequent procedures.
244 !
248 use dc_message, only: messagenotify
249 use dc_types, only: dp, token
250 use dc_trace, only: beginsub, endsub
252 use dc_types, only: string
253 implicit none
254 character(*), intent(in):: date_str
255 ! 日時情報を表す文字列.
256 ! 表示形式については gtool4 netCDF 規約
257 ! 5.5 日時形式を参照のこと.
258 !
259 ! Strings that express date and time.
260 ! See gtool4 netCDF Convention
261 ! 5.5 Expression of date and time for details.
262 type(DC_CAL_DATE), intent(out), optional, target:: date
263 ! 日時情報を収めたオブジェクト.
264 ! 省略した場合には, デフォルトの日時として
265 ! 指定される.
266 !
267 ! An object that stores information of
268 ! date and time.
269 ! If this is omitted, these information is
270 ! set as default date and time.
271 logical, intent(out), optional:: err
272 ! 例外処理用フラグ.
273 ! デフォルトでは, この手続き内でエラーが
274 ! 生じた場合, プログラムは強制終了します.
275 ! 引数 *err* が与えられる場合,
276 ! プログラムは強制終了せず, 代わりに
277 ! *err* に .true. が代入されます.
278 !
279 ! Exception handling flag.
280 ! By default, when error occur in
281 ! this procedure, the program aborts.
282 ! If this *err* argument is given,
283 ! .true. is substituted to *err* and
284 ! the program does not abort.
285
286
287 ! 作業変数
288 ! Work variables
289 !
290 type(DC_CAL_DATE), pointer:: datep =>null()
291 integer:: year ! 年. Year.
292 integer:: month ! 月. Month.
293 integer:: day ! 日. Day.
294 integer:: hour ! 時. Hour.
295 integer:: min ! 分. Minute.
296 real(DP):: sec ! 秒. Second.
297 character(TOKEN):: zone
298 ! UTC からの時差. Time-zone.
299 integer:: stat
300 character(STRING):: cause_c
301 character(*), parameter:: version = &
302 & '$Name: $' // &
303 & '$Id: dccaldatecreate.f90,v 1.3 2010-09-24 07:07:31 morikawa Exp $'
304 character(*), parameter:: subname = 'DCCalDateCreate2'
305continue
306 call beginsub( subname, version )
307 stat = dc_noerr
308 cause_c = ''
309
310 ! オブジェクトのポインタ割付
311 ! Associate pointer of an object
312 !
313 if ( present( date ) ) then
314 datep => date
315 else
316 datep => default_date
317 end if
318
319!!$ ! 初期設定のチェック
320!!$ ! Check initialization
321!!$ !
322!!$ if ( datep % initialized ) then
323!!$ stat = DC_EALREADYINIT
324!!$ cause_c = 'DC_CAL_DATE'
325!!$ goto 999
326!!$ end if
327
328 ! 日時を表現した文字列の解釈
329 ! Parse strings that express date and time
330 !
331 call dccaldateparsestr( date_str, & ! (in)
332 & year, month, day, hour, min, sec, zone, & ! (out)
333 & err = err ) ! (out) optional
334 if ( present(err) ) then
335 if ( err ) then
336 stat = dc_ebaddate
337 goto 999
338 end if
339 end if
340
341 ! オブジェクトの作成
342 ! Create an object
343 !
344 call dccaldatecreate( &
345 & year, month, day, hour, min, sec, & ! (in)
346 & datep, zone, err = err ) ! (out) optional
347 if ( present(err) ) then
348 if ( err ) then
349 stat = dc_ebaddate
350 goto 999
351 end if
352 end if
353
354 ! 終了処理, 例外処理
355 ! Termination and Exception handling
356 !
357999 continue
358 nullify( datep )
359 call storeerror( stat, subname, err, cause_c )
360 call endsub( subname )
integer, parameter, public token
単語やキーワードを保持する文字型変数の種別型パラメタ
Definition dc_types.f90:109

References dc_error::dc_ealreadyinit, dc_error::dc_ebaddate, dc_error::dc_noerr, dc_calendar_internal::default_date, dc_types::dp, dc_error::storeerror(), dc_types::string, and dc_types::token.

Here is the call graph for this function: