Sheet1
Page 1
! CE311K Introduction to Computer Methods
! Lab9 - Systems of Linear Equations
Program lab9
! Declaration of Variables
real a(50,50), b(50), x(50)
integer n, i, j
real er, tol
! Open I/O files Input file called input.txt, output file out.dat
Open(unit=5, file='input.txt',status='old')
Open(unit=6, file='out.dat', status='unknown')
! Initialization of the Matrix
!
Read(5,*) n ! Reads the number of equations to solve
! Loop to store matrix of coefficients in a, and array of constants in b
Do i=1,n
read (5,*) (a(i,j), j=1,n), b(i)
x(i)=0
Enddo
print *, 'Input Matrix: '
write (6,*) 'Input Matrix'
call printer(a, n, b, j) !Calls function that prints system of equations
!a Matrix of coefficients of nxj
!b Array of constants of nx1
! er: error code, tol: tolerable number
! +initialize er at zero
er=0
! +set tolerance error as 1E-8
tol=1e-8
call Gauss(a, b, n, x, tol, er)
! +Write solutions to a file remember solutions are in the array x
call printsol(n, j, x)
End program lab9
! Subroutine dealing with Gauss Elimination