      SUBROUTINE DUNUCL(GNUCL,H2SO4,SXP,ADU,CNH3N,CNH3CH,RKBN,RKBCH,RKTN, &
                        RKTCH,DUALFA,PRION,SCLNCL,ACND,DFSO4,TICGR1,TICGR2, &
                        TIDRYR,YSCALE,YM3TOCM3,YSDUNNE,PDIAM,PMASS,DT, &
                        ILGA,LEVA)
!-----------------------------------------------------------------------
!     PURPOSE:
!     --------
!     IT IS ASSUMED THAT SUFFICIENT AMMONIA
!     IS AVAILABLE TO FORM (NH4)2S04 PARTICLES ONCE THE PARTICLES
!     ARE PRODUCED BY NUCLEATION. ALTHOUGH THE PARTICLES INTIALLY
!     CONTAIN WATER THEY ARE INJECTED AS DRY PARTICLES AT THE LOWER
!     BOUNDARY OF THE SIZE SPECTRUM.
!
!     HISTORY:
!     --------
!     * DEC 11/200X - K.VONSALZEN   NEW.
!
!-----------------------------------------------------------------------
!
      USE SDPARM
      USE SDPHYS
      USE FPDEF
!
      IMPLICIT REAL (A-H,O-Z), INTEGER (I-N)
!
      REAL(R8), INTENT(OUT), DIMENSION(ILGA,LEVA) :: GNUCL,SXP
      REAL(R8), INTENT(IN), DIMENSION(ILGA,LEVA) :: H2SO4,ACND,DFSO4
      REAL(R8), INTENT(IN), DIMENSION(ILGA,LEVA) :: CNH3N,CNH3CH,RKBN, &
                                                    RKBCH,RKTN,RKTCH, &
                                                    DUALFA,PRION,SCLNCL
      REAL, INTENT(IN), DIMENSION(20) :: ADU
      REAL, DIMENSION(ILGA,LEVA,ISINTSO4) :: TICGR1,TICGR2
      REAL, DIMENSION(ISINTSO4+1) :: TIDRYR

      REAL, INTENT(IN) :: YSCALE,YM3TOCM3,YSDUNNE,PDIAM,PMASS,DT
      INTEGER, INTENT(IN) :: ILGA,LEVA
      REAL(R8), ALLOCATABLE, DIMENSION(:,:) :: H2SO4P,CONDS,GRWTHR, &
                                               ETA,ARG,CGR,CGASC,SCALEF, &
                                               ATERM,SABN,SABI,SATN,SATI, &
                                               SABIC,XD,CION,J1P7BNR, &
                                               J1P7BCHR,J1P7TNR,J1P7TCHR, &
                                               AKINLIM,J1P7R
      REAL, PARAMETER :: YDREF=1.7
      REAL, PARAMETER :: FTUNE=0.01
      LOGICAL, PARAMETER :: KERKU=.TRUE.
!
!-----------------------------------------------------------------------
!
!     * ALLOCATE WORK ARRAYS.
!
      ALLOCATE(H2SO4P  (ILGA,LEVA))
      ALLOCATE(SCALEF  (ILGA,LEVA))
      ALLOCATE(ATERM   (ILGA,LEVA))
      ALLOCATE(SABN    (ILGA,LEVA))
      ALLOCATE(SABI    (ILGA,LEVA))
      ALLOCATE(SATN    (ILGA,LEVA))
      ALLOCATE(SATI    (ILGA,LEVA))
      ALLOCATE(SABIC   (ILGA,LEVA))
      ALLOCATE(XD      (ILGA,LEVA))
      ALLOCATE(CION    (ILGA,LEVA))
      ALLOCATE(J1P7BNR (ILGA,LEVA))
      ALLOCATE(J1P7BCHR(ILGA,LEVA))
      ALLOCATE(J1P7TNR (ILGA,LEVA))
      ALLOCATE(J1P7TCHR(ILGA,LEVA))
      ALLOCATE(AKINLIM (ILGA,LEVA))
      ALLOCATE(J1P7R   (ILGA,LEVA))
      ALLOCATE(ARG   (ILGA,LEVA))
      IF ( KERKU ) THEN
        ALLOCATE(CONDS (ILGA,LEVA))
        ALLOCATE(GRWTHR(ILGA,LEVA))
        ALLOCATE(CGASC (ILGA,LEVA))
        ALLOCATE(CGR   (ILGA,LEVA))
        ALLOCATE(ETA   (ILGA,LEVA))
      ENDIF
!
!     * SCALE SULPHURIC ACID CONCENTRATION TO CONVERT FROM FMOL/M3
!     * TO 10E6*MOLECULES/CM3
!
      H2SO4P=H2SO4*(AVO/(YSCALE*YM3TOCM3))*YSDUNNE
!
!     * H2SO4-DEPENDENT TERMS IN PARAMETERIZATION. BN REFERS TO THE BINARY
!     * NEUTRAL RATE, BI TO THE BINARY ION-INDUCED RATE, TN THE TERNARY
!     * NEUTRAL RATE, AND TI THE TERNARY ION-INDUCED RATE.
!
      ARG=ADU(1)
      SABN=H2SO4P**ARG
      ARG=ADU(14)
      SABI=H2SO4P**ARG
      ARG=ADU(10)
      SATN=H2SO4P**ARG
      ARG=ADU(20)
      SATI=H2SO4P**ARG
      SABIC=RKBCH
!
!     * CONCENTRATION OF SMALL NEGATIVE IONS (1/CM3). LOSSES OF IONS DUE
!     * TO STICKING TO PARTICLES AND DEPLETION VIA ION-INDUCED NUCLEATION.
!     * CURRENTLY ASSUMES STEADY STATE ION BALANCE AND THAT ORGANIC-H2SO4
!     * NUCLEATION IS NEUTRAL.
!
      XD=ACND+SABI*SABIC+RKTCH*SATI
      ATERM=XD**2+4.*DUALFA*PRION
      ARG=SQRT(ATERM)
      ARG=(ARG-XD)/2.
      WHERE ( DUALFA > MAX(ARG/YLARGE,YTINY) )
        CION=ARG/DUALFA
      ELSEWHERE
        WHERE ( XD > MAX(PRION/YLARGE,YTINY) )
          CION=PRION/XD
        ELSEWHERE
          CION=PRION*DT
        ENDWHERE
      ENDWHERE
!
!     * NUCLEATION RATES FOR EACH PROCESS.
!
      J1P7BNR =RKBN*SABN
      J1P7BCHR=CION*SABI*SABIC
      J1P7TNR =RKTN*SATN
      J1P7TCHR=RKTCH*CION*SATI
!
!     * KINETIC LIMIT FOR TERNARY NEUTRAL NUCLEATION, WHICH CAN IN
!     * PRINCIPLE BE EXCEEDED AT VERY HIGH NH3 CONCENTRATIONS.
!
      WHERE ( H2SO4P > YTINY )
        AKINLIM=(49.19*H2SO4P**2.016)/(1.+3.126*H2SO4P**(-3.594))
      ELSEWHERE
        AKINLIM=0.
      ENDWHERE
      WHERE (J1P7TNR > AKINLIM)
        J1P7TNR=AKINLIM
      ENDWHERE
      WHERE (J1P7TCHR > AKINLIM)
        J1P7TCHR=AKINLIM
      ENDWHERE
!
!     * SUM OF ALL NUCLEATION RATES (PARTICLES/CM3/SEC).
!
      J1P7R=J1P7BNR+J1P7BCHR+J1P7TNR+J1P7TCHR
      ATERM=ADU(1)*J1P7BNR+ADU(14)*J1P7BCHR+ADU(10)*J1P7TNR+ &
            ADU(20)*J1P7TCHR
      SXP=ATERM/MAX(J1P7R,YTINY)
!
!     * H2SO4 DEPLETION RATE IN MOL/M3/SEC.
!
      GNUCL=-PMASS*J1P7R*YM3TOCM3/WAMSUL
      GNUCL=SCLNCL*GNUCL
!
!-----------------------------------------------------------------------
!     * PARAMETERIZATION TO CALCULATE NUCLEATION RATE AT SIZE OF THE
!     * SMALLEST PARTICLES IN THE SIMULATED SIZE DISTRIBUTION, FOR A
!     * PARAMETERIZED NUCLEATION RATE AT A PARTICLE DIAMETER OF YDREF
!     * (IN NANOMETRES).
!
      IF ( KERKU ) THEN
!
!       * CONDENSATION SINK (1/M2).
!
        CONDS=ACND/(4.*YPI*DFSO4)
!
!       * NUCLEI GROWTH RATE (NM/HOUR), FROM PRODUCT OF PARTICLE GROWTH
!       * FACTOR (M5/KG/SEC) AND CONDENSABLE GAS CONCENTRATION (H2SO4+2*NH3,
!       * KG/M3), DIVIDED BY PARTICLE RADIUS (M), AND FINAL UNIT SCALING.
!
        CGR=(TICGR1(:,:,1)+TICGR2(:,:,1)*TIDRYR(1))
        CGASC=H2SO4*WAMSUL/YSCALE
        GRWTHR=CGR/TIDRYR(1)*CGASC
        GRWTHR=GRWTHR*1.E+09*3600.
!
!       * ETA PARAMETER AND NUCLEATION RATE SCALING FACTOR ACCORDING TO
!       * KERMINEN AND KULMALA (2002).
!
        WHERE ( GRWTHR > MAX(0.23*CONDS/YLARGE,YTINY) )
          ETA=0.23*CONDS/GRWTHR
        ELSEWHERE
          ETA=1.
        ENDWHERE
        ARG=(1._R8/PDIAM - 1._R8/YDREF)*ETA
        ARG=MAX(-10.,MIN(ARG,10.))
        SCALEF=EXP(ARG)
      ELSE
        SCALEF=0.001
      ENDIF
      GNUCL=GNUCL*SCALEF
!
!     * SCALE H2SO4 DEPLETION RATE TO CONVERT FROM MOL/M3/SEC TO FMOL/M3/SEC.
!
      GNUCL=GNUCL*YSCALE*FTUNE
!
!     * DEALLOCATE WORK ARRAYS.
!
      DEALLOCATE(H2SO4P)
      DEALLOCATE(SCALEF)
      DEALLOCATE(ATERM)
      DEALLOCATE(SABN)
      DEALLOCATE(SABI)
      DEALLOCATE(SATN)
      DEALLOCATE(SATI)
      DEALLOCATE(SABIC)
      DEALLOCATE(XD)
      DEALLOCATE(CION)
      DEALLOCATE(J1P7BNR)
      DEALLOCATE(J1P7BCHR)
      DEALLOCATE(J1P7TNR)
      DEALLOCATE(J1P7TCHR)
      DEALLOCATE(AKINLIM)
      DEALLOCATE(J1P7R)
      DEALLOCATE(ARG)
      IF ( KERKU ) THEN
        DEALLOCATE(CONDS)
        DEALLOCATE(GRWTHR)
        DEALLOCATE(CGASC)
        DEALLOCATE(CGR)
        DEALLOCATE(ETA)
      ENDIF
!
      END SUBROUTINE DUNUCL
