OSDN Git Service

2008-12-21 Arjen Markus <arjen.markus@wldelft.nl>
[pf3gnuchains/gcc-fork.git] / gcc / fortran / invoke.texi
1 @c Copyright (C) 2004, 2005, 2006, 2007, 2008
2 @c Free Software Foundation, Inc.
3 @c This is part of the GNU Fortran manual.   
4 @c For copying conditions, see the file gfortran.texi.
5
6 @ignore
7 @c man begin COPYRIGHT
8 Copyright @copyright{} 2004, 2005, 2006, 2007, 2008
9 Free Software Foundation, Inc.
10
11 Permission is granted to copy, distribute and/or modify this document
12 under the terms of the GNU Free Documentation License, Version 1.2 or
13 any later version published by the Free Software Foundation; with the
14 Invariant Sections being ``Funding Free Software'', the Front-Cover
15 Texts being (a) (see below), and with the Back-Cover Texts being (b)
16 (see below).  A copy of the license is included in the gfdl(7) man page.
17
18 (a) The FSF's Front-Cover Text is:
19
20      A GNU Manual
21
22 (b) The FSF's Back-Cover Text is:
23
24      You have freedom to copy and modify this GNU Manual, like GNU
25      software.  Copies published by the Free Software Foundation raise
26      funds for GNU development.
27 @c man end
28 @c Set file name and title for the man page.
29 @setfilename gfortran
30 @settitle GNU Fortran compiler.
31 @c man begin SYNOPSIS
32 gfortran [@option{-c}|@option{-S}|@option{-E}]
33          [@option{-g}] [@option{-pg}] [@option{-O}@var{level}]
34          [@option{-W}@var{warn}@dots{}] [@option{-pedantic}]
35          [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
36          [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}]
37          [@option{-f}@var{option}@dots{}]
38          [@option{-m}@var{machine-option}@dots{}]
39          [@option{-o} @var{outfile}] @var{infile}@dots{}
40
41 Only the most useful options are listed here; see below for the
42 remainder.
43 @c man end
44 @c man begin SEEALSO
45 gpl(7), gfdl(7), fsf-funding(7),
46 cpp(1), gcov(1), gcc(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1)
47 and the Info entries for @file{gcc}, @file{cpp}, @file{gfortran}, @file{as},
48 @file{ld}, @file{binutils} and @file{gdb}.
49 @c man end
50 @c man begin BUGS
51 For instructions on reporting bugs, see
52 @w{@value{BUGURL}}.
53 @c man end
54 @c man begin AUTHOR
55 See the Info entry for @command{gfortran} for contributors to GCC and
56 GNU Fortran.
57 @c man end
58 @end ignore
59
60 @node Invoking GNU Fortran
61 @chapter GNU Fortran Command Options
62 @cindex GNU Fortran command options
63 @cindex command options
64 @cindex options, @command{gfortran} command
65
66 @c man begin DESCRIPTION
67
68 The @command{gfortran} command supports all the options supported by the
69 @command{gcc} command.  Only options specific to GNU Fortran are documented here.
70
71 @xref{Invoking GCC,,GCC Command Options,gcc,Using the GNU Compiler
72 Collection (GCC)}, for information
73 on the non-Fortran-specific aspects of the @command{gcc} command (and,
74 therefore, the @command{gfortran} command).
75
76 @cindex options, negative forms
77 All GCC and GNU Fortran options
78 are accepted both by @command{gfortran} and by @command{gcc}
79 (as well as any other drivers built at the same time,
80 such as @command{g++}),
81 since adding GNU Fortran to the GCC distribution
82 enables acceptance of GNU Fortran options
83 by all of the relevant drivers.
84
85 In some cases, options have positive and negative forms;
86 the negative form of @option{-ffoo} would be @option{-fno-foo}.
87 This manual documents only one of these two forms, whichever
88 one is not the default.
89 @c man end
90
91 @menu
92 * Option Summary::      Brief list of all @command{gfortran} options,
93                         without explanations.
94 * Fortran Dialect Options::  Controlling the variant of Fortran language
95                              compiled.
96 * Preprocessing Options::  Enable and customize preprocessing.
97 * Error and Warning Options::     How picky should the compiler be?
98 * Debugging Options::   Symbol tables, measurements, and debugging dumps.
99 * Directory Options::   Where to find module files
100 * Link Options ::       Influencing the linking step
101 * Runtime Options::     Influencing runtime behavior
102 * Code Gen Options::    Specifying conventions for function calls, data layout
103                         and register usage.
104 * Environment Variables:: Environment variables that affect @command{gfortran}.
105 @end menu
106
107 @node Option Summary
108 @section Option summary
109
110 @c man begin OPTIONS
111
112 Here is a summary of all the options specific to GNU Fortran, grouped
113 by 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}.
118 @gccoptlist{-fall-intrinsics  -ffree-form  -fno-fixed-form @gol
119 -fdollar-ok  -fimplicit-none  -fmax-identifier-length @gol
120 -std=@var{std} -fd-lines-as-code  -fd-lines-as-comments @gol
121 -ffixed-line-length-@var{n}  -ffixed-line-length-none @gol
122 -ffree-line-length-@var{n}  -ffree-line-length-none @gol
123 -fdefault-double-8  -fdefault-integer-8  -fdefault-real-8 @gol
124 -fcray-pointer  -fopenmp  -fno-range-check -fbackslash -fmodule-private}
125
126 @item Preprocessing Options
127 @xref{Preprocessing Options,,Enable and customize preprocessing}.
128 @gccoptlist{-cpp -dD -dI -dM -dN -dU -fworking-directory @gol
129 -imultilib @var{dir} -iprefix @var{file} -isysroot @var{dir} @gol
130 -iquote -isystem @var{dir} -nocpp -nostdinc -undef @gol
131 -A@var{question}=@var{answer} -A-@var{question}@r{[}=@var{answer}@r{]} @gol
132 -C -CC -D@var{macro}@r{[}=@var{defn}@r{]} -U@var{macro} -H -P}
133
134 @item Error and Warning Options
135 @xref{Error and Warning Options,,Options to request or suppress errors
136 and warnings}.
137 @gccoptlist{-fmax-errors=@var{n} @gol
138 -fsyntax-only  -pedantic  -pedantic-errors @gol
139 -Wall  -Waliasing  -Wampersand  -Warray-bounds -Wcharacter-truncation @gol
140 -Wconversion -Wimplicit-interface  -Wline-truncation  -Wintrinsics-std @gol
141 -Wsurprising -Wno-tabs  -Wunderflow -Wunused-parameter -Wintrinsics-shadow @gol
142 -Wno-align-commons}
143
144 @item Debugging Options
145 @xref{Debugging Options,,Options for debugging your program or GNU Fortran}.
146 @gccoptlist{-fdump-parse-tree  -ffpe-trap=@var{list} @gol
147 -fdump-core -fbacktrace}
148
149 @item Directory Options
150 @xref{Directory Options,,Options for directory search}.
151 @gccoptlist{-I@var{dir}  -J@var{dir}  -M@var{dir}  @gol
152 -fintrinsic-modules-path @var{dir}}
153
154 @item Link Options
155 @xref{Link Options,,Options for influencing the linking step}.
156 @gccoptlist{-static-libgfortran}
157
158 @item Runtime Options
159 @xref{Runtime Options,,Options for influencing runtime behavior}.
160 @gccoptlist{-fconvert=@var{conversion}  -fno-range-check
161 -frecord-marker=@var{length} @gol  -fmax-subrecord-length=@var{length}
162 -fsign-zero}
163
164 @item Code Generation Options
165 @xref{Code Gen Options,,Options for code generation conventions}.
166 @gccoptlist{-fno-automatic  -ff2c  -fno-underscoring @gol
167 -fsecond-underscore @gol
168 -fbounds-check -fcheck-array-temporaries  -fmax-array-constructor =@var{n} @gol
169 -fmax-stack-var-size=@var{n} @gol
170 -fpack-derived  -frepack-arrays  -fshort-enums  -fexternal-blas @gol
171 -fblas-matmul-limit=@var{n} -frecursive -finit-local-zero @gol
172 -finit-integer=@var{n} -finit-real=@var{<zero|inf|-inf|nan>} @gol
173 -finit-logical=@var{<true|false>} -finit-character=@var{n} -fno-align-commons}
174 @end table
175
176 @menu
177 * Fortran Dialect Options::  Controlling the variant of Fortran language
178                              compiled.
179 * Preprocessing Options::  Enable and customize preprocessing.
180 * Error and Warning Options::     How picky should the compiler be?
181 * Debugging Options::   Symbol tables, measurements, and debugging dumps.
182 * Directory Options::   Where to find module files
183 * Link Options ::       Influencing the linking step
184 * Runtime Options::     Influencing runtime behavior
185 * Code Gen Options::    Specifying conventions for function calls, data layout
186                         and register usage.
187 @end menu
188
189 @node Fortran Dialect Options
190 @section Options controlling Fortran dialect
191 @cindex dialect options
192 @cindex language, dialect options
193 @cindex options, dialect
194
195 The following options control the details of the Fortran dialect
196 accepted by the compiler:
197
198 @table @gcctabopt
199 @item -ffree-form
200 @item -ffixed-form
201 @opindex @code{ffree-form}
202 @opindex @code{fno-fixed-form}
203 @cindex options, fortran dialect
204 @cindex file format, free
205 @cindex file format, fixed
206 Specify the layout used by the source file.  The free form layout
207 was introduced in Fortran 90.  Fixed form was traditionally used in
208 older Fortran programs.  When neither option is specified, the source
209 form is determined by the file extension.
210
211 @item -fall-intrinsics
212 @opindex @code{fall-intrinsics}
213 This option causes all intrinsic procedures (including the GNU-specific
214 extensions) to be accepted.  This can be useful with @option{-std=f95} to
215 force standard-compliance but get access to the full range of intrinsics
216 available with @command{gfortran}.  As a consequence, @option{-Wintrinsics-std}
217 will be ignored and no user-defined procedure with the same name as any
218 intrinsic will be called except when it is explicitly declared @code{EXTERNAL}.
219
220 @item -fd-lines-as-code
221 @item -fd-lines-as-comments
222 @opindex @code{fd-lines-as-code}
223 @opindex @code{fd-lines-as-comments}
224 Enable special treatment for lines beginning with @code{d} or @code{D}
225 in fixed form sources.  If the @option{-fd-lines-as-code} option is
226 given they are treated as if the first column contained a blank.  If the
227 @option{-fd-lines-as-comments} option is given, they are treated as
228 comment lines.
229
230 @item -fdefault-double-8
231 @opindex @code{fdefault-double-8}
232 Set the @code{DOUBLE PRECISION} type to an 8 byte wide type.  If
233 @option{-fdefault-real-8} is given, @code{DOUBLE PRECISION} would
234 instead be promoted to 16 bytes if possible, and @option{-fdefault-double-8}
235 can be used to prevent this.  The kind of real constants like @code{1.d0} will
236 not be changed by @option{-fdefault-real-8} though, so also
237 @option{-fdefault-double-8} does not affect it.
238
239 @item -fdefault-integer-8
240 @opindex @code{fdefault-integer-8}
241 Set the default integer and logical types to an 8 byte wide type.
242 Do nothing if this is already the default.  This option also affects
243 the kind of integer constants like @code{42}.
244
245 @item -fdefault-real-8
246 @opindex @code{fdefault-real-8}
247 Set the default real type to an 8 byte wide type.
248 Do nothing if this is already the default.  This option also affects
249 the kind of non-double real constants like @code{1.0}, and does promote
250 the default width of @code{DOUBLE PRECISION} to 16 bytes if possible, unless
251 @code{-fdefault-double-8} is given, too.
252
253 @item -fdollar-ok
254 @opindex @code{fdollar-ok}
255 @cindex $
256 @cindex symbol names
257 @cindex character set
258 Allow @samp{$} as a valid character in a symbol name.
259
260 @item -fbackslash
261 @opindex @code{backslash}
262 @cindex backslash
263 @cindex escape characters
264 Change the interpretation of backslashes in string literals from a single
265 backslash character to ``C-style'' escape characters. The following
266 combinations are expanded @code{\a}, @code{\b}, @code{\f}, @code{\n},
267 @code{\r}, @code{\t}, @code{\v}, @code{\\}, and @code{\0} to the ASCII
268 characters alert, backspace, form feed, newline, carriage return,
269 horizontal tab, vertical tab, backslash, and NUL, respectively.
270 Additionally, @code{\x}@var{nn}, @code{\u}@var{nnnn} and
271 @code{\U}@var{nnnnnnnn} (where each @var{n} is a hexadecimal digit) are
272 translated into the Unicode characters corresponding to the specified code
273 points. All other combinations of a character preceded by \ are
274 unexpanded.
275
276 @item -fmodule-private
277 @opindex @code{fmodule-private}
278 @cindex module entities
279 @cindex private
280 Set the default accessibility of module entities to @code{PRIVATE}.
281 Use-associated entities will not be accessible unless they are explicitly
282 declared as @code{PUBLIC}.
283
284 @item -ffixed-line-length-@var{n}
285 @opindex @code{ffixed-line-length-}@var{n}
286 @cindex file format, fixed
287 Set column after which characters are ignored in typical fixed-form
288 lines in the source file, and through which spaces are assumed (as
289 if padded to that length) after the ends of short fixed-form lines.
290
291 Popular values for @var{n} include 72 (the
292 standard and the default), 80 (card image), and 132 (corresponding
293 to ``extended-source'' options in some popular compilers).
294 @var{n} may also be @samp{none}, meaning that the entire line is meaningful
295 and that continued character constants never have implicit spaces appended
296 to them to fill out the line.
297 @option{-ffixed-line-length-0} means the same thing as
298 @option{-ffixed-line-length-none}.
299
300 @item -ffree-line-length-@var{n}
301 @opindex @code{ffree-line-length-}@var{n}
302 @cindex file format, free
303 Set column after which characters are ignored in typical free-form
304 lines in the source file. The default value is 132.
305 @var{n} may be @samp{none}, meaning that the entire line is meaningful.
306 @option{-ffree-line-length-0} means the same thing as
307 @option{-ffree-line-length-none}.
308
309 @item -fmax-identifier-length=@var{n}
310 @opindex @code{fmax-identifier-length=}@var{n}
311 Specify the maximum allowed identifier length. Typical values are
312 31 (Fortran 95) and 63 (Fortran 2003 and Fortran 2008).
313
314 @item -fimplicit-none
315 @opindex @code{fimplicit-none}
316 Specify that no implicit typing is allowed, unless overridden by explicit
317 @code{IMPLICIT} statements.  This is the equivalent of adding
318 @code{implicit none} to the start of every procedure.
319
320 @item -fcray-pointer
321 @opindex @code{fcray-pointer}
322 Enable the Cray pointer extension, which provides C-like pointer
323 functionality.
324
325 @item -fopenmp
326 @opindex @code{fopenmp}
327 @cindex OpenMP
328 Enable the OpenMP extensions.  This includes OpenMP @code{!$omp} directives
329 in free form
330 and @code{c$omp}, @code{*$omp} and @code{!$omp} directives in fixed form,
331 @code{!$} conditional compilation sentinels in free form
332 and @code{c$}, @code{*$} and @code{!$} sentinels in fixed form, 
333 and when linking arranges for the OpenMP runtime library to be linked
334 in.  The option @option{-fopenmp} implies @option{-frecursive}.
335
336 @item -fno-range-check
337 @opindex @code{frange-check}
338 Disable range checking on results of simplification of constant
339 expressions during compilation.  For example, GNU Fortran will give
340 an error at compile time when simplifying @code{a = 1. / 0}.
341 With this option, no error will be given and @code{a} will be assigned
342 the value @code{+Infinity}.  If an expression evaluates to a value
343 outside of the relevant range of [@code{-HUGE()}:@code{HUGE()}],
344 then the expression will be replaced by @code{-Inf} or @code{+Inf}
345 as appropriate.
346 Similarly, @code{DATA i/Z'FFFFFFFF'/} will result in an integer overflow
347 on most systems, but with @option{-fno-range-check} the value will
348 ``wrap around'' and @code{i} will be initialized to @math{-1} instead.
349
350 @item -std=@var{std}
351 @opindex @code{std=}@var{std} option
352 Specify the standard to which the program is expected to conform, which
353 may be one of @samp{f95}, @samp{f2003}, @samp{f2008}, @samp{gnu}, or
354 @samp{legacy}.  The default value for @var{std} is @samp{gnu}, which
355 specifies a superset of the Fortran 95 standard that includes all of the
356 extensions supported by GNU Fortran, although warnings will be given for
357 obsolete extensions not recommended for use in new code.  The
358 @samp{legacy} value is equivalent but without the warnings for obsolete
359 extensions, and may be useful for old non-standard programs.  The
360 @samp{f95}, @samp{f2003} and @samp{f2008} values specify strict
361 conformance to the Fortran 95, Fortran 2003 and Fortran 2008 standards,
362 respectively; errors are given for all extensions beyond the relevant
363 language standard, and warnings are given for the Fortran 77 features
364 that are permitted but obsolescent in later standards.
365
366 @end table
367
368 @node Preprocessing Options
369 @section Enable and customize preprocessing
370 @cindex preprocessor
371 @cindex options, preprocessor
372 @cindex CPP
373
374 Preprocessor related options. See section 
375 @ref{Preprocessing and conditional compilation} for more detailed
376 information on preprocessing in @command{gfortran}.
377
378 @table @gcctabopt
379 @item -cpp
380 @item -nocpp
381 @opindex @code{cpp}
382 @opindex @code{fpp}
383 @cindex preprocessor, enable
384 @cindex preprocessor, disable
385 Enable preprocessing. The preprocessor is automatically invoked if
386 the file extension is @file{.fpp}, @file{.FPP},  @file{.F}, @file{.FOR},
387 @file{.FTN}, @file{.F90}, @file{.F95}, @file{.F03} or @file{.F08}. Use
388 this option to manually enable preprocessing of any kind of Fortran file.
389
390 To disable preprocessing of files with any of the above listed extensions,
391 use the negative form: @option{-nocpp}.
392
393 The preprocessor is run in traditional mode, be aware that any
394 restrictions of the file-format, e.g. fixed-form line width,
395 apply for preprocessed output as well.
396
397 @item -dM
398 @opindex @code{dM}
399 @cindex preprocessor, debugging
400 @cindex debugging, preprocessor
401 Instead of the normal output, generate a list of @code{'#define'}
402 directives for all the macros defined during the execution of the
403 preprocessor, including predefined macros. This gives you a way
404 of finding out what is predefined in your version of the preprocessor.
405 Assuming you have no file @file{foo.f90}, the command
406 @smallexample
407   touch foo.f90; gfortran -cpp -dM foo.f90
408 @end smallexample
409 will show all the predefined macros.
410
411 @item -dD
412 @opindex @code{dD}
413 @cindex preprocessor, debugging
414 @cindex debugging, preprocessor
415 Like @option{-dM} except in two respects: it does not include the
416 predefined macros, and it outputs both the @code{#define} directives
417 and the result of preprocessing. Both kinds of output go to the
418 standard output file.
419
420 @item -dN
421 @opindex @code{dN}
422 @cindex preprocessor, debugging
423 @cindex debugging, preprocessor
424 Like @option{-dD}, but emit only the macro names, not their expansions.
425
426 @item -dU
427 @opindex @code{dU}
428 @cindex preprocessor, debugging
429 @cindex debugging, preprocessor
430 Like @option{dD} except that only macros that are expanded, or whose
431 definedness is tested in preprocessor directives, are output; the 
432 output is delayed until the use or test of the macro; and @code{'#undef'}
433 directives are also output for macros tested but undefined at the time.
434
435 @item -dI
436 @opindex @code{dI}
437 @cindex preprocessor, debugging
438 @cindex debugging, preprocessor
439 Output @code{'#include'} directives in addition to the result
440 of preprocessing.
441
442 @item -fworking-directory
443 @opindex @code{fworking-directory}
444 @cindex preprocessor, working directory
445 Enable generation of linemarkers in the preprocessor output that will
446 let the compiler know the current working directory at the time of
447 preprocessing. When this option is enabled, the preprocessor will emit,
448 after the initial linemarker, a second linemarker with the current
449 working directory followed by two slashes. GCC will use this directory,
450 when it's present in the preprocessed input, as the directory emitted
451 as the current working directory in some debugging information formats.
452 This option is implicitly enabled if debugging information is enabled,
453 but this can be inhibited with the negated form
454 @option{-fno-working-directory}. If the @option{-P} flag is present
455 in the command line, this option has no effect, since no @code{#line}
456 directives are emitted whatsoever.
457
458 @item -idirafter @var{dir}
459 @opindex @code{idirafter @var{dir}}
460 @cindex preprocessing, include path
461 Search @var{dir} for include files, but do it after all directories
462 specified with @option{-I} and the standard system directories have
463 been exhausted. @var{dir} is treated as a system include directory.
464 If dir begins with @code{=}, then the @code{=} will be replaced by
465 the sysroot prefix; see @option{--sysroot} and @option{-isysroot}.
466
467 @item -imultilib @var{dir}
468 @opindex @code{imultilib @var{dir}}
469 @cindex preprocessing, include path
470 Use @var{dir} as a subdirectory of the directory containing target-specific
471 C++ headers.
472
473 @item -iprefix @var{prefix}
474 @opindex @code{iprefix @var{prefix}}
475 @cindex preprocessing, include path
476 Specify @var{prefix} as the prefix for subsequent @option{-iwithprefix}
477 options. If the @var{prefix} represents a directory, you should include
478 the final @code{'/'}.
479
480 @item -isysroot @var{dir}
481 @opindex @code{isysroot @var{dir}}
482 @cindex preprocessing, include path
483 This option is like the @option{--sysroot} option, but applies only to
484 header files. See the @option{--sysroot} option for more information.
485
486 @item -iquote @var{dir}
487 @opindex @code{iquote @var{dir}}
488 @cindex preprocessing, include path
489 Search @var{dir} only for header files requested with @code{#include "file"};
490 they are not searched for @code{#include <file>}, before all directories
491 specified by @option{-I} and before the standard system directories. If
492 @var{dir} begins with @code{=}, then the @code{=} will be replaced by the
493 sysroot prefix; see @option{--sysroot} and @option{-isysroot}.
494
495 @item -isystem @var{dir}
496 @opindex @code{isystem @var{dir}}
497 @cindex preprocessing, include path
498 Search @var{dir} for header files, after all directories specified by
499 @option{-I} but before the standard system directories. Mark it as a
500 system directory, so that it gets the same special treatment as is
501 applied to the standard system directories. If @var{dir} begins with
502 @code{=}, then the @code{=} will be replaced by the sysroot prefix;
503 see @option{--sysroot} and @option{-isysroot}.
504
505 @item -nostdinc
506 @opindex @code{nostdinc}
507 Do not search the standard system directories for header files. Only
508 the directories you have specified with @option{-I} options (and the
509 directory of the current file, if appropriate) are searched.
510
511 @item -undef
512 @opindex @code{undef}
513 Do not predefine any system-specific or GCC-specific macros.
514 The standard predefined macros remain defined.
515
516 @item -A@var{predicate}=@var{answer}
517 @opindex @code{A@var{predicate}=@var{answer}}
518 @cindex preprocessing, assertation
519 Make an assertion with the predicate @var{predicate} and answer @var{answer}.
520 This form is preferred to the older form -A predicate(answer), which is still
521 supported, because it does not use shell special characters.
522
523 @item -A-@var{predicate}=@var{answer}
524 @opindex @code{A-@var{predicate}=@var{answer}}
525 @cindex preprocessing, assertation
526 Cancel an assertion with the predicate @var{predicate} and answer @var{answer}.
527
528 @item -C
529 @opindex @code{C}
530 @cindex preprocessing, keep comments
531 Do not discard comments. All comments are passed through to the output
532 file, except for comments in processed directives, which are deleted
533 along with the directive.
534
535 You should be prepared for side effects when using @option{-C}; it causes
536 the preprocessor to treat comments as tokens in their own right. For example,
537 comments appearing at the start of what would be a directive line have the
538 effect of turning that line into an ordinary source line, since the first
539 token on the line is no longer a @code{'#'}.
540
541 Warning: this currently handles C-Style comments only. The preprocessor
542 does not yet recognize Fortran-style comments.
543
544 @item -CC
545 @opindex @code{CC}
546 @cindex preprocessing, keep comments
547 Do not discard comments, including during macro expansion. This is like
548 @option{-C}, except that comments contained within macros are also passed
549 through to the output file where the macro is expanded.
550
551 In addition to the side-effects of the @option{-C} option, the @option{-CC}
552 option causes all C++-style comments inside a macro to be converted to C-style
553 comments. This is to prevent later use of that macro from inadvertently
554 commenting out the remainder of the source line. The @option{-CC} option
555 is generally used to support lint comments.
556
557 Warning: this currently handles C- and C++-Style comments only. The
558 preprocessor does not yet recognize Fortran-style comments.
559
560 @item -D@var{name}
561 @opindex @code{D@var{name}}
562 @cindex preprocessing, define macros
563 Predefine name as a macro, with definition @code{1}.
564
565 @item -D@var{name}=@var{definition}
566 @opindex @code{D@var{name}=@var{definition}}
567 @cindex preprocessing, define macros
568 The contents of @var{definition} are tokenized and processed as if they
569 appeared during translation phase three in a @code{'#define'} directive.
570 In particular, the definition will be truncated by embedded newline
571 characters.
572
573 If you are invoking the preprocessor from a shell or shell-like program
574 you may need to use the shell's quoting syntax to protect characters such
575 as spaces that have a meaning in the shell syntax.
576
577 If you wish to define a function-like macro on the command line, write
578 its argument list with surrounding parentheses before the equals sign
579 (if any). Parentheses are meaningful to most shells, so you will need
580 to quote the option. With sh and csh, @code{-D'name(args...)=definition'}
581 works.
582
583 @option{-D} and @option{-U} options are processed in the order they are
584 given on the command line. All -imacros file and -include file options
585 are processed after all -D and -U options.
586
587 @item -H
588 @opindex @code{H}
589 Print the name of each header file used, in addition to other normal
590 activities. Each name is indented to show how deep in the @code{'#include'}
591 stack it is.
592
593 @item -P
594 @opindex @code{P}
595 @cindex preprocessing, no linemarkers
596 Inhibit generation of linemarkers in the output from the preprocessor.
597 This might be useful when running the preprocessor on something that
598 is not C code, and will be sent to a program which might be confused
599 by the linemarkers.
600
601 @item -U@var{name}
602 @opindex @code{U@var{name}}
603 @cindex preprocessing, undefine macros
604 Cancel any previous definition of @var{name}, either built in or provided
605 with a @option{-D} option.
606 @end table
607
608
609 @node Error and Warning Options
610 @section Options to request or suppress errors and warnings
611 @cindex options, warnings
612 @cindex options, errors
613 @cindex warnings, suppressing
614 @cindex messages, error
615 @cindex messages, warning
616 @cindex suppressing warnings
617
618 Errors are diagnostic messages that report that the GNU Fortran compiler
619 cannot compile the relevant piece of source code.  The compiler will
620 continue to process the program in an attempt to report further errors
621 to aid in debugging, but will not produce any compiled output.  
622
623 Warnings are diagnostic messages that report constructions which
624 are not inherently erroneous but which are risky or suggest there is
625 likely to be a bug in the program.  Unless @option{-Werror} is specified,
626 they do not prevent compilation of the program.
627
628 You can request many specific warnings with options beginning @option{-W},
629 for example @option{-Wimplicit} to request warnings on implicit
630 declarations.  Each of these specific warning options also has a
631 negative form beginning @option{-Wno-} to turn off warnings;
632 for example, @option{-Wno-implicit}.  This manual lists only one of the
633 two forms, whichever is not the default.
634
635 These options control the amount and kinds of errors and warnings produced
636 by GNU Fortran:
637
638 @table @gcctabopt
639 @item -fmax-errors=@var{n}
640 @opindex @code{fmax-errors=}@var{n}
641 @cindex errors, limiting
642 Limits the maximum number of error messages to @var{n}, at which point
643 GNU Fortran bails out rather than attempting to continue processing the
644 source code.  If @var{n} is 0, there is no limit on the number of error
645 messages produced.
646
647 @item -fsyntax-only
648 @opindex @code{fsyntax-only}
649 @cindex syntax checking
650 Check the code for syntax errors, but don't actually compile it.  This
651 will generate module files for each module present in the code, but no
652 other output file.
653
654 @item -pedantic
655 @opindex @code{pedantic}
656 Issue warnings for uses of extensions to Fortran 95.
657 @option{-pedantic} also applies to C-language constructs where they
658 occur in GNU Fortran source files, such as use of @samp{\e} in a
659 character constant within a directive like @code{#include}.
660
661 Valid Fortran 95 programs should compile properly with or without
662 this option.
663 However, without this option, certain GNU extensions and traditional
664 Fortran features are supported as well.
665 With this option, many of them are rejected.
666
667 Some users try to use @option{-pedantic} to check programs for conformance.
668 They soon find that it does not do quite what they want---it finds some
669 nonstandard practices, but not all.
670 However, improvements to GNU Fortran in this area are welcome.
671
672 This should be used in conjunction with @option{-std=f95},
673 @option{-std=f2003} or @option{-std=f2008}.
674
675 @item -pedantic-errors
676 @opindex @code{pedantic-errors}
677 Like @option{-pedantic}, except that errors are produced rather than
678 warnings.
679
680 @item -Wall
681 @opindex @code{Wall}
682 @cindex all warnings
683 @cindex warnings, all
684 Enables commonly used warning options pertaining to usage that
685 we recommend avoiding and that we believe are easy to avoid.
686 This currently includes @option{-Waliasing},
687 @option{-Wampersand}, @option{-Wsurprising}, @option{-Wintrinsics-std},
688 @option{-Wno-tabs}, @option{-Wintrinsic-shadow} and @option{-Wline-truncation}.
689
690 @item -Waliasing
691 @opindex @code{Waliasing}
692 @cindex aliasing
693 @cindex warnings, aliasing
694 Warn about possible aliasing of dummy arguments. Specifically, it warns
695 if the same actual argument is associated with a dummy argument with
696 @code{INTENT(IN)} and a dummy argument with @code{INTENT(OUT)} in a call
697 with an explicit interface.
698
699 The following example will trigger the warning.
700 @smallexample
701   interface
702     subroutine bar(a,b)
703       integer, intent(in) :: a
704       integer, intent(out) :: b
705     end subroutine
706   end interface
707   integer :: a
708
709   call bar(a,a)
710 @end smallexample
711
712 @item -Wampersand
713 @opindex @code{Wampersand}
714 @cindex warnings, ampersand
715 @cindex &
716 Warn about missing ampersand in continued character constants. The warning is
717 given with @option{-Wampersand}, @option{-pedantic}, @option{-std=f95},
718 @option{-std=f2003} and @option{-std=f2008}. Note: With no ampersand
719 given in a continued character constant, GNU Fortran assumes continuation
720 at the first non-comment, non-whitespace character after the ampersand
721 that initiated the continuation.
722
723 @item -Warray-temporaries
724 @opindex @code{Warray-temporaries}
725 @cindex warnings, array temporaries
726 Warn about array temporaries generated by the compiler.  The information
727 generated by this warning is sometimes useful in optimization, in order to
728 avoid such temporaries.
729
730 @item -Wcharacter-truncation
731 @opindex @code{Wcharacter-truncation}
732 @cindex warnings, character truncation
733 Warn when a character assignment will truncate the assigned string.
734
735 @item -Wline-truncation
736 @opindex @code{Wline-truncation}
737 @cindex warnings, line truncation
738 Warn when a source code line will be truncated.
739
740 @item -Wconversion
741 @opindex @code{Wconversion}
742 @cindex warnings, conversion
743 @cindex conversion
744 Warn about implicit conversions between different types.
745
746 @item -Wimplicit-interface
747 @opindex @code{Wimplicit-interface}
748 @cindex warnings, implicit interface
749 Warn if a procedure is called without an explicit interface.
750 Note this only checks that an explicit interface is present.  It does not
751 check that the declared interfaces are consistent across program units.
752
753 @item -Wintrinsics-std
754 @opindex @code{Wintrinsics-std}
755 @cindex warnings, non-standard intrinsics
756 @cindex warnings, intrinsics of other standards
757 Warn if @command{gfortran} finds a procedure named like an intrinsic not
758 available in the currently selected standard (with @option{-std}) and treats
759 it as @code{EXTERNAL} procedure because of this.  @option{-fall-intrinsics} can
760 be used to never trigger this behaviour and always link to the intrinsic
761 regardless of the selected standard.
762
763 @item -Wsurprising
764 @opindex @code{Wsurprising}
765 @cindex warnings, suspicious code
766 Produce a warning when ``suspicious'' code constructs are encountered.
767 While technically legal these usually indicate that an error has been made.
768
769 This currently produces a warning under the following circumstances:
770
771 @itemize @bullet
772 @item
773 An INTEGER SELECT construct has a CASE that can never be matched as its
774 lower value is greater than its upper value.
775
776 @item
777 A LOGICAL SELECT construct has three CASE statements.
778
779 @item
780 A TRANSFER specifies a source that is shorter than the destination.
781
782 @item
783 The type of a function result is declared more than once with the same type.  If
784 @option{-pedantic} or standard-conforming mode is enabled, this is an error.
785 @end itemize
786
787 @item -Wtabs
788 @opindex @code{Wtabs}
789 @cindex warnings, tabs
790 @cindex tabulators
791 By default, tabs are accepted as whitespace, but tabs are not members
792 of the Fortran Character Set.  For continuation lines, a tab followed
793 by a digit between 1 and 9 is supported.  @option{-Wno-tabs} will cause
794 a warning to be issued if a tab is encountered. Note, @option{-Wno-tabs}
795 is active for @option{-pedantic}, @option{-std=f95}, @option{-std=f2003},
796 @option{-std=f2008} and @option{-Wall}.
797
798 @item -Wunderflow
799 @opindex @code{Wunderflow}
800 @cindex warnings, underflow
801 @cindex underflow
802 Produce a warning when numerical constant expressions are
803 encountered, which yield an UNDERFLOW during compilation.
804
805 @item -Wintrinsic-shadow
806 @opindex @code{Wintrinsic-shadow}
807 @cindex warnings, intrinsic
808 @cindex intrinsic
809 Warn if a user-defined procedure or module procedure has the same name as an
810 intrinsic; in this case, an explicit interface or @code{EXTERNAL} or
811 @code{INTRINSIC} declaration might be needed to get calls later resolved to
812 the desired intrinsic/procedure.
813
814 @item -Wunused-parameter
815 @opindex @code{Wunused-parameter}
816 @cindex warnings, unused parameter
817 @cindex unused parameter
818 Contrary to @command{gcc}'s meaning of @option{-Wunused-parameter},
819 @command{gfortran}'s implementation of this option does not warn
820 about unused dummy arguments, but about unused @code{PARAMETER} values.
821 @option{-Wunused-parameter} is not included in @option{-Wall} but is
822 implied by @option{-Wall -Wextra}.
823
824 @item -Walign-commons
825 @opindex @code{Walign-commons}
826 @cindex warnings, alignment of COMMON blocks
827 @cindex alignment of COMMON blocks
828 By default, @command{gfortran} warns about any occasion of variables being
829 padded for proper alignment inside a COMMON block. This warning can be turned
830 off via @option{-Wno-align-commons}. See also @option{-falign-commons}.
831
832 @item -Werror
833 @opindex @code{Werror}
834 @cindex warnings, to errors
835 Turns all warnings into errors.
836 @end table
837
838 @xref{Error and Warning Options,,Options to Request or Suppress Errors and
839 Warnings, gcc,Using the GNU Compiler Collection (GCC)}, for information on
840 more options offered by the GBE shared by @command{gfortran}, @command{gcc}
841 and other GNU compilers.
842
843 Some of these have no effect when compiling programs written in Fortran.
844
845 @node Debugging Options
846 @section Options for debugging your program or GNU Fortran
847 @cindex options, debugging
848 @cindex debugging information options
849
850 GNU Fortran has various special options that are used for debugging
851 either your program or the GNU Fortran compiler.
852
853 @table @gcctabopt
854 @item -fdump-parse-tree
855 @opindex @code{fdump-parse-tree}
856 Output the internal parse tree before starting code generation.  Only
857 really useful for debugging the GNU Fortran compiler itself.
858
859 @item -ffpe-trap=@var{list}
860 @opindex @code{ffpe-trap=}@var{list}
861 Specify a list of IEEE exceptions when a Floating Point Exception
862 (FPE) should be raised.  On most systems, this will result in a SIGFPE
863 signal being sent and the program being interrupted, producing a core
864 file useful for debugging.  @var{list} is a (possibly empty) comma-separated
865 list of the following IEEE exceptions: @samp{invalid} (invalid floating
866 point operation, such as @code{SQRT(-1.0)}), @samp{zero} (division by
867 zero), @samp{overflow} (overflow in a floating point operation),
868 @samp{underflow} (underflow in a floating point operation),
869 @samp{precision} (loss of precision during operation) and @samp{denormal}
870 (operation produced a denormal value).
871
872 Some of the routines in the Fortran runtime library, like
873 @samp{CPU_TIME}, are likely to trigger floating point exceptions when
874 @code{ffpe-trap=precision} is used. For this reason, the use of 
875 @code{ffpe-trap=precision} is not recommended.
876
877 @item -fbacktrace
878 @opindex @code{fbacktrace}
879 @cindex backtrace
880 @cindex trace
881 Specify that, when a runtime error is encountered or a deadly signal is
882 emitted (segmentation fault, illegal instruction, bus error or
883 floating-point exception), the Fortran runtime
884 library should output a backtrace of the error.  This option
885 only has influence for compilation of the Fortran main program.
886
887 @item -fdump-core
888 @cindex core, dump
889 @opindex @code{fdump-core}
890 Request that a core-dump file is written to disk when a runtime error
891 is encountered on systems that support core dumps. This option is
892 only effective for the compilation of the Fortran main program.
893 @end table
894
895 @xref{Debugging Options,,Options for Debugging Your Program or GCC,
896 gcc,Using the GNU Compiler Collection (GCC)}, for more information on
897 debugging options.
898
899 @node Directory Options
900 @section Options for directory search
901 @cindex directory, options
902 @cindex options, directory search
903 @cindex search path
904 @cindex INCLUDE directive
905 @cindex directive, INCLUDE
906 These options affect how GNU Fortran searches
907 for files specified by the @code{INCLUDE} directive and where it searches
908 for previously compiled modules.
909
910 It also affects the search paths used by @command{cpp} when used to preprocess
911 Fortran source.
912
913 @table @gcctabopt
914 @item -I@var{dir}
915 @opindex @code{I}@var{dir}
916 @cindex directory, search paths for inclusion
917 @cindex inclusion, directory search paths for
918 @cindex search paths, for included files
919 @cindex paths, search
920 @cindex module search path
921 These affect interpretation of the @code{INCLUDE} directive
922 (as well as of the @code{#include} directive of the @command{cpp}
923 preprocessor).
924
925 Also note that the general behavior of @option{-I} and
926 @code{INCLUDE} is pretty much the same as of @option{-I} with
927 @code{#include} in the @command{cpp} preprocessor, with regard to
928 looking for @file{header.gcc} files and other such things.
929
930 This path is also used to search for @file{.mod} files when previously
931 compiled modules are required by a @code{USE} statement.
932
933 @xref{Directory Options,,Options for Directory Search,
934 gcc,Using the GNU Compiler Collection (GCC)}, for information on the
935 @option{-I} option.
936
937 @item -J@var{dir}
938 @item -M@var{dir}
939 @opindex @code{J}@var{dir}
940 @opindex @code{M}@var{dir}
941 @cindex paths, search
942 @cindex module search path
943 This option specifies where to put @file{.mod} files for compiled modules.
944 It is also added to the list of directories to searched by an @code{USE}
945 statement.
946
947 The default is the current directory.
948
949 @option{-M} is deprecated to avoid conflicts with existing GCC options.
950
951 @item -fintrinsic-modules-path @var{dir}
952 @opindex @code{fintrinsic-modules-path} @var{dir}
953 @cindex paths, search
954 @cindex module search path
955 This option specifies the location of pre-compiled intrinsic modules, if
956 they are not in the default location expected by the compiler.
957 @end table
958
959 @node Link Options
960 @section Influencing the linking step
961 @cindex options, linking
962 @cindex linking, static
963
964 These options come into play when the compiler links object files into an 
965 executable output file. They are meaningless if the compiler is not doing 
966 a link step.
967
968 @table @gcctabopt
969 @item -static-libgfortran
970 @opindex @code{static-libgfortran}
971 On systems that provide @file{libgfortran} as a shared and a static
972 library, this option forces the use of the static version. If no
973 shared version of @file{libgfortran} was built when the compiler was
974 configured, this option has no effect.
975 @end table
976
977
978 @node Runtime Options
979 @section Influencing runtime behavior
980 @cindex options, runtime
981
982 These options affect the runtime behavior of programs compiled with GNU Fortran.
983 @table @gcctabopt
984 @item -fconvert=@var{conversion}
985 @opindex @code{fconvert=}@var{conversion}
986 Specify the representation of data for unformatted files.  Valid
987 values for conversion are: @samp{native}, the default; @samp{swap},
988 swap between big- and little-endian; @samp{big-endian}, use big-endian
989 representation for unformatted files; @samp{little-endian}, use little-endian
990 representation for unformatted files.
991
992 @emph{This option has an effect only when used in the main program.
993 The @code{CONVERT} specifier and the GFORTRAN_CONVERT_UNIT environment
994 variable override the default specified by @option{-fconvert}.}
995
996
997 @item -fno-range-check
998 @opindex @code{fno-range-check}
999 Disable range checking of input values during integer @code{READ} operations.
1000 For example, GNU Fortran will give an error if an input value is
1001 outside of the relevant range of [@code{-HUGE()}:@code{HUGE()}]. In other words,
1002 with @code{INTEGER (kind=4) :: i} , attempting to read @math{-2147483648} will
1003 give an error unless @option{-fno-range-check} is given. 
1004
1005
1006 @item -frecord-marker=@var{length}
1007 @opindex @code{frecord-marker=}@var{length}
1008 Specify the length of record markers for unformatted files.
1009 Valid values for @var{length} are 4 and 8.  Default is 4.
1010 @emph{This is different from previous versions of @command{gfortran}},
1011 which specified a default record marker length of 8 on most
1012 systems.  If you want to read or write files compatible
1013 with earlier versions of @command{gfortran}, use @option{-frecord-marker=8}.
1014
1015 @item -fmax-subrecord-length=@var{length}
1016 @opindex @code{fmax-subrecord-length=}@var{length}
1017 Specify the maximum length for a subrecord.  The maximum permitted
1018 value for length is 2147483639, which is also the default.  Only
1019 really useful for use by the gfortran testsuite.
1020
1021 @item -fsign-zero
1022 @opindex @code{fsign-zero}
1023 When writing zero values, show the negative sign if the sign bit is set.
1024 @code{fno-sign-zero} does not print the negative sign of zero values for
1025 compatibility with F77.  Default behavior is to show the negative sign.
1026 @end table
1027
1028 @node Code Gen Options
1029 @section Options for code generation conventions
1030 @cindex code generation, conventions
1031 @cindex options, code generation
1032 @cindex options, run-time
1033
1034 These machine-independent options control the interface conventions
1035 used in code generation.
1036
1037 Most of them have both positive and negative forms; the negative form
1038 of @option{-ffoo} would be @option{-fno-foo}.  In the table below, only
1039 one of the forms is listed---the one which is not the default.  You
1040 can figure out the other form by either removing @option{no-} or adding
1041 it.
1042
1043 @table @gcctabopt
1044 @item -fno-automatic
1045 @opindex @code{fno-automatic}
1046 @cindex @code{SAVE} statement
1047 @cindex statement, @code{SAVE}
1048 Treat each program unit (except those marked as RECURSIVE) as if the
1049 @code{SAVE} statement were specified for every local variable and array
1050 referenced in it. Does not affect common blocks. (Some Fortran compilers
1051 provide this option under the name @option{-static} or @option{-save}.)
1052 The default, which is @option{-fautomatic}, uses the stack for local
1053 variables smaller than the value given by @option{-fmax-stack-var-size}.
1054 Use the option @option{-frecursive} to use no static memory. 
1055
1056 @item -ff2c
1057 @opindex ff2c
1058 @cindex calling convention
1059 @cindex @command{f2c} calling convention
1060 @cindex @command{g77} calling convention
1061 @cindex libf2c calling convention
1062 Generate code designed to be compatible with code generated
1063 by @command{g77} and @command{f2c}.
1064
1065 The calling conventions used by @command{g77} (originally implemented
1066 in @command{f2c}) require functions that return type
1067 default @code{REAL} to actually return the C type @code{double}, and
1068 functions that return type @code{COMPLEX} to return the values via an
1069 extra argument in the calling sequence that points to where to
1070 store the return value.  Under the default GNU calling conventions, such
1071 functions simply return their results as they would in GNU
1072 C---default @code{REAL} functions return the C type @code{float}, and
1073 @code{COMPLEX} functions return the GNU C type @code{complex}.
1074 Additionally, this option implies the @option{-fsecond-underscore}
1075 option, unless @option{-fno-second-underscore} is explicitly requested.
1076
1077 This does not affect the generation of code that interfaces with
1078 the @command{libgfortran} library.
1079
1080 @emph{Caution:} It is not a good idea to mix Fortran code compiled with
1081 @option{-ff2c} with code compiled with the default @option{-fno-f2c}
1082 calling conventions as, calling @code{COMPLEX} or default @code{REAL}
1083 functions between program parts which were compiled with different
1084 calling conventions will break at execution time.
1085
1086 @emph{Caution:} This will break code which passes intrinsic functions
1087 of type default @code{REAL} or @code{COMPLEX} as actual arguments, as
1088 the library implementations use the @option{-fno-f2c} calling conventions.
1089
1090 @item -fno-underscoring
1091 @opindex @code{fno-underscoring}
1092 @cindex underscore
1093 @cindex symbol names, underscores
1094 @cindex transforming symbol names
1095 @cindex symbol names, transforming
1096 Do not transform names of entities specified in the Fortran
1097 source file by appending underscores to them.
1098
1099 With @option{-funderscoring} in effect, GNU Fortran appends one
1100 underscore to external names with no underscores.  This is done to ensure
1101 compatibility with code produced by many UNIX Fortran compilers.
1102
1103 @emph{Caution}: The default behavior of GNU Fortran is
1104 incompatible with @command{f2c} and @command{g77}, please use the
1105 @option{-ff2c} option if you want object files compiled with
1106 GNU Fortran to be compatible with object code created with these
1107 tools.
1108
1109 Use of @option{-fno-underscoring} is not recommended unless you are
1110 experimenting with issues such as integration of GNU Fortran into
1111 existing system environments (vis-@`{a}-vis existing libraries, tools,
1112 and so on).
1113
1114 For example, with @option{-funderscoring}, and assuming other defaults like
1115 @option{-fcase-lower} and that @code{j()} and @code{max_count()} are
1116 external functions while @code{my_var} and @code{lvar} are local variables,
1117 a statement like
1118 @smallexample
1119 I = J() + MAX_COUNT (MY_VAR, LVAR)
1120 @end smallexample
1121 @noindent
1122 is implemented as something akin to:
1123 @smallexample
1124 i = j_() + max_count__(&my_var__, &lvar);
1125 @end smallexample
1126
1127 With @option{-fno-underscoring}, the same statement is implemented as:
1128
1129 @smallexample
1130 i = j() + max_count(&my_var, &lvar);
1131 @end smallexample
1132
1133 Use of @option{-fno-underscoring} allows direct specification of
1134 user-defined names while debugging and when interfacing GNU Fortran
1135 code with other languages.
1136
1137 Note that just because the names match does @emph{not} mean that the
1138 interface implemented by GNU Fortran for an external name matches the
1139 interface implemented by some other language for that same name.
1140 That is, getting code produced by GNU Fortran to link to code produced
1141 by some other compiler using this or any other method can be only a
1142 small part of the overall solution---getting the code generated by
1143 both compilers to agree on issues other than naming can require
1144 significant effort, and, unlike naming disagreements, linkers normally
1145 cannot detect disagreements in these other areas.
1146
1147 Also, note that with @option{-fno-underscoring}, the lack of appended
1148 underscores introduces the very real possibility that a user-defined
1149 external name will conflict with a name in a system library, which
1150 could make finding unresolved-reference bugs quite difficult in some
1151 cases---they might occur at program run time, and show up only as
1152 buggy behavior at run time.
1153
1154 In future versions of GNU Fortran we hope to improve naming and linking
1155 issues so that debugging always involves using the names as they appear
1156 in the source, even if the names as seen by the linker are mangled to
1157 prevent accidental linking between procedures with incompatible
1158 interfaces.
1159
1160 @item -fsecond-underscore
1161 @opindex @code{fsecond-underscore}
1162 @cindex underscore
1163 @cindex symbol names, underscores
1164 @cindex transforming symbol names
1165 @cindex symbol names, transforming
1166 @cindex @command{f2c} calling convention
1167 @cindex @command{g77} calling convention
1168 @cindex libf2c calling convention
1169 By default, GNU Fortran appends an underscore to external
1170 names.  If this option is used GNU Fortran appends two
1171 underscores to names with underscores and one underscore to external names
1172 with no underscores.  GNU Fortran also appends two underscores to
1173 internal names with underscores to avoid naming collisions with external
1174 names.
1175
1176 This option has no effect if @option{-fno-underscoring} is
1177 in effect.  It is implied by the @option{-ff2c} option.
1178
1179 Otherwise, with this option, an external name such as @code{MAX_COUNT}
1180 is implemented as a reference to the link-time external symbol
1181 @code{max_count__}, instead of @code{max_count_}.  This is required
1182 for compatibility with @command{g77} and @command{f2c}, and is implied
1183 by use of the @option{-ff2c} option.
1184
1185 @item -fbounds-check
1186 @opindex @code{fbounds-check}
1187 @cindex array, bounds checking
1188 @cindex bounds checking
1189 @cindex range checking
1190 @cindex subscript checking
1191 @cindex checking subscripts
1192 Enable generation of run-time checks for array subscripts
1193 and against the declared minimum and maximum values.  It also
1194 checks array indices for assumed and deferred
1195 shape arrays against the actual allocated bounds and ensures that all string
1196 lengths are equal for character array constructors without an explicit
1197 typespec.
1198
1199 Some checks require that @option{-fbounds-check} is set for
1200 the compilation of the main program.
1201
1202 Note: In the future this may also include other forms of checking, e.g.,
1203 checking substring references.
1204
1205
1206 @item fcheck-array-temporaries
1207 @opindex @code{fcheck-array-temporaries}
1208 @cindex checking array temporaries
1209 Warns at run time when for passing an actual argument a temporary array
1210 had to be generated. The information generated by this warning is
1211 sometimes useful in optimization, in order to avoid such temporaries.
1212
1213 Note: The warning is only printed once per location.
1214
1215
1216 @item -fmax-array-constructor=@var{n}
1217 @opindex @code{fmax-array-constructor}
1218 This option can be used to increase the upper limit permitted in 
1219 array constructors.  The code below requires this option to expand
1220 the array at compile time.
1221
1222 @smallexample
1223 @code{program test}
1224 @code{implicit none}
1225 @code{integer j}
1226 @code{integer, parameter :: n = 100000}
1227 @code{integer, parameter :: i(n) = (/ (2*j, j = 1, n) /)}
1228 @code{print '(10(I0,1X))', i}
1229 @code{end program test}
1230 @end smallexample
1231
1232 @emph{Caution:  This option can lead to long compile times and excessively
1233 large object files.}
1234
1235 The default value for @var{n} is 65535.
1236
1237
1238 @item -fmax-stack-var-size=@var{n}
1239 @opindex @code{fmax-stack-var-size}
1240 This option specifies the size in bytes of the largest array that will be put
1241 on the stack; if the size is exceeded static memory is used (except in
1242 procedures marked as RECURSIVE). Use the option @option{-frecursive} to
1243 allow for recursive procedures which do not have a RECURSIVE attribute or
1244 for parallel programs. Use @option{-fno-automatic} to never use the stack.
1245
1246 This option currently only affects local arrays declared with constant
1247 bounds, and may not apply to all character variables.
1248 Future versions of GNU Fortran may improve this behavior.
1249
1250 The default value for @var{n} is 32768.
1251
1252 @item -fpack-derived
1253 @opindex @code{fpack-derived}
1254 @cindex structure packing
1255 This option tells GNU Fortran to pack derived type members as closely as
1256 possible.  Code compiled with this option is likely to be incompatible
1257 with code compiled without this option, and may execute slower.
1258
1259 @item -frepack-arrays
1260 @opindex @code{frepack-arrays}
1261 @cindex repacking arrays
1262 In some circumstances GNU Fortran may pass assumed shape array
1263 sections via a descriptor describing a noncontiguous area of memory.
1264 This option adds code to the function prologue to repack the data into
1265 a contiguous block at runtime.
1266
1267 This should result in faster accesses to the array.  However it can introduce
1268 significant overhead to the function call, especially  when the passed data
1269 is noncontiguous.
1270
1271 @item -fshort-enums
1272 @opindex @code{fshort-enums}
1273 This option is provided for interoperability with C code that was
1274 compiled with the @option{-fshort-enums} option.  It will make
1275 GNU Fortran choose the smallest @code{INTEGER} kind a given
1276 enumerator set will fit in, and give all its enumerators this kind.
1277
1278 @item -fexternal-blas
1279 @opindex @code{fexternal-blas}
1280 This option will make @command{gfortran} generate calls to BLAS functions
1281 for some matrix operations like @code{MATMUL}, instead of using our own
1282 algorithms, if the size of the matrices involved is larger than a given
1283 limit (see @option{-fblas-matmul-limit}).  This may be profitable if an
1284 optimized vendor BLAS library is available.  The BLAS library will have
1285 to be specified at link time.
1286
1287 @item -fblas-matmul-limit=@var{n}
1288 @opindex @code{fblas-matmul-limit}
1289 Only significant when @option{-fexternal-blas} is in effect.
1290 Matrix multiplication of matrices with size larger than (or equal to) @var{n}
1291 will be performed by calls to BLAS functions, while others will be
1292 handled by @command{gfortran} internal algorithms. If the matrices
1293 involved are not square, the size comparison is performed using the
1294 geometric mean of the dimensions of the argument and result matrices.
1295
1296 The default value for @var{n} is 30.
1297
1298 @item -frecursive
1299 @opindex @code{frecursive}
1300 Allow indirect recursion by forcing all local arrays to be allocated
1301 on the stack. This flag cannot be used together with
1302 @option{-fmax-stack-var-size=} or @option{-fno-automatic}.
1303
1304 @item -finit-local-zero
1305 @item -finit-integer=@var{n}
1306 @item -finit-real=@var{<zero|inf|-inf|nan>} 
1307 @item -finit-logical=@var{<true|false>}
1308 @item -finit-character=@var{n}
1309 @opindex @code{finit-local-zero}
1310 @opindex @code{finit-integer}
1311 @opindex @code{finit-real}
1312 @opindex @code{finit-logical}
1313 @opindex @code{finit-character}
1314 The @option{-finit-local-zero} option instructs the compiler to
1315 initialize local @code{INTEGER}, @code{REAL}, and @code{COMPLEX}
1316 variables to zero, @code{LOGICAL} variables to false, and
1317 @code{CHARACTER} variables to a string of null bytes.  Finer-grained
1318 initialization options are provided by the
1319 @option{-finit-integer=@var{n}},
1320 @option{-finit-real=@var{<zero|inf|-inf|nan>}} (which also initializes
1321 the real and imaginary parts of local @code{COMPLEX} variables),
1322 @option{-finit-logical=@var{<true|false>}}, and
1323 @option{-finit-character=@var{n}} (where @var{n} is an ASCII character
1324 value) options.  These options do not initialize components of derived
1325 type variables, nor do they initialize variables that appear in an
1326 @code{EQUIVALENCE} statement.  (This limitation may be removed in
1327 future releases).
1328
1329 Note that the @option{-finit-real=nan} option initializes @code{REAL}
1330 and @code{COMPLEX} variables with a quiet NaN.
1331
1332 @item -falign-commons
1333 @opindex @code{falign-commons}
1334 @cindex alignment of COMMON blocks
1335 By default, @command{gfortran} enforces proper alignment of all variables in a
1336 COMMON block by padding them as needed. On certain platforms this is mandatory,
1337 on others it increases performance. If a COMMON block is not declared with
1338 consistent data types everywhere, this padding can cause trouble, and
1339 @option{-fno-align-commons } can be used to disable automatic alignment. The
1340 same form of this option should be used for all files that share a COMMON block.
1341 To avoid potential alignment issues in COMMON blocks, it is recommended to order
1342 objects from largests to smallest.
1343 @end table
1344
1345 @xref{Code Gen Options,,Options for Code Generation Conventions,
1346 gcc,Using the GNU Compiler Collection (GCC)}, for information on more options
1347 offered by the GBE
1348 shared by @command{gfortran}, @command{gcc}, and other GNU compilers.
1349
1350
1351 @c man end
1352
1353 @node Environment Variables
1354 @section Environment variables affecting @command{gfortran}
1355 @cindex environment variable
1356
1357 @c man begin ENVIRONMENT
1358
1359 The @command{gfortran} compiler currently does not make use of any environment
1360 variables to control its operation above and beyond those
1361 that affect the operation of @command{gcc}.
1362
1363 @xref{Environment Variables,,Environment Variables Affecting GCC,
1364 gcc,Using the GNU Compiler Collection (GCC)}, for information on environment
1365 variables.
1366
1367 @xref{Runtime}, for environment variables that affect the
1368 run-time behavior of programs compiled with GNU Fortran.
1369 @c man end