function GetTWetBulbFromRelHum(TDryBulb, RelHum, Pressure) result(TWetBulb)
!+ Return wet-bulb temperature given dry-bulb temperature, relative humidity, and pressure.
!+ References:
!+ ASHRAE Handbook - Fundamentals (2017) ch. 1
real, intent(in) :: TDryBulb
!+ Dry-bulb temperature in °F [IP] or °C [SI]
real, intent(in) :: RelHum
!+ Relative humidity in range [0, 1]
real, intent(in) :: Pressure
!+ Atmospheric pressure in Psi [IP] or Pa [SI]
real :: TWetBulb
!+ Wet-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 (RelHum < 0.0 .or. RelHum > 1.0) then
error stop "Error: relative humidity is outside range [0,1]"
end if
HumRatio = GetHumRatioFromRelHum(TDryBulb, RelHum, Pressure)
TWetBulb = GetTWetBulbFromHumRatio(TDryBulb, HumRatio, Pressure)
end function GetTWetBulbFromRelHum