gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
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 )

日時の設定手続

Author
Yasuhiro MORIKAWA

このファイルに記載される手続き群は dc_calendar モジュールから提供されます.

個別変数で日時を設定

日時の設定を行います.

YYYY-MM-DDThh:mm:ss.sTZD のような文字列 (YYYY は年, MM は月, DD は日, hh は時, mm は分, ss.s は秒, TZD はタイムゾーン) で指定する場合には 下記の同名のサブルーチンを使用して下さい.

省略可能引数 date が省略された場合には, dc_calendar 内部で 保持される "dc_calendar_types#DC_CAL_DATE" 型の変数に日時が 設定されます. その後の手続きで date を省略した場合には この日時が使用されます. date が省略されない場合にはその変数に日時が設定されます. その日時を使用する場合, 手続きにその "dc_calendar_types#DC_CAL_DATE" 型の変数 を与えてください.

Parameters
[in]year
[in]month
[in]day
[in]hour
[in]min
[in]sec
[out]date日時情報を収めたオブジェクト. 省略した場合には, デフォルトの日時として指定される.
[in]zoneUTC からの時差
[out]err例外処理用フラグ. デフォルトでは, この手続き内でエラーが生じた場合, プログラムは強制終了します. 引数 err が与えられる場合, プログラムは強制終了せず, 代わりに err に .true. が代入されます.

Definition at line 89 of file dccaldatecreate.f90.

90
93 use dc_regex, only: match
94 use dc_message, only: messagenotify
95 use dc_string, only: lchar
96 use dc_trace, only: beginsub, endsub
98 use dc_types, only: string, dp
99 implicit none
100 integer, intent(in):: year
101 integer, intent(in):: month
102 integer, intent(in):: day
103 integer, intent(in):: hour
104 integer, intent(in):: min
105 real(DP), intent(in):: sec
106 type(DC_CAL_DATE), intent(out), optional, target:: date
107 character(*), intent(in), optional:: zone
108 logical, intent(out), optional:: err
109
110 ! 作業変数
111 ! Work variables
112 !
113 type(DC_CAL_DATE), pointer:: datep =>null()
114 integer:: start, length
115 integer:: stat
116 character(STRING):: cause_c
117 character(*), parameter:: version = &
118 & '$Name: $' // &
119 & '$Id: dccaldatecreate.f90,v 1.3 2010-09-24 07:07:31 morikawa Exp $'
120 character(*), parameter:: subname = 'DCCalDateCreate1'
121continue
122 call beginsub( subname, version )
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!!$ ! 初期設定のチェック
136!!$ ! Check initialization
137!!$ !
138!!$ if ( datep % initialized ) then
139!!$ stat = DC_EALREADYINIT
140!!$ cause_c = 'DC_CAL_DATE'
141!!$ goto 999
142!!$ end if
143
144 ! 日時の正当性のチェック
145 ! Validate date and time
146 !
147!!$ if ( year < 1 ) then
148!!$ stat = DC_EBADDATE
149!!$ call MessageNotify('W', subname, 'year=<%d> must be natural number', &
150!!$ & i = (/ year /) )
151!!$ goto 999
152!!$ end if
153
154 if ( month < 1 ) then
155 stat = dc_ebaddate
156 call messagenotify('W', subname, 'month=<%d> must be natural number', &
157 & i = (/ month /) )
158 goto 999
159 end if
160
161 if ( day < 1 ) then
162 stat = dc_ebaddate
163 call messagenotify('W', subname, 'day=<%d> must be natural number', &
164 & i = (/ day /) )
165 goto 999
166 end if
167
168 if ( hour < 0 ) then
169 stat = dc_ebaddate
170 call messagenotify('W', subname, 'hour=<%d> must not be negative', &
171 & i = (/ hour /) )
172 goto 999
173 end if
174
175 if ( min < 0 ) then
176 stat = dc_ebaddate
177 call messagenotify('W', subname, 'min=<%d> must not be negative', &
178 & i = (/ min /) )
179 goto 999
180 end if
181
182 if ( sec < 0.0_dp ) then
183 stat = dc_ebaddate
184 call messagenotify('W', subname, 'sec=<%f> must not be negative', &
185 & d = (/ sec /) )
186 goto 999
187 end if
188
189 call match( '^[#+-]#d+:#d+$', zone, & ! (in)
190 & start, length ) ! (out)
191 if ( length > 0 ) then
192 datep % zone = zone
193 else
194 datep % zone = ''
195 end if
196
197 ! 各要素への値の設定
198 ! Configure elements
199 !
200 datep % year = year
201 datep % month = month
202 datep % day = day
203 datep % hour = hour
204 datep % min = min
205 datep % sec = sec
206
207 ! 終了処理, 例外処理
208 ! Termination and Exception handling
209 !
210 datep % initialized = .true.
211999 continue
212 nullify( datep )
213 call storeerror( stat, subname, err, cause_c )
214 call endsub( subname )
dc_calendar用の内部モジュール
type(dc_cal_date), target, save, public default_date
デフォルトの日時. DCCalDate で始まる手続のうち, DC_CAL_DATE 型の省略可能引数が 与えられない場合にはこの日時が設定もしくは利用される.
暦と日時に関する構造データ型と定数
エラー処理用モジュール
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
エラー等を保持
Definition dc_error.f90:468
integer, parameter, public dc_ebaddate
Definition dc_error.f90:552
メッセージの出力
シンプルな正規表現関数 'match' を提供します.
Definition dc_regex.f90:62
subroutine, public match(pattern, text, start, length)
Definition dc_regex.f90:469
文字型変数の操作
Definition dc_string.f90:83
デバッグ時の追跡用モジュール
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 string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:137
integer, parameter, public dp
倍精度実数型変数
Definition dc_types.f90:92

References dc_trace::beginsub(), dc_error::dc_ebaddate, dc_error::dc_noerr, dc_calendar_internal::default_date, dc_types::dp, dc_trace::endsub(), 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 )

日時文字列で日時を設定

日時の設定を行います.

date_str に YYYY-MM-DDThh:mm:ss.sTZD の形式の文字列 (YYYY は年, MM は月, DD は日, hh は時, mm は分, ss.s は秒, TZD はタイムゾーン) を指定してください. 年月日時分秒を各個変数で指定する場合には 上記の同名のサブルーチンを使用して下さい. 日時の文字列形式は gtool4 netCDF 規約「5.5 日時形式」に準拠しています.

"s since 2009-06-17T11:23:45+09:00" のような文字列を与えた場合には, "s since " の部分をサブルーチン内で自動的に切り取って, "2009-06-17T11:23:45+09:00" の部分を設定します.

省略可能引数 date が省略された場合には, dc_calendar 内部で 保持される "dc_calendar_types#DC_CAL_DATE" 型の変数に日時が 設定されます. その後の手続きで date を省略した場合には この日時が使用されます. date が省略されない場合にはその変数に日時が設定されます. その日時を使用する場合, 手続きにその "dc_calendar_types#DC_CAL_DATE" 型の変数 を与えてください.

Parameters
[in]date_str日時情報を表す文字列. 表示形式については gtool4 netCDF 規約 5.5 日時形式を参照のこと.
[out]date日時情報を収めたオブジェクト. 省略した場合には, デフォルトの日時として指定される.
[out]err例外処理用フラグ. デフォルトでは, この手続き内でエラーが生じた場合, プログラムは強制終了します. 引数 err が与えられる場合, プログラムは強制終了せず, 代わりに err に .true. が代入されます.

Definition at line 287 of file dccaldatecreate.f90.

291 use dc_message, only: messagenotify
292 use dc_types, only: dp, token
293 use dc_trace, only: beginsub, endsub
295 use dc_types, only: string
296 implicit none
297 character(*), intent(in):: date_str
298 type(DC_CAL_DATE), intent(out), optional, target:: date
299 logical, intent(out), optional:: err
300
301 ! 作業変数
302 ! Work variables
303 !
304 type(DC_CAL_DATE), pointer:: datep =>null()
305 integer:: year
306 integer:: month
307 integer:: day
308 integer:: hour
309 integer:: min
310 real(DP):: sec
311 character(TOKEN):: zone
312 integer:: stat
313 character(STRING):: cause_c
314 character(*), parameter:: version = &
315 & '$Name: $' // &
316 & '$Id: dccaldatecreate.f90,v 1.3 2010-09-24 07:07:31 morikawa Exp $'
317 character(*), parameter:: subname = 'DCCalDateCreate2'
318continue
319 call beginsub( subname, version )
320 stat = dc_noerr
321 cause_c = ''
322
323 ! オブジェクトのポインタ割付
324 ! Associate pointer of an object
325 !
326 if ( present( date ) ) then
327 datep => date
328 else
329 datep => default_date
330 end if
331
332!!$ ! 初期設定のチェック
333!!$ ! Check initialization
334!!$ !
335!!$ if ( datep % initialized ) then
336!!$ stat = DC_EALREADYINIT
337!!$ cause_c = 'DC_CAL_DATE'
338!!$ goto 999
339!!$ end if
340
341 ! 日時を表現した文字列の解釈
342 ! Parse strings that express date and time
343 !
344 call dccaldateparsestr( date_str, & ! (in)
345 & year, month, day, hour, min, sec, zone, & ! (out)
346 & 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 ! Create an object
356 !
357 call dccaldatecreate( &
358 & year, month, day, hour, min, sec, & ! (in)
359 & datep, zone, err = err ) ! (out) optional
360 if ( present(err) ) then
361 if ( err ) then
362 stat = dc_ebaddate
363 goto 999
364 end if
365 end if
366
367 ! 終了処理, 例外処理
368 ! Termination and Exception handling
369 !
370999 continue
371 nullify( datep )
372 call storeerror( stat, subname, err, cause_c )
373 call endsub( subname )
dc_calendar 手続のインターフェース宣言
integer, parameter, public token
単語やキーワードを保持する文字型変数の種別型パラメタ
Definition dc_types.f90:128

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

Here is the call graph for this function: