function GetDegreeOfSaturation(TDryBulb, HumRatio, Pressure) result(DegreeOfSaturation)
!+ Return the degree of saturation (i.e humidity ratio of the air / humidity ratio of the air at saturation
!+ at the same temperature and pressure) given dry-bulb temperature, humidity ratio, and atmospheric pressure.
!+ Reference:
!+ ASHRAE Handbook - Fundamentals (2009) ch. 1 eqn 12
!+ Notes:
!+ This definition is absent from the 2017 Handbook. Using 2009 version instead.
real, intent(in) :: TDryBulb
!+ Dry-bulb temperature in °F [IP] or °C [SI]
real, intent(in) :: HumRatio
!+ Humidity ratio in lb_H₂O lb_Air⁻¹ [IP] or kg_H₂O kg_Air⁻¹ [SI]
real, intent(in) :: Pressure
!+ Atmospheric pressure in Psi [IP] or Pa [SI]
real :: DegreeOfSaturation
!+ Degree of saturation in arbitrary unit
real :: BoundedHumRatio
!+ Humidity ratio bounded to MIN_HUM_RATIO
if (HumRatio < 0.0) then
error stop "Error: humidity ratio is negative"
end if
BoundedHumRatio = max(HumRatio, MIN_HUM_RATIO)
DegreeOfSaturation = BoundedHumRatio / GetSatHumRatio(TDryBulb, Pressure)
end function GetDegreeOfSaturation