cle...@dwf.com wrote:
> I am trying to resurrect a Fortran code that hasnt run in 10-15 years.
> The code is showing a large number of NaN's in its output.
>
Pre-remark: You did not state which gfortran version you are using; if
you have 4.0.x or 4.1.x I would strongly suggest to update - if you have
4.2.x you also should consider to update. Currently supported are 4.3.4
(oldest maintained release series, soon to be retired), 4.4.3 (next
days: 4.4.4, previous release series), 4.5.0 (current release series),
and 4.6.0 (active development, i.e. continuously changed). At least in
the SVN version, there is no known regression in 4.4.x, 4.5.x and 4.6.
> Previous Fortran compilers have had something like ieee_handler
> as a library routine, it would appear that gfortran handles this with
> compiler options. (True or False?)
>
Well, "previous Fortran compilers" is a wide term; the Fortran standard
includes IEEE only since Fortran 2003 thus you can only refer to "some
other compilers, which were used before" ;-)
Currently, GNU Fortran (gfortran) does not implement the IEEE modules of
Fortran 2003; however, as you have already mentioned, it supports
trapping via an option, viz. -ffpe-trap=<list>, cf.
http://gcc.gnu.org/onlinedocs/gfortran/Debugging-Options.html
> I have zeroed blank common, and have used the option -finit-local-zero
> which it appears should zero all local variables (what about named
> common ???).
>
I think -finit-local-zero does not touch commons or other static (SAVE)
variables, but by default they should be zero (by being placed in the
.bss segment, cf.
http://en.wikipedia.org/wiki/.bss).
> In any case I would like to get an interrupt and a traceback when
> a NaN or any other IEEE bad number is created. I dont see how
> to do this.
>
Cf. above: -ffpe-trap=invalid,zero (overflow,precision,underflow).
Regarding a backtrace: If you are on a GLIBC system such as Linux, you
can try "-g -fbacktrace" to get a backtrace; otherwise, try "-g" and run
it in a debugger (e.g. "gdb program"; "run"; "bt" [= backtrace]).
Tobias
PS: Supporting the Fortran 2003 IEEE modules is planned, but it will
likely take a while. Supporting the withdrawn POSIXFortran 77 Language
Interfaces (IEEE 1003.9-1992) or some modules similarly to NAG's f90_*
modules or Intel's IFPORT is also planned, but this will likely take a
bit longer. Cf.
http://gcc.gnu.org/wiki/GFortranStandards for the
relevant standards. For the Fortran 2003/2008 status, see also
http://gcc.gnu.org/wiki/Fortran2003Status and
http://gcc.gnu.org/wiki/Fortran2008Status