Go to the first, previous, next, last section, table of contents.
The g77
command supports all the options supported by the
gcc
command.
See section `GNU CC Command Options' in Using and Porting GNU CC,
for information
on the non-Fortran-specific aspects of the gcc
command (and,
therefore, the g77
command).
All gcc
and g77
options
are accepted both by g77
and by gcc
(as well as any other drivers built at the same time,
such as g++
),
since adding g77
to the gcc
distribution
enables acceptance of g77
-specific options
by all of the relevant drivers.
In some cases, options have positive and negative forms; the negative form of `-ffoo' would be `-fno-foo'. This manual documents only one of these two forms, whichever one is not the default.
g77
options,
without explanations.
Here is a summary of all the options specific to GNU Fortran, grouped by type. Explanations are in the following sections.
-fversion -fset-g77-defaults -fno-silent
-ff66 -fno-f66 -ff77 -fno-f77 -fno-ugly
-ffree-form -fno-fixed-form -ff90 -fvxt -fdollar-ok -fno-backslash -fno-ugly-args -fno-ugly-assign -fno-ugly-assumed -fugly-comma -fugly-complex -fugly-init -fugly-logint -fonetrip -ftypeless-boz -fintrin-case-initcap -fintrin-case-upper -fintrin-case-lower -fintrin-case-any -fmatch-case-initcap -fmatch-case-upper -fmatch-case-lower -fmatch-case-any -fsource-case-upper -fsource-case-lower -fsource-case-preserve -fsymbol-case-initcap -fsymbol-case-upper -fsymbol-case-lower -fsymbol-case-any -fcase-strict-upper -fcase-strict-lower -fcase-initcap -fcase-upper -fcase-lower -fcase-preserve -ff2c-intrinsics-delete -ff2c-intrinsics-hide -ff2c-intrinsics-disable -ff2c-intrinsics-enable -fbadu77-intrinsics-delete -fbadu77-intrinsics-hide -fbadu77-intrinsics-disable -fbadu77-intrinsics-enable -ff90-intrinsics-delete -ff90-intrinsics-hide -ff90-intrinsics-disable -ff90-intrinsics-enable -fgnu-intrinsics-delete -fgnu-intrinsics-hide -fgnu-intrinsics-disable -fgnu-intrinsics-enable -fmil-intrinsics-delete -fmil-intrinsics-hide -fmil-intrinsics-disable -fmil-intrinsics-enable -funix-intrinsics-delete -funix-intrinsics-hide -funix-intrinsics-disable -funix-intrinsics-enable -fvxt-intrinsics-delete -fvxt-intrinsics-hide -fvxt-intrinsics-disable -fvxt-intrinsics-enable -ffixed-line-length-n -ffixed-line-length-none
-fsyntax-only -pedantic -pedantic-errors -fpedantic -w -Wno-globals -Wimplicit -Wunused -Wuninitialized -Wall -Wsurprising -Werror -W
-g
-malign-double -ffloat-store -fforce-mem -fforce-addr -fno-inline -ffast-math -fstrength-reduce -frerun-cse-after-loop -fexpensive-optimizations -fdelayed-branch -fschedule-insns -fschedule-insn2 -fcaller-saves -funroll-loops -funroll-all-loops -fno-move-all-movables -fno-reduce-all-givs -fno-rerun-loop-opt
-Idir -I-
-fno-automatic -finit-local-zero -fno-f2c -ff2c-library -fno-underscoring -fno-ident -fpcc-struct-return -freg-struct-return -fshort-double -fno-common -fpack-struct -fzeros -fno-second-underscore -fdebug-kludge -femulate-complex -falias-check -fargument-alias -fargument-noalias -fno-argument-noalias-global -fno-globals -fflatten-arrays -fbounds-check -ffortran-bounds-check
Compilation can involve as many as four stages: preprocessing, code generation (often what is really meant by the term "compilation"), assembly, and linking, always in that order. The first three stages apply to an individual source file, and end by producing an object file; linking combines all the object files (those newly compiled, and those specified as input) into an executable file.
For any given input file, the file name suffix determines what kind of program is contained in the file--that is, the language in which the program is written is generally indicated by the suffix. Suffixes specific to GNU Fortran are listed below. See section Options Controlling the Kind of Output, for information on suffixes recognized by GNU CC.
file.f
file.for
file.FOR
#include
, #define
, #if
, and so on.
You can force `.f' files to be preprocessed by cpp
by using
`-x f77-cpp-input'.
See section LEX
.
file.F
file.fpp
file.FPP
cpp
, which is part of GNU CC).
Note that preprocessing is not extended to the contents of
files included by the INCLUDE
directive--the #include
preprocessor directive must be used instead.
file.r
ratfor
command, which is available separately (as it is not yet part of the GNU
Fortran distribution).
One version in Fortran, adapted for use with g77
, is at
ftp://members.aol.com/n8tm/rat7.uue (of uncertain copyright
status). Another, public domain version in C is at
http://sepwww.stanford.edu/sep/prof/ratfor.shar.2.
UNIX users typically use the `file.f' and `file.F' nomenclature. Users of other operating systems, especially those that cannot distinguish upper-case letters from lower-case letters in their file names, typically use the `file.for' and `file.fpp' nomenclature.
Use of the preprocessor cpp
allows use of C-like
constructs such as #define
and #include
, but can
lead to unexpected, even mistaken, results due to Fortran's source file
format.
It is recommended that use of the C preprocessor
be limited to #include
and, in
conjunction with #define
, only #if
and related directives,
thus avoiding in-line macro expansion entirely.
This recommendation applies especially
when using the traditional fixed source form.
With free source form,
fewer unexpected transformations are likely to happen, but use of
constructs such as Hollerith and character constants can nevertheless
present problems, especially when these are continued across multiple
source lines.
These problems result, primarily, from differences between the way
such constants are interpreted by the C preprocessor and by a Fortran
compiler.
Another example of a problem that results from using the C preprocessor is that a Fortran comment line that happens to contain any characters "interesting" to the C preprocessor, such as a backslash at the end of the line, is not recognized by the preprocessor as a comment line, so instead of being passed through "raw", the line is edited according to the rules for the preprocessor. For example, the backslash at the end of the line is removed, along with the subsequent newline, resulting in the next line being effectively commented out--unfortunate if that line is a non-comment line of important code!
Note: The `-traditional' and `-undef' flags are supplied
to cpp
by default, to help avoid unpleasant surprises.
See section `Options Controlling the Preprocessor' in Using and Porting GNU CC.
This means that ANSI C preprocessor features (such as the `#'
operator) aren't available, and only variables in the C reserved
namespace (generally, names with a leading underscore) are liable to
substitution by C predefines.
Thus, if you want to do system-specific
tests, use, for example, `#ifdef __linux__' rather than `#ifdef linux'.
Use the `-v' option to see exactly how the preprocessor is invoked.
Unfortunately, the `-traditional' flag will not avoid an error from
anything that cpp
sees as an unterminated C comment, such as:
C Some Fortran compilers accept /* as starting C an inline comment.
See section Trailing Comment.
The following options that affect overall processing are recognized
by the g77
and gcc
commands in a GNU Fortran installation:
-fversion
g77
-specific version of the compiler phase is reported,
if run,
and, starting in egcs
version 1.1,
that internal consistency checks in the `f771' program are run.
This option is supplied automatically when `-v' or `--verbose'
is specified as a command-line option for g77
or gcc
and when the resulting commands compile Fortran source files.
-fset-g77-defaults
egcs
version 1.1.
The effect is instead achieved
by the lang_init_options
routine
in `gcc/gcc/f/com.c'.
Set up whatever gcc
options are to apply to Fortran
compilations, and avoid running internal consistency checks
that might take some time.
This option is supplied automatically when compiling Fortran code
via the g77
or gcc
command.
The description of this option is provided so that users seeing
it in the output of, say, `g77 -v' understand why it is
there.
Also, developers who run f771
directly might want to specify it
by hand to get the same defaults as they would running f771
via g77
or gcc
.
However, such developers should, after linking a new f771
executable, invoke it without this option once,
e.g. via ./f771 -quiet < /dev/null,
to ensure that they have not introduced any
internal inconsistencies (such as in the table of
intrinsics) before proceeding---g77
will crash
with a diagnostic if it detects an inconsistency.
-fno-silent
stderr
) the names of the program units as
they are compiled, in a form similar to that used by popular
UNIX f77
implementations and f2c
.
See section `Options Controlling the Kind of Output' in Using and Porting GNU CC, for information
on more options that control the overall operation of the gcc
command
(and, by extension, the g77
command).
The following options serve as "shorthand" for other options accepted by the compiler:
-fugly
-fugly-args -fugly-assign -fugly-assumed -fugly-comma -fugly-complex -fugly-init -fugly-logintThese constructs are considered inappropriate to use in new or well-maintained portable Fortran code, but widely used in old code. See section Distensions, for more information.
-fno-ugly
-fno-ugly-args -fno-ugly-assign -fno-ugly-assumed -fno-ugly-comma -fno-ugly-complex -fno-ugly-init -fno-ugly-logintSee section Distensions, for more information.
-ff66
g77
provide more compatibility with other
existing and obsolete Fortran implementations.
-ff77
f2c
product.
Same as `-fbackslash -fno-typeless-boz'.
The meaning of this option is likely to be refined as future
versions of g77
provide more compatibility with other
existing and obsolete Fortran implementations.
-fno-f77
f2c
, but in a more widely portable dialect.
`-fno-f77' is the same as `-fno-backslash'.
The meaning of this option is likely to be refined as future
versions of g77
provide more compatibility with other
existing and obsolete Fortran implementations.
The following options control the dialect of Fortran that the compiler accepts:
-ffree-form
-fno-fixed-form
-ff90
-fvxt
-fdollar-ok
-fno-backslash
g77
implements a fairly general form of backslash
processing that is incompatible with the narrower forms supported
by some other compilers.
For example, `'A\003B'' is a three-character string in g77
,
whereas other compilers that support backslash might not support
the three-octal-digit form, and thus treat that string as longer
than three characters.
See section Backslash in Constants, for
information on why `-fbackslash' is the default
instead of `-fno-backslash'.
-fno-ugly-args
-fugly-assign
-fugly-assumed
-fugly-comma
-fugly-complex
COMPLEX
type other than COMPLEX(KIND=1)
---usually
this is used to permit COMPLEX(KIND=2)
(DOUBLE COMPLEX
) operands.
The `-ff90' option controls the interpretation
of this construct.
See section Ugly Complex Part Extraction, for more information.
-fno-ugly-init
PARAMETER
and DATA
statements), and
use of character constants to
initialize numeric types and vice versa.
For example, `DATA I/'F'/, CHRVAR/65/, J/4HABCD/' is disallowed by
`-fno-ugly-init'.
See section Ugly Conversion of Initializers, for more information.
-fugly-logint
INTEGER
and LOGICAL
variables and
expressions as potential stand-ins for each other.
For example, automatic conversion between INTEGER
and
LOGICAL
is enabled, for many contexts, via this option.
See section Ugly Integer Conversions, for more information.
-fonetrip
DO
loops are to be executed at
least once each time they are reached.
ANSI FORTRAN 77 and more recent versions of the Fortran standard
specify that the body of an iterative DO
loop is not executed
if the number of iterations calculated from the parameters of the
loop is less than 1.
(For example, `DO 10 I = 1, 0'.)
Such a loop is called a zero-trip loop.
Prior to ANSI FORTRAN 77, many compilers implemented DO
loops
such that the body of a loop would be executed at least once, even
if the iteration count was zero.
Fortran code written assuming this behavior is said to require
one-trip loops.
For example, some code written to the FORTRAN 66 standard
expects this behavior from its DO
loops, although that
standard did not specify this behavior.
The `-fonetrip' option specifies that the source file(s) being
compiled require one-trip loops.
This option affects only those loops specified by the (iterative) DO
statement and by implied-DO
lists in I/O statements.
Loops specified by implied-DO
lists in DATA
and
specification (non-executable) statements are not affected.
-ftypeless-boz
INTEGER(KIND=1)
.
You can test for yourself whether a particular compiler treats
the prefix form as INTEGER(KIND=1)
or typeless by running the
following program:
EQUIVALENCE (I, R) R = Z'ABCD1234' J = Z'ABCD1234' IF (J .EQ. I) PRINT *, 'Prefix form is TYPELESS' IF (J .NE. I) PRINT *, 'Prefix form is INTEGER' ENDReports indicate that many compilers process this form as
INTEGER(KIND=1)
, though a few as typeless, and at least one
based on a command-line option specifying some kind of
compatibility.
-fintrin-case-initcap
-fintrin-case-upper
-fintrin-case-lower
-fintrin-case-any
-fmatch-case-initcap
-fmatch-case-upper
-fmatch-case-lower
-fmatch-case-any
-fsource-case-upper
-fsource-case-lower
-fsource-case-preserve
-fsymbol-case-initcap
-fsymbol-case-upper
-fsymbol-case-lower
-fsymbol-case-any
-fcase-strict-upper
-fcase-strict-lower
-fcase-initcap
-fcase-upper
-fcase-lower
-fcase-preserve
-fbadu77-intrinsics-delete
-fbadu77-intrinsics-hide
-fbadu77-intrinsics-disable
-fbadu77-intrinsics-enable
-ff2c-intrinsics-delete
-ff2c-intrinsics-hide
-ff2c-intrinsics-disable
-ff2c-intrinsics-enable
-ff90-intrinsics-delete
-ff90-intrinsics-hide
-ff90-intrinsics-disable
-ff90-intrinsics-enable
-fgnu-intrinsics-delete
-fgnu-intrinsics-hide
-fgnu-intrinsics-disable
-fgnu-intrinsics-enable
-fmil-intrinsics-delete
-fmil-intrinsics-hide
-fmil-intrinsics-disable
-fmil-intrinsics-enable
-funix-intrinsics-delete
-funix-intrinsics-hide
-funix-intrinsics-disable
-funix-intrinsics-enable
-fvxt-intrinsics-delete
-fvxt-intrinsics-hide
-fvxt-intrinsics-disable
-fvxt-intrinsics-enable
-ffixed-line-length-n
Warnings are diagnostic messages that report constructions which are not inherently erroneous but which are risky or suggest there might have been an error.
You can request many specific warnings with options beginning `-W', for example `-Wimplicit' to request warnings on implicit declarations. Each of these specific warning options also has a negative form beginning `-Wno-' to turn off warnings; for example, `-Wno-implicit'. This manual lists only one of the two forms, whichever is not the default.
These options control the amount and kinds of warnings produced by GNU Fortran:
-fsyntax-only
-pedantic
g77
in this area are welcome.
-pedantic-errors
-fpedantic
-w
-Wno-globals
-Wimplicit
IMPLICIT NONE
statement
in every program unit.
(Some Fortran compilers provide this feature by an option
named `-u' or `/WARNINGS=DECLARATIONS'.)
-Wunused
-Wuninitialized
SUBROUTINE DISPAT(J) IF (J.EQ.1) I=1 IF (J.EQ.2) I=4 IF (J.EQ.3) I=5 CALL FOO(I) ENDIf the value of
J
is always 1, 2 or 3, then I
is
always initialized, but GNU Fortran doesn't know this. Here is
another common case:
SUBROUTINE MAYBE(FLAG) LOGICAL FLAG IF (FLAG) VALUE = 9.4 ... IF (FLAG) PRINT *, VALUE ENDThis has no bug because
VALUE
is used only if it is set.
-Wall
g77
, some might
be added to the list enabled by `-Wall'.)
The remaining `-W...' options are not implied by `-Wall' because they warn about constructions that we consider reasonable to use, on occasion, in clean programs.
-Wsurprising
g77
, along with many other compilers, interprets
this example differently than many programmers, and a few
other compilers.
Specifically, g77
interprets `X**-Y*Z' as
`(X**(-Y))*Z', while others might think it should
be interpreted as `X**(-(Y*Z))'.
A revealing example is the constant expression `2**-2*1.',
which g77
evaluates to .25, while others might evaluate
it to 0., the difference resulting from the way precedence affects
type promotion.
(The `-fpedantic' option also warns about expressions
having two arithmetic operators in a row.)
INTEGER(KIND=1)
variable can hold.
So, the expression evaluates to a positive number, while
the "expected" interpretation, `(-I)*S', would
evaluate to a negative number.
Even cases such as `-I*J' produce warnings,
even though, in most configurations and situations,
there is no computational difference between the
results of the two interpretations--the purpose
of this warning is to warn about differing interpretations
and encourage a better style of coding, not to identify
only those places where bugs might exist in the user's
code.
DO
loops with DO
variables that are not
of integral type--that is, using REAL
variables as loop control variables.
Although such loops can be written to work in the
"obvious" way, the way g77
is required by the
Fortran standard to interpret such code is likely to
be quite different from the way many programmers expect.
(This is true of all DO
loops, but the differences
are pronounced for non-integral loop control variables.)
See section Loops, for more information.
-Werror
-W
g77
.)
"Extra warnings" are issued for:
See section `Options to Request or Suppress Warnings' in Using and Porting GNU CC, for information on more options offered
by the GBE shared by g77
, gcc
, and other GNU compilers.
Some of these have no effect when compiling programs written in Fortran:
-Wcomment
-Wformat
-Wparentheses
-Wswitch
-Wtraditional
-Wshadow
-Wid-clash-len
-Wlarger-than-len
-Wconversion
-Waggregate-return
-Wredundant-decls
GNU Fortran has various special options that are used for debugging
either your program or g77
.
-g
g77
.
In particular, names of variables and arrays in common blocks
or that are storage-associated via EQUIVALENCE
were
unavailable to the debugger.
However, version 0.5.19 of g77
does provide this information
in a rudimentary way, as controlled by the
`-fdebug-kludge' option.
Because version 0.5.26 of g77
enables full debug information
of COMMON BLOCK and EQUIVALENCE items, this option has been disabled.
See section Options for Code Generation Conventions,
for more information.
See section `Options for Debugging Your Program or GNU CC' in Using and Porting GNU CC, for more information on debugging options.
Most Fortran users will want to use no optimization when developing and testing programs, and use `-O' or `-O2' when compiling programs for late-cycle testing and for production use. However, note that certain diagnostics--such as for uninitialized variables--depend on the flow analysis done by `-O', i.e. you must use `-O' or `-O2' to get such diagnostics.
The following flags have particular applicability when compiling Fortran programs:
-malign-double
g77
programs making
heavy use of REAL(KIND=2)
(DOUBLE PRECISION
) data
on some systems.
In particular, systems using Pentium, Pentium Pro, 586, and
686 implementations
of the i386 architecture execute programs faster when
REAL(KIND=2)
(DOUBLE PRECISION
) data are
aligned on 64-bit boundaries
in memory.
This option can, at least, make benchmark results more consistent
across various system configurations, versions of the program,
and data sets.
Note: The warning in the gcc
documentation about
this option does not apply, generally speaking, to Fortran
code compiled by g77
.
See section Aligned Data, for more information on alignment issues.
Also also note: The negative form of `-malign-double'
is `-mno-align-double', not `-benign-double'.
-ffloat-store
a = b + c d = a * ebut not in code like:
d = (b + c) * eFor another, potentially better, way of controlling the precision, see section Floating-point precision.
-fforce-mem
-fforce-addr
-fno-inline
-ffast-math
-fstrength-reduce
-frerun-cse-after-loop
-fexpensive-optimizations
-fdelayed-branch
-fschedule-insns
-fschedule-insns2
-fcaller-saves
-funroll-loops
DO
loops by
unrolling them and is probably generally appropriate for Fortran, though
it is not turned on at any optimization level.
Note that outer loop unrolling isn't done specifically; decisions about
whether to unroll a loop are made on the basis of its instruction count.
Also, no `loop discovery'(1) is done, so only loops written with DO
benefit from loop optimizations, including--but not limited
to--unrolling. Loops written with IF
and GOTO
are not
currently recognized as such. This option unrolls only iterative
DO
loops, not DO WHILE
loops.
-funroll-all-loops
DO WHILE
loops by
unrolling them in addition to iterative DO
loops. In the absence
of DO WHILE
, this option is equivalent to `-funroll-loops'
but possibly slower.
-fno-move-all-movables
-fno-reduce-all-givs
-fno-rerun-loop-opt
g77
based on gcc
version 2.8.
Each of these might improve performance on some code.
Analysis of Fortran code optimization and the resulting
optimizations triggered by the above options were
contributed by Toon Moene (toon@moene.indiv.nluug.nl).
These three options are intended to be removed someday, once
they have helped determine the efficacy of various
approaches to improving the performance of Fortran code.
Please let us know how use of these options affects
the performance of your production code.
We're particularly interested in code that runs faster
when these options are disabled, and in
non-Fortran code that benefits when they are
enabled via the above gcc
command-line options.
See section `Options That Control Optimization' in Using and Porting GNU CC, for more information on options to optimize the generated machine code.
These options control the C preprocessor, which is run on each C source file before actual compilation.
See section `Options Controlling the Preprocessor' in Using and Porting GNU CC, for information on C preprocessor options.
Some of these options also affect how g77
processes the
INCLUDE
directive.
Since this directive is processed even when preprocessing
is not requested, it is not described in this section.
See section Options for Directory Search, for
information on how g77
processes the INCLUDE
directive.
However, the INCLUDE
directive does not apply
preprocessing to the contents of the included file itself.
Therefore, any file that contains preprocessor directives
(such as #include
, #define
, and #if
)
must be included via the #include
directive, not
via the INCLUDE
directive.
Therefore, any file containing preprocessor directives,
if included, is necessarily included by a file that itself
contains preprocessor directives.
These options affect how the cpp
preprocessor searches
for files specified via the #include
directive.
Therefore, when compiling Fortran programs, they are meaningful
when the preprocessor is used.
Some of these options also affect how g77
searches
for files specified via the INCLUDE
directive,
although files included by that directive are not,
themselves, preprocessed.
These options are:
-I-
-Idir
INCLUDE
directive
(as well as of the #include
directive of the cpp
preprocessor).
Note that `-Idir' must be specified without any
spaces between `-I' and the directory name--that is,
`-Ifoo/bar' is valid, but `-I foo/bar'
is rejected by the g77
compiler (though the preprocessor supports
the latter form).
Also note that the general behavior of `-I' and
INCLUDE
is pretty much the same as of `-I' with
#include
in the cpp
preprocessor, with regard to
looking for `header.gcc' files and other such things.
See section `Options for Directory Search' in Using and Porting GNU CC, for information on the `-I' option.
These machine-independent options control the interface conventions used in code generation.
Most of them have both positive and negative forms; the negative form of `-ffoo' would be `-fno-foo'. In the table below, only one of the forms is listed--the one which is not the default. You can figure out the other form by either removing `no-' or adding it.
-fno-automatic
SAVE
statement was specified
for every local variable and array referenced in it.
Does not affect common blocks.
(Some Fortran compilers provide this option under
the name `-static'.)
-finit-local-zero
SAVE
attribute, it might be a
good idea to also use `-fno-automatic' with `-finit-local-zero'.
-fno-f2c
f2c
; use the GNU calling conventions instead.
The f2c
calling conventions require functions that return
type REAL(KIND=1)
to actually return the C type double
,
and functions that return type COMPLEX
to return the
values via an extra argument in the calling sequence that points
to where to store the return value.
Under the GNU calling conventions, such functions simply return
their results as they would in GNU C---REAL(KIND=1)
functions
return the C type float
, and COMPLEX
functions
return the GNU C type complex
(or its struct
equivalent).
This does not affect the generation of code that interfaces with the
libg2c
library.
However, because the libg2c
library uses f2c
calling conventions, g77
rejects attempts to pass
intrinsics implemented by routines in this library as actual
arguments when `-fno-f2c' is used, to avoid bugs when
they are actually called by code expecting the GNU calling
conventions to work.
For example, `INTRINSIC ABS;CALL FOO(ABS)' is
rejected when `-fno-f2c' is in force.
(Future versions of the g77
run-time library might
offer routines that provide GNU-callable versions of the
routines that implement the f2c
-callable intrinsics
that may be passed as actual arguments, so that
valid programs need not be rejected when `-fno-f2c'
is used.)
Caution: If `-fno-f2c' is used when compiling any
source file used in a program, it must be used when compiling
all Fortran source files used in that program.
-ff2c-library
libg2c
(or the original libf2c
)
is required.
This is the default for the current version of g77
.
Currently it is not
valid to specify `-fno-f2c-library'.
This option is provided so users can specify it in shell
scripts that build programs and libraries that require the
libf2c
library, even when being compiled by future
versions of g77
that might otherwise default to
generating code for an incompatible library.
-fno-underscoring
g77
appends two underscores
to names with underscores and one underscore to external names with
no underscores. (g77
also appends two underscores to internal
names with underscores to avoid naming collisions with external names.
The `-fno-second-underscore' option disables appending of the
second underscore in all cases.)
This is done to ensure compatibility with code produced by many
UNIX Fortran compilers, including f2c
, which perform the
same transformations.
Use of `-fno-underscoring' is not recommended unless you are
experimenting with issues such as integration of (GNU) Fortran into
existing system environments (vis-a-vis existing libraries, tools, and
so on).
For example, with `-funderscoring', and assuming other defaults like
`-fcase-lower' and that `j()' and `max_count()' are
external functions while `my_var' and `lvar' are local variables,
a statement like
I = J() + MAX_COUNT (MY_VAR, LVAR)is implemented as something akin to:
i = j_() + max_count__(&my_var__, &lvar);With `-fno-underscoring', the same statement is implemented as:
i = j() + max_count(&my_var, &lvar);Use of `-fno-underscoring' allows direct specification of user-defined names while debugging and when interfacing
g77
-compiled
code with other languages.
Note that just because the names match does not mean that the
interface implemented by g77
for an external name matches the
interface implemented by some other language for that same name.
That is, getting code produced by g77
to link to code produced
by some other compiler using this or any other method can be only a
small part of the overall solution--getting the code generated by
both compilers to agree on issues other than naming can require
significant effort, and, unlike naming disagreements, linkers normally
cannot detect disagreements in these other areas.
Also, note that with `-fno-underscoring', the lack of appended
underscores introduces the very real possibility that a user-defined
external name will conflict with a name in a system library, which
could make finding unresolved-reference bugs quite difficult in some
cases--they might occur at program run time, and show up only as
buggy behavior at run time.
In future versions of g77
, we hope to improve naming and linking
issues so that debugging always involves using the names as they appear
in the source, even if the names as seen by the linker are mangled to
prevent accidental linking between procedures with incompatible
interfaces.
-fno-second-underscore
-fno-ident
-fzeros
g77
normally treats DATA
and
other statements that are used to specify initial values of zero
for variables and arrays as if no values were actually specified,
in the sense that no diagnostics regarding multiple initializations
are produced.
This is done to speed up compiling of programs that initialize
large arrays to zeros.
Use `-fzeros' to revert to the simpler, slower behavior
that can catch multiple initializations by keeping track of
all initializations, zero or otherwise.
Caution: Future versions of g77
might disregard this option
(and its negative form, the default) or interpret it somewhat
differently.
The interpretation changes will affect only non-standard
programs; standard-conforming programs should not be affected.
-fdebug-kludge
COMMON
and EQUIVALENCE
members
that might help users of debuggers work around lack of proper debugging
information on such members.
As of version 0.5.19, g77
offers this option to emit
information on members of aggregate areas to help users while debugging.
This information consists of establishing the type and contents of each
such member so that, when a debugger is asked to print the contents,
the printed information provides rudimentary debugging information.
This information identifies the name of the aggregate area (either the
COMMON
block name, or the g77
-assigned name for the
EQUIVALENCE
name) and the offset, in bytes, of the member from
the beginning of the area.
Using gdb
, this information is not coherently displayed in the Fortran
language mode, so temporarily switching to the C language mode to display the
information is suggested.
Use `set language c' and `set language fortran' to accomplish this.
As of version 0.5.26 of g77
this option has been disabled, as the
compiler is now able to emit correct and complete debug information
for COMMON BLOCK and EQUIVALENCE items.
For example:
COMMON /X/A,B EQUIVALENCE (C,D) CHARACTER XX*50 EQUIVALENCE (I,XX(20:20)) END GDB is free software and you are welcome to distribute copies of it under certain conditions; type "show copying" to see the conditions. There is absolutely no warranty for GDB; type "show warranty" for details. GDB 4.16 (lm-gnits-dwim), Copyright 1996 Free Software Foundation, Inc... (gdb) b MAIN__ Breakpoint 1 at 0t1200000201120112: file cd.f, line 5. (gdb) r Starting program: /home/user/a.out Breakpoint 1, MAIN__ () at cd.f:5 Current language: auto; currently fortran (gdb) set language c Warning: the current language does not match this frame. (gdb) p a $2 = "At (COMMON) `x_' plus 0 bytes" (gdb) p b $3 = "At (COMMON) `x_' plus 4 bytes" (gdb) p c $4 = "At (EQUIVALENCE) `__g77_equiv_c' plus 0 bytes" (gdb) p d $5 = "At (EQUIVALENCE) `__g77_equiv_c' plus 0 bytes" (gdb) p i $6 = "At (EQUIVALENCE) `__g77_equiv_xx' plus 20 bytes" (gdb) p xx $7 = "At (EQUIVALENCE) `__g77_equiv_xx' plus 1 bytes" (gdb) set language fortran (gdb)Use `-fdebug-kludge' to generate this information, which might make some programs noticeably larger. Caution: Future versions of
g77
might disregard this option
(and its negative form).
Current plans call for this to happen when published versions of g77
and gdb
exist that provide proper access to debugging information on
COMMON
and EQUIVALENCE
members. This is believed to have
happened as of version 0.5.26 of g77
, so that this option has been
disabled starting with this release.
-femulate-complex
COMPLEX
arithmetic via emulation,
instead of using the facilities of
the gcc
back end that provide direct support of
complex
arithmetic.
(gcc
had some bugs in its back-end support
for complex
arithmetic, due primarily to the support not being
completed as of version 2.8.1 and egcs
1.1.2.)
Use `-femulate-complex' if you suspect code-generation bugs,
or experience compiler crashes,
that might result from g77
using the COMPLEX
support
in the gcc
back end.
If using that option fixes the bugs or crashes you are seeing,
that indicates a likely g77
bugs
(though, all compiler crashes are considered bugs),
so, please report it.
(Note that the known bugs, now believed fixed, produced compiler crashes
rather than causing the generation of incorrect code.)
Use of this option should not affect how Fortran code compiled
by g77
works in terms of its interfaces to other code,
e.g. that compiled by f2c
.
Caution: Future versions of g77
might ignore both forms
of this option.
-falias-check
-fargument-alias
-fargument-noalias
-fno-argument-noalias-global
g77
based on gcc
version 2.8.
These options specify to what degree aliasing
(overlap)
is permitted between
arguments (passed as pointers) and COMMON
(external, or
public) storage.
The default for Fortran code, as mandated by the FORTRAN 77 and
Fortran 90 standards, is `-fargument-noalias-global'.
The default for code written in the C language family is
`-fargument-alias'.
Note that, on some systems, compiling with `-fforce-addr' in
effect can produce more optimal code when the default aliasing
options are in effect (and when optimization is enabled).
See section Aliasing Assumed To Work, for detailed information on the implications
of compiling Fortran code that depends on the ability to alias dummy
arguments.
-fno-globals
g77
diagnoses.
Use of this option therefore has the effect of
instructing g77
to behave more like it did
up through version 0.5.19.1, when it paid little or
no attention to disagreements between program units
about a procedure's type and argument information,
and when it performed no inlining of procedures
(except statement functions).
Without this option, g77
defaults to performing
the potentially inlining procedures as it started doing
in version 0.5.20, but as of version 0.5.21, it also
diagnoses disagreements that might cause such inlining
to crash the compiler as (fatal) errors,
and warns about similar disagreements
that are currently believed to not
likely to result in the compiler later crashing
or producing incorrect code.
-fflatten-arrays
ARRAY_REF
construct
to handle all array references.
Note: This option is not supported.
It is intended for use only by g77
developers,
to evaluate code-generation issues.
It might be removed at any time.
-fbounds-check
-ffortran-bounds-check
libf2c
library routine s_rnge
to print the diagnostic.
However, whereas f2c
generates a single check per
reference for a multi-dimensional array, of the computed
offset against the valid offset range (0 through the size of the array),
g77
generates a single check per subscript expression.
This catches some cases of potential bugs that f2c
does not,
such as references to below the beginning of an assumed-size array.
g77
also generates checks for CHARACTER
substring references,
something f2c
currently does not do.
Use the new `-ffortran-bounds-check' option
to specify bounds-checking for only the Fortran code you are compiling,
not necessarily for code written in other languages.
Note: To provide more detailed information on the offending subscript,
g77
provides the libg2c
run-time library routine s_rnge
with somewhat differently-formatted information.
Here's a sample diagnostic:
Subscript out of range on file line 4, procedure rnge.f/bf. Attempt to access the -6-th element of variable b[subscript-2-of-2]. AbortedThe above message indicates that the offending source line is line 4 of the file `rnge.f', within the program unit (or statement function) named `bf'. The offended array is named `b'. The offended array dimension is the second for a two-dimensional array, and the offending, computed subscript expression was `-6'. For a
CHARACTER
substring reference, the second line has
this appearance:
Attempt to access the 11-th element of variable a[start-substring].This indicates that the offended
CHARACTER
variable or array
is named `a',
the offended substring position is the starting (leftmost) position,
and the offending substring expression is `11'.
(Though the verbage of s_rnge
is not ideal
for the purpose of the g77
compiler,
the above information should provide adequate diagnostic abilities
to it users.)
See section `Options for Code Generation Conventions' in Using and Porting GNU CC, for information on more options
offered by the GBE
shared by g77
, gcc
, and other GNU compilers.
Some of these do not work when compiling programs written in Fortran:
-fpcc-struct-return
-freg-struct-return
libg2c
with which
you will be linking all code compiled by g77
with the
same option.
-fshort-double
-fno-common
-fpack-struct
libg2c
library,
at the very least, even if it is built with the same option.
GNU Fortran currently does not make use of any environment
variables to control its operation above and beyond those
that affect the operation of gcc
.
See section `Environment Variables Affecting GNU CC' in Using and Porting GNU CC, for information on environment variables.
Go to the first, previous, next, last section, table of contents.