OSDN Git Service

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