Skip to content

Commit

Permalink
Changes to remove dust_emis namelist items from CTSM fortran code and…
Browse files Browse the repository at this point in the history
… use shr_dust_emis_mod from CMEPS
  • Loading branch information
ekluzek committed Jul 11, 2024
1 parent 9878509 commit 17fb3d8
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 33 deletions.
1 change: 0 additions & 1 deletion src/biogeochem/DustEmisBase.F90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module DustEmisBase
use LandunitType , only : lun
use ColumnType , only : col
use PatchType , only : patch
use clm_varctl , only : dust_emis_method
!
! !PUBLIC TYPES
implicit none
Expand Down
14 changes: 6 additions & 8 deletions src/biogeochem/DustEmisFactory.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,28 @@ function create_dust_emissions(bounds, NLFilename) result(dust_emis)
!---------------------------------------------------------------------------
use DustEmisBase , only : dust_emis_base_type
use DustEmisZender2003, only : dust_emis_zender2003_type
use clm_varctl , only : dust_emis_method
use decompMod , only : bounds_type
use shr_kind_mod , only : CL => shr_kind_cl
use shr_dust_emis_mod , only : is_dust_emis_zender, is_dust_emis_leung
implicit none
! Arguments
class(dust_emis_base_type), allocatable :: dust_emis
type(bounds_type), intent(in) :: bounds
character(len=*), intent(in) :: NLFilename
! Local variables

select case ( trim(dust_emis_method) )

case( "Zender_2003" )
if ( is_dust_emis_zender() )then
allocate(dust_emis, source=dust_emis_zender2003_type() )

! This will be added when the Leung2023 comes in
!case( "Leung_2023" )
!else if ( is_dust_emis_leung() )
! allocate(dust_emis, source=dust_emis_zender2003_type() )
case default
write(iulog,*) 'ERROR: unknown dust_emis_method: ', dust_emis_method, &
else
write(iulog,*) 'ERROR: unknown dust_emis_method: ', &
errMsg(sourcefile, __LINE__)
call endrun( "Unrecognized dust_emis_method" )

end select
end if

call dust_emis%Init(bounds, NLFilename)

Expand Down
2 changes: 2 additions & 0 deletions src/biogeochem/test/DustEmis_test/test_DustEmisZender2003.pf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module test_DustEmisZender2003
use DustEmisZender2003
use shr_kind_mod , only : r8 => shr_kind_r8
use DustEmisFactory, only : create_dust_emissions
use shr_dust_emis_mod, only : dust_emis_set_options

implicit none

Expand Down Expand Up @@ -37,6 +38,7 @@ contains
call this%input%setUp()

! Create the dust emission object last
call dust_emis_set_options( 'Zender_2003', 'atm')
allocate(this%dust_emis, source = create_dust_emissions(bounds, NLFilename))
end subroutine setUp

Expand Down
5 changes: 5 additions & 0 deletions src/cpl/nuopc/lnd_import_export.F90
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,11 @@ subroutine advertise_fields(gcomp, flds_scalar_name, glc_present, cism_evolve, r

use shr_carma_mod , only : shr_carma_readnl
use shr_ndep_mod , only : shr_ndep_readnl
use shr_dust_emis_mod , only : shr_dust_emis_readnl
use shr_fire_emis_mod , only : shr_fire_emis_readnl
use clm_varctl , only : ndep_from_cpl
use controlMod , only : NLFilename
use spmdMod , only : mpicom

! input/output variables
type(ESMF_GridComp) :: gcomp
Expand Down Expand Up @@ -237,6 +239,9 @@ subroutine advertise_fields(gcomp, flds_scalar_name, glc_present, cism_evolve, r

! The following namelist reads should always be called regardless of the send_to_atm value

! Dust emissions from land to atmosphere
call shr_dust_emis_readnl( mpicom, "drv_flds_in")

! Dry Deposition velocities from land - ALSO initialize drydep here
call shr_drydep_readnl("drv_flds_in", drydep_nflds)

Expand Down
18 changes: 6 additions & 12 deletions src/cpl/share_esmf/ZenderSoilErodStreamType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ 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) :: zendersoilerod_mapalgo ! map algo
Expand Down Expand Up @@ -179,7 +178,7 @@ logical function UseStreams(this)
! file is being used with it
!
! !USES:
use clm_varctl, only : dust_emis_method
use shr_dust_emis_mod, only : is_dust_emis_zender, is_zender_soil_erod_from_land
!
! !ARGUMENTS:
implicit none
Expand All @@ -189,7 +188,7 @@ logical function UseStreams(this)
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
if ( is_dust_emis_zender() .and. is_zender_soil_erod_from_land() )then
UseStreams = .true.
else
UseStreams = .false.
Expand Down Expand Up @@ -289,6 +288,7 @@ subroutine ReadNML(this, bounds, NLFilename)
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
use shr_dust_emis_mod, only : is_zender_soil_erod_from_land
!
! arguments
implicit none
Expand All @@ -304,14 +304,13 @@ subroutine ReadNML(this, bounds, NLFilename)
character(len=CL) :: stream_meshfile_zendersoilerod = ' '
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, stream_fldFileName_zendersoilerod, &
stream_meshfile_zendersoilerod, zender_soil_erod_source
stream_meshfile_zendersoilerod

! Default values for namelist

Expand All @@ -330,26 +329,22 @@ subroutine ReadNML(this, bounds, NLFilename)
close(nu_nml)
endif

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)

if (masterproc .and. (zender_soil_erod_source == "lnd") ) then
if (masterproc .and. is_zender_soil_erod_from_land() ) 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,*) ' 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 ( is_zender_soil_erod_from_land() ) 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__))
Expand All @@ -365,7 +360,6 @@ subroutine ReadNML(this, bounds, NLFilename)
this%stream_fldFileName_zendersoilerod = stream_fldFileName_zendersoilerod
this%stream_meshfile_zendersoilerod = stream_meshfile_zendersoilerod
this%zendersoilerod_mapalgo = zendersoilerod_mapalgo
this%zender_soil_erod_source = zender_soil_erod_source

this%namelist_set = .true.

Expand Down
5 changes: 0 additions & 5 deletions src/main/clm_varctl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,6 @@ 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
!----------------------------------------------------------
Expand Down
6 changes: 0 additions & 6 deletions src/main/controlMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,6 @@ subroutine control_init(dtime)
for_testing_no_crop_seed_replenishment, &
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/ &
som_adv_flux, max_depth_cryoturb
Expand Down

0 comments on commit 17fb3d8

Please sign in to comment.