SUBROUTINE SWRAD &
 & ( KIDIA  , KFDIA  , KLON  , KLEV   , KNU,&
 & PALBD5 , PCG5   , PCLD5 , POMEGA5, PSEC5 , PTAU5,&
 & PCGAZ5 , PPIZAZ5, PRAY15, PRAY25 , PREFZ5, PRJ5  , PRK5,&
 & PRMUE5 , PTAUAZ5, PTRA15, PTRA25,&
! saved in NL coputation - swr
 & PRE15  , PRE25  , PTR15 , PTR25 ,&
! perturbation
 & PALBD  , PCG    , PCLD  , POMEGA , PSEC  , PTAU,&
 & PCGAZ  , PPIZAZ , PRAY1 , PRAY2  , PREFZ , PRJ   , PRK,&
 & PRMUE  , PTAUAZ , PTRA1 , PTRA2 &
 & )  

!**** *SWRAD* - CONTINUUM SCATTERING COMPUTATIONS
!               -> ADJOINT <-

!     PURPOSE.
!     --------
!           COMPUTES THE REFLECTIVITY AND TRANSMISSIVITY IN CASE OF
!     CONTINUUM SCATTERING

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

!          *SWRAD* IS CALLED EITHER FROM *SW1SAD*, *SWNIAD*

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

!     ==== INPUTS ===
!     ==== OUTPUTS ===

!     METHOD.
!     -------

!          1. COMPUTES CONTINUUM FLUXES CORRESPONDING TO AEROSOL
!     OR/AND RAYLEIGH SCATTERING (NO MOLECULAR GAS ABSORPTION)

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

!          *SWDE*
!          *SWDEAD*

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

!        SEE RADIATION'S PART OF THE ECMWF RESEARCH DEPARTMENT
!        DOCUMENTATION, AND FOUQUART AND BONNEL (1980)

!     AUTHOR.
!     -------
!        JEAN-JACQUES MORCRETTE  *ECMWF*

!     MODIFICATIONS.
!     --------------
!        ORIGINAL : 96-10-22
!        Modified : 99-05-11 M.Janiskova - code corrections
!        Modified : 2002-05-07 M.Janiskova - 6 spectral intervals and
!                                            additional overlap assumption
!        03-10-10 Deborah Salmond and Marta Janiskova Optimisation
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        08-03-27 M.Janiskova - code optimization and cleaning
!     ------------------------------------------------------------------

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

USE YOERAD   , ONLY : NOVLP    ,NSW
USE YOECLD   , ONLY : REPSEC
USE YOEOVLP  , ONLY : RA1OVLP
USE YOPHNC   , ONLY : LWSOPT

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)    :: KNU 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PALBD5(KLON,NSW) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCG5(KLON,NSW,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCLD5(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POMEGA5(KLON,NSW,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PSEC5(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAU5(KLON,NSW,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCGAZ5(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PPIZAZ5(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PRAY15(KLON,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PRAY25(KLON,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PREFZ5(KLON,2,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PRJ5(KLON,6,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PRK5(KLON,6,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PRMUE5(KLON,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAUAZ5(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTRA15(KLON,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTRA25(KLON,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PALBD(KLON,NSW) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PCG(KLON,NSW,KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PCLD(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: POMEGA(KLON,NSW,KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PSEC(KLON) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PTAU(KLON,NSW,KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PCGAZ(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PPIZAZ(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PRAY1(KLON,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PRAY2(KLON,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PREFZ(KLON,2,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PRJ(KLON,6,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PRK(KLON,6,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PRMUE(KLON,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PTAUAZ(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PTRA1(KLON,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PTRA2(KLON,KLEV+1) 
! saved in NL coputation - swr
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PRE15(KLON,KLEV)
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PRE25(KLON,KLEV)
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PTR15(KLON,KLEV)
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PTR25(KLON,KLEV)
!     ------------------------------------------------------------------

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

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

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

REAL(KIND=JPRB) :: ZC1I5(KLON,KLEV+1)&
 & ,  ZCLEAR5(KLON,KLEV+1)  , ZCLOUD5(KLON,KLEV+1) &
 & ,  ZR215(KLON,KLEV)      , ZR225(KLON,KLEV)&
 & ,  ZRA215(KLON,KLEV)     , ZRA225(KLON,KLEV)&
 & ,  ZSS15(KLON,KLEV)&
 & ,  ZTR5(KLON,2,KLEV+1)

! extra fields needed by adjoint computations
REAL(KIND=JPRB) :: ZRE115(KLON,2,KLEV+1)&
 & ,  ZDEN5(KLON,KLEV)      , ZDEN15(KLON,KLEV)&
 & ,  ZDENO5(KLON,KLEV)     , ZNUME5(KLON,KLEV) &
 & ,  ZCHKAE5(KLON,KLEV)    , ZCHKCD5(KLON,KLEV) &
 & ,  ZGG5(KLON,KLEV)       , ZMUE5(KLON,KLEV+1)&
 & ,  ZTO15(KLON,KLEV)      , ZW5(KLON,KLEV)&
 & ,  ZBMU05(KLON,KLEV)     , ZBMU15(KLON,KLEV)&
 & ,  ZFACOA5(KLON,KLEV)    , ZFACOC5(KLON,KLEV)&
 & ,  ZCORAE5(KLON,KLEV)    , ZCORCD5(KLON,KLEV)&
 & ,  ZRR5(KLON,KLEV) 
REAL(KIND=JPRB) :: ZICLEAR5(KLON,KLEV+1)
REAL(KIND=JPRB) :: ZDIV15(KLON,KLEV), ZDIV25(KLON,KLEV)&
 & ,  ZDIV35(KLON,KLEV), ZDIV45(KLON,KLEV)

REAL(KIND=JPRB) :: ZC1I(KLON,KLEV+1)&
 & ,  ZCLEAR(KLON)          , ZCLOUD(KLON) &
 & ,  ZDENO(KLON)           , ZNUME(KLON)&
 & ,  ZGG(KLON)             , ZREF(KLON)&
 & ,  ZRE1(KLON)            , ZRE2(KLON)&
 & ,  ZRMUZ(KLON)           &
 & ,  ZR21(KLON)            , ZR22(KLON)&
 & ,  ZSS1(KLON)&
 & ,  ZTO1(KLON)            , ZTR(KLON,2,KLEV+1)&
 & ,  ZTR1(KLON)            , ZTR2(KLON)&
 & ,  ZW(KLON)  

INTEGER(KIND=JPIM) :: IKL, IKLP1, IKM1, JA, JAJ, JK, JL, INU1

REAL(KIND=JPRB) :: ZBMU0, ZBMU1, ZCORAE, ZCORCD, ZDEN, ZDEN1,&
 & ZFACOA, ZFACOC, &
 & ZMUE, ZRE11, &
 & ZALPHA1, ZCHKAE, ZCHKCD  
REAL(KIND=JPRB) :: ZRR
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "swde.intfb.h"
#include "swdead.intfb.h"

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

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

! 100 CONTINUE

IF (LHOOK) CALL DR_HOOK('SWRAD',0,ZHOOK_HANDLE)
DO JK = 1 , KLEV+1
  DO JA = 1 , 6
    DO JL = KIDIA,KFDIA
      PRJ5(JL,JA,JK) = 0.0_JPRB
      PRK5(JL,JA,JK) = 0.0_JPRB
    ENDDO
  ENDDO
ENDDO

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

!*         2.    TOTAL EFFECTIVE CLOUDINESS ABOVE A GIVEN LEVEL
!                ----------------------------------------------

! 200 CONTINUE

DO JL = KIDIA,KFDIA
  ZC1I5(JL,KLEV+1)   = 0.0_JPRB
  ZCLEAR5(JL,KLEV+1) = 1.0_JPRB
  ZCLOUD5(JL,KLEV+1) = 0.0_JPRB
ENDDO

DO JK = 1 , KLEV
  IKL = KLEV+1 - JK
  IKLP1 = IKL + 1
  ZALPHA1=RA1OVLP( IKL )
  DO JL = KIDIA,KFDIA
    ZFACOA5(JL,IKL) = 1.0_JPRB - PPIZAZ5(JL,IKL)*PCGAZ5(JL,IKL)**2
    ZFACOC5(JL,IKL) = 1.0_JPRB - POMEGA5(JL,KNU,IKL) * PCG5(JL,KNU,IKL)&
     & * PCG5(JL,KNU,IKL)  
    ZCORAE5(JL,IKL) = ZFACOA5(JL,IKL) * PTAUAZ5(JL,IKL) * PSEC5(JL)
    ZCORCD5(JL,IKL) = ZFACOC5(JL,IKL) * PTAU5(JL,KNU,IKL) * PSEC5(JL)
    IF (ZCORAE5(JL,IKL) <= 200._JPRB) THEN
      ZCHKAE5(JL,IKL) =  ZCORAE5(JL,IKL)
    ELSE
      ZCHKAE5(JL,IKL) =  200._JPRB
    ENDIF
    IF (ZCORCD5(JL,IKL) <= 200._JPRB) THEN
      ZCHKCD5(JL,IKL) = ZCORCD5(JL,IKL)
    ELSE
      ZCHKCD5(JL,IKL) = 200._JPRB
    ENDIF    
    ZRA215(JL,IKL) = EXP(-ZCHKAE5(JL,IKL) )
    ZRA225(JL,IKL) = EXP(-ZCHKCD5(JL,IKL) )
    ZSS15(JL,IKL) = PCLD5(JL,IKL)*(1.0_JPRB-ZRA215(JL,IKL)&
     & * ZRA225(JL,IKL))&
     & + (1.0_JPRB-PCLD5(JL,IKL))*(1.0_JPRB-ZRA215(JL,IKL))  

    IF (NOVLP == 1) THEN
!* maximum-random      
      IF (ZSS15(JL,IKL) >= ZCLOUD5(JL,IKLP1)) THEN
        ZNUME5(JL,IKL)= ZSS15(JL,IKL)
      ELSE
        ZNUME5(JL,IKL)= ZCLOUD5(JL,IKLP1)
      ENDIF
      IF (ZCLOUD5(JL,IKLP1) <= 1.0_JPRB-REPSEC) THEN
        ZDENO5(JL,IKL)= ZCLOUD5(JL,IKLP1)
      ELSE
        ZDENO5(JL,IKL)= 1.0_JPRB-REPSEC
      ENDIF
      ZICLEAR5(JL,IKL) = 1.0_JPRB/(1.0_JPRB-ZDENO5(JL,IKL))
      ZCLEAR5(JL,IKL)= ZCLEAR5(JL,IKLP1)&
       & * (1.0_JPRB-ZNUME5(JL,IKL))*ZICLEAR5(JL,IKL)  
      ZC1I5(JL,IKL) = 1.0_JPRB - ZCLEAR5(JL,IKL)
      ZCLOUD5(JL,IKL) = ZSS15(JL,IKL)
    ELSEIF (NOVLP == 2) THEN
!* maximum
      IF (ZSS15(JL,IKL) >= ZCLOUD5(JL,IKLP1)) THEN
        ZCLOUD5(JL,IKL) =  ZSS15(JL,IKL)
      ELSE
        ZCLOUD5(JL,IKL) =  ZCLOUD5(JL,IKLP1)
      ENDIF
      ZC1I5(JL,IKL) = ZCLOUD5(JL,IKL)
    ELSEIF (NOVLP == 3) THEN
!* random
      ZCLEAR5(JL,IKL) = ZCLEAR5(JL,IKLP1)*(1.0_JPRB - ZSS15(JL,IKL))
      ZCLOUD5(JL,IKL) = 1.0_JPRB - ZCLEAR5(JL,IKL)
      ZC1I5(JL,IKL) = ZCLOUD5(JL,IKL)
    ELSEIF (NOVLP == 4) THEN
!* Hogan & Illingworth (2001)
      IF (ZSS15(JL,IKL) >= ZCLOUD5(JL,IKLP1)) THEN
        ZNUME5(JL,IKL) = ZSS15(JL,IKL)
      ELSE
        ZNUME5(JL,IKL) = ZCLOUD5(JL,IKLP1)
      ENDIF
      IF (ZCLOUD5(JL,IKLP1) <= 1.0_JPRB-REPSEC) THEN
        ZDENO5(JL,IKL) = ZCLOUD5(JL,IKLP1)
      ELSE
        ZDENO5(JL,IKL) = 1.0_JPRB-REPSEC
      ENDIF
      ZICLEAR5(JL,IKL) = 1.0_JPRB/(1.0_JPRB-ZDENO5(JL,IKL))
      ZCLEAR5(JL,IKL)=ZCLEAR5(JL,IKLP1) &
       & * (ZALPHA1*(1.0_JPRB-ZNUME5(JL,IKL))*ZICLEAR5(JL,IKL) &
       & + (1.0_JPRB-ZALPHA1)*(1.0_JPRB-ZSS15(JL,IKL)) )  
       
      ZC1I5(JL,IKL) = 1.0_JPRB - ZCLEAR5(JL,IKL)
      ZCLOUD5(JL,IKL) = ZSS15(JL,IKL)
    ENDIF
  ENDDO
ENDDO

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

!*         3.    REFLECTIVITY/TRANSMISSIVITY FOR PURE SCATTERING
!                -----------------------------------------------

! 300 CONTINUE

DO JL = KIDIA,KFDIA
  PRAY15(JL,KLEV+1) = 0.0_JPRB
  PRAY25(JL,KLEV+1) = 0.0_JPRB
  PREFZ5(JL,2,1) = PALBD5(JL,KNU)
  PREFZ5(JL,1,1) = PALBD5(JL,KNU)
  PTRA15(JL,KLEV+1) = 1.0_JPRB
  PTRA25(JL,KLEV+1) = 1.0_JPRB
ENDDO

DO JK = 2 , KLEV+1
  IKM1 = JK-1
  DO JL = KIDIA,KFDIA

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

!*         3.1  EQUIVALENT ZENITH ANGLE
!               -----------------------

! 310 CONTINUE

    ZMUE5(JL,JK) = (1.0_JPRB-ZC1I5(JL,JK))*PSEC5(JL)+ZC1I5(JL,JK)*1.66_JPRB
    PRMUE5(JL,JK) = 1.0_JPRB/ZMUE5(JL,JK)

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

!*         3.2  REFLECT./TRANSMISSIVITY DUE TO RAYLEIGH AND AEROSOLS
!               ----------------------------------------------------

! 320 CONTINUE

    ZBMU05(JL,IKM1) = 0.5_JPRB - 0.75_JPRB * PCGAZ5(JL,IKM1) *PRMUE5(JL,JK)

    ZDEN5(JL,IKM1) = (1.0_JPRB &
     & + (1.0_JPRB-PPIZAZ5(JL,IKM1) + ZBMU05(JL,IKM1) * PPIZAZ5(JL,IKM1)) &
     & * PTAUAZ5(JL,IKM1) * ZMUE5(JL,JK) &
     & + (1-PPIZAZ5(JL,IKM1)) * (1.0_JPRB - PPIZAZ5(JL,IKM1)&
     & + 2.0_JPRB*ZBMU05(JL,IKM1)*PPIZAZ5(JL,IKM1))*PTAUAZ5(JL,IKM1)**2 &
     & * ZMUE5(JL,JK)** 2) 
    PTRA15(JL,IKM1) = 1.0_JPRB/ZDEN5(JL,IKM1)
    PRAY15(JL,IKM1) = ZBMU05(JL,IKM1) * PPIZAZ5(JL,IKM1)&
     & * PTAUAZ5(JL,IKM1) * ZMUE5(JL,JK) *PTRA15(JL,IKM1)  

    ZBMU15(JL,IKM1) = 0.5_JPRB - 0.75_JPRB * PCGAZ5(JL,IKM1) * 0.5_JPRB
    ZDEN15(JL,IKM1)= (1.0_JPRB &
     & + (1.0_JPRB-PPIZAZ5(JL,IKM1) + ZBMU15(JL,IKM1) * PPIZAZ5(JL,IKM1)) &
     & * PTAUAZ5(JL,IKM1) * 2.0_JPRB &
     & + (1-PPIZAZ5(JL,IKM1))* (1.0_JPRB-PPIZAZ5(JL,IKM1) &
     & + 2.0_JPRB*ZBMU15(JL,IKM1)*PPIZAZ5(JL,IKM1))*PTAUAZ5(JL,IKM1)**2 &
     & * 4.0_JPRB)  
    PTRA25(JL,IKM1) = 1.0_JPRB/ZDEN15(JL,IKM1)
    PRAY25(JL,IKM1) = ZBMU15(JL,IKM1) * PPIZAZ5(JL,IKM1)&
     & * PTAUAZ5(JL,IKM1) * 2.0_JPRB * PTRA25(JL,IKM1)

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

!*         3.3  EFFECT OF CLOUD LAYER
!               ---------------------

! 330 CONTINUE

    ZDIV15(JL,IKM1) = 1.0_JPRB/POMEGA5(JL,KNU,IKM1)
    ZDIV25(JL,IKM1) = 1.0_JPRB/PPIZAZ5(JL,IKM1)
    ZTO15(JL,IKM1) = PTAU5(JL,KNU,IKM1)*ZDIV15(JL,IKM1) &
     & + PTAUAZ5(JL,IKM1)*ZDIV25(JL,IKM1)
    ZR215(JL,IKM1) = PTAU5(JL,KNU,IKM1) + PTAUAZ5(JL,IKM1)
    ZDIV35(JL,IKM1) = 1.0_JPRB/ZR215(JL,IKM1)
    ZR225(JL,IKM1) = PTAU5(JL,KNU,IKM1) * ZDIV35(JL,IKM1)
    ZGG5(JL,IKM1)  = ZR225(JL,IKM1) * PCG5(JL,KNU,IKM1)&
     & + (1.0_JPRB - ZR225(JL,IKM1)) * PCGAZ5(JL,IKM1)  
    IF (POMEGA5(JL,KNU,IKM1)==1.0_JPRB .AND. PPIZAZ5(JL,IKM1)==1.0_JPRB) THEN
      ZW5(JL,IKM1)=1.0_JPRB
    ELSE
      ZDIV45(JL,IKM1) = 1.0_JPRB/ZTO15(JL,IKM1)
      ZW5(JL,IKM1) = ZR215(JL,IKM1) * ZDIV45(JL,IKM1)
    ENDIF
  ENDDO

  IF (.NOT. LWSOPT) THEN
    CALL SWDE &
     & ( KIDIA, KFDIA , KLON,&
     & ZGG5(1,IKM1), PREFZ5(1,1,IKM1), PRMUE5(1,JK), &
     & ZTO15(1,IKM1), ZW5(1,IKM1), &
     & PRE15(1,IKM1), PRE25(1,IKM1), PTR15(1,IKM1), PTR25(1,IKM1) &
     & )  
  ENDIF

  DO JL = KIDIA,KFDIA
    ZRR5(JL,IKM1) =1.0_JPRB/(1.0_JPRB-PRAY25(JL,IKM1)*PREFZ5(JL,1,IKM1))

    PREFZ5(JL,1,JK) = PCLD5(JL,IKM1) * PRE25(JL,IKM1)&
     & +(PRAY15(JL,IKM1) + PREFZ5(JL,1,IKM1) * PTRA15(JL,IKM1)&
     & * PTRA25(JL,IKM1) * ZRR5(JL,IKM1)) * (1.0_JPRB-PCLD5(JL,IKM1))  

    ZTR5(JL,1,IKM1) = PCLD5(JL,IKM1) * PTR25(JL,IKM1) &
     & + PTRA15(JL,IKM1)* ZRR5(JL,IKM1) * (1.0_JPRB-PCLD5(JL,IKM1))  

    PREFZ5(JL,2,JK) = (1.0_JPRB-PCLD5(JL,IKM1)) * (PRAY15(JL,IKM1)&
     & + PREFZ5(JL,2,IKM1) * PTRA15(JL,IKM1) * PTRA25(JL,IKM1) )&
     & + PCLD5(JL,IKM1) * PRE15(JL,IKM1)  

    ZTR5(JL,2,IKM1) = PCLD5(JL,IKM1) * PTR15(JL,IKM1)&
     & + PTRA15(JL,IKM1) * (1.0_JPRB-PCLD5(JL,IKM1))  

  ENDDO
ENDDO
DO JL = KIDIA,KFDIA
  ZMUE5(JL,1) = (1.0_JPRB-ZC1I5(JL,1))*PSEC5(JL)+ZC1I5(JL,1)*1.66_JPRB
  PRMUE5(JL,1)=1.0_JPRB/ZMUE5(JL,1)
ENDDO

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

!*         3.5    REFLECT./TRANSMISSIVITY BETWEEN SURFACE AND LEVEL
!                 -------------------------------------------------

! 350 CONTINUE

IF (NSW <= 4) THEN
  INU1=1
ELSEIF (NSW == 6) THEN
  INU1=3
ENDIF

IF (KNU <= INU1) THEN
  JAJ = 2
  DO JL = KIDIA,KFDIA
    PRJ5(JL,JAJ,KLEV+1) = 1.0_JPRB
    PRK5(JL,JAJ,KLEV+1) = PREFZ5(JL, 1,KLEV+1)
  ENDDO

  DO JK = 1 , KLEV
    IKL = KLEV+1 - JK
    IKLP1 = IKL + 1
    DO JL = KIDIA,KFDIA
      ZRE115(JL,JAJ,IKL) = PRJ5(JL,JAJ,IKLP1) * ZTR5(JL, 1,IKL)
      PRJ5(JL,JAJ,IKL)   = ZRE115(JL,JAJ,IKL)
      PRK5(JL,JAJ,IKL)   = ZRE115(JL,JAJ,IKL) * PREFZ5(JL, 1,IKL)
    ENDDO
  ENDDO

ELSE

  DO JAJ = 1 , 2
    DO JL = KIDIA,KFDIA
      PRJ5(JL,JAJ,KLEV+1) = 1.0_JPRB
      PRK5(JL,JAJ,KLEV+1) = PREFZ5(JL,JAJ,KLEV+1)
    ENDDO

    DO JK = 1 , KLEV
      IKL = KLEV+1 - JK
      IKLP1 = IKL + 1
      DO JL = KIDIA,KFDIA
        ZRE115(JL,JAJ,IKL) = PRJ5(JL,JAJ,IKLP1) * ZTR5(JL,JAJ,IKL)
        PRJ5(JL,JAJ,IKL)   = ZRE115(JL,JAJ,IKL)
        PRK5(JL,JAJ,IKL)   = ZRE115(JL,JAJ,IKL) * PREFZ5(JL,JAJ,IKL)
      ENDDO
    ENDDO
  ENDDO

ENDIF

!     ==================================================================

!*         10.     ADJOINT CALCULATIONS
!                  --------------------

ZC1I(:,:)   = 0.0_JPRB
ZTR(:,:,:)  = 0.0_JPRB

IF (KNU <= INU1) THEN

  JAJ=2
  DO JK=KLEV,1,-1
    IKL=KLEV+1-JK
    IKLP1=IKL+1
    DO JL=KIDIA,KFDIA
!------      
      ZRE11 = 0.0_JPRB

      ZRE11 = ZRE11 + PRK(JL,JAJ,IKL) * PREFZ5(JL,1,IKL)
      PREFZ(JL,1,IKL) = PREFZ(JL,1,IKL)&
       & + PRK(JL,JAJ,IKL) * ZRE115(JL,JAJ,IKL)  
      PRK(JL,JAJ,IKL) = 0.0_JPRB

      ZRE11 = ZRE11 + PRJ(JL,JAJ,IKL)
      PRJ(JL,JAJ,IKL) = 0.0_JPRB

      PRJ(JL,JAJ,IKLP1) = PRJ(JL,JAJ,IKLP1) + ZRE11 * ZTR5(JL,1,IKL)
      ZTR(JL,1,IKL) = ZTR(JL,1,IKL) + ZRE11 * PRJ5(JL,JAJ,IKLP1)
!      ZRE11 = 0.0_JPRB
    ENDDO
  ENDDO

  DO JL=KIDIA,KFDIA
    PREFZ(JL,1,KLEV+1) = PREFZ(JL,1,KLEV+1) + PRK(JL,JAJ,KLEV+1)
    PRK(JL,JAJ,KLEV+1) = 0.0_JPRB
    PRJ(JL,JAJ,KLEV+1) = 0.0_JPRB
  ENDDO

ELSE

  DO JAJ=1,2

    DO JK=KLEV,1,-1
      IKL=KLEV+1-JK
      IKLP1=IKL+1
      DO JL=KIDIA,KFDIA
!------      
        ZRE11 = 0.0_JPRB

        ZRE11 = ZRE11 + PRK(JL,JAJ,IKL) * PREFZ5(JL,JAJ,IKL)
        PREFZ(JL,JAJ,IKL) = PREFZ(JL,JAJ,IKL)&
         & + PRK(JL,JAJ,IKL) * ZRE115(JL,JAJ,IKL)  
        PRK(JL,JAJ,IKL) = 0.0_JPRB

        ZRE11 = ZRE11 + PRJ(JL,JAJ,IKL)
        PRJ(JL,JAJ,IKL) = 0.0_JPRB

        PRJ(JL,JAJ,IKLP1) = PRJ(JL,JAJ,IKLP1) + ZRE11 * ZTR5(JL,JAJ,IKL)
        ZTR(JL,JAJ,IKL) = ZTR(JL,JAJ,IKL) + ZRE11 * PRJ5(JL,JAJ,IKLP1)
!        ZRE11 = 0.0_JPRB
      ENDDO
    ENDDO

    DO JL=KIDIA,KFDIA
      PREFZ(JL,JAJ,KLEV+1) = PREFZ(JL,JAJ,KLEV+1) + PRK(JL,JAJ,KLEV+1)
      PRK(JL,JAJ,KLEV+1) = 0.0_JPRB
      PRJ(JL,JAJ,KLEV+1) = 0.0_JPRB
    ENDDO

  ENDDO

ENDIF

!1350 CONTINUE

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

DO JL=KIDIA,KFDIA
!------      
  ZMUE = 0.0_JPRB

  ZMUE = ZMUE - PRMUE(JL,1)*PRMUE5(JL,1)**2
  PRMUE(JL,1) = 0.0_JPRB

  ZC1I(JL,1) = ZC1I(JL,1) - ZMUE * PSEC5(JL)
  PSEC(JL) = PSEC(JL) + ZMUE *(1.0_JPRB-ZC1I5(JL,1))
  ZC1I(JL,1) = ZC1I(JL,1) + ZMUE*1.66_JPRB
!  ZMUE = 0.0_JPRB
ENDDO

ZRE1(:)  = 0.0_JPRB
ZRE2(:)  = 0.0_JPRB
ZTR1(:)  = 0.0_JPRB
ZTR2(:)  = 0.0_JPRB
ZREF(:)  = 0.0_JPRB
ZRMUZ(:) = 0.0_JPRB
ZW(:)    = 0.0_JPRB
ZGG(:)   = 0.0_JPRB
ZTO1(:)  = 0.0_JPRB
ZR21(:)  = 0.0_JPRB
ZR22(:)  = 0.0_JPRB

DO JK=KLEV+1,2,-1
  IKM1=JK-1

  DO JL=KIDIA,KFDIA
    ZRR=0.0_JPRB

    PCLD(JL,IKM1) = PCLD(JL,IKM1) + ZTR(JL,2,IKM1) *PTR15(JL,IKM1)
    ZTR1(JL)  = ZTR1(JL)  + ZTR(JL,2,IKM1) *PCLD5(JL,IKM1)
    PTRA1(JL,IKM1) = PTRA1(JL,IKM1) + ZTR(JL,2,IKM1) &
     & *(1.0_JPRB-PCLD5(JL,IKM1))
    PCLD(JL,IKM1) = PCLD(JL,IKM1) - ZTR(JL,2,IKM1) * PTRA15(JL,IKM1)
    ZTR(JL,2,IKM1) = 0.0_JPRB

    PCLD(JL,IKM1) = PCLD(JL,IKM1) - PREFZ(JL,2,JK) * (PRAY15(JL,IKM1)&
     & + PREFZ5(JL,2,IKM1)*PTRA15(JL,IKM1)*PTRA25(JL,IKM1))  
    PRAY1(JL,IKM1) = PRAY1(JL,IKM1) + PREFZ(JL,2,JK) &
     & *(1.0_JPRB-PCLD5(JL,IKM1))
    PREFZ(JL,2,IKM1) = PREFZ(JL,2,IKM1) + PREFZ(JL,2,JK)&
     & *(1.0_JPRB-PCLD5(JL,IKM1))*PTRA15(JL,IKM1)*PTRA25(JL,IKM1)   
    PTRA1(JL,IKM1) = PTRA1(JL,IKM1) + PREFZ(JL,2,JK)&
     & *(1.0_JPRB-PCLD5(JL,IKM1))*PREFZ5(JL,2,IKM1)*PTRA25(JL,IKM1)   
    PTRA2(JL,IKM1) = PTRA2(JL,IKM1) + PREFZ(JL,2,JK)&
     & *(1.0_JPRB-PCLD5(JL,IKM1))*PREFZ5(JL,2,IKM1)*PTRA15(JL,IKM1)  
    PCLD(JL,IKM1)      = PCLD(JL,IKM1) + PREFZ(JL,2,JK)*PRE15(JL,IKM1)
    ZRE1(JL)       = ZRE1(JL) + PREFZ(JL,2,JK) *PCLD5(JL,IKM1)
    PREFZ(JL,2,JK) = 0.0_JPRB

    PCLD(JL,IKM1) = PCLD(JL,IKM1) + ZTR(JL,1,IKM1) * PTR25(JL,IKM1)
    ZTR2(JL)  = ZTR2(JL)  + ZTR(JL,1,IKM1) * PCLD5(JL,IKM1)
    ZRR=ZRR+ZTR(JL,1,IKM1) *PTRA15(JL,IKM1)*(1.0_JPRB-PCLD5(JL,IKM1))
    PTRA1(JL,IKM1) = PTRA1(JL,IKM1) + ZTR(JL,1,IKM1)&
     & *(1.0_JPRB-PCLD5(JL,IKM1))*ZRR5(JL,IKM1)  
    PCLD(JL,IKM1)      = PCLD(JL,IKM1) - ZTR(JL,1,IKM1) *PTRA15(JL,IKM1)&
     & *ZRR5(JL,IKM1)  
    ZTR(JL,1,IKM1) = 0.0_JPRB

    PCLD(JL,IKM1) = PCLD(JL,IKM1) + PREFZ(JL,1,JK) *PRE25(JL,IKM1)
    ZRE2(JL)  = ZRE2(JL) + PREFZ(JL,1,JK) *PCLD5(JL,IKM1)
    ZRR=ZRR+PREFZ(JL,1,JK)*PREFZ5(JL,1,IKM1)*PTRA15(JL,IKM1)*PTRA25(JL,IKM1)* &
     & (1.0_JPRB-PCLD5(JL,IKM1))  
    PCLD(JL,IKM1) = PCLD(JL,IKM1) - PREFZ(JL,1,JK) *(PRAY15(JL,IKM1)&
     & + PREFZ5(JL,1,IKM1)*PTRA15(JL,IKM1)*PTRA25(JL,IKM1)&
     & *ZRR5(JL,IKM1))  
    PRAY1(JL,IKM1) = PRAY1(JL,IKM1) + PREFZ(JL,1,JK)&
     & *(1.0_JPRB-PCLD5(JL,IKM1))  
    PREFZ(JL,1,IKM1) = PREFZ(JL,1,IKM1)&
     & + PREFZ(JL,1,JK) * PTRA15(JL,IKM1)*PTRA25(JL,IKM1) &
     & *ZRR5(JL,IKM1)&
     & *(1.0_JPRB-PCLD5(JL,IKM1))  
    PTRA1(JL,IKM1) = PTRA1(JL,IKM1)&
     & + PREFZ(JL,1,JK) * PREFZ5(JL,1,IKM1)*PTRA25(JL,IKM1)       &
     & *ZRR5(JL,IKM1)&
     & *(1.0_JPRB-PCLD5(JL,IKM1))  
    PTRA2(JL,IKM1) = PTRA2(JL,IKM1)&
     & + PREFZ(JL,1,JK) * PREFZ5(JL,1,IKM1)*PTRA15(JL,IKM1)&
     & *ZRR5(JL,IKM1)&
     & *(1.0_JPRB-PCLD5(JL,IKM1))  

    PRAY2(JL,IKM1) = PRAY2(JL,IKM1) + ZRR*PREFZ5(JL,1,IKM1)*ZRR5(JL,IKM1)**2
    PREFZ(JL,1,IKM1) = PREFZ(JL,1,IKM1) +ZRR*PRAY25(JL,IKM1)*ZRR5(JL,IKM1)**2

    PREFZ(JL,1,JK) = 0.0_JPRB
  ENDDO

  CALL SWDEAD &
   & ( KIDIA, KFDIA , KLON,&
   & ZGG5(1,IKM1), PREFZ5(1,1,IKM1), PRMUE5(1,JK), &
   & ZTO15(1,IKM1), ZW5(1,IKM1),&
   & PRE15(1,IKM1), PRE25(1,IKM1), PTR15(1,IKM1), PTR25(1,IKM1),&
   & ZGG   , ZREF   , ZRMUZ  , ZTO1  , ZW,&
   & ZRE1  , ZRE2   , ZTR1   , ZTR2 &
   & )  

  DO JL=KIDIA,KFDIA
    PRMUE(JL,JK) = PRMUE(JL,JK) + ZRMUZ(JL)
    ZRMUZ(JL)    = 0.0_JPRB

    PREFZ(JL,1,IKM1) = PREFZ(JL,1,IKM1) + ZREF(JL)
    ZREF(JL) = 0.0_JPRB

    IF (POMEGA5(JL,KNU,IKM1)/=1.0_JPRB .AND. PPIZAZ5(JL,IKM1)/=1.0_JPRB) THEN
      ZR21(JL) = ZR21(JL) + ZW(JL)*ZDIV45(JL,IKM1)
      ZTO1(JL) = ZTO1(JL) - ZW(JL) *ZR215(JL,IKM1)*(ZDIV45(JL,IKM1)**2)
    ENDIF
    ZW(JL)  = 0.0_JPRB

    ZR22(JL) = ZR22(JL) + ZGG(JL) *PCG5(JL,KNU,IKM1)
    PCG(JL,KNU,IKM1) = PCG(JL,KNU,IKM1) + ZGG(JL) *ZR225(JL,IKM1)
    ZR22(JL) = ZR22(JL) - ZGG(JL) *PCGAZ5(JL,IKM1)
    PCGAZ(JL,IKM1) = PCGAZ(JL,IKM1) + ZGG(JL) *(1.0_JPRB-ZR225(JL,IKM1))
    ZGG(JL) = 0.0_JPRB

    PTAU(JL,KNU,IKM1) = PTAU(JL,KNU,IKM1) + ZR22(JL) * ZDIV35(JL,IKM1)
    ZR21(JL) = ZR21(JL) - ZR22(JL)*PTAU5(JL,KNU,IKM1)*(ZDIV35(JL,IKM1)**2)
    ZR22(JL) = 0.0_JPRB

    PTAU(JL,KNU,IKM1) = PTAU(JL,KNU,IKM1) + ZR21(JL)
    PTAUAZ(JL,IKM1)   = PTAUAZ(JL,IKM1) + ZR21(JL)
    ZR21(JL) = 0.0_JPRB

    PTAU(JL,KNU,IKM1) = PTAU(JL,KNU,IKM1) + ZTO1(JL)*ZDIV15(JL,IKM1)
    POMEGA(JL,KNU,IKM1) = POMEGA(JL,KNU,IKM1) &
     & - ZTO1(JL) *PTAU5(JL,KNU,IKM1)*(ZDIV15(JL,IKM1)**2)
    PTAUAZ(JL,IKM1) = PTAUAZ(JL,IKM1) + ZTO1(JL)*ZDIV25(JL,IKM1)
    PPIZAZ(JL,IKM1) = PPIZAZ(JL,IKM1)&
     & - ZTO1(JL) *PTAUAZ5(JL,IKM1)*(ZDIV25(JL,IKM1)**2)  
    ZTO1(JL) = 0.0_JPRB

!1330 CONTINUE

!------
    ZDEN1 = 0.0_JPRB
    ZBMU1 = 0.0_JPRB
    ZDEN  = 0.0_JPRB
    ZBMU0 = 0.0_JPRB
    ZMUE  = 0.0_JPRB

    ZBMU1 = ZBMU1 + PRAY2(JL,IKM1) *PPIZAZ5(JL,IKM1)&
     & *PTAUAZ5(JL,IKM1)* 2.0_JPRB*PTRA25(JL,IKM1)  
    PPIZAZ(JL,IKM1)   = PPIZAZ(JL,IKM1)   + PRAY2(JL,IKM1) *ZBMU15(JL,IKM1)&
     & *PTAUAZ5(JL,IKM1) * 2.0_JPRB*PTRA25(JL,IKM1)  
    PTAUAZ(JL,IKM1)   = PTAUAZ(JL,IKM1)   + PRAY2(JL,IKM1) *ZBMU15(JL,IKM1)&
     & *PPIZAZ5(JL,IKM1) * 2.0_JPRB*PTRA25(JL,IKM1)  
    PTRA2(JL,IKM1)=PTRA2(JL,IKM1)+PRAY2(JL,IKM1)*0.5_JPRB* 4.0_JPRB &
     & * ZBMU15(JL,IKM1)*PPIZAZ5(JL,IKM1)*PTAUAZ5(JL,IKM1)
    PRAY2(JL,IKM1) = 0.0_JPRB

    ZDEN1 = ZDEN1-PTRA2(JL,IKM1)*(PTRA25(JL,IKM1)**2)
    PTRA2(JL,IKM1) = 0.0_JPRB

    PPIZAZ(JL,IKM1)  = PPIZAZ(JL,IKM1) - ZDEN1 *PTAUAZ5(JL,IKM1)*2.0_JPRB
    ZBMU1 = ZBMU1 + ZDEN1 *PPIZAZ5(JL,IKM1)*PTAUAZ5(JL,IKM1)*2.0_JPRB
    PPIZAZ(JL,IKM1)  = PPIZAZ(JL,IKM1) &
     & + ZDEN1 *ZBMU15(JL,IKM1)*PTAUAZ5(JL,IKM1)*2.0_JPRB
    PTAUAZ(JL,IKM1)  = PTAUAZ(JL,IKM1) + ZDEN1*2.0_JPRB &
     & *(1.0_JPRB-PPIZAZ5(JL,IKM1)+ZBMU15(JL,IKM1)*PPIZAZ5(JL,IKM1))  
    PPIZAZ(JL,IKM1)  = PPIZAZ(JL,IKM1) - ZDEN1 &
     & *(1.0_JPRB-PPIZAZ5(JL,IKM1)+2.0_JPRB*ZBMU15(JL,IKM1)*PPIZAZ5(JL,IKM1))&
     & *(PTAUAZ5(JL,IKM1)**2)*4.0_JPRB  
    PPIZAZ(JL,IKM1)  = PPIZAZ(JL,IKM1) - ZDEN1 *(1.0_JPRB-PPIZAZ5(JL,IKM1))&
     & *(PTAUAZ5(JL,IKM1)**2)*4.0_JPRB  
    ZBMU1 = ZBMU1 + ZDEN1 *(1.0_JPRB-PPIZAZ5(JL,IKM1))*2.0_JPRB &
     & *PPIZAZ5(JL,IKM1)&
     & *(PTAUAZ5(JL,IKM1)**2)*4.0_JPRB  
    PPIZAZ(JL,IKM1)  = PPIZAZ(JL,IKM1) &
     & + ZDEN1 *(1.0_JPRB-PPIZAZ5(JL,IKM1))*2.0_JPRB*ZBMU15(JL,IKM1)&
     & *(PTAUAZ5(JL,IKM1)**2)*4.0_JPRB  
    PTAUAZ(JL,IKM1)  = PTAUAZ(JL,IKM1) &
     & + ZDEN1 *(1.0_JPRB-PPIZAZ5(JL,IKM1))*2.0_JPRB *PTAUAZ5(JL,IKM1)       &
     & *(1.0_JPRB-PPIZAZ5(JL,IKM1)+2.0_JPRB*ZBMU15(JL,IKM1)*PPIZAZ5(JL,IKM1))&
     & *4.0_JPRB  
!    ZDEN1 = 0.0_JPRB

    PCGAZ(JL,IKM1) = PCGAZ(JL,IKM1) - ZBMU1 *0.75_JPRB*0.5_JPRB
!    ZBMU1 = 0.0_JPRB

    ZBMU0 = ZBMU0 + PRAY1(JL,IKM1)&
     & *PPIZAZ5(JL,IKM1)*PTAUAZ5(JL,IKM1)*ZMUE5(JL,JK) &
     & *PTRA15(JL,IKM1)  
    PPIZAZ(JL,IKM1) = PPIZAZ(JL,IKM1) + PRAY1(JL,IKM1)&
     & *ZBMU05(JL,IKM1)*PTAUAZ5(JL,IKM1)*ZMUE5(JL,JK) &
     & *PTRA15(JL,IKM1)  
    PTAUAZ(JL,IKM1) = PTAUAZ(JL,IKM1) + PRAY1(JL,IKM1)&
     & *ZBMU05(JL,IKM1)*PPIZAZ5(JL,IKM1)*ZMUE5(JL,JK) &
     & *PTRA15(JL,IKM1)  
    ZMUE = ZMUE + PRAY1(JL,IKM1)&
     & *ZBMU05(JL,IKM1)*PPIZAZ5(JL,IKM1)*PTAUAZ5(JL,IKM1)&
     & *PTRA15(JL,IKM1)  
    PTRA1(JL,IKM1) = PTRA1(JL,IKM1)+PRAY1(JL,IKM1)&
     & *ZBMU05(JL,IKM1)*PPIZAZ5(JL,IKM1)*PTAUAZ5(JL,IKM1)&
     & *ZMUE5(JL,JK)  
    PRAY1(JL,IKM1) = 0.0_JPRB

    ZDEN = ZDEN-PTRA1(JL,IKM1)*(PTRA15(JL,IKM1)**2)
    PTRA1(JL,IKM1) = 0.0_JPRB

    PPIZAZ(JL,IKM1) = PPIZAZ(JL,IKM1) - ZDEN *PTAUAZ5(JL,IKM1)*ZMUE5(JL,JK)
    ZBMU0 = ZBMU0 + ZDEN *PPIZAZ5(JL,IKM1)*PTAUAZ5(JL,IKM1)*ZMUE5(JL,JK)
    PPIZAZ(JL,IKM1) = PPIZAZ(JL,IKM1) &
     & + ZDEN *ZBMU05(JL,IKM1)*PTAUAZ5(JL,IKM1)*ZMUE5(JL,JK)
    PTAUAZ(JL,IKM1) = PTAUAZ(JL,IKM1) + ZDEN *ZMUE5(JL,JK) &
     & *(1.0_JPRB-PPIZAZ5(JL,IKM1)+ZBMU05(JL,IKM1)*PPIZAZ5(JL,IKM1))  
    ZMUE = ZMUE + ZDEN *PTAUAZ5(JL,IKM1)&
     & *(1.0_JPRB-PPIZAZ5(JL,IKM1)+ZBMU05(JL,IKM1)*PPIZAZ5(JL,IKM1))  
    PPIZAZ(JL,IKM1) = PPIZAZ(JL,IKM1) &
     & - ZDEN *(PTAUAZ5(JL,IKM1)**2)*ZMUE5(JL,JK)*ZMUE5(JL,JK) &
     & *(1.0_JPRB-PPIZAZ5(JL,IKM1)+2.0_JPRB*ZBMU05(JL,IKM1)*PPIZAZ5(JL,IKM1))  
    PPIZAZ(JL,IKM1) = PPIZAZ(JL,IKM1) - ZDEN *(1.0_JPRB-PPIZAZ5(JL,IKM1))&
     & *(PTAUAZ5(JL,IKM1)**2)*ZMUE5(JL,JK)*ZMUE5(JL,JK)  
    ZBMU0 = ZBMU0 + ZDEN *2.0_JPRB*PPIZAZ5(JL,IKM1)&
     & *(1.0_JPRB-PPIZAZ5(JL,IKM1))*(PTAUAZ5(JL,IKM1)**2)&
     & *ZMUE5(JL,JK)*ZMUE5(JL,JK)  
    PPIZAZ(JL,IKM1) = PPIZAZ(JL,IKM1) + ZDEN *2.0_JPRB*ZBMU05(JL,IKM1)&
     & *(1.0_JPRB-PPIZAZ5(JL,IKM1))*(PTAUAZ5(JL,IKM1)**2)&
     & *ZMUE5(JL,JK)*ZMUE5(JL,JK)  
    PTAUAZ(JL,IKM1) = PTAUAZ(JL,IKM1) &
     & + ZDEN *2*PTAUAZ5(JL,IKM1)*ZMUE5(JL,JK)*ZMUE5(JL,JK) &
     & *(1.0_JPRB-PPIZAZ5(JL,IKM1))&
     & *(1.0_JPRB-PPIZAZ5(JL,IKM1)+2.0_JPRB*ZBMU05(JL,IKM1)*PPIZAZ5(JL,IKM1))  
    ZMUE = ZMUE + ZDEN *2*(PTAUAZ5(JL,IKM1)**2)*ZMUE5(JL,JK) &
     & *(1.0_JPRB-PPIZAZ5(JL,IKM1))&
     & *(1.0_JPRB-PPIZAZ5(JL,IKM1)+2.0_JPRB*ZBMU05(JL,IKM1)*PPIZAZ5(JL,IKM1))  
!    ZDEN = 0.0_JPRB

    PRMUE(JL,JK) = PRMUE(JL,JK)-0.75_JPRB*PCGAZ5(JL,IKM1)*ZBMU0
    PCGAZ(JL,IKM1) = PCGAZ(JL,IKM1)-0.75_JPRB*PRMUE5(JL,JK)*ZBMU0
!    ZBMU0 = 0.0_JPRB

!1320 CONTINUE

    ZMUE = ZMUE - PRMUE(JL,JK) *(PRMUE5(JL,JK)**2)
    PRMUE(JL,JK) = 0.0_JPRB

    ZC1I(JL,JK) = ZC1I(JL,JK) - ZMUE *PSEC5(JL)
    PSEC(JL) = PSEC(JL) + ZMUE *(1.0_JPRB-ZC1I5(JL,JK))
    ZC1I(JL,JK) = ZC1I(JL,JK) + ZMUE *1.66_JPRB
!    ZMUE = 0.0_JPRB

!1310 CONTINUE

  ENDDO

ENDDO

DO JL=KIDIA,KFDIA
  PTRA2(JL,KLEV+1) = 0.0_JPRB
  PTRA1(JL,KLEV+1) = 0.0_JPRB

  PALBD(JL,KNU) = PALBD(JL,KNU) + PREFZ(JL,1,1)
  PREFZ(JL,1,1) = 0.0_JPRB

  PALBD(JL,KNU) = PALBD(JL,KNU) + PREFZ(JL,2,1)
  PREFZ(JL,2,1) = 0.0_JPRB

  PRAY2(JL,KLEV+1) = 0.0_JPRB
  PRAY1(JL,KLEV+1) = 0.0_JPRB
ENDDO

!1300 CONTINUE             

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

!------
ZCLOUD(:)   = 0.0_JPRB
ZCLEAR(:)   = 0.0_JPRB
ZNUME(:)    = 0.0_JPRB
ZDENO(:)    = 0.0_JPRB
ZR21(:)     = 0.0_JPRB
ZR22(:)     = 0.0_JPRB
ZSS1(:)     = 0.0_JPRB

DO JK=KLEV,1,-1
  IKL=KLEV+1-JK
  IKLP1=IKL+1

  DO JL=KIDIA,KFDIA
    ZCORAE = 0.0_JPRB
    ZCORCD = 0.0_JPRB
    ZFACOA = 0.0_JPRB
    ZFACOC = 0.0_JPRB
    ZCHKAE = 0.0_JPRB
    ZCHKCD = 0.0_JPRB

    IF (NOVLP == 4) THEN
      ZSS1 (JL) = ZSS1 (JL) + ZCLOUD (JL)
      ZCLOUD (JL) = 0.0_JPRB

      ZCLEAR(JL) = ZCLEAR(JL) - ZC1I (JL,IKL)
      ZC1I (JL,IKL) = 0.0_JPRB

      ZNUME(JL) = ZNUME(JL) - (ZALPHA1*ZCLEAR5(JL,IKLP1)&
       & *ZICLEAR5(JL,IKL)) * ZCLEAR (JL)  
      ZDENO(JL) = ZDENO(JL) + (ZALPHA1*ZCLEAR5(JL,IKLP1) &
       & * (1.0_JPRB-ZNUME5(JL,IKL))*ZICLEAR5(JL,IKL)**2) * ZCLEAR (JL)  
      ZSS1(JL) = ZSS1(JL) - (1.0_JPRB-ZALPHA1) &
       & * ZCLEAR5(JL,IKLP1)*ZCLEAR (JL)  
      ZCLEAR(JL) = ZCLEAR (JL) &
       & * (ZALPHA1*(1.0_JPRB-ZNUME5(JL,IKL))*ZICLEAR5(JL,IKL) &
       & + (1.0_JPRB-ZALPHA1)*(1.0_JPRB-ZSS15(JL,IKL)))  

      IF (ZCLOUD5(JL,IKLP1) <= 1.0_JPRB-REPSEC) THEN
        ZCLOUD (JL) = ZCLOUD(JL) + ZDENO(JL)
      ENDIF
      ZDENO(JL) = 0.0_JPRB

      IF (ZSS15(JL,IKL) >= ZCLOUD5(JL,IKLP1)) THEN
        ZSS1 (JL) = ZSS1(JL) + ZNUME(JL)
      ELSE
        ZCLOUD (JL) = ZCLOUD(JL) + ZNUME(JL)
      ENDIF
      ZNUME(JL) = 0.0_JPRB
      
    ELSEIF (NOVLP == 3) THEN
      ZCLOUD(JL) = ZCLOUD(JL) + ZC1I(JL,IKL)
      ZC1I(JL,IKL) = 0.0_JPRB

      ZCLEAR(JL) = ZCLEAR(JL) - ZCLOUD(JL)
      ZCLOUD(JL) = 0.0_JPRB

      ZSS1(JL) = ZSS1(JL) - ZCLEAR(JL) *ZCLEAR5(JL,IKLP1)
      ZCLEAR(JL) = ZCLEAR(JL) * (1.0_JPRB-ZSS15(JL,IKL))

    ELSEIF (NOVLP == 2) THEN
      ZCLOUD(JL) = ZCLOUD(JL) + ZC1I(JL,IKL)
      ZC1I(JL,IKL) = 0.0_JPRB

      IF (ZSS15(JL,IKL) >= ZCLOUD5(JL,IKLP1)) THEN
        ZSS1(JL) = ZSS1(JL) + ZCLOUD(JL)
        ZCLOUD(JL) = 0.0_JPRB
      ENDIF

    ELSEIF (NOVLP == 1) THEN
      ZSS1(JL) = ZSS1(JL) + ZCLOUD(JL)
      ZCLOUD(JL) = 0.0_JPRB

      ZCLEAR(JL) = ZCLEAR(JL) - ZC1I(JL,IKL)
      ZC1I(JL,IKL) = 0.0_JPRB

      ZNUME(JL) = ZNUME(JL)&
       & -ZCLEAR(JL) *ZCLEAR5(JL,IKLP1)*ZICLEAR5(JL,IKL)  
      ZDENO(JL) = ZDENO(JL)&
       & +ZCLEAR(JL) *ZCLEAR5(JL,IKLP1)*(1.0_JPRB-ZNUME5(JL,IKL))&
       & *(ZICLEAR5(JL,IKL)**2)  
      ZCLEAR(JL) = ZCLEAR(JL)*(1.0_JPRB-ZNUME5(JL,IKL))*ZICLEAR5(JL,IKL)   

      IF (ZCLOUD5(JL,IKLP1) <= 1.0_JPRB-REPSEC) THEN
        ZCLOUD(JL) = ZCLOUD(JL) + ZDENO(JL)
      ENDIF
      ZDENO(JL) = 0.0_JPRB

      IF (ZSS15(JL,IKL) >= ZCLOUD5(JL,IKLP1)) THEN
        ZSS1(JL) = ZSS1(JL) + ZNUME(JL)
      ELSE
        ZCLOUD(JL) = ZCLOUD(JL) + ZNUME(JL)
      ENDIF
      ZNUME(JL) = 0.0_JPRB

    ENDIF

    PCLD(JL,IKL) = PCLD(JL,IKL)&
     & + ZSS1(JL) *(1.0_JPRB-ZRA215(JL,IKL)*ZRA225(JL,IKL))  
    ZR21(JL) = ZR21(JL) - ZSS1(JL) *PCLD5(JL,IKL)*ZRA225(JL,IKL)
    ZR22(JL) = ZR22(JL) - ZSS1(JL) *PCLD5(JL,IKL)*ZRA215(JL,IKL)
    PCLD(JL,IKL) = PCLD(JL,IKL) - ZSS1(JL) *(1.0_JPRB-ZRA215(JL,IKL))
    ZR21(JL) = ZR21(JL) - ZSS1(JL) *(1.0_JPRB-PCLD5(JL,IKL))
    ZSS1(JL) = 0.0_JPRB

    ZCHKCD = ZCHKCD - ZR22(JL) *ZRA225(JL,IKL)
    ZR22(JL) = 0.0_JPRB

    ZCHKAE = ZCHKAE - ZR21(JL) *ZRA215(JL,IKL)
    ZR21(JL) = 0.0_JPRB
    
    IF (ZCORCD5(JL,IKL) <= 200._JPRB) THEN
      ZCORCD = ZCORCD + ZCHKCD
    ENDIF
!    ZCHKCD = 0.0_JPRB

    IF (ZCORAE5(JL,IKL) <= 200._JPRB) THEN 
      ZCORAE = ZCORAE + ZCHKAE
    ENDIF
!    ZCHKAE = 0.0_JPRB   
    
    ZFACOC = ZFACOC + ZCORCD *PTAU5(JL,KNU,IKL)*PSEC5(JL)
    PTAU(JL,KNU,IKL) = PTAU(JL,KNU,IKL) + ZCORCD *ZFACOC5(JL,IKL)*PSEC5(JL)
    PSEC(JL) = PSEC(JL) + ZCORCD *PTAU5(JL,KNU,IKL)*ZFACOC5(JL,IKL)
!    ZCORCD = 0.0_JPRB

    ZFACOA = ZFACOA + ZCORAE *PTAUAZ5(JL,IKL)*PSEC5(JL)
    PTAUAZ(JL,IKL) = PTAUAZ(JL,IKL)+ ZCORAE *ZFACOA5(JL,IKL)*PSEC5(JL)
    PSEC(JL) = PSEC(JL) + ZCORAE *ZFACOA5(JL,IKL)*PTAUAZ5(JL,IKL)
!    ZCORAE = 0.0_JPRB

    POMEGA(JL,KNU,IKL) = POMEGA(JL,KNU,IKL)&
     & - ZFACOC *PCG5(JL,KNU,IKL)**2         
    PCG(JL,KNU,IKL) = PCG(JL,KNU,IKL)&
     & - ZFACOC *POMEGA5(JL,KNU,IKL)*2*PCG5(JL,KNU,IKL)  
!    ZFACOC = 0.0_JPRB

    PPIZAZ(JL,IKL) = PPIZAZ(JL,IKL) - ZFACOA *PCGAZ5(JL,IKL)**2
    PCGAZ(JL,IKL) = PCGAZ(JL,IKL)- ZFACOA *PPIZAZ5(JL,IKL)*2*PCGAZ5(JL,IKL)
!    ZFACOA = 0.0_JPRB
  ENDDO

ENDDO

!1201 CONTINUE

!1200 CONTINUE

DO JL = KIDIA,KFDIA
  ZCLOUD(JL) = 0.0_JPRB
  ZCLEAR(JL) = 0.0_JPRB
  ZC1I(JL,KLEV+1) = 0.0_JPRB
ENDDO

DO JK=1,KLEV+1
  DO JA=1,6
    DO JL=KIDIA,KFDIA
      PRK(JL,JA,JK) = 0.0_JPRB
      PRJ(JL,JA,JK) = 0.0_JPRB
    ENDDO
  ENDDO
ENDDO

!1100 CONTINUE       

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

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