        subroutine AUDOPT
      include 'INPAR.INC'
      include 'UNITS.INC'
      integer EOF,DATLEN(4),INUNIT,MINDAT(4),NDATA,IA,IFIND,LENAM
      character DATNAM(13)*1
      character REQFMT*17
      data REQFMT/'(1X,''AUDIT-> ''  )'/
      data NDATA, DATLEN, MINDAT, LENAM /4, 2,3,4,4, 2,2,1,1, 13/
      data DATNAM /'O','N', 'O','F','F', 'H','E','L','P',
     &  'Q','U','I','T'/
      INUNIT = TTYIN(MACHNO)
100   continue
      IA = IFIND(NDATA,LENAM,DATLEN,DATNAM,MINDAT)
      IA = IA+3
      go to (110,130,140,150,160,110,120), IA
110   continue
      write (TTYOUT(MACHNO),5000)
5000  format (/1X,'The following AUDIT options are available'//16X,'ON  
     & -- begins a new Audit File,'/16X,'OFf  -- ends Audit recording of
     & input commands,'/16X,'Help -- this message,'/16X,'Quit -- return 
     &to the EXAMS prompt.')
      REQFMT(15:16) = CRSTOP(MACHNO)
      write (TTYOUT(MACHNO),REQFMT)
      call INREC (EOF,INUNIT,INPUT)
      if (EOF.eq.1) go to 130
      STOPIT = 0
      go to 100
120   continue
      return
130   continue
      write (TTYOUT(MACHNO),5010)
5010  format (//' End-of-file encountered.'//)
      go to 120
140   continue
      write (TTYOUT(MACHNO),5020)
5020  format (//' Option not identified.'//)
      go to 120
150   continue
      AUDFLG = 1
      write (TTYOUT(MACHNO),5030) AUDLUN(MACHNO)
5030  format (//' All input will now be copied into a file'/            
     &' named "AUDOUT.XMS" on Fortran Unit Number ',I2)
      open (unit=AUDLUN(MACHNO),FILE='AUDOUT.XMS',status='UNKNOWN',
     &   access='SEQUENTIAL',form='FORMATTED')
      if (.not.(TOPOPN(MACHNO))) rewind AUDLUN(MACHNO)
      write (AUDLUN(MACHNO),5040)
5040  format (' ! Audit trail of input sequence from EXAMS.')
      endfile AUDLUN(MACHNO)
      close (unit=AUDLUN(MACHNO))
      go to 120
160   continue
      AUDFLG = 0
      write (TTYOUT(MACHNO),5050)
5050  format (//' The AUDIT option has been terminated.')
      go to 120
      end
