      SUBROUTINE GTPCNV (DGDT,PEDNDT,PEDMDT,PIDNDT,PIDMDT,PIDFDT, &
                         PEDDN,PEMAS,PEN0,PENUM,PEPHI0,PEPSI,PEWETRC, &
                         PIFRC,PIDDN,PIMAS,PIN0,PINUM,PIPHI0,PIPSI, &
                         PIWETRC,T,RH,RHOA,H2SO4I,CNH3,SGPR,ZCLF,PBLTS, &
                         DT,ILGA,LEVA,DERSN,DERSM,DIRSN,DIRSMN,DIRSMS, &
                         DENNCL,DECNCL,DINNCL,DICNCL,DECND,DICND,IERR)
!-----------------------------------------------------------------------
!     PURPOSE:
!     --------
!     GAS-TO-PARTICLE CONVERSTION FOR AMMONIUM-SULPHATE AEROSOL.
!
!     NOTE: IT IS CRITICAL THAT THE DRY PARTICLE DENSITIES (PEDDN,
!     PIDDN) AND MASS FRACTIONS FOR INTERNALLY MIXED AEROSOL (PIFRC)
!     ARE CONSISTENT WITH THE AEROSOL MASS (PEMAS, PIMAS) AND NUMBER
!     (PENUM, PINUM) CONCENTRATIONS. MAKE SURE THESE ARE CALCULATED
!     BEFORE THIS SUBROUTINE.
!
!     HISTORY:
!     --------
!     * DEC  6/2017 - K.VONSALZEN   ADDITION OF DUNNE NUCLEATION 
!                                   PARAMETERIZATION, CORRECTION
!                                   OF GROWTH TERM CALCULATION,
!                                   BUGFIX EFFECTIVE CONCENTRATION
!                                   IN NUCLEATION TERM
!     * APR 17/2015 - K.VONSALZEN   CHANGES TO SUPPORT SINGLE PRECISION
!     * FEB 19/2010 - K.VONSALZEN   CORRECT PIDFDT
!     * JUL 07/2008 - K.VONSALZEN   ALLOW TABULATED NUCLEATION
!                                   COEFFICIENTS FOR LINEAR REPRESENTATION
!                                   OF NUCLEATION RATE AS OPTION (DEFAULT).
!     * FEB 20/2007 - K.VONSALZEN   MODIFIED FOR NEW GENERALIZED
!                                   TREATMENT OF AEROSOLS.
!     * DEC 11/2005 - K.VONSALZEN   NEW.
!
!     ************************ INDEX OF VARIABLES **********************
!
!     PRIMARY INPUT/OUTPUT VARIABLES (ARGUMENT LIST):
!
! I   CNH3     GAS-PHASE AMMONIA (NH3) VOLUME MIXING RATIO
! O   DGDT     GAS-PHASE SULPHURIC ACID (H2SO4) TENDENCY (KG/KG/SEC)
! O   DECNCL   (NH4)2SO4 MASS NUCLEATION RATE (KG/KG/SEC), EXT. MIXTURE
! O   DECND    (NH4)2SO4 CONDENSATION RATE (KG/KG/SEC), EXT. MIXTURE
! O   DENNCL   (NH4)2SO4 NUMBER NUCLEATION RATE (1/KG/SEC), EXT. MIXTURE
! O   DERSM    MASS RESIDUUM FROM NUMERICAL TRUNCATION IN GROWTH
!              CALCULATIONS (KG/KG), EXT. MIXTURE
! O   DERSN    NUMBER RESIDUUM FROM NUMERICAL TRUNCATION IN GROWTH
!              CALCULATIONS (KG/KG), EXT. MIXTURE
! O   DICNCL   (NH4)2SO4 MASS NUCLEATION RATE (KG/KG/SEC), INT. MIXTURE
! O   DICND    (NH4)2SO4 CONDENSATION RATE (KG/KG/SEC), INT. MIXTURE
! O   DINNCL   (NH4)2SO4 NUMBER NUCLEATION RATE (1/KG/SEC), INT. MIXTURE
! O   DIRSMN   MASS RESIDUUM FOR NON-(NH4)2SO4 AEROSOL SPECIES FROM NUM.
!              TRUNCATION IN GROWTH CALCULATIONS (KG/KG), INT. MIXTURE
! O   DIRSMS   MASS RESIDUUM FOR (NH4)2SO4 AEROSOL FROM NUM. TRUNCATION
!              IN GROWTH CALCULATIONS (KG/KG), INT. MIXTURE
! O   DIRSN    NUMBER RESIDUUM FROM NUMERICAL TRUNCATION IN GROWTH
!              CALCULATIONS (KG/KG), INT. MIXTURE
! I   DT       TIME STEP (SEC)
! I   H2SO4I   INITIAL H2SO4 MIXING RATIO (KG/KG)
! O   IERR     WARNING CODE INDEX
! I   ILGA     NUMBER OF GRID POINTS IN HORIZONTAL DIRECTION
! I   LEVA     NUMBER OF GRID POINTA IN VERTICAL DIRECTION
! I   PBLTS    OFFSET INDEX FOR VERTICAL AXIS, INDICATING TOPMOST POINT
!              IN BOUNDARY LAYER
! I   PEDDN    DENSITY OF DRY AEROSOL PARTICLE (KG/M3), EXT. MIXTURE
! O   PEDMDT   MASS TENDENCY (KG/KG/SEC), EXT. MIXTURE
! O   PEDNDT   NUMBER TENDENCY (1/KG/SEC), EXT. MIXTURE
! I   PEMAS    AEROSOL MASS CONCENTRATION (KG/KG), EXT. MIXTURE
! I   PEN0     1ST PLA SIZE DISTRIBUTION PARAMETER (AMPLITUDE), EXT.
!              MIXTURE
! I   PENUM    AEROSOL NUMBER CONCENTRATION (1/KG), EXT. MIXTURE
! I   PEPHI0   3RD PLA SIZE DISTRIBUTION PARAMETER (MODE SIZE), EXT.
!              MIXTURE
! I   PEPSI    2ND PLA SIZE DISTRIBUTION PARAMETER (WIDTH), EXT. MIXTURE
! I   PEWETRC  TOTAL/WET PARICLE RADIUS (M), EXT. MIXTURE
! I   PIDDN    DENSITY OF DRY AEROSOL PARTICLE (KG/M3), INT. MIXTURE
! O   PIDFDT   AEROSOL SPECIES MASS FRACTION TENDENCY (1/SEC), INT.
!              MIXTURE
! O   PIDMDT   MASS TENDENCY (KG/KG/SEC), INT. MIXTURE
! O   PIDNDT   NUMBER TENDENCY (1/KG/SEC), INT. MIXTURE
! I   PIFRC    AEROSOL SPECIES MASS FRACTION
! I   PIMAS    AEROSOL MASS CONCENTRATION (KG/KG), INT. MIXTURE
! I   PIN0     1ST PLA SIZE DISTRIBUTION PARAMETER (AMPLITUDE), INT.
!              MIXTURE
! I   PINUM    AEROSOL NUMBER CONCENTRATION (1/KG), INT. MIXTURE
! I   PIPHI0   3RD PLA SIZE DISTRIBUTION PARAMETER (MODE SIZE), INT.
!              MIXTURE
! I   PIPSI    2ND PLA SIZE DISTRIBUTION PARAMETER (WIDTH), INT. MIXTURE
! I   PIWETRC  TOTAL/WET PARICLE RADIUS (M), INT. MIXTURE
! I   RH       RELATIVE HUMIDITY (DIMENSIONLESS)
! I   RHOA     AIR DENSITY (KG/M3)
! I   SGPR     GAS-PHASE PRODUCTION RATE OF H2SO4 (KG/KG/SEC)
! I   T        AIR TEMPERATURE (K)
!
!     SECONDARY INPUT/OUTPUT VARIABLES (VIA MODULES AND COMMON BLOCKS):
!
! I   AEXTF%TP(:)%DRYRC(:)
!              DRY PARTICLE RADIUS IN SECTION CENTRE (M), EXT. MIXTURE
! I   AEXTF%TP(:)%DRYR(:)%VL
!              LOWER DRY PARTICLE RADIUS FOR EACH SECTION (M), EXT.
!              MIXTURE
! I   AEXTF%TP(:)%DRYR(:)%VR
!              UPPER DRY PARTICLE RADIUS FOR EACH SECTION (M), EXT.
!              MIXTURE
! I   AINTF%DRYRC(:)
!              DRY PARTICLE RADIUS IN SECTION CENTRE (M), INT. MIXTURE
! I   AINTF%DRYR(:)%VL
!              LOWER DRY PARTICLE RADIUS FOR EACH SECTION (M), INT.
!              MIXTURE
! I   AINTF%DRYR(:)%VR
!              UPPER DRY PARTICLE RADIUS FOR EACH SECTION (M), INT.
!              MIXTURE
! I   IEXSO4   AEROSOL TRACER INDEX FOR SULPHATE, EXT. MIXTURE
! I   IINSO4   AEROSOL TRACER INDEX FOR SULPHATE, INT. MIXTURE
! I   ISAEXT   NUMBER OF AEROSOL TRACERS, EXT. MIXTURE
! I   ISAINT   NUMBER OF AEROSOL TRACERS, INT. MIXTURE
! I   ISEXTSO4 NUMBER OF SECTIONS FOR (NH4)2SO4 AEROSOL, EXT. MIXTURE
! I   ISINTSO4 NUMBER OF SECTIONS FOR (NH4)2SO4 AEROSOL, INT. MIXTURE
! I   ISO4S    NUMBER OF NON-(NH4)2SO4 AEROSOL SPECIES, INT. MIXTURE
! I   KEXTSO4  SPECIES INDEX FOR (NH4)2SO4 AEROSOL, EXT. MIXTURE
! I   KINT     NUMBER OF INTERNALLY MIXED AEROSOL TYPES, INT. MIXTURE
! I   KINTSO4  SPECIES INDEX FOR (NH4)2SO4 AEROSOL, INT. MIXTURE
! I   PEDPHIS  SECTION WIDTH, EXT. MIXTURE
! I   PEPHISS  LOWER DRY PARTICLE SIZE (=LOG(R/R0)), EXT. MIXTURE
! I   PIDPHIS  SECTION WIDTH, INT. MIXTURE
! I   PIPHISS  LOWER DRY PARTICLE SIZE (=LOG(R/R0)), INT. MIXTURE
! I   WH2SO4   MOLECULAR WEIGHT OF H2SO4 (KG/MOL)
! I   WNH3     MOLECULAR WEIGHT OF NH4 (KG/MOL)
! I   YLARGE   LARGE NUMBER
! I   YSEC     SECURITY PARAMETER FOR ADJUSTMENT OF TIMESTEP
! I   YSMALL   SMALL NUMBER
! I   YTINY    SMALLEST VALID NUMBER
!
!-----------------------------------------------------------------------
!
      USE SDPARM
      USE FPDEF
!
      IMPLICIT REAL (A-H,O-Z), INTEGER (I-N)
!
      REAL, INTENT(OUT), DIMENSION(ILGA,LEVA) :: DGDT
      REAL, INTENT(OUT), DIMENSION(ILGA,LEVA,ISAEXT) :: PEDNDT,PEDMDT
      REAL, INTENT(OUT), DIMENSION(ILGA,LEVA,ISAINT) :: PIDNDT,PIDMDT
      REAL, INTENT(OUT), DIMENSION(ILGA,LEVA,ISAINT,KINT) :: PIDFDT
      REAL, INTENT(OUT), DIMENSION(ILGA,LEVA) :: DENNCL,DECNCL, &
                                                 DERSN,DERSM ,DECND
      REAL, INTENT(OUT), DIMENSION(ILGA,LEVA) :: DINNCL,DICNCL,DIRSMN, &
                                                 DIRSN,DIRSMS,DICND
      INTEGER, INTENT(IN), DIMENSION(ILGA) :: PBLTS
      REAL, INTENT(IN), DIMENSION(ILGA,LEVA) :: SGPR,T,RH,RHOA,H2SO4I, &
                                                CNH3,ZCLF
!
      REAL, INTENT(IN), DIMENSION(ILGA,LEVA,ISAEXT) :: &
                            PEDDN,PEMAS,PEN0,PENUM,PEPHI0,PEPSI,PEWETRC
      REAL, INTENT(IN), DIMENSION(ILGA,LEVA,ISAINT) :: &
                            PIDDN,PIMAS,PIN0,PINUM,PIPHI0,PIPSI,PIWETRC
      REAL, INTENT(IN), DIMENSION(ILGA,LEVA,ISAINT,KINT) :: PIFRC
      INTEGER, INTENT(OUT) :: IERR
      INTEGER, INTENT(IN) :: ILGA,LEVA
      INTEGER, PARAMETER :: IDA=40,IDAM=IDA-1
      REAL, DIMENSION(ILGA,LEVA,IDAM) :: ACOEF,BCOEF
      REAL, DIMENSION(IDA) :: CH2SO4,EPSC
      REAL, ALLOCATABLE, DIMENSION(:,:,:) :: CH2SO4F,EPSCF
      REAL, ALLOCATABLE, DIMENSION(:,:,:,:) :: TIMN,TIFRCN
      REAL(R8), ALLOCATABLE, DIMENSION(:,:,:) :: TECNDGP,TECT1,TECT2
      REAL, ALLOCATABLE, DIMENSION(:,:,:) :: &
                                    TEWETRC,TEDDN, &
                                    TECGR1,TECGR2,TEN0,TEPHI0, &
                                    TEPSI,TEDPHIT,TEPHIST, &
                                    TECORF,TEDCCND,TEDXCND,TENT, &
                                    TEFRC,TEDRYRT
      REAL(R8), ALLOCATABLE, DIMENSION(:,:,:) :: &
                                    TEDP0L,TEDP1L,TEDP2L,TEDP3L, &
                                    TEDP4L,TEDP5L,TEDP6L,TEDM1L, &
                                    TEDM2L,TEDM3L,TEDP0R,TEDP1R, &
                                    TEDP2R,TEDP3R,TEDP4R,TEDP5R, &
                                    TEDP6R,TEDM1R,TEDM2R,TEDM3R, &
                                    TEDP0S,TEDP1S,TEDP2S,TEDP3S, &
                                    TEDP4S,TEDP5S,TEDP6S,TEDM1S, &
                                    TEDM2S,TEDM3S
      REAL(R8), ALLOCATABLE, DIMENSION(:,:,:) :: TICNDGP,TICT1,TICT2
      REAL, ALLOCATABLE, DIMENSION(:,:,:) :: &
                                    TIWETRC,TIDDN, &
                                    TICGR1,TICGR2,TIN0,TIPHI0, &
                                    TIPSI,TIDPHIT,TIPHIST, &
                                    TICORF,TIDCCND,TIDXCND,TINT, &
                                    TIFRCS,TIDRYRT
      REAL(R8), ALLOCATABLE, DIMENSION(:,:,:) :: &
                                    TIDP0L,TIDP1L,TIDP2L,TIDP3L, &
                                    TIDP4L,TIDP5L,TIDP6L,TIDM1L, &
                                    TIDM2L,TIDM3L,TIDP0R,TIDP1R, &
                                    TIDP2R,TIDP3R,TIDP4R,TIDP5R, &
                                    TIDP6R,TIDM1R,TIDM2R,TIDM3R, &
                                    TIDP0S,TIDP1S,TIDP2S,TIDP3S, &
                                    TIDP4S,TIDP5S,TIDP6S,TIDM1S, &
                                    TIDM2S,TIDM3S
      REAL(R8), ALLOCATABLE, DIMENSION(:,:,:) :: &
                                    TEMT,TIMST
      REAL(R8), ALLOCATABLE, DIMENSION(:,:,:,:) :: TIMNT
      REAL, ALLOCATABLE, DIMENSION(:,:,:) :: &
                                    TEN,TEM,TIN,TIM,TIMT,TIMS
      REAL, ALLOCATABLE, DIMENSION(:,:,:) :: TIRSMN,TITM1,TITM2
      REAL(R8), ALLOCATABLE, DIMENSION(:,:) :: ANUCL,SXP,DFSO4,DBL1, &
                                    DBL2,DBL3,GNUCLA,GNUCLB,GNUCLC, &
                                    GNUCLL,GNUCLH,SXPT,AFUNA,AFUNB, &
                                    AFUNC
      REAL, ALLOCATABLE, DIMENSION(:,:) :: BNUCL,PLFN,CNDM,TERMS, &
                                    CNDMX,EFFC,FRP,PLAM,PERTC, &
                                    CORFA,CORFAR,DTC
      REAL(R8), ALLOCATABLE, DIMENSION(:,:) :: &
                                    ACND,TERMX,TERMY,TERM1,TERM2, &
                                    TERM3,TERM4,TERM5,SGPRT,H2SO4T, &
                                    EXPT,SADT,CTMPX,CTMPY,CTMPMX, &
                                    CTMP,FMULF,YSCALF,H2SO4A,H2SO4B, &
                                    H2SO4C,H2SO4L,H2SO4H,CNH3N,CNH3CH, &
                                    RKBN,RKBCH,RKTN,RKTCH,DUALFA,PRION, &
                                    SCLNCL
      REAL, ALLOCATABLE, DIMENSION(:,:) :: &
                                    TECORFA,TEXNCL
      REAL, ALLOCATABLE, DIMENSION(:,:) :: &
                                    TICORFA,TIXNCL
      REAL, ALLOCATABLE, DIMENSION(:) :: &
                                    TECORFS,TEDRYR,TEDRYRC
      REAL, ALLOCATABLE, DIMENSION(:) :: &
                                    TICORFS,TIDRYR,TIDRYRC
      INTEGER, ALLOCATABLE, DIMENSION(:,:,:) :: TEI0L,TEI0R
      INTEGER, ALLOCATABLE, DIMENSION(:,:,:) :: TII0L,TII0R
      REAL(R8) :: CCOEF,CCOEFB,CTMPXA,CTMPXB
      REAL :: YM3TOCM3,YSDUNNE
      REAL, DIMENSION(20) :: ADU
      INTEGER :: ITER
!
!     * NUMERICAL CONSTANTS.
!
      REAL, PARAMETER :: YWG=1.        ! WEIGHTING FOR INITIAL H2SO4
      REAL, PARAMETER :: YEPS=0.1      ! THRESHOLD FOR CONVERGENCE TEST
      REAL, PARAMETER :: YRED=0.       ! STEP SIZE FOR NUCLEATION CALLS 
      INTEGER, PARAMETER :: ITERN=5    ! NUMBER OF ITERATIONS FOR
                                       ! H2SO4 BUDGET BALANCE
      INTEGER, PARAMETER :: IMODC=1
      INTEGER, PARAMETER :: IMETH=3
      LOGICAL, PARAMETER :: KBLNCL=.FALSE.
!
!-----------------------------------------------------------------------
!
      YSCALE=1.E+15 ! FACTOR FOR CONVERSION MOL->FMOL
      IERR=0
      IF ( IMETH == 3 ) THEN
        ITER=1
      ELSE
        ITER=5
      ENDIF
!
!     * WEIGHTING FOR NUCLEATION OF EXTERNALLY VS. INTERNALLY MIXED
!     * AEROSOL TYPE.
!
      IF ( KEXTSO4 > 0 .AND. KINTSO4 > 0 ) THEN
        WEIGHT=.5
      ELSE IF ( KEXTSO4 > 0 ) THEN
        WEIGHT=1.
      ELSE
        WEIGHT=0.
      ENDIF
!
!     * ALLOCATE MEMORY FOR LOCAL FIELDS.
!
      IF ( ISEXTSO4 > 0 ) THEN
        ALLOCATE(TEWETRC(ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEN    (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TENT   (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEM    (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEMT   (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDDN  (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEN0   (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEPHI0 (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEPSI  (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TECT1  (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TECT2  (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TECGR1 (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TECGR2 (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TECNDGP(ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDCCND(ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDXCND(ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDPHIT(ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEPHIST(ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TECORF (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEI0L  (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEI0R  (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP0L (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP1L (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP2L (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP3L (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP4L (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP5L (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP6L (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDM1L (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDM2L (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDM3L (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP0R (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP1R (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP2R (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP3R (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP4R (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP5R (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP6R (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDM1R (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDM2R (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDM3R (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP0S (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP1S (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP2S (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP3S (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP4S (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP5S (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDP6S (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDM1S (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDM2S (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDM3S (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEFRC  (ILGA,LEVA,ISEXTSO4))
        ALLOCATE(TEDRYRT(ILGA,LEVA,ISEXTSO4+1))
        ALLOCATE(TECORFS(ISEXTSO4))
        ALLOCATE(TEDRYR (ISEXTSO4+1))
        ALLOCATE(TEDRYRC(ISEXTSO4))
      ENDIF
      IF ( ISINTSO4 > 0 ) THEN
        ALLOCATE(TIMN   (ILGA,LEVA,ISINTSO4,ISO4S))
        ALLOCATE(TIMNT  (ILGA,LEVA,ISINTSO4,ISO4S))
        ALLOCATE(TIFRCN (ILGA,LEVA,ISINTSO4,ISO4S))
        ALLOCATE(TIMS   (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIMST  (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIWETRC(ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIN    (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TINT   (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIM    (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIMT   (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDDN  (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIN0   (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIPHI0 (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIPSI  (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TICT1  (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TICT2  (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TICGR1 (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TICGR2 (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TICNDGP(ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDCCND(ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDXCND(ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDPHIT(ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIPHIST(ILGA,LEVA,ISINTSO4))
        ALLOCATE(TICORF (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TII0L  (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TII0R  (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP0L (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP1L (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP2L (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP3L (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP4L (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP5L (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP6L (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDM1L (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDM2L (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDM3L (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP0R (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP1R (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP2R (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP3R (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP4R (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP5R (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP6R (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDM1R (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDM2R (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDM3R (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP0S (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP1S (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP2S (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP3S (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP4S (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP5S (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDP6S (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDM1S (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDM2S (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDM3S (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIFRCS (ILGA,LEVA,ISINTSO4))
        ALLOCATE(TIDRYRT(ILGA,LEVA,ISINTSO4+1))
        ALLOCATE(TIRSMN (ILGA,LEVA,ISO4S))
        ALLOCATE(TITM1  (ILGA,LEVA,ISO4S))
        ALLOCATE(TITM2  (ILGA,LEVA,ISO4S))
        ALLOCATE(TICORFS(ISINTSO4))
        ALLOCATE(TIDRYR (ISINTSO4+1))
        ALLOCATE(TIDRYRC(ISINTSO4))
      ENDIF
      ALLOCATE(TECORFA(ILGA,LEVA))
      ALLOCATE(TICORFA(ILGA,LEVA))
      ALLOCATE(TEXNCL (ILGA,LEVA))
      ALLOCATE(TIXNCL (ILGA,LEVA))
      ALLOCATE(GNUCLA (ILGA,LEVA))
      ALLOCATE(GNUCLB (ILGA,LEVA))
      ALLOCATE(GNUCLC (ILGA,LEVA))
      ALLOCATE(GNUCLL (ILGA,LEVA))
      ALLOCATE(GNUCLH (ILGA,LEVA))
      ALLOCATE(AFUNA  (ILGA,LEVA))
      ALLOCATE(AFUNB  (ILGA,LEVA))
      ALLOCATE(AFUNC  (ILGA,LEVA))
      ALLOCATE(ANUCL  (ILGA,LEVA))
      ALLOCATE(BNUCL  (ILGA,LEVA))
      ALLOCATE(SXP    (ILGA,LEVA))
      ALLOCATE(SXPT   (ILGA,LEVA))
      ALLOCATE(CTMP   (ILGA,LEVA))
      ALLOCATE(ACND   (ILGA,LEVA))
      ALLOCATE(PLFN   (ILGA,LEVA))
      ALLOCATE(CNDM   (ILGA,LEVA))
      ALLOCATE(CNDMX  (ILGA,LEVA))
      ALLOCATE(EFFC   (ILGA,LEVA))
      ALLOCATE(TERMX  (ILGA,LEVA))
      ALLOCATE(TERMY  (ILGA,LEVA))
      ALLOCATE(TERMS  (ILGA,LEVA))
      ALLOCATE(TERM1  (ILGA,LEVA))
      ALLOCATE(TERM2  (ILGA,LEVA))
      ALLOCATE(TERM3  (ILGA,LEVA))
      ALLOCATE(TERM4  (ILGA,LEVA))
      ALLOCATE(TERM5  (ILGA,LEVA))
      ALLOCATE(SGPRT  (ILGA,LEVA))
      ALLOCATE(H2SO4T (ILGA,LEVA))
      ALLOCATE(H2SO4A (ILGA,LEVA))
      ALLOCATE(H2SO4B (ILGA,LEVA))
      ALLOCATE(H2SO4C (ILGA,LEVA))
      ALLOCATE(H2SO4L (ILGA,LEVA))
      ALLOCATE(H2SO4H (ILGA,LEVA))
      ALLOCATE(DFSO4  (ILGA,LEVA))
      ALLOCATE(FRP    (ILGA,LEVA))
      ALLOCATE(PLAM   (ILGA,LEVA))
      ALLOCATE(PERTC  (ILGA,LEVA))
      ALLOCATE(CORFA  (ILGA,LEVA))
      ALLOCATE(CORFAR (ILGA,LEVA))
      ALLOCATE(DTC    (ILGA,LEVA))
      ALLOCATE(EXPT   (ILGA,LEVA))
      ALLOCATE(SADT   (ILGA,LEVA))
      ALLOCATE(CTMPX  (ILGA,LEVA))
      ALLOCATE(CTMPY  (ILGA,LEVA))
      ALLOCATE(CTMPMX (ILGA,LEVA))
      ALLOCATE(FMULF  (ILGA,LEVA))
!      ALLOCATE(YSCALF (ILGA,LEVA))
      ALLOCATE(CH2SO4F(ILGA,LEVA,IDA))
      ALLOCATE(EPSCF  (ILGA,LEVA,IDA))
      ALLOCATE(DBL1   (ILGA,LEVA))
      ALLOCATE(DBL2   (ILGA,LEVA))
      ALLOCATE(DBL3   (ILGA,LEVA))
      ALLOCATE(CNH3N  (ILGA,LEVA))
      ALLOCATE(CNH3CH (ILGA,LEVA))
      ALLOCATE(RKBN   (ILGA,LEVA))
      ALLOCATE(RKBCH  (ILGA,LEVA))
      ALLOCATE(RKTN   (ILGA,LEVA))
      ALLOCATE(RKTCH  (ILGA,LEVA))
      ALLOCATE(DUALFA (ILGA,LEVA))
      ALLOCATE(PRION  (ILGA,LEVA))
      ALLOCATE(SCLNCL (ILGA,LEVA))
!
!     * INITIALIZATION.
!
      IF ( ISAEXT > 0 ) THEN
        PEDNDT=0.
        PEDMDT=0.
      ENDIF
      IF ( ISAINT > 0 ) THEN
        PIDNDT=0.
        PIDMDT=0.
        PIDFDT=0.
      ENDIF
!
!     * TEMPORARY AEROSOL FIELDS FOR SULPHATE AEROSOL FOR DRY
!     * AND WET PARTICLE SIZES FOR EXTERNALLY MIXED AEROSOL TYPE.
!
      IF ( KEXTSO4 > 0 ) THEN
        DO IS=1,ISEXTSO4
          TEWETRC(:,:,IS)=PEWETRC(:,:,IEXSO4(IS))
          TEN    (:,:,IS)=PENUM  (:,:,IEXSO4(IS))
          TEM    (:,:,IS)=PEMAS  (:,:,IEXSO4(IS))
          TEDDN  (:,:,IS)=PEDDN  (:,:,IEXSO4(IS))
          TEN0   (:,:,IS)=PEN0   (:,:,IEXSO4(IS))
          TEPHI0 (:,:,IS)=PEPHI0 (:,:,IEXSO4(IS))
          TEPSI  (:,:,IS)=PEPSI  (:,:,IEXSO4(IS))
          TEDPHIT(:,:,IS)=PEDPHIS(IEXSO4(IS))
          TEPHIST(:,:,IS)=PEPHISS(IEXSO4(IS))
          TEDRYRC(IS)=AEXTF%TP(KEXTSO4)%DRYRC(IS)
          TEDRYR(IS)=AEXTF%TP(KEXTSO4)%DRYR(IS)%VL
          TEDRYRT(:,:,IS)=TEDRYR(IS)
        ENDDO
        TEDRYR(ISEXTSO4+1)=AEXTF%TP(KEXTSO4)%DRYR(ISEXTSO4)%VR
        TEDRYRT(:,:,ISEXTSO4+1)=TEDRYR(ISEXTSO4+1)
      ENDIF
!
!     * TEMPORARY AEROSOL FIELDS FOR SULPHATE AEROSOL FOR DRY
!     * AND WET PARTICLE SIZES FOR INTERNALLY MIXED AEROSOL TYPE.
!
      IF ( KINTSO4 > 0 ) THEN
        DO IS=1,ISINTSO4
          TIWETRC(:,:,IS)=PIWETRC(:,:,IINSO4(IS))
          TIN    (:,:,IS)=PINUM  (:,:,IINSO4(IS))
          TIM    (:,:,IS)=PIMAS  (:,:,IINSO4(IS))
          TIMS   (:,:,IS)=PIMAS  (:,:,IINSO4(IS)) &
                         *PIFRC  (:,:,IINSO4(IS),KINTSO4)
          TIFRCS (:,:,IS)=PIFRC  (:,:,IINSO4(IS),KINTSO4)
          DO IT=1,ISO4S
            TIMN(:,:,IS,IT)=PIMAS  (:,:,IINSO4(IS)) &
                           *PIFRC  (:,:,IINSO4(IS),ITSO4(IT))
            TIFRCN(:,:,IS,IT)=PIFRC(:,:,IINSO4(IS),ITSO4(IT))
          ENDDO
          TIDDN  (:,:,IS)=PIDDN  (:,:,IINSO4(IS))
          TIN0   (:,:,IS)=PIN0   (:,:,IINSO4(IS))
          TIPHI0 (:,:,IS)=PIPHI0 (:,:,IINSO4(IS))
          TIPSI  (:,:,IS)=PIPSI  (:,:,IINSO4(IS))
          TIDPHIT(:,:,IS)=PIDPHIS(IINSO4(IS))
          TIPHIST(:,:,IS)=PIPHISS(IINSO4(IS))
          TIDRYRC(IS)=AINTF%DRYRC(IINSO4(IS))
          TIDRYR(IS)=AINTF%DRYR(IINSO4(IS))%VL
          TIDRYRT(:,:,IS)=TIDRYR(IS)
        ENDDO
        TIDRYR(ISINTSO4+1)=AINTF%DRYR(AINTF%TP(KINTSO4)%ISCE)%VR
        TIDRYRT(:,:,ISINTSO4+1)=TIDRYR(ISINTSO4+1)
      ENDIF
!
!-----------------------------------------------------------------------
!     * DIFFUSIVITY OF H2SO4, MEAN FREE PATH, AND RATE COEFFICIENTS FOR
!     * CONDENSATION OF H2SO4 ONTO PRE-EXISTING AEROSOL (CNDGP, IN 1/S).
!
      TERMS=SQRT(T)
      TERMS=TERMS*T
      DFSO4 = 2.150E-09_R8*TERMS
      TERM2=1.62864E-25_R8/T
      TERM1=SQRT(TERM2)
      FRP = 3.372999311E+11_R8*DFSO4*TERM1
      WRAT=WAMSUL/WH2SO4
      ACND=0.
      IF ( ISEXTSO4 > 0 ) THEN
        CALL GRWTRM(TECNDGP,TECGR1,TECGR2,TECT1,TECT2,TEN0,TEN,TEWETRC, &
                    TEDRYRC,TEDRYR,TEDDN,TEPHI0,TEPSI,TEPHIST,TEDPHIT, &
                    FRP,DFSO4,WRAT,RHOA,LEVA,ILGA,ISEXTSO4)
        ACND=ACND+SUM(TECNDGP,DIM=3)
!        TECGR2=0.
      ENDIF
      IF ( ISINTSO4 > 0 ) THEN
        CALL GRWTRM(TICNDGP,TICGR1,TICGR2,TICT1,TICT2,TIN0,TIN,TIWETRC, &
                    TIDRYRC,TIDRYR,TIDDN,TIPHI0,TIPSI,TIPHIST,TIDPHIT, &
                    FRP,DFSO4,WRAT,RHOA,LEVA,ILGA,ISINTSO4)
        ACND=ACND+SUM(TICNDGP,DIM=3)
!        TICGR2=0.
      ENDIF
!
!-----------------------------------------------------------------------
!     * SCALE INITIAL SULPHURIC ACID PRODUCTION RATE AND CONCENTRATION
!     * IN ORDER TO OBTAIN UNITS FMOL/M3/SEC RESP. FMOL/M3.
!
      FMUL=WH2SO4/YSCALE
      SGPRT=SGPR*RHOA/FMUL
      H2SO4T =MAX(H2SO4I*RHOA/FMUL,0.)
!
!-----------------------------------------------------------------------
!     * DENSITY AND MOLECULAR WEIGHT FOR NUCLEATION PARTICLE. CHECK IF
!     * THE SPECIFIED MOLECULAR WEIGHT FROM THE MODEL INPUT AGREES
!     * WITH THE INTERNALLY ASSUMED MOLECULAR WEIGHT FOR NUCLEATION
!     * PARTICLES.
!
      IF ( KEXTSO4>0 ) THEN
        DRYDN0=AEXTF%TP(KEXTSO4)%DENS
        IF ( ABS(AEXTF%TP(KEXTSO4)%MOLW-YNA) > YTINY &
             .AND. ABS(AEXTF%TP(KEXTSO4)%MOLW/WAMSUL-1.) > YSECS ) THEN
          CALL XIT('GTPCNV',-1)
        ENDIF
      ELSE IF ( KINTSO4>0 ) THEN
        DRYDN0=AINTF%TP(KINTSO4)%DENS
        IF ( ABS(AINTF%TP(KINTSO4)%MOLW-YNA) > YTINY &
             .AND. ABS(AINTF%TP(KINTSO4)%MOLW/WAMSUL-1.) > YSECS ) THEN
          CALL XIT('GTPCNV',-2)
        ENDIF
      ENDIF
!
!-----------------------------------------------------------------------
!     * MASS AND DIAMETER OF NUCLEATION PARTICLES.
!
      PMASSEX=0.
      PMASSIN=0.
      PDIAMEX=0.
      PDIAMIN=0.
      IF ( KEXTSO4 > 0 ) THEN
        PMASSEX=(4.*YPI/3.)*DRYDN0*TEDRYR(1)**3
        PDIAMEX=TEDRYR(1)**3
      ENDIF
      IF ( KINTSO4 > 0 ) THEN
        PMASSIN=(4.*YPI/3.)*DRYDN0*TIDRYR(1)**3
        PDIAMIN=TIDRYR(1)**3
      ENDIF
      PMASS=WEIGHT*PMASSEX+(1.-WEIGHT)*PMASSIN
      PDIAM=2.*1.E+09*(WEIGHT*PDIAMEX+(1.-WEIGHT)*PDIAMIN)**(1./3.)
      IF ( IMETH==1 ) THEN
!
!       * KULMALA'S PARAMETERIZATION OF NULCEATION.
!
        CALL BHNUCL(SXP,ANUCL,T,RH,PMASS,YSCALE,ILGA,LEVA)
      ELSE IF ( IMETH==2 ) THEN
!
!       * TABULATED RESULTS FOR MERIKANTO'S PARAMETERIZATION OF NULCEATION.
!
        CALL TBNUCL(ACOEF,BCOEF,CH2SO4,EPSC,T,CNH3,PMASS, &
                    ILGA,LEVA,IDA,IDAM)
        YSCLRF=1.E+09
        ACOEF=ACOEF*YSCALE/YSCLRF
        CH2SO4=CH2SO4*YSCALE/YSCLRF
        EPSC=EPSC*YSCALE/YSCLRF
      ELSE IF ( IMETH==3 ) THEN
!
!       * DUNNE'S PARAMETERIZATION OF NUCLEATION AT HIGH H2SO4 CONC.
!
        H2SO4A=MAX(H2SO4T,YTINY)
        CALL DUNNEPAR(SCLNCL,ADU,CNH3N,CNH3CH,RKBN,RKBCH,RKTN,RKTCH, &
                      DUALFA,PRION,T,RH,RHOA,H2SO4A,CNH3,YSCALE, &
                      YM3TOCM3,YSDUNNE,ILGA,LEVA)
        CALL DUNUCL(GNUCLA,H2SO4A,SXPT,ADU,CNH3N,CNH3CH,RKBN,RKBCH,RKTN, &
                    RKTCH,DUALFA,PRION,SCLNCL,ACND,DFSO4,TICGR1,TICGR2, &
                    TIDRYR,YSCALE,YM3TOCM3,YSDUNNE,PDIAM,PMASS,DT, &
                    ILGA,LEVA)
        ANUCL=-GNUCLA/H2SO4A**SXPT
        AFUNA=SGPRT-ACND*H2SO4A+GNUCLA
!
!       * UPPER/LOWER BOUND ON EQUILIBRATED H2SO4 CONCENTRATION BASED
!       * ON H2SO4 MASS BUDGET WITH LINEARIZED NUCLEATION TERM.
!
        WHERE ( H2SO4A > YTINY )
          WHERE ( AFUNA <= 0. )
            CTMPY=SGPRT
            CTMPX=ACND-GNUCLA/H2SO4A
          ELSEWHERE
            CTMPY=SGPRT-(SXPT-1.)*GNUCLA
            CTMPX=ACND-SXPT*GNUCLA/H2SO4A
          ENDWHERE
        ELSEWHERE
          CTMPY=SGPRT
          CTMPX=ACND
        ENDWHERE
        WHERE ( CTMPX > MAX(CTMPY/YLARGE,YTINY) )
          H2SO4L=CTMPY/CTMPX
        ELSEWHERE
          H2SO4L=H2SO4A
        END WHERE
        WHERE ( AFUNA <= 0. )
          H2SO4B=MAX(MIN(H2SO4L,YSEC*H2SO4A),YRED*H2SO4A)
        ELSEWHERE
          H2SO4B=MAX(H2SO4L,H2SO4A/YSEC)
        ENDWHERE
        SXPT=REAL(INT(SXPT))
        WHERE ( AFUNA > 0. .AND. SXPT > YTINY &
                .AND. ANUCL > MAX(SGPRT/YLARGE,YTINY))
          CTMP=(SGPRT/ANUCL)**(1./SXPT)
          H2SO4B=MIN(H2SO4B,CTMP)
        ENDWHERE
        H2SO4B=MAX(H2SO4B,YTINY)
!
!       * DUNNE'S PARAMETERIZATION OF NUCLEATION AT UPPER/LOWER H2SO4 CONC.
!
        CALL DUNUCL(GNUCLB,H2SO4B,SXPT,ADU,CNH3N,CNH3CH,RKBN,RKBCH,RKTN, &
                    RKTCH,DUALFA,PRION,SCLNCL,ACND,DFSO4,TICGR1,TICGR2, &
                    TIDRYR,YSCALE,YM3TOCM3,YSDUNNE,PDIAM,PMASS,DT, &
                    ILGA,LEVA)
        AFUNB=SGPRT-ACND*H2SO4B+GNUCLB
!
        WHERE ( AFUNA*AFUNB <= 0. )
          H2SO4C=.5*(H2SO4A+H2SO4B)
        ELSEWHERE ( AFUNB > 0. )
          H2SO4C=H2SO4B+(H2SO4B-H2SO4A)
        ELSEWHERE ( AFUNA < 0. )
          H2SO4C=.5*H2SO4A
        ENDWHERE
        H2SO4C=MAX(H2SO4C,YTINY)
        DO INDS=1,ITERN
!
!         * DUNNE'S PARAMETERIZATION OF NUCLEATION AT ITERATION POINTS.
!
          CALL DUNUCL(GNUCLC,H2SO4C,SXPT,ADU,CNH3N,CNH3CH,RKBN,RKBCH,RKTN, &
                      RKTCH,DUALFA,PRION,SCLNCL,ACND,DFSO4,TICGR1,TICGR2, &
                      TIDRYR,YSCALE,YM3TOCM3,YSDUNNE,PDIAM,PMASS,DT, &
                      ILGA,LEVA)
          AFUNC=SGPRT-ACND*H2SO4C+GNUCLC
          WHERE ( AFUNA*AFUNC <= 0. )
            H2SO4B=H2SO4C
            AFUNB=AFUNC
            GNUCLB=GNUCLC
          ELSEWHERE ( AFUNB*AFUNC <= 0. )
            H2SO4A=H2SO4C
            AFUNA=AFUNC
            GNUCLA=GNUCLC
          ENDWHERE
          WHERE ( AFUNA*AFUNB <= 0. )
            H2SO4C=.5*(H2SO4A+H2SO4B)
          ELSEWHERE ( AFUNB > 0. )
            H2SO4C=2.*H2SO4B
          ELSEWHERE ( AFUNA < 0. )
            H2SO4C=.5*H2SO4A
          ENDWHERE
          H2SO4C=MAX(H2SO4C,YTINY)
        ENDDO
!
!       * FIT POWER-LAW RELATIONSHIP TO GIVEN H2SO4 DEPLETION RATES, 
!       * -ANUCL*H2SO4**SXP
!
        GNUCLH=GNUCLA
        GNUCLL=GNUCLB
        H2SO4H=H2SO4A
        H2SO4L=H2SO4B
        WHERE ( -GNUCLL > MAX(-GNUCLH/YLARGE,YTINY) &
           .AND. H2SO4L > MAX(H2SO4H/YLARGE,YTINY) )
          SXP=LOG(GNUCLH/GNUCLL)/LOG(H2SO4H/H2SO4L)
          ANUCL=-GNUCLH/H2SO4H**SXP
        ELSEWHERE
          SXP=1.
          ANUCL=0.
        END WHERE
!
!       * INITIAL GUESS OF H2SO4 CONCENTRATION.
!
        CTMP=H2SO4C
      ENDIF
!
!-----------------------------------------------------------------------
!     * SOLVE NUCLEATION/CONDENSATION EQUATION FOR SULPHURIC ACID.
!
!     * CALCULATE STEAD-STATE SOLUTION OF THE GAS-TO-PARTICLE
!     * CONVERSION EQUATION USING THE NEWTON-RHAPSON-METHOD (H2SO4 IS
!     * IN FMOL/M3 IN THE ITERATION). THE EQUATION ACCOUNTS FOR PRODUCTION
!     * OF GASEOUS SULPHURIC ACID (+SGPR) AND LOSSES DUE TO CONDENSATION
!     * ONTO PRE-EXISTING AEROSOL (-ACND*H2SO4) AND NUCLEATION OF NEW
!     * PARTICLES (-ANUCL*H2SO4**SXP FOR KULMALA'S PARAMETERIZATION
!     * AND -(ANUCL+BNUCL*(H2SO4-H2SO4_REF)) FOR MERIKANTO'S
!     * PARAMETERIZATION).
!
!     * PRODUCTION/LOSS RATES ARE IN FMOL/M3/S. THE STEADY-STATE
!     * SOLUTION (CTMP) IS LATERON USED TO CALCULATE THE APPROXIMATE
!     * TIME EVOLUTION OF THE H2SO4 CONC. ACCORDING TO THE PROGNOSTIC
!     * GAS-TO-PARTICLE CONVERSION EQUATION.
!
!     * INITIAL GUESS OF EQUILIBRATED H2SO4 CONCENTRATION WITHOUT 
!     * TAKING INTO ACCOUNT NUCLEATION.
!
      IF ( IMETH==1 ) THEN
        WHERE ( ACND > MAX(SGPRT/YLARGE,YTINY) )
          CTMP=SGPRT/ACND
        ELSEWHERE
          CTMP=H2SO4T
        END WHERE
      ENDIF
!
!     * INITIAL GUESS OF EQUILIBRATED H2SO4 CONCENTRATION FROM WEIGHTED 
!     * MEAN OF SOLUTIONS FOR VERY EFFICIENT AND INEFFICIENT CONDENSATION 
!     * AND NUCLEATION.
!
      IF ( IMETH==1 .OR. IMETH==3 ) THEN
        DBL1=SGPRT/YLARGE8
        WHERE ( ANUCL > MAX(DBL1,YTINY8) )
          DBL1=SGPRT/ANUCL
          DBL2=1./SXP
          DBL1=DBL1**DBL2
          CTMPX=DBL1
        ELSEWHERE
          CTMPX=H2SO4T
        END WHERE
        CTMPMX=MIN(CTMP,CTMPX)
        IF ( IMETH==1 ) THEN
          CTMP=YWG*CTMPMX
        ENDIF
      ENDIF
!
!     * OPTION TO RESCALE SULPHURIC ACID CONCENTRATIONS TO UNITY IN ORDER
!     * TO OBTAIN NUMERICALLY MORE ROBUST APPROACH.
!
!      YSCALF=YSCALE/MIN(MAX(1.E+03,CTMP),1.E+15)
!      TERM1=YSCALF/YSCALE
      TERM1=1.
!
      FMULF=FMUL/TERM1
      SGPRT=SGPRT*TERM1
      H2SO4T=H2SO4T*TERM1
      CTMP=CTMP*TERM1
      CTMPMX=CTMPMX*TERM1
      IF ( IMETH==1 .OR. IMETH==3 ) THEN
        DBL2=TERM1
        DBL1=1.-SXP
        DBL3=DBL2**DBL1
        ANUCL=ANUCL*DBL3
      ELSE IF ( IMETH==2 ) THEN
        DO INDS=1,IDAM
          ACOEF(:,:,INDS)=ACOEF(:,:,INDS)*TERM1(:,:)
        ENDDO
        DO INDS=1,IDA
          CH2SO4F(:,:,INDS)=CH2SO4(INDS)*TERM1(:,:)
          EPSCF(:,:,INDS)=EPSC(INDS)*TERM1(:,:)
        ENDDO
      ENDIF
!
!     * ITERATIONS TO FIND EQUILBRIUM. THE INITIAL VALUE IS RETURNED IF NO
!     * CONDENSATION OR NUCLEATION. IF IMETH==1, KULMALA'S PARAMETERIZATION
!     * OF NUCLEATION IS USED. IF IMETH==2, TABULATED NUCLEATION RATES
!     * (FROM MERIKANTO AND COLLEAGUES) ARE USED.
!
      IF ( IMETH==1 .OR. IMETH==3 ) THEN
        DO INDS = 1,ITER
          WHERE ( CTMP > YTINY8 )
            DBL1=CTMP
            DBL2=SXP-1.
            DBL1=DBL1**DBL2
            TERM1=DBL1
          ELSEWHERE
            TERM1=0.
          ENDWHERE
          TERM3=ACND*CTMP
          TERM4=ANUCL*CTMP*TERM1
          TERM2=SGPRT-TERM3-TERM4
          TERMX=TERM3+SXP*TERM4
          TERMY=TERM3+SXP**2*TERM4
          WHERE ( TERMX > MAX(TERMY/YLARGE8,YTINY8) )
            EXPT=TERMY/TERMX
            DBL1=MAX(1.+EXPT*TERM2/TERMX,0.)
            DBL2=1./EXPT
            DBL1=DBL1**DBL2
            CTMP=CTMP*DBL1
            CTMP=MIN(CTMP,CTMPMX)
          END WHERE
        ENDDO
      ELSE
        WHERE ( ACND < YTINY )
          CTMP=H2SO4T
        ELSEWHERE
          CTMP=SGPRT/ACND
        ENDWHERE
        ANUCL=0.
        BNUCL=0.
        TERM2=0.
        TERM3=0.
        TERM4=0.
        DO INDS=1,IDAM
          TERM1=ACND+BCOEF(:,:,INDS)
          CTMPX=SGPRT-ACOEF(:,:,INDS)+BCOEF(:,:,INDS)*CH2SO4F(:,:,INDS)
          WHERE ( ABS(TERM1) > MAX(ABS(CTMPX)/YLARGE8,YTINY8) )
            CTMPX=CTMPX/TERM1
          ELSEWHERE
            CTMPX=0.
          ENDWHERE
          TERM5=ACOEF(:,:,INDS)
          WHERE ( ABS(CTMPX-CH2SO4F(:,:,INDS)) > EPSCF(:,:,INDS) )
            TERM5=TERM5+BCOEF(:,:,INDS)*(CTMPX-CH2SO4F(:,:,INDS))
          ENDWHERE
          WHERE (       CTMPX >= CH2SO4F(:,:,INDS) &
                  .AND. CTMPX <= CH2SO4F(:,:,INDS+1) &
                  .AND. ABS(TERM5) > YTINY )
            CTMP=CTMPX
            ANUCL=ACOEF(:,:,INDS)-BCOEF(:,:,INDS)*CH2SO4F(:,:,INDS)
            BNUCL=BCOEF(:,:,INDS)
            TERM3=ACND*CTMP
            TERM2=SGPRT-TERM3-TERM5
            TERM4=TERM5
          ENDWHERE
        ENDDO
        TERM1=ACND
        CTMPX=SGPRT-ACOEF(:,:,IDAM) &
                   -BCOEF(:,:,IDAM)*(CH2SO4F(:,:,IDA)-CH2SO4F(:,:,IDAM))
        WHERE ( ABS(TERM1) > MAX(ABS(CTMPX)/YLARGE8,YTINY8) )
          CTMPX=CTMPX/TERM1
        ELSEWHERE
          CTMPX=0.
        ENDWHERE
        TERM5=ACOEF(:,:,IDAM)
        WHERE ( CTMPX > CH2SO4F(:,:,IDA) )
          TERM5=TERM5 &
               +BCOEF(:,:,IDAM)*(CH2SO4F(:,:,IDA)-CH2SO4F(:,:,IDAM))
        ENDWHERE
        WHERE ( CTMPX > CH2SO4F(:,:,IDA) .AND. ABS(TERM5) > YTINY )
          CTMP=CTMPX
          ANUCL=TERM5
          BNUCL=0.
          TERM3=ACND*CTMP
          TERM2=SGPRT-TERM3-TERM5
          TERM4=TERM5
        ENDWHERE
      ENDIF
!
!     * BOUNDARY LAYER NUCLEATION ACCORDING TO MERIKANTO ET AL. (2009).
!     * THE NUCLEATION RATES CACULATED ABOVE ARE REPLACED BY THE
!     * BOUNDARY LAYER NUCLEATION RATE (PROPORTIONAL TO SULPHURIC
!     * ACID CONCENTRATION) IF THE BOUNDARY LAYER NUCLEATION
!     * RATE EXCEEDS THE RATE CALCULATED ABOVE (I.E. IF SULPHURIC ACID
!     * CONCENTRATION IS LOWER).
!
      IF ( KBLNCL ) THEN
        CCOEFB=2.E-06_R8
        DO IL=1,ILGA
        DO L=1,LEVA
          IF ( L >= LEVA+PBLTS(IL) ) THEN
            CCOEF=CCOEFB
          ELSE
            CCOEF=0.
          ENDIF
          CTMPXA=SGPRT(IL,L)
          CTMPXB=ACND(IL,L)+CCOEF
          IF ( ABS(CTMPXB) > MAX(ABS(CTMPXA)/YLARGE8,YTINY8) ) THEN
            CTMPXA=CTMPXA/CTMPXB
          ELSE
            CTMPXA=0.
          ENDIF
          IF ( CTMPXA < CTMP(IL,L) ) THEN
            CTMP(IL,L)=CTMPXA
            IF ( IMETH==1 .OR. IMETH==3 ) THEN
              SXP(IL,L)=1.
              ANUCL(IL,L)=CCOEF
              BNUCL(IL,L)=0.
            ELSE
              ANUCL(IL,L)=0.
              BNUCL(IL,L)=CCOEF
            ENDIF
            TERM3(IL,L)=ACND(IL,L)*CTMPXA
            TERM2(IL,L)=SGPRT(IL,L)-TERM3(IL,L)-CCOEF*CTMPXA
            TERM4(IL,L)=CCOEF*CTMPXA
          ENDIF
        ENDDO
        ENDDO
      ENDIF
!
!     * LIMIT EQUILIBRIUM VALUE TO VALUES WHICH WOULD BE REACHED
!     * AFTER 10 TIMES STEPS AT CURRENT GAS-PHASE PRODUCTION RATES
!     * AND IN THE ABSENCE OF CONDENSATION AND NUCLEATION.
!
      CTMP=MIN(CTMP,H2SO4T+(10.*DT)*SGPRT)
!
!     * RELATIVE BUDGET ERROR FOR ITERATIVE SOLUTION.
!
      TERMX=0.
      TERM2=ABS(TERM2)*DT
      TERMY=MAX(H2SO4T,CTMP)
      WHERE ( TERM3 > YTINY8 .OR. TERM4 > YTINY8 .AND. &
              TERMY > MAX(TERM2/YLARGE8,YTINY8) ) TERMX=TERM2/TERMY
      IF ( MAXVAL(TERMX) > YEPS ) IERR=-1
!
!-----------------------------------------------------------------------
!     * PARAMETERS FOR TIME-EVOLUTION OF SULPHURIC ACID AND AEROSOL
!     * CONCENTRATIONS FROM RELAXATION OF CONCENTRATIONS TO EQUILIBRIUM
!     * SOLUTION. CALCULATIONS ARE BASED ON LINEARIZATION OF
!     * GAS-TO-PARTICLE EQUATION AROUND EQUILIBRIUM SOLUTION.
!
      TERM1=CTMP
      TERM2=H2SO4T
      EFFC=.5*(TERM1+TERM2)
      PERTC=H2SO4T-CTMP
      PLAM=ACND
      IF ( IMETH==1 .OR. IMETH==3 ) THEN
        WHERE ( EFFC > YTINY )
          DBL1=EFFC
          DBL2=SXP-1.
          DBL1=DBL1**DBL2
          TERMY=DBL1
        ELSEWHERE
          TERMY=0.
        ENDWHERE
        PLAM=PLAM+ANUCL*SXP*TERMY
      ELSE
        PLAM=PLAM+BNUCL
      ENDIF
      DBL1=-PLAM*DT
      DBL2=EXP(DBL1)
      EXPT=DBL2
!
!     * TIME-INTEGRATED SULPHURIC ACID CONCENTRATION FOR CONDENSATION
!     * AND NUCLEATION CALCULATIONS (SADT, KG/M3*SEC).
!
      TERM3=PERTC*(EXPT-1.)
      WHERE ( PLAM > MAX(ABS(TERM3)/YLARGE,YTINY) )
        PLFN=TERM3/PLAM
        SADT=(CTMP*DT-PLFN)*FMULF
      ELSEWHERE
        PLFN=-PERTC*DT
        SADT=(H2SO4T*DT+.5*SGPRT*DT**2)*FMULF
      ENDWHERE
      SADT=MAX(SADT,0.)
!
!     * GROWTH FACTOR FROM TIME-INTEGRATION OF R*DR/DT. UNITS: M**2.
!     * YSEC IS THE THRESHOLD FOR THE ADJUSTMENT TO TIME STEP.
!
      TECORFM=1./YSEC
      TECORFA=1./YSEC
      IF ( ISEXTSO4 > 0 ) THEN
        DO IS=1,ISEXTSO4
          TECGR1(:,:,IS)=TECGR1(:,:,IS)*SADT(:,:)
          TECGR2(:,:,IS)=TECGR2(:,:,IS)*SADT(:,:)
          TERM1=MAX(TECGR1(:,:,IS)+TECGR2(:,:,IS)*TEDRYR(IS  ),YSMALL)
          TERM2=MAX(TECGR1(:,:,IS)+TECGR2(:,:,IS)*TEDRYR(IS+1),YSMALL)
          TECORF(:,:,IS)=YSEC*MIN(TEDRYR(IS  )**2/TERM1(:,:), &
                                  TEDRYR(IS+1)**2/TERM2(:,:))
        ENDDO
        TECORF=MIN(1./YSEC,TECORF)
        TECORFM=MINVAL(TECORF)
        DO L=1,LEVA
        DO IL=1,ILGA
          TECORFS(:)=TECORF(IL,L,:)
          TECORFA(IL,L)=MINVAL(TECORFS)
        ENDDO
        ENDDO
      ENDIF
      TICORFM=1./YSEC
      TICORFA=1./YSEC
      IF ( ISINTSO4 > 0 ) THEN
        DO IS=1,ISINTSO4
          TICGR1(:,:,IS)=TICGR1(:,:,IS)*SADT(:,:)
          TICGR2(:,:,IS)=TICGR2(:,:,IS)*SADT(:,:)
          TERM1=MAX(TICGR1(:,:,IS)+TICGR2(:,:,IS)*TIDRYR(IS  ),YSMALL)
          TERM2=MAX(TICGR1(:,:,IS)+TICGR2(:,:,IS)*TIDRYR(IS+1),YSMALL)
          TICORF(:,:,IS)=YSEC*MIN(TIDRYR(IS  )**2/TERM1(:,:), &
                                  TIDRYR(IS+1)**2/TERM2(:,:))
        ENDDO
        TICORF=MIN(1./YSEC,TICORF)
        TICORFM=MINVAL(TICORF)
        DO L=1,LEVA
        DO IL=1,ILGA
          TICORFS(:)=TICORF(IL,L,:)
          TICORFA(IL,L)=MINVAL(TICORFS)
        ENDDO
        ENDDO
      ENDIF
!
!-----------------------------------------------------------------------
!     * IF NECESSARY, ADJUST TIME STEP TO LIMIT AEROSOL GROWTH
!     * IF GROWTH RATE EXCEEDS CRITICAL THRESHOLD FOR TREATMENT
!     * OF CONDENSATION IN SUBROUTINE PGRWTH.
!
      DTC=DT
      CORFM=MIN(TECORFM,TICORFM)
      CORFAR=1.
      IF ( CORFM < 1. ) THEN
        CORFA=MIN(TECORFA,TICORFA)
        CORFAR=MIN(CORFA,1.)
        SADT=SADT*CORFAR
        IF ( ISEXTSO4 > 0 ) THEN
          DO IS=1,ISEXTSO4
            TECGR1(:,:,IS)=TECGR1(:,:,IS)*CORFAR(:,:)
            TECGR2(:,:,IS)=TECGR2(:,:,IS)*CORFAR(:,:)
          ENDDO
        ENDIF
        IF ( ISINTSO4 > 0 ) THEN
          DO IS=1,ISINTSO4
            TICGR1(:,:,IS)=TICGR1(:,:,IS)*CORFAR(:,:)
            TICGR2(:,:,IS)=TICGR2(:,:,IS)*CORFAR(:,:)
          ENDDO
        ENDIF
!
!       * ITERATE TO OBTAIN REDUCED TIME STEP.
!
        TERMX=(CTMP+PERTC*EXPT)*FMULF
        WHERE ( TERMX < YTINY .AND. CORFA < 1. ) DTC=0.
        TERM2=0.
        DO INDS = 1,ITER
          TERM3=PERTC*(EXPT-1.)
          WHERE ( CORFA < 1. .AND. PLAM > MAX(ABS(TERM3)/YLARGE,YTINY) &
                           .AND. TERMX > MAX(ABS(TERM2)/YLARGE,YTINY) )
            PLFN=TERM3/PLAM
            TERM2=(CTMP*DTC-PLFN)*FMULF-SADT
            DTC=MIN(MAX(DTC-TERM2/TERMX,0.),DT)
          ENDWHERE
          DBL1=-PLAM*DTC
          DBL2=EXP(DBL1)
          EXPT=DBL2
          TERMX=(CTMP+PERTC*EXPT)*FMULF
        ENDDO
        TERM3=ABS(TERM2)
        WHERE ( SADT > MAX(TERM3/YLARGE,YTINY) )
          TERMX=TERM3/SADT
        ELSEWHERE
          TERMX=0.
        END WHERE
        IF ( MAXVAL(TERMX) > YEPS ) IERR=-2
        TERM3=PERTC*(EXPT-1.)
        WHERE ( ABS(PLAM) > MAX(ABS(TERM3)/YLARGE,YTINY) )
          PLFN=TERM3/PLAM
        ELSEWHERE
          PLFN=-PERTC*DTC
        ENDWHERE
      ENDIF
      IF ( MINVAL(DTC) < DT ) IERR=-3
!
!-----------------------------------------------------------------------
!     * CHANGE IN SULPHURIC ACID AND AEROSOL MASS FROM NUCLEATION.
!     * IT IS ASSUMED THAT THE NUCLEATION AEROSOL CONSISTS OF AMMONIUM
!     * SULPHATE (MAKE SURE THAT THIS IS CONSISTENT WITH NUCLEATION PARTICLE
!     * DENSITY). DICNCL IS IN KG/KG.
!
      IF ( IMETH==1 .OR. IMETH==3 ) THEN
        WHERE ( CTMP > YTINY )
          DBL1=CTMP
          DBL2=SXP
          DBL1=DBL1**DBL2
          TERM2=DBL1
        ELSEWHERE
          TERM2=0.
        ENDWHERE
        TERM1=MIN(-FMULF*ANUCL*(TERM2*DTC-SXP*TERMY*PLFN)/RHOA,0.)
      ELSE
        TERM1=MIN(-(FMULF*ANUCL*DTC+BNUCL*SADT)/RHOA,0.)
      ENDIF
      WHERE ( SADT <= YTINY ) TERM1=0.
      DECNCL=WEIGHT*TERM1
      DICNCL=(1.-WEIGHT)*TERM1
      TEXNCL=DECNCL*2.*WNH3/WH2SO4
      TIXNCL=DICNCL*2.*WNH3/WH2SO4
!
!     * CHANGE IN AEROSOL NUMBER FROM NUCLEATION. NNCL IN 1/KG.
!
      DENNCL=0.
      DINNCL=0.
      IF ( ISEXTSO4 > 0 ) DENNCL=-(DECNCL+TEXNCL)/PMASSEX
      IF ( ISINTSO4 > 0 ) DINNCL=-(DICNCL+TIXNCL)/PMASSIN
!
!-----------------------------------------------------------------------
!     * CHANGE IN SULPHURIC ACID CONCENTRATION FROM CONDENSATION.
!
      IF ( ISEXTSO4 > 0 ) THEN
        DO IS=1,ISEXTSO4
          TEDCCND(:,:,IS)=-TECNDGP(:,:,IS)*SADT(:,:)/RHOA(:,:)
        ENDDO
        TEDXCND=TEDCCND*2.*WNH3/WH2SO4
      ENDIF
      IF ( ISINTSO4 > 0 ) THEN
        DO IS=1,ISINTSO4
          TIDCCND(:,:,IS)=-TICNDGP(:,:,IS)*SADT(:,:)/RHOA(:,:)
        ENDDO
        TIDXCND=TIDCCND*2.*WNH3/WH2SO4
      ENDIF
!
!     * DIAGNOSE CONDENSATION RATES.
!
      DECND=0.
      DICND=0.
      CNDM=0.
      IF ( ISEXTSO4 > 0 ) THEN
        TERMX=SUM(TEDCCND,DIM=3)
        CNDM=CNDM+TERMX
        DECND=DECND-TERMX/DT
      ENDIF
      IF ( ISINTSO4 > 0 ) THEN
        TERMX=SUM(TIDCCND,DIM=3)
        CNDM=CNDM+TERMX
        DICND=DICND-TERMX/DT
      ENDIF
!
!     * ADJUST CONDENSATION RATES TO MAKE SURE THAT TRUNCATION ERRORS
!     * IN CALCULATIONS OF CONDENSATION RATES DO NOT LEAD TO ANY
!     * NEGATIVE H2SO4 CONCENTRATIONS.
!
      CNDMX=-H2SO4I-SGPR*DT
      TERMX=1.
      WHERE ( CNDM < CNDMX .AND. CNDM < MIN(CNDMX/YLARGE,-YTINY) )
        TERMX=CNDMX/CNDM
        CNDM=CNDMX
        DECND=DECND*TERMX
        DECND=-DECND*WAMSUL/WH2SO4
        DICND=DICND*TERMX
        DICND=-DICND*WAMSUL/WH2SO4
      ENDWHERE
      IF ( ISEXTSO4 > 0 ) THEN
        DO IS=1,ISEXTSO4
          TEDCCND(:,:,IS)=TEDCCND(:,:,IS)*TERMX(:,:)
          TEDXCND(:,:,IS)=TEDXCND(:,:,IS)*TERMX(:,:)
        ENDDO
      ENDIF
      IF ( ISINTSO4 > 0 ) THEN
        DO IS=1,ISINTSO4
          TIDCCND(:,:,IS)=TIDCCND(:,:,IS)*TERMX(:,:)
          TIDXCND(:,:,IS)=TIDXCND(:,:,IS)*TERMX(:,:)
        ENDDO
      ENDIF
!
!-----------------------------------------------------------------------
!     * PARTICLE GROWTH DUE TO CONDENSATION/EVAPORATION. THE FOLLOWING
!     * CALCULATIONS PROVIDE THE UPDATED SIZE DISTRIBUTIONS FOR
!     * PARTICLE NUMBER, SULPHUR AEROSOL MASS, AND MASS OF OTHER
!     * AEROSOL SPECIES AFTER THE CONDENSATION STEP.
!
      DERSN=0.
      DERSM=0.
      IF ( ISEXTSO4 > 0 ) THEN
        CALL PGRPAR (TEDP0L,TEDP1L,TEDP2L,TEDP3L,TEDP4L,TEDP5L,TEDP6L, &
                     TEDM1L,TEDM2L,TEDM3L,TEDP0R,TEDP1R,TEDP2R,TEDP3R, &
                     TEDP4R,TEDP5R,TEDP6R,TEDM1R,TEDM2R,TEDM3R,TEDP0S, &
                     TEDP1S,TEDP2S,TEDP3S,TEDP4S,TEDP5S,TEDP6S,TEDM1S, &
                     TEDM2S,TEDM3S,TEI0L,TEI0R,TECGR1,TECGR2,TEN0, &
                     TEDRYRT,TEPHIST,TEDPHIT,TEPHI0,TEPSI,ILGA,LEVA, &
                     ISEXTSO4,IERR,IMODC)
        CALL PGRWTH0(TENT,DERSN,TEI0L,TEI0R,TEDP0L,TEDP0R,TEDP0S, &
                     TEN0,ILGA,LEVA,ISEXTSO4)
        TEFRC(:,:,:)=1.
        CALL PGRWTHS(TEMT,DERSM,TEFRC,TEI0L,TEI0R, &
                     TEDP0L,TEDP1L,TEDP2L,TEDP3L,TEDM1L,TEDM2L,TEDM3L, &
                     TEDP0R,TEDP1R,TEDP2R,TEDP3R,TEDM1R,TEDM2R,TEDM3R, &
                     TEDP0S,TEDP1S,TEDP2S,TEDP3S,TEDM1S,TEDM2S,TEDM3S, &
                     TECGR1,TECGR2,TEN0,TEDDN,ILGA,LEVA,ISEXTSO4)
      ENDIF
      DIRSN=0.
      DIRSMS=0.
      DIRSMN=0.
      IF ( ISINTSO4 > 0 ) THEN
        CALL PGRPAR (TIDP0L,TIDP1L,TIDP2L,TIDP3L,TIDP4L,TIDP5L,TIDP6L, &
                     TIDM1L,TIDM2L,TIDM3L,TIDP0R,TIDP1R,TIDP2R,TIDP3R, &
                     TIDP4R,TIDP5R,TIDP6R,TIDM1R,TIDM2R,TIDM3R,TIDP0S, &
                     TIDP1S,TIDP2S,TIDP3S,TIDP4S,TIDP5S,TIDP6S,TIDM1S, &
                     TIDM2S,TIDM3S,TII0L,TII0R,TICGR1,TICGR2,TIN0, &
                     TIDRYRT,TIPHIST,TIDPHIT,TIPHI0,TIPSI,ILGA,LEVA, &
                     ISINTSO4,IERR,IMODC)
        CALL PGRWTH0(TINT,DIRSN,TII0L,TII0R,TIDP0L,TIDP0R,TIDP0S, &
                     TIN0,ILGA,LEVA,ISINTSO4)
        CALL PGRWTHS(TIMST,DIRSMS,TIFRCS,TII0L,TII0R, &
                     TIDP0L,TIDP1L,TIDP2L,TIDP3L,TIDM1L,TIDM2L,TIDM3L, &
                     TIDP0R,TIDP1R,TIDP2R,TIDP3R,TIDM1R,TIDM2R,TIDM3R, &
                     TIDP0S,TIDP1S,TIDP2S,TIDP3S,TIDM1S,TIDM2S,TIDM3S, &
                     TICGR1,TICGR2,TIN0,TIDDN,ILGA,LEVA,ISINTSO4)
        IF ( ISO4S > 0 ) THEN
          TIRSMN=0.
          CALL PGRWTHN(TIMNT,TIRSMN,TIFRCN,TII0L,TII0R,TIDP3L,TIDP3R, &
                       TIDP3S,TIN0,TIDDN,ILGA,LEVA,ISO4S,ISINTSO4)
          DIRSMN=SUM(TIRSMN,DIM=3)
        ENDIF
      ENDIF
!
!-----------------------------------------------------------------------
!     * NUMBER AND MASS FIXERS. THIS CORRECTS FOR ANY TRUNCATION
!     * ERRORS THAT MAY HAVE OCCURRED PREVIOUSLY. THE APPROACH IS
!     * TO SCALE THE TOTAL NUMBER AND MASS CONCENTRATIONS SO THAT THE
!     * FINAL TOTAL MASS WILL BE CONSISTENT WITH THE CORRESPONDING
!     * PHYSICO-CHEMICAL PRODUCTION AND LOSS RATES.
!
      TERM1=0.
      TERM2=0.
      TERM3=0.
      TERM4=0.
      IF ( ISEXTSO4 > 0 ) THEN
        TENT=MAX(TENT,0.)
        TEMT=MAX(TEMT,0._R8)
        TERM1=TERM1+SUM(TEMT,DIM=3)+DERSM
        TERM2=TERM2+SUM(TENT,DIM=3)+DERSN
        TERM3=TERM3+SUM(TEM ,DIM=3)
        TERM4=TERM4+SUM(TEN ,DIM=3)
      ENDIF
      IF ( ISINTSO4 > 0 ) THEN
        TINT=MAX(TINT,0.)
        TIMST=MAX(TIMST,0._R8)
        TERM1=TERM1+SUM(TIMST,DIM=3)+DIRSMS
        TERM2=TERM2+SUM(TINT ,DIM=3)+DIRSN
        TERM3=TERM3+SUM(TIMS ,DIM=3)
        TERM4=TERM4+SUM(TIN  ,DIM=3)
        IF ( ISO4S > 0 ) THEN
          TITM1=SUM(TIMNT,DIM=3)+TIRSMN
          TITM2=SUM(TIMN ,DIM=3)
        ENDIF
      ENDIF
!
      DO L=1,LEVA
      DO IL=1,ILGA
!
!       * CORRECT AEROSOL NUMBER CONCENTRATION.
!
        IF ( TERM2(IL,L) > MAX(TERM4(IL,L)/YLARGE,YTINY) ) THEN
          CFN=TERM4(IL,L)/TERM2(IL,L)
          IF ( ISEXTSO4 > 0 ) TENT(IL,L,:)=TENT(IL,L,:)*CFN
          IF ( ISINTSO4 > 0 ) TINT(IL,L,:)=TINT(IL,L,:)*CFN
        ENDIF
!
!       * CORRECT SULPHUR AEROSOL MASS CONCENTRATION.
!
        TERM6=TERM3(IL,L)-CNDM(IL,L)*WAMSUL/WH2SO4
        IF ( TERM1(IL,L) > MAX(TERM6/YLARGE,YTINY) ) THEN
          CFM=TERM6/TERM1(IL,L)
          IF ( ISEXTSO4 > 0 ) TEMT (IL,L,:)=TEMT (IL,L,:)*CFM
          IF ( ISINTSO4 > 0 ) TIMST(IL,L,:)=TIMST(IL,L,:)*CFM
        ENDIF
      ENDDO
      ENDDO
!
!     * CORRECT NON-SULPHATE AEROSOL MASS CONCENTRATION.
!
      IF ( ISINTSO4 > 0 ) THEN
        DO IT=1,ISO4S
        DO L=1,LEVA
        DO IL=1,ILGA
          IF ( TITM1(IL,L,IT) > MAX(TITM2(IL,L,IT)/YLARGE,YTINY) ) THEN
            CFM=TITM2(IL,L,IT)/TITM1(IL,L,IT)
            TIMNT(IL,L,:,IT)=TIMNT(IL,L,:,IT)*CFM
          ENDIF
        ENDDO
        ENDDO
        ENDDO
      ENDIF
!
!-----------------------------------------------------------------------
!     * TOTAL AEROSOL MASS FOR INTERNALLY MIXED AEROSOL SPECIES.
!
      IF ( KINTSO4 > 0 ) THEN
        TIMT=TIMST
        DO IT=1,ISO4S
          TIMT(:,:,:)=TIMT(:,:,:)+TIMNT(:,:,:,IT)
        ENDDO
      ENDIF
!
!-----------------------------------------------------------------------
!     * SULPHURIC ACID TENDENCY.
!
      TERM2=DECNCL+DICNCL
      TERMX=H2SO4I+SGPR*DT+CNDM+TERM2
!
!     * IN CASE THE NEW H2SO4 CONCENTRATION IS NEGATIVE, TRY TO
!     * ADJUST THE NUCLEATION RATE SO THAT THE RESULT IS NIL.
!
      TERM1=1.
      TERM3=-H2SO4I-SGPR*DT-CNDM
      WHERE ( TERMX < -YTINY .AND. TERM2 < MIN(TERM3/YLARGE,-YTINY) )
        TERMX=0.
        TERM1=TERM3/TERM2
        DECNCL=TERM1*DECNCL
        TEXNCL=TERM1*TEXNCL
        DENNCL=TERM1*DENNCL
        DICNCL=TERM1*DICNCL
        TIXNCL=TERM1*TIXNCL
        DINNCL=TERM1*DINNCL
      END WHERE
      DGDT=(TERMX-H2SO4I)/DT
!
!-----------------------------------------------------------------------
!     * CHANGE FOR SMALLEST PARTICLES DUE TO NUCLEATION.
!
      IS=1
      IF ( ISEXTSO4 > 0 ) THEN
        TENT (:,:,IS)=TENT (:,:,IS)+DENNCL
        DECNCL=DECNCL+TEXNCL
        TEMT (:,:,IS)=TEMT (:,:,IS)-DECNCL
        DENNCL= DENNCL/DT
        DECNCL=-DECNCL/DT
      ENDIF
      IF ( ISINTSO4 > 0 ) THEN
        TINT (:,:,IS)=TINT (:,:,IS)+DINNCL
        DICNCL=DICNCL+TIXNCL
        TIMST(:,:,IS)=TIMST(:,:,IS)-DICNCL
        TIMT (:,:,IS)=TIMT (:,:,IS)-DICNCL
        DINNCL= DINNCL/DT
        DICNCL=-DICNCL/DT
      ENDIF
!
!-----------------------------------------------------------------------
!     * TRACER TENDENCIES.
!
      IF ( KEXTSO4 > 0 ) THEN
        DO IS=1,ISEXTSO4
          PEDNDT(:,:,IEXSO4(IS))=(TENT(:,:,IS)-TEN(:,:,IS))/DT
          PEDMDT(:,:,IEXSO4(IS))=(TEMT(:,:,IS)-TEM(:,:,IS))/DT
        ENDDO
      ENDIF
      IF ( KINTSO4 > 0 ) THEN
        DO IS=1,ISINTSO4
          PIDNDT(:,:,IINSO4(IS))=(TINT(:,:,IS)-TIN(:,:,IS))/DT
          PIDMDT(:,:,IINSO4(IS))=(TIMT(:,:,IS)-TIM(:,:,IS))/DT
          WHERE ( TIMT(:,:,IS) > YTINY )
            PIDFDT(:,:,IINSO4(IS),KINTSO4)= &
                         (TIMST(:,:,IS)/TIMT(:,:,IS)-TIFRCS(:,:,IS))/DT
          ELSEWHERE
            PIDFDT(:,:,IINSO4(IS),KINTSO4)=0.
          ENDWHERE
          DO IT=1,ISO4S
            WHERE ( TIMT(:,:,IS) > YTINY )
              PIDFDT(:,:,IINSO4(IS),ITSO4(IT))= &
                   (TIMNT(:,:,IS,IT)/TIMT(:,:,IS)-TIFRCN(:,:,IS,IT))/DT
            ELSEWHERE
              PIDFDT(:,:,IINSO4(IS),ITSO4(IT))=0.
            ENDWHERE
          ENDDO
        ENDDO
      ENDIF
!
!     * DEALLOCATION.
!
      IF ( ISEXTSO4 > 0 ) THEN
        DEALLOCATE(TEWETRC)
        DEALLOCATE(TEN    )
        DEALLOCATE(TENT   )
        DEALLOCATE(TEM    )
        DEALLOCATE(TEMT   )
        DEALLOCATE(TEDDN  )
        DEALLOCATE(TEN0   )
        DEALLOCATE(TEPHI0 )
        DEALLOCATE(TEPSI  )
        DEALLOCATE(TECT1  )
        DEALLOCATE(TECT2  )
        DEALLOCATE(TECGR1 )
        DEALLOCATE(TECGR2 )
        DEALLOCATE(TECNDGP)
        DEALLOCATE(TEDCCND)
        DEALLOCATE(TEDXCND)
        DEALLOCATE(TEDPHIT)
        DEALLOCATE(TEPHIST)
        DEALLOCATE(TECORF )
        DEALLOCATE(TEI0L  )
        DEALLOCATE(TEI0R  )
        DEALLOCATE(TEDP0L )
        DEALLOCATE(TEDP1L )
        DEALLOCATE(TEDP2L )
        DEALLOCATE(TEDP3L )
        DEALLOCATE(TEDP4L )
        DEALLOCATE(TEDP5L )
        DEALLOCATE(TEDP6L )
        DEALLOCATE(TEDM1L )
        DEALLOCATE(TEDM2L )
        DEALLOCATE(TEDM3L )
        DEALLOCATE(TEDP0R )
        DEALLOCATE(TEDP1R )
        DEALLOCATE(TEDP2R )
        DEALLOCATE(TEDP3R )
        DEALLOCATE(TEDP4R )
        DEALLOCATE(TEDP5R )
        DEALLOCATE(TEDP6R )
        DEALLOCATE(TEDM1R )
        DEALLOCATE(TEDM2R )
        DEALLOCATE(TEDM3R )
        DEALLOCATE(TEDP0S )
        DEALLOCATE(TEDP1S )
        DEALLOCATE(TEDP2S )
        DEALLOCATE(TEDP3S )
        DEALLOCATE(TEDP4S )
        DEALLOCATE(TEDP5S )
        DEALLOCATE(TEDP6S )
        DEALLOCATE(TEDM1S )
        DEALLOCATE(TEDM2S )
        DEALLOCATE(TEDM3S )
        DEALLOCATE(TEFRC  )
        DEALLOCATE(TEDRYRT)
        DEALLOCATE(TECORFS)
        DEALLOCATE(TEDRYR )
        DEALLOCATE(TEDRYRC)
      ENDIF
      IF ( ISINTSO4 > 0 ) THEN
        DEALLOCATE(TIMN   )
        DEALLOCATE(TIMNT  )
        DEALLOCATE(TIFRCN )
        DEALLOCATE(TIMS   )
        DEALLOCATE(TIMST  )
        DEALLOCATE(TIWETRC)
        DEALLOCATE(TIN    )
        DEALLOCATE(TINT   )
        DEALLOCATE(TIM    )
        DEALLOCATE(TIMT   )
        DEALLOCATE(TIDDN  )
        DEALLOCATE(TIN0   )
        DEALLOCATE(TIPHI0 )
        DEALLOCATE(TIPSI  )
        DEALLOCATE(TICT1  )
        DEALLOCATE(TICT2  )
        DEALLOCATE(TICGR1 )
        DEALLOCATE(TICGR2 )
        DEALLOCATE(TICNDGP)
        DEALLOCATE(TIDCCND)
        DEALLOCATE(TIDXCND)
        DEALLOCATE(TIDPHIT)
        DEALLOCATE(TIPHIST)
        DEALLOCATE(TICORF )
        DEALLOCATE(TII0L  )
        DEALLOCATE(TII0R  )
        DEALLOCATE(TIDP0L )
        DEALLOCATE(TIDP1L )
        DEALLOCATE(TIDP2L )
        DEALLOCATE(TIDP3L )
        DEALLOCATE(TIDP4L )
        DEALLOCATE(TIDP5L )
        DEALLOCATE(TIDP6L )
        DEALLOCATE(TIDM1L )
        DEALLOCATE(TIDM2L )
        DEALLOCATE(TIDM3L )
        DEALLOCATE(TIDP0R )
        DEALLOCATE(TIDP1R )
        DEALLOCATE(TIDP2R )
        DEALLOCATE(TIDP3R )
        DEALLOCATE(TIDP4R )
        DEALLOCATE(TIDP5R )
        DEALLOCATE(TIDP6R )
        DEALLOCATE(TIDM1R )
        DEALLOCATE(TIDM2R )
        DEALLOCATE(TIDM3R )
        DEALLOCATE(TIDP0S )
        DEALLOCATE(TIDP1S )
        DEALLOCATE(TIDP2S )
        DEALLOCATE(TIDP3S )
        DEALLOCATE(TIDP4S )
        DEALLOCATE(TIDP5S )
        DEALLOCATE(TIDP6S )
        DEALLOCATE(TIDM1S )
        DEALLOCATE(TIDM2S )
        DEALLOCATE(TIDM3S )
        DEALLOCATE(TIFRCS )
        DEALLOCATE(TIDRYRT)
        DEALLOCATE(TIRSMN )
        DEALLOCATE(TITM1  )
        DEALLOCATE(TITM2  )
        DEALLOCATE(TICORFS)
        DEALLOCATE(TIDRYR )
        DEALLOCATE(TIDRYRC)
      ENDIF
      DEALLOCATE(TECORFA)
      DEALLOCATE(TICORFA)
      DEALLOCATE(TEXNCL )
      DEALLOCATE(TIXNCL )
      DEALLOCATE(GNUCLA )
      DEALLOCATE(GNUCLB )
      DEALLOCATE(GNUCLC )
      DEALLOCATE(GNUCLL )
      DEALLOCATE(GNUCLH )
      DEALLOCATE(AFUNA  )
      DEALLOCATE(AFUNB  )
      DEALLOCATE(AFUNC  )
      DEALLOCATE(ANUCL  )
      DEALLOCATE(BNUCL  )
      DEALLOCATE(SXP    )
      DEALLOCATE(SXPT   )
      DEALLOCATE(CTMP   )
      DEALLOCATE(ACND   )
      DEALLOCATE(PLFN   )
      DEALLOCATE(CNDM   )
      DEALLOCATE(CNDMX  )
      DEALLOCATE(EFFC   )
      DEALLOCATE(TERMX  )
      DEALLOCATE(TERMY  )
      DEALLOCATE(TERMS  )
      DEALLOCATE(TERM1  )
      DEALLOCATE(TERM2  )
      DEALLOCATE(TERM3  )
      DEALLOCATE(TERM4  )
      DEALLOCATE(TERM5  )
      DEALLOCATE(SGPRT  )
      DEALLOCATE(H2SO4T )
      DEALLOCATE(H2SO4A )
      DEALLOCATE(H2SO4B )
      DEALLOCATE(H2SO4C )
      DEALLOCATE(H2SO4L )
      DEALLOCATE(H2SO4H )
      DEALLOCATE(DFSO4  )
      DEALLOCATE(FRP    )
      DEALLOCATE(PLAM   )
      DEALLOCATE(PERTC  )
      DEALLOCATE(CORFA  )
      DEALLOCATE(CORFAR )
      DEALLOCATE(DTC    )
      DEALLOCATE(EXPT   )
      DEALLOCATE(SADT   )
      DEALLOCATE(CTMPX  )
      DEALLOCATE(CTMPY  )
      DEALLOCATE(CTMPMX )
      DEALLOCATE(FMULF  )
!      DEALLOCATE(YSCALF )
      DEALLOCATE(CH2SO4F)
      DEALLOCATE(EPSCF  )
      DEALLOCATE(DBL1   )
      DEALLOCATE(DBL2   )
      DEALLOCATE(DBL3   )
      DEALLOCATE(CNH3N  )
      DEALLOCATE(CNH3CH )
      DEALLOCATE(RKBN   )
      DEALLOCATE(RKBCH  )
      DEALLOCATE(RKTN   )
      DEALLOCATE(RKTCH  )
      DEALLOCATE(DUALFA )
      DEALLOCATE(PRION  )
      DEALLOCATE(SCLNCL )
!
      END SUBROUTINE GTPCNV
