There are lots of compiler options in various compilers, and also newer options are constantly added to more recent versions. So I would appreciate it if you share the information about options that you find useful in your actual coding
In my case, I found -finit-derived
in gfortran useful, which initializes components of derived types with some specified values (e.g., NaN for reals). For example, for this code
program main
implicit none
type Foo
integer :: n
real :: x
complex :: z
character(5) :: s
endtype
type(Foo) :: f
print *, f
end
“gfortran-10 test.f90” (with no option) gives
$ ./a.out
1412855200 4.59163468E-41 (-3.031044989E-24,4.591634678E-41) ^@^@^@^@^@
$ ./a.out
1563989408 4.59163468E-41 (-3.031044989E-24,4.591634678E-41) ^@^@^@^@^@
$ ./a.out
1400161696 4.59163468E-41 (-3.031044989E-24,4.591634678E-41) ^@^@^@^@^@
while “gfortran-10 -finit-derived -finit-integer=-1 -finit-real=snan test.f90” gives
-1 NaN (NaN,NaN) ^@^@^@^@^@
which I think is useful to detect type components not assigned during execution.