c
c
c***********************************************************************
c
      subroutine BACSUB ( mmax, n1, a1, z ) 
c
c-----------------------------------------------------------------------
c
c     backsolve the n1 x n1 upper triangular system
c     a1*z = b.  the solution z overwrites the right
c     side b.
c
      real a1(mmax,n1),z(n1)
c
      z(n1)=z(n1)/a1(n1,n1)
      if (n1.eq.1) go to 1350 
      np1=n1+1
      do 1340 iback=2,n1
         i=np1-iback
c           i = n-1, n-2, ..., 2, 1
         ip1=i+1
         acum=z(i)
         do 1330 j=ip1,n1
1330        acum=acum-a1(i,j)*z(j)
1340     z(i)=acum/a1(i,i)
c
1350  return
c
      end 
