Are you familiar with the -Wunitialized
flag (also included with -Wall
) in gfortran
?
~/fortran$ cat maybe_uninitialized.f90
double precision :: gcc, density, ecc
gcc = 2.0d0
density = 1.0d0
ecc = 1.736d57 * fcc * gcc * density
print *, ecc
end
~/fortran$ gfortran -Wall maybe_uninitialized.f90
maybe_uninitialized.f90:4:39:
4 | ecc = 1.736d57 * fcc * gcc * density
| ^
Warning: 'fcc' is used uninitialized [-Wuninitialized]
maybe_uninitialized.f90:4:23:
4 | ecc = 1.736d57 * fcc * gcc * density
| ^
note: 'fcc' was declared here
- Are you using
-finit-local-zero
in the compilation? - Do you know for certain it runs correctly?
2.a) What kind of verification and/or validation have you performed?
Compiler-dependent. For a previous discussion see Some type of automatic initialization of variables? - #4 by rwmsu