SUBROUTINE SURFEXCDRIVERSTL  ( &
 &   KIDIA , KFDIA, KLON, KLEVS, KTILES, KSTEP &
 & , PTSTEP, PRVDIFTS, LDNOPERT, LDKPERT &
! input data, non-tiled - trajectory
 & , KTVL  , KTVH, PCVL, PCVH  &
 & , PLAIL, PLAIH &
 & , PUMLEV5, PVMLEV5 , PTMLEV5, PQMLEV5, PAPHMS5, PGEOMLEV5, PCPTGZLEV5 &
 & , PSST   , PTSKM1M5, PCHAR  , PSSRFL5, PTICE5 , PTSNOW5  &
 & , PWLMX5 &
! input data, soil - trajectory
 & , PTSAM1M5, PWSAM1M5, KSOTY &
! input data, tiled - trajectory
 & , PFRTI, PALBTI5 &
! updated data, tiled - trajectory
 & , PUSTRTI5, PVSTRTI5, PAHFSTI5, PEVAPTI5, PTSKTI5 &
! updated data, non-tiled - trajectory
 & , PZ0M5, PZ0H5 &
! output data, tiled - trajectory
 & , PSSRFLTI5, PQSTI5 , PDQSTI5 , PCPTSTI5 &
 & , PCFHTI5  , PCFQTI5, PCSATTI5, PCAIRTI5 &
! output data, non-tiled - trajectory
 & , PCFMLEV5 &
 & , PKMFL5  , PKHFL5  , PKQFL5 &
 & , PEVAPSNW5 &
 & , PZ0MW5  , PZ0HW5    , PZ0QW5, PCPTSPP5, PQSAPP5, PBUOMPP5 &
! input data, non-tiled
 & , PUMLEV  , PVMLEV    , PTMLEV, PQMLEV  , PAPHMS , PGEOMLEV, PCPTGZLEV &
 & , PTSKM1M , PSSRFL &
! input data, soil
 & , PTSAM1M , PWSAM1M &
! input data, tiled
 & , PALBTI &
! updated data, tiled
 & , PUSTRTI , PVSTRTI , PAHFSTI, PEVAPTI, PTSKTI &
! updated data, non-tiled
 & , PZ0M, PZ0H &
! output data, tiled
 & , PSSRFLTI, PQSTI   , PDQSTI, PCPTSTI , PCFHTI, PCFQTI, PCSATTI, PCAIRTI &
! output data, non-tiled
 & , PCFMLEV , PEVAPSNW &
 & , PZ0MW   , PZ0HW    , PZ0QW, PCPTSPP , PQSAPP, PBUOMPP &
 & )

USE PARKIND1  ,ONLY : JPIM, JPRB


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

!  PURPOSE:
!    Routine SURFEXCDRIVERSTL controls the ensemble of routines that prepare
!    the surface exchange coefficients and associated surface quantities
!    needed for the solution of the vertical diffusion equations. 
!    (Tangent linear)

!  SURFEXCDRIVERSTL is called by VDFMAINSTL

!  METHOD:
!    This routine is only a shell needed by the surface library
!    externalisation.

!  AUTHOR:
!    M. Janiskova       ECMWF June 2005   

!  REVISION HISTORY:
!    M. Janiskova       Oct.2007   Kinematic fluxes included
!    S. Boussetta/G.Balsamo May 2009 Add lai

!  INTERFACE: 

!    Integers (In):
!      KIDIA    :    Begin point in arrays
!      KFDIA    :    End point in arrays
!      KLON     :    Length of arrays
!      KLEVS    :    Number of soil layers
!      KTILES   :    Number of tiles
!      KSTEP    :    Time step index
!      KTVL     :    Dominant low vegetation type
!      KTVH     :    Dominant high vegetation type
!      KSOTY    :    SOIL TYPE                                        (1-7)

!  Reals (In):
!      PTSTEP   :    Timestep
!      PRVDIFTS :    Semi-implicit factor for vertical diffusion discretization
!      PCVL     :    Low vegetation fraction
!      PCVH     :    High vegetation fraction
!      PLAIL     :    Low vegetation LAI
!      PLAIH     :    High vegetation LAI

!  Logical:
!      LDNOPERT :    TRUE when no perturbations is required for surface arrays
!      LDKPERT  :    TRUE when pertubations of exchange coefficients are used

!*      Reals with tile index (In): 
!  Trajectory  Perturbation  Description                               Unit
!  PFRTI       ---           TILE FRACTIONS                            (0-1)
!                            1: WATER         5: SNOW ON LOW-VEG+BARE-SOIL
!                            2: ICE           6: DRY SNOW-FREE HIGH-VEG
!                            3: WET SKIN      7: SNOW UNDER HIGH-VEG
!                            4: DRY SNOW-FREE 8: BARE SOIL
!                               LOW-VEG
!  PALBTI5     PALBTI        Tile albedo                               (0-1)

!*      Reals independent of tiles (In):
!  Trajectory  Perturbation  Description                               Unit
!  PUMLEV5     PUMLEV        X-VELOCITY COMPONENT, lowest              m/s
!                            atmospheric level
!  PVMLEV5     PVMLEV        Y-VELOCITY COMPONENT, lowest              m/s
!                            atmospheric level
!  PTMLEV5     PTMLEV        TEMPERATURE, lowest atmospheric level     K
!  PQMLEV5     PQMLEV        SPECIFIC HUMIDITY                         kg/kg
!  PAPHMS5     PAPHMS        Surface pressure                          Pa
!  PGEOMLEV5   PGEOMLEV      Geopotential, lowest atmospehric level    m2/s2
!  PCPTGZLEV5  PCPTGZLEV     Geopotential, lowest atmospehric level    J/kg
!  PSST        ---           (OPEN) SEA SURFACE TEMPERATURE            K
!  PTSKM1M5    PTSKM1M       SKIN TEMPERATURE                          K
!  PCHAR       ---           "EQUIVALENT" CHARNOCK PARAMETER           -
!  PSSRFL5     PSSRFL        NET SHORTWAVE RADIATION FLUX AT SURFACE   W/m2
!  PTSAM1M5    PTSAM1M       SURFACE TEMPERATURE                       K
!  PWSAM1M5    PWSAM1M       SOIL MOISTURE ALL LAYERS                 m**3/m**3
!  PTICE5      ---           Ice temperature, top slab                 K
!  PTSNOW5     ---           Snow temperature                          K
!  PWLMX5      ---           Maximum interception layer capacity       kg/m**2

!*      Reals with tile index (In/Out):
!  Trajectory  Perturbation  Description                               Unit
!  PUSTRTI5    PUSTRTI       SURFACE U-STRESS                          N/m2
!  PVSTRTI5    PVSTRTI       SURFACE V-STRESS                          N/m2
!  PAHFSTI5    PAHFSTI       SURFACE SENSIBLE HEAT FLUX                W/m2
!  PEVAPTI5    PEVAPTI       SURFACE MOISTURE FLUX                     KG/m2/s
!  PTSKTI5     PTSKTI        SKIN TEMPERATURE                          K

!*      Reals independent of tiles (In/Out):
!  Trajectory  Perturbation  Description                               Unit
!  PZ0M5       PZ0M          AERODYNAMIC ROUGHNESS LENGTH              m
!  PZ0H5       PZ0H          ROUGHNESS LENGTH FOR HEAT                 m

!*      Reals with tile index (Out):
!  Trajectory  Perturbation  Description                               Unit
!  PSSRFLTI5   PSSRFLTI      Tiled NET SHORTWAVE RADIATION FLUX        W/m2
!                            AT SURFACE
!  PQSTI5      PQSTI         Tiled SATURATION Q AT SURFACE             kg/kg
!  PDQSTI5     PDQSTI        Tiled DERIVATIVE OF SATURATION Q-CURVE    kg/kg/K
!  PCPTSTI5    PCPTSTI       Tiled DRY STATIC ENERGY AT SURFACE        J/kg
!  PCFHTI5     PCFHTI        Tiled EXCHANGE COEFFICIENT AT THE SURFACE ????
!  PCFQTI5     PCFQTI        Tiled EXCHANGE COEFFICIENT AT THE SURFACE ????
!  PCSATTI5    PCSATTI       MULTIPLICATION FACTOR FOR QS AT SURFACE   -
!                            FOR SURFACE FLUX COMPUTATION
!  PCAIRTI5    PCAIRTI       MULTIPLICATION FACTOR FOR Q AT LOWEST     - 
!                            MODEL LEVEL FOR SURFACE FLUX COMPUTATION

!*      Reals independent of tiles (Out):
!  Trajectory  Perturbation  Description                               Unit
!  PCFMLEV5    PCFMLEV       PROP. TO EXCH. COEFF. FOR MOMENTUM        ????
!                             (C-STAR IN DOC.) (SURFACE LAYER ONLY)
!  PKMFL5      ---           Kinematic momentum flux                   ????
!  PKHFL5      ---           Kinematic heat flux                       ????
!  PKQFL5      ---           Kinematic moisture flux                   ????
!  PEVAPSNW5   PEVAPSNW      Evaporation from snow under forest        kgm-2s-1
!  PZ0MW5      PZ0MW         Roughness length for momentum,WMO station m
!  PZ0HW5      PZ0HW         Roughness length for heat, WMO station    m
!  PZ0QW5      PZ0QW         Roughness length for moisture,WMO station m
!  PCPTSPP5    PCPTSPP       Cp*Ts for post-processing of weather      J/kg
!                            parameters
!  PQSAPP5     PQSAPP        Apparent surface humidity                 kg/kg
!                            post-processing of weather parameters
!  PBUOMPP5    PBUOMPP       Buoyancy flux, for post-processing        ???? 
!                            of gustiness

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

!     ** SURFEXCDRIVERS_CTL CALLS SUCCESSIVELY:
!         *VUPDZ0*
!         *VSURF*
!         *VEXCS*
!         *VEVAP*

!  DOCUMENTATION:
!    See Physics Volume of IFS documentation

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

IMPLICIT NONE

! Declaration of arguments

INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA
INTEGER(KIND=JPIM),INTENT(IN)    :: KFDIA
INTEGER(KIND=JPIM),INTENT(IN)    :: KLON
INTEGER(KIND=JPIM),INTENT(IN)    :: KLEVS
INTEGER(KIND=JPIM),INTENT(IN)    :: KTILES
INTEGER(KIND=JPIM),INTENT(IN)    :: KSTEP
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTSTEP
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRVDIFTS
LOGICAL           ,INTENT(IN)    :: LDNOPERT
LOGICAL           ,INTENT(IN)    :: LDKPERT

INTEGER(KIND=JPIM),INTENT(IN)    :: KTVL(:) 
INTEGER(KIND=JPIM),INTENT(IN)    :: KTVH(:) 
INTEGER(KIND=JPIM),INTENT(IN)    :: KSOTY(:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCVL(:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCVH(:)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PLAIL(:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PLAIH(:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PUMLEV5(:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVMLEV5(:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTMLEV5(:)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PQMLEV5(:)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPHMS5(:)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGEOMLEV5(:)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCPTGZLEV5(:)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PSST(:)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTSKM1M5(:)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCHAR(:)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PSSRFL5(:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTICE5(:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTSNOW5(:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PWLMX5(:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTSAM1M5(:,:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PWSAM1M5(:,:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PFRTI(:,:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PALBTI5(:,:) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PUSTRTI5(:,:) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PVSTRTI5(:,:) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PAHFSTI5(:,:) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PEVAPTI5(:,:) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PTSKTI5(:,:) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PZ0M5(:) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PZ0H5(:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSSRFLTI5(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PQSTI5(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PDQSTI5(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCPTSTI5(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCFHTI5(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCFQTI5(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCSATTI5(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCAIRTI5(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCFMLEV5(:)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PKMFL5(:)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PKHFL5(:)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PKQFL5(:)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PEVAPSNW5(:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PZ0MW5(:)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PZ0HW5(:)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PZ0QW5(:)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCPTSPP5(:)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PQSAPP5(:)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PBUOMPP5(:)

REAL(KIND=JPRB)   ,INTENT(IN)    :: PUMLEV(:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVMLEV(:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTMLEV(:)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PQMLEV(:)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPHMS(:)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGEOMLEV(:)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCPTGZLEV(:)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTSKM1M(:)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PSSRFL(:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTSAM1M(:,:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PWSAM1M(:,:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PALBTI(:,:) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PUSTRTI(:,:) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PVSTRTI(:,:) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PAHFSTI(:,:) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PEVAPTI(:,:) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PTSKTI(:,:) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PZ0M(:) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PZ0H(:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSSRFLTI(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PQSTI(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PDQSTI(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCPTSTI(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCFHTI(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCFQTI(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCSATTI(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCAIRTI(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCFMLEV(:)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PEVAPSNW(:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PZ0MW(:)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PZ0HW(:)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PZ0QW(:)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCPTSPP(:)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PQSAPP(:)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PBUOMPP(:)


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

END SUBROUTINE SURFEXCDRIVERSTL
