Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Gaussian Elimination in Fortran

  1. Nov 17, 2009 #1

    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
  2. jcsd
  3. Nov 19, 2009 #2


    User Avatar

    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.
  4. Nov 19, 2009 #3
    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

  5. Nov 19, 2009 #4


    User Avatar

    Staff: Mentor

    Hardly surprising :wink: That's not what jtbell asked about. He asked IF the program asks you to enter solution vector - you wrote

    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
  6. Nov 19, 2009 #5


    User Avatar

    Staff: Mentor

    Exactly. :biggrin:
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Gaussian Elimination in Fortran
  1. Fortran Help (Replies: 2)

  2. Infinity in fortran (Replies: 5)

  3. Linking Fortran (Replies: 5)