gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
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)
 日時の文字列への変換

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 )

日時の文字列への変換

Author
Yasuhiro MORIKAWA

このファイルに記載される手続き群は dc_calendar モジュールから提供されます.

日時要素を文字列に変換

年月日時分秒を文字型変数 (gtool4 netCDF 規約「5.5 日時形式」に準拠) へ変換して返します.

Parameters
[in]year
[in]month
[in]day
[in]hour
[in]min
[in]sec
[in]zoneUTC からの時差
Returns
日時情報を表す文字列. 表示形式については gtool4 netCDF 規約 5.5 日時形式を参照のこと.

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
メッセージの出力
文字型変数の操作
Definition dc_string.f90:83
種別型パラメタを提供します。
Definition dc_types.f90:55
integer, parameter, public token
単語やキーワードを保持する文字型変数の種別型パラメタ
Definition dc_types.f90:128
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:137
integer, parameter, public dp
倍精度実数型変数
Definition dc_types.f90:92

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