gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
dccaldateinquire.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
94subroutine dccaldateinquire1( year, month, day, hour, min, sec, zone, &
95 & elapse_sec, date, cal, err )
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 )
223end subroutine dccaldateinquire1
224
292subroutine dccaldateinquire2( date_str, elapse_sec, date, cal, err )
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 )
410end subroutine dccaldateinquire2
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)
Interface declarations for dc_calendar procedures.
Internal module for dc_calendar.
integer function, public dccaldate_normalize(year, month, day, hour, min, sec, cal)
type(dc_cal), target, save, public default_cal
Default calendar object
subroutine, public default_cal_set
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_enotinit
-400 or less: DC utilities errors
Definition dc_error.f90:534
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 dp
Double Precision Real number
Definition dc_types.f90:92
integer, parameter, public string
Character length for string
Definition dc_types.f90:137