Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29041 Discussions

Different result between release and debug

snowworld
Beginner
1,382 Views
We have a fairly big C/Fortran program and we use the 6.6A version of CVF. I have a problem with a call in a if statement. If the function returns < 0 I should go into the if statement but I don't in the release version even if I know that the function should have returned -1. If I first put the result in a local variable, the if statement works. Any ideas what the problem can be?
0 Kudos
5 Replies
durisinm
Novice
1,382 Views
These kinds of errors often result from the use of uninitialized variables. Try turning off the optimizations for the release configuration to see if the results change.

You say you "know" that the function should've returned -1. Have you verified that by using the debugger?

Mike
0 Kudos
rahzan
New Contributor I
1,382 Views
One other possibility (though it appears in our case slim). You should never do critical branches on floating pt variables. Because of complicated precision handling rules, things can be VERY different depending on some entirely irrelevant operations such as writing to disk, etc. These rules can be controlled by compiler switches but they are by default VERY different between debug and release setting.

TimH
0 Kudos
tom_cole
Beginner
1,382 Views
Very high probability of an uninitialized variables being the culprit. Maybe someone will eventually see the light.
0 Kudos
snowworld
Beginner
1,382 Views
I have made some printouts and they give -1. I have searched for uninitialized variables and haven't found any. The 2 functions I use are quite small so it shouldn't be hard to find uninitialized variables.
0 Kudos
durisinm
Novice
1,382 Views
Try building a debug configuration of your application. Set breakpoints at the start of your Fortran function and at the point where it returns a value to the calling routine. Start the application and step through the function to verify that it's returning -1 and that the calling routine is receiving -1. Continue stepping through the calling routine after the function returns to see if the logic sends it through the proper branch of your IF statement.

Mike
0 Kudos
Reply