      subroutine numery(n,r,NR)
      implicit none
      include 'mpif.h'
      
      integer j,k,l,n,r,il,c,pyt
      character*10 NR
      character D
      dimension c(0:10),D(0:10),NR(0:10000)
      D(0)='0'
      D(1)='1'
      D(2)='2'
      D(3)='3'
      D(4)='4'
      D(5)='5'
      D(6)='6'
      D(7)='7'
      D(8)='8'
      D(9)='9'
      D(10)='*'

      do 1,j=0,n,1

      il=j
      do 2,k=r,1,-1
      c(k)=mod(il,10)
      il=il/10
    2 continue

      if(r.eq.1)then
      NR(j)=D(c(r))
      elseif(r.eq.2)then
      NR(j)=D(c(r-1))//D(c(r))
      elseif(r.eq.3)then
      NR(j)=D(c(r-2))//D(c(r-1))//D(c(r))
      elseif(r.eq.4)then
      NR(j)=D(c(r-3))//D(c(r-2))//D(c(r-1))//D(c(r))
      elseif(r.eq.5)then
      NR(j)=D(c(r-4))//D(c(r-3))//D(c(r-2))//D(c(r-1))//D(c(r))
      elseif(r.eq.6)then
      NR(j)=D(c(r-5))//D(c(r-4))//D(c(r-3))//D(c(r-2))//D(c(r-1))
     $//D(c(r))
      elseif(r.eq.7)then
      NR(j)=D(c(r-6))//D(c(r-5))//D(c(r-4))//D(c(r-3))//D(c(r-2))
     $//D(c(r-1))//D(c(r))
      elseif(r.eq.8)then
      NR(j)=D(c(r-7))//D(c(r-6))//D(c(r-5))//D(c(r-4))//D(c(r-3))
     $//D(c(r-2))//D(c(r-1))//D(c(r))
      elseif(r.eq.9)then
      NR(j)=D(c(r-8))//D(c(r-7))//D(c(r-6))//D(c(r-5))//D(c(r-4))
     $//D(c(r-3))//D(c(r-2))//D(c(r-1))//D(c(r))
      else
      NR(j)=D(c(r-9))//D(c(r-8))//D(c(r-7))//D(c(r-6))//D(c(r-5))
     $//D(c(r-4))//D(c(r-3))//D(c(r-2))//D(c(r-1))//D(c(r))
      endif

    1 continue
      return
      end

