Skip to content

Commit 5faa2c6

Browse files
authored
refactor(prt): use logical arrays (#2476)
Use logical arrays in PRT as enabled by #2473. This involved a few DFN tweaks to work with IDM. Also some cleanup.
1 parent ab383e7 commit 5faa2c6

File tree

7 files changed

+81
-75
lines changed

7 files changed

+81
-75
lines changed

doc/mf6io/mf6ivar/dfn/prt-prp.dfn

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ reader urword
4545
optional true
4646
longname whether to use local z coordinates
4747
description indicates that ``zrpt'' defines the local z coordinate of the release point within the cell, with value of 0 at the bottom and 1 at the top of the cell. If the cell is partially saturated at release time, the top of the cell is considered to be the water table elevation (the head in the cell) rather than the top defined by the user.
48+
mf6internal localz
4849

4950
block options
5051
name extend_tracking
@@ -53,6 +54,7 @@ reader urword
5354
optional true
5455
longname whether to extend tracking beyond the end of the simulation
5556
description indicates that particles should be tracked beyond the end of the simulation's final time step (using that time step's flows) until particles terminate or reach a specified stop time. By default, particles are terminated at the end of the simulation's final time step.
57+
mf6internal extend
5658

5759
block options
5860
name track_filerecord
@@ -262,7 +264,7 @@ reader urword
262264
optional false
263265
longname force ternary tracking method
264266
description force use of the ternary tracking method regardless of cell type in DISV grids.
265-
mf6internal ifrctrn
267+
mf6internal frctrn
266268

267269
block options
268270
name release_time_tolerance

src/Idm/prt-prpidm.f90

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ module PrtPrpInputModule
1616
logical :: iprpak = .false.
1717
logical :: iexmeth = .false.
1818
logical :: extol = .false.
19-
logical :: local_z = .false.
20-
logical :: extend_tracking = .false.
19+
logical :: localz = .false.
20+
logical :: extend = .false.
2121
logical :: track_filerecord = .false.
2222
logical :: track = .false.
2323
logical :: fileout = .false.
@@ -37,7 +37,7 @@ module PrtPrpInputModule
3737
logical :: release_timesfn = .false.
3838
logical :: timesfile = .false.
3939
logical :: idrymeth = .false.
40-
logical :: ifrctrn = .false.
40+
logical :: frctrn = .false.
4141
logical :: rttol = .false.
4242
logical :: rtfreq = .false.
4343
logical :: ichkmeth = .false.
@@ -141,13 +141,13 @@ module PrtPrpInputModule
141141
)
142142

143143
type(InputParamDefinitionType), parameter :: &
144-
prtprp_local_z = InputParamDefinitionType &
144+
prtprp_localz = InputParamDefinitionType &
145145
( &
146146
'PRT', & ! component
147147
'PRP', & ! subcomponent
148148
'OPTIONS', & ! block
149149
'LOCAL_Z', & ! tag name
150-
'LOCAL_Z', & ! fortran variable
150+
'LOCALZ', & ! fortran variable
151151
'KEYWORD', & ! type
152152
'', & ! shape
153153
'whether to use local z coordinates', & ! longname
@@ -159,13 +159,13 @@ module PrtPrpInputModule
159159
)
160160

161161
type(InputParamDefinitionType), parameter :: &
162-
prtprp_extend_tracking = InputParamDefinitionType &
162+
prtprp_extend = InputParamDefinitionType &
163163
( &
164164
'PRT', & ! component
165165
'PRP', & ! subcomponent
166166
'OPTIONS', & ! block
167167
'EXTEND_TRACKING', & ! tag name
168-
'EXTEND_TRACKING', & ! fortran variable
168+
'EXTEND', & ! fortran variable
169169
'KEYWORD', & ! type
170170
'', & ! shape
171171
'whether to extend tracking beyond the end of the simulation', & ! longname
@@ -519,13 +519,13 @@ module PrtPrpInputModule
519519
)
520520

521521
type(InputParamDefinitionType), parameter :: &
522-
prtprp_ifrctrn = InputParamDefinitionType &
522+
prtprp_frctrn = InputParamDefinitionType &
523523
( &
524524
'PRT', & ! component
525525
'PRP', & ! subcomponent
526526
'OPTIONS', & ! block
527527
'DEV_FORCETERNARY', & ! tag name
528-
'IFRCTRN', & ! fortran variable
528+
'FRCTRN', & ! fortran variable
529529
'KEYWORD', & ! type
530530
'', & ! shape
531531
'force ternary tracking method', & ! longname
@@ -903,8 +903,8 @@ module PrtPrpInputModule
903903
prtprp_iprpak, &
904904
prtprp_iexmeth, &
905905
prtprp_extol, &
906-
prtprp_local_z, &
907-
prtprp_extend_tracking, &
906+
prtprp_localz, &
907+
prtprp_extend, &
908908
prtprp_track_filerecord, &
909909
prtprp_track, &
910910
prtprp_fileout, &
@@ -924,7 +924,7 @@ module PrtPrpInputModule
924924
prtprp_release_timesfn, &
925925
prtprp_timesfile, &
926926
prtprp_idrymeth, &
927-
prtprp_ifrctrn, &
927+
prtprp_frctrn, &
928928
prtprp_rttol, &
929929
prtprp_rtfreq, &
930930
prtprp_ichkmeth, &

src/Model/ParticleTracking/prt-prp.f90

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,18 @@ module PrtPrpModule
3636

3737
!> @brief Particle release point (PRP) package
3838
type, extends(BndExtType) :: PrtPrpType
39-
type(PrtFmiType), pointer :: fmi => null() !< flow model interface
40-
type(ParticleStoreType), pointer :: particles => null() !< particle store
41-
type(ParticleReleaseScheduleType), pointer :: schedule !< particle release schedule
42-
integer(I4B), pointer :: nreleasepoints => null() !< number of release points
43-
integer(I4B), pointer :: nreleasetimes => null() !< number of user-specified particle release times
44-
integer(I4B), pointer :: nparticles => null() !< number of particles released
39+
! options
40+
logical(LGP), pointer :: extend => null() !< extend tracking beyond simulation's end
41+
logical(LGP), pointer :: frctrn => null() !< force ternary solution for quad grids
42+
logical(LGP), pointer :: drape => null() !< whether to drape particle to topmost active cell
43+
logical(LGP), pointer :: localz => null() !< compute z coordinates local to the release cell
4544
integer(I4B), pointer :: istopweaksink => null() !< weak sink option: 0 = no stop, 1 = stop
4645
integer(I4B), pointer :: istopzone => null() !< optional stop zone number: 0 = no stop zone
47-
integer(I4B), pointer :: idrape => null() !< drape option: 0 = do not drape, 1 = drape to topmost active cell
4846
integer(I4B), pointer :: idrymeth => null() !< dry tracking method: 0 = drop, 1 = stop, 2 = stay
4947
integer(I4B), pointer :: itrkout => null() !< binary track file
5048
integer(I4B), pointer :: itrkhdr => null() !< track header file
5149
integer(I4B), pointer :: itrkcsv => null() !< CSV track file
5250
integer(I4B), pointer :: irlstls => null() !< release time file
53-
integer(I4B), pointer :: ilocalz => null() !< compute z coordinates local to the cell
54-
integer(I4B), pointer :: iextend => null() !< extend tracking beyond simulation's end
55-
integer(I4B), pointer :: ifrctrn => null() !< force ternary solution for quad grids
5651
integer(I4B), pointer :: iexmeth => null() !< method for iterative solution of particle exit location and time in generalized Pollock's method
5752
integer(I4B), pointer :: ichkmeth => null() !< method for checking particle release coordinates are in the specified cells, 0 = none, 1 = eager
5853
integer(I4B), pointer :: icycwin => null() !< cycle detection window size
@@ -62,6 +57,13 @@ module PrtPrpModule
6257
real(DP), pointer :: offset => null() !< release time offset
6358
real(DP), pointer :: stoptime => null() !< stop time for all release points
6459
real(DP), pointer :: stoptraveltime => null() !< stop travel time for all points
60+
!
61+
type(PrtFmiType), pointer :: fmi => null() !< flow model interface
62+
type(ParticleStoreType), pointer :: particles => null() !< particle store
63+
type(ParticleReleaseScheduleType), pointer :: schedule => null() !< particle release schedule
64+
integer(I4B), pointer :: nreleasepoints => null() !< number of release points
65+
integer(I4B), pointer :: nreleasetimes => null() !< number of user-specified particle release times
66+
integer(I4B), pointer :: nparticles => null() !< number of particles released
6567
integer(I4B), pointer, contiguous :: rptnode(:) => null() !< release point reduced nns
6668
integer(I4B), pointer, contiguous :: rptzone(:) => null() !< release point zone numbers
6769
real(DP), pointer, contiguous :: rptx(:) => null() !< release point x coordinates
@@ -151,14 +153,14 @@ subroutine prp_da(this)
151153
call this%BndExtType%bnd_da()
152154

153155
! Deallocate scalars
154-
call mem_deallocate(this%ilocalz)
155-
call mem_deallocate(this%iextend)
156+
call mem_deallocate(this%localz)
157+
call mem_deallocate(this%extend)
156158
call mem_deallocate(this%offset)
157159
call mem_deallocate(this%stoptime)
158160
call mem_deallocate(this%stoptraveltime)
159161
call mem_deallocate(this%istopweaksink)
160162
call mem_deallocate(this%istopzone)
161-
call mem_deallocate(this%idrape)
163+
call mem_deallocate(this%drape)
162164
call mem_deallocate(this%idrymeth)
163165
call mem_deallocate(this%nreleasepoints)
164166
call mem_deallocate(this%nreleasetimes)
@@ -167,7 +169,7 @@ subroutine prp_da(this)
167169
call mem_deallocate(this%itrkhdr)
168170
call mem_deallocate(this%itrkcsv)
169171
call mem_deallocate(this%irlstls)
170-
call mem_deallocate(this%ifrctrn)
172+
call mem_deallocate(this%frctrn)
171173
call mem_deallocate(this%iexmeth)
172174
call mem_deallocate(this%ichkmeth)
173175
call mem_deallocate(this%icycwin)
@@ -243,14 +245,14 @@ subroutine prp_allocate_scalars(this)
243245
call this%BndExtType%allocate_scalars()
244246

245247
! Allocate scalars for this type
246-
call mem_allocate(this%ilocalz, 'ILOCALZ', this%memoryPath)
247-
call mem_allocate(this%iextend, 'IEXTEND', this%memoryPath)
248+
call mem_allocate(this%localz, 'LOCALZ', this%memoryPath)
249+
call mem_allocate(this%extend, 'EXTEND', this%memoryPath)
248250
call mem_allocate(this%offset, 'OFFSET', this%memoryPath)
249251
call mem_allocate(this%stoptime, 'STOPTIME', this%memoryPath)
250252
call mem_allocate(this%stoptraveltime, 'STOPTRAVELTIME', this%memoryPath)
251253
call mem_allocate(this%istopweaksink, 'ISTOPWEAKSINK', this%memoryPath)
252254
call mem_allocate(this%istopzone, 'ISTOPZONE', this%memoryPath)
253-
call mem_allocate(this%idrape, 'IDRAPE', this%memoryPath)
255+
call mem_allocate(this%drape, 'DRAPE', this%memoryPath)
254256
call mem_allocate(this%idrymeth, 'IDRYMETH', this%memoryPath)
255257
call mem_allocate(this%nreleasepoints, 'NRELEASEPOINTS', this%memoryPath)
256258
call mem_allocate(this%nreleasetimes, 'NRELEASETIMES', this%memoryPath)
@@ -259,7 +261,7 @@ subroutine prp_allocate_scalars(this)
259261
call mem_allocate(this%itrkhdr, 'ITRKHDR', this%memoryPath)
260262
call mem_allocate(this%itrkcsv, 'ITRKCSV', this%memoryPath)
261263
call mem_allocate(this%irlstls, 'IRLSTLS', this%memoryPath)
262-
call mem_allocate(this%ifrctrn, 'IFRCTRN', this%memoryPath)
264+
call mem_allocate(this%frctrn, 'FRCTRN', this%memoryPath)
263265
call mem_allocate(this%iexmeth, 'IEXMETH', this%memoryPath)
264266
call mem_allocate(this%ichkmeth, 'ICHKMETH', this%memoryPath)
265267
call mem_allocate(this%icycwin, 'ICYCWIN', this%memoryPath)
@@ -268,14 +270,14 @@ subroutine prp_allocate_scalars(this)
268270
call mem_allocate(this%rtfreq, 'RTFREQ', this%memoryPath)
269271

270272
! Set values
271-
this%ilocalz = 0
272-
this%iextend = 0
273+
this%localz = .false.
274+
this%extend = .false.
273275
this%offset = DZERO
274276
this%stoptime = huge(1d0)
275277
this%stoptraveltime = huge(1d0)
276278
this%istopweaksink = 0
277279
this%istopzone = 0
278-
this%idrape = 0
280+
this%drape = .false.
279281
this%idrymeth = 0
280282
this%nreleasepoints = 0
281283
this%nreleasetimes = 0
@@ -284,7 +286,7 @@ subroutine prp_allocate_scalars(this)
284286
this%itrkhdr = 0
285287
this%itrkcsv = 0
286288
this%irlstls = 0
287-
this%ifrctrn = 0
289+
this%frctrn = .false.
288290
this%iexmeth = 0
289291
this%ichkmeth = 1
290292
this%icycwin = 0
@@ -361,7 +363,7 @@ subroutine prp_ad(this)
361363
'Skipping negative release time (t=', t, ').'
362364
call store_warning(warnmsg)
363365
cycle
364-
else if (t > totalsimtime .and. this%iextend == 0) then
366+
else if (t > totalsimtime .and. .not. this%extend) then
365367
write (warnmsg, '(a,g0,a)') &
366368
'Skipping release time falling after the end of the &
367369
&simulation (t=', t, '). Enable EXTEND_TRACKING to &
@@ -494,7 +496,7 @@ subroutine initialize_particle(this, particle, ip, trelease)
494496
! enabled, or else terminate permanently unreleased.
495497
if (this%ibound(ic) == 0) then
496498
ic_old = ic
497-
if (this%idrape > 0) then
499+
if (this%drape) then
498500
call this%dis%highest_active(ic, this%ibound)
499501
if (ic == ic_old .or. this%ibound(ic) == 0) then
500502
! negative unreleased status signals to the
@@ -510,7 +512,7 @@ subroutine initialize_particle(this, particle, ip, trelease)
510512
! Load coordinates and transform if needed
511513
x = this%rptx(ip)
512514
y = this%rpty(ip)
513-
if (this%ilocalz > 0) then
515+
if (this%localz) then
514516
top = this%fmi%dis%top(ic)
515517
bot = this%fmi%dis%bot(ic)
516518
hds = this%fmi%gwfhead(ic)
@@ -542,9 +544,9 @@ subroutine initialize_particle(this, particle, ip, trelease)
542544
particle%iboundary(LEVEL_FEATURE) = 0
543545
particle%itrdomain(LEVEL_SUBFEATURE) = 0
544546
particle%iboundary(LEVEL_SUBFEATURE) = 0
545-
particle%ifrctrn = this%ifrctrn
547+
particle%frctrn = this%frctrn
546548
particle%iexmeth = this%iexmeth
547-
particle%iextend = this%iextend
549+
particle%extend = this%extend
548550
particle%icycwin = this%icycwin
549551
particle%extol = this%extol
550552
end subroutine initialize_particle
@@ -694,26 +696,26 @@ subroutine prp_options(this)
694696
found%istopweaksink)
695697
call mem_set_value(this%istopzone, 'ISTOPZONE', this%input_mempath, &
696698
found%istopzone)
697-
call mem_set_value(this%idrape, 'DRAPE', this%input_mempath, &
699+
call mem_set_value(this%drape, 'DRAPE', this%input_mempath, &
698700
found%drape)
699701
call mem_set_value(this%idrymeth, 'IDRYMETH', this%input_mempath, &
700702
drytrack_method, found%idrymeth)
701703
call mem_set_value(trackfile, 'TRACKFILE', this%input_mempath, &
702704
found%trackfile)
703705
call mem_set_value(trackcsvfile, 'TRACKCSVFILE', this%input_mempath, &
704706
found%trackcsvfile)
705-
call mem_set_value(this%ilocalz, 'LOCAL_Z', this%input_mempath, &
706-
found%local_z)
707-
call mem_set_value(this%iextend, 'EXTEND_TRACKING', this%input_mempath, &
708-
found%extend_tracking)
707+
call mem_set_value(this%localz, 'LOCALZ', this%input_mempath, &
708+
found%localz)
709+
call mem_set_value(this%extend, 'EXTEND', this%input_mempath, &
710+
found%extend)
709711
call mem_set_value(this%extol, 'EXTOL', this%input_mempath, &
710712
found%extol)
711713
call mem_set_value(this%rttol, 'RTTOL', this%input_mempath, &
712714
found%rttol)
713715
call mem_set_value(this%rtfreq, 'RTFREQ', this%input_mempath, &
714716
found%rtfreq)
715-
call mem_set_value(this%ifrctrn, 'IFRCTRN', this%input_mempath, &
716-
found%ifrctrn)
717+
call mem_set_value(this%frctrn, 'FRCTRN', this%input_mempath, &
718+
found%frctrn)
717719
call mem_set_value(this%iexmeth, 'IEXMETH', this%input_mempath, &
718720
found%iexmeth)
719721
call mem_set_value(this%ichkmeth, 'ICHKMETH', this%input_mempath, &
@@ -823,7 +825,7 @@ subroutine prp_log_options(this, found, trackfile, trackcsvfile)
823825

824826
write (this%iout, '(1x,a)') 'PROCESSING PARTICLE INPUT DIMENSIONS'
825827

826-
if (found%ifrctrn) then
828+
if (found%frctrn) then
827829
write (this%iout, '(4x,a)') &
828830
'IF DISV, TRACKING WILL USE THE TERNARY METHOD REGARDLESS OF CELL TYPE'
829831
end if
@@ -948,7 +950,7 @@ subroutine prp_packagedata(this)
948950
this%rptnode(rptno) = noder
949951
end if
950952

951-
if (this%ilocalz > 0 .and. (zrpts(n) < 0 .or. zrpts(n) > 1)) then
953+
if (this%localz .and. (zrpts(n) < 0 .or. zrpts(n) > 1)) then
952954
call store_error('Local z coordinate must fall in the interval [0, 1]')
953955
cycle
954956
end if

src/Model/ParticleTracking/prt.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ subroutine prt_solve(this)
961961
! stop time, whichever comes first, unless it's the final
962962
! time step and the extend option is on, in which case
963963
! it's just the particle stop time.
964-
if (endofsimulation .and. particle%iextend > 0) then
964+
if (endofsimulation .and. particle%extend) then
965965
tmax = particle%tstop
966966
else
967967
tmax = min(totimc + delt, particle%tstop)
@@ -982,7 +982,7 @@ subroutine prt_solve(this)
982982
! TODO maybe think about changing that?
983983
if (particle%istatus <= ACTIVE .and. &
984984
(particle%ttrack == particle%tstop .or. &
985-
(endofsimulation .and. particle%iextend == 0))) &
985+
(endofsimulation .and. .not. particle%extend))) &
986986
call this%method%terminate(particle, status=TERM_TIMEOUT)
987987
! Return the particle to the store
988988
call packobj%particles%put(particle, np)

src/Solution/ParticleTracker/Method/MethodDisv.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ subroutine load_disv(this, particle, next_level, submethod)
9494
events=this%events, &
9595
tracktimes=this%tracktimes)
9696
submethod => method_cell_ptb
97-
else if (particle%ifrctrn > 0) then
97+
else if (particle%frctrn) then
9898
! Force the ternary method
9999
call method_cell_tern%init( &
100100
fmi=this%fmi, &

src/Solution/ParticleTracker/Method/MethodSubcellPollock.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ subroutine track_subcell(this, subcell, particle, tmax)
150150
! ideally that would be handled at a higher scope but with extended tracking
151151
! tmax is not the end of the simulation, it's just a wildly high upper bound.
152152
if ((statusVX .eq. 2) .and. (statusVY .eq. 2) .and. (statusVZ .eq. 2) .and. &
153-
particle%iextend > 0 .and. endofsimulation) then
153+
particle%extend .and. endofsimulation) then
154154
call this%terminate(particle, status=TERM_TIMEOUT)
155155
return
156156
end if

0 commit comments

Comments
 (0)