Skip to content

Commit

Permalink
Move namelist read for nfix_method to CNFUNMod based on Erik's review
Browse files Browse the repository at this point in the history
  • Loading branch information
slevis-lmwg committed Dec 24, 2024
1 parent 83e27f7 commit c3d9ecc
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 8 deletions.
1 change: 1 addition & 0 deletions bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5209,6 +5209,7 @@ sub write_output_files {
}
push @groups, "clm_humanindex_inparm";
push @groups, "cnmresp_inparm";
push @groups, "cnfun_inparm";
push @groups, "photosyns_inparm";
push @groups, "cnfire_inparm";
push @groups, "cn_general";
Expand Down
4 changes: 2 additions & 2 deletions bld/namelist_files/namelist_definition_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ 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" >
<entry id="nfix_method" type="char*25" category="cnfun_inparm"
group="cnfun_inparm" valid_values="Houlton,Bytnerowicz" value="Houlton" >
Choice of nfix parameterization
</entry>

Expand Down
61 changes: 60 additions & 1 deletion src/biogeochem/CNFUNMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ module CNFUNMod
private
!
! !PUBLIC MEMBER FUNCTIONS:
public :: CNFUNReadNML ! Read in namelist variables
public:: readParams ! Read in parameters needed for FUN
public:: CNFUNInit ! FUN calculation initialization
public:: CNFUN ! Run FUN

character(len=25) :: nfix_method ! choice of nfix parameterization

type, private :: params_type
real(r8) :: ndays_off ! number of days to complete leaf offset
real(r8), allocatable :: nfix_tmin(:) ! A BNF parameter
Expand Down Expand Up @@ -85,6 +88,62 @@ module CNFUNMod
contains
!--------------------------------------------------------------------
!---
subroutine CNFUNReadNML(NLFilename)
!
! !DESCRIPTION:
! Read in namelist variables
!
! !USES:
use fileutils , only : getavu, relavu, opnfil
use shr_nl_mod , only : shr_nl_find_group_name
use spmdMod , only : masterproc, mpicom
use shr_mpi_mod, only : shr_mpi_bcast
use clm_varctl , only : iulog
use spmdMod , only : MPI_CHARACTER
!
! !ARGUMENTS:
character(len=*), intent(in) :: NLFilename ! Namelist filename
!
! !LOCAL VARIABLES:
integer :: ierr ! error code
integer :: unitn ! unit for namelist file

character(len=*), parameter :: nmlname = 'cnfun_inparm'
!-----------------------------------------------------------------------

namelist /cnfun_inparm/ nfix_method

! Initialize options to default values, in case they are not specified in
! the namelist

if (masterproc) then
unitn = getavu()
write(iulog,*) 'Read in '//nmlname//' namelist'
call opnfil (NLFilename, unitn, 'F')
call shr_nl_find_group_name(unitn, nmlname, status=ierr)
if (ierr == 0) then
read(unitn, nml=cnfun_inparm, iostat=ierr)
if (ierr /= 0) then
call endrun(msg="ERROR reading "//nmlname//"namelist"//errmsg(sourcefile, __LINE__))
end if
else
call endrun(msg="ERROR finding "//nmlname//"namelist"//errmsg(sourcefile, __LINE__))
end if
call relavu( unitn )
end if

call mpi_bcast (nfix_method, len(nfix_method), MPI_CHARACTER, 0, mpicom, ierr)

if (masterproc) then
write(iulog,*) ' '
write(iulog,*) nmlname//' settings:'
write(iulog,nml=cnfun_inparm)
write(iulog,*) ' '
end if

end subroutine CNFUNReadNML

!-----------------------------------------------------------------------
subroutine readParams ( ncid )
!
! !USES:
Expand Down Expand Up @@ -222,7 +281,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, nfix_method
use clm_varctl , only : use_nitrif_denitrif
use PatchType , only : patch
use subgridAveMod , only : p2c
use pftconMod , only : npcropmin
Expand Down
2 changes: 0 additions & 2 deletions src/main/clm_varctl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ module clm_varctl
!
real(r8), public :: nfix_timeconst = -1.2345_r8

character(len=25), public :: nfix_method ! choice of nfix parameterization

!----------------------------------------------------------
! Physics
!----------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions src/main/controlMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ subroutine control_init(dtime)
!
! !USES:
use CNMRespMod , only : CNMRespReadNML
use CNFUNMod , only : CNFUNReadNML
use CNNDynamicsMod , only : CNNDynamicsReadNML
use CNPhenologyMod , only : CNPhenologyReadNML
use landunit_varcon , only : max_lunit
Expand Down Expand Up @@ -257,8 +258,6 @@ 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 @@ -598,6 +597,7 @@ subroutine control_init(dtime)

if ( use_fun ) then
call CNMRespReadNML( NLFilename )
call CNFUNReadNML( NLFilename )
end if

call soilHydReadNML( NLFilename )
Expand Down Expand Up @@ -884,7 +884,6 @@ 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 c3d9ecc

Please sign in to comment.