MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
trackmodule Module Reference

Data Types

type  trackfiletype
 Output file containing all or some particle pathlines. More...
 
type  trackfilecontroltype
 Manages particle track (i.e. pathline) files. More...
 

Functions/Subroutines

subroutine init_track_file (this, iun, csv, iprp)
 Initialize a new track file. More...
 
subroutine expand (this, increment)
 Expand the trackfile array, internal use only. More...
 
subroutine, private save_record (iun, particle, kper, kstp, reason, csv)
 Save record to binary or CSV file, internal use only. More...
 
subroutine save (this, particle, kper, kstp, reason, level)
 Save the particle's state to track output file(s). More...
 
subroutine set_track_events (this, release, transit, timestep, terminate, weaksink, usertime)
 Configure particle events to track. More...
 

Variables

character(len= *), parameter, public trackheader = 'kper,kstp,imdl,iprp,irpt,ilay,icell,izone,istatus,ireason,trelease,t,x,y,z,name'
 
character(len= *), parameter, public trackdtypes = '<i4,<i4,<i4,<i4,<i4,<i4,<i4,<i4,<i4,<i4,<f8,<f8,<f8,<f8,<f8,|S40'
 

Function/Subroutine Documentation

◆ expand()

subroutine trackmodule::expand ( class(trackfilecontroltype this,
integer(i4b), intent(in), optional  increment 
)

Definition at line 151 of file TrackData.f90.

152  ! -- dummy
153  class(TrackFileControlType) :: this
154  integer(I4B), optional, intent(in) :: increment
155  ! -- local
156  integer(I4B) :: inclocal
157  integer(I4B) :: isize
158  integer(I4B) :: newsize
159  type(TrackFileType), allocatable, dimension(:) :: temp
160 
161  ! -- initialize
162  if (present(increment)) then
163  inclocal = increment
164  else
165  inclocal = 1
166  end if
167 
168  ! -- increase size of array
169  if (allocated(this%trackfiles)) then
170  isize = size(this%trackfiles)
171  newsize = isize + inclocal
172  allocate (temp(newsize))
173  temp(1:isize) = this%trackfiles
174  deallocate (this%trackfiles)
175  call move_alloc(temp, this%trackfiles)
176  else
177  allocate (this%trackfiles(inclocal))
178  end if
179 

◆ init_track_file()

subroutine trackmodule::init_track_file ( class(trackfilecontroltype this,
integer(i4b), intent(in)  iun,
logical(lgp), intent(in), optional  csv,
integer(i4b), intent(in), optional  iprp 
)

Definition at line 122 of file TrackData.f90.

123  ! -- dummy
124  class(TrackFileControlType) :: this
125  integer(I4B), intent(in) :: iun
126  logical(LGP), intent(in), optional :: csv
127  integer(I4B), intent(in), optional :: iprp
128  ! -- local
129  type(TrackFileType), pointer :: file
130 
131  ! -- allocate or expand array
132  if (.not. allocated(this%trackfiles)) then
133  allocate (this%trackfiles(1))
134  else
135  call this%expand(increment=1)
136  end if
137 
138  ! -- setup new file
139  allocate (file)
140  file%iun = iun
141  if (present(csv)) file%csv = csv
142  if (present(iprp)) file%iprp = iprp
143 
144  ! -- update array and counter
145  this%ntrackfiles = size(this%trackfiles)
146  this%trackfiles(this%ntrackfiles) = file
147 

◆ save()

subroutine trackmodule::save ( class(trackfilecontroltype), intent(inout)  this,
type(particletype), intent(in), pointer  particle,
integer(i4b), intent(in)  kper,
integer(i4b), intent(in)  kstp,
integer(i4b), intent(in)  reason,
integer(i4b), intent(in), optional  level 
)

A record is saved to all enabled model-level files and to any PRP-level files with PRP index matching the particle's PRP index.

Definition at line 253 of file TrackData.f90.

254  ! -- dummy
255  class(TrackFileControlType), intent(inout) :: this
256  type(ParticleType), pointer, intent(in) :: particle
257  integer(I4B), intent(in) :: kper
258  integer(I4B), intent(in) :: kstp
259  integer(I4B), intent(in) :: reason
260  integer(I4B), intent(in), optional :: level
261  ! -- local
262  integer(I4B) :: i
263  type(TrackFileType) :: file
264 
265  ! -- Only save if reporting is enabled for specified event.
266  if (.not. ((this%trackrelease .and. reason == 0) .or. &
267  (this%tracktransit .and. reason == 1) .or. &
268  (this%tracktimestep .and. reason == 2) .or. &
269  (this%trackterminate .and. reason == 3) .or. &
270  (this%trackweaksink .and. reason == 4) .or. &
271  (this%trackusertime .and. reason == 5))) &
272  return
273 
274  ! -- For now, only allow reporting from outside the tracking
275  ! algorithm (e.g. release time), in which case level will
276  ! not be provided, or if within the tracking solution, in
277  ! subcells (level 3) only. This may change if the subcell
278  ! ever delegates tracking to even smaller subcomponents.
279  if (present(level)) then
280  if (level .ne. 3) return
281  end if
282 
283  ! -- Save to any enabled model-scoped or PRP-scoped files
284  do i = 1, this%ntrackfiles
285  file = this%trackfiles(i)
286  if (file%iun > 0 .and. &
287  (file%iprp == -1 .or. &
288  file%iprp == particle%iprp)) &
289  call save_record(file%iun, particle, &
290  kper, kstp, reason, csv=file%csv)
291  end do
292 
Here is the call graph for this function:

◆ save_record()

subroutine, private trackmodule::save_record ( integer(i4b), intent(in)  iun,
type(particletype), intent(in), pointer  particle,
integer(i4b), intent(in)  kper,
integer(i4b), intent(in)  kstp,
integer(i4b), intent(in)  reason,
logical(lgp), intent(in)  csv 
)
private

Definition at line 183 of file TrackData.f90.

184  ! -- dummy
185  integer(I4B), intent(in) :: iun
186  type(ParticleType), pointer, intent(in) :: particle
187  integer(I4B), intent(in) :: kper
188  integer(I4B), intent(in) :: kstp
189  integer(I4B), intent(in) :: reason
190  logical(LGP), intent(in) :: csv
191  ! -- local
192  real(DP) :: x
193  real(DP) :: y
194  real(DP) :: z
195  integer(I4B) :: status
196 
197  ! -- Get model (global) coordinates
198  call particle%get_model_coords(x, y, z)
199 
200  ! -- Get status
201  if (particle%istatus .lt. 0) then
202  status = 1
203  else
204  status = particle%istatus
205  end if
206 
207  if (csv) then
208  write (iun, '(*(G0,:,","))') &
209  kper, &
210  kstp, &
211  particle%imdl, &
212  particle%iprp, &
213  particle%irpt, &
214  particle%ilay, &
215  particle%icu, &
216  particle%izone, &
217  status, &
218  reason, &
219  particle%trelease, &
220  particle%ttrack, &
221  x, &
222  y, &
223  z, &
224  trim(adjustl(particle%name))
225  else
226  write (iun) &
227  kper, &
228  kstp, &
229  particle%imdl, &
230  particle%iprp, &
231  particle%irpt, &
232  particle%ilay, &
233  particle%icu, &
234  particle%izone, &
235  status, &
236  reason, &
237  particle%trelease, &
238  particle%ttrack, &
239  x, &
240  y, &
241  z, &
242  particle%name
243  end if
244 
Here is the caller graph for this function:

◆ set_track_events()

subroutine trackmodule::set_track_events ( class(trackfilecontroltype this,
logical(lgp), intent(in)  release,
logical(lgp), intent(in)  transit,
logical(lgp), intent(in)  timestep,
logical(lgp), intent(in)  terminate,
logical(lgp), intent(in)  weaksink,
logical(lgp), intent(in)  usertime 
)

Each tracking event corresponds to an "ireason" code as appears in each row of track output.

Definition at line 300 of file TrackData.f90.

307  class(TrackFileControlType) :: this
308  logical(LGP), intent(in) :: release
309  logical(LGP), intent(in) :: transit
310  logical(LGP), intent(in) :: timestep
311  logical(LGP), intent(in) :: terminate
312  logical(LGP), intent(in) :: weaksink
313  logical(LGP), intent(in) :: usertime
314  this%trackrelease = release
315  this%tracktransit = transit
316  this%tracktimestep = timestep
317  this%trackterminate = terminate
318  this%trackweaksink = weaksink
319  this%trackusertime = usertime

Variable Documentation

◆ trackdtypes

character(len=*), parameter, public trackmodule::trackdtypes = '<i4,<i4,<i4,<i4,<i4,<i4,<i4,<i4,<i4,<i4,<f8,<f8,<f8,<f8,<f8,|S40'

Definition at line 61 of file TrackData.f90.

61  character(len=*), parameter, public :: TRACKDTYPES = &
62  '<i4,<i4,<i4,<i4,<i4,<i4,<i4,<i4,&
63  &<i4,<i4,<f8,<f8,<f8,<f8,<f8,|S40'

◆ trackheader

character(len=*), parameter, public trackmodule::trackheader = 'kper,kstp,imdl,iprp,irpt,ilay,icell,izone,istatus,ireason,trelease,t,x,y,z,name'

Definition at line 56 of file TrackData.f90.

56  character(len=*), parameter, public :: TRACKHEADER = &
57  'kper,kstp,imdl,iprp,irpt,ilay,icell,izone,&
58  &istatus,ireason,trelease,t,x,y,z,name'