      double precision function dgamr (x)
c july 1977 edition.  w. fullerton, c3, los alamos scientific lab.
c this routine, not dgamma(x), should be the fundamental one.
c
      double precision x, alngx, sgngx, dgamma, dint, dexp
      external dexp, dgamma, dint
c
      dgamr = 0.0d0
      if (x.le.0.0d0 .and. dint(x).eq.x) return
c
      call entsrc (irold, 1)
      if (dabs(x).gt.10.0d0) go to 10
      dgamr = 1.0d0/dgamma(x)
      call erroff
      call entsrc (ir, irold)
      return
c
 10   call dlgams (x, alngx, sgngx)
      call erroff
      call entsrc (ir, irold)
      dgamr = sgngx * dexp(-alngx)
      return
c
      end