subroutine vegetation_temperature_stress(tgx, j, je, n, avt, nucr, nveg, tmn, to, tx)
!**** PURPOSE: COMPUTES TEMPERATURE STRESS FOR CROP/VEGETATION GROWTH
!**** CALLED IN: GROWTH, VEGMD
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! PARAMETERS & VARIABLES
!
! >>>>> COMMON PARAMETERS & VARIABLES
! avt(j) = average annual daily temerature., degree C
! nucr(j, je) = crop number
! nveg(j, je) = vegetation number
! tb(iv) = base temp for plant growth, degree C
! tmn(j) = daily min temp, from readcli, degree C
! to(iv) = opt temp for growth, degree C
! ts = temp stress factor
! tx(j) = daily aver temp, degree C
! >>>>>
! >>>>> STATIC PARAMETERS
! num = local par
! rto = local par
! rto1 = local par
! rto2 = local par
! >>>>>
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!**** Include common parameters
use landuse, only : landuse_is_cropland
use snow, only : bSnowModule, tmin, tx_tmp, tmit, tmin_tmp
real(dp), dimension(:), intent(in) :: avt
integer, dimension(:, :), intent(in) :: nucr
integer, dimension(:, :), intent(in) :: nveg
real(dp), dimension(:), intent(in) :: tmn
real(dp), dimension(:), intent(in) :: to
real(dp), dimension(:), intent(in) :: tx
integer j, je, n, num
real(dp) tgx, rto, rto1, rto2
!###########################
!#### SNOW MODULE ####
!###########################
if (bSnowModule) then
tx_tmp = tmit
tmin_tmp = tmin
else
tx_tmp = tx(j)
tmin_tmp = tmn(j)
end if
!###########################
if (landuse_is_cropland(n) ) then
num = nucr(j, je)
else
num = nveg(j, je)
endif
rto = 0.
rto1 = 0.
rto2 = 0.
!**** CALC temp stress factor ts
if (tx_tmp .le. to(num)) then
tgx = (to(num) + tb(num)) / (to(num) - tb(num))
rto1 = tgx * (to(num) - tx_tmp) ** 2
rto2 = rto1 / (tx_tmp + 1.e-6)
if (rto2 .le. 200.) then
ts = exp(- 0.1054 * rto2)
else
ts = 0.
end if
else
tgx = 2. * to(num) - tb(num) - tx_tmp
rto = ((to(num)-tx_tmp) / (tgx + 1.e-6)) ** 2
if (rto .le. 200.) then
ts = exp(- 0.1054 * rto)
else
ts = 0.
end if
endif
if (tmin_tmp .le. (avt(j) - 15.)) ts = 0.
return
end subroutine vegetation_temperature_stress