OSDN Git Service

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