SUBROUTINE CTVTOT5(KSTART,KPROF,PT,PQ)

!**** *CTVTOT5* - Computes T from 'TV' (TV defined as RT/Rd)
!                 Trajectory

!     Purpose.
!     --------
!           COMPUTES T FROM 'TV' (simplified version, used in adjoint of
!           case LSPRT=.TRUE.)

!**   Interface.
!     ----------
!        *CALL* *CTVTOT5(...)

!        Explicit arguments :
!        --------------------
!                              PT(NPROMA,NFLEVG)    - output: T
!                                                  - input: TV
!                              PQ(NPROMA,NFLEVG)    - Q

!        Implicit arguments :
!        --------------------

!     Method.
!     -------
!        See documentation

!     Externals.
!     ----------

!     Reference.
!     ----------
!        ECMWF Research Department documentation of the IFS

!     Author.
!     -------
!        Clive Temperton  *ECMWF*

!     Modifications.
!     --------------
!        Original : 01-01-29 (after CTVTOT)
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!     ------------------------------------------------------------------

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK

USE YOMDIM   , ONLY : NFLEVG   ,NPROMA
USE YOMCST   , ONLY : RD       ,RV

!     ------------------------------------------------------------------

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KSTART 
INTEGER(KIND=JPIM),INTENT(IN)    :: KPROF 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PT(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PQ(NPROMA,NFLEVG) 

!     ------------------------------------------------------------------

REAL(KIND=JPRB) :: ZR

INTEGER(KIND=JPIM) :: IEND, IST, JLEV, JROF
REAL(KIND=JPRB) :: ZHOOK_HANDLE

!     ------------------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('CTVTOT5',0,ZHOOK_HANDLE)
!     ------------------------------------------------------------------

!*       1.    COMPUTES T FROM 'TV'
!              --------------------

IST =KSTART
IEND=KPROF

DO JLEV = 1, NFLEVG
  DO JROF = IST, IEND
    ZR=RD+(RV-RD)*PQ(JROF,JLEV)
    PT(JROF,JLEV)=RD*PT(JROF,JLEV)/ZR
  ENDDO
ENDDO

!-----------------------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('CTVTOT5',1,ZHOOK_HANDLE)
END SUBROUTINE CTVTOT5
