      subroutine addrer (ofile, nfile, maxch)
      integer maxch
      integer*2 ofile(*)
      integer*2 nfile(*)
      integer*2 uscore
      integer len
      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 sp
      integer root
      integer ext
      integer errmsg
      logical isrefe
      integer fnroot
      integer fnextn
      integer strldx
      integer xstrln
      logical xerflg
      common /xercom/ xerflg
      integer*2 badnae(23)
      integer*2 st0001(6)
      integer*2 st0002(6)
      integer*2 st0003(6)
      save
      integer iyy
      data (badnae(iyy),iyy= 1, 8) / 73,108,108,101,103, 97,108, 32/
      data (badnae(iyy),iyy= 9,16) /102,105,108,101, 32,110, 97,109/
      data (badnae(iyy),iyy=17,23) /101, 32, 40, 37,115, 41, 0/
      data st0001 / 63,114,101,102, 36, 0/
      data st0002 / 63,114,101,102, 36, 0/
      data st0003 / 63,116, 97, 98, 36, 0/
      data uscore / 95 /
         if (.not.(.not. isrefe (ofile))) goto 110
            call xstrcy(ofile, nfile, maxch)
            goto 100
110      continue
         call smark (sp)
         call salloc (root, 255 , 2)
         call salloc (ext, 255 , 2)
         call salloc (errmsg, 1023 , 2)
         if (.not.(fnroot (ofile, memc(root), 255 ) .eq. 0)) goto 120
            call sprinf (memc(errmsg), 1023 , badnae)
            call pargsr (ofile)
            call xerror(1, memc(errmsg))
            if (xerflg) goto 100
120      continue
         if (.not.(fnextn (ofile, memc(ext), 255 ) .eq. 0)) goto 130
            call sprinf (memc(errmsg), 1023 , badnae)
            call pargsr (ofile)
            call xerror(1, memc(errmsg))
            if (xerflg) goto 100
130      continue
         if (.not.(memc(ext) .eq. 102)) goto 140
            len = strldx (uscore, memc(root)) - 1
            call xstrcy(st0001, nfile, maxch)
            nfile(1) = memc(root+len-1)
            goto 141
140      continue
         if (.not.(memc(ext) .eq. 114 .or. memc(ext) .eq. 98)) goto 150
            len = xstrln(memc(root))
            call xstrcy(st0002, nfile, maxch)
            nfile(1) = memc(root+len-1)
            goto 151
150      continue
            call xstrcy(st0003, nfile, maxch)
            nfile(1) = memc(ext+1)
151      continue
141      continue
         call xstrct(ofile, nfile, maxch)
         call sfree (sp)
100      return
      end
c     sprinf  sprintf
c     isrefe  is_reffile
c     badnae  badname
c     addrer  addrefdir
c     pargsr  pargstr
