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

Changing all calls to single function

  1. Oct 5, 2011 #1
    Hello

    i am runing an ecological model in fortran which calls a single subroutine from about 200 different places in a source code divided to about 50 text files. after ca. 2 days of running i have a devision by zero and the model blows up - this is a tough thing to debug. if i use debug flag on compilation this will take ages.


    what i want to do is change every call to this function that currently look like this:
    call flux_vector( a,b, c)
    to:
    call flux_vector( a,b, c,NUMBER)

    Where number contains a different number on each call

    And then inside the function change the section that stops execution to print where it was called from

    write(6,*)NUMBER
    stop

    i know this can be done using perl or sed/awk but i am not experinced enough to do that, can someone please help?


    thank for the time
    yair
    yairsuari is online now Report Post Edit/Delete Message
     
  2. jcsd
  3. Oct 5, 2011 #2

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    A better way would be to modify your subroutine so it prints a "stack trace" when it crashes. There should be a system routine you can call to do this, and a compiler option to include the line numbers and filenames from the source code in the output. Getting that information will not increase the run time, though it will increase the executable program size because of the extra information saying which lines in the source code relates to which parts of the compiled code.

    Look in your compiler documentation for how to do that. If you edit hundreds of subroutine calls by hand, even with a script, you could easily add more bugs to your program if you miss a few of the subroutine calls.
     
  4. Oct 6, 2011 #3
    thanks, this solves my problem
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Changing all calls to single function
Loading...