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

MIMICS into vertically resolved CTSM #1318

Merged
merged 80 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
9985a65
First commit of MIMICS in CTSM
slevis-lmwg Mar 27, 2021
131147e
Introduce MIMICS using SoilBiogeochemDecompCascadeBGCMod.F90 as template
slevis-lmwg Mar 31, 2021
d963ada
Updating SoilBiogeochemDecompCascadeMIMICSMod.F90 based on code review
slevis-lmwg Apr 2, 2021
5dd9ff2
Updating SoilBiogeochemDecompCascadeMIMICSMod.F90 based on meeting
slevis-lmwg Apr 3, 2021
8601f6e
Mainly changed "rate constants" to "rates" in the comments
slevis-lmwg Apr 13, 2021
0141a3e
Merge tag 'ctsm5.1.dev033' into vert_res_in_mimics
slevis-lmwg Apr 13, 2021
5995cc0
Add new and remove old TODO BFB refactor comments
slevis-lmwg Apr 14, 2021
e6833ea
Remove old TODO BFB refactor comment
slevis-lmwg Apr 14, 2021
446b587
Minor mods to ...DecompCascadeMIMICSMod based on refactor branch
slevis-lmwg Apr 18, 2021
32222a9
Merge tag 'ctsm5.1.dev043' into vert_res_in_mimics
slevis-lmwg Jun 4, 2021
2f67c21
Making ...CascadeMIMICSMod.F90 consistent w pre-MIMICS refactor
slevis-lmwg Jun 5, 2021
e962b0e
Ongoing work in SoilBiogeochemDecompCascadeMIMICSMod.F90
slevis-lmwg Jun 11, 2021
cda5d14
Merge tag 'ctsm5.1.dev048' into vert_res_in_mimics
slevis-lmwg Jul 11, 2021
487f5b3
Updates to MIMICSMod.F90 for consistency w corresponding BGC refactors
slevis-lmwg Jul 12, 2021
65d47da
Working on the tau calculations
slevis-lmwg Jul 12, 2021
39d51b6
Comment updates...
slevis-lmwg Jul 12, 2021
7662239
Updates from today's code review with @wwieder
slevis-lmwg Jul 14, 2021
0fde398
Updates based on new comments from @wwieder
slevis-lmwg Jul 15, 2021
030e9c5
Updates addressing comments in the PR
slevis-lmwg Jul 17, 2021
17fa68f
Minor updates
slevis-lmwg Jul 17, 2021
0860aa4
Rm unnecessary associate assignments as I look through the whole model
slevis-lmwg Jul 19, 2021
8715ec5
First draft of the ligninNratioAvg calculation
slevis-lmwg Jul 19, 2021
3ba4ad3
Made parameters of some two unit conversions
slevis-lmwg Jul 19, 2021
5222227
Working on the calculation of ligninNratioAve
slevis-lmwg Jul 22, 2021
ae3b11b
Closer to completing calculation of ligninNratioAve
slevis-lmwg Jul 23, 2021
d5d83e4
Some clean-up and corrections before starting on the nitrogen
slevis-lmwg Jul 23, 2021
0b91a02
Negligible changes but pushing to have access to latest during downtime
slevis-lmwg Jul 25, 2021
63cfa3d
Mods originally from @wwieder for the MIMICS nitrogen hooks
slevis-lmwg Aug 1, 2021
bf87bd3
Variable declarations and other loose ends from prev commit
slevis-lmwg Aug 5, 2021
3cf47eb
Adding use_mimics_decomp where needed in the fortran
slevis-lmwg Aug 6, 2021
043d8bc
Corrections and minor cleanup
slevis-lmwg Aug 7, 2021
ed35311
Code corrections from attempting to build (part 1)
slevis-lmwg Aug 9, 2021
fc2c33c
Merge tag 'ctsm5.1.dev051' into vert_res_in_mimics
slevis-lmwg Aug 9, 2021
ebadca9
Adding history variables for use with Newton-Krylov
slevis-lmwg Aug 9, 2021
5236864
Adding pathfrac_decomp_cascade to ctsm history
slevis-lmwg Aug 10, 2021
724cb82
Change to variable description as per code review suggestion
slevis-lmwg Aug 11, 2021
1f13e65
Code corrections from attempting to build (part 2)
slevis-lmwg Aug 12, 2021
dcf7689
Code corrections from attempting to build (part 3)
slevis-lmwg Aug 16, 2021
731475e
Merge branch 'hist_vars_for_newton_krylov' into vert_res_in_mimics
slevis-lmwg Aug 17, 2021
fefccc9
Code corrections from attempting to build (part 4)
slevis-lmwg Aug 18, 2021
dfe0688
Code corrections from attempting to build (part 5)
slevis-lmwg Aug 19, 2021
4e22c91
Adding rf_decomp_cascade to history
slevis-lmwg Aug 19, 2021
695f85c
Merge tag 'ctsm5.1.dev053' into hist_vars_for_newton_krylov
slevis-lmwg Aug 19, 2021
07c641b
user_nl_clm and shell_commands files for Newton-Krylov testing
slevis-lmwg Aug 21, 2021
2687cf1
Typo correction...
slevis-lmwg Aug 21, 2021
bae1162
Merge tag 'ctsm5.1.dev053' into vert_res_in_mimics
slevis-lmwg Aug 23, 2021
3033578
Merge branch 'hist_vars_for_newton_krylov' into vert_res_in_mimics
slevis-lmwg Aug 24, 2021
1c1a945
Made params consistent w current params file ctsm51_params.c210528.nc
slevis-lmwg Aug 25, 2021
ecadf73
Added use_mimics_decomp to the namelist
slevis-lmwg Aug 30, 2021
66d7b92
Introduced MIMICS test mod directory
slevis-lmwg Aug 31, 2021
3ff27f3
Debugging while running with use_mimics_decomp = .true.
slevis-lmwg Sep 4, 2021
ee6c401
Corrections to unit conversions based on meeting with @wwieder
slevis-lmwg Sep 13, 2021
680512e
C balance error seems resolved and replaced with N balance error
slevis-lmwg Sep 23, 2021
c522916
Now past the big N balance error but still getting small one
slevis-lmwg Sep 23, 2021
3ce2163
Small changes that seem necessary for N balance though still looking...
slevis-lmwg Oct 13, 2021
e037adf
Adding totmicn to the N balance; still not fixed though
slevis-lmwg Oct 19, 2021
e6d365c
Dimension p_decomp_cn_gain by pools instead of transitions
slevis-lmwg Oct 22, 2021
f3f7d0a
Eliminate max from a line and correct NaNs that resulted
slevis-lmwg Oct 25, 2021
80c0c2f
Updates discussed with @wwieder
slevis-lmwg Oct 25, 2021
520f4f9
The model now runs without balance or other errors
slevis-lmwg Oct 27, 2021
1faa673
Code simplification for improved clarity
slevis-lmwg Oct 27, 2021
e30d41e
Merge tag 'ctsm5.1.dev061' into vert_res_in_mimics
slevis-lmwg Nov 4, 2021
3b2073b
Minor corrections of mistakes that snuck through the dev061 merge
slevis-lmwg Nov 4, 2021
a399480
Change use_mimics_decomp -> mimics_decomp and coordinate w decomp_method
slevis-lmwg Nov 5, 2021
8166fd0
Updated params files and respective code
slevis-lmwg Nov 8, 2021
4eb3372
Add mimics tests, one to cheyenne and one to izumi test suites
slevis-lmwg Nov 8, 2021
019fe54
Update params files (var names/values), clean up various TODOs
slevis-lmwg Nov 15, 2021
3b94597
Revisions in response to Erik's code review and 1 or 2 remaining TODOs
slevis-lmwg Nov 16, 2021
3211e89
I should have removed this comment in the previous commit
slevis-lmwg Nov 16, 2021
e5f3ffd
Revert unnecessary changes in bld/listDefaultNamelist.pl
slevis-lmwg Nov 16, 2021
f6b3bf9
Correct the clay units by converting from % to fraction in MIMICS
slevis-lmwg Nov 18, 2021
2b071a3
Merge tag 'ctsm5.1.dev066' into vert_res_in_mimics
slevis-lmwg Dec 10, 2021
6205b30
First draft of updated ChangeLog
slevis-lmwg Dec 11, 2021
b69a4e7
Merge remote-tracking branch 'escomp/master' into vert_res_in_mimics
slevis-lmwg Jan 27, 2022
ab17157
Minor merge conflict caught by test-suite
slevis-lmwg Jan 27, 2022
c2a21bf
Update ChangeLog + add comment in SoilBiogeochemDecompCascadeMIMICSMod
slevis-lmwg Jan 28, 2022
99c3c30
Committing the three new timing calls that I added to time MIMICS
slevis-lmwg Jan 28, 2022
5451493
Updated ChangeLog/ChangeSum
slevis-lmwg Jan 29, 2022
eba8244
Added newton_krylov_spinup testmod and corresponding new test
slevis-lmwg Feb 2, 2022
be14cd1
Update changelog, tweak a few things, make sure issues mentioned have…
ekluzek Feb 2, 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
104 changes: 55 additions & 49 deletions src/soilbiogeochem/SoilBiogeochemCompetitionMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -557,29 +557,7 @@ subroutine SoilBiogeochemCompetition (bounds, num_soilc, filter_soilc,num_soilp,
sum_nh4_demand_scaled(c,j) = plant_ndemand(c)* nuptake_prof(c,j) * compet_plant_nh4 + &
potential_immob_vr(c,j)*compet_decomp_nh4 + pot_f_nit_vr(c,j)*compet_nit

if (use_mimics_decomp) then
! this turns off fpi for MIMICS and only lets plants
! take up available mineral nitrogen.
! TODO slevis: -ve or tiny sminn_vr could cause problems
nlimit_nh4(c,j) = 1
fpi_nh4_vr(c,j) = 1.0_r8
actual_immob_nh4_vr(c,j) = potential_immob_vr(c,j)
! TODO slevis: check the logic here...
f_nit_vr(c,j) = pot_f_nit_vr(c,j)
if ( .not. local_use_fun ) then
smin_nh4_to_plant_vr(c,j) = min((smin_nh4_vr(c,j) / dt) * &
plant_ndemand(c) * &
nuptake_prof(c,j) * &
compet_plant_nh4 / &
sum_nh4_demand_scaled(c,j), &
plant_ndemand(c) * &
nuptake_prof(c,j))
else
smin_nh4_to_plant_vr(c,j) = smin_nh4_vr(c,j) / dt - &
actual_immob_nh4_vr(c,j) - &
f_nit_vr(c,j)
end if
else if (sum_nh4_demand(c,j)*dt < smin_nh4_vr(c,j)) then
if (sum_nh4_demand(c,j)*dt < smin_nh4_vr(c,j)) then

! NH4 availability is not limiting immobilization or plant
! uptake, and all can proceed at their potential rates
Expand All @@ -596,6 +574,31 @@ subroutine SoilBiogeochemCompetition (bounds, num_soilc, filter_soilc,num_soilp,
smin_nh4_to_plant_vr(c,j) = smin_nh4_vr(c,j)/dt - actual_immob_nh4_vr(c,j) - f_nit_vr(c,j)
end if

else if (use_mimics_decomp) then
slevis-lmwg marked this conversation as resolved.
Show resolved Hide resolved
! this turns off fpi for MIMICS and only lets plants
! take up available mineral nitrogen.
! TODO slevis: -ve or tiny sminn_vr could cause problems
nlimit_nh4(c,j) = 1
if (sum_nh4_demand(c,j) > 0.0_r8) then
fpi_nh4_vr(c,j) = 1.0_r8
actual_immob_nh4_vr(c,j) = potential_immob_vr(c,j)
! TODO slevis: consolidate repeating code if poss.
f_nit_vr(c,j) = min((smin_nh4_vr(c,j)/dt)*(pot_f_nit_vr(c,j)*compet_nit / &
sum_nh4_demand_scaled(c,j)), pot_f_nit_vr(c,j))
if ( .not. local_use_fun ) then
smin_nh4_to_plant_vr(c,j) = min((smin_nh4_vr(c,j) / dt) * &
plant_ndemand(c) * &
nuptake_prof(c,j) * &
compet_plant_nh4 / &
sum_nh4_demand_scaled(c,j), &
plant_ndemand(c) * &
nuptake_prof(c,j))
else
smin_nh4_to_plant_vr(c,j) = smin_nh4_vr(c,j) / dt - &
actual_immob_nh4_vr(c,j) - &
f_nit_vr(c,j)
end if
end if
else

! NH4 availability can not satisfy the sum of immobilization, nitrification, and
Expand Down Expand Up @@ -650,32 +653,7 @@ subroutine SoilBiogeochemCompetition (bounds, num_soilc, filter_soilc,num_soilp,



if (use_mimics_decomp) then
! this turns off fpi for MIMICS and only lets plants
! take up available mineral nitrogen.
! TODO slevis: -ve or tiny sminn_vr could cause problems
nlimit_no3(c,j) = 1
fpi_no3_vr(c,j) = 1.0_r8 - fpi_nh4_vr(c,j) ! currently 0
actual_immob_no3_vr(c,j) = potential_immob_vr(c,j) - &
actual_immob_nh4_vr(c,j) ! currently 0
! TODO slevis: check the logic here...
f_denit_vr(c,j) = pot_f_denit_vr(c,j)
if ( .not. local_use_fun ) then
smin_no3_to_plant_vr(c,j) = min((smin_no3_vr(c,j) / dt) * &
(plant_ndemand(c) * &
nuptake_prof(c,j) - &
smin_nh4_to_plant_vr(c,j)) * &
compet_plant_no3 / &
sum_no3_demand_scaled(c,j), &
plant_ndemand(c) * &
nuptake_prof(c,j) - &
smin_nh4_to_plant_vr(c,j))
else
smin_no3_to_plant_vr(c,j) = smin_no3_vr(c,j) / dt - &
actual_immob_no3_vr(c,j) - &
f_denit_vr(c,j)
end if
else if (sum_no3_demand(c,j)*dt < smin_no3_vr(c,j)) then
if (sum_no3_demand(c,j)*dt < smin_no3_vr(c,j)) then

! NO3 availability is not limiting immobilization or plant
! uptake, and all can proceed at their potential rates
Expand All @@ -698,6 +676,34 @@ subroutine SoilBiogeochemCompetition (bounds, num_soilc, filter_soilc,num_soilp,
end if
endif

else if (use_mimics_decomp) then
slevis-lmwg marked this conversation as resolved.
Show resolved Hide resolved
! this turns off fpi for MIMICS and only lets plants
! take up available mineral nitrogen.
! TODO slevis: -ve or tiny sminn_vr could cause problems
nlimit_no3(c,j) = 1
if (sum_no3_demand(c,j) > 0.0_r8) then
fpi_no3_vr(c,j) = 1.0_r8 - fpi_nh4_vr(c,j) ! => 0
actual_immob_no3_vr(c,j) = potential_immob_vr(c,j) - &
actual_immob_nh4_vr(c,j) ! => 0
! TODO slevis: consolidate repeating code if poss.
f_denit_vr(c,j) = min((smin_no3_vr(c,j)/dt)*(pot_f_denit_vr(c,j)*compet_denit / &
sum_no3_demand_scaled(c,j)), pot_f_denit_vr(c,j))
if ( .not. local_use_fun ) then
smin_no3_to_plant_vr(c,j) = min((smin_no3_vr(c,j) / dt) * &
(plant_ndemand(c) * &
nuptake_prof(c,j) - &
smin_nh4_to_plant_vr(c,j)) * &
compet_plant_no3 / &
sum_no3_demand_scaled(c,j), &
plant_ndemand(c) * &
nuptake_prof(c,j) - &
smin_nh4_to_plant_vr(c,j))
else
smin_no3_to_plant_vr(c,j) = smin_no3_vr(c,j) / dt - &
actual_immob_no3_vr(c,j) - &
f_denit_vr(c,j)
end if
end if
else

! NO3 availability can not satisfy the sum of immobilization, denitrification, and
Expand Down
8 changes: 3 additions & 5 deletions src/soilbiogeochem/SoilBiogeochemDecompMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ subroutine SoilBiogeochemDecomp (bounds, num_soilc, filter_soilc,
real(r8) , intent(inout) :: cn_decomp_pools(bounds%begc:,1:,1:) ! c:n ratios of applicable pools
real(r8) , intent(inout) :: p_decomp_cpool_loss(bounds%begc:,1:,1:) ! potential C loss from one pool to another
real(r8) , intent(inout) :: pmnf_decomp_cascade(bounds%begc:,1:,1:) ! potential mineral N flux from one pool to another
real(r8) , intent(inout) :: p_decomp_npool_to_din(bounds%begc:,1:,1:) ! potential flux to dissolved inorganic N
real(r8) , intent(in) :: p_decomp_npool_to_din(bounds%begc:,1:,1:) ! potential flux to dissolved inorganic N
!
! !LOCAL VARIABLES:
integer :: c,j,k,l,m ! indices
Expand Down Expand Up @@ -121,7 +121,7 @@ subroutine SoilBiogeochemDecomp (bounds, num_soilc, filter_soilc,
decomp_cascade_sminn_flux_vr => soilbiogeochem_nitrogenflux_inst%decomp_cascade_sminn_flux_vr_col , & ! Output: [real(r8) (:,:,:) ] vert-res mineral N flux for transition along decomposition cascade (gN/m3/s)
potential_immob_vr => soilbiogeochem_nitrogenflux_inst%potential_immob_vr_col , & ! Output: [real(r8) (:,:) ]
sminn_to_denit_decomp_cascade_vr => soilbiogeochem_nitrogenflux_inst%sminn_to_denit_decomp_cascade_vr_col , & ! Output: [real(r8) (:,:,:) ]
gross_nmin_vr => soilbiogeochem_nitrogenflux_inst%gross_nmin_vr_col , & ! Output: [real(r8) (:,:) ]
gross_nmin_vr => soilbiogeochem_nitrogenflux_inst%gross_nmin_vr_col , & ! Input: [real(r8) (:,:) ]
net_nmin_vr => soilbiogeochem_nitrogenflux_inst%net_nmin_vr_col , & ! Output: [real(r8) (:,:) ]
gross_nmin => soilbiogeochem_nitrogenflux_inst%gross_nmin_col , & ! Output: [real(r8) (:) ] gross rate of N mineralization (gN/m2/s)
net_nmin => soilbiogeochem_nitrogenflux_inst%net_nmin_col , & ! Output: [real(r8) (:) ] net rate of N mineralization (gN/m2/s)
Expand Down Expand Up @@ -204,10 +204,8 @@ subroutine SoilBiogeochemDecomp (bounds, num_soilc, filter_soilc,
decomp_cascade_sminn_flux_vr(c,j,k) = - pmnf_decomp_cascade(c,j,k)
endif
net_nmin_vr(c,j) = net_nmin_vr(c,j) - pmnf_decomp_cascade(c,j,k)
! TODO slevis: NEED THIS if-block? If so, need anything additional that
! is done to pmnf_decomp_cascade or other?
if (use_mimics_decomp) then
decomp_cascade_sminn_flux_vr(c,j,k) = decomp_cascade_sminn_flux_vr(c,j,k) + p_decomp_npool_to_din(c,j,k)
decomp_cascade_sminn_flux_vr(c,j,k) = decomp_cascade_sminn_flux_vr(c,j,k) - p_decomp_npool_to_din(c,j,k)
ekluzek marked this conversation as resolved.
Show resolved Hide resolved
net_nmin_vr(c,j) = net_nmin_vr(c,j) + p_decomp_npool_to_din(c,j,k)
end if
else
Expand Down
4 changes: 3 additions & 1 deletion src/soilbiogeochem/SoilBiogeochemNitrogenStateType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,10 @@ subroutine Restart ( this, bounds, ncid, flag, totvegc_col )
! matches what the restart file was generated with.
! add info about the SOM decomposition cascade

if (use_century_decomp .or. use_mimics_decomp) then
if (use_century_decomp) then
decomp_cascade_state = 1
else if (use_mimics_decomp) then
decomp_cascade_state = 2
else
decomp_cascade_state = 0
end if
Expand Down
5 changes: 3 additions & 2 deletions src/soilbiogeochem/SoilBiogeochemPotentialMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,10 @@ subroutine SoilBiogeochemPotential (bounds, num_soilc, filter_soilc, &
decomp_k(c,j,cascade_donor_pool(k)) > 0._r8 ) then
! if p_decomp_cn_diff < 0 N mineralization
! > 0 immobilization
p_decomp_cn_diff_ratio = &
! "min" in next line turns off immobilization flux
p_decomp_cn_diff_ratio = min(0.0_r8, &
(p_decomp_cn_gain(c,j,cascade_receiver_pool(k)) - &
cn_col(c,cascade_receiver_pool(k))) / cn_col(c,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
Expand Down