Changing all calls to single function

  • Thread starter yairsuari
  • Start date
  • #1
8
0
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
 

Answers and Replies

  • #2
AlephZero
Science Advisor
Homework Helper
6,994
291
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.
 
  • #3
8
0
thanks, this solves my problem
 

Related Threads on Changing all calls to single function

  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
0
Views
1K
  • Last Post
Replies
0
Views
1K
  • Last Post
Replies
7
Views
3K
  • Last Post
Replies
2
Views
2K
Replies
4
Views
37K
Replies
4
Views
9K
  • Last Post
Replies
10
Views
2K
Replies
5
Views
817
Replies
2
Views
5K
Top