      subroutine DECOD1(OPTION,WHICH,CC,RESULT)
      include 'INPAR.INC'
      include 'UNITS.INC'
      real RESULT
      integer IMBED, MATCH
      integer CC,EOF,ERROR,INUNIT,MNRESP(6),NORESP(6),OPTION,WHICH
      integer IT,HQUIT(2),HELMIN(2),SIX,RSPSIZ,TWO,HELSIZ
      character HELNAM(8)*1,OPT(5)*8,RESP(38)*1,BLANK*1
      character REQFMT*25
      data REQFMT/'(1X,''Help, or Quit-> ''  )'/
      data OPT / 'Store   ','Recall  ','Erase   ','Catalog '
     &, 'Password'/
      data RESP  /'C','H','E','M','I','C','A','L','E','N','V','I',
     &'R','O','N','M','E','N','T','L','O','A','D','P','R','O',
     &'D','U','C','T','H','E','L','P','Q','U','I','T'/
      data BLANK, NORESP, MNRESP /' ', 8,11,4,7,4,4, 1,1,1,1,1,1/
      data HQUIT,HELMIN,SIX,RSPSIZ,TWO,HELSIZ/4,4, 1,1, 6, 38, 2, 8/
      data HELNAM/'H','E','L','P', 'Q','U','I','T'/
      CC = 1
      INUNIT = TTYIN(MACHNO)
      REQFMT(23:24) = CRSTOP(MACHNO)
      START = IMBED(INPUT,STOPIT)
      if (START.ne.-999) go to 110
100   continue
      write (TTYOUT(MACHNO),5000)
5000  format (' Enter Environment, Chemical, Load, Product,')
      write (TTYOUT(MACHNO),REQFMT)
      call INREC (EOF,INUNIT,INPUT)
      if (EOF.eq.1) go to 150
      START = IMBED(INPUT,0)
      if (START.eq.-999) go to 100
110   continue
      call SKAN (INPUT,START,STOPIT,TYPE,BLANK,1)
      if (TYPE.eq.100) STOPIT = 81
      WHICH = MATCH(SIX,RSPSIZ,NORESP,RESP,MNRESP)
      if (WHICH.le.0.or.WHICH.gt.6) then
         write (TTYOUT(MACHNO),5010)
5010     format (/' Response not recognized, please try again--')
         go to 100
      endif
      go to (120,120,120,120,170,180), WHICH
120   continue
      if (OPTION.eq.4) go to 190
130   continue
      call GETNUM (ERROR,RESULT)
      go to (190,140), ERROR+1
      IT = MATCH(TWO,HELSIZ,HQUIT,HELNAM,HELMIN)
      go to (160,180), IT
      write (TTYOUT(MACHNO),5020)
5020  format (/' Invalid record number specified.  Command cancelled.')
      go to 180
140   continue
      if (WHICH.eq.1) write (TTYOUT(MACHNO),5030)
5030  format (/' Enter chemical UDB catalog number,')
      if (WHICH.eq.2) write (TTYOUT(MACHNO),5040)
5040  format (/' Enter environment UDB catalog number,')
      if (WHICH.eq.3) write (TTYOUT(MACHNO),5050)
5050  format (/' Enter allochthonous loading UDB catalog number,')
      if (WHICH.eq.4) write (TTYOUT(MACHNO),5060)
5060  format (/' Enter product chemistry UDB catalog number,')
      write (TTYOUT(MACHNO),REQFMT)
      call INREC (EOF,INUNIT,INPUT)
      if (EOF.eq.1) go to 150
      STOPIT = 0
      go to 130
150   continue
      CC = 2
      write (TTYOUT(MACHNO),5070)
5070  format (/' End-of-File encountered on input.')
      go to 190
160   continue
      write (TTYOUT(MACHNO),5080)
5080  format (/' Enter the User Database Catalog Number'/' of the datase
     &t to be processed.'//' (If you need more information, quit to the 
     &EXAMS >'/'  prompt and then type "HELP UDB".)')
      go to 140
170   continue
      write (TTYOUT(MACHNO),5090) OPT(OPTION)
5090  format (/' The ',A8,' command requires that you specify either'/  
     &10X,'1. Environment,'/10X,'2. Chemical, '/10X,'3. Load,'/10X,'4. P
     &roduct,'/10X,'5. Help (this option), or'/10X,'6. Quit.'//)
      go to 100
180   continue
      CC = 4
190   continue
      return
      end
