Using Optimization flag in Fortran

Tim Prince n8tm@aol.com
Tue Dec 1 13:53:00 GMT 2009


Vardhan, Sundara (GE Infra, Energy) wrote:

> Recently I added the -O3 flag to compile gfortran code. The application
> uses OPEN() call to open files. These calls are made in a sequence, one
> after another to open about 4 files before any operation on any of these
> files are performed. This code works fine when compiled with no
> Optimization flags. However upon adding the Optimization flags (be it -O
> or -O3), the first OPEN() works fine and the next OPEN() call fails. I
> suspect that the optimization flag turns on some check which may be
> causing this failure. 
It looks more likely you have a bug in your program whose ill effect is 
worsened with optimization.  Perhaps you could find it by setting -O 
along with -Wall and subscript range checking.
It may also be useful to assure that you have a more stable version of 
gfortran than would be furnished by some of the "enterprise" linux distros.



More information about the Gcc-help mailing list