SUBROUTINE PPCCAD(KPROMA,KSTART,KPROF,KFLEV,KLEVP,KLOLEV,KLEVB,&
 & PCCF,&
 & PCCPP,&
 & PCCF5)  

!**** *PPCCAD * - POST-PROCESS CLOUD COVER (AD)

!     PURPOSE.
!     --------
!        PERFORMS THE VERTICAL INTERPOLATION OF CLOUD COVER TO A GIVEN
!     LEVEL.

!**   INTERFACE.
!     ----------
!        *CALL* *PPCCAD(KPROMA,KSTART,KPROF,KFLEV,KLEVP,KLOLEV,KLEVB,
!                       PCCF,
!                       PCCPP,
!                       PCCF5)

!        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)
!        PCCF(KPROMA,0:KFLEV)      - CLOUD COVER ON FULL INPUT LEVELS  (INPUT)

!        PCCPP(KPROMA,KLEVP)       - POST-PROCESSED CLOUD COVER        (OUTPUT)
!        PCCF5(KPROMA,0:KFLEV)      - CLOUD COVER ON FULL INPUT LEVELS.(INPUT-T)

!        IMPLICIT ARGUMENTS :  CONSTANTS FROM YOMCST AND YOMSTA.
!        --------------------

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

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

!     REFERENCE.
!     ----------
!        ECMWF Research Department documentation of the IFS

!     AUTHOR.
!     -------
!        D. VASILJEVIC  *ECMWF*

!     MODIFICATIONS.
!     --------------
!        ORIGINAL : 93-01-12
!        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(INOUT) :: PCCF(KPROMA,0:KFLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCCPP(KPROMA,KLEVP) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PCCF5(KPROMA,0:KFLEV) 
INTEGER(KIND=JPIM) :: IPNT, JL, JLEVP
REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

!*       1.    POST-PROCESS CLOUD COVER
!              ------------------------

IF (LHOOK) CALL DR_HOOK('PPCCAD',0,ZHOOK_HANDLE)
DO JL=KSTART,KPROF
  PCCF5(JL,0)=PCCF5(JL,1)
ENDDO

DO JLEVP=KLOLEV,KLEVP
  DO JL   =KSTART,KPROF
    IPNT =MIN(MAX(KLEVB(JL,JLEVP,1),0),KFLEV)
    PCCF(JL,IPNT)   = PCCF(JL,IPNT) + PCCPP(JL,JLEVP)
  ENDDO
ENDDO

!*       1.1   PREPARE FOR EXTRAPOLATION ABOVE TOP

DO JL=KSTART,KPROF
  PCCF(JL,1)=PCCF(JL,1)+PCCF(JL,0)
ENDDO

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

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