      SUBROUTINE PLA2NM (BNUM,BMASS,PN0,PHI0,PSI,PHIS0,DPHI0,DRYDN, &
                         ILGA,LEVA,ISEC)
!-----------------------------------------------------------------------
!     PURPOSE:
!     --------
!     TRANSFORMATION OF PLA-PARAMETERS TO NUMBER AND MASS.
!
!     HISTORY:
!     --------
!     * APR 07/2006 - K.VONSALZEN   COMPLETELY REVISED FOR USE WITH
!     *                             INTERNALLY AND EXTERNALLY MIXED
!     *                             TYPES OF AEROSOLS.
!     * DEC 11/2005 - K.VONSALZEN   NEW.
!
!     ************************ INDEX OF VARIABLES **********************
!
!     PRIMARY INPUT/OUTPUT VARIABLES (ARGUMENT LIST):
!
! O   BMASS    AEROSOL MASS CONCENTRATION (KG/KG)
! O   BNUM     AEROSOL NUMBER CONCENTRATION (1/KG)
! I   DPHI0    SECTION WIDTH
! I   DRYDN    DENSITY OF DRY AEROSOL PARTICLE (KG/M3)
! I   ILGA     NUMBER OF GRID POINTS IN HORIZONTAL DIRECTION
! I   ISEC     NUMBER OF SEPARATE AEROSOL TRACERS
! I   LEVA     NUMBER OF GRID POINTA IN VERTICAL DIRECTION
! I   PHI0     3RD PLA SIZE DISTRIBUTION PARAMETER (MODE SIZE)
! I   PN0      1ST PLA SIZE DISTRIBUTION PARAMETER (AMPLITUDE)
! I   PHIS0    LOWER DRY PARTICLE SIZE (=LOG(R/R0))
! I   PSI      2ND PLA SIZE DISTRIBUTION PARAMETER (WIDTH)
!
!     SECONDARY INPUT/OUTPUT VARIABLES (VIA MODULES AND COMMON BLOCKS):
!
! I   YCNST    4*PI/3
! I   YNA      DEFAULT FOR UNDEFINED VALUE
!
!-----------------------------------------------------------------------
!
      USE SDPARM
      USE SDCODE
!
      IMPLICIT REAL (A-H,O-Z), INTEGER (I-N)
!
      INTEGER, INTENT(IN) :: ILGA,LEVA,ISEC
      REAL, INTENT(IN), DIMENSION(ILGA,LEVA,ISEC) :: DRYDN
      REAL, INTENT(IN), DIMENSION(ILGA,LEVA,ISEC) :: PN0,PHI0,PSI, &
                                                     PHIS0,DPHI0
      REAL, INTENT(OUT), DIMENSION(ILGA,LEVA,ISEC) :: BNUM,BMASS
      REAL, ALLOCATABLE, DIMENSION(:,:,:) :: SDFN,SDFM
!
!-----------------------------------------------------------------------
!     * ALLOCATE WORK ARRAY.
!
      ALLOCATE(SDFN(ILGA,LEVA,ISEC))
      ALLOCATE(SDFM(ILGA,LEVA,ISEC))
!
!-----------------------------------------------------------------------
!     * OBTAIN NUMBER AND MASS CONCENTRATIONS FROM INTEGRATION OF
!     * SIZE DISRIBUTION AS DEFINED BY PLA-PARAMETERS.
!
      SDFN=SDINT0(PHI0,PSI,PHIS0,DPHI0,ILGA,LEVA,ISEC)
      BNUM=PN0*SDFN
      RMOM=3.
      SDFM=SDINT(PHI0,PSI,RMOM,PHIS0,DPHI0,ILGA,LEVA,ISEC)
      BMASS=PN0*SDFM*DRYDN*YCNST
!
!-----------------------------------------------------------------------
!     * CHECK WHETHER PLA PARAMETERS ARE VALID AND PRODUCE INVALID
!     * RESULTS IF THAT IS NOT THE CASE.
!
      WHERE ( ABS(SDFN-YNA) <= YTINY .OR. ABS(SDFM-YNA) <= YTINY )
        BNUM=YNA
        BMASS=YNA
      ENDWHERE
!
!-----------------------------------------------------------------------
!     * DEALLOCATE WORK ARRAY.
!
      DEALLOCATE(SDFN)
      DEALLOCATE(SDFM)
!
      END SUBROUTINE PLA2NM
