OSDN Git Service

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