blob: af07f9982b3af3c019900d9698c1f1ccf91e4923 [file] [log] [blame]
This is doc/gfortran.info, produced by makeinfo version 4.7 from
../../gcc-4.5.3/gcc/fortran/gfortran.texi.
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
2008, 2009, 2010 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover Texts
being (a) (see below), and with the Back-Cover Texts being (b) (see
below). A copy of the license is included in the section entitled "GNU
Free Documentation License".
(a) The FSF's Front-Cover Text is:
A GNU Manual
(b) The FSF's Back-Cover Text is:
You have freedom to copy and modify this GNU Manual, like GNU
software. Copies published by the Free Software Foundation raise
funds for GNU development.
INFO-DIR-SECTION Software development
START-INFO-DIR-ENTRY
* gfortran: (gfortran). The GNU Fortran Compiler.
END-INFO-DIR-ENTRY
This file documents the use and the internals of the GNU Fortran
compiler, (`gfortran').
Published by the Free Software Foundation 51 Franklin Street, Fifth
Floor Boston, MA 02110-1301 USA
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
2008, 2009, 2010 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover Texts
being (a) (see below), and with the Back-Cover Texts being (b) (see
below). A copy of the license is included in the section entitled "GNU
Free Documentation License".
(a) The FSF's Front-Cover Text is:
A GNU Manual
(b) The FSF's Back-Cover Text is:
You have freedom to copy and modify this GNU Manual, like GNU
software. Copies published by the Free Software Foundation raise
funds for GNU development.

File: gfortran.info, Node: Top, Next: Introduction, Up: (dir)
Introduction
************
This manual documents the use of `gfortran', the GNU Fortran compiler.
You can find in this manual how to invoke `gfortran', as well as its
features and incompatibilities.
* Menu:
* Introduction::
Part I: Invoking GNU Fortran
* Invoking GNU Fortran:: Command options supported by `gfortran'.
* Runtime:: Influencing runtime behavior with environment variables.
Part II: Language Reference
* Fortran 2003 and 2008 status:: Fortran 2003 and 2008 features supported by GNU Fortran.
* Compiler Characteristics:: User-visible implementation details.
* Mixed-Language Programming:: Interoperability with C
* Extensions:: Language extensions implemented by GNU Fortran.
* Intrinsic Procedures:: Intrinsic procedures supported by GNU Fortran.
* Intrinsic Modules:: Intrinsic modules supported by GNU Fortran.
* Contributing:: How you can help.
* Copying:: GNU General Public License says
how you can copy and share GNU Fortran.
* GNU Free Documentation License::
How you can copy and share this manual.
* Funding:: How to help assure continued work for free software.
* Option Index:: Index of command line options
* Keyword Index:: Index of concepts

File: gfortran.info, Node: Introduction, Next: Invoking GNU Fortran, Prev: Top, Up: Top
1 Introduction
**************
The GNU Fortran compiler front end was designed initially as a free
replacement for, or alternative to, the unix `f95' command; `gfortran'
is the command you'll use to invoke the compiler.
* Menu:
* About GNU Fortran:: What you should know about the GNU Fortran compiler.
* GNU Fortran and GCC:: You can compile Fortran, C, or other programs.
* Preprocessing and conditional compilation:: The Fortran preprocessor
* GNU Fortran and G77:: Why we chose to start from scratch.
* Project Status:: Status of GNU Fortran, roadmap, proposed extensions.
* Standards:: Standards supported by GNU Fortran.

File: gfortran.info, Node: About GNU Fortran, Next: GNU Fortran and GCC, Up: Introduction
1.1 About GNU Fortran
=====================
The GNU Fortran compiler supports the Fortran 77, 90 and 95 standards
completely, parts of the Fortran 2003 and Fortran 2008 standards, and
several vendor extensions. The development goal is to provide the
following features:
* Read a user's program, stored in a file and containing
instructions written in Fortran 77, Fortran 90, Fortran 95,
Fortran 2003 or Fortran 2008. This file contains "source code".
* Translate the user's program into instructions a computer can
carry out more quickly than it takes to translate the instructions
in the first place. The result after compilation of a program is
"machine code", code designed to be efficiently translated and
processed by a machine such as your computer. Humans usually
aren't as good writing machine code as they are at writing Fortran
(or C++, Ada, or Java), because it is easy to make tiny mistakes
writing machine code.
* Provide the user with information about the reasons why the
compiler is unable to create a binary from the source code.
Usually this will be the case if the source code is flawed. The
Fortran 90 standard requires that the compiler can point out
mistakes to the user. An incorrect usage of the language causes
an "error message".
The compiler will also attempt to diagnose cases where the user's
program contains a correct usage of the language, but instructs
the computer to do something questionable. This kind of
diagnostics message is called a "warning message".
* Provide optional information about the translation passes from the
source code to machine code. This can help a user of the compiler
to find the cause of certain bugs which may not be obvious in the
source code, but may be more easily found at a lower level
compiler output. It also helps developers to find bugs in the
compiler itself.
* Provide information in the generated machine code that can make it
easier to find bugs in the program (using a debugging tool, called
a "debugger", such as the GNU Debugger `gdb').
* Locate and gather machine code already generated to perform
actions requested by statements in the user's program. This
machine code is organized into "modules" and is located and
"linked" to the user program.
The GNU Fortran compiler consists of several components:
* A version of the `gcc' command (which also might be installed as
the system's `cc' command) that also understands and accepts
Fortran source code. The `gcc' command is the "driver" program for
all the languages in the GNU Compiler Collection (GCC); With `gcc',
you can compile the source code of any language for which a front
end is available in GCC.
* The `gfortran' command itself, which also might be installed as the
system's `f95' command. `gfortran' is just another driver program,
but specifically for the Fortran compiler only. The difference
with `gcc' is that `gfortran' will automatically link the correct
libraries to your program.
* A collection of run-time libraries. These libraries contain the
machine code needed to support capabilities of the Fortran
language that are not directly provided by the machine code
generated by the `gfortran' compilation phase, such as intrinsic
functions and subroutines, and routines for interaction with files
and the operating system.
* The Fortran compiler itself, (`f951'). This is the GNU Fortran
parser and code generator, linked to and interfaced with the GCC
backend library. `f951' "translates" the source code to assembler
code. You would typically not use this program directly; instead,
the `gcc' or `gfortran' driver programs will call it for you.

File: gfortran.info, Node: GNU Fortran and GCC, Next: Preprocessing and conditional compilation, Prev: About GNU Fortran, Up: Introduction
1.2 GNU Fortran and GCC
=======================
GNU Fortran is a part of GCC, the "GNU Compiler Collection". GCC
consists of a collection of front ends for various languages, which
translate the source code into a language-independent form called
"GENERIC". This is then processed by a common middle end which
provides optimization, and then passed to one of a collection of back
ends which generate code for different computer architectures and
operating systems.
Functionally, this is implemented with a driver program (`gcc')
which provides the command-line interface for the compiler. It calls
the relevant compiler front-end program (e.g., `f951' for Fortran) for
each file in the source code, and then calls the assembler and linker
as appropriate to produce the compiled output. In a copy of GCC which
has been compiled with Fortran language support enabled, `gcc' will
recognize files with `.f', `.for', `.ftn', `.f90', `.f95', `.f03' and
`.f08' extensions as Fortran source code, and compile it accordingly. A
`gfortran' driver program is also provided, which is identical to `gcc'
except that it automatically links the Fortran runtime libraries into
the compiled program.
Source files with `.f', `.for', `.fpp', `.ftn', `.F', `.FOR',
`.FPP', and `.FTN' extensions are treated as fixed form. Source files
with `.f90', `.f95', `.f03', `.f08', `.F90', `.F95', `.F03' and `.F08'
extensions are treated as free form. The capitalized versions of
either form are run through preprocessing. Source files with the lower
case `.fpp' extension are also run through preprocessing.
This manual specifically documents the Fortran front end, which
handles the programming language's syntax and semantics. The aspects
of GCC which relate to the optimization passes and the back-end code
generation are documented in the GCC manual; see *Note Introduction:
(gcc)Top. The two manuals together provide a complete reference for
the GNU Fortran compiler.

File: gfortran.info, Node: Preprocessing and conditional compilation, Next: GNU Fortran and G77, Prev: GNU Fortran and GCC, Up: Introduction
1.3 Preprocessing and conditional compilation
=============================================
Many Fortran compilers including GNU Fortran allow passing the source
code through a C preprocessor (CPP; sometimes also called the Fortran
preprocessor, FPP) to allow for conditional compilation. In the case of
GNU Fortran, this is the GNU C Preprocessor in the traditional mode. On
systems with case-preserving file names, the preprocessor is
automatically invoked if the filename extension is `.F', `.FOR',
`.FTN', `.fpp', `.FPP', `.F90', `.F95', `.F03' or `.F08'. To manually
invoke the preprocessor on any file, use `-cpp', to disable
preprocessing on files where the preprocessor is run automatically, use
`-nocpp'.
If a preprocessed file includes another file with the Fortran
`INCLUDE' statement, the included file is not preprocessed. To
preprocess included files, use the equivalent preprocessor statement
`#include'.
If GNU Fortran invokes the preprocessor, `__GFORTRAN__' is defined
and `__GNUC__', `__GNUC_MINOR__' and `__GNUC_PATCHLEVEL__' can be used
to determine the version of the compiler. See *Note Overview: (cpp)Top.
for details.
While CPP is the de-facto standard for preprocessing Fortran code,
Part 3 of the Fortran 95 standard (ISO/IEC 1539-3:1998) defines
Conditional Compilation, which is not widely used and not directly
supported by the GNU Fortran compiler. You can use the program coco to
preprocess such files (`http://users.erols.com/dnagle/coco.html').

File: gfortran.info, Node: GNU Fortran and G77, Next: Project Status, Prev: Preprocessing and conditional compilation, Up: Introduction
1.4 GNU Fortran and G77
=======================
The GNU Fortran compiler is the successor to `g77', the Fortran 77
front end included in GCC prior to version 4. It is an entirely new
program that has been designed to provide Fortran 95 support and
extensibility for future Fortran language standards, as well as
providing backwards compatibility for Fortran 77 and nearly all of the
GNU language extensions supported by `g77'.

File: gfortran.info, Node: Project Status, Next: Standards, Prev: GNU Fortran and G77, Up: Introduction
1.5 Project Status
==================
As soon as `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, we'll see if it will be a
beautiful butterfly, or just a big bug....
-Andy Vaught, April 2000
The start of the GNU Fortran 95 project was announced on the GCC
homepage in March 18, 2000 (even though Andy had already been working
on it for a while, of course).
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 and
Fortran 2008 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 NIST Fortran 77 Test
Suite (http://www.fortran-2000.com/ArnaudRecipes/fcvs21_f95.html), and
produces acceptable results on the LAPACK Test Suite
(http://www.netlib.org/lapack/faq.html#1.21). It also provides
respectable performance on the Polyhedron Fortran compiler benchmarks
(http://www.polyhedron.com/pb05.html) and the Livermore Fortran Kernels
test
(http://www.llnl.gov/asci_benchmarks/asci/limited/lfk/README.html). It
has been used to compile a number of large real-world programs,
including the HIRLAM weather-forecasting code
(http://mysite.verizon.net/serveall/moene.pdf) and the Tonto quantum
chemistry package (http://www.theochem.uwa.edu.au/tonto/); see
`http://gcc.gnu.org/wiki/GfortranApps' for an extended list.
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 and
Fortran 2008.

File: gfortran.info, Node: Standards, Prev: Project Status, Up: Introduction
1.6 Standards
=============
* Menu:
* Varying Length Character Strings::
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 OpenMP Application Program
Interface v2.5 (http://www.openmp.org/drupal/mp-documents/spec25.pdf)
specification.
In the future, the GNU Fortran compiler will also support ISO/IEC
1539-1:2004 (Fortran 2003) and future Fortran standards. Partial support
of that standard is already provided; the current status of Fortran 2003
support is reported in the *Note Fortran 2003 status:: section of the
documentation.
The next version of the Fortran standard (Fortran 2008) is currently
being developed and the GNU Fortran compiler supports some of its new
features. This support is based on the latest draft of the standard
(available from `http://www.nag.co.uk/sc22wg5/') and no guarantee of
future compatibility is made, as the final standard might differ from
the draft. For more information, see the *Note Fortran 2008 status::
section.
Additionally, the GNU Fortran compilers supports the OpenMP
specification (version 3.0,
`http://openmp.org/wp/openmp-specifications/').

File: gfortran.info, Node: Varying Length Character Strings, Up: Standards
1.6.1 Varying Length Character Strings
--------------------------------------
The Fortran 95 standard specifies in Part 2 (ISO/IEC 1539-2:2000)
varying length character strings. While GNU Fortran currently does not
support such strings directly, there exist two Fortran implementations
for them, which work with GNU Fortran. They can be found at
`http://www.fortran.com/iso_varying_string.f95' and at
`ftp://ftp.nag.co.uk/sc22wg5/ISO_VARYING_STRING/'.

File: gfortran.info, Node: Invoking GNU Fortran, Next: Runtime, Prev: Introduction, Up: Top
2 GNU Fortran Command Options
*****************************
The `gfortran' command supports all the options supported by the `gcc'
command. Only options specific to GNU Fortran are documented here.
*Note GCC Command Options: (gcc)Invoking GCC, for information on the
non-Fortran-specific aspects of the `gcc' command (and, therefore, the
`gfortran' command).
All GCC and GNU Fortran options are accepted both by `gfortran' and
by `gcc' (as well as any other drivers built at the same time, such as
`g++'), since adding GNU Fortran to the GCC distribution enables
acceptance of GNU Fortran options by all of the relevant drivers.
In some cases, options have positive and negative forms; the
negative form of `-ffoo' would be `-fno-foo'. This manual documents
only one of these two forms, whichever one is not the default.
* Menu:
* Option Summary:: Brief list of all `gfortran' options,
without explanations.
* Fortran Dialect Options:: Controlling the variant of Fortran language
compiled.
* Preprocessing Options:: Enable and customize preprocessing.
* Error and Warning Options:: How picky should the compiler be?
* Debugging Options:: Symbol tables, measurements, and debugging dumps.
* Directory Options:: Where to find module files
* Link Options :: Influencing the linking step
* Runtime Options:: Influencing runtime behavior
* Code Gen Options:: Specifying conventions for function calls, data layout
and register usage.
* Environment Variables:: Environment variables that affect `gfortran'.

File: gfortran.info, Node: Option Summary, Next: Fortran Dialect Options, Up: Invoking GNU Fortran
2.1 Option summary
==================
Here is a summary of all the options specific to GNU Fortran, grouped
by type. Explanations are in the following sections.
_Fortran Language Options_
*Note Options controlling Fortran dialect: Fortran Dialect Options.
-fall-intrinsics -ffree-form -fno-fixed-form
-fdollar-ok -fimplicit-none -fmax-identifier-length
-std=STD -fd-lines-as-code -fd-lines-as-comments
-ffixed-line-length-N -ffixed-line-length-none
-ffree-line-length-N -ffree-line-length-none
-fdefault-double-8 -fdefault-integer-8 -fdefault-real-8
-fcray-pointer -fopenmp -fno-range-check -fbackslash -fmodule-private
_Preprocessing Options_
*Note Enable and customize preprocessing: Preprocessing Options.
-cpp -dD -dI -dM -dN -dU -fworking-directory
-imultilib DIR -iprefix FILE -isysroot DIR
-iquote -isystem DIR -nocpp -nostdinc -undef
-AQUESTION=ANSWER -A-QUESTION[=ANSWER]
-C -CC -DMACRO[=DEFN] -UMACRO -H -P
_Error and Warning Options_
*Note Options to request or suppress errors and warnings: Error
and Warning Options.
-fmax-errors=N
-fsyntax-only -pedantic -pedantic-errors
-Wall -Waliasing -Wampersand -Warray-bounds -Wcharacter-truncation
-Wconversion -Wimplicit-interface -Wimplicit-procedure -Wline-truncation
-Wintrinsics-std -Wsurprising -Wno-tabs -Wunderflow -Wunused-parameter
-Wintrinsics-shadow -Wno-align-commons
_Debugging Options_
*Note Options for debugging your program or GNU Fortran: Debugging
Options.
-fdump-parse-tree -ffpe-trap=LIST
-fdump-core -fbacktrace
_Directory Options_
*Note Options for directory search: Directory Options.
-IDIR -JDIR -fintrinsic-modules-path DIR
_Link Options_
*Note Options for influencing the linking step: Link Options.
-static-libgfortran
_Runtime Options_
*Note Options for influencing runtime behavior: Runtime Options.
-fconvert=CONVERSION -fno-range-check
-frecord-marker=LENGTH -fmax-subrecord-length=LENGTH
-fsign-zero
_Code Generation Options_
*Note Options for code generation conventions: Code Gen Options.
-fno-automatic -ff2c -fno-underscoring
-fwhole-file -fsecond-underscore
-fbounds-check -fcheck-array-temporaries -fmax-array-constructor =N
-fcheck=<ALL|ARRAY-TEMPS|BOUNDS|DO|MEM|POINTER|RECURSION>
-fmax-stack-var-size=N
-fpack-derived -frepack-arrays -fshort-enums -fexternal-blas
-fblas-matmul-limit=N -frecursive -finit-local-zero
-finit-integer=N -finit-real=<ZERO|INF|-INF|NAN|SNAN>
-finit-logical=<TRUE|FALSE> -finit-character=N
-fno-align-commons -fno-protect-parens
* Menu:
* Fortran Dialect Options:: Controlling the variant of Fortran language
compiled.
* Preprocessing Options:: Enable and customize preprocessing.
* Error and Warning Options:: How picky should the compiler be?
* Debugging Options:: Symbol tables, measurements, and debugging dumps.
* Directory Options:: Where to find module files
* Link Options :: Influencing the linking step
* Runtime Options:: Influencing runtime behavior
* Code Gen Options:: Specifying conventions for function calls, data layout
and register usage.

File: gfortran.info, Node: Fortran Dialect Options, Next: Preprocessing Options, Prev: Option Summary, Up: Invoking GNU Fortran
2.2 Options controlling Fortran dialect
=======================================
The following options control the details of the Fortran dialect
accepted by the compiler:
`-ffree-form'
`-ffixed-form'
Specify the layout used by the source file. The free form layout
was introduced in Fortran 90. Fixed form was traditionally used in
older Fortran programs. When neither option is specified, the
source form is determined by the file extension.
`-fall-intrinsics'
This option causes all intrinsic procedures (including the
GNU-specific extensions) to be accepted. This can be useful with
`-std=f95' to force standard-compliance but get access to the full
range of intrinsics available with `gfortran'. As a consequence,
`-Wintrinsics-std' will be ignored and no user-defined procedure
with the same name as any intrinsic will be called except when it
is explicitly declared `EXTERNAL'.
`-fd-lines-as-code'
`-fd-lines-as-comments'
Enable special treatment for lines beginning with `d' or `D' in
fixed form sources. If the `-fd-lines-as-code' option is given
they are treated as if the first column contained a blank. If the
`-fd-lines-as-comments' option is given, they are treated as
comment lines.
`-fdefault-double-8'
Set the `DOUBLE PRECISION' type to an 8 byte wide type. If
`-fdefault-real-8' is given, `DOUBLE PRECISION' would instead be
promoted to 16 bytes if possible, and `-fdefault-double-8' can be
used to prevent this. The kind of real constants like `1.d0' will
not be changed by `-fdefault-real-8' though, so also
`-fdefault-double-8' does not affect it.
`-fdefault-integer-8'
Set the default integer and logical types to an 8 byte wide type.
Do nothing if this is already the default. This option also
affects the kind of integer constants like `42'.
`-fdefault-real-8'
Set the default real type to an 8 byte wide type. Do nothing if
this is already the default. This option also affects the kind of
non-double real constants like `1.0', and does promote the default
width of `DOUBLE PRECISION' to 16 bytes if possible, unless
`-fdefault-double-8' is given, too.
`-fdollar-ok'
Allow `$' as a valid non-first character in a symbol name. Symbols
that start with `$' are rejected since it is unclear which rules to
apply to implicit typing as different vendors implement different
rules. Using `$' in `IMPLICIT' statements is also rejected.
`-fbackslash'
Change the interpretation of backslashes in string literals from a
single backslash character to "C-style" escape characters. The
following combinations are expanded `\a', `\b', `\f', `\n', `\r',
`\t', `\v', `\\', and `\0' to the ASCII characters alert,
backspace, form feed, newline, carriage return, horizontal tab,
vertical tab, backslash, and NUL, respectively. Additionally,
`\x'NN, `\u'NNNN and `\U'NNNNNNNN (where each N is a hexadecimal
digit) are translated into the Unicode characters corresponding to
the specified code points. All other combinations of a character
preceded by \ are unexpanded.
`-fmodule-private'
Set the default accessibility of module entities to `PRIVATE'.
Use-associated entities will not be accessible unless they are
explicitly declared as `PUBLIC'.
`-ffixed-line-length-N'
Set column after which characters are ignored in typical fixed-form
lines in the source file, and through which spaces are assumed (as
if padded to that length) after the ends of short fixed-form lines.
Popular values for N include 72 (the standard and the default), 80
(card image), and 132 (corresponding to "extended-source" options
in some popular compilers). N may also be `none', meaning that
the entire line is meaningful and that continued character
constants never have implicit spaces appended to them to fill out
the line. `-ffixed-line-length-0' means the same thing as
`-ffixed-line-length-none'.
`-ffree-line-length-N'
Set column after which characters are ignored in typical free-form
lines in the source file. The default value is 132. N may be
`none', meaning that the entire line is meaningful.
`-ffree-line-length-0' means the same thing as
`-ffree-line-length-none'.
`-fmax-identifier-length=N'
Specify the maximum allowed identifier length. Typical values are
31 (Fortran 95) and 63 (Fortran 2003 and Fortran 2008).
`-fimplicit-none'
Specify that no implicit typing is allowed, unless overridden by
explicit `IMPLICIT' statements. This is the equivalent of adding
`implicit none' to the start of every procedure.
`-fcray-pointer'
Enable the Cray pointer extension, which provides C-like pointer
functionality.
`-fopenmp'
Enable the OpenMP extensions. This includes OpenMP `!$omp'
directives in free form and `c$omp', `*$omp' and `!$omp'
directives in fixed form, `!$' conditional compilation sentinels
in free form and `c$', `*$' and `!$' sentinels in fixed form, and
when linking arranges for the OpenMP runtime library to be linked
in. The option `-fopenmp' implies `-frecursive'.
`-fno-range-check'
Disable range checking on results of simplification of constant
expressions during compilation. For example, GNU Fortran will give
an error at compile time when simplifying `a = 1. / 0'. With this
option, no error will be given and `a' will be assigned the value
`+Infinity'. If an expression evaluates to a value outside of the
relevant range of [`-HUGE()':`HUGE()'], then the expression will
be replaced by `-Inf' or `+Inf' as appropriate. Similarly, `DATA
i/Z'FFFFFFFF'/' will result in an integer overflow on most
systems, but with `-fno-range-check' the value will "wrap around"
and `i' will be initialized to -1 instead.
`-std=STD'
Specify the standard to which the program is expected to conform,
which may be one of `f95', `f2003', `f2008', `gnu', or `legacy'.
The default value for STD is `gnu', which specifies a superset of
the Fortran 95 standard that includes all of the extensions
supported by GNU Fortran, although warnings will be given for
obsolete extensions not recommended for use in new code. The
`legacy' value is equivalent but without the warnings for obsolete
extensions, and may be useful for old non-standard programs. The
`f95', `f2003' and `f2008' values specify strict conformance to
the Fortran 95, Fortran 2003 and Fortran 2008 standards,
respectively; errors are given for all extensions beyond the
relevant language standard, and warnings are given for the Fortran
77 features that are permitted but obsolescent in later standards.

File: gfortran.info, Node: Preprocessing Options, Next: Error and Warning Options, Prev: Fortran Dialect Options, Up: Invoking GNU Fortran
2.3 Enable and customize preprocessing
======================================
Preprocessor related options. See section *Note Preprocessing and
conditional compilation:: for more detailed information on
preprocessing in `gfortran'.
`-cpp'
`-nocpp'
Enable preprocessing. The preprocessor is automatically invoked if
the file extension is `.fpp', `.FPP', `.F', `.FOR', `.FTN',
`.F90', `.F95', `.F03' or `.F08'. Use this option to manually
enable preprocessing of any kind of Fortran file.
To disable preprocessing of files with any of the above listed
extensions, use the negative form: `-nocpp'.
The preprocessor is run in traditional mode, be aware that any
restrictions of the file-format, e.g. fixed-form line width, apply
for preprocessed output as well.
`-dM'
Instead of the normal output, generate a list of `'#define''
directives for all the macros defined during the execution of the
preprocessor, including predefined macros. This gives you a way of
finding out what is predefined in your version of the preprocessor.
Assuming you have no file `foo.f90', the command
touch foo.f90; gfortran -cpp -dM foo.f90
will show all the predefined macros.
`-dD'
Like `-dM' except in two respects: it does not include the
predefined macros, and it outputs both the `#define' directives
and the result of preprocessing. Both kinds of output go to the
standard output file.
`-dN'
Like `-dD', but emit only the macro names, not their expansions.
`-dU'
Like `dD' except that only macros that are expanded, or whose
definedness is tested in preprocessor directives, are output; the
output is delayed until the use or test of the macro; and
`'#undef'' directives are also output for macros tested but
undefined at the time.
`-dI'
Output `'#include'' directives in addition to the result of
preprocessing.
`-fworking-directory'
Enable generation of linemarkers in the preprocessor output that
will let the compiler know the current working directory at the
time of preprocessing. When this option is enabled, the
preprocessor will emit, after the initial linemarker, a second
linemarker with the current working directory followed by two
slashes. GCC will use this directory, when it's present in the
preprocessed input, as the directory emitted as the current
working directory in some debugging information formats. This
option is implicitly enabled if debugging information is enabled,
but this can be inhibited with the negated form
`-fno-working-directory'. If the `-P' flag is present in the
command line, this option has no effect, since no `#line'
directives are emitted whatsoever.
`-idirafter DIR'
Search DIR for include files, but do it after all directories
specified with `-I' and the standard system directories have been
exhausted. DIR is treated as a system include directory. If dir
begins with `=', then the `=' will be replaced by the sysroot
prefix; see `--sysroot' and `-isysroot'.
`-imultilib DIR'
Use DIR as a subdirectory of the directory containing
target-specific C++ headers.
`-iprefix PREFIX'
Specify PREFIX as the prefix for subsequent `-iwithprefix'
options. If the PREFIX represents a directory, you should include
the final `'/''.
`-isysroot DIR'
This option is like the `--sysroot' option, but applies only to
header files. See the `--sysroot' option for more information.
`-iquote DIR'
Search DIR only for header files requested with `#include "file"';
they are not searched for `#include <file>', before all directories
specified by `-I' and before the standard system directories. If
DIR begins with `=', then the `=' will be replaced by the sysroot
prefix; see `--sysroot' and `-isysroot'.
`-isystem DIR'
Search DIR for header files, after all directories specified by
`-I' but before the standard system directories. Mark it as a
system directory, so that it gets the same special treatment as is
applied to the standard system directories. If DIR begins with
`=', then the `=' will be replaced by the sysroot prefix; see
`--sysroot' and `-isysroot'.
`-nostdinc'
Do not search the standard system directories for header files.
Only the directories you have specified with `-I' options (and the
directory of the current file, if appropriate) are searched.
`-undef'
Do not predefine any system-specific or GCC-specific macros. The
standard predefined macros remain defined.
`-APREDICATE=ANSWER'
Make an assertion with the predicate PREDICATE and answer ANSWER.
This form is preferred to the older form -A predicate(answer),
which is still supported, because it does not use shell special
characters.
`-A-PREDICATE=ANSWER'
Cancel an assertion with the predicate PREDICATE and answer ANSWER.
`-C'
Do not discard comments. All comments are passed through to the
output file, except for comments in processed directives, which
are deleted along with the directive.
You should be prepared for side effects when using `-C'; it causes
the preprocessor to treat comments as tokens in their own right.
For example, comments appearing at the start of what would be a
directive line have the effect of turning that line into an
ordinary source line, since the first token on the line is no
longer a `'#''.
Warning: this currently handles C-Style comments only. The
preprocessor does not yet recognize Fortran-style comments.
`-CC'
Do not discard comments, including during macro expansion. This is
like `-C', except that comments contained within macros are also
passed through to the output file where the macro is expanded.
In addition to the side-effects of the `-C' option, the `-CC'
option causes all C++-style comments inside a macro to be
converted to C-style comments. This is to prevent later use of
that macro from inadvertently commenting out the remainder of the
source line. The `-CC' option is generally used to support lint
comments.
Warning: this currently handles C- and C++-Style comments only. The
preprocessor does not yet recognize Fortran-style comments.
`-DNAME'
Predefine name as a macro, with definition `1'.
`-DNAME=DEFINITION'
The contents of DEFINITION are tokenized and processed as if they
appeared during translation phase three in a `'#define'' directive.
In particular, the definition will be truncated by embedded newline
characters.
If you are invoking the preprocessor from a shell or shell-like
program you may need to use the shell's quoting syntax to protect
characters such as spaces that have a meaning in the shell syntax.
If you wish to define a function-like macro on the command line,
write its argument list with surrounding parentheses before the
equals sign (if any). Parentheses are meaningful to most shells,
so you will need to quote the option. With sh and csh,
`-D'name(args...)=definition'' works.
`-D' and `-U' options are processed in the order they are given on
the command line. All -imacros file and -include file options are
processed after all -D and -U options.
`-H'
Print the name of each header file used, in addition to other
normal activities. Each name is indented to show how deep in the
`'#include'' stack it is.
`-P'
Inhibit generation of linemarkers in the output from the
preprocessor. This might be useful when running the preprocessor
on something that is not C code, and will be sent to a program
which might be confused by the linemarkers.
`-UNAME'
Cancel any previous definition of NAME, either built in or provided
with a `-D' option.

File: gfortran.info, Node: Error and Warning Options, Next: Debugging Options, Prev: Preprocessing Options, Up: Invoking GNU Fortran
2.4 Options to request or suppress errors and warnings
======================================================
Errors are diagnostic messages that report that the GNU Fortran compiler
cannot compile the relevant piece of source code. The compiler will
continue to process the program in an attempt to report further errors
to aid in debugging, but will not produce any compiled output.
Warnings are diagnostic messages that report constructions which are
not inherently erroneous but which are risky or suggest there is likely
to be a bug in the program. Unless `-Werror' is specified, they do not
prevent compilation of the program.
You can request many specific warnings with options beginning `-W',
for example `-Wimplicit' to request warnings on implicit declarations.
Each of these specific warning options also has a negative form
beginning `-Wno-' to turn off warnings; for example, `-Wno-implicit'.
This manual lists only one of the two forms, whichever is not the
default.
These options control the amount and kinds of errors and warnings
produced by GNU Fortran:
`-fmax-errors=N'
Limits the maximum number of error messages to N, at which point
GNU Fortran bails out rather than attempting to continue
processing the source code. If N is 0, there is no limit on the
number of error messages produced.
`-fsyntax-only'
Check the code for syntax errors, but don't actually compile it.
This will generate module files for each module present in the
code, but no other output file.
`-pedantic'
Issue warnings for uses of extensions to Fortran 95. `-pedantic'
also applies to C-language constructs where they occur in GNU
Fortran source files, such as use of `\e' in a character constant
within a directive like `#include'.
Valid Fortran 95 programs should compile properly with or without
this option. However, without this option, certain GNU extensions
and traditional Fortran features are supported as well. With this
option, many of them are rejected.
Some users try to use `-pedantic' to check programs for
conformance. They soon find that it does not do quite what they
want--it finds some nonstandard practices, but not all. However,
improvements to GNU Fortran in this area are welcome.
This should be used in conjunction with `-std=f95', `-std=f2003'
or `-std=f2008'.
`-pedantic-errors'
Like `-pedantic', except that errors are produced rather than
warnings.
`-Wall'
Enables commonly used warning options pertaining to usage that we
recommend avoiding and that we believe are easy to avoid. This
currently includes `-Waliasing', `-Wampersand', `-Wsurprising',
`-Wintrinsics-std', `-Wno-tabs', `-Wintrinsic-shadow' and
`-Wline-truncation'.
`-Waliasing'
Warn about possible aliasing of dummy arguments. Specifically, it
warns if the same actual argument is associated with a dummy
argument with `INTENT(IN)' and a dummy argument with `INTENT(OUT)'
in a call with an explicit interface.
The following example will trigger the warning.
interface
subroutine bar(a,b)
integer, intent(in) :: a
integer, intent(out) :: b
end subroutine
end interface
integer :: a
call bar(a,a)
`-Wampersand'
Warn about missing ampersand in continued character constants. The
warning is given with `-Wampersand', `-pedantic', `-std=f95',
`-std=f2003' and `-std=f2008'. Note: With no ampersand given in a
continued character constant, GNU Fortran assumes continuation at
the first non-comment, non-whitespace character after the ampersand
that initiated the continuation.
`-Warray-temporaries'
Warn about array temporaries generated by the compiler. The
information generated by this warning is sometimes useful in
optimization, in order to avoid such temporaries.
`-Wcharacter-truncation'
Warn when a character assignment will truncate the assigned string.
`-Wline-truncation'
Warn when a source code line will be truncated.
`-Wconversion'
Warn about implicit conversions between different types.
`-Wimplicit-interface'
Warn if a procedure is called without an explicit interface. Note
this only checks that an explicit interface is present. It does
not check that the declared interfaces are consistent across
program units.
`-Wimplicit-procedure'
Warn if a procedure is called that has neither an explicit
interface nor has been declared as `EXTERNAL'.
`-Wintrinsics-std'
Warn if `gfortran' finds a procedure named like an intrinsic not
available in the currently selected standard (with `-std') and
treats it as `EXTERNAL' procedure because of this.
`-fall-intrinsics' can be used to never trigger this behavior and
always link to the intrinsic regardless of the selected standard.
`-Wsurprising'
Produce a warning when "suspicious" code constructs are
encountered. While technically legal these usually indicate that
an error has been made.
This currently produces a warning under the following
circumstances:
* An INTEGER SELECT construct has a CASE that can never be
matched as its lower value is greater than its upper value.
* A LOGICAL SELECT construct has three CASE statements.
* A TRANSFER specifies a source that is shorter than the
destination.
* The type of a function result is declared more than once with
the same type. If `-pedantic' or standard-conforming mode is
enabled, this is an error.
* A `CHARACTER' variable is declared with negative length.
`-Wtabs'
By default, tabs are accepted as whitespace, but tabs are not
members of the Fortran Character Set. For continuation lines, a
tab followed by a digit between 1 and 9 is supported. `-Wno-tabs'
will cause a warning to be issued if a tab is encountered. Note,
`-Wno-tabs' is active for `-pedantic', `-std=f95', `-std=f2003',
`-std=f2008' and `-Wall'.
`-Wunderflow'
Produce a warning when numerical constant expressions are
encountered, which yield an UNDERFLOW during compilation.
`-Wintrinsic-shadow'
Warn if a user-defined procedure or module procedure has the same
name as an intrinsic; in this case, an explicit interface or
`EXTERNAL' or `INTRINSIC' declaration might be needed to get calls
later resolved to the desired intrinsic/procedure.
`-Wunused-parameter'
Contrary to `gcc''s meaning of `-Wunused-parameter', `gfortran''s
implementation of this option does not warn about unused dummy
arguments, but about unused `PARAMETER' values.
`-Wunused-parameter' is not included in `-Wall' but is implied by
`-Wall -Wextra'.
`-Walign-commons'
By default, `gfortran' warns about any occasion of variables being
padded for proper alignment inside a COMMON block. This warning
can be turned off via `-Wno-align-commons'. See also
`-falign-commons'.
`-Werror'
Turns all warnings into errors.
*Note Options to Request or Suppress Errors and Warnings: (gcc)Error
and Warning Options, for information on more options offered by the GBE
shared by `gfortran', `gcc' and other GNU compilers.
Some of these have no effect when compiling programs written in
Fortran.

File: gfortran.info, Node: Debugging Options, Next: Directory Options, Prev: Error and Warning Options, Up: Invoking GNU Fortran
2.5 Options for debugging your program or GNU Fortran
=====================================================
GNU Fortran has various special options that are used for debugging
either your program or the GNU Fortran compiler.
`-fdump-parse-tree'
Output the internal parse tree before starting code generation.
Only really useful for debugging the GNU Fortran compiler itself.
`-ffpe-trap=LIST'
Specify a list of IEEE exceptions when a Floating Point Exception
(FPE) should be raised. On most systems, this will result in a
SIGFPE signal being sent and the program being interrupted,
producing a core file useful for debugging. LIST is a (possibly
empty) comma-separated list of the following IEEE exceptions:
`invalid' (invalid floating point operation, such as
`SQRT(-1.0)'), `zero' (division by zero), `overflow' (overflow in
a floating point operation), `underflow' (underflow in a floating
point operation), `precision' (loss of precision during operation)
and `denormal' (operation produced a denormal value).
Some of the routines in the Fortran runtime library, like
`CPU_TIME', are likely to trigger floating point exceptions when
`ffpe-trap=precision' is used. For this reason, the use of
`ffpe-trap=precision' is not recommended.
`-fbacktrace'
Specify that, when a runtime error is encountered or a deadly
signal is emitted (segmentation fault, illegal instruction, bus
error or floating-point exception), the Fortran runtime library
should output a backtrace of the error. This option only has
influence for compilation of the Fortran main program.
`-fdump-core'
Request that a core-dump file is written to disk when a runtime
error is encountered on systems that support core dumps. This
option is only effective for the compilation of the Fortran main
program.
*Note Options for Debugging Your Program or GCC: (gcc)Debugging
Options, for more information on debugging options.

File: gfortran.info, Node: Directory Options, Next: Link Options, Prev: Debugging Options, Up: Invoking GNU Fortran
2.6 Options for directory search
================================
These options affect how GNU Fortran searches for files specified by
the `INCLUDE' directive and where it searches for previously compiled
modules.
It also affects the search paths used by `cpp' when used to
preprocess Fortran source.
`-IDIR'
These affect interpretation of the `INCLUDE' directive (as well as
of the `#include' directive of the `cpp' preprocessor).
Also note that the general behavior of `-I' and `INCLUDE' is
pretty much the same as of `-I' with `#include' in the `cpp'
preprocessor, with regard to looking for `header.gcc' files and
other such things.
This path is also used to search for `.mod' files when previously
compiled modules are required by a `USE' statement.
*Note Options for Directory Search: (gcc)Directory Options, for
information on the `-I' option.
`-JDIR'
This option specifies where to put `.mod' files for compiled
modules. It is also added to the list of directories to searched
by an `USE' statement.
The default is the current directory.
`-fintrinsic-modules-path DIR'
This option specifies the location of pre-compiled intrinsic
modules, if they are not in the default location expected by the
compiler.

File: gfortran.info, Node: Link Options, Next: Runtime Options, Prev: Directory Options, Up: Invoking GNU Fortran
2.7 Influencing the linking step
================================
These options come into play when the compiler links object files into
an executable output file. They are meaningless if the compiler is not
doing a link step.
`-static-libgfortran'
On systems that provide `libgfortran' as a shared and a static
library, this option forces the use of the static version. If no
shared version of `libgfortran' was built when the compiler was
configured, this option has no effect.

File: gfortran.info, Node: Runtime Options, Next: Code Gen Options, Prev: Link Options, Up: Invoking GNU Fortran
2.8 Influencing runtime behavior
================================
These options affect the runtime behavior of programs compiled with GNU
Fortran.
`-fconvert=CONVERSION'
Specify the representation of data for unformatted files. Valid
values for conversion are: `native', the default; `swap', swap
between big- and little-endian; `big-endian', use big-endian
representation for unformatted files; `little-endian', use
little-endian representation for unformatted files.
_This option has an effect only when used in the main program.
The `CONVERT' specifier and the GFORTRAN_CONVERT_UNIT environment
variable override the default specified by `-fconvert'._
`-fno-range-check'
Disable range checking of input values during integer `READ'
operations. For example, GNU Fortran will give an error if an
input value is outside of the relevant range of
[`-HUGE()':`HUGE()']. In other words, with `INTEGER (kind=4) :: i'
, attempting to read -2147483648 will give an error unless
`-fno-range-check' is given.
`-frecord-marker=LENGTH'
Specify the length of record markers for unformatted files. Valid
values for LENGTH are 4 and 8. Default is 4. _This is different
from previous versions of `gfortran'_, which specified a default
record marker length of 8 on most systems. If you want to read or
write files compatible with earlier versions of `gfortran', use
`-frecord-marker=8'.
`-fmax-subrecord-length=LENGTH'
Specify the maximum length for a subrecord. The maximum permitted
value for length is 2147483639, which is also the default. Only
really useful for use by the gfortran testsuite.
`-fsign-zero'
When enabled, floating point numbers of value zero with the sign
bit set are written as negative number in formatted output and
treated as negative in the `SIGN' intrinsic. `fno-sign-zero' does
not print the negative sign of zero values and regards zero as
positive number in the `SIGN' intrinsic for compatibility with F77.
Default behavior is to show the negative sign.

File: gfortran.info, Node: Code Gen Options, Next: Environment Variables, Prev: Runtime Options, Up: Invoking GNU Fortran
2.9 Options for code generation conventions
===========================================
These machine-independent options control the interface conventions
used in code generation.
Most of them have both positive and negative forms; the negative form
of `-ffoo' would be `-fno-foo'. In the table below, only one of the
forms is listed--the one which is not the default. You can figure out
the other form by either removing `no-' or adding it.
`-fno-automatic'
Treat each program unit (except those marked as RECURSIVE) as if
the `SAVE' statement were specified for every local variable and
array referenced in it. Does not affect common blocks. (Some
Fortran compilers provide this option under the name `-static' or
`-save'.) The default, which is `-fautomatic', uses the stack for
local variables smaller than the value given by
`-fmax-stack-var-size'. Use the option `-frecursive' to use no
static memory.
`-ff2c'
Generate code designed to be compatible with code generated by
`g77' and `f2c'.
The calling conventions used by `g77' (originally implemented in
`f2c') require functions that return type default `REAL' to
actually return the C type `double', and functions that return
type `COMPLEX' to return the values via an extra argument in the
calling sequence that points to where to store the return value.
Under the default GNU calling conventions, such functions simply
return their results as they would in GNU C--default `REAL'
functions return the C type `float', and `COMPLEX' functions
return the GNU C type `complex'. Additionally, this option
implies the `-fsecond-underscore' option, unless
`-fno-second-underscore' is explicitly requested.
This does not affect the generation of code that interfaces with
the `libgfortran' library.
_Caution:_ It is not a good idea to mix Fortran code compiled with
`-ff2c' with code compiled with the default `-fno-f2c' calling
conventions as, calling `COMPLEX' or default `REAL' functions
between program parts which were compiled with different calling
conventions will break at execution time.
_Caution:_ This will break code which passes intrinsic functions
of type default `REAL' or `COMPLEX' as actual arguments, as the
library implementations use the `-fno-f2c' calling conventions.
`-fno-underscoring'
Do not transform names of entities specified in the Fortran source
file by appending underscores to them.
With `-funderscoring' in effect, GNU Fortran appends one
underscore to external names with no underscores. This is done to
ensure compatibility with code produced by many UNIX Fortran
compilers.
_Caution_: The default behavior of GNU Fortran is incompatible
with `f2c' and `g77', please use the `-ff2c' option if you want
object files compiled with GNU Fortran to be compatible with
object code created with these tools.
Use of `-fno-underscoring' is not recommended unless you are
experimenting with issues such as integration of GNU Fortran into
existing system environments (vis-a`-vis existing libraries, tools,
and so on).
For example, with `-funderscoring', and assuming other defaults
like `-fcase-lower' and that `j()' and `max_count()' are external
functions while `my_var' and `lvar' are local variables, a
statement like
I = J() + MAX_COUNT (MY_VAR, LVAR)
is implemented as something akin to:
i = j_() + max_count__(&my_var__, &lvar);
With `-fno-underscoring', the same statement is implemented as:
i = j() + max_count(&my_var, &lvar);
Use of `-fno-underscoring' allows direct specification of
user-defined names while debugging and when interfacing GNU Fortran
code with other languages.
Note that just because the names match does _not_ mean that the
interface implemented by GNU Fortran for an external name matches
the interface implemented by some other language for that same
name. That is, getting code produced by GNU Fortran to link to
code produced by some other compiler using this or any other
method can be only a small part of the overall solution--getting
the code generated by both compilers to agree on issues other than
naming can require significant effort, and, unlike naming
disagreements, linkers normally cannot detect disagreements in
these other areas.
Also, note that with `-fno-underscoring', the lack of appended
underscores introduces the very real possibility that a
user-defined external name will conflict with a name in a system
library, which could make finding unresolved-reference bugs quite
difficult in some cases--they might occur at program run time, and
show up only as buggy behavior at run time.
In future versions of GNU Fortran we hope to improve naming and
linking issues so that debugging always involves using the names
as they appear in the source, even if the names as seen by the
linker are mangled to prevent accidental linking between
procedures with incompatible interfaces.
`-fwhole-file'
By default, GNU Fortran parses, resolves and translates each
procedure in a file separately. Using this option modifies this
such that the whole file is parsed and placed in a single
front-end tree. During resolution, in addition to all the usual
checks and fixups, references to external procedures that are in
the same file effect resolution of that procedure, if not already
done, and a check of the interfaces. The dependences are resolved
by changing the order in which the file is translated into the
backend tree. Thus, a procedure that is referenced is translated
before the reference and the duplication of backend tree
declarations eliminated.
`-fsecond-underscore'
By default, GNU Fortran appends an underscore to external names.
If this option is used GNU Fortran appends two underscores to
names with underscores and one underscore to external names with
no underscores. GNU Fortran also appends two underscores to
internal names with underscores to avoid naming collisions with
external names.
This option has no effect if `-fno-underscoring' is in effect. It
is implied by the `-ff2c' option.
Otherwise, with this option, an external name such as `MAX_COUNT'
is implemented as a reference to the link-time external symbol
`max_count__', instead of `max_count_'. This is required for
compatibility with `g77' and `f2c', and is implied by use of the
`-ff2c' option.
`-fcheck=<KEYWORD>'
Enable the generation of run-time checks; the argument shall be a
comma-delimited list of the following keywords.
`all'
Enable all run-time test of `-fcheck'.
`array-temps'
Warns at run time when for passing an actual argument a
temporary array had to be generated. The information
generated by this warning is sometimes useful in
optimization, in order to avoid such temporaries.
Note: The warning is only printed once per location.
`bounds'
Enable generation of run-time checks for array subscripts and
against the declared minimum and maximum values. It also
checks array indices for assumed and deferred shape arrays
against the actual allocated bounds and ensures that all
string lengths are equal for character array constructors
without an explicit typespec.
Some checks require that `-fcheck=bounds' is set for the
compilation of the main program.
Note: In the future this may also include other forms of
checking, e.g., checking substring references.
`do'
Enable generation of run-time checks for invalid modification
of loop iteration variables.
`mem'
Enable generation of run-time checks for memory allocation.
Note: This option does not affect explicit allocations using
the `ALLOCATE' statement, which will be always checked.
`pointer'
Enable generation of run-time checks for pointers and
allocatables.
`recursion'
Enable generation of run-time checks for recursively called
subroutines and functions which are not marked as recursive.
See also `-frecursive'. Note: This check does not work for
OpenMP programs and is disabled if used together with
`-frecursive' and `-fopenmp'.
`-fbounds-check'
Deprecated alias for `-fcheck=bounds'.
`-fcheck-array-temporaries'
Deprecated alias for `-fcheck=array-temps'.
`-fmax-array-constructor=N'
This option can be used to increase the upper limit permitted in
array constructors. The code below requires this option to expand
the array at compile time.
`program test'
`implicit none'
`integer j'
`integer, parameter :: n = 100000'
`integer, parameter :: i(n) = (/ (2*j, j = 1, n) /)'
`print '(10(I0,1X))', i'
`end program test'
_Caution: This option can lead to long compile times and
excessively large object files._
The default value for N is 65535.
`-fmax-stack-var-size=N'
This option specifies the size in bytes of the largest array that
will be put on the stack; if the size is exceeded static memory is
used (except in procedures marked as RECURSIVE). Use the option
`-frecursive' to allow for recursive procedures which do not have
a RECURSIVE attribute or for parallel programs. Use
`-fno-automatic' to never use the stack.
This option currently only affects local arrays declared with
constant bounds, and may not apply to all character variables.
Future versions of GNU Fortran may improve this behavior.
The default value for N is 32768.
`-fpack-derived'
This option tells GNU Fortran to pack derived type members as
closely as possible. Code compiled with this option is likely to
be incompatible with code compiled without this option, and may
execute slower.
`-frepack-arrays'
In some circumstances GNU Fortran may pass assumed shape array
sections via a descriptor describing a noncontiguous area of
memory. This option adds code to the function prologue to repack
the data into a contiguous block at runtime.
This should result in faster accesses to the array. However it
can introduce significant overhead to the function call,
especially when the passed data is noncontiguous.
`-fshort-enums'
This option is provided for interoperability with C code that was
compiled with the `-fshort-enums' option. It will make GNU
Fortran choose the smallest `INTEGER' kind a given enumerator set
will fit in, and give all its enumerators this kind.
`-fexternal-blas'
This option will make `gfortran' generate calls to BLAS functions
for some matrix operations like `MATMUL', instead of using our own
algorithms, if the size of the matrices involved is larger than a
given limit (see `-fblas-matmul-limit'). This may be profitable
if an optimized vendor BLAS library is available. The BLAS
library will have to be specified at link time.
`-fblas-matmul-limit=N'
Only significant when `-fexternal-blas' is in effect. Matrix
multiplication of matrices with size larger than (or equal to) N
will be performed by calls to BLAS functions, while others will be
handled by `gfortran' internal algorithms. If the matrices
involved are not square, the size comparison is performed using the
geometric mean of the dimensions of the argument and result
matrices.
The default value for N is 30.
`-frecursive'
Allow indirect recursion by forcing all local arrays to be
allocated on the stack. This flag cannot be used together with
`-fmax-stack-var-size=' or `-fno-automatic'.
`-finit-local-zero'
`-finit-integer=N'
`-finit-real=<ZERO|INF|-INF|NAN|SNAN>'
`-finit-logical=<TRUE|FALSE>'
`-finit-character=N'
The `-finit-local-zero' option instructs the compiler to
initialize local `INTEGER', `REAL', and `COMPLEX' variables to
zero, `LOGICAL' variables to false, and `CHARACTER' variables to a
string of null bytes. Finer-grained initialization options are
provided by the `-finit-integer=N',
`-finit-real=<ZERO|INF|-INF|NAN|SNAN>' (which also initializes the
real and imaginary parts of local `COMPLEX' variables),
`-finit-logical=<TRUE|FALSE>', and `-finit-character=N' (where N
is an ASCII character value) options. These options do not
initialize components of derived type variables, nor do they
initialize variables that appear in an `EQUIVALENCE' statement.
(This limitation may be removed in future releases).
Note that the `-finit-real=nan' option initializes `REAL' and
`COMPLEX' variables with a quiet NaN. For a signalling NaN use
`-finit-real=snan'; note, however, that compile-time optimizations
may convert them into quiet NaN and that trapping needs to be
enabled (e.g. via `-ffpe-trap').
`-falign-commons'
By default, `gfortran' enforces proper alignment of all variables
in a COMMON block by padding them as needed. On certain platforms
this is mandatory, on others it increases performance. If a COMMON
block is not declared with consistent data types everywhere, this
padding can cause trouble, and `-fno-align-commons ' can be used
to disable automatic alignment. The same form of this option
should be used for all files that share a COMMON block. To avoid
potential alignment issues in COMMON blocks, it is recommended to
order objects from largests to smallest.
`-fno-protect-parens'
By default the parentheses in expression are honored for all
optimization levels such that the compiler does not do any
re-association. Using `-fno-protect-parens' allows the compiler to
reorder REAL and COMPLEX expressions to produce faster code. Note
that for the re-association optimization `-fno-signed-zeros' and
`-fno-trapping-math' need to be in effect.
*Note Options for Code Generation Conventions: (gcc)Code Gen
Options, for information on more options offered by the GBE shared by
`gfortran', `gcc', and other GNU compilers.

File: gfortran.info, Node: Environment Variables, Prev: Code Gen Options, Up: Invoking GNU Fortran
2.10 Environment variables affecting `gfortran'
===============================================
The `gfortran' compiler currently does not make use of any environment
variables to control its operation above and beyond those that affect
the operation of `gcc'.
*Note Environment Variables Affecting GCC: (gcc)Environment
Variables, for information on environment variables.
*Note Runtime::, for environment variables that affect the run-time
behavior of programs compiled with GNU Fortran.

File: gfortran.info, Node: Runtime, Next: Fortran 2003 and 2008 status, Prev: Invoking GNU Fortran, Up: Top
3 Runtime: Influencing runtime behavior with environment variables
*******************************************************************
The behavior of the `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 I/O for all units.
* GFORTRAN_UNBUFFERED_PRECONNECTED:: Don't buffer I/O for preconnected units.
* 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
* GFORTRAN_ERROR_DUMPCORE:: Dump core on run-time errors
* GFORTRAN_ERROR_BACKTRACE:: Show backtrace on run-time errors

File: gfortran.info, Node: GFORTRAN_STDIN_UNIT, Next: GFORTRAN_STDOUT_UNIT, Up: Runtime
3.1 `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.

File: gfortran.info, Node: GFORTRAN_STDOUT_UNIT, Next: GFORTRAN_STDERR_UNIT, Prev: GFORTRAN_STDIN_UNIT, Up: Runtime
3.2 `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.

File: gfortran.info, Node: GFORTRAN_STDERR_UNIT, Next: GFORTRAN_USE_STDERR, Prev: GFORTRAN_STDOUT_UNIT, Up: Runtime
3.3 `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.

File: gfortran.info, Node: GFORTRAN_USE_STDERR, Next: GFORTRAN_TMPDIR, Prev: GFORTRAN_STDERR_UNIT, Up: Runtime
3.4 `GFORTRAN_USE_STDERR'--Send library output to standard error
================================================================
This environment variable controls where library output is sent. If
the first letter is `y', `Y' or `1', standard error is used. If the
first letter is `n', `N' or `0', standard output is used.

File: gfortran.info, Node: GFORTRAN_TMPDIR, Next: GFORTRAN_UNBUFFERED_ALL, Prev: GFORTRAN_USE_STDERR, Up: Runtime
3.5 `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 `TMP'. If this is also missing, the default is
`/tmp'.

File: gfortran.info, Node: GFORTRAN_UNBUFFERED_ALL, Next: GFORTRAN_UNBUFFERED_PRECONNECTED, Prev: GFORTRAN_TMPDIR, Up: Runtime
3.6 `GFORTRAN_UNBUFFERED_ALL'--Don't buffer I/O on all units
============================================================
This environment variable controls whether all I/O is unbuffered. If
the first letter is `y', `Y' or `1', all I/O is unbuffered. This will
slow down small sequential reads and writes. If the first letter is
`n', `N' or `0', I/O is buffered. This is the default.

File: gfortran.info, Node: GFORTRAN_UNBUFFERED_PRECONNECTED, Next: GFORTRAN_SHOW_LOCUS, Prev: GFORTRAN_UNBUFFERED_ALL, Up: Runtime
3.7 `GFORTRAN_UNBUFFERED_PRECONNECTED'--Don't buffer I/O on preconnected units
==============================================================================
The environment variable named `GFORTRAN_UNBUFFERED_PRECONNECTED'
controls whether I/O on a preconnected unit (i.e. STDOUT or STDERR) is
unbuffered. If the first letter is `y', `Y' or `1', I/O is unbuffered.
This will slow down small sequential reads and writes. If the first
letter is `n', `N' or `0', I/O is buffered. This is the default.

File: gfortran.info, Node: GFORTRAN_SHOW_LOCUS, Next: GFORTRAN_OPTIONAL_PLUS, Prev: GFORTRAN_UNBUFFERED_PRECONNECTED, Up: Runtime
3.8 `GFORTRAN_SHOW_LOCUS'--Show location for runtime errors
===========================================================
If the first letter is `y', `Y' or `1', filename and line numbers for
runtime errors are printed. If the first letter is `n', `N' or `0',
don't print filename and line numbers for runtime errors. The default
is to print the location.

File: gfortran.info, Node: GFORTRAN_OPTIONAL_PLUS, Next: GFORTRAN_DEFAULT_RECL, Prev: GFORTRAN_SHOW_LOCUS, Up: Runtime
3.9 `GFORTRAN_OPTIONAL_PLUS'--Print leading + where permitted
=============================================================
If the first letter is `y', `Y' or `1', a plus sign is printed where
permitted by the Fortran standard. If the first letter is `n', `N' or
`0', a plus sign is not printed in most cases. Default is not to print
plus signs.

File: gfortran.info, Node: GFORTRAN_DEFAULT_RECL, Next: GFORTRAN_LIST_SEPARATOR, Prev: GFORTRAN_OPTIONAL_PLUS, Up: Runtime
3.10 `GFORTRAN_DEFAULT_RECL'--Default record length for new files
=================================================================
This environment variable specifies the default record length, in
bytes, for files which are opened without a `RECL' tag in the `OPEN'
statement. This must be a positive integer. The default value is
1073741824 bytes (1 GB).

File: gfortran.info, Node: GFORTRAN_LIST_SEPARATOR, Next: GFORTRAN_CONVERT_UNIT, Prev: GFORTRAN_DEFAULT_RECL, Up: Runtime
3.11 `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
$ GFORTRAN_LIST_SEPARATOR=' , ' ./a.out
when `a.out' is the compiled Fortran program that you want to run.
Default is a single space.

File: gfortran.info, Node: GFORTRAN_CONVERT_UNIT, Next: GFORTRAN_ERROR_DUMPCORE, Prev: GFORTRAN_LIST_SEPARATOR, Up: Runtime
3.12 `GFORTRAN_CONVERT_UNIT'--Set endianness for unformatted I/O
================================================================
By setting the `GFORTRAN_CONVERT_UNIT' variable, it is possible to
change the representation of data for unformatted files. The syntax
for the `GFORTRAN_CONVERT_UNIT' variable is:
GFORTRAN_CONVERT_UNIT: mode | mode ';' exception | 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 ;
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 `CONVERT' specifier:
`NATIVE' Use the native format. This is the default.
`SWAP' Swap between little- and big-endian.
`LITTLE_ENDIAN' Use the little-endian format for unformatted files.
`BIG_ENDIAN' Use the big-endian format for unformatted files.
A missing mode for an exception is taken to mean `BIG_ENDIAN'.
Examples of values for `GFORTRAN_CONVERT_UNIT' are:
`'big_endian'' Do all unformatted I/O in big_endian mode.
`'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.
`'10-20'' Units 10 to 20 are big-endian, the rest is native.
Setting the environment variables should be done on the command line
or via the `export' command for `sh'-compatible shells and via `setenv'
for `csh'-compatible shells.
Example for `sh':
$ gfortran foo.f90
$ GFORTRAN_CONVERT_UNIT='big_endian;native:10-20' ./a.out
Example code for `csh':
% gfortran foo.f90
% setenv GFORTRAN_CONVERT_UNIT 'big_endian;native:10-20'
% ./a.out
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.
*Note CONVERT specifier::, for an alternative way to specify the
data representation for unformatted files. *Note Runtime Options::, for
setting a default data representation for the whole program. The
`CONVERT' specifier overrides the `-fconvert' compile options.
_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 users who do
not have the source code of their program available.

File: gfortran.info, Node: GFORTRAN_ERROR_DUMPCORE, Next: GFORTRAN_ERROR_BACKTRACE, Prev: GFORTRAN_CONVERT_UNIT, Up: Runtime
3.13 `GFORTRAN_ERROR_DUMPCORE'--Dump core on run-time errors
============================================================
If the `GFORTRAN_ERROR_DUMPCORE' variable is set to `y', `Y' or `1'
(only the first letter is relevant) then library run-time errors cause
core dumps. To disable the core dumps, set the variable to `n', `N',
`0'. Default is not to core dump unless the `-fdump-core' compile option
was used.

File: gfortran.info, Node: GFORTRAN_ERROR_BACKTRACE, Prev: GFORTRAN_ERROR_DUMPCORE, Up: Runtime
3.14 `GFORTRAN_ERROR_BACKTRACE'--Show backtrace on run-time errors
==================================================================
If the `GFORTRAN_ERROR_BACKTRACE' variable is set to `y', `Y' or `1'
(only the first letter is relevant) then a backtrace is printed when a
run-time error occurs. To disable the backtracing, set the variable to
`n', `N', `0'. Default is not to print a backtrace unless the
`-fbacktrace' compile option was used.

File: gfortran.info, Node: Fortran 2003 and 2008 status, Next: Compiler Characteristics, Prev: Runtime, Up: Top
4 Fortran 2003 and 2008 Status
******************************
* Menu:
* Fortran 2003 status::
* Fortran 2008 status::

File: gfortran.info, Node: Fortran 2003 status, Next: Fortran 2008 status, Up: Fortran 2003 and 2008 status
4.1 Fortran 2003 status
=======================
GNU Fortran supports several Fortran 2003 features; an incomplete list
can be found below. See also the wiki page
(http://gcc.gnu.org/wiki/Fortran2003) about Fortran 2003.
* Intrinsics `command_argument_count', `get_command',
`get_command_argument', `get_environment_variable', and
`move_alloc'.
* Array constructors using square brackets. That is, `[...]' rather
than `(/.../)'. Type-specification for array constructors like
`(/ some-type :: ... /)'.
* `FLUSH' statement.
* `IOMSG=' specifier for I/O statements.
* Support for the declaration of enumeration constants via the
`ENUM' and `ENUMERATOR' statements. Interoperability with `gcc'
is guaranteed also for the case where the `-fshort-enums' command
line option is given.
* TR 15581:
* `ALLOCATABLE' dummy arguments.
* `ALLOCATABLE' function results
* `ALLOCATABLE' components of derived types
* The `ERRMSG=' tag is now supported in `ALLOCATE' and `DEALLOCATE'
statements. The `SOURCE=' tag is supported in an `ALLOCATE'
statement. An _intrinsic-type-spec_ can be used as the
_type-spec_ in an `ALLOCATE' statement; while the use of a
_derived-type-name_ is currently unsupported.
* The `OPEN' statement supports the `ACCESS='STREAM'' specifier,
allowing I/O without any record structure.
* Namelist input/output for internal files.
* The `PROTECTED' statement and attribute.
* The `VALUE' statement and attribute.
* The `VOLATILE' statement and attribute.
* The `IMPORT' statement, allowing to import host-associated derived
types.
* `USE' statement with `INTRINSIC' and `NON_INTRINSIC' attribute;
supported intrinsic modules: `ISO_FORTRAN_ENV', `OMP_LIB' and
`OMP_LIB_KINDS'.
* Renaming of operators in the `USE' statement.
* Interoperability with C (ISO C Bindings)
* BOZ as argument of `INT', `REAL', `DBLE' and `CMPLX'.
* Type-bound procedures with `PROCEDURE' or `GENERIC', and operators
bound to a derived-type.
* Extension of derived-types (the `EXTENDS(...)' syntax).
* `ABSTRACT' derived-types and declaring procedure bindings
`DEFERRED'.

File: gfortran.info, Node: Fortran 2008 status, Prev: Fortran 2003 status, Up: Fortran 2003 and 2008 status
4.2 Fortran 2008 status
=======================
The next version of the Fortran standard after Fortran 2003 is currently
being worked on by the Working Group 5 of Sub-Committee 22 of the Joint
Technical Committee 1 of the International Organization for
Standardization (ISO) and the International Electrotechnical Commission
(IEC). This group is known as WG5 (http://www.nag.co.uk/sc22wg5/). The
next revision of the Fortran standard is informally referred to as
Fortran 2008, reflecting its planned release year. The GNU Fortran
compiler has support for some of the new features in Fortran 2008. This
support is based on the latest draft, available from
`http://www.nag.co.uk/sc22wg5/'. However, as the final standard may
differ from the drafts, no guarantee of backward compatibility can be
made and you should only use it for experimental purposes.
The wiki (http://gcc.gnu.org/wiki/Fortran2008Status) has some
information about the current Fortran 2008 implementation status.

File: gfortran.info, Node: Compiler Characteristics, Next: Mixed-Language Programming, Prev: Fortran 2003 and 2008 status, Up: Top
5 Compiler Characteristics
**************************
This chapter describes certain characteristics of the GNU Fortran
compiler, that are not specified by the Fortran standard, but which
might in some way or another become visible to the programmer.
* Menu:
* KIND Type Parameters::
* Internal representation of LOGICAL variables::

File: gfortran.info, Node: KIND Type Parameters, Next: Internal representation of LOGICAL variables, Up: Compiler Characteristics
5.1 KIND Type Parameters
========================
The `KIND' type parameters supported by GNU Fortran for the primitive
data types are:
`INTEGER'
1, 2, 4, 8*, 16*, default: 4 (1)
`LOGICAL'
1, 2, 4, 8*, 16*, default: 4 (1)
`REAL'
4, 8, 10**, 16**, default: 4 (2)
`COMPLEX'
4, 8, 10**, 16**, default: 4 (2)
`CHARACTER'
1, 4, default: 1
* = not available on all systems
** = not available on all systems; additionally 10 and 16 are never
available at the same time
(1) Unless -fdefault-integer-8 is used
(2) Unless -fdefault-real-8 is used
The `KIND' value matches the storage size in bytes, except for
`COMPLEX' where the storage size is twice as much (or both real and
imaginary part are a real value of the given size). It is recommended
to use the `SELECT_*_KIND' intrinsics instead of the concrete values.

File: gfortran.info, Node: Internal representation of LOGICAL variables, Prev: KIND Type Parameters, Up: Compiler Characteristics
5.2 Internal representation of LOGICAL variables
================================================
The Fortran standard does not specify how variables of `LOGICAL' type
are represented, beyond requiring that `LOGICAL' variables of default
kind have the same storage size as default `INTEGER' and `REAL'
variables. The GNU Fortran internal representation is as follows.
A `LOGICAL(KIND=N)' variable is represented as an `INTEGER(KIND=N)'
variable, however, with only two permissible values: `1' for `.TRUE.'
and `0' for `.FALSE.'. Any other integer value results in undefined
behavior.
Note that for mixed-language programming using the `ISO_C_BINDING'
feature, there is a `C_BOOL' kind that can be used to create
`LOGICAL(KIND=C_BOOL)' variables which are interoperable with the C99
_Bool type. The C99 _Bool type has an internal representation
described in the C99 standard, which is identical to the above
description, i.e. with 1 for true and 0 for false being the only
permissible values. Thus the internal representation of `LOGICAL'
variables in GNU Fortran is identical to C99 _Bool, except for a
possible difference in storage size depending on the kind.

File: gfortran.info, Node: Extensions, Next: Intrinsic Procedures, Prev: Mixed-Language Programming, Up: Top
6 Extensions
************
The two sections below detail the extensions to standard Fortran that
are implemented in GNU Fortran, as well as some of the popular or
historically important extensions that are not (or not yet) implemented.
For the latter case, we explain the alternatives available to GNU
Fortran users, including replacement by standard-conforming code or GNU
extensions.
* Menu:
* Extensions implemented in GNU Fortran::
* Extensions not implemented in GNU Fortran::

File: gfortran.info, Node: Extensions implemented in GNU Fortran, Next: Extensions not implemented in GNU Fortran, Up: Extensions
6.1 Extensions implemented in GNU Fortran
=========================================
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 GNU Fortran extensions, those that
provide functionality beyond that provided by any standard, and those
that are supported by GNU Fortran purely for backward compatibility
with legacy compilers. By default, `-std=gnu' allows the compiler to
accept both types of extensions, but to warn about the use of the
latter. Specifying either `-std=f95', `-std=f2003' or `-std=f2008'
disables both types of extensions, and `-std=legacy' allows both
without warning.
* Menu:
* Old-style kind specifications::
* Old-style variable initialization::
* Extensions to namelist::
* X format descriptor without count field::
* Commas in FORMAT specifications::
* Missing period in FORMAT specifications::
* I/O item lists::
* BOZ literal constants::
* Real array indices::
* Unary operators::
* Implicitly convert LOGICAL and INTEGER values::
* Hollerith constants support::
* Cray pointers::
* CONVERT specifier::
* OpenMP::
* Argument list functions::

File: gfortran.info, Node: Old-style kind specifications, Next: Old-style variable initialization, Up: Extensions implemented in GNU Fortran
6.1.1 Old-style kind specifications
-----------------------------------
GNU Fortran allows old-style kind specifications in declarations. These
look like:
TYPESPEC*size x,y,z
where `TYPESPEC' is a basic type (`INTEGER', `REAL', etc.), and
where `size' is a byte count corresponding to the storage size of a
valid kind for that type. (For `COMPLEX' variables, `size' is the
total size of the real and imaginary parts.) The statement then
declares `x', `y' and `z' to be of type `TYPESPEC' with the appropriate
kind. This is equivalent to the standard-conforming declaration
TYPESPEC(k) x,y,z
where `k' is the kind parameter suitable for the intended precision.
As kind parameters are implementation-dependent, use the `KIND',
`SELECTED_INT_KIND' and `SELECTED_REAL_KIND' intrinsics to retrieve the
correct value, for instance `REAL*8 x' can be replaced by:
INTEGER, PARAMETER :: dbl = KIND(1.0d0)
REAL(KIND=dbl) :: x

File: gfortran.info, Node: Old-style variable initialization, Next: Extensions to namelist, Prev: Old-style kind specifications, Up: Extensions implemented in GNU Fortran
6.1.2 Old-style variable initialization
---------------------------------------
GNU Fortran allows old-style initialization of variables of the form:
INTEGER i/1/,j/2/
REAL x(2,2) /3*0.,1./
The syntax for the initializers is as for the `DATA' statement, but
unlike in a `DATA' statement, an initializer only applies to the
variable immediately preceding the initialization. In other words,
something like `INTEGER I,J/2,3/' is not valid. This style of
initialization is only allowed in declarations without double colons
(`::'); the double colons were introduced in Fortran 90, which also
introduced a standard syntax for initializing variables in type
declarations.
Examples of standard-conforming code equivalent to the above example
are:
! Fortran 90
INTEGER :: i = 1, j = 2
REAL :: x(2,2) = RESHAPE((/0.,0.,0.,1./),SHAPE(x))
! Fortran 77
INTEGER i, j
REAL x(2,2)
DATA i/1/, j/2/, x/3*0.,1./
Note that variables which are explicitly initialized in declarations
or in `DATA' statements automatically acquire the `SAVE' attribute.

File: gfortran.info, Node: Extensions to namelist, Next: X format descriptor without count field, Prev: Old-style variable initialization, Up: Extensions implemented in GNU Fortran
6.1.3 Extensions to namelist
----------------------------
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 namelist name. Two extensions are permitted:
Old-style use of `$' instead of `&'
$MYNML
X(:)%Y(2) = 1.0 2.0 3.0
CH(1:4) = "abcd"
$END
It should be noted that the default terminator is `/' rather than
`&END'.
Querying of the namelist when inputting from stdin. After at least
one space, entering `?' sends to stdout the namelist name and the names
of the variables in the namelist:
?
&mynml
x
x%y
ch
&end
Entering `=?' outputs the namelist to stdout, as if `WRITE(*,NML =
mynml)' had been called:
=?
&MYNML
X(1)%Y= 0.000000 , 1.000000 , 0.000000 ,
X(2)%Y= 0.000000 , 2.000000 , 0.000000 ,
X(3)%Y= 0.000000 , 3.000000 , 0.000000 ,
CH=abcd, /
To aid this dialog, when input is from stdin, errors send their
messages to stderr and execution continues, even if `IOSTAT' is set.
`PRINT' namelist is permitted. This causes an error if `-std=f95'
is used.
PROGRAM test_print
REAL, dimension (4) :: x = (/1.0, 2.0, 3.0, 4.0/)
NAMELIST /mynml/ x
PRINT mynml
END PROGRAM test_print
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 the two succeeding elements will
be given the values 1.00 and 2.00.
&MYNML
X(1,1) = 0.00 , 1.00 , 2.00
/

File: gfortran.info, Node: X format descriptor without count field, Next: Commas in FORMAT specifications, Prev: Extensions to namelist, Up: Extensions implemented in GNU Fortran
6.1.4 `X' format descriptor without 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.
PRINT 10, 2, 3
10 FORMAT (I1, X, I1)

File: gfortran.info, Node: Commas in FORMAT specifications, Next: Missing period in FORMAT specifications, Prev: X format descriptor without count field, Up: Extensions implemented in GNU Fortran
6.1.5 Commas in `FORMAT' specifications
---------------------------------------
To support legacy codes, GNU Fortran allows the comma separator to be
omitted immediately before and after character string edit descriptors
in `FORMAT' statements.
PRINT 10, 2, 3
10 FORMAT ('FOO='I1' BAR='I2)

File: gfortran.info, Node: Missing period in FORMAT specifications, Next: I/O item lists, Prev: Commas in FORMAT specifications, Up: Extensions implemented in GNU Fortran
6.1.6 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.
REAL :: value
READ(*,10) value
10 FORMAT ('F4')

File: gfortran.info, Node: I/O item lists, Next: BOZ literal constants, Prev: Missing period in FORMAT specifications, Up: Extensions implemented in GNU Fortran
6.1.7 I/O item lists
--------------------
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.

File: gfortran.info, Node: BOZ literal constants, Next: Real array indices, Prev: I/O item lists, Up: Extensions implemented in GNU Fortran
6.1.8 BOZ literal constants
---------------------------
Besides decimal constants, Fortran also supports binary (`b'), octal
(`o') and hexadecimal (`z') integer constants. The syntax is: `prefix
quote digits quote', were the prefix is either `b', `o' or `z', quote
is either `'' or `"' and the digits are for binary `0' or `1', for
octal between `0' and `7', and for hexadecimal between `0' and `F'.
(Example: `b'01011101''.)
Up to Fortran 95, BOZ literals were only allowed to initialize
integer variables in DATA statements. Since Fortran 2003 BOZ literals
are also allowed as argument of `REAL', `DBLE', `INT' and `CMPLX'; the
result is the same as if the integer BOZ literal had been converted by
`TRANSFER' to, respectively, `real', `double precision', `integer' or
`complex'. As GNU Fortran extension the intrinsic procedures `FLOAT',
`DFLOAT', `COMPLEX' and `DCMPLX' are treated alike.
As an extension, GNU Fortran allows hexadecimal BOZ literal
constants to be specified using the `X' prefix, in addition to the
standard `Z' prefix. The BOZ literal can also be specified by adding a
suffix to the string, for example, `Z'ABC'' and `'ABC'Z' are equivalent.
Furthermore, GNU Fortran allows using BOZ literal constants outside
DATA statements and the four intrinsic functions allowed by Fortran
2003. In DATA statements, in direct assignments, where the right-hand
side only contains a BOZ literal constant, and for old-style
initializers of the form `integer i /o'0173'/', the constant is
transferred as if `TRANSFER' had been used; for `COMPLEX' numbers, only
the real part is initialized unless `CMPLX' is used. In all other
cases, the BOZ literal constant is converted to an `INTEGER' value with
the largest decimal representation. This value is then converted
numerically to the type and kind of the variable in question. (For
instance, `real :: r = b'0000001' + 1' initializes `r' with `2.0'.) As
different compilers implement the extension differently, one should be
careful when doing bitwise initialization of non-integer variables.
Note that initializing an `INTEGER' variable with a statement such
as `DATA i/Z'FFFFFFFF'/' will give an integer overflow error rather
than the desired result of -1 when `i' is a 32-bit integer on a system
that supports 64-bit integers. The `-fno-range-check' option can be
used as a workaround for legacy code that initializes integers in this
manner.

File: gfortran.info, Node: Real array indices, Next: Unary operators, Prev: BOZ literal constants, Up: Extensions implemented in GNU Fortran
6.1.9 Real array indices
------------------------
As an extension, GNU Fortran allows the use of `REAL' expressions or
variables as array indices.

File: gfortran.info, Node: Unary operators, Next: Implicitly convert LOGICAL and INTEGER values, Prev: Real array indices, Up: Extensions implemented in GNU Fortran
6.1.10 Unary operators
----------------------
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.
X = Y * -Z

File: gfortran.info, Node: Implicitly convert LOGICAL and INTEGER values, Next: Hollerith constants support, Prev: Unary operators, Up: Extensions implemented in GNU Fortran
6.1.11 Implicitly convert `LOGICAL' and `INTEGER' values
--------------------------------------------------------
As an extension for backwards compatibility with other compilers, GNU
Fortran allows the implicit conversion of `LOGICAL' values to `INTEGER'
values and vice versa. When converting from a `LOGICAL' to an
`INTEGER', `.FALSE.' is interpreted as zero, and `.TRUE.' is
interpreted as one. When converting from `INTEGER' to `LOGICAL', the
value zero is interpreted as `.FALSE.' and any nonzero value is
interpreted as `.TRUE.'.
LOGICAL :: l
l = 1
INTEGER :: i
i = .TRUE.
However, there is no implicit conversion of `INTEGER' values in
`if'-statements, nor of `LOGICAL' or `INTEGER' values in I/O operations.

File: gfortran.info, Node: Hollerith constants support, Next: Cray pointers, Prev: Implicitly convert LOGICAL and INTEGER values, Up: Extensions implemented in GNU Fortran
6.1.12 Hollerith constants support
----------------------------------
GNU Fortran supports Hollerith constants in assignments, function
arguments, and `DATA' and `ASSIGN' statements. A Hollerith constant is
written as a string of characters preceded by an integer constant
indicating the character count, and the letter `H' or `h', and stored
in bytewise fashion in a numeric (`INTEGER', `REAL', or `complex') or
`LOGICAL' variable. The constant will be padded or truncated to fit
the size of the variable in which it is stored.
Examples of valid uses of Hollerith constants:
complex*16 x(2)
data x /16Habcdefghijklmnop, 16Hqrstuvwxyz012345/
x(1) = 16HABCDEFGHIJKLMNOP
call foo (4h abc)
Invalid Hollerith constants examples:
integer*4 a
a = 8H12345678 ! Valid, but the Hollerith constant will be truncated.
a = 0H ! At least one character is needed.
In general, Hollerith constants were used to provide a rudimentary
facility for handling character strings in early Fortran compilers,
prior to the introduction of `CHARACTER' variables in Fortran 77; in
those cases, the standard-compliant equivalent is to convert the
program to use proper character strings. On occasion, there may be a
case where the intent is specifically to initialize a numeric variable
with a given byte sequence. In these cases, the same result can be
obtained by using the `TRANSFER' statement, as in this example.
INTEGER(KIND=4) :: a
a = TRANSFER ("abcd", a) ! equivalent to: a = 4Habcd

File: gfortran.info, Node: Cray pointers, Next: CONVERT specifier, Prev: Hollerith constants support, Up: Extensions implemented in GNU Fortran
6.1.13 Cray pointers
--------------------
Cray pointers are part of a non-standard extension that provides a
C-like pointer in Fortran. This is accomplished through a pair of
variables: an integer "pointer" that holds a memory address, and a
"pointee" that is used to dereference the pointer.
Pointer/pointee pairs are declared in statements of the form:
pointer ( <pointer> , <pointee> )
or,
pointer ( <pointer1> , <pointee1> ), ( <pointer2> , <pointee2> ), ...
The pointer is an integer that is intended to hold a memory address.
The pointee may be an array or scalar. A pointee can be an assumed
size array--that is, the last dimension may be left unspecified by
using a `*' in place of a value--but a pointee cannot be an assumed
shape array. No space is allocated for the pointee.
The pointee may have its type declared before or after the pointer
statement, and its array specification (if any) may be declared before,
during, or after the pointer statement. The pointer may be declared as
an integer prior to the pointer statement. However, some machines have
default integer sizes that are different than the size of a pointer,
and so the following code is not portable:
integer ipt
pointer (ipt, iarr)
If a pointer is declared with a kind that is too small, the compiler
will issue a warning; the resulting binary will probably not work
correctly, because the memory addresses stored in the pointers may be
truncated. It is safer to omit the first line of the above example; if
explicit declaration of ipt's type is omitted, then the compiler will
ensure that ipt is an integer variable large enough to hold a pointer.
Pointer arithmetic is valid with Cray pointers, but it is not the
same as C pointer arithmetic. Cray pointers are just ordinary
integers, so the user is responsible for determining how many bytes to
add to a pointer in order to increment it. Consider the following
example:
real target(10)
real pointee(10)
pointer (ipt, pointee)
ipt = loc (target)
ipt = ipt + 1
The last statement does not set `ipt' to the address of `target(1)',
as it would in C pointer arithmetic. Adding `1' to `ipt' just adds one
byte to the address stored in `ipt'.
Any expression involving the pointee will be translated to use the
value stored in the pointer as the base address.
To get the address of elements, this extension provides an intrinsic
function `LOC()'. The `LOC()' function is equivalent to the `&'
operator in C, except the address is cast to an integer type:
real ar(10)
pointer(ipt, arpte(10))
real arpte
ipt = loc(ar) ! Makes arpte is an alias for ar
arpte(1) = 1.0 ! Sets ar(1) to 1.0
The pointer can also be set by a call to the `MALLOC' intrinsic (see
*Note MALLOC::).
Cray pointees often are used to alias an existing variable. For
example:
integer target(10)
integer iarr(10)
pointer (ipt, iarr)
ipt = loc(target)
As long as `ipt' remains unchanged, `iarr' is now an alias for
`target'. The optimizer, however, will not detect this aliasing, so it
is unsafe to use `iarr' and `target' simultaneously. Using a pointee
in any way that violates the Fortran aliasing rules or assumptions is
illegal. It is the user's responsibility to avoid doing this; the
compiler works under the assumption that no such aliasing occurs.
Cray pointers will work correctly when there is no aliasing (i.e.,
when they are used to access a dynamically allocated block of memory),
and also in any routine where a pointee is used, but any variable with
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 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
`ALLOCATABLE', `INTENT', `OPTIONAL', `DUMMY', `TARGET', `INTRINSIC', or
`POINTER' attributes. Pointers may not have the `DIMENSION', `POINTER',
`TARGET', `ALLOCATABLE', `EXTERNAL', or `INTRINSIC' attributes.
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 also point to a function or a subroutine. For
example, the following excerpt is valid:
implicit none
external sub
pointer (subptr,subpte)
external subpte
subptr = loc(sub)
call subpte()
[...]
subroutine sub
[...]
end subroutine sub
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.

File: gfortran.info, Node: CONVERT specifier, Next: OpenMP, Prev: Cray pointers, Up: Extensions implemented in GNU Fortran
6.1.14 `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 `CONVERT'
specifier on the `OPEN' statement. *Note GFORTRAN_CONVERT_UNIT::, for
an alternative way of specifying the data format via an environment
variable.
Valid values for `CONVERT' are:
`CONVERT='NATIVE'' Use the native format. This is the default.
`CONVERT='SWAP'' Swap between little- and big-endian.
`CONVERT='LITTLE_ENDIAN'' Use the little-endian representation for
unformatted files.
`CONVERT='BIG_ENDIAN'' Use the big-endian representation for
unformatted files.
Using the option could look like this:
open(file='big.dat',form='unformatted',access='sequential', &
convert='big_endian')
The value of the conversion can be queried by using
`INQUIRE(CONVERT=ch)'. The values returned are `'BIG_ENDIAN'' and
`'LITTLE_ENDIAN''.
`CONVERT' works between big- and little-endian for `INTEGER' values
of all supported kinds and for `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
`REAL(KIND=10)' and `REAL(KIND=16)', will probably not work.
_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 users who do
not have the source code of their 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.

File: gfortran.info, Node: OpenMP, Next: Argument list functions, Prev: CONVERT specifier, Up: Extensions implemented in GNU Fortran
6.1.15 OpenMP
-------------
OpenMP (Open Multi-Processing) is an application programming interface
(API) that supports multi-platform shared memory multiprocessing
programming in C/C++ and Fortran on many architectures, including Unix
and Microsoft Windows platforms. It consists of a set of compiler
directives, library routines, and environment variables that influence
run-time behavior.
GNU Fortran strives to be compatible to the OpenMP Application
Program Interface v3.0 (http://www.openmp.org/mp-documents/spec30.pdf).
To enable the processing of the OpenMP directive `!$omp' in
free-form source code; the `c$omp', `*$omp' and `!$omp' directives in
fixed form; the `!$' conditional compilation sentinels in free form;
and the `c$', `*$' and `!$' sentinels in fixed form, `gfortran' needs
to be invoked with the `-fopenmp'. This also arranges for automatic
linking of the GNU OpenMP runtime library *Note libgomp: (libgomp)Top.
The OpenMP Fortran runtime library routines are provided both in a
form of a Fortran 90 module named `omp_lib' and in a form of a Fortran
`include' file named `omp_lib.h'.
An example of a parallelized loop taken from Appendix A.1 of the
OpenMP Application Program Interface v2.5:
SUBROUTINE A1(N, A, B)
INTEGER I, N
REAL B(N), A(N)
!$OMP PARALLEL DO !I is private by default
DO I=2,N
B(I) = (A(I) + A(I-1)) / 2.0
ENDDO
!$OMP END PARALLEL DO
END SUBROUTINE A1
Please note:
* `-fopenmp' implies `-frecursive', i.e., all local arrays will be
allocated on the stack. When porting existing code to OpenMP, this
may lead to surprising results, especially to segmentation faults
if the stacksize is limited.
* On glibc-based systems, OpenMP enabled applications cannot be
statically linked due to limitations of the underlying
pthreads-implementation. It might be possible to get a working
solution if `-Wl,--whole-archive -lpthread -Wl,--no-whole-archive'
is added to the command line. However, this is not supported by
`gcc' and thus not recommended.

File: gfortran.info, Node: Argument list functions, Prev: OpenMP, Up: Extensions implemented in GNU Fortran
6.1.16 Argument list functions `%VAL', `%REF' and `%LOC'
--------------------------------------------------------
GNU Fortran supports argument list functions `%VAL', `%REF' and `%LOC'
statements, for backward compatibility with g77. It is recommended
that these should be used only for code that is accessing facilities
outside of GNU Fortran, such as operating system or windowing
facilities. It is best to constrain such uses to isolated portions of a
program-portions that deal specifically and exclusively with low-level,
system-dependent facilities. Such portions might well provide a
portable interface for use by the program as a whole, but are
themselves not portable, and should be thoroughly tested each time they
are rebuilt using a new compiler or version of a compiler.
`%VAL' passes a scalar argument by value, `%REF' passes it by
reference and `%LOC' passes its memory location. Since gfortran
already passes scalar arguments by reference, `%REF' is in effect a
do-nothing. `%LOC' has the same effect as a Fortran pointer.
An example of passing an argument by value to a C subroutine foo.:
C
C prototype void foo_ (float x);
C
external foo
real*4 x
x = 3.14159
call foo (%VAL (x))
end
For details refer to the g77 manual
`http://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/index.html#Top'.
Also, `c_by_val.f' and its partner `c_by_val.c' of the GNU Fortran
testsuite are worth a look.

File: gfortran.info, Node: Extensions not implemented in GNU Fortran, Prev: Extensions implemented in GNU Fortran, Up: Extensions
6.2 Extensions not implemented in GNU Fortran
=============================================
The long history of the Fortran language, its wide use and broad
userbase, the large number of different compiler vendors and the lack of
some features crucial to users in the first standards have lead to the
existence of a number of important extensions to the language. While
some of the most useful or popular extensions are supported by the GNU
Fortran compiler, not all existing extensions are supported. This
section aims at listing these extensions and offering advice on how
best make code that uses them running with the GNU Fortran compiler.
* Menu:
* STRUCTURE and RECORD::
* ENCODE and DECODE statements::
* Variable FORMAT expressions::

File: gfortran.info, Node: STRUCTURE and RECORD, Next: ENCODE and DECODE statements, Up: Extensions not implemented in GNU Fortran
6.2.1 `STRUCTURE' and `RECORD'
------------------------------
Structures are user-defined aggregate data types; this functionality was
standardized in Fortran 90 with an different syntax, under the name of
"derived types". Here is an example of code using the non portable
structure syntax:
! Declaring a structure named ``item'' and containing three fields:
! an integer ID, an description string and a floating-point price.
STRUCTURE /item/
INTEGER id
CHARACTER(LEN=200) description
REAL price
END STRUCTURE
! Define two variables, an single record of type ``item''
! named ``pear'', and an array of items named ``store_catalog''
RECORD /item/ pear, store_catalog(100)
! We can directly access the fields of both variables
pear.id = 92316
pear.description = "juicy D'Anjou pear"
pear.price = 0.15
store_catalog(7).id = 7831
store_catalog(7).description = "milk bottle"
store_catalog(7).price = 1.2
! We can also manipulate the whole structure
store_catalog(12) = pear
print *, store_catalog(12)
This code can easily be rewritten in the Fortran 90 syntax as following:
! ``STRUCTURE /name/ ... END STRUCTURE'' becomes
! ``TYPE name ... END TYPE''
TYPE item
INTEGER id
CHARACTER(LEN=200) description
REAL price
END TYPE
! ``RECORD /name/ variable'' becomes ``TYPE(name) variable''
TYPE(item) pear, store_catalog(100)
! Instead of using a dot (.) to access fields of a record, the
! standard syntax uses a percent sign (%)
pear%id = 92316
pear%description = "juicy D'Anjou pear"
pear%price = 0.15
store_catalog(7)%id = 7831
store_catalog(7)%description = "milk bottle"
store_catalog(7)%price = 1.2
! Assignments of a whole variable don't change
store_catalog(12) = pear
print *, store_catalog(12)

File: gfortran.info, Node: ENCODE and DECODE statements, Next: Variable FORMAT expressions, Prev: STRUCTURE and RECORD, Up: Extensions not implemented in GNU Fortran
6.2.2 `ENCODE' and `DECODE' statements
--------------------------------------
GNU Fortran doesn't support the `ENCODE' and `DECODE' statements.
These statements are best replaced by `READ' and `WRITE' statements
involving internal files (`CHARACTER' variables and arrays), which have
been part of the Fortran standard since Fortran 77. For example,
replace a code fragment like
INTEGER*1 LINE(80)
REAL A, B, C
c ... Code that sets LINE
DECODE (80, 9000, LINE) A, B, C
9000 FORMAT (1X, 3(F10.5))
with the following:
CHARACTER(LEN=80) LINE
REAL A, B, C
c ... Code that sets LINE
READ (UNIT=LINE, FMT=9000) A, B, C
9000 FORMAT (1X, 3(F10.5))
Similarly, replace a code fragment like
INTEGER*1 LINE(80)
REAL A, B, C
c ... Code that sets A, B and C
ENCODE (80, 9000, LINE) A, B, C
9000 FORMAT (1X, 'OUTPUT IS ', 3(F10.5))
with the following:
CHARACTER(LEN=80) LINE
REAL A, B, C
c ... Code that sets A, B and C
WRITE (UNIT=LINE, FMT=9000) A, B, C
9000 FORMAT (1X, 'OUTPUT IS ', 3(F10.5))

File: gfortran.info, Node: Variable FORMAT expressions, Prev: ENCODE and DECODE statements, Up: Extensions not implemented in GNU Fortran
6.2.3 Variable `FORMAT' expressions
-----------------------------------
A variable `FORMAT' expression is format statement which includes angle
brackets enclosing a Fortran expression: `FORMAT(I<N>)'. GNU Fortran
does not support this legacy extension. The effect of variable format
expressions can be reproduced by using the more powerful (and standard)
combination of internal output and string formats. For example, replace
a code fragment like this:
WRITE(6,20) INT1
20 FORMAT(I<N+1>)
with the following:
c Variable declaration
CHARACTER(LEN=20) F
c
c Other code here...
c
WRITE(FMT,'("(I", I0, ")")') N+1
WRITE(6,FM) INT1
or with:
c Variable declaration
CHARACTER(LEN=20) FMT
c
c Other code here...
c
WRITE(FMT,*) N+1
WRITE(6,"(I" // ADJUSTL(FMT) // ")") INT1

File: gfortran.info, Node: Mixed-Language Programming, Next: Extensions, Prev: Compiler Characteristics, Up: Top
7 Mixed-Language Programming
****************************
* Menu:
* Interoperability with C::
* GNU Fortran Compiler Directives::
* Non-Fortran Main Program::
This chapter is about mixed-language interoperability, but also
applies if one links Fortran code compiled by different compilers. In
most cases, use of the C Binding features of the Fortran 2003 standard
is sufficient, and their use is highly recommended.

File: gfortran.info, Node: Interoperability with C, Next: GNU Fortran Compiler Directives, Up: Mixed-Language Programming
7.1 Interoperability with C
===========================
* Menu:
* Intrinsic Types::
* Further Interoperability of Fortran with C::
* Derived Types and struct::
* Interoperable Global Variables::
* Interoperable Subroutines and Functions::
Since Fortran 2003 (ISO/IEC 1539-1:2004(E)) there is a standardized
way to generate procedure and derived-type declarations and global
variables which are interoperable with C (ISO/IEC 9899:1999). The
`bind(C)' attribute has been added to inform the compiler that a symbol
shall be interoperable with C; also, some constraints are added. Note,
however, that not all C features have a Fortran equivalent or vice
versa. For instance, neither C's unsigned integers nor C's functions
with variable number of arguments have an equivalent in Fortran.
Note that array dimensions are reversely ordered in C and that
arrays in C always start with index 0 while in Fortran they start by
default with 1. Thus, an array declaration `A(n,m)' in Fortran matches
`A[m][n]' in C and accessing the element `A(i,j)' matches
`A[j-1][i-1]'. The element following `A(i,j)' (C: `A[j-1][i-1]';
assuming i < n) in memory is `A(i+1,j)' (C: `A[j-1][i]').

File: gfortran.info, Node: Intrinsic Types, Next: Further Interoperability of Fortran with C, Up: Interoperability with C
7.1.1 Intrinsic Types
---------------------
In order to ensure that exactly the same variable type and kind is used
in C and Fortran, the named constants shall be used which are defined
in the `ISO_C_BINDING' intrinsic module. That module contains named
constants for kind parameters and character named constants for the
escape sequences in C. For a list of the constants, see *Note
ISO_C_BINDING::.

File: gfortran.info, Node: Derived Types and struct, Next: Interoperable Global Variables, Prev: Further Interoperability of Fortran with C, Up: Interoperability with C
7.1.2 Derived Types and struct
------------------------------
For compatibility of derived types with `struct', one needs to use the
`BIND(C)' attribute in the type declaration. For instance, the
following type declaration
USE ISO_C_BINDING
TYPE, BIND(C) :: myType
INTEGER(C_INT) :: i1, i2
INTEGER(C_SIGNED_CHAR) :: i3
REAL(C_DOUBLE) :: d1
COMPLEX(C_FLOAT_COMPLEX) :: c1
CHARACTER(KIND=C_CHAR) :: str(5)
END TYPE
matches the following `struct' declaration in C
struct {
int i1, i2;
/* Note: "char" might be signed or unsigned. */
signed char i3;
double d1;
float _Complex c1;
char str[5];
} myType;
Derived types with the C binding attribute shall not have the
`sequence' attribute, type parameters, the `extends' attribute, nor
type-bound procedures. Every component must be of interoperable type
and kind and may not have the `pointer' or `allocatable' attribute. The
names of the variables are irrelevant for interoperability.
As there exist no direct Fortran equivalents, neither unions nor
structs with bit field or variable-length array members are
interoperable.

File: gfortran.info, Node: Interoperable Global Variables, Next: Interoperable Subroutines and Functions, Prev: Derived Types and struct, Up: Interoperability with C
7.1.3 Interoperable Global Variables
------------------------------------
Variables can be made accessible from C using the C binding attribute,
optionally together with specifying a binding name. Those variables
have to be declared in the declaration part of a `MODULE', be of
interoperable type, and have neither the `pointer' nor the
`allocatable' attribute.
MODULE m
USE myType_module
USE ISO_C_BINDING
integer(C_INT), bind(C, name="_MyProject_flags") :: global_flag
type(myType), bind(C) :: tp
END MODULE
Here, `_MyProject_flags' is the case-sensitive name of the variable
as seen from C programs while `global_flag' is the case-insensitive
name as seen from Fortran. If no binding name is specified, as for TP,
the C binding name is the (lowercase) Fortran binding name. If a
binding name is specified, only a single variable may be after the
double colon. Note of warning: You cannot use a global variable to
access ERRNO of the C library as the C standard allows it to be a
macro. Use the `IERRNO' intrinsic (GNU extension) instead.

File: gfortran.info, Node: Interoperable Subroutines and Functions, Prev: Interoperable Global Variables, Up: Interoperability with C
7.1.4 Interoperable Subroutines and Functions
---------------------------------------------
Subroutines and functions have to have the `BIND(C)' attribute to be
compatible with C. The dummy argument declaration is relatively
straightforward. However, one needs to be careful because C uses
call-by-value by default while Fortran behaves usually similar to
call-by-reference. Furthermore, strings and pointers are handled
differently. Note that only explicit size and assumed-size arrays are
supported but not assumed-shape or allocatable arrays.
To pass a variable by value, use the `VALUE' attribute. Thus the
following C prototype
`int func(int i, int *j)'
matches the Fortran declaration
integer(c_int) function func(i,j)
use iso_c_binding, only: c_int
integer(c_int), VALUE :: i
integer(c_int) :: j
Note that pointer arguments also frequently need the `VALUE'
attribute.
Strings are handled quite differently in C and Fortran. In C a string
is a `NUL'-terminated array of characters while in Fortran each string
has a length associated with it and is thus not terminated (by e.g.
`NUL'). For example, if one wants to use the following C function,
#include <stdio.h>
void print_C(char *string) /* equivalent: char string[] */
{
printf("%s\n", string);
}
to print "Hello World" from Fortran, one can call it using
use iso_c_binding, only: C_CHAR, C_NULL_CHAR
interface
subroutine print_c(string) bind(C, name="print_C")
use iso_c_binding, only: c_char
character(kind=c_char) :: string(*)
end subroutine print_c
end interface
call print_c(C_CHAR_"Hello World"//C_NULL_CHAR)
As the example shows, one needs to ensure that the string is `NUL'
terminated. Additionally, the dummy argument STRING of `print_C' is a
length-one assumed-size array; using `character(len=*)' is not allowed.
The example above uses `c_char_"Hello World"' to ensure the string
literal has the right type; typically the default character kind and
`c_char' are the same and thus `"Hello World"' is equivalent. However,
the standard does not guarantee this.
The use of pointers is now illustrated using the C library function
`strncpy', whose prototype is
char *strncpy(char *restrict s1, const char *restrict s2, size_t n);
The function `strncpy' copies at most N characters from string S2 to
S1 and returns S1. In the following example, we ignore the return value:
use iso_c_binding
implicit none
character(len=30) :: str,str2
interface
! Ignore the return value of strncpy -> subroutine
! "restrict" is always assumed if we do not pass a pointer
subroutine strncpy(dest, src, n) bind(C)
import
character(kind=c_char), intent(out) :: dest(*)
character(kind=c_char), intent(in) :: src(*)
integer(c_size_t), value, intent(in) :: n
end subroutine strncpy
end interface
str = repeat('X',30) ! Initialize whole string with 'X'
call strncpy(str, c_char_"Hello World"//C_NULL_CHAR, &
len(c_char_"Hello World",kind=c_size_t))
print '(a)', str ! prints: "Hello WorldXXXXXXXXXXXXXXXXXXX"
end
C pointers are represented in Fortran via the special derived type
`type(c_ptr)', with private components. Thus one needs to use intrinsic
conversion procedures to convert from or to C pointers. For example,
use iso_c_binding
type(c_ptr) :: cptr1, cptr2
integer, target :: array(7), scalar
integer, pointer :: pa(:), ps
cptr1 = c_loc(array(1)) ! The programmer needs to ensure that the
! array is contiguous if required by the C
! procedure
cptr2 = c_loc(scalar)
call c_f_pointer(cptr2, ps)
call c_f_pointer(cptr2, pa, shape=[7])
When converting C to Fortran arrays, the one-dimensional `SHAPE'
argument has to be passed. Note: A pointer argument `void *' matches
`TYPE(C_PTR), VALUE' while `TYPE(C_PTR)' matches `void **'.
Procedure pointers are handled analogously to pointers; the C type is
`TYPE(C_FUNPTR)' and the intrinsic conversion procedures are
`C_F_PROC_POINTER' and `C_FUNLOC'.
The intrinsic procedures are described in *Note Intrinsic
Procedures::.

File: gfortran.info, Node: Further Interoperability of Fortran with C, Next: Derived Types and struct, Prev: Intrinsic Types, Up: Interoperability with C
7.1.5 Further Interoperability of Fortran with C
------------------------------------------------
Assumed-shape and allocatable arrays are passed using an array
descriptor (dope vector). The internal structure of the array
descriptor used by GNU Fortran is not yet documented and will change.
There will also be a Technical Report (TR 29113) which standardizes an
interoperable array descriptor. Until then, you can use the Chasm
Language Interoperability Tools,
`http://chasm-interop.sourceforge.net/', which provide an interface to
GNU Fortran's array descriptor.
The technical report 29113 will presumably also include support for
C-interoperable `OPTIONAL' and for assumed-rank and assumed-type dummy
arguments. However, the TR has neither been approved nor implemented in
GNU Fortran; therefore, these features are not yet available.

File: gfortran.info, Node: GNU Fortran Compiler Directives, Next: Non-Fortran Main Program, Prev: Interoperability with C, Up: Mixed-Language Programming
7.2 GNU Fortran Compiler Directives
===================================
The Fortran standard standard describes how a conforming program shall
behave; however, the exact implementation is not standardized. In order
to allow the user to choose specific implementation details, compiler
directives can be used to set attributes of variables and procedures
which are not part of the standard. Whether a given attribute is
supported and its exact effects depend on both the operating system and
on the processor; see *Note C Extensions: (gcc)Top. for details.
For procedures and procedure pointers, the following attributes can
be used to change the calling convention:
* `CDECL' - standard C calling convention
* `STDCALL' - convention where the called procedure pops the stack
* `FASTCALL' - part of the arguments are passed via registers
instead using the stack
Besides changing the calling convention, the attributes also
influence the decoration of the symbol name, e.g., by a leading
underscore or by a trailing at-sign followed by the number of bytes on
the stack. When assigning a procedure to a procedure pointer, both
should use the same calling convention.
On some systems, procedures and global variables (module variables
and `COMMON' blocks) need special handling to be accessible when they
are in a shared library. The following attributes are available:
* `DLLEXPORT' - provide a global pointer to a pointer in the DLL
* `DLLIMPORT' - reference the function or variable using a global
pointer
The attributes are specified using the syntax
`!GCC$ ATTRIBUTES' ATTRIBUTE-LIST `::' VARIABLE-LIST
where in free-form source code only whitespace is allowed before
`!GCC$' and in fixed-form source code `!GCC$', `cGCC$' or `*GCC$' shall
start in the first column.
For procedures, the compiler directives shall be placed into the body
of the procedure; for variables and procedure pointers, they shall be in
the same declaration part as the variable or procedure pointer.

File: gfortran.info, Node: Non-Fortran Main Program, Prev: GNU Fortran Compiler Directives, Up: Mixed-Language Programming
7.3 Non-Fortran Main Program
============================
* Menu:
* _gfortran_set_args:: Save command-line arguments
* _gfortran_set_options:: Set library option flags
* _gfortran_set_convert:: Set endian conversion
* _gfortran_set_record_marker:: Set length of record markers
* _gfortran_set_max_subrecord_length:: Set subrecord length
* _gfortran_set_fpe:: Set when a Floating Point Exception should be raised
Even if you are doing mixed-language programming, it is very likely
that you do not need to know or use the information in this section.
Since it is about the internal structure of GNU Fortran, it may also
change in GCC minor releases.
When you compile a `PROGRAM' with GNU Fortran, a function with the
name `main' (in the symbol table of the object file) is generated,
which initializes the libgfortran library and then calls the actual
program which uses the name `MAIN__', for historic reasons. If you link
GNU Fortran compiled procedures to, e.g., a C or C++ program or to a
Fortran program compiled by a different compiler, the libgfortran
library is not initialized and thus a few intrinsic procedures do not
work properly, e.g. those for obtaining the command-line arguments.
Therefore, if your `PROGRAM' is not compiled with GNU Fortran and
the GNU Fortran compiled procedures require intrinsics relying on the
library initialization, you need to initialize the library yourself.
Using the default options, gfortran calls `_gfortran_set_args' and
`_gfortran_set_options'. The initialization of the former is needed if
the called procedures access the command line (and for backtracing);
the latter sets some flags based on the standard chosen or to enable
backtracing. In typical programs, it is not necessary to call any
initialization function.
If your `PROGRAM' is compiled with GNU Fortran, you shall not call
any of the following functions. The libgfortran initialization
functions are shown in C syntax but using C bindings they are also
accessible from Fortran.

File: gfortran.info, Node: _gfortran_set_args, Next: _gfortran_set_options, Up: Non-Fortran Main Program
7.3.1 `_gfortran_set_args' -- Save command-line arguments
---------------------------------------------------------
_Description_:
`_gfortran_set_args' saves the command-line arguments; this
initialization is required if any of the command-line intrinsics
is called. Additionally, it shall be called if backtracing is
enabled (see `_gfortran_set_options').
_Syntax_:
`void _gfortran_set_args (int argc, char *argv[])'
_Arguments_:
ARGC number of command line argument strings
ARGV the command-line argument strings; argv[0] is
the pathname of the executable itself.
_Example_:
int main (int argc, char *argv[])
{
/* Initialize libgfortran. */
_gfortran_set_args (argc, argv);
return 0;
}

File: gfortran.info, Node: _gfortran_set_options, Next: _gfortran_set_convert, Prev: _gfortran_set_args, Up: Non-Fortran Main Program
7.3.2 `_gfortran_set_options' -- Set library option flags
---------------------------------------------------------
_Description_:
`_gfortran_set_options' sets several flags related to the Fortran
standard to be used, whether backtracing or core dumps should be
enabled and whether range checks should be performed. The syntax
allows for upward compatibility since the number of passed flags
is specified; for non-passed flags, the default value is used. See
also *note Code Gen Options::. Please note that not all flags are
actually used.
_Syntax_:
`void _gfortran_set_options (int num, int options[])'
_Arguments_:
NUM number of options passed
ARGV The list of flag values
_option flag list_:
OPTION[0] Allowed standard; can give run-time errors if
e.g. an input-output edit descriptor is
invalid in a given standard. Possible values
are (bitwise or-ed) `GFC_STD_F77' (1),
`GFC_STD_F95_OBS' (2), `GFC_STD_F95_DEL' (4),
`GFC_STD_F95' (8), `GFC_STD_F2003' (16),
`GFC_STD_GNU' (32), `GFC_STD_LEGACY' (64), and
`GFC_STD_F2008' (128). Default:
`GFC_STD_F95_OBS | GFC_STD_F95_DEL |
GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 |
GFC_STD_F77 | GFC_STD_GNU | GFC_STD_LEGACY'.
OPTION[1] Standard-warning flag; prints a warning to
standard error. Default: `GFC_STD_F95_DEL |
GFC_STD_LEGACY'.
OPTION[2] If non zero, enable pedantic checking.
Default: off.
OPTION[3] If non zero, enable core dumps on run-time
errors. Default: off.
OPTION[4] If non zero, enable backtracing on run-time
errors. Default: off. Note: Installs a signal
handler and requires command-line
initialization using `_gfortran_set_args'.
OPTION[5] If non zero, supports signed zeros. Default:
enabled.
OPTION[6] Enables run-time checking. Possible values are
(bitwise or-ed): GFC_RTCHECK_BOUNDS (1),
GFC_RTCHECK_ARRAY_TEMPS (2),
GFC_RTCHECK_RECURSION (4), GFC_RTCHECK_DO
(16), GFC_RTCHECK_POINTER (32). Default:
disabled.
OPTION[7] If non zero, range checking is enabled.
Default: enabled. See -frange-check (*note
Code Gen Options::).
_Example_:
/* Use gfortran 4.5 default options. */
static int options[] = {68, 255, 0, 0, 0, 1, 0, 1};
_gfortran_set_options (8, &options);

File: gfortran.info, Node: _gfortran_set_convert, Next: _gfortran_set_record_marker, Prev: _gfortran_set_options, Up: Non-Fortran Main Program
7.3.3 `_gfortran_set_convert' -- Set endian conversion
------------------------------------------------------
_Description_:
`_gfortran_set_convert' set the representation of data for
unformatted files.
_Syntax_:
`void _gfortran_set_convert (int conv)'
_Arguments_:
CONV Endian conversion, possible values:
GFC_CONVERT_NATIVE (0, default),
GFC_CONVERT_SWAP (1), GFC_CONVERT_BIG (2),
GFC_CONVERT_LITTLE (3).
_Example_:
int main (int argc, char *argv[])
{
/* Initialize libgfortran. */
_gfortran_set_args (argc, argv);
_gfortran_set_convert (1);
return 0;
}

File: gfortran.info, Node: _gfortran_set_record_marker, Next: _gfortran_set_max_subrecord_length, Prev: _gfortran_set_convert, Up: Non-Fortran Main Program
7.3.4 `_gfortran_set_record_marker' -- Set length of record markers
-------------------------------------------------------------------
_Description_:
`_gfortran_set_record_marker' sets the length of record markers
for unformatted files.
_Syntax_:
`void _gfortran_set_record_marker (int val)'
_Arguments_:
VAL Length of the record marker; valid values are
4 and 8. Default is 4.
_Example_:
int main (int argc, char *argv[])
{
/* Initialize libgfortran. */
_gfortran_set_args (argc, argv);
_gfortran_set_record_marker (8);
return 0;
}

File: gfortran.info, Node: _gfortran_set_fpe, Prev: _gfortran_set_max_subrecord_length, Up: Non-Fortran Main Program
7.3.5 `_gfortran_set_fpe' -- Set when a Floating Point Exception should be raised
---------------------------------------------------------------------------------
_Description_:
`_gfortran_set_fpe' sets the IEEE exceptions for which a Floating
Point Exception (FPE) should be raised. On most systems, this will
result in a SIGFPE signal being sent and the program being
interrupted.
_Syntax_:
`void _gfortran_set_fpe (int val)'
_Arguments_:
OPTION[0] IEEE exceptions. Possible values are (bitwise
or-ed) zero (0, default) no trapping,
`GFC_FPE_INVALID' (1), `GFC_FPE_DENORMAL' (2),
`GFC_FPE_ZERO' (4), `GFC_FPE_OVERFLOW' (8),
`GFC_FPE_UNDERFLOW' (16), and
`GFC_FPE_PRECISION' (32).
_Example_:
int main (int argc, char *argv[])
{
/* Initialize libgfortran. */
_gfortran_set_args (argc, argv);
/* FPE for invalid operations such as SQRT(-1.0). */
_gfortran_set_fpe (1);
return 0;
}

File: gfortran.info, Node: _gfortran_set_max_subrecord_length, Next: _gfortran_set_fpe, Prev: _gfortran_set_record_marker, Up: Non-Fortran Main Program
7.3.6 `_gfortran_set_max_subrecord_length' -- Set subrecord length
------------------------------------------------------------------
_Description_:
`_gfortran_set_max_subrecord_length' set the maximum length for a
subrecord. This option only makes sense for testing and debugging
of unformatted I/O.
_Syntax_:
`void _gfortran_set_max_subrecord_length (int val)'
_Arguments_:
VAL the maximum length for a subrecord; the
maximum permitted value is 2147483639, which
is also the default.
_Example_:
int main (int argc, char *argv[])
{
/* Initialize libgfortran. */
_gfortran_set_args (argc, argv);
_gfortran_set_max_subrecord_length (8);
return 0;
}

File: gfortran.info, Node: Intrinsic Procedures, Next: Intrinsic Modules, Prev: Extensions, Up: Top
8 Intrinsic Procedures
**********************
* Menu:
* Introduction: Introduction to Intrinsics
* `ABORT': ABORT, Abort the program
* `ABS': ABS, Absolute value
* `ACCESS': ACCESS, Checks file access modes
* `ACHAR': ACHAR, Character in ASCII collating sequence
* `ACOS': ACOS, Arccosine function
* `ACOSH': ACOSH, Inverse hyperbolic cosine function
* `ADJUSTL': ADJUSTL, Left adjust a string
* `ADJUSTR': ADJUSTR, Right adjust a string
* `AIMAG': AIMAG, Imaginary part of complex number
* `AINT': AINT, Truncate to a whole number
* `ALARM': ALARM, Set an alarm clock
* `ALL': ALL, Determine if all values are true
* `ALLOCATED': ALLOCATED, Status of allocatable entity
* `AND': AND, Bitwise logical AND
* `ANINT': ANINT, Nearest whole number
* `ANY': ANY, Determine if any values are true
* `ASIN': ASIN, Arcsine function
* `ASINH': ASINH, Inverse hyperbolic sine function
* `ASSOCIATED': ASSOCIATED, Status of a pointer or pointer/target pair
* `ATAN': ATAN, Arctangent function
* `ATAN2': ATAN2, Arctangent function
* `ATANH': ATANH, Inverse hyperbolic tangent function
* `BESSEL_J0': BESSEL_J0, Bessel function of the first kind of order 0
* `BESSEL_J1': BESSEL_J1, Bessel function of the first kind of order 1
* `BESSEL_JN': BESSEL_JN, Bessel function of the first kind
* `BESSEL_Y0': BESSEL_Y0, Bessel function of the second kind of order 0
* `BESSEL_Y1': BESSEL_Y1, Bessel function of the second kind of order 1
* `BESSEL_YN': BESSEL_YN, Bessel function of the second kind
* `BIT_SIZE': BIT_SIZE, Bit size inquiry function
* `BTEST': BTEST, Bit test function
* `C_ASSOCIATED': C_ASSOCIATED, Status of a C pointer
* `C_F_POINTER': C_F_POINTER, Convert C into Fortran pointer
* `C_F_PROCPOINTER': C_F_PROCPOINTER, Convert C into Fortran procedure pointer
* `C_FUNLOC': C_FUNLOC, Obtain the C address of a procedure
* `C_LOC': C_LOC, Obtain the C address of an object
* `C_SIZEOF': C_SIZEOF, Size in bytes of an expression
* `CEILING': CEILING, Integer ceiling function
* `CHAR': CHAR, Integer-to-character conversion function
* `CHDIR': CHDIR, Change working directory
* `CHMOD': CHMOD, Change access permissions of files
* `CMPLX': CMPLX, Complex conversion function
* `COMMAND_ARGUMENT_COUNT': COMMAND_ARGUMENT_COUNT, Get number of command line arguments
* `COMPLEX': COMPLEX, Complex conversion function
* `CONJG': CONJG, Complex conjugate function
* `COS': COS, Cosine function
* `COSH': COSH, Hyperbolic cosine function
* `COUNT': COUNT, Count occurrences of TRUE in an array
* `CPU_TIME': CPU_TIME, CPU time subroutine
* `CSHIFT': CSHIFT, Circular shift elements of an array
* `CTIME': CTIME, Subroutine (or function) to convert a time into a string
* `DATE_AND_TIME': DATE_AND_TIME, Date and time subroutine
* `DBLE': DBLE, Double precision conversion function
* `DCMPLX': DCMPLX, Double complex conversion function
* `DFLOAT': DFLOAT, Double precision conversion function
* `DIGITS': DIGITS, Significant digits function
* `DIM': DIM, Positive difference
* `DOT_PRODUCT': DOT_PRODUCT, Dot product function
* `DPROD': DPROD, Double product function
* `DREAL': DREAL, Double real part function
* `DTIME': DTIME, Execution time subroutine (or function)
* `EOSHIFT': EOSHIFT, End-off shift elements of an array
* `EPSILON': EPSILON, Epsilon function
* `ERF': ERF, Error function
* `ERFC': ERFC, Complementary error function
* `ERFC_SCALED': ERFC_SCALED, Exponentially-scaled complementary error function
* `ETIME': ETIME, Execution time subroutine (or function)
* `EXIT': EXIT, Exit the program with status.
* `EXP': EXP, Exponential function
* `EXPONENT': EXPONENT, Exponent function
* `FDATE': FDATE, Subroutine (or function) to get the current time as a string
* `FGET': FGET, Read a single character in stream mode from stdin
* `FGETC': FGETC, Read a single character in stream mode
* `FLOAT': FLOAT, Convert integer to default real
* `FLOOR': FLOOR, Integer floor function
* `FLUSH': FLUSH, Flush I/O unit(s)
* `FNUM': FNUM, File number function
* `FPUT': FPUT, Write a single character in stream mode to stdout
* `FPUTC': FPUTC, Write a single character in stream mode
* `FRACTION': FRACTION, Fractional part of the model representation
* `FREE': FREE, Memory de-allocation subroutine
* `FSEEK': FSEEK, Low level file positioning subroutine
* `FSTAT': FSTAT, Get file status
* `FTELL': FTELL, Current stream position
* `GAMMA': GAMMA, Gamma function
* `GERROR': GERROR, Get last system error message
* `GETARG': GETARG, Get command line arguments
* `GET_COMMAND': GET_COMMAND, Get the entire command line
* `GET_COMMAND_ARGUMENT': GET_COMMAND_ARGUMENT, Get command line arguments
* `GETCWD': GETCWD, Get current working directory
* `GETENV': GETENV, Get an environmental variable
* `GET_ENVIRONMENT_VARIABLE': GET_ENVIRONMENT_VARIABLE, Get an environmental variable
* `GETGID': GETGID, Group ID function
* `GETLOG': GETLOG, Get login name
* `GETPID': GETPID, Process ID function
* `GETUID': GETUID, User ID function
* `GMTIME': GMTIME, Convert time to GMT info
* `HOSTNM': HOSTNM, Get system host name
* `HUGE': HUGE, Largest number of a kind
* `HYPOT': HYPOT, Euclidian distance function
* `IACHAR': IACHAR, Code in ASCII collating sequence
* `IAND': IAND, Bitwise logical and
* `IARGC': IARGC, Get the number of command line arguments
* `IBCLR': IBCLR, Clear bit
* `IBITS': IBITS, Bit extraction
* `IBSET': IBSET, Set bit
* `ICHAR': ICHAR, Character-to-integer conversion function
* `IDATE': IDATE, Current local time (day/month/year)
* `IEOR': IEOR, Bitwise logical exclusive or
* `IERRNO': IERRNO, Function to get the last system error number
* `INDEX': INDEX intrinsic, Position of a substring within a string
* `INT': INT, Convert to integer type
* `INT2': INT2, Convert to 16-bit integer type
* `INT8': INT8, Convert to 64-bit integer type
* `IOR': IOR, Bitwise logical or
* `IRAND': IRAND, Integer pseudo-random number
* `IS_IOSTAT_END': IS_IOSTAT_END, Test for end-of-file value
* `IS_IOSTAT_EOR': IS_IOSTAT_EOR, Test for end-of-record value
* `ISATTY': ISATTY, Whether a unit is a terminal device
* `ISHFT': ISHFT, Shift bits
* `ISHFTC': ISHFTC, Shift bits circularly
* `ISNAN': ISNAN, Tests for a NaN
* `ITIME': ITIME, Current local time (hour/minutes/seconds)
* `KILL': KILL, Send a signal to a process
* `KIND': KIND, Kind of an entity
* `LBOUND': LBOUND, Lower dimension bounds of an array
* `LEADZ': LEADZ, Number of leading zero bits of an integer
* `LEN': LEN, Length of a character entity
* `LEN_TRIM': LEN_TRIM, Length of a character entity without trailing blank characters
* `LGE': LGE, Lexical greater than or equal
* `LGT': LGT, Lexical greater than
* `LINK': LINK, Create a hard link
* `LLE': LLE, Lexical less than or equal
* `LLT': LLT, Lexical less than
* `LNBLNK': LNBLNK, Index of the last non-blank character in a string
* `LOC': LOC, Returns the address of a variable
* `LOG': LOG, Logarithm function
* `LOG10': LOG10, Base 10 logarithm function
* `LOG_GAMMA': LOG_GAMMA, Logarithm of the Gamma function
* `LOGICAL': LOGICAL, Convert to logical type
* `LONG': LONG, Convert to integer type
* `LSHIFT': LSHIFT, Left shift bits
* `LSTAT': LSTAT, Get file status
* `LTIME': LTIME, Convert time to local time info
* `MALLOC': MALLOC, Dynamic memory allocation function
* `MATMUL': MATMUL, matrix multiplication
* `MAX': MAX, Maximum value of an argument list
* `MAXEXPONENT': MAXEXPONENT, Maximum exponent of a real kind
* `MAXLOC': MAXLOC, Location of the maximum value within an array
* `MAXVAL': MAXVAL, Maximum value of an array
* `MCLOCK': MCLOCK, Time function
* `MCLOCK8': MCLOCK8, Time function (64-bit)
* `MERGE': MERGE, Merge arrays
* `MIN': MIN, Minimum value of an argument list
* `MINEXPONENT': MINEXPONENT, Minimum exponent of a real kind
* `MINLOC': MINLOC, Location of the minimum value within an array
* `MINVAL': MINVAL, Minimum value of an array
* `MOD': MOD, Remainder function
* `MODULO': MODULO, Modulo function
* `MOVE_ALLOC': MOVE_ALLOC, Move allocation from one object to another
* `MVBITS': MVBITS, Move bits from one integer to another
* `NEAREST': NEAREST, Nearest representable number
* `NEW_LINE': NEW_LINE, New line character
* `NINT': NINT, Nearest whole number
* `NOT': NOT, Logical negation
* `NULL': NULL, Function that returns an disassociated pointer
* `OR': OR, Bitwise logical OR
* `PACK': PACK, Pack an array into an array of rank one
* `PERROR': PERROR, Print system error message
* `PRECISION': PRECISION, Decimal precision of a real kind
* `PRESENT': PRESENT, Determine whether an optional dummy argument is specified
* `PRODUCT': PRODUCT, Product of array elements
* `RADIX': RADIX, Base of a data model
* `RANDOM_NUMBER': RANDOM_NUMBER, Pseudo-random number
* `RANDOM_SEED': RANDOM_SEED, Initialize a pseudo-random number sequence
* `RAND': RAND, Real pseudo-random number
* `RANGE': RANGE, Decimal exponent range
* `RAN': RAN, Real pseudo-random number
* `REAL': REAL, Convert to real type
* `RENAME': RENAME, Rename a file
* `REPEAT': REPEAT, Repeated string concatenation
* `RESHAPE': RESHAPE, Function to reshape an array
* `RRSPACING': RRSPACING, Reciprocal of the relative spacing
* `RSHIFT': RSHIFT, Right shift bits
* `SCALE': SCALE, Scale a real value
* `SCAN': SCAN, Scan a string for the presence of a set of characters
* `SECNDS': SECNDS, Time function
* `SECOND': SECOND, CPU time function
* `SELECTED_CHAR_KIND': SELECTED_CHAR_KIND, Choose character kind
* `SELECTED_INT_KIND': SELECTED_INT_KIND, Choose integer kind
* `SELECTED_REAL_KIND': SELECTED_REAL_KIND, Choose real kind
* `SET_EXPONENT': SET_EXPONENT, Set the exponent of the model
* `SHAPE': SHAPE, Determine the shape of an array
* `SIGN': SIGN, Sign copying function
* `SIGNAL': SIGNAL, Signal handling subroutine (or function)
* `SIN': SIN, Sine function
* `SINH': SINH, Hyperbolic sine function
* `SIZE': SIZE, Function to determine the size of an array
* `SIZEOF': SIZEOF, Determine the size in bytes of an expression
* `SLEEP': SLEEP, Sleep for the specified number of seconds
* `SNGL': SNGL, Convert double precision real to default real
* `SPACING': SPACING, Smallest distance between two numbers of a given type
* `SPREAD': SPREAD, Add a dimension to an array
* `SQRT': SQRT, Square-root function
* `SRAND': SRAND, Reinitialize the random number generator
* `STAT': STAT, Get file status
* `SUM': SUM, Sum of array elements
* `SYMLNK': SYMLNK, Create a symbolic link
* `SYSTEM': SYSTEM, Execute a shell command
* `SYSTEM_CLOCK': SYSTEM_CLOCK, Time function
* `TAN': TAN, Tangent function
* `TANH': TANH, Hyperbolic tangent function
* `TIME': TIME, Time function
* `TIME8': TIME8, Time function (64-bit)
* `TINY': TINY, Smallest positive number of a real kind
* `TRAILZ': TRAILZ, Number of trailing zero bits of an integer
* `TRANSFER': TRANSFER, Transfer bit patterns
* `TRANSPOSE': TRANSPOSE, Transpose an array of rank two
* `TRIM': TRIM, Remove trailing blank characters of a string
* `TTYNAM': TTYNAM, Get the name of a terminal device.
* `UBOUND': UBOUND, Upper dimension bounds of an array
* `UMASK': UMASK, Set the file creation mask
* `UNLINK': UNLINK, Remove a file from the file system
* `UNPACK': UNPACK, Unpack an array of rank one into an array
* `VERIFY': VERIFY, Scan a string for the absence of a set of characters
* `XOR': XOR, Bitwise logical exclusive or

File: gfortran.info, Node: Introduction to Intrinsics, Next: ABORT, Up: Intrinsic Procedures
8.1 Introduction to intrinsic procedures
========================================
The intrinsic procedures provided by GNU Fortran include all of the
intrinsic procedures required by the Fortran 95 standard, a set of
intrinsic procedures for backwards compatibility with G77, and a
selection of intrinsic procedures from the Fortran 2003 and Fortran 2008
standards. Any conflict between a description here and a description in
either the Fortran 95 standard, the Fortran 2003 standard or the Fortran
2008 standard is unintentional, and the standard(s) should be considered
authoritative.
The enumeration of the `KIND' type parameter is processor defined in
the Fortran 95 standard. GNU Fortran defines the default integer type
and default real type by `INTEGER(KIND=4)' and `REAL(KIND=4)',
respectively. The standard mandates that both data types shall have
another kind, which have more precision. On typical target
architectures supported by `gfortran', this kind type parameter is
`KIND=8'. Hence, `REAL(KIND=8)' and `DOUBLE PRECISION' are equivalent.
In the description of generic intrinsic procedures, the kind type
parameter will be specified by `KIND=*', and in the description of
specific names for an intrinsic procedure the kind type parameter will
be explicitly given (e.g., `REAL(KIND=4)' or `REAL(KIND=8)'). Finally,
for brevity the optional `KIND=' syntax will be omitted.
Many of the intrinsic procedures take one or more optional arguments.
This document follows the convention used in the Fortran 95 standard,
and denotes such arguments by square brackets.
GNU Fortran offers the `-std=f95' and `-std=gnu' options, which can
be used to restrict the set of intrinsic procedures to a given
standard. By default, `gfortran' sets the `-std=gnu' option, and so
all intrinsic procedures described here are accepted. There is one
caveat. For a select group of intrinsic procedures, `g77' implemented
both a function and a subroutine. Both classes have been implemented
in `gfortran' for backwards compatibility with `g77'. It is noted here
that these functions and subroutines cannot be intermixed in a given
subprogram. In the descriptions that follow, the applicable standard
for each intrinsic procedure is noted.

File: gfortran.info, Node: ABORT, Next: ABS, Prev: Introduction to Intrinsics, Up: Intrinsic Procedures
8.2 `ABORT' -- Abort the program
================================
_Description_:
`ABORT' causes immediate termination of the program. On operating
systems that support a core dump, `ABORT' will produce a core dump
even if the option `-fno-dump-core' is in effect, which is
suitable for debugging purposes.
_Standard_:
GNU extension
_Class_:
Subroutine
_Syntax_:
`CALL ABORT'
_Return value_:
Does not return.
_Example_:
program test_abort
integer :: i = 1, j = 2
if (i /= j) call abort
end program test_abort
_See also_:
*Note EXIT::, *Note KILL::

File: gfortran.info, Node: ABS, Next: ACCESS, Prev: ABORT, Up: Intrinsic Procedures
8.3 `ABS' -- Absolute value
===========================
_Description_:
`ABS(A)' computes the absolute value of `A'.
_Standard_:
Fortran 77 and later, has overloads that are GNU extensions
_Class_:
Elemental function
_Syntax_:
`RESULT = ABS(A)'
_Arguments_:
A The type of the argument shall be an `INTEGER',
`REAL', or `COMPLEX'.
_Return value_:
The return value is of the same type and kind as the argument
except the return value is `REAL' for a `COMPLEX' argument.
_Example_:
program test_abs
integer :: i = -1
real :: x = -1.e0
complex :: z = (-1.e0,0.e0)
i = abs(i)
x = abs(x)
x = abs(z)