207. Use compiler options to catch the use of uninitialized variables.#
topic: Compiling
Note
This tip is a draft1.
To catch the use of uninitialized variables, initialize real variables to signalling NaN and integers to -999 and trap NaNs at run time with
gfortran -g -ffpe-trap=invalid,overflow -finit-real=snan -finit-integer=-999 -fbacktrace a.f90
For ifort see
To catch the use of uninitialized variables, initialize real variables to signalling NaN and integers to -999 and trap NaNs at run time with
— FortranTip (@fortrantip) May 2, 2022
gfortran -g -ffpe-trap=invalid,overflow -finit-real=snan -finit-integer=-999 -fbacktrace a.f90
For ifort see https://t.co/gjX3gj8seB
- 1
From the perspective of FortranTip Browser, “draft” means that it hasn’t been edited for formatting, hasn’t had corresponding Fortran programs added, the text content hasn’t been enhanced, etc. Draft texts are extracted from the corresponding Tweet using the Twitter API.