      SUBROUTINE SCCONF
!-----------------------------------------------------------------------
!     PURPOSE:
!     --------
!     INITIALIZATION OF BASIC PARAMETERS FOR AEROSOL CALCULATIONS WITH
!     PLA METHOD FOR ACTIVATION CALCULATIONS.
!
!     THIS SUBROUTINE NEEDS TO BE CALLED AFTER SDCONF.
!
!     HISTORY:
!     --------
!     * MAR 24/2006 - K.VONSALZEN   NEW.
!
!-----------------------------------------------------------------------
!
      USE SCPARM
      USE SDPARM
!
      IMPLICIT REAL (A-H,O-Z), INTEGER (I-N)
!
!-----------------------------------------------------------------------
!
!     * TOTAL NUMBER OF AEROSOL SECTIONS FOR EVAPORATION/CONDENSATION
!     * CALCULATIONS.
!
      ISEXT=ISESC*ISWEXT
      ISEXTB=ISEXT+KWEXT
      ISINT=ISESC*ISWINT
      ISINTB=ISINT+KWINT
!
!     * ALLOCATE ARRAYS THAT CONTAIN INFORMATION ABOUT THE SECTION
!     * BOUNDARIES, SIZES, AND DENSITIES FOR WETTABLE AEROSOLS FOR
!     * GRID-CELL INVARIANT INFORMATION.
!
      IF ( ISEXT > 0 ) THEN
        IF ( ALLOCATED(CEPHI) ) DEALLOCATE(CEPHI)
        ALLOCATE(CEPHI  (ISEXT))
        IF ( ALLOCATED(CEDRYR) ) DEALLOCATE(CEDRYR)
        ALLOCATE(CEDRYR (ISEXT))
        IF ( ALLOCATED(CEDRYRC) ) DEALLOCATE(CEDRYRC)
        ALLOCATE(CEDRYRC(ISEXT))
        IF ( ALLOCATED(CEISVL) ) DEALLOCATE(CEISVL)
        ALLOCATE(CEISVL (ISEXT))
        IF ( ALLOCATED(CEISVR) ) DEALLOCATE(CEISVR)
        ALLOCATE(CEISVR (ISEXT))
      ENDIF
      IF ( ISEXTB > 0 ) THEN
        IF ( ALLOCATED(CEDRYRB) ) DEALLOCATE(CEDRYRB)
        ALLOCATE(CEDRYRB(ISEXTB))
        IF ( ALLOCATED(CEKX) ) DEALLOCATE(CEKX)
        ALLOCATE(CEKX   (ISEXTB))
        IF ( ALLOCATED(CEIS) ) DEALLOCATE(CEIS)
        ALLOCATE(CEIS   (ISEXTB))
      ENDIF
      IF ( ISINT > 0 ) THEN
        IF ( ALLOCATED(CIPHI) ) DEALLOCATE(CIPHI)
        ALLOCATE(CIPHI  (ISINT))
        IF ( ALLOCATED(CIDRYR) ) DEALLOCATE(CIDRYR)
        ALLOCATE(CIDRYR (ISINT))
        IF ( ALLOCATED(CIDRYRC) ) DEALLOCATE(CIDRYRC)
        ALLOCATE(CIDRYRC(ISINT))
        IF ( ALLOCATED(CIISVL) ) DEALLOCATE(CIISVL)
        ALLOCATE(CIISVL (ISINT))
        IF ( ALLOCATED(CIISVR) ) DEALLOCATE(CIISVR)
        ALLOCATE(CIISVR (ISINT))
      ENDIF
      IF ( ISINTB > 0 ) THEN
        IF ( ALLOCATED(CIDRYRB) ) DEALLOCATE(CIDRYRB)
        ALLOCATE(CIDRYRB(ISINTB))
        IF ( ALLOCATED(CIIS) ) DEALLOCATE(CIIS)
        ALLOCATE(CIIS   (ISINTB))
      ENDIF
!
!     * CALCULATE SIZES FOR DRY SIZE DISTRIBUTION FOR EXTERNALLY MIXED
!     * AEROSOL TYPES.
!
      ISC=0
      DO IS=1,ISWEXT
        ISI=SEXTF%ISWET(IS)%ISI
        KX=SEXTF%ISWET(IS)%ITYP
        DPHI=AEXTF%TP(KX)%DPSTAR
        DPHIC=DPHI/REAL(ISESC)
        ISC=ISC+1
        CEPHI(ISC)%VL=AEXTF%TP(KX)%PHI(ISI)%VL
        CEPHI(ISC)%VR=AEXTF%TP(KX)%PHI(ISI)%VL+DPHIC
        DO IST=2,ISESC
          ISC=ISC+1
          CEPHI(ISC)%VL=CEPHI(ISC-1)%VR
          CEPHI(ISC)%VR=CEPHI(ISC-1)%VR+DPHIC
        ENDDO
      ENDDO
!
!     * CALCULATE SIZES FOR DRY SIZE DISTRIBUTION FOR INTERNALLY MIXED
!     * AEROSOL TYPES.
!
      ISC=0
      DO IS=1,ISWINT
        ISI=SINTF%ISWET(IS)%ISI
        DPHI=AINTF%DPSTAR
        DPHIC=DPHI/REAL(ISESC)
        ISC=ISC+1
        CIPHI(ISC)%VL=AINTF%PHI(ISI)%VL
        CIPHI(ISC)%VR=AINTF%PHI(ISI)%VL+DPHIC
        DO IST=2,ISESC
          ISC=ISC+1
          CIPHI(ISC)%VL=CIPHI(ISC-1)%VR
          CIPHI(ISC)%VR=CIPHI(ISC-1)%VR+DPHIC
        ENDDO
      ENDDO
!
!     * CALCULATE RADII FOR DRY SIZE DISTRIBUTION FOR EXTERNALLY MIXED
!     * AEROSOL TYPES. THE FIRST GROUP OF PARTICLE SIZES (DRYR, DRYRC)
!     * ARE FOR EACH SECTION WHILE THE SECOND GROUP (DRYRB) IS FOR
!     * SECTION BOUNDARIES.
!
      DO ISC=1,ISEXT
        CEDRYR(ISC)%VL=R0*EXP(CEPHI(ISC)%VL)
        CEDRYR(ISC)%VR=R0*EXP(CEPHI(ISC)%VR)
      ENDDO
      DO ISC=1,ISEXT
        DPHIC=CEPHI(ISC)%VR-CEPHI(ISC)%VL
        CEDRYRC(ISC)=R0*EXP(CEPHI(ISC)%VL+.5*DPHIC)
      ENDDO
      IF ( ISEXTB > 0 ) THEN
        ISC=0
        ISX=0
        DO IS=1,ISWEXT-1
          KX=SEXTF%ISWET(IS)%ITYP
          KXP=SEXTF%ISWET(IS+1)%ITYP
          DO IST=1,ISESC
            ISC=ISC+1
            ISX=ISX+1
            CEDRYRB(ISC)=CEDRYR(ISX)%VL
          ENDDO
          IF ( KXP /= KX ) THEN
            ISC=ISC+1
            CEDRYRB(ISC)=CEDRYR(ISX)%VR
          ENDIF
        ENDDO
        DO IST=1,ISESC
          ISC=ISC+1
          ISX=ISX+1
          CEDRYRB(ISC)=CEDRYR(ISX)%VL
        ENDDO
        ISC=ISC+1
        CEDRYRB(ISC)=CEDRYR(ISX)%VR
      ENDIF
!
!     * CALCULATE RADII FOR DRY SIZE DISTRIBUTION FOR INTERNALLY MIXED
!     * AEROSOL TYPES.
!
      DO ISC=1,ISINT
        CIDRYR(ISC)%VL=R0*EXP(CIPHI(ISC)%VL)
        CIDRYR(ISC)%VR=R0*EXP(CIPHI(ISC)%VR)
      ENDDO
      DO ISC=1,ISINT
        DPHIC=CIPHI(ISC)%VR-CIPHI(ISC)%VL
        CIDRYRC(ISC)=R0*EXP(CIPHI(ISC)%VL+.5*DPHIC)
      ENDDO
      IF ( ISINTB > 0 ) THEN
        ISC=0
        ISX=0
        DO IS=1,ISWINT-1
        DO IST=1,ISESC
          ISC=ISC+1
          ISX=ISX+1
          CIDRYRB(ISC)=CIDRYR(ISX)%VL
        ENDDO
        ENDDO
        DO IST=1,ISESC
          ISC=ISC+1
          ISX=ISX+1
          CIDRYRB(ISC)=CIDRYR(ISX)%VL
        ENDDO
        ISC=ISC+1
        CIDRYRB(ISC)=CIDRYR(ISX)%VR
      ENDIF
!
!     * AEROSOL TYPE INDEX (CEKX), CORRESPONDING SECTION INDEX (CEIS),
!     * LOWER SECTION BOUNDARY INDEX (CEISVL), AND UPPER SECTION BOUNDARY
!     * INDEX (CEISVR) FOR SECTION BOUNDARIES FOR EXTERNALLY MIXED TYPES
!     * OF AEROSOL.
!
      IF ( ISEXTB > 0 ) THEN
        ISC=0
        ISX=0
        DO IS=1,ISWEXT-1
          KX=SEXTF%ISWET(IS)%ITYP
          KXP=SEXTF%ISWET(IS+1)%ITYP
          DO IST=1,ISESC
            ISC=ISC+1
            CEKX(ISC)=KX
            CEIS(ISC)=IS
            ISX=ISX+1
            CEISVL(ISX)=ISC
            CEISVR(ISX)=ISC+1
          ENDDO
          IF ( KXP /= KX ) THEN
            ISC=ISC+1
            CEKX(ISC)=KX
            CEIS(ISC)=IS
          ENDIF
        ENDDO
        IS=ISWEXT
        KX=SEXTF%ISWET(IS)%ITYP
        DO IST=1,ISESC
          ISC=ISC+1
          CEKX(ISC)=KX
          CEIS(ISC)=IS
          ISX=ISX+1
          CEISVL(ISX)=ISC
          CEISVR(ISX)=ISC+1
        ENDDO
        ISC=ISC+1
        CEKX(ISC)=KX
        CEIS(ISC)=IS
      ENDIF
!
!     * SECTION INDEX (CIIS), LOWER SECTION BOUNDARY INDEX (CIISVL),
!     * AND UPPER SECTION BOUNDARY INDEX (CIISVR) FOR SECTION
!     * BOUNDARIES FOR INTERNALLY MIXED TYPES OF AEROSOL.
!
      IF ( ISINTB > 0 ) THEN
        ISC=0
        DO IS=1,ISWINT
          DO IST=1,ISESC
            ISC=ISC+1
            CIIS(ISC)=IS
            CIISVL(ISC)=ISC
            CIISVR(ISC)=ISC+1
          ENDDO
        ENDDO
        IS=ISWINT
        ISC=ISC+1
        CIIS(ISC)=IS
      ENDIF
!
      END SUBROUTINE SCCONF
