Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ target_compile_definitions(CCTM PUBLIC SUBST_FILES_ID="FILES_CTM.EXT"
SUBST_COMM=NOOP_COMM
SUBST_BARRIER=NOOP_BARRIER
SUBST_SUBGRID_INDEX=NOOP_SUBGRID_INDEX
AQCHEM=DUMMY_AQCHEM
CONVCLD_ACM=DUMMY_CONVCLD_ACM
EDDYX=DUMMY_EDDYX
MOSAIC_MOD=MOSAIC_MODULE
Mosaic_Mod=Mosaic_Module
Expand Down
14 changes: 11 additions & 3 deletions aqm_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ list(APPEND aqm_files
list(APPEND aqm_shr_files
src/shr/aqm_config_mod.F90
src/shr/aqm_const_mod.F90
src/shr/aqm_domain_mod.F90
src/shr/aqm_domain_mod.F90
src/shr/aqm_emis_mod.F90
src/shr/aqm_prod_mod.F90
src/shr/aqm_fires_mod.F90
src/shr/aqm_internal_mod.F90
src/shr/aqm_model_mod.F90
src/shr/aqm_model_mod.F90
src/shr/aqm_rc_mod.F90
src/shr/aqm_methods.F90
src/shr/aqm_species_mod.F90
src/shr/aqm_state_mod.F90
src/shr/aqm_state_mod.F90
src/shr/aqm_tools_mod.F90
src/shr/aqm_types_mod.F90
)
Expand Down Expand Up @@ -114,6 +115,13 @@ list(APPEND aqm_CCTM_files
${BIOG}/tmpbeis.F
${BIOG}/wrdaymsg.f
${CLOUD}/hlconst.F
${CLOUD}/cldproc_acm.F
${CLOUD}/getalpha.F
${CLOUD}/indexn.f
${CLOUD}/rescld.F
${CLOUD}/scavwdep.F
${CLOUD}/aq_map.F
${CLOUD}/AQ_DATA.F
${DEPV}/ABFLUX_MOD.F
${DEPV}/BIDI_MOD.F
${DEPV}/cgrid_depv.F
Expand Down
8 changes: 7 additions & 1 deletion examples/aqm.rc
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ omi_data: /scratch1/NCEPDEV/nems/Raffaele.Montuoro/dev/aqm/epa/data/omi_cmaq_
init_concentrations: true

#
# Run aerosol module
# Run options:
#
# - enable aerosol module
#
run_aerosol: true
#
# - enable wet deposition processes in resolved-scale clouds
#
run_rescld: true

#
# Microphysics scheme used by coupled atmospheric model
Expand Down
14 changes: 14 additions & 0 deletions src/aqm_comp_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module aqm_comp_mod
use aqm_types_mod, only : AQM_MAXSTR
use aqm_model_mod
use aqm_emis_mod
use aqm_prod_mod
use aqm_internal_mod
use cmaq_model_mod

Expand Down Expand Up @@ -92,6 +93,12 @@ subroutine aqm_comp_create(model, rc)
msg="Failed to initialize emissions subsystem", &
line=__LINE__, file=__FILE__, rcToReturn=rc)) return ! bail out

! -- initialize products
call aqm_prod_init(model, rc=localrc)
if (ESMF_LogFoundError(rcToCheck=localrc, &
msg="Failed to initialize products", &
line=__LINE__, file=__FILE__, rcToReturn=rc)) return ! bail out

end subroutine aqm_comp_create

subroutine aqm_comp_init(rc)
Expand Down Expand Up @@ -198,6 +205,13 @@ subroutine aqm_comp_advance(model, rc)
return ! bail out
end if

! -- update output products if needed
call aqm_prod_update(model, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg="Failed to update products", &
line=__LINE__, &
file=__FILE__)) &
return ! bail out

end subroutine aqm_comp_advance

!-----------------------------------------------------------------------------
Expand Down
210 changes: 207 additions & 3 deletions src/drv/cmaq_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module cmaq_mod
use aqm_types_mod
use aqm_const_mod, only : onebg, rdgas, grav, mwair, zero
use aqm_emis_mod
use aqm_prod_mod
use aqm_tools_mod, only : aqm_units_conv

use PAGRD_DEFN
Expand Down Expand Up @@ -43,6 +44,9 @@ module cmaq_mod
public :: cmaq_emis_init
public :: cmaq_emis_finalize
public :: cmaq_emis_print
public :: cmaq_prod_init
public :: cmaq_prod_units_get
public :: cmaq_prod_update
public :: cmaq_species_read
public :: cmaq_export
public :: cmaq_import
Expand Down Expand Up @@ -116,10 +120,10 @@ subroutine cmaq_init(rc)

end subroutine cmaq_init

subroutine cmaq_advance(jdate, jtime, tstep, run_aero, rc)
subroutine cmaq_advance(jdate, jtime, tstep, run_aero, run_rescld, rc)

integer, intent(in) :: jdate, jtime, tstep(3)
logical, intent(in) :: run_aero
logical, intent(in) :: run_aero, run_rescld
integer, optional, intent(out) :: rc

! -- local variables
Expand All @@ -131,6 +135,11 @@ SUBROUTINE VDIFF ( CGRID, JDATE, JTIME, TSTEP )
INTEGER :: JDATE, JTIME
INTEGER :: TSTEP( 3 )
END SUBROUTINE VDIFF
SUBROUTINE CLDPROC ( CGRID, JDATE, JTIME, TSTEP )
REAL, POINTER :: CGRID( :,:,:,: )
INTEGER :: JDATE, JTIME
INTEGER :: TSTEP( 3 )
END SUBROUTINE CLDPROC
SUBROUTINE CHEM ( CGRID, JDATE, JTIME, TSTEP )
REAL, POINTER :: CGRID( :,:,:,: )
INTEGER :: JDATE, JTIME
Expand All @@ -149,6 +158,10 @@ END SUBROUTINE AERO
! -- advance all physical and chemical processes on a grid
CALL VDIFF ( CGRID, JDATE, JTIME, TSTEP )

if (run_rescld) then
CALL CLDPROC ( CGRID, JDATE, JTIME, TSTEP )
end if

CALL CHEM ( CGRID, JDATE, JTIME, TSTEP )

if (run_aero) then
Expand Down Expand Up @@ -239,17 +252,21 @@ subroutine cmaq_import(tracers, prl, phii, temp, start_index, rc)

end subroutine cmaq_import

subroutine cmaq_export(tracers, prl, temp, start_index, rc)
subroutine cmaq_export(tracers, prl, temp, start_index, diag_index, rc)

real(AQM_KIND_R8), intent(out) :: tracers(:,:,:,:)
real(AQM_KIND_R8), intent(in) :: prl(:,:,:)
real(AQM_KIND_R8), intent(in) :: temp(:,:,:)
integer, intent(in) :: start_index
integer, intent(in) :: diag_index
integer, optional, intent(out) :: rc


! -- local variables
integer :: c, r, l, n, off, spc, v
real(AQM_KIND_R8) :: rdens
real :: pm25(my_ncols,my_nrows,nlays,1)
integer :: localrc

! -- begin
if (present(rc)) rc = AQM_RC_SUCCESS
Expand Down Expand Up @@ -306,6 +323,18 @@ subroutine cmaq_export(tracers, prl, temp, start_index, rc)
end do
end if

! -- pm2.5

call cmaq_prod_pm25( pm25, cgrid, tracers, diag_index, nlays)
n = diag_index + 3
do l = 1, nlays
do r = 1, my_nrows
do c = 1, my_ncols
tracers( c,r,l,n ) = pm25( c,r,l,1 )
end do
end do
end do

end subroutine cmaq_export

subroutine cmaq_conc_init(jdate, jtime, tstep, rc)
Expand Down Expand Up @@ -642,4 +671,179 @@ subroutine cmaq_domain_log(label)

end subroutine cmaq_domain_log

subroutine cmaq_prod_init(rc)

integer, optional, intent(out) :: rc

! -- local variables
integer :: item, n
character(len=AQM_MAXSTR) :: units
type(aqm_internal_emis_type), pointer :: pdata(:)
type(aqm_internal_emis_type), pointer :: prod

! -- begin
if (present(rc)) rc = AQM_RC_SUCCESS

nullify(pdata)
pdata => aqm_emis_data_get()

if (associated(pdata)) then

do item = 1, size(pdata)
nullify(prod)
if (trim(pdata(item) % type) == "product") then
prod => pdata(item)
do n = 1, size(prod % species)
call cmaq_prod_units_get( prod % species(n), units )
call aqm_prod_units_set ( prod % fields(n), units )
end do
end if
end do

end if

end subroutine cmaq_prod_init

subroutine cmaq_prod_units_get( species, units )

character(len=*), intent(in) :: species
character(len=*), intent(out) :: units

! -- local variables
integer :: spc

! -- begin
units = "n/a"
select case ( trim(species) )
case ("PM2.5")
! --- diagnostic PM2.5
units = "ug/m3"
case default
! --- CMAQ species
! --- 1. gas species
spc = index1( trim(species), n_gc_spc, gc_spc )
if (spc > 0) then
units = "ppmV"
else
! --- 2. aerosol species
spc = index1( trim(species), n_ae_spc, ae_spc )
if (spc > 0) units = "ug/m3"
end if
end select

end subroutine cmaq_prod_units_get

subroutine cmaq_prod_update(tracers, start_index, rc)

real(AQM_KIND_R8), intent(in) :: tracers(:,:,:,:)
integer, intent(in) :: start_index
integer, optional, intent(out) :: rc

! -- local variables
integer :: item, n, spc
real :: pm25(my_ncols,my_nrows,1,1)
type(aqm_internal_emis_type), pointer :: pdata(:)
type(aqm_internal_emis_type), pointer :: prod

! -- begin
nullify(pdata)
pdata => aqm_emis_data_get()

if (associated(pdata)) then

do item = 1, size(pdata)
nullify(prod)
if (trim(pdata(item) % type) == "product") then
prod => pdata(item)
do n = 1, size(prod % species)
select case ( trim(prod % species(n)) )
case ("PM2.5")
! --- diagnostic PM2.5
if ( n_ae_spc > 0 ) then
call cmaq_prod_pm25( pm25, cgrid, tracers, start_index, 1)
call aqm_prod_compute( prod, pm25, n, 1 )
end if
case default
! --- CMAQ species
spc = 0
! --- 1. gas species
if ( n_gc_spc > 0 ) spc = index1( prod % species(n), n_gc_spc, gc_spc )
if (spc > 0) then
spc = spc + gc_strt - 1
call aqm_prod_compute( prod, cgrid, n, spc )
else
! --- 2. aerosol species
if ( n_ae_spc > 0 ) spc = index1( prod % species(n), n_ae_spc, ae_spc )
if (spc > 0) then
spc = spc + ae_strt - 1
call aqm_prod_compute( prod, cgrid, n, spc )
end if
end if
end select
end do
end if
end do

end if

end subroutine cmaq_prod_update

subroutine cmaq_prod_pm25( pm25, cgrid, frac, idx, nlays_in)

real, intent(out) :: pm25(:,:,:,:)
real, intent(in) :: cgrid(:,:,:,:)
real(AQM_KIND_R8), intent(in) :: frac(:,:,:,:)
integer, intent(in) :: idx
integer, intent(in) :: nlays_in

! -- local variables
integer :: i, ibeg, iend, imod, mode, spc
integer :: c, r, l

! -- local parameters
character(len=*), parameter :: pm25_species(*) = &
(/ "ASO4I ", "ANO3I ", "ANH4I ", "ANAI ", "ACLI ", "AECI ", "AOTHRI ", & ! I-mode (Atken)
"ALVPO1I", "ASVPO1I", "ASVPO2I", "ALVOO1I", "ALVOO2I", "ASVOO1I", "ASVOO2I", &
"ASO4J ", "ANO3J ", "ANH4J ", "ANAJ ", "ACLJ ", "AECJ ", "AOTHRJ ", & ! J-mode (accum)
"ALVPO1J", "ASVPO1J", "ASVPO2J", "ASVPO3J", "AIVPO1J", &
"AXYL1J ", "AXYL2J ", "AXYL3J ", "ATOL1J ", "ATOL2J ", "ATOL3J ", "ABNZ1J ", "ABNZ2J ", &
"ABNZ3J ", "AISO1J ", "AISO2J ", "AISO3J ", "ATRP1J ", "ATRP2J ", "ASQTJ ", "AALK1J ", &
"AALK2J ", "APAH1J ", "APAH2J ", "APAH3J ", "AORGCJ ", "AOLGBJ ", "AOLGAJ ", &
"ALVOO1J", "ALVOO2J", "ASVOO1J", "ASVOO2J", "ASVOO3J", "APCSOJ ", &
"AFEJ ", "ASIJ ", "ATIJ ", "ACAJ ", "AMGJ ", "AMNJ ", "AALJ ", "AKJ ", &
"ASOIL ", "ACORS ", "ASEACAT", "ACLK ", "ASO4K ", "ANO3K ", "ANH4K " /) ! K-mode (coarse)

integer, parameter :: nspc(3) = (/ 14, 49, 7 /)

! -- begin
pm25 = 0.

if ( n_ae_spc > 0 ) then
ibeg = 0
iend = 0

! -- loop over I, J, K modes
imod = idx
do mode = 1, 3
ibeg = iend + 1
iend = iend + nspc(mode)
do i = ibeg, iend
spc = index1( pm25_species(i), n_ae_spc, ae_spc )
if (spc > 0) then
spc = spc + ae_strt - 1
do l = 1, nlays_in
do r = 1, my_nrows
do c = 1, my_ncols
pm25( c,r,l,1 ) = pm25( c,r,l,1 ) + frac( c,r,l,imod ) * cgrid( c,r,l,spc )
end do
end do
end do
end if
end do
imod = imod + 1
end do
end if

end subroutine cmaq_prod_pm25

end module cmaq_mod
Loading