SUBROUTINE RDBFLR(KOBS,KRDBMX,KFRLAT,KFRLON,KFRDAT,KFRTIM,KFRALT)

!**** SUBROUTINE RDBFLR - GET THE (MAXIMUM) RDB-FLAG FOR REPORT

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

!*    PURPOSE
!     -------

!        GET THE (MAXIMUM) RDB-FLAG FOR REPORT

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

!     ***CALL*RDBFLR(KOBS,KRDBMX
!                   ,KFRLAT,KFRLON,KFRDAT,KFRTIM,KFRALT)
!     WHERE KOBS   = POINTER TO THE CURRENT REPORT
!           KRDBMX = MAXIMUM RDB-FLAG FOR REPORT
!           KFRLAT = LATITUDE RDB-FLAG
!           KFRLON = LONGITUDE RDB-FLAG
!           KFRDAT = DATE RDB-FLAG
!           KFRTIM = TIME RDB-FLAG
!           KFRALT = ALTITUDE RDB-FLAG

!        RDBFLR IS CALLED BY SUBROUTINE FLGTST

!*    METHOD
!     ------

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

!**   MODIFICATIONS
!     -------------

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

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

USE YOMCMHDR , ONLY : NLTFLBP  ,NLNFLBP  ,NDTFLBP  ,NTMFLBP  ,&
 & NALFLBP  ,NFLGBP   ,NFLGOC  
USE YOMDB

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KOBS 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KRDBMX 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KFRLAT 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KFRLON 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KFRDAT 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KFRTIM 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KFRALT 
INTEGER(KIND=JPIM) :: ICMRFL
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "fcobs.h"

#include "openmp_obs.h"
!*
!     ------------------------------------------------------------------

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

IF (LHOOK) CALL DR_HOOK('RDBFLR',0,ZHOOK_HANDLE)
KRDBMX = 0
!*
!     ------------------------------------------------------------------

!        2.       EXTRACT THE RDB-FLAG OF THE REPORT
!                 ----------------------------------
!*
!           2.1   GET THE RDB-FLAG WORD

ICMRFL = ROBHDR(KOBS,MDBRFL)
!*
!           2.2   LATITUDE RDB-FLAG

KFRLAT = IBITS(ICMRFL,NLTFLBP+NFLGBP,NFLGOC)
IF(KFRLAT > KRDBMX) KRDBMX = KFRLAT
!*
!           2.3   LONGITUDE RDB-FLAG

KFRLON = IBITS(ICMRFL,NLNFLBP+NFLGBP,NFLGOC)
IF(KFRLON > KRDBMX) KRDBMX = KFRLON
!*
!           2.4   DATE RDB-FLAG

KFRDAT = IBITS(ICMRFL,NDTFLBP+NFLGBP,NFLGOC)
IF(KFRDAT > KRDBMX) KRDBMX = KFRDAT
!*
!           2.5   TIME RDB-FLAG

KFRTIM = IBITS(ICMRFL,NTMFLBP+NFLGBP,NFLGOC)
IF(KFRTIM > KRDBMX) KRDBMX = KFRTIM
!*
!           2.6   ALTITUDE RDB-FLAG

KFRALT = IBITS(ICMRFL,NALFLBP+NFLGBP,NFLGOC)
IF(KFRALT > KRDBMX) KRDBMX = KFRALT
!*
!     ------------------------------------------------------------------

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