gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
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)
 Date setting procedures.
 
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 
)

Date setting procedures.

Author
Yasuhiro MORIKAWA

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 )
Internal module for dc_calendar.
type(dc_cal_date), target, save, public default_date
Default date object
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.
Provides simple regular expression subroutine: 'match'.
Definition dc_regex.f90:62
subroutine, public match(pattern, text, start, length)
Definition dc_regex.f90:469
Handling character types.
Definition dc_string.f90:83
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 dp
Double Precision Real number
Definition dc_types.f90:92
integer, parameter, public string
Character length for string
Definition dc_types.f90:137

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 
)

Set date with date string

Set date.

Specify a string like as "YYYY-MM-DDThh:mm:ss.sTZD" (YYYY is year, MM is month, DD is day, hh is hour, mm is minute, ss.s is second, TZD is time zone) to date_str. If individual variables (year, month, day, hour, minute, second, zone) are used, use a foregoing homonymous subroutine. Format of date is conformed to gtool4 netCDF Convention "5.5 Expression of date and time"

If a string like as "s since 2009-06-17T11:23:45+09:00" is specified, A part "s since " is truncated automatically, and a part "2009-06-17T11:23:45+09:00" is set.

If an optional argument date is omitted, the date setting is stored to a "dc_calendar_types#DC_CAL_DATE" variable that is saved in the "dc_calendar". When date is omitted in subsequent procedures, the internal date is used. If date is not omitted, the settings is stored to the date. In order to use the date setting, use the "dc_calendar_types#DC_CAL_DATE" variable to subsequent procedures.

Parameters
[in]date_strStrings that express date and time. See gtool4 netCDF Convention 5.5 Expression of date and time for details.
[out]dateAn object that stores information of date and time. If this is omitted, these information is set as default date and time.
[out]errException handling flag. By default, when error occur in this procedure, the program aborts. If this err argument is given, .true. is substituted to err and the program does not abort.

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 )
Interface declarations for dc_calendar procedures.
integer, parameter, public token
Character length for word, 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: