16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
53 use dc_message, only: messagenotify
54 use dc_string, only: lchar
55 use dc_trace, only: beginsub, endsub
58 implicit none
59 integer, intent(in):: year
60 integer, intent(in):: month
61 integer, intent(in):: day
62 integer, intent(in):: hour
63 integer, intent(in):: min
64 real(DP), intent(in):: sec
65 type(DC_CAL_DATE), intent(out), optional, target:: date
66
67
68
69
70
71
72
73
74 character(*), intent(in), optional:: zone
75
76 logical, intent(out), optional:: err
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95 type(DC_CAL_DATE), pointer:: datep =>null()
96 integer:: start, length
97 integer:: stat
98 character(STRING):: cause_c
99 character(*), parameter:: version = &
100 & '$Name: $' // &
101 & '$Id: dccaldatecreate.f90,v 1.3 2010-09-24 07:07:31 morikawa Exp $'
102 character(*), parameter:: subname = 'DCCalDateCreate1'
103continue
104 call beginsub( subname, version )
106 cause_c = ''
107
108
109
110
111 if ( present( date ) ) then
112 datep => date
113 else
115 end if
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136 if ( month < 1 ) then
138 call messagenotify('W', subname, 'month=<%d> must be natural number', &
139 & i = (/ month /) )
140 goto 999
141 end if
142
143 if ( day < 1 ) then
145 call messagenotify('W', subname, 'day=<%d> must be natural number', &
146 & i = (/ day /) )
147 goto 999
148 end if
149
150 if ( hour < 0 ) then
152 call messagenotify('W', subname, 'hour=<%d> must not be negative', &
153 & i = (/ hour /) )
154 goto 999
155 end if
156
157 if ( min < 0 ) then
159 call messagenotify('W', subname, 'min=<%d> must not be negative', &
160 & i = (/ min /) )
161 goto 999
162 end if
163
164 if ( sec < 0.0_dp ) then
166 call messagenotify('W', subname, 'sec=<%f> must not be negative', &
167 & d = (/ sec /) )
168 goto 999
169 end if
170
171 call match(
'^[#+-]#d+:#d+$', zone, &
172 & start, length )
173 if ( length > 0 ) then
174 datep % zone = zone
175 else
176 datep % zone = ''
177 end if
178
179
180
181
182 datep % year = year
183 datep % month = month
184 datep % day = day
185 datep % hour = hour
186 datep % min = min
187 datep % sec = sec
188
189
190
191
192 datep % initialized = .true.
193999 continue
194 nullify( datep )
195 call storeerror( stat, subname, err, cause_c )
196 call endsub( subname )
type(dc_cal_date), target, save, public default_date
subroutine, public storeerror(number, where, err, cause_c, cause_i)
integer, parameter, public dc_ealreadyinit
integer, parameter, public dc_noerr
integer, parameter, public dc_ebaddate
シンプルな正規表現関数 'match' を提供します.
subroutine, public match(pattern, text, start, length)
integer, parameter, public dp
倍精度実数型変数
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ