MODFLOW 6  version 6.7.0.dev3
USGS Modular Hydrologic Model
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, dis, dnodata)
 @ brief Setup output control variables. More...
 
subroutine prt_oc_da (this)
 
subroutine prt_oc_read_options (this)
 
subroutine prt_oc_read_dimensions (this)
 Read the dimensions block. More...
 
subroutine prt_oc_read_tracktimes (this)
 Read the tracking times block. More...
 

Function/Subroutine Documentation

◆ oc_ar()

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

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

124  ! dummy
125  class(PrtOcType) :: this !< PrtOcType object
126  class(DisBaseType), pointer, intent(in) :: dis !< model discretization package
127  real(DP), intent(in) :: dnodata !< no data value
128  ! local
129  integer(I4B) :: i, nocdobj, inodata
130  type(OutputControlDataType), pointer :: ocdobjptr
131  real(DP), dimension(:), pointer, contiguous :: nullvec => null()
132 
133  ! Allocate and initialize variables
134  allocate (this%tracktimes)
135  call this%tracktimes%init()
136  inodata = 0
137  nocdobj = 1
138  allocate (this%ocds(nocdobj))
139  do i = 1, nocdobj
140  call ocd_cr(ocdobjptr)
141  select case (i)
142  case (1)
143  call ocdobjptr%init_dbl('BUDGET', nullvec, dis, 'PRINT LAST ', &
144  'COLUMNS 10 WIDTH 11 DIGITS 4 GENERAL ', &
145  this%iout, dnodata)
146  end select
147  this%ocds(i) = ocdobjptr
148  deallocate (ocdobjptr)
149  end do
150 
151  ! Read options, dimensions, and tracktimes
152  ! blocks if this package is enabled
153  if (this%inunit <= 0) return
154  call this%read_options()
155  call this%prt_oc_read_dimensions()
156  call this%prt_oc_read_tracktimes()
157 
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 52 of file prt-oc.f90.

53  type(PrtOcType), pointer :: ocobj !< PrtOcType object
54  character(len=*), intent(in) :: name_model !< name of the model
55  integer(I4B), intent(in) :: inunit !< unit number for input
56  integer(I4B), intent(in) :: iout !< unit number for output
57 
58  ! Create the object
59  allocate (ocobj)
60 
61  ! Allocate scalars
62  call ocobj%allocate_scalars(name_model)
63 
64  ! Save unit numbers
65  ocobj%inunit = inunit
66  ocobj%iout = iout
67 
68  ! Initialize block parser
69  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 72 of file prt-oc.f90.

73  class(PrtOcType) :: this
74  character(len=*), intent(in) :: name_model !< name of model
75 
76  this%memoryPath = create_mem_path(name_model, 'OC')
77 
78  allocate (this%name_model)
79  call mem_allocate(this%dump_event_trace, 'DUMP_EVENT_TRACE', this%memoryPath)
80  call mem_allocate(this%inunit, 'INUNIT', this%memoryPath)
81  call mem_allocate(this%iout, 'IOUT', this%memoryPath)
82  call mem_allocate(this%ibudcsv, 'IBUDCSV', this%memoryPath)
83  call mem_allocate(this%iperoc, 'IPEROC', this%memoryPath)
84  call mem_allocate(this%iocrep, 'IOCREP', this%memoryPath)
85  call mem_allocate(this%itrkout, 'ITRKOUT', this%memoryPath)
86  call mem_allocate(this%itrkhdr, 'ITRKHDR', this%memoryPath)
87  call mem_allocate(this%itrkcsv, 'ITRKCSV', this%memoryPath)
88  call mem_allocate(this%itrktls, 'ITRKTLS', this%memoryPath)
89  call mem_allocate(this%trackrelease, 'ITRACKRELEASE', this%memoryPath)
90  call mem_allocate(this%trackfeatexit, 'ITRACKFEATEXIT', this%memoryPath)
91  call mem_allocate(this%tracktimestep, 'ITRACKTIMESTEP', this%memoryPath)
92  call mem_allocate(this%trackterminate, 'ITRACKTERMINATE', this%memoryPath)
93  call mem_allocate(this%trackweaksink, 'ITRACKWEAKSINK', this%memoryPath)
94  call mem_allocate(this%trackusertime, 'ITRACKUSERTIME', this%memoryPath)
95  call mem_allocate(this%tracksubfexit, 'ITRACKSUBFEXIT', this%memoryPath)
96  call mem_allocate(this%trackdropped, 'ITRACKDROPPED', this%memoryPath)
97  call mem_allocate(this%ntracktimes, 'NTRACKTIMES', this%memoryPath)
98 
99  this%name_model = name_model
100  this%dump_event_trace = .false.
101  this%inunit = 0
102  this%iout = 0
103  this%ibudcsv = 0
104  this%iperoc = 0
105  this%iocrep = 0
106  this%itrkout = 0
107  this%itrkhdr = 0
108  this%itrkcsv = 0
109  this%itrktls = 0
110  this%trackrelease = .false.
111  this%trackfeatexit = .false.
112  this%tracktimestep = .false.
113  this%trackterminate = .false.
114  this%trackweaksink = .false.
115  this%trackusertime = .false.
116  this%tracksubfexit = .false.
117  this%trackdropped = .false.
118  this%ntracktimes = 0
119 
Here is the call graph for this function:

◆ prt_oc_da()

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

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

161  ! dummy
162  class(PrtOcType) :: this
163  ! local
164  integer(I4B) :: i
165 
166  call this%tracktimes%deallocate()
167 
168  do i = 1, size(this%ocds)
169  call this%ocds(i)%ocd_da()
170  end do
171  deallocate (this%ocds)
172 
173  deallocate (this%name_model)
174  call mem_deallocate(this%dump_event_trace)
175  call mem_deallocate(this%inunit)
176  call mem_deallocate(this%iout)
177  call mem_deallocate(this%ibudcsv)
178  call mem_deallocate(this%iperoc)
179  call mem_deallocate(this%iocrep)
180  call mem_deallocate(this%itrkout)
181  call mem_deallocate(this%itrkhdr)
182  call mem_deallocate(this%itrkcsv)
183  call mem_deallocate(this%itrktls)
184  call mem_deallocate(this%trackrelease)
185  call mem_deallocate(this%trackfeatexit)
186  call mem_deallocate(this%tracktimestep)
187  call mem_deallocate(this%trackterminate)
188  call mem_deallocate(this%trackweaksink)
189  call mem_deallocate(this%trackusertime)
190  call mem_deallocate(this%tracksubfexit)
191  call mem_deallocate(this%trackdropped)
192  call mem_deallocate(this%ntracktimes)
193 

◆ prt_oc_read_dimensions()

subroutine prtocmodule::prt_oc_read_dimensions ( class(prtoctype), intent(inout)  this)

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

363  use constantsmodule, only: linelength
365  ! dummy
366  class(PrtOcType), intent(inout) :: this
367  ! local
368  character(len=LINELENGTH) :: keyword
369  integer(I4B) :: ierr
370  logical(LGP) :: isfound, endOfBlock
371 
372  ! initialize dimensions to -1
373  this%ntracktimes = -1
374 
375  ! get dimensions block
376  call this%parser%GetBlock('DIMENSIONS', isfound, ierr, &
377  supportopenclose=.true., &
378  blockrequired=.false.)
379 
380  ! parse dimensions block if detected
381  if (.not. isfound) return
382  write (this%iout, '(/1x,a)') &
383  'PROCESSING OUTPUT CONTROL DIMENSIONS'
384  do
385  call this%parser%GetNextLine(endofblock)
386  if (endofblock) exit
387  call this%parser%GetStringCaps(keyword)
388  select case (keyword)
389  case ('NTRACKTIMES')
390  this%ntracktimes = this%parser%GetInteger()
391  write (this%iout, '(4x,a,i7)') 'NTRACKTIMES = ', this%ntracktimes
392  case default
393  write (errmsg, '(a,a)') &
394  'UNKNOWN OUTPUT CONTROL DIMENSION: ', trim(keyword)
395  call store_error(errmsg)
396  end select
397  end do
398  write (this%iout, '(1x,a)') &
399  'END OF OUTPUT CONTROL DIMENSIONS'
400 
401  if (this%ntracktimes < 0) then
402  write (errmsg, '(a)') &
403  'NTRACKTIMES WAS NOT SPECIFIED OR WAS SPECIFIED INCORRECTLY.'
404  call store_error(errmsg)
405  end if
406 
407  ! stop if errors were encountered in the block
408  if (count_errors() > 0) &
409  call this%parser%StoreErrorUnit()
410 
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition: Constants.f90:45
This module contains simulation methods.
Definition: Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition: Sim.f90:92
integer(i4b) function, public count_errors()
Return number of errors.
Definition: Sim.f90:59
Here is the call graph for this function:

◆ prt_oc_read_options()

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

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

197  ! modules
198  use openspecmodule, only: access, form
200  use constantsmodule, only: linelength
204  ! dummy
205  class(PrtOcType) :: this
206  ! local
207  character(len=LINELENGTH) :: keyword
208  character(len=LINELENGTH) :: keyword2
209  character(len=LINELENGTH) :: fname
210  character(len=:), allocatable :: line
211  integer(I4B) :: ierr, ipos
212  logical(LGP) :: block_found, param_found, event_found, eob
213  type(OutputControlDataType), pointer :: ocdobjptr
214  ! formats
215  character(len=*), parameter :: fmttrkbin = &
216  "(4x, 'PARTICLE TRACKS WILL BE SAVED TO BINARY FILE: ', a, /4x, &
217  &'OPENED ON UNIT: ', I0)"
218  character(len=*), parameter :: fmttrkcsv = &
219  "(4x, 'PARTICLE TRACKS WILL BE SAVED TO CSV FILE: ', a, /4x, &
220  &'OPENED ON UNIT: ', I0)"
221 
222  ! get options block
223  call this%parser%GetBlock('OPTIONS', block_found, ierr, &
224  supportopenclose=.true., blockrequired=.false.)
225 
226  ! parse options block if detected
227  if (block_found) then
228  write (this%iout, '(/,1x,a,/)') 'PROCESSING OC OPTIONS'
229  event_found = .false.
230  do
231  call this%parser%GetNextLine(eob)
232  if (eob) exit
233  call this%parser%GetStringCaps(keyword)
234  param_found = .false.
235  select case (keyword)
236  case ('BUDGETCSV')
237  call this%parser%GetStringCaps(keyword2)
238  if (keyword2 /= 'FILEOUT') then
239  errmsg = "BUDGETCSV must be followed by FILEOUT and then budget &
240  &csv file name. Found '"//trim(keyword2)//"'."
241  call store_error(errmsg)
242  call this%parser%StoreErrorUnit()
243  end if
244  call this%parser%GetString(fname)
245  this%ibudcsv = getunit()
246  call openfile(this%ibudcsv, this%iout, fname, 'CSV', &
247  filstat_opt='REPLACE')
248  param_found = .true.
249  case ('TRACK')
250  call this%parser%GetStringCaps(keyword)
251  if (keyword == 'FILEOUT') then
252  ! parse filename
253  call this%parser%GetString(fname)
254  ! open binary track output file
255  this%itrkout = getunit()
256  call openfile(this%itrkout, this%iout, fname, 'DATA(BINARY)', &
257  form, access, filstat_opt='REPLACE', &
258  mode_opt=mnormal)
259  write (this%iout, fmttrkbin) trim(adjustl(fname)), this%itrkout
260  ! open and write ascii track header file
261  this%itrkhdr = getunit()
262  fname = trim(fname)//'.hdr'
263  call openfile(this%itrkhdr, this%iout, fname, 'CSV', &
264  filstat_opt='REPLACE', mode_opt=mnormal)
265  write (this%itrkhdr, '(a,/,a)') trackheader, trackdtypes
266  else
267  call store_error('OPTIONAL TRACK KEYWORD MUST BE '// &
268  'FOLLOWED BY FILEOUT')
269  end if
270  param_found = .true.
271  case ('TRACKCSV')
272  call this%parser%GetStringCaps(keyword)
273  if (keyword == 'FILEOUT') then
274  ! parse filename
275  call this%parser%GetString(fname)
276  ! open CSV track output file and write headers
277  this%itrkcsv = getunit()
278  call openfile(this%itrkcsv, this%iout, fname, 'CSV', &
279  filstat_opt='REPLACE')
280  write (this%iout, fmttrkcsv) trim(adjustl(fname)), this%itrkcsv
281  write (this%itrkcsv, '(a)') trackheader
282  else
283  call store_error('OPTIONAL TRACKCSV KEYWORD MUST BE &
284  &FOLLOWED BY FILEOUT')
285  end if
286  param_found = .true.
287  case ('TRACK_RELEASE')
288  this%trackrelease = .true.
289  event_found = .true.
290  param_found = .true.
291  case ('TRACK_EXIT')
292  this%trackfeatexit = .true.
293  event_found = .true.
294  param_found = .true.
295  case ('TRACK_TIMESTEP')
296  this%tracktimestep = .true.
297  event_found = .true.
298  param_found = .true.
299  case ('TRACK_TERMINATE')
300  this%trackterminate = .true.
301  event_found = .true.
302  param_found = .true.
303  case ('TRACK_WEAKSINK')
304  this%trackweaksink = .true.
305  event_found = .true.
306  param_found = .true.
307  case ('TRACK_USERTIME')
308  this%trackusertime = .true.
309  event_found = .true.
310  param_found = .true.
311  case ('TRACK_SUBFEATURE_EXIT')
312  this%tracksubfexit = .true.
313  event_found = .true.
314  param_found = .true.
315  case ('TRACK_DROPPED')
316  this%trackdropped = .true.
317  event_found = .true.
318  param_found = .true.
319  case ('DEV_DUMP_EVENT_TRACE')
320  this%dump_event_trace = .true.
321  param_found = .true.
322  case default
323  param_found = .false.
324  end select
325 
326  ! check if we're done
327  if (.not. param_found) then
328  do ipos = 1, size(this%ocds)
329  ocdobjptr => this%ocds(ipos)
330  if (keyword == trim(ocdobjptr%cname)) then
331  param_found = .true.
332  exit
333  end if
334  end do
335  if (.not. param_found) then
336  errmsg = "UNKNOWN OC OPTION '"//trim(keyword)//"'."
337  call store_error(errmsg)
338  call this%parser%StoreErrorUnit()
339  end if
340  call this%parser%GetRemainingLine(line)
341  call ocdobjptr%set_option(line, this%parser%iuactive, this%iout)
342  end if
343  end do
344 
345  ! default events
346  if (.not. event_found) then
347  this%trackrelease = .true.
348  this%trackfeatexit = .true.
349  this%tracktimestep = .true.
350  this%trackterminate = .true.
351  this%trackweaksink = .true.
352  this%trackusertime = .true.
353  this%trackdropped = .true.
354  end if
355 
356  ! logging
357  write (this%iout, '(1x,a)') 'END OF OC OPTIONS'
358  end if
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
Particle track output module.
character(len= *), parameter, public trackheader
character(len= *), parameter, public trackdtypes
subroutine, public store_error_unit(iunit, terminate)
Store the file unit number.
Definition: Sim.f90:168
Here is the call graph for this function:

◆ prt_oc_read_tracktimes()

subroutine prtocmodule::prt_oc_read_tracktimes ( class(prtoctype), intent(inout)  this)

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

415  ! dummy
416  class(PrtOcType), intent(inout) :: this
417  ! local
418  integer(I4B) :: i, ierr
419  logical(LGP) :: eob, found, success
420  real(DP) :: t
421 
422  ! get tracktimes block
423  call this%parser%GetBlock('TRACKTIMES', found, ierr, &
424  supportopenclose=.true., &
425  blockrequired=.false.)
426 
427  ! raise an error if tracktimes has a dimension
428  ! but no block was found, otherwise return early
429  if (.not. found) then
430  if (this%ntracktimes <= 0) return
431  write (errmsg, '(a, i0)') &
432  "Expected TRACKTIMES with length ", this%ntracktimes
433  call store_error(errmsg)
434  call this%parser%StoreErrorUnit(terminate=.true.)
435  end if
436 
437  ! allocate time selection
438  call this%tracktimes%expand(this%ntracktimes)
439 
440  ! read the block
441  write (this%iout, '(/1x,a)') &
442  'PROCESSING OUTPUT CONTROL TRACKTIMES'
443  do i = 1, this%ntracktimes
444  call this%parser%GetNextLine(eob)
445  if (eob) exit
446  call this%parser%TryGetDouble(t, success)
447  if (.not. success) then
448  errmsg = "Failed to read double precision value"
449  call store_error(errmsg)
450  call this%parser%StoreErrorUnit(terminate=.true.)
451  end if
452  this%tracktimes%times(i) = t
453  end do
454 
455  ! make sure times strictly increase
456  if (.not. this%tracktimes%increasing()) then
457  errmsg = "TRACKTIMES must strictly increase"
458  call store_error(errmsg)
459  call this%parser%StoreErrorUnit(terminate=.true.)
460  end if
461 
Here is the call graph for this function: