next up previous
Next: Assessment Up: Implementation Previous: Implementation

Driver Program

It should be noticed that the number of equations can be less than the size of the array. A driver program for this subroutine is:

!  Sample program for solve.
!
      program solve
      implicit none
      integer, parameter :: MAXROW = 10
      double precision :: a(10,10),b(10),temp(10)
      integer :: flag,i,maxrow,neq
      
!
!     Assign values for NEQ, and entries of A.
!
      NEQ = 3
      A(1,1) =  3.D0
      A(1,2) =  6.D0
      A(1,3) =  9.D0
      A(2,1) =  2.D0
      A(2,2) =  5.D0
      A(2,3) = -2.D0
      A(3,1) =  1.D0
      A(3,2) =  3.D0
      A(3,3) = -1.D0
!
!     Define the right hand side vector B and solve the system.
!
      B(1) = 39.D0
      B(2) =  3.D0
      B(3) =  2.D0

      call solve(a,maxrow,neq,pvtidx,b)
      if( flag .eq. 0 ) then
        print *,' Solution vector for the system:'
        print *,(b(i),i = 1,neq)
      else if (flag .eq. -1) then
        print *,'There is an input error with NEQ & MAXROW'
      else
        print *,'A Zero Pivot occurred at equation ',FLAG
      end if

      stop
      end

J. C. Diaz