OSDN Git Service

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