!+ Program to summarize the contents of a spectral file.
!
! Method:
!	The file is read in and the bands are sequentially processed.
!	The limits of each band and the gases and continua that it 
!	contains are printed.
!
! 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.
!
!- ---------------------------------------------------------------------
      PROGRAM SUMMARIZE_SPEC
!
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/dimensions_spec.ucf'
      INCLUDE 'incl/def_std_io.icf'
      INCLUDE 'incl/continuum.ncf'
      INCLUDE 'incl/continuum.pcf'
      INCLUDE 'incl/gas_list.pcf'
      INCLUDE 'incl/gas_list.ncf'
      INCLUDE 'incl/error.pcf'
!
!     DECLARTION OF VARIABLES.
!
      LOGICAL
     &     LOCK_CODE
!             LOGICAL TO FORBID INTERACTIVE LOOPING
      EXTERNAL
     &     LOCK_CODE
!
      CHARACTER
     &     FILE_SPECTRAL*80
!             NAME OF SPECTRAL FILE
     &   , FILE_OUT*80
!             NAME OF OUTPUT FILE
      INTEGER
     &     IERR
!             ERROR FLAG
     &   , I
!             LOOP VARIABLE
     &   , J
!             LOOP VARIABLE
      LOGICAL
     &     L_EXIST
!             EXISTENCE FLAG
      REAL*8
     &     V1
!             LIMIT OF BAND
     &   , V2
!             LIMIT OF BAND
!
!     DECLARTION OF SPECTRAL VARIABLES.
      INCLUDE 'dec_spec.finc'
!
!     SUBROUTINES CALLED:
      EXTERNAL
     &     IN_SPECTRUM
!
      DATA IERR/I_NORMAL/
!
      INCLUDE 'incl/gas_names.dcf'
      INCLUDE 'incl/continuum_names.dcf'
!
!
      WRITE(IU_USER, '(/A)') 'ENTER THE NAME OF THE SPECTRAL FILE.'
100   READ(IU_STDIN, '(A)') FILE_SPECTRAL
      INCLUDE 'read_spec.finc'
      IF (IERR.NE.I_NORMAL) THEN
         IF (IERR.EQ.I_ERR_EXIST) THEN
            WRITE(IU_ERR, '(A)') '*** FILE DOES NOT EXIST.'
            IF (LOCK_CODE(.TRUE.)) THEN
               INCLUDE 'batch_error_main.finc'
            ELSE
               WRITE(IU_USER, '(A)') 'PLEASE RE-ENTER NAME.'
               IERR=I_NORMAL
               GOTO 100
            ENDIF
         ELSE
            STOP
         ENDIF
      ENDIF
!
      WRITE(IU_USER, '(/A)') 'ENTER THE NAME OF THE OUTPUT FILE'
2     READ(IU_STDIN, '(A)') FILE_OUT
      INQUIRE(FILE=FILE_OUT, EXIST=L_EXIST)
      IF (L_EXIST) THEN
         WRITE(IU_USER, '(A)') '*** THIS FILE ALREADY EXISTS.'
         IF (LOCK_CODE(.TRUE.)) THEN
            INCLUDE 'batch_error_main.finc'
         ELSE
            WRITE(IU_USER, '(A)') 'PLEASE RE-SPECIFY.'
            GOTO 2
         ENDIF
      ENDIF
      OPEN(UNIT=IU_FILE_OUTPUT, FILE=FILE_OUT, STATUS='NEW'
     &   )
!
      DO I=1, N_BAND
         V1=1.0D-02/WAVE_LENGTH_LONG(I)
         V2=1.0D-02/WAVE_LENGTH_SHORT(I)
         WRITE(IU_FILE_OUTPUT, '(//, A7, I5, A10, 1PE11.4
     &      , A3, 1PE11.4, A6)') 'BAND = ', I, ': RANGE = '
     &      , V1, ' - ', V2, ' CM-1.'
         WRITE(IU_FILE_OUTPUT, '(/, 3X, A14, (T20, A20, /))')
     &      'ACTIVE GASES: '
     &      , (NAME_ABSORB(TYPE_ABSORB(INDEX_ABSORB(J, I)))
     &      , J=1, N_BAND_ABSORB(I))
         WRITE(IU_FILE_OUTPUT, '(/, 3X, A17, (T20, A20, /))')
     &      'ACTIVE CONTINUA: '
     &      , (NAME_CONTINUUM(INDEX_CONTINUUM(I, J))
     &      , J=1, N_BAND_CONTINUUM(I))
      ENDDO
!
      CLOSE(IU_FILE_OUTPUT)
!
!
      STOP
      END
