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 -static-libquadmath
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) in a
671 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 * With -fopenmp, for fixed-form source code, when an "omx"
786 vendor-extension sentinel is encountered. (The equivalent
787 "ompx", used in free-form source code, is diagnosed by
788 default.)
789
790 -Wtabs
791 By default, tabs are accepted as whitespace, but tabs are not
792 members of the Fortran Character Set. For continuation lines, a
793 tab followed by a digit between 1 and 9 is supported. -Wtabs will
794 cause a warning to be issued if a tab is encountered. Note, -Wtabs
795 is active for -pedantic, -std=f95, -std=f2003, -std=f2008,
796 -std=f2018 and -Wall.
797
798 -Wundefined-do-loop
799 Warn if a DO loop with step either 1 or -1 yields an underflow or
800 an overflow during iteration of an induction variable of the loop.
801 This option is implied by -Wall.
802
803 -Wunderflow
804 Produce a warning when numerical constant expressions are
805 encountered, which yield an UNDERFLOW during compilation. Enabled
806 by default.
807
808 -Wintrinsic-shadow
809 Warn if a user-defined procedure or module procedure has the same
810 name as an intrinsic; in this case, an explicit interface or
811 "EXTERNAL" or "INTRINSIC" declaration might be needed to get calls
812 later resolved to the desired intrinsic/procedure. This option is
813 implied by -Wall.
814
815 -Wuse-without-only
816 Warn if a "USE" statement has no "ONLY" qualifier and thus
817 implicitly imports all public entities of the used module.
818
819 -Wunused-dummy-argument
820 Warn about unused dummy arguments. This option is implied by -Wall.
821
822 -Wunused-parameter
823 Contrary to gcc's meaning of -Wunused-parameter, gfortran's
824 implementation of this option does not warn about unused dummy
825 arguments (see -Wunused-dummy-argument), but about unused
826 "PARAMETER" values. -Wunused-parameter is implied by -Wextra if
827 also -Wunused or -Wall is used.
828
829 -Walign-commons
830 By default, gfortran warns about any occasion of variables being
831 padded for proper alignment inside a "COMMON" block. This warning
832 can be turned off via -Wno-align-commons. See also -falign-commons.
833
834 -Wfunction-elimination
835 Warn if any calls to impure functions are eliminated by the
836 optimizations enabled by the -ffrontend-optimize option. This
837 option is implied by -Wextra.
838
839 -Wrealloc-lhs
840 Warn when the compiler might insert code to for allocation or
841 reallocation of an allocatable array variable of intrinsic type in
842 intrinsic assignments. In hot loops, the Fortran 2003 reallocation
843 feature may reduce the performance. If the array is already
844 allocated with the correct shape, consider using a whole-array
845 array-spec (e.g. "(:,:,:)") for the variable on the left-hand side
846 to prevent the reallocation check. Note that in some cases the
847 warning is shown, even if the compiler will optimize reallocation
848 checks away. For instance, when the right-hand side contains the
849 same variable multiplied by a scalar. See also -frealloc-lhs.
850
851 -Wrealloc-lhs-all
852 Warn when the compiler inserts code to for allocation or
853 reallocation of an allocatable variable; this includes scalars and
854 derived types.
855
856 -Wcompare-reals
857 Warn when comparing real or complex types for equality or
858 inequality. This option is implied by -Wextra.
859
860 -Wtarget-lifetime
861 Warn if the pointer in a pointer assignment might be longer than
862 the its target. This option is implied by -Wall.
863
864 -Wzerotrip
865 Warn if a "DO" loop is known to execute zero times at compile time.
866 This option is implied by -Wall.
867
868 -Wdo-subscript
869 Warn if an array subscript inside a DO loop could lead to an out-
870 of-bounds access even if the compiler cannot prove that the
871 statement is actually executed, in cases like
872
873 real a(3)
874 do i=1,4
875 if (condition(i)) then
876 a(i) = 1.2
877 end if
878 end do
879
880 This option is implied by -Wextra.
881
882 -Werror
883 Turns all warnings into errors.
884
885 Some of these have no effect when compiling programs written in
886 Fortran.
887
888 Options for debugging your program or GNU Fortran
889 GNU Fortran has various special options that are used for debugging
890 either your program or the GNU Fortran compiler.
891
892 -fdump-fortran-original
893 Output the internal parse tree after translating the source program
894 into internal representation. This option is mostly useful for
895 debugging the GNU Fortran compiler itself. The output generated by
896 this option might change between releases. This option may also
897 generate internal compiler errors for features which have only
898 recently been added.
899
900 -fdump-fortran-optimized
901 Output the parse tree after front-end optimization. Mostly useful
902 for debugging the GNU Fortran compiler itself. The output generated
903 by this option might change between releases. This option may also
904 generate internal compiler errors for features which have only
905 recently been added.
906
907 -fdump-parse-tree
908 Output the internal parse tree after translating the source program
909 into internal representation. Mostly useful for debugging the GNU
910 Fortran compiler itself. The output generated by this option might
911 change between releases. This option may also generate internal
912 compiler errors for features which have only recently been added.
913 This option is deprecated; use "-fdump-fortran-original" instead.
914
915 -fdebug-aux-vars
916 Renames internal variables created by the gfortran front end and
917 makes them accessible to a debugger. The name of the internal
918 variables then start with upper-case letters followed by an
919 underscore. This option is useful for debugging the compiler's
920 code generation together with "-fdump-tree-original" and enabling
921 debugging of the executable program by using "-g" or "-ggdb3".
922
923 -fdump-fortran-global
924 Output a list of the global identifiers after translating into
925 middle-end representation. Mostly useful for debugging the GNU
926 Fortran compiler itself. The output generated by this option might
927 change between releases. This option may also generate internal
928 compiler errors for features which have only recently been added.
929
930 -ffpe-trap=list
931 Specify a list of floating point exception traps to enable. On
932 most systems, if a floating point exception occurs and the trap for
933 that exception is enabled, a SIGFPE signal will be sent and the
934 program being aborted, producing a core file useful for debugging.
935 list is a (possibly empty) comma-separated list of the following
936 exceptions: invalid (invalid floating point operation, such as
937 SQRT(-1.0)), zero (division by zero), overflow (overflow in a
938 floating point operation), underflow (underflow in a floating point
939 operation), inexact (loss of precision during operation), and
940 denormal (operation performed on a denormal value). The first five
941 exceptions correspond to the five IEEE 754 exceptions, whereas the
942 last one (denormal) is not part of the IEEE 754 standard but is
943 available on some common architectures such as x86.
944
945 The first three exceptions (invalid, zero, and overflow) often
946 indicate serious errors, and unless the program has provisions for
947 dealing with these exceptions, enabling traps for these three
948 exceptions is probably a good idea.
949
950 If the option is used more than once in the command line, the lists
951 will be joined: '"ffpe-trap="list1 "ffpe-trap="list2' is equivalent
952 to "ffpe-trap="list1,list2.
953
954 Note that once enabled an exception cannot be disabled (no negative
955 form).
956
957 Many, if not most, floating point operations incur loss of
958 precision due to rounding, and hence the "ffpe-trap=inexact" is
959 likely to be uninteresting in practice.
960
961 By default no exception traps are enabled.
962
963 -ffpe-summary=list
964 Specify a list of floating-point exceptions, whose flag status is
965 printed to "ERROR_UNIT" when invoking "STOP" and "ERROR STOP".
966 list can be either none, all or a comma-separated list of the
967 following exceptions: invalid, zero, overflow, underflow, inexact
968 and denormal. (See -ffpe-trap for a description of the exceptions.)
969
970 If the option is used more than once in the command line, only the
971 last one will be used.
972
973 By default, a summary for all exceptions but inexact is shown.
974
975 -fno-backtrace
976 When a serious runtime error is encountered or a deadly signal is
977 emitted (segmentation fault, illegal instruction, bus error,
978 floating-point exception, and the other POSIX signals that have the
979 action core), the Fortran runtime library tries to output a
980 backtrace of the error. "-fno-backtrace" disables the backtrace
981 generation. This option only has influence for compilation of the
982 Fortran main program.
983
984 Options for directory search
985 These options affect how GNU Fortran searches for files specified by
986 the "INCLUDE" directive and where it searches for previously compiled
987 modules.
988
989 It also affects the search paths used by cpp when used to preprocess
990 Fortran source.
991
992 -Idir
993 These affect interpretation of the "INCLUDE" directive (as well as
994 of the "#include" directive of the cpp preprocessor).
995
996 Also note that the general behavior of -I and "INCLUDE" is pretty
997 much the same as of -I with "#include" in the cpp preprocessor,
998 with regard to looking for header.gcc files and other such things.
999
1000 This path is also used to search for .mod files when previously
1001 compiled modules are required by a "USE" statement.
1002
1003 -Jdir
1004 This option specifies where to put .mod files for compiled modules.
1005 It is also added to the list of directories to searched by an "USE"
1006 statement.
1007
1008 The default is the current directory.
1009
1010 -fintrinsic-modules-path dir
1011 This option specifies the location of pre-compiled intrinsic
1012 modules, if they are not in the default location expected by the
1013 compiler.
1014
1015 Influencing the linking step
1016 These options come into play when the compiler links object files into
1017 an executable output file. They are meaningless if the compiler is not
1018 doing a link step.
1019
1020 -static-libgfortran
1021 On systems that provide libgfortran as a shared and a static
1022 library, this option forces the use of the static version. If no
1023 shared version of libgfortran was built when the compiler was
1024 configured, this option has no effect.
1025
1026 -static-libquadmath
1027 On systems that provide libquadmath as a shared and a static
1028 library, this option forces the use of the static version. If no
1029 shared version of libquadmath was built when the compiler was
1030 configured, this option has no effect.
1031
1032 Please note that the libquadmath runtime library is licensed under
1033 the GNU Lesser General Public License (LGPL), and linking it
1034 statically introduces requirements when redistributing the
1035 resulting binaries.
1036
1037 Influencing runtime behavior
1038 These options affect the runtime behavior of programs compiled with GNU
1039 Fortran.
1040
1041 -fconvert=conversion
1042 Specify the representation of data for unformatted files. Valid
1043 values for conversion on most systems are: native, the default;
1044 swap, swap between big- and little-endian; big-endian, use big-
1045 endian representation for unformatted files; little-endian, use
1046 little-endian representation for unformatted files.
1047
1048 On POWER systems which suppport -mabi=ieeelongdouble, there are
1049 additional options, which can be combined with others with commas.
1050 Those are
1051
1052 @w<-fconvert=r16_ieee Use IEEE 128-bit format for>
1053 REAL(KIND=16).
1054
1055 @w<-fconvert=r16_ibm Use IBM long double format for>
1056 REAL(KIND=16).
1057
1058 This option has an effect only when used in the main program. The
1059 "CONVERT" specifier and the GFORTRAN_CONVERT_UNIT environment
1060 variable override the default specified by -fconvert.
1061
1062 -frecord-marker=length
1063 Specify the length of record markers for unformatted files. Valid
1064 values for length are 4 and 8. Default is 4. This is different
1065 from previous versions of gfortran, which specified a default
1066 record marker length of 8 on most systems. If you want to read or
1067 write files compatible with earlier versions of gfortran, use
1068 -frecord-marker=8.
1069
1070 -fmax-subrecord-length=length
1071 Specify the maximum length for a subrecord. The maximum permitted
1072 value for length is 2147483639, which is also the default. Only
1073 really useful for use by the gfortran testsuite.
1074
1075 -fsign-zero
1076 When enabled, floating point numbers of value zero with the sign
1077 bit set are written as negative number in formatted output and
1078 treated as negative in the "SIGN" intrinsic. -fno-sign-zero does
1079 not print the negative sign of zero values (or values rounded to
1080 zero for I/O) and regards zero as positive number in the "SIGN"
1081 intrinsic for compatibility with Fortran 77. The default is
1082 -fsign-zero.
1083
1084 Options for code generation conventions
1085 These machine-independent options control the interface conventions
1086 used in code generation.
1087
1088 Most of them have both positive and negative forms; the negative form
1089 of -ffoo would be -fno-foo. In the table below, only one of the forms
1090 is listed---the one which is not the default. You can figure out the
1091 other form by either removing no- or adding it.
1092
1093 -fno-automatic
1094 Treat each program unit (except those marked as RECURSIVE) as if
1095 the "SAVE" statement were specified for every local variable and
1096 array referenced in it. Does not affect common blocks. (Some
1097 Fortran compilers provide this option under the name -static or
1098 -save.) The default, which is -fautomatic, uses the stack for
1099 local variables smaller than the value given by
1100 -fmax-stack-var-size. Use the option -frecursive to use no static
1101 memory.
1102
1103 Local variables or arrays having an explicit "SAVE" attribute are
1104 silently ignored unless the -pedantic option is added.
1105
1106 -ff2c
1107 Generate code designed to be compatible with code generated by g77
1108 and f2c.
1109
1110 The calling conventions used by g77 (originally implemented in f2c)
1111 require functions that return type default "REAL" to actually
1112 return the C type "double", and functions that return type
1113 "COMPLEX" to return the values via an extra argument in the calling
1114 sequence that points to where to store the return value. Under the
1115 default GNU calling conventions, such functions simply return their
1116 results as they would in GNU C---default "REAL" functions return
1117 the C type "float", and "COMPLEX" functions return the GNU C type
1118 "complex". Additionally, this option implies the
1119 -fsecond-underscore option, unless -fno-second-underscore is
1120 explicitly requested.
1121
1122 This does not affect the generation of code that interfaces with
1123 the libgfortran library.
1124
1125 Caution: It is not a good idea to mix Fortran code compiled with
1126 -ff2c with code compiled with the default -fno-f2c calling
1127 conventions as, calling "COMPLEX" or default "REAL" functions
1128 between program parts which were compiled with different calling
1129 conventions will break at execution time.
1130
1131 Caution: This will break code which passes intrinsic functions of
1132 type default "REAL" or "COMPLEX" as actual arguments, as the
1133 library implementations use the -fno-f2c calling conventions.
1134
1135 -fno-underscoring
1136 Do not transform names of entities specified in the Fortran source
1137 file by appending underscores to them.
1138
1139 With -funderscoring in effect, GNU Fortran appends one underscore
1140 to external names. This is done to ensure compatibility with code
1141 produced by many UNIX Fortran compilers.
1142
1143 Caution: The default behavior of GNU Fortran is incompatible with
1144 f2c and g77, please use the -ff2c option if you want object files
1145 compiled with GNU Fortran to be compatible with object code created
1146 with these tools.
1147
1148 Use of -fno-underscoring is not recommended unless you are
1149 experimenting with issues such as integration of GNU Fortran into
1150 existing system environments (vis-à-vis existing libraries, tools,
1151 and so on).
1152
1153 For example, with -funderscoring, and assuming that j() and
1154 max_count() are external functions while "my_var" and "lvar" are
1155 local variables, a statement like
1156
1157 I = J() + MAX_COUNT (MY_VAR, LVAR)
1158
1159 is implemented as something akin to:
1160
1161 i = j_() + max_count_(&my_var, &lvar);
1162
1163 With -fno-underscoring, the same statement is implemented as:
1164
1165 i = j() + max_count(&my_var, &lvar);
1166
1167 Use of -fno-underscoring allows direct specification of user-
1168 defined names while debugging and when interfacing GNU Fortran code
1169 with other languages.
1170
1171 Note that just because the names match does not mean that the
1172 interface implemented by GNU Fortran for an external name matches
1173 the interface implemented by some other language for that same
1174 name. That is, getting code produced by GNU Fortran to link to
1175 code produced by some other compiler using this or any other method
1176 can be only a small part of the overall solution---getting the code
1177 generated by both compilers to agree on issues other than naming
1178 can require significant effort, and, unlike naming disagreements,
1179 linkers normally cannot detect disagreements in these other areas.
1180
1181 Also, note that with -fno-underscoring, the lack of appended
1182 underscores introduces the very real possibility that a user-
1183 defined external name will conflict with a name in a system
1184 library, which could make finding unresolved-reference bugs quite
1185 difficult in some cases---they might occur at program run time, and
1186 show up only as buggy behavior at run time.
1187
1188 In future versions of GNU Fortran we hope to improve naming and
1189 linking issues so that debugging always involves using the names as
1190 they appear in the source, even if the names as seen by the linker
1191 are mangled to prevent accidental linking between procedures with
1192 incompatible interfaces.
1193
1194 -fsecond-underscore
1195 By default, GNU Fortran appends an underscore to external names.
1196 If this option is used GNU Fortran appends two underscores to names
1197 with underscores and one underscore to external names with no
1198 underscores. GNU Fortran also appends two underscores to internal
1199 names with underscores to avoid naming collisions with external
1200 names.
1201
1202 This option has no effect if -fno-underscoring is in effect. It is
1203 implied by the -ff2c option.
1204
1205 Otherwise, with this option, an external name such as "MAX_COUNT"
1206 is implemented as a reference to the link-time external symbol
1207 "max_count__", instead of "max_count_". This is required for
1208 compatibility with g77 and f2c, and is implied by use of the -ff2c
1209 option.
1210
1211 -fcoarray=<keyword>
1212 none
1213 Disable coarray support; using coarray declarations and image-
1214 control statements will produce a compile-time error. (Default)
1215
1216 single
1217 Single-image mode, i.e. num_images() is always one.
1218
1219 lib Library-based coarray parallelization; a suitable GNU Fortran
1220 coarray library needs to be linked.
1221
1222 -fcheck=<keyword>
1223 Enable the generation of run-time checks; the argument shall be a
1224 comma-delimited list of the following keywords. Prefixing a check
1225 with no- disables it if it was activated by a previous
1226 specification.
1227
1228 all Enable all run-time test of -fcheck.
1229
1230 array-temps
1231 Warns at run time when for passing an actual argument a
1232 temporary array had to be generated. The information generated
1233 by this warning is sometimes useful in optimization, in order
1234 to avoid such temporaries.
1235
1236 Note: The warning is only printed once per location.
1237
1238 bits
1239 Enable generation of run-time checks for invalid arguments to
1240 the bit manipulation intrinsics.
1241
1242 bounds
1243 Enable generation of run-time checks for array subscripts and
1244 against the declared minimum and maximum values. It also
1245 checks array indices for assumed and deferred shape arrays
1246 against the actual allocated bounds and ensures that all string
1247 lengths are equal for character array constructors without an
1248 explicit typespec.
1249
1250 Some checks require that -fcheck=bounds is set for the
1251 compilation of the main program.
1252
1253 Note: In the future this may also include other forms of
1254 checking, e.g., checking substring references.
1255
1256 do Enable generation of run-time checks for invalid modification
1257 of loop iteration variables.
1258
1259 mem Enable generation of run-time checks for memory allocation.
1260 Note: This option does not affect explicit allocations using
1261 the "ALLOCATE" statement, which will be always checked.
1262
1263 pointer
1264 Enable generation of run-time checks for pointers and
1265 allocatables.
1266
1267 recursion
1268 Enable generation of run-time checks for recursively called
1269 subroutines and functions which are not marked as recursive.
1270 See also -frecursive. Note: This check does not work for
1271 OpenMP programs and is disabled if used together with
1272 -frecursive and -fopenmp.
1273
1274 Example: Assuming you have a file foo.f90, the command
1275
1276 gfortran -fcheck=all,no-array-temps foo.f90
1277
1278 will compile the file with all checks enabled as specified above
1279 except warnings for generated array temporaries.
1280
1281 -fbounds-check
1282 Deprecated alias for -fcheck=bounds.
1283
1284 -ftail-call-workaround
1285 -ftail-call-workaround=n
1286 Some C interfaces to Fortran codes violate the gfortran ABI by
1287 omitting the hidden character length arguments as described in
1288 This can lead to crashes because pushing arguments for tail calls
1289 can overflow the stack.
1290
1291 To provide a workaround for existing binary packages, this option
1292 disables tail call optimization for gfortran procedures with
1293 character arguments. With -ftail-call-workaround=2 tail call
1294 optimization is disabled in all gfortran procedures with character
1295 arguments, with -ftail-call-workaround=1 or equivalent
1296 -ftail-call-workaround only in gfortran procedures with character
1297 arguments that call implicitly prototyped procedures.
1298
1299 Using this option can lead to problems including crashes due to
1300 insufficient stack space.
1301
1302 It is very strongly recommended to fix the code in question. The
1303 -fc-prototypes-external option can be used to generate prototypes
1304 which conform to gfortran's ABI, for inclusion in the source code.
1305
1306 Support for this option will likely be withdrawn in a future
1307 release of gfortran.
1308
1309 The negative form, -fno-tail-call-workaround or equivalent
1310 -ftail-call-workaround=0, can be used to disable this option.
1311
1312 Default is currently -ftail-call-workaround, this will change in
1313 future releases.
1314
1315 -fcheck-array-temporaries
1316 Deprecated alias for -fcheck=array-temps.
1317
1318 -fmax-array-constructor=n
1319 This option can be used to increase the upper limit permitted in
1320 array constructors. The code below requires this option to expand
1321 the array at compile time.
1322
1323 program test
1324 implicit none
1325 integer j
1326 integer, parameter :: n = 100000
1327 integer, parameter :: i(n) = (/ (2*j, j = 1, n) /)
1328 print '(10(I0,1X))', i
1329 end program test
1330
1331 Caution: This option can lead to long compile times and
1332 excessively large object files.
1333
1334 The default value for n is 65535.
1335
1336 -fmax-stack-var-size=n
1337 This option specifies the size in bytes of the largest array that
1338 will be put on the stack; if the size is exceeded static memory is
1339 used (except in procedures marked as RECURSIVE). Use the option
1340 -frecursive to allow for recursive procedures which do not have a
1341 RECURSIVE attribute or for parallel programs. Use -fno-automatic to
1342 never use the stack.
1343
1344 This option currently only affects local arrays declared with
1345 constant bounds, and may not apply to all character variables.
1346 Future versions of GNU Fortran may improve this behavior.
1347
1348 The default value for n is 65536.
1349
1350 -fstack-arrays
1351 Adding this option will make the Fortran compiler put all arrays of
1352 unknown size and array temporaries onto stack memory. If your
1353 program uses very large local arrays it is possible that you will
1354 have to extend your runtime limits for stack memory on some
1355 operating systems. This flag is enabled by default at optimization
1356 level -Ofast unless -fmax-stack-var-size is specified.
1357
1358 -fpack-derived
1359 This option tells GNU Fortran to pack derived type members as
1360 closely as possible. Code compiled with this option is likely to
1361 be incompatible with code compiled without this option, and may
1362 execute slower.
1363
1364 -frepack-arrays
1365 In some circumstances GNU Fortran may pass assumed shape array
1366 sections via a descriptor describing a noncontiguous area of
1367 memory. This option adds code to the function prologue to repack
1368 the data into a contiguous block at runtime.
1369
1370 This should result in faster accesses to the array. However it can
1371 introduce significant overhead to the function call, especially
1372 when the passed data is noncontiguous.
1373
1374 -fshort-enums
1375 This option is provided for interoperability with C code that was
1376 compiled with the -fshort-enums option. It will make GNU Fortran
1377 choose the smallest "INTEGER" kind a given enumerator set will fit
1378 in, and give all its enumerators this kind.
1379
1380 -finline-arg-packing
1381 When passing an assumed-shape argument of a procedure as actual
1382 argument to an assumed-size or explicit size or as argument to a
1383 procedure that does not have an explicit interface, the argument
1384 may have to be packed, that is put into contiguous memory. An
1385 example is the call to "foo" in
1386
1387 subroutine foo(a)
1388 real, dimension(*) :: a
1389 end subroutine foo
1390 subroutine bar(b)
1391 real, dimension(:) :: b
1392 call foo(b)
1393 end subroutine bar
1394
1395 When -finline-arg-packing is in effect, this packing will be
1396 performed by inline code. This allows for more optimization while
1397 increasing code size.
1398
1399 -finline-arg-packing is implied by any of the -O options except
1400 when optimizing for size via -Os. If the code contains a very
1401 large number of argument that have to be packed, code size and also
1402 compilation time may become excessive. If that is the case, it may
1403 be better to disable this option. Instances of packing can be
1404 found by using -Warray-temporaries.
1405
1406 -fexternal-blas
1407 This option will make gfortran generate calls to BLAS functions for
1408 some matrix operations like "MATMUL", instead of using our own
1409 algorithms, if the size of the matrices involved is larger than a
1410 given limit (see -fblas-matmul-limit). This may be profitable if
1411 an optimized vendor BLAS library is available. The BLAS library
1412 will have to be specified at link time.
1413
1414 -fblas-matmul-limit=n
1415 Only significant when -fexternal-blas is in effect. Matrix
1416 multiplication of matrices with size larger than (or equal to) n
1417 will be performed by calls to BLAS functions, while others will be
1418 handled by gfortran internal algorithms. If the matrices involved
1419 are not square, the size comparison is performed using the
1420 geometric mean of the dimensions of the argument and result
1421 matrices.
1422
1423 The default value for n is 30.
1424
1425 -finline-matmul-limit=n
1426 When front-end optimization is active, some calls to the "MATMUL"
1427 intrinsic function will be inlined. This may result in code size
1428 increase if the size of the matrix cannot be determined at compile
1429 time, as code for both cases is generated. Setting
1430 "-finline-matmul-limit=0" will disable inlining in all cases.
1431 Setting this option with a value of n will produce inline code for
1432 matrices with size up to n. If the matrices involved are not
1433 square, the size comparison is performed using the geometric mean
1434 of the dimensions of the argument and result matrices.
1435
1436 The default value for n is 30. The "-fblas-matmul-limit" can be
1437 used to change this value.
1438
1439 -frecursive
1440 Allow indirect recursion by forcing all local arrays to be
1441 allocated on the stack. This flag cannot be used together with
1442 -fmax-stack-var-size= or -fno-automatic.
1443
1444 -finit-local-zero
1445 -finit-derived
1446 -finit-integer=n
1447 -finit-real=<zero|inf|-inf|nan|snan>
1448 -finit-logical=<true|false>
1449 -finit-character=n
1450 The -finit-local-zero option instructs the compiler to initialize
1451 local "INTEGER", "REAL", and "COMPLEX" variables to zero, "LOGICAL"
1452 variables to false, and "CHARACTER" variables to a string of null
1453 bytes. Finer-grained initialization options are provided by the
1454 -finit-integer=n, -finit-real=<zero|inf|-inf|nan|snan> (which also
1455 initializes the real and imaginary parts of local "COMPLEX"
1456 variables), -finit-logical=<true|false>, and -finit-character=n
1457 (where n is an ASCII character value) options.
1458
1459 With -finit-derived, components of derived type variables will be
1460 initialized according to these flags. Components whose type is not
1461 covered by an explicit -finit-* flag will be treated as described
1462 above with -finit-local-zero.
1463
1464 These options do not initialize
1465
1466 * objects with the POINTER attribute
1467
1468 * allocatable arrays
1469
1470 * variables that appear in an "EQUIVALENCE" statement.
1471
1472 (These limitations may be removed in future releases).
1473
1474 Note that the -finit-real=nan option initializes "REAL" and
1475 "COMPLEX" variables with a quiet NaN. For a signalling NaN use
1476 -finit-real=snan; note, however, that compile-time optimizations
1477 may convert them into quiet NaN and that trapping needs to be
1478 enabled (e.g. via -ffpe-trap).
1479
1480 The -finit-integer option will parse the value into an integer of
1481 type INTEGER(kind=C_LONG) on the host. Said value is then assigned
1482 to the integer variables in the Fortran code, which might result in
1483 wraparound if the value is too large for the kind.
1484
1485 Finally, note that enabling any of the -finit-* options will
1486 silence warnings that would have been emitted by -Wuninitialized
1487 for the affected local variables.
1488
1489 -falign-commons
1490 By default, gfortran enforces proper alignment of all variables in
1491 a "COMMON" block by padding them as needed. On certain platforms
1492 this is mandatory, on others it increases performance. If a
1493 "COMMON" block is not declared with consistent data types
1494 everywhere, this padding can cause trouble, and -fno-align-commons
1495 can be used to disable automatic alignment. The same form of this
1496 option should be used for all files that share a "COMMON" block.
1497 To avoid potential alignment issues in "COMMON" blocks, it is
1498 recommended to order objects from largest to smallest.
1499
1500 -fno-protect-parens
1501 By default the parentheses in expression are honored for all
1502 optimization levels such that the compiler does not do any re-
1503 association. Using -fno-protect-parens allows the compiler to
1504 reorder "REAL" and "COMPLEX" expressions to produce faster code.
1505 Note that for the re-association optimization -fno-signed-zeros and
1506 -fno-trapping-math need to be in effect. The parentheses protection
1507 is enabled by default, unless -Ofast is given.
1508
1509 -frealloc-lhs
1510 An allocatable left-hand side of an intrinsic assignment is
1511 automatically (re)allocated if it is either unallocated or has a
1512 different shape. The option is enabled by default except when
1513 -std=f95 is given. See also -Wrealloc-lhs.
1514
1515 -faggressive-function-elimination
1516 Functions with identical argument lists are eliminated within
1517 statements, regardless of whether these functions are marked "PURE"
1518 or not. For example, in
1519
1520 a = f(b,c) + f(b,c)
1521
1522 there will only be a single call to "f". This option only works if
1523 -ffrontend-optimize is in effect.
1524
1525 -ffrontend-optimize
1526 This option performs front-end optimization, based on manipulating
1527 parts the Fortran parse tree. Enabled by default by any -O option
1528 except -O0 and -Og. Optimizations enabled by this option include:
1529
1530 *<inlining calls to "MATMUL",>
1531 *<elimination of identical function calls within expressions,>
1532 *<removing unnecessary calls to "TRIM" in comparisons and
1533 assignments,>
1534 *<replacing TRIM(a) with "a(1:LEN_TRIM(a))" and>
1535 *<short-circuiting of logical operators (".AND." and ".OR.").>
1536
1537 It can be deselected by specifying -fno-frontend-optimize.
1538
1539 -ffrontend-loop-interchange
1540 Attempt to interchange loops in the Fortran front end where
1541 profitable. Enabled by default by any -O option. At the moment,
1542 this option only affects "FORALL" and "DO CONCURRENT" statements
1543 with several forall triplets.
1544
1546 The gfortran compiler currently does not make use of any environment
1547 variables to control its operation above and beyond those that affect
1548 the operation of gcc.
1549
1551 For instructions on reporting bugs, see
1552 <http://bugzilla.redhat.com/bugzilla>.
1553
1555 gpl(7), gfdl(7), fsf-funding(7), cpp(1), gcov(1), gcc(1), as(1), ld(1),
1556 gdb(1), dbx(1) and the Info entries for gcc, cpp, gfortran, as, ld,
1557 binutils and gdb.
1558
1560 See the Info entry for gfortran for contributors to GCC and GNU
1561 Fortran.
1562
1564 Copyright (c) 2004-2023 Free Software Foundation, Inc.
1565
1566 Permission is granted to copy, distribute and/or modify this document
1567 under the terms of the GNU Free Documentation License, Version 1.3 or
1568 any later version published by the Free Software Foundation; with the
1569 Invariant Sections being "Funding Free Software", the Front-Cover Texts
1570 being (a) (see below), and with the Back-Cover Texts being (b) (see
1571 below). A copy of the license is included in the gfdl(7) man page.
1572
1573 (a) The FSF's Front-Cover Text is:
1574
1575 A GNU Manual
1576
1577 (b) The FSF's Back-Cover Text is:
1578
1579 You have freedom to copy and modify this GNU Manual, like GNU
1580 software. Copies published by the Free Software Foundation raise
1581 funds for GNU development.
1582
1583
1584
1585gcc-13 2023-10-11 GFORTRAN(1)