!+ SUbroutine to read one block of scattering data.
!
! Method:
!	Straightforward.
!
! 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 READ_SCATTER_BLOCK(IERR, L_END
     &   , I_TYPE, I_COMPONENT
     &   , I_INPUT_TYPE
     &   , NAME_TYPE, NAME_COMPONENT
     &   , HUMIDITY
     &   , NUMBER_TOTAL
     &   , RADIUS_EFFECTIVE, VOLUME_FRACTION
     &   , RADIUS_EFFECTIVE_DRY, VOLUME_FRACTION_DRY
     &   , N_WAVELENGTH, WAVELENGTH
     &   , ABSORPTION, SCATTERING, ASYMMETRY
     &   )
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/def_sct_io.icf'
      INCLUDE 'incl/def_std_io.icf'
      INCLUDE 'incl/file_type.pcf'
      INCLUDE 'incl/scatter_pp.pcf'
      INCLUDE 'incl/dimensions_pp.ucf'
      INCLUDE 'incl/error.pcf'
!
!     DUMMY ARGUMENTS.
      INTEGER	!, INTENT(OUT)
     &     IERR
!             ERROR FLAG
      CHARACTER	!, INTENT(OUT)
     &     NAME_TYPE*20
!             NAME OF TYPE OF SCATTERER
     &   , NAME_COMPONENT*20
!             NAME OF COMPONENT
      INTEGER	!, INTENT(OUT)
     &     N_WAVELENGTH
!             NUMBER OF WAVELENGTHS
     &   , I_TYPE
!             TYPE OF SCATTERER
     &   , I_COMPONENT
!             INDEX OF COMPONENT
      INTEGER
     &     I_INPUT_TYPE
!             TYPE OF INPUT FILE
      LOGICAL	!, INTENT(OUT)
     &     L_END
!             END OF FILE FLAG
      REAL*8
     &     HUMIDITY
!             HUMIDITY
      REAL*8	!, INTENT(OUT)
     &     NUMBER_TOTAL
!             TOTAL NUMBER OF PARTICLES
     &   , RADIUS_EFFECTIVE
!             EFFECTIVE RADIUS
     &   , VOLUME_FRACTION
!             VOLUME FRACTION OF SPHERES
     &   , RADIUS_EFFECTIVE_DRY
!             EFFECTIVE RADIUS OF DRY PARTICLES
     &   , VOLUME_FRACTION_DRY
!             VOLUME FRACTION OF DRY PARTICLES
     &   , WAVELENGTH(NPD_WAVELENGTH_SCAT)
!             WAVELENGTHS
     &   , ABSORPTION(NPD_WAVELENGTH_SCAT)
!             ABSORPTION
     &   , SCATTERING(NPD_WAVELENGTH_SCAT)
!             SCATTERING EXTINCTION
     &   , ASYMMETRY(NPD_WAVELENGTH_SCAT)
!             ASYMMETRY FACTOR
!
!     LOCAL VARIABLES.
      INTEGER
     &     I_ALGORITHM
!             TYPE OF SCATTERING ALGORITHM
      CHARACTER
     &     LINE*80
!             INPUT LINE OF DATA
      LOGICAL
     &     NON_BLANK
!             TEST FOR BLANK LINE
!
!
!     INITIALLY SET L_END TO .TRUE. AND RESET TO .FALSE. IF THE BLOCK IS
!     READ COMPLETELY
      L_END=.TRUE.
!
!     READ THE INPUT TYPE. THIS IS USED TO CONTROL THE
!     SUBSEQUENT READING IN.
!
      READ(IU_MIE, '(/, 13X, I5)', END=100) I_INPUT_TYPE
!
      IF ( I_INPUT_TYPE .EQ. IT_FILE_MIE_DRY ) THEN
!        READ HEADER WITHOUT HUMIDITY VARIABLE.
         READ(IU_MIE, '(////, 23X, I5, /, 23X, I5, 4X, A20)')
     &      I_ALGORITHM, I_TYPE, NAME_TYPE
         IF (I_TYPE.EQ.IP_TYPE_AEROSOL) THEN
            READ(IU_MIE, '(23X, I5, 4X, A20)')
     &         I_COMPONENT, NAME_COMPONENT
         ENDIF
         READ(IU_MIE, '(/, 3(19X, 1PE12.5, /), /)')
     &        NUMBER_TOTAL, RADIUS_EFFECTIVE, VOLUME_FRACTION
      ELSEIF ( I_INPUT_TYPE .EQ. IT_FILE_MIE_HUMID ) THEN
!        READ HEADER WITH HUMIDITY VARIABLE.
         READ(IU_MIE, '(////, 23X, I5, /, 23X, I5, 4X, A20)')
     &      I_ALGORITHM, I_TYPE, NAME_TYPE
         IF (I_TYPE.EQ.IP_TYPE_AEROSOL) THEN
            READ(IU_MIE, '(23X, I5, 4X, A20)')
     &         I_COMPONENT, NAME_COMPONENT
         ENDIF
         READ(IU_MIE, '(/, 11X, F7.5, //, 19X, 1PE12.5, /
     &      , 2(19X, 1PE12.5, /, 36X, 1PE12.5, /), /)')
     &        HUMIDITY, NUMBER_TOTAL, RADIUS_EFFECTIVE
     &      , RADIUS_EFFECTIVE_DRY, VOLUME_FRACTION
     &      , VOLUME_FRACTION_DRY
      ELSE
         WRITE(IU_ERR, '(/A)') 
     &      '*** ERROR: THE FILE IS OF AN INVALID TYPE.'
         IERR=I_ERR_FATAL
         RETURN
      ENDIF
!
!     READ AND PROCESS EACH LINE IN TURN.
      N_WAVELENGTH=0
1     READ(IU_MIE, '(A)', END=100) LINE
      IF (NON_BLANK(LINE)) THEN
         IF (N_WAVELENGTH.LT.NPD_WAVELENGTH_SCAT) THEN
            N_WAVELENGTH=N_WAVELENGTH+1
         ELSE
            WRITE(IU_ERR, '(/A)')
     &         '*** ERROR: THERE ARE TOO MANY WAVELENGTHS IN THE '
     &         //'INPUT FILE.'
            WRITE(IU_ERR, '(A)')
     &         'INCREASE NPD_WAVELENGTH_SCAT AND RECOMPILE.'
            IERR=I_ERR_FATAL
            RETURN
         ENDIF
         READ(LINE, '(4(4X, 1PE12.5, 4X))') WAVELENGTH(N_WAVELENGTH)
     &      , ABSORPTION(N_WAVELENGTH), SCATTERING(N_WAVELENGTH)
     &      , ASYMMETRY(N_WAVELENGTH)
         GOTO 1
      ENDIF
!
!     THE BLOCK HAS BEEN READ COMPLETELY: RESET L_END TO .FALSE.
      L_END=.FALSE.
!
!
100   RETURN
      END
