Skip to content

Commit

Permalink
Merge branch 'peterdschwartz/lnd/remove-initializations' into next (PR
Browse files Browse the repository at this point in the history
…#6058)

Every model timestep, the vegetation and column fluxes are set to zero for the CNP variables.
This took up roughly 1/3rd of the time for the Ecosystem model time, and this PR reduces that by over half.

[BFB]
  • Loading branch information
bishtgautam committed Jan 5, 2024
2 parents ab7c7e0 + 772a5de commit 575f773
Show file tree
Hide file tree
Showing 6 changed files with 263 additions and 523 deletions.
2 changes: 1 addition & 1 deletion components/elm/src/biogeochem/AllocationMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@ subroutine Allocation2_ResolveNPLimit (bounds, num_soilc, filter_soilc , &
! deficit for NO3 to meet allocation needs, is only added to the NH4 pool.
! Thus, the NH4 fluxes are increased, for itself and as a surrogate to meet the
! NO3 flux demands.

supplement_to_sminn_vr(c,j) = 0._r8
if (carbon_only .or. carbonphosphorus_only) then

if ( fpi_no3_vr(j) + fpi_nh4_vr(j) < 1._r8 ) then
Expand Down
3 changes: 3 additions & 0 deletions components/elm/src/biogeochem/FireMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,7 @@ subroutine FireFluxes (num_soilc, filter_soilc, num_soilp, filter_soilp, &
do j = 1, nlevdecomp
! carbon fluxes
do l = 1, ndecomp_pools
m_decomp_cpools_to_fire_vr(c,j,l) = 0._r8
if ( is_litter(l) ) then
m_decomp_cpools_to_fire_vr(c,j,l) = decomp_cpools_vr(c,j,l) * f * 0.5_r8
end if
Expand All @@ -1386,6 +1387,7 @@ subroutine FireFluxes (num_soilc, filter_soilc, num_soilp, filter_soilp, &

! nitrogen fluxes
do l = 1, ndecomp_pools
m_decomp_npools_to_fire_vr(c,j,l) = 0.0_r8
if ( is_litter(l) ) then
m_decomp_npools_to_fire_vr(c,j,l) = decomp_npools_vr(c,j,l) * f * 0.5_r8
end if
Expand All @@ -1403,6 +1405,7 @@ subroutine FireFluxes (num_soilc, filter_soilc, num_soilp, filter_soilp, &

! phosphorus fluxes - loss due to fire
do l = 1, ndecomp_pools
m_decomp_ppools_to_fire_vr(c,j,l) = 0._r8
if ( is_litter(l) ) then
m_decomp_ppools_to_fire_vr(c,j,l) = decomp_ppools_vr(c,j,l) * f * 0.5_r8
end if
Expand Down
9 changes: 9 additions & 0 deletions components/elm/src/biogeochem/GapMortalityMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ subroutine GapMortality (num_soilc, filter_soilc, num_soilp, filter_soilp, &
!------------------------------------------------------

! displayed pools
veg_cf%m_leafc_to_litter(p) = 0._r8
veg_cf%m_livestemc_to_litter(p) = 0._r8
if(ivt(p) < npcropmin .or. (ivt(p) >= npcropmin .and. croplive(p))) then
veg_cf%m_leafc_to_litter(p) = veg_cs%leafc(p) * m
veg_cf%m_livestemc_to_litter(p) = veg_cs%livestemc(p) * m
Expand Down Expand Up @@ -178,6 +180,8 @@ subroutine GapMortality (num_soilc, filter_soilc, num_soilp, filter_soilp, &
!------------------------------------------------------

! displayed pools
veg_nf%m_leafn_to_litter(p) = 0._r8
veg_nf%m_livestemn_to_litter(p) = 0._r8
if(ivt(p) < npcropmin .or. (ivt(p) >= npcropmin .and. croplive(p))) then
veg_nf%m_leafn_to_litter(p) = veg_ns%leafn(p) * m
veg_nf%m_livestemn_to_litter(p) = veg_ns%livestemn(p) * m
Expand All @@ -186,6 +190,7 @@ subroutine GapMortality (num_soilc, filter_soilc, num_soilp, filter_soilp, &
veg_nf%m_deadstemn_to_litter(p) = veg_ns%deadstemn(p) * m
veg_nf%m_livecrootn_to_litter(p) = veg_ns%livecrootn(p) * m
veg_nf%m_deadcrootn_to_litter(p) = veg_ns%deadcrootn(p) * m
veg_nf%m_retransn_to_litter(p) = 0._r8
if (ivt(p) < npcropmin) then
veg_nf%m_retransn_to_litter(p) = veg_ns%retransn(p) * m
end if
Expand Down Expand Up @@ -219,6 +224,8 @@ subroutine GapMortality (num_soilc, filter_soilc, num_soilp, filter_soilp, &
!------------------------------------------------------

! displayed pools
veg_pf%m_leafp_to_litter(p) = 0._r8
veg_pf%m_livestemp_to_litter(p) = 0._r8
if(ivt(p) < npcropmin .or. (ivt(p) >= npcropmin .and. croplive(p))) then
veg_pf%m_leafp_to_litter(p) = veg_ps%leafp(p) * m
veg_pf%m_livestemp_to_litter(p) = veg_ps%livestemp(p) * m
Expand All @@ -227,6 +234,8 @@ subroutine GapMortality (num_soilc, filter_soilc, num_soilp, filter_soilp, &
veg_pf%m_deadstemp_to_litter(p) = veg_ps%deadstemp(p) * m
veg_pf%m_livecrootp_to_litter(p) = veg_ps%livecrootp(p) * m
veg_pf%m_deadcrootp_to_litter(p) = veg_ps%deadcrootp(p) * m

veg_pf%m_retransp_to_litter(p) = 0._r8
if (ivt(p) < npcropmin) then
veg_pf%m_retransp_to_litter(p) = veg_ps%retransp(p) * m
end if
Expand Down
30 changes: 11 additions & 19 deletions components/elm/src/biogeochem/SoilLittDecompMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ subroutine SoilLittDecompAlloc (bounds, num_soilc, filter_soilc, &
/ cp_decomp_pools_new(c,j,cascade_receiver_pool(k)) )

else ! 100% respiration
pmpf_decomp_cascade(c,j,k) = - p_decomp_cpool_loss(c,j,k) / cp_decomp_pools(c,j,cascade_donor_pool(k))
if(decomp_ppools_vr(c,j,cascade_donor_pool(k)) > 0._r8) then
pmpf_decomp_cascade(c,j,k) = - p_decomp_cpool_loss(c,j,k) / cp_decomp_pools(c,j,cascade_donor_pool(k))
end if
endif

else ! CWD -> litter
Expand Down Expand Up @@ -414,7 +416,12 @@ subroutine SoilLittDecompAlloc (bounds, num_soilc, filter_soilc, &
do j = 1,nlevdecomp
do fc = 1,num_soilc
c = filter_soilc(fc)

decomp_cascade_hr_vr(c,j,k) = 0._r8
decomp_cascade_ctransfer_vr(c,j,k) = 0._r8
decomp_cascade_ptransfer_vr(c,j,k) = 0._r8
decomp_cascade_ntransfer_vr(c,j,k) = 0._r8
decomp_cascade_sminn_flux_vr(c,j,k) = 0._r8
decomp_cascade_sminp_flux_vr(c,j,k) = 0._r8
if (decomp_cpools_vr(c,j,cascade_donor_pool(k)) > 0._r8) then
if ( pmnf_decomp_cascade(c,j,k) > 0._r8 .and. pmpf_decomp_cascade(c,j,k) > 0._r8 ) then ! N and P co-limitation
p_decomp_cpool_loss(c,j,k) = p_decomp_cpool_loss(c,j,k) * min( fpi_vr(c,j),fpi_p_vr(c,j) )
Expand Down Expand Up @@ -553,18 +560,6 @@ subroutine SoilLittDecompAlloc (bounds, num_soilc, filter_soilc, &
end do
end if

! vertically integrate net and gross mineralization fluxes for diagnostic output
! moved to SoilLittDecompAlloc2
! do j = 1,nlevdecomp
! do fc = 1,num_soilc
! c = filter_soilc(fc)
! net_nmin(c) = net_nmin(c) + net_nmin_vr(c,j) * dzsoi_decomp(j)
! gross_nmin(c) = gross_nmin(c) + gross_nmin_vr(c,j) * dzsoi_decomp(j)
! net_pmin(c) = net_pmin(c) + net_pmin_vr(c,j) * dzsoi_decomp(j)
! gross_pmin(c) = gross_pmin(c) + gross_pmin_vr(c,j) * dzsoi_decomp(j)
! end do
! end do

end associate

end subroutine SoilLittDecompAlloc
Expand Down Expand Up @@ -821,7 +816,6 @@ subroutine CNvariables_nan4pf (bounds, num_soilc, filter_soilc, num_soilp, filte
! if not properly set.
!
!USES:
!$acc routine seq
use elm_varctl , only: carbon_only, carbonnitrogen_only
use elm_varpar , only: nlevdecomp, ndecomp_cascade_transitions
!
Expand Down Expand Up @@ -863,13 +857,11 @@ subroutine CNvariables_nan4pf (bounds, num_soilc, filter_soilc, num_soilp, filte
call veg_ps%SetValues(num_patch=num_soilp, filter_patch=filter_soilp, value_patch=0._r8)
call col_ps%SetValues(num_column=num_soilc, filter_column=filter_soilc, value_column=0._r8)

call veg_pf%setvalues( num_patch=num_soilp, filter_patch=filter_soilp, value_patch=0._r8)
call col_pf%setvalues( num_column=num_soilc, filter_column=filter_soilc, value_column=0._r8)
call veg_pf%SetValues( num_patch=num_soilp, filter_patch=filter_soilp, value_patch=0._r8)
call col_pf%SetValues( num_column=num_soilc, filter_column=filter_soilc, value_column=0._r8)
end if

end associate
end subroutine CNvariables_nan4pf

!-------------------------------------------------------------------------------------------------

end module SoilLittDecompMod
Loading

0 comments on commit 575f773

Please sign in to comment.