!+ Subroutine to read the record file for LOWTRAN7.
!
! 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_RECORD(IERR, N_ABSORB, TYPE_ABSORB
     &   , N_CASE, BAND_CASE, U_CASE, P_CASE, T_CASE, RANGE_CASE
     &   , AMOUNT_N2)
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/def_std_io.icf'
      INCLUDE 'incl/def_lwtrn_io.icf'
      INCLUDE 'incl/dimensions_pp.ucf'
      INCLUDE 'incl/dimensions_spec.ucf'
      INCLUDE 'incl/gas_list.pcf'
      INCLUDE 'incl/lowtran_parameters.ecf'
      INCLUDE 'incl/lowtran_dec.ecf'
      INCLUDE 'incl/file_type.pcf'
      INCLUDE 'incl/error.pcf'
!
!     DUMMY ARGUMENTS.
      INTEGER	!, INTENT(OUT)
     &     IERR
!             ERROR FLAG
     &   , N_CASE
!             NUMBER OF CASES TREATED
     &   , BAND_CASE(NPD_CASE)
!             ARRAY OF BAND NUMBERS
      INTEGER	!, INTENT(IN)
     &     N_ABSORB
!             NUMBER OF ABSORBERS IN BANDS
     &   , TYPE_ABSORB(NPD_SPECIES)
!             TYPE NUMBERS OF SPECIES
      REAL*8	!, INTENT(OUT)
     &     U_CASE(NPD_CASE, NPD_SPECIES)
!             AMOUNTS OF GASEOUS ABSORBERS
     &   , P_CASE(NPD_CASE)
!             PRESSURES FOR EACH CASE
     &   , T_CASE(NPD_CASE)
!             TEMPERATURES FOR EACH CASE
     &   , RANGE_CASE(NPD_CASE)
!             RANGE FOR EACH CASE
     &   , AMOUNT_N2(NPD_CASE)
!             AMOUNTS OF NITROGEN
!
!     LOCAL VARIABLES.
      INTEGER
     &     I_GAS_LOWTRAN
!             LOWTRAN NUMBER OF GAS
     &   , I_INPUT_TYPE
!             TYPE OF RECORD FILE
     &   , I
!             LOOP VARIABLE
      REAL*8
     &     AMOUNT(NPD_GAS_LOW)
!             AMOUNTS OF ABSORBERS
!
      INCLUDE 'incl/gas_lowtran_type.ecf'
!
!
!     READ OVER THE HEADERS OF THE FILE.
      READ(IU_LOWTRAN_RECORD, '(13X, I5, /////)') I_INPUT_TYPE
!
      IF (I_INPUT_TYPE.EQ.IT_FILE_LOWTRAN_RECORD) THEN
!        READ IN EACH CASE IN TURN, AUGMENTING N_CASE.
1        READ(IU_LOWTRAN_RECORD, '(5X, I5)') N_CASE
         IF (N_CASE.GT.NPD_CASE) THEN
            WRITE(IU_ERR, '(/A)') 
     &         '*** ERROR: RECORD FILE CONTAINS TOO MANY CASES'
            IERR=I_ERR_FATAL
            RETURN
         ENDIF
!
         READ(IU_LOWTRAN_RECORD, '(/, 12X, I5, 13X, 1PE11.4
     &      , 19X, 1PE11.4)') BAND_CASE(N_CASE), P_CASE(N_CASE)
     &      , T_CASE(N_CASE)
         READ(IU_LOWTRAN_RECORD, '(13X, 1PE11.4)') RANGE_CASE(N_CASE)
         READ(IU_LOWTRAN_RECORD, '(/)')
         DO I=1, NPD_GAS_LOW/2
            READ(IU_LOWTRAN_RECORD, '(30X, 1PE12.5, 25X, 1PE12.5)')
     &         AMOUNT(2*I-1), AMOUNT(2*I)
         ENDDO
         IF (2*(NPD_GAS_LOW/2).LT.NPD_GAS_LOW) THEN
            READ(IU_LOWTRAN_RECORD, '(30X, 1PE12.5)')
     &         AMOUNT(NPD_GAS_LOW)
         ENDIF
!        TRANSFER THE AMOUNTS IN LOWTRAN'S ORDER TO THE INDEXED LARGE
!        ARRAY U.
         DO I=1, N_ABSORB
            I_GAS_LOWTRAN=IP_LOWTRAN_NUMBER(TYPE_ABSORB(I))
            IF (I_GAS_LOWTRAN.GT.0) THEN
               U_CASE(N_CASE, I)=AMOUNT(I_GAS_LOWTRAN)
            ENDIF
         ENDDO
!
!        READ IN THE AMOUNT OF NITROGEN FOR THE CONTINUUM.
         READ(IU_LOWTRAN_RECORD, '(/)')
         READ(IU_LOWTRAN_RECORD, '(30X, 1PE12.5)') AMOUNT_N2(N_CASE)
!
         READ (IU_LOWTRAN_RECORD, '(/)', END=2)
         GOTO 1
      ELSE
         WRITE(IU_ERR, '(/A)')
     &      '*** ERROR: THE TYPE OF THE RECORD FILE IS UNRECOGNIZED.'
         IERR=I_ERR_FATAL
         RETURN
      ENDIF
!
2     CLOSE(IU_LOWTRAN_RECORD)
!
!
!
      RETURN
      END
