!OCL  NOEVAL
SUBROUTINE GPGRPAD( &
 ! --- INPUT IN TL -----------------------------------------------------------
 & LDVERCOR, &
 & KPROMA, &
 !NYC-VC & KPROMVC, &
 & KPROMNH,KSTART,KPROF,KFLEV, &
 & PRT,PRTL,PRTM, &
 !NYC-NH & PRDELP, &
 & PREL,PREM,PRTGR, &
 & PALPH,PALPHPLL,PALPHPLM, &
 !NYC-NH & PDELNHPRE,PLNNHPREFL,PLNNHPREFM, &
 !NYC-NH & PRNHPPI,PQCHAL,PQCHAM, &
 & PHIHL,PHIHM,PHIFL,PHIFM, &
 !NYC-VC & PVCTSF,PVCTSFL,PVCTSFM,PVCMUSF,PVCMUSFL,PVCMUSFM, &
 ! --- OUTPUT IN TL ----------------------------------------------------------
 & PSGRTL,PSGRTM, &
 !NYC-NH & PSGRTSL,PSGRTSM, &
 ! --- INPUT-TRAJECTORY ------------------------------------------------------
 & PRT5,PRT5L,PRT5M, &
 !NYC-NH & PRDELP5, &
 & PRE5L,PRE5M,PRTGR5, &
 & PALPH5,PALPHPL5L,PALPHPL5M, &
 !NYC-NH & PDELNHPRE5,PLNNHPREF5L,PLNNHPREF5M, &
 !NYC-NH & PRNHPPI5,PQCHA5L,PQCHA5M, &
 & PHIF5L,PHIF5M &
 & )  

!**** *GPGRPAD* - Computation of the pressure gradient force term used in the
!               RHS of the horizontal wind equation in both NH and
!               hydrostatic models.
!               This term is computed on model layers.
!               Adjoint code.

!               The NH code is not yet completed and is currently commented
!               with !NYC-NH.
!               The LVERCOR code is not yet completed and is currently commented
!               with !NYC-VC.

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

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

!        Explicit arguments :
!        --------------------
!         * INPUT IN TL:
!           LDVERCOR    : .T./.F.: thin layer hypothesis relaxed/applied
!           KPROMA      : horizontal dimension
!           KPROMVC     : hor. dimension for arrays used only if "lvercor=T" (NYC-VC)
!           KPROMNH     : hor. dimension for arrays used only if "lnhdyn=T"
!           KSTART      : start of work
!           KPROF       : working length
!           KFLEV       : number of levels
!           PRT         : "R(air)*temperature" on layers
!           PRTL        : zonal component of "rssavnabla (RT)" on layers
!           PRTM        : meridian component of "rssavnabla (RT)" on layers
!           PRDELP      : 1/[Delta prehyd] on layers (NYC-NH)
!           PREL        : zonal component of "rssavnabla (prehyds)"
!           PREM        : meridian component of "rssavnabla (prehyds)"
!           PRTGR       : the ratio between "rssavnabla log(prehyd)"
!                          and "rssavnabla log(prehyds)", on layers
!           PALPH       : "alpha" on layers
!           PALPHPLL    : zonal component of "rssavnabla (alpha + log prehyd)"
!                          on layers
!           PALPHPLM    : meridian component "rssavnabla (alpha + log prehyd)"
!                          on layers
!           PDELNHPRE   : [Delta pre] on layers (NYC-NH)
!           PLNNHPREFL  : zonal component of "[rssavnabla pre]/pre" on layers (NYC-NH)
!           PLNNHPREFM  : merid component of "[rssavnabla pre]/pre" on layers (NYC-NH)
!           PRNHPPI     : (prehyd/pre) at full levels (NYC-NH)
!           PQCHAL      : zonal comp of "grad (log(pre/prehyd))" at full levels (NYC-NH)
!           PQCHAM      : merid comp of "grad (log(pre/prehyd))" at full levels (NYC-NH)
!           PHIHL       : zonal component of "rssavnabla[gz]" on half levels
!           PHIHM       : merid component of "rssavnabla[gz]" on half levels
!           PHIFL       : zonal component of "rssavnabla[gz]" on full levels
!           PHIFM       : merid component of "rssavnabla[gz]" on full levels
!           PVCTSF      : reference temperature "Ts" on layers (NYC-VC)
!           PVCTSFL     : zonal component of "rssavnabla Ts" on layers (NYC-VC)
!           PVCTSFM     : meridian component of "rssavnabla Ts" on layers (NYC-VC)
!           PVCMUSF     : "mu_s" on layers (NYC-VC)
!           PVCMUSFL    : zonal component of "rssavnabla mu_s", on layers (NYC-VC)
!           PVCMUSFM    : meridian component of "rssavnabla mu_s", on layers (NYC-VC)

!         * OUTPUT IN TL:
!           PSGRTL      : zonal comp. of pressure (semi-reduced) gradient force
!           PSGRTM      : merid comp. of pressure (semi-reduced) gradient force
!           PSGRTSL     : zonal comp. of surf pressure (semi-reduc) grad force (NYC-NH)
!           PSGRTSM     : merid comp. of surf pressure (semi-reduc) grad force (NYC-NH)

!         * INPUT-TRAJECTORY:
!           PRT5,PRT5L,PRT5M: cf. PRT,PRTL,PRTM.
!           PRDELP5     : cf. PRDELP (NYC-NH)
!           PRE5L,PRE5M,PRTGR5: cf. PREL,PREM,PRTGR.
!           PDELNHPRE5,PLNNHPREF5L,PLNNHPREF5M: cf. PDELNHPRE,PLNNHPREFL,PLNNHPREFM (NYC-NH)
!           PRNHPPI5,PQCHA5L,PQCHA5M: cf. PRNHPPI,PQCHAL,PQCHAM (NYC-NH)
!           PHIF5L,PHIF5M: cf. PHIFL,PHIFM.

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

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

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

!     Reference.
!     ----------
!        See  documentation Arpege ALGORITHME CHAPITRE 6 paragraphe 6

!     Author.
!     -------
!        Florence Rabier

!     Modifications.
!     --------------
!        Original : 91-11-01
!        Modification: 92-04-10 loop indexes
!        Modified : 94-10-11 by Radmila Bubnova: correction in the case
!                            of the other approximation of d (ln p).
!        Modified : 99-08-24 by C. Temperton: add PSGRT5L, PSGRT5M.
!        Modified : 2000-11  by A. Untch: vertical finite elements
!        Modified : 02-07-09 by C. Fischer: remove PSGRT5L, PSGRT5M.
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        K.Yessad   Mar-2006 Complete rewriting according to the new GPGRP.
!        K. Yessad (Dec 2008): remove dummy CDLOCK
!     ------------------------------------------------------------------

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

USE YOMCT0   , ONLY : LNHDYN
USE YOMCVER  , ONLY : LVERTFE

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

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KPROMA 
!NYC_VC INTEGER(KIND=JPIM),INTENT(IN)    :: KPROMVC 
INTEGER(KIND=JPIM),INTENT(IN)    :: KPROMNH
INTEGER(KIND=JPIM),INTENT(IN)    :: KFLEV 
LOGICAL           ,INTENT(IN)    :: LDVERCOR 
INTEGER(KIND=JPIM),INTENT(IN)    :: KSTART 
INTEGER(KIND=JPIM),INTENT(IN)    :: KPROF 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PRT(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PRTL(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PRTM(KPROMA,KFLEV) 
!NYC-NH REAL(KIND=JPRB)   ,INTENT(INOUT) :: PRDELP(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PREL(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PREM(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PRTGR(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PALPH(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PALPHPLL(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PALPHPLM(KPROMA,KFLEV) 
!NYC-NH REAL(KIND=JPRB)   ,INTENT(INOUT) :: PDELNHPRE(KPROMNH,KFLEV) 
!NYC-NH REAL(KIND=JPRB)   ,INTENT(INOUT) :: PLNNHPREFL(KPROMNH,KFLEV) 
!NYC-NH REAL(KIND=JPRB)   ,INTENT(INOUT) :: PLNNHPREFM(KPROMNH,KFLEV) 
!NYC-NH REAL(KIND=JPRB)   ,INTENT(INOUT) :: PRNHPPI(KPROMNH,KFLEV) 
!NYC-NH REAL(KIND=JPRB)   ,INTENT(INOUT) :: PQCHAL(KPROMNH,KFLEV) 
!NYC-NH REAL(KIND=JPRB)   ,INTENT(INOUT) :: PQCHAM(KPROMNH,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PHIHL(KPROMA,0:KFLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PHIHM(KPROMA,0:KFLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PHIFL(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PHIFM(KPROMA,KFLEV) 
!NYC-VC REAL(KIND=JPRB)   ,INTENT(INOUT) :: PVCTSF(KPROMVC,KFLEV) 
!NYC-VC REAL(KIND=JPRB)   ,INTENT(INOUT) :: PVCTSFL(KPROMVC,KFLEV) 
!NYC-VC REAL(KIND=JPRB)   ,INTENT(INOUT) :: PVCTSFM(KPROMVC,KFLEV) 
!NYC-VC REAL(KIND=JPRB)   ,INTENT(INOUT) :: PVCMUSF(KPROMVC,KFLEV) 
!NYC-VC REAL(KIND=JPRB)   ,INTENT(INOUT) :: PVCMUSFL(KPROMVC,KFLEV) 
!NYC-VC REAL(KIND=JPRB)   ,INTENT(INOUT) :: PVCMUSFM(KPROMVC,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PSGRTL(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PSGRTM(KPROMA,KFLEV) 
!NYC-NH REAL(KIND=JPRB)   ,INTENT(INOUT) :: PSGRTSL(KPROMNH) 
!NYC-NH REAL(KIND=JPRB)   ,INTENT(INOUT) :: PSGRTSM(KPROMNH) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRT5(KPROMA,KFLEV)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRT5L(KPROMA,KFLEV)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRT5M(KPROMA,KFLEV)
!NYC-NH REAL(KIND=JPRB)   ,INTENT(IN)    :: PRDELP5(KPROMA,KFLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRE5L(KPROMA)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRE5M(KPROMA)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRTGR5(KPROMA,KFLEV)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PALPH5(KPROMA,KFLEV)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PALPHPL5L(KPROMA,KFLEV)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PALPHPL5M(KPROMA,KFLEV)
!NYC-NH REAL(KIND=JPRB)   ,INTENT(IN)    :: PDELNHPRE5(KPROMNH,KFLEV)
!NYC-NH REAL(KIND=JPRB)   ,INTENT(IN)    :: PLNNHPREF5L(KPROMNH,KFLEV)
!NYC-NH REAL(KIND=JPRB)   ,INTENT(IN)    :: PLNNHPREF5M(KPROMNH,KFLEV)
!NYC-NH REAL(KIND=JPRB)   ,INTENT(IN)    :: PRNHPPI5(KPROMA,KFLEV)
!NYC-NH REAL(KIND=JPRB)   ,INTENT(IN)    :: PQCHA5L(KPROMNH,KFLEV)
!NYC-NH REAL(KIND=JPRB)   ,INTENT(IN)    :: PQCHA5M(KPROMNH,KFLEV)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PHIF5L(KPROMA,KFLEV)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PHIF5M(KPROMA,KFLEV)

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

!NYC-NH REAL(KIND=JPRB) :: ZDPRESDPREHYD(KPROMNH,KFLEV)
REAL(KIND=JPRB) :: ZLNPREFL(KPROMA,KFLEV),ZLNPREFM(KPROMA,KFLEV)
!NYC-NH REAL(KIND=JPRB) :: ZRNHPPI(KPROMNH,KFLEV)

REAL(KIND=JPRB) :: ZDPRESDPREHYD5(KPROMA,KFLEV)
REAL(KIND=JPRB) :: ZLNPREF5L(KPROMA,KFLEV),ZLNPREF5M(KPROMA,KFLEV)
REAL(KIND=JPRB) :: ZRNHPPI5(KPROMA,KFLEV)

INTEGER(KIND=JPIM) :: JLEV, JROF

REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

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

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

!*       2.    INITIAL SET TO ZERO.
!              --------------------

!NYC-NH ZDPRESDPREHYD(KSTART:KPROF,1:KFLEV)=0.0_JPRB
ZLNPREFL(KSTART:KPROF,1:KFLEV)=0.0_JPRB
ZLNPREFM(KSTART:KPROF,1:KFLEV)=0.0_JPRB
!NYC-NH ZRNHPPI(KSTART:KPROF,1:KFLEV)=0.0_JPRB
ZDPRESDPREHYD5(KSTART:KPROF,1:KFLEV)=0.0_JPRB
ZLNPREF5L(KSTART:KPROF,1:KFLEV)=0.0_JPRB
ZLNPREF5M(KSTART:KPROF,1:KFLEV)=0.0_JPRB
ZRNHPPI5(KSTART:KPROF,1:KFLEV)=0.0_JPRB

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

!*       1.    COMPUTATION OF THE PRESSURE GRADIENT TERM.
!              ------------------------------------------

! * In the NH model, PSGRT(L,M) at jlev=KFLEV is copied in PSGRTS(L,M).
IF (LNHDYN) THEN
  !!! AD OF LNHDYN NOT YET CODED (following piece of code to be activated later)
  !NYC-NH DO JROF=KSTART,KPROF
  !NYC-NH   PSGRTL(JROF,KFLEV)=PSGRTL(JROF,KFLEV)+PSGRTSL(JROF)
  !NYC-NH   PSGRTM(JROF,KFLEV)=PSGRTM(JROF,KFLEV)+PSGRTSM(JROF)
  !NYC-NH ENDDO
ENDIF

! * SOME TRAJECTORY PRE-CALCULATIONS:

IF (LNHDYN) THEN
  !!! AD OF LNHDYN NOT YET CODED (following piece of code to be activated later)
  ! * Calculation of "d pre / d prehyd" and "[rssavnabla pre]/pre" on layers:
  !NYC-NH DO JLEV=1,KFLEV
  !NYC-NH   DO JROF=KSTART,KPROF
  !NYC-NH     ZDPRESDPREHYD5(JROF,JLEV)=PDELNHPRE5(JROF,JLEV)*PRDELP5(JROF,JLEV)
  !NYC-NH     ZLNPREF5L(JROF,JLEV)=PLNNHPREF5L(JROF,JLEV)
  !NYC-NH     ZLNPREF5M(JROF,JLEV)=PLNNHPREF5M(JROF,JLEV)
  !NYC-NH     ZRNHPPI5(JROF,JLEV)=PRNHPPI5(JROF,JLEV)
  !NYC-NH   ENDDO
  !NYC-NH ENDDO
ELSE
  ! * In this case:
  !   "d pre / d prehyd" is equal to 1.
  !   "[rssavnabla pre]/pre" is replaced by "rssavnabla (log(prehyd))".
  DO JLEV=1,KFLEV
    DO JROF=KSTART,KPROF
      ZDPRESDPREHYD5(JROF,JLEV)=1.0_JPRB
      ZLNPREF5L(JROF,JLEV)=PRTGR5(JROF,JLEV)*PRE5L(JROF)
      ZLNPREF5M(JROF,JLEV)=PRTGR5(JROF,JLEV)*PRE5M(JROF)
      ZRNHPPI5(JROF,JLEV)=1.0_JPRB
    ENDDO
  ENDDO
ENDIF

! * WE NOW COMPUTE THE PRESSURE GRADIENT TERM:

IF (LVERTFE) THEN

  ! * The pressure gradient term is directly computed on layers in
  !   this case and no quantity at half layers is computed.

  IF (LDVERCOR.AND.(.NOT.LNHDYN)) THEN
    ! Case HYD + LVERCOR=T + LVERTFE=T: AD NOT CODED.
  ENDIF

  IF (LNHDYN) THEN
    !!! AD OF LNHDYN NOT YET CODED (following piece of code to be activated later)
    !NYC-NH DO JLEV=1,KFLEV
    !NYC-NH   DO JROF=KSTART,KPROF
    !NYC-NH     ! zonal
    !NYC-NH     ZDPRESDPREHYD(JROF,JLEV)=ZDPRESDPREHYD(JROF,JLEV) &
    !NYC-NH      & +PHIF5L(JROF,JLEV)*PSGRTL(JROF,JLEV)
    !NYC-NH     ! meridian
    !NYC-NH     ZDPRESDPREHYD(JROF,JLEV)=ZDPRESDPREHYD(JROF,JLEV) &
    !NYC-NH      & +PHIF5M(JROF,JLEV)*PSGRTM(JROF,JLEV)
    !NYC-NH   ENDDO
    !NYC-NH ENDDO
  ENDIF

  ! * First transfer
  !   " rssavnabla[gz] + RT [rssavnabla (log(prehyd))] " (hyd)
  !   or
  !   " (d pre/d prehyd) rssavnabla[gz] + RT [rssavnabla pre]/pre " (NH)
  !   in (PSGRTL,PSGRTM).
  DO JLEV=1,KFLEV
    DO JROF=KSTART,KPROF
      ! zonal
      PHIFL(JROF,JLEV)=PHIFL(JROF,JLEV) &
       & +ZDPRESDPREHYD5(JROF,JLEV)*PSGRTL(JROF,JLEV)
      ZLNPREFL(JROF,JLEV)=ZLNPREFL(JROF,JLEV)+PRT5(JROF,JLEV)*PSGRTL(JROF,JLEV)
      PRT(JROF,JLEV)=PRT(JROF,JLEV)+ZLNPREF5L(JROF,JLEV)*PSGRTL(JROF,JLEV)
      ! meridian
      PHIFM(JROF,JLEV)=PHIFM(JROF,JLEV) &
       & +ZDPRESDPREHYD5(JROF,JLEV)*PSGRTM(JROF,JLEV)
      ZLNPREFM(JROF,JLEV)=ZLNPREFM(JROF,JLEV)+PRT5(JROF,JLEV)*PSGRTM(JROF,JLEV)
      PRT(JROF,JLEV)=PRT(JROF,JLEV)+ZLNPREF5M(JROF,JLEV)*PSGRTM(JROF,JLEV)
    ENDDO
  ENDDO

ELSE

  ! * The pressure gradient term calculation requires some
  !   calculations on half levels.

  ! * In the hydrostatic model, an accurate way to code this
  !   is to exhibit the quantity "rssavnabla alpha + log prehyd"
  !   which is simpler to compute than the separate terms
  !   "rssavnabla alpha" and "log prehyd"
  !   (some quantities cancel each other).
  !   One starts from half level "grad(Phi)" and write:
  !   [grad(Phi) + RT grad(log(prehyd))]_l
  !   = [grad(Phi)]_lbar
  !   + [alpha]_l [grad(RT)]_l
  !   + [RT]_l [grad(alpha + log(prehyd))]_l

  !   In the NH model, this term writes:
  !   (delta pre/delta prehyd) grap(Phi) + RT grad(pre) / pre
  !   For its discretisation we prefer to rewrite it as follows:
  !   [ grad(Phi) + (prehyd/pre) RT grad(log(prehyd)) ]
  !   + [ ((delta pre / delta prehyd) - 1) * grad(Phi) ]
  !   + [ RT grad(log(pre/prehyd)) ]
  !   + [ RT (1 - prehyd/pre) grad(log(prehyd)) ]
  !   The three last terms are non-zero only in the NH model.
  !   The first term [ grad(Phi) + (prehyd/pre) RT grad(log(prehyd)) ]
  !   looks like the hydrostatic pressure gradient term, but with an
  !   additional factor "prehyd/pre" and an additional term
  !   containing " (prehyd/pre) * grad(log(pre/prehyd)) ".
  !   This way of writing avoids the quasi cancellation of terms
  !   which have the same magnitude.

  IF (LDVERCOR.AND.(.NOT.LNHDYN)) THEN
    ! Case HYD + LVERCOR=T + LVERTFE=F: AD NOT CODED.
  ENDIF

  ! * Calculation of the additional anhydrostatic contributions
  !   at full levels:

  IF (LNHDYN) THEN

    !!! AD OF LNHDYN NOT YET CODED (following piece of code to be activated later)
    !NYC-NH DO JLEV=1,KFLEV
    !NYC-NH   DO JROF=KSTART,KPROF
    !NYC-NH     ! zonal
    !NYC-NH     ZDPRESDPREHYD(JROF,JLEV)=ZDPRESDPREHYD(JROF,JLEV)&
    !NYC-NH      & +PHIF5L(JROF,JLEV)*PSGRTL(JROF,JLEV)
    !NYC-NH     PHIFL(JROF,JLEV)=PHIFL(JROF,JLEV)&
    !NYC-NH      & +(ZDPRESDPREHYD5(JROF,JLEV)-1.0_JPRB)*PSGRTL(JROF,JLEV)
    !NYC-NH     PRT(JROF,JLEV)=PRT(JROF,JLEV) &
    !NYC-NH      & +PQCHA5L(JROF,JLEV)*PSGRTL(JROF,JLEV)
    !NYC-NH     PQCHAL(JROF,JLEV)=PQCHAL(JROF,JLEV) &
    !NYC-NH      & +PRT5(JROF,JLEV)*PSGRTL(JROF,JLEV)
    !NYC-NH     PRT(JROF,JLEV)=PRT(JROF,JLEV)+(1.0_JPRB-ZRNHPPI5(JROF,JLEV)) &
    !NYC-NH      & *PRTGR5(JROF,JLEV)*PRE5L(JROF)*PSGRTL(JROF,JLEV)
    !NYC-NH     ZRNHPPI(JROF,JLEV)=ZRNHPPI(JROF,JLEV)-PRT5(JROF,JLEV) &
    !NYC-NH      & *PRTGR5(JROF,JLEV)*PRE5L(JROF)*PSGRTL(JROF,JLEV)
    !NYC-NH     PRTGR(JROF,JLEV)=PRTGR(JROF,JLEV)+PRT5(JROF,JLEV) &
    !NYC-NH      & *(1.0_JPRB-ZRNHPPI5(JROF,JLEV))*PRE5L(JROF)*PSGRTL(JROF,JLEV)
    !NYC-NH     PREL(JROF)=PREL(JROF)+PRT5(JROF,JLEV)*PRTGR5(JROF,JLEV) &
    !NYC-NH      & *(1.0_JPRB-ZRNHPPI5(JROF,JLEV))*PSGRTL(JROF,JLEV)
    !NYC-NH     ! meridian
    !NYC-NH     ZDPRESDPREHYD(JROF,JLEV)=ZDPRESDPREHYD(JROF,JLEV)&
    !NYC-NH      & +PHIF5M(JROF,JLEV)*PSGRTM(JROF,JLEV)
    !NYC-NH     PHIFM(JROF,JLEV)=PHIFM(JROF,JLEV)&
    !NYC-NH      & +(ZDPRESDPREHYD5(JROF,JLEV)-1.0_JPRB)*PSGRTM(JROF,JLEV)
    !NYC-NH     PRT(JROF,JLEV)=PRT(JROF,JLEV) &
    !NYC-NH      & +PQCHA5M(JROF,JLEV)*PSGRTM(JROF,JLEV)
    !NYC-NH     PQCHAM(JROF,JLEV)=PQCHAM(JROF,JLEV) &
    !NYC-NH      & +PRT5(JROF,JLEV)*PSGRTM(JROF,JLEV)
    !NYC-NH     PRT(JROF,JLEV)=PRT(JROF,JLEV)+(1.0_JPRB-ZRNHPPI5(JROF,JLEV)) &
    !NYC-NH      & *PRTGR5(JROF,JLEV)*PRE5M(JROF)*PSGRTM(JROF,JLEV)
    !NYC-NH     ZRNHPPI(JROF,JLEV)=ZRNHPPI(JROF,JLEV)-PRT5(JROF,JLEV) &
    !NYC-NH      & *PRTGR5(JROF,JLEV)*PRE5M(JROF)*PSGRTM(JROF,JLEV)
    !NYC-NH     PRTGR(JROF,JLEV)=PRTGR(JROF,JLEV)+PRT5(JROF,JLEV) &
    !NYC-NH      & *(1.0_JPRB-ZRNHPPI5(JROF,JLEV))*PRE5M(JROF)*PSGRTM(JROF,JLEV)
    !NYC-NH     PREM(JROF)=PREM(JROF)+PRT5(JROF,JLEV)*PRTGR5(JROF,JLEV) &
    !NYC-NH      & *(1.0_JPRB-ZRNHPPI5(JROF,JLEV))*PSGRTM(JROF,JLEV)
    !NYC-NH   ENDDO
    !NYC-NH ENDDO

  ENDIF

  IF (LNHDYN) THEN

    !!! AD OF LNHDYN NOT YET CODED (following piece of code to be activated later)
    !NYC-NH DO JLEV=1,KFLEV
    !NYC-NH   DO JROF=KSTART,KPROF
    !NYC-NH     ! zonal
    !NYC-NH     ZRNHPPI(JROF,JLEV)=ZRNHPPI(JROF,JLEV) &
    !NYC-NH      & +(PALPH5(JROF,JLEV)*PRT5L(JROF,JLEV)&
    !NYC-NH      & +PALPHPL5L(JROF,JLEV)*PRT5(JROF,JLEV))*PSGRTL(JROF,JLEV) &
    !NYC-NH      & -PALPH5(JROF,JLEV) &
    !NYC-NH      & *PRT5(JROF,JLEV)*PQCHA5L(JROF,JLEV)*PSGRTL(JROF,JLEV)
    !NYC-NH     PALPH(JROF,JLEV)=PALPH(JROF,JLEV)-ZRNHPPI5(JROF,JLEV) &
    !NYC-NH      & *PRT5(JROF,JLEV)*PQCHA5L(JROF,JLEV)*PSGRTL(JROF,JLEV)
    !NYC-NH     PRT(JROF,JLEV)=PRT(JROF,JLEV)-ZRNHPPI5(JROF,JLEV) &
    !NYC-NH      & *PALPH5(JROF,JLEV)*PQCHA5L(JROF,JLEV)*PSGRTL(JROF,JLEV)
    !NYC-NH     PQCHAL(JROF,JLEV)=PQCHAL(JROF,JLEV)-ZRNHPPI5(JROF,JLEV) &
    !NYC-NH      & *PALPH5(JROF,JLEV)*PRT5(JROF,JLEV)*PSGRTL(JROF,JLEV)
    !NYC-NH     ! meridian
    !NYC-NH     ZRNHPPI(JROF,JLEV)=ZRNHPPI(JROF,JLEV) &
    !NYC-NH      & +(PALPH5(JROF,JLEV)*PRT5M(JROF,JLEV)&
    !NYC-NH      & +PALPHPL5M(JROF,JLEV)*PRT5(JROF,JLEV))*PSGRTM(JROF,JLEV) &
    !NYC-NH      & -PALPH5(JROF,JLEV) &
    !NYC-NH      & *PRT5(JROF,JLEV)*PQCHA5M(JROF,JLEV)*PSGRTM(JROF,JLEV)
    !NYC-NH     PALPH(JROF,JLEV)=PALPH(JROF,JLEV)-ZRNHPPI5(JROF,JLEV) &
    !NYC-NH      & *PRT5(JROF,JLEV)*PQCHA5M(JROF,JLEV)*PSGRTM(JROF,JLEV)
    !NYC-NH     PRT(JROF,JLEV)=PRT(JROF,JLEV)-ZRNHPPI5(JROF,JLEV) &
    !NYC-NH      & *PALPH5(JROF,JLEV)*PQCHA5M(JROF,JLEV)*PSGRTM(JROF,JLEV)
    !NYC-NH     PQCHAM(JROF,JLEV)=PQCHAM(JROF,JLEV)-ZRNHPPI5(JROF,JLEV) &
    !NYC-NH      & *PALPH5(JROF,JLEV)*PRT5(JROF,JLEV)*PSGRTM(JROF,JLEV)
    !NYC-NH   ENDDO
    !NYC-NH ENDDO

  ENDIF

  ! * Calculation of [ grad(Phi) + (prehyd/pre) RT grad(log(prehyd)) ]
  !   at full levels (cf. what is done in GPGRGEO to compute "grad(Phi)"
  !   at full levels, but replacing (palphl,palphm) by (palphpll,palphplm)):

  DO JLEV=1,KFLEV
    DO JROF=KSTART,KPROF
      ! zonal
      PALPH(JROF,JLEV)=PALPH(JROF,JLEV)&
       & +ZRNHPPI5(JROF,JLEV)*PRT5L(JROF,JLEV)*PSGRTL(JROF,JLEV)
      PALPHPLL(JROF,JLEV)=PALPHPLL(JROF,JLEV)&
       & +ZRNHPPI5(JROF,JLEV)*PRT5(JROF,JLEV)*PSGRTL(JROF,JLEV)
      PRTL(JROF,JLEV)=PRTL(JROF,JLEV)&
       & +ZRNHPPI5(JROF,JLEV)*PALPH5(JROF,JLEV)*PSGRTL(JROF,JLEV)
      PRT(JROF,JLEV)=PRT(JROF,JLEV)&
       & +ZRNHPPI5(JROF,JLEV)*PALPHPL5L(JROF,JLEV)*PSGRTL(JROF,JLEV)
      ! meridian
      PALPH(JROF,JLEV)=PALPH(JROF,JLEV)&
       & +ZRNHPPI5(JROF,JLEV)*PRT5M(JROF,JLEV)*PSGRTM(JROF,JLEV)
      PALPHPLM(JROF,JLEV)=PALPHPLM(JROF,JLEV)&
       & +ZRNHPPI5(JROF,JLEV)*PRT5(JROF,JLEV)*PSGRTM(JROF,JLEV)
      PRTM(JROF,JLEV)=PRTM(JROF,JLEV)&
       & +ZRNHPPI5(JROF,JLEV)*PALPH5(JROF,JLEV)*PSGRTM(JROF,JLEV)
      PRT(JROF,JLEV)=PRT(JROF,JLEV)&
       & +ZRNHPPI5(JROF,JLEV)*PALPHPL5M(JROF,JLEV)*PSGRTM(JROF,JLEV)
    ENDDO
  ENDDO

  ! * First get "rssavnabla[gz]" on half levels.
  DO JLEV=1,KFLEV
    DO JROF=KSTART,KPROF
      PHIHL(JROF,JLEV)=PHIHL(JROF,JLEV)+PSGRTL(JROF,JLEV)
      PHIHM(JROF,JLEV)=PHIHM(JROF,JLEV)+PSGRTM(JROF,JLEV)
    ENDDO
  ENDDO

ENDIF

! * SOME NON-TRAJECTORY PRE-CALCULATIONS:

IF (LNHDYN) THEN
  !!! AD OF LNHDYN NOT YET CODED (following piece of code to be activated later)
  ! * Calculation of "d pre / d prehyd" and "[rssavnabla pre]/pre" on layers:
  !NYC-NH DO JLEV=1,KFLEV
  !NYC-NH   DO JROF=KSTART,KPROF
  !NYC-NH     PRDELP(JROF,JLEV)=PRDELP(JROF,JLEV)&
  !NYC-NH      & +PDELNHPRE5(JROF,JLEV)*ZDPRESDPREHYD(JROF,JLEV)
  !NYC-NH     PDELNHPRE(JROF,JLEV)=PDELNHPRE(JROF,JLEV)&
  !NYC-NH      & +PRDELP5(JROF,JLEV)*ZDPRESDPREHYD(JROF,JLEV)
  !NYC-NH     PLNNHPREFL(JROF,JLEV)=PLNNHPREFL(JROF,JLEV)+ZLNPREFL(JROF,JLEV)
  !NYC-NH     PLNNHPREFM(JROF,JLEV)=PLNNHPREFM(JROF,JLEV)+ZLNPREFM(JROF,JLEV)
  !NYC-NH     PRNHPPI(JROF,JLEV)=PRNHPPI(JROF,JLEV)+ZRNHPPI(JROF,JLEV)
  !NYC-NH   ENDDO
  !NYC-NH ENDDO
ELSE
  ! * In this case:
  !   "d pre / d prehyd" is equal to 1.
  !   "[rssavnabla pre]/pre" is replaced by "rssavnabla (log(prehyd))".
  DO JLEV=1,KFLEV
    DO JROF=KSTART,KPROF
      ! zonal
      PREL(JROF)=PREL(JROF)+PRTGR5(JROF,JLEV)*ZLNPREFL(JROF,JLEV)
      PRTGR(JROF,JLEV)=PRTGR(JROF,JLEV)+PRE5L(JROF)*ZLNPREFL(JROF,JLEV)
      ! meridian
      PREM(JROF)=PREM(JROF)+PRTGR5(JROF,JLEV)*ZLNPREFM(JROF,JLEV)
      PRTGR(JROF,JLEV)=PRTGR(JROF,JLEV)+PRE5M(JROF)*ZLNPREFM(JROF,JLEV)
    ENDDO
  ENDDO
ENDIF

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

!*       0.    FINAL SET TO ZERO.
!              ------------------

PSGRTL(KSTART:KPROF,1:KFLEV)=0.0_JPRB
PSGRTM(KSTART:KPROF,1:KFLEV)=0.0_JPRB
IF (LNHDYN) THEN
  !!! AD OF LNHDYN NOT YET CODED (following piece of code to be activated later)
  !NYC-NH PSGRTSL(KSTART:KPROF)=0.0_JPRB
  !NYC-NH PSGRTSM(KSTART:KPROF)=0.0_JPRB
ENDIF

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

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