TWB_FROM_TPQ_0D Function

public function TWB_FROM_TPQ_0D(PT, PP, PQ) result(PTWB)

Arguments

Type IntentOptional AttributesName
real, intent(in) :: PT
real, intent(in) :: PP
real, intent(in) :: PQ

Return Value real


Contents

Source Code


Source Code

function TWB_FROM_TPQ_0D(PT, PP, PQ) RESULT(PTWB)
!!    MODIFICATIONS
!!    -------------
!!       D.Meyer and R. Schoetter 2018: see a9c4c46889dca998ea9ca40e5e0edc62ecc75715
!arguments and results
REAL, INTENT(IN) :: PT !air temperature (K)
REAL, INTENT(IN) :: PQ !mixing ratio (kg/kg)
REAL, INTENT(IN) :: PP !atmos. pressure (Pa)
REAL :: PTWB !Wet Bulb Temp. (K)
!local variable
REAL :: ZTD !Dew Point Temp. (K)
REAL :: ZTWBINF, ZTWBSUP, ZRV
INTEGER :: JITER
REAL(KIND=JPRB) :: ZHOOK_HANDLE
IF (LHOOK) CALL DR_HOOK('MODE_PSYCHRO:TWB_FROM_TPQ_0D',0,ZHOOK_HANDLE)
JITER = 1
ZTD = TD_FROM_TQ(PT, PQ, PP)
!initial guess
ZTWBSUP = PT
ZTWBINF = ZTD
PTWB = 0.5 * (ZTWBSUP + ZTWBINF)
DO WHILE ( (ABS(ZTWBSUP - ZTWBINF).GT.0.01) .AND. (JITER .LE. 50) )
        ZRV = RV_FROM_TPTWB(PT, PP, PTWB)
        IF (ZRV .GT. PQ/(1 - PQ)) THEN
        ZTWBSUP = PTWB
        ELSE
        ZTWBINF = PTWB
        ENDIF
        PTWB = 0.5 * (ZTWBINF + ZTWBSUP)
        JITER = JITER + 1
END DO
IF (JITER.GE.49) STOP ("Maximum number of iterations exceeded in twb_from_tpq_0d")
IF (LHOOK) CALL DR_HOOK('MODE_PSYCHRO:TWB_FROM_TPQ_0D',1,ZHOOK_HANDLE)
end function TWB_FROM_TPQ_0D