GetSpecificHumFromHumRatio Function

public function GetSpecificHumFromHumRatio(HumRatio) result(SpecificHum)

Arguments

Type IntentOptional AttributesName
real, intent(in) :: HumRatio

Return Value real


Contents


Source Code

  function GetSpecificHumFromHumRatio(HumRatio) result(SpecificHum)
    !+ Return the specific humidity from humidity ratio (aka mixing ratio).
    !+ Reference:
    !+ ASHRAE Handbook - Fundamentals (2017) ch. 1 eqn 9b

    real, intent(in) :: HumRatio
      !+ Humidity ratio in lb_H₂O lb_Dry_Air⁻¹ [IP] or kg_H₂O kg_Dry_Air⁻¹ [SI]
    real             :: SpecificHum
      !+ Specific humidity in lb_H₂O lb_Air⁻¹ [IP] or kg_H₂O kg_Air⁻¹ [SI]
    real              ::  BoundedHumRatio
      !+ Humidity ratio bounded to MIN_HUM_RATIO

    if (HumRatio < 0.0) then
      error stop "Error: humidity ratio cannot be negative"
    end if
    BoundedHumRatio = max(HumRatio, MIN_HUM_RATIO)

    SpecificHum = BoundedHumRatio / (1.0 + BoundedHumRatio)
  end function GetSpecificHumFromHumRatio