SUBROUTINE m7_wetdep &
  &( KIDIA , KFDIA , KLON , KLEV, KTOP,  & ! dimensions
  &  pxtp10, pxtp1c,                     & ! mixing ratios (ambient, in-cloud, downdraft)
  &  pmfu  , pmfuxt, prhou,              & ! convective properties (not needed for stratiform)
  &  pxtm1 ,                             & ! stratiform properties (not needed for convective)
  &  pmlwc , pmiwc , pmratepr, pmrateps, & ! cloud properties
  &  pfrain, pfsnow, pfevapr,  pfsubls,  & !   "       "
  &  paclc , pmsnowacl, LDSTRAT,         & !   "       "
  &  ptm1  , pdpg  , plfrac,             & ! thermodynamic quantities
  &  pxtte ,                             & ! mixing ratio tendency
  &  PTSPHY                              &
  &)

  ! *xt_wetdep* calculates the wet deposition of tracers
  !
  ! Authors:
  ! --------
  ! Philip Stier,     MPI-MET, Hamburg       2001 - 2004
  ! Claudia Timmreck, MPI-MET, Hamburg            - 2001
  ! Johann Feicher,   MPI-MET, Hamburg            - 2001

  ! JJMorcrette 20091215, Adaptation to ECMWF-IFS
  !
  ! Method:
  ! -------
  ! Currently the scavenging ratios are described in dependence of mode
  ! stratiform or convective cloud type. This will/might be replaced by the 
  ! explicit formulation of nucleation and impaction scavenging. 
  !
  ! Externals:
  ! ----------
  !
  ! References:
  ! -----------
  !
  ! Variables:
  ! ----------
  ! pxtp10         = ambient tracer mass mixing ratio at t=t+dt 
  !                  units: [kg(tracer) kg-1(air)] incoming and returned
  !                         [kg(tracer) m-2]       during calculation
  ! pxtp1c         = in-cloud tracer mass mixing ratio at t=t+dt 
  !                  units: [kg(tracer) kg-1(air)] incoming and returned
  !                         [kg(tracer) m-2]       during calculation
  !
  ! zxtfracwat     = total fraction of the tracer associated with water 
  !                  that is in the water phase [%]
  ! zxtfracice     = total fraction of the tracer associated with ice 
  !                  that is in the ice phase [%]
  ! zxtfracXXX_YYY = fraction of the tracer associated with water 
  !                  that is in the XXX phase due to process YYY 
  !                  where YYY=(nuc: nucleation; imp: impaction; 
  !                  dif: gaseous diffusion) [%]
  ! zdxtwat        = total change of the tracer in the water phase during
  !                  one timestep [kg m-2]
  ! zdxtice        = total change of the tracer in the ice phase during
  !                  one timestep [kg m-2]

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

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

!  USE mo_kind,         ONLY: dp
!  USE mo_time_control, ONLY: time_step_len, delta_time
!  USE mo_tracer,       ONLY: trlist, ntrac,     &
!                             GAS, AEROSOLMASS, AEROSOLNUMBER
!  USE mo_exception,    ONLY: finish
!  USE mo_aero_mem,     ONLY: precipform, precipevap, uparfrac
!  USE mo_aero_m7,      ONLY: nmod
!  USE mo_aero_mem,     ONLY: wdep, wdepinst
!  USE mo_aero_mem,     ONLY: wdep_conv, wdep_strat
!  USE mo_constants,    ONLY: tmelt

USE YO_AERO_M7,ONLY : nmod, nmode, ntrac, cphas, ctrac, &
  &                   lwetd                    , &
  &                   csr_strat_wat, csr_strat_mix, csr_strat_ice, &
  &                   csr_conv, rbcr, rbcs, rwu
USE YOMCST    ,ONLY : RTT
USE YOMLUN    ,ONLY : NULOUT
  
IMPLICIT NONE

LOGICAL,INTENT(IN) :: LDSTRAT ! Indicates stratiform clouds (call from cloud)

!  INTEGER :: kbdim,     kproma,       klev,     ktop,  krow
INTEGER(KIND=JPIM),INTENT(IN) :: KIDIA, KFDIA, KLON, KLEV, KTOP

REAL(KIND=JPRB),INTENT(IN) :: pmlwc(klon ,klev),       pmiwc(klon ,klev),        &
  &                           pmratepr(klon ,klev),    pmrateps(klon ,klev),     &
  &                           pfrain(klon ,klev),      pfsnow(klon ,klev),       &
  &                           pfevapr(klon ,klev),     pfsubls(klon ,klev),      &
  &                           paclc(klon ,klev),       pmsnowacl(klon ,klev),    &
  &                           ptm1(klon ,klev),        pdpg(klon ,klev),         &
  &                           pmfu(klon ,klev),        prhou(klon ,klev),        &
  &                           plfrac(klon ,klev),      pxtm1(klon ,klev,ntrac)

REAL(KIND=JPRB),INTENT(IN) :: PTSPHY

REAL(KIND=JPRB),INTENT(INOUT) :: pxtp1c(klon ,klev,ntrac), pxtp10(klon ,klev,ntrac), &
  &                              pmfuxt(klon ,klev,ntrac), pxtte(klon ,klev,ntrac)


  !--- Local variables:

LOGICAL :: LLAEROSOL,  LLGAS

INTEGER(KIND=JPIM) :: jl, jk, jt, imod

REAL(KIND=JPRB):: ztmst,     zqtmst

REAL(KIND=JPRB):: zilwc, zxtice, zxtwat, zxtp1, zmprec, zfprec, zeps, &
  &               zdxtwat, zdxtice, zdxtcol, zdxtevap, zdep, zmin, zmin2

REAL(KIND=JPRB):: zxtfracwat,              zxtfracice,           &
  &               zxtte_strat,             zxtte_conv                

REAL(KIND=JPRB):: zsump(klon ),            zsumclcp(klon ),      &
  &               zdepint(klon )

REAL(KIND=JPRB):: zmlwc(klon ,klev),       zmiwc(klon ,klev),    &
  &               zice(klon ,klev),        zclceff(klon ,klev),  &
  &               zeffice(klon ,klev),     zeffwat(klon ,klev),  &
  &               zrevap(klon ,klev),      zaclc(klon ,klev)

REAL(KIND=JPRB):: zxtfracwat_dif(klon ,klev),                    &
  &               zxtfracwat_nuc(klon ,klev),                    &
  &               zxtfracwat_imp(klon ,klev),                    &
  &               zxtfracice_dif(klon ,klev),                    &
  &               zxtfracice_nuc(klon ,klev),                    &
  &               zxtfracice_imp(klon ,klev),                    &
  &               zxtfrac_col(klon ,klev)


  !--- Diagnostic stream:

!  REAL(KIND=JPRB),        POINTER :: wdep_p(:,:)
!  REAL(KIND=JPRB),        POINTER :: wdepinst_p(:,:)
!  REAL(KIND=JPRB),        POINTER :: wdep_conv_p(:,:), wdep_strat_p(:,:)

  !--- Constants:

!REAL(KIND=JPRB), PARAMETER :: zmin =1.e-10_JPRB, &
!  &                           zmin2=1.e-20_JPRB

REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"
!     ----------------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('M7_WETDEP',0,ZHOOK_HANDLE)

  !--- 0) Initializations:

!  IF (nmod /= 7) CALL finish('xt_wetdep',' incompatible number of modes')
  IF (nmod /= 7) CALL ABOR1('xt_wetdep : incompatible number of modes')


  zmin =1.e-10_JPRB
  zmin2=1.e-20_JPRB

!!  zeps=EPSILON(1.0_JPRB)
!  zeps=100._JPRB*TINY(1.0_JPRB)
  zeps=1.E-32_JPRB

  ztmst=PTSPHY
  zqtmst=1._JPRB/ztmst

  zsumclcp(:) = 0._JPRB
  zsump(:)    = 0._JPRB

  zaclc(:,:)  = 0._JPRB 



  !--- 1) Calculate hydrological parameters:

  DO jk=ktop,klev
     DO jl=kidia, kfdia

        !--- 1.1) Calculate ice mass-fraction of the total water:

        zmiwc(jl,jk)=MAX(pmiwc(jl,jk),0._JPRB)
        zmlwc(jl,jk)=MAX(pmlwc(jl,jk),0._JPRB)

        zaclc(jl,jk)=paclc(jl,jk)

        zilwc=zmiwc(jl,jk)+zmlwc(jl,jk)

        IF(zilwc > zmin) THEN
           zice(jl,jk)=zmiwc(jl,jk)/zilwc
        ELSE
           zaclc(jl,jk)=0._JPRB
           zice(jl,jk)=0._JPRB
        ENDIF

        !--- 1.2) Calculate autoconversion rate:

        IF(pmiwc(jl,jk) > zmin) THEN
           zeffice(jl,jk)=pmrateps(jl,jk)/zmiwc(jl,jk)
           zeffice(jl,jk)=MAX(0._JPRB,MIN(1._JPRB,zeffice(jl,jk)))
        ELSE
           zeffice(jl,jk)=0._JPRB
        ENDIF

        IF(pmlwc(jl,jk) > zmin) THEN
           zeffwat(jl,jk)=(pmratepr(jl,jk)+pmsnowacl(jl,jk))/zmlwc(jl,jk)
           zeffwat(jl,jk)=MAX(0._JPRB,MIN(1._JPRB,zeffwat(jl,jk)))
        ELSE
           zeffwat(jl,jk)=0._JPRB
        ENDIF

        !--- 1.3) Calculate the effective grid-box fraction 
        !         affected by precipitation (zclceff):

        !--- Precipitation formation:

        zmprec=pmratepr(jl,jk)+pmrateps(jl,jk)+pmsnowacl(jl,jk)

        !--- Store for diagnostics [kg m-2 s-1]:

!        precipform(jl,jk,krow)=zmprec*pdpg(jl,jk)/ztmst

        !--- 1.3.1) Stratiform clouds:

        IF (LDSTRAT) THEN

           !--- Precipitaion-formation weighted averaging:

           zsumclcp(jl)=zsumclcp(jl)+zaclc(jl,jk)*zmprec
           zsump(jl)=zsump(jl)+zmprec

           IF(zsump(jl) > zmin2) THEN
              zclceff(jl,jk)=zsumclcp(jl)/zsump(jl)
           ELSE
              zclceff(jl,jk)=0._JPRB
           ENDIF

        !--- 1.3.2) Convective clouds:

        ELSE

           !--- Assume updraft area fraction as precipitating 
           !    fraction of grid box
           !
           !    Estimate updraft area from prescribed updraft
           !    velocities

           zclceff(jl,jk)=pmfu(jl,jk)/(rwu*prhou(jl,jk))

!           uparfrac(jl,jk,krow)=zclceff(jl,jk)

        ENDIF

        !--- 1.4) Re-evaporation

        zfprec=pfrain(jl,jk)+pfsnow(jl,jk)

        IF(zfprec > zmin) THEN
           zrevap(jl,jk)=(pfevapr(jl,jk)+pfsubls(jl,jk))/zfprec
        ELSE
           zrevap(jl,jk)=0._JPRB
        ENDIF

        zrevap(jl,jk)=MAX(0._JPRB,MIN(1._JPRB,zrevap(jl,jk)))

        !--- Store re-evaporatio + sublimation for diagnostics:
        
!        precipevap(jl,jk,krow)=pfevapr(jl,jk)+pfsubls(jl,jk)

     ENDDO
  ENDDO


  !--- 2) Scavenging:

  tracer : DO jt=1, ntrac

     !--- Initialization:

!     imod    =trlist%ti(jt)%mode
!     LLAEROSOL=(trlist%ti(jt)%nphase==AEROSOLMASS .OR. trlist%ti(jt)%nphase==AEROSOLNUMBER)
!     LLGAS    =trlist%ti(jt)%nphase==GAS
     imod = nmode(jt)
     LLAEROSOL=.false.
     LLGAS    =.false.
     IF (cphas(jt) == 'AMS' .OR. cphas(jt) == 'ANU') then
       LLAEROSOL=.true.
     ENDIF
     IF (cphas(jt) == 'GAS') then
       LLGAS=.true.
     ENDIF

     zdepint(kidia:kfdia)    = 0._JPRB

     zxtfracwat           = 0._JPRB
     zxtfracice           = 0._JPRB

     zxtfracwat_nuc(:,:)  = 0._JPRB
     zxtfracwat_imp(:,:)  = 0._JPRB
     zxtfracwat_dif(:,:)  = 0._JPRB
     zxtfracice_nuc(:,:)  = 0._JPRB
     zxtfracice_imp(:,:)  = 0._JPRB
     zxtfracice_dif(:,:)  = 0._JPRB
     zxtfrac_col(:,:)     = 0._JPRB

!     nwetdep :IF (trlist%ti(jt)%nwetdep>0) THEN
     nwetdep :IF (lwetd(jt)) THEN

        !--- Consistency check:

!        IF(.NOT.(LLAEROSOL .OR. &
!                 trlist%ti(jt)%fullname=='SO2'.OR.trlist%ti(jt)%fullname=='SO4_gas')) THEN
!           CALL finish('xt_wetdep',' scavenging parameters not defined for '//trlist%ti(jt)%fullname)
        IF (.NOT. (LLAEROSOL .OR. ctrac(jt) == 'SO2' .OR. (ctrac(jt) == 'SO4' .AND. cphas(jt) == 'GAS') ) ) THEN
           WRITE(NULOUT,FMT='(''xt_wetdep: scavenging parameters not defined for JT='',I3)') JT
           CALL ABOR1('xt_wetdep: scavenging parameters not defined') 
        ENDIF

        !--- Get diagostic fields:

!        wdep_p     => wdep(jt)%ptr
!        wdep_strat_p => wdep_strat(jt)%ptr
!        wdep_conv_p  => wdep_conv(jt)%ptr
!        wdepinst_p => wdepinst(jt)%ptr

!        wdepinst_p(kidia:kfdia,krow)=0._JPRB

        !--- 2.1) Calculate scavenging parameters:

        !--- 2.1.1) Aerosols:

        IF(LDSTRAT) THEN

        IF(LLAEROSOL) THEN

           !--- Nucleation and impaction in water clouds:

           WHERE(ptm1(kidia:kfdia,:)> RTT)

              zxtfracwat_nuc(kidia:kfdia,:)=csr_strat_wat(imod)
              zxtfracice_nuc(kidia:kfdia,:)=csr_strat_wat(imod)

           !--- Nucleation and impaction in mixed clouds:

           ELSEWHERE(ptm1(kidia:kfdia,:)>238.15_JPRB)

              zxtfracwat_nuc(kidia:kfdia,:)=csr_strat_mix(imod)
              zxtfracice_nuc(kidia:kfdia,:)=csr_strat_mix(imod)

           ELSEWHERE

           !--- Nucleation and impaction in cold clouds:

              zxtfracwat_nuc(kidia:kfdia,:)=csr_strat_wat(imod)
              zxtfracice_nuc(kidia:kfdia,:)=csr_strat_ice(imod)

           ENDWHERE

           !--- Below-cloud scavenging:
           !    Calculate fraction of below cloud scavenged tracer
           !    dM/M = -C dt where the mean scavenging coefficient C = Cn x R where Cn is normalized 
           !    scavenging coefficient (above) and R is the rain-rate kg m-2 s-1, dt is the timestep

           WHERE(zaclc(kidia:kfdia,:) < zmin)

              zxtfrac_col(kidia:kfdia,:)=ztmst*(rbcr(imod)*pfrain(kidia:kfdia,:)+rbcs(imod)*pfsnow(kidia:kfdia,:))
              zxtfrac_col(kidia:kfdia,:)=MAX(0._JPRB,zxtfrac_col(kidia:kfdia,:))

           ELSEWHERE

              zxtfrac_col(kidia:kfdia,:)=0._JPRB

           ENDWHERE

        !--- 2.2.2) Gases:

        ELSEIF (LLGAS) THEN

!           IF(trlist%ti(jt)%basename=='SO2') THEN
           IF (ctrac(jt) == 'SO2') THEN 

              !--- Gas phase scavenging utilizing the liquid fraction of total SO2 
              !    calculated from Henry's law in xt_chemistry:

              zxtfracwat_dif(kidia:kfdia,:)=plfrac(kidia:kfdia,:)
              zxtfracice_dif(kidia:kfdia,:)=0._JPRB
                 
!           ELSEIF(trlist%ti(jt)%fullname=='SO4_gas') THEN
           ELSEIF (ctrac(jt) == 'SO4' .AND. cphas(jt) == 'GAS') THEN

              zxtfracwat_dif(kidia:kfdia,:)=1.0_JPRB
              zxtfracice_dif(kidia:kfdia,:)=0._JPRB

           ENDIF

        ENDIF

        DO  jk=ktop,klev
           DO jl=kidia, kfdia

           !--- Weight mixing ratios with cloud fraction:

           pxtp1c(jl,jk,jt)=pxtp1c(jl,jk,jt)*zaclc(jl,jk)
           pxtp10(jl,jk,jt)=pxtp10(jl,jk,jt)*(1._JPRB-zaclc(jl,jk))


           !--- 2.2) Partitioning between ice and liquid phase:

           !--- Associate tracer masses in the cloud fraction to water phase
           !    and ice phase according to the respective mass fractions:

           zxtice=pxtp1c(jl,jk,jt)*zice(jl,jk)
           zxtwat=pxtp1c(jl,jk,jt)*(1._JPRB-zice(jl,jk))


           !--- 2.3) Calculate the scavenging parameter as sum over the processes:

           zxtfracwat=zxtfracwat_nuc(jl,jk)+zxtfracwat_imp(jl,jk)+zxtfracwat_dif(jl,jk)
           zxtfracice=zxtfracice_nuc(jl,jk)+zxtfracice_imp(jl,jk)+zxtfracice_dif(jl,jk)

           !--- Confine the fraction between 0% and 100% :
              
           zxtfracwat=MAX(0._JPRB,MIN(1._JPRB,zxtfracwat))
           zxtfracice=MAX(0._JPRB,MIN(1._JPRB,zxtfracice))


           !---  2.4) Calculate the changes in concentration and the deposition flux
           !          (R:Rain S:Snow 0:out of cloud)

           zdxtwat=0._JPRB
           zdxtice=0._JPRB

           !--- 3.1) In-cloud scavenging:

           !--- Change in in-cloud tracer concentration:

           IF(zaclc(jl,jk) > zmin) THEN
              zdxtwat=zxtwat*zxtfracwat*zeffwat(jl,jk)
              zdxtice=zxtice*zxtfracice*zeffice(jl,jk)
           ENDIF

           !--- In-cloud tracer concentration:

           zxtwat = zxtwat - zdxtwat
           zxtice = zxtice - zdxtice

           pxtp1c(jl,jk,jt)=zxtwat+zxtice

           !--- Local deposition mass-flux [grid-box mean kg m-2 s-1]:

           zdep=(zdxtwat+zdxtice)*pdpg(jl,jk) / ztmst

           !--- Integrated deposition mass flux:

           zdepint(jl) = zdepint(jl) + zdep


           !--- 3.2) Below cloud scavenging:

           IF(LLAEROSOL .AND. zclceff(jl,jk) > zmin) THEN

              zdxtcol=pxtp10(jl,jk,jt)*zclceff(jl,jk)*zxtfrac_col(jl,jk)

              pxtp10(jl,jk,jt)=pxtp10(jl,jk,jt)-zdxtcol

              zdepint(jl)=zdepint(jl)+zdxtcol*pdpg(jl,jk)/ztmst

           ENDIF


           !--- 3.3) Re-evaporation:

           zdxtevap=zdepint(jl)*zrevap(jl,jk)

           !--- Reduce integrated deposition mass flux:

           zdepint(jl)=zdepint(jl)-zdxtevap

           !--- Stratiform: attribute evaporated mass to ambient air:

           pxtp10(jl,jk,jt)=pxtp10(jl,jk,jt)+zdxtevap/pdpg(jl,jk)*ztmst


           !--- 3.4) Total tendency:

           zxtp1=pxtm1(jl,jk,jt)+pxtte(jl,jk,jt)*ztmst

           zxtte_strat=((pxtp10(jl,jk,jt)+pxtp1c(jl,jk,jt))-zxtp1) / ztmst

           pxtte(jl,jk,jt)=pxtte(jl,jk,jt)+zxtte_strat

           ENDDO
        ENDDO

        !--- 3.5 Diagnostics:

!        DO jl=1, kproma
!           wdep_p(jl,krow)    =wdep_p(jl,krow)+zdepint(jl)*delta_time
!           wdep_strat_p(jl,krow)=wdep_strat_p(jl,krow)+zdepint(jl)*delta_time
!           wdepinst_p(jl,krow)=zdepint(jl)
!        ENDDO


        ELSE ! Convective:

        IF(LLAEROSOL) THEN

           !--- Nucleation and impaction:

           zxtfracwat_nuc(kidia:kfdia,:)=csr_conv(imod)
           zxtfracice_nuc(kidia:kfdia,:)=csr_conv(imod)

           !--- Below-cloud scavenging:
           !    Calculate fraction of below cloud scavenged tracer
           !    dM/M = -C dt where the mean scavenging coefficient C = Cn x R where Cn is normalized 
           !    scavenging coefficient (above) and R is the rain-rate kg m-2 s-1, dt is the timestep

           WHERE(zaclc(kidia:kfdia,:) < zmin)

              zxtfrac_col(kidia:kfdia,:)=ztmst*(rbcr(imod)*pfrain(kidia:kfdia,:)+rbcs(imod)*pfsnow(kidia:kfdia,:))
              zxtfrac_col(kidia:kfdia,:)=MAX(0._JPRB,zxtfrac_col(kidia:kfdia,:))

           ELSEWHERE

              zxtfrac_col(kidia:kfdia,:)=0._JPRB

           ENDWHERE

        !--- 2.2.2) Gases:

        ELSEIF (LLGAS) THEN

!           IF(trlist%ti(jt)%basename=='SO2') THEN
           IF (ctrac(jt) == 'SO2') THEN 

              !--- Gas phase scavenging utilizing the liquid fraction of total SO2 
              !    calculated from Henry's law in xt_chemistry:

              zxtfracwat_dif(kidia:kfdia,:)=plfrac(kidia:kfdia,:)
              zxtfracice_dif(kidia:kfdia,:)=0._JPRB
                 
!           ELSEIF(trlist%ti(jt)%fullname=='SO4_gas') THEN
           ELSEIF (ctrac(jt) == 'SO4' .AND. cphas(jt) == 'GAS') THEN

              zxtfracwat_dif(kidia:kfdia,:)=1.0_JPRB
              zxtfracice_dif(kidia:kfdia,:)=0._JPRB

           ENDIF

        ENDIF

        DO  jk=ktop,klev
           DO jl=kidia, kfdia

              !--- 2.2) Partitioning between ice and liquid phase:

              !--- Associate tracer masses in the cloud fraction to water phase
              !    and ice phase according to the respective mass fractions:

              zxtice=pxtp1c(jl,jk,jt)*zice(jl,jk)
              zxtwat=pxtp1c(jl,jk,jt)*(1._JPRB-zice(jl,jk))


              !--- 2.3) Calculate the scavenging parameter as sum over the processes:

              zxtfracwat=zxtfracwat_nuc(jl,jk)+zxtfracwat_imp(jl,jk)+zxtfracwat_dif(jl,jk)
              zxtfracice=zxtfracice_nuc(jl,jk)+zxtfracice_imp(jl,jk)+zxtfracice_dif(jl,jk)

              !--- Confine the fraction between 0% and 100% :
              
              zxtfracwat=MAX(0._JPRB,MIN(1._JPRB,zxtfracwat))
              zxtfracice=MAX(0._JPRB,MIN(1._JPRB,zxtfracice))


              !---  2.4) Calculate the changes in concentration and the deposition flux
              !          (R:Rain S:Snow 0:out of cloud)

              zdxtwat=0._JPRB
              zdxtice=0._JPRB

              !--- 3.1) In-cloud scavenging:

              !--- Change in updraft tracer concentration:

              IF(zaclc(jl,jk) > zmin) THEN
                 zdxtwat=zxtwat*zxtfracwat*zeffwat(jl,jk)
                 zdxtice=zxtice*zxtfracice*zeffice(jl,jk)
              ENDIF


              !--- Update updraft tracer concentration:

              zxtwat = zxtwat - zdxtwat
              zxtice = zxtice - zdxtice

              pxtp1c(jl,jk,jt)=zxtwat+zxtice

              !--- Local deposition mass-flux [grid-box mean kg m-2 s-1]:

              zdep=(zdxtwat+zdxtice)*pmfu(jl,jk)

              !--- Integrated deposition mass flux:

              zdepint(jl) = zdepint(jl) + zdep

              !--- Update updraft mass flux:

              pmfuxt(jl,jk,jt)=pxtp1c(jl,jk,jt)*pmfu(jl,jk)

              !--- Local tendency:

              zxtte_conv=-zdep/pdpg(jl,jk)

              !--- 3.2) Below cloud scavenging:

              IF(LLAEROSOL .AND. zclceff(jl,jk) > zmin) THEN

                 zdxtcol=pxtp10(jl,jk,jt)*zclceff(jl,jk)*zxtfrac_col(jl,jk)

                 zxtte_conv=zxtte_conv-zdxtcol/ztmst

                 zdepint(jl)=zdepint(jl)+zdxtcol/ztmst*pdpg(jl,jk)

              ENDIF

              !--- 3.3) Re-evaporation:

              zdxtevap=zdepint(jl)*zrevap(jl,jk)

              !--- Reduce integrated deposition mass flux:

              zdepint(jl)=zdepint(jl)-zdxtevap

              !--- Convective: change local tendency:

              zxtte_conv=zxtte_conv+zdxtevap/pdpg(jl,jk)


              !--- 4.4) Total tendency:

              pxtte(jl,jk,jt)=pxtte(jl,jk,jt)+zxtte_conv

           ENDDO
        ENDDO

        !--- 4.5) Diagnostics:

!        DO jl=1, kproma
!           wdep_p(jl,krow)=wdep_p(jl,krow)+zdepint(jl)*delta_time
!           wdep_conv_p(jl,krow)=wdep_conv_p(jl,krow)+zdepint(jl)*delta_time
!           wdepinst_p(jl,krow)=wdepinst_p(jl,krow)+zdepint(jl)
!        ENDDO

     ENDIF

     ENDIF nwetdep

  ENDDO tracer

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