MODFLOW 6  version 6.7.0.dev1
USGS Modular Hydrologic Model
MethodCell.f90
Go to the documentation of this file.
2 
3  use kindmodule, only: dp, i4b, lgp
4  use constantsmodule, only: done, dzero
5  use methodmodule, only: methodtype
8  implicit none
9 
10  private
11  public :: methodcelltype
12 
13  type, abstract, extends(methodtype) :: methodcelltype
14  contains
15  procedure, public :: check
16  end type methodcelltype
17 
18 contains
19 
20  !> @brief Check reporting/terminating conditions before tracking
21  !! the particle across the cell.
22  !!
23  !! Check a number of conditions determining whether to continue
24  !! tracking the particle or terminate it, as well as whether to
25  !! record any output data as per selected reporting conditions.
26  !<
27  subroutine check(this, particle, cell_defn, tmax)
28  ! modules
32  ! dummy
33  class(methodcelltype), intent(inout) :: this
34  type(particletype), pointer, intent(inout) :: particle
35  type(celldefntype), pointer, intent(inout) :: cell_defn
36  real(DP), intent(in) :: tmax
37  ! local
38  logical(LGP) :: dry_cell, dry_particle, no_exit_face, stop_zone, weak_sink
39  integer(I4B) :: i
40  real(DP) :: t, ttrackmax
41 
42  dry_cell = this%fmi%ibdgwfsat0(cell_defn%icell) == 0
43  dry_particle = particle%z > cell_defn%top
44  no_exit_face = cell_defn%inoexitface > 0
45  stop_zone = cell_defn%izone > 0 .and. particle%istopzone == cell_defn%izone
46  weak_sink = cell_defn%iweaksink > 0
47 
48  particle%izone = cell_defn%izone
49  if (stop_zone) then
50  particle%advancing = .false.
51  particle%istatus = term_stopzone
52  call this%save(particle, reason=3)
53  return
54  end if
55 
56  if (no_exit_face .and. .not. dry_cell) then
57  particle%advancing = .false.
58  particle%istatus = term_no_exits
59  call this%save(particle, reason=3)
60  return
61  end if
62 
63  if (weak_sink) then
64  if (particle%istopweaksink > 0) then
65  particle%advancing = .false.
66  particle%istatus = term_weaksink
67  call this%save(particle, reason=3)
68  return
69  else
70  call this%save(particle, reason=4)
71  end if
72  end if
73 
74  if (dry_cell) then
75  if (particle%idrymeth == 0) then
76  ! drop to cell bottom. handled by pass
77  ! to bottom method, nothing to do here
78  no_exit_face = .false.
79  else if (particle%idrymeth == 1) then
80  ! stop
81  particle%advancing = .false.
82  particle%istatus = term_inactive
83  call this%save(particle, reason=3)
84  return
85  else if (particle%idrymeth == 2) then
86  ! stay
87  particle%advancing = .false.
88  no_exit_face = .false.
89 
90  ! we might report tracking times
91  ! out of order here, but we want
92  ! the particle termination event
93  ! (if this is the last time step)
94  ! to have the maximum tracking t,
95  ! so we need to keep tabs on it.
96  ttrackmax = totim
97 
98  ! update tracking time to time
99  ! step end time and save record
100  particle%ttrack = totim
101  call this%save(particle, reason=2)
102 
103  ! record user tracking times
104  call this%tracktimes%advance()
105  if (this%tracktimes%any()) then
106  do i = this%tracktimes%selection(1), this%tracktimes%selection(2)
107  t = this%tracktimes%times(i)
108  if (t < totimc) cycle
109  if (t >= tmax) exit
110  particle%ttrack = t
111  call this%save(particle, reason=5)
112  if (t > ttrackmax) ttrackmax = t
113  end do
114  end if
115 
116  ! terminate if last period/step
117  if (endofsimulation) then
118  particle%istatus = term_no_exits
119  particle%ttrack = ttrackmax
120  call this%save(particle, reason=3)
121  return
122  end if
123  end if
124  else if (dry_particle .and. this%name /= "passtobottom") then
125  if (particle%idrymeth == 0) then
126  ! drop to water table
127  particle%z = cell_defn%top
128  call this%save(particle, reason=1)
129  else if (particle%idrymeth == 1) then
130  ! stop
131  particle%advancing = .false.
132  particle%istatus = term_inactive
133  call this%save(particle, reason=3)
134  return
135  else if (particle%idrymeth == 2) then
136  ! stay
137  particle%advancing = .false.
138  no_exit_face = .false.
139 
140  ! we might report tracking times
141  ! out of order here, but we want
142  ! the particle termination event
143  ! (if this is the last time step)
144  ! to have the maximum tracking t,
145  ! so we need to keep tabs on it.
146  ttrackmax = totim
147 
148  ! update tracking time to time
149  ! step end time and save record
150  particle%ttrack = totim
151  call this%save(particle, reason=2)
152 
153  ! record user tracking times
154  call this%tracktimes%advance()
155  if (this%tracktimes%any()) then
156  do i = this%tracktimes%selection(1), this%tracktimes%selection(2)
157  t = this%tracktimes%times(i)
158  if (t < totimc) cycle
159  if (t >= tmax) exit
160  particle%ttrack = t
161  call this%save(particle, reason=5)
162  if (t > ttrackmax) ttrackmax = t
163  end do
164  end if
165  end if
166  end if
167 
168  if (no_exit_face) then
169  particle%advancing = .false.
170  particle%istatus = term_no_exits
171  call this%save(particle, reason=3)
172  return
173  end if
174 
175  end subroutine check
176 
177 end module methodcellmodule
This module contains simulation constants.
Definition: Constants.f90:9
real(dp), parameter dzero
real constant zero
Definition: Constants.f90:65
real(dp), parameter done
real constant 1
Definition: Constants.f90:76
This module defines variable data types.
Definition: kind.f90:8
subroutine check(this, particle, cell_defn, tmax)
Check reporting/terminating conditions before tracking the particle across the cell.
Definition: MethodCell.f90:28
Particle tracking strategies.
Definition: Method.f90:2
@ term_weaksink
terminated in a weak sink cell
Definition: Particle.f90:34
@ term_inactive
terminated in an inactive cell
Definition: Particle.f90:37
@ term_no_exits
terminated in a cell with no exit face
Definition: Particle.f90:35
@ term_stopzone
terminated in a cell with a stop zone number
Definition: Particle.f90:36
logical(lgp), pointer, public endofsimulation
flag indicating end of simulation
Definition: tdis.f90:28
real(dp), pointer, public totim
time relative to start of simulation
Definition: tdis.f90:32
real(dp), pointer, public totimc
simulation time at start of time step
Definition: tdis.f90:33
Base grid cell definition.
Definition: CellDefn.f90:10
Base type for particle tracking methods.
Definition: Method.f90:31
Particle tracked by the PRT model.
Definition: Particle.f90:78