      integer function log2(np)
      integer i,np

      log2=0
      i=np

      do while(i.gt.1)
        log2=log2+1
        i=i/2
      end do

      return
      end
