Skip to content

Commit

Permalink
Move nfix_method from a hardwired variable to the namelist
Browse files Browse the repository at this point in the history
  • Loading branch information
slevis-lmwg committed Dec 6, 2024
1 parent da2c5d9 commit 80a32ba
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
8 changes: 7 additions & 1 deletion bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3381,7 +3381,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 @@ -3394,6 +3394,12 @@ sub setup_logic_mineral_nitrogen_dynamics {
}
}
}

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
2 changes: 2 additions & 0 deletions bld/namelist_files/namelist_defaults_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2024,6 +2024,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
19 changes: 9 additions & 10 deletions src/biogeochem/CNFUNMod.F90
Original file line number Diff line number Diff line change
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 @@ -487,15 +487,14 @@ subroutine CNFUN(bounds,num_soilc, filter_soilc,num_soilp&
integer :: icost ! a local index
integer :: fixer ! 0 = non-fixer, 1
! =fixer
!TODO, make namelist option
integer :: nfix_method = 2 ! 1 = Houlton, 2 = Bytnerowicz
logical :: unmetDemand ! True while there
! is still demand for N
logical :: local_use_flexibleCN ! local version of use_flexCN
integer :: FIX ! for loop. 1 for
! fixers, 2 for non fixers. This will become redundant with the
! 'fixer' parameter if it works.

character(len=32) :: subname = 'CNFUN'
!--------------------------------------------------------------------
!---------------------------------
associate(ivt => patch%itype , & ! Input: [integer (:) ] p
Expand Down Expand Up @@ -1063,19 +1062,19 @@ subroutine CNFUN(bounds,num_soilc, filter_soilc,num_soilp&
fixer=0
endif

! TODO, make this a name list change determining which equation to use
if (nfix_method == 1) then
! This calls the Houlton function.
select case (nfix_method)
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))
elseif (nfix_method == 2) then
! Bytnerowicz no acclimation calculation
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))

endif
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)
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

!----------------------------------------------------------
! 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

0 comments on commit 80a32ba

Please sign in to comment.