From 80a32ba244e36e6b4ba52feab953418571de4f9f Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 6 Dec 2024 12:10:45 -0700 Subject: [PATCH] Move nfix_method from a hardwired variable to the namelist --- bld/CLMBuildNamelist.pm | 8 +++++++- bld/namelist_files/namelist_defaults_ctsm.xml | 2 ++ .../namelist_definition_ctsm.xml | 5 +++++ src/biogeochem/CNFUNMod.F90 | 19 +++++++++---------- src/main/clm_varctl.F90 | 2 ++ src/main/controlMod.F90 | 3 +++ 6 files changed, 28 insertions(+), 11 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index cfdb4e9278..33a8baebbc 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -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, @@ -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"); + } + } diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 7d1f29fb28..8674482851 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2024,6 +2024,8 @@ lnd/clm2/surfdata_esmf/NEON/ctsm5.3.0/surfdata_1x1_NEON_TOOL_hist_2000_78pfts_c2 0.0117d00 0.0006d00 +Houlton + 0.83d-06 diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 351cdc5c80..0f92a28f5d 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -388,6 +388,11 @@ Slope of free living Nitrogen fixation with annual ET Intercept of free living Nitrogen fixation with zero annual ET + +Choice of nfix parameterization + + If TRUE use the undercanopy stability term used with CLM4.5 (Sakaguchi&Zeng, 2008) diff --git a/src/biogeochem/CNFUNMod.F90 b/src/biogeochem/CNFUNMod.F90 index 25fb2f79c0..b2f9a15470 100644 --- a/src/biogeochem/CNFUNMod.F90 +++ b/src/biogeochem/CNFUNMod.F90 @@ -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 @@ -487,8 +487,6 @@ 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 @@ -496,6 +494,7 @@ 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' !-------------------------------------------------------------------- !--------------------------------- associate(ivt => patch%itype , & ! Input: [integer (:) ] p @@ -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) diff --git a/src/main/clm_varctl.F90 b/src/main/clm_varctl.F90 index 9539060200..0989400961 100644 --- a/src/main/clm_varctl.F90 +++ b/src/main/clm_varctl.F90 @@ -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 !---------------------------------------------------------- diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90 index 3f5c58ac0e..61c56f5201 100644 --- a/src/main/controlMod.F90 +++ b/src/main/controlMod.F90 @@ -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 @@ -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)