!+ Subroutine to read a line giving the gases in a band.
!
! 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_LINE(IERR, I, PROMPT, MAX_SIZE
     &   , N_ABSORB, N_ABS_BAND, I_ABS_BAND
     &   )
!
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/def_std_io.icf'
      INCLUDE 'incl/error.pcf'
!
!     DUMMY ARGUMENTS
      CHARACTER	!, INTENT(IN)
     &     PROMPT*(*)
!             PROMPT TO USER
      INTEGER	!, INTENT(OUT)
     &     IERR
!             ERROR FLAG
     &   , N_ABS_BAND
!             NUMBER OF ABSORBERS IN BAND
     &   , I_ABS_BAND(MAX_SIZE)
!             INDEXING NUMBERS
      INTEGER	!, INTENT(IN)
     &     I
!             NUMBER OF BAND
     &   , N_ABSORB
!             TOTAL NUMBER OF ABSORBERS
     &   , MAX_SIZE
!             MAXIMUM ARRAY SIZE
!
!     LOCAL VARAIBLES
!
      LOGICAL
     &     LOCK_CODE
!             LOGICAL TO FORBID INTERACTIVE LOOPING
      EXTERNAL
     &     LOCK_CODE
!
      INTEGER
     &     LENGTH
!             LENGTH OF INPUT LINE
     &   , J
!             LOOP VARIABLE
     &   , K
!             LOOP VARIABLE
     &   , BEGIN
!             BEGINNING OF STRING
     &   , END
!             END OF STRING
     &   , IOS
!             IO ERROR FLAG
      CHARACTER
     &     LINE*80
!             LINE OF INPUT DATA
     &   , LIST*1024
!             ASSEMBLED INPUT LIST
     &   , WORD*5
!             INPUT NUMBER
      LOGICAL
     &     L_NEXT
!             FLAG TO READ NEXT LINE
!
!
!
!     INITIALIZE INPUT VARIABLES.
1     LIST(1:1)=' '
      BEGIN=2
!
      WRITE(IU_USER, '(A, 1X, I5)')
     &   PROMPT, I
2     READ(IU_STDIN, '(A)', IOSTAT=IOS) LINE
      IF (IOS.NE.0) THEN
         WRITE(IU_ERR, '(A)') '+++ ERRONEOUS INPUT '
         IF (LOCK_CODE(.TRUE.)) THEN
            INCLUDE 'batch_error.finc'
         ELSE
            WRITE(IU_USER, '(A)') ' PLEASE RE-ENTER THIS LINE.'
            GOTO 2
         ENDIF
      ENDIF
!
!     CHECK WHETHER CONCATENATION IS REQUIRED.
      END=80
3     IF (LINE(END:END).EQ.' ') THEN
         IF (END.GT.1) THEN
            END=END-1
            GOTO 3
         ELSE
         WRITE(IU_ERR, '(A)') '+++ ERRONEOUS INPUT '
         IF (LOCK_CODE(.TRUE.)) THEN
            INCLUDE 'batch_error.finc'
         ELSE
            WRITE(IU_USER, '(A)') ' PLEASE RE-ENTER THIS LINE.'
            GOTO 2
         ENDIF
         ENDIF
      ENDIF
      IF (LINE(END:END).EQ.'&') THEN
!        SET THE RETURN FLAG.
         L_NEXT=.TRUE.
         END=END-1
      ELSE
         L_NEXT=.FALSE.
      ENDIF
!
!     ADD THIS LINE ON TO THE LONG LIST.
      LIST(BEGIN: BEGIN+END)=' '//LINE(1:END)
!     ADVANCE THE FREE COUNTER.
      BEGIN=BEGIN+END+1
!     READ THE NEXT LINE IF NECESSARY.
      IF (L_NEXT) GOTO 2
!
!     DETERMINE THE LENGTH OF THE INPUT LINE AND PROCESS TO DETERMINE
!     THE NUMBERS CONTAINED THEREIN.
      LIST(BEGIN:BEGIN)=' '
      LENGTH=BEGIN
      N_ABS_BAND=0
      J=2
4     CONTINUE
         IF ( (LIST(J-1:J-1).EQ.' ').AND.(LIST(J:J).NE.' ') ) THEN
!           BEGINNING OF WORD FOUND.
            BEGIN=J
            N_ABS_BAND=N_ABS_BAND+1
!
5           CONTINUE
               IF ( (LIST(J+1:J+1).EQ.' ').AND.
     &              (LIST(J:J).NE.' ') ) THEN
!                 END OF WORD FOUND.
                  END=J
!
!                 CHECK AND PERFORM READ.
                  IF ( (END-BEGIN).GT.4 ) THEN
                     WRITE(IU_ERR, '(/A)')
     &                 '+++ ERRONEOUS INPUT: A NUMBER IS TOO LARGE: '
                     IF (LOCK_CODE(.TRUE.)) THEN
                        INCLUDE 'batch_error.finc'
                     ELSE
                        WRITE(IU_ERR, '(A/)')
     &                    'PLEASE RE-ENTER THE DATA FOR THIS BAND.'
                        GOTO 1
                     ENDIF
                  ENDIF
                  DO K=1, 5
                     WORD(K:K)=' '
                  ENDDO
                  DO K=5+BEGIN-END, 5
                     WORD(K:K)=LIST(END-5+K:END-5+K)
                  ENDDO
!
!                 READ IN THE WORD.
                  READ(WORD, FMT='(I5)', IOSTAT=IOS)
     &               I_ABS_BAND(N_ABS_BAND)
                  IF (IOS.NE.0) THEN
                     WRITE(IU_ERR, '(/A)')
     &                 '+++ ERRONEOUS INPUT:'
                     IF (LOCK_CODE(.TRUE.)) THEN
                        INCLUDE 'batch_error.finc'
                     ELSE
                        WRITE(IU_ERR, '(A/)')
     &                    'PLEASE RE-ENTER THE DATA FOR THIS BAND.'
                        GOTO 1
                     ENDIF
                  ENDIF
                  J=J+1
                  GOTO 4
!
               ELSE
                  J=J+1
                  GOTO 5
               ENDIF
         ELSE IF (J.LT.LENGTH) THEN
            J=J+1
            GOTO 4
         ELSE
            CONTINUE
         ENDIF
!
!     RESET N_ABS_BAND IF THERE ARE ACTUALLY NO ABSORBERS ACTIVE IN
!     THE BAND.
      IF (I_ABS_BAND(1).EQ.0) THEN
         N_ABS_BAND=0
      ENDIF
!
!
!
      RETURN
      END
