diff options
author | Martin Liska <mliska@suse.cz> | 2022-11-07 13:23:41 +0100 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2022-11-09 09:00:35 +0100 |
commit | 54ca4eef58661a7d7a511e2bbbe309bde1732abf (patch) | |
tree | 4f9067b036a4e7c08d0d483246cb5ab5a0d60d41 /gcc/fortran | |
parent | 564a805f9f08b4346a854ab8dca2e5b561a7a28e (diff) | |
download | gcc-54ca4eef58661a7d7a511e2bbbe309bde1732abf.zip gcc-54ca4eef58661a7d7a511e2bbbe309bde1732abf.tar.gz gcc-54ca4eef58661a7d7a511e2bbbe309bde1732abf.tar.bz2 |
sphinx: remove texinfo files
gcc/d/ChangeLog:
* gdc.texi: Removed.
gcc/ChangeLog:
* doc/analyzer.texi: Removed.
* doc/avr-mmcu.texi: Removed.
* doc/bugreport.texi: Removed.
* doc/cfg.texi: Removed.
* doc/collect2.texi: Removed.
* doc/compat.texi: Removed.
* doc/configfiles.texi: Removed.
* doc/configterms.texi: Removed.
* doc/contrib.texi: Removed.
* doc/contribute.texi: Removed.
* doc/cpp.texi: Removed.
* doc/cppdiropts.texi: Removed.
* doc/cppenv.texi: Removed.
* doc/cppinternals.texi: Removed.
* doc/cppopts.texi: Removed.
* doc/cppwarnopts.texi: Removed.
* doc/extend.texi: Removed.
* doc/fragments.texi: Removed.
* doc/frontends.texi: Removed.
* doc/gcc.texi: Removed.
* doc/gccint.texi: Removed.
* doc/gcov-dump.texi: Removed.
* doc/gcov-tool.texi: Removed.
* doc/gcov.texi: Removed.
* doc/generic.texi: Removed.
* doc/gimple.texi: Removed.
* doc/gnu.texi: Removed.
* doc/gty.texi: Removed.
* doc/headerdirs.texi: Removed.
* doc/hostconfig.texi: Removed.
* doc/implement-c.texi: Removed.
* doc/implement-cxx.texi: Removed.
* doc/include/fdl.texi: Removed.
* doc/include/funding.texi: Removed.
* doc/include/gcc-common.texi: Removed.
* doc/include/gpl_v3.texi: Removed.
* doc/install.texi: Removed.
* doc/interface.texi: Removed.
* doc/invoke.texi: Removed.
* doc/languages.texi: Removed.
* doc/libgcc.texi: Removed.
* doc/loop.texi: Removed.
* doc/lto-dump.texi: Removed.
* doc/lto.texi: Removed.
* doc/makefile.texi: Removed.
* doc/match-and-simplify.texi: Removed.
* doc/md.texi: Removed.
* doc/objc.texi: Removed.
* doc/optinfo.texi: Removed.
* doc/options.texi: Removed.
* doc/passes.texi: Removed.
* doc/plugins.texi: Removed.
* doc/poly-int.texi: Removed.
* doc/portability.texi: Removed.
* doc/rtl.texi: Removed.
* doc/service.texi: Removed.
* doc/sourcebuild.texi: Removed.
* doc/standards.texi: Removed.
* doc/tm.texi: Removed.
* doc/tree-ssa.texi: Removed.
* doc/trouble.texi: Removed.
* doc/ux.texi: Removed.
* doc/tm.texi.in: Removed.
gcc/fortran/ChangeLog:
* gfc-internals.texi: Removed.
* gfortran.texi: Removed.
* intrinsic.texi: Removed.
* invoke.texi: Removed.
gcc/go/ChangeLog:
* gccgo.texi: Removed.
libgomp/ChangeLog:
* libgomp.texi: Removed.
libiberty/ChangeLog:
* at-file.texi: Removed.
* copying-lib.texi: Removed.
* functions.texi: Removed.
* libiberty.texi: Removed.
* obstacks.texi: Removed.
libitm/ChangeLog:
* libitm.texi: Removed.
libquadmath/ChangeLog:
* libquadmath.texi: Removed.
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/gfc-internals.texi | 968 | ||||
-rw-r--r-- | gcc/fortran/gfortran.texi | 5573 | ||||
-rw-r--r-- | gcc/fortran/intrinsic.texi | 15435 | ||||
-rw-r--r-- | gcc/fortran/invoke.texi | 2133 |
4 files changed, 0 insertions, 24109 deletions
diff --git a/gcc/fortran/gfc-internals.texi b/gcc/fortran/gfc-internals.texi deleted file mode 100644 index 1409e28..0000000 --- a/gcc/fortran/gfc-internals.texi +++ /dev/null @@ -1,968 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@c %**start of header -@setfilename gfc-internals.info -@set copyrights-gfortran 2007-2022 - -@include gcc-common.texi - -@synindex tp cp - -@settitle GNU Fortran Compiler Internals - -@c %**end of header - -@c Use with @@smallbook. - -@c %** start of document - -@c Cause even numbered pages to be printed on the left hand side of -@c the page and odd numbered pages to be printed on the right hand -@c side of the page. Using this, you can print on both sides of a -@c sheet of paper and have the text on the same part of the sheet. - -@c The text on right hand pages is pushed towards the right hand -@c margin and the text on left hand pages is pushed toward the left -@c hand margin. -@c (To provide the reverse effect, set bindingoffset to -0.75in.) - -@c @tex -@c \global\bindingoffset=0.75in -@c \global\normaloffset =0.75in -@c @end tex - -@copying -Copyright @copyright{} @value{copyrights-gfortran} Free Software Foundation, Inc. - -Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.3 or -any later version published by the Free Software Foundation; with the -Invariant Sections being ``Funding Free Software'', the Front-Cover -Texts being (a) (see below), and with the Back-Cover Texts being (b) -(see below). A copy of the license is included in the section entitled -``GNU Free Documentation License''. - -(a) The FSF's Front-Cover Text is: - - A GNU Manual - -(b) The FSF's Back-Cover Text is: - - You have freedom to copy and modify this GNU Manual, like GNU - software. Copies published by the Free Software Foundation raise - funds for GNU development. -@end copying - -@ifinfo -@dircategory Software development -@direntry -* gfortran: (gfortran). The GNU Fortran Compiler. -@end direntry -This file documents the internals of the GNU Fortran -compiler, (@command{gfortran}). - -Published by the Free Software Foundation -51 Franklin Street, Fifth Floor -Boston, MA 02110-1301 USA - -@insertcopying -@end ifinfo - - -@setchapternewpage odd -@titlepage -@title GNU Fortran Internals -@versionsubtitle -@author The @t{gfortran} team -@page -@vskip 0pt plus 1filll -Published by the Free Software Foundation@* -51 Franklin Street, Fifth Floor@* -Boston, MA 02110-1301, USA@* -@c Last printed ??ber, 19??.@* -@c Printed copies are available for $? each.@* -@c ISBN ??? -@sp 1 -@insertcopying -@end titlepage - -@summarycontents -@contents - -@page - -@c --------------------------------------------------------------------- -@c TexInfo table of contents. -@c --------------------------------------------------------------------- - -@ifnottex -@node Top -@top Introduction -@cindex Introduction - -This manual documents the internals of @command{gfortran}, -the GNU Fortran compiler. - -@ifset DEVELOPMENT -@emph{Warning:} This document, and the compiler it describes, are still -under development. While efforts are made to keep it up-to-date, it might -not accurately reflect the status of the most recent GNU Fortran compiler. -@end ifset - -@comment -@comment When you add a new menu item, please keep the right hand -@comment aligned to the same column. Do not use tabs. This provides -@comment better formatting. -@comment -@menu -* Introduction:: About this manual. -* User Interface:: Code that Interacts with the User. -* Frontend Data Structures:: - Data structures used by the frontend -* Object Orientation:: Internals of Fortran 2003 OOP features. -* Translating to GENERIC:: - Generating the intermediate language for later stages. -* LibGFortran:: The LibGFortran Runtime Library. -* GNU Free Documentation License:: - How you can copy and share this manual. -* Index:: Index of this documentation. -@end menu -@end ifnottex - -@c --------------------------------------------------------------------- -@c Introduction -@c --------------------------------------------------------------------- - -@node Introduction -@chapter Introduction - -@c The following duplicates the text on the TexInfo table of contents. -@iftex -This manual documents the internals of @command{gfortran}, the GNU Fortran -compiler. - -@ifset DEVELOPMENT -@emph{Warning:} This document, and the compiler it describes, are still -under development. While efforts are made to keep it up-to-date, it -might not accurately reflect the status of the most recent GNU Fortran -compiler. -@end ifset -@end iftex - -At present, this manual is very much a work in progress, containing -miscellaneous notes about the internals of the compiler. It is hoped -that at some point in the future it will become a reasonably complete -guide; in the interim, GNU Fortran developers are strongly encouraged to -contribute to it as a way of keeping notes while working on the -compiler. - - -@c --------------------------------------------------------------------- -@c Code that Interacts with the User -@c --------------------------------------------------------------------- - -@node User Interface -@chapter Code that Interacts with the User - -@menu -* Command-Line Options:: Command-Line Options. -* Error Handling:: Error Handling. -@end menu - - -@c --------------------------------------------------------------------- -@c Command-Line Options -@c --------------------------------------------------------------------- - -@node Command-Line Options -@section Command-Line Options - -Command-line options for @command{gfortran} involve four interrelated -pieces within the Fortran compiler code. - -The relevant command-line flag is defined in @file{lang.opt}, according -to the documentation in @ref{Options,, Options, gccint, GNU Compiler -Collection Internals}. This is then processed by the overall GCC -machinery to create the code that enables @command{gfortran} and -@command{gcc} to recognize the option in the command-line arguments and -call the relevant handler function. - -This generated code calls the @code{gfc_handle_option} code in -@file{options.cc} with an enumerator variable indicating which option is -to be processed, and the relevant integer or string values associated -with that option flag. Typically, @code{gfc_handle_option} uses these -arguments to set global flags which record the option states. - -The global flags that record the option states are stored in the -@code{gfc_option_t} struct, which is defined in @file{gfortran.h}. -Before the options are processed, initial values for these flags are set -in @code{gfc_init_option} in @file{options.cc}; these become the default -values for the options. - - - -@c --------------------------------------------------------------------- -@c Error Handling -@c --------------------------------------------------------------------- - -@node Error Handling -@section Error Handling - -The GNU Fortran compiler's parser operates by testing each piece of -source code against a variety of matchers. In some cases, if these -matchers do not match the source code, they will store an error message -in a buffer. If the parser later finds a matcher that does correctly -match the source code, then the buffered error is discarded. However, -if the parser cannot find a match, then the buffered error message is -reported to the user. This enables the compiler to provide more -meaningful error messages even in the many cases where (erroneous) -Fortran syntax is ambiguous due to things like the absence of reserved -keywords. - -As an example of how this works, consider the following line: -@smallexample -IF = 3 -@end smallexample -Hypothetically, this may get passed to the matcher for an @code{IF} -statement. Since this could plausibly be an erroneous @code{IF} -statement, the matcher will buffer an error message reporting the -absence of an expected @samp{(} following an @code{IF}. Since no -matchers reported an error-free match, however, the parser will also try -matching this against a variable assignment. When @code{IF} is a valid -variable, this will be parsed as an assignment statement, and the error -discarded. However, when @code{IF} is not a valid variable, this -buffered error message will be reported to the user. - -The error handling code is implemented in @file{error.cc}. Errors are -normally entered into the buffer with the @code{gfc_error} function. -Warnings go through a similar buffering process, and are entered into -the buffer with @code{gfc_warning}. There is also a special-purpose -function, @code{gfc_notify_std}, for things which have an error/warning -status that depends on the currently-selected language standard. - -The @code{gfc_error_check} function checks the buffer for errors, -reports the error message to the user if one exists, clears the buffer, -and returns a flag to the user indicating whether or not an error -existed. To check the state of the buffer without changing its state or -reporting the errors, the @code{gfc_error_flag_test} function can be -used. The @code{gfc_clear_error} function will clear out any errors in -the buffer, without reporting them. The @code{gfc_warning_check} and -@code{gfc_clear_warning} functions provide equivalent functionality for -the warning buffer. - -Only one error and one warning can be in the buffers at a time, and -buffering another will overwrite the existing one. In cases where one -may wish to work on a smaller piece of source code without disturbing an -existing error state, the @code{gfc_push_error}, @code{gfc_pop_error}, -and @code{gfc_free_error} mechanism exists to implement a stack for the -error buffer. - -For cases where an error or warning should be reported immediately -rather than buffered, the @code{gfc_error_now} and -@code{gfc_warning_now} functions can be used. Normally, the compiler -will continue attempting to parse the program after an error has -occurred, but if this is not appropriate, the @code{gfc_fatal_error} -function should be used instead. For errors that are always the result -of a bug somewhere in the compiler, the @code{gfc_internal_error} -function should be used. - -The syntax for the strings used to produce the error/warning message in -the various error and warning functions is similar to the @code{printf} -syntax, with @samp{%}-escapes to insert variable values. The details, -and the allowable codes, are documented in the @code{error_print} -function in @file{error.cc}. - -@c --------------------------------------------------------------------- -@c Frontend Data Structures -@c --------------------------------------------------------------------- - -@node Frontend Data Structures -@chapter Frontend Data Structures -@cindex data structures - -This chapter should describe the details necessary to understand how -the various @code{gfc_*} data are used and interact. In general it is -advisable to read the code in @file{dump-parse-tree.cc} as its routines -should exhaust all possible valid combinations of content for these -structures. - -@menu -* gfc_code:: Representation of Executable Statements. -* gfc_expr:: Representation of Values and Expressions. -@end menu - - -@c gfc_code -@c -------- - -@node gfc_code -@section @code{gfc_code} -@cindex statement chaining -@tindex @code{gfc_code} -@tindex @code{struct gfc_code} - -The executable statements in a program unit are represented by a -nested chain of @code{gfc_code} structures. The type of statement is -identified by the @code{op} member of the structure, the different -possible values are enumerated in @code{gfc_exec_op}. A special -member of this @code{enum} is @code{EXEC_NOP} which is used to -represent the various @code{END} statements if they carry a label. -Depending on the type of statement some of the other fields will be -filled in. Fields that are generally applicable are the @code{next} -and @code{here} fields. The former points to the next statement in -the current block or is @code{NULL} if the current statement is the -last in a block, @code{here} points to the statement label of the -current statement. - -If the current statement is one of @code{IF}, @code{DO}, @code{SELECT} -it starts a block, i.e.@: a nested level in the program. In order to -represent this, the @code{block} member is set to point to a -@code{gfc_code} structure whose @code{next} member starts the chain of -statements inside the block; this structure's @code{op} member should be set to -the same value as the parent structure's @code{op} member. The @code{SELECT} -and @code{IF} statements may contain various blocks (the chain of @code{ELSE IF} -and @code{ELSE} blocks or the various @code{CASE}s, respectively). These chains -are linked-lists formed by the @code{block} members. - -Consider the following example code: - -@example -IF (foo < 20) THEN - PRINT *, "Too small" - foo = 20 -ELSEIF (foo > 50) THEN - PRINT *, "Too large" - foo = 50 -ELSE - PRINT *, "Good" -END IF -@end example - -This statement-block will be represented in the internal gfortran tree as -follows, were the horizontal link-chains are those induced by the @code{next} -members and vertical links down are those of @code{block}. @samp{==|} and -@samp{--|} mean @code{NULL} pointers to mark the end of a chain: - -@example -... ==> IF ==> ... - | - +--> IF foo < 20 ==> PRINT *, "Too small" ==> foo = 20 ==| - | - +--> IF foo > 50 ==> PRINT *, "Too large" ==> foo = 50 ==| - | - +--> ELSE ==> PRINT *, "Good" ==| - | - +--| -@end example - - -@subsection IF Blocks - -Conditionals are represented by @code{gfc_code} structures with their -@code{op} member set to @code{EXEC_IF}. This structure's @code{block} -member must point to another @code{gfc_code} node that is the header of the -if-block. This header's @code{op} member must be set to @code{EXEC_IF}, too, -its @code{expr} member holds the condition to check for, and its @code{next} -should point to the code-chain of the statements to execute if the condition is -true. - -If in addition an @code{ELSEIF} or @code{ELSE} block is present, the -@code{block} member of the if-block-header node points to yet another -@code{gfc_code} structure that is the header of the elseif- or else-block. Its -structure is identical to that of the if-block-header, except that in case of an -@code{ELSE} block without a new condition the @code{expr} member should be -@code{NULL}. This block can itself have its @code{block} member point to the -next @code{ELSEIF} or @code{ELSE} block if there's a chain of them. - - -@subsection Loops - -@code{DO} loops are stored in the tree as @code{gfc_code} nodes with their -@code{op} set to @code{EXEC_DO} for a @code{DO} loop with iterator variable and -to @code{EXEC_DO_WHILE} for infinite @code{DO}s and @code{DO WHILE} blocks. -Their @code{block} member should point to a @code{gfc_code} structure heading -the code-chain of the loop body; its @code{op} member should be set to -@code{EXEC_DO} or @code{EXEC_DO_WHILE}, too, respectively. - -For @code{DO WHILE} loops, the loop condition is stored on the top -@code{gfc_code} structure's @code{expr} member; @code{DO} forever loops are -simply @code{DO WHILE} loops with a constant @code{.TRUE.} loop condition in -the internal representation. - -Similarly, @code{DO} loops with an iterator have instead of the condition their -@code{ext.iterator} member set to the correct values for the loop iterator -variable and its range. - - -@subsection @code{SELECT} Statements - -A @code{SELECT} block is introduced by a @code{gfc_code} structure with an -@code{op} member of @code{EXEC_SELECT} and @code{expr} containing the expression -to evaluate and test. Its @code{block} member starts a list of @code{gfc_code} -structures linked together by their @code{block} members that stores the various -@code{CASE} parts. - -Each @code{CASE} node has its @code{op} member set to @code{EXEC_SELECT}, too, -its @code{next} member points to the code-chain to be executed in the current -case-block, and @code{extx.case_list} contains the case-values this block -corresponds to. The @code{block} member links to the next case in the list. - - -@subsection @code{BLOCK} and @code{ASSOCIATE} - -The code related to a @code{BLOCK} statement is stored inside an -@code{gfc_code} structure (say @var{c}) -with @code{c.op} set to @code{EXEC_BLOCK}. The -@code{gfc_namespace} holding the locally defined variables of the -@code{BLOCK} is stored in @code{c.ext.block.ns}. The code inside the -construct is in @code{c.code}. - -@code{ASSOCIATE} constructs are based on @code{BLOCK} and thus also have -the internal storage structure described above (including @code{EXEC_BLOCK}). -However, for them @code{c.ext.block.assoc} is set additionally and points -to a linked list of @code{gfc_association_list} structures. Those -structures basically store a link of associate-names to target expressions. -The associate-names themselves are still also added to the @code{BLOCK}'s -namespace as ordinary symbols, but they have their @code{gfc_symbol}'s -member @code{assoc} set also pointing to the association-list structure. -This way associate-names can be distinguished from ordinary variables -and their target expressions identified. - -For association to expressions (as opposed to variables), at the very beginning -of the @code{BLOCK} construct assignments are automatically generated to -set the corresponding variables to their target expressions' values, and -later on the compiler simply disallows using such associate-names in contexts -that may change the value. - - -@c gfc_expr -@c -------- - -@node gfc_expr -@section @code{gfc_expr} -@tindex @code{gfc_expr} -@tindex @code{struct gfc_expr} - -Expressions and ``values'', including constants, variable-, array- and -component-references as well as complex expressions consisting of operators and -function calls are internally represented as one or a whole tree of -@code{gfc_expr} objects. The member @code{expr_type} specifies the overall -type of an expression (for instance, @code{EXPR_CONSTANT} for constants or -@code{EXPR_VARIABLE} for variable references). The members @code{ts} and -@code{rank} as well as @code{shape}, which can be @code{NULL}, specify -the type, rank and, if applicable, shape of the whole expression or expression -tree of which the current structure is the root. @code{where} is the locus of -this expression in the source code. - -Depending on the flavor of the expression being described by the object -(that is, the value of its @code{expr_type} member), the corresponding structure -in the @code{value} union will usually contain additional data describing the -expression's value in a type-specific manner. The @code{ref} member is used to -build chains of (array-, component- and substring-) references if the expression -in question contains such references, see below for details. - - -@subsection Constants - -Scalar constants are represented by @code{gfc_expr} nodes with their -@code{expr_type} set to @code{EXPR_CONSTANT}. The constant's value shall -already be known at compile-time and is stored in the @code{logical}, -@code{integer}, @code{real}, @code{complex} or @code{character} struct inside -@code{value}, depending on the constant's type specification. - - -@subsection Operators - -Operator-expressions are expressions that are the result of the execution of -some operator on one or two operands. The expressions have an @code{expr_type} -of @code{EXPR_OP}. Their @code{value.op} structure contains additional data. - -@code{op1} and optionally @code{op2} if the operator is binary point to the -two operands, and @code{operator} or @code{uop} describe the operator that -should be evaluated on these operands, where @code{uop} describes a user-defined -operator. - - -@subsection Function Calls - -If the expression is the return value of a function-call, its @code{expr_type} -is set to @code{EXPR_FUNCTION}, and @code{symtree} must point to the symtree -identifying the function to be called. @code{value.function.actual} holds the -actual arguments given to the function as a linked list of -@code{gfc_actual_arglist} nodes. - -The other members of @code{value.function} describe the function being called -in more detail, containing a link to the intrinsic symbol or user-defined -function symbol if the call is to an intrinsic or external function, -respectively. These values are determined during resolution-phase from the -structure's @code{symtree} member. - -A special case of function calls are ``component calls'' to type-bound -procedures; those have the @code{expr_type} @code{EXPR_COMPCALL} with -@code{value.compcall} containing the argument list and the procedure called, -while @code{symtree} and @code{ref} describe the object on which the procedure -was called in the same way as a @code{EXPR_VARIABLE} expression would. -@xref{Type-bound Procedures}. - - -@subsection Array- and Structure-Constructors - -Array- and structure-constructors (one could probably call them ``array-'' and -``derived-type constants'') are @code{gfc_expr} structures with their -@code{expr_type} member set to @code{EXPR_ARRAY} or @code{EXPR_STRUCTURE}, -respectively. For structure constructors, @code{symtree} points to the -derived-type symbol for the type being constructed. - -The values for initializing each array element or structure component are -stored as linked-list of @code{gfc_constructor} nodes in the -@code{value.constructor} member. - - -@subsection Null - -@code{NULL} is a special value for pointers; it can be of different base types. -Such a @code{NULL} value is represented in the internal tree by a -@code{gfc_expr} node with @code{expr_type} @code{EXPR_NULL}. If the base type -of the @code{NULL} expression is known, it is stored in @code{ts} (that's for -instance the case for default-initializers of @code{ALLOCATABLE} components), -but this member can also be set to @code{BT_UNKNOWN} if the information is not -available (for instance, when the expression is a pointer-initializer -@code{NULL()}). - - -@subsection Variables and Reference Expressions - -Variable references are @code{gfc_expr} structures with their @code{expr_type} -set to @code{EXPR_VARIABLE}; their @code{symtree} should point to the variable -that is referenced. - -For this type of expression, it's also possible to chain array-, component- -or substring-references to the original expression to get something like -@samp{struct%component(2:5)}, where @code{component} is either an array or -a @code{CHARACTER} member of @code{struct} that is of some derived-type. Such a -chain of references is achieved by a linked list headed by @code{ref} of the -@code{gfc_expr} node. For the example above it would be (@samp{==|} is the -last @code{NULL} pointer): - -@smallexample -EXPR_VARIABLE(struct) ==> REF_COMPONENT(component) ==> REF_ARRAY(2:5) ==| -@end smallexample - -If @code{component} is a string rather than an array, the last element would be -a @code{REF_SUBSTRING} reference, of course. If the variable itself or some -component referenced is an array and the expression should reference the whole -array rather than being followed by an array-element or -section reference, a -@code{REF_ARRAY} reference must be built as the last element in the chain with -an array-reference type of @code{AR_FULL}. Consider this example code: - -@smallexample -TYPE :: mytype - INTEGER :: array(42) -END TYPE mytype - -TYPE(mytype) :: variable -INTEGER :: local_array(5) - -CALL do_something (variable%array, local_array) -@end smallexample - -The @code{gfc_expr} nodes representing the arguments to the @samp{do_something} -call will have a reference-chain like this: - -@smallexample -EXPR_VARIABLE(variable) ==> REF_COMPONENT(array) ==> REF_ARRAY(FULL) ==| -EXPR_VARIABLE(local_array) ==> REF_ARRAY(FULL) ==| -@end smallexample - - -@subsection Constant Substring References - -@code{EXPR_SUBSTRING} is a special type of expression that encodes a substring -reference of a constant string, as in the following code snippet: - -@smallexample -x = "abcde"(1:2) -@end smallexample - -In this case, @code{value.character} contains the full string's data as if it -was a string constant, but the @code{ref} member is also set and points to a -substring reference as described in the subsection above. - - -@c --------------------------------------------------------------------- -@c F2003 OOP -@c --------------------------------------------------------------------- - -@node Object Orientation -@chapter Internals of Fortran 2003 OOP Features - -@menu -* Type-bound Procedures:: Type-bound procedures. -* Type-bound Operators:: Type-bound operators. -@end menu - - -@c Type-bound procedures -@c --------------------- - -@node Type-bound Procedures -@section Type-bound Procedures - -Type-bound procedures are stored in the @code{tb_sym_root} of the namespace -@code{f2k_derived} associated with the derived-type symbol as @code{gfc_symtree} -nodes. The name and symbol of these symtrees corresponds to the binding-name -of the procedure, i.e. the name that is used to call it from the context of an -object of the derived-type. - -In addition, this type of symtrees stores in @code{n.tb} a struct of type -@code{gfc_typebound_proc} containing the additional data needed: The -binding attributes (like @code{PASS} and @code{NOPASS}, @code{NON_OVERRIDABLE} -or the access-specifier), the binding's target(s) and, if the current binding -overrides or extends an inherited binding of the same name, @code{overridden} -points to this binding's @code{gfc_typebound_proc} structure. - - -@subsection Specific Bindings -@c -------------------------- - -For specific bindings (declared with @code{PROCEDURE}), if they have a -passed-object argument, the passed-object dummy argument is first saved by its -name, and later during resolution phase the corresponding argument is looked for -and its position remembered as @code{pass_arg_num} in @code{gfc_typebound_proc}. -The binding's target procedure is pointed-to by @code{u.specific}. - -@code{DEFERRED} bindings are just like ordinary specific bindings, except -that their @code{deferred} flag is set of course and that @code{u.specific} -points to their ``interface'' defining symbol (might be an abstract interface) -instead of the target procedure. - -At the moment, all type-bound procedure calls are statically dispatched and -transformed into ordinary procedure calls at resolution time; their actual -argument list is updated to include at the right position the passed-object -argument, if applicable, and then a simple procedure call to the binding's -target procedure is built. To handle dynamic dispatch in the future, this will -be extended to allow special code generation during the trans-phase to dispatch -based on the object's dynamic type. - - -@subsection Generic Bindings -@c ------------------------- - -Bindings declared as @code{GENERIC} store the specific bindings they target as -a linked list using nodes of type @code{gfc_tbp_generic} in @code{u.generic}. -For each specific target, the parser records its symtree and during resolution -this symtree is bound to the corresponding @code{gfc_typebound_proc} structure -of the specific target. - -Calls to generic bindings are handled entirely in the resolution-phase, where -for the actual argument list present the matching specific binding is found -and the call's target procedure (@code{value.compcall.tbp}) is re-pointed to -the found specific binding and this call is subsequently handled by the logic -for specific binding calls. - - -@subsection Calls to Type-bound Procedures -@c --------------------------------------- - -Calls to type-bound procedures are stored in the parse-tree as @code{gfc_expr} -nodes of type @code{EXPR_COMPCALL}. Their @code{value.compcall.actual} saves -the actual argument list of the call and @code{value.compcall.tbp} points to the -@code{gfc_typebound_proc} structure of the binding to be called. The object -in whose context the procedure was called is saved by combination of -@code{symtree} and @code{ref}, as if the expression was of type -@code{EXPR_VARIABLE}. - -For code like this: -@smallexample -CALL myobj%procedure (arg1, arg2) -@end smallexample -@noindent -the @code{CALL} is represented in the parse-tree as a @code{gfc_code} node of -type @code{EXEC_COMPCALL}. The @code{expr} member of this node holds an -expression of type @code{EXPR_COMPCALL} of the same structure as mentioned above -except that its target procedure is of course a @code{SUBROUTINE} and not a -@code{FUNCTION}. - -Expressions that are generated internally (as expansion of a type-bound -operator call) may also use additional flags and members. -@code{value.compcall.ignore_pass} signals that even though a @code{PASS} -attribute may be present the actual argument list should not be updated because -it already contains the passed-object. -@code{value.compcall.base_object} overrides, if it is set, the base-object -(that is normally stored in @code{symtree} and @code{ref} as mentioned above); -this is needed because type-bound operators can be called on a base-object that -need not be of type @code{EXPR_VARIABLE} and thus representable in this way. -Finally, if @code{value.compcall.assign} is set, the call was produced in -expansion of a type-bound assignment; this means that proper dependency-checking -needs to be done when relevant. - - -@c Type-bound operators -@c -------------------- - -@node Type-bound Operators -@section Type-bound Operators - -Type-bound operators are in fact basically just @code{GENERIC} procedure -bindings and are represented much in the same way as those (see -@ref{Type-bound Procedures}). - -They come in two flavours: -User-defined operators (like @code{.MYOPERATOR.}) -are stored in the @code{f2k_derived} namespace's @code{tb_uop_root} -symtree exactly like ordinary type-bound procedures are stored in -@code{tb_sym_root}; their symtrees' names are the operator-names (e.g. -@samp{myoperator} in the example). -Intrinsic operators on the other hand are stored in the namespace's -array member @code{tb_op} indexed by the intrinsic operator's enum -value. Those need not be packed into @code{gfc_symtree} structures and are -only @code{gfc_typebound_proc} instances. - -When an operator call or assignment is found that cannot be handled in -another way (i.e. neither matches an intrinsic nor interface operator -definition) but that contains a derived-type expression, all type-bound -operators defined on that derived-type are checked for a match with -the operator call. If there's indeed a relevant definition, the -operator call is replaced with an internally generated @code{GENERIC} -type-bound procedure call to the respective definition and that call is -further processed. - -@c --------------------------------------------------------------------- -@c - Translating to GENERIC -@c --------------------------------------------------------------------- - -@node Translating to GENERIC -@chapter Generating the intermediate language for later stages. - -This chapter deals with the transformation of gfortran's frontend data -structures to the intermediate language used by the later stages of -the compiler, the so-called middle end. - -Data structures relating to this are found in the source files -@file{trans*.h} and @file{trans-*.c}. - -@menu -* Basic Data Structures:: Basic data structures. -* Converting Expressions:: Converting expressions to tree. -* Translating Statements:: Translating statements. -* Accessing Declarations:: Accessing declarations. -@end menu - -@node Basic Data Structures -@section Basic data structures - -Gfortran creates GENERIC as an intermediate language for the -middle-end. Details about GENERIC can be found in the GCC manual. - -The basic data structure of GENERIC is a @code{tree}. Everything in -GENERIC is a @code{tree}, including types and statements. Fortunately -for the gfortran programmer, @code{tree} variables are -garbage-collected, so doing memory management for them is not -necessary. - -@code{tree} expressions are built using functions such as, for -example, @code{fold_build2_loc}. For two tree variables @code{a} and -@code{b}, both of which have the type @code{gfc_arry_index_type}, -calculation @code{c = a * b} would be done by - -@smallexample -c = fold_build2_loc (input_location, MULT_EXPR, - gfc_array_index_type, a, b); -@end smallexample - -The types have to agree, otherwise internal compiler errors will occur -at a later stage. Expressions can be converted to a different type -using @code{fold_convert}. - -Accessing individual members in the @code{tree} structures should not -be done. Rather, access should be done via macros. - -One basic data structure is the @code{stmtblock_t} struct. This is -used for holding a list of statements, expressed as @code{tree} -expressions. If a block is created using @code{gfc_start_block}, it -has its own scope for variables; if it is created using -@code{gfc_init_block}, it does not have its own scope. - -It is possible to -@itemize @bullet -@item Add an expression to the end of a block using - @code{gfc_add_expr_to_block} -@item Add an expression to the beginning of a block using - @code{void gfc_prepend_expr_to_block} -@item Make a block into a single @code{tree} using - @code{gfc_finish_block}. For example, this is needed to put the - contents of a block into the @code{if} or @code{else} branch of - a @code{COND_EXPR}. -@end itemize - -Variables are also @code{tree} expressions, they can be created using -@code{gfc_create_var}. Assigning to a variable can be done with -@code{gfc_add_modify}. - -An example: Creating a default integer type variable in the current -scope with the prefix ``everything'' in the @code{stmt_block} -@code{block} and assigning the value 42 would be - -@smallexample -tree var, *block; -/* Initialize block somewhere here. */ -var = gfc_create_var (integer_type_node, "everything"); -gfc_add_modify (block, var, build_int_cst (integer_type_node, 42)); -@end smallexample - -@node Converting Expressions -@section Converting Expressions to tree - -Converting expressions to @code{tree} is done by functions called -@code{gfc_conv_*}. - -The central data structure for a GENERIC expression is the -@code{gfc_se} structure. Its @code{expr} member is a @code{tree} that -holds the value of the expression. A @code{gfc_se} structure is -initialized using @code{gfc_init_se}; it needs to be embedded in an -outer @code{gfc_se}. - -Evaluating Fortran expressions often require things to be done before -and after evaluation of the expression, for example code for the -allocation of a temporary variable and its subsequent deallocation. -Therefore, @code{gfc_se} contains the members @code{pre} and -@code{post}, which point to @code{stmt_block} blocks for code that -needs to be executed before and after evaluation of the expression. - -When using a local @code{gfc_se} to convert some expression, it is -often necessary to add the generated @code{pre} and @code{post} blocks -to the @code{pre} or @code{post} blocks of the outer @code{gfc_se}. -Code like this (lifted from @file{trans-expr.cc}) is fairly common: - -@smallexample -gfc_se cont_se; -tree cont_var; - -/* cont_var = is_contiguous (expr); . */ -gfc_init_se (&cont_se, parmse); -gfc_conv_is_contiguous_expr (&cont_se, expr); -gfc_add_block_to_block (&se->pre, &(&cont_se)->pre); -gfc_add_modify (&se->pre, cont_var, cont_se.expr); -gfc_add_block_to_block (&se->pre, &(&cont_se)->post); -@end smallexample - -Conversion functions which need a @code{gfc_se} structure will have a -corresponding argument. - -@code{gfc_se} also contains pointers to a @code{gfc_ss} and a -@code{gfc_loopinfo} structure. These are needed by the scalarizer. - -@node Translating Statements -@section Translating statements -Translating statements to @code{tree} is done by functions called -@code{gfc_trans_*}. These functions usually get passed a -@code{gfc_code} structure, evaluate any expressions and then -return a @code{tree} structure. - -@node Accessing Declarations -@section Accessing declarations - -@code{gfc_symbol}, @code{gfc_charlen} and other front-end structures -contain a @code{backend_decl} variable, which contains the @code{tree} -used for accessing that entity in the middle-end. - -Accessing declarations is usually done by functions called -@code{gfc_get*}. - -@c --------------------------------------------------------------------- -@c LibGFortran -@c --------------------------------------------------------------------- - -@node LibGFortran -@chapter The LibGFortran Runtime Library - -@menu -* Symbol Versioning:: Symbol Versioning. -@end menu - - -@c --------------------------------------------------------------------- -@c Symbol Versioning -@c --------------------------------------------------------------------- - -@node Symbol Versioning -@section Symbol Versioning -@comment Based on https://gcc.gnu.org/wiki/SymbolVersioning, -@comment as of 2006-11-05, written by Janne Blomqvist. - -In general, this capability exists only on a few platforms, thus there -is a need for configure magic so that it is used only on those targets -where it is supported. - -The central concept in symbol versioning is the so-called map file, -which specifies the version node(s) exported symbols are labeled with. -Also, the map file is used to hide local symbols. - -Some relevant references: -@itemize @bullet -@item -@uref{https://sourceware.org/binutils/docs/ld/VERSION.html, -GNU @command{ld} manual} - -@item -@uref{https://www.akkadia.org/drepper/symbol-versioning, ELF Symbol -Versioning - Ulrich Depper} - -@item -@uref{https://www.akkadia.org/drepper/dsohowto.pdf, How to Write Shared -Libraries - Ulrich Drepper (see Chapter 3)} - -@end itemize - -If one adds a new symbol to a library that should be exported, the new -symbol should be mentioned in the map file and a new version node -defined, e.g., if one adds a new symbols @code{foo} and @code{bar} to -libgfortran for the next GCC release, the following should be added to -the map file: -@smallexample -GFORTRAN_1.1 @{ - global: - foo; - bar; -@} GFORTRAN_1.0; -@end smallexample -@noindent -where @code{GFORTRAN_1.0} is the version node of the current release, -and @code{GFORTRAN_1.1} is the version node of the next release where -foo and bar are made available. - -If one wants to change an existing interface, it is possible by using -some asm trickery (from the @command{ld} manual referenced above): - -@smallexample -__asm__(".symver original_foo,foo@@"); -__asm__(".symver old_foo,foo@@VERS_1.1"); -__asm__(".symver old_foo1,foo@@VERS_1.2"); -__asm__(".symver new_foo,foo@@VERS_2.0"); -@end smallexample - -In this example, @code{foo@@} represents the symbol @code{foo} bound to -the unspecified base version of the symbol. The source file that -contains this example would define 4 C functions: @code{original_foo}, -@code{old_foo}, @code{old_foo1}, and @code{new_foo}. - -In this case the map file must contain @code{foo} in @code{VERS_1.1} -and @code{VERS_1.2} as well as in @code{VERS_2.0}. - - -@c --------------------------------------------------------------------- -@c GNU Free Documentation License -@c --------------------------------------------------------------------- - -@include fdl.texi - - -@c --------------------------------------------------------------------- -@c Index -@c --------------------------------------------------------------------- - -@node Index -@unnumbered Index - -@printindex cp - -@bye diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi deleted file mode 100644 index 4b4ecd5..0000000 --- a/gcc/fortran/gfortran.texi +++ /dev/null @@ -1,5573 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@c %**start of header -@setfilename gfortran.info -@set copyrights-gfortran 1999-2022 - -@include gcc-common.texi - -@settitle The GNU Fortran Compiler - -@c Create a separate index for command line options -@defcodeindex op -@c Merge the standard indexes into a single one. -@syncodeindex fn cp -@syncodeindex vr cp -@syncodeindex ky cp -@syncodeindex pg cp -@syncodeindex tp cp - -@c TODO: The following "Part" definitions are included here temporarily -@c until they are incorporated into the official Texinfo distribution. -@c They borrow heavily from Texinfo's \unnchapentry definitions. - -@tex -\gdef\part#1#2{% - \pchapsepmacro - \gdef\thischapter{} - \begingroup - \vglue\titlepagetopglue - \titlefonts \rm - \leftline{Part #1:@* #2} - \vskip4pt \hrule height 4pt width \hsize \vskip4pt - \endgroup - \writetocentry{part}{#2}{#1} -} -\gdef\blankpart{% - \writetocentry{blankpart}{}{} -} -% Part TOC-entry definition for summary contents. -\gdef\dosmallpartentry#1#2#3#4{% - \vskip .5\baselineskip plus.2\baselineskip - \begingroup - \let\rm=\bf \rm - \tocentry{Part #2: #1}{\doshortpageno\bgroup#4\egroup} - \endgroup -} -\gdef\dosmallblankpartentry#1#2#3#4{% - \vskip .5\baselineskip plus.2\baselineskip -} -% Part TOC-entry definition for regular contents. This has to be -% equated to an existing entry to not cause problems when the PDF -% outline is created. -\gdef\dopartentry#1#2#3#4{% - \unnchapentry{Part #2: #1}{}{#3}{#4} -} -\gdef\doblankpartentry#1#2#3#4{} -@end tex - -@c %**end of header - -@c Use with @@smallbook. - -@c %** start of document - -@c Cause even numbered pages to be printed on the left hand side of -@c the page and odd numbered pages to be printed on the right hand -@c side of the page. Using this, you can print on both sides of a -@c sheet of paper and have the text on the same part of the sheet. - -@c The text on right hand pages is pushed towards the right hand -@c margin and the text on left hand pages is pushed toward the left -@c hand margin. -@c (To provide the reverse effect, set bindingoffset to -0.75in.) - -@c @tex -@c \global\bindingoffset=0.75in -@c \global\normaloffset =0.75in -@c @end tex - -@copying -Copyright @copyright{} @value{copyrights-gfortran} Free Software Foundation, Inc. - -Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.3 or -any later version published by the Free Software Foundation; with the -Invariant Sections being ``Funding Free Software'', the Front-Cover -Texts being (a) (see below), and with the Back-Cover Texts being (b) -(see below). A copy of the license is included in the section entitled -``GNU Free Documentation License''. - -(a) The FSF's Front-Cover Text is: - - A GNU Manual - -(b) The FSF's Back-Cover Text is: - - You have freedom to copy and modify this GNU Manual, like GNU - software. Copies published by the Free Software Foundation raise - funds for GNU development. -@end copying - -@ifinfo -@dircategory Software development -@direntry -* gfortran: (gfortran). The GNU Fortran Compiler. -@end direntry -This file documents the use and the internals of -the GNU Fortran compiler, (@command{gfortran}). - -Published by the Free Software Foundation -51 Franklin Street, Fifth Floor -Boston, MA 02110-1301 USA - -@insertcopying -@end ifinfo - - -@setchapternewpage odd -@titlepage -@title Using GNU Fortran -@versionsubtitle -@author The @t{gfortran} team -@page -@vskip 0pt plus 1filll -Published by the Free Software Foundation@* -51 Franklin Street, Fifth Floor@* -Boston, MA 02110-1301, USA@* -@c Last printed ??ber, 19??.@* -@c Printed copies are available for $? each.@* -@c ISBN ??? -@sp 1 -@insertcopying -@end titlepage - -@c TODO: The following "Part" definitions are included here temporarily -@c until they are incorporated into the official Texinfo distribution. - -@tex -\global\let\partentry=\dosmallpartentry -\global\let\blankpartentry=\dosmallblankpartentry -@end tex -@summarycontents - -@tex -\global\let\partentry=\dopartentry -\global\let\blankpartentry=\doblankpartentry -@end tex -@contents - -@page - -@c --------------------------------------------------------------------- -@c TexInfo table of contents. -@c --------------------------------------------------------------------- - -@ifnottex -@node Top -@top Introduction -@cindex Introduction - -This manual documents the use of @command{gfortran}, -the GNU Fortran compiler. You can find in this manual how to invoke -@command{gfortran}, as well as its features and incompatibilities. - -@ifset DEVELOPMENT -@emph{Warning:} This document, and the compiler it describes, are still -under development. While efforts are made to keep it up-to-date, it might -not accurately reflect the status of the most recent GNU Fortran compiler. -@end ifset - -@comment -@comment When you add a new menu item, please keep the right hand -@comment aligned to the same column. Do not use tabs. This provides -@comment better formatting. -@comment -@menu -* Introduction:: - -Part I: Invoking GNU Fortran -* Invoking GNU Fortran:: Command options supported by @command{gfortran}. -* Runtime:: Influencing runtime behavior with environment variables. - -Part II: Language Reference -* Compiler Characteristics:: User-visible implementation details. -* Extensions:: Language extensions implemented by GNU Fortran. -* Mixed-Language Programming:: Interoperability with C -* Coarray Programming:: -* Intrinsic Procedures:: Intrinsic procedures supported by GNU Fortran. -* Intrinsic Modules:: Intrinsic modules supported by GNU Fortran. - -* Contributing:: How you can help. -* Copying:: GNU General Public License says - how you can copy and share GNU Fortran. -* GNU Free Documentation License:: - How you can copy and share this manual. -* Funding:: How to help assure continued work for free software. -* Option Index:: Index of command line options -* Keyword Index:: Index of concepts -@end menu -@end ifnottex - -@c --------------------------------------------------------------------- -@c Introduction -@c --------------------------------------------------------------------- - -@node Introduction -@chapter Introduction - -@c The following duplicates the text on the TexInfo table of contents. -@iftex -This manual documents the use of @command{gfortran}, the GNU Fortran -compiler. You can find in this manual how to invoke @command{gfortran}, -as well as its features and incompatibilities. - -@ifset DEVELOPMENT -@emph{Warning:} This document, and the compiler it describes, are still -under development. While efforts are made to keep it up-to-date, it -might not accurately reflect the status of the most recent GNU Fortran -compiler. -@end ifset -@end iftex - -@menu -* About GNU Fortran:: What you should know about the GNU Fortran compiler. -* GNU Fortran and GCC:: You can compile Fortran, C, or other programs. -* Standards:: Standards supported by GNU Fortran. -@end menu - - -@c --------------------------------------------------------------------- -@c About GNU Fortran -@c --------------------------------------------------------------------- - -@node About GNU Fortran -@section About GNU Fortran - -The GNU Fortran compiler is the successor to @command{g77}, the -Fortran 77 front end included in GCC prior to version 4 (released in -2005). While it is backward-compatible with most @command{g77} -extensions and command-line options, @command{gfortran} is a completely new -implemention designed to support more modern dialects of Fortran. -GNU Fortran implements the Fortran 77, 90 and 95 standards -completely, most of the Fortran 2003 and 2008 standards, and some -features from the 2018 standard. It also implements several extensions -including OpenMP and OpenACC support for parallel programming. - -The GNU Fortran compiler passes the -@uref{http://www.fortran-2000.com/ArnaudRecipes/fcvs21_f95.html, -NIST Fortran 77 Test Suite}, and produces acceptable results on the -@uref{https://www.netlib.org/lapack/faq.html, LAPACK Test Suite}. -It also provides respectable performance on -the @uref{https://polyhedron.com/?page_id=175, -Polyhedron Fortran compiler benchmarks} and the -@uref{https://www.netlib.org/benchmark/livermore, -Livermore Fortran Kernels test}. It has been used to compile a number of -large real-world programs, including -@uref{http://hirlam.org/, the HARMONIE and HIRLAM weather forecasting code} and -@uref{https://github.com/dylan-jayatilaka/tonto, -the Tonto quantum chemistry package}; see -@url{https://gcc.gnu.org/@/wiki/@/GfortranApps} for an extended list. - -GNU Fortran provides the following functionality: - -@itemize @bullet -@item -Read a program, stored in a file and containing @dfn{source code} -instructions written in Fortran 77. - -@item -Translate the program into instructions a computer -can carry out more quickly than it takes to translate the -original Fortran instructions. -The result after compilation of a program is -@dfn{machine code}, -which is efficiently translated and processed -by a machine such as your computer. -Humans usually are not as good writing machine code -as they are at writing Fortran (or C++, Ada, or Java), -because it is easy to make tiny mistakes writing machine code. - -@item -Provide information about the reasons why -the compiler may be unable to create a binary from the source code, -for example if the source code is flawed. -The Fortran language standards require that the compiler can point out -mistakes in your code. -An incorrect usage of the language causes an @dfn{error message}. - -The compiler also attempts to diagnose cases where your -program contains a correct usage of the language, -but instructs the computer to do something questionable. -This kind of diagnostic message is called a @dfn{warning message}. - -@item -Provide optional information about the translation passes -from the source code to machine code. -This can help you to find the cause of -certain bugs which may not be obvious in the source code, -but may be more easily found at a lower level compiler output. -It also helps developers to find bugs in the compiler itself. - -@item -Provide information in the generated machine code that can -make it easier to find bugs in the program (using a debugging tool, -called a @dfn{debugger}, such as the GNU Debugger @command{gdb}). - -@item -Locate and gather machine code already generated to -perform actions requested by statements in the program. -This machine code is organized into @dfn{modules} and is located -and @dfn{linked} to the user program. -@end itemize - -The GNU Fortran compiler consists of several components: - -@itemize @bullet -@item -A version of the @command{gcc} command -(which also might be installed as the system's @command{cc} command) -that also understands and accepts Fortran source code. -The @command{gcc} command is the @dfn{driver} program for -all the languages in the GNU Compiler Collection (GCC); -With @command{gcc}, -you can compile the source code of any language for -which a front end is available in GCC. - -@item -The @command{gfortran} command itself, -which also might be installed as the -system's @command{f95} command. -@command{gfortran} is just another driver program, -but specifically for the Fortran compiler only. -The primary difference between the @command{gcc} and @command{gfortran} -commands is that the latter automatically links the correct libraries -to your program. - -@item -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 -@command{gfortran} compilation phase, -such as intrinsic functions and subroutines, -and routines for interaction with files and the operating system. -@c and mechanisms to spawn, -@c unleash and pause threads in parallelized code. - -@item -The Fortran compiler itself, (@command{f951}). -This is the GNU Fortran parser and code generator, -linked to and interfaced with the GCC backend library. -@command{f951} ``translates'' the source code to -assembler code. You would typically not use this -program directly; -instead, the @command{gcc} or @command{gfortran} driver -programs call it for you. -@end itemize - - -@c --------------------------------------------------------------------- -@c GNU Fortran and GCC -@c --------------------------------------------------------------------- - -@node GNU Fortran and GCC -@section GNU Fortran and GCC -@cindex GNU Compiler Collection -@cindex GCC - -GNU Fortran is a part of GCC, the @dfn{GNU Compiler Collection}. GCC -consists of a collection of front ends for various languages, which -translate the source code into a language-independent form called -@dfn{GENERIC}. This is then processed by a common middle end which -provides optimization, and then passed to one of a collection of back -ends which generate code for different computer architectures and -operating systems. - -Functionally, this is implemented with a driver program (@command{gcc}) -which provides the command-line interface for the compiler. It calls -the relevant compiler front-end program (e.g., @command{f951} for -Fortran) for each file in the source code, and then calls the assembler -and linker as appropriate to produce the compiled output. In a copy of -GCC that has been compiled with Fortran language support enabled, -@command{gcc} recognizes files with @file{.f}, @file{.for}, @file{.ftn}, -@file{.f90}, @file{.f95}, @file{.f03} and @file{.f08} extensions as -Fortran source code, and compiles it accordingly. A @command{gfortran} -driver program is also provided, which is identical to @command{gcc} -except that it automatically links the Fortran runtime libraries into the -compiled program. - -Source files with @file{.f}, @file{.for}, @file{.fpp}, @file{.ftn}, @file{.F}, -@file{.FOR}, @file{.FPP}, and @file{.FTN} extensions are treated as fixed form. -Source files with @file{.f90}, @file{.f95}, @file{.f03}, @file{.f08}, -@file{.F90}, @file{.F95}, @file{.F03} and @file{.F08} extensions are -treated as free form. The capitalized versions of either form are run -through preprocessing. Source files with the lower case @file{.fpp} -extension are also run through preprocessing. - -This manual specifically documents the Fortran front end, which handles -the programming language's syntax and semantics. The aspects of GCC -that relate to the optimization passes and the back-end code generation -are documented in the GCC manual; see -@ref{Top,,Introduction,gcc,Using the GNU Compiler Collection (GCC)}. -The two manuals together provide a complete reference for the GNU -Fortran compiler. - -@c --------------------------------------------------------------------- -@c Standards -@c --------------------------------------------------------------------- - -@node Standards -@section Standards -@cindex Standards - -@menu -* Fortran 95 status:: -* Fortran 2003 status:: -* Fortran 2008 status:: -* Fortran 2018 status:: -@end menu - -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 @uref{http://www.nag.co.uk/sc22wg5/, WG5}. -Official Fortran standard documents are available for purchase -from ISO; a collection of free documents (typically final drafts) are -also available on the @uref{https://gcc.gnu.org/wiki/GFortranStandards, wiki}. - -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 standard, including full support for the Technical Specification -@code{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, -@url{https://openmp.org/@/specifications/}). -There also is support for the OpenACC specification (targeting -version 2.6, @uref{https://www.openacc.org/}). See -@uref{https://gcc.gnu.org/wiki/OpenACC} for more information. - -@node Fortran 95 status -@subsection Fortran 95 status -@cindex Varying length strings -@cindex strings, varying length -@cindex conditional compilation - -The Fortran 95 standard specifies in Part 2 (ISO/IEC 1539-2:2000) -varying length character strings. While GNU Fortran currently does not -support such strings directly, there exist two Fortran implementations -for them, which work with GNU Fortran. One can be found at -@uref{http://user.astro.wisc.edu/~townsend/static.php?ref=iso-varying-string}. - -Deferred-length character strings of Fortran 2003 supports part of -the features of @code{ISO_VARYING_STRING} and should be considered as -replacement. (Namely, allocatable or pointers of the type -@code{character(len=:)}.) - -Part 3 of the Fortran 95 standard (ISO/IEC 1539-3:1998) defines -Conditional Compilation, which is not widely used and not directly -supported by the GNU Fortran compiler. You can use the program coco -to preprocess such files (@uref{http://www.daniellnagle.com/coco.html}). - -@node Fortran 2003 status -@subsection Fortran 2003 status - -GNU Fortran implements the Fortran 2003 (ISO/IEC 1539-1:2004) standard -except for finalization support, which is incomplete. -See the -@uref{https://gcc.gnu.org/wiki/Fortran2003, wiki page} for a full list -of new features introduced by Fortran 2003 and their implementation status. - -@node Fortran 2008 status -@subsection Fortran 2008 status - -The GNU Fortran compiler supports almost all features of Fortran 2008; -the @uref{https://gcc.gnu.org/wiki/Fortran2008Status, wiki} -has some information about the current implementation status. -In particular, the following are not yet supported: - -@itemize @bullet -@item -@code{DO CONCURRENT} and @code{FORALL} do not recognize a -type-spec in the loop header. - -@item -The change to permit any constant expression in subscripts and -nested implied-do limits in a @code{DATA} statement has not been implemented. -@end itemize - - -@node Fortran 2018 status -@subsection Fortran 2018 status - -Fortran 2018 (ISO/IEC 1539:2018) is the most recent version -of the Fortran language standard. GNU Fortran implements some of the -new features of this standard: - -@itemize @bullet -@item -All Fortran 2018 features derived from ISO/IEC TS 29113:2012, -``Further Interoperability of Fortran with C'', are supported by GNU Fortran. -This includes assumed-type and assumed-rank objects and -the @code{SELECT RANK} construct as well as the parts relating to -@code{BIND(C)} functions. -See also @ref{Further Interoperability of Fortran with C}. - -@item -GNU Fortran supports a subset of features derived from ISO/IEC TS 18508:2015, -``Additional Parallel Features in Fortran'': - -@itemize @bullet -@item -The new atomic ADD, CAS, FETCH and ADD/OR/XOR, OR and XOR intrinsics. - -@item -The @code{CO_MIN} and @code{CO_MAX} and @code{SUM} reduction intrinsics, -and the @code{CO_BROADCAST} and @code{CO_REDUCE} intrinsic, except that those -do not support polymorphic types or types with allocatable, pointer or -polymorphic components. - -@item -Events (@code{EVENT POST}, @code{EVENT WAIT}, @code{EVENT_QUERY}). - -@item -Failed images (@code{FAIL IMAGE}, @code{IMAGE_STATUS}, -@code{FAILED_IMAGES}, @code{STOPPED_IMAGES}). - -@end itemize - -@item -An @code{ERROR STOP} statement is permitted in a @code{PURE} -procedure. - -@item -GNU Fortran supports the @code{IMPLICIT NONE} statement with an -@code{implicit-none-spec-list}. - -@item -The behavior of the @code{INQUIRE} statement with the @code{RECL=} -specifier now conforms to Fortran 2018. - -@end itemize - - -@c ===================================================================== -@c PART I: INVOCATION REFERENCE -@c ===================================================================== - -@tex -\part{I}{Invoking GNU Fortran} -@end tex - -@c --------------------------------------------------------------------- -@c Compiler Options -@c --------------------------------------------------------------------- - -@include invoke.texi - - -@c --------------------------------------------------------------------- -@c Runtime -@c --------------------------------------------------------------------- - -@node Runtime -@chapter Runtime: Influencing runtime behavior with environment variables -@cindex environment variable - -The behavior of the @command{gfortran} can be influenced by -environment variables. - -Malformed environment variables are silently ignored. - -@menu -* TMPDIR:: Directory for scratch files -* GFORTRAN_STDIN_UNIT:: Unit number for standard input -* GFORTRAN_STDOUT_UNIT:: Unit number for standard output -* GFORTRAN_STDERR_UNIT:: Unit number for standard error -* GFORTRAN_UNBUFFERED_ALL:: Do not buffer I/O for all units -* GFORTRAN_UNBUFFERED_PRECONNECTED:: Do not buffer I/O for preconnected units. -* GFORTRAN_SHOW_LOCUS:: Show location for runtime errors -* GFORTRAN_OPTIONAL_PLUS:: Print leading + where permitted -* GFORTRAN_LIST_SEPARATOR:: Separator for list output -* GFORTRAN_CONVERT_UNIT:: Set conversion for unformatted I/O -* GFORTRAN_ERROR_BACKTRACE:: Show backtrace on run-time errors -* GFORTRAN_FORMATTED_BUFFER_SIZE:: Buffer size for formatted files -* GFORTRAN_UNFORMATTED_BUFFER_SIZE:: Buffer size for unformatted files -@end menu - -@node TMPDIR -@section @env{TMPDIR}---Directory for scratch files - -When opening a file with @code{STATUS='SCRATCH'}, GNU Fortran tries to -create the file in one of the potential directories by testing each -directory in the order below. - -@enumerate -@item -The environment variable @env{TMPDIR}, if it exists. - -@item -On the MinGW target, the directory returned by the @code{GetTempPath} -function. Alternatively, on the Cygwin target, the @env{TMP} and -@env{TEMP} environment variables, if they exist, in that order. - -@item -The @code{P_tmpdir} macro if it is defined, otherwise the directory -@file{/tmp}. -@end enumerate - -@node GFORTRAN_STDIN_UNIT -@section @env{GFORTRAN_STDIN_UNIT}---Unit number for standard input - -This environment variable can be used to select the unit number -preconnected to standard input. This must be a positive integer. -The default value is 5. - -@node GFORTRAN_STDOUT_UNIT -@section @env{GFORTRAN_STDOUT_UNIT}---Unit number for standard output - -This environment variable can be used to select the unit number -preconnected to standard output. This must be a positive integer. -The default value is 6. - -@node GFORTRAN_STDERR_UNIT -@section @env{GFORTRAN_STDERR_UNIT}---Unit number for standard error - -This environment variable can be used to select the unit number -preconnected to standard error. This must be a positive integer. -The default value is 0. - -@node GFORTRAN_UNBUFFERED_ALL -@section @env{GFORTRAN_UNBUFFERED_ALL}---Do not buffer I/O on all units - -This environment variable controls whether all I/O is unbuffered. If -the first letter is @samp{y}, @samp{Y} or @samp{1}, all I/O is -unbuffered. This will slow down small sequential reads and writes. If -the first letter is @samp{n}, @samp{N} or @samp{0}, I/O is buffered. -This is the default. - -@node GFORTRAN_UNBUFFERED_PRECONNECTED -@section @env{GFORTRAN_UNBUFFERED_PRECONNECTED}---Do not buffer I/O on preconnected units - -The environment variable named @env{GFORTRAN_UNBUFFERED_PRECONNECTED} controls -whether I/O on a preconnected unit (i.e.@: STDOUT or STDERR) is unbuffered. If -the first letter is @samp{y}, @samp{Y} or @samp{1}, I/O is unbuffered. This -will slow down small sequential reads and writes. If the first letter -is @samp{n}, @samp{N} or @samp{0}, I/O is buffered. This is the default. - -@node GFORTRAN_SHOW_LOCUS -@section @env{GFORTRAN_SHOW_LOCUS}---Show location for runtime errors - -If the first letter is @samp{y}, @samp{Y} or @samp{1}, filename and -line numbers for runtime errors are printed. If the first letter is -@samp{n}, @samp{N} or @samp{0}, do not print filename and line numbers -for runtime errors. The default is to print the location. - -@node GFORTRAN_OPTIONAL_PLUS -@section @env{GFORTRAN_OPTIONAL_PLUS}---Print leading + where permitted - -If the first letter is @samp{y}, @samp{Y} or @samp{1}, -a plus sign is printed -where permitted by the Fortran standard. If the first letter -is @samp{n}, @samp{N} or @samp{0}, a plus sign is not printed -in most cases. Default is not to print plus signs. - -@node GFORTRAN_LIST_SEPARATOR -@section @env{GFORTRAN_LIST_SEPARATOR}---Separator for list output - -This environment variable specifies the separator when writing -list-directed output. It may contain any number of spaces and -at most one comma. If you specify this on the command line, -be sure to quote spaces, as in -@smallexample -$ GFORTRAN_LIST_SEPARATOR=' , ' ./a.out -@end smallexample -when @command{a.out} is the compiled Fortran program that you want to run. -Default is a single space. - -@node GFORTRAN_CONVERT_UNIT -@section @env{GFORTRAN_CONVERT_UNIT}---Set conversion for unformatted I/O - -By setting the @env{GFORTRAN_CONVERT_UNIT} variable, it is possible -to change the representation of data for unformatted files. -The syntax for the @env{GFORTRAN_CONVERT_UNIT} variable for -most systems is: -@smallexample -GFORTRAN_CONVERT_UNIT: mode | mode ';' exception | exception ; -mode: 'native' | 'swap' | 'big_endian' | 'little_endian' ; -exception: mode ':' unit_list | unit_list ; -unit_list: unit_spec | unit_list unit_spec ; -unit_spec: INTEGER | INTEGER '-' INTEGER ; -@end smallexample -The variable consists of an optional default mode, followed by -a list of optional exceptions, which are separated by semicolons -from the preceding default and each other. Each exception consists -of a format and a comma-separated list of units. Valid values for -the modes are the same as for the @code{CONVERT} specifier: - -@itemize @w{} -@item @code{NATIVE} Use the native format. This is the default. -@item @code{SWAP} Swap between little- and big-endian. -@item @code{LITTLE_ENDIAN} Use the little-endian format -for unformatted files. -@item @code{BIG_ENDIAN} Use the big-endian format for unformatted files. -@end itemize -For POWER systems which support @option{-mabi=ieeelongdouble}, -there are additional options, which can be combined with the -others with commas. Those are -@itemize @w{} -@item @code{R16_IEEE} Use IEEE 128-bit format for @code{REAL(KIND=16)}. -@item @code{R16_IBM} Use IBM @code{long double} format for -@code{REAL(KIND=16)}. -@end itemize -A missing mode for an exception is taken to mean @code{BIG_ENDIAN}. -Examples of values for @env{GFORTRAN_CONVERT_UNIT} are: -@itemize @w{} -@item @code{'big_endian'} Do all unformatted I/O in big_endian mode. -@item @code{'little_endian;native:10-20,25'} Do all unformatted I/O -in little_endian mode, except for units 10 to 20 and 25, which are in -native format. -@item @code{'10-20'} Units 10 to 20 are big-endian, the rest is native. -@item @code{'big_endian,r16_ibm'} Do all unformatted I/O in big-endian -mode and use IBM long double for output of @code{REAL(KIND=16)} values. -@end itemize - -Setting the environment variables should be done on the command -line or via the @command{export} -command for @command{sh}-compatible shells and via @command{setenv} -for @command{csh}-compatible shells. - -Example for @command{sh}: -@smallexample -$ gfortran foo.f90 -$ GFORTRAN_CONVERT_UNIT='big_endian;native:10-20' ./a.out -@end smallexample - -Example code for @command{csh}: -@smallexample -% gfortran foo.f90 -% setenv GFORTRAN_CONVERT_UNIT 'big_endian;native:10-20' -% ./a.out -@end smallexample - -Using anything but the native representation for unformatted data -carries a significant speed overhead. If speed in this area matters -to you, it is best if you use this only for data that needs to be -portable. - -@xref{CONVERT specifier}, for an alternative way to specify the -data representation for unformatted files. @xref{Runtime Options}, for -setting a default data representation for the whole program. The -@code{CONVERT} specifier overrides the @option{-fconvert} compile options. - -@emph{Note that the values specified via the GFORTRAN_CONVERT_UNIT -environment variable will override the CONVERT specifier in the -open statement}. This is to give control over data formats to -users who do not have the source code of their program available. - -@node GFORTRAN_ERROR_BACKTRACE -@section @env{GFORTRAN_ERROR_BACKTRACE}---Show backtrace on run-time errors - -If the @env{GFORTRAN_ERROR_BACKTRACE} variable is set to @samp{y}, -@samp{Y} or @samp{1} (only the first letter is relevant) then a -backtrace is printed when a serious run-time error occurs. To disable -the backtracing, set the variable to @samp{n}, @samp{N}, @samp{0}. -Default is to print a backtrace unless the @option{-fno-backtrace} -compile option was used. - -@node GFORTRAN_FORMATTED_BUFFER_SIZE -@section @env{GFORTRAN_FORMATTED_BUFFER_SIZE}---Set buffer size for formatted I/O - -The @env{GFORTRAN_FORMATTED_BUFFER_SIZE} environment variable -specifies buffer size in bytes to be used for formatted output. -The default value is 8192. - -@node GFORTRAN_UNFORMATTED_BUFFER_SIZE -@section @env{GFORTRAN_UNFORMATTED_BUFFER_SIZE}---Set buffer size for unformatted I/O - -The @env{GFORTRAN_UNFORMATTED_BUFFER_SIZE} environment variable -specifies buffer size in bytes to be used for unformatted output. -The default value is 131072. - -@c ===================================================================== -@c PART II: LANGUAGE REFERENCE -@c ===================================================================== - -@tex -\part{II}{Language Reference} -@end tex - - - -@c --------------------------------------------------------------------- -@c Compiler Characteristics -@c --------------------------------------------------------------------- - -@node Compiler Characteristics -@chapter Compiler Characteristics - -This chapter describes certain characteristics of the GNU Fortran -compiler, that are not specified by the Fortran standard, but which -might in some way or another become visible to the programmer. - -@menu -* KIND Type Parameters:: -* Internal representation of LOGICAL variables:: -* Evaluation of logical expressions:: -* MAX and MIN intrinsics with REAL NaN arguments:: -* Thread-safety of the runtime library:: -* Data consistency and durability:: -* Files opened without an explicit ACTION= specifier:: -* File operations on symbolic links:: -* File format of unformatted sequential files:: -* Asynchronous I/O:: -@end menu - - -@node KIND Type Parameters -@section KIND Type Parameters -@cindex kind - -The @code{KIND} type parameters supported by GNU Fortran for the primitive -data types are: - -@table @code - -@item INTEGER -1, 2, 4, 8*, 16*, default: 4** - -@item LOGICAL -1, 2, 4, 8*, 16*, default: 4** - -@item REAL -4, 8, 10*, 16*, default: 4*** - -@item COMPLEX -4, 8, 10*, 16*, default: 4*** - -@item DOUBLE PRECISION -4, 8, 10*, 16*, default: 8*** - -@item CHARACTER -1, 4, default: 1 - -@end table - -@noindent -* not available on all systems @* -** unless @option{-fdefault-integer-8} is used @* -*** unless @option{-fdefault-real-8} is used (see @ref{Fortran Dialect Options}) - -@noindent -The @code{KIND} value matches the storage size in bytes, except for -@code{COMPLEX} where the storage size is twice as much (or both real and -imaginary part are a real value of the given size). It is recommended to use -the @ref{SELECTED_CHAR_KIND}, @ref{SELECTED_INT_KIND} and -@ref{SELECTED_REAL_KIND} intrinsics or the @code{INT8}, @code{INT16}, -@code{INT32}, @code{INT64}, @code{REAL32}, @code{REAL64}, and @code{REAL128} -parameters of the @code{ISO_FORTRAN_ENV} module instead of the concrete values. -The available kind parameters can be found in the constant arrays -@code{CHARACTER_KINDS}, @code{INTEGER_KINDS}, @code{LOGICAL_KINDS} and -@code{REAL_KINDS} in the @ref{ISO_FORTRAN_ENV} module. For C interoperability, -the kind parameters of the @ref{ISO_C_BINDING} module should be used. - - -@node Internal representation of LOGICAL variables -@section Internal representation of LOGICAL variables -@cindex logical, variable representation - -The Fortran standard does not specify how variables of @code{LOGICAL} -type are represented, beyond requiring that @code{LOGICAL} variables -of default kind have the same storage size as default @code{INTEGER} -and @code{REAL} variables. The GNU Fortran internal representation is -as follows. - -A @code{LOGICAL(KIND=N)} variable is represented as an -@code{INTEGER(KIND=N)} variable, however, with only two permissible -values: @code{1} for @code{.TRUE.} and @code{0} for -@code{.FALSE.}. Any other integer value results in undefined behavior. - -See also @ref{Argument passing conventions} and @ref{Interoperability with C}. - - -@node Evaluation of logical expressions -@section Evaluation of logical expressions - -The Fortran standard does not require the compiler to evaluate all parts of an -expression, if they do not contribute to the final result. For logical -expressions with @code{.AND.} or @code{.OR.} operators, in particular, GNU -Fortran will optimize out function calls (even to impure functions) if the -result of the expression can be established without them. However, since not -all compilers do that, and such an optimization can potentially modify the -program flow and subsequent results, GNU Fortran throws warnings for such -situations with the @option{-Wfunction-elimination} flag. - - -@node MAX and MIN intrinsics with REAL NaN arguments -@section MAX and MIN intrinsics with REAL NaN arguments -@cindex MAX, MIN, NaN - -The Fortran standard does not specify what the result of the -@code{MAX} and @code{MIN} intrinsics are if one of the arguments is a -@code{NaN}. Accordingly, the GNU Fortran compiler does not specify -that either, as this allows for faster and more compact code to be -generated. If the programmer wishes to take some specific action in -case one of the arguments is a @code{NaN}, it is necessary to -explicitly test the arguments before calling @code{MAX} or @code{MIN}, -e.g. with the @code{IEEE_IS_NAN} function from the intrinsic module -@code{IEEE_ARITHMETIC}. - - -@node Thread-safety of the runtime library -@section Thread-safety of the runtime library -@cindex thread-safety, threads - -GNU Fortran can be used in programs with multiple threads, e.g.@: by -using OpenMP, by calling OS thread handling functions via the -@code{ISO_C_BINDING} facility, or by GNU Fortran compiled library code -being called from a multi-threaded program. - -The GNU Fortran runtime library, (@code{libgfortran}), supports being -called concurrently from multiple threads with the following -exceptions. - -During library initialization, the C @code{getenv} function is used, -which need not be thread-safe. Similarly, the @code{getenv} -function is used to implement the @code{GET_ENVIRONMENT_VARIABLE} and -@code{GETENV} intrinsics. It is the responsibility of the user to -ensure that the environment is not being updated concurrently when any -of these actions are taking place. - -The @code{EXECUTE_COMMAND_LINE} and @code{SYSTEM} intrinsics are -implemented with the @code{system} function, which need not be -thread-safe. It is the responsibility of the user to ensure that -@code{system} is not called concurrently. - -For platforms not supporting thread-safe POSIX functions, further -functionality might not be thread-safe. For details, please consult -the documentation for your operating system. - -The GNU Fortran runtime library uses various C library functions that -depend on the locale, such as @code{strtod} and @code{snprintf}. In -order to work correctly in locale-aware programs that set the locale -using @code{setlocale}, the locale is reset to the default ``C'' -locale while executing a formatted @code{READ} or @code{WRITE} -statement. On targets supporting the POSIX 2008 per-thread locale -functions (e.g. @code{newlocale}, @code{uselocale}, -@code{freelocale}), these are used and thus the global locale set -using @code{setlocale} or the per-thread locales in other threads are -not affected. However, on targets lacking this functionality, the -global LC_NUMERIC locale is set to ``C'' during the formatted I/O. -Thus, on such targets it's not safe to call @code{setlocale} -concurrently from another thread while a Fortran formatted I/O -operation is in progress. Also, other threads doing something -dependent on the LC_NUMERIC locale might not work correctly if a -formatted I/O operation is in progress in another thread. - -@node Data consistency and durability -@section Data consistency and durability -@cindex consistency, durability - -This section contains a brief overview of data and metadata -consistency and durability issues when doing I/O. - -With respect to durability, GNU Fortran makes no effort to ensure that -data is committed to stable storage. If this is required, the GNU -Fortran programmer can use the intrinsic @code{FNUM} to retrieve the -low level file descriptor corresponding to an open Fortran unit. Then, -using e.g. the @code{ISO_C_BINDING} feature, one can call the -underlying system call to flush dirty data to stable storage, such as -@code{fsync} on POSIX, @code{_commit} on MingW, or @code{fcntl(fd, -F_FULLSYNC, 0)} on Mac OS X. The following example shows how to call -fsync: - -@smallexample - ! Declare the interface for POSIX fsync function - interface - function fsync (fd) bind(c,name="fsync") - use iso_c_binding, only: c_int - integer(c_int), value :: fd - integer(c_int) :: fsync - end function fsync - end interface - - ! Variable declaration - integer :: ret - - ! Opening unit 10 - open (10,file="foo") - - ! ... - ! Perform I/O on unit 10 - ! ... - - ! Flush and sync - flush(10) - ret = fsync(fnum(10)) - - ! Handle possible error - if (ret /= 0) stop "Error calling FSYNC" -@end smallexample - -With respect to consistency, for regular files GNU Fortran uses -buffered I/O in order to improve performance. This buffer is flushed -automatically when full and in some other situations, e.g. when -closing a unit. It can also be explicitly flushed with the -@code{FLUSH} statement. Also, the buffering can be turned off with the -@code{GFORTRAN_UNBUFFERED_ALL} and -@code{GFORTRAN_UNBUFFERED_PRECONNECTED} environment variables. Special -files, such as terminals and pipes, are always unbuffered. Sometimes, -however, further things may need to be done in order to allow other -processes to see data that GNU Fortran has written, as follows. - -The Windows platform supports a relaxed metadata consistency model, -where file metadata is written to the directory lazily. This means -that, for instance, the @code{dir} command can show a stale size for a -file. One can force a directory metadata update by closing the unit, -or by calling @code{_commit} on the file descriptor. Note, though, -that @code{_commit} will force all dirty data to stable storage, which -is often a very slow operation. - -The Network File System (NFS) implements a relaxed consistency model -called open-to-close consistency. Closing a file forces dirty data and -metadata to be flushed to the server, and opening a file forces the -client to contact the server in order to revalidate cached -data. @code{fsync} will also force a flush of dirty data and metadata -to the server. Similar to @code{open} and @code{close}, acquiring and -releasing @code{fcntl} file locks, if the server supports them, will -also force cache validation and flushing dirty data and metadata. - - -@node Files opened without an explicit ACTION= specifier -@section Files opened without an explicit ACTION= specifier -@cindex open, action - -The Fortran standard says that if an @code{OPEN} statement is executed -without an explicit @code{ACTION=} specifier, the default value is -processor dependent. GNU Fortran behaves as follows: - -@enumerate -@item Attempt to open the file with @code{ACTION='READWRITE'} -@item If that fails, try to open with @code{ACTION='READ'} -@item If that fails, try to open with @code{ACTION='WRITE'} -@item If that fails, generate an error -@end enumerate - - -@node File operations on symbolic links -@section File operations on symbolic links -@cindex file, symbolic link - -This section documents the behavior of GNU Fortran for file operations on -symbolic links, on systems that support them. - -@itemize - -@item Results of INQUIRE statements of the ``inquire by file'' form will -relate to the target of the symbolic link. For example, -@code{INQUIRE(FILE="foo",EXIST=ex)} will set @var{ex} to @var{.true.} if -@var{foo} is a symbolic link pointing to an existing file, and @var{.false.} -if @var{foo} points to an non-existing file (``dangling'' symbolic link). - -@item Using the @code{OPEN} statement with a @code{STATUS="NEW"} specifier -on a symbolic link will result in an error condition, whether the symbolic -link points to an existing target or is dangling. - -@item If a symbolic link was connected, using the @code{CLOSE} statement -with a @code{STATUS="DELETE"} specifier will cause the symbolic link itself -to be deleted, not its target. - -@end itemize - -@node File format of unformatted sequential files -@section File format of unformatted sequential files -@cindex file, unformatted sequential -@cindex unformatted sequential -@cindex sequential, unformatted -@cindex record marker -@cindex subrecord - -Unformatted sequential files are stored as logical records using -record markers. Each logical record consists of one of more -subrecords. - -Each subrecord consists of a leading record marker, the data written -by the user program, and a trailing record marker. The record markers -are four-byte integers by default, and eight-byte integers if the -@option{-fmax-subrecord-length=8} option (which exists for backwards -compability only) is in effect. - -The representation of the record markers is that of unformatted files -given with the @option{-fconvert} option, the @ref{CONVERT specifier} -in an open statement or the @ref{GFORTRAN_CONVERT_UNIT} environment -variable. - -The maximum number of bytes of user data in a subrecord is 2147483639 -(2 GiB - 9) for a four-byte record marker. This limit can be lowered -with the @option{-fmax-subrecord-length} option, although this is -rarely useful. If the length of a logical record exceeds this limit, -the data is distributed among several subrecords. - -The absolute of the number stored in the record markers is the number -of bytes of user data in the corresponding subrecord. If the leading -record marker of a subrecord contains a negative number, another -subrecord follows the current one. If the trailing record marker -contains a negative number, then there is a preceding subrecord. - -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: - -@smallexample -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 -@end smallexample - -@node Asynchronous I/O -@section Asynchronous I/O -@cindex input/output, asynchronous -@cindex asynchronous I/O - -Asynchronous I/O is supported if the program is linked against the -POSIX thread library. If that is not the case, all I/O is performed -as synchronous. On systems which do not support pthread condition -variables, such as AIX, I/O is also performed as synchronous. - -On some systems, such as Darwin or Solaris, the POSIX thread library -is always linked in, so asynchronous I/O is always performed. On other -sytems, such as Linux, it is necessary to specify @option{-pthread}, -@option{-lpthread} or @option{-fopenmp} during the linking step. - -@c --------------------------------------------------------------------- -@c Extensions -@c --------------------------------------------------------------------- - -@c Maybe this chapter should be merged with the 'Standards' section, -@c whenever that is written :-) - -@node Extensions -@chapter Extensions -@cindex extensions - -The two sections below detail the extensions to standard Fortran that are -implemented in GNU Fortran, as well as some of the popular or -historically important extensions that are not (or not yet) implemented. -For the latter case, we explain the alternatives available to GNU Fortran -users, including replacement by standard-conforming code or GNU -extensions. - -@menu -* Extensions implemented in GNU Fortran:: -* Extensions not implemented in GNU Fortran:: -@end menu - - -@node Extensions implemented in GNU Fortran -@section Extensions implemented in GNU Fortran -@cindex extensions, implemented - -GNU Fortran implements a number of extensions over standard Fortran. -This chapter contains information on their syntax and meaning. There -are currently two categories of GNU Fortran extensions, those that -provide functionality beyond that provided by any standard, and those -that are supported by GNU Fortran purely for backward compatibility -with legacy compilers. By default, @option{-std=gnu} allows the -compiler to accept both types of extensions, but to warn about the use -of the latter. Specifying either @option{-std=f95}, -@option{-std=f2003}, @option{-std=f2008}, or @option{-std=f2018} -disables both types of extensions, and @option{-std=legacy} allows -both without warning. The special compile flag @option{-fdec} enables -additional compatibility extensions along with those enabled by -@option{-std=legacy}. - -@menu -* Old-style kind specifications:: -* Old-style variable initialization:: -* Extensions to namelist:: -* X format descriptor without count field:: -* Commas in FORMAT specifications:: -* Missing period in FORMAT specifications:: -* Default widths for F@comma{} G and I format descriptors:: -* I/O item lists:: -* @code{Q} exponent-letter:: -* BOZ literal constants:: -* Real array indices:: -* Unary operators:: -* Implicitly convert LOGICAL and INTEGER values:: -* Hollerith constants support:: -* Character conversion:: -* Cray pointers:: -* CONVERT specifier:: -* OpenMP:: -* OpenACC:: -* Argument list functions:: -* Read/Write after EOF marker:: -* STRUCTURE and RECORD:: -* UNION and MAP:: -* Type variants for integer intrinsics:: -* AUTOMATIC and STATIC attributes:: -* Extended math intrinsics:: -* Form feed as whitespace:: -* TYPE as an alias for PRINT:: -* %LOC as an rvalue:: -* .XOR. operator:: -* Bitwise logical operators:: -* Extended I/O specifiers:: -* Legacy PARAMETER statements:: -* Default exponents:: -@end menu - -@node Old-style kind specifications -@subsection Old-style kind specifications -@cindex kind, old-style - -GNU Fortran allows old-style kind specifications in declarations. These -look like: -@smallexample - TYPESPEC*size x,y,z -@end smallexample -@noindent -where @code{TYPESPEC} is a basic type (@code{INTEGER}, @code{REAL}, -etc.), and where @code{size} is a byte count corresponding to the -storage size of a valid kind for that type. (For @code{COMPLEX} -variables, @code{size} is the total size of the real and imaginary -parts.) The statement then declares @code{x}, @code{y} and @code{z} to -be of type @code{TYPESPEC} with the appropriate kind. This is -equivalent to the standard-conforming declaration -@smallexample - TYPESPEC(k) x,y,z -@end smallexample -@noindent -where @code{k} is the kind parameter suitable for the intended precision. As -kind parameters are implementation-dependent, use the @code{KIND}, -@code{SELECTED_INT_KIND} and @code{SELECTED_REAL_KIND} intrinsics to retrieve -the correct value, for instance @code{REAL*8 x} can be replaced by: -@smallexample -INTEGER, PARAMETER :: dbl = KIND(1.0d0) -REAL(KIND=dbl) :: x -@end smallexample - -@node Old-style variable initialization -@subsection Old-style variable initialization - -GNU Fortran allows old-style initialization of variables of the -form: -@smallexample - INTEGER i/1/,j/2/ - REAL x(2,2) /3*0.,1./ -@end smallexample -The syntax for the initializers is as for the @code{DATA} statement, but -unlike in a @code{DATA} statement, an initializer only applies to the -variable immediately preceding the initialization. In other words, -something like @code{INTEGER I,J/2,3/} is not valid. This style of -initialization is only allowed in declarations without double colons -(@code{::}); the double colons were introduced in Fortran 90, which also -introduced a standard syntax for initializing variables in type -declarations. - -Examples of standard-conforming code equivalent to the above example -are: -@smallexample -! Fortran 90 - INTEGER :: i = 1, j = 2 - REAL :: x(2,2) = RESHAPE((/0.,0.,0.,1./),SHAPE(x)) -! Fortran 77 - INTEGER i, j - REAL x(2,2) - DATA i/1/, j/2/, x/3*0.,1./ -@end smallexample - -Note that variables which are explicitly initialized in declarations -or in @code{DATA} statements automatically acquire the @code{SAVE} -attribute. - -@node Extensions to namelist -@subsection Extensions to namelist -@cindex Namelist - -GNU Fortran fully supports the Fortran 95 standard for namelist I/O -including array qualifiers, substrings and fully qualified derived types. -The output from a namelist write is compatible with namelist read. The -output has all names in upper case and indentation to column 1 after the -namelist name. Two extensions are permitted: - -Old-style use of @samp{$} instead of @samp{&} -@smallexample -$MYNML - X(:)%Y(2) = 1.0 2.0 3.0 - CH(1:4) = "abcd" -$END -@end smallexample - -It should be noted that the default terminator is @samp{/} rather than -@samp{&END}. - -Querying of the namelist when inputting from stdin. After at least -one space, entering @samp{?} sends to stdout the namelist name and the names of -the variables in the namelist: -@smallexample - ? - -&mynml - x - x%y - ch -&end -@end smallexample - -Entering @samp{=?} outputs the namelist to stdout, as if -@code{WRITE(*,NML = mynml)} had been called: -@smallexample -=? - -&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, / -@end smallexample - -To aid this dialog, when input is from stdin, errors send their -messages to stderr and execution continues, even if @code{IOSTAT} is set. - -@code{PRINT} namelist is permitted. This causes an error if -@option{-std=f95} is used. -@smallexample -PROGRAM test_print - REAL, dimension (4) :: x = (/1.0, 2.0, 3.0, 4.0/) - NAMELIST /mynml/ x - PRINT mynml -END PROGRAM test_print -@end smallexample - -Expanded namelist reads are permitted. This causes an error if -@option{-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. -@smallexample -&MYNML - X(1,1) = 0.00 , 1.00 , 2.00 -/ -@end smallexample - -When writing a namelist, if no @code{DELIM=} is specified, by default a -double quote is used to delimit character strings. If -std=F95, F2003, -or F2008, etc, the delim status is set to 'none'. Defaulting to -quotes ensures that namelists with character strings can be subsequently -read back in accurately. - -@node X format descriptor without count field -@subsection @code{X} format descriptor without count field - -To support legacy codes, GNU Fortran permits the count field of the -@code{X} edit descriptor in @code{FORMAT} statements to be omitted. -When omitted, the count is implicitly assumed to be one. - -@smallexample - PRINT 10, 2, 3 -10 FORMAT (I1, X, I1) -@end smallexample - -@node Commas in FORMAT specifications -@subsection Commas in @code{FORMAT} specifications - -To support legacy codes, GNU Fortran allows the comma separator -to be omitted immediately before and after character string edit -descriptors in @code{FORMAT} statements. A comma with no following format -decriptor is permited if the @option{-fdec-blank-format-item} is given on -the command line. This is considered non-conforming code and is -discouraged. - -@smallexample - PRINT 10, 2, 3 -10 FORMAT ('FOO='I1' BAR='I2) - print 20, 5, 6 -20 FORMAT (I3, I3,) -@end smallexample - - -@node Missing period in FORMAT specifications -@subsection Missing period in @code{FORMAT} specifications - -To support legacy codes, GNU Fortran allows missing periods in format -specifications if and only if @option{-std=legacy} is given on the -command line. This is considered non-conforming code and is -discouraged. - -@smallexample - REAL :: value - READ(*,10) value -10 FORMAT ('F4') -@end smallexample - -@node Default widths for F@comma{} G and I format descriptors -@subsection Default widths for @code{F}, @code{G} and @code{I} format descriptors - -To support legacy codes, GNU Fortran allows width to be omitted from format -specifications if and only if @option{-fdec-format-defaults} is given on the -command line. Default widths will be used. This is considered non-conforming -code and is discouraged. - -@smallexample - REAL :: value1 - INTEGER :: value2 - WRITE(*,10) value1, value1, value2 -10 FORMAT ('F, G, I') -@end smallexample - - -@node I/O item lists -@subsection I/O item lists -@cindex I/O item lists - -To support legacy codes, GNU Fortran allows the input item list -of the @code{READ} statement, and the output item lists of the -@code{WRITE} and @code{PRINT} statements, to start with a comma. - -@node @code{Q} exponent-letter -@subsection @code{Q} exponent-letter -@cindex @code{Q} exponent-letter - -GNU Fortran accepts real literal constants with an exponent-letter -of @code{Q}, for example, @code{1.23Q45}. The constant is interpreted -as a @code{REAL(16)} entity on targets that support this type. If -the target does not support @code{REAL(16)} but has a @code{REAL(10)} -type, then the real-literal-constant will be interpreted as a -@code{REAL(10)} entity. In the absence of @code{REAL(16)} and -@code{REAL(10)}, an error will occur. - -@node BOZ literal constants -@subsection BOZ literal constants -@cindex BOZ literal constants - -Besides decimal constants, Fortran also supports binary (@code{b}), -octal (@code{o}) and hexadecimal (@code{z}) integer constants. The -syntax is: @samp{prefix quote digits quote}, where the prefix is -either @code{b}, @code{o} or @code{z}, quote is either @code{'} or -@code{"} and the digits are @code{0} or @code{1} for binary, -between @code{0} and @code{7} for octal, and between @code{0} and -@code{F} for hexadecimal. (Example: @code{b'01011101'}.) - -Up to Fortran 95, BOZ literal constants were only allowed to initialize -integer variables in DATA statements. Since Fortran 2003 BOZ literal -constants are also allowed as actual arguments to the @code{REAL}, -@code{DBLE}, @code{INT} and @code{CMPLX} intrinsic functions. -The BOZ literal constant is simply a string of bits, which is padded -or truncated as needed, during conversion to a numeric type. The -Fortran standard states that the treatment of the sign bit is processor -dependent. Gfortran interprets the sign bit as a user would expect. - -As a deprecated extension, GNU Fortran allows hexadecimal BOZ literal -constants to be specified using the @code{X} prefix. That the BOZ literal -constant can also be specified by adding a suffix to the string, for -example, @code{Z'ABC'} and @code{'ABC'X} are equivalent. Additionally, -as extension, BOZ literals are permitted in some contexts outside of -@code{DATA} and the intrinsic functions listed in the Fortran standard. -Use @option{-fallow-invalid-boz} to enable the extension. - -@node Real array indices -@subsection Real array indices -@cindex array, indices of type real - -As an extension, GNU Fortran allows the use of @code{REAL} expressions -or variables as array indices. - -@node Unary operators -@subsection Unary operators -@cindex operators, unary - -As an extension, GNU Fortran allows unary plus and unary minus operators -to appear as the second operand of binary arithmetic operators without -the need for parenthesis. - -@smallexample - X = Y * -Z -@end smallexample - -@node Implicitly convert LOGICAL and INTEGER values -@subsection Implicitly convert @code{LOGICAL} and @code{INTEGER} values -@cindex conversion, to integer -@cindex conversion, to logical - -As an extension for backwards compatibility with other compilers, GNU -Fortran allows the implicit conversion of @code{LOGICAL} values to -@code{INTEGER} values and vice versa. When converting from a -@code{LOGICAL} to an @code{INTEGER}, @code{.FALSE.} is interpreted as -zero, and @code{.TRUE.} is interpreted as one. When converting from -@code{INTEGER} to @code{LOGICAL}, the value zero is interpreted as -@code{.FALSE.} and any nonzero value is interpreted as @code{.TRUE.}. - -@smallexample - LOGICAL :: l - l = 1 -@end smallexample -@smallexample - INTEGER :: i - i = .TRUE. -@end smallexample - -However, there is no implicit conversion of @code{INTEGER} values in -@code{if}-statements, nor of @code{LOGICAL} or @code{INTEGER} values -in I/O operations. - -@node Hollerith constants support -@subsection Hollerith constants support -@cindex Hollerith constants - -GNU Fortran supports Hollerith constants in assignments, @code{DATA} -statements, function and subroutine arguments. A Hollerith constant is -written as a string of characters preceded by an integer constant -indicating the character count, and the letter @code{H} or -@code{h}, and stored in bytewise fashion in a numeric (@code{INTEGER}, -@code{REAL}, or @code{COMPLEX}), @code{LOGICAL} or @code{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: -@smallexample - complex*16 x(2) - data x /16Habcdefghijklmnop, 16Hqrstuvwxyz012345/ - x(1) = 16HABCDEFGHIJKLMNOP - call foo (4h abc) -@end smallexample - -Examples of Hollerith constants: -@smallexample - integer*4 a - a = 0H ! Invalid, at least one character is needed. - a = 4HAB12 ! Valid - a = 8H12345678 ! Valid, but the Hollerith constant will be truncated. - a = 3Hxyz ! Valid, but the Hollerith constant will be padded. -@end smallexample - -In general, Hollerith constants were used to provide a rudimentary -facility for handling character strings in early Fortran compilers, -prior to the introduction of @code{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 @code{TRANSFER} statement, as in this example. -@smallexample - integer(kind=4) :: a - a = transfer ("abcd", a) ! equivalent to: a = 4Habcd -@end smallexample - -The use of the @option{-fdec} option extends support of Hollerith constants -to comparisons: -@smallexample - integer*4 a - a = 4hABCD - if (a .ne. 4habcd) then - write(*,*) "no match" - end if -@end smallexample - -Supported types are numeric (@code{INTEGER}, @code{REAL}, or @code{COMPLEX}), -and @code{CHARACTER}. - -@node Character conversion -@subsection Character conversion -@cindex conversion, to character - -Allowing character literals to be used in a similar way to Hollerith constants -is a non-standard extension. This feature is enabled using --fdec-char-conversions and only applies to character literals of @code{kind=1}. - -Character literals can be used in @code{DATA} statements and assignments with -numeric (@code{INTEGER}, @code{REAL}, or @code{COMPLEX}) or @code{LOGICAL} -variables. Like Hollerith constants they are copied byte-wise fashion. The -constant will be padded with spaces or truncated to fit the size of the -variable in which it is stored. - -Examples: -@smallexample - integer*4 x - data x / 'abcd' / - - x = 'A' ! Will be padded. - x = 'ab1234' ! Will be truncated. -@end smallexample - - -@node Cray pointers -@subsection Cray pointers -@cindex pointer, Cray - -Cray pointers are part of a non-standard extension that provides a -C-like pointer in Fortran. This is accomplished through a pair of -variables: an integer "pointer" that holds a memory address, and a -"pointee" that is used to dereference the pointer. - -Pointer/pointee pairs are declared in statements of the form: -@smallexample - pointer ( <pointer> , <pointee> ) -@end smallexample -or, -@smallexample - pointer ( <pointer1> , <pointee1> ), ( <pointer2> , <pointee2> ), ... -@end smallexample -The pointer is an integer that is intended to hold a memory address. -The pointee may be an array or scalar. -If an assumed-size array is permitted within the scoping unit, a -pointee can be an assumed-size array. -That is, the last dimension may be left unspecified by using a @code{*} -in place of a value. A pointee cannot be an assumed shape array. -No space is allocated for the pointee. - -The pointee may have its type declared before or after the pointer -statement, and its array specification (if any) may be declared -before, during, or after the pointer statement. The pointer may be -declared as an integer prior to the pointer statement. However, some -machines have default integer sizes that are different than the size -of a pointer, and so the following code is not portable: -@smallexample - integer ipt - pointer (ipt, iarr) -@end smallexample -If a pointer is declared with a kind that is too small, the compiler -will issue a warning; the resulting binary will probably not work -correctly, because the memory addresses stored in the pointers may be -truncated. It is safer to omit the first line of the above example; -if explicit declaration of ipt's type is omitted, then the compiler -will ensure that ipt is an integer variable large enough to hold a -pointer. - -Pointer arithmetic is valid with Cray pointers, but it is not the same -as C pointer arithmetic. Cray pointers are just ordinary integers, so -the user is responsible for determining how many bytes to add to a -pointer in order to increment it. Consider the following example: -@smallexample - real target(10) - real pointee(10) - pointer (ipt, pointee) - ipt = loc (target) - ipt = ipt + 1 -@end smallexample -The last statement does not set @code{ipt} to the address of -@code{target(1)}, as it would in C pointer arithmetic. Adding @code{1} -to @code{ipt} just adds one byte to the address stored in @code{ipt}. - -Any expression involving the pointee will be translated to use the -value stored in the pointer as the base address. - -To get the address of elements, this extension provides an intrinsic -function @code{LOC()}. The @code{LOC()} function is equivalent to the -@code{&} operator in C, except the address is cast to an integer type: -@smallexample - real ar(10) - pointer(ipt, arpte(10)) - real arpte - ipt = loc(ar) ! Makes arpte is an alias for ar - arpte(1) = 1.0 ! Sets ar(1) to 1.0 -@end smallexample -The pointer can also be set by a call to the @code{MALLOC} intrinsic -(see @ref{MALLOC}). - -Cray pointees often are used to alias an existing variable. For -example: -@smallexample - integer target(10) - integer iarr(10) - pointer (ipt, iarr) - ipt = loc(target) -@end smallexample -As long as @code{ipt} remains unchanged, @code{iarr} is now an alias for -@code{target}. The optimizer, however, will not detect this aliasing, so -it is unsafe to use @code{iarr} and @code{target} simultaneously. Using -a pointee in any way that violates the Fortran aliasing rules or -assumptions is illegal. It is the user's responsibility to avoid doing -this; the compiler works under the assumption that no such aliasing -occurs. - -Cray pointers will work correctly when there is no aliasing (i.e., when -they are used to access a dynamically allocated block of memory), and -also in any routine where a pointee is used, but any variable with which -it shares storage is not used. Code that violates these rules may not -run as the user intends. This is not a bug in the optimizer; any code -that violates the aliasing rules is illegal. (Note that this is not -unique to GNU Fortran; any Fortran compiler that supports Cray pointers -will ``incorrectly'' optimize code with illegal aliasing.) - -There are a number of restrictions on the attributes that can be applied -to Cray pointers and pointees. Pointees may not have the -@code{ALLOCATABLE}, @code{INTENT}, @code{OPTIONAL}, @code{DUMMY}, -@code{TARGET}, @code{INTRINSIC}, or @code{POINTER} attributes. Pointers -may not have the @code{DIMENSION}, @code{POINTER}, @code{TARGET}, -@code{ALLOCATABLE}, @code{EXTERNAL}, or @code{INTRINSIC} attributes, nor -may they be function results. 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: -@smallexample - implicit none - external sub - pointer (subptr,subpte) - external subpte - subptr = loc(sub) - call subpte() - [...] - subroutine sub - [...] - end subroutine sub -@end smallexample - -A pointer may be modified during the course of a program, and this -will change the location to which the pointee refers. However, when -pointees are passed as arguments, they are treated as ordinary -variables in the invoked function. Subsequent changes to the pointer -will not change the base address of the array that was passed. - -@node CONVERT specifier -@subsection @code{CONVERT} specifier -@cindex @code{CONVERT} specifier - -GNU Fortran allows the conversion of unformatted data between little- -and big-endian representation to facilitate moving of data -between different systems. The conversion can be indicated with -the @code{CONVERT} specifier on the @code{OPEN} statement. -@xref{GFORTRAN_CONVERT_UNIT}, for an alternative way of specifying -the data format via an environment variable. - -Valid values for @code{CONVERT} on most systems are: -@itemize @w{} -@item @code{CONVERT='NATIVE'} Use the native format. This is the default. -@item @code{CONVERT='SWAP'} Swap between little- and big-endian. -@item @code{CONVERT='LITTLE_ENDIAN'} Use the little-endian representation -for unformatted files. -@item @code{CONVERT='BIG_ENDIAN'} Use the big-endian representation for -unformatted files. -@end itemize -On POWER systems which support @option{-mabi=ieeelongdouble}, -there are additional options, which can be combined with the others -with commas. Those are -@itemize @w{} -@item @code{CONVERT='R16_IEEE'} Use IEEE 128-bit format for -@code{REAL(KIND=16)}. -@item @code{CONVERT='R16_IBM'} Use IBM @code{long double} format for -real@code{REAL(KIND=16)}. -@end itemize - -Using the option could look like this: -@smallexample - open(file='big.dat',form='unformatted',access='sequential', & - convert='big_endian') -@end smallexample - -The value of the conversion can be queried by using -@code{INQUIRE(CONVERT=ch)}. The values returned are -@code{'BIG_ENDIAN'} and @code{'LITTLE_ENDIAN'}. - -@code{CONVERT} works between big- and little-endian for -@code{INTEGER} values of all supported kinds and for @code{REAL} -on IEEE systems of kinds 4 and 8. Conversion between different -``extended double'' types on different architectures such as -m68k and x86_64, which GNU Fortran -supports as @code{REAL(KIND=10)} and @code{REAL(KIND=16)}, will -probably not work. - -@emph{Note that the values specified via the GFORTRAN_CONVERT_UNIT -environment variable will override the CONVERT specifier in the -open statement}. This is to give control over data formats to -users who do not have the source code of their program available. - -Using anything but the native representation for unformatted data -carries a significant speed overhead. If speed in this area matters -to you, it is best if you use this only for data that needs to be -portable. - -@node OpenMP -@subsection OpenMP -@cindex OpenMP - -OpenMP (Open Multi-Processing) is an application programming -interface (API) that supports multi-platform shared memory -multiprocessing programming in C/C++ and Fortran on many -architectures, including Unix and Microsoft Windows platforms. -It consists of a set of compiler directives, library routines, -and environment variables that influence run-time behavior. - -GNU Fortran strives to be compatible to the -@uref{https://openmp.org/specifications/, -OpenMP Application Program Interface v4.5}. - -To enable the processing of the OpenMP directive @code{!$omp} in -free-form source code; the @code{c$omp}, @code{*$omp} and @code{!$omp} -directives in fixed form; the @code{!$} conditional compilation sentinels -in free form; and the @code{c$}, @code{*$} and @code{!$} sentinels -in fixed form, @command{gfortran} needs to be invoked with the -@option{-fopenmp}. This also arranges for automatic linking of the -GNU Offloading and Multi Processing Runtime Library -@ref{Top,,libgomp,libgomp,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 @code{omp_lib} and in a form of -a Fortran @code{include} file named @file{omp_lib.h}. - -An example of a parallelized loop taken from Appendix A.1 of -the OpenMP Application Program Interface v2.5: -@smallexample -SUBROUTINE A1(N, A, B) - INTEGER I, N - REAL B(N), A(N) -!$OMP PARALLEL DO !I is private by default - DO I=2,N - B(I) = (A(I) + A(I-1)) / 2.0 - ENDDO -!$OMP END PARALLEL DO -END SUBROUTINE A1 -@end smallexample - -Please note: -@itemize -@item -@option{-fopenmp} implies @option{-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. - -@item -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 -@command{-Wl,--whole-archive -lpthread -Wl,--no-whole-archive} is added -to the command line. However, this is not supported by @command{gcc} and -thus not recommended. -@end itemize - -@node OpenACC -@subsection OpenACC -@cindex 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 -@uref{https://www.openacc.org/, OpenACC Application Programming -Interface v2.6}. - -To enable the processing of the OpenACC directive @code{!$acc} in -free-form source code; the @code{c$acc}, @code{*$acc} and @code{!$acc} -directives in fixed form; the @code{!$} conditional compilation -sentinels in free form; and the @code{c$}, @code{*$} and @code{!$} -sentinels in fixed form, @command{gfortran} needs to be invoked with -the @option{-fopenacc}. This also arranges for automatic linking of -the GNU Offloading and Multi Processing Runtime Library -@ref{Top,,libgomp,libgomp,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 @code{openacc} and in a form of a -Fortran @code{include} file named @file{openacc_lib.h}. - -@node Argument list functions -@subsection Argument list functions @code{%VAL}, @code{%REF} and @code{%LOC} -@cindex argument list functions -@cindex @code{%VAL} -@cindex @code{%REF} -@cindex @code{%LOC} - -GNU Fortran supports argument list functions @code{%VAL}, @code{%REF} -and @code{%LOC} statements, for backward compatibility with g77. -It is recommended that these should be used only for code that is -accessing facilities outside of GNU Fortran, such as operating system -or windowing facilities. It is best to constrain such uses to isolated -portions of a program--portions that deal specifically and exclusively -with low-level, system-dependent facilities. Such portions might well -provide a portable interface for use by the program as a whole, but are -themselves not portable, and should be thoroughly tested each time they -are rebuilt using a new compiler or version of a compiler. - -@code{%VAL} passes a scalar argument by value, @code{%REF} passes it by -reference and @code{%LOC} passes its memory location. Since gfortran -already passes scalar arguments by reference, @code{%REF} is in effect -a do-nothing. @code{%LOC} has the same effect as a Fortran pointer. - -An example of passing an argument by value to a C subroutine foo.: -@smallexample -C -C prototype void foo_ (float x); -C - external foo - real*4 x - x = 3.14159 - call foo (%VAL (x)) - end -@end smallexample - -For details refer to the g77 manual -@uref{https://gcc.gnu.org/@/onlinedocs/@/gcc-3.4.6/@/g77/@/index.html#Top}. - -Also, @code{c_by_val.f} and its partner @code{c_by_val.c} of the -GNU Fortran testsuite are worth a look. - -@node Read/Write after EOF marker -@subsection Read/Write after EOF marker -@cindex @code{EOF} -@cindex @code{BACKSPACE} -@cindex @code{REWIND} - -Some legacy codes rely on allowing @code{READ} or @code{WRITE} after the -EOF file marker in order to find the end of a file. GNU Fortran normally -rejects these codes with a run-time error message and suggests the user -consider @code{BACKSPACE} or @code{REWIND} to properly position -the file before the EOF marker. As an extension, the run-time error may -be disabled using -std=legacy. - - -@node STRUCTURE and RECORD -@subsection @code{STRUCTURE} and @code{RECORD} -@cindex @code{STRUCTURE} -@cindex @code{RECORD} - -Record structures are a pre-Fortran-90 vendor extension to create -user-defined aggregate data types. Support for record structures in GNU -Fortran can be enabled with the @option{-fdec-structure} compile flag. -If you have a choice, you should instead use Fortran 90's ``derived types'', -which have a different syntax. - -In many cases, record structures can easily be converted to derived types. -To convert, replace @code{STRUCTURE /}@var{structure-name}@code{/} -by @code{TYPE} @var{type-name}. Additionally, replace -@code{RECORD /}@var{structure-name}@code{/} by -@code{TYPE(}@var{type-name}@code{)}. Finally, in the component access, -replace the period (@code{.}) by the percent sign (@code{%}). - -Here is an example of code using the non portable record structure syntax: - -@example -! Declaring a structure named ``item'' and containing three fields: -! an integer ID, an description string and a floating-point price. -STRUCTURE /item/ - INTEGER id - CHARACTER(LEN=200) description - REAL price -END STRUCTURE - -! Define two variables, an single record of type ``item'' -! named ``pear'', and an array of items named ``store_catalog'' -RECORD /item/ pear, store_catalog(100) - -! We can directly access the fields of both variables -pear.id = 92316 -pear.description = "juicy D'Anjou pear" -pear.price = 0.15 -store_catalog(7).id = 7831 -store_catalog(7).description = "milk bottle" -store_catalog(7).price = 1.2 - -! We can also manipulate the whole structure -store_catalog(12) = pear -print *, store_catalog(12) -@end example - -@noindent -This code can easily be rewritten in the Fortran 90 syntax as following: - -@example -! ``STRUCTURE /name/ ... END STRUCTURE'' becomes -! ``TYPE name ... END TYPE'' -TYPE item - INTEGER id - CHARACTER(LEN=200) description - REAL price -END TYPE - -! ``RECORD /name/ variable'' becomes ``TYPE(name) variable'' -TYPE(item) pear, store_catalog(100) - -! Instead of using a dot (.) to access fields of a record, the -! standard syntax uses a percent sign (%) -pear%id = 92316 -pear%description = "juicy D'Anjou pear" -pear%price = 0.15 -store_catalog(7)%id = 7831 -store_catalog(7)%description = "milk bottle" -store_catalog(7)%price = 1.2 - -! Assignments of a whole variable do not change -store_catalog(12) = pear -print *, store_catalog(12) -@end example - -@noindent -GNU Fortran implements STRUCTURES like derived types with the following -rules and exceptions: - -@itemize @bullet -@item Structures act like derived types with the @code{SEQUENCE} attribute. -Otherwise they may contain no specifiers. - -@item Structures may contain a special field with the name @code{%FILL}. -This will create an anonymous component which cannot be accessed but occupies -space just as if a component of the same type was declared in its place, useful -for alignment purposes. As an example, the following structure will consist -of at least sixteen bytes: - -@smallexample -structure /padded/ - character(4) start - character(8) %FILL - character(4) end -end structure -@end smallexample - -@item Structures may share names with other symbols. For example, the following -is invalid for derived types, but valid for structures: - -@smallexample -structure /header/ - ! ... -end structure -record /header/ header -@end smallexample - -@item Structure types may be declared nested within another parent structure. -The syntax is: -@smallexample -structure /type-name/ - ... - structure [/<type-name>/] <field-list> -... -@end smallexample - -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: - -@example -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 - -! The 'time' structure is still usable -record /time/ now -now = time(5, 30) - -... - -structure /appointment/ - ! anonymous nested structure definition - structure start, end - integer(1) hour, minute - end structure - character(10) memo -end structure -@end example - -@item Structures may contain @code{UNION} blocks. For more detail see the -section on @ref{UNION and MAP}. - -@item Structures support old-style initialization of components, like -those described in @ref{Old-style variable initialization}. For array -initializers, an initializer may contain a repeat specification of the form -@code{<literal-integer> * <constant-initializer>}. The value of the integer -indicates the number of times to repeat the constant initializer when expanding -the initializer list. -@end itemize - -@node UNION and MAP -@subsection @code{UNION} and @code{MAP} -@cindex @code{UNION} -@cindex @code{MAP} - -Unions are an old vendor extension which were commonly used with the -non-standard @ref{STRUCTURE and RECORD} extensions. Use of @code{UNION} and -@code{MAP} is automatically enabled with @option{-fdec-structure}. - -A @code{UNION} declaration occurs within a structure; within the definition of -each union is a number of @code{MAP} blocks. Each @code{MAP} shares storage -with its sibling maps (in the same union), and the size of the union is the -size of the largest map within it, just as with unions in C. 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: -@smallexample -structure /myunion/ -union - map - character(2) w0, w1, w2 - end map - map - character(6) long - end map -end union -end structure - -record /myunion/ rec -! After this assignment... -rec.long = 'hello!' - -! The following is true: -! rec.w0 === 'he' -! rec.w1 === 'll' -! rec.w2 === 'o!' -@end smallexample - -The two maps share memory, and the size of the union is ultimately six bytes: - -@example -0 1 2 3 4 5 6 Byte offset -------------------------------- -| | | | | | | -------------------------------- - -^ W0 ^ W1 ^ W2 ^ - \-------/ \-------/ \-------/ - -^ LONG ^ - \---------------------------/ -@end example - -Following is an example mirroring the layout of an Intel x86_64 register: - -@example -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 - 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 - -! After this assignment... -a.rx = 'AAAAAAAA.BBB.C.D' - -! The following is true: -a.rx === 'AAAAAAAA.BBB.C.D' -a.rh === 'AAAAAAAA' -a.rl === '.BBB.C.D' -a.ex === '.BBB.C.D' -a.eh === '.BBB' -a.el === '.C.D' -a.x === '.C.D' -a.h === '.C' -a.l === '.D' -@end example - -@node Type variants for integer intrinsics -@subsection Type variants for integer intrinsics -@cindex intrinsics, integer - -Similar to the D/C prefixes to real functions to specify the input/output -types, GNU Fortran offers B/I/J/K prefixes to integer functions for -compatibility with DEC programs. The types implied by each are: - -@example -@code{B} - @code{INTEGER(kind=1)} -@code{I} - @code{INTEGER(kind=2)} -@code{J} - @code{INTEGER(kind=4)} -@code{K} - @code{INTEGER(kind=8)} -@end example - -GNU Fortran supports these with the flag @option{-fdec-intrinsic-ints}. -Intrinsics for which prefixed versions are available and in what form are noted -in @ref{Intrinsic Procedures}. The complete list of supported intrinsics is -here: - -@multitable @columnfractions .2 .2 .2 .2 .2 - -@headitem Intrinsic @tab B @tab I @tab J @tab K - -@item @code{@ref{ABS}} - @tab @code{BABS} @tab @code{IIABS} @tab @code{JIABS} @tab @code{KIABS} -@item @code{@ref{BTEST}} - @tab @code{BBTEST} @tab @code{BITEST} @tab @code{BJTEST} @tab @code{BKTEST} -@item @code{@ref{IAND}} - @tab @code{BIAND} @tab @code{IIAND} @tab @code{JIAND} @tab @code{KIAND} -@item @code{@ref{IBCLR}} - @tab @code{BBCLR} @tab @code{IIBCLR} @tab @code{JIBCLR} @tab @code{KIBCLR} -@item @code{@ref{IBITS}} - @tab @code{BBITS} @tab @code{IIBITS} @tab @code{JIBITS} @tab @code{KIBITS} -@item @code{@ref{IBSET}} - @tab @code{BBSET} @tab @code{IIBSET} @tab @code{JIBSET} @tab @code{KIBSET} -@item @code{@ref{IEOR}} - @tab @code{BIEOR} @tab @code{IIEOR} @tab @code{JIEOR} @tab @code{KIEOR} -@item @code{@ref{IOR}} - @tab @code{BIOR} @tab @code{IIOR} @tab @code{JIOR} @tab @code{KIOR} -@item @code{@ref{ISHFT}} - @tab @code{BSHFT} @tab @code{IISHFT} @tab @code{JISHFT} @tab @code{KISHFT} -@item @code{@ref{ISHFTC}} - @tab @code{BSHFTC} @tab @code{IISHFTC} @tab @code{JISHFTC} @tab @code{KISHFTC} -@item @code{@ref{MOD}} - @tab @code{BMOD} @tab @code{IMOD} @tab @code{JMOD} @tab @code{KMOD} -@item @code{@ref{NOT}} - @tab @code{BNOT} @tab @code{INOT} @tab @code{JNOT} @tab @code{KNOT} -@item @code{@ref{REAL}} - @tab @code{--} @tab @code{FLOATI} @tab @code{FLOATJ} @tab @code{FLOATK} -@end multitable - -@node AUTOMATIC and STATIC attributes -@subsection @code{AUTOMATIC} and @code{STATIC} attributes -@cindex variable attributes -@cindex @code{AUTOMATIC} -@cindex @code{STATIC} - -With @option{-fdec-static} GNU Fortran supports the DEC extended attributes -@code{STATIC} and @code{AUTOMATIC} to provide explicit specification of entity -storage. These follow the syntax of the Fortran standard @code{SAVE} attribute. - -@code{STATIC} is exactly equivalent to @code{SAVE}, and specifies that -an entity should be allocated in static memory. As an example, @code{STATIC} -local variables will retain their values across multiple calls to a function. - -Entities marked @code{AUTOMATIC} will be stack automatic whenever possible. -@code{AUTOMATIC} is the default for local variables smaller than -@option{-fmax-stack-var-size}, unless @option{-fno-automatic} is given. This -attribute overrides @option{-fno-automatic}, @option{-fmax-stack-var-size}, and -blanket @code{SAVE} statements. - - -Examples: - -@example -subroutine f - integer, automatic :: i ! automatic variable - integer x, y ! static variables - save - ... -endsubroutine -@end example -@example -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 -@end example -@example -! Compiled with -fno-automatic -subroutine f - integer a, b, c, d - automatic :: a - ! a is automatic; b, c, and d are static -endsubroutine -@end example - -@node Extended math intrinsics -@subsection Extended math intrinsics -@cindex intrinsics, math -@cindex intrinsics, trigonometric functions - -GNU Fortran supports an extended list of mathematical intrinsics with the -compile flag @option{-fdec-math} for compatability with legacy code. -These intrinsics are described fully in @ref{Intrinsic Procedures} where it is -noted that they are extensions and should be avoided whenever possible. - -Specifically, @option{-fdec-math} enables the @ref{COTAN} intrinsic, and -trigonometric intrinsics which accept or produce values in degrees instead of -radians. Here is a summary of the new intrinsics: - -@multitable @columnfractions .5 .5 -@headitem Radians @tab Degrees -@item @code{@ref{ACOS}} @tab @code{@ref{ACOSD}}* -@item @code{@ref{ASIN}} @tab @code{@ref{ASIND}}* -@item @code{@ref{ATAN}} @tab @code{@ref{ATAND}}* -@item @code{@ref{ATAN2}} @tab @code{@ref{ATAN2D}}* -@item @code{@ref{COS}} @tab @code{@ref{COSD}}* -@item @code{@ref{COTAN}}* @tab @code{@ref{COTAND}}* -@item @code{@ref{SIN}} @tab @code{@ref{SIND}}* -@item @code{@ref{TAN}} @tab @code{@ref{TAND}}* -@end multitable - -* Enabled with @option{-fdec-math}. - -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). - -@node Form feed as whitespace -@subsection Form feed as whitespace -@cindex form feed whitespace - -Historically, legacy compilers allowed insertion of form feed characters ('\f', -ASCII 0xC) at the beginning of lines for formatted output to line printers, -though the Fortran standard does not mention this. GNU Fortran supports the -interpretation of form feed characters in source as whitespace for -compatibility. - -@node TYPE as an alias for PRINT -@subsection TYPE as an alias for PRINT -@cindex type alias print -For compatibility, GNU Fortran will interpret @code{TYPE} statements as -@code{PRINT} statements with the flag @option{-fdec}. With this flag asserted, -the following two examples are equivalent: - -@smallexample -TYPE *, 'hello world' -@end smallexample - -@smallexample -PRINT *, 'hello world' -@end smallexample - -@node %LOC as an rvalue -@subsection %LOC as an rvalue -@cindex LOC -Normally @code{%LOC} is allowed only in parameter lists. However the intrinsic -function @code{LOC} does the same thing, and is usable as the right-hand-side of -assignments. For compatibility, GNU Fortran supports the use of @code{%LOC} as -an alias for the builtin @code{LOC} with @option{-std=legacy}. With this -feature enabled the following two examples are equivalent: - -@smallexample -integer :: i, l -l = %loc(i) -call sub(l) -@end smallexample - -@smallexample -integer :: i -call sub(%loc(i)) -@end smallexample - -@node .XOR. operator -@subsection .XOR. operator -@cindex operators, xor - -GNU Fortran supports @code{.XOR.} as a logical operator with @code{-std=legacy} -for compatibility with legacy code. @code{.XOR.} is equivalent to -@code{.NEQV.}. That is, the output is true if and only if the inputs differ. - -@node Bitwise logical operators -@subsection Bitwise logical operators -@cindex logical, bitwise - -With @option{-fdec}, GNU Fortran relaxes the type constraints on -logical operators to allow integer operands, and performs the corresponding -bitwise operation instead. This flag is for compatibility only, and should be -avoided in new code. Consider: - -@smallexample - INTEGER :: i, j - i = z'33' - j = z'cc' - print *, i .AND. j -@end smallexample - -In this example, compiled with @option{-fdec}, GNU Fortran will -replace the @code{.AND.} operation with a call to the intrinsic -@code{@ref{IAND}} function, yielding the bitwise-and of @code{i} and @code{j}. - -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, -@code{.TRUE.} is converted to @code{1} and @code{.FALSE.} to @code{0}. - -Here is the mapping of logical operator to bitwise intrinsic used with -@option{-fdec}: - -@multitable @columnfractions .25 .25 .5 -@headitem Operator @tab Intrinsic @tab Bitwise operation -@item @code{.NOT.} @tab @code{@ref{NOT}} @tab complement -@item @code{.AND.} @tab @code{@ref{IAND}} @tab intersection -@item @code{.OR.} @tab @code{@ref{IOR}} @tab union -@item @code{.NEQV.} @tab @code{@ref{IEOR}} @tab exclusive or -@item @code{.EQV.} @tab @code{@ref{NOT}(@ref{IEOR})} @tab complement of exclusive or -@end multitable - -@node Extended I/O specifiers -@subsection Extended I/O specifiers -@cindex @code{CARRIAGECONTROL} -@cindex @code{READONLY} -@cindex @code{SHARE} -@cindex @code{SHARED} -@cindex @code{NOSHARED} -@cindex I/O specifiers - -GNU Fortran supports the additional legacy I/O specifiers -@code{CARRIAGECONTROL}, @code{READONLY}, and @code{SHARE} with the -compile flag @option{-fdec}, for compatibility. - -@table @code -@item CARRIAGECONTROL -The @code{CARRIAGECONTROL} specifier allows a user to control line -termination settings between output records for an I/O unit. The specifier has -no meaning for readonly files. When @code{CARRAIGECONTROL} is specified upon -opening a unit for formatted writing, the exact @code{CARRIAGECONTROL} setting -determines what characters to write between output records. The syntax is: - -@smallexample -OPEN(..., CARRIAGECONTROL=cc) -@end smallexample - -Where @emph{cc} is a character expression that evaluates to one of the -following values: - -@multitable @columnfractions .2 .8 -@item @code{'LIST'} @tab One line feed between records (default) -@item @code{'FORTRAN'} @tab Legacy interpretation of the first character (see below) -@item @code{'NONE'} @tab No separator between records -@end multitable - -With @code{CARRIAGECONTROL='FORTRAN'}, when a record is written, the first -character of the input record is not written, and instead determines the output -record separator as follows: - -@multitable @columnfractions .3 .3 .4 -@headitem Leading character @tab Meaning @tab Output separating character(s) -@item @code{'+'} @tab Overprinting @tab Carriage return only -@item @code{'-'} @tab New line @tab Line feed and carriage return -@item @code{'0'} @tab Skip line @tab Two line feeds and carriage return -@item @code{'1'} @tab New page @tab Form feed and carriage return -@item @code{'$'} @tab Prompting @tab Line feed (no carriage return) -@item @code{CHAR(0)} @tab Overprinting (no advance) @tab None -@end multitable - -@item READONLY -The @code{READONLY} specifier may be given upon opening a unit, and is -equivalent to specifying @code{ACTION='READ'}, except that the file may not be -deleted on close (i.e. @code{CLOSE} with @code{STATUS="DELETE"}). The syntax -is: - -@smallexample -@code{OPEN(..., READONLY)} -@end smallexample - -@item SHARE -The @code{SHARE} specifier allows system-level locking on a unit upon opening -it for controlled access from multiple processes/threads. The @code{SHARE} -specifier has several forms: - -@smallexample -OPEN(..., SHARE=sh) -OPEN(..., SHARED) -OPEN(..., NOSHARED) -@end smallexample - -Where @emph{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 @emph{sh}: - -@multitable @columnfractions .3 .3 .4 -@headitem Explicit form @tab Short form @tab Meaning -@item @code{SHARE='DENYRW'} @tab @code{NOSHARED} @tab Exclusive (write) lock -@item @code{SHARE='DENYNONE'} @tab @code{SHARED} @tab Shared (read) lock -@end multitable - -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 @code{fcntl}. Consult your corresponding operating -system's manual pages for further details. Locking via @code{SHARE=} is not -supported on other systems. - -@end table - -@node Legacy PARAMETER statements -@subsection Legacy PARAMETER statements -@cindex PARAMETER - -For compatibility, GNU Fortran supports legacy PARAMETER statements without -parentheses with @option{-std=legacy}. A warning is emitted if used with -@option{-std=gnu}, and an error is acknowledged with a real Fortran standard -flag (@option{-std=f95}, etc...). These statements take the following form: - -@smallexample -implicit real (E) -parameter e = 2.718282 -real c -parameter c = 3.0e8 -@end smallexample - -@node Default exponents -@subsection Default exponents -@cindex exponent - -For compatibility, GNU Fortran supports a default exponent of zero in real -constants with @option{-fdec}. For example, @code{9e} would be -interpreted as @code{9e0}, rather than an error. - - -@node Extensions not implemented in GNU Fortran -@section Extensions not implemented in GNU Fortran -@cindex extensions, not implemented - -The long history of the Fortran language, its wide use and broad -userbase, the large number of different compiler vendors and the lack of -some features crucial to users in the first standards have lead to the -existence of a number of important extensions to the language. While -some of the most useful or popular extensions are supported by the GNU -Fortran compiler, not all existing extensions are supported. This section -aims at listing these extensions and offering advice on how best make -code that uses them running with the GNU Fortran compiler. - -@c More can be found here: -@c -- https://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/Missing-Features.html -@c -- the list of Fortran and libgfortran bugs closed as WONTFIX: -@c http://tinyurl.com/2u4h5y - -@menu -* ENCODE and DECODE statements:: -* Variable FORMAT expressions:: -@c * TYPE and ACCEPT I/O Statements:: -@c * DEFAULTFILE, DISPOSE and RECORDTYPE I/O specifiers:: -@c * Omitted arguments in procedure call:: -* Alternate complex function syntax:: -* Volatile COMMON blocks:: -* OPEN( ... NAME=):: -* Q edit descriptor:: -@end menu - -@node ENCODE and DECODE statements -@subsection @code{ENCODE} and @code{DECODE} statements -@cindex @code{ENCODE} -@cindex @code{DECODE} - -GNU Fortran does not support the @code{ENCODE} and @code{DECODE} -statements. These statements are best replaced by @code{READ} and -@code{WRITE} statements involving internal files (@code{CHARACTER} -variables and arrays), which have been part of the Fortran standard since -Fortran 77. For example, replace a code fragment like - -@smallexample - INTEGER*1 LINE(80) - REAL A, B, C -c ... Code that sets LINE - DECODE (80, 9000, LINE) A, B, C - 9000 FORMAT (1X, 3(F10.5)) -@end smallexample - -@noindent -with the following: - -@smallexample - CHARACTER(LEN=80) LINE - REAL A, B, C -c ... Code that sets LINE - READ (UNIT=LINE, FMT=9000) A, B, C - 9000 FORMAT (1X, 3(F10.5)) -@end smallexample - -Similarly, replace a code fragment like - -@smallexample - INTEGER*1 LINE(80) - REAL A, B, C -c ... Code that sets A, B and C - ENCODE (80, 9000, LINE) A, B, C - 9000 FORMAT (1X, 'OUTPUT IS ', 3(F10.5)) -@end smallexample - -@noindent -with the following: - -@smallexample - CHARACTER(LEN=80) LINE - REAL A, B, C -c ... Code that sets A, B and C - WRITE (UNIT=LINE, FMT=9000) A, B, C - 9000 FORMAT (1X, 'OUTPUT IS ', 3(F10.5)) -@end smallexample - - -@node Variable FORMAT expressions -@subsection Variable @code{FORMAT} expressions -@cindex @code{FORMAT} - -A variable @code{FORMAT} expression is format statement which includes -angle brackets enclosing a Fortran expression: @code{FORMAT(I<N>)}. GNU -Fortran does not support this legacy extension. The effect of variable -format expressions can be reproduced by using the more powerful (and -standard) combination of internal output and string formats. For example, -replace a code fragment like this: - -@smallexample - WRITE(6,20) INT1 - 20 FORMAT(I<N+1>) -@end smallexample - -@noindent -with the following: - -@smallexample -c Variable declaration - CHARACTER(LEN=20) FMT -c -c Other code here... -c - WRITE(FMT,'("(I", I0, ")")') N+1 - WRITE(6,FMT) INT1 -@end smallexample - -@noindent -or with: - -@smallexample -c Variable declaration - CHARACTER(LEN=20) FMT -c -c Other code here... -c - WRITE(FMT,*) N+1 - WRITE(6,"(I" // ADJUSTL(FMT) // ")") INT1 -@end smallexample - - -@node Alternate complex function syntax -@subsection Alternate complex function syntax -@cindex Complex function - -Some Fortran compilers, including @command{g77}, let the user declare -complex functions with the syntax @code{COMPLEX FUNCTION name*16()}, as -well as @code{COMPLEX*16 FUNCTION name()}. Both are non-standard, legacy -extensions. @command{gfortran} accepts the latter form, which is more -common, but not the former. - - -@node Volatile COMMON blocks -@subsection Volatile @code{COMMON} blocks -@cindex @code{VOLATILE} -@cindex @code{COMMON} - -Some Fortran compilers, including @command{g77}, let the user declare -@code{COMMON} with the @code{VOLATILE} attribute. This is -invalid standard Fortran syntax and is not supported by -@command{gfortran}. Note that @command{gfortran} accepts -@code{VOLATILE} variables in @code{COMMON} blocks since revision 4.3. - - -@node OPEN( ... NAME=) -@subsection @code{OPEN( ... NAME=)} -@cindex @code{NAME} - -Some Fortran compilers, including @command{g77}, let the user declare -@code{OPEN( ... NAME=)}. This is -invalid standard Fortran syntax and is not supported by -@command{gfortran}. @code{OPEN( ... NAME=)} should be replaced -with @code{OPEN( ... FILE=)}. - -@node Q edit descriptor -@subsection @code{Q} edit descriptor -@cindex @code{Q} edit descriptor - -Some Fortran compilers provide the @code{Q} edit descriptor, which -transfers the number of characters left within an input record into an -integer variable. - -A direct replacement of the @code{Q} edit descriptor is not available -in @command{gfortran}. How to replicate its functionality using -standard-conforming code depends on what the intent of the original -code is. - -Options to replace @code{Q} may be to read the whole line into a -character variable and then counting the number of non-blank -characters left using @code{LEN_TRIM}. Another method may be to use -formatted stream, read the data up to the position where the @code{Q} -descriptor occurred, use @code{INQUIRE} to get the file position, -count the characters up to the next @code{NEW_LINE} and then start -reading from the position marked previously. - - -@c --------------------------------------------------------------------- -@c --------------------------------------------------------------------- -@c Mixed-Language Programming -@c --------------------------------------------------------------------- - -@node Mixed-Language Programming -@chapter Mixed-Language Programming -@cindex Interoperability -@cindex Mixed-language programming - -@menu -* Interoperability with C:: -* GNU Fortran Compiler Directives:: -* Non-Fortran Main Program:: -* Naming and argument-passing conventions:: -@end menu - -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 @code{extern "C"} on -the C++ side and @code{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 @command{gfortran} command to link both Fortran and -non-Fortran code into the same program, or you can use @command{gcc} -or @command{g++} if you also add an explicit @option{-lgfortran} option -to link with the Fortran library. If your main program is written in -C or some other language instead of Fortran, see -@ref{Non-Fortran Main Program}, below. - -@node Interoperability with C -@section Interoperability with C -@cindex interoperability with C -@cindex C interoperability - -@menu -* Intrinsic Types:: -* Derived Types and struct:: -* Interoperable Global Variables:: -* Interoperable Subroutines and Functions:: -* Working with C Pointers:: -* Further Interoperability of Fortran with C:: -@end menu - -Since Fortran 2003 (ISO/IEC 1539-1:2004(E)) there is a -standardized way to generate procedure and derived-type -declarations and global variables that are interoperable with C -(ISO/IEC 9899:1999). The @code{BIND(C)} attribute has been added -to inform the compiler that a symbol shall be interoperable with C; -also, some constraints are added. Note, however, that not -all C features have a Fortran equivalent or vice versa. For instance, -neither C's unsigned integers nor C's functions with variable number -of arguments have an equivalent in Fortran. - -Note that array dimensions are reversely ordered in C and that arrays in -C always start with index 0 while in Fortran they start by default with -1. Thus, an array declaration @code{A(n,m)} in Fortran matches -@code{A[m][n]} in C and accessing the element @code{A(i,j)} matches -@code{A[j-1][i-1]}. The element following @code{A(i,j)} (C: @code{A[j-1][i-1]}; -assuming @math{i < n}) in memory is @code{A(i+1,j)} (C: @code{A[j-1][i]}). - -@node Intrinsic Types -@subsection Intrinsic Types -@cindex C intrinsic type interoperability -@cindex intrinsic type interoperability with C -@cindex interoperability, intrinsic type - -In order to ensure that exactly the same variable type and kind is used -in C and Fortran, you should use the named constants for kind parameters -that are defined in the @code{ISO_C_BINDING} intrinsic module. -That module contains named constants of character type representing -the escaped special characters in C, such as newline. -For a list of the constants, see @ref{ISO_C_BINDING}. - -For logical types, please note that the Fortran standard only guarantees -interoperability between C99's @code{_Bool} and Fortran's @code{C_Bool}-kind -logicals and C99 defines that @code{true} has the value 1 and @code{false} -the value 0. Using any other integer value with GNU Fortran's @code{LOGICAL} -(with any kind parameter) gives an undefined result. (Passing other integer -values than 0 and 1 to GCC's @code{_Bool} is also undefined, unless the -integer is explicitly or implicitly casted to @code{_Bool}.) - -@node Derived Types and struct -@subsection Derived Types and struct -@cindex C derived type and struct interoperability -@cindex derived type interoperability with C -@cindex interoperability, derived type and struct - -For compatibility of derived types with @code{struct}, use -the @code{BIND(C)} attribute in the type declaration. For instance, the -following type declaration - -@smallexample - USE ISO_C_BINDING - TYPE, BIND(C) :: myType - INTEGER(C_INT) :: i1, i2 - INTEGER(C_SIGNED_CHAR) :: i3 - REAL(C_DOUBLE) :: d1 - COMPLEX(C_FLOAT_COMPLEX) :: c1 - CHARACTER(KIND=C_CHAR) :: str(5) - END TYPE -@end smallexample - -@noindent -matches the following @code{struct} declaration in C - -@smallexample - struct @{ - int i1, i2; - /* Note: "char" might be signed or unsigned. */ - signed char i3; - double d1; - float _Complex c1; - char str[5]; - @} myType; -@end smallexample - -Derived types with the C binding attribute shall not have the @code{sequence} -attribute, type parameters, the @code{extends} attribute, nor type-bound -procedures. Every component must be of interoperable type and kind and may not -have the @code{pointer} or @code{allocatable} attribute. The names of the -components are irrelevant for interoperability. - -As there exist no direct Fortran equivalents, neither unions nor structs -with bit field or variable-length array members are interoperable. - -@node Interoperable Global Variables -@subsection Interoperable Global Variables -@cindex C variable interoperability -@cindex variable interoperability with C -@cindex interoperability, variable - -Variables can be made accessible from C using the C binding attribute, -optionally together with specifying a binding name. Those variables -have to be declared in the declaration part of a @code{MODULE}, -be of interoperable type, and have neither the @code{pointer} nor -the @code{allocatable} attribute. - -@smallexample - MODULE m - USE myType_module - USE ISO_C_BINDING - integer(C_INT), bind(C, name="_MyProject_flags") :: global_flag - type(myType), bind(C) :: tp - END MODULE -@end smallexample - -Here, @code{_MyProject_flags} is the case-sensitive name of the variable -as seen from C programs while @code{global_flag} is the case-insensitive -name as seen from Fortran. If no binding name is specified, as for -@var{tp}, the C binding name is the (lowercase) Fortran binding name. -If a binding name is specified, only a single variable may be after the -double colon. Note of warning: You cannot use a global variable to -access @var{errno} of the C library as the C standard allows it to be -a macro. Use the @code{IERRNO} intrinsic (GNU extension) instead. - -@node Interoperable Subroutines and Functions -@subsection Interoperable Subroutines and Functions -@cindex C procedure interoperability -@cindex procedure interoperability with C -@cindex function interoperability with C -@cindex subroutine interoperability with C -@cindex interoperability, subroutine and function - -Subroutines and functions have to have the @code{BIND(C)} attribute to -be compatible with C. The dummy argument declaration is relatively -straightforward. However, one needs to be careful because C uses -call-by-value by default while Fortran behaves usually similar to -call-by-reference. Furthermore, strings and pointers are handled -differently. - -To pass a variable by value, use the @code{VALUE} attribute. -Thus, the following C prototype - -@smallexample -@code{int func(int i, int *j)} -@end smallexample - -@noindent -matches the Fortran declaration - -@smallexample - integer(c_int) function func(i,j) - use iso_c_binding, only: c_int - integer(c_int), VALUE :: i - integer(c_int) :: j -@end smallexample - -Note that pointer arguments also frequently need the @code{VALUE} attribute, -see @ref{Working with C Pointers}. - -Strings are handled quite differently in C and Fortran. In C a string -is a @code{NUL}-terminated array of characters while in Fortran each string -has a length associated with it and is thus not terminated (by e.g. -@code{NUL}). For example, if you want to use the following C function, - -@smallexample - #include <stdio.h> - void print_C(char *string) /* equivalent: char string[] */ - @{ - printf("%s\n", string); - @} -@end smallexample - -@noindent -to print ``Hello World'' from Fortran, you can call it using - -@smallexample - use iso_c_binding, only: C_CHAR, C_NULL_CHAR - interface - subroutine print_c(string) bind(C, name="print_C") - use iso_c_binding, only: c_char - character(kind=c_char) :: string(*) - end subroutine print_c - end interface - call print_c(C_CHAR_"Hello World"//C_NULL_CHAR) -@end smallexample - -As the example shows, you need to ensure that the -string is @code{NUL} terminated. Additionally, the dummy argument -@var{string} of @code{print_C} is a length-one assumed-size -array; using @code{character(len=*)} is not allowed. The example -above uses @code{c_char_"Hello World"} to ensure the string -literal has the right type; typically the default character -kind and @code{c_char} are the same and thus @code{"Hello World"} -is equivalent. However, the standard does not guarantee this. - -The use of strings is now further illustrated using the C library -function @code{strncpy}, whose prototype is - -@smallexample - char *strncpy(char *restrict s1, const char *restrict s2, size_t n); -@end smallexample - -@noindent -The function @code{strncpy} copies at most @var{n} characters from -string @var{s2} to @var{s1} and returns @var{s1}. In the following -example, we ignore the return value: - -@smallexample - use iso_c_binding - implicit none - character(len=30) :: str,str2 - interface - ! Ignore the return value of strncpy -> subroutine - ! "restrict" is always assumed if we do not pass a pointer - subroutine strncpy(dest, src, n) bind(C) - import - character(kind=c_char), intent(out) :: dest(*) - character(kind=c_char), intent(in) :: src(*) - integer(c_size_t), value, intent(in) :: n - end subroutine strncpy - end interface - str = repeat('X',30) ! Initialize whole string with 'X' - call strncpy(str, c_char_"Hello World"//C_NULL_CHAR, & - len(c_char_"Hello World",kind=c_size_t)) - print '(a)', str ! prints: "Hello WorldXXXXXXXXXXXXXXXXXXX" - end -@end smallexample - -The intrinsic procedures are described in @ref{Intrinsic Procedures}. - -@node Working with C Pointers -@subsection Working with C Pointers -@cindex C pointers -@cindex pointers, C - -C pointers are represented in Fortran via the special opaque derived -type @code{type(c_ptr)} (with private components). C pointers are distinct -from Fortran objects with the @code{POINTER} attribute. Thus one needs to -use intrinsic conversion procedures to convert from or to C pointers. -For some applications, using an assumed type (@code{TYPE(*)}) can be -an alternative to a C pointer, and you can also use library routines -to access Fortran pointers from C. See @ref{Further Interoperability -of Fortran with C}. - -Here is an example of using C pointers in Fortran: - -@smallexample - use iso_c_binding - type(c_ptr) :: cptr1, cptr2 - integer, target :: array(7), scalar - integer, pointer :: pa(:), ps - cptr1 = c_loc(array(1)) ! The programmer needs to ensure that the - ! array is contiguous if required by the C - ! procedure - cptr2 = c_loc(scalar) - call c_f_pointer(cptr2, ps) - call c_f_pointer(cptr2, pa, shape=[7]) -@end smallexample - -When converting C to Fortran arrays, the one-dimensional @code{SHAPE} argument -has to be passed. - -If a pointer is a dummy argument of an interoperable procedure, it usually -has to be declared using the @code{VALUE} attribute. @code{void*} -matches @code{TYPE(C_PTR), VALUE}, while @code{TYPE(C_PTR)} alone -matches @code{void**}. - -Procedure pointers are handled analogously to pointers; the C type is -@code{TYPE(C_FUNPTR)} and the intrinsic conversion procedures are -@code{C_F_PROCPOINTER} and @code{C_FUNLOC}. - -Let us consider two examples of actually passing a procedure pointer from -C to Fortran and vice versa. Note that these examples are also very -similar to passing ordinary pointers between both languages. First, -consider this code in C: - -@smallexample -/* Procedure implemented in Fortran. */ -void get_values (void (*)(double)); - -/* Call-back routine we want called from Fortran. */ -void -print_it (double x) -@{ - printf ("Number is %f.\n", x); -@} - -/* Call Fortran routine and pass call-back to it. */ -void -foobar () -@{ - get_values (&print_it); -@} -@end smallexample - -A matching implementation for @code{get_values} in Fortran, that correctly -receives the procedure pointer from C and is able to call it, is given -in the following @code{MODULE}: - -@smallexample -MODULE m - IMPLICIT NONE - - ! Define interface of call-back routine. - ABSTRACT INTERFACE - SUBROUTINE callback (x) - USE, INTRINSIC :: ISO_C_BINDING - REAL(KIND=C_DOUBLE), INTENT(IN), VALUE :: x - END SUBROUTINE callback - END INTERFACE - -CONTAINS - - ! Define C-bound procedure. - SUBROUTINE get_values (cproc) BIND(C) - USE, INTRINSIC :: ISO_C_BINDING - TYPE(C_FUNPTR), INTENT(IN), VALUE :: cproc - - PROCEDURE(callback), POINTER :: proc - - ! Convert C to Fortran procedure pointer. - CALL C_F_PROCPOINTER (cproc, proc) - - ! 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 -@end smallexample - -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: - -@smallexample -int -call_it (int (*func)(int), int arg) -@{ - return func (arg); -@} -@end smallexample - -It can be used as in the following Fortran code: - -@smallexample -MODULE m - USE, INTRINSIC :: ISO_C_BINDING - IMPLICIT NONE - - ! Define interface of C function. - INTERFACE - INTEGER(KIND=C_INT) FUNCTION call_it (func, arg) BIND(C) - USE, INTRINSIC :: ISO_C_BINDING - TYPE(C_FUNPTR), INTENT(IN), VALUE :: func - INTEGER(KIND=C_INT), INTENT(IN), VALUE :: arg - END FUNCTION call_it - END INTERFACE - -CONTAINS - - ! Define procedure passed to C function. - ! It must be interoperable! - INTEGER(KIND=C_INT) FUNCTION double_it (arg) BIND(C) - INTEGER(KIND=C_INT), INTENT(IN), VALUE :: arg - double_it = arg + arg - END FUNCTION double_it - - ! Call C function. - SUBROUTINE foobar () - TYPE(C_FUNPTR) :: cproc - INTEGER(KIND=C_INT) :: i - - ! Get C procedure pointer. - cproc = C_FUNLOC (double_it) - - ! Use it. - DO i = 1_C_INT, 10_C_INT - PRINT *, call_it (cproc, i) - END DO - END SUBROUTINE foobar - -END MODULE m -@end smallexample - -@node Further Interoperability of Fortran with C -@subsection Further Interoperability of Fortran with C -@cindex Further Interoperability of Fortran with C -@cindex TS 29113 -@cindex array descriptor -@cindex dope vector -@cindex assumed-type -@cindex assumed-rank - -GNU Fortran implements the Technical Specification ISO/IEC TS -29113:2012, which extends the interoperability support of Fortran 2003 -and Fortran 2008 and is now part of the 2018 Fortran standard. -Besides removing some restrictions and constraints, the Technical -Specification adds assumed-type (@code{TYPE(*)}) and assumed-rank -(@code{DIMENSION(..)}) variables and allows for interoperability of -assumed-shape, assumed-rank, and deferred-shape arrays, as well as -allocatables and pointers. Objects of these types are passed to -@code{BIND(C)} functions as descriptors with a standard interface, -declared in the header file @code{<ISO_Fortran_binding.h>}. - -Note: Currently, GNU Fortran does not use internally the array descriptor -(dope vector) as specified in the Technical Specification, but uses -an array descriptor with different fields in functions without the -@code{BIND(C)} attribute. Arguments to functions marked @code{BIND(C)} -are converted to the specified form. If you need to access GNU Fortran's -internal array descriptor, you can use the Chasm Language Interoperability -Tools, @url{http://chasm-interop.sourceforge.net/}. - -@node GNU Fortran Compiler Directives -@section GNU Fortran Compiler Directives - -@menu -* ATTRIBUTES directive:: -* UNROLL directive:: -* BUILTIN directive:: -* IVDEP directive:: -* VECTOR directive:: -* NOVECTOR directive:: -@end menu - -@node ATTRIBUTES directive -@subsection ATTRIBUTES directive - -The Fortran standard describes how a conforming program shall -behave; however, the exact implementation is not standardized. In order -to allow the user to choose specific implementation details, compiler -directives can be used to set attributes of variables and procedures -which are not part of the standard. Whether a given attribute is -supported and its exact effects depend on both the operating system and -on the processor; see -@ref{Top,,C Extensions,gcc,Using the GNU Compiler Collection (GCC)} -for details. - -For procedures and procedure pointers, the following attributes can -be used to change the calling convention: - -@itemize -@item @code{CDECL} -- standard C calling convention -@item @code{STDCALL} -- convention where the called procedure pops the stack -@item @code{FASTCALL} -- part of the arguments are passed via registers -instead using the stack -@end itemize - -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 -@code{COMMON} blocks) need special handling to be accessible when they -are in a shared library. The following attributes are available: - -@itemize -@item @code{DLLEXPORT} -- provide a global pointer to a pointer in the DLL -@item @code{DLLIMPORT} -- reference the function or variable using a -global pointer -@end itemize - -For dummy arguments, the @code{NO_ARG_CHECK} attribute can be used; in -other compilers, it is also known as @code{IGNORE_TKR}. For dummy arguments -with this attribute actual arguments of any type and kind (similar to -@code{TYPE(*)}), scalars and arrays of any rank (no equivalent -in Fortran standard) are accepted. As with @code{TYPE(*)}, the argument -is unlimited polymorphic and no type information is available. -Additionally, the argument may only be passed to dummy arguments -with the @code{NO_ARG_CHECK} attribute and as argument to the -@code{PRESENT} intrinsic function and to @code{C_LOC} of the -@code{ISO_C_BINDING} module. - -Variables with @code{NO_ARG_CHECK} attribute shall be of assumed-type -(@code{TYPE(*)}; recommended) or of type @code{INTEGER}, @code{LOGICAL}, -@code{REAL} or @code{COMPLEX}. They shall not have the @code{ALLOCATE}, -@code{CODIMENSION}, @code{INTENT(OUT)}, @code{POINTER} or @code{VALUE} -attribute; furthermore, they shall be either scalar or of assumed-size -(@code{dimension(*)}). As @code{TYPE(*)}, the @code{NO_ARG_CHECK} attribute -requires an explicit interface. - -@itemize -@item @code{NO_ARG_CHECK} -- disable the type, kind and rank checking -@item @code{DEPRECATED} -- print a warning when using a such-tagged -deprecated procedure, variable or parameter; the warning can be suppressed -with @option{-Wno-deprecated-declarations}. -@end itemize - - -The attributes are specified using the syntax - -@code{!GCC$ ATTRIBUTES} @var{attribute-list} @code{::} @var{variable-list} - -where in free-form source code only whitespace is allowed before @code{!GCC$} -and in fixed-form source code @code{!GCC$}, @code{cGCC$} or @code{*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. - - -@node UNROLL directive -@subsection UNROLL directive - -The syntax of the directive is - -@code{!GCC$ unroll N} - -You can use this directive to control how many times a loop should be unrolled. -It must be placed immediately before a @code{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. - - -@node BUILTIN directive -@subsection BUILTIN directive - -The syntax of the directive is - -@code{!GCC$ BUILTIN (B) attributes simd FLAGS IF('target')} - -You can use this directive to define which middle-end built-ins provide vector -implementations. @code{B} is name of the middle-end built-in. @code{FLAGS} -are optional and must be either "(inbranch)" or "(notinbranch)". -@code{IF} statement is optional and is used to filter multilib ABIs -for the built-in that should be vectorized. Example usage: - -@smallexample -!GCC$ builtin (sinf) attributes simd (notinbranch) if('x86_64') -@end smallexample - -The purpose of the directive is to provide an API among the GCC compiler and -the GNU C Library which would define vector implementations of math routines. - - -@node IVDEP directive -@subsection IVDEP directive - -The syntax of the directive is - -@code{!GCC$ ivdep} - -This directive tells the compiler to ignore vector dependencies in the -following loop. It must be placed immediately before a @code{DO} loop -and applies only to the loop that follows. - -Sometimes the compiler may not have sufficient information to decide -whether a particular loop is vectorizable due to potential -dependencies between iterations. The purpose of the directive is to -tell the compiler that vectorization is safe. - -This directive is intended for annotation of existing code. For new -code it is recommended to consider OpenMP SIMD directives as potential -alternative. - - -@node VECTOR directive -@subsection VECTOR directive - -The syntax of the directive is - -@code{!GCC$ vector} - -This directive tells the compiler to vectorize the following loop. It -must be placed immediately before a @code{DO} loop and applies only to -the loop that follows. - - -@node NOVECTOR directive -@subsection NOVECTOR directive - -The syntax of the directive is - -@code{!GCC$ novector} - -This directive tells the compiler to not vectorize the following loop. -It must be placed immediately before a @code{DO} loop and applies only -to the loop that follows. - - -@node Non-Fortran Main Program -@section Non-Fortran Main Program - -@menu -* _gfortran_set_args:: Save command-line arguments -* _gfortran_set_options:: Set library option flags -* _gfortran_set_convert:: Set endian conversion -* _gfortran_set_record_marker:: Set length of record markers -* _gfortran_set_fpe:: Set when a Floating Point Exception should be raised -* _gfortran_set_max_subrecord_length:: Set subrecord length -@end menu - -Even if you are doing mixed-language programming, it is very -likely that you do not need to know or use the information in this -section. Since it is about the internal structure of GNU Fortran, -it may also change in GCC minor releases. - -When you compile a @code{PROGRAM} with GNU Fortran, a function -with the name @code{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 @code{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 @code{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 @code{_gfortran_set_args} and -@code{_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 @code{PROGRAM} is compiled with GNU Fortran, you shall -not call any of the following functions. The libgfortran -initialization functions are shown in C syntax but using C -bindings they are also accessible from Fortran. - - -@node _gfortran_set_args -@subsection @code{_gfortran_set_args} --- Save command-line arguments -@fnindex _gfortran_set_args -@cindex libgfortran initialization, set_args - -@table @asis -@item @emph{Description}: -@code{_gfortran_set_args} saves the command-line arguments; this -initialization is required if any of the command-line intrinsics -is called. Additionally, it shall be called if backtracing is -enabled (see @code{_gfortran_set_options}). - -@item @emph{Syntax}: -@code{void _gfortran_set_args (int argc, char *argv[])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{argc} @tab number of command line argument strings -@item @var{argv} @tab the command-line argument strings; argv[0] -is the pathname of the executable itself. -@end multitable - -@item @emph{Example}: -@smallexample -int main (int argc, char *argv[]) -@{ - /* Initialize libgfortran. */ - _gfortran_set_args (argc, argv); - return 0; -@} -@end smallexample -@end table - - -@node _gfortran_set_options -@subsection @code{_gfortran_set_options} --- Set library option flags -@fnindex _gfortran_set_options -@cindex libgfortran initialization, set_options - -@table @asis -@item @emph{Description}: -@code{_gfortran_set_options} sets several flags related to the Fortran -standard to be used, whether backtracing should be enabled -and whether range checks should be performed. The syntax allows for -upward compatibility since the number of passed flags is specified; for -non-passed flags, the default value is used. See also -@pxref{Code Gen Options}. Please note that not all flags are actually -used. - -@item @emph{Syntax}: -@code{void _gfortran_set_options (int num, int options[])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{num} @tab number of options passed -@item @var{argv} @tab The list of flag values -@end multitable - -@item @emph{option flag list}: -@multitable @columnfractions .15 .70 -@item @var{option}[0] @tab Allowed standard; can give run-time errors -if e.g. an input-output edit descriptor is invalid in a given -standard. Possible values are (bitwise or-ed) @code{GFC_STD_F77} (1), -@code{GFC_STD_F95_OBS} (2), @code{GFC_STD_F95_DEL} (4), -@code{GFC_STD_F95} (8), @code{GFC_STD_F2003} (16), @code{GFC_STD_GNU} -(32), @code{GFC_STD_LEGACY} (64), @code{GFC_STD_F2008} (128), -@code{GFC_STD_F2008_OBS} (256), @code{GFC_STD_F2008_TS} (512), -@code{GFC_STD_F2018} (1024), @code{GFC_STD_F2018_OBS} (2048), and -@code{GFC_STD=F2018_DEL} (4096). Default: @code{GFC_STD_F95_OBS | -GFC_STD_F95_DEL | GFC_STD_F95 | GFC_STD_F2003 | GFC_STD_F2008 | -GFC_STD_F2008_TS | GFC_STD_F2008_OBS | GFC_STD_F77 | GFC_STD_F2018 | -GFC_STD_F2018_OBS | GFC_STD_F2018_DEL | GFC_STD_GNU | GFC_STD_LEGACY}. -@item @var{option}[1] @tab Standard-warning flag; prints a warning to -standard error. Default: @code{GFC_STD_F95_DEL | GFC_STD_LEGACY}. -@item @var{option}[2] @tab If non zero, enable pedantic checking. -Default: off. -@item @var{option}[3] @tab Unused. -@item @var{option}[4] @tab If non zero, enable backtracing on run-time -errors. Default: off. (Default in the compiler: on.) -Note: Installs a signal handler and requires command-line -initialization using @code{_gfortran_set_args}. -@item @var{option}[5] @tab If non zero, supports signed zeros. -Default: enabled. -@item @var{option}[6] @tab Enables run-time checking. Possible values -are (bitwise or-ed): GFC_RTCHECK_BOUNDS (1), GFC_RTCHECK_ARRAY_TEMPS (2), -GFC_RTCHECK_RECURSION (4), GFC_RTCHECK_DO (8), GFC_RTCHECK_POINTER (16), -GFC_RTCHECK_MEM (32), GFC_RTCHECK_BITS (64). -Default: disabled. -@item @var{option}[7] @tab Unused. -@item @var{option}[8] @tab Show a warning when invoking @code{STOP} and -@code{ERROR STOP} if a floating-point exception occurred. Possible values -are (bitwise or-ed) @code{GFC_FPE_INVALID} (1), @code{GFC_FPE_DENORMAL} (2), -@code{GFC_FPE_ZERO} (4), @code{GFC_FPE_OVERFLOW} (8), -@code{GFC_FPE_UNDERFLOW} (16), @code{GFC_FPE_INEXACT} (32). Default: None (0). -(Default in the compiler: @code{GFC_FPE_INVALID | GFC_FPE_DENORMAL | -GFC_FPE_ZERO | GFC_FPE_OVERFLOW | GFC_FPE_UNDERFLOW}.) -@end multitable - -@item @emph{Example}: -@smallexample - /* Use gfortran 4.9 default options. */ - static int options[] = @{68, 511, 0, 0, 1, 1, 0, 0, 31@}; - _gfortran_set_options (9, &options); -@end smallexample -@end table - - -@node _gfortran_set_convert -@subsection @code{_gfortran_set_convert} --- Set endian conversion -@fnindex _gfortran_set_convert -@cindex libgfortran initialization, set_convert - -@table @asis -@item @emph{Description}: -@code{_gfortran_set_convert} set the representation of data for -unformatted files. - -@item @emph{Syntax}: -@code{void _gfortran_set_convert (int conv)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{conv} @tab Endian conversion, possible values: -GFC_CONVERT_NATIVE (0, default), GFC_CONVERT_SWAP (1), -GFC_CONVERT_BIG (2), GFC_CONVERT_LITTLE (3). -@end multitable - -@item @emph{Example}: -@smallexample -int main (int argc, char *argv[]) -@{ - /* Initialize libgfortran. */ - _gfortran_set_args (argc, argv); - _gfortran_set_convert (1); - return 0; -@} -@end smallexample -@end table - - -@node _gfortran_set_record_marker -@subsection @code{_gfortran_set_record_marker} --- Set length of record markers -@fnindex _gfortran_set_record_marker -@cindex libgfortran initialization, set_record_marker - -@table @asis -@item @emph{Description}: -@code{_gfortran_set_record_marker} sets the length of record markers -for unformatted files. - -@item @emph{Syntax}: -@code{void _gfortran_set_record_marker (int val)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{val} @tab Length of the record marker; valid values -are 4 and 8. Default is 4. -@end multitable - -@item @emph{Example}: -@smallexample -int main (int argc, char *argv[]) -@{ - /* Initialize libgfortran. */ - _gfortran_set_args (argc, argv); - _gfortran_set_record_marker (8); - return 0; -@} -@end smallexample -@end table - - -@node _gfortran_set_fpe -@subsection @code{_gfortran_set_fpe} --- Enable floating point exception traps -@fnindex _gfortran_set_fpe -@cindex libgfortran initialization, set_fpe - -@table @asis -@item @emph{Description}: -@code{_gfortran_set_fpe} enables floating point exception traps for -the specified exceptions. On most systems, this will result in a -SIGFPE signal being sent and the program being aborted. - -@item @emph{Syntax}: -@code{void _gfortran_set_fpe (int val)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{option}[0] @tab IEEE exceptions. Possible values are -(bitwise or-ed) zero (0, default) no trapping, -@code{GFC_FPE_INVALID} (1), @code{GFC_FPE_DENORMAL} (2), -@code{GFC_FPE_ZERO} (4), @code{GFC_FPE_OVERFLOW} (8), -@code{GFC_FPE_UNDERFLOW} (16), and @code{GFC_FPE_INEXACT} (32). -@end multitable - -@item @emph{Example}: -@smallexample -int main (int argc, char *argv[]) -@{ - /* Initialize libgfortran. */ - _gfortran_set_args (argc, argv); - /* FPE for invalid operations such as SQRT(-1.0). */ - _gfortran_set_fpe (1); - return 0; -@} -@end smallexample -@end table - - -@node _gfortran_set_max_subrecord_length -@subsection @code{_gfortran_set_max_subrecord_length} --- Set subrecord length -@fnindex _gfortran_set_max_subrecord_length -@cindex libgfortran initialization, set_max_subrecord_length - -@table @asis -@item @emph{Description}: -@code{_gfortran_set_max_subrecord_length} set the maximum length -for a subrecord. This option only makes sense for testing and -debugging of unformatted I/O. - -@item @emph{Syntax}: -@code{void _gfortran_set_max_subrecord_length (int val)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{val} @tab the maximum length for a subrecord; -the maximum permitted value is 2147483639, which is also -the default. -@end multitable - -@item @emph{Example}: -@smallexample -int main (int argc, char *argv[]) -@{ - /* Initialize libgfortran. */ - _gfortran_set_args (argc, argv); - _gfortran_set_max_subrecord_length (8); - return 0; -@} -@end smallexample -@end table - - -@node Naming and argument-passing conventions -@section Naming and argument-passing conventions - -This section gives an overview about the naming convention of procedures -and global variables and about the argument passing conventions used by -GNU Fortran. If a C binding 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 defined -C binding for interoperability. See @pxref{Interoperability with C}. - -@menu -* Naming conventions:: -* Argument passing conventions:: -@end menu - - -@node Naming conventions -@subsection Naming conventions - -According the Fortran standard, valid Fortran names consist of a letter -between @code{A} to @code{Z}, @code{a} to @code{z}, digits @code{0}, -@code{1} to @code{9} and underscores (@code{_}) with the restriction -that names may only start with a letter. As vendor extension, the -dollar sign (@code{$}) is additionally permitted with the option -@option{-fdollar-ok}, but not as first character and only if the -target system supports it. - -By default, the procedure name is the lower-cased Fortran name with an -appended underscore (@code{_}); using @option{-fno-underscoring} no -underscore is appended while @code{-fsecond-underscore} appends two -underscores. Depending on the target system and the calling convention, -the procedure might be additionally dressed; for instance, on 32bit -Windows with @code{stdcall}, an at-sign @code{@@} followed by an integer -number is appended. For the changing the calling convention, see -@pxref{GNU Fortran Compiler Directives}. - -For common blocks, the same convention is used, i.e. by default an -underscore is appended to the lower-cased Fortran name. Blank commons -have the name @code{__BLNK__}. - -For procedures and variables declared in the specification space of a -module, the name is formed by @code{__}, followed by the lower-cased -module name, @code{_MOD_}, and the lower-cased Fortran name. Note that -no underscore is appended. - - -@node Argument passing conventions -@subsection Argument passing conventions - -Subroutines do not return a value (matching C99's @code{void}) while -functions either return a value as specified in the platform ABI or -the result variable is passed as hidden argument to the function and -no result is returned. A hidden result variable is used when the -result variable is an array or of type @code{CHARACTER}. - -Arguments are passed according to the platform ABI. In particular, -complex arguments might not be compatible to a struct with two real -components for the real and imaginary part. The argument passing -matches the one of C99's @code{_Complex}. Functions with scalar -complex result variables return their value and do not use a -by-reference argument. Note that with the @option{-ff2c} option, -the argument passing is modified and no longer completely matches -the platform ABI. Some other Fortran compilers use @code{f2c} -semantic by default; this might cause problems with -interoperablility. - -GNU Fortran passes most arguments by reference, i.e. by passing a -pointer to the data. Note that the compiler might use a temporary -variable into which the actual argument has been copied, if required -semantically (copy-in/copy-out). - -For arguments with @code{ALLOCATABLE} and @code{POINTER} -attribute (including procedure pointers), a pointer to the pointer -is passed such that the pointer address can be modified in the -procedure. - -For dummy arguments with the @code{VALUE} attribute: Scalar arguments -of the type @code{INTEGER}, @code{LOGICAL}, @code{REAL} and -@code{COMPLEX} are passed by value according to the platform ABI. -(As vendor extension and not recommended, using @code{%VAL()} in the -call to a procedure has the same effect.) For @code{TYPE(C_PTR)} and -procedure pointers, the pointer itself is passed such that it can be -modified without affecting the caller. -@c FIXME: Document how VALUE is handled for CHARACTER, TYPE, -@c CLASS and arrays, i.e. whether the copy-in is done in the caller -@c or in the callee. - -For Boolean (@code{LOGICAL}) arguments, please note that GCC expects -only the integer value 0 and 1. If a GNU Fortran @code{LOGICAL} -variable contains another integer value, the result is undefined. -As some other Fortran compilers use @math{-1} for @code{.TRUE.}, -extra care has to be taken -- such as passing the value as -@code{INTEGER}. (The same value restriction also applies to other -front ends of GCC, e.g. to GCC's C99 compiler for @code{_Bool} -or GCC's Ada compiler for @code{Boolean}.) - -For arguments of @code{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 @code{size_t} (or -@code{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 @code{int}. In -order to retain compatibility with older versions, one can e.g. for -the following Fortran procedure - -@smallexample -subroutine fstrlen (s, a) - character(len=*) :: s - integer :: a - print*, len(s) -end subroutine fstrlen -@end smallexample - -define the corresponding C prototype as follows: - -@smallexample -#if __GNUC__ > 7 -typedef size_t fortran_charlen_t; -#else -typedef int fortran_charlen_t; -#endif - -void fstrlen_ (char*, int*, fortran_charlen_t); -@end smallexample - -In order to avoid such compiler-specific details, for new code it is -instead recommended to use the ISO_C_BINDING feature. - -Note with C binding, @code{CHARACTER(len=1)} result variables are -returned according to the platform ABI and no hidden length argument -is used for dummy arguments; with @code{VALUE}, those variables are -passed by value. - -For @code{OPTIONAL} dummy arguments, an absent argument is denoted -by a NULL pointer, except for scalar dummy arguments of type -@code{INTEGER}, @code{LOGICAL}, @code{REAL} and @code{COMPLEX} -which have the @code{VALUE} attribute. For those, a hidden Boolean -argument (@code{logical(kind=C_bool),value}) is used to indicate -whether the argument is present. - -Arguments which are assumed-shape, assumed-rank or deferred-rank -arrays or, with @option{-fcoarray=lib}, allocatable scalar coarrays use -an array descriptor. All other arrays pass the address of the -first element of the array. With @option{-fcoarray=lib}, the token -and the offset belonging to nonallocatable coarrays dummy arguments -are passed as hidden argument along the character length hidden -arguments. The token is an opaque pointer identifying the coarray -and the offset is a passed-by-value integer of kind @code{C_PTRDIFF_T}, -denoting the byte offset between the base address of the coarray and -the passed scalar or first element of the passed array. - -The arguments are passed in the following order -@itemize @bullet -@item Result variable, when the function result is passed by reference -@item Character length of the function result, if it is a of type -@code{CHARACTER} and no C binding is used -@item The arguments in the order in which they appear in the Fortran -declaration -@item The present status for optional arguments with value attribute, -which are internally passed by value -@item The character length and/or coarray token and offset for the first -argument which is a @code{CHARACTER} or a nonallocatable coarray dummy -argument, followed by the hidden arguments of the next dummy argument -of such a type -@end itemize - - -@c --------------------------------------------------------------------- -@c Coarray Programming -@c --------------------------------------------------------------------- - -@node Coarray Programming -@chapter Coarray Programming -@cindex Coarrays - -@menu -* Type and enum ABI Documentation:: -* Function ABI Documentation:: -@end menu - - -@node Type and enum ABI Documentation -@section Type and enum ABI Documentation - -@menu -* caf_token_t:: -* caf_register_t:: -* caf_deregister_t:: -* caf_reference_t:: -* caf_team_t:: -@end menu - -@node caf_token_t -@subsection @code{caf_token_t} - -Typedef of type @code{void *} on the compiler side. Can be any data -type on the library side. - -@node caf_register_t -@subsection @code{caf_register_t} - -Indicates which kind of coarray variable should be registered. - -@verbatim -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; -@end verbatim - -The values @code{CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY} and -@code{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 -@code{_caf_is_present} which used internally by the @code{ALLOCATED} -intrinsic. - -@node caf_deregister_t -@subsection @code{caf_deregister_t} - -@verbatim -typedef enum caf_deregister_t { - CAF_DEREGTYPE_COARRAY_DEREGISTER, - CAF_DEREGTYPE_COARRAY_DEALLOCATE_ONLY -} -caf_deregister_t; -@end verbatim - -Allows to specifiy the type of deregistration of a coarray object. The -@code{CAF_DEREGTYPE_COARRAY_DEALLOCATE_ONLY} flag is only allowed for -allocatable components in derived type coarrays. - -@node caf_reference_t -@subsection @code{caf_reference_t} - -The structure used for implementing arbitrary reference chains. -A @code{CAF_REFERENCE_T} allows to specify a component reference or any kind -of array reference of any rank supported by gfortran. For array references all -kinds as known by the compiler/Fortran standard are supported indicated by -a @code{MODE}. - -@verbatim -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; -@end verbatim - -@verbatim -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; -@end verbatim - -@verbatim -/* 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 { - /* The offset (in bytes) of the component in the derived type. - Unused for allocatable or pointer components. */ - ptrdiff_t offset; - /* The offset (in bytes) to the caf_token associated with this - component. NULL, when not allocatable/pointer ref. */ - ptrdiff_t caf_token_offset; - } c; - struct { - /* The mode of the array ref. See CAF_ARR_REF_*. */ - /* caf_array_ref_t, replaced by unsigend char to allow specification in - fortran FE. */ - unsigned char mode[GFC_MAX_DIMENSIONS]; - /* The type of a static array. Unset for array's with descriptors. */ - int static_array_type; - /* Subscript refs (s) or vector refs (v). */ - union { - struct { - /* The start and end boundary of the ref and the stride. */ - index_type start, end, stride; - } s; - struct { - /* nvec entries of kind giving the elements to reference. */ - void *vector; - /* The number of entries in vector. */ - size_t nvec; - /* The integer kind used for the elements in vector. */ - int kind; - } v; - } dim[GFC_MAX_DIMENSIONS]; - } a; - } u; -} caf_reference_t; -@end verbatim - -The references make up a single linked list of reference operations. The -@code{NEXT} member links to the next reference or NULL to indicate the end of -the chain. Component and array refs can be arbitrarily mixed as long as they -comply to the Fortran standard. - -@emph{NOTES} -The member @code{STATIC_ARRAY_TYPE} is used only when the @code{TYPE} is -@code{CAF_REF_STATIC_ARRAY}. The member gives the type of the data referenced. -Because no array descriptor is available for a descriptor-less array and -type conversion still needs to take place the type is transported here. - -At the moment @code{CAF_ARR_REF_VECTOR} is not implemented in the front end for -descriptor-less arrays. The library caf_single has untested support for it. - -@node caf_team_t -@subsection @code{caf_team_t} - -Opaque pointer to represent a team-handle. This type is a stand-in for the -future implementation of teams. It is about to change without further notice. - -@node Function ABI Documentation -@section Function ABI Documentation - -@menu -* _gfortran_caf_init:: Initialiation function -* _gfortran_caf_finish:: Finalization function -* _gfortran_caf_this_image:: Querying the image number -* _gfortran_caf_num_images:: Querying the maximal number of images -* _gfortran_caf_image_status :: Query the status of an image -* _gfortran_caf_failed_images :: Get an array of the indexes of the failed images -* _gfortran_caf_stopped_images :: Get an array of the indexes of the stopped images -* _gfortran_caf_register:: Registering coarrays -* _gfortran_caf_deregister:: Deregistering coarrays -* _gfortran_caf_is_present:: Query whether an allocatable or pointer component in a derived type coarray is allocated -* _gfortran_caf_send:: Sending data from a local image to a remote image -* _gfortran_caf_get:: Getting data from a remote image -* _gfortran_caf_sendget:: Sending data between remote images -* _gfortran_caf_send_by_ref:: Sending data from a local image to a remote image using enhanced references -* _gfortran_caf_get_by_ref:: Getting data from a remote image using enhanced references -* _gfortran_caf_sendget_by_ref:: Sending data between remote images using enhanced references -* _gfortran_caf_lock:: Locking a lock variable -* _gfortran_caf_unlock:: Unlocking a lock variable -* _gfortran_caf_event_post:: Post an event -* _gfortran_caf_event_wait:: Wait that an event occurred -* _gfortran_caf_event_query:: Query event count -* _gfortran_caf_sync_all:: All-image barrier -* _gfortran_caf_sync_images:: Barrier for selected images -* _gfortran_caf_sync_memory:: Wait for completion of segment-memory operations -* _gfortran_caf_error_stop:: Error termination with exit code -* _gfortran_caf_error_stop_str:: Error termination with string -* _gfortran_caf_fail_image :: Mark the image failed and end its execution -* _gfortran_caf_atomic_define:: Atomic variable assignment -* _gfortran_caf_atomic_ref:: Atomic variable reference -* _gfortran_caf_atomic_cas:: Atomic compare and swap -* _gfortran_caf_atomic_op:: Atomic operation -* _gfortran_caf_co_broadcast:: Sending data to all images -* _gfortran_caf_co_max:: Collective maximum reduction -* _gfortran_caf_co_min:: Collective minimum reduction -* _gfortran_caf_co_sum:: Collective summing reduction -* _gfortran_caf_co_reduce:: Generic collective reduction -@end menu - - -@node _gfortran_caf_init -@subsection @code{_gfortran_caf_init} --- Initialiation function -@cindex Coarray, _gfortran_caf_init - -@table @asis -@item @emph{Description}: -This function is called at startup of the program before the Fortran main -program, if the latter has been compiled with @option{-fcoarray=lib}. -It takes as arguments the command-line arguments of the program. It is -permitted to pass two @code{NULL} pointers as argument; if non-@code{NULL}, -the library is permitted to modify the arguments. - -@item @emph{Syntax}: -@code{void _gfortran_caf_init (int *argc, char ***argv)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{argc} @tab intent(inout) An integer pointer with the number of -arguments passed to the program or @code{NULL}. -@item @var{argv} @tab intent(inout) A pointer to an array of strings with the -command-line arguments or @code{NULL}. -@end multitable - -@item @emph{NOTES} -The function is modelled after the initialization function of the Message -Passing Interface (MPI) specification. Due to the way coarray registration -works, it might not be the first call to the library. If the main program is -not written in Fortran and only a library uses coarrays, it can happen that -this function is never called. Therefore, it is recommended that the library -does not rely on the passed arguments and whether the call has been done. -@end table - - -@node _gfortran_caf_finish -@subsection @code{_gfortran_caf_finish} --- Finalization function -@cindex Coarray, _gfortran_caf_finish - -@table @asis -@item @emph{Description}: -This function is called at the end of the Fortran main program, if it has -been compiled with the @option{-fcoarray=lib} option. - -@item @emph{Syntax}: -@code{void _gfortran_caf_finish (void)} - -@item @emph{NOTES} -For non-Fortran programs, it is recommended to call the function at the end -of the main program. To ensure that the shutdown is also performed for -programs where this function is not explicitly invoked, for instance -non-Fortran programs or calls to the system's exit() function, the library -can use a destructor function. Note that programs can also be terminated -using the STOP and ERROR STOP statements; those use different library calls. -@end table - - -@node _gfortran_caf_this_image -@subsection @code{_gfortran_caf_this_image} --- Querying the image number -@cindex Coarray, _gfortran_caf_this_image - -@table @asis -@item @emph{Description}: -This function returns the current image number, which is a positive number. - -@item @emph{Syntax}: -@code{int _gfortran_caf_this_image (int distance)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{distance} @tab As specified for the @code{this_image} intrinsic -in TS18508. Shall be a non-negative number. -@end multitable - -@item @emph{NOTES} -If the Fortran intrinsic @code{this_image} is invoked without an argument, which -is the only permitted form in Fortran 2008, GCC passes @code{0} as -first argument. -@end table - - -@node _gfortran_caf_num_images -@subsection @code{_gfortran_caf_num_images} --- Querying the maximal number of images -@cindex Coarray, _gfortran_caf_num_images - -@table @asis -@item @emph{Description}: -This function returns the number of images in the current team, if -@var{distance} is 0 or the number of images in the parent team at the specified -distance. If failed is -1, the function returns the number of all images at -the specified distance; if it is 0, the function returns the number of -nonfailed images, and if it is 1, it returns the number of failed images. - -@item @emph{Syntax}: -@code{int _gfortran_caf_num_images(int distance, int failed)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{distance} @tab the distance from this image to the ancestor. -Shall be positive. -@item @var{failed} @tab shall be -1, 0, or 1 -@end multitable - -@item @emph{NOTES} -This function follows TS18508. If the num_image intrinsic has no arguments, -then the compiler passes @code{distance=0} and @code{failed=-1} to the function. -@end table - - -@node _gfortran_caf_image_status -@subsection @code{_gfortran_caf_image_status} --- Query the status of an image -@cindex Coarray, _gfortran_caf_image_status - -@table @asis -@item @emph{Description}: -Get the status of the image given by the id @var{image} of the team given by -@var{team}. Valid results are zero, for image is ok, @code{STAT_STOPPED_IMAGE} -from the ISO_FORTRAN_ENV module to indicate that the image has been stopped and -@code{STAT_FAILED_IMAGE} also from ISO_FORTRAN_ENV to indicate that the image -has executed a @code{FAIL IMAGE} statement. - -@item @emph{Syntax}: -@code{int _gfortran_caf_image_status (int image, caf_team_t * team)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{image} @tab the positive scalar id of the image in the current TEAM. -@item @var{team} @tab optional; team on the which the inquiry is to be -performed. -@end multitable - -@item @emph{NOTES} -This function follows TS18508. Because team-functionality is not yet -implemented a null-pointer is passed for the @var{team} argument at the moment. -@end table - - -@node _gfortran_caf_failed_images -@subsection @code{_gfortran_caf_failed_images} --- Get an array of the indexes of the failed images -@cindex Coarray, _gfortran_caf_failed_images - -@table @asis -@item @emph{Description}: -Get an array of image indexes in the current @var{team} that have failed. The -array is sorted ascendingly. When @var{team} is not provided the current team -is to be used. When @var{kind} is provided then the resulting array is of that -integer kind else it is of default integer kind. The returns an unallocated -size zero array when no images have failed. - -@item @emph{Syntax}: -@code{int _gfortran_caf_failed_images (caf_team_t * team, int * kind)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{team} @tab optional; team on the which the inquiry is to be -performed. -@item @var{image} @tab optional; the kind of the resulting integer array. -@end multitable - -@item @emph{NOTES} -This function follows TS18508. Because team-functionality is not yet -implemented a null-pointer is passed for the @var{team} argument at the moment. -@end table - - -@node _gfortran_caf_stopped_images -@subsection @code{_gfortran_caf_stopped_images} --- Get an array of the indexes of the stopped images -@cindex Coarray, _gfortran_caf_stopped_images - -@table @asis -@item @emph{Description}: -Get an array of image indexes in the current @var{team} that have stopped. The -array is sorted ascendingly. When @var{team} is not provided the current team -is to be used. When @var{kind} is provided then the resulting array is of that -integer kind else it is of default integer kind. The returns an unallocated -size zero array when no images have failed. - -@item @emph{Syntax}: -@code{int _gfortran_caf_stopped_images (caf_team_t * team, int * kind)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{team} @tab optional; team on the which the inquiry is to be -performed. -@item @var{image} @tab optional; the kind of the resulting integer array. -@end multitable - -@item @emph{NOTES} -This function follows TS18508. Because team-functionality is not yet -implemented a null-pointer is passed for the @var{team} argument at the moment. -@end table - - -@node _gfortran_caf_register -@subsection @code{_gfortran_caf_register} --- Registering coarrays -@cindex Coarray, _gfortran_caf_register - -@table @asis -@item @emph{Description}: -Registers memory for a coarray and creates a token to identify the coarray. The -routine is called for both coarrays with @code{SAVE} attribute and using an -explicit @code{ALLOCATE} statement. If an error occurs and @var{STAT} is a -@code{NULL} pointer, the function shall abort with printing an error message -and starting the error termination. If no error occurs and @var{STAT} is -present, it shall be set to zero. Otherwise, it shall be set to a positive -value and, if not-@code{NULL}, @var{ERRMSG} shall be set to a string describing -the failure. The routine shall register the memory provided in the -@code{DATA}-component of the array descriptor @var{DESC}, when that component -is non-@code{NULL}, else it shall allocate sufficient memory and provide a -pointer to it in the @code{DATA}-component of @var{DESC}. The array descriptor -has rank zero, when a scalar object is to be registered and the array -descriptor may be invalid after the call to @code{_gfortran_caf_register}. -When an array is to be allocated the descriptor persists. - -For @code{CAF_REGTYPE_COARRAY_STATIC} and @code{CAF_REGTYPE_COARRAY_ALLOC}, -the passed size is the byte size requested. For @code{CAF_REGTYPE_LOCK_STATIC}, -@code{CAF_REGTYPE_LOCK_ALLOC} and @code{CAF_REGTYPE_CRITICAL} it is the array -size or one for a scalar. - -When @code{CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY} is used, then only a token -for an allocatable or pointer component is created. The @code{SIZE} parameter -is not used then. On the contrary when -@code{CAF_REGTYPE_COARRAY_ALLOC_ALLOCATE_ONLY} is specified, then the -@var{token} needs to be registered by a previous call with regtype -@code{CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY} and either the memory specified -in the @var{DESC}'s data-ptr is registered or allocate when the data-ptr is -@code{NULL}. - -@item @emph{Syntax}: -@code{void caf_register (size_t size, caf_register_t type, caf_token_t *token, -gfc_descriptor_t *desc, int *stat, char *errmsg, size_t errmsg_len)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{size} @tab For normal coarrays, the byte size of the coarray to be -allocated; for lock types and event types, the number of elements. -@item @var{type} @tab one of the caf_register_t types. -@item @var{token} @tab intent(out) An opaque pointer identifying the coarray. -@item @var{desc} @tab intent(inout) The (pseudo) array descriptor. -@item @var{stat} @tab intent(out) For allocatable coarrays, stores the STAT=; -may be @code{NULL} -@item @var{errmsg} @tab intent(out) When an error occurs, this will be set to -an error message; may be @code{NULL} -@item @var{errmsg_len} @tab the buffer size of errmsg. -@end multitable - -@item @emph{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 -@var{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 -(@code{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. -@end table - - -@node _gfortran_caf_deregister -@subsection @code{_gfortran_caf_deregister} --- Deregistering coarrays -@cindex Coarray, _gfortran_caf_deregister - -@table @asis -@item @emph{Description}: -Called to free or deregister the memory of a coarray; the processor calls this -function for automatic and explicit deallocation. In case of an error, this -function shall fail with an error message, unless the @var{STAT} variable is -not null. The library is only expected to free memory it allocated itself -during a call to @code{_gfortran_caf_register}. - -@item @emph{Syntax}: -@code{void caf_deregister (caf_token_t *token, caf_deregister_t type, -int *stat, char *errmsg, size_t errmsg_len)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{token} @tab the token to free. -@item @var{type} @tab the type of action to take for the coarray. A -@code{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. -@item @var{stat} @tab intent(out) Stores the STAT=; may be NULL -@item @var{errmsg} @tab intent(out) When an error occurs, this will be set -to an error message; may be NULL -@item @var{errmsg_len} @tab the buffer size of errmsg. -@end multitable - -@item @emph{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. -@end table - - -@node _gfortran_caf_is_present -@subsection @code{_gfortran_caf_is_present} --- Query whether an allocatable or pointer component in a derived type coarray is allocated -@cindex Coarray, _gfortran_caf_is_present - -@table @asis -@item @emph{Description}: -Used to query the coarray library whether an allocatable component in a derived -type coarray is allocated on a remote image. - -@item @emph{Syntax}: -@code{void _gfortran_caf_is_present (caf_token_t token, int image_index, -gfc_reference_t *ref)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{token} @tab An opaque pointer identifying the coarray. -@item @var{image_index} @tab The ID of the remote image; must be a positive -number. -@item @var{ref} @tab 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. -@end multitable - -@end table - -@node _gfortran_caf_send -@subsection @code{_gfortran_caf_send} --- Sending data from a local image to a remote image -@cindex Coarray, _gfortran_caf_send - -@table @asis -@item @emph{Description}: -Called to send a scalar, an array section or a whole array from a local -to a remote image identified by the image_index. - -@item @emph{Syntax}: -@code{void _gfortran_caf_send (caf_token_t token, size_t offset, -int image_index, gfc_descriptor_t *dest, caf_vector_t *dst_vector, -gfc_descriptor_t *src, int dst_kind, int src_kind, bool may_require_tmp, -int *stat)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{token} @tab intent(in) An opaque pointer identifying the coarray. -@item @var{offset} @tab intent(in) By which amount of bytes the actual data is -shifted compared to the base address of the coarray. -@item @var{image_index} @tab intent(in) The ID of the remote image; must be a -positive number. -@item @var{dest} @tab intent(in) Array descriptor for the remote image for the -bounds and the size. The @code{base_addr} shall not be accessed. -@item @var{dst_vector} @tab intent(in) If not NULL, it contains the vector -subscript of the destination array; the values are relative to the dimension -triplet of the dest argument. -@item @var{src} @tab intent(in) Array descriptor of the local array to be -transferred to the remote image -@item @var{dst_kind} @tab intent(in) Kind of the destination argument -@item @var{src_kind} @tab intent(in) Kind of the source argument -@item @var{may_require_tmp} @tab intent(in) The variable is @code{false} when -it is known at compile time that the @var{dest} and @var{src} either cannot -overlap or overlap (fully or partially) such that walking @var{src} and -@var{dest} in element wise element order (honoring the stride value) will not -lead to wrong results. Otherwise, the value is @code{true}. -@item @var{stat} @tab intent(out) when non-NULL give the result of the -operation, i.e., zero on success and non-zero on error. When NULL and an error -occurs, then an error message is printed and the program is terminated. -@end multitable - -@item @emph{NOTES} -It is permitted to have @var{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 -@code{memmove} which handles (partially) overlapping memory. If -@var{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 @code{memmove} takes care of overlap issues). - -Note that the assignment of a scalar to an array is permitted. In addition, -the library has to handle numeric-type conversion and for strings, padding -and different character kinds. -@end table - - -@node _gfortran_caf_get -@subsection @code{_gfortran_caf_get} --- Getting data from a remote image -@cindex Coarray, _gfortran_caf_get - -@table @asis -@item @emph{Description}: -Called to get an array section or a whole array from a remote, -image identified by the image_index. - -@item @emph{Syntax}: -@code{void _gfortran_caf_get (caf_token_t token, size_t offset, -int image_index, gfc_descriptor_t *src, caf_vector_t *src_vector, -gfc_descriptor_t *dest, int src_kind, int dst_kind, bool may_require_tmp, -int *stat)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{token} @tab intent(in) An opaque pointer identifying the coarray. -@item @var{offset} @tab intent(in) By which amount of bytes the actual data is -shifted compared to the base address of the coarray. -@item @var{image_index} @tab intent(in) The ID of the remote image; must be a -positive number. -@item @var{dest} @tab intent(out) Array descriptor of the local array to store -the data retrieved from the remote image -@item @var{src} @tab intent(in) Array descriptor for the remote image for the -bounds and the size. The @code{base_addr} shall not be accessed. -@item @var{src_vector} @tab intent(in) If not NULL, it contains the vector -subscript of the source array; the values are relative to the dimension -triplet of the @var{src} argument. -@item @var{dst_kind} @tab intent(in) Kind of the destination argument -@item @var{src_kind} @tab intent(in) Kind of the source argument -@item @var{may_require_tmp} @tab intent(in) The variable is @code{false} when -it is known at compile time that the @var{dest} and @var{src} either cannot -overlap or overlap (fully or partially) such that walking @var{src} and -@var{dest} in element wise element order (honoring the stride value) will not -lead to wrong results. Otherwise, the value is @code{true}. -@item @var{stat} @tab intent(out) When non-NULL give the result of the -operation, i.e., zero on success and non-zero on error. When NULL and an error -occurs, then an error message is printed and the program is terminated. -@end multitable - -@item @emph{NOTES} -It is permitted to have @var{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 -@code{memmove} which handles (partially) overlapping memory. If -@var{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 @code{memmove} takes care of overlap issues). - -Note that the library has to handle numeric-type conversion and for strings, -padding and different character kinds. -@end table - - -@node _gfortran_caf_sendget -@subsection @code{_gfortran_caf_sendget} --- Sending data between remote images -@cindex Coarray, _gfortran_caf_sendget - -@table @asis -@item @emph{Description}: -Called to send a scalar, an array section or a whole array from a remote image -identified by the @var{src_image_index} to a remote image identified by the -@var{dst_image_index}. - -@item @emph{Syntax}: -@code{void _gfortran_caf_sendget (caf_token_t dst_token, size_t dst_offset, -int dst_image_index, gfc_descriptor_t *dest, caf_vector_t *dst_vector, -caf_token_t src_token, size_t src_offset, int src_image_index, -gfc_descriptor_t *src, caf_vector_t *src_vector, int dst_kind, int src_kind, -bool may_require_tmp, int *stat)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{dst_token} @tab intent(in) An opaque pointer identifying the -destination coarray. -@item @var{dst_offset} @tab intent(in) By which amount of bytes the actual data -is shifted compared to the base address of the destination coarray. -@item @var{dst_image_index} @tab intent(in) The ID of the destination remote -image; must be a positive number. -@item @var{dest} @tab intent(in) Array descriptor for the destination -remote image for the bounds and the size. The @code{base_addr} shall not be -accessed. -@item @var{dst_vector} @tab intent(int) If not NULL, it contains the vector -subscript of the destination array; the values are relative to the dimension -triplet of the @var{dest} argument. -@item @var{src_token} @tab intent(in) An opaque pointer identifying the source -coarray. -@item @var{src_offset} @tab intent(in) By which amount of bytes the actual data -is shifted compared to the base address of the source coarray. -@item @var{src_image_index} @tab intent(in) The ID of the source remote image; -must be a positive number. -@item @var{src} @tab intent(in) Array descriptor of the local array to be -transferred to the remote image. -@item @var{src_vector} @tab intent(in) Array descriptor of the local array to -be transferred to the remote image -@item @var{dst_kind} @tab intent(in) Kind of the destination argument -@item @var{src_kind} @tab intent(in) Kind of the source argument -@item @var{may_require_tmp} @tab intent(in) The variable is @code{false} when -it is known at compile time that the @var{dest} and @var{src} either cannot -overlap or overlap (fully or partially) such that walking @var{src} and -@var{dest} in element wise element order (honoring the stride value) will not -lead to wrong results. Otherwise, the value is @code{true}. -@item @var{stat} @tab intent(out) when non-NULL give the result of the -operation, i.e., zero on success and non-zero on error. When NULL and an error -occurs, then an error message is printed and the program is terminated. -@end multitable - -@item @emph{NOTES} -It is permitted to have the same image index for both @var{src_image_index} and -@var{dst_image_index}; 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 @code{memmove} which handles (partially) -overlapping memory. If @var{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 @code{memmove} takes care of overlap issues). - -Note that the assignment of a scalar to an array is permitted. In addition, -the library has to handle numeric-type conversion and for strings, padding and -different character kinds. -@end table - -@node _gfortran_caf_send_by_ref -@subsection @code{_gfortran_caf_send_by_ref} --- Sending data from a local image to a remote image with enhanced referencing options -@cindex Coarray, _gfortran_caf_send_by_ref - -@table @asis -@item @emph{Description}: -Called to send a scalar, an array section or a whole array from a local to a -remote image identified by the @var{image_index}. - -@item @emph{Syntax}: -@code{void _gfortran_caf_send_by_ref (caf_token_t token, int image_index, -gfc_descriptor_t *src, caf_reference_t *refs, int dst_kind, int src_kind, -bool may_require_tmp, bool dst_reallocatable, int *stat, int dst_type)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{token} @tab intent(in) An opaque pointer identifying the coarray. -@item @var{image_index} @tab intent(in) The ID of the remote image; must be a -positive number. -@item @var{src} @tab intent(in) Array descriptor of the local array to be -transferred to the remote image -@item @var{refs} @tab intent(in) The references on the remote array to store -the data given by src. Guaranteed to have at least one entry. -@item @var{dst_kind} @tab intent(in) Kind of the destination argument -@item @var{src_kind} @tab intent(in) Kind of the source argument -@item @var{may_require_tmp} @tab intent(in) The variable is @code{false} when -it is known at compile time that the @var{dest} and @var{src} either cannot -overlap or overlap (fully or partially) such that walking @var{src} and -@var{dest} in element wise element order (honoring the stride value) will not -lead to wrong results. Otherwise, the value is @code{true}. -@item @var{dst_reallocatable} @tab intent(in) Set when the destination is of -allocatable or pointer type and the refs will allow reallocation, i.e., the ref -is a full array or component ref. -@item @var{stat} @tab intent(out) When non-@code{NULL} give the result of the -operation, i.e., zero on success and non-zero on error. When @code{NULL} and -an error occurs, then an error message is printed and the program is terminated. -@item @var{dst_type} @tab intent(in) Give the type of the destination. When -the destination is not an array, than the precise type, e.g. of a component in -a derived type, is not known, but provided here. -@end multitable - -@item @emph{NOTES} -It is permitted to have @var{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 -@code{memmove} which handles (partially) overlapping memory. If -@var{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 @code{memmove} takes care of overlap issues). - -Note that the assignment of a scalar to an array is permitted. In addition, -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. -@end table - - -@node _gfortran_caf_get_by_ref -@subsection @code{_gfortran_caf_get_by_ref} --- Getting data from a remote image using enhanced references -@cindex Coarray, _gfortran_caf_get_by_ref - -@table @asis -@item @emph{Description}: -Called to get a scalar, an array section or a whole array from a remote image -identified by the @var{image_index}. - -@item @emph{Syntax}: -@code{void _gfortran_caf_get_by_ref (caf_token_t token, int image_index, -caf_reference_t *refs, gfc_descriptor_t *dst, int dst_kind, int src_kind, -bool may_require_tmp, bool dst_reallocatable, int *stat, int src_type)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{token} @tab intent(in) An opaque pointer identifying the coarray. -@item @var{image_index} @tab intent(in) The ID of the remote image; must be a -positive number. -@item @var{refs} @tab intent(in) The references to apply to the remote structure -to get the data. -@item @var{dst} @tab intent(in) Array descriptor of the local array to store -the data transferred from the remote image. May be reallocated where needed -and when @var{DST_REALLOCATABLE} allows it. -@item @var{dst_kind} @tab intent(in) Kind of the destination argument -@item @var{src_kind} @tab intent(in) Kind of the source argument -@item @var{may_require_tmp} @tab intent(in) The variable is @code{false} when -it is known at compile time that the @var{dest} and @var{src} either cannot -overlap or overlap (fully or partially) such that walking @var{src} and -@var{dest} in element wise element order (honoring the stride value) will not -lead to wrong results. Otherwise, the value is @code{true}. -@item @var{dst_reallocatable} @tab intent(in) Set when @var{DST} is of -allocatable or pointer type and its refs allow reallocation, i.e., the full -array or a component is referenced. -@item @var{stat} @tab intent(out) When non-@code{NULL} give the result of the -operation, i.e., zero on success and non-zero on error. When @code{NULL} and an -error occurs, then an error message is printed and the program is terminated. -@item @var{src_type} @tab 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. -@end multitable - -@item @emph{NOTES} -It is permitted to have @code{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 -@code{memmove} which handles (partially) overlapping memory. If -@var{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 @code{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. -@end table - - -@node _gfortran_caf_sendget_by_ref -@subsection @code{_gfortran_caf_sendget_by_ref} --- Sending data between remote images using enhanced references on both sides -@cindex Coarray, _gfortran_caf_sendget_by_ref - -@table @asis -@item @emph{Description}: -Called to send a scalar, an array section or a whole array from a remote image -identified by the @var{src_image_index} to a remote image identified by the -@var{dst_image_index}. - -@item @emph{Syntax}: -@code{void _gfortran_caf_sendget_by_ref (caf_token_t dst_token, -int dst_image_index, caf_reference_t *dst_refs, -caf_token_t src_token, int src_image_index, caf_reference_t *src_refs, -int dst_kind, int src_kind, bool may_require_tmp, int *dst_stat, -int *src_stat, int dst_type, int src_type)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{dst_token} @tab intent(in) An opaque pointer identifying the -destination coarray. -@item @var{dst_image_index} @tab intent(in) The ID of the destination remote -image; must be a positive number. -@item @var{dst_refs} @tab intent(in) The references on the remote array to store -the data given by the source. Guaranteed to have at least one entry. -@item @var{src_token} @tab intent(in) An opaque pointer identifying the source -coarray. -@item @var{src_image_index} @tab intent(in) The ID of the source remote image; -must be a positive number. -@item @var{src_refs} @tab intent(in) The references to apply to the remote -structure to get the data. -@item @var{dst_kind} @tab intent(in) Kind of the destination argument -@item @var{src_kind} @tab intent(in) Kind of the source argument -@item @var{may_require_tmp} @tab intent(in) The variable is @code{false} when -it is known at compile time that the @var{dest} and @var{src} either cannot -overlap or overlap (fully or partially) such that walking @var{src} and -@var{dest} in element wise element order (honoring the stride value) will not -lead to wrong results. Otherwise, the value is @code{true}. -@item @var{dst_stat} @tab intent(out) when non-@code{NULL} give the result of -the send-operation, i.e., zero on success and non-zero on error. When -@code{NULL} and an error occurs, then an error message is printed and the -program is terminated. -@item @var{src_stat} @tab intent(out) When non-@code{NULL} give the result of -the get-operation, i.e., zero on success and non-zero on error. When -@code{NULL} and an error occurs, then an error message is printed and the -program is terminated. -@item @var{dst_type} @tab intent(in) Give the type of the destination. When -the destination is not an array, than the precise type, e.g. of a component in -a derived type, is not known, but provided here. -@item @var{src_type} @tab 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. -@end multitable - -@item @emph{NOTES} -It is permitted to have the same image index for both @var{src_image_index} and -@var{dst_image_index}; 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 @code{memmove} which handles (partially) -overlapping memory. If @var{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 @code{memmove} takes care of overlap issues). - -Note that the assignment of a scalar to an array is permitted. In addition, -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. -@end table - - -@node _gfortran_caf_lock -@subsection @code{_gfortran_caf_lock} --- Locking a lock variable -@cindex Coarray, _gfortran_caf_lock - -@table @asis -@item @emph{Description}: -Acquire a lock on the given image on a scalar locking variable or for the -given array element for an array-valued variable. If the @var{acquired_lock} -is @code{NULL}, the function returns after having obtained the lock. If it is -non-@code{NULL}, then @var{acquired_lock} is assigned the value true (one) when -the lock could be obtained and false (zero) otherwise. Locking a lock variable -which has already been locked by the same image is an error. - -@item @emph{Syntax}: -@code{void _gfortran_caf_lock (caf_token_t token, size_t index, int image_index, -int *acquired_lock, int *stat, char *errmsg, size_t errmsg_len)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{token} @tab intent(in) An opaque pointer identifying the coarray. -@item @var{index} @tab intent(in) Array index; first array index is 0. For -scalars, it is always 0. -@item @var{image_index} @tab intent(in) The ID of the remote image; must be a -positive number. -@item @var{acquired_lock} @tab intent(out) If not NULL, it returns whether lock -could be obtained. -@item @var{stat} @tab intent(out) Stores the STAT=; may be NULL. -@item @var{errmsg} @tab intent(out) When an error occurs, this will be set to -an error message; may be NULL. -@item @var{errmsg_len} @tab intent(in) the buffer size of errmsg -@end multitable - -@item @emph{NOTES} -This function is also called for critical blocks; for those, the array index -is always zero and the image index is one. Libraries are permitted to use other -images for critical-block locking variables. -@end table - -@node _gfortran_caf_unlock -@subsection @code{_gfortran_caf_lock} --- Unlocking a lock variable -@cindex Coarray, _gfortran_caf_unlock - -@table @asis -@item @emph{Description}: -Release a lock on the given image on a scalar locking variable or for the -given array element for an array-valued variable. Unlocking a lock variable -which is unlocked or has been locked by a different image is an error. - -@item @emph{Syntax}: -@code{void _gfortran_caf_unlock (caf_token_t token, size_t index, int image_index, -int *stat, char *errmsg, size_t errmsg_len)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{token} @tab intent(in) An opaque pointer identifying the coarray. -@item @var{index} @tab intent(in) Array index; first array index is 0. For -scalars, it is always 0. -@item @var{image_index} @tab intent(in) The ID of the remote image; must be a -positive number. -@item @var{stat} @tab intent(out) For allocatable coarrays, stores the STAT=; -may be NULL. -@item @var{errmsg} @tab intent(out) When an error occurs, this will be set to -an error message; may be NULL. -@item @var{errmsg_len} @tab intent(in) the buffer size of errmsg -@end multitable - -@item @emph{NOTES} -This function is also called for critical block; for those, the array index -is always zero and the image index is one. Libraries are permitted to use other -images for critical-block locking variables. -@end table - -@node _gfortran_caf_event_post -@subsection @code{_gfortran_caf_event_post} --- Post an event -@cindex Coarray, _gfortran_caf_event_post - -@table @asis -@item @emph{Description}: -Increment the event count of the specified event variable. - -@item @emph{Syntax}: -@code{void _gfortran_caf_event_post (caf_token_t token, size_t index, -int image_index, int *stat, char *errmsg, size_t errmsg_len)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{token} @tab intent(in) An opaque pointer identifying the coarray. -@item @var{index} @tab intent(in) Array index; first array index is 0. For -scalars, it is always 0. -@item @var{image_index} @tab intent(in) The ID of the remote image; must be a -positive number; zero indicates the current image, when accessed noncoindexed. -@item @var{stat} @tab intent(out) Stores the STAT=; may be NULL. -@item @var{errmsg} @tab intent(out) When an error occurs, this will be set to -an error message; may be NULL. -@item @var{errmsg_len} @tab intent(in) the buffer size of errmsg -@end multitable - -@item @emph{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 @code{event_wait} on the remote -image returns. -@end table - - - -@node _gfortran_caf_event_wait -@subsection @code{_gfortran_caf_event_wait} --- Wait that an event occurred -@cindex Coarray, _gfortran_caf_event_wait - -@table @asis -@item @emph{Description}: -Wait until the event count has reached at least the specified -@var{until_count}; if so, atomically decrement the event variable by this -amount and return. - -@item @emph{Syntax}: -@code{void _gfortran_caf_event_wait (caf_token_t token, size_t index, -int until_count, int *stat, char *errmsg, size_t errmsg_len)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{token} @tab intent(in) An opaque pointer identifying the coarray. -@item @var{index} @tab intent(in) Array index; first array index is 0. For -scalars, it is always 0. -@item @var{until_count} @tab intent(in) The number of events which have to be -available before the function returns. -@item @var{stat} @tab intent(out) Stores the STAT=; may be NULL. -@item @var{errmsg} @tab intent(out) When an error occurs, this will be set to -an error message; may be NULL. -@item @var{errmsg_len} @tab intent(in) the buffer size of errmsg -@end multitable - -@item @emph{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 @var{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. - -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 @code{event_wait} on the remote -image returns. -@end table - - - -@node _gfortran_caf_event_query -@subsection @code{_gfortran_caf_event_query} --- Query event count -@cindex Coarray, _gfortran_caf_event_query - -@table @asis -@item @emph{Description}: -Return the event count of the specified event variable. - -@item @emph{Syntax}: -@code{void _gfortran_caf_event_query (caf_token_t token, size_t index, -int image_index, int *count, int *stat)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{token} @tab intent(in) An opaque pointer identifying the coarray. -@item @var{index} @tab intent(in) Array index; first array index is 0. For -scalars, it is always 0. -@item @var{image_index} @tab intent(in) The ID of the remote image; must be a -positive number; zero indicates the current image when accessed noncoindexed. -@item @var{count} @tab intent(out) The number of events currently posted to -the event variable. -@item @var{stat} @tab intent(out) Stores the STAT=; may be NULL. -@end multitable - -@item @emph{NOTES} -The typical use is to check the local event variable to only call -@code{event_wait} when the data is available. However, a coindexed variable -is permitted; there is no ordering or synchronization implied. It acts like -an atomic fetch of the value of the event variable. -@end table - - - -@node _gfortran_caf_sync_all -@subsection @code{_gfortran_caf_sync_all} --- All-image barrier -@cindex Coarray, _gfortran_caf_sync_all - -@table @asis -@item @emph{Description}: -Synchronization of all images in the current team; the program only continues -on a given image after this function has been called on all images of the -current team. Additionally, it ensures that all pending data transfers of -previous segment have completed. - -@item @emph{Syntax}: -@code{void _gfortran_caf_sync_all (int *stat, char *errmsg, size_t errmsg_len)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{stat} @tab intent(out) Stores the status STAT= and may be NULL. -@item @var{errmsg} @tab intent(out) When an error occurs, this will be set to -an error message; may be NULL. -@item @var{errmsg_len} @tab intent(in) the buffer size of errmsg -@end multitable -@end table - - - -@node _gfortran_caf_sync_images -@subsection @code{_gfortran_caf_sync_images} --- Barrier for selected images -@cindex Coarray, _gfortran_caf_sync_images - -@table @asis -@item @emph{Description}: -Synchronization between the specified images; the program only continues on a -given image after this function has been called on all images specified for -that image. Note that one image can wait for all other images in the current -team (e.g. via @code{sync images(*)}) while those only wait for that specific -image. Additionally, @code{sync images} ensures that all pending data -transfers of previous segments have completed. - -@item @emph{Syntax}: -@code{void _gfortran_caf_sync_images (int count, int images[], int *stat, -char *errmsg, size_t errmsg_len)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{count} @tab intent(in) The number of images which are provided in -the next argument. For a zero-sized array, the value is zero. For -@code{sync images (*)}, the value is @math{-1}. -@item @var{images} @tab intent(in) An array with the images provided by the -user. If @var{count} is zero, a NULL pointer is passed. -@item @var{stat} @tab intent(out) Stores the status STAT= and may be NULL. -@item @var{errmsg} @tab intent(out) When an error occurs, this will be set to -an error message; may be NULL. -@item @var{errmsg_len} @tab intent(in) the buffer size of errmsg -@end multitable -@end table - - - -@node _gfortran_caf_sync_memory -@subsection @code{_gfortran_caf_sync_memory} --- Wait for completion of segment-memory operations -@cindex Coarray, _gfortran_caf_sync_memory - -@table @asis -@item @emph{Description}: -Acts as optimization barrier between different segments. It also ensures that -all pending memory operations of this image have been completed. - -@item @emph{Syntax}: -@code{void _gfortran_caf_sync_memory (int *stat, char *errmsg, size_t errmsg_len)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{stat} @tab intent(out) Stores the status STAT= and may be NULL. -@item @var{errmsg} @tab intent(out) When an error occurs, this will be set to -an error message; may be NULL. -@item @var{errmsg_len} @tab intent(in) the buffer size of errmsg -@end multitable - -@item @emph{NOTE} A simple implementation could be -@code{__asm__ __volatile__ ("":::"memory")} to prevent code movements. -@end table - - - -@node _gfortran_caf_error_stop -@subsection @code{_gfortran_caf_error_stop} --- Error termination with exit code -@cindex Coarray, _gfortran_caf_error_stop - -@table @asis -@item @emph{Description}: -Invoked for an @code{ERROR STOP} statement which has an integer argument. The -function should terminate the program with the specified exit code. - - -@item @emph{Syntax}: -@code{void _gfortran_caf_error_stop (int error)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{error} @tab intent(in) The exit status to be used. -@end multitable -@end table - - - -@node _gfortran_caf_error_stop_str -@subsection @code{_gfortran_caf_error_stop_str} --- Error termination with string -@cindex Coarray, _gfortran_caf_error_stop_str - -@table @asis -@item @emph{Description}: -Invoked for an @code{ERROR STOP} statement which has a string as argument. The -function should terminate the program with a nonzero-exit code. - -@item @emph{Syntax}: -@code{void _gfortran_caf_error_stop (const char *string, size_t len)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{string} @tab intent(in) the error message (not zero terminated) -@item @var{len} @tab intent(in) the length of the string -@end multitable -@end table - - - -@node _gfortran_caf_fail_image -@subsection @code{_gfortran_caf_fail_image} --- Mark the image failed and end its execution -@cindex Coarray, _gfortran_caf_fail_image - -@table @asis -@item @emph{Description}: -Invoked for an @code{FAIL IMAGE} statement. The function should terminate the -current image. - -@item @emph{Syntax}: -@code{void _gfortran_caf_fail_image ()} - -@item @emph{NOTES} -This function follows TS18508. -@end table - - - -@node _gfortran_caf_atomic_define -@subsection @code{_gfortran_caf_atomic_define} --- Atomic variable assignment -@cindex Coarray, _gfortran_caf_atomic_define - -@table @asis -@item @emph{Description}: -Assign atomically a value to an integer or logical variable. - -@item @emph{Syntax}: -@code{void _gfortran_caf_atomic_define (caf_token_t token, size_t offset, -int image_index, void *value, int *stat, int type, int kind)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{token} @tab intent(in) An opaque pointer identifying the coarray. -@item @var{offset} @tab intent(in) By which amount of bytes the actual data is -shifted compared to the base address of the coarray. -@item @var{image_index} @tab intent(in) The ID of the remote image; must be a -positive number; zero indicates the current image when used noncoindexed. -@item @var{value} @tab intent(in) the value to be assigned, passed by reference -@item @var{stat} @tab intent(out) Stores the status STAT= and may be NULL. -@item @var{type} @tab intent(in) The data type, i.e. @code{BT_INTEGER} (1) or -@code{BT_LOGICAL} (2). -@item @var{kind} @tab intent(in) The kind value (only 4; always @code{int}) -@end multitable -@end table - - - -@node _gfortran_caf_atomic_ref -@subsection @code{_gfortran_caf_atomic_ref} --- Atomic variable reference -@cindex Coarray, _gfortran_caf_atomic_ref - -@table @asis -@item @emph{Description}: -Reference atomically a value of a kind-4 integer or logical variable. - -@item @emph{Syntax}: -@code{void _gfortran_caf_atomic_ref (caf_token_t token, size_t offset, -int image_index, void *value, int *stat, int type, int kind)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{token} @tab intent(in) An opaque pointer identifying the coarray. -@item @var{offset} @tab intent(in) By which amount of bytes the actual data is -shifted compared to the base address of the coarray. -@item @var{image_index} @tab intent(in) The ID of the remote image; must be a -positive number; zero indicates the current image when used noncoindexed. -@item @var{value} @tab intent(out) The variable assigned the atomically -referenced variable. -@item @var{stat} @tab intent(out) Stores the status STAT= and may be NULL. -@item @var{type} @tab the data type, i.e. @code{BT_INTEGER} (1) or -@code{BT_LOGICAL} (2). -@item @var{kind} @tab The kind value (only 4; always @code{int}) -@end multitable -@end table - - - -@node _gfortran_caf_atomic_cas -@subsection @code{_gfortran_caf_atomic_cas} --- Atomic compare and swap -@cindex Coarray, _gfortran_caf_atomic_cas - -@table @asis -@item @emph{Description}: -Atomic compare and swap of a kind-4 integer or logical variable. Assigns -atomically the specified value to the atomic variable, if the latter has -the value specified by the passed condition value. - -@item @emph{Syntax}: -@code{void _gfortran_caf_atomic_cas (caf_token_t token, size_t offset, -int image_index, void *old, void *compare, void *new_val, int *stat, -int type, int kind)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{token} @tab intent(in) An opaque pointer identifying the coarray. -@item @var{offset} @tab intent(in) By which amount of bytes the actual data is -shifted compared to the base address of the coarray. -@item @var{image_index} @tab intent(in) The ID of the remote image; must be a -positive number; zero indicates the current image when used noncoindexed. -@item @var{old} @tab intent(out) The value which the atomic variable had -just before the cas operation. -@item @var{compare} @tab intent(in) The value used for comparision. -@item @var{new_val} @tab intent(in) The new value for the atomic variable, -assigned to the atomic variable, if @code{compare} equals the value of the -atomic variable. -@item @var{stat} @tab intent(out) Stores the status STAT= and may be NULL. -@item @var{type} @tab intent(in) the data type, i.e. @code{BT_INTEGER} (1) or -@code{BT_LOGICAL} (2). -@item @var{kind} @tab intent(in) The kind value (only 4; always @code{int}) -@end multitable -@end table - - - -@node _gfortran_caf_atomic_op -@subsection @code{_gfortran_caf_atomic_op} --- Atomic operation -@cindex Coarray, _gfortran_caf_atomic_op - -@table @asis -@item @emph{Description}: -Apply an operation atomically to an atomic integer or logical variable. -After the operation, @var{old} contains the value just before the operation, -which, respectively, adds (GFC_CAF_ATOMIC_ADD) atomically the @code{value} to -the atomic integer variable or does a bitwise AND, OR or exclusive OR -between the atomic variable and @var{value}; the result is then stored in the -atomic variable. - -@item @emph{Syntax}: -@code{void _gfortran_caf_atomic_op (int op, caf_token_t token, size_t offset, -int image_index, void *value, void *old, int *stat, int type, int kind)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{op} @tab intent(in) the operation to be performed; possible values -@code{GFC_CAF_ATOMIC_ADD} (1), @code{GFC_CAF_ATOMIC_AND} (2), -@code{GFC_CAF_ATOMIC_OR} (3), @code{GFC_CAF_ATOMIC_XOR} (4). -@item @var{token} @tab intent(in) An opaque pointer identifying the coarray. -@item @var{offset} @tab intent(in) By which amount of bytes the actual data is -shifted compared to the base address of the coarray. -@item @var{image_index} @tab intent(in) The ID of the remote image; must be a -positive number; zero indicates the current image when used noncoindexed. -@item @var{old} @tab intent(out) The value which the atomic variable had -just before the atomic operation. -@item @var{val} @tab intent(in) The new value for the atomic variable, -assigned to the atomic variable, if @code{compare} equals the value of the -atomic variable. -@item @var{stat} @tab intent(out) Stores the status STAT= and may be NULL. -@item @var{type} @tab intent(in) the data type, i.e. @code{BT_INTEGER} (1) or -@code{BT_LOGICAL} (2) -@item @var{kind} @tab intent(in) the kind value (only 4; always @code{int}) -@end multitable -@end table - - - - -@node _gfortran_caf_co_broadcast -@subsection @code{_gfortran_caf_co_broadcast} --- Sending data to all images -@cindex Coarray, _gfortran_caf_co_broadcast - -@table @asis -@item @emph{Description}: -Distribute a value from a given image to all other images in the team. Has to -be called collectively. - -@item @emph{Syntax}: -@code{void _gfortran_caf_co_broadcast (gfc_descriptor_t *a, -int source_image, int *stat, char *errmsg, size_t errmsg_len)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{a} @tab intent(inout) An array descriptor with the data to be -broadcasted (on @var{source_image}) or to be received (other images). -@item @var{source_image} @tab intent(in) The ID of the image from which the -data should be broadcasted. -@item @var{stat} @tab intent(out) Stores the status STAT= and may be NULL. -@item @var{errmsg} @tab intent(out) When an error occurs, this will be set to -an error message; may be NULL. -@item @var{errmsg_len} @tab intent(in) the buffer size of errmsg. -@end multitable -@end table - - - -@node _gfortran_caf_co_max -@subsection @code{_gfortran_caf_co_max} --- Collective maximum reduction -@cindex Coarray, _gfortran_caf_co_max - -@table @asis -@item @emph{Description}: -Calculates for each array element of the variable @var{a} the maximum -value for that element in the current team; if @var{result_image} has the -value 0, the result shall be stored on all images, otherwise, only on the -specified image. This function operates on numeric values and character -strings. - -@item @emph{Syntax}: -@code{void _gfortran_caf_co_max (gfc_descriptor_t *a, int result_image, -int *stat, char *errmsg, int a_len, size_t errmsg_len)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{a} @tab intent(inout) An array descriptor for the data to be -processed. On the destination image(s) the result overwrites the old content. -@item @var{result_image} @tab 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. -@item @var{stat} @tab intent(out) Stores the status STAT= and may be NULL. -@item @var{errmsg} @tab intent(out) When an error occurs, this will be set to -an error message; may be NULL. -@item @var{a_len} @tab intent(in) the string length of argument @var{a} -@item @var{errmsg_len} @tab intent(in) the buffer size of errmsg -@end multitable - -@item @emph{NOTES} -If @var{result_image} is nonzero, the data in the array descriptor @var{a} on -all images except of the specified one become undefined; hence, the library may -make use of this. -@end table - - - -@node _gfortran_caf_co_min -@subsection @code{_gfortran_caf_co_min} --- Collective minimum reduction -@cindex Coarray, _gfortran_caf_co_min - -@table @asis -@item @emph{Description}: -Calculates for each array element of the variable @var{a} the minimum -value for that element in the current team; if @var{result_image} has the -value 0, the result shall be stored on all images, otherwise, only on the -specified image. This function operates on numeric values and character -strings. - -@item @emph{Syntax}: -@code{void _gfortran_caf_co_min (gfc_descriptor_t *a, int result_image, -int *stat, char *errmsg, int a_len, size_t errmsg_len)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{a} @tab intent(inout) An array descriptor for the data to be -processed. On the destination image(s) the result overwrites the old content. -@item @var{result_image} @tab 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. -@item @var{stat} @tab intent(out) Stores the status STAT= and may be NULL. -@item @var{errmsg} @tab intent(out) When an error occurs, this will be set to -an error message; may be NULL. -@item @var{a_len} @tab intent(in) the string length of argument @var{a} -@item @var{errmsg_len} @tab intent(in) the buffer size of errmsg -@end multitable - -@item @emph{NOTES} -If @var{result_image} is nonzero, the data in the array descriptor @var{a} on -all images except of the specified one become undefined; hence, the library may -make use of this. -@end table - - - -@node _gfortran_caf_co_sum -@subsection @code{_gfortran_caf_co_sum} --- Collective summing reduction -@cindex Coarray, _gfortran_caf_co_sum - -@table @asis -@item @emph{Description}: -Calculates for each array element of the variable @var{a} the sum of all -values for that element in the current team; if @var{result_image} has the -value 0, the result shall be stored on all images, otherwise, only on the -specified image. This function operates on numeric values only. - -@item @emph{Syntax}: -@code{void _gfortran_caf_co_sum (gfc_descriptor_t *a, int result_image, -int *stat, char *errmsg, size_t errmsg_len)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{a} @tab intent(inout) An array descriptor with the data to be -processed. On the destination image(s) the result overwrites the old content. -@item @var{result_image} @tab 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. -@item @var{stat} @tab intent(out) Stores the status STAT= and may be NULL. -@item @var{errmsg} @tab intent(out) When an error occurs, this will be set to -an error message; may be NULL. -@item @var{errmsg_len} @tab intent(in) the buffer size of errmsg -@end multitable - -@item @emph{NOTES} -If @var{result_image} is nonzero, the data in the array descriptor @var{a} on -all images except of the specified one become undefined; hence, the library may -make use of this. -@end table - - - -@node _gfortran_caf_co_reduce -@subsection @code{_gfortran_caf_co_reduce} --- Generic collective reduction -@cindex Coarray, _gfortran_caf_co_reduce - -@table @asis -@item @emph{Description}: -Calculates for each array element of the variable @var{a} the reduction -value for that element in the current team; if @var{result_image} has the -value 0, the result shall be stored on all images, otherwise, only on the -specified image. The @var{opr} is a pure function doing a mathematically -commutative and associative operation. - -The @var{opr_flags} denote the following; the values are bitwise ored. -@code{GFC_CAF_BYREF} (1) if the result should be returned -by reference; @code{GFC_CAF_HIDDENLEN} (2) whether the result and argument -string lengths shall be specified as hidden arguments; -@code{GFC_CAF_ARG_VALUE} (4) whether the arguments shall be passed by value, -@code{GFC_CAF_ARG_DESC} (8) whether the arguments shall be passed by descriptor. - - -@item @emph{Syntax}: -@code{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)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{a} @tab intent(inout) An array descriptor with the data to be -processed. On the destination image(s) the result overwrites the old content. -@item @var{opr} @tab intent(in) Function pointer to the reduction function -@item @var{opr_flags} @tab intent(in) Flags regarding the reduction function -@item @var{result_image} @tab 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. -@item @var{stat} @tab intent(out) Stores the status STAT= and may be NULL. -@item @var{errmsg} @tab intent(out) When an error occurs, this will be set to -an error message; may be NULL. -@item @var{a_len} @tab intent(in) the string length of argument @var{a} -@item @var{errmsg_len} @tab intent(in) the buffer size of errmsg -@end multitable - -@item @emph{NOTES} -If @var{result_image} is nonzero, the data in the array descriptor @var{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. -@end table - - -@c Intrinsic Procedures -@c --------------------------------------------------------------------- - -@include intrinsic.texi - - -@tex -\blankpart -@end tex - -@c --------------------------------------------------------------------- -@c Contributing -@c --------------------------------------------------------------------- - -@node Contributing -@unnumbered Contributing -@cindex 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. - -@menu -* Contributors:: -* Projects:: -@end menu - - -@node Contributors -@section Contributors to GNU Fortran -@cindex Contributors -@cindex Credits -@cindex Authors - -Most of the parser was hand-crafted by @emph{Andy Vaught}, who is -also the initiator of the whole project. Thanks Andy! -Most of the interface with GCC was written by @emph{Paul Brook}. - -The following individuals have contributed code and/or -ideas and significant help to the GNU Fortran project -(in alphabetical order): - -@itemize @minus -@item Janne Blomqvist -@item Steven Bosscher -@item Paul Brook -@item Tobias Burnus -@item Fran@,{c}ois-Xavier Coudert -@item Bud Davis -@item Jerry DeLisle -@item Erik Edelmann -@item Bernhard Fischer -@item Daniel Franke -@item Richard Guenther -@item Richard Henderson -@item Katherine Holcomb -@item Jakub Jelinek -@item Niels Kristian Bech Jensen -@item Steven Johnson -@item Steven G. Kargl -@item Thomas Koenig -@item Asher Langton -@item H. J. Lu -@item Toon Moene -@item Brooks Moses -@item Andrew Pinski -@item Tim Prince -@item Christopher D. Rickett -@item Richard Sandiford -@item Tobias Schl@"uter -@item Roger Sayle -@item Paul Thomas -@item Andy Vaught -@item Feng Wang -@item Janus Weil -@item Daniel Kraft -@end itemize - -The following people have contributed bug reports, -smaller or larger patches, -and much needed feedback and encouragement for the -GNU Fortran project: - -@itemize @minus -@item Bill Clodius -@item Dominique d'Humi@`eres -@item Kate Hedstrom -@item Erik Schnetter -@item Gerhard Steinmetz -@item Joost VandeVondele -@end itemize - -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. - - -@node Projects -@section Projects - -@table @emph - -@item 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. - -@item Bug hunting/squishing -Find bugs and write more test cases! Test cases are especially very -welcome, because it allows us to concentrate on fixing bugs instead of -isolating them. Going through the bugzilla database at -@url{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. - -@item Missing features -For a larger project, consider working on the missing features required for -Fortran language standards compliance (@pxref{Standards}), or contributing -to the implementation of extensions such as OpenMP (@pxref{OpenMP}) or -OpenACC (@pxref{OpenACC}) that are under active development. Again, -contributing test cases for these features is useful too! - -@end table - - -@c --------------------------------------------------------------------- -@c GNU General Public License -@c --------------------------------------------------------------------- - -@include gpl_v3.texi - - - -@c --------------------------------------------------------------------- -@c GNU Free Documentation License -@c --------------------------------------------------------------------- - -@include fdl.texi - - - -@c --------------------------------------------------------------------- -@c Funding Free Software -@c --------------------------------------------------------------------- - -@include funding.texi - -@c --------------------------------------------------------------------- -@c Indices -@c --------------------------------------------------------------------- - -@node Option Index -@unnumbered Option Index -@command{gfortran}'s command line options are indexed here without any -initial @samp{-} or @samp{--}. 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. -@printindex op - -@node Keyword Index -@unnumbered Keyword Index -@printindex cp - -@bye diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi deleted file mode 100644 index 55f53fc..0000000 --- a/gcc/fortran/intrinsic.texi +++ /dev/null @@ -1,15435 +0,0 @@ -@ignore -Copyright (C) 2005-2022 Free Software Foundation, Inc. -This is part of the GNU Fortran manual. -For copying conditions, see the file gfortran.texi. - -Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.3 or -any later version published by the Free Software Foundation; with the -Invariant Sections being ``Funding Free Software'', the Front-Cover -Texts being (a) (see below), and with the Back-Cover Texts being (b) -(see below). A copy of the license is included in the gfdl(7) man page. - - -Some basic guidelines for editing this document: - - (1) The intrinsic procedures are to be listed in alphabetical order. - (2) The generic name is to be used. - (3) The specific names are included in the function index and in a - table at the end of the node (See ABS entry). - (4) Try to maintain the same style for each entry. - - -@end ignore - -@tex -\gdef\acosd{\mathop{\rm acosd}\nolimits} -\gdef\asind{\mathop{\rm asind}\nolimits} -\gdef\atand{\mathop{\rm atand}\nolimits} -\gdef\acos{\mathop{\rm acos}\nolimits} -\gdef\asin{\mathop{\rm asin}\nolimits} -\gdef\atan{\mathop{\rm atan}\nolimits} -\gdef\acosh{\mathop{\rm acosh}\nolimits} -\gdef\asinh{\mathop{\rm asinh}\nolimits} -\gdef\atanh{\mathop{\rm atanh}\nolimits} -\gdef\cosd{\mathop{\rm cosd}\nolimits} -@end tex - - -@node Intrinsic Procedures -@chapter Intrinsic Procedures -@cindex intrinsic procedures - -@menu -* Introduction: Introduction to Intrinsics -* @code{ABORT}: ABORT, Abort the program -* @code{ABS}: ABS, Absolute value -* @code{ACCESS}: ACCESS, Checks file access modes -* @code{ACHAR}: ACHAR, Character in @acronym{ASCII} collating sequence -* @code{ACOS}: ACOS, Arccosine function -* @code{ACOSD}: ACOSD, Arccosine function, degrees -* @code{ACOSH}: ACOSH, Inverse hyperbolic cosine function -* @code{ADJUSTL}: ADJUSTL, Left adjust a string -* @code{ADJUSTR}: ADJUSTR, Right adjust a string -* @code{AIMAG}: AIMAG, Imaginary part of complex number -* @code{AINT}: AINT, Truncate to a whole number -* @code{ALARM}: ALARM, Set an alarm clock -* @code{ALL}: ALL, Determine if all values are true -* @code{ALLOCATED}: ALLOCATED, Status of allocatable entity -* @code{AND}: AND, Bitwise logical AND -* @code{ANINT}: ANINT, Nearest whole number -* @code{ANY}: ANY, Determine if any values are true -* @code{ASIN}: ASIN, Arcsine function -* @code{ASIND}: ASIND, Arcsine function, degrees -* @code{ASINH}: ASINH, Inverse hyperbolic sine function -* @code{ASSOCIATED}: ASSOCIATED, Status of a pointer or pointer/target pair -* @code{ATAN}: ATAN, Arctangent function -* @code{ATAND}: ATAND, Arctangent function, degrees -* @code{ATAN2}: ATAN2, Arctangent function -* @code{ATAN2D}: ATAN2D, Arctangent function, degrees -* @code{ATANH}: ATANH, Inverse hyperbolic tangent function -* @code{ATOMIC_ADD}: ATOMIC_ADD, Atomic ADD operation -* @code{ATOMIC_AND}: ATOMIC_AND, Atomic bitwise AND operation -* @code{ATOMIC_CAS}: ATOMIC_CAS, Atomic compare and swap -* @code{ATOMIC_DEFINE}: ATOMIC_DEFINE, Setting a variable atomically -* @code{ATOMIC_FETCH_ADD}: ATOMIC_FETCH_ADD, Atomic ADD operation with prior fetch -* @code{ATOMIC_FETCH_AND}: ATOMIC_FETCH_AND, Atomic bitwise AND operation with prior fetch -* @code{ATOMIC_FETCH_OR}: ATOMIC_FETCH_OR, Atomic bitwise OR operation with prior fetch -* @code{ATOMIC_FETCH_XOR}: ATOMIC_FETCH_XOR, Atomic bitwise XOR operation with prior fetch -* @code{ATOMIC_OR}: ATOMIC_OR, Atomic bitwise OR operation -* @code{ATOMIC_REF}: ATOMIC_REF, Obtaining the value of a variable atomically -* @code{ATOMIC_XOR}: ATOMIC_XOR, Atomic bitwise OR operation -* @code{BACKTRACE}: BACKTRACE, Show a backtrace -* @code{BESSEL_J0}: BESSEL_J0, Bessel function of the first kind of order 0 -* @code{BESSEL_J1}: BESSEL_J1, Bessel function of the first kind of order 1 -* @code{BESSEL_JN}: BESSEL_JN, Bessel function of the first kind -* @code{BESSEL_Y0}: BESSEL_Y0, Bessel function of the second kind of order 0 -* @code{BESSEL_Y1}: BESSEL_Y1, Bessel function of the second kind of order 1 -* @code{BESSEL_YN}: BESSEL_YN, Bessel function of the second kind -* @code{BGE}: BGE, Bitwise greater than or equal to -* @code{BGT}: BGT, Bitwise greater than -* @code{BIT_SIZE}: BIT_SIZE, Bit size inquiry function -* @code{BLE}: BLE, Bitwise less than or equal to -* @code{BLT}: BLT, Bitwise less than -* @code{BTEST}: BTEST, Bit test function -* @code{C_ASSOCIATED}: C_ASSOCIATED, Status of a C pointer -* @code{C_F_POINTER}: C_F_POINTER, Convert C into Fortran pointer -* @code{C_F_PROCPOINTER}: C_F_PROCPOINTER, Convert C into Fortran procedure pointer -* @code{C_FUNLOC}: C_FUNLOC, Obtain the C address of a procedure -* @code{C_LOC}: C_LOC, Obtain the C address of an object -* @code{C_SIZEOF}: C_SIZEOF, Size in bytes of an expression -* @code{CEILING}: CEILING, Integer ceiling function -* @code{CHAR}: CHAR, Integer-to-character conversion function -* @code{CHDIR}: CHDIR, Change working directory -* @code{CHMOD}: CHMOD, Change access permissions of files -* @code{CMPLX}: CMPLX, Complex conversion function -* @code{CO_BROADCAST}: CO_BROADCAST, Copy a value to all images the current set of images -* @code{CO_MAX}: CO_MAX, Maximal value on the current set of images -* @code{CO_MIN}: CO_MIN, Minimal value on the current set of images -* @code{CO_REDUCE}: CO_REDUCE, Reduction of values on the current set of images -* @code{CO_SUM}: CO_SUM, Sum of values on the current set of images -* @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments -* @code{COMPILER_OPTIONS}: COMPILER_OPTIONS, Options passed to the compiler -* @code{COMPILER_VERSION}: COMPILER_VERSION, Compiler version string -* @code{COMPLEX}: COMPLEX, Complex conversion function -* @code{CONJG}: CONJG, Complex conjugate function -* @code{COS}: COS, Cosine function -* @code{COSD}: COSD, Cosine function, degrees -* @code{COSH}: COSH, Hyperbolic cosine function -* @code{COTAN}: COTAN, Cotangent function -* @code{COTAND}: COTAND, Cotangent function, degrees -* @code{COUNT}: COUNT, Count occurrences of TRUE in an array -* @code{CPU_TIME}: CPU_TIME, CPU time subroutine -* @code{CSHIFT}: CSHIFT, Circular shift elements of an array -* @code{CTIME}: CTIME, Subroutine (or function) to convert a time into a string -* @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine -* @code{DBLE}: DBLE, Double precision conversion function -* @code{DCMPLX}: DCMPLX, Double complex conversion function -* @code{DIGITS}: DIGITS, Significant digits function -* @code{DIM}: DIM, Positive difference -* @code{DOT_PRODUCT}: DOT_PRODUCT, Dot product function -* @code{DPROD}: DPROD, Double product function -* @code{DREAL}: DREAL, Double real part function -* @code{DSHIFTL}: DSHIFTL, Combined left shift -* @code{DSHIFTR}: DSHIFTR, Combined right shift -* @code{DTIME}: DTIME, Execution time subroutine (or function) -* @code{EOSHIFT}: EOSHIFT, End-off shift elements of an array -* @code{EPSILON}: EPSILON, Epsilon function -* @code{ERF}: ERF, Error function -* @code{ERFC}: ERFC, Complementary error function -* @code{ERFC_SCALED}: ERFC_SCALED, Exponentially-scaled complementary error function -* @code{ETIME}: ETIME, Execution time subroutine (or function) -* @code{EVENT_QUERY}: EVENT_QUERY, Query whether a coarray event has occurred -* @code{EXECUTE_COMMAND_LINE}: EXECUTE_COMMAND_LINE, Execute a shell command -* @code{EXIT}: EXIT, Exit the program with status. -* @code{EXP}: EXP, Exponential function -* @code{EXPONENT}: EXPONENT, Exponent function -* @code{EXTENDS_TYPE_OF}: EXTENDS_TYPE_OF, Query dynamic type for extension -* @code{FDATE}: FDATE, Subroutine (or function) to get the current time as a string -* @code{FGET}: FGET, Read a single character in stream mode from stdin -* @code{FGETC}: FGETC, Read a single character in stream mode -* @code{FINDLOC}: FINDLOC, Search an array for a value -* @code{FLOOR}: FLOOR, Integer floor function -* @code{FLUSH}: FLUSH, Flush I/O unit(s) -* @code{FNUM}: FNUM, File number function -* @code{FPUT}: FPUT, Write a single character in stream mode to stdout -* @code{FPUTC}: FPUTC, Write a single character in stream mode -* @code{FRACTION}: FRACTION, Fractional part of the model representation -* @code{FREE}: FREE, Memory de-allocation subroutine -* @code{FSEEK}: FSEEK, Low level file positioning subroutine -* @code{FSTAT}: FSTAT, Get file status -* @code{FTELL}: FTELL, Current stream position -* @code{GAMMA}: GAMMA, Gamma function -* @code{GERROR}: GERROR, Get last system error message -* @code{GETARG}: GETARG, Get command line arguments -* @code{GET_COMMAND}: GET_COMMAND, Get the entire command line -* @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments -* @code{GETCWD}: GETCWD, Get current working directory -* @code{GETENV}: GETENV, Get an environmental variable -* @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable -* @code{GETGID}: GETGID, Group ID function -* @code{GETLOG}: GETLOG, Get login name -* @code{GETPID}: GETPID, Process ID function -* @code{GETUID}: GETUID, User ID function -* @code{GMTIME}: GMTIME, Convert time to GMT info -* @code{HOSTNM}: HOSTNM, Get system host name -* @code{HUGE}: HUGE, Largest number of a kind -* @code{HYPOT}: HYPOT, Euclidean distance function -* @code{IACHAR}: IACHAR, Code in @acronym{ASCII} collating sequence -* @code{IALL}: IALL, Bitwise AND of array elements -* @code{IAND}: IAND, Bitwise logical and -* @code{IANY}: IANY, Bitwise OR of array elements -* @code{IARGC}: IARGC, Get the number of command line arguments -* @code{IBCLR}: IBCLR, Clear bit -* @code{IBITS}: IBITS, Bit extraction -* @code{IBSET}: IBSET, Set bit -* @code{ICHAR}: ICHAR, Character-to-integer conversion function -* @code{IDATE}: IDATE, Current local time (day/month/year) -* @code{IEOR}: IEOR, Bitwise logical exclusive or -* @code{IERRNO}: IERRNO, Function to get the last system error number -* @code{IMAGE_INDEX}: IMAGE_INDEX, Cosubscript to image index conversion -* @code{INDEX}: INDEX intrinsic, Position of a substring within a string -* @code{INT}: INT, Convert to integer type -* @code{INT2}: INT2, Convert to 16-bit integer type -* @code{INT8}: INT8, Convert to 64-bit integer type -* @code{IOR}: IOR, Bitwise logical or -* @code{IPARITY}: IPARITY, Bitwise XOR of array elements -* @code{IRAND}: IRAND, Integer pseudo-random number -* @code{IS_CONTIGUOUS}: IS_CONTIGUOUS, Test whether an array is contiguous -* @code{IS_IOSTAT_END}: IS_IOSTAT_END, Test for end-of-file value -* @code{IS_IOSTAT_EOR}: IS_IOSTAT_EOR, Test for end-of-record value -* @code{ISATTY}: ISATTY, Whether a unit is a terminal device -* @code{ISHFT}: ISHFT, Shift bits -* @code{ISHFTC}: ISHFTC, Shift bits circularly -* @code{ISNAN}: ISNAN, Tests for a NaN -* @code{ITIME}: ITIME, Current local time (hour/minutes/seconds) -* @code{KILL}: KILL, Send a signal to a process -* @code{KIND}: KIND, Kind of an entity -* @code{LBOUND}: LBOUND, Lower dimension bounds of an array -* @code{LCOBOUND}: LCOBOUND, Lower codimension bounds of an array -* @code{LEADZ}: LEADZ, Number of leading zero bits of an integer -* @code{LEN}: LEN, Length of a character entity -* @code{LEN_TRIM}: LEN_TRIM, Length of a character entity without trailing blank characters -* @code{LGE}: LGE, Lexical greater than or equal -* @code{LGT}: LGT, Lexical greater than -* @code{LINK}: LINK, Create a hard link -* @code{LLE}: LLE, Lexical less than or equal -* @code{LLT}: LLT, Lexical less than -* @code{LNBLNK}: LNBLNK, Index of the last non-blank character in a string -* @code{LOC}: LOC, Returns the address of a variable -* @code{LOG}: LOG, Logarithm function -* @code{LOG10}: LOG10, Base 10 logarithm function -* @code{LOG_GAMMA}: LOG_GAMMA, Logarithm of the Gamma function -* @code{LOGICAL}: LOGICAL, Convert to logical type -* @code{LSHIFT}: LSHIFT, Left shift bits -* @code{LSTAT}: LSTAT, Get file status -* @code{LTIME}: LTIME, Convert time to local time info -* @code{MALLOC}: MALLOC, Dynamic memory allocation function -* @code{MASKL}: MASKL, Left justified mask -* @code{MASKR}: MASKR, Right justified mask -* @code{MATMUL}: MATMUL, matrix multiplication -* @code{MAX}: MAX, Maximum value of an argument list -* @code{MAXEXPONENT}: MAXEXPONENT, Maximum exponent of a real kind -* @code{MAXLOC}: MAXLOC, Location of the maximum value within an array -* @code{MAXVAL}: MAXVAL, Maximum value of an array -* @code{MCLOCK}: MCLOCK, Time function -* @code{MCLOCK8}: MCLOCK8, Time function (64-bit) -* @code{MERGE}: MERGE, Merge arrays -* @code{MERGE_BITS}: MERGE_BITS, Merge of bits under mask -* @code{MIN}: MIN, Minimum value of an argument list -* @code{MINEXPONENT}: MINEXPONENT, Minimum exponent of a real kind -* @code{MINLOC}: MINLOC, Location of the minimum value within an array -* @code{MINVAL}: MINVAL, Minimum value of an array -* @code{MOD}: MOD, Remainder function -* @code{MODULO}: MODULO, Modulo function -* @code{MOVE_ALLOC}: MOVE_ALLOC, Move allocation from one object to another -* @code{MVBITS}: MVBITS, Move bits from one integer to another -* @code{NEAREST}: NEAREST, Nearest representable number -* @code{NEW_LINE}: NEW_LINE, New line character -* @code{NINT}: NINT, Nearest whole number -* @code{NORM2}: NORM2, Euclidean vector norm -* @code{NOT}: NOT, Logical negation -* @code{NULL}: NULL, Function that returns an disassociated pointer -* @code{NUM_IMAGES}: NUM_IMAGES, Number of images -* @code{OR}: OR, Bitwise logical OR -* @code{PACK}: PACK, Pack an array into an array of rank one -* @code{PARITY}: PARITY, Reduction with exclusive OR -* @code{PERROR}: PERROR, Print system error message -* @code{POPCNT}: POPCNT, Number of bits set -* @code{POPPAR}: POPPAR, Parity of the number of bits set -* @code{PRECISION}: PRECISION, Decimal precision of a real kind -* @code{PRESENT}: PRESENT, Determine whether an optional dummy argument is specified -* @code{PRODUCT}: PRODUCT, Product of array elements -* @code{RADIX}: RADIX, Base of a data model -* @code{RAN}: RAN, Real pseudo-random number -* @code{RAND}: RAND, Real pseudo-random number -* @code{RANDOM_INIT}: RANDOM_INIT, Initialize pseudo-random number generator -* @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number -* @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence -* @code{RANGE}: RANGE, Decimal exponent range -* @code{RANK} : RANK, Rank of a data object -* @code{REAL}: REAL, Convert to real type -* @code{RENAME}: RENAME, Rename a file -* @code{REPEAT}: REPEAT, Repeated string concatenation -* @code{RESHAPE}: RESHAPE, Function to reshape an array -* @code{RRSPACING}: RRSPACING, Reciprocal of the relative spacing -* @code{RSHIFT}: RSHIFT, Right shift bits -* @code{SAME_TYPE_AS}: SAME_TYPE_AS, Query dynamic types for equality -* @code{SCALE}: SCALE, Scale a real value -* @code{SCAN}: SCAN, Scan a string for the presence of a set of characters -* @code{SECNDS}: SECNDS, Time function -* @code{SECOND}: SECOND, CPU time function -* @code{SELECTED_CHAR_KIND}: SELECTED_CHAR_KIND, Choose character kind -* @code{SELECTED_INT_KIND}: SELECTED_INT_KIND, Choose integer kind -* @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND, Choose real kind -* @code{SET_EXPONENT}: SET_EXPONENT, Set the exponent of the model -* @code{SHAPE}: SHAPE, Determine the shape of an array -* @code{SHIFTA}: SHIFTA, Right shift with fill -* @code{SHIFTL}: SHIFTL, Left shift -* @code{SHIFTR}: SHIFTR, Right shift -* @code{SIGN}: SIGN, Sign copying function -* @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function) -* @code{SIN}: SIN, Sine function -* @code{SIND}: SIND, Sine function, degrees -* @code{SINH}: SINH, Hyperbolic sine function -* @code{SIZE}: SIZE, Function to determine the size of an array -* @code{SIZEOF}: SIZEOF, Determine the size in bytes of an expression -* @code{SLEEP}: SLEEP, Sleep for the specified number of seconds -* @code{SPACING}: SPACING, Smallest distance between two numbers of a given type -* @code{SPREAD}: SPREAD, Add a dimension to an array -* @code{SQRT}: SQRT, Square-root function -* @code{SRAND}: SRAND, Reinitialize the random number generator -* @code{STAT}: STAT, Get file status -* @code{STORAGE_SIZE}: STORAGE_SIZE, Storage size in bits -* @code{SUM}: SUM, Sum of array elements -* @code{SYMLNK}: SYMLNK, Create a symbolic link -* @code{SYSTEM}: SYSTEM, Execute a shell command -* @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function -* @code{TAN}: TAN, Tangent function -* @code{TAND}: TAND, Tangent function, degrees -* @code{TANH}: TANH, Hyperbolic tangent function -* @code{THIS_IMAGE}: THIS_IMAGE, Cosubscript index of this image -* @code{TIME}: TIME, Time function -* @code{TIME8}: TIME8, Time function (64-bit) -* @code{TINY}: TINY, Smallest positive number of a real kind -* @code{TRAILZ}: TRAILZ, Number of trailing zero bits of an integer -* @code{TRANSFER}: TRANSFER, Transfer bit patterns -* @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two -* @code{TRIM}: TRIM, Remove trailing blank characters of a string -* @code{TTYNAM}: TTYNAM, Get the name of a terminal device -* @code{UBOUND}: UBOUND, Upper dimension bounds of an array -* @code{UCOBOUND}: UCOBOUND, Upper codimension bounds of an array -* @code{UMASK}: UMASK, Set the file creation mask -* @code{UNLINK}: UNLINK, Remove a file from the file system -* @code{UNPACK}: UNPACK, Unpack an array of rank one into an array -* @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters -* @code{XOR}: XOR, Bitwise logical exclusive or -@end menu - -@node Introduction to Intrinsics -@section Introduction to intrinsic procedures - -The intrinsic procedures provided by GNU Fortran include procedures required -by the Fortran 95 and later supported standards, and a set of intrinsic -procedures for backwards compatibility with G77. Any conflict between -a description here and a description in the Fortran standards is -unintentional, and the standard(s) should be considered authoritative. - -The enumeration of the @code{KIND} type parameter is processor defined in -the Fortran 95 standard. GNU Fortran defines the default integer type and -default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)}, -respectively. The standard mandates that both data types shall have -another kind, which have more precision. On typical target architectures -supported by @command{gfortran}, this kind type parameter is @code{KIND=8}. -Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent. -In the description of generic intrinsic procedures, the kind type parameter -will be specified by @code{KIND=*}, and in the description of specific -names for an intrinsic procedure the kind type parameter will be explicitly -given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for -brevity the optional @code{KIND=} syntax will be omitted. - -Many of the intrinsic procedures take one or more optional arguments. -This document follows the convention used in the Fortran 95 standard, -and denotes such arguments by square brackets. - -GNU Fortran offers the @option{-std=} command-line option, -which can be used to restrict the set of intrinsic procedures to a -given standard. By default, @command{gfortran} sets the @option{-std=gnu} -option, and so all intrinsic procedures described here are accepted. There -is one caveat. For a select group of intrinsic procedures, @command{g77} -implemented both a function and a subroutine. Both classes -have been implemented in @command{gfortran} for backwards compatibility -with @command{g77}. It is noted here that these functions and subroutines -cannot be intermixed in a given subprogram. In the descriptions that follow, -the applicable standard for each intrinsic procedure is noted. - - - -@node ABORT -@section @code{ABORT} --- Abort the program -@fnindex ABORT -@cindex program termination, with core dump -@cindex terminate program, with core dump -@cindex core, dump - -@table @asis -@item @emph{Description}: -@code{ABORT} causes immediate termination of the program. On operating -systems that support a core dump, @code{ABORT} will produce a core dump. -It will also print a backtrace, unless @code{-fno-backtrace} is given. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL ABORT} - -@item @emph{Return value}: -Does not return. - -@item @emph{Example}: -@smallexample -program test_abort - integer :: i = 1, j = 2 - if (i /= j) call abort -end program test_abort -@end smallexample - -@item @emph{See also}: -@ref{EXIT}, @gol -@ref{KILL}, @gol -@ref{BACKTRACE} -@end table - - - -@node ABS -@section @code{ABS} --- Absolute value -@fnindex ABS -@fnindex CABS -@fnindex DABS -@fnindex IABS -@fnindex ZABS -@fnindex CDABS -@fnindex BABS -@fnindex IIABS -@fnindex JIABS -@fnindex KIABS -@cindex absolute value - -@table @asis -@item @emph{Description}: -@code{ABS(A)} computes the absolute value of @code{A}. - -@item @emph{Standard}: -Fortran 77 and later, has overloads that are GNU extensions - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ABS(A)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab The type of the argument shall be an @code{INTEGER}, -@code{REAL}, or @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value is of the same type and -kind as the argument except the return value is @code{REAL} for a -@code{COMPLEX} argument. - -@item @emph{Example}: -@smallexample -program test_abs - integer :: i = -1 - real :: x = -1.e0 - complex :: z = (-1.e0,0.e0) - i = abs(i) - x = abs(x) - x = abs(z) -end program test_abs -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{ABS(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{CABS(A)} @tab @code{COMPLEX(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DABS(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later -@item @code{IABS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab Fortran 77 and later -@item @code{BABS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension -@item @code{IIABS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension -@item @code{JIABS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension -@item @code{KIABS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension -@item @code{ZABS(A)} @tab @code{COMPLEX(8) A} @tab @code{REAL(8)} @tab GNU extension -@item @code{CDABS(A)} @tab @code{COMPLEX(8) A} @tab @code{REAL(8)} @tab GNU extension -@end multitable -@end table - - - -@node ACCESS -@section @code{ACCESS} --- Checks file access modes -@fnindex ACCESS -@cindex file system, access mode - -@table @asis -@item @emph{Description}: -@code{ACCESS(NAME, MODE)} checks whether the file @var{NAME} -exists, is readable, writable or executable. Except for the -executable check, @code{ACCESS} can be replaced by -Fortran 95's @code{INQUIRE}. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = ACCESS(NAME, MODE)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the -file name. Trailing blank are ignored unless the character @code{achar(0)} -is present, then all characters up to and excluding @code{achar(0)} are -used as file name. -@item @var{MODE} @tab Scalar @code{CHARACTER} of default kind with the -file access mode, may be any concatenation of @code{"r"} (readable), -@code{"w"} (writable) and @code{"x"} (executable), or @code{" "} to check -for existence. -@end multitable - -@item @emph{Return value}: -Returns a scalar @code{INTEGER}, which is @code{0} if the file is -accessible in the given mode; otherwise or if an invalid argument -has been given for @code{MODE} the value @code{1} is returned. - -@item @emph{Example}: -@smallexample -program access_test - implicit none - character(len=*), parameter :: file = 'test.dat' - character(len=*), parameter :: file2 = 'test.dat '//achar(0) - if(access(file,' ') == 0) print *, trim(file),' is exists' - if(access(file,'r') == 0) print *, trim(file),' is readable' - if(access(file,'w') == 0) print *, trim(file),' is writable' - if(access(file,'x') == 0) print *, trim(file),' is executable' - if(access(file2,'rwx') == 0) & - print *, trim(file2),' is readable, writable and executable' -end program access_test -@end smallexample -@end table - - - -@node ACHAR -@section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence -@fnindex ACHAR -@cindex @acronym{ASCII} collating sequence -@cindex collating sequence, @acronym{ASCII} - -@table @asis -@item @emph{Description}: -@code{ACHAR(I)} returns the character located at position @code{I} -in the @acronym{ASCII} collating sequence. - -@item @emph{Standard}: -Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ACHAR(I [, KIND])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{CHARACTER} with a length of one. -If the @var{KIND} argument is present, the return value is of the -specified kind and of the default kind otherwise. - -@item @emph{Example}: -@smallexample -program test_achar - character c - c = achar(32) -end program test_achar -@end smallexample - -@item @emph{Note}: -See @ref{ICHAR} for a discussion of converting between numerical values -and formatted string representations. - -@item @emph{See also}: -@ref{CHAR}, @gol -@ref{IACHAR}, @gol -@ref{ICHAR} -@end table - - - -@node ACOS -@section @code{ACOS} --- Arccosine function -@fnindex ACOS -@fnindex DACOS -@cindex trigonometric function, cosine, inverse -@cindex cosine, inverse - -@table @asis -@item @emph{Description}: -@code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}). - -@item @emph{Standard}: -Fortran 77 and later, for a complex argument Fortran 2008 or later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ACOS(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is -less than or equal to one - or the type shall be @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value is of the same type and kind as @var{X}. -The real part of the result is in radians and lies in the range -@math{0 \leq \Re \acos(x) \leq \pi}. - -@item @emph{Example}: -@smallexample -program test_acos - real(8) :: x = 0.866_8 - x = acos(x) -end program test_acos -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{ACOS(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later -@end multitable - -@item @emph{See also}: -Inverse function: @gol -@ref{COS} @gol -Degrees function: @gol -@ref{ACOSD} -@end table - - - -@node ACOSD -@section @code{ACOSD} --- Arccosine function, degrees -@fnindex ACOSD -@fnindex DACOSD -@cindex trigonometric function, cosine, inverse, degrees -@cindex cosine, inverse, degrees - -@table @asis -@item @emph{Description}: -@code{ACOSD(X)} computes the arccosine of @var{X} in degrees (inverse of -@code{COSD(X)}). - -This function is for compatibility only and should be avoided in favor of -standard constructs wherever possible. - -@item @emph{Standard}: -GNU extension, enabled with @option{-fdec-math} - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ACOSD(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is -less than or equal to one - or the type shall be @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value is of the same type and kind as @var{X}. -The real part of the result is in degrees and lies in the range -@math{0 \leq \Re \acos(x) \leq 180}. - -@item @emph{Example}: -@smallexample -program test_acosd - real(8) :: x = 0.866_8 - x = acosd(x) -end program test_acosd -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{ACOSD(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension -@item @code{DACOSD(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -Inverse function: @gol -@ref{COSD} @gol -Radians function: @gol -@ref{ACOS} @gol -@end table - - - -@node ACOSH -@section @code{ACOSH} --- Inverse hyperbolic cosine function -@fnindex ACOSH -@fnindex DACOSH -@cindex area hyperbolic cosine -@cindex inverse hyperbolic cosine -@cindex hyperbolic function, cosine, inverse -@cindex cosine, hyperbolic, inverse - -@table @asis -@item @emph{Description}: -@code{ACOSH(X)} computes the inverse hyperbolic cosine of @var{X}. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ACOSH(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value has the same type and kind as @var{X}. If @var{X} is -complex, the imaginary part of the result is in radians and lies between -@math{ 0 \leq \Im \acosh(x) \leq \pi}. - -@item @emph{Example}: -@smallexample -PROGRAM test_acosh - REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /) - WRITE (*,*) ACOSH(x) -END PROGRAM -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{DACOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -Inverse function: @gol -@ref{COSH} -@end table - - - -@node ADJUSTL -@section @code{ADJUSTL} --- Left adjust a string -@fnindex ADJUSTL -@cindex string, adjust left -@cindex adjust string - -@table @asis -@item @emph{Description}: -@code{ADJUSTL(STRING)} will left adjust a string by removing leading spaces. -Spaces are inserted at the end of the string as needed. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ADJUSTL(STRING)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{STRING} @tab The type shall be @code{CHARACTER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{CHARACTER} and of the same kind as -@var{STRING} where leading spaces are removed and the same number of -spaces are inserted on the end of @var{STRING}. - -@item @emph{Example}: -@smallexample -program test_adjustl - character(len=20) :: str = ' gfortran' - str = adjustl(str) - print *, str -end program test_adjustl -@end smallexample - -@item @emph{See also}: -@ref{ADJUSTR}, @gol -@ref{TRIM} -@end table - - - -@node ADJUSTR -@section @code{ADJUSTR} --- Right adjust a string -@fnindex ADJUSTR -@cindex string, adjust right -@cindex adjust string - -@table @asis -@item @emph{Description}: -@code{ADJUSTR(STRING)} will right adjust a string by removing trailing spaces. -Spaces are inserted at the start of the string as needed. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ADJUSTR(STRING)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{STR} @tab The type shall be @code{CHARACTER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{CHARACTER} and of the same kind as -@var{STRING} where trailing spaces are removed and the same number of -spaces are inserted at the start of @var{STRING}. - -@item @emph{Example}: -@smallexample -program test_adjustr - character(len=20) :: str = 'gfortran' - str = adjustr(str) - print *, str -end program test_adjustr -@end smallexample - -@item @emph{See also}: -@ref{ADJUSTL}, @gol -@ref{TRIM} -@end table - - - -@node AIMAG -@section @code{AIMAG} --- Imaginary part of complex number -@fnindex AIMAG -@fnindex DIMAG -@fnindex IMAG -@fnindex IMAGPART -@cindex complex numbers, imaginary part - -@table @asis -@item @emph{Description}: -@code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}. -The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided -for compatibility with @command{g77}, and their use in new code is -strongly discouraged. - -@item @emph{Standard}: -Fortran 77 and later, has overloads that are GNU extensions - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = AIMAG(Z)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{Z} @tab The type of the argument shall be @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{REAL} with the -kind type parameter of the argument. - -@item @emph{Example}: -@smallexample -program test_aimag - complex(4) z4 - complex(8) z8 - z4 = cmplx(1.e0_4, 0.e0_4) - z8 = cmplx(0.e0_8, 1.e0_8) - print *, aimag(z4), dimag(z8) -end program test_aimag -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{AIMAG(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab Fortran 77 and later -@item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension -@item @code{IMAG(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension -@item @code{IMAGPART(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension -@end multitable -@end table - - - -@node AINT -@section @code{AINT} --- Truncate to a whole number -@fnindex AINT -@fnindex DINT -@cindex floor -@cindex rounding, floor - -@table @asis -@item @emph{Description}: -@code{AINT(A [, KIND])} truncates its argument to a whole number. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = AINT(A [, KIND])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab The type of the argument shall be @code{REAL}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{REAL} with the kind type parameter of the -argument if the optional @var{KIND} is absent; otherwise, the kind -type parameter will be given by @var{KIND}. If the magnitude of -@var{X} is less than one, @code{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 @var{X}. - -@item @emph{Example}: -@smallexample -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 -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{AINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later -@end multitable -@end table - - - -@node ALARM -@section @code{ALARM} --- Execute a routine after a given delay -@fnindex ALARM -@cindex delayed execution - -@table @asis -@item @emph{Description}: -@code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER} -to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to -set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is -supplied, it will be returned with the number of seconds remaining until -any previously scheduled alarm was due to be delivered, or zero if there -was no previously scheduled alarm. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL ALARM(SECONDS, HANDLER [, STATUS])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{SECONDS} @tab The type of the argument shall be a scalar -@code{INTEGER}. It is @code{INTENT(IN)}. -@item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or -@code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar -values may be either @code{SIG_IGN=1} to ignore the alarm generated -or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}. -@item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar -variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}. -@end multitable - -@item @emph{Example}: -@smallexample -program test_alarm - external handler_print - integer i - call alarm (3, handler_print, i) - print *, i - call sleep(10) -end program test_alarm -@end smallexample -This will cause the external routine @var{handler_print} to be called -after 3 seconds. -@end table - - - -@node ALL -@section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true -@fnindex ALL -@cindex array, apply condition -@cindex array, condition testing - -@table @asis -@item @emph{Description}: -@code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK} -in the array along dimension @var{DIM}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = ALL(MASK [, DIM])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and -it shall not be scalar. -@item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer -with a value that lies between one and the rank of @var{MASK}. -@end multitable - -@item @emph{Return value}: -@code{ALL(MASK)} returns a scalar value of type @code{LOGICAL} where -the kind type parameter is the same as the kind type parameter of -@var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns -an array with the rank of @var{MASK} minus 1. The shape is determined from -the shape of @var{MASK} where the @var{DIM} dimension is elided. - -@table @asis -@item (A) -@code{ALL(MASK)} is true if all elements of @var{MASK} are true. -It also is true if @var{MASK} has zero size; otherwise, it is false. -@item (B) -If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent -to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)} -is determined by applying @code{ALL} to the array sections. -@end table - -@item @emph{Example}: -@smallexample -program test_all - logical l - l = all((/.true., .true., .true./)) - print *, l - call section - contains - subroutine section - integer a(2,3), b(2,3) - a = 1 - b = 1 - b(2,2) = 2 - print *, all(a .eq. b, 1) - print *, all(a .eq. b, 2) - end subroutine section -end program test_all -@end smallexample -@end table - - - -@node ALLOCATED -@section @code{ALLOCATED} --- Status of an allocatable entity -@fnindex ALLOCATED -@cindex allocation, status - -@table @asis -@item @emph{Description}: -@code{ALLOCATED(ARRAY)} and @code{ALLOCATED(SCALAR)} check the allocation -status of @var{ARRAY} and @var{SCALAR}, respectively. - -@item @emph{Standard}: -Fortran 90 and later. Note, the @code{SCALAR=} keyword and allocatable -scalar entities are available in Fortran 2003 and later. - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = ALLOCATED(ARRAY)} -@item @code{RESULT = ALLOCATED(SCALAR)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab The argument shall be an @code{ALLOCATABLE} array. -@item @var{SCALAR} @tab The argument shall be an @code{ALLOCATABLE} scalar. -@end multitable - -@item @emph{Return value}: -The return value is a scalar @code{LOGICAL} with the default logical -kind type parameter. If the argument is allocated, then the result is -@code{.TRUE.}; otherwise, it returns @code{.FALSE.} - -@item @emph{Example}: -@smallexample -program test_allocated - integer :: i = 4 - real(4), allocatable :: x(:) - if (.not. allocated(x)) allocate(x(i)) -end program test_allocated -@end smallexample -@end table - - - -@node AND -@section @code{AND} --- Bitwise logical AND -@fnindex AND -@cindex bitwise logical and -@cindex logical and, bitwise - -@table @asis -@item @emph{Description}: -Bitwise logical @code{AND}. - -This intrinsic routine is provided for backwards compatibility with -GNU Fortran 77. For integer arguments, programmers should consider -the use of the @ref{IAND} intrinsic defined by the Fortran standard. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{RESULT = AND(I, J)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be either a scalar @code{INTEGER} -type or a scalar @code{LOGICAL} type or a boz-literal-constant. -@item @var{J} @tab The type shall be the same as the type of @var{I} or -a boz-literal-constant. @var{I} and @var{J} shall not both be -boz-literal-constants. If either @var{I} or @var{J} is a -boz-literal-constant, then the other argument must be a scalar @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return type is either a scalar @code{INTEGER} or a scalar -@code{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 @code{INTEGER} with the kind type parameter of -the other argument as-if a call to @ref{INT} occurred. - -@item @emph{Example}: -@smallexample -PROGRAM test_and - LOGICAL :: T = .TRUE., F = .FALSE. - INTEGER :: a, b - DATA a / Z'F' /, b / Z'3' / - - WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F) - WRITE (*,*) AND(a, b) -END PROGRAM -@end smallexample - -@item @emph{See also}: -Fortran 95 elemental function: @gol -@ref{IAND} -@end table - - - -@node ANINT -@section @code{ANINT} --- Nearest whole number -@fnindex ANINT -@fnindex DNINT -@cindex ceiling -@cindex rounding, ceiling - -@table @asis -@item @emph{Description}: -@code{ANINT(A [, KIND])} rounds its argument to the nearest whole number. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ANINT(A [, KIND])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab The type of the argument shall be @code{REAL}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type real with the kind type parameter of the -argument if the optional @var{KIND} is absent; otherwise, the kind -type parameter will be given by @var{KIND}. If @var{A} is greater than -zero, @code{ANINT(A)} returns @code{AINT(X+0.5)}. If @var{A} is -less than or equal to zero then it returns @code{AINT(X-0.5)}. - -@item @emph{Example}: -@smallexample -program test_anint - real(4) x4 - real(8) x8 - x4 = 1.234E0_4 - x8 = 4.321_8 - print *, anint(x4), dnint(x8) - x8 = anint(x4,8) -end program test_anint -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{ANINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DNINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later -@end multitable -@end table - - - -@node ANY -@section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true -@fnindex ANY -@cindex array, apply condition -@cindex array, condition testing - -@table @asis -@item @emph{Description}: -@code{ANY(MASK [, DIM])} determines if any of the values in the logical array -@var{MASK} along dimension @var{DIM} are @code{.TRUE.}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = ANY(MASK [, DIM])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and -it shall not be scalar. -@item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer -with a value that lies between one and the rank of @var{MASK}. -@end multitable - -@item @emph{Return value}: -@code{ANY(MASK)} returns a scalar value of type @code{LOGICAL} where -the kind type parameter is the same as the kind type parameter of -@var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns -an array with the rank of @var{MASK} minus 1. The shape is determined from -the shape of @var{MASK} where the @var{DIM} dimension is elided. - -@table @asis -@item (A) -@code{ANY(MASK)} is true if any element of @var{MASK} is true; -otherwise, it is false. It also is false if @var{MASK} has zero size. -@item (B) -If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent -to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)} -is determined by applying @code{ANY} to the array sections. -@end table - -@item @emph{Example}: -@smallexample -program test_any - logical l - l = any((/.true., .true., .true./)) - print *, l - call section - contains - subroutine section - integer a(2,3), b(2,3) - a = 1 - b = 1 - b(2,2) = 2 - print *, any(a .eq. b, 1) - print *, any(a .eq. b, 2) - end subroutine section -end program test_any -@end smallexample -@end table - - - -@node ASIN -@section @code{ASIN} --- Arcsine function -@fnindex ASIN -@fnindex DASIN -@cindex trigonometric function, sine, inverse -@cindex sine, inverse - -@table @asis -@item @emph{Description}: -@code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}). - -@item @emph{Standard}: -Fortran 77 and later, for a complex argument Fortran 2008 or later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ASIN(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is -less than or equal to one - or be @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value is of the same type and kind as @var{X}. -The real part of the result is in radians and lies in the range -@math{-\pi/2 \leq \Re \asin(x) \leq \pi/2}. - -@item @emph{Example}: -@smallexample -program test_asin - real(8) :: x = 0.866_8 - x = asin(x) -end program test_asin -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{ASIN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later -@end multitable - -@item @emph{See also}: -Inverse function: @gol -@ref{SIN} @gol -Degrees function: @gol -@ref{ASIND} -@end table - - - -@node ASIND -@section @code{ASIND} --- Arcsine function, degrees -@fnindex ASIND -@fnindex DASIND -@cindex trigonometric function, sine, inverse, degrees -@cindex sine, inverse, degrees - -@table @asis -@item @emph{Description}: -@code{ASIND(X)} computes the arcsine of its @var{X} in degrees (inverse of -@code{SIND(X)}). - -This function is for compatibility only and should be avoided in favor of -standard constructs wherever possible. - -@item @emph{Standard}: -GNU extension, enabled with @option{-fdec-math}. - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ASIND(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is -less than or equal to one - or be @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value is of the same type and kind as @var{X}. -The real part of the result is in degrees and lies in the range -@math{-90 \leq \Re \asin(x) \leq 90}. - -@item @emph{Example}: -@smallexample -program test_asind - real(8) :: x = 0.866_8 - x = asind(x) -end program test_asind -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{ASIND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension -@item @code{DASIND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -Inverse function: @gol -@ref{SIND} @gol -Radians function: @gol -@ref{ASIN} -@end table - - - -@node ASINH -@section @code{ASINH} --- Inverse hyperbolic sine function -@fnindex ASINH -@fnindex DASINH -@cindex area hyperbolic sine -@cindex inverse hyperbolic sine -@cindex hyperbolic function, sine, inverse -@cindex sine, hyperbolic, inverse - -@table @asis -@item @emph{Description}: -@code{ASINH(X)} computes the inverse hyperbolic sine of @var{X}. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ASINH(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value is of the same type and kind as @var{X}. If @var{X} is -complex, the imaginary part of the result is in radians and lies between -@math{-\pi/2 \leq \Im \asinh(x) \leq \pi/2}. - -@item @emph{Example}: -@smallexample -PROGRAM test_asinh - REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /) - WRITE (*,*) ASINH(x) -END PROGRAM -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{DASINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension. -@end multitable - -@item @emph{See also}: -Inverse function: @gol -@ref{SINH} -@end table - - - -@node ASSOCIATED -@section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair -@fnindex ASSOCIATED -@cindex pointer, status -@cindex association status - -@table @asis -@item @emph{Description}: -@code{ASSOCIATED(POINTER [, TARGET])} determines the status of the pointer -@var{POINTER} or if @var{POINTER} is associated with the target @var{TARGET}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = ASSOCIATED(POINTER [, TARGET])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{POINTER} @tab @var{POINTER} shall have the @code{POINTER} attribute -and it can be of any type. -@item @var{TARGET} @tab (Optional) @var{TARGET} shall be a pointer or -a target. It must have the same type, kind type parameter, and -array rank as @var{POINTER}. -@end multitable -The association status of neither @var{POINTER} nor @var{TARGET} shall be -undefined. - -@item @emph{Return value}: -@code{ASSOCIATED(POINTER)} returns a scalar value of type @code{LOGICAL(4)}. -There are several cases: -@table @asis -@item (A) When the optional @var{TARGET} is not present then -@code{ASSOCIATED(POINTER)} is true if @var{POINTER} is associated with a target; otherwise, it returns false. -@item (B) If @var{TARGET} is present and a scalar target, the result is true if -@var{TARGET} is not a zero-sized storage sequence and the target associated with @var{POINTER} occupies the same storage units. If @var{POINTER} is -disassociated, the result is false. -@item (C) If @var{TARGET} is present and an array target, the result is true if -@var{TARGET} and @var{POINTER} have the same shape, are not zero-sized arrays, -are arrays whose elements are not zero-sized storage sequences, and -@var{TARGET} and @var{POINTER} occupy the same storage units in array element -order. -As in case(B), the result is false, if @var{POINTER} is disassociated. -@item (D) If @var{TARGET} is present and an scalar pointer, the result is true -if @var{TARGET} is associated with @var{POINTER}, the target associated with -@var{TARGET} are not zero-sized storage sequences and occupy the same storage -units. -The result is false, if either @var{TARGET} or @var{POINTER} is disassociated. -@item (E) If @var{TARGET} is present and an array pointer, the result is true if -target associated with @var{POINTER} and the target associated with @var{TARGET} -have the same shape, are not zero-sized arrays, are arrays whose elements are -not zero-sized storage sequences, and @var{TARGET} and @var{POINTER} occupy -the same storage units in array element order. -The result is false, if either @var{TARGET} or @var{POINTER} is disassociated. -@end table - -@item @emph{Example}: -@smallexample -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 -@end smallexample - -@item @emph{See also}: -@ref{NULL} -@end table - - - -@node ATAN -@section @code{ATAN} --- Arctangent function -@fnindex ATAN -@fnindex DATAN -@cindex trigonometric function, tangent, inverse -@cindex tangent, inverse - -@table @asis -@item @emph{Description}: -@code{ATAN(X)} computes the arctangent of @var{X}. - -@item @emph{Standard}: -Fortran 77 and later, for a complex argument and for two arguments -Fortran 2008 or later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = ATAN(X)} -@item @code{RESULT = ATAN(Y, X)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}; -if @var{Y} is present, @var{X} shall be REAL. -@item @var{Y} @tab The type and kind type parameter shall be the same as @var{X}. -@end multitable - -@item @emph{Return value}: -The return value is of the same type and kind as @var{X}. -If @var{Y} is present, the result is identical to @code{ATAN2(Y,X)}. -Otherwise, it the arcus tangent of @var{X}, where the real part of -the result is in radians and lies in the range -@math{-\pi/2 \leq \Re \atan(x) \leq \pi/2}. - -@item @emph{Example}: -@smallexample -program test_atan - real(8) :: x = 2.866_8 - x = atan(x) -end program test_atan -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{ATAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later -@end multitable - -@item @emph{See also}: -Inverse function: @gol -@ref{TAN} @gol -Degrees function: @gol -@ref{ATAND} -@end table - - - -@node ATAND -@section @code{ATAND} --- Arctangent function, degrees -@fnindex ATAND -@fnindex DATAND -@cindex trigonometric function, tangent, inverse, degrees -@cindex tangent, inverse, degrees - -@table @asis -@item @emph{Description}: -@code{ATAND(X)} computes the arctangent of @var{X} in degrees (inverse of -@ref{TAND}). - -This function is for compatibility only and should be avoided in favor of -standard constructs wherever possible. - -@item @emph{Standard}: -GNU extension, enabled with @option{-fdec-math}. - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = ATAND(X)} -@item @code{RESULT = ATAND(Y, X)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}; -if @var{Y} is present, @var{X} shall be REAL. -@item @var{Y} @tab The type and kind type parameter shall be the same as @var{X}. -@end multitable - -@item @emph{Return value}: -The return value is of the same type and kind as @var{X}. -If @var{Y} is present, the result is identical to @code{ATAND2(Y,X)}. -Otherwise, it is the arcus tangent of @var{X}, where the real part of -the result is in degrees and lies in the range -@math{-90 \leq \Re \atand(x) \leq 90}. - -@item @emph{Example}: -@smallexample -program test_atand - real(8) :: x = 2.866_8 - x = atand(x) -end program test_atand -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .23 .23 .20 .30 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{ATAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension -@item @code{DATAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -Inverse function: @gol -@ref{TAND} @gol -Radians function: @gol -@ref{ATAN} -@end table - - - -@node ATAN2 -@section @code{ATAN2} --- Arctangent function -@fnindex ATAN2 -@fnindex DATAN2 -@cindex trigonometric function, tangent, inverse -@cindex tangent, inverse - -@table @asis -@item @emph{Description}: -@code{ATAN2(Y, X)} computes the principal value of the argument -function of the complex number @math{X + i Y}. This function can -be used to transform from Cartesian into polar coordinates and -allows to determine the angle in the correct quadrant. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ATAN2(Y, X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{Y} @tab The type shall be @code{REAL}. -@item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}. -If @var{Y} is zero, then @var{X} must be nonzero. -@end multitable - -@item @emph{Return value}: -The return value has the same type and kind type parameter as @var{Y}. It -is the principal value of the complex number @math{X + i Y}. If @var{X} -is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}. -The sign is positive if @var{Y} is positive. If @var{Y} is zero, then -the return value is zero if @var{X} is strictly positive, @math{\pi} if -@var{X} is negative and @var{Y} is positive zero (or the processor does -not handle signed zeros), and @math{-\pi} if @var{X} is negative and -@var{Y} is negative zero. Finally, if @var{X} is zero, then the -magnitude of the result is @math{\pi/2}. - -@item @emph{Example}: -@smallexample -program test_atan2 - real(4) :: x = 1.e0_4, y = 0.5e0_4 - x = atan2(y,x) -end program test_atan2 -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .22 .22 .20 .32 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{ATAN2(X, Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DATAN2(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later -@end multitable - -@item @emph{See also}: -Alias: @gol -@ref{ATAN} @gol -Degrees function: @gol -@ref{ATAN2D} -@end table - - - -@node ATAN2D -@section @code{ATAN2D} --- Arctangent function, degrees -@fnindex ATAN2D -@fnindex DATAN2D -@cindex trigonometric function, tangent, inverse, degrees -@cindex tangent, inverse, degrees - -@table @asis -@item @emph{Description}: -@code{ATAN2D(Y, X)} computes the principal value of the argument -function of the complex number @math{X + i Y} in degrees. This function can -be used to transform from Cartesian into polar coordinates and -allows to determine the angle in the correct quadrant. - -This function is for compatibility only and should be avoided in favor of -standard constructs wherever possible. - -@item @emph{Standard}: -GNU extension, enabled with @option{-fdec-math}. - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ATAN2D(Y, X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{Y} @tab The type shall be @code{REAL}. -@item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}. -If @var{Y} is zero, then @var{X} must be nonzero. -@end multitable - -@item @emph{Return value}: -The return value has the same type and kind type parameter as @var{Y}. It -is the principal value of the complex number @math{X + i Y}. If @var{X} -is nonzero, then it lies in the range @math{-180 \le \atan (x) \leq 180}. -The sign is positive if @var{Y} is positive. If @var{Y} is zero, then -the return value is zero if @var{X} is strictly positive, @math{180} if -@var{X} is negative and @var{Y} is positive zero (or the processor does -not handle signed zeros), and @math{-180} if @var{X} is negative and -@var{Y} is negative zero. Finally, if @var{X} is zero, then the -magnitude of the result is @math{90}. - -@item @emph{Example}: -@smallexample -program test_atan2d - real(4) :: x = 1.e0_4, y = 0.5e0_4 - x = atan2d(y,x) -end program test_atan2d -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .23 .23 .20 .30 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{ATAN2D(X, Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab GNU extension -@item @code{DATAN2D(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -Alias: @gol -@ref{ATAND} @gol -Radians function: @gol -@ref{ATAN2} -@end table - - - -@node ATANH -@section @code{ATANH} --- Inverse hyperbolic tangent function -@fnindex ATANH -@fnindex DATANH -@cindex area hyperbolic tangent -@cindex inverse hyperbolic tangent -@cindex hyperbolic function, tangent, inverse -@cindex tangent, hyperbolic, inverse - -@table @asis -@item @emph{Description}: -@code{ATANH(X)} computes the inverse hyperbolic tangent of @var{X}. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ATANH(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value has same type and kind as @var{X}. If @var{X} is -complex, the imaginary part of the result is in radians and lies between -@math{-\pi/2 \leq \Im \atanh(x) \leq \pi/2}. - -@item @emph{Example}: -@smallexample -PROGRAM test_atanh - REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /) - WRITE (*,*) ATANH(x) -END PROGRAM -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{DATANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -Inverse function: @gol -@ref{TANH} -@end table - - - -@node ATOMIC_ADD -@section @code{ATOMIC_ADD} --- Atomic ADD operation -@fnindex ATOMIC_ADD -@cindex Atomic subroutine, add - -@table @asis -@item @emph{Description}: -@code{ATOMIC_ADD(ATOM, VALUE)} atomically adds the value of @var{VALUE} to the -variable @var{ATOM}. When @var{STAT} is present and the invocation was -successful, it is assigned the value 0. If it is present and the invocation -has failed, it is assigned a positive value; in particular, for a coindexed -@var{ATOM}, if the remote image has stopped, it is assigned the value of -@code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has -failed, the value @code{STAT_FAILED_IMAGE}. - -@item @emph{Standard}: -TS 18508 or later - -@item @emph{Class}: -Atomic subroutine - -@item @emph{Syntax}: -@code{CALL ATOMIC_ADD (ATOM, VALUE [, STAT])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ATOM} @tab Scalar coarray or coindexed variable of integer -type with @code{ATOMIC_INT_KIND} kind. -@item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind -is different, the value is converted to the kind of @var{ATOM}. -@item @var{STAT} @tab (optional) Scalar default-kind integer variable. -@end multitable - -@item @emph{Example}: -@smallexample -program atomic - use iso_fortran_env - integer(atomic_int_kind) :: atom[*] - call atomic_add (atom[1], this_image()) -end program atomic -@end smallexample - -@item @emph{See also}: -@ref{ATOMIC_DEFINE}, @gol -@ref{ATOMIC_FETCH_ADD}, @gol -@ref{ISO_FORTRAN_ENV}, @gol -@ref{ATOMIC_AND}, @gol -@ref{ATOMIC_OR}, @gol -@ref{ATOMIC_XOR} -@end table - - - - -@node ATOMIC_AND -@section @code{ATOMIC_AND} --- Atomic bitwise AND operation -@fnindex ATOMIC_AND -@cindex Atomic subroutine, AND - -@table @asis -@item @emph{Description}: -@code{ATOMIC_AND(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise -AND between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present -and the invocation was successful, it is assigned the value 0. If it is present -and the invocation has failed, it is assigned a positive value; in particular, -for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the -value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote -image has failed, the value @code{STAT_FAILED_IMAGE}. - -@item @emph{Standard}: -TS 18508 or later - -@item @emph{Class}: -Atomic subroutine - -@item @emph{Syntax}: -@code{CALL ATOMIC_AND (ATOM, VALUE [, STAT])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ATOM} @tab Scalar coarray or coindexed variable of integer -type with @code{ATOMIC_INT_KIND} kind. -@item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind -is different, the value is converted to the kind of @var{ATOM}. -@item @var{STAT} @tab (optional) Scalar default-kind integer variable. -@end multitable - -@item @emph{Example}: -@smallexample -program atomic - use iso_fortran_env - integer(atomic_int_kind) :: atom[*] - call atomic_and (atom[1], int(b'10100011101')) -end program atomic -@end smallexample - -@item @emph{See also}: -@ref{ATOMIC_DEFINE}, @gol -@ref{ATOMIC_FETCH_AND}, @gol -@ref{ISO_FORTRAN_ENV}, @gol -@ref{ATOMIC_ADD}, @gol -@ref{ATOMIC_OR}, @gol -@ref{ATOMIC_XOR} -@end table - - - -@node ATOMIC_CAS -@section @code{ATOMIC_CAS} --- Atomic compare and swap -@fnindex ATOMIC_DEFINE -@cindex Atomic subroutine, compare and swap - -@table @asis -@item @emph{Description}: -@code{ATOMIC_CAS} compares the variable @var{ATOM} with the value of -@var{COMPARE}; if the value is the same, @var{ATOM} is set to the value -of @var{NEW}. Additionally, @var{OLD} is set to the value of @var{ATOM} -that was used for the comparison. When @var{STAT} is present and the invocation -was successful, it is assigned the value 0. If it is present and the invocation -has failed, it is assigned a positive value; in particular, for a coindexed -@var{ATOM}, if the remote image has stopped, it is assigned the value of -@code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has -failed, the value @code{STAT_FAILED_IMAGE}. - -@item @emph{Standard}: -TS 18508 or later - -@item @emph{Class}: -Atomic subroutine - -@item @emph{Syntax}: -@code{CALL ATOMIC_CAS (ATOM, OLD, COMPARE, NEW [, STAT])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer -type with @code{ATOMIC_INT_KIND} kind or logical type with -@code{ATOMIC_LOGICAL_KIND} kind. -@item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}. -@item @var{COMPARE} @tab Scalar variable of the same type and kind as -@var{ATOM}. -@item @var{NEW} @tab Scalar variable of the same type as @var{ATOM}. If kind -is different, the value is converted to the kind of @var{ATOM}. -@item @var{STAT} @tab (optional) Scalar default-kind integer variable. -@end multitable - -@item @emph{Example}: -@smallexample -program atomic - use iso_fortran_env - logical(atomic_logical_kind) :: atom[*], prev - call atomic_cas (atom[1], prev, .false., .true.)) -end program atomic -@end smallexample - -@item @emph{See also}: -@ref{ATOMIC_DEFINE}, @gol -@ref{ATOMIC_REF}, @gol -@ref{ISO_FORTRAN_ENV} -@end table - - - -@node ATOMIC_DEFINE -@section @code{ATOMIC_DEFINE} --- Setting a variable atomically -@fnindex ATOMIC_DEFINE -@cindex Atomic subroutine, define - -@table @asis -@item @emph{Description}: -@code{ATOMIC_DEFINE(ATOM, VALUE)} defines the variable @var{ATOM} with the value -@var{VALUE} atomically. When @var{STAT} is present and the invocation was -successful, it is assigned the value 0. If it is present and the invocation -has failed, it is assigned a positive value; in particular, for a coindexed -@var{ATOM}, if the remote image has stopped, it is assigned the value of -@code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has -failed, the value @code{STAT_FAILED_IMAGE}. - -@item @emph{Standard}: -Fortran 2008 and later; with @var{STAT}, TS 18508 or later - -@item @emph{Class}: -Atomic subroutine - -@item @emph{Syntax}: -@code{CALL ATOMIC_DEFINE (ATOM, VALUE [, STAT])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer -type with @code{ATOMIC_INT_KIND} kind or logical type with -@code{ATOMIC_LOGICAL_KIND} kind. - -@item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind -is different, the value is converted to the kind of @var{ATOM}. -@item @var{STAT} @tab (optional) Scalar default-kind integer variable. -@end multitable - -@item @emph{Example}: -@smallexample -program atomic - use iso_fortran_env - integer(atomic_int_kind) :: atom[*] - call atomic_define (atom[1], this_image()) -end program atomic -@end smallexample - -@item @emph{See also}: -@ref{ATOMIC_REF}, @gol -@ref{ATOMIC_CAS}, @gol -@ref{ISO_FORTRAN_ENV}, @gol -@ref{ATOMIC_ADD}, @gol -@ref{ATOMIC_AND}, @gol -@ref{ATOMIC_OR}, @gol -@ref{ATOMIC_XOR} -@end table - - - -@node ATOMIC_FETCH_ADD -@section @code{ATOMIC_FETCH_ADD} --- Atomic ADD operation with prior fetch -@fnindex ATOMIC_FETCH_ADD -@cindex Atomic subroutine, ADD with fetch - -@table @asis -@item @emph{Description}: -@code{ATOMIC_FETCH_ADD(ATOM, VALUE, OLD)} atomically stores the value of -@var{ATOM} in @var{OLD} and adds the value of @var{VALUE} to the -variable @var{ATOM}. When @var{STAT} is present and the invocation was -successful, it is assigned the value 0. If it is present and the invocation -has failed, it is assigned a positive value; in particular, for a coindexed -@var{ATOM}, if the remote image has stopped, it is assigned the value of -@code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has -failed, the value @code{STAT_FAILED_IMAGE}. - -@item @emph{Standard}: -TS 18508 or later - -@item @emph{Class}: -Atomic subroutine - -@item @emph{Syntax}: -@code{CALL ATOMIC_FETCH_ADD (ATOM, VALUE, old [, STAT])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ATOM} @tab Scalar coarray or coindexed variable of integer -type with @code{ATOMIC_INT_KIND} kind. -@code{ATOMIC_LOGICAL_KIND} kind. - -@item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind -is different, the value is converted to the kind of @var{ATOM}. -@item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}. -@item @var{STAT} @tab (optional) Scalar default-kind integer variable. -@end multitable - -@item @emph{Example}: -@smallexample -program atomic - use iso_fortran_env - integer(atomic_int_kind) :: atom[*], old - call atomic_add (atom[1], this_image(), old) -end program atomic -@end smallexample - -@item @emph{See also}: -@ref{ATOMIC_DEFINE}, @gol -@ref{ATOMIC_ADD}, @gol -@ref{ISO_FORTRAN_ENV}, @gol -@ref{ATOMIC_FETCH_AND}, @gol -@ref{ATOMIC_FETCH_OR}, @gol -@ref{ATOMIC_FETCH_XOR} -@end table - - - -@node ATOMIC_FETCH_AND -@section @code{ATOMIC_FETCH_AND} --- Atomic bitwise AND operation with prior fetch -@fnindex ATOMIC_FETCH_AND -@cindex Atomic subroutine, AND with fetch - -@table @asis -@item @emph{Description}: -@code{ATOMIC_AND(ATOM, VALUE)} atomically stores the value of @var{ATOM} in -@var{OLD} and defines @var{ATOM} with the bitwise AND between the values of -@var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was -successful, it is assigned the value 0. If it is present and the invocation has -failed, it is assigned a positive value; in particular, for a coindexed -@var{ATOM}, if the remote image has stopped, it is assigned the value of -@code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has -failed, the value @code{STAT_FAILED_IMAGE}. - -@item @emph{Standard}: -TS 18508 or later - -@item @emph{Class}: -Atomic subroutine - -@item @emph{Syntax}: -@code{CALL ATOMIC_FETCH_AND (ATOM, VALUE, OLD [, STAT])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ATOM} @tab Scalar coarray or coindexed variable of integer -type with @code{ATOMIC_INT_KIND} kind. -@item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind -is different, the value is converted to the kind of @var{ATOM}. -@item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}. -@item @var{STAT} @tab (optional) Scalar default-kind integer variable. -@end multitable - -@item @emph{Example}: -@smallexample -program atomic - use iso_fortran_env - integer(atomic_int_kind) :: atom[*], old - call atomic_fetch_and (atom[1], int(b'10100011101'), old) -end program atomic -@end smallexample - -@item @emph{See also}: -@ref{ATOMIC_DEFINE}, @gol -@ref{ATOMIC_AND}, @gol -@ref{ISO_FORTRAN_ENV}, @gol -@ref{ATOMIC_FETCH_ADD}, @gol -@ref{ATOMIC_FETCH_OR}, @gol -@ref{ATOMIC_FETCH_XOR} -@end table - - - -@node ATOMIC_FETCH_OR -@section @code{ATOMIC_FETCH_OR} --- Atomic bitwise OR operation with prior fetch -@fnindex ATOMIC_FETCH_OR -@cindex Atomic subroutine, OR with fetch - -@table @asis -@item @emph{Description}: -@code{ATOMIC_OR(ATOM, VALUE)} atomically stores the value of @var{ATOM} in -@var{OLD} and defines @var{ATOM} with the bitwise OR between the values of -@var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was -successful, it is assigned the value 0. If it is present and the invocation has -failed, it is assigned a positive value; in particular, for a coindexed -@var{ATOM}, if the remote image has stopped, it is assigned the value of -@code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has -failed, the value @code{STAT_FAILED_IMAGE}. - -@item @emph{Standard}: -TS 18508 or later - -@item @emph{Class}: -Atomic subroutine - -@item @emph{Syntax}: -@code{CALL ATOMIC_FETCH_OR (ATOM, VALUE, OLD [, STAT])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ATOM} @tab Scalar coarray or coindexed variable of integer -type with @code{ATOMIC_INT_KIND} kind. -@item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind -is different, the value is converted to the kind of @var{ATOM}. -@item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}. -@item @var{STAT} @tab (optional) Scalar default-kind integer variable. -@end multitable - -@item @emph{Example}: -@smallexample -program atomic - use iso_fortran_env - integer(atomic_int_kind) :: atom[*], old - call atomic_fetch_or (atom[1], int(b'10100011101'), old) -end program atomic -@end smallexample - -@item @emph{See also}: -@ref{ATOMIC_DEFINE}, @gol -@ref{ATOMIC_OR}, @gol -@ref{ISO_FORTRAN_ENV}, @gol -@ref{ATOMIC_FETCH_ADD}, @gol -@ref{ATOMIC_FETCH_AND}, @gol -@ref{ATOMIC_FETCH_XOR} -@end table - - - -@node ATOMIC_FETCH_XOR -@section @code{ATOMIC_FETCH_XOR} --- Atomic bitwise XOR operation with prior fetch -@fnindex ATOMIC_FETCH_XOR -@cindex Atomic subroutine, XOR with fetch - -@table @asis -@item @emph{Description}: -@code{ATOMIC_XOR(ATOM, VALUE)} atomically stores the value of @var{ATOM} in -@var{OLD} and defines @var{ATOM} with the bitwise XOR between the values of -@var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was -successful, it is assigned the value 0. If it is present and the invocation has -failed, it is assigned a positive value; in particular, for a coindexed -@var{ATOM}, if the remote image has stopped, it is assigned the value of -@code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has -failed, the value @code{STAT_FAILED_IMAGE}. - -@item @emph{Standard}: -TS 18508 or later - -@item @emph{Class}: -Atomic subroutine - -@item @emph{Syntax}: -@code{CALL ATOMIC_FETCH_XOR (ATOM, VALUE, OLD [, STAT])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ATOM} @tab Scalar coarray or coindexed variable of integer -type with @code{ATOMIC_INT_KIND} kind. -@item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind -is different, the value is converted to the kind of @var{ATOM}. -@item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}. -@item @var{STAT} @tab (optional) Scalar default-kind integer variable. -@end multitable - -@item @emph{Example}: -@smallexample -program atomic - use iso_fortran_env - integer(atomic_int_kind) :: atom[*], old - call atomic_fetch_xor (atom[1], int(b'10100011101'), old) -end program atomic -@end smallexample - -@item @emph{See also}: -@ref{ATOMIC_DEFINE}, @gol -@ref{ATOMIC_XOR}, @gol -@ref{ISO_FORTRAN_ENV}, @gol -@ref{ATOMIC_FETCH_ADD}, @gol -@ref{ATOMIC_FETCH_AND}, @gol -@ref{ATOMIC_FETCH_OR} -@end table - - - -@node ATOMIC_OR -@section @code{ATOMIC_OR} --- Atomic bitwise OR operation -@fnindex ATOMIC_OR -@cindex Atomic subroutine, OR - -@table @asis -@item @emph{Description}: -@code{ATOMIC_OR(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise -AND between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present -and the invocation was successful, it is assigned the value 0. If it is present -and the invocation has failed, it is assigned a positive value; in particular, -for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the -value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote -image has failed, the value @code{STAT_FAILED_IMAGE}. - -@item @emph{Standard}: -TS 18508 or later - -@item @emph{Class}: -Atomic subroutine - -@item @emph{Syntax}: -@code{CALL ATOMIC_OR (ATOM, VALUE [, STAT])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ATOM} @tab Scalar coarray or coindexed variable of integer -type with @code{ATOMIC_INT_KIND} kind. -@item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind -is different, the value is converted to the kind of @var{ATOM}. -@item @var{STAT} @tab (optional) Scalar default-kind integer variable. -@end multitable - -@item @emph{Example}: -@smallexample -program atomic - use iso_fortran_env - integer(atomic_int_kind) :: atom[*] - call atomic_or (atom[1], int(b'10100011101')) -end program atomic -@end smallexample - -@item @emph{See also}: -@ref{ATOMIC_DEFINE}, @gol -@ref{ATOMIC_FETCH_OR}, @gol -@ref{ISO_FORTRAN_ENV}, @gol -@ref{ATOMIC_ADD}, @gol -@ref{ATOMIC_OR}, @gol -@ref{ATOMIC_XOR} -@end table - - - -@node ATOMIC_REF -@section @code{ATOMIC_REF} --- Obtaining the value of a variable atomically -@fnindex ATOMIC_REF -@cindex Atomic subroutine, reference - -@table @asis -@item @emph{Description}: -@code{ATOMIC_DEFINE(ATOM, VALUE)} atomically assigns the value of the -variable @var{ATOM} to @var{VALUE}. When @var{STAT} is present and the -invocation was successful, it is assigned the value 0. If it is present and the -invocation has failed, it is assigned a positive value; in particular, for a -coindexed @var{ATOM}, if the remote image has stopped, it is assigned the value -of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image -has failed, the value @code{STAT_FAILED_IMAGE}. - - -@item @emph{Standard}: -Fortran 2008 and later; with @var{STAT}, TS 18508 or later - -@item @emph{Class}: -Atomic subroutine - -@item @emph{Syntax}: -@code{CALL ATOMIC_REF(VALUE, ATOM [, STAT])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind -is different, the value is converted to the kind of @var{ATOM}. -@item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer -type with @code{ATOMIC_INT_KIND} kind or logical type with -@code{ATOMIC_LOGICAL_KIND} kind. -@item @var{STAT} @tab (optional) Scalar default-kind integer variable. -@end multitable - -@item @emph{Example}: -@smallexample -program atomic - use iso_fortran_env - logical(atomic_logical_kind) :: atom[*] - logical :: val - call atomic_ref (atom, .false.) - ! ... - call atomic_ref (atom, val) - if (val) then - print *, "Obtained" - end if -end program atomic -@end smallexample - -@item @emph{See also}: -@ref{ATOMIC_DEFINE}, @gol -@ref{ATOMIC_CAS}, @gol -@ref{ISO_FORTRAN_ENV}, @gol -@ref{ATOMIC_FETCH_ADD}, @gol -@ref{ATOMIC_FETCH_AND}, @gol -@ref{ATOMIC_FETCH_OR}, @gol -@ref{ATOMIC_FETCH_XOR} -@end table - - -@node ATOMIC_XOR -@section @code{ATOMIC_XOR} --- Atomic bitwise OR operation -@fnindex ATOMIC_XOR -@cindex Atomic subroutine, XOR - -@table @asis -@item @emph{Description}: -@code{ATOMIC_AND(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise -XOR between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present -and the invocation was successful, it is assigned the value 0. If it is present -and the invocation has failed, it is assigned a positive value; in particular, -for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the -value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote -image has failed, the value @code{STAT_FAILED_IMAGE}. - -@item @emph{Standard}: -TS 18508 or later - -@item @emph{Class}: -Atomic subroutine - -@item @emph{Syntax}: -@code{CALL ATOMIC_XOR (ATOM, VALUE [, STAT])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ATOM} @tab Scalar coarray or coindexed variable of integer -type with @code{ATOMIC_INT_KIND} kind. -@item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind -is different, the value is converted to the kind of @var{ATOM}. -@item @var{STAT} @tab (optional) Scalar default-kind integer variable. -@end multitable - -@item @emph{Example}: -@smallexample -program atomic - use iso_fortran_env - integer(atomic_int_kind) :: atom[*] - call atomic_xor (atom[1], int(b'10100011101')) -end program atomic -@end smallexample - -@item @emph{See also}: -@ref{ATOMIC_DEFINE}, @gol -@ref{ATOMIC_FETCH_XOR}, @gol -@ref{ISO_FORTRAN_ENV}, @gol -@ref{ATOMIC_ADD}, @gol -@ref{ATOMIC_OR}, @gol -@ref{ATOMIC_XOR} -@end table - - -@node BACKTRACE -@section @code{BACKTRACE} --- Show a backtrace -@fnindex BACKTRACE -@cindex backtrace - -@table @asis -@item @emph{Description}: -@code{BACKTRACE} shows a backtrace at an arbitrary place in user code. Program -execution continues normally afterwards. The backtrace information is printed -to the unit corresponding to @code{ERROR_UNIT} in @code{ISO_FORTRAN_ENV}. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL BACKTRACE} - -@item @emph{Arguments}: -None - -@item @emph{See also}: -@ref{ABORT} -@end table - - - -@node BESSEL_J0 -@section @code{BESSEL_J0} --- Bessel function of the first kind of order 0 -@fnindex BESSEL_J0 -@fnindex BESJ0 -@fnindex DBESJ0 -@cindex Bessel function, first kind - -@table @asis -@item @emph{Description}: -@code{BESSEL_J0(X)} computes the Bessel function of the first kind of -order 0 of @var{X}. This function is available under the name -@code{BESJ0} as a GNU extension. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = BESSEL_J0(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{REAL} and lies in the -range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}. It has the same -kind as @var{X}. - -@item @emph{Example}: -@smallexample -program test_besj0 - real(8) :: x = 0.0_8 - x = bessel_j0(x) -end program test_besj0 -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .21 .22 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@end multitable -@end table - - - -@node BESSEL_J1 -@section @code{BESSEL_J1} --- Bessel function of the first kind of order 1 -@fnindex BESSEL_J1 -@fnindex BESJ1 -@fnindex DBESJ1 -@cindex Bessel function, first kind - -@table @asis -@item @emph{Description}: -@code{BESSEL_J1(X)} computes the Bessel function of the first kind of -order 1 of @var{X}. This function is available under the name -@code{BESJ1} as a GNU extension. - -@item @emph{Standard}: -Fortran 2008 - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = BESSEL_J1(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{REAL} and lies in the -range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }. It has the same -kind as @var{X}. - -@item @emph{Example}: -@smallexample -program test_besj1 - real(8) :: x = 1.0_8 - x = bessel_j1(x) -end program test_besj1 -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{DBESJ1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@end multitable -@end table - - - -@node BESSEL_JN -@section @code{BESSEL_JN} --- Bessel function of the first kind -@fnindex BESSEL_JN -@fnindex BESJN -@fnindex DBESJN -@cindex Bessel function, first kind - -@table @asis -@item @emph{Description}: -@code{BESSEL_JN(N, X)} computes the Bessel function of the first kind of -order @var{N} of @var{X}. This function is available under the name -@code{BESJN} as a GNU extension. If @var{N} and @var{X} are arrays, -their ranks and shapes shall conform. - -@code{BESSEL_JN(N1, N2, X)} returns an array with the Bessel functions -of the first kind of the orders @var{N1} to @var{N2}. - -@item @emph{Standard}: -Fortran 2008 and later, negative @var{N} is allowed as GNU extension - -@item @emph{Class}: -Elemental function, except for the transformational function -@code{BESSEL_JN(N1, N2, X)} - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = BESSEL_JN(N, X)} -@item @code{RESULT = BESSEL_JN(N1, N2, X)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER}. -@item @var{N1} @tab Shall be a non-negative scalar of type @code{INTEGER}. -@item @var{N2} @tab Shall be a non-negative scalar of type @code{INTEGER}. -@item @var{X} @tab Shall be a scalar or an array of type @code{REAL}; -for @code{BESSEL_JN(N1, N2, X)} it shall be scalar. -@end multitable - -@item @emph{Return value}: -The return value is a scalar of type @code{REAL}. It has the same -kind as @var{X}. - -@item @emph{Note}: -The transformational function uses a recurrence algorithm which might, -for some values of @var{X}, lead to different results than calls to -the elemental function. - -@item @emph{Example}: -@smallexample -program test_besjn - real(8) :: x = 1.0_8 - x = bessel_jn(5,x) -end program test_besjn -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .22 .22 .20 .32 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{DBESJN(N, X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension -@item @tab @code{REAL(8) X} @tab @tab -@end multitable -@end table - - - -@node BESSEL_Y0 -@section @code{BESSEL_Y0} --- Bessel function of the second kind of order 0 -@fnindex BESSEL_Y0 -@fnindex BESY0 -@fnindex DBESY0 -@cindex Bessel function, second kind - -@table @asis -@item @emph{Description}: -@code{BESSEL_Y0(X)} computes the Bessel function of the second kind of -order 0 of @var{X}. This function is available under the name -@code{BESY0} as a GNU extension. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = BESSEL_Y0(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{REAL}. It has the same kind as @var{X}. - -@item @emph{Example}: -@smallexample -program test_besy0 - real(8) :: x = 0.0_8 - x = bessel_y0(x) -end program test_besy0 -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@end multitable -@end table - - - -@node BESSEL_Y1 -@section @code{BESSEL_Y1} --- Bessel function of the second kind of order 1 -@fnindex BESSEL_Y1 -@fnindex BESY1 -@fnindex DBESY1 -@cindex Bessel function, second kind - -@table @asis -@item @emph{Description}: -@code{BESSEL_Y1(X)} computes the Bessel function of the second kind of -order 1 of @var{X}. This function is available under the name -@code{BESY1} as a GNU extension. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = BESSEL_Y1(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{REAL}. It has the same kind as @var{X}. - -@item @emph{Example}: -@smallexample -program test_besy1 - real(8) :: x = 1.0_8 - x = bessel_y1(x) -end program test_besy1 -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@end multitable -@end table - - - -@node BESSEL_YN -@section @code{BESSEL_YN} --- Bessel function of the second kind -@fnindex BESSEL_YN -@fnindex BESYN -@fnindex DBESYN -@cindex Bessel function, second kind - -@table @asis -@item @emph{Description}: -@code{BESSEL_YN(N, X)} computes the Bessel function of the second kind of -order @var{N} of @var{X}. This function is available under the name -@code{BESYN} as a GNU extension. If @var{N} and @var{X} are arrays, -their ranks and shapes shall conform. - -@code{BESSEL_YN(N1, N2, X)} returns an array with the Bessel functions -of the first kind of the orders @var{N1} to @var{N2}. - -@item @emph{Standard}: -Fortran 2008 and later, negative @var{N} is allowed as GNU extension - -@item @emph{Class}: -Elemental function, except for the transformational function -@code{BESSEL_YN(N1, N2, X)} - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = BESSEL_YN(N, X)} -@item @code{RESULT = BESSEL_YN(N1, N2, X)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER} . -@item @var{N1} @tab Shall be a non-negative scalar of type @code{INTEGER}. -@item @var{N2} @tab Shall be a non-negative scalar of type @code{INTEGER}. -@item @var{X} @tab Shall be a scalar or an array of type @code{REAL}; -for @code{BESSEL_YN(N1, N2, X)} it shall be scalar. -@end multitable - -@item @emph{Return value}: -The return value is a scalar of type @code{REAL}. It has the same -kind as @var{X}. - -@item @emph{Note}: -The transformational function uses a recurrence algorithm which might, -for some values of @var{X}, lead to different results than calls to -the elemental function. - -@item @emph{Example}: -@smallexample -program test_besyn - real(8) :: x = 1.0_8 - x = bessel_yn(5,x) -end program test_besyn -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{DBESYN(N,X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension -@item @tab @code{REAL(8) X} @tab @tab -@end multitable -@end table - - - -@node BGE -@section @code{BGE} --- Bitwise greater than or equal to -@fnindex BGE -@cindex bitwise comparison - -@table @asis -@item @emph{Description}: -Determines whether an integral is a bitwise greater than or equal to -another. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = BGE(I, J)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab Shall be of @code{INTEGER} type. -@item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind -as @var{I}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{LOGICAL} and of the default kind. - -@item @emph{See also}: -@ref{BGT}, @gol -@ref{BLE}, @gol -@ref{BLT} -@end table - - - -@node BGT -@section @code{BGT} --- Bitwise greater than -@fnindex BGT -@cindex bitwise comparison - -@table @asis -@item @emph{Description}: -Determines whether an integral is a bitwise greater than another. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = BGT(I, J)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab Shall be of @code{INTEGER} type. -@item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind -as @var{I}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{LOGICAL} and of the default kind. - -@item @emph{See also}: -@ref{BGE}, @gol -@ref{BLE}, @gol -@ref{BLT} -@end table - - - -@node BIT_SIZE -@section @code{BIT_SIZE} --- Bit size inquiry function -@fnindex BIT_SIZE -@cindex bits, number of -@cindex size of a variable, in bits - -@table @asis -@item @emph{Description}: -@code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit) -represented by the type of @var{I}. The result of @code{BIT_SIZE(I)} is -independent of the actual value of @var{I}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = BIT_SIZE(I)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} - -@item @emph{Example}: -@smallexample -program test_bit_size - integer :: i = 123 - integer :: size - size = bit_size(i) - print *, size -end program test_bit_size -@end smallexample -@end table - - - -@node BLE -@section @code{BLE} --- Bitwise less than or equal to -@fnindex BLE -@cindex bitwise comparison - -@table @asis -@item @emph{Description}: -Determines whether an integral is a bitwise less than or equal to -another. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = BLE(I, J)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab Shall be of @code{INTEGER} type. -@item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind -as @var{I}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{LOGICAL} and of the default kind. - -@item @emph{See also}: -@ref{BGT}, @gol -@ref{BGE}, @gol -@ref{BLT} -@end table - - - -@node BLT -@section @code{BLT} --- Bitwise less than -@fnindex BLT -@cindex bitwise comparison - -@table @asis -@item @emph{Description}: -Determines whether an integral is a bitwise less than another. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = BLT(I, J)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab Shall be of @code{INTEGER} type. -@item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind -as @var{I}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{LOGICAL} and of the default kind. - -@item @emph{See also}: -@ref{BGE}, @gol -@ref{BGT}, @gol -@ref{BLE} -@end table - - - -@node BTEST -@section @code{BTEST} --- Bit test function -@fnindex BTEST -@fnindex BBTEST -@fnindex BITEST -@fnindex BJTEST -@fnindex BKTEST -@cindex bits, testing - -@table @asis -@item @emph{Description}: -@code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS} -in @var{I} is set. The counting of the bits starts at 0. - -@item @emph{Standard}: -Fortran 90 and later, has overloads that are GNU extensions - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = BTEST(I, POS)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER}. -@item @var{POS} @tab The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{LOGICAL} - -@item @emph{Example}: -@smallexample -program test_btest - integer :: i = 32768 + 1024 + 64 - integer :: pos - logical :: bool - do pos=0,16 - bool = btest(i, pos) - print *, pos, bool - end do -end program test_btest -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .21 .28 .18 .30 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{BTEST(I,POS)} @tab @code{INTEGER I,POS} @tab @code{LOGICAL} @tab Fortran 95 and later -@item @code{BBTEST(I,POS)} @tab @code{INTEGER(1) I,POS} @tab @code{LOGICAL(1)} @tab GNU extension -@item @code{BITEST(I,POS)} @tab @code{INTEGER(2) I,POS} @tab @code{LOGICAL(2)} @tab GNU extension -@item @code{BJTEST(I,POS)} @tab @code{INTEGER(4) I,POS} @tab @code{LOGICAL(4)} @tab GNU extension -@item @code{BKTEST(I,POS)} @tab @code{INTEGER(8) I,POS} @tab @code{LOGICAL(8)} @tab GNU extension -@end multitable -@end table - -@node C_ASSOCIATED -@section @code{C_ASSOCIATED} --- Status of a C pointer -@fnindex C_ASSOCIATED -@cindex association status, C pointer -@cindex pointer, C association status - -@table @asis -@item @emph{Description}: -@code{C_ASSOCIATED(c_ptr_1[, c_ptr_2])} determines the status of the C pointer -@var{c_ptr_1} or if @var{c_ptr_1} is associated with the target @var{c_ptr_2}. - -@item @emph{Standard}: -Fortran 2003 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = C_ASSOCIATED(c_ptr_1[, c_ptr_2])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{c_ptr_1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}. -@item @var{c_ptr_2} @tab (Optional) Scalar of the same type as @var{c_ptr_1}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{LOGICAL}; it is @code{.false.} if either -@var{c_ptr_1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr_2} -point to different addresses. - -@item @emph{Example}: -@smallexample -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 smallexample - -@item @emph{See also}: -@ref{C_LOC}, @gol -@ref{C_FUNLOC} -@end table - - -@node C_F_POINTER -@section @code{C_F_POINTER} --- Convert C into Fortran pointer -@fnindex C_F_POINTER -@cindex pointer, convert C to Fortran - -@table @asis -@item @emph{Description}: -@code{C_F_POINTER(CPTR, FPTR[, SHAPE])} assigns the target of the C pointer -@var{CPTR} to the Fortran pointer @var{FPTR} and specifies its shape. - -@item @emph{Standard}: -Fortran 2003 and later - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL C_F_POINTER(CPTR, FPTR[, SHAPE])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{CPTR} @tab scalar of the type @code{C_PTR}. It is -@code{INTENT(IN)}. -@item @var{FPTR} @tab pointer interoperable with @var{cptr}. It is -@code{INTENT(OUT)}. -@item @var{SHAPE} @tab (Optional) Rank-one array of type @code{INTEGER} -with @code{INTENT(IN)}. It shall be present -if and only if @var{fptr} is an array. The size -must be equal to the rank of @var{fptr}. -@end multitable - -@item @emph{Example}: -@smallexample -program main - use iso_c_binding - implicit none - interface - subroutine my_routine(p) bind(c,name='myC_func') - import :: c_ptr - type(c_ptr), intent(out) :: p - end subroutine - end interface - type(c_ptr) :: cptr - real,pointer :: a(:) - call my_routine(cptr) - call c_f_pointer(cptr, a, [12]) -end program main -@end smallexample - -@item @emph{See also}: -@ref{C_LOC}, @gol -@ref{C_F_PROCPOINTER} -@end table - - -@node C_F_PROCPOINTER -@section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer -@fnindex C_F_PROCPOINTER -@cindex pointer, C address of pointers - -@table @asis -@item @emph{Description}: -@code{C_F_PROCPOINTER(CPTR, FPTR)} Assign the target of the C function pointer -@var{CPTR} to the Fortran procedure pointer @var{FPTR}. - -@item @emph{Standard}: -Fortran 2003 and later - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL C_F_PROCPOINTER(cptr, fptr)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{CPTR} @tab scalar of the type @code{C_FUNPTR}. It is -@code{INTENT(IN)}. -@item @var{FPTR} @tab procedure pointer interoperable with @var{cptr}. It is -@code{INTENT(OUT)}. -@end multitable - -@item @emph{Example}: -@smallexample -program main - use iso_c_binding - implicit none - abstract interface - function func(a) - import :: c_float - real(c_float), intent(in) :: a - real(c_float) :: func - end function - end interface - interface - function getIterFunc() bind(c,name="getIterFunc") - import :: c_funptr - type(c_funptr) :: getIterFunc - end function - end interface - type(c_funptr) :: cfunptr - procedure(func), pointer :: myFunc - cfunptr = getIterFunc() - call c_f_procpointer(cfunptr, myFunc) -end program main -@end smallexample - -@item @emph{See also}: -@ref{C_LOC}, @gol -@ref{C_F_POINTER} -@end table - - -@node C_FUNLOC -@section @code{C_FUNLOC} --- Obtain the C address of a procedure -@fnindex C_FUNLOC -@cindex pointer, C address of procedures - -@table @asis -@item @emph{Description}: -@code{C_FUNLOC(x)} determines the C address of the argument. - -@item @emph{Standard}: -Fortran 2003 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = C_FUNLOC(x)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{x} @tab Interoperable function or pointer to such function. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{C_FUNPTR} and contains the C address -of the argument. - -@item @emph{Example}: -@smallexample -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 -@end smallexample - -@item @emph{See also}: -@ref{C_ASSOCIATED}, @gol -@ref{C_LOC}, @gol -@ref{C_F_POINTER}, @gol -@ref{C_F_PROCPOINTER} -@end table - - -@node C_LOC -@section @code{C_LOC} --- Obtain the C address of an object -@fnindex C_LOC -@cindex procedure pointer, convert C to Fortran - -@table @asis -@item @emph{Description}: -@code{C_LOC(X)} determines the C address of the argument. - -@item @emph{Standard}: -Fortran 2003 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = C_LOC(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .10 .75 -@item @var{X} @tab 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 parameters, or be a scalar, nonpolymorphic variable with no length type parameters. - -@end multitable - -@item @emph{Return value}: -The return value is of type @code{C_PTR} and contains the C address -of the argument. - -@item @emph{Example}: -@smallexample -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 smallexample - -@item @emph{See also}: -@ref{C_ASSOCIATED}, @gol -@ref{C_FUNLOC}, @gol -@ref{C_F_POINTER}, @gol -@ref{C_F_PROCPOINTER} -@end table - - -@node C_SIZEOF -@section @code{C_SIZEOF} --- Size in bytes of an expression -@fnindex C_SIZEOF -@cindex expression size -@cindex size of an expression - -@table @asis -@item @emph{Description}: -@code{C_SIZEOF(X)} calculates the number of bytes of storage the -expression @code{X} occupies. - -@item @emph{Standard}: -Fortran 2008 - -@item @emph{Class}: -Inquiry function of the module @code{ISO_C_BINDING} - -@item @emph{Syntax}: -@code{N = C_SIZEOF(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The argument shall be an interoperable data entity. -@end multitable - -@item @emph{Return value}: -The return value is of type integer and of the system-dependent kind -@code{C_SIZE_T} (from the @code{ISO_C_BINDING} module). Its value is the -number of bytes occupied by the argument. If the argument has the -@code{POINTER} attribute, the number of bytes of the storage area pointed -to is returned. If the argument is of a derived type with @code{POINTER} -or @code{ALLOCATABLE} components, the return value does not account for -the sizes of the data pointed to by these components. - -@item @emph{Example}: -@smallexample - use iso_c_binding - integer(c_int) :: i - real(c_float) :: r, s(5) - print *, (c_sizeof(s)/c_sizeof(r) == 5) - end -@end smallexample -The example will print @code{T} unless you are using a platform -where default @code{REAL} variables are unusually padded. - -@item @emph{See also}: -@ref{SIZEOF}, @gol -@ref{STORAGE_SIZE} -@end table - - -@node CEILING -@section @code{CEILING} --- Integer ceiling function -@fnindex CEILING -@cindex ceiling -@cindex rounding, ceiling - -@table @asis -@item @emph{Description}: -@code{CEILING(A)} returns the least integer greater than or equal to @var{A}. - -@item @emph{Standard}: -Fortran 95 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = CEILING(A [, KIND])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab The type shall be @code{REAL}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present -and a default-kind @code{INTEGER} otherwise. - -@item @emph{Example}: -@smallexample -program test_ceiling - real :: x = 63.29 - real :: y = -63.59 - print *, ceiling(x) ! returns 64 - print *, ceiling(y) ! returns -63 -end program test_ceiling -@end smallexample - -@item @emph{See also}: -@ref{FLOOR}, @gol -@ref{NINT} -@end table - - - -@node CHAR -@section @code{CHAR} --- Character conversion function -@fnindex CHAR -@cindex conversion, to character - -@table @asis -@item @emph{Description}: -@code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = CHAR(I [, KIND])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{CHARACTER(1)} - -@item @emph{Example}: -@smallexample -program test_char - integer :: i = 74 - character(1) :: c - c = char(i) - print *, i, c ! returns 'J' -end program test_char -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .19 .19 .25 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{CHAR(I)} @tab @code{INTEGER I} @tab @code{CHARACTER(LEN=1)} @tab Fortran 77 and later -@end multitable - -@item @emph{Note}: -See @ref{ICHAR} for a discussion of converting between numerical values -and formatted string representations. - -@item @emph{See also}: -@ref{ACHAR}, @gol -@ref{IACHAR}, @gol -@ref{ICHAR} - -@end table - - - -@node CHDIR -@section @code{CHDIR} --- Change working directory -@fnindex CHDIR -@cindex system, working directory - -@table @asis -@item @emph{Description}: -Change current working directory to a specified path. - -This intrinsic is provided in both subroutine and function forms; however, -only one form can be used in any given program unit. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL CHDIR(NAME [, STATUS])} -@item @code{STATUS = CHDIR(NAME)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{NAME} @tab The type shall be @code{CHARACTER} of default -kind and shall specify a valid path within the file system. -@item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default -kind. Returns 0 on success, and a system specific and nonzero error code -otherwise. -@end multitable - -@item @emph{Example}: -@smallexample -PROGRAM test_chdir - CHARACTER(len=255) :: path - CALL getcwd(path) - WRITE(*,*) TRIM(path) - CALL chdir("/tmp") - CALL getcwd(path) - WRITE(*,*) TRIM(path) -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{GETCWD} -@end table - - - -@node CHMOD -@section @code{CHMOD} --- Change access permissions of files -@fnindex CHMOD -@cindex file system, change access mode - -@table @asis -@item @emph{Description}: -@code{CHMOD} changes the permissions of a file. - -This intrinsic is provided in both subroutine and function forms; however, -only one form can be used in any given program unit. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL CHMOD(NAME, MODE[, STATUS])} -@item @code{STATUS = CHMOD(NAME, MODE)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 - -@item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the -file name. Trailing blanks are ignored unless the character -@code{achar(0)} is present, then all characters up to and excluding -@code{achar(0)} are used as the file name. - -@item @var{MODE} @tab Scalar @code{CHARACTER} of default kind giving the -file permission. @var{MODE} uses the same syntax as the @code{chmod} utility -as defined by the POSIX standard. The argument shall either be a string of -a nonnegative octal number or a symbolic mode. - -@item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is -@code{0} on success and nonzero otherwise. -@end multitable - -@item @emph{Return value}: -In either syntax, @var{STATUS} is set to @code{0} on success and nonzero -otherwise. - -@item @emph{Example}: -@code{CHMOD} as subroutine -@smallexample -program chmod_test - implicit none - integer :: status - call chmod('test.dat','u+x',status) - print *, 'Status: ', status -end program chmod_test -@end smallexample -@code{CHMOD} as function: -@smallexample -program chmod_test - implicit none - integer :: status - status = chmod('test.dat','u+x') - print *, 'Status: ', status -end program chmod_test -@end smallexample - -@end table - - - -@node CMPLX -@section @code{CMPLX} --- Complex conversion function -@fnindex CMPLX -@cindex complex numbers, conversion to -@cindex conversion, to complex - -@table @asis -@item @emph{Description}: -@code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to -the real component. If @var{Y} is present it is converted to the imaginary -component. If @var{Y} is not present then the imaginary component is set to -0.0. If @var{X} is complex then @var{Y} must not be present. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = CMPLX(X [, Y [, KIND]])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type may be @code{INTEGER}, @code{REAL}, -or @code{COMPLEX}. -@item @var{Y} @tab (Optional; only allowed if @var{X} is not -@code{COMPLEX}.) May be @code{INTEGER} or @code{REAL}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of @code{COMPLEX} type, with a kind equal to -@var{KIND} if it is specified. If @var{KIND} is not specified, the -result is of the default @code{COMPLEX} kind, regardless of the kinds of -@var{X} and @var{Y}. - -@item @emph{Example}: -@smallexample -program test_cmplx - integer :: i = 42 - real :: x = 3.14 - complex :: z - z = cmplx(i, x) - print *, z, cmplx(x) -end program test_cmplx -@end smallexample - -@item @emph{See also}: -@ref{COMPLEX} -@end table - - - -@node CO_BROADCAST -@section @code{CO_BROADCAST} --- Copy a value to all images the current set of images -@fnindex CO_BROADCAST -@cindex Collectives, value broadcasting - -@table @asis -@item @emph{Description}: -@code{CO_BROADCAST} copies the value of argument @var{A} on the image with -image index @code{SOURCE_IMAGE} to all images in the current team. @var{A} -becomes defined as if by intrinsic assignment. If the execution was -successful and @var{STAT} is present, it is assigned the value zero. If the -execution failed, @var{STAT} gets assigned a nonzero value and, if present, -@var{ERRMSG} gets assigned a value describing the occurred error. - -@item @emph{Standard}: -Technical Specification (TS) 18508 or later - -@item @emph{Class}: -Collective subroutine - -@item @emph{Syntax}: -@code{CALL CO_BROADCAST(A, SOURCE_IMAGE [, STAT, ERRMSG])} - -@item @emph{Arguments}: -@multitable @columnfractions .20 .65 -@item @var{A} @tab 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. -@item @var{SOURCE_IMAGE} @tab a scalar integer expression. -It shall have the same value on all images and refer to an -image of the current team. -@item @var{STAT} @tab (optional) a scalar integer variable -@item @var{ERRMSG} @tab (optional) a scalar character variable -@end multitable - -@item @emph{Example}: -@smallexample -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 -@end smallexample - -@item @emph{See also}: -@ref{CO_MAX}, @gol -@ref{CO_MIN}, @gol -@ref{CO_SUM}, @gol -@ref{CO_REDUCE} -@end table - - - -@node CO_MAX -@section @code{CO_MAX} --- Maximal value on the current set of images -@fnindex CO_MAX -@cindex Collectives, maximal value - -@table @asis -@item @emph{Description}: -@code{CO_MAX} determines element-wise the maximal value of @var{A} on all -images of the current team. If @var{RESULT_IMAGE} is present, the maximum -values are returned in @var{A} on the specified image only and the value -of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is -not present, the value is returned on all images. If the execution was -successful and @var{STAT} is present, it is assigned the value zero. If the -execution failed, @var{STAT} gets assigned a nonzero value and, if present, -@var{ERRMSG} gets assigned a value describing the occurred error. - -@item @emph{Standard}: -Technical Specification (TS) 18508 or later - -@item @emph{Class}: -Collective subroutine - -@item @emph{Syntax}: -@code{CALL CO_MAX(A [, RESULT_IMAGE, STAT, ERRMSG])} - -@item @emph{Arguments}: -@multitable @columnfractions .20 .65 -@item @var{A} @tab shall be an integer, real or character variable, -which has the same type and type parameters on all images of the team. -@item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if -present, it shall have the same value on all images and refer to an -image of the current team. -@item @var{STAT} @tab (optional) a scalar integer variable -@item @var{ERRMSG} @tab (optional) a scalar character variable -@end multitable - -@item @emph{Example}: -@smallexample -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 -@end smallexample - -@item @emph{See also}: -@ref{CO_MIN}, @gol -@ref{CO_SUM}, @gol -@ref{CO_REDUCE}, @gol -@ref{CO_BROADCAST} -@end table - - - -@node CO_MIN -@section @code{CO_MIN} --- Minimal value on the current set of images -@fnindex CO_MIN -@cindex Collectives, minimal value - -@table @asis -@item @emph{Description}: -@code{CO_MIN} determines element-wise the minimal value of @var{A} on all -images of the current team. If @var{RESULT_IMAGE} is present, the minimal -values are returned in @var{A} on the specified image only and the value -of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is -not present, the value is returned on all images. If the execution was -successful and @var{STAT} is present, it is assigned the value zero. If the -execution failed, @var{STAT} gets assigned a nonzero value and, if present, -@var{ERRMSG} gets assigned a value describing the occurred error. - -@item @emph{Standard}: -Technical Specification (TS) 18508 or later - -@item @emph{Class}: -Collective subroutine - -@item @emph{Syntax}: -@code{CALL CO_MIN(A [, RESULT_IMAGE, STAT, ERRMSG])} - -@item @emph{Arguments}: -@multitable @columnfractions .20 .65 -@item @var{A} @tab shall be an integer, real or character variable, -which has the same type and type parameters on all images of the team. -@item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if -present, it shall have the same value on all images and refer to an -image of the current team. -@item @var{STAT} @tab (optional) a scalar integer variable -@item @var{ERRMSG} @tab (optional) a scalar character variable -@end multitable - -@item @emph{Example}: -@smallexample -program test - integer :: val - val = this_image () - call co_min (val, result_image=1) - if (this_image() == 1) then - write(*,*) "Minimal value", val ! prints 1 - end if -end program test -@end smallexample - -@item @emph{See also}: -@ref{CO_MAX}, @gol -@ref{CO_SUM}, @gol -@ref{CO_REDUCE}, @gol -@ref{CO_BROADCAST} -@end table - - - -@node CO_REDUCE -@section @code{CO_REDUCE} --- Reduction of values on the current set of images -@fnindex CO_REDUCE -@cindex Collectives, generic reduction - -@table @asis -@item @emph{Description}: -@code{CO_REDUCE} determines element-wise the reduction of the value of @var{A} -on all images of the current team. The pure function passed as @var{OPERATION} -is used to pairwise reduce the values of @var{A} by passing either the value -of @var{A} of different images or the result values of such a reduction as -argument. If @var{A} is an array, the deduction is done element wise. If -@var{RESULT_IMAGE} is present, the result values are returned in @var{A} on -the specified image only and the value of @var{A} on the other images become -undefined. If @var{RESULT_IMAGE} is not present, the value is returned on all -images. If the execution was successful and @var{STAT} is present, it is -assigned the value zero. If the execution failed, @var{STAT} gets assigned -a nonzero value and, if present, @var{ERRMSG} gets assigned a value describing -the occurred error. - -@item @emph{Standard}: -Technical Specification (TS) 18508 or later - -@item @emph{Class}: -Collective subroutine - -@item @emph{Syntax}: -@code{CALL CO_REDUCE(A, OPERATION, [, RESULT_IMAGE, STAT, ERRMSG])} - -@item @emph{Arguments}: -@multitable @columnfractions .20 .65 -@item @var{A} @tab is an @code{INTENT(INOUT)} argument and shall be -nonpolymorphic. If it is allocatable, it shall be allocated; if it is a pointer, -it shall be associated. @var{A} shall have the same type and type parameters on -all images of the team; if it is an array, it shall have the same shape on all -images. -@item @var{OPERATION} @tab pure function with two scalar nonallocatable -arguments, which shall be nonpolymorphic and have the same type and type -parameters as @var{A}. The function shall return a nonallocatable scalar of -the same type and type parameters as @var{A}. The function shall be the same on -all images and with regards to the arguments mathematically commutative and -associative. Note that @var{OPERATION} may not be an elemental function, unless -it is an intrisic function. -@item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if -present, it shall have the same value on all images and refer to an -image of the current team. -@item @var{STAT} @tab (optional) a scalar integer variable -@item @var{ERRMSG} @tab (optional) a scalar character variable -@end multitable - -@item @emph{Example}: -@smallexample -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 -@end smallexample - -@item @emph{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. - -@item @emph{See also}: -@ref{CO_MIN}, @gol -@ref{CO_MAX}, @gol -@ref{CO_SUM}, @gol -@ref{CO_BROADCAST} -@end table - - - -@node CO_SUM -@section @code{CO_SUM} --- Sum of values on the current set of images -@fnindex CO_SUM -@cindex Collectives, sum of values - -@table @asis -@item @emph{Description}: -@code{CO_SUM} sums up the values of each element of @var{A} on all -images of the current team. If @var{RESULT_IMAGE} is present, the summed-up -values are returned in @var{A} on the specified image only and the value -of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is -not present, the value is returned on all images. If the execution was -successful and @var{STAT} is present, it is assigned the value zero. If the -execution failed, @var{STAT} gets assigned a nonzero value and, if present, -@var{ERRMSG} gets assigned a value describing the occurred error. - -@item @emph{Standard}: -Technical Specification (TS) 18508 or later - -@item @emph{Class}: -Collective subroutine - -@item @emph{Syntax}: -@code{CALL CO_SUM(A [, RESULT_IMAGE, STAT, ERRMSG])} - -@item @emph{Arguments}: -@multitable @columnfractions .20 .65 -@item @var{A} @tab shall be an integer, real or complex variable, -which has the same type and type parameters on all images of the team. -@item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if -present, it shall have the same value on all images and refer to an -image of the current team. -@item @var{STAT} @tab (optional) a scalar integer variable -@item @var{ERRMSG} @tab (optional) a scalar character variable -@end multitable - -@item @emph{Example}: -@smallexample -program test - integer :: val - val = this_image () - call co_sum (val, result_image=1) - if (this_image() == 1) then - write(*,*) "The sum is ", val ! prints (n**2 + n)/2, - ! with n = num_images() - end if -end program test -@end smallexample - -@item @emph{See also}: -@ref{CO_MAX}, @gol -@ref{CO_MIN}, @gol -@ref{CO_REDUCE}, @gol -@ref{CO_BROADCAST} -@end table - - - -@node COMMAND_ARGUMENT_COUNT -@section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments -@fnindex COMMAND_ARGUMENT_COUNT -@cindex command-line arguments -@cindex command-line arguments, number of -@cindex arguments, to program - -@table @asis -@item @emph{Description}: -@code{COMMAND_ARGUMENT_COUNT} returns the number of arguments passed on the -command line when the containing program was invoked. - -@item @emph{Standard}: -Fortran 2003 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = COMMAND_ARGUMENT_COUNT()} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item None -@end multitable - -@item @emph{Return value}: -The return value is an @code{INTEGER} of default kind. - -@item @emph{Example}: -@smallexample -program test_command_argument_count - integer :: count - count = command_argument_count() - print *, count -end program test_command_argument_count -@end smallexample - -@item @emph{See also}: -@ref{GET_COMMAND}, @gol -@ref{GET_COMMAND_ARGUMENT} -@end table - - - -@node COMPILER_OPTIONS -@section @code{COMPILER_OPTIONS} --- Options passed to the compiler -@fnindex COMPILER_OPTIONS -@cindex flags inquiry function -@cindex options inquiry function -@cindex compiler flags inquiry function - -@table @asis -@item @emph{Description}: -@code{COMPILER_OPTIONS} returns a string with the options used for -compiling. - -@item @emph{Standard}: -Fortran 2008 - -@item @emph{Class}: -Inquiry function of the module @code{ISO_FORTRAN_ENV} - -@item @emph{Syntax}: -@code{STR = COMPILER_OPTIONS()} - -@item @emph{Arguments}: -None - -@item @emph{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 @code{COMPILER_OPTIONS} intrinsic. - -@item @emph{Example}: -@smallexample - use iso_fortran_env - print '(4a)', 'This file was compiled by ', & - compiler_version(), ' using the options ', & - compiler_options() - end -@end smallexample - -@item @emph{See also}: -@ref{COMPILER_VERSION}, @gol -@ref{ISO_FORTRAN_ENV} -@end table - - - -@node COMPILER_VERSION -@section @code{COMPILER_VERSION} --- Compiler version string -@fnindex COMPILER_VERSION -@cindex compiler, name and version -@cindex version of the compiler - -@table @asis -@item @emph{Description}: -@code{COMPILER_VERSION} returns a string with the name and the -version of the compiler. - -@item @emph{Standard}: -Fortran 2008 - -@item @emph{Class}: -Inquiry function of the module @code{ISO_FORTRAN_ENV} - -@item @emph{Syntax}: -@code{STR = COMPILER_VERSION()} - -@item @emph{Arguments}: -None - -@item @emph{Return value}: -The return value is a default-kind string with system-dependent length. -It contains the name of the compiler and its version number. - -@item @emph{Example}: -@smallexample - use iso_fortran_env - print '(4a)', 'This file was compiled by ', & - compiler_version(), ' using the options ', & - compiler_options() - end -@end smallexample - -@item @emph{See also}: -@ref{COMPILER_OPTIONS}, @gol -@ref{ISO_FORTRAN_ENV} -@end table - - - -@node COMPLEX -@section @code{COMPLEX} --- Complex conversion function -@fnindex COMPLEX -@cindex complex numbers, conversion to -@cindex conversion, to complex - -@table @asis -@item @emph{Description}: -@code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted -to the real component and @var{Y} is converted to the imaginary -component. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = COMPLEX(X, Y)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}. -@item @var{Y} @tab The type may be @code{INTEGER} or @code{REAL}. -@end multitable - -@item @emph{Return value}: -If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return -value is of default @code{COMPLEX} type. - -If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL} -type and one is of @code{INTEGER} type, then the return value is of -@code{COMPLEX} type with a kind equal to that of the @code{REAL} -argument with the highest precision. - -@item @emph{Example}: -@smallexample -program test_complex - integer :: i = 42 - real :: x = 3.14 - print *, complex(i, x) -end program test_complex -@end smallexample - -@item @emph{See also}: -@ref{CMPLX} -@end table - - - -@node CONJG -@section @code{CONJG} --- Complex conjugate function -@fnindex CONJG -@fnindex DCONJG -@cindex complex conjugate - -@table @asis -@item @emph{Description}: -@code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)} -then the result is @code{(x, -y)} - -@item @emph{Standard}: -Fortran 77 and later, has an overload that is a GNU extension - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{Z = CONJG(Z)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{Z} @tab The type shall be @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{COMPLEX}. - -@item @emph{Example}: -@smallexample -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 -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension -@end multitable -@end table - - - -@node COS -@section @code{COS} --- Cosine function -@fnindex COS -@fnindex DCOS -@fnindex CCOS -@fnindex ZCOS -@fnindex CDCOS -@cindex trigonometric function, cosine -@cindex cosine - -@table @asis -@item @emph{Description}: -@code{COS(X)} computes the cosine of @var{X}. - -@item @emph{Standard}: -Fortran 77 and later, has overloads that are GNU extensions - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = COS(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or -@code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value is of the same type and kind as @var{X}. The real part -of the result is in radians. If @var{X} is of the type @code{REAL}, -the return value lies in the range @math{ -1 \leq \cos (x) \leq 1}. - -@item @emph{Example}: -@smallexample -program test_cos - real :: x = 0.0 - x = cos(x) -end program test_cos -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{COS(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later -@item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later -@item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension -@item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -Inverse function: @gol -@ref{ACOS} @gol -Degrees function: @gol -@ref{COSD} -@end table - - - -@node COSD -@section @code{COSD} --- Cosine function, degrees -@fnindex COSD -@fnindex DCOSD -@fnindex CCOSD -@fnindex ZCOSD -@fnindex CDCOSD -@cindex trigonometric function, cosine, degrees -@cindex cosine, degrees - -@table @asis -@item @emph{Description}: -@code{COSD(X)} computes the cosine of @var{X} in degrees. - -This function is for compatibility only and should be avoided in favor of -standard constructs wherever possible. - -@item @emph{Standard}: -GNU extension, enabled with @option{-fdec-math}. - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = COSD(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or -@code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value is of the same type and kind as @var{X}. The real part -of the result is in degrees. If @var{X} is of the type @code{REAL}, -the return value lies in the range @math{ -1 \leq \cosd (x) \leq 1}. - -@item @emph{Example}: -@smallexample -program test_cosd - real :: x = 0.0 - x = cosd(x) -end program test_cosd -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{COSD(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension -@item @code{DCOSD(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@item @code{CCOSD(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab GNU extension -@item @code{ZCOSD(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension -@item @code{CDCOSD(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -Inverse function: @gol -@ref{ACOSD} @gol -Radians function: @gol -@ref{COS} -@end table - - - -@node COSH -@section @code{COSH} --- Hyperbolic cosine function -@fnindex COSH -@fnindex DCOSH -@cindex hyperbolic cosine -@cindex hyperbolic function, cosine -@cindex cosine, hyperbolic - -@table @asis -@item @emph{Description}: -@code{COSH(X)} computes the hyperbolic cosine of @var{X}. - -@item @emph{Standard}: -Fortran 77 and later, for a complex argument Fortran 2008 or later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{X = COSH(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value has same type and kind as @var{X}. If @var{X} is -complex, the imaginary part of the result is in radians. If @var{X} -is @code{REAL}, the return value has a lower bound of one, -@math{\cosh (x) \geq 1}. - -@item @emph{Example}: -@smallexample -program test_cosh - real(8) :: x = 1.0_8 - x = cosh(x) -end program test_cosh -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{COSH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later -@end multitable - -@item @emph{See also}: -Inverse function: @gol -@ref{ACOSH} -@end table - - - -@node COTAN -@section @code{COTAN} --- Cotangent function -@fnindex COTAN -@fnindex DCOTAN -@cindex trigonometric function, cotangent -@cindex cotangent - -@table @asis -@item @emph{Description}: -@code{COTAN(X)} computes the cotangent of @var{X}. Equivalent to @code{COS(x)} -divided by @code{SIN(x)}, or @code{1 / TAN(x)}. - -This function is for compatibility only and should be avoided in favor of -standard constructs wherever possible. - -@item @emph{Standard}: -GNU extension, enabled with @option{-fdec-math}. - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = COTAN(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value has same type and kind as @var{X}, and its value is in radians. - -@item @emph{Example}: -@smallexample -program test_cotan - real(8) :: x = 0.165_8 - x = cotan(x) -end program test_cotan -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{COTAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension -@item @code{DCOTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -Converse function: @gol -@ref{TAN} @gol -Degrees function: @gol -@ref{COTAND} -@end table - - - -@node COTAND -@section @code{COTAND} --- Cotangent function, degrees -@fnindex COTAND -@fnindex DCOTAND -@cindex trigonometric function, cotangent, degrees -@cindex cotangent, degrees - -@table @asis -@item @emph{Description}: -@code{COTAND(X)} computes the cotangent of @var{X} in degrees. Equivalent to -@code{COSD(x)} divided by @code{SIND(x)}, or @code{1 / TAND(x)}. - -@item @emph{Standard}: -GNU extension, enabled with @option{-fdec-math}. - -This function is for compatibility only and should be avoided in favor of -standard constructs wherever possible. - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = COTAND(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value has same type and kind as @var{X}, and its value is in degrees. - -@item @emph{Example}: -@smallexample -program test_cotand - real(8) :: x = 0.165_8 - x = cotand(x) -end program test_cotand -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{COTAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension -@item @code{DCOTAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -Converse function: @gol -@ref{TAND} @gol -Radians function: @gol -@ref{COTAN} -@end table - - - -@node COUNT -@section @code{COUNT} --- Count function -@fnindex COUNT -@cindex array, conditionally count elements -@cindex array, element counting -@cindex array, number of elements - -@table @asis -@item @emph{Description}: - -Counts the number of @code{.TRUE.} elements in a logical @var{MASK}, -or, if the @var{DIM} argument is supplied, counts the number of -elements along each row of the array in the @var{DIM} direction. -If the array has zero size, or all of the elements of @var{MASK} are -@code{.FALSE.}, then the result is @code{0}. - -@item @emph{Standard}: -Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = COUNT(MASK [, DIM, KIND])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{MASK} @tab The type shall be @code{LOGICAL}. -@item @var{DIM} @tab (Optional) The type shall be @code{INTEGER}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of kind @var{KIND}. If -@var{KIND} is absent, the return value is of default integer kind. -If @var{DIM} is present, the result is an array with a rank one less -than the rank of @var{ARRAY}, and a size corresponding to the shape -of @var{ARRAY} with the @var{DIM} dimension removed. - -@item @emph{Example}: -@smallexample -program test_count - integer, dimension(2,3) :: a, b - logical, dimension(2,3) :: mask - a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /)) - b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /)) - print '(3i3)', a(1,:) - print '(3i3)', a(2,:) - print * - print '(3i3)', b(1,:) - print '(3i3)', b(2,:) - print * - 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 -@end smallexample -@end table - - - -@node CPU_TIME -@section @code{CPU_TIME} --- CPU elapsed time in seconds -@fnindex CPU_TIME -@cindex time, elapsed - -@table @asis -@item @emph{Description}: -Returns a @code{REAL} value representing the elapsed CPU time in -seconds. This is useful for testing segments of code to determine -execution time. - -If a time source is available, time will be reported with microsecond -resolution. If no time source is available, @var{TIME} is set to -@code{-1.0}. - -Note that @var{TIME} may contain a, system dependent, arbitrary offset -and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute -value is meaningless, only differences between subsequent calls to -this subroutine, as shown in the example below, should be used. - - -@item @emph{Standard}: -Fortran 95 and later - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL CPU_TIME(TIME)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}. -@end multitable - -@item @emph{Return value}: -None - -@item @emph{Example}: -@smallexample -program test_cpu_time - real :: start, finish - call cpu_time(start) - ! put code to test here - call cpu_time(finish) - print '("Time = ",f6.3," seconds.")',finish-start -end program test_cpu_time -@end smallexample - -@item @emph{See also}: -@ref{SYSTEM_CLOCK}, @gol -@ref{DATE_AND_TIME} -@end table - - - -@node CSHIFT -@section @code{CSHIFT} --- Circular shift elements of an array -@fnindex CSHIFT -@cindex array, shift circularly -@cindex array, permutation -@cindex array, rotate - -@table @asis -@item @emph{Description}: -@code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of -@var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is -taken to be @code{1}. @var{DIM} is a scalar of type @code{INTEGER} in the -range of @math{1 \leq DIM \leq n)} where @math{n} is the rank of @var{ARRAY}. -If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted -by @var{SHIFT} places. If rank is greater than one, then all complete rank one -sections of @var{ARRAY} along the given dimension are shifted. Elements -shifted out one end of each rank one section are shifted back in the other end. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an array of any type. -@item @var{SHIFT} @tab The type shall be @code{INTEGER}. -@item @var{DIM} @tab The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -Returns an array of same type and rank as the @var{ARRAY} argument. - -@item @emph{Example}: -@smallexample -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 -@end smallexample -@end table - - - -@node CTIME -@section @code{CTIME} --- Convert a time into a string -@fnindex CTIME -@cindex time, conversion to string -@cindex conversion, to string - -@table @asis -@item @emph{Description}: -@code{CTIME} converts a system time value, such as returned by -@ref{TIME8}, to a string. The output will be of the form @samp{Sat -Aug 19 18:13:14 1995}. - -This intrinsic is provided in both subroutine and function forms; however, -only one form can be used in any given program unit. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL CTIME(TIME, RESULT)}. -@item @code{RESULT = CTIME(TIME)}. -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{TIME} @tab The type shall be of type @code{INTEGER}. -@item @var{RESULT} @tab The type shall be of type @code{CHARACTER} and -of default kind. It is an @code{INTENT(OUT)} argument. If the length -of this variable is too short for the time and date string to fit -completely, it will be blank on procedure return. -@end multitable - -@item @emph{Return value}: -The converted date and time as a string. - -@item @emph{Example}: -@smallexample -program test_ctime - integer(8) :: i - character(len=30) :: date - i = time8() - - ! Do something, main part of the program - - call ctime(i,date) - print *, 'Program was started on ', date -end program test_ctime -@end smallexample - -@item @emph{See Also}: -@ref{DATE_AND_TIME}, @gol -@ref{GMTIME}, @gol -@ref{LTIME}, @gol -@ref{TIME}, @gol -@ref{TIME8} -@end table - - - -@node DATE_AND_TIME -@section @code{DATE_AND_TIME} --- Date and time subroutine -@fnindex DATE_AND_TIME -@cindex date, current -@cindex current date -@cindex time, current -@cindex current time - -@table @asis -@item @emph{Description}: -@code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and -time information from the real-time system clock. @var{DATE} is -@code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and -has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm, -representing the difference with respect to Coordinated Universal Time (UTC). -Unavailable time and date parameters return blanks. - -@var{VALUES} is @code{INTENT(OUT)} and provides the following: - -@multitable @columnfractions .15 .70 -@item @code{VALUE(1)}: @tab The year -@item @code{VALUE(2)}: @tab The month -@item @code{VALUE(3)}: @tab The day of the month -@item @code{VALUE(4)}: @tab Time difference with UTC in minutes -@item @code{VALUE(5)}: @tab The hour of the day -@item @code{VALUE(6)}: @tab The minutes of the hour -@item @code{VALUE(7)}: @tab The seconds of the minute -@item @code{VALUE(8)}: @tab The milliseconds of the second -@end multitable - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(LEN=8)} -or larger, and of default kind. -@item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(LEN=10)} -or larger, and of default kind. -@item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(LEN=5)} -or larger, and of default kind. -@item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}. -@end multitable - -@item @emph{Return value}: -None - -@item @emph{Example}: -@smallexample -program test_time_and_date - character(8) :: date - character(10) :: time - character(5) :: zone - integer,dimension(8) :: values - ! using keyword arguments - call date_and_time(date,time,zone,values) - call date_and_time(DATE=date,ZONE=zone) - call date_and_time(TIME=time) - call date_and_time(VALUES=values) - print '(a,2x,a,2x,a)', date, time, zone - print '(8i5)', values -end program test_time_and_date -@end smallexample - -@item @emph{See also}: -@ref{CPU_TIME}, @gol -@ref{SYSTEM_CLOCK} -@end table - - - -@node DBLE -@section @code{DBLE} --- Double conversion function -@fnindex DBLE -@cindex conversion, to real - -@table @asis -@item @emph{Description}: -@code{DBLE(A)} Converts @var{A} to double precision real type. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = DBLE(A)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab The type shall be @code{INTEGER}, @code{REAL}, -or @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value is of type double precision real. - -@item @emph{Example}: -@smallexample -program test_dble - real :: x = 2.18 - integer :: i = 5 - complex :: z = (2.3,1.14) - print *, dble(x), dble(i), dble(z) -end program test_dble -@end smallexample - -@item @emph{See also}: -@ref{REAL} -@end table - - - -@node DCMPLX -@section @code{DCMPLX} --- Double complex conversion function -@fnindex DCMPLX -@cindex complex numbers, conversion to -@cindex conversion, to complex - -@table @asis -@item @emph{Description}: -@code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is -converted to the real component. If @var{Y} is present it is converted to the -imaginary component. If @var{Y} is not present then the imaginary component is -set to 0.0. If @var{X} is complex then @var{Y} must not be present. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = DCMPLX(X [, Y])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type may be @code{INTEGER}, @code{REAL}, -or @code{COMPLEX}. -@item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX}.) May be -@code{INTEGER} or @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{COMPLEX(8)} - -@item @emph{Example}: -@smallexample -program test_dcmplx - integer :: i = 42 - real :: x = 3.14 - complex :: z - z = cmplx(i, x) - print *, dcmplx(i) - print *, dcmplx(x) - print *, dcmplx(z) - print *, dcmplx(x,i) -end program test_dcmplx -@end smallexample -@end table - - -@node DIGITS -@section @code{DIGITS} --- Significant binary digits function -@fnindex DIGITS -@cindex model representation, significant digits - -@table @asis -@item @emph{Description}: -@code{DIGITS(X)} returns the number of significant binary digits of the internal -model representation of @var{X}. For example, on a system using a 32-bit -floating point representation, a default real number would likely return 24. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = DIGITS(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER}. - -@item @emph{Example}: -@smallexample -program test_digits - integer :: i = 12345 - real :: x = 3.143 - real(8) :: y = 2.33 - print *, digits(i) - print *, digits(x) - print *, digits(y) -end program test_digits -@end smallexample -@end table - - - -@node DIM -@section @code{DIM} --- Positive difference -@fnindex DIM -@fnindex IDIM -@fnindex DDIM -@cindex positive difference - -@table @asis -@item @emph{Description}: -@code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive; -otherwise returns zero. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = DIM(X, Y)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{INTEGER} or @code{REAL} -@item @var{Y} @tab The type shall be the same type and kind as @var{X}. (As -a GNU extension, arguments of different kinds are permitted.) -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} or @code{REAL}. (As a GNU -extension, kind is the largest kind of the actual arguments.) - -@item @emph{Example}: -@smallexample -program test_dim - integer :: i - real(8) :: x - i = dim(4, 15) - x = dim(4.345_8, 2.111_8) - print *, i - print *, x -end program test_dim -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .26 .20 .30 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{DIM(X,Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X, Y} @tab @code{INTEGER(4)} @tab Fortran 77 and later -@item @code{DDIM(X,Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later -@end multitable -@end table - - - -@node DOT_PRODUCT -@section @code{DOT_PRODUCT} --- Dot product function -@fnindex DOT_PRODUCT -@cindex dot product -@cindex vector product -@cindex product, vector - -@table @asis -@item @emph{Description}: -@code{DOT_PRODUCT(VECTOR_A, VECTOR_B)} computes the dot product multiplication -of two vectors @var{VECTOR_A} and @var{VECTOR_B}. The two vectors may be -either numeric or logical and must be arrays of rank one and of equal size. If -the vectors are @code{INTEGER} or @code{REAL}, the result is -@code{SUM(VECTOR_A*VECTOR_B)}. If the vectors are @code{COMPLEX}, the result -is @code{SUM(CONJG(VECTOR_A)*VECTOR_B)}. If the vectors are @code{LOGICAL}, -the result is @code{ANY(VECTOR_A .AND. VECTOR_B)}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = DOT_PRODUCT(VECTOR_A, VECTOR_B)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{VECTOR_A} @tab The type shall be numeric or @code{LOGICAL}, rank 1. -@item @var{VECTOR_B} @tab The type shall be numeric if @var{VECTOR_A} is of numeric type or @code{LOGICAL} if @var{VECTOR_A} is of type @code{LOGICAL}. @var{VECTOR_B} shall be a rank-one array. -@end multitable - -@item @emph{Return value}: -If the arguments are numeric, the return value is a scalar of numeric type, -@code{INTEGER}, @code{REAL}, or @code{COMPLEX}. If the arguments are -@code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}. - -@item @emph{Example}: -@smallexample -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 -@end smallexample -@end table - - - -@node DPROD -@section @code{DPROD} --- Double product function -@fnindex DPROD -@cindex product, double-precision - -@table @asis -@item @emph{Description}: -@code{DPROD(X,Y)} returns the product @code{X*Y}. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = DPROD(X, Y)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL}. -@item @var{Y} @tab The type shall be @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{REAL(8)}. - -@item @emph{Example}: -@smallexample -program test_dprod - real :: x = 5.2 - real :: y = 2.3 - real(8) :: d - d = dprod(x,y) - print *, d -end program test_dprod -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{DPROD(X,Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later -@end multitable - -@end table - - -@node DREAL -@section @code{DREAL} --- Double real part function -@fnindex DREAL -@cindex complex numbers, real part - -@table @asis -@item @emph{Description}: -@code{DREAL(Z)} returns the real part of complex variable @var{Z}. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = DREAL(A)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab The type shall be @code{COMPLEX(8)}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{REAL(8)}. - -@item @emph{Example}: -@smallexample -program test_dreal - complex(8) :: z = (1.3_8,7.2_8) - print *, dreal(z) -end program test_dreal -@end smallexample - -@item @emph{See also}: -@ref{AIMAG} - -@end table - - - -@node DSHIFTL -@section @code{DSHIFTL} --- Combined left shift -@fnindex DSHIFTL -@cindex left shift, combined -@cindex shift, left - -@table @asis -@item @emph{Description}: -@code{DSHIFTL(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The -rightmost @var{SHIFT} bits of the result are the leftmost @var{SHIFT} -bits of @var{J}, and the remaining bits are the rightmost bits of -@var{I}. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = DSHIFTL(I, J, SHIFT)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant. -@item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant. -If both @var{I} and @var{J} have integer type, then they shall have -the same kind type parameter. @var{I} and @var{J} shall not both be -BOZ constants. -@item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall -be nonnegative. If @var{I} is not a BOZ constant, then @var{SHIFT} -shall be less than or equal to @code{BIT_SIZE(I)}; otherwise, -@var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}. -@end multitable - -@item @emph{Return value}: -If either @var{I} or @var{J} is a BOZ constant, it is first converted -as if by the intrinsic function @code{INT} to an integer type with the -kind type parameter of the other. - -@item @emph{See also}: -@ref{DSHIFTR} -@end table - - -@node DSHIFTR -@section @code{DSHIFTR} --- Combined right shift -@fnindex DSHIFTR -@cindex right shift, combined -@cindex shift, right - -@table @asis -@item @emph{Description}: -@code{DSHIFTR(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The -leftmost @var{SHIFT} bits of the result are the rightmost @var{SHIFT} -bits of @var{I}, and the remaining bits are the leftmost bits of -@var{J}. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = DSHIFTR(I, J, SHIFT)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant. -@item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant. -If both @var{I} and @var{J} have integer type, then they shall have -the same kind type parameter. @var{I} and @var{J} shall not both be -BOZ constants. -@item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall -be nonnegative. If @var{I} is not a BOZ constant, then @var{SHIFT} -shall be less than or equal to @code{BIT_SIZE(I)}; otherwise, -@var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}. -@end multitable - -@item @emph{Return value}: -If either @var{I} or @var{J} is a BOZ constant, it is first converted -as if by the intrinsic function @code{INT} to an integer type with the -kind type parameter of the other. - -@item @emph{See also}: -@ref{DSHIFTL} -@end table - - -@node DTIME -@section @code{DTIME} --- Execution time subroutine (or function) -@fnindex DTIME -@cindex time, elapsed -@cindex elapsed time - -@table @asis -@item @emph{Description}: -@code{DTIME(VALUES, TIME)} initially returns the number of seconds of runtime -since the start of the process's execution in @var{TIME}. @var{VALUES} -returns the user and system components of this time in @code{VALUES(1)} and -@code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) + -VALUES(2)}. - -Subsequent invocations of @code{DTIME} return values accumulated since the -previous invocation. - -On some systems, the underlying timings are represented using types with -sufficiently small limits that overflows (wrap around) are possible, such as -32-bit types. 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. - -Please note, that this implementation is thread safe if used within OpenMP -directives, i.e., its state will be consistent while called from multiple -threads. However, if @code{DTIME} is called from multiple threads, the result -is still the time since the last invocation. This may not give the intended -results. If possible, use @code{CPU_TIME} instead. - -This intrinsic is provided in both subroutine and function forms; however, -only one form can be used in any given program unit. - -@var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following: - -@multitable @columnfractions .15 .70 -@item @code{VALUES(1)}: @tab User time in seconds. -@item @code{VALUES(2)}: @tab System time in seconds. -@item @code{TIME}: @tab Run time since start in seconds. -@end multitable - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL DTIME(VALUES, TIME)}. -@item @code{TIME = DTIME(VALUES)}, (not recommended). -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}. -@item @var{TIME}@tab The type shall be @code{REAL(4)}. -@end multitable - -@item @emph{Return value}: -Elapsed time in seconds since the last invocation or since the start of program -execution if not called before. - -@item @emph{Example}: -@smallexample -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 -@end smallexample - -@item @emph{See also}: -@ref{CPU_TIME} - -@end table - - - -@node EOSHIFT -@section @code{EOSHIFT} --- End-off shift elements of an array -@fnindex EOSHIFT -@cindex array, shift - -@table @asis -@item @emph{Description}: -@code{EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])} performs an end-off shift on -elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is -omitted it is taken to be @code{1}. @var{DIM} is a scalar of type -@code{INTEGER} in the range of @math{1 \leq DIM \leq n)} where @math{n} is the -rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of -@var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one, -then all complete rank one sections of @var{ARRAY} along the given dimension are -shifted. Elements shifted out one end of each rank one section are dropped. If -@var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY} -is copied back in the other end. If @var{BOUNDARY} is not present then the -following are copied in depending on the type of @var{ARRAY}. - -@multitable @columnfractions .15 .80 -@item @emph{Array Type} @tab @emph{Boundary Value} -@item Numeric @tab 0 of the type and kind of @var{ARRAY}. -@item Logical @tab @code{.FALSE.}. -@item Character(@var{len}) @tab @var{len} blanks. -@end multitable - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab May be any type, not scalar. -@item @var{SHIFT} @tab The type shall be @code{INTEGER}. -@item @var{BOUNDARY} @tab Same type as @var{ARRAY}. -@item @var{DIM} @tab The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -Returns an array of same type and rank as the @var{ARRAY} argument. - -@item @emph{Example}: -@smallexample -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 -@end smallexample -@end table - - - -@node EPSILON -@section @code{EPSILON} --- Epsilon function -@fnindex EPSILON -@cindex model representation, epsilon - -@table @asis -@item @emph{Description}: -@code{EPSILON(X)} returns the smallest number @var{E} of the same kind -as @var{X} such that @math{1 + E > 1}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = EPSILON(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of same type as the argument. - -@item @emph{Example}: -@smallexample -program test_epsilon - real :: x = 3.143 - real(8) :: y = 2.33 - print *, EPSILON(x) - print *, EPSILON(y) -end program test_epsilon -@end smallexample -@end table - - - -@node ERF -@section @code{ERF} --- Error function -@fnindex ERF -@cindex error function - -@table @asis -@item @emph{Description}: -@code{ERF(X)} computes the error function of @var{X}. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ERF(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{REAL}, of the same kind as -@var{X} and lies in the range @math{-1 \leq erf (x) \leq 1 }. - -@item @emph{Example}: -@smallexample -program test_erf - real(8) :: x = 0.17_8 - x = erf(x) -end program test_erf -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@end multitable -@end table - - - -@node ERFC -@section @code{ERFC} --- Error function -@fnindex ERFC -@cindex error function, complementary - -@table @asis -@item @emph{Description}: -@code{ERFC(X)} computes the complementary error function of @var{X}. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ERFC(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{REAL} and of the same kind as @var{X}. -It lies in the range @math{ 0 \leq erfc (x) \leq 2 }. - -@item @emph{Example}: -@smallexample -program test_erfc - real(8) :: x = 0.17_8 - x = erfc(x) -end program test_erfc -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@end multitable -@end table - - - -@node ERFC_SCALED -@section @code{ERFC_SCALED} --- Error function -@fnindex ERFC_SCALED -@cindex error function, complementary, exponentially-scaled - -@table @asis -@item @emph{Description}: -@code{ERFC_SCALED(X)} computes the exponentially-scaled complementary -error function of @var{X}. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ERFC_SCALED(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{REAL} and of the same kind as @var{X}. - -@item @emph{Example}: -@smallexample -program test_erfc_scaled - real(8) :: x = 0.17_8 - x = erfc_scaled(x) -end program test_erfc_scaled -@end smallexample -@end table - - - -@node ETIME -@section @code{ETIME} --- Execution time subroutine (or function) -@fnindex ETIME -@cindex time, elapsed - -@table @asis -@item @emph{Description}: -@code{ETIME(VALUES, TIME)} returns the number of seconds of runtime -since the start of the process's execution in @var{TIME}. @var{VALUES} -returns the user and system components of this time in @code{VALUES(1)} and -@code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) + VALUES(2)}. - -On some systems, the underlying timings are represented using types with -sufficiently small limits that overflows (wrap around) are possible, such as -32-bit types. 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. - -This intrinsic is provided in both subroutine and function forms; however, -only one form can be used in any given program unit. - -@var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following: - -@multitable @columnfractions .15 .70 -@item @code{VALUES(1)}: @tab User time in seconds. -@item @code{VALUES(2)}: @tab System time in seconds. -@item @code{TIME}: @tab Run time since start in seconds. -@end multitable - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL ETIME(VALUES, TIME)}. -@item @code{TIME = ETIME(VALUES)}, (not recommended). -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}. -@item @var{TIME}@tab The type shall be @code{REAL(4)}. -@end multitable - -@item @emph{Return value}: -Elapsed time in seconds since the start of program execution. - -@item @emph{Example}: -@smallexample -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 -@end smallexample - -@item @emph{See also}: -@ref{CPU_TIME} - -@end table - - - -@node EVENT_QUERY -@section @code{EVENT_QUERY} --- Query whether a coarray event has occurred -@fnindex EVENT_QUERY -@cindex Events, EVENT_QUERY - -@table @asis -@item @emph{Description}: -@code{EVENT_QUERY} assignes the number of events to @var{COUNT} which have been -posted to the @var{EVENT} variable and not yet been removed by calling -@code{EVENT WAIT}. When @var{STAT} is present and the invocation was successful, -it is assigned the value 0. If it is present and the invocation has failed, -it is assigned a positive value and @var{COUNT} is assigned the value @math{-1}. - -@item @emph{Standard}: -TS 18508 or later - -@item @emph{Class}: - subroutine - -@item @emph{Syntax}: -@code{CALL EVENT_QUERY (EVENT, COUNT [, STAT])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{EVENT} @tab (intent(IN)) Scalar of type @code{EVENT_TYPE}, -defined in @code{ISO_FORTRAN_ENV}; shall not be coindexed. -@item @var{COUNT} @tab (intent(out))Scalar integer with at least the -precision of default integer. -@item @var{STAT} @tab (optional) Scalar default-kind integer variable. -@end multitable - -@item @emph{Example}: -@smallexample -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 -@end smallexample - -@end table - - - -@node EXECUTE_COMMAND_LINE -@section @code{EXECUTE_COMMAND_LINE} --- Execute a shell command -@fnindex EXECUTE_COMMAND_LINE -@cindex system, system call -@cindex command line - -@table @asis -@item @emph{Description}: -@code{EXECUTE_COMMAND_LINE} runs a shell command, synchronously or -asynchronously. - -The @code{COMMAND} argument is passed to the shell and executed (The -shell is @code{sh} on Unix systems, and @code{cmd.exe} on Windows.). -If @code{WAIT} is present and has the value false, the execution of -the command is asynchronous if the system supports it; otherwise, the -command is executed synchronously using the C library's @code{system} -call. - -The three last arguments allow the user to get status information. After -synchronous execution, @code{EXITSTAT} contains the integer exit code of -the command, as returned by @code{system}. @code{CMDSTAT} is set to zero -if the command line was executed (whatever its exit status was). -@code{CMDMSG} is assigned an error message if an error has occurred. - -Note that the @code{system} function need not be thread-safe. It is -the responsibility of the user to ensure that @code{system} is not -called concurrently. - -For asynchronous execution on supported targets, the POSIX -@code{posix_spawn} or @code{fork} functions are used. Also, a signal -handler for the @code{SIGCHLD} signal is installed. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL EXECUTE_COMMAND_LINE(COMMAND [, WAIT, EXITSTAT, CMDSTAT, CMDMSG ])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{COMMAND} @tab Shall be a default @code{CHARACTER} scalar. -@item @var{WAIT} @tab (Optional) Shall be a default @code{LOGICAL} scalar. -@item @var{EXITSTAT} @tab (Optional) Shall be an @code{INTEGER} of the -default kind. -@item @var{CMDSTAT} @tab (Optional) Shall be an @code{INTEGER} of the -default kind. -@item @var{CMDMSG} @tab (Optional) Shall be an @code{CHARACTER} scalar of the -default kind. -@end multitable - -@item @emph{Example}: -@smallexample -program test_exec - integer :: i - - call execute_command_line ("external_prog.exe", exitstat=i) - print *, "Exit status of external_prog.exe was ", i - - call execute_command_line ("reindex_files.exe", wait=.false.) - print *, "Now reindexing files in the background" - -end program test_exec -@end smallexample - - -@item @emph{Note}: - -Because this intrinsic is implemented in terms of the @code{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. - - -@item @emph{See also}: -@ref{SYSTEM} -@end table - - - -@node EXIT -@section @code{EXIT} --- Exit the program with status. -@fnindex EXIT -@cindex program termination -@cindex terminate program - -@table @asis -@item @emph{Description}: -@code{EXIT} causes immediate termination of the program with status. If status -is omitted it returns the canonical @emph{success} for the system. All Fortran -I/O units are closed. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL EXIT([STATUS])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind. -@end multitable - -@item @emph{Return value}: -@code{STATUS} is passed to the parent process on exit. - -@item @emph{Example}: -@smallexample -program test_exit - integer :: STATUS = 0 - print *, 'This program is going to exit.' - call EXIT(STATUS) -end program test_exit -@end smallexample - -@item @emph{See also}: -@ref{ABORT}, @gol -@ref{KILL} -@end table - - - -@node EXP -@section @code{EXP} --- Exponential function -@fnindex EXP -@fnindex DEXP -@fnindex CEXP -@fnindex ZEXP -@fnindex CDEXP -@cindex exponential function -@cindex logarithm function, inverse - -@table @asis -@item @emph{Description}: -@code{EXP(X)} computes the base @math{e} exponential of @var{X}. - -@item @emph{Standard}: -Fortran 77 and later, has overloads that are GNU extensions - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = EXP(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or -@code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value has same type and kind as @var{X}. - -@item @emph{Example}: -@smallexample -program test_exp - real :: x = 1.0 - x = exp(x) -end program test_exp -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{EXP(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later -@item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later -@item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension -@item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension -@end multitable -@end table - - - -@node EXPONENT -@section @code{EXPONENT} --- Exponent function -@fnindex EXPONENT -@cindex real number, exponent -@cindex floating point, exponent - -@table @asis -@item @emph{Description}: -@code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X} -is zero the value returned is zero. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = EXPONENT(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of type default @code{INTEGER}. - -@item @emph{Example}: -@smallexample -program test_exponent - real :: x = 1.0 - integer :: i - i = exponent(x) - print *, i - print *, exponent(0.0) -end program test_exponent -@end smallexample -@end table - - - -@node EXTENDS_TYPE_OF -@section @code{EXTENDS_TYPE_OF} --- Query dynamic type for extension -@fnindex EXTENDS_TYPE_OF - -@table @asis -@item @emph{Description}: -Query dynamic type for extension. - -@item @emph{Standard}: -Fortran 2003 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = EXTENDS_TYPE_OF(A, MOLD)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab Shall be an object of extensible declared type or -unlimited polymorphic. -@item @var{MOLD} @tab Shall be an object of extensible declared type or -unlimited polymorphic. -@end multitable - -@item @emph{Return value}: -The return value is a scalar of type default logical. It is true if and only if -the dynamic type of A is an extension type of the dynamic type of MOLD. - - -@item @emph{See also}: -@ref{SAME_TYPE_AS} -@end table - - - -@node FDATE -@section @code{FDATE} --- Get the current time as a string -@fnindex FDATE -@cindex time, current -@cindex current time -@cindex date, current -@cindex current date - -@table @asis -@item @emph{Description}: -@code{FDATE(DATE)} returns the current date (using the same format as -@ref{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE, -TIME())}. - -This intrinsic is provided in both subroutine and function forms; however, -only one form can be used in any given program unit. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL FDATE(DATE)}. -@item @code{DATE = FDATE()}. -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{DATE}@tab The type shall be of type @code{CHARACTER} of the -default kind. It is an @code{INTENT(OUT)} argument. If the length of -this variable is too short for the date and time string to fit -completely, it will be blank on procedure return. -@end multitable - -@item @emph{Return value}: -The current date and time as a string. - -@item @emph{Example}: -@smallexample -program test_fdate - integer(8) :: i, j - character(len=30) :: date - call fdate(date) - print *, 'Program started on ', date - do i = 1, 100000000 ! Just a delay - j = i * i - i - end do - call fdate(date) - print *, 'Program ended on ', date -end program test_fdate -@end smallexample - -@item @emph{See also}: -@ref{DATE_AND_TIME}, @gol -@ref{CTIME} -@end table - - -@node FGET -@section @code{FGET} --- Read a single character in stream mode from stdin -@fnindex FGET -@cindex read character, stream mode -@cindex stream mode, read character -@cindex file operation, read character - -@table @asis -@item @emph{Description}: -Read a single character in stream mode from stdin by bypassing normal -formatted output. Stream I/O should not be mixed with normal record-oriented -(formatted or unformatted) I/O on the same unit; the results are unpredictable. - -This intrinsic is provided in both subroutine and function forms; however, -only one form can be used in any given program unit. - -Note that the @code{FGET} intrinsic is provided for backwards compatibility with -@command{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 @ref{Fortran 2003 status}. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL FGET(C [, STATUS])} -@item @code{STATUS = FGET(C)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{C} @tab The type shall be @code{CHARACTER} and of default -kind. -@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. -Returns 0 on success, -1 on end-of-file, and a system specific positive -error code otherwise. -@end multitable - -@item @emph{Example}: -@smallexample -PROGRAM test_fget - INTEGER, PARAMETER :: strlen = 100 - INTEGER :: status, i = 1 - CHARACTER(len=strlen) :: str = "" - - WRITE (*,*) 'Enter text:' - DO - CALL fget(str(i:i), status) - if (status /= 0 .OR. i > strlen) exit - i = i + 1 - END DO - WRITE (*,*) TRIM(str) -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{FGETC}, @gol -@ref{FPUT}, @gol -@ref{FPUTC} -@end table - - - -@node FGETC -@section @code{FGETC} --- Read a single character in stream mode -@fnindex FGETC -@cindex read character, stream mode -@cindex stream mode, read character -@cindex file operation, read character - -@table @asis -@item @emph{Description}: -Read a single character in stream mode by bypassing normal formatted output. -Stream I/O should not be mixed with normal record-oriented (formatted or -unformatted) I/O on the same unit; the results are unpredictable. - -This intrinsic is provided in both subroutine and function forms; however, -only one form can be used in any given program unit. - -Note that the @code{FGET} intrinsic is provided for backwards compatibility -with @command{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 @ref{Fortran 2003 status}. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL FGETC(UNIT, C [, STATUS])} -@item @code{STATUS = FGETC(UNIT, C)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{UNIT} @tab The type shall be @code{INTEGER}. -@item @var{C} @tab The type shall be @code{CHARACTER} and of default -kind. -@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. -Returns 0 on success, -1 on end-of-file and a system specific positive -error code otherwise. -@end multitable - -@item @emph{Example}: -@smallexample -PROGRAM test_fgetc - INTEGER :: fd = 42, status - CHARACTER :: c - - OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD") - DO - CALL fgetc(fd, c, status) - IF (status /= 0) EXIT - call fput(c) - END DO - CLOSE(UNIT=fd) -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{FGET}, @gol -@ref{FPUT}, @gol -@ref{FPUTC} -@end table - -@node FINDLOC -@section @code{FINDLOC} --- Search an array for a value -@fnindex FINDLOC -@cindex findloc - -@table @asis -@item @emph{Description}: -Determines the location of the element in the array with the value -given in the @var{VALUE} argument, or, if the @var{DIM} argument is -supplied, determines the locations of the elements equal to the -@var{VALUE} argument element along each -row of the array in the @var{DIM} direction. If @var{MASK} is -present, only the elements for which @var{MASK} is @code{.TRUE.} are -considered. If more than one element in the array has the value -@var{VALUE}, the location returned is that of the first such element -in array element order if the @var{BACK} is not present or if it is -@code{.FALSE.}. If @var{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 @var{MASK} are @code{.FALSE.}, then the result is an array -of zeroes. Similarly, if @var{DIM} is supplied and all of the -elements of @var{MASK} along a given row are zero, the result value -for that row is zero. - -@item @emph{Standard}: -Fortran 2008 and later. - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = FINDLOC(ARRAY, VALUE, DIM [, MASK] [,KIND] [,BACK])} -@item @code{RESULT = FINDLOC(ARRAY, VALUE, [, MASK] [,KIND] [,BACK])} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an array of intrinsic type. -@item @var{VALUE} @tab A scalar of intrinsic type which is in type -conformance with @var{ARRAY}. -@item @var{DIM} @tab (Optional) Shall be a scalar of type -@code{INTEGER}, with a value between one and the rank of @var{ARRAY}, -inclusive. It may not be an optional dummy argument. -@item @var{MASK} @tab (Optional) Shall be of type @code{LOGICAL}, -and conformable with @var{ARRAY}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}. -@end multitable - -@item @emph{Return value}: -If @var{DIM} is absent, the result is a rank-one array with a length -equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result -is an array with a rank one less than the rank of @var{ARRAY}, and a -size corresponding to the size of @var{ARRAY} with the @var{DIM} -dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank -of one, the result is a scalar. If the optional argument @var{KIND} -is present, the result is an integer of kind @var{KIND}, otherwise it -is of default kind. - -@item @emph{See also}: -@ref{MAXLOC}, @gol -@ref{MINLOC} - -@end table - -@node FLOOR -@section @code{FLOOR} --- Integer floor function -@fnindex FLOOR -@cindex floor -@cindex rounding, floor - -@table @asis -@item @emph{Description}: -@code{FLOOR(A)} returns the greatest integer less than or equal to @var{X}. - -@item @emph{Standard}: -Fortran 95 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = FLOOR(A [, KIND])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab The type shall be @code{REAL}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present -and of default-kind @code{INTEGER} otherwise. - -@item @emph{Example}: -@smallexample -program test_floor - real :: x = 63.29 - real :: y = -63.59 - print *, floor(x) ! returns 63 - print *, floor(y) ! returns -64 -end program test_floor -@end smallexample - -@item @emph{See also}: -@ref{CEILING}, @gol -@ref{NINT} -@end table - - - -@node FLUSH -@section @code{FLUSH} --- Flush I/O unit(s) -@fnindex FLUSH -@cindex file operation, flush - -@table @asis -@item @emph{Description}: -Flushes Fortran unit(s) currently open for output. Without the optional -argument, all units are flushed, otherwise just the unit specified. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL FLUSH(UNIT)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Note}: -Beginning with the Fortran 2003 standard, there is a @code{FLUSH} -statement that should be preferred over the @code{FLUSH} intrinsic. - -The @code{FLUSH} intrinsic and the Fortran 2003 @code{FLUSH} statement -have identical effect: they flush the runtime library's I/O buffer so -that the data becomes visible to other processes. This does not guarantee -that the data is committed to disk. - -On POSIX systems, you can request that all data is transferred to the -storage device by calling the @code{fsync} function, with the POSIX file -descriptor of the I/O unit as argument (retrieved with GNU intrinsic -@code{FNUM}). The following example shows how: - -@smallexample - ! Declare the interface for POSIX fsync function - interface - function fsync (fd) bind(c,name="fsync") - use iso_c_binding, only: c_int - integer(c_int), value :: fd - integer(c_int) :: fsync - end function fsync - end interface - - ! Variable declaration - integer :: ret - - ! Opening unit 10 - open (10,file="foo") - - ! ... - ! Perform I/O on unit 10 - ! ... - - ! Flush and sync - flush(10) - ret = fsync(fnum(10)) - - ! Handle possible error - if (ret /= 0) stop "Error calling FSYNC" -@end smallexample - -@end table - - - -@node FNUM -@section @code{FNUM} --- File number function -@fnindex FNUM -@cindex file operation, file number - -@table @asis -@item @emph{Description}: -@code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the -open Fortran I/O unit @code{UNIT}. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{RESULT = FNUM(UNIT)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{UNIT} @tab The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} - -@item @emph{Example}: -@smallexample -program test_fnum - integer :: i - open (unit=10, status = "scratch") - i = fnum(10) - print *, i - close (10) -end program test_fnum -@end smallexample -@end table - - - -@node FPUT -@section @code{FPUT} --- Write a single character in stream mode to stdout -@fnindex FPUT -@cindex write character, stream mode -@cindex stream mode, write character -@cindex file operation, write character - -@table @asis -@item @emph{Description}: -Write a single character in stream mode to stdout by bypassing normal -formatted output. Stream I/O should not be mixed with normal record-oriented -(formatted or unformatted) I/O on the same unit; the results are unpredictable. - -This intrinsic is provided in both subroutine and function forms; however, -only one form can be used in any given program unit. - -Note that the @code{FGET} intrinsic is provided for backwards compatibility with -@command{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 @ref{Fortran 2003 status}. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL FPUT(C [, STATUS])} -@item @code{STATUS = FPUT(C)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{C} @tab The type shall be @code{CHARACTER} and of default -kind. -@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. -Returns 0 on success, -1 on end-of-file and a system specific positive -error code otherwise. -@end multitable - -@item @emph{Example}: -@smallexample -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 -@end smallexample - -@item @emph{See also}: -@ref{FPUTC}, @gol -@ref{FGET}, @gol -@ref{FGETC} -@end table - - - -@node FPUTC -@section @code{FPUTC} --- Write a single character in stream mode -@fnindex FPUTC -@cindex write character, stream mode -@cindex stream mode, write character -@cindex file operation, write character - -@table @asis -@item @emph{Description}: -Write a single character in stream mode by bypassing normal formatted -output. Stream I/O should not be mixed with normal record-oriented -(formatted or unformatted) I/O on the same unit; the results are unpredictable. - -This intrinsic is provided in both subroutine and function forms; however, -only one form can be used in any given program unit. - -Note that the @code{FGET} intrinsic is provided for backwards compatibility with -@command{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 @ref{Fortran 2003 status}. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL FPUTC(UNIT, C [, STATUS])} -@item @code{STATUS = FPUTC(UNIT, C)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{UNIT} @tab The type shall be @code{INTEGER}. -@item @var{C} @tab The type shall be @code{CHARACTER} and of default -kind. -@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. -Returns 0 on success, -1 on end-of-file and a system specific positive -error code otherwise. -@end multitable - -@item @emph{Example}: -@smallexample -PROGRAM test_fputc - CHARACTER(len=10) :: str = "gfortran" - INTEGER :: fd = 42, i - - OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW") - DO i = 1, len_trim(str) - CALL fputc(fd, str(i:i)) - END DO - CLOSE(fd) -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{FPUT}, @gol -@ref{FGET}, @gol -@ref{FGETC} -@end table - - - -@node FRACTION -@section @code{FRACTION} --- Fractional part of the model representation -@fnindex FRACTION -@cindex real number, fraction -@cindex floating point, fraction - -@table @asis -@item @emph{Description}: -@code{FRACTION(X)} returns the fractional part of the model -representation of @code{X}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{Y = FRACTION(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type of the argument shall be a @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of the same type and kind as the argument. -The fractional part of the model representation of @code{X} is returned; -it is @code{X * RADIX(X)**(-EXPONENT(X))}. - -@item @emph{Example}: -@smallexample -program test_fraction - real :: x - x = 178.1387e-4 - print *, fraction(x), x * radix(x)**(-exponent(x)) -end program test_fraction -@end smallexample - -@end table - - - -@node FREE -@section @code{FREE} --- Frees memory -@fnindex FREE -@cindex pointer, cray - -@table @asis -@item @emph{Description}: -Frees memory previously allocated by @code{MALLOC}. The @code{FREE} -intrinsic is an extension intended to be used with Cray pointers, and is -provided in GNU Fortran to allow user to compile legacy code. For -new code using Fortran 95 pointers, the memory de-allocation intrinsic is -@code{DEALLOCATE}. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL FREE(PTR)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the -location of the memory that should be de-allocated. -@end multitable - -@item @emph{Return value}: -None - -@item @emph{Example}: -See @code{MALLOC} for an example. - -@item @emph{See also}: -@ref{MALLOC} -@end table - - - -@node FSEEK -@section @code{FSEEK} --- Low level file positioning subroutine -@fnindex FSEEK -@cindex file operation, seek -@cindex file operation, position - -@table @asis -@item @emph{Description}: -Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE} -is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET}, -if set to 1, @var{OFFSET} is taken to be relative to the current position -@code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}. -On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek -fails silently. - -This intrinsic routine is not fully backwards compatible with @command{g77}. -In @command{g77}, the @code{FSEEK} takes a statement label instead of a -@var{STATUS} variable. If FSEEK is used in old code, change -@smallexample - CALL FSEEK(UNIT, OFFSET, WHENCE, *label) -@end smallexample -to -@smallexample - INTEGER :: status - CALL FSEEK(UNIT, OFFSET, WHENCE, status) - IF (status /= 0) GOTO label -@end smallexample - -Please note that 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 @ref{Fortran 2003 status}. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{UNIT} @tab Shall be a scalar of type @code{INTEGER}. -@item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}. -@item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}. -Its value shall be either 0, 1 or 2. -@item @var{STATUS} @tab (Optional) shall be a scalar of type -@code{INTEGER(4)}. -@end multitable - -@item @emph{Example}: -@smallexample -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 - - CALL FSEEK(fd, 0, SEEK_END, ierr) ! move to end - print *, FTELL(fd), ierr - - CALL FSEEK(fd, 0, SEEK_SET, ierr) ! move to beginning - print *, FTELL(fd), ierr - - CLOSE(UNIT=fd) -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{FTELL} -@end table - - - -@node FSTAT -@section @code{FSTAT} --- Get file status -@fnindex FSTAT -@cindex file system, file status - -@table @asis -@item @emph{Description}: -@code{FSTAT} is identical to @ref{STAT}, except that information about an -already opened file is obtained. - -The elements in @code{VALUES} are the same as described by @ref{STAT}. - -This intrinsic is provided in both subroutine and function forms; however, -only one form can be used in any given program unit. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL FSTAT(UNIT, VALUES [, STATUS])} -@item @code{STATUS = FSTAT(UNIT, VALUES)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}. -@item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}. -@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 -on success and a system specific error code otherwise. -@end multitable - -@item @emph{Example}: -See @ref{STAT} for an example. - -@item @emph{See also}: -To stat a link: @gol -@ref{LSTAT} @gol -To stat a file: @gol -@ref{STAT} -@end table - - - -@node FTELL -@section @code{FTELL} --- Current stream position -@fnindex FTELL -@cindex file operation, position - -@table @asis -@item @emph{Description}: -Retrieves the current position within an open file. - -This intrinsic is provided in both subroutine and function forms; however, -only one form can be used in any given program unit. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL FTELL(UNIT, OFFSET)} -@item @code{OFFSET = FTELL(UNIT)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{OFFSET} @tab Shall of type @code{INTEGER}. -@item @var{UNIT} @tab Shall of type @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -In either syntax, @var{OFFSET} is set to the current offset of unit -number @var{UNIT}, or to @math{-1} if the unit is not currently open. - -@item @emph{Example}: -@smallexample -PROGRAM test_ftell - INTEGER :: i - OPEN(10, FILE="temp.dat") - CALL ftell(10,i) - WRITE(*,*) i -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{FSEEK} -@end table - - - -@node GAMMA -@section @code{GAMMA} --- Gamma function -@fnindex GAMMA -@fnindex DGAMMA -@cindex Gamma function -@cindex Factorial function - -@table @asis -@item @emph{Description}: -@code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive, -integer values of @var{X} the Gamma function simplifies to the factorial -function @math{\Gamma(x)=(x-1)!}. - -@tex -$$ -\Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t -$$ -@end tex - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{X = GAMMA(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab Shall be of type @code{REAL} and neither zero -nor a negative integer. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{REAL} of the same kind as @var{X}. - -@item @emph{Example}: -@smallexample -program test_gamma - real :: x = 1.0 - x = gamma(x) ! returns 1.0 -end program test_gamma -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -Logarithm of the Gamma function: @gol -@ref{LOG_GAMMA} -@end table - - - -@node GERROR -@section @code{GERROR} --- Get last system error message -@fnindex GERROR -@cindex system, error handling - -@table @asis -@item @emph{Description}: -Returns the system error message corresponding to the last system error. -This resembles the functionality of @code{strerror(3)} in C. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL GERROR(RESULT)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{RESULT} @tab Shall be of type @code{CHARACTER} and of default kind. -@end multitable - -@item @emph{Example}: -@smallexample -PROGRAM test_gerror - CHARACTER(len=100) :: msg - CALL gerror(msg) - WRITE(*,*) msg -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{IERRNO}, @gol -@ref{PERROR} -@end table - - - -@node GETARG -@section @code{GETARG} --- Get command line arguments -@fnindex GETARG -@cindex command-line arguments -@cindex arguments, to program - -@table @asis -@item @emph{Description}: -Retrieve the @var{POS}-th argument that was passed on the -command line when the containing program was invoked. - -This intrinsic routine is provided for backwards compatibility with -GNU Fortran 77. In new code, programmers should consider the use of -the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003 -standard. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL GETARG(POS, VALUE)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{POS} @tab Shall be of type @code{INTEGER} and not wider than -the default integer kind; @math{@var{POS} \geq 0} -@item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default -kind. -@end multitable - -@item @emph{Return value}: -After @code{GETARG} returns, the @var{VALUE} argument holds the -@var{POS}th command line argument. If @var{VALUE} cannot hold the -argument, it is truncated to fit the length of @var{VALUE}. If there are -less than @var{POS} arguments specified at the command line, @var{VALUE} -will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set -to the name of the program (on systems that support this feature). - -@item @emph{Example}: -@smallexample -PROGRAM test_getarg - INTEGER :: i - CHARACTER(len=32) :: arg - - DO i = 1, iargc() - CALL getarg(i, arg) - WRITE (*,*) arg - END DO -END PROGRAM -@end smallexample - -@item @emph{See also}: -GNU Fortran 77 compatibility function: @gol -@ref{IARGC} @gol -Fortran 2003 functions and subroutines: @gol -@ref{GET_COMMAND}, @gol -@ref{GET_COMMAND_ARGUMENT}, @gol -@ref{COMMAND_ARGUMENT_COUNT} -@end table - - - -@node GET_COMMAND -@section @code{GET_COMMAND} --- Get the entire command line -@fnindex GET_COMMAND -@cindex command-line arguments -@cindex arguments, to program - -@table @asis -@item @emph{Description}: -Retrieve the entire command line that was used to invoke the program. - -@item @emph{Standard}: -Fortran 2003 and later - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL GET_COMMAND([COMMAND, LENGTH, STATUS])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{COMMAND} @tab (Optional) shall be of type @code{CHARACTER} and -of default kind. -@item @var{LENGTH} @tab (Optional) Shall be of type @code{INTEGER} and of -default kind. -@item @var{STATUS} @tab (Optional) Shall be of type @code{INTEGER} and of -default kind. -@end multitable - -@item @emph{Return value}: -If @var{COMMAND} is present, stores the entire command line that was used -to invoke the program in @var{COMMAND}. If @var{LENGTH} is present, it is -assigned the length of the command line. If @var{STATUS} is present, it -is assigned 0 upon success of the command, -1 if @var{COMMAND} is too -short to store the command line, or a positive value in case of an error. - -@item @emph{Example}: -@smallexample -PROGRAM test_get_command - CHARACTER(len=255) :: cmd - CALL get_command(cmd) - WRITE (*,*) TRIM(cmd) -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{GET_COMMAND_ARGUMENT}, @gol -@ref{COMMAND_ARGUMENT_COUNT} -@end table - - - -@node GET_COMMAND_ARGUMENT -@section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments -@fnindex GET_COMMAND_ARGUMENT -@cindex command-line arguments -@cindex arguments, to program - -@table @asis -@item @emph{Description}: -Retrieve the @var{NUMBER}-th argument that was passed on the -command line when the containing program was invoked. - -@item @emph{Standard}: -Fortran 2003 and later - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{NUMBER} @tab Shall be a scalar of type @code{INTEGER} and of -default kind, @math{@var{NUMBER} \geq 0} -@item @var{VALUE} @tab (Optional) Shall be a scalar of type @code{CHARACTER} -and of default kind. -@item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER} -and of default kind. -@item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER} -and of default kind. -@end multitable - -@item @emph{Return value}: -After @code{GET_COMMAND_ARGUMENT} returns, the @var{VALUE} argument holds the -@var{NUMBER}-th command line argument. If @var{VALUE} cannot hold the argument, it is -truncated to fit the length of @var{VALUE}. If there are less than @var{NUMBER} -arguments specified at the command line, @var{VALUE} will be filled with blanks. -If @math{@var{NUMBER} = 0}, @var{VALUE} is set to the name of the program (on -systems that support this feature). The @var{LENGTH} argument contains the -length of the @var{NUMBER}-th command line argument. If the argument retrieval -fails, @var{STATUS} is a positive number; if @var{VALUE} contains a truncated -command line argument, @var{STATUS} is -1; and otherwise the @var{STATUS} is -zero. - -@item @emph{Example}: -@smallexample -PROGRAM test_get_command_argument - INTEGER :: i - CHARACTER(len=32) :: arg - - i = 0 - DO - CALL get_command_argument(i, arg) - IF (LEN_TRIM(arg) == 0) EXIT - - WRITE (*,*) TRIM(arg) - i = i+1 - END DO -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{GET_COMMAND}, @gol -@ref{COMMAND_ARGUMENT_COUNT} -@end table - - - -@node GETCWD -@section @code{GETCWD} --- Get current working directory -@fnindex GETCWD -@cindex system, working directory - -@table @asis -@item @emph{Description}: -Get current working directory. - -This intrinsic is provided in both subroutine and function forms; however, -only one form can be used in any given program unit. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL GETCWD(C [, STATUS])} -@item @code{STATUS = GETCWD(C)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{C} @tab The type shall be @code{CHARACTER} and of default kind. -@item @var{STATUS} @tab (Optional) status flag. Returns 0 on success, -a system specific and nonzero error code otherwise. -@end multitable - -@item @emph{Example}: -@smallexample -PROGRAM test_getcwd - CHARACTER(len=255) :: cwd - CALL getcwd(cwd) - WRITE(*,*) TRIM(cwd) -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{CHDIR} -@end table - - - -@node GETENV -@section @code{GETENV} --- Get an environmental variable -@fnindex GETENV -@cindex environment variable - -@table @asis -@item @emph{Description}: -Get the @var{VALUE} of the environmental variable @var{NAME}. - -This intrinsic routine is provided for backwards compatibility with -GNU Fortran 77. In new code, programmers should consider the use of -the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran -2003 standard. - -Note that @code{GETENV} need not be thread-safe. It is the -responsibility of the user to ensure that the environment is not being -updated concurrently with a call to the @code{GETENV} intrinsic. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL GETENV(NAME, VALUE)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{NAME} @tab Shall be of type @code{CHARACTER} and of default kind. -@item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default kind. -@end multitable - -@item @emph{Return value}: -Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is -not large enough to hold the data, it is truncated. If @var{NAME} -is not set, @var{VALUE} will be filled with blanks. - -@item @emph{Example}: -@smallexample -PROGRAM test_getenv - CHARACTER(len=255) :: homedir - CALL getenv("HOME", homedir) - WRITE (*,*) TRIM(homedir) -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{GET_ENVIRONMENT_VARIABLE} -@end table - - - -@node GET_ENVIRONMENT_VARIABLE -@section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable -@fnindex GET_ENVIRONMENT_VARIABLE -@cindex environment variable - -@table @asis -@item @emph{Description}: -Get the @var{VALUE} of the environmental variable @var{NAME}. - -Note that @code{GET_ENVIRONMENT_VARIABLE} need not be thread-safe. It -is the responsibility of the user to ensure that the environment is -not being updated concurrently with a call to the -@code{GET_ENVIRONMENT_VARIABLE} intrinsic. - -@item @emph{Standard}: -Fortran 2003 and later - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{NAME} @tab Shall be a scalar of type @code{CHARACTER} -and of default kind. -@item @var{VALUE} @tab (Optional) Shall be a scalar of type @code{CHARACTER} -and of default kind. -@item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER} -and of default kind. -@item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER} -and of default kind. -@item @var{TRIM_NAME} @tab (Optional) Shall be a scalar of type @code{LOGICAL} -and of default kind. -@end multitable - -@item @emph{Return value}: -Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is -not large enough to hold the data, it is truncated. If @var{NAME} -is not set, @var{VALUE} will be filled with blanks. Argument @var{LENGTH} -contains the length needed for storing the environment variable @var{NAME} -or zero if it is not present. @var{STATUS} is -1 if @var{VALUE} is present -but too short for the environment variable; it is 1 if the environment -variable does not exist and 2 if the processor does not support environment -variables; in all other cases @var{STATUS} is zero. If @var{TRIM_NAME} is -present with the value @code{.FALSE.}, the trailing blanks in @var{NAME} -are significant; otherwise they are not part of the environment variable -name. - -@item @emph{Example}: -@smallexample -PROGRAM test_getenv - CHARACTER(len=255) :: homedir - CALL get_environment_variable("HOME", homedir) - WRITE (*,*) TRIM(homedir) -END PROGRAM -@end smallexample -@end table - - - -@node GETGID -@section @code{GETGID} --- Group ID function -@fnindex GETGID -@cindex system, group ID - -@table @asis -@item @emph{Description}: -Returns the numerical group ID of the current process. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{RESULT = GETGID()} - -@item @emph{Return value}: -The return value of @code{GETGID} is an @code{INTEGER} of the default -kind. - - -@item @emph{Example}: -See @code{GETPID} for an example. - -@item @emph{See also}: -@ref{GETPID}, @gol -@ref{GETUID} -@end table - - - -@node GETLOG -@section @code{GETLOG} --- Get login name -@fnindex GETLOG -@cindex system, login name -@cindex login name - -@table @asis -@item @emph{Description}: -Gets the username under which the program is running. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL GETLOG(C)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{C} @tab Shall be of type @code{CHARACTER} and of default kind. -@end multitable - -@item @emph{Return value}: -Stores the current user name in @var{C}. (On systems where POSIX -functions @code{geteuid} and @code{getpwuid} are not available, and -the @code{getlogin} function is not implemented either, this will -return a blank string.) - -@item @emph{Example}: -@smallexample -PROGRAM TEST_GETLOG - CHARACTER(32) :: login - CALL GETLOG(login) - WRITE(*,*) login -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{GETUID} -@end table - - - -@node GETPID -@section @code{GETPID} --- Process ID function -@fnindex GETPID -@cindex system, process ID -@cindex process ID - -@table @asis -@item @emph{Description}: -Returns the numerical process identifier of the current process. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{RESULT = GETPID()} - -@item @emph{Return value}: -The return value of @code{GETPID} is an @code{INTEGER} of the default -kind. - - -@item @emph{Example}: -@smallexample -program info - print *, "The current process ID is ", getpid() - print *, "Your numerical user ID is ", getuid() - print *, "Your numerical group ID is ", getgid() -end program info -@end smallexample - -@item @emph{See also}: -@ref{GETGID}, @gol -@ref{GETUID} -@end table - - - -@node GETUID -@section @code{GETUID} --- User ID function -@fnindex GETUID -@cindex system, user ID -@cindex user id - -@table @asis -@item @emph{Description}: -Returns the numerical user ID of the current process. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{RESULT = GETUID()} - -@item @emph{Return value}: -The return value of @code{GETUID} is an @code{INTEGER} of the default -kind. - - -@item @emph{Example}: -See @code{GETPID} for an example. - -@item @emph{See also}: -@ref{GETPID}, @gol -@ref{GETLOG} -@end table - - - -@node GMTIME -@section @code{GMTIME} --- Convert time to GMT info -@fnindex GMTIME -@cindex time, conversion to GMT info - -@table @asis -@item @emph{Description}: -Given a system time value @var{TIME} (as provided by the @ref{TIME} -intrinsic), fills @var{VALUES} with values extracted from it appropriate -to the UTC time zone (Universal Coordinated Time, also known in some -countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}. - -This intrinsic routine is provided for backwards compatibility with -GNU Fortran 77. In new code, programmers should consider the use of -the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95 -standard. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL GMTIME(TIME, VALUES)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{TIME} @tab An @code{INTEGER} scalar expression -corresponding to a system time, with @code{INTENT(IN)}. -@item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements, -with @code{INTENT(OUT)}. -@end multitable - -@item @emph{Return value}: -The elements of @var{VALUES} are assigned as follows: -@enumerate -@item Seconds after the minute, range 0--59 or 0--61 to allow for leap -seconds -@item Minutes after the hour, range 0--59 -@item Hours past midnight, range 0--23 -@item Day of month, range 1--31 -@item Number of months since January, range 0--11 -@item Years since 1900 -@item Number of days since Sunday, range 0--6 -@item Days since January 1, range 0--365 -@item Daylight savings indicator: positive if daylight savings is in -effect, zero if not, and negative if the information is not available. -@end enumerate - -@item @emph{See also}: -@ref{DATE_AND_TIME}, @gol -@ref{CTIME}, @gol -@ref{LTIME}, @gol -@ref{TIME}, @gol -@ref{TIME8} -@end table - - - -@node HOSTNM -@section @code{HOSTNM} --- Get system host name -@fnindex HOSTNM -@cindex system, host name - -@table @asis -@item @emph{Description}: -Retrieves the host name of the system on which the program is running. - -This intrinsic is provided in both subroutine and function forms; however, -only one form can be used in any given program unit. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL HOSTNM(C [, STATUS])} -@item @code{STATUS = HOSTNM(NAME)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{C} @tab Shall of type @code{CHARACTER} and of default kind. -@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. -Returns 0 on success, or a system specific error code otherwise. -@end multitable - -@item @emph{Return value}: -In either syntax, @var{NAME} is set to the current hostname if it can -be obtained, or to a blank string otherwise. - -@end table - - - -@node HUGE -@section @code{HUGE} --- Largest number of a kind -@fnindex HUGE -@cindex limits, largest number -@cindex model representation, largest number - -@table @asis -@item @emph{Description}: -@code{HUGE(X)} returns the largest number that is not an infinity in -the model of the type of @code{X}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = HUGE(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of the same type and kind as @var{X} - -@item @emph{Example}: -@smallexample -program test_huge_tiny - print *, huge(0), huge(0.0), huge(0.0d0) - print *, tiny(0.0), tiny(0.0d0) -end program test_huge_tiny -@end smallexample -@end table - - - -@node HYPOT -@section @code{HYPOT} --- Euclidean distance function -@fnindex HYPOT -@cindex Euclidean distance - -@table @asis -@item @emph{Description}: -@code{HYPOT(X,Y)} is the Euclidean distance function. It is equal to -@math{\sqrt{X^2 + Y^2}}, without undue underflow or overflow. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = HYPOT(X, Y)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL}. -@item @var{Y} @tab The type and kind type parameter shall be the same as -@var{X}. -@end multitable - -@item @emph{Return value}: -The return value has the same type and kind type parameter as @var{X}. - -@item @emph{Example}: -@smallexample -program test_hypot - real(4) :: x = 1.e0_4, y = 0.5e0_4 - x = hypot(x,y) -end program test_hypot -@end smallexample -@end table - - - -@node IACHAR -@section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence -@fnindex IACHAR -@cindex @acronym{ASCII} collating sequence -@cindex collating sequence, @acronym{ASCII} -@cindex conversion, to integer - -@table @asis -@item @emph{Description}: -@code{IACHAR(C)} returns the code for the @acronym{ASCII} character -in the first character position of @code{C}. - -@item @emph{Standard}: -Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = IACHAR(C [, KIND])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)} -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of kind @var{KIND}. If -@var{KIND} is absent, the return value is of default integer kind. - -@item @emph{Example}: -@smallexample -program test_iachar - integer i - i = iachar(' ') -end program test_iachar -@end smallexample - -@item @emph{Note}: -See @ref{ICHAR} for a discussion of converting between numerical values -and formatted string representations. - -@item @emph{See also}: -@ref{ACHAR}, @gol -@ref{CHAR}, @gol -@ref{ICHAR} -@end table - - - -@node IALL -@section @code{IALL} --- Bitwise AND of array elements -@fnindex IALL -@cindex array, AND -@cindex bits, AND of array elements - -@table @asis -@item @emph{Description}: -Reduces with bitwise AND the elements of @var{ARRAY} along dimension @var{DIM} -if the corresponding element in @var{MASK} is @code{TRUE}. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = IALL(ARRAY[, MASK])} -@item @code{RESULT = IALL(ARRAY, DIM[, MASK])} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} -@item @var{DIM} @tab (Optional) shall be a scalar of type -@code{INTEGER} with a value in the range from 1 to n, where n -equals the rank of @var{ARRAY}. -@item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL} -and either be a scalar or an array of the same shape as @var{ARRAY}. -@end multitable - -@item @emph{Return value}: -The result is of the same type as @var{ARRAY}. - -If @var{DIM} is absent, a scalar with the bitwise ALL of all elements in -@var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals -the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with -dimension @var{DIM} dropped is returned. - -@item @emph{Example}: -@smallexample -PROGRAM test_iall - INTEGER(1) :: a(2) - - a(1) = b'00100100' - a(2) = b'01101010' - - ! prints 00100000 - PRINT '(b8.8)', IALL(a) -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{IANY}, @gol -@ref{IPARITY}, @gol -@ref{IAND} -@end table - - - -@node IAND -@section @code{IAND} --- Bitwise logical and -@fnindex IAND -@fnindex BIAND -@fnindex IIAND -@fnindex JIAND -@fnindex KIAND -@cindex bitwise logical and -@cindex logical and, bitwise - -@table @asis -@item @emph{Description}: -Bitwise logical @code{AND}. - -@item @emph{Standard}: -Fortran 90 and later, with boz-literal-constant Fortran 2008 and later, has overloads that are GNU extensions - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = IAND(I, J)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant. -@item @var{J} @tab The type shall be @code{INTEGER} with the same -kind type parameter as @var{I} or a boz-literal-constant. -@var{I} and @var{J} shall not both be boz-literal-constants. -@end multitable - -@item @emph{Return value}: -The return type is @code{INTEGER} with the kind type parameter of the -arguments. -A boz-literal-constant is converted to an @code{INTEGER} with the kind -type parameter of the other argument as-if a call to @ref{INT} occurred. - -@item @emph{Example}: -@smallexample -PROGRAM test_iand - INTEGER :: a, b - DATA a / Z'F' /, b / Z'3' / - WRITE (*,*) IAND(a, b) -END PROGRAM -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{IAND(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later -@item @code{BIAND(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension -@item @code{IIAND(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension -@item @code{JIAND(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension -@item @code{KIAND(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -@ref{IOR}, @gol -@ref{IEOR}, @gol -@ref{IBITS}, @gol -@ref{IBSET}, @gol -@ref{IBCLR}, @gol -@ref{NOT} -@end table - - - -@node IANY -@section @code{IANY} --- Bitwise OR of array elements -@fnindex IANY -@cindex array, OR -@cindex bits, OR of array elements - -@table @asis -@item @emph{Description}: -Reduces with bitwise OR (inclusive or) the elements of @var{ARRAY} along -dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = IANY(ARRAY[, MASK])} -@item @code{RESULT = IANY(ARRAY, DIM[, MASK])} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} -@item @var{DIM} @tab (Optional) shall be a scalar of type -@code{INTEGER} with a value in the range from 1 to n, where n -equals the rank of @var{ARRAY}. -@item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL} -and either be a scalar or an array of the same shape as @var{ARRAY}. -@end multitable - -@item @emph{Return value}: -The result is of the same type as @var{ARRAY}. - -If @var{DIM} is absent, a scalar with the bitwise OR of all elements in -@var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals -the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with -dimension @var{DIM} dropped is returned. - -@item @emph{Example}: -@smallexample -PROGRAM test_iany - INTEGER(1) :: a(2) - - a(1) = b'00100100' - a(2) = b'01101010' - - ! prints 01101110 - PRINT '(b8.8)', IANY(a) -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{IPARITY}, @gol -@ref{IALL}, @gol -@ref{IOR} -@end table - - - -@node IARGC -@section @code{IARGC} --- Get the number of command line arguments -@fnindex IARGC -@cindex command-line arguments -@cindex command-line arguments, number of -@cindex arguments, to program - -@table @asis -@item @emph{Description}: -@code{IARGC} returns the number of arguments passed on the -command line when the containing program was invoked. - -This intrinsic routine is provided for backwards compatibility with -GNU Fortran 77. In new code, programmers should consider the use of -the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003 -standard. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{RESULT = IARGC()} - -@item @emph{Arguments}: -None - -@item @emph{Return value}: -The number of command line arguments, type @code{INTEGER(4)}. - -@item @emph{Example}: -See @ref{GETARG} - -@item @emph{See also}: -GNU Fortran 77 compatibility subroutine: @gol -@ref{GETARG} @gol -Fortran 2003 functions and subroutines: @gol -@ref{GET_COMMAND}, @gol -@ref{GET_COMMAND_ARGUMENT}, @gol -@ref{COMMAND_ARGUMENT_COUNT} -@end table - - - -@node IBCLR -@section @code{IBCLR} --- Clear bit -@fnindex IBCLR -@fnindex BBCLR -@fnindex IIBCLR -@fnindex JIBCLR -@fnindex KIBCLR -@cindex bits, unset -@cindex bits, clear - -@table @asis -@item @emph{Description}: -@code{IBCLR} returns the value of @var{I} with the bit at position -@var{POS} set to zero. - -@item @emph{Standard}: -Fortran 90 and later, has overloads that are GNU extensions - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = IBCLR(I, POS)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER}. -@item @var{POS} @tab The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the same kind as -@var{I}. - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{IBCLR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later -@item @code{BBCLR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension -@item @code{IIBCLR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension -@item @code{JIBCLR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension -@item @code{KIBCLR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -@ref{IBITS}, @gol -@ref{IBSET}, @gol -@ref{IAND}, @gol -@ref{IOR}, @gol -@ref{IEOR}, @gol -@ref{MVBITS} -@end table - - - -@node IBITS -@section @code{IBITS} --- Bit extraction -@fnindex IBITS -@fnindex BBITS -@fnindex IIBITS -@fnindex JIBITS -@fnindex KIBITS -@cindex bits, get -@cindex bits, extract - -@table @asis -@item @emph{Description}: -@code{IBITS} extracts a field of length @var{LEN} from @var{I}, -starting from bit position @var{POS} and extending left for @var{LEN} -bits. The result is right-justified and the remaining bits are -zeroed. The value of @code{POS+LEN} must be less than or equal to the -value @code{BIT_SIZE(I)}. - -@item @emph{Standard}: -Fortran 90 and later, has overloads that are GNU extensions - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = IBITS(I, POS, LEN)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER}. -@item @var{POS} @tab The type shall be @code{INTEGER}. -@item @var{LEN} @tab The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the same kind as -@var{I}. - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{IBITS(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later -@item @code{BBITS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension -@item @code{IIBITS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension -@item @code{JIBITS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension -@item @code{KIBITS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -@ref{BIT_SIZE}, @gol -@ref{IBCLR}, @gol -@ref{IBSET}, @gol -@ref{IAND}, @gol -@ref{IOR}, @gol -@ref{IEOR} -@end table - - - -@node IBSET -@section @code{IBSET} --- Set bit -@fnindex IBSET -@fnindex BBSET -@fnindex IIBSET -@fnindex JIBSET -@fnindex KIBSET -@cindex bits, set - -@table @asis -@item @emph{Description}: -@code{IBSET} returns the value of @var{I} with the bit at position -@var{POS} set to one. - -@item @emph{Standard}: -Fortran 90 and later, has overloads that are GNU extensions - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = IBSET(I, POS)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER}. -@item @var{POS} @tab The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the same kind as -@var{I}. - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{IBSET(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later -@item @code{BBSET(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension -@item @code{IIBSET(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension -@item @code{JIBSET(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension -@item @code{KIBSET(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -@ref{IBCLR}, @gol -@ref{IBITS}, @gol -@ref{IAND}, @gol -@ref{IOR}, @gol -@ref{IEOR}, @gol -@ref{MVBITS} -@end table - - - -@node ICHAR -@section @code{ICHAR} --- Character-to-integer conversion function -@fnindex ICHAR -@cindex conversion, to integer - -@table @asis -@item @emph{Description}: -@code{ICHAR(C)} returns the code for the character in the first character -position of @code{C} in the system's native character set. -The correspondence between characters and their codes is not necessarily -the same across different GNU Fortran implementations. - -@item @emph{Standard}: -Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ICHAR(C [, KIND])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)} -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of kind @var{KIND}. If -@var{KIND} is absent, the return value is of default integer kind. - -@item @emph{Example}: -@smallexample -program test_ichar - integer i - i = ichar(' ') -end program test_ichar -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{ICHAR(C)} @tab @code{CHARACTER C} @tab @code{INTEGER(4)} @tab Fortran 77 and later -@end multitable - -@item @emph{Note}: -No intrinsic exists to convert between a numeric value and a formatted -character string representation -- for instance, given the -@code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or -@code{REAL} value with the value 154, or vice versa. Instead, this -functionality is provided by internal-file I/O, as in the following -example: -@smallexample -program read_val - integer value - character(len=10) string, string2 - string = '154' - - ! Convert a string to a numeric value - read (string,'(I10)') value - print *, value - - ! Convert a value to a formatted string - write (string2,'(I10)') value - print *, string2 -end program read_val -@end smallexample - -@item @emph{See also}: -@ref{ACHAR}, @gol -@ref{CHAR}, @gol -@ref{IACHAR} -@end table - - - -@node IDATE -@section @code{IDATE} --- Get current local time subroutine (day/month/year) -@fnindex IDATE -@cindex date, current -@cindex current date - -@table @asis -@item @emph{Description}: -@code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the -current local time. The day (in the range 1-31), month (in the range 1-12), -and year appear in elements 1, 2, and 3 of @var{VALUES}, respectively. -The year has four significant digits. - -This intrinsic routine is provided for backwards compatibility with -GNU Fortran 77. In new code, programmers should consider the use of -the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95 -standard. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL IDATE(VALUES)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} and -the kind shall be the default integer kind. -@end multitable - -@item @emph{Return value}: -Does not return anything. - -@item @emph{Example}: -@smallexample -program test_idate - integer, dimension(3) :: tarray - call idate(tarray) - print *, tarray(1) - print *, tarray(2) - print *, tarray(3) -end program test_idate -@end smallexample - -@item @emph{See also}: -@ref{DATE_AND_TIME} -@end table - - -@node IEOR -@section @code{IEOR} --- Bitwise logical exclusive or -@fnindex IEOR -@fnindex BIEOR -@fnindex IIEOR -@fnindex JIEOR -@fnindex KIEOR -@cindex bitwise logical exclusive or -@cindex logical exclusive or, bitwise - -@table @asis -@item @emph{Description}: -@code{IEOR} returns the bitwise Boolean exclusive-OR of @var{I} and -@var{J}. - -@item @emph{Standard}: -Fortran 90 and later, with boz-literal-constant Fortran 2008 and later, has overloads that are GNU extensions - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = IEOR(I, J)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant. -@item @var{J} @tab The type shall be @code{INTEGER} with the same -kind type parameter as @var{I} or a boz-literal-constant. -@var{I} and @var{J} shall not both be boz-literal-constants. -@end multitable - -@item @emph{Return value}: -The return type is @code{INTEGER} with the kind type parameter of the -arguments. -A boz-literal-constant is converted to an @code{INTEGER} with the kind -type parameter of the other argument as-if a call to @ref{INT} occurred. - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{IEOR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later -@item @code{BIEOR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension -@item @code{IIEOR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension -@item @code{JIEOR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension -@item @code{KIEOR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -@ref{IOR}, @gol -@ref{IAND}, @gol -@ref{IBITS}, @gol -@ref{IBSET}, @gol -@ref{IBCLR}, @gol -@ref{NOT} -@end table - - - -@node IERRNO -@section @code{IERRNO} --- Get the last system error number -@fnindex IERRNO -@cindex system, error handling - -@table @asis -@item @emph{Description}: -Returns the last system error number, as given by the C @code{errno} -variable. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{RESULT = IERRNO()} - -@item @emph{Arguments}: -None - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the default integer -kind. - -@item @emph{See also}: -@ref{PERROR} -@end table - - - -@node IMAGE_INDEX -@section @code{IMAGE_INDEX} --- Function that converts a cosubscript to an image index -@fnindex IMAGE_INDEX -@cindex coarray, @code{IMAGE_INDEX} -@cindex images, cosubscript to image index conversion - -@table @asis -@item @emph{Description}: -Returns the image index belonging to a cosubscript. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Inquiry function. - -@item @emph{Syntax}: -@code{RESULT = IMAGE_INDEX(COARRAY, SUB)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{COARRAY} @tab Coarray of any type. -@item @var{SUB} @tab default integer rank-1 array of a size equal to -the corank of @var{COARRAY}. -@end multitable - - -@item @emph{Return value}: -Scalar default integer with the value of the image index which corresponds -to the cosubscripts. For invalid cosubscripts the result is zero. - -@item @emph{Example}: -@smallexample -INTEGER :: array[2,-1:4,8,*] -! Writes 28 (or 0 if there are fewer than 28 images) -WRITE (*,*) IMAGE_INDEX (array, [2,0,3,1]) -@end smallexample - -@item @emph{See also}: -@ref{THIS_IMAGE}, @gol -@ref{NUM_IMAGES} -@end table - - - -@node INDEX intrinsic -@section @code{INDEX} --- Position of a substring within a string -@fnindex INDEX -@cindex substring position -@cindex string, find substring - -@table @asis -@item @emph{Description}: -Returns the position of the start of the first occurrence of string -@var{SUBSTRING} as a substring in @var{STRING}, counting from one. If -@var{SUBSTRING} is not present in @var{STRING}, zero is returned. If -the @var{BACK} argument is present and true, the return value is the -start of the last occurrence rather than the first. - -@item @emph{Standard}: -Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{STRING} @tab Shall be a scalar @code{CHARACTER}, with -@code{INTENT(IN)} -@item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER}, with -@code{INTENT(IN)} -@item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL}, with -@code{INTENT(IN)} -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of kind @var{KIND}. If -@var{KIND} is absent, the return value is of default integer kind. - -@item @emph{Specific names}: -@multitable @columnfractions .35 .15 .17 .30 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{INDEX(STRING,SUBSTRING)} @tab @code{CHARACTER} @tab @code{INTEGER(4)} @tab Fortran 77 and later -@end multitable - -@item @emph{See also}: -@ref{SCAN}, @gol -@ref{VERIFY} -@end table - - - -@node INT -@section @code{INT} --- Convert to integer type -@fnindex INT -@fnindex IFIX -@fnindex IDINT -@cindex conversion, to integer - -@table @asis -@item @emph{Description}: -Convert to integer type - -@item @emph{Standard}: -Fortran 77 and later, with boz-literal-constant Fortran 2008 and later. - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = INT(A [, KIND))} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab Shall be of type @code{INTEGER}, -@code{REAL}, or @code{COMPLEX} or a boz-literal-constant. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -These functions return a @code{INTEGER} variable or array under -the following rules: - -@table @asis -@item (A) -If @var{A} is of type @code{INTEGER}, @code{INT(A) = A} -@item (B) -If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)} -equals @code{0}. If @math{|A| \geq 1}, then @code{INT(A)} is the integer -whose magnitude is the largest integer that does not exceed the magnitude -of @var{A} and whose sign is the same as the sign of @var{A}. -@item (C) -If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}. -@end table - -@item @emph{Example}: -@smallexample -program test_int - integer :: i = 42 - complex :: z = (-3.7, 1.0) - print *, int(i) - print *, int(z), int(z,8) -end program -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{INT(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later -@item @code{IFIX(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later -@item @code{IDINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab Fortran 77 and later -@end multitable - -@end table - - -@node INT2 -@section @code{INT2} --- Convert to 16-bit integer type -@fnindex INT2 -@cindex conversion, to integer - -@table @asis -@item @emph{Description}: -Convert to a @code{KIND=2} integer type. This is equivalent to the -standard @code{INT} intrinsic with an optional argument of -@code{KIND=2}, and is only included for backwards compatibility. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = INT2(A)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab Shall be of type @code{INTEGER}, -@code{REAL}, or @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value is a @code{INTEGER(2)} variable. - -@item @emph{See also}: -@ref{INT}, @gol -@ref{INT8} -@end table - - - -@node INT8 -@section @code{INT8} --- Convert to 64-bit integer type -@fnindex INT8 -@cindex conversion, to integer - -@table @asis -@item @emph{Description}: -Convert to a @code{KIND=8} integer type. This is equivalent to the -standard @code{INT} intrinsic with an optional argument of -@code{KIND=8}, and is only included for backwards compatibility. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = INT8(A)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab Shall be of type @code{INTEGER}, -@code{REAL}, or @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value is a @code{INTEGER(8)} variable. - -@item @emph{See also}: -@ref{INT}, @gol -@ref{INT2} -@end table - - - -@node IOR -@section @code{IOR} --- Bitwise logical or -@fnindex IOR -@fnindex BIOR -@fnindex IIOR -@fnindex JIOR -@fnindex KIOR -@cindex bitwise logical or -@cindex logical or, bitwise - -@table @asis -@item @emph{Description}: -@code{IOR} returns the bitwise Boolean inclusive-OR of @var{I} and -@var{J}. - -@item @emph{Standard}: -Fortran 90 and later, with boz-literal-constant Fortran 2008 and later, has overloads that are GNU extensions - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = IOR(I, J)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant. -@item @var{J} @tab The type shall be @code{INTEGER} with the same -kind type parameter as @var{I} or a boz-literal-constant. -@var{I} and @var{J} shall not both be boz-literal-constants. -@end multitable - -@item @emph{Return value}: -The return type is @code{INTEGER} with the kind type parameter of the -arguments. -A boz-literal-constant is converted to an @code{INTEGER} with the kind -type parameter of the other argument as-if a call to @ref{INT} occurred. - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{IOR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later -@item @code{BIOR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension -@item @code{IIOR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension -@item @code{JIOR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension -@item @code{KIOR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -@ref{IEOR}, @gol -@ref{IAND}, @gol -@ref{IBITS}, @gol -@ref{IBSET}, @gol -@ref{IBCLR}, @gol -@ref{NOT} -@end table - - - -@node IPARITY -@section @code{IPARITY} --- Bitwise XOR of array elements -@fnindex IPARITY -@cindex array, parity -@cindex array, XOR -@cindex bits, XOR of array elements - -@table @asis -@item @emph{Description}: -Reduces with bitwise XOR (exclusive or) the elements of @var{ARRAY} along -dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = IPARITY(ARRAY[, MASK])} -@item @code{RESULT = IPARITY(ARRAY, DIM[, MASK])} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} -@item @var{DIM} @tab (Optional) shall be a scalar of type -@code{INTEGER} with a value in the range from 1 to n, where n -equals the rank of @var{ARRAY}. -@item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL} -and either be a scalar or an array of the same shape as @var{ARRAY}. -@end multitable - -@item @emph{Return value}: -The result is of the same type as @var{ARRAY}. - -If @var{DIM} is absent, a scalar with the bitwise XOR of all elements in -@var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals -the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with -dimension @var{DIM} dropped is returned. - -@item @emph{Example}: -@smallexample -PROGRAM test_iparity - INTEGER(1) :: a(2) - - a(1) = int(b'00100100', 1) - a(2) = int(b'01101010', 1) - - ! prints 01001110 - PRINT '(b8.8)', IPARITY(a) -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{IANY}, @gol -@ref{IALL}, @gol -@ref{IEOR}, @gol -@ref{PARITY} -@end table - - - -@node IRAND -@section @code{IRAND} --- Integer pseudo-random number -@fnindex IRAND -@cindex random number generation - -@table @asis -@item @emph{Description}: -@code{IRAND(FLAG)} returns a pseudo-random number from a uniform -distribution between 0 and a system-dependent limit (which is in most -cases 2147483647). If @var{FLAG} is 0, the next number -in the current sequence is returned; if @var{FLAG} is 1, the generator -is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value, -it is used as a new seed with @code{SRAND}. - -This intrinsic routine is provided for backwards compatibility with -GNU Fortran 77. It implements a simple modulo generator as provided -by @command{g77}. For new code, one should consider the use of -@ref{RANDOM_NUMBER} as it implements a superior algorithm. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{RESULT = IRAND(I)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4. -@end multitable - -@item @emph{Return value}: -The return value is of @code{INTEGER(kind=4)} type. - -@item @emph{Example}: -@smallexample -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 -@end smallexample - -@end table - - - -@node IS_CONTIGUOUS -@section @code{IS_CONTIGUOUS} --- Test whether an array is contiguous -@fnindex IS_IOSTAT_EOR -@cindex array, contiguity - -@table @asis -@item @emph{Description}: -@code{IS_CONTIGUOUS} tests whether an array is contiguous. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = IS_CONTIGUOUS(ARRAY)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an array of any type. -@end multitable - -@item @emph{Return value}: -Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if -@var{ARRAY} is contiguous and false otherwise. - -@item @emph{Example}: -@smallexample -program test - integer :: a(10) - a = [1,2,3,4,5,6,7,8,9,10] - call sub (a) ! every element, is contiguous - call sub (a(::2)) ! every other element, is noncontiguous -contains - subroutine sub (x) - integer :: x(:) - if (is_contiguous (x)) then - write (*,*) 'X is contiguous' - else - write (*,*) 'X is not contiguous' - end if - end subroutine sub -end program test -@end smallexample -@end table - - - -@node IS_IOSTAT_END -@section @code{IS_IOSTAT_END} --- Test for end-of-file value -@fnindex IS_IOSTAT_END -@cindex @code{IOSTAT}, end of file - -@table @asis -@item @emph{Description}: -@code{IS_IOSTAT_END} tests whether an variable has the value of the I/O -status ``end of file''. The function is equivalent to comparing the variable -with the @code{IOSTAT_END} parameter of the intrinsic module -@code{ISO_FORTRAN_ENV}. - -@item @emph{Standard}: -Fortran 2003 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = IS_IOSTAT_END(I)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab Shall be of the type @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if -@var{I} has the value which indicates an end of file condition for -@code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise. - -@item @emph{Example}: -@smallexample -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 -@end smallexample -@end table - - - -@node IS_IOSTAT_EOR -@section @code{IS_IOSTAT_EOR} --- Test for end-of-record value -@fnindex IS_IOSTAT_EOR -@cindex @code{IOSTAT}, end of record - -@table @asis -@item @emph{Description}: -@code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O -status ``end of record''. The function is equivalent to comparing the -variable with the @code{IOSTAT_EOR} parameter of the intrinsic module -@code{ISO_FORTRAN_ENV}. - -@item @emph{Standard}: -Fortran 2003 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = IS_IOSTAT_EOR(I)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab Shall be of the type @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if -@var{I} has the value which indicates an end of file condition for -@code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise. - -@item @emph{Example}: -@smallexample -PROGRAM iostat - IMPLICIT NONE - INTEGER :: stat, i(50) - OPEN(88, FILE='test.dat', FORM='UNFORMATTED') - READ(88, IOSTAT=stat) i - IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD' -END PROGRAM -@end smallexample -@end table - - -@node ISATTY -@section @code{ISATTY} --- Whether a unit is a terminal device -@fnindex ISATTY -@cindex system, terminal - -@table @asis -@item @emph{Description}: -Determine whether a unit is connected to a terminal device. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{RESULT = ISATTY(UNIT)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{UNIT} @tab Shall be a scalar @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal -device, @code{.FALSE.} otherwise. - -@item @emph{Example}: -@smallexample -PROGRAM test_isatty - INTEGER(kind=1) :: unit - DO unit = 1, 10 - write(*,*) isatty(unit=unit) - END DO -END PROGRAM -@end smallexample -@item @emph{See also}: -@ref{TTYNAM} -@end table - - - -@node ISHFT -@section @code{ISHFT} --- Shift bits -@fnindex ISHFT -@fnindex BSHFT -@fnindex IISHFT -@fnindex JISHFT -@fnindex KISHFT -@cindex bits, shift - -@table @asis -@item @emph{Description}: -@code{ISHFT} returns a value corresponding to @var{I} with all of the -bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than -zero corresponds to a left shift, a value of zero corresponds to no -shift, and a value less than zero corresponds to a right shift. If the -absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the -value is undefined. Bits shifted out from the left end or right end are -lost; zeros are shifted in from the opposite end. - -@item @emph{Standard}: -Fortran 90 and later, has overloads that are GNU extensions - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ISHFT(I, SHIFT)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER}. -@item @var{SHIFT} @tab The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the same kind as -@var{I}. - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{ISHFT(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later -@item @code{BSHFT(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension -@item @code{IISHFT(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension -@item @code{JISHFT(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension -@item @code{KISHFT(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -@ref{ISHFTC} -@end table - - - -@node ISHFTC -@section @code{ISHFTC} --- Shift bits circularly -@fnindex ISHFTC -@fnindex BSHFTC -@fnindex IISHFTC -@fnindex JISHFTC -@fnindex KISHFTC -@cindex bits, shift circular - -@table @asis -@item @emph{Description}: -@code{ISHFTC} returns a value corresponding to @var{I} with the -rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that -is, bits shifted out one end are shifted into the opposite end. A value -of @var{SHIFT} greater than zero corresponds to a left shift, a value of -zero corresponds to no shift, and a value less than zero corresponds to -a right shift. The absolute value of @var{SHIFT} must be less than -@var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be -equivalent to @code{BIT_SIZE(I)}. - -@item @emph{Standard}: -Fortran 90 and later, has overloads that are GNU extensions - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = ISHFTC(I, SHIFT [, SIZE])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER}. -@item @var{SHIFT} @tab The type shall be @code{INTEGER}. -@item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER}; -the value must be greater than zero and less than or equal to -@code{BIT_SIZE(I)}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the same kind as -@var{I}. - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{ISHFTC(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later -@item @code{BSHFTC(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension -@item @code{IISHFTC(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension -@item @code{JISHFTC(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension -@item @code{KISHFTC(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -@ref{ISHFT} -@end table - - - -@node ISNAN -@section @code{ISNAN} --- Test for a NaN -@fnindex ISNAN -@cindex IEEE, ISNAN - -@table @asis -@item @emph{Description}: -@code{ISNAN} tests whether a floating-point value is an IEEE -Not-a-Number (NaN). -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{ISNAN(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab Variable of the type @code{REAL}. - -@end multitable - -@item @emph{Return value}: -Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE} -if @var{X} is a NaN and @code{FALSE} otherwise. - -@item @emph{Example}: -@smallexample -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 -@end smallexample -@end table - - - -@node ITIME -@section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds) -@fnindex ITIME -@cindex time, current -@cindex current time - -@table @asis -@item @emph{Description}: -@code{ITIME(VALUES)} Fills @var{VALUES} with the numerical values at the -current local time. The hour (in the range 1-24), minute (in the range 1-60), -and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{VALUES}, -respectively. - -This intrinsic routine is provided for backwards compatibility with -GNU Fortran 77. In new code, programmers should consider the use of -the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95 -standard. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL ITIME(VALUES)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} -and the kind shall be the default integer kind. -@end multitable - -@item @emph{Return value}: -Does not return anything. - - -@item @emph{Example}: -@smallexample -program test_itime - integer, dimension(3) :: tarray - call itime(tarray) - print *, tarray(1) - print *, tarray(2) - print *, tarray(3) -end program test_itime -@end smallexample - -@item @emph{See also}: -@ref{DATE_AND_TIME} -@end table - - - -@node KILL -@section @code{KILL} --- Send a signal to a process -@fnindex KILL - -@table @asis -@item @emph{Description}: -Sends the signal specified by @var{SIG} to the process @var{PID}. -See @code{kill(2)}. - -This intrinsic is provided in both subroutine and function forms; -however, only one form can be used in any given program unit. -@item @emph{Standard}: -GNU extension - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL KILL(PID, SIG [, STATUS])} -@item @code{STATUS = KILL(PID, SIG)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{PID} @tab Shall be a scalar @code{INTEGER} with @code{INTENT(IN)}. -@item @var{SIG} @tab Shall be a scalar @code{INTEGER} with @code{INTENT(IN)}. -@item @var{STATUS} @tab [Subroutine](Optional) -Shall be a scalar @code{INTEGER}. -Returns 0 on success; otherwise a system-specific error code is returned. -@item @var{STATUS} @tab [Function] The kind type parameter is that of -@code{pid}. -Returns 0 on success; otherwise a system-specific error code is returned. -@end multitable - -@item @emph{See also}: -@ref{ABORT}, @gol -@ref{EXIT} -@end table - - -@node KIND -@section @code{KIND} --- Kind of an entity -@fnindex KIND -@cindex kind - -@table @asis -@item @emph{Description}: -@code{KIND(X)} returns the kind value of the entity @var{X}. - -@item @emph{Standard}: -Fortran 95 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{K = KIND(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER}, -@code{REAL}, @code{COMPLEX} or @code{CHARACTER}. It may be scalar or -array valued. -@end multitable - -@item @emph{Return value}: -The return value is a scalar of type @code{INTEGER} and of the default -integer kind. - -@item @emph{Example}: -@smallexample -program test_kind - integer,parameter :: kc = kind(' ') - integer,parameter :: kl = kind(.true.) - - print *, "The default character kind is ", kc - print *, "The default logical kind is ", kl -end program test_kind -@end smallexample - -@end table - - - -@node LBOUND -@section @code{LBOUND} --- Lower dimension bounds of an array -@fnindex LBOUND -@cindex array, lower bound - -@table @asis -@item @emph{Description}: -Returns the lower bounds of an array, or a single lower bound -along the @var{DIM} dimension. -@item @emph{Standard}: -Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an array, of any type. -@item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of kind @var{KIND}. If -@var{KIND} is absent, the return value is of default integer kind. -If @var{DIM} is absent, the result is an array of the lower bounds of -@var{ARRAY}. If @var{DIM} is present, the result is a scalar -corresponding to the lower bound of the array along that dimension. If -@var{ARRAY} is an expression rather than a whole array or array -structure component, or if it has a zero extent along the relevant -dimension, the lower bound is taken to be 1. - -@item @emph{See also}: -@ref{UBOUND}, @gol -@ref{LCOBOUND} -@end table - - - -@node LCOBOUND -@section @code{LCOBOUND} --- Lower codimension bounds of an array -@fnindex LCOBOUND -@cindex coarray, lower bound - -@table @asis -@item @emph{Description}: -Returns the lower bounds of a coarray, or a single lower cobound -along the @var{DIM} codimension. -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = LCOBOUND(COARRAY [, DIM [, KIND]])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an coarray, of any type. -@item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of kind @var{KIND}. If -@var{KIND} is absent, the return value is of default integer kind. -If @var{DIM} is absent, the result is an array of the lower cobounds of -@var{COARRAY}. If @var{DIM} is present, the result is a scalar -corresponding to the lower cobound of the array along that codimension. - -@item @emph{See also}: -@ref{UCOBOUND}, @gol -@ref{LBOUND} -@end table - - - -@node LEADZ -@section @code{LEADZ} --- Number of leading zero bits of an integer -@fnindex LEADZ -@cindex zero bits - -@table @asis -@item @emph{Description}: -@code{LEADZ} returns the number of leading zero bits of an integer. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = LEADZ(I)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab Shall be of type @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The type of the return value is the default @code{INTEGER}. -If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}. - -@item @emph{Example}: -@smallexample -PROGRAM test_leadz - WRITE (*,*) BIT_SIZE(1) ! prints 32 - WRITE (*,*) LEADZ(1) ! prints 31 -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{BIT_SIZE}, @gol -@ref{TRAILZ}, @gol -@ref{POPCNT}, @gol -@ref{POPPAR} -@end table - - - -@node LEN -@section @code{LEN} --- Length of a character entity -@fnindex LEN -@cindex string, length - -@table @asis -@item @emph{Description}: -Returns the length of a character string. If @var{STRING} is an array, -the length of an element of @var{STRING} is returned. Note that -@var{STRING} need not be defined when this intrinsic is invoked, since -only the length, not the content, of @var{STRING} is needed. - -@item @emph{Standard}: -Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{L = LEN(STRING [, KIND])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{STRING} @tab Shall be a scalar or array of type -@code{CHARACTER}, with @code{INTENT(IN)} -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of kind @var{KIND}. If -@var{KIND} is absent, the return value is of default integer kind. - - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{LEN(STRING)} @tab @code{CHARACTER} @tab @code{INTEGER} @tab Fortran 77 and later -@end multitable - - -@item @emph{See also}: -@ref{LEN_TRIM}, @gol -@ref{ADJUSTL}, @gol -@ref{ADJUSTR} -@end table - - - -@node LEN_TRIM -@section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters -@fnindex LEN_TRIM -@cindex string, length, without trailing whitespace - -@table @asis -@item @emph{Description}: -Returns the length of a character string, ignoring any trailing blanks. - -@item @emph{Standard}: -Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = LEN_TRIM(STRING [, KIND])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}, -with @code{INTENT(IN)} -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of kind @var{KIND}. If -@var{KIND} is absent, the return value is of default integer kind. - -@item @emph{See also}: -@ref{LEN}, @gol -@ref{ADJUSTL}, @gol -@ref{ADJUSTR} -@end table - - - -@node LGE -@section @code{LGE} --- Lexical greater than or equal -@fnindex LGE -@cindex lexical comparison of strings -@cindex string, comparison - -@table @asis -@item @emph{Description}: -Determines whether one string is lexically greater than or equal to -another string, where the two strings are interpreted as containing -ASCII character codes. If the String A and String B are not the same -length, the shorter is compared as if spaces were appended to it to form -a value that has the same length as the longer. - -In general, the lexical comparison intrinsics @code{LGE}, @code{LGT}, -@code{LLE}, and @code{LLT} differ from the corresponding intrinsic -operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in -that the latter use the processor's character ordering (which is not -ASCII on some targets), whereas the former always use the ASCII -ordering. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = LGE(STRING_A, STRING_B)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type. -@item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type. -@end multitable - -@item @emph{Return value}: -Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.} -otherwise, based on the ASCII ordering. - -@item @emph{Specific names}: -@multitable @columnfractions .34 .16 .17 .30 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{LGE(STRING_A,STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later -@end multitable - -@item @emph{See also}: -@ref{LGT}, @gol -@ref{LLE}, @gol -@ref{LLT} -@end table - - - -@node LGT -@section @code{LGT} --- Lexical greater than -@fnindex LGT -@cindex lexical comparison of strings -@cindex string, comparison - -@table @asis -@item @emph{Description}: -Determines whether one string is lexically greater than another string, -where the two strings are interpreted as containing ASCII character -codes. If the String A and String B are not the same length, the -shorter is compared as if spaces were appended to it to form a value -that has the same length as the longer. - -In general, the lexical comparison intrinsics @code{LGE}, @code{LGT}, -@code{LLE}, and @code{LLT} differ from the corresponding intrinsic -operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in -that the latter use the processor's character ordering (which is not -ASCII on some targets), whereas the former always use the ASCII -ordering. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = LGT(STRING_A, STRING_B)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type. -@item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type. -@end multitable - -@item @emph{Return value}: -Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.} -otherwise, based on the ASCII ordering. - -@item @emph{Specific names}: -@multitable @columnfractions .34 .16 .17 .30 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{LGT(STRING_A,STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later -@end multitable - -@item @emph{See also}: -@ref{LGE}, @gol -@ref{LLE}, @gol -@ref{LLT} -@end table - - - -@node LINK -@section @code{LINK} --- Create a hard link -@fnindex LINK -@cindex file system, create link -@cindex file system, hard link - -@table @asis -@item @emph{Description}: -Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null -character (@code{CHAR(0)}) can be used to mark the end of the names in -@var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file -names are ignored. If the @var{STATUS} argument is supplied, it -contains 0 on success or a nonzero error code upon return; see -@code{link(2)}. - -This intrinsic is provided in both subroutine and function forms; -however, only one form can be used in any given program unit. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL LINK(PATH1, PATH2 [, STATUS])} -@item @code{STATUS = LINK(PATH1, PATH2)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{PATH1} @tab Shall be of default @code{CHARACTER} type. -@item @var{PATH2} @tab Shall be of default @code{CHARACTER} type. -@item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type. -@end multitable - -@item @emph{See also}: -@ref{SYMLNK}, @gol -@ref{UNLINK} -@end table - - - -@node LLE -@section @code{LLE} --- Lexical less than or equal -@fnindex LLE -@cindex lexical comparison of strings -@cindex string, comparison - -@table @asis -@item @emph{Description}: -Determines whether one string is lexically less than or equal to another -string, where the two strings are interpreted as containing ASCII -character codes. If the String A and String B are not the same length, -the shorter is compared as if spaces were appended to it to form a value -that has the same length as the longer. - -In general, the lexical comparison intrinsics @code{LGE}, @code{LGT}, -@code{LLE}, and @code{LLT} differ from the corresponding intrinsic -operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in -that the latter use the processor's character ordering (which is not -ASCII on some targets), whereas the former always use the ASCII -ordering. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = LLE(STRING_A, STRING_B)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type. -@item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type. -@end multitable - -@item @emph{Return value}: -Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.} -otherwise, based on the ASCII ordering. - -@item @emph{Specific names}: -@multitable @columnfractions .34 .16 .17 .30 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{LLE(STRING_A,STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later -@end multitable - -@item @emph{See also}: -@ref{LGE}, @gol -@ref{LGT}, @gol -@ref{LLT} -@end table - - - -@node LLT -@section @code{LLT} --- Lexical less than -@fnindex LLT -@cindex lexical comparison of strings -@cindex string, comparison - -@table @asis -@item @emph{Description}: -Determines whether one string is lexically less than another string, -where the two strings are interpreted as containing ASCII character -codes. If the String A and String B are not the same length, the -shorter is compared as if spaces were appended to it to form a value -that has the same length as the longer. - -In general, the lexical comparison intrinsics @code{LGE}, @code{LGT}, -@code{LLE}, and @code{LLT} differ from the corresponding intrinsic -operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in -that the latter use the processor's character ordering (which is not -ASCII on some targets), whereas the former always use the ASCII -ordering. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = LLT(STRING_A, STRING_B)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type. -@item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type. -@end multitable - -@item @emph{Return value}: -Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.} -otherwise, based on the ASCII ordering. - -@item @emph{Specific names}: -@multitable @columnfractions .34 .16 .17 .30 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{LLT(STRING_A,STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later -@end multitable - -@item @emph{See also}: -@ref{LGE}, @gol -@ref{LGT}, @gol -@ref{LLE} -@end table - - - -@node LNBLNK -@section @code{LNBLNK} --- Index of the last non-blank character in a string -@fnindex LNBLNK -@cindex string, find non-blank character - -@table @asis -@item @emph{Description}: -Returns the length of a character string, ignoring any trailing blanks. -This is identical to the standard @code{LEN_TRIM} intrinsic, and is only -included for backwards compatibility. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = LNBLNK(STRING)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}, -with @code{INTENT(IN)} -@end multitable - -@item @emph{Return value}: -The return value is of @code{INTEGER(kind=4)} type. - -@item @emph{See also}: -@ref{INDEX intrinsic}, @gol -@ref{LEN_TRIM} -@end table - - - -@node LOC -@section @code{LOC} --- Returns the address of a variable -@fnindex LOC -@cindex location of a variable in memory - -@table @asis -@item @emph{Description}: -@code{LOC(X)} returns the address of @var{X} as an integer. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = LOC(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab Variable of any type. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER}, with a @code{KIND} -corresponding to the size (in bytes) of a memory address on the target -machine. - -@item @emph{Example}: -@smallexample -program test_loc - integer :: i - real :: r - i = loc(r) - print *, i -end program test_loc -@end smallexample -@end table - - - -@node LOG -@section @code{LOG} --- Natural logarithm function -@fnindex LOG -@fnindex ALOG -@fnindex DLOG -@fnindex CLOG -@fnindex ZLOG -@fnindex CDLOG -@cindex exponential function, inverse -@cindex logarithm function -@cindex natural logarithm function - -@table @asis -@item @emph{Description}: -@code{LOG(X)} computes the natural logarithm of @var{X}, i.e. the -logarithm to the base @math{e}. - -@item @emph{Standard}: -Fortran 77 and later, has GNU extensions - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = LOG(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or -@code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{REAL} or @code{COMPLEX}. -The kind type parameter is the same as @var{X}. -If @var{X} is @code{COMPLEX}, the imaginary part @math{\omega} is in the range -@math{-\pi < \omega \leq \pi}. - -@item @emph{Example}: -@smallexample -program test_log - real(8) :: x = 2.7182818284590451_8 - complex :: z = (1.0, 2.0) - x = log(x) ! will yield (approximately) 1 - z = log(z) -end program test_log -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 or later -@item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 or later -@item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 or later -@item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension -@item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension -@end multitable -@end table - - - -@node LOG10 -@section @code{LOG10} --- Base 10 logarithm function -@fnindex LOG10 -@fnindex ALOG10 -@fnindex DLOG10 -@cindex exponential function, inverse -@cindex logarithm function with base 10 -@cindex base 10 logarithm function - -@table @asis -@item @emph{Description}: -@code{LOG10(X)} computes the base 10 logarithm of @var{X}. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = LOG10(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{REAL} or @code{COMPLEX}. -The kind type parameter is the same as @var{X}. - -@item @emph{Example}: -@smallexample -program test_log10 - real(8) :: x = 10.0_8 - x = log10(x) -end program test_log10 -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later -@end multitable -@end table - - - -@node LOG_GAMMA -@section @code{LOG_GAMMA} --- Logarithm of the Gamma function -@fnindex LOG_GAMMA -@fnindex LGAMMA -@fnindex ALGAMA -@fnindex DLGAMA -@cindex Gamma function, logarithm of - -@table @asis -@item @emph{Description}: -@code{LOG_GAMMA(X)} computes the natural logarithm of the absolute value -of the Gamma (@math{\Gamma}) function. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{X = LOG_GAMMA(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab Shall be of type @code{REAL} and neither zero -nor a negative integer. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{REAL} of the same kind as @var{X}. - -@item @emph{Example}: -@smallexample -program test_log_gamma - real :: x = 1.0 - x = lgamma(x) ! returns 0.0 -end program test_log_gamma -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension -@item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension -@item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -Gamma function: @gol -@ref{GAMMA} -@end table - - - -@node LOGICAL -@section @code{LOGICAL} --- Convert to logical type -@fnindex LOGICAL -@cindex conversion, to logical - -@table @asis -@item @emph{Description}: -Converts one kind of @code{LOGICAL} variable to another. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = LOGICAL(L [, KIND])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{L} @tab The type shall be @code{LOGICAL}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is a @code{LOGICAL} value equal to @var{L}, with a -kind corresponding to @var{KIND}, or of the default logical kind if -@var{KIND} is not given. - -@item @emph{See also}: -@ref{INT}, @gol -@ref{REAL}, @gol -@ref{CMPLX} -@end table - - - -@node LSHIFT -@section @code{LSHIFT} --- Left shift bits -@fnindex LSHIFT -@cindex bits, shift left - -@table @asis -@item @emph{Description}: -@code{LSHIFT} returns a value corresponding to @var{I} with all of the -bits shifted left by @var{SHIFT} places. @var{SHIFT} shall be -nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise -the result value is undefined. Bits shifted out from the left end are -lost; zeros are shifted in from the opposite end. - -This function has been superseded by the @code{ISHFT} intrinsic, which -is standard in Fortran 95 and later, and the @code{SHIFTL} intrinsic, -which is standard in Fortran 2008 and later. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = LSHIFT(I, SHIFT)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER}. -@item @var{SHIFT} @tab The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the same kind as -@var{I}. - -@item @emph{See also}: -@ref{ISHFT}, @gol -@ref{ISHFTC}, @gol -@ref{RSHIFT}, @gol -@ref{SHIFTA}, @gol -@ref{SHIFTL}, @gol -@ref{SHIFTR} -@end table - - - -@node LSTAT -@section @code{LSTAT} --- Get file status -@fnindex LSTAT -@cindex file system, file status - -@table @asis -@item @emph{Description}: -@code{LSTAT} is identical to @ref{STAT}, except that if path is a -symbolic link, then the link itself is statted, not the file that it -refers to. - -The elements in @code{VALUES} are the same as described by @ref{STAT}. - -This intrinsic is provided in both subroutine and function forms; -however, only one form can be used in any given program unit. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL LSTAT(NAME, VALUES [, STATUS])} -@item @code{STATUS = LSTAT(NAME, VALUES)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{NAME} @tab The type shall be @code{CHARACTER} of the default -kind, a valid path within the file system. -@item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}. -@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. -Returns 0 on success and a system specific error code otherwise. -@end multitable - -@item @emph{Example}: -See @ref{STAT} for an example. - -@item @emph{See also}: -To stat an open file: @gol -@ref{FSTAT} @gol -To stat a file: @gol -@ref{STAT} -@end table - - - -@node LTIME -@section @code{LTIME} --- Convert time to local time info -@fnindex LTIME -@cindex time, conversion to local time info - -@table @asis -@item @emph{Description}: -Given a system time value @var{TIME} (as provided by the @ref{TIME} -intrinsic), fills @var{VALUES} with values extracted from it appropriate -to the local time zone using @code{localtime(3)}. - -This intrinsic routine is provided for backwards compatibility with -GNU Fortran 77. In new code, programmers should consider the use of -the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95 -standard. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL LTIME(TIME, VALUES)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{TIME} @tab An @code{INTEGER} scalar expression -corresponding to a system time, with @code{INTENT(IN)}. -@item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements, -with @code{INTENT(OUT)}. -@end multitable - -@item @emph{Return value}: -The elements of @var{VALUES} are assigned as follows: -@enumerate -@item Seconds after the minute, range 0--59 or 0--61 to allow for leap -seconds -@item Minutes after the hour, range 0--59 -@item Hours past midnight, range 0--23 -@item Day of month, range 1--31 -@item Number of months since January, range 0--11 -@item Years since 1900 -@item Number of days since Sunday, range 0--6 -@item Days since January 1, range 0--365 -@item Daylight savings indicator: positive if daylight savings is in -effect, zero if not, and negative if the information is not available. -@end enumerate - -@item @emph{See also}: -@ref{DATE_AND_TIME}, @gol -@ref{CTIME}, @gol -@ref{GMTIME}, @gol -@ref{TIME}, @gol -@ref{TIME8} -@end table - - - -@node MALLOC -@section @code{MALLOC} --- Allocate dynamic memory -@fnindex MALLOC -@cindex pointer, cray - -@table @asis -@item @emph{Description}: -@code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and -returns the address of the allocated memory. The @code{MALLOC} intrinsic -is an extension intended to be used with Cray pointers, and is provided -in GNU Fortran to allow the user to compile legacy code. For new code -using Fortran 95 pointers, the memory allocation intrinsic is -@code{ALLOCATE}. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{PTR = MALLOC(SIZE)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{SIZE} @tab The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER(K)}, with @var{K} such that -variables of type @code{INTEGER(K)} have the same size as -C pointers (@code{sizeof(void *)}). - -@item @emph{Example}: -The following example demonstrates the use of @code{MALLOC} and -@code{FREE} with Cray pointers. - -@smallexample -program test_malloc - implicit none - integer i - real*8 x(*), z - pointer(ptr_x,x) - - 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 -@end smallexample - -@item @emph{See also}: -@ref{FREE} -@end table - - - -@node MASKL -@section @code{MASKL} --- Left justified mask -@fnindex MASKL -@cindex mask, left justified - -@table @asis -@item @emph{Description}: -@code{MASKL(I[, KIND])} has its leftmost @var{I} bits set to 1, and the -remaining bits set to 0. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = MASKL(I[, KIND])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab Shall be of type @code{INTEGER}. -@item @var{KIND} @tab Shall be a scalar constant expression of type -@code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER}. If @var{KIND} is present, it -specifies the kind value of the return type; otherwise, it is of the -default integer kind. - -@item @emph{See also}: -@ref{MASKR} -@end table - - - -@node MASKR -@section @code{MASKR} --- Right justified mask -@fnindex MASKR -@cindex mask, right justified - -@table @asis -@item @emph{Description}: -@code{MASKL(I[, KIND])} has its rightmost @var{I} bits set to 1, and the -remaining bits set to 0. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = MASKR(I[, KIND])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab Shall be of type @code{INTEGER}. -@item @var{KIND} @tab Shall be a scalar constant expression of type -@code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER}. If @var{KIND} is present, it -specifies the kind value of the return type; otherwise, it is of the -default integer kind. - -@item @emph{See also}: -@ref{MASKL} -@end table - - - -@node MATMUL -@section @code{MATMUL} --- matrix multiplication -@fnindex MATMUL -@cindex matrix multiplication -@cindex product, matrix - -@table @asis -@item @emph{Description}: -Performs a matrix multiplication on numeric or logical arguments. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = MATMUL(MATRIX_A, MATRIX_B)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{MATRIX_A} @tab An array of @code{INTEGER}, -@code{REAL}, @code{COMPLEX}, or @code{LOGICAL} type, with a rank of -one or two. -@item @var{MATRIX_B} @tab An array of @code{INTEGER}, -@code{REAL}, or @code{COMPLEX} type if @var{MATRIX_A} is of a numeric -type; otherwise, an array of @code{LOGICAL} type. The rank shall be one -or two, and the first (or only) dimension of @var{MATRIX_B} shall be -equal to the last (or only) dimension of @var{MATRIX_A}. -@var{MATRIX_A} and @var{MATRIX_B} shall not both be rank one arrays. -@end multitable - -@item @emph{Return value}: -The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and -kind of the result follow the usual type and kind promotion rules, as -for the @code{*} or @code{.AND.} operators. -@end table - - - -@node MAX -@section @code{MAX} --- Maximum value of an argument list -@fnindex MAX -@fnindex MAX0 -@fnindex AMAX0 -@fnindex MAX1 -@fnindex AMAX1 -@fnindex DMAX1 -@cindex maximum value - -@table @asis -@item @emph{Description}: -Returns the argument with the largest (most positive) value. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = MAX(A1, A2 [, A3 [, ...]])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A1} @tab The type shall be @code{INTEGER} or -@code{REAL}. -@item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind -as @var{A1}. (As a GNU extension, arguments of different kinds are -permitted.) -@end multitable - -@item @emph{Return value}: -The return value corresponds to the maximum value among the arguments, -and has the same type and kind as the first argument. - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{MAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later -@item @code{AMAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(MAX(X))} @tab Fortran 77 and later -@item @code{MAX1(A1)} @tab @code{REAL A1} @tab @code{INT(MAX(X))} @tab Fortran 77 and later -@item @code{AMAX1(A1)} @tab @code{REAL(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DMAX1(A1)} @tab @code{REAL(8) A1} @tab @code{REAL(8)} @tab Fortran 77 and later -@end multitable - -@item @emph{See also}: -@ref{MAXLOC} @gol -@ref{MAXVAL}, @gol -@ref{MIN} -@end table - - - -@node MAXEXPONENT -@section @code{MAXEXPONENT} --- Maximum exponent of a real kind -@fnindex MAXEXPONENT -@cindex model representation, maximum exponent - -@table @asis -@item @emph{Description}: -@code{MAXEXPONENT(X)} returns the maximum exponent in the model of the -type of @code{X}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = MAXEXPONENT(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab Shall be of type @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the default integer -kind. - -@item @emph{Example}: -@smallexample -program exponents - real(kind=4) :: x - real(kind=8) :: y - - print *, minexponent(x), maxexponent(x) - print *, minexponent(y), maxexponent(y) -end program exponents -@end smallexample -@end table - - - -@node MAXLOC -@section @code{MAXLOC} --- Location of the maximum value within an array -@fnindex MAXLOC -@cindex array, location of maximum element - -@table @asis -@item @emph{Description}: -Determines the location of the element in the array with the maximum -value, or, if the @var{DIM} argument is supplied, determines the -locations of the maximum element along each row of the array in the -@var{DIM} direction. If @var{MASK} is present, only the elements for -which @var{MASK} is @code{.TRUE.} are considered. If more than one -element in the array has the maximum value, the location returned is -that of the first such element in array element order if the -@var{BACK} is not present, or is false; if @var{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 @var{MASK} are @code{.FALSE.}, then -the result is an array of zeroes. Similarly, if @var{DIM} is supplied -and all of the elements of @var{MASK} along a given row are zero, the -result value for that row is zero. - -@item @emph{Standard}: -Fortran 95 and later; @var{ARRAY} of @code{CHARACTER} and the -@var{KIND} argument are available in Fortran 2003 and later. -The @var{BACK} argument is available in Fortran 2008 and later. - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK])} -@item @code{RESULT = MAXLOC(ARRAY [, MASK] [,KIND] [,BACK])} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or -@code{REAL}. -@item @var{DIM} @tab (Optional) Shall be a scalar of type -@code{INTEGER}, with a value between one and the rank of @var{ARRAY}, -inclusive. It may not be an optional dummy argument. -@item @var{MASK} @tab Shall be of type @code{LOGICAL}, -and conformable with @var{ARRAY}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}. -@end multitable - -@item @emph{Return value}: -If @var{DIM} is absent, the result is a rank-one array with a length -equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result -is an array with a rank one less than the rank of @var{ARRAY}, and a -size corresponding to the size of @var{ARRAY} with the @var{DIM} -dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank -of one, the result is a scalar. If the optional argument @var{KIND} -is present, the result is an integer of kind @var{KIND}, otherwise it -is of default kind. - -@item @emph{See also}: -@ref{FINDLOC}, @gol -@ref{MAX}, @gol -@ref{MAXVAL} -@end table - - - -@node MAXVAL -@section @code{MAXVAL} --- Maximum value of an array -@fnindex MAXVAL -@cindex array, maximum value -@cindex maximum value - -@table @asis -@item @emph{Description}: -Determines the maximum value of the elements in an array value, or, if -the @var{DIM} argument is supplied, determines the maximum value along -each row of the array in the @var{DIM} direction. If @var{MASK} is -present, only the elements for which @var{MASK} is @code{.TRUE.} are -considered. If the array has zero size, or all of the elements of -@var{MASK} are @code{.FALSE.}, then the result is @code{-HUGE(ARRAY)} -if @var{ARRAY} is numeric, or a string of nulls if @var{ARRAY} is of character -type. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])} -@item @code{RESULT = MAXVAL(ARRAY [, MASK])} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or -@code{REAL}. -@item @var{DIM} @tab (Optional) Shall be a scalar of type -@code{INTEGER}, with a value between one and the rank of @var{ARRAY}, -inclusive. It may not be an optional dummy argument. -@item @var{MASK} @tab (Optional) Shall be of type @code{LOGICAL}, -and conformable with @var{ARRAY}. -@end multitable - -@item @emph{Return value}: -If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result -is a scalar. If @var{DIM} is present, the result is an array with a -rank one less than the rank of @var{ARRAY}, and a size corresponding to -the size of @var{ARRAY} with the @var{DIM} dimension removed. In all -cases, the result is of the same type and kind as @var{ARRAY}. - -@item @emph{See also}: -@ref{MAX}, @gol -@ref{MAXLOC} -@end table - - - -@node MCLOCK -@section @code{MCLOCK} --- Time function -@fnindex MCLOCK -@cindex time, clock ticks -@cindex clock ticks - -@table @asis -@item @emph{Description}: -Returns the number of clock ticks since the start of the process, based -on the function @code{clock(3)} in the C standard library. - -This intrinsic is not fully portable, such as to systems with 32-bit -@code{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. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{RESULT = MCLOCK()} - -@item @emph{Return value}: -The return value is a scalar of type @code{INTEGER(4)}, equal to the -number of clock ticks since the start of the process, or @code{-1} if -the system does not support @code{clock(3)}. - -@item @emph{See also}: -@ref{CTIME}, @gol -@ref{GMTIME}, @gol -@ref{LTIME}, @gol -@ref{MCLOCK}, @gol -@ref{TIME} -@end table - - - -@node MCLOCK8 -@section @code{MCLOCK8} --- Time function (64-bit) -@fnindex MCLOCK8 -@cindex time, clock ticks -@cindex clock ticks - -@table @asis -@item @emph{Description}: -Returns the number of clock ticks since the start of the process, based -on the function @code{clock(3)} in the C standard library. - -@emph{Warning:} this intrinsic does not increase the range of the timing -values over that returned by @code{clock(3)}. On a system with a 32-bit -@code{clock(3)}, @code{MCLOCK8} will return a 32-bit value, even though -it is converted to a 64-bit @code{INTEGER(8)} value. That means -overflows of the 32-bit value can still occur. 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. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{RESULT = MCLOCK8()} - -@item @emph{Return value}: -The return value is a scalar of type @code{INTEGER(8)}, equal to the -number of clock ticks since the start of the process, or @code{-1} if -the system does not support @code{clock(3)}. - -@item @emph{See also}: -@ref{CTIME}, @gol -@ref{GMTIME}, @gol -@ref{LTIME}, @gol -@ref{MCLOCK}, @gol -@ref{TIME8} -@end table - - - -@node MERGE -@section @code{MERGE} --- Merge variables -@fnindex MERGE -@cindex array, merge arrays -@cindex array, combine arrays - -@table @asis -@item @emph{Description}: -Select values from two arrays according to a logical mask. The result -is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to -@var{FSOURCE} if it is @code{.FALSE.}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{TSOURCE} @tab May be of any type. -@item @var{FSOURCE} @tab Shall be of the same type and type parameters -as @var{TSOURCE}. -@item @var{MASK} @tab Shall be of type @code{LOGICAL}. -@end multitable - -@item @emph{Return value}: -The result is of the same type and type parameters as @var{TSOURCE}. - -@end table - - - -@node MERGE_BITS -@section @code{MERGE_BITS} --- Merge of bits under mask -@fnindex MERGE_BITS -@cindex bits, merge - -@table @asis -@item @emph{Description}: -@code{MERGE_BITS(I, J, MASK)} merges the bits of @var{I} and @var{J} -as determined by the mask. The i-th bit of the result is equal to the -i-th bit of @var{I} if the i-th bit of @var{MASK} is 1; it is equal to -the i-th bit of @var{J} otherwise. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = MERGE_BITS(I, J, MASK)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab Shall be of type @code{INTEGER} or a boz-literal-constant. -@item @var{J} @tab Shall be of type @code{INTEGER} with the same -kind type parameter as @var{I} or a boz-literal-constant. -@var{I} and @var{J} shall not both be boz-literal-constants. -@item @var{MASK} @tab Shall be of type @code{INTEGER} or a boz-literal-constant -and of the same kind as @var{I}. -@end multitable - -@item @emph{Return value}: -The result is of the same type and kind as @var{I}. - -@end table - - - -@node MIN -@section @code{MIN} --- Minimum value of an argument list -@fnindex MIN -@fnindex MIN0 -@fnindex AMIN0 -@fnindex MIN1 -@fnindex AMIN1 -@fnindex DMIN1 -@cindex minimum value - -@table @asis -@item @emph{Description}: -Returns the argument with the smallest (most negative) value. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = MIN(A1, A2 [, A3, ...])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A1} @tab The type shall be @code{INTEGER} or -@code{REAL}. -@item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind -as @var{A1}. (As a GNU extension, arguments of different kinds are -permitted.) -@end multitable - -@item @emph{Return value}: -The return value corresponds to the minimum value among the arguments, -and has the same type and kind as the first argument. - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{MIN0(A1)} @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later -@item @code{AMIN0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{MIN1(A1)} @tab @code{REAL A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later -@item @code{AMIN1(A1)} @tab @code{REAL(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DMIN1(A1)} @tab @code{REAL(8) A1} @tab @code{REAL(8)} @tab Fortran 77 and later -@end multitable - -@item @emph{See also}: -@ref{MAX}, @gol -@ref{MINLOC}, @gol -@ref{MINVAL} -@end table - - - -@node MINEXPONENT -@section @code{MINEXPONENT} --- Minimum exponent of a real kind -@fnindex MINEXPONENT -@cindex model representation, minimum exponent - -@table @asis -@item @emph{Description}: -@code{MINEXPONENT(X)} returns the minimum exponent in the model of the -type of @code{X}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = MINEXPONENT(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab Shall be of type @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the default integer -kind. - -@item @emph{Example}: -See @code{MAXEXPONENT} for an example. -@end table - - - -@node MINLOC -@section @code{MINLOC} --- Location of the minimum value within an array -@fnindex MINLOC -@cindex array, location of minimum element - -@table @asis -@item @emph{Description}: -Determines the location of the element in the array with the minimum -value, or, if the @var{DIM} argument is supplied, determines the -locations of the minimum element along each row of the array in the -@var{DIM} direction. If @var{MASK} is present, only the elements for -which @var{MASK} is @code{.TRUE.} are considered. If more than one -element in the array has the minimum value, the location returned is -that of the first such element in array element order if the -@var{BACK} is not present, or is false; if @var{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 @var{MASK} are @code{.FALSE.}, then -the result is an array of zeroes. Similarly, if @var{DIM} is supplied -and all of the elements of @var{MASK} along a given row are zero, the -result value for that row is zero. - -@item @emph{Standard}: -Fortran 90 and later; @var{ARRAY} of @code{CHARACTER} and the -@var{KIND} argument are available in Fortran 2003 and later. -The @var{BACK} argument is available in Fortran 2008 and later. - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = MINLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK])} -@item @code{RESULT = MINLOC(ARRAY [, MASK], [,KIND] [,BACK])} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, -@code{REAL} or @code{CHARACTER}. -@item @var{DIM} @tab (Optional) Shall be a scalar of type -@code{INTEGER}, with a value between one and the rank of @var{ARRAY}, -inclusive. It may not be an optional dummy argument. -@item @var{MASK} @tab Shall be of type @code{LOGICAL}, -and conformable with @var{ARRAY}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}. -@end multitable - -@item @emph{Return value}: -If @var{DIM} is absent, the result is a rank-one array with a length -equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result -is an array with a rank one less than the rank of @var{ARRAY}, and a -size corresponding to the size of @var{ARRAY} with the @var{DIM} -dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank -of one, the result is a scalar. If the optional argument @var{KIND} -is present, the result is an integer of kind @var{KIND}, otherwise it -is of default kind. - -@item @emph{See also}: -@ref{FINDLOC}, @gol -@ref{MIN}, @gol -@ref{MINVAL} -@end table - - - -@node MINVAL -@section @code{MINVAL} --- Minimum value of an array -@fnindex MINVAL -@cindex array, minimum value -@cindex minimum value - -@table @asis -@item @emph{Description}: -Determines the minimum value of the elements in an array value, or, if -the @var{DIM} argument is supplied, determines the minimum value along -each row of the array in the @var{DIM} direction. If @var{MASK} is -present, only the elements for which @var{MASK} is @code{.TRUE.} are -considered. If the array has zero size, or all of the elements of -@var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if -@var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if -@var{ARRAY} is of character type. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])} -@item @code{RESULT = MINVAL(ARRAY [, MASK])} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or -@code{REAL}. -@item @var{DIM} @tab (Optional) Shall be a scalar of type -@code{INTEGER}, with a value between one and the rank of @var{ARRAY}, -inclusive. It may not be an optional dummy argument. -@item @var{MASK} @tab Shall be of type @code{LOGICAL}, -and conformable with @var{ARRAY}. -@end multitable - -@item @emph{Return value}: -If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result -is a scalar. If @var{DIM} is present, the result is an array with a -rank one less than the rank of @var{ARRAY}, and a size corresponding to -the size of @var{ARRAY} with the @var{DIM} dimension removed. In all -cases, the result is of the same type and kind as @var{ARRAY}. - -@item @emph{See also}: -@ref{MIN}, @gol -@ref{MINLOC} -@end table - - - -@node MOD -@section @code{MOD} --- Remainder function -@fnindex MOD -@fnindex AMOD -@fnindex DMOD -@fnindex BMOD -@fnindex IMOD -@fnindex JMOD -@fnindex KMOD -@cindex remainder -@cindex division, remainder - -@table @asis -@item @emph{Description}: -@code{MOD(A,P)} computes the remainder of the division of A by P@. - -@item @emph{Standard}: -Fortran 77 and later, has overloads that are GNU extensions - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = MOD(A, P)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}. -@item @var{P} @tab Shall be a scalar of the same type and kind as @var{A} -and not equal to zero. (As a GNU extension, arguments of different kinds are -permitted.) -@end multitable - -@item @emph{Return value}: -The return value is the result of @code{A - (INT(A/P) * P)}. The type -and kind of the return value is the same as that of the arguments. The -returned value has the same sign as A and a magnitude less than the -magnitude of P. (As a GNU extension, kind is the largest kind of the actual -arguments.) - -@item @emph{Example}: -@smallexample -program test_mod - 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) - - 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 -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .25 .20 .31 -@headitem Name @tab Arguments @tab Return type @tab Standard -@item @code{MOD(A,P)} @tab @code{INTEGER A,P} @tab @code{INTEGER} @tab Fortran 77 and later -@item @code{AMOD(A,P)} @tab @code{REAL(4) A,P} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DMOD(A,P)} @tab @code{REAL(8) A,P} @tab @code{REAL(8)} @tab Fortran 77 and later -@item @code{BMOD(A,P)} @tab @code{INTEGER(1) A,P} @tab @code{INTEGER(1)} @tab GNU extension -@item @code{IMOD(A,P)} @tab @code{INTEGER(2) A,P} @tab @code{INTEGER(2)} @tab GNU extension -@item @code{JMOD(A,P)} @tab @code{INTEGER(4) A,P} @tab @code{INTEGER(4)} @tab GNU extension -@item @code{KMOD(A,P)} @tab @code{INTEGER(8) A,P} @tab @code{INTEGER(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -@ref{MODULO} - -@end table - - - -@node MODULO -@section @code{MODULO} --- Modulo function -@fnindex MODULO -@cindex modulo -@cindex division, modulo - -@table @asis -@item @emph{Description}: -@code{MODULO(A,P)} computes the @var{A} modulo @var{P}. - -@item @emph{Standard}: -Fortran 95 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = MODULO(A, P)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}. -@item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}. -It shall not be zero. (As a GNU extension, arguments of different kinds are -permitted.) -@end multitable - -@item @emph{Return value}: -The type and kind of the result are those of the arguments. (As a GNU -extension, kind is the largest kind of the actual arguments.) -@table @asis -@item If @var{A} and @var{P} are of type @code{INTEGER}: -@code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where -@var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P} -(exclusive). -@item If @var{A} and @var{P} are of type @code{REAL}: -@code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}. -@end table -The returned value has the same sign as P and a magnitude less than -the magnitude of P. - -@item @emph{Example}: -@smallexample -program test_modulo - print *, modulo(17,3) - print *, modulo(17.5,5.5) - - print *, modulo(-17,3) - print *, modulo(-17.5,5.5) - - print *, modulo(17,-3) - print *, modulo(17.5,-5.5) -end program -@end smallexample - -@item @emph{See also}: -@ref{MOD} - -@end table - - - -@node MOVE_ALLOC -@section @code{MOVE_ALLOC} --- Move allocation from one object to another -@fnindex MOVE_ALLOC -@cindex moving allocation -@cindex allocation, moving - -@table @asis -@item @emph{Description}: -@code{MOVE_ALLOC(FROM, TO)} moves the allocation from @var{FROM} to -@var{TO}. @var{FROM} will become deallocated in the process. - -@item @emph{Standard}: -Fortran 2003 and later - -@item @emph{Class}: -Pure subroutine - -@item @emph{Syntax}: -@code{CALL MOVE_ALLOC(FROM, TO)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{FROM} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be -of any type and kind. -@item @var{TO} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be -of the same type, kind and rank as @var{FROM}. -@end multitable - -@item @emph{Return value}: -None - -@item @emph{Example}: -@smallexample -program test_move_alloc - integer, allocatable :: a(:), b(:) - - allocate(a(3)) - a = [ 1, 2, 3 ] - call move_alloc(a, b) - print *, allocated(a), allocated(b) - print *, b -end program test_move_alloc -@end smallexample -@end table - - - -@node MVBITS -@section @code{MVBITS} --- Move bits from one integer to another -@fnindex MVBITS -@fnindex BMVBITS -@fnindex IMVBITS -@fnindex JMVBITS -@fnindex KMVBITS -@cindex bits, move - -@table @asis -@item @emph{Description}: -Moves @var{LEN} bits from positions @var{FROMPOS} through -@code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through -@code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not -affected by the movement of bits is unchanged. The values of -@code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than -@code{BIT_SIZE(FROM)}. - -@item @emph{Standard}: -Fortran 90 and later, has overloads that are GNU extensions - -@item @emph{Class}: -Elemental subroutine - -@item @emph{Syntax}: -@code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{FROM} @tab The type shall be @code{INTEGER}. -@item @var{FROMPOS} @tab The type shall be @code{INTEGER}. -@item @var{LEN} @tab The type shall be @code{INTEGER}. -@item @var{TO} @tab The type shall be @code{INTEGER}, of the -same kind as @var{FROM}. -@item @var{TOPOS} @tab The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{MVBITS(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later -@item @code{BMVBITS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension -@item @code{IMVBITS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension -@item @code{JMVBITS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension -@item @code{KMVBITS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -@ref{IBCLR}, @gol -@ref{IBSET}, @gol -@ref{IBITS}, @gol -@ref{IAND}, @gol -@ref{IOR}, @gol -@ref{IEOR} -@end table - - - -@node NEAREST -@section @code{NEAREST} --- Nearest representable number -@fnindex NEAREST -@cindex real number, nearest different -@cindex floating point, nearest different - -@table @asis -@item @emph{Description}: -@code{NEAREST(X, S)} returns the processor-representable number nearest -to @code{X} in the direction indicated by the sign of @code{S}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = NEAREST(X, S)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab Shall be of type @code{REAL}. -@item @var{S} @tab Shall be of type @code{REAL} and -not equal to zero. -@end multitable - -@item @emph{Return value}: -The return value is of the same type as @code{X}. If @code{S} is -positive, @code{NEAREST} returns the processor-representable number -greater than @code{X} and nearest to it. If @code{S} is negative, -@code{NEAREST} returns the processor-representable number smaller than -@code{X} and nearest to it. - -@item @emph{Example}: -@smallexample -program test_nearest - real :: x, y - x = nearest(42.0, 1.0) - y = nearest(42.0, -1.0) - write (*,"(3(G20.15))") x, y, x - y -end program test_nearest -@end smallexample -@end table - - - -@node NEW_LINE -@section @code{NEW_LINE} --- New line character -@fnindex NEW_LINE -@cindex newline -@cindex output, newline - -@table @asis -@item @emph{Description}: -@code{NEW_LINE(C)} returns the new-line character. - -@item @emph{Standard}: -Fortran 2003 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = NEW_LINE(C)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{C} @tab The argument shall be a scalar or array of the -type @code{CHARACTER}. -@end multitable - -@item @emph{Return value}: -Returns a @var{CHARACTER} scalar of length one with the new-line character of -the same kind as parameter @var{C}. - -@item @emph{Example}: -@smallexample -program newline - implicit none - write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.' -end program newline -@end smallexample -@end table - - - -@node NINT -@section @code{NINT} --- Nearest whole number -@fnindex NINT -@fnindex IDNINT -@cindex rounding, nearest whole number - -@table @asis -@item @emph{Description}: -@code{NINT(A)} rounds its argument to the nearest whole number. - -@item @emph{Standard}: -Fortran 77 and later, with @var{KIND} argument Fortran 90 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = NINT(A [, KIND])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab The type of the argument shall be @code{REAL}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -Returns @var{A} with the fractional portion of its magnitude eliminated by -rounding to the nearest whole number and with its sign preserved, -converted to an @code{INTEGER} of the default kind. - -@item @emph{Example}: -@smallexample -program test_nint - real(4) x4 - real(8) x8 - x4 = 1.234E0_4 - x8 = 4.321_8 - print *, nint(x4), idnint(x8) -end program test_nint -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return Type @tab Standard -@item @code{NINT(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later -@item @code{IDNINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab Fortran 77 and later -@end multitable - -@item @emph{See also}: -@ref{CEILING}, @gol -@ref{FLOOR} -@end table - - - -@node NORM2 -@section @code{NORM2} --- Euclidean vector norms -@fnindex NORM2 -@cindex Euclidean vector norm -@cindex L2 vector norm -@cindex norm, Euclidean - -@table @asis -@item @emph{Description}: -Calculates the Euclidean vector norm (@math{L_2} norm) -of @var{ARRAY} along dimension @var{DIM}. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = NORM2(ARRAY[, DIM])} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an array of type @code{REAL} -@item @var{DIM} @tab (Optional) shall be a scalar of type -@code{INTEGER} with a value in the range from 1 to n, where n -equals the rank of @var{ARRAY}. -@end multitable - -@item @emph{Return value}: -The result is of the same type as @var{ARRAY}. - -If @var{DIM} is absent, a scalar with the square root of the sum of all -elements in @var{ARRAY} squared is returned. Otherwise, an array of -rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY}, and a -shape similar to that of @var{ARRAY} with dimension @var{DIM} dropped -is returned. - -@item @emph{Example}: -@smallexample -PROGRAM test_sum - REAL :: x(5) = [ real :: 1, 2, 3, 4, 5 ] - print *, NORM2(x) ! = sqrt(55.) ~ 7.416 -END PROGRAM -@end smallexample -@end table - - - -@node NOT -@section @code{NOT} --- Logical negation -@fnindex NOT -@fnindex BNOT -@fnindex INOT -@fnindex JNOT -@fnindex KNOT -@cindex bits, negate -@cindex bitwise logical not -@cindex logical not, bitwise - -@table @asis -@item @emph{Description}: -@code{NOT} returns the bitwise Boolean inverse of @var{I}. - -@item @emph{Standard}: -Fortran 90 and later, has overloads that are GNU extensions - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = NOT(I)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return type is @code{INTEGER}, of the same kind as the -argument. - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{NOT(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later -@item @code{BNOT(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension -@item @code{INOT(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension -@item @code{JNOT(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension -@item @code{KNOT(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -@ref{IAND}, @gol -@ref{IEOR}, @gol -@ref{IOR}, @gol -@ref{IBITS}, @gol -@ref{IBSET}, @gol -@ref{IBCLR} -@end table - - - -@node NULL -@section @code{NULL} --- Function that returns an disassociated pointer -@fnindex NULL -@cindex pointer, status -@cindex pointer, disassociated - -@table @asis -@item @emph{Description}: -Returns a disassociated pointer. - -If @var{MOLD} is present, a disassociated pointer of the same type is -returned, otherwise the type is determined by context. - -In Fortran 95, @var{MOLD} is optional. Please note that Fortran 2003 -includes cases where it is required. - -@item @emph{Standard}: -Fortran 95 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{PTR => NULL([MOLD])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{MOLD} @tab (Optional) shall be a pointer of any association -status and of any type. -@end multitable - -@item @emph{Return value}: -A disassociated pointer. - -@item @emph{Example}: -@smallexample -REAL, POINTER, DIMENSION(:) :: VEC => NULL () -@end smallexample - -@item @emph{See also}: -@ref{ASSOCIATED} -@end table - - - -@node NUM_IMAGES -@section @code{NUM_IMAGES} --- Function that returns the number of images -@fnindex NUM_IMAGES -@cindex coarray, @code{NUM_IMAGES} -@cindex images, number of - -@table @asis -@item @emph{Description}: -Returns the number of images. - -@item @emph{Standard}: -Fortran 2008 and later. With @var{DISTANCE} or @var{FAILED} argument, -Technical Specification (TS) 18508 or later - - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = NUM_IMAGES(DISTANCE, FAILED)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{DISTANCE} @tab (optional, intent(in)) Nonnegative scalar integer -@item @var{FAILED} @tab (optional, intent(in)) Scalar logical expression -@end multitable - -@item @emph{Return value}: -Scalar default-kind integer. If @var{DISTANCE} is not present or has value 0, -the number of images in the current team is returned. For values smaller or -equal distance to the initial team, it returns the number of images index -on the ancestor team which has a distance of @var{DISTANCE} from the invoking -team. If @var{DISTANCE} is larger than the distance to the initial team, the -number of images of the initial team is returned. If @var{FAILED} is not present -the total number of images is returned; if it has the value @code{.TRUE.}, -the number of failed images is returned, otherwise, the number of images which -do have not the failed status. - -@item @emph{Example}: -@smallexample -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 -@end smallexample - -@item @emph{See also}: -@ref{THIS_IMAGE}, @gol -@ref{IMAGE_INDEX} -@end table - - - -@node OR -@section @code{OR} --- Bitwise logical OR -@fnindex OR -@cindex bitwise logical or -@cindex logical or, bitwise - -@table @asis -@item @emph{Description}: -Bitwise logical @code{OR}. - -This intrinsic routine is provided for backwards compatibility with -GNU Fortran 77. For integer arguments, programmers should consider -the use of the @ref{IOR} intrinsic defined by the Fortran standard. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{RESULT = OR(I, J)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be either a scalar @code{INTEGER} -type or a scalar @code{LOGICAL} type or a boz-literal-constant. -@item @var{J} @tab The type shall be the same as the type of @var{I} or -a boz-literal-constant. @var{I} and @var{J} shall not both be -boz-literal-constants. If either @var{I} and @var{J} is a -boz-literal-constant, then the other argument must be a scalar @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return type is either a scalar @code{INTEGER} or a scalar -@code{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 @code{INTEGER} with the kind type parameter of -the other argument as-if a call to @ref{INT} occurred. - -@item @emph{Example}: -@smallexample -PROGRAM test_or - LOGICAL :: T = .TRUE., F = .FALSE. - INTEGER :: a, b - DATA a / Z'F' /, b / Z'3' / - - WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F) - WRITE (*,*) OR(a, b) -END PROGRAM -@end smallexample - -@item @emph{See also}: -Fortran 95 elemental function: @gol -@ref{IOR} -@end table - - - -@node PACK -@section @code{PACK} --- Pack an array into an array of rank one -@fnindex PACK -@cindex array, packing -@cindex array, reduce dimension -@cindex array, gather elements - -@table @asis -@item @emph{Description}: -Stores the elements of @var{ARRAY} in an array of rank one. - -The beginning of the resulting array is made up of elements whose @var{MASK} -equals @code{TRUE}. Afterwards, positions are filled with elements taken from -@var{VECTOR}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = PACK(ARRAY, MASK[,VECTOR])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an array of any type. -@item @var{MASK} @tab Shall be an array of type @code{LOGICAL} and -of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL} -scalar. -@item @var{VECTOR} @tab (Optional) shall be an array of the same type -as @var{ARRAY} and of rank one. If present, the number of elements in -@var{VECTOR} shall be equal to or greater than the number of true elements -in @var{MASK}. If @var{MASK} is scalar, the number of elements in -@var{VECTOR} shall be equal to or greater than the number of elements in -@var{ARRAY}. -@end multitable - -@item @emph{Return value}: -The result is an array of rank one and the same type as that of @var{ARRAY}. -If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the -number of @code{TRUE} values in @var{MASK} otherwise. - -@item @emph{Example}: -Gathering nonzero elements from an array: -@smallexample -PROGRAM test_pack_1 - INTEGER :: m(6) - m = (/ 1, 0, 0, 0, 5, 0 /) - WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0) ! "1 5" -END PROGRAM -@end smallexample - -Gathering nonzero elements from an array and appending elements from @var{VECTOR}: -@smallexample -PROGRAM test_pack_2 - INTEGER :: m(4) - m = (/ 1, 0, 0, 2 /) - ! The following results in "1 2 3 4" - WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /)) -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{UNPACK} -@end table - - - -@node PARITY -@section @code{PARITY} --- Reduction with exclusive OR -@fnindex PARITY -@cindex Parity -@cindex Reduction, XOR -@cindex XOR reduction - -@table @asis -@item @emph{Description}: -Calculates the parity, i.e. the reduction using @code{.XOR.}, -of @var{MASK} along dimension @var{DIM}. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = PARITY(MASK[, DIM])} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{MASK} @tab Shall be an array of type @code{LOGICAL} -@item @var{DIM} @tab (Optional) shall be a scalar of type -@code{INTEGER} with a value in the range from 1 to n, where n -equals the rank of @var{MASK}. -@end multitable - -@item @emph{Return value}: -The result is of the same type as @var{MASK}. - -If @var{DIM} is absent, a scalar with the parity of all elements in -@var{MASK} is returned, i.e. true if an odd number of elements is -@code{.true.} and false otherwise. If @var{DIM} is present, an array -of rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY}, -and a shape similar to that of @var{MASK} with dimension @var{DIM} -dropped is returned. - -@item @emph{Example}: -@smallexample -PROGRAM test_sum - LOGICAL :: x(2) = [ .true., .false. ] - print *, PARITY(x) ! prints "T" (true). -END PROGRAM -@end smallexample -@end table - - - -@node PERROR -@section @code{PERROR} --- Print system error message -@fnindex PERROR -@cindex system, error handling - -@table @asis -@item @emph{Description}: -Prints (on the C @code{stderr} stream) a newline-terminated error -message corresponding to the last system error. This is prefixed by -@var{STRING}, a colon and a space. See @code{perror(3)}. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL PERROR(STRING)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{STRING} @tab A scalar of type @code{CHARACTER} and of the -default kind. -@end multitable - -@item @emph{See also}: -@ref{IERRNO} -@end table - - - -@node POPCNT -@section @code{POPCNT} --- Number of bits set -@fnindex POPCNT -@cindex binary representation -@cindex bits set - -@table @asis -@item @emph{Description}: -@code{POPCNT(I)} returns the number of bits set ('1' bits) in the binary -representation of @code{I}. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = POPCNT(I)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab Shall be of type @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the default integer -kind. - -@item @emph{Example}: -@smallexample -program test_population - print *, popcnt(127), poppar(127) - print *, popcnt(huge(0_4)), poppar(huge(0_4)) - print *, popcnt(huge(0_8)), poppar(huge(0_8)) -end program test_population -@end smallexample -@item @emph{See also}: -@ref{POPPAR}, @gol -@ref{LEADZ}, @gol -@ref{TRAILZ} -@end table - - - -@node POPPAR -@section @code{POPPAR} --- Parity of the number of bits set -@fnindex POPPAR -@cindex binary representation -@cindex parity - -@table @asis -@item @emph{Description}: -@code{POPPAR(I)} returns parity of the integer @code{I}, i.e. the parity -of the number of bits set ('1' bits) in the binary representation of -@code{I}. It is equal to 0 if @code{I} has an even number of bits set, -and 1 for an odd number of '1' bits. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = POPPAR(I)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab Shall be of type @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the default integer -kind. - -@item @emph{Example}: -@smallexample -program test_population - print *, popcnt(127), poppar(127) - print *, popcnt(huge(0_4)), poppar(huge(0_4)) - print *, popcnt(huge(0_8)), poppar(huge(0_8)) -end program test_population -@end smallexample -@item @emph{See also}: -@ref{POPCNT}, @gol -@ref{LEADZ}, @gol -@ref{TRAILZ} -@end table - - - -@node PRECISION -@section @code{PRECISION} --- Decimal precision of a real kind -@fnindex PRECISION -@cindex model representation, precision - -@table @asis -@item @emph{Description}: -@code{PRECISION(X)} returns the decimal precision in the model of the -type of @code{X}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = PRECISION(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}. It may -be scalar or valued. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the default integer -kind. - -@item @emph{Example}: -@smallexample -program prec_and_range - real(kind=4) :: x(2) - complex(kind=8) :: y - - print *, precision(x), range(x) - print *, precision(y), range(y) -end program prec_and_range -@end smallexample -@item @emph{See also}: -@ref{SELECTED_REAL_KIND}, @gol -@ref{RANGE} -@end table - - - -@node PRESENT -@section @code{PRESENT} --- Determine whether an optional dummy argument is specified -@fnindex PRESENT - -@table @asis -@item @emph{Description}: -Determines whether an optional dummy argument is present. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = PRESENT(A)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab May be of any type and may be a pointer, scalar or array -value, or a dummy procedure. It shall be the name of an optional dummy argument -accessible within the current subroutine or function. -@end multitable - -@item @emph{Return value}: -Returns either @code{TRUE} if the optional argument @var{A} is present, or -@code{FALSE} otherwise. - -@item @emph{Example}: -@smallexample -PROGRAM test_present - WRITE(*,*) f(), f(42) ! "F T" -CONTAINS - LOGICAL FUNCTION f(x) - INTEGER, INTENT(IN), OPTIONAL :: x - f = PRESENT(x) - END FUNCTION -END PROGRAM -@end smallexample -@end table - - - -@node PRODUCT -@section @code{PRODUCT} --- Product of array elements -@fnindex PRODUCT -@cindex array, product -@cindex array, multiply elements -@cindex array, conditionally multiply elements -@cindex multiply array elements - -@table @asis -@item @emph{Description}: -Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if -the corresponding element in @var{MASK} is @code{TRUE}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = PRODUCT(ARRAY[, MASK])} -@item @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, -@code{REAL} or @code{COMPLEX}. -@item @var{DIM} @tab (Optional) shall be a scalar of type -@code{INTEGER} with a value in the range from 1 to n, where n -equals the rank of @var{ARRAY}. -@item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL} -and either be a scalar or an array of the same shape as @var{ARRAY}. -@end multitable - -@item @emph{Return value}: -The result is of the same type as @var{ARRAY}. - -If @var{DIM} is absent, a scalar with the product of all elements in -@var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals -the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with -dimension @var{DIM} dropped is returned. - - -@item @emph{Example}: -@smallexample -PROGRAM test_product - INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /) - print *, PRODUCT(x) ! all elements, product = 120 - print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15 -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{SUM} -@end table - - - -@node RADIX -@section @code{RADIX} --- Base of a model number -@fnindex RADIX -@cindex model representation, base -@cindex model representation, radix - -@table @asis -@item @emph{Description}: -@code{RADIX(X)} returns the base of the model representing the entity @var{X}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = RADIX(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL} -@end multitable - -@item @emph{Return value}: -The return value is a scalar of type @code{INTEGER} and of the default -integer kind. - -@item @emph{Example}: -@smallexample -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 -@end smallexample -@item @emph{See also}: -@ref{SELECTED_REAL_KIND} -@end table - - - -@node RAN -@section @code{RAN} --- Real pseudo-random number -@fnindex RAN -@cindex random number generation - -@table @asis -@item @emph{Description}: -For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is -provided as an alias for @code{RAND}. See @ref{RAND} for complete -documentation. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{See also}: -@ref{RAND}, @gol -@ref{RANDOM_NUMBER} -@end table - - - -@node RAND -@section @code{RAND} --- Real pseudo-random number -@fnindex RAND -@cindex random number generation - -@table @asis -@item @emph{Description}: -@code{RAND(FLAG)} returns a pseudo-random number from a uniform -distribution between 0 and 1. If @var{FLAG} is 0, the next number -in the current sequence is returned; if @var{FLAG} is 1, the generator -is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value, -it is used as a new seed with @code{SRAND}. - -This intrinsic routine is provided for backwards compatibility with -GNU Fortran 77. It implements a simple modulo generator as provided -by @command{g77}. For new code, one should consider the use of -@ref{RANDOM_NUMBER} as it implements a superior algorithm. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{RESULT = RAND(I)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4. -@end multitable - -@item @emph{Return value}: -The return value is of @code{REAL} type and the default kind. - -@item @emph{Example}: -@smallexample -program test_rand - integer,parameter :: seed = 86456 - - call srand(seed) - print *, rand(), rand(), rand(), rand() - print *, rand(seed), rand(), rand(), rand() -end program test_rand -@end smallexample - -@item @emph{See also}: -@ref{SRAND}, @gol -@ref{RANDOM_NUMBER} - -@end table - - -@node RANDOM_INIT -@section @code{RANDOM_INIT} --- Initialize a pseudo-random number generator -@fnindex RANDOM_INIT -@cindex random number generation, initialization - -@table @asis -@item @emph{Description}: -Initializes the state of the pseudorandom number generator used by -@code{RANDOM_NUMBER}. - -@item @emph{Standard}: -Fortran 2018 - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL RANDOM_INIT(REPEATABLE, IMAGE_DISTINCT)} - -@item @emph{Arguments}: -@multitable @columnfractions .25 .70 -@item @var{REPEATABLE} @tab Shall be a scalar with a @code{LOGICAL} type, -and it is @code{INTENT(IN)}. If it is @code{.true.}, the seed is set to -a processor-dependent value that is the same each time @code{RANDOM_INIT} -is called from the same image. The term ``same image'' means a single -instance of program execution. The sequence of random numbers is different -for repeated execution of the program. If it is @code{.false.}, the seed -is set to a processor-dependent value. -@item @var{IMAGE_DISTINCT} @tab Shall be a scalar with a -@code{LOGICAL} type, and it is @code{INTENT(IN)}. If it is @code{.true.}, -the seed is set to a processor-dependent value that is distinct from th -seed set by a call to @code{RANDOM_INIT} in another image. If it is -@code{.false.}, the seed is set to a value that does depend which image called -@code{RANDOM_INIT}. -@end multitable - -@item @emph{Example}: -@smallexample -program test_random_seed - implicit none - real x(3), y(3) - call random_init(.true., .true.) - call random_number(x) - call random_init(.true., .true.) - call random_number(y) - ! x and y are the same sequence - if (any(x /= y)) call abort -end program test_random_seed -@end smallexample - -@item @emph{See also}: -@ref{RANDOM_NUMBER}, @gol -@ref{RANDOM_SEED} -@end table - - -@node RANDOM_NUMBER -@section @code{RANDOM_NUMBER} --- Pseudo-random number -@fnindex RANDOM_NUMBER -@cindex random number generation - -@table @asis -@item @emph{Description}: -Returns a single pseudorandom number or an array of pseudorandom numbers -from the uniform distribution over the range @math{ 0 \leq x < 1}. - -The runtime-library implements the xoshiro256** pseudorandom number -generator (PRNG). This generator has a period of @math{2^{256} - 1}, -and when using multiple threads up to @math{2^{128}} threads can each -generate @math{2^{128}} random numbers before any aliasing occurs. - -Note that in a multi-threaded program (e.g. using OpenMP directives), -each thread will have its own random number state. For details of the -seeding procedure, see the documentation for the @code{RANDOM_SEED} -intrinsic. - - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL RANDOM_NUMBER(HARVEST)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL}. -@end multitable - -@item @emph{Example}: -@smallexample -program test_random_number - REAL :: r(5,5) - CALL RANDOM_NUMBER(r) -end program -@end smallexample - -@item @emph{See also}: -@ref{RANDOM_SEED}, @gol -@ref{RANDOM_INIT} -@end table - - - -@node RANDOM_SEED -@section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence -@fnindex RANDOM_SEED -@cindex random number generation, seeding -@cindex seeding a random number generator - -@table @asis -@item @emph{Description}: -Restarts or queries the state of the pseudorandom number generator used by -@code{RANDOM_NUMBER}. - -If @code{RANDOM_SEED} is called without arguments, it is seeded with -random data retrieved from the operating system. - -As an extension to the Fortran standard, the GFortran -@code{RANDOM_NUMBER} supports multiple threads. Each thread in a -multi-threaded program has its own seed. When @code{RANDOM_SEED} is -called either without arguments or with the @var{PUT} argument, the -given seed is copied into a master seed as well as the seed of the -current thread. When a new thread uses @code{RANDOM_NUMBER} for the -first time, the seed is copied from the master seed, and forwarded -@math{N * 2^{128}} steps to guarantee that the random stream does not -alias any other stream in the system, where @var{N} is the number of -threads that have used @code{RANDOM_NUMBER} so far during the program -execution. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL RANDOM_SEED([SIZE, PUT, GET])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{SIZE} @tab (Optional) Shall be a scalar and of type default -@code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size -of the arrays used with the @var{PUT} and @var{GET} arguments. -@item @var{PUT} @tab (Optional) Shall be an array of type default -@code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of -the array must be larger than or equal to the number returned by the -@var{SIZE} argument. -@item @var{GET} @tab (Optional) Shall be an array of type default -@code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size -of the array must be larger than or equal to the number returned by -the @var{SIZE} argument. -@end multitable - -@item @emph{Example}: -@smallexample -program test_random_seed - implicit none - integer, allocatable :: seed(:) - integer :: n - - call random_seed(size = n) - allocate(seed(n)) - call random_seed(get=seed) - write (*, *) seed -end program test_random_seed -@end smallexample - -@item @emph{See also}: -@ref{RANDOM_NUMBER}, @gol -@ref{RANDOM_INIT} -@end table - - - -@node RANGE -@section @code{RANGE} --- Decimal exponent range -@fnindex RANGE -@cindex model representation, range - -@table @asis -@item @emph{Description}: -@code{RANGE(X)} returns the decimal exponent range in the model of the -type of @code{X}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = RANGE(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab Shall be of type @code{INTEGER}, @code{REAL} -or @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the default integer -kind. - -@item @emph{Example}: -See @code{PRECISION} for an example. -@item @emph{See also}: -@ref{SELECTED_REAL_KIND}, @gol -@ref{PRECISION} -@end table - - - -@node RANK -@section @code{RANK} --- Rank of a data object -@fnindex RANK -@cindex rank - -@table @asis -@item @emph{Description}: -@code{RANK(A)} returns the rank of a scalar or array data object. - -@item @emph{Standard}: -Technical Specification (TS) 29113 - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = RANK(A)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab can be of any type -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the default integer -kind. For arrays, their rank is returned; for scalars zero is returned. - -@item @emph{Example}: -@smallexample -program test_rank - integer :: a - real, allocatable :: b(:,:) - - print *, rank(a), rank(b) ! Prints: 0 2 -end program test_rank -@end smallexample - -@end table - - - -@node REAL -@section @code{REAL} --- Convert to real type -@fnindex REAL -@fnindex REALPART -@fnindex FLOAT -@fnindex DFLOAT -@fnindex FLOATI -@fnindex FLOATJ -@fnindex FLOATK -@fnindex SNGL -@cindex conversion, to real -@cindex complex numbers, real part - -@table @asis -@item @emph{Description}: -@code{REAL(A [, KIND])} converts its argument @var{A} to a real type. The -@code{REALPART} function is provided for compatibility with @command{g77}, -and its use is strongly discouraged. - -@item @emph{Standard}: -Fortran 77 and later, with @var{KIND} argument Fortran 90 and later, has GNU extensions - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = REAL(A [, KIND])} -@item @code{RESULT = REALPART(Z)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab Shall be @code{INTEGER}, @code{REAL}, or -@code{COMPLEX}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -These functions return a @code{REAL} variable or array under -the following rules: - -@table @asis -@item (A) -@code{REAL(A)} is converted to a default real type if @var{A} is an -integer or real variable. -@item (B) -@code{REAL(A)} is converted to a real type with the kind type parameter -of @var{A} if @var{A} is a complex variable. -@item (C) -@code{REAL(A, KIND)} is converted to a real type with kind type -parameter @var{KIND} if @var{A} is a complex, integer, or real -variable. -@end table - -@item @emph{Example}: -@smallexample -program test_real - complex :: x = (1.0, 2.0) - print *, real(x), real(x,8), realpart(x) -end program test_real -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{FLOAT(A)} @tab @code{INTEGER(4)} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DFLOAT(A)} @tab @code{INTEGER(4)} @tab @code{REAL(8)} @tab GNU extension -@item @code{FLOATI(A)} @tab @code{INTEGER(2)} @tab @code{REAL(4)} @tab GNU extension (-fdec) -@item @code{FLOATJ(A)} @tab @code{INTEGER(4)} @tab @code{REAL(4)} @tab GNU extension (-fdec) -@item @code{FLOATK(A)} @tab @code{INTEGER(8)} @tab @code{REAL(4)} @tab GNU extension (-fdec) -@item @code{SNGL(A)} @tab @code{REAL(8)} @tab @code{REAL(4)} @tab Fortran 77 and later -@end multitable - - -@item @emph{See also}: -@ref{DBLE} - -@end table - - - -@node RENAME -@section @code{RENAME} --- Rename a file -@fnindex RENAME -@cindex file system, rename file - -@table @asis -@item @emph{Description}: -Renames a file from file @var{PATH1} to @var{PATH2}. A null -character (@code{CHAR(0)}) can be used to mark the end of the names in -@var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file -names are ignored. If the @var{STATUS} argument is supplied, it -contains 0 on success or a nonzero error code upon return; see -@code{rename(2)}. - -This intrinsic is provided in both subroutine and function forms; -however, only one form can be used in any given program unit. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL RENAME(PATH1, PATH2 [, STATUS])} -@item @code{STATUS = RENAME(PATH1, PATH2)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{PATH1} @tab Shall be of default @code{CHARACTER} type. -@item @var{PATH2} @tab Shall be of default @code{CHARACTER} type. -@item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type. -@end multitable - -@item @emph{See also}: -@ref{LINK} - -@end table - - - -@node REPEAT -@section @code{REPEAT} --- Repeated string concatenation -@fnindex REPEAT -@cindex string, repeat -@cindex string, concatenate - -@table @asis -@item @emph{Description}: -Concatenates @var{NCOPIES} copies of a string. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = REPEAT(STRING, NCOPIES)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{STRING} @tab Shall be scalar and of type @code{CHARACTER}. -@item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies -of @var{STRING}. - -@item @emph{Example}: -@smallexample -program test_repeat - write(*,*) repeat("x", 5) ! "xxxxx" -end program -@end smallexample -@end table - - - -@node RESHAPE -@section @code{RESHAPE} --- Function to reshape an array -@fnindex RESHAPE -@cindex array, change dimensions -@cindex array, transmogrify - -@table @asis -@item @emph{Description}: -Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary, -the new array may be padded with elements from @var{PAD} or permuted -as defined by @var{ORDER}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{SOURCE} @tab Shall be an array of any type. -@item @var{SHAPE} @tab Shall be of type @code{INTEGER} and an -array of rank one. Its values must be positive or zero. -@item @var{PAD} @tab (Optional) shall be an array of the same -type as @var{SOURCE}. -@item @var{ORDER} @tab (Optional) shall be of type @code{INTEGER} -and an array of the same shape as @var{SHAPE}. Its values shall -be a permutation of the numbers from 1 to n, where n is the size of -@var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall -be assumed. -@end multitable - -@item @emph{Return value}: -The result is an array of shape @var{SHAPE} with the same type as -@var{SOURCE}. - -@item @emph{Example}: -@smallexample -PROGRAM test_reshape - INTEGER, DIMENSION(4) :: x - WRITE(*,*) SHAPE(x) ! prints "4" - WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/))) ! prints "2 2" -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{SHAPE} -@end table - - - -@node RRSPACING -@section @code{RRSPACING} --- Reciprocal of the relative spacing -@fnindex RRSPACING -@cindex real number, relative spacing -@cindex floating point, relative spacing - - -@table @asis -@item @emph{Description}: -@code{RRSPACING(X)} returns the reciprocal of the relative spacing of -model numbers near @var{X}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = RRSPACING(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab Shall be of type @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of the same type and kind as @var{X}. -The value returned is equal to -@code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}. - -@item @emph{See also}: -@ref{SPACING} -@end table - - - -@node RSHIFT -@section @code{RSHIFT} --- Right shift bits -@fnindex RSHIFT -@cindex bits, shift right - -@table @asis -@item @emph{Description}: -@code{RSHIFT} returns a value corresponding to @var{I} with all of the -bits shifted right by @var{SHIFT} places. @var{SHIFT} shall be -nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise -the result value is undefined. Bits shifted out from the right end -are lost. The fill is arithmetic: the bits shifted in from the left -end are equal to the leftmost bit, which in two's complement -representation is the sign bit. - -This function has been superseded by the @code{SHIFTA} intrinsic, which -is standard in Fortran 2008 and later. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = RSHIFT(I, SHIFT)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER}. -@item @var{SHIFT} @tab The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the same kind as -@var{I}. - -@item @emph{See also}: -@ref{ISHFT}, @gol -@ref{ISHFTC}, @gol -@ref{LSHIFT}, @gol -@ref{SHIFTA}, @gol -@ref{SHIFTR}, @gol -@ref{SHIFTL} - -@end table - - - -@node SAME_TYPE_AS -@section @code{SAME_TYPE_AS} --- Query dynamic types for equality -@fnindex SAME_TYPE_AS - -@table @asis -@item @emph{Description}: -Query dynamic types for equality. - -@item @emph{Standard}: -Fortran 2003 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = SAME_TYPE_AS(A, B)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab Shall be an object of extensible declared type or -unlimited polymorphic. -@item @var{B} @tab Shall be an object of extensible declared type or -unlimited polymorphic. -@end multitable - -@item @emph{Return value}: -The return value is a scalar of type default logical. It is true if and -only if the dynamic type of A is the same as the dynamic type of B. - -@item @emph{See also}: -@ref{EXTENDS_TYPE_OF} - -@end table - - - -@node SCALE -@section @code{SCALE} --- Scale a real value -@fnindex SCALE -@cindex real number, scale -@cindex floating point, scale - -@table @asis -@item @emph{Description}: -@code{SCALE(X,I)} returns @code{X * RADIX(X)**I}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = SCALE(X, I)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type of the argument shall be a @code{REAL}. -@item @var{I} @tab The type of the argument shall be a @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of the same type and kind as @var{X}. -Its value is @code{X * RADIX(X)**I}. - -@item @emph{Example}: -@smallexample -program test_scale - real :: x = 178.1387e-4 - integer :: i = 5 - print *, scale(x,i), x*radix(x)**i -end program test_scale -@end smallexample - -@end table - - - -@node SCAN -@section @code{SCAN} --- Scan a string for the presence of a set of characters -@fnindex SCAN -@cindex string, find subset - -@table @asis -@item @emph{Description}: -Scans a @var{STRING} for any of the characters in a @var{SET} -of characters. - -If @var{BACK} is either absent or equals @code{FALSE}, this function -returns the position of the leftmost character of @var{STRING} that is -in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position -is returned. If no character of @var{SET} is found in @var{STRING}, the -result is zero. - -@item @emph{Standard}: -Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{STRING} @tab Shall be of type @code{CHARACTER}. -@item @var{SET} @tab Shall be of type @code{CHARACTER}. -@item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of kind @var{KIND}. If -@var{KIND} is absent, the return value is of default integer kind. - -@item @emph{Example}: -@smallexample -PROGRAM test_scan - WRITE(*,*) SCAN("FORTRAN", "AO") ! 2, found 'O' - WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.) ! 6, found 'A' - WRITE(*,*) SCAN("FORTRAN", "C++") ! 0, found none -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{INDEX intrinsic}, @gol -@ref{VERIFY} -@end table - - - -@node SECNDS -@section @code{SECNDS} --- Time function -@fnindex SECNDS -@cindex time, elapsed -@cindex elapsed time - -@table @asis -@item @emph{Description}: -@code{SECNDS(X)} gets the time in seconds from the real-time system clock. -@var{X} is a reference time, also in seconds. If this is zero, the time in -seconds from midnight is returned. This function is non-standard and its -use is discouraged. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{RESULT = SECNDS (X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{T} @tab Shall be of type @code{REAL(4)}. -@item @var{X} @tab Shall be of type @code{REAL(4)}. -@end multitable - -@item @emph{Return value}: -None - -@item @emph{Example}: -@smallexample -program test_secnds - integer :: i - real(4) :: t1, t2 - print *, secnds (0.0) ! seconds since midnight - t1 = secnds (0.0) ! reference time - do i = 1, 10000000 ! do something - end do - t2 = secnds (t1) ! elapsed time - print *, "Something took ", t2, " seconds." -end program test_secnds -@end smallexample -@end table - - - -@node SECOND -@section @code{SECOND} --- CPU time function -@fnindex SECOND -@cindex time, elapsed -@cindex elapsed time - -@table @asis -@item @emph{Description}: -Returns a @code{REAL(4)} value representing the elapsed CPU time in -seconds. This provides the same functionality as the standard -@code{CPU_TIME} intrinsic, and is only included for backwards -compatibility. - -This intrinsic is provided in both subroutine and function forms; -however, only one form can be used in any given program unit. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL SECOND(TIME)} -@item @code{TIME = SECOND()} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{TIME} @tab Shall be of type @code{REAL(4)}. -@end multitable - -@item @emph{Return value}: -In either syntax, @var{TIME} is set to the process's current runtime in -seconds. - -@item @emph{See also}: -@ref{CPU_TIME} - -@end table - - - -@node SELECTED_CHAR_KIND -@section @code{SELECTED_CHAR_KIND} --- Choose character kind -@fnindex SELECTED_CHAR_KIND -@cindex character kind -@cindex kind, character - -@table @asis -@item @emph{Description}: - -@code{SELECTED_CHAR_KIND(NAME)} returns the kind value for the character -set named @var{NAME}, if a character set with such a name is supported, -or @math{-1} otherwise. Currently, supported character sets include -``ASCII'' and ``DEFAULT'', which are equivalent, and ``ISO_10646'' -(Universal Character Set, UCS-4) which is commonly known as Unicode. - -@item @emph{Standard}: -Fortran 2003 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = SELECTED_CHAR_KIND(NAME)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{NAME} @tab Shall be a scalar and of the default character type. -@end multitable - -@item @emph{Example}: -@smallexample -program character_kind - use iso_fortran_env - implicit none - integer, parameter :: ascii = selected_char_kind ("ascii") - integer, parameter :: ucs4 = selected_char_kind ('ISO_10646') - - character(kind=ascii, len=26) :: alphabet - character(kind=ucs4, len=30) :: hello_world - - alphabet = ascii_"abcdefghijklmnopqrstuvwxyz" - hello_world = ucs4_'Hello World and Ni Hao -- ' & - // char (int (z'4F60'), ucs4) & - // char (int (z'597D'), ucs4) - - write (*,*) alphabet - - open (output_unit, encoding='UTF-8') - write (*,*) trim (hello_world) -end program character_kind -@end smallexample -@end table - - - -@node SELECTED_INT_KIND -@section @code{SELECTED_INT_KIND} --- Choose integer kind -@fnindex SELECTED_INT_KIND -@cindex integer kind -@cindex kind, integer - -@table @asis -@item @emph{Description}: -@code{SELECTED_INT_KIND(R)} return the kind value of the smallest integer -type that can represent all values ranging from @math{-10^R} (exclusive) -to @math{10^R} (exclusive). If there is no integer kind that accommodates -this range, @code{SELECTED_INT_KIND} returns @math{-1}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = SELECTED_INT_KIND(R)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{R} @tab Shall be a scalar and of type @code{INTEGER}. -@end multitable - -@item @emph{Example}: -@smallexample -program large_integers - integer,parameter :: k5 = selected_int_kind(5) - integer,parameter :: k15 = selected_int_kind(15) - integer(kind=k5) :: i5 - integer(kind=k15) :: i15 - - print *, huge(i5), huge(i15) - - ! The following inequalities are always true - print *, huge(i5) >= 10_k5**5-1 - print *, huge(i15) >= 10_k15**15-1 -end program large_integers -@end smallexample -@end table - - - -@node SELECTED_REAL_KIND -@section @code{SELECTED_REAL_KIND} --- Choose real kind -@fnindex SELECTED_REAL_KIND -@cindex real kind -@cindex kind, real -@cindex radix, real - -@table @asis -@item @emph{Description}: -@code{SELECTED_REAL_KIND(P,R)} returns the kind value of a real data type -with decimal precision of at least @code{P} digits, exponent range of -at least @code{R}, and with a radix of @code{RADIX}. - -@item @emph{Standard}: -Fortran 90 and later, with @code{RADIX} Fortran 2008 or later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = SELECTED_REAL_KIND([P, R, RADIX])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}. -@item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}. -@item @var{RADIX} @tab (Optional) shall be a scalar and of type @code{INTEGER}. -@end multitable -Before Fortran 2008, at least one of the arguments @var{R} or @var{P} shall -be present; since Fortran 2008, they are assumed to be zero if absent. - -@item @emph{Return value}: - -@code{SELECTED_REAL_KIND} returns the value of the kind type parameter of -a real data type with decimal precision of at least @code{P} digits, a -decimal exponent range of at least @code{R}, and with the requested -@code{RADIX}. If the @code{RADIX} parameter is absent, real kinds with -any radix can be returned. If more than one real data type meet the -criteria, the kind of the data type with the smallest decimal precision -is returned. If no real data type matches the criteria, the result is -@table @asis -@item -1 if the processor does not support a real data type with a -precision greater than or equal to @code{P}, but the @code{R} and -@code{RADIX} requirements can be fulfilled -@item -2 if the processor does not support a real type with an exponent -range greater than or equal to @code{R}, but @code{P} and @code{RADIX} -are fulfillable -@item -3 if @code{RADIX} but not @code{P} and @code{R} requirements -are fulfillable -@item -4 if @code{RADIX} and either @code{P} or @code{R} requirements -are fulfillable -@item -5 if there is no real type with the given @code{RADIX} -@end table - -@item @emph{Example}: -@smallexample -program real_kinds - integer,parameter :: p6 = selected_real_kind(6) - integer,parameter :: p10r100 = selected_real_kind(10,100) - integer,parameter :: r400 = selected_real_kind(r=400) - real(kind=p6) :: x - real(kind=p10r100) :: y - real(kind=r400) :: z - - print *, precision(x), range(x) - print *, precision(y), range(y) - print *, precision(z), range(z) -end program real_kinds -@end smallexample -@item @emph{See also}: -@ref{PRECISION}, @gol -@ref{RANGE}, @gol -@ref{RADIX} -@end table - - - -@node SET_EXPONENT -@section @code{SET_EXPONENT} --- Set the exponent of the model -@fnindex SET_EXPONENT -@cindex real number, set exponent -@cindex floating point, set exponent - -@table @asis -@item @emph{Description}: -@code{SET_EXPONENT(X, I)} returns the real number whose fractional part -is that of @var{X} and whose exponent part is @var{I}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = SET_EXPONENT(X, I)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab Shall be of type @code{REAL}. -@item @var{I} @tab Shall be of type @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of the same type and kind as @var{X}. -The real number whose fractional part -is that of @var{X} and whose exponent part if @var{I} is returned; -it is @code{FRACTION(X) * RADIX(X)**I}. - -@item @emph{Example}: -@smallexample -PROGRAM test_setexp - REAL :: x = 178.1387e-4 - INTEGER :: i = 17 - PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i -END PROGRAM -@end smallexample - -@end table - - - -@node SHAPE -@section @code{SHAPE} --- Determine the shape of an array -@fnindex SHAPE -@cindex array, shape - -@table @asis -@item @emph{Description}: -Determines the shape of an array. - -@item @emph{Standard}: -Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = SHAPE(SOURCE [, KIND])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{SOURCE} @tab Shall be an array or scalar of any type. -If @var{SOURCE} is a pointer it must be associated and allocatable -arrays must be allocated. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -An @code{INTEGER} array of rank one with as many elements as @var{SOURCE} -has dimensions. The elements of the resulting array correspond to the extend -of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar, -the result is the rank one array of size zero. If @var{KIND} is absent, the -return value has the default integer kind otherwise the specified kind. - -@item @emph{Example}: -@smallexample -PROGRAM test_shape - INTEGER, DIMENSION(-1:1, -1:2) :: A - WRITE(*,*) SHAPE(A) ! (/ 3, 4 /) - WRITE(*,*) SIZE(SHAPE(42)) ! (/ /) -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{RESHAPE}, @gol -@ref{SIZE} -@end table - - - -@node SHIFTA -@section @code{SHIFTA} --- Right shift with fill -@fnindex SHIFTA -@cindex bits, shift right -@cindex shift, right with fill - -@table @asis -@item @emph{Description}: -@code{SHIFTA} returns a value corresponding to @var{I} with all of the -bits shifted right by @var{SHIFT} places. @var{SHIFT} that be -nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise -the result value is undefined. Bits shifted out from the right end -are lost. The fill is arithmetic: the bits shifted in from the left -end are equal to the leftmost bit, which in two's complement -representation is the sign bit. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = SHIFTA(I, SHIFT)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER}. -@item @var{SHIFT} @tab The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the same kind as -@var{I}. - -@item @emph{See also}: -@ref{SHIFTL}, @gol -@ref{SHIFTR} -@end table - - - -@node SHIFTL -@section @code{SHIFTL} --- Left shift -@fnindex SHIFTL -@cindex bits, shift left -@cindex shift, left - -@table @asis -@item @emph{Description}: -@code{SHIFTL} returns a value corresponding to @var{I} with all of the -bits shifted left by @var{SHIFT} places. @var{SHIFT} shall be -nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise -the result value is undefined. Bits shifted out from the left end are -lost, and bits shifted in from the right end are set to 0. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = SHIFTL(I, SHIFT)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER}. -@item @var{SHIFT} @tab The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the same kind as -@var{I}. - -@item @emph{See also}: -@ref{SHIFTA}, @gol -@ref{SHIFTR} -@end table - - - -@node SHIFTR -@section @code{SHIFTR} --- Right shift -@fnindex SHIFTR -@cindex bits, shift right -@cindex shift, right - -@table @asis -@item @emph{Description}: -@code{SHIFTR} returns a value corresponding to @var{I} with all of the -bits shifted right by @var{SHIFT} places. @var{SHIFT} shall be -nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise -the result value is undefined. Bits shifted out from the right end -are lost, and bits shifted in from the left end are set to 0. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = SHIFTR(I, SHIFT)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be @code{INTEGER}. -@item @var{SHIFT} @tab The type shall be @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of the same kind as -@var{I}. - -@item @emph{See also}: -@ref{SHIFTA}, @gol -@ref{SHIFTL} -@end table - - - -@node SIGN -@section @code{SIGN} --- Sign copying function -@fnindex SIGN -@fnindex ISIGN -@fnindex DSIGN -@cindex sign copying - -@table @asis -@item @emph{Description}: -@code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = SIGN(A, B)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL} -@item @var{B} @tab Shall be of the same type and kind as @var{A}. -@end multitable - -@item @emph{Return value}: -The kind of the return value is that of @var{A} and @var{B}. -If @math{B \ge 0} then the result is @code{ABS(A)}, else -it is @code{-ABS(A)}. - -@item @emph{Example}: -@smallexample -program test_sign - print *, sign(-12,1) - print *, sign(-12,0) - print *, sign(-12,-1) - - print *, sign(-12.,1.) - print *, sign(-12.,0.) - print *, sign(-12.,-1.) -end program test_sign -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .26 .20 .30 -@headitem Name @tab Arguments @tab Return type @tab Standard -@item @code{SIGN(A,B)} @tab @code{REAL(4) A, B} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{ISIGN(A,B)} @tab @code{INTEGER(4) A, B} @tab @code{INTEGER(4)} @tab Fortran 77 and later -@item @code{DSIGN(A,B)} @tab @code{REAL(8) A, B} @tab @code{REAL(8)} @tab Fortran 77 and later -@end multitable -@end table - - - -@node SIGNAL -@section @code{SIGNAL} --- Signal handling subroutine (or function) -@fnindex SIGNAL -@cindex system, signal handling - -@table @asis -@item @emph{Description}: -@code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine -@var{HANDLER} to be executed with a single integer argument when signal -@var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to -turn off handling of signal @var{NUMBER} or revert to its default -action. See @code{signal(2)}. - -If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument -is supplied, it is set to the value returned by @code{signal(2)}. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])} -@item @code{STATUS = SIGNAL(NUMBER, HANDLER)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)} -@item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or -@code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. -@code{INTEGER}. It is @code{INTENT(IN)}. -@item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar -integer. It has @code{INTENT(OUT)}. -@end multitable -@c TODO: What should the interface of the handler be? Does it take arguments? - -@item @emph{Return value}: -The @code{SIGNAL} function returns the value returned by @code{signal(2)}. - -@item @emph{Example}: -@smallexample -program test_signal - intrinsic signal - external handler_print - - call signal (12, handler_print) - call signal (10, 1) - - call sleep (30) -end program test_signal -@end smallexample -@end table - - - -@node SIN -@section @code{SIN} --- Sine function -@fnindex SIN -@fnindex DSIN -@fnindex CSIN -@fnindex ZSIN -@fnindex CDSIN -@cindex trigonometric function, sine -@cindex sine - -@table @asis -@item @emph{Description}: -@code{SIN(X)} computes the sine of @var{X}. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = SIN(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or -@code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value has same type and kind as @var{X}. - -@item @emph{Example}: -@smallexample -program test_sin - real :: x = 0.0 - x = sin(x) -end program test_sin -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{SIN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later -@item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later -@item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension -@item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -Inverse function: @gol -@ref{ASIN} @gol -Degrees function: @gol -@ref{SIND} -@end table - - - -@node SIND -@section @code{SIND} --- Sine function, degrees -@fnindex SIND -@fnindex DSIND -@fnindex CSIND -@fnindex ZSIND -@fnindex CDSIND -@cindex trigonometric function, sine, degrees -@cindex sine, degrees - -@table @asis -@item @emph{Description}: -@code{SIND(X)} computes the sine of @var{X} in degrees. - -This function is for compatibility only and should be avoided in favor of -standard constructs wherever possible. - -@item @emph{Standard}: -GNU extension, enabled with @option{-fdec-math}. - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = SIND(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or -@code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value has same type and kind as @var{X}, and its value is in degrees. - -@item @emph{Example}: -@smallexample -program test_sind - real :: x = 0.0 - x = sind(x) -end program test_sind -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{SIND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension -@item @code{DSIND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@item @code{CSIND(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab GNU extension -@item @code{ZSIND(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension -@item @code{CDSIND(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -Inverse function: @gol -@ref{ASIND} @gol -Radians function: @gol -@ref{SIN} @gol -@end table - - - -@node SINH -@section @code{SINH} --- Hyperbolic sine function -@fnindex SINH -@fnindex DSINH -@cindex hyperbolic sine -@cindex hyperbolic function, sine -@cindex sine, hyperbolic - -@table @asis -@item @emph{Description}: -@code{SINH(X)} computes the hyperbolic sine of @var{X}. - -@item @emph{Standard}: -Fortran 90 and later, for a complex argument Fortran 2008 or later, has -a GNU extension - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = SINH(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value has same type and kind as @var{X}. - -@item @emph{Example}: -@smallexample -program test_sinh - real(8) :: x = - 1.0_8 - x = sinh(x) -end program test_sinh -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 90 and later -@end multitable - -@item @emph{See also}: -@ref{ASINH} -@end table - - - -@node SIZE -@section @code{SIZE} --- Determine the size of an array -@fnindex SIZE -@cindex array, size -@cindex array, number of elements -@cindex array, count elements - -@table @asis -@item @emph{Description}: -Determine the extent of @var{ARRAY} along a specified dimension @var{DIM}, -or the total number of elements in @var{ARRAY} if @var{DIM} is absent. - -@item @emph{Standard}: -Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = SIZE(ARRAY[, DIM [, KIND]])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is -a pointer it must be associated and allocatable arrays must be allocated. -@item @var{DIM} @tab (Optional) shall be a scalar of type @code{INTEGER} -and its value shall be in the range from 1 to n, where n equals the rank -of @var{ARRAY}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of kind @var{KIND}. If -@var{KIND} is absent, the return value is of default integer kind. - -@item @emph{Example}: -@smallexample -PROGRAM test_size - WRITE(*,*) SIZE((/ 1, 2 /)) ! 2 -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{SHAPE}, @gol -@ref{RESHAPE} -@end table - - -@node SIZEOF -@section @code{SIZEOF} --- Size in bytes of an expression -@fnindex SIZEOF -@cindex expression size -@cindex size of an expression - -@table @asis -@item @emph{Description}: -@code{SIZEOF(X)} calculates the number of bytes of storage the -expression @code{X} occupies. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{N = SIZEOF(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The argument shall be of any type, rank or shape. -@end multitable - -@item @emph{Return value}: -The return value is of type integer and of the system-dependent kind -@var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the -number of bytes occupied by the argument. If the argument has the -@code{POINTER} attribute, the number of bytes of the storage area pointed -to is returned. If the argument is of a derived type with @code{POINTER} -or @code{ALLOCATABLE} components, the return value does not account for -the sizes of the data pointed to by these components. If the argument is -polymorphic, the size according to the dynamic type is returned. The argument -may not be a procedure or procedure pointer. Note that the code assumes for -arrays that those are contiguous; for contiguous arrays, it returns the -storage or an array element multiplied by the size of the array. - -@item @emph{Example}: -@smallexample - integer :: i - real :: r, s(5) - print *, (sizeof(s)/sizeof(r) == 5) - end -@end smallexample -The example will print @code{.TRUE.} unless you are using a platform -where default @code{REAL} variables are unusually padded. - -@item @emph{See also}: -@ref{C_SIZEOF}, @gol -@ref{STORAGE_SIZE} -@end table - - -@node SLEEP -@section @code{SLEEP} --- Sleep for the specified number of seconds -@fnindex SLEEP -@cindex delayed execution - -@table @asis -@item @emph{Description}: -Calling this subroutine causes the process to pause for @var{SECONDS} seconds. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL SLEEP(SECONDS)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{SECONDS} @tab The type shall be of default @code{INTEGER}. -@end multitable - -@item @emph{Example}: -@smallexample -program test_sleep - call sleep(5) -end -@end smallexample -@end table - - - -@node SPACING -@section @code{SPACING} --- Smallest distance between two numbers of a given type -@fnindex SPACING -@cindex real number, relative spacing -@cindex floating point, relative spacing - -@table @asis -@item @emph{Description}: -Determines the distance between the argument @var{X} and the nearest -adjacent number of the same type. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = SPACING(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab Shall be of type @code{REAL}. -@end multitable - -@item @emph{Return value}: -The result is of the same type as the input argument @var{X}. - -@item @emph{Example}: -@smallexample -PROGRAM test_spacing - INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37) - INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200) - - WRITE(*,*) spacing(1.0_SGL) ! "1.1920929E-07" on i686 - WRITE(*,*) spacing(1.0_DBL) ! "2.220446049250313E-016" on i686 -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{RRSPACING} -@end table - - - -@node SPREAD -@section @code{SPREAD} --- Add a dimension to an array -@fnindex SPREAD -@cindex array, increase dimension -@cindex array, duplicate elements -@cindex array, duplicate dimensions - -@table @asis -@item @emph{Description}: -Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified -dimension @var{DIM}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{SOURCE} @tab Shall be a scalar or an array of any type and -a rank less than seven. -@item @var{DIM} @tab Shall be a scalar of type @code{INTEGER} with a -value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}. -@item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The result is an array of the same type as @var{SOURCE} and has rank n+1 -where n equals the rank of @var{SOURCE}. - -@item @emph{Example}: -@smallexample -PROGRAM test_spread - INTEGER :: a = 1, b(2) = (/ 1, 2 /) - WRITE(*,*) SPREAD(A, 1, 2) ! "1 1" - WRITE(*,*) SPREAD(B, 1, 2) ! "1 1 2 2" -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{UNPACK} -@end table - - - -@node SQRT -@section @code{SQRT} --- Square-root function -@fnindex SQRT -@fnindex DSQRT -@fnindex CSQRT -@fnindex ZSQRT -@fnindex CDSQRT -@cindex root -@cindex square-root - -@table @asis -@item @emph{Description}: -@code{SQRT(X)} computes the square root of @var{X}. - -@item @emph{Standard}: -Fortran 77 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = SQRT(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or -@code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{REAL} or @code{COMPLEX}. -The kind type parameter is the same as @var{X}. - -@item @emph{Example}: -@smallexample -program test_sqrt - real(8) :: x = 2.0_8 - complex :: z = (1.0, 2.0) - x = sqrt(x) - z = sqrt(z) -end program test_sqrt -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{SQRT(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later -@item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later -@item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension -@item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension -@end multitable -@end table - - - -@node SRAND -@section @code{SRAND} --- Reinitialize the random number generator -@fnindex SRAND -@cindex random number generation, seeding -@cindex seeding a random number generator - -@table @asis -@item @emph{Description}: -@code{SRAND} reinitializes the pseudo-random number generator -called by @code{RAND} and @code{IRAND}. The new seed used by the -generator is specified by the required argument @var{SEED}. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL SRAND(SEED)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}. -@end multitable - -@item @emph{Return value}: -Does not return anything. - -@item @emph{Example}: -See @code{RAND} and @code{IRAND} for examples. - -@item @emph{Notes}: -The Fortran standard specifies the intrinsic subroutines -@code{RANDOM_SEED} to initialize the pseudo-random number -generator and @code{RANDOM_NUMBER} to generate pseudo-random numbers. -These subroutines should be used in new codes. - -Please note that in GNU Fortran, these two sets of intrinsics (@code{RAND}, -@code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and -@code{RANDOM_SEED} on the other hand) access two independent -pseudo-random number generators. - -@item @emph{See also}: -@ref{RAND}, @gol -@ref{RANDOM_SEED}, @gol -@ref{RANDOM_NUMBER} -@end table - - - -@node STAT -@section @code{STAT} --- Get file status -@fnindex STAT -@cindex file system, file status - -@table @asis -@item @emph{Description}: -This function returns information about a file. No permissions are required on -the file itself, but execute (search) permission is required on all of the -directories in path that lead to the file. - -The elements that are obtained and stored in the array @code{VALUES}: -@multitable @columnfractions .15 .70 -@item @code{VALUES(1)} @tab Device ID -@item @code{VALUES(2)} @tab Inode number -@item @code{VALUES(3)} @tab File mode -@item @code{VALUES(4)} @tab Number of links -@item @code{VALUES(5)} @tab Owner's uid -@item @code{VALUES(6)} @tab Owner's gid -@item @code{VALUES(7)} @tab ID of device containing directory entry for file (0 if not available) -@item @code{VALUES(8)} @tab File size (bytes) -@item @code{VALUES(9)} @tab Last access time -@item @code{VALUES(10)} @tab Last modification time -@item @code{VALUES(11)} @tab Last file status change time -@item @code{VALUES(12)} @tab Preferred I/O block size (-1 if not available) -@item @code{VALUES(13)} @tab Number of blocks allocated (-1 if not available) -@end multitable - -Not all these elements are relevant on all systems. -If an element is not relevant, it is returned as 0. - -This intrinsic is provided in both subroutine and function forms; however, -only one form can be used in any given program unit. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL STAT(NAME, VALUES [, STATUS])} -@item @code{STATUS = STAT(NAME, VALUES)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{NAME} @tab The type shall be @code{CHARACTER}, of the -default kind and a valid path within the file system. -@item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}. -@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 -on success and a system specific error code otherwise. -@end multitable - -@item @emph{Example}: -@smallexample -PROGRAM test_stat - INTEGER, DIMENSION(13) :: buff - INTEGER :: status - - CALL STAT("/etc/passwd", buff, status) - - 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 -@end smallexample - -@item @emph{See also}: -To stat an open file: @gol -@ref{FSTAT} @gol -To stat a link: @gol -@ref{LSTAT} -@end table - - - -@node STORAGE_SIZE -@section @code{STORAGE_SIZE} --- Storage size in bits -@fnindex STORAGE_SIZE -@cindex storage size - -@table @asis -@item @emph{Description}: -Returns the storage size of argument @var{A} in bits. -@item @emph{Standard}: -Fortran 2008 and later -@item @emph{Class}: -Inquiry function -@item @emph{Syntax}: -@code{RESULT = STORAGE_SIZE(A [, KIND])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{A} @tab Shall be a scalar or array of any type. -@item @var{KIND} @tab (Optional) shall be a scalar integer constant expression. -@end multitable - -@item @emph{Return Value}: -The result is a scalar integer with the kind type parameter specified by KIND -(or default integer type if KIND is missing). The result value is the size -expressed in bits for an element of an array that has the dynamic type and type -parameters of A. - -@item @emph{See also}: -@ref{C_SIZEOF}, @gol -@ref{SIZEOF} -@end table - - - -@node SUM -@section @code{SUM} --- Sum of array elements -@fnindex SUM -@cindex array, sum -@cindex array, add elements -@cindex array, conditionally add elements -@cindex sum array elements - -@table @asis -@item @emph{Description}: -Adds the elements of @var{ARRAY} along dimension @var{DIM} if -the corresponding element in @var{MASK} is @code{TRUE}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = SUM(ARRAY[, MASK])} -@item @code{RESULT = SUM(ARRAY, DIM[, MASK])} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, -@code{REAL} or @code{COMPLEX}. -@item @var{DIM} @tab (Optional) shall be a scalar of type -@code{INTEGER} with a value in the range from 1 to n, where n -equals the rank of @var{ARRAY}. -@item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL} -and either be a scalar or an array of the same shape as @var{ARRAY}. -@end multitable - -@item @emph{Return value}: -The result is of the same type as @var{ARRAY}. - -If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY} -is returned. Otherwise, an array of rank n-1, where n equals the rank of -@var{ARRAY}, and a shape similar to that of @var{ARRAY} with dimension @var{DIM} -dropped is returned. - -@item @emph{Example}: -@smallexample -PROGRAM test_sum - INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /) - print *, SUM(x) ! all elements, sum = 15 - print *, SUM(x, MASK=MOD(x, 2)==1) ! odd elements, sum = 9 -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{PRODUCT} -@end table - - - -@node SYMLNK -@section @code{SYMLNK} --- Create a symbolic link -@fnindex SYMLNK -@cindex file system, create link -@cindex file system, soft link - -@table @asis -@item @emph{Description}: -Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null -character (@code{CHAR(0)}) can be used to mark the end of the names in -@var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file -names are ignored. If the @var{STATUS} argument is supplied, it -contains 0 on success or a nonzero error code upon return; see -@code{symlink(2)}. If the system does not supply @code{symlink(2)}, -@code{ENOSYS} is returned. - -This intrinsic is provided in both subroutine and function forms; -however, only one form can be used in any given program unit. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])} -@item @code{STATUS = SYMLNK(PATH1, PATH2)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{PATH1} @tab Shall be of default @code{CHARACTER} type. -@item @var{PATH2} @tab Shall be of default @code{CHARACTER} type. -@item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type. -@end multitable - -@item @emph{See also}: -@ref{LINK}, @gol -@ref{UNLINK} -@end table - - - -@node SYSTEM -@section @code{SYSTEM} --- Execute a shell command -@fnindex SYSTEM -@cindex system, system call - -@table @asis -@item @emph{Description}: -Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If -argument @var{STATUS} is present, it contains the value returned by -@code{system(3)}, which is presumably 0 if the shell command succeeded. -Note that which shell is used to invoke the command is system-dependent -and environment-dependent. - -This intrinsic is provided in both subroutine and function forms; -however, only one form can be used in any given program unit. - -Note that the @code{system} function need not be thread-safe. It is -the responsibility of the user to ensure that @code{system} is not -called concurrently. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL SYSTEM(COMMAND [, STATUS])} -@item @code{STATUS = SYSTEM(COMMAND)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type. -@item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type. -@end multitable - -@item @emph{See also}: -@ref{EXECUTE_COMMAND_LINE}, which is part of the Fortran 2008 standard -and should considered in new code for future portability. -@end table - - - -@node SYSTEM_CLOCK -@section @code{SYSTEM_CLOCK} --- Time function -@fnindex SYSTEM_CLOCK -@cindex time, clock ticks -@cindex clock ticks - -@table @asis -@item @emph{Description}: -Determines the @var{COUNT} of a processor clock since an unspecified -time in the past modulo @var{COUNT_MAX}, @var{COUNT_RATE} determines -the number of clock ticks per second. If the platform supports a -monotonic clock, that clock is used and can, depending on the platform -clock implementation, provide up to nanosecond resolution. If a -monotonic clock is not available, the implementation falls back to a -realtime clock. - -@var{COUNT_RATE} is system dependent and can vary depending on the kind of -the arguments. For @var{kind=4} arguments (and smaller integer kinds), -@var{COUNT} represents milliseconds, while for @var{kind=8} arguments (and -larger integer kinds), @var{COUNT} typically represents micro- or -nanoseconds depending on resolution of the underlying platform clock. -@var{COUNT_MAX} usually equals @code{HUGE(COUNT_MAX)}. Note that the -millisecond resolution of the @var{kind=4} version implies that the -@var{COUNT} will wrap around in roughly 25 days. In order to avoid issues -with the wrap around and for more precise timing, please use the -@var{kind=8} version. - -If there is no clock, or querying the clock fails, @var{COUNT} is set -to @code{-HUGE(COUNT)}, and @var{COUNT_RATE} and @var{COUNT_MAX} are -set to zero. - -When running on a platform using the GNU C library (glibc) version -2.16 or older, or a derivative thereof, the high resolution monotonic -clock is available only when linking with the @var{rt} library. This -can be done explicitly by adding the @code{-lrt} flag when linking the -application, but is also done implicitly when using OpenMP. - -On the Windows platform, the version with @var{kind=4} arguments uses -the @code{GetTickCount} function, whereas the @var{kind=8} version -uses @code{QueryPerformanceCounter} and -@code{QueryPerformanceCounterFrequency}. For more information, and -potential caveats, please see the platform documentation. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Subroutine - -@item @emph{Syntax}: -@code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])} - -@item @emph{Arguments}: -@multitable @columnfractions .20 .65 -@item @var{COUNT} @tab (Optional) shall be a scalar of type -@code{INTEGER} with @code{INTENT(OUT)}. -@item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type -@code{INTEGER} or @code{REAL}, with @code{INTENT(OUT)}. -@item @var{COUNT_MAX} @tab (Optional) shall be a scalar of type -@code{INTEGER} with @code{INTENT(OUT)}. -@end multitable - -@item @emph{Example}: -@smallexample -PROGRAM test_system_clock - INTEGER :: count, count_rate, count_max - CALL SYSTEM_CLOCK(count, count_rate, count_max) - WRITE(*,*) count, count_rate, count_max -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{DATE_AND_TIME}, @gol -@ref{CPU_TIME} -@end table - - - -@node TAN -@section @code{TAN} --- Tangent function -@fnindex TAN -@fnindex DTAN -@cindex trigonometric function, tangent -@cindex tangent - -@table @asis -@item @emph{Description}: -@code{TAN(X)} computes the tangent of @var{X}. - -@item @emph{Standard}: -Fortran 77 and later, for a complex argument Fortran 2008 or later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = TAN(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value has same type and kind as @var{X}, and its value is in radians. - -@item @emph{Example}: -@smallexample -program test_tan - real(8) :: x = 0.165_8 - x = tan(x) -end program test_tan -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{TAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later -@end multitable - -@item @emph{See also}: -Inverse function: @gol -@ref{ATAN} @gol -Degrees function: @gol -@ref{TAND} -@end table - - - -@node TAND -@section @code{TAND} --- Tangent function, degrees -@fnindex TAND -@fnindex DTAND -@cindex trigonometric function, tangent, degrees -@cindex tangent, degrees - -@table @asis -@item @emph{Description}: -@code{TAND(X)} computes the tangent of @var{X} in degrees. - -This function is for compatibility only and should be avoided in favor of -standard constructs wherever possible. - -@item @emph{Standard}: -GNU extension, enabled with @option{-fdec-math}. - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = TAND(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value has same type and kind as @var{X}, and its value is in degrees. - -@item @emph{Example}: -@smallexample -program test_tand - real(8) :: x = 0.165_8 - x = tand(x) -end program test_tand -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{TAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension -@item @code{DTAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension -@end multitable - -@item @emph{See also}: -Inverse function: @gol -@ref{ATAND} @gol -Radians function: @gol -@ref{TAN} -@end table - - - -@node TANH -@section @code{TANH} --- Hyperbolic tangent function -@fnindex TANH -@fnindex DTANH -@cindex hyperbolic tangent -@cindex hyperbolic function, tangent -@cindex tangent, hyperbolic - -@table @asis -@item @emph{Description}: -@code{TANH(X)} computes the hyperbolic tangent of @var{X}. - -@item @emph{Standard}: -Fortran 77 and later, for a complex argument Fortran 2008 or later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{X = TANH(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. -@end multitable - -@item @emph{Return value}: -The return value has same type and kind as @var{X}. If @var{X} is -complex, the imaginary part of the result is in radians. If @var{X} -is @code{REAL}, the return value lies in the range -@math{ - 1 \leq tanh(x) \leq 1 }. - -@item @emph{Example}: -@smallexample -program test_tanh - real(8) :: x = 2.1_8 - x = tanh(x) -end program test_tanh -@end smallexample - -@item @emph{Specific names}: -@multitable @columnfractions .20 .23 .20 .33 -@headitem Name @tab Argument @tab Return type @tab Standard -@item @code{TANH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later -@item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later -@end multitable - -@item @emph{See also}: -@ref{ATANH} -@end table - - - -@node THIS_IMAGE -@section @code{THIS_IMAGE} --- Function that returns the cosubscript index of this image -@fnindex THIS_IMAGE -@cindex coarray, @code{THIS_IMAGE} -@cindex images, index of this image - -@table @asis -@item @emph{Description}: -Returns the cosubscript for this image. - -@item @emph{Standard}: -Fortran 2008 and later. With @var{DISTANCE} argument, -Technical Specification (TS) 18508 or later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{RESULT = THIS_IMAGE()} -@item @code{RESULT = THIS_IMAGE(DISTANCE)} -@item @code{RESULT = THIS_IMAGE(COARRAY [, DIM])} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{DISTANCE} @tab (optional, intent(in)) Nonnegative scalar integer -(not permitted together with @var{COARRAY}). -@item @var{COARRAY} @tab Coarray of any type (optional; if @var{DIM} -present, required). -@item @var{DIM} @tab default integer scalar (optional). If present, -@var{DIM} shall be between one and the corank of @var{COARRAY}. -@end multitable - - -@item @emph{Return value}: -Default integer. If @var{COARRAY} is not present, it is scalar; if -@var{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 @var{DISTANCE} from the invoking team. If -@var{DISTANCE} is larger than the distance to the initial team, the image -index of the initial team is returned. Otherwise when the @var{COARRAY} is -present, if @var{DIM} is not present, a rank-1 array with corank elements is -returned, containing the cosubscripts for @var{COARRAY} specifying the invoking -image. If @var{DIM} is present, a scalar is returned, with the value of -the @var{DIM} element of @code{THIS_IMAGE(COARRAY)}. - -@item @emph{Example}: -@smallexample -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 - -! Check whether the current image is the initial image -IF (THIS_IMAGE(HUGE(1)) /= THIS_IMAGE()) - error stop "something is rotten here" -@end smallexample - -@item @emph{See also}: -@ref{NUM_IMAGES}, @gol -@ref{IMAGE_INDEX} -@end table - - - -@node TIME -@section @code{TIME} --- Time function -@fnindex TIME -@cindex time, current -@cindex current time - -@table @asis -@item @emph{Description}: -Returns the current time encoded as an integer (in the manner of the -function @code{time(3)} in the C standard library). This value is -suitable for passing to @ref{CTIME}, @ref{GMTIME}, and @ref{LTIME}. - -This intrinsic is not fully portable, such as to systems with 32-bit -@code{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 @ref{TIME8}, for information on a similar intrinsic that might be -portable to more GNU Fortran implementations, though to fewer Fortran -compilers. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{RESULT = TIME()} - -@item @emph{Return value}: -The return value is a scalar of type @code{INTEGER(4)}. - -@item @emph{See also}: -@ref{DATE_AND_TIME}, @gol -@ref{CTIME}, @gol -@ref{GMTIME}, @gol -@ref{LTIME}, @gol -@ref{MCLOCK}, @gol -@ref{TIME8} -@end table - - - -@node TIME8 -@section @code{TIME8} --- Time function (64-bit) -@fnindex TIME8 -@cindex time, current -@cindex current time - -@table @asis -@item @emph{Description}: -Returns the current time encoded as an integer (in the manner of the -function @code{time(3)} in the C standard library). This value is -suitable for passing to @ref{CTIME}, @ref{GMTIME}, and @ref{LTIME}. - -@emph{Warning:} this intrinsic does not increase the range of the timing -values over that returned by @code{time(3)}. On a system with a 32-bit -@code{time(3)}, @code{TIME8} will return a 32-bit value, even though -it is converted to a 64-bit @code{INTEGER(8)} value. That means -overflows of the 32-bit value can still occur. 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. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{RESULT = TIME8()} - -@item @emph{Return value}: -The return value is a scalar of type @code{INTEGER(8)}. - -@item @emph{See also}: -@ref{DATE_AND_TIME}, @gol -@ref{CTIME}, @gol -@ref{GMTIME}, @gol -@ref{LTIME}, @gol -@ref{MCLOCK8}, @gol -@ref{TIME} -@end table - - - -@node TINY -@section @code{TINY} --- Smallest positive number of a real kind -@fnindex TINY -@cindex limits, smallest number -@cindex model representation, smallest number - -@table @asis -@item @emph{Description}: -@code{TINY(X)} returns the smallest positive (non zero) number -in the model of the type of @code{X}. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = TINY(X)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{X} @tab Shall be of type @code{REAL}. -@end multitable - -@item @emph{Return value}: -The return value is of the same type and kind as @var{X} - -@item @emph{Example}: -See @code{HUGE} for an example. -@end table - - - -@node TRAILZ -@section @code{TRAILZ} --- Number of trailing zero bits of an integer -@fnindex TRAILZ -@cindex zero bits - -@table @asis -@item @emph{Description}: -@code{TRAILZ} returns the number of trailing zero bits of an integer. - -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = TRAILZ(I)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab Shall be of type @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The type of the return value is the default @code{INTEGER}. -If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}. - -@item @emph{Example}: -@smallexample -PROGRAM test_trailz - WRITE (*,*) TRAILZ(8) ! prints 3 -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{BIT_SIZE}, @gol -@ref{LEADZ}, @gol -@ref{POPPAR}, @gol -@ref{POPCNT} -@end table - - - -@node TRANSFER -@section @code{TRANSFER} --- Transfer bit patterns -@fnindex TRANSFER -@cindex bits, move -@cindex type cast - -@table @asis -@item @emph{Description}: -Interprets the bitwise representation of @var{SOURCE} in memory as if it -is the representation of a variable or array of the same type and type -parameters as @var{MOLD}. - -This is approximately equivalent to the C concept of @emph{casting} one -type to another. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{SOURCE} @tab Shall be a scalar or an array of any type. -@item @var{MOLD} @tab Shall be a scalar or an array of any type. -@item @var{SIZE} @tab (Optional) shall be a scalar of type -@code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The result has the same type as @var{MOLD}, with the bit level -representation of @var{SOURCE}. If @var{SIZE} is present, the result is -a one-dimensional array of length @var{SIZE}. If @var{SIZE} is absent -but @var{MOLD} is an array (of any size or shape), the result is a one- -dimensional array of the minimum length needed to contain the entirety -of the bitwise representation of @var{SOURCE}. If @var{SIZE} is absent -and @var{MOLD} is a scalar, the result is a scalar. - -If the bitwise representation of the result is longer than that of -@var{SOURCE}, then the leading bits of the result correspond to those of -@var{SOURCE} and any trailing bits are filled arbitrarily. - -When the resulting bit representation does not correspond to a valid -representation of a variable of the same type as @var{MOLD}, the results -are undefined, and subsequent operations on the result cannot be -guaranteed to produce sensible behavior. For example, it is possible to -create @code{LOGICAL} variables for which @code{@var{VAR}} and -@code{.NOT.@var{VAR}} both appear to be true. - -@item @emph{Example}: -@smallexample -PROGRAM test_transfer - integer :: x = 2143289344 - print *, transfer(x, 1.0) ! prints "NaN" on i686 -END PROGRAM -@end smallexample -@end table - - - -@node TRANSPOSE -@section @code{TRANSPOSE} --- Transpose an array of rank two -@fnindex TRANSPOSE -@cindex array, transpose -@cindex matrix, transpose -@cindex transpose - -@table @asis -@item @emph{Description}: -Transpose an array of rank two. Element (i, j) of the result has the value -@code{MATRIX(j, i)}, for all i, j. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = TRANSPOSE(MATRIX)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{MATRIX} @tab Shall be an array of any type and have a rank of two. -@end multitable - -@item @emph{Return value}: -The result has the same type as @var{MATRIX}, and has shape -@code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}. -@end table - - - -@node TRIM -@section @code{TRIM} --- Remove trailing blank characters of a string -@fnindex TRIM -@cindex string, remove trailing whitespace - -@table @asis -@item @emph{Description}: -Removes trailing blank characters of a string. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = TRIM(STRING)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}. -@end multitable - -@item @emph{Return value}: -A scalar of type @code{CHARACTER} which length is that of @var{STRING} -less the number of trailing blanks. - -@item @emph{Example}: -@smallexample -PROGRAM test_trim - CHARACTER(len=10), PARAMETER :: s = "GFORTRAN " - WRITE(*,*) LEN(s), LEN(TRIM(s)) ! "10 8", with/without trailing blanks -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{ADJUSTL}, @gol -@ref{ADJUSTR} -@end table - - - -@node TTYNAM -@section @code{TTYNAM} --- Get the name of a terminal device -@fnindex TTYNAM -@cindex system, terminal - -@table @asis -@item @emph{Description}: -Get the name of a terminal device. For more information, -see @code{ttyname(3)}. - -This intrinsic is provided in both subroutine and function forms; -however, only one form can be used in any given program unit. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL TTYNAM(UNIT, NAME)} -@item @code{NAME = TTYNAM(UNIT)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{UNIT} @tab Shall be a scalar @code{INTEGER}. -@item @var{NAME} @tab Shall be of type @code{CHARACTER}. -@end multitable - -@item @emph{Example}: -@smallexample -PROGRAM test_ttynam - INTEGER :: unit - DO unit = 1, 10 - IF (isatty(unit=unit)) write(*,*) ttynam(unit) - END DO -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{ISATTY} -@end table - - - -@node UBOUND -@section @code{UBOUND} --- Upper dimension bounds of an array -@fnindex UBOUND -@cindex array, upper bound - -@table @asis -@item @emph{Description}: -Returns the upper bounds of an array, or a single upper bound -along the @var{DIM} dimension. -@item @emph{Standard}: -Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an array, of any type. -@item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}. -@item @var{KIND}@tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of kind @var{KIND}. If -@var{KIND} is absent, the return value is of default integer kind. -If @var{DIM} is absent, the result is an array of the upper bounds of -@var{ARRAY}. If @var{DIM} is present, the result is a scalar -corresponding to the upper bound of the array along that dimension. If -@var{ARRAY} is an expression rather than a whole array or array -structure component, or if it has a zero extent along the relevant -dimension, the upper bound is taken to be the number of elements along -the relevant dimension. - -@item @emph{See also}: -@ref{LBOUND}, @gol -@ref{LCOBOUND} -@end table - - - -@node UCOBOUND -@section @code{UCOBOUND} --- Upper codimension bounds of an array -@fnindex UCOBOUND -@cindex coarray, upper bound - -@table @asis -@item @emph{Description}: -Returns the upper cobounds of a coarray, or a single upper cobound -along the @var{DIM} codimension. -@item @emph{Standard}: -Fortran 2008 and later - -@item @emph{Class}: -Inquiry function - -@item @emph{Syntax}: -@code{RESULT = UCOBOUND(COARRAY [, DIM [, KIND]])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{ARRAY} @tab Shall be an coarray, of any type. -@item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of kind @var{KIND}. If -@var{KIND} is absent, the return value is of default integer kind. -If @var{DIM} is absent, the result is an array of the lower cobounds of -@var{COARRAY}. If @var{DIM} is present, the result is a scalar -corresponding to the lower cobound of the array along that codimension. - -@item @emph{See also}: -@ref{LCOBOUND}, @gol -@ref{LBOUND} -@end table - - - -@node UMASK -@section @code{UMASK} --- Set the file creation mask -@fnindex UMASK -@cindex file system, file creation mask - -@table @asis -@item @emph{Description}: -Sets the file creation mask to @var{MASK}. If called as a function, it -returns the old value. If called as a subroutine and argument @var{OLD} -if it is supplied, it is set to the old value. See @code{umask(2)}. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL UMASK(MASK [, OLD])} -@item @code{OLD = UMASK(MASK)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{MASK} @tab Shall be a scalar of type @code{INTEGER}. -@item @var{OLD} @tab (Optional) Shall be a scalar of type -@code{INTEGER}. -@end multitable - -@end table - - - -@node UNLINK -@section @code{UNLINK} --- Remove a file from the file system -@fnindex UNLINK -@cindex file system, remove file - -@table @asis -@item @emph{Description}: -Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be -used to mark the end of the name in @var{PATH}; otherwise, trailing -blanks in the file name are ignored. If the @var{STATUS} argument is -supplied, it contains 0 on success or a nonzero error code upon return; -see @code{unlink(2)}. - -This intrinsic is provided in both subroutine and function forms; -however, only one form can be used in any given program unit. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Subroutine, function - -@item @emph{Syntax}: -@multitable @columnfractions .80 -@item @code{CALL UNLINK(PATH [, STATUS])} -@item @code{STATUS = UNLINK(PATH)} -@end multitable - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{PATH} @tab Shall be of default @code{CHARACTER} type. -@item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type. -@end multitable - -@item @emph{See also}: -@ref{LINK}, @gol -@ref{SYMLNK} -@end table - - - -@node UNPACK -@section @code{UNPACK} --- Unpack an array of rank one into an array -@fnindex UNPACK -@cindex array, unpacking -@cindex array, increase dimension -@cindex array, scatter elements - -@table @asis -@item @emph{Description}: -Store the elements of @var{VECTOR} in an array of higher rank. - -@item @emph{Standard}: -Fortran 90 and later - -@item @emph{Class}: -Transformational function - -@item @emph{Syntax}: -@code{RESULT = UNPACK(VECTOR, MASK, FIELD)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{VECTOR} @tab Shall be an array of any type and rank one. It -shall have at least as many elements as @var{MASK} has @code{TRUE} values. -@item @var{MASK} @tab Shall be an array of type @code{LOGICAL}. -@item @var{FIELD} @tab Shall be of the same type as @var{VECTOR} and have -the same shape as @var{MASK}. -@end multitable - -@item @emph{Return value}: -The resulting array corresponds to @var{FIELD} with @code{TRUE} elements -of @var{MASK} replaced by values from @var{VECTOR} in array element order. - -@item @emph{Example}: -@smallexample -PROGRAM test_unpack - integer :: vector(2) = (/1,1/) - logical :: mask(4) = (/ .TRUE., .FALSE., .FALSE., .TRUE. /) - integer :: field(2,2) = 0, unity(2,2) - - ! result: unity matrix - unity = unpack(vector, reshape(mask, (/2,2/)), field) -END PROGRAM -@end smallexample - -@item @emph{See also}: -@ref{PACK}, @gol -@ref{SPREAD} -@end table - - - -@node VERIFY -@section @code{VERIFY} --- Scan a string for characters not a given set -@fnindex VERIFY -@cindex string, find missing set - -@table @asis -@item @emph{Description}: -Verifies that all the characters in @var{STRING} belong to the set of -characters in @var{SET}. - -If @var{BACK} is either absent or equals @code{FALSE}, this function -returns the position of the leftmost character of @var{STRING} that is -not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost -position is returned. If all characters of @var{STRING} are found in -@var{SET}, the result is zero. - -@item @emph{Standard}: -Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later - -@item @emph{Class}: -Elemental function - -@item @emph{Syntax}: -@code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{STRING} @tab Shall be of type @code{CHARACTER}. -@item @var{SET} @tab Shall be of type @code{CHARACTER}. -@item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}. -@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization -expression indicating the kind parameter of the result. -@end multitable - -@item @emph{Return value}: -The return value is of type @code{INTEGER} and of kind @var{KIND}. If -@var{KIND} is absent, the return value is of default integer kind. - -@item @emph{Example}: -@smallexample -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 -@end smallexample - -@item @emph{See also}: -@ref{SCAN}, @gol -@ref{INDEX intrinsic} -@end table - - - -@node XOR -@section @code{XOR} --- Bitwise logical exclusive OR -@fnindex XOR -@cindex bitwise logical exclusive or -@cindex logical exclusive or, bitwise - -@table @asis -@item @emph{Description}: -Bitwise logical exclusive or. - -This intrinsic routine is provided for backwards compatibility with -GNU Fortran 77. For integer arguments, programmers should consider -the use of the @ref{IEOR} intrinsic and for logical arguments the -@code{.NEQV.} operator, which are both defined by the Fortran standard. - -@item @emph{Standard}: -GNU extension - -@item @emph{Class}: -Function - -@item @emph{Syntax}: -@code{RESULT = XOR(I, J)} - -@item @emph{Arguments}: -@multitable @columnfractions .15 .70 -@item @var{I} @tab The type shall be either a scalar @code{INTEGER} -type or a scalar @code{LOGICAL} type or a boz-literal-constant. -@item @var{J} @tab The type shall be the same as the type of @var{I} or -a boz-literal-constant. @var{I} and @var{J} shall not both be -boz-literal-constants. If either @var{I} and @var{J} is a -boz-literal-constant, then the other argument must be a scalar @code{INTEGER}. -@end multitable - -@item @emph{Return value}: -The return type is either a scalar @code{INTEGER} or a scalar -@code{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 @code{INTEGER} with the kind type parameter of -the other argument as-if a call to @ref{INT} occurred. - -@item @emph{Example}: -@smallexample -PROGRAM test_xor - LOGICAL :: T = .TRUE., F = .FALSE. - INTEGER :: a, b - DATA a / Z'F' /, b / Z'3' / - - WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F) - WRITE (*,*) XOR(a, b) -END PROGRAM -@end smallexample - -@item @emph{See also}: -Fortran 95 elemental function: @gol -@ref{IEOR} -@end table - - - -@node Intrinsic Modules -@chapter Intrinsic Modules -@cindex intrinsic Modules - -@menu -* ISO_FORTRAN_ENV:: -* ISO_C_BINDING:: -* IEEE modules:: -* OpenMP Modules OMP_LIB and OMP_LIB_KINDS:: -* OpenACC Module OPENACC:: -@end menu - -@node ISO_FORTRAN_ENV -@section @code{ISO_FORTRAN_ENV} -@table @asis -@item @emph{Standard}: -Fortran 2003 and later, except when otherwise noted -@end table - -The @code{ISO_FORTRAN_ENV} module provides the following scalar default-integer -named constants: - -@table @asis -@item @code{ATOMIC_INT_KIND}: -Default-kind integer constant to be used as kind parameter when defining -integer variables used in atomic operations. (Fortran 2008 or later.) - -@item @code{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.) - -@item @code{CHARACTER_KINDS}: -Default-kind integer constant array of rank one containing the supported kind -parameters of the @code{CHARACTER} type. (Fortran 2008 or later.) - -@item @code{CHARACTER_STORAGE_SIZE}: -Size in bits of the character storage unit. - -@item @code{ERROR_UNIT}: -Identifies the preconnected unit used for error reporting. - -@item @code{FILE_STORAGE_SIZE}: -Size in bits of the file-storage unit. - -@item @code{INPUT_UNIT}: -Identifies the preconnected unit identified by the asterisk -(@code{*}) in @code{READ} statement. - -@item @code{INT8}, @code{INT16}, @code{INT32}, @code{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.) - -@item @code{INTEGER_KINDS}: -Default-kind integer constant array of rank one containing the supported kind -parameters of the @code{INTEGER} type. (Fortran 2008 or later.) - -@item @code{IOSTAT_END}: -The value assigned to the variable passed to the @code{IOSTAT=} specifier of -an input/output statement if an end-of-file condition occurred. - -@item @code{IOSTAT_EOR}: -The value assigned to the variable passed to the @code{IOSTAT=} specifier of -an input/output statement if an end-of-record condition occurred. - -@item @code{IOSTAT_INQUIRE_INTERNAL_UNIT}: -Scalar default-integer constant, used by @code{INQUIRE} for the -@code{IOSTAT=} specifier to denote an that a unit number identifies an -internal unit. (Fortran 2008 or later.) - -@item @code{NUMERIC_STORAGE_SIZE}: -The size in bits of the numeric storage unit. - -@item @code{LOGICAL_KINDS}: -Default-kind integer constant array of rank one containing the supported kind -parameters of the @code{LOGICAL} type. (Fortran 2008 or later.) - -@item @code{OUTPUT_UNIT}: -Identifies the preconnected unit identified by the asterisk -(@code{*}) in @code{WRITE} statement. - -@item @code{REAL32}, @code{REAL64}, @code{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.) - -@item @code{REAL_KINDS}: -Default-kind integer constant array of rank one containing the supported kind -parameters of the @code{REAL} type. (Fortran 2008 or later.) - -@item @code{STAT_LOCKED}: -Scalar default-integer constant used as STAT= return value by @code{LOCK} to -denote that the lock variable is locked by the executing image. (Fortran 2008 -or later.) - -@item @code{STAT_LOCKED_OTHER_IMAGE}: -Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to -denote that the lock variable is locked by another image. (Fortran 2008 or -later.) - -@item @code{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.) - -@item @code{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.) - -@item @code{STAT_UNLOCKED}: -Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to -denote that the lock variable is unlocked. (Fortran 2008 or later.) -@end table - -The module provides the following derived type: - -@table @asis -@item @code{LOCK_TYPE}: -Derived type with private components to be use with the @code{LOCK} and -@code{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.) -@end table - -The module also provides the following intrinsic procedures: -@ref{COMPILER_OPTIONS} and @ref{COMPILER_VERSION}. - - - -@node ISO_C_BINDING -@section @code{ISO_C_BINDING} -@table @asis -@item @emph{Standard}: -Fortran 2003 and later, GNU extensions -@end table - -The following intrinsic procedures are provided by the module; their -definition can be found in the section Intrinsic Procedures of this -manual. - -@table @asis -@item @code{C_ASSOCIATED} -@item @code{C_F_POINTER} -@item @code{C_F_PROCPOINTER} -@item @code{C_FUNLOC} -@item @code{C_LOC} -@item @code{C_SIZEOF} -@end table -@c TODO: Vertical spacing between C_FUNLOC and C_LOC wrong in PDF, -@c don't really know why. - -The @code{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 @code{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: @code{C_INT128_T, C_INT_LEAST128_T, C_INT_FAST128_T}. -Furthermore, if @code{_Float128} is supported in C, the named constants -@code{C_FLOAT128} and @code{C_FLOAT128_COMPLEX} are defined. - -@multitable @columnfractions .19 .32 .34 .15 -@headitem Fortran Type @tab Named constant @tab C type @tab Extension -@item @code{INTEGER}@tab @code{C_INT} @tab @code{int} -@item @code{INTEGER}@tab @code{C_SHORT} @tab @code{short int} -@item @code{INTEGER}@tab @code{C_LONG} @tab @code{long int} -@item @code{INTEGER}@tab @code{C_LONG_LONG} @tab @code{long long int} -@item @code{INTEGER}@tab @code{C_SIGNED_CHAR} @tab @code{signed char}/@code{unsigned char} -@item @code{INTEGER}@tab @code{C_SIZE_T} @tab @code{size_t} -@item @code{INTEGER}@tab @code{C_INT8_T} @tab @code{int8_t} -@item @code{INTEGER}@tab @code{C_INT16_T} @tab @code{int16_t} -@item @code{INTEGER}@tab @code{C_INT32_T} @tab @code{int32_t} -@item @code{INTEGER}@tab @code{C_INT64_T} @tab @code{int64_t} -@item @code{INTEGER}@tab @code{C_INT128_T} @tab @code{int128_t} @tab Ext. -@item @code{INTEGER}@tab @code{C_INT_LEAST8_T} @tab @code{int_least8_t} -@item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t} -@item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t} -@item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t} -@item @code{INTEGER}@tab @code{C_INT_LEAST128_T}@tab @code{int_least128_t} @tab Ext. -@item @code{INTEGER}@tab @code{C_INT_FAST8_T} @tab @code{int_fast8_t} -@item @code{INTEGER}@tab @code{C_INT_FAST16_T} @tab @code{int_fast16_t} -@item @code{INTEGER}@tab @code{C_INT_FAST32_T} @tab @code{int_fast32_t} -@item @code{INTEGER}@tab @code{C_INT_FAST64_T} @tab @code{int_fast64_t} -@item @code{INTEGER}@tab @code{C_INT_FAST128_T} @tab @code{int_fast128_t} @tab Ext. -@item @code{INTEGER}@tab @code{C_INTMAX_T} @tab @code{intmax_t} -@item @code{INTEGER}@tab @code{C_INTPTR_T} @tab @code{intptr_t} -@item @code{INTEGER}@tab @code{C_PTRDIFF_T} @tab @code{ptrdiff_t} @tab TS 29113 -@item @code{REAL} @tab @code{C_FLOAT} @tab @code{float} -@item @code{REAL} @tab @code{C_DOUBLE} @tab @code{double} -@item @code{REAL} @tab @code{C_LONG_DOUBLE} @tab @code{long double} -@item @code{REAL} @tab @code{C_FLOAT128} @tab @code{_Float128} @tab Ext. -@item @code{COMPLEX}@tab @code{C_FLOAT_COMPLEX} @tab @code{float _Complex} -@item @code{COMPLEX}@tab @code{C_DOUBLE_COMPLEX}@tab @code{double _Complex} -@item @code{COMPLEX}@tab @code{C_LONG_DOUBLE_COMPLEX}@tab @code{long double _Complex} -@item @code{COMPLEX}@tab @code{C_FLOAT128_COMPLEX} @tab @code{_Float128 _Complex} @tab Ext. -@item @code{LOGICAL}@tab @code{C_BOOL} @tab @code{_Bool} -@item @code{CHARACTER}@tab @code{C_CHAR} @tab @code{char} -@end multitable - -Additionally, the following parameters of type @code{CHARACTER(KIND=C_CHAR)} -are defined. - -@multitable @columnfractions .20 .45 .15 -@headitem Name @tab C definition @tab Value -@item @code{C_NULL_CHAR} @tab null character @tab @code{'\0'} -@item @code{C_ALERT} @tab alert @tab @code{'\a'} -@item @code{C_BACKSPACE} @tab backspace @tab @code{'\b'} -@item @code{C_FORM_FEED} @tab form feed @tab @code{'\f'} -@item @code{C_NEW_LINE} @tab new line @tab @code{'\n'} -@item @code{C_CARRIAGE_RETURN} @tab carriage return @tab @code{'\r'} -@item @code{C_HORIZONTAL_TAB} @tab horizontal tab @tab @code{'\t'} -@item @code{C_VERTICAL_TAB} @tab vertical tab @tab @code{'\v'} -@end multitable - -Moreover, the following two named constants are defined: - -@multitable @columnfractions .20 .80 -@headitem Name @tab Type -@item @code{C_NULL_PTR} @tab @code{C_PTR} -@item @code{C_NULL_FUNPTR} @tab @code{C_FUNPTR} -@end multitable - -Both are equivalent to the value @code{NULL} in C. - - - -@node IEEE modules -@section IEEE modules: @code{IEEE_EXCEPTIONS}, @code{IEEE_ARITHMETIC}, and @code{IEEE_FEATURES} -@table @asis -@item @emph{Standard}: -Fortran 2003 and later -@end table - -The @code{IEEE_EXCEPTIONS}, @code{IEEE_ARITHMETIC}, and @code{IEEE_FEATURES} -intrinsic modules provide support for exceptions and IEEE arithmetic, as -defined in Fortran 2003 and later standards, and the IEC 60559:1989 standard -(@emph{Binary floating-point arithmetic for microprocessor systems}). These -modules are only provided on the following supported platforms: - -@itemize @bullet -@item i386 and x86_64 processors -@item platforms which use the GNU C Library (glibc) -@item platforms with support for SysV/386 routines for floating point -interface (including Solaris and BSDs) -@item platforms with the AIX OS -@end itemize - -For full compliance with the Fortran standards, code using the -@code{IEEE_EXCEPTIONS} or @code{IEEE_ARITHMETIC} modules should be compiled -with the following options: @code{-fno-unsafe-math-optimizations --frounding-math -fsignaling-nans}. - - - -@node OpenMP Modules OMP_LIB and OMP_LIB_KINDS -@section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS} -@table @asis -@item @emph{Standard}: -OpenMP Application Program Interface v4.5, -OpenMP Application Program Interface v5.0 (partially supported) and -OpenMP Application Program Interface v5.1 (partially supported). -@end table - -The OpenMP Fortran runtime library routines are provided both in -a form of two Fortran modules, named @code{OMP_LIB} and -@code{OMP_LIB_KINDS}, and in a form of a Fortran @code{include} file named -@file{omp_lib.h}. The procedures provided by @code{OMP_LIB} can be found -in the @ref{Top,,Introduction,libgomp,GNU Offloading and Multi -Processing Runtime Library} manual, -the named constants defined in the modules are listed -below. - -For details refer to the actual -@uref{https://www.openmp.org/wp-content/uploads/openmp-4.5.pdf, -OpenMP Application Program Interface v4.5} and -@uref{https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-5.0.pdf, -OpenMP Application Program Interface v5.0}. - -@code{OMP_LIB_KINDS} provides the following scalar default-integer -named constants: - -@table @asis -@item @code{omp_allocator_handle_kind} -@item @code{omp_alloctrait_key_kind} -@item @code{omp_alloctrait_val_kind} -@item @code{omp_depend_kind} -@item @code{omp_lock_kind} -@item @code{omp_lock_hint_kind} -@item @code{omp_nest_lock_kind} -@item @code{omp_pause_resource_kind} -@item @code{omp_memspace_handle_kind} -@item @code{omp_proc_bind_kind} -@item @code{omp_sched_kind} -@item @code{omp_sync_hint_kind} -@end table - -@code{OMP_LIB} provides the scalar default-integer -named constant @code{openmp_version} with a value of the form -@var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month -of the OpenMP version; for OpenMP v4.5 the value is @code{201511}. - -The following derived type: - -@table @asis -@item @code{omp_alloctrait} -@end table - -The following scalar integer named constants of the -kind @code{omp_sched_kind}: - -@table @asis -@item @code{omp_sched_static} -@item @code{omp_sched_dynamic} -@item @code{omp_sched_guided} -@item @code{omp_sched_auto} -@end table - -And the following scalar integer named constants of the -kind @code{omp_proc_bind_kind}: - -@table @asis -@item @code{omp_proc_bind_false} -@item @code{omp_proc_bind_true} -@item @code{omp_proc_bind_primary} -@item @code{omp_proc_bind_master} -@item @code{omp_proc_bind_close} -@item @code{omp_proc_bind_spread} -@end table - -The following scalar integer named constants are of the -kind @code{omp_lock_hint_kind}: - -@table @asis -@item @code{omp_lock_hint_none} -@item @code{omp_lock_hint_uncontended} -@item @code{omp_lock_hint_contended} -@item @code{omp_lock_hint_nonspeculative} -@item @code{omp_lock_hint_speculative} -@item @code{omp_sync_hint_none} -@item @code{omp_sync_hint_uncontended} -@item @code{omp_sync_hint_contended} -@item @code{omp_sync_hint_nonspeculative} -@item @code{omp_sync_hint_speculative} -@end table - -And the following two scalar integer named constants are of the -kind @code{omp_pause_resource_kind}: - -@table @asis -@item @code{omp_pause_soft} -@item @code{omp_pause_hard} -@end table - -The following scalar integer named constants are of the kind -@code{omp_alloctrait_key_kind}: - -@table @asis -@item @code{omp_atk_sync_hint} -@item @code{omp_atk_alignment} -@item @code{omp_atk_access} -@item @code{omp_atk_pool_size} -@item @code{omp_atk_fallback} -@item @code{omp_atk_fb_data} -@item @code{omp_atk_pinned} -@item @code{omp_atk_partition} -@end table - -The following scalar integer named constants are of the kind -@code{omp_alloctrait_val_kind}: - -@table @asis -@code{omp_alloctrait_key_kind}: -@item @code{omp_atv_default} -@item @code{omp_atv_false} -@item @code{omp_atv_true} -@item @code{omp_atv_contended} -@item @code{omp_atv_uncontended} -@item @code{omp_atv_serialized} -@item @code{omp_atv_sequential} -@item @code{omp_atv_private} -@item @code{omp_atv_all} -@item @code{omp_atv_thread} -@item @code{omp_atv_pteam} -@item @code{omp_atv_cgroup} -@item @code{omp_atv_default_mem_fb} -@item @code{omp_atv_null_fb} -@item @code{omp_atv_abort_fb} -@item @code{omp_atv_allocator_fb} -@item @code{omp_atv_environment} -@item @code{omp_atv_nearest} -@item @code{omp_atv_blocked} -@end table - -The following scalar integer named constants are of the kind -@code{omp_allocator_handle_kind}: - -@table @asis -@item @code{omp_null_allocator} -@item @code{omp_default_mem_alloc} -@item @code{omp_large_cap_mem_alloc} -@item @code{omp_const_mem_alloc} -@item @code{omp_high_bw_mem_alloc} -@item @code{omp_low_lat_mem_alloc} -@item @code{omp_cgroup_mem_alloc} -@item @code{omp_pteam_mem_alloc} -@item @code{omp_thread_mem_alloc} -@end table - -The following scalar integer named constants are of the kind -@code{omp_memspace_handle_kind}: - -@table @asis -@item @code{omp_default_mem_space} -@item @code{omp_large_cap_mem_space} -@item @code{omp_const_mem_space} -@item @code{omp_high_bw_mem_space} -@item @code{omp_low_lat_mem_space} -@end table - - - -@node OpenACC Module OPENACC -@section OpenACC Module @code{OPENACC} -@table @asis -@item @emph{Standard}: -OpenACC Application Programming Interface v2.6 -@end table - - -The OpenACC Fortran runtime library routines are provided both in a -form of a Fortran 90 module, named @code{OPENACC}, and in form of a -Fortran @code{include} file named @file{openacc_lib.h}. The -procedures provided by @code{OPENACC} can be found in the -@ref{Top,,Introduction,libgomp,GNU Offloading and Multi Processing -Runtime Library} manual, the named constants defined in the modules -are listed below. - -For details refer to the actual -@uref{https://www.openacc.org/, -OpenACC Application Programming Interface v2.6}. - -@code{OPENACC} provides the scalar default-integer -named constant @code{openacc_version} with a value of the form -@var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month -of the OpenACC version; for OpenACC v2.6 the value is @code{201711}. diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi deleted file mode 100644 index 58502d3..0000000 --- a/gcc/fortran/invoke.texi +++ /dev/null @@ -1,2133 +0,0 @@ -@c Copyright (C) 2004-2022 Free Software Foundation, Inc. -@c This is part of the GNU Fortran manual. -@c For copying conditions, see the file gfortran.texi. - -@ignore -@c man begin COPYRIGHT -Copyright @copyright{} 2004-2022 Free Software Foundation, Inc. - -Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.3 or -any later version published by the Free Software Foundation; with the -Invariant Sections being ``Funding Free Software'', the Front-Cover -Texts being (a) (see below), and with the Back-Cover Texts being (b) -(see below). A copy of the license is included in the gfdl(7) man page. - -(a) The FSF's Front-Cover Text is: - - A GNU Manual - -(b) The FSF's Back-Cover Text is: - - You have freedom to copy and modify this GNU Manual, like GNU - software. Copies published by the Free Software Foundation raise - funds for GNU development. -@c man end -@c Set file name and title for the man page. -@setfilename gfortran -@settitle GNU Fortran compiler. -@c man begin SYNOPSIS -gfortran [@option{-c}|@option{-S}|@option{-E}] - [@option{-g}] [@option{-pg}] [@option{-O}@var{level}] - [@option{-W}@var{warn}@dots{}] [@option{-pedantic}] - [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}] - [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}] - [@option{-f}@var{option}@dots{}] - [@option{-m}@var{machine-option}@dots{}] - [@option{-o} @var{outfile}] @var{infile}@dots{} - -Only the most useful options are listed here; see below for the -remainder. -@c man end -@c man begin SEEALSO -gpl(7), gfdl(7), fsf-funding(7), -cpp(1), gcov(1), gcc(1), as(1), ld(1), gdb(1), dbx(1) -and the Info entries for @file{gcc}, @file{cpp}, @file{gfortran}, @file{as}, -@file{ld}, @file{binutils} and @file{gdb}. -@c man end -@c man begin BUGS -For instructions on reporting bugs, see -@w{@value{BUGURL}}. -@c man end -@c man begin AUTHOR -See the Info entry for @command{gfortran} for contributors to GCC and -GNU Fortran. -@c man end -@end ignore - -@node Invoking GNU Fortran -@chapter GNU Fortran Command Options -@cindex GNU Fortran command options -@cindex command options -@cindex options, @command{gfortran} command - -@c man begin DESCRIPTION - -The @command{gfortran} command supports all the options supported by the -@command{gcc} command. Only options specific to GNU Fortran are documented -here. - -@xref{Invoking GCC,,GCC Command Options,gcc,Using the GNU Compiler -Collection (GCC)}, for information -on the non-Fortran-specific aspects of the @command{gcc} command (and, -therefore, the @command{gfortran} command). - -@cindex options, negative forms -All GCC and GNU Fortran options -are accepted both by @command{gfortran} and by @command{gcc} -(as well as any other drivers built at the same time, -such as @command{g++}), -since adding GNU Fortran to the GCC distribution -enables acceptance of GNU Fortran options -by all of the relevant drivers. - -In some cases, options have positive and negative forms; -the negative form of @option{-ffoo} would be @option{-fno-foo}. -This manual documents only one of these two forms, whichever -one is not the default. -@c man end - -@menu -* Option Summary:: Brief list of all @command{gfortran} options, - without explanations. -* Fortran Dialect Options:: Controlling the variant of Fortran language - compiled. -* Preprocessing Options:: Enable and customize preprocessing. -* Error and Warning Options:: How picky should the compiler be? -* Debugging Options:: Symbol tables, measurements, and debugging dumps. -* Directory Options:: Where to find module files -* Link Options :: Influencing the linking step -* Runtime Options:: Influencing runtime behavior -* Code Gen Options:: Specifying conventions for function calls, data layout - and register usage. -* Interoperability Options:: Options for interoperability with other - languages. -* Environment Variables:: Environment variables that affect @command{gfortran}. -@end menu - -@node Option Summary -@section Option summary - -@c man begin OPTIONS - -Here is a summary of all the options specific to GNU Fortran, grouped -by type. Explanations are in the following sections. - -@table @emph -@item Fortran Language Options -@xref{Fortran Dialect Options,,Options controlling Fortran dialect}. -@gccoptlist{-fall-intrinsics -fallow-argument-mismatch -fallow-invalid-boz @gol --fbackslash -fcray-pointer -fd-lines-as-code -fd-lines-as-comments @gol --fdec -fdec-char-conversions -fdec-structure -fdec-intrinsic-ints @gol --fdec-static -fdec-math -fdec-include -fdec-format-defaults @gol --fdec-blank-format-item -fdefault-double-8 -fdefault-integer-8 @gol --fdefault-real-8 -fdefault-real-10 -fdefault-real-16 -fdollar-ok @gol --ffixed-line-length-@var{n} -ffixed-line-length-none -fpad-source @gol --ffree-form -ffree-line-length-@var{n} -ffree-line-length-none @gol --fimplicit-none -finteger-4-integer-8 -fmax-identifier-length @gol --fmodule-private -ffixed-form -fno-range-check -fopenacc -fopenmp @gol --freal-4-real-10 -freal-4-real-16 -freal-4-real-8 -freal-8-real-10 @gol --freal-8-real-16 -freal-8-real-4 -std=@var{std} -ftest-forall-temp -} - -@item Preprocessing Options -@xref{Preprocessing Options,,Enable and customize preprocessing}. -@gccoptlist{-A-@var{question}@r{[}=@var{answer}@r{]} --A@var{question}=@var{answer} -C -CC -D@var{macro}@r{[}=@var{defn}@r{]} --H -P @gol --U@var{macro} -cpp -dD -dI -dM -dN -dU -fworking-directory --imultilib @var{dir} @gol --iprefix @var{file} -iquote -isysroot @var{dir} -isystem @var{dir} -nocpp --nostdinc @gol --undef -} - -@item Error and Warning Options -@xref{Error and Warning Options,,Options to request or suppress errors -and warnings}. -@gccoptlist{-Waliasing -Wall -Wampersand -Warray-bounds @gol --Wc-binding-type -Wcharacter-truncation -Wconversion @gol --Wdo-subscript -Wfunction-elimination -Wimplicit-interface @gol --Wimplicit-procedure -Wintrinsic-shadow -Wuse-without-only @gol --Wintrinsics-std -Wline-truncation -Wno-align-commons @gol --Wno-overwrite-recursive -Wno-tabs -Wreal-q-constant -Wsurprising @gol --Wunderflow -Wunused-parameter -Wrealloc-lhs -Wrealloc-lhs-all @gol --Wfrontend-loop-interchange -Wtarget-lifetime -fmax-errors=@var{n} @gol --fsyntax-only -pedantic @gol --pedantic-errors @gol -} - -@item Debugging Options -@xref{Debugging Options,,Options for debugging your program or GNU Fortran}. -@gccoptlist{-fbacktrace -fdump-fortran-optimized -fdump-fortran-original @gol --fdebug-aux-vars -fdump-fortran-global -fdump-parse-tree -ffpe-trap=@var{list} @gol --ffpe-summary=@var{list} -} - -@item Directory Options -@xref{Directory Options,,Options for directory search}. -@gccoptlist{-I@var{dir} -J@var{dir} -fintrinsic-modules-path @var{dir}} - -@item Link Options -@xref{Link Options,,Options for influencing the linking step}. -@gccoptlist{-static-libgfortran -static-libquadmath} - -@item Runtime Options -@xref{Runtime Options,,Options for influencing runtime behavior}. -@gccoptlist{-fconvert=@var{conversion} -fmax-subrecord-length=@var{length} @gol --frecord-marker=@var{length} -fsign-zero -} - -@item Interoperability Options -@xref{Interoperability Options,,Options for interoperability}. -@gccoptlist{-fc-prototypes -fc-prototypes-external} - -@item Code Generation Options -@xref{Code Gen Options,,Options for code generation conventions}. -@gccoptlist{-faggressive-function-elimination -fblas-matmul-limit=@var{n} @gol --fbounds-check -ftail-call-workaround -ftail-call-workaround=@var{n} @gol --fcheck-array-temporaries @gol --fcheck=@var{<all|array-temps|bits|bounds|do|mem|pointer|recursion>} @gol --fcoarray=@var{<none|single|lib>} -fexternal-blas -ff2c @gol --ffrontend-loop-interchange -ffrontend-optimize @gol --finit-character=@var{n} -finit-integer=@var{n} -finit-local-zero @gol --finit-derived -finit-logical=@var{<true|false>} @gol --finit-real=@var{<zero|inf|-inf|nan|snan>} --finline-matmul-limit=@var{n} @gol --finline-arg-packing -fmax-array-constructor=@var{n} @gol --fmax-stack-var-size=@var{n} -fno-align-commons -fno-automatic @gol --fno-protect-parens -fno-underscoring -fsecond-underscore @gol --fpack-derived -frealloc-lhs -frecursive -frepack-arrays @gol --fshort-enums -fstack-arrays -} -@end table - -@node Fortran Dialect Options -@section Options controlling Fortran dialect -@cindex dialect options -@cindex language, dialect options -@cindex options, dialect - -The following options control the details of the Fortran dialect -accepted by the compiler: - -@table @gcctabopt -@item -ffree-form -@itemx -ffixed-form -@opindex @code{ffree-form} -@opindex @code{ffixed-form} -@cindex options, Fortran dialect -@cindex file format, free -@cindex file format, fixed -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. - -@item -fall-intrinsics -@opindex @code{fall-intrinsics} -This option causes all intrinsic procedures (including the GNU-specific -extensions) to be accepted. This can be useful with @option{-std=} to -force standard-compliance but get access to the full range of intrinsics -available with @command{gfortran}. As a consequence, @option{-Wintrinsics-std} -will be ignored and no user-defined procedure with the same name as any -intrinsic will be called except when it is explicitly declared @code{EXTERNAL}. - -@item -fallow-argument-mismatch -@opindex @code{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 -@option{-w}. Only a single occurrence per argument is flagged by this -warning. @option{-fallow-argument-mismatch} is implied by -@option{-std=legacy}. - -Using this option is @emph{strongly} discouraged. It is possible to -provide standard-conforming code which allows different types of -arguments by using an explicit interface and @code{TYPE(*)}. - -@item -fallow-invalid-boz -@opindex @code{allow-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. - -@item -fd-lines-as-code -@itemx -fd-lines-as-comments -@opindex @code{fd-lines-as-code} -@opindex @code{fd-lines-as-comments} -Enable special treatment for lines beginning with @code{d} or @code{D} -in fixed form sources. If the @option{-fd-lines-as-code} option is -given they are treated as if the first column contained a blank. If the -@option{-fd-lines-as-comments} option is given, they are treated as -comment lines. - -@item -fdec -@opindex @code{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: -@option{-fdollar-ok} @option{-fcray-pointer} @option{-fdec-char-conversions} -@option{-fdec-structure} @option{-fdec-intrinsic-ints} @option{-fdec-static} -@option{-fdec-math} @option{-fdec-include} @option{-fdec-blank-format-item} -@option{-fdec-format-defaults} - -If @option{-fd-lines-as-code}/@option{-fd-lines-as-comments} are unset, then -@option{-fdec} also sets @option{-fd-lines-as-comments}. - -@item -fdec-char-conversions -@opindex @code{fdec-char-conversions} -Enable the use of character literals in assignments and @code{DATA} statements -for non-character variables. - -@item -fdec-structure -@opindex @code{fdec-structure} -Enable DEC @code{STRUCTURE} and @code{RECORD} as well as @code{UNION}, -@code{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. - -@item -fdec-intrinsic-ints -@opindex @code{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. - -@item -fdec-math -@opindex @code{fdec-math} -Enable legacy math intrinsics such as COTAN and degree-valued trigonometric -functions (e.g. TAND, ATAND, etc...) for compatability with older code. - -@item -fdec-static -@opindex @code{fdec-static} -Enable DEC-style STATIC and AUTOMATIC attributes to explicitly specify -the storage of variables and other objects. - -@item -fdec-include -@opindex @code{fdec-include} -Enable parsing of INCLUDE as a statement in addition to parsing it as -INCLUDE line. When parsed as INCLUDE statement, INCLUDE does not have to -be on a single line and can use line continuations. - -@item -fdec-format-defaults -@opindex @code{fdec-format-defaults} -Enable format specifiers F, G and I to be used without width specifiers, -default widths will be used instead. - -@item -fdec-blank-format-item -@opindex @code{fdec-blank-format-item} -Enable a blank format item at the end of a format specification i.e. nothing -following the final comma. - -@item -fdollar-ok -@opindex @code{fdollar-ok} -@cindex @code{$} -@cindex symbol names -@cindex character set -Allow @samp{$} as a valid non-first character in a symbol name. Symbols -that start with @samp{$} are rejected since it is unclear which rules to -apply to implicit typing as different vendors implement different rules. -Using @samp{$} in @code{IMPLICIT} statements is also rejected. - -@item -fbackslash -@opindex @code{backslash} -@cindex backslash -@cindex escape characters -Change the interpretation of backslashes in string literals from a single -backslash character to ``C-style'' escape characters. The following -combinations are expanded @code{\a}, @code{\b}, @code{\f}, @code{\n}, -@code{\r}, @code{\t}, @code{\v}, @code{\\}, and @code{\0} to the ASCII -characters alert, backspace, form feed, newline, carriage return, -horizontal tab, vertical tab, backslash, and NUL, respectively. -Additionally, @code{\x}@var{nn}, @code{\u}@var{nnnn} and -@code{\U}@var{nnnnnnnn} (where each @var{n} is a hexadecimal digit) are -translated into the Unicode characters corresponding to the specified code -points. All other combinations of a character preceded by \ are -unexpanded. - -@item -fmodule-private -@opindex @code{fmodule-private} -@cindex module entities -@cindex private -Set the default accessibility of module entities to @code{PRIVATE}. -Use-associated entities will not be accessible unless they are explicitly -declared as @code{PUBLIC}. - -@item -ffixed-line-length-@var{n} -@opindex @code{ffixed-line-length-}@var{n} -@cindex file format, fixed -Set column after which characters are ignored in typical fixed-form -lines in the source file, and, unless @code{-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 @var{n} include 72 (the -standard and the default), 80 (card image), and 132 (corresponding -to ``extended-source'' options in some popular compilers). -@var{n} may also be @samp{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. -@option{-ffixed-line-length-0} means the same thing as -@option{-ffixed-line-length-none}. - -@item -fno-pad-source -@opindex @code{fpad-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 -@option{-ffixed-line-length-0}, @option{-ffixed-line-length-none} or -if @option{-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. - -@item -ffree-line-length-@var{n} -@opindex @code{ffree-line-length-}@var{n} -@cindex file format, free -Set column after which characters are ignored in typical free-form -lines in the source file. The default value is 132. -@var{n} may be @samp{none}, meaning that the entire line is meaningful. -@option{-ffree-line-length-0} means the same thing as -@option{-ffree-line-length-none}. - -@item -fmax-identifier-length=@var{n} -@opindex @code{fmax-identifier-length=}@var{n} -Specify the maximum allowed identifier length. Typical values are -31 (Fortran 95) and 63 (Fortran 2003 and later). - -@item -fimplicit-none -@opindex @code{fimplicit-none} -Specify that no implicit typing is allowed, unless overridden by explicit -@code{IMPLICIT} statements. This is the equivalent of adding -@code{implicit none} to the start of every procedure. - -@item -fcray-pointer -@opindex @code{fcray-pointer} -Enable the Cray pointer extension, which provides C-like pointer -functionality. - -@item -fopenacc -@opindex @code{fopenacc} -@cindex OpenACC -Enable the OpenACC extensions. This includes OpenACC @code{!$acc} -directives in free form and @code{c$acc}, @code{*$acc} and -@code{!$acc} directives in fixed form, @code{!$} conditional -compilation sentinels in free form and @code{c$}, @code{*$} and -@code{!$} sentinels in fixed form, and when linking arranges for the -OpenACC runtime library to be linked in. - -@item -fopenmp -@opindex @code{fopenmp} -@cindex OpenMP -Enable the OpenMP extensions. This includes OpenMP @code{!$omp} directives -in free form -and @code{c$omp}, @code{*$omp} and @code{!$omp} directives in fixed form, -@code{!$} conditional compilation sentinels in free form -and @code{c$}, @code{*$} and @code{!$} sentinels in fixed form, -and when linking arranges for the OpenMP runtime library to be linked -in. The option @option{-fopenmp} implies @option{-frecursive}. - -@item -fno-range-check -@opindex @code{frange-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 @code{a = 1. / 0}. -With this option, no error will be given and @code{a} will be assigned -the value @code{+Infinity}. If an expression evaluates to a value -outside of the relevant range of [@code{-HUGE()}:@code{HUGE()}], -then the expression will be replaced by @code{-Inf} or @code{+Inf} -as appropriate. -Similarly, @code{DATA i/Z'FFFFFFFF'/} will result in an integer overflow -on most systems, but with @option{-fno-range-check} the value will -``wrap around'' and @code{i} will be initialized to @math{-1} instead. - -@item -fdefault-integer-8 -@opindex @code{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 @code{42}. Unlike -@option{-finteger-4-integer-8}, it does not promote variables with explicit -kind declaration. - -@item -fdefault-real-8 -@opindex @code{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 @code{1.0}. This option promotes -the default width of @code{DOUBLE PRECISION} and double real constants -like @code{1.d0} to 16 bytes if possible. If @code{-fdefault-double-8} -is given along with @code{fdefault-real-8}, @code{DOUBLE PRECISION} -and double real constants are not promoted. Unlike @option{-freal-4-real-8}, -@code{fdefault-real-8} does not promote variables with explicit kind -declarations. - -@item -fdefault-real-10 -@opindex @code{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 @code{1.0}. This option promotes -the default width of @code{DOUBLE PRECISION} and double real constants -like @code{1.d0} to 16 bytes if possible. If @code{-fdefault-double-8} -is given along with @code{fdefault-real-10}, @code{DOUBLE PRECISION} -and double real constants are not promoted. Unlike @option{-freal-4-real-10}, -@code{fdefault-real-10} does not promote variables with explicit kind -declarations. - -@item -fdefault-real-16 -@opindex @code{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 @code{1.0}. This option promotes -the default width of @code{DOUBLE PRECISION} and double real constants -like @code{1.d0} to 16 bytes if possible. If @code{-fdefault-double-8} -is given along with @code{fdefault-real-16}, @code{DOUBLE PRECISION} -and double real constants are not promoted. Unlike @option{-freal-4-real-16}, -@code{fdefault-real-16} does not promote variables with explicit kind -declarations. - -@item -fdefault-double-8 -@opindex @code{fdefault-double-8} -Set the @code{DOUBLE PRECISION} type and double real constants -like @code{1.d0} to an 8 byte wide type. Do nothing if this -is already the default. This option prevents @option{-fdefault-real-8}, -@option{-fdefault-real-10}, and @option{-fdefault-real-16}, -from promoting @code{DOUBLE PRECISION} and double real constants like -@code{1.d0} to 16 bytes. - -@item -finteger-4-integer-8 -@opindex @code{finteger-4-integer-8} -Promote all @code{INTEGER(KIND=4)} entities to an @code{INTEGER(KIND=8)} -entities. If @code{KIND=8} is unavailable, then an error will be issued. -This option should be used with care and may not be suitable for your codes. -Areas of possible concern include calls to external procedures, -alignment in @code{EQUIVALENCE} and/or @code{COMMON}, generic interfaces, -BOZ literal constant conversion, and I/O. Inspection of the intermediate -representation of the translated Fortran code, produced by -@option{-fdump-tree-original}, is suggested. - -@item -freal-4-real-8 -@itemx -freal-4-real-10 -@itemx -freal-4-real-16 -@itemx -freal-8-real-4 -@itemx -freal-8-real-10 -@itemx -freal-8-real-16 -@opindex @code{freal-4-real-8} -@opindex @code{freal-4-real-10} -@opindex @code{freal-4-real-16} -@opindex @code{freal-8-real-4} -@opindex @code{freal-8-real-10} -@opindex @code{freal-8-real-16} -@cindex options, real kind type promotion -Promote all @code{REAL(KIND=M)} entities to @code{REAL(KIND=N)} entities. -If @code{REAL(KIND=N)} is unavailable, then an error will be issued. -The @code{-freal-4-} flags also affect the default real kind and the -@code{-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, @code{-fdefault-real-8}, @code{-fdefault-real-10}, -@code{-fdefault-real-10}, and @code{-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 @code{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 procedures, -alignment in @code{EQUIVALENCE} and/or @code{COMMON}, generic interfaces, -BOZ literal constant conversion, and I/O and calls to intrinsic procedures -when passing a value to the @code{kind=} dummy argument. Inspection of the -intermediate representation of the translated Fortran code, produced by -@option{-fdump-fortran-original} or @option{-fdump-tree-original}, is suggested. - -@item -std=@var{std} -@opindex @code{std=}@var{std} option -Specify the standard to which the program is expected to conform, -which may be one of @samp{f95}, @samp{f2003}, @samp{f2008}, -@samp{f2018}, @samp{gnu}, or @samp{legacy}. The default value for -@var{std} is @samp{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 @samp{legacy} value is -equivalent but without the warnings for obsolete extensions, and may -be useful for old non-standard programs. The @samp{f95}, -@samp{f2003}, @samp{f2008}, and @samp{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 @samp{-std=f2008ts} acts as an alias for -@samp{-std=f2018}. It is only present for backwards compatibility with -earlier gfortran versions and should not be used any more. - -@item -ftest-forall-temp -@opindex @code{ftest-forall-temp} -Enhance test coverage by forcing most forall assignments to use temporary. - -@end table - -@node Preprocessing Options -@section Enable and customize preprocessing -@cindex preprocessor -@cindex options, preprocessor -@cindex CPP -@cindex FPP -@cindex Conditional compilation -@cindex Preprocessing -@cindex preprocessor, include file handling - -Many Fortran compilers including GNU Fortran allow passing the source code -through a C preprocessor (CPP; sometimes also called the Fortran preprocessor, -FPP) to allow for conditional compilation. In the case of GNU Fortran, -this is the GNU C Preprocessor in the traditional mode. On systems with -case-preserving file names, the preprocessor is automatically invoked if the -filename extension is @file{.F}, @file{.FOR}, @file{.FTN}, @file{.fpp}, -@file{.FPP}, @file{.F90}, @file{.F95}, @file{.F03} or @file{.F08}. To manually -invoke the preprocessor on any file, use @option{-cpp}, to disable -preprocessing on files where the preprocessor is run automatically, use -@option{-nocpp}. - -If a preprocessed file includes another file with the Fortran @code{INCLUDE} -statement, the included file is not preprocessed. To preprocess included -files, use the equivalent preprocessor statement @code{#include}. - -If GNU Fortran invokes the preprocessor, @code{__GFORTRAN__} -is defined. The macros @code{__GNUC__}, @code{__GNUC_MINOR__} and -@code{__GNUC_PATCHLEVEL__} can be used to determine the version of the -compiler. See @ref{Top,,Overview,cpp,The C Preprocessor} for details. - -GNU Fortran supports a number of @code{INTEGER} and @code{REAL} kind types -in additional to the kind types required by the Fortran standard. -The availability of any given kind type is architecture dependent. The -following pre-defined preprocessor macros can be used to conditionally -include code for these additional kind types: @code{__GFC_INT_1__}, -@code{__GFC_INT_2__}, @code{__GFC_INT_8__}, @code{__GFC_INT_16__}, -@code{__GFC_REAL_10__}, and @code{__GFC_REAL_16__}. - -While CPP is the de-facto standard for preprocessing Fortran code, -Part 3 of the Fortran 95 standard (ISO/IEC 1539-3:1998) defines -Conditional Compilation, which is not widely used and not directly -supported by the GNU Fortran compiler. You can use the program coco -to preprocess such files (@uref{http://www.daniellnagle.com/coco.html}). - -The following options control preprocessing of Fortran code: - -@table @gcctabopt -@item -cpp -@itemx -nocpp -@opindex @code{cpp} -@opindex @code{fpp} -@cindex preprocessor, enable -@cindex preprocessor, disable -Enable preprocessing. The preprocessor is automatically invoked if -the file extension is @file{.fpp}, @file{.FPP}, @file{.F}, @file{.FOR}, -@file{.FTN}, @file{.F90}, @file{.F95}, @file{.F03} or @file{.F08}. Use -this option to manually enable preprocessing of any kind of Fortran file. - -To disable preprocessing of files with any of the above listed extensions, -use the negative form: @option{-nocpp}. - -The preprocessor is run in traditional mode. Any restrictions of the -file-format, especially the limits on line length, apply for -preprocessed output as well, so it might be advisable to use the -@option{-ffree-line-length-none} or @option{-ffixed-line-length-none} -options. - -@item -dM -@opindex @code{dM} -@cindex preprocessor, debugging -@cindex debugging, preprocessor -Instead of the normal output, generate a list of @code{'#define'} -directives for all the macros defined during the execution of the -preprocessor, including predefined macros. This gives you a way -of finding out what is predefined in your version of the preprocessor. -Assuming you have no file @file{foo.f90}, the command -@smallexample - touch foo.f90; gfortran -cpp -E -dM foo.f90 -@end smallexample -will show all the predefined macros. - -@item -dD -@opindex @code{dD} -@cindex preprocessor, debugging -@cindex debugging, preprocessor -Like @option{-dM} except in two respects: it does not include the -predefined macros, and it outputs both the @code{#define} directives -and the result of preprocessing. Both kinds of output go to the -standard output file. - -@item -dN -@opindex @code{dN} -@cindex preprocessor, debugging -@cindex debugging, preprocessor -Like @option{-dD}, but emit only the macro names, not their expansions. - -@item -dU -@opindex @code{dU} -@cindex preprocessor, debugging -@cindex debugging, preprocessor -Like @option{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 @code{'#undef'} -directives are also output for macros tested but undefined at the time. - -@item -dI -@opindex @code{dI} -@cindex preprocessor, debugging -@cindex debugging, preprocessor -Output @code{'#include'} directives in addition to the result -of preprocessing. - -@item -fworking-directory -@opindex @code{fworking-directory} -@cindex preprocessor, working 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 information formats. -This option is implicitly enabled if debugging information is enabled, -but this can be inhibited with the negated form -@option{-fno-working-directory}. If the @option{-P} flag is present -in the command line, this option has no effect, since no @code{#line} -directives are emitted whatsoever. - -@item -idirafter @var{dir} -@opindex @code{idirafter @var{dir}} -@cindex preprocessing, include path -Search @var{dir} for include files, but do it after all directories -specified with @option{-I} and the standard system directories have -been exhausted. @var{dir} is treated as a system include directory. -If dir begins with @code{=}, then the @code{=} will be replaced by -the sysroot prefix; see @option{--sysroot} and @option{-isysroot}. - -@item -imultilib @var{dir} -@opindex @code{imultilib @var{dir}} -@cindex preprocessing, include path -Use @var{dir} as a subdirectory of the directory containing target-specific -C++ headers. - -@item -iprefix @var{prefix} -@opindex @code{iprefix @var{prefix}} -@cindex preprocessing, include path -Specify @var{prefix} as the prefix for subsequent @option{-iwithprefix} -options. If the @var{prefix} represents a directory, you should include -the final @code{'/'}. - -@item -isysroot @var{dir} -@opindex @code{isysroot @var{dir}} -@cindex preprocessing, include path -This option is like the @option{--sysroot} option, but applies only to -header files. See the @option{--sysroot} option for more information. - -@item -iquote @var{dir} -@opindex @code{iquote @var{dir}} -@cindex preprocessing, include path -Search @var{dir} only for header files requested with @code{#include "file"}; -they are not searched for @code{#include <file>}, before all directories -specified by @option{-I} and before the standard system directories. If -@var{dir} begins with @code{=}, then the @code{=} will be replaced by the -sysroot prefix; see @option{--sysroot} and @option{-isysroot}. - -@item -isystem @var{dir} -@opindex @code{isystem @var{dir}} -@cindex preprocessing, include path -Search @var{dir} for header files, after all directories specified by -@option{-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 @var{dir} begins with -@code{=}, then the @code{=} will be replaced by the sysroot prefix; -see @option{--sysroot} and @option{-isysroot}. - -@item -nostdinc -@opindex @code{nostdinc} -Do not search the standard system directories for header files. Only -the directories you have specified with @option{-I} options (and the -directory of the current file, if appropriate) are searched. - -@item -undef -@opindex @code{undef} -Do not predefine any system-specific or GCC-specific macros. -The standard predefined macros remain defined. - -@item -A@var{predicate}=@var{answer} -@opindex @code{A@var{predicate}=@var{answer}} -@cindex preprocessing, assertion -Make an assertion with the predicate @var{predicate} and answer @var{answer}. -This form is preferred to the older form -A predicate(answer), which is still -supported, because it does not use shell special characters. - -@item -A-@var{predicate}=@var{answer} -@opindex @code{A-@var{predicate}=@var{answer}} -@cindex preprocessing, assertion -Cancel an assertion with the predicate @var{predicate} and answer @var{answer}. - -@item -C -@opindex @code{C} -@cindex preprocessing, keep comments -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 @option{-C}; it causes -the preprocessor to treat comments as tokens in their own right. For example, -comments appearing at the start of what would be a directive line have the -effect of turning that line into an ordinary source line, since the first -token on the line is no longer a @code{'#'}. - -Warning: this currently handles C-Style comments only. The preprocessor -does not yet recognize Fortran-style comments. - -@item -CC -@opindex @code{CC} -@cindex preprocessing, keep comments -Do not discard comments, including during macro expansion. This is like -@option{-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 @option{-C} option, the @option{-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 @option{-CC} option -is generally used to support lint comments. - -Warning: this currently handles C- and C++-Style comments only. The -preprocessor does not yet recognize Fortran-style comments. - -@item -D@var{name} -@opindex @code{D@var{name}} -@cindex preprocessing, define macros -Predefine name as a macro, with definition @code{1}. - -@item -D@var{name}=@var{definition} -@opindex @code{D@var{name}=@var{definition}} -@cindex preprocessing, define macros -The contents of @var{definition} are tokenized and processed as if they -appeared during translation phase three in a @code{'#define'} directive. -In particular, the definition will be truncated by embedded newline -characters. - -If you are invoking the preprocessor from a shell or shell-like program -you may need to use the shell's quoting syntax to protect characters such -as spaces that have a meaning in the shell syntax. - -If you wish to define a function-like macro on the command line, write -its argument list with surrounding parentheses before the equals sign -(if any). Parentheses are meaningful to most shells, so you will need -to quote the option. With sh and csh, @code{-D'name(args...)=definition'} -works. - -@option{-D} and @option{-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. - -@item -H -@opindex @code{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 @code{'#include'} -stack it is. - -@item -P -@opindex @code{P} -@cindex preprocessing, no linemarkers -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. - -@item -U@var{name} -@opindex @code{U@var{name}} -@cindex preprocessing, undefine macros -Cancel any previous definition of @var{name}, either built in or provided -with a @option{-D} option. -@end table - - -@node Error and Warning Options -@section Options to request or suppress errors and warnings -@cindex options, warnings -@cindex options, errors -@cindex warnings, suppressing -@cindex messages, error -@cindex messages, warning -@cindex suppressing warnings - -Errors are diagnostic messages that report that the GNU Fortran compiler -cannot compile the relevant piece of source code. The compiler will -continue to process the program in an attempt to report further errors -to aid in debugging, but will not produce any compiled output. - -Warnings are diagnostic messages that report constructions which -are not inherently erroneous but which are risky or suggest there is -likely to be a bug in the program. Unless @option{-Werror} is specified, -they do not prevent compilation of the program. - -You can request many specific warnings with options beginning @option{-W}, -for example @option{-Wimplicit} to request warnings on implicit -declarations. Each of these specific warning options also has a -negative form beginning @option{-Wno-} to turn off warnings; -for example, @option{-Wno-implicit}. This manual lists only one of the -two forms, whichever is not the default. - -These options control the amount and kinds of errors and warnings produced -by GNU Fortran: - -@table @gcctabopt -@item -fmax-errors=@var{n} -@opindex @code{fmax-errors=}@var{n} -@cindex errors, limiting -Limits the maximum number of error messages to @var{n}, at which point -GNU Fortran bails out rather than attempting to continue processing the -source code. If @var{n} is 0, there is no limit on the number of error -messages produced. - -@item -fsyntax-only -@opindex @code{fsyntax-only} -@cindex syntax checking -Check the code for syntax errors, but do not actually compile it. This -will generate module files for each module present in the code, but no -other output file. - -@item -Wpedantic -@itemx -pedantic -@opindex @code{pedantic} -@opindex @code{Wpedantic} -Issue warnings for uses of extensions to Fortran. -@option{-pedantic} also applies to C-language constructs where they -occur in GNU Fortran source files, such as use of @samp{\e} in a -character constant within a directive like @code{#include}. - -Valid Fortran programs should compile properly with or without -this option. -However, without this option, certain GNU extensions and traditional -Fortran features are supported as well. -With this option, many of them are rejected. - -Some users try to use @option{-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 @option{-std=f95}, -@option{-std=f2003}, @option{-std=f2008} or @option{-std=f2018}. - -@item -pedantic-errors -@opindex @code{pedantic-errors} -Like @option{-pedantic}, except that errors are produced rather than -warnings. - -@item -Wall -@opindex @code{Wall} -@cindex all warnings -@cindex warnings, all -Enables commonly used warning options pertaining to usage that -we recommend avoiding and that we believe are easy to avoid. -This currently includes @option{-Waliasing}, @option{-Wampersand}, -@option{-Wconversion}, @option{-Wsurprising}, @option{-Wc-binding-type}, -@option{-Wintrinsics-std}, @option{-Wtabs}, @option{-Wintrinsic-shadow}, -@option{-Wline-truncation}, @option{-Wtarget-lifetime}, -@option{-Winteger-division}, @option{-Wreal-q-constant}, @option{-Wunused} -and @option{-Wundefined-do-loop}. - -@item -Waliasing -@opindex @code{Waliasing} -@cindex aliasing -@cindex warnings, aliasing -Warn about possible aliasing of dummy arguments. Specifically, it warns -if the same actual argument is associated with a dummy argument with -@code{INTENT(IN)} and a dummy argument with @code{INTENT(OUT)} in a call -with an explicit interface. - -The following example will trigger the warning. -@smallexample - interface - subroutine bar(a,b) - integer, intent(in) :: a - integer, intent(out) :: b - end subroutine - end interface - integer :: a - - call bar(a,a) -@end smallexample - -@item -Wampersand -@opindex @code{Wampersand} -@cindex warnings, ampersand -@cindex @code{&} -Warn about missing ampersand in continued character constants. The -warning is given with @option{-Wampersand}, @option{-pedantic}, -@option{-std=f95}, @option{-std=f2003}, @option{-std=f2008} and -@option{-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. - -@item -Warray-temporaries -@opindex @code{Warray-temporaries} -@cindex warnings, array 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. - -@item -Wc-binding-type -@opindex @code{Wc-binding-type} -@cindex warning, C 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 @code{ISO_C_Binding} module. This option is implied by -@option{-Wall}. - -@item -Wcharacter-truncation -@opindex @code{Wcharacter-truncation} -@cindex warnings, character truncation -Warn when a character assignment will truncate the assigned string. - -@item -Wline-truncation -@opindex @code{Wline-truncation} -@cindex warnings, line truncation -Warn when a source code line will be truncated. This option is -implied by @option{-Wall}. For free-form source code, the default is -@option{-Werror=line-truncation} such that truncations are reported as -error. - -@item -Wconversion -@opindex @code{Wconversion} -@cindex warnings, conversion -@cindex conversion -Warn about implicit conversions that are likely to change the value of -the expression after conversion. Implied by @option{-Wall}. - -@item -Wconversion-extra -@opindex @code{Wconversion-extra} -@cindex warnings, conversion -@cindex conversion -Warn about implicit conversions between different types and kinds. This -option does @emph{not} imply @option{-Wconversion}. - -@item -Wextra -@opindex @code{Wextra} -@cindex extra warnings -@cindex warnings, extra -Enables some warning options for usages of language features which -may be problematic. This currently includes @option{-Wcompare-reals}, -@option{-Wunused-parameter} and @option{-Wdo-subscript}. - -@item -Wfrontend-loop-interchange -@opindex @code{Wfrontend-loop-interchange} -@cindex warnings, loop interchange -@cindex loop interchange, warning -Warn when using @option{-ffrontend-loop-interchange} for performing loop -interchanges. - -@item -Wimplicit-interface -@opindex @code{Wimplicit-interface} -@cindex warnings, implicit 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. - -@item -Wimplicit-procedure -@opindex @code{Wimplicit-procedure} -@cindex warnings, implicit procedure -Warn if a procedure is called that has neither an explicit interface -nor has been declared as @code{EXTERNAL}. - -@item -Winteger-division -@opindex @code{Winteger-division} -@cindex warnings, integer division -@cindex warnings, division of integers -Warn if a constant integer division truncates its result. -As an example, 3/5 evaluates to 0. - -@item -Wintrinsics-std -@opindex @code{Wintrinsics-std} -@cindex warnings, non-standard intrinsics -@cindex warnings, intrinsics of other standards -Warn if @command{gfortran} finds a procedure named like an intrinsic not -available in the currently selected standard (with @option{-std}) and treats -it as @code{EXTERNAL} procedure because of this. @option{-fall-intrinsics} can -be used to never trigger this behavior and always link to the intrinsic -regardless of the selected standard. - -@item -Wno-overwrite-recursive -@opindex @code{Woverwrite-recursive} -@cindex warnings, overwrite recursive -Do not warn when @option{-fno-automatic} is used with @option{-frecursive}. Recursion -will be broken if the relevant local variables do not have the attribute -@code{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 -@option{-Werror}. - -@item -Wreal-q-constant -@opindex @code{Wreal-q-constant} -@cindex warnings, @code{q} exponent-letter -Produce a warning if a real-literal-constant contains a @code{q} -exponent-letter. - -@item -Wsurprising -@opindex @code{Wsurprising} -@cindex warnings, suspicious code -Produce a warning when ``suspicious'' code constructs are encountered. -While technically legal these usually indicate that an error has been made. - -This currently produces a warning under the following circumstances: - -@itemize @bullet -@item -An INTEGER SELECT construct has a CASE that can never be matched as its -lower value is greater than its upper value. - -@item -A LOGICAL SELECT construct has three CASE statements. - -@item -A TRANSFER specifies a source that is shorter than the destination. - -@item -The type of a function result is declared more than once with the same type. If -@option{-pedantic} or standard-conforming mode is enabled, this is an error. - -@item -A @code{CHARACTER} variable is declared with negative length. - -@item -With @option{-fopenmp}, for fixed-form source code, when an @code{omx} -vendor-extension sentinel is encountered. (The equivalent @code{ompx}, -used in free-form source code, is diagnosed by default.) -@end itemize - -@item -Wtabs -@opindex @code{Wtabs} -@cindex warnings, tabs -@cindex tabulators -By default, tabs are accepted as whitespace, but tabs are not members -of the Fortran Character Set. For continuation lines, a tab followed -by a digit between 1 and 9 is supported. @option{-Wtabs} will cause a -warning to be issued if a tab is encountered. Note, @option{-Wtabs} is -active for @option{-pedantic}, @option{-std=f95}, @option{-std=f2003}, -@option{-std=f2008}, @option{-std=f2018} and -@option{-Wall}. - -@item -Wundefined-do-loop -@opindex @code{Wundefined-do-loop} -@cindex warnings, undefined do loop -Warn if a DO loop with step either 1 or -1 yields an underflow or an overflow -during iteration of an induction variable of the loop. -This option is implied by @option{-Wall}. - -@item -Wunderflow -@opindex @code{Wunderflow} -@cindex warnings, underflow -@cindex underflow -Produce a warning when numerical constant expressions are -encountered, which yield an UNDERFLOW during compilation. Enabled by default. - -@item -Wintrinsic-shadow -@opindex @code{Wintrinsic-shadow} -@cindex warnings, intrinsic -@cindex intrinsic -Warn if a user-defined procedure or module procedure has the same name as an -intrinsic; in this case, an explicit interface or @code{EXTERNAL} or -@code{INTRINSIC} declaration might be needed to get calls later resolved to -the desired intrinsic/procedure. This option is implied by @option{-Wall}. - -@item -Wuse-without-only -@opindex @code{Wuse-without-only} -@cindex warnings, use statements -@cindex intrinsic -Warn if a @code{USE} statement has no @code{ONLY} qualifier and -thus implicitly imports all public entities of the used module. - -@item -Wunused-dummy-argument -@opindex @code{Wunused-dummy-argument} -@cindex warnings, unused dummy argument -@cindex unused dummy argument -@cindex dummy argument, unused -Warn about unused dummy arguments. This option is implied by @option{-Wall}. - -@item -Wunused-parameter -@opindex @code{Wunused-parameter} -@cindex warnings, unused parameter -@cindex unused parameter -Contrary to @command{gcc}'s meaning of @option{-Wunused-parameter}, -@command{gfortran}'s implementation of this option does not warn -about unused dummy arguments (see @option{-Wunused-dummy-argument}), -but about unused @code{PARAMETER} values. @option{-Wunused-parameter} -is implied by @option{-Wextra} if also @option{-Wunused} or -@option{-Wall} is used. - -@item -Walign-commons -@opindex @code{Walign-commons} -@cindex warnings, alignment of @code{COMMON} blocks -@cindex alignment of @code{COMMON} blocks -By default, @command{gfortran} warns about any occasion of variables being -padded for proper alignment inside a @code{COMMON} block. This warning can be turned -off via @option{-Wno-align-commons}. See also @option{-falign-commons}. - -@item -Wfunction-elimination -@opindex @code{Wfunction-elimination} -@cindex function elimination -@cindex warnings, function elimination -Warn if any calls to impure functions are eliminated by the optimizations -enabled by the @option{-ffrontend-optimize} option. -This option is implied by @option{-Wextra}. - -@item -Wrealloc-lhs -@opindex @code{Wrealloc-lhs} -@cindex Reallocate the LHS in assignments, notification -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. @code{(:,:,:)}) 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 @option{-frealloc-lhs}. - -@item -Wrealloc-lhs-all -@opindex @code{Wrealloc-lhs-all} -Warn when the compiler inserts code to for allocation or reallocation of an -allocatable variable; this includes scalars and derived types. - -@item -Wcompare-reals -@opindex @code{Wcompare-reals} -Warn when comparing real or complex types for equality or inequality. -This option is implied by @option{-Wextra}. - -@item -Wtarget-lifetime -@opindex @code{Wtargt-lifetime} -Warn if the pointer in a pointer assignment might be longer than the its -target. This option is implied by @option{-Wall}. - -@item -Wzerotrip -@opindex @code{Wzerotrip} -Warn if a @code{DO} loop is known to execute zero times at compile -time. This option is implied by @option{-Wall}. - -@item -Wdo-subscript -@opindex @code{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 -@smallexample - real a(3) - do i=1,4 - if (condition(i)) then - a(i) = 1.2 - end if - end do -@end smallexample -This option is implied by @option{-Wextra}. - -@item -Werror -@opindex @code{Werror} -@cindex warnings, to errors -Turns all warnings into errors. -@end table - -@xref{Warning Options,,Options to Request or Suppress Errors and -Warnings, gcc,Using the GNU Compiler Collection (GCC)}, for information on -more options offered by the GBE shared by @command{gfortran}, @command{gcc} -and other GNU compilers. - -Some of these have no effect when compiling programs written in Fortran. - -@node Debugging Options -@section Options for debugging your program or GNU Fortran -@cindex options, debugging -@cindex debugging information options - -GNU Fortran has various special options that are used for debugging -either your program or the GNU Fortran compiler. - -@table @gcctabopt -@item -fdump-fortran-original -@opindex @code{fdump-fortran-original} -Output the internal parse tree after translating the source program -into internal representation. This option is mostly useful for -debugging the GNU Fortran compiler itself. The output generated by -this option might change between releases. This option may also -generate internal compiler errors for features which have only -recently been added. - -@item -fdump-fortran-optimized -@opindex @code{fdump-fortran-optimized} -Output the parse tree after front-end optimization. Mostly useful for -debugging the GNU Fortran compiler itself. The output generated by -this option might change between releases. This option may also -generate internal compiler errors for features which have only -recently been added. - -@item -fdump-parse-tree -@opindex @code{fdump-parse-tree} -Output the internal parse tree after translating the source program -into internal representation. Mostly useful for debugging the GNU -Fortran compiler itself. The output generated by this option might -change between releases. This option may also generate internal -compiler errors for features which have only recently been added. This -option is deprecated; use @code{-fdump-fortran-original} instead. - -@item -fdebug-aux-vars -@opindex @code{fdebug-aux-vars} -Renames internal variables created by the gfortran front end and makes -them accessible to a debugger. The name of the internal variables then -start with upper-case letters followed by an underscore. This option is -useful for debugging the compiler's code generation together with -@code{-fdump-tree-original} and enabling debugging of the executable -program by using @code{-g} or @code{-ggdb3}. - -@item -fdump-fortran-global -@opindex @code{fdump-fortran-global} -Output a list of the global identifiers after translating into -middle-end representation. Mostly useful for debugging the GNU Fortran -compiler itself. The output generated by this option might change -between releases. This option may also generate internal compiler -errors for features which have only recently been added. - -@item -ffpe-trap=@var{list} -@opindex @code{ffpe-trap=}@var{list} -Specify a list of floating point exception traps to enable. On most -systems, if a floating point exception occurs and the trap for that -exception is enabled, a SIGFPE signal will be sent and the program -being aborted, producing a core file useful for debugging. @var{list} -is a (possibly empty) comma-separated list of the following -exceptions: @samp{invalid} (invalid floating point operation, such as -@code{SQRT(-1.0)}), @samp{zero} (division by zero), @samp{overflow} -(overflow in a floating point operation), @samp{underflow} (underflow -in a floating point operation), @samp{inexact} (loss of precision -during operation), and @samp{denormal} (operation performed on a -denormal value). The first five exceptions correspond to the five -IEEE 754 exceptions, whereas the last one (@samp{denormal}) is not -part of the IEEE 754 standard but is available on some common -architectures such as x86. - -The first three exceptions (@samp{invalid}, @samp{zero}, and -@samp{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: '@code{ffpe-trap=}@var{list1} @code{ffpe-trap=}@var{list2}' -is equivalent to @code{ffpe-trap=}@var{list1},@var{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 rounding, and hence the @code{ffpe-trap=inexact} is likely to -be uninteresting in practice. - -By default no exception traps are enabled. - -@item -ffpe-summary=@var{list} -@opindex @code{ffpe-summary=}@var{list} -Specify a list of floating-point exceptions, whose flag status is printed -to @code{ERROR_UNIT} when invoking @code{STOP} and @code{ERROR STOP}. -@var{list} can be either @samp{none}, @samp{all} or a comma-separated list -of the following exceptions: @samp{invalid}, @samp{zero}, @samp{overflow}, -@samp{underflow}, @samp{inexact} and @samp{denormal}. (See -@option{-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 @samp{inexact} is shown. - -@item -fno-backtrace -@opindex @code{fno-backtrace} -@cindex backtrace -@cindex trace -When a serious runtime error is encountered or a deadly signal is -emitted (segmentation fault, illegal instruction, bus error, -floating-point exception, and the other POSIX signals that have the -action @samp{core}), the Fortran runtime library tries to output a -backtrace of the error. @code{-fno-backtrace} disables the backtrace -generation. This option only has influence for compilation of the -Fortran main program. - -@end table - -@xref{Debugging Options,,Options for Debugging Your Program or GCC, -gcc,Using the GNU Compiler Collection (GCC)}, for more information on -debugging options. - -@node Directory Options -@section Options for directory search -@cindex directory, options -@cindex options, directory search -@cindex search path -@cindex @code{INCLUDE} directive -@cindex directive, @code{INCLUDE} -These options affect how GNU Fortran searches -for files specified by the @code{INCLUDE} directive and where it searches -for previously compiled modules. - -It also affects the search paths used by @command{cpp} when used to preprocess -Fortran source. - -@table @gcctabopt -@item -I@var{dir} -@opindex @code{I}@var{dir} -@cindex directory, search paths for inclusion -@cindex inclusion, directory search paths for -@cindex search paths, for included files -@cindex paths, search -@cindex module search path -These affect interpretation of the @code{INCLUDE} directive -(as well as of the @code{#include} directive of the @command{cpp} -preprocessor). - -Also note that the general behavior of @option{-I} and -@code{INCLUDE} is pretty much the same as of @option{-I} with -@code{#include} in the @command{cpp} preprocessor, with regard to -looking for @file{header.gcc} files and other such things. - -This path is also used to search for @file{.mod} files when previously -compiled modules are required by a @code{USE} statement. - -@xref{Directory Options,,Options for Directory Search, -gcc,Using the GNU Compiler Collection (GCC)}, for information on the -@option{-I} option. - -@item -J@var{dir} -@opindex @code{J}@var{dir} -@opindex @code{M}@var{dir} -@cindex paths, search -@cindex module search path -This option specifies where to put @file{.mod} files for compiled modules. -It is also added to the list of directories to searched by an @code{USE} -statement. - -The default is the current directory. - -@item -fintrinsic-modules-path @var{dir} -@opindex @code{fintrinsic-modules-path} @var{dir} -@cindex paths, search -@cindex module search path -This option specifies the location of pre-compiled intrinsic modules, if -they are not in the default location expected by the compiler. -@end table - -@node Link Options -@section Influencing the linking step -@cindex options, linking -@cindex linking, static - -These options come into play when the compiler links object files into an -executable output file. They are meaningless if the compiler is not doing -a link step. - -@table @gcctabopt -@item -static-libgfortran -@opindex @code{static-libgfortran} -On systems that provide @file{libgfortran} as a shared and a static -library, this option forces the use of the static version. If no -shared version of @file{libgfortran} was built when the compiler was -configured, this option has no effect. -@end table - - -@table @gcctabopt -@item -static-libquadmath -@opindex @code{static-libquadmath} -On systems that provide @file{libquadmath} as a shared and a static -library, this option forces the use of the static version. If no -shared version of @file{libquadmath} was built when the compiler was -configured, this option has no effect. - -Please note that the @file{libquadmath} runtime library is licensed under the -GNU Lesser General Public License (LGPL), and linking it statically introduces -requirements when redistributing the resulting binaries. -@end table - - -@node Runtime Options -@section Influencing runtime behavior -@cindex options, runtime - -These options affect the runtime behavior of programs compiled with GNU Fortran. - -@table @gcctabopt -@item -fconvert=@var{conversion} -@opindex @code{fconvert=}@var{conversion} -Specify the representation of data for unformatted files. Valid -values for conversion on most systems are: @samp{native}, the default; -@samp{swap}, swap between big- and little-endian; @samp{big-endian}, use -big-endian representation for unformatted files; @samp{little-endian}, use -little-endian representation for unformatted files. - -On POWER systems which suppport @option{-mabi=ieeelongdouble}, -there are additional options, which can be combined with others with -commas. Those are -@itemize @w{} -@item @option{-fconvert=r16_ieee} Use IEEE 128-bit format for -@code{REAL(KIND=16)}. -@item @option{-fconvert=r16_ibm} Use IBM long double format for -@code{REAL(KIND=16)}. -@end itemize - -@emph{This option has an effect only when used in the main program. -The @code{CONVERT} specifier and the GFORTRAN_CONVERT_UNIT environment -variable override the default specified by @option{-fconvert}.} - -@item -frecord-marker=@var{length} -@opindex @code{frecord-marker=}@var{length} -Specify the length of record markers for unformatted files. -Valid values for @var{length} are 4 and 8. Default is 4. -@emph{This is different from previous versions of @command{gfortran}}, -which specified a default record marker length of 8 on most -systems. If you want to read or write files compatible -with earlier versions of @command{gfortran}, use @option{-frecord-marker=8}. - -@item -fmax-subrecord-length=@var{length} -@opindex @code{fmax-subrecord-length=}@var{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. - -@item -fsign-zero -@opindex @code{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 @code{SIGN} intrinsic. @option{-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 @code{SIGN} intrinsic for -compatibility with Fortran 77. The default is @option{-fsign-zero}. -@end table - -@node Code Gen Options -@section Options for code generation conventions -@cindex code generation, conventions -@cindex options, code generation -@cindex options, run-time - -These machine-independent options control the interface conventions -used in code generation. - -Most of them have both positive and negative forms; the negative form -of @option{-ffoo} would be @option{-fno-foo}. In the table below, only -one of the forms is listed---the one which is not the default. You -can figure out the other form by either removing @option{no-} or adding -it. - -@table @gcctabopt -@item -fno-automatic -@opindex @code{fno-automatic} -@cindex @code{SAVE} statement -@cindex statement, @code{SAVE} -Treat each program unit (except those marked as RECURSIVE) as if the -@code{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 @option{-static} or @option{-save}.) -The default, which is @option{-fautomatic}, uses the stack for local -variables smaller than the value given by @option{-fmax-stack-var-size}. -Use the option @option{-frecursive} to use no static memory. - -Local variables or arrays having an explicit @code{SAVE} attribute are -silently ignored unless the @option{-pedantic} option is added. - -@item -ff2c -@opindex ff2c -@cindex calling convention -@cindex @command{f2c} calling convention -@cindex @command{g77} calling convention -@cindex libf2c calling convention -Generate code designed to be compatible with code generated -by @command{g77} and @command{f2c}. - -The calling conventions used by @command{g77} (originally implemented -in @command{f2c}) require functions that return type -default @code{REAL} to actually return the C type @code{double}, and -functions that return type @code{COMPLEX} to return the values via an -extra argument in the calling sequence that points to where to -store the return value. Under the default GNU calling conventions, such -functions simply return their results as they would in GNU -C---default @code{REAL} functions return the C type @code{float}, and -@code{COMPLEX} functions return the GNU C type @code{complex}. -Additionally, this option implies the @option{-fsecond-underscore} -option, unless @option{-fno-second-underscore} is explicitly requested. - -This does not affect the generation of code that interfaces with -the @command{libgfortran} library. - -@emph{Caution:} It is not a good idea to mix Fortran code compiled with -@option{-ff2c} with code compiled with the default @option{-fno-f2c} -calling conventions as, calling @code{COMPLEX} or default @code{REAL} -functions between program parts which were compiled with different -calling conventions will break at execution time. - -@emph{Caution:} This will break code which passes intrinsic functions -of type default @code{REAL} or @code{COMPLEX} as actual arguments, as -the library implementations use the @option{-fno-f2c} calling conventions. - -@item -fno-underscoring -@opindex @code{fno-underscoring} -@cindex underscore -@cindex symbol names, underscores -@cindex transforming symbol names -@cindex symbol names, transforming -Do not transform names of entities specified in the Fortran -source file by appending underscores to them. - -With @option{-funderscoring} in effect, GNU Fortran appends one -underscore to external names with no underscores. This is done to ensure -compatibility with code produced by many UNIX Fortran compilers. - -@emph{Caution}: The default behavior of GNU Fortran is -incompatible with @command{f2c} and @command{g77}, please use the -@option{-ff2c} option if you want object files compiled with -GNU Fortran to be compatible with object code created with these -tools. - -Use of @option{-fno-underscoring} is not recommended unless you are -experimenting with issues such as integration of GNU Fortran into -existing system environments (vis-@`{a}-vis existing libraries, tools, -and so on). - -For example, with @option{-funderscoring}, and assuming that @code{j()} and -@code{max_count()} are external functions while @code{my_var} and -@code{lvar} are local variables, a statement like -@smallexample -I = J() + MAX_COUNT (MY_VAR, LVAR) -@end smallexample -@noindent -is implemented as something akin to: -@smallexample -i = j_() + max_count__(&my_var__, &lvar); -@end smallexample - -With @option{-fno-underscoring}, the same statement is implemented as: - -@smallexample -i = j() + max_count(&my_var, &lvar); -@end smallexample - -Use of @option{-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 @emph{not} mean that the -interface implemented by GNU Fortran for an external name matches the -interface implemented by some other language for that same name. -That is, getting code produced by GNU Fortran to link to code produced -by some other compiler using this or any other method can be only a -small part of the overall solution---getting the code generated by -both compilers to agree on issues other than naming can require -significant effort, and, unlike naming disagreements, linkers normally -cannot detect disagreements in these other areas. - -Also, note that with @option{-fno-underscoring}, the lack of appended -underscores introduces the very real possibility that a user-defined -external name will conflict with a name in a system library, which -could make finding unresolved-reference bugs quite difficult in some -cases---they might occur at program run time, and show up only as -buggy behavior at run time. - -In future versions of GNU Fortran we hope to improve naming and linking -issues so that debugging always involves using the names as they appear -in the source, even if the names as seen by the linker are mangled to -prevent accidental linking between procedures with incompatible -interfaces. - -@item -fsecond-underscore -@opindex @code{fsecond-underscore} -@cindex underscore -@cindex symbol names, underscores -@cindex transforming symbol names -@cindex symbol names, transforming -@cindex @command{f2c} calling convention -@cindex @command{g77} calling convention -@cindex libf2c calling convention -By default, GNU Fortran appends an underscore to external -names. If this option is used GNU Fortran appends two -underscores to names with underscores and one underscore to external names -with no underscores. GNU Fortran also appends two underscores to -internal names with underscores to avoid naming collisions with external -names. - -This option has no effect if @option{-fno-underscoring} is -in effect. It is implied by the @option{-ff2c} option. - -Otherwise, with this option, an external name such as @code{MAX_COUNT} -is implemented as a reference to the link-time external symbol -@code{max_count__}, instead of @code{max_count_}. This is required -for compatibility with @command{g77} and @command{f2c}, and is implied -by use of the @option{-ff2c} option. - -@item -fcoarray=@var{<keyword>} -@opindex @code{fcoarray} -@cindex coarrays - -@table @asis -@item @samp{none} -Disable coarray support; using coarray declarations and image-control -statements will produce a compile-time error. (Default) - -@item @samp{single} -Single-image mode, i.e. @code{num_images()} is always one. - -@item @samp{lib} -Library-based coarray parallelization; a suitable GNU Fortran coarray -library needs to be linked. -@end table - - -@item -fcheck=@var{<keyword>} -@opindex @code{fcheck} -@cindex array, bounds checking -@cindex bit intrinsics checking -@cindex bounds checking -@cindex pointer checking -@cindex memory checking -@cindex range checking -@cindex subscript checking -@cindex checking subscripts -@cindex run-time checking -@cindex checking array temporaries - -Enable the generation of run-time checks; the argument shall be -a comma-delimited list of the following keywords. Prefixing a check with -@option{no-} disables it if it was activated by a previous specification. - -@table @asis -@item @samp{all} -Enable all run-time test of @option{-fcheck}. - -@item @samp{array-temps} -Warns at run time when for passing an actual argument a temporary array -had to be generated. The information generated by this warning is -sometimes useful in optimization, in order to avoid such temporaries. - -Note: The warning is only printed once per location. - -@item @samp{bits} -Enable generation of run-time checks for invalid arguments to the bit -manipulation intrinsics. - -@item @samp{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 @option{-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. - -@item @samp{do} -Enable generation of run-time checks for invalid modification of loop -iteration variables. - -@item @samp{mem} -Enable generation of run-time checks for memory allocation. -Note: This option does not affect explicit allocations using the -@code{ALLOCATE} statement, which will be always checked. - -@item @samp{pointer} -Enable generation of run-time checks for pointers and allocatables. - -@item @samp{recursion} -Enable generation of run-time checks for recursively called subroutines and -functions which are not marked as recursive. See also @option{-frecursive}. -Note: This check does not work for OpenMP programs and is disabled if used -together with @option{-frecursive} and @option{-fopenmp}. -@end table - -Example: Assuming you have a file @file{foo.f90}, the command -@smallexample - gfortran -fcheck=all,no-array-temps foo.f90 -@end smallexample -will compile the file with all checks enabled as specified above except -warnings for generated array temporaries. - - -@item -fbounds-check -@opindex @code{fbounds-check} -@c Note: This option is also referred in gcc's manpage -Deprecated alias for @option{-fcheck=bounds}. - -@item -ftail-call-workaround -@itemx -ftail-call-workaround=@var{n} -@opindex @code{tail-call-workaround} -Some C interfaces to Fortran codes violate the gfortran ABI by -omitting the hidden character length arguments as described in -@xref{Argument passing conventions}. This can lead to crashes -because pushing arguments 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 @option{-ftail-call-workaround=2} tail call optimization -is disabled in all gfortran procedures with character arguments, -with @option{-ftail-call-workaround=1} or equivalent -@option{-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 @emph{very strongly} recommended to fix the code in question. -The @option{-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, @option{-fno-tail-call-workaround} or equivalent -@option{-ftail-call-workaround=0}, can be used to disable this option. - -Default is currently @option{-ftail-call-workaround}, this will change -in future releases. - -@item -fcheck-array-temporaries -@opindex @code{fcheck-array-temporaries} -Deprecated alias for @option{-fcheck=array-temps}. - -@item -fmax-array-constructor=@var{n} -@opindex @code{fmax-array-constructor} -This option can be used to increase the upper limit permitted in -array constructors. The code below requires this option to expand -the array at compile time. - -@smallexample -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 -@end smallexample - -@emph{Caution: This option can lead to long compile times and excessively -large object files.} - -The default value for @var{n} is 65535. - - -@item -fmax-stack-var-size=@var{n} -@opindex @code{fmax-stack-var-size} -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 @option{-frecursive} to -allow for recursive procedures which do not have a RECURSIVE attribute or -for parallel programs. Use @option{-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 @var{n} is 65536. - -@item -fstack-arrays -@opindex @code{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 @option{-Ofast} unless -@option{-fmax-stack-var-size} is specified. - -@item -fpack-derived -@opindex @code{fpack-derived} -@cindex structure packing -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. - -@item -frepack-arrays -@opindex @code{frepack-arrays} -@cindex repacking 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. - -@item -fshort-enums -@opindex @code{fshort-enums} -This option is provided for interoperability with C code that was -compiled with the @option{-fshort-enums} option. It will make -GNU Fortran choose the smallest @code{INTEGER} kind a given -enumerator set will fit in, and give all its enumerators this kind. - -@item -finline-arg-packing -@opindex @code{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 @code{foo} in -@smallexample - subroutine foo(a) - real, dimension(*) :: a - end subroutine foo - subroutine bar(b) - real, dimension(:) :: b - call foo(b) - end subroutine bar -@end smallexample - -When @option{-finline-arg-packing} is in effect, this packing will be -performed by inline code. This allows for more optimization while -increasing code size. - -@option{-finline-arg-packing} is implied by any of the @option{-O} options -except when optimizing for size via @option{-Os}. If the code -contains a very large number of argument that have to be packed, code -size and also compilation time may become excessive. If that is the -case, it may be better to disable this option. Instances of packing -can be found by using @option{-Warray-temporaries}. - -@item -fexternal-blas -@opindex @code{fexternal-blas} -This option will make @command{gfortran} generate calls to BLAS functions -for some matrix operations like @code{MATMUL}, instead of using our own -algorithms, if the size of the matrices involved is larger than a given -limit (see @option{-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. - -@item -fblas-matmul-limit=@var{n} -@opindex @code{fblas-matmul-limit} -Only significant when @option{-fexternal-blas} is in effect. -Matrix multiplication of matrices with size larger than (or equal to) @var{n} -will be performed by calls to BLAS functions, while others will be -handled by @command{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 @var{n} is 30. - -@item -finline-matmul-limit=@var{n} -@opindex @code{finline-matmul-limit} -When front-end optimization is active, some calls to the @code{MATMUL} -intrinsic function 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. Setting -@code{-finline-matmul-limit=0} will disable inlining in all cases. -Setting this option with a value of @var{n} will produce inline code -for matrices with size up to @var{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 @var{n} is 30. The @code{-fblas-matmul-limit} -can be used to change this value. - -@item -frecursive -@opindex @code{frecursive} -Allow indirect recursion by forcing all local arrays to be allocated -on the stack. This flag cannot be used together with -@option{-fmax-stack-var-size=} or @option{-fno-automatic}. - -@item -finit-local-zero -@itemx -finit-derived -@itemx -finit-integer=@var{n} -@itemx -finit-real=@var{<zero|inf|-inf|nan|snan>} -@itemx -finit-logical=@var{<true|false>} -@itemx -finit-character=@var{n} -@opindex @code{finit-local-zero} -@opindex @code{finit-derived} -@opindex @code{finit-integer} -@opindex @code{finit-real} -@opindex @code{finit-logical} -@opindex @code{finit-character} -The @option{-finit-local-zero} option instructs the compiler to -initialize local @code{INTEGER}, @code{REAL}, and @code{COMPLEX} -variables to zero, @code{LOGICAL} variables to false, and -@code{CHARACTER} variables to a string of null bytes. Finer-grained -initialization options are provided by the -@option{-finit-integer=@var{n}}, -@option{-finit-real=@var{<zero|inf|-inf|nan|snan>}} (which also initializes -the real and imaginary parts of local @code{COMPLEX} variables), -@option{-finit-logical=@var{<true|false>}}, and -@option{-finit-character=@var{n}} (where @var{n} is an ASCII character -value) options. - -With @option{-finit-derived}, components of derived type variables will be -initialized according to these flags. Components whose type is not covered by -an explicit @option{-finit-*} flag will be treated as described above with -@option{-finit-local-zero}. - -These options do not initialize -@itemize @bullet -@item -objects with the POINTER attribute -@item -allocatable arrays -@item -variables that appear in an @code{EQUIVALENCE} statement. -@end itemize -(These limitations may be removed in future releases). - -Note that the @option{-finit-real=nan} option initializes @code{REAL} -and @code{COMPLEX} variables with a quiet NaN. For a signalling NaN -use @option{-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 @option{-ffpe-trap}). - -The @option{-finit-integer} option will parse the value into an -integer of type @code{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 @option{-finit-*} options will -silence warnings that would have been emitted by @option{-Wuninitialized} -for the affected local variables. - -@item -falign-commons -@opindex @code{falign-commons} -@cindex alignment of @code{COMMON} blocks -By default, @command{gfortran} enforces proper alignment of all variables in a -@code{COMMON} block by padding them as needed. On certain platforms this is mandatory, -on others it increases performance. If a @code{COMMON} block is not declared with -consistent data types everywhere, this padding can cause trouble, and -@option{-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 @code{COMMON} block. -To avoid potential alignment issues in @code{COMMON} blocks, it is recommended to order -objects from largest to smallest. - -@item -fno-protect-parens -@opindex @code{fno-protect-parens} -@cindex re-association of parenthesized expressions -By default the parentheses in expression are honored for all optimization -levels such that the compiler does not do any re-association. Using -@option{-fno-protect-parens} allows the compiler to reorder @code{REAL} and -@code{COMPLEX} expressions to produce faster code. Note that for the re-association -optimization @option{-fno-signed-zeros} and @option{-fno-trapping-math} -need to be in effect. The parentheses protection is enabled by default, unless -@option{-Ofast} is given. - -@item -frealloc-lhs -@opindex @code{frealloc-lhs} -@cindex Reallocate the LHS in assignments -An allocatable left-hand side of an intrinsic assignment is automatically -(re)allocated if it is either unallocated or has a different shape. The -option is enabled by default except when @option{-std=f95} is given. See -also @option{-Wrealloc-lhs}. - -@item -faggressive-function-elimination -@opindex @code{faggressive-function-elimination} -@cindex Elimination of functions with identical argument lists -Functions with identical argument lists are eliminated within -statements, regardless of whether these functions are marked -@code{PURE} or not. For example, in -@smallexample - a = f(b,c) + f(b,c) -@end smallexample -there will only be a single call to @code{f}. This option only works -if @option{-ffrontend-optimize} is in effect. - -@item -ffrontend-optimize -@opindex @code{frontend-optimize} -@cindex Front-end optimization -This option performs front-end optimization, based on manipulating -parts the Fortran parse tree. Enabled by default by any @option{-O} option -except @option{-O0} and @option{-Og}. Optimizations enabled by this option -include: -@itemize @bullet -@item inlining calls to @code{MATMUL}, -@item elimination of identical function calls within expressions, -@item removing unnecessary calls to @code{TRIM} in comparisons and assignments, -@item replacing @code{TRIM(a)} with @code{a(1:LEN_TRIM(a))} and -@item short-circuiting of logical operators (@code{.AND.} and @code{.OR.}). -@end itemize -It can be deselected by specifying @option{-fno-frontend-optimize}. - -@item -ffrontend-loop-interchange -@opindex @code{frontend-loop-interchange} -@cindex loop interchange, Fortran -Attempt to interchange loops in the Fortran front end where -profitable. Enabled by default by any @option{-O} option. -At the moment, this option only affects @code{FORALL} and -@code{DO CONCURRENT} statements with several forall triplets. -@end table - -@xref{Code Gen Options,,Options for Code Generation Conventions, -gcc,Using the GNU Compiler Collection (GCC)}, for information on more options -offered by the GBE -shared by @command{gfortran}, @command{gcc}, and other GNU compilers. - -@c man end - -@node Interoperability Options -@section Options for interoperability with other languages - -@table @asis - -@item -fc-prototypes -@opindex @code{c-prototypes} -@cindex Generating C prototypes from Fortran BIND(C) enteties -This option will generate C prototypes from @code{BIND(C)} variable -declarations, types and procedure interfaces and writes them to -standard output. @code{ENUM} is not yet supported. - -The generated prototypes may need inclusion of an appropriate header, -such as @code{<stdint.h>} or @code{<stdlib.h>}. For types which are -not specified using the appropriate kind from the @code{iso_c_binding} -module, a warning is added as a comment to the code. - -For function pointers, a pointer to a function returning @code{int} -without an explicit argument list is generated. - -Example of use: -@smallexample -$ gfortran -fc-prototypes -fsyntax-only foo.f90 > foo.h -@end smallexample -where the C code intended for interoperating with the Fortran code -then uses @code{#include "foo.h"}. - -@item -fc-prototypes-external -@opindex @code{c-prototypes-external} -@cindex Generating C prototypes from external procedures -This option will generate C prototypes from external functions and -subroutines and write them to standard output. This may be useful for -making sure that C bindings to Fortran code are correct. This option -does not generate prototypes for @code{BIND(C)} procedures, use -@option{-fc-prototypes} for that. - -The generated prototypes may need inclusion of an appropriate -header, such as @code{<stdint.h>} or @code{<stdlib.h>}. - -This is primarily meant for legacy code to ensure that existing C -bindings match what @command{gfortran} emits. The generated C -prototypes should be correct for the current version of the compiler, -but may not match what other compilers or earlier versions of -@command{gfortran} need. For new developments, use of the -@code{BIND(C)} features is recommended. - -Example of use: -@smallexample -$ gfortran -fc-prototypes-external -fsyntax-only foo.f > foo.h -@end smallexample -where the C code intended for interoperating with the Fortran code -then uses @code{#include "foo.h"}. -@end table - -@node Environment Variables -@section Environment variables affecting @command{gfortran} -@cindex environment variable - -@c man begin ENVIRONMENT - -The @command{gfortran} compiler currently does not make use of any environment -variables to control its operation above and beyond those -that affect the operation of @command{gcc}. - -@xref{Environment Variables,,Environment Variables Affecting GCC, -gcc,Using the GNU Compiler Collection (GCC)}, for information on environment -variables. - -@xref{Runtime}, for environment variables that affect the -run-time behavior of programs compiled with GNU Fortran. -@c man end |