      subroutine on_ran(sta,n,ns) ! bernd berg, feb 12 2002.
c assigns random (i.e. beta=0) values to the spins in ista(n,ms).
      include '../../libs/fortran/implicit.sta'
      include '../../libs/fortran/constants.par'
      dimension sta(n,ns)
      do is=1,ns
1       sum=zero
          do i=1,n
            sta(i,is)=two*(rmafun()-half)
            sum=sum+sta(i,is)**2
          end do
        if(sum.gt.one) go to 1
        fn=one/sqrt(sum)
        do i=1,n
          sta(i,is)=fn*sta(i,is)
        end do
      end do
      return
      end
