function TD_FROM_TQ_1D(PT, PQ, PP) RESULT(PTD)
!! MODIFICATIONS
!! -------------
!! D.Meyer and R. Schoetter 2018: see a9c4c46889dca998ea9ca40e5e0edc62ecc75715
USE MODD_CSTS
USE MODD_SURF_PAR, ONLY: XUNDEF
!arguments and result
REAL, DIMENSION(:), INTENT(IN) :: PT !Air Temp. (K)
REAL, DIMENSION(:), INTENT(IN) :: PQ !Specific humidity (kg/kg)
REAL, DIMENSION(:), INTENT(IN) :: PP ! Atmospheric pressure (Pa)
REAL, DIMENSION(SIZE(PQ)) :: PTD !Dew Point Air Temp. (K)
!local variables
REAL, DIMENSION(SIZE(PQ)) :: ALPHA
REAL, DIMENSION(SIZE(PQ)) :: ZPE !water vapour pressure
REAL(KIND=JPRB) :: ZHOOK_HANDLE
IF (LHOOK) CALL DR_HOOK('MODE_PSYCHRO:TD_FROM_TQ_1D',0,ZHOOK_HANDLE)
ZPE(:) = PE_FROM_PQ(PP(:), PQ(:))
ALPHA(:) = LOG(ZPE(:)/1000.)
WHERE ( (PT(:).GE.XTT) .AND. (PT(:).LE.(93.+XTT)) )
PTD = XTT+6.54+14.526*ALPHA+0.7389*ALPHA*ALPHA+0.09486*ALPHA**3 &
+0.4569*(ZPE/1000.)**0.1984
ELSEWHERE (PT .LT. XTT)
PTD = XTT+6.09+12.608*ALPHA+0.4959*ALPHA*ALPHA
ELSEWHERE
PTD = XUNDEF
END WHERE
WHERE(PTD(:).GT.PT(:)) PTD(:) = PT(:)
IF (LHOOK) CALL DR_HOOK('MODE_PSYCHRO:TD_FROM_TQ_1D',1,ZHOOK_HANDLE)
end function TD_FROM_TQ_1D