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