SUBROUTINE AER_STRVELO &
  &( KLAT   , KLEV  , &
  &  PT    , PFPATH , PR2SO4 , PDENSO4, PCONHS4, &
  &  PRNLOG, PRSTDEV, PRMODRA, &
  &  PVSHS4A )

!*** *AER_STRVELO* - MASS-WEIGHTED SEDIMENTATION VELOCITY

!**   INTERFACE.
!     ----------
!          *AER_STRVELO* IS CALLED FROM *AER_STRAERO*.

!     AUTHOR.
!     -------
!        FROM S.BEKKI's *velomod*
!        JJMorcrette  ECMWF 20080423 rewritten for IFS

! INPUTS
! ------ 
!   PT     : temperature (K)
!   PPMB   : pressure (mb)
!   PCONCM : total air density (also called concentration) (molec/cm3)
! All aerosol particles are assumed to have the same composition
!   PR2SO4 : aerosol H2SO4 weight fraction (percent)
!   PDENSO4: aerosol volumic mass (gr/cm3 = aerosol mass/aerosol volume) 
!   PRNLOG : total number of aerosol particles (VMR or concentration)
!   PRSTDEV: standard deviation of aerosol distribution (no unit)
!   PRMODRA: mode radius (cm)
!   PRRSI  : radius (cm)
!   KLAT   : number of latitude bands in the model domain
!   KLEV   : number of altitude bands in the model domain
!   for IFS: perhaps add another dimension for longitude

! OUTPUT
! ------
!   PVSHS4A: mass weighted sedimentation velocity (cm/sec) 
!------------------------------------------------------------------------------
 
USE PARKIND1  ,ONLY : JPRB , JPIM
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK

IMPLICIT NONE
   
!-----------------------------------------------------------------------

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

INTEGER(KIND=JPIM),INTENT(IN) :: KLAT,KLEV

REAL(KIND=JPRB),INTENT(IN) :: PT(KLAT,KLEV)     , PFPATH(KLAT,KLEV)
REAL(KIND=JPRB),INTENT(IN) :: PR2SO4 (KLAT,KLEV), PDENSO4(KLAT,KLEV)
REAL(KIND=JPRB),INTENT(IN) :: PCONHS4(KLAT,KLEV), PRNLOG(KLAT,KLEV)
REAL(KIND=JPRB),INTENT(IN) :: PRSTDEV(KLAT,KLEV), PRMODRA(KLAT,KLEV)

REAL(KIND=JPRB),INTENT(OUT) :: PVSHS4A(KLAT,KLEV)

!*       0.5   LOCAL VARIABLES
!              ---------------

INTEGER(KIND=JPIM) :: JI,JK
 
REAL(KIND=JPRB) :: ZGCM, ZTIJ, ZDENS, ZVMS, ZFAC, ZPI, ZRMH2S4
REAL(KIND=JPRB) :: ZRO, ZA, ZB, ZC, ZSR, ZSR2, ZX, ZCXR, ZBP, ZF4, ZF5, ZF6, ZF7, ZFF, ZVOL

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

ZRMH2S4=98.082_JPRB*1.66E-24_JPRB
ZGCM=981.0_JPRB
ZPI=4.0_JPRB*ATAN(1.0_JPRB)
  
DO JI=1,KLAT
  DO JK=2,KLEV
    ZRO=PRMODRA(JI,JK)
    ZDENS =(PDENSO4(JI,JK)+PDENSO4(JI,JK-1))*0.5_JPRB
    ZTIJ=(PT(JI,JK)+PT(JI,JK-1))*0.5_JPRB

!  DYN VISCOSITY OF AIR IN GR/(CM*SEC)
!  VMS =-0.2032634E-10*(TIJ-273.17)*(TIJ-273.17)+
!        0.46893669E-6*(TIJ-273.17)+0.17193993E-3
    ZVMS =( 1.718_JPRB +0.0049_JPRB*(ZTIJ-273.17_JPRB) &
      &    -1.2E-5_JPRB*(ZTIJ-273.17_JPRB)*(ZTIJ-273.17_JPRB) )*1.E-4_JPRB

!  sedimentaion velocity without R-dependent factors
    ZFAC=2.0_JPRB*ZDENS*ZGCM/(9.0_JPRB*ZVMS)
 
!        for sedimentation flux of H2SO4 (VMR.cm.sec-1)
!!       also for mass-weighted average sed velocity (full calc.)
!!        ZFAC=ZFAC*PRNLOG(JI,JK)*(4._JPRB*ZPI/3._JPRB)
!!        ZFAC=ZFAC*PR2SO4(I,J)*0.01_JPRB*PDENSO4(JI,JK)/ZRMH2S4
!!        ZFAC=ZFAC*ZRO*ZRO*ZRO

!       for mass-weighted average sedimentation velocity
!        ZFAC=ZFAC  ???!!!!!!!
 
!  correction factor (based on Knudsen number)
    ZA=1.246_JPRB* PFPATH(JI,JK)
    ZB=0.42_JPRB * PFPATH(JI,JK)
    ZC=0.87_JPRB / PFPATH(JI,JK)

!    IF(PRSTDEV(JI,JK).GT.1.0000001_JPRB) THEN 
!       need to find my notes that explains this choice of X !!!!!?????
    ZSR= LOG(PRSTDEV(JI,JK))
    ZSR2=ZSR*ZSR
!  fourth order moment (see limited development)
    ZX=EXP(4.0_JPRB*ZSR2)

    ZCXR=ZC*ZX*ZRO
    ZBP=ZB*EXP(-ZCXR)

    ZF4 = ZA 
    ZF4 = ZF4 + ZBP + ZBP*ZCXR + 0.5_JPRB*ZBP*ZCXR*ZCXR &
      &    + (1._JPRB/6._JPRB)*ZBP*ZCXR*ZCXR*ZCXR
    ZF5 = 1._JPRB 
    ZF5= ZF5 - ZBP*ZC - ZBP*ZC*ZCXR - 0.5_JPRB*ZBP*ZC*ZCXR*ZCXR 
    ZF6= 0.5_JPRB*ZBP*ZC*ZC + 0.5_JPRB*ZBP*ZC*ZC*ZCXR
    ZF7=  -(1._JPRB/6._JPRB)*ZBP*ZC*ZC*ZC
 
    ZFF = ZF4*EXP(0.5_JPRB*4._JPRB*4._JPRB*ZSR2) + ZF5*ZRO*EXP(0.5_JPRB*5._JPRB*5._JPRB*ZSR2) &
      & + ZF6*ZRO*ZRO*EXP(0.5_JPRB*6._JPRB*6._JPRB*ZSR2) &
      & + ZF7*ZRO*ZRO*ZRO*EXP(0.5_JPRB*7._JPRB*7._JPRB*ZSR2)

!  SEDIMENTATION FLUX IN H2SO4(VMR).CM.SEC-1
!   if for mass-weighted average sed velocity (full calc.)
!   but here calculation (FAC) is simplified 
    PVSHS4A(JI,JK)=-ZFF*ZRO*ZFAC

!       aerosol volume (cm3 of aerosol/cm3 of air 
!          x nb of H2SO4 per cm3 of aerosol
!!       for mass-weighted average sed velocity (full calc.)
!!        ZVOL=PRNLOG(JI,JK)*(4._JPRB*ZPI/3._JPRB)
!!        ZVOL=ZVOL*PR2SO4(JI,JK)*0.01_JPRB*PDENSO4(JI,JK)/ZRMH2S4
!!        ZVOL=ZVOL**ZRO*ZRO*ZRO*EXP(0.5_JPRB*3._JPRB*3._JPRB*ZSR2)

!       for mass-weighted average sedimentation velocity 
!       because calculation (ZFAC) is simplified 
    ZVOL=EXP(0.5_JPRB*3._JPRB*3._JPRB*ZSR2)
 
!       for mass-weighted average sedimentation velocity
!conhs4 added for converting velocity on H2SO4condensed 
!       to velocity on H2SO4total
    PVSHS4A(JI,JK)=PVSHS4A(JI,JK)*PCONHS4(JI,JK)/ZVOL
 
  ENDDO
ENDDO
 
!-----------------------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('AER_STRVELO',1,ZHOOK_HANDLE)
END SUBROUTINE AER_STRVELO
