SUBROUTINE m7_nucl_ku &
  &( KIDIA  , KFDIA , KLON   , KLEV, &  ! ECMWF dims
  &  pso4g  , ptp1  , prelhum      , & 
  &  pbnrate, palpha, pbeta          )

    
    !  Authors:
    !  --------
    !  P. Stier, MPI-Met, Hamburg,    from the original f77 code
    !                                 in the routine m7_nuck        2001-2003
    !  J. Wilson, E. Vignati, JRC/EI, original source                 09/2000

    !  JJMorcrette  20100115 Adaptation to ECMWF-IFS
    !
    !  Purpose:                                                           
    !  --------                                                           
    !  This routine calculates the instananeous nucleation rate            
    !  znucrate [molec. cm-3 s-1] from a given gas phase H2SO4 concentration      
    !  pso4g [molec. cm-3]. It also calculates the integrated change of 
    !  H2SO4 gas phase mass over one timestep due to nucleation 
    !  pa4delt(:,:,1) [molec. cm-3] as well as the number of nucleated 
    !  particles panew [1] during the timestep.
    !
    !  Interface:
    !  ----------
    !  *m7_nucl_ku* is called from *m7_nuck*
    !
    !  Method:
    !  -------
    !  Kulmala et al. (1998) 's formula for binary nucleation is 
    !  rewritten to take the form znucrate = exp[zalpha+ln(pso4g)*beta]. 
    !  Equation numbers are taken from Kulmala et al. (1998).
    !  After the calculation of the nucleation rate znucrate, it is 
    !  integrated in 2) analytically over one timestep, i.e.:
    !
    !  Integration of:
    ! 
    !  znucrate=d(critn*znav)/dt=exp[zalpha + zbeta*ln(znav)]
    !
    !  gives znav(t0+dt, znav(t0)) where znav(t0) is pso4g.
    !  znav is temporarily stored in zso4g_new and confined between
    !  0 and pso4g. 
    !  The number of nucleated particles is then calculated by 
    !  assuming a fixed critical mass critn of newly nucleated 
    !  particles and dividing the total mass of nucleated sulfate 
    !  by this critical mass of one nucleated particle. 
    !
    !  Externals:
    !  ----------
    !  None

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

USE YO_AERO_M7, ONLY: bk
USE YOMCST    , ONLY: RTT

    IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN) :: KIDIA, KFDIA, KLON, KLEV

REAL(KIND=JPRB),INTENT(IN)  :: pso4g(klon ,klev), ptp1(klon ,klev), prelhum(klon ,klev)       
	       
REAL(KIND=JPRB),INTENT(OUT) :: pbnrate(klon ,klev), palpha(klon ,klev), pbeta(klon ,klev)

INTEGER(KIND=JPIM) :: jl,          jk

REAL(KIND=JPRB) :: znwv,        zln_nac,      ztk,         zsupsat,  &
  &                zpeh2o,      zpeh2so4,     zra,         zxal,     &
  &                ztkn,        zssn,         zdelta

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

    !---1) Calculation of the nucleation rate: ----------------------------
    
    DO jk=1,klev
       DO jl=KIDIA,KFDIA

          IF (pso4g(jl,jk)  >  1.e-5_JPRB) THEN
             ztk=ptp1(jl,jk)
             zsupsat=prelhum(jl,jk)
             !
             !--- 1.1) Restrict t, and rh to limits where the parameterization ok:
             !
             ztkn = MAX(ztk, 220.0_JPRB)
             zssn = MIN(zsupsat, 0.90_JPRB)

             !
             !--- 1.2) Equlibrium vapour pressures (Jaeker-Mirabel (1995), JGR):
             !
             !--- H2O equlibrium vapour pressure (Tabata):
             !
             zpeh2o=0.750064_JPRB*(10._JPRB**(8.42926609_JPRB-1827.17843_JPRB/          &
               &    ztkn-71208.271_JPRB/ztkn/ztkn))*1333._JPRB/bk/ztkn
             !
             !--- H2SO4 equlibrium vapour pressure at 360 
             !@@@ Check source: which Ayers?
             !
             zpeh2so4=EXP(-10156._JPRB/ztkn+16.259_JPRB)*7.6e2_JPRB*1333._JPRB/bk/ztkn
             !
             !--- H2SO4 equlibrium vapour pressure - correction of ayers
             !    by kulmala - currently not used
             !
             !     payers=exp(-10156/360+16.259)*7.6e2
             !     zpeh2so4=exp(log(payers)+10156*(-1./ztkn+1./360.+0.38/(905-360) * &
             !              (1+log(360./ztkn)-360./ztkn)))*1333/bk/ztkn
             !
             !--- 1.3) Relative acidity (0.0 -1.0):
             ! 
             zra=pso4g(jl,jk)/zpeh2so4
             !
             !--- 1.4) Water vapour molecule concentration [cm-3]:
             !
             znwv=zsupsat*zpeh2o
             !
             !--- 1.5) Factor delta in Eq. 22:
             ! 
             zdelta=1.0_JPRB+(ztkn-RTT)/RTT
             !
             !--- 1.6) Molefraction of H2SO4 in the critical cluster 
             !         minus the H2SO4(g) term in Eq. 17:
             !
             zxal = 1.2233_JPRB-0.0154_JPRB*zra/(zra+zssn)-0.0415_JPRB*LOG(znwv)+ 0.0016_JPRB*ztkn 
             !
             !--- 1.7) Exponent of the critical cluster (Eq. 18):
             !
             zln_nac = -14.5125_JPRB+0.1335_JPRB*ztkn-10.5462_JPRB*zssn+1958.4_JPRB*zssn/ztkn
             !
             !--- 1.8) Sum of all terms in Eq. 20 containing H2SO4(g):
             !
             pbeta(jl,jk) = 25.1289_JPRB - 4890.8_JPRB/ztkn + 7643.4_JPRB*0.0102_JPRB/ztkn - &
               &            2.2479_JPRB*zdelta*zssn - 1.9712_JPRB*0.0102_JPRB*zdelta/zssn
             ! 
             !--- 1.9) Sum all terms in Eq. 20 not containing H2SO4(g):
             !
             palpha(jl,jk) = zln_nac*(-25.1289_JPRB + 4890.8_JPRB/ztkn + 2.2479_JPRB*zdelta*zssn) - &
               &             1743.3_JPRB/ztkn + zxal*(7643.4_JPRB/ztkn - 1.9712_JPRB*zdelta/zssn)
             !
             !--- 1.10) Nucleation rate [cm-3 s-1] (Kulmala et al., 1998):
             !
             pbnrate(jl,jk) = EXP(palpha(jl,jk)+LOG(pso4g(jl,jk))*pbeta(jl,jk))

          ELSE

             palpha(jl,jk) =0._JPRB 
             pbeta(jl,jk)  =0._JPRB
             pbnrate(jl,jk)=0._JPRB

          ENDIF ! pso4g(jl,jk) > 1.e-5
       ENDDO ! kproma
    ENDDO !klev

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