SUBROUTINE LADINE(KSTART,KPROF,&
 & KASLB1,KPROMA,KFLDN,KFLDX,&
 & PCOLON,PSILON,PGM,PGEMU,PGSQM2,PGECLO,PGESLO,&
 & PGNORDL,PGNORDM,PINDX,PINDY,&
 & PURL0,PVRL0,PURL,PVRL,&
 & PUL0,PVL0,PCL0,PUL9,PVL9,PCL9,&
 & PUSI,PVSI,&
 & PUT1,PVT1,PSPT1 )  

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

USE YOMDIM   , ONLY : NDGSAG   ,NDGSAL   ,NDGENG   ,NDGENL   ,&
 & NDGUNG   ,NDGUXG   ,NDLUNG   ,NDLUXG   ,NDGSAH   ,&
 & NDGENH  
USE YOMLUN   , ONLY : NULOUT
USE YOMCT0   , ONLY : LRPLANE
USE YOMDYN   , ONLY : NVLAG    ,NWLAG    ,NITMP    ,&
 & VMAX1    ,VMAX2    ,LADVF    ,LQMHW    ,&
 & LQMHP    ,LSETTLST ,L2TLFF   ,LELTRA  
USE YOMCST   , ONLY : RPI      ,ROMEGA   ,RA
USE YOMLEG   , ONLY : RLATI    ,RIPI0    ,RIPI1    ,RIPI2
USE YOMGEM   , ONLY : NLOENG   ,NSTTYP   ,RMUCEN   ,RLOCEN   ,&
 & RSTRET   ,R4JP     ,RC2P1    ,RC2M1  
USE YOMRIP   , ONLY : RDTSA    ,RDTS62   ,RDTS22   ,RTDT
USE YOMSC2   , ONLY : NSLWIDE
USE YOMMP    , ONLY : NSLOFF   ,NFRSTLOFF
USE YEMGEO   , ONLY : EDELX    ,EDELY

!**** *LADINE* - semi-LAgrangian scheme:
!                Interface subroutine for interpolations and lagrangian
!                trends. (Programme INterface d'Ensemble).
!                2D Shallow water.

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

!           Computes the medium point M and origin point O.
!           Does interpolations at O.
!           Computes lagrangian trends.

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

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

!        INPUT:
!          KSTART  - first element of arrays where
!                    computations are performed.
!          KPROF   - depth of work.
!          KASLB1  - horizontal dimension for semi-Lagrangian buffer.
!          KPROMA  - horizontal dimension.
!          KFLDN   - number of the first field for semi-lag variables.
!          KFLDX   - number of the last field for semi-lag variables.
!          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 normalized vector directed
!                    towards the geographical north pole.
!          PGNORDM - meridian component of the normalized vector directed
!                    towards the geographical north pole.
!          PINDX   - x coordinate on the plane.
!          PINDY   - y coordinate on the plane.
!          PURL0   - U-wind, to be interpolated.
!          PVRL0   - V-wind, to be interpolated.
!          PURL    - U-wind for research of medium point.
!          PVRL    - V-wind for research of medium point.
!          PUL0    - Quantity to interpolate linearly at O in the
!                    U-wind equation if NWLAG=3.
!          PVL0    - Quantity to interpolate linearly at O in the
!                    V-wind equation if NWLAG=3.
!          PCL0    - Quantity to interpolate linearly at O in the
!                    continuity equation if NVLAG=3.
!          PUL9    - Quantity to interpolate at O in the U-wind equation.
!          PVL9    - Quantity to interpolate at O in the V-wind equation.
!          PCL9    - Quantity to interpolate at O in the continuity equation.
!          PUSI    - Part of the t semi-implicit term evaluated at the
!                    final point in the U-wind equation.
!          PVSI    - Part of the t semi-implicit term evaluated at the
!                    final point in the V-wind equation.

!        INPUT AND OUTPUT:
!          PUT1    - t+dt U-wind.
!          PVT1    - t+dt V-wind.
!          PSPT1   - t+dt equivalent height.

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

!     Method.
!     -------

!     Externals.    LARMES2  - Computes the medium point coordinates then
!     ----------               interpolations at this point.
!                   ELARMES2 - idem for plane geometry.
!                   LAINOR2  - Computes the origin point coordinates then
!                              interpolations at this point.
!                   LACONE   - Analytical computation of 2*Omega*Vec*r if
!                              LADVF=.T.
!                   LARCHE
!                   Called by CPG2LAG.

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

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

!     Modifications.
!     --------------
!        Original : FEBRUARY 1992
!        Modification by K. YESSAD: MAY 1992.
!        Modified by M. HORTAL (ECMWF) and K. YESSAD (CNRM/GMAP): 04/11/1992.
!        Modification by K. YESSAD: DEC 1992.
!        Modified 93-12-14 by K. YESSAD: interpolations at medium point for
!                                      semi-lagrangian temperature equation.
!        Modified 93-12-21 by C. Temperton: interpolations at medium point for
!                                      semi-lagrangian moisture equation.
!        Modified 94-03-23 by M. Hortal: interpolations at medium point for
!                                      semi-lagrangian momentum equations.
!        Modified 94-01-28 by M. Tolstykh (orography term in shallow water
!                   semi-lagrangian scheme).
!        Modified 94-10-17 by M. Tolstykh: CUD-5 interpolation
!        K. YESSAD (JAN 1995):
!             - Introduction of array RCUDWM for optimisations of CUD-5
!               meridian derivatives.
!             - Remove of useless arrays ZGOMVRL and ZGOMVRM (all corresponding
!               computations made in CPG2 for implicit treatment of Coriolis
!               terms).
!             - Simplification of treatment of NVLAG=2 formulation of
!               2D shallow-water continuity equation.
!        R. BUBNOVA (JAN 1995): Plane geometry.
!        K. YESSAD (AUGUST 1995):
!             - Update dummy arguments in CALL LAINOR (accurate 2TL SL scheme).
!             - DO loops updated according to F90 norms.
!       Modified 96-10-23 by M. Hortal: LTWOTL passed to LARMES
!               (wind averaged along trajectory to find midpoint in 2TL scheme)
!        K. YESSAD (MARCH 1996): 
!             - New arguments to LARMES and LAINOR.
!       Modified 97-05-19 by C. Temperton: LCORAN,LEVGO,LCUTRA options added
!       Modified 98-01-19 by C. Temperton: 2TL SL; call LARMES2 and LAINOR2
!       Modified 98-06-11 by C. Fischer: add ELARMES2
!       Modified July 1998 by K. YESSAD and C. TEMPERTON: cleaning
!             - 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.
!             - rewrite the code in a manner more consistent with lapine.F (3D).
!             - removal of the CUD-5 interpolations.
!       Modified 98-12-18 by K. YESSAD: allow LELTRA for trajectory with
!        LSETTLS for RHS equations.
!       Modified 99-12-22 by C. Fischer: clean out call to elarmes2
!       Modified 00-03-07 by C. Temperton: Bugfixes
!       Modified 01-08-30 by K. YESSAD: pruning and some other cleanings.
!       R. El Khatib : 01-08-07 Pruning options
!       M.Hamrud      01-Oct-2003 CY28 Cleaning
!   N. Wedi and K. Yessad (Jan 2008): different dev for NH model and PC scheme
!   J. Masek  30-Jun-2008  Dataflow for new SLHD interpolators.
!   K. Yessad Nov 2008: rationalisation of dummy argument interfaces
!     ------------------------------------------------------------------

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KASLB1 
INTEGER(KIND=JPIM),INTENT(IN)    :: KPROMA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KFLDN 
INTEGER(KIND=JPIM),INTENT(IN)    :: KFLDX 
INTEGER(KIND=JPIM),INTENT(IN)    :: KSTART 
INTEGER(KIND=JPIM),INTENT(IN)    :: KPROF 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCOLON(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PSILON(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGM(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGEMU(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGSQM2(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGECLO(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGESLO(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGNORDL(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGNORDM(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PINDX(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PINDY(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PURL0(KASLB1,KFLDN:KFLDX) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVRL0(KASLB1,KFLDN:KFLDX) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PURL(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVRL(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PUL0(KASLB1,KFLDN:KFLDX) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVL0(KASLB1,KFLDN:KFLDX) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCL0(KASLB1,KFLDN:KFLDX) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PUL9(KASLB1,KFLDN:KFLDX) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVL9(KASLB1,KFLDN:KFLDX) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCL9(KASLB1,KFLDN:KFLDX) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PUSI(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVSI(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PUT1(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PVT1(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PSPT1(KPROMA) 

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

! - trigonometric arrays.
REAL(KIND=JPRB) :: ZSINCO(KPROMA)
REAL(KIND=JPRB) :: ZCOSCO(KPROMA)
REAL(KIND=JPRB) :: ZSINLA(KPROMA)
REAL(KIND=JPRB) :: ZCOPHI(KPROMA)
REAL(KIND=JPRB) :: ZP    (KPROMA)
REAL(KIND=JPRB) :: ZQ    (KPROMA)
REAL(KIND=JPRB) :: ZR    (KPROMA)
REAL(KIND=JPRB) :: ZS    (KPROMA)
! - interpolated quantities arrays.
REAL(KIND=JPRB) :: ZU9(KPROMA)
REAL(KIND=JPRB) :: ZV9(KPROMA)
REAL(KIND=JPRB) :: ZC9(KPROMA)
REAL(KIND=JPRB) :: ZZUZ9(KPROMA)         ! To allow L2TLFF option
REAL(KIND=JPRB) :: ZZVZ9(KPROMA)         ! To allow L2TLFF option
! - geographical parameters.
REAL(KIND=JPRB) :: ZGMDTX(KPROMA)
REAL(KIND=JPRB) :: ZGMDTY(KPROMA)
REAL(KIND=JPRB) :: ZINEZV(KPROMA)
REAL(KIND=JPRB) :: ZLON(KPROMA)
REAL(KIND=JPRB) :: ZLAT(KPROMA)
REAL(KIND=JPRB) :: ZLSDEPI(NDGSAH:NDGENH)

INTEGER(KIND=JPIM) :: ISTALAT(NDGSAH:NDGENH)

INTEGER(KIND=JPIM) :: IGLGLO, JGL, JROF

LOGICAL :: LLSETTLST

REAL(KIND=JPRB) :: ZCOPH, ZDEPI, ZDGUN, ZDGUX, ZDLUN, ZDLUX,&
 & ZDSTRET, ZPHI, ZPIS2, ZPP, ZPP1, ZPP9, ZQQ, &
 & ZQQ1, ZQQ9, ZSINX, ZTXO, ZTYO, ZUT1, ZVT1  
REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

#include "abor1.intfb.h"
#include "elarche.intfb.h"
#include "lacone.intfb.h"
#include "lainor2.intfb.h"
#include "larche.intfb.h"
#include "larmes2.intfb.h"

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

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

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

!*       1.    PRELIMINARY INITIALISATIONS:
!              ----------------------------

ZDEPI  =2.0_JPRB*RPI
ZPIS2  =0.5_JPRB*RPI

ZDSTRET=2.0_JPRB*RSTRET
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

IF(LRPLANE) THEN
  ZDLUN=REAL(NDLUNG,JPRB)
  ZDLUX=REAL(NDLUXG,JPRB)
  ZDGUN=REAL(NDGUNG,JPRB)
  ZDGUX=REAL(NDGUXG,JPRB)
  DO JROF = KSTART, KPROF
    ZGMDTX (JROF)=0.5_JPRB*PGM(JROF)*RTDT/EDELX
    ZGMDTY (JROF)=0.5_JPRB*PGM(JROF)*RTDT/EDELY
    ZINEZV(JROF)=MAX(0.0_JPRB,SIGN(1.0_JPRB,(PINDX(JROF)-ZDLUN)*&
     & (ZDLUX-PINDX(JROF))))*&
     & MAX(0.0_JPRB,SIGN(1.0_JPRB,(PINDY(JROF)-ZDGUN)*(ZDGUX-PINDY(JROF))))  
  ENDDO
ENDIF

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

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

!*       2.    COMPUTATION OF THE MEDIUM POINT AND
!              INTERPOLATIONS AT THIS POINT.
!              ------------------------------------

LLSETTLST=LSETTLST.AND.(.NOT.LELTRA)
IF (LRPLANE) THEN
  CALL ABOR1('LADINE: ELARMES2 NOT YET CODED ')
ELSE
  CALL LARMES2(KASLB1,KPROMA,KSTART,KPROF,NDGSAH,NDGENH,&
   & KFLDN,KFLDX,NDLUNG,NDLUXG,NDGUNG,NDGUXG,&
   & NULOUT,ISTALAT,&
   & NVLAG,NWLAG,NITMP,VMAX1,VMAX2,&
   & LRPLANE,LLSETTLST,LELTRA,&
   & PURL0,PVRL0,PURL,PVRL,&
   & NSTTYP,ZDSTRET,RC2M1,RC2P1,R4JP,RPI,ZDEPI,ZPIS2,&
   & RDTSA,RDTS62,RDTS22,&
   & RLOCEN,RMUCEN,ZLSDEPI,RLATI(NDGSAH),RIPI0(NDGSAH),&
   & RIPI1(NDGSAH),RIPI2(NDGSAH),&
   & PCOLON,PSILON,PGEMU,PGSQM2,PGECLO,PGESLO,&
   & PGNORDL,PGNORDM,&
   & ZLON,ZLAT,&
   & ZCOSCO,ZSINCO,ZSINLA,ZCOPHI,&
   & ZR,ZS)  
ENDIF

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

!*       3.    COMPUTATION OF THE ORIGIN POINT AND
!              INTERPOLATIONS AT THIS POINT.
!              ------------------------------------

CALL LAINOR2(KASLB1,KPROMA,KSTART,KPROF,NDGSAH,NDGENH,KFLDN,KFLDX,&
 & NDLUNG,NDLUXG,NDGUNG,NDGUXG,&
 & ISTALAT,&
 & NVLAG,NWLAG,&
 & LRPLANE,LQMHW,LQMHP,&
 & PUL9,PVL9,PCL9,PUL0,PVL0,PCL0,&
 & PINDX,PINDY,&
 & NSTTYP,ZDSTRET,RC2M1,RC2P1,R4JP,RPI,ZDEPI,ZPIS2,&
 & RLOCEN,RMUCEN,ZLSDEPI,RLATI(NDGSAH),RIPI0(NDGSAH),&
 & RIPI1(NDGSAH),RIPI2(NDGSAH),&
 & PCOLON,PSILON,PGEMU,PGSQM2,PGECLO,PGESLO,&
 & ZCOSCO,ZSINCO,ZSINLA,ZCOPHI,&
 & ZLON,ZLAT,&
 & ZP,ZQ,&
 & ZU9,ZV9,ZC9,&
 & ZZUZ9,ZZVZ9)  

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

!*       4.    COMPUTATION OF LAGRANGIAN TRENDS.
!              ---------------------------------

!*       4.1   MOMENTUM EQUATION.

DO JROF=KSTART,KPROF
  ZPP=ZP(JROF)*PGNORDM(JROF)-ZQ(JROF)*PGNORDL(JROF)
  ZQQ=ZQ(JROF)*PGNORDM(JROF)+ZP(JROF)*PGNORDL(JROF)
  PUT1(JROF) = PUT1(JROF) + ZPP*ZU9(JROF) + ZQQ*ZV9(JROF)
  PVT1(JROF) = PVT1(JROF) - ZQQ*ZU9(JROF) + ZPP*ZV9(JROF)
ENDDO

IF (LADVF) THEN

  IF (LRPLANE) THEN

!*        calculation of LACONE done already in ELARCHE -> results are in
!         zlon, zlat tables.

    DO JROF=KSTART,KPROF
      ZU9(JROF)=ZLON(JROF)
      ZV9(JROF)=ZLAT(JROF)
    ENDDO

  ELSE

    CALL LACONE(KPROMA,KSTART,KPROF,1,NSTTYP,&
     & ROMEGA,ZDSTRET,RC2M1,RC2P1,RMUCEN,&
     & RA,RPI,ZLON,ZLAT,ZU9,ZV9)  

  ENDIF

  DO JROF=KSTART,KPROF
    ZPP=ZP(JROF)*PGNORDM(JROF)-ZQ(JROF)*PGNORDL(JROF)
    ZQQ=ZQ(JROF)*PGNORDM(JROF)+ZP(JROF)*PGNORDL(JROF)
    PUT1(JROF) = PUT1(JROF) + ZPP*ZU9(JROF) + ZQQ*ZV9(JROF)
    PVT1(JROF) = PVT1(JROF) - ZQQ*ZU9(JROF) + ZPP*ZV9(JROF)
  ENDDO

ENDIF

!     Refined treatment of Coriolis term in 2TL scheme (or in 3TL scheme).
!     Works for the following configurations:
!      - 3TL SL scheme, LADVF=.T. or 2TL SL scheme, LADVF=.T.
!      - RW2TLFF=1.
!     Contrary to the 3D model where (PUSI, PVSI) are already substracted
!      in the not lagged calculations (because of t+dt physics), (PUSI,PVSI)
!      has to be substracted here.

IF (L2TLFF) THEN

  IF (LRPLANE) THEN

!   * compute new origin point:
    DO JROF=KSTART,KPROF
!     * old rotation and vector deplacement:
      ZPP=ZP(JROF)*PGNORDM(JROF)-ZQ(JROF)*PGNORDL(JROF)
      ZQQ=ZQ(JROF)*PGNORDM(JROF)+ZP(JROF)*PGNORDL(JROF)
!     * new estimate of trajectory wind:
      ZUT1=0.5_JPRB*((PUT1(JROF)-PUSI(JROF))+ZZUZ9(JROF))
      ZVT1=0.5_JPRB*((PVT1(JROF)-PVSI(JROF))+ZZVZ9(JROF))
!     * subtract old estimate of advected Coriolis term:
      PUT1(JROF)=PUT1(JROF)-ZPP*ZU9(JROF)-ZQQ*ZV9(JROF)
      PVT1(JROF)=PVT1(JROF)+ZQQ*ZU9(JROF)-ZPP*ZV9(JROF)
!     * compute new origin point:
      ZTXO=PINDX(JROF)-2.0_JPRB*ZUT1*ZGMDTX(JROF)
      ZTYO=PINDY(JROF)-2.0_JPRB*ZVT1*ZGMDTY(JROF)
      ZLON(JROF)=ZTXO*ZINEZV(JROF)+PINDX(JROF)*(1.0_JPRB-ZINEZV(JROF))
      ZLAT(JROF)=ZTYO*ZINEZV(JROF)+PINDY(JROF)*(1.0_JPRB-ZINEZV(JROF))
      ZTXO=MIN(MAX(ZTXO,ZDLUN),ZDLUX)
      ZTYO=MIN(MAX(ZTYO,ZDGUN),ZDGUX)
      ZCOSCO(JROF)=ZTXO*ZINEZV(JROF)+PINDX(JROF)*(1.0_JPRB-ZINEZV(JROF))
      ZSINCO(JROF)=ZTYO*ZINEZV(JROF)+PINDY(JROF)*(1.0_JPRB-ZINEZV(JROF))
    ENDDO
!   * compute rotation matrix and Coriolis term at the new origin point.
    CALL ELARCHE(KPROMA,KSTART,KPROF,1,&
     & PGEMU,PGSQM2,PGECLO,PGESLO,&
     & ZCOSCO,ZSINCO,ZP,ZQ,ZLON,ZLAT)  
    ZU9(KSTART:KPROF)=ZLON(KSTART:KPROF)
    ZV9(KSTART:KPROF)=ZLAT(KSTART:KPROF)
!   * add new estimate of advected Coriolis term:
    DO JROF=KSTART,KPROF
      ZPP=ZP(JROF)*PGNORDM(JROF)-ZQ(JROF)*PGNORDL(JROF)
      ZQQ=ZQ(JROF)*PGNORDM(JROF)+ZP(JROF)*PGNORDL(JROF)
      PUT1(JROF) = PUT1(JROF) + ZPP*ZU9(JROF) + ZQQ*ZV9(JROF)
      PVT1(JROF) = PVT1(JROF) - ZQQ*ZU9(JROF) + ZPP*ZV9(JROF)
    ENDDO

  ELSE

!   * compute new origin point:
    DO JROF=KSTART,KPROF
      ZPP=ZP(JROF)*PGNORDM(JROF)-ZQ(JROF)*PGNORDL(JROF)
      ZQQ=ZQ(JROF)*PGNORDM(JROF)+ZP(JROF)*PGNORDL(JROF)
      ZPP9=ZP(JROF)
      ZQQ9=ZQ(JROF)
      ZPP1=PGNORDM(JROF)
      ZQQ1=-PGNORDL(JROF)
!     * new estimate of trajectory wind:
      ZUT1=0.5_JPRB*(&
       & ZPP1*(PUT1(JROF)-PUSI(JROF))+ZQQ1*(PVT1(JROF)-PVSI(JROF))&
       & +ZPP9*ZZUZ9(JROF)+ZQQ9*ZZVZ9(JROF))  
      ZVT1=0.5_JPRB*(&
       & -ZQQ1*(PUT1(JROF)-PUSI(JROF))+ZPP1*(PVT1(JROF)-PVSI(JROF))&
       & -ZQQ9*ZZUZ9(JROF)+ZPP9*ZZVZ9(JROF))  
!     * subtract old estimate of advected Coriolis term:
      PUT1(JROF)=PUT1(JROF)-ZPP*ZU9(JROF)-ZQQ*ZV9(JROF)
      PVT1(JROF)=PVT1(JROF)+ZQQ*ZU9(JROF)-ZPP*ZV9(JROF)
!     * compute new origin point:
      ZPHI=0.5_JPRB*RTDT*SQRT(ZUT1*ZUT1+ZVT1*ZVT1)/RA
      ZCOPH=1.0_JPRB-0.5_JPRB*ZPHI*ZPHI
      ZSINX=ZCOPH*RTDT*(1.0_JPRB-ZPHI*ZPHI/6.0_JPRB)/RA
      ZSINLA(JROF)=PGEMU(JROF)*(2.0_JPRB*ZCOPH*ZCOPH-1.0_JPRB)&
       & -ZVT1*PGSQM2(JROF)*ZSINX  
      ZCOSCO(JROF)=PGSQM2(JROF)*(2.0_JPRB*ZCOPH*ZCOPH-1.0_JPRB)&
       & +ZVT1*PGEMU(JROF)*ZSINX  
      ZSINCO(JROF)=-ZUT1*ZSINX
      ZCOPHI(JROF)=2.0_JPRB*ZCOPH*ZCOPH-1.0_JPRB
    ENDDO
!   * compute rotation matrix and Coriolis term at the new origin point.
    CALL LARCHE(KPROMA,KSTART,KPROF,1,NSTTYP,ZDSTRET,RC2M1,RC2P1,&
     & RPI,ZDEPI,RLOCEN,RMUCEN,PCOLON,PSILON,PGEMU,PGSQM2,PGECLO,&
     & PGESLO,ZCOSCO,ZSINCO,ZSINLA,ZCOPHI,1,ZLON,ZLAT,ZP,ZQ)  
    CALL LACONE(KPROMA,KSTART,KPROF,1,NSTTYP,&
     & ROMEGA,ZDSTRET,RC2M1,RC2P1,RMUCEN,&
     & RA,RPI,ZLON,ZLAT,ZU9,ZV9)  
!   * add new estimate of advected Coriolis term:
    DO JROF=KSTART,KPROF
      ZPP=ZP(JROF)*PGNORDM(JROF)-ZQ(JROF)*PGNORDL(JROF)
      ZQQ=ZQ(JROF)*PGNORDM(JROF)+ZP(JROF)*PGNORDL(JROF)
      PUT1(JROF) = PUT1(JROF) + ZPP*ZU9(JROF) + ZQQ*ZV9(JROF)
      PVT1(JROF) = PVT1(JROF) - ZQQ*ZU9(JROF) + ZPP*ZV9(JROF)
    ENDDO

  ENDIF

ENDIF

!*       4.2   CONTINUITY EQUATION.

DO JROF=KSTART,KPROF
  PSPT1(JROF)=PSPT1(JROF)+ZC9(JROF)
ENDDO

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

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