Skip to content

Commit

Permalink
Fixed a bug introduced in WRF v4.3 that affects chem_opts = 201 (MOZA…
Browse files Browse the repository at this point in the history
…RT_MOSAIC_4BIN_KPP) and 202 (MOZART_MOSAIC_4BIN_AQ_KPP). (#1813)

Fixed a bug for chem_opt = 201, 202.

TYPE: bug fix

KEYWORDS: MOZART_MOSAIC_4BIN, mozart_pH_diag, bug fix

SOURCE: Internal

DESCRIPTION OF CHANGES:
Problem:
Users will experience a stalled simulation upon writing history files. This was caused by the pH diagnostics added in v4.3 (#1342) not being activated with the namelist option mozart_ph_diag = 1.

Solution:
Add as optional arguments only filled if the namelist is activated.

LIST OF MODIFIED FILES: list of changed files (use git diff --name-status master to get formatted list)
M chem/aerosol_driver.F
M chem/cloudchem_driver.F
M chem/module_mosaic_cloudchem.F
M chem/module_mosaic_driver.F
M chem/module_mosaic_therm.F

TESTS CONDUCTED:

Yes, the fix remedies the problem.
The Jenkins tests have passed.
RELEASE NOTE: This PR addresses a bug introduced in WRF v4.3 that affects users using chem_opts = 201 (MOZART_MOSAIC_4BIN_KPP) and 202 (MOZART_MOSAIC_4BIN_AQ_KPP).
  • Loading branch information
jordanschnell authored Jan 31, 2023
1 parent 1243d08 commit 3e447db
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions chem/aerosol_driver.F
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ SUBROUTINE aerosols_driver (id,curr_secs,ktau,dtstep,ktauc, &

! output of aerosol pH from MOSAIC 4-bin
REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , &
OPTIONAL, &
INTENT(OUT ) :: &
ph_aer01, ph_aer02, ph_aer03, ph_aer04
!
Expand Down
1 change: 1 addition & 0 deletions chem/cloudchem_driver.F
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ SUBROUTINE cloudchem_driver( &
INTENT(INOUT ) :: gas_aqfrac

REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
OPTIONAL, &
INTENT(OUT) :: ph_cw ! ph_cw - pH of cloud water

! LOCAL VAR
Expand Down
10 changes: 6 additions & 4 deletions chem/module_mosaic_cloudchem.F
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ subroutine mosaic_cloudchem_driver( &
! gas_aqfrac - fraction (0-1) of gas that is dissolved in cloud water

real, intent(out), &
OPTIONAL, &
dimension( ims:ime, kms:kme, jms:jme ) :: &
ph_cw

Expand Down Expand Up @@ -148,7 +149,7 @@ subroutine mosaic_cloudchem_driver( &
end if
! following line turns aqueous radical chem off unconditionally
iradical_onoff = 0

if ( config_flags%mozart_ph_diag .eq. 1 ) then
! Initialize pH of CW ph_cw to a FillValue value
do jt = jts, jte
do kt = kts, kte
Expand All @@ -157,7 +158,7 @@ subroutine mosaic_cloudchem_driver( &
end do
end do
end do

end if
do 3920 jt = jts, jte
do 3910 it = its, ite

Expand Down Expand Up @@ -214,9 +215,10 @@ subroutine mosaic_cloudchem_driver( &
num_moist, num_chem, moist, chem, &
t_phy, p_phy, rho_phy )

gas_aqfrac(it,kt,jt,:) = gas_aqfrac_box(:)
gas_aqfrac(it,kt,jt,:) = gas_aqfrac_box(:)
if ( config_flags%mozart_ph_diag .eq. 1 ) then
ph_cw(it,kt,jt) = ph_aq_box

end if
3800 continue

3910 continue
Expand Down
4 changes: 3 additions & 1 deletion chem/module_mosaic_driver.F
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ subroutine mosaic_aerchem_driver( &
! (ug/kg for mass species, #/kg for number species)

real, intent(out), &
optional, &
dimension( ims:ime, kms:kme, jms:jme ) :: &
ph_aer01, ph_aer02, ph_aer03, ph_aer04

Expand Down Expand Up @@ -456,7 +457,8 @@ subroutine mosaic_aerchem_driver( &
call aerchemistry( it, jt, kclm_calcbgn, kclm_calcend, &
dtchem, idiagaa_dum, vbs_nbin, &
ph_aer01(it,kms:kme,jt), ph_aer02(it,kms:kme,jt), &
ph_aer03(it,kms:kme,jt), ph_aer04(it,kms:kme,jt), kms,kme )
ph_aer03(it,kms:kme,jt), ph_aer04(it,kms:kme,jt), &
kms,kme,config_flags%mozart_ph_diag )

! note units for aerosol is now ug/m3

Expand Down
8 changes: 5 additions & 3 deletions chem/module_mosaic_therm.F
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module module_mosaic_therm
!-----------------------------------------------------------------------
subroutine aerchemistry( iclm, jclm, kclm_calcbgn, kclm_calcend, &
dtchem_sngl, idiagaa,vbs_nbin, &
ph_aer1, ph_aer2, ph_aer3, ph_aer4,kms,kme )
ph_aer1, ph_aer2, ph_aer3, ph_aer4,kms,kme,do_ph )

use module_data_mosaic_asect
use module_data_mosaic_other
Expand All @@ -107,7 +107,8 @@ subroutine aerchemistry( iclm, jclm, kclm_calcbgn, kclm_calcend, &
integer iclm, jclm, kclm_calcbgn, kclm_calcend, idiagaa,vbs_nbin(1)
real dtchem_sngl
integer kms, kme
real, intent(out), dimension(kms:kme) :: &
integer, intent(in) :: do_ph
real, optional, intent(out), dimension(kms:kme) :: &
ph_aer1, ph_aer2, ph_aer3, ph_aer4 ! pH of the aerosols
! local variables
real(kind=8) :: dtchem
Expand Down Expand Up @@ -157,11 +158,12 @@ subroutine aerchemistry( iclm, jclm, kclm_calcbgn, kclm_calcend, &
call specialoutaa( iclm, jclm, k, m, 'befor_movesect' )
call move_sections( 1, iclm, jclm, k, m)
call specialoutaa( iclm, jclm, k, m, 'after_movesect' )

if ( do_ph .eq. 1 ) then
ph_aer1(k) = mc(1,1)
ph_aer2(k) = mc(1,2)
ph_aer3(k) = mc(1,3)
ph_aer4(k) = mc(1,4)
end if

100 continue ! k levels

Expand Down

0 comments on commit 3e447db

Please sign in to comment.