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