!OPTIONS XOPT(NOEVAL)
SUBROUTINE APLPARSADT ( KIDIA, KFDIA, KLON, KTDIA, KLEV,&
 & KSGST  , KSTEP  ,&
 !---------------------------------------------------------------------
 ! - INPUT .
 & PAPHI5 , PAPRS5 , PAPHIF5, PAPRSF5, PDELP5 , PRDELP5,&
 & PU5    , PV5    , PT5    , PQ5    , PCP5   , PCVGQ5 ,&
 & PSNS   , PTS    , PQS    , PTS1   , PQS1   ,&
 & PGETRL , PLSM   , PVEG   , PGZ0F  , PVRLAN , PVRLDI ,&
 & PALBF  , PEMISF , PMU0   , PGM    ,&
 & PAC    , PCOR   ,&
 & PRAB3C , PRAB3N , PRAB4C , PRAB4N , PRAB6C , PRAB6N ,&
 & PRAT1C , PRAT1N , PRAT2C , PRAT2N , PRAT3C , PRAT3N ,&
 & PRAT4C , PRAT4N , PRAT5C , PRAT5N ,&
 ! - OUTPUT .
 & PDIFCQ5, PDIFCS5, PDIFTQ5, PDIFTS5,&
 & PFCCQL5, PFCCQN5, PFCSQL5, PFCSQN5,&
 & PFPLCL5, PFPLCN5, PFPLSL5, PFPLSN5, PFRSO5 , PFRTH5 ,&
 & PSTRCU5, PSTRCV5, PSTRDU5, PSTRDV5, PSTRTU5, PSTRTV5,&
 & PKTROV5, PKUROV5, PXTROV5, PXUROV5,&
 & PCDROV5, PCHROV5, PXDROV5, PXHROV5,&
 & PSTRMU5, PSTRMV5, PFRMH5 ,&
 ! - LOCK ARGUMENTS .
 & CDLOCK)  

!**** *APLPARSADT - COMPUTATION OF TRAJECTORIES OF CALLING THE
!                   SIMPLIFIED PHYSICAL PARAMETRIZATIONS.

!     Subject.
!     --------
!     - CALL THE SUBROUTINES FOR COMPUTATION OF TRAJECTORIES OF THE
!       SIMPLIFIED PHYSICAL PARAMETRIZATIONS.

!**   Interface.
!     ----------
!        *CALL* *APLPARSADT*

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

! -   INPUT ARGUMENTS.
!     -------------------

! - DIMENSIONAL PARAMETERS.

! KIDIA, KFDIA : START/END OF HORIZONTAL LOOP  (IST,IEND IN *CPG*).
! KLON : HORIZONTAL DIMENSION                  (NPROMA IN *CPG*).
! KTDIA : START OF THE VERTICAL LOOP IN THE PHYSICS (IF SOME LEVELS ARE
!                      SKIPPED AT THE TOP OF THE MODEL).
! KLEV  : END OF VERTICAL LOOP AND VERTICAL DIMENSION (NFLEVG IN *CPG*)
! KSGST : NUMBER OF SUBGRID SURFACE TEMPERATURES AND FLUXES
!                      (NTSSG IN *CPG*)

! - THE NAMES OF THE PHYSICAL VARIABLES - trajectories

! - 2D (0:KLEV) .

! PAPHI5     : GEOPOTENTIAL ON HALF-LEVELS.
! PAPRS5     : PRESSURE ON HALF-LEVELS.

! - 2D (1:KLEV) .

! PAPHIF5    : GEOPOTENTIAL ON FULL LEVELS.
! PAPRSF5    : PRESSURE ON FULL LEVELS.
! PDELP5     : LAYER THICKNESS IN PRESSURE UNITS.
! PRDELP5    : INVERSE OF PDELP.
! PU5        : X-COMPONENT OF WIND.
! PV5        : Y-COMPONENT OF WIND.
! PT5        : TEMPERATURE.
! PQ5        : SPECIFIC HUMIDITY OF WATER VAPOUR.
! PCP5       : SPECIFIC HEAT AT CONSTANT PRESSURE FOR AIR.
! PCVGQ5     : CONVERGENCE OF HUMIDITY.

! ----------------
! - 1D (PROGNOSTIC QUANTITIES) .

! PSNS       : MASS OF SNOW PER UNIT SURFACE.
! PTS        : SURFACE LAYER TEMPERATURE.
! PQS        : SURFACE SPECIFIC HUMIDITY.

! - 1D (GEOGRAPHICAL DISTRIBUTION) .

! PGETRL     : STANDARD DEVIATION OF OROGRAPHY  (UNIT: J/KG).
! PLSM       : LAND/SEA MASK.
! PVEG       : FRACTIONAL COVER BY VEGETATION.
! PVRLAN     : ANISOTROPY OF THE RELIEF (1 = ISOTROPY).
! PVRLDI     : ANGLE OF MAXIMAL GRADIENT OF RELIEF WITH x-AXIS.
! PGZ0F      : GRAVITY * ROUGHNESS LENGTH (TIME VARIABLE).
! PALBF      : BACKGROUND SURFACE SHORTWAVE ALBEDO (SNOW-FREE).
! PEMISF     : BACKGROUND SURFACE LONGWAVE EMISSIVITY (SNOW-FREE).

! - 1D (DIAGNOSTIC QUANTITIES).

! PMU0       : LOCAL COSINE OF INSTANTENOUS SOLAR ZENITH ANGLE.
! PNEBH      : CONVECTIVE CLOUDINESS.

! - CONSTANTES

! PAC       : COURTIS MATRIX FOR THERMAL RADIATION FOR CLEAR SKY
! PCOR      : CORRECTION FOR CLOUDINESS FOR THERMAL RADIATION

! PRAB3C    : CLEAR-SKY PARALLEL/DIFFUSE REFLECTIVITY.  ---
! PRAB4C    : CLEAR-SKY DIFFUSE TRANSMISSIVITY.            | equivalent
! PRAB6C    : CLEAR-SKY DIFFUSE REFLECTIVITY.              | coefficients
! PRAB3N    : CLOUDY PARALLEL/DIFFUSE REFLECTIVITY.        | from bottom
! PRAB4N    : CLOUDY DIFFUSE TRANSMISSIVITY.               | to given
! PRAB6N    : CLOUDY DIFFUSE REFLECTIVITY.              ---  level

! PRAT1C    : CLEAR-SKY PARALLEL TRANSMISSIVITY.        ---
! PRAT2C    : CLEAR-SKY PARALLEL/DIFFUSE TRANSMISSIVITY.   |
! PRAT3C    : CLEAR-SKY PARALLEL/DIFFUSE REFLECTIVITY.     |
! PRAT4C    : CLEAR-SKY DIFFUSE TRANSMISSIVITY.            | equivalent
! PRAT5C    : CLEAR-SKY DIFFUSE REFLECTIVITY.              | coefficients
! PRAT1N    : CLOUDY PARALLEL TRANSMISSIVITY.              | from top
! PRAT2N    : CLOUDY PARALLEL/DIFFUSE TRANSMISSIVITY.      | to given
! PRAT3N    : CLOUDY PARALLEL/DIFFUSE REFLECTIVITY.        | level
! PRAT4N    : CLOUDY DIFFUSE TRANSMISSIVITY.               |
! PRAT5N    : CLOUDY DIFFUSE REFLECTIVITY.              ---

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

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

! - THE NAMES OF THE PHYSICAL VARIABLES - trajectories

! - 2D (0:KLEV) .

! PDIFCQ5    : CONVECTIVE FLUX OF SPECIFIC HUMIDITY (NOT RAIN/SNOW).
! PDIFCS5    : CONVECTIVE FLUX OF ENTHALPY (NOT RAIN/SNOW).
! PDIFTQ5    : TURBULENT FLUX (INC. Q NEGATIVE) OF SPECIFIC HUMIDITY.
! PDIFTS5    : TURBULENT FLUX OF ENTHALPY (OR DRY STATIC ENERGY).
! PFCCQN5    : CONVECTIVE CONDENSATION FLUX FOR ICE.
! PFCCQL5    : CONVECTIVE CONDENSATION FLUX FOR LIQUID WATER.
! PFPLCL5    : CONVECTIVE PRECIPITATION AS RAIN.
! PFPLCN5    : CONVECTIVE PRECIPITATION AS SNOW.
! PFPLSL5    : STRATIFORM PRECIPITATION AS RAIN.
! PFPLSN5    : STRATIFORM PRECIPITATION AS SNOW.
! PFRSO5     : SHORTWAVE RADIATIVE FLUX.
! PFRTH5     : LONGWAVE RADIATIVE FLUX.
! PFCSQN5    : STRATIFORM CONDENSATION FLUX FOR ICE.
! PFCSQL5    : STRATIFORM CONDENSATION FLUX FOR LIQUID WATER.
! PSTRCU5    : CONVECTIVE FLUX OF MOMENTUM "U".
! PSTRCV5    : CONVECTIVE FLUX OF MOMENTUM "V".
! PSTRDU5    : GRAVITY WAVE DRAG FLUX "U".
! PSTRDV5    : GRAVITY WAVE DRAG FLUX "V".
! PSTRTU5    : TURBULENT FLUX OF MOMENTUM "U".
! PSTRTV5    : TURBULENT FLUX OF MOMENTUM "V".
! PSTRMU5    : MESOSPHERIC FLUX FOR "U"-MOMENTUM.
! PSTRMV5    : MESOSPHERIC FLUX FOR "V"-MOMENTUM.
! PFRMH5     : MESOSPHERIC ENTHALPY FLUX.

!  The trajectory 2D (0:KLEV)
!  --------------------------
! PKTROV5    : VERTICAL EXCHANGE COEFFICIENT OF T AND Q IN KG/(M*M*S).
! PKUROV5    : VERTICAL EXCHANGE COEFFICIENT OF U AND V IN KG/(M*M*S).
! PXTROV5    : "ANTI-FIBRILLATION" MULTIPLICATOR OF PKTROV.
! PXUROV5    : "ANTI-FIBRILLATION" MULTIPLICATOR OF PKUROV.

!  The trajectory 1D
!  -----------------
! PCDROV5    : PCD NORMALIZED BY WIND SPEED TIMES DENSITY.
! PCHROV5    : PCH NORMALIZED BY WIND SPEED TIMES DENSITY.
! PXDROV5    : "ANTI-FIBRILLATION" MULTIPLICATOR OF PCDROV.
! PXHROV5    : "ANTI-FIBRILLATION" MULTIPLICATOR OF PCHROV.

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

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

! COMMON/YOMLUN /: UNITE NULOUT.
! COMMON/YOMCST /: UNIVERSAL CONSTANTS.
! COMMON/YOMPHY /: LOGICAL INDICATORS.
! COMMON/YOMPHY0, YOMPHY1, YOMPHY2, YOMPHY3/:
!       PHYSICAL CONSTANTS   (USED WITHIN METEO-FRANCE PHYSICS)
!       ( TEMPORARILY DIMENSIONLESS VERTICAL COORDINATE /YOMGEM/).

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

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

!     Methode.
!     --------
!     - TRAJECTORY COMPUTATION OF THE INITIALIZATION OF THE PHYSICAL
!       FLUXES.
!     - CALL THE COMPUTATION OF TRAJECTORIES FOR PHYSICS SUBROUTINES OF
!       SIMPLIFIED PHYSICAL PARAMETRIZATIONS.

!     Author.
!     -------
!        96-01-24 M.Janiskova

!     Modifications.
!     --------------
!        96-11-13 transmission coefficients for radiation scheme
!        97-08, introduce CDLOCK - J.M. Piriou.
!        97-11, call ACDIFSP instead of ACDIFSPADT,
!               calling radiation at the end due to changed cloudiness
!               parametrization - M. Janiskova
!        98-01, code optimalization and cleaning - M. Janiskova
!        01-03, mesospheric drag - F. Bouyssel
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        05-10, PQ introduced in ACDRME (P.Simon) - A. Alias

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

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

USE YOMGEM   , ONLY : TEQK
USE YOMPHY   , ONLY : LCONDWT  ,LNEIGE
USE YOMCST   , ONLY : RG
USE YOMPHY1  , ONLY : ALCRIN   ,ALRCN1   ,ALRCN2   ,EMCRIN   ,WCRIN
USE YOMTOPH  , ONLY : RMESOU   ,RMESOT   ,RMESOQ
USE YOMSTA   , ONLY : STTEM
USE YOMSIMPHL, ONLY : LSMOOTHD ,LSMOOTHA ,LCVRASP  ,LGWDSP   ,&
 & LRAYSP   ,LSTRASP  ,LVDIFSP  ,LRRMESSP  

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV 
INTEGER(KIND=JPIM),INTENT(IN)    :: KSGST 
INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KFDIA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KTDIA 
INTEGER(KIND=JPIM)               :: KSTEP ! Argument NOT used
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPHI5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPRS5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPHIF5(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPRSF5(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PDELP5(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRDELP5(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PU5(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PV5(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PT5(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PQ5(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCP5(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PCVGQ5(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PSNS(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTS(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PQS(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTS1(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PQS1(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGETRL(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PLSM(KLON) 
REAL(KIND=JPRB)                  :: PVEG(KLON) ! Argument NOT used
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGZ0F(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVRLAN(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVRLDI(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PALBF(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PEMISF(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PMU0(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGM(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAC(KLEV+1,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCOR(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRAB3C(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRAB3N(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRAB4C(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRAB4N(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRAB6C(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRAB6N(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRAT1C(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRAT1N(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRAT2C(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRAT2N(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRAT3C(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRAT3N(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRAT4C(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRAT4N(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRAT5C(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRAT5N(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PDIFCQ5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PDIFCS5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PDIFTQ5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PDIFTS5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFCCQL5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFCCQN5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFCSQL5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFCSQN5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFPLCL5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFPLCN5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFPLSL5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFPLSN5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFRSO5(KLON,0:KLEV,KSGST+1) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFRTH5(KLON,0:KLEV,KSGST+1) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSTRCU5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSTRCV5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSTRDU5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSTRDV5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSTRTU5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSTRTV5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PKTROV5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PKUROV5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PXTROV5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PXUROV5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PCDROV5(KLON) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PCHROV5(KLON) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PXDROV5(KLON) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PXHROV5(KLON) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSTRMU5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSTRMV5(KLON,0:KLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFRMH5(KLON,0:KLEV) 
CHARACTER(LEN=7)  ,INTENT(IN)    :: CDLOCK 
!     ------------------------------------------------------------------

!*
!     ------------------------------------------------------------------
!     DECLARATION OF THE ARGUMENTS

!*
!     -----------------------------------------------------------------
!     DECLARATION OF LOCAL VARIABLES OF PARAMETRIZATION

! - 1D (DIAGNOSTIC) .

! ZNEIJ      : FRACTION OF SOIL COVERED BY SNOW.

! - 1D (GEOGRAPHIC) .

! ZGZ0       : GRAVITY * ROUGHNESS LENGTH.

REAL(KIND=JPRB) :: ZGZ0(KLON),ZNEIJ(KLON),ZALB(KLON),ZEMIS(KLON)
REAL(KIND=JPRB) :: ZNTS(KLON)

! The trajectory - 2D (0:KLEV)
! ----------------------------

! ZFPLC5     : SUM OF CONVECTIVE PRECIPITATION AS RAIN AND AS SNOW.
! ZFRMQ5     : Humidity MESOSPHERIQC flux


!  The trajectory 1D
!  -----------------

! ZFCLL5     : LATENT HEAT FLUX OVER LIQUID WATER (OR WET SOIL).
! ZFCLN5     : LATENT HEAT FLUX OVER SNOW (OR ICE).
! ZFCS5      : SENSIBLE HEAT FLUX AT SURFACE LEVEL.
! ZFEVL5     : WATER VAPOR FLUX OVER LIQUID WATER (OR WET SOIL).
! ZFEVN5     : WATER VAPOR FLUX OVER SNOW (OR ICE).
! ZLHS5      : LATENT HEAT AT THE SURFACE.

REAL(KIND=JPRB) :: ZFPLC5(KLON,0:KLEV)
REAL(KIND=JPRB):: ZFRMQ5(KLON,0:KLEV) 
REAL(KIND=JPRB) :: ZLHS5(KLON),ZFEVL5(KLON),ZFEVN5(KLON),&
 & ZFCLL5(KLON),ZFCLN5(KLON),ZFCS5(KLON)  

INTEGER(KIND=JPIM) :: IJN, JLEV, JLON

LOGICAL :: LLSMO

REAL(KIND=JPRB) :: Z0CR, Z0CRIW
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"
#include "acconv.intfb.h"
#include "acdifsp.intfb.h"
#include "acdragl.intfb.h"
#include "acdrme.intfb.h"
#include "acqwlsr.intfb.h"
#include "acrads.intfb.h"
#include "actsec.intfb.h"

!     CHECK RELIABILITY OF INPUT ARGUMENTS.

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

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

!*
!**
!     -----------------------------------------------------------------
!     I - SOME INITIALIZATION AND SET VARIABLES TO ZERO IN THE CASE OF
!         NON-CALLING PARAMETRIZATIONS.
!     ------------------------------------------------------------------

IJN=KLON

PDIFCQ5(:,:) = 0.0_JPRB
PDIFCS5(:,:) = 0.0_JPRB
PDIFTQ5(:,:) = 0.0_JPRB
PDIFTS5(:,:) = 0.0_JPRB
PFPLCL5(:,:) = 0.0_JPRB
PFPLCN5(:,:) = 0.0_JPRB
PFPLSL5(:,:) = 0.0_JPRB
PFPLSN5(:,:) = 0.0_JPRB
PFCCQN5(:,:) = 0.0_JPRB
PFCCQL5(:,:) = 0.0_JPRB
PFCSQN5(:,:) = 0.0_JPRB
PFCSQL5(:,:) = 0.0_JPRB
PSTRCU5(:,:) = 0.0_JPRB
PSTRCV5(:,:) = 0.0_JPRB
PSTRDU5(:,:) = 0.0_JPRB
PSTRDV5(:,:) = 0.0_JPRB
PSTRTU5(:,:) = 0.0_JPRB
PSTRTV5(:,:) = 0.0_JPRB
PSTRMU5(:,:) = 0.0_JPRB
PSTRMV5(:,:) = 0.0_JPRB
PFRMH5 (:,:) = 0.0_JPRB

PFRSO5(:,:,:) = 0.0_JPRB
PFRTH5(:,:,:) = 0.0_JPRB


!      SET-UP LOGICAL VARIABLE FOR SMOOTHING OF SOME FUNCTIONS

IF (.NOT.LSMOOTHD.AND.LSMOOTHA) THEN
  LSMOOTHD=.TRUE.
  LLSMO=.TRUE.
ELSE
  LLSMO=.FALSE.
ENDIF

!*
!     -------------------------------------------------------------------
!     II - COMPUTATION OF FRACTION OF SOIL COVERED BY SNOW AND ROUGHNESS
!     -------------------------------------------------------------------
DO JLON=KIDIA,KFDIA

!     COMPUTATIONS CONCERNING THE PRESENCE OR ABSENCE OF SNOW ON GROUND.

  Z0CR=RG*ALRCN1
  Z0CRIW=1.0_JPRB/(RG*ALRCN2)

  IF (LNEIGE) THEN
    ZNEIJ(JLON)=PLSM(JLON)*PSNS(JLON)/(PSNS(JLON)+WCRIN)
    ZGZ0(JLON)=PGZ0F(JLON)+(Z0CR-PGZ0F(JLON))*PLSM(JLON)*&
     & PSNS(JLON)&
     & /(PSNS(JLON)+WCRIN+Z0CRIW*PGZ0F(JLON))  
  ELSE
    ZNEIJ(JLON)=0.0_JPRB
    ZGZ0(JLON)=PGZ0F(JLON)
  ENDIF

ENDDO

!*
!     ------------------------------------------------------------------
!     III - COMPUTATION OF VERTICAL TURBULENT EXCHANGE COEFFICIENTS
!           AND SURFACE EXCHANGE COEFFICIENTS AND COMPUTATION OF
!           VERTICAL TURBULENT DIFFUSION
!     ------------------------------------------------------------------
IF ( LVDIFSP) THEN

  DO JLON=KIDIA, KFDIA
    ZNTS(JLON)=PTS1(JLON)
  ENDDO

  CALL ACTSEC (KIDIA,KFDIA,KLON,KTDIA,KLEV,&
   & PAPHI5,PAPHIF5,PAPRS5,PAPRSF5,PQ5,PT5,PU5,PV5,&
   & PQS,PTS,ZGZ0,&
   & PKTROV5,PKUROV5,PXTROV5,PXUROV5,&
   & PCDROV5,PCHROV5,PXDROV5,PXHROV5,'ACTSEC ')  

  CALL ACDIFSP (KIDIA,KFDIA,KLON,KTDIA,KLEV,&
   & PAPHI5,PAPHIF5,PDELP5,PRDELP5,PT5,PQ5,&
   & PU5,PV5,PKTROV5,PKUROV5,PXTROV5,PXUROV5,&
   & PCDROV5,PCHROV5,PXDROV5,PXHROV5,&
   & PLSM,ZNEIJ,PQS,PTS,ZNTS,PTS1,PQS1,&
   & PDIFTQ5,PDIFTS5,PSTRTU5,PSTRTV5,&
   & ZFCLL5,ZFCLN5,ZFCS5,ZFEVL5,ZFEVN5,ZLHS5,'ACDIFSP')  
ENDIF

!*
!     ------------------------------------------------------------------
!     IV - COMPUTATION OF OROGRAPHIC GRAVITY WAVE DRAG
!     ------------------------------------------------------------------
IF ( LGWDSP ) THEN
  CALL ACDRAGL (KIDIA,KFDIA,KLON,KTDIA,KLEV,&
   & PAPHI5,PAPHIF5,PAPRS5,PAPRSF5,PDELP5,PRDELP5,&
   & PU5,PV5,PT5,PQ5,&
   & PGETRL,PVRLAN,PVRLDI,PTS,PQS,&
   & PSTRDU5,PSTRDV5,'ACDRAGL')  
ENDIF

!*
!     ------------------------------------------------------------------
!     V - COMPUTING CONVECTIVE PRECIPITATIONS, DEEP CONVECTIVE SCHEME
!     ------------------------------------------------------------------

IF ( LVDIFSP.AND.LCVRASP ) THEN
!        THE DYNAMIC TENDENCY OF Q IS MULTIPLIED BY CORRECTION FACTOR
!        OF LOCAL RESOLUTION OF THE MODEL AND BY ARGUMENT OF THE
!        EVAPORATION OF THE SURFACE

  DO JLEV=KTDIA,KLEV
    DO JLON=KIDIA,KFDIA
      PCVGQ5(JLON,JLEV)=PCVGQ5(JLON,JLEV)/(1.0_JPRB+PGM(JLON)*TEQK)&
       & -RG*PRDELP5(JLON,JLEV)&
       & *(PDIFTQ5(JLON,JLEV)-PDIFTQ5(JLON,JLEV-1))  
    ENDDO
  ENDDO
ENDIF

IF ( LCVRASP ) THEN
  CALL ACCONV ( KIDIA,KFDIA,KLON,KTDIA,KLEV,&
   & PAPHIF5,PAPRS5,PAPRSF5,PCVGQ5,&
   & PDELP5,PQ5,PRDELP5,PT5,PU5,PV5,&
   & PTS,&
   & PDIFCQ5,PDIFCS5,PFPLCL5,PFPLCN5,&
   & PSTRCU5,PSTRCV5,'ACCONV ')  

ENDIF

!*
!     ------------------------------------------------------------------
!     VI - COMPUTATION OF WET-BULB CHARACTERISTICS AND STRATIFORM
!          PRECIPITATION FLUXES
!     ------------------------------------------------------------------
IF ( LSTRASP ) THEN
  CALL ACQWLSR ( KIDIA,KFDIA,KLON,KTDIA,KLEV,&
   & PQ5,PT5,PAPRSF5,PDELP5,&
   & PFPLSL5,PFPLSN5,'ACQWLSR')  
ENDIF

!*
!     -------------------------------------------------------------------
!     VII - COMPUTATION OF RADIATIVE FLUXES
!     -------------------------------------------------------------------

IF (LRAYSP) THEN

!        ALBEDO AND EMISSIVITY WITH SNOW

  DO JLON=KIDIA,KFDIA
    ZALB(JLON)=PALBF(JLON)-ZNEIJ(JLON)*(PALBF(JLON)-MAX(PALBF(JLON),ALCRIN))
    ZEMIS(JLON)=PEMISF(JLON)-ZNEIJ(JLON)*(PEMISF(JLON)-EMCRIN)
  ENDDO

  DO JLEV=KTDIA-1,KLEV
    DO JLON=KIDIA,KFDIA
      ZFPLC5(JLON,JLEV)=PFPLCL5(JLON,JLEV)+PFPLCN5(JLON,JLEV)
    ENDDO
  ENDDO

!        COMPUTATION OF THE FLUXES

  CALL ACRADS (KIDIA,KFDIA,KLON,KTDIA,KLEV,IJN,&
   & PT5,PAPRSF5,PQ5,PDELP5,PRDELP5,ZFPLC5,&
   & ZALB,ZEMIS,PMU0,PTS,&
   & PAC,PCOR,&
   & PRAB3C,PRAB3N,PRAB4C,PRAB4N,PRAB6C,PRAB6N,&
   & PRAT1C,PRAT1N,PRAT2C,PRAT2N,PRAT3C,PRAT3N,&
   & PRAT4C,PRAT4N,PRAT5C,PRAT5N,&
   & PFRSO5,PFRTH5,'ACRADS ')  

ENDIF

!*
!     ------------------------------------------------------------------
!     VIII - COMPUTES THE MOMENTUM FLUX DUE TO A MESOSPHERIC DRAG AND 
!            THE HEAT FLUX CORRESPONDING TO A RELAXATION OF TEMPERATURE 
!            TOWARDS THE STANDARD ATMOSPHERE
!     ------------------------------------------------------------------

IF ( LRRMESSP ) THEN
  CALL ACDRME ( KIDIA,KFDIA,KLON,KTDIA,KLEV,&
   & PCP5,PDELP5,PT5,PQ5,PU5,PV5,&
   & PFRMH5,ZFRMQ5,PSTRMU5,PSTRMV5,&
   & RMESOT,RMESOQ,RMESOU,STTEM,'ACDRME ')  
ENDIF

!*
!     ------------------------------------------------------------------
!     IX - COMPUTATION OF THE FLUXES OF ENTHALPY AND SENSIBLE HEAT
!          (THE FUNCTION OF THE FLUXES OF PRECIPITATIONS AND
!           CONDENSATION)
!     ------------------------------------------------------------------

!      - IF IT IS NOT LIQUID WATER, THEN
!                   THE FLUX OF CONDENSATION = THE FLUX OF PRECIPITATION

IF (.NOT.LCONDWT) THEN
  DO JLEV = KTDIA, KLEV
    DO JLON = KIDIA, KFDIA
      PFCCQL5(JLON,JLEV) = PFPLCL5(JLON,JLEV)
      PFCCQN5(JLON,JLEV) = PFPLCN5(JLON,JLEV)
      PFCSQL5(JLON,JLEV) = PFPLSL5(JLON,JLEV)
      PFCSQN5(JLON,JLEV) = PFPLSN5(JLON,JLEV)
    ENDDO
  ENDDO
ENDIF

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

IF (LLSMO) THEN
  LSMOOTHD=.FALSE.
ENDIF

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