1GFORTRAN(1) GNU GFORTRAN(1)
2
3
4
6 gfortran - GNU Fortran compiler
7
9 gfortran [-c|-S|-E]
10 [-g] [-pg] [-Olevel]
11 [-Wwarn...] [-pedantic]
12 [-Idir...] [-Ldir...]
13 [-Dmacro[=defn]...] [-Umacro]
14 [-foption...]
15 [-mmachine-option...]
16 [-o outfile] infile...
17
18 Only the most useful options are listed here; see below for the
19 remainder.
20
22 The gfortran command supports all the options supported by the gcc
23 command. Only options specific to GNU Fortran are documented here.
24
25 All GCC and GNU Fortran options are accepted both by gfortran and by
26 gcc (as well as any other drivers built at the same time, such as g++),
27 since adding GNU Fortran to the GCC distribution enables acceptance of
28 GNU Fortran options by all of the relevant drivers.
29
30 In some cases, options have positive and negative forms; the negative
31 form of -ffoo would be -fno-foo. This manual documents only one of
32 these two forms, whichever one is not the default.
33
35 Here is a summary of all the options specific to GNU Fortran, grouped
36 by type. Explanations are in the following sections.
37
38 Fortran Language Options
39 -fall-intrinsics -fbackslash -fcray-pointer -fd-lines-as-code
40 -fd-lines-as-comments -fdec -fdec-structure -fdec-intrinsic-ints
41 -fdec-static -fdec-math -fdec-include -fdefault-double-8
42 -fdefault-integer-8 -fdefault-real-8 -fdefault-real-10
43 -fdefault-real-16 -fdollar-ok -ffixed-line-length-n
44 -ffixed-line-length-none -fpad-source -ffree-form
45 -ffree-line-length-n -ffree-line-length-none -fimplicit-none
46 -finteger-4-integer-8 -fmax-identifier-length -fmodule-private
47 -ffixed-form -fno-range-check -fopenacc -fopenmp -freal-4-real-10
48 -freal-4-real-16 -freal-4-real-8 -freal-8-real-10 -freal-8-real-16
49 -freal-8-real-4 -std=std -ftest-forall-temp
50
51 Preprocessing Options
52 -A-question[=answer] -Aquestion=answer -C -CC -Dmacro[=defn] -H -P
53 -Umacro -cpp -dD -dI -dM -dN -dU -fworking-directory -imultilib dir
54 -iprefix file -iquote -isysroot dir -isystem dir -nocpp -nostdinc
55 -undef
56
57 Error and Warning Options
58 -Waliasing -Wall -Wampersand -Wargument-mismatch -Warray-bounds
59 -Wc-binding-type -Wcharacter-truncation -Wconversion -Wdo-subscript
60 -Wfunction-elimination -Wimplicit-interface -Wimplicit-procedure
61 -Wintrinsic-shadow -Wuse-without-only -Wintrinsics-std
62 -Wline-truncation -Wno-align-commons -Wno-tabs -Wreal-q-constant
63 -Wsurprising -Wunderflow -Wunused-parameter -Wrealloc-lhs
64 -Wrealloc-lhs-all -Wfrontend-loop-interchange -Wtarget-lifetime
65 -fmax-errors=n -fsyntax-only -pedantic -pedantic-errors
66
67 Debugging Options
68 -fbacktrace -fdump-fortran-optimized -fdump-fortran-original
69 -fdump-fortran-global -fdump-parse-tree -ffpe-trap=list
70 -ffpe-summary=list
71
72 Directory Options
73 -Idir -Jdir -fintrinsic-modules-path dir
74
75 Link Options
76 -static-libgfortran
77
78 Runtime Options
79 -fconvert=conversion -fmax-subrecord-length=length
80 -frecord-marker=length -fsign-zero
81
82 Interoperability Options
83 -fc-prototypes -fc-prototypes-external
84
85 Code Generation Options
86 -faggressive-function-elimination -fblas-matmul-limit=n
87 -fbounds-check -ftail-call-workaround -ftail-call-workaround=n
88 -fcheck-array-temporaries
89 -fcheck=<all|array-temps|bounds|do|mem|pointer|recursion>
90 -fcoarray=<none|single|lib> -fexternal-blas -ff2c
91 -ffrontend-loop-interchange -ffrontend-optimize -finit-character=n
92 -finit-integer=n -finit-local-zero -finit-derived
93 -finit-logical=<true|false> -finit-real=<zero|inf|-inf|nan|snan>
94 -finline-matmul-limit=n -fmax-array-constructor=n
95 -fmax-stack-var-size=n -fno-align-commons -fno-automatic
96 -fno-protect-parens -fno-underscoring -fsecond-underscore
97 -fpack-derived -frealloc-lhs -frecursive -frepack-arrays
98 -fshort-enums -fstack-arrays
99
100 Options controlling Fortran dialect
101 The following options control the details of the Fortran dialect
102 accepted by the compiler:
103
104 -ffree-form
105 -ffixed-form
106 Specify the layout used by the source file. The free form layout
107 was introduced in Fortran 90. Fixed form was traditionally used in
108 older Fortran programs. When neither option is specified, the
109 source form is determined by the file extension.
110
111 -fall-intrinsics
112 This option causes all intrinsic procedures (including the GNU-
113 specific extensions) to be accepted. This can be useful with
114 -std=f95 to force standard-compliance but get access to the full
115 range of intrinsics available with gfortran. As a consequence,
116 -Wintrinsics-std will be ignored and no user-defined procedure with
117 the same name as any intrinsic will be called except when it is
118 explicitly declared "EXTERNAL".
119
120 -fd-lines-as-code
121 -fd-lines-as-comments
122 Enable special treatment for lines beginning with "d" or "D" in
123 fixed form sources. If the -fd-lines-as-code option is given they
124 are treated as if the first column contained a blank. If the
125 -fd-lines-as-comments option is given, they are treated as comment
126 lines.
127
128 -fdec
129 DEC compatibility mode. Enables extensions and other features that
130 mimic the default behavior of older compilers (such as DEC). These
131 features are non-standard and should be avoided at all costs. For
132 details on GNU Fortran's implementation of these extensions see the
133 full documentation.
134
135 Other flags enabled by this switch are: -fdollar-ok -fcray-pointer
136 -fdec-structure -fdec-intrinsic-ints -fdec-static -fdec-math
137
138 If -fd-lines-as-code/-fd-lines-as-comments are unset, then -fdec
139 also sets -fd-lines-as-comments.
140
141 -fdec-structure
142 Enable DEC "STRUCTURE" and "RECORD" as well as "UNION", "MAP", and
143 dot ('.') as a member separator (in addition to '%'). This is
144 provided for compatibility only; Fortran 90 derived types should be
145 used instead where possible.
146
147 -fdec-intrinsic-ints
148 Enable B/I/J/K kind variants of existing integer functions (e.g.
149 BIAND, IIAND, JIAND, etc...). For a complete list of intrinsics see
150 the full documentation.
151
152 -fdec-math
153 Enable legacy math intrinsics such as COTAN and degree-valued
154 trigonometric functions (e.g. TAND, ATAND, etc...) for
155 compatability with older code.
156
157 -fdec-static
158 Enable DEC-style STATIC and AUTOMATIC attributes to explicitly
159 specify the storage of variables and other objects.
160
161 -fdec-include
162 Enable parsing of INCLUDE as a statement in addition to parsing it
163 as INCLUDE line. When parsed as INCLUDE statement, INCLUDE does
164 not have to be on a single line and can use line continuations.
165
166 -fdollar-ok
167 Allow $ as a valid non-first character in a symbol name. Symbols
168 that start with $ are rejected since it is unclear which rules to
169 apply to implicit typing as different vendors implement different
170 rules. Using $ in "IMPLICIT" statements is also rejected.
171
172 -fbackslash
173 Change the interpretation of backslashes in string literals from a
174 single backslash character to "C-style" escape characters. The
175 following combinations are expanded "\a", "\b", "\f", "\n", "\r",
176 "\t", "\v", "\\", and "\0" to the ASCII characters alert,
177 backspace, form feed, newline, carriage return, horizontal tab,
178 vertical tab, backslash, and NUL, respectively. Additionally,
179 "\x"nn, "\u"nnnn and "\U"nnnnnnnn (where each n is a hexadecimal
180 digit) are translated into the Unicode characters corresponding to
181 the specified code points. All other combinations of a character
182 preceded by \ are unexpanded.
183
184 -fmodule-private
185 Set the default accessibility of module entities to "PRIVATE".
186 Use-associated entities will not be accessible unless they are
187 explicitly declared as "PUBLIC".
188
189 -ffixed-line-length-n
190 Set column after which characters are ignored in typical fixed-form
191 lines in the source file, and, unless "-fno-pad-source", through
192 which spaces are assumed (as if padded to that length) after the
193 ends of short fixed-form lines.
194
195 Popular values for n include 72 (the standard and the default), 80
196 (card image), and 132 (corresponding to "extended-source" options
197 in some popular compilers). n may also be none, meaning that the
198 entire line is meaningful and that continued character constants
199 never have implicit spaces appended to them to fill out the line.
200 -ffixed-line-length-0 means the same thing as
201 -ffixed-line-length-none.
202
203 -fno-pad-source
204 By default fixed-form lines have spaces assumed (as if padded to
205 that length) after the ends of short fixed-form lines. This is not
206 done either if -ffixed-line-length-0, -ffixed-line-length-none or
207 if -fno-pad-source option is used. With any of those options
208 continued character constants never have implicit spaces appended
209 to them to fill out the line.
210
211 -ffree-line-length-n
212 Set column after which characters are ignored in typical free-form
213 lines in the source file. The default value is 132. n may be none,
214 meaning that the entire line is meaningful. -ffree-line-length-0
215 means the same thing as -ffree-line-length-none.
216
217 -fmax-identifier-length=n
218 Specify the maximum allowed identifier length. Typical values are
219 31 (Fortran 95) and 63 (Fortran 2003 and Fortran 2008).
220
221 -fimplicit-none
222 Specify that no implicit typing is allowed, unless overridden by
223 explicit "IMPLICIT" statements. This is the equivalent of adding
224 "implicit none" to the start of every procedure.
225
226 -fcray-pointer
227 Enable the Cray pointer extension, which provides C-like pointer
228 functionality.
229
230 -fopenacc
231 Enable the OpenACC extensions. This includes OpenACC "!$acc"
232 directives in free form and "c$acc", *$acc and "!$acc" directives
233 in fixed form, "!$" conditional compilation sentinels in free form
234 and "c$", "*$" and "!$" sentinels in fixed form, and when linking
235 arranges for the OpenACC runtime library to be linked in.
236
237 Note that this is an experimental feature, incomplete, and subject
238 to change in future versions of GCC. See
239 <https://gcc.gnu.org/wiki/OpenACC> for more information.
240
241 -fopenmp
242 Enable the OpenMP extensions. This includes OpenMP "!$omp"
243 directives in free form and "c$omp", *$omp and "!$omp" directives
244 in fixed form, "!$" conditional compilation sentinels in free form
245 and "c$", "*$" and "!$" sentinels in fixed form, and when linking
246 arranges for the OpenMP runtime library to be linked in. The
247 option -fopenmp implies -frecursive.
248
249 -fno-range-check
250 Disable range checking on results of simplification of constant
251 expressions during compilation. For example, GNU Fortran will give
252 an error at compile time when simplifying "a = 1. / 0". With this
253 option, no error will be given and "a" will be assigned the value
254 "+Infinity". If an expression evaluates to a value outside of the
255 relevant range of ["-HUGE()":"HUGE()"], then the expression will be
256 replaced by "-Inf" or "+Inf" as appropriate. Similarly, "DATA
257 i/Z'FFFFFFFF'/" will result in an integer overflow on most systems,
258 but with -fno-range-check the value will "wrap around" and "i" will
259 be initialized to -1 instead.
260
261 -fdefault-integer-8
262 Set the default integer and logical types to an 8 byte wide type.
263 This option also affects the kind of integer constants like 42.
264 Unlike -finteger-4-integer-8, it does not promote variables with
265 explicit kind declaration.
266
267 -fdefault-real-8
268 Set the default real type to an 8 byte wide type. This option also
269 affects the kind of non-double real constants like 1.0. This
270 option promotes the default width of "DOUBLE PRECISION" and double
271 real constants like "1.d0" to 16 bytes if possible. If
272 "-fdefault-double-8" is given along with "fdefault-real-8", "DOUBLE
273 PRECISION" and double real constants are not promoted. Unlike
274 -freal-4-real-8, "fdefault-real-8" does not promote variables with
275 explicit kind declarations.
276
277 -fdefault-real-10
278 Set the default real type to an 10 byte wide type. This option
279 also affects the kind of non-double real constants like 1.0. This
280 option promotes the default width of "DOUBLE PRECISION" and double
281 real constants like "1.d0" to 16 bytes if possible. If
282 "-fdefault-double-8" is given along with "fdefault-real-10",
283 "DOUBLE PRECISION" and double real constants are not promoted.
284 Unlike -freal-4-real-10, "fdefault-real-10" does not promote
285 variables with explicit kind declarations.
286
287 -fdefault-real-16
288 Set the default real type to an 16 byte wide type. This option
289 also affects the kind of non-double real constants like 1.0. This
290 option promotes the default width of "DOUBLE PRECISION" and double
291 real constants like "1.d0" to 16 bytes if possible. If
292 "-fdefault-double-8" is given along with "fdefault-real-16",
293 "DOUBLE PRECISION" and double real constants are not promoted.
294 Unlike -freal-4-real-16, "fdefault-real-16" does not promote
295 variables with explicit kind declarations.
296
297 -fdefault-double-8
298 Set the "DOUBLE PRECISION" type and double real constants like
299 "1.d0" to an 8 byte wide type. Do nothing if this is already the
300 default. This option prevents -fdefault-real-8, -fdefault-real-10,
301 and -fdefault-real-16, from promoting "DOUBLE PRECISION" and double
302 real constants like "1.d0" to 16 bytes.
303
304 -finteger-4-integer-8
305 Promote all "INTEGER(KIND=4)" entities to an "INTEGER(KIND=8)"
306 entities. If "KIND=8" is unavailable, then an error will be
307 issued. This option should be used with care and may not be
308 suitable for your codes. Areas of possible concern include calls
309 to external procedures, alignment in "EQUIVALENCE" and/or "COMMON",
310 generic interfaces, BOZ literal constant conversion, and I/O.
311 Inspection of the intermediate representation of the translated
312 Fortran code, produced by -fdump-tree-original, is suggested.
313
314 -freal-4-real-8
315 -freal-4-real-10
316 -freal-4-real-16
317 -freal-8-real-4
318 -freal-8-real-10
319 -freal-8-real-16
320 Promote all "REAL(KIND=M)" entities to "REAL(KIND=N)" entities. If
321 "REAL(KIND=N)" is unavailable, then an error will be issued. All
322 other real kind types are unaffected by this option. These options
323 should be used with care and may not be suitable for your codes.
324 Areas of possible concern include calls to external procedures,
325 alignment in "EQUIVALENCE" and/or "COMMON", generic interfaces, BOZ
326 literal constant conversion, and I/O. Inspection of the
327 intermediate representation of the translated Fortran code,
328 produced by -fdump-tree-original, is suggested.
329
330 -std=std
331 Specify the standard to which the program is expected to conform,
332 which may be one of f95, f2003, f2008, f2018, gnu, or legacy. The
333 default value for std is gnu, which specifies a superset of the
334 latest Fortran standard that includes all of the extensions
335 supported by GNU Fortran, although warnings will be given for
336 obsolete extensions not recommended for use in new code. The
337 legacy value is equivalent but without the warnings for obsolete
338 extensions, and may be useful for old non-standard programs. The
339 f95, f2003, f2008, and f2018 values specify strict conformance to
340 the Fortran 95, Fortran 2003, Fortran 2008 and Fortran 2018
341 standards, respectively; errors are given for all extensions beyond
342 the relevant language standard, and warnings are given for the
343 Fortran 77 features that are permitted but obsolescent in later
344 standards. The deprecated option -std=f2008ts acts as an alias for
345 -std=f2018. It is only present for backwards compatibility with
346 earlier gfortran versions and should not be used any more.
347
348 -ftest-forall-temp
349 Enhance test coverage by forcing most forall assignments to use
350 temporary.
351
352 Enable and customize preprocessing
353 Preprocessor related options. See section Preprocessing and conditional
354 compilation for more detailed information on preprocessing in gfortran.
355
356 -cpp
357 -nocpp
358 Enable preprocessing. The preprocessor is automatically invoked if
359 the file extension is .fpp, .FPP, .F, .FOR, .FTN, .F90, .F95, .F03
360 or .F08. Use this option to manually enable preprocessing of any
361 kind of Fortran file.
362
363 To disable preprocessing of files with any of the above listed
364 extensions, use the negative form: -nocpp.
365
366 The preprocessor is run in traditional mode. Any restrictions of
367 the file-format, especially the limits on line length, apply for
368 preprocessed output as well, so it might be advisable to use the
369 -ffree-line-length-none or -ffixed-line-length-none options.
370
371 -dM Instead of the normal output, generate a list of '#define'
372 directives for all the macros defined during the execution of the
373 preprocessor, including predefined macros. This gives you a way of
374 finding out what is predefined in your version of the preprocessor.
375 Assuming you have no file foo.f90, the command
376
377 touch foo.f90; gfortran -cpp -E -dM foo.f90
378
379 will show all the predefined macros.
380
381 -dD Like -dM except in two respects: it does not include the predefined
382 macros, and it outputs both the "#define" directives and the result
383 of preprocessing. Both kinds of output go to the standard output
384 file.
385
386 -dN Like -dD, but emit only the macro names, not their expansions.
387
388 -dU Like dD except that only macros that are expanded, or whose
389 definedness is tested in preprocessor directives, are output; the
390 output is delayed until the use or test of the macro; and '#undef'
391 directives are also output for macros tested but undefined at the
392 time.
393
394 -dI Output '#include' directives in addition to the result of
395 preprocessing.
396
397 -fworking-directory
398 Enable generation of linemarkers in the preprocessor output that
399 will let the compiler know the current working directory at the
400 time of preprocessing. When this option is enabled, the
401 preprocessor will emit, after the initial linemarker, a second
402 linemarker with the current working directory followed by two
403 slashes. GCC will use this directory, when it is present in the
404 preprocessed input, as the directory emitted as the current working
405 directory in some debugging information formats. This option is
406 implicitly enabled if debugging information is enabled, but this
407 can be inhibited with the negated form -fno-working-directory. If
408 the -P flag is present in the command line, this option has no
409 effect, since no "#line" directives are emitted whatsoever.
410
411 -idirafter dir
412 Search dir for include files, but do it after all directories
413 specified with -I and the standard system directories have been
414 exhausted. dir is treated as a system include directory. If dir
415 begins with "=", then the "=" will be replaced by the sysroot
416 prefix; see --sysroot and -isysroot.
417
418 -imultilib dir
419 Use dir as a subdirectory of the directory containing target-
420 specific C++ headers.
421
422 -iprefix prefix
423 Specify prefix as the prefix for subsequent -iwithprefix options.
424 If the prefix represents a directory, you should include the final
425 '/'.
426
427 -isysroot dir
428 This option is like the --sysroot option, but applies only to
429 header files. See the --sysroot option for more information.
430
431 -iquote dir
432 Search dir only for header files requested with "#include "file"";
433 they are not searched for "#include <file>", before all directories
434 specified by -I and before the standard system directories. If dir
435 begins with "=", then the "=" will be replaced by the sysroot
436 prefix; see --sysroot and -isysroot.
437
438 -isystem dir
439 Search dir for header files, after all directories specified by -I
440 but before the standard system directories. Mark it as a system
441 directory, so that it gets the same special treatment as is applied
442 to the standard system directories. If dir begins with "=", then
443 the "=" will be replaced by the sysroot prefix; see --sysroot and
444 -isysroot.
445
446 -nostdinc
447 Do not search the standard system directories for header files.
448 Only the directories you have specified with -I options (and the
449 directory of the current file, if appropriate) are searched.
450
451 -undef
452 Do not predefine any system-specific or GCC-specific macros. The
453 standard predefined macros remain defined.
454
455 -Apredicate=answer
456 Make an assertion with the predicate predicate and answer answer.
457 This form is preferred to the older form -A predicate(answer),
458 which is still supported, because it does not use shell special
459 characters.
460
461 -A-predicate=answer
462 Cancel an assertion with the predicate predicate and answer answer.
463
464 -C Do not discard comments. All comments are passed through to the
465 output file, except for comments in processed directives, which are
466 deleted along with the directive.
467
468 You should be prepared for side effects when using -C; it causes
469 the preprocessor to treat comments as tokens in their own right.
470 For example, comments appearing at the start of what would be a
471 directive line have the effect of turning that line into an
472 ordinary source line, since the first token on the line is no
473 longer a '#'.
474
475 Warning: this currently handles C-Style comments only. The
476 preprocessor does not yet recognize Fortran-style comments.
477
478 -CC Do not discard comments, including during macro expansion. This is
479 like -C, except that comments contained within macros are also
480 passed through to the output file where the macro is expanded.
481
482 In addition to the side-effects of the -C option, the -CC option
483 causes all C++-style comments inside a macro to be converted to
484 C-style comments. This is to prevent later use of that macro from
485 inadvertently commenting out the remainder of the source line. The
486 -CC option is generally used to support lint comments.
487
488 Warning: this currently handles C- and C++-Style comments only. The
489 preprocessor does not yet recognize Fortran-style comments.
490
491 -Dname
492 Predefine name as a macro, with definition 1.
493
494 -Dname=definition
495 The contents of definition are tokenized and processed as if they
496 appeared during translation phase three in a '#define' directive.
497 In particular, the definition will be truncated by embedded newline
498 characters.
499
500 If you are invoking the preprocessor from a shell or shell-like
501 program you may need to use the shell's quoting syntax to protect
502 characters such as spaces that have a meaning in the shell syntax.
503
504 If you wish to define a function-like macro on the command line,
505 write its argument list with surrounding parentheses before the
506 equals sign (if any). Parentheses are meaningful to most shells, so
507 you will need to quote the option. With sh and csh,
508 "-D'name(args...)=definition'" works.
509
510 -D and -U options are processed in the order they are given on the
511 command line. All -imacros file and -include file options are
512 processed after all -D and -U options.
513
514 -H Print the name of each header file used, in addition to other
515 normal activities. Each name is indented to show how deep in the
516 '#include' stack it is.
517
518 -P Inhibit generation of linemarkers in the output from the
519 preprocessor. This might be useful when running the preprocessor
520 on something that is not C code, and will be sent to a program
521 which might be confused by the linemarkers.
522
523 -Uname
524 Cancel any previous definition of name, either built in or provided
525 with a -D option.
526
527 Options to request or suppress errors and warnings
528 Errors are diagnostic messages that report that the GNU Fortran
529 compiler cannot compile the relevant piece of source code. The
530 compiler will continue to process the program in an attempt to report
531 further errors to aid in debugging, but will not produce any compiled
532 output.
533
534 Warnings are diagnostic messages that report constructions which are
535 not inherently erroneous but which are risky or suggest there is likely
536 to be a bug in the program. Unless -Werror is specified, they do not
537 prevent compilation of the program.
538
539 You can request many specific warnings with options beginning -W, for
540 example -Wimplicit to request warnings on implicit declarations. Each
541 of these specific warning options also has a negative form beginning
542 -Wno- to turn off warnings; for example, -Wno-implicit. This manual
543 lists only one of the two forms, whichever is not the default.
544
545 These options control the amount and kinds of errors and warnings
546 produced by GNU Fortran:
547
548 -fmax-errors=n
549 Limits the maximum number of error messages to n, at which point
550 GNU Fortran bails out rather than attempting to continue processing
551 the source code. If n is 0, there is no limit on the number of
552 error messages produced.
553
554 -fsyntax-only
555 Check the code for syntax errors, but do not actually compile it.
556 This will generate module files for each module present in the
557 code, but no other output file.
558
559 -Wpedantic
560 -pedantic
561 Issue warnings for uses of extensions to Fortran. -pedantic also
562 applies to C-language constructs where they occur in GNU Fortran
563 source files, such as use of \e in a character constant within a
564 directive like "#include".
565
566 Valid Fortran programs should compile properly with or without this
567 option. However, without this option, certain GNU extensions and
568 traditional Fortran features are supported as well. With this
569 option, many of them are rejected.
570
571 Some users try to use -pedantic to check programs for conformance.
572 They soon find that it does not do quite what they want---it finds
573 some nonstandard practices, but not all. However, improvements to
574 GNU Fortran in this area are welcome.
575
576 This should be used in conjunction with -std=f95, -std=f2003,
577 -std=f2008 or -std=f2018.
578
579 -pedantic-errors
580 Like -pedantic, except that errors are produced rather than
581 warnings.
582
583 -Wall
584 Enables commonly used warning options pertaining to usage that we
585 recommend avoiding and that we believe are easy to avoid. This
586 currently includes -Waliasing, -Wampersand, -Wconversion,
587 -Wsurprising, -Wc-binding-type, -Wintrinsics-std, -Wtabs,
588 -Wintrinsic-shadow, -Wline-truncation, -Wtarget-lifetime,
589 -Winteger-division, -Wreal-q-constant, -Wunused and
590 -Wundefined-do-loop.
591
592 -Waliasing
593 Warn about possible aliasing of dummy arguments. Specifically, it
594 warns if the same actual argument is associated with a dummy
595 argument with "INTENT(IN)" and a dummy argument with "INTENT(OUT)"
596 in a call with an explicit interface.
597
598 The following example will trigger the warning.
599
600 interface
601 subroutine bar(a,b)
602 integer, intent(in) :: a
603 integer, intent(out) :: b
604 end subroutine
605 end interface
606 integer :: a
607
608 call bar(a,a)
609
610 -Wampersand
611 Warn about missing ampersand in continued character constants. The
612 warning is given with -Wampersand, -pedantic, -std=f95, -std=f2003,
613 -std=f2008 and -std=f2018. Note: With no ampersand given in a
614 continued character constant, GNU Fortran assumes continuation at
615 the first non-comment, non-whitespace character after the ampersand
616 that initiated the continuation.
617
618 -Wargument-mismatch
619 Warn about type, rank, and other mismatches between formal
620 parameters and actual arguments to functions and subroutines.
621 These warnings are recommended and thus enabled by default.
622
623 -Warray-temporaries
624 Warn about array temporaries generated by the compiler. The
625 information generated by this warning is sometimes useful in
626 optimization, in order to avoid such temporaries.
627
628 -Wc-binding-type
629 Warn if the a variable might not be C interoperable. In
630 particular, warn if the variable has been declared using an
631 intrinsic type with default kind instead of using a kind parameter
632 defined for C interoperability in the intrinsic "ISO_C_Binding"
633 module. This option is implied by -Wall.
634
635 -Wcharacter-truncation
636 Warn when a character assignment will truncate the assigned string.
637
638 -Wline-truncation
639 Warn when a source code line will be truncated. This option is
640 implied by -Wall. For free-form source code, the default is
641 -Werror=line-truncation such that truncations are reported as
642 error.
643
644 -Wconversion
645 Warn about implicit conversions that are likely to change the value
646 of the expression after conversion. Implied by -Wall.
647
648 -Wconversion-extra
649 Warn about implicit conversions between different types and kinds.
650 This option does not imply -Wconversion.
651
652 -Wextra
653 Enables some warning options for usages of language features which
654 may be problematic. This currently includes -Wcompare-reals,
655 -Wunused-parameter and -Wdo-subscript.
656
657 -Wfrontend-loop-interchange
658 Enable warning for loop interchanges performed by the
659 -ffrontend-loop-interchange option.
660
661 -Wimplicit-interface
662 Warn if a procedure is called without an explicit interface. Note
663 this only checks that an explicit interface is present. It does
664 not check that the declared interfaces are consistent across
665 program units.
666
667 -Wimplicit-procedure
668 Warn if a procedure is called that has neither an explicit
669 interface nor has been declared as "EXTERNAL".
670
671 -Winteger-division
672 Warn if a constant integer division truncates it result. As an
673 example, 3/5 evaluates to 0.
674
675 -Wintrinsics-std
676 Warn if gfortran finds a procedure named like an intrinsic not
677 available in the currently selected standard (with -std) and treats
678 it as "EXTERNAL" procedure because of this. -fall-intrinsics can
679 be used to never trigger this behavior and always link to the
680 intrinsic regardless of the selected standard.
681
682 -Wreal-q-constant
683 Produce a warning if a real-literal-constant contains a "q"
684 exponent-letter.
685
686 -Wsurprising
687 Produce a warning when "suspicious" code constructs are
688 encountered. While technically legal these usually indicate that
689 an error has been made.
690
691 This currently produces a warning under the following
692 circumstances:
693
694 * An INTEGER SELECT construct has a CASE that can never be
695 matched as its lower value is greater than its upper value.
696
697 * A LOGICAL SELECT construct has three CASE statements.
698
699 * A TRANSFER specifies a source that is shorter than the
700 destination.
701
702 * The type of a function result is declared more than once with
703 the same type. If -pedantic or standard-conforming mode is
704 enabled, this is an error.
705
706 * A "CHARACTER" variable is declared with negative length.
707
708 -Wtabs
709 By default, tabs are accepted as whitespace, but tabs are not
710 members of the Fortran Character Set. For continuation lines, a
711 tab followed by a digit between 1 and 9 is supported. -Wtabs will
712 cause a warning to be issued if a tab is encountered. Note, -Wtabs
713 is active for -pedantic, -std=f95, -std=f2003, -std=f2008,
714 -std=f2018 and -Wall.
715
716 -Wundefined-do-loop
717 Warn if a DO loop with step either 1 or -1 yields an underflow or
718 an overflow during iteration of an induction variable of the loop.
719 This option is implied by -Wall.
720
721 -Wunderflow
722 Produce a warning when numerical constant expressions are
723 encountered, which yield an UNDERFLOW during compilation. Enabled
724 by default.
725
726 -Wintrinsic-shadow
727 Warn if a user-defined procedure or module procedure has the same
728 name as an intrinsic; in this case, an explicit interface or
729 "EXTERNAL" or "INTRINSIC" declaration might be needed to get calls
730 later resolved to the desired intrinsic/procedure. This option is
731 implied by -Wall.
732
733 -Wuse-without-only
734 Warn if a "USE" statement has no "ONLY" qualifier and thus
735 implicitly imports all public entities of the used module.
736
737 -Wunused-dummy-argument
738 Warn about unused dummy arguments. This option is implied by -Wall.
739
740 -Wunused-parameter
741 Contrary to gcc's meaning of -Wunused-parameter, gfortran's
742 implementation of this option does not warn about unused dummy
743 arguments (see -Wunused-dummy-argument), but about unused
744 "PARAMETER" values. -Wunused-parameter is implied by -Wextra if
745 also -Wunused or -Wall is used.
746
747 -Walign-commons
748 By default, gfortran warns about any occasion of variables being
749 padded for proper alignment inside a "COMMON" block. This warning
750 can be turned off via -Wno-align-commons. See also -falign-commons.
751
752 -Wfunction-elimination
753 Warn if any calls to impure functions are eliminated by the
754 optimizations enabled by the -ffrontend-optimize option. This
755 option is implied by -Wextra.
756
757 -Wrealloc-lhs
758 Warn when the compiler might insert code to for allocation or
759 reallocation of an allocatable array variable of intrinsic type in
760 intrinsic assignments. In hot loops, the Fortran 2003 reallocation
761 feature may reduce the performance. If the array is already
762 allocated with the correct shape, consider using a whole-array
763 array-spec (e.g. "(:,:,:)") for the variable on the left-hand side
764 to prevent the reallocation check. Note that in some cases the
765 warning is shown, even if the compiler will optimize reallocation
766 checks away. For instance, when the right-hand side contains the
767 same variable multiplied by a scalar. See also -frealloc-lhs.
768
769 -Wrealloc-lhs-all
770 Warn when the compiler inserts code to for allocation or
771 reallocation of an allocatable variable; this includes scalars and
772 derived types.
773
774 -Wcompare-reals
775 Warn when comparing real or complex types for equality or
776 inequality. This option is implied by -Wextra.
777
778 -Wtarget-lifetime
779 Warn if the pointer in a pointer assignment might be longer than
780 the its target. This option is implied by -Wall.
781
782 -Wzerotrip
783 Warn if a "DO" loop is known to execute zero times at compile time.
784 This option is implied by -Wall.
785
786 -Wdo-subscript
787 Warn if an array subscript inside a DO loop could lead to an out-
788 of-bounds access even if the compiler cannot prove that the
789 statement is actually executed, in cases like
790
791 real a(3)
792 do i=1,4
793 if (condition(i)) then
794 a(i) = 1.2
795 end if
796 end do
797
798 This option is implied by -Wextra.
799
800 -Werror
801 Turns all warnings into errors.
802
803 Some of these have no effect when compiling programs written in
804 Fortran.
805
806 Options for debugging your program or GNU Fortran
807 GNU Fortran has various special options that are used for debugging
808 either your program or the GNU Fortran compiler.
809
810 -fdump-fortran-original
811 Output the internal parse tree after translating the source program
812 into internal representation. This option is mostly useful for
813 debugging the GNU Fortran compiler itself. The output generated by
814 this option might change between releases. This option may also
815 generate internal compiler errors for features which have only
816 recently been added.
817
818 -fdump-fortran-optimized
819 Output the parse tree after front-end optimization. Mostly useful
820 for debugging the GNU Fortran compiler itself. The output generated
821 by this option might change between releases. This option may also
822 generate internal compiler errors for features which have only
823 recently been added.
824
825 -fdump-parse-tree
826 Output the internal parse tree after translating the source program
827 into internal representation. Mostly useful for debugging the GNU
828 Fortran compiler itself. The output generated by this option might
829 change between releases. This option may also generate internal
830 compiler errors for features which have only recently been added.
831 This option is deprecated; use "-fdump-fortran-original" instead.
832
833 -fdump-fortran-global
834 Output a list of the global identifiers after translating into
835 middle-end representation. Mostly useful for debugging the GNU
836 Fortran compiler itself. The output generated by this option might
837 change between releases. This option may also generate internal
838 compiler errors for features which have only recently been added.
839
840 -ffpe-trap=list
841 Specify a list of floating point exception traps to enable. On
842 most systems, if a floating point exception occurs and the trap for
843 that exception is enabled, a SIGFPE signal will be sent and the
844 program being aborted, producing a core file useful for debugging.
845 list is a (possibly empty) comma-separated list of the following
846 exceptions: invalid (invalid floating point operation, such as
847 "SQRT(-1.0)"), zero (division by zero), overflow (overflow in a
848 floating point operation), underflow (underflow in a floating point
849 operation), inexact (loss of precision during operation), and
850 denormal (operation performed on a denormal value). The first five
851 exceptions correspond to the five IEEE 754 exceptions, whereas the
852 last one (denormal) is not part of the IEEE 754 standard but is
853 available on some common architectures such as x86.
854
855 The first three exceptions (invalid, zero, and overflow) often
856 indicate serious errors, and unless the program has provisions for
857 dealing with these exceptions, enabling traps for these three
858 exceptions is probably a good idea.
859
860 If the option is used more than once in the command line, the lists
861 will be joined: '"ffpe-trap="list1 "ffpe-trap="list2' is equivalent
862 to "ffpe-trap="list1,list2.
863
864 Note that once enabled an exception cannot be disabled (no negative
865 form).
866
867 Many, if not most, floating point operations incur loss of
868 precision due to rounding, and hence the "ffpe-trap=inexact" is
869 likely to be uninteresting in practice.
870
871 By default no exception traps are enabled.
872
873 -ffpe-summary=list
874 Specify a list of floating-point exceptions, whose flag status is
875 printed to "ERROR_UNIT" when invoking "STOP" and "ERROR STOP".
876 list can be either none, all or a comma-separated list of the
877 following exceptions: invalid, zero, overflow, underflow, inexact
878 and denormal. (See -ffpe-trap for a description of the exceptions.)
879
880 If the option is used more than once in the command line, only the
881 last one will be used.
882
883 By default, a summary for all exceptions but inexact is shown.
884
885 -fno-backtrace
886 When a serious runtime error is encountered or a deadly signal is
887 emitted (segmentation fault, illegal instruction, bus error,
888 floating-point exception, and the other POSIX signals that have the
889 action core), the Fortran runtime library tries to output a
890 backtrace of the error. "-fno-backtrace" disables the backtrace
891 generation. This option only has influence for compilation of the
892 Fortran main program.
893
894 Options for directory search
895 These options affect how GNU Fortran searches for files specified by
896 the "INCLUDE" directive and where it searches for previously compiled
897 modules.
898
899 It also affects the search paths used by cpp when used to preprocess
900 Fortran source.
901
902 -Idir
903 These affect interpretation of the "INCLUDE" directive (as well as
904 of the "#include" directive of the cpp preprocessor).
905
906 Also note that the general behavior of -I and "INCLUDE" is pretty
907 much the same as of -I with "#include" in the cpp preprocessor,
908 with regard to looking for header.gcc files and other such things.
909
910 This path is also used to search for .mod files when previously
911 compiled modules are required by a "USE" statement.
912
913 -Jdir
914 This option specifies where to put .mod files for compiled modules.
915 It is also added to the list of directories to searched by an "USE"
916 statement.
917
918 The default is the current directory.
919
920 -fintrinsic-modules-path dir
921 This option specifies the location of pre-compiled intrinsic
922 modules, if they are not in the default location expected by the
923 compiler.
924
925 Influencing the linking step
926 These options come into play when the compiler links object files into
927 an executable output file. They are meaningless if the compiler is not
928 doing a link step.
929
930 -static-libgfortran
931 On systems that provide libgfortran as a shared and a static
932 library, this option forces the use of the static version. If no
933 shared version of libgfortran was built when the compiler was
934 configured, this option has no effect.
935
936 Influencing runtime behavior
937 These options affect the runtime behavior of programs compiled with GNU
938 Fortran.
939
940 -fconvert=conversion
941 Specify the representation of data for unformatted files. Valid
942 values for conversion are: native, the default; swap, swap between
943 big- and little-endian; big-endian, use big-endian representation
944 for unformatted files; little-endian, use little-endian
945 representation for unformatted files.
946
947 This option has an effect only when used in the main program. The
948 "CONVERT" specifier and the GFORTRAN_CONVERT_UNIT environment
949 variable override the default specified by -fconvert.
950
951 -frecord-marker=length
952 Specify the length of record markers for unformatted files. Valid
953 values for length are 4 and 8. Default is 4. This is different
954 from previous versions of gfortran, which specified a default
955 record marker length of 8 on most systems. If you want to read or
956 write files compatible with earlier versions of gfortran, use
957 -frecord-marker=8.
958
959 -fmax-subrecord-length=length
960 Specify the maximum length for a subrecord. The maximum permitted
961 value for length is 2147483639, which is also the default. Only
962 really useful for use by the gfortran testsuite.
963
964 -fsign-zero
965 When enabled, floating point numbers of value zero with the sign
966 bit set are written as negative number in formatted output and
967 treated as negative in the "SIGN" intrinsic. -fno-sign-zero does
968 not print the negative sign of zero values (or values rounded to
969 zero for I/O) and regards zero as positive number in the "SIGN"
970 intrinsic for compatibility with Fortran 77. The default is
971 -fsign-zero.
972
973 Options for code generation conventions
974 These machine-independent options control the interface conventions
975 used in code generation.
976
977 Most of them have both positive and negative forms; the negative form
978 of -ffoo would be -fno-foo. In the table below, only one of the forms
979 is listed---the one which is not the default. You can figure out the
980 other form by either removing no- or adding it.
981
982 -fno-automatic
983 Treat each program unit (except those marked as RECURSIVE) as if
984 the "SAVE" statement were specified for every local variable and
985 array referenced in it. Does not affect common blocks. (Some
986 Fortran compilers provide this option under the name -static or
987 -save.) The default, which is -fautomatic, uses the stack for
988 local variables smaller than the value given by
989 -fmax-stack-var-size. Use the option -frecursive to use no static
990 memory.
991
992 Local variables or arrays having an explicit "SAVE" attribute are
993 silently ignored unless the -pedantic option is added.
994
995 -ff2c
996 Generate code designed to be compatible with code generated by g77
997 and f2c.
998
999 The calling conventions used by g77 (originally implemented in f2c)
1000 require functions that return type default "REAL" to actually
1001 return the C type "double", and functions that return type
1002 "COMPLEX" to return the values via an extra argument in the calling
1003 sequence that points to where to store the return value. Under the
1004 default GNU calling conventions, such functions simply return their
1005 results as they would in GNU C---default "REAL" functions return
1006 the C type "float", and "COMPLEX" functions return the GNU C type
1007 "complex". Additionally, this option implies the
1008 -fsecond-underscore option, unless -fno-second-underscore is
1009 explicitly requested.
1010
1011 This does not affect the generation of code that interfaces with
1012 the libgfortran library.
1013
1014 Caution: It is not a good idea to mix Fortran code compiled with
1015 -ff2c with code compiled with the default -fno-f2c calling
1016 conventions as, calling "COMPLEX" or default "REAL" functions
1017 between program parts which were compiled with different calling
1018 conventions will break at execution time.
1019
1020 Caution: This will break code which passes intrinsic functions of
1021 type default "REAL" or "COMPLEX" as actual arguments, as the
1022 library implementations use the -fno-f2c calling conventions.
1023
1024 -fno-underscoring
1025 Do not transform names of entities specified in the Fortran source
1026 file by appending underscores to them.
1027
1028 With -funderscoring in effect, GNU Fortran appends one underscore
1029 to external names with no underscores. This is done to ensure
1030 compatibility with code produced by many UNIX Fortran compilers.
1031
1032 Caution: The default behavior of GNU Fortran is incompatible with
1033 f2c and g77, please use the -ff2c option if you want object files
1034 compiled with GNU Fortran to be compatible with object code created
1035 with these tools.
1036
1037 Use of -fno-underscoring is not recommended unless you are
1038 experimenting with issues such as integration of GNU Fortran into
1039 existing system environments (vis-a-vis existing libraries, tools,
1040 and so on).
1041
1042 For example, with -funderscoring, and assuming that "j()" and
1043 "max_count()" are external functions while "my_var" and "lvar" are
1044 local variables, a statement like
1045
1046 I = J() + MAX_COUNT (MY_VAR, LVAR)
1047
1048 is implemented as something akin to:
1049
1050 i = j_() + max_count__(&my_var__, &lvar);
1051
1052 With -fno-underscoring, the same statement is implemented as:
1053
1054 i = j() + max_count(&my_var, &lvar);
1055
1056 Use of -fno-underscoring allows direct specification of user-
1057 defined names while debugging and when interfacing GNU Fortran code
1058 with other languages.
1059
1060 Note that just because the names match does not mean that the
1061 interface implemented by GNU Fortran for an external name matches
1062 the interface implemented by some other language for that same
1063 name. That is, getting code produced by GNU Fortran to link to
1064 code produced by some other compiler using this or any other method
1065 can be only a small part of the overall solution---getting the code
1066 generated by both compilers to agree on issues other than naming
1067 can require significant effort, and, unlike naming disagreements,
1068 linkers normally cannot detect disagreements in these other areas.
1069
1070 Also, note that with -fno-underscoring, the lack of appended
1071 underscores introduces the very real possibility that a user-
1072 defined external name will conflict with a name in a system
1073 library, which could make finding unresolved-reference bugs quite
1074 difficult in some cases---they might occur at program run time, and
1075 show up only as buggy behavior at run time.
1076
1077 In future versions of GNU Fortran we hope to improve naming and
1078 linking issues so that debugging always involves using the names as
1079 they appear in the source, even if the names as seen by the linker
1080 are mangled to prevent accidental linking between procedures with
1081 incompatible interfaces.
1082
1083 -fsecond-underscore
1084 By default, GNU Fortran appends an underscore to external names.
1085 If this option is used GNU Fortran appends two underscores to names
1086 with underscores and one underscore to external names with no
1087 underscores. GNU Fortran also appends two underscores to internal
1088 names with underscores to avoid naming collisions with external
1089 names.
1090
1091 This option has no effect if -fno-underscoring is in effect. It is
1092 implied by the -ff2c option.
1093
1094 Otherwise, with this option, an external name such as "MAX_COUNT"
1095 is implemented as a reference to the link-time external symbol
1096 "max_count__", instead of "max_count_". This is required for
1097 compatibility with g77 and f2c, and is implied by use of the -ff2c
1098 option.
1099
1100 -fcoarray=<keyword>
1101 none
1102 Disable coarray support; using coarray declarations and image-
1103 control statements will produce a compile-time error. (Default)
1104
1105 single
1106 Single-image mode, i.e. "num_images()" is always one.
1107
1108 lib Library-based coarray parallelization; a suitable GNU Fortran
1109 coarray library needs to be linked.
1110
1111 -fcheck=<keyword>
1112 Enable the generation of run-time checks; the argument shall be a
1113 comma-delimited list of the following keywords. Prefixing a check
1114 with no- disables it if it was activated by a previous
1115 specification.
1116
1117 all Enable all run-time test of -fcheck.
1118
1119 array-temps
1120 Warns at run time when for passing an actual argument a
1121 temporary array had to be generated. The information generated
1122 by this warning is sometimes useful in optimization, in order
1123 to avoid such temporaries.
1124
1125 Note: The warning is only printed once per location.
1126
1127 bounds
1128 Enable generation of run-time checks for array subscripts and
1129 against the declared minimum and maximum values. It also
1130 checks array indices for assumed and deferred shape arrays
1131 against the actual allocated bounds and ensures that all string
1132 lengths are equal for character array constructors without an
1133 explicit typespec.
1134
1135 Some checks require that -fcheck=bounds is set for the
1136 compilation of the main program.
1137
1138 Note: In the future this may also include other forms of
1139 checking, e.g., checking substring references.
1140
1141 do Enable generation of run-time checks for invalid modification
1142 of loop iteration variables.
1143
1144 mem Enable generation of run-time checks for memory allocation.
1145 Note: This option does not affect explicit allocations using
1146 the "ALLOCATE" statement, which will be always checked.
1147
1148 pointer
1149 Enable generation of run-time checks for pointers and
1150 allocatables.
1151
1152 recursion
1153 Enable generation of run-time checks for recursively called
1154 subroutines and functions which are not marked as recursive.
1155 See also -frecursive. Note: This check does not work for
1156 OpenMP programs and is disabled if used together with
1157 -frecursive and -fopenmp.
1158
1159 Example: Assuming you have a file foo.f90, the command
1160
1161 gfortran -fcheck=all,no-array-temps foo.f90
1162
1163 will compile the file with all checks enabled as specified above
1164 except warnings for generated array temporaries.
1165
1166 -fbounds-check
1167 Deprecated alias for -fcheck=bounds.
1168
1169 -ftail-call-workaround
1170 -ftail-call-workaround=n
1171 Some C interfaces to Fortran codes violate the gfortran ABI by
1172 omitting the hidden character length arguments as described in
1173 This can lead to crashes because pushing arguments for tail calls
1174 can overflow the stack.
1175
1176 To provide a workaround for existing binary packages, this option
1177 disables tail call optimization for gfortran procedures with
1178 character arguments. With -ftail-call-workaround=2 tail call
1179 optimization is disabled in all gfortran procedures with character
1180 arguments, with -ftail-call-workaround=1 or equivalent
1181 -ftail-call-workaround only in gfortran procedures with character
1182 arguments that call implicitly prototyped procedures.
1183
1184 Using this option can lead to problems including crashes due to
1185 insufficient stack space.
1186
1187 It is very strongly recommended to fix the code in question. The
1188 -fc-prototypes-external option can be used to generate prototypes
1189 which conform to gfortran's ABI, for inclusion in the source code.
1190
1191 Support for this option will likely be withdrawn in a future
1192 release of gfortran.
1193
1194 The negative form, -fno-tail-call-workaround or equivalent
1195 -ftail-call-workaround=0, can be used to disable this option.
1196
1197 Default is currently -ftail-call-workaround, this will change in
1198 future releases.
1199
1200 -fcheck-array-temporaries
1201 Deprecated alias for -fcheck=array-temps.
1202
1203 -fmax-array-constructor=n
1204 This option can be used to increase the upper limit permitted in
1205 array constructors. The code below requires this option to expand
1206 the array at compile time.
1207
1208 program test
1209 implicit none
1210 integer j
1211 integer, parameter :: n = 100000
1212 integer, parameter :: i(n) = (/ (2*j, j = 1, n) /)
1213 print '(10(I0,1X))', i
1214 end program test
1215
1216 Caution: This option can lead to long compile times and
1217 excessively large object files.
1218
1219 The default value for n is 65535.
1220
1221 -fmax-stack-var-size=n
1222 This option specifies the size in bytes of the largest array that
1223 will be put on the stack; if the size is exceeded static memory is
1224 used (except in procedures marked as RECURSIVE). Use the option
1225 -frecursive to allow for recursive procedures which do not have a
1226 RECURSIVE attribute or for parallel programs. Use -fno-automatic to
1227 never use the stack.
1228
1229 This option currently only affects local arrays declared with
1230 constant bounds, and may not apply to all character variables.
1231 Future versions of GNU Fortran may improve this behavior.
1232
1233 The default value for n is 32768.
1234
1235 -fstack-arrays
1236 Adding this option will make the Fortran compiler put all arrays of
1237 unknown size and array temporaries onto stack memory. If your
1238 program uses very large local arrays it is possible that you will
1239 have to extend your runtime limits for stack memory on some
1240 operating systems. This flag is enabled by default at optimization
1241 level -Ofast unless -fmax-stack-var-size is specified.
1242
1243 -fpack-derived
1244 This option tells GNU Fortran to pack derived type members as
1245 closely as possible. Code compiled with this option is likely to
1246 be incompatible with code compiled without this option, and may
1247 execute slower.
1248
1249 -frepack-arrays
1250 In some circumstances GNU Fortran may pass assumed shape array
1251 sections via a descriptor describing a noncontiguous area of
1252 memory. This option adds code to the function prologue to repack
1253 the data into a contiguous block at runtime.
1254
1255 This should result in faster accesses to the array. However it can
1256 introduce significant overhead to the function call, especially
1257 when the passed data is noncontiguous.
1258
1259 -fshort-enums
1260 This option is provided for interoperability with C code that was
1261 compiled with the -fshort-enums option. It will make GNU Fortran
1262 choose the smallest "INTEGER" kind a given enumerator set will fit
1263 in, and give all its enumerators this kind.
1264
1265 -fexternal-blas
1266 This option will make gfortran generate calls to BLAS functions for
1267 some matrix operations like "MATMUL", instead of using our own
1268 algorithms, if the size of the matrices involved is larger than a
1269 given limit (see -fblas-matmul-limit). This may be profitable if
1270 an optimized vendor BLAS library is available. The BLAS library
1271 will have to be specified at link time.
1272
1273 -fblas-matmul-limit=n
1274 Only significant when -fexternal-blas is in effect. Matrix
1275 multiplication of matrices with size larger than (or equal to) n
1276 will be performed by calls to BLAS functions, while others will be
1277 handled by gfortran internal algorithms. If the matrices involved
1278 are not square, the size comparison is performed using the
1279 geometric mean of the dimensions of the argument and result
1280 matrices.
1281
1282 The default value for n is 30.
1283
1284 -finline-matmul-limit=n
1285 When front-end optimiztion is active, some calls to the "MATMUL"
1286 intrinsic function will be inlined. This may result in code size
1287 increase if the size of the matrix cannot be determined at compile
1288 time, as code for both cases is generated. Setting
1289 "-finline-matmul-limit=0" will disable inlining in all cases.
1290 Setting this option with a value of n will produce inline code for
1291 matrices with size up to n. If the matrices involved are not
1292 square, the size comparison is performed using the geometric mean
1293 of the dimensions of the argument and result matrices.
1294
1295 The default value for n is 30. The "-fblas-matmul-limit" can be
1296 used to change this value.
1297
1298 -frecursive
1299 Allow indirect recursion by forcing all local arrays to be
1300 allocated on the stack. This flag cannot be used together with
1301 -fmax-stack-var-size= or -fno-automatic.
1302
1303 -finit-local-zero
1304 -finit-derived
1305 -finit-integer=n
1306 -finit-real=<zero|inf|-inf|nan|snan>
1307 -finit-logical=<true|false>
1308 -finit-character=n
1309 The -finit-local-zero option instructs the compiler to initialize
1310 local "INTEGER", "REAL", and "COMPLEX" variables to zero, "LOGICAL"
1311 variables to false, and "CHARACTER" variables to a string of null
1312 bytes. Finer-grained initialization options are provided by the
1313 -finit-integer=n, -finit-real=<zero|inf|-inf|nan|snan> (which also
1314 initializes the real and imaginary parts of local "COMPLEX"
1315 variables), -finit-logical=<true|false>, and -finit-character=n
1316 (where n is an ASCII character value) options.
1317
1318 With -finit-derived, components of derived type variables will be
1319 initialized according to these flags. Components whose type is not
1320 covered by an explicit -finit-* flag will be treated as described
1321 above with -finit-local-zero.
1322
1323 These options do not initialize
1324
1325 * objects with the POINTER attribute
1326
1327 * allocatable arrays
1328
1329 * variables that appear in an "EQUIVALENCE" statement.
1330
1331 (These limitations may be removed in future releases).
1332
1333 Note that the -finit-real=nan option initializes "REAL" and
1334 "COMPLEX" variables with a quiet NaN. For a signalling NaN use
1335 -finit-real=snan; note, however, that compile-time optimizations
1336 may convert them into quiet NaN and that trapping needs to be
1337 enabled (e.g. via -ffpe-trap).
1338
1339 The -finit-integer option will parse the value into an integer of
1340 type "INTEGER(kind=C_LONG)" on the host. Said value is then
1341 assigned to the integer variables in the Fortran code, which might
1342 result in wraparound if the value is too large for the kind.
1343
1344 Finally, note that enabling any of the -finit-* options will
1345 silence warnings that would have been emitted by -Wuninitialized
1346 for the affected local variables.
1347
1348 -falign-commons
1349 By default, gfortran enforces proper alignment of all variables in
1350 a "COMMON" block by padding them as needed. On certain platforms
1351 this is mandatory, on others it increases performance. If a
1352 "COMMON" block is not declared with consistent data types
1353 everywhere, this padding can cause trouble, and -fno-align-commons
1354 can be used to disable automatic alignment. The same form of this
1355 option should be used for all files that share a "COMMON" block.
1356 To avoid potential alignment issues in "COMMON" blocks, it is
1357 recommended to order objects from largest to smallest.
1358
1359 -fno-protect-parens
1360 By default the parentheses in expression are honored for all
1361 optimization levels such that the compiler does not do any re-
1362 association. Using -fno-protect-parens allows the compiler to
1363 reorder "REAL" and "COMPLEX" expressions to produce faster code.
1364 Note that for the re-association optimization -fno-signed-zeros and
1365 -fno-trapping-math need to be in effect. The parentheses protection
1366 is enabled by default, unless -Ofast is given.
1367
1368 -frealloc-lhs
1369 An allocatable left-hand side of an intrinsic assignment is
1370 automatically (re)allocated if it is either unallocated or has a
1371 different shape. The option is enabled by default except when
1372 -std=f95 is given. See also -Wrealloc-lhs.
1373
1374 -faggressive-function-elimination
1375 Functions with identical argument lists are eliminated within
1376 statements, regardless of whether these functions are marked "PURE"
1377 or not. For example, in
1378
1379 a = f(b,c) + f(b,c)
1380
1381 there will only be a single call to "f". This option only works if
1382 -ffrontend-optimize is in effect.
1383
1384 -ffrontend-optimize
1385 This option performs front-end optimization, based on manipulating
1386 parts the Fortran parse tree. Enabled by default by any -O option
1387 except -O0 and -Og. Optimizations enabled by this option include:
1388
1389 *<inlining calls to "MATMUL",>
1390 *<elimination of identical function calls within expressions,>
1391 *<removing unnecessary calls to "TRIM" in comparisons and
1392 assignments,>
1393 *<replacing TRIM(a) with "a(1:LEN_TRIM(a))" and>
1394 *<short-circuiting of logical operators (".AND." and ".OR.").>
1395
1396 It can be deselected by specifying -fno-frontend-optimize.
1397
1398 -ffrontend-loop-interchange
1399 Attempt to interchange loops in the Fortran front end where
1400 profitable. Enabled by default by any -O option. At the moment,
1401 this option only affects "FORALL" and "DO CONCURRENT" statements
1402 with several forall triplets.
1403
1405 The gfortran compiler currently does not make use of any environment
1406 variables to control its operation above and beyond those that affect
1407 the operation of gcc.
1408
1410 For instructions on reporting bugs, see
1411 <http://bugzilla.redhat.com/bugzilla>.
1412
1414 gpl(7), gfdl(7), fsf-funding(7), cpp(1), gcov(1), gcc(1), as(1), ld(1),
1415 gdb(1), dbx(1) and the Info entries for gcc, cpp, gfortran, as, ld,
1416 binutils and gdb.
1417
1419 See the Info entry for gfortran for contributors to GCC and GNU
1420 Fortran.
1421
1423 Copyright (c) 2004-2019 Free Software Foundation, Inc.
1424
1425 Permission is granted to copy, distribute and/or modify this document
1426 under the terms of the GNU Free Documentation License, Version 1.3 or
1427 any later version published by the Free Software Foundation; with the
1428 Invariant Sections being "Funding Free Software", the Front-Cover Texts
1429 being (a) (see below), and with the Back-Cover Texts being (b) (see
1430 below). A copy of the license is included in the gfdl(7) man page.
1431
1432 (a) The FSF's Front-Cover Text is:
1433
1434 A GNU Manual
1435
1436 (b) The FSF's Back-Cover Text is:
1437
1438 You have freedom to copy and modify this GNU Manual, like GNU
1439 software. Copies published by the Free Software Foundation raise
1440 funds for GNU development.
1441
1442
1443
1444gcc-9 2019-08-27 GFORTRAN(1)