!! pWU%supplied should not be added to %inflow, because the irrigation supply is added in hydrotope !! %inflow is added to sda or varoute in "subbasin" and/or "add"
!! pWU%supplied should not be added to %inflow, because the irrigation supply is added in hydrotope !! %inflow is added to sda or varoute in "subbasin" and/or "add"
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | sub | |||
integer, | intent(in) | :: | day | |||
integer, | intent(in) | :: | ida | |||
integer, | intent(in) | :: | iyr |
subroutine management_external_supply(sub, day, ida, iyr)
integer, intent(in) :: ida
integer, intent(in) :: iyr
! calculate total inputs from external source(s) where this subbain is a destination subbasin
! external supply is true, if source subbasin number == 0 .AND. destination subbasin number >=1 .AND. <=mb
! this condition is true if TWU(sub)%wu_opt == 3
! CALLED FROM MONTHLY (in daily SUBBASIN command)
! current subbasin number
integer, intent(in) :: sub
! current day of simulation
integer, intent(in) :: day
integer :: i
! pointer on actual subbasin (TSub)
TYPE (TSubbasin), POINTER :: pS, pSd
! pointer on actual water user (TWU)
TYPE (TWaterUser), POINTER :: pWU
! NOTE: If subbasin receives water from another subbasin, this supply volume
! is added later on in subroutine wam_withdraw_Transfer_Out
if (management_is_transfer_subbasin(sub) ) then
pS => management_subbasin_pointer(sub)
if (pS % nWUin > 0) then
do i = 1, pS % nWU ! loop over water users in subbasin
pWU => management_user_pointer(pS % pos(i)) ! pointer on current water user
!-----------------------------------------------------------------
! if destination subbasin receives water from external source
!-----------------------------------------------------------------
if (pWU % wu_opt == 3 .AND. management_is_active_period(iyr, ida, pWU) ) then
!-----------------------------------------------------------------
! TSub (current subbasin)
!-----------------------------------------------------------------
! add external supply to destination subbasin inflow
pS % inflow(day) = pS % inflow(day) & ! [m3 / s]
+ pWU % data(day) & ! add supply from external source (daily time series input file)
* pWU % tr_eff ! subtract losses
! add losses to destination subbasin
pS % tr_losses_in(day) = pS % tr_losses_in(day) &
+ pWU % data(day) * (1. - pWU % tr_eff) ! summarise losses [m3 / s]
!-----------------------------------------------------------------
!-----------------------------------------------------------------
! TWU (current water user)
!-----------------------------------------------------------------
! calculate volume delivered to water user
pWU % supplied(day) = pWU % data(day) * pWU % tr_eff ! [m3 / s]
! calculate losses during transfer
pWU % tr_losses(day) = pWU % data(day) * (1. - pWU % tr_eff) ! [m3 / s]
!-----------------------------------------------------------------
end if
!-----------------------------------------------------------------
! Water user type: IRRIGATION, unlimited external source, from input file
!-----------------------------------------------------------------
! Put on the field what is provided by external source
if (pWU % wu_opt == 4 .AND. pWU % subs == 0 .AND. pWU % irr_opt == 1 &
.AND. management_is_active_period(iyr, ida, pWU) .AND. pWU % data(day) > 0. ) then
pSd => management_subbasin_pointer(pWU % subd)
!-----------------------------------------------------------------
! TWU (current water user)
!-----------------------------------------------------------------
pWU % supplied(day) = pWU % data(day) * pWU % tr_eff ! [m3 / s]
wam_supplied_summary(day) = wam_supplied_summary(day) + pWU % supplied(day) ! [m3 / s]
pWU % tr_losses(day) = pWU % data(day) * (1. - pWU % tr_eff) ! [m3 / s]
!-----------------------------------------------------------------
! TSub (current subbasin)
!-----------------------------------------------------------------
!!!! pWU%supplied should not be added to %inflow, because the irrigation supply is added in hydrotope
!!!! %inflow is added to sda or varoute in "subbasin" and/or "add"
!pSd%inflow(day) = pSd%inflow(day) + pWU%supplied(day)
pSd % tr_losses_in(day) = pSd % tr_losses_in(day) + pWU % tr_losses(day)
end if
!-----------------------------------------------------------------
! Water user type: IRRIGATION, unlimited external source, demand from plant deficit
!-----------------------------------------------------------------
! assuming an unlimited source providing exactly the required irrigation demand
if (day > 1) then
if (pWU % wu_opt == 4 .AND. pWU % subs == 0 .AND. pWU % irr_opt == 2 &
.AND. management_is_active_period(iyr, ida, pWU) .AND. pWU % irrigationDemand(day - 1) > 0. ) then ! .AND. pWU % supplied(day - 1) > 0. ) then
pSd => management_subbasin_pointer(pWU % subd)
!-----------------------------------------------------------------
! TWU (current water user)
!-----------------------------------------------------------------
pWU % data(day) = pWU % irrigationDemand(day - 1) ! [m3 / s]
pWU % supplied(day) = pWU % irrigationDemand(day - 1) ! [m3 / s]
wam_supplied_summary(day) = wam_supplied_summary(day) + pWU % supplied(day) ! [m3 / s]
pWU % tr_losses(day) = pWU % supplied(day - 1) * (1. - pWU % tr_eff) ! [m3 / s]
!-----------------------------------------------------------------
! TSub (current subbasin)
!-----------------------------------------------------------------
pSd % irrDemand(day) = pSd % irrDemand(day) + pWU % irrigationDemand(day - 1)
!!!! pWU%supplied should not be added to %inflow, because the irrigation supply is added in hydrotope
!!!! %inflow is added to sda or varoute in "subbasin" and/or "add"
!pSd%inflow(day) = pSd%inflow(day) + pWU%supplied(day)
pSd % tr_losses_in(day) = pWU % tr_losses(day)
end if
end if ! ( day > 1 )
end do
end if
else
call log_warn("wam", "Water allocation module was called for (subbasin) "// &
"although it has no water users !!!", i1=sub)
end if
end subroutine management_external_supply