
      SUBROUTINE rdasci(infile, nenrgy, nspec, enlow, enhigh, flux, 
     &                  error, matrix, channel, ngrp, nchan, fchan, 
     &                  contxt, status)

      INTEGER nenrgy, nspec

      REAL enlow(nenrgy), enhigh(nenrgy), flux(nenrgy,nspec)
      REAL matrix(nenrgy), error(nenrgy,nspec)

      INTEGER channel(nenrgy,nspec), ngrp(nenrgy), nchan(nenrgy)
      INTEGER fchan(nenrgy)
      INTEGER status

      CHARACTER*(*) infile, contxt

c Subroutine to read the ASCII file and set the arrays used for the
c response to give a diagonal matrix

c Arguments :
c      infile    c*(*)      i: Name of ASCII file
c      nenrgy    i          i: Number of rows in input file
c      nspec     i          i: Number of spectra
c      enlow     r          r: Start energy for each flux bin
c      enhigh    r          r: End energy for each flux bin
c      flux      r          r: Flux (in bin)
c      error     r          r: Error on flux
c      matrix    r          r: Response matrix (returned as unit matrix)
c      channel   i          r: Channel number for each bin
c      ngrp      i          r: Number of response groups per energy (=1)
c      nchan     i          r: Number of channels per response group (=1)
c      fchan     i          r: Start channel of each response group (=channel)
c      contxt    c          r: Error context
c      status    i          r: Error status : 0 = OK

      INTEGER i, j

      OPEN (unit=1, file=infile, status='old', iostat=status)
      contxt = ' Failed to open input ASCII file in RDASCI'
      IF ( status .NE. 0 ) RETURN

      DO i = 1, nenrgy

         READ(1,*,iostat=status) enlow(i), enhigh(i), 
     &                           (flux(i,j), error(i,j), j=1,nspec)
         WRITE(contxt,'(a,i8,a,i5)')
     &    'Failed to read ASCII file in RDASCI on line ', i,
     &    ', status = ', status
         IF ( status .NE. 0 ) RETURN

         DO j = 1, nspec
            channel(i,j) = i
         ENDDO
         matrix(i) = 1.0
         ngrp(i) = 1
         nchan(i) = 1
         fchan(i) = i

      ENDDO

      CLOSE(1)

      RETURN
      END
         

