SUBROUTINE PREINTRTL(KDLEN,KLEN,KSET,PTS,PWS,PSN)

!****  PREINTRTL  - PREPARATION FOR THE RADIANCE INTERPOLATION

!     ERIK ANDERSSON          01/04/99       ECMWF

!     PURPOSE
!     -------

!        PREINTRTL PREPARES INTERPOLATION FOR ONE SET OF OBSERVATIONS.

!**   INTERFACE
!     ---------

!        CALL PREINTRTL(KDLEN,KLEN,KSET,PTS,PWS,PSN)

!        Where KDLEN   = First dimension (observations)
!              KLEN    = Actual number of observations
!              KSET    = Number (numero) of the obs set to be treated
!              PTS    = Surface skin temperature
!              PWS    = Soil wetness
!              PSN    = Snow depth

!        PREINTRTL IS CALLED FROM HOPTL

!**   METHOD
!     ------

!**   EXTERNALS
!     ---------

!**   MODIFICATIONS
!     -------------
!     E.Andersson 990104 : Original
!     ------------------------------------------------------------------

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
USE GOMS_MIX     , ONLY : YGOMS
USE YOMOBSET , ONLY : MTYPOB
USE YOMDB

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KDLEN
INTEGER(KIND=JPIM),INTENT(IN)    :: KLEN 
INTEGER(KIND=JPIM),INTENT(IN)    :: KSET 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTS(KDLEN) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PWS(KDLEN) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSN(KDLEN) 
INTEGER(KIND=JPIM) :: IOBSTYPE,IPOSM,ILEN,JOBS
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "openmp_obs.h"

!*
!        1.       PREPARATION OF INTERPOLATION
!                 ----------------------------
IF (LHOOK) CALL DR_HOOK('PREINTRTL',0,ZHOOK_HANDLE)
ILEN     = KLEN
IOBSTYPE = MOD(MTYPOB(KSET),100)

DO JOBS = 1,ILEN
  IPOSM   = ROBHDR(JOBS,MDB_MAPOMM_AT_INDEX)
  PTS(JOBS) = YGOMS(IPOSM)%TS
  PWS(JOBS) = YGOMS(IPOSM)%WS/1000._JPRB
  PSN(JOBS) = YGOMS(IPOSM)%SN/1000._JPRB
ENDDO

!*
!     ------------------------------------------------------------------

!        9.       RETURN
!                 ------

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