1GFORTRAN(1)                           GNU                          GFORTRAN(1)
2
3
4

NAME

6       gfortran - GNU Fortran 95 compiler
7

SYNOPSIS

9       gfortran [-c-S-E]
10                [-g] [-pg] [-Olevel]
11                [-Wwarn...] [-pedantic]
12                [-Idir...] [-Ldir...]
13                [-Dmacro[=defn]...] [-Umacro]
14                [-foption...]        [-mmachine-option...]
15                [-o outfile] infile...
16
17       Only the most useful options are listed here; see below for the remain‐
18       der.
19

DESCRIPTION

21       The gfortran command supports all the options supported by the gcc com‐
22       mand.  Only options specific to gfortran are documented here.
23
24       All gcc and gfortran options are accepted both by gfortran and by gcc
25       (as well as any other drivers built at the same time, such as g++),
26       since adding gfortran to the gcc distribution enables acceptance of
27       gfortran options by all of the relevant drivers.
28
29       In some cases, options have positive and negative forms; the negative
30       form of -ffoo would be -fno-foo.  This manual documents only one of
31       these two forms, whichever one is not the default.
32

OPTIONS

34       Here is a summary of all the options specific to GNU Fortran, grouped
35       by type.  Explanations are in the following sections.
36
37       Fortran Language Options
38           -ffree-form  -fno-fixed-form -fdollar-ok  -fimplicit-none
39           -fmax-identifier-length -std=std -fd-lines-as-code
40           -fd-lines-as-comments -ffixed-line-length-n
41           -ffixed-line-length-none -ffree-line-length-n
42           -ffree-line-length-none -fdefault-double-8  -fdefault-integer-8
43           -fdefault-real-8 -fcray-pointer  -fopenmp  -frange-check
44
45       Warning Options
46           -fsyntax-only  -pedantic  -pedantic-errors -w  -Wall  -Waliasing
47           -Wampersand -Wconversion -Wimplicit-interface -Wnonstd-intrinsics
48           -Wsurprising -Wunderflow -Wunused-labels -Wline-truncation -W
49
50       Debugging Options
51           -fdump-parse-tree -ffpe-trap=list
52
53       Directory Options
54           -Idir  -Mdir
55
56       Runtime Options
57           -fconvert=conversion -frecord-marker=length
58
59       Code Generation Options
60           -fno-automatic -ff2c -fno-underscoring  -fsecond-underscore
61           -fbounds-check  -fmax-stack-var-size=n -fpackderived
62           -frepack-arrays  -fshort-enums
63
64       Options Controlling Fortran Dialect
65
66       The following options control the dialect of Fortran that the compiler
67       accepts:
68
69       -ffree-form
70       -ffixed-form
71           Specify the layout used by the source file.  The free form layout
72           was introduced in Fortran 90.  Fixed form was traditionally used in
73           older Fortran programs.
74
75       -fd-lines-as-code
76       -fd-lines-as-comments
77           Enables special treating for lines with d or D in fixed form
78           sources.  If the -fd-lines-as-code option is given they are treated
79           as if the first column contained a blank.  If the -fd-lines-as-com‐
80           ments option is given, they are treated as comment lines.
81
82       -fdefault-double-8
83           Set the "DOUBLE PRECISION" type to an 8 byte wide.
84
85       -fdefault-integer-8
86           Set the default integer and logical types to an 8 byte wide type.
87           Do nothing if this is already the default.
88
89       -fdefault-real-8
90           Set the default real type to an 8 byte wide type.  Do nothing if
91           this is already the default.
92
93       -fdollar-ok
94           Allow $ as a valid character in a symbol name.
95
96       -fno-backslash
97           Compile switch to change the interpretation of a backslash from
98           "C"-style escape characters to a single backslash character.
99
100       -ffixed-line-length-n
101           Set column after which characters are ignored in typical fixed-form
102           lines in the source file, and through which spaces are assumed (as
103           if padded to that length) after the ends of short fixed-form lines.
104
105           Popular values for n include 72 (the standard and the default), 80
106           (card image), and 132 (corresponds to "extended-source" options in
107           some popular compilers).  n may be none, meaning that the entire
108           line is meaningful and that continued character constants never
109           have implicit spaces appended to them to fill out the line.
110           -ffixed-line-length-0 means the same thing as
111           -ffixed-line-length-none.
112
113       -ffree-line-length-n
114           Set column after which characters are ignored in typical free-form
115           lines in the source file. For free-form, the default value is 132.
116           n may be none, meaning that the entire line is meaningful.
117           -ffree-line-length-0 means the same thing as
118           -ffree-line-length-none.
119
120       -fmax-identifier-length=n
121           Specify the maximum allowed identifier length. Typical values are
122           31 (Fortran 95) and 63 (Fortran 200x).
123
124       -fimplicit-none
125           Specify that no implicit typing is allowed, unless overridden by
126           explicit IMPLICIT statements.  This is the equivalent of adding
127           implicit none to the start of every procedure.
128
129       -fcray-pointer
130           Enables the Cray pointer extension, which provides a C-like
131           pointer.
132
133       -fopenmp
134           Enables handling of OpenMP "!$omp" directives in free form and
135           "c$omp", *$omp and "!$omp" directives in fixed form, enables "!$"
136           conditional compilation sentinels in free form and "c$", "*$" and
137           "!$" sentinels in fixed form and when linking arranges for the
138           OpenMP runtime library to be linked in.
139
140       -frange-check
141           Enable range checking on results of simplification of constant
142           expressions during compilation.  For example, by default, gfortran
143           will give an overflow error at compile time when simplifying "a =
144           EXP(1000)".  With -fno-range-check, no error will be given and the
145           variable "a" will be assigned the value "+Infinity".
146
147       -std=std
148           Conform to the specified standard.  Allowed values for std are gnu,
149           f95, f2003 and legacy.
150
151       Options to Request or Suppress Warnings
152
153       Warnings are diagnostic messages that report constructions which are
154       not inherently erroneous but which are risky or suggest there might
155       have been an error.
156
157       You can request many specific warnings with options beginning -W, for
158       example -Wimplicit to request warnings on implicit declarations.  Each
159       of these specific warning options also has a negative form beginning
160       -Wno- to turn off warnings; for example, -Wno-implicit.  This manual
161       lists only one of the two forms, whichever is not the default.
162
163       These options control the amount and kinds of warnings produced by GNU
164       Fortran:
165
166       -fsyntax-only
167           Check the code for syntax errors, but don't do anything beyond
168           that.
169
170       -pedantic
171           Issue warnings for uses of extensions to FORTRAN 95.  -pedantic
172           also applies to C-language constructs where they occur in GNU For‐
173           tran source files, such as use of \e in a character constant within
174           a directive like #include.
175
176           Valid FORTRAN 95 programs should compile properly with or without
177           this option.  However, without this option, certain GNU extensions
178           and traditional Fortran features are supported as well.  With this
179           option, many of them are rejected.
180
181           Some users try to use -pedantic to check programs for conformance.
182           They soon find that it does not do quite what they want---it finds
183           some nonstandard practices, but not all.  However, improvements to
184           gfortran in this area are welcome.
185
186           This should be used in conjunction with -std=std.
187
188       -pedantic-errors
189           Like -pedantic, except that errors are produced rather than warn‐
190           ings.
191
192       -w  Inhibit all warning messages.
193
194       -Wall
195           Enables commonly used warning options pertaining to usage that we
196           recommend avoiding and that we believe are easy to avoid. This cur‐
197           rently includes -Wunused-labels, -Waliasing, -Wampersand, -Wsur‐
198           prising, -Wnonstd-intrinsic, and -Wline-truncation.
199
200       -Waliasing
201           Warn about possible aliasing of dummy arguments. Specifically, it
202           warns if the same actual argument is associated with a dummy argu‐
203           ment with "intent(in)" and a dummy argument with "intent(out)" in a
204           call with an explicit interface.
205
206           The following example will trigger the warning.
207
208                     interface
209                       subroutine bar(a,b)
210                         integer, intent(in) :: a
211                         integer, intent(out) :: b
212                       end subroutine
213                     end interface
214                     integer :: a
215
216                     call bar(a,a)
217
218       -Wampersand
219           Warn about missing ampersand in continued character literals. The
220           warning is given with -Wampersand, -pedantic, and -std=f95.  Note:
221           With no ampersand given in a continued character literal, gfortran
222           assumes continuation at the first non-comment, non-whitespace char‐
223           acter.
224
225       -Wconversion
226           Warn about implicit conversions between different types.
227
228       -Wimplicit-interface
229           Warn about when procedure are called without an explicit interface.
230           Note this only checks that an explicit interface is present.  It
231           does not check that the declared interfaces are consistent across
232           program units.
233
234       -Wnonstd-intrinsic
235           Warn if the user tries to use an intrinsic that does not belong to
236           the standard the user has chosen via the -std option.
237
238       -Wsurprising
239           Produce a warning when "suspicious" code constructs are encoun‐
240           tered.  While technically legal these usually indicate that an
241           error has been made.
242
243           This currently produces a warning under the following circum‐
244           stances:
245
246           *   An INTEGER SELECT construct has a CASE that can never be
247               matched as its lower value is greater than its upper value.
248
249           *   A LOGICAL SELECT construct has three CASE statements.
250
251       -Wunderflow
252           Produce a warning when numerical constant expressions are encoun‐
253           tered, which yield an UNDERFLOW during compilation.
254
255       -Wunused-labels
256           Warn whenever a label is defined but never referenced.
257
258       -Werror
259           Turns all warnings into errors.
260
261       -W  Turns on "extra warnings" and, if optimization is specified via -O,
262           the -Wuninitialized option.  (This might change in future versions
263           of gfortran
264
265       Some of these have no effect when compiling programs written in For‐
266       tran.
267
268       Options for Debugging Your Program or GNU Fortran
269
270       GNU Fortran has various special options that are used for debugging
271       either your program or gfortran
272
273       -fdump-parse-tree
274           Output the internal parse tree before starting code generation.
275           Only really useful for debugging gfortran itself.
276
277       -ffpe-trap=list
278           Specify a list of IEEE exceptions when a Floating Point Exception
279           (FPE) should be raised.  On most systems, this will result in a
280           SIGFPE signal being sent and the program being interrupted, produc‐
281           ing a core file useful for debugging.  list is a (possibly empty)
282           comma-separated list of the following IEEE exceptions: invalid
283           (invalid floating point operation, such as "sqrt(-1.0)"), zero
284           (division by zero), overflow (overflow in a floating point opera‐
285           tion), underflow (underflow in a floating point operation), preci‐
286           sion (loss of precision during operation) and denormal (operation
287           produced a denormal denormal value).
288
289       Options for Directory Search
290
291       These options affect how gfortran searches for files specified by the
292       "INCLUDE" directive and where it searches for previously compiled mod‐
293       ules.
294
295       It also affects the search paths used by cpp when used to preprocess
296       Fortran source.
297
298       -Idir
299           These affect interpretation of the "INCLUDE" directive (as well as
300           of the "#include" directive of the cpp preprocessor).
301
302           Also note that the general behavior of -I and "INCLUDE" is pretty
303           much the same as of -I with "#include" in the cpp preprocessor,
304           with regard to looking for header.gcc files and other such things.
305
306           This path is also used to search for .mod files when previously
307           compiled modules are required by a "USE" statement.
308
309       -Mdir
310       -Jdir
311           This option specifies where to put .mod files for compiled modules.
312           It is also added to the list of directories to searched by an "USE"
313           statement.
314
315           The default is the current directory.
316
317           -J is an alias for -M to avoid conflicts with existing GCC options.
318
319       Influencing runtime behavior
320
321       These options affect the runtime behavior of gfortran.
322
323       -fconvert=conversion
324           Specify the representation of data for unformatted files.  Valid
325           values for conversion are: native, the default; swap, swap between
326           big- and little-endian; big-endian, use big-endian representation
327           for unformatted files; little-endian, use little-endian representa‐
328           tion for unformatted files.
329
330           This option has an effect only when used in the main program.  The
331           "CONVERT" specifier and the GFORTRAN_CONVERT_UNIT environment vari‐
332           able override the default specified by -fconvert.
333
334       -frecord-marker=length
335           Specify the length of record markers for unformatted files.  Valid
336           values for length are 4 and 8.  Default is whatever "off_t" is
337           specified to be on that particular system.  Note that specifying
338           length as 4 limits the record length of unformatted files to 2 GB.
339           This option does not extend the maximum possible record length on
340           systems where "off_t" is a four_byte quantity.
341
342       Options for Code Generation Conventions
343
344       These machine-independent options control the interface conventions
345       used in code generation.
346
347       Most of them have both positive and negative forms; the negative form
348       of -ffoo would be -fno-foo.  In the table below, only one of the forms
349       is listed---the one which is not the default.  You can figure out the
350       other form by either removing no- or adding it.
351
352       -fno-automatic
353           Treat each program unit as if the "SAVE" statement was specified
354           for every local variable and array referenced in it. Does not
355           affect common blocks. (Some Fortran compilers provide this option
356           under the name -static.)
357
358       -ff2c
359           Generate code designed to be compatible with code generated by g77
360           and f2c.
361
362           The calling conventions used by g77 (originally implemented in f2c)
363           require functions that return type default "REAL" to actually
364           return the C type "double", and functions that return type "COM‐
365           PLEX" to return the values via an extra argument in the calling
366           sequence that points to where to store the return value.  Under the
367           default GNU calling conventions, such functions simply return their
368           results as they would in GNU C -- default "REAL" functions return
369           the C type "float", and "COMPLEX" functions return the GNU C type
370           "complex".  Additionally, this option implies the -fsecond-under‐
371           score option, unless -fno-second-underscore is explicitly
372           requested.
373
374           This does not affect the generation of code that interfaces with
375           the libgfortran library.
376
377           Caution: It is not a good idea to mix Fortran code compiled with
378           "-ff2c" with code compiled with the default "-fno-f2c" calling con‐
379           ventions as, calling "COMPLEX" or default "REAL" functions between
380           program parts which were compiled with different calling conven‐
381           tions will break at execution time.
382
383           Caution: This will break code which passes intrinsic functions of
384           type default "REAL" or "COMPLEX" as actual arguments, as the
385           library implementations use the -fno-f2c calling conventions.
386
387       -fno-underscoring
388           Do not transform names of entities specified in the Fortran source
389           file by appending underscores to them.
390
391           With -funderscoring in effect, gfortran appends one underscore to
392           external names with no underscores.  This is done to ensure compat‐
393           ibility with code produced by many UNIX Fortran compilers.
394
395           Caution: The default behavior of gfortran is incompatible with f2c
396           and g77, please use the -ff2c option if you want object files com‐
397           piled with gfortran to be compatible with object code created with
398           these tools.
399
400           Use of -fno-underscoring is not recommended unless you are experi‐
401           menting with issues such as integration of (GNU) Fortran into
402           existing system environments (vis-a-vis existing libraries, tools,
403           and so on).
404
405           For example, with -funderscoring, and assuming other defaults like
406           -fcase-lower and that j() and max_count() are external functions
407           while my_var and lvar are local variables, a statement like
408
409                   I = J() + MAX_COUNT (MY_VAR, LVAR)
410
411           is implemented as something akin to:
412
413                   i = j_() + max_count__(&my_var__, &lvar);
414
415           With -fno-underscoring, the same statement is implemented as:
416
417                   i = j() + max_count(&my_var, &lvar);
418
419           Use of -fno-underscoring allows direct specification of user-
420           defined names while debugging and when interfacing gfortran code
421           with other languages.
422
423           Note that just because the names match does not mean that the
424           interface implemented by gfortran for an external name matches the
425           interface implemented by some other language for that same name.
426           That is, getting code produced by gfortran to link to code produced
427           by some other compiler using this or any other method can be only a
428           small part of the overall solution---getting the code generated by
429           both compilers to agree on issues other than naming can require
430           significant effort, and, unlike naming disagreements, linkers nor‐
431           mally cannot detect disagreements in these other areas.
432
433           Also, note that with -fno-underscoring, the lack of appended under‐
434           scores introduces the very real possibility that a user-defined
435           external name will conflict with a name in a system library, which
436           could make finding unresolved-reference bugs quite difficult in
437           some cases---they might occur at program run time, and show up only
438           as buggy behavior at run time.
439
440           In future versions of gfortran we hope to improve naming and link‐
441           ing issues so that debugging always involves using the names as
442           they appear in the source, even if the names as seen by the linker
443           are mangled to prevent accidental linking between procedures with
444           incompatible interfaces.
445
446       -fsecond-underscore
447           By default, gfortran appends an underscore to external names.  If
448           this option is used gfortran appends two underscores to names with
449           underscores and one underscore to external names with no under‐
450           scores.  (gfortran also appends two underscores to internal names
451           with underscores to avoid naming collisions with external names.
452
453           This option has no effect if -fno-underscoring is in effect.  It is
454           implied by the -ff2c option.
455
456           Otherwise, with this option, an external name such as MAX_COUNT is
457           implemented as a reference to the link-time external symbol
458           max_count__, instead of max_count_.  This is required for compati‐
459           bility with g77 and f2c, and is implied by use of the -ff2c option.
460
461       -fbounds-check
462           Enable generation of run-time checks for array subscripts and
463           against the declared minimum and maximum values.  It also checks
464           array indices for assumed and deferred shape arrays against the
465           actual allocated bounds.
466
467           In the future this may also include other forms of checking, eg.
468           checking substring references.
469
470       -fmax-stack-var-size=n
471           This option specifies the size in bytes of the largest array that
472           will be put on the stack.
473
474           This option currently only affects local arrays declared with con‐
475           stant bounds, and may not apply to all character variables.  Future
476           versions of gfortran may improve this behavior.
477
478           The default value for n is 32768.
479
480       -fpackderived
481           This option tells gfortran to pack derived type members as closely
482           as possible.  Code compiled with this option is likely to be incom‐
483           patible with code compiled without this option, and may execute
484           slower.
485
486       -frepack-arrays
487           In some circumstances gfortran may pass assumed shape array sec‐
488           tions via a descriptor describing a discontiguous area of memory.
489           This option adds code to the function prologue to repack the data
490           into a contiguous block at runtime.
491
492           This should result in faster accesses to the array.  However it can
493           introduce significant overhead to the function call, especially
494           when the passed data is discontiguous.
495
496       -fshort-enums
497           This option is provided for interoperability with C code that was
498           compiled with the -fshort-enums option.  It will make gfortran
499           choose the smallest "INTEGER" kind a given enumerator set will fit
500           in, and give all its enumerators this kind.
501

ENVIRONMENT

503       GNU Fortran 95 currently does not make use of any environment variables
504       to control its operation above and beyond those that affect the opera‐
505       tion of gcc.
506

BUGS

508       For instructions on reporting bugs, see <http://gcc.gnu.org/bugs.html>.
509

SEE ALSO

511       gpl(7), gfdl(7), fsf-funding(7), cpp(1), gcov(1), gcc(1), as(1), ld(1),
512       gdb(1), adb(1), dbx(1), sdb(1) and the Info entries for gcc, cpp, gfor‐
513       tran, as, ld, binutils and gdb.
514

AUTHOR

516       See the Info entry for gfortran for contributors to GCC and GFORTRAN.
517
519       Copyright (c) 2004, 2005, 2006 Free Software Foundation, Inc.
520
521       Permission is granted to copy, distribute and/or modify this document
522       under the terms of the GNU Free Documentation License, Version 1.2 or
523       any later version published by the Free Software Foundation; with the
524       Invariant Sections being "GNU General Public License" and "Funding Free
525       Software", the Front-Cover texts being (a) (see below), and with the
526       Back-Cover Texts being (b) (see below).  A copy of the license is
527       included in the gfdl(7) man page.
528
529       (a) The FSF's Front-Cover Text is:
530
531            A GNU Manual
532
533       (b) The FSF's Back-Cover Text is:
534
535            You have freedom to copy and modify this GNU Manual, like GNU
536            software.  Copies published by the Free Software Foundation raise
537            funds for GNU development.
538
539
540
541gcc-4.1.2                         2007-09-25                       GFORTRAN(1)
Impressum