Loading...
Searching...
No Matches
Functions/Subroutines
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)
 

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 
)

Definition at line 15 of file dccaldatetochar.f90.

17 !
18 ! 年月日時分秒を文字型変数 (gtool4 netCDF 規約「5.5 日時形式」に準拠)
19 ! へ変換して返します.
20 !
21 ! Convert year, month, day, hour, minute, second into a string
22 ! (conformed to gtool4 netCDF Convention
23 ! "5.5 Expression of date and time").
24 !
25 use dc_types, only: string, token, dp
26 use dc_string, only: tochar, cprintf, stoa, roundnum
27 use dc_message, only: messagenotify
28 implicit none
29 character(STRING):: result
30 ! 日時情報を表す文字列.
31 ! 表示形式については gtool4 netCDF 規約
32 ! 5.5 日時形式を参照のこと.
33 !
34 ! Strings that express date and time.
35 ! See gtool4 netCDF Convention
36 ! 5.5 Expression of date and time for details.
37 integer, intent(in):: year ! 年. Year.
38 integer, intent(in):: month ! 月. Month.
39 integer, intent(in):: day ! 日. Day.
40 integer, intent(in):: hour ! 時. Hour.
41 integer, intent(in):: min ! 分. Minute.
42 real(DP), intent(in):: sec ! 秒. Sec.
43 character(*), intent(in), optional:: zone ! UTC からの時差. Time-zone.
44 integer:: csec_len
45 character(TOKEN):: csec, zonew
46continue
47
48 if ( present(zone) ) then
49 zonew = zone
50 else
51 zonew = ''
52 end if
53
54 csec = tochar(sec)
55 csec = roundnum( csec )
56 if ( trim(csec) == '-0.' ) csec = '0.'
57 do while ( index('123456789.', csec(len_trim(csec):len_trim(csec)) ) == 0 )
58 if ( len_trim(csec) < 2 ) exit
59 csec = csec(1:len_trim(csec)-1)
60 end do
61 if (int(sec) > -1 .and. int(sec) < 10) csec = '0' // csec
62 csec_len = len(trim(adjustl(csec)))
63 if (csec(csec_len:csec_len) == '.') csec = csec(1:csec_len-1)
64
65 result = cprintf('%04d-%02d-%02dT%02d:%02d:%c%c', &
66 & i=(/year, month, day, hour, min/), &
67 & c1=trim(csec), c2=trim(zonew))
68
Provides kind type parameter values.
Definition dc_types.f90:49
integer, parameter, public token
Character length for word, token
Definition dc_types.f90:109
integer, parameter, public dp
Double Precision Real number
Definition dc_types.f90:83
integer, parameter, public string
Character length for string
Definition dc_types.f90:118

References dc_types::dp, dc_types::string, and dc_types::token.