📄 invoke.texi
字号:
@c Copyright (C) 2004, 2005@c Free Software Foundation, Inc.@c This is part of the GFORTRAN manual. @c For copying conditions, see the file gfortran.texi.@ignore@c man begin COPYRIGHTCopyright @copyright{} 2004, 2005Free Software Foundation, Inc.Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.2 orany later version published by the Free Software Foundation; with theInvariant Sections being ``GNU General Public License'' and ``FundingFree Software'', the Front-Cover texts being (a) (see below), and withthe Back-Cover Texts being (b) (see below). A copy of the license isincluded 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.@c man end@c Set file name and title for the man page.@setfilename gfortran@settitle GNU Fortran 95 compiler.@c man begin SYNOPSISgfortran [@option{-c}|@option{-S}|@option{-E}] [@option{-g}] [@option{-pg}] [@option{-O}@var{level}] [@option{-W}@var{warn}@dots{}] [@option{-pedantic}] [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}] [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}] [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}] [@option{-o} @var{outfile}] @var{infile}@dots{}Only the most useful options are listed here; see below for theremainder.@c man end@c man begin SEEALSOgpl(7), gfdl(7), fsf-funding(7),cpp(1), gcov(1), gcc(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1)and the Info entries for @file{gcc}, @file{cpp}, @file{gfortran}, @file{as},@file{ld}, @file{binutils} and @file{gdb}.@c man end@c man begin BUGSFor instructions on reporting bugs, see@w{@uref{http://gcc.gnu.org/bugs.html}}.@c man end@c man begin AUTHORSee the Info entry for @command{gfortran} for contributors to GCC andGFORTRAN@.@c man end@end ignore@node Invoking GFORTRAN@chapter GNU Fortran 95 Command Options@cindex GNU Fortran 95 command options@cindex command options@cindex options, GNU Fortran 95 command@c man begin DESCRIPTIONThe @command{gfortran} command supports all the options supported by the@command{gcc} command. Only options specific to gfortran are documented here.@xref{Invoking GCC,,GCC Command Options,gcc,Using the GNU CompilerCollection (GCC)}, for informationon the non-Fortran-specific aspects of the @command{gcc} command (and,therefore, the @command{gfortran} command).@cindex options, negative forms@cindex negative forms of optionsAll @command{gcc} and @command{gfortran} optionsare accepted both by @command{gfortran} and by @command{gcc}(as well as any other drivers built at the same time,such as @command{g++}),since adding @command{gfortran} to the @command{gcc} distributionenables acceptance of @command{gfortran} optionsby all of the relevant drivers.In some cases, options have positive and negative forms;the negative form of @option{-ffoo} would be @option{-fno-foo}.This manual documents only one of these two forms, whicheverone is not the default.@c man end@menu* Option Summary:: Brief list of all @command{gfortran} options, without explanations.* Fortran Dialect Options:: Controlling the variant of Fortran language compiled.* Warning Options:: How picky should the compiler be?* Debugging Options:: Symbol tables, measurements, and debugging dumps.* Directory Options:: Where to find module files* Runtime Options:: Influencing runtime behavior* Code Gen Options:: Specifying conventions for function calls, data layout and register usage.* Environment Variables:: Env vars that affect GNU Fortran.@end menu@node Option Summary@section Option Summary@c man begin OPTIONSHere is a summary of all the options specific to GNU Fortran, groupedby type. Explanations are in the following sections.@table @emph@item Fortran Language Options@xref{Fortran Dialect Options,,Options Controlling Fortran Dialect}.@gccoptlist{-ffree-form -fno-fixed-form @gol-fdollar-ok -fimplicit-none -fmax-identifier-length @gol-std=@var{std} -fd-lines-as-code -fd-lines-as-comments @gol-ffixed-line-length-@var{n} -ffixed-line-length-none @gol-ffree-line-length-@var{n} -ffree-line-length-none @gol-fdefault-double-8 -fdefault-integer-8 -fdefault-real-8 @gol-fcray-pointer }@item Warning Options@xref{Warning Options,,Options to Request or Suppress Warnings}.@gccoptlist{-fsyntax-only -pedantic -pedantic-errors @gol-w -Wall -Waliasing -Wconversion @gol-Wimplicit-interface -Wnonstd-intrinsics -Wsurprising -Wunderflow @gol-Wunused-labels -Wline-truncation -W}@item Debugging Options@xref{Debugging Options,,Options for Debugging Your Program or GCC}.@gccoptlist{-fdump-parse-tree -ffpe-trap=@var{list}}@item Directory Options@xref{Directory Options,,Options for Directory Search}.@gccoptlist{-I@var{dir} -M@var{dir}}@item Runtime Options@xref{Runtime Options,,Options for influencing runtime behavior}.@gccoptlist{-fconvert=@var{conversion}}@item Code Generation Options@xref{Code Gen Options,,Options for Code Generation Conventions}.@gccoptlist{-fno-automatic -ff2c -fno-underscoring -fsecond-underscore @gol-fbounds-check -fmax-stack-var-size=@var{n} @gol-fpackderived -frepack-arrays -fshort-enums}@end table@menu* Fortran Dialect Options:: Controlling the variant of Fortran language compiled.* Warning Options:: How picky should the compiler be?* Debugging Options:: Symbol tables, measurements, and debugging dumps.* Directory Options:: Where to find module files* Runtime Options:: Influencing runtime behavior* Code Gen Options:: Specifying conventions for function calls, data layout and register usage.@end menu@node Fortran Dialect Options@section Options Controlling Fortran Dialect@cindex dialect options@cindex language, dialect options@cindex options, dialectThe following options control the dialect of Fortranthat the compiler accepts:@table @gcctabopt@cindex -ffree-form option@cindex options, -ffree-form@cindex -fno-fixed-form option@cindex options, -fno-fixed-form@cindex source file format@cindex free form@cindex fixed form@cindex Source Form@cindex Fortran 90, features@item -ffree-form@item -ffixed-formSpecify the layout used by the source file. The free form layoutwas introduced in Fortran 90. Fixed form was traditionally used inolder Fortran programs.@cindex option, -fd-lines-as-code@cindex -fd-lines-as-code, option@cindex option, -fd-lines-as-comments@cindex -fd-lines-as-comments, option@item -fd-lines-as-code@item -fd-lines-as-commentEnables special treating for lines with @samp{d} or @samp{D} in fixedform sources. If the @option{-fd-lines-as-code} option is giventhey are treated as if the first column contained a blank. If the@option{-fd-lines-as-comments} option is given, they are treated ascomment lines.@cindex option, -fdefault-double-8@cindex -fdefault-double-8, option@item -fdefault-double-8Set the "DOUBLE PRECISION" type to an 8 byte wide.@cindex option, -fdefault-integer-8@cindex -fdefault-integer-8, option@item -fdefault-integer-8Set the default integer and logical types to an 8 byte wide type.Do nothing if this is already the default.@cindex option, -fdefault-real-8@cindex -fdefault-real-8, option@item -fdefault-real-8Set the default real type to an 8 byte wide type.Do nothing if this is already the default.@cindex -fdollar-ok option@cindex options, -fdollar-ok@item -fdollar-ok@cindex dollar sign@cindex symbol names@cindex character setAllow @samp{$} as a valid character in a symbol name.@cindex -fno-backslash option@cindex options, -fno-backslash@item -fno-backslash@cindex backslash@cindex escape charactersCompile switch to change the interpretation of a backslash from``C''-style escape characters to a single backslash character.@cindex -ffixed-line-length-@var{n} option@cindex options, -ffixed-line-length-@var{n}@item -ffixed-line-length-@var{n}@cindex source file format@cindex lines, length@cindex length of source lines@cindex fixed form@cindex limits, lengths of source linesSet column after which characters are ignored in typical fixed-formlines in the source file, and through which spaces are assumed (asif padded to that length) after the ends of short fixed-form lines.@cindex card image@cindex extended-source optionPopular values for @var{n} include 72 (thestandard and the default), 80 (card image), and 132 (correspondsto ``extended-source'' options in some popular compilers).@var{n} may be @samp{none}, meaning that the entire line is meaningfuland that continued character constants never have implicit spaces appendedto them to fill out the line.@option{-ffixed-line-length-0} means the same thing as@option{-ffixed-line-length-none}.@cindex -ffree-line-length-@var{n} option@cindex options, -ffree-line-length-@var{n}@item -ffree-line-length-@var{n}@cindex source file format@cindex lines, length@cindex length of source lines@cindex free form@cindex limits, lengths of source linesSet column after which characters are ignored in typical free-formlines in the source file. For free-form, the default value is 132.@var{n} may be @samp{none}, meaning that the entire line is meaningful.@option{-ffree-line-length-0} means the same thing as@option{-ffree-line-length-none}.@cindex -fmax-identifier-length=@var{n} option@cindex option -fmax-identifier-length=@var{n}@item -fmax-identifier-length=@var{n}Specify the maximum allowed identifier length. Typical values are31 (Fortran 95) and 63 (Fortran 200x).@cindex -fimplicit-none option@cindex options, -fimplicit-none@item -fimplicit-noneSpecify that no implicit typing is allowed, unless overridden by explicit@samp{IMPLICIT} statements. This is the equivalent of adding@samp{implicit none} to the start of every procedure.@cindex -fcray-pointer option@cindex options, -fcray-pointer@item -fcray-pointerEnables the Cray pointer extension, which provides a C-like pointer.@cindex -std=@var{std} option@cindex option, -std=@var{std}@item -std=@var{std}Conform to the specified standard. Allowed values for @var{std} are@samp{gnu}, @samp{f95}, @samp{f2003} and @samp{legacy}.@end table@node Warning Options@section Options to Request or Suppress Warnings@cindex options, warnings@cindex warnings, suppressing@cindex messages, warning@cindex suppressing warningsWarnings are diagnostic messages that report constructions whichare not inherently erroneous but which are risky or suggest theremight have been an error.You can request many specific warnings with options beginning @option{-W},for example @option{-Wimplicit} to request warnings on implicitdeclarations. Each of these specific warning options also has anegative form beginning @option{-Wno-} to turn off warnings;for example, @option{-Wno-implicit}. This manual lists only one of thetwo forms, whichever is not the default.These options control the amount and kinds of warnings produced by GNUFortran:@table @gcctabopt@cindex syntax checking@cindex -fsyntax-only option@cindex options, -fsyntax-only@item -fsyntax-onlyCheck the code for syntax errors, but don't do anything beyond that.@cindex -pedantic option@cindex options, -pedantic@item -pedanticIssue warnings for uses of extensions to FORTRAN 95.@option{-pedantic} also applies to C-language constructs where theyoccur in GNU Fortran source files, such as use of @samp{\e} in acharacter constant within a directive like @samp{#include}.Valid FORTRAN 95 programs should compile properly with or withoutthis option.However, without this option, certain GNU extensions and traditionalFortran features are supported as well.With this option, many of them are rejected.Some users try to use @option{-pedantic} to check programs for conformance.They soon find that it does not do quite what they want---it finds somenonstandard practices, but not all.However, improvements to @command{gfortran} in this area are welcome.This should be used in conjunction with -std=@var{std}.@cindex -pedantic-errors option@cindex options, -pedantic-errors@item -pedantic-errorsLike @option{-pedantic}, except that errors are produced rather thanwarnings.@cindex -w option@cindex options, -w@item -wInhibit all warning messages.@cindex -Wall option@cindex options, -Wall@item -Wall@cindex all warnings@cindex warnings, allEnables commonly used warning options that which pertain to usage thatwe recommend avoiding and that we believe is easy to avoid.This currently includes @option{-Wunused-labels}, @option{-Waliasing},@option{-Wsurprising}, @option{-Wnonstd-intrinsic} and@option{-Wline-truncation}.@cindex -Waliasing option@cindex options, -Waliasing@item -Waliasing@cindex aliasingWarn about possible aliasing of dummy arguments. Specifically, it warnsif the same actual argument is associated with a dummy argument with@code{intent(in)} and a dummy argument with @code{intent(out)} in a callwith an explicit interface.The following example will trigger the warning.@smallexample interface subroutine bar(a,b) integer, intent(in) :: a integer, intent(out) :: b end subroutine end interface integer :: a call bar(a,a)@end smallexample@cindex -Wconversion option@cindex options, -Wconversion@item -Wconversion@cindex conversionWarn about implicit conversions between different types.@cindex -Wimplicit-interface option@cindex options, -Wimplicit-interface@item -Wimplicit-interfaceWarn about when procedure are called without an explicit interface.Note this only checks that an explicit interface is present. It does notcheck that the declared interfaces are consistent across program units.@cindex -Wnonstd-intrinsic option@cindex options, -Wnonstd-intrinsic
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -