SUBROUTINE LARCINB5(&
 ! --- INPUT ---------------------------------------------------
 & KST,KPROF,KL0,PDLO,PCLO,PCLOSLD,&
 & PDLAT,PCLA,PCLASLD,PDVER,PVINTW,PVINTWSLD,PB15,&
 ! --- OUTPUT --------------------------------------------------
 & PUF,PVF,PUFZ,PVFZ)

!**** *LARCINB5    -  semi-LAgrangian scheme:(Interpolation)
!      (Stripped-down version of LARCINB, used by SL adjoint)

!     Purpose.
!     --------
!       Does the interpolations necessary in the semi-Lagrangian scheme.

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

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

!        INPUT:
!          KST     - first element of arrays where computations are performed.
!          KPROF   - depth of work.
!          KL0     - index of the four western points
!                    of the 16 points interpolation grid.
!          PDLO    - distances for horizontal linear interpolations
!                    in longitude (latitude rows 0, 1, 2, 3)
!          PCLO    - weights for horizontal cubic interpolations in longitude
!                    (latitude rows 1, 2)
!          PCLOSLD - idem for SLHD case
!          PDLAT   - distance for horizontal linear interpolations in latitude
!          PCLA    - weights for horizontal cubic interpolations in latitude
!          PCLASLD - idem for SLHD case
!          PDVER   - distance for vertical linear interpolation
!          PVINTW  - weights for cubic vertical interpolation
!          PVINTWSLD - idem for SLHD case
!          PB15    - "SLBUF1" buffer for interpolations (trajectory).

!        OUTPUT:
!          PUF     - Interpolated quantity at O in the U-wind eqn.
!          PVF     - Interpolated quantity at O in the V-wind eqn.
!          PUFZ    - Interpolated U-wind at O for L2TLFF=.T. option.
!          PVFZ    - Interpolated V-wind at O for L2TLFF=.T. option.

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

!     Method.
!     -------
!        See documentation

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

!        Called by LAPINEAD.

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

!     Author.
!     -------
!        D. SALMOND, from LARCINB.

!     Modifications.
!     --------------
!        Original : DEC 2003.
!        Modifications:
!     11-Jan-2005 C. Temperton  Streamlining.
!     30-Jun-2008 J. Masek      New dataflow for modified LAITRI.
!     14-Aug-2008 F. Vana       Weights driven interpolation
!     K. Yessad Nov 2008: rationalisation of dummy argument interfaces
!     K. Yessad Nov 2008: interpolation routines: merge QM with not-QM version.
!     ------------------------------------------------------------------

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

USE YOMDIM   , ONLY : NFLEVG   ,NPROMA   ,NFLSA    ,NFLEN
USE YOMDYNA   ,ONLY : LSLHD_W
USE YOMMP    , ONLY : NASLB1
USE YOMSC2   , ONLY : NFLDSLB15
USE PTRSLB15 , ONLY : MSLB1U95 ,MSLB1V95 ,MSLB1U05 ,MSLB1V05

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

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KST 
INTEGER(KIND=JPIM),INTENT(IN)    :: KPROF 
INTEGER(KIND=JPIM),INTENT(IN)    :: KL0(NPROMA,NFLEVG,0:3) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PDLO(NPROMA,NFLEVG,0:3) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCLO(NPROMA,NFLEVG,3,2)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCLOSLD(NPROMA,NFLEVG,3,2)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PDLAT(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCLA(NPROMA,NFLEVG,3) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCLASLD(NPROMA,NFLEVG,3) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PDVER(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVINTW(NPROMA,NFLEVG,3) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVINTWSLD(NPROMA,NFLEVG,3) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PB15(NASLB1,NFLDSLB15)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PUF(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PVF(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PUFZ(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PVFZ(NPROMA,NFLEVG) 

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

REAL(KIND=JPRB) :: ZUF(NPROMA,NFLEVG)
REAL(KIND=JPRB) :: ZVF(NPROMA,NFLEVG)

INTEGER(KIND=JPIM) :: JLEV, JROF

REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

#include "laitli.intfb.h"
#include "laitri.intfb.h"

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

IF (LHOOK) CALL DR_HOOK('LARCINB5',0,ZHOOK_HANDLE)

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

!*       6.    ORIGIN POINT INTERPOLATIONS FOR U AND V.
!              ----------------------------------------

!  (U and V only; used in adjoint of semi-Lagrangian. Assumes NWLAG=3,
!  weights driven cubic and linear interpolations)

IF (LSLHD_W) THEN
  CALL LAITRI(NASLB1,NPROMA,KST,KPROF,NFLEVG,NFLSA,NFLEN,0, &
   & PDLAT,PCLASLD,PDLO,PCLOSLD,KL0(1,1,0),PVINTWSLD, &
   & PB15(1,MSLB1U95),PUF)
  CALL LAITRI(NASLB1,NPROMA,KST,KPROF,NFLEVG,NFLSA,NFLEN,0, &
   & PDLAT,PCLASLD,PDLO,PCLOSLD,KL0(1,1,0),PVINTWSLD, &
   & PB15(1,MSLB1V95),PVF)
ELSE
  CALL LAITRI(NASLB1,NPROMA,KST,KPROF,NFLEVG,NFLSA,NFLEN,0, &
   & PDLAT,PCLA,PDLO,PCLO,KL0(1,1,0),PVINTW, &
   & PB15(1,MSLB1U95),PUF)
  CALL LAITRI(NASLB1,NPROMA,KST,KPROF,NFLEVG,NFLSA,NFLEN,0, &
   & PDLAT,PCLA,PDLO,PCLO,KL0(1,1,0),PVINTW, &
   & PB15(1,MSLB1V95),PVF)
ENDIF
! * Save PUF,PVF in case of refined treatment of
!   Coriolis term and lagged physics in 2TL scheme:
PUFZ(KST:KPROF,1:NFLEVG)=PUF(KST:KPROF,1:NFLEVG)
PVFZ(KST:KPROF,1:NFLEVG)=PVF(KST:KPROF,1:NFLEVG)
CALL LAITLI(NASLB1,NPROMA,KST,KPROF,NFLEVG,NFLSA,NFLEN,&
 & PDLAT,PDLO(1,1,1),KL0(1,1,1),PDVER,&
 & PB15(1,MSLB1U05),ZUF)  
CALL LAITLI(NASLB1,NPROMA,KST,KPROF,NFLEVG,NFLSA,NFLEN,&
 & PDLAT,PDLO(1,1,1),KL0(1,1,1),PDVER,&
 & PB15(1,MSLB1V05),ZVF)  
DO JLEV=1,NFLEVG
  DO JROF=KST,KPROF
    PUF(JROF,JLEV)=PUF(JROF,JLEV) +ZUF(JROF,JLEV)
    PVF(JROF,JLEV)=PVF(JROF,JLEV) +ZVF(JROF,JLEV)
  ENDDO
ENDDO

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

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