!OPTIONS XOPT(NOEVAL)
SUBROUTINE ACRALU ( KIDIA,KFDIA,KLON,KTDIA,KLEV,KJN,&
 !-----------------------------------------------------------------------
 ! - INPUT  2D .
 & PAPRS,PAPRSF,PDELP,PNEB,PQ,PQCO2,PQICE,PQLI,&
 & PQO3,PT,&
 ! - INPUT  1D .
 & PALB,PGEMU,PGELAM,PMU0LU,&
 ! - OUTPUT 1D .
 & PFRSOLU,&
 ! - CONSTANTES .
 & PDAER,&
 ! - LOCK ARGUMENTS .
 & CDLOCK)  

!**** *ACRALU * - FLUX RADIATIFS LUNAIRES .

!     Sujet.
!     ------
!     - ROUTINE DE CALCUL ACTIF .
!       CALCUL DES FLUX RADIATIFS LUNAIRES .
!     - COMPUTATION OF LUNAR RADIATIVE FLUXES 

!**   Interface.
!     ----------
!        *CALL* *ACRALU*

!-----------------------------------------------------------------------
! WARNING: THE ENGLISH VERSION OF VARIABLES' NAMES IS TO BE READ IN THE
!          "APLPAR" CODE.
!-----------------------------------------------------------------------

! -   ARGUMENTS D'ENTREE.
!     -------------------

! - NOM DES PARAMETRES DE DIMENSIONNEMENT DE LA PHYSIQUE.

! KIDIA      : INDICE DE DEPART DES BOUCLES VECTORISEES SUR L'HORIZONT..
! KFDIA      : INDICE DE FIN DES BOUCLES VECTORISEES SUR L'HORIZONTALE.
! KLON       : DIMENSION HORIZONTALE DES TABLEAUX.
! KTDIA      : INDICE DE DEPART DES BOUCLES VERTICALES (1 EN GENERAL).
! KLEV       : DIMENSION VERTICALE DES TABLEAUX "FULL LEVEL".
! KJN        : NOMBRE MAXI DE PLAGES JOUR/NUIT DANS LE VECTEUR.

! - NOM DES VARIABLES DE LA PHYSIQUE (PAR ORDRE ALPHABETIQUE DANS CHAQUE
!   CATEGORIE).

! - 2D (0:KLEV) .

! PAPRS      : PRESSION AUX DEMI-NIVEAUX.
! PQO3       : CONTENU SPECIFIQUE LOCAL EN OZONE.
!        (0) : CONTENU MOYEN AU DESSUS DU MODELE.

! - 2D (1:KLEV) .

! PAPRSF     : PRESSION AUX NIVEAUX DES COUCHES.
! PDELP      : EPAISSEUR EN PRESSION DE LA COUCHE.
! PNEB       : NEBULOSITE PARTIELLE "RADIATIVE".
! PQ         : HUMIDITE SPECIFIQUE DE LA VAPEUR D'EAU.
! PQCO2      : CONTENU SPECIFIQUE LOCAL EN CO2.
! PQICE      : HUMIDITE SPECIFIQUE SOLIDE "RADIATIVE".
! PQLI       : HUMIDITE SPECIFIQUE LIQUIDE "RADIATIVE".
! PT         : TEMPERATURE.

! - 1D (PROGNOSTIQUE) .

! PALB       : ALBEDO DE SURFACE.

! - 1D (DIAGNOSTIQUE) .

! PMU0LU     : COSINUS LOCAL INSTANTANE DE L'ANGLE ZENITHAL LUNAIRE.

! - CONSTANTES .

! PDAER(KLEV): EPAISSEUR OPTIQUE DES AEROSOLS STANDARDS DANS LA COUCHE.

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

! -   ARGUMENTS DE SORTIE.
!     --------------------

! - 1D (DIAGNOSTIQUE) .

! PFRSOLU    : FLUX DE RAYONNEMENT LUNAIRE DESCENDANT EN SURFACE.

! -   LOCALS.
!     --------------------

! - 2D (0:KLEV) .

! ZFRSO      : FLUX DE RAYONNEMENT LUNAIRE.

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

!     Externes.
!     ---------

!     Methode.
!     --------

!     Auteur.
!     -------
!        2004-01 : Y. Bouteloup (From ACRANEB !)

!     Modifications.
!     --------------
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!-----------------------------------------------------------------------

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

USE YOMPHY3  , ONLY : GCA      ,GCB      ,GCC      ,VDP      ,&
 & VNP      ,BSFSA    ,BSFSI    ,BSFSN    ,BSFTA    ,&
 & BSFTI    ,BSFTN    ,EARRT    ,EOASA    ,EOASI    ,&
 & EOASN    ,EOATA    ,EOATI    ,EOATN    ,EODSA    ,&
 & EODSI    ,EODSN    ,EODTA    ,EODTI    ,EODTN    ,&
 & EORAY    ,GCD4     ,GCE4     ,&
 & GIREC1   ,GIREC2   ,GIREC3   ,GIREC4,USAA     ,&
 & USAI     ,USAN     ,USBA     ,USBI     ,USBN  
USE YOMRIP   , ONLY :  RIP0LU

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)    :: KTDIA 
INTEGER(KIND=JPIM)               :: KJN ! Argument NOT used
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPRS(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPRSF(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PDELP(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PNEB(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PQ(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PQCO2(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PQICE(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PQLI(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PQO3(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PT(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PALB(KLON) 
REAL(KIND=JPRB)                  :: PGEMU(KLON) ! Argument NOT used
REAL(KIND=JPRB)                  :: PGELAM(KLON) ! Argument NOT used
REAL(KIND=JPRB)   ,INTENT(IN)    :: PMU0LU(KLON) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFRSOLU(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PDAER(KLEV) 
CHARACTER(LEN=6)  ,INTENT(IN)    :: CDLOCK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ZEO2TI, ZEO2TN, ZEO3, ZEO4, ZEO5,&
 & ZEOSA, ZEOSI, ZEOSN, ZEPS, ZEPS1, ZEPS2,&
 & ZEPS3, ZEPSAL, ZG1, ZG2, ZIEART, ZMD, ZMU0IC, ZMU0IN,&
 & ZP, ZQ, ZRHO, ZRT, ZT2, ZT2I, ZT3, ZT4I,&
 & ZTAU, ZTD1, ZTD4, ZTDETA, ZTDS1, ZTI,&
 & ZWSC, ZWSH, ZWSO, ZWTC, ZWTH, ZWTO,&
 & ZASC,ZDES,ZTES,ZEPSEXC,ZEPSNEB  
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"

!     CHECK RELIABILITY OF INPUT ARGUMENTS.

IF (LHOOK) CALL DR_HOOK('ACRALU',0,ZHOOK_HANDLE)
IF(CDLOCK /= 'ACRALU') CALL ABOR1('BAD NUMBER OF ARGUMENTS!')

!     ------------------------------------------------------------------
!     0 - SET QL AND QI DEFINITIONS TO THEIR VALUE INSIDE THE CLOUD.

ZEPSNEB=1.E-10_JPRB

DO JLEV=KTDIA,KLEV
  DO JLON=KIDIA,KFDIA
    ZQLI(JLON,JLEV)=PQLI(JLON,JLEV)/MAX(ZEPSNEB,PNEB(JLON,JLEV))
    ZQICE(JLON,JLEV)=PQICE(JLON,JLEV)/MAX(ZEPSNEB,PNEB(JLON,JLEV))
  ENDDO
ENDDO

!*
!     ------------------------------------------------------------------
!     I - CALCUL DES PARAMETRES DERIVES, CONSTANTES DE SECURITE (POUR
!     L'EPAISSEUR EN PRESSION DE LA COUCHE "AU DESSUS DU SOMMET DU
!     MODELE", L'HUMIDITE SPECIFIQUE ET LA CORRECTION POUR EVITER UNE
!     SOLUTION ANALYTIQUE RESONNANTE ENTRE RAYONNEMENT PARALLELE ET
!     RAYONNEMENT DIFFUS) AINSI QU'ARGUMENT LIMITE POUR EVITER
!     "L'UNDERFLOW" DANS LES CALCULS DE TRANSMISSION.

!         COMPUTATION OF DERIVED PARAMETERS, SECURITY CONSTANTS (FOR THE
!     PRESSURE THICKNESS OF THE LAYER "ABOVE THE MODEL'S TOP, THE
!     SPECIFIC HUMIDITY AND THE CORRECTION TO AVOID A RESONNANT
!     ANALYTICAL SOLUTION BETWEEN PARALLEL AND SCATTERED RADIATION) AS
!     WELL AS A LIMIT ARGUMENT TO AVOID "UNDERFLOW" IN THE COMPUTATIONS
!     OF TRANSMISSIVITY.

DO JGA=1,6
  ZGAS2B(JGA)=GCA(JGA)/(2.0_JPRB*GCB(JGA))
  ZG4B(JGA)=4._JPRB*GCB(JGA)
ENDDO

ZEO2TA=2.0_JPRB*BSFTA*EODTA
ZEO1TA=ZEO2TA+2.0_JPRB*EOATA
ZEO2TI=2.0_JPRB*BSFTI*EODTI
ZEO1TI=ZEO2TI+2.0_JPRB*EOATI
ZEO2TN=2.0_JPRB*BSFTN*EODTN
ZEO1TN=ZEO2TN+2.0_JPRB*EOATN
ZEO2SA=2.0_JPRB*BSFSA*EODSA
ZEO1SA=ZEO2SA+2.0_JPRB*EOASA
ZEO2SI=2.0_JPRB*BSFSI*EODSI
ZEO1SI=ZEO2SI+2.0_JPRB*EOASI
ZEO2SN=2.0_JPRB*BSFSN*EODSN
ZEO1SN=ZEO2SN+2.0_JPRB*EOASN
ZEOSA=EODSA+EOASA
ZEOSI=EODSI+EOASI
ZEOSN=EODSN+EOASN

ZEPS1=1.E-03_JPRB
ZEPS2=1.E-09_JPRB
ZEPS3=1.E-12_JPRB
ZEPSAL=1.E-04_JPRB

ZARGLI=-250._JPRB

DO JLON=KIDIA,KFDIA
  ZMU0(JLON)=PMU0LU(JLON)
  ZII0(JLON)=RIP0LU
ENDDO

DO JLON=KIDIA,KFDIA
  ZII0(JLON)=ZII0(JLON)
ENDDO

!*
!     ------------------------------------------------------------------
!     III - CALCUL DES EPAISSEURS OPTIQUES GASEUSES. LES CALCULS
!     DESCENDANTS SONT SYMETRIQUES ENTRE SOLAIRE ET THERMIQUE (AU TERME
!     D'ALLONGEMENT PRES) MAIS LES CALCULS MONTANTS (DIFFUS TOUS LES
!     DEUX) SONT POUR UN FLUX SOLAIRE REFLECHI ET UN FLUX THERMIQUE
!     CORRESPONDANT A L'ECHANGE AVEC LA SURFACE.

!           COMPUTATION OF GASEOUS OPTICAL DEPTHS. THE DESCENDING
!     CALCULATIONS ARE SYMETRICAL BETWEEN SOLAR AND THERMAL (EXCEPT FOR
!     THE DIFFUSIVITY FACTOR) BUT THE ASCENDING CALCULATIONS (DIFFUSE IN
!     BOTH CASES) ARE FOR A REFLECTED SOLAR FLUX AND FOR A THERMAL FLUX
!     CORRESPONDING TO THE EXCHANGE WITH THE SURFACE.

! - TEMPORAIRE(S) 2D (1:KLEV) .

! ZDEOS     : EPAISSEUR OPTIQUE "GAZ" DESCENDANTE SOLAIRE.
!            : GASEOUS OPTICAL DEPTH SOLAR DESCENDING.
! ZDEOT     : EPAISSEUR OPTIQUE "GAZ" DESCENDANTE THERMIQUE.
!            : GASEOUS OPTICAL DEPTH THERMAL DESCENDING.
! ZUEOS     : EPAISSEUR OPTIQUE "GAZ" MONTANTE SOLAIRE.
!            : GASEOUS OPTICAL DEPTH SOLAR ASCENDING.
! ZUEOT     : EPAISSEUR OPTIQUE "GAZ" MONTANTE THERMIQUE.
!            : GASEOUS OPTICAL DEPTH THERMAL ASCENDING.

!*
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!     III.1   CALCULS PRELIMINAIRES.

!             PRELIMINARY CALCULATIONS.

!     GEOMETRIE DU RAYONNEMENT.
!     RADIATIVE GEOMETRY.

! - TEMPORAIRE(S) 1D .

! ZDM0I     : DEMI DE L'INVERSE DU COSINUS MODIFIE DE L'ANGLE ZENITHAL.
!            : HALF INVERSE OF THE MODIFIED COSINE OF THE ZENITH ANGLE.

ZMD=0.5_JPRB*EXP(0.5_JPRB)
ZEARRT=EARRT*(EARRT+2.0_JPRB)
ZIEART=1.0_JPRB/EARRT
DO JLON=KIDIA,KFDIA
  ZDM0I(JLON)=0.5_JPRB*(SQRT(ZMU0(JLON)*ZMU0(JLON)+ZEARRT)-ZMU0(JLON))*ZIEART
ENDDO

!*
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!     III.2   SOMMET DE L'ATMOSPHERE DU MODELE (OU VALEUR ARBITRAIREMENT
!     FAIBLE DE LA PRESSION).

!             TOP OF THE MODEL'S ATMOSPHERE (OR ARBITRARILY SMALL
!     PRESSURE VALUE).

! - TEMPORAIRE(S) 1D .

! ZNSH      : QUANTITE D'ABSORBANT NON REDUITE SOLAIRE H2O.
!            : UNREDUCED ABSORBER AMOUNT SOLAR H2O.
! ZNSC      : QUANTITE D'ABSORBANT NON REDUITE SOLAIRE CO2.
!            : UNREDUCED ABSORBER AMOUNT SOLAR CO2.
! ZNSO      : QUANTITE D'ABSORBANT NON REDUITE SOLAIRE O3.
!            : UNREDUCED ABSORBER AMOUNT SOLAR O3.
! ZNTH      : QUANTITE D'ABSORBANT NON REDUITE THERMIQUE H2O.
!            : UNREDUCED ABSORBER AMOUNT THERMAL H2O.
! ZNTC      : QUANTITE D'ABSORBANT NON REDUITE THERMIQUE CO2.
!            : UNREDUCED ABSORBER AMOUNT THERMAL CO2.
! ZNTO      : QUANTITE D'ABSORBANT NON REDUITE THERMIQUE O3.
!            : UNREDUCED ABSORBER AMOUNT THERMAL O3.
! ZRSH      : QUANTITE D'ABSORBANT REDUITE (*P) SOLAIRE H2O.
!            : REDUCED (*P) ABSORBER AMOUNT SOLAR H2O.
! ZRSC      : QUANTITE D'ABSORBANT REDUITE (*P) SOLAIRE CO2.
!            : REDUCED (*P) ABSORBER AMOUNT SOLAR CO2.
! ZRSO      : QUANTITE D'ABSORBANT REDUITE (*P) SOLAIRE O3.
!            : REDUCED (*P) ABSORBER AMOUNT SOLAR O3.
! ZRTH      : QUANTITE D'ABSORBANT REDUITE (*P) THERMIQUE H2O (BANDES).
!            : REDUCED (*P) ABSORBER AMOUNT THERMAL H2O (BANDS).
! ZCTH      : QUANTITE D'ABSORBANT (*P ET *ES) THERMIQUE H2O (CONTINU).
!            : REDUCED (*P AND *ES) ABSORBER AMOUNT THERMAL H2O (CONT.).
! ZRTC      : QUANTITE D'ABSORBANT REDUITE (*P) THERMIQUE CO2.
!            : REDUCED (*P) ABSORBER AMOUNT THERMAL CO2.
! ZRTO      : QUANTITE D'ABSORBANT REDUITE (*P) THERMIQUE O3.
!            : REDUCED (*P) ABSORBER AMOUNT THERMAL O3.
! ZNSOR     : QUANTITE DOUBLE D'OZONE AU DESSUS DU NIVEAU CONSIDERE.
!            : DOUBLED OZONE QUANTITY ABOVE THE CONSIDERED LEVEL.
! ZEOS      : RESULTAT DES CALCULS D'EPAISSEUR OPTIQUE SOLAIRE.
!            : RESULT OF THE SOLAR OPTICAL DEPTH COMPUTATIONS.
! ZEOT      : RESULTAT DES CALCULS D'EPAISSEUR OPTIQUE THERMIQUE.
!            : RESULT OF THE THERMAL OPTICAL DEPTH COMPUTATIONS.
! ZEOSS     : EPAISSEUR OPTIQUE SOLAIRE "AU DESSUS DU MODELE".
!            : SOLAR OPTICAL DEPTH "ABOVE THE MODEL'S TOP".
! ZEOTS     : EPAISSEUR OPTIQUE THERMIQUE "DOWN" "AU DESSUS DU MODELE".
!            : THERM. "DOWNWARDS" OPTICAL DEPTH "ABOVE THE MODEL'S TOP".

DO JLON=KIDIA,KFDIA
  ZNSOR(JLON)=2.0_JPRB*MAX(PAPRS(JLON,0),ZEPS1)*PQO3(JLON,0)
ENDDO
DO JLEV=1,KTDIA-1
  DO JLON=KIDIA,KFDIA
    ZNSOR(JLON)=ZNSOR(JLON)+2.0_JPRB*PDELP(JLON,JLEV)*PQO3(JLON,JLEV)
  ENDDO
ENDDO
DO JLON=KIDIA,KFDIA
  ZP=MAX(ZEPS1,PAPRS(JLON,KTDIA-1))
  ZQ=MAX(ZEPS2,PQ(JLON,KTDIA))
  ZRT=SQRT(PT(JLON,KTDIA))
  ZTI=1.0_JPRB/PT(JLON,KTDIA)
  ZT2=PT(JLON,KTDIA)*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*(ZRTC(JLON)/ZNTC(JLON)))*(SQRT(1.0_JPRB+ZG4B(5)&
   & *ZNTC(JLON)/(ZRTC(JLON)/ZNTC(JLON)))-1.0_JPRB)+GCC(5)&
   & *ZRTC(JLON)  
  ZWTO=(ZGAS2B(6)*(ZRTO(JLON)/ZNTO(JLON)))*(SQRT(1.0_JPRB+ZG4B(6)&
   & *ZNTO(JLON)/(ZRTO(JLON)/ZNTO(JLON)))-1.0_JPRB)+GCC(6)&
   & *ZRTO(JLON)  
  ZEOT(JLON)=(ZWTH*(1.0_JPRB+ZWTH*(VNP(1,4)+ZWTH*(VNP(2,4)+ZWTH*(VNP(3,&
   & 4)&
   & +ZWTH*(VNP(4,4)+ZWTH*VNP(5,4)))))))/(1.0_JPRB+ZWTH*(VDP(1,4)&
   & +ZWTH*(VDP(2,4)+ZWTH*(VDP(3,4)+ZWTH*(VDP(4,4)+ZWTH&
   & *VDP(5,4))))))+(ZWTC*(1.0_JPRB+ZWTC*(VNP(1,5)+ZWTC*(VNP(2,5)&
   & +ZWTC*(VNP(3,5)+ZWTC*(VNP(4,5)+ZWTC*VNP(5,5)))))))/(1.0_JPRB&
   & +ZWTC*(VDP(1,5)+ZWTC*(VDP(2,5)+ZWTC*(VDP(3,5)+ZWTC&
   & *(VDP(4,5)+ZWTC*VDP(5,5))))))+(ZWTO*(1.0_JPRB+ZWTO*(VNP(1,6)&
   & +ZWTO*(VNP(2,6)+ZWTO*(VNP(3,6)+ZWTO*(VNP(4,6)+ZWTO&
   & *VNP(5,6)))))))/(1.0_JPRB+ZWTO*(VDP(1,6)+ZWTO*(VDP(2,6)+ZWTO&
   & *(VDP(3,6)+ZWTO*(VDP(4,6)+ZWTO*VDP(5,6))))))  
  ZEOTS(JLON)=ZEOT(JLON)
ENDDO

!*
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!     III.3   BOUCLE DESCENDANTE SUR LES NIVEAUX VERTICAUX.

!             DESCENDING VERTICAL LOOP ON LAYERS.

! - TEMPORAIRE(S) 1D .

! ZEOSO     : EPAISSEUR OPTIQUE SOLAIRE "OLD" (POUR CALCUL "NEW").
!            : "OLD" SOLAR OPTICAL DEPTH (FOR COMPUTING "NEW" ONE).
! ZEOTO     : EPAISSEUR OPTIQUE THERMIQUE "OLD" (POUR CALCUL "NEW").
!            : "OLD" THERMAL OPTICAL DEPTH (FOR COMPUTING "NEW" ONE).

DO JLEV=KTDIA,KLEV
  DO JLON=KIDIA,KFDIA
    ZEOSO(JLON)=ZEOS(JLON)
  ENDDO
  DO JLON=KIDIA,KFDIA
    ZEOTO(JLON)=ZEOT(JLON)
  ENDDO
  DO JLON=KIDIA,KFDIA
    ZP=PAPRS(JLON,JLEV)
    ZQ=MAX(ZEPS2,PQ(JLON,JLEV))
    ZRT=SQRT(PT(JLON,JLEV))
    ZTI=1.0_JPRB/PT(JLON,JLEV)
    ZT2=PT(JLON,JLEV)*PT(JLON,JLEV)
    ZT2I=ZTI*ZTI
    ZT4I=ZT2I*ZT2I
    ZTDETA=ZRT**49*EXP(GCE4/PT(JLON,JLEV))
    ZT3=ZT2*PT(JLON,JLEV)
    ZDUH=(2.0_JPRB*PDELP(JLON,JLEV))*ZQ
    ZDUC=(2.0_JPRB*PDELP(JLON,JLEV))*PQCO2(JLON,JLEV)
    ZDUO=(2.0_JPRB*PDELP(JLON,JLEV))*PQO3(JLON,JLEV)
    ZNSH(JLON)=ZNSH(JLON)+ZDUH*ZDM0I(JLON)
    ZNSC(JLON)=ZNSC(JLON)+ZDUC*ZDM0I(JLON)
    ZNSO(JLON)=ZNSO(JLON)+ZDUO*ZDM0I(JLON)
    ZNTH(JLON)=ZNTH(JLON)+ZDUH*ZTI
    ZNTC(JLON)=ZNTC(JLON)+ZDUC
    ZNTO(JLON)=ZNTO(JLON)+ZDUO*ZT2
    ZDUH=ZDUH*(ZMD*PAPRSF(JLON,JLEV))*ZRT
    ZDUC=ZDUC*(ZMD*PAPRSF(JLON,JLEV))*PT(JLON,JLEV)
    ZD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(3,4)+ZWTH*(VDP(4,4)+ZWTH&
     & *VDP(5,4))))))+(ZWTC*(1.0_JPRB+ZWTC*(VNP(1,5)+ZWTC*(VNP(2,5)&
     & +ZWTC*(VNP(3,5)+ZWTC*(VNP(4,5)+ZWTC*VNP(5,5)))))))/(1.0_JPRB&
     & +ZWTC*(VDP(1,5)+ZWTC*(VDP(2,5)+ZWTC*(VDP(3,5)+ZWTC&
     & *(VDP(4,5)+ZWTC*VDP(5,5))))))+(ZWTO*(1.0_JPRB+ZWTO*(VNP(1,6)&
     & +ZWTO*(VNP(2,6)+ZWTO*(VNP(3,6)+ZWTO*(VNP(4,6)+ZWTO&
     & *VNP(5,6)))))))/(1.0_JPRB+ZWTO*(VDP(1,6)+ZWTO*(VDP(2,6)+ZWTO&
     & *(VDP(3,6)+ZWTO*(VDP(4,6)+ZWTO*VDP(5,6))))))  
    ZDEOT(JLON,JLEV)=ZEOT(JLON)-ZEOTO(JLON)
  ENDDO
ENDDO

!*
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!     III.4   CONDITION A LA SURFACE POUR LES CALCULS THERMIQUES.

!             SURFACE CONDITION FOR THE THERMAL CALCULATIONS.

DO JLON=KIDIA,KFDIA
  ZEOT(JLON)=0.0_JPRB
  ZNTH(JLON)=0.0_JPRB
  ZNTC(JLON)=0.0_JPRB
  ZNTO(JLON)=0.0_JPRB
  ZRTH(JLON)=0.0_JPRB
  ZCTH(JLON)=0.0_JPRB
  ZRTC(JLON)=0.0_JPRB
  ZRTO(JLON)=0.0_JPRB
ENDDO

!*
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!     III.5   BOUCLE ASCENDANTE SUR LES NIVEAUX VERTICAUX.

!             ASCENDING VERTICAL LOOP ON LAYERS.

DO JLEV=KLEV,KTDIA,-1
  DO JLON=KIDIA,KFDIA
    ZEOSO(JLON)=ZEOS(JLON)
  ENDDO
  DO JLON=KIDIA,KFDIA
    ZEOTO(JLON)=ZEOT(J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(3,6)+ZWTO*(VDP(4,6)+ZWTO*VDP(5,6))))))  
    ZASC=ZDEOT(JLON,JLEV)
    ZDES=ZEOT(JLON)-ZEOTO(JLON)
    ZTES=MAX(0.0_JPRB,SIGN(1.0_JPRB,ZASC-ZDES))
    ZEPSEXC=(GIREC1+ZTES*GIREC3)&
     & *(MIN(ZASC,ZDES)/MAX(ZASC,ZDES))**(GIREC2+ZTES*GIREC4)  
    ZUEOT(JLON,JLEV)=MAX(ZASC,ZDES)*(MIN(ZASC,ZDES)/MAX(ZASC,ZDES))&
     & **(1.0_JPRB-ZEPSEXC)  
    ZUUEOT(JLON,JLEV)=ZDES
  ENDDO
ENDDO

!*
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!     III.6   SOMMET DE L'ATMOSPHERE DU MODELE (OU VALEUR ARBITRAIREMENT
!     FAIBLE DE LA PRESSION) POUR LES CALCULS THERMIQUES D'ECHANGE ENTRE
!     COUCHES.

!             TOP OF THE MODEL'S ATMOSPHERE (OR ARBITRARILY SMALL
!     PRESSURE VALUE) FOR THERMAL "EXCHANGE BETWEEN LAYERS"
!     COMPUTATIONS.

! - TEMPORAIRE(S) 1D .

! ZUETS     : EPAISSEUR OPTIQUE THERMIQUE "UP" "AU DESSUS DU MODELE".
!            : "UPWARDS" THERMAL OPTICAL DEPTH ABOVE THE MODEL'S TOP.

DO JLON=KIDIA,KFDIA
  ZEOTO(JLON)=ZEOT(JLON)
ENDDO
DO JLON=KIDIA,KFDIA
  ZP=MAX(ZEPS1,PAPRS(JLON,KTDIA-1))
  ZQ=MAX(ZEPS2,PQ(JLON,KTDIA))
  ZRT=SQRT(PT(JLON,KTDIA))
  ZTI=1.0_JPRB/PT(JLON,KTDIA)
  ZT2=PT(JLON,KTDIA)*PT(JLON,KTDIA)
  ZT2I=ZTI*ZTI
  ZT4I=ZT2I*ZT2I
  ZTDETA=ZRT**49*EXP(GCE4/PT(JLON,KTDIA))
  ZT3=ZT2*PT(JLON,KTDIA)
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ZWTH*VNP(5,4)))))))/(1.0_JPRB+ZWTH*(VDP(1,4)&
   & +ZWTH*(VDP(2,4)+ZWTH*(VDP(3,4)+ZWTH*(VDP(4,4)+ZWTH&
   & *VDP(5,4))))))+(ZWTC*(1.0_JPRB+ZWTC*(VNP(1,5)+ZWTC*(VNP(2,5)&
   & +ZWTC*(VNP(3,5)+ZWTC*(VNP(4,5)+ZWTC*VNP(5,5)))))))/(1.0_JPRB&
   & +ZWTC*(VDP(1,5)+ZWTC*(VDP(2,5)+ZWTC*(VDP(3,5)+ZWTC&
   & *(VDP(4,5)+ZWTC*VDP(5,5))))))+(ZWTO*(1.0_JPRB+ZWTO*(VNP(1,6)&
   & +ZWTO*(VNP(2,6)+ZWTO*(VNP(3,6)+ZWTO*(VNP(4,6)+ZWTO&
   & *VNP(5,6)))))))/(1.0_JPRB+ZWTO*(VDP(1,6)+ZWTO*(VDP(2,6)+ZWTO&
   & *(VDP(3,6)+ZWTO*(VDP(4,6)+ZWTO*VDP(5,6))))))  
  ZEPSEXC=(GIREC1+GIREC3)*((ZEOT(JLON)&
   & -ZEOTO(JLON))/ZEOTS(JLON))**(GIREC2+GIREC4)  
  ZUETS(JLON)=ZEOTS(JLON)*((ZEOT(JLON)-ZEOTO(JLON))/ZEOTS(JLON))&
   & **(1.0_JPRB-ZEPSEXC)  
  ZUUETS(JLON)=ZEOT(JLON)-ZEOTO(JLON)
ENDDO

!*

DO JLEV=KTDIA,KLEV
  DO JLON=KIDIA,KFDIA
    ZB1(JLON,JLEV)=1.0_JPRB-PNEB(JLON,JLEV)
  ENDDO
ENDDO

!*
!     ------------------------------------------------------------------
!     VIII - CALCUL DES TABLEAUX DEPENDANTS DE L'ANGLE SOLAIRE ET DE
!     L'ALBEDO EFFECTIF DE SURFACE.

!            COMPUTATION OF THE SOLAR ANGLE DEPENDENT ARRAYS AND OF THE
!     EFFECTIVE SURFACE ALBEDO.

!     INVERSE DU COSINUS DE L'ANGLE ZENITHAL ET "UPSCATTERED FRACTIONS".
!     INVERSE OF THE COSINE OF THE ZENITH ANGLE AND UPSCATTERED
!     FRACTIONS.

! - TEMPORAIRE(S) 1D .

! ZMU0I     : INVERSE DU COSINUS MODIFIE DE L'ANGLE ZENITHAL.
!            : INVERSE OF THE MODIFIED COSINE OF THE ZENITH ANGLE.
! ZUSA      : "UPSCATTERED FRACTION" POUR LES AEROSOLS.
!            : AEROSOLS' UPSCATTERED FRACTION.
! ZUSI      : "UPSCATTERED FRACTION" POUR LES NUAGES DE GLACE.
!            : ICE CLOUDS' UPSCATTERED FRACTION.
! ZUSN      : "UPSCATTERED FRACTION" POUR LES NUAGES.
!            : CLOUDS' UPSCATTERED FRACTION.

DO JLON=KIDIA,KFDIA
  ZMU0I(JLON)=2.0_JPRB*ZDM0I(JLON)
  ZUSA(JLON)=(0.5_JPRB+USAA*ZMU0(JLON))/(1.0_JPRB+USBA*ZMU0(JLON))
  ZUSI(JLON)=(0.5_JPRB+USAI*ZMU0(JLON))/(1.0_JPRB+USBI*ZMU0(JLON))
  ZUSN(JLON)=(0.5_JPRB+USAN*ZMU0(JLON))/(1.0_JPRB+USBN*ZMU0(JLON))
ENDDO

!*
!     ------------------------------------------------------------------
!     IX - CALCUL DES FLUX SOLAIRES PAR ELIMINATION/SUBSTITUTION.

!          SOLAR FLUXES' CALCULATION BY ELIMINATION/BACK-SUBSTITUTION.

!*
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!     IX.1   SOMMET DE L'ATMOSPHERE.

!            TOP OF THE ATMOSPHERE.

DO JLON=KIDIA,KFDIA
  ZFPC(JLON,KTDIA-1)=ZII0(JLON)*ZMU0(JLON)*EXP(MAX(-0.5_JPRB*ZMU0I(JLON)&
   & *ZEOSS(JLON),ZARGLI))  
  ZFDC(JLON,KTDIA-1)=0.0_JPRB
ENDDO

!*
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!     IX.2   PREMIERE COUCHE : CALCUL DES EPAISSEURS OPTIQUES, DES
!     TRANSMISSIVITES/REFLECTIVITES ET DES COEFFICIENTS LOCAUX DE
!     GEOMETRIE NUAGEUSE.

!            FIRST LAYER : COMPUTATION OF THE OPTICAL DEPTHS, OF THE
!     TRANSMISSIVITIES/REFLECTIVITIES AND OF THE LOCAL COEFFICIENTS FOR
!     THE CLOUD GEOMETRY.

DO JLON=KIDIA,KFDIA
  ZEO1=ZUEOS(JLON,KTDIA)+ZEO1SA*PDAER(KTDIA)+(EORAY*PDELP(JLON,KTDIA))
  ZEO2=ZEO2SA*PDAER(KTDIA)+(EORAY*PDELP(JLON,KTDIA))
  ZEPS=SQRT(ZEO1*ZEO1-ZEO2*ZEO2)
  ZTAU=EXP(MAX(-ZEPS,ZARGLI))
  ZRHO=ZEO2/(ZEO1+ZEPS)
  ZA4C(JLON)=ZTAU*(1.0_JPRB-(ZRHO*ZRHO))*(1.0_JPRB/(1.0_JPRB-(ZRHO*ZRHO)*(ZTAU&
   & *ZTAU)))  
  ZA5C(JLON)=ZRHO*(1.0_JPRB-(ZTAU*ZTAU))*(1.0_JPRB/(1.0_JPRB-(ZRHO*ZRHO)*(ZTAU&
   & *ZTAU)))  
  ZEO=0.5_JPRB*ZDEOS(JLON,KTDIA)+ZEOSA*PDAER(KTDIA)+(EORAY*PDELP(JLON,KTDIA))
  ZMU0IC=(ZEPS/ZEO)+SIGN(MAX(ABS(ZMU0I(JLON)-(ZEPS&
   & /ZEO)),ZEPS3),(ZMU0I(JLON)-(ZEPS/ZEO)))  
  ZEO3=((EODSA*PDAER(KTDIA))*ZUSA(JLON)+(0.5_JPRB*(EORAY&
   & *PDELP(JLON,KTDIA))))*ZMU0IC  
  ZEO4=((EODSA*PDAER(KTDIA))*(1.0_JPRB-ZUSA(JLON))+(0.5_JPRB*(EORAY&
   & *PDELP(JLON,KTDIA))))*ZMU0IC  
  ZEO5=ZEO*ZMU0IC
  ZA1C(JLON)=EXP(MAX(-ZEO5,ZARGLI))
  ZG1=(ZEO3*(ZEO5-ZEO1)-ZE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ZUSI(JLON)*((PDELP(JLON,KTDIA)&
   & *ZQICE(JLON,KTDIA))*EODSI))*ZMU0IN  
  ZEO4=(ZEO4/ZMU0IC+(1.0_JPRB-ZUSN(JLON))*((PDELP(JLON,KTDIA)&
   & *ZQLI(JLON,KTDIA))*EODSN)&
   & +(1.0_JPRB-ZUSI(JLON))*((PDELP(JLON,KTDIA)&
   & *ZQICE(JLON,KTDIA))*EODSI))*ZMU0IN  
  ZEO5=ZEO*ZMU0IN
  ZA1N(JLON)=EXP(MAX(-ZEO5,ZARGLI))
  ZG1=(ZEO3*(ZEO5-ZEO1)-ZEO2*ZEO4)*(1.0_JPRB/(ZEO5*ZEO5-ZEPS*ZEPS))
  ZG2=-(ZEO4*(ZEO5+ZEO1)+ZEO2*ZEO3)*(1.0_JPRB/(ZEO5*ZEO5-ZEPS*ZEPS))
  ZA2N(JLON)=ZG2*(ZA1N(JLON)-ZA4N(JLON))-ZG1*ZA5N(JLON)*ZA1N(JLON)
  ZA3N(JLON)=ZG1*(1.0_JPRB-ZA4N(JLON)*ZA1N(JLON))-ZG2*ZA5N(JLON)

  ZA1C(JLON)=ZA1C(JLON)*ZB1(JLON,KTDIA)+ZA1N(JLON)*PNEB(JLON,KTDIA)
  ZA2C(JLON)=ZA2C(JLON)*ZB1(JLON,KTDIA)+ZA2N(JLON)*PNEB(JLON,KTDIA)
  ZA3C(JLON)=ZA3C(JLON)*ZB1(JLON,KTDIA)+ZA3N(JLON)*PNEB(JLON,KTDIA)
  ZA4C(JLON)=ZA4C(JLON)*ZB1(JLON,KTDIA)+ZA4N(JLON)*PNEB(JLON,KTDIA)
  ZA5C(JLON)=ZA5C(JLON)*ZB1(JLON,KTDIA)+ZA5N(JLON)*PNEB(JLON,KTDIA)

ENDDO

!*
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!     IX.3   PREMIERE COUCHE, ELIMINATION (SANS PROBLEMES).

!            FIRST LAYER, ELIMINATION (EASY).

DO JLON=KIDIA,KFDIA
  ZFMC(JLON,KTDIA-1)=ZA3C(JLON)*ZFPC(JLON,KTDIA-1)
  ZFPC(JLON,KTDIA)=ZA1C(JLON)*ZFPC(JLON,KTDIA-1)
  ZFDC(JLON,KTDIA)=ZA2C(JLON)*ZFPC(JLON,KTDIA-1)
  ZTU2(JLON,KTDIA)=ZA4C(JLON)
  ZTU6(JLON,KTDIA)=ZA5C(JLON)
ENDDO

!*
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!     IX.4   BOUCLE SUR LES NIVEAUX, CALCULS PRELIMINAIRES PUIS
!     ELIMINATION.

!            LOOP OVER THE LAYERS, PRELIMINARY COMPUTATIONS AND THEN
!     ELIMINATION.

DO JLEV=KTDIA+1,KLEV
  DO JLON=KIDIA,KFDIA
    ZEO1=ZUEOS(JLON,JLEV)+ZEO1SA*PDAER(JLEV)+(EORAY*PDELP(JLON,JLEV))
    ZEO2=ZEO2SA*PDAER(JLEV)+(EORAY*PDELP(JLON,JLEV))
    ZEPS=SQRT(ZEO1*ZEO1-ZEO2*ZEO2)
    ZTAU=EXP(MAX(-ZEPS,ZARGLI))
    ZRHO=ZEO2/(ZEO1+ZEPS)
    ZA4C(JLON)=ZTAU*(1.0_JPRB-(ZRHO*ZRHO))*(1.0_JPRB/(1.0_JPRB-(ZRHO*ZRHO)*(ZTAU&
     & *ZTAU)))  
    ZA5C(JLON)=ZRHO*(1.0_JPRB-(ZTAU*ZTAU))*(1.0_JPRB/(1.0_JPRB-(ZRHO*ZRHO)*(ZTAU&
     & *ZTAU)))  
    ZEO=0.5_JPRB*ZDEOS(JLON,JLEV)+ZEOSA*PDAER(JLEV)+(EORAY*PDELP(JLON,JLEV))
    ZMU0IC=(ZEPS/ZEO)+SIGN(MAX(ABS(ZMU0I(JLON)-(ZEPS&
     & /ZEO)),ZEPS3),(ZMU0I(JLON)-(ZEPS/ZEO)))  
    ZEO3=((EODSA*PDAER(JLEV))*ZUSA(JLON)+(0.5_JPRB*(EORAY&
     & *PD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*ZB1(JLON,JLEV)+ZA5N(JLON)*PNEB(JLON,JLEV)

  ENDDO
  DO JLON=KIDIA,KFDIA
    ZTD1=1.0_JPRB/(1.0_JPRB-ZA5C(JLON)*ZTU6(JLON,JLEV-1))
    ZFMC(JLON,JLEV-1)=ZTD1*(ZA5C(JLON)*ZFDC(JLON,JLEV-1)&
     & +ZA3C(JLON)*ZFPC(JLON,JLEV-1))  
    ZTU2(JLON,JLEV)=ZTD1*ZA4C(JLON)
  ENDDO
  DO JLON=KIDIA,KFDIA
    ZFPC(JLON,JLEV)=ZA1C(JLON)*ZFPC(JLON,JLEV-1)
    ZTD4=ZA4C(JLON)*ZTU6(JLON,JLEV-1)
    ZFDC(JLON,JLEV)=ZA4C(JLON)*ZFDC(JLON,JLEV-1)+ZTD4&
     & *ZFMC(JLON,JLEV-1)+ZA2C(JLON)&
     & *ZFPC(JLON,JLEV-1)  
    ZTU6(JLON,JLEV)=ZA5C(JLON)+ZTD4*ZTU2(JLON,JLEV)
  ENDDO
ENDDO

!*
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!     IX.5   TRAITEMENT EN SURFACE.

!            SURFACE TREATMENT.

DO JLON=KIDIA,KFDIA
  ZAL=PALB(JLON)
  ZALP=(1.0_JPRB+0.5_JPRB*(ZMU0(JLON)*(1.0_JPRB/ZAL-&
   & 1.0_JPRB)))/(1.0_JPRB+(ZMU0(JLON)*(1.0_JPRB/ZAL&
   & -1.0_JPRB)))**2  
  ZTDS1=1.0_JPRB/(1.0_JPRB-ZAL*ZTU6(JLON,KLEV))
  ZFMC(JLON,KLEV)=ZTDS1*(ZAL*ZFDC(JLON,KLEV)+ZALP*ZFPC(JLON,KLEV))
ENDDO

!*
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!     IX.6   SUBSTITUTION NIVEAU PAR NIVEAU.

!            BACK-SUBSTITUTION LAYER BY LAYER.

DO JLEV=KLEV,KTDIA,-1
  DO JLON=KIDIA,KFDIA
    ZFDC(JLON,JLEV)=ZFDC(JLON,JLEV)+ZTU6(JLON,JLEV)*ZFMC(JLON,JLEV)
    ZFMC(JLON,JLEV-1)=ZFMC(JLON,JLEV-1)+ZTU2(JLON,JLEV)*ZFMC(JLON,JLEV)
  ENDDO
ENDDO

!*
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!     IX.7   CALCUL DES FLUX.

!            FLUXES' COMPUTATION.

DO JLEV=KTDIA-1,KLEV

!     MISE A ZERO DES FLUX EN SECURITE POUR LE CAS NOCTURNE.
!     SETTING FLUXES TO ZERO FOR SECURITY IN THE NIGHT-TIME CASE.

  DO JLON=KIDIA,KFDIA
    ZFRSO(JLON,JLEV)=0.0_JPRB
  ENDDO

!     CALCUL EFFECTIF.
!     ACTUAL COMPUTATION.

  DO JLON=KIDIA,KFDIA
    ZFRSO(JLON,JLEV)=ZFPC(JLON,JLEV)+ZFDC(JLON,JLEV)-ZFMC(JLON,JLEV)
  ENDDO
ENDDO

!     PAS DE DIVERGENCE DES FLUX AU DESSUS DE KTDIA.
!     NO FLUX DIVERGENCE ABOVE KTDIA.

DO JLEV=0,KTDIA-2
  DO JLON=KIDIA,KFDIA
    ZFRSO(JLON,JLEV)=ZFRSO(JLON,KTDIA-1)
  ENDDO
ENDDO

DO JLON=KIDIA,KFDIA
  PFRSOLU(JLON)=1.0_JPRB/(MAX(ZEPSAL,1.0_JPRB-PALB(JLON)))*ZFRSO(JLON,KLEV)
ENDDO

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

