OSDN Git Service

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