@c Copyright (C) 2004-2026 Free Software Foundation, Inc.
@c This is part of the GNU Fortran manual.
@c For copying conditions, see the file gfortran.texi.

@ignore
@c man begin COPYRIGHT
Copyright @copyright{} 2004-2026 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.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``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 gfortran
@settitle GNU Fortran compiler.
@c man begin SYNOPSIS
gfortran [@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), dbx(1)
and the Info entries for @file{gcc}, @file{cpp}, @file{gfortran}, @file{as},
@file{ld}, @file{binutils} and @file{gdb}.
@c man end
@c man begin BUGS
For instructions on reporting bugs, see
@w{@value{BUGURL}}.
@c man end
@c man begin AUTHOR
See the Info entry for @command{gfortran} for contributors to GCC and
GNU Fortran.
@c man end
@end ignore

@node Invoking GNU Fortran
@chapter GNU Fortran Command Options
@cindex GNU Fortran command options
@cindex command options
@cindex options, @command{gfortran} command

@c man begin DESCRIPTION

The @command{gfortran} command supports all the options supported by the
@command{gcc} command.  Only options specific to GNU Fortran are documented
here.

@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{gfortran} command).

@cindex options, negative forms
All GCC and GNU Fortran options
are accepted both by @command{gfortran} and by @command{gcc}
(as well as any other drivers built at the same time,
such as @command{g++}),
since adding GNU Fortran to the GCC distribution
enables acceptance of GNU Fortran 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{gfortran} options,
                        without explanations.
* Fortran Dialect Options::  Controlling the variant of Fortran language
                             compiled.
* Preprocessing Options::  Enable and customize preprocessing.
* Error and Warning Options::     How picky should the compiler be?
* Debugging Options::   Symbol tables, measurements.
* Directory Options::   Where to find module files
* Link Options ::       Influencing the linking step
* Runtime Options::     Influencing runtime behavior
* Developer Options::   Printing GNU Fortran specific info, debugging dumps.
* Code Gen Options::    Specifying conventions for function calls, data layout
                        and register usage.
* Interoperability Options::  Options for interoperability with other
                              languages.
* Environment Variables:: Environment variables that affect @command{gfortran}.
* Shared-memory Coarrays:: Multiprocess shared-memory coarray support.
@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 Fortran Language Options
@xref{Fortran Dialect Options,,Options controlling Fortran dialect}.
@gccoptlist{-fall-intrinsics -fallow-argument-mismatch -fallow-invalid-boz
-fbackslash -fcray-pointer -fd-lines-as-code -fd-lines-as-comments
-fdec -fdec-char-conversions -fdec-structure -fdec-intrinsic-ints
-fdec-static -fdec-math -fdec-include -fdec-format-defaults
-fdec-blank-format-item -fdefault-double-8 -fdefault-integer-8
-fdefault-real-8 -fdefault-real-10 -fdefault-real-16 -fdollar-ok
-ffixed-line-length-@var{n} -ffixed-line-length-none -fpad-source
-ffree-form -ffree-line-length-@var{n} -ffree-line-length-none
-fimplicit-none -finteger-4-integer-8 -fmax-identifier-length
-fmodule-private -ffixed-form -fno-range-check -fopenacc -fopenmp
-fopenmp-allocators -fopenmp-simd -freal-4-real-10 -freal-4-real-16
-freal-4-real-8 -freal-8-real-10 -freal-8-real-16 -freal-8-real-4
-std=@var{std} -ftest-forall-temp -funsigned
}

@item Preprocessing Options
@xref{Preprocessing Options,,Enable and customize preprocessing}.
@gccoptlist{-A-@var{question}@r{[}=@var{answer}@r{]}
-A@var{question}=@var{answer} -C -CC -D@var{macro}@r{[}=@var{defn}@r{]}
-H -P
-U@var{macro} -cpp -dD -dI -dM -dN -dU -fworking-directory
-imultilib @var{dir}
-iprefix @var{file} -iquote -isysroot @var{dir} -isystem @var{dir} -nocpp
-nostdinc
-undef
}

@item Error and Warning Options
@xref{Error and Warning Options,,Options to request or suppress errors
and warnings}.
@gccoptlist{-Waliasing -Wall -Wampersand -Warray-bounds
-Wc-binding-type -Wcharacter-truncation -Wconversion
-Wno-deprecated-openmp -Wdo-subscript -Wfunction-elimination
-Wimplicit-interface -Wimplicit-procedure -Wintrinsic-shadow
-Wuse-without-only -Wintrinsics-std -Wline-truncation -Wno-align-commons
-Wno-overwrite-recursive -Wno-tabs -Wreal-q-constant -Wsurprising
-Wunderflow -Wunused-parameter -Wrealloc-lhs -Wrealloc-lhs-all
-Wfrontend-loop-interchange -Wtarget-lifetime -fmax-errors=@var{n}
-fsyntax-only -pedantic
-pedantic-errors
}

@item Debugging Options
@xref{Debugging Options,,Options for debugging your program}.
@gccoptlist{-fbacktrace -fdebug-aux-vars -ffpe-trap=@var{list}
-ffpe-summary=@var{list}
}

@item Directory Options
@xref{Directory Options,,Options for directory search}.
@gccoptlist{-I@var{dir}  -J@var{dir} -fintrinsic-modules-path @var{dir}}

@item Link Options
@xref{Link Options,,Options for influencing the linking step}.
@gccoptlist{-static-libgfortran  -static-libquadmath}

@item Runtime Options
@xref{Runtime Options,,Options for influencing runtime behavior}.
@gccoptlist{-fconvert=@var{conversion} -fmax-subrecord-length=@var{length}
-frecord-marker=@var{length} -fsign-zero
}

@item Interoperability Options
@xref{Interoperability Options,,Options for interoperability}.
@gccoptlist{-fc-prototypes -fc-prototypes-external}

@item Code Generation Options
@xref{Code Gen Options,,Options for code generation conventions}.
@gccoptlist{-faggressive-function-elimination -fblas-matmul-limit=@var{n}
-fbounds-check -ftail-call-workaround -ftail-call-workaround=@var{n}
-fcheck-array-temporaries
-fcheck=<all|array-temps|bits|bounds|do|mem|pointer|recursion>
-fcoarray=<none|single|shared|lib> -fexternal-blas -fexternal-blas64 -ff2c
-ffrontend-loop-interchange -ffrontend-optimize
-finit-character=@var{n} -finit-integer=@var{n} -finit-local-zero
-finit-derived -finit-logical=<true|false>
-finit-real=<zero|inf|-inf|nan|snan>
-finline-intrinsics[=<@var{minloc},@var{maxloc}>]
-finline-matmul-limit=@var{n}
-finline-arg-packing -fmax-array-constructor=@var{n}
-fmax-stack-var-size=@var{n} -fno-align-commons -fno-automatic
-fno-protect-parens -fno-underscoring -fsecond-underscore
-fpack-derived -frealloc-lhs -frecursive -frepack-arrays
-fshort-enums -fstack-arrays
}

@item Developer Options
@xref{Developer Options,,GNU Fortran Developer Options}.
@gccoptlist{-fdump-fortran-global -fdump-fortran-optimized
-fdump-fortran-original -fdump-parse-tree -save-temps
}
@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 details of the Fortran dialect
accepted by the compiler:

@table @gcctabopt
@opindex ffree-form
@opindex ffixed-form
@cindex options, Fortran dialect
@cindex file format, free
@cindex file format, fixed
@item -ffree-form
@itemx -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.

@opindex fall-intrinsics
@item -fall-intrinsics
This option causes all intrinsic procedures (including the GNU-specific
extensions) to be accepted.  This can be useful with @option{-std=} to
force standard compliance but get access to the full range of intrinsics
available with @command{gfortran}.  As a consequence, @option{-Wintrinsics-std}
is ignored and no user-defined procedure with the same name as any
intrinsic is called except when it is explicitly declared @code{EXTERNAL}.

@opindex fallow-argument-mismatch
@cindex argument mismatch
@item -fallow-argument-mismatch
Some code contains calls to external procedures with mismatches
between the calls and the procedure definition, or with mismatches
between different calls. Such code is nonconforming, and is usually
flagged with an error.  This options degrades the error to a
warning that can only be disabled by disabling all warnings via
@option{-w}.  Only a single occurrence per argument is flagged by this
warning.  @option{-fallow-argument-mismatch} is implied by
@option{-std=legacy}.

Using this option is @emph{strongly} discouraged.  It is possible to
provide standard-conforming code that allows different types of
arguments by using an explicit interface and @code{TYPE(*)}.

@opindex allow-invalid-boz
@item -fallow-invalid-boz
A BOZ literal constant can occur in a limited number of contexts in
standard conforming Fortran.  This option degrades an error condition
to a warning, and allows a BOZ literal constant to appear where the
Fortran standard would otherwise prohibit its use.

@opindex fd-lines-as-code
@opindex fd-lines-as-comments
@item -fd-lines-as-code
@itemx -fd-lines-as-comments
Enable special treatment for lines beginning with @code{d} or @code{D}
in fixed form sources.  If the @option{-fd-lines-as-code} option is
given they are treated as if the first column contained a blank.  If the
@option{-fd-lines-as-comments} option is given, they are treated as
comment lines.

@opindex fdec
@item -fdec
DEC compatibility mode. Enables extensions and other features that mimic
the default behavior of older compilers (such as DEC).
These features are nonstandard and should be avoided at all costs.
For details on GNU Fortran's implementation of these extensions see the
full documentation.

Other flags enabled by this switch are:
@option{-fdollar-ok} @option{-fcray-pointer} @option{-fdec-char-conversions}
@option{-fdec-structure} @option{-fdec-intrinsic-ints} @option{-fdec-static}
@option{-fdec-math} @option{-fdec-include} @option{-fdec-blank-format-item}
@option{-fdec-format-defaults}

If @option{-fd-lines-as-code}/@option{-fd-lines-as-comments} are unset, then
@option{-fdec} also sets @option{-fd-lines-as-comments}.

@opindex fdec-char-conversions
@item -fdec-char-conversions
Enable the use of character literals in assignments and @code{DATA} statements
for non-character variables.

@opindex fdec-structure
@item -fdec-structure
Enable DEC @code{STRUCTURE} and @code{RECORD} as well as @code{UNION},
@code{MAP}, and dot ('.') as a member separator (in addition to '%'). This is
provided for compatibility only; Fortran 90 derived types should be used
instead where possible.

@opindex fdec-intrinsic-ints
@item -fdec-intrinsic-ints
Enable B/I/J/K kind variants of existing integer functions
(e.g. @code{BIAND}, @code{IIAND}, @code{JIAND}, etc...).
For a complete list of intrinsics see @ref{Intrinsic Procedures}.

@opindex fdec-math
@item -fdec-math
Obsolete flag.  The purpose of this option was to
enable legacy math intrinsics such as @code{COTAN} and degree-valued
trigonometric functions (e.g. @code{TAND}, @code{ATAND}, etc...)
for compatibility with older code. This
option is no longer operable. The trigonometric functions are now either
part of Fortran 2023 or GNU extensions.

@opindex fdec-static
@item -fdec-static
Enable DEC-style @code{STATIC} and @code{AUTOMATIC}
attributes to explicitly specify
the storage of variables and other objects.

@opindex fdec-include
@item -fdec-include
Enable parsing of @code{INCLUDE} as a statement in addition to parsing it as
@code{INCLUDE} line.
When parsed as @code{INCLUDE} statement, @code{INCLUDE} does not have to
be on a single line and can use line continuations.

@opindex fdec-format-defaults
@item -fdec-format-defaults
Enable format specifiers @samp{F}, @samp{G} and @samp{I}
to be used without width specifiers; default widths are used instead.

@opindex fdec-blank-format-item
@item -fdec-blank-format-item
Enable a blank format item at the end of a format specification i.e. nothing
following the final comma.

@opindex fdollar-ok
@cindex @code{$}
@cindex symbol names
@cindex character set
@item -fdollar-ok
Allow @samp{$} as a valid non-first character in a symbol name. Symbols
that start with @samp{$} are rejected since it is unclear which rules to
apply to implicit typing as different vendors implement different rules.
Using @samp{$} in @code{IMPLICIT} statements is also rejected.

@opindex backslash
@cindex backslash
@cindex escape characters
@item -fbackslash
Change the interpretation of backslashes in string literals from a single
backslash character to ``C-style'' escape characters. The following
combinations are expanded: @samp{\a}, @samp{\b}, @samp{\f}, @samp{\n},
@samp{\r}, @samp{\t}, @samp{\v}, @samp{\\}, and @samp{\0} to the ASCII
characters alert, backspace, form feed, newline, carriage return,
horizontal tab, vertical tab, backslash, and NUL, respectively.
Additionally, @samp{\x@var{nn}}, @samp{\u@var{nnnn}} and
@samp{\U@var{nnnnnnnn}} (where each @var{n} is a hexadecimal digit) are
translated into the Unicode characters corresponding to the specified code
points. All other combinations of a character preceded by @samp{\} are
unexpanded.

@opindex fmodule-private
@cindex module entities
@cindex private
@item -fmodule-private
Set the default accessibility of module entities to @code{PRIVATE}.
Use-associated entities are not accessible unless they are explicitly
declared as @code{PUBLIC}.

@opindex ffixed-line-length-@var{n}
@cindex file format, fixed
@item -ffixed-line-length-@var{n}
Set column after which characters are ignored in typical fixed-form
lines in the source file, and, unless @code{-fno-pad-source}, through which
spaces are assumed (as if padded to that length) after the ends of short
fixed-form lines.

Popular values for @var{n} include 72 (the
standard and the default), 80 (card image), and 132 (corresponding
to ``extended-source'' options in some popular compilers).
@var{n} may also 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}.

@opindex fpad-source
@item -fno-pad-source
By default fixed-form lines have spaces assumed (as if padded to that length)
after the ends of short fixed-form lines.  This is not done either if
@option{-ffixed-line-length-0}, @option{-ffixed-line-length-none} or
if @option{-fno-pad-source} option is used.  With any of those options
continued character constants never have implicit spaces appended
to them to fill out the line.

@opindex ffree-line-length-@var{n}
@cindex file format, free
@item -ffree-line-length-@var{n}
Set column after which characters are ignored in typical free-form
lines in the source file. The default value is 132.
@var{n} may be @samp{none}, meaning that the entire line is meaningful.
@option{-ffree-line-length-0} means the same thing as
@option{-ffree-line-length-none}.

@opindex fmax-identifier-length=@var{n}
@item -fmax-identifier-length=@var{n}
Specify the maximum allowed identifier length. Typical values are
31 (Fortran 95) and 63 (Fortran 2003 and later).

@opindex fimplicit-none
@item -fimplicit-none
Specify that no implicit typing is allowed, unless overridden by explicit
@code{IMPLICIT} statements.  This is the equivalent of adding
@code{implicit none} to the start of every procedure.

@opindex fcray-pointer
@item -fcray-pointer
Enable the Cray pointer extension, which provides C-like pointer
functionality.


@opindex fopenacc
@cindex OpenACC accelerator programming
@item -fopenacc
Enable handling of OpenACC directives @samp{!$acc} in free-form Fortran and
@samp{!$acc}, @samp{c$acc} and @samp{*$acc} in fixed-form Fortran.  When
@option{-fopenacc} is specified, the compiler generates accelerated code
according to the OpenACC Application Programming Interface v2.6
@w{@uref{https://www.openacc.org}}.  This option implies @option{-pthread},
and thus is only supported on targets that have support for @option{-pthread}.
The option @option{-fopenacc} implies @option{-frecursive}.

@opindex fopenmp
@cindex OpenMP parallel
@item -fopenmp
Enable handling of OpenMP directives @samp{!$omp} in Fortran.  It
additionally enables the conditional compilation sentinel @samp{!$} in
Fortran.  In fixed source form Fortran, the sentinels can also start with
@samp{c} or @samp{*}.  When @option{-fopenmp} is specified, the
compiler generates parallel code according to the OpenMP Application
Program Interface v4.5 @w{@uref{https://www.openmp.org}}.  This option
implies @option{-pthread}, and thus is only supported on targets that
have support for @option{-pthread}. @option{-fopenmp} implies
@option{-fopenmp-simd} and @option{-frecursive}.

@opindex fopenmp-allocators
@cindex OpenMP Allocators
@item -fopenmp-allocators
Enables handling of allocation, reallocation and deallocation of Fortran
allocatable and pointer variables that are allocated using the
@samp{!$omp allocators} and @samp{!$omp allocate} constructs.  Files
containing either directive have to be compiled with this option in addition
to @option{-fopenmp}.  Additionally, all files that might deallocate or
reallocate a variable that has been allocated with an OpenMP allocator
have to be compiled with this option.  This includes intrinsic assignment
to allocatable variables when reallocation may occur and deallocation
due to either of the following: end of scope, explicit deallocation,
@samp{intent(out)}, deallocation of allocatable components etc.
Files not changing the allocation status or only for components of
a derived type that have not been allocated using those two directives
do not need to be compiled with this option.  Nor do files that handle
such variables after they have been deallocated or allocated by the
normal Fortran allocator.

@opindex fopenmp-simd
@cindex OpenMP SIMD
@cindex SIMD
@item -fopenmp-simd
Enable handling of OpenMP's @code{simd}, @code{declare simd},
@code{declare reduction}, @code{assume}, @code{ordered}, @code{scan}
and @code{loop} directive, and of combined or composite directives with
@code{simd} as constituent with  @code{!$omp} in Fortran.  It additionally
enables the conditional compilation sentinel @samp{!$} in Fortran.  In
fixed source form Fortran, the sentinels can also start with @samp{c} or
@samp{*}.  Other OpenMP directives are ignored.  Unless @option{-fopenmp}
is additionally specified, the @code{loop} region binds to the current task
region, independent of the specified @code{bind} clause.


@opindex frange-check
@item -fno-range-check
Disable range checking on results of simplification of constant
expressions during compilation.  For example, GNU Fortran gives
an error at compile time when simplifying @code{a = 1. / 0}.
With this option, no error is given and @code{a} is assigned
the value @code{+Infinity}.  If an expression evaluates to a value
outside of the relevant range of [@code{-HUGE()}:@code{HUGE()}],
then the expression is replaced by @code{-Inf} or @code{+Inf}
as appropriate.
Similarly, @code{DATA i/Z'FFFFFFFF'/} results in an integer overflow
on most systems, but with @option{-fno-range-check} the value
``wraps around'' and @code{i} is initialized to @math{-1} instead.

@opindex fdefault-integer-8
@item -fdefault-integer-8
Set the default integer and logical types to an 8 byte wide type.  This option
also affects the kind of integer constants like @code{42}. Unlike
@option{-finteger-4-integer-8}, it does not promote variables with explicit
kind declaration.

@opindex fdefault-real-8
@item -fdefault-real-8
Set the default real type to an 8 byte wide type.  This option also affects
the kind of non-double real constants like @code{1.0}.  This option promotes
the default width of @code{DOUBLE PRECISION} and double real constants
like @code{1.d0} to 16 bytes if possible.  If @code{-fdefault-double-8}
is given along with @code{fdefault-real-8}, @code{DOUBLE PRECISION}
and double real constants are not promoted.  Unlike @option{-freal-4-real-8},
@code{fdefault-real-8} does not promote variables with explicit kind
declarations.

@opindex fdefault-real-10
@item -fdefault-real-10
Set the default real type to an 10 byte wide type.  This option also affects
the kind of non-double real constants like @code{1.0}.  This option promotes
the default width of @code{DOUBLE PRECISION} and double real constants
like @code{1.d0} to 16 bytes if possible.  If @code{-fdefault-double-8}
is given along with @code{fdefault-real-10}, @code{DOUBLE PRECISION}
and double real constants are not promoted.  Unlike @option{-freal-4-real-10},
@code{fdefault-real-10} does not promote variables with explicit kind
declarations.

@opindex fdefault-real-16
@item -fdefault-real-16
Set the default real type to an 16 byte wide type.  This option also affects
the kind of non-double real constants like @code{1.0}.  This option promotes
the default width of @code{DOUBLE PRECISION} and double real constants
like @code{1.d0} to 16 bytes if possible.  If @code{-fdefault-double-8}
is given along with @code{fdefault-real-16}, @code{DOUBLE PRECISION}
and double real constants are not promoted.  Unlike @option{-freal-4-real-16},
@code{fdefault-real-16} does not promote variables with explicit kind
declarations.

@opindex fdefault-double-8
@item -fdefault-double-8
Set the @code{DOUBLE PRECISION} type and double real constants
like @code{1.d0} to an 8 byte wide type.  Do nothing if this
is already the default.  This option prevents @option{-fdefault-real-8},
@option{-fdefault-real-10}, and @option{-fdefault-real-16},
from promoting @code{DOUBLE PRECISION} and double real constants like
@code{1.d0} to 16 bytes.

@opindex finteger-4-integer-8
@item -finteger-4-integer-8
Promote all @code{INTEGER(KIND=4)} entities to an @code{INTEGER(KIND=8)}
entities.  If @code{KIND=8} is unavailable, then an error is issued.
This option should be used with care and may not be suitable for your codes.
Areas of possible concern include calls to external procedures,
alignment in @code{EQUIVALENCE} and/or @code{COMMON}, generic interfaces,
BOZ literal constant conversion, and I/O.  Inspection of the intermediate
representation of the translated Fortran code, produced by
@option{-fdump-tree-original}, is suggested.

@opindex freal-4-real-8
@opindex freal-4-real-10
@opindex freal-4-real-16
@opindex freal-8-real-4
@opindex freal-8-real-10
@opindex freal-8-real-16
@cindex options, real kind type promotion
@item  -freal-4-real-8
@itemx -freal-4-real-10
@itemx -freal-4-real-16
@itemx -freal-8-real-4
@itemx -freal-8-real-10
@itemx -freal-8-real-16
Promote all @code{REAL(KIND=M)} entities to @code{REAL(KIND=N)} entities.
If @code{REAL(KIND=N)} is unavailable, then an error is issued.
The @code{-freal-4-} flags also affect the default real kind and the
@code{-freal-8-} flags also the double-precision real kind.  All other
real-kind types are unaffected by this option.  The promotion is also
applied to real literal constants of default and double-precision kind
and a specified kind number of 4 or 8, respectively.
However, @code{-fdefault-real-8}, @code{-fdefault-real-10},
@code{-fdefault-real-10}, and @code{-fdefault-double-8} take precedence
for the default and double-precision real kinds, both for real literal
constants and for declarations without a kind number.
Note that for @code{REAL(KIND=KIND(1.0))} the literal may get promoted and
then the result may get promoted again.
These options should be used with care and may not be suitable for your
codes.  Areas of possible concern include calls to external procedures,
alignment in @code{EQUIVALENCE} and/or @code{COMMON}, generic interfaces,
BOZ literal constant conversion, and I/O and calls to intrinsic procedures
when passing a value to the @code{kind=} dummy argument.  Inspection of the
intermediate representation of the translated Fortran code, produced by
@option{-fdump-fortran-original} or @option{-fdump-tree-original}, is suggested.
NOTE: These options are incompatible with user defined derived
type I/O (DTIO).

@opindex std=@var{std}
@item -std=@var{std}
Specify the standard to which the program is expected to conform,
which may be one of @samp{f95}, @samp{f2003}, @samp{f2008}, @samp{f2018},
@samp{f2023}, @samp{gnu}, or @samp{legacy}.  The default value for
@var{std} is @samp{gnu}, which specifies a superset of the latest
Fortran standard that includes all of the extensions supported by GNU
Fortran, although warnings are given for obsolete extensions not
recommended for use in new code.  The @samp{legacy} value is
equivalent but without the warnings for obsolete extensions, and may
be useful for old nonstandard programs.  The @samp{f95}, @samp{f2003},
@samp{f2008}, @samp{f2018}, and @samp{f2023} values specify strict
conformance to the Fortran 95, Fortran 2003, Fortran 2008, Fortran 2018
and Fortran 2023 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. The deprecated option @samp{-std=f2008ts} acts as an alias for
@samp{-std=f2018}. It is only present for backwards compatibility with
earlier gfortran versions and should not be used any more. @samp{-std=f202y}
acts as an alias for @samp{-std=f2023} and enables proposed features for
testing Fortran 202y. As the Fortran 202y standard develops, implementation
might change or the experimental new features might be removed.

@opindex ftest-forall-temp
@item -ftest-forall-temp
Enhance test coverage by forcing most forall assignments to use temporary.

@opindex funsigned
@item -funsigned
@anchor{-funsigned}
Allow the experimental unsigned extension.
@end table

@node Preprocessing Options
@section Enable and customize preprocessing
@cindex preprocessor
@cindex options, preprocessor
@cindex CPP
@cindex FPP
@cindex Conditional compilation
@cindex Preprocessing
@cindex preprocessor, include file handling

Many Fortran compilers including GNU Fortran allow passing the source code
through a C preprocessor (CPP; sometimes also called the Fortran preprocessor,
FPP) to allow for conditional compilation.  In the case of GNU Fortran,
this is the GNU C Preprocessor in the traditional mode.  On systems with
case-preserving file names, the preprocessor is automatically invoked if the
filename extension is @file{.F}, @file{.FOR}, @file{.FTN}, @file{.fpp},
@file{.FPP}, @file{.F90}, @file{.F95}, @file{.F03} or @file{.F08}.  To manually
invoke the preprocessor on any file, use @option{-cpp}, to disable
preprocessing on files where the preprocessor is run automatically, use
@option{-nocpp}.

When compiling a preprocessed file, use @option{-fpreprocessed}
(@pxref{Preprocessor Options,,Options Controlling the Preprocessor,gcc,
Using the GNU Compiler Collection (GCC)}).  This skips the C preprocessor.

If a preprocessed file includes another file with the Fortran @code{INCLUDE}
statement, the included file is not preprocessed.  To preprocess included
files, use the equivalent preprocessor statement @code{#include}.

If GNU Fortran invokes the preprocessor, @code{__GFORTRAN__}
is defined.  The macros @code{__GNUC__}, @code{__GNUC_MINOR__} and
@code{__GNUC_PATCHLEVEL__} can be used to determine the version of the
compiler.  See @ref{Top,,Overview,cpp,The C Preprocessor} for details.

GNU Fortran supports a number of @code{INTEGER} and @code{REAL} kind types
in additional to the kind types required by the Fortran standard.
The availability of any given kind type is architecture dependent.  The
following predefined preprocessor macros can be used to conditionally
include code for these additional kind types: @code{__GFC_INT_1__},
@code{__GFC_INT_2__}, @code{__GFC_INT_8__}, @code{__GFC_INT_16__},
@code{__GFC_REAL_10__}, and @code{__GFC_REAL_16__}.

While CPP is the de facto standard for preprocessing Fortran code,
Part 3 of the Fortran 95 standard (ISO/IEC 1539-3:1998) defines
Conditional Compilation, which is not widely used and not directly
supported by the GNU Fortran compiler.

The following options control preprocessing of Fortran code:

@table @gcctabopt
@opindex cpp
@opindex fpp
@cindex preprocessor, enable
@cindex preprocessor, disable
@item -cpp
@itemx -nocpp
Enable preprocessing. The preprocessor is automatically invoked if
the file extension is @file{.fpp}, @file{.FPP},  @file{.F}, @file{.FOR},
@file{.FTN}, @file{.F90}, @file{.F95}, @file{.F03} or @file{.F08}. Use
this option to manually enable preprocessing of any kind of Fortran file.

To disable preprocessing of files with any of the above listed extensions,
use the negative form: @option{-nocpp}.

The preprocessor is run in traditional mode. Any restrictions of the
file format, especially the limits on line length, apply for
preprocessed output as well, so it might be advisable to use the
@option{-ffree-line-length-none} or @option{-ffixed-line-length-none}
options.

@opindex dM
@cindex preprocessor, debugging
@cindex debugging, preprocessor
@item -dM
Instead of the normal output, generate a list of @code{'#define'}
directives for all the macros defined during the execution of the
preprocessor, including predefined macros. This gives you a way
of finding out what is predefined in your version of the preprocessor.
Assuming you have no file @file{foo.f90}, the command
@smallexample
  touch foo.f90; gfortran -cpp -E -dM foo.f90
@end smallexample
@noindent
shows all the predefined macros.

@opindex dD
@cindex preprocessor, debugging
@cindex debugging, preprocessor
@item -dD
Like @option{-dM} except in two respects: it does not include the
predefined macros, and it outputs both the @code{#define} directives
and the result of preprocessing. Both kinds of output go to the
standard output file.

@opindex dN
@cindex preprocessor, debugging
@cindex debugging, preprocessor
@item -dN
Like @option{-dD}, but emit only the macro names, not their expansions.

@opindex dU
@cindex preprocessor, debugging
@cindex debugging, preprocessor
@item -dU
Like @option{dD} except that only macros that are expanded, or whose
definedness is tested in preprocessor directives, are output; the
output is delayed until the use or test of the macro; and @code{'#undef'}
directives are also output for macros tested but undefined at the time.

@opindex dI
@cindex preprocessor, debugging
@cindex debugging, preprocessor
@item -dI
Output @code{'#include'} directives in addition to the result
of preprocessing.

@opindex fworking-directory
@cindex preprocessor, working directory
@item -fworking-directory
Enable generation of linemarkers in the preprocessor output that
let the compiler know the current working directory at the time of
preprocessing. When this option is enabled, the preprocessor emits,
after the initial linemarker, a second linemarker with the current
working directory followed by two slashes. GCC uses this directory,
when it is present in the preprocessed input, as the directory emitted
as the current working directory in some debugging information formats.
This option is implicitly enabled if debugging information is enabled,
but this can be inhibited with the negated form
@option{-fno-working-directory}. If the @option{-P} flag is present
in the command line, this option has no effect, since no @code{#line}
directives are emitted whatsoever.

@opindex idirafter
@cindex preprocessing, include path
@item -idirafter @var{dir}
Search @var{dir} for include files, but do it after all directories
specified with @option{-I} and the standard system directories have
been exhausted. @var{dir} is treated as a system include directory.
If dir begins with @code{=}, then the @code{=} is replaced by
the sysroot prefix; see @option{--sysroot} and @option{-isysroot}.

@opindex imultilib
@cindex preprocessing, include path
@item -imultilib @var{dir}
Use @var{dir} as a subdirectory of the directory containing target-specific
C++ headers.

@opindex iprefix
@cindex preprocessing, include path
@item -iprefix @var{prefix}
Specify @var{prefix} as the prefix for subsequent @option{-iwithprefix}
options. If the @var{prefix} represents a directory, you should include
the final @code{'/'}.

@opindex isysroot
@cindex preprocessing, include path
@item -isysroot @var{dir}
This option is like the @option{--sysroot} option, but applies only to
header files. See the @option{--sysroot} option for more information.

@opindex iquote
@cindex preprocessing, include path
@item -iquote @var{dir}
Search @var{dir} only for header files requested with @code{#include "file"};
they are not searched for @code{#include <file>}, before all directories
specified by @option{-I} and before the standard system directories. If
@var{dir} begins with @code{=}, then the @code{=} is replaced by the
sysroot prefix; see @option{--sysroot} and @option{-isysroot}.

@opindex isystem
@cindex preprocessing, include path
@item -isystem @var{dir}
Search @var{dir} for header files, after all directories specified by
@option{-I} but before the standard system directories. Mark it as a
system directory, so that it gets the same special treatment as is
applied to the standard system directories. If @var{dir} begins with
@code{=}, then the @code{=} is replaced by the sysroot prefix;
see @option{--sysroot} and @option{-isysroot}.

@opindex nostdinc
@item -nostdinc
Do not search the standard system directories for header files. Only
the directories you have specified with @option{-I} options (and the
directory of the current file, if appropriate) are searched.

@opindex undef
@item -undef
Do not predefine any system-specific or GCC-specific macros.
The standard predefined macros remain defined.

@opindex A@var{predicate}=@var{answer}
@cindex preprocessing, assertion
@item -A@var{predicate}=@var{answer}
Make an assertion with the predicate @var{predicate} and answer @var{answer}.
This form is preferred to the older form -A predicate(answer), which is still
supported, because it does not use shell special characters.

@opindex A-@var{predicate}=@var{answer}
@cindex preprocessing, assertion
@item -A-@var{predicate}=@var{answer}
Cancel an assertion with the predicate @var{predicate} and answer @var{answer}.

@opindex C
@cindex preprocessing, keep comments
@item -C
Do not discard comments. All comments are passed through to the output
file, except for comments in processed directives, which are deleted
along with the directive.

You should be prepared for side effects when using @option{-C}; it causes
the preprocessor to treat comments as tokens in their own right. For example,
comments appearing at the start of what would be a directive line have the
effect of turning that line into an ordinary source line, since the first
token on the line is no longer a @code{'#'}.

Warning: this currently handles C-Style comments only. The preprocessor
does not yet recognize Fortran-style comments.

@opindex CC
@cindex preprocessing, keep comments
@item -CC
Do not discard comments, including during macro expansion. This is like
@option{-C}, except that comments contained within macros are also passed
through to the output file where the macro is expanded.

In addition to the side-effects of the @option{-C} option, the @option{-CC}
option causes all C++-style comments inside a macro to be converted to C-style
comments. This is to prevent later use of that macro from inadvertently
commenting out the remainder of the source line. The @option{-CC} option
is generally used to support lint comments.

Warning: this currently handles C- and C++-Style comments only. The
preprocessor does not yet recognize Fortran-style comments.

@opindex D@var{name}
@cindex preprocessing, define macros
@item -D@var{name}
Predefine name as a macro, with definition @code{1}.

@opindex D@var{name}=@var{definition}
@cindex preprocessing, define macros
@item -D@var{name}=@var{definition}
The contents of @var{definition} are tokenized and processed as if they
appeared during translation phase three in a @code{'#define'} directive.
In particular, the definition is truncated by embedded newline
characters.

If you are invoking the preprocessor from a shell or shell-like program
you may need to use the shell's quoting syntax to protect characters such
as spaces that have a meaning in the shell syntax.

If you wish to define a function-like macro on the command line, write
its argument list with surrounding parentheses before the equals sign
(if any). Parentheses are meaningful to most shells, so you need
to quote the option. With sh and csh, @code{-D'name(args...)=definition'}
works.

@option{-D} and @option{-U} options are processed in the order they are
given on the command line. All -imacros file and -include file options
are processed after all -D and -U options.

@opindex H
@item -H
Print the name of each header file used, in addition to other normal
activities. Each name is indented to show how deep in the @code{'#include'}
stack it is.

@opindex P
@cindex preprocessing, no linemarkers
@item -P
Inhibit generation of linemarkers in the output from the preprocessor.
This might be useful when running the preprocessor on something that
is not C code, and is sent to a program that might be confused
by the linemarkers.

@opindex U@var{name}
@cindex preprocessing, undefine macros
@item -U@var{name}
Cancel any previous definition of @var{name}, either built in or provided
with a @option{-D} option.
@end table


@node Error and Warning Options
@section Options to request or suppress errors and warnings
@cindex options, warnings
@cindex options, errors
@cindex warnings, suppressing
@cindex messages, error
@cindex messages, warning
@cindex suppressing warnings

Errors are diagnostic messages that report that the GNU Fortran compiler
cannot compile the relevant piece of source code.  The compiler
continues to process the program in an attempt to report further errors
to aid in debugging, but does not produce any compiled output.

Warnings are diagnostic messages that report constructions that
are not inherently erroneous but that are risky or suggest there is
likely to be a bug in the program.  Unless @option{-Werror} is specified,
they do not prevent compilation of the program.

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 errors and warnings produced
by GNU Fortran:

@table @gcctabopt
@opindex fmax-errors=@var{n}
@cindex errors, limiting
@item -fmax-errors=@var{n}
Limits the maximum number of error messages to @var{n}, at which point
GNU Fortran bails out rather than attempting to continue processing the
source code.  If @var{n} is 0, there is no limit on the number of error
messages produced.

@opindex fsyntax-only
@cindex syntax checking
@item -fsyntax-only
Check the code for syntax errors, but do not actually compile it.  This
generates module files for each module present in the code, but no
other output file.

@opindex pedantic
@opindex Wpedantic
@item -Wpedantic
@itemx -pedantic
Issue warnings for uses of extensions to Fortran.
@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 @code{#include}.

Valid Fortran 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 conformance.
They soon find that it does not do quite what they want---it finds some
nonstandard practices, but not all.
However, improvements to GNU Fortran in this area are welcome.

This should be used in conjunction with @option{-std=f95},
@option{-std=f2003}, @option{-std=f2008}, @option{-std=f2018}
or @option{-std=f2023}.

@opindex pedantic-errors
@item -pedantic-errors
Like @option{-pedantic}, except that errors are produced rather than
warnings.

@opindex Wall
@cindex all warnings
@cindex warnings, all
@item -Wall
Enables commonly used warning options pertaining to usage that
we recommend avoiding and that we believe are easy to avoid.
This currently includes @option{-Waliasing}, @option{-Wampersand},
@option{-Wconversion}, @option{-Wsurprising}, @option{-Wc-binding-type},
@option{-Wintrinsics-std}, @option{-Wtabs}, @option{-Wintrinsic-shadow},
@option{-Wline-truncation}, @option{-Wtarget-lifetime},
@option{-Winteger-division}, @option{-Wreal-q-constant}, @option{-Wunused}
and @option{-Wundefined-do-loop}.

@opindex Waliasing
@cindex aliasing
@cindex warnings, aliasing
@item -Waliasing
Warn about possible aliasing of dummy arguments. Specifically, it warns
if the same actual argument is associated with a dummy argument with
@code{INTENT(IN)} and a dummy argument with @code{INTENT(OUT)} in a call
with an explicit interface.

The following example triggers the warning.
@smallexample
  interface
    subroutine bar(a,b)
      integer, intent(in) :: a
      integer, intent(out) :: b
    end subroutine
  end interface
  integer :: a

  call bar(a,a)
@end smallexample

@opindex Wampersand
@cindex warnings, ampersand
@cindex @code{&}
@item -Wampersand
Warn about missing ampersand in continued character constants. The
warning is given with @option{-Wampersand}, @option{-pedantic},
@option{-std=f95}, @option{-std=f2003}, @option{-std=f2008}, @option{-std=f2018}
and @option{-std=f2023}. Note: With no ampersand given in a continued
character constant, GNU Fortran assumes continuation at the first
non-comment, non-whitespace character after the ampersand that
initiated the continuation.

@opindex Warray-temporaries
@cindex warnings, array temporaries
@item -Warray-temporaries
Warn about array temporaries generated by the compiler.  The information
generated by this warning is sometimes useful in optimization, in order to
avoid such temporaries.

@opindex Wc-binding-type
@cindex warning, C binding type
@item -Wc-binding-type
Warn if the a variable might not be C interoperable.  In particular, warn if
the variable has been declared using an intrinsic type with default kind
instead of using a kind parameter defined for C interoperability in the
intrinsic @code{ISO_C_Binding} module.  This option is implied by
@option{-Wall}.

@opindex Wcharacter-truncation
@cindex warnings, character truncation
@item -Wcharacter-truncation
Warn when a character assignment truncates the assigned string.

@opindex Wline-truncation
@cindex warnings, line truncation
@item -Wline-truncation
Warn when a source code line is truncated.  This option is
implied by @option{-Wall}.  For free-form source code, the default is
@option{-Werror=line-truncation} such that truncations are reported as
error.

@opindex Wconversion
@cindex warnings, conversion
@cindex conversion
@item -Wconversion
Warn about implicit conversions that are likely to change the value of
the expression after conversion. Implied by @option{-Wall}.

@opindex Wconversion-extra
@cindex warnings, conversion
@cindex conversion
@item -Wconversion-extra
Warn about implicit conversions between different types and kinds. This
option does @emph{not} imply @option{-Wconversion}.

@opindex Wdeprecated-openmp
@cindex warnings
@item -Wdeprecated-openmp
Warn for usage of deprecated OpenMP code.

@opindex Wexternal-argument-mismatch
@cindex warnings, argument mismatch
@cindex argument mismatch, warnings
@item -Wexternal-argument-mismatch
Warn about argument mismatches for dummy external procedures.  This is
implied by @option{-fc-prototypes-external} because generation of a
valid C23 interface is not possible in such a case.  Also implied
by @option{-Wall}.

@opindex Wextra
@cindex extra warnings
@cindex warnings, extra
@item -Wextra
Enables some warning options for usages of language features that
may be problematic. This currently includes @option{-Wcompare-reals},
@option{-Wunused-parameter} and @option{-Wdo-subscript}.

@opindex Wfrontend-loop-interchange
@cindex warnings, loop interchange
@cindex loop interchange, warning
@item -Wfrontend-loop-interchange
Warn when using @option{-ffrontend-loop-interchange} for performing loop
interchanges.

@opindex Wimplicit-interface
@cindex warnings, implicit interface
@item -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.

@opindex Wimplicit-procedure
@cindex warnings, implicit procedure
@item -Wimplicit-procedure
Warn if a procedure is called that has neither an explicit interface
nor has been declared as @code{EXTERNAL}.

@opindex Winteger-division
@cindex warnings, integer division
@cindex warnings, division of integers
@item -Winteger-division
Warn if a constant integer division truncates its result.
As an example, 3/5 evaluates to 0.

@opindex Wintrinsics-std
@cindex warnings, nonstandard intrinsics
@cindex warnings, intrinsics of other standards
@item -Wintrinsics-std
Warn if @command{gfortran} finds a procedure named like an intrinsic not
available in the currently selected standard (with @option{-std}) and treats
it as @code{EXTERNAL} procedure because of this.  @option{-fall-intrinsics} can
be used to never trigger this behavior and always link to the intrinsic
regardless of the selected standard.

@opindex Woverwrite-recursive
@cindex  warnings, overwrite recursive
@item -Wno-overwrite-recursive
Do not warn when @option{-fno-automatic} is used with @option{-frecursive}. Recursion
is broken if the relevant local variables do not have the attribute
@code{AUTOMATIC} explicitly declared. This option can be used to suppress the warning
when it is known that recursion is not broken. Useful for build environments that use
@option{-Werror}.

@opindex Wreal-q-constant
@cindex warnings, @code{q} exponent-letter
@item -Wreal-q-constant
Produce a warning if a real-literal-constant contains a @code{q}
exponent-letter.

@opindex Wsurprising
@cindex warnings, suspicious code
@item -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:

@itemize @bullet
@item
An @code{INTEGER}-typed @code{SELECT CASE} construct has a @code{CASE}
that can never be matched as its
lower value is greater than its upper value.

@item
A @code{LOGICAL}-typed @code{SELECT CASE} construct has three @code{CASE}
statements.

@item
A @code{TRANSFER} specifies a source that is shorter than the destination.

@item
The type of a function result is declared more than once with the same type.  If
@option{-pedantic} or standard-conforming mode is enabled, this is an error.

@item
A @code{CHARACTER} variable is declared with negative length.

@item
With @option{-fopenmp}, for fixed-form source code, when an @code{omx}
vendor-extension sentinel is encountered. (The equivalent @code{ompx},
used in free-form source code, is diagnosed by default.)

@item
With @option{-fopenacc}, when using named constances with clauses that
take a variable as doing so has no effect.
@end itemize

@opindex Wtabs
@cindex warnings, tabs
@cindex tabulators
@item -Wtabs
By default, tabs are accepted as whitespace, but tabs are not members
of the Fortran Character Set.  For continuation lines, a tab followed
by a digit between 1 and 9 is supported.  @option{-Wtabs} causes a
warning to be issued if a tab is encountered. Note, @option{-Wtabs} is
active for @option{-pedantic}, @option{-std=f95}, @option{-std=f2003},
@option{-std=f2008}, @option{-std=f2018}, @option{-std=f2023} and
@option{-Wall}.

@opindex Wundefined-do-loop
@cindex warnings, undefined do loop
@item -Wundefined-do-loop
Warn if a @code{DO} loop with step either 1 or -1 yields an underflow
or an overflow
during iteration of an induction variable of the loop.
This option is implied by @option{-Wall}.

@opindex Wunderflow
@cindex warnings, underflow
@cindex underflow
@item -Wunderflow
Produce a warning when numerical constant expressions
that yield an underflow are encountered during compilation.
Enabled by default.

@opindex Wintrinsic-shadow
@cindex warnings, intrinsic
@cindex intrinsic
@item -Wintrinsic-shadow
Warn if a user-defined procedure or module procedure has the same name as an
intrinsic; in this case, an explicit interface or @code{EXTERNAL} or
@code{INTRINSIC} declaration might be needed to get calls later resolved to
the desired intrinsic/procedure.  This option is implied by @option{-Wall}.

@opindex Wuse-without-only
@cindex warnings, use statements
@cindex intrinsic
@item -Wuse-without-only
Warn if a @code{USE} statement has no @code{ONLY} qualifier and
thus implicitly imports all public entities of the used module.

@opindex Wunused-dummy-argument
@cindex warnings, unused dummy argument
@cindex unused dummy argument
@cindex dummy argument, unused
@item -Wunused-dummy-argument
Warn about unused dummy arguments. This option is implied by @option{-Wall}.

@opindex Wunused-parameter
@cindex warnings, unused parameter
@cindex unused parameter
@item -Wunused-parameter
Contrary to @command{gcc}'s meaning of @option{-Wunused-parameter},
@command{gfortran}'s implementation of this option does not warn
about unused dummy arguments (see @option{-Wunused-dummy-argument}),
but about unused @code{PARAMETER} values. @option{-Wunused-parameter}
is implied by @option{-Wextra} if also @option{-Wunused} or
@option{-Wall} is used.

@opindex Walign-commons
@cindex warnings, alignment of @code{COMMON} blocks
@cindex alignment of @code{COMMON} blocks
@item -Walign-commons
By default, @command{gfortran} warns about any occasion of variables being
padded for proper alignment inside a @code{COMMON} block. This warning can be turned
off via @option{-Wno-align-commons}. See also @option{-falign-commons}.

@opindex Wfunction-elimination
@cindex function elimination
@cindex warnings, function elimination
@item -Wfunction-elimination
Warn if any calls to impure functions are eliminated by the optimizations
enabled by the @option{-ffrontend-optimize} option.
This option is implied by @option{-Wextra}.

@opindex Wrealloc-lhs
@cindex Reallocate the LHS in assignments, notification
@item -Wrealloc-lhs
Warn when the compiler might insert code to for allocation or reallocation of
an allocatable array variable of intrinsic type in intrinsic assignments.  In
hot loops, the Fortran 2003 reallocation feature may reduce the performance.
If the array is already allocated with the correct shape, consider using a
whole-array array-spec (e.g. @code{(:,:,:)}) for the variable on the left-hand
side to prevent the reallocation check. Note that in some cases the warning
is shown, even if the compiler optimizes reallocation checks away.  For
instance, when the right-hand side contains the same variable multiplied by
a scalar.  See also @option{-frealloc-lhs}.

@opindex Wrealloc-lhs-all
@item -Wrealloc-lhs-all
Warn when the compiler inserts code to for allocation or reallocation of an
allocatable variable; this includes scalars and derived types.

@opindex Wcompare-reals
@item -Wcompare-reals
Warn when comparing real or complex types for equality or inequality.
This option is implied by @option{-Wextra}.

@opindex Wtargt-lifetime
@item -Wtarget-lifetime
Warn if the pointer in a pointer assignment might be longer than the its
target. This option is implied by @option{-Wall}.

@opindex Wzerotrip
@item -Wzerotrip
Warn if a @code{DO} loop is known to execute zero times at compile
time.  This option is implied by @option{-Wall}.

@opindex Wdo-subscript
@item -Wdo-subscript
Warn if an array subscript inside a @code{DO} loop could lead to an
out-of-bounds access even if the compiler cannot prove that the
statement is actually executed, in cases like
@smallexample
  real a(3)
  do i=1,4
    if (condition(i)) then
      a(i) = 1.2
    end if
  end do
@end smallexample
This option is implied by @option{-Wextra}.

@opindex Werror
@cindex warnings, to errors
@item -Werror
Turns all warnings into errors.
@end table

@xref{Warning Options,,Options to Request or Suppress Errors and
Warnings, gcc,Using the GNU Compiler Collection (GCC)}, for information on
more options offered by the back end shared by @command{gfortran}, @command{gcc}
and other GNU compilers.

Some of these have no effect when compiling programs written in Fortran.

@node Debugging Options
@section Options for debugging your program
@cindex options, debugging
@cindex debugging information options

GNU Fortran has various special options that are used for debugging
your program.

@table @gcctabopt
@opindex fdebug-aux-vars
@item -fdebug-aux-vars
Renames internal variables created by the gfortran front end and makes
them accessible to a debugger.  The name of the internal variables then
start with uppercase letters followed by an underscore.  This option is
useful for debugging the compiler's code generation together with
@code{-fdump-tree-original} and enabling debugging of the executable
program by using @code{-g} or @code{-ggdb3}.

@opindex ffpe-trap=@var{list}
@item -ffpe-trap=@var{list}
Specify a list of floating point exception traps to enable.  On most
systems, if a floating point exception occurs and the trap for that
exception is enabled, a @code{SIGFPE} signal is sent and the program
being aborted, producing a core file useful for debugging.  @var{list}
is a (possibly empty) comma-separated list of either @samp{none} (to
clear the set of exceptions to be trapped), or of the following
exceptions: @samp{invalid} (invalid floating point operation, such as
@code{SQRT(-1.0)}), @samp{zero} (division by zero), @samp{overflow}
(overflow in a floating point operation), @samp{underflow} (underflow
in a floating point operation), @samp{inexact} (loss of precision
during operation), and @samp{denormal} (operation performed on a
denormal value).  The first five exceptions correspond to the five
IEEE 754 exceptions, whereas the last one (@samp{denormal}) is not
part of the IEEE 754 standard but is available on some common
architectures such as x86.

The first three exceptions (@samp{invalid}, @samp{zero}, and
@samp{overflow}) often indicate serious errors, and unless the program
has provisions for dealing with these exceptions, enabling traps for
these three exceptions is probably a good idea.

If the option is used more than once in the command line, the lists are
joined: '@code{ffpe-trap=}@var{list1} @code{ffpe-trap=}@var{list2}'
is equivalent to @code{ffpe-trap=}@var{list1},@var{list2}.

Note that once enabled an exception cannot be disabled (no negative form),
except by clearing all traps by specifying @samp{none}.

Many, if not most, floating point operations incur loss of precision
due to rounding, and hence the @code{ffpe-trap=inexact} is likely to
be uninteresting in practice.

By default no exception traps are enabled.

@opindex ffpe-summary=@var{list}
@item -ffpe-summary=@var{list}
Specify a list of floating-point exceptions, whose flag status is printed
to @code{ERROR_UNIT} when invoking @code{STOP} and @code{ERROR STOP}.
@var{list} can be either @samp{none}, @samp{all} or a comma-separated list
of the following exceptions: @samp{invalid}, @samp{zero}, @samp{overflow},
@samp{underflow}, @samp{inexact} and @samp{denormal}. (See
@option{-ffpe-trap} for a description of the exceptions.)

If the option is used more than once in the command line, only the
last one is used.

By default, a summary for all exceptions but @samp{inexact} is shown.

@opindex fno-backtrace
@cindex backtrace
@cindex trace
@item -fno-backtrace
When a serious runtime error is encountered or a deadly signal is
emitted (segmentation fault, illegal instruction, bus error,
floating-point exception, and the other POSIX signals that have the
action @samp{core}), the Fortran runtime library tries to output a
backtrace of the error. @code{-fno-backtrace} disables the backtrace
generation. This option only has influence for compilation of the
Fortran main program.

@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 Directory Options
@section Options for directory search
@cindex directory, options
@cindex options, directory search
@cindex search path
@cindex @code{INCLUDE} directive
@cindex directive, @code{INCLUDE}
These options affect how GNU Fortran searches
for files specified by the @code{INCLUDE} directive and where it searches
for previously compiled modules.

It also affects the search paths used by @command{cpp} when used to preprocess
Fortran source.

@table @gcctabopt
@opindex I@var{dir}
@cindex directory, search paths for inclusion
@cindex inclusion, directory search paths for
@cindex search paths, for included files
@cindex paths, search
@cindex module search path
@item -I@var{dir}
These affect interpretation of the @code{INCLUDE} directive
(as well as of the @code{#include} directive of the @command{cpp}
preprocessor).

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.

This path is also used to search for @file{.mod} files when previously
compiled modules are required by a @code{USE} statement.

@xref{Directory Options,,Options for Directory Search,
gcc,Using the GNU Compiler Collection (GCC)}, for information on the
@option{-I} option.

@opindex J@var{dir}
@cindex paths, search
@cindex module search path
@item -J@var{dir}
This option specifies where to put @file{.mod} files for compiled modules.
It is also added to the list of directories to searched by an @code{USE}
statement.

The default is the current directory.

@opindex fintrinsic-modules-path
@cindex paths, search
@cindex module search path
@item -fintrinsic-modules-path @var{dir}
This option specifies the location of pre-compiled intrinsic modules, if
they are not in the default location expected by the compiler.
@end table

@node Link Options
@section Influencing the linking step
@cindex options, linking
@cindex linking, static

These options come into play when the compiler links object files into an
executable output file. They are meaningless if the compiler is not doing
a link step.

@table @gcctabopt
@opindex static-libgfortran
@item -static-libgfortran
On systems that provide @file{libgfortran} as a shared and a static
library, this option forces the use of the static version. If no
shared version of @file{libgfortran} was built when the compiler was
configured, this option has no effect.
@end table


@table @gcctabopt
@opindex static-libquadmath
@item -static-libquadmath
On systems that provide @file{libquadmath} as a shared and a static
library, this option forces the use of the static version. If no
shared version of @file{libquadmath} was built when the compiler was
configured, this option has no effect.

Please note that the @file{libquadmath} runtime library is licensed under the
GNU Lesser General Public License (LGPL), and linking it statically introduces
requirements when redistributing the resulting binaries.
@end table


@node Runtime Options
@section Influencing runtime behavior
@cindex options, runtime

These options affect the runtime behavior of programs compiled with GNU Fortran.

@table @gcctabopt
@opindex fconvert=@var{conversion}
@item -fconvert=@var{conversion}
Specify the representation of data for unformatted files.  Valid
values for conversion on most systems are: @samp{native}, the default;
@samp{swap}, swap between big- and little-endian; @samp{big-endian}, use
big-endian representation for unformatted files; @samp{little-endian}, use
little-endian representation for unformatted files.

On POWER systems that support @option{-mabi=ieeelongdouble},
there are additional options, which can be combined with others with
commas.  Those are
@itemize @w{}
@item @option{-fconvert=r16_ieee} Use IEEE 128-bit format for
@code{REAL(KIND=16)}.
@item @option{-fconvert=r16_ibm} Use IBM long double format for
@code{REAL(KIND=16)}.
@end itemize

This option has an effect only when used in the main program.
The @code{CONVERT} specifier and the @env{GFORTRAN_CONVERT_UNIT} environment
variable override the default specified by @option{-fconvert}.

@opindex frecord-marker=@var{length}
@item -frecord-marker=@var{length}
Specify the length of record markers for unformatted files.
Valid values for @var{length} are 4 and 8.  Default is 4.
@emph{This is different from previous versions of @command{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 @command{gfortran}, use @option{-frecord-marker=8}.

@opindex fmax-subrecord-length=@var{length}
@item -fmax-subrecord-length=@var{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.

@opindex fsign-zero
@item -fsign-zero
When enabled, floating point numbers of value zero with the sign bit set
are written as negative number in formatted output and treated as
negative in the @code{SIGN} intrinsic.  @option{-fno-sign-zero} does not
print the negative sign of zero values (or values rounded to zero for I/O)
and regards zero as positive number in the @code{SIGN} intrinsic for
compatibility with Fortran 77. The default is @option{-fsign-zero}.
@end table

@node Developer Options
@section GNU Fortran Developer Options
@cindex options, debugging
@cindex developer options

GNU Fortran has various special options that are used for debugging
the GNU Fortran compiler.

@table @gcctabopt
@opindex fdump-fortran-global
@item -fdump-fortran-global
Output a list of the global identifiers after translating into
middle-end representation. Mostly useful for debugging the GNU Fortran
compiler itself. The output generated by this option might change
between releases.  This option may also generate internal compiler
errors for features that have only recently been added.

@opindex fdump-fortran-optimized
@item -fdump-fortran-optimized
Output the parse tree after front-end optimization.  Mostly useful for
debugging the GNU Fortran compiler itself. The output generated by
this option might change between releases.  This option may also
generate internal compiler errors for features that have only
recently been added.

@opindex fdump-fortran-original
@item -fdump-fortran-original
Output the internal parse tree after translating the source program
into internal representation.  This option is mostly useful for
debugging the GNU Fortran compiler itself. The output generated by
this option might change between releases. This option may also
generate internal compiler errors for features that have only
recently been added.

@opindex fdump-parse-tree
@item -fdump-parse-tree
Output the internal parse tree after translating the source program
into internal representation.  Mostly useful for debugging the GNU
Fortran compiler itself. The output generated by this option might
change between releases. This option may also generate internal
compiler errors for features that have only recently been added. This
option is deprecated; use @code{-fdump-fortran-original} instead.

@item -save-temps
Store the usual ``temporary'' intermediate files permanently; name them
as auxiliary output files, as specified described under GCC
@option{-dumpbase} and @option{-dumpdir}.

@smallexample
gfortran -save-temps -c foo.F90
@end smallexample

@noindent
preprocesses input file @file{foo.F90} to @file{foo.fii}, compiles to an
intermediate @file{foo.s}, and then assembles to the (implied) output
file @file{foo.o}, whereas:

@smallexample
gfortran -save-temps -S foo.F
@end smallexample

@noindent
saves the preprocessor output in @file{foo.fi}, and then compiles to
the (implied) output file @file{foo.s}.

@end table

@node Code Gen Options
@section Options for code generation conventions
@cindex code generation, conventions
@cindex options, code generation
@cindex options, run-time

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 that is not the default.  You
can figure out the other form by either removing @option{no-} or adding
it.

@table @gcctabopt
@opindex fno-automatic
@cindex @code{SAVE} statement
@cindex statement, @code{SAVE}
@item -fno-automatic
Treat each program unit (except those marked as @code{RECURSIVE}) as if the
@code{SAVE} statement were 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} or @option{-save}.)
The default, which is @option{-fautomatic}, uses the stack for local
variables smaller than the value given by @option{-fmax-stack-var-size}.
Use the option @option{-frecursive} to use no static memory.

Local variables or arrays having an explicit @code{SAVE} attribute are
silently ignored unless the @option{-pedantic} option is added.

@opindex ff2c
@cindex calling convention
@cindex @command{f2c} calling convention
@cindex @command{g77} calling convention
@cindex libf2c calling convention
@item -ff2c
Generate code designed to be compatible with code generated
by @command{g77} and @command{f2c}.

The calling conventions used by @command{g77} (originally implemented
in @command{f2c}) require functions that return type
default @code{REAL} 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 default GNU calling conventions, such
functions simply return their results as they would in GNU
C---default @code{REAL} functions return the C type @code{float}, and
@code{COMPLEX} functions return the GNU C type @code{complex}.
Additionally, this option implies the @option{-fsecond-underscore}
option, unless @option{-fno-second-underscore} is explicitly requested.

This does not affect the generation of code that interfaces with
the @command{libgfortran} library.

@emph{Caution:} It is not a good idea to mix Fortran code compiled with
@option{-ff2c} with code compiled with the default @option{-fno-f2c}
calling conventions as, calling @code{COMPLEX} or default @code{REAL}
functions between program parts that were compiled with different
calling conventions will break at execution time.

@emph{Caution:} This breaks code that passes intrinsic functions
of type default @code{REAL} or @code{COMPLEX} as actual arguments, as
the library implementations use the @option{-fno-f2c} calling conventions.

@opindex fno-underscoring
@cindex underscore
@cindex symbol names, underscores
@cindex transforming symbol names
@cindex symbol names, transforming
@item -fno-underscoring
Do not transform names of entities specified in the Fortran
source file by appending underscores to them.

With @option{-funderscoring} in effect, GNU Fortran appends one
underscore to external names.  This is done to ensure
compatibility with code produced by many UNIX Fortran compilers.
Note this does not apply to names declared with C binding, or within
a module.

@emph{Caution}: The default behavior of GNU Fortran is
incompatible with @command{f2c} and @command{g77}, please use the
@option{-ff2c} option if you want object files compiled with
GNU Fortran to be compatible with object code created with these
tools.

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 that @code{j()} and
@code{max_count()} are external functions while @code{my_var} and
@code{lvar} are local variables, a Fortran statement like
@smallexample
I = J() + MAX_COUNT (MY_VAR, LVAR)
@end smallexample
@noindent
is implemented as something akin to the C code:
@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 GNU Fortran
code with other languages.

Note that just because the names match does @emph{not} mean that the
interface implemented by GNU Fortran for an external name matches the
interface implemented by some other language for that same name.
That is, getting code produced by GNU 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 @option{-fno-underscoring}, the lack of appended
underscores introduces the very real possibility that a user-defined
external name conflicts 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.

@xref{Naming and argument-passing conventions}, for more information.
Also note that declaring symbols as @code{bind(C)} is a more robust way to
interface with code written in other languages or compiled with different
Fortran compilers than the command-line options documented in this section.

@opindex fsecond-underscore
@cindex underscore
@cindex symbol names, underscores
@cindex transforming symbol names
@cindex symbol names, transforming
@cindex @command{f2c} calling convention
@cindex @command{g77} calling convention
@cindex libf2c calling convention
@item -fsecond-underscore
By default, GNU Fortran appends an underscore to external
names.  If this option is used, GNU Fortran appends two
underscores to names with underscores and one underscore to names
with no underscores.

For example, an external name such as @code{MAX_COUNT}
is implemented as a reference to the link-time external symbol
@code{max_count__}, instead of @code{max_count_}.  This is required
for compatibility with @command{g77} and @command{f2c}, and is implied
by use of the @option{-ff2c} option.

This option has no effect if @option{-fno-underscoring} is
in effect.  It is implied by the @option{-ff2c} option.

@opindex fcoarray
@cindex coarrays
@item -fcoarray=@var{<keyword>}

@table @asis
@item @samp{none}
Disable coarray support; using coarray declarations and image-control
statements produces a compile-time error. (Default)

@item @samp{single}
Single-image mode, i.e. @code{num_images()} is always one.

@item @samp{shared}
Use shared-memory multithreading parallelization.

@item @samp{lib}
Library-based coarray parallelization; a suitable GNU Fortran coarray
library such as @url{http://opencoarrays.org} needs to be linked.
Alternatively, GCC's @code{libcaf_single} library can be linked,
albeit it only supports a single image.

@end table


@opindex fcheck
@cindex array, bounds checking
@cindex bit intrinsics checking
@cindex bounds checking
@cindex pointer checking
@cindex memory checking
@cindex range checking
@cindex subscript checking
@cindex checking subscripts
@cindex run-time checking
@cindex checking array temporaries
@item -fcheck=@var{<keyword>}

Enable the generation of run-time checks; the argument shall be
a comma-delimited list of the following keywords.  Prefixing a check with
@option{no-} disables it if it was activated by a previous specification.

@table @asis
@item @samp{all}
Enable all run-time test of @option{-fcheck}.

@item @samp{array-temps}
Warns at run time when for passing an actual argument a temporary array
had to be generated. The information generated by this warning is
sometimes useful in optimization, in order to avoid such temporaries.

Note: The warning is only printed once per location.

@item @samp{bits}
Enable generation of run-time checks for invalid arguments to the bit
manipulation intrinsics.

@item @samp{bounds}
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 and ensures that all string
lengths are equal for character array constructors without an explicit
typespec.

Some checks require that @option{-fcheck=bounds} is set for
the compilation of the main program.

Note: In the future this may also include other forms of checking, e.g.,
checking substring references.

@item @samp{do}
Enable generation of run-time checks for invalid modification of loop
iteration variables.

@item @samp{mem}
Enable generation of run-time checks for memory allocation.
Note: This option does not affect explicit allocations using the
@code{ALLOCATE} statement, which are always checked.

@item @samp{pointer}
Enable generation of run-time checks for pointers and allocatables.

@item @samp{recursion}
Enable generation of run-time checks for recursively called subroutines and
functions that are not marked as recursive. See also @option{-frecursive}.
Note: This check does not work for OpenMP programs and is disabled if used
together with @option{-frecursive} and @option{-fopenmp}.
@end table

Example: Assuming you have a file @file{foo.f90}, the command
@smallexample
  gfortran -fcheck=all,no-array-temps foo.f90
@end smallexample
@noindent
compiles the file with all checks enabled as specified above except
warnings for generated array temporaries.


@opindex fbounds-check
@item -fbounds-check
@c Note: This option is also referred in gcc's manpage
Deprecated alias for @option{-fcheck=bounds}.

@opindex tail-call-workaround
@item -ftail-call-workaround
@itemx -ftail-call-workaround=@var{n}
Some C interfaces to Fortran codes violate the gfortran ABI by
omitting the hidden character length arguments as described in
@xref{Argument passing conventions}.  This can lead to crashes
because pushing arguments for tail calls can overflow the stack.

To provide a workaround for existing binary packages, this option
disables tail call optimization for gfortran procedures with character
arguments.  With @option{-ftail-call-workaround=2} tail call optimization
is disabled in all gfortran procedures with character arguments,
with @option{-ftail-call-workaround=1} or equivalent
@option{-ftail-call-workaround} only in gfortran procedures with character
arguments that call implicitly prototyped procedures.

Using this option can lead to problems including crashes due to
insufficient stack space.

It is @emph{very strongly} recommended to fix the code in question.
The @option{-fc-prototypes-external} option can be used to generate
prototypes that conform to gfortran's ABI, for inclusion in the
source code.

Support for this option will likely be withdrawn in a future release
of gfortran.

The negative form, @option{-fno-tail-call-workaround} or equivalent
@option{-ftail-call-workaround=0}, can be used to disable this option.

Default is currently @option{-ftail-call-workaround}, this will change
in future releases.

@opindex fcheck-array-temporaries
@item -fcheck-array-temporaries
Deprecated alias for @option{-fcheck=array-temps}.

@opindex fmax-array-constructor
@item -fmax-array-constructor=@var{n}
This option can be used to increase the upper limit permitted in
array constructors.  The code below requires this option to expand
the array at compile time.

@smallexample
program test
implicit none
integer j
integer, parameter :: n = 100000
integer, parameter :: i(n) = (/ (2*j, j = 1, n) /)
print '(10(I0,1X))', i
end program test
@end smallexample

@emph{Caution:  This option can lead to long compile times and excessively
large object files.}

The default value for @var{n} is 65535.


@opindex fmax-stack-var-size
@item -fmax-stack-var-size=@var{n}
This option specifies the size in bytes of the largest array that is put
on the stack; if the size is exceeded static memory is used (except in
procedures marked as @code{RECURSIVE}).
Use the option @option{-frecursive} to
allow for recursive procedures that do not have a
@code{RECURSIVE} attribute or
for parallel programs. Use @option{-fno-automatic} to never use the stack.

This option currently only affects local arrays declared with constant
bounds, and may not apply to all character variables.
Future versions of GNU Fortran may improve this behavior.

The default value for @var{n} is 65536.

@opindex fstack-arrays
@item -fstack-arrays
Adding this option makes the Fortran compiler put all arrays of
unknown size and array temporaries onto stack memory.  If your program uses very
large local arrays it is possible that you have to extend your runtime
limits for stack memory on some operating systems. This flag is enabled
by default at optimization level @option{-Ofast} unless
@option{-fmax-stack-var-size} is specified.

@opindex fpack-derived
@cindex structure packing
@item -fpack-derived
This option tells GNU 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.

@opindex frepack-arrays
@cindex repacking arrays
@item -frepack-arrays
In some circumstances GNU 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.

@opindex fshort-enums
@item -fshort-enums
This option is provided for interoperability with C code that was
compiled with the @option{-fshort-enums} option.  It makes
GNU Fortran choose the smallest @code{INTEGER} kind a given
enumerator set fits in, and give all its enumerators this kind.

@opindex finline-arg-packing
@item -finline-arg-packing
When passing an assumed-shape argument of a procedure as actual
argument to an assumed-size or explicit size or as argument to a
procedure that does not have an explicit interface, the argument may
have to be packed; that is, put into contiguous memory. An example is
the call to @code{foo} in
@smallexample
  subroutine foo(a)
     real, dimension(*) :: a
  end subroutine foo
  subroutine bar(b)
     real, dimension(:) :: b
     call foo(b)
  end subroutine bar
@end smallexample

When @option{-finline-arg-packing} is in effect, this packing is
performed by inline code. This allows for more optimization while
increasing code size.

@option{-finline-arg-packing} is implied by any of the @option{-O} options
except when optimizing for size via @option{-Os}.  If the code
contains a very large number of argument that have to be packed, code
size and also compilation time may become excessive.  If that is the
case, it may be better to disable this option.  Instances of packing
can be found by using @option{-Warray-temporaries}.

@opindex fexternal-blas
@item -fexternal-blas
This option makes @command{gfortran} generate calls to BLAS functions
for some matrix operations like @code{MATMUL}, instead of using our own
algorithms, if the size of the matrices involved is larger than a given
limit (see @option{-fblas-matmul-limit}).  This may be profitable if an
optimized vendor BLAS library is available.  The BLAS library has
to be specified at link time.  This option specifies a BLAS library
with integer arguments of default kind (32 bits). It cannot be used
together with @option{-fexternal-blas64}.

@opindex fexternal-blas64
@item -fexternal-blas64
makes @command{gfortran} generate calls to BLAS functions
for some matrix operations like @code{MATMUL}, instead of using our own
algorithms, if the size of the matrices involved is larger than a given
limit (see @option{-fblas-matmul-limit}).  This may be profitable if an
optimized vendor BLAS library is available.  The BLAS library has
to be specified at link time.  This option specifies a BLAS library
with integer arguments of @code{KIND=8} (64 bits). It cannot be used
together with @option{-fexternal-blas}, and requires a 64-bit system.
This option also requires @option{-ffrontend-optimize}.

@opindex fblas-matmul-limit
@item -fblas-matmul-limit=@var{n}
Only significant when @option{-fexternal-blas} or @option{-fexternal-blas64}
are in effect. Matrix multiplication of matrices with size larger than or equal
to @var{n} is performed by calls to BLAS functions, while others are
handled by @command{gfortran} internal algorithms. If the matrices
involved are not square, the size comparison is performed using the
geometric mean of the dimensions of the argument and result matrices.

The default value for @var{n} is 30.

@opindex finline-intrinsics
@item -finline-intrinsics
@itemx -finline-intrinsics=@var{intr1},@var{intr2},...
Prefer generating inline code over calls to libgfortran functions to implement
intrinsics.

Usage of intrinsics can be implemented either by generating a call to the
libgfortran library function or by directly generating inline code.  For most
intrinsics, only a single variant is available, and there is no choice of
implementation.  However, some intrinsics can use a library function or inline
code, where inline code typically offers opportunities for additional
optimization over a library function.  With @code{-finline-intrinsics=...} or
@code{-fno-inline-intrinsics=...}, the choice applies only to the intrinsics
present in the comma-separated list provided as argument.

For each intrinsic, if no choice of implementation was made through either of
the flag variants, a default behavior is chosen depending on optimization:
library calls are generated when not optimizing or when optimizing for size;
otherwise inline code is preferred.

The set of intrinsics allowed as argument to @code{-finline-intrinsics=}
is currently limited to @code{MAXLOC} and @code{MINLOC}.  The effect of
the flag is moreover limited to calls of those intrinsics without
@code{DIM} argument and with @code{ARRAY} of a non-@code{CHARACTER} type.
The case of rank-1 argument and @code{DIM} argument present, i.e.
@code{MAXLOC(A(:),DIM=1)} or @code{MINLOC(A(:),DIM=1)} is inlined
unconditionally for numeric rank-1 array argument @code{A}.

@opindex finline-matmul-limit
@item -finline-matmul-limit=@var{n}
When front-end optimization is active, some calls to the @code{MATMUL}
intrinsic function are inlined.  This may result in code size
increase if the size of the matrix cannot be determined at compile
time, as code for both cases is generated.  Setting
@code{-finline-matmul-limit=0} disables inlining in all cases.
Setting this option with a value of @var{n} produces inline code
for matrices with size up to @var{n}. If the matrices involved are not
square, the size comparison is performed using the geometric mean of
the dimensions of the argument and result matrices.

The default value for @var{n} is 30.  The @code{-fblas-matmul-limit}
can be used to change this value.

@opindex frecursive
@item -frecursive
Allow indirect recursion by forcing all local arrays to be allocated
on the stack. This flag cannot be used together with
@option{-fmax-stack-var-size=} or @option{-fno-automatic}.

@opindex finit-local-zero
@opindex finit-derived
@opindex finit-integer
@opindex finit-real
@opindex finit-logical
@opindex finit-character
@item -finit-local-zero
@itemx -finit-derived
@itemx -finit-integer=@var{n}
@itemx -finit-real=<zero|inf|-inf|nan|snan>
@itemx -finit-logical=<true|false>
@itemx -finit-character=@var{n}
The @option{-finit-local-zero} option instructs the compiler to
initialize local @code{INTEGER}, @code{REAL}, and @code{COMPLEX}
variables to zero, @code{LOGICAL} variables to false, and
@code{CHARACTER} variables to a string of null bytes.  Finer-grained
initialization options are provided by the
@option{-finit-integer=@var{n}},
@option{-finit-real=<zero|inf|-inf|nan|snan>} (which also initializes
the real and imaginary parts of local @code{COMPLEX} variables),
@option{-finit-logical=<true|false>}, and
@option{-finit-character=@var{n}} (where @var{n} is an ASCII character
value) options.

With @option{-finit-derived}, components of derived type variables are
initialized according to these flags.  Components whose type is not covered by
an explicit @option{-finit-*} flag are treated as described above with
@option{-finit-local-zero}.

These options do not initialize
@itemize @bullet
@item
objects with the @code{POINTER} attribute
@item
allocatable arrays
@item
variables that appear in an @code{EQUIVALENCE} statement.
@end itemize
(These limitations may be removed in future releases).

Note that the @option{-finit-real=nan} option initializes @code{REAL}
and @code{COMPLEX} variables with a quiet NaN. For a signalling NaN
use @option{-finit-real=snan}; note, however, that compile-time
optimizations may convert them into quiet NaN and that trapping
needs to be enabled (e.g. via @option{-ffpe-trap}).

The @option{-finit-integer} option parses the value into an
integer of type @code{INTEGER(kind=C_LONG)} on the host.  Said value
is then assigned to the integer variables in the Fortran code, which
might result in wraparound if the value is too large for the kind.

Finally, note that enabling any of the @option{-finit-*} options
silences warnings that would have been emitted by @option{-Wuninitialized}
for the affected local variables.

@opindex falign-commons
@cindex alignment of @code{COMMON} blocks
@item -falign-commons
By default, @command{gfortran} enforces proper alignment of all variables in a
@code{COMMON} block by padding them as needed. On certain platforms this is mandatory,
on others it increases performance. If a @code{COMMON} block is not declared with
consistent data types everywhere, this padding can cause trouble, and
@option{-fno-align-commons} can be used to disable automatic alignment. The
same form of this option should be used for all files that share a @code{COMMON} block.
To avoid potential alignment issues in @code{COMMON} blocks, it is recommended to order
objects from largest to smallest.

@opindex fno-protect-parens
@cindex reassociation of parenthesized expressions
@item -fno-protect-parens
By default the parentheses in expression are honored for all optimization
levels such that the compiler does not do any reassociation. Using
@option{-fno-protect-parens} allows the compiler to reorder @code{REAL} and
@code{COMPLEX} expressions to produce faster code. Note that for the reassociation
optimization @option{-fno-signed-zeros} and @option{-fno-trapping-math}
need to be in effect. The parentheses protection is enabled by default, unless
@option{-Ofast} is given.

@opindex frealloc-lhs
@cindex Reallocate the LHS in assignments
@item -frealloc-lhs
An allocatable left-hand side of an intrinsic assignment is automatically
(re)allocated if it is either unallocated or has a different shape. The
option is enabled by default except when @option{-std=f95} is given. See
also @option{-Wrealloc-lhs}.

@opindex faggressive-function-elimination
@cindex Elimination of functions with identical argument lists
@item -faggressive-function-elimination
Functions with identical argument lists are eliminated within
statements, regardless of whether these functions are marked
@code{PURE} or not. For example, in
@smallexample
  a = f(b,c) + f(b,c)
@end smallexample
@noindent
there is only a single call to @code{f}.  This option only works
if @option{-ffrontend-optimize} is in effect.

@opindex frontend-optimize
@cindex Front-end optimization
@item -ffrontend-optimize
This option performs front-end optimization, based on manipulating
parts of the Fortran parse tree.  Enabled by default by any @option{-O} option
except @option{-O0} and @option{-Og}.  Optimizations enabled by this option
include:
@itemize @bullet
@item inlining calls to @code{MATMUL},
@item elimination of identical function calls within expressions,
@item removing unnecessary calls to @code{TRIM} in comparisons and assignments,
@item replacing @code{TRIM(a)} with @code{a(1:LEN_TRIM(a))} and
@item short-circuiting of logical operators (@code{.AND.} and @code{.OR.}).
@end itemize
It can be deselected by specifying @option{-fno-frontend-optimize}.

@opindex frontend-loop-interchange
@cindex loop interchange, Fortran
@item -ffrontend-loop-interchange
Attempt to interchange loops in the Fortran front end where
profitable.  Enabled by default by any @option{-O} option.
At the moment, this option only affects @code{FORALL} and
@code{DO CONCURRENT} statements with several forall triplets.
@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 back end
shared by @command{gfortran}, @command{gcc}, and other GNU compilers.

@c man end

@node Interoperability Options
@section Options for interoperability with other languages

@table @gcctabopt

@opindex fc-prototypes
@cindex Generating C prototypes from Fortran BIND(C) enteties
@item -fc-prototypes
This option generates C prototypes from @code{BIND(C)} variable
declarations, types and procedure interfaces and writes them to
standard output.  @code{ENUM} is not yet supported.

The generated prototypes may need inclusion of an appropriate header,
such as @code{<stdint.h>} or @code{<stdlib.h>}.  For types that are
not specified using the appropriate kind from the @code{iso_c_binding}
module, a warning is added as a comment to the code.

For function pointers, a pointer to a function returning @code{int}
without an explicit argument list is generated.

Example of use:
@smallexample
$ gfortran -fc-prototypes -fsyntax-only foo.f90 > foo.h
@end smallexample
@noindent
where the C code intended for interoperating with the Fortran code
then uses @code{#include "foo.h"}.

@opindex fc-prototypes-external
@cindex Generating C prototypes from external procedures
@item -fc-prototypes-external
This option generates C prototypes from external functions and
subroutines and writes them to standard output.  This may be useful for
making sure that C bindings to Fortran code are correct.  This option
does not generate prototypes for @code{BIND(C)} procedures; use
@option{-fc-prototypes} for that.

The generated prototypes may need inclusion of an appropriate
header, such as @code{<stdint.h>} or @code{<stdlib.h>}.

This is primarily meant for legacy code to ensure that existing C
bindings match what @command{gfortran} emits.  The generated C
prototypes should be correct for the current version of the compiler,
but may not match what other compilers or earlier versions of
@command{gfortran} need.  For new development, use of the
@code{BIND(C)} features is recommended.

Example of use:
@smallexample
$ gfortran -fc-prototypes-external -fsyntax-only foo.f > foo.h
@end smallexample
@noindent
where the C code intended for interoperating with the Fortran code
then uses @code{#include "foo.h"}.
@end table

@node Environment Variables
@section Environment variables affecting @command{gfortran}
@cindex environment variable

@c man begin ENVIRONMENT

The @command{gfortran} compiler 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.

@xref{Runtime}, for environment variables that affect the
run-time behavior of programs compiled with GNU Fortran.
@c man end

@node Shared-memory Coarrays
@section Shared-memory Coarrays

@c man begin SHARED-MEMORY COARRAYS

@command{gfortran} supplies a runtime library for running coarray-enabled
programs using a shared-memory multiprocess approach.  The library is supplied
as a static link library with the @command{libgfortran} library, and is fully
compatible with the ABI enabled when @command{gfortran} is invoked with
@option{-fcoarray=lib}.  Link the shared-memory coarray to the executable
produced by @command{gfortran} using @option{-lcaf_shmem}.

The library @code{caf_shmem} can only be used on architectures that allow
multiple processes to use the same memory at the same virtual memory address in
each process' memory space.  This is the case on most Unix- and Windows-based
systems.

One can control some aspects of the library behavior at run time using
environment variables:

@env{GFORTRAN_NUM_IMAGES}: The number of images to spawn when running the
executable.  Note, there is always one additional supervisor process, which
does not participate in the computation, but is only responsible for starting
the images and catching any (ab-)normal termination.  When the environment
variable is not set, then the number of hardware threads reported by the OS is
used. Over-provisioning is possible.  The number of images is limited only
by the OS and the size of an integer variable on the architecture the program is
running on.

@env{GFORTRAN_SHARED_MEMORY_SIZE}: The size of the shared-memory segment made
available to all images is fixed and needs to be set at program start.  It
cannot grow or shrink.  The size can be given in bytes (no suffix), kilobytes
(@code{k} or @code{K} suffix), megabytes (@code{m} or @code{M}) or gigabytes
(@code{g} or @code{G}).  If the variable is not set, or not parseable, then on
32-bit architectures 2^28 bytes and on 64-bit 2^34 bytes are chosen.  Note,
although the size is set, most modern systems do not allocate the memory at
program start.  This allows one to choose a shared-memory size larger than
available memory.

Warning: Choosing a large shared-memory size may produce large core dumps!

@env{GFORTRAN_IMAGE_RESTARTS_LIMIT}: On certain platforms, esp. MacOS, the
shared-memory segment needs to be placed on the same (virtual) address in every
image or synchronization primitives do not work as expected.  Unfortunately some
operating systems are somewhat arbitrary on when they can do this.  When the OS
is not able to fulfill the request, the image aborts itself and is restarted by the
supervisor until the OS complies.  This environment variable limits the total
number of restarts of all images having an issue with shared-memory segment
placement.  The default value is 4000.

The shared-memory coarray library internally uses some additional environment
variables, which are overwritten without notice or may result in failure to
start.  These are: @code{GFORTRAN_IMAGE_NUM}, @code{GFORTRAN_SHMEM_PID}, and
@code{GFORTRAN_SHMEM_BASE}.  Using these variables is strongly discouraged.
Special care needs to be taken when one coarray program starts another coarray
program as a child process.  In this case it is the spawning process'
responsibility to remove the above variables from the environment.

@c man end

