Skip to content

Commit

Permalink
Add a barebones dust emission factory module to create a dust emissio…
Browse files Browse the repository at this point in the history
…n class object to be used depending on the namelist option, need to add documentation to it
  • Loading branch information
ekluzek committed Jun 7, 2024
1 parent 0f511ee commit 46862cc
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/biogeochem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ list(APPEND clm_sources
CNDVType.F90
DustEmisBase.F90
DustEmisZender2003.F90
DustEmisFactory.F90
CropReprPoolsMod.F90
CropType.F90
CNVegStateType.F90
Expand Down
51 changes: 51 additions & 0 deletions src/biogeochem/DustEmisFactory.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
module DustEmisFactory

use abortutils , only : endrun
use shr_log_mod , only : errMsg => shr_log_errMsg
use clm_varctl , only : iulog

implicit none
save
private
!
public :: create_dust_emissions ! create an object of class dust_emis_base

character(len=*), parameter, private :: sourcefile = &
__FILE__

contains

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
implicit none
class(dust_emis_base_type), allocatable :: dust_emis
type(bounds_type), intent(in) :: bounds
character(len=*), intent(in) :: NLFilename
character(len=CL) :: method

method = dust_emis_method

select case ( trim(method) )

case( "Zender_2003" )
allocate(dust_emis, source=dust_emis_zender2003_type() )

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

end select

call dust_emis%Init(bounds, NLFilename)

end function create_dust_emissions

end module DustEmisFactory
14 changes: 14 additions & 0 deletions src/biogeochem/DustEmisZender2003.F90
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,27 @@ module DustEmisZender2003
procedure , private :: InitCold

end type dust_emis_zender2003_type

interface dust_emis_zender2003_type
! initialize a new dust emission object
module procedure constructor
end interface dust_emis_zender2003_type
!------------------------------------------------------------------------

character(len=*), parameter, private :: sourcefile = &
__FILE__

contains

!-----------------------------------------------------------------------
type(dust_emis_zender2003_type) function constructor()
!
! Creates a dust emission object for Zender-2003 type
! For now this is just a placeholder
!-----------------------------------------------------------------------

end function constructor

!------------------------------------------------------------------------

subroutine InitZender2003(this, bounds, NLFilename)
Expand Down
6 changes: 4 additions & 2 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 clm_varctl, only : soil_layerstruct_predefined, create_crop_landunit, use_crop, create_crop_landunit
use clm_varcon, only : clm_varcon_init, clm_varcon_clean
use SnowHydrologyMod, only : InitSnowLayers, SnowHydrologySetControlForTesting, SnowHydrologyClean
use DustEmisBase
use DustEmisZender2003
use shr_kind_mod , only : r8 => shr_kind_r8
use unittestFilterBuilderMod, only : filter_from_range
Expand All @@ -20,14 +21,15 @@ module test_DustEmisZender2003
use FrictionVelocityMod, only : frictionvel_type
use unittestWaterTypeFactory, only : unittest_water_type_factory_type
use SoilStateInitTimeConstMod, only : ThresholdSoilMoistZender2003, ThresholdSoilMoistKok2014, MassFracClay
use DustEmisFactory, only : create_dust_emissions

implicit none

real(r8), parameter :: tol = 1.e-18_r8

@TestCase
type, extends(TestCase) :: TestDustEmisZender2003
type(dust_emis_zender2003_type) :: dust_emis
class(dust_emis_base_type), allocatable :: dust_emis
integer, allocatable :: filter_nolakep(:) ! non-lake filter (patches)
integer :: num_nolakep ! number of patches in non-lake filter
type(atm2lnd_type) :: atm2lnd_inst
Expand Down Expand Up @@ -79,7 +81,7 @@ contains
endc = bounds%endc
allocate( urb_em(begl:endl) )

call this%dust_emis%Init( bounds, NLFilename )
allocate(this%dust_emis, source = create_dust_emissions(bounds, NLFilename))
call filter_from_range(start=bounds%begp, end=bounds%endp, numf=this%num_nolakep, filter=this%filter_nolakep)
atm2lnd_params = atm2lnd_params_type( repartition_rain_snow = .false., &
glcmec_downscale_longwave = .false., &
Expand Down
7 changes: 4 additions & 3 deletions src/main/clm_instMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module clm_instMod
use SoilBiogeochemNitrogenStateType , only : soilbiogeochem_nitrogenstate_type
use CropType , only : crop_type
use DryDepVelocity , only : drydepvel_type
use DustEmisZender2003 , only : dust_emis_zender2003_type
use DustEmisBase , only : dust_emis_base_type
use EnergyFluxType , only : energyflux_type
use FrictionVelocityMod , only : frictionvel_type
use GlacierSurfaceMassBalanceMod , only : glacier_smb_type
Expand Down Expand Up @@ -151,7 +151,7 @@ module clm_instMod
! General biogeochem types
type(ch4_type) , public :: ch4_inst
type(crop_type) , public :: crop_inst
type(dust_emis_zender2003_type) , public :: dust_emis_inst
class(dust_emis_base_type), public, allocatable :: dust_emis_inst
type(vocemis_type) , public :: vocemis_inst
type(fireemis_type) , public :: fireemis_inst
type(drydepvel_type), public :: drydepvel_inst
Expand Down Expand Up @@ -203,6 +203,7 @@ subroutine clm_instInit(bounds)
use clm_varctl , only : use_hillslope
use HillslopeHydrologyMod , only : SetHillslopeSoilThickness
use initVerticalMod , only : setSoilLayerClass
use DustEmisFactory , only : create_dust_emissions
!
! !ARGUMENTS
type(bounds_type), intent(in) :: bounds ! processor bounds
Expand Down Expand Up @@ -350,7 +351,7 @@ subroutine clm_instInit(bounds)

call surfrad_inst%Init(bounds)

call dust_emis_inst%Init(bounds, NLFilename)
allocate(dust_emis_inst, source = create_dust_emissions(bounds, NLFilename))

allocate(scf_method, source = CreateAndInitSnowCoverFraction( &
snow_cover_fraction_method = snow_cover_fraction_method, &
Expand Down
4 changes: 2 additions & 2 deletions src/main/lnd2atmMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module lnd2atmMod
use lnd2atmType , only : lnd2atm_type
use atm2lndType , only : atm2lnd_type
use ch4Mod , only : ch4_type
use DustEmisZender2003 , only : dust_emis_zender2003_type
use DustEmisBase , only : dust_emis_base_type
use DryDepVelocity , only : drydepvel_type
use VocEmissionMod , only : vocemis_type
use CNFireEmissionsMod , only : fireemis_type
Expand Down Expand Up @@ -173,7 +173,7 @@ subroutine lnd2atm(bounds, &
type(drydepvel_type) , intent(in) :: drydepvel_inst
type(vocemis_type) , intent(in) :: vocemis_inst
type(fireemis_type) , intent(in) :: fireemis_inst
type(dust_emis_zender2003_type) , intent(in) :: dust_emis_inst
class(dust_emis_base_type) , intent(in) :: dust_emis_inst
type(ch4_type) , intent(in) :: ch4_inst
type(glc_behavior_type) , intent(in) :: glc_behavior
type(lnd2atm_type) , intent(inout) :: lnd2atm_inst
Expand Down

0 comments on commit 46862cc

Please sign in to comment.