#ifdef RS6K
@PROCESS NOCHECK
#endif
SUBROUTINE CALL_SL_TL(PB1,PB15,PB2,PGFLT1)

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

USE YOMCT0   , ONLY : NPROC    ,NSTART   ,NSTOP
USE YOMGC    , ONLY : GEMU     ,GECLO    ,GESLO  ,&
 & GM       ,GNORDL   ,GNORDM   ,GSQM2  
USE YOMGEM   , ONLY : RCOLON   ,RSILON   ,RINDX    ,RINDY    ,NGPTOT,NLOENG
USE YOMDIM   , ONLY : NFLEVG   ,NPROMA   ,NGPBLKS  ,NFLSA    ,NFLEN    ,&
 & NDGLG   ,NDGSAG   ,NDGENG   ,NDGSAL   ,NDGENL   ,NFLSUL
USE YOMDYN   , ONLY : NITMP
USE PTRSLB1  , ONLY : MSLB1UR0 ,MSLB1WR0 ,RPARSL1  
USE PTRSLB15 , ONLY : MSLB1UR05,MSLB1WR05,RPARSL15  
USE YOMMP    , ONLY : NASLB1    ,NSLPROCS  ,&
 & NSLRPT    ,NSLSPT    ,NSLSENDPOS,&
 & NSLRECVPOS,NSENDPTR  ,NRECVPTR  ,NSLCOMM   ,LSLCOMM ,&
 & NSLSTA    ,NSLONL    ,NSLOFF    ,NFRSTLOFF ,&
 & MYFRSTACTLAT         ,MYLSTACTLAT  
USE YOMCT3   ,ONLY : NSTEP
USE YOMVAR  , ONLY : NSIM4D
USE YOMSC2   , ONLY : NSLWIDE   ,NFLDSLB1   ,NFLDSLB15,  NFLDSLB2
USE YOMMASK  , ONLY : LSLONDEM,  NFIXSFLD, LSLONDEM_ACTIVE,  &
 & MASK_SL1  ,MASK_SL2, MFIELD_TYPE1 ,MFIELD_TYPE15 ,&
 & MASK_SL2A, MASK_SL3, LNEW_MASK_SL, &
 & MASK_SL2T, MASK_SL2AT, MASK_SL3T
USE YOMGMV   , ONLY : GMVT1,GMVT1S
USE YOM_YGFL , ONLY : YGFL

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

!**** *CALL_SL_TL* - Semi-Lagrangian Interpolation TL

!     Purpose.
!     --------
!           Semi-Lagrangian Interpolation TL

!**   Interface.
!     ----------
!        *CALL* *CALL_SL_TL*

!        Explicit arguments :
!        --------------------
!        INPUT/OUTPUT:
!          PB1     - SLBUF1-buffer for interpolations.
!          PB15    - SLBUF1-buf traj for interpolations
!          PB2     - SLBUF2-buf to communicate info from non lag. to lag. dyn.
!          PGFLT1  - GFL variables at t+dt.

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

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

!     Externals.
!     ----------
!        Called by GP_MODEL_TL.

!     Author.
!     -------
!        Deborah Salmond 

!     Modifications.
!     --------------
!   Modified 00-11-09 by C. Temperton: changed call to LAPINETL_TRAJ
!   Modified 00-11-23 by C. Temperton: renamed _TRAJ and _INT routines.
!   Modified 01-08-30 by K. YESSAD: pruning and some other cleanings.
!   Modified at ECMWF (24 -> 24R1): some local arrays become allocatable.
!   Modified 02-10-01 G.Mozdzynski: support for radiation on-demand comms
!   M.Hamrud      01-Oct-2003 CY28 Cleaning
!   D.Salmond     22-Dec-2003 Karim's Larcin cleaning
!   Modified 05-01-19 by C. Temperton: cleaning.
!   D.Salmond     08-Feb-2005 Call to LAPINEA5 inserted as in CALL_SL_AD
!   F. Vana       08-Jan-2007 plane geometry extension
!   N. Wedi and K. Yessad (Jan 2008): different dev for NH model and PC scheme
!   F. Vana       30-Jun-2008 Weights driven interpolation
!   K. Yessad Nov 2008: rationalisation of dummy argument interfaces
!   K. Yessad Dec 2008: merge SLCOMM+SLCOMM1 -> SLCOMM.
!   K. Yessad Dec 2008: merge the different (E)SLEXTPOL.. -> (E)SLEXTPOL.
!   F. Vana  13-Jan-2009: TL/AD of SLHD
!     ------------------------------------------------------------------

IMPLICIT NONE

REAL(KIND=JPRB)   ,INTENT(INOUT) :: PB1(NASLB1,NFLDSLB1) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PB15(NASLB1,NFLDSLB15) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PB2(NPROMA,NFLDSLB2,NGPBLKS) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PGFLT1(NPROMA,NFLEVG,YGFL%NDIM1,NGPBLKS) 

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

INTEGER(KIND=JPIM) :: JSTGLO, IST, IEND, IBL, IOFF, JSTEP
INTEGER(KIND=JPIM) :: J, IDIFF2, IDIFF2A
INTEGER(KIND=JPIM) :: IDUMARR(2)

LOGICAL :: LLINC, LLEXCLUDE

! * trigonometric arrays.

REAL(KIND=JPRB) :: ZR    (NPROMA,NFLEVG,NGPBLKS)
REAL(KIND=JPRB) :: ZS    (NPROMA,NFLEVG,NGPBLKS)
REAL(KIND=JPRB) :: ZR5   (NPROMA,NFLEVG,NITMP,NGPBLKS)
REAL(KIND=JPRB) :: ZS5   (NPROMA,NFLEVG,NITMP,NGPBLKS)
REAL(KIND=JPRB) :: ZUF5  (NPROMA,NFLEVG,NITMP-1,NGPBLKS)
REAL(KIND=JPRB) :: ZVF5  (NPROMA,NFLEVG,NITMP-1,NGPBLKS)
REAL(KIND=JPRB) :: ZLON  (NPROMA,NFLEVG,NGPBLKS)
REAL(KIND=JPRB) :: ZLAT  (NPROMA,NFLEVG,NGPBLKS)
REAL(KIND=JPRB) :: ZLON5 (NPROMA,NFLEVG,NITMP,NGPBLKS)
REAL(KIND=JPRB) :: ZLAT5 (NPROMA,NFLEVG,NITMP,NGPBLKS)

! * interpolated quantities arrays.

INTEGER(KIND=JPIM), ALLOCATABLE :: IL0(:,:,:,:,:)
INTEGER(KIND=JPIM), ALLOCATABLE :: ILH0(:,:,:,:)
INTEGER(KIND=JPIM), ALLOCATABLE :: IDEP(:,:,:)

REAL(KIND=JPRB), ALLOCATABLE :: ZDLO(:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZCLO(:,:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZCLOSLD(:,:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZDLAT(:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZCLA(:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZCLASLD(:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZDVER(:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZVINTW(:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZVINTWSLD(:,:,:,:)

REAL(KIND=JPRB), ALLOCATABLE :: ZDLO5(:,:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZCLO5(:,:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZCLOSLD5(:,:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZDLAT5(:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZCLA5(:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZCLASLD5(:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZDVER5(:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZVINTW5(:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZVINTWSLD5(:,:,:,:)

REAL(KIND=JPRB), ALLOCATABLE :: ZCOSCO(:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZSINLA(:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZSINCO(:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZCOPHI(:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZLEV(:,:,:)

REAL(KIND=JPRB), ALLOCATABLE :: ZCOSCO5(:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZSINLA5(:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZSINCO5(:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZCOPHI5(:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZLEV5(:,:,:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZOUT5(:,:,:,:)

REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

#include "lapinea5.intfb.h"
#include "lapineatl.intfb.h"
#include "lapinebtl.intfb.h"
#include "slcomm.intfb.h"
#include "slcomm2a.intfb.h"
#include "slextpol.intfb.h"

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

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

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

!*       0.    PRELIMINARY ALLOCATIONS.
!              -----------------------

ALLOCATE(IL0(NPROMA,NFLEVG,0:3,NITMP,NGPBLKS))
ALLOCATE(ILH0(NPROMA,NFLEVG,0:3,NGPBLKS))
ALLOCATE(IDEP(NPROMA,NFLEVG,NGPBLKS))

ALLOCATE(ZDLO(NPROMA,NFLEVG,0:3,NGPBLKS))
ALLOCATE(ZCLO(NPROMA,NFLEVG,3,2,NGPBLKS))
ALLOCATE(ZCLOSLD(NPROMA,NFLEVG,3,2,NGPBLKS))
ALLOCATE(ZDLAT(NPROMA,NFLEVG,NGPBLKS))
ALLOCATE(ZCLA(NPROMA,NFLEVG,3,NGPBLKS))
ALLOCATE(ZCLASLD(NPROMA,NFLEVG,3,NGPBLKS))
ALLOCATE(ZDVER(NPROMA,NFLEVG,NGPBLKS))
ALLOCATE(ZVINTW(NPROMA,NFLEVG,3,NGPBLKS))
ALLOCATE(ZVINTWSLD(NPROMA,NFLEVG,3,NGPBLKS))

ALLOCATE(ZDLO5(NPROMA,NFLEVG,0:3,NITMP,NGPBLKS))
ALLOCATE(ZCLO5(NPROMA,NFLEVG,3,2,NGPBLKS))
ALLOCATE(ZCLOSLD5(NPROMA,NFLEVG,3,2,NGPBLKS))
ALLOCATE(ZDLAT5(NPROMA,NFLEVG,NITMP,NGPBLKS))
ALLOCATE(ZCLA5(NPROMA,NFLEVG,3,NGPBLKS))
ALLOCATE(ZCLASLD5(NPROMA,NFLEVG,3,NGPBLKS))
ALLOCATE(ZDVER5(NPROMA,NFLEVG,NITMP,NGPBLKS))
ALLOCATE(ZVINTW5(NPROMA,NFLEVG,3,NGPBLKS))
ALLOCATE(ZVINTWSLD5(NPROMA,NFLEVG,3,NGPBLKS))

ALLOCATE(ZCOSCO(NPROMA,NFLEVG,NGPBLKS))
ALLOCATE(ZSINLA(NPROMA,NFLEVG,NGPBLKS))
ALLOCATE(ZSINCO(NPROMA,NFLEVG,NGPBLKS))
ALLOCATE(ZCOPHI(NPROMA,NFLEVG,NGPBLKS))
ALLOCATE(ZLEV(NPROMA,NFLEVG,NGPBLKS))

ALLOCATE(ZCOSCO5(NPROMA,NFLEVG,NITMP,NGPBLKS))
ALLOCATE(ZSINLA5(NPROMA,NFLEVG,NITMP,NGPBLKS))
ALLOCATE(ZSINCO5(NPROMA,NFLEVG,NITMP,NGPBLKS))
ALLOCATE(ZCOPHI5(NPROMA,NFLEVG,NITMP,NGPBLKS))
ALLOCATE(ZLEV5(NPROMA,NFLEVG,NITMP,NGPBLKS))
ALLOCATE(ZOUT5(NPROMA,NFLEVG,NITMP,NGPBLKS))

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

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

LLINC=.FALSE.

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

!*       2.    FIRST PART OF PROCESSOR COMMUNICATIONS WHEN NEEDED.
!              ---------------------------------------------------

CALL GSTATS(34,2)
CALL GSTATS(84,0)

IF (NPROC > 1) THEN

  IF(LSLONDEM)THEN
    LNEW_MASK_SL=.TRUE.
    LSLONDEM_ACTIVE=.TRUE.
  ENDIF

  IF (LSLONDEM_ACTIVE) THEN
    IF(ALLOCATED(MASK_SL2))DEALLOCATE(MASK_SL2)
    ALLOCATE(MASK_SL2(NASLB1+4))
    IF(ALLOCATED(MASK_SL2A))DEALLOCATE(MASK_SL2A)
    ALLOCATE(MASK_SL2A(NASLB1+4))
    IF(ALLOCATED(MASK_SL3))DEALLOCATE(MASK_SL3)
    ALLOCATE(MASK_SL3(NASLB1+4))
    MASK_SL2=0
    MASK_SL2A=0
    MASK_SL3=0
    IF( NSIM4D==0 .AND. NSTEP==NSTART )THEN
      IF(ALLOCATED(MASK_SL2T))DEALLOCATE(MASK_SL2T)
      ALLOCATE(MASK_SL2T(NASLB1+4,NSTART:NSTOP-1))
      IF(ALLOCATED(MASK_SL2AT))DEALLOCATE(MASK_SL2AT)
      ALLOCATE(MASK_SL2AT(NASLB1+4,NSTART:NSTOP-1))
      IF(ALLOCATED(MASK_SL3T))DEALLOCATE(MASK_SL3T)
      ALLOCATE(MASK_SL3T(NASLB1+4,NSTART:NSTOP-1))
!$OMP PARALLEL DO SCHEDULE(STATIC) PRIVATE(JSTEP)
      DO JSTEP=NSTART,NSTOP-1
        MASK_SL2T(:,JSTEP)=0
        MASK_SL2AT(:,JSTEP)=0
        MASK_SL3T(:,JSTEP)=0
      ENDDO
!$OMP END PARALLEL DO    
    ENDIF
  ENDIF

  IF (LSLONDEM_ACTIVE) THEN
    IF( NSIM4D==0 )THEN
      NFIXSFLD(1)=MSLB1UR0
      NFIXSFLD(2)=MSLB1WR0+NFLEVG+NFLSUL
      CALL SLCOMM(NASLB1,NSLPROCS,NSLRPT,&
       & NSLSPT,NSLSENDPOS,NSLRECVPOS,NSENDPTR,NRECVPTR,NSLCOMM,&
       & NFIXSFLD,NFLDSLB1,LLINC,1,PB1,LDSLCOMM=LSLCOMM(:,NSTEP))  
    ELSE
      NFIXSFLD(1)=1
      NFIXSFLD(2)=NFLDSLB1
      LLEXCLUDE=.FALSE.
      CALL SLCOMM2A(NASLB1,NSLPROCS,NSLRPT,&
       & NSLSPT,NSLSENDPOS,NSLRECVPOS,NSENDPTR,NRECVPTR,NSLCOMM,&
       & NFIXSFLD,LLEXCLUDE,MASK_SL1,MASK_SL2T(:,NSTEP),MASK_SL2AT(:,NSTEP),MASK_SL3T(:,NSTEP),&
       & NFLDSLB1,LLINC,PB1,MFIELD_TYPE1,LDSLCOMM=LSLCOMM(:,NSTEP))  
    ENDIF
  ELSE
    CALL SLCOMM(NASLB1,NSLPROCS,NSLRPT,&
     & NSLSPT,NSLSENDPOS,NSLRECVPOS,NSENDPTR,NRECVPTR,NSLCOMM,&
     & IDUMARR,NFLDSLB1,LLINC,0,PB1)  
  ENDIF

ENDIF

IF (LSLONDEM_ACTIVE) THEN
  CALL SLEXTPOL(NSLWIDE,NSLWIDE,&
   & NASLB1,NDGSAG,NDGENG,NDGSAL,NDGENL,NFLDSLB1,NSLSTA,NSLONL,NSLOFF,&
   & NDGLG,NLOENG,NFRSTLOFF,MYFRSTACTLAT,MYLSTACTLAT,NFIXSFLD,3,&
   & RPARSL1,PB1,KMASK3=MASK_SL3)  
ELSE
  CALL SLEXTPOL(NSLWIDE,NSLWIDE,&
   & NASLB1,NDGSAG,NDGENG,NDGSAL,NDGENL,NFLDSLB1,NSLSTA,NSLONL,NSLOFF,&
   & NDGLG,NLOENG,NFRSTLOFF,MYFRSTACTLAT,MYLSTACTLAT,IDUMARR,1,&
   & RPARSL1,PB1)  
ENDIF

IF (NPROC > 1) THEN

  IF(LSLONDEM)THEN
    LSLONDEM_ACTIVE=.TRUE.
  ENDIF

  IF (LSLONDEM_ACTIVE) THEN
    IF( NSIM4D==0 )THEN
      NFIXSFLD(1)=MSLB1UR05
      NFIXSFLD(2)=MSLB1WR05+NFLEVG+NFLSUL
      CALL SLCOMM(NASLB1,NSLPROCS,NSLRPT,&
       & NSLSPT,NSLSENDPOS,NSLRECVPOS,NSENDPTR,NRECVPTR,NSLCOMM,&
       & NFIXSFLD,NFLDSLB15,LLINC,1,PB15,LDSLCOMM=LSLCOMM(:,NSTEP))  
    ELSE
      NFIXSFLD(1)=1
      NFIXSFLD(2)=NFLDSLB1
      LLEXCLUDE=.FALSE.
      CALL SLCOMM2A(NASLB1,NSLPROCS,NSLRPT,&
       & NSLSPT,NSLSENDPOS,NSLRECVPOS,NSENDPTR,NRECVPTR,NSLCOMM,&
       & NFIXSFLD,LLEXCLUDE,MASK_SL1,MASK_SL2T(:,NSTEP),MASK_SL2AT(:,NSTEP),MASK_SL3T(:,NSTEP),&
       & NFLDSLB15,LLINC,PB15,MFIELD_TYPE15,LDSLCOMM=LSLCOMM(:,NSTEP))  
    ENDIF
  ELSE
    CALL SLCOMM(NASLB1,NSLPROCS,NSLRPT,&
     & NSLSPT,NSLSENDPOS,NSLRECVPOS,NSENDPTR,NRECVPTR,NSLCOMM,&
     & IDUMARR,NFLDSLB15,LLINC,0,PB15)  
  ENDIF

ENDIF

IF (LSLONDEM_ACTIVE) THEN
  CALL SLEXTPOL(NSLWIDE,NSLWIDE,&
   & NASLB1,NDGSAG,NDGENG,NDGSAL,NDGENL,NFLDSLB15,NSLSTA,NSLONL,NSLOFF,&
   & NDGLG,NLOENG,NFRSTLOFF,MYFRSTACTLAT,MYLSTACTLAT,NFIXSFLD,3,&
   & RPARSL15,PB15,KMASK3=MASK_SL3)  
ELSE
  CALL SLEXTPOL(NSLWIDE,NSLWIDE,&
   & NASLB1,NDGSAG,NDGENG,NDGSAL,NDGENL,NFLDSLB15,NSLSTA,NSLONL,NSLOFF,&
   & NDGLG,NLOENG,NFRSTLOFF,MYFRSTACTLAT,MYLSTACTLAT,IDUMARR,1,&
   & RPARSL15,PB15)  
ENDIF

CALL GSTATS(84,1)
CALL GSTATS(34,3)

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

!*       3.    SL-TRAJECTORY RESEARCH, WEIGHTS AND INTERP. GRID CALCULATION.
!              -------------------------------------------------------------

CALL GSTATS(1009,0)
!$OMP PARALLEL DO SCHEDULE(DYNAMIC,1)&
!$OMP&PRIVATE(JSTGLO,IST,IEND,IBL,IOFF)

DO JSTGLO=1,NGPTOT,NPROMA
  IST=1
  IEND=MIN(NPROMA,NGPTOT-JSTGLO+1)
  IBL=(JSTGLO-1)/NPROMA+1
  IOFF=JSTGLO

  CALL LAPINEA5(IST,IEND,.FALSE.,&
   & RCOLON(IOFF),RSILON(IOFF),GM(IOFF),GEMU(IOFF),&
   & GSQM2(IOFF),GECLO(IOFF),GESLO(IOFF),GNORDL(IOFF),&
   & GNORDM(IOFF),RINDX(IOFF),RINDY(IOFF),&
   & PB15(1,1),PB2(1,1,IBL),&
   & ZLON5(1,1,1,IBL),ZLAT5(1,1,1,IBL),&
   & ZR5(1,1,1,IBL),ZS5(1,1,1,IBL),&
   & ZUF5(1,1,1,IBL),ZVF5(1,1,1,IBL),&
   & IL0(1,1,0,1,IBL),ILH0(1,1,0,IBL),&
   & ZDLO5(1,1,0,1,IBL),ZCLO5(1,1,1,1,IBL),ZCLOSLD5(1,1,1,1,IBL),&
   & ZDLAT5(1,1,1,IBL),ZCLA5(1,1,1,IBL),ZCLASLD5(1,1,1,IBL),&
   & ZDVER5(1,1,1,IBL),ZVINTW5(1,1,1,IBL),ZVINTWSLD5(1,1,1,IBL),&
   & ZCOSCO5(1,1,1,IBL),ZSINCO5(1,1,1,IBL),&
   & ZCOPHI5(1,1,1,IBL),ZSINLA5(1,1,1,IBL),&
   & ZLEV5(1,1,1,IBL),ZOUT5(1,1,1,IBL),IDEP(1,1,IBL))

ENDDO
!$OMP END PARALLEL DO

!$OMP PARALLEL DO SCHEDULE(DYNAMIC,1)&
!$OMP&PRIVATE(JSTGLO,IST,IEND,IBL,IOFF)

DO JSTGLO=1,NGPTOT,NPROMA
  IST=1
  IEND=MIN(NPROMA,NGPTOT-JSTGLO+1)
  IBL=(JSTGLO-1)/NPROMA+1
  IOFF=JSTGLO

  CALL LAPINEATL(IST,IEND,&
   & RCOLON(IOFF),RSILON(IOFF),GM(IOFF),GEMU(IOFF),GSQM2(IOFF),&
   & GECLO(IOFF),GESLO(IOFF),GNORDL(IOFF),GNORDM(IOFF),&
   & RINDX(IOFF),RINDY(IOFF),&
   ! -----------------------------------------------------------------------
   & PB1(1,1),PB2(1,1,IBL),PB15(1,1),&
   ! -----------------------------------------------------------------------
   & ZLON(1,1,IBL),ZLAT(1,1,IBL),&
   & ZR(1,1,IBL),ZS(1,1,IBL),&
   & ZLON5(1,1,1,IBL),ZLAT5(1,1,1,IBL),&
   & ZR5(1,1,1,IBL),ZS5(1,1,1,IBL),&
   ! -----------------------------------------------------------------------
   & IL0(1,1,0,1,IBL),ILH0(1,1,0,IBL),ZDLO(1,1,0,IBL),&
   & ZCLO(1,1,1,1,IBL),ZCLOSLD(1,1,1,1,IBL),&
   & ZDLAT(1,1,IBL),ZCLA(1,1,1,IBL),ZCLASLD(1,1,1,IBL),ZDVER(1,1,IBL),&
   & ZVINTW(1,1,1,IBL),ZVINTWSLD(1,1,1,IBL),&
   & ZDLO5(1,1,0,1,IBL),ZCLO5(1,1,1,1,IBL),ZCLOSLD5(1,1,1,1,IBL),&
   & ZDLAT5(1,1,1,IBL),ZCLA5(1,1,1,IBL),ZCLASLD5(1,1,1,IBL),&
   & ZDVER5(1,1,1,IBL),ZVINTW5(1,1,1,IBL),ZVINTWSLD5(1,1,1,IBL),&
   ! -----------------------------------------------------------------------
   & ZCOSCO(1,1,IBL),ZSINCO(1,1,IBL),ZCOPHI(1,1,IBL),ZSINLA(1,1,IBL),&
   & ZLEV(1,1,IBL),&
   & ZCOSCO5(1,1,1,IBL),ZSINCO5(1,1,1,IBL),ZCOPHI5(1,1,1,IBL),&
   & ZSINLA5(1,1,1,IBL),ZLEV5(1,1,1,IBL),&
   ! -----------------------------------------------------------------------
   & ZUF5(1,1,1,IBL),ZVF5(1,1,1,IBL),ZOUT5(1,1,1,IBL))

ENDDO

!$OMP END PARALLEL DO
CALL GSTATS(1009,1)

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

!*       4.    SECOND PART OF PROCESSOR COMMUNICATIONS WHEN NEEDED.
!              ----------------------------------------------------

IF (NPROC > 1 .AND. LSLONDEM_ACTIVE) THEN

  IF( NSIM4D==0 )THEN
    LLINC=.FALSE.

    CALL GSTATS(34,2)
    CALL GSTATS(88,0)
  
    NFIXSFLD(1)=MSLB1UR0
    NFIXSFLD(2)=MSLB1WR0+NFLEVG+NFLSUL
    LLEXCLUDE=.TRUE.
  
    CALL SLCOMM2A(NASLB1,NSLPROCS,NSLRPT,&
     & NSLSPT,NSLSENDPOS,NSLRECVPOS,NSENDPTR,NRECVPTR,NSLCOMM,&
     & NFIXSFLD,LLEXCLUDE,MASK_SL1,MASK_SL2,MASK_SL2A,MASK_SL3,&
     & NFLDSLB1,LLINC,PB1,MFIELD_TYPE1,LDSLCOMM=LSLCOMM(:,NSTEP))  
  
    CALL SLEXTPOL(NSLWIDE,NSLWIDE,&
     & NASLB1,NDGSAG,NDGENG,NDGSAL,NDGENL,NFLDSLB1,NSLSTA,NSLONL,NSLOFF,&
     & NDGLG,NLOENG,NFRSTLOFF,MYFRSTACTLAT,MYLSTACTLAT,NFIXSFLD,2,&
     & RPARSL1,PB1)  
  
    NFIXSFLD(1)=MSLB1UR05
    NFIXSFLD(2)=MSLB1WR05+NFLEVG+NFLSUL
  
    CALL SLCOMM2A(NASLB1,NSLPROCS,NSLRPT,&
     & NSLSPT,NSLSENDPOS,NSLRECVPOS,NSENDPTR,NRECVPTR,NSLCOMM,&
     & NFIXSFLD,LLEXCLUDE,MASK_SL1,MASK_SL2,MASK_SL2A,MASK_SL3,&
     & NFLDSLB15,LLINC,PB15,MFIELD_TYPE15,LDSLCOMM=LSLCOMM(:,NSTEP))  
  
    CALL SLEXTPOL(NSLWIDE,NSLWIDE,&
     & NASLB1,NDGSAG,NDGENG,NDGSAL,NDGENL,NFLDSLB15,NSLSTA,NSLONL,NSLOFF,&
     & NDGLG,NLOENG,NFRSTLOFF,MYFRSTACTLAT,MYLSTACTLAT,NFIXSFLD,2,&
     & RPARSL15,PB15)  
  
    CALL GSTATS(88,1)
    CALL GSTATS(34,3)

    MASK_SL2T(:,NSTEP)=MASK_SL2
    MASK_SL2AT(:,NSTEP)=MASK_SL2A
    MASK_SL3T(:,NSTEP)=MASK_SL3

  ELSE
    IDIFF2=0
    IDIFF2A=0
    DO J=1,NASLB1+4
      IF(MASK_SL2T(J,NSTEP)/=MASK_SL2(J)) IDIFF2=IDIFF2+1
    ENDDO
    DO J=1,NASLB1+4
      IF(MASK_SL2AT(J,NSTEP)/=MASK_SL2A(J)) IDIFF2A=IDIFF2A+1
    ENDDO
    ! note it is not possible to check mask3 as this is modified in slcomm2a and slextpol
    IF(IDIFF2 > 0 .OR. IDIFF2A > 0 )THEN
      WRITE(0,'("CALL_SL_TL: NSIM4D=",I3," NSTEP=",I3," IDIFF2=",I10," IDIFF2A=",I10)')&
       &NSIM4D,NSTEP,IDIFF2,IDIFF2A
      CALL ABOR1('CALL_SL_TL: HALO MASKS DIFFERENT OVER MINIMISATION ITERATIONS')
    ENDIF
  ENDIF

ENDIF

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

!*       5.    INTERPOLATIONS.
!              ---------------

CALL GSTATS(1010,0)
!$OMP PARALLEL DO SCHEDULE(DYNAMIC,1) PRIVATE(JSTGLO,IST,IEND,IBL,IOFF) 

DO JSTGLO=1,NGPTOT,NPROMA
  IST=1
  IEND=MIN(NPROMA,NGPTOT-JSTGLO+1)
  IBL=(JSTGLO-1)/NPROMA+1
  IOFF=JSTGLO

  CALL LAPINEBTL(IST,IEND,&
   & RCOLON(IOFF),RSILON(IOFF),GM(IOFF),GEMU(IOFF),&
   & GSQM2(IOFF),GECLO(IOFF),GESLO(IOFF),GNORDL(IOFF),&
   & GNORDM(IOFF),RINDX(IOFF),RINDY(IOFF),&
   & PB1(1,1),PB15(1,1),&
   ! -------------------------------------------------------------------
   & GMVT1(1,1,1,IBL),GMVT1S(1,1,IBL),PGFLT1(1,1,1,IBL),PB2(1,1,IBL),&
   ! -------------------------------------------------------------------
   & ZLON(1,1,IBL),ZLAT(1,1,IBL),ZR(1,1,IBL),ZS(1,1,IBL),&
   & ZLON5(1,1,NITMP,IBL),ZLAT5(1,1,NITMP,IBL),&
   & ZR5(1,1,NITMP,IBL),ZS5(1,1,NITMP,IBL),&
   ! -------------------------------------------------------------------
   & IL0(1,1,0,NITMP,IBL),ILH0(1,1,0,IBL),ZDLO(1,1,0,IBL),&
   & ZCLO(1,1,1,1,IBL),ZCLOSLD(1,1,1,1,IBL),&
   & ZDLAT(1,1,IBL),ZCLA(1,1,1,IBL),ZCLASLD(1,1,1,IBL),&
   & ZDVER(1,1,IBL),ZVINTW(1,1,1,IBL),ZVINTWSLD(1,1,1,IBL),&
   & ZDLO5(1,1,0,NITMP,IBL),ZCLO5(1,1,1,1,IBL),ZCLOSLD5(1,1,1,1,IBL),&
   & ZDLAT5(1,1,NITMP,IBL),ZCLA5(1,1,1,IBL),ZCLASLD5(1,1,1,IBL),&
   & ZDVER5(1,1,NITMP,IBL),ZVINTW5(1,1,1,IBL),ZVINTWSLD5(1,1,1,IBL),&
   ! -------------------------------------------------------------------
   & ZCOSCO(1,1,IBL),ZSINCO(1,1,IBL),ZCOPHI(1,1,IBL),ZSINLA(1,1,IBL),&
   & ZCOSCO5(1,1,NITMP,IBL),ZSINCO5(1,1,NITMP,IBL),&
   & ZCOPHI5(1,1,NITMP,IBL),ZSINLA5(1,1,NITMP,IBL))

ENDDO

!$OMP END PARALLEL DO
CALL GSTATS(1010,1)

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

!*       6.    FINAL ACTIONS AND DESALLOCATIONS.
!              ---------------------------------

DEALLOCATE(ZDLO)
DEALLOCATE(ZCLO)
DEALLOCATE(ZCLOSLD)
DEALLOCATE(IL0)
DEALLOCATE(ILH0)
DEALLOCATE(IDEP)
DEALLOCATE(ZDLAT)
DEALLOCATE(ZCLA)
DEALLOCATE(ZCLASLD)
DEALLOCATE(ZDVER)
DEALLOCATE(ZVINTW)
DEALLOCATE(ZVINTWSLD)
DEALLOCATE(ZCOSCO)
DEALLOCATE(ZSINLA)
DEALLOCATE(ZSINCO)
DEALLOCATE(ZCOPHI)
DEALLOCATE(ZLEV)
DEALLOCATE(ZDLO5)
DEALLOCATE(ZCLO5)
DEALLOCATE(ZCLOSLD5)
DEALLOCATE(ZDLAT5)
DEALLOCATE(ZCLA5)
DEALLOCATE(ZCLASLD5)
DEALLOCATE(ZDVER5)
DEALLOCATE(ZVINTW5)
DEALLOCATE(ZVINTWSLD5)
DEALLOCATE(ZCOSCO5)
DEALLOCATE(ZSINLA5)
DEALLOCATE(ZSINCO5)
DEALLOCATE(ZCOPHI5)
DEALLOCATE(ZLEV5)
DEALLOCATE(ZOUT5)

LSLONDEM_ACTIVE=.FALSE.
LNEW_MASK_SL=.FALSE.

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

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