SUBROUTINE LAPINEA( &
 ! --- INPUT ------------------------------------------------------------------
 & KST,KPROF,&
 & PCOLON,PSILON,PGM,PGEMU,PGSQM2,PGECLO,PGESLO,PGNORDL,PGNORDM,PINDX,PINDY,&
 & PB1,PB2, &
 ! --- INPUT/OUTPUT -----------------------------------------------------------
 & KVSEPC,KVSEPL,&
 ! --- OUTPUT -----------------------------------------------------------------
 & PLON,PLAT,&
 & PQX,PQY,PR,PS,&
 & PUF,PVF,&
 & KL0,KLH0,&
 & PDLO,PCLO,PCLOSLD,&
 & PDLAT,PCLA,PCLASLD,&
 & KLEV,PDVER,&
 & PVINTW,PVINTWSLD,PVINTWS,&
 & KL0H,&
 & PDLOH,PCLOH,PCLOHSLD,&
 & PDLATH,PCLAH,PCLAHSLD,&
 & PDVERH,PVINTWH,PVINTWHSLD,&
 & PCOSCO,PSINCO,PCOPHI,PSINLA,&
 & PVDERW,PHVW,PGFLT1)

!**** *LAPINEA* - semi-LAgrangian scheme(Trajectory):
!                Interface subroutine for interpolations and lagrangian
!                trends. (Programme INterface d'Ensemble).

!     Purpose.
!     --------
!           Grid point calculations in dynamics.

!           Computes the semi-Lagrangian trajectory. 
!           Computes the weights ready for interpolations at origin point.

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

!        Explicit arguments :
!        --------------------
!        INPUT:
!          KST     - first element of arrays where computations are performed.
!          KPROF   - depth of work.
!          PCOLON  - cos(computational sphere longitude).
!          PSILON  - sin(computational sphere longitude).
!          PGM     - mapping factor.
!          PGEMU   - sin(geographical latitude).
!          PGSQM2  - cos(geographical latitude).
!          PGECLO  - cos(geographical longitude).
!          PGESLO  - sin(geographical longitude).
!          PGNORDL - zonal component of the vector directed towards the
!                    true North pole.
!          PGNORDM - meridian component of the vector directed towards the
!                    true North pole.
!          PINDX   - x coordinate on the plane.
!          PINDY   - y coordinate on the plane.
!          PB1     - SLBUF1-buffer for interpolations.
!          PB2     - SLBUF2-buf to communicate info from non lag. to lag. dyn.

!        INPUT AND OUTPUT:
!          KVSEPC  - vertical separation (used in S/L adjoint of cubic interp.)
!          KVSEPL  - vertical separation (used in S/L adjoint, linear interp.)

!        OUTPUT:
!          PLON      - computational sphere longitude of interpolation point.
!          PLAT      - computational sphere latitude of interpolation point.
!          PQX       - first element of the wind displacement matrix for O.
!          PQY       - second element of the wind displacement matrix for O.
!          PR        - first element of the wind displacement matrix for M.
!          PS        - second element of the wind displacement matrix for M.
!          PUF       - U-comp of "(a/rs)*wind" at the medium point necessary to
!                      find the positions of the medium and origin points,
!                      in a local repere linked to computational sphere.
!          PVF       - V-comp of "(a/rs)*wind" at the medium point necessary to
!                      find the positions of the medium and origin points,
!                      in a local repere linked to computational sphere.
!          KL0       - index of the four western points
!                      of the 16 points interpolation grid.
!          KLH0      - second value of index of the four western points
!                      of the 16 points interpolation grid if needed.
!          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   - weights for horizontal cubic interpolations in
!                      longitude, SLHD case (latitude rows 1, 2)
!          PDLAT     - distance for horizontal linear interpolations
!                      in latitude
!          PCLA      - weights for horizontal cubic interpolations
!                      in latitude
!          PCLASLD   - weights for horizontal cubic interpolations
!                      in latitude, SLHD case
!          KLEV      - lower level of the vertical interpolation
!                      grid needed for vertical interpolations.
!          PDVER     - distance for vertical linear interpolation
!          PVINTW    - vertical cubic interpolation weights
!          PVINTWSLD - vertical cubic interpolation weights, SLHD case
!          PVINTWS   - Vertical spline interpolation weights.
!          KL0H      - half-level KL0
!          PDLOH     - half-level PDLO
!          PCLOH     - half-level PCLO
!          PCLOHSLD  - half-level PCLOSLD
!          PDLATH    - half-level PDLAT
!          PCLAH     - half-level PCLA
!          PCLAHSLD  - half-level PCLASLD
!          PDVERH    - half-level PDVER
!          PVINTWH   - half-level PVINTW
!          PVINTWHSLD- half-level PVINTWSLD
!          PCOSCO    - cos(Longitude-Longitude(grid-point))*cos(Latitude)
!                      of the interpolation point (geographical longitude
!                      and latitude).
!                      ! if LDPLANE: x - coordinate (fractional system).
!          PSINCO    - sin(Longitude-Longitude(grid-point))*cos(Latitude)
!                      of the interpolation point (geographical longitude
!                      and latitude).
!                      ! if LDPLANE: y - coordinate (fractional system).
!          PSINLA    - sine of the interpolation point geographical latitude.
!          PCOPHI    - cosine of the geographical angle between the
!                      interpolation point and the grid-point.
!          PVDERW    - weights to compute vertical derivatives necessary for
!                      Hermite cubic vertical interpolation.
!          PHVW      - Hermite vertical cubic interpolation weights.
!          PGFLT1    - t+dt unified_treatment grid-point fields (for SL diagn.)

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

!     Method.
!     -------

!     Externals.
!     ----------
!       See includes below.
!       Called by CALL_SL.

!     Reference.
!     ----------
!        ARPEGE documentation about semi-Lagrangian scheme.

!     Author.
!     -------
!        K. YESSAD after the subroutine CPLGDY2 written by
!        Maurice IMBARD   METEO FRANCE/EERM/CRMD

!     Modifications.
!     --------------
!        Original : JUNE 1991.
!        Modifications:
!        K. YESSAD (METEO-FRANCE CNRM/GMAP).  22/11/1991.
!        K. YESSAD: FEBRUARY 1992.
!        K. YESSAD: MAY 1992.
!        M. HORTAL (ECMWF) and K. YESSAD (CNRM/GMAP): 04/11/1992.
!        K. YESSAD: DECEMBER 1992 (non interpolating vertical scheme and
!                   some cleaning, introduction of a decentering factor
!                   in semi-implicit terms and terms averaged along the
!                   semi-lagrangian trajectory).
!        Modified 93-12-14 by K. YESSAD: interpolations at medium point for
!                                      semi-lagrangian temperature equation.
!        M.HAMRUD: 94-01-31 Memory savings (use of "work-space")
!        Modified 94-03-23 by M. Hortal: interpolations at medium point for
!                                      semi-lagrangian momentum equations.
!        Modified 94-10-17 M. Tolstykh: CUD interpolation, variable decentering
!        K. YESSAD (JAN 1995):
!             - Introduction of array RCUDWM for optimisations of CUD-5
!               meridian derivatives.
!             - Constant part of decentering factor becomes VESLA for
!               explicit terms and vertical residual advections.
!        R. BUBNOVA (22 JAN 1995):
!             - Plane geometry, after developments of Martin Janousek.
!        K. YESSAD (AUGUST 1995):
!             - Accurate two-time level SL scheme (after Tolstykh/Janousek).
!             - Second-order decentering in two-time level SL scheme.
!             - DO loops updated according to F90 norms.
!        K. YESSAD (MARCH 1996):
!             - New option LCORAN=.T. (analytical computation of 2*Omega*Vec*r).
!        Modified 96-03 by A. Untch : grid-point prognostic ozone (EC)
!        Modified 96-04-17 by C. Temperton:
!             - Refined treatment of Coriolis term in 2TL scheme
!        Modified by K. YESSAD (AUGUST 1996):
!             - Hermite cubic vertical interpolations for passive scalars.
!               Not yet coded for plane geometry.
!               Not yet coded for CUD-5 scheme.
!             - Removal of variable uncentering.
!        Modified 96-10-23 by C. Temperton / M. Hortal:
!             - Analytic treatment of Coriolis term in 2TL scheme for
!               option L2TLFF=T.
!        Modified 97-05-19 by C. Temperton: LCUTRA option added      
!               (only used for 2D model)
!        Modified by K. YESSAD (MAY 1998): adaptation of L2TLFF to LAGPHY=.F..
!        Modified July 1998 by K. YESSAD: cleaning
!             - removal of options NODEC=2, L2TLAW=T, L2TLAT=T
!             - VESLA is replaced by VESL.
!             - removal of useless dummy arguments.
!             - complete declaration of dummy arguments.
!             - correction of false comments.
!             - replace NDGSA,NDGEN by NDGSAG,NDGENG
!             - adaptation of L2TLFF to NSTTYP=2 (correction of residual bugs).
!             - LRPLANE version of L2TLFF.
!        Modified 98-05-27 by E. Holm: Order of ozone changed in call
!               and in calls to LARMES and LAINOR.
!        Modified 98-09-01 by N. Wedi, added parameters for SL-physics
!        Modified 98-12-02 by K. YESSAD: new option LRADVTORO.
!        Modified 98-12-18 by K. YESSAD and I. GOSPODINOV: option LELTRA.
!        Modified 99-11-16 by C. Temperton: added LLADJO in call to LAINOR;
!                                           allowed LSLAG+LSPO3.
!        Modified 99-03-31 by P. SMOLIKOVA: option LRDAORG (double averaging).
!        Modified 00-02-07 by C. Temperton: removed redundant use of PDP0
!                                           when NVLAG=3 (contained zero!)
!        Modified 00-02-11 by C. Temperton: added KVSEP, LFINDVSEP
!        Modified 00-06-15 by C. Temperton: NVSEP -> NVSEPC,NVSEPL.
!        Modified NOV 1999 by K. YESSAD:
!         - in 'lacudw', compute PDLAT and ILA as in 'lascaw' =>
!           'nrlatx', 'nindlat' and 'rdllat' become useless.
!        K. YESSAD (Nov 1999): cleaning
!         - recode SL3TL like SL2TL and eliminate useless interpolations
!           in continuity equation.
!           Remark: (PX0,PDP0) is now useless but has to be kept to make
!           easier a test of a pure 2D formulation of continuity equation.
!        Modified April 2000 by Malgorzata Szczech:
!         - bug corrections for thermodynamical ozon.
!         - add option "lhvo3" for thermodynamical ozon.
!        Modified August 2000 by Deborah Salmond to split into _traj and _int
!        Modified 00-11-07 by C. Temperton: streamlining.
!        Modified 00-11-23 by C. Temperton: renamed _TRAJ and _INT routines.
!        Modified 01-03-16 by M. Janousek: adaptation of on-demand s-L
!                                          commun. for plane geometry
!        Modified 01-06-26 by K. YESSAD:
!         - cleanings (remove useless variables),
!           update or correct some comments, especially in the context of the
!           introduction of thin layer hypothesis relaxation ("(a/rs)*winds"
!           are interpolated and no longer winds if lvercor=true).
!         - relaxation of thin layer hypothesis.
!         - restore options using Hermite vertical interpolations.
!        Modified 01-08-30 by K. YESSAD: pruning and some other cleanings.
!        R. El Khatib : 01-08-07 Pruning options
!        Modified 08-2002 C. Smith : use "w" as prognostic variable in the
!         semi-lag advection of vertical divergence in the NH model.
!        Modified 2003-08-19 by F. Vana: SL diffusion.
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        M.Hortal      01-Dec-2003 Extra-fields coming from thwe dynamics
!        D.Salmond     22-Dec-2003 Karim's Larcin cleaning
!        A.Bogatchev   06-Oct-2004 Add PWRLA in call to ELARMES
!        A.Trojakova   17-Oct-2004 phasing CY29 (fix PLON,PLAT)
!        Modified 05-01-11 by C. Temperton: streamlining.
!        Modified 05-01-14 by C. Temperton: transfer computations from
!                                start of LAIDEP to end of LARMES.
!   ??-Nov-2004 F. Vana     3D spline interpolation
!   22-Mar-2005 K. Yessad and J. Vivoda  adapt LGWADV for spherical geom.
!   ??-May-2005 O. Spaniel  phasing al30
!   07-Sep-2005 K. Yessad   Now calls directly LARCINA and LARCINHA.
!        F.Vana  09-Jan-2007 new argument to LARCINA
!        K. Yessad 07-03-2007: Remove useless (gw)_surf interpol. in NH+LGWADV.
!        F. Vana   28-Aug-2007: removing 3D spline interpolation
!   N. Wedi and K. Yessad (Jan 2008): different dev for NH model and PC scheme
!   30-Jun-2008 J. Masek    New dataflow for SLHD scheme.
!   K. Yessad Nov 2008: rationalisation of dummy argument interfaces
! End Modifications
!-------------------------------------------------------------------------------

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

USE YOMDIM   , ONLY : NDGSAG   ,NDGSAL   ,NDGENG   ,NDGENL   ,NDGUNG   ,&
 &                    NDGUXG   ,NDLUNG   ,NDLUXG   ,NFLEVG   ,NDGSAH   ,&
 &                    NDGENH   ,NRLEVX   ,NPROMA   ,NFLSA    ,NFLEN
USE YOMCT0   , ONLY : LRPLANE  ,LNHDYN   ,LPC_CHEAP
USE YOMDYNA  , ONLY : LGWADV   ,LSLHD    ,LSLHDQUAD,LNH_PDVD ,LSLDIA
USE YOMDYN   , ONLY : LSETTLST ,LELTRA   ,LADVF    ,NCURRENT_ITER, NSITER
USE YOMCVER  , ONLY : LVFE_GW
USE YOMCST   , ONLY : RPI
USE YOMGEM   , ONLY : NLOENG
USE YEMGEO   , ONLY : EDELX    ,EDELY
USE YOMRIP   , ONLY : RTDT
USE YOMSC2   , ONLY : NSLWIDE  ,NFLDSLB1 ,NFLDSLB2
USE YOMMP    , ONLY : NSLOFF   ,NFRSTLOFF,NASLB1
USE YOMSEP   , ONLY : LFINDVSEP
USE YOM_YGFL , ONLY : YGFL     ,YGFLC    ,YSLDIA   ,YSLDIA_NL,NSLDIA   ,NSLDIAGP
USE PTRSLB2  , ONLY : MSLB2KAPPA

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

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KST 
INTEGER(KIND=JPIM),INTENT(IN)    :: KPROF 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCOLON(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PSILON(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGM(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGEMU(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGSQM2(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGECLO(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGESLO(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGNORDL(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGNORDM(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PINDX(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PINDY(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PB1(NASLB1,NFLDSLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PB2(NPROMA,NFLDSLB2)
INTEGER(KIND=JPIM),INTENT(INOUT) :: KVSEPC 
INTEGER(KIND=JPIM),INTENT(INOUT) :: KVSEPL 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PLON(NPROMA,NFLEVG)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PLAT(NPROMA,NFLEVG)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PQX(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PQY(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PR(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PS(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PUF(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PVF(NPROMA,NFLEVG) 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KL0(NPROMA,NFLEVG,0:3) 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KLH0(NPROMA,NFLEVG,0:3) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PDLO(NPROMA,NFLEVG,0:3) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCLO(NPROMA,NFLEVG,3,2) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCLOSLD(NPROMA,NFLEVG,3,2) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PDLAT(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCLA(NPROMA,NFLEVG,3)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCLASLD(NPROMA,NFLEVG,3)
INTEGER(KIND=JPIM),INTENT(OUT)   :: KLEV(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PDVER(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PVINTW(NPROMA,NFLEVG,3) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PVINTWSLD(NPROMA,NFLEVG,3) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PVINTWS(NPROMA,NFLEVG,1:4) 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KL0H(NPROMA,0:NFLEVG-1,0:3) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PDLOH(NPROMA,0:NFLEVG-1,0:3) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCLOH(NPROMA,0:NFLEVG-1,3,2)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCLOHSLD(NPROMA,0:NFLEVG-1,3,2)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PDLATH(NPROMA,0:NFLEVG-1) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCLAH(NPROMA,0:NFLEVG-1,3)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCLAHSLD(NPROMA,0:NFLEVG-1,3)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PDVERH(NPROMA,0:NFLEVG-1) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PVINTWH(NPROMA,0:NFLEVG-1,3)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PVINTWHSLD(NPROMA,0:NFLEVG-1,3)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCOSCO(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSINCO(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCOPHI(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSINLA(NPROMA,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PVDERW(NPROMA,NFLEVG,2,2) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PHVW(NPROMA,NFLEVG,4) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PGFLT1(NPROMA,NFLEVG,YGFL%NDIM1)
!     ------------------------------------------------------------------

INTEGER(KIND=JPIM) :: IGLGLO
INTEGER(KIND=JPIM) :: IHVI
INTEGER(KIND=JPIM) :: IROT
INTEGER(KIND=JPIM) :: ISTALAT(NDGSAH:NDGENH)
INTEGER(KIND=JPIM) :: ITIP
INTEGER(KIND=JPIM) :: JGL
INTEGER(KIND=JPIM) :: JROF
INTEGER(KIND=JPIM) :: JLEV
INTEGER(KIND=JPIM) :: JGFL
INTEGER(KIND=JPIM) :: IDEP(NPROMA,NFLEVG)

LOGICAL :: LLSETTLST
LOGICAL :: LLINTV

REAL(KIND=JPRB) :: ZUF0(1), ZURL0(1), ZVF0(1)
REAL(KIND=JPRB) :: ZVRL0(1), ZWF0(1), ZWFSM(1), ZWRL0(1)

! SL diagnostics
REAL(KIND=JPRB), ALLOCATABLE  :: ZWF(:,:)

REAL(KIND=JPRB) :: ZDEPI                     ! Now only used by ELARMES
REAL(KIND=JPRB) :: ZGMDTX(NPROMA)
REAL(KIND=JPRB) :: ZGMDTY(NPROMA)
REAL(KIND=JPRB) :: ZLEV(NPROMA,NFLEVG)
REAL(KIND=JPRB) :: ZLSDEPI(NDGSAH:NDGENH)

REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

#include "elarmes.intfb.h"
#include "larcina.intfb.h"
#include "larcinha.intfb.h"
#include "larmes.intfb.h"

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

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

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

!*       1.    PRELIMINAR INITIALISATIONS:
!              ---------------------------

! The following are now only used by ELARMES:
ZDEPI=2.0_JPRB*RPI

DO JGL=MAX(NDGSAG,NDGSAL+NFRSTLOFF-NSLWIDE)-NFRSTLOFF,&
   & MIN(NDGENG,NDGENL+NFRSTLOFF+NSLWIDE)-NFRSTLOFF  
  IGLGLO=JGL+NFRSTLOFF
  ZLSDEPI(JGL)=REAL(NLOENG(IGLGLO),JPRB)/ZDEPI
ENDDO

IHVI=0
DO JGFL=1,YGFL%NUMFLDS
  IF(YGFLC(JGFL)%CSLINT == 'LAIHVT      ' .OR. &
     & YGFLC(JGFL)%CSLINT == 'LAIHVTQM    ' .OR. &
     & YGFLC(JGFL)%CSLINT == 'LAIHVTQMH   ' ) THEN  
    IHVI=1
  ENDIF
ENDDO

IF(LRPLANE) THEN
  DO JROF = KST, KPROF
    ZGMDTX (JROF)=0.5_JPRB*PGM(JROF)*RTDT/EDELX
    ZGMDTY (JROF)=0.5_JPRB*PGM(JROF)*RTDT/EDELY
  ENDDO
ENDIF

DO JGL=MAX(NDGSAH,LBOUND(NSLOFF,1)),MIN(NDGENH,UBOUND(NSLOFF,1))
  ISTALAT(JGL)=NSLOFF(JGL)
ENDDO

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

!*       2.    COMPUTATION OF THE SL TRAJECTORY.
!              ---------------------------------

LLSETTLST=LSETTLST.AND.(.NOT.LELTRA)

IF (LRPLANE) THEN

  CALL ELARMES(KST,KPROF,ISTALAT,LLSETTLST,PINDX,PINDY,ZGMDTX,ZGMDTY,PB1,PB2,&
   & ZLSDEPI,PCOLON,PSILON,PGEMU,PGSQM2,PGECLO,PGESLO,&
   & KVSEPC,KVSEPL,&
   & PLON,PLAT,PCOSCO,PSINCO,PSINLA,PCOPHI,ZLEV,PR,PS,PUF,PVF,&
   & KL0,KLH0,PDLO,PCLO,PDLAT,PCLA,KLEV,PDVER,PVINTW,PVINTWS)  

ELSE

  IF( LSLDIA ) THEN
    IF(.NOT.ALLOCATED(ZWF)) ALLOCATE(ZWF(NPROMA,NFLEVG))
  ENDIF

  CALL LARMES(KST,KPROF,ISTALAT,LLSETTLST,PB1,PB2,&
   & ZLSDEPI,PCOLON,PSILON,PGEMU,PGSQM2,PGECLO,PGESLO,PGNORDL,PGNORDM,&
   & KVSEPC,KVSEPL,&
   & PLON,PLAT,PCOSCO,PSINCO,PSINLA,PCOPHI,ZLEV,PR,PS,PUF,PVF,ZWF,&
   & KL0,KLH0,PDLO,PCLO,PDLAT,PCLA,KLEV,PDVER,PVINTW,PVINTWS)

  ! diagnostics for semi-Lagrangian scheme
  IF( LSLDIA .AND. ( LPC_CHEAP.OR.(NCURRENT_ITER == NSITER) )) THEN
    DO JGFL=NSLDIAGP+1,NSLDIA
      IF (YSLDIA_NL(JGFL)%CNAME == 'UTRAJ           ') THEN
        PGFLT1(KST:KPROF,1:NFLEVG,YSLDIA(JGFL)%MP1)=PUF(KST:KPROF,1:NFLEVG)
      ENDIF
      IF (YSLDIA_NL(JGFL)%CNAME == 'VTRAJ           ') THEN     
        PGFLT1(KST:KPROF,1:NFLEVG,YSLDIA(JGFL)%MP1)=PVF(KST:KPROF,1:NFLEVG)
      ENDIF
      IF (YSLDIA_NL(JGFL)%CNAME == 'WTRAJ           ') THEN     
        PGFLT1(KST:KPROF,1:NFLEVG,YSLDIA(JGFL)%MP1)=ZWF(KST:KPROF,1:NFLEVG)
      ENDIF
      IF (YSLDIA_NL(JGFL)%CNAME == 'LAMBDA0         ') THEN
        DO JLEV=1,NFLEVG
          DO JROF=KST,KPROF     
            PGFLT1(JROF,JLEV,YSLDIA(JGFL)%MP1)=SIN(PLON(JROF,JLEV))
          ENDDO
        ENDDO
      ENDIF
      IF (YSLDIA_NL(JGFL)%CNAME == 'THETA0          ') THEN     
        DO JLEV=1,NFLEVG
          DO JROF=KST,KPROF     
            PGFLT1(JROF,JLEV,YSLDIA(JGFL)%MP1)=SIN(PLAT(JROF,JLEV))
          ENDDO
        ENDDO
      ENDIF
      IF (YSLDIA_NL(JGFL)%CNAME == 'ETA0            ') THEN  
        PGFLT1(KST:KPROF,1:NFLEVG,YSLDIA(JGFL)%MP1)=ZLEV(KST:KPROF,1:NFLEVG)
      ENDIF
    ENDDO
  ENDIF

  IF(ALLOCATED(ZWF)) DEALLOCATE(ZWF)

ENDIF

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

!*       3.    COMPUTATION OF WEIGHTS AND INDICES ARRAYS FOR INTERPOLATIONS.
!              -------------------------------------------------------------

!*       3.1   Full-level Quantities.
!              ---------------------

IROT=1
ITIP=2

LLINTV=.FALSE.

!  Warning: ZURL0,ZVRL0,ZWRL0,ZUF0,ZVF0,ZWF0,ZWFSM are not
!           used in this call to LARCINA.

CALL LARCINA(KST,KPROF,IHVI,ISTALAT,LFINDVSEP,LSLHD,LSLHDQUAD,LLINTV,&
 & ITIP,IROT,LRPLANE,ZLSDEPI,&
 & PCOLON,PSILON,PGEMU,PGSQM2,PGECLO,PGESLO,&
 & PCOSCO,PSINCO,PSINLA,PCOPHI,ZLEV,&
 & PB2(1,MSLB2KAPPA),ZURL0,ZVRL0,ZWRL0,&
 & KVSEPC,KVSEPL,&
 & PLON,PLAT,PQX,PQY,&
 & ZUF0,ZVF0,ZWF0,ZWFSM,&
 & KL0,KLH0,PDLO,PCLO,PCLOSLD,PDLAT,PCLA,PCLASLD,&
 & KLEV,PDVER,PVINTW,PVINTWSLD,PVINTWS,&
 & PVDERW,PHVW,IDEP)

IF (LRPLANE) THEN
! * Use PSINLA and PCOPHI to transfer origin point coordinates to LAPINEB
!   for "2 Omega vectorial a k" recalculation.
  IF(LADVF) THEN
    PSINLA(KST:KPROF,1:NFLEVG)=PLON(KST:KPROF,1:NFLEVG)
    PCOPHI(KST:KPROF,1:NFLEVG)=PLAT(KST:KPROF,1:NFLEVG)
  ENDIF
ENDIF

!*       3.2   Half-level Quantities.
!              ---------------------

IF (LNHDYN.AND.LNH_PDVD.AND.LGWADV.AND.(.NOT.LVFE_GW)) THEN

  IROT=0
  ITIP=2

  CALL LARCINHA(KST,KPROF,IHVI,ISTALAT,ITIP,IROT,ZLSDEPI,&
   & PCOLON,PSILON,PGEMU,PGSQM2,PGECLO,PGESLO,&
   & PCOSCO,PSINCO,PSINLA,PCOPHI,ZLEV,PB2(1,MSLB2KAPPA),&
   & KL0H,PDLOH,PCLOH,PCLOHSLD,&
   & PDLATH,PCLAH,PCLAHSLD,PDVERH,PVINTWH,PVINTWHSLD)

ENDIF

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

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