******************************** ngamma ********************************

      integer function n(gammat)
      implicit real*8(a-h,o-z)
      pi=4.d0*datan(1.d0)
      itmp=ifloor(gammat/(2*pi))
      n=itmp-(1+2*itmp)*iabs(mod(ifloor(gammat/pi),2))
      return
      end

*   can't name function below 'gamma' since that name already taken
      real*8 function gamm(gammat)
      implicit real*8(a-h,o-z)
      pi=4.d0*datan(1.d0)
      gamm=dabs(dabs(dmod(gammat-pi,2*pi))-pi)
      return
      end

      integer function ifloor(x)
      implicit real*8(a-h,o-z)
      if (x.ge.0.d0) then
         ifloor=int(x)
      else
         ifloor=int(x)-1
      end if
      return
      end


