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

Data Types

type  prtoctype
 @ brief Output control for particle tracking models More...
 

Functions/Subroutines

subroutine, public oc_cr (ocobj, name_model, inunit, iout)
 @ brief Create an output control object More...
 
subroutine prt_oc_allocate_scalars (this, name_model)
 
subroutine oc_ar (this, mass, dis, dnodata)
 @ brief Setup output control variables. More...
 
subroutine prt_oc_da (this)
 
subroutine prt_oc_read_options (this)
 

Function/Subroutine Documentation

◆ oc_ar()

subroutine prtocmodule::oc_ar ( class(prtoctype this,
real(dp), dimension(:), intent(in), pointer, contiguous  mass,
class(disbasetype), intent(in), pointer  dis,
real(dp), intent(in)  dnodata 
)
private
Parameters
thisPrtOcType object
[in]massparticle mass
[in]dismodel discretization package
[in]dnodatano data value

Definition at line 108 of file prt-oc.f90.

109  ! -- dummy
110  class(PrtOcType) :: this !< PrtOcType object
111  real(DP), dimension(:), pointer, contiguous, intent(in) :: mass !< particle mass
112  class(DisBaseType), pointer, intent(in) :: dis !< model discretization package
113  real(DP), intent(in) :: dnodata !< no data value
114  ! -- local
115  integer(I4B) :: i, nocdobj, inodata
116  type(OutputControlDataType), pointer :: ocdobjptr
117  real(DP), dimension(:), pointer, contiguous :: nullvec => null()
118 
119  ! -- Allocate and initialize variables
120  allocate (this%tracktimes)
121  call this%tracktimes%init()
122  inodata = 0
123  nocdobj = 2
124  allocate (this%ocdobj(nocdobj))
125  do i = 1, nocdobj
126  call ocd_cr(ocdobjptr)
127  select case (i)
128  case (1)
129  call ocdobjptr%init_dbl('BUDGET', nullvec, dis, 'PRINT LAST ', &
130  'COLUMNS 10 WIDTH 11 DIGITS 4 GENERAL ', &
131  this%iout, dnodata)
132  case (2)
133  call ocdobjptr%init_dbl('MASS', mass, dis, 'PRINT LAST ', &
134  'COLUMNS 10 WIDTH 11 DIGITS 4 GENERAL ', &
135  this%iout, dnodata)
136  end select
137  this%ocdobj(i) = ocdobjptr
138  deallocate (ocdobjptr)
139  end do
140 
141  ! -- Read options or set defaults if this package not on
142  if (this%inunit > 0) then
143  call this%read_options()
144  end if
Here is the call graph for this function:

◆ oc_cr()

subroutine, public prtocmodule::oc_cr ( type(prtoctype), pointer  ocobj,
character(len=*), intent(in)  name_model,
integer(i4b), intent(in)  inunit,
integer(i4b), intent(in)  iout 
)
Parameters
ocobjPrtOcType object
[in]name_modelname of the model
[in]inunitunit number for input
[in]ioutunit number for output

Definition at line 45 of file prt-oc.f90.

46  type(PrtOcType), pointer :: ocobj !< PrtOcType object
47  character(len=*), intent(in) :: name_model !< name of the model
48  integer(I4B), intent(in) :: inunit !< unit number for input
49  integer(I4B), intent(in) :: iout !< unit number for output
50 
51  ! -- Create the object
52  allocate (ocobj)
53 
54  ! -- Allocate scalars
55  call ocobj%allocate_scalars(name_model)
56 
57  ! -- Save unit numbers
58  ocobj%inunit = inunit
59  ocobj%iout = iout
60 
61  ! -- Initialize block parser
62  call ocobj%parser%Initialize(inunit, iout)
Here is the caller graph for this function:

◆ prt_oc_allocate_scalars()

subroutine prtocmodule::prt_oc_allocate_scalars ( class(prtoctype this,
character(len=*), intent(in)  name_model 
)
private
Parameters
[in]name_modelname of model

Definition at line 65 of file prt-oc.f90.

66  class(PrtOcType) :: this
67  character(len=*), intent(in) :: name_model !< name of model
68 
69  this%memoryPath = create_mem_path(name_model, 'OC')
70 
71  allocate (this%name_model)
72  call mem_allocate(this%inunit, 'INUNIT', this%memoryPath)
73  call mem_allocate(this%iout, 'IOUT', this%memoryPath)
74  call mem_allocate(this%ibudcsv, 'IBUDCSV', this%memoryPath)
75  call mem_allocate(this%iperoc, 'IPEROC', this%memoryPath)
76  call mem_allocate(this%iocrep, 'IOCREP', this%memoryPath)
77  call mem_allocate(this%itrkout, 'ITRKOUT', this%memoryPath)
78  call mem_allocate(this%itrkhdr, 'ITRKHDR', this%memoryPath)
79  call mem_allocate(this%itrkcsv, 'ITRKCSV', this%memoryPath)
80  call mem_allocate(this%itrktls, 'ITRKTLS', this%memoryPath)
81  call mem_allocate(this%trackrelease, 'ITRACKRLS', this%memoryPath)
82  call mem_allocate(this%tracktransit, 'ITRACKTRS', this%memoryPath)
83  call mem_allocate(this%tracktimestep, 'ITRACKTST', this%memoryPath)
84  call mem_allocate(this%trackterminate, 'ITRACKTER', this%memoryPath)
85  call mem_allocate(this%trackweaksink, 'ITRACKWSK', this%memoryPath)
86  call mem_allocate(this%trackusertime, 'ITRACKTLS', this%memoryPath)
87 
88  this%name_model = name_model
89  this%inunit = 0
90  this%iout = 0
91  this%ibudcsv = 0
92  this%iperoc = 0
93  this%iocrep = 0
94  this%itrkout = 0
95  this%itrkhdr = 0
96  this%itrkcsv = 0
97  this%itrktls = 0
98  this%trackrelease = .false.
99  this%tracktransit = .false.
100  this%tracktimestep = .false.
101  this%trackterminate = .false.
102  this%trackweaksink = .false.
103  this%trackusertime = .false.
104 
Here is the call graph for this function:

◆ prt_oc_da()

subroutine prtocmodule::prt_oc_da ( class(prtoctype this)
private

Definition at line 147 of file prt-oc.f90.

148  ! -- dummy
149  class(PrtOcType) :: this
150  ! -- local
151  integer(I4B) :: i
152 
153  call this%tracktimes%destroy()
154 
155  do i = 1, size(this%ocdobj)
156  call this%ocdobj(i)%ocd_da()
157  end do
158  deallocate (this%ocdobj)
159 
160  deallocate (this%name_model)
161  call mem_deallocate(this%inunit)
162  call mem_deallocate(this%iout)
163  call mem_deallocate(this%ibudcsv)
164  call mem_deallocate(this%iperoc)
165  call mem_deallocate(this%iocrep)
166  call mem_deallocate(this%itrkout)
167  call mem_deallocate(this%itrkhdr)
168  call mem_deallocate(this%itrkcsv)
169  call mem_deallocate(this%itrktls)
170  call mem_deallocate(this%trackrelease)
171  call mem_deallocate(this%tracktransit)
172  call mem_deallocate(this%tracktimestep)
173  call mem_deallocate(this%trackterminate)
174  call mem_deallocate(this%trackweaksink)
175  call mem_deallocate(this%trackusertime)
176 

◆ prt_oc_read_options()

subroutine prtocmodule::prt_oc_read_options ( class(prtoctype this)
private

Definition at line 179 of file prt-oc.f90.

180  ! -- modules
181  use openspecmodule, only: access, form
183  use constantsmodule, only: linelength
187  ! -- dummy
188  class(PrtOcType) :: this
189  ! -- local
190  character(len=LINELENGTH) :: keyword
191  character(len=LINELENGTH) :: keyword2
192  character(len=LINELENGTH) :: fname
193  character(len=:), allocatable :: line
194  integer(I4B) :: i, ierr, ipos, ios, nlines
195  real(DP) :: dval
196  logical(LGP) :: isfound, found, endOfBlock, eventFound, success
197  type(OutputControlDataType), pointer :: ocdobjptr
198  ! -- formats
199  character(len=*), parameter :: fmttrkbin = &
200  "(4x, 'PARTICLE TRACKS WILL BE SAVED TO BINARY FILE: ', a, /4x, &
201  &'OPENED ON UNIT: ', I0)"
202  character(len=*), parameter :: fmttrkcsv = &
203  "(4x, 'PARTICLE TRACKS WILL BE SAVED TO CSV FILE: ', a, /4x, &
204  &'OPENED ON UNIT: ', I0)"
205 
206  ! -- get options block
207  call this%parser%GetBlock('OPTIONS', isfound, ierr, &
208  supportopenclose=.true., blockrequired=.false.)
209 
210  ! -- parse options block if detected
211  if (isfound) then
212  write (this%iout, '(/,1x,a,/)') 'PROCESSING OC OPTIONS'
213  eventfound = .false.
214  do
215  call this%parser%GetNextLine(endofblock)
216  if (endofblock) exit
217  call this%parser%GetStringCaps(keyword)
218  found = .false.
219  select case (keyword)
220  case ('BUDGETCSV')
221  call this%parser%GetStringCaps(keyword2)
222  if (keyword2 /= 'FILEOUT') then
223  errmsg = "BUDGETCSV must be followed by FILEOUT and then budget &
224  &csv file name. Found '"//trim(keyword2)//"'."
225  call store_error(errmsg)
226  call this%parser%StoreErrorUnit()
227  end if
228  call this%parser%GetString(fname)
229  this%ibudcsv = getunit()
230  call openfile(this%ibudcsv, this%iout, fname, 'CSV', &
231  filstat_opt='REPLACE')
232  found = .true.
233  case ('TRACK')
234  call this%parser%GetStringCaps(keyword)
235  if (keyword == 'FILEOUT') then
236  ! parse filename
237  call this%parser%GetString(fname)
238  ! open binary track output file
239  this%itrkout = getunit()
240  call openfile(this%itrkout, this%iout, fname, 'DATA(BINARY)', &
241  form, access, filstat_opt='REPLACE', &
242  mode_opt=mnormal)
243  write (this%iout, fmttrkbin) trim(adjustl(fname)), this%itrkout
244  ! open and write ascii track header file
245  this%itrkhdr = getunit()
246  fname = trim(fname)//'.hdr'
247  call openfile(this%itrkhdr, this%iout, fname, 'CSV', &
248  filstat_opt='REPLACE', mode_opt=mnormal)
249  write (this%itrkhdr, '(a,/,a)') trackheader, trackdtypes
250  else
251  call store_error('OPTIONAL TRACK KEYWORD MUST BE '// &
252  'FOLLOWED BY FILEOUT')
253  end if
254  found = .true.
255  case ('TRACKCSV')
256  call this%parser%GetStringCaps(keyword)
257  if (keyword == 'FILEOUT') then
258  ! parse filename
259  call this%parser%GetString(fname)
260  ! open CSV track output file and write headers
261  this%itrkcsv = getunit()
262  call openfile(this%itrkcsv, this%iout, fname, 'CSV', &
263  filstat_opt='REPLACE')
264  write (this%iout, fmttrkcsv) trim(adjustl(fname)), this%itrkcsv
265  write (this%itrkcsv, '(a)') trackheader
266  else
267  call store_error('OPTIONAL TRACKCSV KEYWORD MUST BE &
268  &FOLLOWED BY FILEOUT')
269  end if
270  found = .true.
271  case ('TRACK_ALL')
272  eventfound = .false. ! defaults set below
273  found = .true.
274  case ('TRACK_RELEASE')
275  this%trackrelease = .true.
276  eventfound = .true.
277  found = .true.
278  case ('TRACK_TRANSIT')
279  this%tracktransit = .true.
280  eventfound = .true.
281  found = .true.
282  case ('TRACK_TIMESTEP')
283  this%tracktimestep = .true.
284  eventfound = .true.
285  found = .true.
286  case ('TRACK_TERMINATE')
287  this%trackterminate = .true.
288  eventfound = .true.
289  found = .true.
290  case ('TRACK_WEAKSINK')
291  this%trackweaksink = .true.
292  eventfound = .true.
293  found = .true.
294  case ('TRACK_USERTIME')
295  this%trackusertime = .true.
296  eventfound = .true.
297  found = .true.
298  case ('TRACK_TIMES')
299  ttloop: do
300  success = .false.
301  call this%parser%TryGetDouble(dval, success)
302  if (.not. success) exit ttloop
303  call this%tracktimes%expand()
304  this%tracktimes%times(size(this%tracktimes%times)) = dval
305  end do ttloop
306  if (.not. this%tracktimes%increasing()) then
307  errmsg = "TRACK TIMES MUST STRICTLY INCREASE"
308  call store_error(errmsg)
309  call this%parser%StoreErrorUnit(terminate=.true.)
310  end if
311  this%trackusertime = .true.
312  found = .true.
313  case ('TRACK_TIMESFILE')
314  call this%parser%GetString(fname)
315  call openfile(this%itrktls, this%iout, fname, 'TLS')
316  nlines = 0
317  ttfloop: do
318  read (this%itrktls, '(A)', iostat=ios) line
319  if (ios /= 0) exit ttfloop
320  nlines = nlines + 1
321  end do ttfloop
322  call this%tracktimes%expand(nlines)
323  rewind(this%itrktls)
324  allocate (character(len=LINELENGTH) :: line)
325  do i = 1, nlines
326  read (this%itrktls, '(A)') line
327  read (line, '(f30.0)') dval
328  this%tracktimes%times(i) = dval
329  end do
330  if (.not. this%tracktimes%increasing()) then
331  errmsg = "TRACK TIMES MUST STRICTLY INCREASE"
332  call store_error(errmsg)
333  call this%parser%StoreErrorUnit(terminate=.true.)
334  end if
335  this%trackusertime = .true.
336  found = .true.
337  case default
338  found = .false.
339  end select
340 
341  ! -- check if we're done
342  if (.not. found) then
343  do ipos = 1, size(this%ocdobj)
344  ocdobjptr => this%ocdobj(ipos)
345  if (keyword == trim(ocdobjptr%cname)) then
346  found = .true.
347  exit
348  end if
349  end do
350  if (.not. found) then
351  errmsg = "UNKNOWN OC OPTION '"//trim(keyword)//"'."
352  call store_error(errmsg)
353  call this%parser%StoreErrorUnit()
354  end if
355  call this%parser%GetRemainingLine(line)
356  call ocdobjptr%set_option(line, this%parser%iuactive, this%iout)
357  end if
358  end do
359 
360  ! -- default to all events
361  if (.not. eventfound) then
362  this%trackrelease = .true.
363  this%tracktransit = .true.
364  this%tracktimestep = .true.
365  this%trackterminate = .true.
366  this%trackweaksink = .true.
367  this%trackusertime = .true.
368  end if
369 
370  ! -- logging
371  write (this%iout, '(1x,a)') 'END OF OC OPTIONS'
372  end if
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition: Constants.f90:44
integer(i4b) function, public getunit()
Get a free unit number.
subroutine, public lowcase(word)
Convert to lower case.
subroutine, public openfile(iu, iout, fname, ftype, fmtarg_opt, accarg_opt, filstat_opt, mode_opt)
Open a file.
Definition: InputOutput.f90:30
character(len=20) access
Definition: OpenSpec.f90:7
character(len=20) form
Definition: OpenSpec.f90:7
This module contains simulation methods.
Definition: Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition: Sim.f90:92
subroutine, public store_error_unit(iunit, terminate)
Store the file unit number.
Definition: Sim.f90:168
character(len= *), parameter, public trackheader
Definition: TrackData.f90:56
character(len= *), parameter, public trackdtypes
Definition: TrackData.f90:61
Here is the call graph for this function: