# Gaussian Elimination in Fortran

1. Nov 17, 2009

### 50Cent

Hi,

I am trying to recreate the naive gauss elimination method in fotran 95 but am having a few problems with it. The idea is to read in a nxn matrix of equations, so you can type in any number when u start the program and then the program will ask you to enter the relavant amount of coefficients.

This is my program so far:
I know the last print command is incorrect because its only specific for 3 unknowns. I didnt know how to write it to print N unknowns.

At the moment the program compiles and runs, asks for the the coefficients but then stops there. Can anyone see the problem?

Any help is much appreciated
Thanks

2. Nov 19, 2009

### Staff: Mentor

Does it ask for the solution vector?

If it does, then I would add some extra PRINT statements so as to see exactly how far the program is going. For example, first add one immediately before the back-substitution section. If you don't see that output, then add a PRINT statement inside the loops of the decomposition section, that displays the values of I, J and K. Otherwise add a similar PRINT statment inside the loops of the back-substitution section. Etc.

The general idea is to make the program itself tell you what it is actually doing, instead of trying to puzzle it out simply by reading the code.

3. Nov 19, 2009

### 50Cent

Hi, Thanks for the reply. Yes i do need to find the solution vector X(IN).

I think the problem is actually the last print statement that i have. The one i have used is for a set 3x3 matrix. Do you know how to code it so that it will print "N" solutions?

i tried this:
but get the error:
In the meanwhile i will add the extra print statements to check how far the program is going

Thanks

4. Nov 19, 2009

### Staff: Mentor

So we don't know if problems started BEFORE elimination loop, or if the program was able to get INTO elimination loop.

Last edited: Nov 19, 2009
5. Nov 19, 2009

Exactly.