!OPTIONS XOPT(NOEVAL)
SUBROUTINE ACTSEC (KIDIA,KFDIA,KLON,KTDIA,KLEV,&
 !-----------------------------------------------------------------------
 ! - INPUT  2D .
 & PAPHI,PAPHIF,PAPRS,PAPRSF,PQ,PT,PU,PV,&
 ! - INPUT  1D .
 & PQS,PTS,PGZ0,&
 ! - OUTPUT 2D .
 & PKTROV,PKUROV,PXTROV,PXUROV,&
 ! - OUTPUT 1D .
 & PCDROV,PCHROV,&
 & PXDROV,PXHROV,&
 ! - LOCK ARGUMENTS .
 & CDLOCK)  

!**** *ACTSEC* - VERTICAL TURBULENT AND SURFACE EXCHANGE COEFFICIENTS.

!     Subject.
!     --------
!     - COMPUTATION OF VERTICAL TURBULENT EXCHANGE COEFFICIENTS
!       (DIMENSION (DP/(G*DT)) AND OF STATIC STABILITY (DIMENSION
!       (U/DP)**2), AS WELL AS OF THE "ANTI-FIBRILLATION" AMPLIFICATION
!       FACTORS OF THE FORMERS .
!     - COMPUTATION OF SURFACE EXCHANGE COEFFICIENTS PLUS THEIR
!       AMPLIFICATION FACTOR IF "ANTI-FIBRILLATION" IS ACTIVATED .

!**   Interface.
!     ----------
!        *CALL* *ACTSEC*

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

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

! - DIMENSIONAL PARAMETERS OF PHYSICS.

! KIDIA      : START OF HORIZONTAL LOOP (IST in CPG)
! KFDIA      : END OF HORIZONTAL LOOP.
! KLON       : HORIZONTAL DIMENSION.
! KTDIA      : START OF THE VERTICAL LOOP IN THE PHYSICS (1 IN GENERAL)
! KLEV       : END OF VERTICAL LOOP IN THE PHYSICS (1 IN GENERAL)

! - THE NAME OF THE PHYSICAL VARIABLES.

! PAPHI      : GEOPOTENTIAL ON HALF LEVELS.
! PAPRS      : PRESSURE ON HALF LEVELS.

! - 2D (1:KLEV) .

! PAPHIF     : GEOPOTENTIAL ON FULL LEVELS.
! PQ         : SPECIFIC HUMIDITY OF WATER VAPOR.
! PT         : TEMPERATURE.
! PU         : X - COMPONENT OF WIND.
! PV         : Y - COMPONENT OF WIND.

! - 1D (PROGNOSTIC) .

! PTP        : DEEP LAYER TEMPERATURE.
!     (KCSS)
! PTS        : SURFACE TEMPERATURE.
! PQS        : SURFACE SPECIFIC HUMIDITY

! - 1D (GEOGRAPHIC) .

! PGZ0       : GRAVITY * ROUGHNESS LENGTH.

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

! -   ARGUMENTS FOR OUTPUT.
!     ---------------------

! - 2D (0:KLEV) .

! PKTROV     : VERTICAL EXCHANGE COEFFICIENT OF T AND Q IN KG/(M*M*S).
! PKUROV     : VERTICAL EXCHANGE COEFFICIENT OF U AND V IN KG/(M*M*S).
! PXTROV     : "ANTI-FIBRILLATION" MULTIPLICATOR OF PKTROV.
! PXUROV     : "ANTI-FIBRILLATION" MULTIPLICATOR OF PKUROV.

! - 1D (DIAGNOSTIC) .

! PCDROV     : PCD RENORME EN DENSITE FOIS VITESSE.
! PCHROV     : PCH RENORME EN DENSITE FOIS VITESSE.
! PXDROV     : "ANTI-FIBRILLATION" MULTIPLICATOR OF PCDROV.
! PXHROV     : "ANTI-FIBRILLATION" MULTIPLICATOR OF PCHROV.

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

! -   IMPLICIT ARGUMENTS.
!     -------------------

! COMMON/YOMPHY /
! COMMON/YOMCST /
! COMMON/YOMPHY0/
! COMMON/YOMPHY1/
! COMMON/FCTTRM /

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

!     Externals.
!     ----------

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

!     Authors
!     -------
!        see subroutines ACHMT and ACCOEFK

!     Modifications.
!     --------------
!        95-06 - combining subroutines ACHMT and ACCOEFK into one
!             and leaving only necessary comput.for ACDIFSP - M.Janiskova
!        97-08, introduce CDLOCK - J.M. Piriou.
!        97-11, removed smoothing for trajectory - M. Janiskova
!        98-11, adopted modifications for anti-fibrillation and
!               shallow convection as in ACHMT,ACCOEFK - M.Janiskova
!        03-12, introduction of USURID,USURIDE,USURICE,USURICL - C Loo
!        03-12, remove of Girard-Delage anti-fibrillation - C Loo
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        04-06, introduction of EDK for Fm and Fh in stable case - F Bouyssel
!-----------------------------------------------------------------------

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

USE YOMPHY   , ONLY : LCVPP    ,LNEIGE
USE YOMCST   , ONLY : RG       ,RD       ,RV       ,RCPD     ,&
 & RCPV     ,RKAPPA   ,RETV     ,RCW      ,RCS      ,&
 & RLVTT    ,RLSTT    ,RTT      ,RALPW    ,RBETW    ,&
 & RGAMW    ,RALPS    ,RBETS    ,RGAMS    ,RALPD    ,&
 & RBETD    ,RGAMD  
USE YOMPHY0  , ONLY : ALMAV    ,BEDIFV   ,EDB      ,EDC      ,&
 & EDD      ,UHDIFV   ,USURIC   ,VKARMN   ,GRCVPP   ,&
 & USURICL  ,USURICE  ,USURIDE  ,USURID   ,EDK
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 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPHI(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPHIF(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPRS(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPRSF(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PQ(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PT(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PU(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PV(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PQS(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTS(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGZ0(KLON) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PKTROV(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PKUROV(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PXTROV(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PXUROV(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCDROV(KLON) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCHROV(KLON) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PXDROV(KLON) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PXHROV(KLON) 
CHARACTER(LEN=7)  ,INTENT(IN)    :: CDLOCK 
REAL(KIND=JPRB) :: ZLSCPE(KLON,KLEV),ZQSAT(KLON,KLEV),ZLH(KLON,KLEV),ZR(KLON,KLEV)
REAL(KIND=JPRB) :: ZCDNH(KLON),ZDPHI(KLON),ZRTI(KLON),ZSTA(KLON)&
 & ,ZU(KLON),ZRS(KLON),ZSTAB(KLON),ZSTAC(KLON)&
 & ,ZCP(KLON),ZPCD(KLON),ZPCDN(KLON),ZPCH(KLON)&
 & ,ZSTAH(KLON),ZSTACH(KLON)  

INTEGER(KIND=JPIM) :: JLEV, JLON

REAL(KIND=JPRB) :: Z2B, Z3B, Z3BC, Z3BCF, ZAUX, ZCD, ZCH, ZCIS, ZCK, &
 & ZDELTA, ZDID, ZDIDP, ZDIFV, ZDIH, ZDIHP, ZDS, ZDTETA, &
 & ZEPS1, ZESP1, ZEW1, ZGLMT2, ZGLMU2, ZGLT, ZGLU, &
 & ZIS, ZLOI, ZLOS, ZPFD, ZRCVPP, ZRLTLU, &
 & ZRVMD, ZRZD, ZRZH, ZZ, &
 & ZEDIFV, ZDIFT, ZZUSURIC, ZZIXP, ZHS, ZZT, ZPFH, ZUSURIC, &
 & ZUSURID, ZIXP  

REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"

#include "fcttrm.h"

!     CHECK RELIABILITY OF INPUT ARGUMENTS.

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

!*
!     ------------------------------------------------------------------
!     I - AUXILIARY CONSTANTS.

ZRVMD=RV-RD

!*
!     ------------------------------------------------------------------
!     II - COMPUTATION OF DERIVED PARAMETERS AND SECURITY CONSTANT (FOR
!     THE SQUARE OF THE WIND SHEAR).

Z2B=2.0_JPRB*EDB
Z3B=3._JPRB*EDB
Z3BC=3._JPRB*EDB*EDC
Z3BCF=EDB*EDC*VKARMN**2/SQRT(3._JPRB)
ZEDIFV=BEDIFV/SQRT(3._JPRB)
ZRLTLU=1.5_JPRB*EDD
ZDIFV=UHDIFV/(RG*VKARMN)
ZDIFT=ZDIFV/SQRT(3._JPRB)
ZRCVPP=1.0_JPRB/GRCVPP
ZZUSURIC=USURIC*USURICL

IF(USURID == 0.0_JPRB) THEN
  ZEDIFV=BEDIFV
  ZZIXP=1.0_JPRB
ELSE
  ZZIXP=3._JPRB
ENDIF

ZEPS1=1.E-04_JPRB

!*
!     ----------------------------------------------------------------
!     III - COMPUTATION OF SPECIFIC HUMIDITY OF SATURATION AND
!     EFFECTIVE RATIO OF L AND Cp FOR CONDENSATION/EVAPORATION
!     COMPUTATION OF GASS CONSTANT FOR AIR

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

! ZLH       : LATENT HEAT
! ZQSAT     : SPECIFIC HUMIDITY OF SATURATION
! ZLSCPE    : EFFECTIVE RATIO OF L AND Cp FOR CONDENSATION/EVAPORATION
! ZR       : GASS CONSTANT FOR AIR

! - TEMPORARY 1D

! ZCP       : VALUE OF ATMOSPHERIC Cp

DO JLEV=KTDIA,KLEV
  DO JLON=KIDIA,KFDIA

    ZCP(JLON)=RCPD*(1.0_JPRB-PQ(JLON,JLEV))+RCPV*PQ(JLON,JLEV)
    ZR(JLON,JLEV)=RD*(1.0_JPRB-PQ(JLON,JLEV))+RV*PQ(JLON,JLEV)

!     SNOW OPTION DEPENDENT COMPUTATIONS.

    IF (LNEIGE) THEN
      ZDELTA=MAX(0.0_JPRB,SIGN(1.0_JPRB,RTT-PT(JLON,JLEV)))
    ELSE
      ZDELTA=0.0_JPRB
    ENDIF

!     CALL TO THE DEFINED FUNCTION TO COMPUTE LH.

    ZLH(JLON,JLEV)= FOLH (PT(JLON,JLEV),ZDELTA)

!     COMPUTATION OF EFFECTIVE RATIO OF L AND Cp FOR COND./EVAP.

    ZLSCPE(JLON,JLEV)=ZLH(JLON,JLEV)/ZCP(JLON)

!     COMPUTATION OF Qsat(PT)

    ZEW1= FOEW (PT(JLON,JLEV),ZDELTA)
    ZESP1=ZEW1/PAPRSF(JLON,JLEV)
    ZQSAT(JLON,JLEV)= FOQS (ZESP1)

  ENDDO
ENDDO

!*
!     ------------------------------------------------------------------
!     IV - COMPUTATION OF SURFACE EXCHANGE COEFFICIENTS PLUS THEIR
!     AMPLIFICATION  FACTOR IF "ANTI-FIBRILLATION" IS ACTIVATED .

!*
!          COMPUTATION OF THE THICKNESS OF THE SBL (IN GEOPOTENTIAL).

! - TEMPORARY(S) 2D .

! ZDPHI     : GEOPOTENTIAL THICKNESS OF THE SURFACE LEVEL.

DO JLON=KIDIA,KFDIA
  ZDPHI(JLON)=PAPHIF(JLON,KLEV)-PAPHI(JLON,KLEV)
ENDDO

!*
!         SETTING TO A CONSTANT VALUE THE MAXIMUM CONTENT OF THE
!     SURFACE WATER RESERVOIR (HYPER-SIMPLIFIED SOIL PHYSICS).

!*
!          EFFECTIVE CALCULATIONS OF THE SURFACE CHARACTERISTICS.

! - TEMPORARY(S) 1D .

! ZPCDN     : EXCHANGE COEF. AT SURFACE LEVEL IN NEUTRAL CONDITION.
! ZRS       : GASS CONSTANT FOR AIR AT THE SURFACE.

DO JLON=KIDIA,KFDIA

  ZRS(JLON)=RD+ZRVMD*PQS(JLON)

!     GEOMETRIC CALCULATIONS.

  ZRZD=1.0_JPRB+ZDPHI(JLON)/PGZ0(JLON)
  ZPCDN(JLON)=(VKARMN/LOG(ZRZD))**2

!     PRELIMINARY COMPUTATIONS NECESSARY FOR THE DETERMINATION OF
!     EXCHANGE COEFFICIENTS CD AND CH

! - TEMPORARY(S) 1D .

! ZCDNH     : NEUTRAL SURFACE THERMAL EXCHANGE COEFFICIENT.

  ZRZH=ZRZD
  ZCDNH(JLON)=ZPCDN(JLON)
  ZCD=1.0_JPRB
  ZCH=1.0_JPRB

!     WIND SHEAR.

! - TEMPORARY(S) 1D .

! ZU        : SURFACE WIND SPEED.
! ZPCD      : EXCHANGE COEFFICIENT AT SURFACE LEVEL FOR U AND V.

  ZCIS=MAX(ZEPS1,PU(JLON,KLEV)**2+PV(JLON,KLEV)**2)
  ZU(JLON)=SQRT(ZCIS)

!     STABILITY COMPUTATION.

! - TEMPORARY(S) 1D .

! ZRTI      : INVERSE OF R*T.
! ZSTA      : APPROXIMATION OF DELTA(PHI)*DELTA(LN(THETA)).

  ZRTI(JLON)=2.0_JPRB/(ZR(JLON,KLEV)*PT(JLON,KLEV)+RKAPPA*ZDPHI(JLON)&
   & +ZRS(JLON)*PTS(JLON))  
  ZSTA(JLON)=ZDPHI(JLON)*(ZR(JLON,KLEV)*PT(JLON,KLEV)+RKAPPA &
   & *ZDPHI(JLON)-ZRS(JLON)*PTS(JLON))*ZRTI(JLON)  
  ZSTAH(JLON)=ZSTA(JLON)/(1.0_JPRB+ZZIXP*ZZUSURIC&
   & *MAX(0.0_JPRB,ZSTA(JLON))/ZCIS)**(1.0_JPRB/ZZIXP)  
  ZSTA(JLON)=ZSTA(JLON)/(1.0_JPRB+MAX(0.0_JPRB,ZSTA(JLON))*ZZUSURIC/ZCIS)
  ZSTAB(JLON)=MAX(0.0_JPRB,SIGN(1.0_JPRB,ZSTA(JLON)))
  ZSTAC(JLON)=ABS(ZSTA(JLON))
  ZSTACH(JLON)=ABS(ZSTAH(JLON))

!     COMMON COMPUTATIONS FOR MOMENTUM AND ENERGY.

  ZDS=SQRT(ZCIS+(EDD/EDK)*ZSTAC(JLON))
  ZHS=SQRT(ZCIS+EDD*EDK*ZSTACH(JLON))

  ZDIDP=ZU(JLON)+ZCD*Z3BC*ZPCDN(JLON)*SQRT(ZSTAC(JLON)*ZRZD)
  ZDID=1.0_JPRB/ZDIDP

  ZDIHP=ZU(JLON)+ZCH*Z3BC*ZCDNH(JLON)*SQRT(ZSTAC(JLON)*ZRZH)
  ZDIH=1.0_JPRB/ZDIHP

!     COMPUTATIONS FOR MOMENTUM OF CD AND OF ITS PRODUCT BY DENSITY
!     TIME WIND SPEED.

  ZLOS=ZCIS*ZDS/(ZU(JLON)*ZDS+Z2B*ZSTAC(JLON))
  ZLOI=ZU(JLON)-Z2B*ZSTA(JLON)*ZDID
  ZPCD(JLON)=(ZLOI+ZSTAB(JLON)*(ZLOS-ZLOI))*ZPCDN(JLON)/ZU(JLON)

!     THE SAME FOR TEMPERATURE AND HUMIDITY.

  ZLOS=ZCIS**2/(ZU(JLON)*ZCIS+Z3B*ZSTACH(JLON)*ZHS)
  ZLOI=ZU(JLON)-Z3B*ZSTA(JLON)*ZDIH
  ZPCH(JLON)=(ZLOI+ZSTAB(JLON)*(ZLOS-ZLOI))*ZCDNH(JLON)/ZU(JLON)

!     NO ANTI-FIBRILLATION.

  PXDROV(JLON)=1.0_JPRB
  PXHROV(JLON)=1.0_JPRB

ENDDO

!     COMPUTATION OF THE EXCHANGE COEFFICIENTS MULTIPLIED BY DENSITY
!     AND WIND SPEED.

DO JLON=KIDIA,KFDIA
  PCDROV(JLON)=ZPCD(JLON)*ZU(JLON)*PAPRS(JLON,KLEV)*ZRTI(JLON)
  PCHROV(JLON)=ZPCH(JLON)*ZU(JLON)*PAPRS(JLON,KLEV)*ZRTI(JLON)
ENDDO

!*
!     ------------------------------------------------------------------
!     V - COMPUTATION OF VERTICAL EXCHANGE COEFFICIENTS,
!     AS WELL AS OF THE "ANTI-FIBRILLATION" AMPLIFICATION
!     FACTORS OF THE FORMERS .

!*
!          GOING TO GEOPOTENTIAL FOR ASYMPTOTIC MIXING LENGTHS.

ZGLU=RG*ALMAV
ZGLT=ZGLU*ZRLTLU

!*
!           PASSIVE LOOP ON VERTICAL LEVELS.

DO JLEV=KTDIA,KLEV-1

!*
!          EFFECTIVE CALCULATIONS.

  DO JLON=KIDIA,KFDIA

!     GEOMETRIC COMPUTATIONS, THE MULTIPLYING FACTOR ZPFD (POTENTIALLY
!     DIFFERENT OF 1) FOR THE DIFFUSION'S VERTICAL PROFILE DEPENDS UPON
!     THE CHOICE OF UHDIFV AND BEDIFV.

    ZZ=VKARMN*(0.5_JPRB*(PAPHIF(JLON,JLEV)+PAPHIF(JLON,JLEV+1))&
     & -PAPHI(JLON,KLEV)+PGZ0(JLON))  
    ZZT=VKARMN*(0.5_JPRB*(PAPHIF(JLON,JLEV)+PAPHIF(JLON,JLEV+1))&
     & -PAPHI(JLON,KLEV)+PGZ0(JLON))  
    ZPFD=MAX(0.0_JPRB,BEDIFV+(1.0_JPRB-BEDIFV)/(1.0_JPRB+(ZDIFV*ZZ)**2))
    ZPFH=MAX(0.0_JPRB,ZEDIFV+(1.0_JPRB-ZEDIFV)/(1.0_JPRB+(ZDIFT*ZZT)**2))
    ZGLMU2=(ZZ*ZGLU*ZPFD/(ZGLU+ZZ))**2
    ZGLMT2=(ZZT*ZGLT*ZPFH/(ZGLT+ZZT))*(ZZ*ZGLU*ZPFD/(ZGLU+ZZ))
    ZCK=Z3BCF*(ZGLT*ZPFH/(ZGLT+ZZT))*(ZGLU*ZPFD/(ZGLU+ZZ))
    ZDPHI(JLON)=PAPHIF(JLON,JLEV)-PAPHIF(JLON,JLEV+1)

!     WIND SHEAR.

    ZCIS=MAX(ZEPS1,(PU(JLON,JLEV)-PU(JLON,JLEV+1))**2 &
     & +(PV(JLON,JLEV)-PV(JLON,JLEV+1))**2)  
    ZU(JLON)=SQRT(ZCIS)

!     PRELIMINARY STABILITY COMPUTATION.

    ZDTETA=ZR(JLON,JLEV)*PT(JLON,JLEV)-ZR(JLON,JLEV+1)&
     & *PT(JLON,JLEV+1)+RKAPPA*ZDPHI(JLON)  

!     CORRECTION FOR SHALLOW CONVECTION (OPTIONAL).

    IF (LCVPP) THEN
      ZAUX=ZRCVPP*MIN(0.0_JPRB,PQ(JLON,JLEV)-ZQSAT(JLON,JLEV)&
       & -PQ(JLON,JLEV+1)+ZQSAT(JLON,JLEV+1))&
       & *(0.5_JPRB*(ZLSCPE(JLON,JLEV)+ZLSCPE(JLON,JLEV+1)))&
       & *MAX(0.0_JPRB,SIGN(1.0_JPRB,RD*(PQ(JLON,JLEV+1)-PQ(JLON,JLEV))&
       & *(0.5_JPRB*(ZLSCPE(JLON,JLEV)+ZLSCPE(JLON,JLEV+1)))-ZDTETA))  
    ELSE
      ZAUX=0.0_JPRB
    ENDIF

!     STABILITY COMPUTATION.

    ZRTI(JLON)=2.0_JPRB/(ZR(JLON,JLEV)*PT(JLON,JLEV)+ZR(JLON,JLEV+1)&
     & *PT(JLON,JLEV+1))  
    ZSTA(JLON)=ZDPHI(JLON)*(ZDTETA+RD*ZAUX)*ZRTI(JLON)
    ZUSURIC=USURIC*(1.0_JPRB+(USURICL-1.0_JPRB)*((ZGLT*ZPFH)/(ZGLT+ZZT))**USURICE)
    ZUSURID=USURID*(1.0_JPRB+1.0_JPRB/((ZZ*ZDIFV)*(ZZT*ZDIFT)))**USURIDE
    ZIXP=(1.0_JPRB+3._JPRB*ZUSURID*MAX(0.0_JPRB,ZSTA(JLON))/ZCIS) &
     & /(1.0_JPRB+ZUSURID*MAX(0.0_JPRB,ZSTA(JLON))/ZCIS)  
    ZSTAH(JLON)=ZSTA(JLON)/(1.0_JPRB+ZIXP*ZUSURIC &
     & *MAX(0.0_JPRB,ZSTA(JLON))/ZCIS)**(1.0_JPRB/ZIXP)  
    ZSTA(JLON)=ZSTA(JLON)/(1.0_JPRB+MAX(0.0_JPRB,ZSTA(JLON))*ZUSURIC/ZCIS)
    ZIS=MAX(0.0_JPRB,SIGN(1.0_JPRB,ZSTA(JLON)))
    ZSTAC(JLON)=ABS(ZSTA(JLON))
    ZSTACH(JLON)=ABS(ZSTAH(JLON))

!     COMMON COMPUTATIONS FOR MOMENTUM AND ENERGY.

    ZDS=SQRT(ZCIS+(EDD/EDK)*ZSTAC(JLON))
    ZHS=SQRT(ZCIS+EDD*EDK*ZSTACH(JLON))

!     COMPUTATIONS FOR THE WIND COMPONENTS.

    ZLOS=ZCIS*ZDS/(ZU(JLON)*ZDS+Z2B*ZSTAC(JLON))
    ZLOI=ZU(JLON)-Z2B*ZSTA(JLON)/(ZU(JLON)+ZCK*SQRT(ZSTAC(JLON)))
    PKUROV(JLON,JLEV)=(ZLOI+ZIS*(ZLOS-ZLOI))*ZGLMU2 &
     & *PAPRS(JLON,JLEV)*ZRTI(JLON)/ZDPHI(JLON)**2  

!     COMPUTATIONS FOR TEMPERATURE AND HUMIDITY.

    ZLOS=ZCIS**2/(ZU(JLON)*ZCIS+Z3B*ZSTACH(JLON)*ZHS)
    ZLOI=ZU(JLON)-Z3B*ZSTA(JLON)/(ZU(JLON)+ZCK*SQRT(ZSTAC(JLON)))
    PKTROV(JLON,JLEV)=(ZLOI+ZIS*(ZLOS-ZLOI))*ZGLMT2 &
     & *PAPRS(JLON,JLEV)*ZRTI(JLON)/ZDPHI(JLON)**2  

!     NO ANTI-FIBRILLATION.

    PXUROV(JLON,JLEV)=1.0_JPRB
    PXTROV(JLON,JLEV)=1.0_JPRB

  ENDDO

ENDDO

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