      subroutine NEWNAM(IT)
      include 'SIZE.INC'
      include 'GLOBAL.INC'
      include 'INPAR.INC'
      include 'UNITS.INC'
      integer NUMB1,NUMB2,NUMB3,LEN1(3),LEN2(3),LEN3(2)
      integer NAMLN1,NAMLN2,NAMLN3
      integer MINNO1(3),MINNO2(3),MINNO3(2)
      integer EOF,INUNIT,WHICH,IFIND,I,ISAVE,IMBED,K,J,IT
      character NAME1(12)*1, NAME2(10)*1, NAME3(8)*1, REQFMT*27
      data REQFMT/'(/1X,''Enter new name-> ''  )'/
      data NUMB1, NUMB2, NUMB3 /3, 3, 2/
      data NAMLN1,NAMLN2,NAMLN3 /12,10,8/
      data LEN1, LEN2, MINNO1, MINNO2 /4,4,4, 2,4,4, 1,1,1, 1,1,1 /
      data LEN3, MINNO3 /4,4, 1,1/
      data NAME1 /'N','A','M','E', 'H','E','L','P', 'Q','U','I','T'/
      data NAME2 /'I','S', 'H','E','L','P', 'Q','U','I','T'/
      data NAME3 /'H','E','L','P', 'Q','U','I','T'/
      WHICH = IFIND(NUMB1,NAMLN1,LEN1,NAME1,MINNO1)
      I = WHICH+3
      go to (100,220,230,110,100,200), I
100   continue
      write (TTYOUT(MACHNO),5000)
5000  format(//' Options available are '//                              
     .  10X,' Help                 - this message.'/                    
     .  10X,' Quit                 - return to EXAMS command mode.'/    
     .  10X,' <carriage return>    = Help'/                             
     .  10X,' <any other response> - accepted as the new name.'/        
     .  10X,' For more information, quit to the EXAMS prompt'/          
     .  10X,' and then type "HELP NAME".')
      REQFMT(25:26) = CRSTOP(MACHNO)
      write (TTYOUT(MACHNO),REQFMT)
      INUNIT = TTYIN(MACHNO)
      call INREC (EOF,INUNIT,INPUT)
      if (EOF.eq.1) go to 200
      STOPIT = 0
      go to 120
110   continue
      WHICH = IFIND(NUMB2,NAMLN2,LEN2,NAME2,MINNO2)
      I = WHICH+3
      go to (100,220,230,120,100,200), I
120   continue
      ISAVE = STOPIT
      WHICH = IFIND(NUMB3,NAMLN3,LEN3,NAME3,MINNO3)
      I = WHICH+3
      go to (130,220,130,100,200), I
130   continue
      STOPIT = ISAVE
140   continue
      START = IMBED(INPUT,STOPIT)
      if (START.eq.-999) go to 100
      do 160 K = 80, START, -1
         if (INPUT(K:K).ne.' ') go to 170
160   continue
      go to 140
170   continue
      J = 1
      do 180 I = START, K
         if (IT.eq.0) CHEMNA(J,MCHEMG) = INPUT(I:I)
         if (IT.eq.1) ECONAM(J) = INPUT(I:I)
         if (IT.eq.2) LOADNM(J) = INPUT(I:I)
         if (IT.eq.3) PRODNM(J) = INPUT(I:I)
         J = J+1
         if (J.gt.51) go to 210
180   continue
      if (J.gt.50) go to 200
      do 190 I = J, 50
         if (IT.eq.0) CHEMNA(I,MCHEMG) = ' '
         if (IT.eq.1) ECONAM(I) = ' '
         if (IT.eq.2) LOADNM(I) = ' '
         if (IT.eq.3) PRODNM(I) = ' '
190   continue
200   continue
      return
210   continue
      write (TTYOUT(MACHNO),5010)
5010  format (' Remainder of name truncated. Maximum length is 50.')
      go to 200
220   continue
      write (TTYOUT(MACHNO),5020)
5020  format (//' End-of-file encountered.'//)
      go to 200
230   continue
      write (TTYOUT(MACHNO),5030)
5030  format (//' Option not identified.'//)
      go to 200
      end
