How do I force gfortran to stop program at first NaN?

-ffpe-trap=invalid

How do I force gfortran to stop at a first floating point exception?

-ffpe-trap=zero,overflow

What optimization does gfortran support?

O0, O1, O2, O3, Os, Ofast, Og.

How do I debug?

Use gdb.
edit