fortran optimization errors

Tim Prince tprince@myrealbox.com
Fri Jun 22 04:21:00 GMT 2007


Sebastian Sandersius wrote:
> Dear Jerry and Steve,
>
>   The linux compiler is f90.  
None of the linux compilers I know are commonly installed as "f90," 
since Pacific-Sierra went away.  The compiler which is the subject of 
this mail list is invariably installed as gfortran, regardless of OS.
> I don't think the code is numerically
> unstable because I can run it on my mac and compile it with gfortran
> and the numerical output is the same no matter what the optimization
> tag is.
If you have a mac PPC you don't have an extra precision option such as 
you do on linux (and -mfpmath=387 is the default for 32-bit linux).  
It's important for you to quote exact target names and compiler 
switches.  Commonly used gfortran architecture switches include 
-march=pentium4 (to cover all SSE2 machines) -mfpmath=sse (to request 
SSE code rather than x87).  Not everyone would call a code numerically 
unstable simply because the results are slightly different when you run 
with extra precision.
>  This wasn't as alarming to me as the different numerical
> output from the linux compiler.  The numerical difference was about
> 0.1% which is much larger than computational noise which is on the
> order of 10^-8.  
If your results change by 0.1% on account of extra precision, few of us 
will be prepared to believe your "numerical noise" is so small.  If you 
have any single precision (even if inadvertent) you won't come close to 
making your roundoff error that small.  If you are alarmed, look for 
places where you forgot to set double precision.  implicit none would 
catch undeclared variables, but you still must look for default-typed 
constants.



More information about the Fortran mailing list