]> gcc.gnu.org Git - gcc.git/blame - gcc/fortran/invoke.texi
re PR fortran/32634 (renamed, use associated generic interface rejected)
[gcc.git] / gcc / fortran / invoke.texi
CommitLineData
2553e4e0 1@c Copyright (C) 2004, 2005, 2006, 2007
6de9cd9a 2@c Free Software Foundation, Inc.
7fc15ba5 3@c This is part of the GNU Fortran manual.
6de9cd9a
DN
4@c For copying conditions, see the file gfortran.texi.
5
6@ignore
7@c man begin COPYRIGHT
5f9a37a6 8Copyright @copyright{} 2004, 2005, 2006, 2007
6de9cd9a
DN
9Free Software Foundation, Inc.
10
11Permission is granted to copy, distribute and/or modify this document
12under the terms of the GNU Free Documentation License, Version 1.2 or
13any later version published by the Free Software Foundation; with the
14Invariant Sections being ``GNU General Public License'' and ``Funding
15Free Software'', the Front-Cover texts being (a) (see below), and with
16the Back-Cover Texts being (b) (see below). A copy of the license is
17included in the gfdl(7) man page.
18
19(a) The FSF's Front-Cover Text is:
20
21 A GNU Manual
22
23(b) The FSF's Back-Cover Text is:
24
25 You have freedom to copy and modify this GNU Manual, like GNU
26 software. Copies published by the Free Software Foundation raise
27 funds for GNU development.
28@c man end
29@c Set file name and title for the man page.
30@setfilename gfortran
7fc15ba5 31@settitle GNU Fortran compiler.
6de9cd9a
DN
32@c man begin SYNOPSIS
33gfortran [@option{-c}|@option{-S}|@option{-E}]
34 [@option{-g}] [@option{-pg}] [@option{-O}@var{level}]
35 [@option{-W}@var{warn}@dots{}] [@option{-pedantic}]
36 [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
37 [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}]
38 [@option{-f}@var{option}@dots{}]
39 [@option{-m}@var{machine-option}@dots{}]
40 [@option{-o} @var{outfile}] @var{infile}@dots{}
41
42Only the most useful options are listed here; see below for the
43remainder.
44@c man end
45@c man begin SEEALSO
46gpl(7), gfdl(7), fsf-funding(7),
47cpp(1), gcov(1), gcc(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1)
48and the Info entries for @file{gcc}, @file{cpp}, @file{gfortran}, @file{as},
49@file{ld}, @file{binutils} and @file{gdb}.
50@c man end
51@c man begin BUGS
52For instructions on reporting bugs, see
53@w{@uref{http://gcc.gnu.org/bugs.html}}.
54@c man end
55@c man begin AUTHOR
56See the Info entry for @command{gfortran} for contributors to GCC and
7fc15ba5 57GNU Fortran.
6de9cd9a
DN
58@c man end
59@end ignore
60
7fc15ba5
BM
61@node Invoking GNU Fortran
62@chapter GNU Fortran Command Options
63@cindex GNU Fortran command options
6de9cd9a 64@cindex command options
7fc15ba5 65@cindex options, @command{gfortran} command
6de9cd9a
DN
66
67@c man begin DESCRIPTION
68
69The @command{gfortran} command supports all the options supported by the
7fc15ba5 70@command{gcc} command. Only options specific to GNU Fortran are documented here.
6de9cd9a
DN
71
72@xref{Invoking GCC,,GCC Command Options,gcc,Using the GNU Compiler
73Collection (GCC)}, for information
74on the non-Fortran-specific aspects of the @command{gcc} command (and,
75therefore, the @command{gfortran} command).
76
77@cindex options, negative forms
7fc15ba5 78All GCC and GNU Fortran options
6de9cd9a
DN
79are accepted both by @command{gfortran} and by @command{gcc}
80(as well as any other drivers built at the same time,
81such as @command{g++}),
7fc15ba5
BM
82since adding GNU Fortran to the GCC distribution
83enables acceptance of GNU Fortran options
6de9cd9a
DN
84by all of the relevant drivers.
85
86In some cases, options have positive and negative forms;
87the negative form of @option{-ffoo} would be @option{-fno-foo}.
88This manual documents only one of these two forms, whichever
89one is not the default.
90@c man end
91
92@menu
93* Option Summary:: Brief list of all @command{gfortran} options,
94 without explanations.
95* Fortran Dialect Options:: Controlling the variant of Fortran language
96 compiled.
592600ce 97* Error and Warning Options:: How picky should the compiler be?
6de9cd9a
DN
98* Debugging Options:: Symbol tables, measurements, and debugging dumps.
99* Directory Options:: Where to find module files
eaa90d25 100* Runtime Options:: Influencing runtime behavior
6de9cd9a
DN
101* Code Gen Options:: Specifying conventions for function calls, data layout
102 and register usage.
7fc15ba5 103* Environment Variables:: Env vars that affect @command{gfortran}.
6de9cd9a
DN
104@end menu
105
106@node Option Summary
107@section Option Summary
108
109@c man begin OPTIONS
110
111Here is a summary of all the options specific to GNU Fortran, grouped
112by type. Explanations are in the following sections.
113
114@table @emph
115@item Fortran Language Options
116@xref{Fortran Dialect Options,,Options Controlling Fortran Dialect}.
592600ce 117@gccoptlist{-fall-intrinsics -ffree-form -fno-fixed-form @gol
6de9cd9a 118-fdollar-ok -fimplicit-none -fmax-identifier-length @gol
592600ce 119-std=@var{std} -fd-lines-as-code -fd-lines-as-comments @gol
6de9cd9a 120-ffixed-line-length-@var{n} -ffixed-line-length-none @gol
16ab8e74 121-ffree-line-length-@var{n} -ffree-line-length-none @gol
83d890b9 122-fdefault-double-8 -fdefault-integer-8 -fdefault-real-8 @gol
eedeea04 123-fcray-pointer -fopenmp -frange-check -fno-backslash }
6de9cd9a 124
592600ce
BM
125@item Error and Warning Options
126@xref{Error and Warning Options,,Options to Request or Suppress Errors
127and Warnings}.
128@gccoptlist{-fmax-errors=@var{n} @gol
6de9cd9a 129-fsyntax-only -pedantic -pedantic-errors @gol
276419d0
BM
130-w -Wall -Waliasing -Wampersand -Wcharacter-truncation -Wconversion @gol
131-Wimplicit-interface -Wline-truncation -Wnonstd-intrinsics -Wsurprising @gol
132-Wno-tabs -Wunderflow -W}
6de9cd9a
DN
133
134@item Debugging Options
135@xref{Debugging Options,,Options for Debugging Your Program or GCC}.
868d75db
FXC
136@gccoptlist{-fdump-parse-tree -ffpe-trap=@var{list} @gol
137-fdump-core -fbacktrace}
6de9cd9a
DN
138
139@item Directory Options
140@xref{Directory Options,,Options for Directory Search}.
276419d0 141@gccoptlist{-I@var{dir} -J@var{dir} -M@var{dir} -fintrinsic-modules-path @var{dir}}
6de9cd9a 142
eaa90d25
TK
143@item Runtime Options
144@xref{Runtime Options,,Options for influencing runtime behavior}.
276419d0
BM
145@gccoptlist{-fconvert=@var{conversion} -frecord-marker=@var{length} @gol
146-fmax-subrecord-length=@var{length}}
eaa90d25 147
6de9cd9a
DN
148@item Code Generation Options
149@xref{Code Gen Options,,Options for Code Generation Conventions}.
592600ce
BM
150@gccoptlist{-fno-automatic -ff2c -fno-underscoring
151-fsecond-underscore @gol
6de9cd9a 152-fbounds-check -fmax-stack-var-size=@var{n} @gol
592600ce 153-fpack-derived -frepack-arrays -fshort-enums -fexternal-blas @gol
5a0aad31 154-fblas-matmul-limit=@var{n}}
6de9cd9a
DN
155@end table
156
6de9cd9a
DN
157@menu
158* Fortran Dialect Options:: Controlling the variant of Fortran language
159 compiled.
592600ce 160* Error and Warning Options:: How picky should the compiler be?
6de9cd9a
DN
161* Debugging Options:: Symbol tables, measurements, and debugging dumps.
162* Directory Options:: Where to find module files
eaa90d25 163* Runtime Options:: Influencing runtime behavior
6de9cd9a
DN
164* Code Gen Options:: Specifying conventions for function calls, data layout
165 and register usage.
166@end menu
167
168@node Fortran Dialect Options
169@section Options Controlling Fortran Dialect
170@cindex dialect options
171@cindex language, dialect options
172@cindex options, dialect
173
3397327c
BM
174The following options control the details of the Fortran dialect
175accepted by the compiler:
6de9cd9a
DN
176
177@table @gcctabopt
4ba96c02
BM
178@item -ffree-form
179@item -ffixed-form
32864778
DF
180@opindex @code{ffree-form}
181@opindex @code{fno-fixed-form}
182@cindex options, fortran dialect
e739dfac
DF
183@cindex file format, free
184@cindex file format, fixed
49de9e73 185Specify the layout used by the source file. The free form layout
6de9cd9a 186was introduced in Fortran 90. Fixed form was traditionally used in
3397327c
BM
187older Fortran programs. When neither option is specified, the source
188form is determined by the file extension.
6de9cd9a 189
a23eec13 190@item -fall-intrinsics
32864778 191@opindex @code{fall-intrinsics}
a23eec13
SK
192Accept all of the intrinsic procedures provided in libgfortran
193without regard to the setting of @option{-std}. In particular,
08f36673 194this option can be quite useful with @option{-std=f95}. Additionally,
7fc15ba5 195@command{gfortran} will ignore @option{-Wnonstd-intrinsics}.
a23eec13 196
e0bcf78c 197@item -fd-lines-as-code
259b41c1 198@item -fd-lines-as-comments
32864778
DF
199@opindex @code{fd-lines-as-code}
200@opindex @code{fd-lines-as-comments}
4ba96c02 201Enable special treatment for lines beginning with @code{d} or @code{D}
3397327c
BM
202in fixed form sources. If the @option{-fd-lines-as-code} option is
203given they are treated as if the first column contained a blank. If the
e0bcf78c
TS
204@option{-fd-lines-as-comments} option is given, they are treated as
205comment lines.
206
3ae9eb27 207@item -fdefault-double-8
32864778 208@opindex @code{fdefault-double-8}
3397327c 209Set the @code{DOUBLE PRECISION} type to an 8 byte wide type.
3ae9eb27 210
3ae9eb27 211@item -fdefault-integer-8
32864778 212@opindex @code{fdefault-integer-8}
3ae9eb27
SK
213Set the default integer and logical types to an 8 byte wide type.
214Do nothing if this is already the default.
215
3ae9eb27 216@item -fdefault-real-8
32864778 217@opindex @code{fdefault-real-8}
3ae9eb27
SK
218Set the default real type to an 8 byte wide type.
219Do nothing if this is already the default.
220
6de9cd9a 221@item -fdollar-ok
32864778 222@opindex @code{fdollar-ok}
e739dfac 223@cindex $
6de9cd9a
DN
224@cindex symbol names
225@cindex character set
226Allow @samp{$} as a valid character in a symbol name.
227
131c66cd 228@item -fno-backslash
32864778 229@opindex @code{fno-backslash}
131c66cd
FXC
230@cindex backslash
231@cindex escape characters
3397327c
BM
232Change the interpretation of backslashes in string literals from
233``C-style'' escape characters to a single backslash character.
131c66cd 234
6de9cd9a 235@item -ffixed-line-length-@var{n}
32864778 236@opindex @code{ffixed-line-length-}@var{n}
e739dfac 237@cindex file format, fixed
6de9cd9a
DN
238Set column after which characters are ignored in typical fixed-form
239lines in the source file, and through which spaces are assumed (as
240if padded to that length) after the ends of short fixed-form lines.
241
6de9cd9a 242Popular values for @var{n} include 72 (the
3397327c 243standard and the default), 80 (card image), and 132 (corresponding
6de9cd9a 244to ``extended-source'' options in some popular compilers).
3397327c 245@var{n} may also be @samp{none}, meaning that the entire line is meaningful
6de9cd9a
DN
246and that continued character constants never have implicit spaces appended
247to them to fill out the line.
248@option{-ffixed-line-length-0} means the same thing as
249@option{-ffixed-line-length-none}.
250
16ab8e74 251@item -ffree-line-length-@var{n}
32864778 252@opindex @code{ffree-line-length-}@var{n}
e739dfac 253@cindex file format, free
16ab8e74 254Set column after which characters are ignored in typical free-form
3397327c 255lines in the source file. The default value is 132.
16ab8e74
BF
256@var{n} may be @samp{none}, meaning that the entire line is meaningful.
257@option{-ffree-line-length-0} means the same thing as
258@option{-ffree-line-length-none}.
259
6de9cd9a 260@item -fmax-identifier-length=@var{n}
32864778 261@opindex @code{fmax-identifier-length=}@var{n}
6de9cd9a 262Specify the maximum allowed identifier length. Typical values are
3397327c 26331 (Fortran 95) and 63 (Fortran 2003).
6de9cd9a 264
6de9cd9a 265@item -fimplicit-none
32864778 266@opindex @code{fimplicit-none}
6de9cd9a 267Specify that no implicit typing is allowed, unless overridden by explicit
40746dcc
BM
268@code{IMPLICIT} statements. This is the equivalent of adding
269@code{implicit none} to the start of every procedure.
6de9cd9a 270
83d890b9 271@item -fcray-pointer
32864778 272@opindex @code{fcray-pointer}
3397327c
BM
273Enable the Cray pointer extension, which provides C-like pointer
274functionality.
83d890b9 275
6c7a4dfd 276@item -fopenmp
32864778 277@opindex @code{fopenmp}
4e8b3590 278@cindex OpenMP
3397327c
BM
279Enable the OpenMP extensions. This includes OpenMP @code{!$omp} directives
280in free form
6c7a4dfd 281and @code{c$omp}, @code{*$omp} and @code{!$omp} directives in fixed form,
3397327c
BM
282@code{!$} conditional compilation sentinels in free form
283and @code{c$}, @code{*$} and @code{!$} sentinels in fixed form,
6c7a4dfd
JJ
284and when linking arranges for the OpenMP runtime library to be linked
285in.
286
54554825 287@item -frange-check
32864778 288@opindex @code{frange-check}
40746dcc
BM
289Enable range checking on results of simplification of constant
290expressions during compilation. For example, by default, GNU Fortran
291will give an overflow error at compile time when simplifying @code{a =
292EXP(1000)}. With @option{-fno-range-check}, no error will be given and
293the variable @code{a} will be assigned the value @code{+Infinity}.
294Similarly, @code{DATA i/Z'FFFFFFFF'/} will result in an integer overflow
295on most systems, but with @option{-fno-range-check} the value will
296``wrap around'' and @code{i} will be initialized to @math{-1} instead.
54554825 297
6de9cd9a 298@item -std=@var{std}
32864778 299@opindex @code{std=}@var{std} option
276419d0
BM
300Specify the standard to which the program is expected to conform, which
301may be one of @samp{f95}, @samp{f2003}, @samp{gnu}, or @samp{legacy}.
302The default value for @var{std} is @samp{gnu}, which specifies a
303superset of the Fortran 95 standard that includes all of the extensions
304supported by GNU Fortran, although warnings will be given for obsolete
305extensions not recommended for use in new code. The @samp{legacy} value
306is equivalent but without the warnings for obsolete extensions, and may
307be useful for old non-standard programs. The @samp{f95} and
308@samp{f2003} values specify strict conformance to the Fortran 95 and
309Fortran 2003 standards, respectively; errors are given for all
310extensions beyond the relevant language standard, and warnings are given
311for the Fortran 77 features that are permitted but obsolescent in later
312standards.
6de9cd9a 313
6de9cd9a
DN
314@end table
315
592600ce
BM
316@node Error and Warning Options
317@section Options to Request or Suppress Errors and Warnings
6de9cd9a 318@cindex options, warnings
592600ce 319@cindex options, errors
6de9cd9a 320@cindex warnings, suppressing
592600ce 321@cindex messages, error
6de9cd9a
DN
322@cindex messages, warning
323@cindex suppressing warnings
324
592600ce
BM
325Errors are diagnostic messages that report that the GNU Fortran compiler
326cannot compile the relevant piece of source code. The compiler will
327continue to process the program in an attempt to report further errors
328to aid in debugging, but will not produce any compiled output.
329
6de9cd9a 330Warnings are diagnostic messages that report constructions which
592600ce 331are not inherently erroneous but which are risky or suggest there is
4ba96c02 332likely to be a bug in the program. Unless @option{-Werror} is specified,
592600ce 333they do not prevent compilation of the program.
6de9cd9a
DN
334
335You can request many specific warnings with options beginning @option{-W},
336for example @option{-Wimplicit} to request warnings on implicit
337declarations. Each of these specific warning options also has a
338negative form beginning @option{-Wno-} to turn off warnings;
339for example, @option{-Wno-implicit}. This manual lists only one of the
340two forms, whichever is not the default.
341
592600ce
BM
342These options control the amount and kinds of errors and warnings produced
343by GNU Fortran:
6de9cd9a
DN
344
345@table @gcctabopt
592600ce 346@item -fmax-errors-@var{n}
32864778 347@opindex @code{fmax-errors-}@var{n}
4ba96c02 348@cindex errors, limiting
592600ce
BM
349Limits the maximum number of error messages to @var{n}, at which point
350GNU Fortran bails out rather than attempting to continue processing the
351source code. If @var{n} is 0, there is no limit on the number of error
352messages produced.
353
6de9cd9a 354@item -fsyntax-only
32864778 355@opindex @code{fsyntax-only}
4ba96c02 356@cindex syntax checking
6de9cd9a
DN
357Check the code for syntax errors, but don't do anything beyond that.
358
6de9cd9a 359@item -pedantic
32864778 360@opindex @code{pedantic}
7fc15ba5 361Issue warnings for uses of extensions to Fortran 95.
6de9cd9a
DN
362@option{-pedantic} also applies to C-language constructs where they
363occur in GNU Fortran source files, such as use of @samp{\e} in a
40746dcc 364character constant within a directive like @code{#include}.
6de9cd9a 365
7fc15ba5 366Valid Fortran 95 programs should compile properly with or without
6de9cd9a
DN
367this option.
368However, without this option, certain GNU extensions and traditional
369Fortran features are supported as well.
370With this option, many of them are rejected.
371
372Some users try to use @option{-pedantic} to check programs for conformance.
373They soon find that it does not do quite what they want---it finds some
374nonstandard practices, but not all.
7fc15ba5 375However, improvements to GNU Fortran in this area are welcome.
6de9cd9a 376
4ba96c02
BM
377This should be used in conjunction with @option{-std=f95} or
378@option{-std=f2003}.
6de9cd9a 379
6de9cd9a 380@item -pedantic-errors
32864778 381@opindex @code{pedantic-errors}
6de9cd9a
DN
382Like @option{-pedantic}, except that errors are produced rather than
383warnings.
384
6de9cd9a 385@item -w
32864778
DF
386@opindex @code{w}
387@cindex warnings, none
6de9cd9a
DN
388Inhibit all warning messages.
389
6de9cd9a 390@item -Wall
32864778 391@opindex @code{Wall}
6de9cd9a
DN
392@cindex all warnings
393@cindex warnings, all
3fbab549
JD
394Enables commonly used warning options pertaining to usage that
395we recommend avoiding and that we believe are easy to avoid.
2e5758e8 396This currently includes @option{-Waliasing},
276419d0 397@option{-Wampersand}, @option{-Wsurprising}, @option{-Wnonstd-intrinsics},
3fbab549 398@option{-Wno-tabs}, and @option{-Wline-truncation}.
6de9cd9a 399
6de9cd9a 400@item -Waliasing
32864778 401@opindex @code{Waliasing}
6de9cd9a 402@cindex aliasing
32864778 403@cindex warnings, aliasing
3010be13
AD
404Warn about possible aliasing of dummy arguments. Specifically, it warns
405if the same actual argument is associated with a dummy argument with
40746dcc 406@code{INTENT(IN)} and a dummy argument with @code{INTENT(OUT)} in a call
3010be13
AD
407with an explicit interface.
408
409The following example will trigger the warning.
6de9cd9a 410@smallexample
3010be13
AD
411 interface
412 subroutine bar(a,b)
413 integer, intent(in) :: a
414 integer, intent(out) :: b
415 end subroutine
416 end interface
417 integer :: a
418
419 call bar(a,a)
6de9cd9a
DN
420@end smallexample
421
3fbab549 422@item -Wampersand
32864778
DF
423@opindex @code{Wampersand}
424@cindex warnings, ampersand
e739dfac 425@cindex &
3fbab549
JD
426Warn about missing ampersand in continued character constants. The warning is
427given with @option{-Wampersand}, @option{-pedantic}, @option{-std=f95}, and
428@option{-std=f2003}. Note: With no ampersand given in a continued character
7fc15ba5 429constant, GNU Fortran assumes continuation at the first non-comment,
3fbab549
JD
430non-whitespace character after the ampersand that initiated the continuation.
431
276419d0 432@item -Wcharacter-truncation
32864778
DF
433@opindex @code{Wcharacter-truncation}
434@cindex warnings, character truncation
276419d0
BM
435Warn when a character assignment will truncate the assigned string.
436
6de9cd9a 437@item -Wconversion
32864778
DF
438@opindex @code{Wconversion}
439@cindex warnings, conversion
6de9cd9a
DN
440@cindex conversion
441Warn about implicit conversions between different types.
442
6de9cd9a 443@item -Wimplicit-interface
32864778
DF
444@opindex @code{Wimplicit-interface}
445@cindex warnings, implicit interface
02712c16 446Warn if a procedure is called without an explicit interface.
6de9cd9a
DN
447Note this only checks that an explicit interface is present. It does not
448check that the declared interfaces are consistent across program units.
449
276419d0 450@item -Wnonstd-intrinsics
32864778
DF
451@opindex @code{Wnonstd-intrinsics}
452@cindex warnings, non-stdandard intrinsics
b7892582 453Warn if the user tries to use an intrinsic that does not belong to the
276419d0 454standard the user has chosen via the @option{-std} option.
b7892582 455
6de9cd9a 456@item -Wsurprising
32864778
DF
457@opindex @code{Wsurprising}
458@cindex warnings, suspicious code
2d8b59df
SK
459Produce a warning when ``suspicious'' code constructs are encountered.
460While technically legal these usually indicate that an error has been made.
6de9cd9a
DN
461
462This currently produces a warning under the following circumstances:
463
464@itemize @bullet
465@item
ffd1953e
FXC
466An INTEGER SELECT construct has a CASE that can never be matched as its
467lower value is greater than its upper value.
6de9cd9a
DN
468
469@item
470A LOGICAL SELECT construct has three CASE statements.
471@end itemize
472
840bd9f7 473@item -Wtabs
32864778
DF
474@opindex @code{Wtabs}
475@cindex warnings, tabs
e739dfac 476@cindex tabulators
840bd9f7
SK
477By default, tabs are accepted as whitespace, but tabs are not members
478of the Fortran Character Set. @option{-Wno-tabs} will cause a warning
479to be issued if a tab is encountered. Note, @option{-Wno-tabs} is active
8135cfa8
SK
480for @option{-pedantic}, @option{-std=f95}, @option{-std=f2003}, and
481@option{-Wall}.
840bd9f7 482
2d8b59df 483@item -Wunderflow
32864778
DF
484@opindex @code{Wunderflow}
485@cindex warnings, underflow
486@cindex underflow
2d8b59df
SK
487Produce a warning when numerical constant expressions are
488encountered, which yield an UNDERFLOW during compilation.
489
6de9cd9a 490@item -Werror
32864778
DF
491@opindex @code{Werror}
492@cindex warnings, to errors
6de9cd9a
DN
493Turns all warnings into errors.
494
6de9cd9a 495@item -W
32864778 496@opindex @code{W}
6de9cd9a 497@cindex warnings, extra
32864778 498@cindex extra warnings
6de9cd9a
DN
499Turns on ``extra warnings'' and, if optimization is specified
500via @option{-O}, the @option{-Wuninitialized} option.
7fc15ba5 501(This might change in future versions of GNU Fortran.)
6de9cd9a
DN
502@end table
503
592600ce
BM
504@xref{Error and Warning Options,,Options to Request or Suppress Errors and
505Warnings, gcc,Using the GNU Compiler Collection (GCC)}, for information on
506more options offered by the GBE shared by @command{gfortran}, @command{gcc}
507and other GNU compilers.
6de9cd9a
DN
508
509Some of these have no effect when compiling programs written in Fortran.
510
511@node Debugging Options
512@section Options for Debugging Your Program or GNU Fortran
513@cindex options, debugging
514@cindex debugging information options
515
516GNU Fortran has various special options that are used for debugging
7fc15ba5 517either your program or the GNU Fortran compiler.
6de9cd9a
DN
518
519@table @gcctabopt
6de9cd9a 520@item -fdump-parse-tree
32864778 521@opindex @code{fdump-parse-tree}
6de9cd9a 522Output the internal parse tree before starting code generation. Only
7fc15ba5 523really useful for debugging the GNU Fortran compiler itself.
6de9cd9a 524
944b8b35 525@item -ffpe-trap=@var{list}
32864778 526@opindex @code{ffpe-trap=}@var{list}
944b8b35
FXC
527Specify a list of IEEE exceptions when a Floating Point Exception
528(FPE) should be raised. On most systems, this will result in a SIGFPE
529signal being sent and the program being interrupted, producing a core
530file useful for debugging. @var{list} is a (possibly empty) comma-separated
531list of the following IEEE exceptions: @samp{invalid} (invalid floating
40746dcc 532point operation, such as @code{SQRT(-1.0)}), @samp{zero} (division by
944b8b35
FXC
533zero), @samp{overflow} (overflow in a floating point operation),
534@samp{underflow} (underflow in a floating point operation),
535@samp{precision} (loss of precision during operation) and @samp{denormal}
27ea0360 536(operation produced a denormal value).
eedeea04 537
868d75db 538@item -fbacktrace
32864778 539@opindex @code{fbacktrace}
868d75db
FXC
540@cindex backtrace
541@cindex trace
542Specify that, when a runtime error is encountered, the Fortran runtime
543library should output a backtrace of the error. This option
544only has influence for compilation of the Fortran main program.
545
eedeea04 546@item -fdump-core
e739dfac
DF
547@cindex core, dump
548@opindex @code{fdump-core}
eedeea04
FXC
549Request that a core-dump file is written to disk when a runtime error
550is encountered on systems that support core dumps. This option is
551only effective for the compilation of the Fortran main program.
944b8b35
FXC
552@end table
553
6de9cd9a
DN
554@xref{Debugging Options,,Options for Debugging Your Program or GCC,
555gcc,Using the GNU Compiler Collection (GCC)}, for more information on
556debugging options.
557
558@node Directory Options
559@section Options for Directory Search
560@cindex directory, options
561@cindex options, directory search
562@cindex search path
6de9cd9a
DN
563@cindex INCLUDE directive
564@cindex directive, INCLUDE
7fc15ba5 565These options affect how GNU Fortran searches
5724da63 566for files specified by the @code{INCLUDE} directive and where it searches
6de9cd9a
DN
567for previously compiled modules.
568
569It also affects the search paths used by @command{cpp} when used to preprocess
2d8b59df 570Fortran source.
6de9cd9a
DN
571
572@table @gcctabopt
6de9cd9a 573@item -I@var{dir}
32864778 574@opindex @code{I}@var{dir}
6de9cd9a
DN
575@cindex directory, search paths for inclusion
576@cindex inclusion, directory search paths for
577@cindex search paths, for included files
578@cindex paths, search
579@cindex module search path
580These affect interpretation of the @code{INCLUDE} directive
581(as well as of the @code{#include} directive of the @command{cpp}
582preprocessor).
583
584Also note that the general behavior of @option{-I} and
585@code{INCLUDE} is pretty much the same as of @option{-I} with
586@code{#include} in the @command{cpp} preprocessor, with regard to
587looking for @file{header.gcc} files and other such things.
588
40746dcc 589This path is also used to search for @file{.mod} files when previously
6de9cd9a
DN
590compiled modules are required by a @code{USE} statement.
591
592@xref{Directory Options,,Options for Directory Search,
593gcc,Using the GNU Compiler Collection (GCC)}, for information on the
594@option{-I} option.
595
6de9cd9a
DN
596@item -M@var{dir}
597@item -J@var{dir}
32864778
DF
598@opindex @code{M}@var{dir}
599@opindex @code{J}@var{dir}
276419d0
BM
600@cindex paths, search
601@cindex module search path
40746dcc 602This option specifies where to put @file{.mod} files for compiled modules.
2d8b59df 603It is also added to the list of directories to searched by an @code{USE}
6de9cd9a
DN
604statement.
605
606The default is the current directory.
607
608@option{-J} is an alias for @option{-M} to avoid conflicts with existing
609GCC options.
276419d0
BM
610
611@item -fintrinsic-modules-path @var{dir}
32864778 612@opindex @code{fintrinsic-modules-path} @var{dir}
276419d0
BM
613@cindex paths, search
614@cindex module search path
615This option specifies the location of pre-compiled intrinsic modules, if
616they are not in the default location expected by the compiler.
6de9cd9a
DN
617@end table
618
eaa90d25
TK
619@node Runtime Options
620@section Influencing runtime behavior
e739dfac 621@cindex options, runtime
eaa90d25 622
7fc15ba5 623These options affect the runtime behavior of programs compiled with GNU Fortran.
eaa90d25 624@table @gcctabopt
eaa90d25 625@item -fconvert=@var{conversion}
32864778 626@opindex @code{fconvert=}@var{conversion}
eaa90d25
TK
627Specify the representation of data for unformatted files. Valid
628values for conversion are: @samp{native}, the default; @samp{swap},
629swap between big- and little-endian; @samp{big-endian}, use big-endian
630representation for unformatted files; @samp{little-endian}, use little-endian
631representation for unformatted files.
632
633@emph{This option has an effect only when used in the main program.
634The @code{CONVERT} specifier and the GFORTRAN_CONVERT_UNIT environment
40746dcc 635variable override the default specified by @option{-fconvert}.}
d67ab5ee 636
d67ab5ee 637@item -frecord-marker=@var{length}
32864778 638@opindex @code{frecord-marker=}@var{length}
d67ab5ee 639Specify the length of record markers for unformatted files.
07b3bbf2
TK
640Valid values for @var{length} are 4 and 8. Default is 4.
641@emph{This is different from previous versions of gfortran},
642which specified a default record marker length of 8 on most
643systems. If you want to read or write files compatible
40746dcc 644with earlier versions of gfortran, use @option{-frecord-marker=8}.
07b3bbf2 645
07b3bbf2 646@item -fmax-subrecord-length=@var{length}
32864778 647@opindex @code{fmax-subrecord-length=}@var{length}
07b3bbf2
TK
648Specify the maximum length for a subrecord. The maximum permitted
649value for length is 2147483639, which is also the default. Only
650really useful for use by the gfortran testsuite.
eaa90d25
TK
651@end table
652
6de9cd9a
DN
653@node Code Gen Options
654@section Options for Code Generation Conventions
655@cindex code generation, conventions
656@cindex options, code generation
e739dfac 657@cindex options, run-time
6de9cd9a
DN
658
659These machine-independent options control the interface conventions
660used in code generation.
661
662Most of them have both positive and negative forms; the negative form
663of @option{-ffoo} would be @option{-fno-foo}. In the table below, only
664one of the forms is listed---the one which is not the default. You
665can figure out the other form by either removing @option{no-} or adding
666it.
667
6de9cd9a 668@table @gcctabopt
ee5426a4 669@item -fno-automatic
32864778 670@opindex @code{fno-automatic}
e739dfac
DF
671@cindex @code{SAVE} statement
672@cindex statement, @code{SAVE}
ee5426a4
FXC
673Treat each program unit as if the @code{SAVE} statement was specified for
674every local variable and array referenced in it. Does not affect common
675blocks. (Some Fortran compilers provide this option under the name
676@option{-static}.)
677
973ff4c0 678@item -ff2c
e739dfac 679@opindex ff2c
973ff4c0
TS
680@cindex calling convention
681@cindex @command{f2c} calling convention
682@cindex @command{g77} calling convention
683@cindex libf2c calling convention
684Generate code designed to be compatible with code generated
685by @command{g77} and @command{f2c}.
686
687The calling conventions used by @command{g77} (originally implemented
688in @command{f2c}) require functions that return type
689default @code{REAL} to actually return the C type @code{double}, and
690functions that return type @code{COMPLEX} to return the values via an
691extra argument in the calling sequence that points to where to
692store the return value. Under the default GNU calling conventions, such
693functions simply return their results as they would in GNU
8556236b 694C---default @code{REAL} functions return the C type @code{float}, and
973ff4c0 695@code{COMPLEX} functions return the GNU C type @code{complex}.
a226fc2b
TS
696Additionally, this option implies the @option{-fsecond-underscore}
697option, unless @option{-fno-second-underscore} is explicitly requested.
973ff4c0
TS
698
699This does not affect the generation of code that interfaces with
700the @command{libgfortran} library.
701
40746dcc
BM
702@emph{Caution:} It is not a good idea to mix Fortran code compiled with
703@option{-ff2c} with code compiled with the default @option{-fno-f2c}
973ff4c0
TS
704calling conventions as, calling @code{COMPLEX} or default @code{REAL}
705functions between program parts which were compiled with different
706calling conventions will break at execution time.
707
708@emph{Caution:} This will break code which passes intrinsic functions
709of type default @code{REAL} or @code{COMPLEX} as actual arguments, as
40746dcc 710the library implementations use the @option{-fno-f2c} calling conventions.
973ff4c0 711
6de9cd9a 712@item -fno-underscoring
32864778 713@opindex @code{fno-underscoring}
6de9cd9a
DN
714@cindex underscore
715@cindex symbol names, underscores
716@cindex transforming symbol names
717@cindex symbol names, transforming
718Do not transform names of entities specified in the Fortran
719source file by appending underscores to them.
720
7fc15ba5 721With @option{-funderscoring} in effect, GNU Fortran appends one
5724da63
JD
722underscore to external names with no underscores. This is done to ensure
723compatibility with code produced by many UNIX Fortran compilers.
973ff4c0 724
7fc15ba5 725@emph{Caution}: The default behavior of GNU Fortran is
973ff4c0 726incompatible with @command{f2c} and @command{g77}, please use the
b4cbcd1a 727@option{-ff2c} option if you want object files compiled with
7fc15ba5 728GNU Fortran to be compatible with object code created with these
b4cbcd1a 729tools.
6de9cd9a
DN
730
731Use of @option{-fno-underscoring} is not recommended unless you are
7fc15ba5 732experimenting with issues such as integration of GNU Fortran into
6de9cd9a
DN
733existing system environments (vis-a-vis existing libraries, tools, and
734so on).
735
736For example, with @option{-funderscoring}, and assuming other defaults like
40746dcc
BM
737@option{-fcase-lower} and that @code{j()} and @code{max_count()} are
738external functions while @code{my_var} and @code{lvar} are local variables,
6de9cd9a 739a statement like
6de9cd9a
DN
740@smallexample
741I = J() + MAX_COUNT (MY_VAR, LVAR)
742@end smallexample
6de9cd9a
DN
743@noindent
744is implemented as something akin to:
6de9cd9a
DN
745@smallexample
746i = j_() + max_count__(&my_var__, &lvar);
747@end smallexample
748
749With @option{-fno-underscoring}, the same statement is implemented as:
750
751@smallexample
752i = j() + max_count(&my_var, &lvar);
753@end smallexample
754
755Use of @option{-fno-underscoring} allows direct specification of
7fc15ba5 756user-defined names while debugging and when interfacing GNU Fortran
6de9cd9a
DN
757code with other languages.
758
759Note that just because the names match does @emph{not} mean that the
7fc15ba5 760interface implemented by GNU Fortran for an external name matches the
6de9cd9a 761interface implemented by some other language for that same name.
7fc15ba5 762That is, getting code produced by GNU Fortran to link to code produced
6de9cd9a
DN
763by some other compiler using this or any other method can be only a
764small part of the overall solution---getting the code generated by
765both compilers to agree on issues other than naming can require
766significant effort, and, unlike naming disagreements, linkers normally
767cannot detect disagreements in these other areas.
768
769Also, note that with @option{-fno-underscoring}, the lack of appended
770underscores introduces the very real possibility that a user-defined
771external name will conflict with a name in a system library, which
772could make finding unresolved-reference bugs quite difficult in some
773cases---they might occur at program run time, and show up only as
774buggy behavior at run time.
775
7fc15ba5 776In future versions of GNU Fortran we hope to improve naming and linking
6de9cd9a
DN
777issues so that debugging always involves using the names as they appear
778in the source, even if the names as seen by the linker are mangled to
779prevent accidental linking between procedures with incompatible
780interfaces.
781
973ff4c0 782@item -fsecond-underscore
32864778 783@opindex @code{fsecond-underscore}
6de9cd9a
DN
784@cindex underscore
785@cindex symbol names, underscores
786@cindex transforming symbol names
787@cindex symbol names, transforming
973ff4c0
TS
788@cindex @command{f2c} calling convention
789@cindex @command{g77} calling convention
790@cindex libf2c calling convention
7fc15ba5
BM
791By default, GNU Fortran appends an underscore to external
792names. If this option is used GNU Fortran appends two
973ff4c0 793underscores to names with underscores and one underscore to external names
7fc15ba5 794with no underscores. GNU Fortran also appends two underscores to
973ff4c0
TS
795internal names with underscores to avoid naming collisions with external
796names.
6de9cd9a
DN
797
798This option has no effect if @option{-fno-underscoring} is
973ff4c0 799in effect. It is implied by the @option{-ff2c} option.
6de9cd9a 800
40746dcc 801Otherwise, with this option, an external name such as @code{MAX_COUNT}
6de9cd9a 802is implemented as a reference to the link-time external symbol
40746dcc 803@code{max_count__}, instead of @code{max_count_}. This is required
973ff4c0
TS
804for compatibility with @command{g77} and @command{f2c}, and is implied
805by use of the @option{-ff2c} option.
6de9cd9a 806
6de9cd9a 807@item -fbounds-check
32864778 808@opindex @code{fbounds-check}
e739dfac 809@cindex array, bounds checking
6de9cd9a
DN
810@cindex bounds checking
811@cindex range checking
6de9cd9a
DN
812@cindex subscript checking
813@cindex checking subscripts
814Enable generation of run-time checks for array subscripts
815and against the declared minimum and maximum values. It also
816checks array indices for assumed and deferred
817shape arrays against the actual allocated bounds.
818
8370304d 819In the future this may also include other forms of checking, e.g., checking
6de9cd9a
DN
820substring references.
821
6de9cd9a 822@item -fmax-stack-var-size=@var{n}
32864778 823@opindex @code{fmax-stack-var-size}
6de9cd9a
DN
824This option specifies the size in bytes of the largest array that will be put
825on the stack.
826
827This option currently only affects local arrays declared with constant
828bounds, and may not apply to all character variables.
7fc15ba5 829Future versions of GNU Fortran may improve this behavior.
6de9cd9a
DN
830
831The default value for @var{n} is 32768.
832
5139e1e9 833@item -fpack-derived
32864778
DF
834@opindex @code{fpack-derived}
835@cindex structure packing
7fc15ba5 836This option tells GNU Fortran to pack derived type members as closely as
2d8b59df 837possible. Code compiled with this option is likely to be incompatible
6de9cd9a
DN
838with code compiled without this option, and may execute slower.
839
6de9cd9a 840@item -frepack-arrays
32864778
DF
841@opindex @code{frepack-arrays}
842@cindex repacking arrays
7fc15ba5 843In some circumstances GNU Fortran may pass assumed shape array
02712c16 844sections via a descriptor describing a noncontiguous area of memory.
6de9cd9a
DN
845This option adds code to the function prologue to repack the data into
846a contiguous block at runtime.
847
848This should result in faster accesses to the array. However it can introduce
849significant overhead to the function call, especially when the passed data
02712c16 850is noncontiguous.
a63dad5b 851
a63dad5b 852@item -fshort-enums
32864778 853@opindex @code{fshort-enums}
a63dad5b 854This option is provided for interoperability with C code that was
4ba96c02 855compiled with the @option{-fshort-enums} option. It will make
7fc15ba5 856GNU Fortran choose the smallest @code{INTEGER} kind a given
a63dad5b 857enumerator set will fit in, and give all its enumerators this kind.
5a0aad31 858
5a0aad31 859@item -fexternal-blas
32864778 860@opindex @code{fexternal-blas}
5a0aad31
FXC
861This option will make gfortran generate calls to BLAS functions for some
862matrix operations like @code{MATMUL}, instead of using our own
863algorithms, if the size of the matrices involved is larger than a given
4ba96c02 864limit (see @option{-fblas-matmul-limit}). This may be profitable if an
5a0aad31
FXC
865optimized vendor BLAS library is available. The BLAS library will have
866to be specified at link time.
867
5a0aad31 868@item -fblas-matmul-limit=@var{n}
32864778 869@opindex @code{fblas-matmul-limit}
4ba96c02 870Only significant when @option{-fexternal-blas} is in effect.
5a0aad31
FXC
871Matrix multiplication of matrices with size larger than (or equal to) @var{n}
872will be performed by calls to BLAS functions, while others will be
873handled by @command{gfortran} internal algorithms. If the matrices
874involved are not square, the size comparison is performed using the
875geometric mean of the dimensions of the argument and result matrices.
876
877The default value for @var{n} is 30.
878
6de9cd9a
DN
879@end table
880
881@xref{Code Gen Options,,Options for Code Generation Conventions,
882gcc,Using the GNU Compiler Collection (GCC)}, for information on more options
883offered by the GBE
7fc15ba5 884shared by @command{gfortran}, @command{gcc}, and other GNU compilers.
6de9cd9a
DN
885
886
887@c man end
888
889@node Environment Variables
7fc15ba5 890@section Environment Variables Affecting @command{gfortran}
e739dfac 891@cindex environment variable
6de9cd9a
DN
892
893@c man begin ENVIRONMENT
894
7fc15ba5 895The @command{gfortran} compiler currently does not make use of any environment
6de9cd9a
DN
896variables to control its operation above and beyond those
897that affect the operation of @command{gcc}.
898
899@xref{Environment Variables,,Environment Variables Affecting GCC,
900gcc,Using the GNU Compiler Collection (GCC)}, for information on environment
901variables.
902
eaa90d25 903@xref{Runtime}, for environment variables that affect the
7fc15ba5 904run-time behavior of programs compiled with GNU Fortran.
6de9cd9a 905@c man end
This page took 1.107932 seconds and 5 git commands to generate.