SUBROUTINE AER_DRYDEP &
 !---input
 & ( KIDIA  , KFDIA , KLON  , KLEV   , KDRYDP , KSTEP, &
 &   PAERO  , PCI   , PFAERI, PLSM   , PRHO   , &
 &   PFAERO &
 & )


!**** *AER_DRYDEP* -  ROUTINE FOR PARAMETRIZATION OF DRY DEPOSITION

!      Jean-Jacques Morcrette 
!      following O.Boucher's formulation for LMD-Z

!      Dry deposition is (simply) represented by a modification of the 
!      instantaneous surface flux by what comes down from layer just 
!      above the surface

!**   INTERFACE.
!     ----------
!          *AER_DRYDEP* IS CALLED FROM *CALLPAR*.

! INPUTS:
! -------
! PFAERI (KLON,KDRYDP)   : INPUT SURFACE FLUX        (xx m-2)

! OUTPUTS:
! --------
! PFAERO(KLON,KDRYDP)    : SURFACE FLUX              (xx m-2)

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

!     MODIFICATIONS.
!     -------------

!     SWITCHES.
!     --------

!     MODEL PARAMETERS
!     ----------------

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

USE YOEAERSNK, ONLY : RVDPLIC, RVDPLND, RVDPOCE, RVDPSIC

USE YOMLUN   , ONLY : NULOUT
USE YOEDBUG  , ONLY : KSTPDBG, NSTPDBG

IMPLICIT NONE

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

!*       0.1  ARGUMENTS
!             ---------

!---input fields
INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KFDIA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV 
INTEGER(KIND=JPIM),INTENT(IN)    :: KDRYDP 
INTEGER(KIND=JPIM),INTENT(IN)    :: KSTEP 

REAL(KIND=JPRB)   ,INTENT(IN)    :: PLSM(KLON), PCI(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAERO(KLON,KLEV,KDRYDP)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRHO(KLON,KLEV)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PFAERI(KLON,KDRYDP) 

!---output fields
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFAERO(KLON,KDRYDP) 

INTEGER(KIND=JPIM) :: JL, JAER
REAL(KIND=JPRB) :: ZAERO, ZFROC, ZOCEA, ZLAND, ZLICE, ZSICE, ZRHO
REAL(KIND=JPRB) :: ZVDEP(KDRYDP)

LOGICAL :: LLPRINT


REAL(KIND=JPRB) :: ZHOOK_HANDLE
!-----------------------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('AER_DRYDEP',0,ZHOOK_HANDLE)

!- PFAERI   in unit of xx m-2 s-1 (surface flux)
!- PFAERO    in unit of xx m-2 s-1 (surface flux)
!- N.B. Surface emission fluxes are negative upward, so contribution of 
!  dry deposition is to make the surface flux less negative 

LLPRINT=.FALSE.
!DO JL=1,NSTPDBG
!  IF (KSTEP == KSTPDBG(JL)) THEN
!    LLPRINT=.TRUE.
!  ENDIF
!ENDDO

DO JAER=1,KDRYDP
  DO JL=KIDIA,KFDIA
    ZAERO = PAERO(JL,KLEV,JAER)
        
    ZLAND= PLSM(JL)
    ZOCEA= 1._JPRB-PLSM(JL)
    ZFROC= ZOCEA*(1._JPRB-PCI(JL))
    ZSICE= ZOCEA*PCI(JL)
    ZLICE= 0._JPRB
    ZRHO =PRHO(JL,KLEV)

    ZVDEP(JAER)= ZLAND * RVDPLND(JAER) + ZFROC * RVDPOCE(JAER) + &
      &    ZSICE * RVDPSIC(JAER) + ZLICE * RVDPLIC(JAER)

! RVDPxxx (from su_aerp, derived from LMDZ in m s-1)

    PFAERO(JL,JAER)=PFAERI(JL,JAER) &
      & + ZVDEP(JAER) * ZAERO * ZRHO

!   formula is consistent: (xx m-2 s-1) - (m s-1) * (xx kg-1) * (kg m-3)
!   PFAERO is then in xx m-2 s-1

  ENDDO
ENDDO
IF (LLPRINT) THEN
  WRITE(UNIT=NULOUT,FMT='(1x,''DRYDEP'',I5,9E12.5)') KSTEP,PRHO(KIDIA,KLEV),&
    & (PFAERI(KIDIA,JAER),PFAERO(KIDIA,JAER),ZVDEP(JAER),PAERO(KIDIA,KLEV,JAER),JAER=3,KDRYDP,3)
ENDIF

!-----------------------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('AER_DRYDEP',1,ZHOOK_HANDLE)
END SUBROUTINE AER_DRYDEP
