gfortran - GNU Fortran compiler
[-g] [-pg] [-Olevel]
[-o outfile] infile...
[-g] [-pg] [-Olevel]
[-o outfile] infile...
Only the most useful options are listed here; see below for the remainder.
The gfortran command supports all the options supported by the gcc command. Only options specific to GNU Fortran are documented here.
All GCC and GNU Fortran options are accepted both by gfortran and by gcc (as well as any other drivers built at the same time, such as g++), since adding GNU Fortran to the GCC distribution enables acceptance of GNU Fortran options by all of the relevant drivers.
In some cases, options have positive and negative forms; the negative form of -ffoo would be -fno-foo. This manual documents only one of these two forms, whichever one is not the default.
Here is a summary of all the options specific to GNU Fortran, grouped by type. Explanations are in the following sections.
|Fortran Language Options||-fall-intrinsics -fallow-argument-mismatch -fallow-invalid-boz -fbackslash -fcray-pointer -fd-lines-as-code -fd-lines-as-comments -fdec -fdec-char-conversions -fdec-structure -fdec-intrinsic-ints -fdec-static -fdec-math -fdec-include -fdec-format-defaults -fdec-blank-format-item -fdefault-double-8 -fdefault-integer-8 -fdefault-real-8 -fdefault-real-10 -fdefault-real-16 -fdollar-ok -ffixed-line-length-n -ffixed-line-length-none -fpad-source -ffree-form -ffree-line-length-n -ffree-line-length-none -fimplicit-none -finteger-4-integer-8 -fmax-identifier-length -fmodule-private -ffixed-form -fno-range-check -fopenacc -fopenmp -freal-4-real-10 -freal-4-real-16 -freal-4-real-8 -freal-8-real-10 -freal-8-real-16 -freal-8-real-4 -std=std -ftest-forall-temp|
|Preprocessing Options||-A-question[=answer] -Aquestion=answer -C -CC -Dmacro[=defn] -H -P -Umacro -cpp -dD -dI -dM -dN -dU -fworking-directory -imultilib dir -iprefix file -iquote -isysroot dir -isystem dir -nocpp -nostdinc -undef|
|Error and Warning Options||-Waliasing -Wall -Wampersand -Warray-bounds -Wc-binding-type -Wcharacter-truncation -Wconversion -Wdo-subscript -Wfunction-elimination -Wimplicit-interface -Wimplicit-procedure -Wintrinsic-shadow -Wuse-without-only -Wintrinsics-std -Wline-truncation -Wno-align-commons -Wno-overwrite-recursive -Wno-tabs -Wreal-q-constant -Wsurprising -Wunderflow -Wunused-parameter -Wrealloc-lhs -Wrealloc-lhs-all -Wfrontend-loop-interchange -Wtarget-lifetime -fmax-errors=n -fsyntax-only -pedantic -pedantic-errors|
|Debugging Options||-fbacktrace -fdump-fortran-optimized -fdump-fortran-original -fdump-fortran-global -fdump-parse-tree -ffpe-trap=list -ffpe-summary=list|
|Directory Options||-Idir -Jdir -fintrinsic-modules-path dir|
|Runtime Options||-fconvert=conversion -fmax-subrecord-length=length -frecord-marker=length -fsign-zero|
|Interoperability Options||-fc-prototypes -fc-prototypes-external|
|Code Generation Options||-faggressive-function-elimination -fblas-matmul-limit=n -fbounds-check -ftail-call-workaround -ftail-call-workaround=n -fcheck-array-temporaries -fcheck=<all|array-temps|bits|bounds|do|mem|pointer|recursion> -fcoarray=<none|single|lib> -fexternal-blas -ff2c -ffrontend-loop-interchange -ffrontend-optimize -finit-character=n -finit-integer=n -finit-local-zero -finit-derived -finit-logical=<true|false> -finit-real=<zero|inf|-inf|nan|snan> -finline-matmul-limit=n -finline-arg-packing -fmax-array-constructor=n -fmax-stack-var-size=n -fno-align-commons -fno-automatic -fno-protect-parens -fno-underscoring -fsecond-underscore -fpack-derived -frealloc-lhs -frecursive -frepack-arrays -fshort-enums -fstack-arrays|
Options controlling Fortran dialect
The following options control the details of the Fortran dialect accepted by the compiler:
|-ffixed-form||Specify the layout used by the source file. The free form layout was introduced in Fortran 90. Fixed form was traditionally used in older Fortran programs. When neither option is specified, the source form is determined by the file extension.|
|-fall-intrinsics||This option causes all intrinsic procedures (including the GNU-specific extensions) to be accepted. This can be useful with -std=f95 to force standard-compliance but get access to the full range of intrinsics available with gfortran. As a consequence, -Wintrinsics-std will be ignored and no user-defined procedure with the same name as any intrinsic will be called except when it is explicitly declared
|-fallow-argument-mismatch||Some code contains calls to external procedures whith mismatches between the calls and the procedure definition, or with mismatches between different calls. Such code is non-conforming, and will usually be flagged wi1th an error. This options degrades the error to a warning, which can only be disabled by disabling all warnings vial -w. Only a single occurrence per argument is flagged by this warning. -fallow-argument-mismatch is implied by -std=legacy.
Using this option is strongly discouraged. It is possible to provide standard-conforming code which allows different types of arguments by using an explicit interface and
|-fallow-invalid-boz||A BOZ literal constant can occur in a limited number of contexts in standard conforming Fortran. This option degrades an error condition to a warning, and allows a BOZ literal constant to appear where the Fortran standard would otherwise prohibit its use.|
|-fd-lines-as-comments||Enable special treatment for lines beginning with
|-fdec||DEC compatibility mode. Enables extensions and other features that mimic the default behavior of older compilers (such as DEC). These features are non-standard and should be avoided at all costs. For details on GNU Fortran’s implementation of these extensions see the full documentation.
Other flags enabled by this switch are: -fdollar-ok -fcray-pointer -fdec-char-conversions -fdec-structure -fdec-intrinsic-ints -fdec-static -fdec-math -fdec-include -fdec-blank-format-item -fdec-format-defaults
If -fd-lines-as-code/-fd-lines-as-comments are unset, then -fdec also sets -fd-lines-as-comments.
|-fdec-char-conversions||Enable the use of character literals in assignments and
|-fdec-intrinsic-ints||Enable B/I/J/K kind variants of existing integer functions (e.g. BIAND, IIAND, JIAND, etc...). For a complete list of intrinsics see the full documentation.|
|-fdec-math||Enable legacy math intrinsics such as COTAN and degree-valued trigonometric functions (e.g. TAND, ATAND, etc...) for compatability with older code.|
|-fdec-static||Enable DEC-style STATIC and AUTOMATIC attributes to explicitly specify the storage of variables and other objects.|
|-fdec-include||Enable parsing of INCLUDE as a statement in addition to parsing it as INCLUDE line. When parsed as INCLUDE statement, INCLUDE does not have to be on a single line and can use line continuations.|
|-fdec-format-defaults||Enable format specifiers F, G and I to be used without width specifiers, default widths will be used instead.|
|-fdec-blank-format-item||Enable a blank format item at the end of a format specification i.e. nothing following the final comma.|
|-fdollar-ok||Allow $ as a valid non-first character in a symbol name. Symbols that start with $ are rejected since it is unclear which rules to apply to implicit typing as different vendors implement different rules. Using $ in
|-fbackslash||Change the interpretation of backslashes in string literals from a single backslash character to C-style escape characters. The following combinations are expanded
|-fmodule-private||Set the default accessibility of module entities to
|-ffixed-line-length-n||Set column after which characters are ignored in typical fixed-form lines in the source file, and, unless
Popular values for n include 72 (the standard and the default), 80 (card image), and 132 (corresponding to extended-source options in some popular compilers). n may also be none, meaning that the entire line is meaningful and that continued character constants never have implicit spaces appended to them to fill out the line. -ffixed-line-length-0 means the same thing as -ffixed-line-length-none.
|-fno-pad-source||By default fixed-form lines have spaces assumed (as if padded to that length) after the ends of short fixed-form lines. This is not done either if -ffixed-line-length-0, -ffixed-line-length-none or if -fno-pad-source option is used. With any of those options continued character constants never have implicit spaces appended to them to fill out the line.|
|-ffree-line-length-n||Set column after which characters are ignored in typical free-form lines in the source file. The default value is 132. n may be none, meaning that the entire line is meaningful. -ffree-line-length-0 means the same thing as -ffree-line-length-none.|
|-fmax-identifier-length=n||Specify the maximum allowed identifier length. Typical values are 31 (Fortran 95) and 63 (Fortran 2003 and Fortran 2008).|
|-fimplicit-none||Specify that no implicit typing is allowed, unless overridden by explicit
|-fcray-pointer||Enable the Cray pointer extension, which provides C-like pointer functionality.|
|-fopenacc||Enable the OpenACC extensions. This includes OpenACC
|-fopenmp||Enable the OpenMP extensions. This includes OpenMP
|-fno-range-check||Disable range checking on results of simplification of constant expressions during compilation. For example, GNU Fortran will give an error at compile time when simplifying
|-fdefault-integer-8||Set the default integer and logical types to an 8 byte wide type. This option also affects the kind of integer constants like
|-fdefault-real-8||Set the default real type to an 8 byte wide type. This option also affects the kind of non-double real constants like
|-fdefault-real-10||Set the default real type to an 10 byte wide type. This option also affects the kind of non-double real constants like
|-fdefault-real-16||Set the default real type to an 16 byte wide type. This option also affects the kind of non-double real constants like
|-std=std||Specify the standard to which the program is expected to conform, which may be one of f95, f2003, f2008, f2018, gnu, or legacy. The default value for std is gnu, which specifies a superset of the latest Fortran standard that includes all of the extensions supported by GNU Fortran, although warnings will be given for obsolete extensions not recommended for use in new code. The legacy value is equivalent but without the warnings for obsolete extensions, and may be useful for old non-standard programs. The f95, f2003, f2008, and f2018 values specify strict conformance to the Fortran 95, Fortran 2003, Fortran 2008 and Fortran 2018 standards, respectively; errors are given for all extensions beyond the relevant language standard, and warnings are given for the Fortran 77 features that are permitted but obsolescent in later standards. The deprecated option -std=f2008ts acts as an alias for -std=f2018. It is only present for backwards compatibility with earlier gfortran versions and should not be used any more.|
|-ftest-forall-temp||Enhance test coverage by forcing most forall assignments to use temporary.|
Enable and customize preprocessing
Preprocessor related options. See section Preprocessing and conditional compilation for more detailed information on preprocessing in gfortran.
|-nocpp||Enable preprocessing. The preprocessor is automatically invoked if the file extension is .fpp, .FPP, .F, .FOR, .FTN, .F90, .F95, .F03 or .F08. Use this option to manually enable preprocessing of any kind of Fortran file.
To disable preprocessing of files with any of the above listed extensions, use the negative form: -nocpp.
The preprocessor is run in traditional mode. Any restrictions of the file-format, especially the limits on line length, apply for preprocessed output as well, so it might be advisable to use the -ffree-line-length-none or -ffixed-line-length-none options.
|-dM||Instead of the normal output, generate a list of
will show all the predefined macros.
|-dD||Like -dM except in two respects: it does not include the predefined macros, and it outputs both the
|-dN||Like -dD, but emit only the macro names, not their expansions.|
|-dU||Like dD except that only macros that are expanded, or whose definedness is tested in preprocessor directives, are output; the output is delayed until the use or test of the macro; and
|-fworking-directory||Enable generation of linemarkers in the preprocessor output that will let the compiler know the current working directory at the time of preprocessing. When this option is enabled, the preprocessor will emit, after the initial linemarker, a second linemarker with the current working directory followed by two slashes. GCC will use this directory, when it is present in the preprocessed input, as the directory emitted as the current working directory in some debugging information formats. This option is implicitly enabled if debugging information is enabled, but this can be inhibited with the negated form -fno-working-directory. If the -P flag is present in the command line, this option has no effect, since no
|-idirafter dir||Search dir for include files, but do it after all directories specified with -I and the standard system directories have been exhausted. dir is treated as a system include directory. If dir begins with
|-imultilib dir||Use dir as a subdirectory of the directory containing target-specific C++ headers.|
|-iprefix prefix||Specify prefix as the prefix for subsequent -iwithprefix options. If the prefix represents a directory, you should include the final
|-isysroot dir||This option is like the --sysroot option, but applies only to header files. See the --sysroot option for more information.|
|-iquote dir||Search dir only for header files requested with
|-isystem dir||Search dir for header files, after all directories specified by -I but before the standard system directories. Mark it as a system directory, so that it gets the same special treatment as is applied to the standard system directories. If dir begins with
|-nostdinc||Do not search the standard system directories for header files. Only the directories you have specified with -I options (and the directory of the current file, if appropriate) are searched.|
|-undef||Do not predefine any system-specific or GCC-specific macros. The standard predefined macros remain defined.|
|-Apredicate=answer||Make an assertion with the predicate predicate and answer answer. This form is preferred to the older form -A predicate(answer), which is still supported, because it does not use shell special characters.|
|-A-predicate=answer||Cancel an assertion with the predicate predicate and answer answer.|
|-C||Do not discard comments. All comments are passed through to the output file, except for comments in processed directives, which are deleted along with the directive.
You should be prepared for side effects when using -C; it causes the preprocessor to treat comments as tokens in their own right. For example, comments appearing at the start of what would be a directive line have the effect of turning that line into an ordinary source line, since the first token on the line is no longer a
Warning: this currently handles C-Style comments only. The preprocessor does not yet recognize Fortran-style comments.
|-CC||Do not discard comments, including during macro expansion. This is like -C, except that comments contained within macros are also passed through to the output file where the macro is expanded.
In addition to the side-effects of the -C option, the -CC option causes all C++-style comments inside a macro to be converted to C-style comments. This is to prevent later use of that macro from inadvertently commenting out the remainder of the source line. The -CC option is generally used to support lint comments.
Warning: this currently handles C- and C++-Style comments only. The preprocessor does not yet recognize Fortran-style comments.
|-Dname||Predefine name as a macro, with definition
|-Dname=definition||The contents of definition are tokenized and processed as if they appeared during translation phase three in a
If you are invoking the preprocessor from a shell or shell-like program you may need to use the shell’s quoting syntax to protect characters such as spaces that have a meaning in the shell syntax.
If you wish to define a function-like macro on the command line, write its argument list with surrounding parentheses before the equals sign (if any). Parentheses are meaningful to most shells, so you will need to quote the option. With sh and csh,
-D and -U options are processed in the order they are given on the command line. All -imacros file and -include file options are processed after all -D and -U options.
|-H||Print the name of each header file used, in addition to other normal activities. Each name is indented to show how deep in the
|-P||Inhibit generation of linemarkers in the output from the preprocessor. This might be useful when running the preprocessor on something that is not C code, and will be sent to a program which might be confused by the linemarkers.|
|-Uname||Cancel any previous definition of name, either built in or provided with a -D option.|
Options to request or suppress errors and warnings
Errors are diagnostic messages that report that the GNU Fortran compiler cannot compile the relevant piece of source code. The compiler will continue to process the program in an attempt to report further errors to aid in debugging, but will not produce any compiled output.
Some of these have no effect when compiling programs written in Fortran.
Warnings are diagnostic messages that report constructions which are not inherently erroneous but which are risky or suggest there is likely to be a bug in the program. Unless -Werror is specified, they do not prevent compilation of the program.
You can request many specific warnings with options beginning -W, for example -Wimplicit to request warnings on implicit declarations. Each of these specific warning options also has a negative form beginning -Wno- to turn off warnings; for example, -Wno-implicit. This manual lists only one of the two forms, whichever is not the default.
These options control the amount and kinds of errors and warnings produced by GNU Fortran:
|-fmax-errors=n||Limits the maximum number of error messages to n, at which point GNU Fortran bails out rather than attempting to continue processing the source code. If n is 0, there is no limit on the number of error messages produced.|
|-fsyntax-only||Check the code for syntax errors, but do not actually compile it. This will generate module files for each module present in the code, but no other output file.|
|-pedantic||Issue warnings for uses of extensions to Fortran. -pedantic also applies to C-language constructs where they occur in GNU Fortran source files, such as use of \e in a character constant within a directive like
Valid Fortran programs should compile properly with or without this option. However, without this option, certain GNU extensions and traditional Fortran features are supported as well. With this option, many of them are rejected.
Some users try to use -pedantic to check programs for conformance. They soon find that it does not do quite what they want---it finds some nonstandard practices, but not all. However, improvements to GNU Fortran in this area are welcome.
This should be used in conjunction with -std=f95, -std=f2003, -std=f2008 or -std=f2018.
|-pedantic-errors||Like -pedantic, except that errors are produced rather than warnings.|
|-Wall||Enables commonly used warning options pertaining to usage that we recommend avoiding and that we believe are easy to avoid. This currently includes -Waliasing, -Wampersand, -Wconversion, -Wsurprising, -Wc-binding-type, -Wintrinsics-std, -Wtabs, -Wintrinsic-shadow, -Wline-truncation, -Wtarget-lifetime, -Winteger-division, -Wreal-q-constant, -Wunused and -Wundefined-do-loop.|
|-Waliasing||Warn about possible aliasing of dummy arguments. Specifically, it warns if the same actual argument is associated with a dummy argument with
The following example will trigger the warning.
|-Wampersand||Warn about missing ampersand in continued character constants. The warning is given with -Wampersand, -pedantic, -std=f95, -std=f2003, -std=f2008 and -std=f2018. Note: With no ampersand given in a continued character constant, GNU Fortran assumes continuation at the first non-comment, non-whitespace character after the ampersand that initiated the continuation.|
|-Warray-temporaries||Warn about array temporaries generated by the compiler. The information generated by this warning is sometimes useful in optimization, in order to avoid such temporaries.|
|-Wc-binding-type||Warn if the a variable might not be C interoperable. In particular, warn if the variable has been declared using an intrinsic type with default kind instead of using a kind parameter defined for C interoperability in the intrinsic
|-Wcharacter-truncation||Warn when a character assignment will truncate the assigned string.|
|-Wline-truncation||Warn when a source code line will be truncated. This option is implied by -Wall. For free-form source code, the default is -Werror=line-truncation such that truncations are reported as error.|
|-Wconversion||Warn about implicit conversions that are likely to change the value of the expression after conversion. Implied by -Wall.|
|-Wconversion-extra||Warn about implicit conversions between different types and kinds. This option does not imply -Wconversion.|
|-Wextra||Enables some warning options for usages of language features which may be problematic. This currently includes -Wcompare-reals, -Wunused-parameter and -Wdo-subscript.|
|-Wfrontend-loop-interchange||Warn when using -ffrontend-loop-interchange for performing loop interchanges.|
|-Wimplicit-interface||Warn if a procedure is called without an explicit interface. Note this only checks that an explicit interface is present. It does not check that the declared interfaces are consistent across program units.|
|-Wimplicit-procedure||Warn if a procedure is called that has neither an explicit interface nor has been declared as
|-Winteger-division||Warn if a constant integer division truncates its result. As an example, 3/5 evaluates to 0.|
|-Wintrinsics-std||Warn if gfortran finds a procedure named like an intrinsic not available in the currently selected standard (with -std) and treats it as
|-Wno-overwrite-recursive||Do not warn when -fno-automatic is used with -frecursive. Recursion will be broken if the relevant local variables do not have the attribute
|-Wreal-q-constant||Produce a warning if a real-literal-constant contains a
|-Wsurprising||Produce a warning when suspicious code constructs are encountered. While technically legal these usually indicate that an error has been made.
This currently produces a warning under the following circumstances:
|-Wtabs||By default, tabs are accepted as whitespace, but tabs are not members of the Fortran Character Set. For continuation lines, a tab followed by a digit between 1 and 9 is supported. -Wtabs will cause a warning to be issued if a tab is encountered. Note, -Wtabs is active for -pedantic, -std=f95, -std=f2003, -std=f2008, -std=f2018 and -Wall.|
|-Wundefined-do-loop||Warn if a DO loop with step either 1 or -1 yields an underflow or an overflow during iteration of an induction variable of the loop. This option is implied by -Wall.|
|-Wunderflow||Produce a warning when numerical constant expressions are encountered, which yield an UNDERFLOW during compilation. Enabled by default.|
|-Wintrinsic-shadow||Warn if a user-defined procedure or module procedure has the same name as an intrinsic; in this case, an explicit interface or
|-Wuse-without-only||Warn if a
|-Wunused-dummy-argument||Warn about unused dummy arguments. This option is implied by -Wall.|
|-Wunused-parameter||Contrary to gcc’s meaning of -Wunused-parameter, gfortran’s implementation of this option does not warn about unused dummy arguments (see -Wunused-dummy-argument), but about unused
|-Walign-commons||By default, gfortran warns about any occasion of variables being padded for proper alignment inside a
|-Wfunction-elimination||Warn if any calls to impure functions are eliminated by the optimizations enabled by the -ffrontend-optimize option. This option is implied by -Wextra.|
|-Wrealloc-lhs||Warn when the compiler might insert code to for allocation or reallocation of an allocatable array variable of intrinsic type in intrinsic assignments. In hot loops, the Fortran 2003 reallocation feature may reduce the performance. If the array is already allocated with the correct shape, consider using a whole-array array-spec (e.g.
|-Wrealloc-lhs-all||Warn when the compiler inserts code to for allocation or reallocation of an allocatable variable; this includes scalars and derived types.|
|-Wcompare-reals||Warn when comparing real or complex types for equality or inequality. This option is implied by -Wextra.|
|-Wtarget-lifetime||Warn if the pointer in a pointer assignment might be longer than the its target. This option is implied by -Wall.|
|-Wzerotrip||Warn if a
|-Wdo-subscript||Warn if an array subscript inside a DO loop could lead to an out-of-bounds access even if the compiler cannot prove that the statement is actually executed, in cases like
This option is implied by -Wextra.
|-Werror||Turns all warnings into errors.|
Options for debugging your program or GNU Fortran
GNU Fortran has various special options that are used for debugging either your program or the GNU Fortran compiler.
|-fdump-fortran-original||Output the internal parse tree after translating the source program into internal representation. This option is mostly useful for debugging the GNU Fortran compiler itself. The output generated by this option might change between releases. This option may also generate internal compiler errors for features which have only recently been added.|
|-fdump-fortran-optimized||Output the parse tree after front-end optimization. Mostly useful for debugging the GNU Fortran compiler itself. The output generated by this option might change between releases. This option may also generate internal compiler errors for features which have only recently been added.|
|-fdump-parse-tree||Output the internal parse tree after translating the source program into internal representation. Mostly useful for debugging the GNU Fortran compiler itself. The output generated by this option might change between releases. This option may also generate internal compiler errors for features which have only recently been added. This option is deprecated; use
|-fdump-fortran-global||Output a list of the global identifiers after translating into middle-end representation. Mostly useful for debugging the GNU Fortran compiler itself. The output generated by this option might change between releases. This option may also generate internal compiler errors for features which have only recently been added.|
|-ffpe-trap=list||Specify a list of floating point exception traps to enable. On most systems, if a floating point exception occurs and the trap for that exception is enabled, a SIGFPE signal will be sent and the program being aborted, producing a core file useful for debugging. list is a (possibly empty) comma-separated list of the following exceptions: invalid (invalid floating point operation, such as
The first three exceptions (invalid, zero, and overflow) often indicate serious errors, and unless the program has provisions for dealing with these exceptions, enabling traps for these three exceptions is probably a good idea.
If the option is used more than once in the command line, the lists will be joined: ’
Note that once enabled an exception cannot be disabled (no negative form).
Many, if not most, floating point operations incur loss of precision due to rounding, and hence the
By default no exception traps are enabled.
|-ffpe-summary=list||Specify a list of floating-point exceptions, whose flag status is printed to
If the option is used more than once in the command line, only the last one will be used.
By default, a summary for all exceptions but inexact is shown.
|-fno-backtrace||When a serious runtime error is encountered or a deadly signal is emitted (segmentation fault, illegal instruction, bus error, floating-point exception, and the other POSIX signals that have the action core), the Fortran runtime library tries to output a backtrace of the error.
Options for directory search
These options affect how GNU Fortran searches for files specified by the
INCLUDEdirective and where it searches for previously compiled modules.
It also affects the search paths used by cpp when used to preprocess Fortran source.
|-Idir||These affect interpretation of the
Also note that the general behavior of -I and
This path is also used to search for .mod files when previously compiled modules are required by a
|-Jdir||This option specifies where to put .mod files for compiled modules. It is also added to the list of directories to searched by an
The default is the current directory.
|-fintrinsic-modules-path dir||This option specifies the location of pre-compiled intrinsic modules, if they are not in the default location expected by the compiler.|
Influencing the linking step
These options come into play when the compiler links object files into an executable output file. They are meaningless if the compiler is not doing a link step.
|-static-libgfortran||On systems that provide libgfortran as a shared and a static library, this option forces the use of the static version. If no shared version of libgfortran was built when the compiler was configured, this option has no effect.|
Influencing runtime behavior
These options affect the runtime behavior of programs compiled with GNU Fortran.
|-fconvert=conversion||Specify the representation of data for unformatted files. Valid values for conversion are: native, the default; swap, swap between big- and little-endian; big-endian, use big-endian representation for unformatted files; little-endian, use little-endian representation for unformatted files.
This option has an effect only when used in the main program. The
|-frecord-marker=length||Specify the length of record markers for unformatted files. Valid values for length are 4 and 8. Default is 4. This is different from previous versions of gfortran, which specified a default record marker length of 8 on most systems. If you want to read or write files compatible with earlier versions of gfortran, use -frecord-marker=8.|
|-fmax-subrecord-length=length||Specify the maximum length for a subrecord. The maximum permitted value for length is 2147483639, which is also the default. Only really useful for use by the gfortran testsuite.|
|-fsign-zero||When enabled, floating point numbers of value zero with the sign bit set are written as negative number in formatted output and treated as negative in the
Options for code generation conventions
These machine-independent options control the interface conventions used in code generation.
Most of them have both positive and negative forms; the negative form of -ffoo would be -fno-foo. In the table below, only one of the forms is listed---the one which is not the default. You can figure out the other form by either removing no- or adding it.
|-fno-automatic||Treat each program unit (except those marked as RECURSIVE) as if the
Local variables or arrays having an explicit
|-ff2c||Generate code designed to be compatible with code generated by g77 and f2c.
The calling conventions used by g77 (originally implemented in f2c) require functions that return type default
This does not affect the generation of code that interfaces with the libgfortran library.
Caution: It is not a good idea to mix Fortran code compiled with -ff2c with code compiled with the default -fno-f2c calling conventions as, calling
Caution: This will break code which passes intrinsic functions of type default
|-fno-underscoring||Do not transform names of entities specified in the Fortran source file by appending underscores to them.
With -funderscoring in effect, GNU Fortran appends one underscore to external names with no underscores. This is done to ensure compatibility with code produced by many UNIX Fortran compilers.
Caution: The default behavior of GNU Fortran is incompatible with f2c and g77, please use the -ff2c option if you want object files compiled with GNU Fortran to be compatible with object code created with these tools.
Use of -fno-underscoring is not recommended unless you are experimenting with issues such as integration of GNU Fortran into existing system environments (vis-a\k:`-vis existing libraries, tools, and so on).
For example, with -funderscoring, and assuming that
is implemented as something akin to:
With -fno-underscoring, the same statement is implemented as:
Use of -fno-underscoring allows direct specification of user-defined names while debugging and when interfacing GNU Fortran code with other languages.
Note that just because the names match does not mean that the interface implemented by GNU Fortran for an external name matches the interface implemented by some other language for that same name. That is, getting code produced by GNU Fortran to link to code produced by some other compiler using this or any other method can be only a small part of the overall solution---getting the code generated by both compilers to agree on issues other than naming can require significant effort, and, unlike naming disagreements, linkers normally cannot detect disagreements in these other areas.
Also, note that with -fno-underscoring, the lack of appended underscores introduces the very real possibility that a user-defined external name will conflict with a name in a system library, which could make finding unresolved-reference bugs quite difficult in some cases---they might occur at program run time, and show up only as buggy behavior at run time.
In future versions of GNU Fortran we hope to improve naming and linking issues so that debugging always involves using the names as they appear in the source, even if the names as seen by the linker are mangled to prevent accidental linking between procedures with incompatible interfaces.
|-fsecond-underscore||By default, GNU Fortran appends an underscore to external names. If this option is used GNU Fortran appends two underscores to names with underscores and one underscore to external names with no underscores. GNU Fortran also appends two underscores to internal names with underscores to avoid naming collisions with external names.
This option has no effect if -fno-underscoring is in effect. It is implied by the -ff2c option.
Otherwise, with this option, an external name such as
|-fcheck=<keyword>||Enable the generation of run-time checks; the argument shall be a comma-delimited list of the following keywords. Prefixing a check with no- disables it if it was activated by a previous specification.
Example: Assuming you have a file foo.f90, the command
will compile the file with all checks enabled as specified above except warnings for generated array temporaries.
|-fbounds-check||Deprecated alias for -fcheck=bounds.|
|-ftail-call-workaround=n||Some C interfaces to Fortran codes violate the gfortran ABI by omitting the hidden character length arguments as described in
This can lead to crashes because pushing arguments for tail calls can overflow the stack.
To provide a workaround for existing binary packages, this option disables tail call optimization for gfortran procedures with character arguments. With -ftail-call-workaround=2 tail call optimization is disabled in all gfortran procedures with character arguments, with -ftail-call-workaround=1 or equivalent -ftail-call-workaround only in gfortran procedures with character arguments that call implicitly prototyped procedures.
Using this option can lead to problems including crashes due to insufficient stack space.
It is very strongly recommended to fix the code in question. The -fc-prototypes-external option can be used to generate prototypes which conform to gfortran’s ABI, for inclusion in the source code.
Support for this option will likely be withdrawn in a future release of gfortran.
The negative form, -fno-tail-call-workaround or equivalent -ftail-call-workaround=0, can be used to disable this option.
Default is currently -ftail-call-workaround, this will change in future releases.
|-fcheck-array-temporaries||Deprecated alias for -fcheck=array-temps.|
|-fmax-array-constructor=n||This option can be used to increase the upper limit permitted in array constructors. The code below requires this option to expand the array at compile time.
Caution: This option can lead to long compile times and excessively large object files.
The default value for n is 65535.
|-fmax-stack-var-size=n||This option specifies the size in bytes of the largest array that will be put on the stack; if the size is exceeded static memory is used (except in procedures marked as RECURSIVE). Use the option -frecursive to allow for recursive procedures which do not have a RECURSIVE attribute or for parallel programs. Use -fno-automatic to never use the stack.
This option currently only affects local arrays declared with constant bounds, and may not apply to all character variables. Future versions of GNU Fortran may improve this behavior.
The default value for n is 65536.
|-fstack-arrays||Adding this option will make the Fortran compiler put all arrays of unknown size and array temporaries onto stack memory. If your program uses very large local arrays it is possible that you will have to extend your runtime limits for stack memory on some operating systems. This flag is enabled by default at optimization level -Ofast unless -fmax-stack-var-size is specified.|
|-fpack-derived||This option tells GNU Fortran to pack derived type members as closely as possible. Code compiled with this option is likely to be incompatible with code compiled without this option, and may execute slower.|
|-frepack-arrays||In some circumstances GNU Fortran may pass assumed shape array sections via a descriptor describing a noncontiguous area of memory. This option adds code to the function prologue to repack the data into a contiguous block at runtime.
This should result in faster accesses to the array. However it can introduce significant overhead to the function call, especially when the passed data is noncontiguous.
|-fshort-enums||This option is provided for interoperability with C code that was compiled with the -fshort-enums option. It will make GNU Fortran choose the smallest
|-finline-arg-packing||When passing an assumed-shape argument of a procedure as actual argument to an assumed-size or explicit size or as argument to a procedure that does not have an explicit interface, the argument may have to be packed, that is put into contiguous memory. An example is the call to
When -finline-arg-packing is in effect, this packing will be performed by inline code. This allows for more optimization while increasing code size.
-finline-arg-packing is implied by any of the -O options except when optimizing for size via -Os. If the code contains a very large number of argument that have to be packed, code size and also compilation time may become excessive. If that is the case, it may be better to disable this option. Instances of packing can be found by using by using -Warray-temporaries.
|-fexternal-blas||This option will make gfortran generate calls to BLAS functions for some matrix operations like
|-fblas-matmul-limit=n||Only significant when -fexternal-blas is in effect. Matrix multiplication of matrices with size larger than (or equal to) n will be performed by calls to BLAS functions, while others will be handled by gfortran internal algorithms. If the matrices involved are not square, the size comparison is performed using the geometric mean of the dimensions of the argument and result matrices.
The default value for n is 30.
|-finline-matmul-limit=n||When front-end optimiztion is active, some calls to the
The default value for n is 30. The
|-frecursive||Allow indirect recursion by forcing all local arrays to be allocated on the stack. This flag cannot be used together with -fmax-stack-var-size= or -fno-automatic.|
|-finit-character=n||The -finit-local-zero option instructs the compiler to initialize local
With -finit-derived, components of derived type variables will be initialized according to these flags. Components whose type is not covered by an explicit -finit-* flag will be treated as described above with -finit-local-zero.
These options do not initialize
(These limitations may be removed in future releases).
Note that the -finit-real=nan option initializes
The -finit-integer option will parse the value into an integer of type
Finally, note that enabling any of the -finit-* options will silence warnings that would have been emitted by -Wuninitialized for the affected local variables.
|-falign-commons||By default, gfortran enforces proper alignment of all variables in a
|-fno-protect-parens||By default the parentheses in expression are honored for all optimization levels such that the compiler does not do any re-association. Using -fno-protect-parens allows the compiler to reorder
|-frealloc-lhs||An allocatable left-hand side of an intrinsic assignment is automatically (re)allocated if it is either unallocated or has a different shape. The option is enabled by default except when -std=f95 is given. See also -Wrealloc-lhs.|
|-faggressive-function-elimination||Functions with identical argument lists are eliminated within statements, regardless of whether these functions are marked
there will only be a single call to
|-ffrontend-optimize||This option performs front-end optimization, based on manipulating parts the Fortran parse tree. Enabled by default by any -O option except -O0 and -Og. Optimizations enabled by this option include:
It can be deselected by specifying -fno-frontend-optimize.
|-ffrontend-loop-interchange||Attempt to interchange loops in the Fortran front end where profitable. Enabled by default by any -O option. At the moment, this option only affects
The gfortran compiler currently does not make use of any environment variables to control its operation above and beyond those that affect the operation of gcc.
For instructions on reporting bugs, see <file:///usr/share/doc/gcc-10/README.Bugs>.
See the Info entry for gfortran for contributors to GCC and GNU Fortran.
Copyright (c) 2004-2020 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being Funding Free Software, the Front-Cover Texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the gfdl(7) man page.
(a) The FSF’s Front-Cover Text is:
A GNU Manual
(b) The FSF’s Back-Cover Text is:
You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development.