!+ Subroutine to read and process a line giving p and T.
!
! 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_PT_LINE(IERR, L_FILE, N_PT_PAIR, P, T, L_FINISH)
!
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/dimensions_pp.ucf'
      INCLUDE 'incl/def_std_io.icf'
      INCLUDE 'incl/error.pcf'
!
!
!     DUMMY ARGUMENTS
      INTEGER	!, INTENT(OUT)
     &     IERR
!             ERROR FLAG
      LOGICAL	!, INTENT(IN)
     &     L_FILE
!             FLAG SET AS TRUE WHEN READING FROM A FILE
      INTEGER	!, INTENT(OUT)
     &     N_PT_PAIR
!             NUMBER OF PAIRS
      LOGICAL	!, INTENT(OUT)
     &     L_FINISH
!             TERMINATION FLAG
      REAL*8	!, INTENT(OUT)
     &     P(NPD_PT)
!             VALUES OF PRESSURES.
     &   , T(NPD_PT)
!             VALUES OF TEMPERATURES.
!
!
!     LOCAL VARAIBLES
!
      LOGICAL
     &     LOCK_CODE
!             LOGICAL TO FORBID INTERACTIVE LOOPING
      EXTERNAL
     &     LOCK_CODE
!
      INTEGER
     &     LENGTH
!             LENGTH OF INPUT LINE
     &   , N_WORD
!             NUMBER OF WORDS IN LINE
     &   , I
!             LOOP VARIABLE
     &   , 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*12
!             INPUT NUMBER
      LOGICAL
     &     L_NEXT
!             FLAG TO READ NEXT LINE
      REAL*8
     &     X(NPD_PT)
!             WORDS READ IN
!
!
!
!     INITIALIZE INPUT VARIABLES.
1     LIST(1:1)=' '
      BEGIN=2
!
      IF (.NOT.L_FILE) THEN
         WRITE(IU_USER, '(A)')
     &      'SPECIFY PRESSURE AND CORRESPONDING TEMPERATURES '
     &      //'(*END TO FINISH)'
      ENDIF
!

      L_NEXT=.TRUE.
!     THE NEXT LINE WILL BE READ UNTIL L_NEXT IS FALSE.
      DO WHILE (L_NEXT)
         IF (.NOT.L_FILE) THEN
            READ(IU_STDIN, '(A)', IOSTAT=IOS) LINE
            DO WHILE (IOS.NE.0)
               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.'
                  READ(IU_STDIN, '(A)', IOSTAT=IOS) LINE
               ENDIF
            ENDDO
         ELSE
            READ(IU_FILE_IN, '(A)', IOSTAT=IOS) LINE
            IF (IOS.NE.0) THEN
               WRITE(IU_ERR, '(A)')
     &            '*** ERROR: AN ERROR OCCURING WHILE READING THE '
     &            //'PRESSURES AND TEMPERATURES.'
               IERR=I_ERR_FATAL
               RETURN
            ENDIF
         ENDIF
!
!        CHECK WHETHER CONCATENATION IS REQUIRED.
         END=80
         DO WHILE (LINE(END:END).EQ.' ')
            END=END-1
         ENDDO
         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
!
      ENDDO
!
!
!     DETERMINE THE LENGTH OF THE INPUT LINE AND PROCESS TO DETERMINE
!     THE NUMBERS CONTAINED THEREIN.
      LIST(BEGIN:BEGIN)=' '
      LENGTH=BEGIN
      N_WORD=0
      J=2
      DO WHILE (J.LT.LENGTH)
         IF ( (LIST(J-1:J-1).EQ.' ').AND.(LIST(J:J).NE.' ') ) THEN
!           BEGINNING OF WORD FOUND.
            BEGIN=J
            N_WORD=N_WORD+1
!           CHECK FOR TERMINATION OF INPUT: A LINE BEGINS WITH 'F' 
!           OR 'f' OR THE DIRECTIVE "*END"
            IF (N_WORD.EQ.1) THEN
               IF ( (LIST(J:J).EQ.'F').OR.
     &              (LIST(J:J).EQ.'f').OR.
     &              (LIST(J:J+3).EQ.'*END') ) THEN
                  L_FINISH=.TRUE.
                  RETURN
               ENDIF
            ENDIF
         ENDIF
!
         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.11 ) THEN
               WRITE(IU_ERR, '(/A)')
     &           '+++ ERRONEOUS INPUT: A NUMBER IS TOO LARGE: '
               IF (L_FILE) THEN
                  IERR=I_ERR_FATAL
                  RETURN
               ELSE
                  IF (LOCK_CODE(.TRUE.)) THEN
                     INCLUDE 'batch_error.finc'
                  ELSE
                     WRITE(IU_USER, '(A)')
     &                  'PLEASE RE-ENTER THE LIST.'
                     GOTO 1
                  ENDIF
               ENDIF
            ENDIF
            DO K=1, 12
               WORD(K:K)=' '
            ENDDO
            DO K=12+BEGIN-END, 12
               WORD(K:K)=LIST(END-12+K:END-12+K)
            ENDDO
!
!           READ IN THE WORD.
            READ(WORD, FMT='(E12.5)', IOSTAT=IOS)
     &         X(N_WORD)
            IF (IOS.NE.0) THEN
               WRITE(IU_ERR, '(/A/)') '+++ ERRONEOUS INPUT:'
               IF (L_FILE) THEN
                  IERR=I_ERR_FATAL
                  RETURN
               ELSE
                  IF (LOCK_CODE(.TRUE.)) THEN
                     INCLUDE 'batch_error.finc'
                  ELSE
                     WRITE(IU_USER, '(/A/)') 'PLEASE RE-ENTER'
                     GOTO 1
                  ENDIF
               ENDIF
            ENDIF
         ENDIF
         J=J+1
      ENDDO
!
!     TRANSFER THE NUMBERS READ IN TO THE ARRAYS OF P AND T.
!     CHECK ARRAY SIZES.
      IF (N_WORD-1+N_PT_PAIR.GT.NPD_PT) THEN
         WRITE(IU_ERR, '(/A22, A)')
     &      '+++ TOO MANY PAIRS OF PRESSURE AND TEMPERATURE. '
         WRITE(IU_ERR, '(A, I5)')
     &      'MAXIMUM NUMBER ALLOWED = ', NPD_PT
         IF (L_FILE) THEN
            IERR=I_ERR_FATAL
            RETURN
         ELSE
            IF (LOCK_CODE(.TRUE.)) THEN
               INCLUDE 'batch_error.finc'
            ELSE
               WRITE(IU_USER, '(A)')
     &            'PLEASE RE-SPECIFY THIS LAST LINE.'
               GOTO 1
            ENDIF
         ENDIF
      ELSE IF (N_WORD.EQ.1) THEN
         WRITE(IU_ERR, '(/A)') '+++ NO TEMPERATURES GIVEN:'
         IF (L_FILE) THEN
            IERR=I_ERR_FATAL
            RETURN
         ELSE
            IF (LOCK_CODE(.TRUE.)) THEN
               INCLUDE 'batch_error.finc'
            ELSE
               WRITE(IU_USER, '(/A)') 'RE-ENTER THE LIST.'
               GOTO 1
            ENDIF
         ENDIF
      ELSE
         DO I=2, N_WORD
            N_PT_PAIR=N_PT_PAIR+1
            P(N_PT_PAIR)=X(1)
            T(N_PT_PAIR)=X(I)
         ENDDO
      ENDIF

!
!
      RETURN
      END
