OSDN Git Service

texinfo fixes suggested by Ralf Wildenhues
[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, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
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.3 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::      User-visible implementation details.
185 * Mixed-Language Programming::    Interoperability with C
186 * Extensions::           Language extensions implemented by GNU Fortran.
187 * Intrinsic Procedures:: Intrinsic procedures supported by GNU Fortran.
188 * Intrinsic Modules::    Intrinsic modules supported by GNU Fortran.
189
190 * Contributing::         How you can help.
191 * Copying::              GNU General Public License says
192                          how you can copy and share GNU Fortran.
193 * GNU Free Documentation License::
194                          How you can copy and share this manual.
195 * Funding::              How to help assure continued work for free software.
196 * Option Index::         Index of command line options
197 * Keyword Index::        Index of concepts
198 @end menu
199 @end ifnottex
200
201 @c ---------------------------------------------------------------------
202 @c Introduction
203 @c ---------------------------------------------------------------------
204
205 @node Introduction
206 @chapter Introduction
207
208 @c The following duplicates the text on the TexInfo table of contents.
209 @iftex
210 This manual documents the use of @command{gfortran}, the GNU Fortran
211 compiler.  You can find in this manual how to invoke @command{gfortran},
212 as well as its features and incompatibilities.
213
214 @ifset DEVELOPMENT
215 @emph{Warning:} This document, and the compiler it describes, are still
216 under development.  While efforts are made to keep it up-to-date, it
217 might not accurately reflect the status of the most recent GNU Fortran
218 compiler.
219 @end ifset
220 @end iftex
221
222 The GNU Fortran compiler front end was
223 designed initially as a free replacement for,
224 or alternative to, the unix @command{f95} command;
225 @command{gfortran} is the command you'll use to invoke the compiler.
226
227 @menu
228 * About GNU Fortran::    What you should know about the GNU Fortran compiler.
229 * GNU Fortran and GCC::  You can compile Fortran, C, or other programs.
230 * Preprocessing and conditional compilation:: The Fortran preprocessor
231 * GNU Fortran and G77::  Why we chose to start from scratch.
232 * Project Status::       Status of GNU Fortran, roadmap, proposed extensions.
233 * Standards::            Standards supported by GNU Fortran.
234 @end menu
235
236
237 @c ---------------------------------------------------------------------
238 @c About GNU Fortran
239 @c ---------------------------------------------------------------------
240
241 @node About GNU Fortran
242 @section About GNU Fortran
243
244 The GNU Fortran compiler supports the Fortran 77, 90 and 95 standards
245 completely, parts of the Fortran 2003 and Fortran 2008 standards, and
246 several vendor extensions.  The development goal is to provide the
247 following features:
248
249 @itemize @bullet
250 @item
251 Read a user's program,
252 stored in a file and containing instructions written
253 in Fortran 77, Fortran 90, Fortran 95, Fortran 2003 or Fortran 2008.
254 This file contains @dfn{source code}.
255
256 @item
257 Translate the user's program into instructions a computer
258 can carry out more quickly than it takes to translate the
259 instructions in the first
260 place.  The result after compilation of a program is
261 @dfn{machine code},
262 code designed to be efficiently translated and processed
263 by a machine such as your computer.
264 Humans usually aren't as good writing machine code
265 as they are at writing Fortran (or C++, Ada, or Java),
266 because it is easy to make tiny mistakes writing machine code.
267
268 @item
269 Provide the user with information about the reasons why
270 the compiler is unable to create a binary from the source code.
271 Usually this will be the case if the source code is flawed.
272 The Fortran 90 standard requires that the compiler can point out
273 mistakes to the user.
274 An incorrect usage of the language causes an @dfn{error message}.
275
276 The compiler will also attempt to diagnose cases where the
277 user's program contains a correct usage of the language,
278 but instructs the computer to do something questionable.
279 This kind of diagnostics message is called a @dfn{warning message}.
280
281 @item
282 Provide optional information about the translation passes
283 from the source code to machine code.
284 This can help a user of the compiler to find the cause of
285 certain bugs which may not be obvious in the source code,
286 but may be more easily found at a lower level compiler output.
287 It also helps developers to find bugs in the compiler itself.
288
289 @item
290 Provide information in the generated machine code that can
291 make it easier to find bugs in the program (using a debugging tool,
292 called a @dfn{debugger}, such as the GNU Debugger @command{gdb}). 
293
294 @item
295 Locate and gather machine code already generated to
296 perform actions requested by statements in the user's program.
297 This machine code is organized into @dfn{modules} and is located
298 and @dfn{linked} to the user program. 
299 @end itemize
300
301 The GNU Fortran compiler consists of several components:
302
303 @itemize @bullet
304 @item
305 A version of the @command{gcc} command
306 (which also might be installed as the system's @command{cc} command)
307 that also understands and accepts Fortran source code.
308 The @command{gcc} command is the @dfn{driver} program for
309 all the languages in the GNU Compiler Collection (GCC);
310 With @command{gcc},
311 you can compile the source code of any language for
312 which a front end is available in GCC.
313
314 @item
315 The @command{gfortran} command itself,
316 which also might be installed as the
317 system's @command{f95} command.
318 @command{gfortran} is just another driver program,
319 but specifically for the Fortran compiler only.
320 The difference with @command{gcc} is that @command{gfortran}
321 will automatically link the correct libraries to your program.
322
323 @item
324 A collection of run-time libraries.
325 These libraries contain the machine code needed to support
326 capabilities of the Fortran language that are not directly
327 provided by the machine code generated by the
328 @command{gfortran} compilation phase,
329 such as intrinsic functions and subroutines,
330 and routines for interaction with files and the operating system.
331 @c and mechanisms to spawn,
332 @c unleash and pause threads in parallelized code.
333
334 @item
335 The Fortran compiler itself, (@command{f951}).
336 This is the GNU Fortran parser and code generator,
337 linked to and interfaced with the GCC backend library.
338 @command{f951} ``translates'' the source code to
339 assembler code.  You would typically not use this
340 program directly;
341 instead, the @command{gcc} or @command{gfortran} driver
342 programs will call it for you.
343 @end itemize
344
345
346 @c ---------------------------------------------------------------------
347 @c GNU Fortran and GCC
348 @c ---------------------------------------------------------------------
349
350 @node GNU Fortran and GCC
351 @section GNU Fortran and GCC
352 @cindex GNU Compiler Collection
353 @cindex GCC
354
355 GNU Fortran is a part of GCC, the @dfn{GNU Compiler Collection}.  GCC
356 consists of a collection of front ends for various languages, which
357 translate the source code into a language-independent form called
358 @dfn{GENERIC}.  This is then processed by a common middle end which
359 provides optimization, and then passed to one of a collection of back
360 ends which generate code for different computer architectures and
361 operating systems.
362
363 Functionally, this is implemented with a driver program (@command{gcc})
364 which provides the command-line interface for the compiler.  It calls
365 the relevant compiler front-end program (e.g., @command{f951} for
366 Fortran) for each file in the source code, and then calls the assembler
367 and linker as appropriate to produce the compiled output.  In a copy of
368 GCC which has been compiled with Fortran language support enabled,
369 @command{gcc} will recognize files with @file{.f}, @file{.for}, @file{.ftn},
370 @file{.f90}, @file{.f95}, @file{.f03} and @file{.f08} extensions as
371 Fortran source code, and compile it accordingly.  A @command{gfortran}
372 driver program is also provided, which is identical to @command{gcc}
373 except that it automatically links the Fortran runtime libraries into the
374 compiled program.
375
376 Source files with @file{.f}, @file{.for}, @file{.fpp}, @file{.ftn}, @file{.F},
377 @file{.FOR}, @file{.FPP}, and @file{.FTN} extensions are treated as fixed form.
378 Source files with @file{.f90}, @file{.f95}, @file{.f03}, @file{.f08},
379 @file{.F90}, @file{.F95}, @file{.F03} and @file{.F08} extensions are
380 treated as free form.  The capitalized versions of either form are run
381 through preprocessing.  Source files with the lower case @file{.fpp}
382 extension are also run through preprocessing.
383
384 This manual specifically documents the Fortran front end, which handles
385 the programming language's syntax and semantics.  The aspects of GCC
386 which relate to the optimization passes and the back-end code generation
387 are documented in the GCC manual; see 
388 @ref{Top,,Introduction,gcc,Using the GNU Compiler Collection (GCC)}.
389 The two manuals together provide a complete reference for the GNU
390 Fortran compiler.
391
392
393 @c ---------------------------------------------------------------------
394 @c Preprocessing and conditional compilation
395 @c ---------------------------------------------------------------------
396
397 @node Preprocessing and conditional compilation
398 @section Preprocessing and conditional compilation
399 @cindex CPP
400 @cindex FPP
401 @cindex Conditional compilation
402 @cindex Preprocessing
403 @cindex preprocessor, include file handling
404
405 Many Fortran compilers including GNU Fortran allow passing the source code
406 through a C preprocessor (CPP; sometimes also called the Fortran preprocessor,
407 FPP) to allow for conditional compilation.  In the case of GNU Fortran,
408 this is the GNU C Preprocessor in the traditional mode.  On systems with
409 case-preserving file names, the preprocessor is automatically invoked if the
410 filename extension is @file{.F}, @file{.FOR}, @file{.FTN}, @file{.fpp},
411 @file{.FPP}, @file{.F90}, @file{.F95}, @file{.F03} or @file{.F08}.  To manually
412 invoke the preprocessor on any file, use @option{-cpp}, to disable
413 preprocessing on files where the preprocessor is run automatically, use
414 @option{-nocpp}.
415
416 If a preprocessed file includes another file with the Fortran @code{INCLUDE}
417 statement, the included file is not preprocessed.  To preprocess included
418 files, use the equivalent preprocessor statement @code{#include}.
419
420 If GNU Fortran invokes the preprocessor, @code{__GFORTRAN__}
421 is defined and @code{__GNUC__}, @code{__GNUC_MINOR__} and
422 @code{__GNUC_PATCHLEVEL__} can be used to determine the version of the
423 compiler.  See @ref{Top,,Overview,cpp,The C Preprocessor} for details.
424
425 While CPP is the de-facto standard for preprocessing Fortran code,
426 Part 3 of the Fortran 95 standard (ISO/IEC 1539-3:1998) defines
427 Conditional Compilation, which is not widely used and not directly
428 supported by the GNU Fortran compiler.  You can use the program coco
429 to preprocess such files (@uref{http://www.daniellnagle.com/coco.html}).
430
431
432 @c ---------------------------------------------------------------------
433 @c GNU Fortran and G77
434 @c ---------------------------------------------------------------------
435
436 @node GNU Fortran and G77
437 @section GNU Fortran and G77
438 @cindex Fortran 77
439 @cindex @command{g77}
440
441 The GNU Fortran compiler is the successor to @command{g77}, the Fortran 
442 77 front end included in GCC prior to version 4.  It is an entirely new 
443 program that has been designed to provide Fortran 95 support and 
444 extensibility for future Fortran language standards, as well as providing 
445 backwards compatibility for Fortran 77 and nearly all of the GNU language 
446 extensions supported by @command{g77}.
447
448
449 @c ---------------------------------------------------------------------
450 @c Project Status
451 @c ---------------------------------------------------------------------
452
453 @node Project Status
454 @section Project Status
455
456 @quotation
457 As soon as @command{gfortran} can parse all of the statements correctly,
458 it will be in the ``larva'' state.
459 When we generate code, the ``puppa'' state.
460 When @command{gfortran} is done,
461 we'll see if it will be a beautiful butterfly,
462 or just a big bug....
463
464 --Andy Vaught, April 2000
465 @end quotation
466
467 The start of the GNU Fortran 95 project was announced on
468 the GCC homepage in March 18, 2000
469 (even though Andy had already been working on it for a while,
470 of course).
471
472 The GNU Fortran compiler is able to compile nearly all
473 standard-compliant Fortran 95, Fortran 90, and Fortran 77 programs,
474 including a number of standard and non-standard extensions, and can be
475 used on real-world programs.  In particular, the supported extensions
476 include OpenMP, Cray-style pointers, and several Fortran 2003 and Fortran
477 2008 features, including TR 15581.  However, it is still under
478 development and has a few remaining rough edges.
479
480 At present, the GNU Fortran compiler passes the
481 @uref{http://www.fortran-2000.com/ArnaudRecipes/fcvs21_f95.html, 
482 NIST Fortran 77 Test Suite}, and produces acceptable results on the
483 @uref{http://www.netlib.org/lapack/faq.html#1.21, LAPACK Test Suite}.
484 It also provides respectable performance on 
485 the @uref{http://www.polyhedron.com/pb05.html, Polyhedron Fortran
486 compiler benchmarks} and the
487 @uref{http://www.llnl.gov/asci_benchmarks/asci/limited/lfk/README.html,
488 Livermore Fortran Kernels test}.  It has been used to compile a number of
489 large real-world programs, including
490 @uref{http://mysite.verizon.net/serveall/moene.pdf, the HIRLAM
491 weather-forecasting code} and
492 @uref{http://www.theochem.uwa.edu.au/tonto/, the Tonto quantum 
493 chemistry package}; see @url{http://gcc.gnu.org/@/wiki/@/GfortranApps} for an
494 extended list.
495
496 Among other things, the GNU Fortran compiler is intended as a replacement
497 for G77.  At this point, nearly all programs that could be compiled with
498 G77 can be compiled with GNU Fortran, although there are a few minor known
499 regressions.
500
501 The primary work remaining to be done on GNU Fortran falls into three
502 categories: bug fixing (primarily regarding the treatment of invalid code
503 and providing useful error messages), improving the compiler optimizations
504 and the performance of compiled code, and extending the compiler to support
505 future standards---in particular, Fortran 2003 and Fortran 2008.
506
507
508 @c ---------------------------------------------------------------------
509 @c Standards
510 @c ---------------------------------------------------------------------
511
512 @node Standards
513 @section Standards
514 @cindex Standards
515
516 @menu
517 * Varying Length Character Strings::
518 @end menu
519
520 The GNU Fortran compiler implements
521 ISO/IEC 1539:1997 (Fortran 95).  As such, it can also compile essentially all
522 standard-compliant Fortran 90 and Fortran 77 programs.   It also supports
523 the ISO/IEC TR-15581 enhancements to allocatable arrays.
524
525 In the future, the GNU Fortran compiler will also support ISO/IEC
526 1539-1:2004 (Fortran 2003), ISO/IEC 1539-1:2010 (Fortran 2008) and
527 future Fortran standards.  Partial support of the Fortran 2003 and
528 Fortran 2008 standard is already provided; the current status of the
529 support is reported in the @ref{Fortran 2003 status} and
530 @ref{Fortran 2008 status} sections of the documentation.
531
532 Additionally, the GNU Fortran compilers supports the OpenMP specification
533 (version 3.0, @url{http://openmp.org/@/wp/@/openmp-specifications/}).
534
535 @node Varying Length Character Strings
536 @subsection Varying Length Character Strings
537 @cindex Varying length character strings
538 @cindex Varying length strings
539 @cindex strings, varying length
540
541 The Fortran 95 standard specifies in Part 2 (ISO/IEC 1539-2:2000)
542 varying length character strings.  While GNU Fortran currently does not
543 support such strings directly, there exist two Fortran implementations
544 for them, which work with GNU Fortran.  They can be found at
545 @uref{http://www.fortran.com/@/iso_varying_string.f95} and at
546 @uref{ftp://ftp.nag.co.uk/@/sc22wg5/@/ISO_VARYING_STRING/}.
547
548
549
550 @c =====================================================================
551 @c PART I: INVOCATION REFERENCE
552 @c =====================================================================
553
554 @tex
555 \part{I}{Invoking GNU Fortran}
556 @end tex
557
558 @c ---------------------------------------------------------------------
559 @c Compiler Options
560 @c ---------------------------------------------------------------------
561
562 @include invoke.texi
563
564
565 @c ---------------------------------------------------------------------
566 @c Runtime
567 @c ---------------------------------------------------------------------
568
569 @node Runtime
570 @chapter Runtime:  Influencing runtime behavior with environment variables
571 @cindex environment variable
572
573 The behavior of the @command{gfortran} can be influenced by
574 environment variables.
575
576 Malformed environment variables are silently ignored.
577
578 @menu
579 * GFORTRAN_STDIN_UNIT:: Unit number for standard input
580 * GFORTRAN_STDOUT_UNIT:: Unit number for standard output
581 * GFORTRAN_STDERR_UNIT:: Unit number for standard error
582 * GFORTRAN_USE_STDERR:: Send library output to standard error
583 * GFORTRAN_TMPDIR:: Directory for scratch files
584 * GFORTRAN_UNBUFFERED_ALL:: Don't buffer I/O for all units.
585 * GFORTRAN_UNBUFFERED_PRECONNECTED:: Don't buffer I/O for preconnected units.
586 * GFORTRAN_SHOW_LOCUS::  Show location for runtime errors
587 * GFORTRAN_OPTIONAL_PLUS:: Print leading + where permitted
588 * GFORTRAN_DEFAULT_RECL:: Default record length for new files
589 * GFORTRAN_LIST_SEPARATOR::  Separator for list output
590 * GFORTRAN_CONVERT_UNIT::  Set endianness for unformatted I/O
591 * GFORTRAN_ERROR_DUMPCORE:: Dump core on run-time errors
592 * GFORTRAN_ERROR_BACKTRACE:: Show backtrace on run-time errors
593 @end menu
594
595 @node GFORTRAN_STDIN_UNIT
596 @section @env{GFORTRAN_STDIN_UNIT}---Unit number for standard input
597
598 This environment variable can be used to select the unit number
599 preconnected to standard input.  This must be a positive integer.
600 The default value is 5.
601
602 @node GFORTRAN_STDOUT_UNIT
603 @section @env{GFORTRAN_STDOUT_UNIT}---Unit number for standard output
604
605 This environment variable can be used to select the unit number
606 preconnected to standard output.  This must be a positive integer.
607 The default value is 6.
608
609 @node GFORTRAN_STDERR_UNIT
610 @section @env{GFORTRAN_STDERR_UNIT}---Unit number for standard error
611
612 This environment variable can be used to select the unit number
613 preconnected to standard error.  This must be a positive integer.
614 The default value is 0.
615
616 @node GFORTRAN_USE_STDERR
617 @section @env{GFORTRAN_USE_STDERR}---Send library output to standard error
618
619 This environment variable controls where library output is sent.
620 If the first letter is @samp{y}, @samp{Y} or @samp{1}, standard
621 error is used.  If the first letter is @samp{n}, @samp{N} or
622 @samp{0}, standard output is used.
623
624 @node GFORTRAN_TMPDIR
625 @section @env{GFORTRAN_TMPDIR}---Directory for scratch files
626
627 This environment variable controls where scratch files are
628 created.  If this environment variable is missing,
629 GNU Fortran searches for the environment variable @env{TMP}, then @env{TEMP}.
630 If these are missing, the default is @file{/tmp}.
631
632 @node GFORTRAN_UNBUFFERED_ALL
633 @section @env{GFORTRAN_UNBUFFERED_ALL}---Don't buffer I/O on all units
634
635 This environment variable controls whether all I/O is unbuffered.  If
636 the first letter is @samp{y}, @samp{Y} or @samp{1}, all I/O is
637 unbuffered.  This will slow down small sequential reads and writes.  If
638 the first letter is @samp{n}, @samp{N} or @samp{0}, I/O is buffered.
639 This is the default.
640
641 @node GFORTRAN_UNBUFFERED_PRECONNECTED
642 @section @env{GFORTRAN_UNBUFFERED_PRECONNECTED}---Don't buffer I/O on preconnected units
643
644 The environment variable named @env{GFORTRAN_UNBUFFERED_PRECONNECTED} controls
645 whether I/O on a preconnected unit (i.e.@: STDOUT or STDERR) is unbuffered.  If 
646 the first letter is @samp{y}, @samp{Y} or @samp{1}, I/O is unbuffered.  This
647 will slow down small sequential reads and writes.  If the first letter
648 is @samp{n}, @samp{N} or @samp{0}, I/O is buffered.  This is the default.
649
650 @node GFORTRAN_SHOW_LOCUS
651 @section @env{GFORTRAN_SHOW_LOCUS}---Show location for runtime errors
652
653 If the first letter is @samp{y}, @samp{Y} or @samp{1}, filename and
654 line numbers for runtime errors are printed.  If the first letter is
655 @samp{n}, @samp{N} or @samp{0}, don't print filename and line numbers
656 for runtime errors.  The default is to print the location.
657
658 @node GFORTRAN_OPTIONAL_PLUS
659 @section @env{GFORTRAN_OPTIONAL_PLUS}---Print leading + where permitted
660
661 If the first letter is @samp{y}, @samp{Y} or @samp{1},
662 a plus sign is printed
663 where permitted by the Fortran standard.  If the first letter
664 is @samp{n}, @samp{N} or @samp{0}, a plus sign is not printed
665 in most cases.  Default is not to print plus signs.
666
667 @node GFORTRAN_DEFAULT_RECL
668 @section @env{GFORTRAN_DEFAULT_RECL}---Default record length for new files
669
670 This environment variable specifies the default record length, in
671 bytes, for files which are opened without a @code{RECL} tag in the
672 @code{OPEN} statement.  This must be a positive integer.  The
673 default value is 1073741824 bytes (1 GB).
674
675 @node GFORTRAN_LIST_SEPARATOR
676 @section @env{GFORTRAN_LIST_SEPARATOR}---Separator for list output
677
678 This environment variable specifies the separator when writing
679 list-directed output.  It may contain any number of spaces and
680 at most one comma.  If you specify this on the command line,
681 be sure to quote spaces, as in
682 @smallexample
683 $ GFORTRAN_LIST_SEPARATOR='  ,  ' ./a.out
684 @end smallexample
685 when @command{a.out} is the compiled Fortran program that you want to run.
686 Default is a single space.
687
688 @node GFORTRAN_CONVERT_UNIT
689 @section @env{GFORTRAN_CONVERT_UNIT}---Set endianness for unformatted I/O
690
691 By setting the @env{GFORTRAN_CONVERT_UNIT} variable, it is possible
692 to change the representation of data for unformatted files.
693 The syntax for the @env{GFORTRAN_CONVERT_UNIT} variable is:
694 @smallexample
695 GFORTRAN_CONVERT_UNIT: mode | mode ';' exception | exception ;
696 mode: 'native' | 'swap' | 'big_endian' | 'little_endian' ;
697 exception: mode ':' unit_list | unit_list ;
698 unit_list: unit_spec | unit_list unit_spec ;
699 unit_spec: INTEGER | INTEGER '-' INTEGER ;
700 @end smallexample
701 The variable consists of an optional default mode, followed by
702 a list of optional exceptions, which are separated by semicolons
703 from the preceding default and each other.  Each exception consists
704 of a format and a comma-separated list of units.  Valid values for
705 the modes are the same as for the @code{CONVERT} specifier:
706
707 @itemize @w{}
708 @item @code{NATIVE} Use the native format.  This is the default.
709 @item @code{SWAP} Swap between little- and big-endian.
710 @item @code{LITTLE_ENDIAN} Use the little-endian format
711 for unformatted files.
712 @item @code{BIG_ENDIAN} Use the big-endian format for unformatted files.
713 @end itemize
714 A missing mode for an exception is taken to mean @code{BIG_ENDIAN}.
715 Examples of values for @env{GFORTRAN_CONVERT_UNIT} are:
716 @itemize @w{}
717 @item @code{'big_endian'}  Do all unformatted I/O in big_endian mode.
718 @item @code{'little_endian;native:10-20,25'}  Do all unformatted I/O 
719 in little_endian mode, except for units 10 to 20 and 25, which are in
720 native format.
721 @item @code{'10-20'}  Units 10 to 20 are big-endian, the rest is native.
722 @end itemize
723
724 Setting the environment variables should be done on the command
725 line or via the @command{export}
726 command for @command{sh}-compatible shells and via @command{setenv}
727 for @command{csh}-compatible shells.
728
729 Example for @command{sh}:
730 @smallexample
731 $ gfortran foo.f90
732 $ GFORTRAN_CONVERT_UNIT='big_endian;native:10-20' ./a.out
733 @end smallexample
734
735 Example code for @command{csh}:
736 @smallexample
737 % gfortran foo.f90
738 % setenv GFORTRAN_CONVERT_UNIT 'big_endian;native:10-20'
739 % ./a.out
740 @end smallexample
741
742 Using anything but the native representation for unformatted data
743 carries a significant speed overhead.  If speed in this area matters
744 to you, it is best if you use this only for data that needs to be
745 portable.
746
747 @xref{CONVERT specifier}, for an alternative way to specify the
748 data representation for unformatted files.  @xref{Runtime Options}, for
749 setting a default data representation for the whole program.  The
750 @code{CONVERT} specifier overrides the @option{-fconvert} compile options.
751
752 @emph{Note that the values specified via the GFORTRAN_CONVERT_UNIT
753 environment variable will override the CONVERT specifier in the
754 open statement}.  This is to give control over data formats to
755 users who do not have the source code of their program available.
756
757 @node GFORTRAN_ERROR_DUMPCORE
758 @section @env{GFORTRAN_ERROR_DUMPCORE}---Dump core on run-time errors
759
760 If the @env{GFORTRAN_ERROR_DUMPCORE} variable is set to
761 @samp{y}, @samp{Y} or @samp{1} (only the first letter is relevant)
762 then library run-time errors cause core dumps.  To disable the core
763 dumps, set the variable to @samp{n}, @samp{N}, @samp{0}.  Default
764 is not to core dump unless the @option{-fdump-core} compile option
765 was used.
766
767 @node GFORTRAN_ERROR_BACKTRACE
768 @section @env{GFORTRAN_ERROR_BACKTRACE}---Show backtrace on run-time errors
769
770 If the @env{GFORTRAN_ERROR_BACKTRACE} variable is set to
771 @samp{y}, @samp{Y} or @samp{1} (only the first letter is relevant)
772 then a backtrace is printed when a run-time error occurs.
773 To disable the backtracing, set the variable to
774 @samp{n}, @samp{N}, @samp{0}.  Default is not to print a backtrace
775 unless the @option{-fbacktrace} compile option
776 was used.
777
778 @c =====================================================================
779 @c PART II: LANGUAGE REFERENCE
780 @c =====================================================================
781
782 @tex
783 \part{II}{Language Reference}
784 @end tex
785
786 @c ---------------------------------------------------------------------
787 @c Fortran 2003 and 2008 Status
788 @c ---------------------------------------------------------------------
789
790 @node Fortran 2003 and 2008 status
791 @chapter Fortran 2003 and 2008 Status
792
793 @menu
794 * Fortran 2003 status::
795 * Fortran 2008 status::
796 @end menu
797
798 @node Fortran 2003 status
799 @section Fortran 2003 status
800
801 GNU Fortran supports several Fortran 2003 features; an incomplete
802 list can be found below.  See also the
803 @uref{http://gcc.gnu.org/wiki/Fortran2003, wiki page} about Fortran 2003.
804
805 @itemize
806 @item Procedure pointers including procedure-pointer components with
807 @code{PASS} attribute.
808
809 @item Procedures which are bound to a derived type (type-bound procedures)
810 including @code{PASS}, @code{PROCEDURE} and @code{GENERIC}, and
811 operators bound to a type.
812
813 @item Abstract interfaces and and type extension with the possibility to
814 override type-bound procedures or to have deferred binding.
815
816 @item Polymorphic entities (``@code{CLASS}'') for derived types -- including
817 @code{SAME_TYPE_AS}, @code{EXTENDS_TYPE_OF} and @code{SELECT TYPE}.
818 Note that the support for array-valued polymorphic entities is incomplete
819 and unlimited polymophism is currently not supported.
820
821 @item The @code{ASSOCIATE} construct.
822
823 @item Interoperability with C including enumerations, 
824
825 @item In structure constructors the components with default values may be
826 omitted.
827
828 @item Extensions to the @code{ALLOCATE} statement, allowing for a
829 type-specification with type parameter and for allocation and initialization
830 from a @code{SOURCE=} expression; @code{ALLOCATE} and @code{DEALLOCATE}
831 optionally return an error message string via @code{ERRMSG=}.
832
833 @item Reallocation on assignment: If an intrinsic assignment is
834 used, an allocatable variable on the left-hand side is automatically allocated
835 (if unallocated) or reallocated (if the shape is different). Currently, scalar
836 deferred character length left-hand sides are correctly handled but arrays
837 are not yet fully implemented.
838
839 @item Transferring of allocations via @code{MOVE_ALLOC}.
840
841 @item The @code{PRIVATE} and @code{PUBLIC} attributes may be given individually
842 to derived-type components.
843
844 @item In pointer assignments, the lower bound may be specified and
845 the remapping of elements is supported.
846
847 @item For pointers an @code{INTENT} may be specified which affect the
848 association status not the value of the pointer target.
849
850 @item Intrinsics @code{command_argument_count}, @code{get_command},
851 @code{get_command_argument}, and @code{get_environment_variable}.
852
853 @item Support for unicode characters (ISO 10646) and UTF-8, including
854 the @code{SELECTED_CHAR_KIND} and @code{NEW_LINE} intrinsic functions.
855
856 @item Support for binary, octal and hexadecimal (BOZ) constants in the
857 intrinsic functions @code{INT}, @code{REAL}, @code{CMPLX} and @code{DBLE}.
858
859 @item Support for namelist variables with allocatable and pointer
860 attribute and nonconstant length type parameter.
861
862 @item
863 @cindex array, constructors
864 @cindex @code{[...]}
865 Array constructors using square brackets.  That is, @code{[...]} rather
866 than @code{(/.../)}.  Type-specification for array constructors like
867 @code{(/ some-type :: ... /)}.
868
869 @item Extensions to the specification and initialization expressions,
870 including the support for intrinsics with real and complex arguments.
871
872 @item Support for the asynchronous input/output syntax; however, the
873 data transfer is currently always synchronously performed. 
874
875 @item
876 @cindex @code{FLUSH} statement
877 @cindex statement, @code{FLUSH}
878 @code{FLUSH} statement.
879
880 @item
881 @cindex @code{IOMSG=} specifier
882 @code{IOMSG=} specifier for I/O statements.
883
884 @item
885 @cindex @code{ENUM} statement
886 @cindex @code{ENUMERATOR} statement
887 @cindex statement, @code{ENUM}
888 @cindex statement, @code{ENUMERATOR}
889 @opindex @code{fshort-enums}
890 Support for the declaration of enumeration constants via the
891 @code{ENUM} and @code{ENUMERATOR} statements.  Interoperability with
892 @command{gcc} is guaranteed also for the case where the
893 @command{-fshort-enums} command line option is given.
894
895 @item
896 @cindex TR 15581
897 TR 15581:
898 @itemize
899 @item
900 @cindex @code{ALLOCATABLE} dummy arguments
901 @code{ALLOCATABLE} dummy arguments.
902 @item
903 @cindex @code{ALLOCATABLE} function results
904 @code{ALLOCATABLE} function results
905 @item
906 @cindex @code{ALLOCATABLE} components of derived types
907 @code{ALLOCATABLE} components of derived types
908 @end itemize
909
910 @item
911 @cindex @code{STREAM} I/O
912 @cindex @code{ACCESS='STREAM'} I/O
913 The @code{OPEN} statement supports the @code{ACCESS='STREAM'} specifier,
914 allowing I/O without any record structure.
915
916 @item
917 Namelist input/output for internal files.
918
919 @item Further I/O extensions: Rounding during formatted output, using of
920 a decimal comma instead of a decimal point, setting whether a plus sign
921 should appear for positive numbers.
922
923 @item
924 @cindex @code{PROTECTED} statement
925 @cindex statement, @code{PROTECTED}
926 The @code{PROTECTED} statement and attribute.
927
928 @item
929 @cindex @code{VALUE} statement
930 @cindex statement, @code{VALUE}
931 The @code{VALUE} statement and attribute.
932
933 @item
934 @cindex @code{VOLATILE} statement
935 @cindex statement, @code{VOLATILE}
936 The @code{VOLATILE} statement and attribute.
937
938 @item
939 @cindex @code{IMPORT} statement
940 @cindex statement, @code{IMPORT}
941 The @code{IMPORT} statement, allowing to import
942 host-associated derived types.
943
944 @item The intrinsic modules @code{ISO_FORTRAN_ENVIRONMENT} is supported,
945 which contains parameters of the I/O units, storage sizes. Additionally,
946 procedures for C interoperability are available in the @code{ISO_C_BINDING}
947 module.
948
949 @item
950 @cindex @code{USE, INTRINSIC} statement
951 @cindex statement, @code{USE, INTRINSIC}
952 @cindex @code{ISO_FORTRAN_ENV} statement
953 @cindex statement, @code{ISO_FORTRAN_ENV}
954 @code{USE} statement with @code{INTRINSIC} and @code{NON_INTRINSIC}
955 attribute; supported intrinsic modules: @code{ISO_FORTRAN_ENV},
956 @code{ISO_C_BINDING}, @code{OMP_LIB} and @code{OMP_LIB_KINDS}.
957
958 @item
959 Renaming of operators in the @code{USE} statement.
960
961 @end itemize
962
963
964 @node Fortran 2008 status
965 @section Fortran 2008 status
966
967 The latest version of the Fortran standard is ISO/IEC 1539-1:2010, informally
968 known as Fortran 2008.  The official version is available from International
969 Organization for Standardization (ISO) or its national member organizations.
970 The the final draft (FDIS) can be downloaded free of charge from
971 @url{http://www.nag.co.uk/@/sc22wg5/@/links.html}.  Fortran is developed by the
972 Working Group 5 of Sub-Committee 22 of the Joint Technical Committee 1 of the
973 International Organization for Standardization and the International
974 Electrotechnical Commission (IEC).  This group is known as
975 @uref{http://www.nag.co.uk/sc22wg5/, WG5}.
976
977 The GNU Fortran supports several of the new features of Fortran 2008; the
978 @uref{http://gcc.gnu.org/wiki/Fortran2008Status, wiki} has some information
979 about the current Fortran 2008 implementation status.  In particular, the
980 following is implemented.
981
982 @itemize
983 @item The @option{-std=f2008} option and support for the file extensions 
984 @file{.f08} and @file{.F08}.
985
986 @item The @code{OPEN} statement now supports the @code{NEWUNIT=} option,
987 which returns a unique file unit, thus preventing inadvertent use of the
988 same unit in different parts of the program.
989
990 @item The @code{g0} format descriptor and unlimited format items.
991
992 @item The mathematical intrinsics @code{ASINH}, @code{ACOSH}, @code{ATANH},
993 @code{ERF}, @code{ERFC}, @code{GAMMA}, @code{LOG_GAMMA}, @code{BESSEL_J0},
994 @code{BESSEL_J1}, @code{BESSEL_JN}, @code{BESSEL_Y0}, @code{BESSEL_Y1},
995 @code{BESSEL_YN}, @code{HYPOT}, @code{NORM2}, and @code{ERFC_SCALED}.
996
997 @item Using complex arguments with @code{TAN}, @code{SINH}, @code{COSH},
998 @code{TANH}, @code{ASIN}, @code{ACOS}, and @code{ATAN} is now possible;
999 @code{ATAN}(@var{Y},@var{X}) is now an alias for @code{ATAN2}(@var{Y},@var{X}).
1000
1001 @item Support of the @code{PARITY} intrinsic functions.
1002
1003 @item The following bit intrinsics: @code{LEADZ} and @code{TRAILZ} for
1004 counting the number of leading and trailing zero bits, @code{POPCNT} and
1005 @code{POPPAR} for counting the number of one bits and returning the parity;
1006 @code{BGE}, @code{BGT}, @code{BLE}, and @code{BLT} for bitwise comparisons;
1007 @code{DSHIFTL} and @code{DSHIFTR} for combined left and right shifts,
1008 @code{MASKL} and @code{MASKR} for simple left and right justified masks,
1009 @code{MERGE_BITS} for a bitwise merge using a mask, @code{SHIFTA},
1010 @code{SHIFTL} and @code{SHIFTR} for shift operations, and the
1011 transformational bit intrinsics @code{IALL}, @code{IANY} and @code{IPARITY}.
1012
1013 @item Support of the @code{EXECUTE_COMMAND_LINE} intrinsic subroutine.
1014
1015 @item Support for the @code{STORAGE_SIZE} intrinsic inquiry function.
1016
1017 @item The @code{INT@{8,16,32@}} and @code{REAL@{32,64,128@}} kind type
1018 parameters and the array-valued named constants @code{INTEGER_KINDS},
1019 @code{LOGICAL_KINDS}, @code{REAL_KINDS} and @code{CHARACTER_KINDS} of
1020 the intrinsic module @code{ISO_FORTRAN_ENV}.
1021
1022 @item The module procedures @code{C_SIZEOF} of the intrinsic module
1023 @code{ISO_C_BINDINGS} and @code{COMPILER_VERSION} and @code{COMPILER_OPTIONS}
1024 of @code{ISO_FORTRAN_ENV}.
1025
1026 @item Experimental coarray support (for one image only), use the
1027 @option{-fcoarray=single} flag to enable it.
1028
1029 @item The @code{BLOCK} construct is supported.
1030
1031 @item The @code{STOP} and the new @code{ERROR STOP} statements now
1032 support all constant expressions.
1033
1034 @item Support for the @code{CONTIGUOUS} attribute.
1035
1036 @item Support for @code{ALLOCATE} with @code{MOLD}.
1037
1038 @item Support for the @code{IMPURE} attribute for procedures, which
1039 allows for @code{ELEMENTAL} procedures without the restrictions of
1040 @code{PURE}.
1041
1042 @item Null pointers (including @code{NULL()}) and not-allocated variables
1043 can be used as actual argument to optional non-pointer, non-allocatable
1044 dummy arguments, denoting an absent argument.
1045
1046 @item Non-pointer variables with @code{TARGET} attribute can be used as
1047 actual argument to @code{POINTER} dummies with @code{INTENT(IN)}.
1048
1049 @item Pointers including procedure pointers and those in a derived
1050 type (pointer components) can now be initialized by a target instead
1051 of only by @code{NULL}.
1052
1053 @item The @code{EXIT} statement (with construct-name) can be now be
1054 used to leave not only the @code{DO} but also the @code{ASSOCIATE},
1055 @code{BLOCK}, @code{IF}, @code{SELECT CASE} and @code{SELECT TYPE}
1056 constructs.
1057
1058 @item Internal procedures can now be used as actual argument.
1059
1060 @item Minor features: obsolesce diagnostics for @code{ENTRY} with
1061 @option{-std=f2008}; a line may start with a semicolon; for internal
1062 and module procedures @code{END} can be used instead of
1063 @code{END SUBROUTINE} and @code{END FUNCTION}; @code{SELECTED_REAL_KIND}
1064 now also takes a @code{RADIX} argument; intrinsic types are supported
1065 for @code{TYPE}(@var{intrinsic-type-spec}); multiple type-bound procedures
1066 can be declared in a single @code{PROCEDURE} statement; implied-shape
1067 arrays are supported for named constants (@code{PARAMETER}).
1068 @end itemize
1069
1070
1071
1072 @c ---------------------------------------------------------------------
1073 @c Compiler Characteristics
1074 @c ---------------------------------------------------------------------
1075
1076 @node Compiler Characteristics
1077 @chapter Compiler Characteristics
1078
1079 This chapter describes certain characteristics of the GNU Fortran
1080 compiler, that are not specified by the Fortran standard, but which
1081 might in some way or another become visible to the programmer.
1082
1083 @menu
1084 * KIND Type Parameters::
1085 * Internal representation of LOGICAL variables::
1086 * Thread-safety of the runtime library::
1087 @end menu
1088
1089
1090 @node KIND Type Parameters
1091 @section KIND Type Parameters
1092 @cindex kind
1093
1094 The @code{KIND} type parameters supported by GNU Fortran for the primitive
1095 data types are:
1096
1097 @table @code
1098
1099 @item INTEGER
1100 1, 2, 4, 8*, 16*, default: 4 (1)
1101
1102 @item LOGICAL
1103 1, 2, 4, 8*, 16*, default: 4 (1)
1104
1105 @item REAL
1106 4, 8, 10*, 16*, default: 4 (2)
1107
1108 @item COMPLEX
1109 4, 8, 10*, 16*, default: 4 (2)
1110
1111 @item CHARACTER
1112 1, 4, default: 1
1113
1114 @end table
1115
1116 @noindent
1117 * = not available on all systems @*
1118 (1) Unless -fdefault-integer-8 is used @*
1119 (2) Unless -fdefault-real-8 is used
1120
1121 @noindent
1122 The @code{KIND} value matches the storage size in bytes, except for
1123 @code{COMPLEX} where the storage size is twice as much (or both real and
1124 imaginary part are a real value of the given size).  It is recommended to use
1125 the @code{SELECTED_CHAR_KIND}, @code{SELECTED_INT_KIND} and
1126 @code{SELECTED_REAL_KIND} intrinsics or the @code{INT8}, @code{INT16},
1127 @code{INT32}, @code{INT64}, @code{REAL32}, @code{REAL64}, and @code{REAL128}
1128 parameters of the @code{ISO_FORTRAN_ENV} module instead of the concrete values.
1129 The available kind parameters can be found in the constant arrays
1130 @code{CHARACTER_KINDS}, @code{INTEGER_KINDS}, @code{LOGICAL_KINDS} and
1131 @code{REAL_KINDS} in the @code{ISO_FORTRAN_ENV} module
1132 (see @ref{ISO_FORTRAN_ENV}).
1133
1134
1135 @node Internal representation of LOGICAL variables
1136 @section Internal representation of LOGICAL variables
1137 @cindex logical, variable representation
1138
1139 The Fortran standard does not specify how variables of @code{LOGICAL}
1140 type are represented, beyond requiring that @code{LOGICAL} variables
1141 of default kind have the same storage size as default @code{INTEGER}
1142 and @code{REAL} variables.  The GNU Fortran internal representation is
1143 as follows.
1144
1145 A @code{LOGICAL(KIND=N)} variable is represented as an
1146 @code{INTEGER(KIND=N)} variable, however, with only two permissible
1147 values: @code{1} for @code{.TRUE.} and @code{0} for
1148 @code{.FALSE.}.  Any other integer value results in undefined behavior.
1149
1150 Note that for mixed-language programming using the
1151 @code{ISO_C_BINDING} feature, there is a @code{C_BOOL} kind that can
1152 be used to create @code{LOGICAL(KIND=C_BOOL)} variables which are
1153 interoperable with the C99 _Bool type.  The C99 _Bool type has an
1154 internal representation described in the C99 standard, which is
1155 identical to the above description, i.e. with 1 for true and 0 for
1156 false being the only permissible values.  Thus the internal
1157 representation of @code{LOGICAL} variables in GNU Fortran is identical
1158 to C99 _Bool, except for a possible difference in storage size
1159 depending on the kind.
1160
1161
1162 @node Thread-safety of the runtime library
1163 @section Thread-safety of the runtime library
1164 @cindex thread-safety, threads
1165
1166 GNU Fortran can be used in programs with multiple threads, e.g. by
1167 using OpenMP, by calling OS thread handling functions via the
1168 @code{ISO_C_BINDING} facility, or by GNU Fortran compiled library code
1169 being called from a multi-threaded program.
1170
1171 The GNU Fortran runtime library, (@code{libgfortran}), supports being
1172 called concurrently from multiple threads with the following
1173 exceptions. 
1174
1175 During library initialization, the C @code{getenv} function is used,
1176 which need not be thread-safe.  Similarly, the @code{getenv}
1177 function is used to implement the @code{GET_ENVIRONMENT_VARIABLE} and
1178 @code{GETENV} intrinsics.  It is the responsibility of the user to
1179 ensure that the environment is not being updated concurrently when any
1180 of these actions are taking place.
1181
1182 The @code{EXECUTE_COMMAND_LINE} and @code{SYSTEM} intrinsics are
1183 implemented with the @code{system} function, which need not be
1184 thread-safe.  It is the responsibility of the user to ensure that
1185 @code{system} is not called concurrently.
1186
1187 Finally, for platforms not supporting thread-safe POSIX functions,
1188 further functionality might not be thread-safe.  For details, please
1189 consult the documentation for your operating system.
1190
1191 @c ---------------------------------------------------------------------
1192 @c Extensions
1193 @c ---------------------------------------------------------------------
1194
1195 @c Maybe this chapter should be merged with the 'Standards' section,
1196 @c whenever that is written :-)
1197
1198 @node Extensions
1199 @chapter Extensions
1200 @cindex extensions
1201
1202 The two sections below detail the extensions to standard Fortran that are
1203 implemented in GNU Fortran, as well as some of the popular or
1204 historically important extensions that are not (or not yet) implemented.
1205 For the latter case, we explain the alternatives available to GNU Fortran
1206 users, including replacement by standard-conforming code or GNU
1207 extensions.
1208
1209 @menu
1210 * Extensions implemented in GNU Fortran::
1211 * Extensions not implemented in GNU Fortran::
1212 @end menu
1213
1214
1215 @node Extensions implemented in GNU Fortran
1216 @section Extensions implemented in GNU Fortran
1217 @cindex extensions, implemented
1218
1219 GNU Fortran implements a number of extensions over standard
1220 Fortran.  This chapter contains information on their syntax and
1221 meaning.  There are currently two categories of GNU Fortran
1222 extensions, those that provide functionality beyond that provided
1223 by any standard, and those that are supported by GNU Fortran
1224 purely for backward compatibility with legacy compilers.  By default,
1225 @option{-std=gnu} allows the compiler to accept both types of
1226 extensions, but to warn about the use of the latter.  Specifying
1227 either @option{-std=f95}, @option{-std=f2003} or @option{-std=f2008}
1228 disables both types of extensions, and @option{-std=legacy} allows both
1229 without warning.
1230
1231 @menu
1232 * Old-style kind specifications::
1233 * Old-style variable initialization::
1234 * Extensions to namelist::
1235 * X format descriptor without count field::
1236 * Commas in FORMAT specifications::
1237 * Missing period in FORMAT specifications::
1238 * I/O item lists::
1239 * BOZ literal constants::
1240 * Real array indices::
1241 * Unary operators::
1242 * Implicitly convert LOGICAL and INTEGER values::
1243 * Hollerith constants support::
1244 * Cray pointers::
1245 * CONVERT specifier::
1246 * OpenMP::
1247 * Argument list functions::
1248 @end menu
1249
1250 @node Old-style kind specifications
1251 @subsection Old-style kind specifications
1252 @cindex kind, old-style
1253
1254 GNU Fortran allows old-style kind specifications in declarations.  These
1255 look like:
1256 @smallexample
1257       TYPESPEC*size x,y,z
1258 @end smallexample
1259 @noindent
1260 where @code{TYPESPEC} is a basic type (@code{INTEGER}, @code{REAL},
1261 etc.), and where @code{size} is a byte count corresponding to the
1262 storage size of a valid kind for that type.  (For @code{COMPLEX}
1263 variables, @code{size} is the total size of the real and imaginary
1264 parts.)  The statement then declares @code{x}, @code{y} and @code{z} to
1265 be of type @code{TYPESPEC} with the appropriate kind.  This is
1266 equivalent to the standard-conforming declaration
1267 @smallexample
1268       TYPESPEC(k) x,y,z
1269 @end smallexample
1270 @noindent
1271 where @code{k} is the kind parameter suitable for the intended precision.  As
1272 kind parameters are implementation-dependent, use the @code{KIND},
1273 @code{SELECTED_INT_KIND} and @code{SELECTED_REAL_KIND} intrinsics to retrieve
1274 the correct value, for instance @code{REAL*8 x} can be replaced by:
1275 @smallexample
1276 INTEGER, PARAMETER :: dbl = KIND(1.0d0)
1277 REAL(KIND=dbl) :: x
1278 @end smallexample
1279
1280 @node Old-style variable initialization
1281 @subsection Old-style variable initialization
1282
1283 GNU Fortran allows old-style initialization of variables of the
1284 form:
1285 @smallexample
1286       INTEGER i/1/,j/2/
1287       REAL x(2,2) /3*0.,1./
1288 @end smallexample
1289 The syntax for the initializers is as for the @code{DATA} statement, but
1290 unlike in a @code{DATA} statement, an initializer only applies to the
1291 variable immediately preceding the initialization.  In other words,
1292 something like @code{INTEGER I,J/2,3/} is not valid.  This style of
1293 initialization is only allowed in declarations without double colons
1294 (@code{::}); the double colons were introduced in Fortran 90, which also
1295 introduced a standard syntax for initializing variables in type
1296 declarations.
1297
1298 Examples of standard-conforming code equivalent to the above example
1299 are:
1300 @smallexample
1301 ! Fortran 90
1302       INTEGER :: i = 1, j = 2
1303       REAL :: x(2,2) = RESHAPE((/0.,0.,0.,1./),SHAPE(x))
1304 ! Fortran 77
1305       INTEGER i, j
1306       REAL x(2,2)
1307       DATA i/1/, j/2/, x/3*0.,1./
1308 @end smallexample
1309
1310 Note that variables which are explicitly initialized in declarations
1311 or in @code{DATA} statements automatically acquire the @code{SAVE}
1312 attribute.
1313
1314 @node Extensions to namelist
1315 @subsection Extensions to namelist
1316 @cindex Namelist
1317
1318 GNU Fortran fully supports the Fortran 95 standard for namelist I/O
1319 including array qualifiers, substrings and fully qualified derived types.
1320 The output from a namelist write is compatible with namelist read.  The
1321 output has all names in upper case and indentation to column 1 after the
1322 namelist name.  Two extensions are permitted:
1323
1324 Old-style use of @samp{$} instead of @samp{&}
1325 @smallexample
1326 $MYNML
1327  X(:)%Y(2) = 1.0 2.0 3.0
1328  CH(1:4) = "abcd"
1329 $END
1330 @end smallexample
1331
1332 It should be noted that the default terminator is @samp{/} rather than
1333 @samp{&END}.
1334
1335 Querying of the namelist when inputting from stdin.  After at least
1336 one space, entering @samp{?} sends to stdout the namelist name and the names of
1337 the variables in the namelist:
1338 @smallexample
1339  ?
1340
1341 &mynml
1342  x
1343  x%y
1344  ch
1345 &end
1346 @end smallexample
1347
1348 Entering @samp{=?} outputs the namelist to stdout, as if
1349 @code{WRITE(*,NML = mynml)} had been called:
1350 @smallexample
1351 =?
1352
1353 &MYNML
1354  X(1)%Y=  0.000000    ,  1.000000    ,  0.000000    ,
1355  X(2)%Y=  0.000000    ,  2.000000    ,  0.000000    ,
1356  X(3)%Y=  0.000000    ,  3.000000    ,  0.000000    ,
1357  CH=abcd,  /
1358 @end smallexample
1359
1360 To aid this dialog, when input is from stdin, errors send their
1361 messages to stderr and execution continues, even if @code{IOSTAT} is set.
1362
1363 @code{PRINT} namelist is permitted.  This causes an error if
1364 @option{-std=f95} is used.
1365 @smallexample
1366 PROGRAM test_print
1367   REAL, dimension (4)  ::  x = (/1.0, 2.0, 3.0, 4.0/)
1368   NAMELIST /mynml/ x
1369   PRINT mynml
1370 END PROGRAM test_print
1371 @end smallexample
1372
1373 Expanded namelist reads are permitted.  This causes an error if 
1374 @option{-std=f95} is used.  In the following example, the first element
1375 of the array will be given the value 0.00 and the two succeeding
1376 elements will be given the values 1.00 and 2.00.
1377 @smallexample
1378 &MYNML
1379   X(1,1) = 0.00 , 1.00 , 2.00
1380 /
1381 @end smallexample
1382
1383 @node X format descriptor without count field
1384 @subsection @code{X} format descriptor without count field
1385
1386 To support legacy codes, GNU Fortran permits the count field of the
1387 @code{X} edit descriptor in @code{FORMAT} statements to be omitted.
1388 When omitted, the count is implicitly assumed to be one.
1389
1390 @smallexample
1391        PRINT 10, 2, 3
1392 10     FORMAT (I1, X, I1)
1393 @end smallexample
1394
1395 @node Commas in FORMAT specifications
1396 @subsection Commas in @code{FORMAT} specifications
1397
1398 To support legacy codes, GNU Fortran allows the comma separator
1399 to be omitted immediately before and after character string edit
1400 descriptors in @code{FORMAT} statements.
1401
1402 @smallexample
1403        PRINT 10, 2, 3
1404 10     FORMAT ('FOO='I1' BAR='I2)
1405 @end smallexample
1406
1407
1408 @node Missing period in FORMAT specifications
1409 @subsection Missing period in @code{FORMAT} specifications
1410
1411 To support legacy codes, GNU Fortran allows missing periods in format
1412 specifications if and only if @option{-std=legacy} is given on the
1413 command line.  This is considered non-conforming code and is
1414 discouraged.
1415
1416 @smallexample
1417        REAL :: value
1418        READ(*,10) value
1419 10     FORMAT ('F4')
1420 @end smallexample
1421
1422 @node I/O item lists
1423 @subsection I/O item lists
1424 @cindex I/O item lists
1425
1426 To support legacy codes, GNU Fortran allows the input item list
1427 of the @code{READ} statement, and the output item lists of the
1428 @code{WRITE} and @code{PRINT} statements, to start with a comma.
1429
1430 @node BOZ literal constants
1431 @subsection BOZ literal constants
1432 @cindex BOZ literal constants
1433
1434 Besides decimal constants, Fortran also supports binary (@code{b}),
1435 octal (@code{o}) and hexadecimal (@code{z}) integer constants.  The
1436 syntax is: @samp{prefix quote digits quote}, were the prefix is
1437 either @code{b}, @code{o} or @code{z}, quote is either @code{'} or
1438 @code{"} and the digits are for binary @code{0} or @code{1}, for
1439 octal between @code{0} and @code{7}, and for hexadecimal between
1440 @code{0} and @code{F}.  (Example: @code{b'01011101'}.)
1441
1442 Up to Fortran 95, BOZ literals were only allowed to initialize
1443 integer variables in DATA statements.  Since Fortran 2003 BOZ literals
1444 are also allowed as argument of @code{REAL}, @code{DBLE}, @code{INT}
1445 and @code{CMPLX}; the result is the same as if the integer BOZ
1446 literal had been converted by @code{TRANSFER} to, respectively,
1447 @code{real}, @code{double precision}, @code{integer} or @code{complex}.
1448 As GNU Fortran extension the intrinsic procedures @code{FLOAT},
1449 @code{DFLOAT}, @code{COMPLEX} and @code{DCMPLX} are treated alike.
1450
1451 As an extension, GNU Fortran allows hexadecimal BOZ literal constants to
1452 be specified using the @code{X} prefix, in addition to the standard
1453 @code{Z} prefix.  The BOZ literal can also be specified by adding a
1454 suffix to the string, for example, @code{Z'ABC'} and @code{'ABC'Z} are
1455 equivalent.
1456
1457 Furthermore, GNU Fortran allows using BOZ literal constants outside
1458 DATA statements and the four intrinsic functions allowed by Fortran 2003.
1459 In DATA statements, in direct assignments, where the right-hand side
1460 only contains a BOZ literal constant, and for old-style initializers of
1461 the form @code{integer i /o'0173'/}, the constant is transferred
1462 as if @code{TRANSFER} had been used; for @code{COMPLEX} numbers, only
1463 the real part is initialized unless @code{CMPLX} is used.  In all other
1464 cases, the BOZ literal constant is converted to an @code{INTEGER} value with
1465 the largest decimal representation.  This value is then converted
1466 numerically to the type and kind of the variable in question.
1467 (For instance, @code{real :: r = b'0000001' + 1} initializes @code{r}
1468 with @code{2.0}.) As different compilers implement the extension
1469 differently, one should be careful when doing bitwise initialization
1470 of non-integer variables.
1471
1472 Note that initializing an @code{INTEGER} variable with a statement such
1473 as @code{DATA i/Z'FFFFFFFF'/} will give an integer overflow error rather
1474 than the desired result of @math{-1} when @code{i} is a 32-bit integer
1475 on a system that supports 64-bit integers.  The @samp{-fno-range-check}
1476 option can be used as a workaround for legacy code that initializes
1477 integers in this manner.
1478
1479 @node Real array indices
1480 @subsection Real array indices
1481 @cindex array, indices of type real
1482
1483 As an extension, GNU Fortran allows the use of @code{REAL} expressions
1484 or variables as array indices.
1485
1486 @node Unary operators
1487 @subsection Unary operators
1488 @cindex operators, unary
1489
1490 As an extension, GNU Fortran allows unary plus and unary minus operators
1491 to appear as the second operand of binary arithmetic operators without
1492 the need for parenthesis.
1493
1494 @smallexample
1495        X = Y * -Z
1496 @end smallexample
1497
1498 @node Implicitly convert LOGICAL and INTEGER values
1499 @subsection Implicitly convert @code{LOGICAL} and @code{INTEGER} values
1500 @cindex conversion, to integer
1501 @cindex conversion, to logical
1502
1503 As an extension for backwards compatibility with other compilers, GNU
1504 Fortran allows the implicit conversion of @code{LOGICAL} values to
1505 @code{INTEGER} values and vice versa.  When converting from a
1506 @code{LOGICAL} to an @code{INTEGER}, @code{.FALSE.} is interpreted as
1507 zero, and @code{.TRUE.} is interpreted as one.  When converting from
1508 @code{INTEGER} to @code{LOGICAL}, the value zero is interpreted as
1509 @code{.FALSE.} and any nonzero value is interpreted as @code{.TRUE.}.
1510
1511 @smallexample
1512         LOGICAL :: l
1513         l = 1
1514 @end smallexample
1515 @smallexample
1516         INTEGER :: i
1517         i = .TRUE.
1518 @end smallexample
1519
1520 However, there is no implicit conversion of @code{INTEGER} values in
1521 @code{if}-statements, nor of @code{LOGICAL} or @code{INTEGER} values
1522 in I/O operations.
1523
1524 @node Hollerith constants support
1525 @subsection Hollerith constants support
1526 @cindex Hollerith constants
1527
1528 GNU Fortran supports Hollerith constants in assignments, function
1529 arguments, and @code{DATA} and @code{ASSIGN} statements.  A Hollerith
1530 constant is written as a string of characters preceded by an integer
1531 constant indicating the character count, and the letter @code{H} or
1532 @code{h}, and stored in bytewise fashion in a numeric (@code{INTEGER},
1533 @code{REAL}, or @code{complex}) or @code{LOGICAL} variable.  The
1534 constant will be padded or truncated to fit the size of the variable in
1535 which it is stored.
1536
1537 Examples of valid uses of Hollerith constants:
1538 @smallexample
1539       complex*16 x(2)
1540       data x /16Habcdefghijklmnop, 16Hqrstuvwxyz012345/
1541       x(1) = 16HABCDEFGHIJKLMNOP
1542       call foo (4h abc)
1543 @end smallexample
1544
1545 Invalid Hollerith constants examples:
1546 @smallexample
1547       integer*4 a
1548       a = 8H12345678 ! Valid, but the Hollerith constant will be truncated.
1549       a = 0H         ! At least one character is needed.
1550 @end smallexample
1551
1552 In general, Hollerith constants were used to provide a rudimentary
1553 facility for handling character strings in early Fortran compilers,
1554 prior to the introduction of @code{CHARACTER} variables in Fortran 77;
1555 in those cases, the standard-compliant equivalent is to convert the
1556 program to use proper character strings.  On occasion, there may be a
1557 case where the intent is specifically to initialize a numeric variable
1558 with a given byte sequence.  In these cases, the same result can be
1559 obtained by using the @code{TRANSFER} statement, as in this example.
1560 @smallexample
1561       INTEGER(KIND=4) :: a
1562       a = TRANSFER ("abcd", a)     ! equivalent to: a = 4Habcd
1563 @end smallexample
1564
1565
1566 @node Cray pointers
1567 @subsection Cray pointers
1568 @cindex pointer, Cray
1569
1570 Cray pointers are part of a non-standard extension that provides a
1571 C-like pointer in Fortran.  This is accomplished through a pair of
1572 variables: an integer "pointer" that holds a memory address, and a
1573 "pointee" that is used to dereference the pointer.
1574
1575 Pointer/pointee pairs are declared in statements of the form:
1576 @smallexample
1577         pointer ( <pointer> , <pointee> )
1578 @end smallexample
1579 or,
1580 @smallexample
1581         pointer ( <pointer1> , <pointee1> ), ( <pointer2> , <pointee2> ), ...
1582 @end smallexample
1583 The pointer is an integer that is intended to hold a memory address.
1584 The pointee may be an array or scalar.  A pointee can be an assumed
1585 size array---that is, the last dimension may be left unspecified by
1586 using a @code{*} in place of a value---but a pointee cannot be an
1587 assumed shape array.  No space is allocated for the pointee.
1588
1589 The pointee may have its type declared before or after the pointer
1590 statement, and its array specification (if any) may be declared
1591 before, during, or after the pointer statement.  The pointer may be
1592 declared as an integer prior to the pointer statement.  However, some
1593 machines have default integer sizes that are different than the size
1594 of a pointer, and so the following code is not portable:
1595 @smallexample
1596         integer ipt
1597         pointer (ipt, iarr)
1598 @end smallexample
1599 If a pointer is declared with a kind that is too small, the compiler
1600 will issue a warning; the resulting binary will probably not work
1601 correctly, because the memory addresses stored in the pointers may be
1602 truncated.  It is safer to omit the first line of the above example;
1603 if explicit declaration of ipt's type is omitted, then the compiler
1604 will ensure that ipt is an integer variable large enough to hold a
1605 pointer.
1606
1607 Pointer arithmetic is valid with Cray pointers, but it is not the same
1608 as C pointer arithmetic.  Cray pointers are just ordinary integers, so
1609 the user is responsible for determining how many bytes to add to a
1610 pointer in order to increment it.  Consider the following example:
1611 @smallexample
1612         real target(10)
1613         real pointee(10)
1614         pointer (ipt, pointee)
1615         ipt = loc (target)
1616         ipt = ipt + 1       
1617 @end smallexample
1618 The last statement does not set @code{ipt} to the address of
1619 @code{target(1)}, as it would in C pointer arithmetic.  Adding @code{1}
1620 to @code{ipt} just adds one byte to the address stored in @code{ipt}.
1621
1622 Any expression involving the pointee will be translated to use the
1623 value stored in the pointer as the base address.
1624
1625 To get the address of elements, this extension provides an intrinsic
1626 function @code{LOC()}.  The @code{LOC()} function is equivalent to the
1627 @code{&} operator in C, except the address is cast to an integer type:
1628 @smallexample
1629         real ar(10)
1630         pointer(ipt, arpte(10))
1631         real arpte
1632         ipt = loc(ar)  ! Makes arpte is an alias for ar
1633         arpte(1) = 1.0 ! Sets ar(1) to 1.0
1634 @end smallexample
1635 The pointer can also be set by a call to the @code{MALLOC} intrinsic
1636 (see @ref{MALLOC}).
1637
1638 Cray pointees often are used to alias an existing variable.  For
1639 example:
1640 @smallexample
1641         integer target(10)
1642         integer iarr(10)
1643         pointer (ipt, iarr)
1644         ipt = loc(target)
1645 @end smallexample
1646 As long as @code{ipt} remains unchanged, @code{iarr} is now an alias for
1647 @code{target}.  The optimizer, however, will not detect this aliasing, so
1648 it is unsafe to use @code{iarr} and @code{target} simultaneously.  Using
1649 a pointee in any way that violates the Fortran aliasing rules or
1650 assumptions is illegal.  It is the user's responsibility to avoid doing
1651 this; the compiler works under the assumption that no such aliasing
1652 occurs.
1653
1654 Cray pointers will work correctly when there is no aliasing (i.e., when
1655 they are used to access a dynamically allocated block of memory), and
1656 also in any routine where a pointee is used, but any variable with which
1657 it shares storage is not used.  Code that violates these rules may not
1658 run as the user intends.  This is not a bug in the optimizer; any code
1659 that violates the aliasing rules is illegal.  (Note that this is not
1660 unique to GNU Fortran; any Fortran compiler that supports Cray pointers
1661 will ``incorrectly'' optimize code with illegal aliasing.)
1662
1663 There are a number of restrictions on the attributes that can be applied
1664 to Cray pointers and pointees.  Pointees may not have the
1665 @code{ALLOCATABLE}, @code{INTENT}, @code{OPTIONAL}, @code{DUMMY},
1666 @code{TARGET}, @code{INTRINSIC}, or @code{POINTER} attributes.  Pointers
1667 may not have the @code{DIMENSION}, @code{POINTER}, @code{TARGET},
1668 @code{ALLOCATABLE}, @code{EXTERNAL}, or @code{INTRINSIC} attributes, nor
1669 may they be function results.  Pointees may not occur in more than one
1670 pointer statement.  A pointee cannot be a pointer.  Pointees cannot occur
1671 in equivalence, common, or data statements.
1672
1673 A Cray pointer may also point to a function or a subroutine.  For
1674 example, the following excerpt is valid:
1675 @smallexample
1676   implicit none
1677   external sub
1678   pointer (subptr,subpte)
1679   external subpte
1680   subptr = loc(sub)
1681   call subpte()
1682   [...]
1683   subroutine sub
1684   [...]
1685   end subroutine sub
1686 @end smallexample
1687
1688 A pointer may be modified during the course of a program, and this
1689 will change the location to which the pointee refers.  However, when
1690 pointees are passed as arguments, they are treated as ordinary
1691 variables in the invoked function.  Subsequent changes to the pointer
1692 will not change the base address of the array that was passed.
1693
1694 @node CONVERT specifier
1695 @subsection @code{CONVERT} specifier
1696 @cindex @code{CONVERT} specifier
1697
1698 GNU Fortran allows the conversion of unformatted data between little-
1699 and big-endian representation to facilitate moving of data
1700 between different systems.  The conversion can be indicated with
1701 the @code{CONVERT} specifier on the @code{OPEN} statement.
1702 @xref{GFORTRAN_CONVERT_UNIT}, for an alternative way of specifying
1703 the data format via an environment variable.
1704
1705 Valid values for @code{CONVERT} are:
1706 @itemize @w{}
1707 @item @code{CONVERT='NATIVE'} Use the native format.  This is the default.
1708 @item @code{CONVERT='SWAP'} Swap between little- and big-endian.
1709 @item @code{CONVERT='LITTLE_ENDIAN'} Use the little-endian representation
1710 for unformatted files.
1711 @item @code{CONVERT='BIG_ENDIAN'} Use the big-endian representation for
1712 unformatted files.
1713 @end itemize
1714
1715 Using the option could look like this:
1716 @smallexample
1717   open(file='big.dat',form='unformatted',access='sequential', &
1718        convert='big_endian')
1719 @end smallexample
1720
1721 The value of the conversion can be queried by using
1722 @code{INQUIRE(CONVERT=ch)}.  The values returned are
1723 @code{'BIG_ENDIAN'} and @code{'LITTLE_ENDIAN'}.
1724
1725 @code{CONVERT} works between big- and little-endian for
1726 @code{INTEGER} values of all supported kinds and for @code{REAL}
1727 on IEEE systems of kinds 4 and 8.  Conversion between different
1728 ``extended double'' types on different architectures such as
1729 m68k and x86_64, which GNU Fortran
1730 supports as @code{REAL(KIND=10)} and @code{REAL(KIND=16)}, will
1731 probably not work.
1732
1733 @emph{Note that the values specified via the GFORTRAN_CONVERT_UNIT
1734 environment variable will override the CONVERT specifier in the
1735 open statement}.  This is to give control over data formats to
1736 users who do not have the source code of their program available.
1737
1738 Using anything but the native representation for unformatted data
1739 carries a significant speed overhead.  If speed in this area matters
1740 to you, it is best if you use this only for data that needs to be
1741 portable.
1742
1743 @node OpenMP
1744 @subsection OpenMP
1745 @cindex OpenMP
1746
1747 OpenMP (Open Multi-Processing) is an application programming
1748 interface (API) that supports multi-platform shared memory 
1749 multiprocessing programming in C/C++ and Fortran on many 
1750 architectures, including Unix and Microsoft Windows platforms.
1751 It consists of a set of compiler directives, library routines,
1752 and environment variables that influence run-time behavior.
1753
1754 GNU Fortran strives to be compatible to the 
1755 @uref{http://www.openmp.org/mp-documents/spec30.pdf,
1756 OpenMP Application Program Interface v3.0}.
1757
1758 To enable the processing of the OpenMP directive @code{!$omp} in
1759 free-form source code; the @code{c$omp}, @code{*$omp} and @code{!$omp}
1760 directives in fixed form; the @code{!$} conditional compilation sentinels
1761 in free form; and the @code{c$}, @code{*$} and @code{!$} sentinels
1762 in fixed form, @command{gfortran} needs to be invoked with the
1763 @option{-fopenmp}.  This also arranges for automatic linking of the
1764 GNU OpenMP runtime library @ref{Top,,libgomp,libgomp,GNU OpenMP
1765 runtime library}.
1766
1767 The OpenMP Fortran runtime library routines are provided both in a
1768 form of a Fortran 90 module named @code{omp_lib} and in a form of
1769 a Fortran @code{include} file named @file{omp_lib.h}.
1770
1771 An example of a parallelized loop taken from Appendix A.1 of
1772 the OpenMP Application Program Interface v2.5:
1773 @smallexample
1774 SUBROUTINE A1(N, A, B)
1775   INTEGER I, N
1776   REAL B(N), A(N)
1777 !$OMP PARALLEL DO !I is private by default
1778   DO I=2,N
1779     B(I) = (A(I) + A(I-1)) / 2.0
1780   ENDDO
1781 !$OMP END PARALLEL DO
1782 END SUBROUTINE A1
1783 @end smallexample
1784
1785 Please note:
1786 @itemize
1787 @item
1788 @option{-fopenmp} implies @option{-frecursive}, i.e., all local arrays
1789 will be allocated on the stack.  When porting existing code to OpenMP,
1790 this may lead to surprising results, especially to segmentation faults
1791 if the stacksize is limited.
1792
1793 @item
1794 On glibc-based systems, OpenMP enabled applications cannot be statically
1795 linked due to limitations of the underlying pthreads-implementation.  It
1796 might be possible to get a working solution if 
1797 @command{-Wl,--whole-archive -lpthread -Wl,--no-whole-archive} is added
1798 to the command line.  However, this is not supported by @command{gcc} and
1799 thus not recommended.
1800 @end itemize
1801
1802 @node Argument list functions
1803 @subsection Argument list functions @code{%VAL}, @code{%REF} and @code{%LOC}
1804 @cindex argument list functions
1805 @cindex @code{%VAL}
1806 @cindex @code{%REF}
1807 @cindex @code{%LOC}
1808
1809 GNU Fortran supports argument list functions @code{%VAL}, @code{%REF} 
1810 and @code{%LOC} statements, for backward compatibility with g77. 
1811 It is recommended that these should be used only for code that is 
1812 accessing facilities outside of GNU Fortran, such as operating system 
1813 or windowing facilities.  It is best to constrain such uses to isolated 
1814 portions of a program--portions that deal specifically and exclusively 
1815 with low-level, system-dependent facilities.  Such portions might well 
1816 provide a portable interface for use by the program as a whole, but are 
1817 themselves not portable, and should be thoroughly tested each time they 
1818 are rebuilt using a new compiler or version of a compiler.
1819
1820 @code{%VAL} passes a scalar argument by value, @code{%REF} passes it by 
1821 reference and @code{%LOC} passes its memory location.  Since gfortran 
1822 already passes scalar arguments by reference, @code{%REF} is in effect 
1823 a do-nothing.  @code{%LOC} has the same effect as a Fortran pointer.
1824
1825 An example of passing an argument by value to a C subroutine foo.:
1826 @smallexample
1827 C
1828 C prototype      void foo_ (float x);
1829 C
1830       external foo
1831       real*4 x
1832       x = 3.14159
1833       call foo (%VAL (x))
1834       end
1835 @end smallexample
1836
1837 For details refer to the g77 manual
1838 @uref{http://gcc.gnu.org/@/onlinedocs/@/gcc-3.4.6/@/g77/@/index.html#Top}.
1839
1840 Also, @code{c_by_val.f} and its partner @code{c_by_val.c} of the
1841 GNU Fortran testsuite are worth a look.
1842
1843
1844 @node Extensions not implemented in GNU Fortran
1845 @section Extensions not implemented in GNU Fortran
1846 @cindex extensions, not implemented
1847
1848 The long history of the Fortran language, its wide use and broad
1849 userbase, the large number of different compiler vendors and the lack of
1850 some features crucial to users in the first standards have lead to the
1851 existence of a number of important extensions to the language.  While
1852 some of the most useful or popular extensions are supported by the GNU
1853 Fortran compiler, not all existing extensions are supported.  This section
1854 aims at listing these extensions and offering advice on how best make
1855 code that uses them running with the GNU Fortran compiler.
1856
1857 @c More can be found here:
1858 @c   -- http://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/Missing-Features.html
1859 @c   -- the list of Fortran and libgfortran bugs closed as WONTFIX:
1860 @c      http://tinyurl.com/2u4h5y
1861
1862 @menu
1863 * STRUCTURE and RECORD::
1864 @c * UNION and MAP::
1865 * ENCODE and DECODE statements::
1866 * Variable FORMAT expressions::
1867 @c * Q edit descriptor::
1868 @c * AUTOMATIC statement::
1869 @c * TYPE and ACCEPT I/O Statements::
1870 @c * .XOR. operator::
1871 @c * CARRIAGECONTROL, DEFAULTFILE, DISPOSE and RECORDTYPE I/O specifiers::
1872 @c * Omitted arguments in procedure call::
1873 * Alternate complex function syntax::
1874 @end menu
1875
1876
1877 @node STRUCTURE and RECORD
1878 @subsection @code{STRUCTURE} and @code{RECORD}
1879 @cindex @code{STRUCTURE}
1880 @cindex @code{RECORD}
1881
1882 Structures are user-defined aggregate data types; this functionality was
1883 standardized in Fortran 90 with an different syntax, under the name of
1884 ``derived types''.  Here is an example of code using the non portable
1885 structure syntax:
1886
1887 @example
1888 ! Declaring a structure named ``item'' and containing three fields:
1889 ! an integer ID, an description string and a floating-point price.
1890 STRUCTURE /item/
1891   INTEGER id
1892   CHARACTER(LEN=200) description
1893   REAL price
1894 END STRUCTURE
1895
1896 ! Define two variables, an single record of type ``item''
1897 ! named ``pear'', and an array of items named ``store_catalog''
1898 RECORD /item/ pear, store_catalog(100)
1899
1900 ! We can directly access the fields of both variables
1901 pear.id = 92316
1902 pear.description = "juicy D'Anjou pear"
1903 pear.price = 0.15
1904 store_catalog(7).id = 7831
1905 store_catalog(7).description = "milk bottle"
1906 store_catalog(7).price = 1.2
1907
1908 ! We can also manipulate the whole structure
1909 store_catalog(12) = pear
1910 print *, store_catalog(12)
1911 @end example
1912
1913 @noindent
1914 This code can easily be rewritten in the Fortran 90 syntax as following:
1915
1916 @example
1917 ! ``STRUCTURE /name/ ... END STRUCTURE'' becomes
1918 ! ``TYPE name ... END TYPE''
1919 TYPE item
1920   INTEGER id
1921   CHARACTER(LEN=200) description
1922   REAL price
1923 END TYPE
1924
1925 ! ``RECORD /name/ variable'' becomes ``TYPE(name) variable''
1926 TYPE(item) pear, store_catalog(100)
1927
1928 ! Instead of using a dot (.) to access fields of a record, the
1929 ! standard syntax uses a percent sign (%)
1930 pear%id = 92316
1931 pear%description = "juicy D'Anjou pear"
1932 pear%price = 0.15
1933 store_catalog(7)%id = 7831
1934 store_catalog(7)%description = "milk bottle"
1935 store_catalog(7)%price = 1.2
1936
1937 ! Assignments of a whole variable don't change
1938 store_catalog(12) = pear
1939 print *, store_catalog(12)
1940 @end example
1941
1942
1943 @c @node UNION and MAP
1944 @c @subsection @code{UNION} and @code{MAP}
1945 @c @cindex @code{UNION}
1946 @c @cindex @code{MAP}
1947 @c
1948 @c For help writing this one, see
1949 @c http://www.eng.umd.edu/~nsw/ench250/fortran1.htm#UNION and
1950 @c http://www.tacc.utexas.edu/services/userguides/pgi/pgiws_ug/pgi32u06.htm
1951
1952
1953 @node ENCODE and DECODE statements
1954 @subsection @code{ENCODE} and @code{DECODE} statements
1955 @cindex @code{ENCODE}
1956 @cindex @code{DECODE}
1957
1958 GNU Fortran doesn't support the @code{ENCODE} and @code{DECODE}
1959 statements.  These statements are best replaced by @code{READ} and
1960 @code{WRITE} statements involving internal files (@code{CHARACTER}
1961 variables and arrays), which have been part of the Fortran standard since
1962 Fortran 77.  For example, replace a code fragment like
1963
1964 @smallexample
1965       INTEGER*1 LINE(80)
1966       REAL A, B, C
1967 c     ... Code that sets LINE
1968       DECODE (80, 9000, LINE) A, B, C
1969  9000 FORMAT (1X, 3(F10.5))
1970 @end smallexample
1971
1972 @noindent
1973 with the following:
1974
1975 @smallexample
1976       CHARACTER(LEN=80) LINE
1977       REAL A, B, C
1978 c     ... Code that sets LINE
1979       READ (UNIT=LINE, FMT=9000) A, B, C
1980  9000 FORMAT (1X, 3(F10.5))
1981 @end smallexample
1982
1983 Similarly, replace a code fragment like
1984
1985 @smallexample
1986       INTEGER*1 LINE(80)
1987       REAL A, B, C
1988 c     ... Code that sets A, B and C
1989       ENCODE (80, 9000, LINE) A, B, C
1990  9000 FORMAT (1X, 'OUTPUT IS ', 3(F10.5))
1991 @end smallexample
1992
1993 @noindent
1994 with the following:
1995
1996 @smallexample
1997       CHARACTER(LEN=80) LINE
1998       REAL A, B, C
1999 c     ... Code that sets A, B and C
2000       WRITE (UNIT=LINE, FMT=9000) A, B, C
2001  9000 FORMAT (1X, 'OUTPUT IS ', 3(F10.5))
2002 @end smallexample
2003
2004
2005 @node Variable FORMAT expressions
2006 @subsection Variable @code{FORMAT} expressions
2007 @cindex @code{FORMAT}
2008
2009 A variable @code{FORMAT} expression is format statement which includes
2010 angle brackets enclosing a Fortran expression: @code{FORMAT(I<N>)}.  GNU
2011 Fortran does not support this legacy extension.  The effect of variable
2012 format expressions can be reproduced by using the more powerful (and
2013 standard) combination of internal output and string formats.  For example,
2014 replace a code fragment like this:
2015
2016 @smallexample
2017       WRITE(6,20) INT1
2018  20   FORMAT(I<N+1>)
2019 @end smallexample
2020
2021 @noindent
2022 with the following:
2023
2024 @smallexample
2025 c     Variable declaration
2026       CHARACTER(LEN=20) FMT
2027 c     
2028 c     Other code here...
2029 c
2030       WRITE(FMT,'("(I", I0, ")")') N+1
2031       WRITE(6,FMT) INT1
2032 @end smallexample
2033
2034 @noindent
2035 or with:
2036
2037 @smallexample
2038 c     Variable declaration
2039       CHARACTER(LEN=20) FMT
2040 c     
2041 c     Other code here...
2042 c
2043       WRITE(FMT,*) N+1
2044       WRITE(6,"(I" // ADJUSTL(FMT) // ")") INT1
2045 @end smallexample
2046
2047
2048 @node Alternate complex function syntax
2049 @subsection Alternate complex function syntax
2050 @cindex Complex function
2051
2052 Some Fortran compilers, including @command{g77}, let the user declare
2053 complex functions with the syntax @code{COMPLEX FUNCTION name*16()}, as
2054 well as @code{COMPLEX*16 FUNCTION name()}.  Both are non-standard, legacy
2055 extensions.  @command{gfortran} accepts the latter form, which is more
2056 common, but not the former.
2057
2058
2059
2060 @c ---------------------------------------------------------------------
2061 @c Mixed-Language Programming
2062 @c ---------------------------------------------------------------------
2063
2064 @node Mixed-Language Programming
2065 @chapter Mixed-Language Programming
2066 @cindex Interoperability
2067 @cindex Mixed-language programming
2068
2069 @menu
2070 * Interoperability with C::
2071 * GNU Fortran Compiler Directives::
2072 * Non-Fortran Main Program::
2073 @end menu
2074
2075 This chapter is about mixed-language interoperability, but also applies
2076 if one links Fortran code compiled by different compilers.  In most cases,
2077 use of the C Binding features of the Fortran 2003 standard is sufficient,
2078 and their use is highly recommended.
2079
2080
2081 @node Interoperability with C
2082 @section Interoperability with C
2083
2084 @menu
2085 * Intrinsic Types::
2086 * Derived Types and struct::
2087 * Interoperable Global Variables::
2088 * Interoperable Subroutines and Functions::
2089 * Working with Pointers::
2090 * Further Interoperability of Fortran with C::
2091 @end menu
2092
2093 Since Fortran 2003 (ISO/IEC 1539-1:2004(E)) there is a
2094 standardized way to generate procedure and derived-type
2095 declarations and global variables which are interoperable with C
2096 (ISO/IEC 9899:1999).  The @code{bind(C)} attribute has been added
2097 to inform the compiler that a symbol shall be interoperable with C;
2098 also, some constraints are added.  Note, however, that not
2099 all C features have a Fortran equivalent or vice versa.  For instance,
2100 neither C's unsigned integers nor C's functions with variable number
2101 of arguments have an equivalent in Fortran.
2102
2103 Note that array dimensions are reversely ordered in C and that arrays in
2104 C always start with index 0 while in Fortran they start by default with
2105 1.  Thus, an array declaration @code{A(n,m)} in Fortran matches
2106 @code{A[m][n]} in C and accessing the element @code{A(i,j)} matches
2107 @code{A[j-1][i-1]}.  The element following @code{A(i,j)} (C: @code{A[j-1][i-1]};
2108 assuming @math{i < n}) in memory is @code{A(i+1,j)} (C: @code{A[j-1][i]}).
2109
2110 @node Intrinsic Types
2111 @subsection Intrinsic Types
2112
2113 In order to ensure that exactly the same variable type and kind is used
2114 in C and Fortran, the named constants shall be used which are defined in the
2115 @code{ISO_C_BINDING} intrinsic module.  That module contains named constants
2116 for kind parameters and character named constants for the escape sequences
2117 in C.  For a list of the constants, see @ref{ISO_C_BINDING}.
2118
2119 @node Derived Types and struct
2120 @subsection Derived Types and struct
2121
2122 For compatibility of derived types with @code{struct}, one needs to use
2123 the @code{BIND(C)} attribute in the type declaration.  For instance, the
2124 following type declaration
2125
2126 @smallexample
2127  USE ISO_C_BINDING
2128  TYPE, BIND(C) :: myType
2129    INTEGER(C_INT) :: i1, i2
2130    INTEGER(C_SIGNED_CHAR) :: i3
2131    REAL(C_DOUBLE) :: d1
2132    COMPLEX(C_FLOAT_COMPLEX) :: c1
2133    CHARACTER(KIND=C_CHAR) :: str(5)
2134  END TYPE
2135 @end smallexample
2136
2137 matches the following @code{struct} declaration in C
2138
2139 @smallexample
2140  struct @{
2141    int i1, i2;
2142    /* Note: "char" might be signed or unsigned.  */
2143    signed char i3;
2144    double d1;
2145    float _Complex c1;
2146    char str[5];
2147  @} myType;
2148 @end smallexample
2149
2150 Derived types with the C binding attribute shall not have the @code{sequence}
2151 attribute, type parameters, the @code{extends} attribute, nor type-bound
2152 procedures.  Every component must be of interoperable type and kind and may not
2153 have the @code{pointer} or @code{allocatable} attribute.  The names of the
2154 variables are irrelevant for interoperability.
2155
2156 As there exist no direct Fortran equivalents, neither unions nor structs
2157 with bit field or variable-length array members are interoperable.
2158
2159 @node Interoperable Global Variables
2160 @subsection Interoperable Global Variables
2161
2162 Variables can be made accessible from C using the C binding attribute,
2163 optionally together with specifying a binding name.  Those variables
2164 have to be declared in the declaration part of a @code{MODULE},
2165 be of interoperable type, and have neither the @code{pointer} nor
2166 the @code{allocatable} attribute.
2167
2168 @smallexample
2169   MODULE m
2170     USE myType_module
2171     USE ISO_C_BINDING
2172     integer(C_INT), bind(C, name="_MyProject_flags") :: global_flag
2173     type(myType), bind(C) :: tp
2174   END MODULE
2175 @end smallexample
2176
2177 Here, @code{_MyProject_flags} is the case-sensitive name of the variable
2178 as seen from C programs while @code{global_flag} is the case-insensitive
2179 name as seen from Fortran.  If no binding name is specified, as for
2180 @var{tp}, the C binding name is the (lowercase) Fortran binding name.
2181 If a binding name is specified, only a single variable may be after the
2182 double colon.  Note of warning: You cannot use a global variable to
2183 access @var{errno} of the C library as the C standard allows it to be
2184 a macro.  Use the @code{IERRNO} intrinsic (GNU extension) instead.
2185
2186 @node Interoperable Subroutines and Functions
2187 @subsection Interoperable Subroutines and Functions
2188
2189 Subroutines and functions have to have the @code{BIND(C)} attribute to
2190 be compatible with C.  The dummy argument declaration is relatively
2191 straightforward.  However, one needs to be careful because C uses
2192 call-by-value by default while Fortran behaves usually similar to
2193 call-by-reference.  Furthermore, strings and pointers are handled
2194 differently.  Note that only explicit size and assumed-size arrays are
2195 supported but not assumed-shape or allocatable arrays.
2196
2197 To pass a variable by value, use the @code{VALUE} attribute.
2198 Thus the following C prototype
2199
2200 @smallexample
2201 @code{int func(int i, int *j)}
2202 @end smallexample
2203
2204 matches the Fortran declaration
2205
2206 @smallexample
2207   integer(c_int) function func(i,j)
2208     use iso_c_binding, only: c_int
2209     integer(c_int), VALUE :: i
2210     integer(c_int) :: j
2211 @end smallexample
2212
2213 Note that pointer arguments also frequently need the @code{VALUE} attribute,
2214 see @ref{Working with Pointers}.
2215
2216 Strings are handled quite differently in C and Fortran.  In C a string
2217 is a @code{NUL}-terminated array of characters while in Fortran each string
2218 has a length associated with it and is thus not terminated (by e.g.
2219 @code{NUL}).  For example, if one wants to use the following C function,
2220
2221 @smallexample
2222   #include <stdio.h>
2223   void print_C(char *string) /* equivalent: char string[]  */
2224   @{
2225      printf("%s\n", string);
2226   @}
2227 @end smallexample
2228
2229 to print ``Hello World'' from Fortran, one can call it using
2230
2231 @smallexample
2232   use iso_c_binding, only: C_CHAR, C_NULL_CHAR
2233   interface
2234     subroutine print_c(string) bind(C, name="print_C")
2235       use iso_c_binding, only: c_char
2236       character(kind=c_char) :: string(*)
2237     end subroutine print_c
2238   end interface
2239   call print_c(C_CHAR_"Hello World"//C_NULL_CHAR)
2240 @end smallexample
2241
2242 As the example shows, one needs to ensure that the
2243 string is @code{NUL} terminated.  Additionally, the dummy argument
2244 @var{string} of @code{print_C} is a length-one assumed-size
2245 array; using @code{character(len=*)} is not allowed.  The example
2246 above uses @code{c_char_"Hello World"} to ensure the string
2247 literal has the right type; typically the default character
2248 kind and @code{c_char} are the same and thus @code{"Hello World"}
2249 is equivalent.  However, the standard does not guarantee this.
2250
2251 The use of strings is now further illustrated using the C library
2252 function @code{strncpy}, whose prototype is
2253
2254 @smallexample
2255   char *strncpy(char *restrict s1, const char *restrict s2, size_t n);
2256 @end smallexample
2257
2258 The function @code{strncpy} copies at most @var{n} characters from
2259 string @var{s2} to @var{s1} and returns @var{s1}.  In the following
2260 example, we ignore the return value:
2261
2262 @smallexample
2263   use iso_c_binding
2264   implicit none
2265   character(len=30) :: str,str2
2266   interface
2267     ! Ignore the return value of strncpy -> subroutine
2268     ! "restrict" is always assumed if we do not pass a pointer
2269     subroutine strncpy(dest, src, n) bind(C)
2270       import
2271       character(kind=c_char),  intent(out) :: dest(*)
2272       character(kind=c_char),  intent(in)  :: src(*)
2273       integer(c_size_t), value, intent(in) :: n
2274     end subroutine strncpy
2275   end interface
2276   str = repeat('X',30) ! Initialize whole string with 'X'
2277   call strncpy(str, c_char_"Hello World"//C_NULL_CHAR, &
2278                len(c_char_"Hello World",kind=c_size_t))
2279   print '(a)', str ! prints: "Hello WorldXXXXXXXXXXXXXXXXXXX"
2280   end
2281 @end smallexample
2282
2283 The intrinsic procedures are described in @ref{Intrinsic Procedures}.
2284
2285 @node Working with Pointers
2286 @subsection Working with Pointers
2287
2288 C pointers are represented in Fortran via the special opaque derived type
2289 @code{type(c_ptr)} (with private components).  Thus one needs to
2290 use intrinsic conversion procedures to convert from or to C pointers.
2291 For example,
2292
2293 @smallexample
2294   use iso_c_binding
2295   type(c_ptr) :: cptr1, cptr2
2296   integer, target :: array(7), scalar
2297   integer, pointer :: pa(:), ps
2298   cptr1 = c_loc(array(1)) ! The programmer needs to ensure that the
2299                           ! array is contiguous if required by the C
2300                           ! procedure
2301   cptr2 = c_loc(scalar)
2302   call c_f_pointer(cptr2, ps)
2303   call c_f_pointer(cptr2, pa, shape=[7])
2304 @end smallexample
2305
2306 When converting C to Fortran arrays, the one-dimensional @code{SHAPE} argument
2307 has to be passed.
2308
2309 If a pointer is a dummy-argument of an interoperable procedure, it usually
2310 has to be declared using the @code{VALUE} attribute.  @code{void*}
2311 matches @code{TYPE(C_PTR), VALUE}, while @code{TYPE(C_PTR)} alone
2312 matches @code{void**}.
2313
2314 Procedure pointers are handled analogously to pointers; the C type is
2315 @code{TYPE(C_FUNPTR)} and the intrinsic conversion procedures are
2316 @code{C_F_PROCPOINTER} and @code{C_FUNLOC}.
2317
2318 Let's consider two examples of actually passing a procedure pointer from
2319 C to Fortran and vice versa.  Note that these examples are also very
2320 similar to passing ordinary pointers between both languages.
2321 First, consider this code in C:
2322
2323 @smallexample
2324 /* Procedure implemented in Fortran.  */
2325 void get_values (void (*)(double));
2326
2327 /* Call-back routine we want called from Fortran.  */
2328 void
2329 print_it (double x)
2330 @{
2331   printf ("Number is %f.\n", x);
2332 @}
2333
2334 /* Call Fortran routine and pass call-back to it.  */
2335 void
2336 foobar ()
2337 @{
2338   get_values (&print_it);
2339 @}
2340 @end smallexample
2341
2342 A matching implementation for @code{get_values} in Fortran, that correctly
2343 receives the procedure pointer from C and is able to call it, is given
2344 in the following @code{MODULE}:
2345
2346 @smallexample
2347 MODULE m
2348   IMPLICIT NONE
2349
2350   ! Define interface of call-back routine.
2351   ABSTRACT INTERFACE
2352     SUBROUTINE callback (x)
2353       USE, INTRINSIC :: ISO_C_BINDING
2354       REAL(KIND=C_DOUBLE), INTENT(IN), VALUE :: x
2355     END SUBROUTINE callback
2356   END INTERFACE
2357
2358 CONTAINS
2359
2360   ! Define C-bound procedure.
2361   SUBROUTINE get_values (cproc) BIND(C)
2362     USE, INTRINSIC :: ISO_C_BINDING
2363     TYPE(C_FUNPTR), INTENT(IN), VALUE :: cproc
2364
2365     PROCEDURE(callback), POINTER :: proc
2366
2367     ! Convert C to Fortran procedure pointer.
2368     CALL C_F_PROCPOINTER (cproc, proc)
2369
2370     ! Call it.
2371     CALL proc (1.0_C_DOUBLE)
2372     CALL proc (-42.0_C_DOUBLE)
2373     CALL proc (18.12_C_DOUBLE)
2374   END SUBROUTINE get_values
2375
2376 END MODULE m
2377 @end smallexample
2378
2379 Next, we want to call a C routine that expects a procedure pointer argument
2380 and pass it a Fortran procedure (which clearly must be interoperable!).
2381 Again, the C function may be:
2382
2383 @smallexample
2384 int
2385 call_it (int (*func)(int), int arg)
2386 @{
2387   return func (arg);
2388 @}
2389 @end smallexample
2390
2391 It can be used as in the following Fortran code:
2392
2393 @smallexample
2394 MODULE m
2395   USE, INTRINSIC :: ISO_C_BINDING
2396   IMPLICIT NONE
2397
2398   ! Define interface of C function.
2399   INTERFACE
2400     INTEGER(KIND=C_INT) FUNCTION call_it (func, arg) BIND(C)
2401       USE, INTRINSIC :: ISO_C_BINDING
2402       TYPE(C_FUNPTR), INTENT(IN), VALUE :: func
2403       INTEGER(KIND=C_INT), INTENT(IN), VALUE :: arg
2404     END FUNCTION call_it
2405   END INTERFACE
2406
2407 CONTAINS
2408
2409   ! Define procedure passed to C function.
2410   ! It must be interoperable!
2411   INTEGER(KIND=C_INT) FUNCTION double_it (arg) BIND(C)
2412     INTEGER(KIND=C_INT), INTENT(IN), VALUE :: arg
2413     double_it = arg + arg
2414   END FUNCTION double_it
2415
2416   ! Call C function.
2417   SUBROUTINE foobar ()
2418     TYPE(C_FUNPTR) :: cproc
2419     INTEGER(KIND=C_INT) :: i
2420
2421     ! Get C procedure pointer.
2422     cproc = C_FUNLOC (double_it)
2423
2424     ! Use it.
2425     DO i = 1_C_INT, 10_C_INT
2426       PRINT *, call_it (cproc, i)
2427     END DO
2428   END SUBROUTINE foobar
2429
2430 END MODULE m
2431 @end smallexample
2432
2433 @node Further Interoperability of Fortran with C
2434 @subsection Further Interoperability of Fortran with C
2435
2436 Assumed-shape and allocatable arrays are passed using an array descriptor
2437 (dope vector).  The internal structure of the array descriptor used
2438 by GNU Fortran is not yet documented and will change.  There will also be
2439 a Technical Report (TR 29113) which standardizes an interoperable
2440 array descriptor.  Until then, you can use the Chasm Language
2441 Interoperability Tools, @url{http://chasm-interop.sourceforge.net/},
2442 which provide an interface to GNU Fortran's array descriptor.
2443
2444 The technical report 29113 will presumably also include support for
2445 C-interoperable @code{OPTIONAL} and for assumed-rank and assumed-type
2446 dummy arguments.  However, the TR has neither been approved nor implemented
2447 in GNU Fortran; therefore, these features are not yet available.
2448
2449
2450
2451 @node GNU Fortran Compiler Directives
2452 @section GNU Fortran Compiler Directives
2453
2454 The Fortran standard standard describes how a conforming program shall
2455 behave; however, the exact implementation is not standardized.  In order
2456 to allow the user to choose specific implementation details, compiler
2457 directives can be used to set attributes of variables and procedures
2458 which are not part of the standard.  Whether a given attribute is
2459 supported and its exact effects depend on both the operating system and
2460 on the processor; see
2461 @ref{Top,,C Extensions,gcc,Using the GNU Compiler Collection (GCC)}
2462 for details.
2463
2464 For procedures and procedure pointers, the following attributes can
2465 be used to change the calling convention:
2466
2467 @itemize
2468 @item @code{CDECL} -- standard C calling convention
2469 @item @code{STDCALL} -- convention where the called procedure pops the stack
2470 @item @code{FASTCALL} -- part of the arguments are passed via registers
2471 instead using the stack
2472 @end itemize
2473
2474 Besides changing the calling convention, the attributes also influence
2475 the decoration of the symbol name, e.g., by a leading underscore or by
2476 a trailing at-sign followed by the number of bytes on the stack.  When
2477 assigning a procedure to a procedure pointer, both should use the same
2478 calling convention.
2479
2480 On some systems, procedures and global variables (module variables and
2481 @code{COMMON} blocks) need special handling to be accessible when they
2482 are in a shared library.  The following attributes are available:
2483
2484 @itemize
2485 @item @code{DLLEXPORT} -- provide a global pointer to a pointer in the DLL
2486 @item @code{DLLIMPORT} -- reference the function or variable using a global pointer 
2487 @end itemize
2488
2489 The attributes are specified using the syntax
2490
2491 @code{!GCC$ ATTRIBUTES} @var{attribute-list} @code{::} @var{variable-list}
2492
2493 where in free-form source code only whitespace is allowed before @code{!GCC$}
2494 and in fixed-form source code @code{!GCC$}, @code{cGCC$} or @code{*GCC$} shall
2495 start in the first column.
2496
2497 For procedures, the compiler directives shall be placed into the body
2498 of the procedure; for variables and procedure pointers, they shall be in
2499 the same declaration part as the variable or procedure pointer.
2500
2501
2502
2503 @node Non-Fortran Main Program
2504 @section Non-Fortran Main Program
2505
2506 @menu
2507 * _gfortran_set_args:: Save command-line arguments
2508 * _gfortran_set_options:: Set library option flags
2509 * _gfortran_set_convert:: Set endian conversion
2510 * _gfortran_set_record_marker:: Set length of record markers
2511 * _gfortran_set_max_subrecord_length:: Set subrecord length
2512 * _gfortran_set_fpe:: Set when a Floating Point Exception should be raised
2513 @end menu
2514
2515 Even if you are doing mixed-language programming, it is very
2516 likely that you do not need to know or use the information in this
2517 section.  Since it is about the internal structure of GNU Fortran,
2518 it may also change in GCC minor releases.
2519
2520 When you compile a @code{PROGRAM} with GNU Fortran, a function
2521 with the name @code{main} (in the symbol table of the object file)
2522 is generated, which initializes the libgfortran library and then
2523 calls the actual program which uses the name @code{MAIN__}, for
2524 historic reasons.  If you link GNU Fortran compiled procedures
2525 to, e.g., a C or C++ program or to a Fortran program compiled by
2526 a different compiler, the libgfortran library is not initialized
2527 and thus a few intrinsic procedures do not work properly, e.g.
2528 those for obtaining the command-line arguments.
2529
2530 Therefore, if your @code{PROGRAM} is not compiled with
2531 GNU Fortran and the GNU Fortran compiled procedures require
2532 intrinsics relying on the library initialization, you need to
2533 initialize the library yourself.  Using the default options,
2534 gfortran calls @code{_gfortran_set_args} and
2535 @code{_gfortran_set_options}.  The initialization of the former
2536 is needed if the called procedures access the command line
2537 (and for backtracing); the latter sets some flags based on the
2538 standard chosen or to enable backtracing.  In typical programs,
2539 it is not necessary to call any initialization function.
2540
2541 If your @code{PROGRAM} is compiled with GNU Fortran, you shall
2542 not call any of the following functions.  The libgfortran
2543 initialization functions are shown in C syntax but using C
2544 bindings they are also accessible from Fortran.
2545
2546
2547 @node _gfortran_set_args
2548 @subsection @code{_gfortran_set_args} --- Save command-line arguments
2549 @fnindex _gfortran_set_args
2550 @cindex libgfortran initialization, set_args
2551
2552 @table @asis
2553 @item @emph{Description}:
2554 @code{_gfortran_set_args} saves the command-line arguments; this
2555 initialization is required if any of the command-line intrinsics
2556 is called.  Additionally, it shall be called if backtracing is
2557 enabled (see @code{_gfortran_set_options}).
2558
2559 @item @emph{Syntax}:
2560 @code{void _gfortran_set_args (int argc, char *argv[])}
2561
2562 @item @emph{Arguments}:
2563 @multitable @columnfractions .15 .70
2564 @item @var{argc} @tab number of command line argument strings
2565 @item @var{argv} @tab the command-line argument strings; argv[0]
2566 is the pathname of the executable itself.
2567 @end multitable
2568
2569 @item @emph{Example}:
2570 @smallexample
2571 int main (int argc, char *argv[])
2572 @{
2573   /* Initialize libgfortran.  */
2574   _gfortran_set_args (argc, argv);
2575   return 0;
2576 @}
2577 @end smallexample
2578 @end table
2579
2580
2581 @node _gfortran_set_options
2582 @subsection @code{_gfortran_set_options} --- Set library option flags
2583 @fnindex _gfortran_set_options
2584 @cindex libgfortran initialization, set_options
2585
2586 @table @asis
2587 @item @emph{Description}:
2588 @code{_gfortran_set_options} sets several flags related to the Fortran
2589 standard to be used, whether backtracing or core dumps should be enabled
2590 and whether range checks should be performed.  The syntax allows for
2591 upward compatibility since the number of passed flags is specified; for
2592 non-passed flags, the default value is used.  See also
2593 @pxref{Code Gen Options}.  Please note that not all flags are actually
2594 used.
2595
2596 @item @emph{Syntax}:
2597 @code{void _gfortran_set_options (int num, int options[])}
2598
2599 @item @emph{Arguments}:
2600 @multitable @columnfractions .15 .70
2601 @item @var{num} @tab number of options passed
2602 @item @var{argv} @tab The list of flag values
2603 @end multitable
2604
2605 @item @emph{option flag list}:
2606 @multitable @columnfractions .15 .70
2607 @item @var{option}[0] @tab Allowed standard; can give run-time errors
2608 if e.g. an input-output edit descriptor is invalid in a given standard.
2609 Possible values are (bitwise or-ed) @code{GFC_STD_F77} (1),
2610 @code{GFC_STD_F95_OBS} (2), @code{GFC_STD_F95_DEL} (4), @code{GFC_STD_F95}
2611 (8), @code{GFC_STD_F2003} (16), @code{GFC_STD_GNU} (32),
2612 @code{GFC_STD_LEGACY} (64), @code{GFC_STD_F2008} (128), and
2613 @code{GFC_STD_F2008_OBS} (256).  Default: @code{GFC_STD_F95_OBS
2614 | GFC_STD_F95_DEL | GFC_STD_F95 | GFC_STD_F2003 | GFC_STD_F2008
2615 | GFC_STD_F2008_OBS | GFC_STD_F77 | GFC_STD_GNU | GFC_STD_LEGACY}.
2616 @item @var{option}[1] @tab Standard-warning flag; prints a warning to
2617 standard error.  Default: @code{GFC_STD_F95_DEL | GFC_STD_LEGACY}.
2618 @item @var{option}[2] @tab If non zero, enable pedantic checking.
2619 Default: off.
2620 @item @var{option}[3] @tab If non zero, enable core dumps on run-time
2621 errors.  Default: off.
2622 @item @var{option}[4] @tab If non zero, enable backtracing on run-time
2623 errors.  Default: off.
2624 Note: Installs a signal handler and requires command-line
2625 initialization using @code{_gfortran_set_args}.
2626 @item @var{option}[5] @tab If non zero, supports signed zeros.
2627 Default: enabled.
2628 @item @var{option}[6] @tab Enables run-time checking.  Possible values
2629 are (bitwise or-ed): GFC_RTCHECK_BOUNDS (1), GFC_RTCHECK_ARRAY_TEMPS (2),
2630 GFC_RTCHECK_RECURSION (4), GFC_RTCHECK_DO (16), GFC_RTCHECK_POINTER (32).
2631 Default: disabled.
2632 @item @var{option}[7] @tab If non zero, range checking is enabled.
2633 Default: enabled.  See -frange-check (@pxref{Code Gen Options}).
2634 @end multitable
2635
2636 @item @emph{Example}:
2637 @smallexample
2638   /* Use gfortran 4.5 default options.  */
2639   static int options[] = @{68, 255, 0, 0, 0, 1, 0, 1@};
2640   _gfortran_set_options (8, &options);
2641 @end smallexample
2642 @end table
2643
2644
2645 @node _gfortran_set_convert
2646 @subsection @code{_gfortran_set_convert} --- Set endian conversion
2647 @fnindex _gfortran_set_convert
2648 @cindex libgfortran initialization, set_convert
2649
2650 @table @asis
2651 @item @emph{Description}:
2652 @code{_gfortran_set_convert} set the representation of data for
2653 unformatted files.
2654
2655 @item @emph{Syntax}:
2656 @code{void _gfortran_set_convert (int conv)}
2657
2658 @item @emph{Arguments}:
2659 @multitable @columnfractions .15 .70
2660 @item @var{conv} @tab Endian conversion, possible values:
2661 GFC_CONVERT_NATIVE (0, default), GFC_CONVERT_SWAP (1),
2662 GFC_CONVERT_BIG (2), GFC_CONVERT_LITTLE (3).
2663 @end multitable
2664
2665 @item @emph{Example}:
2666 @smallexample
2667 int main (int argc, char *argv[])
2668 @{
2669   /* Initialize libgfortran.  */
2670   _gfortran_set_args (argc, argv);
2671   _gfortran_set_convert (1);
2672   return 0;
2673 @}
2674 @end smallexample
2675 @end table
2676
2677
2678 @node _gfortran_set_record_marker
2679 @subsection @code{_gfortran_set_record_marker} --- Set length of record markers
2680 @fnindex _gfortran_set_record_marker
2681 @cindex libgfortran initialization, set_record_marker
2682
2683 @table @asis
2684 @item @emph{Description}:
2685 @code{_gfortran_set_record_marker} sets the length of record markers
2686 for unformatted files.
2687
2688 @item @emph{Syntax}:
2689 @code{void _gfortran_set_record_marker (int val)}
2690
2691 @item @emph{Arguments}:
2692 @multitable @columnfractions .15 .70
2693 @item @var{val} @tab Length of the record marker; valid values
2694 are 4 and 8.  Default is 4.
2695 @end multitable
2696
2697 @item @emph{Example}:
2698 @smallexample
2699 int main (int argc, char *argv[])
2700 @{
2701   /* Initialize libgfortran.  */
2702   _gfortran_set_args (argc, argv);
2703   _gfortran_set_record_marker (8);
2704   return 0;
2705 @}
2706 @end smallexample
2707 @end table
2708
2709
2710 @node _gfortran_set_fpe
2711 @subsection @code{_gfortran_set_fpe} --- Set when a Floating Point Exception should be raised
2712 @fnindex _gfortran_set_fpe
2713 @cindex libgfortran initialization, set_fpe
2714
2715 @table @asis
2716 @item @emph{Description}:
2717 @code{_gfortran_set_fpe} sets the IEEE exceptions for which a
2718 Floating Point Exception (FPE) should be raised.  On most systems,
2719 this will result in a SIGFPE signal being sent and the program
2720 being interrupted.
2721
2722 @item @emph{Syntax}:
2723 @code{void _gfortran_set_fpe (int val)}
2724
2725 @item @emph{Arguments}:
2726 @multitable @columnfractions .15 .70
2727 @item @var{option}[0] @tab IEEE exceptions.  Possible values are
2728 (bitwise or-ed) zero (0, default) no trapping,
2729 @code{GFC_FPE_INVALID} (1), @code{GFC_FPE_DENORMAL} (2),
2730 @code{GFC_FPE_ZERO} (4), @code{GFC_FPE_OVERFLOW} (8),
2731 @code{GFC_FPE_UNDERFLOW} (16), and @code{GFC_FPE_PRECISION} (32).
2732 @end multitable
2733
2734 @item @emph{Example}:
2735 @smallexample
2736 int main (int argc, char *argv[])
2737 @{
2738   /* Initialize libgfortran.  */
2739   _gfortran_set_args (argc, argv);
2740   /* FPE for invalid operations such as SQRT(-1.0).  */
2741   _gfortran_set_fpe (1);
2742   return 0;
2743 @}
2744 @end smallexample
2745 @end table
2746
2747
2748 @node _gfortran_set_max_subrecord_length
2749 @subsection @code{_gfortran_set_max_subrecord_length} --- Set subrecord length
2750 @fnindex _gfortran_set_max_subrecord_length
2751 @cindex libgfortran initialization, set_max_subrecord_length
2752
2753 @table @asis
2754 @item @emph{Description}:
2755 @code{_gfortran_set_max_subrecord_length} set the maximum length
2756 for a subrecord.  This option only makes sense for testing and
2757 debugging of unformatted I/O.
2758
2759 @item @emph{Syntax}:
2760 @code{void _gfortran_set_max_subrecord_length (int val)}
2761
2762 @item @emph{Arguments}:
2763 @multitable @columnfractions .15 .70
2764 @item @var{val} @tab the maximum length for a subrecord;
2765 the maximum permitted value is 2147483639, which is also
2766 the default.
2767 @end multitable
2768
2769 @item @emph{Example}:
2770 @smallexample
2771 int main (int argc, char *argv[])
2772 @{
2773   /* Initialize libgfortran.  */
2774   _gfortran_set_args (argc, argv);
2775   _gfortran_set_max_subrecord_length (8);
2776   return 0;
2777 @}
2778 @end smallexample
2779 @end table
2780
2781
2782
2783 @c Intrinsic Procedures
2784 @c ---------------------------------------------------------------------
2785
2786 @include intrinsic.texi
2787
2788
2789 @tex
2790 \blankpart
2791 @end tex
2792
2793 @c ---------------------------------------------------------------------
2794 @c Contributing
2795 @c ---------------------------------------------------------------------
2796
2797 @node Contributing
2798 @unnumbered Contributing
2799 @cindex Contributing
2800
2801 Free software is only possible if people contribute to efforts
2802 to create it.
2803 We're always in need of more people helping out with ideas
2804 and comments, writing documentation and contributing code.
2805
2806 If you want to contribute to GNU Fortran,
2807 have a look at the long lists of projects you can take on.
2808 Some of these projects are small,
2809 some of them are large;
2810 some are completely orthogonal to the rest of what is
2811 happening on GNU Fortran,
2812 but others are ``mainstream'' projects in need of enthusiastic hackers.
2813 All of these projects are important!
2814 We'll eventually get around to the things here,
2815 but they are also things doable by someone who is willing and able.
2816
2817 @menu
2818 * Contributors::
2819 * Projects::
2820 * Proposed Extensions::
2821 @end menu
2822
2823
2824 @node Contributors
2825 @section Contributors to GNU Fortran
2826 @cindex Contributors
2827 @cindex Credits
2828 @cindex Authors
2829
2830 Most of the parser was hand-crafted by @emph{Andy Vaught}, who is
2831 also the initiator of the whole project.  Thanks Andy!
2832 Most of the interface with GCC was written by @emph{Paul Brook}.
2833
2834 The following individuals have contributed code and/or
2835 ideas and significant help to the GNU Fortran project
2836 (in alphabetical order):
2837
2838 @itemize @minus
2839 @item Janne Blomqvist
2840 @item Steven Bosscher
2841 @item Paul Brook
2842 @item Tobias Burnus
2843 @item Fran@,{c}ois-Xavier Coudert
2844 @item Bud Davis
2845 @item Jerry DeLisle
2846 @item Erik Edelmann
2847 @item Bernhard Fischer
2848 @item Daniel Franke
2849 @item Richard Guenther
2850 @item Richard Henderson
2851 @item Katherine Holcomb
2852 @item Jakub Jelinek
2853 @item Niels Kristian Bech Jensen
2854 @item Steven Johnson
2855 @item Steven G. Kargl
2856 @item Thomas Koenig
2857 @item Asher Langton
2858 @item H. J. Lu
2859 @item Toon Moene
2860 @item Brooks Moses
2861 @item Andrew Pinski
2862 @item Tim Prince
2863 @item Christopher D. Rickett
2864 @item Richard Sandiford
2865 @item Tobias Schl@"uter
2866 @item Roger Sayle
2867 @item Paul Thomas
2868 @item Andy Vaught
2869 @item Feng Wang
2870 @item Janus Weil
2871 @item Daniel Kraft
2872 @end itemize
2873
2874 The following people have contributed bug reports,
2875 smaller or larger patches,
2876 and much needed feedback and encouragement for the
2877 GNU Fortran project: 
2878
2879 @itemize @minus
2880 @item Bill Clodius
2881 @item Dominique d'Humi@`eres
2882 @item Kate Hedstrom
2883 @item Erik Schnetter
2884 @item Joost VandeVondele
2885 @end itemize
2886
2887 Many other individuals have helped debug,
2888 test and improve the GNU Fortran compiler over the past few years,
2889 and we welcome you to do the same!
2890 If you already have done so,
2891 and you would like to see your name listed in the
2892 list above, please contact us.
2893
2894
2895 @node Projects
2896 @section Projects
2897
2898 @table @emph
2899
2900 @item Help build the test suite
2901 Solicit more code for donation to the test suite: the more extensive the
2902 testsuite, the smaller the risk of breaking things in the future! We can
2903 keep code private on request.
2904
2905 @item Bug hunting/squishing
2906 Find bugs and write more test cases! Test cases are especially very
2907 welcome, because it allows us to concentrate on fixing bugs instead of
2908 isolating them.  Going through the bugzilla database at
2909 @url{http://gcc.gnu.org/@/bugzilla/} to reduce testcases posted there and
2910 add more information (for example, for which version does the testcase
2911 work, for which versions does it fail?) is also very helpful.
2912
2913 @end table
2914
2915
2916 @node Proposed Extensions
2917 @section Proposed Extensions
2918
2919 Here's a list of proposed extensions for the GNU Fortran compiler, in no particular
2920 order.  Most of these are necessary to be fully compatible with
2921 existing Fortran compilers, but they are not part of the official
2922 J3 Fortran 95 standard.
2923
2924 @subsection Compiler extensions: 
2925 @itemize @bullet
2926 @item
2927 User-specified alignment rules for structures.
2928
2929 @item
2930 Automatically extend single precision constants to double.
2931
2932 @item
2933 Compile code that conserves memory by dynamically allocating common and
2934 module storage either on stack or heap.
2935
2936 @item
2937 Compile flag to generate code for array conformance checking (suggest -CC).
2938
2939 @item
2940 User control of symbol names (underscores, etc).
2941
2942 @item
2943 Compile setting for maximum size of stack frame size before spilling
2944 parts to static or heap.
2945
2946 @item
2947 Flag to force local variables into static space.
2948
2949 @item
2950 Flag to force local variables onto stack.
2951 @end itemize
2952
2953
2954 @subsection Environment Options
2955 @itemize @bullet
2956 @item
2957 Pluggable library modules for random numbers, linear algebra.
2958 LA should use BLAS calling conventions.
2959
2960 @item
2961 Environment variables controlling actions on arithmetic exceptions like
2962 overflow, underflow, precision loss---Generate NaN, abort, default.
2963 action.
2964
2965 @item
2966 Set precision for fp units that support it (i387).
2967
2968 @item
2969 Variable for setting fp rounding mode.
2970
2971 @item
2972 Variable to fill uninitialized variables with a user-defined bit
2973 pattern.
2974
2975 @item
2976 Environment variable controlling filename that is opened for that unit
2977 number.
2978
2979 @item
2980 Environment variable to clear/trash memory being freed.
2981
2982 @item
2983 Environment variable to control tracing of allocations and frees.
2984
2985 @item
2986 Environment variable to display allocated memory at normal program end.
2987
2988 @item
2989 Environment variable for filename for * IO-unit.
2990
2991 @item
2992 Environment variable for temporary file directory.
2993
2994 @item
2995 Environment variable forcing standard output to be line buffered (unix).
2996
2997 @end itemize
2998
2999
3000 @c ---------------------------------------------------------------------
3001 @c GNU General Public License
3002 @c ---------------------------------------------------------------------
3003
3004 @include gpl_v3.texi
3005
3006
3007
3008 @c ---------------------------------------------------------------------
3009 @c GNU Free Documentation License
3010 @c ---------------------------------------------------------------------
3011
3012 @include fdl.texi
3013
3014
3015
3016 @c ---------------------------------------------------------------------
3017 @c Funding Free Software
3018 @c ---------------------------------------------------------------------
3019
3020 @include funding.texi
3021
3022 @c ---------------------------------------------------------------------
3023 @c Indices
3024 @c ---------------------------------------------------------------------
3025
3026 @node Option Index
3027 @unnumbered Option Index
3028 @command{gfortran}'s command line options are indexed here without any
3029 initial @samp{-} or @samp{--}.  Where an option has both positive and
3030 negative forms (such as -foption and -fno-option), relevant entries in
3031 the manual are indexed under the most appropriate form; it may sometimes
3032 be useful to look up both forms.
3033 @printindex op
3034
3035 @node Keyword Index
3036 @unnumbered Keyword Index
3037 @printindex cp
3038
3039 @bye