MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
prt.f90
Go to the documentation of this file.
2 use kindmodule, only: dp, i4b, lgp
3 use errorutilmodule, only: pstop
12 use dismodule, only: distype, dis_cr
13 use disvmodule, only: disvtype, disv_cr
14 use disumodule, only: disutype, disu_cr
16 use prtfmimodule, only: prtfmitype
17 use prtmipmodule, only: prtmiptype
18 use prtocmodule, only: prtoctype
19 use budgetmodule, only: budgettype
20 use listmodule, only: listtype
24 particletrackfiletype, &
34
35 implicit none
36
37 private
38 public :: prt_cr
39 public :: prtmodeltype
41 public :: prt_basepkg, prt_multipkg
42
43 integer(I4B), parameter :: nbditems = 2
44 character(len=LENBUDTXT), dimension(NBDITEMS) :: budtxt
45 data budtxt/' STORAGE', ' TERMINATION'/
46
47 !> @brief Particle tracking (PRT) model
49 type(prtfmitype), pointer :: fmi => null() ! flow model interface
50 type(prtmiptype), pointer :: mip => null() ! model input package
51 type(prtoctype), pointer :: oc => null() ! output control package
52 type(budgettype), pointer :: budget => null() ! budget object
53 class(methodtype), pointer :: method => null() ! tracking method
54 type(methoddistype), pointer :: method_dis => null() ! DIS tracking method
55 type(methoddisvtype), pointer :: method_disv => null() ! DISV tracking method
56 type(particleeventdispatchertype), pointer :: events => null() ! event dispatcher
57 type(particletrackstype), pointer :: tracks ! track output manager
58 integer(I4B), pointer :: infmi => null() ! unit number FMI
59 integer(I4B), pointer :: inmip => null() ! unit number MIP
60 integer(I4B), pointer :: inmvt => null() ! unit number MVT
61 integer(I4B), pointer :: inmst => null() ! unit number MST
62 integer(I4B), pointer :: inadv => null() ! unit number ADV
63 integer(I4B), pointer :: indsp => null() ! unit number DSP
64 integer(I4B), pointer :: inssm => null() ! unit number SSM
65 integer(I4B), pointer :: inoc => null() ! unit number OC
66 integer(I4B), pointer :: nprp => null() ! number of PRP packages in the model
67 real(dp), dimension(:), pointer, contiguous :: masssto => null() !< particle mass storage in cells, new value
68 real(dp), dimension(:), pointer, contiguous :: massstoold => null() !< particle mass storage in cells, old value
69 real(dp), dimension(:), pointer, contiguous :: ratesto => null() !< particle mass storage rate in cells
70 real(dp), dimension(:), pointer, contiguous :: masstrm => null() !< particle mass terminating in cells, new value
71 real(dp), dimension(:), pointer, contiguous :: ratetrm => null() !< particle mass termination rate in cells
72 type(hashtabletype), pointer :: trm_ids => null() !< terminated particle ids
73 contains
74 ! Override BaseModelType procs
75 procedure :: model_df => prt_df
76 procedure :: model_ar => prt_ar
77 procedure :: model_rp => prt_rp
78 procedure :: model_ad => prt_ad
79 procedure :: model_cq => prt_cq
80 procedure :: model_bd => prt_bd
81 procedure :: model_ot => prt_ot
82 procedure :: model_da => prt_da
83 procedure :: model_solve => prt_solve
84
85 ! Private utilities
86 procedure :: allocate_scalars
87 procedure :: allocate_arrays
88 procedure, private :: package_create
89 procedure, private :: ftype_check
90 procedure, private :: prt_ot_flow
91 procedure, private :: prt_ot_saveflow
92 procedure, private :: prt_ot_printflow
93 procedure, private :: prt_ot_dv
94 procedure, private :: prt_ot_bdsummary
95 procedure, private :: prt_cq_budterms
96 procedure, private :: create_packages
97 procedure, private :: create_bndpkgs
98 procedure, private :: create_exg_prp
99 procedure, private :: log_namfile_options
100
101 end type prtmodeltype
102
103 !> @brief PRT base package array descriptors
104 !!
105 !! PRT6 model base package types. Only listed packages are candidates
106 !! for input and these will be loaded in the order specified.
107 !<
108 integer(I4B), parameter :: prt_nbasepkg = 50
109 character(len=LENPACKAGETYPE), dimension(PRT_NBASEPKG) :: prt_basepkg
110 data prt_basepkg/'DIS6 ', 'DISV6', 'DISU6', 'IC6 ', 'MST6 ', & ! 5
111 &'ADV6 ', 'DSP6 ', 'SSM6 ', 'MIP6 ', 'CNC6 ', & ! 10
112 &'OC6 ', ' ', 'FMI6 ', ' ', 'IST6 ', & ! 15
113 &'LKT6 ', 'SFT6 ', 'MWT6 ', 'UZT6 ', 'MVT6 ', & ! 20
114 &' ', ' ', ' ', ' ', ' ', & ! 25
115 25*' '/ ! 50
116
117 !> @brief PRT multi package array descriptors
118 !!
119 !! PRT6 model multi-instance package types. Only listed packages are
120 !! candidates for input and these will be loaded in the order specified.
121 !<
122 integer(I4B), parameter :: prt_nmultipkg = 50
123 character(len=LENPACKAGETYPE), dimension(PRT_NMULTIPKG) :: prt_multipkg
124 data prt_multipkg/'PRP6 ', ' ', ' ', ' ', ' ', & ! 5
125 &45*' '/ ! 50
126
127 ! size of supported model package arrays
128 integer(I4B), parameter :: niunit_prt = prt_nbasepkg + prt_nmultipkg
129
130contains
131
132 !> @brief Create a new particle tracking model object
133 subroutine prt_cr(filename, id, modelname)
134 ! modules
135 use listsmodule, only: basemodellist
143 ! dummy
144 character(len=*), intent(in) :: filename
145 integer(I4B), intent(in) :: id
146 character(len=*), intent(in) :: modelname
147 ! local
148 type(prtmodeltype), pointer :: this
149 class(basemodeltype), pointer :: model
150 character(len=LENMEMPATH) :: input_mempath
151 character(len=LINELENGTH) :: lst_fname
152 type(prtnamparamfoundtype) :: found
153
154 ! Allocate a new PRT Model (this)
155 allocate (this)
156
157 ! Set this before any allocs in the memory manager can be done
158 this%memoryPath = create_mem_path(modelname)
159
160 ! Allocate event system and track output manager
161 allocate (this%events)
162 allocate (this%tracks)
163
164 ! Allocate scalars and add model to basemodellist
165 call this%allocate_scalars(modelname)
166 model => this
168
169 ! Assign variables
170 this%filename = filename
171 this%name = modelname
172 this%macronym = 'PRT'
173 this%id = id
174
175 ! Set input model namfile memory path
176 input_mempath = create_mem_path(modelname, 'NAM', idm_context)
177
178 ! Copy options from input context
179 call mem_set_value(this%iprpak, 'PRINT_INPUT', input_mempath, &
180 found%print_input)
181 call mem_set_value(this%iprflow, 'PRINT_FLOWS', input_mempath, &
182 found%print_flows)
183 call mem_set_value(this%ipakcb, 'SAVE_FLOWS', input_mempath, &
184 found%save_flows)
185
186 ! Create the list file
187 call this%create_lstfile(lst_fname, filename, found%list, &
188 'PARTICLE TRACKING MODEL (PRT)')
189
190 ! Activate save_flows if found
191 if (found%save_flows) then
192 this%ipakcb = -1
193 end if
194
195 ! Create model packages
196 call this%create_packages()
197
198 ! Create hash table for terminated particle ids
199 call hash_table_cr(this%trm_ids)
200
201 ! Log options
202 if (this%iout > 0) then
203 call this%log_namfile_options(found)
204 end if
205
206 end subroutine prt_cr
207
208 !> @brief Define packages
209 !!
210 !! (1) call df routines for each package
211 !! (2) set variables and pointers
212 !<
213 subroutine prt_df(this)
214 ! modules
215 use prtprpmodule, only: prtprptype
216 ! dummy
217 class(prtmodeltype) :: this
218 ! local
219 integer(I4B) :: ip
220 class(bndtype), pointer :: packobj
221
222 ! Define packages and utility objects
223 call this%dis%dis_df()
224 call this%fmi%fmi_df(this%dis, 1)
225 call this%oc%oc_df()
226 call this%budget%budget_df(niunit_prt, 'MASS', 'M')
227
228 ! Define packages and assign iout for time series managers
229 do ip = 1, this%bndlist%Count()
230 packobj => getbndfromlist(this%bndlist, ip)
231 call packobj%bnd_df(this%dis%nodes, this%dis)
232 packobj%TsManager%iout = this%iout
233 packobj%TasManager%iout = this%iout
234 end do
235
236 ! Allocate model arrays
237 call this%allocate_arrays()
238
239 end subroutine prt_df
240
241 !> @brief Allocate and read
242 !!
243 !! (1) allocates and reads packages part of this model,
244 !! (2) allocates memory for arrays part of this model object
245 !<
246 subroutine prt_ar(this)
247 ! modules
248 use constantsmodule, only: dhnoflo
249 use prtprpmodule, only: prtprptype
250 use prtmipmodule, only: prtmiptype
251 use simvariablesmodule, only: warnmsg
252 ! dummy
253 class(prtmodeltype) :: this
254 ! locals
255 integer(I4B) :: ip, nprp
256 class(bndtype), pointer :: packobj
257 class(*), pointer :: p
258
259 ! Set up basic packages
260 call this%fmi%fmi_ar(this%ibound)
261 if (this%inmip > 0) call this%mip%mip_ar()
262
263 ! Set up output control and budget
264 call this%oc%oc_ar(this%dis, dhnoflo)
265 call this%budget%set_ibudcsv(this%oc%ibudcsv)
266
267 ! Initialize the event buffer (memory or scratch file per OC option)
268 call this%tracks%init_buffer(this%oc%scratch_buffer)
269
270 ! Select tracking events
271 call this%tracks%select_events( &
272 this%oc%trackrelease, &
273 this%oc%trackfeatexit, &
274 this%oc%tracktimestep, &
275 this%oc%trackterminate, &
276 this%oc%trackweaksink, &
277 this%oc%trackusertime, &
278 this%oc%tracksubfexit, &
279 this%oc%trackdropped)
280
281 ! Set up boundary pkgs and pkg-scoped track files
282 nprp = 0
283 do ip = 1, this%bndlist%Count()
284 packobj => getbndfromlist(this%bndlist, ip)
285 select type (packobj)
286 type is (prtprptype)
287 nprp = nprp + 1
288 call packobj%prp_set_pointers(this%ibound, this%mip%izone)
289 call packobj%bnd_ar()
290 if (packobj%itrkout > 0) then
291 call this%tracks%init_file( &
292 packobj%itrkout, &
293 iprp=nprp)
294 end if
295 if (packobj%itrkcsv > 0) then
296 call this%tracks%init_file( &
297 packobj%itrkcsv, &
298 csv=.true., &
299 iprp=nprp)
300 end if
301 class default
302 call packobj%bnd_ar()
303 end select
304 end do
305
306 ! Set up model-scoped track files
307 if (this%oc%itrkout > 0) &
308 call this%tracks%init_file(this%oc%itrkout)
309 if (this%oc%itrkcsv > 0) &
310 call this%tracks%init_file(this%oc%itrkcsv, csv=.true.)
311
312 ! Warn if no track files are configured
313 if (this%tracks%ntrackfiles == 0) then
314 write (warnmsg, '(a)') &
315 'No particle track output configured (TRACK or TRACKCSV FILEOUT &
316 &in OC or any PRP). Particle events will not be saved.'
318 end if
319
320 ! Initialize and select the tracking method based on discretization
321 select type (dis => this%dis)
322 type is (distype)
323 call this%method_dis%init( &
324 fmi=this%fmi, &
325 events=this%events, &
326 izone=this%mip%izone, &
327 flowja=this%flowja, &
328 porosity=this%mip%porosity, &
329 retfactor=this%mip%retfactor, &
330 tracktimes=this%oc%tracktimes)
331 this%method => this%method_dis
332 type is (disvtype)
333 call this%method_disv%init( &
334 fmi=this%fmi, &
335 events=this%events, &
336 izone=this%mip%izone, &
337 flowja=this%flowja, &
338 porosity=this%mip%porosity, &
339 retfactor=this%mip%retfactor, &
340 tracktimes=this%oc%tracktimes)
341 this%method => this%method_disv
342 end select
343
344 ! Subscribe particle track output manager to events
345 p => this%tracks
346 call this%events%subscribe(add_particle_event, p)
347
348 ! Set verbose tracing if requested
349 if (this%oc%dump_event_trace) this%tracks%iout = 0
350 end subroutine prt_ar
351
352 !> @brief Read and prepare (calls package read and prepare routines)
353 subroutine prt_rp(this)
354 use tdismodule, only: readnewdata
355 ! dummy
356 class(prtmodeltype) :: this
357 ! local
358 class(bndtype), pointer :: packobj
359 integer(I4B) :: ip
360
361 ! Check with TDIS on whether or not it is time to RP
362 if (.not. readnewdata) return
363
364 ! Read and prepare
365 if (this%inoc > 0) call this%oc%oc_rp()
366 do ip = 1, this%bndlist%Count()
367 packobj => getbndfromlist(this%bndlist, ip)
368 call packobj%bnd_rp()
369 end do
370 end subroutine prt_rp
371
372 !> @brief Time step advance (calls package advance subroutines)
373 subroutine prt_ad(this)
374 ! modules
376 ! dummy
377 class(prtmodeltype) :: this
378 class(bndtype), pointer :: packobj
379 ! local
380 integer(I4B) :: ip, n, i
381
382 ! Discard buffered events from previous time step solve attempts.
383 ! prt_advance() is called on every sln_ca(): once per ATS retry,
384 ! once per Picard iteration, and once for the post-Picard output
385 ! rerun if mxiter > 1. Tracking is skipped during Picard iterations
386 ! (isuppress_output=1) in prt_solve, so the buffer is empty here on
387 ! Picard calls and the discard is a no-op. On the output rerun
388 ! (isuppress_output=0), tracking runs once and the buffer is cleared
389 ! before it is filled, so only events from that run reach disk.
390 call this%tracks%discard_buffer()
391
392 ! Update look-behind mass
393 do n = 1, this%dis%nodes
394 this%massstoold(n) = this%masssto(n)
395 end do
396
397 ! Advance fmi
398 call this%fmi%fmi_ad()
399
400 ! Advance release packages
401 do ip = 1, this%bndlist%Count()
402 packobj => getbndfromlist(this%bndlist, ip)
403 call packobj%bnd_ad()
404 if (isimcheck > 0) &
405 call packobj%bnd_ck()
406 end do
407
408 ! Initialize the flowja array. Flowja is calculated each time,
409 ! even if output is suppressed. (Flowja represents flow of particle
410 ! mass and is positive into a cell. Currently, each particle is assigned
411 ! unit mass.) Flowja is updated continually as particles are tracked
412 ! over the time step and at the end of the time step. The diagonal
413 ! position of the flowja array will contain the flow residual.
414 do i = 1, this%dis%nja
415 this%flowja(i) = dzero
416 end do
417 end subroutine prt_ad
418
419 !> @brief Calculate intercell flow (flowja)
420 subroutine prt_cq(this, icnvg, isuppress_output)
421 ! modules
422 use sparsemodule, only: csr_diagsum
423 use tdismodule, only: delt
424 use prtprpmodule, only: prtprptype
425 ! dummy
426 class(prtmodeltype) :: this
427 integer(I4B), intent(in) :: icnvg
428 integer(I4B), intent(in) :: isuppress_output
429 ! local
430 integer(I4B) :: i
431 integer(I4B) :: ip
432 class(bndtype), pointer :: packobj
433 real(DP) :: tled
434
435 ! Flowja is calculated each time, even if output is suppressed.
436 ! Flowja represents flow of particle mass and is positive into a cell.
437 ! Currently, each particle is assigned unit mass.
438 !
439 ! Reciprocal of time step size.
440 tled = done / delt
441 !
442 ! Flowja was updated continually as particles were tracked over the
443 ! time step. At this point, flowja contains the net particle mass
444 ! exchanged between cells during the time step. To convert these to
445 ! flow rates (particle mass per time), divide by the time step size.
446 do i = 1, this%dis%nja
447 this%flowja(i) = this%flowja(i) * tled
448 end do
449
450 ! Particle mass budget terms
451 call this%prt_cq_budterms()
452
453 ! Go through packages and call cq routines. Just a formality.
454 do ip = 1, this%bndlist%Count()
455 packobj => getbndfromlist(this%bndlist, ip)
456 call packobj%bnd_cq(this%masssto, this%flowja)
457 end do
458
459 ! Finalize calculation of flowja by adding face flows to the diagonal.
460 ! This results in the flow residual being stored in the diagonal
461 ! position for each cell.
462 call csr_diagsum(this%dis%con%ia, this%flowja)
463 end subroutine prt_cq
464
465 !> @brief Calculate particle mass budget terms
466 subroutine prt_cq_budterms(this)
467 ! modules
468 use tdismodule, only: delt
469 use prtprpmodule, only: prtprptype
470 ! dummy
471 class(prtmodeltype) :: this
472 ! local
473 integer(I4B) :: ip
474 class(bndtype), pointer :: packobj
475 integer(I4B) :: n
476 integer(I4B) :: np
477 integer(I4B) :: idiag
478 integer(I4B) :: iprp
479 integer(I4B) :: istatus
480 real(DP) :: tled
481 real(DP) :: ratesto, ratetrm
482 character(len=:), allocatable :: particle_id
483 type(particletype), pointer :: particle
484
485 call create_particle(particle)
486
487 ! Reciprocal of time step size.
488 tled = done / delt
489
490 ! Reset mass and rate arrays
491 do n = 1, this%dis%nodes
492 this%masssto(n) = dzero
493 this%masstrm(n) = dzero
494 this%ratesto(n) = dzero
495 this%ratetrm(n) = dzero
496 end do
497
498 ! Loop over PRP packages and assign particle mass to the
499 ! appropriate budget term based on the particle status.
500 iprp = 0
501 do ip = 1, this%bndlist%Count()
502 packobj => getbndfromlist(this%bndlist, ip)
503 select type (packobj)
504 type is (prtprptype)
505 iprp = iprp + 1
506 do np = 1, packobj%nparticles
507 call packobj%particles_staging%get(particle, this%id, iprp, np)
508 istatus = packobj%particles_staging%istatus(np)
509 particle_id = particle%get_id()
510 if (istatus == active) then
511 ! calculate storage mass
512 n = packobj%particles_staging%itrdomain(np, level_feature)
513 this%masssto(n) = this%masssto(n) + done ! unit mass
514 else if (istatus > active) then
515 if (this%trm_ids%get(particle_id) /= 0) cycle
516 ! calculate terminating mass
517 n = packobj%particles_staging%itrdomain(np, level_feature)
518 this%masstrm(n) = this%masstrm(n) + done ! unit mass
519 call this%trm_ids%add(particle_id, 1) ! mark id terminated
520 end if
521 end do
522 end select
523 end do
524
525 ! Calculate rates and update flowja
526 do n = 1, this%dis%nodes
527 ratesto = -(this%masssto(n) - this%massstoold(n)) * tled
528 ratetrm = -this%masstrm(n) * tled
529 this%ratesto(n) = ratesto
530 this%ratetrm(n) = ratetrm
531 idiag = this%dis%con%ia(n)
532 this%flowja(idiag) = this%flowja(idiag) + ratesto
533 end do
534
535 call particle%destroy()
536 deallocate (particle)
537
538 end subroutine prt_cq_budterms
539
540 !> @brief Calculate flows and budget
541 !!
542 !! (1) Calculate intercell flows (flowja)
543 !! (2) Calculate package contributions to model budget
544 !!
545 !<
546 subroutine prt_bd(this, icnvg, isuppress_output)
547 ! modules
548 use tdismodule, only: delt
550 ! dummy
551 class(prtmodeltype) :: this
552 integer(I4B), intent(in) :: icnvg
553 integer(I4B), intent(in) :: isuppress_output
554 ! local
555 integer(I4B) :: ip
556 class(bndtype), pointer :: packobj
557 real(DP) :: rin
558 real(DP) :: rout
559
560 ! Budget routines (start by resetting). Sole purpose of this section
561 ! is to add in and outs to model budget. All ins and out for a model
562 ! should be added here to this%budget. In a subsequent exchange call,
563 ! exchange flows might also be added.
564 call this%budget%reset()
565 ! storage term
566 call rate_accumulator(this%ratesto, rin, rout)
567 call this%budget%addentry(rin, rout, delt, budtxt(1), &
568 isuppress_output, ' PRT')
569 ! termination term
570 call rate_accumulator(this%ratetrm, rin, rout)
571 call this%budget%addentry(rin, rout, delt, budtxt(2), &
572 isuppress_output, ' PRT')
573 ! boundary packages
574 do ip = 1, this%bndlist%Count()
575 packobj => getbndfromlist(this%bndlist, ip)
576 call packobj%bnd_bd(this%budget)
577 end do
578 end subroutine prt_bd
579
580 !> @brief Print and/or save model output
581 subroutine prt_ot(this)
582 use tdismodule, only: tdis_ot, endofperiod
583 use prtprpmodule, only: prtprptype
584 ! dummy
585 class(prtmodeltype) :: this
586 ! local
587 integer(I4B) :: idvsave
588 integer(I4B) :: idvprint
589 integer(I4B) :: icbcfl
590 integer(I4B) :: icbcun
591 integer(I4B) :: ibudfl
592 integer(I4B) :: ipflag
593 integer(I4B) :: ip
594 class(bndtype), pointer :: packobj
595
596 ! Flush buffered events to disk
597 call this%tracks%flush_buffer()
598
599 ! Commit each PRP's staged state
600 do ip = 1, this%bndlist%Count()
601 packobj => getbndfromlist(this%bndlist, ip)
602 select type (packobj)
603 type is (prtprptype)
604 call packobj%prp_commit()
605 end select
606 end do
607
608 ! Set write and print flags
609 idvsave = 0
610 idvprint = 0
611 icbcfl = 0
612 ibudfl = 0
613 if (this%oc%oc_save('CONCENTRATION')) idvsave = 1
614 if (this%oc%oc_print('CONCENTRATION')) idvprint = 1
615 if (this%oc%oc_save('BUDGET')) icbcfl = 1
616 if (this%oc%oc_print('BUDGET')) ibudfl = 1
617 icbcun = this%oc%oc_save_unit('BUDGET')
618
619 ! Override ibudfl and idvprint flags for nonconvergence
620 ! and end of period
621 ibudfl = this%oc%set_print_flag('BUDGET', 1, endofperiod)
622 idvprint = this%oc%set_print_flag('CONCENTRATION', 1, endofperiod)
623
624 ! Save and print flows
625 call this%prt_ot_flow(icbcfl, ibudfl, icbcun)
626
627 ! Save and print dependent variables
628 call this%prt_ot_dv(idvsave, idvprint, ipflag)
629
630 ! Print budget summaries
631 call this%prt_ot_bdsummary(ibudfl, ipflag)
632
633 ! Timing Output; if any dependent variables or budgets
634 ! are printed, then ipflag is set to 1.
635 if (ipflag == 1) call tdis_ot(this%iout)
636 end subroutine prt_ot
637
638 !> @brief Save flows
639 subroutine prt_ot_flow(this, icbcfl, ibudfl, icbcun)
640 use prtprpmodule, only: prtprptype
641 class(prtmodeltype) :: this
642 integer(I4B), intent(in) :: icbcfl
643 integer(I4B), intent(in) :: ibudfl
644 integer(I4B), intent(in) :: icbcun
645 class(bndtype), pointer :: packobj
646 integer(I4B) :: ip
647
648 ! Save PRT flows
649 call this%prt_ot_saveflow(this%dis%nja, this%flowja, icbcfl, icbcun)
650 do ip = 1, this%bndlist%Count()
651 packobj => getbndfromlist(this%bndlist, ip)
652 call packobj%bnd_ot_model_flows(icbcfl=icbcfl, ibudfl=0, icbcun=icbcun)
653 end do
654
655 ! Save advanced package flows
656 do ip = 1, this%bndlist%Count()
657 packobj => getbndfromlist(this%bndlist, ip)
658 call packobj%bnd_ot_package_flows(icbcfl=icbcfl, ibudfl=0)
659 end do
660
661 ! Print PRT flows
662 call this%prt_ot_printflow(ibudfl, this%flowja)
663 do ip = 1, this%bndlist%Count()
664 packobj => getbndfromlist(this%bndlist, ip)
665 call packobj%bnd_ot_model_flows(icbcfl=icbcfl, ibudfl=ibudfl, icbcun=0)
666 end do
667
668 ! Print advanced package flows
669 do ip = 1, this%bndlist%Count()
670 packobj => getbndfromlist(this%bndlist, ip)
671 call packobj%bnd_ot_package_flows(icbcfl=0, ibudfl=ibudfl)
672 end do
673 end subroutine prt_ot_flow
674
675 !> @brief Save intercell flows
676 subroutine prt_ot_saveflow(this, nja, flowja, icbcfl, icbcun)
677 ! dummy
678 class(prtmodeltype) :: this
679 integer(I4B), intent(in) :: nja
680 real(DP), dimension(nja), intent(in) :: flowja
681 integer(I4B), intent(in) :: icbcfl
682 integer(I4B), intent(in) :: icbcun
683 ! local
684 integer(I4B) :: ibinun
685 integer(I4B) :: naux
686 real(DP), dimension(0) :: auxrow
687 character(len=LENAUXNAME), dimension(0) :: auxname
688 logical(LGP) :: header_written
689 integer(I4B) :: i, nn
690 real(DP) :: m
691 integer(I4B) :: nsto, ntrm
692 logical(LGP), allocatable :: msto_mask(:), mtrm_mask(:)
693 integer(I4B), allocatable :: msto_nns(:), mtrm_nns(:)
694 real(DP), allocatable :: msto_vals(:), mtrm_vals(:)
695
696 ! Set unit number for binary output
697 if (this%ipakcb < 0) then
698 ibinun = icbcun
699 elseif (this%ipakcb == 0) then
700 ibinun = 0
701 else
702 ibinun = this%ipakcb
703 end if
704 if (icbcfl == 0) ibinun = 0
705
706 ! Return if nothing to do
707 if (ibinun == 0) return
708
709 ! Write mass face flows
710 call this%dis%record_connection_array(flowja, ibinun, this%iout)
711
712 ! Write mass storage term
713 naux = 0
714 header_written = .false.
715 msto_mask = this%masssto > dzero
716 msto_vals = pack(this%masssto, msto_mask)
717 msto_nns = [(i, i=1, size(this%masssto))]
718 msto_nns = pack(msto_nns, msto_mask)
719 nsto = size(msto_nns)
720 do i = 1, nsto
721 nn = msto_nns(i)
722 m = msto_vals(i)
723 if (.not. header_written) then
724 call this%dis%record_srcdst_list_header(budtxt(1), &
725 'PRT ', &
726 'PRT ', &
727 'PRT ', &
728 'STORAGE ', &
729 naux, auxname, ibinun, &
730 nsto, this%iout)
731 header_written = .true.
732 end if
733 call this%dis%record_mf6_list_entry(ibinun, nn, nn, m, &
734 0, auxrow, &
735 olconv2=.false.)
736 end do
737
738 ! Write mass termination term
739 header_written = .false.
740 mtrm_mask = this%masstrm > dzero
741 mtrm_vals = pack(this%masstrm, mtrm_mask)
742 mtrm_nns = [(i, i=1, size(this%masstrm))]
743 mtrm_nns = pack(mtrm_nns, mtrm_mask)
744 ntrm = size(mtrm_nns)
745 do i = 1, ntrm
746 nn = mtrm_nns(i)
747 m = mtrm_vals(i)
748 if (.not. header_written) then
749 call this%dis%record_srcdst_list_header(budtxt(2), &
750 'PRT ', &
751 'PRT ', &
752 'PRT ', &
753 'TERMINATION ', &
754 naux, auxname, ibinun, &
755 ntrm, this%iout)
756 header_written = .true.
757 end if
758 call this%dis%record_mf6_list_entry(ibinun, nn, nn, m, &
759 0, auxrow, &
760 olconv2=.false.)
761 end do
762
763 end subroutine prt_ot_saveflow
764
765 !> @brief Print intercell flows
766 subroutine prt_ot_printflow(this, ibudfl, flowja)
767 ! modules
768 use tdismodule, only: kper, kstp
769 use constantsmodule, only: lenbigline
770 ! dummy
771 class(prtmodeltype) :: this
772 integer(I4B), intent(in) :: ibudfl
773 real(DP), intent(inout), dimension(:) :: flowja
774 ! local
775 character(len=LENBIGLINE) :: line
776 character(len=30) :: tempstr
777 integer(I4B) :: n, ipos, m
778 real(DP) :: qnm
779 ! formats
780 character(len=*), parameter :: fmtiprflow = &
781 "(/,4x,'CALCULATED INTERCELL FLOW &
782 &FOR PERIOD ', i0, ' STEP ', i0)"
783
784 ! Write flowja to list file if requested
785 if (ibudfl /= 0 .and. this%iprflow > 0) then
786 write (this%iout, fmtiprflow) kper, kstp
787 do n = 1, this%dis%nodes
788 line = ''
789 call this%dis%noder_to_string(n, tempstr)
790 line = trim(tempstr)//':'
791 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
792 m = this%dis%con%ja(ipos)
793 call this%dis%noder_to_string(m, tempstr)
794 line = trim(line)//' '//trim(tempstr)
795 qnm = flowja(ipos)
796 write (tempstr, '(1pg15.6)') qnm
797 line = trim(line)//' '//trim(adjustl(tempstr))
798 end do
799 write (this%iout, '(a)') trim(line)
800 end do
801 end if
802 end subroutine prt_ot_printflow
803
804 !> @brief Print dependent variables
805 subroutine prt_ot_dv(this, idvsave, idvprint, ipflag)
806 ! dummy
807 class(prtmodeltype) :: this
808 integer(I4B), intent(in) :: idvsave
809 integer(I4B), intent(in) :: idvprint
810 integer(I4B), intent(inout) :: ipflag
811 ! local
812 class(bndtype), pointer :: packobj
813 integer(I4B) :: ip
814
815 ! Print advanced package dependent variables
816 do ip = 1, this%bndlist%Count()
817 packobj => getbndfromlist(this%bndlist, ip)
818 call packobj%bnd_ot_dv(idvsave, idvprint)
819 end do
820
821 ! save head and print head
822 call this%oc%oc_ot(ipflag)
823 end subroutine prt_ot_dv
824
825 !> @brief Print budget summary
826 subroutine prt_ot_bdsummary(this, ibudfl, ipflag)
827 ! modules
828 use tdismodule, only: kstp, kper, totim, delt
829 ! dummy
830 class(prtmodeltype) :: this
831 integer(I4B), intent(in) :: ibudfl
832 integer(I4B), intent(inout) :: ipflag
833 ! local
834 class(bndtype), pointer :: packobj
835 integer(I4B) :: ip
836
837 ! Package budget summary
838 do ip = 1, this%bndlist%Count()
839 packobj => getbndfromlist(this%bndlist, ip)
840 call packobj%bnd_ot_bdsummary(kstp, kper, this%iout, ibudfl)
841 end do
842
843 ! model budget summary
844 call this%budget%finalize_step(delt)
845 if (ibudfl /= 0) then
846 ipflag = 1
847 ! model budget summary
848 call this%budget%budget_ot(kstp, kper, this%iout)
849 end if
850
851 ! Write to budget csv
852 call this%budget%writecsv(totim)
853 end subroutine prt_ot_bdsummary
854
855 !> @brief Deallocate
856 subroutine prt_da(this)
857 ! modules
861 ! dummy
862 class(prtmodeltype) :: this
863 ! local
864 integer(I4B) :: ip
865 class(bndtype), pointer :: packobj
866
867 ! Deallocate idm memory
868 call memorystore_remove(this%name, 'NAM', idm_context)
869 call memorystore_remove(component=this%name, context=idm_context)
870
871 ! Internal packages
872 call this%dis%dis_da()
873 call this%fmi%fmi_da()
874 call this%mip%mip_da()
875 call this%budget%budget_da()
876 call this%oc%oc_da()
877 deallocate (this%dis)
878 deallocate (this%fmi)
879 deallocate (this%mip)
880 deallocate (this%budget)
881 deallocate (this%oc)
882
883 ! Method objects
884 call this%method_dis%deallocate()
885 deallocate (this%method_dis)
886 call this%method_disv%deallocate()
887 deallocate (this%method_disv)
888
889 ! Boundary packages
890 do ip = 1, this%bndlist%Count()
891 packobj => getbndfromlist(this%bndlist, ip)
892 call packobj%bnd_da()
893 deallocate (packobj)
894 end do
895
896 ! Scalars
897 call mem_deallocate(this%infmi)
898 call mem_deallocate(this%inmip)
899 call mem_deallocate(this%inadv)
900 call mem_deallocate(this%indsp)
901 call mem_deallocate(this%inssm)
902 call mem_deallocate(this%inmst)
903 call mem_deallocate(this%inmvt)
904 call mem_deallocate(this%inoc)
905
906 ! Arrays
907 call mem_deallocate(this%masssto)
908 call mem_deallocate(this%massstoold)
909 call mem_deallocate(this%ratesto)
910 call mem_deallocate(this%masstrm)
911 call mem_deallocate(this%ratetrm)
912
913 call this%tracks%destroy()
914 deallocate (this%events)
915 deallocate (this%tracks)
916
917 call this%ExplicitModelType%model_da()
918 end subroutine prt_da
919
920 !> @brief Allocate memory for scalars
921 subroutine allocate_scalars(this, modelname)
922 ! dummy
923 class(prtmodeltype) :: this
924 character(len=*), intent(in) :: modelname
925
926 ! allocate members from parent class
927 call this%ExplicitModelType%allocate_scalars(modelname)
928
929 ! allocate members that are part of model class
930 call mem_allocate(this%infmi, 'INFMI', this%memoryPath)
931 call mem_allocate(this%inmip, 'INMIP', this%memoryPath)
932 call mem_allocate(this%inmvt, 'INMVT', this%memoryPath)
933 call mem_allocate(this%inmst, 'INMST', this%memoryPath)
934 call mem_allocate(this%inadv, 'INADV', this%memoryPath)
935 call mem_allocate(this%indsp, 'INDSP', this%memoryPath)
936 call mem_allocate(this%inssm, 'INSSM', this%memoryPath)
937 call mem_allocate(this%inoc, 'INOC ', this%memoryPath)
938
939 this%infmi = 0
940 this%inmip = 0
941 this%inmvt = 0
942 this%inmst = 0
943 this%inadv = 0
944 this%indsp = 0
945 this%inssm = 0
946 this%inoc = 0
947 end subroutine allocate_scalars
948
949 !> @brief Allocate arrays
950 subroutine allocate_arrays(this)
952 class(prtmodeltype) :: this
953 integer(I4B) :: n
954
955 ! Allocate arrays in parent type (ibound, flowja, nja)
956 call this%ExplicitModelType%allocate_arrays()
957
958 ! Allocate and initialize PRT-specific arrays
959 call mem_allocate(this%masssto, this%dis%nodes, &
960 'MASSSTO', this%memoryPath)
961 call mem_allocate(this%massstoold, this%dis%nodes, &
962 'MASSSTOOLD', this%memoryPath)
963 call mem_allocate(this%ratesto, this%dis%nodes, &
964 'RATESTO', this%memoryPath)
965 call mem_allocate(this%masstrm, this%dis%nodes, &
966 'MASSTRM', this%memoryPath)
967 call mem_allocate(this%ratetrm, this%dis%nodes, &
968 'RATETRM', this%memoryPath)
969 do n = 1, this%dis%nodes
970 this%masssto(n) = dzero
971 this%massstoold(n) = dzero
972 this%ratesto(n) = dzero
973 this%masstrm(n) = dzero
974 this%ratetrm(n) = dzero
975 end do
976 end subroutine allocate_arrays
977
978 !> @brief Create boundary condition packages for this model
979 subroutine package_create(this, filtyp, ipakid, ipaknum, pakname, mempath, &
980 inunit, iout)
981 ! modules
982 use constantsmodule, only: linelength
983 ! dummy
984 class(prtmodeltype) :: this
985 character(len=*), intent(in) :: filtyp
986 character(len=LINELENGTH) :: errmsg
987 integer(I4B), intent(in) :: ipakid
988 integer(I4B), intent(in) :: ipaknum
989 character(len=*), intent(in) :: pakname
990 character(len=*), intent(in) :: mempath
991 integer(I4B), intent(in) :: inunit
992 integer(I4B), intent(in) :: iout
993 ! local
994 class(bndtype), pointer :: packobj
995 class(bndtype), pointer :: packobj2
996 integer(I4B) :: ip
997
998 ! This part creates the package object
999 select case (filtyp)
1000 case ('PRP6')
1001 call prp_create(packobj, ipakid, ipaknum, inunit, iout, &
1002 this%name, pakname, this%fmi, mempath)
1003 case default
1004 write (errmsg, *) 'Invalid package type: ', filtyp
1005 call store_error(errmsg, terminate=.true.)
1006 end select
1007
1008 ! Packages is the bndlist that is associated with the parent model
1009 ! The following statement puts a pointer to this package in the ipakid
1010 ! position of packages.
1011 do ip = 1, this%bndlist%Count()
1012 packobj2 => getbndfromlist(this%bndlist, ip)
1013 if (packobj2%packName == pakname) then
1014 write (errmsg, '(a,a)') 'Cannot create package. Package name '// &
1015 'already exists: ', trim(pakname)
1016 call store_error(errmsg, terminate=.true.)
1017 end if
1018 end do
1019 call addbndtolist(this%bndlist, packobj)
1020 end subroutine package_create
1021
1022 !> @brief Check to make sure required input files have been specified
1023 subroutine ftype_check(this, indis)
1024 ! dummy
1025 class(prtmodeltype) :: this
1026 integer(I4B), intent(in) :: indis
1027 ! local
1028 character(len=LINELENGTH) :: errmsg
1029
1030 ! Check for DIS(u) and MIP. Stop if not present.
1031 if (indis == 0) then
1032 write (errmsg, '(1x,a)') &
1033 'Discretization (DIS6, DISV6, or DISU6) package not specified.'
1034 call store_error(errmsg)
1035 end if
1036 if (this%inmip == 0) then
1037 write (errmsg, '(1x,a)') &
1038 'Model input (MIP6) package not specified.'
1039 call store_error(errmsg)
1040 end if
1041
1042 if (count_errors() > 0) then
1043 write (errmsg, '(1x,a)') 'One or more required package(s) not specified.'
1044 call store_error(errmsg)
1045 call store_error_filename(this%filename)
1046 end if
1047 end subroutine ftype_check
1048
1049 !> @brief Solve the model
1050 subroutine prt_solve(this, isuppress_output)
1052 use prtprpmodule, only: prtprptype
1055 use simvariablesmodule, only: warnmsg
1056 ! dummy
1057 class(prtmodeltype) :: this
1058 integer(I4B), intent(in) :: isuppress_output
1059 ! local
1060 integer(I4B) :: np, ip
1061 class(bndtype), pointer :: packobj
1062 type(particletype), pointer :: particle
1063 real(DP) :: tmax
1064 integer(I4B) :: iprp
1065
1066 ! Skip tracking during Picard iterations: PRT doesn't affect the flow
1067 ! solution, so tracking is only needed once on the final output rerun
1068 ! (or on the single call when mxiter=1, which also has isuppress_output=0).
1069 if (isuppress_output /= 0) return
1070
1071 ! A single particle is reused in the tracking loops
1072 ! to avoid allocating and deallocating it each time.
1073 ! get() and put() retrieve and store particle state.
1074 call create_particle(particle)
1075 ! Loop over PRP packages and particles within them.
1076 iprp = 0
1077 do ip = 1, this%bndlist%Count()
1078 packobj => getbndfromlist(this%bndlist, ip)
1079 select type (packobj)
1080 type is (prtprptype)
1081 iprp = iprp + 1
1082 do np = 1, packobj%nparticles
1083 ! Get the particle from the staging store
1084 call packobj%particles_staging%get(particle, this%id, iprp, np)
1085 ! If particle is permanently unreleased, cycle.
1086 ! Raise a termination event if we haven't yet.
1087 ! TODO: when we have generic dynamic vectors,
1088 ! consider terminating permanently unreleased
1089 ! in PRP instead of here. For now, status -8
1090 ! indicates the permanently unreleased event
1091 ! is not yet recorded, status 8 it has been.
1092 if (particle%istatus == (-1 * term_unreleased)) then
1093 call this%method%terminate(particle, status=term_unreleased)
1094 call packobj%particles_staging%put(particle, np)
1095 end if
1096 if (particle%istatus > active) cycle ! Skip terminated particles
1097 if (particle%istatus == 0) then
1098 particle%istatus = active ! Set active status in case of release
1099 if (particle%trelease >= totimc) then
1100 if (particle%trelease > particle%tstop) then
1101 ! The package's stop time is earlier than the release time.
1102 ! Terminate it permanently unreleased and show a warning.
1103 write (warnmsg, '(a,g0,a,g0,a,g0,a)') &
1104 'Particle release point ', particle%irpt, ' has &
1105 &release time ', particle%trelease, ' after package &
1106 &stop time ', particle%tstop, '; particle will not &
1107 &be released.'
1109 call this%method%terminate(particle, status=term_unreleased)
1110 else
1111 ! The particle was released this time step; emit a
1112 ! release event.
1113 call this%method%release(particle)
1114 end if
1115 end if
1116 end if
1117 if (particle%istatus <= active) then
1118 ! Maximum time is the end of the time step or the particle
1119 ! stop time, whichever comes first, unless it's the final
1120 ! time step and the extend option is on, in which case
1121 ! it's just the particle stop time.
1122 if (endofsimulation .and. particle%extend) then
1123 tmax = particle%tstop
1124 else
1125 tmax = min(totimc + delt, particle%tstop)
1126 end if
1127 ! tmax should never be less than the particle's current
1128 ! tracked time: ttrack can't get ahead of totimc, the
1129 ! smaller of the two terms tmax is drawn from, and a
1130 ! release whose time precedes the stop time was already
1131 ! caught above and never reaches this point. If it
1132 ! happens anyway, that's a programmer error: tracking
1133 ! methods assume a nonnegative time interval, and calling
1134 ! apply() with tmax < ttrack sends them a negative one,
1135 ! which corrupts the tracking method.
1136 if (tmax < particle%ttrack) &
1137 call pstop(1, 'Programmer error: PRT tracking tmax &
1138 &precedes particle%ttrack.')
1139 ! Apply the tracking method until the maximum time.
1140 call this%method%apply(particle, tmax)
1141 ! If the particle timed out, terminate it.
1142 ! "Timed out" means it's still active but
1143 ! - it reached its stop time, or
1144 ! - the simulation is over.
1145 ! We can't detect timeout within the tracking
1146 ! method because the method just receives the
1147 ! maximum time with no context on what it is.
1148 ! TODO maybe think about changing that?
1149 if (particle%istatus <= active .and. &
1150 (particle%ttrack == particle%tstop .or. endofsimulation)) &
1151 call this%method%terminate(particle, status=term_timeout)
1152 end if
1153 ! Return the particle to the staging store
1154 call packobj%particles_staging%put(particle, np)
1155 end do
1156 end select
1157 end do
1158 call particle%destroy()
1159 deallocate (particle)
1160 end subroutine prt_solve
1161
1162 !> @brief Source package info and begin to process
1163 subroutine create_bndpkgs(this, bndpkgs, pkgtypes, pkgnames, &
1164 mempaths, inunits)
1165 ! modules
1168 ! dummy
1169 class(prtmodeltype) :: this
1170 integer(I4B), dimension(:), allocatable, intent(inout) :: bndpkgs
1171 type(characterstringtype), dimension(:), contiguous, &
1172 pointer, intent(inout) :: pkgtypes
1173 type(characterstringtype), dimension(:), contiguous, &
1174 pointer, intent(inout) :: pkgnames
1175 type(characterstringtype), dimension(:), contiguous, &
1176 pointer, intent(inout) :: mempaths
1177 integer(I4B), dimension(:), contiguous, &
1178 pointer, intent(inout) :: inunits
1179 ! local
1180 integer(I4B) :: ipakid, ipaknum
1181 character(len=LENFTYPE) :: pkgtype, bndptype
1182 character(len=LENPACKAGENAME) :: pkgname
1183 character(len=LENMEMPATH) :: mempath
1184 integer(I4B), pointer :: inunit
1185 integer(I4B) :: n
1186
1187 if (allocated(bndpkgs)) then
1188 ! create stress packages
1189 ipakid = 1
1190 bndptype = ''
1191 do n = 1, size(bndpkgs)
1192 pkgtype = pkgtypes(bndpkgs(n))
1193 pkgname = pkgnames(bndpkgs(n))
1194 mempath = mempaths(bndpkgs(n))
1195 inunit => inunits(bndpkgs(n))
1196
1197 if (bndptype /= pkgtype) then
1198 ipaknum = 1
1199 bndptype = pkgtype
1200 end if
1201
1202 call this%package_create(pkgtype, ipakid, ipaknum, pkgname, mempath, &
1203 inunit, this%iout)
1204 ipakid = ipakid + 1
1205 ipaknum = ipaknum + 1
1206 end do
1207
1208 ! cleanup
1209 deallocate (bndpkgs)
1210 end if
1211
1212 end subroutine create_bndpkgs
1213
1214 !> @brief Source package info and begin to process
1215 subroutine create_packages(this)
1216 ! modules
1223 use budgetmodule, only: budget_cr
1224 use prtmipmodule, only: mip_cr
1225 use prtfmimodule, only: fmi_cr
1226 use prtocmodule, only: oc_cr
1227 ! dummy
1228 class(prtmodeltype) :: this
1229 ! local
1230 type(characterstringtype), dimension(:), contiguous, &
1231 pointer :: pkgtypes => null()
1232 type(characterstringtype), dimension(:), contiguous, &
1233 pointer :: pkgnames => null()
1234 type(characterstringtype), dimension(:), contiguous, &
1235 pointer :: mempaths => null()
1236 integer(I4B), dimension(:), contiguous, &
1237 pointer :: inunits => null()
1238 character(len=LENMEMPATH) :: model_mempath
1239 character(len=LENFTYPE) :: pkgtype
1240 character(len=LENPACKAGENAME) :: pkgname
1241 character(len=LENMEMPATH) :: mempath
1242 integer(I4B), pointer :: inunit
1243 integer(I4B), dimension(:), allocatable :: bndpkgs
1244 integer(I4B) :: n
1245 integer(I4B) :: indis = 0 ! DIS enabled flag
1246 character(len=LENMEMPATH) :: mempathmip = ''
1247 character(len=LENMEMPATH) :: mempathfmi = ''
1248 character(len=LENMEMPATH) :: mempathoc = ''
1249
1250 ! set input memory paths, input/model and input/model/namfile
1251 model_mempath = create_mem_path(component=this%name, context=idm_context)
1252
1253 ! set pointers to model path package info
1254 call mem_setptr(pkgtypes, 'PKGTYPES', model_mempath)
1255 call mem_setptr(pkgnames, 'PKGNAMES', model_mempath)
1256 call mem_setptr(mempaths, 'MEMPATHS', model_mempath)
1257 call mem_setptr(inunits, 'INUNITS', model_mempath)
1258
1259 ! determine which packages we have. create
1260 ! dis up front as the others depend on it.
1261 do n = 1, size(pkgtypes)
1262 pkgtype = pkgtypes(n)
1263 pkgname = pkgnames(n)
1264 mempath = mempaths(n)
1265 inunit => inunits(n)
1266
1267 select case (pkgtype)
1268 case ('DIS6')
1269 indis = 1
1270 call dis_cr(this%dis, this%name, mempath, indis, this%iout)
1271 case ('DISV6')
1272 indis = 1
1273 call disv_cr(this%dis, this%name, mempath, indis, this%iout)
1274 case ('DISU6')
1275 indis = 1
1276 call disu_cr(this%dis, this%name, mempath, indis, this%iout)
1277 case ('MIP6')
1278 this%inmip = 1
1279 mempathmip = mempath
1280 case ('FMI6')
1281 this%infmi = 1
1282 mempathfmi = mempath
1283 case ('OC6')
1284 this%inoc = 1
1285 mempathoc = mempath
1286 case ('PRP6')
1287 call expandarray(bndpkgs)
1288 bndpkgs(size(bndpkgs)) = n
1289 case default
1290 call pstop(1, "Unrecognized package type: "//pkgtype)
1291 end select
1292 end do
1293
1294 ! Create budget manager
1295 call budget_cr(this%budget, this%name)
1296
1297 ! Create tracking methods
1298 call create_method_dis(this%method_dis)
1299 call create_method_disv(this%method_disv)
1300
1301 ! Create non-boundary packages
1302 call mip_cr(this%mip, this%name, mempathmip, this%inmip, this%iout, this%dis)
1303 call fmi_cr(this%fmi, this%name, mempathfmi, this%infmi, this%iout)
1304 call oc_cr(this%oc, this%name, mempathoc, this%inoc, this%iout)
1305
1306 ! Check required input files
1307 call this%ftype_check(indis)
1308
1309 ! Create boundary packages
1310 call this%create_bndpkgs(bndpkgs, pkgtypes, pkgnames, mempaths, inunits)
1311 call this%create_exg_prp()
1312 end subroutine create_packages
1313
1314 !> @brief Create an exchange PRP package for particles
1315 !! entering this model from other model.
1316 subroutine create_exg_prp(this)
1317 class(prtmodeltype) :: this
1318 ! local
1319 class(bndtype), pointer :: packobj
1320 character(len=LENPACKAGENAME) :: exgprp_name
1321
1322 exgprp_name = 'EXGPRP'
1323
1324 call prp_create(packobj, &
1325 id=0, &
1326 ibcnum=0, &
1327 inunit=-1, &
1328 iout=this%iout, &
1329 namemodel=this%name, &
1330 pakname=exgprp_name, &
1331 fmi=this%fmi)
1332 call addbndtolist(this%bndlist, packobj)
1333 end subroutine create_exg_prp
1334
1335 !> @brief Write model namfile options to list file
1336 subroutine log_namfile_options(this, found)
1338 class(prtmodeltype) :: this
1339 type(prtnamparamfoundtype), intent(in) :: found
1340
1341 write (this%iout, '(1x,a)') 'NAMEFILE OPTIONS:'
1342
1343 if (found%print_input) then
1344 write (this%iout, '(4x,a)') 'STRESS PACKAGE INPUT WILL BE PRINTED '// &
1345 'FOR ALL MODEL STRESS PACKAGES'
1346 end if
1347
1348 if (found%print_flows) then
1349 write (this%iout, '(4x,a)') 'PACKAGE FLOWS WILL BE PRINTED '// &
1350 'FOR ALL MODEL PACKAGES'
1351 end if
1352
1353 if (found%save_flows) then
1354 write (this%iout, '(4x,a)') &
1355 'FLOWS WILL BE SAVED TO BUDGET FILE SPECIFIED IN OUTPUT CONTROL'
1356 end if
1357
1358 write (this%iout, '(1x,a)') 'END NAMEFILE OPTIONS:'
1359 end subroutine log_namfile_options
1360
1361end module prtmodule
Event handler interface. Handlers may signal to the dispatching caller whether they have handled the ...
subroutine, public addbasemodeltolist(list, model)
subroutine model_ar(this)
Allocate and read.
Definition BaseModel.f90:55
subroutine model_ot(this)
Output results.
Definition BaseModel.f90:70
subroutine allocate_scalars(this, modelname)
Allocate scalar variables.
Definition BaseModel.f90:98
subroutine model_rp(this)
Read and prepare.
Definition BaseModel.f90:60
subroutine model_df(this)
Define the model.
Definition BaseModel.f90:50
subroutine model_da(this)
Deallocate.
This module contains the base boundary package.
subroutine, public addbndtolist(list, bnd)
Add boundary to package list.
class(bndtype) function, pointer, public getbndfromlist(list, idx)
Get boundary from package list.
This module contains the BudgetModule.
Definition Budget.f90:20
subroutine, public budget_cr(this, name_model)
Create a new budget object.
Definition Budget.f90:85
subroutine, public rate_accumulator(flow, rin, rout)
Rate accumulator subroutine.
Definition Budget.f90:634
This module contains simulation constants.
Definition Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition Constants.f90:45
@ mnormal
normal output mode
integer(i4b), parameter lenpackagename
maximum length of the package name
Definition Constants.f90:23
integer(i4b), parameter lenpackagetype
maximum length of a package type (DIS6, SFR6, CSUB6, etc.)
Definition Constants.f90:38
integer(i4b), parameter lenbigline
maximum length of a big line
Definition Constants.f90:15
real(dp), parameter dhnoflo
real no flow constant
Definition Constants.f90:93
integer(i4b), parameter lenpakloc
maximum length of a package location
Definition Constants.f90:50
@ dis
DIS6 discretization.
integer(i4b), parameter lenftype
maximum length of a package type (DIS, WEL, OC, etc.)
Definition Constants.f90:39
integer(i4b), parameter lenauxname
maximum length of a aux variable
Definition Constants.f90:35
real(dp), parameter dzero
real constant zero
Definition Constants.f90:65
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
Definition Constants.f90:37
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition Constants.f90:27
real(dp), parameter done
real constant 1
Definition Constants.f90:76
subroutine allocate_scalars(this, name_model, input_mempath)
Allocate and initialize scalar variables.
Definition Dis.f90:819
subroutine, public dis_cr(dis, name_model, input_mempath, inunit, iout)
Create a new structured discretization object.
Definition Dis.f90:99
subroutine allocate_arrays(this)
Allocate and initialize arrays.
Definition Dis.f90:843
subroutine, public disu_cr(dis, name_model, input_mempath, inunit, iout)
Create a new unstructured discretization object.
Definition Disu.f90:135
subroutine, public disv_cr(dis, name_model, input_mempath, inunit, iout)
Create a new discretization by vertices object.
Definition Disv.f90:112
subroutine pstop(status, message)
Stop the program, optionally specifying an error status code.
Definition ErrorUtil.f90:24
Models that solve themselves.
subroutine model_bd(this, icnvg, isuppress_output)
Calculate model budget.
subroutine model_solve(this, isuppress_output)
Solve the model.
subroutine model_cq(this, icnvg, isuppress_output)
Calculate model flows.
subroutine model_ad(this)
Advance the model.
A chaining hash map for integers.
Definition HashTable.f90:7
subroutine, public hash_table_cr(map)
Create a hash table.
Definition HashTable.f90:46
subroutine, public hash_table_da(map)
Deallocate the hash table.
Definition HashTable.f90:64
subroutine, public lowcase(word)
Convert to lower case.
subroutine, public parseline(line, nwords, words, inunit, filename)
Parse a line into words.
subroutine, public upcase(word)
Convert to upper case.
This module defines variable data types.
Definition kind.f90:8
type(listtype), public basemodellist
Definition mf6lists.f90:16
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
subroutine, public memorystore_remove(component, subcomponent, context)
subroutine, public create_method_dis(method)
Create a new structured grid (DIS) tracking method.
Definition MethodDis.f90:50
subroutine, public create_method_disv(method)
Create a new vertex grid (DISV) tracking method.
Particle tracking strategies.
Definition Method.f90:2
subroutine terminate(this, particle, status)
A particle terminates.
Definition Method.f90:222
@ release
particle was released
@ terminate
particle terminated
@ term_timeout
terminated at stop time or end of simulation
Definition Particle.f90:40
@ term_unreleased
terminated permanently unreleased
Definition Particle.f90:38
subroutine create_particle(particle)
Create a new particle.
Definition Particle.f90:166
Particle track output module.
logical(lgp) function, public add_particle_event(context, particle, event)
Add a particle event to be written to eligible files and printed to an output file unit if requested....
subroutine, public fmi_cr(fmiobj, name_model, input_mempath, inunit, iout)
Create a new PrtFmi object.
Definition prt-fmi.f90:60
subroutine, public mip_cr(mip, name_model, input_mempath, inunit, iout, dis)
Create a model input object.
Definition prt-mip.f90:34
integer(i4b), parameter niunit_prt
Definition prt.f90:128
subroutine prt_ot(this)
Print and/or save model output.
Definition prt.f90:582
subroutine prt_rp(this)
Read and prepare (calls package read and prepare routines).
Definition prt.f90:354
subroutine create_bndpkgs(this, bndpkgs, pkgtypes, pkgnames, mempaths, inunits)
Source package info and begin to process.
Definition prt.f90:1165
subroutine prt_ar(this)
Allocate and read.
Definition prt.f90:247
subroutine ftype_check(this, indis)
Check to make sure required input files have been specified.
Definition prt.f90:1024
subroutine prt_ot_saveflow(this, nja, flowja, icbcfl, icbcun)
Save intercell flows.
Definition prt.f90:677
subroutine prt_ad(this)
Time step advance (calls package advance subroutines).
Definition prt.f90:374
subroutine prt_cq(this, icnvg, isuppress_output)
Calculate intercell flow (flowja).
Definition prt.f90:421
subroutine package_create(this, filtyp, ipakid, ipaknum, pakname, mempath, inunit, iout)
Create boundary condition packages for this model.
Definition prt.f90:981
subroutine prt_ot_flow(this, icbcfl, ibudfl, icbcun)
Save flows.
Definition prt.f90:640
subroutine prt_ot_bdsummary(this, ibudfl, ipflag)
Print budget summary.
Definition prt.f90:827
character(len=lenpackagetype), dimension(prt_nmultipkg), public prt_multipkg
Definition prt.f90:123
subroutine create_packages(this)
Source package info and begin to process.
Definition prt.f90:1216
character(len=lenpackagetype), dimension(prt_nbasepkg), public prt_basepkg
Definition prt.f90:109
subroutine prt_solve(this, isuppress_output)
Solve the model.
Definition prt.f90:1051
integer(i4b), parameter, public prt_nmultipkg
PRT multi package array descriptors.
Definition prt.f90:122
character(len=lenbudtxt), dimension(nbditems) budtxt
Definition prt.f90:44
subroutine prt_da(this)
Deallocate.
Definition prt.f90:857
subroutine, public prt_cr(filename, id, modelname)
Create a new particle tracking model object.
Definition prt.f90:134
subroutine prt_ot_printflow(this, ibudfl, flowja)
Print intercell flows.
Definition prt.f90:767
subroutine prt_bd(this, icnvg, isuppress_output)
Calculate flows and budget.
Definition prt.f90:547
subroutine prt_df(this)
Define packages.
Definition prt.f90:214
integer(i4b), parameter, public prt_nbasepkg
PRT base package array descriptors.
Definition prt.f90:108
integer(i4b), parameter nbditems
Definition prt.f90:43
subroutine log_namfile_options(this, found)
Write model namfile options to list file.
Definition prt.f90:1337
subroutine prt_cq_budterms(this)
Calculate particle mass budget terms.
Definition prt.f90:467
subroutine prt_ot_dv(this, idvsave, idvprint, ipflag)
Print dependent variables.
Definition prt.f90:806
subroutine create_exg_prp(this)
Create an exchange PRP package for particles entering this model from other model.
Definition prt.f90:1317
subroutine, public oc_cr(ocobj, name_model, input_mempath, inunit, iout)
Create an output control object.
Definition prt-oc.f90:53
subroutine, public prp_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, fmi, input_mempath)
Create a new particle release point package.
Definition prt-prp.f90:131
This module contains simulation methods.
Definition Sim.f90:10
subroutine, public store_warning(msg, substring)
Store warning message.
Definition Sim.f90:241
subroutine, public store_error(msg, terminate)
Store an error message.
Definition Sim.f90:94
integer(i4b) function, public count_errors()
Return number of errors.
Definition Sim.f90:60
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
Definition Sim.f90:208
This module contains simulation variables.
character(len=linelength) idm_context
integer(i4b) isimcheck
simulation input check flag (1) to check input, (0) to ignore checks
character(len=maxcharlen) warnmsg
warning message string
subroutine csr_diagsum(ia, flowja)
Definition Sparse.f90:263
logical(lgp), pointer, public endofperiod
flag indicating end of stress period
Definition tdis.f90:30
logical(lgp), pointer, public endofsimulation
flag indicating end of simulation
Definition tdis.f90:31
subroutine, public tdis_ot(iout)
Print simulation time.
Definition tdis.f90:271
real(dp), pointer, public totim
time relative to start of simulation
Definition tdis.f90:35
logical(lgp), pointer, public readnewdata
flag indicating time to read new data
Definition tdis.f90:29
real(dp), pointer, public totimc
simulation time at start of time step
Definition tdis.f90:36
integer(i4b), pointer, public kstp
current time step number
Definition tdis.f90:27
integer(i4b), pointer, public kper
current stress period number
Definition tdis.f90:26
real(dp), pointer, public delt
length of the current time step
Definition tdis.f90:32
This module contains version information.
Definition version.f90:7
subroutine write_listfile_header(iout, cmodel_type, write_sys_command, write_kind_info)
Write program header.
Definition version.f90:103
Highest level model type. All models extend this parent type.
Definition BaseModel.f90:16
Derived type for the Budget object.
Definition Budget.f90:40
This class is used to store a single deferred-length character string. It was designed to work in an ...
Structured grid discretization.
Definition Dis.f90:23
Unstructured grid discretization.
Definition Disu.f90:30
Vertex grid discretization.
Definition Disv.f90:25
Base type for models that solve themselves.
A generic heterogeneous doubly-linked list.
Definition List.f90:14
Base type for particle tracking methods.
Definition Method.f90:57
Dispatcher for particle events. Consumers subscribe handlers to the dispatcher. Events may be dispatc...
Particle tracked by the PRT model.
Definition Particle.f90:64
Particle track output manager. Handles printing as well as writing to files. One output unit can be c...
Particle tracking (PRT) model.
Definition prt.f90:48
Output control for particle tracking models.
Definition prt-oc.f90:21
Particle release point (PRP) package.
Definition prt-prp.f90:39