g77 command supports all the options supported by the
See section `GNU CC Command Options' in Using and Porting GNU CC,
on the non-Fortran-specific aspects of the
gcc command (and,
g77 command supports one option not supported by
gcc, is to be invoked by
g77to do its job. For example, within the gcc build directory after building GNU Fortran (but without having to install it), `./g77 --driver=./xgcc foo.f -B./'.
All other options are supported both by
g77 and by
modified (and reinstalled) by the
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.
Here is a summary of all the options specific to GNU Fortran, grouped by type. Explanations are in the following sections.
--driver -fversion -fset-g77-defaults
-ffree-form -fno-fixed-form -ff90 -fvxt-not-f90 -ff90-not-vxt -fdollar-ok -fno-backslash -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 -fdcp-intrinsics-delete -fdcp-intrinsics-hide -fdcp-intrinsics-disable -fdcp-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 -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 -fugly -fno-ugly-args -fno-ugly-init -w -Wimplicit -Wunused -Wuninitialized -Wall -Wsurprising -Werror -W
-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
-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
Compilation can involve as many as four stages: preprocessing, compilation proper, 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 compilation is done. Suffixes specific to GNU Fortran are listed below. See section Options Controlling the Kind of Output, for information on suffixes recognized by GNU CC.
cpp, which is part of GNU CC).
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
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
Hollerith and things like continued character constants can nevertheless
The following options that affect overall processing are recognized
gcc commands in a GNU Fortran installation:
g77command, not when invoking the
gcccommand. See section GNU Fortran Command Options, for information on this option.
g77-specific version of the compiler phase is reported, if run. (This is supplied automatically when `-v' or `--version' is specified as a command-line option for
gccand when the resulting commands compile Fortran source files.)
gccoptions are to apply to Fortran compilations. For version 0.5.18, this is equivalent to `-fmove-all-movables -freduce-all-givs -frerun-loop-opt'. (This is supplied automatically when compiling Fortran code. The description of this option is here so that users seeing it in the output of, say, `g77 -v' understand why it is there. Also, developers who run
f771directly might want to specify it by hand to get the same defaults as they would running
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
(and, by extension, the
The following options control the dialect of Fortran that the compiler accepts:
g77implements 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 Certain Changes We Don't Want to Make, for information on why `-fbackslash' is the default instead of `-fno-backslash'.
FLUSHas a library function and thus works with other UNIX Fortran compilers or earlier version of
g77, either add the `EXTERNAL FLUSH' statement or, perhaps more convenient for you, compile with the -funix-intrinsics-hide or -funix-intrinsics-delete option. Note that
SYSTEMare intrinsic subroutines, not functions (since they have side effects), so to get the return values from
SYSTEM, append a final argument specifying an `INTEGER' variable or array element to receive the returned status. (For example, `CALL SYSTEM('rm foo',ISTAT)'.)
FLUSH()accepts an optional single `INTEGER' argument, since many Fortran implementations allow or require a unit number. Currently, since
libf2cdoes not flush a given unit number, this argument is not used--all units are flushed by
libf2c's implementation of
FLUSH(). Do not depend on this behavior--if you want to flush all units, use `CALL FLUSH' (that is, specify no arguments to
EXIT()accepts an optional single `INTEGER' argument. If omitted, zero is the default (as in `CALL EXIT(0)'). The default might change on configurations where the "normal return status" is not zero, however. If you want to return a "success" status, it is best to call
EXITwith no arguments in your code, and let
g77choose the appropriate default.
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:
g77in this area are welcome.
DATAstatements), 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'.
volatile, or whose address is taken, or whose size is other than 1, 2, 4 or 8 bytes. Also, they do not occur for arrays, even when they are in registers. Note that there may be no warning about a variable that is used only to compute a value that itself is never used, because such computations may be deleted by data flow analysis before the warnings are printed. These warnings are made optional because GNU Fortran is not smart enough to see all the reasons why the code might be correct despite appearing to have an error. Here is one example of how this can happen:
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
Jis always 1, 2 or 3, then
Iis always initialized, but GNU Fortran doesn't know this. Here is another common case:
SUBROUTINE MAYBE(FLAG) LOGICAL FLAG IF (FLAG) VALUE = 3.14 ... IF (FLAG) PRINT *, VALUE ENDThis has no bug because
VALUEis used only if it is set.
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.
g77, along with many other compilers, interprets this example differently than many programmers, and a few other compilers. Specifically,
g77interprets `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
g77evaluates to .25, while others might evaluate it to 0., the difference being the way precedence affects type promotion. (The `-fpedantic' option also warns about expressions having two arithmetic operators in a row.)
g77is 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.
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
gcc, and other GNU compilers.
Some of these have no effect when compiling programs written in Fortran:
GNU Fortran has various special options that are used for debugging
either your program or
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.
The following flags have particular applicability when compiling Fortran programs:
email@example.com). 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
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
Since this statement 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' statement.
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 preproecssor is used.
Some of these options also affect how
for files specified via the `INCLUDE' statement.
These options are:
cpppreprocessor). 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
g77compiler (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
cpppreprocessor, 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.
SAVEstatement 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'.)
SAVEattribute, it might be a good idea to also use `-fno-automatic' with `-finit-local-zero'.
f2c. This does not affect the generation of code that interfaces with the
libf2clibrary. 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.
libf2cis 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
libf2clibrary, even when being compiled by future versions of
g77that might otherwise default to generating code for an incompatible library.
g77appends two underscores to names with underscores and one underscore to external names with no underscores. (
g77also appends two underscores to internal names with underscores to avoid naming collisions with external names.) 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
g77for an external name matches the interface implemented by some other language for that same name. That is, getting code produced by
g77to 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.
g77normally treats `DATA' and other statements that are used 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
g77might 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.
See section `Options for Code Generation Conventions' in Using and Porting GNU CC, for information on more options
offered by the GBE
gcc, and other GNU compilers.
Some of these do not work when compiling programs written in Fortran:
libf2cwith which you will be linking all code compiled by
g77with the same option.
libf2clibrary, 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
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.