SUBROUTINE FPMODCFU

!**** *FPMODCFU*  - Preliminary modification of cumulated fluxes 
!                   for Post-Processing
!     PURPOSE.
!     --------
!        To prepare input fields before horizontal interpolations

!**   INTERFACE.
!     ----------
!       *CALL* *FPMODCFU*

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

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

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

!     EXTERNALS.
!     ----------

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

!     AUTHOR.
!     -------
!        RYAD EL KHATIB *METEO-FRANCE*

!     MODIFICATIONS.
!     --------------
!        ORIGINAL : 96-08-06
!    R. El Khatib : 03-04-17 Fullpos improvemnts
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        Y.Seity      15-Jan-2007 add Graupel and Hail
!     ------------------------------------------------------------------

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

USE YOMDIM   , ONLY : NFLEVG
USE YOMAFN   , ONLY : GFP_CLSP ,GFP_CCP  ,GFP_CLSS ,GFP_CCSF,&
                    &  GFP_CLSG ,GFP_CCSG ,GFP_CLSH ,GFP_CCSH
USE YOMFPC   , ONLY : C1FPCFU
USE YOMCFU   , ONLY : NFDCFU   ,LTFPLC   ,LTFPLS
USE YOMGFUB  , ONLY : GFUBUF
USE PTRGFU   , ONLY : MFPLCL   ,MFPLSL   ,MFPLCN   ,MFPLSN,&
                    &  MFPLCG   ,MFPLSG   ,MFPLCH   ,MFPLSH 

IMPLICIT NONE

INTEGER(KIND=JPIM) :: IFLDPTR(NFDCFU)

INTEGER(KIND=JPIM) :: IFLD
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "fpmodprec.intfb.h"

!*    1. FIND FIELDS TO MODIFY 
!        ---------------------

IF (LHOOK) CALL DR_HOOK('FPMODCFU',0,ZHOOK_HANDLE)
IFLD=0
IF (INDEX(C1FPCFU,GFP_CLSP%CLNAME) /= 0) THEN   ! Large scale rain
  IFLD=IFLD+1
  IF (LTFPLS)THEN
    IFLDPTR(IFLD)=NFLEVG+MFPLSL
  ELSE
    IFLDPTR(IFLD)=MFPLSL
  ENDIF
ENDIF
IF (INDEX(C1FPCFU,GFP_CCP%CLNAME) /= 0) THEN    ! Convective rain
  IFLD=IFLD+1
  IF (LTFPLC)THEN
    IFLDPTR(IFLD)=NFLEVG+MFPLCL
  ELSE
    IFLDPTR(IFLD)=MFPLCL
  ENDIF
ENDIF
IF (INDEX(C1FPCFU,GFP_CLSS%CLNAME) /= 0) THEN   ! Large Scale Snow fall
  IFLD=IFLD+1
  IF (LTFPLS)THEN
    IFLDPTR(IFLD)=NFLEVG+MFPLSN
  ELSE
    IFLDPTR(IFLD)=MFPLSN
  ENDIF
ENDIF
IF (INDEX(C1FPCFU,GFP_CCSF%CLNAME) /= 0) THEN   ! Convective  Snow fall
  IFLD=IFLD+1
  IF (LTFPLC)THEN
    IFLDPTR(IFLD)=NFLEVG+MFPLCN
  ELSE
    IFLDPTR(IFLD)=MFPLCN
  ENDIF
ENDIF
IF (INDEX(C1FPCFU,GFP_CLSG%CLNAME) /= 0) THEN   ! Large Scale Graupel fall
  IFLD=IFLD+1
  IF (LTFPLS)THEN
    IFLDPTR(IFLD)=NFLEVG+MFPLSG
  ELSE
    IFLDPTR(IFLD)=MFPLSG
  ENDIF
ENDIF
IF (INDEX(C1FPCFU,GFP_CCSG%CLNAME) /= 0) THEN   ! Convective  Graupel fall
  IFLD=IFLD+1
  IF (LTFPLC)THEN
    IFLDPTR(IFLD)=NFLEVG+MFPLCG
  ELSE
    IFLDPTR(IFLD)=MFPLCG
  ENDIF
ENDIF
IF (INDEX(C1FPCFU,GFP_CLSH%CLNAME) /= 0) THEN   ! Large Scale Hail fall
  IFLD=IFLD+1
  IF (LTFPLS)THEN
    IFLDPTR(IFLD)=NFLEVG+MFPLSH
  ELSE
    IFLDPTR(IFLD)=MFPLSH
  ENDIF
ENDIF
IF (INDEX(C1FPCFU,GFP_CCSH%CLNAME) /= 0) THEN   ! Convective  Hail fall
  IFLD=IFLD+1
  IF (LTFPLC)THEN
    IFLDPTR(IFLD)=NFLEVG+MFPLCH
  ELSE
    IFLDPTR(IFLD)=MFPLCH
  ENDIF
ENDIF

!*    2. MODIFY FIELDS 
!        -------------

IF (IFLD > 0) THEN
  CALL FPMODPREC(IFLD,GFUBUF,IFLDPTR)
ENDIF

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