SUBROUTINE SSMIMAS(KSKIP ,KMXLIN,LDLIMA,KMXELE,LDELMA,KERR                 )

!**** SUBROUTINE SSMIMAS - CREATE THINNING MASK FOR SSM/I

!        L. PHALIPPOU    ECMWF  21/06/96

!     PURPOSE
!     -------

!        THIN SSM/I DATA

!**   INTERFACE
!     ---------
!     INPUT:
!     KSKIP:      NUMBER OF POINTS TO SKIP ALONG/ACROSS SCAN
!     KMXLIN:     MAX NUMBER OF SSM/I LINES IN 1 ORBIT
!     KMXELE:     MAX NUMBER OF ELEMENTS IN 1 SCAN

!     OUTPUT:
!     LDLIMA:     LINE MASK
!     LDELMA:     ELEMENT MASK
!     KERR:       ERROR FLAG (0:OK, -1:FAIL)

!     METHOD
!     ------

!     EXTERNALS
!     ---------

!     HISTORY
!     -------

!....................................................................

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

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KMXLIN 
INTEGER(KIND=JPIM),INTENT(IN)    :: KMXELE 
INTEGER(KIND=JPIM),INTENT(IN)    :: KSKIP 
LOGICAL           ,INTENT(OUT)   :: LDLIMA(KMXLIN) 
LOGICAL           ,INTENT(OUT)   :: LDELMA(KMXELE) 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KERR 
INTEGER(KIND=JPIM) :: J
REAL(KIND=JPRB) :: ZHOOK_HANDLE

!....................................................................

!*          1. MAKE LINE MASK

IF (LHOOK) CALL DR_HOOK('SSMIMAS',0,ZHOOK_HANDLE)
KERR=0
IF(KSKIP < 0) THEN
  KERR=-1
  GO TO 9999
ENDIF

!     Initialize
DO J=1,KMXLIN
  LDLIMA(J)=.FALSE.
ENDDO
!     Mask
DO J=1,KMXLIN,KSKIP+1
  LDLIMA(J)=.TRUE.
ENDDO

!*          2. MAKE ELEMENT MASK

!     Initialize
DO J=1,KMXELE
  LDELMA(J)=.FALSE.
ENDDO
!     Mask
DO J=1,KMXELE,KSKIP+1
  LDELMA(J)=.TRUE.
ENDDO

9999 CONTINUE
IF (LHOOK) CALL DR_HOOK('SSMIMAS',1,ZHOOK_HANDLE)
END SUBROUTINE SSMIMAS

