xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/fortran/invoke.texi (revision 4c3eb207d36f67d31994830c0a694161fc1ca39b)
1*4c3eb207Smrg@c Copyright (C) 2004-2020 Free Software Foundation, Inc.
2627f7eb2Smrg@c This is part of the GNU Fortran manual.
3627f7eb2Smrg@c For copying conditions, see the file gfortran.texi.
4627f7eb2Smrg
5627f7eb2Smrg@ignore
6627f7eb2Smrg@c man begin COPYRIGHT
7*4c3eb207SmrgCopyright @copyright{} 2004-2020 Free Software Foundation, Inc.
8627f7eb2Smrg
9627f7eb2SmrgPermission is granted to copy, distribute and/or modify this document
10627f7eb2Smrgunder the terms of the GNU Free Documentation License, Version 1.3 or
11627f7eb2Smrgany later version published by the Free Software Foundation; with the
12627f7eb2SmrgInvariant Sections being ``Funding Free Software'', the Front-Cover
13627f7eb2SmrgTexts being (a) (see below), and with the Back-Cover Texts being (b)
14627f7eb2Smrg(see below).  A copy of the license is included in the gfdl(7) man page.
15627f7eb2Smrg
16627f7eb2Smrg(a) The FSF's Front-Cover Text is:
17627f7eb2Smrg
18627f7eb2Smrg     A GNU Manual
19627f7eb2Smrg
20627f7eb2Smrg(b) The FSF's Back-Cover Text is:
21627f7eb2Smrg
22627f7eb2Smrg     You have freedom to copy and modify this GNU Manual, like GNU
23627f7eb2Smrg     software.  Copies published by the Free Software Foundation raise
24627f7eb2Smrg     funds for GNU development.
25627f7eb2Smrg@c man end
26627f7eb2Smrg@c Set file name and title for the man page.
27627f7eb2Smrg@setfilename gfortran
28627f7eb2Smrg@settitle GNU Fortran compiler.
29627f7eb2Smrg@c man begin SYNOPSIS
30627f7eb2Smrggfortran [@option{-c}|@option{-S}|@option{-E}]
31627f7eb2Smrg         [@option{-g}] [@option{-pg}] [@option{-O}@var{level}]
32627f7eb2Smrg         [@option{-W}@var{warn}@dots{}] [@option{-pedantic}]
33627f7eb2Smrg         [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
34627f7eb2Smrg         [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}]
35627f7eb2Smrg         [@option{-f}@var{option}@dots{}]
36627f7eb2Smrg         [@option{-m}@var{machine-option}@dots{}]
37627f7eb2Smrg         [@option{-o} @var{outfile}] @var{infile}@dots{}
38627f7eb2Smrg
39627f7eb2SmrgOnly the most useful options are listed here; see below for the
40627f7eb2Smrgremainder.
41627f7eb2Smrg@c man end
42627f7eb2Smrg@c man begin SEEALSO
43627f7eb2Smrggpl(7), gfdl(7), fsf-funding(7),
44627f7eb2Smrgcpp(1), gcov(1), gcc(1), as(1), ld(1), gdb(1), dbx(1)
45627f7eb2Smrgand the Info entries for @file{gcc}, @file{cpp}, @file{gfortran}, @file{as},
46627f7eb2Smrg@file{ld}, @file{binutils} and @file{gdb}.
47627f7eb2Smrg@c man end
48627f7eb2Smrg@c man begin BUGS
49627f7eb2SmrgFor instructions on reporting bugs, see
50627f7eb2Smrg@w{@value{BUGURL}}.
51627f7eb2Smrg@c man end
52627f7eb2Smrg@c man begin AUTHOR
53627f7eb2SmrgSee the Info entry for @command{gfortran} for contributors to GCC and
54627f7eb2SmrgGNU Fortran.
55627f7eb2Smrg@c man end
56627f7eb2Smrg@end ignore
57627f7eb2Smrg
58627f7eb2Smrg@node Invoking GNU Fortran
59627f7eb2Smrg@chapter GNU Fortran Command Options
60627f7eb2Smrg@cindex GNU Fortran command options
61627f7eb2Smrg@cindex command options
62627f7eb2Smrg@cindex options, @command{gfortran} command
63627f7eb2Smrg
64627f7eb2Smrg@c man begin DESCRIPTION
65627f7eb2Smrg
66627f7eb2SmrgThe @command{gfortran} command supports all the options supported by the
67627f7eb2Smrg@command{gcc} command.  Only options specific to GNU Fortran are documented
68627f7eb2Smrghere.
69627f7eb2Smrg
70627f7eb2Smrg@xref{Invoking GCC,,GCC Command Options,gcc,Using the GNU Compiler
71627f7eb2SmrgCollection (GCC)}, for information
72627f7eb2Smrgon the non-Fortran-specific aspects of the @command{gcc} command (and,
73627f7eb2Smrgtherefore, the @command{gfortran} command).
74627f7eb2Smrg
75627f7eb2Smrg@cindex options, negative forms
76627f7eb2SmrgAll GCC and GNU Fortran options
77627f7eb2Smrgare accepted both by @command{gfortran} and by @command{gcc}
78627f7eb2Smrg(as well as any other drivers built at the same time,
79627f7eb2Smrgsuch as @command{g++}),
80627f7eb2Smrgsince adding GNU Fortran to the GCC distribution
81627f7eb2Smrgenables acceptance of GNU Fortran options
82627f7eb2Smrgby all of the relevant drivers.
83627f7eb2Smrg
84627f7eb2SmrgIn some cases, options have positive and negative forms;
85627f7eb2Smrgthe negative form of @option{-ffoo} would be @option{-fno-foo}.
86627f7eb2SmrgThis manual documents only one of these two forms, whichever
87627f7eb2Smrgone is not the default.
88627f7eb2Smrg@c man end
89627f7eb2Smrg
90627f7eb2Smrg@menu
91627f7eb2Smrg* Option Summary::      Brief list of all @command{gfortran} options,
92627f7eb2Smrg                        without explanations.
93627f7eb2Smrg* Fortran Dialect Options::  Controlling the variant of Fortran language
94627f7eb2Smrg                             compiled.
95627f7eb2Smrg* Preprocessing Options::  Enable and customize preprocessing.
96627f7eb2Smrg* Error and Warning Options::     How picky should the compiler be?
97627f7eb2Smrg* Debugging Options::   Symbol tables, measurements, and debugging dumps.
98627f7eb2Smrg* Directory Options::   Where to find module files
99627f7eb2Smrg* Link Options ::       Influencing the linking step
100627f7eb2Smrg* Runtime Options::     Influencing runtime behavior
101627f7eb2Smrg* Code Gen Options::    Specifying conventions for function calls, data layout
102627f7eb2Smrg                        and register usage.
103627f7eb2Smrg* Interoperability Options::  Options for interoperability with other
104627f7eb2Smrg                              languages.
105627f7eb2Smrg* Environment Variables:: Environment variables that affect @command{gfortran}.
106627f7eb2Smrg@end menu
107627f7eb2Smrg
108627f7eb2Smrg@node Option Summary
109627f7eb2Smrg@section Option summary
110627f7eb2Smrg
111627f7eb2Smrg@c man begin OPTIONS
112627f7eb2Smrg
113627f7eb2SmrgHere is a summary of all the options specific to GNU Fortran, grouped
114627f7eb2Smrgby type.  Explanations are in the following sections.
115627f7eb2Smrg
116627f7eb2Smrg@table @emph
117627f7eb2Smrg@item Fortran Language Options
118627f7eb2Smrg@xref{Fortran Dialect Options,,Options controlling Fortran dialect}.
119*4c3eb207Smrg@gccoptlist{-fall-intrinsics -fallow-argument-mismatch -fallow-invalid-boz @gol
120*4c3eb207Smrg-fbackslash -fcray-pointer -fd-lines-as-code -fd-lines-as-comments @gol
121*4c3eb207Smrg-fdec -fdec-char-conversions -fdec-structure -fdec-intrinsic-ints @gol
122*4c3eb207Smrg-fdec-static -fdec-math -fdec-include -fdec-format-defaults @gol
123*4c3eb207Smrg-fdec-blank-format-item -fdefault-double-8 -fdefault-integer-8 @gol
124*4c3eb207Smrg-fdefault-real-8 -fdefault-real-10 -fdefault-real-16 -fdollar-ok @gol
125*4c3eb207Smrg-ffixed-line-length-@var{n} -ffixed-line-length-none -fpad-source @gol
126*4c3eb207Smrg-ffree-form -ffree-line-length-@var{n} -ffree-line-length-none @gol
127*4c3eb207Smrg-fimplicit-none -finteger-4-integer-8 -fmax-identifier-length @gol
128*4c3eb207Smrg-fmodule-private -ffixed-form -fno-range-check -fopenacc -fopenmp @gol
129*4c3eb207Smrg-freal-4-real-10 -freal-4-real-16 -freal-4-real-8 -freal-8-real-10 @gol
130*4c3eb207Smrg-freal-8-real-16 -freal-8-real-4 -std=@var{std} -ftest-forall-temp
131627f7eb2Smrg}
132627f7eb2Smrg
133627f7eb2Smrg@item Preprocessing Options
134627f7eb2Smrg@xref{Preprocessing Options,,Enable and customize preprocessing}.
135627f7eb2Smrg@gccoptlist{-A-@var{question}@r{[}=@var{answer}@r{]}
136627f7eb2Smrg-A@var{question}=@var{answer} -C -CC -D@var{macro}@r{[}=@var{defn}@r{]}
137627f7eb2Smrg-H -P @gol
138627f7eb2Smrg-U@var{macro} -cpp -dD -dI -dM -dN -dU -fworking-directory
139627f7eb2Smrg-imultilib @var{dir} @gol
140627f7eb2Smrg-iprefix @var{file} -iquote -isysroot @var{dir} -isystem @var{dir} -nocpp
141627f7eb2Smrg-nostdinc @gol
142627f7eb2Smrg-undef
143627f7eb2Smrg}
144627f7eb2Smrg
145627f7eb2Smrg@item Error and Warning Options
146627f7eb2Smrg@xref{Error and Warning Options,,Options to request or suppress errors
147627f7eb2Smrgand warnings}.
148*4c3eb207Smrg@gccoptlist{-Waliasing -Wall -Wampersand -Warray-bounds @gol
149627f7eb2Smrg-Wc-binding-type -Wcharacter-truncation -Wconversion @gol
150627f7eb2Smrg-Wdo-subscript -Wfunction-elimination -Wimplicit-interface @gol
151*4c3eb207Smrg-Wimplicit-procedure -Wintrinsic-shadow -Wuse-without-only @gol
152*4c3eb207Smrg-Wintrinsics-std -Wline-truncation -Wno-align-commons @gol
153*4c3eb207Smrg-Wno-overwrite-recursive -Wno-tabs -Wreal-q-constant -Wsurprising @gol
154*4c3eb207Smrg-Wunderflow -Wunused-parameter -Wrealloc-lhs -Wrealloc-lhs-all @gol
155*4c3eb207Smrg-Wfrontend-loop-interchange -Wtarget-lifetime -fmax-errors=@var{n} @gol
156*4c3eb207Smrg-fsyntax-only -pedantic @gol
157*4c3eb207Smrg-pedantic-errors @gol
158627f7eb2Smrg}
159627f7eb2Smrg
160627f7eb2Smrg@item Debugging Options
161627f7eb2Smrg@xref{Debugging Options,,Options for debugging your program or GNU Fortran}.
162627f7eb2Smrg@gccoptlist{-fbacktrace -fdump-fortran-optimized -fdump-fortran-original @gol
163627f7eb2Smrg-fdump-fortran-global -fdump-parse-tree -ffpe-trap=@var{list} @gol
164627f7eb2Smrg-ffpe-summary=@var{list}
165627f7eb2Smrg}
166627f7eb2Smrg
167627f7eb2Smrg@item Directory Options
168627f7eb2Smrg@xref{Directory Options,,Options for directory search}.
169627f7eb2Smrg@gccoptlist{-I@var{dir}  -J@var{dir} -fintrinsic-modules-path @var{dir}}
170627f7eb2Smrg
171627f7eb2Smrg@item Link Options
172627f7eb2Smrg@xref{Link Options,,Options for influencing the linking step}.
173627f7eb2Smrg@gccoptlist{-static-libgfortran}
174627f7eb2Smrg
175627f7eb2Smrg@item Runtime Options
176627f7eb2Smrg@xref{Runtime Options,,Options for influencing runtime behavior}.
177627f7eb2Smrg@gccoptlist{-fconvert=@var{conversion} -fmax-subrecord-length=@var{length} @gol
178627f7eb2Smrg-frecord-marker=@var{length} -fsign-zero
179627f7eb2Smrg}
180627f7eb2Smrg
181627f7eb2Smrg@item Interoperability Options
182627f7eb2Smrg@xref{Interoperability Options,,Options for interoperability}.
183627f7eb2Smrg@gccoptlist{-fc-prototypes -fc-prototypes-external}
184627f7eb2Smrg
185627f7eb2Smrg@item Code Generation Options
186627f7eb2Smrg@xref{Code Gen Options,,Options for code generation conventions}.
187627f7eb2Smrg@gccoptlist{-faggressive-function-elimination -fblas-matmul-limit=@var{n} @gol
188627f7eb2Smrg-fbounds-check -ftail-call-workaround -ftail-call-workaround=@var{n} @gol
189627f7eb2Smrg-fcheck-array-temporaries @gol
190*4c3eb207Smrg-fcheck=@var{<all|array-temps|bits|bounds|do|mem|pointer|recursion>} @gol
191*4c3eb207Smrg-fcoarray=@var{<none|single|lib>} -fexternal-blas -ff2c @gol
192*4c3eb207Smrg-ffrontend-loop-interchange -ffrontend-optimize @gol
193627f7eb2Smrg-finit-character=@var{n} -finit-integer=@var{n} -finit-local-zero @gol
194*4c3eb207Smrg-finit-derived -finit-logical=@var{<true|false>} @gol
195*4c3eb207Smrg-finit-real=@var{<zero|inf|-inf|nan|snan>}
196627f7eb2Smrg-finline-matmul-limit=@var{n} @gol
197*4c3eb207Smrg-finline-arg-packing -fmax-array-constructor=@var{n} @gol
198*4c3eb207Smrg-fmax-stack-var-size=@var{n} -fno-align-commons -fno-automatic @gol
199*4c3eb207Smrg-fno-protect-parens -fno-underscoring -fsecond-underscore @gol
200*4c3eb207Smrg-fpack-derived -frealloc-lhs -frecursive -frepack-arrays @gol
201*4c3eb207Smrg-fshort-enums -fstack-arrays
202627f7eb2Smrg}
203627f7eb2Smrg@end table
204627f7eb2Smrg
205627f7eb2Smrg@node Fortran Dialect Options
206627f7eb2Smrg@section Options controlling Fortran dialect
207627f7eb2Smrg@cindex dialect options
208627f7eb2Smrg@cindex language, dialect options
209627f7eb2Smrg@cindex options, dialect
210627f7eb2Smrg
211627f7eb2SmrgThe following options control the details of the Fortran dialect
212627f7eb2Smrgaccepted by the compiler:
213627f7eb2Smrg
214627f7eb2Smrg@table @gcctabopt
215627f7eb2Smrg@item -ffree-form
216627f7eb2Smrg@itemx -ffixed-form
217627f7eb2Smrg@opindex @code{ffree-form}
218627f7eb2Smrg@opindex @code{ffixed-form}
219627f7eb2Smrg@cindex options, Fortran dialect
220627f7eb2Smrg@cindex file format, free
221627f7eb2Smrg@cindex file format, fixed
222627f7eb2SmrgSpecify the layout used by the source file.  The free form layout
223627f7eb2Smrgwas introduced in Fortran 90.  Fixed form was traditionally used in
224627f7eb2Smrgolder Fortran programs.  When neither option is specified, the source
225627f7eb2Smrgform is determined by the file extension.
226627f7eb2Smrg
227627f7eb2Smrg@item -fall-intrinsics
228627f7eb2Smrg@opindex @code{fall-intrinsics}
229627f7eb2SmrgThis option causes all intrinsic procedures (including the GNU-specific
230627f7eb2Smrgextensions) to be accepted.  This can be useful with @option{-std=f95} to
231627f7eb2Smrgforce standard-compliance but get access to the full range of intrinsics
232627f7eb2Smrgavailable with @command{gfortran}.  As a consequence, @option{-Wintrinsics-std}
233627f7eb2Smrgwill be ignored and no user-defined procedure with the same name as any
234627f7eb2Smrgintrinsic will be called except when it is explicitly declared @code{EXTERNAL}.
235627f7eb2Smrg
236*4c3eb207Smrg@item -fallow-argument-mismatch
237*4c3eb207Smrg@opindex @code{fallow-argument-mismatch}
238*4c3eb207SmrgSome code contains calls to external procedures whith mismatches
239*4c3eb207Smrgbetween the calls and the procedure definition, or with mismatches
240*4c3eb207Smrgbetween different calls. Such code is non-conforming, and will usually
241*4c3eb207Smrgbe flagged wi1th an error.  This options degrades the error to a
242*4c3eb207Smrgwarning, which can only be disabled by disabling all warnings vial
243*4c3eb207Smrg@option{-w}.  Only a single occurrence per argument is flagged by this
244*4c3eb207Smrgwarning.  @option{-fallow-argument-mismatch} is implied by
245*4c3eb207Smrg@option{-std=legacy}.
246*4c3eb207Smrg
247*4c3eb207SmrgUsing this option is @emph{strongly} discouraged.  It is possible to
248*4c3eb207Smrgprovide standard-conforming code which allows different types of
249*4c3eb207Smrgarguments by using an explicit interface and @code{TYPE(*)}.
250*4c3eb207Smrg
251*4c3eb207Smrg@item -fallow-invalid-boz
252*4c3eb207Smrg@opindex @code{allow-invalid-boz}
253*4c3eb207SmrgA BOZ literal constant can occur in a limited number of contexts in
254*4c3eb207Smrgstandard conforming Fortran.  This option degrades an error condition
255*4c3eb207Smrgto a warning, and allows a BOZ literal constant to appear where the
256*4c3eb207SmrgFortran standard would otherwise prohibit its use.
257*4c3eb207Smrg
258627f7eb2Smrg@item -fd-lines-as-code
259627f7eb2Smrg@itemx -fd-lines-as-comments
260627f7eb2Smrg@opindex @code{fd-lines-as-code}
261627f7eb2Smrg@opindex @code{fd-lines-as-comments}
262627f7eb2SmrgEnable special treatment for lines beginning with @code{d} or @code{D}
263627f7eb2Smrgin fixed form sources.  If the @option{-fd-lines-as-code} option is
264627f7eb2Smrggiven they are treated as if the first column contained a blank.  If the
265627f7eb2Smrg@option{-fd-lines-as-comments} option is given, they are treated as
266627f7eb2Smrgcomment lines.
267627f7eb2Smrg
268627f7eb2Smrg@item -fdec
269627f7eb2Smrg@opindex @code{fdec}
270627f7eb2SmrgDEC compatibility mode. Enables extensions and other features that mimic
271627f7eb2Smrgthe default behavior of older compilers (such as DEC).
272627f7eb2SmrgThese features are non-standard and should be avoided at all costs.
273627f7eb2SmrgFor details on GNU Fortran's implementation of these extensions see the
274627f7eb2Smrgfull documentation.
275627f7eb2Smrg
276627f7eb2SmrgOther flags enabled by this switch are:
277*4c3eb207Smrg@option{-fdollar-ok} @option{-fcray-pointer} @option{-fdec-char-conversions}
278*4c3eb207Smrg@option{-fdec-structure} @option{-fdec-intrinsic-ints} @option{-fdec-static}
279*4c3eb207Smrg@option{-fdec-math} @option{-fdec-include} @option{-fdec-blank-format-item}
280*4c3eb207Smrg@option{-fdec-format-defaults}
281627f7eb2Smrg
282627f7eb2SmrgIf @option{-fd-lines-as-code}/@option{-fd-lines-as-comments} are unset, then
283627f7eb2Smrg@option{-fdec} also sets @option{-fd-lines-as-comments}.
284627f7eb2Smrg
285*4c3eb207Smrg@item -fdec-char-conversions
286*4c3eb207Smrg@opindex @code{fdec-char-conversions}
287*4c3eb207SmrgEnable the use of character literals in assignments and @code{DATA} statements
288*4c3eb207Smrgfor non-character variables.
289*4c3eb207Smrg
290627f7eb2Smrg@item -fdec-structure
291627f7eb2Smrg@opindex @code{fdec-structure}
292627f7eb2SmrgEnable DEC @code{STRUCTURE} and @code{RECORD} as well as @code{UNION},
293627f7eb2Smrg@code{MAP}, and dot ('.') as a member separator (in addition to '%'). This is
294627f7eb2Smrgprovided for compatibility only; Fortran 90 derived types should be used
295627f7eb2Smrginstead where possible.
296627f7eb2Smrg
297627f7eb2Smrg@item -fdec-intrinsic-ints
298627f7eb2Smrg@opindex @code{fdec-intrinsic-ints}
299627f7eb2SmrgEnable B/I/J/K kind variants of existing integer functions (e.g. BIAND, IIAND,
300627f7eb2SmrgJIAND, etc...). For a complete list of intrinsics see the full documentation.
301627f7eb2Smrg
302627f7eb2Smrg@item -fdec-math
303627f7eb2Smrg@opindex @code{fdec-math}
304627f7eb2SmrgEnable legacy math intrinsics such as COTAN and degree-valued trigonometric
305627f7eb2Smrgfunctions (e.g. TAND, ATAND, etc...) for compatability with older code.
306627f7eb2Smrg
307627f7eb2Smrg@item -fdec-static
308627f7eb2Smrg@opindex @code{fdec-static}
309627f7eb2SmrgEnable DEC-style STATIC and AUTOMATIC attributes to explicitly specify
310627f7eb2Smrgthe storage of variables and other objects.
311627f7eb2Smrg
312627f7eb2Smrg@item -fdec-include
313627f7eb2Smrg@opindex @code{fdec-include}
314627f7eb2SmrgEnable parsing of INCLUDE as a statement in addition to parsing it as
315627f7eb2SmrgINCLUDE line.  When parsed as INCLUDE statement, INCLUDE does not have to
316627f7eb2Smrgbe on a single line and can use line continuations.
317627f7eb2Smrg
318*4c3eb207Smrg@item -fdec-format-defaults
319*4c3eb207Smrg@opindex @code{fdec-format-defaults}
320*4c3eb207SmrgEnable format specifiers F, G and I to be used without width specifiers,
321*4c3eb207Smrgdefault widths will be used instead.
322*4c3eb207Smrg
323*4c3eb207Smrg@item -fdec-blank-format-item
324*4c3eb207Smrg@opindex @code{fdec-blank-format-item}
325*4c3eb207SmrgEnable a blank format item at the end of a format specification i.e. nothing
326*4c3eb207Smrgfollowing the final comma.
327*4c3eb207Smrg
328627f7eb2Smrg@item -fdollar-ok
329627f7eb2Smrg@opindex @code{fdollar-ok}
330627f7eb2Smrg@cindex @code{$}
331627f7eb2Smrg@cindex symbol names
332627f7eb2Smrg@cindex character set
333627f7eb2SmrgAllow @samp{$} as a valid non-first character in a symbol name. Symbols
334627f7eb2Smrgthat start with @samp{$} are rejected since it is unclear which rules to
335627f7eb2Smrgapply to implicit typing as different vendors implement different rules.
336627f7eb2SmrgUsing @samp{$} in @code{IMPLICIT} statements is also rejected.
337627f7eb2Smrg
338627f7eb2Smrg@item -fbackslash
339627f7eb2Smrg@opindex @code{backslash}
340627f7eb2Smrg@cindex backslash
341627f7eb2Smrg@cindex escape characters
342627f7eb2SmrgChange the interpretation of backslashes in string literals from a single
343627f7eb2Smrgbackslash character to ``C-style'' escape characters. The following
344627f7eb2Smrgcombinations are expanded @code{\a}, @code{\b}, @code{\f}, @code{\n},
345627f7eb2Smrg@code{\r}, @code{\t}, @code{\v}, @code{\\}, and @code{\0} to the ASCII
346627f7eb2Smrgcharacters alert, backspace, form feed, newline, carriage return,
347627f7eb2Smrghorizontal tab, vertical tab, backslash, and NUL, respectively.
348627f7eb2SmrgAdditionally, @code{\x}@var{nn}, @code{\u}@var{nnnn} and
349627f7eb2Smrg@code{\U}@var{nnnnnnnn} (where each @var{n} is a hexadecimal digit) are
350627f7eb2Smrgtranslated into the Unicode characters corresponding to the specified code
351627f7eb2Smrgpoints. All other combinations of a character preceded by \ are
352627f7eb2Smrgunexpanded.
353627f7eb2Smrg
354627f7eb2Smrg@item -fmodule-private
355627f7eb2Smrg@opindex @code{fmodule-private}
356627f7eb2Smrg@cindex module entities
357627f7eb2Smrg@cindex private
358627f7eb2SmrgSet the default accessibility of module entities to @code{PRIVATE}.
359627f7eb2SmrgUse-associated entities will not be accessible unless they are explicitly
360627f7eb2Smrgdeclared as @code{PUBLIC}.
361627f7eb2Smrg
362627f7eb2Smrg@item -ffixed-line-length-@var{n}
363627f7eb2Smrg@opindex @code{ffixed-line-length-}@var{n}
364627f7eb2Smrg@cindex file format, fixed
365627f7eb2SmrgSet column after which characters are ignored in typical fixed-form
366627f7eb2Smrglines in the source file, and, unless @code{-fno-pad-source}, through which
367627f7eb2Smrgspaces are assumed (as if padded to that length) after the ends of short
368627f7eb2Smrgfixed-form lines.
369627f7eb2Smrg
370627f7eb2SmrgPopular values for @var{n} include 72 (the
371627f7eb2Smrgstandard and the default), 80 (card image), and 132 (corresponding
372627f7eb2Smrgto ``extended-source'' options in some popular compilers).
373627f7eb2Smrg@var{n} may also be @samp{none}, meaning that the entire line is meaningful
374627f7eb2Smrgand that continued character constants never have implicit spaces appended
375627f7eb2Smrgto them to fill out the line.
376627f7eb2Smrg@option{-ffixed-line-length-0} means the same thing as
377627f7eb2Smrg@option{-ffixed-line-length-none}.
378627f7eb2Smrg
379627f7eb2Smrg@item -fno-pad-source
380627f7eb2Smrg@opindex @code{fpad-source}
381627f7eb2SmrgBy default fixed-form lines have spaces assumed (as if padded to that length)
382627f7eb2Smrgafter the ends of short fixed-form lines.  This is not done either if
383627f7eb2Smrg@option{-ffixed-line-length-0}, @option{-ffixed-line-length-none} or
384627f7eb2Smrgif @option{-fno-pad-source} option is used.  With any of those options
385627f7eb2Smrgcontinued character constants never have implicit spaces appended
386627f7eb2Smrgto them to fill out the line.
387627f7eb2Smrg
388627f7eb2Smrg@item -ffree-line-length-@var{n}
389627f7eb2Smrg@opindex @code{ffree-line-length-}@var{n}
390627f7eb2Smrg@cindex file format, free
391627f7eb2SmrgSet column after which characters are ignored in typical free-form
392627f7eb2Smrglines in the source file. The default value is 132.
393627f7eb2Smrg@var{n} may be @samp{none}, meaning that the entire line is meaningful.
394627f7eb2Smrg@option{-ffree-line-length-0} means the same thing as
395627f7eb2Smrg@option{-ffree-line-length-none}.
396627f7eb2Smrg
397627f7eb2Smrg@item -fmax-identifier-length=@var{n}
398627f7eb2Smrg@opindex @code{fmax-identifier-length=}@var{n}
399627f7eb2SmrgSpecify the maximum allowed identifier length. Typical values are
400627f7eb2Smrg31 (Fortran 95) and 63 (Fortran 2003 and Fortran 2008).
401627f7eb2Smrg
402627f7eb2Smrg@item -fimplicit-none
403627f7eb2Smrg@opindex @code{fimplicit-none}
404627f7eb2SmrgSpecify that no implicit typing is allowed, unless overridden by explicit
405627f7eb2Smrg@code{IMPLICIT} statements.  This is the equivalent of adding
406627f7eb2Smrg@code{implicit none} to the start of every procedure.
407627f7eb2Smrg
408627f7eb2Smrg@item -fcray-pointer
409627f7eb2Smrg@opindex @code{fcray-pointer}
410627f7eb2SmrgEnable the Cray pointer extension, which provides C-like pointer
411627f7eb2Smrgfunctionality.
412627f7eb2Smrg
413627f7eb2Smrg@item -fopenacc
414627f7eb2Smrg@opindex @code{fopenacc}
415627f7eb2Smrg@cindex OpenACC
416627f7eb2SmrgEnable the OpenACC extensions.  This includes OpenACC @code{!$acc}
417627f7eb2Smrgdirectives in free form and @code{c$acc}, @code{*$acc} and
418627f7eb2Smrg@code{!$acc} directives in fixed form, @code{!$} conditional
419627f7eb2Smrgcompilation sentinels in free form and @code{c$}, @code{*$} and
420627f7eb2Smrg@code{!$} sentinels in fixed form, and when linking arranges for the
421627f7eb2SmrgOpenACC runtime library to be linked in.
422627f7eb2Smrg
423627f7eb2Smrg@item -fopenmp
424627f7eb2Smrg@opindex @code{fopenmp}
425627f7eb2Smrg@cindex OpenMP
426627f7eb2SmrgEnable the OpenMP extensions.  This includes OpenMP @code{!$omp} directives
427627f7eb2Smrgin free form
428627f7eb2Smrgand @code{c$omp}, @code{*$omp} and @code{!$omp} directives in fixed form,
429627f7eb2Smrg@code{!$} conditional compilation sentinels in free form
430627f7eb2Smrgand @code{c$}, @code{*$} and @code{!$} sentinels in fixed form,
431627f7eb2Smrgand when linking arranges for the OpenMP runtime library to be linked
432627f7eb2Smrgin.  The option @option{-fopenmp} implies @option{-frecursive}.
433627f7eb2Smrg
434627f7eb2Smrg@item -fno-range-check
435627f7eb2Smrg@opindex @code{frange-check}
436627f7eb2SmrgDisable range checking on results of simplification of constant
437627f7eb2Smrgexpressions during compilation.  For example, GNU Fortran will give
438627f7eb2Smrgan error at compile time when simplifying @code{a = 1. / 0}.
439627f7eb2SmrgWith this option, no error will be given and @code{a} will be assigned
440627f7eb2Smrgthe value @code{+Infinity}.  If an expression evaluates to a value
441627f7eb2Smrgoutside of the relevant range of [@code{-HUGE()}:@code{HUGE()}],
442627f7eb2Smrgthen the expression will be replaced by @code{-Inf} or @code{+Inf}
443627f7eb2Smrgas appropriate.
444627f7eb2SmrgSimilarly, @code{DATA i/Z'FFFFFFFF'/} will result in an integer overflow
445627f7eb2Smrgon most systems, but with @option{-fno-range-check} the value will
446627f7eb2Smrg``wrap around'' and @code{i} will be initialized to @math{-1} instead.
447627f7eb2Smrg
448627f7eb2Smrg@item -fdefault-integer-8
449627f7eb2Smrg@opindex @code{fdefault-integer-8}
450627f7eb2SmrgSet the default integer and logical types to an 8 byte wide type.  This option
451627f7eb2Smrgalso affects the kind of integer constants like @code{42}. Unlike
452627f7eb2Smrg@option{-finteger-4-integer-8}, it does not promote variables with explicit
453627f7eb2Smrgkind declaration.
454627f7eb2Smrg
455627f7eb2Smrg@item -fdefault-real-8
456627f7eb2Smrg@opindex @code{fdefault-real-8}
457627f7eb2SmrgSet the default real type to an 8 byte wide type.  This option also affects
458627f7eb2Smrgthe kind of non-double real constants like @code{1.0}.  This option promotes
459627f7eb2Smrgthe default width of @code{DOUBLE PRECISION} and double real constants
460627f7eb2Smrglike @code{1.d0} to 16 bytes if possible.  If @code{-fdefault-double-8}
461627f7eb2Smrgis given along with @code{fdefault-real-8}, @code{DOUBLE PRECISION}
462627f7eb2Smrgand double real constants are not promoted.  Unlike @option{-freal-4-real-8},
463627f7eb2Smrg@code{fdefault-real-8} does not promote variables with explicit kind
464627f7eb2Smrgdeclarations.
465627f7eb2Smrg
466627f7eb2Smrg@item -fdefault-real-10
467627f7eb2Smrg@opindex @code{fdefault-real-10}
468627f7eb2SmrgSet the default real type to an 10 byte wide type.  This option also affects
469627f7eb2Smrgthe kind of non-double real constants like @code{1.0}.  This option promotes
470627f7eb2Smrgthe default width of @code{DOUBLE PRECISION} and double real constants
471627f7eb2Smrglike @code{1.d0} to 16 bytes if possible.  If @code{-fdefault-double-8}
472627f7eb2Smrgis given along with @code{fdefault-real-10}, @code{DOUBLE PRECISION}
473627f7eb2Smrgand double real constants are not promoted.  Unlike @option{-freal-4-real-10},
474627f7eb2Smrg@code{fdefault-real-10} does not promote variables with explicit kind
475627f7eb2Smrgdeclarations.
476627f7eb2Smrg
477627f7eb2Smrg@item -fdefault-real-16
478627f7eb2Smrg@opindex @code{fdefault-real-16}
479627f7eb2SmrgSet the default real type to an 16 byte wide type.  This option also affects
480627f7eb2Smrgthe kind of non-double real constants like @code{1.0}.  This option promotes
481627f7eb2Smrgthe default width of @code{DOUBLE PRECISION} and double real constants
482627f7eb2Smrglike @code{1.d0} to 16 bytes if possible.  If @code{-fdefault-double-8}
483627f7eb2Smrgis given along with @code{fdefault-real-16}, @code{DOUBLE PRECISION}
484627f7eb2Smrgand double real constants are not promoted.  Unlike @option{-freal-4-real-16},
485627f7eb2Smrg@code{fdefault-real-16} does not promote variables with explicit kind
486627f7eb2Smrgdeclarations.
487627f7eb2Smrg
488627f7eb2Smrg@item -fdefault-double-8
489627f7eb2Smrg@opindex @code{fdefault-double-8}
490627f7eb2SmrgSet the @code{DOUBLE PRECISION} type and double real constants
491627f7eb2Smrglike @code{1.d0} to an 8 byte wide type.  Do nothing if this
492627f7eb2Smrgis already the default.  This option prevents @option{-fdefault-real-8},
493627f7eb2Smrg@option{-fdefault-real-10}, and @option{-fdefault-real-16},
494627f7eb2Smrgfrom promoting @code{DOUBLE PRECISION} and double real constants like
495627f7eb2Smrg@code{1.d0} to 16 bytes.
496627f7eb2Smrg
497627f7eb2Smrg@item -finteger-4-integer-8
498627f7eb2Smrg@opindex @code{finteger-4-integer-8}
499627f7eb2SmrgPromote all @code{INTEGER(KIND=4)} entities to an @code{INTEGER(KIND=8)}
500627f7eb2Smrgentities.  If @code{KIND=8} is unavailable, then an error will be issued.
501627f7eb2SmrgThis option should be used with care and may not be suitable for your codes.
502627f7eb2SmrgAreas of possible concern include calls to external procedures,
503627f7eb2Smrgalignment in @code{EQUIVALENCE} and/or @code{COMMON}, generic interfaces,
504627f7eb2SmrgBOZ literal constant conversion, and I/O.  Inspection of the intermediate
505627f7eb2Smrgrepresentation of the translated Fortran code, produced by
506627f7eb2Smrg@option{-fdump-tree-original}, is suggested.
507627f7eb2Smrg
508627f7eb2Smrg@item  -freal-4-real-8
509627f7eb2Smrg@itemx -freal-4-real-10
510627f7eb2Smrg@itemx -freal-4-real-16
511627f7eb2Smrg@itemx -freal-8-real-4
512627f7eb2Smrg@itemx -freal-8-real-10
513627f7eb2Smrg@itemx -freal-8-real-16
514627f7eb2Smrg@opindex @code{freal-4-real-8}
515627f7eb2Smrg@opindex @code{freal-4-real-10}
516627f7eb2Smrg@opindex @code{freal-4-real-16}
517627f7eb2Smrg@opindex @code{freal-8-real-4}
518627f7eb2Smrg@opindex @code{freal-8-real-10}
519627f7eb2Smrg@opindex @code{freal-8-real-16}
520627f7eb2Smrg@cindex options, real kind type promotion
521627f7eb2SmrgPromote all @code{REAL(KIND=M)} entities to @code{REAL(KIND=N)} entities.
522627f7eb2SmrgIf @code{REAL(KIND=N)} is unavailable, then an error will be issued.
523627f7eb2SmrgAll other real kind types are unaffected by this option.
524627f7eb2SmrgThese options should be used with care and may not be suitable for your
525627f7eb2Smrgcodes.  Areas of possible concern include calls to external procedures,
526627f7eb2Smrgalignment in @code{EQUIVALENCE} and/or @code{COMMON}, generic interfaces,
527627f7eb2SmrgBOZ literal constant conversion, and I/O.  Inspection of the intermediate
528627f7eb2Smrgrepresentation of the translated Fortran code, produced by
529627f7eb2Smrg@option{-fdump-tree-original}, is suggested.
530627f7eb2Smrg
531627f7eb2Smrg@item -std=@var{std}
532627f7eb2Smrg@opindex @code{std=}@var{std} option
533627f7eb2SmrgSpecify the standard to which the program is expected to conform,
534627f7eb2Smrgwhich may be one of @samp{f95}, @samp{f2003}, @samp{f2008},
535627f7eb2Smrg@samp{f2018}, @samp{gnu}, or @samp{legacy}.  The default value for
536627f7eb2Smrg@var{std} is @samp{gnu}, which specifies a superset of the latest
537627f7eb2SmrgFortran standard that includes all of the extensions supported by GNU
538627f7eb2SmrgFortran, although warnings will be given for obsolete extensions not
539627f7eb2Smrgrecommended for use in new code.  The @samp{legacy} value is
540627f7eb2Smrgequivalent but without the warnings for obsolete extensions, and may
541627f7eb2Smrgbe useful for old non-standard programs.  The @samp{f95},
542627f7eb2Smrg@samp{f2003}, @samp{f2008}, and @samp{f2018} values specify strict
543627f7eb2Smrgconformance to the Fortran 95, Fortran 2003, Fortran 2008 and Fortran
544627f7eb2Smrg2018 standards, respectively; errors are given for all extensions
545627f7eb2Smrgbeyond the relevant language standard, and warnings are given for the
546627f7eb2SmrgFortran 77 features that are permitted but obsolescent in later
547627f7eb2Smrgstandards. The deprecated option @samp{-std=f2008ts} acts as an alias for
548627f7eb2Smrg@samp{-std=f2018}. It is only present for backwards compatibility with
549627f7eb2Smrgearlier gfortran versions and should not be used any more.
550627f7eb2Smrg
551627f7eb2Smrg@item -ftest-forall-temp
552627f7eb2Smrg@opindex @code{ftest-forall-temp}
553627f7eb2SmrgEnhance test coverage by forcing most forall assignments to use temporary.
554627f7eb2Smrg
555627f7eb2Smrg@end table
556627f7eb2Smrg
557627f7eb2Smrg@node Preprocessing Options
558627f7eb2Smrg@section Enable and customize preprocessing
559627f7eb2Smrg@cindex preprocessor
560627f7eb2Smrg@cindex options, preprocessor
561627f7eb2Smrg@cindex CPP
562627f7eb2Smrg
563627f7eb2SmrgPreprocessor related options. See section
564627f7eb2Smrg@ref{Preprocessing and conditional compilation} for more detailed
565627f7eb2Smrginformation on preprocessing in @command{gfortran}.
566627f7eb2Smrg
567627f7eb2Smrg@table @gcctabopt
568627f7eb2Smrg@item -cpp
569627f7eb2Smrg@itemx -nocpp
570627f7eb2Smrg@opindex @code{cpp}
571627f7eb2Smrg@opindex @code{fpp}
572627f7eb2Smrg@cindex preprocessor, enable
573627f7eb2Smrg@cindex preprocessor, disable
574627f7eb2SmrgEnable preprocessing. The preprocessor is automatically invoked if
575627f7eb2Smrgthe file extension is @file{.fpp}, @file{.FPP},  @file{.F}, @file{.FOR},
576627f7eb2Smrg@file{.FTN}, @file{.F90}, @file{.F95}, @file{.F03} or @file{.F08}. Use
577627f7eb2Smrgthis option to manually enable preprocessing of any kind of Fortran file.
578627f7eb2Smrg
579627f7eb2SmrgTo disable preprocessing of files with any of the above listed extensions,
580627f7eb2Smrguse the negative form: @option{-nocpp}.
581627f7eb2Smrg
582627f7eb2SmrgThe preprocessor is run in traditional mode. Any restrictions of the
583627f7eb2Smrgfile-format, especially the limits on line length, apply for
584627f7eb2Smrgpreprocessed output as well, so it might be advisable to use the
585627f7eb2Smrg@option{-ffree-line-length-none} or @option{-ffixed-line-length-none}
586627f7eb2Smrgoptions.
587627f7eb2Smrg
588627f7eb2Smrg@item -dM
589627f7eb2Smrg@opindex @code{dM}
590627f7eb2Smrg@cindex preprocessor, debugging
591627f7eb2Smrg@cindex debugging, preprocessor
592627f7eb2SmrgInstead of the normal output, generate a list of @code{'#define'}
593627f7eb2Smrgdirectives for all the macros defined during the execution of the
594627f7eb2Smrgpreprocessor, including predefined macros. This gives you a way
595627f7eb2Smrgof finding out what is predefined in your version of the preprocessor.
596627f7eb2SmrgAssuming you have no file @file{foo.f90}, the command
597627f7eb2Smrg@smallexample
598627f7eb2Smrg  touch foo.f90; gfortran -cpp -E -dM foo.f90
599627f7eb2Smrg@end smallexample
600627f7eb2Smrgwill show all the predefined macros.
601627f7eb2Smrg
602627f7eb2Smrg@item -dD
603627f7eb2Smrg@opindex @code{dD}
604627f7eb2Smrg@cindex preprocessor, debugging
605627f7eb2Smrg@cindex debugging, preprocessor
606627f7eb2SmrgLike @option{-dM} except in two respects: it does not include the
607627f7eb2Smrgpredefined macros, and it outputs both the @code{#define} directives
608627f7eb2Smrgand the result of preprocessing. Both kinds of output go to the
609627f7eb2Smrgstandard output file.
610627f7eb2Smrg
611627f7eb2Smrg@item -dN
612627f7eb2Smrg@opindex @code{dN}
613627f7eb2Smrg@cindex preprocessor, debugging
614627f7eb2Smrg@cindex debugging, preprocessor
615627f7eb2SmrgLike @option{-dD}, but emit only the macro names, not their expansions.
616627f7eb2Smrg
617627f7eb2Smrg@item -dU
618627f7eb2Smrg@opindex @code{dU}
619627f7eb2Smrg@cindex preprocessor, debugging
620627f7eb2Smrg@cindex debugging, preprocessor
621627f7eb2SmrgLike @option{dD} except that only macros that are expanded, or whose
622627f7eb2Smrgdefinedness is tested in preprocessor directives, are output; the
623627f7eb2Smrgoutput is delayed until the use or test of the macro; and @code{'#undef'}
624627f7eb2Smrgdirectives are also output for macros tested but undefined at the time.
625627f7eb2Smrg
626627f7eb2Smrg@item -dI
627627f7eb2Smrg@opindex @code{dI}
628627f7eb2Smrg@cindex preprocessor, debugging
629627f7eb2Smrg@cindex debugging, preprocessor
630627f7eb2SmrgOutput @code{'#include'} directives in addition to the result
631627f7eb2Smrgof preprocessing.
632627f7eb2Smrg
633627f7eb2Smrg@item -fworking-directory
634627f7eb2Smrg@opindex @code{fworking-directory}
635627f7eb2Smrg@cindex preprocessor, working directory
636627f7eb2SmrgEnable generation of linemarkers in the preprocessor output that will
637627f7eb2Smrglet the compiler know the current working directory at the time of
638627f7eb2Smrgpreprocessing. When this option is enabled, the preprocessor will emit,
639627f7eb2Smrgafter the initial linemarker, a second linemarker with the current
640627f7eb2Smrgworking directory followed by two slashes. GCC will use this directory,
641627f7eb2Smrgwhen it is present in the preprocessed input, as the directory emitted
642627f7eb2Smrgas the current working directory in some debugging information formats.
643627f7eb2SmrgThis option is implicitly enabled if debugging information is enabled,
644627f7eb2Smrgbut this can be inhibited with the negated form
645627f7eb2Smrg@option{-fno-working-directory}. If the @option{-P} flag is present
646627f7eb2Smrgin the command line, this option has no effect, since no @code{#line}
647627f7eb2Smrgdirectives are emitted whatsoever.
648627f7eb2Smrg
649627f7eb2Smrg@item -idirafter @var{dir}
650627f7eb2Smrg@opindex @code{idirafter @var{dir}}
651627f7eb2Smrg@cindex preprocessing, include path
652627f7eb2SmrgSearch @var{dir} for include files, but do it after all directories
653627f7eb2Smrgspecified with @option{-I} and the standard system directories have
654627f7eb2Smrgbeen exhausted. @var{dir} is treated as a system include directory.
655627f7eb2SmrgIf dir begins with @code{=}, then the @code{=} will be replaced by
656627f7eb2Smrgthe sysroot prefix; see @option{--sysroot} and @option{-isysroot}.
657627f7eb2Smrg
658627f7eb2Smrg@item -imultilib @var{dir}
659627f7eb2Smrg@opindex @code{imultilib @var{dir}}
660627f7eb2Smrg@cindex preprocessing, include path
661627f7eb2SmrgUse @var{dir} as a subdirectory of the directory containing target-specific
662627f7eb2SmrgC++ headers.
663627f7eb2Smrg
664627f7eb2Smrg@item -iprefix @var{prefix}
665627f7eb2Smrg@opindex @code{iprefix @var{prefix}}
666627f7eb2Smrg@cindex preprocessing, include path
667627f7eb2SmrgSpecify @var{prefix} as the prefix for subsequent @option{-iwithprefix}
668627f7eb2Smrgoptions. If the @var{prefix} represents a directory, you should include
669627f7eb2Smrgthe final @code{'/'}.
670627f7eb2Smrg
671627f7eb2Smrg@item -isysroot @var{dir}
672627f7eb2Smrg@opindex @code{isysroot @var{dir}}
673627f7eb2Smrg@cindex preprocessing, include path
674627f7eb2SmrgThis option is like the @option{--sysroot} option, but applies only to
675627f7eb2Smrgheader files. See the @option{--sysroot} option for more information.
676627f7eb2Smrg
677627f7eb2Smrg@item -iquote @var{dir}
678627f7eb2Smrg@opindex @code{iquote @var{dir}}
679627f7eb2Smrg@cindex preprocessing, include path
680627f7eb2SmrgSearch @var{dir} only for header files requested with @code{#include "file"};
681627f7eb2Smrgthey are not searched for @code{#include <file>}, before all directories
682627f7eb2Smrgspecified by @option{-I} and before the standard system directories. If
683627f7eb2Smrg@var{dir} begins with @code{=}, then the @code{=} will be replaced by the
684627f7eb2Smrgsysroot prefix; see @option{--sysroot} and @option{-isysroot}.
685627f7eb2Smrg
686627f7eb2Smrg@item -isystem @var{dir}
687627f7eb2Smrg@opindex @code{isystem @var{dir}}
688627f7eb2Smrg@cindex preprocessing, include path
689627f7eb2SmrgSearch @var{dir} for header files, after all directories specified by
690627f7eb2Smrg@option{-I} but before the standard system directories. Mark it as a
691627f7eb2Smrgsystem directory, so that it gets the same special treatment as is
692627f7eb2Smrgapplied to the standard system directories. If @var{dir} begins with
693627f7eb2Smrg@code{=}, then the @code{=} will be replaced by the sysroot prefix;
694627f7eb2Smrgsee @option{--sysroot} and @option{-isysroot}.
695627f7eb2Smrg
696627f7eb2Smrg@item -nostdinc
697627f7eb2Smrg@opindex @code{nostdinc}
698627f7eb2SmrgDo not search the standard system directories for header files. Only
699627f7eb2Smrgthe directories you have specified with @option{-I} options (and the
700627f7eb2Smrgdirectory of the current file, if appropriate) are searched.
701627f7eb2Smrg
702627f7eb2Smrg@item -undef
703627f7eb2Smrg@opindex @code{undef}
704627f7eb2SmrgDo not predefine any system-specific or GCC-specific macros.
705627f7eb2SmrgThe standard predefined macros remain defined.
706627f7eb2Smrg
707627f7eb2Smrg@item -A@var{predicate}=@var{answer}
708627f7eb2Smrg@opindex @code{A@var{predicate}=@var{answer}}
709627f7eb2Smrg@cindex preprocessing, assertion
710627f7eb2SmrgMake an assertion with the predicate @var{predicate} and answer @var{answer}.
711627f7eb2SmrgThis form is preferred to the older form -A predicate(answer), which is still
712627f7eb2Smrgsupported, because it does not use shell special characters.
713627f7eb2Smrg
714627f7eb2Smrg@item -A-@var{predicate}=@var{answer}
715627f7eb2Smrg@opindex @code{A-@var{predicate}=@var{answer}}
716627f7eb2Smrg@cindex preprocessing, assertion
717627f7eb2SmrgCancel an assertion with the predicate @var{predicate} and answer @var{answer}.
718627f7eb2Smrg
719627f7eb2Smrg@item -C
720627f7eb2Smrg@opindex @code{C}
721627f7eb2Smrg@cindex preprocessing, keep comments
722627f7eb2SmrgDo not discard comments. All comments are passed through to the output
723627f7eb2Smrgfile, except for comments in processed directives, which are deleted
724627f7eb2Smrgalong with the directive.
725627f7eb2Smrg
726627f7eb2SmrgYou should be prepared for side effects when using @option{-C}; it causes
727627f7eb2Smrgthe preprocessor to treat comments as tokens in their own right. For example,
728627f7eb2Smrgcomments appearing at the start of what would be a directive line have the
729627f7eb2Smrgeffect of turning that line into an ordinary source line, since the first
730627f7eb2Smrgtoken on the line is no longer a @code{'#'}.
731627f7eb2Smrg
732627f7eb2SmrgWarning: this currently handles C-Style comments only. The preprocessor
733627f7eb2Smrgdoes not yet recognize Fortran-style comments.
734627f7eb2Smrg
735627f7eb2Smrg@item -CC
736627f7eb2Smrg@opindex @code{CC}
737627f7eb2Smrg@cindex preprocessing, keep comments
738627f7eb2SmrgDo not discard comments, including during macro expansion. This is like
739627f7eb2Smrg@option{-C}, except that comments contained within macros are also passed
740627f7eb2Smrgthrough to the output file where the macro is expanded.
741627f7eb2Smrg
742627f7eb2SmrgIn addition to the side-effects of the @option{-C} option, the @option{-CC}
743627f7eb2Smrgoption causes all C++-style comments inside a macro to be converted to C-style
744627f7eb2Smrgcomments. This is to prevent later use of that macro from inadvertently
745627f7eb2Smrgcommenting out the remainder of the source line. The @option{-CC} option
746627f7eb2Smrgis generally used to support lint comments.
747627f7eb2Smrg
748627f7eb2SmrgWarning: this currently handles C- and C++-Style comments only. The
749627f7eb2Smrgpreprocessor does not yet recognize Fortran-style comments.
750627f7eb2Smrg
751627f7eb2Smrg@item -D@var{name}
752627f7eb2Smrg@opindex @code{D@var{name}}
753627f7eb2Smrg@cindex preprocessing, define macros
754627f7eb2SmrgPredefine name as a macro, with definition @code{1}.
755627f7eb2Smrg
756627f7eb2Smrg@item -D@var{name}=@var{definition}
757627f7eb2Smrg@opindex @code{D@var{name}=@var{definition}}
758627f7eb2Smrg@cindex preprocessing, define macros
759627f7eb2SmrgThe contents of @var{definition} are tokenized and processed as if they
760627f7eb2Smrgappeared during translation phase three in a @code{'#define'} directive.
761627f7eb2SmrgIn particular, the definition will be truncated by embedded newline
762627f7eb2Smrgcharacters.
763627f7eb2Smrg
764627f7eb2SmrgIf you are invoking the preprocessor from a shell or shell-like program
765627f7eb2Smrgyou may need to use the shell's quoting syntax to protect characters such
766627f7eb2Smrgas spaces that have a meaning in the shell syntax.
767627f7eb2Smrg
768627f7eb2SmrgIf you wish to define a function-like macro on the command line, write
769627f7eb2Smrgits argument list with surrounding parentheses before the equals sign
770627f7eb2Smrg(if any). Parentheses are meaningful to most shells, so you will need
771627f7eb2Smrgto quote the option. With sh and csh, @code{-D'name(args...)=definition'}
772627f7eb2Smrgworks.
773627f7eb2Smrg
774627f7eb2Smrg@option{-D} and @option{-U} options are processed in the order they are
775627f7eb2Smrggiven on the command line. All -imacros file and -include file options
776627f7eb2Smrgare processed after all -D and -U options.
777627f7eb2Smrg
778627f7eb2Smrg@item -H
779627f7eb2Smrg@opindex @code{H}
780627f7eb2SmrgPrint the name of each header file used, in addition to other normal
781627f7eb2Smrgactivities. Each name is indented to show how deep in the @code{'#include'}
782627f7eb2Smrgstack it is.
783627f7eb2Smrg
784627f7eb2Smrg@item -P
785627f7eb2Smrg@opindex @code{P}
786627f7eb2Smrg@cindex preprocessing, no linemarkers
787627f7eb2SmrgInhibit generation of linemarkers in the output from the preprocessor.
788627f7eb2SmrgThis might be useful when running the preprocessor on something that
789627f7eb2Smrgis not C code, and will be sent to a program which might be confused
790627f7eb2Smrgby the linemarkers.
791627f7eb2Smrg
792627f7eb2Smrg@item -U@var{name}
793627f7eb2Smrg@opindex @code{U@var{name}}
794627f7eb2Smrg@cindex preprocessing, undefine macros
795627f7eb2SmrgCancel any previous definition of @var{name}, either built in or provided
796627f7eb2Smrgwith a @option{-D} option.
797627f7eb2Smrg@end table
798627f7eb2Smrg
799627f7eb2Smrg
800627f7eb2Smrg@node Error and Warning Options
801627f7eb2Smrg@section Options to request or suppress errors and warnings
802627f7eb2Smrg@cindex options, warnings
803627f7eb2Smrg@cindex options, errors
804627f7eb2Smrg@cindex warnings, suppressing
805627f7eb2Smrg@cindex messages, error
806627f7eb2Smrg@cindex messages, warning
807627f7eb2Smrg@cindex suppressing warnings
808627f7eb2Smrg
809627f7eb2SmrgErrors are diagnostic messages that report that the GNU Fortran compiler
810627f7eb2Smrgcannot compile the relevant piece of source code.  The compiler will
811627f7eb2Smrgcontinue to process the program in an attempt to report further errors
812627f7eb2Smrgto aid in debugging, but will not produce any compiled output.
813627f7eb2Smrg
814627f7eb2SmrgWarnings are diagnostic messages that report constructions which
815627f7eb2Smrgare not inherently erroneous but which are risky or suggest there is
816627f7eb2Smrglikely to be a bug in the program.  Unless @option{-Werror} is specified,
817627f7eb2Smrgthey do not prevent compilation of the program.
818627f7eb2Smrg
819627f7eb2SmrgYou can request many specific warnings with options beginning @option{-W},
820627f7eb2Smrgfor example @option{-Wimplicit} to request warnings on implicit
821627f7eb2Smrgdeclarations.  Each of these specific warning options also has a
822627f7eb2Smrgnegative form beginning @option{-Wno-} to turn off warnings;
823627f7eb2Smrgfor example, @option{-Wno-implicit}.  This manual lists only one of the
824627f7eb2Smrgtwo forms, whichever is not the default.
825627f7eb2Smrg
826627f7eb2SmrgThese options control the amount and kinds of errors and warnings produced
827627f7eb2Smrgby GNU Fortran:
828627f7eb2Smrg
829627f7eb2Smrg@table @gcctabopt
830627f7eb2Smrg@item -fmax-errors=@var{n}
831627f7eb2Smrg@opindex @code{fmax-errors=}@var{n}
832627f7eb2Smrg@cindex errors, limiting
833627f7eb2SmrgLimits the maximum number of error messages to @var{n}, at which point
834627f7eb2SmrgGNU Fortran bails out rather than attempting to continue processing the
835627f7eb2Smrgsource code.  If @var{n} is 0, there is no limit on the number of error
836627f7eb2Smrgmessages produced.
837627f7eb2Smrg
838627f7eb2Smrg@item -fsyntax-only
839627f7eb2Smrg@opindex @code{fsyntax-only}
840627f7eb2Smrg@cindex syntax checking
841627f7eb2SmrgCheck the code for syntax errors, but do not actually compile it.  This
842627f7eb2Smrgwill generate module files for each module present in the code, but no
843627f7eb2Smrgother output file.
844627f7eb2Smrg
845627f7eb2Smrg@item -Wpedantic
846627f7eb2Smrg@itemx -pedantic
847627f7eb2Smrg@opindex @code{pedantic}
848627f7eb2Smrg@opindex @code{Wpedantic}
849627f7eb2SmrgIssue warnings for uses of extensions to Fortran.
850627f7eb2Smrg@option{-pedantic} also applies to C-language constructs where they
851627f7eb2Smrgoccur in GNU Fortran source files, such as use of @samp{\e} in a
852627f7eb2Smrgcharacter constant within a directive like @code{#include}.
853627f7eb2Smrg
854627f7eb2SmrgValid Fortran programs should compile properly with or without
855627f7eb2Smrgthis option.
856627f7eb2SmrgHowever, without this option, certain GNU extensions and traditional
857627f7eb2SmrgFortran features are supported as well.
858627f7eb2SmrgWith this option, many of them are rejected.
859627f7eb2Smrg
860627f7eb2SmrgSome users try to use @option{-pedantic} to check programs for conformance.
861627f7eb2SmrgThey soon find that it does not do quite what they want---it finds some
862627f7eb2Smrgnonstandard practices, but not all.
863627f7eb2SmrgHowever, improvements to GNU Fortran in this area are welcome.
864627f7eb2Smrg
865627f7eb2SmrgThis should be used in conjunction with @option{-std=f95},
866627f7eb2Smrg@option{-std=f2003}, @option{-std=f2008} or @option{-std=f2018}.
867627f7eb2Smrg
868627f7eb2Smrg@item -pedantic-errors
869627f7eb2Smrg@opindex @code{pedantic-errors}
870627f7eb2SmrgLike @option{-pedantic}, except that errors are produced rather than
871627f7eb2Smrgwarnings.
872627f7eb2Smrg
873627f7eb2Smrg@item -Wall
874627f7eb2Smrg@opindex @code{Wall}
875627f7eb2Smrg@cindex all warnings
876627f7eb2Smrg@cindex warnings, all
877627f7eb2SmrgEnables commonly used warning options pertaining to usage that
878627f7eb2Smrgwe recommend avoiding and that we believe are easy to avoid.
879627f7eb2SmrgThis currently includes @option{-Waliasing}, @option{-Wampersand},
880627f7eb2Smrg@option{-Wconversion}, @option{-Wsurprising}, @option{-Wc-binding-type},
881627f7eb2Smrg@option{-Wintrinsics-std}, @option{-Wtabs}, @option{-Wintrinsic-shadow},
882627f7eb2Smrg@option{-Wline-truncation}, @option{-Wtarget-lifetime},
883627f7eb2Smrg@option{-Winteger-division}, @option{-Wreal-q-constant}, @option{-Wunused}
884627f7eb2Smrgand @option{-Wundefined-do-loop}.
885627f7eb2Smrg
886627f7eb2Smrg@item -Waliasing
887627f7eb2Smrg@opindex @code{Waliasing}
888627f7eb2Smrg@cindex aliasing
889627f7eb2Smrg@cindex warnings, aliasing
890627f7eb2SmrgWarn about possible aliasing of dummy arguments. Specifically, it warns
891627f7eb2Smrgif the same actual argument is associated with a dummy argument with
892627f7eb2Smrg@code{INTENT(IN)} and a dummy argument with @code{INTENT(OUT)} in a call
893627f7eb2Smrgwith an explicit interface.
894627f7eb2Smrg
895627f7eb2SmrgThe following example will trigger the warning.
896627f7eb2Smrg@smallexample
897627f7eb2Smrg  interface
898627f7eb2Smrg    subroutine bar(a,b)
899627f7eb2Smrg      integer, intent(in) :: a
900627f7eb2Smrg      integer, intent(out) :: b
901627f7eb2Smrg    end subroutine
902627f7eb2Smrg  end interface
903627f7eb2Smrg  integer :: a
904627f7eb2Smrg
905627f7eb2Smrg  call bar(a,a)
906627f7eb2Smrg@end smallexample
907627f7eb2Smrg
908627f7eb2Smrg@item -Wampersand
909627f7eb2Smrg@opindex @code{Wampersand}
910627f7eb2Smrg@cindex warnings, ampersand
911627f7eb2Smrg@cindex @code{&}
912627f7eb2SmrgWarn about missing ampersand in continued character constants. The
913627f7eb2Smrgwarning is given with @option{-Wampersand}, @option{-pedantic},
914627f7eb2Smrg@option{-std=f95}, @option{-std=f2003}, @option{-std=f2008} and
915627f7eb2Smrg@option{-std=f2018}. Note: With no ampersand given in a continued
916627f7eb2Smrgcharacter constant, GNU Fortran assumes continuation at the first
917627f7eb2Smrgnon-comment, non-whitespace character after the ampersand that
918627f7eb2Smrginitiated the continuation.
919627f7eb2Smrg
920627f7eb2Smrg@item -Warray-temporaries
921627f7eb2Smrg@opindex @code{Warray-temporaries}
922627f7eb2Smrg@cindex warnings, array temporaries
923627f7eb2SmrgWarn about array temporaries generated by the compiler.  The information
924627f7eb2Smrggenerated by this warning is sometimes useful in optimization, in order to
925627f7eb2Smrgavoid such temporaries.
926627f7eb2Smrg
927627f7eb2Smrg@item -Wc-binding-type
928627f7eb2Smrg@opindex @code{Wc-binding-type}
929627f7eb2Smrg@cindex warning, C binding type
930627f7eb2SmrgWarn if the a variable might not be C interoperable.  In particular, warn if
931627f7eb2Smrgthe variable has been declared using an intrinsic type with default kind
932627f7eb2Smrginstead of using a kind parameter defined for C interoperability in the
933627f7eb2Smrgintrinsic @code{ISO_C_Binding} module.  This option is implied by
934627f7eb2Smrg@option{-Wall}.
935627f7eb2Smrg
936627f7eb2Smrg@item -Wcharacter-truncation
937627f7eb2Smrg@opindex @code{Wcharacter-truncation}
938627f7eb2Smrg@cindex warnings, character truncation
939627f7eb2SmrgWarn when a character assignment will truncate the assigned string.
940627f7eb2Smrg
941627f7eb2Smrg@item -Wline-truncation
942627f7eb2Smrg@opindex @code{Wline-truncation}
943627f7eb2Smrg@cindex warnings, line truncation
944627f7eb2SmrgWarn when a source code line will be truncated.  This option is
945627f7eb2Smrgimplied by @option{-Wall}.  For free-form source code, the default is
946627f7eb2Smrg@option{-Werror=line-truncation} such that truncations are reported as
947627f7eb2Smrgerror.
948627f7eb2Smrg
949627f7eb2Smrg@item -Wconversion
950627f7eb2Smrg@opindex @code{Wconversion}
951627f7eb2Smrg@cindex warnings, conversion
952627f7eb2Smrg@cindex conversion
953627f7eb2SmrgWarn about implicit conversions that are likely to change the value of
954627f7eb2Smrgthe expression after conversion. Implied by @option{-Wall}.
955627f7eb2Smrg
956627f7eb2Smrg@item -Wconversion-extra
957627f7eb2Smrg@opindex @code{Wconversion-extra}
958627f7eb2Smrg@cindex warnings, conversion
959627f7eb2Smrg@cindex conversion
960627f7eb2SmrgWarn about implicit conversions between different types and kinds. This
961627f7eb2Smrgoption does @emph{not} imply @option{-Wconversion}.
962627f7eb2Smrg
963627f7eb2Smrg@item -Wextra
964627f7eb2Smrg@opindex @code{Wextra}
965627f7eb2Smrg@cindex extra warnings
966627f7eb2Smrg@cindex warnings, extra
967627f7eb2SmrgEnables some warning options for usages of language features which
968627f7eb2Smrgmay be problematic. This currently includes @option{-Wcompare-reals},
969627f7eb2Smrg@option{-Wunused-parameter} and @option{-Wdo-subscript}.
970627f7eb2Smrg
971627f7eb2Smrg@item -Wfrontend-loop-interchange
972627f7eb2Smrg@opindex @code{Wfrontend-loop-interchange}
973627f7eb2Smrg@cindex warnings, loop interchange
974627f7eb2Smrg@cindex loop interchange, warning
975*4c3eb207SmrgWarn when using @option{-ffrontend-loop-interchange} for performing loop
976*4c3eb207Smrginterchanges.
977627f7eb2Smrg
978627f7eb2Smrg@item -Wimplicit-interface
979627f7eb2Smrg@opindex @code{Wimplicit-interface}
980627f7eb2Smrg@cindex warnings, implicit interface
981627f7eb2SmrgWarn if a procedure is called without an explicit interface.
982627f7eb2SmrgNote this only checks that an explicit interface is present.  It does not
983627f7eb2Smrgcheck that the declared interfaces are consistent across program units.
984627f7eb2Smrg
985627f7eb2Smrg@item -Wimplicit-procedure
986627f7eb2Smrg@opindex @code{Wimplicit-procedure}
987627f7eb2Smrg@cindex warnings, implicit procedure
988627f7eb2SmrgWarn if a procedure is called that has neither an explicit interface
989627f7eb2Smrgnor has been declared as @code{EXTERNAL}.
990627f7eb2Smrg
991627f7eb2Smrg@item -Winteger-division
992627f7eb2Smrg@opindex @code{Winteger-division}
993627f7eb2Smrg@cindex warnings, integer division
994627f7eb2Smrg@cindex warnings, division of integers
995*4c3eb207SmrgWarn if a constant integer division truncates its result.
996627f7eb2SmrgAs an example, 3/5 evaluates to 0.
997627f7eb2Smrg
998627f7eb2Smrg@item -Wintrinsics-std
999627f7eb2Smrg@opindex @code{Wintrinsics-std}
1000627f7eb2Smrg@cindex warnings, non-standard intrinsics
1001627f7eb2Smrg@cindex warnings, intrinsics of other standards
1002627f7eb2SmrgWarn if @command{gfortran} finds a procedure named like an intrinsic not
1003627f7eb2Smrgavailable in the currently selected standard (with @option{-std}) and treats
1004627f7eb2Smrgit as @code{EXTERNAL} procedure because of this.  @option{-fall-intrinsics} can
1005627f7eb2Smrgbe used to never trigger this behavior and always link to the intrinsic
1006627f7eb2Smrgregardless of the selected standard.
1007627f7eb2Smrg
1008*4c3eb207Smrg@item -Wno-overwrite-recursive
1009*4c3eb207Smrg@opindex @code{Woverwrite-recursive}
1010*4c3eb207Smrg@cindex  warnings, overwrite recursive
1011*4c3eb207SmrgDo not warn when @option{-fno-automatic} is used with @option{-frecursive}. Recursion
1012*4c3eb207Smrgwill be broken if the relevant local variables do not have the attribute
1013*4c3eb207Smrg@code{AUTOMATIC} explicitly declared. This option can be used to suppress the warning
1014*4c3eb207Smrgwhen it is known that recursion is not broken. Useful for build environments that use
1015*4c3eb207Smrg@option{-Werror}.
1016*4c3eb207Smrg
1017627f7eb2Smrg@item -Wreal-q-constant
1018627f7eb2Smrg@opindex @code{Wreal-q-constant}
1019627f7eb2Smrg@cindex warnings, @code{q} exponent-letter
1020627f7eb2SmrgProduce a warning if a real-literal-constant contains a @code{q}
1021627f7eb2Smrgexponent-letter.
1022627f7eb2Smrg
1023627f7eb2Smrg@item -Wsurprising
1024627f7eb2Smrg@opindex @code{Wsurprising}
1025627f7eb2Smrg@cindex warnings, suspicious code
1026627f7eb2SmrgProduce a warning when ``suspicious'' code constructs are encountered.
1027627f7eb2SmrgWhile technically legal these usually indicate that an error has been made.
1028627f7eb2Smrg
1029627f7eb2SmrgThis currently produces a warning under the following circumstances:
1030627f7eb2Smrg
1031627f7eb2Smrg@itemize @bullet
1032627f7eb2Smrg@item
1033627f7eb2SmrgAn INTEGER SELECT construct has a CASE that can never be matched as its
1034627f7eb2Smrglower value is greater than its upper value.
1035627f7eb2Smrg
1036627f7eb2Smrg@item
1037627f7eb2SmrgA LOGICAL SELECT construct has three CASE statements.
1038627f7eb2Smrg
1039627f7eb2Smrg@item
1040627f7eb2SmrgA TRANSFER specifies a source that is shorter than the destination.
1041627f7eb2Smrg
1042627f7eb2Smrg@item
1043627f7eb2SmrgThe type of a function result is declared more than once with the same type.  If
1044627f7eb2Smrg@option{-pedantic} or standard-conforming mode is enabled, this is an error.
1045627f7eb2Smrg
1046627f7eb2Smrg@item
1047627f7eb2SmrgA @code{CHARACTER} variable is declared with negative length.
1048627f7eb2Smrg@end itemize
1049627f7eb2Smrg
1050627f7eb2Smrg@item -Wtabs
1051627f7eb2Smrg@opindex @code{Wtabs}
1052627f7eb2Smrg@cindex warnings, tabs
1053627f7eb2Smrg@cindex tabulators
1054627f7eb2SmrgBy default, tabs are accepted as whitespace, but tabs are not members
1055627f7eb2Smrgof the Fortran Character Set.  For continuation lines, a tab followed
1056627f7eb2Smrgby a digit between 1 and 9 is supported.  @option{-Wtabs} will cause a
1057627f7eb2Smrgwarning to be issued if a tab is encountered. Note, @option{-Wtabs} is
1058627f7eb2Smrgactive for @option{-pedantic}, @option{-std=f95}, @option{-std=f2003},
1059627f7eb2Smrg@option{-std=f2008}, @option{-std=f2018} and
1060627f7eb2Smrg@option{-Wall}.
1061627f7eb2Smrg
1062627f7eb2Smrg@item -Wundefined-do-loop
1063627f7eb2Smrg@opindex @code{Wundefined-do-loop}
1064627f7eb2Smrg@cindex warnings, undefined do loop
1065627f7eb2SmrgWarn if a DO loop with step either 1 or -1 yields an underflow or an overflow
1066627f7eb2Smrgduring iteration of an induction variable of the loop.
1067627f7eb2SmrgThis option is implied by @option{-Wall}.
1068627f7eb2Smrg
1069627f7eb2Smrg@item -Wunderflow
1070627f7eb2Smrg@opindex @code{Wunderflow}
1071627f7eb2Smrg@cindex warnings, underflow
1072627f7eb2Smrg@cindex underflow
1073627f7eb2SmrgProduce a warning when numerical constant expressions are
1074627f7eb2Smrgencountered, which yield an UNDERFLOW during compilation. Enabled by default.
1075627f7eb2Smrg
1076627f7eb2Smrg@item -Wintrinsic-shadow
1077627f7eb2Smrg@opindex @code{Wintrinsic-shadow}
1078627f7eb2Smrg@cindex warnings, intrinsic
1079627f7eb2Smrg@cindex intrinsic
1080627f7eb2SmrgWarn if a user-defined procedure or module procedure has the same name as an
1081627f7eb2Smrgintrinsic; in this case, an explicit interface or @code{EXTERNAL} or
1082627f7eb2Smrg@code{INTRINSIC} declaration might be needed to get calls later resolved to
1083627f7eb2Smrgthe desired intrinsic/procedure.  This option is implied by @option{-Wall}.
1084627f7eb2Smrg
1085627f7eb2Smrg@item -Wuse-without-only
1086627f7eb2Smrg@opindex @code{Wuse-without-only}
1087627f7eb2Smrg@cindex warnings, use statements
1088627f7eb2Smrg@cindex intrinsic
1089627f7eb2SmrgWarn if a @code{USE} statement has no @code{ONLY} qualifier and
1090627f7eb2Smrgthus implicitly imports all public entities of the used module.
1091627f7eb2Smrg
1092627f7eb2Smrg@item -Wunused-dummy-argument
1093627f7eb2Smrg@opindex @code{Wunused-dummy-argument}
1094627f7eb2Smrg@cindex warnings, unused dummy argument
1095627f7eb2Smrg@cindex unused dummy argument
1096627f7eb2Smrg@cindex dummy argument, unused
1097627f7eb2SmrgWarn about unused dummy arguments. This option is implied by @option{-Wall}.
1098627f7eb2Smrg
1099627f7eb2Smrg@item -Wunused-parameter
1100627f7eb2Smrg@opindex @code{Wunused-parameter}
1101627f7eb2Smrg@cindex warnings, unused parameter
1102627f7eb2Smrg@cindex unused parameter
1103627f7eb2SmrgContrary to @command{gcc}'s meaning of @option{-Wunused-parameter},
1104627f7eb2Smrg@command{gfortran}'s implementation of this option does not warn
1105627f7eb2Smrgabout unused dummy arguments (see @option{-Wunused-dummy-argument}),
1106627f7eb2Smrgbut about unused @code{PARAMETER} values. @option{-Wunused-parameter}
1107627f7eb2Smrgis implied by @option{-Wextra} if also @option{-Wunused} or
1108627f7eb2Smrg@option{-Wall} is used.
1109627f7eb2Smrg
1110627f7eb2Smrg@item -Walign-commons
1111627f7eb2Smrg@opindex @code{Walign-commons}
1112627f7eb2Smrg@cindex warnings, alignment of @code{COMMON} blocks
1113627f7eb2Smrg@cindex alignment of @code{COMMON} blocks
1114627f7eb2SmrgBy default, @command{gfortran} warns about any occasion of variables being
1115627f7eb2Smrgpadded for proper alignment inside a @code{COMMON} block. This warning can be turned
1116627f7eb2Smrgoff via @option{-Wno-align-commons}. See also @option{-falign-commons}.
1117627f7eb2Smrg
1118627f7eb2Smrg@item -Wfunction-elimination
1119627f7eb2Smrg@opindex @code{Wfunction-elimination}
1120627f7eb2Smrg@cindex function elimination
1121627f7eb2Smrg@cindex warnings, function elimination
1122627f7eb2SmrgWarn if any calls to impure functions are eliminated by the optimizations
1123627f7eb2Smrgenabled by the @option{-ffrontend-optimize} option.
1124627f7eb2SmrgThis option is implied by @option{-Wextra}.
1125627f7eb2Smrg
1126627f7eb2Smrg@item -Wrealloc-lhs
1127627f7eb2Smrg@opindex @code{Wrealloc-lhs}
1128627f7eb2Smrg@cindex Reallocate the LHS in assignments, notification
1129627f7eb2SmrgWarn when the compiler might insert code to for allocation or reallocation of
1130627f7eb2Smrgan allocatable array variable of intrinsic type in intrinsic assignments.  In
1131627f7eb2Smrghot loops, the Fortran 2003 reallocation feature may reduce the performance.
1132627f7eb2SmrgIf the array is already allocated with the correct shape, consider using a
1133627f7eb2Smrgwhole-array array-spec (e.g. @code{(:,:,:)}) for the variable on the left-hand
1134627f7eb2Smrgside to prevent the reallocation check. Note that in some cases the warning
1135627f7eb2Smrgis shown, even if the compiler will optimize reallocation checks away.  For
1136627f7eb2Smrginstance, when the right-hand side contains the same variable multiplied by
1137627f7eb2Smrga scalar.  See also @option{-frealloc-lhs}.
1138627f7eb2Smrg
1139627f7eb2Smrg@item -Wrealloc-lhs-all
1140627f7eb2Smrg@opindex @code{Wrealloc-lhs-all}
1141627f7eb2SmrgWarn when the compiler inserts code to for allocation or reallocation of an
1142627f7eb2Smrgallocatable variable; this includes scalars and derived types.
1143627f7eb2Smrg
1144627f7eb2Smrg@item -Wcompare-reals
1145627f7eb2Smrg@opindex @code{Wcompare-reals}
1146627f7eb2SmrgWarn when comparing real or complex types for equality or inequality.
1147627f7eb2SmrgThis option is implied by @option{-Wextra}.
1148627f7eb2Smrg
1149627f7eb2Smrg@item -Wtarget-lifetime
1150627f7eb2Smrg@opindex @code{Wtargt-lifetime}
1151627f7eb2SmrgWarn if the pointer in a pointer assignment might be longer than the its
1152627f7eb2Smrgtarget. This option is implied by @option{-Wall}.
1153627f7eb2Smrg
1154627f7eb2Smrg@item -Wzerotrip
1155627f7eb2Smrg@opindex @code{Wzerotrip}
1156627f7eb2SmrgWarn if a @code{DO} loop is known to execute zero times at compile
1157627f7eb2Smrgtime.  This option is implied by @option{-Wall}.
1158627f7eb2Smrg
1159627f7eb2Smrg@item -Wdo-subscript
1160627f7eb2Smrg@opindex @code{Wdo-subscript}
1161627f7eb2SmrgWarn if an array subscript inside a DO loop could lead to an
1162627f7eb2Smrgout-of-bounds access even if the compiler cannot prove that the
1163627f7eb2Smrgstatement is actually executed, in cases like
1164627f7eb2Smrg@smallexample
1165627f7eb2Smrg  real a(3)
1166627f7eb2Smrg  do i=1,4
1167627f7eb2Smrg    if (condition(i)) then
1168627f7eb2Smrg      a(i) = 1.2
1169627f7eb2Smrg    end if
1170627f7eb2Smrg  end do
1171627f7eb2Smrg@end smallexample
1172627f7eb2SmrgThis option is implied by @option{-Wextra}.
1173627f7eb2Smrg
1174627f7eb2Smrg@item -Werror
1175627f7eb2Smrg@opindex @code{Werror}
1176627f7eb2Smrg@cindex warnings, to errors
1177627f7eb2SmrgTurns all warnings into errors.
1178627f7eb2Smrg@end table
1179627f7eb2Smrg
1180627f7eb2Smrg@xref{Warning Options,,Options to Request or Suppress Errors and
1181627f7eb2SmrgWarnings, gcc,Using the GNU Compiler Collection (GCC)}, for information on
1182627f7eb2Smrgmore options offered by the GBE shared by @command{gfortran}, @command{gcc}
1183627f7eb2Smrgand other GNU compilers.
1184627f7eb2Smrg
1185627f7eb2SmrgSome of these have no effect when compiling programs written in Fortran.
1186627f7eb2Smrg
1187627f7eb2Smrg@node Debugging Options
1188627f7eb2Smrg@section Options for debugging your program or GNU Fortran
1189627f7eb2Smrg@cindex options, debugging
1190627f7eb2Smrg@cindex debugging information options
1191627f7eb2Smrg
1192627f7eb2SmrgGNU Fortran has various special options that are used for debugging
1193627f7eb2Smrgeither your program or the GNU Fortran compiler.
1194627f7eb2Smrg
1195627f7eb2Smrg@table @gcctabopt
1196627f7eb2Smrg@item -fdump-fortran-original
1197627f7eb2Smrg@opindex @code{fdump-fortran-original}
1198627f7eb2SmrgOutput the internal parse tree after translating the source program
1199627f7eb2Smrginto internal representation.  This option is mostly useful for
1200627f7eb2Smrgdebugging the GNU Fortran compiler itself. The output generated by
1201627f7eb2Smrgthis option might change between releases. This option may also
1202627f7eb2Smrggenerate internal compiler errors for features which have only
1203627f7eb2Smrgrecently been added.
1204627f7eb2Smrg
1205627f7eb2Smrg@item -fdump-fortran-optimized
1206627f7eb2Smrg@opindex @code{fdump-fortran-optimized}
1207627f7eb2SmrgOutput the parse tree after front-end optimization.  Mostly useful for
1208627f7eb2Smrgdebugging the GNU Fortran compiler itself. The output generated by
1209627f7eb2Smrgthis option might change between releases.  This option may also
1210627f7eb2Smrggenerate internal compiler errors for features which have only
1211627f7eb2Smrgrecently been added.
1212627f7eb2Smrg
1213627f7eb2Smrg@item -fdump-parse-tree
1214627f7eb2Smrg@opindex @code{fdump-parse-tree}
1215627f7eb2SmrgOutput the internal parse tree after translating the source program
1216627f7eb2Smrginto internal representation.  Mostly useful for debugging the GNU
1217627f7eb2SmrgFortran compiler itself. The output generated by this option might
1218627f7eb2Smrgchange between releases. This option may also generate internal
1219627f7eb2Smrgcompiler errors for features which have only recently been added. This
1220627f7eb2Smrgoption is deprecated; use @code{-fdump-fortran-original} instead.
1221627f7eb2Smrg
1222627f7eb2Smrg@item -fdump-fortran-global
1223627f7eb2Smrg@opindex @code{fdump-fortran-global}
1224627f7eb2SmrgOutput a list of the global identifiers after translating into
1225627f7eb2Smrgmiddle-end representation. Mostly useful for debugging the GNU Fortran
1226627f7eb2Smrgcompiler itself. The output generated by this option might change
1227627f7eb2Smrgbetween releases.  This option may also generate internal compiler
1228627f7eb2Smrgerrors for features which have only recently been added.
1229627f7eb2Smrg
1230627f7eb2Smrg@item -ffpe-trap=@var{list}
1231627f7eb2Smrg@opindex @code{ffpe-trap=}@var{list}
1232627f7eb2SmrgSpecify a list of floating point exception traps to enable.  On most
1233627f7eb2Smrgsystems, if a floating point exception occurs and the trap for that
1234627f7eb2Smrgexception is enabled, a SIGFPE signal will be sent and the program
1235627f7eb2Smrgbeing aborted, producing a core file useful for debugging.  @var{list}
1236627f7eb2Smrgis a (possibly empty) comma-separated list of the following
1237627f7eb2Smrgexceptions: @samp{invalid} (invalid floating point operation, such as
1238627f7eb2Smrg@code{SQRT(-1.0)}), @samp{zero} (division by zero), @samp{overflow}
1239627f7eb2Smrg(overflow in a floating point operation), @samp{underflow} (underflow
1240627f7eb2Smrgin a floating point operation), @samp{inexact} (loss of precision
1241627f7eb2Smrgduring operation), and @samp{denormal} (operation performed on a
1242627f7eb2Smrgdenormal value).  The first five exceptions correspond to the five
1243627f7eb2SmrgIEEE 754 exceptions, whereas the last one (@samp{denormal}) is not
1244627f7eb2Smrgpart of the IEEE 754 standard but is available on some common
1245627f7eb2Smrgarchitectures such as x86.
1246627f7eb2Smrg
1247627f7eb2SmrgThe first three exceptions (@samp{invalid}, @samp{zero}, and
1248627f7eb2Smrg@samp{overflow}) often indicate serious errors, and unless the program
1249627f7eb2Smrghas provisions for dealing with these exceptions, enabling traps for
1250627f7eb2Smrgthese three exceptions is probably a good idea.
1251627f7eb2Smrg
1252627f7eb2SmrgIf the option is used more than once in the command line, the lists will
1253627f7eb2Smrgbe joined: '@code{ffpe-trap=}@var{list1} @code{ffpe-trap=}@var{list2}'
1254627f7eb2Smrgis equivalent to @code{ffpe-trap=}@var{list1},@var{list2}.
1255627f7eb2Smrg
1256627f7eb2SmrgNote that once enabled an exception cannot be disabled (no negative form).
1257627f7eb2Smrg
1258627f7eb2SmrgMany, if not most, floating point operations incur loss of precision
1259627f7eb2Smrgdue to rounding, and hence the @code{ffpe-trap=inexact} is likely to
1260627f7eb2Smrgbe uninteresting in practice.
1261627f7eb2Smrg
1262627f7eb2SmrgBy default no exception traps are enabled.
1263627f7eb2Smrg
1264627f7eb2Smrg@item -ffpe-summary=@var{list}
1265627f7eb2Smrg@opindex @code{ffpe-summary=}@var{list}
1266627f7eb2SmrgSpecify a list of floating-point exceptions, whose flag status is printed
1267627f7eb2Smrgto @code{ERROR_UNIT} when invoking @code{STOP} and @code{ERROR STOP}.
1268627f7eb2Smrg@var{list} can be either @samp{none}, @samp{all} or a comma-separated list
1269627f7eb2Smrgof the following exceptions: @samp{invalid}, @samp{zero}, @samp{overflow},
1270627f7eb2Smrg@samp{underflow}, @samp{inexact} and @samp{denormal}. (See
1271627f7eb2Smrg@option{-ffpe-trap} for a description of the exceptions.)
1272627f7eb2Smrg
1273627f7eb2SmrgIf the option is used more than once in the command line, only the
1274627f7eb2Smrglast one will be used.
1275627f7eb2Smrg
1276627f7eb2SmrgBy default, a summary for all exceptions but @samp{inexact} is shown.
1277627f7eb2Smrg
1278627f7eb2Smrg@item -fno-backtrace
1279627f7eb2Smrg@opindex @code{fno-backtrace}
1280627f7eb2Smrg@cindex backtrace
1281627f7eb2Smrg@cindex trace
1282627f7eb2SmrgWhen a serious runtime error is encountered or a deadly signal is
1283627f7eb2Smrgemitted (segmentation fault, illegal instruction, bus error,
1284627f7eb2Smrgfloating-point exception, and the other POSIX signals that have the
1285627f7eb2Smrgaction @samp{core}), the Fortran runtime library tries to output a
1286627f7eb2Smrgbacktrace of the error. @code{-fno-backtrace} disables the backtrace
1287627f7eb2Smrggeneration. This option only has influence for compilation of the
1288627f7eb2SmrgFortran main program.
1289627f7eb2Smrg
1290627f7eb2Smrg@end table
1291627f7eb2Smrg
1292627f7eb2Smrg@xref{Debugging Options,,Options for Debugging Your Program or GCC,
1293627f7eb2Smrggcc,Using the GNU Compiler Collection (GCC)}, for more information on
1294627f7eb2Smrgdebugging options.
1295627f7eb2Smrg
1296627f7eb2Smrg@node Directory Options
1297627f7eb2Smrg@section Options for directory search
1298627f7eb2Smrg@cindex directory, options
1299627f7eb2Smrg@cindex options, directory search
1300627f7eb2Smrg@cindex search path
1301627f7eb2Smrg@cindex @code{INCLUDE} directive
1302627f7eb2Smrg@cindex directive, @code{INCLUDE}
1303627f7eb2SmrgThese options affect how GNU Fortran searches
1304627f7eb2Smrgfor files specified by the @code{INCLUDE} directive and where it searches
1305627f7eb2Smrgfor previously compiled modules.
1306627f7eb2Smrg
1307627f7eb2SmrgIt also affects the search paths used by @command{cpp} when used to preprocess
1308627f7eb2SmrgFortran source.
1309627f7eb2Smrg
1310627f7eb2Smrg@table @gcctabopt
1311627f7eb2Smrg@item -I@var{dir}
1312627f7eb2Smrg@opindex @code{I}@var{dir}
1313627f7eb2Smrg@cindex directory, search paths for inclusion
1314627f7eb2Smrg@cindex inclusion, directory search paths for
1315627f7eb2Smrg@cindex search paths, for included files
1316627f7eb2Smrg@cindex paths, search
1317627f7eb2Smrg@cindex module search path
1318627f7eb2SmrgThese affect interpretation of the @code{INCLUDE} directive
1319627f7eb2Smrg(as well as of the @code{#include} directive of the @command{cpp}
1320627f7eb2Smrgpreprocessor).
1321627f7eb2Smrg
1322627f7eb2SmrgAlso note that the general behavior of @option{-I} and
1323627f7eb2Smrg@code{INCLUDE} is pretty much the same as of @option{-I} with
1324627f7eb2Smrg@code{#include} in the @command{cpp} preprocessor, with regard to
1325627f7eb2Smrglooking for @file{header.gcc} files and other such things.
1326627f7eb2Smrg
1327627f7eb2SmrgThis path is also used to search for @file{.mod} files when previously
1328627f7eb2Smrgcompiled modules are required by a @code{USE} statement.
1329627f7eb2Smrg
1330627f7eb2Smrg@xref{Directory Options,,Options for Directory Search,
1331627f7eb2Smrggcc,Using the GNU Compiler Collection (GCC)}, for information on the
1332627f7eb2Smrg@option{-I} option.
1333627f7eb2Smrg
1334627f7eb2Smrg@item -J@var{dir}
1335627f7eb2Smrg@opindex @code{J}@var{dir}
1336627f7eb2Smrg@opindex @code{M}@var{dir}
1337627f7eb2Smrg@cindex paths, search
1338627f7eb2Smrg@cindex module search path
1339627f7eb2SmrgThis option specifies where to put @file{.mod} files for compiled modules.
1340627f7eb2SmrgIt is also added to the list of directories to searched by an @code{USE}
1341627f7eb2Smrgstatement.
1342627f7eb2Smrg
1343627f7eb2SmrgThe default is the current directory.
1344627f7eb2Smrg
1345627f7eb2Smrg@item -fintrinsic-modules-path @var{dir}
1346627f7eb2Smrg@opindex @code{fintrinsic-modules-path} @var{dir}
1347627f7eb2Smrg@cindex paths, search
1348627f7eb2Smrg@cindex module search path
1349627f7eb2SmrgThis option specifies the location of pre-compiled intrinsic modules, if
1350627f7eb2Smrgthey are not in the default location expected by the compiler.
1351627f7eb2Smrg@end table
1352627f7eb2Smrg
1353627f7eb2Smrg@node Link Options
1354627f7eb2Smrg@section Influencing the linking step
1355627f7eb2Smrg@cindex options, linking
1356627f7eb2Smrg@cindex linking, static
1357627f7eb2Smrg
1358627f7eb2SmrgThese options come into play when the compiler links object files into an
1359627f7eb2Smrgexecutable output file. They are meaningless if the compiler is not doing
1360627f7eb2Smrga link step.
1361627f7eb2Smrg
1362627f7eb2Smrg@table @gcctabopt
1363627f7eb2Smrg@item -static-libgfortran
1364627f7eb2Smrg@opindex @code{static-libgfortran}
1365627f7eb2SmrgOn systems that provide @file{libgfortran} as a shared and a static
1366627f7eb2Smrglibrary, this option forces the use of the static version. If no
1367627f7eb2Smrgshared version of @file{libgfortran} was built when the compiler was
1368627f7eb2Smrgconfigured, this option has no effect.
1369627f7eb2Smrg@end table
1370627f7eb2Smrg
1371627f7eb2Smrg
1372627f7eb2Smrg@node Runtime Options
1373627f7eb2Smrg@section Influencing runtime behavior
1374627f7eb2Smrg@cindex options, runtime
1375627f7eb2Smrg
1376627f7eb2SmrgThese options affect the runtime behavior of programs compiled with GNU Fortran.
1377627f7eb2Smrg
1378627f7eb2Smrg@table @gcctabopt
1379627f7eb2Smrg@item -fconvert=@var{conversion}
1380627f7eb2Smrg@opindex @code{fconvert=}@var{conversion}
1381627f7eb2SmrgSpecify the representation of data for unformatted files.  Valid
1382627f7eb2Smrgvalues for conversion are: @samp{native}, the default; @samp{swap},
1383627f7eb2Smrgswap between big- and little-endian; @samp{big-endian}, use big-endian
1384627f7eb2Smrgrepresentation for unformatted files; @samp{little-endian}, use little-endian
1385627f7eb2Smrgrepresentation for unformatted files.
1386627f7eb2Smrg
1387627f7eb2Smrg@emph{This option has an effect only when used in the main program.
1388627f7eb2SmrgThe @code{CONVERT} specifier and the GFORTRAN_CONVERT_UNIT environment
1389627f7eb2Smrgvariable override the default specified by @option{-fconvert}.}
1390627f7eb2Smrg
1391627f7eb2Smrg@item -frecord-marker=@var{length}
1392627f7eb2Smrg@opindex @code{frecord-marker=}@var{length}
1393627f7eb2SmrgSpecify the length of record markers for unformatted files.
1394627f7eb2SmrgValid values for @var{length} are 4 and 8.  Default is 4.
1395627f7eb2Smrg@emph{This is different from previous versions of @command{gfortran}},
1396627f7eb2Smrgwhich specified a default record marker length of 8 on most
1397627f7eb2Smrgsystems.  If you want to read or write files compatible
1398627f7eb2Smrgwith earlier versions of @command{gfortran}, use @option{-frecord-marker=8}.
1399627f7eb2Smrg
1400627f7eb2Smrg@item -fmax-subrecord-length=@var{length}
1401627f7eb2Smrg@opindex @code{fmax-subrecord-length=}@var{length}
1402627f7eb2SmrgSpecify the maximum length for a subrecord.  The maximum permitted
1403627f7eb2Smrgvalue for length is 2147483639, which is also the default.  Only
1404627f7eb2Smrgreally useful for use by the gfortran testsuite.
1405627f7eb2Smrg
1406627f7eb2Smrg@item -fsign-zero
1407627f7eb2Smrg@opindex @code{fsign-zero}
1408627f7eb2SmrgWhen enabled, floating point numbers of value zero with the sign bit set
1409627f7eb2Smrgare written as negative number in formatted output and treated as
1410627f7eb2Smrgnegative in the @code{SIGN} intrinsic.  @option{-fno-sign-zero} does not
1411627f7eb2Smrgprint the negative sign of zero values (or values rounded to zero for I/O)
1412627f7eb2Smrgand regards zero as positive number in the @code{SIGN} intrinsic for
1413627f7eb2Smrgcompatibility with Fortran 77. The default is @option{-fsign-zero}.
1414627f7eb2Smrg@end table
1415627f7eb2Smrg
1416627f7eb2Smrg@node Code Gen Options
1417627f7eb2Smrg@section Options for code generation conventions
1418627f7eb2Smrg@cindex code generation, conventions
1419627f7eb2Smrg@cindex options, code generation
1420627f7eb2Smrg@cindex options, run-time
1421627f7eb2Smrg
1422627f7eb2SmrgThese machine-independent options control the interface conventions
1423627f7eb2Smrgused in code generation.
1424627f7eb2Smrg
1425627f7eb2SmrgMost of them have both positive and negative forms; the negative form
1426627f7eb2Smrgof @option{-ffoo} would be @option{-fno-foo}.  In the table below, only
1427627f7eb2Smrgone of the forms is listed---the one which is not the default.  You
1428627f7eb2Smrgcan figure out the other form by either removing @option{no-} or adding
1429627f7eb2Smrgit.
1430627f7eb2Smrg
1431627f7eb2Smrg@table @gcctabopt
1432627f7eb2Smrg@item -fno-automatic
1433627f7eb2Smrg@opindex @code{fno-automatic}
1434627f7eb2Smrg@cindex @code{SAVE} statement
1435627f7eb2Smrg@cindex statement, @code{SAVE}
1436627f7eb2SmrgTreat each program unit (except those marked as RECURSIVE) as if the
1437627f7eb2Smrg@code{SAVE} statement were specified for every local variable and array
1438627f7eb2Smrgreferenced in it. Does not affect common blocks. (Some Fortran compilers
1439627f7eb2Smrgprovide this option under the name @option{-static} or @option{-save}.)
1440627f7eb2SmrgThe default, which is @option{-fautomatic}, uses the stack for local
1441627f7eb2Smrgvariables smaller than the value given by @option{-fmax-stack-var-size}.
1442627f7eb2SmrgUse the option @option{-frecursive} to use no static memory.
1443627f7eb2Smrg
1444627f7eb2SmrgLocal variables or arrays having an explicit @code{SAVE} attribute are
1445627f7eb2Smrgsilently ignored unless the @option{-pedantic} option is added.
1446627f7eb2Smrg
1447627f7eb2Smrg@item -ff2c
1448627f7eb2Smrg@opindex ff2c
1449627f7eb2Smrg@cindex calling convention
1450627f7eb2Smrg@cindex @command{f2c} calling convention
1451627f7eb2Smrg@cindex @command{g77} calling convention
1452627f7eb2Smrg@cindex libf2c calling convention
1453627f7eb2SmrgGenerate code designed to be compatible with code generated
1454627f7eb2Smrgby @command{g77} and @command{f2c}.
1455627f7eb2Smrg
1456627f7eb2SmrgThe calling conventions used by @command{g77} (originally implemented
1457627f7eb2Smrgin @command{f2c}) require functions that return type
1458627f7eb2Smrgdefault @code{REAL} to actually return the C type @code{double}, and
1459627f7eb2Smrgfunctions that return type @code{COMPLEX} to return the values via an
1460627f7eb2Smrgextra argument in the calling sequence that points to where to
1461627f7eb2Smrgstore the return value.  Under the default GNU calling conventions, such
1462627f7eb2Smrgfunctions simply return their results as they would in GNU
1463627f7eb2SmrgC---default @code{REAL} functions return the C type @code{float}, and
1464627f7eb2Smrg@code{COMPLEX} functions return the GNU C type @code{complex}.
1465627f7eb2SmrgAdditionally, this option implies the @option{-fsecond-underscore}
1466627f7eb2Smrgoption, unless @option{-fno-second-underscore} is explicitly requested.
1467627f7eb2Smrg
1468627f7eb2SmrgThis does not affect the generation of code that interfaces with
1469627f7eb2Smrgthe @command{libgfortran} library.
1470627f7eb2Smrg
1471627f7eb2Smrg@emph{Caution:} It is not a good idea to mix Fortran code compiled with
1472627f7eb2Smrg@option{-ff2c} with code compiled with the default @option{-fno-f2c}
1473627f7eb2Smrgcalling conventions as, calling @code{COMPLEX} or default @code{REAL}
1474627f7eb2Smrgfunctions between program parts which were compiled with different
1475627f7eb2Smrgcalling conventions will break at execution time.
1476627f7eb2Smrg
1477627f7eb2Smrg@emph{Caution:} This will break code which passes intrinsic functions
1478627f7eb2Smrgof type default @code{REAL} or @code{COMPLEX} as actual arguments, as
1479627f7eb2Smrgthe library implementations use the @option{-fno-f2c} calling conventions.
1480627f7eb2Smrg
1481627f7eb2Smrg@item -fno-underscoring
1482627f7eb2Smrg@opindex @code{fno-underscoring}
1483627f7eb2Smrg@cindex underscore
1484627f7eb2Smrg@cindex symbol names, underscores
1485627f7eb2Smrg@cindex transforming symbol names
1486627f7eb2Smrg@cindex symbol names, transforming
1487627f7eb2SmrgDo not transform names of entities specified in the Fortran
1488627f7eb2Smrgsource file by appending underscores to them.
1489627f7eb2Smrg
1490627f7eb2SmrgWith @option{-funderscoring} in effect, GNU Fortran appends one
1491627f7eb2Smrgunderscore to external names with no underscores.  This is done to ensure
1492627f7eb2Smrgcompatibility with code produced by many UNIX Fortran compilers.
1493627f7eb2Smrg
1494627f7eb2Smrg@emph{Caution}: The default behavior of GNU Fortran is
1495627f7eb2Smrgincompatible with @command{f2c} and @command{g77}, please use the
1496627f7eb2Smrg@option{-ff2c} option if you want object files compiled with
1497627f7eb2SmrgGNU Fortran to be compatible with object code created with these
1498627f7eb2Smrgtools.
1499627f7eb2Smrg
1500627f7eb2SmrgUse of @option{-fno-underscoring} is not recommended unless you are
1501627f7eb2Smrgexperimenting with issues such as integration of GNU Fortran into
1502627f7eb2Smrgexisting system environments (vis-@`{a}-vis existing libraries, tools,
1503627f7eb2Smrgand so on).
1504627f7eb2Smrg
1505627f7eb2SmrgFor example, with @option{-funderscoring}, and assuming that @code{j()} and
1506627f7eb2Smrg@code{max_count()} are external functions while @code{my_var} and
1507627f7eb2Smrg@code{lvar} are local variables, a statement like
1508627f7eb2Smrg@smallexample
1509627f7eb2SmrgI = J() + MAX_COUNT (MY_VAR, LVAR)
1510627f7eb2Smrg@end smallexample
1511627f7eb2Smrg@noindent
1512627f7eb2Smrgis implemented as something akin to:
1513627f7eb2Smrg@smallexample
1514627f7eb2Smrgi = j_() + max_count__(&my_var__, &lvar);
1515627f7eb2Smrg@end smallexample
1516627f7eb2Smrg
1517627f7eb2SmrgWith @option{-fno-underscoring}, the same statement is implemented as:
1518627f7eb2Smrg
1519627f7eb2Smrg@smallexample
1520627f7eb2Smrgi = j() + max_count(&my_var, &lvar);
1521627f7eb2Smrg@end smallexample
1522627f7eb2Smrg
1523627f7eb2SmrgUse of @option{-fno-underscoring} allows direct specification of
1524627f7eb2Smrguser-defined names while debugging and when interfacing GNU Fortran
1525627f7eb2Smrgcode with other languages.
1526627f7eb2Smrg
1527627f7eb2SmrgNote that just because the names match does @emph{not} mean that the
1528627f7eb2Smrginterface implemented by GNU Fortran for an external name matches the
1529627f7eb2Smrginterface implemented by some other language for that same name.
1530627f7eb2SmrgThat is, getting code produced by GNU Fortran to link to code produced
1531627f7eb2Smrgby some other compiler using this or any other method can be only a
1532627f7eb2Smrgsmall part of the overall solution---getting the code generated by
1533627f7eb2Smrgboth compilers to agree on issues other than naming can require
1534627f7eb2Smrgsignificant effort, and, unlike naming disagreements, linkers normally
1535627f7eb2Smrgcannot detect disagreements in these other areas.
1536627f7eb2Smrg
1537627f7eb2SmrgAlso, note that with @option{-fno-underscoring}, the lack of appended
1538627f7eb2Smrgunderscores introduces the very real possibility that a user-defined
1539627f7eb2Smrgexternal name will conflict with a name in a system library, which
1540627f7eb2Smrgcould make finding unresolved-reference bugs quite difficult in some
1541627f7eb2Smrgcases---they might occur at program run time, and show up only as
1542627f7eb2Smrgbuggy behavior at run time.
1543627f7eb2Smrg
1544627f7eb2SmrgIn future versions of GNU Fortran we hope to improve naming and linking
1545627f7eb2Smrgissues so that debugging always involves using the names as they appear
1546627f7eb2Smrgin the source, even if the names as seen by the linker are mangled to
1547627f7eb2Smrgprevent accidental linking between procedures with incompatible
1548627f7eb2Smrginterfaces.
1549627f7eb2Smrg
1550627f7eb2Smrg@item -fsecond-underscore
1551627f7eb2Smrg@opindex @code{fsecond-underscore}
1552627f7eb2Smrg@cindex underscore
1553627f7eb2Smrg@cindex symbol names, underscores
1554627f7eb2Smrg@cindex transforming symbol names
1555627f7eb2Smrg@cindex symbol names, transforming
1556627f7eb2Smrg@cindex @command{f2c} calling convention
1557627f7eb2Smrg@cindex @command{g77} calling convention
1558627f7eb2Smrg@cindex libf2c calling convention
1559627f7eb2SmrgBy default, GNU Fortran appends an underscore to external
1560627f7eb2Smrgnames.  If this option is used GNU Fortran appends two
1561627f7eb2Smrgunderscores to names with underscores and one underscore to external names
1562627f7eb2Smrgwith no underscores.  GNU Fortran also appends two underscores to
1563627f7eb2Smrginternal names with underscores to avoid naming collisions with external
1564627f7eb2Smrgnames.
1565627f7eb2Smrg
1566627f7eb2SmrgThis option has no effect if @option{-fno-underscoring} is
1567627f7eb2Smrgin effect.  It is implied by the @option{-ff2c} option.
1568627f7eb2Smrg
1569627f7eb2SmrgOtherwise, with this option, an external name such as @code{MAX_COUNT}
1570627f7eb2Smrgis implemented as a reference to the link-time external symbol
1571627f7eb2Smrg@code{max_count__}, instead of @code{max_count_}.  This is required
1572627f7eb2Smrgfor compatibility with @command{g77} and @command{f2c}, and is implied
1573627f7eb2Smrgby use of the @option{-ff2c} option.
1574627f7eb2Smrg
1575627f7eb2Smrg@item -fcoarray=@var{<keyword>}
1576627f7eb2Smrg@opindex @code{fcoarray}
1577627f7eb2Smrg@cindex coarrays
1578627f7eb2Smrg
1579627f7eb2Smrg@table @asis
1580627f7eb2Smrg@item @samp{none}
1581627f7eb2SmrgDisable coarray support; using coarray declarations and image-control
1582627f7eb2Smrgstatements will produce a compile-time error. (Default)
1583627f7eb2Smrg
1584627f7eb2Smrg@item @samp{single}
1585627f7eb2SmrgSingle-image mode, i.e. @code{num_images()} is always one.
1586627f7eb2Smrg
1587627f7eb2Smrg@item @samp{lib}
1588627f7eb2SmrgLibrary-based coarray parallelization; a suitable GNU Fortran coarray
1589627f7eb2Smrglibrary needs to be linked.
1590627f7eb2Smrg@end table
1591627f7eb2Smrg
1592627f7eb2Smrg
1593627f7eb2Smrg@item -fcheck=@var{<keyword>}
1594627f7eb2Smrg@opindex @code{fcheck}
1595627f7eb2Smrg@cindex array, bounds checking
1596*4c3eb207Smrg@cindex bit intrinsics checking
1597627f7eb2Smrg@cindex bounds checking
1598627f7eb2Smrg@cindex pointer checking
1599627f7eb2Smrg@cindex memory checking
1600627f7eb2Smrg@cindex range checking
1601627f7eb2Smrg@cindex subscript checking
1602627f7eb2Smrg@cindex checking subscripts
1603627f7eb2Smrg@cindex run-time checking
1604627f7eb2Smrg@cindex checking array temporaries
1605627f7eb2Smrg
1606627f7eb2SmrgEnable the generation of run-time checks; the argument shall be
1607627f7eb2Smrga comma-delimited list of the following keywords.  Prefixing a check with
1608627f7eb2Smrg@option{no-} disables it if it was activated by a previous specification.
1609627f7eb2Smrg
1610627f7eb2Smrg@table @asis
1611627f7eb2Smrg@item @samp{all}
1612627f7eb2SmrgEnable all run-time test of @option{-fcheck}.
1613627f7eb2Smrg
1614627f7eb2Smrg@item @samp{array-temps}
1615627f7eb2SmrgWarns at run time when for passing an actual argument a temporary array
1616627f7eb2Smrghad to be generated. The information generated by this warning is
1617627f7eb2Smrgsometimes useful in optimization, in order to avoid such temporaries.
1618627f7eb2Smrg
1619627f7eb2SmrgNote: The warning is only printed once per location.
1620627f7eb2Smrg
1621*4c3eb207Smrg@item @samp{bits}
1622*4c3eb207SmrgEnable generation of run-time checks for invalid arguments to the bit
1623*4c3eb207Smrgmanipulation intrinsics.
1624*4c3eb207Smrg
1625627f7eb2Smrg@item @samp{bounds}
1626627f7eb2SmrgEnable generation of run-time checks for array subscripts
1627627f7eb2Smrgand against the declared minimum and maximum values.  It also
1628627f7eb2Smrgchecks array indices for assumed and deferred
1629627f7eb2Smrgshape arrays against the actual allocated bounds and ensures that all string
1630627f7eb2Smrglengths are equal for character array constructors without an explicit
1631627f7eb2Smrgtypespec.
1632627f7eb2Smrg
1633627f7eb2SmrgSome checks require that @option{-fcheck=bounds} is set for
1634627f7eb2Smrgthe compilation of the main program.
1635627f7eb2Smrg
1636627f7eb2SmrgNote: In the future this may also include other forms of checking, e.g.,
1637627f7eb2Smrgchecking substring references.
1638627f7eb2Smrg
1639627f7eb2Smrg@item @samp{do}
1640627f7eb2SmrgEnable generation of run-time checks for invalid modification of loop
1641627f7eb2Smrgiteration variables.
1642627f7eb2Smrg
1643627f7eb2Smrg@item @samp{mem}
1644627f7eb2SmrgEnable generation of run-time checks for memory allocation.
1645627f7eb2SmrgNote: This option does not affect explicit allocations using the
1646627f7eb2Smrg@code{ALLOCATE} statement, which will be always checked.
1647627f7eb2Smrg
1648627f7eb2Smrg@item @samp{pointer}
1649627f7eb2SmrgEnable generation of run-time checks for pointers and allocatables.
1650627f7eb2Smrg
1651627f7eb2Smrg@item @samp{recursion}
1652627f7eb2SmrgEnable generation of run-time checks for recursively called subroutines and
1653627f7eb2Smrgfunctions which are not marked as recursive. See also @option{-frecursive}.
1654627f7eb2SmrgNote: This check does not work for OpenMP programs and is disabled if used
1655627f7eb2Smrgtogether with @option{-frecursive} and @option{-fopenmp}.
1656627f7eb2Smrg@end table
1657627f7eb2Smrg
1658627f7eb2SmrgExample: Assuming you have a file @file{foo.f90}, the command
1659627f7eb2Smrg@smallexample
1660627f7eb2Smrg  gfortran -fcheck=all,no-array-temps foo.f90
1661627f7eb2Smrg@end smallexample
1662627f7eb2Smrgwill compile the file with all checks enabled as specified above except
1663627f7eb2Smrgwarnings for generated array temporaries.
1664627f7eb2Smrg
1665627f7eb2Smrg
1666627f7eb2Smrg@item -fbounds-check
1667627f7eb2Smrg@opindex @code{fbounds-check}
1668627f7eb2Smrg@c Note: This option is also referred in gcc's manpage
1669627f7eb2SmrgDeprecated alias for @option{-fcheck=bounds}.
1670627f7eb2Smrg
1671627f7eb2Smrg@item -ftail-call-workaround
1672627f7eb2Smrg@itemx -ftail-call-workaround=@var{n}
1673627f7eb2Smrg@opindex @code{tail-call-workaround}
1674627f7eb2SmrgSome C interfaces to Fortran codes violate the gfortran ABI by
1675627f7eb2Smrgomitting the hidden character length arguments as described in
1676627f7eb2Smrg@xref{Argument passing conventions}.  This can lead to crashes
1677627f7eb2Smrgbecause pushing arguments for tail calls can overflow the stack.
1678627f7eb2Smrg
1679627f7eb2SmrgTo provide a workaround for existing binary packages, this option
1680627f7eb2Smrgdisables tail call optimization for gfortran procedures with character
1681627f7eb2Smrgarguments.  With @option{-ftail-call-workaround=2} tail call optimization
1682627f7eb2Smrgis disabled in all gfortran procedures with character arguments,
1683627f7eb2Smrgwith @option{-ftail-call-workaround=1} or equivalent
1684627f7eb2Smrg@option{-ftail-call-workaround} only in gfortran procedures with character
1685627f7eb2Smrgarguments that call implicitly prototyped procedures.
1686627f7eb2Smrg
1687627f7eb2SmrgUsing this option can lead to problems including crashes due to
1688627f7eb2Smrginsufficient stack space.
1689627f7eb2Smrg
1690627f7eb2SmrgIt is @emph{very strongly} recommended to fix the code in question.
1691627f7eb2SmrgThe @option{-fc-prototypes-external} option can be used to generate
1692627f7eb2Smrgprototypes which conform to gfortran's ABI, for inclusion in the
1693627f7eb2Smrgsource code.
1694627f7eb2Smrg
1695627f7eb2SmrgSupport for this option will likely be withdrawn in a future release
1696627f7eb2Smrgof gfortran.
1697627f7eb2Smrg
1698627f7eb2SmrgThe negative form, @option{-fno-tail-call-workaround} or equivalent
1699627f7eb2Smrg@option{-ftail-call-workaround=0}, can be used to disable this option.
1700627f7eb2Smrg
1701627f7eb2SmrgDefault is currently @option{-ftail-call-workaround}, this will change
1702627f7eb2Smrgin future releases.
1703627f7eb2Smrg
1704627f7eb2Smrg@item -fcheck-array-temporaries
1705627f7eb2Smrg@opindex @code{fcheck-array-temporaries}
1706627f7eb2SmrgDeprecated alias for @option{-fcheck=array-temps}.
1707627f7eb2Smrg
1708627f7eb2Smrg@item -fmax-array-constructor=@var{n}
1709627f7eb2Smrg@opindex @code{fmax-array-constructor}
1710627f7eb2SmrgThis option can be used to increase the upper limit permitted in
1711627f7eb2Smrgarray constructors.  The code below requires this option to expand
1712627f7eb2Smrgthe array at compile time.
1713627f7eb2Smrg
1714627f7eb2Smrg@smallexample
1715627f7eb2Smrgprogram test
1716627f7eb2Smrgimplicit none
1717627f7eb2Smrginteger j
1718627f7eb2Smrginteger, parameter :: n = 100000
1719627f7eb2Smrginteger, parameter :: i(n) = (/ (2*j, j = 1, n) /)
1720627f7eb2Smrgprint '(10(I0,1X))', i
1721627f7eb2Smrgend program test
1722627f7eb2Smrg@end smallexample
1723627f7eb2Smrg
1724627f7eb2Smrg@emph{Caution:  This option can lead to long compile times and excessively
1725627f7eb2Smrglarge object files.}
1726627f7eb2Smrg
1727627f7eb2SmrgThe default value for @var{n} is 65535.
1728627f7eb2Smrg
1729627f7eb2Smrg
1730627f7eb2Smrg@item -fmax-stack-var-size=@var{n}
1731627f7eb2Smrg@opindex @code{fmax-stack-var-size}
1732627f7eb2SmrgThis option specifies the size in bytes of the largest array that will be put
1733627f7eb2Smrgon the stack; if the size is exceeded static memory is used (except in
1734627f7eb2Smrgprocedures marked as RECURSIVE). Use the option @option{-frecursive} to
1735627f7eb2Smrgallow for recursive procedures which do not have a RECURSIVE attribute or
1736627f7eb2Smrgfor parallel programs. Use @option{-fno-automatic} to never use the stack.
1737627f7eb2Smrg
1738627f7eb2SmrgThis option currently only affects local arrays declared with constant
1739627f7eb2Smrgbounds, and may not apply to all character variables.
1740627f7eb2SmrgFuture versions of GNU Fortran may improve this behavior.
1741627f7eb2Smrg
1742*4c3eb207SmrgThe default value for @var{n} is 65536.
1743627f7eb2Smrg
1744627f7eb2Smrg@item -fstack-arrays
1745627f7eb2Smrg@opindex @code{fstack-arrays}
1746627f7eb2SmrgAdding this option will make the Fortran compiler put all arrays of
1747627f7eb2Smrgunknown size and array temporaries onto stack memory.  If your program uses very
1748627f7eb2Smrglarge local arrays it is possible that you will have to extend your runtime
1749627f7eb2Smrglimits for stack memory on some operating systems. This flag is enabled
1750627f7eb2Smrgby default at optimization level @option{-Ofast} unless
1751627f7eb2Smrg@option{-fmax-stack-var-size} is specified.
1752627f7eb2Smrg
1753627f7eb2Smrg@item -fpack-derived
1754627f7eb2Smrg@opindex @code{fpack-derived}
1755627f7eb2Smrg@cindex structure packing
1756627f7eb2SmrgThis option tells GNU Fortran to pack derived type members as closely as
1757627f7eb2Smrgpossible.  Code compiled with this option is likely to be incompatible
1758627f7eb2Smrgwith code compiled without this option, and may execute slower.
1759627f7eb2Smrg
1760627f7eb2Smrg@item -frepack-arrays
1761627f7eb2Smrg@opindex @code{frepack-arrays}
1762627f7eb2Smrg@cindex repacking arrays
1763627f7eb2SmrgIn some circumstances GNU Fortran may pass assumed shape array
1764627f7eb2Smrgsections via a descriptor describing a noncontiguous area of memory.
1765627f7eb2SmrgThis option adds code to the function prologue to repack the data into
1766627f7eb2Smrga contiguous block at runtime.
1767627f7eb2Smrg
1768627f7eb2SmrgThis should result in faster accesses to the array.  However it can introduce
1769627f7eb2Smrgsignificant overhead to the function call, especially  when the passed data
1770627f7eb2Smrgis noncontiguous.
1771627f7eb2Smrg
1772627f7eb2Smrg@item -fshort-enums
1773627f7eb2Smrg@opindex @code{fshort-enums}
1774627f7eb2SmrgThis option is provided for interoperability with C code that was
1775627f7eb2Smrgcompiled with the @option{-fshort-enums} option.  It will make
1776627f7eb2SmrgGNU Fortran choose the smallest @code{INTEGER} kind a given
1777627f7eb2Smrgenumerator set will fit in, and give all its enumerators this kind.
1778627f7eb2Smrg
1779*4c3eb207Smrg@item -finline-arg-packing
1780*4c3eb207Smrg@opindex @code{finline-arg-packing}
1781*4c3eb207SmrgWhen passing an assumed-shape argument of a procedure as actual
1782*4c3eb207Smrgargument to an assumed-size or explicit size or as argument to a
1783*4c3eb207Smrgprocedure that does not have an explicit interface, the argument may
1784*4c3eb207Smrghave to be packed, that is put into contiguous memory. An example is
1785*4c3eb207Smrgthe call to @code{foo} in
1786*4c3eb207Smrg@smallexample
1787*4c3eb207Smrg  subroutine foo(a)
1788*4c3eb207Smrg     real, dimension(*) :: a
1789*4c3eb207Smrg  end subroutine foo
1790*4c3eb207Smrg  subroutine bar(b)
1791*4c3eb207Smrg     real, dimension(:) :: b
1792*4c3eb207Smrg     call foo(b)
1793*4c3eb207Smrg  end subroutine bar
1794*4c3eb207Smrg@end smallexample
1795*4c3eb207Smrg
1796*4c3eb207SmrgWhen @option{-finline-arg-packing} is in effect, this packing will be
1797*4c3eb207Smrgperformed by inline code. This allows for more optimization while
1798*4c3eb207Smrgincreasing code size.
1799*4c3eb207Smrg
1800*4c3eb207Smrg@option{-finline-arg-packing} is implied by any of the @option{-O} options
1801*4c3eb207Smrgexcept when optimizing for size via @option{-Os}.  If the code
1802*4c3eb207Smrgcontains a very large number of argument that have to be packed, code
1803*4c3eb207Smrgsize and also compilation time may become excessive.  If that is the
1804*4c3eb207Smrgcase, it may be better to disable this option.  Instances of packing
1805*4c3eb207Smrgcan be found by using by using @option{-Warray-temporaries}.
1806*4c3eb207Smrg
1807627f7eb2Smrg@item -fexternal-blas
1808627f7eb2Smrg@opindex @code{fexternal-blas}
1809627f7eb2SmrgThis option will make @command{gfortran} generate calls to BLAS functions
1810627f7eb2Smrgfor some matrix operations like @code{MATMUL}, instead of using our own
1811627f7eb2Smrgalgorithms, if the size of the matrices involved is larger than a given
1812627f7eb2Smrglimit (see @option{-fblas-matmul-limit}).  This may be profitable if an
1813627f7eb2Smrgoptimized vendor BLAS library is available.  The BLAS library will have
1814627f7eb2Smrgto be specified at link time.
1815627f7eb2Smrg
1816627f7eb2Smrg@item -fblas-matmul-limit=@var{n}
1817627f7eb2Smrg@opindex @code{fblas-matmul-limit}
1818627f7eb2SmrgOnly significant when @option{-fexternal-blas} is in effect.
1819627f7eb2SmrgMatrix multiplication of matrices with size larger than (or equal to) @var{n}
1820627f7eb2Smrgwill be performed by calls to BLAS functions, while others will be
1821627f7eb2Smrghandled by @command{gfortran} internal algorithms. If the matrices
1822627f7eb2Smrginvolved are not square, the size comparison is performed using the
1823627f7eb2Smrggeometric mean of the dimensions of the argument and result matrices.
1824627f7eb2Smrg
1825627f7eb2SmrgThe default value for @var{n} is 30.
1826627f7eb2Smrg
1827627f7eb2Smrg@item -finline-matmul-limit=@var{n}
1828627f7eb2Smrg@opindex @code{finline-matmul-limit}
1829627f7eb2SmrgWhen front-end optimiztion is active, some calls to the @code{MATMUL}
1830627f7eb2Smrgintrinsic function will be inlined.  This may result in code size
1831627f7eb2Smrgincrease if the size of the matrix cannot be determined at compile
1832627f7eb2Smrgtime, as code for both cases is generated.  Setting
1833627f7eb2Smrg@code{-finline-matmul-limit=0} will disable inlining in all cases.
1834627f7eb2SmrgSetting this option with a value of @var{n} will produce inline code
1835627f7eb2Smrgfor matrices with size up to @var{n}. If the matrices involved are not
1836627f7eb2Smrgsquare, the size comparison is performed using the geometric mean of
1837627f7eb2Smrgthe dimensions of the argument and result matrices.
1838627f7eb2Smrg
1839627f7eb2SmrgThe default value for @var{n} is 30.  The @code{-fblas-matmul-limit}
1840627f7eb2Smrgcan be used to change this value.
1841627f7eb2Smrg
1842627f7eb2Smrg@item -frecursive
1843627f7eb2Smrg@opindex @code{frecursive}
1844627f7eb2SmrgAllow indirect recursion by forcing all local arrays to be allocated
1845627f7eb2Smrgon the stack. This flag cannot be used together with
1846627f7eb2Smrg@option{-fmax-stack-var-size=} or @option{-fno-automatic}.
1847627f7eb2Smrg
1848627f7eb2Smrg@item -finit-local-zero
1849627f7eb2Smrg@itemx -finit-derived
1850627f7eb2Smrg@itemx -finit-integer=@var{n}
1851627f7eb2Smrg@itemx -finit-real=@var{<zero|inf|-inf|nan|snan>}
1852627f7eb2Smrg@itemx -finit-logical=@var{<true|false>}
1853627f7eb2Smrg@itemx -finit-character=@var{n}
1854627f7eb2Smrg@opindex @code{finit-local-zero}
1855627f7eb2Smrg@opindex @code{finit-derived}
1856627f7eb2Smrg@opindex @code{finit-integer}
1857627f7eb2Smrg@opindex @code{finit-real}
1858627f7eb2Smrg@opindex @code{finit-logical}
1859627f7eb2Smrg@opindex @code{finit-character}
1860627f7eb2SmrgThe @option{-finit-local-zero} option instructs the compiler to
1861627f7eb2Smrginitialize local @code{INTEGER}, @code{REAL}, and @code{COMPLEX}
1862627f7eb2Smrgvariables to zero, @code{LOGICAL} variables to false, and
1863627f7eb2Smrg@code{CHARACTER} variables to a string of null bytes.  Finer-grained
1864627f7eb2Smrginitialization options are provided by the
1865627f7eb2Smrg@option{-finit-integer=@var{n}},
1866627f7eb2Smrg@option{-finit-real=@var{<zero|inf|-inf|nan|snan>}} (which also initializes
1867627f7eb2Smrgthe real and imaginary parts of local @code{COMPLEX} variables),
1868627f7eb2Smrg@option{-finit-logical=@var{<true|false>}}, and
1869627f7eb2Smrg@option{-finit-character=@var{n}} (where @var{n} is an ASCII character
1870627f7eb2Smrgvalue) options.
1871627f7eb2Smrg
1872627f7eb2SmrgWith @option{-finit-derived}, components of derived type variables will be
1873627f7eb2Smrginitialized according to these flags.  Components whose type is not covered by
1874627f7eb2Smrgan explicit @option{-finit-*} flag will be treated as described above with
1875627f7eb2Smrg@option{-finit-local-zero}.
1876627f7eb2Smrg
1877627f7eb2SmrgThese options do not initialize
1878627f7eb2Smrg@itemize @bullet
1879627f7eb2Smrg@item
1880627f7eb2Smrgobjects with the POINTER attribute
1881627f7eb2Smrg@item
1882627f7eb2Smrgallocatable arrays
1883627f7eb2Smrg@item
1884627f7eb2Smrgvariables that appear in an @code{EQUIVALENCE} statement.
1885627f7eb2Smrg@end itemize
1886627f7eb2Smrg(These limitations may be removed in future releases).
1887627f7eb2Smrg
1888627f7eb2SmrgNote that the @option{-finit-real=nan} option initializes @code{REAL}
1889627f7eb2Smrgand @code{COMPLEX} variables with a quiet NaN. For a signalling NaN
1890627f7eb2Smrguse @option{-finit-real=snan}; note, however, that compile-time
1891627f7eb2Smrgoptimizations may convert them into quiet NaN and that trapping
1892627f7eb2Smrgneeds to be enabled (e.g. via @option{-ffpe-trap}).
1893627f7eb2Smrg
1894627f7eb2SmrgThe @option{-finit-integer} option will parse the value into an
1895627f7eb2Smrginteger of type @code{INTEGER(kind=C_LONG)} on the host.  Said value
1896627f7eb2Smrgis then assigned to the integer variables in the Fortran code, which
1897627f7eb2Smrgmight result in wraparound if the value is too large for the kind.
1898627f7eb2Smrg
1899627f7eb2SmrgFinally, note that enabling any of the @option{-finit-*} options will
1900627f7eb2Smrgsilence warnings that would have been emitted by @option{-Wuninitialized}
1901627f7eb2Smrgfor the affected local variables.
1902627f7eb2Smrg
1903627f7eb2Smrg@item -falign-commons
1904627f7eb2Smrg@opindex @code{falign-commons}
1905627f7eb2Smrg@cindex alignment of @code{COMMON} blocks
1906627f7eb2SmrgBy default, @command{gfortran} enforces proper alignment of all variables in a
1907627f7eb2Smrg@code{COMMON} block by padding them as needed. On certain platforms this is mandatory,
1908627f7eb2Smrgon others it increases performance. If a @code{COMMON} block is not declared with
1909627f7eb2Smrgconsistent data types everywhere, this padding can cause trouble, and
1910627f7eb2Smrg@option{-fno-align-commons} can be used to disable automatic alignment. The
1911627f7eb2Smrgsame form of this option should be used for all files that share a @code{COMMON} block.
1912627f7eb2SmrgTo avoid potential alignment issues in @code{COMMON} blocks, it is recommended to order
1913627f7eb2Smrgobjects from largest to smallest.
1914627f7eb2Smrg
1915627f7eb2Smrg@item -fno-protect-parens
1916627f7eb2Smrg@opindex @code{fno-protect-parens}
1917627f7eb2Smrg@cindex re-association of parenthesized expressions
1918627f7eb2SmrgBy default the parentheses in expression are honored for all optimization
1919627f7eb2Smrglevels such that the compiler does not do any re-association. Using
1920627f7eb2Smrg@option{-fno-protect-parens} allows the compiler to reorder @code{REAL} and
1921627f7eb2Smrg@code{COMPLEX} expressions to produce faster code. Note that for the re-association
1922627f7eb2Smrgoptimization @option{-fno-signed-zeros} and @option{-fno-trapping-math}
1923627f7eb2Smrgneed to be in effect. The parentheses protection is enabled by default, unless
1924627f7eb2Smrg@option{-Ofast} is given.
1925627f7eb2Smrg
1926627f7eb2Smrg@item -frealloc-lhs
1927627f7eb2Smrg@opindex @code{frealloc-lhs}
1928627f7eb2Smrg@cindex Reallocate the LHS in assignments
1929627f7eb2SmrgAn allocatable left-hand side of an intrinsic assignment is automatically
1930627f7eb2Smrg(re)allocated if it is either unallocated or has a different shape. The
1931627f7eb2Smrgoption is enabled by default except when @option{-std=f95} is given. See
1932627f7eb2Smrgalso @option{-Wrealloc-lhs}.
1933627f7eb2Smrg
1934627f7eb2Smrg@item -faggressive-function-elimination
1935627f7eb2Smrg@opindex @code{faggressive-function-elimination}
1936627f7eb2Smrg@cindex Elimination of functions with identical argument lists
1937627f7eb2SmrgFunctions with identical argument lists are eliminated within
1938627f7eb2Smrgstatements, regardless of whether these functions are marked
1939627f7eb2Smrg@code{PURE} or not. For example, in
1940627f7eb2Smrg@smallexample
1941627f7eb2Smrg  a = f(b,c) + f(b,c)
1942627f7eb2Smrg@end smallexample
1943627f7eb2Smrgthere will only be a single call to @code{f}.  This option only works
1944627f7eb2Smrgif @option{-ffrontend-optimize} is in effect.
1945627f7eb2Smrg
1946627f7eb2Smrg@item -ffrontend-optimize
1947627f7eb2Smrg@opindex @code{frontend-optimize}
1948627f7eb2Smrg@cindex Front-end optimization
1949627f7eb2SmrgThis option performs front-end optimization, based on manipulating
1950627f7eb2Smrgparts the Fortran parse tree.  Enabled by default by any @option{-O} option
1951627f7eb2Smrgexcept @option{-O0} and @option{-Og}.  Optimizations enabled by this option
1952627f7eb2Smrginclude:
1953627f7eb2Smrg@itemize @bullet
1954627f7eb2Smrg@item inlining calls to @code{MATMUL},
1955627f7eb2Smrg@item elimination of identical function calls within expressions,
1956627f7eb2Smrg@item removing unnecessary calls to @code{TRIM} in comparisons and assignments,
1957627f7eb2Smrg@item replacing @code{TRIM(a)} with @code{a(1:LEN_TRIM(a))} and
1958627f7eb2Smrg@item short-circuiting of logical operators (@code{.AND.} and @code{.OR.}).
1959627f7eb2Smrg@end itemize
1960627f7eb2SmrgIt can be deselected by specifying @option{-fno-frontend-optimize}.
1961627f7eb2Smrg
1962627f7eb2Smrg@item -ffrontend-loop-interchange
1963627f7eb2Smrg@opindex @code{frontend-loop-interchange}
1964627f7eb2Smrg@cindex loop interchange, Fortran
1965627f7eb2SmrgAttempt to interchange loops in the Fortran front end where
1966627f7eb2Smrgprofitable.  Enabled by default by any @option{-O} option.
1967627f7eb2SmrgAt the moment, this option only affects @code{FORALL} and
1968627f7eb2Smrg@code{DO CONCURRENT} statements with several forall triplets.
1969627f7eb2Smrg@end table
1970627f7eb2Smrg
1971627f7eb2Smrg@xref{Code Gen Options,,Options for Code Generation Conventions,
1972627f7eb2Smrggcc,Using the GNU Compiler Collection (GCC)}, for information on more options
1973627f7eb2Smrgoffered by the GBE
1974627f7eb2Smrgshared by @command{gfortran}, @command{gcc}, and other GNU compilers.
1975627f7eb2Smrg
1976627f7eb2Smrg@c man end
1977627f7eb2Smrg
1978627f7eb2Smrg@node Interoperability Options
1979627f7eb2Smrg@section Options for interoperability with other languages
1980627f7eb2Smrg
1981627f7eb2Smrg@table @asis
1982627f7eb2Smrg
1983627f7eb2Smrg@item -fc-prototypes
1984627f7eb2Smrg@opindex @code{c-prototypes}
1985627f7eb2Smrg@cindex Generating C prototypes from Fortran BIND(C) enteties
1986627f7eb2SmrgThis option will generate C prototypes from @code{BIND(C)} variable
1987627f7eb2Smrgdeclarations, types and procedure interfaces and writes them to
1988627f7eb2Smrgstandard output.  @code{ENUM} is not yet supported.
1989627f7eb2Smrg
1990627f7eb2SmrgThe generated prototypes may need inclusion of an appropriate header,
1991627f7eb2Smrgsuch as @code{<stdint.h>} or @code{<stdlib.h>}.  For types which are
1992627f7eb2Smrgnot specified using the appropriate kind from the @code{iso_c_binding}
1993627f7eb2Smrgmodule, a warning is added as a comment to the code.
1994627f7eb2Smrg
1995627f7eb2SmrgFor function pointers, a pointer to a function returning @code{int}
1996627f7eb2Smrgwithout an explicit argument list is generated.
1997627f7eb2Smrg
1998627f7eb2SmrgExample of use:
1999627f7eb2Smrg@smallexample
2000627f7eb2Smrg$ gfortran -fc-prototypes -fsyntax-only foo.f90 > foo.h
2001627f7eb2Smrg@end smallexample
2002627f7eb2Smrgwhere the C code intended for interoperating with the Fortran code
2003627f7eb2Smrgthen  uses @code{#include "foo.h"}.
2004627f7eb2Smrg
2005627f7eb2Smrg@item -fc-prototypes-external
2006627f7eb2Smrg@opindex @code{c-prototypes-external}
2007627f7eb2Smrg@cindex Generating C prototypes from external procedures
2008627f7eb2SmrgThis option will generate C prototypes from external functions and
2009627f7eb2Smrgsubroutines and write them to standard output.  This may be useful for
2010627f7eb2Smrgmaking sure that C bindings to Fortran code are correct.  This option
2011627f7eb2Smrgdoes not generate prototypes for @code{BIND(C)} procedures, use
2012627f7eb2Smrg@option{-fc-prototypes} for that.
2013627f7eb2Smrg
2014627f7eb2SmrgThe generated prototypes may need inclusion of an appropriate
2015627f7eb2Smrgheader, such as as @code{<stdint.h>} or @code{<stdlib.h>}.
2016627f7eb2Smrg
2017627f7eb2SmrgThis is primarily meant for legacy code to ensure that existing C
2018627f7eb2Smrgbindings match what @command{gfortran} emits.  The generated C
2019627f7eb2Smrgprototypes should be correct for the current version of the compiler,
2020627f7eb2Smrgbut may not match what other compilers or earlier versions of
2021627f7eb2Smrg@command{gfortran} need.  For new developments, use of the
2022627f7eb2Smrg@code{BIND(C)} features is recommended.
2023627f7eb2Smrg
2024627f7eb2SmrgExample of use:
2025627f7eb2Smrg@smallexample
2026627f7eb2Smrg$ gfortran -fc-prototypes-external -fsyntax-only foo.f > foo.h
2027627f7eb2Smrg@end smallexample
2028627f7eb2Smrgwhere the C code intended for interoperating with the Fortran code
2029627f7eb2Smrgthen  uses @code{#include "foo.h"}.
2030627f7eb2Smrg@end table
2031627f7eb2Smrg
2032627f7eb2Smrg@node Environment Variables
2033627f7eb2Smrg@section Environment variables affecting @command{gfortran}
2034627f7eb2Smrg@cindex environment variable
2035627f7eb2Smrg
2036627f7eb2Smrg@c man begin ENVIRONMENT
2037627f7eb2Smrg
2038627f7eb2SmrgThe @command{gfortran} compiler currently does not make use of any environment
2039627f7eb2Smrgvariables to control its operation above and beyond those
2040627f7eb2Smrgthat affect the operation of @command{gcc}.
2041627f7eb2Smrg
2042627f7eb2Smrg@xref{Environment Variables,,Environment Variables Affecting GCC,
2043627f7eb2Smrggcc,Using the GNU Compiler Collection (GCC)}, for information on environment
2044627f7eb2Smrgvariables.
2045627f7eb2Smrg
2046627f7eb2Smrg@xref{Runtime}, for environment variables that affect the
2047627f7eb2Smrgrun-time behavior of programs compiled with GNU Fortran.
2048627f7eb2Smrg@c man end
2049