\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename gfortran.info
-@set copyrights-gfortran 1999-2005
+@set copyrights-gfortran 1999-2006
@include gcc-common.texi
-@settitle The GNU Fortran 95 Compiler
+@settitle The GNU Fortran Compiler
@c Create a separate index for command line options
@defcodeindex op
@end copying
@ifinfo
-@dircategory Programming
+@dircategory Software development
@direntry
-* gfortran: (gfortran). The GNU Fortran 95 Compiler.
+* gfortran: (gfortran). The GNU Fortran Compiler.
@end direntry
This file documents the use and the internals of
-the GNU Fortran 95 compiler, (@command{gfortran}).
+the GNU Fortran compiler, (@command{gfortran}).
Published by the Free Software Foundation
51 Franklin Street, Fifth Floor
@setchapternewpage odd
@titlepage
-@title Using GNU Fortran 95
+@title Using GNU Fortran
@sp 2
@center The gfortran team
@page
@cindex Introduction
This manual documents the use of @command{gfortran},
-the GNU Fortran 95 compiler. You can find in this manual how to invoke
+the GNU Fortran compiler. You can find in this manual how to invoke
@command{gfortran}, as well as its features and incompatibilities.
@ifset DEVELOPMENT
@emph{Warning:} This document, and the compiler it describes, are still
under development. While efforts are made to keep it up-to-date, it might
-not accurately reflect the status of the most recent @command{gfortran}.
+not accurately reflect the status of the most recent GNU Fortran compiler.
@end ifset
@comment
@comment better formatting.
@comment
@menu
-* Getting Started:: What you should know about @command{gfortran}.
-* GFORTRAN and GCC:: You can compile Fortran, C, or other programs.
-* GFORTRAN and G77:: Why we chose to start from scratch.
-* Invoking GFORTRAN:: Command options supported by @command{gfortran}.
-* Project Status:: Status of @command{gfortran}, roadmap, proposed extensions.
+* Getting Started:: What you should know about GNU Fortran.
+* GNU Fortran and GCC:: You can compile Fortran, C, or other programs.
+* GNU Fortran and G77:: Why we chose to start from scratch.
+* Invoking GNU Fortran:: Command options supported by @command{gfortran}.
+* Project Status:: Status of GNU Fortran, roadmap, proposed extensions.
* Contributing:: How you can help.
-* Standards:: Standards supported by @command{gfortran}
-* Extensions:: Language extensions implemented by @command{gfortran}
-* Intrinsic Procedures:: Intrinsic procedures supported by @command{gfortran}
+* Standards:: Standards supported by GNU Fortran.
+* Runtime:: Influencing runtime behavior with environment variables.
+* Extensions:: Language extensions implemented by GNU Fortran.
+* Intrinsic Procedures:: Intrinsic procedures supported by GNU Fortran.
* Copying:: GNU General Public License says
how you can copy and share GNU Fortran.
* GNU Free Documentation License::
@node Getting Started
@chapter Getting Started
-Gfortran is the GNU Fortran 95 compiler front end,
+The GNU Fortran compiler front end was
designed initially as a free replacement for,
or alternative to, the unix @command{f95} command;
@command{gfortran} is the command you'll use to invoke the compiler.
-Gfortran is still in an early state of development.
-@command{gfortran} can generate code for most constructs and expressions,
+The GNU Fortran compiler is still in an early state of development.
+It can generate code for most constructs and expressions,
but much work remains to be done.
-When @command{gfortran} is finished,
+When the GNU Fortran compiler is finished,
it will do everything you expect from any decent compiler:
@itemize @bullet
and @dfn{linked} to the user program.
@end itemize
-Gfortran consists of several components:
+The GNU Fortran compiler consists of several components:
@itemize @bullet
@item
which also might be installed as the
system's @command{f95} command.
@command{gfortran} is just another driver program,
-but specifically for the Fortran 95 compiler only.
+but specifically for the Fortran compiler only.
The difference with @command{gcc} is that @command{gfortran}
will automatically link the correct libraries to your program.
@item
The Fortran compiler itself, (@command{f951}).
-This is the gfortran parser and code generator,
+This is the GNU Fortran parser and code generator,
linked to and interfaced with the GCC backend library.
@command{f951} ``translates'' the source code to
assembler code. You would typically not use this
@c ---------------------------------------------------------------------
-@c GFORTRAN and GCC
+@c GNU Fortran and GCC
@c ---------------------------------------------------------------------
-@node GFORTRAN and GCC
-@chapter GFORTRAN and GCC
+@node GNU Fortran and GCC
+@chapter GNU Fortran and GCC
@cindex GNU Compiler Collection
GCC used to be the GNU ``C'' Compiler,
Different phases in this translation process can be,
and in fact @emph{are} merged in many compiler front ends.
-GNU Fortran 95 has a strict separation between the
+GNU Fortran has a strict separation between the
parser and code generator.
-The goal of the gfortran project is to build a new front end for GCC.
+The goal of the GNU Fortran project is to build a new front end for GCC.
Specifically, a Fortran 95 front end.
-In a non-gfortran installation,
-@command{gcc} will not be able to compile Fortran 95 source code
+In a non-@command{gfortran} installation,
+@command{gcc} will not be able to compile Fortran source code
(only the ``C'' front end has to be compiled if you want to build GCC,
all other languages are optional).
-If you build GCC with gfortran, @command{gcc} will recognize
-@file{.f/.f90/.f95} source files and accepts Fortran 95 specific
+If you build GCC with @command{gfortran}, @command{gcc} will recognize
+@file{.f/.f90/.f95} source files and accepts Fortran specific
command line options.
@c ---------------------------------------------------------------------
-@c GFORTRAN and G77
+@c GNU Fortran and G77
@c ---------------------------------------------------------------------
-@node GFORTRAN and G77
-@chapter GFORTRAN and G77
+@node GNU Fortran and G77
+@chapter GNU Fortran and G77
@cindex Fortran 77
@cindex G77
@chapter Project Status
@quotation
-As soon as gfortran can parse all of the statements correctly,
+As soon as @command{gfortran} can parse all of the statements correctly,
it will be in the ``larva'' state.
When we generate code, the ``puppa'' state.
-When gfortran is done,
+When @command{gfortran} is done,
we'll see if it will be a beautiful butterfly,
or just a big bug....
(even though Andy had already been working on it for a while,
of course).
-Gfortran is currently reaching the stage where is is able to compile real
-world programs. However it is still under development and has many rough
-edges.
-
@menu
-* Compiler Status::
-* Library Status::
+* Compiler and Library Status::
* Proposed Extensions::
@end menu
-@node Compiler Status
-@section Compiler Status
-
-@table @emph
-@item Front end
-This is the part of gfortran which parses a source file, verifies that it
-is valid Fortran 95, performs compile time replacement of constants
-(PARAMETER variables) and reads and generate module files. This is
-almost complete. Every Fortran 95 source should be accepted, and most
-none-Fortran 95 source should be rejected. If you find a source file where
-this is not true, please tell us. You can use the -fsyntax-only switch to
-make gfortran quit after running the front end, effectively reducing it to
-a syntax checker.
-
-@item Middle end interface
-These are the parts of gfortran that take the parse tree generated by the
-front end and translate it to the GENERIC form required by the GCC back
-end. Work is ongoing in these parts of gfortran, but a large part has
-already been completed.
-@end table
-
-@node Library Status
-@section Library Status
-
-Some intrinsic functions map directly to library functions, and in most
-cases the name of the library function used depends on the type of the
-arguments. For some intrinsics we generate inline code, and for others,
-such as sin, cos and sqrt, we rely on the backend to use special
-instructions in the floating point unit of the CPU if available, or to
-fall back to a call to libm if these are not available.
-
-Implementation of some non-elemental intrinsic functions (eg. DOT_PRODUCT,
-AVERAGE) is not yet optimal. This is hard because we have to make decisions
-whether to use inline code (good for small arrays as no function call
-overhead occurs) or generate function calls (good for large arrays as it
-allows use of hand-optimized assembly routines, SIMD instructions, etc.)
+@node Compiler and Library Status
+@section Compiler and Library Status
+
+The GNU Fortran compiler is able to compile nearly all
+standard-compliant Fortran 95, Fortran 90, and Fortran 77 programs,
+including a number of standard and non-standard extensions, and can be
+used on real-world programs. In particular, the supported extensions
+include OpenMP, Cray-style pointers, and several Fortran 2003 features
+such as enumeration, stream I/O, and some of the enhancements to
+allocatable array support from TR 15581. However, it is still under
+development and has a few remaining rough edges.
+
+At present, the GNU Fortran compiler passes the
+@uref{http://www.fortran-2000.com/ArnaudRecipes/fcvs21_f95.html,
+NIST Fortran 77 Test Suite}, and produces acceptable results on the
+@uref{http://www.netlib.org/lapack/faq.html#1.21, LAPACK Test Suite}.
+It also provides respectable performance on
+the @uref{http://www.polyhedron.com/pb05.html, Polyhedron Fortran
+compiler benchmarks} and the
+@uref{http://www.llnl.gov/asci_benchmarks/asci/limited/lfk/README.html,
+Livermore Fortran Kernels test}. It has been used to compile a number of
+large real-world programs, including
+@uref{http://mysite.verizon.net/serveall/moene.pdf, the HIRLAM
+weather-forecasting code} and
+@uref{http://www.theochem.uwa.edu.au/tonto/, the Tonto quantum
+chemistry package}.
+
+Among other things, the GNU Fortran compiler is intended as a replacement
+for G77. At this point, nearly all programs that could be compiled with
+G77 can be compiled with GNU Fortran, although there are a few minor known
+regressions.
+
+The primary work remaining to be done on GNU Fortran falls into three
+categories: bug fixing (primarily regarding the treatment of invalid code
+and providing useful error messages), improving the compiler optimizations
+and the performance of compiled code, and extending the compiler to support
+future standards -- in particular, Fortran 2003.
-The IO library is in a mostly usable state. Unformatted I/O for
-@code{REAL(KIND=10)} variables is currently not recommended.
-
-Array intrinsics mostly work.
@node Proposed Extensions
@section Proposed Extensions
-Here's a list of proposed extensions for @command{gfortran}, in no particular
+Here's a list of proposed extensions for the GNU Fortran compiler, in no particular
order. Most of these are necessary to be fully compatible with
existing Fortran compilers, but they are not part of the official
J3 Fortran 95 standard.
@subsection Compiler extensions:
@itemize @bullet
@item
-Flag for defining the kind number for default logicals.
-
-@item
User-specified alignment rules for structures.
+
@item
Flag to generate @code{Makefile} info.
module storage either on stack or heap.
@item
-Flag to cause the compiler to distinguish between upper and lower case
-names. The Fortran 95 standard does not distinguish them.
-
-@item
Compile flag to generate code for array conformance checking (suggest -CC).
@item
Flag to force local variables onto stack.
@item
-Flag to compile lines beginning with ``D''.
-
-@item
-Flag to ignore lines beginning with ``D''.
-
-@item
Flag for maximum errors before ending compile.
@item
-Generate code to check for null pointer dereferences -- prints locus of
-dereference instead of segfaulting. There was some discussion about this
-option in the g95 development mailing list.
-
-@item
-Allow setting the default unit number.
-
-@item
Option to initialize otherwise uninitialized integer and floating
point variables.
-
-@item
-Support for OpenMP directives. This also requires support from the runtime
-library and the rest of the compiler.
-
-@item
-Support for Fortran 200x. This includes several new features including
-floating point exceptions, extended use of allocatable arrays, C
-interoperability, Parameterizer data types and function pointers.
@end itemize
@item
Environment variable forcing standard output to be line buffered (unix).
-@item
-Variable for swapping endianness during unformatted read.
+@end itemize
-@item
-Variable for swapping Endianness during unformatted write.
+
+@c ---------------------------------------------------------------------
+@c Runtime
+@c ---------------------------------------------------------------------
+
+@node Runtime
+@chapter Runtime: Influencing runtime behavior with environment variables
+@cindex Runtime
+
+The behavior of the @command{gfortran} can be influenced by
+environment variables.
+
+Malformed environment variables are silently ignored.
+
+@menu
+* GFORTRAN_STDIN_UNIT:: Unit number for standard input
+* GFORTRAN_STDOUT_UNIT:: Unit number for standard output
+* GFORTRAN_STDERR_UNIT:: Unit number for standard error
+* GFORTRAN_USE_STDERR:: Send library output to standard error
+* GFORTRAN_TMPDIR:: Directory for scratch files
+* GFORTRAN_UNBUFFERED_ALL:: Don't buffer output
+* GFORTRAN_SHOW_LOCUS:: Show location for runtime errors
+* GFORTRAN_OPTIONAL_PLUS:: Print leading + where permitted
+* GFORTRAN_DEFAULT_RECL:: Default record length for new files
+* GFORTRAN_LIST_SEPARATOR:: Separator for list output
+* GFORTRAN_CONVERT_UNIT:: Set endianness for unformatted I/O
+@end menu
+
+@node GFORTRAN_STDIN_UNIT
+@section @env{GFORTRAN_STDIN_UNIT}---Unit number for standard input
+
+This environment variable can be used to select the unit number
+preconnected to standard input. This must be a positive integer.
+The default value is 5.
+
+@node GFORTRAN_STDOUT_UNIT
+@section @env{GFORTRAN_STDOUT_UNIT}---Unit number for standard output
+
+This environment variable can be used to select the unit number
+preconnected to standard output. This must be a positive integer.
+The default value is 6.
+
+@node GFORTRAN_STDERR_UNIT
+@section @env{GFORTRAN_STDERR_UNIT}---Unit number for standard error
+
+This environment variable can be used to select the unit number
+preconnected to standard error. This must be a positive integer.
+The default value is 0.
+
+@node GFORTRAN_USE_STDERR
+@section @env{GFORTRAN_USE_STDERR}---Send library output to standard error
+
+This environment variable controls where library output is sent.
+If the first letter is @samp{y}, @samp{Y} or @samp{1}, standard
+error is used. If the first letter is @samp{n}, @samp{N} or
+@samp{0}, standard output is used.
+
+@node GFORTRAN_TMPDIR
+@section @env{GFORTRAN_TMPDIR}---Directory for scratch files
+
+This environment variable controls where scratch files are
+created. If this environment variable is missing,
+GNU Fortran searches for the environment variable @env{TMP}. If
+this is also missing, the default is @file{/tmp}.
+
+@node GFORTRAN_UNBUFFERED_ALL
+@section @env{GFORTRAN_UNBUFFERED_ALL}---Don't buffer output
+
+This environment variable controls whether all output is unbuffered.
+If the first letter is @samp{y}, @samp{Y} or @samp{1}, all output is
+unbuffered. This will slow down large writes. If the first letter is
+@samp{n}, @samp{N} or @samp{0}, output is buffered. This is the
+default.
+
+@node GFORTRAN_SHOW_LOCUS
+@section @env{GFORTRAN_SHOW_LOCUS}---Show location for runtime errors
+
+If the first letter is @samp{y}, @samp{Y} or @samp{1}, filename and
+line numbers for runtime errors are printed. If the first letter is
+@samp{n}, @samp{N} or @samp{0}, don't print filename and line numbers
+for runtime errors. The default is to print the location.
+
+@node GFORTRAN_OPTIONAL_PLUS
+@section @env{GFORTRAN_OPTIONAL_PLUS}---Print leading + where permitted
+
+If the first letter is @samp{y}, @samp{Y} or @samp{1},
+a plus sign is printed
+where permitted by the Fortran standard. If the first letter
+is @samp{n}, @samp{N} or @samp{0}, a plus sign is not printed
+in most cases. Default is not to print plus signs.
+
+@node GFORTRAN_DEFAULT_RECL
+@section @env{GFORTRAN_DEFAULT_RECL}---Default record length for new files
+
+This environment variable specifies the default record length for
+files which are opened without a @code{RECL} tag in the @code{OPEN}
+statement. This must be a positive integer. The default value is
+1073741824.
+
+@node GFORTRAN_LIST_SEPARATOR
+@section @env{GFORTRAN_LIST_SEPARATOR}---Separator for list output
+
+This environment variable specifies the separator when writing
+list-directed output. It may contain any number of spaces and
+at most one comma. If you specify this on the command line,
+be sure to quote spaces, as in
+@smallexample
+$ GFORTRAN_LIST_SEPARATOR=' , ' ./a.out
+@end smallexample
+when @code{a.out} is the compiled Fortran program that you want to run.
+Default is a single space.
+
+@node GFORTRAN_CONVERT_UNIT
+@section @env{GFORTRAN_CONVERT_UNIT}---Set endianness for unformatted I/O
+
+By setting the @env{GFORTRAN_CONVERT_UNIT} variable, it is possible
+to change the representation of data for unformatted files.
+The syntax for the @env{GFORTRAN_CONVERT_UNIT} variable is:
+@smallexample
+GFORTRAN_CONVERT_UNIT: mode | mode ';' exception ;
+mode: 'native' | 'swap' | 'big_endian' | 'little_endian' ;
+exception: mode ':' unit_list | unit_list ;
+unit_list: unit_spec | unit_list unit_spec ;
+unit_spec: INTEGER | INTEGER '-' INTEGER ;
+@end smallexample
+The variable consists of an optional default mode, followed by
+a list of optional exceptions, which are separated by semicolons
+from the preceding default and each other. Each exception consists
+of a format and a comma-separated list of units. Valid values for
+the modes are the same as for the @code{CONVERT} specifier:
+
+@itemize @w{}
+@item @code{NATIVE} Use the native format. This is the default.
+@item @code{SWAP} Swap between little- and big-endian.
+@item @code{LITTLE_ENDIAN} Use the little-endian format
+ for unformatted files.
+@item @code{BIG_ENDIAN} Use the big-endian format for unformatted files.
@end itemize
+A missing mode for an exception is taken to mean @code{BIG_ENDIAN}.
+Examples of values for @code{GFORTRAN_CONVERT_UNIT} are:
+@itemize @w{}
+@item @code{'big_endian'} Do all unformatted I/O in big_endian mode.
+@item @code{'little_endian;native:10-20,25'} Do all unformatted I/O
+in little_endian mode, except for units 10 to 20 and 25, which are in
+native format.
+@item @code{'10-20'} Units 10 to 20 are big-endian, the rest is native.
+@end itemize
+
+Setting the environment variables should be done on the command
+line or via the @code{export}
+command for @code{sh}-compatible shells and via @code{setenv}
+for @code{csh}-compatible shells.
+
+Example for @code{sh}:
+@smallexample
+$ gfortran foo.f90
+$ GFORTRAN_CONVERT_UNIT='big_endian;native:10-20' ./a.out
+@end smallexample
+
+Example code for @code{csh}:
+@smallexample
+% gfortran foo.f90
+% setenv GFORTRAN_CONVERT_UNIT 'big_endian;native:10-20'
+% ./a.out
+@end smallexample
+
+Using anything but the native representation for unformatted data
+carries a significant speed overhead. If speed in this area matters
+to you, it is best if you use this only for data that needs to be
+portable.
+
+@xref{CONVERT specifier}, for an alternative way to specify the
+data representation for unformatted files. @xref{Runtime Options}, for
+setting a default data representation for the whole program. The
+@code{CONVERT} specifier overrides the @code{-fconvert} compile options.
@c ---------------------------------------------------------------------
@c Extensions
@chapter Extensions
@cindex Extension
-@command{gfortran} implements a number of extensions over standard
+GNU Fortran implements a number of extensions over standard
Fortran. This chapter contains information on their syntax and
-meaning. There are currently two categories of @command{gfortran}
+meaning. There are currently two categories of GNU Fortran
extensions, those that provide functionality beyond that provided
-by any standard, and those that are supported by @command{gfortran}
+by any standard, and those that are supported by GNU Fortran
purely for backward compatibility with legacy compilers. By default,
@option{-std=gnu} allows the compiler to accept both types of
extensions, but to warn about the use of the latter. Specifying
* Extensions to namelist::
* X format descriptor::
* Commas in FORMAT specifications::
+* Missing period in FORMAT specifications::
* I/O item lists::
* Hexadecimal constants::
* Real array indices::
* Implicitly interconvert LOGICAL and INTEGER::
* Hollerith constants support::
* Cray pointers::
+* CONVERT specifier::
+* OpenMP::
@end menu
@node Old-style kind specifications
@section Old-style kind specifications
@cindex Kind specifications
-@command{gfortran} allows old-style kind specifications in
+GNU Fortran allows old-style kind specifications in
declarations. These look like:
@smallexample
TYPESPEC*k x,y,z
@section Old-style variable initialization
@cindex Initialization
-@command{gfortran} allows old-style initialization of variables of the
+GNU Fortran allows old-style initialization of variables of the
form:
@smallexample
INTEGER*4 i/1/,j/2/
DATA i,j,x /1,2,3*0.,1./
@end smallexample
+Note that variables initialized in type declarations
+automatically acquire the @code{SAVE} attribute.
+
@node Extensions to namelist
@section Extensions to namelist
@cindex Namelist
-@command{gfortran} fully supports the Fortran 95 standard for namelist I/O
+GNU Fortran fully supports the Fortran 95 standard for namelist I/O
including array qualifiers, substrings and fully qualified derived types.
The output from a namelist write is compatible with namelist read. The
output has all names in upper case and indentation to column 1 after the
END PROGRAM test_print
@end smallexample
+Expanded namelist reads are permitted. This causes an error if -std=f95
+is used. In the following example, the first element of the array will be
+given the value 0.00 and succeeding elements will be 1.00 and 2.00.
+@smallexample
+&MYNML
+ X(1,1) = 0.00 , 1.00 , 2.00
+/
+@end smallexample
+
@node X format descriptor
@section X format descriptor
@cindex X format descriptor
-To support legacy codes, @command{gfortran} permits the count field
+To support legacy codes, GNU Fortran permits the count field
of the X edit descriptor in FORMAT statements to be omitted. When
omitted, the count is implicitly assumed to be one.
@section Commas in FORMAT specifications
@cindex Commas in FORMAT specifications
-To support legacy codes, @command{gfortran} allows the comma separator
+To support legacy codes, GNU Fortran allows the comma separator
to be omitted immediately before and after character string edit
descriptors in FORMAT statements.
10 FORMAT ('FOO='I1' BAR='I2)
@end smallexample
+
+@node Missing period in FORMAT specifications
+@section Missing period in FORMAT specifications
+@cindex Missing period in FORMAT specifications
+
+To support legacy codes, GNU Fortran allows missing periods in format
+specifications if and only if -std=legacy is given on the command line. This
+is considered non-conforming code and is discouraged.
+
+@smallexample
+ REAL :: value
+ READ(*,10) value
+10 FORMAT ('F4')
+@end smallexample
+
@node I/O item lists
@section I/O item lists
@cindex I/O item lists
-To support legacy codes, @command{gfortran} allows the input item list
+To support legacy codes, GNU Fortran allows the input item list
of the READ statement, and the output item lists of the WRITE and PRINT
statements to start with a comma.
@section Hexadecimal constants
@cindex Hexadecimal constants
-As a GNU extension, @command{gfortran} allows hexadecimal constants to
+As an extension, GNU Fortran allows hexadecimal constants to
be specified using the X prefix, in addition to the standard Z prefix.
+BOZ literal constants can also be specified by adding a suffix to the string.
+For example, @code{Z'ABC'} and @code{'ABC'Z} are the same constant.
+
+The Fortran standard restricts the appearance of a BOZ literal constant to
+the @code{DATA} statement, and it is expected to be assigned to an
+@code{INTEGER} variable. GNU Fortran permits a BOZ literal to appear
+in any initialization expression as well as assignment statements.
+
+Attempts to use a BOZ literal constant to do a bitwise initialization of a
+variable can lead to confusion. A BOZ literal constant is converted to an
+@code{INTEGER} value with the kind type with the largest decimal representation,
+and this value is then converted numerically to the type and kind of the
+variable in question. Thus, one should not expect a bitwise copy of the BOZ
+literal constant to be assigned to a @code{REAL} variable.
+
+Similarly, initializing an @code{INTEGER} variable with a statement such as
+@code{DATA i/Z'FFFFFFFF'/} will produce an integer overflow rather than the
+desired result of @math{-1} when @code{i} is a 32-bit integer on a system that
+supports 64-bit integers. The @samp{-fno-range-check} option can be used as
+a workaround for legacy code that initializes integers in this manner.
+
@node Real array indices
@section Real array indices
@cindex Real array indices
-As a GNU extension, @command{gfortran} allows arrays to be indexed using
+As an extension, GNU Fortran allows arrays to be indexed using
real types, whose values are implicitly converted to integers.
@node Unary operators
@section Unary operators
@cindex Unary operators
-As a GNU extension, @command{gfortran} allows unary plus and unary
+As an extension, GNU Fortran allows unary plus and unary
minus operators to appear as the second operand of binary arithmetic
operators without the need for parenthesis.
@section Implicitly interconvert LOGICAL and INTEGER
@cindex Implicitly interconvert LOGICAL and INTEGER
-As a GNU extension for backwards compatibility with other compilers,
-@command{gfortran} allows the implicit conversion of LOGICALs to INTEGERs
+As an extension for backwards compatibility with other compilers,
+GNU Fortran allows the implicit conversion of LOGICALs to INTEGERs
and vice versa. When converting from a LOGICAL to an INTEGER, the numeric
value of @code{.FALSE.} is zero, and that of @code{.TRUE.} is one. When
converting from INTEGER to LOGICAL, the value zero is interpreted as
constant indicating the number of characters in the string. Hollerith constants
are stored as byte strings, one character per byte.
-@command{gfortran} supports Hollerith constants. They can be used as the right
+GNU Fortran supports Hollerith constants. They can be used as the right
hands in the @code{DATA} statement and @code{ASSIGN} statement, also as the
arguments. The left hands can be of Integer, Real, Complex and Logical type.
The constant will be padded or truncated to fit the size of left hand.
ipt = loc(ar) ! Makes arpte is an alias for ar
arpte(1) = 1.0 ! Sets ar(1) to 1.0
@end smallexample
-The pointer can also be set by a call to a malloc-type
-function. There is no malloc intrinsic implemented as part of the
-Cray pointer extension, but it might be a useful future addition to
-@command{gfortran}. Even without an intrinsic malloc function,
-dynamic memory allocation can be combined with Cray pointers by
-calling a short C function:
-@smallexample
-mymalloc.c:
-
- void mymalloc_(void **ptr, int *nbytes)
- @{
- *ptr = malloc(*nbytes);
- return;
- @}
-
-caller.f:
-
- program caller
- integer ipinfo;
- real*4 data
- pointer (ipdata, data(1024))
- call mymalloc(ipdata,4*1024)
- end
-@end smallexample
+The pointer can also be set by a call to the @code{MALLOC} intrinsic
+(see @ref{MALLOC}).
+
Cray pointees often are used to alias an existing variable. For
example:
@smallexample
which it shares storage is not used. Code that violates these rules
may not run as the user intends. This is not a bug in the optimizer;
any code that violates the aliasing rules is illegal. (Note that this
-is not unique to gfortran; any Fortran compiler that supports Cray
+is not unique to GNU Fortran; any Fortran compiler that supports Cray
pointers will ``incorrectly'' optimize code with illegal aliasing.)
There are a number of restrictions on the attributes that can be
applied to Cray pointers and pointees. Pointees may not have the
-attributes ALLOCATABLE, INTENT, OPTIONAL, DUMMY, TARGET, EXTERNAL,
+attributes ALLOCATABLE, INTENT, OPTIONAL, DUMMY, TARGET,
INTRINSIC, or POINTER. Pointers may not have the attributes
DIMENSION, POINTER, TARGET, ALLOCATABLE, EXTERNAL, or INTRINSIC.
Pointees may not occur in more than one pointer statement. A pointee
cannot be a pointer. Pointees cannot occur in equivalence, common, or
data statements.
+A Cray pointer may point to a function or a subroutine. For example,
+the following excerpt is valid:
+@smallexample
+ implicit none
+ external sub
+ pointer (subptr,subpte)
+ external subpte
+ subptr = loc(sub)
+ call subpte()
+ [...]
+ subroutine sub
+ [...]
+ end subroutine sub
+@end smallexample
+
A pointer may be modified during the course of a program, and this
will change the location to which the pointee refers. However, when
pointees are passed as arguments, they are treated as ordinary
variables in the invoked function. Subsequent changes to the pointer
will not change the base address of the array that was passed.
+@node CONVERT specifier
+@section CONVERT specifier
+@cindex CONVERT specifier
+
+GNU Fortran allows the conversion of unformatted data between little-
+and big-endian representation to facilitate moving of data
+between different systems. The conversion can be indicated with
+the @code{CONVERT} specifier on the @code{OPEN} statement.
+@xref{GFORTRAN_CONVERT_UNIT}, for an alternative way of specifying
+the data format via an environment variable.
+
+Valid values for @code{CONVERT} are:
+@itemize @w{}
+@item @code{CONVERT='NATIVE'} Use the native format. This is the default.
+@item @code{CONVERT='SWAP'} Swap between little- and big-endian.
+@item @code{CONVERT='LITTLE_ENDIAN'} Use the little-endian representation
+ for unformatted files.
+@item @code{CONVERT='BIG_ENDIAN'} Use the big-endian representation for
+ unformatted files.
+@end itemize
+
+Using the option could look like this:
+@smallexample
+ open(file='big.dat',form='unformatted',access='sequential', &
+ convert='big_endian')
+@end smallexample
+
+The value of the conversion can be queried by using
+@code{INQUIRE(CONVERT=ch)}. The values returned are
+@code{'BIG_ENDIAN'} and @code{'LITTLE_ENDIAN'}.
+
+@code{CONVERT} works between big- and little-endian for
+@code{INTEGER} values of all supported kinds and for @code{REAL}
+on IEEE systems of kinds 4 and 8. Conversion between different
+``extended double'' types on different architectures such as
+m68k and x86_64, which GNU Fortran
+supports as @code{REAL(KIND=10)}, will probably not work.
+
+@emph{Note that the values specified via the GFORTRAN_CONVERT_UNIT
+environment variable will override the CONVERT specifier in the
+open statement}. This is to give control over data formats to
+a user who does not have the source code of his program available.
+
+Using anything but the native representation for unformatted data
+carries a significant speed overhead. If speed in this area matters
+to you, it is best if you use this only for data that needs to be
+portable.
+
+@node OpenMP
+@section OpenMP
+@cindex OpenMP
+
+GNU Fortran attempts to be OpenMP Application Program Interface v2.5
+compatible when invoked with the @code{-fopenmp} option. GNU Fortran
+then generates parallelized code according to the OpenMP directives
+used in the source. The OpenMP Fortran runtime library
+routines are provided both in a form of Fortran 90 module named
+@code{omp_lib} and in a form of a Fortran @code{include} file named
+@code{omp_lib.h}.
+
+For details refer to the actual
+@uref{http://www.openmp.org/drupal/mp-documents/spec25.pdf,
+OpenMP Application Program Interface v2.5} specification.
+
@c ---------------------------------------------------------------------
@include intrinsic.texi
@c ---------------------------------------------------------------------
We're always in need of more people helping out with ideas
and comments, writing documentation and contributing code.
-If you want to contribute to GNU Fortran 95,
+If you want to contribute to GNU Fortran,
have a look at the long lists of projects you can take on.
Some of these projects are small,
some of them are large;
some are completely orthogonal to the rest of what is
-happening on @command{gfortran},
+happening on GNU Fortran,
but others are ``mainstream'' projects in need of enthusiastic hackers.
All of these projects are important!
We'll eventually get around to the things here,
@node Contributors
-@section Contributors to GNU Fortran 95
+@section Contributors to GNU Fortran
@cindex Contributors
@cindex Credits
@cindex Authors
Most of the interface with GCC was written by @emph{Paul Brook}.
The following individuals have contributed code and/or
-ideas and significant help to the gfortran project
-(in no particular order):
+ideas and significant help to the GNU Fortran project
+(in no particular order):
@itemize @minus
@item Andy Vaught
@item Katherine Holcomb
-@item Tobias Schlüter
+@item Tobias Schl@"uter
@item Steven Bosscher
@item Toon Moene
@item Tim Prince
@item Feng Wang
@item Bud Davis
@item Paul Thomas
-@item François-Xavier Coudert
-@item Steve Kargl
+@item Fran@,{c}ois-Xavier Coudert
+@item Steven G. Kargl
@item Jerry Delisle
@item Janne Blomqvist
@item Erik Edelmann
@item Thomas Koenig
@item Asher Langton
+@item Jakub Jelinek
+@item Roger Sayle
+@item H.J. Lu
+@item Richard Henderson
+@item Richard Sandiford
+@item Richard Guenther
+@item Bernhard Fischer
@end itemize
The following people have contributed bug reports,
smaller or larger patches,
and much needed feedback and encouragement for the
-@command{gfortran} project:
+GNU Fortran project:
@itemize @minus
@item Erik Schnetter
@end itemize
Many other individuals have helped debug,
-test and improve @command{gfortran} over the past few years,
+test and improve the GNU Fortran compiler over the past few years,
and we welcome you to do the same!
If you already have done so,
and you would like to see your name listed in the
@chapter Standards
@cindex Standards
-The GNU Fortran 95 Compiler aims to be a conforming implementation of
-ISO/IEC 1539:1997 (Fortran 95).
+The GNU Fortran compiler implements
+ISO/IEC 1539:1997 (Fortran 95). As such, it can also compile essentially all
+standard-compliant Fortran 90 and Fortran 77 programs. It also supports
+the ISO/IEC TR-15581 enhancements to allocatable arrays, and
+the @uref{http://www.openmp.org/drupal/mp-documents/spec25.pdf,
+OpenMP Application Program Interface v2.5} specification.
-In the future it may also support other variants of and extensions to
-the Fortran language. These include ANSI Fortran 77, ISO Fortran 90,
-ISO Fortran 2003 and OpenMP.
+In the future, the GNU Fortran compiler may also support other standard
+variants of and extensions to the Fortran language. These include
+ISO/IEC 1539-1:2004 (Fortran 2003).
@menu
* Fortran 2003 status::
@node Fortran 2003 status
@section Fortran 2003 status
-Although @command{gfortran} focuses on implementing the Fortran 95
+Although GNU Fortran focuses on implementing the Fortran 95
standard for the time being, a few Fortran 2003 features are currently
available.
@itemize
@item
Intrinsics @code{command_argument_count}, @code{get_command},
-@code{get_command_argument}, and @code{get_environment_variable}.
+@code{get_command_argument}, @code{get_environment_variable}, and
+@code{move_alloc}.
@item
@cindex Array constructors
@command{gcc} is guaranteed also for the case where the
@command{-fshort-enums} command line option is given.
+@item
+@cindex TR 15581
+TR 15581:
+@itemize
+@item
+@cindex @code{ALLOCATABLE} dummy arguments
+@code{ALLOCATABLE} dummy arguments.
+@item
+@cindex @code{ALLOCATABLE} function results
+@code{ALLOCATABLE} function results
+@item
+@cindex @code{ALLOCATABLE} components of derived types
+@code{ALLOCATABLE} components of derived types
+@end itemize
+
+@item
+@cindex @code{STREAM} I/O
+@cindex @code{ACCESS='STREAM'} I/O
+The @code{OPEN} statement supports the @code{ACCESS='STREAM'} specifier,
+allowing I/O without any record structure.
+
+
+
@end itemize