SUBROUTINE PPLETA(KPROMA,KST,KND,KLEV,KOPLEV,PXLEV,PVAH,PVBH,PS,&
 & PRESF,PRESHB,PRESHT)  

!**** *PPLETA*  - FULL-POS upper air pressure post-processing from eta system

!     PURPOSE.
!     --------
!        To compute upper air pressures from a given vertical hybrid system 
!         and the surface pressure.

!**   INTERFACE.
!     ----------
!       *CALL* *PPLETA*

!        EXPLICIT ARGUMENTS
!        --------------------
!        KPROMA  : horizontal dimension
!        KST     : start of work
!        KND     : depth of work
!        KLEV    : total number of levels in eta system     
!        KOPLEV  : numer of levels among all eta system
!        PXLEV   : indexes of output levels (as a real array)
!        PVAH    : function *A*                       
!        PVBH    : function *B*                       
!        PS      : output surface pressure
!        PRESF   : full level pressures
!        PRESHB  : true half level pressures (on bottom full levels) 
!        PRESHT  : pseudo - half level pressures (on top full levels) 

!        IMPLICIT ARGUMENTS
!        ------------------

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

!     EXTERNALS.
!     ----------

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

!     AUTHOR.
!     -------
!        RYAD EL KHATIB *METEO-FRANCE*

!     MODIFICATIONS.
!     --------------
!        ORIGINAL : 94-04-08
!    R. El Khatib : 00-08-11 partial merge with FPPS 
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!     ------------------------------------------------------------------

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

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KPROMA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV 
INTEGER(KIND=JPIM),INTENT(IN)    :: KOPLEV 
INTEGER(KIND=JPIM),INTENT(IN)    :: KST 
INTEGER(KIND=JPIM),INTENT(IN)    :: KND 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PXLEV(KOPLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVAH(0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVBH(0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PS(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PRESF(KPROMA,KOPLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PRESHB(KPROMA,KOPLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PRESHT(KPROMA,KOPLEV) 
REAL(KIND=JPRB) :: ZDELP (KPROMA,KLEV), ZRDELP(KPROMA,KLEV), ZRPP  (KPROMA,KLEV)
REAL(KIND=JPRB) :: ZLNPR (KPROMA,KLEV), ZALPH (KPROMA,KLEV), ZRPRE (KPROMA,KLEV)
REAL(KIND=JPRB) :: ZRTGR (KPROMA,KLEV), ZPRESF(KPROMA,KLEV)
REAL(KIND=JPRB) :: ZPRESH(KPROMA,0:KLEV)
REAL(KIND=JPRB) :: ZVDELB(KLEV), ZVC(KLEV)

INTEGER(KIND=JPIM) :: JL
INTEGER(KIND=JPIM) :: IPTRLEV(KOPLEV) ! IPTRLEV : absolute indexes of levels
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "gppref.intfb.h"
#include "gppreh.intfb.h"
#include "gpxyb.intfb.h"

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

!*       1.    COMPUTE OUTPUT PRESSURE LEVELS
!              ------------------------------

!        1.1   PRESSURES OF OUTPUT ETA SYSTEM

IF (LHOOK) CALL DR_HOOK('PPLETA',0,ZHOOK_HANDLE)
DO JL=1,KLEV
  ZVC(JL)=PVAH(JL)*PVBH(JL-1)-PVAH(JL-1)*PVBH(JL)
  ZVDELB(JL)=PVBH(JL)-PVBH(JL-1)
ENDDO
ZPRESH(KST:KND,KLEV) = PS(KST:KND)
CALL GPPREH(KPROMA,KST,KND,KLEV,PVAH,PVBH,ZPRESH)
CALL GPXYB(KPROMA,KST,KND,KLEV,ZVDELB,ZVC,ZPRESH,ZDELP,ZRDELP,ZLNPR,ZALPH,&
 & ZRTGR,ZRPRE,ZRPP)  
CALL GPPREF(KPROMA,KST,KND,KLEV,ZALPH,ZPRESH,ZPRESF)

!        1.2   SELECT EFFECTIVE OUTPUT UPPER AIR PRESSURES

DO JL=1,KOPLEV
  IPTRLEV(JL)=INT(PXLEV(JL),JPIM)
  PRESF (KST:KND,JL)=ZPRESF(KST:KND,IPTRLEV(JL))
  PRESHB(KST:KND,JL)=ZPRESH(KST:KND,IPTRLEV(JL))
  PRESHT(KST:KND,JL)=ZPRESH(KST:KND,IPTRLEV(JL)-1)
ENDDO

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

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