gfortran-4.2

NAME

gfortran - GNU Fortran compiler

SYNOPSIS

gfortran [-c|-S|-E] [-g] [-pg] [-Olevel] [-Wwarn...] [-pedantic] [-Idir...] [-Ldir...] [-Dmacro[=defn]...] [-Umacro] [-foption...] [-mmachine-option...] [-o outfile] infile...
Only the most useful options are listed here; see below for the remainder.

DESCRIPTION

The gfortran command supports all the options supported by the gcc command. Only options specific to \s-1GNU\s0 Fortran are documented here.
All \s-1GCC\s0 and \s-1GNU\s0 Fortran options are accepted both by gfortran and by gcc (as well as any other drivers built at the same time, such as g++), since adding \s-1GNU\s0 Fortran to the \s-1GCC\s0 distribution enables acceptance of \s-1GNU\s0 Fortran options by all of the relevant drivers.
In some cases, options have positive and negative forms; the negative form of -ffoo would be -fno-foo. This manual documents only one of these two forms, whichever one is not the default.

OPTIONS

Here is a summary of all the options specific to \s-1GNU\s0 Fortran, grouped by type. Explanations are in the following sections.
"Fortran -fall-intrinsics -ffree-form -fno-fixed-form -fdollar-ok -fimplicit-none -fmax-identifier-length -std=std -fd-lines-as-code -fd-lines-as-comments -ffixed-line-length-n -ffixed-line-length-none -ffree-line-length-n -ffree-line-length-none -fdefault-double-8 -fdefault-integer-8 -fdefault-real-8 -fcray-pointer -fopenmp -frange-check -fno-backslash
"Error -fmax-errors=n -fsyntax-only -pedantic -pedantic-errors -Wall -Waliasing -Wampersand -Wcharacter-truncation -Wconversion -Wimplicit-interface -Wline-truncation -Wnonstd-intrinsics -Wsurprising -Wno-tabs -Wunderflow
"Debugging -fdump-parse-tree -ffpe-trap=list
"Directory -Idir -Jdir -Mdir
"Runtime -fconvert=conversion -frecord-marker=length -fmax-subrecord-length=length
"Code -fno-automatic -ff2c -fno-underscoring -fsecond-underscore -fbounds-check -fmax-stack-var-size=n -fpack-derived -frepack-arrays -fshort-enums

Options controlling Fortran dialect

The following options control the details of the Fortran dialect accepted by the compiler:
"-ffree-form"
"-ffixed-form"
Specify the layout used by the source file. The free form layout was introduced in Fortran 90. Fixed form was traditionally used in older Fortran programs. When neither option is specified, the source form is determined by the file extension.
"-fall-intrinsics" Accept all of the intrinsic procedures provided in libgfortran without regard to the setting of -std. In particular, this option can be quite useful with -std=f95. Additionally, gfortran will ignore -Wnonstd-intrinsics.
"-fd-lines-as-code"
"-fd-lines-as-comments"
Enable special treatment for lines beginning with CWd or CWD in fixed form sources. If the -fd-lines-as-code option is given they are treated as if the first column contained a blank. If the -fd-lines-as-comments option is given, they are treated as comment lines.
"-fdefault-double-8" Set the CWDOUBLE PRECISION type to an 8 byte wide type.
"-fdefault-integer-8" Set the default integer and logical types to an 8 byte wide type. Do nothing if this is already the default.
"-fdefault-real-8" Set the default real type to an 8 byte wide type. Do nothing if this is already the default.
"-fdollar-ok" Allow $ as a valid character in a symbol name.
"-fno-backslash" Change the interpretation of backslashes in string literals from “C-style” escape characters to a single backslash character.
"-ffixed-line-length-n" 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. Popular values for n include 72 (the standard and the default), 80 (card image), and 132 (corresponding to “extended-source” options in some popular compilers). n may also be 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. -ffixed-line-length-0 means the same thing as -ffixed-line-length-none.
"-ffree-line-length-n" Set column after which characters are ignored in typical free-form lines in the source file. The default value is 132. n may be none, meaning that the entire line is meaningful. -ffree-line-length-0 means the same thing as -ffree-line-length-none.
"-fmax-identifier-length=n" Specify the maximum allowed identifier length. Typical values are 31 (Fortran 95) and 63 (Fortran 2003).
"-fimplicit-none" Specify that no implicit typing is allowed, unless overridden by explicit CWIMPLICIT statements. This is the equivalent of adding CWimplicit none to the start of every procedure.
"-fcray-pointer" Enable the Cray pointer extension, which provides C-like pointer functionality.
"-fopenmp" Enable the OpenMP extensions. This includes OpenMP CW!$omp directives in free form and CWc$omp, CW*$omp and CW!$omp directives in fixed form, CW!$ conditional compilation sentinels in free form and CWc$, CW*$ and CW!$ sentinels in fixed form, and when linking arranges for the OpenMP runtime library to be linked in.
"-frange-check" Enable range checking on results of simplification of constant expressions during compilation. For example, by default, \s-1GNU\s0 Fortran will give an overflow error at compile time when simplifying CWa = EXP(1000). With -fno-range-check, no error will be given and the variable CWa will be assigned the value CW+Infinity. Similarly, CWDATA i/Z'FFFFFFFF'/ will result in an integer overflow on most systems, but with -fno-range-check the value will “wrap around” and CWi will be initialized to -1 instead.
"-std=std" Specify the standard to which the program is expected to conform, which may be one of f95, f2003, gnu, or legacy. The default value for std is gnu, which specifies a superset of the Fortran 95 standard that includes all of the extensions supported by \s-1GNU\s0 Fortran, although warnings will be given for obsolete extensions not recommended for use in new code. The legacy value is equivalent but without the warnings for obsolete extensions, and may be useful for old non-standard programs. The f95 and f2003 values specify strict conformance to the Fortran 95 and Fortran 2003 standards, respectively; errors are given for all extensions beyond the relevant language standard, and warnings are given for the Fortran 77 features that are permitted but obsolescent in later standards.

Options to request or suppress errors and warnings

Errors are diagnostic messages that report that the \s-1GNU\s0 Fortran compiler cannot compile the relevant piece of source code. The compiler will continue to process the program in an attempt to report further errors to aid in debugging, but will not produce any compiled output.
Warnings are diagnostic messages that report constructions which are not inherently erroneous but which are risky or suggest there is likely to be a bug in the program. Unless -Werror is specified, they do not prevent compilation of the program.
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 errors and warnings produced by \s-1GNU\s0 Fortran:
"-fmax-errors-n" Limits the maximum number of error messages to n, at which point \s-1GNU\s0 Fortran bails out rather than attempting to continue processing the source code. If n is 0, there is no limit on the number of error messages produced.
"-fsyntax-only" Check the code for syntax errors, but don't do anything beyond that.
"-pedantic" Issue warnings for uses of extensions to Fortran 95. -pedantic also applies to C-language constructs where they occur in \s-1GNU\s0 Fortran source files, such as use of \e in a character constant within a directive like CW#include. Valid Fortran 95 programs should compile properly with or without this option. However, without this option, certain \s-1GNU\s0 extensions and traditional Fortran features are supported as well. With this option, many of them are rejected. Some users try to use -pedantic to check programs for conformance. They soon find that it does not do quite what they want---it finds some nonstandard practices, but not all. However, improvements to \s-1GNU\s0 Fortran in this area are welcome. This should be used in conjunction with -std=f95 or -std=f2003.
"-pedantic-errors" Like -pedantic, except that errors are produced rather than warnings.
"-Wall" Enables commonly used warning options pertaining to usage that we recommend avoiding and that we believe are easy to avoid. This currently includes -Waliasing, -Wampersand, -Wsurprising, -Wnonstd-intrinsics, -Wno-tabs, and -Wline-truncation.
"-Waliasing" Warn about possible aliasing of dummy arguments. Specifically, it warns if the same actual argument is associated with a dummy argument with CWINTENT(IN) and a dummy argument with CWINTENT(OUT) in a call with an explicit interface. The following example will trigger the warning. interface subroutine bar(a,b) integer, intent(in) :: a integer, intent(out) :: b end subroutine end interface integer :: a call bar(a,a)
"-Wampersand" Warn about missing ampersand in continued character constants. The warning is given with -Wampersand, -pedantic, -std=f95, and -std=f2003. Note: With no ampersand given in a continued character constant, \s-1GNU\s0 Fortran assumes continuation at the first non-comment, non-whitespace character after the ampersand that initiated the continuation.
"-Wcharacter-truncation" Warn when a character assignment will truncate the assigned string.
"-Wconversion" Warn about implicit conversions between different types.
"-Wimplicit-interface" Warn if a procedure is called without an explicit interface. Note this only checks that an explicit interface is present. It does not check that the declared interfaces are consistent across program units.
"-Wnonstd-intrinsics" Warn if the user tries to use an intrinsic that does not belong to the standard the user has chosen via the -std option.
"-Wsurprising" Produce a warning when “suspicious” code constructs are encountered. While technically legal these usually indicate that an error has been made. This currently produces a warning under the following circumstances:
"*" An \s-1INTEGER\s0 \s-1SELECT\s0 construct has a \s-1CASE\s0 that can never be matched as its lower value is greater than its upper value.
"*" A \s-1LOGICAL\s0 \s-1SELECT\s0 construct has three \s-1CASE\s0 statements.
"-Wtabs" By default, tabs are accepted as whitespace, but tabs are not members of the Fortran Character Set. -Wno-tabs will cause a warning to be issued if a tab is encountered. Note, -Wno-tabs is active for -pedantic, -std=f95, -std=f2003, and -Wall.
"-Wunderflow" Produce a warning when numerical constant expressions are encountered, which yield an \s-1UNDERFLOW\s0 during compilation.
"-Werror" Turns all warnings into errors.
Some of these have no effect when compiling programs written in Fortran.

Options for debugging your program or \s-1GNU\s0 Fortran

\s-1GNU\s0 Fortran has various special options that are used for debugging either your program or the \s-1GNU\s0 Fortran compiler.
"-fdump-parse-tree" Output the internal parse tree before starting code generation. Only really useful for debugging the \s-1GNU\s0 Fortran compiler itself.
"-ffpe-trap=list" Specify a list of \s-1IEEE\s0 exceptions when a Floating Point Exception (\s-1FPE\s0) should be raised. On most systems, this will result in a \s-1SIGFPE\s0 signal being sent and the program being interrupted, producing a core file useful for debugging. list is a (possibly empty) comma-separated list of the following \s-1IEEE\s0 exceptions: invalid (invalid floating point operation, such as CWSQRT(-1.0)), zero (division by zero), overflow (overflow in a floating point operation), underflow (underflow in a floating point operation), precision (loss of precision during operation) and denormal (operation produced a denormal value).

Options for directory search

These options affect how \s-1GNU\s0 Fortran searches for files specified by the CWINCLUDE directive and where it searches for previously compiled modules.
It also affects the search paths used by cpp when used to preprocess Fortran source.
"-Idir" These affect interpretation of the CWINCLUDE directive (as well as of the CW#include directive of the cpp preprocessor). Also note that the general behavior of -I and CWINCLUDE is pretty much the same as of -I with CW#include in the cpp preprocessor, with regard to looking for header.gcc files and other such things. This path is also used to search for .mod files when previously compiled modules are required by a CWUSE statement.
"-Mdir"
"-Jdir"
This option specifies where to put .mod files for compiled modules. It is also added to the list of directories to searched by an CWUSE statement. The default is the current directory. -J is an alias for -M to avoid conflicts with existing \s-1GCC\s0 options.

Influencing runtime behavior

These options affect the runtime behavior of programs compiled with \s-1GNU\s0 Fortran.
"-fconvert=conversion" Specify the representation of data for unformatted files. Valid values for conversion are: native, the default; swap, swap between big- and little-endian; big-endian, use big-endian representation for unformatted files; little-endian, use little-endian representation for unformatted files. This option has an effect only when used in the main program. The CICONVERT specifier and the \s-1GFORTRAN_CONVERT_UNIT\s0 environment variable override the default specified by BI-fconvert.
"-frecord-marker=length" Specify the length of record markers for unformatted files. Valid values for length are 4 and 8. Default is 4. This is different from previous versions of gfortran, which specified a default record marker length of 8 on most systems. If you want to read or write files compatible with earlier versions of gfortran, use -frecord-marker=8.
"-fmax-subrecord-length=length" Specify the maximum length for a subrecord. The maximum permitted value for length is 2147483639, which is also the default. Only really useful for use by the gfortran testsuite.

Options for code generation conventions

These machine-independent options control the interface conventions used in code generation.
Most of them have both positive and negative forms; the negative form of -ffoo would be -fno-foo. In the table below, only one of the forms is listed---the one which is not the default. You can figure out the other form by either removing no- or adding it.
"-fno-automatic" Treat each program unit as if the CWSAVE statement was specified for every local variable and array referenced in it. Does not affect common blocks. (Some Fortran compilers provide this option under the name -static.)
"-ff2c" Generate code designed to be compatible with code generated by g77 and f2c. The calling conventions used by g77 (originally implemented in f2c) require functions that return type default CWREAL to actually return the C type CWdouble, and functions that return type CWCOMPLEX to return the values via an extra argument in the calling sequence that points to where to store the return value. Under the default \s-1GNU\s0 calling conventions, such functions simply return their results as they would in \s-1GNU\s0 C---default CWREAL functions return the C type CWfloat, and CWCOMPLEX functions return the \s-1GNU\s0 C type CWcomplex. Additionally, this option implies the -fsecond-underscore option, unless -fno-second-underscore is explicitly requested. This does not affect the generation of code that interfaces with the libgfortran library. Caution: It is not a good idea to mix Fortran code compiled with -ff2c with code compiled with the default -fno-f2c calling conventions as, calling CWCOMPLEX or default CWREAL functions between program parts which were compiled with different calling conventions will break at execution time. Caution: This will break code which passes intrinsic functions of type default CWREAL or CWCOMPLEX as actual arguments, as the library implementations use the -fno-f2c calling conventions.
"-fno-underscoring" Do not transform names of entities specified in the Fortran source file by appending underscores to them. With -funderscoring in effect, \s-1GNU\s0 Fortran appends one underscore to external names with no underscores. This is done to ensure compatibility with code produced by many \s-1UNIX\s0 Fortran compilers. Caution: The default behavior of \s-1GNU\s0 Fortran is incompatible with f2c and g77, please use the -ff2c option if you want object files compiled with \s-1GNU\s0 Fortran to be compatible with object code created with these tools. Use of -fno-underscoring is not recommended unless you are experimenting with issues such as integration of \s-1GNU\s0 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 CWj() and CWmax_count() are external functions while CWmy_var and CWlvar 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 \s-1GNU\s0 Fortran code with other languages. Note that just because the names match does not mean that the interface implemented by \s-1GNU\s0 Fortran for an external name matches the interface implemented by some other language for that same name. That is, getting code produced by \s-1GNU\s0 Fortran to link to code produced by some other compiler using this or any other method can be only a small part of the overall solution---getting the code generated by both compilers to agree on issues other than naming can require significant effort, and, unlike naming disagreements, linkers normally cannot detect disagreements in these other areas. Also, note that with -fno-underscoring, the lack of appended underscores introduces the very real possibility that a user-defined external name will conflict with a name in a system library, which could make finding unresolved-reference bugs quite difficult in some cases---they might occur at program run time, and show up only as buggy behavior at run time. In future versions of \s-1GNU\s0 Fortran 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.
"-fsecond-underscore" By default, \s-1GNU\s0 Fortran appends an underscore to external names. If this option is used \s-1GNU\s0 Fortran appends two underscores to names with underscores and one underscore to external names with no underscores. \s-1GNU\s0 Fortran also appends two underscores to internal names with underscores to avoid naming collisions with external names. This option has no effect if -fno-underscoring is in effect. It is implied by the -ff2c option. Otherwise, with this option, an external name such as CWMAX_COUNT is implemented as a reference to the link-time external symbol CWmax_count__, instead of CWmax_count_. This is required for compatibility with g77 and f2c, and is implied by use of the -ff2c option.
"-fbounds-check" Enable generation of run-time checks for array subscripts and against the declared minimum and maximum values. It also checks array indices for assumed and deferred shape arrays against the actual allocated bounds. In the future this may also include other forms of checking, e.g., checking substring references.
"-fmax-stack-var-size=n" This option specifies the size in bytes of the largest array that will be put on the stack. This option currently only affects local arrays declared with constant bounds, and may not apply to all character variables. Future versions of \s-1GNU\s0 Fortran may improve this behavior. The default value for n is 32768.
"-fpack-derived" This option tells \s-1GNU\s0 Fortran to pack derived type members as closely as possible. Code compiled with this option is likely to be incompatible with code compiled without this option, and may execute slower.
"-frepack-arrays" In some circumstances \s-1GNU\s0 Fortran may pass assumed shape array sections via a descriptor describing a noncontiguous area of memory. This option adds code to the function prologue to repack the data into a contiguous block at runtime. This should result in faster accesses to the array. However it can introduce significant overhead to the function call, especially when the passed data is noncontiguous.
"-fshort-enums" This option is provided for interoperability with C code that was compiled with the -fshort-enums option. It will make \s-1GNU\s0 Fortran choose the smallest CWINTEGER kind a given enumerator set will fit in, and give all its enumerators this kind.

ENVIRONMENT

The gfortran compiler currently does not make use of any environment variables to control its operation above and beyond those that affect the operation of gcc.

BUGS

For instructions on reporting bugs, see <http://gcc.gnu.org/bugs.html>.

SEE ALSO

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 gcc, cpp, gfortran, as, ld, binutils and gdb.

AUTHOR

See the Info entry for gfortran for contributors to \s-1GCC\s0 and \s-1GNU\s0 Fortran.

COPYRIGHT

Copyright (c) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being “\s-1GNU\s0 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 \s-1FSF\s0's Front-Cover Text is:
A GNU Manual
(b) The \s-1FSF\s0'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.