SUBROUTINE NGEDEVE(KDEVEN1,KEVENT,KLIST)

!**** SUBROUTINE NGEDEVE - GET ALL DATUM EVENTS

!          HEIKKI JARVINEN   ECMWF          15/MAR/1995
!          DRASKO VASILJEVIC ECMWF          21/10/1999

!*    PURPOSE
!     -------

!        GET ALL DATUM EVENTS

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

!     ***CALL NGEDEVE(KDEVEN1,KEVENT,KLIST)
!     WHERE KDEVEN1 = DATUM EVENT 1
!           KEVENT  = NUMBER OF DATUM EVENTS FOUND
!           KLIST   = BINARY LIST OF DATUM EVENTS

!        NGEDEVE IS CALLED BY SUBROUTINES

!*    METHOD
!     ------

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

!**   MODIFICATIONS
!     -------------
!        H. Jarvinen 12 Dec 1996 : A modified subroutine call
!     ------------------------------------------------------------------

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

USE PARCMA   , ONLY : JPMXDE1

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KDEVEN1
INTEGER(KIND=JPIM),INTENT(OUT)   :: KEVENT 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KLIST(JPMXDE1) 
INTEGER(KIND=JPIM) :: J, IEVE
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "fcobs.h"

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

!        1.       INITIALIZE
!                 ----------

!*          1.1   INITIALIZE EVENT LIST

IF (LHOOK) CALL DR_HOOK('NGEDEVE',0,ZHOOK_HANDLE)
KEVENT = 0
KLIST(:) = 0
!*
!     ------------------------------------------------------------------

!        2.       GET DATUM EVENTS
!                 -----------------

!IDEVEN1 = ROBODY(KOBS,MDBDEV1)
IF(KDEVEN1 == 0) GOTO 3
DO J = 1, JPMXDE1
  IEVE = IBITS(KDEVEN1, J-1, 1)
  IF(IEVE == 1) THEN
    KEVENT   = KEVENT +1
    KLIST(J) = 1
  ENDIF
ENDDO
!*
!     ------------------------------------------------------------------

!        3.       RETURN
!                 ------
3 CONTINUE
IF (LHOOK) CALL DR_HOOK('NGEDEVE',1,ZHOOK_HANDLE)
END SUBROUTINE NGEDEVE
