@c Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004 @c Free Software Foundation, Inc. @c This is part of the G77 manual. @c For copying conditions, see the file g77.texi. @ignore @c man begin COPYRIGHT Copyright @copyright{} 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being ``GNU General Public License'' and ``Funding Free Software'', the Front-Cover texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the gfdl(7) man page. (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. @c man end @c Set file name and title for the man page. @setfilename g77 @settitle GNU project Fortran 77 compiler. @c man begin SYNOPSIS g77 [@option{-c}|@option{-S}|@option{-E}] [@option{-g}] [@option{-pg}] [@option{-O}@var{level}] [@option{-W}@var{warn}@dots{}] [@option{-pedantic}] [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}] [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}] [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}] [@option{-o} @var{outfile}] @var{infile}@dots{} Only the most useful options are listed here; see below for the remainder. @c man end @c man begin SEEALSO gpl(7), gfdl(7), fsf-funding(7), cpp(1), gcov(1), gcc(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1) and the Info entries for @file{gcc}, @file{cpp}, @file{g77}, @file{as}, @file{ld}, @file{binutils} and @file{gdb}. @c man end @c man begin BUGS For instructions on reporting bugs, see @w{@uref{http://gcc.gnu.org/bugs.html}}. Use of the @command{gccbug} script to report bugs is recommended. @c man end @c man begin AUTHOR See the Info entry for @command{g77} for contributors to GCC and G77@. @c man end @end ignore @node Invoking G77 @chapter GNU Fortran Command Options @cindex GNU Fortran command options @cindex command options @cindex options, GNU Fortran command @c man begin DESCRIPTION The @command{g77} command supports all the options supported by the @command{gcc} command. @xref{Invoking GCC,,GCC Command Options,gcc,Using the GNU Compiler Collection (GCC)}, for information on the non-Fortran-specific aspects of the @command{gcc} command (and, therefore, the @command{g77} command). @cindex options, negative forms @cindex negative forms of options All @command{gcc} and @command{g77} options are accepted both by @command{g77} and by @command{gcc} (as well as any other drivers built at the same time, such as @command{g++}), since adding @command{g77} to the @command{gcc} distribution enables acceptance of @command{g77} options by all of the relevant drivers. In some cases, options have positive and negative forms; the negative form of @option{-ffoo} would be @option{-fno-foo}. This manual documents only one of these two forms, whichever one is not the default. @c man end @menu * Option Summary:: Brief list of all @command{g77} options, without explanations. * Overall Options:: Controlling the kind of output: an executable, object files, assembler files, or preprocessed source. * Shorthand Options:: Options that are shorthand for other options. * Fortran Dialect Options:: Controlling the variant of Fortran language compiled. * Warning Options:: How picky should the compiler be? * Debugging Options:: Symbol tables, measurements, and debugging dumps. * Optimize Options:: How much optimization? * Preprocessor Options:: Controlling header files and macro definitions. Also, getting dependency information for Make. * Directory Options:: Where to find header files and libraries. Where to find the compiler executable files. * Code Gen Options:: Specifying conventions for function calls, data layout and register usage. * Environment Variables:: Env vars that affect GNU Fortran. @end menu @node Option Summary @section Option Summary @c man begin OPTIONS Here is a summary of all the options specific to GNU Fortran, grouped by type. Explanations are in the following sections. @table @emph @item Overall Options @xref{Overall Options,,Options Controlling the Kind of Output}. @gccoptlist{ -fversion -fset-g77-defaults -fno-silent} @item Shorthand Options @xref{Shorthand Options}. @gccoptlist{ -ff66 -fno-f66 -ff77 -fno-f77 -fno-ugly} @item Fortran Language Options @xref{Fortran Dialect Options,,Options Controlling Fortran Dialect}. @gccoptlist{ -ffree-form -fno-fixed-form -ff90 @gol -fvxt -fdollar-ok -fno-backslash @gol -fno-ugly-args -fno-ugly-assign -fno-ugly-assumed @gol -fugly-comma -fugly-complex -fugly-init -fugly-logint @gol -fonetrip -ftypeless-boz @gol -fintrin-case-initcap -fintrin-case-upper @gol -fintrin-case-lower -fintrin-case-any @gol -fmatch-case-initcap -fmatch-case-upper @gol -fmatch-case-lower -fmatch-case-any @gol -fsource-case-upper -fsource-case-lower @gol -fsource-case-preserve @gol -fsymbol-case-initcap -fsymbol-case-upper @gol -fsymbol-case-lower -fsymbol-case-any @gol -fcase-strict-upper -fcase-strict-lower @gol -fcase-initcap -fcase-upper -fcase-lower -fcase-preserve @gol -ff2c-intrinsics-delete -ff2c-intrinsics-hide @gol -ff2c-intrinsics-disable -ff2c-intrinsics-enable @gol -fbadu77-intrinsics-delete -fbadu77-intrinsics-hide @gol -fbadu77-intrinsics-disable -fbadu77-intrinsics-enable @gol -ff90-intrinsics-delete -ff90-intrinsics-hide @gol -ff90-intrinsics-disable -ff90-intrinsics-enable @gol -fgnu-intrinsics-delete -fgnu-intrinsics-hide @gol -fgnu-intrinsics-disable -fgnu-intrinsics-enable @gol -fmil-intrinsics-delete -fmil-intrinsics-hide @gol -fmil-intrinsics-disable -fmil-intrinsics-enable @gol -funix-intrinsics-delete -funix-intrinsics-hide @gol -funix-intrinsics-disable -funix-intrinsics-enable @gol -fvxt-intrinsics-delete -fvxt-intrinsics-hide @gol -fvxt-intrinsics-disable -fvxt-intrinsics-enable @gol -ffixed-line-length-@var{n} -ffixed-line-length-none} @item Warning Options @xref{Warning Options,,Options to Request or Suppress Warnings}. @gccoptlist{ -fsyntax-only -pedantic -pedantic-errors -fpedantic @gol -w -Wno-globals -Wimplicit -Wunused -Wuninitialized @gol -Wall -Wsurprising @gol -Werror -W} @item Debugging Options @xref{Debugging Options,,Options for Debugging Your Program or GCC}. @gccoptlist{ -g} @item Optimization Options @xref{Optimize Options,,Options that Control Optimization}. @gccoptlist{ -malign-double @gol -ffloat-store -fforce-mem -fforce-addr -fno-inline @gol -ffast-math -fstrength-reduce -frerun-cse-after-loop @gol -funsafe-math-optimizations -ffinite-math-only -fno-trapping-math @gol -fexpensive-optimizations -fdelayed-branch @gol -fschedule-insns -fschedule-insn2 -fcaller-saves @gol -funroll-loops -funroll-all-loops @gol -fno-move-all-movables -fno-reduce-all-givs @gol -fno-rerun-loop-opt} @item Directory Options @xref{Directory Options,,Options for Directory Search}. @gccoptlist{ -I@var{dir} -I-} @item Code Generation Options @xref{Code Gen Options,,Options for Code Generation Conventions}. @gccoptlist{ -fno-automatic -finit-local-zero -fno-f2c @gol -ff2c-library -fno-underscoring -fno-ident @gol -fpcc-struct-return -freg-struct-return @gol -fshort-double -fno-common -fpack-struct @gol -fzeros -fno-second-underscore @gol -femulate-complex @gol -falias-check -fargument-alias @gol -fargument-noalias -fno-argument-noalias-global @gol -fno-globals -fflatten-arrays @gol -fbounds-check -ffortran-bounds-check} @end table @c man end @menu * Overall Options:: Controlling the kind of output: an executable, object files, assembler files, or preprocessed source. * Shorthand Options:: Options that are shorthand for other options. * Fortran Dialect Options:: Controlling the variant of Fortran language compiled. * Warning Options:: How picky should the compiler be? * Debugging Options:: Symbol tables, measurements, and debugging dumps. * Optimize Options:: How much optimization? * Preprocessor Options:: Controlling header files and macro definitions. Also, getting dependency information for Make. * Directory Options:: Where to find header files and libraries. Where to find the compiler executable files. * Code Gen Options:: Specifying conventions for function calls, data layout and register usage. @end menu @node Overall Options @section Options Controlling the Kind of Output @cindex overall options @cindex options, overall @c man begin OPTIONS 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. @cindex file name suffix @cindex suffixes, file name @cindex file name extension @cindex extensions, file name @cindex file type @cindex types, 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. @xref{Overall Options,,Options Controlling the Kind of Output,gcc,Using the GNU Compiler Collection (GCC)}, for information on suffixes recognized by GCC. @table @gcctabopt @cindex .f filename suffix @cindex .for filename suffix @cindex .FOR filename suffix @item @var{file}.f @item @var{file}.for @item @var{file}.FOR Fortran source code that should not be preprocessed. Such source code cannot contain any preprocessor directives, such as @code{#include}, @code{#define}, @code{#if}, and so on. You can force @samp{.f} files to be preprocessed by @command{cpp} by using @option{-x f77-cpp-input}. @xref{LEX}. @cindex preprocessor @cindex C preprocessor @cindex cpp preprocessor @cindex Fortran preprocessor @cindex cpp program @cindex programs, cpp @cindex .F filename suffix @cindex .fpp filename suffix @cindex .FPP filename suffix @item @var{file}.F @item @var{file}.fpp @item @var{file}.FPP Fortran source code that must be preprocessed (by the C preprocessor @command{cpp}, which is part of GCC). Note that preprocessing is not extended to the contents of files included by the @code{INCLUDE} directive---the @code{#include} preprocessor directive must be used instead. @cindex Ratfor preprocessor @cindex programs, @command{ratfor} @cindex @samp{.r} filename suffix @cindex @command{ratfor} @item @var{file}.r Ratfor source code, which must be preprocessed by the @command{ratfor} command, which is available separately (as it is not yet part of the GNU Fortran distribution). A public domain version in C is at @uref{http://sepwww.stanford.edu/sep/prof/ratfor.shar.2}. @end table UNIX users typically use the @file{@var{file}.f} and @file{@var{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{@var{file}.for} and @file{@var{file}.fpp} nomenclature. @cindex #define @cindex #include @cindex #if Use of the preprocessor @command{cpp} allows use of C-like constructs such as @code{#define} and @code{#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 @code{#include} and, in conjunction with @code{#define}, only @code{#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! @emph{Note:} The @option{-traditional} and @option{-undef} flags are supplied to @command{cpp} by default, to help avoid unpleasant surprises. @xref{Preprocessor Options,,Options Controlling the Preprocessor, gcc,Using the GNU Compiler Collection (GCC)}. This means that ANSI C preprocessor features (such as the @samp{#} 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, @samp{#ifdef __linux__} rather than @samp{#ifdef linux}. Use the @option{-v} option to see exactly how the preprocessor is invoked. @cindex /* Unfortunately, the @option{-traditional} flag will not avoid an error from anything that @command{cpp} sees as an unterminated C comment, such as: @smallexample C Some Fortran compilers accept /* as starting C an inline comment. @end smallexample @xref{Trailing Comment}. The following options that affect overall processing are recognized by the @command{g77} and @command{gcc} commands in a GNU Fortran installation: @table @gcctabopt @cindex -fversion option @cindex options, -fversion @cindex printing version information @cindex version information, printing @cindex consistency checks @cindex internal consistency checks @cindex checks, of internal consistency @item -fversion Ensure that the @command{g77} version of the compiler phase is reported, if run, and, starting in @code{egcs} version 1.1, that internal consistency checks in the @file{f771} program are run. This option is supplied automatically when @option{-v} or @option{--verbose} is specified as a command-line option for @command{g77} or @command{gcc} and when the resulting commands compile Fortran source files. In GCC 3.1, this is changed back to the behavior @command{gcc} displays for @samp{.c} files. @cindex -fset-g77-defaults option @cindex options, -fset-g77-defaults @item -fset-g77-defaults @emph{Version info:} This option was obsolete as of @code{egcs} version 1.1. The effect is instead achieved by the @code{lang_init_options} routine in @file{gcc/gcc/f/com.c}. @cindex consistency checks @cindex internal consistency checks @cindex checks, of internal consistency Set up whatever @command{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 @command{g77} or @command{gcc} command. The description of this option is provided so that users seeing it in the output of, say, @samp{g77 -v} understand why it is there. @cindex modifying @command{g77} @cindex @command{g77}, modifying Also, developers who run @code{f771} directly might want to specify it by hand to get the same defaults as they would running @code{f771} via @command{g77} or @command{gcc} However, such developers should, after linking a new @code{f771} executable, invoke it without this option once, e.g. via @kbd{./f771 -quiet < /dev/null}, to ensure that they have not introduced any internal inconsistencies (such as in the table of intrinsics) before proceeding---@command{g77} will crash with a diagnostic if it detects an inconsistency. @cindex -fno-silent option @cindex options, -fno-silent @cindex f2c compatibility @cindex compatibility, f2c @cindex status, compilation @cindex compilation, status @cindex reporting compilation status @cindex printing compilation status @item -fno-silent Print (to @code{stderr}) the names of the program units as they are compiled, in a form similar to that used by popular UNIX @command{f77} implementations and @command{f2c} @end table @xref{Overall Options,,Options Controlling the Kind of Output, gcc,Using the GNU Compiler Collection (GCC)}, for information on more options that control the overall operation of the @command{gcc} command (and, by extension, the @command{g77} command). @node Shorthand Options @section Shorthand Options @cindex shorthand options @cindex options, shorthand @cindex macro options @cindex options, macro The following options serve as ``shorthand'' for other options accepted by the compiler: @table @gcctabopt @cindex -fugly option @cindex options, -fugly @item -fugly @cindex ugly features @cindex features, ugly @emph{Note:} This option is no longer supported. The information, below, is provided to aid in the conversion of old scripts. Specify that certain ``ugly'' constructs are to be quietly accepted. Same as: @smallexample -fugly-args -fugly-assign -fugly-assumed -fugly-comma -fugly-complex -fugly-init -fugly-logint @end smallexample These constructs are considered inappropriate to use in new or well-maintained portable Fortran code, but widely used in old code. @xref{Distensions}, for more information. @cindex -fno-ugly option @cindex options, -fno-ugly @item -fno-ugly @cindex ugly features @cindex features, ugly Specify that all ``ugly'' constructs are to be noisily rejected. Same as: @smallexample -fno-ugly-args -fno-ugly-assign -fno-ugly-assumed -fno-ugly-comma -fno-ugly-complex -fno-ugly-init -fno-ugly-logint @end smallexample @xref{Distensions}, for more information. @cindex -ff66 option @cindex options, -ff66 @item -ff66 @cindex FORTRAN 66 @cindex compatibility, FORTRAN 66 Specify that the program is written in idiomatic FORTRAN 66. Same as @samp{-fonetrip -fugly-assumed}. The @option{-fno-f66} option is the inverse of @option{-ff66}. As such, it is the same as @samp{-fno-onetrip -fno-ugly-assumed}. The meaning of this option is likely to be refined as future versions of @command{g77} provide more compatibility with other existing and obsolete Fortran implementations. @cindex -ff77 option @cindex options, -ff77 @item -ff77 @cindex UNIX f77 @cindex f2c compatibility @cindex compatibility, f2c @cindex f77 compatibility @cindex compatibility, f77 Specify that the program is written in idiomatic UNIX FORTRAN 77 and/or the dialect accepted by the @command{f2c} product. Same as @samp{-fbackslash -fno-typeless-boz}. The meaning of this option is likely to be refined as future versions of @command{g77} provide more compatibility with other existing and obsolete Fortran implementations. @cindex -fno-f77 option @cindex options, -fno-f77 @item -fno-f77 @cindex UNIX f77 The @option{-fno-f77} option is @emph{not} the inverse of @option{-ff77}. It specifies that the program is not written in idiomatic UNIX FORTRAN 77 or @command{f2c} but in a more widely portable dialect. @option{-fno-f77} is the same as @option{-fno-backslash}. The meaning of this option is likely to be refined as future versions of @command{g77} provide more compatibility with other existing and obsolete Fortran implementations. @end table @node Fortran Dialect Options @section Options Controlling Fortran Dialect @cindex dialect options @cindex language, dialect options @cindex options, dialect The following options control the dialect of Fortran that the compiler accepts: @table @gcctabopt @cindex -ffree-form option @cindex options, -ffree-form @cindex -fno-fixed-form option @cindex options, -fno-fixed-form @cindex source file format @cindex free form @cindex fixed form @cindex Fortran 90, features @item -ffree-form @item -fno-fixed-form Specify that the source file is written in free form (introduced in Fortran 90) instead of the more-traditional fixed form. @cindex -ff90 option @cindex options, -ff90 @cindex Fortran 90, features @item -ff90 Allow certain Fortran-90 constructs. This option controls whether certain Fortran 90 constructs are recognized. (Other Fortran 90 constructs might or might not be recognized depending on other options such as @option{-fvxt}, @option{-ff90-intrinsics-enable}, and the current level of support for Fortran 90.) @xref{Fortran 90}, for more information. @cindex -fvxt option @cindex options, -fvxt @item -fvxt @cindex Fortran 90, features @cindex VXT extensions Specify the treatment of certain constructs that have different meanings depending on whether the code is written in GNU Fortran (based on FORTRAN 77 and akin to Fortran 90) or VXT Fortran (more like VAX FORTRAN). The default is @option{-fno-vxt}. @option{-fvxt} specifies that the VXT Fortran interpretations for those constructs are to be chosen. @xref{VXT Fortran}, for more information. @cindex -fdollar-ok option @cindex options, -fdollar-ok @item -fdollar-ok @cindex dollar sign @cindex symbol names @cindex character set Allow @samp{$} as a valid character in a symbol name. @cindex -fno-backslash option @cindex options, -fno-backslash @item -fno-backslash @cindex backslash @cindex character constants @cindex Hollerith constants Specify that @samp{\} is not to be specially interpreted in character and Hollerith constants a la C and many UNIX Fortran compilers. For example, with @option{-fbackslash} in effect, @samp{A\nB} specifies three characters, with the second one being newline. With @option{-fno-backslash}, it specifies four characters, @samp{A}, @samp{\}, @samp{n}, and @samp{B}. Note that @command{g77} implements a fairly general form of backslash processing that is incompatible with the narrower forms supported by some other compilers. For example, @samp{'A\003B'} is a three-character string in @command{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. @xref{Backslash in Constants}, for information on why @option{-fbackslash} is the default instead of @option{-fno-backslash}. @cindex -fno-ugly-args option @cindex options, -fno-ugly-args @item -fno-ugly-args Disallow passing Hollerith and typeless constants as actual arguments (for example, @samp{CALL FOO(4HABCD)}). @xref{Ugly Implicit Argument Conversion}, for more information. @cindex -fugly-assign option @cindex options, -fugly-assign @item -fugly-assign Use the same storage for a given variable regardless of whether it is used to hold an assigned-statement label (as in @samp{ASSIGN 10 TO I}) or used to hold numeric data (as in @samp{I = 3}). @xref{Ugly Assigned Labels}, for more information. @cindex -fugly-assumed option @cindex options, -fugly-assumed @item -fugly-assumed Assume any dummy array with a final dimension specified as @samp{1} is really an assumed-size array, as if @samp{*} had been specified for the final dimension instead of @samp{1}. For example, @samp{DIMENSION X(1)} is treated as if it had read @samp{DIMENSION X(*)}. @xref{Ugly Assumed-Size Arrays}, for more information. @cindex -fugly-comma option @cindex options, -fugly-comma @item -fugly-comma In an external-procedure invocation, treat a trailing comma in the argument list as specification of a trailing null argument, and treat an empty argument list as specification of a single null argument. For example, @samp{CALL FOO(,)} is treated as @samp{CALL FOO(%VAL(0), %VAL(0))}. That is, @emph{two} null arguments are specified by the procedure call when @option{-fugly-comma} is in force. And @samp{F = FUNC()} is treated as @samp{F = FUNC(%VAL(0))}. The default behavior, @option{-fno-ugly-comma}, is to ignore a single trailing comma in an argument list. So, by default, @samp{CALL FOO(X,)} is treated exactly the same as @samp{CALL FOO(X)}. @xref{Ugly Null Arguments}, for more information. @cindex -fugly-complex option @cindex options, -fugly-complex @item -fugly-complex Do not complain about @samp{REAL(@var{expr})} or @samp{AIMAG(@var{expr})} when @var{expr} is a @code{COMPLEX} type other than @code{COMPLEX(KIND=1)}---usually this is used to permit @code{COMPLEX(KIND=2)} (@code{DOUBLE COMPLEX}) operands. The @option{-ff90} option controls the interpretation of this construct. @xref{Ugly Complex Part Extraction}, for more information. @cindex -fno-ugly-init option @cindex options, -fno-ugly-init @item -fno-ugly-init Disallow use of Hollerith and typeless constants as initial values (in @code{PARAMETER} and @code{DATA} statements), and use of character constants to initialize numeric types and vice versa. For example, @samp{DATA I/'F'/, CHRVAR/65/, J/4HABCD/} is disallowed by @option{-fno-ugly-init}. @xref{Ugly Conversion of Initializers}, for more information. @cindex -fugly-logint option @cindex options, -fugly-logint @item -fugly-logint Treat @code{INTEGER} and @code{LOGICAL} variables and expressions as potential stand-ins for each other. For example, automatic conversion between @code{INTEGER} and @code{LOGICAL} is enabled, for many contexts, via this option. @xref{Ugly Integer Conversions}, for more information. @cindex -fonetrip option @cindex options, -fonetrip @item -fonetrip @cindex FORTRAN 66 @cindex @code{DO} loops, one-trip @cindex one-trip @code{DO} loops @cindex @code{DO} loops, zero-trip @cindex zero-trip @code{DO} loops @cindex compatibility, FORTRAN 66 Executable iterative @code{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 @code{DO} loop is not executed if the number of iterations calculated from the parameters of the loop is less than 1. (For example, @samp{DO 10 I = 1, 0}.) Such a loop is called a @dfn{zero-trip loop}. Prior to ANSI FORTRAN 77, many compilers implemented @code{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 @dfn{one-trip loops}. For example, some code written to the FORTRAN 66 standard expects this behavior from its @code{DO} loops, although that standard did not specify this behavior. The @option{-fonetrip} option specifies that the source file(s) being compiled require one-trip loops. This option affects only those loops specified by the (iterative) @code{DO} statement and by implied-@code{DO} lists in I/O statements. Loops specified by implied-@code{DO} lists in @code{DATA} and specification (non-executable) statements are not affected. @cindex -ftypeless-boz option @cindex options, -ftypeless-boz @cindex prefix-radix constants @cindex constants, prefix-radix @cindex constants, types @cindex types, constants @item -ftypeless-boz Specifies that prefix-radix non-decimal constants, such as @samp{Z'ABCD'}, are typeless instead of @code{INTEGER(KIND=1)}. You can test for yourself whether a particular compiler treats the prefix form as @code{INTEGER(KIND=1)} or typeless by running the following program: @smallexample 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' END @end smallexample Reports indicate that many compilers process this form as @code{INTEGER(KIND=1)}, though a few as typeless, and at least one based on a command-line option specifying some kind of compatibility. @cindex -fintrin-case-initcap option @cindex options, -fintrin-case-initcap @item -fintrin-case-initcap @cindex -fintrin-case-upper option @cindex options, -fintrin-case-upper @item -fintrin-case-upper @cindex -fintrin-case-lower option @cindex options, -fintrin-case-lower @item -fintrin-case-lower @cindex -fintrin-case-any option @cindex options, -fintrin-case-any @item -fintrin-case-any Specify expected case for intrinsic names. @option{-fintrin-case-lower} is the default. @cindex -fmatch-case-initcap option @cindex options, -fmatch-case-initcap @item -fmatch-case-initcap @cindex -fmatch-case-upper option @cindex options, -fmatch-case-upper @item -fmatch-case-upper @cindex -fmatch-case-lower option @cindex options, -fmatch-case-lower @item -fmatch-case-lower @cindex -fmatch-case-any option @cindex options, -fmatch-case-any @item -fmatch-case-any Specify expected case for keywords. @option{-fmatch-case-lower} is the default. @cindex -fsource-case-upper option @cindex options, -fsource-case-upper @item -fsource-case-upper @cindex -fsource-case-lower option @cindex options, -fsource-case-lower @item -fsource-case-lower @cindex -fsource-case-preserve option @cindex options, -fsource-case-preserve @item -fsource-case-preserve Specify whether source text other than character and Hollerith constants is to be translated to uppercase, to lowercase, or preserved as is. @option{-fsource-case-lower} is the default. @cindex -fsymbol-case-initcap option @cindex options, -fsymbol-case-initcap @item -fsymbol-case-initcap @cindex -fsymbol-case-upper option @cindex options, -fsymbol-case-upper @item -fsymbol-case-upper @cindex -fsymbol-case-lower option @cindex options, -fsymbol-case-lower @item -fsymbol-case-lower @cindex -fsymbol-case-any option @cindex options, -fsymbol-case-any @item -fsymbol-case-any Specify valid cases for user-defined symbol names. @option{-fsymbol-case-any} is the default. @cindex -fcase-strict-upper option @cindex options, -fcase-strict-upper @item -fcase-strict-upper Same as @samp{-fintrin-case-upper -fmatch-case-upper -fsource-case-preserve -fsymbol-case-upper}. (Requires all pertinent source to be in uppercase.) @cindex -fcase-strict-lower option @cindex options, -fcase-strict-lower @item -fcase-strict-lower Same as @samp{-fintrin-case-lower -fmatch-case-lower -fsource-case-preserve -fsymbol-case-lower}. (Requires all pertinent source to be in lowercase.) @cindex -fcase-initcap option @cindex options, -fcase-initcap @item -fcase-initcap Same as @samp{-fintrin-case-initcap -fmatch-case-initcap -fsource-case-preserve -fsymbol-case-initcap}. (Requires all pertinent source to be in initial capitals, as in @samp{Print *,SqRt(Value)}.) @cindex -fcase-upper option @cindex options, -fcase-upper @item -fcase-upper Same as @samp{-fintrin-case-any -fmatch-case-any -fsource-case-upper -fsymbol-case-any}. (Maps all pertinent source to uppercase.) @cindex -fcase-lower option @cindex options, -fcase-lower @item -fcase-lower Same as @samp{-fintrin-case-any -fmatch-case-any -fsource-case-lower -fsymbol-case-any}. (Maps all pertinent source to lowercase.) @cindex -fcase-preserve option @cindex options, -fcase-preserve @item -fcase-preserve Same as @samp{-fintrin-case-any -fmatch-case-any -fsource-case-preserve -fsymbol-case-any}. (Preserves all case in user-defined symbols, while allowing any-case matching of intrinsics and keywords. For example, @samp{call Foo(i,I)} would pass two @emph{different} variables named @samp{i} and @samp{I} to a procedure named @samp{Foo}.) @cindex -fbadu77-intrinsics-delete option @cindex options, -fbadu77-intrinsics-delete @item -fbadu77-intrinsics-delete @cindex -fbadu77-intrinsics-hide option @cindex options, -fbadu77-intrinsics-hide @item -fbadu77-intrinsics-hide @cindex -fbadu77-intrinsics-disable option @cindex options, -fbadu77-intrinsics-disable @item -fbadu77-intrinsics-disable @cindex -fbadu77-intrinsics-enable option @cindex options, -fbadu77-intrinsics-enable @item -fbadu77-intrinsics-enable @cindex @code{badu77} intrinsics @cindex intrinsics, @code{badu77} Specify status of UNIX intrinsics having inappropriate forms. @option{-fbadu77-intrinsics-enable} is the default. @xref{Intrinsic Groups}. @cindex -ff2c-intrinsics-delete option @cindex options, -ff2c-intrinsics-delete @item -ff2c-intrinsics-delete @cindex -ff2c-intrinsics-hide option @cindex options, -ff2c-intrinsics-hide @item -ff2c-intrinsics-hide @cindex -ff2c-intrinsics-disable option @cindex options, -ff2c-intrinsics-disable @item -ff2c-intrinsics-disable @cindex -ff2c-intrinsics-enable option @cindex options, -ff2c-intrinsics-enable @item -ff2c-intrinsics-enable @cindex @command{f2c} intrinsics @cindex intrinsics, @command{f2c} Specify status of f2c-specific intrinsics. @option{-ff2c-intrinsics-enable} is the default. @xref{Intrinsic Groups}. @cindex -ff90-intrinsics-delete option @cindex options, -ff90-intrinsics-delete @item -ff90-intrinsics-delete @cindex -ff90-intrinsics-hide option @cindex options, -ff90-intrinsics-hide @item -ff90-intrinsics-hide @cindex -ff90-intrinsics-disable option @cindex options, -ff90-intrinsics-disable @item -ff90-intrinsics-disable @cindex -ff90-intrinsics-enable option @cindex options, -ff90-intrinsics-enable @item -ff90-intrinsics-enable @cindex Fortran 90, intrinsics @cindex intrinsics, Fortran 90 Specify status of F90-specific intrinsics. @option{-ff90-intrinsics-enable} is the default. @xref{Intrinsic Groups}. @cindex -fgnu-intrinsics-delete option @cindex options, -fgnu-intrinsics-delete @item -fgnu-intrinsics-delete @cindex -fgnu-intrinsics-hide option @cindex options, -fgnu-intrinsics-hide @item -fgnu-intrinsics-hide @cindex -fgnu-intrinsics-disable option @cindex options, -fgnu-intrinsics-disable @item -fgnu-intrinsics-disable @cindex -fgnu-intrinsics-enable option @cindex options, -fgnu-intrinsics-enable @item -fgnu-intrinsics-enable @cindex Digital Fortran features @cindex @code{COMPLEX} intrinsics @cindex intrinsics, @code{COMPLEX} Specify status of Digital's COMPLEX-related intrinsics. @option{-fgnu-intrinsics-enable} is the default. @xref{Intrinsic Groups}. @cindex -fmil-intrinsics-delete option @cindex options, -fmil-intrinsics-delete @item -fmil-intrinsics-delete @cindex -fmil-intrinsics-hide option @cindex options, -fmil-intrinsics-hide @item -fmil-intrinsics-hide @cindex -fmil-intrinsics-disable option @cindex options, -fmil-intrinsics-disable @item -fmil-intrinsics-disable @cindex -fmil-intrinsics-enable option @cindex options, -fmil-intrinsics-enable @item -fmil-intrinsics-enable @cindex MIL-STD 1753 @cindex intrinsics, MIL-STD 1753 Specify status of MIL-STD-1753-specific intrinsics. @option{-fmil-intrinsics-enable} is the default. @xref{Intrinsic Groups}. @cindex -funix-intrinsics-delete option @cindex options, -funix-intrinsics-delete @item -funix-intrinsics-delete @cindex -funix-intrinsics-hide option @cindex options, -funix-intrinsics-hide @item -funix-intrinsics-hide @cindex -funix-intrinsics-disable option @cindex options, -funix-intrinsics-disable @item -funix-intrinsics-disable @cindex -funix-intrinsics-enable option @cindex options, -funix-intrinsics-enable @item -funix-intrinsics-enable @cindex UNIX intrinsics @cindex intrinsics, UNIX Specify status of UNIX intrinsics. @option{-funix-intrinsics-enable} is the default. @xref{Intrinsic Groups}. @cindex -fvxt-intrinsics-delete option @cindex options, -fvxt-intrinsics-delete @item -fvxt-intrinsics-delete @cindex -fvxt-intrinsics-hide option @cindex options, -fvxt-intrinsics-hide @item -fvxt-intrinsics-hide @cindex -fvxt-intrinsics-disable option @cindex options, -fvxt-intrinsics-disable @item -fvxt-intrinsics-disable @cindex -fvxt-intrinsics-enable option @cindex options, -fvxt-intrinsics-enable @item -fvxt-intrinsics-enable @cindex VXT intrinsics @cindex intrinsics, VXT Specify status of VXT intrinsics. @option{-fvxt-intrinsics-enable} is the default. @xref{Intrinsic Groups}. @cindex -ffixed-line-length-@var{n} option @cindex options, -ffixed-line-length-@var{n} @item -ffixed-line-length-@var{n} @cindex source file format @cindex lines, length @cindex length of source lines @cindex fixed form @cindex limits, lengths of source lines Set column after which characters are ignored in typical fixed-form lines in the source file, and through which spaces are assumed (as if padded to that length) after the ends of short fixed-form lines. @cindex card image @cindex extended-source option Popular values for @var{n} include 72 (the standard and the default), 80 (card image), and 132 (corresponds to ``extended-source'' options in some popular compilers). @var{n} may be @samp{none}, meaning that the entire line is meaningful and that continued character constants never have implicit spaces appended to them to fill out the line. @option{-ffixed-line-length-0} means the same thing as @option{-ffixed-line-length-none}. @xref{Source Form}, for more information. @end table @node Warning Options @section Options to Request or Suppress Warnings @cindex options, warnings @cindex warnings, suppressing @cindex messages, warning @cindex suppressing warnings 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 @option{-W}, for example @option{-Wimplicit} to request warnings on implicit declarations. Each of these specific warning options also has a negative form beginning @option{-Wno-} to turn off warnings; for example, @option{-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: @table @gcctabopt @cindex syntax checking @cindex -fsyntax-only option @cindex options, -fsyntax-only @item -fsyntax-only Check the code for syntax errors, but don't do anything beyond that. @cindex -pedantic option @cindex options, -pedantic @item -pedantic Issue warnings for uses of extensions to ANSI FORTRAN 77. @option{-pedantic} also applies to C-language constructs where they occur in GNU Fortran source files, such as use of @samp{\e} in a character constant within a directive like @samp{#include}. Valid ANSI FORTRAN 77 programs should compile properly with or without this option. However, without this option, certain GNU extensions and traditional Fortran features are supported as well. With this option, many of them are rejected. Some users try to use @option{-pedantic} to check programs for strict ANSI conformance. They soon find that it does not do quite what they want---it finds some non-ANSI practices, but not all. However, improvements to @command{g77} in this area are welcome. @cindex -pedantic-errors option @cindex options, -pedantic-errors @item -pedantic-errors Like @option{-pedantic}, except that errors are produced rather than warnings. @cindex -fpedantic option @cindex options, -fpedantic @item -fpedantic Like @option{-pedantic}, but applies only to Fortran constructs. @cindex -w option @cindex options, -w @item -w Inhibit all warning messages. @cindex -Wno-globals option @cindex options, -Wno-globals @item -Wno-globals @cindex global names, warning @cindex warnings, global names Inhibit warnings about use of a name as both a global name (a subroutine, function, or block data program unit, or a common block) and implicitly as the name of an intrinsic in a source file. Also inhibit warnings about inconsistent invocations and/or definitions of global procedures (function and subroutines). Such inconsistencies include different numbers of arguments and different types of arguments. @cindex -Wimplicit option @cindex options, -Wimplicit @item -Wimplicit @cindex implicit declaration, warning @cindex warnings, implicit declaration @cindex -u option @cindex /WARNINGS=DECLARATIONS switch @cindex IMPLICIT NONE, similar effect @cindex effecting IMPLICIT NONE Warn whenever a variable, array, or function is implicitly declared. Has an effect similar to using the @code{IMPLICIT NONE} statement in every program unit. (Some Fortran compilers provide this feature by an option named @option{-u} or @samp{/WARNINGS=DECLARATIONS}.) @cindex -Wunused option @cindex options, -Wunused @item -Wunused @cindex unused variables @cindex variables, unused Warn whenever a variable is unused aside from its declaration. @cindex -Wuninitialized option @cindex options, -Wuninitialized @item -Wuninitialized @cindex uninitialized variables @cindex variables, uninitialized Warn whenever an automatic variable is used without first being initialized. These warnings are possible only in optimizing compilation, because they require data-flow information that is computed only when optimizing. If you don't specify @option{-O}, you simply won't get these warnings. These warnings occur only for variables that are candidates for register allocation. Therefore, they do not occur for a variable @c that is declared @code{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 might 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: @example SUBROUTINE DISPAT(J) IF (J.EQ.1) I=1 IF (J.EQ.2) I=4 IF (J.EQ.3) I=5 CALL FOO(I) END @end example @noindent If the value of @code{J} is always 1, 2 or 3, then @code{I} is always initialized, but GNU Fortran doesn't know this. Here is another common case: @example SUBROUTINE MAYBE(FLAG) LOGICAL FLAG IF (FLAG) VALUE = 9.4 @dots{} IF (FLAG) PRINT *, VALUE END @end example @noindent This has no bug because @code{VALUE} is used only if it is set. @cindex -Wall option @cindex options, -Wall @item -Wall @cindex all warnings @cindex warnings, all The @option{-Wunused} and @option{-Wuninitialized} options combined. These are all the options which pertain to usage that we recommend avoiding and that we believe is easy to avoid. (As more warnings are added to @command{g77} some might be added to the list enabled by @option{-Wall}.) @end table The remaining @option{-W@dots{}} options are not implied by @option{-Wall} because they warn about constructions that we consider reasonable to use, on occasion, in clean programs. @table @gcctabopt @c @item -W @c Print extra warning messages for these events: @c @c @itemize @bullet @c @item @c If @option{-Wall} or @option{-Wunused} is also specified, warn about unused @c arguments. @c @c @end itemize @c @cindex -Wsurprising option @cindex options, -Wsurprising @item -Wsurprising Warn about ``suspicious'' constructs that are interpreted by the compiler in a way that might well be surprising to someone reading the code. These differences can result in subtle, compiler-dependent (even machine-dependent) behavioral differences. The constructs warned about include: @itemize @bullet @item Expressions having two arithmetic operators in a row, such as @samp{X*-Y}. Such a construct is nonstandard, and can produce unexpected results in more complicated situations such as @samp{X**-Y*Z}. @command{g77} along with many other compilers, interprets this example differently than many programmers, and a few other compilers. Specifically, @command{g77} interprets @samp{X**-Y*Z} as @samp{(X**(-Y))*Z}, while others might think it should be interpreted as @samp{X**(-(Y*Z))}. A revealing example is the constant expression @samp{2**-2*1.}, which @command{g77} evaluates to .25, while others might evaluate it to 0., the difference resulting from the way precedence affects type promotion. (The @option{-fpedantic} option also warns about expressions having two arithmetic operators in a row.) @item Expressions with a unary minus followed by an operand and then a binary operator other than plus or minus. For example, @samp{-2**2} produces a warning, because the precedence is @samp{-(2**2)}, yielding -4, not @samp{(-2)**2}, which yields 4, and which might represent what a programmer expects. An example of an expression producing different results in a surprising way is @samp{-I*S}, where @var{I} holds the value @samp{-2147483648} and @var{S} holds @samp{0.5}. On many systems, negating @var{I} results in the same value, not a positive number, because it is already the lower bound of what an @code{INTEGER(KIND=1)} variable can hold. So, the expression evaluates to a positive number, while the ``expected'' interpretation, @samp{(-I)*S}, would evaluate to a negative number. Even cases such as @samp{-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. @cindex DO statement @cindex statements, DO @item @code{DO} loops with @code{DO} variables that are not of integral type---that is, using @code{REAL} variables as loop control variables. Although such loops can be written to work in the ``obvious'' way, the way @command{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 @code{DO} loops, but the differences are pronounced for non-integral loop control variables.) @xref{Loops}, for more information. @end itemize @cindex -Werror option @cindex options, -Werror @item -Werror Make all warnings into errors. @cindex -W option @cindex options, -W @item -W @cindex extra warnings @cindex warnings, extra Turns on ``extra warnings'' and, if optimization is specified via @option{-O}, the @option{-Wuninitialized} option. (This might change in future versions of @command{g77} ``Extra warnings'' are issued for: @itemize @bullet @item @cindex unused parameters @cindex parameters, unused @cindex unused arguments @cindex arguments, unused @cindex unused dummies @cindex dummies, unused Unused parameters to a procedure (when @option{-Wunused} also is specified). @item @cindex overflow Overflows involving floating-point constants (not available for certain configurations). @end itemize @end table @xref{Warning Options,,Options to Request or Suppress Warnings, gcc,Using the GNU Compiler Collection (GCC)}, for information on more options offered by the GBE shared by @command{g77} @command{gcc} and other GNU compilers. Some of these have no effect when compiling programs written in Fortran: @table @gcctabopt @cindex -Wcomment option @cindex options, -Wcomment @item -Wcomment @cindex -Wformat option @cindex options, -Wformat @item -Wformat @cindex -Wparentheses option @cindex options, -Wparentheses @item -Wparentheses @cindex -Wswitch option @cindex options, -Wswitch @item -Wswitch @cindex -Wswitch-default option @cindex options, -Wswitch-default @item -Wswitch-default @cindex -Wswitch-enum option @cindex options, -Wswitch-enum @item -Wswitch-enum @cindex -Wtraditional option @cindex options, -Wtraditional @item -Wtraditional @cindex -Wshadow option @cindex options, -Wshadow @item -Wshadow @cindex -Wid-clash-@var{len} option @cindex options, -Wid-clash-@var{len} @item -Wid-clash-@var{len} @cindex -Wlarger-than-@var{len} option @cindex options, -Wlarger-than-@var{len} @item -Wlarger-than-@var{len} @cindex -Wconversion option @cindex options, -Wconversion @item -Wconversion @cindex -Waggregate-return option @cindex options, -Waggregate-return @item -Waggregate-return @cindex -Wredundant-decls option @cindex options, -Wredundant-decls @item -Wredundant-decls @cindex unsupported warnings @cindex warnings, unsupported These options all could have some relevant meaning for GNU Fortran programs, but are not yet supported. @end table @node Debugging Options @section Options for Debugging Your Program or GNU Fortran @cindex options, debugging @cindex debugging information options GNU Fortran has various special options that are used for debugging either your program or @command{g77} @table @gcctabopt @cindex -g option @cindex options, -g @item -g Produce debugging information in the operating system's native format (stabs, COFF, XCOFF, or DWARF). GDB can work with this debugging information. A sample debugging session looks like this (note the use of the breakpoint): @smallexample $ cat gdb.f PROGRAM PROG DIMENSION A(10) DATA A /1.,2.,3.,4.,5.,6.,7.,8.,9.,10./ A(5) = 4. PRINT*,A END $ g77 -g -O gdb.f $ gdb a.out ... (gdb) break MAIN__ Breakpoint 1 at 0x8048e96: file gdb.f, line 4. (gdb) run Starting program: /home/toon/g77-bugs/./a.out Breakpoint 1, MAIN__ () at gdb.f:4 4 A(5) = 4. Current language: auto; currently fortran (gdb) print a(5) $1 = 5 (gdb) step 5 PRINT*,A (gdb) print a(5) $2 = 4 ... @end smallexample One could also add the setting of the breakpoint and the first run command to the file @file{.gdbinit} in the current directory, to simplify the debugging session. @end table @xref{Debugging Options,,Options for Debugging Your Program or GCC, gcc,Using the GNU Compiler Collection (GCC)}, for more information on debugging options. @node Optimize Options @section Options That Control Optimization @cindex optimize options @cindex options, optimization Most Fortran users will want to use no optimization when developing and testing programs, and use @option{-O} or @option{-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 @option{-O}, i.e.@: you must use @option{-O} or @option{-O2} to get such diagnostics. The following flags have particular applicability when compiling Fortran programs: @table @gcctabopt @cindex -malign-double option @cindex options, -malign-double @item -malign-double (Intel x86 architecture only.) Noticeably improves performance of @command{g77} programs making heavy use of @code{REAL(KIND=2)} (@code{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 @code{REAL(KIND=2)} (@code{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. @emph{Note:} The warning in the @command{gcc} documentation about this option does not apply, generally speaking, to Fortran code compiled by @command{g77} @xref{Aligned Data}, for more information on alignment issues. @emph{Also also note:} The negative form of @option{-malign-double} is @option{-mno-align-double}, not @option{-benign-double}. @cindex -ffloat-store option @cindex options, -ffloat-store @item -ffloat-store @cindex IEEE 754 conformance @cindex conformance, IEEE 754 @cindex floating-point, precision Might help a Fortran program that depends on exact IEEE conformance on some machines, but might slow down a program that doesn't. This option is effective when the floating-point unit is set to work in IEEE 854 `extended precision'---as it typically is on x86 and m68k GNU systems---rather than IEEE 754 double precision. @option{-ffloat-store} tries to remove the extra precision by spilling data from floating-point registers into memory and this typically involves a big performance hit. However, it doesn't affect intermediate results, so that it is only partially effective. `Excess precision' is avoided in code like: @smallexample a = b + c d = a * e @end smallexample but not in code like: @smallexample d = (b + c) * e @end smallexample For another, potentially better, way of controlling the precision, see @ref{Floating-point precision}. @cindex -fforce-mem option @cindex options, -fforce-mem @item -fforce-mem @cindex -fforce-addr option @cindex options, -fforce-addr @item -fforce-addr @cindex loops, speeding up @cindex speed, of loops Might improve optimization of loops. @cindex -fno-inline option @cindex options, -fno-inline @item -fno-inline @cindex in-line code @cindex compilation, in-line @c DL: Only relevant for -O3? TM: No, statement functions are @c inlined even at -O1. Don't compile statement functions inline. Might reduce the size of a program unit---which might be at expense of some speed (though it should compile faster). Note that if you are not optimizing, no functions can be expanded inline. @cindex -ffast-math option @cindex options, -ffast-math @item -ffast-math @cindex IEEE 754 conformance @cindex conformance, IEEE 754 Might allow some programs designed to not be too dependent on IEEE behavior for floating-point to run faster, or die trying. Sets @option{-funsafe-math-optimizations}, @option{-ffinite-math-only}, and @option{-fno-trapping-math}. @cindex -funsafe-math-optimizations option @cindex options, -funsafe-math-optimizations @item -funsafe-math-optimizations Allow optimizations that may be give incorrect results for certain IEEE inputs. @cindex -ffinite-math-only option @cindex options, -ffinite-math-only @item -ffinite-math-only Allow optimizations for floating-point arithmetic that assume that arguments and results are not NaNs or +-Infs. This option should never be turned on by any @option{-O} option since it can result in incorrect output for programs which depend on an exact implementation of IEEE or ISO rules/specifications. The default is @option{-fno-finite-math-only}. @cindex -fno-trapping-math option @cindex options, -fno-trapping-math @item -fno-trapping-math Allow the compiler to assume that floating-point arithmetic will not generate traps on any inputs. This is useful, for example, when running a program using IEEE "non-stop" floating-point arithmetic. @cindex -fstrength-reduce option @cindex options, -fstrength-reduce @item -fstrength-reduce @cindex loops, speeding up @cindex speed, of loops @c DL: normally defaulted? Might make some loops run faster. @cindex -frerun-cse-after-loop option @cindex options, -frerun-cse-after-loop @item -frerun-cse-after-loop @cindex -fexpensive-optimizations option @cindex options, -fexpensive-optimizations @c DL: This is -O2? @item -fexpensive-optimizations @cindex -fdelayed-branch option @cindex options, -fdelayed-branch @item -fdelayed-branch @cindex -fschedule-insns option @cindex options, -fschedule-insns @item -fschedule-insns @cindex -fschedule-insns2 option @cindex options, -fschedule-insns2 @item -fschedule-insns2 @cindex -fcaller-saves option @cindex options, -fcaller-saves @item -fcaller-saves Might improve performance on some code. @cindex -funroll-loops option @cindex options, -funroll-loops @item -funroll-loops @cindex loops, unrolling @cindex unrolling loops @cindex loops, optimizing @cindex indexed (iterative) @code{DO} @cindex iterative @code{DO} @c DL: fixme: Craig doesn't like `indexed' but f95 doesn't seem to @c provide a suitable term @c CB: I've decided on `iterative', for the time being, and changed @c my previous, rather bizarre, use of `imperative' to that @c (though `precomputed-trip' would be a more precise adjective) Typically improves performance on code using iterative @code{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. @c DL: Fixme: This should obviously go somewhere else... Also, no `loop discovery'@footnote{@dfn{loop discovery} refers to the process by which a compiler, or indeed any reader of a program, determines which portions of the program are more likely to be executed repeatedly as it is being run. Such discovery typically is done early when compiling using optimization techniques, so the ``discovered'' loops get more attention---and more run-time resources, such as registers---from the compiler. It is easy to ``discover'' loops that are constructed out of looping constructs in the language (such as Fortran's @code{DO}). For some programs, ``discovering'' loops constructed out of lower-level constructs (such as @code{IF} and @code{GOTO}) can lead to generation of more optimal code than otherwise.} is done, so only loops written with @code{DO} benefit from loop optimizations, including---but not limited to---unrolling. Loops written with @code{IF} and @code{GOTO} are not currently recognized as such. This option unrolls only iterative @code{DO} loops, not @code{DO WHILE} loops. @cindex -funroll-all-loops option @cindex options, -funroll-all-loops @cindex DO WHILE @item -funroll-all-loops @c DL: Check my understanding of -funroll-all-loops v. -funroll-loops is correct. Probably improves performance on code using @code{DO WHILE} loops by unrolling them in addition to iterative @code{DO} loops. In the absence of @code{DO WHILE}, this option is equivalent to @option{-funroll-loops} but possibly slower. @item -fno-move-all-movables @cindex -fno-move-all-movables option @cindex options, -fno-move-all-movables @item -fno-reduce-all-givs @cindex -fno-reduce-all-givs option @cindex options, -fno-reduce-all-givs @item -fno-rerun-loop-opt @cindex -fno-rerun-loop-opt option @cindex options, -fno-rerun-loop-opt In general, the optimizations enabled with these options will lead to faster code being generated by GNU Fortran; hence they are enabled by default when issuing the @command{g77} command. @option{-fmove-all-movables} and @option{-freduce-all-givs} will enable loop optimization to move all loop-invariant index computations in nested loops over multi-rank array dummy arguments out of these loops. @option{-frerun-loop-opt} will move offset calculations resulting from the fact that Fortran arrays by default have a lower bound of 1 out of the loops. These three options are intended to be removed someday, once loop optimization is sufficiently advanced to perform all those transformations without help from these options. @end table @xref{Optimize Options,,Options That Control Optimization, gcc,Using the GNU Compiler Collection (GCC)}, for more information on options to optimize the generated machine code. @node Preprocessor Options @section Options Controlling the Preprocessor @cindex preprocessor options @cindex options, preprocessor @cindex cpp program @cindex programs, cpp These options control the C preprocessor, which is run on each C source file before actual compilation. @xref{Preprocessor Options,,Options Controlling the Preprocessor, gcc,Using the GNU Compiler Collection (GCC)}, for information on C preprocessor options. @cindex INCLUDE directive @cindex directive, INCLUDE Some of these options also affect how @command{g77} processes the @code{INCLUDE} directive. Since this directive is processed even when preprocessing is not requested, it is not described in this section. @xref{Directory Options,,Options for Directory Search}, for information on how @command{g77} processes the @code{INCLUDE} directive. However, the @code{INCLUDE} directive does not apply preprocessing to the contents of the included file itself. Therefore, any file that contains preprocessor directives (such as @code{#include}, @code{#define}, and @code{#if}) must be included via the @code{#include} directive, not via the @code{INCLUDE} directive. Therefore, any file containing preprocessor directives, if included, is necessarily included by a file that itself contains preprocessor directives. @node Directory Options @section Options for Directory Search @cindex directory, options @cindex options, directory search @cindex search path These options affect how the @command{cpp} preprocessor searches for files specified via the @code{#include} directive. Therefore, when compiling Fortran programs, they are meaningful when the preprocessor is used. @cindex INCLUDE directive @cindex directive, INCLUDE Some of these options also affect how @command{g77} searches for files specified via the @code{INCLUDE} directive, although files included by that directive are not, themselves, preprocessed. These options are: @table @gcctabopt @cindex -I- option @cindex options, -I- @item -I- @cindex -Idir option @cindex options, -Idir @item -I@var{dir} @cindex directory, search paths for inclusion @cindex inclusion, directory search paths for @cindex search paths, for included files @cindex paths, search These affect interpretation of the @code{INCLUDE} directive (as well as of the @code{#include} directive of the @command{cpp} preprocessor). Note that @option{-I@var{dir}} must be specified @emph{without} any spaces between @option{-I} and the directory name---that is, @option{-Ifoo/bar} is valid, but @option{-I foo/bar} is rejected by the @command{g77} compiler (though the preprocessor supports the latter form). @c this is due to toplev.c's inflexible option processing Also note that the general behavior of @option{-I} and @code{INCLUDE} is pretty much the same as of @option{-I} with @code{#include} in the @command{cpp} preprocessor, with regard to looking for @file{header.gcc} files and other such things. @xref{Directory Options,,Options for Directory Search, gcc,Using the GNU Compiler Collection (GCC)}, for information on the @option{-I} option. @end table @node Code Gen Options @section Options for Code Generation Conventions @cindex code generation, conventions @cindex options, code generation @cindex run-time, options 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 @option{-ffoo} would be @option{-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 @option{no-} or adding it. @table @gcctabopt @cindex -fno-automatic option @cindex options, -fno-automatic @item -fno-automatic @cindex SAVE statement @cindex statements, SAVE Treat each program unit as if the @code{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 @option{-static}.) @cindex -finit-local-zero option @cindex options, -finit-local-zero @item -finit-local-zero @cindex DATA statement @cindex statements, DATA @cindex initialization, of local variables @cindex variables, initialization of @cindex uninitialized variables @cindex variables, uninitialized Specify that variables and arrays that are local to a program unit (not in a common block and not passed as an argument) are to be initialized to binary zeros. Since there is a run-time penalty for initialization of variables that are not given the @code{SAVE} attribute, it might be a good idea to also use @option{-fno-automatic} with @option{-finit-local-zero}. @cindex -fno-f2c option @cindex options, -fno-f2c @item -fno-f2c @cindex @command{f2c} compatibility @cindex compatibility, @command{f2c} Do not generate code designed to be compatible with code generated by @command{f2c} use the GNU calling conventions instead. The @command{f2c} calling conventions require functions that return type @code{REAL(KIND=1)} to actually return the C type @code{double}, and functions that return type @code{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---@code{REAL(KIND=1)} functions return the C type @code{float}, and @code{COMPLEX} functions return the GNU C type @code{complex} (or its @code{struct} equivalent). This does not affect the generation of code that interfaces with the @code{libg2c} library. However, because the @code{libg2c} library uses @command{f2c} calling conventions, @command{g77} rejects attempts to pass intrinsics implemented by routines in this library as actual arguments when @option{-fno-f2c} is used, to avoid bugs when they are actually called by code expecting the GNU calling conventions to work. For example, @samp{INTRINSIC ABS;CALL FOO(ABS)} is rejected when @option{-fno-f2c} is in force. (Future versions of the @command{g77} run-time library might offer routines that provide GNU-callable versions of the routines that implement the @command{f2c} intrinsics that may be passed as actual arguments, so that valid programs need not be rejected when @option{-fno-f2c} is used.) @strong{Caution:} If @option{-fno-f2c} is used when compiling any source file used in a program, it must be used when compiling @emph{all} Fortran source files used in that program. @c seems kinda dumb to tell people about an option they can't use -- jcb @c then again, we want users building future-compatible libraries with it. @cindex -ff2c-library option @cindex options, -ff2c-library @item -ff2c-library Specify that use of @code{libg2c} (or the original @code{libf2c}) is required. This is the default for the current version of @command{g77} Currently it is not valid to specify @option{-fno-f2c-library}. This option is provided so users can specify it in shell scripts that build programs and libraries that require the @code{libf2c} library, even when being compiled by future versions of @command{g77} that might otherwise default to generating code for an incompatible library. @cindex -fno-underscoring option @cindex options, -fno-underscoring @item -fno-underscoring @cindex underscore @cindex symbol names, underscores @cindex transforming symbol names @cindex symbol names, transforming Do not transform names of entities specified in the Fortran source file by appending underscores to them. With @option{-funderscoring} in effect, @command{g77} appends two underscores to names with underscores and one underscore to external names with no underscores. (@command{g77} also appends two underscores to internal names with underscores to avoid naming collisions with external names. The @option{-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 @command{f2c} which perform the same transformations. Use of @option{-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 @option{-funderscoring}, and assuming other defaults like @option{-fcase-lower} and that @samp{j()} and @samp{max_count()} are external functions while @samp{my_var} and @samp{lvar} are local variables, a statement like @smallexample I = J() + MAX_COUNT (MY_VAR, LVAR) @end smallexample @noindent is implemented as something akin to: @smallexample i = j_() + max_count__(&my_var__, &lvar); @end smallexample With @option{-fno-underscoring}, the same statement is implemented as: @smallexample i = j() + max_count(&my_var, &lvar); @end smallexample Use of @option{-fno-underscoring} allows direct specification of user-defined names while debugging and when interfacing @command{g77} code with other languages. Note that just because the names match does @emph{not} mean that the interface implemented by @command{g77} for an external name matches the interface implemented by some other language for that same name. That is, getting code produced by @command{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 @option{-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 @command{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. @cindex -fno-second-underscore option @cindex options, -fno-second-underscore @item -fno-second-underscore @cindex underscore @cindex symbol names, underscores @cindex transforming symbol names @cindex symbol names, transforming Do not append a second underscore to names of entities specified in the Fortran source file. This option has no effect if @option{-fno-underscoring} is in effect. Otherwise, with this option, an external name such as @samp{MAX_COUNT} is implemented as a reference to the link-time external symbol @samp{max_count_}, instead of @samp{max_count__}. @cindex -fno-ident option @cindex options, -fno-ident @item -fno-ident Ignore the @samp{#ident} directive. @cindex -fzeros option @cindex options, -fzeros @item -fzeros Treat initial values of zero as if they were any other value. As of version 0.5.18, @command{g77} normally treats @code{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 @option{-fzeros} to revert to the simpler, slower behavior that can catch multiple initializations by keeping track of all initializations, zero or otherwise. @emph{Caution:} Future versions of @command{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. @cindex -femulate-complex option @cindex options, -femulate-complex @item -femulate-complex Implement @code{COMPLEX} arithmetic via emulation, instead of using the facilities of the @command{gcc} back end that provide direct support of @code{complex} arithmetic. (@command{gcc} had some bugs in its back-end support for @code{complex} arithmetic, due primarily to the support not being completed as of version 2.8.1 and @code{egcs} 1.1.2.) Use @option{-femulate-complex} if you suspect code-generation bugs, or experience compiler crashes, that might result from @command{g77} using the @code{COMPLEX} support in the @command{gcc} back end. If using that option fixes the bugs or crashes you are seeing, that indicates a likely @command{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 @command{g77} works in terms of its interfaces to other code, e.g. that compiled by @command{f2c} As of GCC version 3.0, this option is not necessary anymore. @emph{Caution:} Future versions of @command{g77} might ignore both forms of this option. @cindex -falias-check option @cindex options, -falias-check @cindex -fargument-alias option @cindex options, -fargument-alias @cindex -fargument-noalias option @cindex options, -fargument-noalias @cindex -fno-argument-noalias-global option @cindex options, -fno-argument-noalias-global @item -falias-check @item -fargument-alias @item -fargument-noalias @item -fno-argument-noalias-global @emph{Version info:} These options are not supported by versions of @command{g77} based on @command{gcc} version 2.8. These options specify to what degree aliasing (overlap) is permitted between arguments (passed as pointers) and @code{COMMON} (external, or public) storage. The default for Fortran code, as mandated by the FORTRAN 77 and Fortran 90 standards, is @option{-fargument-noalias-global}. The default for code written in the C language family is @option{-fargument-alias}. Note that, on some systems, compiling with @option{-fforce-addr} in effect can produce more optimal code when the default aliasing options are in effect (and when optimization is enabled). @xref{Aliasing Assumed To Work}, for detailed information on the implications of compiling Fortran code that depends on the ability to alias dummy arguments. @cindex -fno-globals option @cindex options, -fno-globals @item -fno-globals @cindex global names, warning @cindex warnings, global names @cindex in-line code @cindex compilation, in-line Disable diagnostics about inter-procedural analysis problems, such as disagreements about the type of a function or a procedure's argument, that might cause a compiler crash when attempting to inline a reference to a procedure within a program unit. (The diagnostics themselves are still produced, but as warnings, unless @option{-Wno-globals} is specified, in which case no relevant diagnostics are produced.) Further, this option disables such inlining, to avoid compiler crashes resulting from incorrect code that would otherwise be diagnosed. As such, this option might be quite useful when compiling existing, ``working'' code that happens to have a few bugs that do not generally show themselves, but which @command{g77} diagnoses. Use of this option therefore has the effect of instructing @command{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, @command{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. @cindex -fflatten-arrays option @item -fflatten-arrays @cindex array performance @cindex arrays, flattening Use back end's C-like constructs (pointer plus offset) instead of its @code{ARRAY_REF} construct to handle all array references. @emph{Note:} This option is not supported. It is intended for use only by @command{g77} developers, to evaluate code-generation issues. It might be removed at any time. @cindex -fbounds-check option @cindex -ffortran-bounds-check option @item -fbounds-check @itemx -ffortran-bounds-check @cindex bounds checking @cindex range checking @cindex array bounds checking @cindex subscript checking @cindex substring checking @cindex checking subscripts @cindex checking substrings Enable generation of run-time checks for array subscripts and substring start and end points against the (locally) declared minimum and maximum values. The current implementation uses the @code{libf2c} library routine @code{s_rnge} to print the diagnostic. However, whereas @command{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), @command{g77} generates a single check per @emph{subscript} expression. This catches some cases of potential bugs that @command{f2c} does not, such as references to below the beginning of an assumed-size array. @command{g77} also generates checks for @code{CHARACTER} substring references, something @command{f2c} currently does not do. Use the new @option{-ffortran-bounds-check} option to specify bounds-checking for only the Fortran code you are compiling, not necessarily for code written in other languages. @emph{Note:} To provide more detailed information on the offending subscript, @command{g77} provides the @code{libg2c} run-time library routine @code{s_rnge} with somewhat differently-formatted information. Here's a sample diagnostic: @smallexample 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]. Aborted @end smallexample The above message indicates that the offending source line is line 4 of the file @file{rnge.f}, within the program unit (or statement function) named @samp{bf}. The offended array is named @samp{b}. The offended array dimension is the second for a two-dimensional array, and the offending, computed subscript expression was @samp{-6}. For a @code{CHARACTER} substring reference, the second line has this appearance: @smallexample Attempt to access the 11-th element of variable a[start-substring]. @end smallexample This indicates that the offended @code{CHARACTER} variable or array is named @samp{a}, the offended substring position is the starting (leftmost) position, and the offending substring expression is @samp{11}. (Though the verbage of @code{s_rnge} is not ideal for the purpose of the @command{g77} compiler, the above information should provide adequate diagnostic abilities to it users.) @end table @xref{Code Gen Options,,Options for Code Generation Conventions, gcc,Using the GNU Compiler Collection (GCC)}, for information on more options offered by the GBE shared by @command{g77} @command{gcc} and other GNU compilers. Some of these do @emph{not} work when compiling programs written in Fortran: @table @gcctabopt @cindex -fpcc-struct-return option @cindex options, -fpcc-struct-return @item -fpcc-struct-return @cindex -freg-struct-return option @cindex options, -freg-struct-return @item -freg-struct-return You should not use these except strictly the same way as you used them to build the version of @code{libg2c} with which you will be linking all code compiled by @command{g77} with the same option. @cindex -fshort-double option @cindex options, -fshort-double @item -fshort-double This probably either has no effect on Fortran programs, or makes them act loopy. @cindex -fno-common option @cindex options, -fno-common @item -fno-common Do not use this when compiling Fortran programs, or there will be Trouble. @cindex -fpack-struct option @cindex options, -fpack-struct @item -fpack-struct This probably will break any calls to the @code{libg2c} library, at the very least, even if it is built with the same option. @end table @c man end @node Environment Variables @section Environment Variables Affecting GNU Fortran @cindex environment variables @c man begin ENVIRONMENT GNU Fortran currently does not make use of any environment variables to control its operation above and beyond those that affect the operation of @command{gcc}. @xref{Environment Variables,,Environment Variables Affecting GCC, gcc,Using the GNU Compiler Collection (GCC)}, for information on environment variables. @c man end