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.
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 950 of file prt.f90.

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

◆ allocate_scalars()

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

Definition at line 921 of file prt.f90.

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

◆ 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 1163 of file prt.f90.

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
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 1316 of file prt.f90.

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)
Here is the call graph for this function:

◆ create_packages()

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

Definition at line 1215 of file prt.f90.

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()
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 1023 of file prt.f90.

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
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 1336 of file prt.f90.

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:'

◆ 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 979 of file prt.f90.

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)
Here is the call graph for this function:

◆ prt_ad()

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

Definition at line 373 of file prt.f90.

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
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 246 of file prt.f90.

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.'
317 call store_warning(warnmsg)
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
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:39
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 546 of file prt.f90.

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
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 420 of file prt.f90.

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)
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 466 of file prt.f90.

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
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 133 of file prt.f90.

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
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 856 of file prt.f90.

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()
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 213 of file prt.f90.

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
Here is the call graph for this function:

◆ prt_ot()

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

Definition at line 581 of file prt.f90.

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)
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:271
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 826 of file prt.f90.

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)
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 805 of file prt.f90.

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)
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 639 of file prt.f90.

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
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 766 of file prt.f90.

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
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 676 of file prt.f90.

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

◆ prt_rp()

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

Definition at line 353 of file prt.f90.

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
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 1050 of file prt.f90.

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.'
1108 call store_warning(warnmsg)
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)
@ 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
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:

Variable Documentation

◆ budtxt

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

Definition at line 44 of file prt.f90.

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

◆ nbditems

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

Definition at line 43 of file prt.f90.

◆ niunit_prt

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

Definition at line 128 of file prt.f90.

◆ prt_basepkg

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

Definition at line 109 of file prt.f90.

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

◆ prt_multipkg

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

Definition at line 123 of file prt.f90.

123 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 108 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 122 of file prt.f90.