OSDN Git Service

cf90ceda83324dff9ba9286d4b769c4b952292e5
[pf3gnuchains/gcc-fork.git] / gcc / fortran / gfortran.texi
1 \input texinfo  @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename gfortran.info
4 @set copyrights-gfortran 1999-2008
5
6 @include gcc-common.texi
7
8 @settitle The GNU Fortran Compiler
9
10 @c Create a separate index for command line options
11 @defcodeindex op
12 @c Merge the standard indexes into a single one.
13 @syncodeindex fn cp
14 @syncodeindex vr cp
15 @syncodeindex ky cp
16 @syncodeindex pg cp
17 @syncodeindex tp cp
18
19 @c TODO: The following "Part" definitions are included here temporarily
20 @c until they are incorporated into the official Texinfo distribution.
21 @c They borrow heavily from Texinfo's \unnchapentry definitions.
22
23 @tex
24 \gdef\part#1#2{%
25   \pchapsepmacro
26   \gdef\thischapter{}
27   \begingroup
28     \vglue\titlepagetopglue
29     \titlefonts \rm
30     \leftline{Part #1:@* #2}
31     \vskip4pt \hrule height 4pt width \hsize \vskip4pt
32   \endgroup
33   \writetocentry{part}{#2}{#1}
34 }
35 \gdef\blankpart{%
36   \writetocentry{blankpart}{}{}
37 }
38 % Part TOC-entry definition for summary contents.
39 \gdef\dosmallpartentry#1#2#3#4{%
40   \vskip .5\baselineskip plus.2\baselineskip
41   \begingroup
42     \let\rm=\bf \rm
43     \tocentry{Part #2: #1}{\doshortpageno\bgroup#4\egroup}
44   \endgroup
45 }
46 \gdef\dosmallblankpartentry#1#2#3#4{%
47   \vskip .5\baselineskip plus.2\baselineskip
48 }
49 % Part TOC-entry definition for regular contents.  This has to be
50 % equated to an existing entry to not cause problems when the PDF
51 % outline is created.
52 \gdef\dopartentry#1#2#3#4{%
53   \unnchapentry{Part #2: #1}{}{#3}{#4}
54 }
55 \gdef\doblankpartentry#1#2#3#4{}
56 @end tex
57
58 @c %**end of header
59
60 @c Use with @@smallbook.
61
62 @c %** start of document
63
64 @c Cause even numbered pages to be printed on the left hand side of
65 @c the page and odd numbered pages to be printed on the right hand
66 @c side of the page.  Using this, you can print on both sides of a
67 @c sheet of paper and have the text on the same part of the sheet.
68
69 @c The text on right hand pages is pushed towards the right hand
70 @c margin and the text on left hand pages is pushed toward the left
71 @c hand margin.
72 @c (To provide the reverse effect, set bindingoffset to -0.75in.)
73
74 @c @tex
75 @c \global\bindingoffset=0.75in
76 @c \global\normaloffset =0.75in
77 @c @end tex
78
79 @copying
80 Copyright @copyright{} @value{copyrights-gfortran} Free Software Foundation, Inc.
81
82 Permission is granted to copy, distribute and/or modify this document
83 under the terms of the GNU Free Documentation License, Version 1.1 or
84 any later version published by the Free Software Foundation; with the
85 Invariant Sections being ``GNU General Public License'' and ``Funding
86 Free Software'', the Front-Cover
87 texts being (a) (see below), and with the Back-Cover Texts being (b)
88 (see below).  A copy of the license is included in the section entitled
89 ``GNU Free Documentation License''.
90
91 (a) The FSF's Front-Cover Text is:
92
93      A GNU Manual
94
95 (b) The FSF's Back-Cover Text is:
96
97      You have freedom to copy and modify this GNU Manual, like GNU
98      software.  Copies published by the Free Software Foundation raise
99      funds for GNU development.
100 @end copying
101
102 @ifinfo
103 @dircategory Software development
104 @direntry
105 * gfortran: (gfortran).                  The GNU Fortran Compiler.
106 @end direntry
107 This file documents the use and the internals of
108 the GNU Fortran compiler, (@command{gfortran}).
109
110 Published by the Free Software Foundation
111 51 Franklin Street, Fifth Floor
112 Boston, MA 02110-1301 USA
113
114 @insertcopying
115 @end ifinfo
116
117
118 @setchapternewpage odd
119 @titlepage
120 @title Using GNU Fortran
121 @versionsubtitle
122 @author The @t{gfortran} team
123 @page
124 @vskip 0pt plus 1filll
125 Published by the Free Software Foundation@*
126 51 Franklin Street, Fifth Floor@*
127 Boston, MA 02110-1301, USA@*
128 @c Last printed ??ber, 19??.@*
129 @c Printed copies are available for $? each.@*
130 @c ISBN ???
131 @sp 1
132 @insertcopying
133 @end titlepage
134
135 @c TODO: The following "Part" definitions are included here temporarily
136 @c until they are incorporated into the official Texinfo distribution.
137
138 @tex
139 \global\let\partentry=\dosmallpartentry
140 \global\let\blankpartentry=\dosmallblankpartentry
141 @end tex
142 @summarycontents
143
144 @tex
145 \global\let\partentry=\dopartentry
146 \global\let\blankpartentry=\doblankpartentry
147 @end tex
148 @contents
149
150 @page
151
152 @c ---------------------------------------------------------------------
153 @c TexInfo table of contents.
154 @c ---------------------------------------------------------------------
155
156 @ifnottex
157 @node Top
158 @top Introduction
159 @cindex Introduction
160
161 This manual documents the use of @command{gfortran}, 
162 the GNU Fortran compiler. You can find in this manual how to invoke
163 @command{gfortran}, as well as its features and incompatibilities.
164
165 @ifset DEVELOPMENT
166 @emph{Warning:} This document, and the compiler it describes, are still
167 under development.  While efforts are made to keep it up-to-date, it might
168 not accurately reflect the status of the most recent GNU Fortran compiler.
169 @end ifset
170
171 @comment
172 @comment  When you add a new menu item, please keep the right hand
173 @comment  aligned to the same column.  Do not use tabs.  This provides
174 @comment  better formatting.
175 @comment
176 @menu
177 * Introduction::
178
179 Part I: Invoking GNU Fortran
180 * Invoking GNU Fortran:: Command options supported by @command{gfortran}.
181 * Runtime::              Influencing runtime behavior with environment variables.
182
183 Part II: Language Reference
184 * Fortran 2003 and 2008 status::  Fortran 2003 and 2008 features supported by GNU Fortran.
185 * Extensions::           Language extensions implemented by GNU Fortran.
186 * Intrinsic Procedures:: Intrinsic procedures supported by GNU Fortran.
187 * Intrinsic Modules::    Intrinsic modules supported by GNU Fortran.
188
189 * Contributing::         How you can help.
190 * Copying::              GNU General Public License says
191                          how you can copy and share GNU Fortran.
192 * GNU Free Documentation License::
193                          How you can copy and share this manual.
194 * Funding::              How to help assure continued work for free software.
195 * Option Index::         Index of command line options
196 * Keyword Index::        Index of concepts
197 @end menu
198 @end ifnottex
199
200 @c ---------------------------------------------------------------------
201 @c Introduction
202 @c ---------------------------------------------------------------------
203
204 @node Introduction
205 @chapter Introduction
206
207 @c The following duplicates the text on the TexInfo table of contents.
208 @iftex
209 This manual documents the use of @command{gfortran}, the GNU Fortran
210 compiler. You can find in this manual how to invoke @command{gfortran},
211 as well as its features and incompatibilities.
212
213 @ifset DEVELOPMENT
214 @emph{Warning:} This document, and the compiler it describes, are still
215 under development.  While efforts are made to keep it up-to-date, it
216 might not accurately reflect the status of the most recent GNU Fortran
217 compiler.
218 @end ifset
219 @end iftex
220
221 The GNU Fortran compiler front end was
222 designed initially as a free replacement for,
223 or alternative to, the unix @command{f95} command;
224 @command{gfortran} is the command you'll use to invoke the compiler.
225
226 @menu
227 * About GNU Fortran::    What you should know about the GNU Fortran compiler.
228 * GNU Fortran and GCC::  You can compile Fortran, C, or other programs.
229 * Preprocessing and conditional compilation:: The Fortran preprocessor
230 * GNU Fortran and G77::  Why we chose to start from scratch.
231 * Project Status::       Status of GNU Fortran, roadmap, proposed extensions.
232 * Standards::            Standards supported by GNU Fortran.
233 @end menu
234
235
236 @c ---------------------------------------------------------------------
237 @c About GNU Fortran
238 @c ---------------------------------------------------------------------
239
240 @node About GNU Fortran
241 @section About GNU Fortran
242
243 The GNU Fortran compiler is still in an early state of development.
244 It can generate code for most constructs and expressions,
245 but much work remains to be done.
246
247 When the GNU Fortran compiler is finished,
248 it will do everything you expect from any decent compiler: 
249
250 @itemize @bullet
251 @item
252 Read a user's program,
253 stored in a file and containing instructions written
254 in Fortran 77, Fortran 90, Fortran 95, Fortran 2003 or Fortran 2008.
255 This file contains @dfn{source code}.
256
257 @item
258 Translate the user's program into instructions a computer
259 can carry out more quickly than it takes to translate the
260 instructions in the first
261 place.  The result after compilation of a program is
262 @dfn{machine code},
263 code designed to be efficiently translated and processed
264 by a machine such as your computer.
265 Humans usually aren't as good writing machine code
266 as they are at writing Fortran (or C++, Ada, or Java),
267 because is easy to make tiny mistakes writing machine code.
268
269 @item
270 Provide the user with information about the reasons why
271 the compiler is unable to create a binary from the source code.
272 Usually this will be the case if the source code is flawed.
273 When writing Fortran, it is easy to make big mistakes.
274 The Fortran 90 requires that the compiler can point out
275 mistakes to the user.
276 An incorrect usage of the language causes an @dfn{error message}.
277
278 The compiler will also attempt to diagnose cases where the
279 user's program contains a correct usage of the language,
280 but instructs the computer to do something questionable.
281 This kind of diagnostics message is called a @dfn{warning message}.
282
283 @item
284 Provide optional information about the translation passes
285 from the source code to machine code.
286 This can help a user of the compiler to find the cause of
287 certain bugs which may not be obvious in the source code,
288 but may be more easily found at a lower level compiler output.
289 It also helps developers to find bugs in the compiler itself.
290
291 @item
292 Provide information in the generated machine code that can
293 make it easier to find bugs in the program (using a debugging tool,
294 called a @dfn{debugger}, such as the GNU Debugger @command{gdb}). 
295
296 @item
297 Locate and gather machine code already generated to
298 perform actions requested by statements in the user's program.
299 This machine code is organized into @dfn{modules} and is located
300 and @dfn{linked} to the user program. 
301 @end itemize
302
303 The GNU Fortran compiler consists of several components:
304
305 @itemize @bullet
306 @item
307 A version of the @command{gcc} command
308 (which also might be installed as the system's @command{cc} command)
309 that also understands and accepts Fortran source code.
310 The @command{gcc} command is the @dfn{driver} program for
311 all the languages in the GNU Compiler Collection (GCC);
312 With @command{gcc},
313 you can compile the source code of any language for
314 which a front end is available in GCC.
315
316 @item
317 The @command{gfortran} command itself,
318 which also might be installed as the
319 system's @command{f95} command.
320 @command{gfortran} is just another driver program,
321 but specifically for the Fortran compiler only.
322 The difference with @command{gcc} is that @command{gfortran}
323 will automatically link the correct libraries to your program.
324
325 @item
326 A collection of run-time libraries.
327 These libraries contain the machine code needed to support
328 capabilities of the Fortran language that are not directly
329 provided by the machine code generated by the
330 @command{gfortran} compilation phase,
331 such as intrinsic functions and subroutines,
332 and routines for interaction with files and the operating system.
333 @c and mechanisms to spawn,
334 @c unleash and pause threads in parallelized code.
335
336 @item
337 The Fortran compiler itself, (@command{f951}).
338 This is the GNU Fortran parser and code generator,
339 linked to and interfaced with the GCC backend library.
340 @command{f951} ``translates'' the source code to
341 assembler code.  You would typically not use this
342 program directly;
343 instead, the @command{gcc} or @command{gfortran} driver
344 programs will call it for you.
345 @end itemize
346
347
348 @c ---------------------------------------------------------------------
349 @c GNU Fortran and GCC
350 @c ---------------------------------------------------------------------
351
352 @node GNU Fortran and GCC
353 @section GNU Fortran and GCC
354 @cindex GNU Compiler Collection
355 @cindex GCC
356
357 GNU Fortran is a part of GCC, the @dfn{GNU Compiler Collection}.  GCC
358 consists of a collection of front ends for various languages, which
359 translate the source code into a language-independent form called
360 @dfn{GENERIC}.  This is then processed by a common middle end which
361 provides optimization, and then passed to one of a collection of back
362 ends which generate code for different computer architectures and
363 operating systems.
364
365 Functionally, this is implemented with a driver program (@command{gcc})
366 which provides the command-line interface for the compiler.  It calls
367 the relevant compiler front-end program (e.g., @command{f951} for
368 Fortran) for each file in the source code, and then calls the assembler
369 and linker as appropriate to produce the compiled output. In a copy of
370 GCC which has been compiled with Fortran language support enabled,
371 @command{gcc} will recognize files with @file{.f}, @file{.for}, @file{.ftn},
372 @file{.f90}, @file{.f95}, @file{.f03} and @file{.f08} extensions as
373 Fortran source code, and compile it accordingly. A @command{gfortran}
374 driver program is also provided, which is identical to @command{gcc}
375 except that it automatically links the Fortran runtime libraries into the
376 compiled program.
377
378 Source files with @file{.f}, @file{.for}, @file{.fpp}, @file{.ftn}, @file{.F},
379 @file{.FOR}, @file{.FPP}, and @file{.FTN} extensions are treated as fixed form.
380 Source files with @file{.f90}, @file{.f95}, @file{.f03}, @file{.f08},
381 @file{.F90}, @file{.F95}, @file{.F03} and @file{.F08} extensions are
382 treated as free form.  The capitalized versions of either form are run
383 through preprocessing. Source files with the lower case @file{.fpp}
384 extension are also run through preprocessing.
385
386 This manual specifically documents the Fortran front end, which handles
387 the programming language's syntax and semantics.  The aspects of GCC
388 which relate to the optimization passes and the back-end code generation
389 are documented in the GCC manual; see 
390 @ref{Top,,Introduction,gcc,Using the GNU Compiler Collection (GCC)}.
391 The two manuals together provide a complete reference for the GNU
392 Fortran compiler.
393
394
395 @c ---------------------------------------------------------------------
396 @c Preprocessing and conditional compilation
397 @c ---------------------------------------------------------------------
398
399 @node Preprocessing and conditional compilation
400 @section Preprocessing and conditional compilation
401 @cindex CPP
402 @cindex FPP
403 @cindex Conditional compilation
404 @cindex Preprocessing
405
406 Many Fortran compilers including GNU Fortran allow passing the source code
407 through a C preprocessor (CPP; sometimes also called the Fortran preprocessor,
408 FPP) to allow for conditional compilation. In the case of GNU Fortran,
409 this is the GNU C Preprocessor in the traditional mode. On systems with
410 case-preserving file names, the preprocessor is automatically invoked if the
411 filename extension is @code{.F}, @code{.FOR}, @code{.FTN}, @code{.fpp},
412 @code{.FPP}, @code{.F90}, @code{.F95}, @code{.F03} or @code{.F08}. To manually
413 invoke the preprocessor on any file, use @option{-cpp}, to disable
414 preprocessing on files where the preprocessor is run automatically, use
415 @option{-nocpp}.
416
417 If the GNU Fortran invoked the preprocessor, @code{__GFORTRAN__}
418 is defined and @code{__GNUC__}, @code{__GNUC_MINOR__} and
419 @code{__GNUC_PATCHLEVEL__} can be used to determine the version of the
420 compiler. See @ref{Top,,Overview,cpp,The C Preprocessor} for details.
421
422 While CPP is the de-facto standard for preprocessing Fortran code,
423 Part 3 of the Fortran 95 standard (ISO/IEC 1539-3:1998) defines
424 Conditional Compilation, which is not widely used and not directly
425 supported by the GNU Fortran compiler. You can use the program coco
426 to preprocess such files (@uref{http://users.erols.com/dnagle/coco.html}).
427
428
429 @c ---------------------------------------------------------------------
430 @c GNU Fortran and G77
431 @c ---------------------------------------------------------------------
432
433 @node GNU Fortran and G77
434 @section GNU Fortran and G77
435 @cindex Fortran 77
436 @cindex @command{g77}
437
438 The GNU Fortran compiler is the successor to @command{g77}, the Fortran 
439 77 front end included in GCC prior to version 4.  It is an entirely new 
440 program that has been designed to provide Fortran 95 support and 
441 extensibility for future Fortran language standards, as well as providing 
442 backwards compatibility for Fortran 77 and nearly all of the GNU language 
443 extensions supported by @command{g77}.
444
445
446 @c ---------------------------------------------------------------------
447 @c Project Status
448 @c ---------------------------------------------------------------------
449
450 @node Project Status
451 @section Project Status
452
453 @quotation
454 As soon as @command{gfortran} can parse all of the statements correctly,
455 it will be in the ``larva'' state.
456 When we generate code, the ``puppa'' state.
457 When @command{gfortran} is done,
458 we'll see if it will be a beautiful butterfly,
459 or just a big bug....
460
461 --Andy Vaught, April 2000
462 @end quotation
463
464 The start of the GNU Fortran 95 project was announced on
465 the GCC homepage in March 18, 2000
466 (even though Andy had already been working on it for a while,
467 of course).
468
469 The GNU Fortran compiler is able to compile nearly all
470 standard-compliant Fortran 95, Fortran 90, and Fortran 77 programs,
471 including a number of standard and non-standard extensions, and can be
472 used on real-world programs.  In particular, the supported extensions
473 include OpenMP, Cray-style pointers, and several Fortran 2003 and Fortran
474 2008 features such as enumeration, stream I/O, and some of the
475 enhancements to allocatable array support from TR 15581.  However, it is
476 still under development and has a few remaining rough edges.
477
478 At present, the GNU Fortran compiler passes the
479 @uref{http://www.fortran-2000.com/ArnaudRecipes/fcvs21_f95.html, 
480 NIST Fortran 77 Test Suite}, and produces acceptable results on the
481 @uref{http://www.netlib.org/lapack/faq.html#1.21, LAPACK Test Suite}.
482 It also provides respectable performance on 
483 the @uref{http://www.polyhedron.com/pb05.html, Polyhedron Fortran
484 compiler benchmarks} and the
485 @uref{http://www.llnl.gov/asci_benchmarks/asci/limited/lfk/README.html,
486 Livermore Fortran Kernels test}.  It has been used to compile a number of
487 large real-world programs, including
488 @uref{http://mysite.verizon.net/serveall/moene.pdf, the HIRLAM
489 weather-forecasting code} and
490 @uref{http://www.theochem.uwa.edu.au/tonto/, the Tonto quantum 
491 chemistry package}; see @url{http://gcc.gnu.org/wiki/GfortranApps} for an
492 extended list.
493
494 Among other things, the GNU Fortran compiler is intended as a replacement
495 for G77.  At this point, nearly all programs that could be compiled with
496 G77 can be compiled with GNU Fortran, although there are a few minor known
497 regressions.
498
499 The primary work remaining to be done on GNU Fortran falls into three
500 categories: bug fixing (primarily regarding the treatment of invalid code
501 and providing useful error messages), improving the compiler optimizations
502 and the performance of compiled code, and extending the compiler to support
503 future standards---in particular, Fortran 2003.
504
505
506 @c ---------------------------------------------------------------------
507 @c Standards
508 @c ---------------------------------------------------------------------
509
510 @node Standards
511 @section Standards
512 @cindex Standards
513
514 The GNU Fortran compiler implements
515 ISO/IEC 1539:1997 (Fortran 95).  As such, it can also compile essentially all
516 standard-compliant Fortran 90 and Fortran 77 programs.   It also supports
517 the ISO/IEC TR-15581 enhancements to allocatable arrays, and
518 the @uref{http://www.openmp.org/drupal/mp-documents/spec25.pdf,
519 OpenMP Application Program Interface v2.5} specification.
520
521 In the future, the GNU Fortran compiler will also support ISO/IEC
522 1539-1:2004 (Fortran 2003) and future Fortran standards. Partial support
523 of that standard is already provided; the current status of Fortran 2003
524 support is reported in the @ref{Fortran 2003 status} section of the
525 documentation.
526
527 The next version of the Fortran standard after Fortran 2003 is currently
528 being developed and the GNU Fortran compiler supports some of its new
529 features. This support is based on the latest draft of the standard
530 (available from @url{http://www.nag.co.uk/sc22wg5/}) and no guarantee of
531 future compatibility is made, as the final standard might differ from the
532 draft. For more information, see the @ref{Fortran 2008 status} section.
533
534
535 @c =====================================================================
536 @c PART I: INVOCATION REFERENCE
537 @c =====================================================================
538
539 @tex
540 \part{I}{Invoking GNU Fortran}
541 @end tex
542
543 @c ---------------------------------------------------------------------
544 @c Compiler Options
545 @c ---------------------------------------------------------------------
546
547 @include invoke.texi
548
549
550 @c ---------------------------------------------------------------------
551 @c Runtime
552 @c ---------------------------------------------------------------------
553
554 @node Runtime
555 @chapter Runtime:  Influencing runtime behavior with environment variables
556 @cindex environment variable
557
558 The behavior of the @command{gfortran} can be influenced by
559 environment variables.
560
561 Malformed environment variables are silently ignored.
562
563 @menu
564 * GFORTRAN_STDIN_UNIT:: Unit number for standard input
565 * GFORTRAN_STDOUT_UNIT:: Unit number for standard output
566 * GFORTRAN_STDERR_UNIT:: Unit number for standard error
567 * GFORTRAN_USE_STDERR:: Send library output to standard error
568 * GFORTRAN_TMPDIR:: Directory for scratch files
569 * GFORTRAN_UNBUFFERED_ALL:: Don't buffer I/O for all units.
570 * GFORTRAN_UNBUFFERED_PRECONNECTED:: Don't buffer I/O for preconnected units.
571 * GFORTRAN_SHOW_LOCUS::  Show location for runtime errors
572 * GFORTRAN_OPTIONAL_PLUS:: Print leading + where permitted
573 * GFORTRAN_DEFAULT_RECL:: Default record length for new files
574 * GFORTRAN_LIST_SEPARATOR::  Separator for list output
575 * GFORTRAN_CONVERT_UNIT::  Set endianness for unformatted I/O
576 * GFORTRAN_ERROR_DUMPCORE:: Dump core on run-time errors
577 * GFORTRAN_ERROR_BACKTRACE:: Show backtrace on run-time errors
578 @end menu
579
580 @node GFORTRAN_STDIN_UNIT
581 @section @env{GFORTRAN_STDIN_UNIT}---Unit number for standard input
582
583 This environment variable can be used to select the unit number
584 preconnected to standard input.  This must be a positive integer.
585 The default value is 5.
586
587 @node GFORTRAN_STDOUT_UNIT
588 @section @env{GFORTRAN_STDOUT_UNIT}---Unit number for standard output
589
590 This environment variable can be used to select the unit number
591 preconnected to standard output.  This must be a positive integer.
592 The default value is 6.
593
594 @node GFORTRAN_STDERR_UNIT
595 @section @env{GFORTRAN_STDERR_UNIT}---Unit number for standard error
596
597 This environment variable can be used to select the unit number
598 preconnected to standard error.  This must be a positive integer.
599 The default value is 0.
600
601 @node GFORTRAN_USE_STDERR
602 @section @env{GFORTRAN_USE_STDERR}---Send library output to standard error
603
604 This environment variable controls where library output is sent.
605 If the first letter is @samp{y}, @samp{Y} or @samp{1}, standard
606 error is used. If the first letter is @samp{n}, @samp{N} or
607 @samp{0}, standard output is used.
608
609 @node GFORTRAN_TMPDIR
610 @section @env{GFORTRAN_TMPDIR}---Directory for scratch files
611
612 This environment variable controls where scratch files are
613 created.  If this environment variable is missing,
614 GNU Fortran searches for the environment variable @env{TMP}.  If
615 this is also missing, the default is @file{/tmp}.
616
617 @node GFORTRAN_UNBUFFERED_ALL
618 @section @env{GFORTRAN_UNBUFFERED_ALL}---Don't buffer I/O on all units
619
620 This environment variable controls whether all I/O is unbuffered.  If
621 the first letter is @samp{y}, @samp{Y} or @samp{1}, all I/O is
622 unbuffered. This will slow down small sequential reads and writes.  If
623 the first letter is @samp{n}, @samp{N} or @samp{0}, I/O is buffered.
624 This is the default.
625
626 @node GFORTRAN_UNBUFFERED_PRECONNECTED
627 @section @env{GFORTRAN_UNBUFFERED_PRECONNECTED}---Don't buffer I/O on preconnected units
628
629 The environment variable named @env{GFORTRAN_UNBUFFERED_PRECONNECTED} controls
630 whether I/O on a preconnected unit (i.e.@: STDOUT or STDERR) is unbuffered.  If 
631 the first letter is @samp{y}, @samp{Y} or @samp{1}, I/O is unbuffered. This
632 will slow down small sequential reads and writes.  If the first letter
633 is @samp{n}, @samp{N} or @samp{0}, I/O is buffered.  This is the default.
634
635 @node GFORTRAN_SHOW_LOCUS
636 @section @env{GFORTRAN_SHOW_LOCUS}---Show location for runtime errors
637
638 If the first letter is @samp{y}, @samp{Y} or @samp{1}, filename and
639 line numbers for runtime errors are printed.  If the first letter is
640 @samp{n}, @samp{N} or @samp{0}, don't print filename and line numbers
641 for runtime errors. The default is to print the location.
642
643 @node GFORTRAN_OPTIONAL_PLUS
644 @section @env{GFORTRAN_OPTIONAL_PLUS}---Print leading + where permitted
645
646 If the first letter is @samp{y}, @samp{Y} or @samp{1},
647 a plus sign is printed
648 where permitted by the Fortran standard.  If the first letter
649 is @samp{n}, @samp{N} or @samp{0}, a plus sign is not printed
650 in most cases. Default is not to print plus signs.
651
652 @node GFORTRAN_DEFAULT_RECL
653 @section @env{GFORTRAN_DEFAULT_RECL}---Default record length for new files
654
655 This environment variable specifies the default record length, in
656 bytes, for files which are opened without a @code{RECL} tag in the
657 @code{OPEN} statement.  This must be a positive integer.  The
658 default value is 1073741824 bytes (1 GB).
659
660 @node GFORTRAN_LIST_SEPARATOR
661 @section @env{GFORTRAN_LIST_SEPARATOR}---Separator for list output
662
663 This environment variable specifies the separator when writing
664 list-directed output.  It may contain any number of spaces and
665 at most one comma.  If you specify this on the command line,
666 be sure to quote spaces, as in
667 @smallexample
668 $ GFORTRAN_LIST_SEPARATOR='  ,  ' ./a.out
669 @end smallexample
670 when @command{a.out} is the compiled Fortran program that you want to run.
671 Default is a single space.
672
673 @node GFORTRAN_CONVERT_UNIT
674 @section @env{GFORTRAN_CONVERT_UNIT}---Set endianness for unformatted I/O
675
676 By setting the @env{GFORTRAN_CONVERT_UNIT} variable, it is possible
677 to change the representation of data for unformatted files.
678 The syntax for the @env{GFORTRAN_CONVERT_UNIT} variable is:
679 @smallexample
680 GFORTRAN_CONVERT_UNIT: mode | mode ';' exception | exception ;
681 mode: 'native' | 'swap' | 'big_endian' | 'little_endian' ;
682 exception: mode ':' unit_list | unit_list ;
683 unit_list: unit_spec | unit_list unit_spec ;
684 unit_spec: INTEGER | INTEGER '-' INTEGER ;
685 @end smallexample
686 The variable consists of an optional default mode, followed by
687 a list of optional exceptions, which are separated by semicolons
688 from the preceding default and each other.  Each exception consists
689 of a format and a comma-separated list of units.  Valid values for
690 the modes are the same as for the @code{CONVERT} specifier:
691
692 @itemize @w{}
693 @item @code{NATIVE} Use the native format.  This is the default.
694 @item @code{SWAP} Swap between little- and big-endian.
695 @item @code{LITTLE_ENDIAN} Use the little-endian format
696 for unformatted files.
697 @item @code{BIG_ENDIAN} Use the big-endian format for unformatted files.
698 @end itemize
699 A missing mode for an exception is taken to mean @code{BIG_ENDIAN}.
700 Examples of values for @env{GFORTRAN_CONVERT_UNIT} are:
701 @itemize @w{}
702 @item @code{'big_endian'}  Do all unformatted I/O in big_endian mode.
703 @item @code{'little_endian;native:10-20,25'}  Do all unformatted I/O 
704 in little_endian mode, except for units 10 to 20 and 25, which are in
705 native format.
706 @item @code{'10-20'}  Units 10 to 20 are big-endian, the rest is native.
707 @end itemize
708
709 Setting the environment variables should be done on the command
710 line or via the @command{export}
711 command for @command{sh}-compatible shells and via @command{setenv}
712 for @command{csh}-compatible shells.
713
714 Example for @command{sh}:
715 @smallexample
716 $ gfortran foo.f90
717 $ GFORTRAN_CONVERT_UNIT='big_endian;native:10-20' ./a.out
718 @end smallexample
719
720 Example code for @command{csh}:
721 @smallexample
722 % gfortran foo.f90
723 % setenv GFORTRAN_CONVERT_UNIT 'big_endian;native:10-20'
724 % ./a.out
725 @end smallexample
726
727 Using anything but the native representation for unformatted data
728 carries a significant speed overhead.  If speed in this area matters
729 to you, it is best if you use this only for data that needs to be
730 portable.
731
732 @xref{CONVERT specifier}, for an alternative way to specify the
733 data representation for unformatted files.  @xref{Runtime Options}, for
734 setting a default data representation for the whole program.  The
735 @code{CONVERT} specifier overrides the @option{-fconvert} compile options.
736
737 @emph{Note that the values specified via the GFORTRAN_CONVERT_UNIT
738 environment variable will override the CONVERT specifier in the
739 open statement}.  This is to give control over data formats to
740 users who do not have the source code of their program available.
741
742 @node GFORTRAN_ERROR_DUMPCORE
743 @section @env{GFORTRAN_ERROR_DUMPCORE}---Dump core on run-time errors
744
745 If the @env{GFORTRAN_ERROR_DUMPCORE} variable is set to
746 @samp{y}, @samp{Y} or @samp{1} (only the first letter is relevant)
747 then library run-time errors cause core dumps. To disable the core
748 dumps, set the variable to @samp{n}, @samp{N}, @samp{0}. Default
749 is not to core dump unless the @option{-fdump-core} compile option
750 was used.
751
752 @node GFORTRAN_ERROR_BACKTRACE
753 @section @env{GFORTRAN_ERROR_BACKTRACE}---Show backtrace on run-time errors
754
755 If the @env{GFORTRAN_ERROR_BACKTRACE} variable is set to
756 @samp{y}, @samp{Y} or @samp{1} (only the first letter is relevant)
757 then a backtrace is printed when a run-time error occurs.
758 To disable the backtracing, set the variable to
759 @samp{n}, @samp{N}, @samp{0}. Default is not to print a backtrace
760 unless the @option{-fbacktrace} compile option
761 was used.
762
763 @c =====================================================================
764 @c PART II: LANGUAGE REFERENCE
765 @c =====================================================================
766
767 @tex
768 \part{II}{Language Reference}
769 @end tex
770
771 @c ---------------------------------------------------------------------
772 @c Fortran 2003 and 2008 Status
773 @c ---------------------------------------------------------------------
774
775 @node Fortran 2003 and 2008 status
776 @chapter Fortran 2003 and 2008 Status
777
778 @menu
779 * Fortran 2003 status::
780 * Fortran 2008 status::
781 @end menu
782
783 @node Fortran 2003 status
784 @section Fortran 2003 status
785
786 Although GNU Fortran focuses on implementing the Fortran 95
787 standard for the time being, a few Fortran 2003 features are currently
788 available.
789
790 @itemize
791 @item 
792 Intrinsics @code{command_argument_count}, @code{get_command},
793 @code{get_command_argument}, @code{get_environment_variable}, and
794 @code{move_alloc}.
795
796 @item 
797 @cindex array, constructors
798 @cindex @code{[...]}
799 Array constructors using square brackets. That is, @code{[...]} rather
800 than @code{(/.../)}.
801
802 @item
803 @cindex @code{FLUSH} statement
804 @cindex statement, @code{FLUSH}
805 @code{FLUSH} statement.
806
807 @item
808 @cindex @code{IOMSG=} specifier
809 @code{IOMSG=} specifier for I/O statements.
810
811 @item
812 @cindex @code{ENUM} statement
813 @cindex @code{ENUMERATOR} statement
814 @cindex statement, @code{ENUM}
815 @cindex statement, @code{ENUMERATOR}
816 @opindex @code{fshort-enums}
817 Support for the declaration of enumeration constants via the
818 @code{ENUM} and @code{ENUMERATOR} statements.  Interoperability with
819 @command{gcc} is guaranteed also for the case where the
820 @command{-fshort-enums} command line option is given.
821
822 @item
823 @cindex TR 15581
824 TR 15581:
825 @itemize
826 @item
827 @cindex @code{ALLOCATABLE} dummy arguments
828 @code{ALLOCATABLE} dummy arguments.
829 @item
830 @cindex @code{ALLOCATABLE} function results
831 @code{ALLOCATABLE} function results
832 @item
833 @cindex @code{ALLOCATABLE} components of derived types
834 @code{ALLOCATABLE} components of derived types
835 @end itemize
836
837 @item
838 @cindex @code{STREAM} I/O
839 @cindex @code{ACCESS='STREAM'} I/O
840 The @code{OPEN} statement supports the @code{ACCESS='STREAM'} specifier,
841 allowing I/O without any record structure.
842
843 @item
844 Namelist input/output for internal files.
845
846 @item
847 @cindex @code{PROTECTED} statement
848 @cindex statement, @code{PROTECTED}
849 The @code{PROTECTED} statement and attribute.
850
851 @item
852 @cindex @code{VALUE} statement
853 @cindex statement, @code{VALUE}
854 The @code{VALUE} statement and attribute.
855
856 @item
857 @cindex @code{VOLATILE} statement
858 @cindex statement, @code{VOLATILE}
859 The @code{VOLATILE} statement and attribute.
860
861 @item
862 @cindex @code{IMPORT} statement
863 @cindex statement, @code{IMPORT}
864 The @code{IMPORT} statement, allowing to import
865 host-associated derived types.
866
867 @item
868 @cindex @code{USE, INTRINSIC} statement
869 @cindex statement, @code{USE, INTRINSIC}
870 @cindex @code{ISO_FORTRAN_ENV} statement
871 @cindex statement, @code{ISO_FORTRAN_ENV}
872 @code{USE} statement with @code{INTRINSIC} and @code{NON_INTRINSIC}
873 attribute; supported intrinsic modules: @code{ISO_FORTRAN_ENV},
874 @code{OMP_LIB} and @code{OMP_LIB_KINDS}.
875
876 @item
877 Renaming of operators in the @code{USE} statement.
878
879 @item
880 @cindex ISO C Bindings
881 Interoperability with C (ISO C Bindings)
882
883 @item
884 BOZ as argument of INT, REAL, DBLE and CMPLX.
885
886 @end itemize
887
888
889 @node Fortran 2008 status
890 @section Fortran 2008 status
891
892 The next version of the Fortran standard after Fortran 2003 is currently
893 being worked on by the Working Group 5 of Sub-Committee 22 of the Joint
894 Technical Committee 1 of the International Organization for
895 Standardization (ISO) and the International Electrotechnical Commission
896 (IEC). This group is known at @uref{http://www.nag.co.uk/sc22wg5/, WG5}.
897 The next revision of the Fortran standard is informally referred to as
898 Fortran 2008, reflecting its planned release year. The GNU Fortran
899 compiler has support for some of the new features in Fortran 2008. This
900 support is based on the latest draft, available from
901 @url{http://www.nag.co.uk/sc22wg5/}. However, as the final standard may
902 differ from the drafts, no guarantee of backward compatibility can be
903 made and you should only use it for experimental purposes.
904
905 @c ---------------------------------------------------------------------
906 @c Extensions
907 @c ---------------------------------------------------------------------
908
909 @c Maybe this chapter should be merged with the 'Standards' section,
910 @c whenever that is written :-)
911
912 @node Extensions
913 @chapter Extensions
914 @cindex extensions
915
916 The two sections below detail the extensions to standard Fortran that are
917 implemented in GNU Fortran, as well as some of the popular or
918 historically important extensions that are not (or not yet) implemented.
919 For the latter case, we explain the alternatives available to GNU Fortran
920 users, including replacement by standard-conforming code or GNU
921 extensions.
922
923 @menu
924 * Extensions implemented in GNU Fortran::
925 * Extensions not implemented in GNU Fortran::
926 @end menu
927
928
929 @node Extensions implemented in GNU Fortran
930 @section Extensions implemented in GNU Fortran
931 @cindex extensions, implemented
932
933 GNU Fortran implements a number of extensions over standard
934 Fortran. This chapter contains information on their syntax and
935 meaning.  There are currently two categories of GNU Fortran
936 extensions, those that provide functionality beyond that provided
937 by any standard, and those that are supported by GNU Fortran
938 purely for backward compatibility with legacy compilers.  By default,
939 @option{-std=gnu} allows the compiler to accept both types of
940 extensions, but to warn about the use of the latter.  Specifying
941 either @option{-std=f95}, @option{-std=f2003} or @option{-std=f2008}
942 disables both types of extensions, and @option{-std=legacy} allows both
943 without warning.
944
945 @menu
946 * Old-style kind specifications::
947 * Old-style variable initialization::
948 * Extensions to namelist::
949 * X format descriptor without count field::
950 * Commas in FORMAT specifications::
951 * Missing period in FORMAT specifications::
952 * I/O item lists::
953 * BOZ literal constants::
954 * Real array indices::
955 * Unary operators::
956 * Implicitly convert LOGICAL and INTEGER values::
957 * Hollerith constants support::
958 * Cray pointers::
959 * CONVERT specifier::
960 * OpenMP::
961 * Argument list functions::
962 @end menu
963
964 @node Old-style kind specifications
965 @subsection Old-style kind specifications
966 @cindex kind, old-style
967
968 GNU Fortran allows old-style kind specifications in declarations. These
969 look like:
970 @smallexample
971       TYPESPEC*size x,y,z
972 @end smallexample
973 @noindent
974 where @code{TYPESPEC} is a basic type (@code{INTEGER}, @code{REAL},
975 etc.), and where @code{size} is a byte count corresponding to the
976 storage size of a valid kind for that type.  (For @code{COMPLEX}
977 variables, @code{size} is the total size of the real and imaginary
978 parts.)  The statement then declares @code{x}, @code{y} and @code{z} to
979 be of type @code{TYPESPEC} with the appropriate kind.  This is
980 equivalent to the standard-conforming declaration
981 @smallexample
982       TYPESPEC(k) x,y,z
983 @end smallexample
984 @noindent
985 where @code{k} is equal to @code{size} for most types, but is equal to
986 @code{size/2} for the @code{COMPLEX} type.
987
988 @node Old-style variable initialization
989 @subsection Old-style variable initialization
990
991 GNU Fortran allows old-style initialization of variables of the
992 form:
993 @smallexample
994       INTEGER i/1/,j/2/
995       REAL x(2,2) /3*0.,1./
996 @end smallexample
997 The syntax for the initializers is as for the @code{DATA} statement, but
998 unlike in a @code{DATA} statement, an initializer only applies to the
999 variable immediately preceding the initialization.  In other words,
1000 something like @code{INTEGER I,J/2,3/} is not valid.  This style of
1001 initialization is only allowed in declarations without double colons
1002 (@code{::}); the double colons were introduced in Fortran 90, which also
1003 introduced a standard syntax for initializing variables in type
1004 declarations.
1005
1006 Examples of standard-conforming code equivalent to the above example
1007 are:
1008 @smallexample
1009 ! Fortran 90
1010       INTEGER :: i = 1, j = 2
1011       REAL :: x(2,2) = RESHAPE((/0.,0.,0.,1./),SHAPE(x))
1012 ! Fortran 77
1013       INTEGER i, j
1014       REAL x(2,2)
1015       DATA i/1/, j/2/, x/3*0.,1./
1016 @end smallexample
1017
1018 Note that variables which are explicitly initialized in declarations
1019 or in @code{DATA} statements automatically acquire the @code{SAVE}
1020 attribute.
1021
1022 @node Extensions to namelist
1023 @subsection Extensions to namelist
1024 @cindex Namelist
1025
1026 GNU Fortran fully supports the Fortran 95 standard for namelist I/O
1027 including array qualifiers, substrings and fully qualified derived types.
1028 The output from a namelist write is compatible with namelist read.  The
1029 output has all names in upper case and indentation to column 1 after the
1030 namelist name.  Two extensions are permitted:
1031
1032 Old-style use of @samp{$} instead of @samp{&}
1033 @smallexample
1034 $MYNML
1035  X(:)%Y(2) = 1.0 2.0 3.0
1036  CH(1:4) = "abcd"
1037 $END
1038 @end smallexample
1039
1040 It should be noted that the default terminator is @samp{/} rather than
1041 @samp{&END}.
1042
1043 Querying of the namelist when inputting from stdin. After at least
1044 one space, entering @samp{?} sends to stdout the namelist name and the names of
1045 the variables in the namelist:
1046 @smallexample
1047  ?
1048
1049 &mynml
1050  x
1051  x%y
1052  ch
1053 &end
1054 @end smallexample
1055
1056 Entering @samp{=?} outputs the namelist to stdout, as if
1057 @code{WRITE(*,NML = mynml)} had been called:
1058 @smallexample
1059 =?
1060
1061 &MYNML
1062  X(1)%Y=  0.000000    ,  1.000000    ,  0.000000    ,
1063  X(2)%Y=  0.000000    ,  2.000000    ,  0.000000    ,
1064  X(3)%Y=  0.000000    ,  3.000000    ,  0.000000    ,
1065  CH=abcd,  /
1066 @end smallexample
1067
1068 To aid this dialog, when input is from stdin, errors send their
1069 messages to stderr and execution continues, even if @code{IOSTAT} is set.
1070
1071 @code{PRINT} namelist is permitted.  This causes an error if
1072 @option{-std=f95} is used.
1073 @smallexample
1074 PROGRAM test_print
1075   REAL, dimension (4)  ::  x = (/1.0, 2.0, 3.0, 4.0/)
1076   NAMELIST /mynml/ x
1077   PRINT mynml
1078 END PROGRAM test_print
1079 @end smallexample
1080
1081 Expanded namelist reads are permitted.  This causes an error if 
1082 @option{-std=f95} is used.  In the following example, the first element
1083 of the array will be given the value 0.00 and the two succeeding
1084 elements will be given the values 1.00 and 2.00.
1085 @smallexample
1086 &MYNML
1087   X(1,1) = 0.00 , 1.00 , 2.00
1088 /
1089 @end smallexample
1090
1091 @node X format descriptor without count field
1092 @subsection @code{X} format descriptor without count field
1093
1094 To support legacy codes, GNU Fortran permits the count field of the
1095 @code{X} edit descriptor in @code{FORMAT} statements to be omitted.
1096 When omitted, the count is implicitly assumed to be one.
1097
1098 @smallexample
1099        PRINT 10, 2, 3
1100 10     FORMAT (I1, X, I1)
1101 @end smallexample
1102
1103 @node Commas in FORMAT specifications
1104 @subsection Commas in @code{FORMAT} specifications
1105
1106 To support legacy codes, GNU Fortran allows the comma separator
1107 to be omitted immediately before and after character string edit
1108 descriptors in @code{FORMAT} statements.
1109
1110 @smallexample
1111        PRINT 10, 2, 3
1112 10     FORMAT ('FOO='I1' BAR='I2)
1113 @end smallexample
1114
1115
1116 @node Missing period in FORMAT specifications
1117 @subsection Missing period in @code{FORMAT} specifications
1118
1119 To support legacy codes, GNU Fortran allows missing periods in format
1120 specifications if and only if @option{-std=legacy} is given on the
1121 command line.  This is considered non-conforming code and is
1122 discouraged.
1123
1124 @smallexample
1125        REAL :: value
1126        READ(*,10) value
1127 10     FORMAT ('F4')
1128 @end smallexample
1129
1130 @node I/O item lists
1131 @subsection I/O item lists
1132 @cindex I/O item lists
1133
1134 To support legacy codes, GNU Fortran allows the input item list
1135 of the @code{READ} statement, and the output item lists of the
1136 @code{WRITE} and @code{PRINT} statements, to start with a comma.
1137
1138 @node BOZ literal constants
1139 @subsection BOZ literal constants
1140 @cindex BOZ literal constants
1141
1142 Besides decimal constants, Fortran also supports binary (@code{b}),
1143 octal (@code{o}) and hexadecimal (@code{z}) integer constants. The
1144 syntax is: @samp{prefix quote digits quote}, were the prefix is
1145 either @code{b}, @code{o} or @code{z}, quote is either @code{'} or
1146 @code{"} and the digits are for binary @code{0} or @code{1}, for
1147 octal between @code{0} and @code{7}, and for hexadecimal between
1148 @code{0} and @code{F}. (Example: @code{b'01011101'}.)
1149
1150 Up to Fortran 95, BOZ literals were only allowed to initialize
1151 integer variables in DATA statements. Since Fortran 2003 BOZ literals
1152 are also allowed as argument of @code{REAL}, @code{DBLE}, @code{INT}
1153 and @code{CMPLX}; the result is the same as if the integer BOZ
1154 literal had been converted by @code{TRANSFER} to, respectively,
1155 @code{real}, @code{double precision}, @code{integer} or @code{complex}.
1156 As GNU Fortran extension the intrinsic procedures @code{FLOAT},
1157 @code{DFLOAT}, @code{COMPLEX} and @code{DCMPLX} are treated alike.
1158
1159 As an extension, GNU Fortran allows hexadecimal BOZ literal constants to
1160 be specified using the @code{X} prefix, in addition to the standard
1161 @code{Z} prefix. The BOZ literal can also be specified by adding a
1162 suffix to the string, for example, @code{Z'ABC'} and @code{'ABC'Z} are
1163 equivalent.
1164
1165 Furthermore, GNU Fortran allows using BOZ literal constants outside
1166 DATA statements and the four intrinsic functions allowed by Fortran 2003.
1167 In DATA statements, in direct assignments, where the right-hand side
1168 only contains a BOZ literal constant, and for old-style initializers of
1169 the form @code{integer i /o'0173'/}, the constant is transferred
1170 as if @code{TRANSFER} had been used; for @code{COMPLEX} numbers, only
1171 the real part is initialized unless @code{CMPLX} is used. In all other
1172 cases, the BOZ literal constant is converted to an @code{INTEGER} value with
1173 the largest decimal representation.  This value is then converted
1174 numerically to the type and kind of the variable in question.
1175 (For instance @code{real :: r = b'0000001' + 1} initializes @code{r}
1176 with @code{2.0}.) As different compilers implement the extension
1177 differently, one should be careful when doing bitwise initialization
1178 of non-integer variables.
1179
1180 Note that initializing an @code{INTEGER} variable with a statement such
1181 as @code{DATA i/Z'FFFFFFFF'/} will give an integer overflow error rather
1182 than the desired result of @math{-1} when @code{i} is a 32-bit integer
1183 on a system that supports 64-bit integers.  The @samp{-fno-range-check}
1184 option can be used as a workaround for legacy code that initializes
1185 integers in this manner.
1186
1187 @node Real array indices
1188 @subsection Real array indices
1189 @cindex array, indices of type real
1190
1191 As an extension, GNU Fortran allows the use of @code{REAL} expressions
1192 or variables as array indices.
1193
1194 @node Unary operators
1195 @subsection Unary operators
1196 @cindex operators, unary
1197
1198 As an extension, GNU Fortran allows unary plus and unary minus operators
1199 to appear as the second operand of binary arithmetic operators without
1200 the need for parenthesis.
1201
1202 @smallexample
1203        X = Y * -Z
1204 @end smallexample
1205
1206 @node Implicitly convert LOGICAL and INTEGER values
1207 @subsection Implicitly convert @code{LOGICAL} and @code{INTEGER} values
1208 @cindex conversion, to integer
1209 @cindex conversion, to logical
1210
1211 As an extension for backwards compatibility with other compilers, GNU
1212 Fortran allows the implicit conversion of @code{LOGICAL} values to
1213 @code{INTEGER} values and vice versa.  When converting from a
1214 @code{LOGICAL} to an @code{INTEGER}, @code{.FALSE.} is interpreted as
1215 zero, and @code{.TRUE.} is interpreted as one.  When converting from
1216 @code{INTEGER} to @code{LOGICAL}, the value zero is interpreted as
1217 @code{.FALSE.} and any nonzero value is interpreted as @code{.TRUE.}.
1218
1219 @smallexample
1220         LOGICAL :: l
1221         l = 1
1222 @end smallexample
1223 @smallexample
1224         INTEGER :: i
1225         i = .TRUE.
1226 @end smallexample
1227
1228 However, there is no implicit conversion of @code{INTEGER} values in
1229 @code{if}-statements, nor of @code{LOGICAL} or @code{INTEGER} values
1230 in I/O operations.
1231
1232 @node Hollerith constants support
1233 @subsection Hollerith constants support
1234 @cindex Hollerith constants
1235
1236 GNU Fortran supports Hollerith constants in assignments, function
1237 arguments, and @code{DATA} and @code{ASSIGN} statements.  A Hollerith
1238 constant is written as a string of characters preceded by an integer
1239 constant indicating the character count, and the letter @code{H} or
1240 @code{h}, and stored in bytewise fashion in a numeric (@code{INTEGER},
1241 @code{REAL}, or @code{complex}) or @code{LOGICAL} variable.  The
1242 constant will be padded or truncated to fit the size of the variable in
1243 which it is stored.
1244
1245 Examples of valid uses of Hollerith constants:
1246 @smallexample
1247       complex*16 x(2)
1248       data x /16Habcdefghijklmnop, 16Hqrstuvwxyz012345/
1249       x(1) = 16HABCDEFGHIJKLMNOP
1250       call foo (4h abc)
1251 @end smallexample
1252
1253 Invalid Hollerith constants examples:
1254 @smallexample
1255       integer*4 a
1256       a = 8H12345678 ! Valid, but the Hollerith constant will be truncated.
1257       a = 0H         ! At least one character is needed.
1258 @end smallexample
1259
1260 In general, Hollerith constants were used to provide a rudimentary
1261 facility for handling character strings in early Fortran compilers,
1262 prior to the introduction of @code{CHARACTER} variables in Fortran 77;
1263 in those cases, the standard-compliant equivalent is to convert the
1264 program to use proper character strings.  On occasion, there may be a
1265 case where the intent is specifically to initialize a numeric variable
1266 with a given byte sequence.  In these cases, the same result can be
1267 obtained by using the @code{TRANSFER} statement, as in this example.
1268 @smallexample
1269       INTEGER(KIND=4) :: a
1270       a = TRANSFER ("abcd", a)     ! equivalent to: a = 4Habcd
1271 @end smallexample
1272
1273
1274 @node Cray pointers
1275 @subsection Cray pointers
1276 @cindex pointer, Cray
1277
1278 Cray pointers are part of a non-standard extension that provides a
1279 C-like pointer in Fortran.  This is accomplished through a pair of
1280 variables: an integer "pointer" that holds a memory address, and a
1281 "pointee" that is used to dereference the pointer.
1282
1283 Pointer/pointee pairs are declared in statements of the form:
1284 @smallexample
1285         pointer ( <pointer> , <pointee> )
1286 @end smallexample
1287 or,
1288 @smallexample
1289         pointer ( <pointer1> , <pointee1> ), ( <pointer2> , <pointee2> ), ...
1290 @end smallexample
1291 The pointer is an integer that is intended to hold a memory address.
1292 The pointee may be an array or scalar.  A pointee can be an assumed
1293 size array---that is, the last dimension may be left unspecified by
1294 using a @code{*} in place of a value---but a pointee cannot be an
1295 assumed shape array.  No space is allocated for the pointee.
1296
1297 The pointee may have its type declared before or after the pointer
1298 statement, and its array specification (if any) may be declared
1299 before, during, or after the pointer statement.  The pointer may be
1300 declared as an integer prior to the pointer statement.  However, some
1301 machines have default integer sizes that are different than the size
1302 of a pointer, and so the following code is not portable:
1303 @smallexample
1304         integer ipt
1305         pointer (ipt, iarr)
1306 @end smallexample
1307 If a pointer is declared with a kind that is too small, the compiler
1308 will issue a warning; the resulting binary will probably not work
1309 correctly, because the memory addresses stored in the pointers may be
1310 truncated.  It is safer to omit the first line of the above example;
1311 if explicit declaration of ipt's type is omitted, then the compiler
1312 will ensure that ipt is an integer variable large enough to hold a
1313 pointer.
1314
1315 Pointer arithmetic is valid with Cray pointers, but it is not the same
1316 as C pointer arithmetic.  Cray pointers are just ordinary integers, so
1317 the user is responsible for determining how many bytes to add to a
1318 pointer in order to increment it.  Consider the following example:
1319 @smallexample
1320         real target(10)
1321         real pointee(10)
1322         pointer (ipt, pointee)
1323         ipt = loc (target)
1324         ipt = ipt + 1       
1325 @end smallexample
1326 The last statement does not set @code{ipt} to the address of
1327 @code{target(1)}, as it would in C pointer arithmetic.  Adding @code{1}
1328 to @code{ipt} just adds one byte to the address stored in @code{ipt}.
1329
1330 Any expression involving the pointee will be translated to use the
1331 value stored in the pointer as the base address.
1332
1333 To get the address of elements, this extension provides an intrinsic
1334 function @code{LOC()}.  The @code{LOC()} function is equivalent to the
1335 @code{&} operator in C, except the address is cast to an integer type:
1336 @smallexample
1337         real ar(10)
1338         pointer(ipt, arpte(10))
1339         real arpte
1340         ipt = loc(ar)  ! Makes arpte is an alias for ar
1341         arpte(1) = 1.0 ! Sets ar(1) to 1.0
1342 @end smallexample
1343 The pointer can also be set by a call to the @code{MALLOC} intrinsic
1344 (see @ref{MALLOC}).
1345
1346 Cray pointees often are used to alias an existing variable.  For
1347 example:
1348 @smallexample
1349         integer target(10)
1350         integer iarr(10)
1351         pointer (ipt, iarr)
1352         ipt = loc(target)
1353 @end smallexample
1354 As long as @code{ipt} remains unchanged, @code{iarr} is now an alias for
1355 @code{target}. The optimizer, however, will not detect this aliasing, so
1356 it is unsafe to use @code{iarr} and @code{target} simultaneously.  Using
1357 a pointee in any way that violates the Fortran aliasing rules or
1358 assumptions is illegal. It is the user's responsibility to avoid doing
1359 this; the compiler works under the assumption that no such aliasing
1360 occurs.
1361
1362 Cray pointers will work correctly when there is no aliasing (i.e., when
1363 they are used to access a dynamically allocated block of memory), and
1364 also in any routine where a pointee is used, but any variable with which
1365 it shares storage is not used.  Code that violates these rules may not
1366 run as the user intends.  This is not a bug in the optimizer; any code
1367 that violates the aliasing rules is illegal.  (Note that this is not
1368 unique to GNU Fortran; any Fortran compiler that supports Cray pointers
1369 will ``incorrectly'' optimize code with illegal aliasing.)
1370
1371 There are a number of restrictions on the attributes that can be applied
1372 to Cray pointers and pointees.  Pointees may not have the
1373 @code{ALLOCATABLE}, @code{INTENT}, @code{OPTIONAL}, @code{DUMMY},
1374 @code{TARGET}, @code{INTRINSIC}, or @code{POINTER} attributes. Pointers
1375 may not have the @code{DIMENSION}, @code{POINTER}, @code{TARGET},
1376 @code{ALLOCATABLE}, @code{EXTERNAL}, or @code{INTRINSIC} attributes.
1377 Pointees may not occur in more than one pointer statement.  A pointee
1378 cannot be a pointer.  Pointees cannot occur in equivalence, common, or
1379 data statements.
1380
1381 A Cray pointer may also point to a function or a subroutine.  For
1382 example, the following excerpt is valid:
1383 @smallexample
1384   implicit none
1385   external sub
1386   pointer (subptr,subpte)
1387   external subpte
1388   subptr = loc(sub)
1389   call subpte()
1390   [...]
1391   subroutine sub
1392   [...]
1393   end subroutine sub
1394 @end smallexample
1395
1396 A pointer may be modified during the course of a program, and this
1397 will change the location to which the pointee refers.  However, when
1398 pointees are passed as arguments, they are treated as ordinary
1399 variables in the invoked function.  Subsequent changes to the pointer
1400 will not change the base address of the array that was passed.
1401
1402 @node CONVERT specifier
1403 @subsection @code{CONVERT} specifier
1404 @cindex @code{CONVERT} specifier
1405
1406 GNU Fortran allows the conversion of unformatted data between little-
1407 and big-endian representation to facilitate moving of data
1408 between different systems.  The conversion can be indicated with
1409 the @code{CONVERT} specifier on the @code{OPEN} statement.
1410 @xref{GFORTRAN_CONVERT_UNIT}, for an alternative way of specifying
1411 the data format via an environment variable.
1412
1413 Valid values for @code{CONVERT} are:
1414 @itemize @w{}
1415 @item @code{CONVERT='NATIVE'} Use the native format.  This is the default.
1416 @item @code{CONVERT='SWAP'} Swap between little- and big-endian.
1417 @item @code{CONVERT='LITTLE_ENDIAN'} Use the little-endian representation
1418 for unformatted files.
1419 @item @code{CONVERT='BIG_ENDIAN'} Use the big-endian representation for
1420 unformatted files.
1421 @end itemize
1422
1423 Using the option could look like this:
1424 @smallexample
1425   open(file='big.dat',form='unformatted',access='sequential', &
1426        convert='big_endian')
1427 @end smallexample
1428
1429 The value of the conversion can be queried by using
1430 @code{INQUIRE(CONVERT=ch)}.  The values returned are
1431 @code{'BIG_ENDIAN'} and @code{'LITTLE_ENDIAN'}.
1432
1433 @code{CONVERT} works between big- and little-endian for
1434 @code{INTEGER} values of all supported kinds and for @code{REAL}
1435 on IEEE systems of kinds 4 and 8.  Conversion between different
1436 ``extended double'' types on different architectures such as
1437 m68k and x86_64, which GNU Fortran
1438 supports as @code{REAL(KIND=10)} and @code{REAL(KIND=16)}, will
1439 probably not work.
1440
1441 @emph{Note that the values specified via the GFORTRAN_CONVERT_UNIT
1442 environment variable will override the CONVERT specifier in the
1443 open statement}.  This is to give control over data formats to
1444 users who do not have the source code of their program available.
1445
1446 Using anything but the native representation for unformatted data
1447 carries a significant speed overhead.  If speed in this area matters
1448 to you, it is best if you use this only for data that needs to be
1449 portable.
1450
1451 @node OpenMP
1452 @subsection OpenMP
1453 @cindex OpenMP
1454
1455 OpenMP (Open Multi-Processing) is an application programming
1456 interface (API) that supports multi-platform shared memory 
1457 multiprocessing programming in C/C++ and Fortran on many 
1458 architectures, including Unix and Microsoft Windows platforms.
1459 It consists of a set of compiler directives, library routines,
1460 and environment variables that influence run-time behavior.
1461
1462 GNU Fortran strives to be compatible to the 
1463 @uref{http://www.openmp.org/drupal/mp-documents/spec25.pdf,
1464 OpenMP Application Program Interface v2.5}.
1465
1466 To enable the processing of the OpenMP directive @code{!$omp} in
1467 free-form source code; the @code{c$omp}, @code{*$omp} and @code{!$omp}
1468 directives in fixed form; the @code{!$} conditional compilation sentinels
1469 in free form; and the @code{c$}, @code{*$} and @code{!$} sentinels
1470 in fixed form, @command{gfortran} needs to be invoked with the
1471 @option{-fopenmp}. This also arranges for automatic linking of the
1472 GNU OpenMP runtime library @ref{Top,,libgomp,libgomp,GNU OpenMP
1473 runtime library}.
1474
1475 The OpenMP Fortran runtime library routines are provided both in a
1476 form of a Fortran 90 module named @code{omp_lib} and in a form of
1477 a Fortran @code{include} file named @file{omp_lib.h}.
1478
1479 An example of a parallelized loop taken from Appendix A.1 of
1480 the OpenMP Application Program Interface v2.5:
1481 @smallexample
1482 SUBROUTINE A1(N, A, B)
1483   INTEGER I, N
1484   REAL B(N), A(N)
1485 !$OMP PARALLEL DO !I is private by default
1486   DO I=2,N
1487     B(I) = (A(I) + A(I-1)) / 2.0
1488   ENDDO
1489 !$OMP END PARALLEL DO
1490 END SUBROUTINE A1
1491 @end smallexample
1492
1493 Please note:
1494 @itemize
1495 @item
1496 @option{-fopenmp} implies @option{-frecursive}, i.e., all local arrays
1497 will be allocated on the stack. When porting existing code to OpenMP,
1498 this may lead to surprising results, especially to segmentation faults
1499 if the stacksize is limited.
1500
1501 @item
1502 On glibc-based systems, OpenMP enabled applications can not be statically
1503 linked due to limitations of the underlying pthreads-implementation. It
1504 might be possible to get a working solution if 
1505 @command{-Wl,--whole-archive -lpthread -Wl,--no-whole-archive} is added
1506 to the command line. However, this is not supported by @command{gcc} and
1507 thus not recommended.
1508 @end itemize
1509
1510 @node Argument list functions
1511 @subsection Argument list functions @code{%VAL}, @code{%REF} and @code{%LOC}
1512 @cindex argument list functions
1513 @cindex @code{%VAL}
1514 @cindex @code{%REF}
1515 @cindex @code{%LOC}
1516
1517 GNU Fortran supports argument list functions @code{%VAL}, @code{%REF} 
1518 and @code{%LOC} statements, for backward compatibility with g77. 
1519 It is recommended that these should be used only for code that is 
1520 accessing facilities outside of GNU Fortran, such as operating system 
1521 or windowing facilities. It is best to constrain such uses to isolated 
1522 portions of a program--portions that deal specifically and exclusively 
1523 with low-level, system-dependent facilities. Such portions might well 
1524 provide a portable interface for use by the program as a whole, but are 
1525 themselves not portable, and should be thoroughly tested each time they 
1526 are rebuilt using a new compiler or version of a compiler.
1527
1528 @code{%VAL} passes a scalar argument by value, @code{%REF} passes it by 
1529 reference and @code{%LOC} passes its memory location.  Since gfortran 
1530 already passes scalar arguments by reference, @code{%REF} is in effect 
1531 a do-nothing.  @code{%LOC} has the same effect as a fortran pointer.
1532
1533 An example of passing an argument by value to a C subroutine foo.:
1534 @smallexample
1535 C
1536 C prototype      void foo_ (float x);
1537 C
1538       external foo
1539       real*4 x
1540       x = 3.14159
1541       call foo (%VAL (x))
1542       end
1543 @end smallexample
1544
1545 For details refer to the g77 manual
1546 @uref{http://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/index.html#Top}.
1547
1548 Also, the gfortran testsuite c_by_val.f and its partner c_by_val.c are
1549 worth a look.
1550
1551
1552
1553 @node Extensions not implemented in GNU Fortran
1554 @section Extensions not implemented in GNU Fortran
1555 @cindex extensions, not implemented
1556
1557 The long history of the Fortran language, its wide use and broad
1558 userbase, the large number of different compiler vendors and the lack of
1559 some features crucial to users in the first standards have lead to the
1560 existence of an important number of extensions to the language. While
1561 some of the most useful or popular extensions are supported by the GNU
1562 Fortran compiler, not all existing extensions are supported. This section
1563 aims at listing these extensions and offering advice on how best make
1564 code that uses them running with the GNU Fortran compiler.
1565
1566 @c More can be found here:
1567 @c   -- http://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/Missing-Features.html
1568 @c   -- the list of fortran and libgfortran bugs closed as WONTFIX:
1569 @c      http://tinyurl.com/2u4h5y
1570
1571 @menu
1572 * STRUCTURE and RECORD::
1573 @c * UNION and MAP::
1574 * ENCODE and DECODE statements::
1575 @c * Expressions in FORMAT statements::
1576 @c * Q edit descriptor::
1577 @c * AUTOMATIC statement::
1578 @c * TYPE and ACCEPT I/O Statements::
1579 @c * .XOR. operator::
1580 @c * CARRIAGECONTROL, DEFAULTFILE, DISPOSE and RECORDTYPE I/O specifiers::
1581 @c * Omitted arguments in procedure call:
1582 @end menu
1583
1584
1585 @node STRUCTURE and RECORD
1586 @subsection @code{STRUCTURE} and @code{RECORD}
1587 @cindex @code{STRUCTURE}
1588 @cindex @code{RECORD}
1589
1590 Structures are user-defined aggregate data types; this functionality was
1591 standardized in Fortran 90 with an different syntax, under the name of
1592 ``derived types''. Here is an example of code using the non portable
1593 structure syntax:
1594
1595 @example
1596 ! Declaring a structure named ``item'' and containing three fields:
1597 ! an integer ID, an description string and a floating-point price.
1598 STRUCTURE /item/
1599   INTEGER id
1600   CHARACTER(LEN=200) description
1601   REAL price
1602 END STRUCTURE
1603
1604 ! Define two variables, an single record of type ``item''
1605 ! named ``pear'', and an array of items named ``store_catalog''
1606 RECORD /item/ pear, store_catalog(100)
1607
1608 ! We can directly access the fields of both variables
1609 pear.id = 92316
1610 pear.description = "juicy D'Anjou pear"
1611 pear.price = 0.15
1612 store_catalog(7).id = 7831
1613 store_catalog(7).description = "milk bottle"
1614 store_catalog(7).price = 1.2
1615
1616 ! We can also manipulates the whole structure
1617 store_catalog(12) = pear
1618 print *, store_catalog(12)
1619 @end example
1620
1621 @noindent
1622 This code can easily be rewritten in the Fortran 90 syntax as following:
1623
1624 @example
1625 ! ``STRUCTURE /name/ ... END STRUCTURE'' becomes
1626 ! ``TYPE name ... END TYPE''
1627 TYPE item
1628   INTEGER id
1629   CHARACTER(LEN=200) description
1630   REAL price
1631 END TYPE
1632
1633 ! ``RECORD /name/ variable'' becomes ``TYPE(name) variable''
1634 TYPE(item) pear, store_catalog(100)
1635
1636 ! Instead of using a dot (.) to access fields of a record, the
1637 ! standard syntax uses a percent sign (%)
1638 pear%id = 92316
1639 pear%description = "juicy D'Anjou pear"
1640 pear%price = 0.15
1641 store_catalog(7)%id = 7831
1642 store_catalog(7)%description = "milk bottle"
1643 store_catalog(7)%price = 1.2
1644
1645 ! Assignments of a whole variable don't change
1646 store_catalog(12) = pear
1647 print *, store_catalog(12)
1648 @end example
1649
1650
1651 @c @node UNION and MAP
1652 @c @subsection @code{UNION} and @code{MAP}
1653 @c @cindex @code{UNION}
1654 @c @cindex @code{MAP}
1655 @c
1656 @c For help writing this one, see
1657 @c http://www.eng.umd.edu/~nsw/ench250/fortran1.htm#UNION and
1658 @c http://www.tacc.utexas.edu/services/userguides/pgi/pgiws_ug/pgi32u06.htm
1659
1660
1661 @node ENCODE and DECODE statements
1662 @subsection @code{ENCODE} and @code{DECODE} statements
1663 @cindex @code{ENCODE}
1664 @cindex @code{DECODE}
1665
1666 GNU Fortran doesn't support the @code{ENCODE} and @code{DECODE}
1667 statements.  These statements are best replaced by @code{READ} and
1668 @code{WRITE} statements involving internal files (@code{CHARACTER}
1669 variables and arrays), which have been part of the Fortran standard since
1670 Fortran 77. For example, replace a code fragment like
1671
1672 @smallexample
1673       INTEGER*1 LINE(80)
1674       REAL A, B, C
1675 c     ... Code that sets LINE
1676       DECODE (80, 9000, LINE) A, B, C
1677  9000 FORMAT (1X, 3(F10.5))
1678 @end smallexample
1679
1680 @noindent
1681 with the following:
1682
1683 @smallexample
1684       CHARACTER(LEN=80) LINE
1685       REAL A, B, C
1686 c     ... Code that sets LINE
1687       READ (UNIT=LINE, FMT=9000) A, B, C
1688  9000 FORMAT (1X, 3(F10.5))
1689 @end smallexample
1690
1691 Similarly, replace a code fragment like
1692
1693 @smallexample
1694       INTEGER*1 LINE(80)
1695       REAL A, B, C
1696 c     ... Code that sets A, B and C
1697       ENCODE (80, 9000, LINE) A, B, C
1698  9000 FORMAT (1X, 'OUTPUT IS ', 3(F10.5))
1699 @end smallexample
1700
1701 @noindent
1702 with the following:
1703
1704 @smallexample
1705       INTEGER*1 LINE(80)
1706       REAL A, B, C
1707 c     ... Code that sets A, B and C
1708       WRITE (UNIT=LINE, FMT=9000) A, B, C
1709  9000 FORMAT (1X, 'OUTPUT IS ', 3(F10.5))
1710 @end smallexample
1711
1712
1713 @c ---------------------------------------------------------------------
1714 @c Intrinsic Procedures
1715 @c ---------------------------------------------------------------------
1716
1717 @include intrinsic.texi
1718
1719
1720 @tex
1721 \blankpart
1722 @end tex
1723
1724 @c ---------------------------------------------------------------------
1725 @c Contributing
1726 @c ---------------------------------------------------------------------
1727
1728 @node Contributing
1729 @unnumbered Contributing
1730 @cindex Contributing
1731
1732 Free software is only possible if people contribute to efforts
1733 to create it.
1734 We're always in need of more people helping out with ideas
1735 and comments, writing documentation and contributing code.
1736
1737 If you want to contribute to GNU Fortran,
1738 have a look at the long lists of projects you can take on.
1739 Some of these projects are small,
1740 some of them are large;
1741 some are completely orthogonal to the rest of what is
1742 happening on GNU Fortran,
1743 but others are ``mainstream'' projects in need of enthusiastic hackers.
1744 All of these projects are important!
1745 We'll eventually get around to the things here,
1746 but they are also things doable by someone who is willing and able.
1747
1748 @menu
1749 * Contributors::
1750 * Projects::
1751 * Proposed Extensions::
1752 @end menu
1753
1754
1755 @node Contributors
1756 @section Contributors to GNU Fortran
1757 @cindex Contributors
1758 @cindex Credits
1759 @cindex Authors
1760
1761 Most of the parser was hand-crafted by @emph{Andy Vaught}, who is
1762 also the initiator of the whole project.  Thanks Andy!
1763 Most of the interface with GCC was written by @emph{Paul Brook}.
1764
1765 The following individuals have contributed code and/or
1766 ideas and significant help to the GNU Fortran project
1767 (in alphabetical order):
1768
1769 @itemize @minus
1770 @item Janne Blomqvist
1771 @item Steven Bosscher
1772 @item Paul Brook
1773 @item Tobias Burnus
1774 @item Fran@,{c}ois-Xavier Coudert
1775 @item Bud Davis
1776 @item Jerry DeLisle
1777 @item Erik Edelmann
1778 @item Bernhard Fischer
1779 @item Daniel Franke
1780 @item Richard Guenther
1781 @item Richard Henderson
1782 @item Katherine Holcomb
1783 @item Jakub Jelinek
1784 @item Niels Kristian Bech Jensen
1785 @item Steven Johnson
1786 @item Steven G. Kargl
1787 @item Thomas Koenig
1788 @item Asher Langton
1789 @item H. J. Lu
1790 @item Toon Moene
1791 @item Brooks Moses
1792 @item Andrew Pinski
1793 @item Tim Prince
1794 @item Christopher D. Rickett
1795 @item Richard Sandiford
1796 @item Tobias Schl@"uter
1797 @item Roger Sayle
1798 @item Paul Thomas
1799 @item Andy Vaught
1800 @item Feng Wang
1801 @item Janus Weil
1802 @end itemize
1803
1804 The following people have contributed bug reports,
1805 smaller or larger patches,
1806 and much needed feedback and encouragement for the
1807 GNU Fortran project: 
1808
1809 @itemize @minus
1810 @item Bill Clodius
1811 @item Dominique d'Humi@`eres
1812 @item Kate Hedstrom
1813 @item Erik Schnetter
1814 @end itemize
1815
1816 Many other individuals have helped debug,
1817 test and improve the GNU Fortran compiler over the past few years,
1818 and we welcome you to do the same!
1819 If you already have done so,
1820 and you would like to see your name listed in the
1821 list above, please contact us.
1822
1823
1824 @node Projects
1825 @section Projects
1826
1827 @table @emph
1828
1829 @item Help build the test suite
1830 Solicit more code for donation to the test suite: the more extensive the
1831 testsuite, the smaller the risk of breaking things in the future! We can
1832 keep code private on request.
1833
1834 @item Bug hunting/squishing
1835 Find bugs and write more test cases! Test cases are especially very
1836 welcome, because it allows us to concentrate on fixing bugs instead of
1837 isolating them. Going through the bugzilla database at
1838 @url{http://gcc.gnu.org/bugzilla/} to reduce testcases posted there and
1839 add more information (for example, for which version does the testcase
1840 work, for which versions does it fail?) is also very helpful.
1841
1842 @end table
1843
1844
1845 @node Proposed Extensions
1846 @section Proposed Extensions
1847
1848 Here's a list of proposed extensions for the GNU Fortran compiler, in no particular
1849 order.  Most of these are necessary to be fully compatible with
1850 existing Fortran compilers, but they are not part of the official
1851 J3 Fortran 95 standard.
1852
1853 @subsection Compiler extensions: 
1854 @itemize @bullet
1855 @item
1856 User-specified alignment rules for structures.
1857
1858 @item
1859 Flag to generate @code{Makefile} info.
1860
1861 @item
1862 Automatically extend single precision constants to double.
1863
1864 @item
1865 Compile code that conserves memory by dynamically allocating common and
1866 module storage either on stack or heap.
1867
1868 @item
1869 Compile flag to generate code for array conformance checking (suggest -CC).
1870
1871 @item
1872 User control of symbol names (underscores, etc).
1873
1874 @item
1875 Compile setting for maximum size of stack frame size before spilling
1876 parts to static or heap.
1877
1878 @item
1879 Flag to force local variables into static space.
1880
1881 @item
1882 Flag to force local variables onto stack.
1883 @end itemize
1884
1885
1886 @subsection Environment Options
1887 @itemize @bullet
1888 @item
1889 Pluggable library modules for random numbers, linear algebra.
1890 LA should use BLAS calling conventions.
1891
1892 @item
1893 Environment variables controlling actions on arithmetic exceptions like
1894 overflow, underflow, precision loss---Generate NaN, abort, default.
1895 action.
1896
1897 @item
1898 Set precision for fp units that support it (i387).
1899
1900 @item
1901 Variable for setting fp rounding mode.
1902
1903 @item
1904 Variable to fill uninitialized variables with a user-defined bit
1905 pattern.
1906
1907 @item
1908 Environment variable controlling filename that is opened for that unit
1909 number.
1910
1911 @item
1912 Environment variable to clear/trash memory being freed.
1913
1914 @item
1915 Environment variable to control tracing of allocations and frees.
1916
1917 @item
1918 Environment variable to display allocated memory at normal program end.
1919
1920 @item
1921 Environment variable for filename for * IO-unit.
1922
1923 @item
1924 Environment variable for temporary file directory.
1925
1926 @item
1927 Environment variable forcing standard output to be line buffered (unix).
1928
1929 @end itemize
1930
1931
1932 @c ---------------------------------------------------------------------
1933 @c GNU General Public License
1934 @c ---------------------------------------------------------------------
1935
1936 @include gpl_v3.texi
1937
1938
1939
1940 @c ---------------------------------------------------------------------
1941 @c GNU Free Documentation License
1942 @c ---------------------------------------------------------------------
1943
1944 @include fdl.texi
1945
1946
1947
1948 @c ---------------------------------------------------------------------
1949 @c Funding Free Software
1950 @c ---------------------------------------------------------------------
1951
1952 @include funding.texi
1953
1954 @c ---------------------------------------------------------------------
1955 @c Indices
1956 @c ---------------------------------------------------------------------
1957
1958 @node Option Index
1959 @unnumbered Option Index
1960 @command{gfortran}'s command line options are indexed here without any
1961 initial @samp{-} or @samp{--}. Where an option has both positive and
1962 negative forms (such as -foption and -fno-option), relevant entries in
1963 the manual are indexed under the most appropriate form; it may sometimes
1964 be useful to look up both forms.
1965 @printindex op
1966
1967 @node Keyword Index
1968 @unnumbered Keyword Index
1969 @printindex cp
1970
1971 @bye