gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
dcdatetimecreate.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine dcdatetimecreate1 (time, year, mon, day, hour, min, sec, zone, zone_hour, zone_min, caltype, caltype_str, day_seconds, sclyear, sclmon, sclday, sclsec, err)
 dc_date_types#DC_DATETIME, dc_date_types#DC_DIFFTIME 型変数の生成
subroutine get_current_time (jyear, jmon, jday, jsec, jzone)
subroutine dcdifftimecreate1 (diff, year, mon, day, hour, min, sec, day_seconds, nondim, sclyear, sclmon, sclday, sclsec)
subroutine dcdifftimecreate2d (diff, value, unit, unit_symbol, err)
subroutine dcdifftimecreate2r (diff, value, unit, unit_symbol, err)
subroutine dcdifftimecreate2i (diff, value, unit, unit_symbol, err)
subroutine dcdatetimecreatei (time, sec)
subroutine dcdatetimecreater (time, sec)
subroutine dcdatetimecreated (time, sec)
subroutine dcdifftimecreatei (diff, sec)
subroutine dcdifftimecreater (diff, sec)
subroutine dcdifftimecreated (diff, sec)
subroutine dcdatetimecreate1_bc (time, year, mon, day, hour, min, sec, zone, caltype, day_seconds, err)
subroutine dcdifftimecreate1_bc (diff, year, mon, day, hour, min, sec, day_seconds)
subroutine dcdifftimecreate2_bc (diff, value, unit, err)

Function/Subroutine Documentation

◆ dcdatetimecreate1()

subroutine dcdatetimecreate1 ( type(dc_datetime), intent(out) time,
integer, intent(in), optional year,
integer, intent(in), optional mon,
integer, intent(in), optional day,
integer, intent(in), optional hour,
integer, intent(in), optional min,
real(dp), intent(in), optional sec,
character(*), intent(in), optional zone,
integer, intent(in), optional zone_hour,
integer, intent(in), optional zone_min,
integer, intent(in), optional caltype,
character(*), intent(in), optional caltype_str,
real(dp), intent(in), optional day_seconds,
type(dc_scaled_sec), intent(in), optional sclyear,
type(dc_scaled_sec), intent(in), optional sclmon,
type(dc_scaled_sec), intent(in), optional sclday,
type(dc_scaled_sec), intent(in), optional sclsec,
logical, intent(out), optional err )

dc_date_types#DC_DATETIME, dc_date_types#DC_DIFFTIME 型変数の生成

Author
Yasuhiro MORIKAWA, Eizi TOYODA

このファイルで提供される手続き群は dc_date モジュールにて提供されます.

DC_DATETIME 型変数を生成

dc_date_types#DC_DATETIME 型変数の生成を行います. 引数 year, mon, day, hour, min, sec の全てを与えない場合, このサブルーチンが呼ばれた際の時刻が使用されます.

引数 caltype には暦法を設定します. dc_date_types#CAL_CYCLIC, dc_date_types#CAL_NOLEAP, dc_date_types#CAL_JULIAN, dc_date_types#CAL_GREGORIAN のいづれかを与えてください. 引数 caltype を指定しない場合, 暦法は dc_date_types#CAL_GREGORIAN に設定されます. 暦法は caltype_str に文字列を与えることでも指定可能です. 上記の暦法に対応する文字列は以下の通りです. (大文字小文字は区別しません)

caltype caltype_str
dc_date_types#CAL_CYCLIC cyclic
dc_date_types#CAL_NOLEAP noleap
dc_date_types#CAL_JULIAN julian
dc_date_types#CAL_GREGORIAN gregorian

引数 zone には UTC からの時差を設定します. '+09:00' や '-13:00' のように時差を 6 文字で指定してください. 引数 zone を指定しない場合, date_and_time 組み込みサブルーチン によって得られる時差を設定します. 時差は zone_hour または zone_min に整数型を与えることでも 指定可能です.

引数 day_seconds には 1 日何秒かを設定します. この引数を 指定しない場合, dc_date_types::day_seconds の値が用いられます. dc_date_types::day_seconds は SetSecOfDay で変更可能です.

引数 caltype および, zone に不適切な値が与えられた場合, エラーを発生させます. 引数 err を与えている場合には err に .true. が返り, プログラムは続行します.

Parameters
[out]time生成される DC_DATETIME 変数
[in]year
[in]mon
[in]day
[in]hour
[in]min
[in]sec
[in]zoneUTC からの時差
[in]zone_hourUTC からの時差 (時)
[in]zone_minUTC からの時差 (分)
[in]caltype暦法
[in]caltype_str暦法 (文字型による指定)
[in]day_seconds1 日の秒数
[in]sclyear年 (DC_SCALED_SEC 型)
[in]sclmon月 (DC_SCALED_SEC 型)
[in]sclday日 (DC_SCALED_SEC 型)
[in]sclsec秒 (DC_SCALED_SEC 型)
[out]err例外処理用フラグ

Definition at line 134 of file dcdatetimecreate.f90.

138
143 & caltype_default => caltype, &
148 use dc_message, only: messagenotify
149 use dc_trace, only: beginsub, endsub
150 use dc_present, only: present_select
151 use dc_string, only: lchar, cprintf
152 use dc_scaledsec, only: dc_scaled_sec, &
153 & assignment(=), dcscaledsecputline, &
154 & operator(==), operator(>), operator(<), operator(>=), operator(<=), &
155 & operator(+), operator(-), operator(*), operator(/), mod, modulo, &
157 use dc_types, only: dp, string
158 implicit none
159 type(DC_DATETIME), intent(out) :: time
160 integer, intent(in), optional:: year
161 integer, intent(in), optional:: mon
162 integer, intent(in), optional:: day
163 integer, intent(in), optional:: hour
164 integer, intent(in), optional:: min
165 real(DP),intent(in), optional:: sec
166 character(*), intent(in), optional :: zone
167 integer, intent(in), optional :: zone_hour
168 integer, intent(in), optional :: zone_min
169 integer, intent(in), optional:: caltype
170 character(*), intent(in), optional:: caltype_str
171 real(DP),intent(in), optional:: day_seconds
172 type(DC_SCALED_SEC), intent(in), optional:: sclyear
173 type(DC_SCALED_SEC), intent(in), optional:: sclmon
174 type(DC_SCALED_SEC), intent(in), optional:: sclday
175 type(DC_SCALED_SEC), intent(in), optional:: sclsec
176 logical, intent(out), optional:: err
177
178 real(DP):: gcsec
179 integer :: gcday, gcmon, gcyear
180 real(DP):: essec, esds
181 integer :: esday
182 type(DC_SCALED_SEC):: iday, imon, month, iyear, century, isec
183 character(6) :: izone
184 integer, parameter:: year_default = 0, mon_default = 1
185 integer, parameter:: day_default = 1
186 integer, parameter:: sec_default = 0
187 logical :: current_time_used
188 type(DC_DIFFTIME):: zonediff
189 character(STRING):: zone_str_long
190 integer :: stat, cause_i
191 character(STRING) :: cause_c
192 character(*), parameter :: subname = 'DCDateTimeCreate1'
193continue
194 current_time_used = .not. present(year) &
195 & .and. .not. present(mon) &
196 & .and. .not. present(day) &
197 & .and. .not. present(hour) &
198 & .and. .not. present(min) &
199 & .and. .not. present(sec) &
200 & .and. .not. present(sclyear) &
201 & .and. .not. present(sclmon) &
202 & .and. .not. present(sclday) &
203 & .and. .not. present(sclsec)
204 call beginsub(subname, 'current_time_used=<%y>', l=(/current_time_used/))
205 stat = dc_noerr
206 cause_i = dc_noerr
207 cause_c = ''
208
209 if ( present(day_seconds) ) then
210 time % day_seconds = day_seconds
211 else
213 time % day_seconds = day_seconds_scl
214 end if
215
216 call get_current_time(gcyear, gcmon, gcday, gcsec, izone) ! (out)
217 iyear = gcyear
218 imon = gcmon
219 iday = gcday
220 isec = gcsec
221
222 if (.not. current_time_used) then
223 if ( present(zone_hour) .or. present(zone_min) ) then
224 call dcdifftimecreate( zonediff, & ! (out)
225 & hour = zone_hour, min = zone_min ) ! (in)
226 zone_str_long = tochar(zonediff)
227 if ( zone_str_long(1:1) == '-' ) then
228 izone(1:1) = '-'
229 else
230 izone(1:1) = '+'
231 end if
232 izone(2:6) = zone_str_long(13:17)
233 end if
234 if (present(zone)) then
235 izone = zone
236 end if
237 if ( .not. validzone(izone)) then
238 stat = dc_ebadtimezone
239 cause_c = izone
240 if (present(err)) then
241 call messagenotify('W', subname, &
242 & 'zone=<%c> is invalid.', &
243 & c1=trim(izone))
244 else
245 goto 999
246 end if
247 end if
248
249 if ( present(sclsec) ) then
250 isec = sclsec
251 elseif( present(sec) ) then
252 isec = sec
253 else
254 isec = sec_default
255 end if
256 if (present(min)) then
257 isec = isec + min * min_seconds
258 end if
259 if (present(hour)) then
260 isec = isec + hour * hour_seconds
261 end if
262
263 if ( present(sclday) ) then
264 iday = sclday
265 elseif( present(day) ) then
266 iday = day
267 else
268 iday = day_default
269 end if
270
271 if ( present(sclday) ) then
272 iday = sclday
273 elseif( present(day) ) then
274 iday = day
275 else
276 iday = day_default
277 end if
278 iday = iday + floor(isec / time % day_seconds)
279
280 if ( present(sclmon) ) then
281 imon = sclmon
282 elseif( present(mon) ) then
283 imon = mon
284 else
285 imon = mon_default
286 end if
287
288 if ( present(sclyear) ) then
289 iyear = sclyear
290 elseif( present(year) ) then
291 iyear = year
292 else
293 iyear = year_default
294 end if
295 end if
296
297 time % zone = izone
298 time % sec = modulo(isec, time % day_seconds)
299 time % caltype = caltype_default
300 if (present(caltype_str)) then
301 select case( lchar(trim(caltype_str)) )
302 case('cyclic')
303 time % caltype = cal_cyclic
304 case('noleap')
305 time % caltype = cal_noleap
306 case('julian')
307 time % caltype = cal_julian
308 case('gregorian')
309 time % caltype = cal_gregorian
310 case('')
311 time % caltype = cal_gregorian
312 case default
313 stat = dc_ebadcaltype
314 cause_i = 0
315 call messagenotify('W', subname, &
316 & 'caltype=<%c> is invalid calender type.', &
317 & c1 = trim(caltype_str) )
318 if ( .not. present(err) ) then
319 goto 999
320 end if
321 end select
322 end if
323
324 if (present(caltype)) then
325 if (validcaltype(caltype)) then
326 time % caltype = caltype
327 else
328 stat = dc_ebadcaltype
329 cause_i = caltype
330 if (present(err)) then
331 call messagenotify('W', subname, &
332 & 'caltype=<%d> is invalid calender type.', &
333 & i=(/caltype/))
334 else
335 goto 999
336 end if
337 end if
338 end if
339 if (time % caltype == cal_cyclic) then
340 time % day = int( iday + imon * cyclic_mdays )
341 goto 999
342 endif
343 month = modulo(imon - 3, year_months) + 3
344 iyear = iyear + int( (imon - month) / year_months )
345 iday = iday + int( (month * 306 - 914) / 10 )
346 if (time % caltype == cal_noleap) then
347 time % day = iday + iyear * 365 + 90
348 else
349 iday = iday + int( (iyear * four_years - modulo(iyear * four_years, 4)) / 4 )
350 if (time % caltype == cal_julian) then
351 time % day = iday + 91
352 elseif (iday < 640116) then
353 time % day = iday + 91
354 else
355 century = (iyear - modulo(iyear, 100)) / 100 + 1
356 time % day = iday - int( (century * 3 - modulo(century * 3, 4)) / 4 ) + 93
357 endif
358 endif
359
360
361999 continue
362 call storeerror(stat, subname, err, cause_c, cause_i)
363 esday = time % day ; essec = time % sec ; esds = time % day_seconds
364 call endsub(subname, 'time (caltype=%d, day=%d, sec=%f, zone=%c, day_seconds=%f)', &
365 & i=(/time % caltype, esday/), d=(/essec, esds/), &
366 & c1=trim(time % zone))
367
368 contains
369 !> @en
370 !> @brief Get current time using date_and_time intrinsic subroutine
371 !> @details
372 !> Returns current time and timezone from UTC using date_and_time intrinsic subroutine.
373 !> @param[out] jyear Year
374 !> @param[out] jmon Month
375 !> @param[out] jday Day
376 !> @param[out] jsec Second
377 !> @param[out] jzone Timezone
378 !> @enden
379 !>
380 !> @ja
381 !> @brief date_and_time 組み込みサブルーチンを用いて現在時刻を取得
382 !> @details
383 !> date_and_time 組み込みサブルーチンを用いて, 現在
384 !> 時刻と UTC からの時差を返します.
385 !> @param[out] jyear 年
386 !> @param[out] jmon 月
387 !> @param[out] jday 日
388 !> @param[out] jsec 秒
389 !> @param[out] jzone タイムゾーン
390 !> @endja
391 subroutine get_current_time(jyear, jmon, jday, jsec, jzone)
392 use dc_types, only: dp
393 use dc_string, only: stod
394 implicit none
395 integer, intent(out) :: jyear, jmon, jday
396 real(DP), intent(out) :: jsec
397 character(*), intent(out) :: jzone
398
399 integer :: date_time_values(1:8)
400 character(5) :: zone_raw
401 continue
402
403 call date_and_time(zone=zone_raw, values=date_time_values)
404
405 jzone = zone_raw(1:3) // ":" // zone_raw(4:5)
406
407 jyear = date_time_values(1)
408 jmon = date_time_values(2)
409 jday = date_time_values(3)
410 jsec = real(date_time_values(5), dp) * hour_seconds &
411 & + real(date_time_values(6), dp) * min_seconds &
412 & + real(date_time_values(7), dp)
413
414 end subroutine get_current_time
415
subroutine get_current_time(jyear, jmon, jday, jsec, jzone)
dc_date より提供される手続の引用仕様宣言
dc_date用の内部モジュール
subroutine, public dcdate_set_day_seconds_scl
日付・時刻に関する構造データ型と定数
integer, parameter, public cal_noleap
閏年無しの暦 (1年 365 日)
real(dp), parameter, public cyclic_mdays
周期暦での1ヶ月の日数 (DC_DIFFTIME の月換算にも使用)
integer, parameter, public hour_seconds
1時間の秒数
integer, parameter, public four_years
4年の日数 (閏年を含む)
integer, parameter, public cal_cyclic
周期暦 (1ヶ月 30.6 日)
real(dp), save, public day_seconds
1日の秒数 (可変, デフォルトは地球の1日)
integer, save, public caltype
デフォルトの暦タイプ (グレゴリオ暦)
type(dc_scaled_sec), save, public day_seconds_scl
1日の秒数 (DC_SCALED_SEC 型)
logical, save, public flag_set_day_seconds_scl
day_seconds_scl が設定済みかどうかのフラグ
integer, parameter, public year_months
1年の月数
integer, parameter, public cal_gregorian
グレゴリオ暦
integer, parameter, public min_seconds
1分の秒数
integer, parameter, public cal_julian
ユリウス暦
エラー処理用モジュール
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_ebadcaltype
Definition dc_error.f90:537
integer, parameter, public dc_ebadtimezone
Definition dc_error.f90:538
メッセージの出力
省略可能な制御パラメータの判定
精密な時間演算のための秒スケールモジュール
subroutine, public dcscaledsecputline(sclsec, unit, indent)
文字型変数の操作
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_date_types::cal_cyclic, dc_date_types::cal_gregorian, dc_date_types::cal_julian, dc_date_types::cal_noleap, dc_date_types::caltype, dc_date_types::cyclic_mdays, dc_date_types::day_seconds_scl, dc_error::dc_ebadcaltype, dc_error::dc_ebadtimezone, dc_error::dc_noerr, dc_date_internal::dcdate_set_day_seconds_scl(), dc_scaledsec::dcscaledsecputline(), dc_types::dp, dc_trace::endsub(), dc_date_types::flag_set_day_seconds_scl, dc_date_types::four_years, get_current_time(), dc_date_types::hour_seconds, dc_date_types::min_seconds, dc_error::storeerror(), dc_types::string, and dc_date_types::year_months.

Here is the call graph for this function:

◆ dcdatetimecreate1_bc()

subroutine dcdatetimecreate1_bc ( type(dc_datetime), intent(out) time,
integer, intent(in), optional year,
integer, intent(in), optional mon,
integer, intent(in), optional day,
integer, intent(in), optional hour,
integer, intent(in), optional min,
real(dp), intent(in), optional sec,
character(*), intent(in), optional zone,
integer, intent(in), optional caltype,
real(dp), intent(in), optional day_seconds,
logical, intent(out), optional err )

DC_DATETIME 生成 (後方互換用)

Definition at line 1006 of file dcdatetimecreate.f90.

1009 use dc_types, only: dp
1010 use dc_date_types, only: dc_datetime
1012 type(DC_DATETIME), intent(out):: time
1013 integer, intent(in), optional:: year, mon, day, hour, min
1014 real(DP),intent(in), optional:: sec, day_seconds
1015 character(*), intent(in), optional :: zone
1016 integer, intent(in), optional:: caltype
1017 logical, intent(out), optional:: err
1018continue
1019 call dcdatetimecreate( time, &
1020 & year, mon, day, hour, min, sec, &
1021 & zone, caltype, day_seconds = day_seconds, err = err )

References dc_types::dp.

◆ dcdatetimecreated()

subroutine dcdatetimecreated ( type(dc_datetime), intent(out) time,
real(dp), intent(in) sec )

倍精度秒数から DC_DATETIME 型変数を生成

Parameters
[out]time生成される DC_DATETIME 変数
[in]sec秒数 (倍精度)

Definition at line 896 of file dcdatetimecreate.f90.

897 use dc_types, only: dp
898 use dc_date_types, only: dc_datetime
900 use dc_scaledsec, only: dc_scaled_sec, assignment(=)
901 implicit none
902 type(DC_DATETIME), intent(out):: time
903 real(DP), intent(in):: sec
904continue
905 call dcdatetimecreate(time, sec = sec)

References dc_types::dp.

◆ dcdatetimecreatei()

subroutine dcdatetimecreatei ( type(dc_datetime), intent(out) time,
integer, intent(in) sec )

整数秒数から DC_DATETIME 型変数を生成

dc_date_types#DC_DATETIME 型変数の生成を行います. 引数 sec には秒数を与えてください. 年月日, 時分を使って 指定を行いたい場合は Create を利用してください.

Parameters
[out]time生成される DC_DATETIME 変数
[in]sec秒数 (整数)

Definition at line 840 of file dcdatetimecreate.f90.

841 use dc_types, only: dp
842 use dc_date_types, only: dc_datetime
844 use dc_scaledsec, only: dc_scaled_sec, assignment(=)
845 implicit none
846 type(DC_DATETIME), intent(out):: time
847 integer, intent(in):: sec
848continue
849 call dcdatetimecreate(time, sec = real(sec, dp) )

References dc_types::dp.

◆ dcdatetimecreater()

subroutine dcdatetimecreater ( type(dc_datetime), intent(out) time,
real, intent(in) sec )

単精度秒数から DC_DATETIME 型変数を生成

dc_date_types#DC_DATETIME 型変数の生成を行います. 引数 sec には秒数を与えてください. 年月日, 時分を使って 指定を行いたい場合は Create を利用してください.

Parameters
[out]time生成される DC_DATETIME 変数
[in]sec秒数 (単精度)

Definition at line 873 of file dcdatetimecreate.f90.

874 use dc_types, only: dp
875 use dc_date_types, only: dc_datetime
877 use dc_scaledsec, only: dc_scaled_sec, assignment(=)
878 implicit none
879 type(DC_DATETIME), intent(out):: time
880 real, intent(in):: sec
881continue
882 call dcdatetimecreate(time, sec = real(sec, dp) )

References dc_types::dp.

◆ dcdifftimecreate1()

subroutine dcdifftimecreate1 ( type(dc_difftime), intent(out) diff,
integer, intent(in), optional year,
integer, intent(in), optional mon,
integer, intent(in), optional day,
integer, intent(in), optional hour,
integer, intent(in), optional min,
real(dp), intent(in), optional sec,
real(dp), intent(in), optional day_seconds,
real(dp), intent(in), optional nondim,
type(dc_scaled_sec), intent(in), optional sclyear,
type(dc_scaled_sec), intent(in), optional sclmon,
type(dc_scaled_sec), intent(in), optional sclday,
type(dc_scaled_sec), intent(in), optional sclsec )

DC_DIFFTIME 型変数を生成

dc_date_types#DC_DIFFTIME 型変数の生成を行います. 引数 year, mon, day, hour, min, sec, nondim を与えない場合, 0 が与えられたことになります.

引数 day_seconds には 1 日何秒かを設定します. この引数を 指定しない場合, dc_date_types::day_seconds の値が用いられます. dc_date_types::day_seconds は SetSecOfDay で変更可能です.

Parameters
[out]diff生成される DC_DIFFTIME 変数
[in]year
[in]mon
[in]day
[in]hour
[in]min
[in]sec
[in]day_seconds1 日の秒数
[in]nondim無次元時間
[in]sclyear年 (DC_SCALED_SEC 型)
[in]sclmon月 (DC_SCALED_SEC 型)
[in]sclday日 (DC_SCALED_SEC 型)
[in]sclsec秒 (DC_SCALED_SEC 型)

Definition at line 470 of file dcdatetimecreate.f90.

475 use dc_date_types, only: dc_difftime, &
476 & day_seconds_default => day_seconds, &
478 use dc_message, only: messagenotify
479 use dc_trace, only: beginsub, endsub, debug
480 use dc_present, only: present_select
481 use dc_scaledsec, only: dc_scaled_sec, &
482 & assignment(=), dcscaledsecputline, &
483 & operator(==), operator(>), operator(<), operator(>=), operator(<=), &
484 & operator(+), operator(-), operator(*), operator(/), mod, modulo, &
485 & abs, int, sign, floor
486 use dc_string, only: cprintf
487 use dc_types, only: dp, string
488 implicit none
489 type(DC_DIFFTIME), intent(out) :: diff
490 integer, intent(in), optional:: year
491 integer, intent(in), optional:: mon
492 integer, intent(in), optional:: day
493 integer, intent(in), optional:: hour
494 integer, intent(in), optional:: min
495 real(DP), intent(in), optional:: sec
496 real(DP), intent(in), optional:: day_seconds
497 real(DP), intent(in), optional:: nondim
498 type(DC_SCALED_SEC), intent(in), optional:: sclyear
499 type(DC_SCALED_SEC), intent(in), optional:: sclmon
500 type(DC_SCALED_SEC), intent(in), optional:: sclday
501 type(DC_SCALED_SEC), intent(in), optional:: sclsec
502
503 type(DC_SCALED_SEC):: iyear, imon, iday, ihour, imin, isec
504 integer, parameter:: year_default = 0, mon_default = 0
505 integer, parameter:: day_default = 0, hour_default = 0, min_default = 0
506 integer, parameter:: sec_default = 0
507 real(DP):: essec, esds
508 integer :: esmon, esday
509 character(STRING):: endsub_msb
510 logical:: dbg_mode
511 character(*), parameter :: subname = 'DCDiffTimeCreate1'
512continue
513 call beginsub(subname)
514
515 if ( present(nondim) ) then
516 diff % nondim_flag = .true.
517 diff % mon = 0
518 diff % day = 0
519 diff % sec = nondim
520 goto 999
521 else
522 diff % nondim_flag = .false.
523 end if
524
525 if ( present(sclyear) ) then
526 iyear = sclyear
527 elseif( present(year) ) then
528 iyear = year
529 else
530 iyear = year_default
531 end if
532
533 if ( present(sclmon) ) then
534 imon = sclmon
535 elseif( present(mon) ) then
536 imon = mon
537 else
538 imon = mon_default
539 end if
540
541 if ( present(sclday) ) then
542 iday = sclday
543 elseif( present(day) ) then
544 iday = day
545 else
546 iday = day_default
547 end if
548
549 ihour = present_select(.false., hour_default, hour)
550 imin = present_select(.false., min_default, min)
551
552 if ( present(sclsec) ) then
553 isec = sclsec
554 elseif( present(sec) ) then
555 isec = sec
556 else
557 isec = sec_default
558 end if
559
560 diff % mon = iyear * year_months + imon
561 diff % day = iday
562 diff % sec = ihour * hour_seconds &
563 & + imin * min_seconds &
564 & + isec
565
566 if( present(day_seconds) ) then
567 diff % day_seconds = day_seconds
568 else
569 diff % day_seconds = day_seconds_default
570 end if
571
572 call dcdate_normalize(diff % day, diff % sec, diff % day_seconds, diff % nondim_flag)
573
574999 continue
575 call debug( dbg_mode )
576 if ( dbg_mode ) then
577 esmon = diff % mon ; esday = diff % day
578 essec = diff % sec ; esds = diff % day_seconds
579 endsub_msb = &
580 & cprintf( 'mon=%d, day=%d, sec=%f, day_seconds=%f, nondim_flag=%b', &
581 & i = (/ esmon, esday /), d = (/ essec, esds /), &
582 & l = (/ diff % nondim_flag /) )
583 else
584 endsub_msb = ''
585 end if
586 call endsub(subname, 'diff (%c)', c1 = trim(endsub_msb) )
subroutine, public dcdate_normalize(day, sec, day_seconds, nondim_flag)

References dc_trace::beginsub(), dc_date_types::day_seconds, dc_date_internal::dcdate_normalize(), dc_scaledsec::dcscaledsecputline(), dc_types::dp, dc_trace::endsub(), dc_date_types::hour_seconds, dc_date_types::min_seconds, dc_types::string, and dc_date_types::year_months.

Here is the call graph for this function:

◆ dcdifftimecreate1_bc()

subroutine dcdifftimecreate1_bc ( type(dc_difftime), intent(out) diff,
integer, intent(in), optional year,
integer, intent(in), optional mon,
integer, intent(in), optional day,
integer, intent(in), optional hour,
integer, intent(in), optional min,
real(dp), intent(in), optional sec,
real(dp), intent(in), optional day_seconds )

DC_DIFFTIME 生成 (後方互換用)

Definition at line 1030 of file dcdatetimecreate.f90.

1032 use dc_types, only: dp
1033 use dc_date_types, only: dc_difftime
1035 type(DC_DIFFTIME), intent(out) :: diff
1036 integer, intent(in), optional:: year, mon, day, hour, min
1037 real(DP),intent(in), optional:: sec, day_seconds
1038continue
1039 call dcdifftimecreate( diff, &
1040 & year, mon, day, hour, min, sec, day_seconds )

References dc_types::dp.

◆ dcdifftimecreate2_bc()

subroutine dcdifftimecreate2_bc ( type(dc_difftime), intent(out) diff,
real(dp), intent(in) value,
character(*), intent(in) unit,
logical, intent(out), optional err )

値と単位から DC_DIFFTIME 生成 (後方互換用)

Definition at line 1049 of file dcdatetimecreate.f90.

1050 use dc_types, only: dp
1051 use dc_date_types, only: dc_difftime
1053 type(DC_DIFFTIME), intent(out) :: diff
1054 real(DP), intent(in) :: value
1055 character(*), intent(in) :: unit
1056 logical, intent(out), optional :: err
1057continue
1058 call dcdifftimecreate( diff, value, unit, err = err )

References dc_types::dp.

◆ dcdifftimecreate2d()

subroutine dcdifftimecreate2d ( type(dc_difftime), intent(out) diff,
real(dp), intent(in) value,
character(*), intent(in) unit,
integer, intent(in), optional unit_symbol,
logical, intent(out), optional err )

値と単位から DC_DIFFTIME 型変数を生成

dc_date_types#DC_DIFFTIME 型変数の生成を行います. 引数 value に数値を, unit に単位を表す文字列を, または unit_symbol に単位を表すシンボルを与えてください.

unit に指定できるのは以下の文字列です. (大文字小文字は区別しません).

単位 文字列
dc_date_types#UNIT_YEAR
dc_date_types#UNIT_MONTH
dc_date_types#UNIT_DAY
dc_date_types#UNIT_HOUR
dc_date_types#UNIT_MIN
dc_date_types#UNIT_SEC
無次元時間 dc_date_types#UNIT_NONDIM

これらに該当しない文字列を unit に与えた場合, エラーを発生させます.

unit_symbol に指定できるのは以下のシンボルです.

単位 シンボル
dc_date_types#UNIT_SYMBOL_YEAR
dc_date_types#UNIT_SYMBOL_MONTH
dc_date_types#UNIT_SYMBOL_DAY
dc_date_types#UNIT_SYMBOL_HOUR
dc_date_types#UNIT_SYMBOL_MIN
dc_date_types#UNIT_SYMBOL_SEC
無次元時間 dc_date_types#UNIT_SYMBOL_NONDIM

これらに該当しないシンボルを unit_symbol に与えた場合, エラーを発生させます.

引数 err を与えている場合には err に .true. が返り, プログラムは続行します.

Parameters
[out]diff生成される DC_DIFFTIME 変数
[in]value
[in]unit単位文字列
[in]unit_symbol単位シンボル
[out]err例外処理用フラグ

Definition at line 679 of file dcdatetimecreate.f90.

680 use dc_types, only: dp, string
681 use dc_trace, only: beginsub, endsub
683 use dc_string, only: strieq
685 use dc_date_types, only: dc_difftime, &
688 & unit_symbol_err, &
690 use dc_scaledsec, only: dc_scaled_sec, &
691 & assignment(=), dcscaledsecputline, &
692 & operator(==), operator(>), operator(<), operator(>=), operator(<=), &
693 & operator(+), operator(-), operator(*), operator(/), mod, modulo, &
694 & abs, int, sign, floor
695 implicit none
696 type(DC_DIFFTIME), intent(out) :: diff
697 real(DP), intent(in) :: value
698 character(*), intent(in) :: unit
699 integer, intent(in), optional :: unit_symbol
700 logical, intent(out), optional :: err
701
702 real(DP):: essec
703 integer :: esmon, esday
704 integer :: stat, val_int
705 type(DC_SCALED_SEC):: val_scl, val_dec
706 character(STRING) :: cause_c
707 integer:: symbol
708
709 character(*), parameter :: subname = 'DCDiffTimeCreate2'
710continue
711 call beginsub(subname, 'value=%f', d=(/value/))
712 stat = dc_noerr
713 cause_c = ''
714 symbol = unit_symbol_err
715 if ( present(unit_symbol) ) then
716 symbol = unit_symbol
717 else
718 symbol = parsetimeunits(unit)
719 end if
720
721 if ( symbol == unit_symbol_sec ) then
722 call dcdifftimecreate(diff, sec=value)
723 goto 999
724 elseif ( symbol == unit_symbol_nondim ) then
725 call dcdifftimecreate(diff, nondim=value)
726 goto 999
727 end if
728
729 val_int = int(value)
730 val_scl = int(value)
731 val_dec = value - int(value)
732
733 if ( symbol == unit_symbol_min ) then
734 call dcdifftimecreate(diff, min = val_int, sclsec = val_dec * min_seconds)
735 elseif ( symbol == unit_symbol_hour ) then
736 call dcdifftimecreate(diff, hour = val_int, sclsec = val_dec * hour_seconds)
737 elseif ( symbol == unit_symbol_day ) then
738 call dcdifftimecreate(diff, sclday = val_scl, sclsec = val_dec * day_seconds)
739 elseif ( symbol == unit_symbol_month ) then
740 call dcdifftimecreate(diff, sclmon = val_scl, &
741 & sclsec = int(val_dec * cyclic_mdays) * day_seconds)
742 elseif ( symbol == unit_symbol_year ) then
743 call dcdifftimecreate(diff, sclyear = val_scl, &
744 & sclsec = int(val_dec * cyclic_mdays * year_months) * day_seconds)
745 else
746 stat = dc_ebadunit
747 cause_c = unit
748 end if
749
750999 continue
751 call storeerror(stat, subname, err, cause_c)
752 esmon = diff % mon ; esday = diff % day ; essec = diff % sec
753 call endsub(subname, 'diff (mon=%d, day=%d, sec=%f)', &
754 & i=(/esmon, esday/), d=(/essec/))
integer, parameter, public unit_symbol_err
無効な単位を示すシンボル
integer, parameter, public unit_symbol_hour
時間の単位を示すシンボル
integer, parameter, public unit_symbol_min
分の単位を示すシンボル
integer, parameter, public unit_symbol_month
月の単位を示すシンボル
integer, parameter, public unit_symbol_sec
秒の単位を示すシンボル
integer, parameter, public unit_symbol_nondim
無次元時間の単位を示すシンボル
integer, parameter, public unit_symbol_day
日の単位を示すシンボル
integer, parameter, public unit_symbol_year
年の単位を示すシンボル
integer, parameter, public dc_ebadunit
Definition dc_error.f90:536

References dc_trace::beginsub(), dc_date_types::cyclic_mdays, dc_date_types::day_seconds, dc_error::dc_ebadunit, dc_error::dc_noerr, dc_scaledsec::dcscaledsecputline(), dc_types::dp, dc_trace::endsub(), dc_date_types::hour_seconds, dc_date_types::min_seconds, dc_error::storeerror(), dc_types::string, dc_date_types::unit_symbol_day, dc_date_types::unit_symbol_err, dc_date_types::unit_symbol_hour, dc_date_types::unit_symbol_min, dc_date_types::unit_symbol_month, dc_date_types::unit_symbol_nondim, dc_date_types::unit_symbol_sec, dc_date_types::unit_symbol_year, and dc_date_types::year_months.

Here is the call graph for this function:

◆ dcdifftimecreate2i()

subroutine dcdifftimecreate2i ( type(dc_difftime), intent(out) diff,
integer, intent(in) value,
character(*), intent(in) unit,
integer, intent(in), optional unit_symbol,
logical, intent(out), optional err )

整数値と単位から DC_DIFFTIME 型変数を生成

Parameters
[out]diff生成される DC_DIFFTIME 変数
[in]value値 (整数)
[in]unit単位文字列
[in]unit_symbol単位シンボル
[out]err例外処理用フラグ

Definition at line 805 of file dcdatetimecreate.f90.

806 use dc_types, only: dp
808 use dc_date_types, only: dc_difftime
809 implicit none
810 type(DC_DIFFTIME), intent(out) :: diff
811 integer, intent(in) :: value
812 character(*), intent(in) :: unit
813 integer, intent(in), optional :: unit_symbol
814 logical, intent(out), optional :: err
815continue
816 call dcdifftimecreate(diff, real( value, dp ), unit, unit_symbol, err)

References dc_types::dp.

◆ dcdifftimecreate2r()

subroutine dcdifftimecreate2r ( type(dc_difftime), intent(out) diff,
real, intent(in) value,
character(*), intent(in) unit,
integer, intent(in), optional unit_symbol,
logical, intent(out), optional err )

単精度値と単位から DC_DIFFTIME 型変数を生成

Parameters
[out]diff生成される DC_DIFFTIME 変数
[in]value値 (単精度)
[in]unit単位文字列
[in]unit_symbol単位シンボル
[out]err例外処理用フラグ

Definition at line 774 of file dcdatetimecreate.f90.

775 use dc_types, only: dp
777 use dc_date_types, only: dc_difftime
778 implicit none
779 type(DC_DIFFTIME), intent(out) :: diff
780 real, intent(in) :: value
781 character(*), intent(in) :: unit
782 integer, intent(in), optional :: unit_symbol
783 logical, intent(out), optional :: err
784continue
785 call dcdifftimecreate(diff, real( value, dp ), unit, unit_symbol, err)

References dc_types::dp.

◆ dcdifftimecreated()

subroutine dcdifftimecreated ( type(dc_difftime), intent(out) diff,
real(dp), intent(in) sec )

倍精度秒数から DC_DIFFTIME 型変数を生成

Parameters
[out]diff生成される DC_DIFFTIME 変数
[in]sec秒数 (倍精度)

Definition at line 985 of file dcdatetimecreate.f90.

986 use dc_types, only: dp
987 use dc_date_types, only: dc_difftime
989 use dc_scaledsec, only: dc_scaled_sec, assignment(=)
990 implicit none
991 type(DC_DIFFTIME), intent(out):: diff
992 real(DP), intent(in):: sec
993continue
994 call dcdifftimecreate(diff, sec = sec)

References dc_types::dp.

◆ dcdifftimecreatei()

subroutine dcdifftimecreatei ( type(dc_difftime), intent(out) diff,
integer, intent(in) sec )

整数秒数から DC_DIFFTIME 型変数を生成

dc_date_types#DC_DIFFTIME 型変数の生成を行います. 引数 sec には秒数を与えてください. 年月日, 時分を使って 指定を行いたい場合は Create を利用してください.

Parameters
[out]diff生成される DC_DIFFTIME 変数
[in]sec秒数 (整数)

Definition at line 929 of file dcdatetimecreate.f90.

930 use dc_types, only: dp
931 use dc_date_types, only: dc_difftime
933 use dc_scaledsec, only: dc_scaled_sec, assignment(=)
934 implicit none
935 type(DC_DIFFTIME), intent(out):: diff
936 integer, intent(in):: sec
937continue
938 call dcdifftimecreate(diff, sec = real(sec, dp) )

References dc_types::dp.

◆ dcdifftimecreater()

subroutine dcdifftimecreater ( type(dc_difftime), intent(out) diff,
real, intent(in) sec )

単精度秒数から DC_DIFFTIME 型変数を生成

dc_date_types#DC_DIFFTIME 型変数の生成を行います. 引数 sec には秒数を与えてください. 年月日, 時分を使って 指定を行いたい場合は Create を利用してください.

Parameters
[out]diff生成される DC_DIFFTIME 変数
[in]sec秒数 (単精度)

Definition at line 962 of file dcdatetimecreate.f90.

963 use dc_types, only: dp
964 use dc_date_types, only: dc_difftime
966 use dc_scaledsec, only: dc_scaled_sec, assignment(=)
967 implicit none
968 type(DC_DIFFTIME), intent(out):: diff
969 real, intent(in):: sec
970continue
971 call dcdifftimecreate(diff, sec = real(sec, dp) )

References dc_types::dp.

◆ get_current_time()

subroutine dcdatetimecreate1::get_current_time ( integer, intent(out) jyear,
integer, intent(out) jmon,
integer, intent(out) jday,
real(dp), intent(out) jsec,
character(*), intent(out) jzone )

date_and_time 組み込みサブルーチンを用いて現在時刻を取得

date_and_time 組み込みサブルーチンを用いて, 現在 時刻と UTC からの時差を返します.

Parameters
[out]jyear
[out]jmon
[out]jday
[out]jsec
[out]jzoneタイムゾーン

Definition at line 391 of file dcdatetimecreate.f90.

392 use dc_types, only: dp
393 use dc_string, only: stod
394 implicit none
395 integer, intent(out) :: jyear, jmon, jday
396 real(DP), intent(out) :: jsec
397 character(*), intent(out) :: jzone
398
399 integer :: date_time_values(1:8)
400 character(5) :: zone_raw
401 continue
402
403 call date_and_time(zone=zone_raw, values=date_time_values)
404
405 jzone = zone_raw(1:3) // ":" // zone_raw(4:5)
406
407 jyear = date_time_values(1)
408 jmon = date_time_values(2)
409 jday = date_time_values(3)
410 jsec = real(date_time_values(5), dp) * hour_seconds &
411 & + real(date_time_values(6), dp) * min_seconds &
412 & + real(date_time_values(7), dp)
413

References dc_date_types::hour_seconds, and dc_date_types::min_seconds.