Skip to content

Commit

Permalink
Improve CropType%InitCold() efficiency.
Browse files Browse the repository at this point in the history
  • Loading branch information
samsrabin committed Nov 9, 2023
1 parent aa61010 commit 35478a3
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions src/biogeochem/CropType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -373,37 +373,32 @@ subroutine InitCold(this, bounds)
type(bounds_type), intent(in) :: bounds
!
! !LOCAL VARIABLES:
integer :: c, l, g, p, m, ivt ! indices
integer :: l, g, p, ivt ! indices
logical :: latvary_baset

character(len=*), parameter :: subname = 'InitCold'
!-----------------------------------------------------------------------

!DLL - added wheat & sugarcane restrictions to base T vary by lat
latvary_baset = trim(this%baset_mapping) == baset_map_latvary
if (.not. latvary_baset) then
this%latbaset_patch(bounds%begp:bounds%endp) = nan
end if

do p= bounds%begp,bounds%endp
g = patch%gridcell(p)
ivt = patch%itype(p)
l = patch%landunit(p)

this%nyrs_crop_active_patch(p) = 0

this%latbaset_patch(p) = latbaset(pftcon%baset(ivt), grc%latdeg(g), this%baset_latvary_intercept, this%baset_latvary_slope)
if ( trim(this%baset_mapping) == baset_map_constant ) then
this%latbaset_patch(p) = nan
end if
end do
!DLL -- end of mods

if (use_crop) then
do p= bounds%begp,bounds%endp
if (lun%itype(l) == istcrop) then
g = patch%gridcell(p)
l = patch%landunit(p)
c = patch%column(p)
ivt = patch%itype(p)
this%fertnitro_patch(p) = fert_cft(g,ivt)

if (lun%itype(l) == istcrop) then
m = patch%itype(p)
this%fertnitro_patch(p) = fert_cft(g,m)
if (latvary_baset) then
this%latbaset_patch(p) = latbaset(pftcon%baset(ivt), grc%latdeg(g), this%baset_latvary_intercept, this%baset_latvary_slope)
end if
end do
end if
end if
end do

end subroutine InitCold

Expand Down

0 comments on commit 35478a3

Please sign in to comment.