-Wimplicit-none
-Wline-truncation
-Wunused-vars
-Wunset-vars
-Wunused-module-vars
-Wprecision-loss
-std=f95
Is there an option for run-time array bounds checking. For the program
real a(1)
a(2) = 1.0
print*,a(2)
end
g95 warns about about an out-of-bound array element at compile time but
says nothing at run-time, giving output 1.0 .
------------------------------------
$ cat bc.f90
real a(1)
a(2) = 1.0
print*,a(2)
end
$ g95 -fbounds-check bc.f90
In file bc.f90:2
a(2) = 1.0
1
Warning (108): Array reference at (1) is out of bounds
In file bc.f90:3
print*,a(2)
1
Warning (108): Array reference at (1) is out of bounds
$ ./a
At line 2 of file bc.f90
Fortran runtime error: Array element out of bounds
-fbounds-check
works fine on your example...
Cheers,
Joost