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