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