@@ -1206,9 +1206,11 @@ end subroutine physics_cnst_limit
12061206
12071207! ===============================================================================
12081208 subroutine physics_dme_adjust (state , tend , qini , liqini , iceini , dt )
1209- use air_composition, only: dry_air_species_num,thermodynamic_active_species_num
1210- use air_composition, only: thermodynamic_active_species_idx
1211- use dycore, only: dycore_is
1209+ use air_composition, only: dry_air_species_num,thermodynamic_active_species_num
1210+ use air_composition, only: thermodynamic_active_species_idx
1211+ use dycore, only: dycore_is
1212+ use dme_adjust, only: dme_adjust_run
1213+ use ccpp_constituent_prop_mod, only: ccpp_const_props
12121214 !- ----------------------------------------------------------------------
12131215 !
12141216 ! Purpose: Adjust the dry mass in each layer back to the value of physics input state
@@ -1259,6 +1261,12 @@ subroutine physics_dme_adjust(state, tend, qini, liqini, iceini, dt)
12591261
12601262 real (r8 ),allocatable :: cpairv_loc(:,:)
12611263 integer :: m_cnst
1264+
1265+ logical :: is_dycore_moist
1266+
1267+ character (len= 512 ) :: errmsg
1268+ integer :: errflg
1269+
12621270 !
12631271 !- ----------------------------------------------------------------------
12641272
@@ -1269,19 +1277,19 @@ subroutine physics_dme_adjust(state, tend, qini, liqini, iceini, dt)
12691277 lchnk = state% lchnk
12701278 ncol = state% ncol
12711279
1272- ! adjust dry mass in each layer back to input value, while conserving
1273- ! constituents, momentum, and total energy
1274- state% ps(:ncol) = state% pint(:ncol,1 )
1275-
12761280 !
12771281 ! original code for backwards compatability with FV
12781282 !
12791283 if (.not. (dycore_is(' MPAS' ) .or. dycore_is(' SE' ))) then
12801284 do k = 1 , pver
1281-
1285+
1286+ ! adjust dry mass in each layer back to input value, while conserving
1287+ ! constituents, momentum, and total energy
1288+ state% ps(:ncol) = state% pint(:ncol,1 )
1289+
12821290 ! adjusment factor is just change in water vapor
12831291 fdq(:ncol) = 1._r8 + state% q(:ncol,k,1 ) - qini(:ncol,k)
1284-
1292+
12851293 ! adjust constituents to conserve mass in each layer
12861294 do m = 1 , pcnst
12871295 state% q(:ncol,k,m) = state% q(:ncol,k,m) / fdq(:ncol)
@@ -1294,26 +1302,14 @@ subroutine physics_dme_adjust(state, tend, qini, liqini, iceini, dt)
12941302 state% rpdel (:ncol,k ) = 1._r8 / state% pdel(:ncol,k )
12951303 end do
12961304 else
1297- do k = 1 , pver
1298- tot_water(:ncol,1 ) = qini(:ncol,k) + liqini(:ncol,k)+ iceini(:ncol,k) ! initial total H2O
1299- tot_water(:ncol,2 ) = 0.0_r8
1300- do m_cnst= dry_air_species_num+1 ,thermodynamic_active_species_num
1301- m = thermodynamic_active_species_idx(m_cnst)
1302- tot_water(:ncol,2 ) = tot_water(:ncol,2 )+ state% q(:ncol,k,m)
1303- end do
1304- fdq(:ncol) = 1._r8 + tot_water(:ncol,2 ) - tot_water(:ncol,1 )
1305- ! adjust constituents to conserve mass in each layer
1306- do m = 1 , pcnst
1307- state% q(:ncol,k,m) = state% q(:ncol,k,m) / fdq(:ncol)
1308- end do
1309- ! compute new total pressure variables
1310- state% pdel (:ncol,k ) = state% pdel(:ncol,k ) * fdq(:ncol)
1311- state% ps(:ncol) = state% ps(:ncol) + state% pdel(:ncol,k)
1312- state% pint (:ncol,k+1 ) = state% pint(:ncol,k ) + state% pdel(:ncol,k)
1313- state% lnpint(:ncol,k+1 ) = log (state% pint(:ncol,k+1 ))
1314- state% rpdel (:ncol,k ) = 1._r8 / state% pdel(:ncol,k )
1315- ! note that mid-level variables (e.g. pmid) are not recomputed
1316- end do
1305+ is_dycore_moist = .true.
1306+ call dme_adjust_run (state% ncol, pver, pcnst, state% ps(:ncol), state% pint(:ncol,:), state% pdel(:ncol,:), &
1307+ state% lnpint(:ncol,:), state% rpdel(:ncol,:), &
1308+ ccpp_const_props, state% q(:ncol,:,:), qini(:ncol,:), liqini(:ncol,:), iceini(:ncol,:), &
1309+ is_dycore_moist, errmsg, errflg)
1310+ if (errflg /= 0 ) then
1311+ call endrun(' physics_dme_adjust: ' // errmsg)
1312+ end if
13171313 endif
13181314 if ( waccmx_is(' ionosphere' ) .or. waccmx_is(' neutral' ) ) then
13191315 zvirv(:,:) = shr_const_rwv / rairv(:,:,state% lchnk) - 1._r8
0 commit comments