Skip to content

Commit

Permalink
fix(prt): skip release times falling outside tdis
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Jan 6, 2025
1 parent 5105ce7 commit 9223d18
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/Model/ModelUtilities/ReleaseSchedule.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module ReleaseScheduleModule
use MathUtilModule, only: is_close
use TimeSelectModule, only: TimeSelectType
use TimeStepSelectModule, only: TimeStepSelectType
use SimModule, only: store_error, store_warning
use SimVariablesModule, only: errmsg, warnmsg

implicit none
private
Expand Down Expand Up @@ -108,7 +110,7 @@ end subroutine schedule
!! This routine is idempotent.
!<
subroutine advance(this, lines)
use TdisModule, only: totimc, kstp, endofperiod
use TdisModule, only: totimc, kstp, endofperiod, totalsimtime
class(ReleaseScheduleType), intent(inout) :: this
character(len=LINELENGTH), intent(in), optional :: lines(:)
integer(I4B) :: it, i
Expand Down Expand Up @@ -142,17 +144,30 @@ subroutine advance(this, lines)
tprevious = trelease
end if

! Add explicitly configured release times, up
! to the configured tolerance of coincidence.
! Schedule explicitly specified release times, up
! to the configured tolerance of coincidence. Any
! release times falling outside tdis' bounds will
! be omitted; particle releases may only occur in
! the simulation's time window.
if (this%time_select%any()) then
do it = this%time_select%selection(1), this%time_select%selection(2)
trelease = this%time_select%times(it)
! Skip the release time if it's too close
! to the previously scheduled release time.

! Skip the release time if..
! ..it falls before the simulation start time
if (trelease < DZERO .or. trelease > totalsimtime) then
write (warnmsg, '(a,g0,a)') &
'Warning: release time (t=', trelease, ') is outside tdis'
call store_warning(warnmsg)
cycle
end if

! ..or it's too close to the previous time
if (tprevious >= DZERO .and. is_close( &
tprevious, &
trelease, &
atol=this%tolerance)) cycle

call this%schedule(trelease)
tprevious = trelease
end do
Expand Down

0 comments on commit 9223d18

Please sign in to comment.