Gfortran
Gfortran
(GCC)
Short Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Language Reference
4 Compiler Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5 Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6 Mixed-Language Programming . . . . . . . . . . . . . . . . . . . . . . . . . . 69
7 Coarray Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
8 Intrinsic Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
9 Intrinsic Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Contributing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
GNU General Public License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
GNU Free Documentation License . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Funding Free Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
Option Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Keyword Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
iii
Table of Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 About GNU Fortran . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 GNU Fortran and GCC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Standards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.1 Fortran 95 status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.2 Fortran 2003 status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.3 Fortran 2008 status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3.4 Fortran 2018 status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4 Compiler Characteristics . . . . . . . . . . . . . . . . . . . . . . 41
4.1 KIND Type Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.2 Internal representation of LOGICAL variables . . . . . . . . . . . . . . . . . 41
4.3 Evaluation of logical expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.4 MAX and MIN intrinsics with REAL NaN arguments . . . . . . . . . . 42
4.5 Thread-safety of the runtime library . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.6 Data consistency and durability. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.7 Files opened without an explicit ACTION= specifier . . . . . . . . . . . 44
4.8 File operations on symbolic links. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.9 File format of unformatted sequential files . . . . . . . . . . . . . . . . . . . . . 44
4.10 Asynchronous I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.11 Behavior on integer overflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5 Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.1 Extensions implemented in GNU Fortran . . . . . . . . . . . . . . . . . . . . . . 47
5.1.1 Old-style kind specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.1.2 Old-style variable initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.1.3 Extensions to namelist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
5.1.4 X format descriptor without count field . . . . . . . . . . . . . . . . . . . . 49
5.1.5 Commas in FORMAT specifications . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.1.6 Missing period in FORMAT specifications . . . . . . . . . . . . . . . . . . . 49
5.1.7 Default widths for F, G and I format descriptors . . . . . . . . . . . 49
5.1.8 I/O item lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.1.9 Q exponent-letter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.1.10 BOZ literal constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.1.11 Real array indices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.1.12 Unary operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.1.13 Implicitly convert LOGICAL and INTEGER values . . . . . . . . . . 50
5.1.14 Hollerith constants support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.1.15 Character conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.1.16 Cray pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.1.17 CONVERT specifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.1.18 OpenMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.1.19 OpenACC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.1.20 Argument list functions %VAL, %REF and %LOC . . . . . . . . . . . . 55
5.1.21 Read/Write after EOF marker . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.1.22 STRUCTURE and RECORD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.1.23 UNION and MAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.1.24 Type variants for integer intrinsics . . . . . . . . . . . . . . . . . . . . . . . 60
5.1.25 AUTOMATIC and STATIC attributes . . . . . . . . . . . . . . . . . . . . . . . . 61
5.1.26 Extended math intrinsics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
5.1.27 Form feed as whitespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
5.1.28 TYPE as an alias for PRINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
v
6 Mixed-Language Programming . . . . . . . . . . . . . . . 69
6.1 Interoperability with C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
6.1.1 Intrinsic Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
6.1.2 Derived Types and struct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
6.1.3 Interoperable Global Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
6.1.4 Interoperable Subroutines and Functions . . . . . . . . . . . . . . . . . . 70
6.1.5 Working with C Pointers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
6.1.6 Further Interoperability of Fortran with C . . . . . . . . . . . . . . . . 74
6.2 GNU Fortran Compiler Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
6.2.1 ATTRIBUTES directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
6.2.2 UNROLL directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
6.2.3 BUILTIN directive. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
6.2.4 IVDEP directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
6.2.5 VECTOR directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
6.2.6 NOVECTOR directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
6.3 Non-Fortran Main Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
6.3.1 _gfortran_set_args — Save command-line arguments . . . 77
6.3.2 _gfortran_set_options — Set library option flags . . . . . . . 77
6.3.3 _gfortran_set_convert — Set endian conversion . . . . . . . . 79
6.3.4 _gfortran_set_record_marker —
Set length of record markers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
6.3.5 _gfortran_set_fpe — Enable floating point exception traps . . 80
6.3.6 _gfortran_set_max_subrecord_
length — Set subrecord length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
6.4 Naming and argument-passing conventions . . . . . . . . . . . . . . . . . . . . . 80
6.4.1 Naming conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.4.2 Argument passing conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
vi
7 Coarray Programming . . . . . . . . . . . . . . . . . . . . . . . . . 85
7.1 Type and enum ABI Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
7.1.1 caf_token_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
7.1.2 caf_register_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
7.1.3 caf_deregister_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
7.1.4 caf_reference_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
7.1.5 caf_team_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
7.2 Function ABI Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
7.2.1 _gfortran_caf_init — Initialiation function . . . . . . . . . . . . . 88
7.2.2 _gfortran_caf_finish — Finalization function . . . . . . . . . . 88
7.2.3 _gfortran_caf_this_image — Querying the image number . . 88
7.2.4 _gfortran_caf_num_images — Querying
the maximal number of images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
7.2.5 _gfortran_caf_image_status —
Query the status of an image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
7.2.6 _gfortran_caf_failed_images — Get an array
of the indexes of the failed images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
7.2.7 _gfortran_caf_stopped_images — Get an array of
the indexes of the stopped images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
7.2.8 _gfortran_caf_register — Registering coarrays . . . . . . . . 90
7.2.9 _gfortran_caf_deregister — Deregistering coarrays . . . . 91
7.2.10 _gfortran_caf_is_present — Query whether an allocatable or pointer
component in a derived type coarray is allocated . . . . . . . . . . . . . . . 92
7.2.11 _gfortran_caf_send — Sending data from
a local image to a remote image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
7.2.12 _gfortran_caf_get — Getting data from a remote image . . 93
7.2.13 _gfortran_caf_sendget — Sending
data between remote images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
7.2.14 _gfortran_caf_send_by_ref — Sending data from a local image to a
remote image with enhanced referencing options . . . . . . . . . . . . . . . 96
7.2.15 _gfortran_caf_get_by_ref — Getting data from a
remote image using enhanced references . . . . . . . . . . . . . . . . . . . . . . . 97
7.2.16 _gfortran_caf_sendget_by_ref — Sending data between remote
images using enhanced references on both sides . . . . . . . . . . . . . . . . 98
7.2.17 _gfortran_caf_lock — Locking a lock variable . . . . . . . . . 99
7.2.18 _gfortran_caf_lock — Unlocking a lock variable . . . . . . 100
7.2.19 _gfortran_caf_event_post — Post an event . . . . . . . . . . 100
7.2.20 _gfortran_caf_event_wait —
Wait that an event occurred . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
7.2.21 _gfortran_caf_event_query — Query event count . . . . 102
7.2.22 _gfortran_caf_sync_all — All-image barrier . . . . . . . . . 102
7.2.23 _gfortran_caf_sync_images —
Barrier for selected images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
7.2.24 _gfortran_caf_sync_memory — Wait for
completion of segment-memory operations . . . . . . . . . . . . . . . . . . . . 103
vii
7.2.25 _gfortran_caf_error_stop —
Error termination with exit code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
7.2.26 _gfortran_caf_error_stop_str —
Error termination with string. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
7.2.27 _gfortran_caf_fail_image — Mark the
image failed and end its execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
7.2.28 _gfortran_caf_atomic_define —
Atomic variable assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
7.2.29 _gfortran_caf_atomic_ref — Atomic variable reference . . 104
7.2.30 _gfortran_caf_atomic_cas — Atomic compare and swap . . 105
7.2.31 _gfortran_caf_atomic_op — Atomic operation . . . . . . . . 106
7.2.32 _gfortran_caf_co_broadcast —
Sending data to all images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
7.2.33 _gfortran_caf_co_max — Collective maximum reduction . . 107
7.2.34 _gfortran_caf_co_min — Collective minimum reduction . . 107
7.2.35 _gfortran_caf_co_sum — Collective summing reduction . . 108
7.2.36 _gfortran_caf_co_reduce — Generic collective reduction . . 108
Contributing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
Contributors to GNU Fortran. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
xiv
1 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.
• 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 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 com-
mand) 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 com-
mand. gfortran is just another driver program, but specifically for the Fortran com-
piler only. The primary difference between the gcc and gfortran commands is that
the latter automatically links 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 call it for you.
This manual specifically documents the Fortran front end, which handles the program-
ming language’s syntax and semantics. The aspects of GCC that relate to the optimization
passes and the back-end code generation are documented in the GCC manual; see Section
“Introduction” in Using the GNU Compiler Collection (GCC). The two manuals together
provide a complete reference for the GNU Fortran compiler.
1.3 Standards
Fortran is developed by the Working Group 5 of Sub-Committee 22 of the Joint Technical
Committee 1 of the International Organization for Standardization and the International
Electrotechnical Commission (IEC). This group is known as WG5 (http://www.nag.co.
uk/sc22wg5/). Official Fortran standard documents are available for purchase from ISO; a
collection of free documents (typically final drafts) are also available on the wiki (https://
gcc.gnu.org/wiki/GFortranStandards).
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.
GNU Fortran also supports almost all of ISO/IEC 1539-1:2004 (Fortran 2003) and
ISO/IEC 1539-1:2010 (Fortran 2008). It has partial support for features introduced in
ISO/IEC 1539:2018 (Fortran 2018), the most recent version of the Fortran language stan-
dard, including full support for the Technical Specification Further Interoperability of
Fortran with C (ISO/IEC TS 29113:2012). More details on support for these standards
can be found in the following sections of the documentation.
Additionally, the GNU Fortran compilers supports the OpenMP specification (version
4.5 and partial support of the features of the 5.0 version, https://openmp.org/
specifications/). There also is support for the OpenACC specification (targeting version
2.6, https://www.openacc.org/). See https://gcc.gnu.org/wiki/OpenACC for more in-
formation.
Fortran2003) for a full list of new features introduced by Fortran 2003 and their imple-
mentation status.
Preprocessing Options
See Section 2.3 [Enable and customize preprocessing], page 14.
-A-question[=answer]
-Aquestion=answer -C -CC -Dmacro[=defn]
-H -P
-Umacro -cpp -dD -dI -dM -dN -dU -fworking-directory
-imultilib dir
-iprefix file -iquote -isysroot dir -isystem dir -nocpp
-nostdinc
-undef
Debugging Options
See Section 2.5 [Options for debugging your program or GNU Fortran], page 22.
-fbacktrace -fdump-fortran-optimized -fdump-fortran-original
-fdebug-aux-vars -fdump-fortran-global -fdump-parse-tree -ffpe-trap=list
-ffpe-summary=list
Directory Options
See Section 2.6 [Options for directory search], page 23.
-Idir -Jdir -fintrinsic-modules-path dir
Link Options
See Section 2.7 [Options for influencing the linking step], page 24.
-static-libgfortran -static-libquadmath
Runtime Options
See Section 2.8 [Options for influencing runtime behavior], page 24.
-fconvert=conversion -fmax-subrecord-length=length
-frecord-marker=length -fsign-zero
Interoperability Options
See Section 2.10 [Options for interoperability], page 32.
-fc-prototypes -fc-prototypes-external
-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 ex-
tensions) to be accepted. This can be useful with -std= 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 pro-
cedure with the same name as any intrinsic will be called except when it is
explicitly declared EXTERNAL.
-fallow-argument-mismatch
Some code contains calls to external procedures with mismatches between the
calls and the procedure definition, or with mismatches between different calls.
Such code is non-conforming, and will usually be flagged with an error. This
options degrades the error to a warning, which can only be disabled by disabling
all warnings via -w. Only a single occurrence per argument is flagged by this
warning. -fallow-argument-mismatch is implied by -std=legacy.
Using this option is strongly discouraged. It is possible to provide standard-
conforming code which allows different types of arguments by using an explicit
interface and TYPE(*).
-fallow-invalid-boz
A BOZ literal constant can occur in a limited number of contexts in standard
conforming Fortran. This option degrades an error condition to a warning,
and allows a BOZ literal constant to appear where the Fortran standard would
otherwise prohibit its use.
-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.
-fdec DEC compatibility mode. Enables extensions and other features that mimic
the default behavior of older compilers (such as DEC). These features are non-
standard and should be avoided at all costs. For details on GNU Fortran’s
implementation of these extensions see the full documentation.
Other flags enabled by this switch are: -fdollar-ok -fcray-pointer
-fdec-char-conversions -fdec-structure -fdec-intrinsic-ints
-fdec-static -fdec-math -fdec-include -fdec-blank-format-item
-fdec-format-defaults
If -fd-lines-as-code/-fd-lines-as-comments are unset, then -fdec also
sets -fd-lines-as-comments.
10 The GNU Fortran Compiler
-fdec-char-conversions
Enable the use of character literals in assignments and DATA statements for
non-character variables.
-fdec-structure
Enable DEC STRUCTURE and RECORD as well as UNION, MAP, and dot (’.’) as a
member separator (in addition to ’%’). This is provided for compatibility only;
Fortran 90 derived types should be used instead where possible.
-fdec-intrinsic-ints
Enable B/I/J/K kind variants of existing integer functions (e.g. BIAND,
IIAND, JIAND, etc...). For a complete list of intrinsics see the full
documentation.
-fdec-math
Enable legacy math intrinsics such as COTAN and degree-valued trigonometric
functions (e.g. TAND, ATAND, etc...) for compatability with older code.
-fdec-static
Enable DEC-style STATIC and AUTOMATIC attributes to explicitly specify
the storage of variables and other objects.
-fdec-include
Enable parsing of INCLUDE as a statement in addition to parsing it as IN-
CLUDE line. When parsed as INCLUDE statement, INCLUDE does not have
to be on a single line and can use line continuations.
-fdec-format-defaults
Enable format specifiers F, G and I to be used without width specifiers, default
widths will be used instead.
-fdec-blank-format-item
Enable a blank format item at the end of a format specification i.e. nothing
following the final comma.
-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 back-
slash 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, \xnn, \unnnn and \Unnnnnnnn
(where each n is a hexadecimal digit) are translated into the Unicode charac-
ters corresponding to the specified code points. All other combinations of a
character preceded by \ are unexpanded.
Chapter 2: GNU Fortran Command Options 11
-fmodule-private
Set the default accessibility of module entities to PRIVATE. Use-associated en-
tities 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, unless -fno-pad-source, 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 im-
age), 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.
-fno-pad-source
By default fixed-form lines have spaces assumed (as if padded to that length)
after the ends of short fixed-form lines. This is not done either if -ffixed-line-
length-0, -ffixed-line-length-none or if -fno-pad-source option is used.
With any of those options continued character constants never have implicit
spaces appended to them to fill out the line.
-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 later).
-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.
-fopenacc
Enable the OpenACC extensions. This includes OpenACC !$acc directives in
free form and c$acc, *$acc and !$acc directives in fixed form, !$ conditional
compilation sentinels in free form and c$, *$ and !$ sentinels in fixed form,
and when linking arranges for the OpenACC runtime library to be linked in.
-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.
12 The GNU Fortran Compiler
-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.
-fdefault-integer-8
Set the default integer and logical types to an 8 byte wide type. This option also
affects the kind of integer constants like 42. Unlike -finteger-4-integer-8,
it does not promote variables with explicit kind declaration.
-fdefault-real-8
Set the default real type to an 8 byte wide type. This option also affects the kind
of non-double real constants like 1.0. This option promotes the default width
of DOUBLE PRECISION and double real constants like 1.d0 to 16 bytes if pos-
sible. If -fdefault-double-8 is given along with fdefault-real-8, DOUBLE
PRECISION and double real constants are not promoted. Unlike -freal-4-
real-8, fdefault-real-8 does not promote variables with explicit kind dec-
larations.
-fdefault-real-10
Set the default real type to an 10 byte wide type. This option also affects the
kind of non-double real constants like 1.0. This option promotes the default
width of DOUBLE PRECISION and double real constants like 1.d0 to 16 bytes
if possible. If -fdefault-double-8 is given along with fdefault-real-10,
DOUBLE PRECISION and double real constants are not promoted. Unlike -freal-
4-real-10, fdefault-real-10 does not promote variables with explicit kind
declarations.
-fdefault-real-16
Set the default real type to an 16 byte wide type. This option also affects the
kind of non-double real constants like 1.0. This option promotes the default
width of DOUBLE PRECISION and double real constants like 1.d0 to 16 bytes
if possible. If -fdefault-double-8 is given along with fdefault-real-16,
DOUBLE PRECISION and double real constants are not promoted. Unlike -freal-
4-real-16, fdefault-real-16 does not promote variables with explicit kind
declarations.
-fdefault-double-8
Set the DOUBLE PRECISION type and double real constants like 1.d0 to an 8
byte wide type. Do nothing if this is already the default. This option prevents
-fdefault-real-8, -fdefault-real-10, and -fdefault-real-16, from pro-
moting DOUBLE PRECISION and double real constants like 1.d0 to 16 bytes.
-finteger-4-integer-8
Promote all INTEGER(KIND=4) entities to an INTEGER(KIND=8) entities. If
KIND=8 is unavailable, then an error will be issued. This option should be
Chapter 2: GNU Fortran Command Options 13
used with care and may not be suitable for your codes. Areas of possible con-
cern include calls to external procedures, alignment in EQUIVALENCE and/or
COMMON, generic interfaces, BOZ literal constant conversion, and I/O. Inspec-
tion of the intermediate representation of the translated Fortran code, produced
by -fdump-tree-original, is suggested.
-freal-4-real-8
-freal-4-real-10
-freal-4-real-16
-freal-8-real-4
-freal-8-real-10
-freal-8-real-16
Promote all REAL(KIND=M) entities to REAL(KIND=N) entities. If REAL(KIND=N)
is unavailable, then an error will be issued. The -freal-4- flags also affect
the default real kind and the -freal-8- flags also the double-precision real
kind. All other real-kind types are unaffected by this option. The promotion
is also applied to real literal constants of default and double-precision kind
and a specified kind number of 4 or 8, respectively. However, -fdefault-
real-8, -fdefault-real-10, -fdefault-real-10, and -fdefault-double-8
take precedence for the default and double-precision real kinds, both for real
literal constants and for declarations without a kind number. Note that for
REAL(KIND=KIND(1.0)) the literal may get promoted and then the result may
get promoted again. These options should be used with care and may not be
suitable for your codes. Areas of possible concern include calls to external proce-
dures, alignment in EQUIVALENCE and/or COMMON, generic interfaces, BOZ literal
constant conversion, and I/O and calls to intrinsic procedures when passing a
value to the kind= dummy argument. Inspection of the intermediate represen-
tation of the translated Fortran code, produced by -fdump-fortran-original
or -fdump-tree-original, is suggested.
-std=std Specify the standard to which the program is expected to conform, which may
be one of ‘f95’, ‘f2003’, ‘f2008’, ‘f2018’, ‘gnu’, or ‘legacy’. The default value
for std is ‘gnu’, which specifies a superset of the latest Fortran 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’, ‘f2008’,
and ‘f2018’ values specify strict conformance to the Fortran 95, Fortran 2003,
Fortran 2008 and Fortran 2018 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.
The deprecated option ‘-std=f2008ts’ acts as an alias for ‘-std=f2018’. It
is only present for backwards compatibility with earlier gfortran versions and
should not be used any more.
-ftest-forall-temp
Enhance test coverage by forcing most forall assignments to use temporary.
14 The GNU Fortran Compiler
-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.
-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 is present in the preprocessed input, as
the directory emitted as the current working directory in some debugging in-
formation 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.
16 The GNU Fortran Compiler
-nostdinc
Do not search the standard system directories for header files. Only the direc-
tories 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 preproces-
sor 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 turn-
ing 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 prepro-
cessor 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).
Chapter 2: GNU Fortran Command Options 17
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.
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, -std=f2008
or -std=f2018.
-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, -Wconversion, -Wsurprising,
-Wc-binding-type, -Wintrinsics-std, -Wtabs, -Wintrinsic-shadow,
-Wline-truncation, -Wtarget-lifetime, -Winteger-division,
-Wreal-q-constant, -Wunused and -Wundefined-do-loop.
-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, -std=f2008
and -std=f2018. 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.
-Wc-binding-type
Warn if the a variable might not be C interoperable. In particular, warn if the
variable has been declared using an intrinsic type with default kind instead of
using a kind parameter defined for C interoperability in the intrinsic ISO_C_
Binding module. This option is implied by -Wall.
-Wcharacter-truncation
Warn when a character assignment will truncate the assigned string.
Chapter 2: GNU Fortran Command Options 19
-Wline-truncation
Warn when a source code line will be truncated. This option is implied by
-Wall. For free-form source code, the default is -Werror=line-truncation
such that truncations are reported as error.
-Wconversion
Warn about implicit conversions that are likely to change the value of the
expression after conversion. Implied by -Wall.
-Wconversion-extra
Warn about implicit conversions between different types and kinds. This option
does not imply -Wconversion.
-Wextra Enables some warning options for usages of language features which may be
problematic. This currently includes -Wcompare-reals, -Wunused-parameter
and -Wdo-subscript.
-Wfrontend-loop-interchange
Warn when using -ffrontend-loop-interchange for performing loop inter-
changes.
-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.
-Winteger-division
Warn if a constant integer division truncates its result. As an example, 3/5
evaluates to 0.
-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.
-Wno-overwrite-recursive
Do not warn when -fno-automatic is used with -frecursive. Recursion will
be broken if the relevant local variables do not have the attribute AUTOMATIC
explicitly declared. This option can be used to suppress the warning when it
is known that recursion is not broken. Useful for build environments that use
-Werror.
-Wreal-q-constant
Produce a warning if a real-literal-constant contains a q exponent-letter.
-Wsurprising
Produce a warning when “suspicious” code constructs are encountered. While
technically legal these usually indicate that an error has been made.
20 The GNU Fortran Compiler
-Wfunction-elimination
Warn if any calls to impure functions are eliminated by the optimizations en-
abled by the -ffrontend-optimize option. This option is implied by -Wextra.
-Wrealloc-lhs
Warn when the compiler might insert code to for allocation or reallocation of
an allocatable array variable of intrinsic type in intrinsic assignments. In hot
loops, the Fortran 2003 reallocation feature may reduce the performance. If
the array is already allocated with the correct shape, consider using a whole-
array array-spec (e.g. (:,:,:)) for the variable on the left-hand side to prevent
the reallocation check. Note that in some cases the warning is shown, even if
the compiler will optimize reallocation checks away. For instance, when the
right-hand side contains the same variable multiplied by a scalar. See also
-frealloc-lhs.
-Wrealloc-lhs-all
Warn when the compiler inserts code to for allocation or reallocation of an
allocatable variable; this includes scalars and derived types.
-Wcompare-reals
Warn when comparing real or complex types for equality or inequality. This
option is implied by -Wextra.
-Wtarget-lifetime
Warn if the pointer in a pointer assignment might be longer than the its target.
This option is implied by -Wall.
-Wzerotrip
Warn if a DO loop is known to execute zero times at compile time. This option
is implied by -Wall.
-Wdo-subscript
Warn if an array subscript inside a DO loop could lead to an out-of-bounds
access even if the compiler cannot prove that the statement is actually executed,
in cases like
real a(3)
do i=1,4
if (condition(i)) then
a(i) = 1.2
end if
end do
See Section “Options to Request or Suppress Errors and Warnings” in Using the GNU
Compiler Collection (GCC), 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.
22 The GNU Fortran Compiler
The first three exceptions (‘invalid’, ‘zero’, and ‘overflow’) often indicate
serious errors, and unless the program has provisions for dealing with these
exceptions, enabling traps for these three exceptions is probably a good idea.
If the option is used more than once in the command line, the lists will be joined:
’ffpe-trap=list1 ffpe-trap=list2’ is equivalent to ffpe-trap=list1,list2.
Note that once enabled an exception cannot be disabled (no negative form).
Many, if not most, floating point operations incur loss of precision due to round-
ing, and hence the ffpe-trap=inexact is likely to be uninteresting in practice.
By default no exception traps are enabled.
-ffpe-summary=list
Specify a list of floating-point exceptions, whose flag status is printed to ERROR_
UNIT when invoking STOP and ERROR STOP. list can be either ‘none’, ‘all’ or a
comma-separated list of the following exceptions: ‘invalid’, ‘zero’, ‘overflow’,
‘underflow’, ‘inexact’ and ‘denormal’. (See -ffpe-trap for a description of
the exceptions.)
If the option is used more than once in the command line, only the last one will
be used.
By default, a summary for all exceptions but ‘inexact’ is shown.
-fno-backtrace
When a serious runtime error is encountered or a deadly signal is emitted (seg-
mentation fault, illegal instruction, bus error, floating-point exception, and the
other POSIX signals that have the action ‘core’), the Fortran runtime library
tries to output a backtrace of the error. -fno-backtrace disables the backtrace
generation. This option only has influence for compilation of the Fortran main
program.
See Section “Options for Debugging Your Program or GCC” in Using the GNU Compiler
Collection (GCC), for more information on debugging options.
-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.
-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
(or values rounded to zero for I/O) and regards zero as positive number in the
SIGN intrinsic for compatibility with Fortran 77. The default is -fsign-zero.
-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.
Local variables or arrays having an explicit SAVE attribute are silently ignored
unless the -pedantic option is added.
-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 ar-
gument 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.
26 The GNU Fortran Compiler
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 ap-
pending underscores to them.
With -funderscoring in effect, GNU Fortran appends one underscore to ex-
ternal names. 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 environ-
ments (vis-à-vis existing libraries, tools, and so on).
For example, with -funderscoring, and assuming 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 im-
plemented 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 in-
troduces 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.
-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
Chapter 2: GNU Fortran Command Options 27
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 imple-
mented 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.
-fcoarray=<keyword>
‘none’ Disable coarray support; using coarray declarations and image-
control statements will produce a compile-time error. (Default)
‘single’ Single-image mode, i.e. num_images() is always one.
‘lib’ Library-based coarray parallelization; a suitable GNU Fortran coar-
ray library needs to be linked.
-fcheck=<keyword>
Enable the generation of run-time checks; the argument shall be a comma-
delimited list of the following keywords. Prefixing a check with no- disables it
if it was activated by a previous specification.
‘all’ Enable all run-time test of -fcheck.
‘array-temps’
Warns at run time when for passing an actual argument a tempo-
rary 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.
‘bits’ Enable generation of run-time checks for invalid arguments to the
bit manipulation intrinsics.
‘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.
28 The GNU Fortran Compiler
‘recursion’
Enable generation of run-time checks for recursively called sub-
routines 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.
-ftail-call-workaround
-ftail-call-workaround=n
Some C interfaces to Fortran codes violate the gfortran ABI by omitting the
hidden character length arguments as described in See Section 6.4.2 [Argument
passing conventions], page 81. This can lead to crashes because pushing argu-
ments for tail calls can overflow the stack.
To provide a workaround for existing binary packages, this option disables
tail call optimization for gfortran procedures with character arguments. With
-ftail-call-workaround=2 tail call optimization is disabled in all gfortran
procedures with character arguments, with -ftail-call-workaround=1
or equivalent -ftail-call-workaround only in gfortran procedures with
character arguments that call implicitly prototyped procedures.
Using this option can lead to problems including crashes due to insufficient
stack space.
It is very strongly recommended to fix the code in question. The
-fc-prototypes-external option can be used to generate prototypes which
conform to gfortran’s ABI, for inclusion in the source code.
Support for this option will likely be withdrawn in a future release of gfortran.
The negative form, -fno-tail-call-workaround or equivalent -ftail-call-
workaround=0, can be used to disable this option.
Default is currently -ftail-call-workaround, this will change in future re-
leases.
-fcheck-array-temporaries
Deprecated alias for -fcheck=array-temps.
Chapter 2: GNU Fortran Command Options 29
-fmax-array-constructor=n
This option can be used to increase the upper limit permitted in array con-
structors. 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 65536.
-fstack-arrays
Adding this option will make the Fortran compiler put all arrays of unknown
size and array temporaries onto stack memory. If your program uses very large
local arrays it is possible that you will have to extend your runtime limits for
stack memory on some operating systems. This flag is enabled by default at
optimization level -Ofast unless -fmax-stack-var-size is specified.
-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
30 The GNU Fortran Compiler
INTEGER kind a given enumerator set will fit in, and give all its enumerators
this kind.
-finline-arg-packing
When passing an assumed-shape argument of a procedure as actual argument
to an assumed-size or explicit size or as argument to a procedure that does not
have an explicit interface, the argument may have to be packed, that is put into
contiguous memory. An example is the call to foo in
subroutine foo(a)
real, dimension(*) :: a
end subroutine foo
subroutine bar(b)
real, dimension(:) :: b
call foo(b)
end subroutine bar
When -finline-arg-packing is in effect, this packing will be performed by
inline code. This allows for more optimization while increasing code size.
-finline-arg-packing is implied by any of the -O options except when opti-
mizing for size via -Os. If the code contains a very large number of argument
that have to be packed, code size and also compilation time may become ex-
cessive. If that is the case, it may be better to disable this option. Instances of
packing can be found by using -Warray-temporaries.
-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.
-finline-matmul-limit=n
When front-end optimization is active, some calls to the MATMUL intrinsic func-
tion will be inlined. This may result in code size increase if the size of the matrix
cannot be determined at compile time, as code for both cases is generated. Set-
ting -finline-matmul-limit=0 will disable inlining in all cases. Setting this
option with a value of n will produce inline code for matrices with size up to n.
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. The -fblas-matmul-limit can be used to change
this value.
Chapter 2: GNU Fortran Command Options 31
-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-derived
-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.
With -finit-derived, components of derived type variables will be initialized
according to these flags. Components whose type is not covered by an explicit
-finit-* flag will be treated as described above with -finit-local-zero.
These options do not initialize
• objects with the POINTER attribute
• allocatable arrays
• variables that appear in an EQUIVALENCE statement.
(These limitations 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).
The -finit-integer option will parse the value into an integer of type
INTEGER(kind=C_LONG) on the host. Said value is then assigned to the integer
variables in the Fortran code, which might result in wraparound if the value is
too large for the kind.
Finally, note that enabling any of the -finit-* options will silence warnings
that would have been emitted by -Wuninitialized for the affected local vari-
ables.
-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
32 The GNU Fortran Compiler
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.
See Section 5.1.17 [CONVERT specifier], page 53, for an alternative way to specify the
data representation for unformatted files. See Section 2.8 [Runtime Options], page 24, 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 vari-
able 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.
4 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.
! Variable declaration
integer :: ret
! Opening unit 10
open (10,file="foo")
! ...
! Perform I/O on unit 10
! ...
close, acquiring and releasing fcntl file locks, if the server supports them, will also force
cache validation and flushing dirty data and metadata.
In the most simple case, with only one subrecord per logical record, both record markers
contain the number of bytes of user data in the record.
The format for unformatted sequential data can be duplicated using unformatted stream,
as shown in the example program for an unformatted record containing a single subrecord:
program main
use iso_fortran_env, only: int32
implicit none
integer(int32) :: i
real, dimension(10) :: a, b
call random_number(a)
open (10,file='test.dat',form='unformatted',access='stream')
inquire (iolength=i) a
write (10) i, a, i
close (10)
open (10,file='test.dat',form='unformatted')
read (10) b
if (all (a == b)) print *,'success!'
end program main
5 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.
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.
&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
Chapter 5: Extensions 49
5.1.9 Q exponent-letter
GNU Fortran accepts real literal constants with an exponent-letter of Q, for example,
1.23Q45. The constant is interpreted as a REAL(16) entity on targets that support this
50 The GNU Fortran Compiler
type. If the target does not support REAL(16) but has a REAL(10) type, then the real-
literal-constant will be interpreted as a REAL(10) entity. In the absence of REAL(16) and
REAL(10), an error will occur.
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), LOGICAL or CHARACTER variable.
The constant will be padded with spaces 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)
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
The use of the -fdec option extends support of Hollerith constants to comparisons:
integer*4 a
a = 4hABCD
if (a .ne. 4habcd) then
write(*,*) "no match"
end if
The pointer can also be set by a call to the MALLOC intrinsic (see Section 8.184 [MALLOC],
page 230).
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 point-
ers 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, nor may they be function re-
sults. 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.
5.1.18 OpenMP
OpenMP (Open Multi-Processing) is an application programming interface (API) that sup-
ports 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
v4.5 (https://openmp.org/specifications/).
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 Offloading and Multi
Processing Runtime Library Section “libgomp” in GNU Offloading and Multi Processing
Runtime Library.
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)
Chapter 5: Extensions 55
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.
5.1.19 OpenACC
OpenACC is an application programming interface (API) that supports offloading of code
to accelerator devices. 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 OpenACC Application Programming In-
terface v2.6 (https://www.openacc.org/).
To enable the processing of the OpenACC directive !$acc in free-form source code; the
c$acc, *$acc and !$acc 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 -fopenacc. This also arranges for automatic linking of the GNU Offloading and Multi
Processing Runtime Library Section “libgomp” in GNU Offloading and Multi Processing
Runtime Library.
The OpenACC Fortran runtime library routines are provided both in a form of a Fortran
90 module named openacc and in a form of a Fortran include file named openacc_lib.h.
• Structure types may be declared nested within another parent structure. The syntax
is:
structure /type-name/
...
structure [/<type-name>/] <field-list>
...
The type name may be ommitted, in which case the structure type itself is anonymous,
and other structures of the same type cannot be instantiated. The following shows
some examples:
structure /appointment/
! nested structure definition: app_time is an array of two 'time'
structure /time/ app_time (2)
integer(1) hour, minute
end structure
character(10) memo
end structure
...
structure /appointment/
! anonymous nested structure definition
structure start, end
integer(1) hour, minute
end structure
character(10) memo
end structure
• Structures may contain UNION blocks. For more detail see the section on Section 5.1.23
[UNION and MAP], page 58.
• Structures support old-style initialization of components, like those described in Sec-
tion 5.1.2 [Old-style variable initialization], page 47. For array initializers, an initial-
izer may contain a repeat specification of the form <literal-integer> * <constant-
initializer>. The value of the integer indicates the number of times to repeat the
constant initializer when expanding the initializer list.
The major difference is that component references do not indicate which union or map the
component is in (the compiler gets to figure that out).
Here is a small example:
structure /myunion/
union
map
character(2) w0, w1, w2
end map
map
character(6) long
end map
end union
end structure
^ W0 ^ W1 ^ W2 ^
\-------/ \-------/ \-------/
^ LONG ^
\---------------------------/
Following is an example mirroring the layout of an Intel x86 64 register:
structure /reg/
union ! U0 ! rax
map
character(16) rx
end map
map
character(8) rh ! rah
union ! U1
map
character(8) rl ! ral
end map
map
character(8) ex ! eax
end map
map
60 The GNU Fortran Compiler
character(4) eh ! eah
union ! U2
map
character(4) el ! eal
end map
map
character(4) x ! ax
end map
map
character(2) h ! ah
character(2) l ! al
end map
end union
end map
end union
end map
end union
end structure
record /reg/ a
Intrinsic B I J K
Entities marked AUTOMATIC will be stack automatic whenever possible. AUTOMATIC is the
default for local variables smaller than -fmax-stack-var-size, unless -fno-automatic
is given. This attribute overrides -fno-automatic, -fmax-stack-var-size, and blanket
SAVE statements.
Examples:
subroutine f
integer, automatic :: i ! automatic variable
integer x, y ! static variables
save
...
endsubroutine
subroutine f
integer a, b, c, x, y, z
static :: x
save y
automatic z, c
! a, b, c, and z are automatic
! x and y are static
endsubroutine
! Compiled with -fno-automatic
subroutine f
integer a, b, c, d
automatic :: a
! a is automatic; b, c, and d are static
endsubroutine
For advanced users, it may be important to know the implementation of these functions.
They are simply wrappers around the standard radian functions, which have more accurate
builtin versions. These functions convert their arguments (or results) to degrees (or radians)
by taking the value modulus 360 (or 2*pi) and then multiplying it by a constant radian-to-
degree (or degree-to-radian) factor, as appropriate. The factor is computed at compile-time
as 180/pi (or pi/180).
Note that this conversion will occur if at least one operand is of integral type. As a result,
a logical operand will be converted to an integer when the other operand is an integer in a
logical operation. In this case, .TRUE. is converted to 1 and .FALSE. to 0.
Here is the mapping of logical operator to bitwise intrinsic used with -fdec:
Operator Intrinsic Bitwise operation
.NOT. Section 8.208 complement
[NOT], page 245
.AND. Section 8.137 intersection
[IAND], page 202
.OR. Section 8.152 union
[IOR], page 212
.NEQV. Section 8.145 exclusive or
[IEOR], page 208
.EQV. Section 8.208 complement of exclusive or
[NOT],
page 245(Section 8.145
[IEOR], page 208)
SHARE The SHARE specifier allows system-level locking on a unit upon opening it for
controlled access from multiple processes/threads. The SHARE specifier has
several forms:
OPEN(..., SHARE=sh)
OPEN(..., SHARED)
OPEN(..., NOSHARED)
Where sh in the first form is a character expression that evaluates to a value as
seen in the table below. The latter two forms are aliases for particular values
of sh:
Explicit form Short form Meaning
SHARE='DENYRW' NOSHARED Exclusive (write) lock
SHARE='DENYNONE' SHARED Shared (read) lock
In general only one process may hold an exclusive (write) lock for a given file
at a time, whereas many processes may hold shared (read) locks for the same
file.
The behavior of locking may vary with your operating system. On POSIX
systems, locking is implemented with fcntl. Consult your corresponding op-
erating system’s manual pages for further details. Locking via SHARE= is not
supported on other systems.
compiler, not all existing extensions are supported. This section aims at listing these ex-
tensions and offering advice on how best make code that uses them running with the GNU
Fortran compiler.
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
6 Mixed-Language Programming
This chapter is about mixed-language interoperability, but also applies if you link Fortran
code compiled by different compilers. In most cases, use of the C Binding features of the
Fortran 2003 and later standards is sufficient.
For example, it is possible to mix Fortran code with C++ code as well as C, if you declare
the interface functions as extern "C" on the C++ side and BIND(C) on the Fortran side,
and follow the rules for interoperability with C. Note that you cannot manipulate C++ class
objects in Fortran or vice versa except as opaque pointers.
You can use the gfortran command to link both Fortran and non-Fortran code into the
same program, or you can use gcc or g++ if you also add an explicit -lgfortran option to
link with the Fortran library. If your main program is written in C or some other language
instead of Fortran, see Section 6.3 [Non-Fortran Main Program], page 76, below.
IMPLICIT NONE
CONTAINS
! Call it.
CALL proc (1.0_C_DOUBLE)
CALL proc (-42.0_C_DOUBLE)
CALL proc (18.12_C_DOUBLE)
END SUBROUTINE get_values
END MODULE m
Next, we want to call a C routine that expects a procedure pointer argument and pass
it a Fortran procedure (which clearly must be interoperable!). Again, the C function may
be:
int
call_it (int (*func)(int), int arg)
{
return func (arg);
}
It can be used as in the following Fortran code:
MODULE m
USE, INTRINSIC :: ISO_C_BINDING
IMPLICIT NONE
CONTAINS
! Call C function.
SUBROUTINE foobar ()
TYPE(C_FUNPTR) :: cproc
INTEGER(KIND=C_INT) :: i
! Use it.
DO i = 1_C_INT, 10_C_INT
PRINT *, call_it (cproc, i)
END DO
END SUBROUTINE foobar
END MODULE m
• 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
For dummy arguments, the NO_ARG_CHECK attribute can be used; in other compilers, it
is also known as IGNORE_TKR. For dummy arguments with this attribute actual arguments
of any type and kind (similar to TYPE(*)), scalars and arrays of any rank (no equivalent in
Fortran standard) are accepted. As with TYPE(*), the argument is unlimited polymorphic
and no type information is available. Additionally, the argument may only be passed
to dummy arguments with the NO_ARG_CHECK attribute and as argument to the PRESENT
intrinsic function and to C_LOC of the ISO_C_BINDING module.
Variables with NO_ARG_CHECK attribute shall be of assumed-type (TYPE(*);
recommended) or of type INTEGER, LOGICAL, REAL or COMPLEX. They shall not have the
ALLOCATE, CODIMENSION, INTENT(OUT), POINTER or VALUE attribute; furthermore, they
shall be either scalar or of assumed-size (dimension(*)). As TYPE(*), the NO_ARG_CHECK
attribute requires an explicit interface.
• NO_ARG_CHECK – disable the type, kind and rank checking
• DEPRECATED – print a warning when using a such-tagged deprecated procedure, variable
or parameter; the warning can be suppressed with -Wno-deprecated-declarations.
• NOINLINE – prevent inlining given function.
• NORETURN – add a hint that a given function cannot return.
• WEAK – emit the declaration of an external symbol as a weak symbol rather than a
global. This is primarily useful in defining library functions that can be overridden in
user code, though it can also be used with non-function declarations. The overriding
symbol must have the same type as the weak symbol.
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.
You can use this directive to control how many times a loop should be unrolled. It must
be placed immediately before a DO loop and applies only to the loop that follows. N is an
integer constant specifying the unrolling factor. The values of 0 and 1 block any unrolling
of the loop.
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 follow-
ing functions. The libgfortran initialization functions are shown in C syntax but using C
bindings they are also accessible from Fortran.
Arguments:
num number of options passed
argv The list of flag values
return 0;
}
has been specified, the naming convention and some of the argument-passing conventions
change. If possible, mixed-language and mixed-compiler projects should use the better de-
fined C binding for interoperability. See see Section 6.1 [Interoperability with C], page 69.
For Boolean (LOGICAL) arguments, please note that GCC expects only the integer value
0 and 1. If a GNU Fortran LOGICAL variable contains another integer value, the result is
undefined. As some other Fortran compilers use −1 for .TRUE., extra care has to be taken –
such as passing the value as INTEGER. (The same value restriction also applies to other front
ends of GCC, e.g. to GCC’s C99 compiler for _Bool or GCC’s Ada compiler for Boolean.)
For arguments of CHARACTER type, the character length is passed as a hidden argument
at the end of the argument list. For deferred-length strings, the value is passed by reference,
otherwise by value. The character length has the C type size_t (or INTEGER(kind=C_SIZE_
T) in Fortran). Note that this is different to older versions of the GNU Fortran compiler,
where the type of the hidden character length argument was a C int. In order to retain
compatibility with older versions, one can e.g. for the following Fortran procedure
subroutine fstrlen (s, a)
character(len=*) :: s
integer :: a
print*, len(s)
end subroutine fstrlen
define the corresponding C prototype as follows:
#if __GNUC__ > 7
typedef size_t fortran_charlen_t;
#else
typedef int fortran_charlen_t;
#endif
• The present status for optional arguments with value attribute, which are internally
passed by value
• The character length and/or coarray token and offset for the first argument which is
a CHARACTER or a nonallocatable coarray dummy argument, followed by the hidden
arguments of the next dummy argument of such a type
85
7 Coarray Programming
7.1.2 caf_register_t
Indicates which kind of coarray variable should be registered.
typedef enum caf_register_t {
CAF_REGTYPE_COARRAY_STATIC,
CAF_REGTYPE_COARRAY_ALLOC,
CAF_REGTYPE_LOCK_STATIC,
CAF_REGTYPE_LOCK_ALLOC,
CAF_REGTYPE_CRITICAL,
CAF_REGTYPE_EVENT_STATIC,
CAF_REGTYPE_EVENT_ALLOC,
CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY,
CAF_REGTYPE_COARRAY_ALLOC_ALLOCATE_ONLY
}
caf_register_t;
The values CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY and CAF_REGTYPE_COARRAY_
ALLOC_ALLOCATE_ONLY are for allocatable components in derived type coarrays only. The
first one sets up the token without allocating memory for allocatable component. The latter
one only allocates the memory for an allocatable component in a derived type coarray.
The token needs to be setup previously by the REGISTER ONLY. This allows to have
allocatable components un-allocated on some images. The status whether an allocatable
component is allocated on a remote image can be queried by _caf_is_present which used
internally by the ALLOCATED intrinsic.
7.1.3 caf_deregister_t
typedef enum caf_deregister_t {
CAF_DEREGTYPE_COARRAY_DEREGISTER,
CAF_DEREGTYPE_COARRAY_DEALLOCATE_ONLY
}
caf_deregister_t;
Allows to specifiy the type of deregistration of a coarray object. The CAF_DEREGTYPE_
COARRAY_DEALLOCATE_ONLY flag is only allowed for allocatable components in derived type
coarrays.
7.1.4 caf_reference_t
The structure used for implementing arbitrary reference chains. A CAF_REFERENCE_T allows
to specify a component reference or any kind of array reference of any rank supported by
86 The GNU Fortran Compiler
gfortran. For array references all kinds as known by the compiler/Fortran standard are
supported indicated by a MODE.
typedef enum caf_ref_type_t {
/* Reference a component of a derived type, either regular one or an
allocatable or pointer type. For regular ones idx in caf_reference_t is
set to -1. */
CAF_REF_COMPONENT,
/* Reference an allocatable array. */
CAF_REF_ARRAY,
/* Reference a non-allocatable/non-pointer array. I.e., the coarray object
has no array descriptor associated and the addressing is done
completely using the ref. */
CAF_REF_STATIC_ARRAY
} caf_ref_type_t;
typedef enum caf_array_ref_t {
/* No array ref. This terminates the array ref. */
CAF_ARR_REF_NONE = 0,
/* Reference array elements given by a vector. Only for this mode
caf_reference_t.u.a.dim[i].v is valid. */
CAF_ARR_REF_VECTOR,
/* A full array ref (:). */
CAF_ARR_REF_FULL,
/* Reference a range on elements given by start, end and stride. */
CAF_ARR_REF_RANGE,
/* Only a single item is referenced given in the start member. */
CAF_ARR_REF_SINGLE,
/* An array ref of the kind (i:), where i is an arbitrary valid index in the
array. The index i is given in the start member. */
CAF_ARR_REF_OPEN_END,
/* An array ref of the kind (:i), where the lower bound of the array ref
is given by the remote side. The index i is given in the end member. */
CAF_ARR_REF_OPEN_START
} caf_array_ref_t;
/* References to remote components of a derived type. */
typedef struct caf_reference_t {
/* A pointer to the next ref or NULL. */
struct caf_reference_t *next;
/* The type of the reference. */
/* caf_ref_type_t, replaced by int to allow specification in fortran FE. */
int type;
/* The size of an item referenced in bytes. I.e. in an array ref this is
the factor to advance the array pointer with to get to the next item.
For component refs this gives just the size of the element referenced. */
size_t item_size;
union {
struct {
Chapter 7: Coarray Programming 87
7.1.5 caf_team_t
Opaque pointer to represent a team-handle. This type is a stand-in for the future imple-
mentation of teams. It is about to change without further notice.
88 The GNU Fortran Compiler
Arguments:
size For normal coarrays, the byte size of the coarray to be
allocated; for lock types and event types, the number
of elements.
type one of the caf register t types.
token intent(out) An opaque pointer identifying the
coarray.
desc intent(inout) The (pseudo) array descriptor.
stat intent(out) For allocatable coarrays, stores the
STAT=; may be NULL
errmsg intent(out) When an error occurs, this will be set to
an error message; may be NULL
errmsg len the buffer size of errmsg.
NOTES Nonallocatable coarrays have to be registered prior use from remote images. In
order to guarantee this, they have to be registered before the main program.
This can be achieved by creating constructor functions. That is what GCC does
such that also for nonallocatable coarrays the memory is allocated and no static
memory is used. The token permits to identify the coarray; to the processor,
the token is a nonaliasing pointer. The library can, for instance, store the base
address of the coarray in the token, some handle or a more complicated struct.
The library may also store the array descriptor DESC when its rank is non-zero.
For lock types, the value shall only be used for checking the allocation status.
Note that for critical blocks, the locking is only required on one image; in
the locking statement, the processor shall always pass an image index of one
for critical-block lock variables (CAF_REGTYPE_CRITICAL). For lock types and
critical-block variables, the initial value shall be unlocked (or, respectively, not
in critical section) such as the value false; for event types, the initial state should
be no event, e.g. zero.
Arguments:
token the token to free.
type the type of action to take for the coarray. A CAF_
DEREGTYPE_COARRAY_DEALLOCATE_ONLY is allowed
only for allocatable or pointer components of derived
type coarrays. The action only deallocates the local
memory without deleting the token.
stat intent(out) Stores the STAT=; may be NULL
errmsg intent(out) When an error occurs, this will be set to
an error message; may be NULL
errmsg len the buffer size of errmsg.
NOTES For nonalloatable coarrays this function is never called. If a cleanup is required,
it has to be handled via the finish, stop and error stop functions, and via
destructors.
7.2.10 _gfortran_caf_is_present — Query whether an allocatable
or pointer component in a derived type coarray is allocated
Description:
Used to query the coarray library whether an allocatable component in a derived
type coarray is allocated on a remote image.
Syntax : void _gfortran_caf_is_present (caf_token_t token, int image_index,
gfc_reference_t *ref)
Arguments:
token An opaque pointer identifying the coarray.
image index The ID of the remote image; must be a positive
number.
ref A chain of references to address the allocatable or
pointer component in the derived type coarray. The
object reference needs to be a scalar or a full array
reference, respectively.
NOTES It is permitted to have image index equal the current image; the memory of
the send-to and the send-from might (partially) overlap in that case. The
implementation has to take care that it handles this case, e.g. using memmove
which handles (partially) overlapping memory. If may require tmp is true, the
library might additionally create a temporary variable, unless additional checks
show that this is not required (e.g. because walking backward is possible or
because both arrays are contiguous and memmove takes care of overlap issues).
Note that the library has to handle numeric-type conversion and for strings,
padding and different character kinds.
Arguments:
dst token intent(in) An opaque pointer identifying the destina-
tion coarray.
dst offset intent(in) By which amount of bytes the actual data
is shifted compared to the base address of the desti-
nation coarray.
dst image index
intent(in) The ID of the destination remote image;
must be a positive number.
dest intent(in) Array descriptor for the destination remote
image for the bounds and the size. The base_addr
shall not be accessed.
dst vector intent(int) If not NULL, it contains the vector sub-
script of the destination array; the values are relative
to the dimension triplet of the dest argument.
src token intent(in) An opaque pointer identifying the source
coarray.
src offset intent(in) By which amount of bytes the actual data
is shifted compared to the base address of the source
coarray.
src image index
intent(in) The ID of the source remote image; must
be a positive number.
src intent(in) Array descriptor of the local array to be
transferred to the remote image.
src vector intent(in) Array descriptor of the local array to be
transferred to the remote image
dst kind intent(in) Kind of the destination argument
src kind intent(in) Kind of the source argument
may require tmp
intent(in) The variable is false when it is known at
compile time that the dest and src either cannot over-
lap or overlap (fully or partially) such that walking
src and dest in element wise element order (honor-
ing the stride value) will not lead to wrong results.
Otherwise, the value is true.
stat intent(out) when non-NULL give the result of the
operation, i.e., zero on success and non-zero on er-
ror. When NULL and an error occurs, then an error
message is printed and the program is terminated.
NOTES It is permitted to have the same image index for both src image index and
dst image index; the memory of the send-to and the send-from might (par-
tially) overlap in that case. The implementation has to take care that it handles
this case, e.g. using memmove which handles (partially) overlapping memory. If
may require tmp is true, the library might additionally create a temporary
variable, unless additional checks show that this is not required (e.g. because
walking backward is possible or because both arrays are contiguous and memmove
takes care of overlap issues).
96 The GNU Fortran Compiler
src type intent(in) Give the type of the source. When the
source is not an array, than the precise type, e.g. of
a component in a derived type, is not known, but
provided here.
NOTES It is permitted to have image_index equal the current image; the memory
of the send-to and the send-from might (partially) overlap in that case. The
implementation has to take care that it handles this case, e.g. using memmove
which handles (partially) overlapping memory. If may require tmp is true, the
library might additionally create a temporary variable, unless additional checks
show that this is not required (e.g. because walking backward is possible or
because both arrays are contiguous and memmove takes care of overlap issues).
Note that the library has to handle numeric-type conversion and for strings,
padding and different character kinds.
Because of the more complicated references possible some operations may be
unsupported by certain libraries. The library is expected to issue a precise error
message why the operation is not permitted.
Arguments:
token intent(in) An opaque pointer identifying the coarray.
index intent(in) Array index; first array index is 0. For
scalars, it is always 0.
image index intent(in) The ID of the remote image; must be a
positive number; zero indicates the current image,
when accessed noncoindexed.
stat intent(out) Stores the STAT=; may be NULL.
errmsg intent(out) When an error occurs, this will be set to
an error message; may be NULL.
errmsg len intent(in) the buffer size of errmsg
NOTES This acts like an atomic add of one to the remote image’s event variable. The
statement is an image-control statement but does not imply sync memory. Still,
all preceeding push communications of this image to the specified remote image
have to be completed before event_wait on the remote image returns.
Arguments:
token intent(in) An opaque pointer identifying the coarray.
index intent(in) Array index; first array index is 0. For
scalars, it is always 0.
until count intent(in) The number of events which have to be
available before the function returns.
stat intent(out) Stores the STAT=; may be NULL.
errmsg intent(out) When an error occurs, this will be set to
an error message; may be NULL.
errmsg len intent(in) the buffer size of errmsg
NOTES This function only operates on a local coarray. It acts like a loop checking
atomically the value of the event variable, breaking if the value is greater or
equal the requested number of counts. Before the function returns, the event
variable has to be decremented by the requested until count value. A possible
implementation would be a busy loop for a certain number of spins (possibly
depending on the number of threads relative to the number of available cores)
followed by another waiting strategy such as a sleeping wait (possibly with an
increasing number of sleep time) or, if possible, a futex wait.
102 The GNU Fortran Compiler
The statement is an image-control statement but does not imply sync memory.
Still, all preceeding push communications of this image to the specified remote
image have to be completed before event_wait on the remote image returns.
that image. Note that one image can wait for all other images in the current
team (e.g. via sync images(*)) while those only wait for that specific image.
Additionally, sync images ensures that all pending data transfers of previous
segments have completed.
Syntax : void _gfortran_caf_sync_images (int count, int images[], int *stat,
char *errmsg, size_t errmsg_len)
Arguments:
count intent(in) The number of images which are provided
in the next argument. For a zero-sized array, the
value is zero. For sync images (*), the value is −1.
images intent(in) An array with the images provided by the
user. If count is zero, a NULL pointer is passed.
stat intent(out) Stores the status STAT= and may be
NULL.
errmsg intent(out) When an error occurs, this will be set to
an error message; may be NULL.
errmsg len intent(in) the buffer size of errmsg
Arguments:
token intent(in) An opaque pointer identifying the coarray.
offset intent(in) By which amount of bytes the actual data
is shifted compared to the base address of the coarray.
image index intent(in) The ID of the remote image; must be a pos-
itive number; zero indicates the current image when
used noncoindexed.
value intent(out) The variable assigned the atomically ref-
erenced variable.
stat intent(out) Stores the status STAT= and may be
NULL.
type the data type, i.e. BT_INTEGER (1) or BT_LOGICAL
(2).
kind The kind value (only 4; always int)
Description:
Atomic compare and swap of a kind-4 integer or logical variable. Assigns atom-
ically the specified value to the atomic variable, if the latter has the value
specified by the passed condition value.
Arguments:
token intent(in) An opaque pointer identifying the coarray.
offset intent(in) By which amount of bytes the actual data
is shifted compared to the base address of the coarray.
image index intent(in) The ID of the remote image; must be a pos-
itive number; zero indicates the current image when
used noncoindexed.
old intent(out) The value which the atomic variable had
just before the cas operation.
compare intent(in) The value used for comparision.
new val intent(in) The new value for the atomic variable, as-
signed to the atomic variable, if compare equals the
value of the atomic variable.
stat intent(out) Stores the status STAT= and may be
NULL.
type intent(in) the data type, i.e. BT_INTEGER (1) or BT_
LOGICAL (2).
kind intent(in) The kind value (only 4; always int)
106 The GNU Fortran Compiler
The opr flags denote the following; the values are bitwise ored. GFC_CAF_
BYREF (1) if the result should be returned by reference; GFC_CAF_HIDDENLEN
(2) whether the result and argument string lengths shall be specified as hidden
arguments; GFC_CAF_ARG_VALUE (4) whether the arguments shall be passed
by value, GFC_CAF_ARG_DESC (8) whether the arguments shall be passed by
descriptor.
Syntax : void _gfortran_caf_co_reduce (gfc_descriptor_t *a, void * (*opr)
(void *, void *), int opr_flags, int result_image, int *stat, char
*errmsg, int a_len, size_t errmsg_len)
Arguments:
a intent(inout) An array descriptor with the data to
be processed. On the destination image(s) the result
overwrites the old content.
opr intent(in) Function pointer to the reduction function
opr flags intent(in) Flags regarding the reduction function
result image intent(in) The ID of the image to which the reduced
value should be copied to; if zero, it has to be copied
to all images.
stat intent(out) Stores the status STAT= and may be
NULL.
errmsg intent(out) When an error occurs, this will be set to
an error message; may be NULL.
a len intent(in) the string length of argument a
errmsg len intent(in) the buffer size of errmsg
NOTES If result image is nonzero, the data in the array descriptor a on all images
except of the specified one become undefined; hence, the library may make use
of this.
For character arguments, the result is passed as first argument, followed by
the result string length, next come the two string arguments, followed by the
two hidden string length arguments. With C binding, there are no hidden
arguments and by-reference passing and either only a single character is passed
or an array descriptor.
111
8 Intrinsic Procedures
Specific names:
Name Argument Return type Standard
ABS(A) REAL(4) A REAL(4) Fortran 77 and later
CABS(A) COMPLEX(4) A REAL(4) Fortran 77 and later
DABS(A) REAL(8) A REAL(8) Fortran 77 and later
IABS(A) INTEGER(4) A INTEGER(4) Fortran 77 and later
BABS(A) INTEGER(1) A INTEGER(1) GNU extension
IIABS(A) INTEGER(2) A INTEGER(2) GNU extension
JIABS(A) INTEGER(4) A INTEGER(4) GNU extension
KIABS(A) INTEGER(8) A INTEGER(8) GNU extension
ZABS(A) COMPLEX(8) A REAL(8) GNU extension
CDABS(A) COMPLEX(8) A REAL(8) GNU extension
Example:
program test_achar
character c
c = achar(32)
end program test_achar
Note: See Section 8.143 [ICHAR], page 206, for a discussion of converting between
numerical values and formatted string representations.
See also: Section 8.59 [CHAR], page 149,
Section 8.135 [IACHAR], page 201,
Section 8.143 [ICHAR], page 206,
Specific names:
Name Argument Return type Standard
ACOS(X) REAL(4) X REAL(4) Fortran 77 and later
DACOS(X) REAL(8) X REAL(8) Fortran 77 and later
See also: Inverse function:
Section 8.73 [COS], page 160,
Degrees function:
Section 8.7 [ACOSD], page 114,
Specific names:
Name Argument Return type Standard
ACOSD(X) REAL(4) X REAL(4) GNU extension
DACOSD(X) REAL(8) X REAL(8) GNU extension
See also: Inverse function:
Section 8.74 [COSD], page 160,
Radians function:
Section 8.6 [ACOS], page 114,
Specific names:
Name Argument Return type Standard
DACOSH(X) REAL(8) X REAL(8) GNU extension
See also: Inverse function:
Section 8.75 [COSH], page 161,
Example:
program test_adjustr
character(len=20) :: str = 'gfortran'
str = adjustr(str)
print *, str
end program test_adjustr
Specific names:
Name Argument Return type Standard
AIMAG(Z) COMPLEX Z REAL Fortran 77 and later
DIMAG(Z) COMPLEX(8) Z REAL(8) GNU extension
IMAG(Z) COMPLEX Z REAL GNU extension
IMAGPART(Z) COMPLEX Z REAL GNU extension
Arguments:
A The type of the argument shall be REAL.
KIND (Optional) A scalar INTEGER constant expression in-
dicating the kind parameter of the result.
Return value:
The return value is of type REAL with the kind type parameter of the argument
if the optional KIND is absent; otherwise, the kind type parameter will be given
by KIND. If the magnitude of X is less than one, AINT(X) returns zero. If the
magnitude is equal to or greater than one then it returns the largest whole
number that does not exceed its magnitude. The sign is the same as the sign
of X.
Example:
program test_aint
real(4) x4
real(8) x8
x4 = 1.234E0_4
x8 = 4.321_8
print *, aint(x4), dint(x8)
x8 = aint(x4,8)
end program test_aint
Specific names:
Name Argument Return type Standard
AINT(A) REAL(4) A REAL(4) Fortran 77 and later
DINT(A) REAL(8) A REAL(8) Fortran 77 and later
Example:
program test_alarm
external handler_print
integer i
call alarm (3, handler_print, i)
print *, i
call sleep(10)
end program test_alarm
This will cause the external routine handler print to be called after 3 seconds.
Return value:
The return type is either a scalar INTEGER or a scalar LOGICAL. If the kind type
parameters differ, then the smaller kind type is implicitly converted to larger
kind, and the return has the larger kind. A boz-literal-constant is converted to
an INTEGER with the kind type parameter of the other argument as-if a call to
Section 8.149 [INT], page 210, occurred.
Example:
PROGRAM test_and
LOGICAL :: T = .TRUE., F = .FALSE.
INTEGER :: a, b
DATA a / Z'F' /, b / Z'3' /
Specific names:
Name Argument Return type Standard
ASIN(X) REAL(4) X REAL(4) Fortran 77 and later
DASIN(X) REAL(8) X REAL(8) Fortran 77 and later
See also: Inverse function:
Section 8.249 [SIN], page 269,
Degrees function:
Section 8.20 [ASIND], page 123,
Specific names:
Name Argument Return type Standard
ASIND(X) REAL(4) X REAL(4) GNU extension
124 The GNU Fortran Compiler
Specific names:
Name Argument Return type Standard
DASINH(X) REAL(8) X REAL(8) GNU extension.
See also: Inverse function:
Section 8.251 [SINH], page 271,
Return value:
ASSOCIATED(POINTER) returns a scalar value of type LOGICAL(4). There are
several cases:
Example:
program test_associated
implicit none
real, target :: tgt(2) = (/1., 2./)
real, pointer :: ptr(:)
ptr => tgt
if (associated(ptr) .eqv. .false.) call abort
if (associated(ptr,tgt) .eqv. .false.) call abort
end program test_associated
Specific names:
Name Argument Return type Standard
ATAN(X) REAL(4) X REAL(4) Fortran 77 and later
DATAN(X) REAL(8) X REAL(8) Fortran 77 and later
See also: Inverse function:
Section 8.265 [TAN], page 280,
Degrees function:
Section 8.24 [ATAND], page 126,
Syntax :
RESULT = ATAND(X)
RESULT = ATAND(Y, X)
Arguments:
X The type shall be REAL or COMPLEX; if Y is present,
X shall be REAL.
Y The type and kind type parameter shall be the same
as X.
Return value:
The return value is of the same type and kind as X. If Y is present, the result
is identical to ATAND2(Y,X). Otherwise, it is the arcus tangent of X, where the
real part of the result is in degrees and lies in the range −90 ≤ < atand(x) ≤ 90.
Example:
program test_atand
real(8) :: x = 2.866_8
x = atand(x)
end program test_atand
Specific names:
Name Argument Return type Standard
ATAND(X) REAL(4) X REAL(4) GNU extension
DATAND(X) REAL(8) X REAL(8) GNU extension
See also: Inverse function:
Section 8.266 [TAND], page 280,
Radians function:
Section 8.23 [ATAN], page 126,
Specific names:
Name Argument Return type Standard
ATAN2(X, Y) REAL(4) X, Y REAL(4) Fortran 77 and later
DATAN2(X, Y) REAL(8) X, Y REAL(8) Fortran 77 and later
See also: Alias:
Section 8.23 [ATAN], page 126,
Degrees function:
Section 8.26 [ATAN2D], page 128,
Specific names:
Name Argument Return type Standard
ATAN2D(X, Y) REAL(4) X, Y REAL(4) GNU extension
DATAN2D(X, Y) REAL(8) X, Y REAL(8) GNU extension
See also: Alias:
Section 8.24 [ATAND], page 126,
Radians function:
Section 8.25 [ATAN2], page 127,
Specific names:
Name Argument Return type Standard
DATANH(X) REAL(8) X REAL(8) GNU extension
See also: Inverse function:
Section 8.267 [TANH], page 281,
use iso_fortran_env
integer(atomic_int_kind) :: atom[*]
call atomic_and (atom[1], int(b'10100011101'))
end program atomic
Arguments:
ATOM Scalar coarray or coindexed variable of either integer
type with ATOMIC_INT_KIND kind or logical type with
ATOMIC_LOGICAL_KIND kind.
OLD Scalar of the same type and kind as ATOM.
COMPARE Scalar variable of the same type and kind as ATOM.
NEW Scalar variable of the same type as ATOM. If kind is
different, the value is converted to the kind of ATOM.
STAT (optional) Scalar default-kind integer variable.
Example:
program atomic
use iso_fortran_env
logical(atomic_logical_kind) :: atom[*], prev
call atomic_cas (atom[1], prev, .false., .true.))
end program atomic
Specific names:
Name Argument Return type Standard
DBESJ0(X) REAL(8) X REAL(8) GNU extension
Chapter 8: Intrinsic Procedures 139
Specific names:
Name Argument Return type Standard
DBESJ1(X) REAL(8) X REAL(8) GNU extension
Return value:
The return value is a scalar of type REAL. It has the same kind as X.
Note: The transformational function uses a recurrence algorithm which might, for
some values of X, lead to different results than calls to the elemental function.
Example:
program test_besjn
real(8) :: x = 1.0_8
x = bessel_jn(5,x)
end program test_besjn
Specific names:
Name Argument Return type Standard
DBESJN(N, X) INTEGER N REAL(8) GNU extension
REAL(8) X
Specific names:
Name Argument Return type Standard
DBESY0(X) REAL(8) X REAL(8) GNU extension
Specific names:
Name Argument Return type Standard
DBESYN(N,X) INTEGER N REAL(8) GNU extension
REAL(8) X
Return value:
The return value is of type LOGICAL and of the default kind.
See also: Section 8.46 [BGE], page 142,
Section 8.47 [BGT], page 142,
Section 8.49 [BLE], page 143,
Specific names:
Name Argument Return Standard
type
BTEST(I,POS) INTEGER I,POS LOGICAL Fortran 95 and later
BBTEST(I,POS) INTEGER(1) I,POS LOGICAL(1) GNU extension
BITEST(I,POS) INTEGER(2) I,POS LOGICAL(2) GNU extension
BJTEST(I,POS) INTEGER(4) I,POS LOGICAL(4) GNU extension
BKTEST(I,POS) INTEGER(8) I,POS LOGICAL(8) GNU extension
real,pointer :: a(:)
call my_routine(cptr)
call c_f_pointer(cptr, a, [12])
end program main
Arguments:
x Interoperable function or pointer to such function.
Return value:
The return value is of type C_FUNPTR and contains the C address of the argu-
ment.
Example:
module x
use iso_c_binding
implicit none
contains
subroutine sub(a) bind(c)
real(c_float) :: a
a = sqrt(a)+5.0
end subroutine sub
end module x
program main
use iso_c_binding
use x
implicit none
interface
subroutine my_routine(p) bind(c,name='myC_func')
import :: c_funptr
type(c_funptr), intent(in) :: p
end subroutine
end interface
call my_routine(c_funloc(sub))
end program main
Arguments:
X Shall have either the POINTER or TARGET attribute.
It shall not be a coindexed object. It shall either be a
variable with interoperable type and kind type param-
eters, or be a scalar, nonpolymorphic variable with no
length type parameters.
Return value:
The return value is of type C_PTR and contains the C address of the argument.
Example:
subroutine association_test(a,b)
use iso_c_binding, only: c_associated, c_loc, c_ptr
implicit none
real, pointer :: a
type(c_ptr) :: b
if(c_associated(b, c_loc(a))) &
stop 'b and a do not point to same target'
end subroutine association_test
end
The example will print T unless you are using a platform where default REAL
variables are unusually padded.
See also: Section 8.253 [SIZEOF], page 272,
Section 8.260 [STORAGE SIZE], page 276,
Example:
program test_char
integer :: i = 74
character(1) :: c
c = char(i)
print *, i, c ! returns 'J'
end program test_char
Specific names:
Name Argument Return type Standard
CHAR(I) INTEGER I CHARACTER(LEN=1) Fortran 77 and later
Note: See Section 8.143 [ICHAR], page 206, for a discussion of converting between
numerical values and formatted string representations.
See also: Section 8.5 [ACHAR], page 113,
Section 8.135 [IACHAR], page 201,
Section 8.143 [ICHAR], page 206,
Syntax :
CALL CHMOD(NAME, MODE[, STATUS])
STATUS = CHMOD(NAME, MODE)
Arguments:
Return value:
In either syntax, STATUS is set to 0 on success and nonzero otherwise.
CHMOD as function:
program chmod_test
implicit none
integer :: status
status = chmod('test.dat','u+x')
print *, 'Status: ', status
end program chmod_test
152 The GNU Fortran Compiler
Arguments:
A INTENT(INOUT) argument; shall have the
same dynamic type and type parameters on all
images of the current team. If it is an array, it
shall have the same shape on all images.
SOURCE IMAGEa scalar integer expression. It shall have the same
value on all images and refer to an image of the
current team.
STAT (optional) a scalar integer variable
ERRMSG (optional) a scalar character variable
Example:
program test
integer :: val(3)
if (this_image() == 1) then
val = [1, 5, 3]
end if
call co_broadcast (val, source_image=1)
print *, this_image, ":", val
end program test
Example:
program test
integer :: val
val = this_image ()
call co_max (val, result_image=1)
if (this_image() == 1) then
write(*,*) "Maximal value", val ! prints num_images()
end if
end program test
integer :: val
val = this_image ()
call co_reduce (val, result_image=1, operation=myprod)
if (this_image() == 1) then
write(*,*) "Product value", val ! prints num_images() factorial
end if
contains
pure function myprod(a, b)
integer, value :: a, b
integer :: myprod
myprod = a * b
end function myprod
end program test
Note: While the rules permit in principle an intrinsic function, none of the intrinsics
in the standard fulfill the criteria of having a specific function, which takes two
arguments of the same type and returning that type as result.
See also: Section 8.65 [CO MIN], page 154,
Section 8.64 [CO MAX], page 153,
Section 8.67 [CO SUM], page 156,
Section 8.63 [CO BROADCAST], page 152,
Return value:
The return value is a default-kind string with system-dependent length. It
contains the compiler flags used to compile the file, which called the COMPILER_
OPTIONS intrinsic.
Example:
use iso_fortran_env
print '(4a)', 'This file was compiled by ', &
compiler_version(), ' using the options ', &
compiler_options()
end
Arguments:
X The type may be INTEGER or REAL.
Y The type may be INTEGER or REAL.
Return value:
If X and Y are both of INTEGER type, then the return value is of default COMPLEX
type.
If X and Y are of REAL type, or one is of REAL type and one is of INTEGER type,
then the return value is of COMPLEX type with a kind equal to that of the REAL
argument with the highest precision.
Example:
program test_complex
integer :: i = 42
real :: x = 3.14
print *, complex(i, x)
end program test_complex
Syntax : Z = CONJG(Z)
Arguments:
Z The type shall be COMPLEX.
Return value:
The return value is of type COMPLEX.
Example:
program test_conjg
complex :: z = (2.0, 3.0)
complex(8) :: dz = (2.71_8, -3.14_8)
z= conjg(z)
print *, z
dz = dconjg(dz)
print *, dz
end program test_conjg
Specific names:
Name Argument Return type Standard
DCONJG(Z) COMPLEX(8) Z COMPLEX(8) GNU extension
160 The GNU Fortran Compiler
Specific names:
Name Argument Return type Standard
COS(X) REAL(4) X REAL(4) Fortran 77 and later
DCOS(X) REAL(8) X REAL(8) Fortran 77 and later
CCOS(X) COMPLEX(4) X COMPLEX(4) Fortran 77 and later
ZCOS(X) COMPLEX(8) X COMPLEX(8) GNU extension
CDCOS(X) COMPLEX(8) X COMPLEX(8) GNU extension
See also: Inverse function:
Section 8.6 [ACOS], page 114,
Degrees function:
Section 8.74 [COSD], page 160,
Return value:
The return value is of the same type and kind as X. The real part of the
result is in degrees. If X is of the type REAL, the return value lies in the range
−1 ≤ cosd(x) ≤ 1.
Example:
program test_cosd
real :: x = 0.0
x = cosd(x)
end program test_cosd
Specific names:
Name Argument Return type Standard
COSD(X) REAL(4) X REAL(4) GNU extension
DCOSD(X) REAL(8) X REAL(8) GNU extension
CCOSD(X) COMPLEX(4) X COMPLEX(4) GNU extension
ZCOSD(X) COMPLEX(8) X COMPLEX(8) GNU extension
CDCOSD(X) COMPLEX(8) X COMPLEX(8) GNU extension
See also: Inverse function:
Section 8.7 [ACOSD], page 114,
Radians function:
Section 8.73 [COS], page 160,
Specific names:
Name Argument Return type Standard
COTAN(X) REAL(4) X REAL(4) GNU extension
DCOTAN(X) REAL(8) X REAL(8) GNU extension
See also: Converse function:
Section 8.265 [TAN], page 280,
Degrees function:
Section 8.77 [COTAND], page 162,
Example:
program test_cotand
real(8) :: x = 0.165_8
x = cotand(x)
end program test_cotand
Specific names:
Name Argument Return type Standard
COTAND(X) REAL(4) X REAL(4) GNU extension
DCOTAND(X) REAL(8) X REAL(8) GNU extension
See also: Converse function:
Section 8.266 [TAND], page 280,
Radians function:
Section 8.76 [COTAN], page 162,
mask = a.ne.b
print '(3l3)', mask(1,:)
print '(3l3)', mask(2,:)
print *
print '(3i3)', count(mask)
print *
print '(3i3)', count(mask, 1)
print *
print '(3i3)', count(mask, 2)
end program test_count
shifted by SHIFT places. If rank is greater than one, then all complete rank
one sections of ARRAY along the given dimension are shifted. Elements shifted
out one end of each rank one section are shifted back in the other end.
Standard : Fortran 90 and later
Class: Transformational function
Syntax : RESULT = CSHIFT(ARRAY, SHIFT [, DIM])
Arguments:
ARRAY Shall be an array of any type.
SHIFT The type shall be INTEGER.
DIM The type shall be INTEGER.
Return value:
Returns an array of same type and rank as the ARRAY argument.
Example:
program test_cshift
integer, dimension(3,3) :: a
a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
print '(3i3)', a(1,:)
print '(3i3)', a(2,:)
print '(3i3)', a(3,:)
a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
print *
print '(3i3)', a(1,:)
print '(3i3)', a(2,:)
print '(3i3)', a(3,:)
end program test_cshift
Return value:
The converted date and time as a string.
Example:
program test_ctime
integer(8) :: i
character(len=30) :: date
i = time8()
call ctime(i,date)
print *, 'Program was started on ', date
end program test_ctime
Specific names:
Name Argument Return type Standard
DIM(X,Y) REAL(4) X, Y REAL(4) Fortran 77 and later
IDIM(X,Y) INTEGER(4) X, Y INTEGER(4) Fortran 77 and later
DDIM(X,Y) REAL(8) X, Y REAL(8) Fortran 77 and later
Arguments:
VECTOR A The type shall be numeric or LOGICAL, rank 1.
VECTOR B The type shall be numeric if VECTOR A is of nu-
meric type or LOGICAL if VECTOR A is of type
LOGICAL. VECTOR B shall be a rank-one array.
Return value:
If the arguments are numeric, the return value is a scalar of numeric type,
INTEGER, REAL, or COMPLEX. If the arguments are LOGICAL, the return value is
.TRUE. or .FALSE..
Example:
program test_dot_prod
integer, dimension(3) :: a, b
a = (/ 1, 2, 3 /)
b = (/ 4, 5, 6 /)
print '(3i3)', a
print *
print '(3i3)', b
print *
print *, dot_product(a,b)
end program test_dot_prod
Specific names:
Name Argument Return type Standard
DPROD(X,Y) REAL(4) X, Y REAL(8) Fortran 77 and later
Chapter 8: Intrinsic Procedures 171
This intrinsic is provided in both subroutine and function forms; however, only
one form can be used in any given program unit.
VALUES and TIME are INTENT(OUT) and provide the following:
VALUES(1): User time in seconds.
VALUES(2): System time in seconds.
TIME: Run time since start in seconds.
Standard : GNU extension
Class: Subroutine, function
Syntax :
CALL DTIME(VALUES, TIME).
TIME = DTIME(VALUES), (not recommended).
Arguments:
VALUES The type shall be REAL(4), DIMENSION(2).
TIME The type shall be REAL(4).
Return value:
Elapsed time in seconds since the last invocation or since the start of program
execution if not called before.
Example:
program test_dtime
integer(8) :: i, j
real, dimension(2) :: tarray
real :: result
call dtime(tarray, result)
print *, result
print *, tarray(1)
print *, tarray(2)
do i=1,100000000 ! Just a delay
j = i * i - i
end do
call dtime(tarray, result)
print *, result
print *, tarray(1)
print *, tarray(2)
end program test_dtime
back in the other end. If BOUNDARY is not present then the following are
copied in depending on the type of ARRAY.
Array Type Boundary Value
Numeric 0 of the type and kind of ARRAY.
Logical .FALSE..
Character(len)len blanks.
Standard : Fortran 90 and later
Class: Transformational function
Syntax : RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])
Arguments:
ARRAY May be any type, not scalar.
SHIFT The type shall be INTEGER.
BOUNDARY Same type as ARRAY.
DIM The type shall be INTEGER.
Return value:
Returns an array of same type and rank as the ARRAY argument.
Example:
program test_eoshift
integer, dimension(3,3) :: a
a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
print '(3i3)', a(1,:)
print '(3i3)', a(2,:)
print '(3i3)', a(3,:)
a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
print *
print '(3i3)', a(1,:)
print '(3i3)', a(2,:)
print '(3i3)', a(3,:)
end program test_eoshift
real :: x = 3.143
real(8) :: y = 2.33
print *, EPSILON(x)
print *, EPSILON(y)
end program test_epsilon
Specific names:
Name Argument Return type Standard
DERF(X) REAL(8) X REAL(8) GNU extension
Specific names:
Name Argument Return type Standard
DERFC(X) REAL(8) X REAL(8) GNU extension
Syntax :
CALL ETIME(VALUES, TIME).
TIME = ETIME(VALUES), (not recommended).
Arguments:
VALUES The type shall be REAL(4), DIMENSION(2).
TIME The type shall be REAL(4).
Return value:
Elapsed time in seconds since the start of program execution.
Example:
program test_etime
integer(8) :: i, j
real, dimension(2) :: tarray
real :: result
call ETIME(tarray, result)
print *, result
print *, tarray(1)
print *, tarray(2)
do i=1,100000000 ! Just a delay
j = i * i - i
end do
call ETIME(tarray, result)
print *, result
print *, tarray(1)
print *, tarray(2)
end program test_etime
Example:
program atomic
use iso_fortran_env
implicit none
type(event_type) :: event_value_has_been_set[*]
integer :: cnt
if (this_image() == 1) then
call event_query (event_value_has_been_set, cnt)
if (cnt > 0) write(*,*) "Value has been set"
elseif (this_image() == 2) then
event post (event_value_has_been_set[1])
end if
end program atomic
integer :: i
Note:
Because this intrinsic is implemented in terms of the system function call, its
behavior with respect to signaling is processor dependent. In particular, on
POSIX-compliant systems, the SIGINT and SIGQUIT signals will be ignored,
and the SIGCHLD will be blocked. As such, if the parent process is terminated,
the child process might not be terminated alongside.
See also: Section 8.263 [SYSTEM], page 278,
Specific names:
Name Argument Return type Standard
EXP(X) REAL(4) X REAL(4) Fortran 77 and later
DEXP(X) REAL(8) X REAL(8) Fortran 77 and later
CEXP(X) COMPLEX(4) X COMPLEX(4) Fortran 77 and later
ZEXP(X) COMPLEX(8) X COMPLEX(8) GNU extension
CDEXP(X) COMPLEX(8) X COMPLEX(8) GNU extension
Syntax :
CALL FGET(C [, STATUS])
STATUS = FGET(C)
Arguments:
C The type shall be CHARACTER and of default kind.
STATUS (Optional) status flag of type INTEGER. Returns 0
on success, -1 on end-of-file, and a system specific
positive error code otherwise.
Example:
PROGRAM test_fget
INTEGER, PARAMETER :: strlen = 100
INTEGER :: status, i = 1
CHARACTER(len=strlen) :: str = ""
row of the array in the DIM direction. If MASK is present, only the elements
for which MASK is .TRUE. are considered. If more than one element in the
array has the value VALUE, the location returned is that of the first such
element in array element order if the BACK is not present or if it is .FALSE..
If BACK is true, the location returned is that of the last such element. If the
array has zero size, or all of the elements of MASK are .FALSE., then the result
is an array of zeroes. Similarly, if DIM is supplied and all of the elements of
MASK along a given row are zero, the result value for that row is zero.
Standard : Fortran 2008 and later.
Class: Transformational function
Syntax :
RESULT = FINDLOC(ARRAY, VALUE, DIM [, MASK] [,KIND]
[,BACK])
RESULT = FINDLOC(ARRAY, VALUE, [, MASK] [,KIND]
[,BACK])
Arguments:
ARRAY Shall be an array of intrinsic type.
VALUE A scalar of intrinsic type which is in type confor-
mance with ARRAY.
DIM (Optional) Shall be a scalar of type INTEGER, with a
value between one and the rank of ARRAY, inclusive.
It may not be an optional dummy argument.
MASK (Optional) Shall be of type LOGICAL, and con-
formable with ARRAY.
KIND (Optional) A scalar INTEGER constant expression in-
dicating the kind parameter of the result.
BACK (Optional) A scalar of type LOGICAL.
Return value:
If DIM is absent, the result is a rank-one array with a length equal to the rank
of ARRAY. If DIM is present, the result is an array with a rank one less than
the rank of ARRAY, and a size corresponding to the size of ARRAY with the
DIM dimension removed. If DIM is present and ARRAY has a rank of one,
the result is a scalar. If the optional argument KIND is present, the result is
an integer of kind KIND, otherwise it is of default kind.
See also: Section 8.190 [MAXLOC], page 234,
Section 8.198 [MINLOC], page 238,
! Variable declaration
integer :: ret
! Opening unit 10
open (10,file="foo")
! ...
! Perform I/O on unit 10
! ...
Note that the FGET intrinsic is provided for backwards compatibility with g77.
GNU Fortran provides the Fortran 2003 Stream facility. Programmers should
consider the use of new stream IO feature in new code for future portability.
See also Section 1.3.2 [Fortran 2003 status], page 3.
Standard : GNU extension
Class: Subroutine, function
Syntax :
CALL FPUT(C [, STATUS])
STATUS = FPUT(C)
Arguments:
C The type shall be CHARACTER and of default kind.
STATUS (Optional) status flag of type INTEGER. Returns 0 on
success, -1 on end-of-file and a system specific posi-
tive error code otherwise.
Example:
PROGRAM test_fput
CHARACTER(len=10) :: str = "gfortran"
INTEGER :: i
DO i = 1, len_trim(str)
CALL fput(str(i:i))
END DO
END PROGRAM
Arguments:
UNIT The type shall be INTEGER.
C The type shall be CHARACTER and of default kind.
STATUS (Optional) status flag of type INTEGER. Returns 0 on
success, -1 on end-of-file and a system specific posi-
tive error code otherwise.
Example:
PROGRAM test_fputc
CHARACTER(len=10) :: str = "gfortran"
INTEGER :: fd = 42, i
to allow user to compile legacy code. For new code using Fortran 95 pointers,
the memory de-allocation intrinsic is DEALLOCATE.
Standard : GNU extension
Class: Subroutine
Syntax : CALL FREE(PTR)
Arguments:
PTR The type shall be INTEGER. It represents the location
of the memory that should be de-allocated.
Return value:
None
Example: See MALLOC for an example.
See also: Section 8.184 [MALLOC], page 230,
Example:
PROGRAM test_fseek
INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
INTEGER :: fd, offset, ierr
ierr = 0
offset = 5
fd = 10
OPEN(UNIT=fd, FILE="fseek.test")
CALL FSEEK(fd, offset, SEEK_SET, ierr) ! move to OFFSET
print *, FTELL(fd), ierr
CLOSE(UNIT=fd)
END PROGRAM
Example:
program test_gamma
real :: x = 1.0
x = gamma(x) ! returns 1.0
end program test_gamma
Specific names:
Name Argument Return type Standard
DGAMMA(X) REAL(8) X REAL(8) GNU extension
See also: Logarithm of the Gamma function:
Section 8.179 [LOG GAMMA], page 227,
Arguments:
POS Shall be of type INTEGER and not wider than the
default integer kind; POS ≥ 0
VALUE Shall be of type CHARACTER and of default kind.
Return value:
After GETARG returns, the VALUE argument holds the POSth command line
argument. If VALUE cannot hold the argument, it is truncated to fit the length
of VALUE. If there are less than POS arguments specified at the command
line, VALUE will be filled with blanks. If POS = 0, VALUE is set to the name
of the program (on systems that support this feature).
Example:
PROGRAM test_getarg
INTEGER :: i
CHARACTER(len=32) :: arg
DO i = 1, iargc()
CALL getarg(i, arg)
WRITE (*,*) arg
END DO
END PROGRAM
i = 0
DO
Chapter 8: Intrinsic Procedures 195
Class: Subroutine
Syntax : CALL GETENV(NAME, VALUE)
Arguments:
NAME Shall be of type CHARACTER and of default kind.
VALUE Shall be of type CHARACTER and of default kind.
Return value:
Stores the value of NAME in VALUE. If VALUE is not large enough to hold
the data, it is truncated. If NAME is not set, VALUE will be filled with blanks.
Example:
PROGRAM test_getenv
CHARACTER(len=255) :: homedir
CALL getenv("HOME", homedir)
WRITE (*,*) TRIM(homedir)
END PROGRAM
CALL GETLOG(login)
WRITE(*,*) login
END PROGRAM
This intrinsic routine is provided for backwards compatibility with GNU Fortran
77. In new code, programmers should consider the use of the Section 8.82
[DATE AND TIME], page 166, intrinsic defined by the Fortran 95 standard.
Standard : GNU extension
Class: Subroutine
Syntax : CALL GMTIME(TIME, VALUES)
Arguments:
TIME An INTEGER scalar expression corresponding to a sys-
tem time, with INTENT(IN).
VALUES A default INTEGER array with 9 elements, with
INTENT(OUT).
Return value:
The elements of VALUES are assigned as follows:
1. Seconds after the minute, range 0–59 or 0–61 to allow for leap seconds
2. Minutes after the hour, range 0–59
3. Hours past midnight, range 0–23
4. Day of month, range 1–31
5. Number of months since January, range 0–11
6. Years since 1900
7. Number of days since Sunday, range 0–6
8. Days since January 1, range 0–365
9. Daylight savings indicator: positive if daylight savings is in effect, zero if
not, and negative if the information is not available.
See also: Section 8.82 [DATE AND TIME], page 166,
Section 8.81 [CTIME], page 165,
Section 8.183 [LTIME], page 230,
Section 8.269 [TIME], page 282,
Section 8.270 [TIME8], page 283,
Arguments:
C Shall of type CHARACTER and of default kind.
STATUS (Optional) status flag of type INTEGER. Returns 0 on
success, or a system specific error code otherwise.
Return value:
In either syntax, NAME is set to the current hostname if it can be obtained,
or to a blank string otherwise.
Note: See Section 8.143 [ICHAR], page 206, for a discussion of converting between
numerical values and formatted string representations.
See also: Section 8.5 [ACHAR], page 113,
Section 8.59 [CHAR], page 149,
Section 8.143 [ICHAR], page 206,
Return value:
The result is of the same type as ARRAY.
If DIM is absent, a scalar with the bitwise ALL of all elements in ARRAY is
returned. Otherwise, an array of rank n-1, where n equals the rank of ARRAY,
and a shape similar to that of ARRAY with dimension DIM dropped is re-
turned.
Example:
PROGRAM test_iall
INTEGER(1) :: a(2)
a(1) = b'00100100'
a(2) = b'01101010'
! prints 00100000
PRINT '(b8.8)', IALL(a)
END PROGRAM
Specific names:
Name Argument Return type Standard
IAND(A) INTEGER A INTEGER Fortran 90 and later
Chapter 8: Intrinsic Procedures 203
a(1) = b'00100100'
a(2) = b'01101010'
! prints 01101110
PRINT '(b8.8)', IANY(a)
END PROGRAM
204 The GNU Fortran Compiler
Specific names:
Name Argument Return type Standard
IBCLR(A) INTEGER A INTEGER Fortran 90 and later
BBCLR(A) INTEGER(1) A INTEGER(1) GNU extension
IIBCLR(A) INTEGER(2) A INTEGER(2) GNU extension
JIBCLR(A) INTEGER(4) A INTEGER(4) GNU extension
KIBCLR(A) INTEGER(8) A INTEGER(8) GNU extension
See also: Section 8.141 [IBITS], page 205,
Section 8.142 [IBSET], page 206,
Section 8.137 [IAND], page 202,
Section 8.152 [IOR], page 212,
Section 8.145 [IEOR], page 208,
Section 8.203 [MVBITS], page 242,
Example:
program test_ichar
integer i
i = ichar(' ')
end program test_ichar
Specific names:
Name Argument Return type Standard
ICHAR(C) CHARACTER C INTEGER(4) Fortran 77 and later
Note: No intrinsic exists to convert between a numeric value and a formatted character
string representation – for instance, given the CHARACTER value '154', obtaining
an INTEGER or REAL value with the value 154, or vice versa. Instead, this
functionality is provided by internal-file I/O, as in the following example:
program read_val
integer value
character(len=10) string, string2
string = '154'
Return value:
Does not return anything.
Example:
program test_idate
integer, dimension(3) :: tarray
call idate(tarray)
print *, tarray(1)
print *, tarray(2)
print *, tarray(3)
end program test_idate
Standard : Fortran 77 and later, with KIND argument Fortran 2003 and later
Class: Elemental function
Syntax : RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])
Arguments:
STRING Shall be a scalar CHARACTER, with INTENT(IN)
SUBSTRING Shall be a scalar CHARACTER, with INTENT(IN)
BACK (Optional) Shall be a scalar LOGICAL, with
INTENT(IN)
KIND (Optional) A scalar INTEGER constant expression in-
dicating the kind parameter of the result.
Return value:
The return value is of type INTEGER and of kind KIND. If KIND is absent, the
return value is of default integer kind.
Specific names:
Name Argument Return Standard
type
INDEX(STRING,SUBSTRING) CHARACTER INTEGER(4) Fortran 77 and later
See also: Section 8.236 [SCAN], page 261,
Section 8.282 [VERIFY], page 289,
Example:
program test_int
integer :: i = 42
complex :: z = (-3.7, 1.0)
print *, int(i)
print *, int(z), int(z,8)
end program
Specific names:
Name Argument Return type Standard
INT(A) REAL(4) A INTEGER Fortran 77 and later
IFIX(A) REAL(4) A INTEGER Fortran 77 and later
IDINT(A) REAL(8) A INTEGER Fortran 77 and later
a(1) = int(b'00100100', 1)
a(2) = int(b'01101010', 1)
! prints 01001110
PRINT '(b8.8)', IPARITY(a)
END PROGRAM
Example:
program test_irand
integer,parameter :: seed = 86456
call srand(seed)
print *, irand(), irand(), irand(), irand()
print *, irand(seed), irand(), irand(), irand()
end program test_irand
Arguments:
I Shall be of the type INTEGER.
Return value:
Returns a LOGICAL of the default kind, which .TRUE. if I has the value which
indicates an end of file condition for IOSTAT= specifiers, and is .FALSE. other-
wise.
Example:
PROGRAM iostat
IMPLICIT NONE
INTEGER :: stat, i
OPEN(88, FILE='test.dat')
READ(88, *, IOSTAT=stat) i
IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
END PROGRAM
Arguments:
UNIT Shall be a scalar INTEGER.
Return value:
Returns .TRUE. if the UNIT is connected to a terminal device, .FALSE. other-
wise.
Example:
PROGRAM test_isatty
INTEGER(kind=1) :: unit
DO unit = 1, 10
write(*,*) isatty(unit=unit)
END DO
END PROGRAM
Standard : Fortran 90 and later, has overloads that are GNU extensions
Arguments:
I The type shall be INTEGER.
SHIFT The type shall be INTEGER.
Return value:
The return value is of type INTEGER and of the same kind as I.
Specific names:
Name Argument Return type Standard
ISHFT(A) INTEGER A INTEGER Fortran 90 and later
BSHFT(A) INTEGER(1) A INTEGER(1) GNU extension
IISHFT(A) INTEGER(2) A INTEGER(2) GNU extension
JISHFT(A) INTEGER(4) A INTEGER(4) GNU extension
KISHFT(A) INTEGER(8) A INTEGER(8) GNU extension
Return value:
Returns a default-kind LOGICAL. The returned value is TRUE if X is a NaN and
FALSE otherwise.
218 The GNU Fortran Compiler
Example:
program test_nan
implicit none
real :: x
x = -1.0
x = sqrt(x)
if (isnan(x)) stop '"x" is a NaN'
end program test_nan
Syntax :
CALL LINK(PATH1, PATH2 [, STATUS])
STATUS = LINK(PATH1, PATH2)
Arguments:
PATH1 Shall be of default CHARACTER type.
PATH2 Shall be of default CHARACTER type.
STATUS (Optional) Shall be of default INTEGER type.
Arguments:
STRING A Shall be of default CHARACTER type.
STRING B Shall be of default CHARACTER type.
Return value:
Returns .TRUE. if STRING_A <= STRING_B, and .FALSE. otherwise, based on
the ASCII ordering.
Specific names:
Name Argument Return Standard
type
LLE(STRING_A,STRING_B) CHARACTER LOGICAL Fortran 77 and later
Specific names:
Name Argument Return type Standard
ALOG(X) REAL(4) X REAL(4) Fortran 77 or later
DLOG(X) REAL(8) X REAL(8) Fortran 77 or later
CLOG(X) COMPLEX(4) X COMPLEX(4) Fortran 77 or later
ZLOG(X) COMPLEX(8) X COMPLEX(8) GNU extension
CDLOG(X) COMPLEX(8) X COMPLEX(8) GNU extension
Specific names:
Name Argument Return type Standard
ALOG10(X) REAL(4) X REAL(4) Fortran 77 and later
DLOG10(X) REAL(8) X REAL(8) Fortran 77 and later
Example:
program test_log_gamma
real :: x = 1.0
x = lgamma(x) ! returns 0.0
end program test_log_gamma
Specific names:
Name Argument Return type Standard
LGAMMA(X) REAL(4) X REAL(4) GNU extension
ALGAMA(X) REAL(4) X REAL(4) GNU extension
DLGAMA(X) REAL(8) X REAL(8) GNU extension
See also: Gamma function:
Section 8.119 [GAMMA], page 191,
Arguments:
I The type shall be INTEGER.
SHIFT The type shall be INTEGER.
Return value:
The return value is of type INTEGER and of the same kind as I.
Syntax :
CALL LSTAT(NAME, VALUES [, STATUS])
STATUS = LSTAT(NAME, VALUES)
Arguments:
NAME The type shall be CHARACTER of the default kind, a
valid path within the file system.
VALUES The type shall be INTEGER(4), DIMENSION(13).
STATUS (Optional) status flag of type INTEGER(4). Returns 0
on success and a system specific error code otherwise.
ptr_x = malloc(20*8)
do i = 1, 20
x(i) = sqrt(1.0d0 / i)
end do
z = 0
do i = 1, 20
z = z + x(i)
print *, z
end do
call free(ptr_x)
end program test_malloc
Standard : Fortran 95 and later; ARRAY of CHARACTER and the KIND argument are avail-
able in Fortran 2003 and later. The BACK argument is available in Fortran
2008 and later.
Syntax :
RESULT = MAXLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK])
RESULT = MAXLOC(ARRAY [, MASK] [,KIND] [,BACK])
Arguments:
ARRAY Shall be an array of type INTEGER or REAL.
DIM (Optional) Shall be a scalar of type INTEGER, with a
value between one and the rank of ARRAY, inclusive.
It may not be an optional dummy argument.
MASK Shall be of type LOGICAL, and conformable with
ARRAY.
KIND (Optional) A scalar INTEGER constant expression in-
dicating the kind parameter of the result.
BACK (Optional) A scalar of type LOGICAL.
Return value:
If DIM is absent, the result is a rank-one array with a length equal to the rank
of ARRAY. If DIM is present, the result is an array with a rank one less than
the rank of ARRAY, and a size corresponding to the size of ARRAY with the
DIM dimension removed. If DIM is present and ARRAY has a rank of one,
the result is a scalar. If the optional argument KIND is present, the result is
an integer of kind KIND, otherwise it is of default kind.
Return value:
The return value is a scalar of type INTEGER(4), equal to the number of clock
ticks since the start of the process, or -1 if the system does not support
clock(3).
See also: Section 8.81 [CTIME], page 165,
Section 8.131 [GMTIME], page 198,
Section 8.183 [LTIME], page 230,
Section 8.192 [MCLOCK], page 235,
Section 8.269 [TIME], page 282,
Arguments:
TSOURCE May be of any type.
FSOURCE Shall be of the same type and type parameters as
TSOURCE.
MASK Shall be of type LOGICAL.
Return value:
The result is of the same type and type parameters as TSOURCE.
Specific names:
Name Argument Return type Standard
MIN0(A1) INTEGER(4) A1 INTEGER(4) Fortran 77 and later
AMIN0(A1) INTEGER(4) A1 REAL(4) Fortran 77 and later
MIN1(A1) REAL A1 INTEGER(4) Fortran 77 and later
AMIN1(A1) REAL(4) A1 REAL(4) Fortran 77 and later
DMIN1(A1) REAL(8) A1 REAL(8) Fortran 77 and later
See also: Section 8.188 [MAX], page 232,
Section 8.198 [MINLOC], page 238,
Section 8.199 [MINVAL], page 239,
Syntax :
RESULT = MINLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK])
RESULT = MINLOC(ARRAY [, MASK], [,KIND] [,BACK])
Arguments:
ARRAY Shall be an array of type INTEGER, REAL or
CHARACTER.
DIM (Optional) Shall be a scalar of type INTEGER, with a
value between one and the rank of ARRAY, inclusive.
It may not be an optional dummy argument.
MASK Shall be of type LOGICAL, and conformable with
ARRAY.
KIND (Optional) A scalar INTEGER constant expression in-
dicating the kind parameter of the result.
BACK (Optional) A scalar of type LOGICAL.
Return value:
If DIM is absent, the result is a rank-one array with a length equal to the rank
of ARRAY. If DIM is present, the result is an array with a rank one less than
the rank of ARRAY, and a size corresponding to the size of ARRAY with the
DIM dimension removed. If DIM is present and ARRAY has a rank of one,
the result is a scalar. If the optional argument KIND is present, the result is
an integer of kind KIND, otherwise it is of default kind.
See also: Section 8.108 [FINDLOC], page 183,
Section 8.196 [MIN], page 237,
Section 8.199 [MINVAL], page 239,
print *, mod(-17,3)
print *, mod(-17.5,5.5)
print *, mod(-17.5d0,5.5)
print *, mod(-17.5,5.5d0)
print *, mod(17,-3)
print *, mod(17.5,-5.5)
print *, mod(17.5d0,-5.5)
print *, mod(17.5,-5.5d0)
end program test_mod
Specific names:
Name Arguments Return type Standard
MOD(A,P) INTEGER A,P INTEGER Fortran 77 and later
Chapter 8: Intrinsic Procedures 241
print *, modulo(-17,3)
print *, modulo(-17.5,5.5)
print *, modulo(17,-3)
print *, modulo(17.5,-5.5)
end program
allocate(a(3))
a = [ 1, 2, 3 ]
call move_alloc(a, b)
print *, allocated(a), allocated(b)
print *, b
end program test_move_alloc
Specific names:
Name Argument Return type Standard
MVBITS(A) INTEGER A INTEGER Fortran 90 and later
BMVBITS(A) INTEGER(1) A INTEGER(1) GNU extension
IMVBITS(A) INTEGER(2) A INTEGER(2) GNU extension
JMVBITS(A) INTEGER(4) A INTEGER(4) GNU extension
KMVBITS(A) INTEGER(8) A INTEGER(8) GNU extension
See also: Section 8.140 [IBCLR], page 204,
Section 8.142 [IBSET], page 206,
Section 8.141 [IBITS], page 205,
Section 8.137 [IAND], page 202,
Section 8.152 [IOR], page 212,
Section 8.145 [IEOR], page 208,
Specific names:
Name Argument Return Type Standard
NINT(A) REAL(4) A INTEGER Fortran 77 and later
IDNINT(A) REAL(8) A INTEGER Fortran 77 and later
See also: Section 8.58 [CEILING], page 149,
Section 8.109 [FLOOR], page 184,
Chapter 8: Intrinsic Procedures 245
distance to the initial team, it returns the number of images index on the
ancestor team which has a distance of DISTANCE from the invoking team. If
DISTANCE is larger than the distance to the initial team, the number of images
of the initial team is returned. If FAILED is not present the total number of
images is returned; if it has the value .TRUE., the number of failed images is
returned, otherwise, the number of images which do have not the failed status.
Example:
INTEGER :: value[*]
INTEGER :: i
value = THIS_IMAGE()
SYNC ALL
IF (THIS_IMAGE() == 1) THEN
DO i = 1, NUM_IMAGES()
WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
END DO
END IF
INTEGER :: a, b
DATA a / Z'F' /, b / Z'3' /
Arguments:
X Shall be of type INTEGER or REAL
Return value:
The return value is a scalar of type INTEGER and of the default integer kind.
Example:
program test_radix
print *, "The radix for the default integer kind is", radix(0)
print *, "The radix for the default real kind is", radix(0.0)
end program test_radix
call srand(seed)
print *, rand(), rand(), rand(), rand()
print *, rand(seed), rand(), rand(), rand()
end program test_rand
call random_seed(size = n)
allocate(seed(n))
call random_seed(get=seed)
write (*, *) seed
end program test_random_seed
Example:
program test_real
complex :: x = (1.0, 2.0)
print *, real(x), real(x,8), realpart(x)
end program test_real
Specific names:
Name Argument Return type Standard
FLOAT(A) INTEGER(4) REAL(4) Fortran 77 and later
DFLOAT(A) INTEGER(4) REAL(8) GNU extension
FLOATI(A) INTEGER(2) REAL(4) GNU extension (-fdec)
FLOATJ(A) INTEGER(4) REAL(4) GNU extension (-fdec)
FLOATK(A) INTEGER(8) REAL(4) GNU extension (-fdec)
SNGL(A) REAL(8) REAL(4) Fortran 77 and later
See also: Section 8.83 [DBLE], page 167,
Arguments:
STRING Shall be scalar and of type CHARACTER.
NCOPIES Shall be scalar and of type INTEGER.
Return value:
A new scalar of type CHARACTER built up from NCOPIES copies of STRING.
Example:
program test_repeat
write(*,*) repeat("x", 5) ! "xxxxx"
end program
alphabet = ascii_"abcdefghijklmnopqrstuvwxyz"
hello_world = ucs4_'Hello World and Ni Hao -- ' &
264 The GNU Fortran Compiler
Arguments:
X Shall be of type REAL.
I Shall be of type INTEGER.
Return value:
The return value is of the same type and kind as X. The real number whose
fractional part is that of X and whose exponent part if I is returned; it is
FRACTION(X) * RADIX(X)**I.
Example:
PROGRAM test_setexp
REAL :: x = 178.1387e-4
INTEGER :: i = 17
PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
END PROGRAM
Standard : Fortran 90 and later, with KIND argument Fortran 2003 and later
Arguments:
SOURCE Shall be an array or scalar of any type. If SOURCE is
a pointer it must be associated and allocatable arrays
must be allocated.
KIND (Optional) A scalar INTEGER constant expression in-
dicating the kind parameter of the result.
Return value:
An INTEGER array of rank one with as many elements as SOURCE has dimen-
sions. The elements of the resulting array correspond to the extend of SOURCE
along the respective dimensions. If SOURCE is a scalar, the result is the rank
one array of size zero. If KIND is absent, the return value has the default
integer kind otherwise the specified kind.
Example:
PROGRAM test_shape
INTEGER, DIMENSION(-1:1, -1:2) :: A
WRITE(*,*) SHAPE(A) ! (/ 3, 4 /)
WRITE(*,*) SIZE(SHAPE(42)) ! (/ /)
END PROGRAM
Arguments:
I The type shall be INTEGER.
SHIFT The type shall be INTEGER.
Return value:
The return value is of type INTEGER and of the same kind as I.
Arguments:
I The type shall be INTEGER.
SHIFT The type shall be INTEGER.
Return value:
The return value is of type INTEGER and of the same kind as I.
print *, sign(-12.,1.)
print *, sign(-12.,0.)
print *, sign(-12.,-1.)
end program test_sign
Specific names:
Name Arguments Return type Standard
SIGN(A,B) REAL(4) A, B REAL(4) Fortran 77 and later
Chapter 8: Intrinsic Procedures 269
Arguments:
X The type shall be REAL or COMPLEX.
Return value:
The return value has same type and kind as X.
Example:
program test_sin
real :: x = 0.0
x = sin(x)
end program test_sin
Specific names:
Name Argument Return type Standard
SIN(X) REAL(4) X REAL(4) Fortran 77 and later
DSIN(X) REAL(8) X REAL(8) Fortran 77 and later
CSIN(X) COMPLEX(4) X COMPLEX(4) Fortran 77 and later
ZSIN(X) COMPLEX(8) X COMPLEX(8) GNU extension
CDSIN(X) COMPLEX(8) X COMPLEX(8) GNU extension
See also: Inverse function:
Section 8.19 [ASIN], page 122,
Degrees function:
Section 8.250 [SIND], page 270,
Specific names:
Name Argument Return type Standard
SIND(X) REAL(4) X REAL(4) GNU extension
DSIND(X) REAL(8) X REAL(8) GNU extension
Chapter 8: Intrinsic Procedures 271
Specific names:
Name Argument Return type Standard
DSINH(X) REAL(8) X REAL(8) Fortran 90 and later
See also: Section 8.21 [ASINH], page 124,
IF (status == 0) THEN
WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
WRITE (*, FMT="('File size:', T30, I19)") buff(8)
WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
END IF
END PROGRAM
See also: To stat an open file:
Section 8.117 [FSTAT], page 190,
To stat a link:
Section 8.182 [LSTAT], page 229,
Specific names:
Name Argument Return type Standard
TAN(X) REAL(4) X REAL(4) Fortran 77 and later
DTAN(X) REAL(8) X REAL(8) Fortran 77 and later
See also: Inverse function:
Section 8.23 [ATAN], page 126,
Degrees function:
Section 8.266 [TAND], page 280,
Example:
program test_tand
real(8) :: x = 0.165_8
x = tand(x)
end program test_tand
Specific names:
Name Argument Return type Standard
TAND(X) REAL(4) X REAL(4) GNU extension
DTAND(X) REAL(8) X REAL(8) GNU extension
See also: Inverse function:
Section 8.24 [ATAND], page 126,
Radians function:
Section 8.265 [TAN], page 280,
Specific names:
Name Argument Return type Standard
TANH(X) REAL(4) X REAL(4) Fortran 77 and later
DTANH(X) REAL(8) X REAL(8) Fortran 77 and later
See also: Section 8.27 [ATANH], page 129,
Standard : Fortran 2008 and later. With DISTANCE argument, Technical Specification
(TS) 18508 or later
Class: Transformational function
Syntax :
RESULT = THIS_IMAGE()
RESULT = THIS_IMAGE(DISTANCE)
RESULT = THIS_IMAGE(COARRAY [, DIM])
Arguments:
DISTANCE (optional, intent(in)) Nonnegative scalar integer (not
permitted together with COARRAY ).
COARRAY Coarray of any type (optional; if DIM present,
required).
DIM default integer scalar (optional). If present, DIM
shall be between one and the corank of COARRAY.
Return value:
Default integer. If COARRAY is not present, it is scalar; if DISTANCE is not
present or has value 0, its value is the image index on the invoking image for the
current team, for values smaller or equal distance to the initial team, it returns
the image index on the ancestor team which has a distance of DISTANCE
from the invoking team. If DISTANCE is larger than the distance to the
initial team, the image index of the initial team is returned. Otherwise when
the COARRAY is present, if DIM is not present, a rank-1 array with corank
elements is returned, containing the cosubscripts for COARRAY specifying the
invoking image. If DIM is present, a scalar is returned, with the value of the
DIM element of THIS_IMAGE(COARRAY).
Example:
INTEGER :: value[*]
INTEGER :: i
value = THIS_IMAGE()
SYNC ALL
IF (THIS_IMAGE() == 1) THEN
DO i = 1, NUM_IMAGES()
WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
END DO
END IF
to Section 8.81 [CTIME], page 165, Section 8.131 [GMTIME], page 198, and
Section 8.183 [LTIME], page 230.
This intrinsic is not fully portable, such as to systems with 32-bit INTEGER
types but supporting times wider than 32 bits. Therefore, the values returned
by this intrinsic might be, or become, negative, or numerically less than previous
values, during a single run of the compiled program.
See Section 8.270 [TIME8], page 283, for information on a similar intrinsic that
might be portable to more GNU Fortran implementations, though to fewer
Fortran compilers.
Standard : GNU extension
Class: Function
Syntax : RESULT = TIME()
Return value:
The return value is a scalar of type INTEGER(4).
See also: Section 8.82 [DATE AND TIME], page 166,
Section 8.81 [CTIME], page 165,
Section 8.131 [GMTIME], page 198,
Section 8.183 [LTIME], page 230,
Section 8.192 [MCLOCK], page 235,
Section 8.270 [TIME8], page 283,
Arguments:
MATRIX Shall be an array of any type and have a rank of two.
Return value:
The result has the same type as MATRIX, and has shape (/ m, n /) if MA-
TRIX has shape (/ n, m /).
Example:
PROGRAM test_ttynam
INTEGER :: unit
DO unit = 1, 10
IF (isatty(unit=unit)) write(*,*) ttynam(unit)
END DO
END PROGRAM
Arguments:
STRING Shall be of type CHARACTER.
SET Shall be of type CHARACTER.
BACK (Optional) shall be of type LOGICAL.
KIND (Optional) A scalar INTEGER constant expression in-
dicating the kind parameter of the result.
Return value:
The return value is of type INTEGER and of kind KIND. If KIND is absent, the
return value is of default integer kind.
Example:
PROGRAM test_verify
WRITE(*,*) VERIFY("FORTRAN", "AO") ! 1, found 'F'
WRITE(*,*) VERIFY("FORTRAN", "FOO") ! 3, found 'R'
WRITE(*,*) VERIFY("FORTRAN", "C++") ! 1, found 'F'
WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.) ! 7, found 'N'
WRITE(*,*) VERIFY("FORTRAN", "FORTRAN") ! 0' found none
END PROGRAM
Example:
PROGRAM test_xor
LOGICAL :: T = .TRUE., F = .FALSE.
INTEGER :: a, b
DATA a / Z'F' /, b / Z'3' /
9 Intrinsic Modules
9.1 ISO_FORTRAN_ENV
Standard : Fortran 2003 and later, except when otherwise noted
The ISO_FORTRAN_ENV module provides the following scalar default-integer named con-
stants:
ATOMIC_INT_KIND:
Default-kind integer constant to be used as kind parameter when defining inte-
ger variables used in atomic operations. (Fortran 2008 or later.)
ATOMIC_LOGICAL_KIND:
Default-kind integer constant to be used as kind parameter when defining logical
variables used in atomic operations. (Fortran 2008 or later.)
CHARACTER_KINDS:
Default-kind integer constant array of rank one containing the supported kind
parameters of the CHARACTER type. (Fortran 2008 or later.)
CHARACTER_STORAGE_SIZE:
Size in bits of the character storage unit.
ERROR_UNIT:
Identifies the preconnected unit used for error reporting.
FILE_STORAGE_SIZE:
Size in bits of the file-storage unit.
INPUT_UNIT:
Identifies the preconnected unit identified by the asterisk (*) in READ statement.
INT8, INT16, INT32, INT64:
Kind type parameters to specify an INTEGER type with a storage size of 16, 32,
and 64 bits. It is negative if a target platform does not support the particular
kind. (Fortran 2008 or later.)
INTEGER_KINDS:
Default-kind integer constant array of rank one containing the supported kind
parameters of the INTEGER type. (Fortran 2008 or later.)
IOSTAT_END:
The value assigned to the variable passed to the IOSTAT= specifier of an in-
put/output statement if an end-of-file condition occurred.
IOSTAT_EOR:
The value assigned to the variable passed to the IOSTAT= specifier of an in-
put/output statement if an end-of-record condition occurred.
IOSTAT_INQUIRE_INTERNAL_UNIT:
Scalar default-integer constant, used by INQUIRE for the IOSTAT= specifier to
denote an that a unit number identifies an internal unit. (Fortran 2008 or later.)
294 The GNU Fortran Compiler
NUMERIC_STORAGE_SIZE:
The size in bits of the numeric storage unit.
LOGICAL_KINDS:
Default-kind integer constant array of rank one containing the supported kind
parameters of the LOGICAL type. (Fortran 2008 or later.)
OUTPUT_UNIT:
Identifies the preconnected unit identified by the asterisk (*) in WRITE state-
ment.
REAL32, REAL64, REAL128:
Kind type parameters to specify a REAL type with a storage size of 32, 64,
and 128 bits. It is negative if a target platform does not support the particular
kind. (Fortran 2008 or later.)
REAL_KINDS:
Default-kind integer constant array of rank one containing the supported kind
parameters of the REAL type. (Fortran 2008 or later.)
STAT_LOCKED:
Scalar default-integer constant used as STAT= return value by LOCK to denote
that the lock variable is locked by the executing image. (Fortran 2008 or later.)
STAT_LOCKED_OTHER_IMAGE:
Scalar default-integer constant used as STAT= return value by UNLOCK to denote
that the lock variable is locked by another image. (Fortran 2008 or later.)
STAT_STOPPED_IMAGE:
Positive, scalar default-integer constant used as STAT= return value if the
argument in the statement requires synchronisation with an image, which has
initiated the termination of the execution. (Fortran 2008 or later.)
STAT_FAILED_IMAGE:
Positive, scalar default-integer constant used as STAT= return value if the
argument in the statement requires communication with an image, which has
is in the failed state. (TS 18508 or later.)
STAT_UNLOCKED:
Scalar default-integer constant used as STAT= return value by UNLOCK to denote
that the lock variable is unlocked. (Fortran 2008 or later.)
LOCK_TYPE:
Derived type with private components to be use with the LOCK and UNLOCK
statement. A variable of its type has to be always declared as coarray and may
not appear in a variable-definition context. (Fortran 2008 or later.)
The module also provides the following intrinsic procedures: Section 8.69
[COMPILER OPTIONS], page 157, and Section 8.70 [COMPILER VERSION], page 158.
Chapter 9: Intrinsic Modules 295
9.2 ISO_C_BINDING
Standard : Fortran 2003 and later, GNU extensions
The following intrinsic procedures are provided by the module; their definition can be
found in the section Intrinsic Procedures of this manual.
C_ASSOCIATED
C_F_POINTER
C_F_PROCPOINTER
C_FUNLOC
C_LOC
C_SIZEOF
The ISO_C_BINDING module provides the following named constants of type default
integer, which can be used as KIND type parameters.
In addition to the integer named constants required by the Fortran 2003 standard and
C_PTRDIFF_T of TS 29113, GNU Fortran provides as an extension named constants for
the 128-bit integer types supported by the C compiler: C_INT128_T, C_INT_LEAST128_T,
C_INT_FAST128_T. Furthermore, if _Float128 is supported in C, the named constants
C_FLOAT128 and C_FLOAT128_COMPLEX are defined.
Fortran Type Named constant C type Extension
INTEGER C_INT int
INTEGER C_SHORT short int
INTEGER C_LONG long int
INTEGER C_LONG_LONG long long int
INTEGER C_SIGNED_CHAR signed char/unsigned
char
INTEGER C_SIZE_T size_t
INTEGER C_INT8_T int8_t
INTEGER C_INT16_T int16_t
INTEGER C_INT32_T int32_t
INTEGER C_INT64_T int64_t
INTEGER C_INT128_T int128_t Ext.
INTEGER C_INT_LEAST8_T int_least8_t
INTEGER C_INT_LEAST16_T int_least16_t
INTEGER C_INT_LEAST32_T int_least32_t
INTEGER C_INT_LEAST64_T int_least64_t
INTEGER C_INT_LEAST128_T int_least128_t Ext.
INTEGER C_INT_FAST8_T int_fast8_t
INTEGER C_INT_FAST16_T int_fast16_t
INTEGER C_INT_FAST32_T int_fast32_t
INTEGER C_INT_FAST64_T int_fast64_t
INTEGER C_INT_FAST128_T int_fast128_t Ext.
INTEGER C_INTMAX_T intmax_t
INTEGER C_INTPTR_T intptr_t
INTEGER C_PTRDIFF_T ptrdiff_t TS 29113
296 The GNU Fortran Compiler
The OpenMP Fortran runtime library routines are provided both in a form of two Fortran
modules, named OMP_LIB and OMP_LIB_KINDS, and in a form of a Fortran include file
named omp_lib.h. The procedures provided by OMP_LIB can be found in the Section
“Introduction” in GNU Offloading and Multi Processing Runtime Library manual, the
named constants defined in the modules are listed below.
For details refer to the actual OpenMP Application Program Interface v4.5
(https://www.openmp.org/wp-content/uploads/openmp-4.5.pdf) and OpenMP
Application Program Interface v5.0 (https://www.openmp.org/wp-content/uploads/
OpenMP-API-Specification-5.0.pdf).
omp_allocator_handle_kind
omp_alloctrait_key_kind
omp_alloctrait_val_kind
omp_depend_kind
omp_lock_kind
omp_lock_hint_kind
omp_nest_lock_kind
omp_pause_resource_kind
omp_memspace_handle_kind
omp_proc_bind_kind
omp_sched_kind
omp_sync_hint_kind
omp_alloctrait
omp_sched_static
omp_sched_dynamic
omp_sched_guided
omp_sched_auto
And the following scalar integer named constants of the kind omp_proc_bind_kind:
298 The GNU Fortran Compiler
omp_proc_bind_false
omp_proc_bind_true
omp_proc_bind_primary
omp_proc_bind_master
omp_proc_bind_close
omp_proc_bind_spread
The following scalar integer named constants are of the kind omp_lock_hint_kind:
omp_lock_hint_none
omp_lock_hint_uncontended
omp_lock_hint_contended
omp_lock_hint_nonspeculative
omp_lock_hint_speculative
omp_sync_hint_none
omp_sync_hint_uncontended
omp_sync_hint_contended
omp_sync_hint_nonspeculative
omp_sync_hint_speculative
And the following two scalar integer named constants are of the kind omp_pause_
resource_kind:
omp_pause_soft
omp_pause_hard
The following scalar integer named constants are of the kind omp_alloctrait_key_kind:
omp_atk_sync_hint
omp_atk_alignment
omp_atk_access
omp_atk_pool_size
omp_atk_fallback
omp_atk_fb_data
omp_atk_pinned
omp_atk_partition
The following scalar integer named constants are of the kind omp_alloctrait_val_kind:
omp_alloctrait_key_kind:
Chapter 9: Intrinsic Modules 299
omp_atv_default
omp_atv_false
omp_atv_true
omp_atv_contended
omp_atv_uncontended
omp_atv_serialized
omp_atv_sequential
omp_atv_private
omp_atv_all
omp_atv_thread
omp_atv_pteam
omp_atv_cgroup
omp_atv_default_mem_fb
omp_atv_null_fb
omp_atv_abort_fb
omp_atv_allocator_fb
omp_atv_environment
omp_atv_nearest
omp_atv_blocked
The following scalar integer named constants are of the kind omp_allocator_handle_
kind:
omp_null_allocator
omp_default_mem_alloc
omp_large_cap_mem_alloc
omp_const_mem_alloc
omp_high_bw_mem_alloc
omp_low_lat_mem_alloc
omp_cgroup_mem_alloc
omp_pteam_mem_alloc
omp_thread_mem_alloc
The following scalar integer named constants are of the kind omp_memspace_handle_
kind:
omp_default_mem_space
omp_large_cap_mem_space
omp_const_mem_space
omp_high_bw_mem_space
omp_low_lat_mem_space
For details refer to the actual OpenACC Application Programming Interface v2.6
(https://www.openacc.org/).
OPENACC provides the scalar default-integer named constant openacc_version with a
value of the form yyyymm, where yyyy is the year and mm the month of the OpenACC
version; for OpenACC v2.6 the value is 201711.
301
Contributing
Free software is only possible if people contribute to efforts to create it. We’re always in
need of more people helping out with ideas and comments, writing documentation and
contributing code.
If you want to contribute to GNU Fortran, have a look at the long lists of projects you
can take on. Some of these projects are small, some of them are large; some are completely
orthogonal to the rest of what is happening on GNU Fortran, but others are “mainstream”
projects in need of enthusiastic hackers. All of these projects are important! We will
eventually get around to the things here, but they are also things doable by someone who
is willing and able.
− Tim Prince
− Christopher D. Rickett
− Richard Sandiford
− Tobias Schlüter
− Roger Sayle
− Paul Thomas
− Andy Vaught
− Feng Wang
− Janus Weil
− Daniel Kraft
The following people have contributed bug reports, smaller or larger patches, and much
needed feedback and encouragement for the GNU Fortran project:
− Bill Clodius
− Dominique d’Humières
− Kate Hedstrom
− Erik Schnetter
− Gerhard Steinmetz
− Joost VandeVondele
Many other individuals have helped debug, test and improve the GNU Fortran compiler
over the past few years, and we welcome you to do the same! If you already have done so,
and you would like to see your name listed in the list above, please contact us.
Projects
Help build the test suite
Solicit more code for donation to the test suite: the more extensive the testsuite,
the smaller the risk of breaking things in the future! We can keep code private
on request.
Bug hunting/squishing
Find bugs and write more test cases! Test cases are especially very welcome, be-
cause it allows us to concentrate on fixing bugs instead of isolating them. Going
through the bugzilla database at https://gcc.gnu.org/bugzilla/ to reduce
testcases posted there and add more information (for example, for which version
does the testcase work, for which versions does it fail?) is also very helpful.
Missing features
For a larger project, consider working on the missing features required for For-
tran language standards compliance (see Section 1.3 [Standards], page 3), or
contributing to the implementation of extensions such as OpenMP (see Sec-
tion 5.1.18 [OpenMP], page 54) or OpenACC (see Section 5.1.19 [OpenACC],
page 55) that are under active development. Again, contributing test cases for
these features is useful too!
303
Preamble
The GNU General Public License is a free, copyleft license for software and other kinds of
works.
The licenses for most software and other practical works are designed to take away your
freedom to share and change the works. By contrast, the GNU General Public License is
intended to guarantee your freedom to share and change all versions of a program–to make
sure it remains free software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to any other work
released this way by its authors. You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General
Public Licenses are designed to make sure that you have the freedom to distribute copies
of free software (and charge for them if you wish), that you receive source code or can get
it if you want it, that you can change the software or use pieces of it in new free programs,
and that you know you can do these things.
To protect your rights, we need to prevent others from denying you these rights or asking
you to surrender the rights. Therefore, you have certain responsibilities if you distribute
copies of the software, or if you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether gratis or for a fee, you
must pass on to the recipients the same freedoms that you received. You must make sure
that they, too, receive or can get the source code. And you must show them these terms so
they know their rights.
Developers that use the GNU GPL protect your rights with two steps: (1) assert copy-
right on the software, and (2) offer you this License giving you legal permission to copy,
distribute and/or modify it.
For the developers’ and authors’ protection, the GPL clearly explains that there is no
warranty for this free software. For both users’ and authors’ sake, the GPL requires that
modified versions be marked as changed, so that their problems will not be attributed
erroneously to authors of previous versions.
Some devices are designed to deny users access to install or run modified versions of the
software inside them, although the manufacturer can do so. This is fundamentally incom-
patible with the aim of protecting users’ freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to use, which is pre-
cisely where it is most unacceptable. Therefore, we have designed this version of the GPL
to prohibit the practice for those products. If such problems arise substantially in other
domains, we stand ready to extend this provision to those domains in future versions of the
GPL, as needed to protect the freedom of users.
304 The GNU Fortran Compiler
Finally, every program is threatened constantly by software patents. States should not
allow patents to restrict development and use of software on general-purpose computers, but
in those that do, we wish to avoid the special danger that patents applied to a free program
could make it effectively proprietary. To prevent this, the GPL assures that patents cannot
be used to render the program non-free.
The precise terms and conditions for copying, distribution and modification follow.
The “System Libraries” of an executable work include anything, other than the work as
a whole, that (a) is included in the normal form of packaging a Major Component, but
which is not part of that Major Component, and (b) serves only to enable use of the
work with that Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A “Major Component”,
in this context, means a major essential component (kernel, window system, and so
on) of the specific operating system (if any) on which the executable work runs, or a
compiler used to produce the work, or an object code interpreter used to run it.
The “Corresponding Source” for a work in object code form means all the source code
needed to generate, install, and (for an executable work) run the object code and to
modify the work, including scripts to control those activities. However, it does not
include the work’s System Libraries, or general-purpose tools or generally available
free programs which are used unmodified in performing those activities but which are
not part of the work. For example, Corresponding Source includes interface definition
files associated with source files for the work, and the source code for shared libraries
and dynamically linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those subprograms
and other parts of the work.
The Corresponding Source need not include anything that users can regenerate auto-
matically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the
Program, and are irrevocable provided the stated conditions are met. This License ex-
plicitly affirms your unlimited permission to run the unmodified Program. The output
from running a covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your rights of fair use
or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without
conditions so long as your license otherwise remains in force. You may convey covered
works to others for the sole purpose of having them make modifications exclusively
for you, or provide you with facilities for running those works, provided that you
comply with the terms of this License in conveying all material for which you do not
control copyright. Those thus making or running the covered works for you must do
so exclusively on your behalf, under your direction and control, on terms that prohibit
them from making any copies of your copyrighted material outside their relationship
with you.
Conveying under any other circumstances is permitted solely under the conditions
stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users’ Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under
any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty
adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention
of such measures.
306 The GNU Fortran Compiler
When you convey a covered work, you waive any legal power to forbid circumvention of
technological measures to the extent such circumvention is effected by exercising rights
under this License with respect to the covered work, and you disclaim any intention
to limit operation or modification of the work as a means of enforcing, against the
work’s users, your or third parties’ legal rights to forbid circumvention of technological
measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program’s source code as you receive it, in any
medium, provided that you conspicuously and appropriately publish on each copy an
appropriate copyright notice; keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code; keep intact all
notices of the absence of any warranty; and give all recipients a copy of this License
along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer
support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from
the Program, in the form of source code under the terms of section 4, provided that
you also meet all of these conditions:
a. The work must carry prominent notices stating that you modified it, and giving a
relevant date.
b. The work must carry prominent notices stating that it is released under this Li-
cense and any conditions added under section 7. This requirement modifies the
requirement in section 4 to “keep intact all notices”.
c. You must license the entire work, as a whole, under this License to anyone who
comes into possession of a copy. This License will therefore apply, along with any
applicable section 7 additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no permission to license
the work in any other way, but it does not invalidate such permission if you have
separately received it.
d. If the work has interactive user interfaces, each must display Appropriate Legal
Notices; however, if the Program has interactive interfaces that do not display
Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which
are not by their nature extensions of the covered work, and which are not combined
with it such as to form a larger program, in or on a volume of a storage or distribution
medium, is called an “aggregate” if the compilation and its resulting copyright are
not used to limit the access or legal rights of the compilation’s users beyond what the
individual works permit. Inclusion of a covered work in an aggregate does not cause
this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and
5, provided that you also convey the machine-readable Corresponding Source under
the terms of this License, in one of these ways:
GNU General Public License 307
a. Convey the object code in, or embodied in, a physical product (including a phys-
ical distribution medium), accompanied by the Corresponding Source fixed on a
durable physical medium customarily used for software interchange.
b. Convey the object code in, or embodied in, a physical product (including a physi-
cal distribution medium), accompanied by a written offer, valid for at least three
years and valid for as long as you offer spare parts or customer support for that
product model, to give anyone who possesses the object code either (1) a copy of
the Corresponding Source for all the software in the product that is covered by this
License, on a durable physical medium customarily used for software interchange,
for a price no more than your reasonable cost of physically performing this con-
veying of source, or (2) access to copy the Corresponding Source from a network
server at no charge.
c. Convey individual copies of the object code with a copy of the written offer to
provide the Corresponding Source. This alternative is allowed only occasionally
and noncommercially, and only if you received the object code with such an offer,
in accord with subsection 6b.
d. Convey the object code by offering access from a designated place (gratis or for
a charge), and offer equivalent access to the Corresponding Source in the same
way through the same place at no further charge. You need not require recipients
to copy the Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source may be on
a different server (operated by you or a third party) that supports equivalent
copying facilities, provided you maintain clear directions next to the object code
saying where to find the Corresponding Source. Regardless of what server hosts
the Corresponding Source, you remain obligated to ensure that it is available for
as long as needed to satisfy these requirements.
e. Convey the object code using peer-to-peer transmission, provided you inform other
peers where the object code and Corresponding Source of the work are being offered
to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Cor-
responding Source as a System Library, need not be included in conveying the object
code work.
A “User Product” is either (1) a “consumer product”, which means any tangible per-
sonal property which is normally used for personal, family, or household purposes, or
(2) anything designed or sold for incorporation into a dwelling. In determining whether
a product is a consumer product, doubtful cases shall be resolved in favor of coverage.
For a particular product received by a particular user, “normally used” refers to a
typical or common use of that class of product, regardless of the status of the par-
ticular user or of the way in which the particular user actually uses, or expects or is
expected to use, the product. A product is a consumer product regardless of whether
the product has substantial commercial, industrial or non-consumer uses, unless such
uses represent the only significant mode of use of the product.
“Installation Information” for a User Product means any methods, procedures, autho-
rization keys, or other information required to install and execute modified versions of a
covered work in that User Product from a modified version of its Corresponding Source.
308 The GNU Fortran Compiler
The information must suffice to ensure that the continued functioning of the modified
object code is in no case prevented or interfered with solely because modification has
been made.
If you convey an object code work under this section in, or with, or specifically for
use in, a User Product, and the conveying occurs as part of a transaction in which
the right of possession and use of the User Product is transferred to the recipient in
perpetuity or for a fixed term (regardless of how the transaction is characterized),
the Corresponding Source conveyed under this section must be accompanied by the
Installation Information. But this requirement does not apply if neither you nor any
third party retains the ability to install modified object code on the User Product (for
example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement
to continue to provide support service, warranty, or updates for a work that has been
modified or installed by the recipient, or for the User Product in which it has been
modified or installed. Access to a network may be denied when the modification itself
materially and adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with
this section must be in a format that is publicly documented (and with an implementa-
tion available to the public in source code form), and must require no special password
or key for unpacking, reading or copying.
7. Additional Terms.
“Additional permissions” are terms that supplement the terms of this License by mak-
ing exceptions from one or more of its conditions. Additional permissions that are
applicable to the entire Program shall be treated as though they were included in this
License, to the extent that they are valid under applicable law. If additional permis-
sions apply only to part of the Program, that part may be used separately under those
permissions, but the entire Program remains governed by this License without regard
to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any
additional permissions from that copy, or from any part of it. (Additional permissions
may be written to require their own removal in certain cases when you modify the
work.) You may place additional permissions on material, added by you to a covered
work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered
work, you may (if authorized by the copyright holders of that material) supplement
the terms of this License with terms:
a. Disclaiming warranty or limiting liability differently from the terms of sections 15
and 16 of this License; or
b. Requiring preservation of specified reasonable legal notices or author attributions
in that material or in the Appropriate Legal Notices displayed by works containing
it; or
c. Prohibiting misrepresentation of the origin of that material, or requiring that mod-
ified versions of such material be marked in reasonable ways as different from the
original version; or
GNU General Public License 309
d. Limiting the use for publicity purposes of names of licensors or authors of the
material; or
e. Declining to grant rights under trademark law for use of some trade names, trade-
marks, or service marks; or
f. Requiring indemnification of licensors and authors of that material by anyone who
conveys the material (or modified versions of it) with contractual assumptions
of liability to the recipient, for any liability that these contractual assumptions
directly impose on those licensors and authors.
All other non-permissive additional terms are considered “further restrictions” within
the meaning of section 10. If the Program as you received it, or any part of it, con-
tains a notice stating that it is governed by this License along with a term that is a
further restriction, you may remove that term. If a license document contains a further
restriction but permits relicensing or conveying under this License, you may add to a
covered work material governed by the terms of that license document, provided that
the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the
relevant source files, a statement of the additional terms that apply to those files, or a
notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a sep-
arately written license, or stated as exceptions; the above requirements apply either
way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided un-
der this License. Any attempt otherwise to propagate or modify it is void, and will
automatically terminate your rights under this License (including any patent licenses
granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular
copyright holder is reinstated (a) provisionally, unless and until the copyright holder
explicitly and finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means prior to 60 days
after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if
the copyright holder notifies you of the violation by some reasonable means, this is the
first time you have received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after your receipt of the
notice.
Termination of your rights under this section does not terminate the licenses of parties
who have received copies or rights from you under this License. If your rights have
been terminated and not permanently reinstated, you do not qualify to receive new
licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the
Program. Ancillary propagation of a covered work occurring solely as a consequence of
using peer-to-peer transmission to receive a copy likewise does not require acceptance.
310 The GNU Fortran Compiler
However, nothing other than this License grants you permission to propagate or modify
any covered work. These actions infringe copyright if you do not accept this License.
Therefore, by modifying or propagating a covered work, you indicate your acceptance
of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license
from the original licensors, to run, modify and propagate that work, subject to this
License. You are not responsible for enforcing compliance by third parties with this
License.
An “entity transaction” is a transaction transferring control of an organization, or
substantially all assets of one, or subdividing an organization, or merging organizations.
If propagation of a covered work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever licenses to the work
the party’s predecessor in interest had or could give under the previous paragraph, plus
a right to possession of the Corresponding Source of the work from the predecessor in
interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or
affirmed under this License. For example, you may not impose a license fee, royalty, or
other charge for exercise of rights granted under this License, and you may not initiate
litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent
claim is infringed by making, using, selling, offering for sale, or importing the Program
or any portion of it.
11. Patents.
A “contributor” is a copyright holder who authorizes use under this License of the
Program or a work on which the Program is based. The work thus licensed is called
the contributor’s “contributor version”.
A contributor’s “essential patent claims” are all patent claims owned or controlled by
the contributor, whether already acquired or hereafter acquired, that would be infringed
by some manner, permitted by this License, of making, using, or selling its contributor
version, but do not include claims that would be infringed only as a consequence of
further modification of the contributor version. For purposes of this definition, “con-
trol” includes the right to grant patent sublicenses in a manner consistent with the
requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license
under the contributor’s essential patent claims, to make, use, sell, offer for sale, import
and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a “patent license” is any express agreement or com-
mitment, however denominated, not to enforce a patent (such as an express permission
to practice a patent or covenant not to sue for patent infringement). To “grant” such
a patent license to a party means to make such an agreement or commitment not to
enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corre-
sponding Source of the work is not available for anyone to copy, free of charge and under
the terms of this License, through a publicly available network server or other readily
accessible means, then you must either (1) cause the Corresponding Source to be so
GNU General Public License 311
available, or (2) arrange to deprive yourself of the benefit of the patent license for this
particular work, or (3) arrange, in a manner consistent with the requirements of this
License, to extend the patent license to downstream recipients. “Knowingly relying”
means you have actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient’s use of the covered work in a country,
would infringe one or more identifiable patents in that country that you have reason
to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey,
or propagate by procuring conveyance of, a covered work, and grant a patent license
to some of the parties receiving the covered work authorizing them to use, propagate,
modify or convey a specific copy of the covered work, then the patent license you grant
is automatically extended to all recipients of the covered work and works based on it.
A patent license is “discriminatory” if it does not include within the scope of its cover-
age, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the
rights that are specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is in the business of
distributing software, under which you make payment to the third party based on the
extent of your activity of conveying the work, and under which the third party grants,
to any of the parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work conveyed by you (or
copies made from those copies), or (b) primarily for and in connection with specific
products or compilations that contain the covered work, unless you entered into that
arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or
other defenses to infringement that may otherwise be available to you under applicable
patent law.
12. No Surrender of Others’ Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise) that
contradict the conditions of this License, they do not excuse you from the conditions
of this License. If you cannot convey a covered work so as to satisfy simultaneously
your obligations under this License and any other pertinent obligations, then as a
consequence you may not convey it at all. For example, if you agree to terms that
obligate you to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this License would
be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have permission to link or
combine any covered work with a work licensed under version 3 of the GNU Affero
General Public License into a single combined work, and to convey the resulting work.
The terms of this License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License, section 13,
concerning interaction through a network will apply to the combination as such.
14. Revised Versions of this License.
312 The GNU Fortran Compiler
The Free Software Foundation may publish revised and/or new versions of the GNU
General Public License from time to time. Such new versions will be similar in spirit
to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies that
a certain numbered version of the GNU General Public License “or any later version”
applies to it, you have the option of following the terms and conditions either of that
numbered version or of any later version published by the Free Software Foundation.
If the Program does not specify a version number of the GNU General Public License,
you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU
General Public License can be used, that proxy’s public statement of acceptance of a
version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no
additional obligations are imposed on any author or copyright holder as a result of your
choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PER-
MITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN
WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE
THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EX-
PRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFEC-
TIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO
MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, IN-
CIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO
LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUS-
TAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR
OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAM-
AGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given
local legal effect according to their terms, reviewing courts shall apply local law that
most closely approximates an absolute waiver of all civil liability in connection with
the Program, unless a warranty or assumption of liability accompanies a copy of the
Program in return for a fee.
GNU General Public License 313
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like this when it
starts in an interactive mode:
program Copyright (C) year name of author
This program comes with ABSOLUTELY NO WARRANTY; for details type ‘show w’.
This is free software, and you are welcome to redistribute it
under certain conditions; type ‘show c’ for details.
The hypothetical commands ‘show w’ and ‘show c’ should show the appropriate parts of
the General Public License. Of course, your program’s commands might be different; for a
GUI interface, you would use an “about box”.
You should also get your employer (if you work as a programmer) or school, if any, to
sign a “copyright disclaimer” for the program, if necessary. For more information on this,
and how to apply and follow the GNU GPL, see https://www.gnu.org/licenses/.
The GNU General Public License does not permit incorporating your program into pro-
prietary programs. If your program is a subroutine library, you may consider it more useful
to permit linking proprietary applications with the library. If this is what you want to do,
use the GNU Lesser General Public License instead of this License. But first, please read
https://www.gnu.org/licenses/why-not-lgpl.html.
315
under this License. If a section does not fit the above definition of Secondary then it is
not allowed to be designated as Invariant. The Document may contain zero Invariant
Sections. If the Document does not identify any Invariant Sections then there are none.
The “Cover Texts” are certain short passages of text that are listed, as Front-Cover
Texts or Back-Cover Texts, in the notice that says that the Document is released under
this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may
be at most 25 words.
A “Transparent” copy of the Document means a machine-readable copy, represented
in a format whose specification is available to the general public, that is suitable for
revising the document straightforwardly with generic text editors or (for images com-
posed of pixels) generic paint programs or (for drawings) some widely available drawing
editor, and that is suitable for input to text formatters or for automatic translation to
a variety of formats suitable for input to text formatters. A copy made in an otherwise
Transparent file format whose markup, or absence of markup, has been arranged to
thwart or discourage subsequent modification by readers is not Transparent. An image
format is not Transparent if used for any substantial amount of text. A copy that is
not “Transparent” is called “Opaque”.
Examples of suitable formats for Transparent copies include plain ascii without
markup, Texinfo input format, LaTEX input format, SGML or XML using a publicly
available DTD, and standard-conforming simple HTML, PostScript or PDF designed
for human modification. Examples of transparent image formats include PNG, XCF
and JPG. Opaque formats include proprietary formats that can be read and edited
only by proprietary word processors, SGML or XML for which the DTD and/or
processing tools are not generally available, and the machine-generated HTML,
PostScript or PDF produced by some word processors for output purposes only.
The “Title Page” means, for a printed book, the title page itself, plus such following
pages as are needed to hold, legibly, the material this License requires to appear in the
title page. For works in formats which do not have any title page as such, “Title Page”
means the text near the most prominent appearance of the work’s title, preceding the
beginning of the body of the text.
The “publisher” means any person or entity that distributes copies of the Document
to the public.
A section “Entitled XYZ” means a named subunit of the Document whose title either
is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in
another language. (Here XYZ stands for a specific section name mentioned below, such
as “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) To “Preserve
the Title” of such a section when you modify the Document means that it remains a
section “Entitled XYZ” according to this definition.
The Document may include Warranty Disclaimers next to the notice which states that
this License applies to the Document. These Warranty Disclaimers are considered to
be included by reference in this License, but only as regards disclaiming warranties:
any other implication that these Warranty Disclaimers may have is void and has no
effect on the meaning of this License.
2. VERBATIM COPYING
GNU Free Documentation License 317
You may copy and distribute the Document in any medium, either commercially or
noncommercially, provided that this License, the copyright notices, and the license
notice saying this License applies to the Document are reproduced in all copies, and
that you add no other conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further copying of the copies
you make or distribute. However, you may accept compensation in exchange for copies.
If you distribute a large enough number of copies you must also follow the conditions
in section 3.
You may also lend copies, under the same conditions stated above, and you may publicly
display copies.
3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have printed covers) of
the Document, numbering more than 100, and the Document’s license notice requires
Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all
these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify you as the publisher
of these copies. The front cover must present the full title with all words of the title
equally prominent and visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve the title of the
Document and satisfy these conditions, can be treated as verbatim copying in other
respects.
If the required texts for either cover are too voluminous to fit legibly, you should put
the first ones listed (as many as fit reasonably) on the actual cover, and continue the
rest onto adjacent pages.
If you publish or distribute Opaque copies of the Document numbering more than 100,
you must either include a machine-readable Transparent copy along with each Opaque
copy, or state in or with each Opaque copy a computer-network location from which
the general network-using public has access to download using public-standard network
protocols a complete Transparent copy of the Document, free of added material. If
you use the latter option, you must take reasonably prudent steps, when you begin
distribution of Opaque copies in quantity, to ensure that this Transparent copy will
remain thus accessible at the stated location until at least one year after the last time
you distribute an Opaque copy (directly or through your agents or retailers) of that
edition to the public.
It is requested, but not required, that you contact the authors of the Document well
before redistributing any large number of copies, to give them a chance to provide you
with an updated version of the Document.
4. MODIFICATIONS
You may copy and distribute a Modified Version of the Document under the conditions
of sections 2 and 3 above, provided that you release the Modified Version under precisely
this License, with the Modified Version filling the role of the Document, thus licensing
distribution and modification of the Modified Version to whoever possesses a copy of
it. In addition, you must do these things in the Modified Version:
A. Use in the Title Page (and on the covers, if any) a title distinct from that of the
Document, and from those of previous versions (which should, if there were any,
318 The GNU Fortran Compiler
be listed in the History section of the Document). You may use the same title as
a previous version if the original publisher of that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities responsible for
authorship of the modifications in the Modified Version, together with at least five
of the principal authors of the Document (all of its principal authors, if it has fewer
than five), unless they release you from this requirement.
C. State on the Title page the name of the publisher of the Modified Version, as the
publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifications adjacent to the other
copyright notices.
F. Include, immediately after the copyright notices, a license notice giving the public
permission to use the Modified Version under the terms of this License, in the form
shown in the Addendum below.
G. Preserve in that license notice the full lists of Invariant Sections and required Cover
Texts given in the Document’s license notice.
H. Include an unaltered copy of this License.
I. Preserve the section Entitled “History”, Preserve its Title, and add to it an item
stating at least the title, year, new authors, and publisher of the Modified Version
as given on the Title Page. If there is no section Entitled “History” in the Docu-
ment, create one stating the title, year, authors, and publisher of the Document
as given on its Title Page, then add an item describing the Modified Version as
stated in the previous sentence.
J. Preserve the network location, if any, given in the Document for public access to
a Transparent copy of the Document, and likewise the network locations given in
the Document for previous versions it was based on. These may be placed in the
“History” section. You may omit a network location for a work that was published
at least four years before the Document itself, or if the original publisher of the
version it refers to gives permission.
K. For any section Entitled “Acknowledgements” or “Dedications”, Preserve the Title
of the section, and preserve in the section all the substance and tone of each of the
contributor acknowledgements and/or dedications given therein.
L. Preserve all the Invariant Sections of the Document, unaltered in their text and
in their titles. Section numbers or the equivalent are not considered part of the
section titles.
M. Delete any section Entitled “Endorsements”. Such a section may not be included
in the Modified Version.
N. Do not retitle any existing section to be Entitled “Endorsements” or to conflict in
title with any Invariant Section.
O. Preserve any Warranty Disclaimers.
If the Modified Version includes new front-matter sections or appendices that qualify
as Secondary Sections and contain no material copied from the Document, you may at
your option designate some or all of these sections as invariant. To do this, add their
GNU Free Documentation License 319
titles to the list of Invariant Sections in the Modified Version’s license notice. These
titles must be distinct from any other section titles.
You may add a section Entitled “Endorsements”, provided it contains nothing but
endorsements of your Modified Version by various parties—for example, statements of
peer review or that the text has been approved by an organization as the authoritative
definition of a standard.
You may add a passage of up to five words as a Front-Cover Text, and a passage of up
to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified
Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be
added by (or through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or by arrangement
made by the same entity you are acting on behalf of, you may not add another; but
you may replace the old one, on explicit permission from the previous publisher that
added the old one.
The author(s) and publisher(s) of the Document do not by this License give permission
to use their names for publicity for or to assert or imply endorsement of any Modified
Version.
5. COMBINING DOCUMENTS
You may combine the Document with other documents released under this License,
under the terms defined in section 4 above for modified versions, provided that you
include in the combination all of the Invariant Sections of all of the original documents,
unmodified, and list them all as Invariant Sections of your combined work in its license
notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and multiple identical
Invariant Sections may be replaced with a single copy. If there are multiple Invariant
Sections with the same name but different contents, make the title of each such section
unique by adding at the end of it, in parentheses, the name of the original author or
publisher of that section if known, or else a unique number. Make the same adjustment
to the section titles in the list of Invariant Sections in the license notice of the combined
work.
In the combination, you must combine any sections Entitled “History” in the vari-
ous original documents, forming one section Entitled “History”; likewise combine any
sections Entitled “Acknowledgements”, and any sections Entitled “Dedications”. You
must delete all sections Entitled “Endorsements.”
6. COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents released
under this License, and replace the individual copies of this License in the various
documents with a single copy that is included in the collection, provided that you
follow the rules of this License for verbatim copying of each of the documents in all
other respects.
You may extract a single document from such a collection, and distribute it individu-
ally under this License, provided you insert a copy of this License into the extracted
document, and follow this License in all other respects regarding verbatim copying of
that document.
320 The GNU Fortran Compiler
Option Index
gfortran’s command line options are indexed here without any initial ‘-’ or ‘--’. Where
an option has both positive and negative forms (such as -foption and -fno-option), relevant
entries in the manual are indexed under the most appropriate form; it may sometimes be
useful to look up both forms.
A fdec-math . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
A-predicate=answer . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 fdec-static . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
allow-invalid-boz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 fdec-structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Apredicate=answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 fdefault-double-8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
fdefault-integer-8 . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
fdefault-real-10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
B fdefault-real-16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
fdefault-real-8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
backslash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
fdollar-ok . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
fdump-fortran-global . . . . . . . . . . . . . . . . . . . . . . . . 22
C fdump-fortran-optimized . . . . . . . . . . . . . . . . . . . . . 22
fdump-fortran-original . . . . . . . . . . . . . . . . . . . . . . 22
c-prototypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
fdump-parse-tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
c-prototypes-external . . . . . . . . . . . . . . . . . . . . . . . 33
cpp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 fexternal-blas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 ff2c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
CC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 ffixed-form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
ffixed-line-length-n . . . . . . . . . . . . . . . . . . . . . . . . 11
ffpe-summary=list . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
D ffpe-trap=list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
dD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 ffree-form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
dI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 ffree-line-length-n. . . . . . . . . . . . . . . . . . . . . . . . . . 11
dM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 fimplicit-none . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Dname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 finit-character . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Dname=definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 finit-derived . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
dN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 finit-integer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
dU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 finit-local-zero . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
finit-logical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
finit-real . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
F finline-arg-packing. . . . . . . . . . . . . . . . . . . . . . . . . . 30
faggressive-function-elimination . . . . . . . . . . . 32 finline-matmul-limit . . . . . . . . . . . . . . . . . . . . . . . . 30
falign-commons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 finteger-4-integer-8 . . . . . . . . . . . . . . . . . . . . . . . . 12
fall-intrinsics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 fintrinsic-modules-path dir . . . . . . . . . . . . . . . . . 24
fallow-argument-mismatch . . . . . . . . . . . . . . . . . . . . . 9 fmax-array-constructor . . . . . . . . . . . . . . . . . . . . . . 28
fblas-matmul-limit . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 fmax-errors=n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
fbounds-check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 fmax-identifier-length=n . . . . . . . . . . . . . . . . . . . . 11
fcheck. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 fmax-stack-var-size. . . . . . . . . . . . . . . . . . . . . . . . . . 29
fcheck-array-temporaries . . . . . . . . . . . . . . . . . . . . 28 fmax-subrecord-length=length . . . . . . . . . . . . . . . 24
fcoarray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 fmodule-private . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
fconvert=conversion. . . . . . . . . . . . . . . . . . . . . . . . . . 24 fno-automatic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
fcray-pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 fno-backtrace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
fd-lines-as-code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 fno-protect-parens . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
fd-lines-as-comments. . . . . . . . . . . . . . . . . . . . . . . . . . 9 fno-underscoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
fdebug-aux-vars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 fopenacc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
fdec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 fopenmp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
fdec-blank-format-item . . . . . . . . . . . . . . . . . . . . . . 10 fpack-derived . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
fdec-char-conversions . . . . . . . . . . . . . . . . . . . . . . . . 9 fpad-source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
fdec-format-defaults . . . . . . . . . . . . . . . . . . . . . . . . 10 fpp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
fdec-include . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 frange-check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
fdec-intrinsic-ints. . . . . . . . . . . . . . . . . . . . . . . . . . 10 freal-4-real-10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
326 The GNU Fortran Compiler
freal-4-real-16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 S
freal-4-real-8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 static-libgfortran . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
freal-8-real-10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 static-libquadmath . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
freal-8-real-16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 std=std option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
freal-8-real-4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
frealloc-lhs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
frecord-marker=length . . . . . . . . . . . . . . . . . . . . . . . 24 T
frecursive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
tail-call-workaround . . . . . . . . . . . . . . . . . . . . . . . . 28
frepack-arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
frontend-loop-interchange . . . . . . . . . . . . . . . . . . . 32
frontend-optimize . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 U
fsecond-underscore . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
fshort-enums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Uname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
fsign-zero . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 undef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
fstack-arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
fsyntax-only . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 W
ftest-forall-temp . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
fworking-directory . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Waliasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Walign-commons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Wall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Wampersand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
H Warray-temporaries . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Wc-binding-type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Wcharacter-truncation . . . . . . . . . . . . . . . . . . . . . . . 18
Wcompare-reals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
I Wconversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Idir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Wconversion-extra . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
idirafter dir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Wdo-subscript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
imultilib dir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Werror. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
iprefix prefix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Wextra. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
iquote dir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Wfrontend-loop-interchange. . . . . . . . . . . . . . . . . . 19
isysroot dir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Wfunction-elimination . . . . . . . . . . . . . . . . . . . . . . . 20
isystem dir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Wimplicit-interface. . . . . . . . . . . . . . . . . . . . . . . . . . 19
Wimplicit-procedure. . . . . . . . . . . . . . . . . . . . . . . . . . 19
Winteger-division . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
J Wintrinsic-shadow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Jdir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Wintrinsics-std . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Wline-truncation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Woverwrite-recursive . . . . . . . . . . . . . . . . . . . . . . . . 19
M Wpedantic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Wreal-q-constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Mdir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Wrealloc-lhs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Wrealloc-lhs-all . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Wsurprising . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
N Wtabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
nostdinc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Wtargt-lifetime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Wundefined-do-loop . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Wunderflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
P Wunused-dummy-argument . . . . . . . . . . . . . . . . . . . . . . 20
pedantic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Wunused-parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
pedantic-errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Wuse-without-only . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
P . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Wzerotrip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
327
Keyword Index
$ ANINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
$ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 ANY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
area hyperbolic cosine . . . . . . . . . . . . . . . . . . . . . . . . 115
area hyperbolic sine . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
% area hyperbolic tangent . . . . . . . . . . . . . . . . . . . . . . . 129
argument list functions . . . . . . . . . . . . . . . . . . . . . . . . . 55
%LOC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
%REF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 arguments, to program . . . . . 157, 192, 193, 194, 204
%VAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 array descriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
array, add elements . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
array, AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
& array, apply condition . . . . . . . . . . . . . . . . . . . . 119, 122
array, bounds checking . . . . . . . . . . . . . . . . . . . . . . . . . 27
& . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
array, change dimensions . . . . . . . . . . . . . . . . . . . . . . 259
array, combine arrays . . . . . . . . . . . . . . . . . . . . . . . . . 236
array, condition testing . . . . . . . . . . . . . . . . . . . 119, 122
_gfortran_set_args . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 array, conditionally add elements . . . . . . . . . . . . . . 277
_gfortran_set_convert . . . . . . . . . . . . . . . . . . . . . . . 79 array, conditionally count elements . . . . . . . . . . . . 163
_gfortran_set_fpe . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 array, conditionally multiply elements . . . . . . . . . 252
_gfortran_set_max_subrecord_length . . . . . . . . 80 array, contiguity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
_gfortran_set_options . . . . . . . . . . . . . . . . . . . . . . . 77 array, count elements . . . . . . . . . . . . . . . . . . . . . . . . . 271
_gfortran_set_record_marker . . . . . . . . . . . . . . . . 79 array, duplicate dimensions . . . . . . . . . . . . . . . . . . . 273
array, duplicate elements . . . . . . . . . . . . . . . . . . . . . . 273
array, element counting . . . . . . . . . . . . . . . . . . . . . . . 163
A array, gather elements . . . . . . . . . . . . . . . . . . . . . . . . 248
array, increase dimension . . . . . . . . . . . . . . . . . 273, 289
ABORT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
array, indices of type real . . . . . . . . . . . . . . . . . . . . . . 50
absolute value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
array, location of maximum element . . . . . . . . . . . 234
ABS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
array, location of minimum element . . . . . . . . . . . 238
ACCESS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
ACHAR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 array, lower bound . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
ACOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 array, maximum value . . . . . . . . . . . . . . . . . . . . . . . . 235
ACOSD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 array, merge arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
ACOSH. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 array, minimum value . . . . . . . . . . . . . . . . . . . . . . . . . 239
adjust string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 array, multiply elements . . . . . . . . . . . . . . . . . . . . . . 252
ADJUSTL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 array, number of elements . . . . . . . . . . . . . . . . 163, 271
ADJUSTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 array, OR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
AIMAG. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 array, packing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
AINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 array, parity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
ALARM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 array, permutation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
ALGAMA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 array, product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
aliasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 array, reduce dimension . . . . . . . . . . . . . . . . . . . . . . . 248
alignment of COMMON blocks . . . . . . . . . . . . . . . . . 20, 31 array, rotate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
all warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 array, scatter elements . . . . . . . . . . . . . . . . . . . . . . . . 289
ALL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 array, shape . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
ALLOCATED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 array, shift . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
allocation, moving . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 array, shift circularly . . . . . . . . . . . . . . . . . . . . . . . . . . 164
allocation, status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 array, size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
ALOG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 array, sum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
ALOG10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 array, transmogrify . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
AMAX0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 array, transpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
AMAX1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 array, unpacking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
AMIN0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 array, upper bound . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
AMIN1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 array, XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
AMOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 ASCII collating sequence . . . . . . . . . . . . . . . . . 113, 201
AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 ASIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
328 The GNU Fortran Compiler
F
f2c calling convention . . . . . . . . . . . . . . . . . . . . . . 25, 26 G
Factorial function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 g77 calling convention . . . . . . . . . . . . . . . . . . . . . . 25, 26
FDATE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 Gamma function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
FDL, GNU Free Documentation License . . . . . . 315 Gamma function, logarithm of . . . . . . . . . . . . . . . . 227
FGET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 GAMMA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
FGETC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 GCC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
file format, fixed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9, 11 Generating C prototypes from
file format, free . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9, 11 external procedures . . . . . . . . . . . . . . . . . . . . . . . . . . 33
file operation, file number . . . . . . . . . . . . . . . . . . . . . 186 Generating C prototypes from Fortran
file operation, flush . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 BIND(C) enteties . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
file operation, position . . . . . . . . . . . . . . . . . . . 189, 191 GERROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
file operation, read character . . . . . . . . . . . . . 182, 183 GET_COMMAND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
file operation, seek . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 GET_COMMAND_ARGUMENT . . . . . . . . . . . . . . . . . . . . . . . 194
file operation, write character . . . . . . . . . . . . 186, 187 GET_ENVIRONMENT_VARIABLE . . . . . . . . . . . . . . . . . . . 196
file system, access mode . . . . . . . . . . . . . . . . . . . . . . . 112 GETARG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
file system, change access mode . . . . . . . . . . . . . . . 151 GETCWD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
file system, create link . . . . . . . . . . . . . . . . . . . 223, 278 GETENV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
file system, file creation mask . . . . . . . . . . . . . . . . . 288 GETGID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
file system, file status. . . . . . . . . . . . . . . . 190, 229, 275 GETLOG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
332 The GNU Fortran Compiler
module entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 P
module search path. . . . . . . . . . . . . . . . . . . . . . . . . 23, 24 PACK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
modulo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 PARAMETER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
MOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 Parity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
MODULO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 parity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
MOVE_ALLOC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 PARITY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
moving allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 paths, search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23, 24
multiply array elements . . . . . . . . . . . . . . . . . . . . . . . 252 PERROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
MVBITS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
pointer checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
pointer, C address of pointers . . . . . . . . . . . . . . . . . 146
pointer, C address of procedures . . . . . . . . . . . . . . 146
N pointer, C association status . . . . . . . . . . . . . . . . . . 144
Namelist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 pointer, convert C to Fortran . . . . . . . . . . . . . . . . . 145
NAME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 pointer, Cray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
natural logarithm function . . . . . . . . . . . . . . . . . . . . 226 pointer, cray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188, 230
NEAREST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 pointer, disassociated . . . . . . . . . . . . . . . . . . . . . . . . . 246
NEW_LINE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 pointer, status . . . . . . . . . . . . . . . . . . . . . . . . . . . 124, 246
newline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 pointers, C. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
NINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 POPCNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
norm, Euclidean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 POPPAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
NORM2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 positive difference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
NOSHARED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 PRECISION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
NOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 Preprocessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
NULL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 preprocessing, assertion . . . . . . . . . . . . . . . . . . . . . . . . 16
NUM_IMAGES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 preprocessing, define macros . . . . . . . . . . . . . . . . . . . 16
preprocessing, include path. . . . . . . . . . . . . . . . . . . . . 15
preprocessing, keep comments . . . . . . . . . . . . . . . . . . 16
preprocessing, no linemarkers . . . . . . . . . . . . . . . . . . 17
O preprocessing, undefine macros . . . . . . . . . . . . . . . . . 17
open, action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 preprocessor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
OpenACC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11, 55 preprocessor, debugging . . . . . . . . . . . . . . . . . . . . 14, 15
OpenMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11, 54 preprocessor, disable . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
operators, unary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 preprocessor, enable. . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
operators, xor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 preprocessor, include file handling . . . . . . . . . . . . . . 14
options inquiry function . . . . . . . . . . . . . . . . . . . . . . . 157 preprocessor, working directory . . . . . . . . . . . . . . . . 15
options, code generation . . . . . . . . . . . . . . . . . . . . . . . 25 PRESENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
options, debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 private . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
options, dialect. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 procedure interoperability with C . . . . . . . . . . . . . . 70
options, directory search . . . . . . . . . . . . . . . . . . . . . . . 23 procedure pointer, convert C to Fortran . . . . . . . 147
options, errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 process ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
options, Fortran dialect . . . . . . . . . . . . . . . . . . . . . . . . . 9 product, double-precision . . . . . . . . . . . . . . . . . . . . . 170
options, gfortran command . . . . . . . . . . . . . . . . . . . . . 7 product, matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
options, linking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 product, vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
options, negative forms . . . . . . . . . . . . . . . . . . . . . . . . . . 7 PRODUCT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
options, preprocessor . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 program termination . . . . . . . . . . . . . . . . . . . . . . . . . . 179
options, real kind type promotion . . . . . . . . . . . . . . 13 program termination, with core dump . . . . . . . . . 111
options, run-time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
options, runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
options, warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
Q
output, newline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 Q edit descriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
overflow handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Q exponent-letter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Keyword Index 335
W warnings, tabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
warnings, to errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
warning, C binding type . . . . . . . . . . . . . . . . . . . . . . . 18
warnings, undefined do loop . . . . . . . . . . . . . . . . . . . . 20
warnings, aliasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
warnings, underflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
warnings, alignment of COMMON blocks . . . . . . . . . . . 20
warnings, unused dummy argument . . . . . . . . . . . . 20
warnings, all . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
warnings, unused parameter . . . . . . . . . . . . . . . . . . . . 20
warnings, ampersand . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 warnings, use statements . . . . . . . . . . . . . . . . . . . . . . . 20
warnings, array temporaries . . . . . . . . . . . . . . . . . . . . 18 write character, stream mode . . . . . . . . . . . . . 186, 187
warnings, character truncation . . . . . . . . . . . . . . . . . 18
warnings, conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
warnings, division of integers . . . . . . . . . . . . . . . . . . . 19 X
warnings, extra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
warnings, function elimination. . . . . . . . . . . . . . . . . . 20 XOR reduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
warnings, implicit interface . . . . . . . . . . . . . . . . . . . . . 19
warnings, implicit procedure . . . . . . . . . . . . . . . . . . . 19
warnings, integer division . . . . . . . . . . . . . . . . . . . . . . 19 Z
warnings, intrinsic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 ZABS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
warnings, intrinsics of other standards . . . . . . . . . . 19 ZCOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
warnings, line truncation . . . . . . . . . . . . . . . . . . . . . . . 18 ZCOSD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
warnings, loop interchange . . . . . . . . . . . . . . . . . . . . . 19 zero bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220, 284
warnings, non-standard intrinsics . . . . . . . . . . . . . . . 19 ZEXP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
warnings, overwrite recursive . . . . . . . . . . . . . . . . . . . 19 ZLOG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
warnings, q exponent-letter . . . . . . . . . . . . . . . . . . . . 19 ZSIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
warnings, suppressing . . . . . . . . . . . . . . . . . . . . . . . . . . 17 ZSIND. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
warnings, suspicious code . . . . . . . . . . . . . . . . . . . . . . 19 ZSQRT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274