@@ -1503,3 +1503,36 @@ add_diagnostic_variable!(
15031503 comments = " Energy available to a parcel lifted moist adiabatically from the surface. We assume fully reversible phase changes and no precipitation." ,
15041504 compute! = compute_cape!,
15051505)
1506+
1507+ function compute_mslp! (out, state, cache, time)
1508+ thermo_params = CAP. thermodynamics_params (cache. params)
1509+ g = TD. Parameters. grav (thermo_params)
1510+ R_m_surf = Fields. level (
1511+ lazy .(TD. gas_constant_air .(thermo_params, cache. precomputed. ᶜts)),
1512+ 1 ,
1513+ )
1514+
1515+ # get pressure, temperature, and height at the lowest atmospheric level
1516+ p_level = Fields. level (cache. precomputed. ᶜp, 1 )
1517+ t_level = Fields. level (
1518+ lazy .(TD. air_temperature .(thermo_params, cache. precomputed. ᶜts)),
1519+ 1 ,
1520+ )
1521+ z_level = Fields. level (Fields. coordinate_field (state. c. ρ). z, 1 )
1522+
1523+ # compute sea level pressure using the hypsometric equation
1524+ if isnothing (out)
1525+ return @. p_level * exp (g * z_level / (R_m_surf * t_level))
1526+ else
1527+ @. out = p_level * exp (g * z_level / (R_m_surf * t_level))
1528+ end
1529+ end
1530+
1531+ add_diagnostic_variable! (
1532+ short_name = " mslp" ,
1533+ long_name = " Mean Sea Level Pressure" ,
1534+ standard_name = " mean_sea_level_pressure" ,
1535+ units = " Pa" ,
1536+ comments = " Mean sea level pressure computed from the hypsometric equation" ,
1537+ compute! = compute_mslp!,
1538+ )
0 commit comments