SUBROUTINE BOB(KPROMA,KSTART,KPROF,KFLEV,KLEVP,KLOLEV,&
 & KLEVB,PRPRES,LDBELO,LDBLOW,&
 & PRXP,PRXPD,PBH,PBPP)  

!**** *BOB* - B-coefficients interpolated to OBservations' pressures

!     PURPOSE.
!     --------
!           B-coefficients of the model are interpolated to the levels of
!       the output system.

!**   INTERFACE.
!     ----------
!        *CALL* *BOB(KPROMA,KSTART,KPROF,KFLEV,KLEVP,KLOLEV
!    1              ,KLEVB,PRPRES,LDBELO,LDBLOW
!    2              ,PRXP,PRXPD,PBH,PBPP)

!        EXPLICIT ARGUMENTS
!        --------------------

!        KPROMA                    - HORIZONTAL DIMENSION.             (INPUT-C)
!        KSTART                    - START OF WORK.                    (INPUT-C)
!        KPROF                     - DEPTH OF WORK.                    (INPUT-C)
!        KFLEV                     - NUMBER OF INPUT PRESSURE LEVELS   (INPUT-C)
!        KLEVP                     - NUMBER OF OUTPUT PRESSURE LEVELS  (INPUT-C)
!        KLOLEV                    - BEGINING FOR THE INTERPOLATION    (INPUT-C)
!        KLEVB(KPROMA,KLEVP,NPPM)  - INPUT LEVEL BELOW PRPRES          (INPUT-C)
!                                    (SEE PPFLEV)
!        PRPRES(KPROMA,KLEVP)      - POST PROCESS LEVEL PRESSURES       (INPUT_C)
!        LDBELO(KPROMA,KLEVP)      - .TRUE. IF PRESSURE IS UNDER
!                                     LOWEST (FULL) MODEL LEVEL        (INPUT-C)
!        LDBLOW(KLEVP)             - .TRUE. IF LDBELO(J) IS CONTAINING
!                                    AT LEAST ONE .TRUE.               (INPUT-C)
!        PRXP(KPROMA,0:KFLEV,NPPM) - HALF,FULL AND LN HALF,FULL LEVEL
!                                    PRESSURES (SEE PPINIT)            (INPUT)
!        PRXPD(KPROMA,0:KFLEV,NPPM)- 1./D(P) AND 1./D(LN(P))           (INPUT)
!        PBH(KPROMA,0:KFLEV)       - B - COEFFICIENTS  ON HALF INPUT
!                                    LEVELS.                           (INPUT)

!        PBPP(KPROMA,KLEVP)        - POST-PROCESSED B - COEFFICIENTS   (OUTPUT)

!        IMPLICIT ARGUMENTS :  NONE.
!        --------------------

!     METHOD.
!     -------
!        SEE DOCUMENTATION

!     EXTERNALS.  PPINTP - LINEAR INTERPOLATION
!     ----------

!     REFERENCE.
!     ----------
!        ARPEGE/ALADIN Documentation.

!     AUTHOR.
!     -------
!        RADMILA BUBNOVA *GMAP/COMPAS - STAGE MICECO*

!     MODIFICATIONS.
!     --------------
!        ORIGINAL : 92-09-16
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!     ------------------------------------------------------------------

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

USE YOMDIM   , ONLY : NPPM

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KPROMA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KFLEV 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLEVP 
INTEGER(KIND=JPIM),INTENT(IN)    :: KSTART 
INTEGER(KIND=JPIM),INTENT(IN)    :: KPROF 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLOLEV 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLEVB(KPROMA,KLEVP,NPPM) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRPRES(KPROMA,KLEVP) 
LOGICAL           ,INTENT(IN)    :: LDBELO(KPROMA,KLEVP) 
LOGICAL           ,INTENT(IN)    :: LDBLOW(KLEVP) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRXP(KPROMA,0:KFLEV,NPPM) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRXPD(KPROMA,0:KFLEV,NPPM) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PBH(KPROMA,0:KFLEV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PBPP(KPROMA,KLEVP) 
INTEGER(KIND=JPIM) :: ISLCT, JL, JLEVP
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "ppintp.intfb.h"

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

!*       1.    POST-PROCESS  B - COEFFICIENTS.
!              -------------------------------

!*       1.1   INTERPOLATE B COEFFICIENTS.
IF (LHOOK) CALL DR_HOOK('BOB',0,ZHOOK_HANDLE)
ISLCT=1
CALL PPINTP(KPROMA,KSTART,KPROF,KFLEV,KLEVP,KLOLEV,&
 & KLEVB,ISLCT,&
 & LDBELO,LDBLOW,PRPRES,PRXP,PRXPD,&
 & PBH,PBPP)  

!*       1.2   EXTRAPOLATE  BELOW SURFACE.

DO JLEVP=KLOLEV,KLEVP
  IF (LDBLOW(JLEVP)) THEN
    DO JL=KSTART,KPROF
      IF(LDBELO(JL,JLEVP)) THEN
        PBPP(JL,JLEVP)=1.0_JPRB
      ENDIF
    ENDDO
  ENDIF
ENDDO

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

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