Reputation: 13
I have written s subroutine for a commercial software which is compiled by Intel Fortran so that the code has been written in Fortran. the subroutine is compiled by itself without any problem, but when I link it to the main software I get some strange results.
The most interesting and surprising event is:
When I put a write
statement in the subroutine I get different results than there is no write
statement within it and also by changing the place of this statement, the results are changed. I have never seen that the write
statement can affect the results. It would be really appreciated if someone give me an idea?
Upvotes: 0
Views: 439
Reputation: 9489
This is typical undefined behaviour, reflecting a bug somewhere else. This can be whatever, like a corrupted stack, out of bounds memory accesses, etc...
Time to compile with debug options, bound checking, etc, and to give the debugger a try.
Assuming you are on Linux, try adding "-g -O0 -check all" to your compiler command line options. This could report interesting informations at run time.
Also try to run your code with gdb and examine the call stack at crash time with bt
.
Upvotes: 3