C.hr gammln
C@
C....*...1.........2.........3.........4.........5.........6.........7.*
* 
*     this is a modification of the routine of the same name in press, 
*     william h., brian p. flannery, saul a. teukolsky, and william t.
*     vetterling (1986), numerical recipes, cambridge university press,
*     cambridge, u.k., p. 157.
*
      real*8 function gammln(xx)
      implicit none
      save
      real*8 cof(6),stp,half,one,fpf,x,xx,tmp,ser
      integer*4 j
      intrinsic DLOG
      data cof,stp/76.18009173d0,-86.50532033d0,24.01409822d0,
     *    -1.231739516d0,.120858003d-2,-.536382d-5,2.50662827465d0/
      data half,one,fpf/0.5d0,1.0d0,5.5d0/
      x=xx-one
      tmp=x+fpf
      tmp=(x+half)*DLOG(tmp)-tmp
      ser=one
      do 11 j=1,6
        x=x+one
        ser=ser+cof(j)/x
11    continue
      tmp=tmp+DLOG(stp*ser)
      gammln=tmp
      return
      end



