!+ Subroutine to read a file of cross-sectional data.
!
! Method:
!       The name of the file is requested. The file is opened
!       and read. Directives encoutered are processed.
!
! 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_REF_PT(IERR
     &   , N_ABSORB, TYPE_ABSORB
     &   , N_INDEX, LIST_INDEX, N_INDEX_BAND, LIST_BAND
     &   , P_REFERENCE, T_REFERENCE
     &   )
!
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/dimensions_spec.ucf'
      INCLUDE 'incl/dimensions_pp.ucf'
      INCLUDE 'incl/def_std_io.icf'
      INCLUDE 'incl/gas_list.pcf'
      INCLUDE 'incl/gas_list.ncf'
      INCLUDE 'incl/error.pcf'
!
      INTEGER	!, INTENT(OUT)
     &     IERR
!             ERROR FLAG
      INTEGER	!, INTENT(IN)
     &     N_ABSORB
!             NUMBER OF ABSORBERS
     &   , TYPE_ABSORB(NPD_SPECIES)
!             TYPES OF ABSORBERS
     &   , N_INDEX
!             NUMBER OF INDICES IN DATA
     &   , LIST_INDEX(NPD_SET)
!             LIST OF INDEX TYPES
     &   , N_INDEX_BAND(NPD_SPECIES)
!             NUMBER OF BANDS FOR EACH INDEX
     &   , LIST_BAND(NPD_SPECIES, NPD_BAND)
!             LIST OF BANDS IN WHICH INDEX FALLS
      REAL*8	!, INTENT(OUT)
     &     P_REFERENCE(NPD_SPECIES, NPD_BAND)
!             REFERENCE PRESSURES FOR SCALING
     &   , T_REFERENCE(NPD_SPECIES, NPD_BAND)
!             REFERENCE PRESSURES FOR SCALING
!
!
!     LOCAL VARIABLES.
      CHARACTER
     &     LINE*80
!             LINE READ FROM INPUT FILE
     &   , WORD*16
!             SUBSTRING OF INPUT LINE
      INTEGER
     &     I_BEGIN
!             BEGINNING OF SUBSTRING
     &   , I_END
!             END OF SUBSTRING
      INTEGER
     &     IOS
!             I/O ERROR FLAG
     &   , I_FIRST_BAND
!             FISRT BAND IN LIST
     &   , I_LAST_BAND
!             FISRT BAND IN LIST
     &   , I_GAS
!             TYPE OF GAS CONSIDERED
     &   , I
!             LOOP VARIABLE
     &   , J
!             LOOP VARIABLE
     &   , K
!             LOOP VARIABLE
      LOGICAL
     &     L_DONE
!             FLAG SET TO TRUE ON COMPLETION OF ASSIGNMENT
      REAL*8
     &     P0
!             PRESSURE READ FROM FILE
     &   , T0
!             TEMPERATURE READ FROM FILE
!
!     SUBROUTINES CALLED:
      EXTERNAL
     &     OPEN_FILE_IN, READ_WORD
!
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/gas_names.dcf'
!
!
      CALL OPEN_FILE_IN(IERR, IU_FILE_IN
     &  , 'ENTER THE NAME OF THE FILE OF CROSS_SECTIONAL DATA.')
!

!     READ THE FILE LOOKING FOR THE DIRECTIVES. 
      L_GAS_SET=.FALSE.
      IOS=0
      DO WHILE (IOS.EQ.0)
         READ(IU_FILE_IN, '(A)', IOSTAT=IOS) LINE
         IF (IOS.NE.0) GOTO 999
!
         IF (LINE(1:4).EQ.'*GAS') THEN
!
!           PROCESS THE REMAINDER OF THE LINE TO EXTRACT THE DATA.
            L_GAS_SET=.TRUE.
            I_BEGIN=6
            CALL READ_WORD(IERR, LINE, 80, I_BEGIN, I_END, WORD)
            IF (IERR.NE.I_NORMAL) RETURN
            READ(WORD, '(I16)', IOSTAT=IOS) I_FIRST_BAND
            IF (IOS.NE.0) THEN
               WRITE(IU_ERR, '(/A)')
     &            '*** ERROR: THE GAS IS INCORRECTLY SPECIFIED '
     &            //' IN LINE:'
               WRITE(IU_ERR, '(A)') LINE
               IERR=I_ERR_FATAL
               RETURN
            ENDIF
!
         ELSE IF (LINE(1:6).EQ.'*XSECT') THEN
!
!           READ THE LINE SETTING THE UNITS.
            READ
            IOS=0
            I=0
            DO WHILE (IOS.NE.0)
               READ(IU_FILE_IN, *, IOSTAT=IOS) X, Y
               I=I+1
               IF (IOS.NE.0) THEN
                  IF (UNIT_X.EQ.'INV_CM') THEN
                     WAVE_NUMBER(I)=1.0D+02*X
                  ENDIF
                  IF (UNIT_Y.EQ.'M2_KG') THEN
                     ABSORPTION(I)=Y
                  ENDIF
               ENDIF
            ENDDO
!
         ELSE IF (LINE(1:1).EQ.'*') THEN
!
            WRITE(IU_ERR, '(/A)')
     &         '*** ERROR: AN UNRECOGNIZED DIRECTIVE HAS BEEN '
     &         //'SUPPLIED IN LINE:'
            WRITE(IU_ERR, '(A)') LINE
            IERR=I_ERR_FATAL
            RETURN
!
         ENDIF
!
      ENDDO 
!
999   CLOSE(IU_FILE_IN)
!
!
!
      RETURN
      END
