SUBROUTINE GPGRXYBTL(&
 ! --- INPUT --------------------------------------
 & KPROMA,KD,KF,KFLEV,PVC,PVBH,&
 & PREL,PREM,PRDELP,PRPRE,PRPP,PLNPR,PALPH,PRTGR,&
 ! --- OUTPUT -------------------------------------
 & PLNPRL,PLNPRM,PALPHL,PALPHM,PALPHPLL,PALPHPLM,&
 ! --- INPUT (TRAJECTORY) -------------------------
 & PCOEFD5,PCOEFAPL5,PCOEFA5, &
 & PRE5L,PRE5M,PRDELP5,PRPP5,PLNPR5,PALPH5,PRTGR5 &
 & )  

!**** *GPGRXYBTL* - TL of routine "GPGRXYB".
!                 Computation of the horizontal gradient of quantities
!                 "alpha" and "delta" on model layers.

!     Purpose.
!     --------

!      See GPGRXYB

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

!        Explicit arguments :
!        --------------------
!         * INPUT:
!           KPROMA       : horizontal dimension
!           KD           : start of work
!           KF           : working length
!           KFLEV        : number of levels
!           PVC          : A[lbar]*B[lbar-1] - A[lbar-1]*B[lbar]
!           PVBH         : B[lbar] on interlayers
!           PREL         : zonal component of "rssavnabla prehyds"
!           PREM         : meridian component of "rssavnabla prehyds"
!           PRDELP       : 1./( prehyd[lbar] - prehyd[lbar-1] )
!           PRPRE        : 1./(prehyd[lbar]) (on interlayers) 
!           PRPP         : 1./((prehyd[lbar])*(prehyd[lbar-1]))
!           PLNPR        : "delta" on layers (is equal to
!                          "log(prehyd[lbar]/prehyd[lbar-1])" if "ndlnpr=0")
!           PALPH        : "alpha" on layers
!           PRTGR        : scalar ratio of vectors "(rssavnabla prehyd)/prehyd"
!                          and "rssavnabla prehyds" (computed in GPXYB).

!         * OUTPUT:
!           PLNPRL       : zonal component of "rssavnabla(delta)" on layers
!           PLNPRM       : meridian component of "rssavnabla(delta)" on layers
!           PALPHL       : zonal component of "rssavnabla(alpha)" on layers
!           PALPHM       : meridian component of "rssavnabla(alpha)" on layers
!           PALPHPLL     : zonal component of "rssavnabla (alpha + log prehyd)"
!                          on layers
!           PALPHPLM     : meridian component "rssavnabla (alpha + log prehyd)"
!                          on layers

!         * INPUT-TRAJECTORY:
!           PCOEFD5,PCOEFAPL5,PCOEFA5,
!           PRE5L,PRE5M,PRDELP5,PRPP5,PLNPR5,PALPH5,PRTGR5:
!           cf. PCOEFD,PCOEFAPL,PCOEFA,
!           PREL,PREM,PRDELP,PRPP,PLNPR,PALPH,PRTGR in GPGRXYB5:

!        Implicit arguments :   None.
!        --------------------

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

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

!     Reference.
!     ----------

!     Author.
!     -------
!        K. YESSAD

!     Modifications.
!     --------------
!        Original : March 2006
!        K. Yessad (Dec 2008): remove dummy CDLOCK
!     ------------------------------------------------------------------

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

USE YOMDYN   , ONLY : NDLNPR
USE YOMCVER  , ONLY : LVERTFE
USE YOMGEM   , ONLY : VDELB

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

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KPROMA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KFLEV 
INTEGER(KIND=JPIM),INTENT(IN)    :: KD 
INTEGER(KIND=JPIM),INTENT(IN)    :: KF 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVC(KFLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVBH(0:KFLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PREL(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PREM(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRDELP(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRPRE(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRPP(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PLNPR(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PALPH(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRTGR(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PLNPRL(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PLNPRM(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PALPHL(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PALPHM(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PALPHPLL(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PALPHPLM(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCOEFD5(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCOEFAPL5(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCOEFA5(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRE5L(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRE5M(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRDELP5(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRPP5(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PLNPR5(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PALPH5(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRTGR5(KPROMA,KFLEV) 

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

REAL(KIND=JPRB) :: ZCOEFA(KPROMA), ZCOEFAPL(KPROMA), ZCOEFD(KPROMA)

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

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

IF (LHOOK) CALL DR_HOOK('GPGRXYBTL',0,ZHOOK_HANDLE)

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

!*    1/ Calculation of "rssavnabla delta" on layers.

IF(LVERTFE) THEN
  DO JLEV=1,KFLEV
    DO JROF=KD,KF
      ZCOEFD(JROF)=&
       & (VDELB(JLEV)*PRDELP(JROF,JLEV)-PRTGR(JROF,JLEV))*PLNPR5(JROF,JLEV) &
       & +(VDELB(JLEV)*PRDELP5(JROF,JLEV)-PRTGR5(JROF,JLEV))*PLNPR(JROF,JLEV)
      PLNPRL(JROF,JLEV)=ZCOEFD(JROF)*PRE5L(JROF)+PCOEFD5(JROF,JLEV)*PREL(JROF)
      PLNPRM(JROF,JLEV)=ZCOEFD(JROF)*PRE5M(JROF)+PCOEFD5(JROF,JLEV)*PREM(JROF)
    ENDDO
  ENDDO
ELSE
  DO JLEV=1,KFLEV
    DO JROF=KD,KF
      ZCOEFD(JROF)=-PVC(JLEV)*PRPP(JROF,JLEV)
      PLNPRL(JROF,JLEV)=ZCOEFD(JROF)*PRE5L(JROF)+PCOEFD5(JROF,JLEV)*PREL(JROF)
      PLNPRM(JROF,JLEV)=ZCOEFD(JROF)*PRE5M(JROF)+PCOEFD5(JROF,JLEV)*PREM(JROF)
    ENDDO
  ENDDO
ENDIF

!*    2/ Calculation of "rssavnabla (alpha + log prehyd)" on layers
!        discretised as "rssavnabla alpha + (rssavnabla prehyd) / prehyd ",
!        and calculation of "rssavnabla alpha" on layers.

IF(.NOT.LVERTFE) THEN
  IF(NDLNPR == 0) THEN
    DO JLEV=1,KFLEV
      DO JROF=KD,KF
        ZCOEFAPL(JROF)=PVBH(JLEV)*PRPRE(JROF,JLEV)
        ZCOEFA(JROF)=ZCOEFAPL(JROF)-PRTGR(JROF,JLEV)
        PALPHPLL(JROF,JLEV)=ZCOEFAPL(JROF)*PRE5L(JROF) &
         & + PCOEFAPL5(JROF,JLEV)*PREL(JROF)
        PALPHPLM(JROF,JLEV)=ZCOEFAPL(JROF)*PRE5M(JROF) &
         & + PCOEFAPL5(JROF,JLEV)*PREM(JROF)
        PALPHL(JROF,JLEV)=ZCOEFA(JROF)*PRE5L(JROF) &
         & + PCOEFA5(JROF,JLEV)*PREL(JROF)
        PALPHM(JROF,JLEV)=ZCOEFA(JROF)*PRE5M(JROF) &
         & + PCOEFA5(JROF,JLEV)*PREM(JROF)
      ENDDO
    ENDDO
  ELSEIF(NDLNPR == 1) THEN
    DO JLEV=1,KFLEV
      DO JROF=KD,KF
        ZCOEFA(JROF)=-PVC(JLEV)*( &
         & PRPP(JROF,JLEV)*PALPH5(JROF,JLEV)/PLNPR5(JROF,JLEV) &
         & + PRPP5(JROF,JLEV)*PALPH(JROF,JLEV)/PLNPR5(JROF,JLEV) &
         & - PRPP5(JROF,JLEV)*PALPH5(JROF,JLEV)*PLNPR(JROF,JLEV) &
         & /(PLNPR5(JROF,JLEV)*PLNPR5(JROF,JLEV)) )
        ZCOEFAPL(JROF)=ZCOEFA(JROF)+PRTGR(JROF,JLEV)
        PALPHPLL(JROF,JLEV)=ZCOEFAPL(JROF)*PRE5L(JROF) &
         & + PCOEFAPL5(JROF,JLEV)*PREL(JROF)
        PALPHPLM(JROF,JLEV)=ZCOEFAPL(JROF)*PRE5M(JROF) &
         & + PCOEFAPL5(JROF,JLEV)*PREM(JROF)
        PALPHL(JROF,JLEV)=ZCOEFA(JROF)*PRE5L(JROF) &
         & + PCOEFA5(JROF,JLEV)*PREL(JROF)
        PALPHM(JROF,JLEV)=ZCOEFA(JROF)*PRE5M(JROF) &
         & + PCOEFA5(JROF,JLEV)*PREM(JROF)
      ENDDO
    ENDDO
  ENDIF
ENDIF

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

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