This subroutine consists partly of code written by David W. Pollock of the USGS for MODPATH 7. PRT's authors take responsibility for its application in this context and for any modifications or errors.
102 class(MethodSubcellPollockType),
intent(inout) :: this
103 class(SubcellRectType),
intent(in) :: subcell
104 type(ParticleType),
pointer,
intent(inout) :: particle
105 real(DP),
intent(in) :: tmax
107 real(DP) :: dt, dtexit, texit
108 real(DP) :: t, x, y, z
109 real(DP) :: t0, x0, y0, z0
110 integer(I4B) :: i, exit_face, exit_soln
111 type(LinearExitSolutionType) :: exit_x, exit_y, exit_z
114 x0 = particle%x / subcell%dx
115 y0 = particle%y / subcell%dy
116 z0 = particle%z / subcell%dz
119 call this%find_exits(particle, subcell)
121 exit_x = this%exit_solutions(1)
122 exit_y = this%exit_solutions(2)
123 exit_z = this%exit_solutions(3)
127 if (all([this%exit_solutions%status] == no_exit_no_outflow))
then
138 if (all([this%exit_solutions%status] == no_exit_stationary) .and. &
145 exit_soln = this%pick_exit(particle)
146 if (exit_soln == 0)
then
150 exit_face = this%exit_solutions(exit_soln)%iboundary
151 dtexit = this%exit_solutions(exit_soln)%dt
153 texit = particle%ttrack + dtexit
159 call this%tracktimes%advance()
160 if (this%tracktimes%any())
then
161 do i = this%tracktimes%selection(1), this%tracktimes%selection(2)
162 t = this%tracktimes%times(i)
163 if (t < particle%ttrack) cycle
164 if (t >= texit .or. t >= tmax)
exit
166 x = new_x(exit_x%v, exit_x%dvdx, subcell%vx1, subcell%vx2, &
167 dt, x0, subcell%dx, exit_x%status == 1)
168 y = new_x(exit_y%v, exit_y%dvdx, subcell%vy1, subcell%vy2, &
169 dt, y0, subcell%dy, exit_y%status == 1)
170 z = new_x(exit_z%v, exit_z%dvdx, subcell%vz1, subcell%vz2, &
171 dt, z0, subcell%dz, exit_z%status == 1)
172 particle%x = x * subcell%dx
173 particle%y = y * subcell%dy
174 particle%z = z * subcell%dz
177 call this%usertime(particle)
181 if (texit .gt. tmax)
then
187 x = new_x(exit_x%v, exit_x%dvdx, subcell%vx1, subcell%vx2, &
188 dt, x0, subcell%dx, exit_x%status == 1)
189 y = new_x(exit_y%v, exit_y%dvdx, subcell%vy1, subcell%vy2, &
190 dt, y0, subcell%dy, exit_y%status == 1)
191 z = new_x(exit_z%v, exit_z%dvdx, subcell%vz1, subcell%vz2, &
192 dt, z0, subcell%dz, exit_z%status == 1)
195 particle%advancing = .false.
199 particle%x = x * subcell%dx
200 particle%y = y * subcell%dy
201 particle%z = z * subcell%dz
203 particle%iboundary(level_subfeature) = exit_face
206 call this%timestep(particle)
213 if ((exit_face .eq. 1) .or. (exit_face .eq. 2))
then
215 y = new_x(exit_y%v, exit_y%dvdx, subcell%vy1, subcell%vy2, &
216 dt, y0, subcell%dy, exit_y%status == 1)
217 z = new_x(exit_z%v, exit_z%dvdx, subcell%vz1, subcell%vz2, &
218 dt, z0, subcell%dz, exit_z%status == 1)
219 if (exit_face .eq. 2) x = done
220 else if ((exit_face .eq. 3) .or. (exit_face .eq. 4))
then
221 x = new_x(exit_x%v, exit_x%dvdx, subcell%vx1, subcell%vx2, dt, &
222 x0, subcell%dx, exit_x%status == 1)
224 z = new_x(exit_z%v, exit_z%dvdx, subcell%vz1, subcell%vz2, dt, &
225 z0, subcell%dz, exit_z%status == 1)
226 if (exit_face .eq. 4) y = done
227 else if ((exit_face .eq. 5) .or. (exit_face .eq. 6))
then
228 x = new_x(exit_x%v, exit_x%dvdx, subcell%vx1, subcell%vx2, &
229 dt, x0, subcell%dx, exit_x%status == 1)
230 y = new_x(exit_y%v, exit_y%dvdx, subcell%vy1, subcell%vy2, &
231 dt, y0, subcell%dy, exit_y%status == 1)
233 if (exit_face .eq. 6) z = done
235 print *,
"programmer error, invalid exit face", exit_face
241 particle%x = x * subcell%dx
242 particle%y = y * subcell%dy
243 particle%z = z * subcell%dz
245 particle%iboundary(level_subfeature) = exit_face
248 call this%subcellexit(particle)
@, public featexit
particle exited a grid feature
@, public timestep
time step ended
@ term_timeout
terminated at stop time or end of simulation
@ term_no_exits_sub
terminated in a subcell with no exit face
logical(lgp), pointer, public endofsimulation
flag indicating end of simulation