aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/invoke.texi
blob: 42f3b5ee3b7d89013395aad502433f4a17abd2d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
@c Copyright (C) 2004, 2005, 2006, 2007
@c Free Software Foundation, Inc.
@c This is part of the GNU Fortran manual.   
@c For copying conditions, see the file gfortran.texi.

@ignore
@c man begin COPYRIGHT
Copyright @copyright{} 2004, 2005, 2006, 2007
Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``GNU General Public License'' and ``Funding
Free Software'', the Front-Cover texts being (a) (see below), and with
the Back-Cover Texts being (b) (see below).  A copy of the license is
included in the gfdl(7) man page.
 
(a) The FSF's Front-Cover Text is:

     A GNU Manual

(b) The FSF's Back-Cover Text is:

     You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development.
@c man end
@c Set file name and title for the man page.
@setfilename gfortran
@settitle GNU Fortran compiler.
@c man begin SYNOPSIS
gfortran [@option{-c}|@option{-S}|@option{-E}]
         [@option{-g}] [@option{-pg}] [@option{-O}@var{level}]
         [@option{-W}@var{warn}@dots{}] [@option{-pedantic}]
         [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
         [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}]
         [@option{-f}@var{option}@dots{}]
	 [@option{-m}@var{machine-option}@dots{}]
         [@option{-o} @var{outfile}] @var{infile}@dots{}

Only the most useful options are listed here; see below for the
remainder.
@c man end
@c man begin SEEALSO
gpl(7), gfdl(7), fsf-funding(7),
cpp(1), gcov(1), gcc(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1)
and the Info entries for @file{gcc}, @file{cpp}, @file{gfortran}, @file{as},
@file{ld}, @file{binutils} and @file{gdb}.
@c man end
@c man begin BUGS
For instructions on reporting bugs, see
@w{@uref{http://gcc.gnu.org/bugs.html}}.
@c man end
@c man begin AUTHOR
See the Info entry for @command{gfortran} for contributors to GCC and
GNU Fortran.
@c man end
@end ignore

@node Invoking GNU Fortran
@chapter GNU Fortran Command Options
@cindex GNU Fortran command options
@cindex command options
@cindex options, @command{gfortran} command

@c man begin DESCRIPTION

The @command{gfortran} command supports all the options supported by the
@command{gcc} command.  Only options specific to GNU Fortran are documented here.

@xref{Invoking GCC,,GCC Command Options,gcc,Using the GNU Compiler
Collection (GCC)}, for information
on the non-Fortran-specific aspects of the @command{gcc} command (and,
therefore, the @command{gfortran} command).

@cindex options, negative forms
@cindex negative forms of options
All GCC and GNU Fortran options
are accepted both by @command{gfortran} and by @command{gcc}
(as well as any other drivers built at the same time,
such as @command{g++}),
since adding GNU Fortran to the GCC distribution
enables acceptance of GNU Fortran options
by all of the relevant drivers.

In some cases, options have positive and negative forms;
the negative form of @option{-ffoo} would be @option{-fno-foo}.
This manual documents only one of these two forms, whichever
one is not the default.
@c man end

@menu
* Option Summary::      Brief list of all @command{gfortran} options,
                        without explanations.
* Fortran Dialect Options::  Controlling the variant of Fortran language
                             compiled.
* Error and Warning Options::     How picky should the compiler be?
* Debugging Options::   Symbol tables, measurements, and debugging dumps.
* Directory Options::   Where to find module files
* Runtime Options::     Influencing runtime behavior
* Code Gen Options::    Specifying conventions for function calls, data layout
                        and register usage.
* Environment Variables:: Env vars that affect @command{gfortran}.
@end menu

@node Option Summary
@section Option Summary

@c man begin OPTIONS

Here is a summary of all the options specific to GNU Fortran, grouped
by type.  Explanations are in the following sections.

@table @emph
@item Fortran Language Options
@xref{Fortran Dialect Options,,Options Controlling Fortran Dialect}.
@gccoptlist{-fall-intrinsics  -ffree-form  -fno-fixed-form @gol
-fdollar-ok  -fimplicit-none  -fmax-identifier-length @gol
-std=@var{std} -fd-lines-as-code  -fd-lines-as-comments @gol
-ffixed-line-length-@var{n}  -ffixed-line-length-none @gol
-ffree-line-length-@var{n}  -ffree-line-length-none @gol
-fdefault-double-8  -fdefault-integer-8  -fdefault-real-8 @gol
-fcray-pointer  -fopenmp  -frange-check }

@item Error and Warning Options
@xref{Error and Warning Options,,Options to Request or Suppress Errors
and Warnings}.
@gccoptlist{-fmax-errors=@var{n} @gol
-fsyntax-only  -pedantic  -pedantic-errors @gol
-w  -Wall  -Waliasing  -Wampersand  -Wconversion  -Wimplicit-interface @gol
-Wtabs -Wnonstd-intrinsics -Wsurprising -Wunderflow @gol
-Wline-truncation -W}

@item Debugging Options
@xref{Debugging Options,,Options for Debugging Your Program or GCC}.
@gccoptlist{-fdump-parse-tree  -ffpe-trap=@var{list}}

@item Directory Options
@xref{Directory Options,,Options for Directory Search}.
@gccoptlist{-I@var{dir}  -M@var{dir}}

@item Runtime Options
@xref{Runtime Options,,Options for influencing runtime behavior}.
@gccoptlist{-fconvert=@var{conversion} -frecord-marker=@var{length}}

@item Code Generation Options
@xref{Code Gen Options,,Options for Code Generation Conventions}.
@gccoptlist{-fno-automatic  -ff2c  -fno-underscoring
-fsecond-underscore @gol
-fbounds-check  -fmax-stack-var-size=@var{n} @gol
-fpack-derived  -frepack-arrays  -fshort-enums  -fexternal-blas @gol
-fblas-matmul-limit=@var{n}}
@end table

@menu
* Fortran Dialect Options::  Controlling the variant of Fortran language
                             compiled.
* Error and Warning Options::     How picky should the compiler be?
* Debugging Options::   Symbol tables, measurements, and debugging dumps.
* Directory Options::   Where to find module files
* Runtime Options::     Influencing runtime behavior
* Code Gen Options::    Specifying conventions for function calls, data layout
                        and register usage.
@end menu

@node Fortran Dialect Options
@section Options Controlling Fortran Dialect
@cindex dialect options
@cindex language, dialect options
@cindex options, dialect

The following options control the details of the Fortran dialect
accepted by the compiler:

@table @gcctabopt
@item -ffree-form
@item -ffixed-form
@cindex @code{-ffree-form} option
@cindex option, @code{-ffree-form}
@cindex @code{-fno-fixed-form} option
@cindex option, @code{-fno-fixed-form}
@cindex source file format
@cindex free form
@cindex fixed form
@cindex Source Form
@cindex Fortran 90, features
Specify the layout used by the source file.  The free form layout
was introduced in Fortran 90.  Fixed form was traditionally used in
older Fortran programs.  When neither option is specified, the source
form is determined by the file extension.

@item -fall-intrinsics
@cindex @code{-fall-intrinsics} option
@cindex option, @code{-fall-intrinsics}
Accept all of the intrinsic procedures provided in libgfortran 
without regard to the setting of @option{-std}.  In particular, 
this option can be quite useful with @option{-std=f95}.  Additionally,
@command{gfortran} will ignore @option{-Wnonstd-intrinsics}.

@item -fd-lines-as-code
@item -fd-lines-as-comment
@cindex @code{-fd-lines-as-code}, option
@cindex option, @code{-fd-lines-as-code}
@cindex @code{-fd-lines-as-comments}, option
@cindex option, @code{-fd-lines-as-comments}
Enable special treatment for lines beginning with @code{d} or @code{D}
in fixed form sources.  If the @option{-fd-lines-as-code} option is
given they are treated as if the first column contained a blank.  If the
@option{-fd-lines-as-comments} option is given, they are treated as
comment lines.

@item -fdefault-double-8
@cindex @code{-fdefault-double-8}, option
@cindex option, @code{-fdefault-double-8}
Set the @code{DOUBLE PRECISION} type to an 8 byte wide type.

@item -fdefault-integer-8
@cindex @code{-fdefault-integer-8}, option
@cindex option, @code{-fdefault-integer-8}
Set the default integer and logical types to an 8 byte wide type.
Do nothing if this is already the default.

@item -fdefault-real-8
@cindex @code{-fdefault-real-8}, option
@cindex option, @code{-fdefault-real-8}
Set the default real type to an 8 byte wide type.
Do nothing if this is already the default.

@item -fdollar-ok
@cindex @code{-fdollar-ok} option
@cindex option, @code{-fdollar-ok}
@cindex dollar sign
@cindex symbol names
@cindex character set
Allow @samp{$} as a valid character in a symbol name.

@item -fno-backslash
@cindex @code{-fno-backslash} option
@cindex option, @code{-fno-backslash}
@cindex backslash
@cindex escape characters
Change the interpretation of backslashes in string literals from
``C-style'' escape characters to a single backslash character.

@item -ffixed-line-length-@var{n}
@cindex @code{-ffixed-line-length-}@var{n} option
@cindex option, @code{-ffixed-line-length-}@var{n}
@cindex source file format
@cindex lines, length
@cindex length of source lines
@cindex fixed form
@cindex limits, lengths of source lines
Set column after which characters are ignored in typical fixed-form
lines in the source file, and through which spaces are assumed (as
if padded to that length) after the ends of short fixed-form lines.

@cindex card image
@cindex extended-source option
Popular values for @var{n} include 72 (the
standard and the default), 80 (card image), and 132 (corresponding
to ``extended-source'' options in some popular compilers).
@var{n} may also be @samp{none}, meaning that the entire line is meaningful
and that continued character constants never have implicit spaces appended
to them to fill out the line.
@option{-ffixed-line-length-0} means the same thing as
@option{-ffixed-line-length-none}.

@item -ffree-line-length-@var{n}
@cindex @code{-ffree-line-length-}@var{n} option
@cindex option, @code{-ffree-line-length-}@var{n}
@cindex source file format
@cindex lines, length
@cindex length of source lines
@cindex free form
@cindex limits, lengths of source lines
Set column after which characters are ignored in typical free-form
lines in the source file. The default value is 132.
@var{n} may be @samp{none}, meaning that the entire line is meaningful.
@option{-ffree-line-length-0} means the same thing as
@option{-ffree-line-length-none}.

@item -fmax-identifier-length=@var{n}
@cindex @code{-fmax-identifier-length=}@var{n} option
@cindex option @option{-fmax-identifier-length=}@var{n}
Specify the maximum allowed identifier length. Typical values are
31 (Fortran 95) and 63 (Fortran 2003).

@item -fimplicit-none
@cindex @code{-fimplicit-none} option
@cindex option, @code{-fimplicit-none}
Specify that no implicit typing is allowed, unless overridden by explicit
@code{IMPLICIT} statements.  This is the equivalent of adding
@code{implicit none} to the start of every procedure.

@item -fcray-pointer
@cindex @code{-fcray-pointer} option
@cindex option, @code{-fcray-pointer}
Enable the Cray pointer extension, which provides C-like pointer
functionality.

@item -fopenmp
@cindex @code{-fopenmp} option
@cindex option, @code{-fopenmp}
@cindex OpenMP
Enable the OpenMP extensions.  This includes OpenMP @code{!$omp} directives
in free form
and @code{c$omp}, @code{*$omp} and @code{!$omp} directives in fixed form,
@code{!$} conditional compilation sentinels in free form
and @code{c$}, @code{*$} and @code{!$} sentinels in fixed form, 
and when linking arranges for the OpenMP runtime library to be linked
in.

@item -frange-check
@cindex @code{-frange-check} option
@cindex option, @code{-frange-check}
Enable range checking on results of simplification of constant
expressions during compilation.  For example, by default, GNU Fortran
will give an overflow error at compile time when simplifying @code{a =
EXP(1000)}. With @option{-fno-range-check}, no error will be given and
the variable @code{a} will be assigned the value @code{+Infinity}.
Similarly, @code{DATA i/Z'FFFFFFFF'/} will result in an integer overflow
on most systems, but with @option{-fno-range-check} the value will
``wrap around'' and @code{i} will be initialized to @math{-1} instead.

@item -std=@var{std}
@cindex @code{-std=}@var{std} option
@cindex option, @code{-std=}@var{std}
Conform to the specified standard.  The default value for @var{std} is
@samp{gnu}; a superset of the Fortran 95 standard which includes all
of the GNU extensions recommended for use in new code.  The @samp{legacy}
value also includes obsolete extensions that may be required for old 
non-standard programs.  Strict conformance to the Fortran 95 and Fortran 2003
standards is specified by @samp{f95} and @samp{f2003}, respectively.

@end table

@node Error and Warning Options
@section Options to Request or Suppress Errors and Warnings
@cindex options, warnings
@cindex options, errors
@cindex warnings, suppressing
@cindex messages, error
@cindex messages, warning
@cindex suppressing warnings

Errors are diagnostic messages that report that the GNU Fortran compiler
cannot compile the relevant piece of source code.  The compiler will
continue to process the program in an attempt to report further errors
to aid in debugging, but will not produce any compiled output.  

Warnings are diagnostic messages that report constructions which
are not inherently erroneous but which are risky or suggest there is
likely to be a bug in the program.  Unless @option{-Werror} is specified,
they do not prevent compilation of the program.

You can request many specific warnings with options beginning @option{-W},
for example @option{-Wimplicit} to request warnings on implicit
declarations.  Each of these specific warning options also has a
negative form beginning @option{-Wno-} to turn off warnings;
for example, @option{-Wno-implicit}.  This manual lists only one of the
two forms, whichever is not the default.

These options control the amount and kinds of errors and warnings produced
by GNU Fortran:

@table @gcctabopt
@item -fmax-errors-@var{n}
@cindex @code{-fmax-errors-}@var{n} option
@cindex option, @code{-fmax-errors-}@var{n}
@cindex errors, limiting
Limits the maximum number of error messages to @var{n}, at which point
GNU Fortran bails out rather than attempting to continue processing the
source code.  If @var{n} is 0, there is no limit on the number of error
messages produced.

@item -fsyntax-only
@cindex @code{-fsyntax-only} option
@cindex option, @code{-fsyntax-only}
@cindex syntax checking
Check the code for syntax errors, but don't do anything beyond that.

@item -pedantic
@cindex @code{-pedantic} option
@cindex option, @code{-pedantic}
Issue warnings for uses of extensions to Fortran 95.
@option{-pedantic} also applies to C-language constructs where they
occur in GNU Fortran source files, such as use of @samp{\e} in a
character constant within a directive like @code{#include}.

Valid Fortran 95 programs should compile properly with or without
this option.
However, without this option, certain GNU extensions and traditional
Fortran features are supported as well.
With this option, many of them are rejected.

Some users try to use @option{-pedantic} to check programs for conformance.
They soon find that it does not do quite what they want---it finds some
nonstandard practices, but not all.
However, improvements to GNU Fortran in this area are welcome.

This should be used in conjunction with @option{-std=f95} or
@option{-std=f2003}.

@item -pedantic-errors
@cindex @code{-pedantic-errors} option
@cindex option, @code{-pedantic-errors}
Like @option{-pedantic}, except that errors are produced rather than
warnings.

@item -w
@cindex @code{-w} option
@cindex option, @code{-w}
Inhibit all warning messages.

@item -Wall
@cindex @code{-Wall} option
@cindex option, @code{-Wall}
@cindex all warnings
@cindex warnings, all
Enables commonly used warning options pertaining to usage that
we recommend avoiding and that we believe are easy to avoid.
This currently includes @option{-Waliasing},
@option{-Wampersand}, @option{-Wsurprising}, @option{-Wnonstd-intrinsic},
@option{-Wno-tabs}, and @option{-Wline-truncation}.

@item -Waliasing
@cindex @code{-Waliasing} option
@cindex option, @code{-Waliasing}
@cindex aliasing
Warn about possible aliasing of dummy arguments. Specifically, it warns
if the same actual argument is associated with a dummy argument with
@code{INTENT(IN)} and a dummy argument with @code{INTENT(OUT)} in a call
with an explicit interface.

The following example will trigger the warning.
@smallexample
  interface
    subroutine bar(a,b)
      integer, intent(in) :: a
      integer, intent(out) :: b
    end subroutine
  end interface
  integer :: a

  call bar(a,a)
@end smallexample

@item -Wampersand
@cindex @code{-Wampersand} option
@cindex option, @code{-Wampersand}
@cindex ampersand
Warn about missing ampersand in continued character constants. The warning is
given with @option{-Wampersand}, @option{-pedantic}, @option{-std=f95}, and
@option{-std=f2003}. Note: With no ampersand given in a continued character
constant, GNU Fortran assumes continuation at the first non-comment,
non-whitespace character after the ampersand that initiated the continuation.

@item -Wconversion
@cindex @code{-Wconversion} option
@cindex option, @code{-Wconversion}
@cindex conversion
Warn about implicit conversions between different types.

@item -Wimplicit-interface
@cindex @code{-Wimplicit-interface} option
@cindex option, @code{-Wimplicit-interface}
Warn if a procedure is called without an explicit interface.
Note this only checks that an explicit interface is present.  It does not
check that the declared interfaces are consistent across program units.

@item -Wnonstd-intrinsic
@cindex @code{-Wnonstd-intrinsic} option
@cindex option, @code{-Wnonstd-intrinsic}
Warn if the user tries to use an intrinsic that does not belong to the 
standard the user has chosen via the -std option.

@item -Wsurprising
@cindex @code{-Wsurprising} option
@cindex option, @code{-Wsurprising}
@cindex Suspicious code
Produce a warning when ``suspicious'' code constructs are encountered.
While technically legal these usually indicate that an error has been made.

This currently produces a warning under the following circumstances:

@itemize @bullet
@item
An INTEGER SELECT construct has a CASE that can never be matched as its
lower value is greater than its upper value.

@item
A LOGICAL SELECT construct has three CASE statements.
@end itemize

@item -Wtabs
@cindex @code{-Wtabs} option
@cindex option, @code{-Wtabs}
@cindex Tabs
By default, tabs are accepted as whitespace, but tabs are not members
of the Fortran Character Set.  @option{-Wno-tabs} will cause a warning
to be issued if a tab is encountered. Note, @option{-Wno-tabs} is active
for @option{-pedantic}, @option{-std=f95}, and @option{-Wall}.

@item -Wunderflow
@cindex @code{-Wunderflow} option
@cindex option, @code{-Wunderflow}
@cindex UNDERFLOW
Produce a warning when numerical constant expressions are
encountered, which yield an UNDERFLOW during compilation.

@item -Werror
@cindex @code{-Werror} option
@cindex option, @code{-Werror}
Turns all warnings into errors.

@item -W
@cindex @code{-W} option
@cindex option, @code{-W}
@cindex extra warnings
@cindex warnings, extra
Turns on ``extra warnings'' and, if optimization is specified
via @option{-O}, the @option{-Wuninitialized} option.
(This might change in future versions of GNU Fortran.)
@end table

@xref{Error and Warning Options,,Options to Request or Suppress Errors and
Warnings, gcc,Using the GNU Compiler Collection (GCC)}, for information on
more options offered by the GBE shared by @command{gfortran}, @command{gcc}
and other GNU compilers.

Some of these have no effect when compiling programs written in Fortran.

@node Debugging Options
@section Options for Debugging Your Program or GNU Fortran
@cindex options, debugging
@cindex debugging information options

GNU Fortran has various special options that are used for debugging
either your program or the GNU Fortran compiler.

@table @gcctabopt
@item -fdump-parse-tree
@cindex @code{-fdump-parse-tree} option
@cindex option, @code{-fdump-parse-tree}
Output the internal parse tree before starting code generation.  Only
really useful for debugging the GNU Fortran compiler itself.

@item -ffpe-trap=@var{list}
@cindex @code{-ffpe-trap=}@var{list} option
@cindex option, @code{-ffpe-trap=}@var{list}
Specify a list of IEEE exceptions when a Floating Point Exception
(FPE) should be raised.  On most systems, this will result in a SIGFPE
signal being sent and the program being interrupted, producing a core
file useful for debugging.  @var{list} is a (possibly empty) comma-separated
list of the following IEEE exceptions: @samp{invalid} (invalid floating
point operation, such as @code{SQRT(-1.0)}), @samp{zero} (division by
zero), @samp{overflow} (overflow in a floating point operation),
@samp{underflow} (underflow in a floating point operation),
@samp{precision} (loss of precision during operation) and @samp{denormal}
(operation produced a denormal value).
@end table

@xref{Debugging Options,,Options for Debugging Your Program or GCC,
gcc,Using the GNU Compiler Collection (GCC)}, for more information on
debugging options.

@node Directory Options
@section Options for Directory Search
@cindex directory, options
@cindex options, directory search
@cindex search path
@cindex INCLUDE directive
@cindex directive, INCLUDE
These options affect how GNU Fortran searches
for files specified by the @code{INCLUDE} directive and where it searches
for previously compiled modules.

It also affects the search paths used by @command{cpp} when used to preprocess
Fortran source.

@table @gcctabopt
@item -I@var{dir}
@cindex @code{-I}@var{dir} option
@cindex option, @code{-I}@var{dir}
@cindex directory, search paths for inclusion
@cindex inclusion, directory search paths for
@cindex search paths, for included files
@cindex paths, search
@cindex module search path
These affect interpretation of the @code{INCLUDE} directive
(as well as of the @code{#include} directive of the @command{cpp}
preprocessor).

Also note that the general behavior of @option{-I} and
@code{INCLUDE} is pretty much the same as of @option{-I} with
@code{#include} in the @command{cpp} preprocessor, with regard to
looking for @file{header.gcc} files and other such things.

This path is also used to search for @file{.mod} files when previously
compiled modules are required by a @code{USE} statement.

@xref{Directory Options,,Options for Directory Search,
gcc,Using the GNU Compiler Collection (GCC)}, for information on the
@option{-I} option.

@item -M@var{dir}
@item -J@var{dir}
@cindex @code{-M}@var{dir} option
@cindex option, -@code{-M}@var{dir}
@cindex @code{-J}@var{dir} option
@cindex option, -@code{-J}@var{dir}
This option specifies where to put @file{.mod} files for compiled modules.
It is also added to the list of directories to searched by an @code{USE}
statement.

The default is the current directory.

@option{-J} is an alias for @option{-M} to avoid conflicts with existing
GCC options.
@end table

@node Runtime Options
@section Influencing runtime behavior
@cindex runtime, options

These options affect the runtime behavior of programs compiled with GNU Fortran.
@table @gcctabopt
@item -fconvert=@var{conversion}
@cindex @code{-fconvert=}@var{conversion} option
@cindex option, @code{-fconvert=}@var{conversion}
Specify the representation of data for unformatted files.  Valid
values for conversion are: @samp{native}, the default; @samp{swap},
swap between big- and little-endian; @samp{big-endian}, use big-endian
representation for unformatted files; @samp{little-endian}, use little-endian
representation for unformatted files.

@emph{This option has an effect only when used in the main program.
The @code{CONVERT} specifier and the GFORTRAN_CONVERT_UNIT environment
variable override the default specified by @option{-fconvert}.}

@item -frecord-marker=@var{length}
@cindex @code{-frecord-marker=}@var{length} option
@cindex option, @code{-frecord-marker=}@var{length}
Specify the length of record markers for unformatted files.
Valid values for @var{length} are 4 and 8.  Default is 4.
@emph{This is different from previous versions of gfortran},
which specified a default record marker length of 8 on most
systems.  If you want to read or write files compatible
with earlier versions of gfortran, use @option{-frecord-marker=8}.

@item -fmax-subrecord-length=@var{length}
@cindex @code{-fmax-subrecord-length=}@var{length} option
@cindex option, @code{-fmax-subrecord-length=}@var{length}
Specify the maximum length for a subrecord.  The maximum permitted
value for length is 2147483639, which is also the default.  Only
really useful for use by the gfortran testsuite.
@end table

@node Code Gen Options
@section Options for Code Generation Conventions
@cindex code generation, conventions
@cindex options, code generation
@cindex run-time, options

These machine-independent options control the interface conventions
used in code generation.

Most of them have both positive and negative forms; the negative form
of @option{-ffoo} would be @option{-fno-foo}.  In the table below, only
one of the forms is listed---the one which is not the default.  You
can figure out the other form by either removing @option{no-} or adding
it.

@table @gcctabopt
@item -fno-automatic
@cindex @code{-fno-automatic} option
@cindex option, @code{-fno-automatic}
@cindex SAVE statement
@cindex statements, SAVE
Treat each program unit as if the @code{SAVE} statement was specified for
every local variable and array referenced in it. Does not affect common
blocks. (Some Fortran compilers provide this option under the name
@option{-static}.)

@item -ff2c
@cindex @code{-ff2c} option
@cindex option, @code{-ff2c}
@cindex calling convention
@cindex @command{f2c} calling convention
@cindex @command{g77} calling convention
@cindex libf2c calling convention
Generate code designed to be compatible with code generated
by @command{g77} and @command{f2c}.

The calling conventions used by @command{g77} (originally implemented
in @command{f2c}) require functions that return type
default @code{REAL} to actually return the C type @code{double}, and
functions that return type @code{COMPLEX} to return the values via an
extra argument in the calling sequence that points to where to
store the return value.  Under the default GNU calling conventions, such
functions simply return their results as they would in GNU
C---default @code{REAL} functions return the C type @code{float}, and
@code{COMPLEX} functions return the GNU C type @code{complex}.
Additionally, this option implies the @option{-fsecond-underscore}
option, unless @option{-fno-second-underscore} is explicitly requested.

This does not affect the generation of code that interfaces with
the @command{libgfortran} library.

@emph{Caution:} It is not a good idea to mix Fortran code compiled with
@option{-ff2c} with code compiled with the default @option{-fno-f2c}
calling conventions as, calling @code{COMPLEX} or default @code{REAL}
functions between program parts which were compiled with different
calling conventions will break at execution time.

@emph{Caution:} This will break code which passes intrinsic functions
of type default @code{REAL} or @code{COMPLEX} as actual arguments, as
the library implementations use the @option{-fno-f2c} calling conventions.

@item -fno-underscoring
@cindex @code{-fno-underscoring option}
@cindex option, @code{-fno-underscoring}
@cindex underscore
@cindex symbol names, underscores
@cindex transforming symbol names
@cindex symbol names, transforming
Do not transform names of entities specified in the Fortran
source file by appending underscores to them.

With @option{-funderscoring} in effect, GNU Fortran appends one
underscore to external names with no underscores.  This is done to ensure
compatibility with code produced by many UNIX Fortran compilers.

@emph{Caution}: The default behavior of GNU Fortran is
incompatible with @command{f2c} and @command{g77}, please use the
@option{-ff2c} option if you want object files compiled with
GNU Fortran to be compatible with object code created with these
tools.

Use of @option{-fno-underscoring} is not recommended unless you are
experimenting with issues such as integration of GNU Fortran into
existing system environments (vis-a-vis existing libraries, tools, and
so on).

For example, with @option{-funderscoring}, and assuming other defaults like
@option{-fcase-lower} and that @code{j()} and @code{max_count()} are
external functions while @code{my_var} and @code{lvar} are local variables,
a statement like
@smallexample
I = J() + MAX_COUNT (MY_VAR, LVAR)
@end smallexample
@noindent
is implemented as something akin to:
@smallexample
i = j_() + max_count__(&my_var__, &lvar);
@end smallexample

With @option{-fno-underscoring}, the same statement is implemented as:

@smallexample
i = j() + max_count(&my_var, &lvar);
@end smallexample

Use of @option{-fno-underscoring} allows direct specification of
user-defined names while debugging and when interfacing GNU Fortran
code with other languages.

Note that just because the names match does @emph{not} mean that the
interface implemented by GNU Fortran for an external name matches the
interface implemented by some other language for that same name.
That is, getting code produced by GNU Fortran to link to code produced
by some other compiler using this or any other method can be only a
small part of the overall solution---getting the code generated by
both compilers to agree on issues other than naming can require
significant effort, and, unlike naming disagreements, linkers normally
cannot detect disagreements in these other areas.

Also, note that with @option{-fno-underscoring}, the lack of appended
underscores introduces the very real possibility that a user-defined
external name will conflict with a name in a system library, which
could make finding unresolved-reference bugs quite difficult in some
cases---they might occur at program run time, and show up only as
buggy behavior at run time.

In future versions of GNU Fortran we hope to improve naming and linking
issues so that debugging always involves using the names as they appear
in the source, even if the names as seen by the linker are mangled to
prevent accidental linking between procedures with incompatible
interfaces.

@item -fsecond-underscore
@cindex @code{-fsecond-underscore option}
@cindex option, @code{-fsecond-underscore}
@cindex underscore
@cindex symbol names, underscores
@cindex transforming symbol names
@cindex symbol names, transforming
@cindex @command{f2c} calling convention
@cindex @command{g77} calling convention
@cindex libf2c calling convention
By default, GNU Fortran appends an underscore to external
names.  If this option is used GNU Fortran appends two
underscores to names with underscores and one underscore to external names
with no underscores.  GNU Fortran also appends two underscores to
internal names with underscores to avoid naming collisions with external
names.

This option has no effect if @option{-fno-underscoring} is
in effect.  It is implied by the @option{-ff2c} option.

Otherwise, with this option, an external name such as @code{MAX_COUNT}
is implemented as a reference to the link-time external symbol
@code{max_count__}, instead of @code{max_count_}.  This is required
for compatibility with @command{g77} and @command{f2c}, and is implied
by use of the @option{-ff2c} option.

@item -fbounds-check
@cindex @code{-fbounds-check} option
@cindex option, @code{-fbounds-check}
@cindex bounds checking
@cindex range checking
@cindex array bounds checking
@cindex subscript checking
@cindex checking subscripts
Enable generation of run-time checks for array subscripts
and against the declared minimum and maximum values.  It also
checks array indices for assumed and deferred
shape arrays against the actual allocated bounds.

In the future this may also include other forms of checking, eg. checking
substring references.

@item -fmax-stack-var-size=@var{n}
@cindex @code{-fmax-stack-var-size} option
@cindex option, @code{-fmax-stack-var-size}
This option specifies the size in bytes of the largest array that will be put
on the stack.

This option currently only affects local arrays declared with constant
bounds, and may not apply to all character variables.
Future versions of GNU Fortran may improve this behavior.

The default value for @var{n} is 32768.

@item -fpack-derived
@cindex @code{-fpack-derived} option
@cindex option, @code{-fpack-derived}
@cindex Structure packing
This option tells GNU Fortran to pack derived type members as closely as
possible.  Code compiled with this option is likely to be incompatible
with code compiled without this option, and may execute slower.

@item -frepack-arrays
@cindex @code{-frepack-arrays} option
@cindex option, @code{-frepack-arrays}
@cindex Repacking arrays
In some circumstances GNU Fortran may pass assumed shape array
sections via a descriptor describing a noncontiguous area of memory.
This option adds code to the function prologue to repack the data into
a contiguous block at runtime.

This should result in faster accesses to the array.  However it can introduce
significant overhead to the function call, especially  when the passed data
is noncontiguous.

@item -fshort-enums
@cindex @code{-fshort-enums} option
@cindex option, @code{-fshort-enums}
This option is provided for interoperability with C code that was
compiled with the @option{-fshort-enums} option.  It will make
GNU Fortran choose the smallest @code{INTEGER} kind a given
enumerator set will fit in, and give all its enumerators this kind.

@item -fexternal-blas
@cindex @code{-fexternal-blas} option
@cindex option, @code{-fexternal-blas}
This option will make gfortran generate calls to BLAS functions for some
matrix operations like @code{MATMUL}, instead of using our own
algorithms, if the size of the matrices involved is larger than a given
limit (see @option{-fblas-matmul-limit}).  This may be profitable if an
optimized vendor BLAS library is available.  The BLAS library will have
to be specified at link time.

@item -fblas-matmul-limit=@var{n}
@cindex @code{-fblas-matmul-limit} option
@cindex option, @code{-fblas-matmul-limit}
Only significant when @option{-fexternal-blas} is in effect.
Matrix multiplication of matrices with size larger than (or equal to) @var{n}
will be performed by calls to BLAS functions, while others will be
handled by @command{gfortran} internal algorithms. If the matrices
involved are not square, the size comparison is performed using the
geometric mean of the dimensions of the argument and result matrices.

The default value for @var{n} is 30.

@end table

@xref{Code Gen Options,,Options for Code Generation Conventions,
gcc,Using the GNU Compiler Collection (GCC)}, for information on more options
offered by the GBE
shared by @command{gfortran}, @command{gcc}, and other GNU compilers.


@c man end

@node Environment Variables
@section Environment Variables Affecting @command{gfortran}
@cindex environment variables

@c man begin ENVIRONMENT

The @command{gfortran} compiler currently does not make use of any environment
variables to control its operation above and beyond those
that affect the operation of @command{gcc}.

@xref{Environment Variables,,Environment Variables Affecting GCC,
gcc,Using the GNU Compiler Collection (GCC)}, for information on environment
variables.

@xref{Runtime}, for environment variables that affect the
run-time behavior of programs compiled with GNU Fortran.
@c man end