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

Fortran issue. HEEEEELP? Not a human error, somethings buggy ?

  1. Mar 29, 2009 #1
    Fortran issue. HEEEEELP!?! Not a human error, somethings buggy...?

    I have no clue why this is acting like this, I'm getting a strange error. I don't believe this is a human error, I've followed the examples perfectly.

    The picture shows it all. I ran it once trying to use a random function and again trying to use a module, both a similar error.

    http://img27.imageshack.us/img27/7163/37186177.png [Broken]

    (also, the teacher uses a windows compiler(g95.org), I use a unix one.)
     
    Last edited by a moderator: May 4, 2017
  2. jcsd
  3. Mar 29, 2009 #2
    Re: Fortran issue. HEEEEELP!?! Not a human error, somethings buggy...?

    It looks like you have compiled the two files separately, so Randy does not see TestMod and vice versa. Unless you compile and place the object of GetX in an established library, you will need to link them together, usually simply stacking one after in the same file.
    Hope that sovles your problem.
     
  4. Mar 30, 2009 #3
    Re: Fortran issue. HEEEEELP!?! Not a human error, somethings buggy...?

    Well that's the thing, I should be able to compile separately, as the Randy calls to use TestMod, which is in the same directory.

    Moreover, when I take out the module in general, Random_Number(x) seems to give a very similar error, and I knowww that should work fine.

    THANK YOU SO MUCH THUS FAR!
     
  5. Mar 30, 2009 #4

    rcgldr

    User Avatar
    Homework Helper

    Re: Fortran issue. HEEEEELP!?! Not a human error, somethings buggy...?

    I not familiar with this particular tool, but can't you set the project or batch file to simply compile two source files, then link the two created object files along with any common libraries needed?
     
  6. Mar 30, 2009 #5

    alphysicist

    User Avatar
    Homework Helper

    Re: Fortran issue. HEEEEELP!?! Not a human error, somethings buggy...?

    I believe the errors with the random_number case and the module case are from two different situations.

    As Jeff Reid said, you need to link the object files. So if you do want to compile them separately (instead of in one line), you can do something like:

    Code (Text):

    g95 testmod.f95 -c
    g95 randy.f95 -c
    g95 -o po testmod.o randy.o
     
    which creates the executable po.exe .

    The error with the random_number subroutine appears to be because you gave it an integer argument (r1), but it needs a real argument.
     
  7. Mar 30, 2009 #6
    Re: Fortran issue. HEEEEELP!?! Not a human error, somethings buggy...?

    THANK YOU!

    You're right I don't know what I was thinking, I have to link the two together.

    And the random_number issue was because I didn't call "random_seed" before it. Unrelated.

    Thanks again for all the help!
     
  8. Mar 31, 2009 #7

    alphysicist

    User Avatar
    Homework Helper

    Re: Fortran issue. HEEEEELP!?! Not a human error, somethings buggy...?

    Perhaps it's not important, but I don't think the issue with random_number was that, because you are not required to call random_seed in your program. For example, you can have:

    Code (Text):

    program test
    implicit none
    real::r1
    call random_number(r1)
    print*,r1
    end program test
     
    and it will compile and run fine (it will just give the same number every time you run the program). Inserting the line "call random_seed()" at the appropriate place will give a different number every time.

    However, if r1 is declared as integer (as in your sample program), then it will not compile with g95.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Fortran issue. HEEEEELP? Not a human error, somethings buggy ?
  1. Fortran error (Replies: 33)

  2. FORTRAN strange issue (Replies: 7)

Loading...