OSDN Git Service

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