gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
dccaldatecreate.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!-----------------------------------------------------------------------
21
89subroutine dccaldatecreate1( year, month, day, hour, min, sec, date, zone, err )
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 )
215end subroutine dccaldatecreate1
216
287subroutine dccaldatecreate2( date_str, date, err )
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 )
374end subroutine dccaldatecreate2
subroutine dccaldatecreate2(date_str, date, err)
subroutine dccaldatecreate1(year, month, day, hour, min, sec, date, zone, err)
Date setting procedures.
Interface declarations for dc_calendar procedures.
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:476
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:599
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 dp
Double Precision Real number
Definition dc_types.f90:92
integer, parameter, public string
Character length for string
Definition dc_types.f90:137