      function gamr (x)
c july 1977 edition.  w. fullerton, c3, los alamos scientific lab.
c this routine, not gamma(x), should be the fundamental one.
c
      external aint, exp, gamma
c
      gamr = 0.0
      if (x.le.0.0 .and. aint(x).eq.x) return
c
      call entsrc (irold, 1)
      if (abs(x).gt.10.0) go to 10
      gamr = 1.0/gamma(x)
      call erroff
      call entsrc (ir, irold)
      return
c
 10   call algams (x, alngx, sgngx)
      call erroff
      call entsrc (ir, irold)
      gamr = sgngx * exp(-alngx)
      return
c
      end