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

Get FATES and carbon_only test-suite tests to pass with MIMICS active #1643

Merged
merged 30 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d5c1ed5
Changes to get FATES and carbon_only tests pass with MIMICS active
slevis-lmwg Feb 9, 2022
28a0406
Access the FATES copy of annsum_npp in FATES-MIMICS simulations
slevis-lmwg Feb 14, 2022
a16cc85
Calc. ligninNratioAvg(c) from values by pft when use_fates = .true.
slevis-lmwg Feb 14, 2022
41802c2
Check that FATES-MIMICS cases set use_lch4 = .true., else fail
slevis-lmwg Feb 15, 2022
bea8e4a
Replaced if-statement with select case statement as per EK's review
slevis-lmwg Feb 25, 2022
88308bd
Merge remote-tracking branch 'escomp/master' into ligninNratio_forfates
slevis-lmwg Feb 25, 2022
c0747af
Get select case statmt to compile by changing case options to constants
slevis-lmwg Feb 25, 2022
098e86f
Update Fates testmod to run w MIMICS. First draft of ChangeLog updates.
slevis-lmwg Feb 26, 2022
86d18b2
Update ChangeLog with test-suite results
slevis-lmwg Feb 26, 2022
e52992c
Error check in the fortran to ensure MIMICS-FATES sets use_lch4 = .true.
slevis-lmwg Mar 13, 2022
d95a716
Reverted my mods to FATES test and added new FATES test
slevis-lmwg Mar 13, 2022
a8057f9
Update ChangeLog about my mods to the tests (see previous commit)
slevis-lmwg Mar 13, 2022
0438304
Added fates_and_lch4_if: construct around if statement for clarity
slevis-lmwg Mar 18, 2022
ffa084a
Made the fates_and_lch4_if into nested if statements for clearer code
slevis-lmwg Apr 4, 2022
8bf3153
Merge remote-tracking branch 'escomp/master' into ligninNratio_forfates
slevis-lmwg Apr 25, 2022
50f4af3
Update FATES-MIMICS to use FATES copy of ligninNratio
slevis-lmwg Apr 25, 2022
922aaf2
Revert a testmod change I had made for testing FATES-MIMICS
slevis-lmwg Apr 25, 2022
dd24018
Corrected to receive FATES variable litt_flux_ligc_per_n as site level
slevis-lmwg Apr 26, 2022
cd42ddf
Consolidating ligninNratioAvg var from cnveg_carbonflux to ...
slevis-lmwg Apr 27, 2022
eadb090
Update ChangeLog
slevis-lmwg Apr 27, 2022
f704b40
Update ChangeSum
slevis-lmwg Apr 27, 2022
c4708e9
Update comments about microbial C heterotrophic resp. per @wwieder
slevis-lmwg Apr 27, 2022
79a4ec3
Corrections needed for failing tests to pass
slevis-lmwg Apr 27, 2022
1a4bb3f
Fix for restart test that wasn't passing
slevis-lmwg Apr 28, 2022
e5c0d80
Make my restart-fix workaround thread-safe
slevis-lmwg Apr 29, 2022
6794fa3
Updates to get threaded test to PASS
slevis-lmwg Apr 30, 2022
392d047
Merge tag 'ctsm5.1.dev092' into ligninNratio_forfates
slevis-lmwg Apr 30, 2022
611fb16
Make copy_fates_var local to clmfates_interface module
slevis-lmwg May 3, 2022
08f3a3c
The new test added with this PR now also tests threading
slevis-lmwg May 3, 2022
28acc2f
Update date on changelog add description of issue
ekluzek May 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/biogeochem/CNDriverMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ subroutine CNDriverNoLeaching(bounds,
soilstate_inst, temperature_inst, ch4_inst, soilbiogeochem_carbonflux_inst)
else if (decomp_method == mimics_decomp) then
call decomp_rates_mimics(bounds, num_soilc, filter_soilc, &
num_soilp, filter_soilp, &
soilstate_inst, temperature_inst, cnveg_carbonflux_inst, ch4_inst, &
soilbiogeochem_carbonflux_inst, soilbiogeochem_carbonstate_inst)
end if
Expand Down
1 change: 1 addition & 0 deletions src/biogeochem/EDBGCDynMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ subroutine EDBGCDyn(bounds, &
soilstate_inst, temperature_inst, ch4_inst, soilbiogeochem_carbonflux_inst)
else if (decomp_method == mimics_decomp) then
call decomp_rates_mimics(bounds, num_soilc, filter_soilc, &
num_soilp, filter_soilp, &
soilstate_inst, temperature_inst, cnveg_carbonflux_inst, ch4_inst, &
soilbiogeochem_carbonflux_inst, soilbiogeochem_carbonstate_inst)
end if
Expand Down
70 changes: 65 additions & 5 deletions src/soilbiogeochem/SoilBiogeochemDecompCascadeMIMICSMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ end subroutine init_decompcascade_mimics

!-----------------------------------------------------------------------
subroutine decomp_rates_mimics(bounds, num_soilc, filter_soilc, &
num_soilp, filter_soilp, &
soilstate_inst, temperature_inst, cnveg_carbonflux_inst, &
ch4_inst, soilbiogeochem_carbonflux_inst, soilbiogeochem_carbonstate_inst)
!
Expand All @@ -763,9 +764,12 @@ subroutine decomp_rates_mimics(bounds, num_soilc, filter_soilc, &
use clm_time_manager , only : get_curr_days_per_year
use clm_varcon , only : secspday, secsphr, tfrz
use clm_varcon , only : g_to_mg, cm3_to_m3
use clm_varctl , only : cnallocate_carbon_only
!
! !ARGUMENTS:
type(bounds_type) , intent(in) :: bounds
integer , intent(in) :: num_soilp ! number of soil patches in filter
integer , intent(in) :: filter_soilp(:) ! filter for soil patches
integer , intent(in) :: num_soilc ! number of soil columns in filter
integer , intent(in) :: filter_soilc(:) ! filter for soil columns
type(soilstate_type) , intent(in) :: soilstate_inst
Expand Down Expand Up @@ -846,13 +850,17 @@ subroutine decomp_rates_mimics(bounds, num_soilc, filter_soilc, &
real(r8):: spinup_geogterm_s3(bounds%begc:bounds%endc) ! geographically-varying spinup term for s3
real(r8):: spinup_geogterm_m1(bounds%begc:bounds%endc) ! geographically-varying spinup term for m1
real(r8):: spinup_geogterm_m2(bounds%begc:bounds%endc) ! geographically-varying spinup term for m2
real(r8):: ligninNratioAvg_local(bounds%begc:bounds%endc) ! local column-level lignin to nitrogen ratio
real(r8):: annsum_npp_col_local(bounds%begc:bounds%endc) ! local annual sum of NPP at the column level
real(r8):: ligninNratio(bounds%begp:bounds%endp) ! local patch-level lignin to nitrogen ratio
real(r8):: annsum_npp(bounds%begp:bounds%endp) ! local annual sum of NPP at the patch level
integer :: counter(bounds%begc:bounds%endc) ! local counter in loop
real(r8):: ligninNratioAvg_scalar ! lignin to nitrogen ratio, scalar in column-level loop
real(r8):: annsum_npp_col_scalar ! annual sum of NPP, scalar in column-level loop

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

associate( &
ligninNratioAvg => cnveg_carbonflux_inst%ligninNratioAvg_col , & ! Input: [real(r8) (:) ] column-level lignin to nitrogen ratio
annsum_npp_col => cnveg_carbonflux_inst%annsum_npp_col , & ! Input: [real(r8) (:) ] annual sum of NPP at the column level (gC/m2/yr)

rf_cwdl2 => CNParamsShareInst%rf_cwdl2 , & ! Input: [real(r8) ] respiration fraction in CWD to litter2 transition (frac)
minpsi => CNParamsShareInst%minpsi , & ! Input: [real(r8) ] minimum soil suction (mm)
maxpsi => CNParamsShareInst%maxpsi , & ! Input: [real(r8) ] maximum soil suction (mm)
Expand Down Expand Up @@ -1100,21 +1108,73 @@ subroutine decomp_rates_mimics(bounds, num_soilc, filter_soilc, &
mimics_cn_r = params_inst%mimics_cn_r
mimics_cn_k = params_inst%mimics_cn_k

! Local column-level ligninNratioAvg and annsum_npp_col because these are
! not available when use_fates = .true. or when carbon_only = .true.
if (use_fates .or. cnallocate_carbon_only()) then
! Initialize
do fc = 1,num_soilc
c = filter_soilc(fc)
ligninNratioAvg_local(c) = 0._r8
annsum_npp_col_local(c) = 0._r8
counter(c) = 0
end do

! Sum over p
! TODO Not tested, yet
! do fp = 1, num_soilp

! p = filter_soilp(fp)
! c = patch%column(p)

! TODO Obtain values by pft from
! https://bg.copernicus.org/articles/9/565/2012/bg-9-565-2012.pdf
! TODO Move values by pft to the params files?
! if (patch%itype(p) = noveg) then
! ligninNratio(p) = 0._r8
! annsum_npp(p) = 0._r8
! else if (patch%itype(p) = nbrdlf_evr_trp_tree) then
! ligninNratio(p) =
! annsum_npp(p) =
! else if (patch%itype(p) = ...
! end if

! ligninNratioAvg_local(c) = ligninNratio(p) * patch%wtcol(p) + ligninNratioAvg_local(c)
! annsum_npp_col_local(c) = annsum_npp(p) * patch%wtcol(p) + annsum_npp_col_local(c)
! counter(c) = counter(c) + 1

! end do ! p loop

! Calculate the column-level averages
! do fc = 1,num_soilc
! c = filter_soilc(fc)
! ligninNratioAvg_local(c) = ligninNratioAvg_local(c) / counter(c)
! annsum_npp_col_local(c) = annsum_npp_col_local(c) / counter(c)
! end do
end if ! use_fates or carbon_only

! calculate rates for all litter and som pools
do fc = 1,num_soilc
c = filter_soilc(fc)

if (use_fates .or. cnallocate_carbon_only()) then
ligninNratioAvg_scalar = ligninNratioAvg_local(c)
annsum_npp_col_scalar = annsum_npp_col_local(c)
else
ligninNratioAvg_scalar = cnveg_carbonflux_inst%ligninNratioAvg_col(c)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was tracking down how mimics w/o fates arrives at this column level cnveg_carbonflux_inst%ligninNratioAvg_col(c)

Which took me here:

https://github.com/ESCOMP/CTSM/blob/master/src/biogeochem/CNVegCarbonFluxType.F90#L4498-L4503

It looks like its taking an average of the leaf, fineroot and cwd pools. But I was expecting that the terms ligninNratio_leaf_col(c), ligninNratio_froot_col(c) and ligninNratio_cwd would all be multiplied by their respective carbon weighting factors (ie leafc_to_litter_col, etc) before being divided through by the sum of those factors. I probably missed something though, maybe they already are, or I don't understand the units.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I understand it now, looking here at the leaf term:
https://github.com/ESCOMP/CTSM/blob/master/src/biogeochem/CNVegCarbonFluxType.F90#L4422-L4424
I see that it is pre-multiplied by leafc_to_litter_patch(p).
Alright, I see no issue.

Copy link
Collaborator

@rgknox rgknox Mar 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, I really think there should be units for the definition of the column level average, it wasn't clear to me exactly what this ratio is. It is defined here:

https://github.com/ESCOMP/CTSM/blob/master/src/biogeochem/CNVegCarbonFluxType.F90#L338

And I think it should have the same units as the multiple of these two factors (using leaf as a guide):

real(r8), allocatable :: lf_flig (:) ! leaf litter lignin fraction
real(r8), allocatable :: lflitcn (:) ! leaf litter C:N (gC/gN)

So it seems like this column level average is the mean C:N ratio of lignin tissues from leaves, fine-roots and cwd in the column. [gC/gN]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for diving in here @rgknox. @slevisconsulting maybe some additional comments in the code are warranted to clarify what's going on?

annsum_npp_col_scalar = cnveg_carbonflux_inst%annsum_npp_col(c)
end if

! Time-dependent params from Wieder et al. 2015 & testbed code

! Set limits on Lignin:N to keep fmet > 0.2
! Necessary for litter quality in boreal forests with high cwd flux
! TODO Check for high-freq variations in ligninNratioAvg. To avoid,
! replace pool_to_litter terms with ann or other long term mean
! in CNVegCarbonFluxType.
fmet = mimics_fmet_p1 * (mimics_fmet_p2 - mimics_fmet_p3 * min(mimics_fmet_p4, ligninNratioAvg(c)))
fmet = mimics_fmet_p1 * (mimics_fmet_p2 - mimics_fmet_p3 * min(mimics_fmet_p4, ligninNratioAvg_scalar))
tau_mod = min(mimics_tau_mod_max, max(mimics_tau_mod_min, &
sqrt(mimics_tau_mod_factor * &
annsum_npp_col(c))))
annsum_npp_col_scalar)))

! tau_m1 is tauR and tau_m2 is tauK in Wieder et al. 2015
! tau ends up in units of per hour but is expected
Expand Down