SUBROUTINE PPVAFL(KPFLG,KVFLG,KFLAG)

!**** SUBROUTINE PPVAFL - PRESSURE AND VARIABLE RDB FLAG

!        D. VASILJEVIC     ECMWF     04/07/94

!     PURPOSE
!     -------

!        COMBINE (RDB) PRESSURE AND VARIABLE FLAG

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

!        CALL PPVAFL(KPFLG,KVFLG,KFLAG)
!     WHERE:
!           KPFLG  = PRESSURE FLAG
!           KVFLG  = VARIABLE FLAG
!           KFLAG  = COMBINED FLAG

!        PPVAFL IS CALLED BY SUBROUTINES:

!     METHOD
!     ------

!        THE COMBINED FLAG IS SET. THE 15-BIT CMA PRESSURE/VARIABLE
!     FLAGS HAVE THE FOLLOWING MEANING:
!           BIT 0     - 1 HUMAN MONITOR SUBS.
!                     - 0 NO HUMAN MONITOR SUBS.
!           BIT 1     - 1 Q/C SUBS.
!                     - 0 NO Q/C SUBS.
!           BIT 2     - 1 OVER-RIDE FLAG SET
!                     - 0 OVER-RIDE FLAG NOT SET
!           BITS 3-4  - 0 PARAMETER CORRECT
!                     - 1 PARAM PROBABLY CORRECT
!                     - 2 PARAM PROBABLY INCORRECT
!                     - 3 PARAM INCORRECT
!           BIT 5     - 1 PARM FLAG SET BY HUMAN MONITOR
!                     - 0 PARAM FLAG SET BY Q/C OR NOT CHECKED
!           BITS 6-7  - 0 PARAMETER JUDGED CORRECT BY PREVIOUS ANAL.
!                     - 1 PARAM WAS PROBABLY CORRECT
!                     - 2 PARAM WAS PROBABLY INCORRECT
!                     - 3 PARAM WAS INCORRECT
!           BIT 8     - 1 PARAM WAS USED BY PREVIOUS ANALYSIS
!                     - 0 PARAMETER WAS NOT USED
!           BITS 9-14 - 0

!     SINCE ONLY THE INFORMATION IN BITS 3-4 IS AVAILABLE, THE REST
!     IS SET TO 0.

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

!        NONE

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

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

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
USE YOMCMBDY , ONLY : NCMBPFBP ,NCMBVFBP ,NCMBFLBP

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KPFLG 
INTEGER(KIND=JPIM),INTENT(IN)    :: KVFLG 
INTEGER(KIND=JPIM),INTENT(INOUT) :: KFLAG 
INTEGER(KIND=JPIM) :: IPFLG, IVFLG, IZERO

REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

!        1.             (RDB) PRESSURE AND VARIABLE FLAG
!                       --------------------------------

!*          1.1         PRESSURE FLAGS

IF (LHOOK) CALL DR_HOOK('PPVAFL',0,ZHOOK_HANDLE)
IZERO=0
IPFLG=INSERT(IZERO,KPFLG,NCMBFLBP)

!*          1.2         VARIABLE FLAGS

IZERO=0
IVFLG=INSERT(IZERO,KVFLG,NCMBFLBP)

!*          1.3         COMBINED FLAGS

!*          1.3.1       PRESSURE

KFLAG = INSERT(KFLAG,IPFLG,NCMBPFBP)

!*          1.3.2       VARIABLE

KFLAG = INSERT(KFLAG,IVFLG,NCMBVFBP)
!*
!-----------------------------------------------------------------------

!        2.             RETURN
!                       ------

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