      subroutine genun(u,n,m)

c  this subroutine written by alain st-amant of the department of
c  pharmaceutical chemistry, university of california, san francisco.
c  all rights reserved.  this is part of the DeFT project.
c
c  this is based on a subroutine taken out of connolly's ms program.

      implicit real*8(a-h,o-z)

      dimension u(3,*)

      data two,pi/2.0d0,3.1415926535898d0/

      nequator=sqrt(n*pi)

      nvertical=nequator/2

      m=0

      do 1001 i=1,nvertical+1

      theta=(pi*real64((i-1)))/real64(nvertical)

      z=cos(theta)
      xy=sin(theta)

      nhorizontal=max(1,int(real64(nequator)*xy))

      do 1001 j=1,nhorizontal

      phi=(two*pi*real64((j-1)))/real64(nhorizontal)

      x=cos(phi)*xy
      y=sin(phi)*xy

      m=m+1

      u(1,m)=x
      u(2,m)=y
      u(3,m)=z

 1001 continue

      return
      end
