From f2869fe202f71c4fd8c854fce47089630b4396c5 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Sun, 18 Aug 2019 20:19:42 -0600 Subject: [PATCH] Fix for #787 from the clm5_shiftingcultivation branch --- src/biogeochem/CNVegCarbonFluxType.F90 | 63 +++++++++++++++------- src/biogeochem/dynConsBiogeochemMod.F90 | 69 ++++++++++++++----------- 2 files changed, 83 insertions(+), 49 deletions(-) diff --git a/src/biogeochem/CNVegCarbonFluxType.F90 b/src/biogeochem/CNVegCarbonFluxType.F90 index 079813d2a3..48b15e3f6d 100644 --- a/src/biogeochem/CNVegCarbonFluxType.F90 +++ b/src/biogeochem/CNVegCarbonFluxType.F90 @@ -263,7 +263,8 @@ module CNVegCarbonFluxType real(r8), pointer :: dwt_conv_cflux_dribbled_grc (:) ! (gC/m2/s) dwt_conv_cflux_grc dribbled evenly throughout the year real(r8), pointer :: dwt_wood_productc_gain_patch (:) ! (gC/m2/s) addition to wood product pools from landcover change; although this is a patch-level flux, it is expressed per unit GRIDCELL area real(r8), pointer :: dwt_crop_productc_gain_patch (:) ! (gC/m2/s) addition to crop product pools from landcover change; although this is a patch-level flux, it is expressed per unit GRIDCELL area - real(r8), pointer :: dwt_slash_cflux_col (:) ! (gC/m2/s) conversion slash flux due to landcover change + real(r8), pointer :: dwt_slash_cflux_patch (:) ! (gC/m2/s) conversion slash flux due to landcover change + real(r8), pointer :: dwt_slash_cflux_grc (:) ! (gC/m2/s) dwt_slash_cflux_patch summed to the gridcell-level real(r8), pointer :: dwt_frootc_to_litr_met_c_col (:,:) ! (gC/m3/s) fine root to litter due to landcover change real(r8), pointer :: dwt_frootc_to_litr_cel_c_col (:,:) ! (gC/m3/s) fine root to litter due to landcover change real(r8), pointer :: dwt_frootc_to_litr_lig_c_col (:,:) ! (gC/m3/s) fine root to litter due to landcover change @@ -629,7 +630,8 @@ subroutine InitAllocate(this, bounds, carbon_type) allocate(this%harvest_c_to_litr_lig_c_col (begc:endc,1:nlevdecomp_full)); this%harvest_c_to_litr_lig_c_col (:,:)=nan allocate(this%harvest_c_to_cwdc_col (begc:endc,1:nlevdecomp_full)); this%harvest_c_to_cwdc_col (:,:)=nan - allocate(this%dwt_slash_cflux_col (begc:endc)) ; this%dwt_slash_cflux_col (:) =nan + allocate(this%dwt_slash_cflux_patch (begp:endp)) ; this%dwt_slash_cflux_patch (:) =nan + allocate(this%dwt_slash_cflux_grc (begg:endg)) ; this%dwt_slash_cflux_grc (:) =nan allocate(this%dwt_frootc_to_litr_met_c_col (begc:endc,1:nlevdecomp_full)); this%dwt_frootc_to_litr_met_c_col (:,:)=nan allocate(this%dwt_frootc_to_litr_cel_c_col (begc:endc,1:nlevdecomp_full)); this%dwt_frootc_to_litr_cel_c_col (:,:)=nan allocate(this%dwt_frootc_to_litr_lig_c_col (begc:endc,1:nlevdecomp_full)); this%dwt_frootc_to_litr_lig_c_col (:,:)=nan @@ -2876,10 +2878,19 @@ subroutine InitHistory(this, bounds, carbon_type) '(per-area-gridcell; only makes sense with dov2xy=.false.)', & ptr_patch=this%dwt_wood_productc_gain_patch, default='inactive') - this%dwt_slash_cflux_col(begc:endc) = spval - call hist_addfld1d (fname='DWT_SLASH_CFLUX', units='gC/m^2/s', & - avgflag='A', long_name='slash C flux to litter and CWD due to land use', & - ptr_col=this%dwt_slash_cflux_col) + this%dwt_slash_cflux_grc(begg:endg) = spval + call hist_addfld1d (fname='DWT_SLASH_CFLUX', units='gC/m^2/s', & + avgflag='A', & + long_name='slash C flux (to litter diagnostic only) (0 at all times except first timestep of year)', & + ptr_gcell=this%dwt_slash_cflux_grc) + + this%dwt_slash_cflux_patch(begp:endp) = spval + call hist_addfld1d (fname='DWT_SLASH_CFLUX_PATCH', units='gC/m^2/s', & + avgflag='A', & + long_name='patch-level slash C flux (to litter diagnostic only) ' // & + '(0 at all times except first timestep of year) ' // & + '(per-area-gridcell; only makes sense with dov2xy=.false.)', & + ptr_patch=this%dwt_slash_cflux_patch, default='inactive') this%dwt_frootc_to_litr_met_c_col(begc:endc,:) = spval call hist_addfld_decomp (fname='DWT_FROOTC_TO_LITR_MET_C', units='gC/m^2/s', type2d='levdcmp', & @@ -3050,10 +3061,19 @@ subroutine InitHistory(this, bounds, carbon_type) long_name='C13 conversion C flux (immediate loss to atm), dribbled throughout the year', & ptr_gcell=this%dwt_conv_cflux_dribbled_grc, default='inactive') - this%dwt_slash_cflux_col(begc:endc) = spval - call hist_addfld1d (fname='C13_DWT_SLASH_CFLUX', units='gC/m^2/s', & - avgflag='A', long_name='C13 slash C flux to litter and CWD due to land use', & - ptr_col=this%dwt_slash_cflux_col, default='inactive') + this%dwt_slash_cflux_grc(begg:endg) = spval + call hist_addfld1d (fname='C13_DWT_SLASH_CFLUX', units='gC13/m^2/s', & + avgflag='A', long_name='C13 slash C flux (to litter diagnostic only)' // & + '(0 at all times except first timestep of year)', & + ptr_gcell=this%dwt_slash_cflux_grc, default='inactive') + + this%dwt_slash_cflux_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_DWT_SLASH_CFLUX_PATCH', units='gC13/m^2/s', & + avgflag='A', & + long_name='patch-level C13 slash C flux (to litter diagnostic only) ' // & + '(0 at all times except first timestep of year) ' // & + '(per-area-gridcell; only makes sense with dov2xy=.false.)', & + ptr_patch=this%dwt_slash_cflux_patch, default='inactive') this%dwt_frootc_to_litr_met_c_col(begc:endc,:) = spval call hist_addfld_decomp (fname='C13_DWT_FROOTC_TO_LITR_MET_C', units='gC13/m^2/s', type2d='levdcmp', & @@ -3206,10 +3226,19 @@ subroutine InitHistory(this, bounds, carbon_type) long_name='C14 conversion C flux (immediate loss to atm), dribbled throughout the year', & ptr_gcell=this%dwt_conv_cflux_dribbled_grc, default='inactive') - this%dwt_slash_cflux_col(begc:endc) = spval - call hist_addfld1d (fname='C14_DWT_SLASH_CFLUX', units='gC/m^2/s', & - avgflag='A', long_name='C14 slash C flux to litter and CWD due to land use', & - ptr_col=this%dwt_slash_cflux_col, default='inactive') + this%dwt_slash_cflux_grc(begg:endg) = spval + call hist_addfld1d (fname='C14_DWT_SLASH_CFLUX', units='gC14/m^2/s', & + avgflag='A', long_name='C14 slash C flux (to litter diagnostic only)' // & + '(0 at all times except first timestep of year)', & + ptr_gcell=this%dwt_slash_cflux_grc, default='inactive') + + this%dwt_slash_cflux_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_DWT_SLASH_CFLUX_PATCH', units='gC14/m^2/s', & + avgflag='A', & + long_name='patch-level C14 slash C flux (to litter diagnostic only)' // & + '(0 at all times except first timestep of year) ' // & + '(per-area-gridcell; only makes sense with dov2xy=.false.)', & + ptr_patch=this%dwt_slash_cflux_patch, default='inactive') this%dwt_frootc_to_litr_met_c_col(begc:endc,:) = spval call hist_addfld_decomp (fname='C14_DWT_FROOTC_TO_LITR_MET_C', units='gC14/m^2/s', type2d='levdcmp', & @@ -3364,7 +3393,6 @@ subroutine InitCold(this, bounds) ! also initialize dynamic landcover fluxes so that they have ! real values on first timestep, prior to calling pftdyn_cnbal if (lun%itype(l) == istsoil .or. lun%itype(l) == istcrop) then - this%dwt_slash_cflux_col(c) = 0._r8 do j = 1, nlevdecomp_full this%dwt_frootc_to_litr_met_c_col(c,j) = 0._r8 this%dwt_frootc_to_litr_cel_c_col(c,j) = 0._r8 @@ -3965,10 +3993,7 @@ subroutine ZeroDwt( this, bounds ) this%dwt_seedc_to_leaf_grc(g) = 0._r8 this%dwt_seedc_to_deadstem_grc(g) = 0._r8 this%dwt_conv_cflux_grc(g) = 0._r8 - end do - - do c = bounds%begc,bounds%endc - this%dwt_slash_cflux_col(c) = 0._r8 + this%dwt_slash_cflux_grc(g) = 0._r8 end do do j = 1, nlevdecomp_full diff --git a/src/biogeochem/dynConsBiogeochemMod.F90 b/src/biogeochem/dynConsBiogeochemMod.F90 index 1199f99e93..eee632daef 100644 --- a/src/biogeochem/dynConsBiogeochemMod.F90 +++ b/src/biogeochem/dynConsBiogeochemMod.F90 @@ -587,36 +587,6 @@ subroutine dyn_cnbal_patch(bounds, & end do - ! calculate patch-to-column slash fluxes into litter and CWD pools - do p = bounds%begp, bounds%endp - c = patch%column(p) - - ! fine and coarse root to litter and CWD slash carbon fluxes - cnveg_carbonflux_inst%dwt_slash_cflux_col(c) = & - cnveg_carbonflux_inst%dwt_slash_cflux_col(c) + & - dwt_frootc_to_litter(p)/dt + & - dwt_livecrootc_to_litter(p)/dt + & - dwt_deadcrootc_to_litter(p)/dt - - if ( use_c13 ) then - c13_cnveg_carbonflux_inst%dwt_slash_cflux_col(c) = & - c13_cnveg_carbonflux_inst%dwt_slash_cflux_col(c) + & - dwt_frootc13_to_litter(p)/dt + & - dwt_livecrootc13_to_litter(p)/dt + & - dwt_deadcrootc13_to_litter(p)/dt - endif - - if ( use_c14 ) then - c14_cnveg_carbonflux_inst%dwt_slash_cflux_col(c) = & - c14_cnveg_carbonflux_inst%dwt_slash_cflux_col(c) + & - dwt_frootc14_to_litter(p)/dt + & - dwt_livecrootc14_to_litter(p)/dt + & - dwt_deadcrootc14_to_litter(p)/dt - endif - - end do - - ! calculate patch-to-column for fluxes into litter and CWD pools do j = 1, nlevdecomp do p = bounds%begp, bounds%endp @@ -787,6 +757,45 @@ subroutine dyn_cnbal_patch(bounds, & end do + ! calculate patch-to-gridcell slash fluxes into litter and CWD pools + ! Note that patch-level fluxes are stored per unit GRIDCELL area - thus, we don't + ! need to multiply by the patch's gridcell weight when translating patch-level + ! fluxes into gridcell-level fluxes. + + do p = bounds%begp, bounds%endp + g = patch%gridcell(p) + + ! fine and coarse root to litter and CWD slash carbon fluxes + cnveg_carbonflux_inst%dwt_slash_cflux_patch(p) = & + dwt_frootc_to_litter(p)/dt + & + dwt_livecrootc_to_litter(p)/dt + & + dwt_deadcrootc_to_litter(p)/dt + cnveg_carbonflux_inst%dwt_slash_cflux_grc(g) = & + cnveg_carbonflux_inst%dwt_slash_cflux_grc(g) + & + cnveg_carbonflux_inst%dwt_slash_cflux_patch(p) + + if ( use_c13 ) then + c13_cnveg_carbonflux_inst%dwt_slash_cflux_patch(p) = & + dwt_frootc13_to_litter(p)/dt + & + dwt_livecrootc13_to_litter(p)/dt + & + dwt_deadcrootc13_to_litter(p)/dt + c13_cnveg_carbonflux_inst%dwt_slash_cflux_grc(g) = & + c13_cnveg_carbonflux_inst%dwt_slash_cflux_grc(g) + & + c13_cnveg_carbonflux_inst%dwt_slash_cflux_patch(p) + endif + + if ( use_c14 ) then + c14_cnveg_carbonflux_inst%dwt_slash_cflux_patch(p) = & + dwt_frootc14_to_litter(p)/dt + & + dwt_livecrootc14_to_litter(p)/dt + & + dwt_deadcrootc14_to_litter(p)/dt + c14_cnveg_carbonflux_inst%dwt_slash_cflux_grc(g) = & + c14_cnveg_carbonflux_inst%dwt_slash_cflux_grc(g) + & + c14_cnveg_carbonflux_inst%dwt_slash_cflux_patch(p) + endif + + end do + ! Deallocate patch-level flux arrays deallocate(dwt) deallocate(dwt_leafc_seed)