MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
prtmodule Module Reference

Data Types

type  prtmodeltype
 Particle tracking (PRT) model. More...

Functions/Subroutines

subroutine, public prt_cr (filename, id, modelname)
 Create a new particle tracking model object.
subroutine prt_df (this)
 Define packages.
subroutine prt_ar (this)
 Allocate and read.
subroutine prt_rp (this)
 Read and prepare (calls package read and prepare routines).
subroutine prt_ad (this)
 Time step advance (calls package advance subroutines).
subroutine prt_cq (this, icnvg, isuppress_output)
 Calculate intercell flow (flowja).
subroutine prt_cq_budterms (this)
 Calculate particle mass budget terms.
subroutine prt_bd (this, icnvg, isuppress_output)
 Calculate flows and budget.
subroutine prt_ot (this)
 Print and/or save model output.
subroutine prt_ot_flow (this, icbcfl, ibudfl, icbcun)
 Save flows.
subroutine prt_ot_saveflow (this, nja, flowja, icbcfl, icbcun)
 Save intercell flows.
subroutine prt_ot_printflow (this, ibudfl, flowja)
 Print intercell flows.
subroutine prt_ot_dv (this, idvsave, idvprint, ipflag)
 Print dependent variables.
subroutine prt_ot_bdsummary (this, ibudfl, ipflag)
 Print budget summary.
subroutine prt_da (this)
 Deallocate.
subroutine allocate_scalars (this, modelname)
 Allocate memory for scalars.
subroutine allocate_arrays (this)
 Allocate arrays.
subroutine package_create (this, filtyp, ipakid, ipaknum, pakname, mempath, inunit, iout)
 Create boundary condition packages for this model.
subroutine ftype_check (this, indis)
 Check to make sure required input files have been specified.
subroutine prt_solve (this, isuppress_output)
 Solve the model.
real(dp) function sim_end (this, tsim)
 End of the simulation for tracking, the same for every particle: the computed end, or a tracking or release time in the final time step just after it.
pure real(dp) function specified_end (tend, times)
 The latest specified time just after (by is_close) a computed end of tracking, or the end if there's none.
subroutine warn_late_tracktimes (this, prp, tend)
 Warn about tracking times after the end of the simulation.
subroutine create_bndpkgs (this, bndpkgs, pkgtypes, pkgnames, mempaths, inunits)
 Source package info and begin to process.
subroutine create_packages (this)
 Source package info and begin to process.
subroutine create_exg_prp (this)
 Create an exchange PRP package for particles entering this model from other model.
subroutine log_namfile_options (this, found)
 Write model namfile options to list file.

Variables

integer(i4b), parameter nbditems = 2
character(len=lenbudtxt), dimension(nbditems) budtxt
integer(i4b), parameter, public prt_nbasepkg = 50
 PRT base package array descriptors.
character(len=lenpackagetype), dimension(prt_nbasepkg), public prt_basepkg
integer(i4b), parameter, public prt_nmultipkg = 50
 PRT multi package array descriptors.
character(len=lenpackagetype), dimension(prt_nmultipkg), public prt_multipkg
integer(i4b), parameter niunit_prt = PRT_NBASEPKG + PRT_NMULTIPKG

Function/Subroutine Documentation

◆ allocate_arrays()

subroutine prtmodule::allocate_arrays ( class(prtmodeltype) this)
private

Definition at line 964 of file prt.f90.

966 class(PrtModelType) :: this
967 integer(I4B) :: n
968
969 ! Allocate arrays in parent type (ibound, flowja, nja)
970 call this%ExplicitModelType%allocate_arrays()
971
972 ! Allocate and initialize PRT-specific arrays
973 call mem_allocate(this%masssto, this%dis%nodes, &
974 'MASSSTO', this%memoryPath)
975 call mem_allocate(this%massstoold, this%dis%nodes, &
976 'MASSSTOOLD', this%memoryPath)
977 call mem_allocate(this%ratesto, this%dis%nodes, &
978 'RATESTO', this%memoryPath)
979 call mem_allocate(this%masstrm, this%dis%nodes, &
980 'MASSTRM', this%memoryPath)
981 call mem_allocate(this%ratetrm, this%dis%nodes, &
982 'RATETRM', this%memoryPath)
983 do n = 1, this%dis%nodes
984 this%masssto(n) = dzero
985 this%massstoold(n) = dzero
986 this%ratesto(n) = dzero
987 this%masstrm(n) = dzero
988 this%ratetrm(n) = dzero
989 end do

◆ allocate_scalars()

subroutine prtmodule::allocate_scalars ( class(prtmodeltype) this,
character(len=*), intent(in) modelname )
private

Definition at line 935 of file prt.f90.

936 ! dummy
937 class(PrtModelType) :: this
938 character(len=*), intent(in) :: modelname
939
940 ! allocate members from parent class
941 call this%ExplicitModelType%allocate_scalars(modelname)
942
943 ! allocate members that are part of model class
944 call mem_allocate(this%infmi, 'INFMI', this%memoryPath)
945 call mem_allocate(this%inmip, 'INMIP', this%memoryPath)
946 call mem_allocate(this%inmvt, 'INMVT', this%memoryPath)
947 call mem_allocate(this%inmst, 'INMST', this%memoryPath)
948 call mem_allocate(this%inadv, 'INADV', this%memoryPath)
949 call mem_allocate(this%indsp, 'INDSP', this%memoryPath)
950 call mem_allocate(this%inssm, 'INSSM', this%memoryPath)
951 call mem_allocate(this%inoc, 'INOC ', this%memoryPath)
952
953 this%infmi = 0
954 this%inmip = 0
955 this%inmvt = 0
956 this%inmst = 0
957 this%inadv = 0
958 this%indsp = 0
959 this%inssm = 0
960 this%inoc = 0

◆ create_bndpkgs()

subroutine prtmodule::create_bndpkgs ( class(prtmodeltype) this,
integer(i4b), dimension(:), intent(inout), allocatable bndpkgs,
type(characterstringtype), dimension(:), intent(inout), pointer, contiguous pkgtypes,
type(characterstringtype), dimension(:), intent(inout), pointer, contiguous pkgnames,
type(characterstringtype), dimension(:), intent(inout), pointer, contiguous mempaths,
integer(i4b), dimension(:), intent(inout), pointer, contiguous inunits )
private

Definition at line 1262 of file prt.f90.

1264 ! modules
1267 ! dummy
1268 class(PrtModelType) :: this
1269 integer(I4B), dimension(:), allocatable, intent(inout) :: bndpkgs
1270 type(CharacterStringType), dimension(:), contiguous, &
1271 pointer, intent(inout) :: pkgtypes
1272 type(CharacterStringType), dimension(:), contiguous, &
1273 pointer, intent(inout) :: pkgnames
1274 type(CharacterStringType), dimension(:), contiguous, &
1275 pointer, intent(inout) :: mempaths
1276 integer(I4B), dimension(:), contiguous, &
1277 pointer, intent(inout) :: inunits
1278 ! local
1279 integer(I4B) :: ipakid, ipaknum
1280 character(len=LENFTYPE) :: pkgtype, bndptype
1281 character(len=LENPACKAGENAME) :: pkgname
1282 character(len=LENMEMPATH) :: mempath
1283 integer(I4B), pointer :: inunit
1284 integer(I4B) :: n
1285
1286 if (allocated(bndpkgs)) then
1287 ! create stress packages
1288 ipakid = 1
1289 bndptype = ''
1290 do n = 1, size(bndpkgs)
1291 pkgtype = pkgtypes(bndpkgs(n))
1292 pkgname = pkgnames(bndpkgs(n))
1293 mempath = mempaths(bndpkgs(n))
1294 inunit => inunits(bndpkgs(n))
1295
1296 if (bndptype /= pkgtype) then
1297 ipaknum = 1
1298 bndptype = pkgtype
1299 end if
1300
1301 call this%package_create(pkgtype, ipakid, ipaknum, pkgname, mempath, &
1302 inunit, this%iout)
1303 ipakid = ipakid + 1
1304 ipaknum = ipaknum + 1
1305 end do
1306
1307 ! cleanup
1308 deallocate (bndpkgs)
1309 end if
1310
This module contains simulation constants.
Definition Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition Constants.f90:45
integer(i4b), parameter lenpackagename
maximum length of the package name
Definition Constants.f90:23
This class is used to store a single deferred-length character string. It was designed to work in an ...

◆ create_exg_prp()

subroutine prtmodule::create_exg_prp ( class(prtmodeltype) this)
private

Definition at line 1415 of file prt.f90.

1416 class(PrtModelType) :: this
1417 ! local
1418 class(BndType), pointer :: packobj
1419 character(len=LENPACKAGENAME) :: exgprp_name
1420
1421 exgprp_name = 'EXGPRP'
1422
1423 call prp_create(packobj, &
1424 id=0, &
1425 ibcnum=0, &
1426 inunit=-1, &
1427 iout=this%iout, &
1428 namemodel=this%name, &
1429 pakname=exgprp_name, &
1430 fmi=this%fmi)
1431 call addbndtolist(this%bndlist, packobj)
Here is the call graph for this function:

◆ create_packages()

subroutine prtmodule::create_packages ( class(prtmodeltype) this)
private

Definition at line 1314 of file prt.f90.

1315 ! modules
1322 use budgetmodule, only: budget_cr
1323 use prtmipmodule, only: mip_cr
1324 use prtfmimodule, only: fmi_cr
1325 use prtocmodule, only: oc_cr
1326 ! dummy
1327 class(PrtModelType) :: this
1328 ! local
1329 type(CharacterStringType), dimension(:), contiguous, &
1330 pointer :: pkgtypes => null()
1331 type(CharacterStringType), dimension(:), contiguous, &
1332 pointer :: pkgnames => null()
1333 type(CharacterStringType), dimension(:), contiguous, &
1334 pointer :: mempaths => null()
1335 integer(I4B), dimension(:), contiguous, &
1336 pointer :: inunits => null()
1337 character(len=LENMEMPATH) :: model_mempath
1338 character(len=LENFTYPE) :: pkgtype
1339 character(len=LENPACKAGENAME) :: pkgname
1340 character(len=LENMEMPATH) :: mempath
1341 integer(I4B), pointer :: inunit
1342 integer(I4B), dimension(:), allocatable :: bndpkgs
1343 integer(I4B) :: n
1344 integer(I4B) :: indis = 0 ! DIS enabled flag
1345 character(len=LENMEMPATH) :: mempathmip = ''
1346 character(len=LENMEMPATH) :: mempathfmi = ''
1347 character(len=LENMEMPATH) :: mempathoc = ''
1348
1349 ! set input memory paths, input/model and input/model/namfile
1350 model_mempath = create_mem_path(component=this%name, context=idm_context)
1351
1352 ! set pointers to model path package info
1353 call mem_setptr(pkgtypes, 'PKGTYPES', model_mempath)
1354 call mem_setptr(pkgnames, 'PKGNAMES', model_mempath)
1355 call mem_setptr(mempaths, 'MEMPATHS', model_mempath)
1356 call mem_setptr(inunits, 'INUNITS', model_mempath)
1357
1358 ! determine which packages we have. create
1359 ! dis up front as the others depend on it.
1360 do n = 1, size(pkgtypes)
1361 pkgtype = pkgtypes(n)
1362 pkgname = pkgnames(n)
1363 mempath = mempaths(n)
1364 inunit => inunits(n)
1365
1366 select case (pkgtype)
1367 case ('DIS6')
1368 indis = 1
1369 call dis_cr(this%dis, this%name, mempath, indis, this%iout)
1370 case ('DISV6')
1371 indis = 1
1372 call disv_cr(this%dis, this%name, mempath, indis, this%iout)
1373 case ('DISU6')
1374 indis = 1
1375 call disu_cr(this%dis, this%name, mempath, indis, this%iout)
1376 case ('MIP6')
1377 this%inmip = 1
1378 mempathmip = mempath
1379 case ('FMI6')
1380 this%infmi = 1
1381 mempathfmi = mempath
1382 case ('OC6')
1383 this%inoc = 1
1384 mempathoc = mempath
1385 case ('PRP6')
1386 call expandarray(bndpkgs)
1387 bndpkgs(size(bndpkgs)) = n
1388 case default
1389 call pstop(1, "Unrecognized package type: "//pkgtype)
1390 end select
1391 end do
1392
1393 ! Create budget manager
1394 call budget_cr(this%budget, this%name)
1395
1396 ! Create tracking methods
1397 call create_method_dis(this%method_dis)
1398 call create_method_disv(this%method_disv)
1399
1400 ! Create non-boundary packages
1401 call mip_cr(this%mip, this%name, mempathmip, this%inmip, this%iout, this%dis)
1402 call fmi_cr(this%fmi, this%name, mempathfmi, this%infmi, this%iout)
1403 call oc_cr(this%oc, this%name, mempathoc, this%inoc, this%iout)
1404
1405 ! Check required input files
1406 call this%ftype_check(indis)
1407
1408 ! Create boundary packages
1409 call this%create_bndpkgs(bndpkgs, pkgtypes, pkgnames, mempaths, inunits)
1410 call this%create_exg_prp()
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
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
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
subroutine, public oc_cr(ocobj, name_model, input_mempath, inunit, iout)
Create an output control object.
Definition prt-oc.f90:53
This module contains simulation variables.
character(len=linelength) idm_context
Here is the call graph for this function:

◆ ftype_check()

subroutine prtmodule::ftype_check ( class(prtmodeltype) this,
integer(i4b), intent(in) indis )
private

Definition at line 1037 of file prt.f90.

1038 ! dummy
1039 class(PrtModelType) :: this
1040 integer(I4B), intent(in) :: indis
1041 ! local
1042 character(len=LINELENGTH) :: errmsg
1043
1044 ! Check for DIS(u) and MIP. Stop if not present.
1045 if (indis == 0) then
1046 write (errmsg, '(1x,a)') &
1047 'Discretization (DIS6, DISV6, or DISU6) package not specified.'
1048 call store_error(errmsg)
1049 end if
1050 if (this%inmip == 0) then
1051 write (errmsg, '(1x,a)') &
1052 'Model input (MIP6) package not specified.'
1053 call store_error(errmsg)
1054 end if
1055
1056 if (count_errors() > 0) then
1057 write (errmsg, '(1x,a)') 'One or more required package(s) not specified.'
1058 call store_error(errmsg)
1059 call store_error_filename(this%filename)
1060 end if
Here is the call graph for this function:

◆ log_namfile_options()

subroutine prtmodule::log_namfile_options ( class(prtmodeltype) this,
type(prtnamparamfoundtype), intent(in) found )
private

Definition at line 1435 of file prt.f90.

1437 class(PrtModelType) :: this
1438 type(PrtNamParamFoundType), intent(in) :: found
1439
1440 write (this%iout, '(1x,a)') 'NAMEFILE OPTIONS:'
1441
1442 if (found%print_input) then
1443 write (this%iout, '(4x,a)') 'STRESS PACKAGE INPUT WILL BE PRINTED '// &
1444 'FOR ALL MODEL STRESS PACKAGES'
1445 end if
1446
1447 if (found%print_flows) then
1448 write (this%iout, '(4x,a)') 'PACKAGE FLOWS WILL BE PRINTED '// &
1449 'FOR ALL MODEL PACKAGES'
1450 end if
1451
1452 if (found%save_flows) then
1453 write (this%iout, '(4x,a)') &
1454 'FLOWS WILL BE SAVED TO BUDGET FILE SPECIFIED IN OUTPUT CONTROL'
1455 end if
1456
1457 write (this%iout, '(1x,a)') 'END NAMEFILE OPTIONS:'

◆ package_create()

subroutine prtmodule::package_create ( class(prtmodeltype) this,
character(len=*), intent(in) filtyp,
integer(i4b), intent(in) ipakid,
integer(i4b), intent(in) ipaknum,
character(len=*), intent(in) pakname,
character(len=*), intent(in) mempath,
integer(i4b), intent(in) inunit,
integer(i4b), intent(in) iout )
private

Definition at line 993 of file prt.f90.

995 ! modules
996 use constantsmodule, only: linelength
997 ! dummy
998 class(PrtModelType) :: this
999 character(len=*), intent(in) :: filtyp
1000 character(len=LINELENGTH) :: errmsg
1001 integer(I4B), intent(in) :: ipakid
1002 integer(I4B), intent(in) :: ipaknum
1003 character(len=*), intent(in) :: pakname
1004 character(len=*), intent(in) :: mempath
1005 integer(I4B), intent(in) :: inunit
1006 integer(I4B), intent(in) :: iout
1007 ! local
1008 class(BndType), pointer :: packobj
1009 class(BndType), pointer :: packobj2
1010 integer(I4B) :: ip
1011
1012 ! This part creates the package object
1013 select case (filtyp)
1014 case ('PRP6')
1015 call prp_create(packobj, ipakid, ipaknum, inunit, iout, &
1016 this%name, pakname, this%fmi, mempath)
1017 case default
1018 write (errmsg, *) 'Invalid package type: ', filtyp
1019 call store_error(errmsg, terminate=.true.)
1020 end select
1021
1022 ! Packages is the bndlist that is associated with the parent model
1023 ! The following statement puts a pointer to this package in the ipakid
1024 ! position of packages.
1025 do ip = 1, this%bndlist%Count()
1026 packobj2 => getbndfromlist(this%bndlist, ip)
1027 if (packobj2%packName == pakname) then
1028 write (errmsg, '(a,a)') 'Cannot create package. Package name '// &
1029 'already exists: ', trim(pakname)
1030 call store_error(errmsg, terminate=.true.)
1031 end if
1032 end do
1033 call addbndtolist(this%bndlist, packobj)
Here is the call graph for this function:

◆ prt_ad()

subroutine prtmodule::prt_ad ( class(prtmodeltype) this)
private

Definition at line 376 of file prt.f90.

377 ! modules
379 ! dummy
380 class(PrtModelType) :: this
381 class(BndType), pointer :: packobj
382 ! local
383 integer(I4B) :: ip, i
384
385 ! Discard buffered events from previous time step solve attempts.
386 ! prt_advance() is called on every sln_ca(): once per ATS retry,
387 ! once per Picard iteration, and once for the post-Picard output
388 ! rerun if mxiter > 1. Tracking is skipped during Picard iterations
389 ! (isuppress_output=1) in prt_solve, so the buffer is empty here on
390 ! Picard calls and the discard is a no-op. On the output rerun
391 ! (isuppress_output=0), tracking runs once and the buffer is cleared
392 ! before it is filled, so only events from that run reach disk.
393 call this%tracks%discard_buffer()
394
395 ! Advance fmi
396 call this%fmi%fmi_ad()
397
398 ! Advance release packages
399 do ip = 1, this%bndlist%Count()
400 packobj => getbndfromlist(this%bndlist, ip)
401 call packobj%bnd_ad()
402 if (isimcheck > 0) &
403 call packobj%bnd_ck()
404 end do
405
406 ! Initialize the flowja array. Flowja is calculated each time,
407 ! even if output is suppressed. (Flowja represents flow of particle
408 ! mass and is positive into a cell. Currently, each particle is assigned
409 ! unit mass.) Flowja is updated continually as particles are tracked
410 ! over the time step and at the end of the time step. The diagonal
411 ! position of the flowja array will contain the flow residual.
412 do i = 1, this%dis%nja
413 this%flowja(i) = dzero
414 end do
integer(i4b) isimcheck
simulation input check flag (1) to check input, (0) to ignore checks
Here is the call graph for this function:

◆ prt_ar()

subroutine prtmodule::prt_ar ( class(prtmodeltype) this)
private

(1) allocates and reads packages part of this model, (2) allocates memory for arrays part of this model object

Definition at line 249 of file prt.f90.

250 ! modules
251 use constantsmodule, only: dhnoflo
252 use prtprpmodule, only: prtprptype
253 use prtmipmodule, only: prtmiptype
254 use simvariablesmodule, only: warnmsg
255 ! dummy
256 class(PrtModelType) :: this
257 ! locals
258 integer(I4B) :: ip, nprp
259 class(BndType), pointer :: packobj
260 class(*), pointer :: p
261
262 ! Set up basic packages
263 call this%fmi%fmi_ar(this%ibound)
264 if (this%inmip > 0) call this%mip%mip_ar()
265
266 ! Set up output control and budget
267 call this%oc%oc_ar(this%dis, dhnoflo)
268 call this%budget%set_ibudcsv(this%oc%ibudcsv)
269
270 ! Initialize the event buffer (memory or scratch file per OC option)
271 call this%tracks%init_buffer(this%oc%scratch_buffer)
272
273 ! Select tracking events
274 call this%tracks%select_events( &
275 this%oc%trackrelease, &
276 this%oc%trackfeatexit, &
277 this%oc%tracktimestep, &
278 this%oc%trackterminate, &
279 this%oc%trackweaksink, &
280 this%oc%trackusertime, &
281 this%oc%tracksubfexit, &
282 this%oc%trackdropped)
283
284 ! Set up boundary pkgs and pkg-scoped track files
285 nprp = 0
286 do ip = 1, this%bndlist%Count()
287 packobj => getbndfromlist(this%bndlist, ip)
288 select type (packobj)
289 type is (prtprptype)
290 nprp = nprp + 1
291 call packobj%prp_set_pointers(this%ibound, this%mip%izone)
292 call packobj%bnd_ar()
293 if (packobj%itrkout > 0) then
294 call this%tracks%init_file( &
295 packobj%itrkout, &
296 iprp=nprp)
297 end if
298 if (packobj%itrkcsv > 0) then
299 call this%tracks%init_file( &
300 packobj%itrkcsv, &
301 csv=.true., &
302 iprp=nprp)
303 end if
304 class default
305 call packobj%bnd_ar()
306 end select
307 end do
308
309 ! Set up model-scoped track files
310 if (this%oc%itrkout > 0) &
311 call this%tracks%init_file(this%oc%itrkout)
312 if (this%oc%itrkcsv > 0) &
313 call this%tracks%init_file(this%oc%itrkcsv, csv=.true.)
314
315 ! Warn if no track files are configured
316 if (this%tracks%ntrackfiles == 0) then
317 write (warnmsg, '(a)') &
318 'No particle track output configured (TRACK or TRACKCSV FILEOUT &
319 &in OC or any PRP). Particle events will not be saved.'
320 call store_warning(warnmsg)
321 end if
322
323 ! Initialize and select the tracking method based on discretization
324 select type (dis => this%dis)
325 type is (distype)
326 call this%method_dis%init( &
327 fmi=this%fmi, &
328 events=this%events, &
329 izone=this%mip%izone, &
330 flowja=this%flowja, &
331 porosity=this%mip%porosity, &
332 retfactor=this%mip%retfactor, &
333 tracktimes=this%oc%tracktimes)
334 this%method => this%method_dis
335 type is (disvtype)
336 call this%method_disv%init( &
337 fmi=this%fmi, &
338 events=this%events, &
339 izone=this%mip%izone, &
340 flowja=this%flowja, &
341 porosity=this%mip%porosity, &
342 retfactor=this%mip%retfactor, &
343 tracktimes=this%oc%tracktimes)
344 this%method => this%method_disv
345 end select
346
347 ! Subscribe particle track output manager to events
348 p => this%tracks
349 call this%events%subscribe(add_particle_event, p)
350
351 ! Set verbose tracing if requested
352 if (this%oc%dump_event_trace) this%tracks%iout = 0
real(dp), parameter dhnoflo
real no flow constant
Definition Constants.f90:93
@ dis
DIS6 discretization.
character(len=maxcharlen) warnmsg
warning message string
Particle release point (PRP) package.
Definition prt-prp.f90:46
Here is the call graph for this function:

◆ prt_bd()

subroutine prtmodule::prt_bd ( class(prtmodeltype) this,
integer(i4b), intent(in) icnvg,
integer(i4b), intent(in) isuppress_output )
private

(1) Calculate intercell flows (flowja) (2) Calculate package contributions to model budget

Definition at line 543 of file prt.f90.

544 ! modules
545 use tdismodule, only: delt
547 ! dummy
548 class(PrtModelType) :: this
549 integer(I4B), intent(in) :: icnvg
550 integer(I4B), intent(in) :: isuppress_output
551 ! local
552 integer(I4B) :: ip
553 class(BndType), pointer :: packobj
554 real(DP) :: rin
555 real(DP) :: rout
556
557 ! Budget routines (start by resetting). Sole purpose of this section
558 ! is to add in and outs to model budget. All ins and out for a model
559 ! should be added here to this%budget. In a subsequent exchange call,
560 ! exchange flows might also be added.
561 call this%budget%reset()
562 ! storage term
563 call rate_accumulator(this%ratesto, rin, rout)
564 call this%budget%addentry(rin, rout, delt, budtxt(1), &
565 isuppress_output, ' PRT')
566 ! termination term
567 call rate_accumulator(this%ratetrm, rin, rout)
568 call this%budget%addentry(rin, rout, delt, budtxt(2), &
569 isuppress_output, ' PRT')
570 ! boundary packages
571 do ip = 1, this%bndlist%Count()
572 packobj => getbndfromlist(this%bndlist, ip)
573 call packobj%bnd_bd(this%budget)
574 end do
subroutine, public rate_accumulator(flow, rin, rout)
Rate accumulator subroutine.
Definition Budget.f90:634
real(dp), pointer, public delt
length of the current time step
Definition tdis.f90:32
Here is the call graph for this function:

◆ prt_cq()

subroutine prtmodule::prt_cq ( class(prtmodeltype) this,
integer(i4b), intent(in) icnvg,
integer(i4b), intent(in) isuppress_output )
private

Definition at line 418 of file prt.f90.

419 ! modules
420 use sparsemodule, only: csr_diagsum
421 use tdismodule, only: delt
422 use prtprpmodule, only: prtprptype
423 ! dummy
424 class(PrtModelType) :: this
425 integer(I4B), intent(in) :: icnvg
426 integer(I4B), intent(in) :: isuppress_output
427 ! local
428 integer(I4B) :: i
429 integer(I4B) :: ip
430 class(BndType), pointer :: packobj
431 real(DP) :: tled
432
433 ! Flowja is calculated each time, even if output is suppressed.
434 ! Flowja represents flow of particle mass and is positive into a cell.
435 ! Currently, each particle is assigned unit mass.
436 !
437 ! Reciprocal of time step size.
438 tled = done / delt
439 !
440 ! Flowja was updated continually as particles were tracked over the
441 ! time step. At this point, flowja contains the net particle mass
442 ! exchanged between cells during the time step. To convert these to
443 ! flow rates (particle mass per time), divide by the time step size.
444 do i = 1, this%dis%nja
445 this%flowja(i) = this%flowja(i) * tled
446 end do
447
448 ! Particle mass budget terms
449 call this%prt_cq_budterms()
450
451 ! Go through packages and call cq routines. Just a formality.
452 do ip = 1, this%bndlist%Count()
453 packobj => getbndfromlist(this%bndlist, ip)
454 call packobj%bnd_cq(this%masssto, this%flowja)
455 end do
456
457 ! Finalize calculation of flowja by adding face flows to the diagonal.
458 ! This results in the flow residual being stored in the diagonal
459 ! position for each cell.
460 call csr_diagsum(this%dis%con%ia, this%flowja)
subroutine csr_diagsum(ia, flowja)
Definition Sparse.f90:263
Here is the call graph for this function:

◆ prt_cq_budterms()

subroutine prtmodule::prt_cq_budterms ( class(prtmodeltype) this)
private

Definition at line 464 of file prt.f90.

465 ! modules
466 use tdismodule, only: delt
467 use prtprpmodule, only: prtprptype
468 ! dummy
469 class(PrtModelType) :: this
470 ! local
471 integer(I4B) :: ip
472 class(BndType), pointer :: packobj
473 integer(I4B) :: n
474 integer(I4B) :: np
475 integer(I4B) :: idiag
476 integer(I4B) :: iprp
477 integer(I4B) :: istatus
478 real(DP) :: tled
479 real(DP) :: ratesto, ratetrm
480 character(len=:), allocatable :: particle_id
481 type(ParticleType), pointer :: particle
482
483 call create_particle(particle)
484
485 ! Reciprocal of time step size.
486 tled = done / delt
487
488 ! Reset mass and rate arrays
489 do n = 1, this%dis%nodes
490 this%masssto(n) = dzero
491 this%masstrm(n) = dzero
492 this%ratesto(n) = dzero
493 this%ratetrm(n) = dzero
494 end do
495
496 ! Loop over PRP packages and assign particle mass to the
497 ! appropriate budget term based on the particle status.
498 iprp = 0
499 do ip = 1, this%bndlist%Count()
500 packobj => getbndfromlist(this%bndlist, ip)
501 select type (packobj)
502 type is (prtprptype)
503 iprp = iprp + 1
504 do np = 1, packobj%nparticles
505 call packobj%particles_staging%get(particle, this%id, iprp, np)
506 istatus = packobj%particles_staging%istatus(np)
507 particle_id = particle%get_id()
508 if (istatus == active) then
509 ! calculate storage mass
510 n = packobj%particles_staging%itrdomain(np, level_feature)
511 this%masssto(n) = this%masssto(n) + done ! unit mass
512 else if (istatus > active) then
513 if (this%trm_ids%get(particle_id) /= 0) cycle
514 ! calculate terminating mass
515 n = packobj%particles_staging%itrdomain(np, level_feature)
516 this%masstrm(n) = this%masstrm(n) + done ! unit mass
517 end if
518 end do
519 end select
520 end do
521
522 ! Calculate rates and update flowja
523 do n = 1, this%dis%nodes
524 ratesto = -(this%masssto(n) - this%massstoold(n)) * tled
525 ratetrm = -this%masstrm(n) * tled
526 this%ratesto(n) = ratesto
527 this%ratetrm(n) = ratetrm
528 idiag = this%dis%con%ia(n)
529 this%flowja(idiag) = this%flowja(idiag) + ratesto
530 end do
531
532 call particle%destroy()
533 deallocate (particle)
534
Here is the call graph for this function:

◆ prt_cr()

subroutine, public prtmodule::prt_cr ( character(len=*), intent(in) filename,
integer(i4b), intent(in) id,
character(len=*), intent(in) modelname )

Definition at line 136 of file prt.f90.

137 ! modules
138 use listsmodule, only: basemodellist
146 ! dummy
147 character(len=*), intent(in) :: filename
148 integer(I4B), intent(in) :: id
149 character(len=*), intent(in) :: modelname
150 ! local
151 type(PrtModelType), pointer :: this
152 class(BaseModelType), pointer :: model
153 character(len=LENMEMPATH) :: input_mempath
154 character(len=LINELENGTH) :: lst_fname
155 type(PrtNamParamFoundType) :: found
156
157 ! Allocate a new PRT Model (this)
158 allocate (this)
159
160 ! Set this before any allocs in the memory manager can be done
161 this%memoryPath = create_mem_path(modelname)
162
163 ! Allocate event system and track output manager
164 allocate (this%events)
165 allocate (this%tracks)
166
167 ! Allocate scalars and add model to basemodellist
168 call this%allocate_scalars(modelname)
169 model => this
171
172 ! Assign variables
173 this%filename = filename
174 this%name = modelname
175 this%macronym = 'PRT'
176 this%id = id
177
178 ! Set input model namfile memory path
179 input_mempath = create_mem_path(modelname, 'NAM', idm_context)
180
181 ! Copy options from input context
182 call mem_set_value(this%iprpak, 'PRINT_INPUT', input_mempath, &
183 found%print_input)
184 call mem_set_value(this%iprflow, 'PRINT_FLOWS', input_mempath, &
185 found%print_flows)
186 call mem_set_value(this%ipakcb, 'SAVE_FLOWS', input_mempath, &
187 found%save_flows)
188
189 ! Create the list file
190 call this%create_lstfile(lst_fname, filename, found%list, &
191 'PARTICLE TRACKING MODEL (PRT)')
192
193 ! Activate save_flows if found
194 if (found%save_flows) then
195 this%ipakcb = -1
196 end if
197
198 ! Create model packages
199 call this%create_packages()
200
201 ! Create hash table for terminated particle ids
202 call hash_table_cr(this%trm_ids)
203
204 ! Log options
205 if (this%iout > 0) then
206 call this%log_namfile_options(found)
207 end if
208
subroutine, public addbasemodeltolist(list, model)
type(listtype), public basemodellist
Definition mf6lists.f90:16
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prt_da()

subroutine prtmodule::prt_da ( class(prtmodeltype) this)
private

Definition at line 870 of file prt.f90.

871 ! modules
875 ! dummy
876 class(PrtModelType) :: this
877 ! local
878 integer(I4B) :: ip
879 class(BndType), pointer :: packobj
880
881 ! Deallocate idm memory
882 call memorystore_remove(this%name, 'NAM', idm_context)
883 call memorystore_remove(component=this%name, context=idm_context)
884
885 ! Internal packages
886 call this%dis%dis_da()
887 call this%fmi%fmi_da()
888 call this%mip%mip_da()
889 call this%budget%budget_da()
890 call this%oc%oc_da()
891 deallocate (this%dis)
892 deallocate (this%fmi)
893 deallocate (this%mip)
894 deallocate (this%budget)
895 deallocate (this%oc)
896
897 ! Method objects
898 call this%method_dis%deallocate()
899 deallocate (this%method_dis)
900 call this%method_disv%deallocate()
901 deallocate (this%method_disv)
902
903 ! Boundary packages
904 do ip = 1, this%bndlist%Count()
905 packobj => getbndfromlist(this%bndlist, ip)
906 call packobj%bnd_da()
907 deallocate (packobj)
908 end do
909
910 ! Scalars
911 call mem_deallocate(this%infmi)
912 call mem_deallocate(this%inmip)
913 call mem_deallocate(this%inadv)
914 call mem_deallocate(this%indsp)
915 call mem_deallocate(this%inssm)
916 call mem_deallocate(this%inmst)
917 call mem_deallocate(this%inmvt)
918 call mem_deallocate(this%inoc)
919
920 ! Arrays
921 call mem_deallocate(this%masssto)
922 call mem_deallocate(this%massstoold)
923 call mem_deallocate(this%ratesto)
924 call mem_deallocate(this%masstrm)
925 call mem_deallocate(this%ratetrm)
926
927 call this%tracks%destroy()
928 deallocate (this%events)
929 deallocate (this%tracks)
930
931 call this%ExplicitModelType%model_da()
subroutine, public memorystore_remove(component, subcomponent, context)
Here is the call graph for this function:

◆ prt_df()

subroutine prtmodule::prt_df ( class(prtmodeltype) this)
private

(1) call df routines for each package (2) set variables and pointers

Definition at line 216 of file prt.f90.

217 ! modules
218 use prtprpmodule, only: prtprptype
219 ! dummy
220 class(PrtModelType) :: this
221 ! local
222 integer(I4B) :: ip
223 class(BndType), pointer :: packobj
224
225 ! Define packages and utility objects
226 call this%dis%dis_df()
227 call this%fmi%fmi_df(this%dis, 1)
228 call this%oc%oc_df()
229 call this%budget%budget_df(niunit_prt, 'MASS', 'M')
230
231 ! Define packages and assign iout for time series managers
232 do ip = 1, this%bndlist%Count()
233 packobj => getbndfromlist(this%bndlist, ip)
234 call packobj%bnd_df(this%dis%nodes, this%dis)
235 packobj%TsManager%iout = this%iout
236 packobj%TasManager%iout = this%iout
237 end do
238
239 ! Allocate model arrays
240 call this%allocate_arrays()
241
Here is the call graph for this function:

◆ prt_ot()

subroutine prtmodule::prt_ot ( class(prtmodeltype) this)
private

Definition at line 578 of file prt.f90.

579 use tdismodule, only: tdis_ot, endofperiod
580 use prtprpmodule, only: prtprptype
581 ! dummy
582 class(PrtModelType) :: this
583 ! local
584 integer(I4B) :: idvsave
585 integer(I4B) :: idvprint
586 integer(I4B) :: icbcfl
587 integer(I4B) :: icbcun
588 integer(I4B) :: ibudfl
589 integer(I4B) :: ipflag
590 integer(I4B) :: ip, iprp, np, n
591 class(BndType), pointer :: packobj
592 type(ParticleType), pointer :: particle
593
594 ! Flush buffered events to disk
595 call this%tracks%flush_buffer()
596
597 ! Commit each PRP's staged state and mark terminated particles,
598 ! so later steps don't count their termination again
599 call create_particle(particle)
600 iprp = 0
601 do ip = 1, this%bndlist%Count()
602 packobj => getbndfromlist(this%bndlist, ip)
603 select type (packobj)
604 type is (prtprptype)
605 iprp = iprp + 1
606 call packobj%prp_commit()
607 do np = 1, packobj%nparticles
608 if (packobj%particles%istatus(np) <= active) cycle
609 call packobj%particles%get(particle, this%id, iprp, np)
610 call this%trm_ids%add(particle%get_id(), 1)
611 end do
612 end select
613 end do
614 call particle%destroy()
615 deallocate (particle)
616
617 ! Update look-behind mass
618 do n = 1, this%dis%nodes
619 this%massstoold(n) = this%masssto(n)
620 end do
621
622 ! Set write and print flags
623 idvsave = 0
624 idvprint = 0
625 icbcfl = 0
626 ibudfl = 0
627 if (this%oc%oc_save('CONCENTRATION')) idvsave = 1
628 if (this%oc%oc_print('CONCENTRATION')) idvprint = 1
629 if (this%oc%oc_save('BUDGET')) icbcfl = 1
630 if (this%oc%oc_print('BUDGET')) ibudfl = 1
631 icbcun = this%oc%oc_save_unit('BUDGET')
632
633 ! Override ibudfl and idvprint flags for nonconvergence
634 ! and end of period
635 ibudfl = this%oc%set_print_flag('BUDGET', 1, endofperiod)
636 idvprint = this%oc%set_print_flag('CONCENTRATION', 1, endofperiod)
637
638 ! Save and print flows
639 call this%prt_ot_flow(icbcfl, ibudfl, icbcun)
640
641 ! Save and print dependent variables
642 call this%prt_ot_dv(idvsave, idvprint, ipflag)
643
644 ! Print budget summaries
645 call this%prt_ot_bdsummary(ibudfl, ipflag)
646
647 ! Timing Output; if any dependent variables or budgets
648 ! are printed, then ipflag is set to 1.
649 if (ipflag == 1) call tdis_ot(this%iout)
logical(lgp), pointer, public endofperiod
flag indicating end of stress period
Definition tdis.f90:30
subroutine, public tdis_ot(iout)
Print simulation time.
Definition tdis.f90:274
Here is the call graph for this function:

◆ prt_ot_bdsummary()

subroutine prtmodule::prt_ot_bdsummary ( class(prtmodeltype) this,
integer(i4b), intent(in) ibudfl,
integer(i4b), intent(inout) ipflag )
private

Definition at line 840 of file prt.f90.

841 ! modules
842 use tdismodule, only: kstp, kper, totim, delt
843 ! dummy
844 class(PrtModelType) :: this
845 integer(I4B), intent(in) :: ibudfl
846 integer(I4B), intent(inout) :: ipflag
847 ! local
848 class(BndType), pointer :: packobj
849 integer(I4B) :: ip
850
851 ! Package budget summary
852 do ip = 1, this%bndlist%Count()
853 packobj => getbndfromlist(this%bndlist, ip)
854 call packobj%bnd_ot_bdsummary(kstp, kper, this%iout, ibudfl)
855 end do
856
857 ! model budget summary
858 call this%budget%finalize_step(delt)
859 if (ibudfl /= 0) then
860 ipflag = 1
861 ! model budget summary
862 call this%budget%budget_ot(kstp, kper, this%iout)
863 end if
864
865 ! Write to budget csv
866 call this%budget%writecsv(totim)
real(dp), pointer, public totim
time relative to start of simulation
Definition tdis.f90:35
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
Here is the call graph for this function:

◆ prt_ot_dv()

subroutine prtmodule::prt_ot_dv ( class(prtmodeltype) this,
integer(i4b), intent(in) idvsave,
integer(i4b), intent(in) idvprint,
integer(i4b), intent(inout) ipflag )
private

Definition at line 819 of file prt.f90.

820 ! dummy
821 class(PrtModelType) :: this
822 integer(I4B), intent(in) :: idvsave
823 integer(I4B), intent(in) :: idvprint
824 integer(I4B), intent(inout) :: ipflag
825 ! local
826 class(BndType), pointer :: packobj
827 integer(I4B) :: ip
828
829 ! Print advanced package dependent variables
830 do ip = 1, this%bndlist%Count()
831 packobj => getbndfromlist(this%bndlist, ip)
832 call packobj%bnd_ot_dv(idvsave, idvprint)
833 end do
834
835 ! save head and print head
836 call this%oc%oc_ot(ipflag, 1)
Here is the call graph for this function:

◆ prt_ot_flow()

subroutine prtmodule::prt_ot_flow ( class(prtmodeltype) this,
integer(i4b), intent(in) icbcfl,
integer(i4b), intent(in) ibudfl,
integer(i4b), intent(in) icbcun )
private

Definition at line 653 of file prt.f90.

654 use prtprpmodule, only: prtprptype
655 class(PrtModelType) :: this
656 integer(I4B), intent(in) :: icbcfl
657 integer(I4B), intent(in) :: ibudfl
658 integer(I4B), intent(in) :: icbcun
659 class(BndType), pointer :: packobj
660 integer(I4B) :: ip
661
662 ! Save PRT flows
663 call this%prt_ot_saveflow(this%dis%nja, this%flowja, icbcfl, icbcun)
664 do ip = 1, this%bndlist%Count()
665 packobj => getbndfromlist(this%bndlist, ip)
666 call packobj%bnd_ot_model_flows(icbcfl=icbcfl, ibudfl=0, icbcun=icbcun)
667 end do
668
669 ! Save advanced package flows
670 do ip = 1, this%bndlist%Count()
671 packobj => getbndfromlist(this%bndlist, ip)
672 call packobj%bnd_ot_package_flows(icbcfl=icbcfl, ibudfl=0)
673 end do
674
675 ! Print PRT flows
676 call this%prt_ot_printflow(ibudfl, this%flowja)
677 do ip = 1, this%bndlist%Count()
678 packobj => getbndfromlist(this%bndlist, ip)
679 call packobj%bnd_ot_model_flows(icbcfl=icbcfl, ibudfl=ibudfl, icbcun=0)
680 end do
681
682 ! Print advanced package flows
683 do ip = 1, this%bndlist%Count()
684 packobj => getbndfromlist(this%bndlist, ip)
685 call packobj%bnd_ot_package_flows(icbcfl=0, ibudfl=ibudfl)
686 end do
Here is the call graph for this function:

◆ prt_ot_printflow()

subroutine prtmodule::prt_ot_printflow ( class(prtmodeltype) this,
integer(i4b), intent(in) ibudfl,
real(dp), dimension(:), intent(inout) flowja )
private

Definition at line 780 of file prt.f90.

781 ! modules
782 use tdismodule, only: kper, kstp
783 use constantsmodule, only: lenbigline
784 ! dummy
785 class(PrtModelType) :: this
786 integer(I4B), intent(in) :: ibudfl
787 real(DP), intent(inout), dimension(:) :: flowja
788 ! local
789 character(len=LENBIGLINE) :: line
790 character(len=30) :: tempstr
791 integer(I4B) :: n, ipos, m
792 real(DP) :: qnm
793 ! formats
794 character(len=*), parameter :: fmtiprflow = &
795 "(/,4x,'CALCULATED INTERCELL FLOW &
796 &FOR PERIOD ', i0, ' STEP ', i0)"
797
798 ! Write flowja to list file if requested
799 if (ibudfl /= 0 .and. this%iprflow > 0) then
800 write (this%iout, fmtiprflow) kper, kstp
801 do n = 1, this%dis%nodes
802 line = ''
803 call this%dis%noder_to_string(n, tempstr)
804 line = trim(tempstr)//':'
805 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
806 m = this%dis%con%ja(ipos)
807 call this%dis%noder_to_string(m, tempstr)
808 line = trim(line)//' '//trim(tempstr)
809 qnm = flowja(ipos)
810 write (tempstr, '(1pg15.6)') qnm
811 line = trim(line)//' '//trim(adjustl(tempstr))
812 end do
813 write (this%iout, '(a)') trim(line)
814 end do
815 end if
integer(i4b), parameter lenbigline
maximum length of a big line
Definition Constants.f90:15

◆ prt_ot_saveflow()

subroutine prtmodule::prt_ot_saveflow ( class(prtmodeltype) this,
integer(i4b), intent(in) nja,
real(dp), dimension(nja), intent(in) flowja,
integer(i4b), intent(in) icbcfl,
integer(i4b), intent(in) icbcun )
private

Definition at line 690 of file prt.f90.

691 ! dummy
692 class(PrtModelType) :: this
693 integer(I4B), intent(in) :: nja
694 real(DP), dimension(nja), intent(in) :: flowja
695 integer(I4B), intent(in) :: icbcfl
696 integer(I4B), intent(in) :: icbcun
697 ! local
698 integer(I4B) :: ibinun
699 integer(I4B) :: naux
700 real(DP), dimension(0) :: auxrow
701 character(len=LENAUXNAME), dimension(0) :: auxname
702 logical(LGP) :: header_written
703 integer(I4B) :: i, nn
704 real(DP) :: m
705 integer(I4B) :: nsto, ntrm
706 logical(LGP), allocatable :: msto_mask(:), mtrm_mask(:)
707 integer(I4B), allocatable :: msto_nns(:), mtrm_nns(:)
708 real(DP), allocatable :: msto_vals(:), mtrm_vals(:)
709
710 ! Set unit number for binary output
711 if (this%ipakcb < 0) then
712 ibinun = icbcun
713 elseif (this%ipakcb == 0) then
714 ibinun = 0
715 else
716 ibinun = this%ipakcb
717 end if
718 if (icbcfl == 0) ibinun = 0
719
720 ! Return if nothing to do
721 if (ibinun == 0) return
722
723 ! Write mass face flows
724 call this%dis%record_connection_array(flowja, ibinun, this%iout)
725
726 ! Write mass storage term
727 naux = 0
728 header_written = .false.
729 msto_mask = this%masssto > dzero
730 msto_vals = pack(this%masssto, msto_mask)
731 msto_nns = [(i, i=1, size(this%masssto))]
732 msto_nns = pack(msto_nns, msto_mask)
733 nsto = size(msto_nns)
734 do i = 1, nsto
735 nn = msto_nns(i)
736 m = msto_vals(i)
737 if (.not. header_written) then
738 call this%dis%record_srcdst_list_header(budtxt(1), &
739 'PRT ', &
740 'PRT ', &
741 'PRT ', &
742 'STORAGE ', &
743 naux, auxname, ibinun, &
744 nsto, this%iout)
745 header_written = .true.
746 end if
747 call this%dis%record_mf6_list_entry(ibinun, nn, nn, m, &
748 0, auxrow, &
749 olconv2=.false.)
750 end do
751
752 ! Write mass termination term
753 header_written = .false.
754 mtrm_mask = this%masstrm > dzero
755 mtrm_vals = pack(this%masstrm, mtrm_mask)
756 mtrm_nns = [(i, i=1, size(this%masstrm))]
757 mtrm_nns = pack(mtrm_nns, mtrm_mask)
758 ntrm = size(mtrm_nns)
759 do i = 1, ntrm
760 nn = mtrm_nns(i)
761 m = mtrm_vals(i)
762 if (.not. header_written) then
763 call this%dis%record_srcdst_list_header(budtxt(2), &
764 'PRT ', &
765 'PRT ', &
766 'PRT ', &
767 'TERMINATION ', &
768 naux, auxname, ibinun, &
769 ntrm, this%iout)
770 header_written = .true.
771 end if
772 call this%dis%record_mf6_list_entry(ibinun, nn, nn, m, &
773 0, auxrow, &
774 olconv2=.false.)
775 end do
776

◆ prt_rp()

subroutine prtmodule::prt_rp ( class(prtmodeltype) this)
private

Definition at line 356 of file prt.f90.

357 use tdismodule, only: readnewdata
358 ! dummy
359 class(PrtModelType) :: this
360 ! local
361 class(BndType), pointer :: packobj
362 integer(I4B) :: ip
363
364 ! Check with TDIS on whether or not it is time to RP
365 if (.not. readnewdata) return
366
367 ! Read and prepare
368 if (this%inoc > 0) call this%oc%oc_rp()
369 do ip = 1, this%bndlist%Count()
370 packobj => getbndfromlist(this%bndlist, ip)
371 call packobj%bnd_rp()
372 end do
logical(lgp), pointer, public readnewdata
flag indicating time to read new data
Definition tdis.f90:29
Here is the call graph for this function:

◆ prt_solve()

subroutine prtmodule::prt_solve ( class(prtmodeltype) this,
integer(i4b), intent(in) isuppress_output )
private

Definition at line 1064 of file prt.f90.

1066 use prtprpmodule, only: prtprptype
1069 use simvariablesmodule, only: warnmsg
1070 ! dummy
1071 class(PrtModelType) :: this
1072 integer(I4B), intent(in) :: isuppress_output
1073 ! local
1074 integer(I4B) :: np, ip
1075 class(BndType), pointer :: packobj
1076 type(ParticleType), pointer :: particle
1077 real(DP) :: tmax
1078 real(DP) :: tend
1079 integer(I4B) :: iprp
1080
1081 ! Skip tracking during Picard iterations: PRT doesn't affect the flow
1082 ! solution, so tracking is only needed once on the final output rerun
1083 ! (or on the single call when mxiter=1, which also has isuppress_output=0).
1084 if (isuppress_output /= 0) return
1085
1086 ! A single particle is reused in the tracking loops
1087 ! to avoid allocating and deallocating it each time.
1088 ! get() and put() retrieve and store particle state.
1089 call create_particle(particle)
1090 ! End of the time step, or, in the final time step, of the simulation.
1091 tend = totimc + delt
1092 if (endofsimulation) tend = this%sim_end(tend)
1093 ! Loop over PRP packages and particles within them.
1094 iprp = 0
1095 do ip = 1, this%bndlist%Count()
1096 packobj => getbndfromlist(this%bndlist, ip)
1097 select type (packobj)
1098 type is (prtprptype)
1099 iprp = iprp + 1
1100 if (endofsimulation .and. .not. packobj%extend) &
1101 call this%warn_late_tracktimes(packobj, tend)
1102 do np = 1, packobj%nparticles
1103 ! Get the particle from the staging store
1104 call packobj%particles_staging%get(particle, this%id, iprp, np)
1105 ! If particle is permanently unreleased, cycle.
1106 ! Raise a termination event if we haven't yet.
1107 ! TODO: when we have generic dynamic vectors,
1108 ! consider terminating permanently unreleased
1109 ! in PRP instead of here. For now, status -8
1110 ! indicates the permanently unreleased event
1111 ! is not yet recorded, status 8 it has been.
1112 if (particle%istatus == (-1 * term_unreleased)) then
1113 call this%method%terminate(particle, status=term_unreleased)
1114 call packobj%particles_staging%put(particle, np)
1115 end if
1116 if (particle%istatus > active) cycle ! Skip terminated particles
1117 if (particle%istatus == 0) then
1118 if (particle%trelease >= totimc) then
1119 if (particle%trelease > particle%tstop) then
1120 ! The package's stop time is earlier than the release time.
1121 ! Terminate it permanently unreleased and show a warning.
1122 write (warnmsg, '(a,g0,a,g0,a,g0,a)') &
1123 'Particle release point ', particle%irpt, ' has &
1124 &release time ', particle%trelease, ' after package &
1125 &stop time ', particle%tstop, '; particle will not &
1126 &be released.'
1127 call store_warning(warnmsg)
1128 call this%method%terminate(particle, status=term_unreleased)
1129 else
1130 ! The particle was released this time step; emit a
1131 ! release event.
1132 call this%method%release(particle)
1133 ! A stop time from STOPTRAVELTIME is a computed sum;
1134 ! substitute a tracking time just after it, but not past
1135 ! STOPTIME. Once, at release, so it can't creep further.
1136 if (packobj%stoptraveltime /= huge(1d0) .and. &
1137 particle%tstop /= packobj%stoptime) &
1138 particle%tstop = min(packobj%stoptime, &
1139 specified_end(particle%tstop, &
1140 this%oc%tracktimes%times))
1141 end if
1142 end if
1143 end if
1144 if (particle%istatus <= active) then
1145 ! Maximum time is the end of the time step or the particle
1146 ! stop time, whichever comes first, unless it's the final
1147 ! time step and the extend option is on, in which case
1148 ! it's just the particle stop time.
1149 if (endofsimulation .and. particle%extend) then
1150 tmax = particle%tstop
1151 else
1152 tmax = min(tend, particle%tstop)
1153 end if
1154 ! tmax should never be less than the particle's current
1155 ! tracked time: ttrack can't get ahead of totimc, the
1156 ! smaller of the two terms tmax is drawn from, and a
1157 ! release whose time precedes the stop time was already
1158 ! caught above and never reaches this point. If it
1159 ! happens anyway, that's a programmer error: tracking
1160 ! methods assume a nonnegative time interval, and calling
1161 ! apply() with tmax < ttrack sends them a negative one,
1162 ! which corrupts the tracking method.
1163 if (tmax < particle%ttrack) &
1164 call pstop(1, 'Programmer error: PRT tracking tmax &
1165 &precedes particle%ttrack.')
1166 ! Apply the tracking method until the maximum time.
1167 call this%method%apply(particle, tmax)
1168 ! If the particle timed out, terminate it.
1169 ! "Timed out" means it's still active but
1170 ! - it reached its stop time, or
1171 ! - the simulation is over.
1172 ! We can't detect timeout within the tracking
1173 ! method because the method just receives the
1174 ! maximum time with no context on what it is.
1175 ! TODO maybe think about changing that?
1176 if (particle%istatus <= active .and. &
1177 (particle%ttrack == particle%tstop .or. endofsimulation)) &
1178 call this%method%terminate(particle, status=term_timeout)
1179 end if
1180 ! Return the particle to the staging store
1181 call packobj%particles_staging%put(particle, np)
1182 end do
1183 end select
1184 end do
1185 call particle%destroy()
1186 deallocate (particle)
@ release
particle was released
@ terminate
particle terminated
@ term_timeout
terminated at stop time or end of simulation
Definition Particle.f90:39
@ term_unreleased
terminated permanently unreleased
Definition Particle.f90:37
subroutine create_particle(particle)
Create a new particle.
Definition Particle.f90:178
logical(lgp), pointer, public endofsimulation
flag indicating end of simulation
Definition tdis.f90:31
real(dp), pointer, public totimc
simulation time at start of time step
Definition tdis.f90:36
Here is the call graph for this function:

◆ sim_end()

real(dp) function prtmodule::sim_end ( class(prtmodeltype) this,
real(dp), intent(in) tsim )
private
Parameters
[in]tsimcomputed end of the simulation

Definition at line 1193 of file prt.f90.

1194 ! dummy
1195 class(PrtModelType) :: this
1196 real(DP), intent(in) :: tsim !< computed end of the simulation
1197 real(DP) :: t
1198 ! local
1199 integer(I4B) :: ip
1200 class(BndType), pointer :: packobj
1201
1202 t = specified_end(tsim, this%oc%tracktimes%times)
1203 do ip = 1, this%bndlist%Count()
1204 packobj => getbndfromlist(this%bndlist, ip)
1205 select type (packobj)
1206 type is (prtprptype)
1207 t = max(t, specified_end(tsim, packobj%schedule%times))
1208 end select
1209 end do
Here is the call graph for this function:

◆ specified_end()

pure real(dp) function prtmodule::specified_end ( real(dp), intent(in) tend,
real(dp), dimension(:), intent(in) times )
private

A computed end is a floating point sum, which can fall just short of the time a user specifies for it.

Parameters
[in]tendcomputed end of tracking
[in]timesspecified times

Definition at line 1218 of file prt.f90.

1219 real(DP), intent(in) :: tend !< computed end of tracking
1220 real(DP), intent(in) :: times(:) !< specified times
1221 real(DP) :: t
1222 ! local
1223 integer(I4B) :: i
1224
1225 t = tend
1226 do i = 1, size(times)
1227 if (times(i) > t .and. is_close(times(i), tend)) t = times(i)
1228 end do
Here is the call graph for this function:
Here is the caller graph for this function:

◆ warn_late_tracktimes()

subroutine prtmodule::warn_late_tracktimes ( class(prtmodeltype) this,
class(prtprptype), intent(in) prp,
real(dp), intent(in) tend )
private

Without EXTEND_TRACKING, tracking stops at the end of the simulation, so the package's particles never reach tracking times after it.

Parameters
[in]tendend of the simulation

Definition at line 1236 of file prt.f90.

1237 use prtprpmodule, only: prtprptype
1238 use simvariablesmodule, only: warnmsg
1239 ! dummy
1240 class(PrtModelType) :: this
1241 class(PrtPrpType), intent(in) :: prp
1242 real(DP), intent(in) :: tend !< end of the simulation
1243 ! local
1244 integer(I4B) :: i, n
1245
1246 if (.not. allocated(this%oc%tracktimes%times)) return
1247 n = 0
1248 do i = 1, size(this%oc%tracktimes%times)
1249 if (this%oc%tracktimes%times(i) > tend) n = n + 1
1250 end do
1251 if (n == 0) return
1252 write (warnmsg, '(a,i0,a,g0,a)') &
1253 'PRT model '//trim(this%name)//' package '//trim(prp%packName)// &
1254 ': ', n, ' tracking time(s) &
1255 &after the end of the simulation (t=', tend, ') will not be &
1256 &reported. Enable EXTEND_TRACKING to track particles past the &
1257 &simulation end time.'
1258 call store_warning(warnmsg, substring=trim(warnmsg))
Here is the call graph for this function:

Variable Documentation

◆ budtxt

character(len=lenbudtxt), dimension(nbditems) prtmodule::budtxt
private

Definition at line 45 of file prt.f90.

45 character(len=LENBUDTXT), dimension(NBDITEMS) :: budtxt

◆ nbditems

integer(i4b), parameter prtmodule::nbditems = 2
private

Definition at line 44 of file prt.f90.

◆ niunit_prt

integer(i4b), parameter prtmodule::niunit_prt = PRT_NBASEPKG + PRT_NMULTIPKG
private

Definition at line 131 of file prt.f90.

◆ prt_basepkg

character(len=lenpackagetype), dimension(prt_nbasepkg), public prtmodule::prt_basepkg

Definition at line 112 of file prt.f90.

112 character(len=LENPACKAGETYPE), dimension(PRT_NBASEPKG) :: PRT_BASEPKG

◆ prt_multipkg

character(len=lenpackagetype), dimension(prt_nmultipkg), public prtmodule::prt_multipkg

Definition at line 126 of file prt.f90.

126 character(len=LENPACKAGETYPE), dimension(PRT_NMULTIPKG) :: PRT_MULTIPKG

◆ prt_nbasepkg

integer(i4b), parameter, public prtmodule::prt_nbasepkg = 50

PRT6 model base package types. Only listed packages are candidates for input and these will be loaded in the order specified.

Definition at line 111 of file prt.f90.

◆ prt_nmultipkg

integer(i4b), parameter, public prtmodule::prt_nmultipkg = 50

PRT6 model multi-instance package types. Only listed packages are candidates for input and these will be loaded in the order specified.

Definition at line 125 of file prt.f90.