]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/fortran/invoke.texi
* config/i386/i386.md (@cmp<mode>_1): Rename from cmp<mode>_1.
[thirdparty/gcc.git] / gcc / fortran / invoke.texi
CommitLineData
3d8932fd 1@c Copyright (C) 2004-2019 Free Software Foundation, Inc.
61156d26 2@c This is part of the GNU Fortran manual.
4ee9c684 3@c For copying conditions, see the file gfortran.texi.
4
5@ignore
6@c man begin COPYRIGHT
3d8932fd 7Copyright @copyright{} 2004-2019 Free Software Foundation, Inc.
4ee9c684 8
9Permission is granted to copy, distribute and/or modify this document
2d0c81dc 10under the terms of the GNU Free Documentation License, Version 1.3 or
4ee9c684 11any later version published by the Free Software Foundation; with the
a4cb9727 12Invariant Sections being ``Funding Free Software'', the Front-Cover
13Texts being (a) (see below), and with the Back-Cover Texts being (b)
14(see below). A copy of the license is included in the gfdl(7) man page.
c24c5fac 15
4ee9c684 16(a) The FSF's Front-Cover Text is:
17
18 A GNU Manual
19
20(b) The FSF's Back-Cover Text is:
21
22 You have freedom to copy and modify this GNU Manual, like GNU
23 software. Copies published by the Free Software Foundation raise
24 funds for GNU development.
25@c man end
26@c Set file name and title for the man page.
27@setfilename gfortran
61156d26 28@settitle GNU Fortran compiler.
4ee9c684 29@c man begin SYNOPSIS
30gfortran [@option{-c}|@option{-S}|@option{-E}]
31 [@option{-g}] [@option{-pg}] [@option{-O}@var{level}]
32 [@option{-W}@var{warn}@dots{}] [@option{-pedantic}]
33 [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
34 [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}]
35 [@option{-f}@var{option}@dots{}]
c24c5fac 36 [@option{-m}@var{machine-option}@dots{}]
4ee9c684 37 [@option{-o} @var{outfile}] @var{infile}@dots{}
38
39Only the most useful options are listed here; see below for the
40remainder.
41@c man end
42@c man begin SEEALSO
43gpl(7), gfdl(7), fsf-funding(7),
4c52ff7a 44cpp(1), gcov(1), gcc(1), as(1), ld(1), gdb(1), dbx(1)
4ee9c684 45and the Info entries for @file{gcc}, @file{cpp}, @file{gfortran}, @file{as},
46@file{ld}, @file{binutils} and @file{gdb}.
47@c man end
48@c man begin BUGS
49For instructions on reporting bugs, see
d25dc80e 50@w{@value{BUGURL}}.
4ee9c684 51@c man end
52@c man begin AUTHOR
53See the Info entry for @command{gfortran} for contributors to GCC and
61156d26 54GNU Fortran.
4ee9c684 55@c man end
56@end ignore
57
61156d26 58@node Invoking GNU Fortran
59@chapter GNU Fortran Command Options
60@cindex GNU Fortran command options
4ee9c684 61@cindex command options
61156d26 62@cindex options, @command{gfortran} command
4ee9c684 63
64@c man begin DESCRIPTION
65
66The @command{gfortran} command supports all the options supported by the
2d76519f 67@command{gcc} command. Only options specific to GNU Fortran are documented
68here.
4ee9c684 69
70@xref{Invoking GCC,,GCC Command Options,gcc,Using the GNU Compiler
71Collection (GCC)}, for information
72on the non-Fortran-specific aspects of the @command{gcc} command (and,
73therefore, the @command{gfortran} command).
74
75@cindex options, negative forms
61156d26 76All GCC and GNU Fortran options
4ee9c684 77are accepted both by @command{gfortran} and by @command{gcc}
78(as well as any other drivers built at the same time,
79such as @command{g++}),
61156d26 80since adding GNU Fortran to the GCC distribution
81enables acceptance of GNU Fortran options
4ee9c684 82by all of the relevant drivers.
83
84In some cases, options have positive and negative forms;
85the negative form of @option{-ffoo} would be @option{-fno-foo}.
86This manual documents only one of these two forms, whichever
87one is not the default.
88@c man end
89
90@menu
91* Option Summary:: Brief list of all @command{gfortran} options,
92 without explanations.
93* Fortran Dialect Options:: Controlling the variant of Fortran language
94 compiled.
2ecc6bc5 95* Preprocessing Options:: Enable and customize preprocessing.
641096f2 96* Error and Warning Options:: How picky should the compiler be?
4ee9c684 97* Debugging Options:: Symbol tables, measurements, and debugging dumps.
98* Directory Options:: Where to find module files
618e262b 99* Link Options :: Influencing the linking step
15774a8b 100* Runtime Options:: Influencing runtime behavior
4ee9c684 101* Code Gen Options:: Specifying conventions for function calls, data layout
102 and register usage.
41084313 103* Interoperability Options:: Options for interoperability with other
104 languages.
138b8aca 105* Environment Variables:: Environment variables that affect @command{gfortran}.
4ee9c684 106@end menu
107
108@node Option Summary
138b8aca 109@section Option summary
4ee9c684 110
111@c man begin OPTIONS
112
113Here is a summary of all the options specific to GNU Fortran, grouped
114by type. Explanations are in the following sections.
115
116@table @emph
117@item Fortran Language Options
138b8aca 118@xref{Fortran Dialect Options,,Options controlling Fortran dialect}.
2d76519f 119@gccoptlist{-fall-intrinsics -fbackslash -fcray-pointer -fd-lines-as-code @gol
647551f1 120-fd-lines-as-comments -fdec -fdec-structure -fdec-intrinsic-ints @gol
121-fdec-static -fdec-math -fdec-include -fdec-format-defaults @gol
122-fdefault-double-8 -fdefault-integer-8 -fdefault-real-8 -fdefault-real-10 @gol
123-fdefault-real-16 -fdollar-ok -ffixed-line-length-@var{n} @gol
124-ffixed-line-length-none -fpad-source -ffree-form @gol
125-ffree-line-length-@var{n} -ffree-line-length-none @gol
126-fimplicit-none -finteger-4-integer-8 -fmax-identifier-length @gol
127-fmodule-private -ffixed-form -fno-range-check -fopenacc -fopenmp @gol
128-freal-4-real-10 -freal-4-real-16 -freal-4-real-8 -freal-8-real-10 @gol
129-freal-8-real-16 -freal-8-real-4 -std=@var{std} -ftest-forall-temp
2d76519f 130}
4ee9c684 131
2ecc6bc5 132@item Preprocessing Options
133@xref{Preprocessing Options,,Enable and customize preprocessing}.
2d76519f 134@gccoptlist{-A-@var{question}@r{[}=@var{answer}@r{]}
135-A@var{question}=@var{answer} -C -CC -D@var{macro}@r{[}=@var{defn}@r{]}
136-H -P @gol
137-U@var{macro} -cpp -dD -dI -dM -dN -dU -fworking-directory
138-imultilib @var{dir} @gol
139-iprefix @var{file} -iquote -isysroot @var{dir} -isystem @var{dir} -nocpp
140-nostdinc @gol
141-undef
142}
2ecc6bc5 143
641096f2 144@item Error and Warning Options
138b8aca 145@xref{Error and Warning Options,,Options to request or suppress errors
146and warnings}.
2c8c2d4d 147@gccoptlist{-Waliasing -Wall -Wampersand -Wargument-mismatch -Warray-bounds
3eaed19a 148-Wc-binding-type -Wcharacter-truncation -Wconversion @gol
149-Wdo-subscript -Wfunction-elimination -Wimplicit-interface @gol
7cb96c5d 150-Wimplicit-procedure -Wintrinsic-shadow -Wuse-without-only -Wintrinsics-std @gol
2d76519f 151-Wline-truncation -Wno-align-commons -Wno-tabs -Wreal-q-constant @gol
44319903 152-Wsurprising -Wunderflow -Wunused-parameter -Wrealloc-lhs @gol
153-Wrealloc-lhs-all -Wfrontend-loop-interchange -Wtarget-lifetime @gol
154-fmax-errors=@var{n} -fsyntax-only -pedantic -pedantic-errors @gol
2d76519f 155}
4ee9c684 156
157@item Debugging Options
138b8aca 158@xref{Debugging Options,,Options for debugging your program or GNU Fortran}.
2d76519f 159@gccoptlist{-fbacktrace -fdump-fortran-optimized -fdump-fortran-original @gol
553e7cef 160-fdump-parse-tree -ffpe-trap=@var{list} -ffpe-summary=@var{list}
2d76519f 161}
4ee9c684 162
163@item Directory Options
138b8aca 164@xref{Directory Options,,Options for directory search}.
d826a69b 165@gccoptlist{-I@var{dir} -J@var{dir} -fintrinsic-modules-path @var{dir}}
4ee9c684 166
618e262b 167@item Link Options
168@xref{Link Options,,Options for influencing the linking step}.
169@gccoptlist{-static-libgfortran}
170
15774a8b 171@item Runtime Options
172@xref{Runtime Options,,Options for influencing runtime behavior}.
7f4f15dc 173@gccoptlist{-fconvert=@var{conversion} -fmax-subrecord-length=@var{length} @gol
2d76519f 174-frecord-marker=@var{length} -fsign-zero
175}
15774a8b 176
41084313 177@item Interoperability Options
178@xref{Interoperability Options,,Options for interoperability}.
6d658980 179@gccoptlist{-fc-prototypes -fc-prototypes-external}
41084313 180
4ee9c684 181@item Code Generation Options
138b8aca 182@xref{Code Gen Options,,Options for code generation conventions}.
2d76519f 183@gccoptlist{-faggressive-function-elimination -fblas-matmul-limit=@var{n} @gol
d7233bac 184-fbounds-check -ftail-call-workaround -ftail-call-workaround=@var{n} @gol
185-fcheck-array-temporaries @gol
76daec3c 186-fcheck=@var{<all|array-temps|bounds|do|mem|pointer|recursion>} @gol
2d76519f 187-fcoarray=@var{<none|single|lib>} -fexternal-blas -ff2c
44319903 188-ffrontend-loop-interchange @gol
2d76519f 189-ffrontend-optimize @gol
190-finit-character=@var{n} -finit-integer=@var{n} -finit-local-zero @gol
36d310d0 191-finit-derived @gol
2d76519f 192-finit-logical=@var{<true|false>}
193-finit-real=@var{<zero|inf|-inf|nan|snan>} @gol
08f351fd 194-finline-matmul-limit=@var{n} @gol
2d76519f 195-fmax-array-constructor=@var{n} -fmax-stack-var-size=@var{n}
196-fno-align-commons @gol
044bbd71 197-fno-automatic -fno-protect-parens -fno-underscoring @gol
2d76519f 198-fsecond-underscore -fpack-derived -frealloc-lhs -frecursive @gol
199-frepack-arrays -fshort-enums -fstack-arrays
200}
4ee9c684 201@end table
202
4ee9c684 203@node Fortran Dialect Options
138b8aca 204@section Options controlling Fortran dialect
4ee9c684 205@cindex dialect options
206@cindex language, dialect options
207@cindex options, dialect
208
c9a7f17f 209The following options control the details of the Fortran dialect
210accepted by the compiler:
4ee9c684 211
212@table @gcctabopt
5e246457 213@item -ffree-form
67c11f5d 214@itemx -ffixed-form
7d17e6c7 215@opindex @code{ffree-form}
d76862c8 216@opindex @code{ffixed-form}
60472a3b 217@cindex options, Fortran dialect
a1149005 218@cindex file format, free
219@cindex file format, fixed
89d91d02 220Specify the layout used by the source file. The free form layout
4ee9c684 221was introduced in Fortran 90. Fixed form was traditionally used in
c9a7f17f 222older Fortran programs. When neither option is specified, the source
223form is determined by the file extension.
4ee9c684 224
d52febd5 225@item -fall-intrinsics
7d17e6c7 226@opindex @code{fall-intrinsics}
57b9ac90 227This option causes all intrinsic procedures (including the GNU-specific
228extensions) to be accepted. This can be useful with @option{-std=f95} to
229force standard-compliance but get access to the full range of intrinsics
230available with @command{gfortran}. As a consequence, @option{-Wintrinsics-std}
231will be ignored and no user-defined procedure with the same name as any
232intrinsic will be called except when it is explicitly declared @code{EXTERNAL}.
d52febd5 233
8594da07 234@item -fd-lines-as-code
67c11f5d 235@itemx -fd-lines-as-comments
7d17e6c7 236@opindex @code{fd-lines-as-code}
237@opindex @code{fd-lines-as-comments}
5e246457 238Enable special treatment for lines beginning with @code{d} or @code{D}
c9a7f17f 239in fixed form sources. If the @option{-fd-lines-as-code} option is
240given they are treated as if the first column contained a blank. If the
8594da07 241@option{-fd-lines-as-comments} option is given, they are treated as
242comment lines.
243
d7cd448a 244@item -fdec
245@opindex @code{fdec}
246DEC compatibility mode. Enables extensions and other features that mimic
247the default behavior of older compilers (such as DEC).
248These features are non-standard and should be avoided at all costs.
cf078427 249For details on GNU Fortran's implementation of these extensions see the
d7cd448a 250full documentation.
251
252Other flags enabled by this switch are:
253@option{-fdollar-ok} @option{-fcray-pointer} @option{-fdec-structure}
cf078427 254@option{-fdec-intrinsic-ints} @option{-fdec-static} @option{-fdec-math}
255
256If @option{-fd-lines-as-code}/@option{-fd-lines-as-comments} are unset, then
257@option{-fdec} also sets @option{-fd-lines-as-comments}.
d7cd448a 258
259@item -fdec-structure
260@opindex @code{fdec-structure}
261Enable DEC @code{STRUCTURE} and @code{RECORD} as well as @code{UNION},
262@code{MAP}, and dot ('.') as a member separator (in addition to '%'). This is
263provided for compatibility only; Fortran 90 derived types should be used
264instead where possible.
265
278b4698 266@item -fdec-intrinsic-ints
267@opindex @code{fdec-intrinsic-ints}
268Enable B/I/J/K kind variants of existing integer functions (e.g. BIAND, IIAND,
269JIAND, etc...). For a complete list of intrinsics see the full documentation.
270
f9d86318 271@item -fdec-math
272@opindex @code{fdec-math}
273Enable legacy math intrinsics such as COTAN and degree-valued trigonometric
274functions (e.g. TAND, ATAND, etc...) for compatability with older code.
275
8e652fcf 276@item -fdec-static
277@opindex @code{fdec-static}
278Enable DEC-style STATIC and AUTOMATIC attributes to explicitly specify
279the storage of variables and other objects.
280
442cb64f 281@item -fdec-include
282@opindex @code{fdec-include}
283Enable parsing of INCLUDE as a statement in addition to parsing it as
284INCLUDE line. When parsed as INCLUDE statement, INCLUDE does not have to
285be on a single line and can use line continuations.
286
647551f1 287@item -fdec-format-defaults
288@opindex @code{fdec-format-defaults}
289Enable format specifiers F, G and I to be used without width specifiers,
290default widths will be used instead.
291
4ee9c684 292@item -fdollar-ok
7d17e6c7 293@opindex @code{fdollar-ok}
12786727 294@cindex @code{$}
4ee9c684 295@cindex symbol names
296@cindex character set
fee96e90 297Allow @samp{$} as a valid non-first character in a symbol name. Symbols
298that start with @samp{$} are rejected since it is unclear which rules to
dd34c843 299apply to implicit typing as different vendors implement different rules.
30186817 300Using @samp{$} in @code{IMPLICIT} statements is also rejected.
4ee9c684 301
0e0aee06 302@item -fbackslash
303@opindex @code{backslash}
2467f78d 304@cindex backslash
305@cindex escape characters
e0be6f02 306Change the interpretation of backslashes in string literals from a single
307backslash character to ``C-style'' escape characters. The following
308combinations are expanded @code{\a}, @code{\b}, @code{\f}, @code{\n},
309@code{\r}, @code{\t}, @code{\v}, @code{\\}, and @code{\0} to the ASCII
310characters alert, backspace, form feed, newline, carriage return,
311horizontal tab, vertical tab, backslash, and NUL, respectively.
312Additionally, @code{\x}@var{nn}, @code{\u}@var{nnnn} and
313@code{\U}@var{nnnnnnnn} (where each @var{n} is a hexadecimal digit) are
314translated into the Unicode characters corresponding to the specified code
315points. All other combinations of a character preceded by \ are
316unexpanded.
2467f78d 317
ef63afed 318@item -fmodule-private
319@opindex @code{fmodule-private}
320@cindex module entities
321@cindex private
322Set the default accessibility of module entities to @code{PRIVATE}.
323Use-associated entities will not be accessible unless they are explicitly
324declared as @code{PUBLIC}.
325
4ee9c684 326@item -ffixed-line-length-@var{n}
7d17e6c7 327@opindex @code{ffixed-line-length-}@var{n}
a1149005 328@cindex file format, fixed
4ee9c684 329Set column after which characters are ignored in typical fixed-form
063f7a4a 330lines in the source file, and, unless @code{-fno-pad-source}, through which
331spaces are assumed (as if padded to that length) after the ends of short
332fixed-form lines.
4ee9c684 333
4ee9c684 334Popular values for @var{n} include 72 (the
c9a7f17f 335standard and the default), 80 (card image), and 132 (corresponding
4ee9c684 336to ``extended-source'' options in some popular compilers).
c9a7f17f 337@var{n} may also be @samp{none}, meaning that the entire line is meaningful
4ee9c684 338and that continued character constants never have implicit spaces appended
339to them to fill out the line.
340@option{-ffixed-line-length-0} means the same thing as
341@option{-ffixed-line-length-none}.
342
063f7a4a 343@item -fno-pad-source
344@opindex @code{fpad-source}
345By default fixed-form lines have spaces assumed (as if padded to that length)
346after the ends of short fixed-form lines. This is not done either if
347@option{-ffixed-line-length-0}, @option{-ffixed-line-length-none} or
348if @option{-fno-pad-source} option is used. With any of those options
349continued character constants never have implicit spaces appended
350to them to fill out the line.
351
83016156 352@item -ffree-line-length-@var{n}
7d17e6c7 353@opindex @code{ffree-line-length-}@var{n}
a1149005 354@cindex file format, free
83016156 355Set column after which characters are ignored in typical free-form
c9a7f17f 356lines in the source file. The default value is 132.
83016156 357@var{n} may be @samp{none}, meaning that the entire line is meaningful.
358@option{-ffree-line-length-0} means the same thing as
359@option{-ffree-line-length-none}.
360
4ee9c684 361@item -fmax-identifier-length=@var{n}
7d17e6c7 362@opindex @code{fmax-identifier-length=}@var{n}
4ee9c684 363Specify the maximum allowed identifier length. Typical values are
ff4425cf 36431 (Fortran 95) and 63 (Fortran 2003 and Fortran 2008).
4ee9c684 365
4ee9c684 366@item -fimplicit-none
7d17e6c7 367@opindex @code{fimplicit-none}
4ee9c684 368Specify that no implicit typing is allowed, unless overridden by explicit
36348e43 369@code{IMPLICIT} statements. This is the equivalent of adding
370@code{implicit none} to the start of every procedure.
4ee9c684 371
b549d2a5 372@item -fcray-pointer
7d17e6c7 373@opindex @code{fcray-pointer}
c9a7f17f 374Enable the Cray pointer extension, which provides C-like pointer
375functionality.
b549d2a5 376
ca4c3545 377@item -fopenacc
378@opindex @code{fopenacc}
379@cindex OpenACC
380Enable the OpenACC extensions. This includes OpenACC @code{!$acc}
381directives in free form and @code{c$acc}, @code{*$acc} and
382@code{!$acc} directives in fixed form, @code{!$} conditional
383compilation sentinels in free form and @code{c$}, @code{*$} and
384@code{!$} sentinels in fixed form, and when linking arranges for the
385OpenACC runtime library to be linked in.
386
387Note that this is an experimental feature, incomplete, and subject to
388change in future versions of GCC. See
389@w{@uref{https://gcc.gnu.org/wiki/OpenACC}} for more information.
390
764f1175 391@item -fopenmp
7d17e6c7 392@opindex @code{fopenmp}
920c1373 393@cindex OpenMP
c9a7f17f 394Enable the OpenMP extensions. This includes OpenMP @code{!$omp} directives
395in free form
764f1175 396and @code{c$omp}, @code{*$omp} and @code{!$omp} directives in fixed form,
c9a7f17f 397@code{!$} conditional compilation sentinels in free form
398and @code{c$}, @code{*$} and @code{!$} sentinels in fixed form,
764f1175 399and when linking arranges for the OpenMP runtime library to be linked
14af4f75 400in. The option @option{-fopenmp} implies @option{-frecursive}.
764f1175 401
af927157 402@item -fno-range-check
7d17e6c7 403@opindex @code{frange-check}
af927157 404Disable range checking on results of simplification of constant
24128aa2 405expressions during compilation. For example, GNU Fortran will give
406an error at compile time when simplifying @code{a = 1. / 0}.
407With this option, no error will be given and @code{a} will be assigned
408the value @code{+Infinity}. If an expression evaluates to a value
409outside of the relevant range of [@code{-HUGE()}:@code{HUGE()}],
410then the expression will be replaced by @code{-Inf} or @code{+Inf}
411as appropriate.
36348e43 412Similarly, @code{DATA i/Z'FFFFFFFF'/} will result in an integer overflow
413on most systems, but with @option{-fno-range-check} the value will
414``wrap around'' and @code{i} will be initialized to @math{-1} instead.
09638e2c 415
d24beaab 416@item -fdefault-integer-8
417@opindex @code{fdefault-integer-8}
5ea63909 418Set the default integer and logical types to an 8 byte wide type. This option
419also affects the kind of integer constants like @code{42}. Unlike
1ebeebc2 420@option{-finteger-4-integer-8}, it does not promote variables with explicit
421kind declaration.
d24beaab 422
423@item -fdefault-real-8
424@opindex @code{fdefault-real-8}
5851d123 425Set the default real type to an 8 byte wide type. This option also affects
426the kind of non-double real constants like @code{1.0}. This option promotes
427the default width of @code{DOUBLE PRECISION} and double real constants
428like @code{1.d0} to 16 bytes if possible. If @code{-fdefault-double-8}
429is given along with @code{fdefault-real-8}, @code{DOUBLE PRECISION}
430and double real constants are not promoted. Unlike @option{-freal-4-real-8},
431@code{fdefault-real-8} does not promote variables with explicit kind
432declarations.
d24beaab 433
51b237e3 434@item -fdefault-real-10
435@opindex @code{fdefault-real-10}
5851d123 436Set the default real type to an 10 byte wide type. This option also affects
437the kind of non-double real constants like @code{1.0}. This option promotes
438the default width of @code{DOUBLE PRECISION} and double real constants
439like @code{1.d0} to 16 bytes if possible. If @code{-fdefault-double-8}
440is given along with @code{fdefault-real-10}, @code{DOUBLE PRECISION}
441and double real constants are not promoted. Unlike @option{-freal-4-real-10},
442@code{fdefault-real-10} does not promote variables with explicit kind
443declarations.
51b237e3 444
445@item -fdefault-real-16
446@opindex @code{fdefault-real-16}
5851d123 447Set the default real type to an 16 byte wide type. This option also affects
448the kind of non-double real constants like @code{1.0}. This option promotes
449the default width of @code{DOUBLE PRECISION} and double real constants
450like @code{1.d0} to 16 bytes if possible. If @code{-fdefault-double-8}
451is given along with @code{fdefault-real-16}, @code{DOUBLE PRECISION}
452and double real constants are not promoted. Unlike @option{-freal-4-real-16},
453@code{fdefault-real-16} does not promote variables with explicit kind
454declarations.
51b237e3 455
d24beaab 456@item -fdefault-double-8
457@opindex @code{fdefault-double-8}
5851d123 458Set the @code{DOUBLE PRECISION} type and double real constants
459like @code{1.d0} to an 8 byte wide type. Do nothing if this
460is already the default. This option prevents @option{-fdefault-real-8},
461@option{-fdefault-real-10}, and @option{-fdefault-real-16},
462from promoting @code{DOUBLE PRECISION} and double real constants like
463@code{1.d0} to 16 bytes.
d24beaab 464
465@item -finteger-4-integer-8
466@opindex @code{finteger-4-integer-8}
467Promote all @code{INTEGER(KIND=4)} entities to an @code{INTEGER(KIND=8)}
468entities. If @code{KIND=8} is unavailable, then an error will be issued.
469This option should be used with care and may not be suitable for your codes.
470Areas of possible concern include calls to external procedures,
471alignment in @code{EQUIVALENCE} and/or @code{COMMON}, generic interfaces,
472BOZ literal constant conversion, and I/O. Inspection of the intermediate
473representation of the translated Fortran code, produced by
474@option{-fdump-tree-original}, is suggested.
475
2d76519f 476@item -freal-4-real-8
477@itemx -freal-4-real-10
d24beaab 478@itemx -freal-4-real-16
2d76519f 479@itemx -freal-8-real-4
480@itemx -freal-8-real-10
481@itemx -freal-8-real-16
482@opindex @code{freal-4-real-8}
483@opindex @code{freal-4-real-10}
484@opindex @code{freal-4-real-16}
485@opindex @code{freal-8-real-4}
486@opindex @code{freal-8-real-10}
487@opindex @code{freal-8-real-16}
488@cindex options, real kind type promotion
489Promote all @code{REAL(KIND=M)} entities to @code{REAL(KIND=N)} entities.
490If @code{REAL(KIND=N)} is unavailable, then an error will be issued.
491All other real kind types are unaffected by this option.
492These options should be used with care and may not be suitable for your
493codes. Areas of possible concern include calls to external procedures,
494alignment in @code{EQUIVALENCE} and/or @code{COMMON}, generic interfaces,
495BOZ literal constant conversion, and I/O. Inspection of the intermediate
496representation of the translated Fortran code, produced by
497@option{-fdump-tree-original}, is suggested.
498
4ee9c684 499@item -std=@var{std}
7d17e6c7 500@opindex @code{std=}@var{std} option
003e134b 501Specify the standard to which the program is expected to conform,
502which may be one of @samp{f95}, @samp{f2003}, @samp{f2008},
503@samp{f2018}, @samp{gnu}, or @samp{legacy}. The default value for
504@var{std} is @samp{gnu}, which specifies a superset of the latest
505Fortran standard that includes all of the extensions supported by GNU
506Fortran, although warnings will be given for obsolete extensions not
507recommended for use in new code. The @samp{legacy} value is
508equivalent but without the warnings for obsolete extensions, and may
509be useful for old non-standard programs. The @samp{f95},
510@samp{f2003}, @samp{f2008}, and @samp{f2018} values specify strict
511conformance to the Fortran 95, Fortran 2003, Fortran 2008 and Fortran
5122018 standards, respectively; errors are given for all extensions
513beyond the relevant language standard, and warnings are given for the
514Fortran 77 features that are permitted but obsolescent in later
2e2156cf 515standards. The deprecated option @samp{-std=f2008ts} acts as an alias for
516@samp{-std=f2018}. It is only present for backwards compatibility with
517earlier gfortran versions and should not be used any more.
4ee9c684 518
0c8faf56 519@item -ftest-forall-temp
520@opindex @code{ftest-forall-temp}
521Enhance test coverage by forcing most forall assignments to use temporary.
522
4ee9c684 523@end table
524
2ecc6bc5 525@node Preprocessing Options
526@section Enable and customize preprocessing
527@cindex preprocessor
528@cindex options, preprocessor
529@cindex CPP
530
531Preprocessor related options. See section
532@ref{Preprocessing and conditional compilation} for more detailed
533information on preprocessing in @command{gfortran}.
534
535@table @gcctabopt
536@item -cpp
67c11f5d 537@itemx -nocpp
2ecc6bc5 538@opindex @code{cpp}
539@opindex @code{fpp}
540@cindex preprocessor, enable
541@cindex preprocessor, disable
542Enable preprocessing. The preprocessor is automatically invoked if
543the file extension is @file{.fpp}, @file{.FPP}, @file{.F}, @file{.FOR},
544@file{.FTN}, @file{.F90}, @file{.F95}, @file{.F03} or @file{.F08}. Use
545this option to manually enable preprocessing of any kind of Fortran file.
546
547To disable preprocessing of files with any of the above listed extensions,
548use the negative form: @option{-nocpp}.
549
9aa131da 550The preprocessor is run in traditional mode. Any restrictions of the
551file-format, especially the limits on line length, apply for
552preprocessed output as well, so it might be advisable to use the
553@option{-ffree-line-length-none} or @option{-ffixed-line-length-none}
554options.
2ecc6bc5 555
556@item -dM
557@opindex @code{dM}
558@cindex preprocessor, debugging
559@cindex debugging, preprocessor
560Instead of the normal output, generate a list of @code{'#define'}
561directives for all the macros defined during the execution of the
562preprocessor, including predefined macros. This gives you a way
563of finding out what is predefined in your version of the preprocessor.
564Assuming you have no file @file{foo.f90}, the command
565@smallexample
4a20136e 566 touch foo.f90; gfortran -cpp -E -dM foo.f90
2ecc6bc5 567@end smallexample
568will show all the predefined macros.
569
570@item -dD
571@opindex @code{dD}
572@cindex preprocessor, debugging
573@cindex debugging, preprocessor
574Like @option{-dM} except in two respects: it does not include the
575predefined macros, and it outputs both the @code{#define} directives
576and the result of preprocessing. Both kinds of output go to the
577standard output file.
578
579@item -dN
580@opindex @code{dN}
581@cindex preprocessor, debugging
582@cindex debugging, preprocessor
583Like @option{-dD}, but emit only the macro names, not their expansions.
584
585@item -dU
586@opindex @code{dU}
587@cindex preprocessor, debugging
588@cindex debugging, preprocessor
589Like @option{dD} except that only macros that are expanded, or whose
590definedness is tested in preprocessor directives, are output; the
591output is delayed until the use or test of the macro; and @code{'#undef'}
592directives are also output for macros tested but undefined at the time.
593
594@item -dI
595@opindex @code{dI}
596@cindex preprocessor, debugging
597@cindex debugging, preprocessor
598Output @code{'#include'} directives in addition to the result
599of preprocessing.
600
601@item -fworking-directory
602@opindex @code{fworking-directory}
603@cindex preprocessor, working directory
604Enable generation of linemarkers in the preprocessor output that will
605let the compiler know the current working directory at the time of
606preprocessing. When this option is enabled, the preprocessor will emit,
607after the initial linemarker, a second linemarker with the current
608working directory followed by two slashes. GCC will use this directory,
6152df27 609when it is present in the preprocessed input, as the directory emitted
2ecc6bc5 610as the current working directory in some debugging information formats.
611This option is implicitly enabled if debugging information is enabled,
612but this can be inhibited with the negated form
613@option{-fno-working-directory}. If the @option{-P} flag is present
614in the command line, this option has no effect, since no @code{#line}
615directives are emitted whatsoever.
616
7d2bb357 617@item -idirafter @var{dir}
618@opindex @code{idirafter @var{dir}}
619@cindex preprocessing, include path
620Search @var{dir} for include files, but do it after all directories
621specified with @option{-I} and the standard system directories have
622been exhausted. @var{dir} is treated as a system include directory.
623If dir begins with @code{=}, then the @code{=} will be replaced by
624the sysroot prefix; see @option{--sysroot} and @option{-isysroot}.
625
2ecc6bc5 626@item -imultilib @var{dir}
627@opindex @code{imultilib @var{dir}}
628@cindex preprocessing, include path
629Use @var{dir} as a subdirectory of the directory containing target-specific
630C++ headers.
631
632@item -iprefix @var{prefix}
633@opindex @code{iprefix @var{prefix}}
634@cindex preprocessing, include path
635Specify @var{prefix} as the prefix for subsequent @option{-iwithprefix}
636options. If the @var{prefix} represents a directory, you should include
637the final @code{'/'}.
638
639@item -isysroot @var{dir}
640@opindex @code{isysroot @var{dir}}
641@cindex preprocessing, include path
642This option is like the @option{--sysroot} option, but applies only to
643header files. See the @option{--sysroot} option for more information.
644
645@item -iquote @var{dir}
646@opindex @code{iquote @var{dir}}
647@cindex preprocessing, include path
648Search @var{dir} only for header files requested with @code{#include "file"};
649they are not searched for @code{#include <file>}, before all directories
650specified by @option{-I} and before the standard system directories. If
651@var{dir} begins with @code{=}, then the @code{=} will be replaced by the
652sysroot prefix; see @option{--sysroot} and @option{-isysroot}.
653
654@item -isystem @var{dir}
655@opindex @code{isystem @var{dir}}
656@cindex preprocessing, include path
657Search @var{dir} for header files, after all directories specified by
658@option{-I} but before the standard system directories. Mark it as a
659system directory, so that it gets the same special treatment as is
660applied to the standard system directories. If @var{dir} begins with
661@code{=}, then the @code{=} will be replaced by the sysroot prefix;
662see @option{--sysroot} and @option{-isysroot}.
663
664@item -nostdinc
665@opindex @code{nostdinc}
666Do not search the standard system directories for header files. Only
667the directories you have specified with @option{-I} options (and the
668directory of the current file, if appropriate) are searched.
669
670@item -undef
671@opindex @code{undef}
672Do not predefine any system-specific or GCC-specific macros.
673The standard predefined macros remain defined.
674
675@item -A@var{predicate}=@var{answer}
676@opindex @code{A@var{predicate}=@var{answer}}
67c11f5d 677@cindex preprocessing, assertion
2ecc6bc5 678Make an assertion with the predicate @var{predicate} and answer @var{answer}.
679This form is preferred to the older form -A predicate(answer), which is still
680supported, because it does not use shell special characters.
681
682@item -A-@var{predicate}=@var{answer}
683@opindex @code{A-@var{predicate}=@var{answer}}
67c11f5d 684@cindex preprocessing, assertion
2ecc6bc5 685Cancel an assertion with the predicate @var{predicate} and answer @var{answer}.
686
687@item -C
688@opindex @code{C}
689@cindex preprocessing, keep comments
690Do not discard comments. All comments are passed through to the output
691file, except for comments in processed directives, which are deleted
692along with the directive.
693
694You should be prepared for side effects when using @option{-C}; it causes
695the preprocessor to treat comments as tokens in their own right. For example,
696comments appearing at the start of what would be a directive line have the
697effect of turning that line into an ordinary source line, since the first
698token on the line is no longer a @code{'#'}.
699
700Warning: this currently handles C-Style comments only. The preprocessor
701does not yet recognize Fortran-style comments.
702
703@item -CC
704@opindex @code{CC}
705@cindex preprocessing, keep comments
706Do not discard comments, including during macro expansion. This is like
707@option{-C}, except that comments contained within macros are also passed
708through to the output file where the macro is expanded.
709
710In addition to the side-effects of the @option{-C} option, the @option{-CC}
711option causes all C++-style comments inside a macro to be converted to C-style
712comments. This is to prevent later use of that macro from inadvertently
713commenting out the remainder of the source line. The @option{-CC} option
714is generally used to support lint comments.
715
716Warning: this currently handles C- and C++-Style comments only. The
717preprocessor does not yet recognize Fortran-style comments.
718
719@item -D@var{name}
720@opindex @code{D@var{name}}
721@cindex preprocessing, define macros
722Predefine name as a macro, with definition @code{1}.
723
724@item -D@var{name}=@var{definition}
725@opindex @code{D@var{name}=@var{definition}}
726@cindex preprocessing, define macros
727The contents of @var{definition} are tokenized and processed as if they
728appeared during translation phase three in a @code{'#define'} directive.
729In particular, the definition will be truncated by embedded newline
730characters.
731
732If you are invoking the preprocessor from a shell or shell-like program
733you may need to use the shell's quoting syntax to protect characters such
734as spaces that have a meaning in the shell syntax.
735
736If you wish to define a function-like macro on the command line, write
737its argument list with surrounding parentheses before the equals sign
738(if any). Parentheses are meaningful to most shells, so you will need
739to quote the option. With sh and csh, @code{-D'name(args...)=definition'}
740works.
741
742@option{-D} and @option{-U} options are processed in the order they are
743given on the command line. All -imacros file and -include file options
744are processed after all -D and -U options.
745
746@item -H
747@opindex @code{H}
748Print the name of each header file used, in addition to other normal
749activities. Each name is indented to show how deep in the @code{'#include'}
750stack it is.
751
752@item -P
753@opindex @code{P}
754@cindex preprocessing, no linemarkers
755Inhibit generation of linemarkers in the output from the preprocessor.
756This might be useful when running the preprocessor on something that
757is not C code, and will be sent to a program which might be confused
758by the linemarkers.
759
760@item -U@var{name}
761@opindex @code{U@var{name}}
762@cindex preprocessing, undefine macros
763Cancel any previous definition of @var{name}, either built in or provided
764with a @option{-D} option.
765@end table
766
767
641096f2 768@node Error and Warning Options
138b8aca 769@section Options to request or suppress errors and warnings
4ee9c684 770@cindex options, warnings
641096f2 771@cindex options, errors
4ee9c684 772@cindex warnings, suppressing
641096f2 773@cindex messages, error
4ee9c684 774@cindex messages, warning
775@cindex suppressing warnings
776
641096f2 777Errors are diagnostic messages that report that the GNU Fortran compiler
778cannot compile the relevant piece of source code. The compiler will
779continue to process the program in an attempt to report further errors
780to aid in debugging, but will not produce any compiled output.
781
4ee9c684 782Warnings are diagnostic messages that report constructions which
641096f2 783are not inherently erroneous but which are risky or suggest there is
5e246457 784likely to be a bug in the program. Unless @option{-Werror} is specified,
641096f2 785they do not prevent compilation of the program.
4ee9c684 786
787You can request many specific warnings with options beginning @option{-W},
788for example @option{-Wimplicit} to request warnings on implicit
789declarations. Each of these specific warning options also has a
790negative form beginning @option{-Wno-} to turn off warnings;
791for example, @option{-Wno-implicit}. This manual lists only one of the
792two forms, whichever is not the default.
793
641096f2 794These options control the amount and kinds of errors and warnings produced
795by GNU Fortran:
4ee9c684 796
797@table @gcctabopt
dcaeea77 798@item -fmax-errors=@var{n}
799@opindex @code{fmax-errors=}@var{n}
5e246457 800@cindex errors, limiting
641096f2 801Limits the maximum number of error messages to @var{n}, at which point
802GNU Fortran bails out rather than attempting to continue processing the
803source code. If @var{n} is 0, there is no limit on the number of error
804messages produced.
805
4ee9c684 806@item -fsyntax-only
7d17e6c7 807@opindex @code{fsyntax-only}
5e246457 808@cindex syntax checking
6152df27 809Check the code for syntax errors, but do not actually compile it. This
07702c1a 810will generate module files for each module present in the code, but no
811other output file.
4ee9c684 812
a3886308 813@item -Wpedantic
814@itemx -pedantic
7d17e6c7 815@opindex @code{pedantic}
a3886308 816@opindex @code{Wpedantic}
003e134b 817Issue warnings for uses of extensions to Fortran.
4ee9c684 818@option{-pedantic} also applies to C-language constructs where they
819occur in GNU Fortran source files, such as use of @samp{\e} in a
36348e43 820character constant within a directive like @code{#include}.
4ee9c684 821
003e134b 822Valid Fortran programs should compile properly with or without
4ee9c684 823this option.
824However, without this option, certain GNU extensions and traditional
825Fortran features are supported as well.
826With this option, many of them are rejected.
827
828Some users try to use @option{-pedantic} to check programs for conformance.
829They soon find that it does not do quite what they want---it finds some
830nonstandard practices, but not all.
61156d26 831However, improvements to GNU Fortran in this area are welcome.
4ee9c684 832
ff4425cf 833This should be used in conjunction with @option{-std=f95},
003e134b 834@option{-std=f2003}, @option{-std=f2008} or @option{-std=f2018}.
4ee9c684 835
4ee9c684 836@item -pedantic-errors
7d17e6c7 837@opindex @code{pedantic-errors}
4ee9c684 838Like @option{-pedantic}, except that errors are produced rather than
839warnings.
840
4ee9c684 841@item -Wall
7d17e6c7 842@opindex @code{Wall}
4ee9c684 843@cindex all warnings
844@cindex warnings, all
e27238e0 845Enables commonly used warning options pertaining to usage that
846we recommend avoiding and that we believe are easy to avoid.
02dcd1b8 847This currently includes @option{-Waliasing}, @option{-Wampersand},
7e3d1c77 848@option{-Wconversion}, @option{-Wsurprising}, @option{-Wc-binding-type},
e2cc8a2e 849@option{-Wintrinsics-std}, @option{-Wtabs}, @option{-Wintrinsic-shadow},
38d81530 850@option{-Wline-truncation}, @option{-Wtarget-lifetime},
95c9caad 851@option{-Winteger-division}, @option{-Wreal-q-constant}, @option{-Wunused}
852and @option{-Wundefined-do-loop}.
4ee9c684 853
4ee9c684 854@item -Waliasing
7d17e6c7 855@opindex @code{Waliasing}
4ee9c684 856@cindex aliasing
7d17e6c7 857@cindex warnings, aliasing
0afd5e57 858Warn about possible aliasing of dummy arguments. Specifically, it warns
859if the same actual argument is associated with a dummy argument with
36348e43 860@code{INTENT(IN)} and a dummy argument with @code{INTENT(OUT)} in a call
0afd5e57 861with an explicit interface.
862
863The following example will trigger the warning.
4ee9c684 864@smallexample
0afd5e57 865 interface
866 subroutine bar(a,b)
867 integer, intent(in) :: a
868 integer, intent(out) :: b
869 end subroutine
870 end interface
871 integer :: a
872
873 call bar(a,a)
4ee9c684 874@end smallexample
875
e27238e0 876@item -Wampersand
7d17e6c7 877@opindex @code{Wampersand}
878@cindex warnings, ampersand
12786727 879@cindex @code{&}
003e134b 880Warn about missing ampersand in continued character constants. The
881warning is given with @option{-Wampersand}, @option{-pedantic},
882@option{-std=f95}, @option{-std=f2003}, @option{-std=f2008} and
883@option{-std=f2018}. Note: With no ampersand given in a continued
884character constant, GNU Fortran assumes continuation at the first
885non-comment, non-whitespace character after the ampersand that
886initiated the continuation.
e27238e0 887
2c8c2d4d 888@item -Wargument-mismatch
889@opindex @code{Wargument-mismatch}
890@cindex warnings, argument mismatch
891@cindex warnings, parameter mismatch
892@cindex warnings, interface mismatch
893Warn about type, rank, and other mismatches between formal parameters and actual
894arguments to functions and subroutines. These warnings are recommended and
895thus enabled by default.
896
92f4d1c4 897@item -Warray-temporaries
898@opindex @code{Warray-temporaries}
899@cindex warnings, array temporaries
900Warn about array temporaries generated by the compiler. The information
901generated by this warning is sometimes useful in optimization, in order to
902avoid such temporaries.
903
8e618001 904@item -Wc-binding-type
905@opindex @code{Wc-binding-type}
906@cindex warning, C binding type
907Warn if the a variable might not be C interoperable. In particular, warn if
908the variable has been declared using an intrinsic type with default kind
909instead of using a kind parameter defined for C interoperability in the
7e3d1c77 910intrinsic @code{ISO_C_Binding} module. This option is implied by
911@option{-Wall}.
8e618001 912
c889c4a8 913@item -Wcharacter-truncation
7d17e6c7 914@opindex @code{Wcharacter-truncation}
915@cindex warnings, character truncation
c889c4a8 916Warn when a character assignment will truncate the assigned string.
917
2c3b9819 918@item -Wline-truncation
919@opindex @code{Wline-truncation}
920@cindex warnings, line truncation
7e3d1c77 921Warn when a source code line will be truncated. This option is
bf1857ff 922implied by @option{-Wall}. For free-form source code, the default is
923@option{-Werror=line-truncation} such that truncations are reported as
924error.
2c3b9819 925
4ee9c684 926@item -Wconversion
7d17e6c7 927@opindex @code{Wconversion}
928@cindex warnings, conversion
4ee9c684 929@cindex conversion
721f64bf 930Warn about implicit conversions that are likely to change the value of
931the expression after conversion. Implied by @option{-Wall}.
932
933@item -Wconversion-extra
934@opindex @code{Wconversion-extra}
935@cindex warnings, conversion
936@cindex conversion
bf79c656 937Warn about implicit conversions between different types and kinds. This
938option does @emph{not} imply @option{-Wconversion}.
4ee9c684 939
7e3d1c77 940@item -Wextra
941@opindex @code{Wextra}
942@cindex extra warnings
943@cindex warnings, extra
944Enables some warning options for usages of language features which
3eaed19a 945may be problematic. This currently includes @option{-Wcompare-reals},
946@option{-Wunused-parameter} and @option{-Wdo-subscript}.
7e3d1c77 947
44319903 948@item -Wfrontend-loop-interchange
949@opindex @code{Wfrontend-loop-interchange}
950@cindex warnings, loop interchange
951@cindex loop interchange, warning
952Enable warning for loop interchanges performed by the
953@option{-ffrontend-loop-interchange} option.
954
4ee9c684 955@item -Wimplicit-interface
7d17e6c7 956@opindex @code{Wimplicit-interface}
957@cindex warnings, implicit interface
60ac3189 958Warn if a procedure is called without an explicit interface.
4ee9c684 959Note this only checks that an explicit interface is present. It does not
960check that the declared interfaces are consistent across program units.
961
e6bbcce0 962@item -Wimplicit-procedure
963@opindex @code{Wimplicit-procedure}
964@cindex warnings, implicit procedure
965Warn if a procedure is called that has neither an explicit interface
966nor has been declared as @code{EXTERNAL}.
967
2cc308f8 968@item -Winteger-division
969@opindex @code{Winteger-division}
970@cindex warnings, integer division
971@cindex warnings, division of integers
972Warn if a constant integer division truncates it result.
973As an example, 3/5 evaluates to 0.
974
a34926ba 975@item -Wintrinsics-std
976@opindex @code{Wintrinsics-std}
ce1640f1 977@cindex warnings, non-standard intrinsics
a34926ba 978@cindex warnings, intrinsics of other standards
979Warn if @command{gfortran} finds a procedure named like an intrinsic not
980available in the currently selected standard (with @option{-std}) and treats
981it as @code{EXTERNAL} procedure because of this. @option{-fall-intrinsics} can
671f48a4 982be used to never trigger this behavior and always link to the intrinsic
a34926ba 983regardless of the selected standard.
d6583a5f 984
37e35d1c 985@item -Wreal-q-constant
986@opindex @code{Wreal-q-constant}
987@cindex warnings, @code{q} exponent-letter
988Produce a warning if a real-literal-constant contains a @code{q}
989exponent-letter.
990
4ee9c684 991@item -Wsurprising
7d17e6c7 992@opindex @code{Wsurprising}
993@cindex warnings, suspicious code
9857bf0d 994Produce a warning when ``suspicious'' code constructs are encountered.
995While technically legal these usually indicate that an error has been made.
4ee9c684 996
997This currently produces a warning under the following circumstances:
998
999@itemize @bullet
1000@item
32c4b59a 1001An INTEGER SELECT construct has a CASE that can never be matched as its
1002lower value is greater than its upper value.
4ee9c684 1003
1004@item
1005A LOGICAL SELECT construct has three CASE statements.
0c372097 1006
1007@item
1008A TRANSFER specifies a source that is shorter than the destination.
89b9a6ab 1009
1010@item
1011The type of a function result is declared more than once with the same type. If
1012@option{-pedantic} or standard-conforming mode is enabled, this is an error.
7c967940 1013
1014@item
1015A @code{CHARACTER} variable is declared with negative length.
4ee9c684 1016@end itemize
1017
35d6528e 1018@item -Wtabs
7d17e6c7 1019@opindex @code{Wtabs}
1020@cindex warnings, tabs
a1149005 1021@cindex tabulators
35d6528e 1022By default, tabs are accepted as whitespace, but tabs are not members
9357a094 1023of the Fortran Character Set. For continuation lines, a tab followed
003e134b 1024by a digit between 1 and 9 is supported. @option{-Wtabs} will cause a
1025warning to be issued if a tab is encountered. Note, @option{-Wtabs} is
1026active for @option{-pedantic}, @option{-std=f95}, @option{-std=f2003},
2e2156cf 1027@option{-std=f2008}, @option{-std=f2018} and
003e134b 1028@option{-Wall}.
35d6528e 1029
95c9caad 1030@item -Wundefined-do-loop
1031@opindex @code{Wundefined-do-loop}
1032@cindex warnings, undefined do loop
1033Warn if a DO loop with step either 1 or -1 yields an underflow or an overflow
9c0284b2 1034during iteration of an induction variable of the loop.
1035This option is implied by @option{-Wall}.
95c9caad 1036
9857bf0d 1037@item -Wunderflow
7d17e6c7 1038@opindex @code{Wunderflow}
1039@cindex warnings, underflow
1040@cindex underflow
9857bf0d 1041Produce a warning when numerical constant expressions are
8290d53f 1042encountered, which yield an UNDERFLOW during compilation. Enabled by default.
9857bf0d 1043
a34926ba 1044@item -Wintrinsic-shadow
1045@opindex @code{Wintrinsic-shadow}
1046@cindex warnings, intrinsic
1047@cindex intrinsic
1048Warn if a user-defined procedure or module procedure has the same name as an
1049intrinsic; in this case, an explicit interface or @code{EXTERNAL} or
1050@code{INTRINSIC} declaration might be needed to get calls later resolved to
7e3d1c77 1051the desired intrinsic/procedure. This option is implied by @option{-Wall}.
a34926ba 1052
7cb96c5d 1053@item -Wuse-without-only
1054@opindex @code{Wuse-without-only}
1055@cindex warnings, use statements
1056@cindex intrinsic
1057Warn if a @code{USE} statement has no @code{ONLY} qualifier and
1058thus implicitly imports all public entities of the used module.
1059
4acad347 1060@item -Wunused-dummy-argument
1061@opindex @code{Wunused-dummy-argument}
1062@cindex warnings, unused dummy argument
1063@cindex unused dummy argument
1064@cindex dummy argument, unused
1065Warn about unused dummy arguments. This option is implied by @option{-Wall}.
1066
6ecfe89d 1067@item -Wunused-parameter
1068@opindex @code{Wunused-parameter}
1069@cindex warnings, unused parameter
1070@cindex unused parameter
1071Contrary to @command{gcc}'s meaning of @option{-Wunused-parameter},
1072@command{gfortran}'s implementation of this option does not warn
4acad347 1073about unused dummy arguments (see @option{-Wunused-dummy-argument}),
1074but about unused @code{PARAMETER} values. @option{-Wunused-parameter}
23096bb0 1075is implied by @option{-Wextra} if also @option{-Wunused} or
1076@option{-Wall} is used.
6ecfe89d 1077
58601acb 1078@item -Walign-commons
1079@opindex @code{Walign-commons}
12786727 1080@cindex warnings, alignment of @code{COMMON} blocks
1081@cindex alignment of @code{COMMON} blocks
58601acb 1082By default, @command{gfortran} warns about any occasion of variables being
12786727 1083padded for proper alignment inside a @code{COMMON} block. This warning can be turned
58601acb 1084off via @option{-Wno-align-commons}. See also @option{-falign-commons}.
1085
10b2bb30 1086@item -Wfunction-elimination
1087@opindex @code{Wfunction-elimination}
1088@cindex function elimination
1089@cindex warnings, function elimination
2f441104 1090Warn if any calls to impure functions are eliminated by the optimizations
10b2bb30 1091enabled by the @option{-ffrontend-optimize} option.
2f441104 1092This option is implied by @option{-Wextra}.
10b2bb30 1093
c78a1d18 1094@item -Wrealloc-lhs
1095@opindex @code{Wrealloc-lhs}
1096@cindex Reallocate the LHS in assignments, notification
1097Warn when the compiler might insert code to for allocation or reallocation of
1098an allocatable array variable of intrinsic type in intrinsic assignments. In
1099hot loops, the Fortran 2003 reallocation feature may reduce the performance.
1100If the array is already allocated with the correct shape, consider using a
1101whole-array array-spec (e.g. @code{(:,:,:)}) for the variable on the left-hand
1102side to prevent the reallocation check. Note that in some cases the warning
1103is shown, even if the compiler will optimize reallocation checks away. For
1104instance, when the right-hand side contains the same variable multiplied by
1105a scalar. See also @option{-frealloc-lhs}.
1106
1107@item -Wrealloc-lhs-all
1108@opindex @code{Wrealloc-lhs-all}
1109Warn when the compiler inserts code to for allocation or reallocation of an
1110allocatable variable; this includes scalars and derived types.
10b2bb30 1111
02dcd1b8 1112@item -Wcompare-reals
1113@opindex @code{Wcompare-reals}
1114Warn when comparing real or complex types for equality or inequality.
7e3d1c77 1115This option is implied by @option{-Wextra}.
02dcd1b8 1116
38d81530 1117@item -Wtarget-lifetime
1118@opindex @code{Wtargt-lifetime}
1119Warn if the pointer in a pointer assignment might be longer than the its
1120target. This option is implied by @option{-Wall}.
1121
bfdfb835 1122@item -Wzerotrip
1123@opindex @code{Wzerotrip}
1124Warn if a @code{DO} loop is known to execute zero times at compile
1125time. This option is implied by @option{-Wall}.
1126
3eaed19a 1127@item -Wdo-subscript
1128@opindex @code{Wdo-subscript}
1129Warn if an array subscript inside a DO loop could lead to an
f4d3c071 1130out-of-bounds access even if the compiler cannot prove that the
3eaed19a 1131statement is actually executed, in cases like
1132@smallexample
1133 real a(3)
1134 do i=1,4
1135 if (condition(i)) then
1136 a(i) = 1.2
1137 end if
1138 end do
1139@end smallexample
1140This option is implied by @option{-Wextra}.
1141
4ee9c684 1142@item -Werror
7d17e6c7 1143@opindex @code{Werror}
1144@cindex warnings, to errors
4ee9c684 1145Turns all warnings into errors.
4ee9c684 1146@end table
1147
e93c55b8 1148@xref{Warning Options,,Options to Request or Suppress Errors and
641096f2 1149Warnings, gcc,Using the GNU Compiler Collection (GCC)}, for information on
1150more options offered by the GBE shared by @command{gfortran}, @command{gcc}
1151and other GNU compilers.
4ee9c684 1152
1153Some of these have no effect when compiling programs written in Fortran.
1154
1155@node Debugging Options
138b8aca 1156@section Options for debugging your program or GNU Fortran
4ee9c684 1157@cindex options, debugging
1158@cindex debugging information options
1159
1160GNU Fortran has various special options that are used for debugging
61156d26 1161either your program or the GNU Fortran compiler.
4ee9c684 1162
1163@table @gcctabopt
f1a51f6b 1164@item -fdump-fortran-original
1165@opindex @code{fdump-fortran-original}
1166Output the internal parse tree after translating the source program
25832dc4 1167into internal representation. This option is mostly useful for
1168debugging the GNU Fortran compiler itself. The output generated by
1169this option might change between releases. This option may also
1170generate internal compiler errors for features which have only
1171recently been added.
f1a51f6b 1172
26f91b7f 1173@item -fdump-fortran-optimized
f1a51f6b 1174@opindex @code{fdump-fortran-optimized}
25832dc4 1175Output the parse tree after front-end optimization. Mostly useful for
1176debugging the GNU Fortran compiler itself. The output generated by
1177this option might change between releases. This option may also
1178generate internal compiler errors for features which have only
1179recently been added.
f1a51f6b 1180
26f91b7f 1181@item -fdump-parse-tree
7d17e6c7 1182@opindex @code{fdump-parse-tree}
f1a51f6b 1183Output the internal parse tree after translating the source program
25832dc4 1184into internal representation. Mostly useful for debugging the GNU
1185Fortran compiler itself. The output generated by this option might
1186change between releases. This option may also generate internal
1187compiler errors for features which have only recently been added. This
1188option is deprecated; use @code{-fdump-fortran-original} instead.
4ee9c684 1189
8c84a5de 1190@item -ffpe-trap=@var{list}
7d17e6c7 1191@opindex @code{ffpe-trap=}@var{list}
98b28ab6 1192Specify a list of floating point exception traps to enable. On most
1193systems, if a floating point exception occurs and the trap for that
1194exception is enabled, a SIGFPE signal will be sent and the program
1195being aborted, producing a core file useful for debugging. @var{list}
1196is a (possibly empty) comma-separated list of the following
1197exceptions: @samp{invalid} (invalid floating point operation, such as
1198@code{SQRT(-1.0)}), @samp{zero} (division by zero), @samp{overflow}
1199(overflow in a floating point operation), @samp{underflow} (underflow
1200in a floating point operation), @samp{inexact} (loss of precision
1201during operation), and @samp{denormal} (operation performed on a
1202denormal value). The first five exceptions correspond to the five
1203IEEE 754 exceptions, whereas the last one (@samp{denormal}) is not
1204part of the IEEE 754 standard but is available on some common
1205architectures such as x86.
1206
1207The first three exceptions (@samp{invalid}, @samp{zero}, and
1208@samp{overflow}) often indicate serious errors, and unless the program
1209has provisions for dealing with these exceptions, enabling traps for
1210these three exceptions is probably a good idea.
1211
8151f617 1212If the option is used more than once in the command line, the lists will
1213be joined: '@code{ffpe-trap=}@var{list1} @code{ffpe-trap=}@var{list2}'
23f76bad 1214is equivalent to @code{ffpe-trap=}@var{list1},@var{list2}.
8151f617 1215
1216Note that once enabled an exception cannot be disabled (no negative form).
1217
98b28ab6 1218Many, if not most, floating point operations incur loss of precision
1219due to rounding, and hence the @code{ffpe-trap=inexact} is likely to
1220be uninteresting in practice.
1221
1222By default no exception traps are enabled.
3e18450d 1223
553e7cef 1224@item -ffpe-summary=@var{list}
1225@opindex @code{ffpe-summary=}@var{list}
1226Specify a list of floating-point exceptions, whose flag status is printed
1227to @code{ERROR_UNIT} when invoking @code{STOP} and @code{ERROR STOP}.
1228@var{list} can be either @samp{none}, @samp{all} or a comma-separated list
1229of the following exceptions: @samp{invalid}, @samp{zero}, @samp{overflow},
1230@samp{underflow}, @samp{inexact} and @samp{denormal}. (See
1231@option{-ffpe-trap} for a description of the exceptions.)
1232
8151f617 1233If the option is used more than once in the command line, only the
1234last one will be used.
1235
553e7cef 1236By default, a summary for all exceptions but @samp{inexact} is shown.
1237
b2130263 1238@item -fno-backtrace
1239@opindex @code{fno-backtrace}
99798ba4 1240@cindex backtrace
1241@cindex trace
b2130263 1242When a serious runtime error is encountered or a deadly signal is
1243emitted (segmentation fault, illegal instruction, bus error,
1244floating-point exception, and the other POSIX signals that have the
1245action @samp{core}), the Fortran runtime library tries to output a
1246backtrace of the error. @code{-fno-backtrace} disables the backtrace
1247generation. This option only has influence for compilation of the
1248Fortran main program.
1249
8c84a5de 1250@end table
1251
4ee9c684 1252@xref{Debugging Options,,Options for Debugging Your Program or GCC,
1253gcc,Using the GNU Compiler Collection (GCC)}, for more information on
1254debugging options.
1255
1256@node Directory Options
138b8aca 1257@section Options for directory search
4ee9c684 1258@cindex directory, options
1259@cindex options, directory search
1260@cindex search path
12786727 1261@cindex @code{INCLUDE} directive
1262@cindex directive, @code{INCLUDE}
61156d26 1263These options affect how GNU Fortran searches
e6cd6ed5 1264for files specified by the @code{INCLUDE} directive and where it searches
4ee9c684 1265for previously compiled modules.
1266
1267It also affects the search paths used by @command{cpp} when used to preprocess
9857bf0d 1268Fortran source.
4ee9c684 1269
1270@table @gcctabopt
4ee9c684 1271@item -I@var{dir}
7d17e6c7 1272@opindex @code{I}@var{dir}
4ee9c684 1273@cindex directory, search paths for inclusion
1274@cindex inclusion, directory search paths for
1275@cindex search paths, for included files
1276@cindex paths, search
1277@cindex module search path
1278These affect interpretation of the @code{INCLUDE} directive
1279(as well as of the @code{#include} directive of the @command{cpp}
1280preprocessor).
1281
1282Also note that the general behavior of @option{-I} and
1283@code{INCLUDE} is pretty much the same as of @option{-I} with
1284@code{#include} in the @command{cpp} preprocessor, with regard to
1285looking for @file{header.gcc} files and other such things.
1286
36348e43 1287This path is also used to search for @file{.mod} files when previously
4ee9c684 1288compiled modules are required by a @code{USE} statement.
1289
1290@xref{Directory Options,,Options for Directory Search,
1291gcc,Using the GNU Compiler Collection (GCC)}, for information on the
1292@option{-I} option.
1293
4ee9c684 1294@item -J@var{dir}
7d17e6c7 1295@opindex @code{J}@var{dir}
db96818c 1296@opindex @code{M}@var{dir}
c889c4a8 1297@cindex paths, search
1298@cindex module search path
36348e43 1299This option specifies where to put @file{.mod} files for compiled modules.
9857bf0d 1300It is also added to the list of directories to searched by an @code{USE}
4ee9c684 1301statement.
1302
1303The default is the current directory.
1304
c889c4a8 1305@item -fintrinsic-modules-path @var{dir}
7d17e6c7 1306@opindex @code{fintrinsic-modules-path} @var{dir}
c889c4a8 1307@cindex paths, search
1308@cindex module search path
1309This option specifies the location of pre-compiled intrinsic modules, if
1310they are not in the default location expected by the compiler.
4ee9c684 1311@end table
1312
618e262b 1313@node Link Options
138b8aca 1314@section Influencing the linking step
618e262b 1315@cindex options, linking
1316@cindex linking, static
1317
1318These options come into play when the compiler links object files into an
1319executable output file. They are meaningless if the compiler is not doing
1320a link step.
1321
1322@table @gcctabopt
1323@item -static-libgfortran
1324@opindex @code{static-libgfortran}
1325On systems that provide @file{libgfortran} as a shared and a static
1326library, this option forces the use of the static version. If no
1327shared version of @file{libgfortran} was built when the compiler was
1328configured, this option has no effect.
1329@end table
1330
1331
15774a8b 1332@node Runtime Options
138b8aca 1333@section Influencing runtime behavior
a1149005 1334@cindex options, runtime
15774a8b 1335
61156d26 1336These options affect the runtime behavior of programs compiled with GNU Fortran.
67c11f5d 1337
15774a8b 1338@table @gcctabopt
15774a8b 1339@item -fconvert=@var{conversion}
7d17e6c7 1340@opindex @code{fconvert=}@var{conversion}
15774a8b 1341Specify the representation of data for unformatted files. Valid
1342values for conversion are: @samp{native}, the default; @samp{swap},
1343swap between big- and little-endian; @samp{big-endian}, use big-endian
1344representation for unformatted files; @samp{little-endian}, use little-endian
1345representation for unformatted files.
1346
1347@emph{This option has an effect only when used in the main program.
1348The @code{CONVERT} specifier and the GFORTRAN_CONVERT_UNIT environment
36348e43 1349variable override the default specified by @option{-fconvert}.}
f23886ab 1350
f23886ab 1351@item -frecord-marker=@var{length}
7d17e6c7 1352@opindex @code{frecord-marker=}@var{length}
f23886ab 1353Specify the length of record markers for unformatted files.
bbaaa7b1 1354Valid values for @var{length} are 4 and 8. Default is 4.
138b8aca 1355@emph{This is different from previous versions of @command{gfortran}},
bbaaa7b1 1356which specified a default record marker length of 8 on most
1357systems. If you want to read or write files compatible
138b8aca 1358with earlier versions of @command{gfortran}, use @option{-frecord-marker=8}.
bbaaa7b1 1359
bbaaa7b1 1360@item -fmax-subrecord-length=@var{length}
7d17e6c7 1361@opindex @code{fmax-subrecord-length=}@var{length}
bbaaa7b1 1362Specify the maximum length for a subrecord. The maximum permitted
1363value for length is 2147483639, which is also the default. Only
1364really useful for use by the gfortran testsuite.
33e561a5 1365
1366@item -fsign-zero
1367@opindex @code{fsign-zero}
af9e821d 1368When enabled, floating point numbers of value zero with the sign bit set
1369are written as negative number in formatted output and treated as
6152df27 1370negative in the @code{SIGN} intrinsic. @option{-fno-sign-zero} does not
1371print the negative sign of zero values (or values rounded to zero for I/O)
1372and regards zero as positive number in the @code{SIGN} intrinsic for
1373compatibility with Fortran 77. The default is @option{-fsign-zero}.
15774a8b 1374@end table
1375
4ee9c684 1376@node Code Gen Options
138b8aca 1377@section Options for code generation conventions
4ee9c684 1378@cindex code generation, conventions
1379@cindex options, code generation
a1149005 1380@cindex options, run-time
4ee9c684 1381
1382These machine-independent options control the interface conventions
1383used in code generation.
1384
1385Most of them have both positive and negative forms; the negative form
1386of @option{-ffoo} would be @option{-fno-foo}. In the table below, only
1387one of the forms is listed---the one which is not the default. You
1388can figure out the other form by either removing @option{no-} or adding
1389it.
1390
4ee9c684 1391@table @gcctabopt
0fda8d07 1392@item -fno-automatic
7d17e6c7 1393@opindex @code{fno-automatic}
a1149005 1394@cindex @code{SAVE} statement
1395@cindex statement, @code{SAVE}
14af4f75 1396Treat each program unit (except those marked as RECURSIVE) as if the
1397@code{SAVE} statement were specified for every local variable and array
1398referenced in it. Does not affect common blocks. (Some Fortran compilers
1399provide this option under the name @option{-static} or @option{-save}.)
1400The default, which is @option{-fautomatic}, uses the stack for local
1401variables smaller than the value given by @option{-fmax-stack-var-size}.
1402Use the option @option{-frecursive} to use no static memory.
0fda8d07 1403
c81c2702 1404Local variables or arrays having an explicit @code{SAVE} attribute are
1405silently ignored unless the @option{-pedantic} option is added.
1406
bdaed7d2 1407@item -ff2c
a1149005 1408@opindex ff2c
bdaed7d2 1409@cindex calling convention
1410@cindex @command{f2c} calling convention
1411@cindex @command{g77} calling convention
1412@cindex libf2c calling convention
1413Generate code designed to be compatible with code generated
1414by @command{g77} and @command{f2c}.
1415
1416The calling conventions used by @command{g77} (originally implemented
1417in @command{f2c}) require functions that return type
1418default @code{REAL} to actually return the C type @code{double}, and
1419functions that return type @code{COMPLEX} to return the values via an
1420extra argument in the calling sequence that points to where to
1421store the return value. Under the default GNU calling conventions, such
1422functions simply return their results as they would in GNU
31a50a4c 1423C---default @code{REAL} functions return the C type @code{float}, and
bdaed7d2 1424@code{COMPLEX} functions return the GNU C type @code{complex}.
e0072cca 1425Additionally, this option implies the @option{-fsecond-underscore}
1426option, unless @option{-fno-second-underscore} is explicitly requested.
bdaed7d2 1427
1428This does not affect the generation of code that interfaces with
1429the @command{libgfortran} library.
1430
36348e43 1431@emph{Caution:} It is not a good idea to mix Fortran code compiled with
1432@option{-ff2c} with code compiled with the default @option{-fno-f2c}
bdaed7d2 1433calling conventions as, calling @code{COMPLEX} or default @code{REAL}
1434functions between program parts which were compiled with different
1435calling conventions will break at execution time.
1436
1437@emph{Caution:} This will break code which passes intrinsic functions
1438of type default @code{REAL} or @code{COMPLEX} as actual arguments, as
36348e43 1439the library implementations use the @option{-fno-f2c} calling conventions.
bdaed7d2 1440
4ee9c684 1441@item -fno-underscoring
7d17e6c7 1442@opindex @code{fno-underscoring}
4ee9c684 1443@cindex underscore
1444@cindex symbol names, underscores
1445@cindex transforming symbol names
1446@cindex symbol names, transforming
1447Do not transform names of entities specified in the Fortran
1448source file by appending underscores to them.
1449
61156d26 1450With @option{-funderscoring} in effect, GNU Fortran appends one
e6cd6ed5 1451underscore to external names with no underscores. This is done to ensure
1452compatibility with code produced by many UNIX Fortran compilers.
bdaed7d2 1453
61156d26 1454@emph{Caution}: The default behavior of GNU Fortran is
bdaed7d2 1455incompatible with @command{f2c} and @command{g77}, please use the
cb88eb29 1456@option{-ff2c} option if you want object files compiled with
61156d26 1457GNU Fortran to be compatible with object code created with these
cb88eb29 1458tools.
4ee9c684 1459
1460Use of @option{-fno-underscoring} is not recommended unless you are
61156d26 1461experimenting with issues such as integration of GNU Fortran into
3e18450d 1462existing system environments (vis-@`{a}-vis existing libraries, tools,
1463and so on).
4ee9c684 1464
32cd0cc4 1465For example, with @option{-funderscoring}, and assuming that @code{j()} and
1466@code{max_count()} are external functions while @code{my_var} and
1467@code{lvar} are local variables, a statement like
4ee9c684 1468@smallexample
1469I = J() + MAX_COUNT (MY_VAR, LVAR)
1470@end smallexample
4ee9c684 1471@noindent
1472is implemented as something akin to:
4ee9c684 1473@smallexample
1474i = j_() + max_count__(&my_var__, &lvar);
1475@end smallexample
1476
1477With @option{-fno-underscoring}, the same statement is implemented as:
1478
1479@smallexample
1480i = j() + max_count(&my_var, &lvar);
1481@end smallexample
1482
1483Use of @option{-fno-underscoring} allows direct specification of
61156d26 1484user-defined names while debugging and when interfacing GNU Fortran
4ee9c684 1485code with other languages.
1486
1487Note that just because the names match does @emph{not} mean that the
61156d26 1488interface implemented by GNU Fortran for an external name matches the
4ee9c684 1489interface implemented by some other language for that same name.
61156d26 1490That is, getting code produced by GNU Fortran to link to code produced
4ee9c684 1491by some other compiler using this or any other method can be only a
1492small part of the overall solution---getting the code generated by
1493both compilers to agree on issues other than naming can require
1494significant effort, and, unlike naming disagreements, linkers normally
1495cannot detect disagreements in these other areas.
1496
1497Also, note that with @option{-fno-underscoring}, the lack of appended
1498underscores introduces the very real possibility that a user-defined
1499external name will conflict with a name in a system library, which
1500could make finding unresolved-reference bugs quite difficult in some
1501cases---they might occur at program run time, and show up only as
1502buggy behavior at run time.
1503
61156d26 1504In future versions of GNU Fortran we hope to improve naming and linking
4ee9c684 1505issues so that debugging always involves using the names as they appear
1506in the source, even if the names as seen by the linker are mangled to
1507prevent accidental linking between procedures with incompatible
1508interfaces.
1509
bdaed7d2 1510@item -fsecond-underscore
7d17e6c7 1511@opindex @code{fsecond-underscore}
4ee9c684 1512@cindex underscore
1513@cindex symbol names, underscores
1514@cindex transforming symbol names
1515@cindex symbol names, transforming
bdaed7d2 1516@cindex @command{f2c} calling convention
1517@cindex @command{g77} calling convention
1518@cindex libf2c calling convention
61156d26 1519By default, GNU Fortran appends an underscore to external
1520names. If this option is used GNU Fortran appends two
bdaed7d2 1521underscores to names with underscores and one underscore to external names
61156d26 1522with no underscores. GNU Fortran also appends two underscores to
bdaed7d2 1523internal names with underscores to avoid naming collisions with external
1524names.
4ee9c684 1525
1526This option has no effect if @option{-fno-underscoring} is
bdaed7d2 1527in effect. It is implied by the @option{-ff2c} option.
4ee9c684 1528
36348e43 1529Otherwise, with this option, an external name such as @code{MAX_COUNT}
4ee9c684 1530is implemented as a reference to the link-time external symbol
36348e43 1531@code{max_count__}, instead of @code{max_count_}. This is required
bdaed7d2 1532for compatibility with @command{g77} and @command{f2c}, and is implied
1533by use of the @option{-ff2c} option.
4ee9c684 1534
76daec3c 1535@item -fcoarray=@var{<keyword>}
1536@opindex @code{fcoarray}
1537@cindex coarrays
1538
1539@table @asis
1540@item @samp{none}
1541Disable coarray support; using coarray declarations and image-control
1542statements will produce a compile-time error. (Default)
1543
1544@item @samp{single}
1545Single-image mode, i.e. @code{num_images()} is always one.
70b5944a 1546
1547@item @samp{lib}
1548Library-based coarray parallelization; a suitable GNU Fortran coarray
1549library needs to be linked.
76daec3c 1550@end table
1551
1552
ad8ed98e 1553@item -fcheck=@var{<keyword>}
1554@opindex @code{fcheck}
a1149005 1555@cindex array, bounds checking
4ee9c684 1556@cindex bounds checking
91cf6ba3 1557@cindex pointer checking
3a60b071 1558@cindex memory checking
4ee9c684 1559@cindex range checking
4ee9c684 1560@cindex subscript checking
1561@cindex checking subscripts
ad8ed98e 1562@cindex run-time checking
1563@cindex checking array temporaries
1564
1565Enable the generation of run-time checks; the argument shall be
e7fbac94 1566a comma-delimited list of the following keywords. Prefixing a check with
1567@option{no-} disables it if it was activated by a previous specification.
ad8ed98e 1568
1569@table @asis
1570@item @samp{all}
1571Enable all run-time test of @option{-fcheck}.
1572
1573@item @samp{array-temps}
1574Warns at run time when for passing an actual argument a temporary array
1575had to be generated. The information generated by this warning is
1576sometimes useful in optimization, in order to avoid such temporaries.
1577
1578Note: The warning is only printed once per location.
1579
1580@item @samp{bounds}
4ee9c684 1581Enable generation of run-time checks for array subscripts
1582and against the declared minimum and maximum values. It also
1583checks array indices for assumed and deferred
57b9ac90 1584shape arrays against the actual allocated bounds and ensures that all string
1585lengths are equal for character array constructors without an explicit
1586typespec.
4ee9c684 1587
ad8ed98e 1588Some checks require that @option{-fcheck=bounds} is set for
3e18450d 1589the compilation of the main program.
c086aee1 1590
57b9ac90 1591Note: In the future this may also include other forms of checking, e.g.,
1592checking substring references.
a466adc9 1593
7f1bd03f 1594@item @samp{do}
1595Enable generation of run-time checks for invalid modification of loop
1596iteration variables.
1597
3a60b071 1598@item @samp{mem}
1599Enable generation of run-time checks for memory allocation.
1600Note: This option does not affect explicit allocations using the
1601@code{ALLOCATE} statement, which will be always checked.
1602
91cf6ba3 1603@item @samp{pointer}
1604Enable generation of run-time checks for pointers and allocatables.
1605
a466adc9 1606@item @samp{recursion}
1607Enable generation of run-time checks for recursively called subroutines and
1608functions which are not marked as recursive. See also @option{-frecursive}.
ef00cabe 1609Note: This check does not work for OpenMP programs and is disabled if used
53169279 1610together with @option{-frecursive} and @option{-fopenmp}.
ad8ed98e 1611@end table
4ee9c684 1612
e7fbac94 1613Example: Assuming you have a file @file{foo.f90}, the command
1614@smallexample
1615 gfortran -fcheck=all,no-array-temps foo.f90
1616@end smallexample
1617will compile the file with all checks enabled as specified above except
1618warnings for generated array temporaries.
1619
da6ffc6d 1620
ad8ed98e 1621@item -fbounds-check
1622@opindex @code{fbounds-check}
1623@c Note: This option is also referred in gcc's manpage
1624Deprecated alias for @option{-fcheck=bounds}.
da6ffc6d 1625
d7233bac 1626@item -ftail-call-workaround
1627@itemx -ftail-call-workaround=@var{n}
1628@opindex @code{tail-call-workaround}
a4ba5c3e 1629Some C interfaces to Fortran codes violate the gfortran ABI by
1630omitting the hidden character length arguments as described in
1631@xref{Argument passing conventions}. This can lead to crashes
1632because pushing arguments for tail calls can overflow the stack.
1633
1634To provide a workaround for existing binary packages, this option
1635disables tail call optimization for gfortran procedures with character
d7233bac 1636arguments. With @option{-ftail-call-workaround=2} tail call optimization
1637is disabled in all gfortran procedures with character arguments,
1638with @option{-ftail-call-workaround=1} or equivalent
1639@option{-ftail-call-workaround} only in gfortran procedures with character
1640arguments that call implicitly prototyped procedures.
a4ba5c3e 1641
1642Using this option can lead to problems including crashes due to
1643insufficient stack space.
1644
1645It is @emph{very strongly} recommended to fix the code in question.
1646The @option{-fc-prototypes-external} option can be used to generate
1647prototypes which conform to gfortran's ABI, for inclusion in the
1648source code.
1649
1650Support for this option will likely be withdrawn in a future release
1651of gfortran.
1652
d7233bac 1653The negative form, @option{-fno-tail-call-workaround} or equivalent
1654@option{-ftail-call-workaround=0}, can be used to disable this option.
a4ba5c3e 1655
d7233bac 1656Default is currently @option{-ftail-call-workaround}, this will change
a4ba5c3e 1657in future releases.
1658
ad8ed98e 1659@item -fcheck-array-temporaries
1660@opindex @code{fcheck-array-temporaries}
1661Deprecated alias for @option{-fcheck=array-temps}.
da6ffc6d 1662
d6c9e9d7 1663@item -fmax-array-constructor=@var{n}
1664@opindex @code{fmax-array-constructor}
1665This option can be used to increase the upper limit permitted in
1666array constructors. The code below requires this option to expand
1667the array at compile time.
1668
1669@smallexample
12786727 1670program test
1671implicit none
1672integer j
1673integer, parameter :: n = 100000
1674integer, parameter :: i(n) = (/ (2*j, j = 1, n) /)
1675print '(10(I0,1X))', i
1676end program test
d6c9e9d7 1677@end smallexample
1678
1679@emph{Caution: This option can lead to long compile times and excessively
1680large object files.}
1681
1682The default value for @var{n} is 65535.
1683
1684
4ee9c684 1685@item -fmax-stack-var-size=@var{n}
7d17e6c7 1686@opindex @code{fmax-stack-var-size}
4ee9c684 1687This option specifies the size in bytes of the largest array that will be put
14af4f75 1688on the stack; if the size is exceeded static memory is used (except in
1689procedures marked as RECURSIVE). Use the option @option{-frecursive} to
1690allow for recursive procedures which do not have a RECURSIVE attribute or
1691for parallel programs. Use @option{-fno-automatic} to never use the stack.
4ee9c684 1692
1693This option currently only affects local arrays declared with constant
1694bounds, and may not apply to all character variables.
61156d26 1695Future versions of GNU Fortran may improve this behavior.
4ee9c684 1696
1697The default value for @var{n} is 32768.
1698
bc74b641 1699@item -fstack-arrays
1700@opindex @code{fstack-arrays}
f8b90e58 1701Adding this option will make the Fortran compiler put all arrays of
1702unknown size and array temporaries onto stack memory. If your program uses very
6152df27 1703large local arrays it is possible that you will have to extend your runtime
9e412fd2 1704limits for stack memory on some operating systems. This flag is enabled
f8b90e58 1705by default at optimization level @option{-Ofast} unless
1706@option{-fmax-stack-var-size} is specified.
bc74b641 1707
e5a0d2e2 1708@item -fpack-derived
7d17e6c7 1709@opindex @code{fpack-derived}
1710@cindex structure packing
61156d26 1711This option tells GNU Fortran to pack derived type members as closely as
9857bf0d 1712possible. Code compiled with this option is likely to be incompatible
4ee9c684 1713with code compiled without this option, and may execute slower.
1714
4ee9c684 1715@item -frepack-arrays
7d17e6c7 1716@opindex @code{frepack-arrays}
1717@cindex repacking arrays
61156d26 1718In some circumstances GNU Fortran may pass assumed shape array
60ac3189 1719sections via a descriptor describing a noncontiguous area of memory.
4ee9c684 1720This option adds code to the function prologue to repack the data into
1721a contiguous block at runtime.
1722
1723This should result in faster accesses to the array. However it can introduce
1724significant overhead to the function call, especially when the passed data
60ac3189 1725is noncontiguous.
f46e3474 1726
f46e3474 1727@item -fshort-enums
7d17e6c7 1728@opindex @code{fshort-enums}
f46e3474 1729This option is provided for interoperability with C code that was
5e246457 1730compiled with the @option{-fshort-enums} option. It will make
61156d26 1731GNU Fortran choose the smallest @code{INTEGER} kind a given
f46e3474 1732enumerator set will fit in, and give all its enumerators this kind.
4e8e57b0 1733
4e8e57b0 1734@item -fexternal-blas
7d17e6c7 1735@opindex @code{fexternal-blas}
138b8aca 1736This option will make @command{gfortran} generate calls to BLAS functions
1737for some matrix operations like @code{MATMUL}, instead of using our own
4e8e57b0 1738algorithms, if the size of the matrices involved is larger than a given
5e246457 1739limit (see @option{-fblas-matmul-limit}). This may be profitable if an
4e8e57b0 1740optimized vendor BLAS library is available. The BLAS library will have
1741to be specified at link time.
1742
4e8e57b0 1743@item -fblas-matmul-limit=@var{n}
7d17e6c7 1744@opindex @code{fblas-matmul-limit}
5e246457 1745Only significant when @option{-fexternal-blas} is in effect.
4e8e57b0 1746Matrix multiplication of matrices with size larger than (or equal to) @var{n}
1747will be performed by calls to BLAS functions, while others will be
1748handled by @command{gfortran} internal algorithms. If the matrices
1749involved are not square, the size comparison is performed using the
1750geometric mean of the dimensions of the argument and result matrices.
1751
1752The default value for @var{n} is 30.
1753
08f351fd 1754@item -finline-matmul-limit=@var{n}
1755@opindex @code{finline-matmul-limit}
1756When front-end optimiztion is active, some calls to the @code{MATMUL}
1757intrinsic function will be inlined. This may result in code size
1758increase if the size of the matrix cannot be determined at compile
1759time, as code for both cases is generated. Setting
1760@code{-finline-matmul-limit=0} will disable inlining in all cases.
1761Setting this option with a value of @var{n} will produce inline code
1762for matrices with size up to @var{n}. If the matrices involved are not
1763square, the size comparison is performed using the geometric mean of
1764the dimensions of the argument and result matrices.
1765
c23d681b 1766The default value for @var{n} is 30. The @code{-fblas-matmul-limit}
1767can be used to change this value.
08f351fd 1768
14af4f75 1769@item -frecursive
1770@opindex @code{frecursive}
1771Allow indirect recursion by forcing all local arrays to be allocated
1772on the stack. This flag cannot be used together with
1773@option{-fmax-stack-var-size=} or @option{-fno-automatic}.
1774
a28eb9a8 1775@item -finit-local-zero
36d310d0 1776@itemx -finit-derived
67c11f5d 1777@itemx -finit-integer=@var{n}
1778@itemx -finit-real=@var{<zero|inf|-inf|nan|snan>}
1779@itemx -finit-logical=@var{<true|false>}
1780@itemx -finit-character=@var{n}
a28eb9a8 1781@opindex @code{finit-local-zero}
36d310d0 1782@opindex @code{finit-derived}
a28eb9a8 1783@opindex @code{finit-integer}
1784@opindex @code{finit-real}
1785@opindex @code{finit-logical}
1786@opindex @code{finit-character}
1787The @option{-finit-local-zero} option instructs the compiler to
1788initialize local @code{INTEGER}, @code{REAL}, and @code{COMPLEX}
1789variables to zero, @code{LOGICAL} variables to false, and
1790@code{CHARACTER} variables to a string of null bytes. Finer-grained
1791initialization options are provided by the
1792@option{-finit-integer=@var{n}},
2b6bc4f2 1793@option{-finit-real=@var{<zero|inf|-inf|nan|snan>}} (which also initializes
a28eb9a8 1794the real and imaginary parts of local @code{COMPLEX} variables),
1795@option{-finit-logical=@var{<true|false>}}, and
1796@option{-finit-character=@var{n}} (where @var{n} is an ASCII character
c885c55e 1797value) options.
1798
1799With @option{-finit-derived}, components of derived type variables will be
1800initialized according to these flags. Components whose type is not covered by
1801an explicit @option{-finit-*} flag will be treated as described above with
1802@option{-finit-local-zero}.
1803
1804These options do not initialize
08c56d95 1805@itemize @bullet
1806@item
f13dee19 1807objects with the POINTER attribute
1808@item
08c56d95 1809allocatable arrays
1810@item
08c56d95 1811variables that appear in an @code{EQUIVALENCE} statement.
1812@end itemize
1813(These limitations may be removed in future releases).
a28eb9a8 1814
1815Note that the @option{-finit-real=nan} option initializes @code{REAL}
2b6bc4f2 1816and @code{COMPLEX} variables with a quiet NaN. For a signalling NaN
1817use @option{-finit-real=snan}; note, however, that compile-time
1818optimizations may convert them into quiet NaN and that trapping
1819needs to be enabled (e.g. via @option{-ffpe-trap}).
58601acb 1820
9da40462 1821The @option{-finit-integer} option will parse the value into an
1822integer of type @code{INTEGER(kind=C_LONG)} on the host. Said value
1823is then assigned to the integer variables in the Fortran code, which
1824might result in wraparound if the value is too large for the kind.
1825
085c0ba6 1826Finally, note that enabling any of the @option{-finit-*} options will
1827silence warnings that would have been emitted by @option{-Wuninitialized}
1828for the affected local variables.
1829
58601acb 1830@item -falign-commons
1831@opindex @code{falign-commons}
12786727 1832@cindex alignment of @code{COMMON} blocks
58601acb 1833By default, @command{gfortran} enforces proper alignment of all variables in a
12786727 1834@code{COMMON} block by padding them as needed. On certain platforms this is mandatory,
1835on others it increases performance. If a @code{COMMON} block is not declared with
58601acb 1836consistent data types everywhere, this padding can cause trouble, and
12786727 1837@option{-fno-align-commons} can be used to disable automatic alignment. The
1838same form of this option should be used for all files that share a @code{COMMON} block.
1839To avoid potential alignment issues in @code{COMMON} blocks, it is recommended to order
67c11f5d 1840objects from largest to smallest.
54564d01 1841
1842@item -fno-protect-parens
1843@opindex @code{fno-protect-parens}
67c11f5d 1844@cindex re-association of parenthesized expressions
54564d01 1845By default the parentheses in expression are honored for all optimization
1846levels such that the compiler does not do any re-association. Using
12786727 1847@option{-fno-protect-parens} allows the compiler to reorder @code{REAL} and
1848@code{COMPLEX} expressions to produce faster code. Note that for the re-association
54564d01 1849optimization @option{-fno-signed-zeros} and @option{-fno-trapping-math}
9d4ede2c 1850need to be in effect. The parentheses protection is enabled by default, unless
1851@option{-Ofast} is given.
929c6f45 1852
1853@item -frealloc-lhs
1854@opindex @code{frealloc-lhs}
1855@cindex Reallocate the LHS in assignments
1856An allocatable left-hand side of an intrinsic assignment is automatically
1857(re)allocated if it is either unallocated or has a different shape. The
c78a1d18 1858option is enabled by default except when @option{-std=f95} is given. See
1859also @option{-Wrealloc-lhs}.
bf48f16e 1860
1861@item -faggressive-function-elimination
1862@opindex @code{faggressive-function-elimination}
1863@cindex Elimination of functions with identical argument lists
1864Functions with identical argument lists are eliminated within
1865statements, regardless of whether these functions are marked
1866@code{PURE} or not. For example, in
1867@smallexample
1868 a = f(b,c) + f(b,c)
1869@end smallexample
10b2bb30 1870there will only be a single call to @code{f}. This option only works
1871if @option{-ffrontend-optimize} is in effect.
1872
1873@item -ffrontend-optimize
1874@opindex @code{frontend-optimize}
1875@cindex Front-end optimization
1876This option performs front-end optimization, based on manipulating
229c0ef7 1877parts the Fortran parse tree. Enabled by default by any @option{-O} option
1878except @option{-O0} and @option{-Og}. Optimizations enabled by this option
1879include:
1880@itemize @bullet
1881@item inlining calls to @code{MATMUL},
1882@item elimination of identical function calls within expressions,
1883@item removing unnecessary calls to @code{TRIM} in comparisons and assignments,
1884@item replacing @code{TRIM(a)} with @code{a(1:LEN_TRIM(a))} and
1885@item short-circuiting of logical operators (@code{.AND.} and @code{.OR.}).
1886@end itemize
1887It can be deselected by specifying @option{-fno-frontend-optimize}.
44319903 1888
1889@item -ffrontend-loop-interchange
1890@opindex @code{frontend-loop-interchange}
1891@cindex loop interchange, Fortran
1892Attempt to interchange loops in the Fortran front end where
1893profitable. Enabled by default by any @option{-O} option.
1894At the moment, this option only affects @code{FORALL} and
1895@code{DO CONCURRENT} statements with several forall triplets.
4ee9c684 1896@end table
1897
1898@xref{Code Gen Options,,Options for Code Generation Conventions,
1899gcc,Using the GNU Compiler Collection (GCC)}, for information on more options
1900offered by the GBE
61156d26 1901shared by @command{gfortran}, @command{gcc}, and other GNU compilers.
4ee9c684 1902
4ee9c684 1903@c man end
1904
41084313 1905@node Interoperability Options
1906@section Options for interoperability with other languages
1907
1908@table @asis
1909
1910@item -fc-prototypes
1911@opindex @code{c-prototypes}
6d658980 1912@cindex Generating C prototypes from Fortran BIND(C) enteties
41084313 1913This option will generate C prototypes from @code{BIND(C)} variable
1914declarations, types and procedure interfaces and writes them to
1915standard output. @code{ENUM} is not yet supported.
1916
1917The generated prototypes may need inclusion of an appropriate header,
1918such as @code{<stdint.h>} or @code{<stdlib.h>}. For types which are
1919not specified using the appropriate kind from the @code{iso_c_binding}
1920module, a warning is added as a comment to the code.
1921
1922For function pointers, a pointer to a function returning @code{int}
1923without an explicit argument list is generated.
1924
1925Example of use:
1926@smallexample
1927$ gfortran -fc-prototypes -fsyntax-only foo.f90 > foo.h
1928@end smallexample
1929where the C code intended for interoperating with the Fortran code
1930then uses @code{#include "foo.h"}.
6d658980 1931
1932@item -fc-prototypes-external
1933@opindex @code{c-prototypes-external}
1934@cindex Generating C prototypes from external procedures
1935This option will generate C prototypes from external functions and
1936subroutines and write them to standard output. This may be useful for
1937making sure that C bindings to Fortran code are correct. This option
1938does not generate prototypes for @code{BIND(C)} procedures, use
1939@option{-fc-prototypes} for that.
1940
1941The generated prototypes may need inclusion of an appropriate
1942header, such as as @code{<stdint.h>} or @code{<stdlib.h>}.
1943
1944This is primarily meant for legacy code to ensure that existing C
1945bindings match what @command{gfortran} emits. The generated C
1946prototypes should be correct for the current version of the compiler,
1947but may not match what other compilers or earlier versions of
1948@command{gfortran} need. For new developments, use of the
1949@code{BIND(C)} features is recommended.
1950
1951Example of use:
1952@smallexample
1953$ gfortran -fc-prototypes-external -fsyntax-only foo.f > foo.h
1954@end smallexample
1955where the C code intended for interoperating with the Fortran code
1956then uses @code{#include "foo.h"}.
41084313 1957@end table
1958
4ee9c684 1959@node Environment Variables
138b8aca 1960@section Environment variables affecting @command{gfortran}
a1149005 1961@cindex environment variable
4ee9c684 1962
1963@c man begin ENVIRONMENT
1964
61156d26 1965The @command{gfortran} compiler currently does not make use of any environment
4ee9c684 1966variables to control its operation above and beyond those
1967that affect the operation of @command{gcc}.
1968
1969@xref{Environment Variables,,Environment Variables Affecting GCC,
1970gcc,Using the GNU Compiler Collection (GCC)}, for information on environment
1971variables.
1972
15774a8b 1973@xref{Runtime}, for environment variables that affect the
61156d26 1974run-time behavior of programs compiled with GNU Fortran.
4ee9c684 1975@c man end