86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136 use gtool_historyauto_internal, only: initialized, numdims, numvars, &
137 & varname_vars, output_valid_vars, origin_time_vars, histaddvar_vars, &
138 & newfile_inttime_vars, newfile_createtime_vars, prev_outtime_vars, &
139 & interval_time_vars, terminus_time_vars
141
142 implicit none
143 logical:: result
144 real(DP), intent(in):: time
145
146
147 character(*), intent(in):: varname
148
149
150
151 real(DP), parameter:: zero_time = 0.0_dp
152 integer:: i, vnum
153 integer, save:: svnum = 1
154 character(*), parameter:: subname = "HistoryAutoChkOutputTiming"
155 continue
156
157
158
159
160 if ( .not. initialized ) then
161 result = .false.
162 goto 999
163 end if
164
165
166
167
168 varsearch: do
169 do i = svnum, numvars
170 if ( trim( varname_vars(i) ) == trim(varname) ) then
171 vnum = i
172 exit varsearch
173 end if
174 end do
175 do i = 1, svnum - 1
176 if ( trim( varname_vars(i) ) == trim(varname) ) then
177 vnum = i
178 exit varsearch
179 end if
180 end do
181
182 result = .false.
183 goto 999
184 end do varsearch
185
186 svnum = vnum
187
188
189
190
191 result = output_valid_vars( vnum )
192
193 if ( .not. result ) goto 999
194
195 if ( origin_time_vars(vnum) > time ) then
196 result = .false.
197 goto 999
198 end if
199
200 if ( origin_time_vars(vnum) <= time &
201 & .and. ( terminus_time_vars(vnum) < zero_time &
202 & .or. terminus_time_vars(vnum) >= time ) &
203 & .and. .not. histaddvar_vars(vnum) ) then
204
205 result = .true.
206 goto 999
207 end if
208
209 if ( terminus_time_vars(vnum) > zero_time .and. terminus_time_vars(vnum) < time ) then
210 result = .false.
211 goto 999
212 end if
213
214 if ( newfile_inttime_vars(vnum) > zero_time ) then
215 if ( time - newfile_createtime_vars(vnum) >= newfile_inttime_vars(vnum) ) then
216 result = .true.
217 goto 999
218 end if
219 end if
220
221 if ( time - prev_outtime_vars(vnum) >= interval_time_vars(vnum) ) then
222 result = .true.
223 goto 999
224 end if
225
226 result = .false.
227
228999 continue