- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
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?
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page