function GetHumRatioFromEnthalpyAndTDryBulb(MoistAirEnthalpy, TDryBulb) result(HumRatio)
!+ Return humidity ratio from enthalpy and dry-bulb temperature.
!+ Reference:
!+ ASHRAE Handbook - Fundamentals (2017) ch. 1 eqn 30
!+ Notes:
!+ Based on the `GetMoistAirEnthalpy` function, rearranged for humidity ratio.
real, intent(in) :: MoistAirEnthalpy
!+ Moist air enthalpy in Btu lb⁻¹ [IP] or J kg⁻¹
real, intent(in) :: TDryBulb
!+ Dry-bulb temperature in °F [IP] or °C [SI]
real :: HumRatio
!+ Humidity ratio in lb_H₂O lb_Air⁻¹ [IP] or kg_H₂O kg_Air⁻¹ [SI]
if (isIP()) then
HumRatio = (MoistAirEnthalpy - 0.240 * TDryBulb) / (1061.0 + 0.444 * TDryBulb)
else
HumRatio = (MoistAirEnthalpy / 1000.0 - 1.006 * TDryBulb) / (2501.0 + 1.86 * TDryBulb)
end if
! Validity check.
HumRatio = max(HumRatio, MIN_HUM_RATIO)
end function GetHumRatioFromEnthalpyAndTDryBulb