Hi Tim Thanks much for your reply. I will try this out as soon as I get a system to work on. I am working on RedHat Linux enterprise version but a very old gcc - version 4.1.2. With Regards Vardhan -----Original Message----- From: Tim Prince [mailto:n8tm@xxxxxxx] Sent: Tuesday, December 01, 2009 8:53 AM To: Vardhan, Sundara (GE Infra, Energy) Cc: gcc-help@xxxxxxxxxxx Subject: Re: Using Optimization flag in Fortran 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.