From e8fb92b4fbe9d03433ea58efdcf1aa66d152e9a6 Mon Sep 17 00:00:00 2001 From: wwieder Date: Tue, 23 Sep 2025 08:51:09 -0600 Subject: [PATCH 1/5] overflow respiration bug fixes #3491 --- .../SoilBiogeochemCarbonFluxType.F90 | 2 + .../SoilBiogeochemCompetitionMod.F90 | 16 ++++---- .../SoilBiogeochemPotentialMod.F90 | 40 ++++++++++++++----- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90 b/src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90 index 23f24e44d5..ae127fcd59 100644 --- a/src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90 +++ b/src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90 @@ -469,6 +469,8 @@ subroutine InitHistory(this, bounds, carbon_type) call hist_addfld2d (fname='HR_vr', units='gC/m^3/s', type2d='levsoi', & avgflag='A', long_name='total vertically resolved heterotrophic respiration', & ptr_col=data2dptr) + + ! WW TODO is this where I can add overflow_vr fluxes to history? endif end if diff --git a/src/soilbiogeochem/SoilBiogeochemCompetitionMod.F90 b/src/soilbiogeochem/SoilBiogeochemCompetitionMod.F90 index 57bc82984e..afcd97b213 100644 --- a/src/soilbiogeochem/SoilBiogeochemCompetitionMod.F90 +++ b/src/soilbiogeochem/SoilBiogeochemCompetitionMod.F90 @@ -253,8 +253,8 @@ subroutine SoilBiogeochemCompetition (bounds, num_bgc_soilc, filter_bgc_soilc,nu sminn_vr => soilbiogeochem_nitrogenstate_inst%sminn_vr_col , & ! Input: [real(r8) (:,:) ] (gN/m3) soil mineral N smin_nh4_vr => soilbiogeochem_nitrogenstate_inst%smin_nh4_vr_col , & ! Input: [real(r8) (:,:) ] (gN/m3) soil mineral NH4 smin_no3_vr => soilbiogeochem_nitrogenstate_inst%smin_no3_vr_col , & ! Input: [real(r8) (:,:) ] (gN/m3) soil mineral NO3 - - c_overflow_vr => soilbiogeochem_carbonflux_inst%c_overflow_vr , & ! Output: [real(r8) (:,:,:)] (gC/m3/s) vertically-resolved C rejected by microbes that cannot process it + !WW handling overflow respiration in SoilBiogeochemPotentialMod for now + !c_overflow_vr => soilbiogeochem_carbonflux_inst%c_overflow_vr , & ! Output: [real(r8) (:,:,:)] (gC/m3/s) vertically-resolved C rejected by microbes that cannot process it cascade_receiver_pool => decomp_cascade_con%cascade_receiver_pool , & ! Input: [integer (:) ] which pool is C added to for a given decomposition step pot_f_nit_vr => soilbiogeochem_nitrogenflux_inst%pot_f_nit_vr_col , & ! Input: [real(r8) (:,:) ] (gN/m3/s) potential soil nitrification flux @@ -821,6 +821,7 @@ subroutine SoilBiogeochemCompetition (bounds, num_bgc_soilc, filter_bgc_soilc,nu cascade_receiver_pool(k) == i_oli_mic) then sum_ndemand_vr(c,j) = sum_no3_demand_scaled(c,j) + & sum_nh4_demand_scaled(c,j) + ! WW effectively turn this off now, since pmnf_decomp_cascade < 0 for mineralization if (pmnf_decomp_cascade(c,j,k) > 0.0_r8 .and. & sum_ndemand_vr(c,j) > 0.0_r8) then amnf_immob_vr = (sminn_vr(c,j) / dt) * & @@ -828,19 +829,20 @@ subroutine SoilBiogeochemCompetition (bounds, num_bgc_soilc, filter_bgc_soilc,nu sum_ndemand_vr(c,j)) n_deficit_vr = pmnf_decomp_cascade(c,j,k) - & amnf_immob_vr - c_overflow_vr(c,j,k) = & - n_deficit_vr * p_decomp_cn_gain(c,j,cascade_receiver_pool(k)) + !c_overflow_vr(c,j,k) = & + ! n_deficit_vr * p_decomp_cn_gain(c,j,cascade_receiver_pool(k)) + ! TODO, need to updated p_decomp_c_gain accordingly else ! not pmnf and sum_ndemand > 0 - c_overflow_vr(c,j,k) = 0.0_r8 + !c_overflow_vr(c,j,k) = 0.0_r8 end if else ! not microbes receiving - c_overflow_vr(c,j,k) = 0.0_r8 + !c_overflow_vr(c,j,k) = 0.0_r8 end if end do end do end do else ! not mimics_decomp - c_overflow_vr(:,:,:) = 0.0_r8 + !c_overflow_vr(:,:,:) = 0.0_r8 end if if(.not.local_use_fun)then diff --git a/src/soilbiogeochem/SoilBiogeochemPotentialMod.F90 b/src/soilbiogeochem/SoilBiogeochemPotentialMod.F90 index deb9bdbf78..38098f445f 100644 --- a/src/soilbiogeochem/SoilBiogeochemPotentialMod.F90 +++ b/src/soilbiogeochem/SoilBiogeochemPotentialMod.F90 @@ -104,6 +104,7 @@ subroutine SoilBiogeochemPotential (bounds, num_bgc_soilc, filter_bgc_soilc, & real(r8):: p_decomp_npool_gain_sum(1:ndecomp_pools) ! total potential N gain by receiver pool (only microbial pools) real(r8):: decomp_nc_loss_donor ! N:C ratio of donor pool real(r8):: p_decomp_cn_diff_ratio ! relative change in receiver pool C:N + real(r8):: adjusted_c_to_mic ! relative change in receiver pool C:N real(r8):: p_decomp_npool_loss ! potential N flux out of donor pool real(r8):: ratio !temporary variable !----------------------------------------------------------------------- @@ -129,6 +130,7 @@ subroutine SoilBiogeochemPotential (bounds, num_bgc_soilc, filter_bgc_soilc, & decomp_npools_vr => soilbiogeochem_nitrogenstate_inst%decomp_npools_vr_col , & ! Input: [real(r8) (:,:,:) ] (gC/m3) vertically-resolved decomposing (litter, cwd, soil) N pools decomp_cpools_vr => soilbiogeochem_carbonstate_inst%decomp_cpools_vr_col , & ! Input: [real(r8) (:,:,:) ] (gC/m3) vertically-resolved decomposing (litter, cwd, soil) c pools + c_overflow_vr => soilbiogeochem_carbonflux_inst%c_overflow_vr , & ! Output: [real(r8) (:,:,:)] (gC/m3/s) vertically-resolved C rejected by microbes that cannot process it potential_immob_vr => soilbiogeochem_nitrogenflux_inst%potential_immob_vr_col , & ! Output: [real(r8) (:,:) ] gross_nmin_vr => soilbiogeochem_nitrogenflux_inst%gross_nmin_vr_col , & ! Output: [real(r8) (:,:) ] @@ -198,6 +200,7 @@ subroutine SoilBiogeochemPotential (bounds, num_bgc_soilc, filter_bgc_soilc, & endif else ! CWD -> litter OR mimics_decomp is true pmnf_decomp_cascade(c,j,k) = 0._r8 + c_overflow_vr(c,j,k) = 0._r8 if (decomp_method == mimics_decomp) then ! N:C ratio of donor pools (N:C instead of C:N because @@ -271,18 +274,33 @@ subroutine SoilBiogeochemPotential (bounds, num_bgc_soilc, filter_bgc_soilc, & cascade_receiver_pool(k) == i_oli_mic) then if (decomp_cpools_vr(c,j,cascade_donor_pool(k)) > 0._r8 .and. & decomp_k(c,j,cascade_donor_pool(k)) > 0._r8 ) then - ! if p_decomp_cn_diff < 0 N mineralization - ! > 0 immobilization - ! "min" in next line turns off immobilization flux - p_decomp_cn_diff_ratio = min(0.0_r8, & + ! if p_decomp_cn_diff_ratio < 0 N mineralization + ! > 0 immobilization + !! Easier here if p_decomp_cn_diff_ratio < 0 + !! then calculate C supply for each N flux to meet cn_col demands + !! and extra C goes to overflow respiration + !! This approcah this would be on a per flux basis + !! Alternatively could sum all C and N fluxes into microbes and then balance stoich + !! but this would have to take place outside of k loop + p_decomp_cn_diff_ratio = & (p_decomp_cn_gain(c,j,cascade_receiver_pool(k)) - & - cn_col(c,cascade_receiver_pool(k))) / cn_col(c,cascade_receiver_pool(k))) - ! Actual amount of N that's mineralized or that would - ! need to be immobilized - ! negative=mineralization: add to the DIN pool - ! positive=immobilizaiton: compete for N with plants to - ! see how much we get - pmnf_decomp_cascade(c,j,k) = p_decomp_cn_diff_ratio * p_decomp_npool_gain(c,j,k) + cn_col(c,cascade_receiver_pool(k))) / cn_col(c,cascade_receiver_pool(k)) + + ! Actual amount of N that's mineralized or that would be need to be immobilized + ! negative=mineralization: add to the DIN pool + ! positive=immobilizaiton: compete for N with plants to see how much we get + ! WW Overflow respiration calculation requires positive ratio to be active + ! TODO may need to think about how we track actual immobilization fluxes too? + if (p_decomp_cn_diff_ratio <= 0._r8) then + pmnf_decomp_cascade(c,j,k) = p_decomp_cn_diff_ratio * p_decomp_npool_gain(c,j,k) + c_overflow_vr(c,j,k) = 0.0_r8 + else + ! Assumes each flux into MIC must be in stoichiometric ballance + ! Could also sum at all C fluxes into MIC and then maintain stoichiometry + pmnf_decomp_cascade(c,j,k) = 0._r8 + adjusted_c_to_mic = p_decomp_npool_gain(c,j,k) * cn_col(c,cascade_receiver_pool(k)) + c_overflow_vr(c,j,k) = p_decomp_cpool_gain(c,j,k) - adjusted_c_to_mic + end if end if ! donors donating (decomp_cpools_vr & decomp_k > 0) end if ! microbes receiving end do ! transitions loop From fcface4c6e25a7ab0b12c8a64834660fd2e493ec Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 11 May 2026 14:56:25 -0600 Subject: [PATCH 2/5] Remove commented out sections with c_overflow_vr --- src/soilbiogeochem/SoilBiogeochemCompetitionMod.F90 | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/soilbiogeochem/SoilBiogeochemCompetitionMod.F90 b/src/soilbiogeochem/SoilBiogeochemCompetitionMod.F90 index afcd97b213..9883626704 100644 --- a/src/soilbiogeochem/SoilBiogeochemCompetitionMod.F90 +++ b/src/soilbiogeochem/SoilBiogeochemCompetitionMod.F90 @@ -253,8 +253,6 @@ subroutine SoilBiogeochemCompetition (bounds, num_bgc_soilc, filter_bgc_soilc,nu sminn_vr => soilbiogeochem_nitrogenstate_inst%sminn_vr_col , & ! Input: [real(r8) (:,:) ] (gN/m3) soil mineral N smin_nh4_vr => soilbiogeochem_nitrogenstate_inst%smin_nh4_vr_col , & ! Input: [real(r8) (:,:) ] (gN/m3) soil mineral NH4 smin_no3_vr => soilbiogeochem_nitrogenstate_inst%smin_no3_vr_col , & ! Input: [real(r8) (:,:) ] (gN/m3) soil mineral NO3 - !WW handling overflow respiration in SoilBiogeochemPotentialMod for now - !c_overflow_vr => soilbiogeochem_carbonflux_inst%c_overflow_vr , & ! Output: [real(r8) (:,:,:)] (gC/m3/s) vertically-resolved C rejected by microbes that cannot process it cascade_receiver_pool => decomp_cascade_con%cascade_receiver_pool , & ! Input: [integer (:) ] which pool is C added to for a given decomposition step pot_f_nit_vr => soilbiogeochem_nitrogenflux_inst%pot_f_nit_vr_col , & ! Input: [real(r8) (:,:) ] (gN/m3/s) potential soil nitrification flux @@ -829,20 +827,11 @@ subroutine SoilBiogeochemCompetition (bounds, num_bgc_soilc, filter_bgc_soilc,nu sum_ndemand_vr(c,j)) n_deficit_vr = pmnf_decomp_cascade(c,j,k) - & amnf_immob_vr - !c_overflow_vr(c,j,k) = & - ! n_deficit_vr * p_decomp_cn_gain(c,j,cascade_receiver_pool(k)) - ! TODO, need to updated p_decomp_c_gain accordingly - else ! not pmnf and sum_ndemand > 0 - !c_overflow_vr(c,j,k) = 0.0_r8 end if - else ! not microbes receiving - !c_overflow_vr(c,j,k) = 0.0_r8 end if end do end do end do - else ! not mimics_decomp - !c_overflow_vr(:,:,:) = 0.0_r8 end if if(.not.local_use_fun)then From ef8f5d592823c3b24ee1972b04dbbfc275eba12c Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 11 May 2026 15:48:49 -0600 Subject: [PATCH 3/5] Add c_overflow and c_overflow_vr to history --- .../SoilBiogeochemCarbonFluxType.F90 | 52 ++++++++++++++++++- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90 b/src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90 index ae127fcd59..5aef099d74 100644 --- a/src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90 +++ b/src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90 @@ -31,6 +31,7 @@ module SoilBiogeochemCarbonFluxType ! decomposition fluxes real(r8), pointer :: decomp_cpools_sourcesink_col (:,:,:) ! change in decomposing c pools. Used to update concentrations concurrently with vertical transport (gC/m3/timestep) real(r8), pointer :: c_overflow_vr (:,:,:) ! vertically-resolved C rejected by microbes that cannot process it (gC/m3/s) + real(r8), pointer :: c_overflow (:,:) ! vertically-integrated C rejected by microbes that cannot process it (gC/m3/s) real(r8), pointer :: decomp_cascade_hr_vr_col (:,:,:) ! vertically-resolved het. resp. from decomposing C pools (gC/m3/s) real(r8), pointer :: decomp_cascade_hr_col (:,:) ! vertically-integrated (diagnostic) het. resp. from decomposing C pools (gC/m2/s) real(r8), pointer :: decomp_cascade_ctransfer_vr_col (:,:,:) ! vertically-resolved C transferred along deomposition cascade (gC/m3/s) @@ -142,6 +143,9 @@ subroutine InitAllocate(this, bounds) allocate(this%c_overflow_vr(begc:endc,1:nlevdecomp_full,1:ndecomp_cascade_transitions)) this%c_overflow_vr(:,:,:) = nan + allocate(this%c_overflow(begc:endc,1:ndecomp_cascade_transitions)) + this%c_overflow(:,:) = nan + allocate(this%decomp_cascade_hr_vr_col(begc:endc,1:nlevdecomp_full,1:ndecomp_cascade_transitions)) this%decomp_cascade_hr_vr_col(:,:,:)= spval @@ -307,6 +311,8 @@ subroutine InitHistory(this, bounds, carbon_type) ptr_col=data2dptr, default='inactive') end do + this%c_overflow(begc:endc,:) = spval + this%c_overflow_vr(begc:endc,:,:) = spval this%decomp_cascade_hr_col(begc:endc,:) = spval this%decomp_cascade_hr_vr_col(begc:endc,:,:) = spval this%decomp_cascade_ctransfer_col(begc:endc,:) = spval @@ -316,6 +322,27 @@ subroutine InitHistory(this, bounds, carbon_type) do l = 1, ndecomp_cascade_transitions ! output the vertically integrated fluxes only as default + !-- C overflow (ONLY c12 FOR NOW) + data1dptr => this%c_overflow(:,l) + ! check to see if there are multiple pathways that include respiration, and if so, note that in the history file + ii = 0 + do jj = 1, ndecomp_cascade_transitions + if ( decomp_cascade_con%cascade_donor_pool(jj) == decomp_cascade_con%cascade_donor_pool(l) ) ii = ii+1 + end do + if ( ii == 1 ) then + fieldname = & + trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'_COVERFLOW' + else + fieldname = & + trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'_COVERFLOW_'//& + trim(decomp_cascade_con%decomp_pool_name_short(decomp_cascade_con%cascade_receiver_pool(l))) + endif + longname = 'C overflow from '//& + trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l))) + call hist_addfld1d (fname=fieldname, units='gC/m^2/s', & + avgflag='A', long_name=longname, & + ptr_col=data1dptr, default='inactive') + !-- HR fluxes data1dptr => this%decomp_cascade_hr_col(:,l) ! check to see if there are multiple pathways that include respiration, and if so, note that in the history file @@ -352,6 +379,29 @@ subroutine InitHistory(this, bounds, carbon_type) ! output the vertically resolved fluxes if ( nlevdecomp_full > 1 ) then + !-- C overflow (ONLY c12 FOR NOW) + data2dptr => this%c_overflow_vr(:,:,l) + ! check to see if there are multiple pathways that include respiration, and if so, note that in the history file + ii = 0 + do jj = 1, ndecomp_cascade_transitions + if ( decomp_cascade_con%cascade_donor_pool(jj) == decomp_cascade_con%cascade_donor_pool(l) ) ii = ii+1 + end do + if ( ii == 1 ) then + fieldname = & + trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))& + //'_COVERFLOW'//trim(vr_suffix) + else + fieldname = & + trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'_COVERFLOW_'//& + trim(decomp_cascade_con%decomp_pool_name_short(decomp_cascade_con%cascade_receiver_pool(l)))& + //trim(vr_suffix) + endif + longname = 'C overflow from '//& + trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l))) + call hist_addfld_decomp (fname=fieldname, units='gC/m^3/s', type2d='levdcmp', & + avgflag='A', long_name=longname, & + ptr_col=data2dptr, default='inactive') + !-- HR fluxes data2dptr => this%decomp_cascade_hr_vr_col(:,:,l) ! check to see if there are multiple pathways that include respiration, and if so, note that in the history file @@ -469,8 +519,6 @@ subroutine InitHistory(this, bounds, carbon_type) call hist_addfld2d (fname='HR_vr', units='gC/m^3/s', type2d='levsoi', & avgflag='A', long_name='total vertically resolved heterotrophic respiration', & ptr_col=data2dptr) - - ! WW TODO is this where I can add overflow_vr fluxes to history? endif end if From 12eb3e596897116fd1d074fb307451f9f0c0cc30 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 12 May 2026 13:39:29 -0600 Subject: [PATCH 4/5] Correct units in a comment, as per code review --- src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90 b/src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90 index 5aef099d74..91bf8b09d1 100644 --- a/src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90 +++ b/src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90 @@ -31,7 +31,7 @@ module SoilBiogeochemCarbonFluxType ! decomposition fluxes real(r8), pointer :: decomp_cpools_sourcesink_col (:,:,:) ! change in decomposing c pools. Used to update concentrations concurrently with vertical transport (gC/m3/timestep) real(r8), pointer :: c_overflow_vr (:,:,:) ! vertically-resolved C rejected by microbes that cannot process it (gC/m3/s) - real(r8), pointer :: c_overflow (:,:) ! vertically-integrated C rejected by microbes that cannot process it (gC/m3/s) + real(r8), pointer :: c_overflow (:,:) ! vertically-integrated C rejected by microbes that cannot process it (gC/m2/s) real(r8), pointer :: decomp_cascade_hr_vr_col (:,:,:) ! vertically-resolved het. resp. from decomposing C pools (gC/m3/s) real(r8), pointer :: decomp_cascade_hr_col (:,:) ! vertically-integrated (diagnostic) het. resp. from decomposing C pools (gC/m2/s) real(r8), pointer :: decomp_cascade_ctransfer_vr_col (:,:,:) ! vertically-resolved C transferred along deomposition cascade (gC/m3/s) From aed226f80465a3fe63689383d84b805f4075b9c2 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 12 May 2026 17:50:44 -0600 Subject: [PATCH 5/5] Finish adding and rename the c_overflow vars going to history --- .../SoilBiogeochemCarbonFluxType.F90 | 123 +++++++++++------- .../SoilBiogeochemDecompMod.F90 | 4 +- .../SoilBiogeochemPotentialMod.F90 | 8 +- 3 files changed, 79 insertions(+), 56 deletions(-) diff --git a/src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90 b/src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90 index 91bf8b09d1..0b9d461af1 100644 --- a/src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90 +++ b/src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90 @@ -30,8 +30,9 @@ module SoilBiogeochemCarbonFluxType ! decomposition fluxes real(r8), pointer :: decomp_cpools_sourcesink_col (:,:,:) ! change in decomposing c pools. Used to update concentrations concurrently with vertical transport (gC/m3/timestep) - real(r8), pointer :: c_overflow_vr (:,:,:) ! vertically-resolved C rejected by microbes that cannot process it (gC/m3/s) - real(r8), pointer :: c_overflow (:,:) ! vertically-integrated C rejected by microbes that cannot process it (gC/m2/s) + real(r8), pointer :: c_overflow_hr_vr (:,:,:) ! vertically-resolved C rejected by microbes that cannot process it (gC/m3/s) (included in the heterotrophic respiration) + real(r8), pointer :: c_overflow_hr (:,:) ! vertically-integrated C rejected by microbes that cannot process it (gC/m2/s) (included in the heterotrophic respiration) + real(r8), pointer :: c_overflow_hr_sum (:) ! vertically-integrated and summed over all transitions, C rejected by microbes that cannot process it (gC/m2/s) (included in the heterotrophic respiration) real(r8), pointer :: decomp_cascade_hr_vr_col (:,:,:) ! vertically-resolved het. resp. from decomposing C pools (gC/m3/s) real(r8), pointer :: decomp_cascade_hr_col (:,:) ! vertically-integrated (diagnostic) het. resp. from decomposing C pools (gC/m2/s) real(r8), pointer :: decomp_cascade_ctransfer_vr_col (:,:,:) ! vertically-resolved C transferred along deomposition cascade (gC/m3/s) @@ -140,11 +141,14 @@ subroutine InitAllocate(this, bounds) allocate(this%decomp_cpools_sourcesink_col(begc:endc,1:nlevdecomp_full,1:ndecomp_pools)) this%decomp_cpools_sourcesink_col(:,:,:)= nan - allocate(this%c_overflow_vr(begc:endc,1:nlevdecomp_full,1:ndecomp_cascade_transitions)) - this%c_overflow_vr(:,:,:) = nan + allocate(this%c_overflow_hr_vr(begc:endc,1:nlevdecomp_full,1:ndecomp_cascade_transitions)) + this%c_overflow_hr_vr(:,:,:) = nan - allocate(this%c_overflow(begc:endc,1:ndecomp_cascade_transitions)) - this%c_overflow(:,:) = nan + allocate(this%c_overflow_hr(begc:endc,1:ndecomp_cascade_transitions)) + this%c_overflow_hr(:,:) = nan + + allocate(this%c_overflow_hr_sum(begc:endc)) + this%c_overflow_hr_sum(:) = nan allocate(this%decomp_cascade_hr_vr_col(begc:endc,1:nlevdecomp_full,1:ndecomp_cascade_transitions)) this%decomp_cascade_hr_vr_col(:,:,:)= spval @@ -268,6 +272,11 @@ subroutine InitHistory(this, bounds, carbon_type) ptr_col=this%hr_col) if (decomp_method == mimics_decomp) then + this%c_overflow_hr_sum(begc:endc) = spval + call hist_addfld1d (fname='COVERFLOW_HR_SUM', units='gC/m^2/s', & + avgflag='A', long_name='C overflow (already included in the heterotrophic respiration)', & + ptr_col=this%c_overflow_hr_sum) + this%michr_col(begc:endc) = spval call hist_addfld1d (fname='MICC_HR', units='gC/m^2/s', & avgflag='A', long_name='microbial C heterotrophic respiration: donor-pool based, so expect zero with MIMICS', & @@ -311,8 +320,8 @@ subroutine InitHistory(this, bounds, carbon_type) ptr_col=data2dptr, default='inactive') end do - this%c_overflow(begc:endc,:) = spval - this%c_overflow_vr(begc:endc,:,:) = spval + this%c_overflow_hr(begc:endc,:) = spval + this%c_overflow_hr_vr(begc:endc,:,:) = spval this%decomp_cascade_hr_col(begc:endc,:) = spval this%decomp_cascade_hr_vr_col(begc:endc,:,:) = spval this%decomp_cascade_ctransfer_col(begc:endc,:) = spval @@ -323,25 +332,27 @@ subroutine InitHistory(this, bounds, carbon_type) ! output the vertically integrated fluxes only as default !-- C overflow (ONLY c12 FOR NOW) - data1dptr => this%c_overflow(:,l) - ! check to see if there are multiple pathways that include respiration, and if so, note that in the history file - ii = 0 - do jj = 1, ndecomp_cascade_transitions - if ( decomp_cascade_con%cascade_donor_pool(jj) == decomp_cascade_con%cascade_donor_pool(l) ) ii = ii+1 - end do - if ( ii == 1 ) then - fieldname = & - trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'_COVERFLOW' - else - fieldname = & - trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'_COVERFLOW_'//& - trim(decomp_cascade_con%decomp_pool_name_short(decomp_cascade_con%cascade_receiver_pool(l))) - endif - longname = 'C overflow from '//& - trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l))) - call hist_addfld1d (fname=fieldname, units='gC/m^2/s', & - avgflag='A', long_name=longname, & - ptr_col=data1dptr, default='inactive') + if (decomp_method == mimics_decomp) then + data1dptr => this%c_overflow_hr(:,l) + ! check to see if there are multiple pathways that include respiration, and if so, note that in the history file + ii = 0 + do jj = 1, ndecomp_cascade_transitions + if ( decomp_cascade_con%cascade_donor_pool(jj) == decomp_cascade_con%cascade_donor_pool(l) ) ii = ii+1 + end do + if ( ii == 1 ) then + fieldname = & + trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'_COVERFLOW' + else + fieldname = & + trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'_COVERFLOW_'//& + trim(decomp_cascade_con%decomp_pool_name_short(decomp_cascade_con%cascade_receiver_pool(l))) + endif + longname = 'C overflow (already included in HR) from '//& + trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l))) + call hist_addfld1d (fname=fieldname, units='gC/m^2/s', & + avgflag='A', long_name=longname, & + ptr_col=data1dptr) + end if !-- HR fluxes data1dptr => this%decomp_cascade_hr_col(:,l) @@ -380,27 +391,29 @@ subroutine InitHistory(this, bounds, carbon_type) ! output the vertically resolved fluxes if ( nlevdecomp_full > 1 ) then !-- C overflow (ONLY c12 FOR NOW) - data2dptr => this%c_overflow_vr(:,:,l) - ! check to see if there are multiple pathways that include respiration, and if so, note that in the history file - ii = 0 - do jj = 1, ndecomp_cascade_transitions - if ( decomp_cascade_con%cascade_donor_pool(jj) == decomp_cascade_con%cascade_donor_pool(l) ) ii = ii+1 - end do - if ( ii == 1 ) then - fieldname = & - trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))& - //'_COVERFLOW'//trim(vr_suffix) - else - fieldname = & - trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'_COVERFLOW_'//& - trim(decomp_cascade_con%decomp_pool_name_short(decomp_cascade_con%cascade_receiver_pool(l)))& - //trim(vr_suffix) - endif - longname = 'C overflow from '//& - trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l))) - call hist_addfld_decomp (fname=fieldname, units='gC/m^3/s', type2d='levdcmp', & - avgflag='A', long_name=longname, & - ptr_col=data2dptr, default='inactive') + if (decomp_method == mimics_decomp) then + data2dptr => this%c_overflow_hr_vr(:,:,l) + ! check to see if there are multiple pathways that include respiration, and if so, note that in the history file + ii = 0 + do jj = 1, ndecomp_cascade_transitions + if ( decomp_cascade_con%cascade_donor_pool(jj) == decomp_cascade_con%cascade_donor_pool(l) ) ii = ii+1 + end do + if ( ii == 1 ) then + fieldname = & + trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))& + //'_COVERFLOW'//trim(vr_suffix) + else + fieldname = & + trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'_COVERFLOW_'//& + trim(decomp_cascade_con%decomp_pool_name_short(decomp_cascade_con%cascade_receiver_pool(l)))& + //trim(vr_suffix) + endif + longname = 'C overflow (already included in HR) from '//& + trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l))) + call hist_addfld_decomp (fname=fieldname, units='gC/m^3/s', type2d='levdcmp', & + avgflag='A', long_name=longname, & + ptr_col=data2dptr) + end if !-- HR fluxes data2dptr => this%decomp_cascade_hr_vr_col(:,:,l) @@ -781,8 +794,10 @@ subroutine SetValues ( this, num_column, filter_column, value_column) do j = 1, nlevdecomp_full do fi = 1,num_column i = filter_column(fi) + this%c_overflow_hr_sum(i) = value_column + this%c_overflow_hr(i,l) = value_column + this%c_overflow_hr_vr(i,j,l) = value_column this%decomp_cascade_hr_col(i,l) = value_column - this%c_overflow_vr(i,j,l) = value_column this%decomp_cascade_hr_vr_col(i,j,l) = value_column this%decomp_cascade_ctransfer_col(i,l) = value_column this%decomp_cascade_ctransfer_vr_col(i,j,l) = value_column @@ -900,6 +915,10 @@ subroutine Summary(this, bounds, & do j = 1,nlevdecomp do fc = 1,num_bgc_soilc c = filter_bgc_soilc(fc) + this%c_overflow_hr(c,k) = & + this%c_overflow_hr(c,k) + & + this%c_overflow_hr_vr(c,j,k) * dzsoi_decomp(j) + this%decomp_cascade_hr_col(c,k) = & this%decomp_cascade_hr_col(c,k) + & this%decomp_cascade_hr_vr_col(c,j,k) * dzsoi_decomp(j) @@ -948,13 +967,14 @@ subroutine Summary(this, bounds, & end do end do - ! soil organic matter heterotrophic respiration + ! soil organic matter heterotrophic respiration associate(is_soil => decomp_cascade_con%is_soil) ! TRUE => pool is a soil pool do k = 1, ndecomp_cascade_transitions if ( is_soil(decomp_cascade_con%cascade_donor_pool(k)) ) then do fc = 1,num_bgc_soilc c = filter_bgc_soilc(fc) this%somhr_col(c) = this%somhr_col(c) + this%decomp_cascade_hr_col(c,k) + this%c_overflow_hr_sum(c) = this%c_overflow_hr_sum(c) + this%c_overflow_hr(c,k) end do end if end do @@ -967,6 +987,7 @@ subroutine Summary(this, bounds, & do fc = 1,num_bgc_soilc c = filter_bgc_soilc(fc) this%lithr_col(c) = this%lithr_col(c) + this%decomp_cascade_hr_col(c,k) + this%c_overflow_hr_sum(c) = this%c_overflow_hr_sum(c) + this%c_overflow_hr(c,k) end do end if end do @@ -979,6 +1000,7 @@ subroutine Summary(this, bounds, & do fc = 1,num_bgc_soilc c = filter_bgc_soilc(fc) this%cwdhr_col(c) = this%cwdhr_col(c) + this%decomp_cascade_hr_col(c,k) + this%c_overflow_hr_sum(c) = this%c_overflow_hr_sum(c) + this%c_overflow_hr(c,k) end do end if end do @@ -991,6 +1013,7 @@ subroutine Summary(this, bounds, & do fc = 1,num_bgc_soilc c = filter_bgc_soilc(fc) this%michr_col(c) = this%michr_col(c) + this%decomp_cascade_hr_col(c,k) + this%c_overflow_hr_sum(c) = this%c_overflow_hr_sum(c) + this%c_overflow_hr(c,k) end do end if end do diff --git a/src/soilbiogeochem/SoilBiogeochemDecompMod.F90 b/src/soilbiogeochem/SoilBiogeochemDecompMod.F90 index 6be924bcf5..b63ac49837 100644 --- a/src/soilbiogeochem/SoilBiogeochemDecompMod.F90 +++ b/src/soilbiogeochem/SoilBiogeochemDecompMod.F90 @@ -127,7 +127,7 @@ subroutine SoilBiogeochemDecomp (bounds, num_bgc_soilc, filter_bgc_soilc, net_nmin => soilbiogeochem_nitrogenflux_inst%net_nmin_col , & ! Output: [real(r8) (:) ] net rate of N mineralization (gN/m2/s) w_scalar => soilbiogeochem_carbonflux_inst%w_scalar_col , & ! Input: [real(r8) (:,:) ] fraction by which decomposition is limited by moisture availability - c_overflow_vr => soilbiogeochem_carbonflux_inst%c_overflow_vr , & ! Input: [real(r8) (:,:,:) ] vertically-resolved C rejected by microbes that cannot process it (gC/m3/s) + c_overflow_hr_vr => soilbiogeochem_carbonflux_inst%c_overflow_hr_vr , & ! Input: [real(r8) (:,:,:) ] vertically-resolved C rejected by microbes that cannot process it (gC/m3/s) decomp_cascade_hr_vr => soilbiogeochem_carbonflux_inst%decomp_cascade_hr_vr_col , & ! Output: [real(r8) (:,:,:) ] vertically-resolved het. resp. from decomposing C pools (gC/m3/s) decomp_cascade_ctransfer_vr => soilbiogeochem_carbonflux_inst%decomp_cascade_ctransfer_vr_col , & ! Output: [real(r8) (:,:,:) ] vertically-resolved het. resp. from decomposing C pools (gC/m3/s) phr_vr => soilbiogeochem_carbonflux_inst%phr_vr_col , & ! Input: [real(r8) (:,:) ] potential HR (gC/m3/s) @@ -194,7 +194,7 @@ subroutine SoilBiogeochemDecomp (bounds, num_bgc_soilc, filter_bgc_soilc, if (decomp_method == mimics_decomp) then decomp_cascade_hr_vr(c,j,k) = min( & p_decomp_cpool_loss(c,j,k), & - decomp_cascade_hr_vr(c,j,k) + c_overflow_vr(c,j,k)) + decomp_cascade_hr_vr(c,j,k) + c_overflow_hr_vr(c,j,k)) decomp_cascade_ctransfer_vr(c,j,k) = max(0.0_r8, p_decomp_cpool_loss(c,j,k) - decomp_cascade_hr_vr(c,j,k)) end if if (decomp_npools_vr(c,j,cascade_donor_pool(k)) > 0._r8 .and. cascade_receiver_pool(k) /= i_atm) then diff --git a/src/soilbiogeochem/SoilBiogeochemPotentialMod.F90 b/src/soilbiogeochem/SoilBiogeochemPotentialMod.F90 index 38098f445f..044cad9115 100644 --- a/src/soilbiogeochem/SoilBiogeochemPotentialMod.F90 +++ b/src/soilbiogeochem/SoilBiogeochemPotentialMod.F90 @@ -130,7 +130,7 @@ subroutine SoilBiogeochemPotential (bounds, num_bgc_soilc, filter_bgc_soilc, & decomp_npools_vr => soilbiogeochem_nitrogenstate_inst%decomp_npools_vr_col , & ! Input: [real(r8) (:,:,:) ] (gC/m3) vertically-resolved decomposing (litter, cwd, soil) N pools decomp_cpools_vr => soilbiogeochem_carbonstate_inst%decomp_cpools_vr_col , & ! Input: [real(r8) (:,:,:) ] (gC/m3) vertically-resolved decomposing (litter, cwd, soil) c pools - c_overflow_vr => soilbiogeochem_carbonflux_inst%c_overflow_vr , & ! Output: [real(r8) (:,:,:)] (gC/m3/s) vertically-resolved C rejected by microbes that cannot process it + c_overflow_hr_vr => soilbiogeochem_carbonflux_inst%c_overflow_hr_vr , & ! Output: [real(r8) (:,:,:)] (gC/m3/s) vertically-resolved C rejected by microbes that cannot process it potential_immob_vr => soilbiogeochem_nitrogenflux_inst%potential_immob_vr_col , & ! Output: [real(r8) (:,:) ] gross_nmin_vr => soilbiogeochem_nitrogenflux_inst%gross_nmin_vr_col , & ! Output: [real(r8) (:,:) ] @@ -200,7 +200,7 @@ subroutine SoilBiogeochemPotential (bounds, num_bgc_soilc, filter_bgc_soilc, & endif else ! CWD -> litter OR mimics_decomp is true pmnf_decomp_cascade(c,j,k) = 0._r8 - c_overflow_vr(c,j,k) = 0._r8 + c_overflow_hr_vr(c,j,k) = 0._r8 if (decomp_method == mimics_decomp) then ! N:C ratio of donor pools (N:C instead of C:N because @@ -293,13 +293,13 @@ subroutine SoilBiogeochemPotential (bounds, num_bgc_soilc, filter_bgc_soilc, & ! TODO may need to think about how we track actual immobilization fluxes too? if (p_decomp_cn_diff_ratio <= 0._r8) then pmnf_decomp_cascade(c,j,k) = p_decomp_cn_diff_ratio * p_decomp_npool_gain(c,j,k) - c_overflow_vr(c,j,k) = 0.0_r8 + c_overflow_hr_vr(c,j,k) = 0.0_r8 else ! Assumes each flux into MIC must be in stoichiometric ballance ! Could also sum at all C fluxes into MIC and then maintain stoichiometry pmnf_decomp_cascade(c,j,k) = 0._r8 adjusted_c_to_mic = p_decomp_npool_gain(c,j,k) * cn_col(c,cascade_receiver_pool(k)) - c_overflow_vr(c,j,k) = p_decomp_cpool_gain(c,j,k) - adjusted_c_to_mic + c_overflow_hr_vr(c,j,k) = p_decomp_cpool_gain(c,j,k) - adjusted_c_to_mic end if end if ! donors donating (decomp_cpools_vr & decomp_k > 0) end if ! microbes receiving