MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
particlemodule Module Reference

Data Types

type  particletype
 Particle tracked by the PRT model. More...
 
type  particlestoretype
 Structure of arrays to store particles. More...
 

Functions/Subroutines

subroutine, public create_particle (particle)
 Create a new particle. More...
 
subroutine, public allocate_particle_store (this, np, mempath)
 Create a new particle store. More...
 
subroutine deallocate (this, mempath)
 Deallocate particle arrays. More...
 
subroutine resize (this, np, mempath)
 Reallocate particle arrays. More...
 
subroutine load_particle (this, store, imdl, iprp, ip)
 Load a particle from the particle store. More...
 
subroutine save_particle (this, particle, ip)
 Save a particle's state to the particle store. More...
 
subroutine transform_coords (this, xorigin, yorigin, zorigin, sinrot, cosrot, invert)
 Transform particle coordinates. More...
 
subroutine reset_transform (this)
 
subroutine get_model_coords (this, x, y, z)
 Return the particle's model coordinates. More...
 
integer function num_stored (this)
 

Variables

integer, parameter, public levelmax = 4
 

Function/Subroutine Documentation

◆ allocate_particle_store()

subroutine, public particlemodule::allocate_particle_store ( type(particlestoretype), pointer  this,
integer(i4b), intent(in)  np,
character(*), intent(in)  mempath 
)
Parameters
thisstore
[in]npnumber of particles
[in]mempathpath to memory

Definition at line 126 of file Particle.f90.

127  type(ParticleStoreType), pointer :: this !< store
128  integer(I4B), intent(in) :: np !< number of particles
129  character(*), intent(in) :: mempath !< path to memory
130 
131  allocate (this)
132  call mem_allocate(this%imdl, np, 'PLIMDL', mempath)
133  call mem_allocate(this%irpt, np, 'PLIRPT', mempath)
134  call mem_allocate(this%iprp, np, 'PLIPRP', mempath)
135  call mem_allocate(this%name, lenboundname, np, 'PLNAME', mempath)
136  call mem_allocate(this%icp, np, 'PLICP', mempath)
137  call mem_allocate(this%icu, np, 'PLICU', mempath)
138  call mem_allocate(this%ilay, np, 'PLILAY', mempath)
139  call mem_allocate(this%izone, np, 'PLIZONE', mempath)
140  call mem_allocate(this%izp, np, 'PLIZP', mempath)
141  call mem_allocate(this%istatus, np, 'PLISTATUS', mempath)
142  call mem_allocate(this%x, np, 'PLX', mempath)
143  call mem_allocate(this%y, np, 'PLY', mempath)
144  call mem_allocate(this%z, np, 'PLZ', mempath)
145  call mem_allocate(this%trelease, np, 'PLTRELEASE', mempath)
146  call mem_allocate(this%tstop, np, 'PLTSTOP', mempath)
147  call mem_allocate(this%ttrack, np, 'PLTTRACK', mempath)
148  call mem_allocate(this%istopweaksink, np, 'PLISTOPWEAKSINK', mempath)
149  call mem_allocate(this%istopzone, np, 'PLISTOPZONE', mempath)
150  call mem_allocate(this%idrymeth, np, 'PLIDRYMETH', mempath)
151  call mem_allocate(this%ifrctrn, np, 'PLIFRCTRN', mempath)
152  call mem_allocate(this%iexmeth, np, 'PLIEXMETH', mempath)
153  call mem_allocate(this%extol, np, 'PLEXTOL', mempath)
154  call mem_allocate(this%extend, np, 'PLIEXTEND', mempath)
155  call mem_allocate(this%idomain, np, levelmax, 'PLIDOMAIN', mempath)
156  call mem_allocate(this%iboundary, np, levelmax, 'PLIBOUNDARY', mempath)
Here is the caller graph for this function:

◆ create_particle()

subroutine, public particlemodule::create_particle ( type(particletype), pointer  particle)

Definition at line 118 of file Particle.f90.

119  type(ParticleType), pointer :: particle !< particle
120  allocate (particle)
121  allocate (particle%idomain(levelmax))
122  allocate (particle%iboundary(levelmax))
Here is the caller graph for this function:

◆ deallocate()

subroutine particlemodule::deallocate ( class(particlestoretype), intent(inout)  this,
character(*), intent(in)  mempath 
)
private
Parameters
[in,out]thisstore
[in]mempathpath to memory

Definition at line 160 of file Particle.f90.

161  class(ParticleStoreType), intent(inout) :: this !< store
162  character(*), intent(in) :: mempath !< path to memory
163 
164  call mem_deallocate(this%imdl, 'PLIMDL', mempath)
165  call mem_deallocate(this%iprp, 'PLIPRP', mempath)
166  call mem_deallocate(this%irpt, 'PLIRPT', mempath)
167  call mem_deallocate(this%name, 'PLNAME', mempath)
168  call mem_deallocate(this%icp, 'PLICP', mempath)
169  call mem_deallocate(this%icu, 'PLICU', mempath)
170  call mem_deallocate(this%ilay, 'PLILAY', mempath)
171  call mem_deallocate(this%izone, 'PLIZONE', mempath)
172  call mem_deallocate(this%izp, 'PLIZP', mempath)
173  call mem_deallocate(this%istatus, 'PLISTATUS', mempath)
174  call mem_deallocate(this%x, 'PLX', mempath)
175  call mem_deallocate(this%y, 'PLY', mempath)
176  call mem_deallocate(this%z, 'PLZ', mempath)
177  call mem_deallocate(this%trelease, 'PLTRELEASE', mempath)
178  call mem_deallocate(this%tstop, 'PLTSTOP', mempath)
179  call mem_deallocate(this%ttrack, 'PLTTRACK', mempath)
180  call mem_deallocate(this%istopweaksink, 'PLISTOPWEAKSINK', mempath)
181  call mem_deallocate(this%istopzone, 'PLISTOPZONE', mempath)
182  call mem_deallocate(this%idrymeth, 'PLIDRYMETH', mempath)
183  call mem_deallocate(this%ifrctrn, 'PLIFRCTRN', mempath)
184  call mem_deallocate(this%iexmeth, 'PLIEXMETH', mempath)
185  call mem_deallocate(this%extol, 'PLEXTOL', mempath)
186  call mem_deallocate(this%extend, 'PLIEXTEND', mempath)
187  call mem_deallocate(this%idomain, 'PLIDOMAIN', mempath)
188  call mem_deallocate(this%iboundary, 'PLIBOUNDARY', mempath)

◆ get_model_coords()

subroutine particlemodule::get_model_coords ( class(particletype), intent(inout)  this,
real(dp), intent(out)  x,
real(dp), intent(out)  y,
real(dp), intent(out)  z 
)
private
Parameters
[in,out]thisparticle
[out]xx coordinate
[out]yy coordinate
[out]zz coordinate

Definition at line 353 of file Particle.f90.

354  use geomutilmodule, only: transform, compose
355  class(ParticleType), intent(inout) :: this !< particle
356  real(DP), intent(out) :: x !< x coordinate
357  real(DP), intent(out) :: y !< y coordinate
358  real(DP), intent(out) :: z !< z coordinate
359 
360  if (this%transformed) then
361  ! Untransform coordinates
362  call transform(this%x, this%y, this%z, x, y, z, &
363  this%xorigin, this%yorigin, this%zorigin, &
364  this%sinrot, this%cosrot, invert=.true.)
365  else
366  x = this%x
367  y = this%y
368  z = this%z
369  end if
subroutine, public transform(xin, yin, zin, xout, yout, zout, xorigin, yorigin, zorigin, sinrot, cosrot, invert)
Apply a 3D translation and optional 2D rotation to coordinates.
Definition: GeomUtil.f90:183
subroutine, public compose(xorigin, yorigin, zorigin, sinrot, cosrot, xorigin_new, yorigin_new, zorigin_new, sinrot_new, cosrot_new, invert)
Apply a 3D translation and 2D rotation to an existing transformation.
Definition: GeomUtil.f90:243
Here is the call graph for this function:

◆ load_particle()

subroutine particlemodule::load_particle ( class(particletype), intent(inout)  this,
type(particlestoretype), intent(in)  store,
integer(i4b), intent(in)  imdl,
integer(i4b), intent(in)  iprp,
integer(i4b), intent(in)  ip 
)
private

This routine is used to initialize a particle for tracking. The advancing flag and coordinate transformation are reset.

Parameters
[in,out]thisparticle
[in]storeparticle storage
[in]imdlindex of model particle originated in
[in]iprpindex of particle release package particle originated in
[in]ipindex into the particle list

Definition at line 231 of file Particle.f90.

232  class(ParticleType), intent(inout) :: this !< particle
233  type(ParticleStoreType), intent(in) :: store !< particle storage
234  integer(I4B), intent(in) :: imdl !< index of model particle originated in
235  integer(I4B), intent(in) :: iprp !< index of particle release package particle originated in
236  integer(I4B), intent(in) :: ip !< index into the particle list
237 
238  call this%reset_transform()
239  this%imdl = imdl
240  this%iprp = iprp
241  this%irpt = store%irpt(ip)
242  this%ip = ip
243  this%name = store%name(ip)
244  this%istopweaksink = store%istopweaksink(ip)
245  this%istopzone = store%istopzone(ip)
246  this%idrymeth = store%idrymeth(ip)
247  this%icp = store%icp(ip)
248  this%icu = store%icu(ip)
249  this%ilay = store%ilay(ip)
250  this%izone = store%izone(ip)
251  this%izp = store%izp(ip)
252  this%istatus = store%istatus(ip)
253  this%x = store%x(ip)
254  this%y = store%y(ip)
255  this%z = store%z(ip)
256  this%trelease = store%trelease(ip)
257  this%tstop = store%tstop(ip)
258  this%ttrack = store%ttrack(ip)
259  this%advancing = .true.
260  this%idomain(1:levelmax) = &
261  store%idomain(ip, 1:levelmax)
262  this%idomain(1) = imdl
263  this%iboundary(1:levelmax) = &
264  store%iboundary(ip, 1:levelmax)
265  this%ifrctrn = store%ifrctrn(ip)
266  this%iexmeth = store%iexmeth(ip)
267  this%extol = store%extol(ip)
268  this%iextend = store%extend(ip)

◆ num_stored()

integer function particlemodule::num_stored ( class(particlestoretype this)

Definition at line 372 of file Particle.f90.

373  class(ParticleStoreType) :: this
374  n = size(this%imdl)

◆ reset_transform()

subroutine particlemodule::reset_transform ( class(particletype), intent(inout)  this)
Parameters
[in,out]thisparticle

Definition at line 340 of file Particle.f90.

341  class(ParticleType), intent(inout) :: this !< particle
342 
343  this%xorigin = dzero
344  this%yorigin = dzero
345  this%zorigin = dzero
346  this%sinrot = dzero
347  this%cosrot = done
348  this%cosrot = done
349  this%transformed = .false.

◆ resize()

subroutine particlemodule::resize ( class(particlestoretype), intent(inout)  this,
integer(i4b), intent(in)  np,
character(*), intent(in)  mempath 
)
private
Parameters
[in,out]thisparticle store
[in]npnumber of particles
[in]mempathpath to memory

Definition at line 192 of file Particle.f90.

193  ! dummy
194  class(ParticleStoreType), intent(inout) :: this !< particle store
195  integer(I4B), intent(in) :: np !< number of particles
196  character(*), intent(in) :: mempath !< path to memory
197 
198  ! resize arrays
199  call mem_reallocate(this%imdl, np, 'PLIMDL', mempath)
200  call mem_reallocate(this%iprp, np, 'PLIPRP', mempath)
201  call mem_reallocate(this%irpt, np, 'PLIRPT', mempath)
202  call mem_reallocate(this%name, lenboundname, np, 'PLNAME', mempath)
203  call mem_reallocate(this%icp, np, 'PLICP', mempath)
204  call mem_reallocate(this%icu, np, 'PLICU', mempath)
205  call mem_reallocate(this%ilay, np, 'PLILAY', mempath)
206  call mem_reallocate(this%izone, np, 'PLIZONE', mempath)
207  call mem_reallocate(this%izp, np, 'PLIZP', mempath)
208  call mem_reallocate(this%istatus, np, 'PLISTATUS', mempath)
209  call mem_reallocate(this%x, np, 'PLX', mempath)
210  call mem_reallocate(this%y, np, 'PLY', mempath)
211  call mem_reallocate(this%z, np, 'PLZ', mempath)
212  call mem_reallocate(this%trelease, np, 'PLTRELEASE', mempath)
213  call mem_reallocate(this%tstop, np, 'PLTSTOP', mempath)
214  call mem_reallocate(this%ttrack, np, 'PLTTRACK', mempath)
215  call mem_reallocate(this%istopweaksink, np, 'PLISTOPWEAKSINK', mempath)
216  call mem_reallocate(this%istopzone, np, 'PLISTOPZONE', mempath)
217  call mem_reallocate(this%idrymeth, np, 'PLIDRYMETH', mempath)
218  call mem_reallocate(this%ifrctrn, np, 'PLIFRCTRN', mempath)
219  call mem_reallocate(this%iexmeth, np, 'PLIEXMETH', mempath)
220  call mem_reallocate(this%extol, np, 'PLEXTOL', mempath)
221  call mem_reallocate(this%extend, np, 'PLIEXTEND', mempath)
222  call mem_reallocate(this%idomain, np, levelmax, 'PLIDOMAIN', mempath)
223  call mem_reallocate(this%iboundary, np, levelmax, 'PLIBOUNDARY', mempath)

◆ save_particle()

subroutine particlemodule::save_particle ( class(particlestoretype), intent(inout)  this,
type(particletype), intent(in)  particle,
integer(i4b), intent(in)  ip 
)
private
Parameters
[in,out]thisparticle storage
[in]ipparticle index

Definition at line 272 of file Particle.f90.

273  class(ParticleStoreType), intent(inout) :: this !< particle storage
274  type(ParticleType), intent(in) :: particle !< particle
275  integer(I4B), intent(in) :: ip !< particle index
276 
277  this%imdl(ip) = particle%imdl
278  this%iprp(ip) = particle%iprp
279  this%irpt(ip) = particle%irpt
280  this%name(ip) = particle%name
281  this%istopweaksink(ip) = particle%istopweaksink
282  this%istopzone(ip) = particle%istopzone
283  this%idrymeth(ip) = particle%idrymeth
284  this%icp(ip) = particle%icp
285  this%icu(ip) = particle%icu
286  this%ilay(ip) = particle%ilay
287  this%izone(ip) = particle%izone
288  this%izp(ip) = particle%izp
289  this%istatus(ip) = particle%istatus
290  this%x(ip) = particle%x
291  this%y(ip) = particle%y
292  this%z(ip) = particle%z
293  this%trelease(ip) = particle%trelease
294  this%tstop(ip) = particle%tstop
295  this%ttrack(ip) = particle%ttrack
296  this%idomain( &
297  ip, &
298  1:levelmax) = &
299  particle%idomain(1:levelmax)
300  this%iboundary( &
301  ip, &
302  1:levelmax) = &
303  particle%iboundary(1:levelmax)
304  this%ifrctrn(ip) = particle%ifrctrn
305  this%iexmeth(ip) = particle%iexmeth
306  this%extol(ip) = particle%extol
307  this%extend(ip) = particle%iextend

◆ transform_coords()

subroutine particlemodule::transform_coords ( class(particletype), intent(inout)  this,
real(dp), intent(in), optional  xorigin,
real(dp), intent(in), optional  yorigin,
real(dp), intent(in), optional  zorigin,
real(dp), intent(in), optional  sinrot,
real(dp), intent(in), optional  cosrot,
logical(lgp), intent(in), optional  invert 
)
private

Apply a translation and/or rotation to particle coordinates. No rescaling. It's also possible to invert a transformation. Be sure to reset the transformation after using it.

Parameters
[in,out]thisparticle
[in]xoriginx coordinate of origin
[in]yoriginy coordinate of origin
[in]zoriginz coordinate of origin
[in]sinrotsine of rotation angle
[in]cosrotcosine of rotation angle
[in]invertwhether to invert

Definition at line 316 of file Particle.f90.

318  use geomutilmodule, only: transform, compose
319  class(ParticleType), intent(inout) :: this !< particle
320  real(DP), intent(in), optional :: xorigin !< x coordinate of origin
321  real(DP), intent(in), optional :: yorigin !< y coordinate of origin
322  real(DP), intent(in), optional :: zorigin !< z coordinate of origin
323  real(DP), intent(in), optional :: sinrot !< sine of rotation angle
324  real(DP), intent(in), optional :: cosrot !< cosine of rotation angle
325  logical(LGP), intent(in), optional :: invert !< whether to invert
326 
327  call transform(this%x, this%y, this%z, &
328  this%x, this%y, this%z, &
329  xorigin, yorigin, zorigin, &
330  sinrot, cosrot, invert)
331 
332  call compose(this%xorigin, this%yorigin, this%zorigin, &
333  this%sinrot, this%cosrot, &
334  xorigin, yorigin, zorigin, &
335  sinrot, cosrot, invert)
336 
337  this%transformed = .true.
Here is the call graph for this function:

Variable Documentation

◆ levelmax

integer, parameter, public particlemodule::levelmax = 4

Definition at line 14 of file Particle.f90.

14  integer, parameter, public :: levelmax = 4