SUBROUTINE LWVDAD &
 & ( KIDIA, KFDIA, KLON , KLEV  , KTRAER,&
 & PGA    , PGB    ,&
 & PABCU5 , PDBDT5 ,&
 & PCNTRB5, PDISD5 , PDISU5, PDWFSU5, &
! saved in NL coputation - lwvd
 & PTTA5  , PTTB5 ,&
! perturbation
 & PABCU  , PDBDT  ,&
 & PCNTRB , PDISD  , PDISU , PDWFSU &
 & )

!**** *LWVDAD*   - L.W., VERTICAL INTEGRATION, DISTANT LAYERS
!                      (adjoint)

!     PURPOSE.
!     --------
!           CARRIES OUT THE VERTICAL INTEGRATION ON THE DISTANT LAYERS

!**   INTERFACE.
!     ----------

!        EXPLICIT ARGUMENTS :
!        --------------------
!     ==== INPUTS ===
!  Trajectory  Perturbation  Description                    Dimension
!  PABCU5      PABCU         ABSORBER AMOUNTS               (KLON,NUA,3*KLEV+1)
!  PDBDT5      PDBDT         LAYER PLANCK FUNCTION GRADIENT (KLON,KLEV)
!  PGA         ---           PADE APPROXIMANTS              (KLON,NIPD,2)
!  PGB         ---           PADE APPROXIMANTS              (KLON,NIPD,2)

!     ==== OUTPUTS ===
!  Trajectory  Perturbation  Description                       Dimension
!  PCNTRB5     PCNTRB        ENERGY EXCHANGE MATRIX        (KLON,KLEV+1,KLEV+1)
!  PDISD5      PDISD         CONTRIBUTION BY DISTANT LAYERS    (KLON,KLEV+1)
!  PDISU5      PDISU         CONTRIBUTION BY DISTANT LAYERS    (KLON,KLEV+1)
!  PDWFSU5     PDWFSU        SPECTRAL DOWNWARD FLUX AT SURFACE (KLON,NSIL)

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

!     METHOD.
!     -------

!          1. PERFORMS THE VERTICAL INTEGRATION CORRESPONDING TO THE
!     CONTRIBUTIONS OF THE DISTANT LAYERS USING TRAPEZOIDAL RULE

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

!          *LWTTMAD*

!     REFERENCE.
!     ----------

!        SEE RADIATION'S PART OF THE MODEL'S DOCUMENTATION AND
!        ECMWF RESEARCH DEPARTMENT DOCUMENTATION OF THE IFS

!     AUTHOR.
!     -------
!        M. Janiskova  *ECMWF*       7-DEc-2006

!     MODIFICATIONS.
!     --------------

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

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

USE YOELW    , ONLY : NSIL     ,NIPD     ,NTRA     ,NUA      ,NG1P1
USE YOPHNC   , ONLY : LWLOPT

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 
INTEGER(KIND=JPIM),INTENT(IN)    :: KTRAER 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGA(KLON,NIPD,2,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGB(KLON,NIPD,2,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PABCU5(KLON,NUA,3*KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PDBDT5(KLON,NSIL,KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCNTRB5(KLON,KLEV+1,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PDISD5(KLON,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PDISU5(KLON,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PDWFSU5(KLON,NSIL) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PABCU(KLON,NUA,3*KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PDBDT(KLON,NSIL,KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PCNTRB(KLON,KLEV+1,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PDISD(KLON,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PDISU(KLON,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PDWFSU(KLON,NSIL)
! saved in NL coputation - lwvd
REAL(KIND=JPRB)   ,INTENT(INOUT)   :: PTTA5(KLON,KTRAER*KLEV,KLEV+1)
REAL(KIND=JPRB)   ,INTENT(INOUT)   :: PTTB5(KLON,KTRAER*KLEV,KLEV+1)

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

!*       0.1   ARGUMENTS
!              ---------

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

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

REAL(KIND=JPRB) :: ZTT(KLON,NTRA), ZTTP(KLON,NTRA,KLEV+1)
REAL(KIND=JPRB) :: ZTTP5(KLON,NTRA,KLEV+1)
!REAL(KIND=JPRB) :: ZTTPA5(KLON,KLEV+1,KLEV+1),ZTTPB5(KLON,KLEV+1,KLEV+1)

REAL(KIND=JPRB) :: ZWW1, ZWW2, ZWW3, ZWW4, ZWW5, ZWW6
REAL(KIND=JPRB) :: ZWW15, ZWW25, ZWW35, ZWW45, ZWW55, ZWW65

INTEGER(KIND=JPIM) :: IJKL, IKD1, IKD2, IKJ, IKJP1, IKM1, IKN,&
 & IKP1, IKU1, IKU2, JA, JK, JKJ, JL, JLK 
INTEGER(KIND=JPIM) :: IJA,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10
INTEGER(KIND=JPIM) :: I11,I12,I13,I14,I15

REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "lwttm.intfb.h"
#include "lwttmad.intfb.h"

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

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

!*         1.    INITIALIZATION
!                --------------

DO JA = 1, NTRA
  DO JL = KIDIA,KFDIA
    ZTTP5(JL,JA,:) = 1.0_JPRB
  ENDDO
ENDDO

!*         1.1     INITIALIZE LAYER CONTRIBUTIONS
!                  ------------------------------

IF (.NOT. LWLOPT) THEN
  DO JK = 1, KLEV+1
    DO JL = KIDIA,KFDIA
      PDISD5(JL,JK) = 0.0_JPRB
      PDISU5(JL,JK) = 0.0_JPRB
    ENDDO
  ENDDO

!*         1.2     INITIALIZE TRANSMISSION FUNCTIONS
!                  ---------------------------------

  DO JA = 1, NTRA
    DO JL = KIDIA,KFDIA
      PTTA5(JL,JA,:) = 1.0_JPRB
      PTTB5(JL,JA,:) = 1.0_JPRB
    ENDDO
  ENDDO

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

!*         2.      VERTICAL INTEGRATION
!                  --------------------

!*         2.2     CONTRIBUTION FROM DISTANT LAYERS
!                  ---------------------------------

!*         2.2.1   DISTANT AND ABOVE LAYERS
!                  ------------------------

!*         2.2.2   FIRST UPPER LEVEL
!                  -----------------

  DO JK = 1 , KLEV-1
    IKP1=JK+1
    IKN=(JK-1)*NG1P1+1
    IKD1= JK  *NG1P1+1

    CALL LWTTM &
     & ( KIDIA        , KFDIA        , KLON,&
     & PGA(1,1,1,JK)  , PGB(1,1,1,JK),&
     & PABCU5(1,1,IKN), PABCU5(1,1,IKD1), ZTTP5(1,1,JK) )  

!*         2.2.3   HIGHER UP
!                  ---------

    DO JKJ=IKP1,KLEV
      IKJP1=JKJ+1
      IKD2= JKJ  *NG1P1+1

      CALL LWTTM &
       & ( KIDIA        , KFDIA         , KLON,&
       & PGA(1,1,1,JKJ) , PGB(1,1,1,JKJ),&
       & PABCU5(1,1,IKN), PABCU5(1,1,IKD2), ZTTP5(1,1,JKJ) )

      DO JA = 1, KTRAER
        IJA = (JA-1)*KLEV+JKJ

        DO JL = KIDIA,KFDIA
          PTTA5(JL,IJA,JK) = &
           & (ZTTP5(JL,JA,JKJ-1)+ZTTP5(JL,JA,JKJ))*0.5_JPRB
        ENDDO
      ENDDO

      I1  =  JKJ
      I2  =  KLEV+JKJ
      I3  =  2*KLEV+JKJ
      I4  =  3*KLEV+JKJ
      I5  =  4*KLEV+JKJ
      I6  =  5*KLEV+JKJ
      I7  =  6*KLEV+JKJ
      I8  =  7*KLEV+JKJ
      I9  =  8*KLEV+JKJ
      I10 =  9*KLEV+JKJ
      I11 = 10*KLEV+JKJ
      I12 = 11*KLEV+JKJ
      I13 = 12*KLEV+JKJ
      I14 = 13*KLEV+JKJ
      I15 = 14*KLEV+JKJ

      DO JL = KIDIA,KFDIA
        ZWW15 = PDBDT5(JL,1,JKJ)*PTTA5(JL,I1,JK)*PTTA5(JL,I10,JK)
        ZWW25 = PDBDT5(JL,2,JKJ)*PTTA5(JL,I2,JK)*PTTA5(JL,I7,JK) &
         & * PTTA5(JL,I11,JK)
        ZWW35 = PDBDT5(JL,3,JKJ)*PTTA5(JL,I4,JK)*PTTA5(JL,I8,JK) &
         & * PTTA5(JL,I12,JK)
        ZWW45 = PDBDT5(JL,4,JKJ)*PTTA5(JL,I5,JK)*PTTA5(JL,I9,JK) &
         & * PTTA5(JL,I13,JK)
        ZWW55 = PDBDT5(JL,5,JKJ)*PTTA5(JL,I3,JK)*PTTA5(JL,I14,JK)
        ZWW65 = PDBDT5(JL,6,JKJ)*PTTA5(JL,I6,JK)*PTTA5(JL,I15,JK)

        PCNTRB5(JL,JK,IKJP1) = ZWW15+ZWW25+ZWW35+ZWW45+ZWW55+ZWW65
        PDISD5(JL,JK) = PDISD5(JL,JK)+PCNTRB5(JL,JK,IKJP1)
        IF (JK == 1) THEN
          PDWFSU5(JL,1) = PDWFSU5(JL,1)+ZWW15
          PDWFSU5(JL,2) = PDWFSU5(JL,2)+ZWW25
          PDWFSU5(JL,3) = PDWFSU5(JL,3)+ZWW35
          PDWFSU5(JL,4) = PDWFSU5(JL,4)+ZWW45
          PDWFSU5(JL,5) = PDWFSU5(JL,5)+ZWW55
          PDWFSU5(JL,6) = PDWFSU5(JL,6)+ZWW65
        ENDIF
      ENDDO

    ENDDO
  ENDDO

!*         2.2.4   DISTANT AND BELOW LAYERS
!                  ------------------------

!*         2.2.5   FIRST LOWER LEVEL
!                  -----------------

  DO JK=3,KLEV+1
    IKN=(JK-1)*NG1P1+1
    IKM1=JK-1
    IKJ=JK-2
    IKU1= IKJ  *NG1P1+1

    CALL LWTTM &
     & ( KIDIA          , KFDIA         , KLON,&
     & PGA(1,1,1,IKJ) , PGB(1,1,1,IKJ),&
     & PABCU5(1,1,IKU1), PABCU5(1,1,IKN), ZTTP5(1,1,1) )

!*         2.2.6   DOWN BELOW
!                  ----------

    DO JLK=1,IKJ
      IJKL=IKM1-JLK
      IKU2=(IJKL-1)*NG1P1+1

      CALL LWTTM &
       & ( KIDIA          , KFDIA          , KLON,&
       & PGA(1,1,1,IJKL), PGB(1,1,1,IJKL),&
       & PABCU5(1,1,IKU2), PABCU5(1,1,IKN) , ZTTP5(1,1,JLK+1) )

      DO JA = 1, KTRAER
        IJA = (JA-1)*KLEV+JLK

        DO JL = KIDIA,KFDIA
          PTTB5(JL,IJA,JK) = &
           & (ZTTP5(JL,JA,JLK)+ZTTP5(JL,JA,JLK+1))*0.5_JPRB
        ENDDO
      ENDDO

      I1  =  JLK
      I2  =  KLEV+JLK
      I3  =  2*KLEV+JLK
      I4  =  3*KLEV+JLK
      I5  =  4*KLEV+JLK
      I6  =  5*KLEV+JLK
      I7  =  6*KLEV+JLK
      I8  =  7*KLEV+JLK
      I9  =  8*KLEV+JLK
      I10 =  9*KLEV+JLK
      I11 = 10*KLEV+JLK
      I12 = 11*KLEV+JLK
      I13 = 12*KLEV+JLK
      I14 = 13*KLEV+JLK
      I15 = 14*KLEV+JLK

      DO JL = KIDIA,KFDIA
        PCNTRB5(JL,JK,IJKL) = PDBDT5(JL,1,IJKL)*PTTB5(JL,I1,JK) &
         & * PTTB5(JL,I10,JK) &
         & + PDBDT5(JL,2,IJKL)*PTTB5(JL,I2,JK)*PTTB5(JL,I7,JK) &
         & * PTTB5(JL,I11,JK) &
         & + PDBDT5(JL,3,IJKL)*PTTB5(JL,I4,JK)*PTTB5(JL,I8,JK) &
         & * PTTB5(JL,I12,JK) &
         & + PDBDT5(JL,4,IJKL)*PTTB5(JL,I5,JK)*PTTB5(JL,I9,JK) &
         & * PTTB5(JL,I13,JK) &
         & + PDBDT5(JL,5,IJKL)*PTTB5(JL,I3,JK)*PTTB5(JL,I14,JK)&
         & + PDBDT5(JL,6,IJKL)*PTTB5(JL,I6,JK)*PTTB5(JL,I15,JK)
        PDISU5(JL,JK) = PDISU5(JL,JK)+PCNTRB5(JL,JK,IJKL)
      ENDDO

    ENDDO
  ENDDO
ENDIF

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

!*         0.    ADJOINT CALCULATIONS
!                --------------------

!* Set local variables to zero

ZTT(:,:) = 0.0_JPRB
ZTTP(:,:,:) = 0.0_JPRB

!* -------------------------------------------------------------------

!-----------------------
!* BACKWARD COMPUTATION
!-----------------------

!*         1.2.    VERTICAL INTEGRATION
!                  --------------------

!*         1.2.2     CONTRIBUTION FROM DISTANT LAYERS
!                    ---------------------------------

!*         1.2.2.4   DISTANT AND BELOW LAYERS
!                    ------------------------

DO JK = KLEV+1 , 3 , -1
  IKN=(JK-1)*NG1P1+1
  IKM1=JK-1
  IKJ=JK-2
  IKU1= IKJ  *NG1P1+1

!*         1.2.2.6   DOWN BELOW
!                    ----------

  DO JLK=IKJ,1,-1
    IJKL=IKM1-JLK
    IKU2=(IJKL-1)*NG1P1+1

    I1  =  JLK
    I2  =  KLEV+JLK
    I3  =  2*KLEV+JLK
    I4  =  3*KLEV+JLK
    I5  =  4*KLEV+JLK
    I6  =  5*KLEV+JLK
    I7  =  6*KLEV+JLK
    I8  =  7*KLEV+JLK
    I9  =  8*KLEV+JLK
    I10 =  9*KLEV+JLK
    I11 = 10*KLEV+JLK
    I12 = 11*KLEV+JLK
    I13 = 12*KLEV+JLK
    I14 = 13*KLEV+JLK
    I15 = 14*KLEV+JLK

    DO JL = KIDIA,KFDIA
      PCNTRB(JL,JK,IJKL) = PCNTRB(JL,JK,IJKL)+PDISU(JL,JK)
      ZTT(JL,10) = ZTT(JL,10) &
       & + PDBDT5(JL,1,IJKL)*PTTB5(JL,I1,JK)*PCNTRB(JL,JK,IJKL)
      ZTT(JL,1) = ZTT(JL,1) &
       & + PDBDT5(JL,1,IJKL)*PTTB5(JL,I10,JK)*PCNTRB(JL,JK,IJKL)
      PDBDT(JL,1,IJKL) = PDBDT(JL,1,IJKL) &
       & + PTTB5(JL,I1,JK)*PTTB5(JL,I10,JK)*PCNTRB(JL,JK,IJKL)
      ZTT(JL,11) = ZTT(JL,11)+PDBDT5(JL,2,IJKL)*PTTB5(JL,I2,JK) &
       & * PTTB5(JL,I7,JK)*PCNTRB(JL,JK,IJKL)
      ZTT(JL,7) = ZTT(JL,7)+PDBDT5(JL,2,IJKL)*PTTB5(JL,I2,JK) &
       & * PTTB5(JL,I11,JK)*PCNTRB(JL,JK,IJKL)
      ZTT(JL,2) = ZTT(JL,2)+PDBDT5(JL,2,IJKL)*PTTB5(JL,I7,JK) &
       & * PTTB5(JL,I11,JK)*PCNTRB(JL,JK,IJKL)
      PDBDT(JL,2,IJKL) = PDBDT(JL,2,IJKL)+PTTB5(JL,I2,JK) &
       & * PTTB5(JL,I7,JK)*PTTB5(JL,I11,JK)*PCNTRB(JL,JK,IJKL)
      ZTT(JL,12) = ZTT(JL,12)+PDBDT5(JL,3,IJKL)*PTTB5(JL,I4,JK) &
       & * PTTB5(JL,I8,JK)*PCNTRB(JL,JK,IJKL)
      ZTT(JL,8) = ZTT(JL,8)+PDBDT5(JL,3,IJKL)*PTTB5(JL,I4,JK) &
       & * PTTB5(JL,I12,JK)*PCNTRB(JL,JK,IJKL)
      ZTT(JL,4) = ZTT(JL,4)+PDBDT5(JL,3,IJKL)*PTTB5(JL,I8,JK) &
       & * PTTB5(JL,I12,JK)*PCNTRB(JL,JK,IJKL)
      PDBDT(JL,3,IJKL) = PDBDT(JL,3,IJKL)+PTTB5(JL,I4,JK) &
       & * PTTB5(JL,I8,JK)*PTTB5(JL,I12,JK)*PCNTRB(JL,JK,IJKL)
      ZTT(JL,13) = ZTT(JL,13)+PDBDT5(JL,4,IJKL)*PTTB5(JL,I5,JK) &
       & * PTTB5(JL,I9,JK)*PCNTRB(JL,JK,IJKL)
      ZTT(JL,9) = ZTT(JL,9)+PDBDT5(JL,4,IJKL)*PTTB5(JL,I5,JK) &
       & * PTTB5(JL,I13,JK)*PCNTRB(JL,JK,IJKL)
      ZTT(JL,5) = ZTT(JL,5)+PDBDT5(JL,4,IJKL)*PTTB5(JL,I9,JK) &
       & * PTTB5(JL,I13,JK)*PCNTRB(JL,JK,IJKL)
      PDBDT(JL,4,IJKL) = PDBDT(JL,4,IJKL)+PTTB5(JL,I5,JK) &
       & * PTTB5(JL,I9,JK)*PTTB5(JL,I13,JK)*PCNTRB(JL,JK,IJKL)
      ZTT(JL,14) = ZTT(JL,14) &
       & + PDBDT5(JL,5,IJKL)*PTTB5(JL,I3,JK)*PCNTRB(JL,JK,IJKL)
      ZTT(JL,3) = ZTT(JL,3) &
       & + PDBDT5(JL,5,IJKL)*PTTB5(JL,I14,JK)*PCNTRB(JL,JK,IJKL)
      PDBDT(JL,5,IJKL) = PDBDT(JL,5,IJKL) &
       & + PTTB5(JL,I3,JK)*PTTB5(JL,I14,JK)*PCNTRB(JL,JK,IJKL)
      ZTT(JL,15) = ZTT(JL,15) &
       & + PDBDT5(JL,6,IJKL)*PTTB5(JL,I6,JK)*PCNTRB(JL,JK,IJKL)
      ZTT(JL,6) = ZTT(JL,6) &
       & + PDBDT5(JL,6,IJKL)*PTTB5(JL,I15,JK)*PCNTRB(JL,JK,IJKL)
      PDBDT(JL,6,IJKL) = PDBDT(JL,6,IJKL) &
       & + PTTB5(JL,I6,JK)*PTTB5(JL,I15,JK)*PCNTRB(JL,JK,IJKL)
      PCNTRB(JL,JK,IJKL) = 0.0_JPRB
    ENDDO

    DO JA = 1, KTRAER
      DO JL = KIDIA,KFDIA
        ZTTP(JL,JA,JLK)   = ZTTP(JL,JA,JLK)+0.5_JPRB*ZTT(JL,JA)
        ZTTP(JL,JA,JLK+1) = ZTTP(JL,JA,JLK+1)+0.5_JPRB*ZTT(JL,JA)
        ZTT(JL,JA) = 0.0_JPRB
      ENDDO
    ENDDO

    CALL LWTTMAD &
     & ( KIDIA          , KFDIA          , KLON,&
     & PGA(1,1,1,IJKL), PGB(1,1,1,IJKL),&
     & PABCU5(1,1,IKU2), PABCU5(1,1,IKN) , ZTTP5(1,1,JLK+1),&
     & PABCU (1,1,IKU2), PABCU (1,1,IKN) , ZTTP (1,1,JLK+1) )

  ENDDO

!*         1.2.2.5   FIRST LOWER LEVEL
!                    -----------------

  CALL LWTTMAD &
   & ( KIDIA          , KFDIA         , KLON,&
   & PGA(1,1,1,IKJ) , PGB(1,1,1,IKJ),&
   & PABCU5(1,1,IKU1), PABCU5(1,1,IKN), ZTTP5(1,1,1),&
   & PABCU (1,1,IKU1), PABCU (1,1,IKN), ZTTP (1,1,1) ) 

ENDDO

!*         1.2.2.1   DISTANT AND ABOVE LAYERS 
!                    ------------------------

DO JK = KLEV-1 , 1 , -1
  IKP1=JK+1
  IKN=(JK-1)*NG1P1+1
  IKD1= JK  *NG1P1+1

!*         1.2.2.3   HIGHER UP 
!                    ---------

  DO JKJ = KLEV , IKP1 , -1
    IKJP1=JKJ+1
    IKD2= JKJ  *NG1P1+1

    I1  =  JKJ
    I2  =  KLEV+JKJ
    I3  =  2*KLEV+JKJ
    I4  =  3*KLEV+JKJ
    I5  =  4*KLEV+JKJ
    I6  =  5*KLEV+JKJ
    I7  =  6*KLEV+JKJ
    I8  =  7*KLEV+JKJ
    I9  =  8*KLEV+JKJ
    I10 =  9*KLEV+JKJ
    I11 = 10*KLEV+JKJ
    I12 = 11*KLEV+JKJ
    I13 = 12*KLEV+JKJ
    I14 = 13*KLEV+JKJ
    I15 = 14*KLEV+JKJ

    DO JL = KIDIA,KFDIA
      PCNTRB(JL,JK,IKJP1) = PCNTRB(JL,JK,IKJP1)+PDISD(JL,JK)
      IF (JK == 1) THEN
        ZWW6 = PDWFSU(JL,6)
        ZWW5 = PDWFSU(JL,5)
        ZWW4 = PDWFSU(JL,4)
        ZWW3 = PDWFSU(JL,3)
        ZWW2 = PDWFSU(JL,2)
        ZWW1 = PDWFSU(JL,1)

        ZWW1 = ZWW1+PCNTRB(JL,JK,IKJP1)
        ZWW2 = ZWW2+PCNTRB(JL,JK,IKJP1)
        ZWW3 = ZWW3+PCNTRB(JL,JK,IKJP1)
        ZWW4 = ZWW4+PCNTRB(JL,JK,IKJP1)
        ZWW5 = ZWW5+PCNTRB(JL,JK,IKJP1)
        ZWW6 = ZWW6+PCNTRB(JL,JK,IKJP1)
      ELSE
        ZWW1 = PCNTRB(JL,JK,IKJP1)
        ZWW2 = PCNTRB(JL,JK,IKJP1)
        ZWW3 = PCNTRB(JL,JK,IKJP1)
        ZWW4 = PCNTRB(JL,JK,IKJP1)
        ZWW5 = PCNTRB(JL,JK,IKJP1)
        ZWW6 = PCNTRB(JL,JK,IKJP1)
      ENDIF
      PCNTRB(JL,JK,IKJP1) = 0.0_JPRB

      ZTT(JL,15) = ZTT(JL,15)+PDBDT5(JL,6,JKJ)*PTTA5(JL,I6,JK)*ZWW6
      ZTT(JL,6) = ZTT(JL,6)+PDBDT5(JL,6,JKJ)*PTTA5(JL,I15,JK)*ZWW6
      PDBDT(JL,6,JKJ) = PDBDT(JL,6,JKJ)+PTTA5(JL,I6,JK) &
       & * PTTA5(JL,I15,JK)*ZWW6
      ZTT(JL,14) = ZTT(JL,14)+PDBDT5(JL,5,JKJ)*PTTA5(JL,I3,JK)*ZWW5
      ZTT(JL,3) = ZTT(JL,3)+PDBDT5(JL,5,JKJ)*PTTA5(JL,I14,JK)*ZWW5
      PDBDT(JL,5,JKJ) = PDBDT(JL,5,JKJ)+PTTA5(JL,I3,JK) &
       & * PTTA5(JL,I14,JK)*ZWW5
      ZTT(JL,13) = ZTT(JL,13)+PDBDT5(JL,4,JKJ)*PTTA5(JL,I5,JK) &
       & * PTTA5(JL,I9,JK)*ZWW4
      ZTT(JL,9) = ZTT(JL,9)+PDBDT5(JL,4,JKJ)*PTTA5(JL,I5,JK) &
       & * PTTA5(JL,I13,JK)*ZWW4
      ZTT(JL,5) = ZTT(JL,5)+PDBDT5(JL,4,JKJ)*PTTA5(JL,I9,JK) &
       & * PTTA5(JL,I13,JK)*ZWW4
      PDBDT(JL,4,JKJ) = PDBDT(JL,4,JKJ) &
       & + PTTA5(JL,I5,JK)*PTTA5(JL,I9,JK)*PTTA5(JL,I13,JK)*ZWW4
      ZTT(JL,12) = ZTT(JL,12)+PDBDT5(JL,3,JKJ)*PTTA5(JL,I4,JK) &
       & * PTTA5(JL,I8,JK)*ZWW3
      ZTT(JL,8) = ZTT(JL,8)+PDBDT5(JL,3,JKJ)*PTTA5(JL,I4,JK) &
       & * PTTA5(JL,I12,JK)*ZWW3
      ZTT(JL,4) = ZTT(JL,4)+PDBDT5(JL,3,JKJ)*PTTA5(JL,I8,JK) &
       & * PTTA5(JL,I12,JK)*ZWW3
      PDBDT(JL,3,JKJ) = PDBDT(JL,3,JKJ) &
       & + PTTA5(JL,I4,JK)*PTTA5(JL,I8,JK)*PTTA5(JL,I12,JK)*ZWW3
      ZTT(JL,11) = ZTT(JL,11)+PDBDT5(JL,2,JKJ)*PTTA5(JL,I2,JK) &
       & * PTTA5(JL,I7,JK)*ZWW2
      ZTT(JL,7) = ZTT(JL,7)+PDBDT5(JL,2,JKJ)*PTTA5(JL,I2,JK) &
       & * PTTA5(JL,I11,JK)*ZWW2
      ZTT(JL,2) = ZTT(JL,2)+PDBDT5(JL,2,JKJ)*PTTA5(JL,I7,JK) &
       & * PTTA5(JL,I11,JK)*ZWW2
      PDBDT(JL,2,JKJ) = PDBDT(JL,2,JKJ) &
       & + PTTA5(JL,I2,JK)*PTTA5(JL,I7,JK)*PTTA5(JL,I11,JK)*ZWW2
      ZTT(JL,10) = ZTT(JL,10)+PDBDT5(JL,1,JKJ)*PTTA5(JL,I1,JK)*ZWW1
      ZTT(JL,1) = ZTT(JL,1)+PDBDT5(JL,1,JKJ)*PTTA5(JL,I10,JK)*ZWW1
      PDBDT(JL,1,JKJ) = PDBDT(JL,1,JKJ)+PTTA5(JL,I1,JK) &
       & * PTTA5(JL,I10,JK)*ZWW1
    ENDDO

    DO JA = 1, KTRAER
      DO JL = KIDIA,KFDIA
        ZTTP(JL,JA,JKJ-1) = ZTTP(JL,JA,JKJ-1)+0.5_JPRB*ZTT(JL,JA)
        ZTTP(JL,JA,JKJ) = ZTTP(JL,JA,JKJ)+0.5_JPRB*ZTT(JL,JA)
        ZTT(JL,JA) = 0.0_JPRB
      ENDDO
    ENDDO

    CALL LWTTMAD &
     & ( KIDIA        , KFDIA         , KLON,&
     & PGA(1,1,1,JKJ) , PGB(1,1,1,JKJ),&
     & PABCU5(1,1,IKN), PABCU5(1,1,IKD2), ZTTP5(1,1,JKJ),&
     & PABCU (1,1,IKN), PABCU (1,1,IKD2), ZTTP (1,1,JKJ) ) 
  ENDDO

!*         1.2.2.2   FIRST UPPER LEVEL
!                    -----------------

  CALL LWTTMAD &
   & ( KIDIA        , KFDIA        , KLON,&
   & PGA(1,1,1,JK)  , PGB(1,1,1,JK),&
   & PABCU5(1,1,IKN), PABCU5(1,1,IKD1), ZTTP5(1,1,JK),&
   & PABCU (1,1,IKN), PABCU (1,1,IKD1), ZTTP (1,1,JK) )  

ENDDO

!*         1.1.1     INITIALIZE LAYER CONTRIBUTIONS
!                    ------------------------------

DO JK = 1, KLEV+1
  DO JL = KIDIA,KFDIA
    PDISD (JL,JK) = 0.0_JPRB
    PDISU (JL,JK) = 0.0_JPRB
  ENDDO
ENDDO

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

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