gauss5.f90

I suggest you either typed  this as it appears into the compiler, or as an easier way, just copy and paste it!

Note: I do not claim the program will 100% work, but I give it my best. If it doesn't, try tweaking it yourself, or email me about it, and I'll modify and post the improved version later. Good luck!

program gaussian_elimination_proper
!use linear_equations
implicit none
!defines coefficient and solve them


!allocatable array for coefficients
real, dimension(4,4) ::a
real, dimension(4) ::b
!size of array
!integer::n
!loop variables and error flag
integer::i,j,error

!get size of prob
!print*, "how many equations are there?"
!read*, n

!the values in array is:
a(1, :) = (/1, 2, 1, 4/)
a(2, :) = (/2,0,4,2/)
a(3, :) = (/4,2,2,1/)
a(4, :) = (/-3,1,3,2/)

b(1)=(13)
b(2)=(28)
b(3)=(20)
b(4)=(6)
!allocate arrays
!allocate(a(n,n),b(n))

!get coefficients
!print*, "type coefficients for each equation in turn"
!do i=1,4
!read*, (a(i,j), j=1,4)
!print*, "again"
!read*, b(i)
!end do




!attempt to solve system of equations
!call gaussian_solve(a,b,error)



!check to see if there were any errors

!if (error<=-1 .and. error >=-3) then
!print*, "error in call to gaussian_solve"
!else if (error==-4) then
!print*, "system is degenerate"
!else
!print*, ""

!print*, "solution is"

!print'(1X, "x("i2,")=",f6.2)', (i,b(i),i=1,4)
!end if
do i=1,4
print*, a(i,1:4), b(i)
end do



end program gaussian_elimination_proper