SUBROUTINE PPUVTL_OLD(KPROMA,KSTART,KPROF,KFLEV,KLEVP,KLOLEV,&
 & KLEVB,LDBELO,LDBLOW,PRPRESC,PRXP,PRXPD,&
 & PUF,PVF,PUPP,PVPP,&
 & PRXP5,PRXPD5,PUF5,PVF5)  

!**** *PPUVTL* - POST-PROCESS WINDS - TANGENT LINEAR

!     PURPOSE.
!     --------
!           PERFORMS THE VERTICAL INTERPOLATION OF U AND V TO GIVEN
!       PRESSURE LEVELS

!**   INTERFACE.
!     ----------
!        *CALL* *PPUVTL(KPROMA,KSTART,KPROF,KFLEV,KLEVP,KLOLEV,KLEVB,
!                     LDBELO,LDBLOW,PRPRESC,PRXP,PRXPD,
!                     PUF,PVF,PUPP,PVPP)
!                     PRXP5,PRXPD5,PUF5,PVF5)

!        EXPLICIT ARGUMENTS
!        --------------------

!        KPROMA                    - HORIZONTAL DIMENSION.             (INPUT-C)
!        KSTART                    - START OF WORK.                    (INPUT-C)
!        KPROF                     - DEPTH OF WORK.                    (INPUT-C)
!        KFLEV                     - NUMBER OF INPUT PRESSURE LEVELS   (INPUT-C)
!        KLEVP                     - NUMBER OF OUTPUT PRESSURE LEVELS  (INPUT-C)
!        KLEVB(KPROMA,KLEVP,NPPM)  - INPUT LEVEL BELOW PRPRESC         (INPUT-C)
!                                    (SEE PPFLEV)
!        PRPRESC(KPROMA,KLEVP)     - LOG(POST-PROCESSING LEVEL PRESS.) (INPUT-C)
!        LDBELO(KPROMA,KLEVP)      - .TRUE. IF PRESSURE IS UNDER
!                                     LOWEST  MODEL LEVEL              (INPUT-C)
!        LDBLOW(KLEVP)             - FIRST LEVEL OF LDBELO CONTAINING
!                                    AT LEAST ONE .TRUE.               (INPUT-C)
!        PRXP(KPROMA,0:KFLEV,NPPM) - HALF,FULL AND LN HALF,FULL LEVEL
!                                    PRESSURES (SEE PPINIT)            (INPUT)
!        PRXPD(KPROMA,0:KFLEV,NPPM)- 1./D(P) AND 1./D(LN(P))           (INPUT)
!        PUF(KPROMA,0:KFLEV)       - ZONAL WIND ON FULL INPUT LEVELS   (INPUT)
!        PVF(KPROMA,0:KFLEV)       - MERID. WIND ON FULL INPUT LEVELS  (INPUT)

!        PUPP(KPROMA,KLEVP)        - POST-PROCESSED ZONAL WIND         (OUTPUT)
!        PVPP(KPROMA,KLEVP)        - POST-PROCESSED MERIDIONAL WIND    (OUTPUT)

!        IMPLICIT ARGUMENTS :  NONE.
!        --------------------

!     METHOD.
!     -------
!        SEE DOCUMENTATION

!     EXTERNALS.  PPINTPTL - LINEAR INTERPOLATION
!     ----------  PPITPQTL - QUADRATIC INTERPOLATION FOR TOP LEVELS

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

!     AUTHOR.
!     -------
!        MATS HAMRUD AND PHILIPPE COURTIER  *ECMWF*

!     MODIFICATIONS.
!     --------------
!        ORIGINAL : 89-01-26
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!     ------------------------------------------------------------------

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

USE YOMDIM   , ONLY : NPPM
USE YOMCT0B  , ONLY : LECMWF
USE YOMCT0   , ONLY : LFPART2

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KPROMA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KFLEV 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLEVP 
INTEGER(KIND=JPIM),INTENT(IN)    :: KSTART 
INTEGER(KIND=JPIM),INTENT(IN)    :: KPROF 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLOLEV 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLEVB(KPROMA,KLEVP,NPPM) 
LOGICAL           ,INTENT(IN)    :: LDBELO(KPROMA,KLEVP) 
LOGICAL           ,INTENT(IN)    :: LDBLOW(KLEVP) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRPRESC(KPROMA,KLEVP) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRXP(KPROMA,0:KFLEV,NPPM) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRXPD(KPROMA,0:KFLEV,NPPM) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PUF(KPROMA,0:KFLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PVF(KPROMA,0:KFLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PUPP(KPROMA,KLEVP) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PVPP(KPROMA,KLEVP) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRXP5(KPROMA,0:KFLEV,NPPM) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRXPD5(KPROMA,0:KFLEV,NPPM) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PUF5(KPROMA,0:KFLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PVF5(KPROMA,0:KFLEV) 
INTEGER(KIND=JPIM) :: ISLCT, JL, JLEVP
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "ppintptl.intfb.h"
#include "ppitpqtl.intfb.h"

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

!*       1.    POST-PROCESS WINDS.
!              -------------------

IF (LHOOK) CALL DR_HOOK('PPUVTL_OLD',0,ZHOOK_HANDLE)
ISLCT=4

!*       1.1   PREPARE FOR EXTRAPOLATION ABOVE TOP MODEL LEVEL.

IF(LECMWF .AND. LFPART2) THEN
  DO JL=KSTART,KPROF
    PUF5(JL,0)=PUF5(JL,1)
    PVF5(JL,0)=PVF5(JL,1)

    PUF(JL,0)=PUF(JL,1)
    PVF(JL,0)=PVF(JL,1)
  ENDDO
ELSE
  DO JL=KSTART,KPROF
    PUF5(JL,0)=PUF5(JL,2)+PRXP5(JL,2,ISLCT)*PRXPD5(JL,1,ISLCT)*&
     & (PUF5(JL,1)-PUF5(JL,2))  
    PVF5(JL,0)=PVF5(JL,2)+PRXP5(JL,2,ISLCT)*PRXPD5(JL,1,ISLCT)*&
     & (PVF5(JL,1)-PVF5(JL,2))  

    PUF(JL,0)=PUF(JL,2)+&
     & PRXP(JL,2,ISLCT)*PRXPD5(JL,1,ISLCT)*(PUF5(JL,1)-PUF5(JL,2))+&
     & PRXP5(JL,2,ISLCT)*PRXPD(JL,1,ISLCT)*(PUF5(JL,1)-PUF5(JL,2))+&
     & PRXP5(JL,2,ISLCT)*PRXPD5(JL,1,ISLCT)*(PUF(JL,1)-PUF(JL,2))  
    PVF(JL,0)=PVF(JL,2)+&
     & PRXP(JL,2,ISLCT)*PRXPD5(JL,1,ISLCT)*(PVF5(JL,1)-PVF5(JL,2))+&
     & PRXP5(JL,2,ISLCT)*PRXPD(JL,1,ISLCT)*(PVF5(JL,1)-PVF5(JL,2))+&
     & PRXP5(JL,2,ISLCT)*PRXPD5(JL,1,ISLCT)*(PVF(JL,1)-PVF(JL,2))  
  ENDDO
ENDIF

!*       1.2   INTERPOLATE WINDS.
CALL PPINTPTL(KPROMA,KSTART,KPROF,KFLEV,KLEVP,KLOLEV,KLEVB,&
 & ISLCT,LDBELO,LDBLOW,PRPRESC,PRXP,PRXPD,PUF,PUPP,&
 & PRXP5,PRXPD5,PUF5)  
CALL PPINTPTL(KPROMA,KSTART,KPROF,KFLEV,KLEVP,KLOLEV,KLEVB,&
 & ISLCT,LDBELO,LDBLOW,PRPRESC,PRXP,PRXPD,PVF,PVPP,&
 & PRXP5,PRXPD5,PVF5)  

!*       1.3   CONSTANT EXTRAPOLATION BELOW LOWEST MODEL LEVEL.

DO JLEVP=KLOLEV,KLEVP
  IF(LDBLOW(JLEVP)) THEN
    DO JL=KSTART,KPROF
      IF ( LDBELO(JL,JLEVP)) THEN
        PUPP(JL,JLEVP)=PUF(JL,KFLEV)
        PVPP(JL,JLEVP)=PVF(JL,KFLEV)
      ENDIF
    ENDDO
  ENDIF
ENDDO

!*       1.4   MODIFY INTERPOLATION/EXTRAPOLATION ABOVE SECOND
!*          FULL MODEL LEVEL. FIT QUADRATIC POLYNOMIAL IN LN(P).

IF(LECMWF) THEN
  IF(.NOT.LFPART2) THEN
    CALL PPITPQTL(KPROMA,KSTART,KPROF,KFLEV,KLEVP,KLOLEV,ISLCT,&
     & PRPRESC,PRXP,PUF,&
     & PRXP5,PUF5,&
     & PUPP)  
    CALL PPITPQTL(KPROMA,KSTART,KPROF,KFLEV,KLEVP,KLOLEV,ISLCT,&
     & PRPRESC,PRXP,PVF,&
     & PRXP5,PVF5,&
     & PVPP)  
  ENDIF
ELSE
  CALL PPITPQTL(KPROMA,KSTART,KPROF,KFLEV,KLEVP,KLOLEV,ISLCT,&
   & PRPRESC,PRXP,PUF,&
   & PRXP5,PUF5,&
   & PUPP)  
  CALL PPITPQTL(KPROMA,KSTART,KPROF,KFLEV,KLEVP,KLOLEV,ISLCT,&
   & PRPRESC,PRXP,PVF,&
   & PRXP5,PVF5,&
   & PVPP)  
ENDIF

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

IF (LHOOK) CALL DR_HOOK('PPUVTL_OLD',1,ZHOOK_HANDLE)
END SUBROUTINE PPUVTL_OLD
