!-----------------------------------------------------------------------
SUBROUTINE VDIFLCZAD (KIDIA, KFDIA, KLON, KLEV,&
 & PTSTEP,&
 & PLSM,&
 ! TIME 5 VARIABLES:
 & PAPHI5,&
 ! TIME 0 VARIABLES:
 & PAPHI, PAPHIF,&
 ! TIME 9 VARIABLES:
 & PU9, PV9, PT9,&
 ! INPUT VARIABLES:
 & PUT1,PVT1,PTT1)  
!-----------------------------------------------------------------------

!**** *VDIFLCZAD* - SURFACE DRAG AND VERTICAL DIFFUSION SCHEME
!                   TANGENT LINEAR VERSION

!     PURPOSE.
!     --------
!         TO COMPUTE THE FLUXES OF U, V, S=CP*T+PHI AND Q DUE TO THE VERTICAL
!     DIFFUSION AND THE SURFACE DRAG.

!     NB: Either vertical diffusion or surface drag can be applied to
!         U,V only, or to U,V and dse, but not to dse only.

!     INTERFACE.
!     ----------
!        *CALL* *VDIFLCZAD(......)

!     PARAMETER DESCRIPTION                                   UNITS
!     --------- -----------                                   -----

!     INPUT ARGUMENTS
!     ---------------

!     DIMENSIONS:

!     KIDIA, KFDIA : START/END OF HORIZONTAL LOOP  (1, IPROF IN *CPG*).
!     KLON         : HORIZONTAL DIMENSION (NPROMA IN *CPG*).
!     KLEV         : END OF VERTICAL LOOP AND VERTICAL DIMENSION
!                    (NFLEVG IN *CPG*).

!     INPUT PARAMETERS AT T-1 (REAL) OR CONSTANT IN TIME:

!     PTSTEP        DOUBLE TIME STEP
!     PU0          X-VELOCITY COMPONENT                          M/S
!     PV0          Y-VELOCITY COMPONENT                          M/S
!     PT0          TEMPERATURE                                   K
!     PAPH0        PRESSURE ON HALF LEVELS                       PA
!        NB: THE INDEX GOES 1:KLEV+1 INSTEAD OF 0:KLEV FOR EASY OF COMPUTATION
!     PAPHI         GEOPOTENTIAL HEIGHT ON HALF-LEVELS
!     PAPHIF        GEOPOTENTIAL HEIGHT ON FULL LEVELS

!     LOCAL VARIABLES (REAL):

!     ZCPTGZ        DRY STATIC ENERGY
!     ZGEO0        GEOPOTENTIAL                                  M2/S2
!     ZSOL          VARIABLES AT TIME T+1 AFTER VERTICAL DIFFUSION
!     ZM            TRIDIAGONAL MATRIX FOR THE VERTICAL DIFFUSION SCHEME
!     ZRHS          RIGHT HAND SIDE OF THE TRIDIAGONAL PROBLEM

!     OUTPUT PARAMETERS (REAL):

!     PUT1          UPDATED U-COMPONENT
!     PVT1          UPDATED V-COMPONENT
!     PTT1          UPDATED TEMPERATURE

!     VARIABLES IN COMMON:

!     YOEVDF       CONSTANTS FOR VERT DIFF (RLAM, RKAP)
!     YOMCST       CONSTANTS FOR PHYSICS (RD, RV, RCPD, RCPV)
!     YOMLUN       OUTPUT UNITS
!     YOPHLC       LOGICAL SWITCHES AND PARAMETERS FOR THE SIMPLE PHYSICS
!     YOMGEM       VERTICAL COORDINATE DEFINITION (VALH, VBH, VP00)

!     METHOD.
!     -------
!         MIXING LENGHT THEORY IS APPLIED TO COMPUTE THE EXCHANGE
!     COEFFICIENT FOR VERT DIFFUSION. VERT DIFF IS APPLIED TO
!     U, V AND S=CP*T+PHI.
!     TEMPORARY: NO VERT DIFF ON S.

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

!     REFERENCE.
!     ----------
!     SEE LITERATURE (HOLTON OR HALTINER-WILLIAMS).

!     AUTHOR
!     ------
!     FROM VDIF (IFS_CY6) WRITTEN BY OLIVIER TALAGRAND - 22 SEPTEMBER 1988
!     NEW VERSION FOR IFS_CY10 BY:

!     ROBERTO BUIZZA   *ECMWF*

!     MODIFICATIONS
!     -------------
!     ORIGINAL: 2 JUNE 1992
!     MODIFICATION: 25 SEPTEMBER 1992
!                   28.02.94 R Buizza - Constant Cp in dse definition
!                                     - Additional switch for drag on dse
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        M.Hamrud      01-Dec-2003 CY28R1 Cleaning
!        K.Yessad (Nov 2008): replace TRIDIALCZ by TRIDIA + cleanings
!     -----------------------------------------------------------------

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
USE YOMLUN   , ONLY : NULOUT
USE YOEVDF   , ONLY : RLAM     ,RKAP
USE YOMCST   , ONLY : RG       ,RD       ,RCPD
USE YOPHLC   , ONLY : AH0      ,USTARL   ,USTARS   ,ALANDZ0  ,&
 & ASEAZ0   ,LVDFLC   ,LSDRLC   ,LZMCON   ,LKEXP    ,&
 & LVDFDS   ,LSDRDS  
USE YOMGEM   , ONLY : VALH     ,VBH      ,VP00

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

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV 
INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KFDIA 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTSTEP 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PLSM(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPHI5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PAPHI(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PAPHIF(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PU9(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PV9(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PT9(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PUT1(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVT1(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTT1(KLON,KLEV) 

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

INTEGER(KIND=JPIM) :: JPDIMZM

PARAMETER (JPDIMZM=3)

REAL(KIND=JPRB) :: ZM5(JPDIMZM*KLON,KLEV,-1:1)
REAL(KIND=JPRB) :: ZM5TRAS(JPDIMZM*KLON,KLEV,-1:1)
REAL(KIND=JPRB) :: ZPS(KLON)
REAL(KIND=JPRB) :: ZPLEV(KLON,0:KLEV), ZPLEVF(KLON,KLEV)
REAL(KIND=JPRB) :: ZZLEV(KLON,0:KLEV), ZZLEVF(KLON,KLEV)
REAL(KIND=JPRB) :: ZRDELPF(KLON,KLEV)

REAL(KIND=JPRB) :: ZCPTGZ9(KLON,KLEV),ZGEO0(KLON,KLEV)
REAL(KIND=JPRB) :: ZSOL(JPDIMZM*KLON,KLEV)

REAL(KIND=JPRB) :: ZRHS(JPDIMZM*KLON,KLEV)

INTEGER(KIND=JPIM) :: IDIM, IEND, IFIRST, IS, IU, IV, JK, JLEV, JLON

REAL(KIND=JPRB) :: ZCON1, ZCON2, ZDELTA, ZDT, ZFC, ZFLU, ZGAMMAD,&
 & ZH0, ZH1, ZK, ZKL, ZKU, ZL, ZLAM, ZP0, ZRDELTA, &
 & ZRDELZ, ZRDELZF, ZRGLAM, ZRLAM, ZRZ0, ZT0, &
 & ZUSTAR, ZZ0  
REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

#include "tridia.h"
#include "abor1.intfb.h"

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

!*    1. INITIALIZE CONSTANTS.
!     ------------------------

!     1.1 PHYSICAL CONSTANTS

!     ASYMPTOTYC MIXING LENGHT

ZLAM=RLAM/2.0_JPRB
ZRGLAM=1.0_JPRB/(RG*ZLAM)

!     CONSTANTS TO COMPUTE THE VERT DIFF IF(LZMCON)

ZRLAM=1.0_JPRB/ZLAM
ZT0=288.15_JPRB
ZGAMMAD=RG/RCPD
ZDELTA=RCPD/RD
ZRDELTA=1.0_JPRB/ZDELTA
ZP0=VP00
ZCON1=ZGAMMAD/(RG*ZT0)
ZCON2=ZT0/ZGAMMAD
ZH0=AH0
ZH1=8.000_JPRB

!     1.2 ARGUMENTS FOR CALLING SUBROUTINE TRIDIA

IFIRST=JPDIMZM*(KIDIA-1)+1
IEND=JPDIMZM*KFDIA
IDIM=JPDIMZM*KLON

!     1.3 TIME STEP

ZDT=PTSTEP
!     ------------------------------------------------------------------
!     ------------------------------------------------------------------
!     TRAJECTORY COMPUTATIONS
!     ------------------------------------------------------------------
!     ------------------------------------------------------------------

!*    2. DEFINE VARIABLES AND INITIALIZATION OF ZM5.
!     ----------------------------------------------

!     2.1 DEFINE S=CP(Q)*T+GZ

!     2.4 INITIALIZATION.

DO JLEV=1,KLEV
  DO JLON=KIDIA,KFDIA
    IU=JPDIMZM*(JLON-1)+1
    IV=IU+1
    IS=IU+2
    ZM5(IU,JLEV,-1)=0.0_JPRB
    ZM5(IU,JLEV, 0)=1.0_JPRB
    ZM5(IU,JLEV, 1)=0.0_JPRB

    ZRHS(IU,JLEV)=0.0_JPRB
    ZRHS(IV,JLEV)=0.0_JPRB
    ZRHS(IS,JLEV)=0.0_JPRB
  ENDDO
ENDDO

!     2.5 VARIABLES IF(LZMCON)

IF(LZMCON) THEN
  DO JLON=KIDIA,KFDIA
    ZPS(JLON)=ZP0*( (1.0_JPRB-ZCON1*PAPHI5(JLON,KLEV))**(ZDELTA) )
  ENDDO

!     PRESSURE ON THE HALF LEVELS

  DO JLEV=0,KLEV
    DO JLON=KIDIA,KFDIA
      ZPLEV(JLON,JLEV)=VALH(JLEV)+VBH(JLEV)*ZPS(JLON)
    ENDDO
  ENDDO

!    PRESSURE ON THE FULL LEVELS

  DO JLEV=1,KLEV
    DO JLON=KIDIA,KFDIA
      ZPLEVF(JLON,JLEV)=0.5_JPRB*(ZPLEV(JLON,JLEV-1)+ZPLEV(JLON,JLEV) )
    ENDDO
  ENDDO

!    HEIGHT OF THE HALF LEVELS

  DO JLEV=0,KLEV
    DO JLON=KIDIA,KFDIA
      ZZLEV(JLON,JLEV) = ZCON2*( 1.0_JPRB-(ZPLEV(JLON,JLEV)/ZP0)**(ZRDELTA) )
    ENDDO
  ENDDO

!    HEIGHT OF THE FULL LEVELS ABOVE THE SURFACE

  DO JLEV=1,KLEV
    DO JLON=KIDIA,KFDIA
      ZZLEVF(JLON,JLEV) = ZCON2*&
       & ( 1.0_JPRB-(ZPLEVF(JLON,JLEV)/ZP0)**(ZRDELTA) )&
       & - ZZLEV(JLON,KLEV)  
    ENDDO
  ENDDO

!    HEIGHT OF THE HALF LEVELS ABOVE THE SURFACE

  DO JLEV=0,KLEV
    DO JLON=KIDIA,KFDIA
      ZZLEV(JLON,JLEV) = ZZLEV(JLON,JLEV)-ZZLEV(JLON,KLEV)
    ENDDO
  ENDDO

!     INVERSE OF THE THICKNESS AT FULL LEVELS (IN PRESSURE)

  DO JLEV=1,KLEV
    DO JLON=KIDIA,KFDIA
      ZRDELPF(JLON,JLEV) =1.0_JPRB/(ZPLEV(JLON,JLEV)-ZPLEV(JLON,JLEV-1))
    ENDDO
  ENDDO
ENDIF
!     -----------------------------------------------------------------

!*    3. VERTICAL DIFFUSION.
!     ----------------------

IF(LVDFLC) THEN
!     -----------------------------------------------------------------
  IF(.NOT.LZMCON) THEN
    WRITE(NULOUT,'('' >> VDIFLCZAD: TL NOT CODED '')')
    CALL ABOR1('VDIFLCZAD : TL NOT CODED, LZMCON=FALSE') 
  ENDIF
!     -----------------------------------------------------------------

  DO JLEV=1,KLEV-1

    DO JLON=KIDIA,KFDIA
      IU=JPDIMZM*(JLON-1)+1

!     COMPUTATION OF THE DIFFUSION COEFFICIENT

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

!     VERT DIFF WITH CONSTANT COEFFICIENT

!     COMPUTE THE REFERENCE VALUE FOR USTAR

      ZUSTAR=PLSM(JLON)*USTARL+(1.0_JPRB-PLSM(JLON))*USTARS

      IF(.NOT.LKEXP) THEN

!     Vert diff coefficient: RHO*K=R0*EXP(-Z/ZH1)*USTAR*ZL*(1-Z/H0)
!                            WITH R0=1, H1=8.000

        IF(ZZLEV(JLON,JLEV) <= ZH0) THEN
          ZL = RKAP*ZZLEV(JLON,JLEV)/( 1.0_JPRB + ZRLAM*RKAP*ZZLEV(JLON,JLEV) )
          ZRDELZ   = 1.0_JPRB/(ZZLEVF(JLON,JLEV+1)-ZZLEVF(JLON,JLEV))
          ZFC =  (1.0_JPRB-(ZZLEV(JLON,JLEV)/ZH0))*EXP(-ZZLEV(JLON,JLEV)/ZH1)
          ZK  = RG*ZDT*ZL*ZFC*ZUSTAR*ZRDELZ
        ELSE
          ZK  = 0.0_JPRB
        ENDIF
      ELSE

!     Vert diff coefficient: RHO*K=R0*EXP(-Z/H0)*USTAR*ZL

        ZL = RKAP*ZZLEV(JLON,JLEV)/( 1.0_JPRB + ZRLAM*RKAP*ZZLEV(JLON,JLEV) )
        ZRDELZ   = 1.0_JPRB/(ZZLEVF(JLON,JLEV+1)-ZZLEVF(JLON,JLEV))
        ZFC =  EXP(-ZZLEV(JLON,JLEV)/ZH0)
        ZK  = RG*ZDT*ZL*ZFC*ZUSTAR*ZRDELZ
      ENDIF

      ZKU  = ZK*ZRDELPF(JLON,JLEV)
      ZKL  = ZK*ZRDELPF(JLON,JLEV+1)
!     -----------------------------------------------------------------
      ZM5(IU,JLEV,0) = ZM5(IU,JLEV,0) - ZKU
      ZM5(IU,JLEV,1) = ZM5(IU,JLEV,1) + ZKU
      ZM5(IU,JLEV+1,-1) = ZM5(IU,JLEV+1,-1) + ZKL
      ZM5(IU,JLEV+1,0) = ZM5(IU,JLEV+1,0) - ZKL

    ENDDO
  ENDDO
!     -----------------------------------------------------------------
!     -----------------------------------------------------------------
ENDIF
!     -----------------------------------------------------------------
!     -----------------------------------------------------------------

!*    4. AS IN 3.: FILL IN DRY STATIC ZM.
!     -----------------------------------

!     4.1 DRY STATIC ENERGY

IF(.NOT.LSDRDS) THEN

!     NO surface drag on dse

  DO JK=-1,1
    DO JLEV=1,KLEV
      DO JLON=KIDIA,KFDIA
        IU=JPDIMZM*(JLON-1)+1
        IS=IU+2
        ZM5(IS,JLEV,JK) = ZM5(IU,JLEV,JK)
      ENDDO
    ENDDO
  ENDDO
ENDIF

!*    5. MOMENTUM FLUX THROUGH SURFACE.
!     ---------------------------------

!     -----------------------------------------------------------------
IF(.NOT.LZMCON) THEN
!     -----------------------------------------------------------------
  WRITE(NULOUT,'('' >> VDIFLCZAD: TL NOT CODED '')')
  CALL ABOR1('VDIFLCZAD:TL NOT CODED')
!     -----------------------------------------------------------------
ENDIF
!     -----------------------------------------------------------------
IF(LSDRLC) THEN
!     -----------------------------------------------------------------
!     -----------------------------------------------------------------

  DO JLON=KIDIA,KFDIA
    IU=JPDIMZM*(JLON-1)+1

!     COMPUTATION OF THE DRAG COEFFICIENT

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

!     SURFACE DRAG WITH CONSTANT COEFFICIENT

    ZUSTAR=PLSM(JLON)*USTARL+(1.0_JPRB-PLSM(JLON))*USTARS
    ZZ0=PLSM(JLON)*ALANDZ0+(1.0_JPRB-PLSM(JLON))*ASEAZ0
    ZRZ0 = 1.0_JPRB/ZZ0
    ZL=RKAP*ZZLEVF(JLON,KLEV)/LOG(1.0_JPRB+ZZLEVF(JLON,KLEV)*ZRZ0)
    ZRDELZF  = 1.0_JPRB/ZZLEVF(JLON,KLEV)
    ZFLU = RG*ZDT*ZL*ZUSTAR*ZRDELZF*ZRDELPF(JLON,KLEV)
!     -----------------------------------------------------------------

!     ADD SURFACE DRAG TO THE ZM MATRIX AT LEVEL KLEV FOR U-COMPONENT

    ZM5(IU,KLEV,0) = ZM5(IU,KLEV,0) + ZFLU

  ENDDO
!     -----------------------------------------------------------------
!     -----------------------------------------------------------------
ENDIF
!     -----------------------------------------------------------------
!     -----------------------------------------------------------------

!*    6. FILL IN V-DIFF AND DEFINE THE RHS FOR THE TRIDIAGONAL PROBLEM.
!     -----------------------------------------------------------------

DO JLEV=1,KLEV

  DO JLON=KIDIA,KFDIA
    IU = JPDIMZM*(JLON -1) + 1
    IV = IU + 1
    IS = IU + 2

!     V-MATRICES

    ZM5(IV,JLEV,-1) = ZM5(IU,JLEV,-1)
    ZM5(IV,JLEV, 0) = ZM5(IU,JLEV, 0)
    ZM5(IV,JLEV, 1) = ZM5(IU,JLEV, 1)

    IF(LSDRDS) THEN

!     Surface drag on dse

      ZM5(IS,JLEV,-1) = ZM5(IU,JLEV,-1)
      ZM5(IS,JLEV, 0) = ZM5(IU,JLEV, 0)
      ZM5(IS,JLEV, 1) = ZM5(IU,JLEV, 1)
    ENDIF

  ENDDO

ENDDO
!     -----------------------------------------------------------------

!*    7. SOLVE LINEAR SYSTEMS AND COMPUTE TENDENCIES.
!     -----------------------------------------------


!     8. COMPUTE THE TRANSPOSE OF ZM5.
!     --------------------------------

DO JLEV=2,KLEV-1
  DO JLON=KIDIA,KFDIA
    IU=JPDIMZM*(JLON-1)+1
    IV=IU+1
    IS=IU+2
    ZM5TRAS(IU,JLEV,-1)=ZM5(IU,JLEV-1,+1)
    ZM5TRAS(IU,JLEV, 0)=ZM5(IU,JLEV,0)
    ZM5TRAS(IU,JLEV, 1)=ZM5(IU,JLEV+1,-1)

    ZM5TRAS(IV,JLEV,-1)=ZM5(IV,JLEV-1,+1)
    ZM5TRAS(IV,JLEV, 0)=ZM5(IV,JLEV,0)
    ZM5TRAS(IV,JLEV, 1)=ZM5(IV,JLEV+1,-1)

    ZM5TRAS(IS,JLEV,-1)=ZM5(IS,JLEV-1,+1)
    ZM5TRAS(IS,JLEV, 0)=ZM5(IS,JLEV,0)
    ZM5TRAS(IS,JLEV, 1)=ZM5(IS,JLEV+1,-1)
  ENDDO
ENDDO

DO JLON=KIDIA,KFDIA
  IU=JPDIMZM*(JLON-1)+1
  IV=IU+1
  IS=IU+2
  ZM5TRAS(IU,1,-1)=0.0_JPRB
  ZM5TRAS(IU,1, 0)=ZM5(IU,1,0)
  ZM5TRAS(IU,1, 1)=ZM5(IU,2,-1)
  ZM5TRAS(IU,KLEV,-1)=ZM5(IU,KLEV-1,+1)
  ZM5TRAS(IU,KLEV, 0)=ZM5(IU,KLEV,0)
  ZM5TRAS(IU,KLEV, 1)=0.0_JPRB

  ZM5TRAS(IV,1,-1)=0.0_JPRB
  ZM5TRAS(IV,1, 0)=ZM5(IV,1,0)
  ZM5TRAS(IV,1, 1)=ZM5(IV,2,-1)
  ZM5TRAS(IV,KLEV,-1)=ZM5(IV,KLEV-1,+1)
  ZM5TRAS(IV,KLEV, 0)=ZM5(IV,KLEV,0)
  ZM5TRAS(IV,KLEV, 1)=0.0_JPRB

  ZM5TRAS(IS,1,-1)=0.0_JPRB
  ZM5TRAS(IS,1, 0)=ZM5(IS,1,0)
  ZM5TRAS(IS,1, 1)=ZM5(IS,2,-1)
  ZM5TRAS(IS,KLEV,-1)=ZM5(IS,KLEV-1,+1)
  ZM5TRAS(IS,KLEV, 0)=ZM5(IS,KLEV,0)
  ZM5TRAS(IS,KLEV, 1)=0.0_JPRB
ENDDO

!     -----------------------------------------------------------------
!     -----------------------------------------------------------------
!     PERTURBATIONS
!     ------------------------------------------------------------------
!     ------------------------------------------------------------------

!     10.1 INITIALIZE LOCAL ARRAYS

DO JLEV=1,KLEV
  DO JLON=KIDIA,KFDIA
    ZCPTGZ9(JLON,JLEV)=0.0_JPRB
    ZGEO0(JLON,JLEV)=0.0_JPRB
  ENDDO
ENDDO

DO JLEV=1,KLEV
  DO JLON=KIDIA,KFDIA
    IU=JPDIMZM*(JLON-1)+1
    IV=IU+1
    IS=IU+2
    ZSOL(IU,JLEV)=0.0_JPRB
    ZSOL(IV,JLEV)=0.0_JPRB
    ZSOL(IS,JLEV)=0.0_JPRB
    ZRHS(IU,JLEV)=0.0_JPRB
    ZRHS(IV,JLEV)=0.0_JPRB
    ZRHS(IS,JLEV)=0.0_JPRB
  ENDDO
ENDDO
!     -----------------------------------------------------------------

!     21. UPDATE VARIABLES

DO JLEV=1,KLEV

  DO JLON=KIDIA,KFDIA
    IU = JPDIMZM*(JLON -1) + 1
    IV = IU + 1
    IS = IU + 2

    IF(LVDFDS) ZSOL(IS,JLEV) = PTT1(JLON,JLEV)+ZSOL(IS,JLEV)

    ZSOL(IV,JLEV) = PVT1(JLON,JLEV)+ZSOL(IV,JLEV)
    ZSOL(IU,JLEV) = PUT1(JLON,JLEV)+ZSOL(IU,JLEV)

  ENDDO
ENDDO
!     -----------------------------------------------------------------

!     20. INCREMENTS COMPUTATION
!         - CP IS CONSTANT SINCE Q HAS NO VERT DIFF
!         - GEOM1 IS CONSIDERED CONSTANT

DO JLEV=1,KLEV

  DO JLON=KIDIA,KFDIA
    IU = JPDIMZM*(JLON -1) + 1
    IV = IU + 1
    IS = IU + 2
    ZGEO0(JLON,JLEV) = ZGEO0(JLON,JLEV) -ZSOL(IS,JLEV)/RCPD
    PT9(JLON,JLEV) = PT9(JLON,JLEV) - ZSOL(IS,JLEV)
    ZSOL(IS,JLEV) = ZSOL(IS,JLEV)/RCPD

    PV9(JLON,JLEV) = PV9(JLON,JLEV)-ZSOL(IV,JLEV)
    PU9(JLON,JLEV) = PU9(JLON,JLEV)-ZSOL(IU,JLEV)

  ENDDO

ENDDO
!     -----------------------------------------------------------------

!     18. SOLVE THE TRIDIAGONAL PROBLEM FOR THE TIME-9 VARIABLES
!     ----------------------------------------------------------

!     TL:      ZSOL = (ZM5**(-1)) * ZRHS
!     ADJOINT: ZRHS = (ZM5TRAS**(-1)) * ZSOL

CALL TRIDIA(KLEV,IDIM,IFIRST,IEND,2,ZM5TRAS,ZSOL,ZRHS)

!     NOW ZSOL ARE THE UPDATED TIME-9 VARIABLES AFTER VERT DIFF

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

!     17. COMPUTE THE RHS FOR THE TIME-9 VARIABLES TRIDIAGONAL PROBLEM

DO JLEV=1,KLEV
  DO JLON=KIDIA,KFDIA
    IU = JPDIMZM*(JLON -1) + 1
    IV = IU + 1
    IS = IU + 2

    ZCPTGZ9(JLON,JLEV) = ZCPTGZ9(JLON,JLEV) + ZRHS(IS,JLEV)
    ZRHS(IS,JLEV)=0.0_JPRB
    PV9(JLON,JLEV) = PV9(JLON,JLEV) + ZRHS(IV,JLEV)
    ZRHS(IV,JLEV)=0.0_JPRB
    PU9(JLON,JLEV) = PU9(JLON,JLEV) + ZRHS(IU,JLEV)
    ZRHS(IU,JLEV)=0.0_JPRB

  ENDDO
ENDDO

!     11. DEFINE S=CP(Q)*T+GZ.
!     ------------------------

DO JLEV=1,KLEV
  DO JLON=KIDIA,KFDIA
    ZGEO0(JLON,JLEV) = ZGEO0(JLON,JLEV) + ZCPTGZ9(JLON,JLEV)
    PT9(JLON,JLEV) = PT9(JLON,JLEV) + RCPD * ZCPTGZ9(JLON,JLEV)
    ZCPTGZ9(JLON,JLEV)=0.0_JPRB

    PAPHIF(JLON,JLEV) = PAPHIF(JLON,JLEV) + ZGEO0(JLON,JLEV)
    PAPHI(JLON,KLEV) = PAPHI(JLON,KLEV) - ZGEO0(JLON,JLEV)
    ZGEO0(JLON,JLEV)=0.0_JPRB
  ENDDO
ENDDO

!*    10. INITIALIZATION.
!     ------------------

DO JLEV=1,KLEV
  DO JLON=KIDIA,KFDIA
    IU=JPDIMZM*(JLON-1)+1
    IV=IU+1
    IS=IU+2
    ZRHS(IU,JLEV)=0.0_JPRB
    ZRHS(IV,JLEV)=0.0_JPRB
    ZRHS(IS,JLEV)=0.0_JPRB
  ENDDO
ENDDO
!     -----------------------------------------------------------------

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

