From 8434fbb5957e062f38981a0a6cc764d65dff380c Mon Sep 17 00:00:00 2001 From: "Danny M. Leung" Date: Mon, 13 Mar 2023 00:46:19 -0600 Subject: [PATCH 01/40] An initial commit to enable CLM to read in Zender's soil erodibility streams (dmleung 12 Mar 2023) --- bld/CLMBuildNamelist.pm | 11 + bld/namelist_files/namelist_defaults_ctsm.xml | 12 + .../namelist_definition_ctsm.xml | 15 + src/biogeochem/DUSTMod.F90 | 39 +- .../share_esmf/ZenderSoilErodStreamType.F90 | 346 ++++++++++++++++++ src/main/clm_instMod.F90 | 2 +- 6 files changed, 415 insertions(+), 10 deletions(-) create mode 100644 src/cpl/share_esmf/ZenderSoilErodStreamType.F90 diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 05631edc23..a5abc00671 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -1560,6 +1560,7 @@ sub process_namelist_inline_logic { setup_logic_snowpack($opts, $nl_flags, $definition, $defaults, $nl); setup_logic_fates($opts, $nl_flags, $definition, $defaults, $nl); setup_logic_misc($opts, $nl_flags, $definition, $defaults, $nl); + setup_logic_zender_soilerod($opts, $nl_flags, $definition, $defaults, $nl); # dmleung added 11 Mar 2023 ######################################### # namelist group: atm2lnd_inparm @@ -4187,6 +4188,15 @@ sub setup_logic_misc { #------------------------------------------------------------------------------- +sub setup_logic_zender_soilerod { + # dmleung added on 31 Dec 2022 for reading Prigent's roughness stream file + my ($opts, $nl_flags, $definition, $defaults, $nl) = @_; + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_zendersoilerod' ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_meshfile_zendersoilerod' ); +} + +#------------------------------------------------------------------------------- + sub write_output_files { my ($opts, $nl_flags, $defaults, $nl) = @_; @@ -4235,6 +4245,7 @@ sub write_output_files { push @groups, "ch4finundated"; push @groups, "soilbgc_decomp"; push @groups, "clm_canopy_inparm"; + push @groups, "zendersoilerod"; # dmleung 11 Mar 2023 if (remove_leading_and_trailing_quotes($nl->get_value('snow_cover_fraction_method')) eq 'SwensonLawrence2012') { push @groups, "scf_swenson_lawrence_2012_inparm"; } diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 41103b5259..4ee9d1f92e 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2537,6 +2537,18 @@ lnd/clm2/surfdata_map/release-clm5.0.30/surfdata_ne0np4.CONUS.ne30x8_hist_78pfts lnd/clm2/paramdata/finundated_inversiondata_0.9x1_ESMFmesh_cdf5_130621.nc + + + + + + + +/gpfs/fs1/work/dleung/Zender_dust_source/dst_source2x2tunedcam6-2x2-forCLM_c230311.nc +/gpfs/fs1/work/dleung/Zender_dust_source/lnd_mesh.nc + diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index bc1dd034aa..bd5fd05a48 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -1693,6 +1693,21 @@ Mapping method from Nitrogen deposition input file to the model resolution copy = copy using the same indices + + + + + + +Filename of input stream data for Zender's soil erodibility source function + + + +mesh filename of input stream data for Zender's soil erodibility source function + + diff --git a/src/biogeochem/DUSTMod.F90 b/src/biogeochem/DUSTMod.F90 index a86531ba62..bae61fd430 100644 --- a/src/biogeochem/DUSTMod.F90 +++ b/src/biogeochem/DUSTMod.F90 @@ -30,6 +30,7 @@ module DUSTMod use LandunitType , only : lun use ColumnType , only : col use PatchType , only : patch + use ZenderSoilErodStreamType, only : zendersoilerodstream_type ! dmleung added 11 Mar 2023 ! ! !PUBLIC TYPES implicit none @@ -59,7 +60,9 @@ module DUSTMod real(r8), pointer, private :: vlc_trb_2_patch (:) ! turbulent deposition velocity 2(m/s) real(r8), pointer, private :: vlc_trb_3_patch (:) ! turbulent deposition velocity 3(m/s) real(r8), pointer, private :: vlc_trb_4_patch (:) ! turbulent deposition velocity 4(m/s) - real(r8), pointer, private :: mbl_bsn_fct_col (:) ! basin factor + !########### added by dmleung 11 Mar 2023 ######################################################################## + type(zendersoilerodstream_type), private :: zendersoilerodstream ! Zender soil erodibility stream data + real(r8), pointer, private :: mbl_bsn_fct_col (:) ! [dimensionless] basin factor, or soil erodibility, time-constant contains @@ -78,13 +81,17 @@ module DUSTMod contains !------------------------------------------------------------------------ - subroutine Init(this, bounds) + !subroutine Init(this, bounds) + !##### dmleung edited for initializing stream files 11 Mar 2023 ######## + subroutine Init(this, bounds, NLFilename) class(dust_type) :: this type(bounds_type), intent(in) :: bounds + character(len=*), intent(in) :: NLFilename ! dmleung added 11 Mar 2023 call this%InitAllocate (bounds) call this%InitHistory (bounds) + call this%zendersoilerodstream%Init( bounds, NLFilename ) ! dmleung added 11 Mar 2023 call this%InitCold (bounds) call this%InitDustVars (bounds) @@ -129,9 +136,11 @@ subroutine InitHistory(this, bounds) ! ! !LOCAL VARIABLES: integer :: begp,endp + integer :: begc,endc ! dmleung added 11 Mar 2023 !------------------------------------------------------------------------ begp = bounds%begp; endp = bounds%endp + begc = bounds%begc; endc = bounds%endp this%flx_mss_vrt_dst_tot_patch(begp:endp) = spval call hist_addfld1d (fname='DSTFLXT', units='kg/m2/s', & @@ -158,6 +167,13 @@ subroutine InitHistory(this, bounds) avgflag='A', long_name='turbulent deposition velocity 4', & ptr_patch=this%vlc_trb_4_patch, default='inactive') + !#####added by dmleung 11 Mar 2023 ######################################## + this%mbl_bsn_fct_col(begc:endc) = spval + call hist_addfld1d (fname='LND_MBL', units='fraction', & + avgflag='A', long_name='Soil erodibility factor', & + ptr_col=this%mbl_bsn_fct_col) + !########################################################################## + end subroutine InitHistory !----------------------------------------------------------------------- @@ -173,13 +189,18 @@ subroutine InitCold(this, bounds) ! Set basin factor to 1 for now - do c = bounds%begc, bounds%endc - l = col%landunit(c) + !if (dust_emission_scheme == 'Leung2023') + ! do c = bounds%begc, bounds%endc + ! l = col%landunit(c) - if (.not.lun%lakpoi(l)) then - this%mbl_bsn_fct_col(c) = 1.0_r8 - end if - end do + ! if (.not.lun%lakpoi(l)) then + ! this%mbl_bsn_fct_col(c) = 1.0_r8 + ! end if + ! end do + !else if (dust_emission_scheme == 'Zender2003') + call this%zendersoilerodstream%CalcDustSource( bounds, & + this%mbl_bsn_fct_col(bounds%begc:bounds%endc) ) + !end if end subroutine InitCold @@ -262,7 +283,7 @@ subroutine DustEmission (bounds, & fv => frictionvel_inst%fv_patch , & ! Input: [real(r8) (:) ] friction velocity (m/s) (for dust model) u10 => frictionvel_inst%u10_patch , & ! Input: [real(r8) (:) ] 10-m wind (m/s) (created for dust model) - mbl_bsn_fct => dust_inst%mbl_bsn_fct_col , & ! Input: [real(r8) (:) ] basin factor + mbl_bsn_fct => dust_inst%mbl_bsn_fct_col , & ! Input: [real(r8) (:) ] basin factor ; dmleung changed the value in InitCold 11 Mar 2023 flx_mss_vrt_dst => dust_inst%flx_mss_vrt_dst_patch , & ! Output: [real(r8) (:,:) ] surface dust emission (kg/m**2/s) flx_mss_vrt_dst_tot => dust_inst%flx_mss_vrt_dst_tot_patch & ! Output: [real(r8) (:) ] total dust flux back to atmosphere (pft) ) diff --git a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 new file mode 100644 index 0000000000..ab7d71a24f --- /dev/null +++ b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 @@ -0,0 +1,346 @@ +module ZenderSoilErodStreamType +!dmleung modified based on PrigetnRoughnessStreamType.F90 on 11 Mar 2023 +#include "shr_assert.h" ! What is this? In many modules but not dust module + + !----------------------------------------------------------------------- + ! !DESCRIPTION: + ! Contains methods for reading in the Zender et al. (2003b) Dust source function streams file that has been read in from CAM instead of CLM. dmleung 11 Mar 2023 + ! pathname in CAM: /glade/p/cesmdata/cseg/inputdata/atm/cam/dst/ + ! relevant filenames: (CAM6) dst_source2x2tunedcam6-2x2-04062017.nc (default) + ! (CAM5) dst_source2x2_cam5.4_c150327.nc + ! (CAM4) dst_source2x2tuned-cam4-06132012.nc + ! These files are largely similar and the differences are mainly only a little tuning. + ! This .F90 file for now only deals with the CAM6 source function, which can be used in CAM5 and CAM4 too. Not sure if we will expand the code to include a namelist control to deal + ! with the other files. + ! + ! !USES + use ESMF , only : ESMF_LogFoundError, ESMF_LOGERR_PASSTHRU, ESMF_Finalize, ESMF_END_ABORT + use dshr_strdata_mod , only : shr_strdata_type + use shr_kind_mod , only : r8 => shr_kind_r8, CL => shr_kind_cl + use shr_log_mod , only : errMsg => shr_log_errMsg + use spmdMod , only : mpicom, masterproc + use clm_varctl , only : iulog + use abortutils , only : endrun + use decompMod , only : bounds_type + + ! !PUBLIC TYPES: + implicit none + private + + type, public :: zendersoilerodstream_type + real(r8), pointer, private :: soil_erodibility (:) ! Zender et al. (2003b) dust source function (or soil erodibility) + contains + + ! !PUBLIC MEMBER FUNCTIONS: + procedure, public :: Init ! Initialize and read data in + procedure, public :: CalcDustSource ! Calculate dust source spatial filter (basically truncating stream data value smaller than 0.1 following CAM's practice) based on input streams + procedure, public :: UseStreams ! If streams will be used + + ! !PRIVATE MEMBER FUNCTIONS: + procedure, private :: InitAllocate ! Allocate data + + end type zendersoilerodstream_type + + ! ! PRIVATE DATA: + type, private :: streamcontrol_type + character(len=CL) :: stream_fldFileName_zendersoilerod ! data Filename + character(len=CL) :: stream_meshfile_zendersoilerod ! mesh Filename + character(len=CL) :: zendersoilerodmapalgo ! map algo + contains + procedure, private :: ReadNML ! Read in namelist + end type streamcontrol_type + + type(streamcontrol_type), private :: control ! Stream control data + + character(len=*), parameter, private :: sourcefile = & + __FILE__ + +!============================================================================== +contains +!============================================================================== + + subroutine Init(this, bounds, NLFilename) + ! + ! Initialize the prigent roughness stream object + ! + ! Uses: + use spmdMod , only : iam + use lnd_comp_shr , only : mesh, model_clock + use dshr_strdata_mod , only : shr_strdata_init_from_inline, shr_strdata_print + use dshr_strdata_mod , only : shr_strdata_advance + use dshr_methods_mod , only : dshr_fldbun_getfldptr + ! + ! arguments + implicit none + class(zendersoilerodstream_type) :: this + type(bounds_type), intent(in) :: bounds + character(len=*), intent(in) :: NLFilename ! Namelist filename + ! + ! local variables + integer :: ig, g, n ! Indices + integer :: year ! year (0, ...) for nstep+1 + integer :: mon ! month (1, ..., 12) for nstep+1 + integer :: day ! day of month (1, ..., 31) for nstep+1 + integer :: sec ! seconds into current date for nstep+1 + integer :: mcdate ! Current model date (yyyymmdd) + type(shr_strdata_type) :: sdat_erod ! input data stream + character(len=16), allocatable :: stream_varnames(:) ! array of stream field names + integer :: rc ! error code + real(r8), pointer :: dataptr1d(:) ! temporary pointer + character(len=*), parameter :: stream_name = 'zendersoilerod' + !----------------------------------------------------------------------- + + !if ( finundation_mtd /= finundation_mtd_h2osfc )then ! how should I change this? comment out for now + call this%InitAllocate( bounds ) + call control%ReadNML( bounds, NLFileName ) + + if ( this%useStreams() )then ! is this a namelist input and is it set in namelist default + + allocate(stream_varnames(1)) + stream_varnames = (/"mbl_bsn_fct_geo"/) ! varname in the dust source file; the variable is dimensionless + + if (masterproc) then + write(iulog,*) ' stream_varnames = ',stream_varnames + end if + + ! Initialize the cdeps data type sdat_erod + call shr_strdata_init_from_inline(sdat_erod, & ! what is this function and where does it come from? + my_task = iam, & + logunit = iulog, & + compname = 'LND', & + model_clock = model_clock, & + model_mesh = mesh, & + stream_meshfile = control%stream_meshfile_zendersoilerod, & + stream_lev_dimname = 'null', & + stream_mapalgo = control%zendersoilerodmapalgo, & + stream_filenames = (/trim(control%stream_fldFileName_zendersoilerod)/), & + stream_fldlistFile = stream_varnames, & + stream_fldListModel = stream_varnames, & + stream_yearFirst = 1997, & + stream_yearLast = 1997, & + stream_yearAlign = 1, & + stream_offset = 0, & + stream_taxmode = 'extend', & + stream_dtlimit = 1.0e30_r8, & + stream_tintalgo = 'linear', & + stream_name = 'Zender soil erodibility', & + rc = rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then + call ESMF_Finalize(endflag=ESMF_END_ABORT) + end if + + ! Explicitly set current date to a hardcoded constant value. Otherwise + ! using the real date can cause roundoff differences that are + ! detrected as issues with exact restart. EBK M05/20/2017 + ! call get_curr_date(year, mon, day, sec) + year = 2003 + mon = 12 + day = 31 + sec = 0 + mcdate = year*10000 + mon*100 + day + + call shr_strdata_advance(sdat_erod, ymd=mcdate, tod=sec, logunit=iulog, istr='zendersoilerod', rc=rc) ! what is istr and do I need to change elsewhere because the change of istr here + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then + call ESMF_Finalize(endflag=ESMF_END_ABORT) + end if + + ! Get pointer for stream data that is time and spatially interpolate to model time and grid + do n = 1,size(stream_varnames) + call dshr_fldbun_getFldPtr(sdat_erod%pstrm(1)%fldbun_model, stream_varnames(n), fldptr1=dataptr1d, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then + call ESMF_Finalize(endflag=ESMF_END_ABORT) + end if + if (trim(stream_varnames(n)) == 'mbl_bsn_fct_geo') then + ig = 0 + do g = bounds%begg,bounds%endg + ig = ig+1 ! not sure why +1 is needed but it's okay + this%soil_erodibility(g) = dataptr1d(ig) + end do + + end if + + end do + end if + !end if !comment out for now + + end subroutine Init + + !============================================================================== + logical function UseStreams(this) + ! + ! !DESCRIPTION: + ! Return true if + ! + ! !USES: + ! + ! !ARGUMENTS: + implicit none + class(zendersoilerodstream_type) :: this + ! + ! !LOCAL VARIABLES: + !if ( trim(control%stream_fldFileName_zendersoilerod) == '' .or. dust_emission_scheme == 'Leung2023')then + if ( trim(control%stream_fldFileName_zendersoilerod) == '')then + UseStreams = .false. + else + UseStreams = .true. + end if + end function UseStreams + + !============================================================================== + subroutine InitAllocate(this, bounds) + ! + ! !DESCRIPTION: + ! Allocate module variables and data structures + ! + ! !USES: + use shr_infnan_mod, only: nan => shr_infnan_nan, assignment(=) + ! + ! !ARGUMENTS: + implicit none + class(zendersoilerodstream_type) :: this + type(bounds_type), intent(in) :: bounds + ! + ! !LOCAL VARIABLES: + !integer :: begc, endc + integer :: begg, endg + !--------------------------------------------------------------------- + + !begc = bounds%begc; endc = bounds%endc + begg = bounds%begg; endg = bounds%endg + + allocate(this%soil_erodibility (begg:endg)) ; this%soil_erodibility (:) = nan + + end subroutine InitAllocate + + !============================================================================== + !subroutine CalcFinundated(this, bounds, num_soilc, filter_soilc, soilhydrology_inst, & + ! waterdiagnosticbulk_inst, qflx_surf_lag_col, finundated ) + !subroutine CalcDragPartition(this, bounds, num_nolakep, filter_nolakep, dpfct_rock) + subroutine CalcDustSource(this, bounds, soil_erod) + ! + ! !DESCRIPTION: + ! Commented below by dmleung 31 Dec 2022 + ! Calculate the drag partition effect of friction velocity due to surface roughness following + ! Leung et al. (2022). This module is used in the dust emission module DUSTMod.F90 for + ! calculating drag partitioning. The drag partition equation comes from Marticorena and + ! Bergametti (1995) with constants modified by Darmenova et al. (2009). Here it is assumed + ! that this equation is used only over arid/desertic regions, such that Catherine Prigent's + ! roughness measurements represents mostly rocks. For more vegetated areas, the vegetation + ! roughness and drag partitioning are calculated in the DustEmission subroutine. This + ! subroutine is used in the InitCold subroutine of DUSTMod.F90. + ! + ! !USES: + use ColumnType , only : col + !use PatchType , only : patch + !USES dmleung added 31 Dec 2022 + use landunit_varcon , only : istdlak + use LandunitType , only : lun + ! + ! !ARGUMENTS: + implicit none + class(zendersoilerodstream_type) :: this + type(bounds_type) , intent(in) :: bounds + real(r8) , intent(inout) :: soil_erod(bounds%begc:) ! [fraction] rock drag partition factor (roughness effect) + ! + ! !LOCAL VARIABLES: + !integer :: g, c, fc ! Indices + integer :: g, p, fp, l, c ! Indices + !real(r8) :: z0s ! smooth roughness length (m) + + ! constants + real(r8),parameter :: soil_erod_threshold = 0.1_r8 ! CAM soil erodibility threshold; below threshold -> soil_erod = 0_r8 11 Mar 2023 + !--------------------------------------------------------------------- + + SHR_ASSERT_ALL_FL((ubound(soil_erod) == (/bounds%endc/)), sourcefile, __LINE__) !what's the use of this + + !associate( & + !z => col%z & ! Input: [real(r8) (:,:) ] layer depth (m) (-nlevsno+1:nlevsoi) + !) + + + ! dmleung: this loop truncates soil erodibility values smaller than a threshold value (set as 0.1). We save the drag partition factor as a grid level quantity. + !do p = bounds%begp,bounds%endp + !g = patch%gridcell(p) + !l = patch%landunit(p) + do c = bounds%begc,bounds%endc + g = col%gridcell(c) + l = col%landunit(c) + if (lun%itype(l) /= istdlak) then ! not lake (can only be used during initialization) + + if (this%soil_erodibility(g) .lt. soil_erod_threshold ) then + soil_erod(c) = 0._r8 + else + soil_erod(c) = this%soil_erodibility(g) + end if + + end if + end do + + !end associate + + end subroutine CalcDustSource + + !============================================================================== + subroutine ReadNML(this, bounds, NLFilename) + ! + ! Read the namelist data stream information. + ! + ! Uses: + use shr_nl_mod , only : shr_nl_find_group_name + use shr_log_mod , only : errMsg => shr_log_errMsg + use shr_mpi_mod , only : shr_mpi_bcast + ! + ! arguments + implicit none + class(streamcontrol_type) :: this + type(bounds_type), intent(in) :: bounds + character(len=*), intent(in) :: NLFilename ! Namelist filename + ! + ! local variables + integer :: nu_nml ! unit for namelist file + integer :: nml_error ! namelist i/o error flag + character(len=CL) :: stream_fldFileName_zendersoilerod = ' ' + character(len=CL) :: stream_meshfile_zendersoilerod = ' ' + character(len=CL) :: zendersoilerodmapalgo = 'bilinear' + character(len=*), parameter :: namelist_name = 'zendersoilerod' ! MUST agree with group name in namelist definition to read. dmleung commented + character(len=*), parameter :: subName = "('zendersoilerod::ReadNML')" + !----------------------------------------------------------------------- + + namelist /zendersoilerod/ & ! MUST agree with namelist_name above + zendersoilerodmapalgo, stream_fldFileName_zendersoilerod, stream_meshfile_zendersoilerod + + ! Default values for namelist + + ! Read zenderdustsource namelist + if (masterproc) then + open( newunit=nu_nml, file=trim(NLFilename), status='old', iostat=nml_error ) + call shr_nl_find_group_name(nu_nml, namelist_name, status=nml_error) + if (nml_error == 0) then + read(nu_nml, nml=zendersoilerod, iostat=nml_error) ! MUST agree with namelist_name above + if (nml_error /= 0) then + call endrun(msg=' ERROR reading '//namelist_name//' namelist'//errMsg(sourcefile, __LINE__)) + end if + else + call endrun(msg=' ERROR finding '//namelist_name//' namelist'//errMsg(sourcefile, __LINE__)) + end if + close(nu_nml) + endif + + call shr_mpi_bcast(zendersoilerodmapalgo , mpicom) + call shr_mpi_bcast(stream_fldFileName_zendersoilerod , mpicom) + call shr_mpi_bcast(stream_meshfile_zendersoilerod , mpicom) + + if (masterproc) then + write(iulog,*) ' ' + write(iulog,*) namelist_name, ' stream settings:' + write(iulog,*) ' stream_fldFileName_zendersoilerod = ',stream_fldFileName_zendersoilerod + write(iulog,*) ' stream_meshfile_zendersoilerod = ',stream_meshfile_zendersoilerod + write(iulog,*) ' zendersoilerodmapalgo = ',zendersoilerodmapalgo + endif + this%stream_fldFileName_zendersoilerod = stream_fldFileName_zendersoilerod + this%stream_meshfile_zendersoilerod = stream_meshfile_zendersoilerod + this%zendersoilerodmapalgo = zendersoilerodmapalgo + + end subroutine ReadNML + +end module ZenderSoilErodStreamType diff --git a/src/main/clm_instMod.F90 b/src/main/clm_instMod.F90 index 7924c2111e..795c780f40 100644 --- a/src/main/clm_instMod.F90 +++ b/src/main/clm_instMod.F90 @@ -340,7 +340,7 @@ subroutine clm_instInit(bounds) call surfrad_inst%Init(bounds) - call dust_inst%Init(bounds) + call dust_inst%Init(bounds, NLFilename) ! dmleung added NLFilename 11 Mar 2023 allocate(scf_method, source = CreateAndInitSnowCoverFraction( & snow_cover_fraction_method = snow_cover_fraction_method, & From 2c9974c6255080ab6a8930eb05c9461b8c039898 Mon Sep 17 00:00:00 2001 From: "Danny M. Leung" Date: Tue, 21 Mar 2023 15:44:10 -0600 Subject: [PATCH 02/40] first commit on adding a global tuning factor to tune global total dust emission (dmleung 20 Mar 2023) --- bld/CLMBuildNamelist.pm | 3 +- bld/namelist_files/namelist_defaults_ctsm.xml | 2 +- .../namelist_definition_ctsm.xml | 5 +++ src/biogeochem/DUSTMod.F90 | 41 ++++++++++++++++--- .../share_esmf/ZenderSoilErodStreamType.F90 | 4 +- 5 files changed, 45 insertions(+), 10 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index a5abc00671..3900265ac6 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4245,7 +4245,8 @@ sub write_output_files { push @groups, "ch4finundated"; push @groups, "soilbgc_decomp"; push @groups, "clm_canopy_inparm"; - push @groups, "zendersoilerod"; # dmleung 11 Mar 2023 + push @groups, "zendersoilerod"; # dmleung added 11 Mar 2023 + push @groups, "dust_nl"; # dmleung added 11 Mar 2023 if (remove_leading_and_trailing_quotes($nl->get_value('snow_cover_fraction_method')) eq 'SwensonLawrence2012') { push @groups, "scf_swenson_lawrence_2012_inparm"; } diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 4ee9d1f92e..9703ae99e7 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2545,7 +2545,7 @@ lnd/clm2/surfdata_map/release-clm5.0.30/surfdata_ne0np4.CONUS.ne30x8_hist_78pfts /gpfs/fs1/work/dleung/Zender_dust_source/dst_source2x2tunedcam6-2x2-forCLM_c230311.nc +>/gpfs/fs1/work/dleung/Zender_dust_source/cdf5_dst_source2x2tunedcam6-2x2-forCLM_c230311.nc /gpfs/fs1/work/dleung/Zender_dust_source/lnd_mesh.nc diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index bd5fd05a48..dca70b1628 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -1698,6 +1698,11 @@ Mapping method from Nitrogen deposition input file to the model resolution + +Tuning parameter for dust emissions. + + Filename of input stream data for Zender's soil erodibility source function diff --git a/src/biogeochem/DUSTMod.F90 b/src/biogeochem/DUSTMod.F90 index bae61fd430..c5fda3c23b 100644 --- a/src/biogeochem/DUSTMod.F90 +++ b/src/biogeochem/DUSTMod.F90 @@ -31,6 +31,7 @@ module DUSTMod use ColumnType , only : col use PatchType , only : patch use ZenderSoilErodStreamType, only : zendersoilerodstream_type ! dmleung added 11 Mar 2023 + use spmdMod , only : masterproc, mpicom, MPI_REAL8 ! dmleung added 11 Mar 2023 ! ! !PUBLIC TYPES implicit none @@ -48,6 +49,7 @@ module DUSTMod real(r8) , allocatable :: stk_crc(:) ![frc] Correction to Stokes settling velocity real(r8) tmp1 !Factor in saltation computation (named as in Charlie's code) real(r8) dns_aer ![kg m-3] Aerosol density + real(r8) dust_emis_fact ! dmleung added 11 Mar 2023 ! ! !PUBLIC DATA TYPES: ! @@ -119,7 +121,7 @@ subroutine InitAllocate(this, bounds) allocate(this%vlc_trb_2_patch (begp:endp)) ; this%vlc_trb_2_patch (:) = nan allocate(this%vlc_trb_3_patch (begp:endp)) ; this%vlc_trb_3_patch (:) = nan allocate(this%vlc_trb_4_patch (begp:endp)) ; this%vlc_trb_4_patch (:) = nan - allocate(this%mbl_bsn_fct_col (begc:endc)) ; this%mbl_bsn_fct_col (:) = nan + allocate(this%mbl_bsn_fct_col (begc:endc)) ; this%mbl_bsn_fct_col (:) = nan end subroutine InitAllocate @@ -168,10 +170,10 @@ subroutine InitHistory(this, bounds) ptr_patch=this%vlc_trb_4_patch, default='inactive') !#####added by dmleung 11 Mar 2023 ######################################## - this%mbl_bsn_fct_col(begc:endc) = spval - call hist_addfld1d (fname='LND_MBL', units='fraction', & - avgflag='A', long_name='Soil erodibility factor', & - ptr_col=this%mbl_bsn_fct_col) + !this%mbl_bsn_fct_col(begc:endc) = spval + !call hist_addfld1d (fname='LND_MBL', units='fraction', & + ! avgflag='A', long_name='Soil erodibility factor', & + ! ptr_col=this%mbl_bsn_fct_col) !########################################################################## end subroutine InitHistory @@ -185,8 +187,34 @@ subroutine InitCold(this, bounds) ! ! !LOCAL VARIABLES: integer :: c,l + integer ier ! error code, dmleung added 11 Mar 2023 !----------------------------------------------------------------------- + !#### dmleung added 11 Mar 2023 #################################### + ! read in global tuning factor from namelist + namelist /dust_nl/ dust_emis_fact + ! Default values for namelist + dust_emis_fact = 1 + ! Read soilm_streams namelist + !if (masterproc) then + ! open( newunit=nu_nml, file=trim(NLFilename), status='old', iostat=nml_error ) + ! call find_nlgroup_name(nu_nml, 'dust_nl', status=nml_error) + ! if (nml_error == 0) then + ! read(nu_nml, nml=dust_nl,iostat=nml_error) + ! if (nml_error /= 0) then + ! call endrun(subname // ':: ERROR reading dust_nl namelist') + ! end if + ! else + ! call endrun(subname // ':: ERROR finding dust_nl namelist') + ! end if + ! close(nu_nml) + !endif + !call shr_mpi_bcast(dust_emis_fact, mpicom) + call mpi_bcast (dust_emis_fact, 1, MPI_REAL8,0, mpicom, ier) + if (masterproc) then + write(iulog,*) ' dust_emis_fact = ',dust_emis_fact + end if + ! Set basin factor to 1 for now !if (dust_emission_scheme == 'Leung2023') @@ -456,7 +484,8 @@ subroutine DustEmission (bounds, & ! integrated streamwise mass flux dst_slt_flx_rat_ttl = 100.0_r8 * exp( log(10.0_r8) * (13.4_r8 * mss_frc_cly_vld(c) - 6.0_r8) ) - flx_mss_vrt_dst_ttl(p) = flx_mss_hrz_slt_ttl * dst_slt_flx_rat_ttl + !flx_mss_vrt_dst_ttl(p) = flx_mss_hrz_slt_ttl * dst_slt_flx_rat_ttl + flx_mss_vrt_dst_ttl(p) = flx_mss_hrz_slt_ttl * dst_slt_flx_rat_ttl / dust_emis_fact ! dmleung added 11 Mar 2023 end if ! lnd_frc_mbl > 0.0 diff --git a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 index ab7d71a24f..5b93a62f38 100644 --- a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 +++ b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 @@ -116,8 +116,8 @@ subroutine Init(this, bounds, NLFilename) stream_filenames = (/trim(control%stream_fldFileName_zendersoilerod)/), & stream_fldlistFile = stream_varnames, & stream_fldListModel = stream_varnames, & - stream_yearFirst = 1997, & - stream_yearLast = 1997, & + stream_yearFirst = 2003, & + stream_yearLast = 2003, & stream_yearAlign = 1, & stream_offset = 0, & stream_taxmode = 'extend', & From 4f5dcb95366950669f6ba265e28a095f5f5686af Mon Sep 17 00:00:00 2001 From: "Danny M. Leung" Date: Wed, 5 Apr 2023 13:02:29 -0600 Subject: [PATCH 03/40] After discussing with CAM people, I took away the lines relevant to the global tuning factor. We will keep the global tuning factor in CAM. dmleung 5 Apr 2023 --- bld/CLMBuildNamelist.pm | 2 +- .../namelist_definition_ctsm.xml | 8 +++---- src/biogeochem/DUSTMod.F90 | 22 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 3900265ac6..f8fff880fb 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4246,7 +4246,7 @@ sub write_output_files { push @groups, "soilbgc_decomp"; push @groups, "clm_canopy_inparm"; push @groups, "zendersoilerod"; # dmleung added 11 Mar 2023 - push @groups, "dust_nl"; # dmleung added 11 Mar 2023 + #push @groups, "dust_nl"; # dmleung added 11 Mar 2023 if (remove_leading_and_trailing_quotes($nl->get_value('snow_cover_fraction_method')) eq 'SwensonLawrence2012') { push @groups, "scf_swenson_lawrence_2012_inparm"; } diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index dca70b1628..8a7b03fd19 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -1698,10 +1698,10 @@ Mapping method from Nitrogen deposition input file to the model resolution - -Tuning parameter for dust emissions. - + + + + diff --git a/src/biogeochem/DUSTMod.F90 b/src/biogeochem/DUSTMod.F90 index c5fda3c23b..a730a0eba1 100644 --- a/src/biogeochem/DUSTMod.F90 +++ b/src/biogeochem/DUSTMod.F90 @@ -31,7 +31,7 @@ module DUSTMod use ColumnType , only : col use PatchType , only : patch use ZenderSoilErodStreamType, only : zendersoilerodstream_type ! dmleung added 11 Mar 2023 - use spmdMod , only : masterproc, mpicom, MPI_REAL8 ! dmleung added 11 Mar 2023 + !use spmdMod , only : masterproc, mpicom, MPI_REAL8 ! dmleung added 11 Mar 2023 ! ! !PUBLIC TYPES implicit none @@ -49,7 +49,7 @@ module DUSTMod real(r8) , allocatable :: stk_crc(:) ![frc] Correction to Stokes settling velocity real(r8) tmp1 !Factor in saltation computation (named as in Charlie's code) real(r8) dns_aer ![kg m-3] Aerosol density - real(r8) dust_emis_fact ! dmleung added 11 Mar 2023 + !real(r8) dust_emis_fact ! dmleung added 11 Mar 2023 ! ! !PUBLIC DATA TYPES: ! @@ -187,14 +187,14 @@ subroutine InitCold(this, bounds) ! ! !LOCAL VARIABLES: integer :: c,l - integer ier ! error code, dmleung added 11 Mar 2023 + !integer ier ! error code, dmleung added 11 Mar 2023 !----------------------------------------------------------------------- !#### dmleung added 11 Mar 2023 #################################### ! read in global tuning factor from namelist - namelist /dust_nl/ dust_emis_fact + !namelist /dust_nl/ dust_emis_fact ! Default values for namelist - dust_emis_fact = 1 + !dust_emis_fact = 1 ! Read soilm_streams namelist !if (masterproc) then ! open( newunit=nu_nml, file=trim(NLFilename), status='old', iostat=nml_error ) @@ -210,10 +210,10 @@ subroutine InitCold(this, bounds) ! close(nu_nml) !endif !call shr_mpi_bcast(dust_emis_fact, mpicom) - call mpi_bcast (dust_emis_fact, 1, MPI_REAL8,0, mpicom, ier) - if (masterproc) then - write(iulog,*) ' dust_emis_fact = ',dust_emis_fact - end if + !call mpi_bcast (dust_emis_fact, 1, MPI_REAL8,0, mpicom, ier) + !if (masterproc) then + ! write(iulog,*) ' dust_emis_fact = ',dust_emis_fact + !end if ! Set basin factor to 1 for now @@ -484,8 +484,8 @@ subroutine DustEmission (bounds, & ! integrated streamwise mass flux dst_slt_flx_rat_ttl = 100.0_r8 * exp( log(10.0_r8) * (13.4_r8 * mss_frc_cly_vld(c) - 6.0_r8) ) - !flx_mss_vrt_dst_ttl(p) = flx_mss_hrz_slt_ttl * dst_slt_flx_rat_ttl - flx_mss_vrt_dst_ttl(p) = flx_mss_hrz_slt_ttl * dst_slt_flx_rat_ttl / dust_emis_fact ! dmleung added 11 Mar 2023 + flx_mss_vrt_dst_ttl(p) = flx_mss_hrz_slt_ttl * dst_slt_flx_rat_ttl + !flx_mss_vrt_dst_ttl(p) = flx_mss_hrz_slt_ttl * dst_slt_flx_rat_ttl / dust_emis_fact ! dmleung added 11 Mar 2023 end if ! lnd_frc_mbl > 0.0 From f4dde3d623e517013ffcba549c3a65b3910614eb Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 23 Jun 2023 13:18:55 -0600 Subject: [PATCH 04/40] Remove most of the comments that mention dmleung, changes will be stored in git --- bld/CLMBuildNamelist.pm | 9 ++++---- bld/namelist_files/namelist_defaults_ctsm.xml | 2 -- .../namelist_definition_ctsm.xml | 3 +-- src/biogeochem/DUSTMod.F90 | 22 +++++++------------ .../share_esmf/ZenderSoilErodStreamType.F90 | 8 ++----- src/main/clm_instMod.F90 | 2 +- 6 files changed, 17 insertions(+), 29 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index b99a86bbc2..b28dc54814 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -1560,7 +1560,7 @@ sub process_namelist_inline_logic { setup_logic_snowpack($opts, $nl_flags, $definition, $defaults, $nl); setup_logic_fates($opts, $nl_flags, $definition, $defaults, $nl); setup_logic_misc($opts, $nl_flags, $definition, $defaults, $nl); - setup_logic_zender_soilerod($opts, $nl_flags, $definition, $defaults, $nl); # dmleung added 11 Mar 2023 + setup_logic_zender_soilerod($opts, $nl_flags, $definition, $defaults, $nl); ######################################### # namelist group: atm2lnd_inparm @@ -4247,7 +4247,9 @@ sub setup_logic_misc { #------------------------------------------------------------------------------- sub setup_logic_zender_soilerod { - # dmleung added on 31 Dec 2022 for reading Prigent's roughness stream file + # + # Handle the Zender soil eroditability file + # my ($opts, $nl_flags, $definition, $defaults, $nl) = @_; add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_zendersoilerod' ); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_meshfile_zendersoilerod' ); @@ -4303,8 +4305,7 @@ sub write_output_files { push @groups, "ch4finundated"; push @groups, "soilbgc_decomp"; push @groups, "clm_canopy_inparm"; - push @groups, "zendersoilerod"; # dmleung added 11 Mar 2023 - #push @groups, "dust_nl"; # dmleung added 11 Mar 2023 + push @groups, "zendersoilerod"; if (remove_leading_and_trailing_quotes($nl->get_value('snow_cover_fraction_method')) eq 'SwensonLawrence2012') { push @groups, "scf_swenson_lawrence_2012_inparm"; } diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 84cc77e53c..f4dc483d17 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2540,8 +2540,6 @@ lnd/clm2/surfdata_map/release-clm5.0.30/surfdata_ne0np4.CONUS.ne30x8_hist_78pfts - - - - + diff --git a/src/biogeochem/DUSTMod.F90 b/src/biogeochem/DUSTMod.F90 index a730a0eba1..8ef0bbbd7c 100644 --- a/src/biogeochem/DUSTMod.F90 +++ b/src/biogeochem/DUSTMod.F90 @@ -30,8 +30,7 @@ module DUSTMod use LandunitType , only : lun use ColumnType , only : col use PatchType , only : patch - use ZenderSoilErodStreamType, only : zendersoilerodstream_type ! dmleung added 11 Mar 2023 - !use spmdMod , only : masterproc, mpicom, MPI_REAL8 ! dmleung added 11 Mar 2023 + use ZenderSoilErodStreamType, only : zendersoilerodstream_type ! ! !PUBLIC TYPES implicit none @@ -49,7 +48,6 @@ module DUSTMod real(r8) , allocatable :: stk_crc(:) ![frc] Correction to Stokes settling velocity real(r8) tmp1 !Factor in saltation computation (named as in Charlie's code) real(r8) dns_aer ![kg m-3] Aerosol density - !real(r8) dust_emis_fact ! dmleung added 11 Mar 2023 ! ! !PUBLIC DATA TYPES: ! @@ -62,8 +60,7 @@ module DUSTMod real(r8), pointer, private :: vlc_trb_2_patch (:) ! turbulent deposition velocity 2(m/s) real(r8), pointer, private :: vlc_trb_3_patch (:) ! turbulent deposition velocity 3(m/s) real(r8), pointer, private :: vlc_trb_4_patch (:) ! turbulent deposition velocity 4(m/s) - !########### added by dmleung 11 Mar 2023 ######################################################################## - type(zendersoilerodstream_type), private :: zendersoilerodstream ! Zender soil erodibility stream data + type(zendersoilerodstream_type), private :: zendersoilerodstream ! Zender soil erodibility stream data real(r8), pointer, private :: mbl_bsn_fct_col (:) ! [dimensionless] basin factor, or soil erodibility, time-constant contains @@ -84,16 +81,15 @@ module DUSTMod !------------------------------------------------------------------------ !subroutine Init(this, bounds) - !##### dmleung edited for initializing stream files 11 Mar 2023 ######## subroutine Init(this, bounds, NLFilename) class(dust_type) :: this type(bounds_type), intent(in) :: bounds - character(len=*), intent(in) :: NLFilename ! dmleung added 11 Mar 2023 + character(len=*), intent(in) :: NLFilename call this%InitAllocate (bounds) call this%InitHistory (bounds) - call this%zendersoilerodstream%Init( bounds, NLFilename ) ! dmleung added 11 Mar 2023 + call this%zendersoilerodstream%Init( bounds, NLFilename ) call this%InitCold (bounds) call this%InitDustVars (bounds) @@ -138,7 +134,7 @@ subroutine InitHistory(this, bounds) ! ! !LOCAL VARIABLES: integer :: begp,endp - integer :: begc,endc ! dmleung added 11 Mar 2023 + integer :: begc,endc !------------------------------------------------------------------------ begp = bounds%begp; endp = bounds%endp @@ -169,12 +165,10 @@ subroutine InitHistory(this, bounds) avgflag='A', long_name='turbulent deposition velocity 4', & ptr_patch=this%vlc_trb_4_patch, default='inactive') - !#####added by dmleung 11 Mar 2023 ######################################## !this%mbl_bsn_fct_col(begc:endc) = spval !call hist_addfld1d (fname='LND_MBL', units='fraction', & ! avgflag='A', long_name='Soil erodibility factor', & ! ptr_col=this%mbl_bsn_fct_col) - !########################################################################## end subroutine InitHistory @@ -187,7 +181,7 @@ subroutine InitCold(this, bounds) ! ! !LOCAL VARIABLES: integer :: c,l - !integer ier ! error code, dmleung added 11 Mar 2023 + !integer ier !----------------------------------------------------------------------- !#### dmleung added 11 Mar 2023 #################################### @@ -311,7 +305,7 @@ subroutine DustEmission (bounds, & fv => frictionvel_inst%fv_patch , & ! Input: [real(r8) (:) ] friction velocity (m/s) (for dust model) u10 => frictionvel_inst%u10_patch , & ! Input: [real(r8) (:) ] 10-m wind (m/s) (created for dust model) - mbl_bsn_fct => dust_inst%mbl_bsn_fct_col , & ! Input: [real(r8) (:) ] basin factor ; dmleung changed the value in InitCold 11 Mar 2023 + mbl_bsn_fct => dust_inst%mbl_bsn_fct_col , & ! Input: [real(r8) (:) ] basin factor flx_mss_vrt_dst => dust_inst%flx_mss_vrt_dst_patch , & ! Output: [real(r8) (:,:) ] surface dust emission (kg/m**2/s) flx_mss_vrt_dst_tot => dust_inst%flx_mss_vrt_dst_tot_patch & ! Output: [real(r8) (:) ] total dust flux back to atmosphere (pft) ) @@ -485,7 +479,7 @@ subroutine DustEmission (bounds, & dst_slt_flx_rat_ttl = 100.0_r8 * exp( log(10.0_r8) * (13.4_r8 * mss_frc_cly_vld(c) - 6.0_r8) ) flx_mss_vrt_dst_ttl(p) = flx_mss_hrz_slt_ttl * dst_slt_flx_rat_ttl - !flx_mss_vrt_dst_ttl(p) = flx_mss_hrz_slt_ttl * dst_slt_flx_rat_ttl / dust_emis_fact ! dmleung added 11 Mar 2023 + !flx_mss_vrt_dst_ttl(p) = flx_mss_hrz_slt_ttl * dst_slt_flx_rat_ttl / dust_emis_fact end if ! lnd_frc_mbl > 0.0 diff --git a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 index 5b93a62f38..dfa6705275 100644 --- a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 +++ b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 @@ -1,5 +1,4 @@ module ZenderSoilErodStreamType -!dmleung modified based on PrigetnRoughnessStreamType.F90 on 11 Mar 2023 #include "shr_assert.h" ! What is this? In many modules but not dust module !----------------------------------------------------------------------- @@ -232,7 +231,7 @@ subroutine CalcDustSource(this, bounds, soil_erod) ! !USES: use ColumnType , only : col !use PatchType , only : patch - !USES dmleung added 31 Dec 2022 + !USES use landunit_varcon , only : istdlak use LandunitType , only : lun ! @@ -259,9 +258,6 @@ subroutine CalcDustSource(this, bounds, soil_erod) ! dmleung: this loop truncates soil erodibility values smaller than a threshold value (set as 0.1). We save the drag partition factor as a grid level quantity. - !do p = bounds%begp,bounds%endp - !g = patch%gridcell(p) - !l = patch%landunit(p) do c = bounds%begc,bounds%endc g = col%gridcell(c) l = col%landunit(c) @@ -302,7 +298,7 @@ subroutine ReadNML(this, bounds, NLFilename) character(len=CL) :: stream_fldFileName_zendersoilerod = ' ' character(len=CL) :: stream_meshfile_zendersoilerod = ' ' character(len=CL) :: zendersoilerodmapalgo = 'bilinear' - character(len=*), parameter :: namelist_name = 'zendersoilerod' ! MUST agree with group name in namelist definition to read. dmleung commented + character(len=*), parameter :: namelist_name = 'zendersoilerod' ! MUST agree with group name in namelist definition to read. character(len=*), parameter :: subName = "('zendersoilerod::ReadNML')" !----------------------------------------------------------------------- diff --git a/src/main/clm_instMod.F90 b/src/main/clm_instMod.F90 index 795c780f40..099959581f 100644 --- a/src/main/clm_instMod.F90 +++ b/src/main/clm_instMod.F90 @@ -340,7 +340,7 @@ subroutine clm_instInit(bounds) call surfrad_inst%Init(bounds) - call dust_inst%Init(bounds, NLFilename) ! dmleung added NLFilename 11 Mar 2023 + call dust_inst%Init(bounds, NLFilename) allocate(scf_method, source = CreateAndInitSnowCoverFraction( & snow_cover_fraction_method = snow_cover_fraction_method, & From 2a2caf14962f202009ec1e83bbe2255d78de1e97 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Sun, 30 Jul 2023 19:26:12 -0600 Subject: [PATCH 05/40] Move files into inputdata, and nccopy mesh file from NetCDF4 to CDF5 --- bld/namelist_files/namelist_defaults_ctsm.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index f4dc483d17..848a5e510c 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2543,9 +2543,9 @@ lnd/clm2/surfdata_map/release-clm5.0.30/surfdata_ne0np4.CONUS.ne30x8_hist_78pfts /gpfs/fs1/work/dleung/Zender_dust_source/cdf5_dst_source2x2tunedcam6-2x2-forCLM_c230311.nc +>lnd/clm2/dustemisdata/dst_source2x2tunedcam6-2x2-forCLM_cdf5_c230312.nc /gpfs/fs1/work/dleung/Zender_dust_source/lnd_mesh.nc +>lnd/clm2/dustemisdata/dust_2x2_ESMFmesh_cdf5_c230730.nc From 35b1f4ad139aeefecd9bba9c69a31199a2181a6a Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Sun, 30 Jul 2023 19:34:46 -0600 Subject: [PATCH 06/40] Change ESMF Finalize to endrun, add more clarity on what's happening on exit --- src/cpl/share_esmf/ZenderSoilErodStreamType.F90 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 index dfa6705275..032469acfc 100644 --- a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 +++ b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 @@ -95,11 +95,12 @@ subroutine Init(this, bounds, NLFilename) if ( this%useStreams() )then ! is this a namelist input and is it set in namelist default - allocate(stream_varnames(1)) - stream_varnames = (/"mbl_bsn_fct_geo"/) ! varname in the dust source file; the variable is dimensionless + allocate(stream_varnames(1)) + stream_varnames = (/"mbl_bsn_fct_geo"/) ! varname in the dust source file; the variable is dimensionless if (masterproc) then write(iulog,*) ' stream_varnames = ',stream_varnames + flush(iulog) end if ! Initialize the cdeps data type sdat_erod @@ -125,7 +126,8 @@ subroutine Init(this, bounds, NLFilename) stream_name = 'Zender soil erodibility', & rc = rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then - call ESMF_Finalize(endflag=ESMF_END_ABORT) + write(iulog,*) 'Error on stream initialize -- see PET*.ESMF_LogFile(s)' + call endrun("ESMF log error") end if ! Explicitly set current date to a hardcoded constant value. Otherwise @@ -140,14 +142,16 @@ subroutine Init(this, bounds, NLFilename) call shr_strdata_advance(sdat_erod, ymd=mcdate, tod=sec, logunit=iulog, istr='zendersoilerod', rc=rc) ! what is istr and do I need to change elsewhere because the change of istr here if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then - call ESMF_Finalize(endflag=ESMF_END_ABORT) + write(iulog,*) 'Error on stream advance -- see PET*.ESMF_LogFile(s)' + call endrun("ESMF log error") end if ! Get pointer for stream data that is time and spatially interpolate to model time and grid do n = 1,size(stream_varnames) call dshr_fldbun_getFldPtr(sdat_erod%pstrm(1)%fldbun_model, stream_varnames(n), fldptr1=dataptr1d, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then - call ESMF_Finalize(endflag=ESMF_END_ABORT) + write(iulog,*) 'Error on get field pointer -- see PET*.ESMF_LogFile(s)' + call endrun("ESMF log error") end if if (trim(stream_varnames(n)) == 'mbl_bsn_fct_geo') then ig = 0 From a27f6f519ebb8dc83e7aa25227f8ce0057a79634 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 18 Aug 2023 11:09:19 -0600 Subject: [PATCH 07/40] Some updates from the review, this compiles, but fails to run when it gets to the soil eroditability file --- .../share_esmf/ZenderSoilErodStreamType.F90 | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 index 032469acfc..8993722115 100644 --- a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 +++ b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 @@ -1,5 +1,5 @@ module ZenderSoilErodStreamType -#include "shr_assert.h" ! What is this? In many modules but not dust module +#include "shr_assert.h" !----------------------------------------------------------------------- ! !DESCRIPTION: @@ -172,7 +172,8 @@ end subroutine Init logical function UseStreams(this) ! ! !DESCRIPTION: - ! Return true if + ! Return true if the Zender method is being used and the soil erodability + ! file is being used with it ! ! !USES: ! @@ -216,21 +217,10 @@ subroutine InitAllocate(this, bounds) end subroutine InitAllocate !============================================================================== - !subroutine CalcFinundated(this, bounds, num_soilc, filter_soilc, soilhydrology_inst, & - ! waterdiagnosticbulk_inst, qflx_surf_lag_col, finundated ) - !subroutine CalcDragPartition(this, bounds, num_nolakep, filter_nolakep, dpfct_rock) subroutine CalcDustSource(this, bounds, soil_erod) ! ! !DESCRIPTION: - ! Commented below by dmleung 31 Dec 2022 - ! Calculate the drag partition effect of friction velocity due to surface roughness following - ! Leung et al. (2022). This module is used in the dust emission module DUSTMod.F90 for - ! calculating drag partitioning. The drag partition equation comes from Marticorena and - ! Bergametti (1995) with constants modified by Darmenova et al. (2009). Here it is assumed - ! that this equation is used only over arid/desertic regions, such that Catherine Prigent's - ! roughness measurements represents mostly rocks. For more vegetated areas, the vegetation - ! roughness and drag partitioning are calculated in the DustEmission subroutine. This - ! subroutine is used in the InitCold subroutine of DUSTMod.F90. + ! Calculate the soil eroditability for the Zender dust method. ! ! !USES: use ColumnType , only : col @@ -254,7 +244,7 @@ subroutine CalcDustSource(this, bounds, soil_erod) real(r8),parameter :: soil_erod_threshold = 0.1_r8 ! CAM soil erodibility threshold; below threshold -> soil_erod = 0_r8 11 Mar 2023 !--------------------------------------------------------------------- - SHR_ASSERT_ALL_FL((ubound(soil_erod) == (/bounds%endc/)), sourcefile, __LINE__) !what's the use of this + SHR_ASSERT_ALL_FL((ubound(soil_erod) == (/bounds%endc/)), sourcefile, __LINE__) !associate( & !z => col%z & ! Input: [real(r8) (:,:) ] layer depth (m) (-nlevsno+1:nlevsoi) @@ -283,7 +273,8 @@ end subroutine CalcDustSource !============================================================================== subroutine ReadNML(this, bounds, NLFilename) ! - ! Read the namelist data stream information. + ! Read the namelist data stream information for the Zender method soil + ! eroditability file ! ! Uses: use shr_nl_mod , only : shr_nl_find_group_name From cb81fdb1ee40de0de9f538974d2a3042ca369940 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 18 Aug 2023 17:53:41 -0600 Subject: [PATCH 08/40] Remove dust_emis_fact as that will stay inside of CAM --- .../namelist_definition_ctsm.xml | 5 --- src/biogeochem/DUSTMod.F90 | 37 +++---------------- 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 7e2edd7f80..633d5b6437 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -1697,11 +1697,6 @@ Mapping method from Nitrogen deposition input file to the model resolution - - - - - Filename of input stream data for Zender's soil erodibility source function diff --git a/src/biogeochem/DUSTMod.F90 b/src/biogeochem/DUSTMod.F90 index 8ef0bbbd7c..485086203b 100644 --- a/src/biogeochem/DUSTMod.F90 +++ b/src/biogeochem/DUSTMod.F90 @@ -165,10 +165,12 @@ subroutine InitHistory(this, bounds) avgflag='A', long_name='turbulent deposition velocity 4', & ptr_patch=this%vlc_trb_4_patch, default='inactive') - !this%mbl_bsn_fct_col(begc:endc) = spval - !call hist_addfld1d (fname='LND_MBL', units='fraction', & - ! avgflag='A', long_name='Soil erodibility factor', & - ! ptr_col=this%mbl_bsn_fct_col) + ! if Zender + this%mbl_bsn_fct_col(begc:endc) = spval + call hist_addfld1d (fname='LND_MBL', units='fraction', & + avgflag='A', long_name='Soil erodibility factor', & + ptr_col=this%mbl_bsn_fct_col, default='inactive') + ! end if end subroutine InitHistory @@ -181,34 +183,8 @@ subroutine InitCold(this, bounds) ! ! !LOCAL VARIABLES: integer :: c,l - !integer ier !----------------------------------------------------------------------- - !#### dmleung added 11 Mar 2023 #################################### - ! read in global tuning factor from namelist - !namelist /dust_nl/ dust_emis_fact - ! Default values for namelist - !dust_emis_fact = 1 - ! Read soilm_streams namelist - !if (masterproc) then - ! open( newunit=nu_nml, file=trim(NLFilename), status='old', iostat=nml_error ) - ! call find_nlgroup_name(nu_nml, 'dust_nl', status=nml_error) - ! if (nml_error == 0) then - ! read(nu_nml, nml=dust_nl,iostat=nml_error) - ! if (nml_error /= 0) then - ! call endrun(subname // ':: ERROR reading dust_nl namelist') - ! end if - ! else - ! call endrun(subname // ':: ERROR finding dust_nl namelist') - ! end if - ! close(nu_nml) - !endif - !call shr_mpi_bcast(dust_emis_fact, mpicom) - !call mpi_bcast (dust_emis_fact, 1, MPI_REAL8,0, mpicom, ier) - !if (masterproc) then - ! write(iulog,*) ' dust_emis_fact = ',dust_emis_fact - !end if - ! Set basin factor to 1 for now !if (dust_emission_scheme == 'Leung2023') @@ -479,7 +455,6 @@ subroutine DustEmission (bounds, & dst_slt_flx_rat_ttl = 100.0_r8 * exp( log(10.0_r8) * (13.4_r8 * mss_frc_cly_vld(c) - 6.0_r8) ) flx_mss_vrt_dst_ttl(p) = flx_mss_hrz_slt_ttl * dst_slt_flx_rat_ttl - !flx_mss_vrt_dst_ttl(p) = flx_mss_hrz_slt_ttl * dst_slt_flx_rat_ttl / dust_emis_fact end if ! lnd_frc_mbl > 0.0 From 019282a63a41616ae1a43819ab89c1fb4e8e46c0 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 21 Aug 2023 01:03:31 -0600 Subject: [PATCH 09/40] Add lnd_tuning modes for CAM4.0 and CAM5.0 for all CLM physics options and add tests for it that currently fail --- bld/namelist_files/namelist_definition_ctsm.xml | 2 +- bld/unit_testers/build-namelist_test.pl | 8 ++++---- cime_config/config_component.xml | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 633d5b6437..69d9a5c278 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -2057,7 +2057,7 @@ Land mask description + valid_values="clm4_5_CRUv7,clm4_5_GSWP3v1,clm4_5_cam6.0,clm4_5_cam5.0,clm4_5_cam4.0,clm5_0_cam6.0,clm5_0_cam5.0,clm5.0_cam4.0,clm5_0_CRUv7,clm5_0_GSWP3v1,clm5_1_GSWP3v1,clm5_1_cam6.0,clm5_1_cam5.0,clm5_1_cam4.0"> General configuration of model version and atmospheric forcing to tune the model to run under. This sets the model to run with constants and initial conditions that were set to run well under the configuration of model version and atmospheric forcing. To run well constants would need to be changed diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 79add93d88..524a23a402 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -163,9 +163,9 @@ sub cat_and_create_namelistinfile { # # Figure out number of tests that will run # -my $ntests = 1850; +my $ntests = 1922; if ( defined($opts{'compare'}) ) { - $ntests += 1254; + $ntests += 1308; } plan( tests=>$ntests ); @@ -1631,9 +1631,9 @@ sub cat_and_create_namelistinfile { &make_config_cache($phys); my @forclist = (); if ( $phys == "clm5_1" ) { - @forclist = ( "GSWP3v1" ); + @forclist = ( "GSWP3v1", "cam6.0", "cam5.0", "cam4.0" ); } else { - @forclist = ( "CRUv7", "GSWP3v1", "cam6.0" ); + @forclist = ( "CRUv7", "GSWP3v1", "cam6.0", "cam5.0", "cam4.0" ); } foreach my $forc ( @forclist ) { foreach my $bgc ( "sp", "bgc" ) { diff --git a/cime_config/config_component.xml b/cime_config/config_component.xml index 555a0ce9b5..66ccc400f9 100644 --- a/cime_config/config_component.xml +++ b/cime_config/config_component.xml @@ -63,18 +63,28 @@ Tuning parameters and initial conditions should be optimized for what CLM model version and what meteorlogical forcing combination? UNSET - clm5_0_cam6.0,clm5_0_GSWP3v1,clm5_0_CRUv7,clm4_5_CRUv7,clm4_5_GSWP3v1,clm4_5_cam6.0,clm5_1_GSWP3v1 + clm5_0_cam6.0,clm5.0_cam5.0,clm5.0_cam4.0,clm5_0_GSWP3v1,clm5_0_CRUv7,clm4_5_CRUv7,clm4_5_GSWP3v1,clm4_5_cam6.0,clm4_5_cam5.0,clm4_5_cam4.0,clm5_1_GSWP3v1,clm5_1_cam6.0,clm5_1_cam5.0,clm5_1_cam4.0 clm4_5_CRUv7 clm4_5_CRUv7 clm4_5_GSWP3v1 - clm4_5_cam6.0 + clm4_5_cam4.0 + clm4_5_cam5.0 + clm4_5_cam6.0 + clm4_5_cam6.0 clm4_5_cam6.0 clm5_0_CRUv7 clm5_0_CRUv7 clm5_0_GSWP3v1 - clm5_0_cam6.0 + clm5_0_cam4.0 + clm5_0_cam5.0 + clm5_0_cam6.0 + clm5_0_cam6.0 clm5_0_cam6.0 + clm5_1_cam4.0 + clm5_1_cam5.0 + clm5_1_cam6.0 + clm5_1_cam6.0 clm5_1_GSWP3v1 From 70289af6ee39edd203cefe7d21dcd03d8662374c Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Sat, 9 Sep 2023 02:03:14 -0600 Subject: [PATCH 10/40] Get cam4,cam5 options working with coldstarts, add more tests, make sure lnd_tuning_mode has all of the clm physics options paired with all of the forcing types, build-namelist tests now pass --- bld/CLMBuildNamelist.pm | 21 +++-- bld/namelist_files/namelist_defaults_ctsm.xml | 76 ++++++++++++++++++- .../namelist_defaults_overall.xml | 6 ++ .../namelist_definition_ctsm.xml | 2 +- 4 files changed, 89 insertions(+), 16 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index b28dc54814..f39052d796 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -648,9 +648,9 @@ sub process_namelist_commandline_options { setup_cmdl_dynamic_vegetation($opts, $nl_flags, $definition, $defaults, $nl); setup_cmdl_fates_mode($opts, $nl_flags, $definition, $defaults, $nl); setup_cmdl_vichydro($opts, $nl_flags, $definition, $defaults, $nl); + setup_logic_lnd_tuning($opts, $nl_flags, $definition, $defaults, $nl, $physv); setup_cmdl_run_type($opts, $nl_flags, $definition, $defaults, $nl); setup_cmdl_output_reals($opts, $nl_flags, $definition, $defaults, $nl); - setup_logic_lnd_tuning($opts, $nl_flags, $definition, $defaults, $nl, $physv); } #------------------------------------------------------------------------------- @@ -1243,20 +1243,19 @@ sub setup_cmdl_run_type { my $group = $definition->get_group_name($date); $nl->set_variable_value($group, $date, $ic_date ); } + my $set = undef; if (defined $opts->{$var}) { - if ($opts->{$var} eq "default" ) { - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, - 'use_cndv'=>$nl_flags->{'use_cndv'}, 'use_fates'=>$nl_flags->{'use_fates'}, - 'sim_year'=>$st_year, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, - 'bgc_spinup'=>$nl_flags->{'bgc_spinup'} ); - } else { + if ($opts->{$var} ne "default" ) { + $set = 1; my $group = $definition->get_group_name($var); $nl->set_variable_value($group, $var, quote_string( $opts->{$var} ) ); } - } else { - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, - 'use_cndv'=>$nl_flags->{'use_cndv'}, 'use_fates'=>$nl_flags->{'use_fates'}, - 'sim_year'=>$st_year ); + } + if ( ! defined $set ) { + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, + 'use_cndv'=>$nl_flags->{'use_cndv'}, 'use_fates'=>$nl_flags->{'use_fates'}, + 'sim_year'=>$st_year, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, + 'bgc_spinup'=>$nl_flags->{'bgc_spinup'}, 'lnd_tuning_mode'=>$nl_flags->{'lnd_tuning_mode'} ); } $nl_flags->{'clm_start_type'} = $nl->get_value($var); $nl_flags->{'st_year'} = $st_year; diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 848a5e510c..4be4a9a102 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -278,6 +278,10 @@ attributes from the config_cache.xml file (with keys converted to upper-case). >30.0d00 20.0d00 +20.0d00 +20.0d00 80.0d00 0.85d00 0.98d00 @@ -289,6 +293,10 @@ attributes from the config_cache.xml file (with keys converted to upper-case). >0.010d00 0.008d00 +0.008d00 +0.008d00 0.17d-3 1.6d-4 0.33d00 @@ -628,7 +636,15 @@ attributes from the config_cache.xml file (with keys converted to upper-case). -.true. +.true. +.true. +.true. +.true. +.true. +.true. +.true. +.true. +.true. .true. -.true. -.true. +.true. +.true. +.true. +.true. +.true. +.true. .true. .true. .true. + +.false. +.false. +.false. +.false. +.false. +.false. .false. + hgrid=0.9x1.25 maxpft=79 mask=gx1v7 use_cn=.true. use_crop=.true. irrigate=.false. glc_nec=10 do_transient_pfts=.false. @@ -710,6 +737,14 @@ attributes from the config_cache.xml file (with keys converted to upper-case). >hgrid=0.9x1.25 maxpft=79 mask=gx1v7 use_cn=.true. use_crop=.true. irrigate=.false. glc_nec=10 do_transient_pfts=.false. +hgrid=0.9x1.25 maxpft=79 mask=gx1v7 use_cn=.true. use_crop=.true. irrigate=.false. glc_nec=10 do_transient_pfts=.false. + + +hgrid=0.9x1.25 maxpft=79 mask=gx1v7 use_cn=.true. use_crop=.true. irrigate=.false. glc_nec=10 do_transient_pfts=.false. + + hgrid=1.9x2.5 maxpft=79 mask=gx1v7 use_cn=.true. use_crop=.true. irrigate=.true. glc_nec=10 do_transient_pfts=.false. @@ -726,10 +761,19 @@ attributes from the config_cache.xml file (with keys converted to upper-case). hgrid=1.9x2.5 maxpft=79 mask=gx1v7 use_cn=.true. use_crop=.true. irrigate=.true. glc_nec=10 do_transient_pfts=.false. + hgrid=1.9x2.5 maxpft=79 mask=gx1v7 use_cn=.true. use_crop=.true. irrigate=.true. glc_nec=10 do_transient_pfts=.false. +hgrid=1.9x2.5 maxpft=79 mask=gx1v7 use_cn=.true. use_crop=.true. irrigate=.true. glc_nec=10 do_transient_pfts=.false. + + +hgrid=1.9x2.5 maxpft=79 mask=gx1v7 use_cn=.true. use_crop=.true. irrigate=.true. glc_nec=10 do_transient_pfts=.false. + + hgrid=1.9x2.5 maxpft=79 mask=gx1v7 use_cn=.true. use_crop=.true. irrigate=.true. glc_nec=10 do_transient_pfts=.false. @@ -913,6 +957,18 @@ p lnd_tuning_mode="clm5_1_GSWP3v1" >lnd/clm2/initdata_map/clmi.I1850Clm50BgcCrop-ciso.1366-01-01.0.9x1.25_gx1v7_simyr1850_c200428.nc +lnd/clm2/initdata_map/clmi.I1850Clm50BgcCrop-ciso.1366-01-01.0.9x1.25_gx1v7_simyr1850_c200428.nc + +lnd/clm2/initdata_map/clmi.I1850Clm50BgcCrop-ciso.1366-01-01.0.9x1.25_gx1v7_simyr1850_c200428.nc + diff --git a/bld/namelist_files/namelist_defaults_overall.xml b/bld/namelist_files/namelist_defaults_overall.xml index c4ccac6467..fe5abee44b 100644 --- a/bld/namelist_files/namelist_defaults_overall.xml +++ b/bld/namelist_files/namelist_defaults_overall.xml @@ -22,6 +22,12 @@ determine default values for namelists. --> +cold +cold +cold +cold +cold +cold arb_ic arb_ic arb_ic diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 69d9a5c278..e2dc7c804c 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -2057,7 +2057,7 @@ Land mask description + valid_values="clm4_5_CRUv7,clm4_5_GSWP3v1,clm4_5_cam6.0,clm4_5_cam5.0,clm4_5_cam4.0,clm5_0_cam6.0,clm5_0_cam5.0,clm5_0_cam4.0,clm5_0_CRUv7,clm5_0_GSWP3v1,clm5_1_GSWP3v1,clm5_1_CRUv7,clm5_1_cam6.0,clm5_1_cam5.0,clm5_1_cam4.0"> General configuration of model version and atmospheric forcing to tune the model to run under. This sets the model to run with constants and initial conditions that were set to run well under the configuration of model version and atmospheric forcing. To run well constants would need to be changed From a931e74d72b2a777440bbdb59edd53ed8b9c2e73 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Sat, 9 Sep 2023 11:39:17 -0600 Subject: [PATCH 11/40] Add a comment about the ordering to the run_type subroutine --- bld/CLMBuildNamelist.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index f39052d796..0420593b10 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -1229,6 +1229,8 @@ sub setup_cmdl_simulation_year { sub setup_cmdl_run_type { my ($opts, $nl_flags, $definition, $defaults, $nl) = @_; + # Set the clm_start_type and the st_year, start year + # This MUST be done after lnd_tuning_mode is set my $val; my $var = "clm_start_type"; From 08d3c86f33c3b15b0ba4b3a5bd4423240e61a774 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 29 Jan 2024 12:00:40 -0700 Subject: [PATCH 12/40] Add two new namelist options to control the dust emission method and for the Zender scheme how the soil eroditability file is handled --- bld/namelist_files/namelist_definition_ctsm.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index fef39bd8b1..2daf278ade 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -1788,6 +1788,18 @@ Mapping method from Nitrogen deposition input file to the model resolution + +Which dust emission method is going to be used. Either the Zender 2003 scheme or the Leung 2023 +scheme. + + + +Option only applying for the Zender_2003 method for whether the soil erodibility file is handled +here in CTSM, or in the ATM model. When dust_emis_method is NOT Zender_2003 it HAS to be none. + + Filename of input stream data for Zender's soil erodibility source function From 3553befe18f782ec2377f517864e1518d06ad39a Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 29 Jan 2024 18:22:53 -0700 Subject: [PATCH 13/40] Add dust_emission namelist control items to build-namelist and add tests for them --- bld/CLMBuildNamelist.pm | 66 +++++++++++++++---- bld/namelist_files/namelist_defaults_ctsm.xml | 6 +- .../namelist_definition_ctsm.xml | 12 ++-- bld/unit_testers/build-namelist_test.pl | 24 ++++++- 4 files changed, 87 insertions(+), 21 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index ac065e6594..0803428f09 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -1599,7 +1599,6 @@ sub process_namelist_inline_logic { setup_logic_fates($opts, $nl_flags, $definition, $defaults, $nl); setup_logic_z0param($opts, $nl_flags, $definition, $defaults, $nl); setup_logic_misc($opts, $nl_flags, $definition, $defaults, $nl); - setup_logic_zender_soilerod($opts, $nl_flags, $definition, $defaults, $nl); ######################################### # namelist group: atm2lnd_inparm @@ -1697,6 +1696,11 @@ sub process_namelist_inline_logic { ################################# setup_logic_fire_emis($opts, $nl_flags, $definition, $defaults, $nl); + ###################################### + # namelist options for dust emissions + ###################################### + setup_logic_dust_emis($opts, $nl_flags, $definition, $defaults, $nl); + ################################# # namelist group: megan_emis_nl # ################################# @@ -3936,6 +3940,55 @@ sub setup_logic_fire_emis { #------------------------------------------------------------------------------- +sub setup_logic_dust_emis { + # Logic to handle the dust emissions + my ($opts, $nl_flags, $definition, $defaults, $nl) = @_; + + # First get the dust emission method + my $var = "dust_emis_method"; + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var ); + + my $dust_emis_method = remove_leading_and_trailing_quotes( $nl->get_value($var) ); + + my @zender_files_in_lnd_opts = ( "stream_fldfilename_zendersoilerod", "stream_meshfile_zendersoilerod" ); + if ( $dust_emis_method eq "Zender_2003" ) { + # get the zender_soil_erod_source + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, + "zender_soil_erod_source", 'dust_emis_method'=>$dust_emis_method ); + + my $zender_source = remove_leading_and_trailing_quotes( $nl->get_value('zender_soil_erod_source') ); + if ( $zender_source eq "lnd" ) { + foreach my $option ( @zender_files_in_lnd_opts ) { + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $option, + 'dust_emis_method'=>$dust_emis_method, 'zender_soil_erod_source'=>$zender_source, + 'lnd_tuning_mod'=>$nl_flags->{'lnd_tuning_mode'} ); + } + } else { + foreach my $option ( @zender_files_in_lnd_opts ) { + if ( defined($nl->get_value($option)) ) { + $log->fatal_error("zender_soil_erod_source is NOT lnd, but the file option $option is being set" . + " and should NOT be unless you want it handled here in the LAND model, " . + "otherwise the equivalent option is set in CAM" ); + } + } + } + } else { + # Verify that NONE of the Zender options are being set if Zender is NOT being used + push @zender_files_in_lnd_opts, "zender_soil_erod_source"; + foreach my $option ( @zender_files_in_lnd_opts ) { + if ( defined($nl->get_value($option)) ) { + $log->fatal_error("dust_emis_method is NOT set to Zender_2003, but one of it's options " . + "$option is being set, need to change one or the other" ); + } + } + if ( $dust_emis_method eq "Leung_2023" ) { + $log->warning("dust_emis_method is Leung_2023 and that option has NOT been brought into CTSM yet"); + } + } +} + +#------------------------------------------------------------------------------- + sub setup_logic_megan { my ($opts, $nl_flags, $definition, $defaults, $nl) = @_; @@ -4570,17 +4623,6 @@ sub setup_logic_misc { #------------------------------------------------------------------------------- -sub setup_logic_zender_soilerod { - # - # Handle the Zender soil eroditability file - # - my ($opts, $nl_flags, $definition, $defaults, $nl) = @_; - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_zendersoilerod' ); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_meshfile_zendersoilerod' ); -} - -#------------------------------------------------------------------------------- - sub write_output_files { my ($opts, $nl_flags, $defaults, $nl) = @_; diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 7ffac74625..f3c108a68c 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2813,9 +2813,11 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 -Zender_2003 +atm +lnd/clm2/dustemisdata/dst_source2x2tunedcam6-2x2-forCLM_cdf5_c230312.nc -lnd/clm2/dustemisdata/dust_2x2_ESMFmesh_cdf5_c230730.nc diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 2daf278ade..3f382fabe5 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -1789,25 +1789,29 @@ Mapping method from Nitrogen deposition input file to the model resolution + group="clm_inparm" valid_values="Zender_2003,Leung_2023" > Which dust emission method is going to be used. Either the Zender 2003 scheme or the Leung 2023 scheme. +(NOTE: The Leung 2023 method is NOT currently available) - + Option only applying for the Zender_2003 method for whether the soil erodibility file is handled -here in CTSM, or in the ATM model. When dust_emis_method is NOT Zender_2003 it HAS to be none. +here in CTSM, or in the ATM model. +(only used when dust_emis_method is Zender_2003) Filename of input stream data for Zender's soil erodibility source function +(only used when dust_emis_method is Zender_2003, and zender_soil_erod_source is lnd) mesh filename of input stream data for Zender's soil erodibility source function +(only used when dust_emis_method is Zender_2003, and zender_soil_erod_source is lnd) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 7d813e37cb..3f05bac893 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -163,10 +163,10 @@ sub cat_and_create_namelistinfile { # # Figure out number of tests that will run # -my $ntests = 2071; +my $ntests = 2080; if ( defined($opts{'compare'}) ) { - $ntests += 1407; + $ntests += 1410; } plan( tests=>$ntests ); @@ -470,6 +470,7 @@ sub cat_and_create_namelistinfile { "-bgc fates -use_case 1850_control -no-megan -namelist \"&a use_fates_sp=T, soil_decomp_method='None'/\"", "-bgc sp -use_case 2000_control -res 0.9x1.25 -namelist '&a use_soil_moisture_streams = T/'", "-bgc bgc -use_case 1850-2100_SSP5-8.5_transient -namelist '&a start_ymd=19101023/'", + "-namelist \"&a dust_emis_method='Zender_2003', zender_soil_erod_source='lnd' /'\"", "-bgc bgc -use_case 2000_control -namelist \"&a fire_method='nofire'/\" -crop", "-res 0.9x1.25 -bgc sp -use_case 1850_noanthro_control -drydep -fire_emis", "-res 0.9x1.25 -bgc bgc -use_case 1850_noanthro_control -drydep -fire_emis -light_res 360x720", @@ -1222,7 +1223,7 @@ sub cat_and_create_namelistinfile { phys=>"clm5_0", }, "NOlunabutsetJmaxb1" =>{ options=>"-envxml_dir . -bgc sp", - namelst=>"use_luna=.false., jmaxb1=1.0", + namelst=>"use_luna=.fwlse., jmaxb1=1.0", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_0", }, @@ -1256,6 +1257,18 @@ sub cat_and_create_namelistinfile { GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_0", }, + "soil_erod_wo_Zender" =>{ options=>"--envxml_dir . --ignore_warnings", + namelst=>"dust_emis_msethod='Leung_2023', " . + "stream_meshfile_zendersoilerod = '/dev/null'", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm5_1", + }, + "soil_erod_wo_lnd_source" =>{ options=>"--envxml_dir .", + namelst=>"dust_emis_msethod='Zender_2003', " . + "stream_fldfilename_zendersoilerod = '/dev/null', zender_soil_erod_source='atm'", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm5_1", + }, ); foreach my $key ( keys(%failtest) ) { print( "$key\n" ); @@ -1277,6 +1290,11 @@ sub cat_and_create_namelistinfile { my %warntest = ( # Warnings without the -ignore_warnings option given + "dustemisLeung" =>{ options=>"-envxml_dir .", + namelst=>"dust_emis_method = 'Leung_2023'", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm5_1", + }, "coldwfinidat" =>{ options=>"-envxml_dir . -clm_start_type cold", namelst=>"finidat = 'testfile.nc'", GLC_TWO_WAY_COUPLING=>"FALSE", From 8a9f51356ad2bfa295ec2b7f9b3de8f7d3f313f5 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 29 Jan 2024 20:22:44 -0700 Subject: [PATCH 14/40] Fix bug in tests after running with the error check turned off --- bld/unit_testers/build-namelist_test.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 3f05bac893..cb2456ee32 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -1258,13 +1258,13 @@ sub cat_and_create_namelistinfile { phys=>"clm5_0", }, "soil_erod_wo_Zender" =>{ options=>"--envxml_dir . --ignore_warnings", - namelst=>"dust_emis_msethod='Leung_2023', " . + namelst=>"dust_emis_method='Leung_2023', " . "stream_meshfile_zendersoilerod = '/dev/null'", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_1", }, "soil_erod_wo_lnd_source" =>{ options=>"--envxml_dir .", - namelst=>"dust_emis_msethod='Zender_2003', " . + namelst=>"dust_emis_method='Zender_2003', " . "stream_fldfilename_zendersoilerod = '/dev/null', zender_soil_erod_source='atm'", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_1", From dd61c141ee267b293b532724f7f9daa6f966816a Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Tue, 30 Jan 2024 21:37:29 -0700 Subject: [PATCH 15/40] Add zendersoilerodmapalgo into the build-namelist --- bld/CLMBuildNamelist.pm | 3 ++- bld/namelist_files/namelist_defaults_ctsm.xml | 1 + bld/namelist_files/namelist_definition_ctsm.xml | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 0803428f09..ba2885e5de 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -3950,7 +3950,8 @@ sub setup_logic_dust_emis { my $dust_emis_method = remove_leading_and_trailing_quotes( $nl->get_value($var) ); - my @zender_files_in_lnd_opts = ( "stream_fldfilename_zendersoilerod", "stream_meshfile_zendersoilerod" ); + my @zender_files_in_lnd_opts = ( "stream_fldfilename_zendersoilerod", "stream_meshfile_zendersoilerod", + "zendersoilerodmapalgo" ); if ( $dust_emis_method eq "Zender_2003" ) { # get the zender_soil_erod_source add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index f3c108a68c..d1e77db965 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2815,6 +2815,7 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 Zender_2003 atm +bilinear lnd/clm2/dustemisdata/dst_source2x2tunedcam6-2x2-forCLM_cdf5_c230312.nc + +Option only applying for the Zender_2003 method for whether the soil erodibility file is handled +here in CTSM, or in the ATM model. +(only used when dust_emis_method is Zender_2003) + bilinear = bilinear interpolation + nn = nearest neighbor + nnoni = nearest neighbor on the "i" (longitude) axis + nnonj = nearest neighbor on the "j" (latitude) axis + spval = set to special value + copy = copy using the same indices + + Filename of input stream data for Zender's soil erodibility source function From 0d19e854d852ba7c50f20519db3842978c8cd35d Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Wed, 31 Jan 2024 16:56:03 -0700 Subject: [PATCH 16/40] Add new test mods that include using Zender_2003 dust and lnd_tuning_modes for CAM4 and CAM5 --- .../clm/clm45cam4LndTuningModZDustSoilErod/include_user_mods | 1 + .../clm/clm45cam4LndTuningModZDustSoilErod/shell_commands | 4 ++++ .../clm/clm45cam4LndTuningModZDustSoilErod/user_nl_clm | 3 +++ .../clm/clm45cam5LndTuningModZDustSoilErod/include_user_mods | 1 + .../clm/clm45cam5LndTuningModZDustSoilErod/shell_commands | 5 +++++ 5 files changed, 14 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/shell_commands create mode 100644 cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/user_nl_clm create mode 100644 cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModZDustSoilErod/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModZDustSoilErod/shell_commands diff --git a/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/include_user_mods new file mode 100644 index 0000000000..fe0e18cf88 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/include_user_mods @@ -0,0 +1 @@ +../default diff --git a/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/shell_commands b/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/shell_commands new file mode 100644 index 0000000000..b858269501 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/shell_commands @@ -0,0 +1,4 @@ +#!/bin/bash + +./xmlchange LND_TUNING_MODE="clm4_5_cam4.0" + diff --git a/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/user_nl_clm new file mode 100644 index 0000000000..deab434d1c --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/user_nl_clm @@ -0,0 +1,3 @@ +! Turn on using the soil eroditability file in CTSM +dust_emis_method = 'Zender_2023' +clm45cam4LndTuningModZDustSoilErod = 'lnd' diff --git a/cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModZDustSoilErod/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModZDustSoilErod/include_user_mods new file mode 100644 index 0000000000..fe0e18cf88 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModZDustSoilErod/include_user_mods @@ -0,0 +1 @@ +../default diff --git a/cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModZDustSoilErod/shell_commands b/cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModZDustSoilErod/shell_commands new file mode 100644 index 0000000000..753bc2f045 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModZDustSoilErod/shell_commands @@ -0,0 +1,5 @@ +#!/bin/bash + +./xmlchange LND_TUNING_MODE="clm5_0_cam5.0" +./xmlchange ROF_NCPL='$ATM_NCPL' + From c3f2b30fedf87baf4b3fc469f4993704b68583ed Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Wed, 31 Jan 2024 16:57:17 -0700 Subject: [PATCH 17/40] Add in the new dust handling namelist parameters, and some control logic for it, this compilers, but does NOT run --- src/biogeochem/DUSTMod.F90 | 32 ++++++++++------- .../share_esmf/ZenderSoilErodStreamType.F90 | 35 +++++++++++++------ src/main/clm_varctl.F90 | 5 +++ src/main/controlMod.F90 | 2 +- 4 files changed, 50 insertions(+), 24 deletions(-) diff --git a/src/biogeochem/DUSTMod.F90 b/src/biogeochem/DUSTMod.F90 index 485086203b..28823f573d 100644 --- a/src/biogeochem/DUSTMod.F90 +++ b/src/biogeochem/DUSTMod.F90 @@ -31,6 +31,7 @@ module DUSTMod use ColumnType , only : col use PatchType , only : patch use ZenderSoilErodStreamType, only : zendersoilerodstream_type + use clm_varctl , only : dust_emis_method ! ! !PUBLIC TYPES implicit none @@ -80,7 +81,6 @@ module DUSTMod contains !------------------------------------------------------------------------ - !subroutine Init(this, bounds) subroutine Init(this, bounds, NLFilename) class(dust_type) :: this @@ -187,18 +187,24 @@ subroutine InitCold(this, bounds) ! Set basin factor to 1 for now - !if (dust_emission_scheme == 'Leung2023') - ! do c = bounds%begc, bounds%endc - ! l = col%landunit(c) - - ! if (.not.lun%lakpoi(l)) then - ! this%mbl_bsn_fct_col(c) = 1.0_r8 - ! end if - ! end do - !else if (dust_emission_scheme == 'Zender2003') - call this%zendersoilerodstream%CalcDustSource( bounds, & - this%mbl_bsn_fct_col(bounds%begc:bounds%endc) ) - !end if + if (dust_emis_method == 'Leung_2023') then + !do c = bounds%begc, bounds%endc + ! l = col%landunit(c) + + ! if (.not.lun%lakpoi(l)) then + ! this%mbl_bsn_fct_col(c) = 1.0_r8 + ! end if + !end do + call endrun( msg="Leung_2023 dust_emis_method is currently not available"//errMsg(sourcefile, __LINE__)) + else if (dust_emis_method == 'Zender_2003') then + if ( this%zendersoilerodstream%UseStreams() )then + call this%zendersoilerodstream%CalcDustSource( bounds, & + this%mbl_bsn_fct_col(bounds%begc:bounds%endc) ) + end if + else + write(iulog,*) 'dust_emis_method not recognized = ', trim(dust_emis_method) + call endrun( msg="dust_emis_method namelist item is not valid "//errMsg(sourcefile, __LINE__)) + end if end subroutine InitCold diff --git a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 index 8993722115..1422f2e84c 100644 --- a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 +++ b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 @@ -42,6 +42,7 @@ module ZenderSoilErodStreamType ! ! PRIVATE DATA: type, private :: streamcontrol_type + character(len=CL) :: zender_soil_erod_source ! if calculed in lnd or atm character(len=CL) :: stream_fldFileName_zendersoilerod ! data Filename character(len=CL) :: stream_meshfile_zendersoilerod ! mesh Filename character(len=CL) :: zendersoilerodmapalgo ! map algo @@ -60,7 +61,7 @@ module ZenderSoilErodStreamType subroutine Init(this, bounds, NLFilename) ! - ! Initialize the prigent roughness stream object + ! Initialize the Zender soil eroditability stream object ! ! Uses: use spmdMod , only : iam @@ -89,7 +90,6 @@ subroutine Init(this, bounds, NLFilename) character(len=*), parameter :: stream_name = 'zendersoilerod' !----------------------------------------------------------------------- - !if ( finundation_mtd /= finundation_mtd_h2osfc )then ! how should I change this? comment out for now call this%InitAllocate( bounds ) call control%ReadNML( bounds, NLFileName ) @@ -164,7 +164,6 @@ subroutine Init(this, bounds, NLFilename) end do end if - !end if !comment out for now end subroutine Init @@ -176,14 +175,14 @@ logical function UseStreams(this) ! file is being used with it ! ! !USES: + use clm_varctl, only : dust_emis_method ! ! !ARGUMENTS: implicit none class(zendersoilerodstream_type) :: this ! ! !LOCAL VARIABLES: - !if ( trim(control%stream_fldFileName_zendersoilerod) == '' .or. dust_emission_scheme == 'Leung2023')then - if ( trim(control%stream_fldFileName_zendersoilerod) == '')then + if ( (trim(dust_emis_method) /= 'Zender_2003') .or. (control%zender_soil_erod_source == "atm") )then UseStreams = .false. else UseStreams = .true. @@ -205,14 +204,17 @@ subroutine InitAllocate(this, bounds) type(bounds_type), intent(in) :: bounds ! ! !LOCAL VARIABLES: - !integer :: begc, endc integer :: begg, endg !--------------------------------------------------------------------- - !begc = bounds%begc; endc = bounds%endc begg = bounds%begg; endg = bounds%endg - allocate(this%soil_erodibility (begg:endg)) ; this%soil_erodibility (:) = nan + if ( this%useStreams() ) then + allocate(this%soil_erodibility (begg:endg)) + else + allocate(this%soil_erodibility (0)) + end if + this%soil_erodibility (:) = nan end subroutine InitAllocate @@ -293,12 +295,14 @@ subroutine ReadNML(this, bounds, NLFilename) character(len=CL) :: stream_fldFileName_zendersoilerod = ' ' character(len=CL) :: stream_meshfile_zendersoilerod = ' ' character(len=CL) :: zendersoilerodmapalgo = 'bilinear' + character(len=3) :: zender_soil_erod_source = 'atm' character(len=*), parameter :: namelist_name = 'zendersoilerod' ! MUST agree with group name in namelist definition to read. character(len=*), parameter :: subName = "('zendersoilerod::ReadNML')" !----------------------------------------------------------------------- namelist /zendersoilerod/ & ! MUST agree with namelist_name above - zendersoilerodmapalgo, stream_fldFileName_zendersoilerod, stream_meshfile_zendersoilerod + zendersoilerodmapalgo, zendersoilerodmapalgo, stream_fldFileName_zendersoilerod, & + stream_meshfile_zendersoilerod ! Default values for namelist @@ -321,16 +325,27 @@ subroutine ReadNML(this, bounds, NLFilename) call shr_mpi_bcast(stream_fldFileName_zendersoilerod , mpicom) call shr_mpi_bcast(stream_meshfile_zendersoilerod , mpicom) - if (masterproc) then + if (masterproc .and. (zender_soil_erod_source == "lnd") ) then write(iulog,*) ' ' write(iulog,*) namelist_name, ' stream settings:' write(iulog,*) ' stream_fldFileName_zendersoilerod = ',stream_fldFileName_zendersoilerod write(iulog,*) ' stream_meshfile_zendersoilerod = ',stream_meshfile_zendersoilerod write(iulog,*) ' zendersoilerodmapalgo = ',zendersoilerodmapalgo endif + + if ( (zender_soil_erod_source /= 'atm') .and. (zender_soil_erod_source /= 'lnd') )then + call endrun(msg=' ERROR zender_soil_erod_source must be either lnd or atm and is NOT'//errMsg(sourcefile, __LINE__)) + end if + if ( len_trim(stream_meshfile_zendersoilerod) == 0 )then + call endrun(msg=' ERROR stream_meshfile_zendersoilerod must be set when Zender_2003 is being used and zender_soil_erod_source is lnd'//errMsg(sourcefile, __LINE__)) + end if + if ( len_trim(stream_meshfile_zendersoilerod) == 0 )then + call endrun(msg=' ERROR stream_meshfile_zendersoilerod must be set when Zender_2003 is being used and zender_soil_erod_source is lnd'//errMsg(sourcefile, __LINE__)) + end if this%stream_fldFileName_zendersoilerod = stream_fldFileName_zendersoilerod this%stream_meshfile_zendersoilerod = stream_meshfile_zendersoilerod this%zendersoilerodmapalgo = zendersoilerodmapalgo + this%zender_soil_erod_source = zender_soil_erod_source end subroutine ReadNML diff --git a/src/main/clm_varctl.F90 b/src/main/clm_varctl.F90 index 615f3b2606..e2ad7156ef 100644 --- a/src/main/clm_varctl.F90 +++ b/src/main/clm_varctl.F90 @@ -265,6 +265,11 @@ module clm_varctl ! option to activate OC in snow in SNICAR logical, public :: do_sno_oc = .false. ! control to include organic carbon (OC) in snow + !---------------------------------------------------------- + ! DUST emission method + !---------------------------------------------------------- + character(len=25), public :: dust_emis_method = 'Zender_2003' ! Dust emisison method to use: Zender_2003 or Leung_2023 + !---------------------------------------------------------- ! C isotopes !---------------------------------------------------------- diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90 index d95c0e28e0..b3120c353a 100644 --- a/src/main/controlMod.F90 +++ b/src/main/controlMod.F90 @@ -205,7 +205,7 @@ subroutine control_init(dtime) crop_fsat_equals_zero, for_testing_run_ncdiopio_tests, & for_testing_use_second_grain_pool, for_testing_use_repr_structure_pool, & for_testing_no_crop_seed_replenishment, & - z0param_method, use_z0m_snowmelt + z0param_method, use_z0m_snowmelt, dust_emis_method ! vertical soil mixing variables namelist /clm_inparm/ & From 15bf184e4d66927ce85e215db41b53c99f8a5326 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Thu, 1 Feb 2024 20:36:59 -0700 Subject: [PATCH 18/40] Get simple case with Zender soil eroditablity off working so SMS_D_Ld1_Mmpi-serial.1x1_brazil.I2000Clm51SpRs.derecho_gnu.clm-clm51cam6LndTuningMode PASSes --- src/biogeochem/DUSTMod.F90 | 16 +++++++++------- src/cpl/share_esmf/ZenderSoilErodStreamType.F90 | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/biogeochem/DUSTMod.F90 b/src/biogeochem/DUSTMod.F90 index 28823f573d..d447f42f04 100644 --- a/src/biogeochem/DUSTMod.F90 +++ b/src/biogeochem/DUSTMod.F90 @@ -87,9 +87,9 @@ subroutine Init(this, bounds, NLFilename) type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename + call this%zendersoilerodstream%Init( bounds, NLFilename ) call this%InitAllocate (bounds) call this%InitHistory (bounds) - call this%zendersoilerodstream%Init( bounds, NLFilename ) call this%InitCold (bounds) call this%InitDustVars (bounds) @@ -165,12 +165,14 @@ subroutine InitHistory(this, bounds) avgflag='A', long_name='turbulent deposition velocity 4', & ptr_patch=this%vlc_trb_4_patch, default='inactive') - ! if Zender - this%mbl_bsn_fct_col(begc:endc) = spval - call hist_addfld1d (fname='LND_MBL', units='fraction', & - avgflag='A', long_name='Soil erodibility factor', & - ptr_col=this%mbl_bsn_fct_col, default='inactive') - ! end if + if (dust_emis_method == 'Zender_2003') then + if ( this%zendersoilerodstream%UseStreams() )then + this%mbl_bsn_fct_col(begc:endc) = spval + call hist_addfld1d (fname='LND_MBL', units='fraction', & + avgflag='A', long_name='Soil erodibility factor', & + ptr_col=this%mbl_bsn_fct_col, default='inactive') + end if + end if end subroutine InitHistory diff --git a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 index 1422f2e84c..2749b9b28f 100644 --- a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 +++ b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 @@ -302,7 +302,7 @@ subroutine ReadNML(this, bounds, NLFilename) namelist /zendersoilerod/ & ! MUST agree with namelist_name above zendersoilerodmapalgo, zendersoilerodmapalgo, stream_fldFileName_zendersoilerod, & - stream_meshfile_zendersoilerod + stream_meshfile_zendersoilerod, zender_soil_erod_source ! Default values for namelist @@ -333,14 +333,16 @@ subroutine ReadNML(this, bounds, NLFilename) write(iulog,*) ' zendersoilerodmapalgo = ',zendersoilerodmapalgo endif - if ( (zender_soil_erod_source /= 'atm') .and. (zender_soil_erod_source /= 'lnd') )then + if ( (trim(zender_soil_erod_source) /= 'atm') .and. (trim(zender_soil_erod_source) /= 'lnd') )then call endrun(msg=' ERROR zender_soil_erod_source must be either lnd or atm and is NOT'//errMsg(sourcefile, __LINE__)) end if - if ( len_trim(stream_meshfile_zendersoilerod) == 0 )then - call endrun(msg=' ERROR stream_meshfile_zendersoilerod must be set when Zender_2003 is being used and zender_soil_erod_source is lnd'//errMsg(sourcefile, __LINE__)) - end if - if ( len_trim(stream_meshfile_zendersoilerod) == 0 )then - call endrun(msg=' ERROR stream_meshfile_zendersoilerod must be set when Zender_2003 is being used and zender_soil_erod_source is lnd'//errMsg(sourcefile, __LINE__)) + if ( trim(zender_soil_erod_source) == 'lnd' )then + if ( len_trim(stream_meshfile_zendersoilerod) == 0 )then + call endrun(msg=' ERROR stream_meshfile_zendersoilerod must be set when Zender_2003 is being used and zender_soil_erod_source is lnd'//errMsg(sourcefile, __LINE__)) + end if + if ( len_trim(stream_meshfile_zendersoilerod) == 0 )then + call endrun(msg=' ERROR stream_meshfile_zendersoilerod must be set when Zender_2003 is being used and zender_soil_erod_source is lnd'//errMsg(sourcefile, __LINE__)) + end if end if this%stream_fldFileName_zendersoilerod = stream_fldFileName_zendersoilerod this%stream_meshfile_zendersoilerod = stream_meshfile_zendersoilerod From 0b9c97976aad14ce10ce09d786c1cbc094444815 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 2 Feb 2024 16:15:35 -0700 Subject: [PATCH 19/40] Fix some issues, get a test using soileroditability file to work --- src/biogeochem/DUSTMod.F90 | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/biogeochem/DUSTMod.F90 b/src/biogeochem/DUSTMod.F90 index d447f42f04..3d1d4d80ee 100644 --- a/src/biogeochem/DUSTMod.F90 +++ b/src/biogeochem/DUSTMod.F90 @@ -138,7 +138,7 @@ subroutine InitHistory(this, bounds) !------------------------------------------------------------------------ begp = bounds%begp; endp = bounds%endp - begc = bounds%begc; endc = bounds%endp + begc = bounds%begc; endc = bounds%endc this%flx_mss_vrt_dst_tot_patch(begp:endp) = spval call hist_addfld1d (fname='DSTFLXT', units='kg/m2/s', & @@ -202,6 +202,8 @@ subroutine InitCold(this, bounds) if ( this%zendersoilerodstream%UseStreams() )then call this%zendersoilerodstream%CalcDustSource( bounds, & this%mbl_bsn_fct_col(bounds%begc:bounds%endc) ) + else + this%mbl_bsn_fct_col(:) = 1.0_r8 end if else write(iulog,*) 'dust_emis_method not recognized = ', trim(dust_emis_method) @@ -708,10 +710,6 @@ subroutine InitDustVars(this, bounds) real(r8), parameter :: dns_slt = 2650.0_r8 ! [kg m-3] Density of optimal saltation particles !------------------------------------------------------------------------ - associate(& - mbl_bsn_fct => this%mbl_bsn_fct_col & ! Output: [real(r8) (:)] basin factor - ) - ! allocate module variable allocate (ovr_src_snk_mss(dst_src_nbr,ndst)) allocate (dmt_vwr(ndst)) @@ -947,8 +945,6 @@ subroutine InitDustVars(this, bounds) stk_crc(m) = vlc_grv(m) / vlc_stk(m) end do - end associate - end subroutine InitDustVars end module DUSTMod From 3921fbf67a8e8e2eb115ef9ddd7e8b3908786fd3 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 2 Feb 2024 17:12:42 -0700 Subject: [PATCH 20/40] Add tests for Zender dust with soil eroditability file in CTSM for CAM4, CAM5, CAM6 cases --- cime_config/testdefs/testlist_clm.xml | 22 +++++++++++++++++-- .../include_user_mods | 0 .../shell_commands | 1 + .../user_nl_clm | 0 .../include_user_mods | 0 .../shell_commands | 0 .../include_user_mods | 1 + .../user_nl_clm | 3 +++ 8 files changed, 25 insertions(+), 2 deletions(-) rename cime_config/testdefs/testmods_dirs/clm/{clm45cam4LndTuningModZDustSoilErod => clm45cam4LndTuningModeZDustSoilErod}/include_user_mods (100%) rename cime_config/testdefs/testmods_dirs/clm/{clm45cam4LndTuningModZDustSoilErod => clm45cam4LndTuningModeZDustSoilErod}/shell_commands (63%) rename cime_config/testdefs/testmods_dirs/clm/{clm45cam4LndTuningModZDustSoilErod => clm45cam4LndTuningModeZDustSoilErod}/user_nl_clm (100%) rename cime_config/testdefs/testmods_dirs/clm/{clm45cam5LndTuningModZDustSoilErod => clm45cam5LndTuningModeZDustSoilErod}/include_user_mods (100%) rename cime_config/testdefs/testmods_dirs/clm/{clm45cam5LndTuningModZDustSoilErod => clm45cam5LndTuningModeZDustSoilErod}/shell_commands (100%) create mode 100644 cime_config/testdefs/testmods_dirs/clm/clm51cam6LndTuningModeZDustSoilErod/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/clm51cam6LndTuningModeZDustSoilErod/user_nl_clm diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 4761a2111f..958a903eab 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -52,14 +52,32 @@ - + + + + + + + + + + + + + + + + + + + - + diff --git a/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModeZDustSoilErod/include_user_mods similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/include_user_mods rename to cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModeZDustSoilErod/include_user_mods diff --git a/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/shell_commands b/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModeZDustSoilErod/shell_commands similarity index 63% rename from cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/shell_commands rename to cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModeZDustSoilErod/shell_commands index b858269501..010b5b5680 100644 --- a/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/shell_commands +++ b/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModeZDustSoilErod/shell_commands @@ -1,4 +1,5 @@ #!/bin/bash ./xmlchange LND_TUNING_MODE="clm4_5_cam4.0" +./xmlchange ROF_NCPL='$ATM_NCPL' diff --git a/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModeZDustSoilErod/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModZDustSoilErod/user_nl_clm rename to cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModeZDustSoilErod/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModZDustSoilErod/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModeZDustSoilErod/include_user_mods similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModZDustSoilErod/include_user_mods rename to cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModeZDustSoilErod/include_user_mods diff --git a/cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModZDustSoilErod/shell_commands b/cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModeZDustSoilErod/shell_commands similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModZDustSoilErod/shell_commands rename to cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModeZDustSoilErod/shell_commands diff --git a/cime_config/testdefs/testmods_dirs/clm/clm51cam6LndTuningModeZDustSoilErod/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/clm51cam6LndTuningModeZDustSoilErod/include_user_mods new file mode 100644 index 0000000000..aa76c52034 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/clm51cam6LndTuningModeZDustSoilErod/include_user_mods @@ -0,0 +1 @@ +../clm51cam6LndTuningMode diff --git a/cime_config/testdefs/testmods_dirs/clm/clm51cam6LndTuningModeZDustSoilErod/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/clm51cam6LndTuningModeZDustSoilErod/user_nl_clm new file mode 100644 index 0000000000..deab434d1c --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/clm51cam6LndTuningModeZDustSoilErod/user_nl_clm @@ -0,0 +1,3 @@ +! Turn on using the soil eroditability file in CTSM +dust_emis_method = 'Zender_2023' +clm45cam4LndTuningModZDustSoilErod = 'lnd' From 2ad96ff966695c90d26f4c88a8abfe1ddbfd4de9 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 2 Feb 2024 18:00:42 -0700 Subject: [PATCH 21/40] Add dust soil eroditability files for all CAM options, which requires a version for each lnd_tuning_mode, and for CAM4 cases for the f09 grid --- bld/namelist_files/namelist_defaults_ctsm.xml | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index d1e77db965..a6b9a7a6cc 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2816,8 +2816,49 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 Zender_2003 atm bilinear -lnd/clm2/dustemisdata/dst_source2x2tunedcam6-2x2-forCLM_cdf5_c230312.nc +lnd/clm2/dustemisdata/dst_source2x2tunedcam6-2x2-forCLM_cdf5_c230312.nc +lnd/clm2/dustemisdata/dst_source2x2tunedcam6-2x2-forCLM_cdf5_c230312.nc +lnd/clm2/dustemisdata/dst_source2x2_cam5.4-forCLM_cdf5_c240202.nc +lnd/clm2/dustemisdata/dst_source2x2_cam5.4-forCLM_cdf5_c240202.nc +lnd/clm2/dustemisdata/dst_source2x2_cam5.4-forCLM_cdf5_c240202.nc +lnd/clm2/dustemisdata/dst_source2x2tuned-cam4-forCLM_cdf5_c240202.nc +lnd/clm2/dustemisdata/dst_source2x2tuned-cam4-forCLM_cdf5_c240202.nc +lnd/clm2/dustemisdata/dst_source2x2tuned-cam4-forCLM_cdf5_c240202.nc +lnd/clm2/dustemisdata/dst_source1x1tuned-cam4-forCLM_cdf5_c240202.nc +lnd/clm2/dustemisdata/dst_source1x1tuned-cam4-forCLM_cdf5_c240202.nc +lnd/clm2/dustemisdata/dst_source1x1tuned-cam4-forCLM_cdf5_c240202.nc +lnd/clm2/dustemisdata/dst_source2x2tunedcam6-2x2-forCLM_cdf5_c230312.nc +lnd/clm2/dustemisdata/dst_source2x2tunedcam6-2x2-forCLM_cdf5_c230312.nc +lnd/clm2/dustemisdata/dst_source2x2tunedcam6-2x2-forCLM_cdf5_c230312.nc +lnd/clm2/dustemisdata/dst_source2x2tunedcam6-2x2-forCLM_cdf5_c230312.nc +lnd/clm2/dustemisdata/dst_source2x2tunedcam6-2x2-forCLM_cdf5_c230312.nc +lnd/clm2/dustemisdata/dst_source2x2tunedcam6-2x2-forCLM_cdf5_c230312.nc +lnd/clm2/dustemisdata/dst_source2x2tunedcam6-2x2-forCLM_cdf5_c230312.nc +lnd/clm2/dustemisdata/dst_source2x2tunedcam6-2x2-forCLM_cdf5_c230312.nc +lnd/clm2/dustemisdata/dst_source2x2tunedcam6-2x2-forCLM_cdf5_c230312.nc + lnd/clm2/dustemisdata/dust_2x2_ESMFmesh_cdf5_c230730.nc From 301181856209bb3f4e2b30f100b7eec032d830b1 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 2 Feb 2024 18:04:05 -0700 Subject: [PATCH 22/40] Need hgrid for some of the Zender soil eroditability files --- bld/CLMBuildNamelist.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index ba2885e5de..facfef91ce 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -3962,7 +3962,7 @@ sub setup_logic_dust_emis { foreach my $option ( @zender_files_in_lnd_opts ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $option, 'dust_emis_method'=>$dust_emis_method, 'zender_soil_erod_source'=>$zender_source, - 'lnd_tuning_mod'=>$nl_flags->{'lnd_tuning_mode'} ); + 'hgrid'=>$nl_flags->{'res'}, 'lnd_tuning_mod'=>$nl_flags->{'lnd_tuning_mode'} ); } } else { foreach my $option ( @zender_files_in_lnd_opts ) { From 7e226ba46459e14cab820122e424877edc30862b Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Sat, 3 Feb 2024 12:27:18 -0700 Subject: [PATCH 23/40] Correct year in dust_emis_method --- .../clm/clm45cam4LndTuningModeZDustSoilErod/user_nl_clm | 2 +- .../clm/clm51cam6LndTuningModeZDustSoilErod/user_nl_clm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModeZDustSoilErod/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModeZDustSoilErod/user_nl_clm index deab434d1c..755d7e30c9 100644 --- a/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModeZDustSoilErod/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModeZDustSoilErod/user_nl_clm @@ -1,3 +1,3 @@ ! Turn on using the soil eroditability file in CTSM -dust_emis_method = 'Zender_2023' +dust_emis_method = 'Zender_2003' clm45cam4LndTuningModZDustSoilErod = 'lnd' diff --git a/cime_config/testdefs/testmods_dirs/clm/clm51cam6LndTuningModeZDustSoilErod/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/clm51cam6LndTuningModeZDustSoilErod/user_nl_clm index deab434d1c..755d7e30c9 100644 --- a/cime_config/testdefs/testmods_dirs/clm/clm51cam6LndTuningModeZDustSoilErod/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/clm51cam6LndTuningModeZDustSoilErod/user_nl_clm @@ -1,3 +1,3 @@ ! Turn on using the soil eroditability file in CTSM -dust_emis_method = 'Zender_2023' +dust_emis_method = 'Zender_2003' clm45cam4LndTuningModZDustSoilErod = 'lnd' From ef7a41a9ae379c3082d0660e6261487bd204bec1 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Sat, 3 Feb 2024 13:39:04 -0700 Subject: [PATCH 24/40] Correct namelist name --- .../clm/clm45cam4LndTuningModeZDustSoilErod/user_nl_clm | 2 +- .../include_user_mods | 0 .../shell_commands | 0 .../clm/clm50cam5LndTuningModeZDustSoilErod/user_nl_clm | 3 +++ .../clm/clm51cam6LndTuningModeZDustSoilErod/user_nl_clm | 2 +- 5 files changed, 5 insertions(+), 2 deletions(-) rename cime_config/testdefs/testmods_dirs/clm/{clm45cam5LndTuningModeZDustSoilErod => clm50cam5LndTuningModeZDustSoilErod}/include_user_mods (100%) rename cime_config/testdefs/testmods_dirs/clm/{clm45cam5LndTuningModeZDustSoilErod => clm50cam5LndTuningModeZDustSoilErod}/shell_commands (100%) create mode 100644 cime_config/testdefs/testmods_dirs/clm/clm50cam5LndTuningModeZDustSoilErod/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModeZDustSoilErod/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModeZDustSoilErod/user_nl_clm index 755d7e30c9..93b7ee2e48 100644 --- a/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModeZDustSoilErod/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/clm45cam4LndTuningModeZDustSoilErod/user_nl_clm @@ -1,3 +1,3 @@ ! Turn on using the soil eroditability file in CTSM dust_emis_method = 'Zender_2003' -clm45cam4LndTuningModZDustSoilErod = 'lnd' +zender_soil_erod_source = 'lnd' diff --git a/cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModeZDustSoilErod/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/clm50cam5LndTuningModeZDustSoilErod/include_user_mods similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModeZDustSoilErod/include_user_mods rename to cime_config/testdefs/testmods_dirs/clm/clm50cam5LndTuningModeZDustSoilErod/include_user_mods diff --git a/cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModeZDustSoilErod/shell_commands b/cime_config/testdefs/testmods_dirs/clm/clm50cam5LndTuningModeZDustSoilErod/shell_commands similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/clm45cam5LndTuningModeZDustSoilErod/shell_commands rename to cime_config/testdefs/testmods_dirs/clm/clm50cam5LndTuningModeZDustSoilErod/shell_commands diff --git a/cime_config/testdefs/testmods_dirs/clm/clm50cam5LndTuningModeZDustSoilErod/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/clm50cam5LndTuningModeZDustSoilErod/user_nl_clm new file mode 100644 index 0000000000..93b7ee2e48 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/clm50cam5LndTuningModeZDustSoilErod/user_nl_clm @@ -0,0 +1,3 @@ +! Turn on using the soil eroditability file in CTSM +dust_emis_method = 'Zender_2003' +zender_soil_erod_source = 'lnd' diff --git a/cime_config/testdefs/testmods_dirs/clm/clm51cam6LndTuningModeZDustSoilErod/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/clm51cam6LndTuningModeZDustSoilErod/user_nl_clm index 755d7e30c9..93b7ee2e48 100644 --- a/cime_config/testdefs/testmods_dirs/clm/clm51cam6LndTuningModeZDustSoilErod/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/clm51cam6LndTuningModeZDustSoilErod/user_nl_clm @@ -1,3 +1,3 @@ ! Turn on using the soil eroditability file in CTSM dust_emis_method = 'Zender_2003' -clm45cam4LndTuningModZDustSoilErod = 'lnd' +zender_soil_erod_source = 'lnd' From 2d9aaccf240b0b4a4a8f9db7017cb15e2f4710e4 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 26 Feb 2024 17:01:43 -0700 Subject: [PATCH 25/40] Use straight logic rather than a logical not of the straightforward case for simplicity, suggested by @slevis-lmwg --- src/cpl/share_esmf/ZenderSoilErodStreamType.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 index 2749b9b28f..fdb170d4d8 100644 --- a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 +++ b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 @@ -182,10 +182,10 @@ logical function UseStreams(this) class(zendersoilerodstream_type) :: this ! ! !LOCAL VARIABLES: - if ( (trim(dust_emis_method) /= 'Zender_2003') .or. (control%zender_soil_erod_source == "atm") )then - UseStreams = .false. - else + if ( (trim(dust_emis_method) == 'Zender_2003') .and. (control%zender_soil_erod_source == "lnd") )then UseStreams = .true. + else + UseStreams = .false. end if end function UseStreams From 8c42551d770c36bed4ed233deae5027389fea1ea Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 26 Feb 2024 17:15:56 -0700 Subject: [PATCH 26/40] Change names with zendersoilerod in them, in some cases removing the zender part of it, and for zendersoilerodmapalgo add a underscore for readability --- bld/CLMBuildNamelist.pm | 2 +- bld/namelist_files/namelist_defaults_ctsm.xml | 2 +- .../namelist_definition_ctsm.xml | 2 +- src/biogeochem/DUSTMod.F90 | 12 ++++----- .../share_esmf/ZenderSoilErodStreamType.F90 | 26 +++++++++---------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index facfef91ce..18999dd5af 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -3951,7 +3951,7 @@ sub setup_logic_dust_emis { my $dust_emis_method = remove_leading_and_trailing_quotes( $nl->get_value($var) ); my @zender_files_in_lnd_opts = ( "stream_fldfilename_zendersoilerod", "stream_meshfile_zendersoilerod", - "zendersoilerodmapalgo" ); + "zendersoilerod_mapalgo" ); if ( $dust_emis_method eq "Zender_2003" ) { # get the zender_soil_erod_source add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index a6b9a7a6cc..e8328c29de 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2815,7 +2815,7 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 Zender_2003 atm -bilinear +bilinear lnd/clm2/dustemisdata/dst_source2x2tunedcam6-2x2-forCLM_cdf5_c230312.nc - Option only applying for the Zender_2003 method for whether the soil erodibility file is handled here in CTSM, or in the ATM model. diff --git a/src/biogeochem/DUSTMod.F90 b/src/biogeochem/DUSTMod.F90 index 3d1d4d80ee..ffa2bfe6f0 100644 --- a/src/biogeochem/DUSTMod.F90 +++ b/src/biogeochem/DUSTMod.F90 @@ -30,7 +30,7 @@ module DUSTMod use LandunitType , only : lun use ColumnType , only : col use PatchType , only : patch - use ZenderSoilErodStreamType, only : zendersoilerodstream_type + use ZenderSoilErodStreamType, only : soil_erod_stream_type use clm_varctl , only : dust_emis_method ! ! !PUBLIC TYPES @@ -61,7 +61,7 @@ module DUSTMod real(r8), pointer, private :: vlc_trb_2_patch (:) ! turbulent deposition velocity 2(m/s) real(r8), pointer, private :: vlc_trb_3_patch (:) ! turbulent deposition velocity 3(m/s) real(r8), pointer, private :: vlc_trb_4_patch (:) ! turbulent deposition velocity 4(m/s) - type(zendersoilerodstream_type), private :: zendersoilerodstream ! Zender soil erodibility stream data + type(soil_erod_stream_type), private :: soil_erod_stream ! Zender soil erodibility stream data real(r8), pointer, private :: mbl_bsn_fct_col (:) ! [dimensionless] basin factor, or soil erodibility, time-constant contains @@ -87,7 +87,7 @@ subroutine Init(this, bounds, NLFilename) type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename - call this%zendersoilerodstream%Init( bounds, NLFilename ) + call this%soil_erod_stream%Init( bounds, NLFilename ) call this%InitAllocate (bounds) call this%InitHistory (bounds) call this%InitCold (bounds) @@ -166,7 +166,7 @@ subroutine InitHistory(this, bounds) ptr_patch=this%vlc_trb_4_patch, default='inactive') if (dust_emis_method == 'Zender_2003') then - if ( this%zendersoilerodstream%UseStreams() )then + if ( this%soil_erod_stream%UseStreams() )then this%mbl_bsn_fct_col(begc:endc) = spval call hist_addfld1d (fname='LND_MBL', units='fraction', & avgflag='A', long_name='Soil erodibility factor', & @@ -199,8 +199,8 @@ subroutine InitCold(this, bounds) !end do call endrun( msg="Leung_2023 dust_emis_method is currently not available"//errMsg(sourcefile, __LINE__)) else if (dust_emis_method == 'Zender_2003') then - if ( this%zendersoilerodstream%UseStreams() )then - call this%zendersoilerodstream%CalcDustSource( bounds, & + if ( this%soil_erod_stream%UseStreams() )then + call this%soil_erod_stream%CalcDustSource( bounds, & this%mbl_bsn_fct_col(bounds%begc:bounds%endc) ) else this%mbl_bsn_fct_col(:) = 1.0_r8 diff --git a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 index fdb170d4d8..4eee1cbd56 100644 --- a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 +++ b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 @@ -26,7 +26,7 @@ module ZenderSoilErodStreamType implicit none private - type, public :: zendersoilerodstream_type + type, public :: soil_erod_stream_type real(r8), pointer, private :: soil_erodibility (:) ! Zender et al. (2003b) dust source function (or soil erodibility) contains @@ -38,14 +38,14 @@ module ZenderSoilErodStreamType ! !PRIVATE MEMBER FUNCTIONS: procedure, private :: InitAllocate ! Allocate data - end type zendersoilerodstream_type + end type soil_erod_stream_type ! ! PRIVATE DATA: type, private :: streamcontrol_type character(len=CL) :: zender_soil_erod_source ! if calculed in lnd or atm character(len=CL) :: stream_fldFileName_zendersoilerod ! data Filename character(len=CL) :: stream_meshfile_zendersoilerod ! mesh Filename - character(len=CL) :: zendersoilerodmapalgo ! map algo + character(len=CL) :: zendersoilerod_mapalgo ! map algo contains procedure, private :: ReadNML ! Read in namelist end type streamcontrol_type @@ -72,7 +72,7 @@ subroutine Init(this, bounds, NLFilename) ! ! arguments implicit none - class(zendersoilerodstream_type) :: this + class(soil_erod_stream_type) :: this type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename ! Namelist filename ! @@ -112,7 +112,7 @@ subroutine Init(this, bounds, NLFilename) model_mesh = mesh, & stream_meshfile = control%stream_meshfile_zendersoilerod, & stream_lev_dimname = 'null', & - stream_mapalgo = control%zendersoilerodmapalgo, & + stream_mapalgo = control%zendersoilerod_mapalgo, & stream_filenames = (/trim(control%stream_fldFileName_zendersoilerod)/), & stream_fldlistFile = stream_varnames, & stream_fldListModel = stream_varnames, & @@ -179,7 +179,7 @@ logical function UseStreams(this) ! ! !ARGUMENTS: implicit none - class(zendersoilerodstream_type) :: this + class(soil_erod_stream_type) :: this ! ! !LOCAL VARIABLES: if ( (trim(dust_emis_method) == 'Zender_2003') .and. (control%zender_soil_erod_source == "lnd") )then @@ -200,7 +200,7 @@ subroutine InitAllocate(this, bounds) ! ! !ARGUMENTS: implicit none - class(zendersoilerodstream_type) :: this + class(soil_erod_stream_type) :: this type(bounds_type), intent(in) :: bounds ! ! !LOCAL VARIABLES: @@ -233,7 +233,7 @@ subroutine CalcDustSource(this, bounds, soil_erod) ! ! !ARGUMENTS: implicit none - class(zendersoilerodstream_type) :: this + class(soil_erod_stream_type) :: this type(bounds_type) , intent(in) :: bounds real(r8) , intent(inout) :: soil_erod(bounds%begc:) ! [fraction] rock drag partition factor (roughness effect) ! @@ -294,14 +294,14 @@ subroutine ReadNML(this, bounds, NLFilename) integer :: nml_error ! namelist i/o error flag character(len=CL) :: stream_fldFileName_zendersoilerod = ' ' character(len=CL) :: stream_meshfile_zendersoilerod = ' ' - character(len=CL) :: zendersoilerodmapalgo = 'bilinear' + character(len=CL) :: zendersoilerod_mapalgo = 'bilinear' character(len=3) :: zender_soil_erod_source = 'atm' character(len=*), parameter :: namelist_name = 'zendersoilerod' ! MUST agree with group name in namelist definition to read. character(len=*), parameter :: subName = "('zendersoilerod::ReadNML')" !----------------------------------------------------------------------- namelist /zendersoilerod/ & ! MUST agree with namelist_name above - zendersoilerodmapalgo, zendersoilerodmapalgo, stream_fldFileName_zendersoilerod, & + zendersoilerod_mapalgo, zendersoilerod_mapalgo, stream_fldFileName_zendersoilerod, & stream_meshfile_zendersoilerod, zender_soil_erod_source ! Default values for namelist @@ -321,7 +321,7 @@ subroutine ReadNML(this, bounds, NLFilename) close(nu_nml) endif - call shr_mpi_bcast(zendersoilerodmapalgo , mpicom) + call shr_mpi_bcast(zendersoilerod_mapalgo , mpicom) call shr_mpi_bcast(stream_fldFileName_zendersoilerod , mpicom) call shr_mpi_bcast(stream_meshfile_zendersoilerod , mpicom) @@ -330,7 +330,7 @@ subroutine ReadNML(this, bounds, NLFilename) write(iulog,*) namelist_name, ' stream settings:' write(iulog,*) ' stream_fldFileName_zendersoilerod = ',stream_fldFileName_zendersoilerod write(iulog,*) ' stream_meshfile_zendersoilerod = ',stream_meshfile_zendersoilerod - write(iulog,*) ' zendersoilerodmapalgo = ',zendersoilerodmapalgo + write(iulog,*) ' zendersoilerod_mapalgo = ',zendersoilerod_mapalgo endif if ( (trim(zender_soil_erod_source) /= 'atm') .and. (trim(zender_soil_erod_source) /= 'lnd') )then @@ -346,7 +346,7 @@ subroutine ReadNML(this, bounds, NLFilename) end if this%stream_fldFileName_zendersoilerod = stream_fldFileName_zendersoilerod this%stream_meshfile_zendersoilerod = stream_meshfile_zendersoilerod - this%zendersoilerodmapalgo = zendersoilerodmapalgo + this%zendersoilerod_mapalgo = zendersoilerod_mapalgo this%zender_soil_erod_source = zender_soil_erod_source end subroutine ReadNML From 1421d6d76cbff3a2ec274205f2d4933eabe840db Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 26 Feb 2024 18:25:41 -0700 Subject: [PATCH 27/40] Fix some issues from comments in the PR, make sure all namelist items are broadcast, remove an unneeded item, add checks that namelist items are set (or not set) appropriately --- .../share_esmf/ZenderSoilErodStreamType.F90 | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 index 4eee1cbd56..11ae162d1e 100644 --- a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 +++ b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 @@ -290,18 +290,20 @@ subroutine ReadNML(this, bounds, NLFilename) character(len=*), intent(in) :: NLFilename ! Namelist filename ! ! local variables + integer :: i ! Indices integer :: nu_nml ! unit for namelist file integer :: nml_error ! namelist i/o error flag character(len=CL) :: stream_fldFileName_zendersoilerod = ' ' character(len=CL) :: stream_meshfile_zendersoilerod = ' ' - character(len=CL) :: zendersoilerod_mapalgo = 'bilinear' + character(len=CL) :: zendersoilerod_mapalgo = ' ' + character(len=CL) :: tmp_file_array(3) character(len=3) :: zender_soil_erod_source = 'atm' character(len=*), parameter :: namelist_name = 'zendersoilerod' ! MUST agree with group name in namelist definition to read. character(len=*), parameter :: subName = "('zendersoilerod::ReadNML')" !----------------------------------------------------------------------- namelist /zendersoilerod/ & ! MUST agree with namelist_name above - zendersoilerod_mapalgo, zendersoilerod_mapalgo, stream_fldFileName_zendersoilerod, & + zendersoilerod_mapalgo, stream_fldFileName_zendersoilerod, & stream_meshfile_zendersoilerod, zender_soil_erod_source ! Default values for namelist @@ -321,7 +323,8 @@ subroutine ReadNML(this, bounds, NLFilename) close(nu_nml) endif - call shr_mpi_bcast(zendersoilerod_mapalgo , mpicom) + call shr_mpi_bcast(zender_soil_erod_source , mpicom) + call shr_mpi_bcast(zendersoilerod_mapalgo , mpicom) call shr_mpi_bcast(stream_fldFileName_zendersoilerod , mpicom) call shr_mpi_bcast(stream_meshfile_zendersoilerod , mpicom) @@ -330,23 +333,31 @@ subroutine ReadNML(this, bounds, NLFilename) write(iulog,*) namelist_name, ' stream settings:' write(iulog,*) ' stream_fldFileName_zendersoilerod = ',stream_fldFileName_zendersoilerod write(iulog,*) ' stream_meshfile_zendersoilerod = ',stream_meshfile_zendersoilerod - write(iulog,*) ' zendersoilerod_mapalgo = ',zendersoilerod_mapalgo + write(iulog,*) ' zendersoilerod_mapalgo = ',zendersoilerod_mapalgo endif if ( (trim(zender_soil_erod_source) /= 'atm') .and. (trim(zender_soil_erod_source) /= 'lnd') )then call endrun(msg=' ERROR zender_soil_erod_source must be either lnd or atm and is NOT'//errMsg(sourcefile, __LINE__)) end if + tmp_file_array(1) = stream_fldFileName_zendersoilerod + tmp_file_array(2) = stream_meshfile_zendersoilerod + tmp_file_array(3) = zendersoilerod_mapalgo if ( trim(zender_soil_erod_source) == 'lnd' )then - if ( len_trim(stream_meshfile_zendersoilerod) == 0 )then - call endrun(msg=' ERROR stream_meshfile_zendersoilerod must be set when Zender_2003 is being used and zender_soil_erod_source is lnd'//errMsg(sourcefile, __LINE__)) - end if - if ( len_trim(stream_meshfile_zendersoilerod) == 0 )then - call endrun(msg=' ERROR stream_meshfile_zendersoilerod must be set when Zender_2003 is being used and zender_soil_erod_source is lnd'//errMsg(sourcefile, __LINE__)) - end if + do i = 1, size(tmp_file_array) + if ( len_trim(tmp_file_array(i)) == 0 )then + call endrun(msg=' ERROR '//trim(tmp_file_array(i)//' must be set when Zender_2003 is being used and zender_soil_erod_source is lnd'//errMsg(sourcefile, __LINE__)) + end if + end do + else + do i = 1, size(tmp_file_array) + if ( len_trim(tmp_file_array(i)) > 0 )then + call endrun(msg=' ERROR '//trim(tmp_file_array(i)//' is set and MUST iNOT be when Zender_2003 is NOT being used or zender_soil_erod_source is atm'//errMsg(sourcefile, __LINE__)) + end if + end do end if this%stream_fldFileName_zendersoilerod = stream_fldFileName_zendersoilerod this%stream_meshfile_zendersoilerod = stream_meshfile_zendersoilerod - this%zendersoilerod_mapalgo = zendersoilerod_mapalgo + this%zendersoilerod_mapalgo = zendersoilerod_mapalgo this%zender_soil_erod_source = zender_soil_erod_source end subroutine ReadNML From b66c1f06e6d10d7f6b7ff627684c827c2424e5af Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 26 Feb 2024 18:54:14 -0700 Subject: [PATCH 28/40] Fix issue so will compile --- src/cpl/share_esmf/ZenderSoilErodStreamType.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 index 11ae162d1e..1755a32f76 100644 --- a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 +++ b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 @@ -345,13 +345,13 @@ subroutine ReadNML(this, bounds, NLFilename) if ( trim(zender_soil_erod_source) == 'lnd' )then do i = 1, size(tmp_file_array) if ( len_trim(tmp_file_array(i)) == 0 )then - call endrun(msg=' ERROR '//trim(tmp_file_array(i)//' must be set when Zender_2003 is being used and zender_soil_erod_source is lnd'//errMsg(sourcefile, __LINE__)) + call endrun(msg=' ERROR '//trim(tmp_file_array(i))//' must be set when Zender_2003 is being used and zender_soil_erod_source is lnd'//errMsg(sourcefile, __LINE__)) end if end do else do i = 1, size(tmp_file_array) if ( len_trim(tmp_file_array(i)) > 0 )then - call endrun(msg=' ERROR '//trim(tmp_file_array(i)//' is set and MUST iNOT be when Zender_2003 is NOT being used or zender_soil_erod_source is atm'//errMsg(sourcefile, __LINE__)) + call endrun(msg=' ERROR '//trim(tmp_file_array(i))//' is set and MUST iNOT be when Zender_2003 is NOT being used or zender_soil_erod_source is atm'//errMsg(sourcefile, __LINE__)) end if end do end if From 23eb33be6eb1a3f681d4492f4376ac816959446f Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 26 Feb 2024 19:09:24 -0700 Subject: [PATCH 29/40] Add comment about dust_emis_method --- src/main/controlMod.F90 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90 index b3120c353a..d8a0eb6fea 100644 --- a/src/main/controlMod.F90 +++ b/src/main/controlMod.F90 @@ -205,7 +205,13 @@ subroutine control_init(dtime) crop_fsat_equals_zero, for_testing_run_ncdiopio_tests, & for_testing_use_second_grain_pool, for_testing_use_repr_structure_pool, & for_testing_no_crop_seed_replenishment, & - z0param_method, use_z0m_snowmelt, dust_emis_method + z0param_method, use_z0m_snowmelt + + ! NOTE: EBK 02/26/2024: dust_emis_method is here in CTSM temporarily until it's moved to CMEPS + ! See: https://github.com/ESCOMP/CMEPS/pull/429 + ! Normally this should also need error checking and a broadcast, but since + ! there is only one hardcoded option right now that is unneeded. + namelist /clm_inparm/ dust_emis_method ! vertical soil mixing variables namelist /clm_inparm/ & From cd005b3c548e69c019c3262322c0e6de107c5dfa Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Tue, 27 Feb 2024 14:51:23 -0700 Subject: [PATCH 30/40] Add some Zender soil eroditability tests for izumi, and a 1-degree CLM4 test for Derecho --- cime_config/testdefs/testlist_clm.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index d602e25413..8359217e65 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -55,15 +55,26 @@ + + + + + + + + + + + From 9dc57dad549ff537bf1e65f16aa9baac49d6179b Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Wed, 28 Feb 2024 14:39:28 -0700 Subject: [PATCH 31/40] Change izumi_nag test to izumi_gnu because non-DEBUG tests don't build on izumi --- cime_config/testdefs/testlist_clm.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 8359217e65..90f8b4a6a7 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -55,7 +55,7 @@ - + @@ -74,7 +74,7 @@ - + From f5168f9a995dbe37d57bf31e0284ea98e35d5754 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 22 Mar 2024 16:38:54 -0600 Subject: [PATCH 32/40] Fix ordering so that array is allocated properly --- src/cpl/share_esmf/ZenderSoilErodStreamType.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 index 1755a32f76..0d5a7653dc 100644 --- a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 +++ b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 @@ -90,8 +90,8 @@ subroutine Init(this, bounds, NLFilename) character(len=*), parameter :: stream_name = 'zendersoilerod' !----------------------------------------------------------------------- - call this%InitAllocate( bounds ) call control%ReadNML( bounds, NLFileName ) + call this%InitAllocate( bounds ) if ( this%useStreams() )then ! is this a namelist input and is it set in namelist default From 67bbf59cd7bbf1b03ed979989723effaf027ab7d Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 22 Mar 2024 17:46:42 -0600 Subject: [PATCH 33/40] Add some error checking that would have caught the previous problem --- src/cpl/share_esmf/ZenderSoilErodStreamType.F90 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 index 0d5a7653dc..1dfe899700 100644 --- a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 +++ b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 @@ -45,7 +45,8 @@ module ZenderSoilErodStreamType character(len=CL) :: zender_soil_erod_source ! if calculed in lnd or atm character(len=CL) :: stream_fldFileName_zendersoilerod ! data Filename character(len=CL) :: stream_meshfile_zendersoilerod ! mesh Filename - character(len=CL) :: zendersoilerod_mapalgo ! map algo + character(len=CL) :: zendersoilerod_mapalgo ! map algo + logical :: namelist_set = .false. ! if namelist was set yet contains procedure, private :: ReadNML ! Read in namelist end type streamcontrol_type @@ -182,6 +183,9 @@ logical function UseStreams(this) class(soil_erod_stream_type) :: this ! ! !LOCAL VARIABLES: + if ( .not. control%namelist_set )then + call endrun(msg=' ERROR namelist NOT set before being used'//errMsg(sourcefile, __LINE__)) + end if if ( (trim(dust_emis_method) == 'Zender_2003') .and. (control%zender_soil_erod_source == "lnd") )then UseStreams = .true. else @@ -360,6 +364,8 @@ subroutine ReadNML(this, bounds, NLFilename) this%zendersoilerod_mapalgo = zendersoilerod_mapalgo this%zender_soil_erod_source = zender_soil_erod_source + this%namelist_set = .true. + end subroutine ReadNML end module ZenderSoilErodStreamType From 1d64435838e78e331df7ec6030ae6d09b81600fc Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 25 Mar 2024 12:40:38 -0600 Subject: [PATCH 34/40] Remove uneeded comment, and add a TODO from the code review --- src/cpl/share_esmf/ZenderSoilErodStreamType.F90 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 index 1dfe899700..73c93a5b92 100644 --- a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 +++ b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 @@ -157,13 +157,16 @@ subroutine Init(this, bounds, NLFilename) if (trim(stream_varnames(n)) == 'mbl_bsn_fct_geo') then ig = 0 do g = bounds%begg,bounds%endg - ig = ig+1 ! not sure why +1 is needed but it's okay + ig = ig+1 this%soil_erodibility(g) = dataptr1d(ig) end do end if end do + ! TODO: EBK 03/25/2024: When shr_strdata adds a clean method we should invoke it here to save memory + ! This is talked about in https://github.com/ESCOMP/CDEPS/issues/261 + end if end subroutine Init From 36bfba6e821f48948b6486269a1621fab894b72a Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 25 Mar 2024 13:02:36 -0600 Subject: [PATCH 35/40] Remove trailing whitespace --- src/cpl/share_esmf/ZenderSoilErodStreamType.F90 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 index 73c93a5b92..194e022132 100644 --- a/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 +++ b/src/cpl/share_esmf/ZenderSoilErodStreamType.F90 @@ -13,7 +13,7 @@ module ZenderSoilErodStreamType ! with the other files. ! ! !USES - use ESMF , only : ESMF_LogFoundError, ESMF_LOGERR_PASSTHRU, ESMF_Finalize, ESMF_END_ABORT + use ESMF , only : ESMF_LogFoundError, ESMF_LOGERR_PASSTHRU, ESMF_Finalize, ESMF_END_ABORT use dshr_strdata_mod , only : shr_strdata_type use shr_kind_mod , only : r8 => shr_kind_r8, CL => shr_kind_cl use shr_log_mod , only : errMsg => shr_log_errMsg @@ -53,7 +53,7 @@ module ZenderSoilErodStreamType type(streamcontrol_type), private :: control ! Stream control data - character(len=*), parameter, private :: sourcefile = & + character(len=*), parameter, private :: sourcefile = & __FILE__ !============================================================================== @@ -148,7 +148,7 @@ subroutine Init(this, bounds, NLFilename) end if ! Get pointer for stream data that is time and spatially interpolate to model time and grid - do n = 1,size(stream_varnames) + do n = 1,size(stream_varnames) call dshr_fldbun_getFldPtr(sdat_erod%pstrm(1)%fldbun_model, stream_varnames(n), fldptr1=dataptr1d, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then write(iulog,*) 'Error on get field pointer -- see PET*.ESMF_LogFile(s)' @@ -248,7 +248,7 @@ subroutine CalcDustSource(this, bounds, soil_erod) !integer :: g, c, fc ! Indices integer :: g, p, fp, l, c ! Indices !real(r8) :: z0s ! smooth roughness length (m) - + ! constants real(r8),parameter :: soil_erod_threshold = 0.1_r8 ! CAM soil erodibility threshold; below threshold -> soil_erod = 0_r8 11 Mar 2023 !--------------------------------------------------------------------- @@ -268,10 +268,10 @@ subroutine CalcDustSource(this, bounds, soil_erod) if (this%soil_erodibility(g) .lt. soil_erod_threshold ) then soil_erod(c) = 0._r8 - else + else soil_erod(c) = this%soil_erodibility(g) end if - + end if end do From 7943f8d3b0d2cf56efe2f840756552f6c05d49d0 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 25 Mar 2024 13:07:12 -0600 Subject: [PATCH 36/40] Another trailing blank --- src/main/controlMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90 index cc56cb8d59..dc9622ddac 100644 --- a/src/main/controlMod.F90 +++ b/src/main/controlMod.F90 @@ -205,7 +205,7 @@ subroutine control_init(dtime) crop_fsat_equals_zero, for_testing_run_ncdiopio_tests, & for_testing_use_second_grain_pool, for_testing_use_repr_structure_pool, & for_testing_no_crop_seed_replenishment, & - z0param_method, use_z0m_snowmelt + z0param_method, use_z0m_snowmelt ! NOTE: EBK 02/26/2024: dust_emis_method is here in CTSM temporarily until it's moved to CMEPS ! See: https://github.com/ESCOMP/CMEPS/pull/429 From 20e3fe9bac504a336107b165ab13f1d09fc7d595 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 25 Mar 2024 13:08:52 -0600 Subject: [PATCH 37/40] More trailing whitspace --- bld/CLMBuildNamelist.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index f62a16ffa1..fd8def8845 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -1266,7 +1266,7 @@ sub setup_cmdl_simulation_year { sub setup_cmdl_run_type { my ($opts, $nl_flags, $definition, $defaults, $nl) = @_; # Set the clm_start_type and the st_year, start year - # This MUST be done after lnd_tuning_mode is set + # This MUST be done after lnd_tuning_mode is set my $val; my $var = "clm_start_type"; @@ -3975,7 +3975,7 @@ sub setup_logic_dust_emis { my $dust_emis_method = remove_leading_and_trailing_quotes( $nl->get_value($var) ); - my @zender_files_in_lnd_opts = ( "stream_fldfilename_zendersoilerod", "stream_meshfile_zendersoilerod", + my @zender_files_in_lnd_opts = ( "stream_fldfilename_zendersoilerod", "stream_meshfile_zendersoilerod", "zendersoilerod_mapalgo" ); if ( $dust_emis_method eq "Zender_2003" ) { # get the zender_soil_erod_source From b63459e6a50e00d67f56663b70781b09a6b18144 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 25 Mar 2024 14:21:41 -0600 Subject: [PATCH 38/40] Correct number of tests --- bld/unit_testers/build-namelist_test.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 76612736be..f207053924 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -166,7 +166,7 @@ sub cat_and_create_namelistinfile { my $ntests = 1611; if ( defined($opts{'compare'}) ) { - $ntests += 1145; + $ntests += 945; } plan( tests=>$ntests ); From 296a00eeae9840a61f06a9fa6eeabaa211d382cb Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Tue, 26 Mar 2024 10:17:21 -0600 Subject: [PATCH 39/40] Remove a bunch of uneeded settings for initial conditions and use_init_interp, this gets the ERI_D.ne30pg3_t232.I1850Clm51BgcCrop.derecho_intel.clm-clm51cam6LndTuningMode test giving identical answers as baseline --- bld/namelist_files/namelist_defaults_ctsm.xml | 68 +++---------------- 1 file changed, 10 insertions(+), 58 deletions(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 682955b204..a01839836d 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -665,15 +665,7 @@ attributes from the config_cache.xml file (with keys converted to upper-case). -.true. -.true. -.true. -.true. -.true. -.true. -.true. -.true. -.true. +.true. .true. -.true. -.true. -.true. -.true. -.true. -.true. +.true. +.true. .true. .true. .true. -.false. -.false. -.false. -.false. -.false. -.false. + +.false. +.false. +.false. +.false. +.false. +.false. .false. hgrid=0.9x1.25 maxpft=79 mask=gx1v7 use_cn=.true. use_crop=.true. irrigate=.false. glc_nec=10 do_transient_pfts=.false. @@ -797,14 +781,6 @@ attributes from the config_cache.xml file (with keys converted to upper-case). >hgrid=1.9x2.5 maxpft=79 mask=gx1v7 use_cn=.true. use_crop=.true. irrigate=.true. glc_nec=10 do_transient_pfts=.false. -hgrid=1.9x2.5 maxpft=79 mask=gx1v7 use_cn=.true. use_crop=.true. irrigate=.true. glc_nec=10 do_transient_pfts=.false. - - -hgrid=1.9x2.5 maxpft=79 mask=gx1v7 use_cn=.true. use_crop=.true. irrigate=.true. glc_nec=10 do_transient_pfts=.false. - - hgrid=1.9x2.5 maxpft=79 mask=gx1v7 use_cn=.true. use_crop=.true. irrigate=.true. glc_nec=10 do_transient_pfts=.false. @@ -1038,18 +1014,6 @@ attributes from the config_cache.xml file (with keys converted to upper-case). lnd_tuning_mode="clm5_1_GSWP3v1" >lnd/clm2/initdata_map/clmi.I1850Clm50BgcCrop-ciso.1366-01-01.0.9x1.25_gx1v7_simyr1850_c200428.nc -lnd/clm2/initdata_map/clmi.I1850Clm50BgcCrop-ciso.1366-01-01.0.9x1.25_gx1v7_simyr1850_c200428.nc - -lnd/clm2/initdata_map/clmi.I1850Clm50BgcCrop-ciso.1366-01-01.0.9x1.25_gx1v7_simyr1850_c200428.nc - lnd/clm2/initdata_map/clmi.I2000Clm50BgcCrop.2011-01-01.1.9x2.5_gx1v7_gl4_simyr2000_c190312.nc -lnd/clm2/initdata_map/clmi.I2000Clm50BgcCrop.2011-01-01.1.9x2.5_gx1v7_gl4_simyr2000_c190312.nc - -lnd/clm2/initdata_map/clmi.I2000Clm50BgcCrop.2011-01-01.1.9x2.5_gx1v7_gl4_simyr2000_c190312.nc - From b01fbb5312f6e6c9dc1332d542b9180573e56955 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Tue, 26 Mar 2024 12:02:22 -0600 Subject: [PATCH 40/40] Change compilers up for ZDustSoilErod tests a bit, and make sure there is a izumi_nag test --- cime_config/testdefs/testlist_clm.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 3209068d46..8354a40c60 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -73,8 +73,8 @@ - - + + @@ -85,6 +85,7 @@ +