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

compilation differences between g77 and ifort (-CB -static options)

zubair_anwar
Beginner
871 Views
I am having a weird problem with my code. If I compile the code with g77 I get the correct numerical value. However, compilation with ifort returns an icorrect but reasonably close (2%) value. If I add the -CB and -static option when compiling, the correct value is reported by ifort run. I've checked my code thoroughly and there are no uninitialized arrays or array bound exceptions.

I have a simple driver fortran file (temp.f) which calls a subroutine (stress_solve.f).

g77 temp.f stress_solve.f (CORRECT OUTPUT)

ifort temp.f stress_solve.f (INCORRECT OUTPUT)

ifort -CB -static temp.f stress_solve.f (CORRECT OUTPUT!!)

Any idea what may be going wrong?
0 Kudos
2 Replies
Steven_L_Intel1
Employee
871 Views
You may have other uninitialized variables, or you could be seeing the effects of the use of extended precision registers. The best way to figure this out is to have the program write out intermediate calculations (in hex and float formats) to a log file, build the program both ways and compare the outputs.
0 Kudos
TimP
Honored Contributor III
871 Views
In your first g77 compile command line, you have optimization off.
In your first ifort line, you have optimization on (by default).
If you are using 32-bit compilers, you would be generating extended precision code, since you didn't ask for SSE. As Steve said, this could easily make a difference, where some of the optimized results are calculated more accurately. Also, as he mentioned, the compiler would make more assumptions about correctness, so un-initialized variables and the like would become a problem.
Why not turn on warnings, and equivalent optimization levels, for both compilers?
g77 -Wall -O
ifort -warn -O1
0 Kudos
Reply