!+ Subroutine to make spectral blocks of type 11.
!
! Method:
!	Observational data may be used. In this case the single
!	scattering properties are read from files at appropriate
!	pressure levels and scalings may be applied. Alternatively,
!	data may be given in a parametrized form where the 
!	extinctions are proportion to the mass loading. In this case,
!	a file of scattering properties is supplied. In the case of
!	dry aerosols, only one set of properties for each band is 
!	required. In the case of moist aerosols this file must
!	contain a number of blocks, each giving the single scattering
!	properties in each band at a particular value of the humidity.
!	A look-up table is constructed from these values.
!
! Current Owner of Code: J. M. Edwards
!
! History:
!       Version         Date                    Comment
!       1.0             12-04-95                First Version under RCS
!                                               (J. M. Edwards)
!
! Description of Code:
!   FORTRAN 77  with extensions listed in documentation.
!
!- ---------------------------------------------------------------------
      SUBROUTINE MAKE_BLOCK_11(IERR, N_BAND
     &   , N_AEROSOL, TYPE_AEROSOL
     &   , I_AEROSOL_PARAMETRIZATION
     &   , AEROSOL_ABSORPTION, AEROSOL_SCATTERING, AEROSOL_ASYMMETRY
     &   , NHUMIDITY, HUMIDITIES
     &   , N_AEROSOL_DATA_LAYER, OBS_AEROSOL_PRESSURE
     &   , OBS_AEROSOL_ABSORPTION, OBS_AEROSOL_SCATTERING
     &   , OBS_AEROSOL_ASYMMETRY
     &   , L_AEROSOL_SPECIES, L_PRESENT_11
     &   )
!
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/dimensions_spec.ucf'
      INCLUDE 'incl/dimensions_pp.ucf'
      INCLUDE 'incl/aerosol_component.pcf'
      INCLUDE 'incl/aerosol_component.ncf'
      INCLUDE 'incl/aerosol_name.ncf'
      INCLUDE 'incl/scatter_pp.pcf'
      INCLUDE 'incl/def_std_io.icf'
      INCLUDE 'incl/error.pcf'
      INCLUDE 'incl/file_type.pcf'
      INCLUDE 'incl/def_sct_io.icf'
      INCLUDE 'incl/aerosol_parametrization.pcf'
!
!     DUMMY ARGUMENTS.
      INTEGER	!, INTENT(OUT)
     &     IERR
!             ERROR FLAG
     &   , I_AEROSOL_PARAMETRIZATION(NPD_AEROSOL_SPECIES)
!             FLAG FOR HUMIDITY ON-OFF
      INTEGER	!, INTENT(IN)
     &     N_BAND
!             NUMBER OF SPECTRAL BANDS
     &   , N_AEROSOL
!             NUMBER OF AEROSOLS
     &   , TYPE_AEROSOL(NPD_AEROSOL_SPECIES)
!             TYPES OF AEROSOLS
      INTEGER	!, INTENT(INOUT)
     &     NHUMIDITY(NPD_AEROSOL_SPECIES)
!             THIS IS THE NUMBER OF HUMIDITY VALUES FOR EACH 
!             AEROSOL SPECIES. NOTE THAT A VALUE OF ZERO INDICATES 
!             DRY AEROSOL (NO HUMIDITY VARIATION).
!
      INTEGER	!, INTENT(OUT)
     &     N_AEROSOL_DATA_LAYER(NPD_AEROSOL_SPECIES)
!             NUMBER OF AEROSOL DATA LAYERS
      LOGICAL	!, INTENT(INOUT)
     &     L_PRESENT_11
!             PRESENCE FLAG FOR TYPE 11
     &   , L_AEROSOL_SPECIES(NPD_AEROSOL_SPECIES)
!             SPECIES PRESENT
      REAL*8	!, INTENT(OUT)
     &     AEROSOL_ABSORPTION(NPD_HUMIDITIES, NPD_AEROSOL_SPECIES
     &        , NPD_BAND)
!             ABSORPTION OF AEROSOLS
     &   , AEROSOL_SCATTERING(NPD_HUMIDITIES, NPD_AEROSOL_SPECIES
     &        , NPD_BAND)
!             SCATTERING OF AEROSOLS
     &   , AEROSOL_ASYMMETRY(NPD_HUMIDITIES, NPD_AEROSOL_SPECIES
     &        , NPD_BAND)
!             ASYMMETRY OF AEROSOLS
      REAL*8	!, INTENT(INOUT)
     &     HUMIDITIES(NPD_HUMIDITIES, NPD_AEROSOL_SPECIES)
!             THESE ARE THE HUMIDITY VALUES FOR EACH AEROSOL SPECIES.
!             THEY ARE ASSUMED TO OCCUR IN INCREASING ORDER, AND AN 
!             ERROR MESSAGE SHOULD BE PRINTED IF AN ATTEMPT IS MADE 
!             TO BREAK THIS RULE.
!
!
      REAL*8	!, INTENT(OUT)
     &     OBS_AEROSOL_PRESSURE(0: NPD_AEROSOL_DATA_LAYER
     &        , NPD_AEROSOL_SPECIES)
!             PRESSURE AT AEROSOL DATA LEVELS
     &   , OBS_AEROSOL_ABSORPTION(0: NPD_AEROSOL_DATA_LAYER
     &        , NPD_AEROSOL_SPECIES, NPD_BAND)
!             AEROSOL ABSORPTION
     &   , OBS_AEROSOL_SCATTERING(0: NPD_AEROSOL_DATA_LAYER
     &        , NPD_AEROSOL_SPECIES, NPD_BAND)
!             AEROSOL SCATTERING
     &   , OBS_AEROSOL_ASYMMETRY(0: NPD_AEROSOL_DATA_LAYER
     &        , NPD_AEROSOL_SPECIES, NPD_BAND)
!             AEROSOL ASYMMETRY
!
!
!     LOCAL VARIABLES.
!
      LOGICAL
     &     LOCK_CODE
!             LOGICAL TO FORBID INTERACTIVE LOOPING
      EXTERNAL
     &     LOCK_CODE
!
      CHARACTER
     &     CHAR_YN
!             CHARACTER RESPONSE VARIABLE
      INTEGER
     &     I_SCATTER_TYPE
!             TYPE OF SCATTERER
     &   , I_BLOCK
!             BLOCK INDEX
     &   , I_COMPONENT
!             AEROSOL COMPONENT
     &   , I_SPECIES
!             SPECIES OF AEROSOL
     &   , IDUM
!             DUMMY VARIABLE
     &   , I
!             LOOP VARIABLE
     &   , J
!             LOOP VARIABLE
     &   , I_INPUT_TYPE
!             INPUT TYPE
     &   , IOS
!             I/O ERROR FLAG
     &   , POINTER(0: NPD_AEROSOL_DATA_LAYER)
!             POINTERS FOR SORTING
      REAL*8
     &     ABSORPTION(NPD_BAND)
!             ABSORPTION VALUES OF BLOCK
     &   , SCATTERING(NPD_BAND)
!             SCATTERING VALUES OF BLOCK
     &   , ASYMMETRY(NPD_BAND)
!             ASYMMETRY VALUES OF BLOCK
     &   , RADIUS_EFF
!             EFFECTIVE RADIUS
     &   , NUMBER_TOTAL
!             TOTAL NUMBER DENSITY
     &   , VOLUME_FRACTION
!             VOLUME FRACTION
     &   , RADIUS_EFF_DRY
!             EFFECTIVE RADIUS
     &   , VOLUME_FRACTION_DRY
!             VOLUME FRACTION
     &   , FACTOR_SCALE
!             SCALING FACTOR FOR THE EXTINCTION
     &   , HUMIDITY
!             HUMIDITY
     &   , DUMMY(0: NPD_AEROSOL_DATA_LAYER)
!             DUMMY ARRAY FOR SORTING
!
!     SUBROUTINES CALLED:
      EXTERNAL
     &     SHELL_SORT
!
!
      INCLUDE 'incl/aerosol_component.dcf'
      INCLUDE 'incl/aerosol_name.dcf'
!
!
!
      WRITE(IU_USER, '(/A)') 'USE DIRECT OBSERVATIONAL DATA? (Y/N)'
1     READ(IU_STDIN, '(A)') CHAR_YN
      IF ( (CHAR_YN.EQ.'Y').OR.(CHAR_YN.EQ.'y') ) THEN
         J=0
4        CALL OPEN_FILE_IN(IERR, IU_AVERAGE
     &      , 'ENTER NAME OF FILE OF AVERAGED SCATTERING '
     &      //'DATA AT AN AEROSOL DATA-LEVEL.')
         IF (IERR.NE.I_NORMAL) THEN
            IERR=I_ABORT_CALCULATION
            RETURN
         ENDIF
         READ(IU_AVERAGE, '(13X, I5)') I_INPUT_TYPE
         IF (I_INPUT_TYPE.NE.IT_FILE_AVE_MIE_DRY) THEN
            WRITE(IU_ERR, '(A)') '+++ THIS FILE IS OF AN INVALID TYPE.'
            IF (LOCK_CODE(.TRUE.)) THEN
               INCLUDE 'batch_error.finc'
            ELSE
               GOTO 4
            ENDIF
         ENDIF
         READ(IU_AVERAGE, '(///, 11X, I5, /, 23X, I5)')
     &      I_BLOCK, I_SCATTER_TYPE
         IF (I_SCATTER_TYPE.NE.IP_TYPE_AEROSOL) THEN
            WRITE(IU_ERR, '(A)') '+++ THE SCATTERER IS NOT AEROSOL.'
            IF (LOCK_CODE(.TRUE.)) THEN
               INCLUDE 'batch_error.finc'
            ELSE
               GOTO 4
            ENDIF
         ENDIF
         READ(IU_AVERAGE, '(24X, I5, //, 3(22X, 1PE12.5, /)
     &      , //)') I_COMPONENT
     &      , NUMBER_TOTAL, RADIUS_EFF, VOLUME_FRACTION
!        FIND THE SPECIES OF AEROSOL WHICH REPRESENTS THIS COMPONENT.
         I=0
40       I=I+1
         IF (TYPE_AEROSOL(I).EQ.I_COMPONENT) THEN
            I_SPECIES=I
         ELSE IF (I.LT.N_AEROSOL) THEN
            GOTO 40
         ELSE
            WRITE(IU_ERR, '(/A)') '+++ ILLEGAL COMPONENT'
            WRITE(IU_ERR, '(A)') 'THIS FILE CONTAINS DATA FOR AN '
     &         //'AEROSOL WHICH IS NOT IN THE SPECTRAL FILE.'
            IF (LOCK_CODE(.TRUE.)) THEN
               INCLUDE 'batch_error.finc'
            ELSE
               WRITE(IU_ERR, '(A)') 'REPEAT THIS STEP.'
               CLOSE(IU_AVERAGE)
               GOTO 4
            ENDIF
         ENDIF
!
         DO I=1, N_BAND
            READ(IU_AVERAGE, '(I5, 3(4X, 1PE12.5, 4X))')
     &           IDUM, OBS_AEROSOL_ABSORPTION(J, I_SPECIES, I)
     &         , OBS_AEROSOL_SCATTERING(J, I_SPECIES, I)
     &         , OBS_AEROSOL_ASYMMETRY(J, I_SPECIES, I)
         ENDDO
         READ(IU_AVERAGE, '(//)')
         CLOSE(IU_AVERAGE)
!
         WRITE(IU_USER, '(A)') 'ENTER THE PRESSURE TO WHICH THESE '
     &      //'PROPERTIES REFER.'
5        READ(IU_STDIN, *, IOSTAT=IOS)
     &      OBS_AEROSOL_PRESSURE(J, I_SPECIES)
         IF (IOS.NE.0) THEN
            WRITE(IU_ERR, '(A)') '+++ UNRECOGNIZED RESPONSE:'
            IF (LOCK_CODE(.TRUE.)) THEN
               INCLUDE 'batch_error.finc'
            ELSE
               WRITE(IU_USER, '(A)') 'PLEASE REENTER.'
               GOTO 5
            ENDIF
         ENDIF
!
         WRITE(IU_USER, '(A)') 'ENTER THE SCALING FACTOR FOR THE '
     &      //'EXTINCTION.'
55       READ(IU_STDIN, *, IOSTAT=IOS) FACTOR_SCALE
         IF (IOS.NE.0) THEN
            WRITE(IU_ERR, '(A)') '+++ UNRECOGNIZED RESPONSE:'
            IF (LOCK_CODE(.TRUE.)) THEN
               INCLUDE 'batch_error.finc'
            ELSE
               WRITE(IU_USER, '(A)') 'PLEASE REENTER.'
               GOTO 55
            ENDIF
         ENDIF
         DO I=1, N_BAND
            OBS_AEROSOL_ABSORPTION(J, I_SPECIES, I)=FACTOR_SCALE
     &         *OBS_AEROSOL_ABSORPTION(J, I_SPECIES, I)
            OBS_AEROSOL_SCATTERING(J, I_SPECIES, I)=FACTOR_SCALE
     &         *OBS_AEROSOL_SCATTERING(J, I_SPECIES, I)
         ENDDO
!
         WRITE(IU_USER, '(A)') 'ADD ANOTHER PRESSURE LEVEL? (Y/N)'
6        READ(IU_STDIN, '(A)') CHAR_YN
         IF ( (CHAR_YN.EQ.'Y').OR.(CHAR_YN.EQ.'y') ) THEN
            J=J+1
            GOTO 4
         ELSE IF ( (CHAR_YN.NE.'N').AND.(CHAR_YN.NE.'n') ) THEN
            WRITE(IU_ERR, '(/A)') '+++ ILLEGAL RESPONSE:'
            IF (LOCK_CODE(.TRUE.)) THEN
               INCLUDE 'batch_error.finc'
            ELSE
               WRITE(IU_USER, '(/A)') 'PLEASE REENTER.'
               GOTO 6
            ENDIF
         ENDIF
!
!        CHECK THAT THE DATA ARE SUFFICIENT.
         IF (J.LT.1) THEN
            WRITE(IU_ERR, '(A)') '+++ TO FEW AEROSOL DATA-LEVELS HAVE '
     &         //'BEEN SPECIFIED.'
            IF (LOCK_CODE(.TRUE.)) THEN
               INCLUDE 'batch_error.finc'
            ELSE
               WRITE(IU_USER, '(A)') 'PLEASE GIVE ANOTHER LEVEL.'
               GOTO 4
            ENDIF
         ELSE
            N_AEROSOL_DATA_LAYER(I_SPECIES)=J
!           ORDER THE DATA BY INCREASING PRESSURE.
!           SET UP THE POINTER FOR SORTING BEGINNING AT 1.
            DO J=0, N_AEROSOL_DATA_LAYER(I_SPECIES)
               POINTER(J)=J+1
            ENDDO
            J=N_AEROSOL_DATA_LAYER(I_SPECIES)+1
            CALL SHELL_SORT(J, POINTER(0)
     &         , OBS_AEROSOL_PRESSURE(0, I_SPECIES) )
            DO J=0, N_AEROSOL_DATA_LAYER(I_SPECIES)
               DUMMY(J)=OBS_AEROSOL_PRESSURE(POINTER(J)-1, I_SPECIES)
            ENDDO
            DO J=0, N_AEROSOL_DATA_LAYER(I_SPECIES)
               OBS_AEROSOL_PRESSURE(J, I_SPECIES)=DUMMY(J)
            ENDDO
            DO I=1, N_BAND
               DO J=0, N_AEROSOL_DATA_LAYER(I_SPECIES)
                  DUMMY(J)=OBS_AEROSOL_ABSORPTION(POINTER(J)-1
     &              , I_SPECIES, I)
               ENDDO
               DO J=0, N_AEROSOL_DATA_LAYER(I_SPECIES)
                  OBS_AEROSOL_ABSORPTION(J, I_SPECIES, I)=DUMMY(J)
               ENDDO
               DO J=0, N_AEROSOL_DATA_LAYER(I_SPECIES)
                  DUMMY(J)=OBS_AEROSOL_SCATTERING(POINTER(J)-1
     &              , I_SPECIES, I)
               ENDDO
               DO J=0, N_AEROSOL_DATA_LAYER(I_SPECIES)
                  OBS_AEROSOL_SCATTERING(J, I_SPECIES, I)=DUMMY(J)
               ENDDO
               DO J=0, N_AEROSOL_DATA_LAYER(I_SPECIES)
                  DUMMY(J)=OBS_AEROSOL_ASYMMETRY(POINTER(J)-1
     &              , I_SPECIES, I)
               ENDDO
               DO J=0, N_AEROSOL_DATA_LAYER(I_SPECIES)
                  OBS_AEROSOL_ASYMMETRY(J, I_SPECIES, I)=DUMMY(J)
               ENDDO
            ENDDO
         ENDIF
!
         I_AEROSOL_PARAMETRIZATION(I_SPECIES)=IP_AEROSOL_UNPARAMETRIZED
         L_AEROSOL_SPECIES(I_SPECIES)=.TRUE.
!
      ELSE IF ( (CHAR_YN.EQ.'N').OR.(CHAR_YN.EQ.'n') ) THEN
!        OBTAIN INPUT DATA.
21       CALL OPEN_FILE_IN(IERR, IU_AVERAGE
     &      , 'ENTER THE NAME OF THE FILE OF AVERAGED '
     &      //'SCATTERING PROPERTIES.')
         IF (IERR.NE.I_NORMAL) THEN
            IERR=I_ERR_FATAL
            RETURN
         ENDIF
!
!        READ IN AND PROCESS EACH BLOCK.
!
!        READ THE INPUT TYPE. THIS IS USED TO CONTROL THE
!        SUBSEQUENT READING IN.
!
2           READ(IU_AVERAGE, '(13X,I5)', END=100) I_INPUT_TYPE
            READ(IU_AVERAGE, '(///, 11X, I5, /, 23X, I5)', END=100)
     &         I_BLOCK, I_SCATTER_TYPE
            IF (I_SCATTER_TYPE.NE.IP_TYPE_AEROSOL) THEN
               WRITE(IU_ERR, '(A)') '+++ THE SCATTERER IS NOT AEROSOL.'
               IF (LOCK_CODE(.TRUE.)) THEN
                  INCLUDE 'batch_error.finc'
               ELSE
                  GOTO 21
               ENDIF
            ENDIF
            READ(IU_AVERAGE, '(24X, I5)' ) I_COMPONENT
!
!           FIND THE SPECIES OF AEROSOL WHICH REPRESENTS THIS COMPONENT.
            I=0
20          I=I+1
            IF (TYPE_AEROSOL(I).EQ.I_COMPONENT) THEN
               I_SPECIES=I
            ELSE IF (I.LT.N_AEROSOL) THEN
               GOTO 20
            ELSE
               WRITE(IU_ERR, '(/A)') '+++ ILLEGAL COMPONENT'
               WRITE(IU_ERR, '(A)') 'THIS FILE CONTAINS DATA FOR AN '
     &            //'AEROSOL WHICH IS NOT IN THE SPECTRAL FILE.'
               IF (LOCK_CODE(.TRUE.)) THEN
                  INCLUDE 'batch_error.finc'
               ELSE
                  WRITE(IU_USER, '(A)') 'REPEAT THIS STEP.'
                  CLOSE(IU_AVERAGE)
                  GOTO 21
               ENDIF
            ENDIF
!
            IF (I_INPUT_TYPE .EQ. IT_FILE_AVE_MIE_HUMID) THEN
               READ(IU_AVERAGE, '(/, 14X,F7.5)') HUMIDITY
               READ(IU_AVERAGE, '(/, 22X, 1PE12.5, /
     &            , 22X, 1PE12.5, /, 39X, 1PE12.5, /, 22X, 1PE12.5
     &            , /, 39X, 1PE12.5, ///)' )
     &            NUMBER_TOTAL, RADIUS_EFF, RADIUS_EFF_DRY
     &            ,VOLUME_FRACTION, VOLUME_FRACTION_DRY
            ELSEIF(I_INPUT_TYPE .EQ. IT_FILE_AVE_MIE_DRY) THEN
               HUMIDITY = 0.0D+00
               READ(IU_AVERAGE, '(/, 22X, 1PE12.5, /
     &            , 22X, 1PE12.5, /, 22X, 1PE12.5, ///)' )
     &            NUMBER_TOTAL, RADIUS_EFF, VOLUME_FRACTION
            ENDIF
!
            DO I=1, N_BAND
               READ(IU_AVERAGE, '(I5, 3(4X, 1PE12.5, 4X))')
     &            IDUM, ABSORPTION(I), SCATTERING(I), ASYMMETRY(I)
            ENDDO
            READ(IU_AVERAGE, '(//)')
!
            IF (I_SCATTER_TYPE.NE.IP_TYPE_AEROSOL) THEN
               WRITE(IU_ERR, '(/A, I5, A)') '+++ WARNING TYPE OF '
     &            //'SCATTERER IS NOT AEROSOL: BLOCK '
     &            , I_BLOCK, ' IS SKIPPED.'
               GOTO 2
            ENDIF
!
!           CHECK WHETHER THIS COMPONENT IS ALREADY PRESENT.
!           IF IT IS PRESENT, THE ACTION TO BE TAKEN DEPENDS ON WHETHER 
!           THE AEROSOL IS DRY OR MOIST.
!
            IF (L_AEROSOL_SPECIES(I_SPECIES)) THEN
!
               IF (NHUMIDITY(I_SPECIES) .EQ. 0) THEN
!                 WE ARE TRYING TO OVERWRITE A DRY AEROSOL. THIS SHOULD
!                 NEVER BE DONE AUTOMATICALLY, SO STOP THE PROGRAM OR 
!                 ASK THE USER WHAT TO DO.
                  IF (LOCK_CODE(.TRUE.)) THEN
                     INCLUDE 'batch_error.finc'
                  ELSE
                     WRITE(IU_ERR, '(/A, I5, 1X, A1, A20, A1, 1X, A15)')
     &                  '+++ WARNING: '
     &                  //'DATA FOR (DRY) AEROSOL COMPONENT '
     &                  , I_COMPONENT
     &                  , '(', NAME_AEROSOL_COMPONENT(I_COMPONENT), ')'
     &                  , 'ALREADY EXISTS.'
                     WRITE(IU_USER, '(A)')
     &                  'DO YOU WISH TO OVERWRITE? (Y/N)'
3                    READ(IU_STDIN, '(A)') CHAR_YN
                     IF ( (CHAR_YN.NE.'Y').AND.(CHAR_YN.NE.'y')
     &                  .AND.(CHAR_YN.NE.'N').AND.(CHAR_YN.NE.'n') )
     &                  THEN
                        WRITE(IU_USER, '(A)') '+++ ILLEGAL RESPONSE: '
     &                     //'PLEASE REENTER.'
                        GOTO 3
                     ENDIF
                  ENDIF
               ELSE
!
!                 WE ARE TRYING TO OVERWRITE A MOIST AEROSOL. IN THIS
!                 CASE, WE MIGHT WANT TO ADD DATA FOR A NEW, LARGER 
!                 VALUEOF HUMIDITY.CHECK THAT THE NEW VALUE REALLY IS 
!                 LARGERTHAN THE PREVIOUS ONE.
!
                  IF (HUMIDITY.GT.HUMIDITIES(NHUMIDITY(I_SPECIES)
     &               , I_SPECIES) ) THEN
                     CHAR_YN = 'Y'
                  ELSE
                     IF (LOCK_CODE(.TRUE.)) THEN
                        INCLUDE 'batch_error.finc'
                     ELSE
                        WRITE(IU_ERR, '(/A, I5, 1X, A1, A20, A1
     &                     , 1X, A38, 1X, A48)')
     &                     '+++ WARNING: DATA FOR (MOIST) AEROSOL '
     &                     //'COMPONENT ', I_COMPONENT
     &                     , '(', NAME_AEROSOL_COMPONENT(I_COMPONENT)
     &                     , ')', 'IS NOT IN ASCENDING ORDER OF '
     &                     , 'HUMIDITY, OR MOIST AEROSOL WAS BEING '
     &                     //'OVERWRITTEN WITH DRY.'
                        WRITE(IU_ERR, '(//A39)')
     &                    'PROGRAM TERMINATING....HAVE A NICE DAY!'
                        WRITE(IU_ERR, '(/A, /A)')
     &                     'DISCLAIMER: THIS VULGAR AMERICANISM WAS '
     &                     //'ADDED BY DAVID L. ROBERTS, AND '
     &                     , 'THE PRINCIPAL AUTHOR OF THE CODE DENIES '
     &                     //'ANY RESPONSIBILITY FOR IT.'
                        STOP
                     ENDIF
                  ENDIF
               ENDIF
            ENDIF
!
!           IF THIS TYPE OF AEROSOL IS NEW, INITIALISE THE NUMBER OF
!           HUMIDITIES TO BE ZERO. THIS WILL BE CORRECT IF IT IS A DRY
!           AEROSOL. IF IT IS A MOIST AEROSOL, IT WILL BE INCREMENTED TO
!           1 FURTHER DOWN, BEFORE ASSIGNING TO THE MAIN ARRAYS.
!
            IF ( .NOT. L_AEROSOL_SPECIES(I_SPECIES) ) THEN
               NHUMIDITY(I_SPECIES) = 0
            ENDIF
!
            IF ( (.NOT.L_AEROSOL_SPECIES(I_SPECIES))
     &         .OR.(CHAR_YN.EQ.'Y').OR.(CHAR_YN.EQ.'y') ) THEN
!
!              ASSIGN TO THE MAIN ARRAYS AND SCALE OUT 
!              THE VOLUME FRACTION.
               I_COMPONENT=TYPE_AEROSOL(I_SPECIES)
!
               IF ( I_INPUT_TYPE .EQ. IT_FILE_AVE_MIE_DRY) THEN
!
!                 DRY AEROSOL.
                  I_AEROSOL_PARAMETRIZATION(I_SPECIES)
     &               =IP_AEROSOL_PARAM_DRY
                  DO I=1, N_BAND
                     AEROSOL_ABSORPTION(1,I_SPECIES, I)
     &                  =ABSORPTION(I)
     &                  /(VOLUME_FRACTION
     &                  *DENSITY_COMPONENT(I_COMPONENT))
                     print*,density_component(i_component)
                     AEROSOL_SCATTERING(1,I_SPECIES, I)
     &                  =SCATTERING(I)
     &                  /(VOLUME_FRACTION
     &                  *DENSITY_COMPONENT(I_COMPONENT))
                     AEROSOL_ASYMMETRY(1,I_SPECIES, I)=ASYMMETRY(I)
                  ENDDO
!
               ELSE IF (I_INPUT_TYPE .EQ. IT_FILE_AVE_MIE_HUMID) THEN
!
!                 MOIST AEROSOL.
                  I_AEROSOL_PARAMETRIZATION(I_SPECIES)
     &               =IP_AEROSOL_PARAM_MOIST
                  NHUMIDITY(I_SPECIES)=NHUMIDITY(I_SPECIES)+1
                  DO I=1, N_BAND
                     AEROSOL_ABSORPTION(NHUMIDITY(I_SPECIES)
     &                  , I_SPECIES, I)=ABSORPTION(I)
     &                  /(VOLUME_FRACTION_DRY
     &                  *DENSITY_COMPONENT(I_COMPONENT))
                     AEROSOL_SCATTERING(NHUMIDITY(I_SPECIES)
     &                  , I_SPECIES, I)=SCATTERING(I)
     &                  /(VOLUME_FRACTION_DRY
     &                  *DENSITY_COMPONENT(I_COMPONENT))
                     AEROSOL_ASYMMETRY(NHUMIDITY(I_SPECIES)
     &                  , I_SPECIES, I)=ASYMMETRY(I)
                  ENDDO
                  HUMIDITIES(NHUMIDITY(I_SPECIES)
     &               , I_SPECIES)=HUMIDITY
               ELSE
                  IF (LOCK_CODE(.TRUE.)) THEN
                     INCLUDE 'batch_error.finc'
                  ELSE
                     WRITE(IU_ERR, '(/A, I5, 1X, A1, A20, A1
     &                  , 1X, A26,1X,A39)')
     &                  '+++ WARNING: DATA FOR AEROSOL COMPONENT '
     &                  , I_COMPONENT
     &                  , '(', NAME_AEROSOL_COMPONENT(I_COMPONENT), ')'
     &                  , 'HAS AN ILLEGAL INPUT TYPE.'
     &                  , 'PROGRAM TERMINATING....HAVE A NICE DAY!'
                     WRITE(IU_ERR, '(/A, /A)')
     &                  'DISCLAIMER: THIS VULGAR AMERICANISM WAS ADDED '
     &                  //'BY DAVID L. ROBERTS, AND '
     &                  , 'THE PRINCIPAL AUTHOR OF THE CODE DENIES ANY '
     &                  //'RESPONSIBILITY FOR IT.'
                     STOP
                  ENDIF
               ENDIF
!              THIS SPECIES NOW HAS DATA.
               L_AEROSOL_SPECIES(I_SPECIES)=.TRUE.
            ENDIF
         GOTO 2
      ELSE
         WRITE(IU_ERR, '(/A)') '+++INVALID RESPONSE:'
         IF (LOCK_CODE(.TRUE.)) THEN
            INCLUDE 'batch_error.finc'
         ELSE
            WRITE(IU_USER, '(A)') 'PLEASE REENTER.'
            GOTO 1
         ENDIF
      ENDIF
!
!
100   L_PRESENT_11=.FALSE.
      DO I=1, N_AEROSOL
         L_PRESENT_11=L_PRESENT_11.OR.L_AEROSOL_SPECIES(I)
      ENDDO
!
!     CHECK FOR ASSIGNMENT OF DATA.
      IF (.NOT.L_PRESENT_11) THEN
         WRITE(IU_ERR, '(/A)') '+++ WARNING IN MAKE_BLOCK_11'
         WRITE(IU_ERR, '(A)')
     &      'NO AEROSOL PROPERTIES HAVE BEEN ASSIGNED.'
      ENDIF
!
      CLOSE(IU_AVERAGE)
!
!
      RETURN
      END
