SUBROUTINE LASCAW_CLA(KFLEV,KLEV1,KLEV2,&
 & KPROM,KGLN,KGLX,KST,KPROF,LDT_SLHD,&
 & KILA,PWH,PDLAT,PKAPPA,PSLD1_,PSLD2_,PSLD3_,PSLDW_,&
 & PCLA,PCLASLD)

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

!**** *LASCAW_CLA  -  Weights for semi-LAgrangian interpolator:
!                     Computes PCLA and PCLASLD for one layer
!                     (high-order zonal weights)
!      Spherical geometry only.

!     Purpose.
!     --------

!**   Interface.
!     ----------
!        *CALL* *LASCAW_CLA( ... )

!        Explicit arguments :
!        --------------------

!        INPUT:
!          KFLEV    - Vertical dimension
!          KFLEV1   - Start level
!          KFLEV2   - End level
!          KPROM    - horizontal dimension.
!          KGLN     - lower dimension for latitude.
!          KGLX     - upper dimension for latitude.
!          KST      - first element of arrays where computations are performed.
!          KPROF    - depth of work.
!          LDT_SLHD - keys for SLHD.
!          KILA     - cf. ILA in LASCAW.
!          PWH      - cf. ZZWH in LASCAW.
!          PDLAT    - distance for horizontal linear interpolations in latitude
!          PKAPPA   - kappa function ("coefficient of SLHD").
!          PSLD1_   - auxiliary quantity for SLHD interpolation in latitude
!          PSLD2_   - auxiliary quantity for SLHD interpolation in latitude
!          PSLD3_   - auxiliary quantity for SLHD interpolation in latitude
!          PSLDW_   - weights for SLHD Laplacian smoother in latitude

!        OUTPUT:
!          PCLA    - weights for horizontal cubic interpolations in latitude.
!          PCLASLD - cf. PCLA, SLHD case.

!        Implicit arguments :
!        --------------------

!     Method.
!     -------
!        See documentation about semi-Lagrangian scheme.

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

!        No external.
!        Called by LASCAW.

!     Reference.
!     ----------

!     Author.
!     -------
!        K. YESSAD, after former LASCAW code (JAN 2009).
!        METEO-FRANCE, CNRM/GMAP.

!     Modifications.
!     --------------
!     ------------------------------------------------------------------

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK    ,DR_HOOK 
USE YOMDYNA  , ONLY : SLHDKMIN ,SLHDKMAX
USE YOMLASCAW, ONLY : KPDUP

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

IMPLICIT NONE

INTEGER(KIND=JPIM), INTENT(IN)  :: KFLEV
INTEGER(KIND=JPIM), INTENT(IN)  :: KLEV1
INTEGER(KIND=JPIM), INTENT(IN)  :: KLEV2
INTEGER(KIND=JPIM), INTENT(IN)  :: KPROM
INTEGER(KIND=JPIM), INTENT(IN)  :: KGLN
INTEGER(KIND=JPIM), INTENT(IN)  :: KGLX
INTEGER(KIND=JPIM), INTENT(IN)  :: KST
INTEGER(KIND=JPIM), INTENT(IN)  :: KPROF
LOGICAL           , INTENT(IN)  :: LDT_SLHD(3)
INTEGER(KIND=JPIM), INTENT(IN)  :: KILA(KPROM)
REAL(KIND=JPRB)   , INTENT(IN)  :: PWH(KPROM,3,KLEV1:KLEV2)
REAL(KIND=JPRB)   , INTENT(IN)  :: PDLAT(KPROM,KLEV1:KLEV2)
REAL(KIND=JPRB)   , INTENT(IN)  :: PKAPPA(KPROM,0:KFLEV)
REAL(KIND=JPRB)   , INTENT(IN)  :: PSLD1_(KPDUP,KGLN:KGLX)
REAL(KIND=JPRB)   , INTENT(IN)  :: PSLD2_(KPDUP,KGLN:KGLX)
REAL(KIND=JPRB)   , INTENT(IN)  :: PSLD3_(KPDUP,KGLN:KGLX)
REAL(KIND=JPRB)   , INTENT(IN)  :: PSLDW_(KPDUP,3,3,KGLN:KGLX)
REAL(KIND=JPRB)   , INTENT(OUT) :: PCLA(KPROM,KLEV1:KLEV2,3)
REAL(KIND=JPRB)   , INTENT(OUT) :: PCLASLD(KPROM,KLEV1:KLEV2,3)

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

INTEGER(KIND=JPIM) :: JROF,IJ_,ILA,JLEV
REAL(KIND=JPRB) :: ZWA1,ZWA2,ZWA3,ZWD1,ZWD2,ZWD3,ZWH1,ZWH2,ZWH3
REAL(KIND=JPRB) :: ZWDS1,ZWDS2,ZWDS3,ZWL1,ZWL2,ZWL3
LOGICAL :: LLSLHD,LLSLHDQUAD,LLSLHD_OLD
REAL(KIND=JPRB) :: ZHOOK_HANDLE

!     ------------------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('LASCAW_CLA',0,ZHOOK_HANDLE)
!     ------------------------------------------------------------------

LLSLHD=LDT_SLHD(1)
LLSLHDQUAD=LDT_SLHD(2)
LLSLHD_OLD=LDT_SLHD(3)

! * Calculation of PCLA and PCLASLD:
DO JLEV=KLEV1,KLEV2
!CDIR NODEP
DO JROF=KST,KPROF

  IJ_ = MOD(JROF+1-KST,KPDUP)+1
  ILA=KILA(JROF)

  ZWH1=PWH(JROF,1,JLEV)
  ZWH2=PWH(JROF,2,JLEV)
  ZWH3=PWH(JROF,3,JLEV)
  IF (LLSLHDQUAD) THEN
    ZWL2=PDLAT(JROF,JLEV)
    ZWL1=1.0_JPRB-ZWL2
    ZWL3=PSLD3_(IJ_,ILA+1)*ZWL1*ZWL2
    ZWL1=ZWL1+PSLD1_(IJ_,ILA+1)*ZWL3
    ZWL2=ZWL2+PSLD2_(IJ_,ILA+1)*ZWL3
  ELSEIF (LLSLHD_OLD) THEN
    ZWL2=PDLAT(JROF,JLEV)
    ZWL1=1.0_JPRB-ZWL2
    ZWL3=0.0_JPRB
  ENDIF

  IF (LLSLHD) THEN
    ZWA1=ZWH1+SLHDKMIN*(ZWL1-ZWH1)
    ZWA2=ZWH2+SLHDKMIN*(ZWL2-ZWH2)
    ZWA3=ZWH3+SLHDKMIN*(ZWL3-ZWH3)
    ZWD1=ZWH1+SLHDKMAX*(ZWL1-ZWH1)
    ZWD2=ZWH2+SLHDKMAX*(ZWL2-ZWH2)
    ZWD3=ZWH3+SLHDKMAX*(ZWL3-ZWH3)
    ZWDS1=PSLDW_(IJ_,1,1,ILA+1)*ZWD1+PSLDW_(IJ_,1,2,ILA+1)*ZWD2+ &
     & PSLDW_(IJ_,1,3,ILA+1)*ZWD3
    ZWDS2=PSLDW_(IJ_,2,1,ILA+1)*ZWD1+PSLDW_(IJ_,2,2,ILA+1)*ZWD2+ &
     & PSLDW_(IJ_,2,3,ILA+1)*ZWD3
    ZWDS3=PSLDW_(IJ_,3,1,ILA+1)*ZWD1+PSLDW_(IJ_,3,2,ILA+1)*ZWD2+ &
     & PSLDW_(IJ_,3,3,ILA+1)*ZWD3
    PCLA(JROF,JLEV,1)=ZWA1
    PCLA(JROF,JLEV,2)=ZWA2
    PCLA(JROF,JLEV,3)=ZWA3
    PCLASLD(JROF,JLEV,1)=ZWA1+PKAPPA(JROF,JLEV)*(ZWDS1-ZWA1)
    PCLASLD(JROF,JLEV,2)=ZWA2+PKAPPA(JROF,JLEV)*(ZWDS2-ZWA2)
    PCLASLD(JROF,JLEV,3)=ZWA3+PKAPPA(JROF,JLEV)*(ZWDS3-ZWA3)
  ELSEIF (LLSLHDQUAD) THEN
    ZWA1=ZWH1+SLHDKMIN*(ZWL1-ZWH1)
    ZWA2=ZWH2+SLHDKMIN*(ZWL2-ZWH2)
    ZWA3=ZWH3+SLHDKMIN*(ZWL3-ZWH3)
    PCLA(JROF,JLEV,1)=ZWA1
    PCLA(JROF,JLEV,2)=ZWA2
    PCLA(JROF,JLEV,3)=ZWA3
    PCLASLD(JROF,JLEV,1)=ZWA1
    PCLASLD(JROF,JLEV,2)=ZWA2
    PCLASLD(JROF,JLEV,3)=ZWA3
  ELSE
    PCLA(JROF,JLEV,1)=ZWH1
    PCLA(JROF,JLEV,2)=ZWH2
    PCLA(JROF,JLEV,3)=ZWH3
    PCLASLD(JROF,JLEV,1)=ZWH1
    PCLASLD(JROF,JLEV,2)=ZWH2
    PCLASLD(JROF,JLEV,3)=ZWH3
  ENDIF
ENDDO
ENDDO

!     ------------------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('LASCAW_CLA',1,ZHOOK_HANDLE)
END SUBROUTINE LASCAW_CLA
