SUBROUTINE FILFBDE(KPOINT   ,&
 & KVNM    ,KVCT  ,PVCR1 ,PVCR2 ,PVAL  ,&
 & PFOERR  ,POERR ,PRERR ,PPERR ,&
 & PFGERR  ,PFGCC1,PFGCC2,&
 & POMAN   ,POMFG ,&
 & KDST    ,KDEV1 ,KDEV2 ,KPVFLG,KANFLG)  

!**** SUBROUTINE FILFBDE - FILL UP BODY ENTRY 

!        D. VASILJEVIC     ECMWF     04/07/94

!     PURPOSE
!     -------

!        STORE VALUES INTO A BODY ENTRY ARRAY

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

!        CALL FILFBDE(KPOINT,
!                     KVNM  ,KVCT  ,
!                     PVCR1 ,PVCR2 ,
!                     PVAL  ,POMAN ,POMFG,
!                     PFOERR,POERR ,PRERR,PPERR,PFGERR,
!                     KPFLG ,KVFLG ,KDST ,KDEV1,
!                     PFGCC1,PFGCC2                    )
!     WHERE:
!           KPOINT = BODY ENTR POINTER
!           KVNM   = VARIABLE NUMBER
!           KVCT   = TYPE OF VERTICAL COORDINATE
!           PVCR1  = VERTICAL COORDINATE REFERENCE 1
!           PVCR2  = VERTICAL COORDINATE REFERENCE 2
!           PVAL   = OBSERVED VALUE
!           POMAN  = OBSERVED MINUS ANLAYSED VALUE
!           POMFG  = OBSERVED MINUS FIRST GUESS VALUE
!           PFOERR = FINAL OBSERVATION ERROR
!           POERR  = OBSERVATION ERROR
!           PRERR  = REPRESENTATIVNESS ERROR
!           PPERERR= PERSISTENCE ERROR
!           PFGERR = FIRST GUESS ERROR
!           KPVFLG = PRESSURE/VARIABLE FLAG
!           KANFLG = ANALYSIS FLAG
!           KDST   = DATUM STATUS
!           KDEV1  = DATUM STATUS
!           PFGCC1 = FIRST GUESS CHECK CONSTANT 1
!           PFGCC2 = FIRST GUESS CHECK CONSTANT 2
!           KENTSQ = BODY ENTRY SQ. NO.

!        FILFBDE IS CALLED BY SUBROUTINES:

!     METHOD
!     ------

!        THE APPROPIRIATE WORDS OF A BODY ENTRY ARE FILLED UP.

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

!        NONE

!     MODIFICATIONS
!     -------------
!        M.Hamrud      01-Oct-2003 CY28 Cleaning

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

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
USE YOMDB
IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KPOINT 
INTEGER(KIND=JPIM),INTENT(IN)    :: KVNM 
INTEGER(KIND=JPIM),INTENT(IN)    :: KVCT 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVCR1 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVCR2 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVAL 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PFOERR 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POERR 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRERR 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PPERR 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PFGERR 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PFGCC1 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PFGCC2 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POMAN 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POMFG 
INTEGER(KIND=JPIM),INTENT(IN)    :: KDST 
INTEGER(KIND=JPIM),INTENT(IN)    :: KDEV1 
INTEGER(KIND=JPIM),INTENT(IN)    :: KDEV2 
INTEGER(KIND=JPIM),INTENT(IN)    :: KPVFLG 
INTEGER(KIND=JPIM),INTENT(IN)    :: KANFLG 
INTEGER(KIND=JPIM) :: IDEVENT

INTEGER(KIND=JPIM) :: IDLIST(32)

LOGICAL :: LLWRONG
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "ngedeve.intfb.h"

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

!*

!        1.             OBSERVATION BODY ENTRY CREATION 
!                       -------------------------------
!                              (FIXED PART)
!                              ------------

IF (LHOOK) CALL DR_HOOK('FILFBDE',0,ZHOOK_HANDLE)
LLWRONG = .FALSE.
CALL NGEDEVE(INT(ROBODY(KPOINT,MDBDEV1)),IDEVENT,IDLIST)

!*          1.1         VARIABLE NUMBER

ROBODY(KPOINT,MDBVNM ) = KVNM

!*          1.2         TYPE OF VERTICAL COORDINATE

ROBODY(KPOINT,MDBVCO ) = KVCT

!*          1.3         VERTICAL COORDINATE REFERENCE 1

ROBODY(KPOINT,MDBPPP ) = PVCR1

!*          1.4         VERTICAL COORDINATE REFERENCE 2

ROBODY(KPOINT,MDBPRL ) = PVCR2

!*          1.5         OBSERVED VALUE

ROBODY(KPOINT,MDBVAR ) = PVAL

!*          1.6         OBSERVED MINUS ANALYSED VALUE

ROBODY(KPOINT,MDBOMN ) = POMAN

!*          1.7         OBSERVED MINUS FIRST GUESS VALUE

ROBODY(KPOINT,MDBOMF ) = POMFG

!*          1.8         FINAL OBSERVATION ERROR

ROBODY(KPOINT,MDBFOE ) = PFOERR

!*          1.9         OBSERVATION ERROR

ROBODY(KPOINT,MDBOER ) = POERR

!*          1.10        REPRESENTATIVNESS ERROR

ROBODY(KPOINT,MDBRER ) = PRERR

!*          1.11        PERSISTENCE ERROR

ROBODY(KPOINT,MDBPER ) = PPERR

!*          1.12        FIRST GUESS ERROR

ROBODY(KPOINT,MDBFGE ) = PFGERR

!*          1.13        PRESSURE AND VARIABLE FLAGS

ROBODY(KPOINT,MDBRDFL) = KPVFLG

!*          1.14        ANALYSIS FLAGS

ROBODY(KPOINT,MDBFLG ) = KANFLG

!*          1.15        STATUS

ROBODY(KPOINT,MDBDSTA) = KDST

!*          1.16        GENERAL EVENTS 1

ROBODY(KPOINT,MDBDEV1) = KDEV1

!*          1.17        GENERAL EVENTS 2

ROBODY(KPOINT,MDBDEV2) = KDEV2

!*          1.18        BLACKLIST EVENTS (DEFAULT KEPT)

!*          1.19        FIRST GUESS CHECK CONSTANT 1

!*AFROBODY(KPOINT,MDB_QC_A) = PFGCC1

!*          1.20        FIRST GUESS CHECK CONSTANT 2

!*AFROBODY(KPOINT,MDB_QC_L) = PFGCC2
!*
!-----------------------------------------------------------------------

!        2.             RETURN
!                       ------

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