Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-fates integration preparations #1519

Merged
merged 7 commits into from
May 12, 2017
71 changes: 55 additions & 16 deletions components/clm/src/biogeochem/CNCStateUpdate1Mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module CNCStateUpdate1Mod
use PatchType , only : pft
use clm_varctl , only : nu_com
! bgc interface & pflotran:
use clm_varctl , only : use_pflotran, pf_cmode
use clm_varctl , only : use_pflotran, pf_cmode, use_ed
!
implicit none
save
Expand Down Expand Up @@ -122,12 +122,14 @@ subroutine CStateUpdate1(bounds, &

! column level fluxes

do fc = 1,num_soilc
c = filter_soilc(fc)
! seeding fluxes, from dynamic landcover
cs%seedc_col(c) = cs%seedc_col(c) - cf%dwt_seedc_to_leaf_col(c) * dt
cs%seedc_col(c) = cs%seedc_col(c) - cf%dwt_seedc_to_deadstem_col(c) * dt
end do
if(.not.use_ed) then
do fc = 1,num_soilc
c = filter_soilc(fc)
! seeding fluxes, from dynamic landcover
cs%seedc_col(c) = cs%seedc_col(c) - cf%dwt_seedc_to_leaf_col(c) * dt
cs%seedc_col(c) = cs%seedc_col(c) - cf%dwt_seedc_to_deadstem_col(c) * dt
end do
end if


if (is_active_betr_bgc) then
Expand All @@ -149,7 +151,7 @@ subroutine CStateUpdate1(bounds, &
enddo
enddo

elseif (.not.(use_pflotran .and. pf_cmode)) then
elseif (.not.(use_pflotran .and. pf_cmode) .and. .not.use_ed ) then

! plant to litter fluxes

Expand Down Expand Up @@ -194,8 +196,43 @@ subroutine CStateUpdate1(bounds, &
end do
end if
end do
endif !end if is_active_betr_bgc()

elseif( use_ed ) then

! The following pools were updated via the FATES interface
! cf%decomp_cpools_sourcesink_col(c,j,i_met_lit)
! cf%decomp_cpools_sourcesink_col(c,j,i_cel_lit)
! cf%decomp_cpools_sourcesink_col(c,j,i_lig_lit)

! litter and SOM HR fluxes
do k = 1, ndecomp_cascade_transitions
do j = 1,nlevdecomp
do fc = 1,num_soilc
c = filter_soilc(fc)
cf%decomp_cpools_sourcesink_col(c,j,cascade_donor_pool(k)) = &
cf%decomp_cpools_sourcesink_col(c,j,cascade_donor_pool(k)) &
- ( cf%decomp_cascade_hr_vr_col(c,j,k) + cf%decomp_cascade_ctransfer_vr_col(c,j,k)) *dt
end do
end do
end do
do k = 1, ndecomp_cascade_transitions
if ( cascade_receiver_pool(k) /= 0 ) then ! skip terminal transitions
do j = 1,nlevdecomp
do fc = 1,num_soilc
c = filter_soilc(fc)
cf%decomp_cpools_sourcesink_col(c,j,cascade_receiver_pool(k)) = &
cf%decomp_cpools_sourcesink_col(c,j,cascade_receiver_pool(k)) &
+ cf%decomp_cascade_ctransfer_vr_col(c,j,k)*dt
end do
end do
end if
end do


endif !end if is_active_betr_bgc()


if (.not.use_ed) then

! patch loop
do fp = 1,num_soilp
Expand Down Expand Up @@ -384,16 +421,18 @@ subroutine CStateUpdate1(bounds, &

end do ! end of patch loop

if(is_active_betr_bgc)then

!the following is introduced to fix the spinup problem with simultaneous nitrogen competition
end if

call p2c(bounds, num_soilc, filter_soilc, &
if(is_active_betr_bgc)then

!the following is introduced to fix the spinup problem with simultaneous nitrogen competition

call p2c(bounds, num_soilc, filter_soilc, &
cs%frootc_patch(bounds%begp:bounds%endp), &
cnstate_vars%frootc_nfix_scalar_col(bounds%begc:bounds%endc))
endif
end associate
endif
end associate

end subroutine CStateUpdate1
end subroutine CStateUpdate1

end module CNCStateUpdate1Mod
6,136 changes: 3,079 additions & 3,057 deletions components/clm/src/biogeochem/CNCarbonFluxType.F90

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions components/clm/src/biogeochem/CNCarbonStateType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ module CNCarbonStateType
real(r8), pointer :: totpftc_col (:) ! (gC/m2) total patch-level carbon, including cpool averaged to column (p2c)
real(r8), pointer :: decomp_cpools_1m_col (:,:) ! col (gC/m2) Diagnostic: decomposing (litter, cwd, soil) c pools to 1 meter
real(r8), pointer :: decomp_cpools_col (:,:) ! col (gC/m2) decomposing (litter, cwd, soil) c pools

! (FATES-INTERF) cwdc_col is prevented from allocation in fates-clm
! waiting for discussion with cdk to determin its ... fate ... here
real(r8), pointer :: cwdc_col (:) ! col (gC/m2) Diagnostic: coarse woody debris C
real(r8), pointer :: ctrunc_col (:) ! col (gC/m2) column-level sink for C truncation
real(r8), pointer :: totlitc_col (:) ! col (gC/m2) total litter carbon
Expand Down
124 changes: 81 additions & 43 deletions components/clm/src/biogeochem/CNDecompCascadeBGCMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module CNDecompCascadeBGCMod
use shr_log_mod , only : errMsg => shr_log_errMsg
use clm_varpar , only : nlevsoi, nlevgrnd, nlevdecomp, ndecomp_cascade_transitions, ndecomp_pools
use clm_varpar , only : i_met_lit, i_cel_lit, i_lig_lit, i_cwd
use clm_varctl , only : iulog, spinup_state, anoxia, use_lch4, use_vertsoilc
use clm_varctl , only : iulog, spinup_state, anoxia, use_lch4, use_vertsoilc, use_ed
use clm_varcon , only : zsoi
use decompMod , only : bounds_type
use abortutils , only : endrun
Expand Down Expand Up @@ -428,23 +428,29 @@ subroutine init_decompcascade_bgc(bounds, cnstate_vars, soilstate_vars)
is_lignin (i_litr3) = .true.

! CWD
floating_cn_ratio_decomp_pools (i_cwd) = .true.
floating_cp_ratio_decomp_pools (i_cwd) = .true.
decomp_pool_name_restart (i_cwd) = 'cwd'
decomp_pool_name_history (i_cwd) = 'CWD'
decomp_pool_name_long (i_cwd) = 'coarse woody debris'
decomp_pool_name_short (i_cwd) = 'CWD'
is_litter (i_cwd) = .false.
is_soil (i_cwd) = .false.
is_cwd (i_cwd) = .true.
initial_cn_ratio (i_cwd) = 90._r8
initial_cp_ratio (i_cwd) = 900._r8
initial_stock (i_cwd) = 0._r8
is_metabolic (i_cwd) = .false.
is_cellulose (i_cwd) = .false.
is_lignin (i_cwd) = .false.

i_soil1 = 5
if (.not.use_ed) then
floating_cn_ratio_decomp_pools (i_cwd) = .true.
floating_cp_ratio_decomp_pools (i_cwd) = .true.
decomp_pool_name_restart (i_cwd) = 'cwd'
decomp_pool_name_history (i_cwd) = 'CWD'
decomp_pool_name_long (i_cwd) = 'coarse woody debris'
decomp_pool_name_short (i_cwd) = 'CWD'
is_litter (i_cwd) = .false.
is_soil (i_cwd) = .false.
is_cwd (i_cwd) = .true.
initial_cn_ratio (i_cwd) = 90._r8
initial_cp_ratio (i_cwd) = 900._r8
initial_stock (i_cwd) = 0._r8
is_metabolic (i_cwd) = .false.
is_cellulose (i_cwd) = .false.
is_lignin (i_cwd) = .false.
end if

if (.not. use_ed) then
i_soil1 = 5
else
i_soil1 = 4
endif
floating_cn_ratio_decomp_pools (i_soil1) = .false.
floating_cp_ratio_decomp_pools (i_soil1) = .true.
decomp_pool_name_restart (i_soil1) = 'soil1'
Expand All @@ -461,7 +467,11 @@ subroutine init_decompcascade_bgc(bounds, cnstate_vars, soilstate_vars)
is_cellulose (i_soil1) = .false.
is_lignin (i_soil1) = .false.

i_soil2 = 6
if (.not. use_ed) then
i_soil2 = 6
else
i_soil2 = 5
endif
floating_cn_ratio_decomp_pools (i_soil2) = .false.
floating_cp_ratio_decomp_pools (i_soil2) = .true.
decomp_pool_name_restart (i_soil2) = 'soil2'
Expand All @@ -478,7 +488,11 @@ subroutine init_decompcascade_bgc(bounds, cnstate_vars, soilstate_vars)
is_cellulose (i_soil2) = .false.
is_lignin (i_soil2) = .false.

i_soil3 = 7
if (.not. use_ed) then
i_soil3 = 7
else
i_soil3 = 6
endif
floating_cn_ratio_decomp_pools (i_soil3) = .false.
floating_cp_ratio_decomp_pools (i_soil3) = .true.
decomp_pool_name_restart (i_soil3) = 'soil3'
Expand All @@ -498,7 +512,10 @@ subroutine init_decompcascade_bgc(bounds, cnstate_vars, soilstate_vars)
spinup_factor(i_litr1) = 1._r8
spinup_factor(i_litr2) = 1._r8
spinup_factor(i_litr3) = 1._r8
spinup_factor(i_cwd) = 1._r8
!CWD
if (.not. use_ed) then
spinup_factor(i_cwd) = 1._r8
end if
spinup_factor(i_soil1) = CNDecompBgcParamsInst%spinup_vector(1)
spinup_factor(i_soil2) = CNDecompBgcParamsInst%spinup_vector(2)
spinup_factor(i_soil3) = CNDecompBgcParamsInst%spinup_vector(3)
Expand Down Expand Up @@ -561,19 +578,21 @@ subroutine init_decompcascade_bgc(bounds, cnstate_vars, soilstate_vars)
cascade_receiver_pool(i_s3s1) = i_soil1
pathfrac_decomp_cascade(bounds%begc:bounds%endc,1:nlevdecomp,i_s3s1) = 1.0_r8

i_cwdl2 = 9
cascade_step_name(i_cwdl2) = 'CWDL2'
rf_decomp_cascade(bounds%begc:bounds%endc,1:nlevdecomp,i_cwdl2) = rf_cwdl2
cascade_donor_pool(i_cwdl2) = i_cwd
cascade_receiver_pool(i_cwdl2) = i_litr2
pathfrac_decomp_cascade(bounds%begc:bounds%endc,1:nlevdecomp,i_cwdl2) = cwd_fcel

i_cwdl3 = 10
cascade_step_name(i_cwdl3) = 'CWDL3'
rf_decomp_cascade(bounds%begc:bounds%endc,1:nlevdecomp,i_cwdl3) = rf_cwdl3
cascade_donor_pool(i_cwdl3) = i_cwd
cascade_receiver_pool(i_cwdl3) = i_litr3
pathfrac_decomp_cascade(bounds%begc:bounds%endc,1:nlevdecomp,i_cwdl3) = cwd_flig
if (.not. use_ed) then
i_cwdl2 = 9
cascade_step_name(i_cwdl2) = 'CWDL2'
rf_decomp_cascade(bounds%begc:bounds%endc,1:nlevdecomp,i_cwdl2) = rf_cwdl2
cascade_donor_pool(i_cwdl2) = i_cwd
cascade_receiver_pool(i_cwdl2) = i_litr2
pathfrac_decomp_cascade(bounds%begc:bounds%endc,1:nlevdecomp,i_cwdl2) = cwd_fcel

i_cwdl3 = 10
cascade_step_name(i_cwdl3) = 'CWDL3'
rf_decomp_cascade(bounds%begc:bounds%endc,1:nlevdecomp,i_cwdl3) = rf_cwdl3
cascade_donor_pool(i_cwdl3) = i_cwd
cascade_receiver_pool(i_cwdl3) = i_litr3
pathfrac_decomp_cascade(bounds%begc:bounds%endc,1:nlevdecomp,i_cwdl3) = cwd_flig
end if

deallocate(rf_s1s2)
deallocate(rf_s1s3)
Expand Down Expand Up @@ -727,13 +746,18 @@ subroutine decomp_rate_constants_bgc(bounds, num_soilc, filter_soilc, &
k_s3 = k_s3 * CNDecompBgcParamsInst%spinup_vector(3)
endif

i_litr1 = 1
i_litr2 = 2
i_litr3 = 3
i_soil1 = 5
i_soil2 = 6
i_soil3 = 7

i_litr1 = 1
i_litr2 = 2
i_litr3 = 3
if (.not.use_ed) then
i_soil1 = 5
i_soil2 = 6
i_soil3 = 7
else
i_soil1 = 4
i_soil2 = 5
i_soil3 = 6
end if

!--- time dependent coefficients-----!
if ( nlevdecomp .eq. 1 ) then
Expand Down Expand Up @@ -976,25 +1000,39 @@ subroutine decomp_rate_constants_bgc(bounds, num_soilc, filter_soilc, &
decomp_k(c,j,i_litr1) = k_l1 * t_scalar(c,j) * w_scalar(c,j) * depth_scalar(c,j) * o_scalar(c,j)
decomp_k(c,j,i_litr2) = k_l2_l3 * t_scalar(c,j) * w_scalar(c,j) * depth_scalar(c,j) * o_scalar(c,j)
decomp_k(c,j,i_litr3) = k_l2_l3 * t_scalar(c,j) * w_scalar(c,j) * depth_scalar(c,j) * o_scalar(c,j)
decomp_k(c,j,i_cwd) = k_frag * t_scalar(c,j) * w_scalar(c,j) * depth_scalar(c,j) * o_scalar(c,j)
decomp_k(c,j,i_soil1) = k_s1 * t_scalar(c,j) * w_scalar(c,j) * depth_scalar(c,j) * o_scalar(c,j)
decomp_k(c,j,i_soil2) = k_s2 * t_scalar(c,j) * w_scalar(c,j) * depth_scalar(c,j) * o_scalar(c,j)
decomp_k(c,j,i_soil3) = k_s3 * t_scalar(c,j) * w_scalar(c,j) * depth_scalar(c,j) * o_scalar(c,j)
end do
end do
if (.not. use_ed) then
do j = 1,nlevdecomp
do fc = 1,num_soilc
c = filter_soilc(fc)
decomp_k(c,j,i_cwd) = k_frag * t_scalar(c,j) * w_scalar(c,j) * depth_scalar(c,j) * o_scalar(c,j)
end do
end do
end if
else
do j = 1,nlevdecomp
do fc = 1,num_soilc
c = filter_soilc(fc)
decomp_k(c,j,i_litr1) = k_l1 * t_scalar(c,j) * w_scalar(c,j) * o_scalar(c,j)
decomp_k(c,j,i_litr2) = k_l2_l3 * t_scalar(c,j) * w_scalar(c,j) * o_scalar(c,j)
decomp_k(c,j,i_litr3) = k_l2_l3 * t_scalar(c,j) * w_scalar(c,j) * o_scalar(c,j)
decomp_k(c,j,i_cwd) = k_frag * t_scalar(c,j) * w_scalar(c,j) * o_scalar(c,j)
decomp_k(c,j,i_soil1) = k_s1 * t_scalar(c,j) * w_scalar(c,j) * o_scalar(c,j)
decomp_k(c,j,i_soil2) = k_s2 * t_scalar(c,j) * w_scalar(c,j) * o_scalar(c,j)
decomp_k(c,j,i_soil3) = k_s3 * t_scalar(c,j) * w_scalar(c,j) * o_scalar(c,j)
end do
end do
if (.not. use_ed) then
do j = 1,nlevdecomp
do fc = 1,num_soilc
c = filter_soilc(fc)
decomp_k(c,j,i_cwd) = k_frag * t_scalar(c,j) * w_scalar(c,j) * o_scalar(c,j)
end do
end do
end if
end if

end associate
Expand Down
Loading