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

Merge b4bdev 20241220 #2917

Merged
merged 24 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c0bf3a1
BNF usermods
wwieder Mar 18, 2024
3f6ee73
Merge master into BNF_v2
wwieder Oct 31, 2024
e381e9d
alternative nfix temperature cost function
wwieder Nov 7, 2024
88d5b0f
cleanup and print errors
wwieder Nov 12, 2024
ac08121
remove print statements
wwieder Nov 12, 2024
dedd134
removing BNF usermod_dirs
wwieder Nov 15, 2024
f125b60
Merge branch 'master' into BNF_v2
wwieder Nov 15, 2024
67117da
Update parameter files with the new nfix fields on them
ekluzek Nov 19, 2024
9d9337b
fix (namelist): Change paramfiles to name without nfix in the name, a…
ekluzek Nov 19, 2024
1d5f4f2
Merge tag 'ctsm5.3.013' into merge-master-20241126
ekluzek Nov 26, 2024
7417668
Merge pull request #2894 from ekluzek/merge-master-20241126
ekluzek Nov 26, 2024
da2c5d9
Merge remote-tracking branch 'escomp/b4b-dev' into BNF_v2
slevis-lmwg Dec 6, 2024
80a32ba
Move nfix_method from a hardwired variable to the namelist
slevis-lmwg Dec 6, 2024
9b0be80
Add if statement to CLMBuildNamelist for correct trigger of error
slevis-lmwg Dec 13, 2024
2db5c6a
Merge pull request #2869 from wwieder/BNF_v2
slevis-lmwg Dec 16, 2024
e562c52
Merge tag 'ctsm5.3.016' into merge-b4bdev-20241220
slevis-lmwg Dec 20, 2024
d420b69
Update paramfiles for ciso_cwd_hr and cn30 testmods
slevis-lmwg Dec 20, 2024
49490c7
Updated ChangeLog/ChangeSum
slevis-lmwg Dec 20, 2024
f30e9f2
Remove obsolete clm5_1 entry
slevis-lmwg Dec 23, 2024
5e27db7
Error-check clean-up from Erik's code review
slevis-lmwg Dec 23, 2024
83e27f7
Move nfix_t* param-read from pftconMod (public) to CNFUNMod (local)
slevis-lmwg Dec 23, 2024
c3d9ecc
Move namelist read for nfix_method to CNFUNMod based on Erik's review
slevis-lmwg Dec 24, 2024
a73a961
Simplify equation based on Erik's review
slevis-lmwg Dec 24, 2024
b603c68
Final ChangeLog/ChangeSum
slevis-lmwg Dec 24, 2024
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
10 changes: 9 additions & 1 deletion bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3395,7 +3395,7 @@ sub setup_logic_mineral_nitrogen_dynamics {
#
my ($opts, $nl_flags, $definition, $defaults, $nl) = @_;

my @vars = ( "freelivfix_slope_wet", "freelivfix_intercept" );
my @vars = ( "freelivfix_slope_wet", "freelivfix_intercept", "nfix_method" );
if ( &value_is_true($nl_flags->{'use_cn'}) && &value_is_true($nl->get_value('use_fun')) ) {
foreach my $var ( @vars ) {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var,
Expand All @@ -3408,6 +3408,14 @@ sub setup_logic_mineral_nitrogen_dynamics {
}
}
}

if ( &value_is_true($nl_flags->{'use_cn'}) && &value_is_true($nl->get_value('use_fun')) ) {
slevis-lmwg marked this conversation as resolved.
Show resolved Hide resolved
my $var = $nl->get_value('nfix_method');
if ( $var ne "'Houlton'" && $var ne "'Bytnerowicz'" ) {
$log->fatal_error("$var is incorrect entry for the namelist variable nfix_method; expected Houlton or Bytnerowicz");
}
}

}


Expand Down
10 changes: 6 additions & 4 deletions bld/namelist_files/namelist_defaults_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,10 @@ attributes from the config_cache.xml file (with keys converted to upper-case).
<!-- The default filenames are given relative to the root directory
for the CLM2 data in the CESM distribution -->
<!-- Plant function types (relative to {csmdata}) -->
<paramfile phys="clm6_0" >lnd/clm2/paramdata/ctsm60_params.c241017.nc</paramfile>
<paramfile phys="clm5_1" >lnd/clm2/paramdata/ctsm51_params.c241017.nc</paramfile>
<paramfile phys="clm5_0" >lnd/clm2/paramdata/clm50_params.c241017.nc</paramfile>
<paramfile phys="clm4_5" >lnd/clm2/paramdata/clm45_params.c241017.nc</paramfile>
<paramfile phys="clm6_0" >lnd/clm2/paramdata/ctsm60_params.c241119.nc</paramfile>
<paramfile phys="clm5_1" >lnd/clm2/paramdata/ctsm60_params.c241119.nc</paramfile>
slevis-lmwg marked this conversation as resolved.
Show resolved Hide resolved
<paramfile phys="clm5_0" >lnd/clm2/paramdata/clm50_params.c241119.nc</paramfile>
<paramfile phys="clm4_5" >lnd/clm2/paramdata/clm45_params.c241119.nc</paramfile>

<!-- ================================================================== -->
<!-- FATES default parameter file -->
Expand Down Expand Up @@ -1894,6 +1894,8 @@ lnd/clm2/surfdata_esmf/NEON/ctsm5.3.0/surfdata_1x1_NEON_TOOL_hist_2000_78pfts_c2
<freelivfix_intercept use_fun=".true." use_cn=".true.">0.0117d00</freelivfix_intercept>
<freelivfix_slope_wet use_fun=".true." use_cn=".true.">0.0006d00</freelivfix_slope_wet>

<nfix_method>Houlton</nfix_method>

<br_root>0.83d-06</br_root>

<!-- Scalar of leaf respiration to vcmax (used for SP mode and with luna) (could vary with physics version) -->
Expand Down
5 changes: 5 additions & 0 deletions bld/namelist_files/namelist_definition_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@ Slope of free living Nitrogen fixation with annual ET
Intercept of free living Nitrogen fixation with zero annual ET
</entry>

<entry id="nfix_method" type="char*25" category="clm_nitrogen"
group="clm_nitrogen" valid_values="Houlton,Bytnerowicz" value="Houlton" >
Choice of nfix parameterization
</entry>

<entry id="use_undercanopy_stability" type="logical" category="clm_physics"
group="canopyfluxes_inparm" valid_values="" >
If TRUE use the undercanopy stability term used with CLM4.5 (Sakaguchi&amp;Zeng, 2008)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
paramfile = '$DIN_LOC_ROOT/lnd/clm2/paramdata/ctsm51_ciso_cwd_hr_params.c241017.nc'
paramfile = '$DIN_LOC_ROOT/lnd/clm2/paramdata/ctsm60_ciso_cwd_hr_params.c241119.nc'
hist_fincl1 = 'CWDC_HR','C13_CWDC_HR','C14_CWDC_HR','CWD_HR_L2','CWD_HR_L2_vr','CWD_HR_L3','CWD_HR_L3_vr'
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
use_soil_matrixcn = .true.
paramfile = '$DIN_LOC_ROOT/lnd/clm2/paramdata/ctsm60_params_cn30.c241017.nc'
paramfile = '$DIN_LOC_ROOT/lnd/clm2/paramdata/ctsm60_params_cn30.c241119.nc'
84 changes: 84 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,88 @@
===============================================================
Tag name: ctsm5.3.017
Originator(s): slevis (Samuel Levis,UCAR/TSS,303-665-1310)
Date: Fri 20 Dec 2024 11:31:36 AM MST
One-line Summary: Merge b4b-dev

Purpose and description of changes
----------------------------------

#2869 Update temperature cost function for symbiotic Nfix in FUN


Significant changes to scientifically-supported configurations
--------------------------------------------------------------

Does this tag change answers significantly for any of the following physics configurations?
(Details of any changes will be given in the "Answer changes" section below.)

[Put an [X] in the box for any configuration with significant answer changes.]

[ ] clm6_0

[ ] clm5_0

[ ] ctsm5_0-nwp

[ ] clm4_5


Bugs fixed
----------
List of CTSM issues fixed (include CTSM Issue # and description) [one per line]:
Resolves #2869

Notes of particular relevance for users
---------------------------------------
Changes to CTSM's user interface (e.g., new/renamed XML or namelist variables):
New namelist variable: nfix_method

Changes made to namelist defaults (e.g., changed parameter values):
nfix_method default: Houlton
other available option: Bytnerowicz


Testing summary:
----------------

[PASS means all tests PASS; OK means tests PASS other than expected fails.]

build-namelist tests (if CLMBuildNamelist.pm has changed):

derecho - PASS

regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing):

derecho ----- OK
izumi ------- machine unavailable


Answer changes
--------------

Changes answers relative to baseline: No, but read caveat.

Summarize any changes to answers, i.e.,
- what code configurations: tests with ciso_cwd_hr testmods
- what platforms/compilers: all
- nature of change: irrelevant

Explanation:
"diff ctsm60_ciso_cwd_hr_params.c241119.asc ctsm60_params.c241119.asc"
differ ONLY in the value of ceta. The previous paramfile for ciso_cwd_hr
showed additional diffs, likely due to problems that we have seen before
when generating new paramfiles. The ciso_cwd_hr tests would not have shown
diffs had the previous paramfile been correct, so I only mention the diffs
here for the record.


Other details
-------------
Pull Requests that document the changes (include PR ids):
https://github.com/ESCOMP/ctsm/pull/2869

===============================================================
===============================================================
Tag name: ctsm5.3.016
Originator(s): jedwards and erik (Erik Kluzek,UCAR/TSS,303-497-1326)
Date: Thu 19 Dec 2024 04:23:39 PM MST
Expand Down
1 change: 1 addition & 0 deletions doc/ChangeSum
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Tag Who Date Summary
============================================================================================================================
ctsm5.3.017 slevis 12/20/2024 Merge b4b-dev
ctsm5.3.016 erik 12/19/2024 Rpointer files for restart now have the simulation date in the filename
ctsm5.3.015 erik 12/18/2024 Update cdeps with cam7 nextsw cday changes
ctsm5.3.014 erik 12/03/2024 Bring in several fixes for testing in the previous cesm3_0_beta03/04 tags
Expand Down
87 changes: 68 additions & 19 deletions src/biogeochem/CNFUNMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module CNFUNMod
use pftconMod , only : pftcon, npcropmin
use decompMod , only : bounds_type
use clm_varctl , only : use_nitrif_denitrif,use_flexiblecn
use CNSharedParamsMod , only : use_matrixcn
use CNSharedParamsMod , only : use_matrixcn
use abortutils , only : endrun
use CNVegstateType , only : cnveg_state_type
use CNVegCarbonStateType , only : cnveg_carbonstate_type
Expand Down Expand Up @@ -206,7 +206,7 @@ subroutine CNFUN(bounds,num_soilc, filter_soilc,num_soilp&
use clm_time_manager, only : get_step_size_real, get_curr_date
use clm_varpar , only : nlevdecomp
use clm_varcon , only : secspday, smallValue, fun_period, tfrz, dzsoi_decomp, spval
use clm_varctl , only : use_nitrif_denitrif
use clm_varctl , only : use_nitrif_denitrif, nfix_method
use PatchType , only : patch
use subgridAveMod , only : p2c
use pftconMod , only : npcropmin
Expand Down Expand Up @@ -290,7 +290,7 @@ subroutine CNFUN(bounds,num_soilc, filter_soilc,num_soilp&
real(r8) :: litterfall_n(bounds%begp:bounds%endp) ! N loss based on the leafc to litter (gN/m2)
real(r8) :: litterfall_n_step(bounds%begp:bounds%endp,1:nstp) ! N loss based on the leafc to litter (gN/m2)
real(r8) :: litterfall_c_step(bounds%begp:bounds%endp,1:nstp) ! N loss based on the leafc to litter (gN/m2)
real(r8) :: tc_soisno(bounds%begc:bounds%endc,1:nlevdecomp) ! Soil temperature (degrees Celsius)
real(r8) :: tc_soisno(bounds%begc:bounds%endc,1:nlevdecomp) ! Soil temperature (degrees Celsius)
real(r8) :: npp_remaining(bounds%begp:bounds%endp,1:nstp) ! A temporary variable for npp_remaining(gC/m2)
real(r8) :: n_passive_step(bounds%begp:bounds%endp,1:nstp) ! N taken up by transpiration at substep(gN/m2)
real(r8) :: n_passive_acc(bounds%begp:bounds%endp) ! N acquired by passive uptake (gN/m2)
Expand Down Expand Up @@ -467,7 +467,6 @@ subroutine CNFUN(bounds,num_soilc, filter_soilc,num_soilp&
real(r8) :: total_c_spent_retrans
real(r8) :: total_c_accounted_retrans


!------end of not_use_nitrif_denitrif------!
!--------------------------------------------------------------------
!------------
Expand Down Expand Up @@ -495,9 +494,10 @@ subroutine CNFUN(bounds,num_soilc, filter_soilc,num_soilp&
! fixers, 2 for non fixers. This will become redundant with the
! 'fixer' parameter if it works.

character(len=32) :: subname = 'CNFUN'
slevis-lmwg marked this conversation as resolved.
Show resolved Hide resolved
!--------------------------------------------------------------------
!---------------------------------
associate(ivt => patch%itype , & ! Input: [integer (:) ] p
associate(ivt => patch%itype , & ! Input: [integer (:) ] p
leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN)
season_decid => pftcon%season_decid , & ! Input: binary flag for seasonal
! -deciduous leaf habit (0 or 1)
Expand All @@ -507,6 +507,9 @@ subroutine CNFUN(bounds,num_soilc, filter_soilc,num_soilp&
b_fix => pftcon%b_fix , & ! Input: A BNF parameter
c_fix => pftcon%c_fix , & ! Input: A BNF parameter
s_fix => pftcon%s_fix , & ! Input: A BNF parameter
nfix_tmin => pftcon%nfix_tmin , & ! Input: A BNF parameter
nfix_topt => pftcon%nfix_topt , & ! Input: A BNF parameter
nfix_tmax => pftcon%nfix_tmax , & ! Input: A BNF parameter
akc_active => pftcon%akc_active , & ! Input: A mycorrhizal uptake
! parameter
akn_active => pftcon%akn_active , & ! Input: A mycorrhizal uptake
Expand All @@ -522,10 +525,10 @@ subroutine CNFUN(bounds,num_soilc, filter_soilc,num_soilp&
perecm => pftcon%perecm , & ! Input: The fraction of ECM
! -associated PFT
grperc => pftcon%grperc , & ! Input: growth percentage
fun_cn_flex_a => pftcon%fun_cn_flex_a , & ! Parameter a of FUN-flexcn link code (def 5)
fun_cn_flex_b => pftcon%fun_cn_flex_b , & ! Parameter b of FUN-flexcn link code (def 200)
fun_cn_flex_c => pftcon%fun_cn_flex_c , & ! Parameter b of FUN-flexcn link code (def 80)
FUN_fracfixers => pftcon%FUN_fracfixers , & ! Fraction of C that can be used for fixation.
fun_cn_flex_a => pftcon%fun_cn_flex_a , & ! Parameter a of FUN-flexcn link code (def 5)
fun_cn_flex_b => pftcon%fun_cn_flex_b , & ! Parameter b of FUN-flexcn link code (def 200)
fun_cn_flex_c => pftcon%fun_cn_flex_c , & ! Parameter b of FUN-flexcn link code (def 80)
FUN_fracfixers => pftcon%FUN_fracfixers , & ! Fraction of C that can be used for fixation.
leafcn_offset => cnveg_state_inst%leafcn_offset_patch , & ! Output:
! [real(r8) (:)] Leaf C:N used by FUN
plantCN => cnveg_state_inst%plantCN_patch , & ! Output: [real(r8) (:)] Plant
Expand Down Expand Up @@ -1041,42 +1044,50 @@ subroutine CNFUN(bounds,num_soilc, filter_soilc,num_soilp&
npp_to_nonmyc_nh4(:) = 0.0_r8
npp_to_fixation(:) = 0.0_r8
npp_to_retrans(:) = 0.0_r8




unmetDemand = .TRUE.
plant_ndemand_pool_step(p,istp) = plant_ndemand_pool(p) * permyc(p,istp)
npp_remaining(p,istp) = availc_pool(p) * permyc(p,istp)


! if (plant_ndemand_pool_step(p,istp) .gt. 0._r8) then !
! plant_ndemand_pool_step > 0.0

do j = 1, nlevdecomp
tc_soisno(c,j) = t_soisno(c,j) - tfrz

if(pftcon%c3psn(patch%itype(p)).eq.1)then
fixer=1
else
fixer=0
endif
costNit(j,icostFix) = fun_cost_fix(fixer,a_fix(ivt(p)),b_fix(ivt(p))&
,c_fix(ivt(p)) ,big_cost,crootfr(p,j),s_fix(ivt(p)),tc_soisno(c,j))

select case (nfix_method)
slevis-lmwg marked this conversation as resolved.
Show resolved Hide resolved
case ('Houlton')
costNit(j,icostFix) = fun_cost_fix(fixer,&
a_fix(ivt(p)),b_fix(ivt(p)),c_fix(ivt(p)),&
big_cost,crootfr(p,j),s_fix(ivt(p)),tc_soisno(c,j))
case ('Bytnerowicz') ! no acclimation calculation
costNit(j,icostFix) = fun_cost_fix_Bytnerowicz_noAcc(fixer, &
nfix_tmin(ivt(p)),nfix_topt(ivt(p)),nfix_tmax(ivt(p)), &
big_cost,crootfr(p,j),s_fix(ivt(p)),tc_soisno(c,j))
case default
write(iulog,*) subname//' ERROR: unknown nfix_method value: ', nfix_method
call endrun(msg=errMsg(sourcefile, __LINE__))
end select

end do
cost_fix(p,1:nlevdecomp) = costNit(:,icostFix)


!--------------------------------------------------------------------
!------------
! If passive uptake is insufficient, consider fixation,
! mycorrhizal
! non-mycorrhizal, storage, and retranslocation.
!--------------------------------------------------------------------
!------------
!--------------------------------------------------------------------
!------------
! Costs of active uptake.
!--------------------------------------------------------------------
!------------
!------Mycorrhizal Uptake Cost-----------------!
do j = 1,nlevdecomp
rootc_dens_step = rootc_dens(p,j) * permyc(p,istp)
Expand Down Expand Up @@ -1608,6 +1619,44 @@ real(r8) function fun_cost_fix(fixer,a_fix,b_fix,c_fix,big_cost,crootfr,s_fix, t
end if ! ends up with the fixer or non-fixer decision

end function fun_cost_fix


!=========================================================================================
real(r8) function fun_cost_fix_Bytnerowicz_noAcc(fixer,nfix_tmin,nfix_topt,nfix_tmax,big_cost,crootfr,s_fix, tc_soisno)
slevis-lmwg marked this conversation as resolved.
Show resolved Hide resolved

! Description:
! Calculate the cost of fixing N by nodules.
! Code Description:
! This code is written to CTSM5.1 by Will Wieder 11/17/2022, modified for CLM6 11/01/2024

implicit none
!--------------------------------------------------------------------------
! Function result.
!--------------------------------------------------------------------------
! real(r8) , intent(out) :: cost_of_n !!! cost of fixing N (kgC/kgN)
!--------------------------------------------------------------------------
integer, intent(in) :: fixer ! flag indicating if plant is a fixer
! 1=yes, otherwise no.
real(r8), intent(in) :: nfix_tmin ! As in Bytnerowicz et al. (2022)
real(r8), intent(in) :: nfix_topt ! As in Bytnerowicz et al. (2022)
real(r8), intent(in) :: nfix_tmax ! As in Bytnerowicz et al. (2022)
real(r8), intent(in) :: big_cost ! an arbitrary large cost (gC/gN)
slevis-lmwg marked this conversation as resolved.
Show resolved Hide resolved
real(r8), intent(in) :: crootfr ! fraction of roots for carbon that are in this layer
real(r8), intent(in) :: s_fix ! Inverts the temperature function for a cost function
real(r8), intent(in) :: tc_soisno ! soil temperature (degrees Celsius)

if (fixer == 1 .and. crootfr > 1.e-6_r8 .and. tc_soisno > nfix_tmin .and. tc_soisno < nfix_tmax) then
fun_cost_fix_Bytnerowicz_noAcc = (-1*s_fix) * 1._r8 / ( ((nfix_tmax-tc_soisno)/(nfix_tmax-nfix_topt))*&
( ((tc_soisno-nfix_tmin)/(nfix_topt-nfix_tmin))**&
((nfix_topt- nfix_tmin)/(nfix_tmax-nfix_topt)) ) )
fun_cost_fix_Bytnerowicz_noAcc = min(fun_cost_fix_Bytnerowicz_noAcc,big_cost)
else
fun_cost_fix_Bytnerowicz_noAcc = big_cost
end if ! ends up with the fixer or non-fixer decision

end function fun_cost_fix_Bytnerowicz_noAcc
!=========================================================================================

!=========================================================================================
real(r8) function fun_cost_active(sminn_layer,big_cost,kc_active,kn_active,rootc_dens,crootfr,smallValue)

Expand Down
2 changes: 2 additions & 0 deletions src/main/clm_varctl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ module clm_varctl
!
real(r8), public :: nfix_timeconst = -1.2345_r8

character(len=25), public :: nfix_method ! choice of nfix parameterization
slevis-lmwg marked this conversation as resolved.
Show resolved Hide resolved

!----------------------------------------------------------
! Physics
!----------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions src/main/controlMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ subroutine control_init(dtime)
CNratio_floating, lnc_opt, reduce_dayl_factor, vcmax_opt, &
CN_evergreen_phenology_opt, carbon_resp_opt

namelist /clm_nitrogen/ nfix_method

namelist /clm_inparm/ use_soil_moisture_streams

! excess ice flag
Expand Down Expand Up @@ -882,6 +884,7 @@ subroutine control_spmd()
call mpi_bcast (use_c13_timeseries, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (atm_c13_filename, len(atm_c13_filename), MPI_CHARACTER, 0, mpicom, ier)
call mpi_bcast (use_fun, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (nfix_method, len(nfix_method), MPI_CHARACTER, 0, mpicom, ier)
end if

call mpi_bcast (perchroot, 1, MPI_LOGICAL, 0, mpicom, ier)
Expand Down
Loading
Loading