OSDN Git Service

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