gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
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)
 Create DC_DATETIME and DC_DIFFTIME type variables.
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 )

Create DC_DATETIME and DC_DIFFTIME type variables.

Author
Yasuhiro MORIKAWA, Eizi TOYODA

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

Create DC_DATETIME type variable

Create dc_date_types#DC_DATETIME type variable. If all arguments year, mon, day, hour, min, sec are not given, the current time is used.

Set calendar type with caltype argument. Use one of dc_date_types#CAL_CYCLIC, dc_date_types#CAL_NOLEAP, dc_date_types#CAL_JULIAN, dc_date_types#CAL_GREGORIAN. If caltype is not specified, calendar is set to dc_date_types#CAL_GREGORIAN. Calendar can also be specified by string with caltype_str. Corresponding strings (case insensitive) are:

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

Set timezone from UTC with zone argument. Specify timezone as 6 characters like '+09:00' or '-13:00'. If zone is not specified, timezone obtained from date_and_time intrinsic subroutine is used. Timezone can also be specified with zone_hour or zone_min as integer.

Set seconds per day with day_seconds argument. If not specified, dc_date_types::day_seconds value is used. dc_date_types::day_seconds can be changed with SetSecOfDay.

If invalid value is given to caltype or zone, an error occurs. If err argument is given, .true. is returned to err and the program continues.

Parameters
[out]timeCreated DC_DATETIME variable
[in]yearYear
[in]monMonth
[in]dayDay
[in]hourHour
[in]minMinute
[in]secSecond
[in]zoneTimezone from UTC
[in]zone_hourTimezone (hour)
[in]zone_minTimezone (minute)
[in]caltypeCalendar type
[in]caltype_strCalendar type (string)
[in]day_secondsSeconds per day
[in]sclyearYear (DC_SCALED_SEC type)
[in]sclmonMonth (DC_SCALED_SEC type)
[in]scldayDay (DC_SCALED_SEC type)
[in]sclsecSecond (DC_SCALED_SEC type)
[out]errException handling flag

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)
Interface declarations for procedures provided from dc_date.
Internal module for dc_date.
subroutine, public dcdate_set_day_seconds_scl
Derived types and parameters for date and time.
integer, parameter, public cal_noleap
Calendar without leap years (365 days per year)
real(dp), parameter, public cyclic_mdays
Days per month for cyclic calendar (also used for DC_DIFFTIME)
integer, parameter, public hour_seconds
Seconds per hour
integer, parameter, public four_years
Days in 4 years (including leap year)
integer, parameter, public cal_cyclic
Cyclic calendar (30.6 days per month)
real(dp), save, public day_seconds
Seconds per day (variable, default is Earth day)
integer, save, public caltype
Default calendar type (Gregorian)
type(dc_scaled_sec), save, public day_seconds_scl
Seconds per day (DC_SCALED_SEC type)
logical, save, public flag_set_day_seconds_scl
Flag indicating if day_seconds_scl is set
integer, parameter, public year_months
Months per year
integer, parameter, public cal_gregorian
Gregorian calendar
integer, parameter, public min_seconds
Seconds per minute
integer, parameter, public cal_julian
Julian calendar
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_ebadcaltype
Definition dc_error.f90:537
integer, parameter, public dc_ebadtimezone
Definition dc_error.f90:538
Message output module.
Judge optional control parameters.
Scaled seconds module for precise time operations.
subroutine, public dcscaledsecputline(sclsec, unit, indent)
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 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_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 )

Create DC_DATETIME (backward compatibility)

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 )

Create DC_DATETIME type variable with double precision seconds

Parameters
[out]timeCreated DC_DATETIME variable
[in]secSeconds (double precision)

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 )

Create DC_DATETIME type variable with integer seconds

Create dc_date_types#DC_DATETIME type variable. Specify seconds with sec argument. Use Create for year/month/day/hour/minute specification.

Parameters
[out]timeCreated DC_DATETIME variable
[in]secSeconds (integer)

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 )

Create DC_DATETIME type variable with single precision seconds

Create dc_date_types#DC_DATETIME type variable. Specify seconds with sec argument. Use Create for year/month/day/hour/minute specification.

Parameters
[out]timeCreated DC_DATETIME variable
[in]secSeconds (single precision)

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 )

Create DC_DIFFTIME type variable

Create dc_date_types#DC_DIFFTIME type variable. If arguments year, mon, day, hour, min, sec, nondim are not given, 0 is used.

Set seconds per day with day_seconds argument. If not specified, dc_date_types::day_seconds value is used. dc_date_types::day_seconds can be changed with SetSecOfDay.

Parameters
[out]diffCreated DC_DIFFTIME variable
[in]yearYear
[in]monMonth
[in]dayDay
[in]hourHour
[in]minMinute
[in]secSecond
[in]day_secondsSeconds per day
[in]nondimNondimensional time
[in]sclyearYear (DC_SCALED_SEC type)
[in]sclmonMonth (DC_SCALED_SEC type)
[in]scldayDay (DC_SCALED_SEC type)
[in]sclsecSecond (DC_SCALED_SEC type)

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 )

Create DC_DIFFTIME (backward compatibility)

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 )

Create DC_DIFFTIME with value and unit (backward compatibility)

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 )

Create DC_DIFFTIME type variable with value and unit

Create dc_date_types#DC_DIFFTIME type variable. Specify value with value argument and unit with unit string or unit symbol with unit_symbol.

Valid strings for unit (case insensitive):

Unit String
Year dc_date_types#UNIT_YEAR
Month dc_date_types#UNIT_MONTH
Day dc_date_types#UNIT_DAY
Hour dc_date_types#UNIT_HOUR
Minute dc_date_types#UNIT_MIN
Second dc_date_types#UNIT_SEC
Nondimensional dc_date_types#UNIT_NONDIM

If invalid string is given to unit, an error occurs.

Valid symbols for unit_symbol:

Unit Symbol
Year dc_date_types#UNIT_SYMBOL_YEAR
Month dc_date_types#UNIT_SYMBOL_MONTH
Day dc_date_types#UNIT_SYMBOL_DAY
Hour dc_date_types#UNIT_SYMBOL_HOUR
Minute dc_date_types#UNIT_SYMBOL_MIN
Second dc_date_types#UNIT_SYMBOL_SEC
Nondimensional dc_date_types#UNIT_SYMBOL_NONDIM

If invalid symbol is given to unit_symbol, an error occurs. If err argument is given, .true. is returned to err and the program continues.

Parameters
[out]diffCreated DC_DIFFTIME variable
[in]valueValue
[in]unitUnit string
[in]unit_symbolUnit symbol
[out]errException handling flag

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
Symbol for invalid unit
integer, parameter, public unit_symbol_hour
Symbol for hour unit
integer, parameter, public unit_symbol_min
Symbol for minute unit
integer, parameter, public unit_symbol_month
Symbol for month unit
integer, parameter, public unit_symbol_sec
Symbol for second unit
integer, parameter, public unit_symbol_nondim
Symbol for nondimensional unit
integer, parameter, public unit_symbol_day
Symbol for day unit
integer, parameter, public unit_symbol_year
Symbol for year unit
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 )

Create DC_DIFFTIME type variable with integer value and unit

Parameters
[out]diffCreated DC_DIFFTIME variable
[in]valueValue (integer)
[in]unitUnit string
[in]unit_symbolUnit symbol
[out]errException handling flag

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 )

Create DC_DIFFTIME type variable with single precision value and unit

Parameters
[out]diffCreated DC_DIFFTIME variable
[in]valueValue (single precision)
[in]unitUnit string
[in]unit_symbolUnit symbol
[out]errException handling flag

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 )

Create DC_DIFFTIME type variable with double precision seconds

Parameters
[out]diffCreated DC_DIFFTIME variable
[in]secSeconds (double precision)

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 )

Create DC_DIFFTIME type variable with integer seconds

Create dc_date_types#DC_DIFFTIME type variable. Specify seconds with sec argument. Use Create for year/month/day/hour/minute specification.

Parameters
[out]diffCreated DC_DIFFTIME variable
[in]secSeconds (integer)

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 )

Create DC_DIFFTIME type variable with single precision seconds

Create dc_date_types#DC_DIFFTIME type variable. Specify seconds with sec argument. Use Create for year/month/day/hour/minute specification.

Parameters
[out]diffCreated DC_DIFFTIME variable
[in]secSeconds (single precision)

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 )

Get current time using date_and_time intrinsic subroutine

Returns current time and timezone from UTC using date_and_time intrinsic subroutine.

Parameters
[out]jyearYear
[out]jmonMonth
[out]jdayDay
[out]jsecSecond
[out]jzoneTimezone

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.