Re: [S] flagging Fortran violations

Alan Zaslavsky (
Tue, 14 Jul 1998 08:42:54 -0400 (EDT)

> From: (Matt Wand)
> I often get bugs in my S-PLUS/Fortran programmes
> that are due to
> (1) referencing an array element that is outside
> the range of the allowable indices.
> (2) referencing an undeclared variable.

You can help to reduce the frequency of these errors by using the following
flags in your compilation (this is in the Sun fortran compiler, quotes are
from man page):

-C Check array references for out of range subscripts.

Subscripting arrays beyond their declared sizes may
result in unexpected results, including segmentation
faults. The -C option checks for possible array sub-
script violations in the source code and during execu-

-u Report undeclared variables.

Make the default type of variables undeclared rather
than using FORTRAN implicit typing.

These are not foolproof solutions, and in particular they don't keep you from
making mistakes about declaring the same variable differently in different
subroutines, but at least they give you a bit more of a chance of catching
your mistakes.

Fortran 90 has a module construct which gives you more of a consistency
check in function/subroutine calls, and therefore has even more potential
for preventing typing errors.
This message was distributed by To unsubscribe
send e-mail to with the BODY of the
message: unsubscribe s-news