c    @(#)balbak.f	1.1
c
      subroutine balbak(nm,n,low,igh,scale,m,z)
      integer i,j,k,m,n,ii,nm,igh,low
      real scale(n),z(nm,m)
      real s
      if (m .eq. 0) go to 200
      if (igh .eq. low) go to 120
      do 110 i = low, igh
         s = scale(i)
         do 100 j = 1, m
  100    z(i,j) = z(i,j) * s
  110 continue
  120 do 140 ii = 1, n
         i = ii
         if (i .ge. low .and. i .le. igh) go to 140
         if (i .lt. low) i = low - ii
         k = scale(i)
         if (k .eq. i) go to 140
         do 130 j = 1, m
            s = z(i,j)
            z(i,j) = z(k,j)
            z(k,j) = s
  130    continue
  140 continue
  200 return
      end
