Changing all calls to single function

  • Thread starter Thread starter yairsuari
  • Start date Start date
  • Tags Tags
    Function
AI Thread Summary
The discussion revolves around debugging an ecological model written in Fortran that encounters a division by zero error after running for two days. The user seeks to modify numerous calls to a subroutine to include a unique identifier for each call, which would help identify the source of the error when it occurs. They express a lack of experience with scripting tools like Perl or sed/awk for automating this process. A suggestion is made to modify the subroutine to print a "stack trace" upon crashing, utilizing a system routine and compiler options to include line numbers and filenames, which would provide crucial debugging information without significantly impacting runtime. This approach is recommended over manually editing hundreds of calls, as it minimizes the risk of introducing additional bugs.
yairsuari
Messages
7
Reaction score
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
 
Technology news on Phys.org
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.
 
thanks, this solves my problem
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top