@@ -605,6 +605,7 @@ subroutine initialize_particle(this, particle, ip, trelease)
605605 integer (I4B), intent (in ) :: ip ! < particle index
606606 real (DP), intent (in ) :: trelease ! < release time
607607 ! local
608+ logical (LGP) :: draped
608609 integer (I4B) :: irow, icol, ilay, icpl
609610 integer (I4B) :: ic, icu, ic_old
610611 real (DP) :: x, y, z
@@ -617,7 +618,6 @@ subroutine initialize_particle(this, particle, ip, trelease)
617618 &Make sure a GWFGRID entry is configured in the PRT FMI package.')"
618619
619620 ic = this% rptnode(ip)
620- icu = this% dis% get_nodeuser(ic)
621621
622622 call create_particle(particle)
623623
@@ -631,25 +631,19 @@ subroutine initialize_particle(this, particle, ip, trelease)
631631 particle% istopweaksink = this% istopweaksink
632632 particle% istopzone = this% istopzone
633633 particle% idrymeth = this% idrymeth
634- particle% icu = icu
635-
636- select type (dis = > this% dis)
637- type is (DisType)
638- call get_ijk(icu, dis% nrow, dis% ncol, dis% nlay, irow, icol, ilay)
639- type is (DisvType)
640- call get_jk(icu, dis% ncpl, dis% nlay, icpl, ilay)
641- end select
642- particle% ilay = ilay
643- particle% izone = this% rptzone(ic)
644634 particle% istatus = 0 ! status 0 until tracking starts
635+
645636 ! If the cell is inactive, either drape the particle
646637 ! to the top-most active cell beneath it if drape is
647638 ! enabled, or else terminate permanently unreleased.
639+ draped = .false.
648640 if (this% ibound(ic) == 0 ) then
649641 ic_old = ic
650642 if (this% drape) then
651643 call this% dis% highest_active(ic, this% ibound)
652- if (ic == ic_old .or. this% ibound(ic) == 0 ) then
644+ if (ic /= ic_old) then
645+ draped = .true.
646+ else if (this% ibound(ic) == 0 ) then
653647 ! negative unreleased status signals to the
654648 ! tracking method that we haven't yet saved
655649 ! a termination record, it needs to do so.
@@ -660,36 +654,37 @@ subroutine initialize_particle(this, particle, ip, trelease)
660654 end if
661655 end if
662656
663- ! load coordinates
664- x = this% rptx(ip)
665- y = this% rpty(ip)
666- if (this% localz) then
667- ! make sure FMI has cell type array. we need
668- ! it to distinguish convertible and confined
669- ! cells if release z coordinates are local
670- if (this% fmi% igwfceltyp /= 1 ) then
671- write (errmsg, fmticterr) trim (this% text)
672- call store_error(errmsg, terminate= .TRUE. )
673- end if
657+ icu = this% dis% get_nodeuser(ic)
658+ particle% icu = icu
659+ select type (dis = > this% dis)
660+ type is (DisType)
661+ call get_ijk(icu, dis% nrow, dis% ncol, dis% nlay, irow, icol, ilay)
662+ type is (DisvType)
663+ call get_jk(icu, dis% ncpl, dis% nlay, icpl, ilay)
664+ end select
665+ particle% ilay = ilay
666+ particle% izone = this% rptzone(ic)
674667
675- ! calculate model z coord from local z coord.
676- ! if cell is confined (icelltype == 0) use the
677- ! actual cell height (geometric top - bottom).
678- ! otherwise use head as cell top, clamping to
679- ! the cell bottom if head is below the bottom
680- ! and to geometric cell top if head is above top
681- top = this% fmi% dis% top(ic)
682- bot = this% fmi% dis% bot(ic)
683- if (this% fmi% gwfceltyp(icu) /= 0 ) then
684- hds = this% fmi% gwfhead(ic)
685- top = min (top, hds)
686- top = max (top, bot)
687- end if
688- z = bot + this% rptz(ip) * (top - bot)
668+ ! if the particle was draped, override the release z coord and
669+ ! set it to the saturated top of the cell. this puts a draped
670+ ! a draped particle at the water table for a convertible cell
671+ ! or at the geometric cell top for a confined cell.
672+ if (draped) then
673+ z = this% fmi% dis% bot(ic) + &
674+ this% fmi% gwfsat(ic) * &
675+ (this% fmi% dis% top(ic) - this% fmi% dis% bot(ic))
676+ else if (this% localz) then
677+ z = this% fmi% dis% bot(ic) + &
678+ this% rptz(ip) * &
679+ this% fmi% gwfsat(ic) * &
680+ (this% fmi% dis% top(ic) - this% fmi% dis% bot(ic))
689681 else
690682 z = this% rptz(ip)
691683 end if
692684
685+ x = this% rptx(ip)
686+ y = this% rpty(ip)
687+
693688 if (this% ichkmeth > 0 ) &
694689 call this% validate_release_point(ic, x, y, z)
695690
0 commit comments