aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/invoke.texi
blob: 41fee670a6c72fdb4274c50a03ce9c8a4c48e409 (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
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
@c Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
@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, 2008, 2009, 2010, 2011
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.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``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{@value{BUGURL}}.
@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
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.
* Preprocessing Options::  Enable and customize preprocessing.
* 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
* Link Options ::       Influencing the linking step
* Runtime Options::     Influencing runtime behavior
* Code Gen Options::    Specifying conventions for function calls, data layout
                        and register usage.
* Environment Variables:: Environment variables 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  -fno-range-check -fbackslash -fmodule-private}

@item Preprocessing Options
@xref{Preprocessing Options,,Enable and customize preprocessing}.
@gccoptlist{-cpp -dD -dI -dM -dN -dU -fworking-directory @gol
-imultilib @var{dir} -iprefix @var{file} -isysroot @var{dir} @gol
-iquote -isystem @var{dir} -nocpp -nostdinc -undef @gol
-A@var{question}=@var{answer} -A-@var{question}@r{[}=@var{answer}@r{]} @gol
-C -CC -D@var{macro}@r{[}=@var{defn}@r{]} -U@var{macro} -H -P}

@item Error and Warning Options
@xref{Error and Warning Options,,Options to request or suppress errors
and warnings}.
@gccoptlist{-fmax-errors=@var{n}
-fsyntax-only -pedantic -pedantic-errors -Wall @gol
-Waliasing -Wampersand -Warray-bounds -Wcharacter-truncation @gol
-Wconversion -Wimplicit-interface -Wimplicit-procedure -Wline-truncation @gol
-Wintrinsics-std -Wreal-q-constant -Wsurprising -Wno-tabs -Wunderflow @gol
-Wunused-parameter -Wintrinsic-shadow -Wno-align-commons @gol
-Wfunction-elimination}

@item Debugging Options
@xref{Debugging Options,,Options for debugging your program or GNU Fortran}.
@gccoptlist{-fdump-fortran-original  -fdump-fortran-optimized @gol
-ffpe-trap=@var{list} -fbacktrace -fdump-parse-tree}

@item Directory Options
@xref{Directory Options,,Options for directory search}.
@gccoptlist{-I@var{dir}  -J@var{dir} -fintrinsic-modules-path @var{dir}}

@item Link Options
@xref{Link Options,,Options for influencing the linking step}.
@gccoptlist{-static-libgfortran}

@item Runtime Options
@xref{Runtime Options,,Options for influencing runtime behavior}.
@gccoptlist{-fconvert=@var{conversion}  -fno-range-check
-frecord-marker=@var{length} @gol  -fmax-subrecord-length=@var{length}
-fsign-zero}

@item Code Generation Options
@xref{Code Gen Options,,Options for code generation conventions}.
@gccoptlist{-fno-automatic  -ff2c  -fno-underscoring @gol
-fwhole-file -fsecond-underscore @gol
-fbounds-check -fcheck-array-temporaries  -fmax-array-constructor =@var{n} @gol
-fcheck=@var{<all|array-temps|bounds|do|mem|pointer|recursion>} @gol
-fcoarray=@var{<none|single|lib>} -fmax-stack-var-size=@var{n} @gol
-fstack-arrays @gol
-fpack-derived  -frepack-arrays  -fshort-enums  -fexternal-blas @gol
-fblas-matmul-limit=@var{n} -frecursive -finit-local-zero @gol
-finit-integer=@var{n} -finit-real=@var{<zero|inf|-inf|nan|snan>} @gol
-finit-logical=@var{<true|false>} -finit-character=@var{n} @gol
-fno-align-commons -fno-protect-parens -frealloc-lhs @gol
-faggressive-function-elimination -ffrontend-optimize}
@end table

@menu
* Fortran Dialect Options::  Controlling the variant of Fortran language
                             compiled.
* Preprocessing Options::  Enable and customize preprocessing.
* 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
* Link Options ::       Influencing the linking step
* 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
@itemx -ffixed-form
@opindex @code{ffree-form}
@opindex @code{fno-fixed-form}
@cindex options, fortran dialect
@cindex file format, free
@cindex file format, fixed
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
@opindex @code{fall-intrinsics}
This option causes all intrinsic procedures (including the GNU-specific
extensions) to be accepted.  This can be useful with @option{-std=f95} to
force standard-compliance but get access to the full range of intrinsics
available with @command{gfortran}.  As a consequence, @option{-Wintrinsics-std}
will be ignored and no user-defined procedure with the same name as any
intrinsic will be called except when it is explicitly declared @code{EXTERNAL}.

@item -fd-lines-as-code
@itemx -fd-lines-as-comments
@opindex @code{fd-lines-as-code}
@opindex @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
@opindex @code{fdefault-double-8}
Set the @code{DOUBLE PRECISION} type to an 8 byte wide type.  If
@option{-fdefault-real-8} is given, @code{DOUBLE PRECISION} would
instead be promoted to 16 bytes if possible, and @option{-fdefault-double-8}
can be used to prevent this.  The kind of real constants like @code{1.d0} will
not be changed by @option{-fdefault-real-8} though, so also
@option{-fdefault-double-8} does not affect it.

@item -fdefault-integer-8
@opindex @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.  This option also affects
the kind of integer constants like @code{42}.

@item -fdefault-real-8
@opindex @code{fdefault-real-8}
Set the default real type to an 8 byte wide type.
Do nothing if this is already the default.  This option also affects
the kind of non-double real constants like @code{1.0}, and does promote
the default width of @code{DOUBLE PRECISION} to 16 bytes if possible, unless
@code{-fdefault-double-8} is given, too.

@item -fdollar-ok
@opindex @code{fdollar-ok}
@cindex @code{$}
@cindex symbol names
@cindex character set
Allow @samp{$} as a valid non-first character in a symbol name. Symbols 
that start with @samp{$} are rejected since it is unclear which rules to
apply to implicit typing as different vendors implement different rules.
Using @samp{$} in @code{IMPLICIT} statements is also rejected.

@item -fbackslash
@opindex @code{backslash}
@cindex backslash
@cindex escape characters
Change the interpretation of backslashes in string literals from a single
backslash character to ``C-style'' escape characters. The following
combinations are expanded @code{\a}, @code{\b}, @code{\f}, @code{\n},
@code{\r}, @code{\t}, @code{\v}, @code{\\}, and @code{\0} to the ASCII
characters alert, backspace, form feed, newline, carriage return,
horizontal tab, vertical tab, backslash, and NUL, respectively.
Additionally, @code{\x}@var{nn}, @code{\u}@var{nnnn} and
@code{\U}@var{nnnnnnnn} (where each @var{n} is a hexadecimal digit) are
translated into the Unicode characters corresponding to the specified code
points. All other combinations of a character preceded by \ are
unexpanded.

@item -fmodule-private
@opindex @code{fmodule-private}
@cindex module entities
@cindex private
Set the default accessibility of module entities to @code{PRIVATE}.
Use-associated entities will not be accessible unless they are explicitly
declared as @code{PUBLIC}.

@item -ffixed-line-length-@var{n}
@opindex @code{ffixed-line-length-}@var{n}
@cindex file format, fixed
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.

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}
@opindex @code{ffree-line-length-}@var{n}
@cindex file format, free
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}
@opindex @code{fmax-identifier-length=}@var{n}
Specify the maximum allowed identifier length. Typical values are
31 (Fortran 95) and 63 (Fortran 2003 and Fortran 2008).

@item -fimplicit-none
@opindex @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
@opindex @code{fcray-pointer}
Enable the Cray pointer extension, which provides C-like pointer
functionality.

@item -fopenmp
@opindex @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.  The option @option{-fopenmp} implies @option{-frecursive}.

@item -fno-range-check
@opindex @code{frange-check}
Disable range checking on results of simplification of constant
expressions during compilation.  For example, GNU Fortran will give
an error at compile time when simplifying @code{a = 1. / 0}.
With this option, no error will be given and @code{a} will be assigned
the value @code{+Infinity}.  If an expression evaluates to a value
outside of the relevant range of [@code{-HUGE()}:@code{HUGE()}],
then the expression will be replaced by @code{-Inf} or @code{+Inf}
as appropriate.
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}
@opindex @code{std=}@var{std} option
Specify the standard to which the program is expected to conform, which
may be one of @samp{f95}, @samp{f2003}, @samp{f2008}, @samp{gnu}, or
@samp{legacy}.  The default value for @var{std} is @samp{gnu}, which
specifies a superset of the Fortran 95 standard that includes all of the
extensions supported by GNU Fortran, although warnings will be given for
obsolete extensions not recommended for use in new code.  The
@samp{legacy} value is equivalent but without the warnings for obsolete
extensions, and may be useful for old non-standard programs.  The
@samp{f95}, @samp{f2003} and @samp{f2008} values specify strict
conformance to the Fortran 95, Fortran 2003 and Fortran 2008 standards,
respectively; errors are given for all extensions beyond the relevant
language standard, and warnings are given for the Fortran 77 features
that are permitted but obsolescent in later standards. @samp{-std=f2008tr}
allows the Fortran 2008 standard including the additions of the 
technical report (TR) 29113.

@end table

@node Preprocessing Options
@section Enable and customize preprocessing
@cindex preprocessor
@cindex options, preprocessor
@cindex CPP

Preprocessor related options. See section 
@ref{Preprocessing and conditional compilation} for more detailed
information on preprocessing in @command{gfortran}.

@table @gcctabopt
@item -cpp
@itemx -nocpp
@opindex @code{cpp}
@opindex @code{fpp}
@cindex preprocessor, enable
@cindex preprocessor, disable
Enable preprocessing. The preprocessor is automatically invoked if
the file extension is @file{.fpp}, @file{.FPP},  @file{.F}, @file{.FOR},
@file{.FTN}, @file{.F90}, @file{.F95}, @file{.F03} or @file{.F08}. Use
this option to manually enable preprocessing of any kind of Fortran file.

To disable preprocessing of files with any of the above listed extensions,
use the negative form: @option{-nocpp}.

The preprocessor is run in traditional mode. Any restrictions of the
file-format, especially the limits on line length, apply for
preprocessed output as well, so it might be advisable to use the
@option{-ffree-line-length-none} or @option{-ffixed-line-length-none}
options.

@item -dM
@opindex @code{dM}
@cindex preprocessor, debugging
@cindex debugging, preprocessor
Instead of the normal output, generate a list of @code{'#define'}
directives for all the macros defined during the execution of the
preprocessor, including predefined macros. This gives you a way
of finding out what is predefined in your version of the preprocessor.
Assuming you have no file @file{foo.f90}, the command
@smallexample
  touch foo.f90; gfortran -cpp -E -dM foo.f90
@end smallexample
will show all the predefined macros.

@item -dD
@opindex @code{dD}
@cindex preprocessor, debugging
@cindex debugging, preprocessor
Like @option{-dM} except in two respects: it does not include the
predefined macros, and it outputs both the @code{#define} directives
and the result of preprocessing. Both kinds of output go to the
standard output file.

@item -dN
@opindex @code{dN}
@cindex preprocessor, debugging
@cindex debugging, preprocessor
Like @option{-dD}, but emit only the macro names, not their expansions.

@item -dU
@opindex @code{dU}
@cindex preprocessor, debugging
@cindex debugging, preprocessor
Like @option{dD} except that only macros that are expanded, or whose
definedness is tested in preprocessor directives, are output; the 
output is delayed until the use or test of the macro; and @code{'#undef'}
directives are also output for macros tested but undefined at the time.

@item -dI
@opindex @code{dI}
@cindex preprocessor, debugging
@cindex debugging, preprocessor
Output @code{'#include'} directives in addition to the result
of preprocessing.

@item -fworking-directory
@opindex @code{fworking-directory}
@cindex preprocessor, working directory
Enable generation of linemarkers in the preprocessor output that will
let the compiler know the current working directory at the time of
preprocessing. When this option is enabled, the preprocessor will emit,
after the initial linemarker, a second linemarker with the current
working directory followed by two slashes. GCC will use this directory,
when it's present in the preprocessed input, as the directory emitted
as the current working directory in some debugging information formats.
This option is implicitly enabled if debugging information is enabled,
but this can be inhibited with the negated form
@option{-fno-working-directory}. If the @option{-P} flag is present
in the command line, this option has no effect, since no @code{#line}
directives are emitted whatsoever.

@item -idirafter @var{dir}
@opindex @code{idirafter @var{dir}}
@cindex preprocessing, include path
Search @var{dir} for include files, but do it after all directories
specified with @option{-I} and the standard system directories have
been exhausted. @var{dir} is treated as a system include directory.
If dir begins with @code{=}, then the @code{=} will be replaced by
the sysroot prefix; see @option{--sysroot} and @option{-isysroot}.

@item -imultilib @var{dir}
@opindex @code{imultilib @var{dir}}
@cindex preprocessing, include path
Use @var{dir} as a subdirectory of the directory containing target-specific
C++ headers.

@item -iprefix @var{prefix}
@opindex @code{iprefix @var{prefix}}
@cindex preprocessing, include path
Specify @var{prefix} as the prefix for subsequent @option{-iwithprefix}
options. If the @var{prefix} represents a directory, you should include
the final @code{'/'}.

@item -isysroot @var{dir}
@opindex @code{isysroot @var{dir}}
@cindex preprocessing, include path
This option is like the @option{--sysroot} option, but applies only to
header files. See the @option{--sysroot} option for more information.

@item -iquote @var{dir}
@opindex @code{iquote @var{dir}}
@cindex preprocessing, include path
Search @var{dir} only for header files requested with @code{#include "file"};
they are not searched for @code{#include <file>}, before all directories
specified by @option{-I} and before the standard system directories. If
@var{dir} begins with @code{=}, then the @code{=} will be replaced by the
sysroot prefix; see @option{--sysroot} and @option{-isysroot}.

@item -isystem @var{dir}
@opindex @code{isystem @var{dir}}
@cindex preprocessing, include path
Search @var{dir} for header files, after all directories specified by
@option{-I} but before the standard system directories. Mark it as a
system directory, so that it gets the same special treatment as is
applied to the standard system directories. If @var{dir} begins with
@code{=}, then the @code{=} will be replaced by the sysroot prefix;
see @option{--sysroot} and @option{-isysroot}.

@item -nostdinc
@opindex @code{nostdinc}
Do not search the standard system directories for header files. Only
the directories you have specified with @option{-I} options (and the
directory of the current file, if appropriate) are searched.

@item -undef
@opindex @code{undef}
Do not predefine any system-specific or GCC-specific macros.
The standard predefined macros remain defined.

@item -A@var{predicate}=@var{answer}
@opindex @code{A@var{predicate}=@var{answer}}
@cindex preprocessing, assertion
Make an assertion with the predicate @var{predicate} and answer @var{answer}.
This form is preferred to the older form -A predicate(answer), which is still
supported, because it does not use shell special characters.

@item -A-@var{predicate}=@var{answer}
@opindex @code{A-@var{predicate}=@var{answer}}
@cindex preprocessing, assertion
Cancel an assertion with the predicate @var{predicate} and answer @var{answer}.

@item -C
@opindex @code{C}
@cindex preprocessing, keep comments
Do not discard comments. All comments are passed through to the output
file, except for comments in processed directives, which are deleted
along with the directive.

You should be prepared for side effects when using @option{-C}; it causes
the preprocessor to treat comments as tokens in their own right. For example,
comments appearing at the start of what would be a directive line have the
effect of turning that line into an ordinary source line, since the first
token on the line is no longer a @code{'#'}.

Warning: this currently handles C-Style comments only. The preprocessor
does not yet recognize Fortran-style comments.

@item -CC
@opindex @code{CC}
@cindex preprocessing, keep comments
Do not discard comments, including during macro expansion. This is like
@option{-C}, except that comments contained within macros are also passed
through to the output file where the macro is expanded.

In addition to the side-effects of the @option{-C} option, the @option{-CC}
option causes all C++-style comments inside a macro to be converted to C-style
comments. This is to prevent later use of that macro from inadvertently
commenting out the remainder of the source line. The @option{-CC} option
is generally used to support lint comments.

Warning: this currently handles C- and C++-Style comments only. The
preprocessor does not yet recognize Fortran-style comments.

@item -D@var{name}
@opindex @code{D@var{name}}
@cindex preprocessing, define macros
Predefine name as a macro, with definition @code{1}.

@item -D@var{name}=@var{definition}
@opindex @code{D@var{name}=@var{definition}}
@cindex preprocessing, define macros
The contents of @var{definition} are tokenized and processed as if they
appeared during translation phase three in a @code{'#define'} directive.
In particular, the definition will be truncated by embedded newline
characters.

If you are invoking the preprocessor from a shell or shell-like program
you may need to use the shell's quoting syntax to protect characters such
as spaces that have a meaning in the shell syntax.

If you wish to define a function-like macro on the command line, write
its argument list with surrounding parentheses before the equals sign
(if any). Parentheses are meaningful to most shells, so you will need
to quote the option. With sh and csh, @code{-D'name(args...)=definition'}
works.

@option{-D} and @option{-U} options are processed in the order they are
given on the command line. All -imacros file and -include file options
are processed after all -D and -U options.

@item -H
@opindex @code{H}
Print the name of each header file used, in addition to other normal
activities. Each name is indented to show how deep in the @code{'#include'}
stack it is.

@item -P
@opindex @code{P}
@cindex preprocessing, no linemarkers
Inhibit generation of linemarkers in the output from the preprocessor.
This might be useful when running the preprocessor on something that
is not C code, and will be sent to a program which might be confused
by the linemarkers.

@item -U@var{name}
@opindex @code{U@var{name}}
@cindex preprocessing, undefine macros
Cancel any previous definition of @var{name}, either built in or provided
with a @option{-D} option.
@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}
@opindex @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
@opindex @code{fsyntax-only}
@cindex syntax checking
Check the code for syntax errors, but don't actually compile it.  This
will generate module files for each module present in the code, but no
other output file.

@item -pedantic
@opindex @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},
@option{-std=f2003} or @option{-std=f2008}.

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

@item -Wall
@opindex @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{-Wconversion}, @option{-Wsurprising}, @option{-Wintrinsics-std},
@option{-Wno-tabs}, @option{-Wintrinsic-shadow}, @option{-Wline-truncation},
@option{-Wreal-q-constant} and @option{-Wunused}.

@item -Waliasing
@opindex @code{Waliasing}
@cindex aliasing
@cindex warnings, 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
@opindex @code{Wampersand}
@cindex warnings, ampersand
@cindex @code{&}
Warn about missing ampersand in continued character constants. The warning is
given with @option{-Wampersand}, @option{-pedantic}, @option{-std=f95},
@option{-std=f2003} and @option{-std=f2008}. 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 -Warray-temporaries
@opindex @code{Warray-temporaries}
@cindex warnings, array temporaries
Warn about array temporaries generated by the compiler.  The information
generated by this warning is sometimes useful in optimization, in order to
avoid such temporaries.

@item -Wcharacter-truncation
@opindex @code{Wcharacter-truncation}
@cindex warnings, character truncation
Warn when a character assignment will truncate the assigned string.

@item -Wline-truncation
@opindex @code{Wline-truncation}
@cindex warnings, line truncation
Warn when a source code line will be truncated.

@item -Wconversion
@opindex @code{Wconversion}
@cindex warnings, conversion
@cindex conversion
Warn about implicit conversions that are likely to change the value of 
the expression after conversion. Implied by @option{-Wall}.

@item -Wconversion-extra
@opindex @code{Wconversion-extra}
@cindex warnings, conversion
@cindex conversion
Warn about implicit conversions between different types and kinds.

@item -Wimplicit-interface
@opindex @code{Wimplicit-interface}
@cindex warnings, implicit 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 -Wimplicit-procedure
@opindex @code{Wimplicit-procedure}
@cindex warnings, implicit procedure
Warn if a procedure is called that has neither an explicit interface
nor has been declared as @code{EXTERNAL}.

@item -Wintrinsics-std
@opindex @code{Wintrinsics-std}
@cindex warnings, non-standard intrinsics
@cindex warnings, intrinsics of other standards
Warn if @command{gfortran} finds a procedure named like an intrinsic not
available in the currently selected standard (with @option{-std}) and treats
it as @code{EXTERNAL} procedure because of this.  @option{-fall-intrinsics} can
be used to never trigger this behavior and always link to the intrinsic
regardless of the selected standard.

@item -Wreal-q-constant
@opindex @code{Wreal-q-constant}
@cindex warnings, @code{q} exponent-letter
Produce a warning if a real-literal-constant contains a @code{q}
exponent-letter.

@item -Wsurprising
@opindex @code{Wsurprising}
@cindex warnings, 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.

@item
A TRANSFER specifies a source that is shorter than the destination.

@item
The type of a function result is declared more than once with the same type.  If
@option{-pedantic} or standard-conforming mode is enabled, this is an error.

@item
A @code{CHARACTER} variable is declared with negative length.
@end itemize

@item -Wtabs
@opindex @code{Wtabs}
@cindex warnings, tabs
@cindex tabulators
By default, tabs are accepted as whitespace, but tabs are not members
of the Fortran Character Set.  For continuation lines, a tab followed
by a digit between 1 and 9 is supported.  @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}, @option{-std=f2003},
@option{-std=f2008} and @option{-Wall}.

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

@item -Wintrinsic-shadow
@opindex @code{Wintrinsic-shadow}
@cindex warnings, intrinsic
@cindex intrinsic
Warn if a user-defined procedure or module procedure has the same name as an
intrinsic; in this case, an explicit interface or @code{EXTERNAL} or
@code{INTRINSIC} declaration might be needed to get calls later resolved to
the desired intrinsic/procedure.

@item -Wunused-dummy-argument
@opindex @code{Wunused-dummy-argument}
@cindex warnings, unused dummy argument
@cindex unused dummy argument
@cindex dummy argument, unused
Warn about unused dummy arguments. This option is implied by @option{-Wall}.

@item -Wunused-parameter
@opindex @code{Wunused-parameter}
@cindex warnings, unused parameter
@cindex unused parameter
Contrary to @command{gcc}'s meaning of @option{-Wunused-parameter},
@command{gfortran}'s implementation of this option does not warn
about unused dummy arguments (see @option{-Wunused-dummy-argument}),
but about unused @code{PARAMETER} values. @option{-Wunused-parameter}
is not included in @option{-Wall} but is implied by @option{-Wall -Wextra}.

@item -Walign-commons
@opindex @code{Walign-commons}
@cindex warnings, alignment of @code{COMMON} blocks
@cindex alignment of @code{COMMON} blocks
By default, @command{gfortran} warns about any occasion of variables being
padded for proper alignment inside a @code{COMMON} block. This warning can be turned
off via @option{-Wno-align-commons}. See also @option{-falign-commons}.

@item -Wfunction-elimination
@opindex @code{Wfunction-elimination}
@cindex function elimination
@cindex warnings, function elimination
Warn if any calls to functions are eliminated by the optimizations
enabled by the @option{-ffrontend-optimize} option.


@item -Werror
@opindex @code{Werror}
@cindex warnings, to errors
Turns all warnings into errors.
@end table

@xref{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-fortran-original
@opindex @code{fdump-fortran-original}
Output the internal parse tree after translating the source program
into internal representation.  Only really useful for debugging the
GNU Fortran compiler itself.

@item -fdump-optimized-tree
@opindex @code{fdump-fortran-optimized}
Output the parse tree after front-end optimization.  Only really
useful for debugging the GNU Fortran compiler itself.

@opindex @code{fdump-parse-tree}
Output the internal parse tree after translating the source program
into internal representation.  Only really useful for debugging the
GNU Fortran compiler itself.  This option is deprecated; use
@code{-fdump-fortran-original} instead.

@item -ffpe-trap=@var{list}
@opindex @code{ffpe-trap=}@var{list}
Specify a list of floating point exception traps to enable.  On most
systems, if a floating point exception occurs and the trap for that
exception is enabled, a SIGFPE signal will be sent and the program
being aborted, producing a core file useful for debugging.  @var{list}
is a (possibly empty) comma-separated list of the following
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{inexact} (loss of precision
during operation), and @samp{denormal} (operation performed on a
denormal value).  The first five exceptions correspond to the five
IEEE 754 exceptions, whereas the last one (@samp{denormal}) is not
part of the IEEE 754 standard but is available on some common
architectures such as x86.

The first three exceptions (@samp{invalid}, @samp{zero}, and
@samp{overflow}) often indicate serious errors, and unless the program
has provisions for dealing with these exceptions, enabling traps for
these three exceptions is probably a good idea.

Many, if not most, floating point operations incur loss of precision
due to rounding, and hence the @code{ffpe-trap=inexact} is likely to
be uninteresting in practice.

By default no exception traps are enabled.

@item -fno-backtrace
@opindex @code{fno-backtrace}
@cindex backtrace
@cindex trace
When a serious runtime error is encountered or a deadly signal is
emitted (segmentation fault, illegal instruction, bus error,
floating-point exception, and the other POSIX signals that have the
action @samp{core}), the Fortran runtime library tries to output a
backtrace of the error. @code{-fno-backtrace} disables the backtrace
generation. This option only has influence for compilation of the
Fortran main program.

@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 @code{INCLUDE} directive
@cindex directive, @code{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}
@opindex @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 -J@var{dir}
@opindex @code{J}@var{dir}
@opindex @code{M}@var{dir}
@cindex paths, search
@cindex module search path
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.

@item -fintrinsic-modules-path @var{dir}
@opindex @code{fintrinsic-modules-path} @var{dir}
@cindex paths, search
@cindex module search path
This option specifies the location of pre-compiled intrinsic modules, if
they are not in the default location expected by the compiler.
@end table

@node Link Options
@section Influencing the linking step
@cindex options, linking
@cindex linking, static

These options come into play when the compiler links object files into an 
executable output file. They are meaningless if the compiler is not doing 
a link step.

@table @gcctabopt
@item -static-libgfortran
@opindex @code{static-libgfortran}
On systems that provide @file{libgfortran} as a shared and a static
library, this option forces the use of the static version. If no
shared version of @file{libgfortran} was built when the compiler was
configured, this option has no effect.
@end table


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

These options affect the runtime behavior of programs compiled with GNU Fortran.

@table @gcctabopt
@item -fconvert=@var{conversion}
@opindex @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 -fno-range-check
@opindex @code{fno-range-check}
Disable range checking of input values during integer @code{READ} operations.
For example, GNU Fortran will give an error if an input value is
outside of the relevant range of [@code{-HUGE()}:@code{HUGE()}]. In other words,
with @code{INTEGER (kind=4) :: i} , attempting to read @math{-2147483648} will
give an error unless @option{-fno-range-check} is given. 


@item -frecord-marker=@var{length}
@opindex @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 @command{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 @command{gfortran}, use @option{-frecord-marker=8}.

@item -fmax-subrecord-length=@var{length}
@opindex @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.

@item -fsign-zero
@opindex @code{fsign-zero}
When enabled, floating point numbers of value zero with the sign bit set
are written as negative number in formatted output and treated as
negative in the @code{SIGN} intrinsic.  @code{fno-sign-zero} does not
print the negative sign of zero values and regards zero as positive
number in the @code{SIGN} intrinsic for compatibility with F77.
Default behavior is to show the negative sign.
@end table

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

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
@opindex @code{fno-automatic}
@cindex @code{SAVE} statement
@cindex statement, @code{SAVE}
Treat each program unit (except those marked as RECURSIVE) as if the
@code{SAVE} statement were 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} or @option{-save}.)
The default, which is @option{-fautomatic}, uses the stack for local
variables smaller than the value given by @option{-fmax-stack-var-size}.
Use the option @option{-frecursive} to use no static memory. 

@item -ff2c
@opindex 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
@opindex @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 -fwhole-file
@opindex @code{fwhole-file}
By default, GNU Fortran parses, resolves and translates each procedure
in a file separately.  Using this option modifies this such that the
whole file is parsed and placed in a single front-end tree.  During
resolution, in addition to all the usual checks and fixups, references
to external procedures that are in the same file effect resolution of
that procedure, if not already done, and a check of the interfaces. The
dependences are resolved by changing the order in which the file is
translated into the backend tree.  Thus, a procedure that is referenced
is translated before the reference and the duplication of backend tree
declarations eliminated.

@item -fsecond-underscore
@opindex @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 -fcoarray=@var{<keyword>}
@opindex @code{fcoarray}
@cindex coarrays

@table @asis
@item @samp{none}
Disable coarray support; using coarray declarations and image-control
statements will produce a compile-time error. (Default)

@item @samp{single}
Single-image mode, i.e. @code{num_images()} is always one.

@item @samp{lib}
Library-based coarray parallelization; a suitable GNU Fortran coarray
library needs to be linked.
@end table


@item -fcheck=@var{<keyword>}
@opindex @code{fcheck}
@cindex array, bounds checking
@cindex bounds checking
@cindex pointer checking
@cindex memory checking
@cindex range checking
@cindex subscript checking
@cindex checking subscripts
@cindex run-time checking
@cindex checking array temporaries

Enable the generation of run-time checks; the argument shall be
a comma-delimited list of the following keywords.

@table @asis
@item @samp{all}
Enable all run-time test of @option{-fcheck}.

@item @samp{array-temps}
Warns at run time when for passing an actual argument a temporary array
had to be generated. The information generated by this warning is
sometimes useful in optimization, in order to avoid such temporaries.

Note: The warning is only printed once per location.

@item @samp{bounds}
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 and ensures that all string
lengths are equal for character array constructors without an explicit
typespec.

Some checks require that @option{-fcheck=bounds} is set for
the compilation of the main program.

Note: In the future this may also include other forms of checking, e.g.,
checking substring references.

@item @samp{do}
Enable generation of run-time checks for invalid modification of loop
iteration variables.

@item @samp{mem}
Enable generation of run-time checks for memory allocation.
Note: This option does not affect explicit allocations using the
@code{ALLOCATE} statement, which will be always checked.

@item @samp{pointer}
Enable generation of run-time checks for pointers and allocatables.

@item @samp{recursion}
Enable generation of run-time checks for recursively called subroutines and
functions which are not marked as recursive. See also @option{-frecursive}.
Note: This check does not work for OpenMP programs and is disabled if used
together with @option{-frecursive} and @option{-fopenmp}.
@end table


@item -fbounds-check
@opindex @code{fbounds-check}
@c Note: This option is also referred in gcc's manpage
Deprecated alias for @option{-fcheck=bounds}.

@item -fcheck-array-temporaries
@opindex @code{fcheck-array-temporaries}
Deprecated alias for @option{-fcheck=array-temps}.

@item -fmax-array-constructor=@var{n}
@opindex @code{fmax-array-constructor}
This option can be used to increase the upper limit permitted in 
array constructors.  The code below requires this option to expand
the array at compile time.

@smallexample
program test
implicit none
integer j
integer, parameter :: n = 100000
integer, parameter :: i(n) = (/ (2*j, j = 1, n) /)
print '(10(I0,1X))', i
end program test
@end smallexample

@emph{Caution:  This option can lead to long compile times and excessively
large object files.}

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


@item -fmax-stack-var-size=@var{n}
@opindex @code{fmax-stack-var-size}
This option specifies the size in bytes of the largest array that will be put
on the stack; if the size is exceeded static memory is used (except in
procedures marked as RECURSIVE). Use the option @option{-frecursive} to
allow for recursive procedures which do not have a RECURSIVE attribute or
for parallel programs. Use @option{-fno-automatic} to never use 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 -fstack-arrays
@opindex @code{fstack-arrays}
Adding this option will make the fortran compiler put all local arrays,
even those of unknown size onto stack memory.  If your program uses very
large local arrays it's possible that you'll have to extend your runtime
limits for stack memory on some operating systems. This flag is enabled
by default at optimization level @option{-Ofast}.


@item -fpack-derived
@opindex @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
@opindex @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
@opindex @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
@opindex @code{fexternal-blas}
This option will make @command{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}
@opindex @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.

@item -frecursive
@opindex @code{frecursive}
Allow indirect recursion by forcing all local arrays to be allocated
on the stack. This flag cannot be used together with
@option{-fmax-stack-var-size=} or @option{-fno-automatic}.

@item -finit-local-zero
@itemx -finit-integer=@var{n}
@itemx -finit-real=@var{<zero|inf|-inf|nan|snan>}
@itemx -finit-logical=@var{<true|false>}
@itemx -finit-character=@var{n}
@opindex @code{finit-local-zero}
@opindex @code{finit-integer}
@opindex @code{finit-real}
@opindex @code{finit-logical}
@opindex @code{finit-character}
The @option{-finit-local-zero} option instructs the compiler to
initialize local @code{INTEGER}, @code{REAL}, and @code{COMPLEX}
variables to zero, @code{LOGICAL} variables to false, and
@code{CHARACTER} variables to a string of null bytes.  Finer-grained
initialization options are provided by the
@option{-finit-integer=@var{n}},
@option{-finit-real=@var{<zero|inf|-inf|nan|snan>}} (which also initializes
the real and imaginary parts of local @code{COMPLEX} variables),
@option{-finit-logical=@var{<true|false>}}, and
@option{-finit-character=@var{n}} (where @var{n} is an ASCII character
value) options.  These options do not initialize components of derived
type variables, nor do they initialize variables that appear in an
@code{EQUIVALENCE} statement.  (This limitation may be removed in
future releases).

Note that the @option{-finit-real=nan} option initializes @code{REAL}
and @code{COMPLEX} variables with a quiet NaN. For a signalling NaN
use @option{-finit-real=snan}; note, however, that compile-time
optimizations may convert them into quiet NaN and that trapping
needs to be enabled (e.g. via @option{-ffpe-trap}).

@item -falign-commons
@opindex @code{falign-commons}
@cindex alignment of @code{COMMON} blocks
By default, @command{gfortran} enforces proper alignment of all variables in a
@code{COMMON} block by padding them as needed. On certain platforms this is mandatory,
on others it increases performance. If a @code{COMMON} block is not declared with
consistent data types everywhere, this padding can cause trouble, and
@option{-fno-align-commons} can be used to disable automatic alignment. The
same form of this option should be used for all files that share a @code{COMMON} block.
To avoid potential alignment issues in @code{COMMON} blocks, it is recommended to order
objects from largest to smallest.

@item -fno-protect-parens
@opindex @code{fno-protect-parens}
@cindex re-association of parenthesized expressions
By default the parentheses in expression are honored for all optimization
levels such that the compiler does not do any re-association. Using
@option{-fno-protect-parens} allows the compiler to reorder @code{REAL} and
@code{COMPLEX} expressions to produce faster code. Note that for the re-association
optimization @option{-fno-signed-zeros} and @option{-fno-trapping-math}
need to be in effect. The parentheses protection is enabled by default, unless
@option{-Ofast} is given.

@item -frealloc-lhs
@opindex @code{frealloc-lhs}
@cindex Reallocate the LHS in assignments
An allocatable left-hand side of an intrinsic assignment is automatically
(re)allocated if it is either unallocated or has a different shape. The
option is enabled by default except when @option{-std=f95} is given.

@item -faggressive-function-elimination
@opindex @code{faggressive-function-elimination}
@cindex Elimination of functions with identical argument lists
Functions with identical argument lists are eliminated within
statements, regardless of whether these functions are marked
@code{PURE} or not. For example, in
@smallexample
  a = f(b,c) + f(b,c)
@end smallexample
there will only be a single call to @code{f}.  This option only works
if @option{-ffrontend-optimize} is in effect.

@item -ffrontend-optimize
@opindex @code{frontend-optimize}
@cindex Front-end optimization
This option performs front-end optimization, based on manipulating
parts the Fortran parse tree.  Enabled by default by any @option{-O}
option.  Optimizations enabled by this option include elimination of
identical function calls within expressions, removing unnecessary
calls to @code{TRIM} in comparisons and assignments and replacing
@code{TRIM(a)} with @code{a(1:LEN_TRIM(a))}. 
It can be deselected by specifying @option{-fno-frontend-optimize}.
@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 variable

@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