157
158 class(TspAdvType) :: this
159 real(DP), intent(out) :: dtmax
160 character(len=*), intent(inout) :: msg
161 real(DP), dimension(:), intent(in) :: thetam
162
163 integer(I4B) :: n
164 integer(I4B) :: m
165 integer(I4B) :: ipos
166 integer(I4B) :: nrmax
167 character(len=LINELENGTH) :: cellstr
168 real(DP) :: dt
169 real(DP) :: flowmax
170 real(DP) :: flowsumpos
171 real(DP) :: flowsumneg
172 real(DP) :: flownm
173 real(DP) :: cell_volume
174 dtmax = dnodata
175 nrmax = 0
176 msg = ''
177
178
179
180 if (this%ats_percel == dnodata) then
181 return
182 end if
183
184
185
186 do n = 1, this%dis%nodes
187 if (this%ibound(n) == 0) cycle
188 flowsumneg = dzero
189 flowsumpos = dzero
190 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
191 if (this%dis%con%mask(ipos) == 0) cycle
192 m = this%dis%con%ja(ipos)
193 if (this%ibound(m) == 0) cycle
194 flownm = this%fmi%gwfflowja(ipos)
195 if (flownm < dzero) then
196 flowsumneg = flowsumneg - flownm
197 else
198 flowsumpos = flowsumpos + flownm
199 end if
200 end do
201 flowmax = max(flowsumneg, flowsumpos)
202 if (flowmax < dprec) cycle
203 cell_volume = this%dis%get_cell_volume(n)
204 dt = cell_volume * this%fmi%gwfsat(n) * thetam(n) / flowmax
205 dt = dt * this%ats_percel
206 if (dt < dtmax) then
207 dtmax = dt
208 nrmax = n
209 end if
210 end do
211 if (nrmax > 0) then
212 call this%dis%noder_to_string(nrmax, cellstr)
213 write (msg, *) adjustl(trim(this%memoryPath))//'-'//trim(cellstr)
214 end if