      subroutine uprefe ()
      logical Memb(1)
      integer*2 Memc(1)
      integer*2 Mems(1)
      integer Memi(1)
      integer*4 Meml(1)
      real Memr(1)
      double precision Memd(1)
      complex Memx(1)
      equivalence (Memb, Memc, Mems, Memi, Meml, Memr, Memd, Memx)
      common /Mem/ Memd
      integer input
      logical verify
      integer ref
      integer sp
      integer key
      integer value
      integer temple
      integer file
      integer oper
      integer oldfie
      integer errmsg
      integer list
      integer im
      logical clgetb
      logical strne
      integer fstati
      integer xfopen
      integer imtgem
      integer rdrefe
      integer immap
      integer imtopn
      logical xerpop
      logical xerflg
      common /xercom/ xerflg
      integer*2 badime(24)
      integer*2 st0001(6)
      integer*2 st0002(6)
      integer*2 st0003(7)
      save
      integer iyy
      data (badime(iyy),iyy= 1, 8) / 67, 97,110,110,111,116, 32,111/
      data (badime(iyy),iyy= 9,16) /112,101,110, 32,105,109, 97,103/
      data (badime(iyy),iyy=17,24) /101, 32, 40, 37,115, 41, 10, 0/
      data st0001 /105,110,112,117,116, 0/
      data st0002 / 83, 84, 68, 73, 78, 0/
      data st0003 /118,101,114,105,102,121, 0/
         call smark (sp)
         call salloc (input, 255 , 2)
         call salloc (key, 255 , 2)
         call salloc (value, 255 , 2)
         call salloc (temple, 255 , 2)
         call salloc (file, 255 , 2)
         call salloc (oper, 255 , 2)
         call salloc (oldfie, 255 , 2)
         call salloc (errmsg, 1023 , 2)
         call poster ()
         if (.not.(fstati (3 , 35 ) .eq. 0)) goto 110
            call clgstr (st0001, memc(input), 255 )
            goto 111
110      continue
            call xstrcy(st0002, memc(input), 255 )
111      continue
         verify = clgetb (st0003)
         ref = xfopen(memc(input), 1 , 11 )
         im = 0
         memc(oldfie) = 0
120      if (.not.(rdrefe (ref, memc(key), memc(value), memc(temple), 
     *   memc(oper), 255 ) .ne. -2)) goto 121
            list = imtopn (memc(temple))
130         if (.not.(imtgem (list, memc(file), 255 ) .ne. -2)) goto 131
               if (.not.(strne (memc(file), memc(oldfie)))) goto 140
                  if (.not.(im .ne. 0)) goto 150
                     call imunmp (im)
150               continue
                  call xerpsh
                  im = immap (memc(file), 2, 0)
162               if (.not.xerpop()) goto 160
                     call sprinf (memc(errmsg), 1023 , badime)
                     call pargsr (memc(file))
                     call xerror(1, memc(errmsg))
                     if (xerflg) goto 100
160               continue
                  call xstrcy(memc(file), memc(oldfie), 255 )
140            continue
               if (.not.(im .ne. 0)) goto 170
                  call uphear (im, memc(key), memc(value), memc(oper), 
     *            verify)
170            continue
               goto 130
131         continue
            call imtcle (list)
            goto 120
121      continue
         if (.not.(im .ne. 0)) goto 180
            call imunmp (im)
180      continue
         call xfcloe(ref)
         call sfree (sp)
100      return
      end
c     temple  template
c     sprinf  sprintf
c     oldfie  oldfile
c     imtgem  imtgetim
c     imtcle  imtclose
c     rdrefe  rd_reffile
c     poster  post_exit_handler
c     uprefe  upreffile
c     imunmp  imunmap
c     uphear  upheader
c     imtopn  imtopen
c     badime  badimage
c     pargsr  pargstr
