SUBROUTINE SLINT(&
 & KPROMB,KASLB1,&
 & PLAT,PLON,PPARITY,&
 & POBB1U5  ,POBB1V5  ,POBB1T5 ,POBB1GFL5 ,&
 & POBB1EZ5 ,POBB1EH5,&
 & POBB1SP5 ,POBB1EST5,&
 & POBB1U05 ,POBB1V05, POBB1CHN5,&
 & POBB1TS5 ,POBB1WS5 ,POBB1SN5,POBB1Z05 ,POBB1WL5,&
 & POBB1U10N5,POBB1V10N5,&
 & POBB1OR5 ,POBB1CO5 ,POBB1DL5,POBB1DM5 ,POBB1AL5,&
 & POBB1EM5 ,POBB1LS5 ,POBB1VG5,&
 & POBB1CI5 ,POBB1CVH5,POBB1CVL5,POBB1TVH5,POBB1TVL5,&
 & POBB1PW5 ,POBB1PS5 ,&
 & POBB1ARG5,POBB1SAB5,POBB1HV5,POBB1Z0H5,&
 & POBB1XTS ,POBB1XWS ,POBB1XWP,POBB1XSN ,POBB1XTP,&
 & POBB1ESN ,POBB1ET2 ,POBB1EH2,POBB1EV1 ,&
 & PSXTS    ,PSXWS    ,PSXWP   ,PSXSN    ,PSXTP   ,&
 & PSLU     ,PSLV     ,PSLT    ,PSLGFL   ,&
 & PSLEZ    ,PSLEH   ,&
 & PSLSP    ,PSLEST   ,&
 & PSLU0    ,PSLV0    ,PSLCHN  ,&
 & PSLTS    ,PSLWS    ,PSLSN   ,PSLZ0    ,PSLWL   ,&
 & PSLU10N  ,PSLV10N  ,&
 & PSLDL    ,PSLDM    ,&
 & PSLCORI  ,PSLALBE  ,PSLEMIS ,PSLLSMA  ,&
 & PSLVEGE  ,&
 & PSLCI    ,PSLCVH   ,PSLCVL  ,PSLTVH   ,PSLTVL  ,&
 & PSLPRWA  ,PSLPRSN  ,PSLARG  ,PSLSAB   ,&
 & PSLHV    ,PSLZ0H   ,PSLOROG ,PSLESN   ,PSLET2  ,&
 & PSLEH2   ,PSLEV1   ,PSLSST  ,&
 & KLSOBS,POBB1TCLS5,PSLTCLS,POBB1HUCLS5,PSLHUCLS)

!**** *SLINT* - Horizontal interpolation of the model variables
!               from grid points to observation points by using semi-
!               lagrangian interpolation routines

!     Purpose.
!     -------
!           Feeding the tables GOMMV,GOSMV,GSMMV,GSSMV,GSCMV with the
!     variables at the observation points, from the model variables in
!     grid points. These tables are containing the quantity called Xmvo
!     in the scientific documentation.

!     Interface.
!     ---------
!        CALL SLINT(..)
!     where: 
!            KOBNUM,KOBTYP = TYPE AND INDEX OF PROCESSED OBS
!            PPARITY  = INDICATOR FOR SCALAR(1) OR VECTOR(-1) FIELD
!            POBB1U5  = PART OF S/L BUFFER FOR U
!            POBB1V5  = PART OF S/L BUFFER FOR V
!            POBB1T5  = PART OF S/L BUFFER FOR T
!            POBB1GFL5  = PART OF S/L BUFFER FOR GFL
!            POBB1EZ5 = PART OF S/L BUFFER FOR PHI MODEL ERROR
!            POBB1EH5 = PART OF S/L BUFFER FOR Hu MODEL ERROR
!            POBB1SP5 = PART OF S/L BUFFER FOR Ps
!            POBB1EST5= PART OF S/L BUFFER FOR SST MODEL ERROR
!            POBB1U05 = PART OF S/L BUFFER FOR U-COMP OCEAN CURRENT
!            POBB1V05 = PART OF S/L BUFFER FOR V-COMP OCEAN CURRENT
!            POBB1CHN5= PART OF S/L BUFFER FOR WAVE CHARNOCK
!            POBB1TS5 = PART OF S/L BUFFER FOR Ts
!            POBB1WS5 = PART OF S/L BUFFER FOR Ws
!            POBB1SN5 = PART OF S/L BUFFER FOR SNOW
!            POBB1Z05 = PART OF S/L BUFFER FOR Z0
!            POBB1WL5 = PART OF S/L BUFFER FOR Wl
!            POBB1U10N5=PART OF S/L BUFFER FOR U-COMP 10M NEUTRAL WIND
!            POBB1V10N5=PART OF S/L BUFFER FOR V-COMP 10M NEUTRAL WIND
!            POBB1OR5 = PART OF S/L BUFFER FOR OROGRAPHY
!            POBB1CO5 = PART OF S/L BUFFER FOR CORIOLIS PARAMETER
!            POBB1DL5 = PART OF S/L BUFFER FOR NORTH GEOGRAPHICAL DIRECTION
!            POBB1DM5 = PART OF S/L BUFFER FOR NORTH GEOGRAPHICAL DIRECTION
!            POBB1AL5 = PART OF S/L BUFFER FOR ALBEDO
!            POBB1EM5 = PART OF S/L BUFFER FOR EMISSIVITY
!            POBB1LS5 = PART OF S/L BUFFER FOR SEA/LAND MASK
!            POBB1VG5 = PART OF S/L BUFFER FOR VEGETATION
!            POBB1CI5 = PART OF S/L BUFFER FOR SEA-ICE CONCENTRATION
!            POBB1CVH5= PART OF S/L BUFFER FOR HIGH VEGETATION FRACTION
!            POBB1CVL5= PART OF S/L BUFFER FOR LOW  VEGETATION FRACTION
!            POBB1TVH5= PART OF S/L BUFFER FOR HIGH VEGETATION TYPE
!            POBB1TVL5= PART OF S/L BUFFER FOR LOW VEGETATION TYPE
!            POBB1PW5 = PART OF S/L BUFFER FOR WATER PRECIPITATION
!            POBB1PS5 = PART OF S/L BUFFER FOR SNOW PRECIPITATION
!            POBB1ARG5= PART OF S/L BUFFER FOR PERCENT OF CLAY
!            POBB1SAB5= PART OF S/L BUFFER FOR PERCENT OF SAND
!            POBB1HV5 = PART OF S/L BUFFER FOR RESISTANCE TO EVAPOTRANSPIRATION
!            POBB1Z0H5= PART OF S/L BUFFER FOR G*THERMAL ROUGHNESS LENGTH
!            POBB1XTS = PART OF S/L BUFFER FOR Ts CLIM.
!            POBB1XWS = PART OF S/L BUFFER FOR Ws CLIM.
!            POBB1XWP = PART OF S/L BUFFER FOR Wp CLIM.
!            POBB1XSN = PART OF S/L BUFFER FOR Snow CLIM.
!            POBB1XTP = PART OF S/L BUFFER FOR Tp CLIM.
!            POBB1ESN = PART OF S/L BUFFER FOR SNOW MODEL ERROR
!            POBB1ET2 = PART OF S/L BUFFER FOR T2m MODEL ERROR
!            POBB1EH2 = PART OF S/L BUFFER FOR Hu2m MODEL ERROR
!            POBB1EV1 = PART OF S/L BUFFER FOR WIND 10m MODEL ERROR

!     Externals. See includes below.
!     ---------

!     Author: Drasko Vasiljevic
!     Date  : 92-05-19

!     Modifications.
!     -------------
!     92-12-01 J-N.Thepaut : change of name conventions.
!     94-02-20 K.Yessad    : change of numbering for switch IWIS.
!     94-11    AAD         : new fields for CANARI + use with ALADIN
!     95-01-20 M. Fisher   : store to GOMMV5, etc.
!     95-09-20 H.Jarvinen  : New CMA file format
!     95-12-15 F.Bouttier  : move GOMMV5 copies to CPTOMVO5,output KOBNUM/TYP
!     96-02-20 L. Isaksen  : NFLEV --> NFLEVG
!     97-02-20 B. Urban    : added arrays for surface climatology (CANARI)
!     97-05-26 F.Taillefer : add DL and DM arrays for wind treatment
!     97-10-10 F.Taillefer : add model errors (used in CANARI only)
!     97-11-17 E.Andersson : Introduce CIW and O3
!     98-07-31 K. YESSAD   : removal of useless seq 2.02 and arg ZIL in LASCAW.
!     99-06-23 A. Horanyi  : correcting the call of ELASCAW (removing ZIL)
!     99-09-01 P.Viterbo   : Surface tiles
!     00-06-29 M.Zitouni   : Land/sea mask
!     00-10-20 F.Taillefer : Land/sea mask reform
!     02-10-01 G.Mozdzynski: support for radiation on-demand comms
!     02-05-22 F.Taillefer : Add SST in obs equivalent estimation
!     03-05-15 C.Fischer   : Add arg in call to elascaw (al26t1)
!     03-10-01 G.Radnoti   : update call to eslextpol2
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!     2004-Nov F. Vana     : update arguments of (E)LASCAW
!     05-12-16 S.Saarinen  : Made sure that all directives !$OMP start from the 1st column
!        M.Hamrud      01-Jul-2006 Revised surface fields
!     09-Jan-2007 F. Vana  : arguments update for ELASCAW
!     28-Aug-2007 F. Vana     : update arguments of (E)LASCAW
!     04-07-08 H.Hersbach  : add ocean current and wave Charnock
!     07-Nov-2007 J. Masek : Modified calls to LASCAW/ELASCAW. Removed
!                             argument KIBUFP1.
!     20-Aug-2008 F. Vana  : Weights driven interpolation.
!     K. Yessad Dec 2008: merge the different (E)SLEXTPOL.. -> (E)SLEXTPOL.
!     09-12-04 H. Hersbach : 10-m neutral wind; argument PPARITY
!    -------------------------------------------------------------------

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
USE YOMDIM   , ONLY : NDGSAG   ,NDGSAL   ,NDGENG   ,NDGENL   ,NDGLG    ,&
 & NDGUNG   ,NDGUXG   ,NDLUNG   ,NDLUXG   ,NFLEVG   ,&
 & NDGSAH   ,NDGENH     
USE YOMCT0   , ONLY : LCANARI  ,LELAM    ,LRPLANE  ,LCASIG, NPROC
USE YOMCT0B  , ONLY : LECMWF
USE YOMCST   , ONLY : RPI
USE YOMGEM   , ONLY : NLOENG   ,NSTTYP   ,R4JP
USE YOMLEG   , ONLY : RLATI    ,RIPI0    ,RIPI1    ,RIPI2
USE SURFACE_FIELDS_MIX, ONLY : YSD_VVD
USE YOMSC2   , ONLY : NSLWIDE  ,NFLDOBB1
USE YOMOBS   , ONLY : NOBSHOR  ,LSLREJ
USE YOMPHY   , ONLY : LSOLV
USE YOMMP    , ONLY : NSLOFF   ,NFRSTLOFF, &
 & NASLB1   ,NSLSTA   ,NSLPROCS , &
 & NSLRPT   ,NSLSPT   ,NSLSENDPOS,&
 & NSLRECVPOS,NSENDPTR,NRECVPTR ,NSLCOMM,NSLONL, &
 & MYFRSTACTLAT,MYLSTACTLAT  
USE YOMMASK  , ONLY : MASK_SL1,MASK_SL2,NFIXSFLD
USE GOMS_MIX     , ONLY : YGOMGFL, NGOMGFL
USE YOMDPHY,   ONLY : LDIRCLSMOD

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

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KPROMB
INTEGER(KIND=JPIM),INTENT(IN)    :: KASLB1
REAL(KIND=JPRB)   ,INTENT(IN)    :: PLAT(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PLON(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PPARITY(NFLDOBB1)
REAL(KIND=JPRB)   ,INTENT(INOUT) :: POBB1U5(KASLB1,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1V5(KASLB1,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1T5(KASLB1,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1GFL5(KASLB1,NFLEVG,NGOMGFL) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1EZ5(KASLB1,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1EH5(KASLB1,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1SP5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1EST5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1U05(KASLB1)
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1V05(KASLB1)
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1CHN5(KASLB1)
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1TS5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1WS5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1SN5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1Z05(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1WL5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1U10N5(KASLB1)
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1V10N5(KASLB1)
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1OR5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1CO5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1DL5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1DM5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1AL5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1EM5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1LS5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1VG5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1CI5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1CVH5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1CVL5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1TVH5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1TVL5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1PW5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1PS5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1ARG5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1SAB5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1HV5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1Z0H5(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1XTS(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1XWS(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1XWP(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1XSN(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1XTP(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1ESN(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1ET2(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1EH2(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POBB1EV1(KASLB1) 
REAL(KIND=JPRB)   ,INTENT(IN),OPTIONAL    :: POBB1TCLS5(KASLB1)
REAL(KIND=JPRB)   ,INTENT(IN),OPTIONAL    :: POBB1HUCLS5(KASLB1)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSXTS(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSXWS(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSXWP(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSXSN(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSXTP(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLU(KPROMB,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLV(KPROMB,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLT(KPROMB,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLGFL(KPROMB,NFLEVG,NGOMGFL) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLEZ(KPROMB,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLEH(KPROMB,NFLEVG) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLSP(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLEST(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLU0(KPROMB)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLV0(KPROMB)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLCHN(KPROMB)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLTS(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLWS(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLSN(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLZ0(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLWL(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLU10N(KPROMB)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLV10N(KPROMB)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLDL(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLDM(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLCORI(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLALBE(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLEMIS(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLLSMA(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLVEGE(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLCI(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLCVH(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLCVL(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLTVH(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLTVL(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLPRWA(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLPRSN(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLARG(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLSAB(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLHV(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLZ0H(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLOROG(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLESN(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLET2(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLEH2(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLEV1(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSLSST(KPROMB) 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLSOBS(KPROMB) 
REAL(KIND=JPRB)   ,INTENT(OUT),OPTIONAL   :: PSLTCLS(KPROMB)
REAL(KIND=JPRB)   ,INTENT(OUT),OPTIONAL   :: PSLHUCLS(KPROMB)

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

REAL(KIND=JPRB) :: ZLSDEPI(NDGSAH:NDGENH)
REAL(KIND=JPRB) :: ZLEV(KPROMB,1)
REAL(KIND=JPRB) :: ZDSLAT(KPROMB,1)
REAL(KIND=JPRB) :: ZCSLA (KPROMB,1,2:4)
REAL(KIND=JPRB) :: ZDSLON(KPROMB,1,0:3)
REAL(KIND=JPRB) :: ZCSLO (KPROMB,1,3,2)
INTEGER(KIND=JPIM) :: IL0S(KPROMB,1,0:3)
INTEGER(KIND=JPIM) :: IDLX
INTEGER(KIND=JPIM) :: ISTALAT(NDGSAH:NDGENH)
INTEGER(KIND=JPIM) :: IL0ULI(KPROMB,2,2), IL0UDI(KPROMB,0:3,0:3)
INTEGER(KIND=JPIM) :: IDEP(KPROMB,NFLEVG)

INTEGER(KIND=JPIM) :: IDUM1, IFLDN, IFLDX, IGLGLO, IHOR,&
 & IHVI, IWIS, J1, JGL, JLAT, JROF
INTEGER(KIND=JPIM) :: JLEV,JGFL

LOGICAL :: LLTDLX, LLINC, LLSLHD, LLSLHDQUAD

REAL(KIND=JPRB) :: ZDEPI, ZPIS2  

REAL(KIND=JPRB) :: ZHOOK_HANDLE

! unused arguments in call to LASCAW/ELASCAW
! a) input - array dimensions contracted
INTEGER(KIND=JPIM) :: IUN_VAUTF(1)
REAL(KIND=JPRB) :: ZUN_SLD1(1)
REAL(KIND=JPRB) :: ZUN_SLD2(1)
REAL(KIND=JPRB) :: ZUN_SLD3(1)
REAL(KIND=JPRB) :: ZUN_SLDW(1)
REAL(KIND=JPRB) :: ZUN_VETAF(1)
REAL(KIND=JPRB) :: ZUN_VETAH(1)
REAL(KIND=JPRB) :: ZUN_VCUICO(1)
REAL(KIND=JPRB) :: ZUN_VSLD(1)
REAL(KIND=JPRB) :: ZUN_VSLDW(1)
REAL(KIND=JPRB) :: ZUN_KAPPA(1)
! b) output - array dimensions kept for safety
INTEGER(KIND=JPIM) :: IUN_LEV(KPROMB,1)
INTEGER(KIND=JPIM) :: IUN_LH0(KPROMB,1,0:3)
REAL(KIND=JPRB) :: ZUN_CLASLD(KPROMB,1,3)
REAL(KIND=JPRB) :: ZUN_CLOSLD(KPROMB,1,3,2)
REAL(KIND=JPRB) :: ZUN_DVER(KPROMB,1)
REAL(KIND=JPRB) :: ZUN_VINTW(KPROMB,1,3)
REAL(KIND=JPRB) :: ZUN_VINTWSLD(KPROMB,1,3)
REAL(KIND=JPRB) :: ZUN_VINTWS(KPROMB,1,1:4)
REAL(KIND=JPRB) :: ZUN_VDERW(KPROMB,1,0,0)  ! case KHVI=0
REAL(KIND=JPRB) :: ZUN_HVW(KPROMB,1,0)      ! case KHVI=0

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

#include "abor1.intfb.h"
#include "elascaw.intfb.h"
#include "eslextpol.intfb.h"
#include "laiddiobs.intfb.h"
#include "laidlic.intfb.h"
#include "laidliobs.intfb.h"
#include "lascaw.intfb.h"
#include "slcomm2.intfb.h"
#include "slextpol.intfb.h"

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

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

!    -------------------------------------------------------------------
!*       1. PRESET INTERPOLATION AT OBS. POINTS
!           -----------------------------------

CALL GSTATS(1856,0)
IWIS = NOBSHOR
IF ( IWIS /= 201.AND. IWIS /= 203 ) THEN
  CALL ABOR1('SLINT: UNKNOWN INTERPOL. NO:')
ENDIF
IF ( IWIS == 203 ) THEN
  LLTDLX=.FALSE.
  IDLX=1
ENDIF
IFLDN=1
IFLDX=NFLDOBB1
IHOR=0
IHVI=0
ZDEPI=2.0_JPRB*RPI
ZPIS2=0.5_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

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

ZLEV(:,:) = 0.0_JPRB

!    -------------------------------------------------------------------
!*       2. SET INTERPOLATION/BUFFER PARAMETERS
!           -----------------------------------

! deactivate computation of SLHD weights
LLSLHD     =.FALSE.
LLSLHDQUAD =.FALSE.

IF ( LRPLANE ) THEN
  CALL ELASCAW(KASLB1,KPROMB,1,KPROMB,1,1,NDGSAH,NDGENH,&
   & NDLUNG,NDLUXG,NDGUNG,NDGUXG,&
   & IFLDN,IFLDX,ISTALAT,IWIS,IHOR,IHVI,&
   & LLSLHD,LLSLHDQUAD,&
   & PLON,PLAT,ZLEV,&
   & ZUN_VETAF,ZUN_VETAH,IUN_VAUTF,&
   & ZUN_VCUICO,ZUN_VSLD,ZUN_VSLDW,1,1.0_JPRB,ZUN_KAPPA,&
   & ZDSLAT,ZCSLA,ZUN_CLASLD,ZDSLON,ZCSLO,ZUN_CLOSLD,&
   & IL0S,IUN_LH0,IUN_LEV,&
   & ZUN_DVER,ZUN_VINTW,ZUN_VINTWSLD,ZUN_VINTWS,&
   & ZUN_VDERW,ZUN_HVW,IDEP)  
ELSE
  CALL LASCAW(KASLB1,KPROMB,1,KPROMB,1,1,NDGSAH,NDGENH,&
   & IFLDN,ISTALAT,IWIS,IHOR,IHVI,&
   & LLSLHD,LLSLHDQUAD,&
   & R4JP,ZPIS2,ZLSDEPI,RLATI(NDGSAH),&
   & RIPI0(NDGSAH),RIPI1(NDGSAH),RIPI2(NDGSAH),&
   & ZUN_SLD1,ZUN_SLD2,ZUN_SLD3,ZUN_SLDW,&
   & PLON,PLAT,ZLEV,&
   & ZUN_VETAF,ZUN_VETAH,IUN_VAUTF,& 
   & ZUN_VCUICO,ZUN_VSLD,ZUN_VSLDW,1,1.0_JPRB,ZUN_KAPPA,&
   & ZDSLAT,ZCSLA,ZUN_CLASLD,ZDSLON,ZCSLO,ZUN_CLOSLD,&
   & IL0S,IUN_LH0,IUN_LEV,&
   & ZUN_DVER,ZUN_VINTW,ZUN_VINTWSLD,ZUN_VINTWS,&
   & ZUN_VDERW,ZUN_HVW)
ENDIF
CALL GSTATS(1856,1)

IF (NPROC > 1)THEN

  LLINC=.FALSE.

  CALL GSTATS(43,2)
  CALL GSTATS(59,0)

  NFIXSFLD(1)=1
  NFIXSFLD(2)=0

  CALL SLCOMM2(NASLB1,NSLPROCS,NSLRPT,&
   & NSLSPT,NSLSENDPOS,NSLRECVPOS,NSENDPTR,NRECVPTR,NSLCOMM,&
   & NFIXSFLD,MASK_SL1,MASK_SL2,&
   & NFLDOBB1,LLINC,POBB1U5)  

  CALL GSTATS(59,1)
  CALL GSTATS(43,3)

ENDIF

IF (.NOT.LELAM) THEN
  CALL SLEXTPOL(NSLWIDE,NSLWIDE,&
   & NASLB1,NDGSAG,NDGENG,NDGSAL,NDGENL,NFLDOBB1,NSLSTA,NSLONL,NSLOFF,&
   & NDGLG,NLOENG,NFRSTLOFF,MYFRSTACTLAT,MYLSTACTLAT,NFIXSFLD,2,&
   & PPARITY,POBB1U5)  
ELSE
  CALL ESLEXTPOL(NSLWIDE,NSLWIDE,&
   & NASLB1,NDGSAG,NDGENG,NDGSAL,NDGENL,NFLDOBB1,NSLSTA,NSLONL,NSLOFF,&
   & NLOENG,NFRSTLOFF,MYFRSTACTLAT,MYLSTACTLAT,NFIXSFLD,2,&
   & POBB1U5)  
ENDIF

IF (IWIS == 201) THEN
  DO J1 = 1 , KPROMB
    IL0ULI(J1,1,1) = IL0S(J1,1,1)+1
    IL0ULI(J1,1,2) = IL0S(J1,1,1)+2
    IL0ULI(J1,2,1) = IL0S(J1,1,2)+1
    IL0ULI(J1,2,2) = IL0S(J1,1,2)+2
  ENDDO
ELSEIF (IWIS == 203) THEN
  DO J1 = 1 , KPROMB
    IL0UDI(J1,0,0) = 0
    IL0UDI(J1,0,1) = IL0S(J1,1,0)+1
    IL0UDI(J1,0,2) = IL0S(J1,1,0)+2
    IL0UDI(J1,0,3) = 0
    IL0UDI(J1,1,0) = IL0S(J1,1,1)+0
    IL0UDI(J1,1,1) = IL0S(J1,1,1)+1
    IL0UDI(J1,1,2) = IL0S(J1,1,1)+2
    IL0UDI(J1,1,3) = IL0S(J1,1,1)+3
    IL0UDI(J1,2,0) = IL0S(J1,1,2)+0
    IL0UDI(J1,2,1) = IL0S(J1,1,2)+1
    IL0UDI(J1,2,2) = IL0S(J1,1,2)+2
    IL0UDI(J1,2,3) = IL0S(J1,1,2)+3
    IL0UDI(J1,3,0) = 0
    IL0UDI(J1,3,1) = IL0S(J1,1,3)+1
    IL0UDI(J1,3,2) = IL0S(J1,1,3)+2
    IL0UDI(J1,3,3) = 0
  ENDDO
ENDIF

!    -------------------------------------------------------------------
!*       3. UPPER-AIR FIELDS INTERPOLATION
!           ------------------------------

IF(KPROMB == 0) THEN
  IF (LHOOK) CALL DR_HOOK('SLINT',1,ZHOOK_HANDLE)
  RETURN  ! To avoid problems with array bound checking
ENDIF

!*       3.1  U COMPONENT

CALL GSTATS(1020,0)
IF (IWIS == 201) THEN
!$OMP PARALLEL DO SCHEDULE(DYNAMIC,1) PRIVATE(JLEV)
  DO JLEV=1,NFLEVG
    CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,JLEV,NFLEVG,&
     & IFLDN,IFLDX,&
     & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
     & POBB1U5,PSLU)  
  ENDDO
!$OMP END PARALLEL DO
ELSEIF (IWIS == 203) THEN
!$OMP PARALLEL DO SCHEDULE(DYNAMIC,1) PRIVATE(JLEV)
  DO JLEV=1,NFLEVG
    CALL LAIDDIOBS(KASLB1,KPROMB,1,KPROMB,JLEV,NFLEVG,&
     & IFLDN,IFLDX,&
     & ZCSLA,ZDSLON,ZCSLO,IL0UDI,&
     & POBB1U5,PSLU)  
  ENDDO
!$OMP END PARALLEL DO
ENDIF

!*       3.2  V COMPONENT

IF (IWIS == 201) THEN
!$OMP PARALLEL DO SCHEDULE(DYNAMIC,1) PRIVATE(JLEV)
  DO JLEV=1,NFLEVG
    CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,JLEV,NFLEVG,&
     & IFLDN,IFLDX,&
     & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
     & POBB1V5,PSLV)  
  ENDDO
!$OMP END PARALLEL DO
ELSEIF (IWIS == 203) THEN
!$OMP PARALLEL DO SCHEDULE(DYNAMIC,1) PRIVATE(JLEV)
  DO JLEV=1,NFLEVG
    CALL LAIDDIOBS(KASLB1,KPROMB,1,KPROMB,JLEV,NFLEVG,&
     & IFLDN,IFLDX,&
     & ZCSLA,ZDSLON,ZCSLO,IL0UDI,&
     & POBB1V5,PSLV)  
  ENDDO
!$OMP END PARALLEL DO
ENDIF

!*       3.3  TEMPERATURE

IF (IWIS == 201) THEN
!$OMP PARALLEL DO SCHEDULE(DYNAMIC,1) PRIVATE(JLEV)
  DO JLEV=1,NFLEVG
    CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,JLEV,NFLEVG,&
     & IFLDN,IFLDX,&
     & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
     & POBB1T5,PSLT)  
  ENDDO
!$OMP END PARALLEL DO
ELSEIF (IWIS == 203) THEN
!$OMP PARALLEL DO SCHEDULE(DYNAMIC,1) PRIVATE(JLEV)
  DO JLEV=1,NFLEVG
    CALL LAIDDIOBS(KASLB1,KPROMB,1,KPROMB,JLEV,NFLEVG,&
     & IFLDN,IFLDX,&
     & ZCSLA,ZDSLON,ZCSLO,IL0UDI,&
     & POBB1T5,PSLT)  
  ENDDO
!$OMP END PARALLEL DO
ENDIF

!*       3.4  GFL

DO JGFL=1,NGOMGFL
  IF(YGOMGFL(JGFL)%CSLINT == 'STANDARD  ')THEN
    IF (IWIS == 201) THEN
!$OMP PARALLEL DO SCHEDULE(DYNAMIC,1) PRIVATE(JLEV)
      DO JLEV=1,NFLEVG
        CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,JLEV,NFLEVG,&
         & IFLDN,IFLDX,&
         & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
         & POBB1GFL5(1,1,JGFL),PSLGFL(1,1,JGFL))  
      ENDDO
!$OMP END PARALLEL DO
    ELSEIF (IWIS == 203) THEN
!$OMP PARALLEL DO SCHEDULE(DYNAMIC,1) PRIVATE(JLEV)
      DO JLEV=1,NFLEVG
        CALL LAIDDIOBS(KASLB1,KPROMB,1,KPROMB,JLEV,NFLEVG,&
         & IFLDN,IFLDX,&
         & ZCSLA,ZDSLON,ZCSLO, IL0UDI,&
         & POBB1GFL5(1,1,JGFL),PSLGFL(1,1,JGFL))  
      ENDDO
!$OMP END PARALLEL DO
    ENDIF
  ENDIF
ENDDO


CALL GSTATS(1020,1)

!*       3.6  SURFACE PRESSURE (DONE IN THE CONTEXT OF UPPERAIR)

CALL GSTATS(1937,0)
IF (IWIS == 201) THEN
  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1SP5,PSLSP)  
ELSEIF (IWIS == 203) THEN
  CALL LAIDDIOBS(KASLB1,KPROMB,1,KPROMB,1,   1,&
   & IFLDN,IFLDX,&
   & ZCSLA,ZDSLON,ZCSLO, IL0UDI,&
   & POBB1SP5,PSLSP)  
ENDIF

!*       3.7  OROGRAPHY (HAS TO FOLLOW PS INTERPOLATION)

IF (IWIS == 201) THEN
  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1OR5,PSLOROG)  
ELSEIF (IWIS == 203) THEN
  CALL LAIDDIOBS(KASLB1,KPROMB,1,KPROMB,1,   1,&
   & IFLDN,IFLDX,&
   & ZCSLA,ZDSLON,ZCSLO, IL0UDI,&
   & POBB1OR5,PSLOROG)  
ENDIF

!*       3.8  GEOGRAPHICAL NORTH DIRECTION (ANGLE)

IF ( NSTTYP > 1.OR. LELAM ) THEN
  IF (IWIS == 201) THEN
    CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
     & IFLDN,IFLDX,&
     & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
     & POBB1DL5,PSLDL)  
    CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
     & IFLDN,IFLDX,&
     & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
     & POBB1DM5,PSLDM)  
  ELSEIF (IWIS == 203) THEN
    CALL LAIDDIOBS(KASLB1,KPROMB,1,KPROMB,1,   1,&
     & IFLDN,IFLDX,&
     & ZCSLA,ZDSLON,ZCSLO, IL0UDI,&
     & POBB1DL5,PSLDL)  
    CALL LAIDDIOBS(KASLB1,KPROMB,1,KPROMB,1,   1,&
     & IFLDN,IFLDX,&
     & ZCSLA,ZDSLON,ZCSLO, IL0UDI,&
     & POBB1DM5,PSLDM)  
  ENDIF
ELSE
  PSLDL(:) = 0.0_JPRB
  PSLDM(:) = 1.0_JPRB
ENDIF
CALL GSTATS(1937,1)

!    -------------------------------------------------------------------
!*       4. OTHER FIELDS INTERPOLATION
!           --------------------------

!*       4.1  RESET INTERPOLATION; SURFACE/CONSTANT FIELDS ARE
!*            DONE USING BI-LINEAR (CODE: 201) INTERPOLATION

IF (IWIS == 203) THEN
  IFLDN = 1
  IFLDX = NFLDOBB1
  IWIS  = 201
  IHOR  = 0
  IF ( LRPLANE ) THEN
    CALL ELASCAW(KASLB1,KPROMB,1,KPROMB,1,1,NDGSAH,NDGENH,&
     & NDLUNG,NDLUXG,NDGUNG,NDGUXG,&
     & IFLDN,IFLDX,ISTALAT,IWIS,IHOR,IHVI,&
     & LLSLHD,LLSLHDQUAD,&
     & PLON,PLAT,ZLEV,&
     & ZUN_VETAF,ZUN_VETAH,IUN_VAUTF,&
     & ZUN_VCUICO,ZUN_VSLD,ZUN_VSLDW,1,1.0_JPRB,ZUN_KAPPA,&
     & ZDSLAT,ZCSLA,ZUN_CLASLD,ZDSLON,ZCSLO,ZUN_CLOSLD,&
     & IL0S,IUN_LH0,IUN_LEV,&
     & ZUN_DVER,ZUN_VINTW,ZUN_VINTWSLD,ZUN_VINTWS,&
     & ZUN_VDERW,ZUN_HVW,IDEP)  
  ELSE
    CALL LASCAW(KASLB1,KPROMB,1,KPROMB,1,1,NDGSAH,NDGENH,&
     & IFLDN,ISTALAT,IWIS,IHOR,IHVI,&
     & LLSLHD,LLSLHDQUAD,&
     & R4JP,ZPIS2,ZLSDEPI,RLATI(NDGSAH),&
     & RIPI0(NDGSAH),RIPI1(NDGSAH),RIPI2(NDGSAH),&
     & ZUN_SLD1,ZUN_SLD2,ZUN_SLD3,ZUN_SLDW,&
     & PLON,PLAT,ZLEV,&
     & ZUN_VETAF,ZUN_VETAH,IUN_VAUTF,&
     & ZUN_VCUICO,ZUN_VSLD,ZUN_VSLDW,1,1.0_JPRB,ZUN_KAPPA,&
     & ZDSLAT,ZCSLA,ZUN_CLASLD,ZDSLON,ZCSLO,ZUN_CLOSLD,&
     & IL0S,IUN_LH0,IUN_LEV,&
     & ZUN_DVER,ZUN_VINTW,ZUN_VINTWSLD,ZUN_VINTWS,&
     & ZUN_VDERW,ZUN_HVW)
  ENDIF

  DO J1 = 1 , KPROMB
    IL0ULI(J1,1,1) = IL0S(J1,1,1)+1
    IL0ULI(J1,1,2) = IL0S(J1,1,1)+2
    IL0ULI(J1,2,1) = IL0S(J1,1,2)+1
    IL0ULI(J1,2,2) = IL0S(J1,1,2)+2
  ENDDO

ENDIF

!*       4.2  FIELDS FOR MODEL ERRORS STATISTICS (FRENCH OI)  - PART I

IF ( LCANARI .AND. LCASIG ) THEN
  CALL GSTATS(1020,0)
!$OMP PARALLEL DO SCHEDULE(DYNAMIC,1) PRIVATE(JLEV)
  DO JLEV=1,NFLEVG
    CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,JLEV,NFLEVG,&
     & IFLDN,IFLDX,&
     & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
     & POBB1EZ5,PSLEZ)  
    CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,JLEV,NFLEVG,&
     & IFLDN,IFLDX,&
     & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
     & POBB1EH5,PSLEH)  
  ENDDO
!$OMP END PARALLEL DO
  CALL GSTATS(1020,1)
ENDIF

! Interpolation of Coriolis parameter and 3 cloud parameters are moved
! because ZDSLAT and ZDSLON are different. They are changed in a sense
! that they depend on land/sea mask.

!*       4.3  CORIOLIS PAR.

CALL GSTATS(1937,0)
CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
 & IFLDN,IFLDX,&
 & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
 & POBB1CO5,PSLCORI)  
CALL GSTATS(1937,1)

!*       4.4  CLOUD LIQUID WATER

!   *** WARNING - LAIDLIC HAS TO BE CALLED AFTER CALL TO LASCAW
!                 FOR LINEAR INTERPOLATION

DO JGFL=1,NGOMGFL
  IF(YGOMGFL(JGFL)%CSLINT == 'LAIDLIC   ')THEN
    CALL LAIDLIC(KASLB1,KPROMB,1,KPROMB,NFLEVG,&
     & IFLDN,IFLDX,&
     & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
     & POBB1GFL5(1,1,JGFL),PSLGFL(1,1,JGFL))  
  ENDIF
ENDDO

!    -------------------------------------------------------------------
!*       5. SURFACE FIELDS INTERPOLATION
!           ----------------------------

!*       5.1  MODIFICATION OF ZDSLAT/ZDSLON DUE TO LAND/SEA MASK

ZLEV(:,:) = 0.0_JPRB

IF ( LCANARI .AND. LSLREJ ) THEN

  DO JROF = 1,KPROMB

!for land observation
    IF ( KLSOBS(JROF) == 1 .OR. KLSOBS(JROF) == 2 ) THEN
!*         if point 1,1 is land and point 1,2 is sea
      IF (POBB1LS5(IL0ULI(JROF,1,1)) > 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,1,2)) < 0.5_JPRB ) THEN  
        ZDSLON(JROF,1,1) = 0.
      ENDIF
!*         if point 1,1 is sea and point 1,2 is land
      IF (POBB1LS5(IL0ULI(JROF,1,1)) < 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,1,2)) > 0.5_JPRB ) THEN  
        ZDSLON(JROF,1,1) = 1.
      ENDIF
!*         if both points 1,1 and 1,2 are sea
      IF (POBB1LS5(IL0ULI(JROF,1,1)) < 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,1,2)) < 0.5_JPRB ) THEN  
        ZDSLAT(JROF,1) = 1.
      ENDIF
!*         if point 2,1 is land and point 2,2 is sea
      IF (POBB1LS5(IL0ULI(JROF,2,1)) > 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,2,2)) < 0.5_JPRB ) THEN  
        ZDSLON(JROF,1,2) = 0.
      ENDIF
!*         if point 2,1 is sea and point 2,2 is land
      IF (POBB1LS5(IL0ULI(JROF,2,1)) < 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,2,2)) > 0.5_JPRB ) THEN  
        ZDSLON(JROF,1,2) = 1.
      ENDIF
!*         if both points 2,1 and 2,2 are sea
      IF (POBB1LS5(IL0ULI(JROF,2,1)) < 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,2,2)) < 0.5_JPRB ) THEN  
        ZDSLAT(JROF,1) = 0.
      ENDIF
!*         if four points are sea
      IF (POBB1LS5(IL0ULI(JROF,1,1)) < 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,1,2)) < 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,2,1)) < 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,2,2)) < 0.5_JPRB ) THEN  
        ZLEV(JROF,1) = 2.0_JPRB
      ENDIF

!for sea observation
    ELSEIF (KLSOBS(JROF) == 0 ) THEN
!*         if point 1,1 is sea and point 1,2 is land
      IF (POBB1LS5(IL0ULI(JROF,1,1)) < 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,1,2)) > 0.5_JPRB ) THEN  
        ZDSLON(JROF,1,1) = 0.
      ENDIF
!*         if point 1,1 is land and point 1,2 is sea
      IF (POBB1LS5(IL0ULI(JROF,1,1)) > 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,1,2)) < 0.5_JPRB ) THEN  
        ZDSLON(JROF,1,1) = 1.
      ENDIF
!*         if both points 1,1 and 1,2 are land
      IF (POBB1LS5(IL0ULI(JROF,1,1)) > 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,1,2)) > 0.5_JPRB ) THEN  
        ZDSLAT(JROF,1) = 1.
      ENDIF
!*         if point 2,1 is sea and point 2,2 is land
      IF (POBB1LS5(IL0ULI(JROF,2,1)) < 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,2,2)) > 0.5_JPRB ) THEN  
        ZDSLON(JROF,1,2) = 0.
      ENDIF
!*         if point 2,1 is land and point 2,2 is sea
      IF (POBB1LS5(IL0ULI(JROF,2,1)) > 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,2,2)) < 0.5_JPRB ) THEN  
        ZDSLON(JROF,1,2) = 1.
      ENDIF
!*         if both points 2,1 and 2,2 are land
      IF (POBB1LS5(IL0ULI(JROF,2,1)) > 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,2,2)) > 0.5_JPRB ) THEN  
        ZDSLAT(JROF,1) = 0.
      ENDIF
!*         if four points are land
      IF (POBB1LS5(IL0ULI(JROF,1,1)) > 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,1,2)) > 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,2,1)) > 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,2,2)) > 0.5_JPRB ) THEN  
        ZLEV(JROF,1) = 2.0_JPRB
      ENDIF
    ENDIF
  ENDDO
ENDIF

!*       5.2  SURFACE TEMPERATURE / CLS FIELDS

CALL GSTATS(1937,0)
CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
 & IFLDN,IFLDX,&
 & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
 & POBB1TS5,PSLTS)  

IF (LDIRCLSMOD) THEN

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1TCLS5,PSLTCLS)

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1HUCLS5,PSLHUCLS)
ENDIF

!*       5.3  SOIL WETNESS

CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
 & IFLDN,IFLDX,&
 & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
 & POBB1WS5,PSLWS)  

!*       5.4  SNOW

CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
 & IFLDN,IFLDX,&
 & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
 & POBB1SN5,PSLSN)  

!*       5.5.1  ROUGHNESS LEN.

CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
 & IFLDN,IFLDX,&
 & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
 & POBB1Z05,PSLZ0)  

!*       5.5.2  U-COMP 10M NEUTRAL WIND
IF (IWIS == 201) THEN
  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1U10N5,PSLU10N)
ELSE
  CALL LAIDDIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZCSLA,ZDSLON,ZCSLO, IL0UDI,&
   & POBB1U10N5,PSLU10N)
ENDIF

!*       5.5.3  V-COMP 10M NEUTRAL WIND

IF (IWIS == 201) THEN
  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1V10N5,PSLV10N)
ELSE
  CALL LAIDDIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZCSLA,ZDSLON,ZCSLO, IL0UDI,&
   & POBB1V10N5,PSLV10N)
ENDIF

!*       5.6  SKIN RESERVOIR

CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
 & IFLDN,IFLDX,&
 & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
 & POBB1WL5,PSLWL)  

!*       5.7  CONSTANT FIELDS (SAME INTERPOLATION AS FOR
!*                               SURFACE FIELDS)

!*       5.7.1  ALBEDO

CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
 & IFLDN,IFLDX,&
 & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
 & POBB1AL5,PSLALBE)  

!*       5.7.2  EMISSIVITY

CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
 & IFLDN,IFLDX,&
 & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
 & POBB1EM5,PSLEMIS)  

!*       5.7.3  SEA/LAND MASK

CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
 & IFLDN,IFLDX,&
 & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
 & POBB1LS5,PSLLSMA)  
CALL GSTATS(1937,1)

IF (LECMWF) THEN

!*       5.7.4  SEA-ICE FRACTION 

  CALL GSTATS(1937,0)
  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1CI5,PSLCI)  
  CALL GSTATS(1937,1)

!*       5.7.5  HIGH VEGETATION FRACTION (nearest-grid point)

  CALL LAIDLIC  (KASLB1,KPROMB,1,KPROMB,    1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1CVH5,PSLCVH)  

!*       5.7.6  LOW VEGETATION FRACTION (nearest-grid point)

  CALL LAIDLIC  (KASLB1,KPROMB,1,KPROMB,    1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1CVL5,PSLCVL)  

!*       5.7.7  HIGH VEGETATION TYPE (nearest-grid point)

  CALL LAIDLIC  (KASLB1,KPROMB,1,KPROMB,    1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1TVH5,PSLTVH)  

!*       5.7.8  LOW VEGETATION TYPE (nearest-grid point)

  CALL LAIDLIC  (KASLB1,KPROMB,1,KPROMB,    1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1TVL5,PSLTVL)  

!*       5.7.9  OCEAN CURRENT

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1U05,PSLU0)

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1V05,PSLV0)

!*       5.7.10 OCEAN CHARNOCK

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1CHN5,PSLCHN)

ELSE

!*       5.7.11  VEGETATION

  CALL GSTATS(1937,0)
  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1VG5,PSLVEGE)  
  CALL GSTATS(1937,1)
ENDIF

!*       5.8  WATER PRECIPITATION (IF CANARI)

IF ( LCANARI ) THEN
  CALL GSTATS(1937,0)
  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1PW5,PSLPRWA)  

!*       5.9  SNOW PRECIPITATION (IF CANARI)

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1PS5,PSLPRSN)  

!*       5.10 CLIMATOLOGICAL FIELDS (IF CANARI)

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1XTS,PSXTS)  

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1XTP,PSXTP)  

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1XWS,PSXWS)  

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1XWP,PSXWP)  

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1XSN,PSXSN)  
  CALL GSTATS(1937,1)
ENDIF

!*       5.11  FIELDS FOR ISBA

CALL GSTATS(1937,0)
IF ( LSOLV ) THEN

!*       5.11.1 PERCENTAGE OF CLAY WITHIN THE SOIL

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1ARG5,PSLARG)  

!*       5.11.2 PERCENTAGE OF SAND WITHIN THE SOIL

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1SAB5,PSLSAB)  

!*       5.11.3 RESISTANCE TO EVAPOTRANSPIRATION

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1HV5,PSLHV)  

!*       5.11.4 G*THERMAL ROUGHNESS LENGTH

  IF (YSD_VVD%NUMFLDS >= 8) THEN
    CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,  1,&
     & IFLDN,IFLDX,&
     & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
     & POBB1Z0H5,PSLZ0H)  
  ELSE
    PSLZ0H(:)= 1.0_JPRB
  ENDIF
ENDIF

!*       5.12  FIELDS FOR MODEL ERRORS STATISTICS (FRENCH OI)

IF ( LCANARI .AND. LCASIG ) THEN

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,   1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1EST5,PSLEST)  

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,   1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1ESN,PSLESN)  

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,   1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1ET2,PSLET2)  

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,   1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1EH2,PSLEH2)  

  CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,   1,&
   & IFLDN,IFLDX,&
   & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
   & POBB1EV1,PSLEV1)  
ENDIF
CALL GSTATS(1937,1)

!*       5.13  SURFACE TEMPERATURE : SPECIAL TREATMENT FOR COASTAL OBS

! Some observations need 2 Ts interpolated fields : one for land parameter (T2m,Hu2m,...)
! and one for sea parameter (SST).
! The land case is OK, now prepare Ts over sea.

PSLSST(:) = PSLTS(:)

IF ( LCANARI .AND. LSLREJ ) THEN
  IDUM1=0

  DO JROF = 1,KPROMB

    IF ( KLSOBS(JROF) == 2 ) THEN

      IDUM1=IDUM1+1

!*         if point 1,1 is sea and point 1,2 is land
      IF (POBB1LS5(IL0ULI(JROF,1,1)) < 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,1,2)) > 0.5_JPRB ) THEN  
        ZDSLON(JROF,1,1) = 0.
      ENDIF
!*         if point 1,1 is land and point 1,2 is sea
      IF (POBB1LS5(IL0ULI(JROF,1,1)) > 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,1,2)) < 0.5_JPRB ) THEN  
        ZDSLON(JROF,1,1) = 1.
      ENDIF
!*         if both points 1,1 and 1,2 are land
      IF (POBB1LS5(IL0ULI(JROF,1,1)) > 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,1,2)) > 0.5_JPRB ) THEN  
        ZDSLAT(JROF,1) = 1.
      ENDIF
!*         if point 2,1 is sea and point 2,2 is land
      IF (POBB1LS5(IL0ULI(JROF,2,1)) < 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,2,2)) > 0.5_JPRB ) THEN  
        ZDSLON(JROF,1,2) = 0.
      ENDIF
!*         if point 2,1 is land and point 2,2 is sea
      IF (POBB1LS5(IL0ULI(JROF,2,1)) > 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,2,2)) < 0.5_JPRB ) THEN  
        ZDSLON(JROF,1,2) = 1.
      ENDIF
!*         if both points 2,1 and 2,2 are land
      IF (POBB1LS5(IL0ULI(JROF,2,1)) > 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,2,2)) > 0.5_JPRB ) THEN  
        ZDSLAT(JROF,1) = 0.
      ENDIF
!*         if four points are land
      IF (POBB1LS5(IL0ULI(JROF,1,1)) > 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,1,2)) > 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,2,1)) > 0.5_JPRB .AND.&
         & POBB1LS5(IL0ULI(JROF,2,2)) > 0.5_JPRB ) THEN  
        ZLEV(JROF,1) = 1.0_JPRB
      ENDIF
    ENDIF
  ENDDO

  CALL GSTATS(1937,0)
  IF (IDUM1 /= 0) THEN
    CALL LAIDLIOBS(KASLB1,KPROMB,1,KPROMB,1,   1,&
     & IFLDN,IFLDX,&
     & ZDSLAT,ZDSLON(1,1,1),IL0ULI,&
     & POBB1TS5,PSLSST)  
  ENDIF
  CALL GSTATS(1937,1)
ENDIF
    
!*       5.14  CONSIDER LAND/SEA MASK  (FRENCH OI)

! We want to reject the parameters of the observations which are surrounded
! by 4 sea points over ground (T2m and Hu2m) and with 4 land points over sea (SST).
! To allow this rejection, we use the PSLEMIS array to "mark" the concerned obs.

IF ( LCANARI .AND. LSLREJ ) PSLEMIS(:) = PSLEMIS(:)+ZLEV(:,1)*100._JPRB

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