rounding issue when running same fortran code


i have rewritten a piece of code to f90 originally written in f77. Both version of the code are compiled with the same flags, same machine/arch and same compiler (pgf90). However, when the values are rounded by writting it to a file the two codes round differently. Any suggestions on how to get both coees to behave the same.

Some things to check.

  1. Constants - make sure you use all 32-bit real constants, or all
    64-bit real constants.
    a=12345.0E0 is a different number than

  2. Don’t use
    -r8 or -r4 to force all reals used to be always real8 or real4
    carelessly. These switches affect constants and function values.

  3. Make sure you declare any real functions as
    real8 or real4.

  4. The order of operations can be changed with optimization,
    and so you may want to use
    to force operation order to remain the same. This can eliminate
    problems with optimization that save and use more bits
    in x86 registers than ift in memory.

If it still fails to be the same, send the code to