      SUBROUTINE GETTXT
      include 'MOP6FILE'
      common /KEYWRD/ KEYWRD
      common /TITLES/ KOMENT,TITLE
      dimension IS(3)
      character KEYWRD*241, KOMENT*81, TITLE*81, CH*1, CH2*1, FILEN*50
     +,GETNAM*80
      IS(1)=161
      IS(2)=81
      IS(3)=1
      KEYWRD=' '
      KOMENT='    NULL  '
      TITLE ='    NULL  '
      read(MIOA,'(A)',end=100,ERR=90) KEYWRD(:80)
      call UPCASE(KEYWRD(1:80))
      if (INDEX(KEYWRD,'SETUP').NE.0) then
         I=INDEX(KEYWRD,'SETUP=')
         if (I.NE.0) then
            J=INDEX(KEYWRD(I:),' ')
            FILEN=KEYWRD(I+6:I+J-1)
         else
            FILEN='SETUP'
         end if
         open(unit=MIOL,file=GETNAM(FILEN),
     +        status='UNKNOWN',form='FORMATTED')
         rewind MIOL
         read(MIOL,'(A)',end=40,ERR=40) KEYWRD(81:160)
         call UPCASE(KEYWRD(81:160))
         read(MIOL,'(A)',end=10,ERR=10) KEYWRD(161:240)
         call UPCASE(KEYWRD(161:240))
   10    continue
         read(MIOA,'(A)',end=100,ERR=90) KOMENT,TITLE
      else if (INDEX(KEYWRD(1:80),' +') .NE.0) then
C
C  READ SECOND KEYWORD LINE
C
         read(MIOA,'(A)',end=100,ERR=90)KEYWRD(81:160)
         call UPCASE(KEYWRD(81:160))
         if (INDEX(KEYWRD(81:160),'SETUP').NE.0) then
            I=INDEX(KEYWRD,'SETUP=')
            if (I.NE.0) then
               J=INDEX(KEYWRD(I:),' ')
               FILEN=KEYWRD(I+6:I+J)
            else
               FILEN='SETUP'
            end if
            open(unit=MIOL,file=GETNAM(FILEN)
     +          ,status='UNKNOWN',form='FORMATTED')
            rewind MIOL
            read(MIOL,'(A)',end=20,ERR=20) KEYWRD(161:240)
            call UPCASE(KEYWRD(161:240))
   20       continue
         else if (INDEX(KEYWRD(81:160),' +') .NE.0) then
C
C  READ THIRD KEYWORD LINE
C
            read(MIOA,'(A)',end=100,ERR=90)KEYWRD(161:240)
            call UPCASE(KEYWRD(161:240))
         end if
C
C  READ TITLE LINE
C
         read(MIOA,'(A)',end=100,ERR=90) KOMENT,TITLE
      else if (INDEX(KEYWRD(:80),'&').NE.0) then
         read(MIOA,'(A)',end=100,ERR=90) KEYWRD(81:160)
         call UPCASE(KEYWRD(81:160))
         if (INDEX(KEYWRD(81:160),'SETUP').NE.0) then
            I=INDEX(KEYWRD,'SETUP=')
            if (I.NE.0) then
               J=INDEX(KEYWRD(I:),' ')
               FILEN=KEYWRD(I+6:I+J)
            else
               FILEN='SETUP'
            end if
            open(unit=MIOL,file=GETNAM(FILEN),
     +           status='UNKNOWN',form='FORMATTED')
            rewind MIOL
            read(MIOL,'(A)',end=30,ERR=30) KEYWRD(161:240)
            call UPCASE(KEYWRD(161:240))
            read(MIOA,'(A)',end=100,ERR=90)TITLE
   30       continue
         else if (INDEX(KEYWRD(81:160),'&').NE.0) then
            read(MIOA,'(A)',end=100,ERR=90)KEYWRD(161:240)
         else
            read(MIOA,'(A)',end=100,ERR=90)TITLE
         end if
      else
         read(MIOA,'(A)',end=100,ERR=90) KOMENT,TITLE
      end if
      go to 50
   40 write(MIOB,'(A)') ' SETUP FILE MISSING OR CORRUPT'
   50 do 80 J=1,3
         if (KEYWRD(IS(J):IS(J)) .NE. ' ') then
            CH=KEYWRD(IS(J):IS(J))
            KEYWRD(IS(J):IS(J))=' '
            do 60 I=IS(J)+1,239
               CH2=KEYWRD(I:I)
               KEYWRD(I:I)=CH
               CH=CH2
               if (KEYWRD(I+1:I+2) .EQ. '  ') then
                  KEYWRD(I+1:I+1)=CH
                  go to 70
               end if
   60       continue
            write(MIOB,'(A,I2,A)')
     %       ' LINE',J,' OF KEYWORDS DOES NOT HAVE ENOUGH'
         write(MIOB,'(A)')' SPACES FOR PARSING.  PLEASE CORRECT LINE.'
            call filclo  ! J/M
            stop ' in GETTXT - more blanks in keyword liness needed'
   70       continue
         end if
   80 continue
      return
   90 write(MIOB,'(A)') ' ERROR IN READ OF FIRST THREE LINES'
c
  100 call filclo ! J/M
      stop ' in GETTXT -NO TIME, error in first 3 lines or no more data'
      end
