!creating uniform grids
      program test
      implicit none
      integer i,j,k,msect,nparams,ip(10),n,m
      msect=4
      nparams=3
      do i=1,msect**nparams
        do j=1,nparams
!the size of the larger repeated unit is msect**(nparams-j+1)
          k=i/(msect**(nparams-j+1))
          n=mod(i,(msect**(nparams-j+1)))
          if(n.eq.0)k=k-1
!k is the number of repeated units before i (not include the unit i is in)
          k=i-k*(msect**(nparams-j+1))
!now k is the position in the larger repeated unit
!
!the size of the smaller repeated unit is (msect**(nparams-j+1))/msect
          m=(msect**(nparams-j+1))/msect
          n=k/m
          if(mod(k,m).ne.0)n=n+1
          ip(j)=n
        enddo
        write(1,210)(ip(j),j=1,nparams)
      enddo
210   format(1x,10i3)
      end
