MODFLOW 6  version 6.7.0.dev1
USGS Modular Hydrologic Model
TrackFile.f90
Go to the documentation of this file.
2  use kindmodule, only: dp, i4b, lgp
3  use constantsmodule, only: dzero, dpio180
5  use geomutilmodule, only: transform
6 
7  implicit none
8  public :: trackfiletype
9  public :: save_record
10 
11  !> @brief Output file containing all or some particle pathlines.
12  !!
13  !! Can be associated with a particle release point (PRP) package
14  !! or with an entire model, and can be binary or comma-separated.
15  !!
16  !! Each particle's pathline consists of 1+ records reported as the particle
17  !! is tracked over the model domain. Records are snapshots of the particle's
18  !! state (e.g. tracking status, position) at a particular moment in time.
19  !!
20  !! Particles have no ID property. Particles can be uniquely identified
21  !! by composite key, i.e. combination of fields:
22  !!
23  !! - imdl: originating model ID
24  !! - iprp: originating PRP ID
25  !! - irpt: particle release location ID
26  !! - trelease: particle release time
27  !<
28  type :: trackfiletype
29  private
30  integer(I4B), public :: iun = 0 !< file unit number
31  logical(LGP), public :: csv = .false. !< whether the file is binary or CSV
32  integer(I4B), public :: iprp = -1 !< -1 is model-level file, 0 is exchange PRP
33  end type trackfiletype
34 
35  character(len=*), parameter, public :: trackheader = &
36  'kper,kstp,imdl,iprp,irpt,ilay,icell,izone,&
37  &istatus,ireason,trelease,t,x,y,z,name'
38 
39  character(len=*), parameter, public :: trackdtypes = &
40  '<i4,<i4,<i4,<i4,<i4,<i4,<i4,<i4,&
41  &<i4,<i4,<f8,<f8,<f8,<f8,<f8,|S40'
42 
43 contains
44 
45  !> @brief Save a particle track record to a binary or CSV file.
46  subroutine save_record(iun, particle, kper, kstp, reason, csv)
47  ! dummy
48  integer(I4B), intent(in) :: iun
49  type(particletype), pointer, intent(in) :: particle
50  integer(I4B), intent(in) :: kper
51  integer(I4B), intent(in) :: kstp
52  integer(I4B), intent(in) :: reason
53  logical(LGP), intent(in) :: csv
54  ! local
55  real(dp) :: x, y, z
56  integer(I4B) :: status
57 
58  ! Convert from cell-local to model coordinates if needed
59  call particle%get_model_coords(x, y, z)
60 
61  ! Set status
62  if (particle%istatus .lt. 0) then
63  status = active
64  else
65  status = particle%istatus
66  end if
67 
68  if (csv) then
69  write (iun, '(*(G0,:,","))') &
70  kper, &
71  kstp, &
72  particle%imdl, &
73  particle%iprp, &
74  particle%irpt, &
75  particle%ilay, &
76  particle%icu, &
77  particle%izone, &
78  status, &
79  reason, &
80  particle%trelease, &
81  particle%ttrack, &
82  x, &
83  y, &
84  z, &
85  trim(adjustl(particle%name))
86  else
87  write (iun) &
88  kper, &
89  kstp, &
90  particle%imdl, &
91  particle%iprp, &
92  particle%irpt, &
93  particle%ilay, &
94  particle%icu, &
95  particle%izone, &
96  status, &
97  reason, &
98  particle%trelease, &
99  particle%ttrack, &
100  x, &
101  y, &
102  z, &
103  particle%name
104  end if
105  end subroutine
106 end module trackfilemodule
This module contains simulation constants.
Definition: Constants.f90:9
real(dp), parameter dpio180
real constant
Definition: Constants.f90:130
real(dp), parameter dzero
real constant zero
Definition: Constants.f90:65
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
This module defines variable data types.
Definition: kind.f90:8
subroutine, public save_record(iun, particle, kper, kstp, reason, csv)
Save a particle track record to a binary or CSV file.
Definition: TrackFile.f90:47
character(len= *), parameter, public trackdtypes
Definition: TrackFile.f90:39
character(len= *), parameter, public trackheader
Definition: TrackFile.f90:35
Particle tracked by the PRT model.
Definition: Particle.f90:78
Output file containing all or some particle pathlines.
Definition: TrackFile.f90:28