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

Go to the source code of this file.

Functions/Subroutines

character(string) function dccaldatetochar1 (year, month, day, hour, min, sec, zone)
 Convert date into a string.

Function/Subroutine Documentation

◆ dccaldatetochar1()

character(string) function dccaldatetochar1 ( integer, intent(in) year,
integer, intent(in) month,
integer, intent(in) day,
integer, intent(in) hour,
integer, intent(in) min,
real(dp), intent(in) sec,
character(*), intent(in), optional zone )

Convert date into a string.

Author
Yasuhiro MORIKAWA

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

Convert date components to string

Convert year, month, day, hour, minute, second into a string (conformed to gtool4 netCDF Convention "5.5 Expression of date and time").

Parameters
[in]yearYear
[in]monthMonth
[in]dayDay
[in]hourHour
[in]minMinute
[in]secSecond
[in]zoneTime-zone (difference from UTC)
Returns
Strings that express date and time. See gtool4 netCDF Convention 5.5 Expression of date and time for details.

Definition at line 56 of file dccaldatetochar.f90.

58
59 use dc_types, only: string, token, dp
61 use dc_message, only: messagenotify
62 implicit none
63 character(STRING):: result
64 integer, intent(in):: year
65 integer, intent(in):: month
66 integer, intent(in):: day
67 integer, intent(in):: hour
68 integer, intent(in):: min
69 real(DP), intent(in):: sec
70 character(*), intent(in), optional:: zone
71 integer:: csec_len
72 character(STRING):: csec
73 character(TOKEN):: zonew
74continue
75
76 if ( present(zone) ) then
77 zonew = zone
78 else
79 zonew = ''
80 end if
81
82 csec = tochar(sec)
83 csec = roundnum( csec )
84 if ( trim(csec) == '-0.' ) csec = '0.'
85 do while ( index('123456789.', csec(len_trim(csec):len_trim(csec)) ) == 0 )
86 if ( len_trim(csec) < 2 ) exit
87 csec = csec(1:len_trim(csec)-1)
88 end do
89 if (int(sec) > -1 .and. int(sec) < 10) then
90 if (len_trim(csec) >= len(csec)) then
91 csec = '0' // trim(csec(1:len(csec) - 1))
92 else
93 csec = '0' // trim(csec)
94 end if
95 end if
96 csec_len = len(trim(adjustl(csec)))
97 if (csec(csec_len:csec_len) == '.') csec = csec(1:csec_len-1)
98
99 result = cprintf('%04d-%02d-%02dT%02d:%02d:%c%c', &
100 & i=(/year, month, day, hour, min/), &
101 & c1=trim(csec), c2=trim(zonew))
102
Message output module.
Handling character types.
Definition dc_string.f90:83
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_types::dp, dc_types::string, and dc_types::token.