subroutine crop_yield_output(j, jek, k, ieap, ms, ndgro, tsav, wsav, ylda, is_cropland)
!**** PURPOSE: Write crop yield for GRASS output
!**** CALLED IN: SUBBASIN
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! PARAMETERS & VARIABLES
!
! >>>>> COMMON PARAMETERS & VARIABLES
! ieap = counter
! ndgro = number days of growth - calc. in crop
! tsav(j, je) = temp stress, sum for the growth period
! wsav(j, je) = water stress, sum for the growth period
! ylda(j, k) = crop yield, kg/ha
! >>>>>
! >>>>> STATIC PARAMETERS
! mts = mean temp stress for the growth period, in %
! mws = mean water stress for the growth period, in %
! myld = ylda(j, k)/100 - yield in kg/dt, integer
! xyld = crop yield, dt/ha
! >>>>>
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!**** Include common parameters
integer, intent(inout) :: ieap
integer, intent(in) :: ms
integer, intent(in) :: ndgro
real(dp), dimension(:, :), intent(inout) :: tsav
real(dp), dimension(:, :), intent(inout) :: wsav
real(dp), dimension(:, :), intent(in) :: ylda
logical, intent(in) :: is_cropland
integer :: j, jek, k, mts, mws, myld
real(dp) :: xyld
if (is_cropland .and. k .lt. ms .and. ndgro .gt. 0) then
xyld = ylda(j, k) / 100. + 0.5
myld = int(xyld)
mws = int(wsav(j, jek) / ndgro * 100)
mts = int(tsav(j, jek) / ndgro * 100)
else
myld = 0
mws = 0
mts = 0
end if
ieap = ieap + 1
wsav(j, jek) = 0.
tsav(j, jek) = 0.
end subroutine crop_yield_output