gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
dccaldateinquire.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine dccaldateinquire1 (year, month, day, hour, min, sec, zone, elapse_sec, date, cal, err)
 Inquire information of date.
subroutine dccaldateinquire2 (date_str, elapse_sec, date, cal, err)

Function/Subroutine Documentation

◆ dccaldateinquire1()

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

Inquire information of date.

Author
Yasuhiro MORIKAWA

Procedures described in this file are provided from "dc_calendar" module.

Inquire date information as individual variables

Inquire information of date.

If 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) is needed, use a following homonymous subroutine.

If an optional argument date is omitted, information of date that is stored in the "dc_calendar" is returned, If date is not omitted, information of the variable is returned.

If an optional argument cal is omitted, information of calendar that is stored in the "dc_calendar" is used for conversion of elapsed seconds elapse_sec into year-month-day etc. If cal is not omitted, information of the variable is used.

Parameters
[out]yearYear
[out]monthMonth
[out]dayDay
[out]hourHour
[out]minMinute
[out]secSecond
[out]zoneTime-zone (difference from UTC)
[in]elapse_secElapsed seconds from date
[in]dateAn object that stores information of date and time
[in]calAn object that stores information of calendar
[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 94 of file dccaldateinquire.f90.

96
101 use dc_message, only: messagenotify
102 use dc_string, only: lchar
103 use dc_trace, only: beginsub, endsub
106 use dc_types, only: string, dp, token
107 implicit none
108 integer, intent(out), optional:: year
109 integer, intent(out), optional:: month
110 integer, intent(out), optional:: day
111 integer, intent(out), optional:: hour
112 integer, intent(out), optional:: min
113 real(DP), intent(out), optional:: sec
114 character(*), intent(out), optional:: zone
115 real(DP), intent(in), optional:: elapse_sec
116 type(DC_CAL_DATE), intent(in), optional, target:: date
117 type(DC_CAL), intent(in), optional, target:: cal
118 logical, intent(out), optional:: err
119
120 ! 作業変数
121 ! Work variables
122 !
123 integer:: wyear, wmonth, wday, whour, wmin
124 real(DP):: wsec
125 character(TOKEN):: wzone
126 type(DC_CAL_DATE), pointer:: datep =>null()
127 type(DC_CAL), pointer:: calp =>null()
128 character(STRING):: e_date_str, e_cal_str
129 integer:: stat
130 character(STRING):: cause_c
131 character(*), parameter:: subname = 'DCCalInquire1'
132continue
133 call beginsub( subname )
134 stat = dc_noerr
135 cause_c = ''
136
137 ! オブジェクトのポインタ割付
138 ! Associate pointer of an object
139 !
140 if ( present( date ) ) then
141 datep => date
142 else
143 datep => default_date
144 end if
145
146 if ( present( cal ) ) then
147 calp => cal
148 else
149 calp => default_cal
150 if ( .not. calp % initialized ) call default_cal_set
151 end if
152
153 ! 初期設定のチェック
154 ! Check initialization
155 !
156 if ( .not. datep % initialized ) then
157 stat = dc_enotinit
158 cause_c = 'DC_CAL_DATE'
159 goto 999
160 end if
161
162 if ( .not. calp % initialized ) then
163 stat = dc_enotinit
164 cause_c = 'DC_CAL'
165 goto 999
166 end if
167
168 ! 各要素への値の参照
169 ! Refer elements
170 !
171 wyear = datep % year
172 wmonth = datep % month
173 wday = datep % day
174 whour = datep % hour
175 wmin = datep % min
176 wsec = datep % sec
177 wzone = datep % zone
178
179 ! 経過時間(秒)の追加
180 ! Add elapsed time (seconds)
181 !
182 if ( present( elapse_sec ) ) then
183!!$ if ( elapse_sec < 0.0_DP ) then
184!!$ stat = DC_ENEGATIVE
185!!$ cause_c = 'elapse_sec'
186!!$ goto 999
187!!$ end if
188
189 wsec = wsec + elapse_sec
190 end if
191
192 ! 日時の正規化
193 ! Normalize date and time
194 !
195 stat = dccaldate_normalize( wyear, wmonth, wday, whour, wmin, wsec, & ! (inout)
196 & calp ) ! (in)
197 if ( stat == dc_einconsistcaldate ) then
198 e_cal_str = dccaltochar( calp )
199 e_date_str = dccaldatetochar( wyear, wmonth, wday, whour, wmin, wsec, wzone )
200 call messagenotify('W', subname, 'cal=<%c> and date=<%c> are inconsistency', &
201 & c1 = trim(e_cal_str), c2 = trim(e_date_str) )
202 goto 999
203 end if
204
205 ! 引数への代入
206 ! Substitute arguments
207 !
208 if ( present(year ) ) year = wyear
209 if ( present(month) ) month = wmonth
210 if ( present(day ) ) day = wday
211 if ( present(hour ) ) hour = whour
212 if ( present(min ) ) min = wmin
213 if ( present(sec ) ) sec = wsec
214 if ( present(zone ) ) zone = wzone
215
216 ! 終了処理, 例外処理
217 ! Termination and Exception handling
218 !
219999 continue
220 nullify( calp, datep )
221 call storeerror( stat, subname, err, cause_c )
222 call endsub( subname )
Interface declarations for dc_calendar procedures.
Internal module for dc_calendar.
type(dc_cal), target, save, public default_cal
Default calendar object
type(dc_cal_date), target, save, public default_date
Default date object
integer function, public dccaldate_normalize(year, month, day, hour, min, sec, cal)
subroutine, public default_cal_set
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_enotinit
-400 or less: DC utilities errors
Definition dc_error.f90:534
integer, parameter, public dc_noerr
Error storage variables
Definition dc_error.f90:468
integer, parameter, public dc_einconsistcaldate
Definition dc_error.f90:553
Message output module.
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 string
Character length for string
Definition dc_types.f90:137
integer, parameter, public dp
Double Precision Real number
Definition dc_types.f90:92

References dc_trace::beginsub(), dc_error::dc_einconsistcaldate, dc_error::dc_enotinit, dc_error::dc_noerr, dc_calendar_internal::dccaldate_normalize(), dc_calendar_internal::default_cal, dc_calendar_internal::default_cal_set(), 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:

◆ dccaldateinquire2()

subroutine dccaldateinquire2 ( character(*), intent(out) date_str,
real(dp), intent(in), optional elapse_sec,
type(dc_cal_date), intent(in), optional, target date,
type(dc_cal), intent(in), optional, target cal,
logical, intent(out), optional err )

Inquire date information as a string

Inquire information of date. A result is returned as 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). Format of date is conformed to gtool4 netCDF Convention "5.5 Expression of date and time"

If individual variables (year, month, day, hour, minute, second, zone) are needed, use a foregoing homonymous subroutine.

If an optional argument date is omitted, information of date that is stored in the "dc_calendar" is returned, If date is not omitted, information of the variable is returned.

If an optional argument cal is omitted, information of calendar that is stored in the "dc_calendar" is used for conversion of elapsed seconds elapse_sec into year-month-day etc. If cal is not omitted, information of the variable is used.

Parameters
[out]date_strStrings that express date and time. See gtool4 netCDF Convention 5.5 Expression of date and time for details.
[in]elapse_secElapsed seconds from date
[in]dateAn object that stores information of date and time
[in]calAn object that stores information of calendar
[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 292 of file dccaldateinquire.f90.

293
299 use dc_message, only: messagenotify
300 use dc_string, only: lchar
301 use dc_trace, only: beginsub, endsub
304 use dc_types, only: string, dp, token
305 implicit none
306 character(*), intent(out):: date_str
307 real(DP), intent(in), optional:: elapse_sec
308 type(DC_CAL_DATE), intent(in), optional, target:: date
309 type(DC_CAL), intent(in), optional, target:: cal
310 logical, intent(out), optional:: err
311
312 ! 作業変数
313 ! Work variables
314 !
315 integer:: year, month, day, hour, min
316 real(DP):: sec
317 character(TOKEN):: zone
318 type(DC_CAL_DATE), pointer:: datep =>null()
319 type(DC_CAL), pointer:: calp =>null()
320 character(STRING):: e_date_str, e_cal_str
321 integer:: stat
322 character(STRING):: cause_c
323 character(*), parameter:: subname = 'DCCalInquire2'
324continue
325 call beginsub( subname )
326 stat = dc_noerr
327 cause_c = ''
328
329 ! オブジェクトのポインタ割付
330 ! Associate pointer of an object
331 !
332 if ( present( date ) ) then
333 datep => date
334 else
335 datep => default_date
336 end if
337
338 if ( present( cal ) ) then
339 calp => cal
340 else
341 calp => default_cal
342 if ( .not. calp % initialized ) call default_cal_set
343 end if
344
345 ! 初期設定のチェック
346 ! Check initialization
347 !
348 if ( .not. datep % initialized ) then
349 stat = dc_enotinit
350 cause_c = 'DC_CAL_DATE'
351 goto 999
352 end if
353
354 if ( .not. calp % initialized ) then
355 stat = dc_enotinit
356 cause_c = 'DC_CAL'
357 goto 999
358 end if
359
360 ! 各要素の取得
361 ! Get elements
362 !
363 year = datep % year
364 month = datep % month
365 day = datep % day
366 hour = datep % hour
367 min = datep % min
368 sec = datep % sec
369 zone = datep % zone
370
371
372 ! 経過時間(秒)の追加
373 ! Add elapsed time (seconds)
374 !
375 if ( present( elapse_sec ) ) then
376!!$ if ( elapse_sec < 0.0_DP ) then
377!!$ stat = DC_ENEGATIVE
378!!$ cause_c = 'elapse_sec'
379!!$ goto 999
380!!$ end if
381
382 sec = sec + elapse_sec
383 end if
384
385 ! 日時の正規化
386 ! Normalize date and time
387 !
388 stat = dccaldate_normalize( year, month, day, hour, min, sec, & ! (inout)
389 & calp ) ! (in)
390 if ( stat == dc_einconsistcaldate ) then
391 e_cal_str = dccaltochar( calp )
392 e_date_str = dccaldatetochar( year, month, day, hour, min, sec, zone )
393 call messagenotify('W', subname, 'cal=<%c> and date=<%c> are inconsistency', &
394 & c1 = trim(e_cal_str), c2 = trim(e_date_str) )
395 goto 999
396 end if
397
398 ! 日時表記(gtool4 netCDF 規約 5.5 日時形式)への変換
399 ! Convert expression of date (gtool4 netCDF Convention 5.5 Expression of date and time)
400 !
401 date_str = dccaldatetochar( year, month, day, hour, min, sec, zone )
402
403 ! 終了処理, 例外処理
404 ! Termination and Exception handling
405 !
406999 continue
407 nullify( calp, datep )
408 call storeerror( stat, subname, err, cause_c )
409 call endsub( subname )

References dc_trace::beginsub(), dc_error::dc_einconsistcaldate, dc_error::dc_enotinit, dc_error::dc_noerr, dc_calendar_internal::dccaldate_normalize(), dc_calendar_internal::default_cal, dc_calendar_internal::default_cal_set(), 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: