      SUBROUTINE SDPEMI
!-----------------------------------------------------------------------
!     PURPOSE:
!     --------
!     INITIALIZATION OF BASIC PARAMETERS FOR PRIMARY AEROSOL EMISSIONS.
!
!     HISTORY:
!     --------
!     * FEB  4/2015 - K.VONSALZEN.  NEW VERSION FOR GCM18:
!     *                             - MODE RADIUS FOR {BC,OC,SO4}
!     *                               REDUCED FROM 0.250E-06 TO 0.200E-06
!     *                               FOR OPEN VEGETATION/BIOMASS BURNING,
!     *                               AND FROM 0.070E-06 TO 0.040E-06 FOR
!     *                               FOR FOSSIL FUEL BURNING.
!     * MAR  9/2009 - K.VONSALZEN   NEW. USED UP TO AND INCLUDING GCM17.
!
!-----------------------------------------------------------------------
!
      USE SDCODE
      USE SDPARM
      USE SDEMI
!
      IMPLICIT REAL (A-H,O-Z), INTEGER (I-N)
!
!     * WORK ARRAYS.
!
      REAL, ALLOCATABLE, DIMENSION(:) :: PEOCM1,PEOCN1,PEOCM2,PEOCN2, &
                                         PEOCM3,PEOCN3,PEOCM4,PEOCN4, &
                                         PEBCM1,PEBCN1,PEBCM2,PEBCN2, &
                                         PEBCM3,PEBCN3,PEBCM4,PEBCN4, &
                                         PESUM1,PESUN1,PESUM2,PESUN2, &
                                         PESUM3,PESUN3,PESUM4,PESUN4
      REAL, ALLOCATABLE, DIMENSION(:) :: PIOCM1,PIOCN1,PIOCM2,PIOCN2, &
                                         PIOCM3,PIOCN3,PIOCM4,PIOCN4, &
                                         PIBCM1,PIBCN1,PIBCM2,PIBCN2, &
                                         PIBCM3,PIBCN3,PIBCM4,PIBCN4, &
                                         PISUM1,PISUN1,PISUM2,PISUN2, &
                                         PISUM3,PISUN3,PISUM4,PISUN4
!
!     * INTRINSIC FUNCTIONS.
!
      ZPSI(ARG)=1./(2.*LOG(ARG)**2)
      ZPHI(ARG)=LOG(ARG/R0)
!
!-----------------------------------------------------------------------
!     * SIZE DISTRIBUTION PARAMETERS (MODE RADIUS, VARIANCE)
!     * FOR PRIMARY EMISSIONS OF ORGANIC CARBON. SOURCES: DENTENER
!     * ET AL. (2006), BOND ET AL. (2013), KONDO ET AL. (2011),
!     * PETZOLD ET AL. (1998), SHIRAIWA ET AL. (2008), SEINFELD.
!
!     * NATURAL AND ANTHROPOGENIC EMISSIONS IN FOLLOWING ORDER:
!     * 1 - OPEN VEGETATION AND BIOFUEL BURNING
!     * 2 - FOSSIL FUEL BURNING
!     * 3 - AIRCRAFT
!     * 4 - SHIPPING
!
      OCE1%RADMS=0.050E-06
      OCE1%SIGMS=1.3
      OCE2%RADMS=0.020E-06
      OCE2%SIGMS=1.8
      OCE3%RADMS=0.250E-06
      OCE3%SIGMS=1.3
      OCE4%RADMS=0.250E-06
      OCE4%SIGMS=1.3
!
!     * THE SAME AS ABOVE FOR BLACK CARBON.
!
      BCE1%RADMS=0.050E-06
      BCE1%SIGMS=1.3
      BCE2%RADMS=0.020E-06
      BCE2%SIGMS=1.8
      BCE3%RADMS=0.250E-06
      BCE3%SIGMS=1.3
      BCE4%RADMS=0.250E-06
      BCE4%SIGMS=1.3
!
!     * THE SAME AS ABOVE FOR SULPHATE.
!
      SUE1%RADMS=0.050E-06
      SUE1%SIGMS=1.3
      SUE2%RADMS=0.020E-06
      SUE2%SIGMS=1.8
      SUE3%RADMS=0.250E-06
      SUE3%SIGMS=1.3
      SUE4%RADMS=0.250E-06
      SUE4%SIGMS=1.3
!
!     * FRACTION OF EMISSIONS THAT GO INTO PRIMARY PARTICLE EMISSIONS
!     * VS. TOTAL (GAS-PHASE + PRIMARY) EMISSIONS.
!
      OCE1%CNVEFF=1.
      OCE2%CNVEFF=1.
      OCE3%CNVEFF=1.
      OCE4%CNVEFF=1.
      BCE1%CNVEFF=1.
      BCE2%CNVEFF=1.
      BCE3%CNVEFF=1.
      BCE4%CNVEFF=1.
      SUE1%CNVEFF=0.025
      SUE2%CNVEFF=0.025
      SUE3%CNVEFF=0.025
      SUE4%CNVEFF=0.025
!
!-----------------------------------------------------------------------
!     * ALLOCATE WORK ARRAYS AND INITIALIZATION OF CONTSTANTS.
!
      IF ( ISEXTOC > 0 ) THEN
        ALLOCATE(PEOCM1(ISEXTOC))
        ALLOCATE(PEOCN1(ISEXTOC))
        ALLOCATE(PEOCM2(ISEXTOC))
        ALLOCATE(PEOCN2(ISEXTOC))
        ALLOCATE(PEOCM3(ISEXTOC))
        ALLOCATE(PEOCN3(ISEXTOC))
        ALLOCATE(PEOCM4(ISEXTOC))
        ALLOCATE(PEOCN4(ISEXTOC))
      ENDIF
      IF ( ISEXTBC > 0 ) THEN
        ALLOCATE(PEBCM1(ISEXTBC))
        ALLOCATE(PEBCN1(ISEXTBC))
        ALLOCATE(PEBCM2(ISEXTBC))
        ALLOCATE(PEBCN2(ISEXTBC))
        ALLOCATE(PEBCM3(ISEXTBC))
        ALLOCATE(PEBCN3(ISEXTBC))
        ALLOCATE(PEBCM4(ISEXTBC))
        ALLOCATE(PEBCN4(ISEXTBC))
      ENDIF
      IF ( ISEXTSO4 > 0 ) THEN
        ALLOCATE(PESUM1(ISEXTSO4))
        ALLOCATE(PESUN1(ISEXTSO4))
        ALLOCATE(PESUM2(ISEXTSO4))
        ALLOCATE(PESUN2(ISEXTSO4))
        ALLOCATE(PESUM3(ISEXTSO4))
        ALLOCATE(PESUN3(ISEXTSO4))
        ALLOCATE(PESUM4(ISEXTSO4))
        ALLOCATE(PESUN4(ISEXTSO4))
      ENDIF
      IF ( ISINTOC > 0 ) THEN
        ALLOCATE(PIOCM1(ISINTOC))
        ALLOCATE(PIOCN1(ISINTOC))
        ALLOCATE(PIOCM2(ISINTOC))
        ALLOCATE(PIOCN2(ISINTOC))
        ALLOCATE(PIOCM3(ISINTOC))
        ALLOCATE(PIOCN3(ISINTOC))
        ALLOCATE(PIOCM4(ISINTOC))
        ALLOCATE(PIOCN4(ISINTOC))
      ENDIF
      IF ( ISINTBC > 0 ) THEN
        ALLOCATE(PIBCM1(ISINTBC))
        ALLOCATE(PIBCN1(ISINTBC))
        ALLOCATE(PIBCM2(ISINTBC))
        ALLOCATE(PIBCN2(ISINTBC))
        ALLOCATE(PIBCM3(ISINTBC))
        ALLOCATE(PIBCN3(ISINTBC))
        ALLOCATE(PIBCM4(ISINTBC))
        ALLOCATE(PIBCN4(ISINTBC))
      ENDIF
      IF ( ISINTSO4 > 0 ) THEN
        ALLOCATE(PISUM1(ISINTSO4))
        ALLOCATE(PISUN1(ISINTSO4))
        ALLOCATE(PISUM2(ISINTSO4))
        ALLOCATE(PISUN2(ISINTSO4))
        ALLOCATE(PISUM3(ISINTSO4))
        ALLOCATE(PISUN3(ISINTSO4))
        ALLOCATE(PISUM4(ISINTSO4))
        ALLOCATE(PISUN4(ISINTSO4))
      ENDIF
      RMOM=3.
!
!-----------------------------------------------------------------------
!     * PLA PARAMETERS FOR PRIMARY EMISSIONS OF ORGANIC CARBON.
!
      IF ( KEXTOC > 0 ) THEN
        PEOCT1%PHI0=ZPHI(OCE1%RADMS)
        PEOCT1%PSI =ZPSI(OCE1%SIGMS)
        PEOCT2%PHI0=ZPHI(OCE2%RADMS)
        PEOCT2%PSI =ZPSI(OCE2%SIGMS)
        PEOCT3%PHI0=ZPHI(OCE3%RADMS)
        PEOCT3%PSI =ZPSI(OCE3%SIGMS)
        PEOCT4%PHI0=ZPHI(OCE4%RADMS)
        PEOCT4%PSI =ZPSI(OCE4%SIGMS)
      ENDIF
      IF ( KINTOC > 0 ) THEN
        PIOCT1%PHI0=ZPHI(OCE1%RADMS)
        PIOCT1%PSI =ZPSI(OCE1%SIGMS)
        PIOCT2%PHI0=ZPHI(OCE2%RADMS)
        PIOCT2%PSI =ZPSI(OCE2%SIGMS)
        PIOCT3%PHI0=ZPHI(OCE3%RADMS)
        PIOCT3%PSI =ZPSI(OCE3%SIGMS)
        PIOCT4%PHI0=ZPHI(OCE4%RADMS)
        PIOCT4%PSI =ZPSI(OCE4%SIGMS)
      ENDIF
!
!     * PLA PARAMETERS FOR PRIMARY EMISSIONS OF BLACK CARBON.
!
      IF ( KEXTBC > 0 ) THEN
        PEBCT1%PHI0=ZPHI(BCE1%RADMS)
        PEBCT1%PSI =ZPSI(BCE1%SIGMS)
        PEBCT2%PHI0=ZPHI(BCE2%RADMS)
        PEBCT2%PSI =ZPSI(BCE2%SIGMS)
        PEBCT3%PHI0=ZPHI(BCE3%RADMS)
        PEBCT3%PSI =ZPSI(BCE3%SIGMS)
        PEBCT4%PHI0=ZPHI(BCE4%RADMS)
        PEBCT4%PSI =ZPSI(BCE4%SIGMS)
      ENDIF
      IF ( KINTBC > 0 ) THEN
        PIBCT1%PHI0=ZPHI(BCE1%RADMS)
        PIBCT1%PSI =ZPSI(BCE1%SIGMS)
        PIBCT2%PHI0=ZPHI(BCE2%RADMS)
        PIBCT2%PSI =ZPSI(BCE2%SIGMS)
        PIBCT3%PHI0=ZPHI(BCE3%RADMS)
        PIBCT3%PSI =ZPSI(BCE3%SIGMS)
        PIBCT4%PHI0=ZPHI(BCE4%RADMS)
        PIBCT4%PSI =ZPSI(BCE4%SIGMS)
      ENDIF
!
!     * PLA PARAMETERS FOR PRIMARY EMISSIONS OF SULPHATE.
!
      IF ( KEXTSO4 > 0 ) THEN
        PESUT1%PHI0=ZPHI(SUE1%RADMS)
        PESUT1%PSI =ZPSI(SUE1%SIGMS)
        PESUT2%PHI0=ZPHI(SUE2%RADMS)
        PESUT2%PSI =ZPSI(SUE2%SIGMS)
        PESUT3%PHI0=ZPHI(SUE3%RADMS)
        PESUT3%PSI =ZPSI(SUE3%SIGMS)
        PESUT4%PHI0=ZPHI(SUE4%RADMS)
        PESUT4%PSI =ZPSI(SUE4%SIGMS)
      ENDIF
      IF ( KINTSO4 > 0 ) THEN
        PISUT1%PHI0=ZPHI(SUE1%RADMS)
        PISUT1%PSI =ZPSI(SUE1%SIGMS)
        PISUT2%PHI0=ZPHI(SUE2%RADMS)
        PISUT2%PSI =ZPSI(SUE2%SIGMS)
        PISUT3%PHI0=ZPHI(SUE3%RADMS)
        PISUT3%PSI =ZPSI(SUE3%SIGMS)
        PISUT4%PHI0=ZPHI(SUE4%RADMS)
        PISUT4%PSI =ZPSI(SUE4%SIGMS)
      ENDIF
!
!-----------------------------------------------------------------------
!     * INTEGRATE OVER EMISSION SIZE DISTRIBUTIONS FOR NATURAL
!     * AND ANTHROPOGENIC EMISSIONS OF ORGANIC AND BLACK CARBON.
!     * FOR EXTERNALLY MIXED TYPES OF AEROSOL.
!
      IF ( KEXTOC > 0 ) THEN
        OCDDN=AEXTF%TP(KEXTOC)%DENS
        PEOCM1T=0.
        PEOCM2T=0.
        PEOCM3T=0.
        PEOCM4T=0.
        DO IS=1,ISEXTOC
          PHIS0=PEPHISS(IEXOC(IS))
          DPHI0=PEDPHIS(IEXOC(IS))
          PEOCN1(IS)=SDINTB0(PEOCT1%PHI0,PEOCT1%PSI,PHIS0,DPHI0)
          PEOCM1(IS)=OCDDN*YCNST &
                   *SDINTB(PEOCT1%PHI0,PEOCT1%PSI,RMOM,PHIS0,DPHI0)
          PEOCM1T=PEOCM1T+PEOCM1(IS)
          PEOCN2(IS)=SDINTB0(PEOCT2%PHI0,PEOCT2%PSI,PHIS0,DPHI0)
          PEOCM2(IS)=OCDDN*YCNST &
                   *SDINTB(PEOCT2%PHI0,PEOCT2%PSI,RMOM,PHIS0,DPHI0)
          PEOCM2T=PEOCM2T+PEOCM2(IS)
          PEOCN3(IS)=SDINTB0(PEOCT3%PHI0,PEOCT3%PSI,PHIS0,DPHI0)
          PEOCM3(IS)=OCDDN*YCNST &
                   *SDINTB(PEOCT3%PHI0,PEOCT3%PSI,RMOM,PHIS0,DPHI0)
          PEOCM3T=PEOCM3T+PEOCM3(IS)
          PEOCN4(IS)=SDINTB0(PEOCT4%PHI0,PEOCT4%PSI,PHIS0,DPHI0)
          PEOCM4(IS)=OCDDN*YCNST &
                   *SDINTB(PEOCT4%PHI0,PEOCT4%PSI,RMOM,PHIS0,DPHI0)
          PEOCM4T=PEOCM4T+PEOCM4(IS)
        ENDDO
      ENDIF
      IF ( KEXTBC > 0 ) THEN
        BCDDN=AEXTF%TP(KEXTBC)%DENS
        PEBCM1T=0.
        PEBCM2T=0.
        PEBCM3T=0.
        PEBCM4T=0.
        DO IS=1,ISEXTBC
          PHIS0=PEPHISS(IEXBC(IS))
          DPHI0=PEDPHIS(IEXBC(IS))
          PEBCN1(IS)=SDINTB0(PEBCT1%PHI0,PEBCT1%PSI,PHIS0,DPHI0)
          PEBCM1(IS)=BCDDN*YCNST &
                   *SDINTB(PEBCT1%PHI0,PEBCT1%PSI,RMOM,PHIS0,DPHI0)
          PEBCM1T=PEBCM1T+PEBCM1(IS)
          PEBCN2(IS)=SDINTB0(PEBCT2%PHI0,PEBCT2%PSI,PHIS0,DPHI0)
          PEBCM2(IS)=BCDDN*YCNST &
                   *SDINTB(PEBCT2%PHI0,PEBCT2%PSI,RMOM,PHIS0,DPHI0)
          PEBCM2T=PEBCM2T+PEBCM2(IS)
          PEBCN3(IS)=SDINTB0(PEBCT3%PHI0,PEBCT3%PSI,PHIS0,DPHI0)
          PEBCM3(IS)=BCDDN*YCNST &
                   *SDINTB(PEBCT3%PHI0,PEBCT3%PSI,RMOM,PHIS0,DPHI0)
          PEBCM3T=PEBCM3T+PEBCM3(IS)
          PEBCN4(IS)=SDINTB0(PEBCT4%PHI0,PEBCT4%PSI,PHIS0,DPHI0)
          PEBCM4(IS)=BCDDN*YCNST &
                   *SDINTB(PEBCT4%PHI0,PEBCT4%PSI,RMOM,PHIS0,DPHI0)
          PEBCM4T=PEBCM4T+PEBCM4(IS)
        ENDDO
      ENDIF
      IF ( KEXTSO4 > 0 ) THEN
        SUDDN=AEXTF%TP(KEXTSO4)%DENS
        PESUM1T=0.
        PESUM2T=0.
        PESUM3T=0.
        PESUM4T=0.
        DO IS=1,ISEXTSO4
          PHIS0=PEPHISS(IEXSO4(IS))
          DPHI0=PEDPHIS(IEXSO4(IS))
          PESUN1(IS)=SDINTB0(PESUT1%PHI0,PESUT1%PSI,PHIS0,DPHI0)
          PESUM1(IS)=SUDDN*YCNST &
                   *SDINTB(PESUT1%PHI0,PESUT1%PSI,RMOM,PHIS0,DPHI0)
          PESUM1T=PESUM1T+PESUM1(IS)
          PESUN2(IS)=SDINTB0(PESUT2%PHI0,PESUT2%PSI,PHIS0,DPHI0)
          PESUM2(IS)=SUDDN*YCNST &
                   *SDINTB(PESUT2%PHI0,PESUT2%PSI,RMOM,PHIS0,DPHI0)
          PESUM2T=PESUM2T+PESUM2(IS)
          PESUN3(IS)=SDINTB0(PESUT3%PHI0,PESUT3%PSI,PHIS0,DPHI0)
          PESUM3(IS)=SUDDN*YCNST &
                   *SDINTB(PESUT3%PHI0,PESUT3%PSI,RMOM,PHIS0,DPHI0)
          PESUM3T=PESUM3T+PESUM3(IS)
          PESUN4(IS)=SDINTB0(PESUT4%PHI0,PESUT4%PSI,PHIS0,DPHI0)
          PESUM4(IS)=SUDDN*YCNST &
                   *SDINTB(PESUT4%PHI0,PESUT4%PSI,RMOM,PHIS0,DPHI0)
          PESUM4T=PESUM4T+PESUM4(IS)
        ENDDO
      ENDIF
!
!     * THE SAME AS ABOVE FOR INTERNALLY MIXED AEROSOL.
!
      IF ( KINTOC > 0 ) THEN
        OCDDN=AINTF%TP(KINTOC)%DENS
        PIOCM1T=0.
        PIOCM2T=0.
        PIOCM3T=0.
        PIOCM4T=0.
        DO IS=1,ISINTOC
          PHIS0=PIPHISS(IINOC(IS))
          DPHI0=PIDPHIS(IINOC(IS))
          PIOCN1(IS)=SDINTB0(PIOCT1%PHI0,PIOCT1%PSI,PHIS0,DPHI0)
          PIOCM1(IS)=OCDDN*YCNST &
                   *SDINTB(PIOCT1%PHI0,PIOCT1%PSI,RMOM,PHIS0,DPHI0)
          PIOCM1T=PIOCM1T+PIOCM1(IS)
          PIOCN2(IS)=SDINTB0(PIOCT2%PHI0,PIOCT2%PSI,PHIS0,DPHI0)
          PIOCM2(IS)=OCDDN*YCNST &
                   *SDINTB(PIOCT2%PHI0,PIOCT2%PSI,RMOM,PHIS0,DPHI0)
          PIOCM2T=PIOCM2T+PIOCM2(IS)
          PIOCN3(IS)=SDINTB0(PIOCT3%PHI0,PIOCT3%PSI,PHIS0,DPHI0)
          PIOCM3(IS)=OCDDN*YCNST &
                   *SDINTB(PIOCT3%PHI0,PIOCT3%PSI,RMOM,PHIS0,DPHI0)
          PIOCM3T=PIOCM3T+PIOCM3(IS)
          PIOCN4(IS)=SDINTB0(PIOCT4%PHI0,PIOCT4%PSI,PHIS0,DPHI0)
          PIOCM4(IS)=OCDDN*YCNST &
                   *SDINTB(PIOCT4%PHI0,PIOCT4%PSI,RMOM,PHIS0,DPHI0)
          PIOCM4T=PIOCM4T+PIOCM4(IS)
        ENDDO
      ENDIF
      IF ( KINTBC > 0 ) THEN
        BCDDN=AINTF%TP(KINTBC)%DENS
        PIBCM1T=0.
        PIBCM2T=0.
        PIBCM3T=0.
        PIBCM4T=0.
        DO IS=1,ISINTBC
          PHIS0=PIPHISS(IINBC(IS))
          DPHI0=PIDPHIS(IINBC(IS))
          PIBCN1(IS)=SDINTB0(PIBCT1%PHI0,PIBCT1%PSI,PHIS0,DPHI0)
          PIBCM1(IS)=BCDDN*YCNST &
                   *SDINTB(PIBCT1%PHI0,PIBCT1%PSI,RMOM,PHIS0,DPHI0)
          PIBCM1T=PIBCM1T+PIBCM1(IS)
          PIBCN2(IS)=SDINTB0(PIBCT2%PHI0,PIBCT2%PSI,PHIS0,DPHI0)
          PIBCM2(IS)=BCDDN*YCNST &
                   *SDINTB(PIBCT2%PHI0,PIBCT2%PSI,RMOM,PHIS0,DPHI0)
          PIBCM2T=PIBCM2T+PIBCM2(IS)
          PIBCN3(IS)=SDINTB0(PIBCT3%PHI0,PIBCT3%PSI,PHIS0,DPHI0)
          PIBCM3(IS)=BCDDN*YCNST &
                   *SDINTB(PIBCT3%PHI0,PIBCT3%PSI,RMOM,PHIS0,DPHI0)
          PIBCM3T=PIBCM3T+PIBCM3(IS)
          PIBCN4(IS)=SDINTB0(PIBCT4%PHI0,PIBCT4%PSI,PHIS0,DPHI0)
          PIBCM4(IS)=BCDDN*YCNST &
                   *SDINTB(PIBCT4%PHI0,PIBCT4%PSI,RMOM,PHIS0,DPHI0)
          PIBCM4T=PIBCM4T+PIBCM4(IS)
        ENDDO
      ENDIF
      IF ( KINTSO4 > 0 ) THEN
        SUDDN=AINTF%TP(KINTSO4)%DENS
        PISUM1T=0.
        PISUM2T=0.
        PISUM3T=0.
        PISUM4T=0.
        DO IS=1,ISINTSO4
          PHIS0=PIPHISS(IINSO4(IS))
          DPHI0=PIDPHIS(IINSO4(IS))
          PISUN1(IS)=SDINTB0(PISUT1%PHI0,PISUT1%PSI,PHIS0,DPHI0)
          PISUM1(IS)=SUDDN*YCNST &
                   *SDINTB(PISUT1%PHI0,PISUT1%PSI,RMOM,PHIS0,DPHI0)
          PISUM1T=PISUM1T+PISUM1(IS)
          PISUN2(IS)=SDINTB0(PISUT2%PHI0,PISUT2%PSI,PHIS0,DPHI0)
          PISUM2(IS)=SUDDN*YCNST &
                   *SDINTB(PISUT2%PHI0,PISUT2%PSI,RMOM,PHIS0,DPHI0)
          PISUM2T=PISUM2T+PISUM2(IS)
          PISUN3(IS)=SDINTB0(PISUT3%PHI0,PISUT3%PSI,PHIS0,DPHI0)
          PISUM3(IS)=SUDDN*YCNST &
                   *SDINTB(PISUT3%PHI0,PISUT3%PSI,RMOM,PHIS0,DPHI0)
          PISUM3T=PISUM3T+PISUM3(IS)
          PISUN4(IS)=SDINTB0(PISUT4%PHI0,PISUT4%PSI,PHIS0,DPHI0)
          PISUM4(IS)=SUDDN*YCNST &
                   *SDINTB(PISUT4%PHI0,PISUT4%PSI,RMOM,PHIS0,DPHI0)
          PISUM4T=PISUM4T+PISUM4(IS)
        ENDDO
      ENDIF
!
!-----------------------------------------------------------------------
!     * ALLOCATE EMISSION MASS FRACTIONS.
!
      IF ( ISEXTOC > 0 ) THEN
        IF(ALLOCATED(PEOCT1%EFMAS)) DEALLOCATE(PEOCT1%EFMAS)
        ALLOCATE(PEOCT1%EFMAS(ISEXTOC))
        IF(ALLOCATED(PEOCT1%EFNUM)) DEALLOCATE(PEOCT1%EFNUM)
        ALLOCATE(PEOCT1%EFNUM(ISEXTOC))
        IF(ALLOCATED(PEOCT2%EFMAS)) DEALLOCATE(PEOCT2%EFMAS)
        ALLOCATE(PEOCT2%EFMAS(ISEXTOC))
        IF(ALLOCATED(PEOCT2%EFNUM)) DEALLOCATE(PEOCT2%EFNUM)
        ALLOCATE(PEOCT2%EFNUM(ISEXTOC))
        IF(ALLOCATED(PEOCT3%EFMAS)) DEALLOCATE(PEOCT3%EFMAS)
        ALLOCATE(PEOCT3%EFMAS(ISEXTOC))
        IF(ALLOCATED(PEOCT3%EFNUM)) DEALLOCATE(PEOCT3%EFNUM)
        ALLOCATE(PEOCT3%EFNUM(ISEXTOC))
        IF(ALLOCATED(PEOCT4%EFMAS)) DEALLOCATE(PEOCT4%EFMAS)
        ALLOCATE(PEOCT4%EFMAS(ISEXTOC))
        IF(ALLOCATED(PEOCT4%EFNUM)) DEALLOCATE(PEOCT4%EFNUM)
        ALLOCATE(PEOCT4%EFNUM(ISEXTOC))
      ENDIF
      IF ( ISEXTBC > 0 ) THEN
        IF(ALLOCATED(PEBCT1%EFMAS)) DEALLOCATE(PEBCT1%EFMAS)
        ALLOCATE(PEBCT1%EFMAS(ISEXTBC))
        IF(ALLOCATED(PEBCT1%EFNUM)) DEALLOCATE(PEBCT1%EFNUM)
        ALLOCATE(PEBCT1%EFNUM(ISEXTBC))
        IF(ALLOCATED(PEBCT2%EFMAS)) DEALLOCATE(PEBCT2%EFMAS)
        ALLOCATE(PEBCT2%EFMAS(ISEXTBC))
        IF(ALLOCATED(PEBCT2%EFNUM)) DEALLOCATE(PEBCT2%EFNUM)
        ALLOCATE(PEBCT2%EFNUM(ISEXTBC))
        IF(ALLOCATED(PEBCT3%EFMAS)) DEALLOCATE(PEBCT3%EFMAS)
        ALLOCATE(PEBCT3%EFMAS(ISEXTBC))
        IF(ALLOCATED(PEBCT3%EFNUM)) DEALLOCATE(PEBCT3%EFNUM)
        ALLOCATE(PEBCT3%EFNUM(ISEXTBC))
        IF(ALLOCATED(PEBCT4%EFMAS)) DEALLOCATE(PEBCT4%EFMAS)
        ALLOCATE(PEBCT4%EFMAS(ISEXTBC))
        IF(ALLOCATED(PEBCT4%EFNUM)) DEALLOCATE(PEBCT4%EFNUM)
        ALLOCATE(PEBCT4%EFNUM(ISEXTBC))
      ENDIF
      IF ( ISEXTSO4 > 0 ) THEN
        IF(ALLOCATED(PESUT1%EFMAS)) DEALLOCATE(PESUT1%EFMAS)
        ALLOCATE(PESUT1%EFMAS(ISEXTSO4))
        IF(ALLOCATED(PESUT1%EFNUM)) DEALLOCATE(PESUT1%EFNUM)
        ALLOCATE(PESUT1%EFNUM(ISEXTSO4))
        IF(ALLOCATED(PESUT2%EFMAS)) DEALLOCATE(PESUT2%EFMAS)
        ALLOCATE(PESUT2%EFMAS(ISEXTSO4))
        IF(ALLOCATED(PESUT2%EFNUM)) DEALLOCATE(PESUT2%EFNUM)
        ALLOCATE(PESUT2%EFNUM(ISEXTSO4))
        IF(ALLOCATED(PESUT3%EFMAS)) DEALLOCATE(PESUT3%EFMAS)
        ALLOCATE(PESUT3%EFMAS(ISEXTSO4))
        IF(ALLOCATED(PESUT3%EFNUM)) DEALLOCATE(PESUT3%EFNUM)
        ALLOCATE(PESUT3%EFNUM(ISEXTSO4))
        IF(ALLOCATED(PESUT4%EFMAS)) DEALLOCATE(PESUT4%EFMAS)
        ALLOCATE(PESUT4%EFMAS(ISEXTSO4))
        IF(ALLOCATED(PESUT4%EFNUM)) DEALLOCATE(PESUT4%EFNUM)
        ALLOCATE(PESUT4%EFNUM(ISEXTSO4))
      ENDIF
      IF ( ISINTOC > 0 ) THEN
        IF(ALLOCATED(PIOCT1%EFMAS)) DEALLOCATE(PIOCT1%EFMAS)
        ALLOCATE(PIOCT1%EFMAS(ISINTOC))
        IF(ALLOCATED(PIOCT1%EFNUM)) DEALLOCATE(PIOCT1%EFNUM)
        ALLOCATE(PIOCT1%EFNUM(ISINTOC))
        IF(ALLOCATED(PIOCT2%EFMAS)) DEALLOCATE(PIOCT2%EFMAS)
        ALLOCATE(PIOCT2%EFMAS(ISINTOC))
        IF(ALLOCATED(PIOCT2%EFNUM)) DEALLOCATE(PIOCT2%EFNUM)
        ALLOCATE(PIOCT2%EFNUM(ISINTOC))
        IF(ALLOCATED(PIOCT3%EFMAS)) DEALLOCATE(PIOCT3%EFMAS)
        ALLOCATE(PIOCT3%EFMAS(ISINTOC))
        IF(ALLOCATED(PIOCT3%EFNUM)) DEALLOCATE(PIOCT3%EFNUM)
        ALLOCATE(PIOCT3%EFNUM(ISINTOC))
        IF(ALLOCATED(PIOCT4%EFMAS)) DEALLOCATE(PIOCT4%EFMAS)
        ALLOCATE(PIOCT4%EFMAS(ISINTOC))
        IF(ALLOCATED(PIOCT4%EFNUM)) DEALLOCATE(PIOCT4%EFNUM)
        ALLOCATE(PIOCT4%EFNUM(ISINTOC))
      ENDIF
      IF ( ISINTBC > 0 ) THEN
        IF(ALLOCATED(PIBCT1%EFMAS)) DEALLOCATE(PIBCT1%EFMAS)
        ALLOCATE(PIBCT1%EFMAS(ISINTBC))
        IF(ALLOCATED(PIBCT1%EFNUM)) DEALLOCATE(PIBCT1%EFNUM)
        ALLOCATE(PIBCT1%EFNUM(ISINTBC))
        IF(ALLOCATED(PIBCT2%EFMAS)) DEALLOCATE(PIBCT2%EFMAS)
        ALLOCATE(PIBCT2%EFMAS(ISINTBC))
        IF(ALLOCATED(PIBCT2%EFNUM)) DEALLOCATE(PIBCT2%EFNUM)
        ALLOCATE(PIBCT2%EFNUM(ISINTBC))
        IF(ALLOCATED(PIBCT3%EFMAS)) DEALLOCATE(PIBCT3%EFMAS)
        ALLOCATE(PIBCT3%EFMAS(ISINTBC))
        IF(ALLOCATED(PIBCT3%EFNUM)) DEALLOCATE(PIBCT3%EFNUM)
        ALLOCATE(PIBCT3%EFNUM(ISINTBC))
        IF(ALLOCATED(PIBCT4%EFMAS)) DEALLOCATE(PIBCT4%EFMAS)
        ALLOCATE(PIBCT4%EFMAS(ISINTBC))
        IF(ALLOCATED(PIBCT4%EFNUM)) DEALLOCATE(PIBCT4%EFNUM)
        ALLOCATE(PIBCT4%EFNUM(ISINTBC))
      ENDIF
      IF ( ISINTSO4 > 0 ) THEN
        IF(ALLOCATED(PISUT1%EFMAS)) DEALLOCATE(PISUT1%EFMAS)
        ALLOCATE(PISUT1%EFMAS(ISINTSO4))
        IF(ALLOCATED(PISUT1%EFNUM)) DEALLOCATE(PISUT1%EFNUM)
        ALLOCATE(PISUT1%EFNUM(ISINTSO4))
        IF(ALLOCATED(PISUT2%EFMAS)) DEALLOCATE(PISUT2%EFMAS)
        ALLOCATE(PISUT2%EFMAS(ISINTSO4))
        IF(ALLOCATED(PISUT2%EFNUM)) DEALLOCATE(PISUT2%EFNUM)
        ALLOCATE(PISUT2%EFNUM(ISINTSO4))
        IF(ALLOCATED(PISUT3%EFMAS)) DEALLOCATE(PISUT3%EFMAS)
        ALLOCATE(PISUT3%EFMAS(ISINTSO4))
        IF(ALLOCATED(PISUT3%EFNUM)) DEALLOCATE(PISUT3%EFNUM)
        ALLOCATE(PISUT3%EFNUM(ISINTSO4))
        IF(ALLOCATED(PISUT4%EFMAS)) DEALLOCATE(PISUT4%EFMAS)
        ALLOCATE(PISUT4%EFMAS(ISINTSO4))
        IF(ALLOCATED(PISUT4%EFNUM)) DEALLOCATE(PISUT4%EFNUM)
        ALLOCATE(PISUT4%EFNUM(ISINTSO4))
      ENDIF
!
!-----------------------------------------------------------------------
!     * DETERMINE EMISSION MASS AND NUMBER FRACTIONS. MULTIPLICATION
!     * WITH TOTAL MASS CONCENTRATION YIELDS THE MASS RESP. NUMBER
!     * CONCENTRATION IN EACH AEROSOL SIZE SECTION. FIRST, FOR
!     * EXTERNALLY MIXED TYPES OF AEROSOL.
!
      IF ( ISEXTOC > 0 ) THEN
        IF ( PEOCM1T > YTINY ) THEN
          DO IS=1,ISEXTOC
            PEOCT1%EFMAS(IS)=PEOCM1(IS)/PEOCM1T
            PEOCT1%EFNUM(IS)=PEOCN1(IS)/PEOCM1T
          ENDDO
        ELSE
          PEOCT1%EFMAS=0.
          PEOCT1%EFNUM=0.
        ENDIF
        IF ( PEOCM2T > YTINY ) THEN
          DO IS=1,ISEXTOC
            PEOCT2%EFMAS(IS)=PEOCM2(IS)/PEOCM2T
            PEOCT2%EFNUM(IS)=PEOCN2(IS)/PEOCM2T
          ENDDO
        ELSE
          PEOCT2%EFMAS=0.
          PEOCT2%EFNUM=0.
        ENDIF
        IF ( PEOCM3T > YTINY ) THEN
          DO IS=1,ISEXTOC
            PEOCT3%EFMAS(IS)=PEOCM3(IS)/PEOCM3T
            PEOCT3%EFNUM(IS)=PEOCN3(IS)/PEOCM3T
          ENDDO
        ELSE
          PEOCT3%EFMAS=0.
          PEOCT3%EFNUM=0.
        ENDIF
        IF ( PEOCM4T > YTINY ) THEN
          DO IS=1,ISEXTOC
            PEOCT4%EFMAS(IS)=PEOCM4(IS)/PEOCM4T
            PEOCT4%EFNUM(IS)=PEOCN4(IS)/PEOCM4T
          ENDDO
        ELSE
          PEOCT4%EFMAS=0.
          PEOCT4%EFNUM=0.
        ENDIF
      ENDIF
      IF ( ISEXTBC > 0 ) THEN
        IF ( PEBCM1T > YTINY ) THEN
          DO IS=1,ISEXTBC
            PEBCT1%EFMAS(IS)=PEBCM1(IS)/PEBCM1T
            PEBCT1%EFNUM(IS)=PEBCN1(IS)/PEBCM1T
          ENDDO
        ELSE
          PEBCT1%EFMAS=0.
          PEBCT1%EFNUM=0.
        ENDIF
        IF ( PEBCM2T > YTINY ) THEN
          DO IS=1,ISEXTBC
            PEBCT2%EFMAS(IS)=PEBCM2(IS)/PEBCM2T
            PEBCT2%EFNUM(IS)=PEBCN2(IS)/PEBCM2T
          ENDDO
        ELSE
          PEBCT2%EFMAS=0.
          PEBCT2%EFNUM=0.
        ENDIF
        IF ( PEBCM3T > YTINY ) THEN
          DO IS=1,ISEXTBC
            PEBCT3%EFMAS(IS)=PEBCM3(IS)/PEBCM3T
            PEBCT3%EFNUM(IS)=PEBCN3(IS)/PEBCM3T
          ENDDO
        ELSE
          PEBCT3%EFMAS=0.
          PEBCT3%EFNUM=0.
        ENDIF
        IF ( PEBCM4T > YTINY ) THEN
          DO IS=1,ISEXTBC
            PEBCT4%EFMAS(IS)=PEBCM4(IS)/PEBCM4T
            PEBCT4%EFNUM(IS)=PEBCN4(IS)/PEBCM4T
          ENDDO
        ELSE
          PEBCT4%EFMAS=0.
          PEBCT4%EFNUM=0.
        ENDIF
      ENDIF
      IF ( ISEXTSO4 > 0 ) THEN
        IF ( PESUM1T > YTINY ) THEN
          DO IS=1,ISEXTSO4
            PESUT1%EFMAS(IS)=PESUM1(IS)/PESUM1T
            PESUT1%EFNUM(IS)=PESUN1(IS)/PESUM1T
          ENDDO
        ELSE
          PESUT1%EFMAS=0.
          PESUT1%EFNUM=0.
        ENDIF
        IF ( PESUM2T > YTINY ) THEN
          DO IS=1,ISEXTSO4
            PESUT2%EFMAS(IS)=PESUM2(IS)/PESUM2T
            PESUT2%EFNUM(IS)=PESUN2(IS)/PESUM2T
          ENDDO
        ELSE
          PESUT2%EFMAS=0.
          PESUT2%EFNUM=0.
        ENDIF
        IF ( PESUM3T > YTINY ) THEN
          DO IS=1,ISEXTSO4
            PESUT3%EFMAS(IS)=PESUM3(IS)/PESUM3T
            PESUT3%EFNUM(IS)=PESUN3(IS)/PESUM3T
          ENDDO
        ELSE
          PESUT3%EFMAS=0.
          PESUT3%EFNUM=0.
        ENDIF
        IF ( PESUM4T > YTINY ) THEN
          DO IS=1,ISEXTSO4
            PESUT4%EFMAS(IS)=PESUM4(IS)/PESUM4T
            PESUT4%EFNUM(IS)=PESUN4(IS)/PESUM4T
          ENDDO
        ELSE
          PESUT4%EFMAS=0.
          PESUT4%EFNUM=0.
        ENDIF
      ENDIF
!
!     * THE SAME AS ABOVE FOR INTERNALLY MIXED TYPES OF AEROSOL.
!
      IF ( ISINTOC > 0 ) THEN
        IF ( PIOCM1T > YTINY ) THEN
          DO IS=1,ISINTOC
            PIOCT1%EFMAS(IS)=PIOCM1(IS)/PIOCM1T
            PIOCT1%EFNUM(IS)=PIOCN1(IS)/PIOCM1T
          ENDDO
        ELSE
          PIOCT1%EFMAS=0.
          PIOCT1%EFNUM=0.
        ENDIF
        IF ( PIOCM2T > YTINY ) THEN
          DO IS=1,ISINTOC
            PIOCT2%EFMAS(IS)=PIOCM2(IS)/PIOCM2T
            PIOCT2%EFNUM(IS)=PIOCN2(IS)/PIOCM2T
          ENDDO
        ELSE
          PIOCT2%EFMAS=0.
          PIOCT2%EFNUM=0.
        ENDIF
        IF ( PIOCM3T > YTINY ) THEN
          DO IS=1,ISINTOC
            PIOCT3%EFMAS(IS)=PIOCM3(IS)/PIOCM3T
            PIOCT3%EFNUM(IS)=PIOCN3(IS)/PIOCM3T
          ENDDO
        ELSE
          PIOCT3%EFMAS=0.
          PIOCT3%EFNUM=0.
        ENDIF
        IF ( PIOCM4T > YTINY ) THEN
          DO IS=1,ISINTOC
            PIOCT4%EFMAS(IS)=PIOCM4(IS)/PIOCM4T
            PIOCT4%EFNUM(IS)=PIOCN4(IS)/PIOCM4T
          ENDDO
        ELSE
          PIOCT4%EFMAS=0.
          PIOCT4%EFNUM=0.
        ENDIF
      ENDIF
      IF ( ISINTBC > 0 ) THEN
        IF ( PIBCM1T > YTINY ) THEN
          DO IS=1,ISINTBC
            PIBCT1%EFMAS(IS)=PIBCM1(IS)/PIBCM1T
            PIBCT1%EFNUM(IS)=PIBCN1(IS)/PIBCM1T
          ENDDO
        ELSE
          PIBCT1%EFMAS=0.
          PIBCT1%EFNUM=0.
        ENDIF
        IF ( PIBCM2T > YTINY ) THEN
          DO IS=1,ISINTBC
            PIBCT2%EFMAS(IS)=PIBCM2(IS)/PIBCM2T
            PIBCT2%EFNUM(IS)=PIBCN2(IS)/PIBCM2T
          ENDDO
        ELSE
          PIBCT2%EFMAS=0.
          PIBCT2%EFNUM=0.
        ENDIF
        IF ( PIBCM3T > YTINY ) THEN
          DO IS=1,ISINTBC
            PIBCT3%EFMAS(IS)=PIBCM3(IS)/PIBCM3T
            PIBCT3%EFNUM(IS)=PIBCN3(IS)/PIBCM3T
          ENDDO
        ELSE
          PIBCT3%EFMAS=0.
          PIBCT3%EFNUM=0.
        ENDIF
        IF ( PIBCM4T > YTINY ) THEN
          DO IS=1,ISINTBC
            PIBCT4%EFMAS(IS)=PIBCM4(IS)/PIBCM4T
            PIBCT4%EFNUM(IS)=PIBCN4(IS)/PIBCM4T
          ENDDO
        ELSE
          PIBCT4%EFMAS=0.
          PIBCT4%EFNUM=0.
        ENDIF
      ENDIF
      IF ( ISINTSO4 > 0 ) THEN
        IF ( PISUM1T > YTINY ) THEN
          DO IS=1,ISINTSO4
            PISUT1%EFMAS(IS)=PISUM1(IS)/PISUM1T
            PISUT1%EFNUM(IS)=PISUN1(IS)/PISUM1T
          ENDDO
        ELSE
          PISUT1%EFMAS=0.
          PISUT1%EFNUM=0.
        ENDIF
        IF ( PISUM2T > YTINY ) THEN
          DO IS=1,ISINTSO4
            PISUT2%EFMAS(IS)=PISUM2(IS)/PISUM2T
            PISUT2%EFNUM(IS)=PISUN2(IS)/PISUM2T
          ENDDO
        ELSE
          PISUT2%EFMAS=0.
          PISUT2%EFNUM=0.
        ENDIF
        IF ( PISUM3T > YTINY ) THEN
          DO IS=1,ISINTSO4
            PISUT3%EFMAS(IS)=PISUM3(IS)/PISUM3T
            PISUT3%EFNUM(IS)=PISUN3(IS)/PISUM3T
          ENDDO
        ELSE
          PISUT3%EFMAS=0.
          PISUT3%EFNUM=0.
        ENDIF
        IF ( PISUM4T > YTINY ) THEN
          DO IS=1,ISINTSO4
            PISUT4%EFMAS(IS)=PISUM4(IS)/PISUM4T
            PISUT4%EFNUM(IS)=PISUN4(IS)/PISUM4T
          ENDDO
        ELSE
          PISUT4%EFMAS=0.
          PISUT4%EFNUM=0.
        ENDIF
      ENDIF
!
!-----------------------------------------------------------------------
!     * DEALLOCATE WORK ARRAYS.
!
      IF ( ISEXTOC > 0 ) THEN
        DEALLOCATE(PEOCM1)
        DEALLOCATE(PEOCN1)
        DEALLOCATE(PEOCM2)
        DEALLOCATE(PEOCN2)
        DEALLOCATE(PEOCM3)
        DEALLOCATE(PEOCN3)
        DEALLOCATE(PEOCM4)
        DEALLOCATE(PEOCN4)
      ENDIF
      IF ( ISEXTBC > 0 ) THEN
        DEALLOCATE(PEBCM1)
        DEALLOCATE(PEBCN1)
        DEALLOCATE(PEBCM2)
        DEALLOCATE(PEBCN2)
        DEALLOCATE(PEBCM3)
        DEALLOCATE(PEBCN3)
        DEALLOCATE(PEBCM4)
        DEALLOCATE(PEBCN4)
      ENDIF
      IF ( ISEXTSO4 > 0 ) THEN
        DEALLOCATE(PESUM1)
        DEALLOCATE(PESUN1)
        DEALLOCATE(PESUM2)
        DEALLOCATE(PESUN2)
        DEALLOCATE(PESUM3)
        DEALLOCATE(PESUN3)
        DEALLOCATE(PESUM4)
        DEALLOCATE(PESUN4)
      ENDIF
      IF ( ISINTOC > 0 ) THEN
        DEALLOCATE(PIOCM1)
        DEALLOCATE(PIOCN1)
        DEALLOCATE(PIOCM2)
        DEALLOCATE(PIOCN2)
        DEALLOCATE(PIOCM3)
        DEALLOCATE(PIOCN3)
        DEALLOCATE(PIOCM4)
        DEALLOCATE(PIOCN4)
      ENDIF
      IF ( ISINTBC > 0 ) THEN
        DEALLOCATE(PIBCM1)
        DEALLOCATE(PIBCN1)
        DEALLOCATE(PIBCM2)
        DEALLOCATE(PIBCN2)
        DEALLOCATE(PIBCM3)
        DEALLOCATE(PIBCN3)
        DEALLOCATE(PIBCM4)
        DEALLOCATE(PIBCN4)
      ENDIF
      IF ( ISINTSO4 > 0 ) THEN
        DEALLOCATE(PISUM1)
        DEALLOCATE(PISUN1)
        DEALLOCATE(PISUM2)
        DEALLOCATE(PISUN2)
        DEALLOCATE(PISUM3)
        DEALLOCATE(PISUN3)
        DEALLOCATE(PISUM4)
        DEALLOCATE(PISUN4)
      ENDIF
!
      END SUBROUTINE SDPEMI
