Which g95 compiler options to use for development?

9 views
Skip to first unread message

beli...@aol.com

unread,
Mar 29, 2005, 7:17:45 AM3/29/05
to gg...@googlegroups.com
G95 compiler options are listed at http://www.g95.org/docs.html . I
wonder which compiler options people recommend during Fortran 95
program development and debugging. Here is my suggested list.

-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 .

Doug

unread,
Mar 29, 2005, 7:45:05 AM3/29/05
to gg...@googlegroups.com
The option -fbounds-check provides run-time bounds checking.
Doug

------------------------------------
$ 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

Joost

unread,
Mar 29, 2005, 7:47:13 AM3/29/05
to gg...@googlegroups.com
> Is there an option for run-time array bounds checking.

-fbounds-check

works fine on your example...

Cheers,

Joost

Reply all
Reply to author
Forward
0 new messages