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

Different result between release and debug

snowworld
初学者
1,917 次查看
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 项奖励
5 回复数
durisinm
新手
1,917 次查看
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 项奖励
rahzan
新分销商 I
1,917 次查看
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 项奖励
tom_cole
初学者
1,917 次查看
Very high probability of an uninitialized variables being the culprit. Maybe someone will eventually see the light.
0 项奖励
snowworld
初学者
1,917 次查看
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 项奖励
durisinm
新手
1,917 次查看
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 项奖励
回复