!OPTIONS XOPT(HSFUN)
SUBROUTINE RADACA ( KIDIA , KFDIA , KLON , KLEV,&
 & PAPRS , PGELAM, PSIN  , PCLON, PSLON , PTH,&
 & PAER  , POZON                         )  

!***********************************************************************
! CAUTION: THIS ROUTINE WORKS ONLY ON A NON-ROTATED, UNSTRETCHED GRID
!***********************************************************************

!**** *RADACA  - COMPUTES DISTRIBUTION OF AEROSOLS AND OZONE
!                >>> FOR ASSIMILATION AND UV-DIAGNOSTIC PURPOSES <<

!     PURPOSE.
!     --------

!**   INTERFACE.
!     ----------
!        CALL *RADACA* FROM *RADINA*
!                      FROM *CALLPAR* for UV diagnostics 

!        EXPLICIT ARGUMENTS :
!        --------------------
!     ==== INPUTS ===
!     ==== OUTPUTS ===

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

!     METHOD.
!     -------

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

!          NONE

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

!        SEE RADIATION'S PART OF THE MODEL'S DOCUMENTATION AND
!        ECMWF RESEARCH DEPARTMENT DOCUMENTATION OF THE "I.F.S"

!     AUTHOR.
!     -------

!     J.-F. MAHFOUF    E.C.M.W.F.    97/07/04

!     Aadapted from

!     J.-J. MORCRETTE  E.C.M.W.F.    91/03/15

!     MODIFICATIONS.
!     --------------
!     J.-J. MORCRETTE  E.C.M.W.F.    93/03/15   OPERATIONAL CLIMATOLOGY
!     JJMorcrette  99-05-25     Revised aerosols (over 6 types)
!     JJMorcrette  03-05-01     Tegen et al's aerosols
!     J.HAGUE      01/07/03     Modified for bit reproducibility
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!     JJMorcrette 20080206 revised use of GISS history of volcanic aerosols
!-----------------------------------------------------------------------

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

USE YOMCST   , ONLY :         RPI
USE YOEAERD  , ONLY : CVDAES   ,CVDAEL   ,CVDAEU   ,CVDAED   ,&
 & RCAEOPS  ,RCAEOPL  ,RCAEOPU  ,RCAEOPD  ,RCTRBGA  ,&
 & RCVOBGA  ,RCSTBGA  ,RCTRPT   ,RAESC    ,RAESS    ,&
 & RAELC    ,RAELS    ,RAEUC    ,RAEUS    ,RAEDC    ,&
 & RAEDS  
USE YOEOZOC  , ONLY : COZQC    ,COZQS    ,COZHC    ,COZHS
USE YOERAD   , ONLY : LHVOLCA  ,LNEWAER
USE YOEAERC  , ONLY :       REPAER   ,&
 & RTAEBC  ,RTAEOR   ,RTAESD   ,RTAESS   ,RTAESU   , &
 & RTAEVO  

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)    :: PAPRS(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGELAM(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PSIN(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCLON(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PSLON(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTH(KLON,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PAER(KLON,6,KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: POZON(KLON,KLEV) 
!     -----------------------------------------------------------------

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

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

!*       0.2   LOCAL ARRAYS.
!              -------------

!--
INTEGER(KIND=JPIM) :: IINLA1(KLON), IINLA2(KLON)
INTEGER(KIND=JPIM) :: IINLO1(KLON), IINLO2(KLON)

REAL(KIND=JPRB) :: ZAERBC(KLON), ZAEROR(KLON), ZAERSD(KLON)
REAL(KIND=JPRB) :: ZAERSS(KLON), ZAERSU(KLON), ZAERVO(KLON)
REAL(KIND=JPRB) :: ZSILAT(KLON), ZSINR(46), ZLONR(72), ZLON(KLON), ZNLO1(KLON), ZNLO2(KLON)

INTEGER(KIND=JPIM) :: INLA, INLA1, INLA2, INLO1, INLO2, &
 & JLR, ITLATR, ITLONR, JAER  

REAL(KIND=JPRB) :: ZAERBC1, ZAERBC2, ZAEROR1, ZAEROR2, ZAERSD1, ZAERSD2, &
 & ZAERSS1, ZAERSS2, ZAERSU1, ZAERSU2  
REAL(KIND=JPRB) :: ZDLONR, ZGRIDR, ZLATR
!--

REAL(KIND=JPRB) :: ZALP(66,KLON)
REAL(KIND=JPRB) :: ZFOZQ(11,KLON),ZFOZH(11,KLON)
REAL(KIND=JPRB) :: ZFAES(21,KLON),ZFAEL(21,KLON),ZFAEU(21,KLON),ZFAED(21,KLON)

REAL(KIND=JPRB) :: ZDPN (KLON) ,ZDPO (KLON) ,ZQOFN(KLON) ,ZQOFO(KLON)
REAL(KIND=JPRB) :: ZOZH (KLON) ,ZOZQ (KLON)
REAL(KIND=JPRB) :: ZAEQSN(KLON),ZAEQSO(KLON),ZAEQLN(KLON),ZAEQLO(KLON)
REAL(KIND=JPRB) :: ZAEQUN(KLON),ZAEQUO(KLON),ZAEQDN(KLON),ZAEQDO(KLON)
REAL(KIND=JPRB) :: ZAETRN(KLON),ZAETRO(KLON)
REAL(KIND=JPRB) :: ZAES  (KLON),ZAEL  (KLON),ZAEU  (KLON),ZAED  (KLON)
REAL(KIND=JPRB) :: ZSIN(KLON)  ,ZSTRDEP(KLON)


INTEGER(KIND=JPIM) :: IMM, IMNC, IMNS, JK, JL, JMM, JNN

REAL(KIND=JPRB) :: ZAETR, ZCOS1, ZCOS10, ZCOS2, ZCOS3, ZCOS4,&
 & ZCOS5, ZCOS6, ZCOS7, ZCOS8, ZCOS9, ZCPHN3, &
 & ZCPHO3, ZDPNMO, ZSDPN3, ZSDPO3, ZSIN1, &
 & ZSIN10, ZSIN2, ZSIN3, ZSIN4, ZSIN5, ZSIN6, &
 & ZSIN7, ZSIN8, ZSIN9  
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"
#include "legtriv.intfb.h"

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

!*         1.     "NEW AEROSOL DISTRIBUTION" PARAMETERS COMPUTATIONS
!                 --------------------------------------------------


!*         1.1    VOLCANIC AEROSOL DISTRIBUTION PARAMETERS
!                 ----------------------------------------

!                 GISS CLIMATOLOGY, APPLIED TO SULPHATE AEROSOLS 
!                 ----------------------------------------------

IF (LHOOK) CALL DR_HOOK('RADACA',0,ZHOOK_HANDLE)
IF (LHVOLCA) THEN
  ITLATR=46
  ZGRIDR=180._JPRB/(ITLATR-1)
  DO JLR=1,ITLATR
    ZLATR=90._JPRB-(JLR-1)*ZGRIDR
    ZSINR(JLR)=SIN(ZLATR*RPI/180._JPRB)
  ENDDO

  DO JL=KIDIA,KFDIA
    INLA=0
    ZSILAT(JL)=-9999._JPRB
    DO JLR=1,ITLATR-1
      IF (PSIN(JL) <= ZSINR(JLR) .AND. PSIN(JL) > ZSINR(JLR+1)) THEN
        INLA=JLR
        ZSILAT(JL)=(PSIN(JL)-ZSINR(INLA))/(ZSINR(INLA+1)-ZSINR(INLA))
        ZAERVO(JL)=RTAEVO(INLA)+ZSILAT(JL)*(RTAEVO(INLA+1)-RTAEVO(INLA))
      ENDIF
    ENDDO
    IF (PSIN(JL) <= ZSINR(ITLATR-1) .AND. PSIN(JL) >= ZSINR(ITLATR))THEN
      INLA=ITLATR
      ZSILAT(JL)=(PSIN(JL)-ZSINR(INLA-1))/(ZSINR(INLA)-ZSINR(INLA-1))
      ZAERVO(JL)=RTAEVO(INLA-1)&
       & +ZSILAT(JL)*(RTAEVO(INLA)-RTAEVO(INLA-1))  
    ENDIF
    IF (INLA == 0) THEN
      CALL ABOR1(' Problem with lat. interpolation in radaca!')
    ENDIF
    ZDPO(JL)=PAPRS(JL,0)
    ZAETRO(JL)=1.0_JPRB
    ZSTRDEP(JL)=0.0_JPRB
  ENDDO

!-- define how thick the stratosphere is in pressure units
  DO JK=1,KLEV
    DO JL=KIDIA,KFDIA
      ZDPN(JL)=PAPRS(JL,JK)
      IF (0.5_JPRB*(PAPRS(JL,JK-1)+PAPRS(JL,JK)) < 999._JPRB) THEN
! for models with top above 10hPa
        ZAETRN(JL)=1.0_JPRB
        ZAETRO(JL)=1.0_JPRB
      ELSE
        ZAETRN(JL)=ZAETRO(JL)*(MIN(1.0_JPRB,PTH(JL,JK)/PTH(JL,JK+1)))**RCTRPT
      ENDIF
      ZAETR=SQRT(ZAETRN(JL)*ZAETRO(JL))
      ZDPNMO=ZDPN(JL)-ZDPO(JL)
      ZSTRDEP(JL)=ZSTRDEP(JL)+ZAETR*ZDPNMO
    ENDDO
    DO JL=KIDIA,KFDIA
      ZDPO(JL)  =ZDPN(JL)
      ZAETRO(JL)=ZAETRN(JL)
    ENDDO
  ENDDO
!-- 
  DO JL=KIDIA,KFDIA
    ZAERVO(JL)=ZAERVO(JL)/ZSTRDEP(JL)
  ENDDO

!                 TANRE ET AL. CLIMATOLOGY 
!                 ------------------------

ELSE
  DO JL=KIDIA,KFDIA
    ZAERVO(JL)=RCSTBGA
  ENDDO
ENDIF

!*         1.2    TROPOSPHERIC AEROSOL DISTRIBUTION PARAMETERS
!                 --------------------------------------------

IF (LNEWAER) THEN
!  print *,'LNEWAER= ',LNEWAER
!  print *,' inputs        SINLAT            LONGITUDE'
!  DO JL=KIDIA,KFDIA
!    print 9001,JL,PSIN(JL),PGELAM(JL)
  9001    format(1x,'RADACT ',1x,I5,1x,2E15.8)
!  ENDDO         

!-- latitude       
  ITLATR=46
  ZGRIDR=180._JPRB/(ITLATR-1)
  DO JLR=1,ITLATR
    ZLATR=90._JPRB-(JLR-1)*ZGRIDR
    ZSINR(JLR)=SIN(ZLATR*RPI/180._JPRB)
  ENDDO
  ITLONR=72
  ZDLONR=2._JPRB*RPI/ITLONR
  DO JLR=1,ITLONR
    ZLONR(JLR)=(JLR-1)*ZDLONR
  ENDDO

!  print *,'Reference grid for Tegen climatology'        
!  print 9121,(ZSINR(JLR),JLR=1,NLATR)
  9121     format(1x,'ZSINR ',8E15.7)
!  print 9122,(ZLONR(JLR),JLR=1,NLONR)
  9122     format(1x,'ZLONR ',8E15.7)
           
  DO JL=KIDIA,KFDIA         
    IINLA1(JL)=0
    IINLA2(JL)=0
    ZSILAT(JL)=-9999._JPRB
        DO JLR=1,ITLATR-1
      IF (PSIN(JL) <= ZSINR(JLR) .AND. PSIN(JL) > ZSINR(JLR+1)) THEN
        INLA=JLR
        IINLA1(JL)=JLR
        IINLA2(JL)=JLR+1
        ZSILAT(JL)=(PSIN(JL)-ZSINR(INLA))/(ZSINR(INLA+1)-ZSINR(INLA))
      ENDIF
    ENDDO
    IF (PSIN(JL) <= ZSINR(ITLATR-1) .AND. PSIN(JL) >= ZSINR(ITLATR))THEN
      INLA=ITLATR
      IINLA1(JL)=ITLATR-1
      IINLA2(JL)=ITLATR
      ZSILAT(JL)=(PSIN(JL)-ZSINR(INLA-1))/(ZSINR(INLA)-ZSINR(INLA-1))
    ENDIF    
    IF (INLA == 0) THEN 
      CALL ABOR1(' Problem with lat. interpolation in radaca!')
    ENDIF
!    print 9123,JL,PSIN(JL),INLA,ZSINR(INLA),ZSILAT(JL)
    9123     format(1x,'Interp.Latit.',I4,F10.7,I4,2F10.7)          
  ENDDO  

!-- longitude
  DO JL=KIDIA,KFDIA
    IINLO1(JL)=0
    IINLO2(JL)=0
    ZLON(JL)=-9999.
    DO JLR=1,71
      IF (PGELAM(JL) < ZLONR(JLR+1) .AND. PGELAM(JL) >= ZLONR(JLR)) &
         & THEN  
        IINLO1(JL)=JLR
        IINLO2(JL)=JLR+1
        ZNLO1(JL)=ZLONR(JLR)
        ZNLO2(JL)=ZLONR(JLR+1)
      ENDIF
    ENDDO      
    IF (PGELAM(JL) >= ZLONR(72)) THEN
      IINLO1(JL)=72
      IINLO2(JL)= 1
      ZNLO1(JL)=ZLONR(72)
!      ZNLO2(JL)=ZLONR(72)+2.*RPI
      ZNLO2(JL)=ZLONR(72)+ZDLONR
    ENDIF
!    print 9124,JL,PGELAM(JL),IINLO1(JL),IINLO2(JL),ZNLO1(JL),ZNLO2(JL)
    9124     format(1x,'Interp.Longit0.',I4,F10.7,2I5,2F10.7)          
  ENDDO  
 
  DO JL=KIDIA,KFDIA
    IF (IINLO1(JL) == 0 .OR. IINLO2(JL) == 0) THEN 
      CALL ABOR1(' Problem with long. interpolation in radaca!')
    ENDIF
    ZLON(JL)=(PGELAM(JL)-ZNLO1(JL))/(ZNLO2(JL)-ZNLO1(JL))
    INLO1=IINLO1(JL)
    INLO2=IINLO2(JL)
    INLA1=IINLA1(JL)
    INLA2=IINLA2(JL)
    
    ZAERBC1=RTAEBC(INLO1,INLA1) &
     & +ZSILAT(JL)*(RTAEBC(INLO1,INLA2)-RTAEBC(INLO1,INLA1))    
    ZAERBC2=RTAEBC(INLO2,INLA1) &
     & +ZSILAT(JL)*(RTAEBC(INLO2,INLA2)-RTAEBC(INLO2,INLA1))    
    ZAERBC(JL)=ZAERBC1+ZLON(JL)*(ZAERBC2-ZAERBC1)
        
    ZAEROR1=RTAEOR(INLO1,INLA1) &
     & +ZSILAT(JL)*(RTAEOR(INLO1,INLA2)-RTAEOR(INLO1,INLA1))    
    ZAEROR2=RTAEOR(INLO2,INLA1) &
     & +ZSILAT(JL)*(RTAEOR(INLO2,INLA2)-RTAEOR(INLO2,INLA1))    
    ZAEROR(JL)=ZAEROR1+ZLON(JL)*(ZAEROR2-ZAEROR1)
        
    ZAERSD1=RTAESD(INLO1,INLA1) &
     & +ZSILAT(JL)*(RTAESD(INLO1,INLA2)-RTAESD(INLO1,INLA1))    
    ZAERSD2=RTAESD(INLO2,INLA1) &
     & +ZSILAT(JL)*(RTAESD(INLO2,INLA2)-RTAESD(INLO2,INLA1))    
    ZAERSD(JL)=ZAERSD1+ZLON(JL)*(ZAERSD2-ZAERSD1)
        
    ZAERSS1=RTAESS(INLO1,INLA1) &
     & +ZSILAT(JL)*(RTAESS(INLO1,INLA2)-RTAESS(INLO1,INLA1))    
    ZAERSS2=RTAESS(INLO2,INLA1) &
     & +ZSILAT(JL)*(RTAESS(INLO2,INLA2)-RTAESS(INLO2,INLA1))    
    ZAERSS(JL)=ZAERSS1+ZLON(JL)*(ZAERSS2-ZAERSS1)
        
    ZAERSU1=RTAESU(INLO1,INLA1) &
     & +ZSILAT(JL)*(RTAESU(INLO1,INLA2)-RTAESU(INLO1,INLA1))    
    ZAERSU2=RTAESU(INLO2,INLA1) &
     & +ZSILAT(JL)*(RTAESU(INLO2,INLA2)-RTAESU(INLO2,INLA1))    
    ZAERSU(JL)=ZAERSU1+ZLON(JL)*(ZAERSU2-ZAERSU1)
          
!    print 9125,JL,PSIN(JL),PGELAM(JL),ZSILAT(JL) &
!     &      ,RTAESU(INLO1,INLA2),RTAESU(INLO1,INLA1),ZAERSU1 &
!     &      ,RTAESU(INLO2,INLA2),RTAESU(INLO2,INLA1),ZAERSU2 &
!     &                    ,INLA1,INLO1,INLO2,INLA2
!9125     format(1x,'Interp.Longit1.',I4,9F10.7,4I5)          
!    print 9126,JL,PSIN(JL),PGELAM(JL),ZSILAT(JL),ZLON(JL) &
!     &      ,ZNLO1(JL),ZNLO2(JL),INLA1,INLO1,INLO2,INLA2
!9126     format(1x,'Interp.Longit2.',I4,6F10.7,4I5)          
!    print 9127,JL,ZAERBC(JL),ZAEROR(JL),ZAERSD(JL),ZAERSS(JL) &
!     &      ,ZAERSU(JL)
!9127     format(1x,'Interp.Longit3.',I4,5F10.7)          
  ENDDO       
ENDIF

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

!*         2.     OZONE
!                 -----

DO JL=KIDIA,KFDIA
  ZSIN(JL)=PSIN(JL)
ENDDO

!*       2.1     CALL TO LEGTRI.

!***
CALL LEGTRIV(ZSIN(KIDIA),6,66,ZALP,KFDIA-KIDIA+1)
!***

!*       2.2     *LEGENDRE TRANSFORM FOR OZONE.

DO JL=KIDIA,KFDIA
  DO JMM=1,11
    ZFOZQ(JMM,JL)=0.0_JPRB
    ZFOZH(J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(11,JL)*ZSIN5)  
  ZOZH(JL)=&
   & ZFOZH(1,JL)+2.0_JPRB*(ZFOZH(2,JL)*ZCOS1+ZFOZH(3,JL)*ZSIN1+ZFOZH(4,JL)*ZCOS2 &
   & +ZFOZH(5,JL)*ZSIN2+ZFOZH(6,JL)*ZCOS3+ZFOZH(7,JL)*ZSIN3+ZFOZH(8,JL)&
   & *ZCOS4+ZFOZH(9,JL)*ZSIN4+ZFOZH(10,JL)*ZCOS5+ZFOZH(11,JL)*ZSIN5)  
  ZOZH(JL)=SQRT(ZOZH(JL))**3
ENDDO

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

!       3.     AEROSOLS
!              --------
!***
!       3.1     CALL TO LEGTRI

!***
CALL LEGTRIV(ZSIN(KIDIA),11,66,ZALP,KFDIA-KIDIA+1)
!***

!       3.2     LEGENDRE TRANSFORM FOR TANRE'S AEROSOLS
!               ---------------------------------------

DO JL=KIDIA,KFDIA
  DO JMM=1,21
    ZFAES(JMM,JL) = 0.0_JPRB
    ZFAEL(JMM,JL) = 0.0_JPRB
    ZFAEU(JMM,JL) = 0.0_JPRB
    ZFAED(JMM,JL) = 0.0_JPRB
  ENDDO
  IMM  = 0
  IMNC = 0
  IMNS = 0
  DO JMM=1,11
    IMM  = IMM+1
    DO JNN=JMM,11
      IMNC = IMNC+1
      ZFAES(IMM,JL) = ZFAES(IMM,JL)+ZALP(IMNC,JL)*RAESC(IMNC)
      ZFAEL(IMM,JL) = ZFAEL(IMM,JL)+ZALP(IMNC,JL)*RAELC(IMNC)
      ZFAEU(IMM,JL) = ZFAEU(IMM,JL)+ZALP(IMNC,JL)*RAEUC(IMNC)
      ZFAED(IMM,JL) = ZFAED(IMM,JL)+ZALP(IMNC,JL)*RAEDC(IMNC)
    ENDDO
    IF(JMM /= 1) THEN
      IMM  = IMM+1
      DO JNN=JMM,11
        IMNS = IMNS+1
        ZFAES(IMM,JL) = ZFAES(IMM,JL)+ZALP(IMNS+11,JL)*RAESS(IMNS)
        ZFAEL(IMM,JL) = ZFAEL(IMM,JL)+ZALP(IMNS+11,JL)*RAELS(IMNS)
        ZFAEU(IMM,JL) = ZFAEU(IMM,JL)+ZALP(IMNS+11,JL)*RAEUS(IMNS)
        ZFAED(IMM,JL) = ZFAED(IMM,JL)+ZALP(IMNS+11,JL)*RAEDS(IMNS)
      ENDDO
    ENDIF
  ENDDO
ENDDO

!       3.3     FOURIER TRANSFORM FOR TANRE'S AEROSOLS
!               --------------------------------------

DO JL=KIDIA,KFDIA
  ZCOS1    = PCLON(JL)
  ZSIN1    = PSLON(JL)
  ZCOS2    = ZCOS1*ZCOS1-ZSIN1*ZSIN1
  ZSIN2    = ZSIN1*ZCOS1+ZCOS1*ZSIN1
  ZCOS3    = ZCOS2*ZCOS1-ZSIN2*ZSIN1
  ZSIN3    = ZSIN2*ZCOS1+ZCOS2*ZSIN1
  ZCOS4    = ZCOS3*ZCOS1-ZSIN3*ZSIN1
  ZSIN4    = ZSIN3*ZCOS1+ZCOS3*ZSIN1
  ZCOS5    = ZCOS4*ZCOS1-ZSIN4*ZSIN1
  ZSIN5    = ZSIN4*ZCOS1+ZCOS4*ZSIN1
  ZCOS6    = ZCOS5*ZCOS1-ZSIN5*ZSIN1
  ZSIN6    = ZSIN5*ZCOS1+ZCOS5*ZSIN1
  ZCOS7    = ZCOS6*ZCOS1-ZSIN6*ZSIN1
  ZSIN7    = ZSIN6*ZCOS1+ZCOS6*ZSIN1
  ZCOS8    = ZCOS7*ZCOS1-ZSIN7*ZSIN1
  ZSIN8    = ZSIN7*ZCOS1+ZCOS7*ZSIN1
  ZCOS9    = ZCOS8*ZCOS1-ZSIN8*ZSIN1
  ZSIN9    = ZSIN8*ZCOS1+ZCOS8*ZSIN1
  ZCOS10   = ZCOS9*ZCOS1-ZSIN9*ZSIN1
  ZSIN10   = ZSIN9*ZCOS1+ZCOS9*ZSIN1
  ZAES(JL) = ZFAES(1,JL) + 2.0_JPRB*&
   & ( ZFAES(2,JL)*ZCOS1  + ZFAES(3,JL)*ZSIN1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+ ZFAEU(7,JL)*ZSIN3 &
   & + ZFAEU(8,JL)*ZCOS4  + ZFAEU(9,JL)*ZSIN4  + ZFAEU(10,JL)*ZCOS5 &
   & + ZFAEU(11,JL)*ZSIN5 + ZFAEU(12,JL)*ZCOS6 + ZFAEU(13,JL)*ZSIN6 &
   & + ZFAEU(14,JL)*ZCOS7 + ZFAEU(15,JL)*ZSIN7 + ZFAEU(16,JL)*ZCOS8 &
   & + ZFAEU(17,JL)*ZSIN8 + ZFAEU(18,JL)*ZCOS9 + ZFAEU(19,JL)*ZSIN9 &
   & + ZFAEU(20,JL)*ZCOS10+ ZFAEU(21,JL)*ZSIN10                 )  
  ZAED(JL) = ZFAED(1,JL) + 2.0_JPRB*&
   & ( ZFAED(2,JL)*ZCOS1  + ZFAED(3,JL)*ZSIN1  + ZFAED(4,JL)*ZCOS2 &
   & + ZFAED(5,JL)*ZSIN2  + ZFAED(6,JL)*ZCOS3  + ZFAED(7,JL)*ZSIN3 &
   & + ZFAED(8,JL)*ZCOS4  + ZFAED(9,JL)*ZSIN4  + ZFAED(10,JL)*ZCOS5 &
   & + ZFAED(11,JL)*ZSIN5 + ZFAED(12,JL)*ZCOS6 + ZFAED(13,JL)*ZSIN6 &
   & + ZFAED(14,JL)*ZCOS7 + ZFAED(15,JL)*ZSIN7 + ZFAED(16,JL)*ZCOS8 &
   & + ZFAED(17,JL)*ZSIN8 + ZFAED(18,JL)*ZCOS9 + ZFAED(19,JL)*ZSIN9 &
   & + ZFAED(20,JL)*ZCOS10+ ZFAED(21,JL)*ZSIN10                 )  
ENDDO

!*         2.      VERTICAL DISTRIBUTION
!*                 ---------------------

DO JL=KIDIA,KFDIA
  ZDPO(JL)=PAPRS (JL,0)
  ZCPHO3=PAPRS (JL,0)**3
  ZSDPO3=SQRT  (ZCPHO3)

  IF (LNEWAER) THEN
    ZAEQSO(JL)= ZAERSS(JL)*CVDAES(1)
    ZAEQLO(JL)=(ZAEROR(JL)+ZAERSU(JL))*CVDAEL(1)
    ZAEQUO(JL)= ZAERBC(JL)*CVDAEU(1)
    ZAEQDO(JL)= ZAERSD(JL)*CVDAED(1)
  ELSE
    ZAEQSO(JL)=RCAEOPS*ZAES(JL)*CVDAES(1)
    ZAEQLO(JL)=RCAEOPL*ZAEL(JL)*CVDAEL(1)
    ZAEQUO(JL)=RCAEOPU*ZAEU(JL)*CVDAEU(1)
    ZAEQDO(JL)=RCAEOPD*ZAED(JL)*CVDAED(1)
  ENDIF
  ZAETRO(JL)=1.0_JPRB
  ZQOFO(JL)=ZOZQ(JL)*ZSDPO3 / (ZSDPO3 + ZOZH(JL))
ENDDO

DO JK=1,KLEV
  DO JL=KIDIA,KFDIA
    ZDPN(JL)=PAPRS (JL,JK)
    ZCPHN3=PAPRS (JL,JK)**3
    ZSDPN3=SQRT  (ZCPHN3)

    IF (LNEWAER) THEN
      ZAEQSN(JL)= ZAERSS(JL)*CVDAES(JK+1)
      ZAEQLN(JL)=(ZAEROR(JL)+ZAERSU(JL))*CVDAEL(JK+1)
      ZAEQUN(JL)= ZAERBC(JL)*CVDAEU(JK+1)
      ZAEQDN(JL)= ZAERSD(JL)*CVDAED(JK+1)
    ELSE
      ZAEQSN(JL)=RCAEOPS*ZAES(JL)*CVDAES(JK+1)
      ZAEQLN(JL)=RCAEOPL*ZAEL(JL)*CVDAEL(JK+1)
      ZAEQUN(JL)=RCAEOPU*ZAEU(JL)*CVDAEU(JK+1)
      ZAEQDN(JL)=RCAEOPD*ZAED(JL)*CVDAED(JK+1)
    ENDIF  

    IF (0.5_JPRB*(PAPRS(JL,JK-1)+PAPRS(JL,JK)) < 999._JPRB) THEN
! for models with top above 10hPa
      ZAETRN(JL)=1.0_JPRB
      ZAETRO(JL)=1.0_JPRB
    ELSE
      ZAETRN(JL)=ZAETRO(JL)*(MIN(1.0_JPRB,PTH(JL,JK)/PTH(JL,JK+1)))**RCTRPT
    ENDIF

    ZAETR=SQRT  (ZAETRN(JL)*ZAETRO(JL))
    ZQOFN(JL)=ZOZQ(JL)*ZSDPN3/(ZSDPN3+ZOZH(JL))
    ZDPNMO    =ZDPN(JL)-ZDPO(JL)
    PAER(JL,1,JK)=(1.0_JPRB-ZAETR)*(RCTRBGA*ZDPNMO+ ZAEQLN(JL)-ZAEQLO(JL))
    PAER(JL,2,JK)=(1.0_JPRB-ZAETR)*(ZAEQSN(JL)-ZAEQSO(JL))
    PAER(JL,3,JK)=(1.0_JPRB-ZAETR)*(ZAEQDN(JL)-ZAEQDO(JL))
    PAER(JL,4,JK)=(1.0_JPRB-ZAETR)*(ZAEQUN(JL)-ZAEQUO(JL))
! time variation applied to volcanic sulphate aerosols only - ash is background value
    PAER(JL,5,JK)= ZAETR * RCVOBGA*ZDPNMO
    PAER(JL,6,JK)= ZAETR * ZAERVO(JL)*ZDPNMO
!old RH dependence     
!         AADS(JL,JK)=MAX(RCAEADM, (RCAEADK(1)*PAER(JL,1,JK)
!           + RCAEADK(2)*PAER(JL,2,JK)+RCAEADK(3)*PAER(JL,3,JK))/ZDPNMO)
    POZON(JL,JK)=ZQOFN(JL)-ZQOFO(JL)
!**** **************************************************
!**** **************************************************
  ENDDO
  DO JL=KIDIA,KFDIA
    ZDPO(JL)  =ZDPN(JL)
    ZQOFO(JL) =ZQOFN(JL)
    ZAEQSO(JL)=ZAEQSN(JL)
    ZAEQLO(JL)=ZAEQLN(JL)
    ZAEQUO(JL)=ZAEQUN(JL)
    ZAEQDO(JL)=ZAEQDN(JL)
    ZAETRO(JL)=ZAETRN(JL)
  ENDDO

!-- diagnostics in case of problem  
  DO JAER=1,6
    DO JL=KIDIA,KFDIA
      PAER(JL,JAER,JK)=MAX(PAER(JL,JAER,JK),REPAER)
    ENDDO
  ENDDO   
!  print 9101,JK,PAPRS(JL,JK-1),PAPRS(JL,JK),POZON(JL,JK),(PAER(KIDIA,JAER,JK),JAER=1,6)
9101 format(1x,'radaca ',I3,9E12.5)
ENDDO

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

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