      subroutine STORE
      include 'SIZE.INC'
      include 'GLOBAL.INC'
      include 'LOCAL.INC'
      include 'INPAR.INC'
      include 'UNITS.INC'
      real RESULT
      integer CC,EOF,INUNIT,VRAIL,WHICH,KT,IREC,II,J,KP,IMBED,NUSED
      character*1 CBUFF(VARCEC),TEMP(50)
      character REQFMT(2)*48
      data REQFMT(1)
     &  /'('' Replace?-> ''                                )'/
        data REQFMT(2)
     &  /'('' Please enter the Store Access Password-> ''  )'/
      INUNIT = TTYIN(MACHNO)
      call DECOD1 (1,WHICH,CC,RESULT)
      if (CC.gt.1) go to 240
      KT = 1
      if (MCHEMG.ge.1) KT = MCHEMG
      IREC = ifix(RESULT)
      if (WHICH.ge.2) go to 100
      call DECOD4 (1,IREC,KT,KCHEM,CC)
      if (CC.gt.1) go to 240
100   continue
      call DECOD2 (IREC,CC,WHICH,II,CBUFF)
      if (CC.eq.3) go to 240
      if (CC.eq.1) go to 200
110   continue
      if (WHICH.eq.1) then
         call PAK (IREC,KT)
         read (RANUNT(MACHNO),rec=II) CBUFF
         do 120 J = 1, 50
            TEMP(J) = CBUFF(J)
120      continue
         KP = VRAIL(TEMP)
         write (TTYOUT(MACHNO),5000) (TEMP(J),J=1,KP)
5000     format (/' Chemical stored > ',50A1)
      elseif (WHICH.eq.2) then
         call PAKENV (IREC)
         read (RANUNT(MACHNO),rec=II) CBUFF
         do 130 J = 1, 50
            TEMP(J) = CBUFF(J)
130      continue
         KP = VRAIL(TEMP)
         write (TTYOUT(MACHNO),5010) (TEMP(J),J=1,KP)
5010     format (/' Environment stored: ',50A1)
      elseif (WHICH.eq.3) then
         do 140 J = 1, 50
            if (LOADNM(J).ne.' ') go to 150
140      continue
         write (TTYOUT(MACHNO),5020)
5020  format (' You must execute "LOAD NAME IS" before STORE can'/' ente
     &r the data into the UDB catalog.')
         write (TTYOUT(MACHNO),5070)
         go to 240
150      continue
         call PACLDS (IREC)
         read (RANUNT(MACHNO),rec=II) CBUFF
         do 160 J = 1, 50
            TEMP(J) = CBUFF(J)
160      continue
         KP = VRAIL(TEMP)
         write (TTYOUT(MACHNO),5030) (TEMP(J),J=1,KP)
5030     format (/1X,'Load stored: ',50A1)
      elseif (WHICH.eq.4) then
         do 170 J = 1, 50
            if (PRODNM(J).ne.' ') go to 180
170      continue
         write (TTYOUT(MACHNO),5040)
5040     format (' You must execute "PRODUCT NAME IS" before STORE can'/
     &      ' enter the data into the UDB catalog.')
         write (TTYOUT(MACHNO),5070)
         go to 240
180      continue
         call PACPRO (IREC)
         read (RANUNT(MACHNO),rec=II) CBUFF
         do 190 J = 1, 50
            TEMP(J) = CBUFF(J)
190      continue
         KP = VRAIL(TEMP)
         write (TTYOUT(MACHNO),5050) (TEMP(J),J=1,KP)
5050     format (/1X,'Product stored: ',50A1)
      else
         write (TTYOUT(MACHNO),5070)
      endif
      go to 240
200   continue
      do 210 J = 1, 50
         TEMP(J) = CBUFF(J)
210   continue
      KP = VRAIL(TEMP)
      write (TTYOUT(MACHNO),5060) IREC,(TEMP(J),J=1,KP)
5060  format (/' Record ',I3,' is in use with'/1X,50A1/)
      REQFMT(1)(16:17) = CRSTOP(MACHNO)
      write (TTYOUT(MACHNO),REQFMT(1))
      call INREC (EOF,INUNIT,INPUT)
      if (EOF.eq.1) go to 230
      START = IMBED(INPUT,0)
      if (START.eq.-999) then
         write (TTYOUT(MACHNO),5070)
         goto 240
      endif
      if (INPUT(START:START).ne.'Y'.and.INPUT(START:START).ne.'y') then
         write (TTYOUT(MACHNO),5070)
5070     format (/' STORE command has been cancelled.')
         go to 240
      endif
      NUSED = 50
      do 220 J = 1, 6
         RPASS(WHICH)(J:J) = CBUFF(NUSED+1)
         WPASS(WHICH)(J:J) = CBUFF(NUSED+2)
         NUSED = NUSED+2
220   continue
      if (WPASS(WHICH).eq.'GLOBAL') go to 110
      write (TTYOUT(MACHNO),5080)
5080  format (' This entry is protected from unauthorized revision.')
      REQFMT(2)(46:47) = CRSTOP(MACHNO)
      write (TTYOUT(MACHNO),REQFMT(2))
      call INREC (EOF,INUNIT,INPUT)
      if (EOF.eq.1) then
         write (TTYOUT(MACHNO),5090)
5090     format (' End-of-file while reading password -- STORE aborted.'
     &      )
         go to 240
      endif
      START = IMBED(INPUT,0)
      if (START.eq.-999) then
         write (TTYOUT(MACHNO),5070)
         go to 240
      endif
      if (INPUT(START:START+5).eq.WPASS(WHICH).or.INPUT(START:START+5)
     &   .eq.SYSPAS) go to 110
      write (TTYOUT(MACHNO),5100)
5100  format (' Password does not match.  Please check your records;')
      write (TTYOUT(MACHNO),5070)
      go to 240
230   continue
      write (TTYOUT(MACHNO),5110)
5110  format (/1X,'E-O-F encountered on input.')
      go to 240
240   continue
      return
      end
