subroutine subbasin_flow_travel_time(j, je, k, bSubcatch, bff, hrtc, nn, sc, sccor, z)
!**** PURPOSE: THIS SUBROUTINE CALCULATES RETURN FLOW TRAVEL TIMES
!**** CALLED IN: SUBBASIN
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! PARAMETERS & VARIABLES
!
! >>>>> COMMON PARAMETERS & VARIABLES
! bff = baseflow factor for basin, from readbas
! hrtc(j, je, l) = return flow travel time, calculated here, h
! nn = number of soil layers, calc in readsol
! sc(l, k) = sat. cond., input in readsol, mm/h
! z(l, k) = depth, input in readsol, mm
! >>>>>
! >>>>> STATIC PARAMETERS
! dg = local par
! i1 = local par
! ii = local par
! la = local par
! sumk = local par
! xx = local par
! yy = local par
! zk = local par
! >>>>>
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!**** Include common parameters
logical, intent(in) :: bSubcatch
real(dp), dimension(:), intent(inout) :: bff
real(dp), dimension(:, :, :), intent(inout) :: hrtc
integer, intent(in) :: nn
real(dp), dimension(:, :), intent(in) :: sc
real(dp), dimension(:), intent(in) :: sccor
real(dp), dimension(:, :), intent(in) :: z
integer j, je, k, i1, ii, la
real(dp) dg, sumk, xx, yy, zk
sumk = 0.
yy = 0.
zk = 0.
do la = 1, nn
ii = nn - la + 1
i1 = ii - 1
if (i1 .ne. 0) then
xx = z(i1, k)
else
xx = 0.
end if
dg = z(ii, k) - xx
yy = yy + dg
! SL begin
! sumk = sumk + dg / sc(ii, k)
! zk = yy / sumk
! zk = sc(ii, k) / zk
if (bSubcatch) then
sumk = sumk + dg / (sc(ii, k) * sccor(j))
zk = yy / sumk
zk = (sc(ii, k) * sccor(j)) / zk
else
sumk = sumk + dg / sc(ii, k)
zk = yy / sumk
zk = sc(ii, k) / zk
end if
! SL end
xx = - 0.5447 + 0.01757 * zk
if (xx .lt. - 20.) xx = - 20.
if (bff(j) .le. 0.) bff(j) = .01
hrtc(j, je, ii) = 10. * (1. - zk / (zk + exp(xx))) / bff(j)
end do
return
end subroutine subbasin_flow_travel_time