intrinsic.texi revision 1.1.1.2 1 1.1 mrg @ignore
2 1.1.1.2 mrg Copyright (C) 2005-2020 Free Software Foundation, Inc.
3 1.1 mrg This is part of the GNU Fortran manual.
4 1.1 mrg For copying conditions, see the file gfortran.texi.
5 1.1 mrg
6 1.1 mrg Permission is granted to copy, distribute and/or modify this document
7 1.1 mrg under the terms of the GNU Free Documentation License, Version 1.3 or
8 1.1 mrg any later version published by the Free Software Foundation; with the
9 1.1 mrg Invariant Sections being ``Funding Free Software'', the Front-Cover
10 1.1 mrg Texts being (a) (see below), and with the Back-Cover Texts being (b)
11 1.1 mrg (see below). A copy of the license is included in the gfdl(7) man page.
12 1.1 mrg
13 1.1 mrg
14 1.1 mrg Some basic guidelines for editing this document:
15 1.1 mrg
16 1.1 mrg (1) The intrinsic procedures are to be listed in alphabetical order.
17 1.1 mrg (2) The generic name is to be used.
18 1.1 mrg (3) The specific names are included in the function index and in a
19 1.1 mrg table at the end of the node (See ABS entry).
20 1.1 mrg (4) Try to maintain the same style for each entry.
21 1.1 mrg
22 1.1 mrg
23 1.1 mrg @end ignore
24 1.1 mrg
25 1.1 mrg @tex
26 1.1 mrg \gdef\acosd{\mathop{\rm acosd}\nolimits}
27 1.1 mrg \gdef\asind{\mathop{\rm asind}\nolimits}
28 1.1 mrg \gdef\atand{\mathop{\rm atand}\nolimits}
29 1.1 mrg \gdef\acos{\mathop{\rm acos}\nolimits}
30 1.1 mrg \gdef\asin{\mathop{\rm asin}\nolimits}
31 1.1 mrg \gdef\atan{\mathop{\rm atan}\nolimits}
32 1.1 mrg \gdef\acosh{\mathop{\rm acosh}\nolimits}
33 1.1 mrg \gdef\asinh{\mathop{\rm asinh}\nolimits}
34 1.1 mrg \gdef\atanh{\mathop{\rm atanh}\nolimits}
35 1.1 mrg \gdef\cosd{\mathop{\rm cosd}\nolimits}
36 1.1 mrg @end tex
37 1.1 mrg
38 1.1 mrg
39 1.1 mrg @node Intrinsic Procedures
40 1.1 mrg @chapter Intrinsic Procedures
41 1.1 mrg @cindex intrinsic procedures
42 1.1 mrg
43 1.1 mrg @menu
44 1.1 mrg * Introduction: Introduction to Intrinsics
45 1.1 mrg * @code{ABORT}: ABORT, Abort the program
46 1.1 mrg * @code{ABS}: ABS, Absolute value
47 1.1 mrg * @code{ACCESS}: ACCESS, Checks file access modes
48 1.1 mrg * @code{ACHAR}: ACHAR, Character in @acronym{ASCII} collating sequence
49 1.1 mrg * @code{ACOS}: ACOS, Arccosine function
50 1.1 mrg * @code{ACOSD}: ACOSD, Arccosine function, degrees
51 1.1 mrg * @code{ACOSH}: ACOSH, Inverse hyperbolic cosine function
52 1.1 mrg * @code{ADJUSTL}: ADJUSTL, Left adjust a string
53 1.1 mrg * @code{ADJUSTR}: ADJUSTR, Right adjust a string
54 1.1 mrg * @code{AIMAG}: AIMAG, Imaginary part of complex number
55 1.1 mrg * @code{AINT}: AINT, Truncate to a whole number
56 1.1 mrg * @code{ALARM}: ALARM, Set an alarm clock
57 1.1 mrg * @code{ALL}: ALL, Determine if all values are true
58 1.1 mrg * @code{ALLOCATED}: ALLOCATED, Status of allocatable entity
59 1.1 mrg * @code{AND}: AND, Bitwise logical AND
60 1.1 mrg * @code{ANINT}: ANINT, Nearest whole number
61 1.1 mrg * @code{ANY}: ANY, Determine if any values are true
62 1.1 mrg * @code{ASIN}: ASIN, Arcsine function
63 1.1 mrg * @code{ASIND}: ASIND, Arcsine function, degrees
64 1.1 mrg * @code{ASINH}: ASINH, Inverse hyperbolic sine function
65 1.1 mrg * @code{ASSOCIATED}: ASSOCIATED, Status of a pointer or pointer/target pair
66 1.1 mrg * @code{ATAN}: ATAN, Arctangent function
67 1.1 mrg * @code{ATAND}: ATAND, Arctangent function, degrees
68 1.1 mrg * @code{ATAN2}: ATAN2, Arctangent function
69 1.1 mrg * @code{ATAN2D}: ATAN2D, Arctangent function, degrees
70 1.1 mrg * @code{ATANH}: ATANH, Inverse hyperbolic tangent function
71 1.1 mrg * @code{ATOMIC_ADD}: ATOMIC_ADD, Atomic ADD operation
72 1.1 mrg * @code{ATOMIC_AND}: ATOMIC_AND, Atomic bitwise AND operation
73 1.1 mrg * @code{ATOMIC_CAS}: ATOMIC_CAS, Atomic compare and swap
74 1.1 mrg * @code{ATOMIC_DEFINE}: ATOMIC_DEFINE, Setting a variable atomically
75 1.1 mrg * @code{ATOMIC_FETCH_ADD}: ATOMIC_FETCH_ADD, Atomic ADD operation with prior fetch
76 1.1 mrg * @code{ATOMIC_FETCH_AND}: ATOMIC_FETCH_AND, Atomic bitwise AND operation with prior fetch
77 1.1 mrg * @code{ATOMIC_FETCH_OR}: ATOMIC_FETCH_OR, Atomic bitwise OR operation with prior fetch
78 1.1 mrg * @code{ATOMIC_FETCH_XOR}: ATOMIC_FETCH_XOR, Atomic bitwise XOR operation with prior fetch
79 1.1 mrg * @code{ATOMIC_OR}: ATOMIC_OR, Atomic bitwise OR operation
80 1.1 mrg * @code{ATOMIC_REF}: ATOMIC_REF, Obtaining the value of a variable atomically
81 1.1 mrg * @code{ATOMIC_XOR}: ATOMIC_XOR, Atomic bitwise OR operation
82 1.1 mrg * @code{BACKTRACE}: BACKTRACE, Show a backtrace
83 1.1 mrg * @code{BESSEL_J0}: BESSEL_J0, Bessel function of the first kind of order 0
84 1.1 mrg * @code{BESSEL_J1}: BESSEL_J1, Bessel function of the first kind of order 1
85 1.1 mrg * @code{BESSEL_JN}: BESSEL_JN, Bessel function of the first kind
86 1.1 mrg * @code{BESSEL_Y0}: BESSEL_Y0, Bessel function of the second kind of order 0
87 1.1 mrg * @code{BESSEL_Y1}: BESSEL_Y1, Bessel function of the second kind of order 1
88 1.1 mrg * @code{BESSEL_YN}: BESSEL_YN, Bessel function of the second kind
89 1.1 mrg * @code{BGE}: BGE, Bitwise greater than or equal to
90 1.1 mrg * @code{BGT}: BGT, Bitwise greater than
91 1.1 mrg * @code{BIT_SIZE}: BIT_SIZE, Bit size inquiry function
92 1.1 mrg * @code{BLE}: BLE, Bitwise less than or equal to
93 1.1 mrg * @code{BLT}: BLT, Bitwise less than
94 1.1 mrg * @code{BTEST}: BTEST, Bit test function
95 1.1 mrg * @code{C_ASSOCIATED}: C_ASSOCIATED, Status of a C pointer
96 1.1 mrg * @code{C_F_POINTER}: C_F_POINTER, Convert C into Fortran pointer
97 1.1 mrg * @code{C_F_PROCPOINTER}: C_F_PROCPOINTER, Convert C into Fortran procedure pointer
98 1.1 mrg * @code{C_FUNLOC}: C_FUNLOC, Obtain the C address of a procedure
99 1.1 mrg * @code{C_LOC}: C_LOC, Obtain the C address of an object
100 1.1 mrg * @code{C_SIZEOF}: C_SIZEOF, Size in bytes of an expression
101 1.1 mrg * @code{CEILING}: CEILING, Integer ceiling function
102 1.1 mrg * @code{CHAR}: CHAR, Integer-to-character conversion function
103 1.1 mrg * @code{CHDIR}: CHDIR, Change working directory
104 1.1 mrg * @code{CHMOD}: CHMOD, Change access permissions of files
105 1.1 mrg * @code{CMPLX}: CMPLX, Complex conversion function
106 1.1 mrg * @code{CO_BROADCAST}: CO_BROADCAST, Copy a value to all images the current set of images
107 1.1 mrg * @code{CO_MAX}: CO_MAX, Maximal value on the current set of images
108 1.1 mrg * @code{CO_MIN}: CO_MIN, Minimal value on the current set of images
109 1.1 mrg * @code{CO_REDUCE}: CO_REDUCE, Reduction of values on the current set of images
110 1.1 mrg * @code{CO_SUM}: CO_SUM, Sum of values on the current set of images
111 1.1 mrg * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
112 1.1 mrg * @code{COMPILER_OPTIONS}: COMPILER_OPTIONS, Options passed to the compiler
113 1.1 mrg * @code{COMPILER_VERSION}: COMPILER_VERSION, Compiler version string
114 1.1 mrg * @code{COMPLEX}: COMPLEX, Complex conversion function
115 1.1 mrg * @code{CONJG}: CONJG, Complex conjugate function
116 1.1 mrg * @code{COS}: COS, Cosine function
117 1.1 mrg * @code{COSD}: COSD, Cosine function, degrees
118 1.1 mrg * @code{COSH}: COSH, Hyperbolic cosine function
119 1.1 mrg * @code{COTAN}: COTAN, Cotangent function
120 1.1 mrg * @code{COTAND}: COTAND, Cotangent function, degrees
121 1.1 mrg * @code{COUNT}: COUNT, Count occurrences of TRUE in an array
122 1.1 mrg * @code{CPU_TIME}: CPU_TIME, CPU time subroutine
123 1.1 mrg * @code{CSHIFT}: CSHIFT, Circular shift elements of an array
124 1.1 mrg * @code{CTIME}: CTIME, Subroutine (or function) to convert a time into a string
125 1.1 mrg * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
126 1.1 mrg * @code{DBLE}: DBLE, Double precision conversion function
127 1.1 mrg * @code{DCMPLX}: DCMPLX, Double complex conversion function
128 1.1 mrg * @code{DIGITS}: DIGITS, Significant digits function
129 1.1 mrg * @code{DIM}: DIM, Positive difference
130 1.1 mrg * @code{DOT_PRODUCT}: DOT_PRODUCT, Dot product function
131 1.1 mrg * @code{DPROD}: DPROD, Double product function
132 1.1 mrg * @code{DREAL}: DREAL, Double real part function
133 1.1 mrg * @code{DSHIFTL}: DSHIFTL, Combined left shift
134 1.1 mrg * @code{DSHIFTR}: DSHIFTR, Combined right shift
135 1.1 mrg * @code{DTIME}: DTIME, Execution time subroutine (or function)
136 1.1 mrg * @code{EOSHIFT}: EOSHIFT, End-off shift elements of an array
137 1.1 mrg * @code{EPSILON}: EPSILON, Epsilon function
138 1.1 mrg * @code{ERF}: ERF, Error function
139 1.1 mrg * @code{ERFC}: ERFC, Complementary error function
140 1.1 mrg * @code{ERFC_SCALED}: ERFC_SCALED, Exponentially-scaled complementary error function
141 1.1 mrg * @code{ETIME}: ETIME, Execution time subroutine (or function)
142 1.1 mrg * @code{EVENT_QUERY}: EVENT_QUERY, Query whether a coarray event has occurred
143 1.1 mrg * @code{EXECUTE_COMMAND_LINE}: EXECUTE_COMMAND_LINE, Execute a shell command
144 1.1 mrg * @code{EXIT}: EXIT, Exit the program with status.
145 1.1 mrg * @code{EXP}: EXP, Exponential function
146 1.1 mrg * @code{EXPONENT}: EXPONENT, Exponent function
147 1.1 mrg * @code{EXTENDS_TYPE_OF}: EXTENDS_TYPE_OF, Query dynamic type for extension
148 1.1 mrg * @code{FDATE}: FDATE, Subroutine (or function) to get the current time as a string
149 1.1 mrg * @code{FGET}: FGET, Read a single character in stream mode from stdin
150 1.1 mrg * @code{FGETC}: FGETC, Read a single character in stream mode
151 1.1 mrg * @code{FINDLOC}: FINDLOC, Search an array for a value
152 1.1 mrg * @code{FLOOR}: FLOOR, Integer floor function
153 1.1 mrg * @code{FLUSH}: FLUSH, Flush I/O unit(s)
154 1.1 mrg * @code{FNUM}: FNUM, File number function
155 1.1 mrg * @code{FPUT}: FPUT, Write a single character in stream mode to stdout
156 1.1 mrg * @code{FPUTC}: FPUTC, Write a single character in stream mode
157 1.1 mrg * @code{FRACTION}: FRACTION, Fractional part of the model representation
158 1.1 mrg * @code{FREE}: FREE, Memory de-allocation subroutine
159 1.1 mrg * @code{FSEEK}: FSEEK, Low level file positioning subroutine
160 1.1 mrg * @code{FSTAT}: FSTAT, Get file status
161 1.1 mrg * @code{FTELL}: FTELL, Current stream position
162 1.1 mrg * @code{GAMMA}: GAMMA, Gamma function
163 1.1 mrg * @code{GERROR}: GERROR, Get last system error message
164 1.1 mrg * @code{GETARG}: GETARG, Get command line arguments
165 1.1 mrg * @code{GET_COMMAND}: GET_COMMAND, Get the entire command line
166 1.1 mrg * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
167 1.1 mrg * @code{GETCWD}: GETCWD, Get current working directory
168 1.1 mrg * @code{GETENV}: GETENV, Get an environmental variable
169 1.1 mrg * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
170 1.1 mrg * @code{GETGID}: GETGID, Group ID function
171 1.1 mrg * @code{GETLOG}: GETLOG, Get login name
172 1.1 mrg * @code{GETPID}: GETPID, Process ID function
173 1.1 mrg * @code{GETUID}: GETUID, User ID function
174 1.1 mrg * @code{GMTIME}: GMTIME, Convert time to GMT info
175 1.1 mrg * @code{HOSTNM}: HOSTNM, Get system host name
176 1.1 mrg * @code{HUGE}: HUGE, Largest number of a kind
177 1.1 mrg * @code{HYPOT}: HYPOT, Euclidean distance function
178 1.1 mrg * @code{IACHAR}: IACHAR, Code in @acronym{ASCII} collating sequence
179 1.1 mrg * @code{IALL}: IALL, Bitwise AND of array elements
180 1.1 mrg * @code{IAND}: IAND, Bitwise logical and
181 1.1 mrg * @code{IANY}: IANY, Bitwise OR of array elements
182 1.1 mrg * @code{IARGC}: IARGC, Get the number of command line arguments
183 1.1 mrg * @code{IBCLR}: IBCLR, Clear bit
184 1.1 mrg * @code{IBITS}: IBITS, Bit extraction
185 1.1 mrg * @code{IBSET}: IBSET, Set bit
186 1.1 mrg * @code{ICHAR}: ICHAR, Character-to-integer conversion function
187 1.1 mrg * @code{IDATE}: IDATE, Current local time (day/month/year)
188 1.1 mrg * @code{IEOR}: IEOR, Bitwise logical exclusive or
189 1.1 mrg * @code{IERRNO}: IERRNO, Function to get the last system error number
190 1.1 mrg * @code{IMAGE_INDEX}: IMAGE_INDEX, Cosubscript to image index conversion
191 1.1 mrg * @code{INDEX}: INDEX intrinsic, Position of a substring within a string
192 1.1 mrg * @code{INT}: INT, Convert to integer type
193 1.1 mrg * @code{INT2}: INT2, Convert to 16-bit integer type
194 1.1 mrg * @code{INT8}: INT8, Convert to 64-bit integer type
195 1.1 mrg * @code{IOR}: IOR, Bitwise logical or
196 1.1 mrg * @code{IPARITY}: IPARITY, Bitwise XOR of array elements
197 1.1 mrg * @code{IRAND}: IRAND, Integer pseudo-random number
198 1.1 mrg * @code{IS_CONTIGUOUS}: IS_CONTIGUOUS, Test whether an array is contiguous
199 1.1 mrg * @code{IS_IOSTAT_END}: IS_IOSTAT_END, Test for end-of-file value
200 1.1 mrg * @code{IS_IOSTAT_EOR}: IS_IOSTAT_EOR, Test for end-of-record value
201 1.1 mrg * @code{ISATTY}: ISATTY, Whether a unit is a terminal device
202 1.1 mrg * @code{ISHFT}: ISHFT, Shift bits
203 1.1 mrg * @code{ISHFTC}: ISHFTC, Shift bits circularly
204 1.1 mrg * @code{ISNAN}: ISNAN, Tests for a NaN
205 1.1 mrg * @code{ITIME}: ITIME, Current local time (hour/minutes/seconds)
206 1.1 mrg * @code{KILL}: KILL, Send a signal to a process
207 1.1 mrg * @code{KIND}: KIND, Kind of an entity
208 1.1 mrg * @code{LBOUND}: LBOUND, Lower dimension bounds of an array
209 1.1 mrg * @code{LCOBOUND}: LCOBOUND, Lower codimension bounds of an array
210 1.1 mrg * @code{LEADZ}: LEADZ, Number of leading zero bits of an integer
211 1.1 mrg * @code{LEN}: LEN, Length of a character entity
212 1.1 mrg * @code{LEN_TRIM}: LEN_TRIM, Length of a character entity without trailing blank characters
213 1.1 mrg * @code{LGE}: LGE, Lexical greater than or equal
214 1.1 mrg * @code{LGT}: LGT, Lexical greater than
215 1.1 mrg * @code{LINK}: LINK, Create a hard link
216 1.1 mrg * @code{LLE}: LLE, Lexical less than or equal
217 1.1 mrg * @code{LLT}: LLT, Lexical less than
218 1.1 mrg * @code{LNBLNK}: LNBLNK, Index of the last non-blank character in a string
219 1.1 mrg * @code{LOC}: LOC, Returns the address of a variable
220 1.1 mrg * @code{LOG}: LOG, Logarithm function
221 1.1 mrg * @code{LOG10}: LOG10, Base 10 logarithm function
222 1.1 mrg * @code{LOG_GAMMA}: LOG_GAMMA, Logarithm of the Gamma function
223 1.1 mrg * @code{LOGICAL}: LOGICAL, Convert to logical type
224 1.1 mrg * @code{LONG}: LONG, Convert to integer type
225 1.1 mrg * @code{LSHIFT}: LSHIFT, Left shift bits
226 1.1 mrg * @code{LSTAT}: LSTAT, Get file status
227 1.1 mrg * @code{LTIME}: LTIME, Convert time to local time info
228 1.1 mrg * @code{MALLOC}: MALLOC, Dynamic memory allocation function
229 1.1 mrg * @code{MASKL}: MASKL, Left justified mask
230 1.1 mrg * @code{MASKR}: MASKR, Right justified mask
231 1.1 mrg * @code{MATMUL}: MATMUL, matrix multiplication
232 1.1 mrg * @code{MAX}: MAX, Maximum value of an argument list
233 1.1 mrg * @code{MAXEXPONENT}: MAXEXPONENT, Maximum exponent of a real kind
234 1.1 mrg * @code{MAXLOC}: MAXLOC, Location of the maximum value within an array
235 1.1 mrg * @code{MAXVAL}: MAXVAL, Maximum value of an array
236 1.1 mrg * @code{MCLOCK}: MCLOCK, Time function
237 1.1 mrg * @code{MCLOCK8}: MCLOCK8, Time function (64-bit)
238 1.1 mrg * @code{MERGE}: MERGE, Merge arrays
239 1.1 mrg * @code{MERGE_BITS}: MERGE_BITS, Merge of bits under mask
240 1.1 mrg * @code{MIN}: MIN, Minimum value of an argument list
241 1.1 mrg * @code{MINEXPONENT}: MINEXPONENT, Minimum exponent of a real kind
242 1.1 mrg * @code{MINLOC}: MINLOC, Location of the minimum value within an array
243 1.1 mrg * @code{MINVAL}: MINVAL, Minimum value of an array
244 1.1 mrg * @code{MOD}: MOD, Remainder function
245 1.1 mrg * @code{MODULO}: MODULO, Modulo function
246 1.1 mrg * @code{MOVE_ALLOC}: MOVE_ALLOC, Move allocation from one object to another
247 1.1 mrg * @code{MVBITS}: MVBITS, Move bits from one integer to another
248 1.1 mrg * @code{NEAREST}: NEAREST, Nearest representable number
249 1.1 mrg * @code{NEW_LINE}: NEW_LINE, New line character
250 1.1 mrg * @code{NINT}: NINT, Nearest whole number
251 1.1 mrg * @code{NORM2}: NORM2, Euclidean vector norm
252 1.1 mrg * @code{NOT}: NOT, Logical negation
253 1.1 mrg * @code{NULL}: NULL, Function that returns an disassociated pointer
254 1.1 mrg * @code{NUM_IMAGES}: NUM_IMAGES, Number of images
255 1.1 mrg * @code{OR}: OR, Bitwise logical OR
256 1.1 mrg * @code{PACK}: PACK, Pack an array into an array of rank one
257 1.1 mrg * @code{PARITY}: PARITY, Reduction with exclusive OR
258 1.1 mrg * @code{PERROR}: PERROR, Print system error message
259 1.1 mrg * @code{POPCNT}: POPCNT, Number of bits set
260 1.1 mrg * @code{POPPAR}: POPPAR, Parity of the number of bits set
261 1.1 mrg * @code{PRECISION}: PRECISION, Decimal precision of a real kind
262 1.1 mrg * @code{PRESENT}: PRESENT, Determine whether an optional dummy argument is specified
263 1.1 mrg * @code{PRODUCT}: PRODUCT, Product of array elements
264 1.1 mrg * @code{RADIX}: RADIX, Base of a data model
265 1.1 mrg * @code{RAN}: RAN, Real pseudo-random number
266 1.1 mrg * @code{RAND}: RAND, Real pseudo-random number
267 1.1 mrg * @code{RANDOM_INIT}: RANDOM_INIT, Initialize pseudo-random number generator
268 1.1 mrg * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
269 1.1 mrg * @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence
270 1.1 mrg * @code{RANGE}: RANGE, Decimal exponent range
271 1.1 mrg * @code{RANK} : RANK, Rank of a data object
272 1.1 mrg * @code{REAL}: REAL, Convert to real type
273 1.1 mrg * @code{RENAME}: RENAME, Rename a file
274 1.1 mrg * @code{REPEAT}: REPEAT, Repeated string concatenation
275 1.1 mrg * @code{RESHAPE}: RESHAPE, Function to reshape an array
276 1.1 mrg * @code{RRSPACING}: RRSPACING, Reciprocal of the relative spacing
277 1.1 mrg * @code{RSHIFT}: RSHIFT, Right shift bits
278 1.1 mrg * @code{SAME_TYPE_AS}: SAME_TYPE_AS, Query dynamic types for equality
279 1.1 mrg * @code{SCALE}: SCALE, Scale a real value
280 1.1 mrg * @code{SCAN}: SCAN, Scan a string for the presence of a set of characters
281 1.1 mrg * @code{SECNDS}: SECNDS, Time function
282 1.1 mrg * @code{SECOND}: SECOND, CPU time function
283 1.1 mrg * @code{SELECTED_CHAR_KIND}: SELECTED_CHAR_KIND, Choose character kind
284 1.1 mrg * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND, Choose integer kind
285 1.1 mrg * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND, Choose real kind
286 1.1 mrg * @code{SET_EXPONENT}: SET_EXPONENT, Set the exponent of the model
287 1.1 mrg * @code{SHAPE}: SHAPE, Determine the shape of an array
288 1.1 mrg * @code{SHIFTA}: SHIFTA, Right shift with fill
289 1.1 mrg * @code{SHIFTL}: SHIFTL, Left shift
290 1.1 mrg * @code{SHIFTR}: SHIFTR, Right shift
291 1.1 mrg * @code{SIGN}: SIGN, Sign copying function
292 1.1 mrg * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
293 1.1 mrg * @code{SIN}: SIN, Sine function
294 1.1 mrg * @code{SIND}: SIND, Sine function, degrees
295 1.1 mrg * @code{SINH}: SINH, Hyperbolic sine function
296 1.1 mrg * @code{SIZE}: SIZE, Function to determine the size of an array
297 1.1 mrg * @code{SIZEOF}: SIZEOF, Determine the size in bytes of an expression
298 1.1 mrg * @code{SLEEP}: SLEEP, Sleep for the specified number of seconds
299 1.1 mrg * @code{SPACING}: SPACING, Smallest distance between two numbers of a given type
300 1.1 mrg * @code{SPREAD}: SPREAD, Add a dimension to an array
301 1.1 mrg * @code{SQRT}: SQRT, Square-root function
302 1.1 mrg * @code{SRAND}: SRAND, Reinitialize the random number generator
303 1.1 mrg * @code{STAT}: STAT, Get file status
304 1.1 mrg * @code{STORAGE_SIZE}: STORAGE_SIZE, Storage size in bits
305 1.1 mrg * @code{SUM}: SUM, Sum of array elements
306 1.1 mrg * @code{SYMLNK}: SYMLNK, Create a symbolic link
307 1.1 mrg * @code{SYSTEM}: SYSTEM, Execute a shell command
308 1.1 mrg * @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function
309 1.1 mrg * @code{TAN}: TAN, Tangent function
310 1.1 mrg * @code{TAND}: TAND, Tangent function, degrees
311 1.1 mrg * @code{TANH}: TANH, Hyperbolic tangent function
312 1.1 mrg * @code{THIS_IMAGE}: THIS_IMAGE, Cosubscript index of this image
313 1.1 mrg * @code{TIME}: TIME, Time function
314 1.1 mrg * @code{TIME8}: TIME8, Time function (64-bit)
315 1.1 mrg * @code{TINY}: TINY, Smallest positive number of a real kind
316 1.1 mrg * @code{TRAILZ}: TRAILZ, Number of trailing zero bits of an integer
317 1.1 mrg * @code{TRANSFER}: TRANSFER, Transfer bit patterns
318 1.1 mrg * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two
319 1.1 mrg * @code{TRIM}: TRIM, Remove trailing blank characters of a string
320 1.1 mrg * @code{TTYNAM}: TTYNAM, Get the name of a terminal device.
321 1.1 mrg * @code{UBOUND}: UBOUND, Upper dimension bounds of an array
322 1.1 mrg * @code{UCOBOUND}: UCOBOUND, Upper codimension bounds of an array
323 1.1 mrg * @code{UMASK}: UMASK, Set the file creation mask
324 1.1 mrg * @code{UNLINK}: UNLINK, Remove a file from the file system
325 1.1 mrg * @code{UNPACK}: UNPACK, Unpack an array of rank one into an array
326 1.1 mrg * @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters
327 1.1 mrg * @code{XOR}: XOR, Bitwise logical exclusive or
328 1.1 mrg @end menu
329 1.1 mrg
330 1.1 mrg @node Introduction to Intrinsics
331 1.1 mrg @section Introduction to intrinsic procedures
332 1.1 mrg
333 1.1 mrg The intrinsic procedures provided by GNU Fortran include all of the
334 1.1 mrg intrinsic procedures required by the Fortran 95 standard, a set of
335 1.1 mrg intrinsic procedures for backwards compatibility with G77, and a
336 1.1 mrg selection of intrinsic procedures from the Fortran 2003 and Fortran 2008
337 1.1 mrg standards. Any conflict between a description here and a description in
338 1.1 mrg either the Fortran 95 standard, the Fortran 2003 standard or the Fortran
339 1.1 mrg 2008 standard is unintentional, and the standard(s) should be considered
340 1.1 mrg authoritative.
341 1.1 mrg
342 1.1 mrg The enumeration of the @code{KIND} type parameter is processor defined in
343 1.1 mrg the Fortran 95 standard. GNU Fortran defines the default integer type and
344 1.1 mrg default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
345 1.1 mrg respectively. The standard mandates that both data types shall have
346 1.1 mrg another kind, which have more precision. On typical target architectures
347 1.1 mrg supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
348 1.1 mrg Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
349 1.1 mrg In the description of generic intrinsic procedures, the kind type parameter
350 1.1 mrg will be specified by @code{KIND=*}, and in the description of specific
351 1.1 mrg names for an intrinsic procedure the kind type parameter will be explicitly
352 1.1 mrg given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
353 1.1 mrg brevity the optional @code{KIND=} syntax will be omitted.
354 1.1 mrg
355 1.1 mrg Many of the intrinsic procedures take one or more optional arguments.
356 1.1 mrg This document follows the convention used in the Fortran 95 standard,
357 1.1 mrg and denotes such arguments by square brackets.
358 1.1 mrg
359 1.1 mrg GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
360 1.1 mrg which can be used to restrict the set of intrinsic procedures to a
361 1.1 mrg given standard. By default, @command{gfortran} sets the @option{-std=gnu}
362 1.1 mrg option, and so all intrinsic procedures described here are accepted. There
363 1.1 mrg is one caveat. For a select group of intrinsic procedures, @command{g77}
364 1.1 mrg implemented both a function and a subroutine. Both classes
365 1.1 mrg have been implemented in @command{gfortran} for backwards compatibility
366 1.1 mrg with @command{g77}. It is noted here that these functions and subroutines
367 1.1 mrg cannot be intermixed in a given subprogram. In the descriptions that follow,
368 1.1 mrg the applicable standard for each intrinsic procedure is noted.
369 1.1 mrg
370 1.1 mrg
371 1.1 mrg
372 1.1 mrg @node ABORT
373 1.1 mrg @section @code{ABORT} --- Abort the program
374 1.1 mrg @fnindex ABORT
375 1.1 mrg @cindex program termination, with core dump
376 1.1 mrg @cindex terminate program, with core dump
377 1.1 mrg @cindex core, dump
378 1.1 mrg
379 1.1 mrg @table @asis
380 1.1 mrg @item @emph{Description}:
381 1.1 mrg @code{ABORT} causes immediate termination of the program. On operating
382 1.1 mrg systems that support a core dump, @code{ABORT} will produce a core dump.
383 1.1 mrg It will also print a backtrace, unless @code{-fno-backtrace} is given.
384 1.1 mrg
385 1.1 mrg @item @emph{Standard}:
386 1.1 mrg GNU extension
387 1.1 mrg
388 1.1 mrg @item @emph{Class}:
389 1.1 mrg Subroutine
390 1.1 mrg
391 1.1 mrg @item @emph{Syntax}:
392 1.1 mrg @code{CALL ABORT}
393 1.1 mrg
394 1.1 mrg @item @emph{Return value}:
395 1.1 mrg Does not return.
396 1.1 mrg
397 1.1 mrg @item @emph{Example}:
398 1.1 mrg @smallexample
399 1.1 mrg program test_abort
400 1.1 mrg integer :: i = 1, j = 2
401 1.1 mrg if (i /= j) call abort
402 1.1 mrg end program test_abort
403 1.1 mrg @end smallexample
404 1.1 mrg
405 1.1 mrg @item @emph{See also}:
406 1.1.1.2 mrg @ref{EXIT}, @gol
407 1.1.1.2 mrg @ref{KILL}, @gol
408 1.1.1.2 mrg @ref{BACKTRACE}
409 1.1 mrg @end table
410 1.1 mrg
411 1.1 mrg
412 1.1 mrg
413 1.1 mrg @node ABS
414 1.1 mrg @section @code{ABS} --- Absolute value
415 1.1 mrg @fnindex ABS
416 1.1 mrg @fnindex CABS
417 1.1 mrg @fnindex DABS
418 1.1 mrg @fnindex IABS
419 1.1 mrg @fnindex ZABS
420 1.1 mrg @fnindex CDABS
421 1.1 mrg @fnindex BABS
422 1.1 mrg @fnindex IIABS
423 1.1 mrg @fnindex JIABS
424 1.1 mrg @fnindex KIABS
425 1.1 mrg @cindex absolute value
426 1.1 mrg
427 1.1 mrg @table @asis
428 1.1 mrg @item @emph{Description}:
429 1.1 mrg @code{ABS(A)} computes the absolute value of @code{A}.
430 1.1 mrg
431 1.1 mrg @item @emph{Standard}:
432 1.1 mrg Fortran 77 and later, has overloads that are GNU extensions
433 1.1 mrg
434 1.1 mrg @item @emph{Class}:
435 1.1 mrg Elemental function
436 1.1 mrg
437 1.1 mrg @item @emph{Syntax}:
438 1.1 mrg @code{RESULT = ABS(A)}
439 1.1 mrg
440 1.1 mrg @item @emph{Arguments}:
441 1.1 mrg @multitable @columnfractions .15 .70
442 1.1 mrg @item @var{A} @tab The type of the argument shall be an @code{INTEGER},
443 1.1 mrg @code{REAL}, or @code{COMPLEX}.
444 1.1 mrg @end multitable
445 1.1 mrg
446 1.1 mrg @item @emph{Return value}:
447 1.1 mrg The return value is of the same type and
448 1.1 mrg kind as the argument except the return value is @code{REAL} for a
449 1.1 mrg @code{COMPLEX} argument.
450 1.1 mrg
451 1.1 mrg @item @emph{Example}:
452 1.1 mrg @smallexample
453 1.1 mrg program test_abs
454 1.1 mrg integer :: i = -1
455 1.1 mrg real :: x = -1.e0
456 1.1 mrg complex :: z = (-1.e0,0.e0)
457 1.1 mrg i = abs(i)
458 1.1 mrg x = abs(x)
459 1.1 mrg x = abs(z)
460 1.1 mrg end program test_abs
461 1.1 mrg @end smallexample
462 1.1 mrg
463 1.1 mrg @item @emph{Specific names}:
464 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
465 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
466 1.1 mrg @item @code{ABS(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
467 1.1 mrg @item @code{CABS(A)} @tab @code{COMPLEX(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
468 1.1 mrg @item @code{DABS(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later
469 1.1 mrg @item @code{IABS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab Fortran 77 and later
470 1.1 mrg @item @code{BABS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
471 1.1 mrg @item @code{IIABS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
472 1.1 mrg @item @code{JIABS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
473 1.1 mrg @item @code{KIABS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
474 1.1.1.2 mrg @item @code{ZABS(A)} @tab @code{COMPLEX(8) A} @tab @code{REAL(8)} @tab GNU extension
475 1.1.1.2 mrg @item @code{CDABS(A)} @tab @code{COMPLEX(8) A} @tab @code{REAL(8)} @tab GNU extension
476 1.1 mrg @end multitable
477 1.1 mrg @end table
478 1.1 mrg
479 1.1 mrg
480 1.1 mrg
481 1.1 mrg @node ACCESS
482 1.1 mrg @section @code{ACCESS} --- Checks file access modes
483 1.1 mrg @fnindex ACCESS
484 1.1 mrg @cindex file system, access mode
485 1.1 mrg
486 1.1 mrg @table @asis
487 1.1 mrg @item @emph{Description}:
488 1.1 mrg @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
489 1.1 mrg exists, is readable, writable or executable. Except for the
490 1.1 mrg executable check, @code{ACCESS} can be replaced by
491 1.1 mrg Fortran 95's @code{INQUIRE}.
492 1.1 mrg
493 1.1 mrg @item @emph{Standard}:
494 1.1 mrg GNU extension
495 1.1 mrg
496 1.1 mrg @item @emph{Class}:
497 1.1 mrg Inquiry function
498 1.1 mrg
499 1.1 mrg @item @emph{Syntax}:
500 1.1 mrg @code{RESULT = ACCESS(NAME, MODE)}
501 1.1 mrg
502 1.1 mrg @item @emph{Arguments}:
503 1.1 mrg @multitable @columnfractions .15 .70
504 1.1 mrg @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
505 1.1 mrg file name. Tailing blank are ignored unless the character @code{achar(0)}
506 1.1 mrg is present, then all characters up to and excluding @code{achar(0)} are
507 1.1 mrg used as file name.
508 1.1 mrg @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind with the
509 1.1 mrg file access mode, may be any concatenation of @code{"r"} (readable),
510 1.1 mrg @code{"w"} (writable) and @code{"x"} (executable), or @code{" "} to check
511 1.1 mrg for existence.
512 1.1 mrg @end multitable
513 1.1 mrg
514 1.1 mrg @item @emph{Return value}:
515 1.1 mrg Returns a scalar @code{INTEGER}, which is @code{0} if the file is
516 1.1 mrg accessible in the given mode; otherwise or if an invalid argument
517 1.1 mrg has been given for @code{MODE} the value @code{1} is returned.
518 1.1 mrg
519 1.1 mrg @item @emph{Example}:
520 1.1 mrg @smallexample
521 1.1 mrg program access_test
522 1.1 mrg implicit none
523 1.1 mrg character(len=*), parameter :: file = 'test.dat'
524 1.1 mrg character(len=*), parameter :: file2 = 'test.dat '//achar(0)
525 1.1 mrg if(access(file,' ') == 0) print *, trim(file),' is exists'
526 1.1 mrg if(access(file,'r') == 0) print *, trim(file),' is readable'
527 1.1 mrg if(access(file,'w') == 0) print *, trim(file),' is writable'
528 1.1 mrg if(access(file,'x') == 0) print *, trim(file),' is executable'
529 1.1 mrg if(access(file2,'rwx') == 0) &
530 1.1 mrg print *, trim(file2),' is readable, writable and executable'
531 1.1 mrg end program access_test
532 1.1 mrg @end smallexample
533 1.1 mrg @end table
534 1.1 mrg
535 1.1 mrg
536 1.1 mrg
537 1.1 mrg @node ACHAR
538 1.1 mrg @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
539 1.1 mrg @fnindex ACHAR
540 1.1 mrg @cindex @acronym{ASCII} collating sequence
541 1.1 mrg @cindex collating sequence, @acronym{ASCII}
542 1.1 mrg
543 1.1 mrg @table @asis
544 1.1 mrg @item @emph{Description}:
545 1.1 mrg @code{ACHAR(I)} returns the character located at position @code{I}
546 1.1 mrg in the @acronym{ASCII} collating sequence.
547 1.1 mrg
548 1.1 mrg @item @emph{Standard}:
549 1.1 mrg Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
550 1.1 mrg
551 1.1 mrg @item @emph{Class}:
552 1.1 mrg Elemental function
553 1.1 mrg
554 1.1 mrg @item @emph{Syntax}:
555 1.1 mrg @code{RESULT = ACHAR(I [, KIND])}
556 1.1 mrg
557 1.1 mrg @item @emph{Arguments}:
558 1.1 mrg @multitable @columnfractions .15 .70
559 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
560 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
561 1.1 mrg expression indicating the kind parameter of the result.
562 1.1 mrg @end multitable
563 1.1 mrg
564 1.1 mrg @item @emph{Return value}:
565 1.1 mrg The return value is of type @code{CHARACTER} with a length of one.
566 1.1 mrg If the @var{KIND} argument is present, the return value is of the
567 1.1 mrg specified kind and of the default kind otherwise.
568 1.1 mrg
569 1.1 mrg @item @emph{Example}:
570 1.1 mrg @smallexample
571 1.1 mrg program test_achar
572 1.1 mrg character c
573 1.1 mrg c = achar(32)
574 1.1 mrg end program test_achar
575 1.1 mrg @end smallexample
576 1.1 mrg
577 1.1 mrg @item @emph{Note}:
578 1.1 mrg See @ref{ICHAR} for a discussion of converting between numerical values
579 1.1 mrg and formatted string representations.
580 1.1 mrg
581 1.1 mrg @item @emph{See also}:
582 1.1.1.2 mrg @ref{CHAR}, @gol
583 1.1.1.2 mrg @ref{IACHAR}, @gol
584 1.1.1.2 mrg @ref{ICHAR}
585 1.1 mrg @end table
586 1.1 mrg
587 1.1 mrg
588 1.1 mrg
589 1.1 mrg @node ACOS
590 1.1 mrg @section @code{ACOS} --- Arccosine function
591 1.1 mrg @fnindex ACOS
592 1.1 mrg @fnindex DACOS
593 1.1 mrg @cindex trigonometric function, cosine, inverse
594 1.1 mrg @cindex cosine, inverse
595 1.1 mrg
596 1.1 mrg @table @asis
597 1.1 mrg @item @emph{Description}:
598 1.1 mrg @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
599 1.1 mrg
600 1.1 mrg @item @emph{Standard}:
601 1.1 mrg Fortran 77 and later, for a complex argument Fortran 2008 or later
602 1.1 mrg
603 1.1 mrg @item @emph{Class}:
604 1.1 mrg Elemental function
605 1.1 mrg
606 1.1 mrg @item @emph{Syntax}:
607 1.1 mrg @code{RESULT = ACOS(X)}
608 1.1 mrg
609 1.1 mrg @item @emph{Arguments}:
610 1.1 mrg @multitable @columnfractions .15 .70
611 1.1 mrg @item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is
612 1.1 mrg less than or equal to one - or the type shall be @code{COMPLEX}.
613 1.1 mrg @end multitable
614 1.1 mrg
615 1.1 mrg @item @emph{Return value}:
616 1.1 mrg The return value is of the same type and kind as @var{X}.
617 1.1 mrg The real part of the result is in radians and lies in the range
618 1.1 mrg @math{0 \leq \Re \acos(x) \leq \pi}.
619 1.1 mrg
620 1.1 mrg @item @emph{Example}:
621 1.1 mrg @smallexample
622 1.1 mrg program test_acos
623 1.1 mrg real(8) :: x = 0.866_8
624 1.1 mrg x = acos(x)
625 1.1 mrg end program test_acos
626 1.1 mrg @end smallexample
627 1.1 mrg
628 1.1 mrg @item @emph{Specific names}:
629 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
630 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
631 1.1 mrg @item @code{ACOS(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
632 1.1 mrg @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
633 1.1 mrg @end multitable
634 1.1 mrg
635 1.1 mrg @item @emph{See also}:
636 1.1.1.2 mrg Inverse function: @gol
637 1.1.1.2 mrg @ref{COS} @gol
638 1.1.1.2 mrg Degrees function: @gol
639 1.1.1.2 mrg @ref{ACOSD}
640 1.1 mrg @end table
641 1.1 mrg
642 1.1 mrg
643 1.1 mrg
644 1.1 mrg @node ACOSD
645 1.1 mrg @section @code{ACOSD} --- Arccosine function, degrees
646 1.1 mrg @fnindex ACOSD
647 1.1 mrg @fnindex DACOSD
648 1.1 mrg @cindex trigonometric function, cosine, inverse, degrees
649 1.1 mrg @cindex cosine, inverse, degrees
650 1.1 mrg
651 1.1 mrg @table @asis
652 1.1 mrg @item @emph{Description}:
653 1.1 mrg @code{ACOSD(X)} computes the arccosine of @var{X} in degrees (inverse of
654 1.1 mrg @code{COSD(X)}).
655 1.1 mrg
656 1.1 mrg This function is for compatibility only and should be avoided in favor of
657 1.1 mrg standard constructs wherever possible.
658 1.1 mrg
659 1.1 mrg @item @emph{Standard}:
660 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math}
661 1.1 mrg
662 1.1 mrg @item @emph{Class}:
663 1.1 mrg Elemental function
664 1.1 mrg
665 1.1 mrg @item @emph{Syntax}:
666 1.1 mrg @code{RESULT = ACOSD(X)}
667 1.1 mrg
668 1.1 mrg @item @emph{Arguments}:
669 1.1 mrg @multitable @columnfractions .15 .70
670 1.1 mrg @item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is
671 1.1 mrg less than or equal to one - or the type shall be @code{COMPLEX}.
672 1.1 mrg @end multitable
673 1.1 mrg
674 1.1 mrg @item @emph{Return value}:
675 1.1 mrg The return value is of the same type and kind as @var{X}.
676 1.1 mrg The real part of the result is in degrees and lies in the range
677 1.1 mrg @math{0 \leq \Re \acos(x) \leq 180}.
678 1.1 mrg
679 1.1 mrg @item @emph{Example}:
680 1.1 mrg @smallexample
681 1.1 mrg program test_acosd
682 1.1 mrg real(8) :: x = 0.866_8
683 1.1 mrg x = acosd(x)
684 1.1 mrg end program test_acosd
685 1.1 mrg @end smallexample
686 1.1 mrg
687 1.1 mrg @item @emph{Specific names}:
688 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
689 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
690 1.1.1.2 mrg @item @code{ACOSD(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
691 1.1.1.2 mrg @item @code{DACOSD(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
692 1.1 mrg @end multitable
693 1.1 mrg
694 1.1 mrg @item @emph{See also}:
695 1.1.1.2 mrg Inverse function: @gol
696 1.1.1.2 mrg @ref{COSD} @gol
697 1.1.1.2 mrg Radians function: @gol
698 1.1.1.2 mrg @ref{ACOS} @gol
699 1.1 mrg @end table
700 1.1 mrg
701 1.1 mrg
702 1.1 mrg
703 1.1 mrg @node ACOSH
704 1.1 mrg @section @code{ACOSH} --- Inverse hyperbolic cosine function
705 1.1 mrg @fnindex ACOSH
706 1.1 mrg @fnindex DACOSH
707 1.1 mrg @cindex area hyperbolic cosine
708 1.1 mrg @cindex inverse hyperbolic cosine
709 1.1 mrg @cindex hyperbolic function, cosine, inverse
710 1.1 mrg @cindex cosine, hyperbolic, inverse
711 1.1 mrg
712 1.1 mrg @table @asis
713 1.1 mrg @item @emph{Description}:
714 1.1 mrg @code{ACOSH(X)} computes the inverse hyperbolic cosine of @var{X}.
715 1.1 mrg
716 1.1 mrg @item @emph{Standard}:
717 1.1 mrg Fortran 2008 and later
718 1.1 mrg
719 1.1 mrg @item @emph{Class}:
720 1.1 mrg Elemental function
721 1.1 mrg
722 1.1 mrg @item @emph{Syntax}:
723 1.1 mrg @code{RESULT = ACOSH(X)}
724 1.1 mrg
725 1.1 mrg @item @emph{Arguments}:
726 1.1 mrg @multitable @columnfractions .15 .70
727 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
728 1.1 mrg @end multitable
729 1.1 mrg
730 1.1 mrg @item @emph{Return value}:
731 1.1 mrg The return value has the same type and kind as @var{X}. If @var{X} is
732 1.1 mrg complex, the imaginary part of the result is in radians and lies between
733 1.1 mrg @math{ 0 \leq \Im \acosh(x) \leq \pi}.
734 1.1 mrg
735 1.1 mrg @item @emph{Example}:
736 1.1 mrg @smallexample
737 1.1 mrg PROGRAM test_acosh
738 1.1 mrg REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
739 1.1 mrg WRITE (*,*) ACOSH(x)
740 1.1 mrg END PROGRAM
741 1.1 mrg @end smallexample
742 1.1 mrg
743 1.1 mrg @item @emph{Specific names}:
744 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
745 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
746 1.1 mrg @item @code{DACOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
747 1.1 mrg @end multitable
748 1.1 mrg
749 1.1 mrg @item @emph{See also}:
750 1.1.1.2 mrg Inverse function: @gol
751 1.1.1.2 mrg @ref{COSH}
752 1.1 mrg @end table
753 1.1 mrg
754 1.1 mrg
755 1.1 mrg
756 1.1 mrg @node ADJUSTL
757 1.1 mrg @section @code{ADJUSTL} --- Left adjust a string
758 1.1 mrg @fnindex ADJUSTL
759 1.1 mrg @cindex string, adjust left
760 1.1 mrg @cindex adjust string
761 1.1 mrg
762 1.1 mrg @table @asis
763 1.1 mrg @item @emph{Description}:
764 1.1 mrg @code{ADJUSTL(STRING)} will left adjust a string by removing leading spaces.
765 1.1 mrg Spaces are inserted at the end of the string as needed.
766 1.1 mrg
767 1.1 mrg @item @emph{Standard}:
768 1.1 mrg Fortran 90 and later
769 1.1 mrg
770 1.1 mrg @item @emph{Class}:
771 1.1 mrg Elemental function
772 1.1 mrg
773 1.1 mrg @item @emph{Syntax}:
774 1.1 mrg @code{RESULT = ADJUSTL(STRING)}
775 1.1 mrg
776 1.1 mrg @item @emph{Arguments}:
777 1.1 mrg @multitable @columnfractions .15 .70
778 1.1 mrg @item @var{STRING} @tab The type shall be @code{CHARACTER}.
779 1.1 mrg @end multitable
780 1.1 mrg
781 1.1 mrg @item @emph{Return value}:
782 1.1 mrg The return value is of type @code{CHARACTER} and of the same kind as
783 1.1 mrg @var{STRING} where leading spaces are removed and the same number of
784 1.1 mrg spaces are inserted on the end of @var{STRING}.
785 1.1 mrg
786 1.1 mrg @item @emph{Example}:
787 1.1 mrg @smallexample
788 1.1 mrg program test_adjustl
789 1.1 mrg character(len=20) :: str = ' gfortran'
790 1.1 mrg str = adjustl(str)
791 1.1 mrg print *, str
792 1.1 mrg end program test_adjustl
793 1.1 mrg @end smallexample
794 1.1 mrg
795 1.1 mrg @item @emph{See also}:
796 1.1.1.2 mrg @ref{ADJUSTR}, @gol
797 1.1.1.2 mrg @ref{TRIM}
798 1.1 mrg @end table
799 1.1 mrg
800 1.1 mrg
801 1.1 mrg
802 1.1 mrg @node ADJUSTR
803 1.1 mrg @section @code{ADJUSTR} --- Right adjust a string
804 1.1 mrg @fnindex ADJUSTR
805 1.1 mrg @cindex string, adjust right
806 1.1 mrg @cindex adjust string
807 1.1 mrg
808 1.1 mrg @table @asis
809 1.1 mrg @item @emph{Description}:
810 1.1 mrg @code{ADJUSTR(STRING)} will right adjust a string by removing trailing spaces.
811 1.1 mrg Spaces are inserted at the start of the string as needed.
812 1.1 mrg
813 1.1 mrg @item @emph{Standard}:
814 1.1.1.2 mrg Fortran 90 and later
815 1.1 mrg
816 1.1 mrg @item @emph{Class}:
817 1.1 mrg Elemental function
818 1.1 mrg
819 1.1 mrg @item @emph{Syntax}:
820 1.1 mrg @code{RESULT = ADJUSTR(STRING)}
821 1.1 mrg
822 1.1 mrg @item @emph{Arguments}:
823 1.1 mrg @multitable @columnfractions .15 .70
824 1.1 mrg @item @var{STR} @tab The type shall be @code{CHARACTER}.
825 1.1 mrg @end multitable
826 1.1 mrg
827 1.1 mrg @item @emph{Return value}:
828 1.1 mrg The return value is of type @code{CHARACTER} and of the same kind as
829 1.1 mrg @var{STRING} where trailing spaces are removed and the same number of
830 1.1 mrg spaces are inserted at the start of @var{STRING}.
831 1.1 mrg
832 1.1 mrg @item @emph{Example}:
833 1.1 mrg @smallexample
834 1.1 mrg program test_adjustr
835 1.1 mrg character(len=20) :: str = 'gfortran'
836 1.1 mrg str = adjustr(str)
837 1.1 mrg print *, str
838 1.1 mrg end program test_adjustr
839 1.1 mrg @end smallexample
840 1.1 mrg
841 1.1 mrg @item @emph{See also}:
842 1.1.1.2 mrg @ref{ADJUSTL}, @gol
843 1.1.1.2 mrg @ref{TRIM}
844 1.1 mrg @end table
845 1.1 mrg
846 1.1 mrg
847 1.1 mrg
848 1.1 mrg @node AIMAG
849 1.1 mrg @section @code{AIMAG} --- Imaginary part of complex number
850 1.1 mrg @fnindex AIMAG
851 1.1 mrg @fnindex DIMAG
852 1.1 mrg @fnindex IMAG
853 1.1 mrg @fnindex IMAGPART
854 1.1 mrg @cindex complex numbers, imaginary part
855 1.1 mrg
856 1.1 mrg @table @asis
857 1.1 mrg @item @emph{Description}:
858 1.1 mrg @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
859 1.1 mrg The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
860 1.1 mrg for compatibility with @command{g77}, and their use in new code is
861 1.1 mrg strongly discouraged.
862 1.1 mrg
863 1.1 mrg @item @emph{Standard}:
864 1.1 mrg Fortran 77 and later, has overloads that are GNU extensions
865 1.1 mrg
866 1.1 mrg @item @emph{Class}:
867 1.1 mrg Elemental function
868 1.1 mrg
869 1.1 mrg @item @emph{Syntax}:
870 1.1 mrg @code{RESULT = AIMAG(Z)}
871 1.1 mrg
872 1.1 mrg @item @emph{Arguments}:
873 1.1 mrg @multitable @columnfractions .15 .70
874 1.1 mrg @item @var{Z} @tab The type of the argument shall be @code{COMPLEX}.
875 1.1 mrg @end multitable
876 1.1 mrg
877 1.1 mrg @item @emph{Return value}:
878 1.1 mrg The return value is of type @code{REAL} with the
879 1.1 mrg kind type parameter of the argument.
880 1.1 mrg
881 1.1 mrg @item @emph{Example}:
882 1.1 mrg @smallexample
883 1.1 mrg program test_aimag
884 1.1 mrg complex(4) z4
885 1.1 mrg complex(8) z8
886 1.1 mrg z4 = cmplx(1.e0_4, 0.e0_4)
887 1.1 mrg z8 = cmplx(0.e0_8, 1.e0_8)
888 1.1 mrg print *, aimag(z4), dimag(z8)
889 1.1 mrg end program test_aimag
890 1.1 mrg @end smallexample
891 1.1 mrg
892 1.1 mrg @item @emph{Specific names}:
893 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
894 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
895 1.1.1.2 mrg @item @code{AIMAG(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab Fortran 77 and later
896 1.1 mrg @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
897 1.1 mrg @item @code{IMAG(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
898 1.1 mrg @item @code{IMAGPART(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
899 1.1 mrg @end multitable
900 1.1 mrg @end table
901 1.1 mrg
902 1.1 mrg
903 1.1 mrg
904 1.1 mrg @node AINT
905 1.1 mrg @section @code{AINT} --- Truncate to a whole number
906 1.1 mrg @fnindex AINT
907 1.1 mrg @fnindex DINT
908 1.1 mrg @cindex floor
909 1.1 mrg @cindex rounding, floor
910 1.1 mrg
911 1.1 mrg @table @asis
912 1.1 mrg @item @emph{Description}:
913 1.1 mrg @code{AINT(A [, KIND])} truncates its argument to a whole number.
914 1.1 mrg
915 1.1 mrg @item @emph{Standard}:
916 1.1 mrg Fortran 77 and later
917 1.1 mrg
918 1.1 mrg @item @emph{Class}:
919 1.1 mrg Elemental function
920 1.1 mrg
921 1.1 mrg @item @emph{Syntax}:
922 1.1 mrg @code{RESULT = AINT(A [, KIND])}
923 1.1 mrg
924 1.1 mrg @item @emph{Arguments}:
925 1.1 mrg @multitable @columnfractions .15 .70
926 1.1 mrg @item @var{A} @tab The type of the argument shall be @code{REAL}.
927 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
928 1.1 mrg expression indicating the kind parameter of the result.
929 1.1 mrg @end multitable
930 1.1 mrg
931 1.1 mrg @item @emph{Return value}:
932 1.1 mrg The return value is of type @code{REAL} with the kind type parameter of the
933 1.1 mrg argument if the optional @var{KIND} is absent; otherwise, the kind
934 1.1 mrg type parameter will be given by @var{KIND}. If the magnitude of
935 1.1 mrg @var{X} is less than one, @code{AINT(X)} returns zero. If the
936 1.1 mrg magnitude is equal to or greater than one then it returns the largest
937 1.1 mrg whole number that does not exceed its magnitude. The sign is the same
938 1.1 mrg as the sign of @var{X}.
939 1.1 mrg
940 1.1 mrg @item @emph{Example}:
941 1.1 mrg @smallexample
942 1.1 mrg program test_aint
943 1.1 mrg real(4) x4
944 1.1 mrg real(8) x8
945 1.1 mrg x4 = 1.234E0_4
946 1.1 mrg x8 = 4.321_8
947 1.1 mrg print *, aint(x4), dint(x8)
948 1.1 mrg x8 = aint(x4,8)
949 1.1 mrg end program test_aint
950 1.1 mrg @end smallexample
951 1.1 mrg
952 1.1 mrg @item @emph{Specific names}:
953 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
954 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
955 1.1 mrg @item @code{AINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
956 1.1 mrg @item @code{DINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later
957 1.1 mrg @end multitable
958 1.1 mrg @end table
959 1.1 mrg
960 1.1 mrg
961 1.1 mrg
962 1.1 mrg @node ALARM
963 1.1 mrg @section @code{ALARM} --- Execute a routine after a given delay
964 1.1 mrg @fnindex ALARM
965 1.1 mrg @cindex delayed execution
966 1.1 mrg
967 1.1 mrg @table @asis
968 1.1 mrg @item @emph{Description}:
969 1.1 mrg @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
970 1.1 mrg to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
971 1.1 mrg set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
972 1.1 mrg supplied, it will be returned with the number of seconds remaining until
973 1.1 mrg any previously scheduled alarm was due to be delivered, or zero if there
974 1.1 mrg was no previously scheduled alarm.
975 1.1 mrg
976 1.1 mrg @item @emph{Standard}:
977 1.1 mrg GNU extension
978 1.1 mrg
979 1.1 mrg @item @emph{Class}:
980 1.1 mrg Subroutine
981 1.1 mrg
982 1.1 mrg @item @emph{Syntax}:
983 1.1 mrg @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
984 1.1 mrg
985 1.1 mrg @item @emph{Arguments}:
986 1.1 mrg @multitable @columnfractions .15 .70
987 1.1 mrg @item @var{SECONDS} @tab The type of the argument shall be a scalar
988 1.1 mrg @code{INTEGER}. It is @code{INTENT(IN)}.
989 1.1 mrg @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
990 1.1 mrg @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar
991 1.1 mrg values may be either @code{SIG_IGN=1} to ignore the alarm generated
992 1.1 mrg or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
993 1.1 mrg @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
994 1.1 mrg variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
995 1.1 mrg @end multitable
996 1.1 mrg
997 1.1 mrg @item @emph{Example}:
998 1.1 mrg @smallexample
999 1.1 mrg program test_alarm
1000 1.1 mrg external handler_print
1001 1.1 mrg integer i
1002 1.1 mrg call alarm (3, handler_print, i)
1003 1.1 mrg print *, i
1004 1.1 mrg call sleep(10)
1005 1.1 mrg end program test_alarm
1006 1.1 mrg @end smallexample
1007 1.1 mrg This will cause the external routine @var{handler_print} to be called
1008 1.1 mrg after 3 seconds.
1009 1.1 mrg @end table
1010 1.1 mrg
1011 1.1 mrg
1012 1.1 mrg
1013 1.1 mrg @node ALL
1014 1.1 mrg @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
1015 1.1 mrg @fnindex ALL
1016 1.1 mrg @cindex array, apply condition
1017 1.1 mrg @cindex array, condition testing
1018 1.1 mrg
1019 1.1 mrg @table @asis
1020 1.1 mrg @item @emph{Description}:
1021 1.1 mrg @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
1022 1.1 mrg in the array along dimension @var{DIM}.
1023 1.1 mrg
1024 1.1 mrg @item @emph{Standard}:
1025 1.1.1.2 mrg Fortran 90 and later
1026 1.1 mrg
1027 1.1 mrg @item @emph{Class}:
1028 1.1 mrg Transformational function
1029 1.1 mrg
1030 1.1 mrg @item @emph{Syntax}:
1031 1.1 mrg @code{RESULT = ALL(MASK [, DIM])}
1032 1.1 mrg
1033 1.1 mrg @item @emph{Arguments}:
1034 1.1 mrg @multitable @columnfractions .15 .70
1035 1.1 mrg @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1036 1.1 mrg it shall not be scalar.
1037 1.1 mrg @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1038 1.1 mrg with a value that lies between one and the rank of @var{MASK}.
1039 1.1 mrg @end multitable
1040 1.1 mrg
1041 1.1 mrg @item @emph{Return value}:
1042 1.1 mrg @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL} where
1043 1.1 mrg the kind type parameter is the same as the kind type parameter of
1044 1.1 mrg @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
1045 1.1 mrg an array with the rank of @var{MASK} minus 1. The shape is determined from
1046 1.1 mrg the shape of @var{MASK} where the @var{DIM} dimension is elided.
1047 1.1 mrg
1048 1.1 mrg @table @asis
1049 1.1 mrg @item (A)
1050 1.1 mrg @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
1051 1.1 mrg It also is true if @var{MASK} has zero size; otherwise, it is false.
1052 1.1 mrg @item (B)
1053 1.1 mrg If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
1054 1.1 mrg to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
1055 1.1 mrg is determined by applying @code{ALL} to the array sections.
1056 1.1 mrg @end table
1057 1.1 mrg
1058 1.1 mrg @item @emph{Example}:
1059 1.1 mrg @smallexample
1060 1.1 mrg program test_all
1061 1.1 mrg logical l
1062 1.1 mrg l = all((/.true., .true., .true./))
1063 1.1 mrg print *, l
1064 1.1 mrg call section
1065 1.1 mrg contains
1066 1.1 mrg subroutine section
1067 1.1 mrg integer a(2,3), b(2,3)
1068 1.1 mrg a = 1
1069 1.1 mrg b = 1
1070 1.1 mrg b(2,2) = 2
1071 1.1 mrg print *, all(a .eq. b, 1)
1072 1.1 mrg print *, all(a .eq. b, 2)
1073 1.1 mrg end subroutine section
1074 1.1 mrg end program test_all
1075 1.1 mrg @end smallexample
1076 1.1 mrg @end table
1077 1.1 mrg
1078 1.1 mrg
1079 1.1 mrg
1080 1.1 mrg @node ALLOCATED
1081 1.1 mrg @section @code{ALLOCATED} --- Status of an allocatable entity
1082 1.1 mrg @fnindex ALLOCATED
1083 1.1 mrg @cindex allocation, status
1084 1.1 mrg
1085 1.1 mrg @table @asis
1086 1.1 mrg @item @emph{Description}:
1087 1.1 mrg @code{ALLOCATED(ARRAY)} and @code{ALLOCATED(SCALAR)} check the allocation
1088 1.1 mrg status of @var{ARRAY} and @var{SCALAR}, respectively.
1089 1.1 mrg
1090 1.1 mrg @item @emph{Standard}:
1091 1.1.1.2 mrg Fortran 90 and later. Note, the @code{SCALAR=} keyword and allocatable
1092 1.1 mrg scalar entities are available in Fortran 2003 and later.
1093 1.1 mrg
1094 1.1 mrg @item @emph{Class}:
1095 1.1 mrg Inquiry function
1096 1.1 mrg
1097 1.1 mrg @item @emph{Syntax}:
1098 1.1 mrg @multitable @columnfractions .80
1099 1.1 mrg @item @code{RESULT = ALLOCATED(ARRAY)}
1100 1.1 mrg @item @code{RESULT = ALLOCATED(SCALAR)}
1101 1.1 mrg @end multitable
1102 1.1 mrg
1103 1.1 mrg @item @emph{Arguments}:
1104 1.1 mrg @multitable @columnfractions .15 .70
1105 1.1 mrg @item @var{ARRAY} @tab The argument shall be an @code{ALLOCATABLE} array.
1106 1.1 mrg @item @var{SCALAR} @tab The argument shall be an @code{ALLOCATABLE} scalar.
1107 1.1 mrg @end multitable
1108 1.1 mrg
1109 1.1 mrg @item @emph{Return value}:
1110 1.1 mrg The return value is a scalar @code{LOGICAL} with the default logical
1111 1.1 mrg kind type parameter. If the argument is allocated, then the result is
1112 1.1 mrg @code{.TRUE.}; otherwise, it returns @code{.FALSE.}
1113 1.1 mrg
1114 1.1 mrg @item @emph{Example}:
1115 1.1 mrg @smallexample
1116 1.1 mrg program test_allocated
1117 1.1 mrg integer :: i = 4
1118 1.1 mrg real(4), allocatable :: x(:)
1119 1.1 mrg if (.not. allocated(x)) allocate(x(i))
1120 1.1 mrg end program test_allocated
1121 1.1 mrg @end smallexample
1122 1.1 mrg @end table
1123 1.1 mrg
1124 1.1 mrg
1125 1.1 mrg
1126 1.1 mrg @node AND
1127 1.1 mrg @section @code{AND} --- Bitwise logical AND
1128 1.1 mrg @fnindex AND
1129 1.1 mrg @cindex bitwise logical and
1130 1.1 mrg @cindex logical and, bitwise
1131 1.1 mrg
1132 1.1 mrg @table @asis
1133 1.1 mrg @item @emph{Description}:
1134 1.1 mrg Bitwise logical @code{AND}.
1135 1.1 mrg
1136 1.1 mrg This intrinsic routine is provided for backwards compatibility with
1137 1.1 mrg GNU Fortran 77. For integer arguments, programmers should consider
1138 1.1 mrg the use of the @ref{IAND} intrinsic defined by the Fortran standard.
1139 1.1 mrg
1140 1.1 mrg @item @emph{Standard}:
1141 1.1 mrg GNU extension
1142 1.1 mrg
1143 1.1 mrg @item @emph{Class}:
1144 1.1 mrg Function
1145 1.1 mrg
1146 1.1 mrg @item @emph{Syntax}:
1147 1.1 mrg @code{RESULT = AND(I, J)}
1148 1.1 mrg
1149 1.1 mrg @item @emph{Arguments}:
1150 1.1 mrg @multitable @columnfractions .15 .70
1151 1.1 mrg @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
1152 1.1 mrg type or a scalar @code{LOGICAL} type or a boz-literal-constant.
1153 1.1 mrg @item @var{J} @tab The type shall be the same as the type of @var{I} or
1154 1.1 mrg a boz-literal-constant. @var{I} and @var{J} shall not both be
1155 1.1 mrg boz-literal-constants. If either @var{I} or @var{J} is a
1156 1.1 mrg boz-literal-constant, then the other argument must be a scalar @code{INTEGER}.
1157 1.1 mrg @end multitable
1158 1.1 mrg
1159 1.1 mrg @item @emph{Return value}:
1160 1.1 mrg The return type is either a scalar @code{INTEGER} or a scalar
1161 1.1 mrg @code{LOGICAL}. If the kind type parameters differ, then the
1162 1.1 mrg smaller kind type is implicitly converted to larger kind, and the
1163 1.1 mrg return has the larger kind. A boz-literal-constant is
1164 1.1 mrg converted to an @code{INTEGER} with the kind type parameter of
1165 1.1 mrg the other argument as-if a call to @ref{INT} occurred.
1166 1.1 mrg
1167 1.1 mrg @item @emph{Example}:
1168 1.1 mrg @smallexample
1169 1.1 mrg PROGRAM test_and
1170 1.1 mrg LOGICAL :: T = .TRUE., F = .FALSE.
1171 1.1 mrg INTEGER :: a, b
1172 1.1 mrg DATA a / Z'F' /, b / Z'3' /
1173 1.1 mrg
1174 1.1 mrg WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1175 1.1 mrg WRITE (*,*) AND(a, b)
1176 1.1 mrg END PROGRAM
1177 1.1 mrg @end smallexample
1178 1.1 mrg
1179 1.1 mrg @item @emph{See also}:
1180 1.1.1.2 mrg Fortran 95 elemental function: @gol
1181 1.1.1.2 mrg @ref{IAND}
1182 1.1 mrg @end table
1183 1.1 mrg
1184 1.1 mrg
1185 1.1 mrg
1186 1.1 mrg @node ANINT
1187 1.1 mrg @section @code{ANINT} --- Nearest whole number
1188 1.1 mrg @fnindex ANINT
1189 1.1 mrg @fnindex DNINT
1190 1.1 mrg @cindex ceiling
1191 1.1 mrg @cindex rounding, ceiling
1192 1.1 mrg
1193 1.1 mrg @table @asis
1194 1.1 mrg @item @emph{Description}:
1195 1.1 mrg @code{ANINT(A [, KIND])} rounds its argument to the nearest whole number.
1196 1.1 mrg
1197 1.1 mrg @item @emph{Standard}:
1198 1.1 mrg Fortran 77 and later
1199 1.1 mrg
1200 1.1 mrg @item @emph{Class}:
1201 1.1 mrg Elemental function
1202 1.1 mrg
1203 1.1 mrg @item @emph{Syntax}:
1204 1.1 mrg @code{RESULT = ANINT(A [, KIND])}
1205 1.1 mrg
1206 1.1 mrg @item @emph{Arguments}:
1207 1.1 mrg @multitable @columnfractions .15 .70
1208 1.1 mrg @item @var{A} @tab The type of the argument shall be @code{REAL}.
1209 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
1210 1.1 mrg expression indicating the kind parameter of the result.
1211 1.1 mrg @end multitable
1212 1.1 mrg
1213 1.1 mrg @item @emph{Return value}:
1214 1.1 mrg The return value is of type real with the kind type parameter of the
1215 1.1 mrg argument if the optional @var{KIND} is absent; otherwise, the kind
1216 1.1 mrg type parameter will be given by @var{KIND}. If @var{A} is greater than
1217 1.1 mrg zero, @code{ANINT(A)} returns @code{AINT(X+0.5)}. If @var{A} is
1218 1.1 mrg less than or equal to zero then it returns @code{AINT(X-0.5)}.
1219 1.1 mrg
1220 1.1 mrg @item @emph{Example}:
1221 1.1 mrg @smallexample
1222 1.1 mrg program test_anint
1223 1.1 mrg real(4) x4
1224 1.1 mrg real(8) x8
1225 1.1 mrg x4 = 1.234E0_4
1226 1.1 mrg x8 = 4.321_8
1227 1.1 mrg print *, anint(x4), dnint(x8)
1228 1.1 mrg x8 = anint(x4,8)
1229 1.1 mrg end program test_anint
1230 1.1 mrg @end smallexample
1231 1.1 mrg
1232 1.1 mrg @item @emph{Specific names}:
1233 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1234 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1235 1.1 mrg @item @code{AINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
1236 1.1 mrg @item @code{DNINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later
1237 1.1 mrg @end multitable
1238 1.1 mrg @end table
1239 1.1 mrg
1240 1.1 mrg
1241 1.1 mrg
1242 1.1 mrg @node ANY
1243 1.1 mrg @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1244 1.1 mrg @fnindex ANY
1245 1.1 mrg @cindex array, apply condition
1246 1.1 mrg @cindex array, condition testing
1247 1.1 mrg
1248 1.1 mrg @table @asis
1249 1.1 mrg @item @emph{Description}:
1250 1.1 mrg @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1251 1.1 mrg @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1252 1.1 mrg
1253 1.1 mrg @item @emph{Standard}:
1254 1.1.1.2 mrg Fortran 90 and later
1255 1.1 mrg
1256 1.1 mrg @item @emph{Class}:
1257 1.1 mrg Transformational function
1258 1.1 mrg
1259 1.1 mrg @item @emph{Syntax}:
1260 1.1 mrg @code{RESULT = ANY(MASK [, DIM])}
1261 1.1 mrg
1262 1.1 mrg @item @emph{Arguments}:
1263 1.1 mrg @multitable @columnfractions .15 .70
1264 1.1 mrg @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1265 1.1 mrg it shall not be scalar.
1266 1.1 mrg @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1267 1.1 mrg with a value that lies between one and the rank of @var{MASK}.
1268 1.1 mrg @end multitable
1269 1.1 mrg
1270 1.1 mrg @item @emph{Return value}:
1271 1.1 mrg @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL} where
1272 1.1 mrg the kind type parameter is the same as the kind type parameter of
1273 1.1 mrg @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1274 1.1 mrg an array with the rank of @var{MASK} minus 1. The shape is determined from
1275 1.1 mrg the shape of @var{MASK} where the @var{DIM} dimension is elided.
1276 1.1 mrg
1277 1.1 mrg @table @asis
1278 1.1 mrg @item (A)
1279 1.1 mrg @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1280 1.1 mrg otherwise, it is false. It also is false if @var{MASK} has zero size.
1281 1.1 mrg @item (B)
1282 1.1 mrg If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1283 1.1 mrg to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1284 1.1 mrg is determined by applying @code{ANY} to the array sections.
1285 1.1 mrg @end table
1286 1.1 mrg
1287 1.1 mrg @item @emph{Example}:
1288 1.1 mrg @smallexample
1289 1.1 mrg program test_any
1290 1.1 mrg logical l
1291 1.1 mrg l = any((/.true., .true., .true./))
1292 1.1 mrg print *, l
1293 1.1 mrg call section
1294 1.1 mrg contains
1295 1.1 mrg subroutine section
1296 1.1 mrg integer a(2,3), b(2,3)
1297 1.1 mrg a = 1
1298 1.1 mrg b = 1
1299 1.1 mrg b(2,2) = 2
1300 1.1 mrg print *, any(a .eq. b, 1)
1301 1.1 mrg print *, any(a .eq. b, 2)
1302 1.1 mrg end subroutine section
1303 1.1 mrg end program test_any
1304 1.1 mrg @end smallexample
1305 1.1 mrg @end table
1306 1.1 mrg
1307 1.1 mrg
1308 1.1 mrg
1309 1.1 mrg @node ASIN
1310 1.1 mrg @section @code{ASIN} --- Arcsine function
1311 1.1 mrg @fnindex ASIN
1312 1.1 mrg @fnindex DASIN
1313 1.1 mrg @cindex trigonometric function, sine, inverse
1314 1.1 mrg @cindex sine, inverse
1315 1.1 mrg
1316 1.1 mrg @table @asis
1317 1.1 mrg @item @emph{Description}:
1318 1.1 mrg @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1319 1.1 mrg
1320 1.1 mrg @item @emph{Standard}:
1321 1.1 mrg Fortran 77 and later, for a complex argument Fortran 2008 or later
1322 1.1 mrg
1323 1.1 mrg @item @emph{Class}:
1324 1.1 mrg Elemental function
1325 1.1 mrg
1326 1.1 mrg @item @emph{Syntax}:
1327 1.1 mrg @code{RESULT = ASIN(X)}
1328 1.1 mrg
1329 1.1 mrg @item @emph{Arguments}:
1330 1.1 mrg @multitable @columnfractions .15 .70
1331 1.1 mrg @item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is
1332 1.1 mrg less than or equal to one - or be @code{COMPLEX}.
1333 1.1 mrg @end multitable
1334 1.1 mrg
1335 1.1 mrg @item @emph{Return value}:
1336 1.1 mrg The return value is of the same type and kind as @var{X}.
1337 1.1 mrg The real part of the result is in radians and lies in the range
1338 1.1 mrg @math{-\pi/2 \leq \Re \asin(x) \leq \pi/2}.
1339 1.1 mrg
1340 1.1 mrg @item @emph{Example}:
1341 1.1 mrg @smallexample
1342 1.1 mrg program test_asin
1343 1.1 mrg real(8) :: x = 0.866_8
1344 1.1 mrg x = asin(x)
1345 1.1 mrg end program test_asin
1346 1.1 mrg @end smallexample
1347 1.1 mrg
1348 1.1 mrg @item @emph{Specific names}:
1349 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1350 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1351 1.1 mrg @item @code{ASIN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
1352 1.1 mrg @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
1353 1.1 mrg @end multitable
1354 1.1 mrg
1355 1.1 mrg @item @emph{See also}:
1356 1.1.1.2 mrg Inverse function: @gol
1357 1.1.1.2 mrg @ref{SIN} @gol
1358 1.1.1.2 mrg Degrees function: @gol
1359 1.1.1.2 mrg @ref{ASIND}
1360 1.1 mrg @end table
1361 1.1 mrg
1362 1.1 mrg
1363 1.1 mrg
1364 1.1 mrg @node ASIND
1365 1.1 mrg @section @code{ASIND} --- Arcsine function, degrees
1366 1.1 mrg @fnindex ASIND
1367 1.1 mrg @fnindex DASIND
1368 1.1 mrg @cindex trigonometric function, sine, inverse, degrees
1369 1.1 mrg @cindex sine, inverse, degrees
1370 1.1 mrg
1371 1.1 mrg @table @asis
1372 1.1 mrg @item @emph{Description}:
1373 1.1 mrg @code{ASIND(X)} computes the arcsine of its @var{X} in degrees (inverse of
1374 1.1 mrg @code{SIND(X)}).
1375 1.1 mrg
1376 1.1 mrg This function is for compatibility only and should be avoided in favor of
1377 1.1 mrg standard constructs wherever possible.
1378 1.1 mrg
1379 1.1 mrg @item @emph{Standard}:
1380 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math}.
1381 1.1 mrg
1382 1.1 mrg @item @emph{Class}:
1383 1.1 mrg Elemental function
1384 1.1 mrg
1385 1.1 mrg @item @emph{Syntax}:
1386 1.1 mrg @code{RESULT = ASIND(X)}
1387 1.1 mrg
1388 1.1 mrg @item @emph{Arguments}:
1389 1.1 mrg @multitable @columnfractions .15 .70
1390 1.1 mrg @item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is
1391 1.1 mrg less than or equal to one - or be @code{COMPLEX}.
1392 1.1 mrg @end multitable
1393 1.1 mrg
1394 1.1 mrg @item @emph{Return value}:
1395 1.1 mrg The return value is of the same type and kind as @var{X}.
1396 1.1 mrg The real part of the result is in degrees and lies in the range
1397 1.1 mrg @math{-90 \leq \Re \asin(x) \leq 90}.
1398 1.1 mrg
1399 1.1 mrg @item @emph{Example}:
1400 1.1 mrg @smallexample
1401 1.1 mrg program test_asind
1402 1.1 mrg real(8) :: x = 0.866_8
1403 1.1 mrg x = asind(x)
1404 1.1 mrg end program test_asind
1405 1.1 mrg @end smallexample
1406 1.1 mrg
1407 1.1 mrg @item @emph{Specific names}:
1408 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1409 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1410 1.1.1.2 mrg @item @code{ASIND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
1411 1.1.1.2 mrg @item @code{DASIND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1412 1.1 mrg @end multitable
1413 1.1 mrg
1414 1.1 mrg @item @emph{See also}:
1415 1.1.1.2 mrg Inverse function: @gol
1416 1.1.1.2 mrg @ref{SIND} @gol
1417 1.1.1.2 mrg Radians function: @gol
1418 1.1.1.2 mrg @ref{ASIN}
1419 1.1 mrg @end table
1420 1.1 mrg
1421 1.1 mrg
1422 1.1 mrg
1423 1.1 mrg @node ASINH
1424 1.1 mrg @section @code{ASINH} --- Inverse hyperbolic sine function
1425 1.1 mrg @fnindex ASINH
1426 1.1 mrg @fnindex DASINH
1427 1.1 mrg @cindex area hyperbolic sine
1428 1.1 mrg @cindex inverse hyperbolic sine
1429 1.1 mrg @cindex hyperbolic function, sine, inverse
1430 1.1 mrg @cindex sine, hyperbolic, inverse
1431 1.1 mrg
1432 1.1 mrg @table @asis
1433 1.1 mrg @item @emph{Description}:
1434 1.1 mrg @code{ASINH(X)} computes the inverse hyperbolic sine of @var{X}.
1435 1.1 mrg
1436 1.1 mrg @item @emph{Standard}:
1437 1.1 mrg Fortran 2008 and later
1438 1.1 mrg
1439 1.1 mrg @item @emph{Class}:
1440 1.1 mrg Elemental function
1441 1.1 mrg
1442 1.1 mrg @item @emph{Syntax}:
1443 1.1 mrg @code{RESULT = ASINH(X)}
1444 1.1 mrg
1445 1.1 mrg @item @emph{Arguments}:
1446 1.1 mrg @multitable @columnfractions .15 .70
1447 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1448 1.1 mrg @end multitable
1449 1.1 mrg
1450 1.1 mrg @item @emph{Return value}:
1451 1.1 mrg The return value is of the same type and kind as @var{X}. If @var{X} is
1452 1.1 mrg complex, the imaginary part of the result is in radians and lies between
1453 1.1 mrg @math{-\pi/2 \leq \Im \asinh(x) \leq \pi/2}.
1454 1.1 mrg
1455 1.1 mrg @item @emph{Example}:
1456 1.1 mrg @smallexample
1457 1.1 mrg PROGRAM test_asinh
1458 1.1 mrg REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1459 1.1 mrg WRITE (*,*) ASINH(x)
1460 1.1 mrg END PROGRAM
1461 1.1 mrg @end smallexample
1462 1.1 mrg
1463 1.1 mrg @item @emph{Specific names}:
1464 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1465 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1466 1.1 mrg @item @code{DASINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension.
1467 1.1 mrg @end multitable
1468 1.1 mrg
1469 1.1 mrg @item @emph{See also}:
1470 1.1.1.2 mrg Inverse function: @gol
1471 1.1.1.2 mrg @ref{SINH}
1472 1.1 mrg @end table
1473 1.1 mrg
1474 1.1 mrg
1475 1.1 mrg
1476 1.1 mrg @node ASSOCIATED
1477 1.1 mrg @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1478 1.1 mrg @fnindex ASSOCIATED
1479 1.1 mrg @cindex pointer, status
1480 1.1 mrg @cindex association status
1481 1.1 mrg
1482 1.1 mrg @table @asis
1483 1.1 mrg @item @emph{Description}:
1484 1.1 mrg @code{ASSOCIATED(POINTER [, TARGET])} determines the status of the pointer
1485 1.1 mrg @var{POINTER} or if @var{POINTER} is associated with the target @var{TARGET}.
1486 1.1 mrg
1487 1.1 mrg @item @emph{Standard}:
1488 1.1.1.2 mrg Fortran 90 and later
1489 1.1 mrg
1490 1.1 mrg @item @emph{Class}:
1491 1.1 mrg Inquiry function
1492 1.1 mrg
1493 1.1 mrg @item @emph{Syntax}:
1494 1.1 mrg @code{RESULT = ASSOCIATED(POINTER [, TARGET])}
1495 1.1 mrg
1496 1.1 mrg @item @emph{Arguments}:
1497 1.1 mrg @multitable @columnfractions .15 .70
1498 1.1 mrg @item @var{POINTER} @tab @var{POINTER} shall have the @code{POINTER} attribute
1499 1.1 mrg and it can be of any type.
1500 1.1 mrg @item @var{TARGET} @tab (Optional) @var{TARGET} shall be a pointer or
1501 1.1 mrg a target. It must have the same type, kind type parameter, and
1502 1.1 mrg array rank as @var{POINTER}.
1503 1.1 mrg @end multitable
1504 1.1 mrg The association status of neither @var{POINTER} nor @var{TARGET} shall be
1505 1.1 mrg undefined.
1506 1.1 mrg
1507 1.1 mrg @item @emph{Return value}:
1508 1.1 mrg @code{ASSOCIATED(POINTER)} returns a scalar value of type @code{LOGICAL(4)}.
1509 1.1 mrg There are several cases:
1510 1.1 mrg @table @asis
1511 1.1 mrg @item (A) When the optional @var{TARGET} is not present then
1512 1.1 mrg @code{ASSOCIATED(POINTER)} is true if @var{POINTER} is associated with a target; otherwise, it returns false.
1513 1.1 mrg @item (B) If @var{TARGET} is present and a scalar target, the result is true if
1514 1.1 mrg @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
1515 1.1 mrg disassociated, the result is false.
1516 1.1 mrg @item (C) If @var{TARGET} is present and an array target, the result is true if
1517 1.1 mrg @var{TARGET} and @var{POINTER} have the same shape, are not zero-sized arrays,
1518 1.1 mrg are arrays whose elements are not zero-sized storage sequences, and
1519 1.1 mrg @var{TARGET} and @var{POINTER} occupy the same storage units in array element
1520 1.1 mrg order.
1521 1.1 mrg As in case(B), the result is false, if @var{POINTER} is disassociated.
1522 1.1 mrg @item (D) If @var{TARGET} is present and an scalar pointer, the result is true
1523 1.1 mrg if @var{TARGET} is associated with @var{POINTER}, the target associated with
1524 1.1 mrg @var{TARGET} are not zero-sized storage sequences and occupy the same storage
1525 1.1 mrg units.
1526 1.1 mrg The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1527 1.1 mrg @item (E) If @var{TARGET} is present and an array pointer, the result is true if
1528 1.1 mrg target associated with @var{POINTER} and the target associated with @var{TARGET}
1529 1.1 mrg have the same shape, are not zero-sized arrays, are arrays whose elements are
1530 1.1 mrg not zero-sized storage sequences, and @var{TARGET} and @var{POINTER} occupy
1531 1.1 mrg the same storage units in array element order.
1532 1.1 mrg The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1533 1.1 mrg @end table
1534 1.1 mrg
1535 1.1 mrg @item @emph{Example}:
1536 1.1 mrg @smallexample
1537 1.1 mrg program test_associated
1538 1.1 mrg implicit none
1539 1.1 mrg real, target :: tgt(2) = (/1., 2./)
1540 1.1 mrg real, pointer :: ptr(:)
1541 1.1 mrg ptr => tgt
1542 1.1 mrg if (associated(ptr) .eqv. .false.) call abort
1543 1.1 mrg if (associated(ptr,tgt) .eqv. .false.) call abort
1544 1.1 mrg end program test_associated
1545 1.1 mrg @end smallexample
1546 1.1 mrg
1547 1.1 mrg @item @emph{See also}:
1548 1.1 mrg @ref{NULL}
1549 1.1 mrg @end table
1550 1.1 mrg
1551 1.1 mrg
1552 1.1 mrg
1553 1.1 mrg @node ATAN
1554 1.1 mrg @section @code{ATAN} --- Arctangent function
1555 1.1 mrg @fnindex ATAN
1556 1.1 mrg @fnindex DATAN
1557 1.1 mrg @cindex trigonometric function, tangent, inverse
1558 1.1 mrg @cindex tangent, inverse
1559 1.1 mrg
1560 1.1 mrg @table @asis
1561 1.1 mrg @item @emph{Description}:
1562 1.1 mrg @code{ATAN(X)} computes the arctangent of @var{X}.
1563 1.1 mrg
1564 1.1 mrg @item @emph{Standard}:
1565 1.1 mrg Fortran 77 and later, for a complex argument and for two arguments
1566 1.1 mrg Fortran 2008 or later
1567 1.1 mrg
1568 1.1 mrg @item @emph{Class}:
1569 1.1 mrg Elemental function
1570 1.1 mrg
1571 1.1 mrg @item @emph{Syntax}:
1572 1.1 mrg @multitable @columnfractions .80
1573 1.1 mrg @item @code{RESULT = ATAN(X)}
1574 1.1 mrg @item @code{RESULT = ATAN(Y, X)}
1575 1.1 mrg @end multitable
1576 1.1 mrg
1577 1.1 mrg @item @emph{Arguments}:
1578 1.1 mrg @multitable @columnfractions .15 .70
1579 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX};
1580 1.1 mrg if @var{Y} is present, @var{X} shall be REAL.
1581 1.1.1.2 mrg @item @var{Y} @tab The type and kind type parameter shall be the same as @var{X}.
1582 1.1 mrg @end multitable
1583 1.1 mrg
1584 1.1 mrg @item @emph{Return value}:
1585 1.1 mrg The return value is of the same type and kind as @var{X}.
1586 1.1 mrg If @var{Y} is present, the result is identical to @code{ATAN2(Y,X)}.
1587 1.1 mrg Otherwise, it the arcus tangent of @var{X}, where the real part of
1588 1.1 mrg the result is in radians and lies in the range
1589 1.1 mrg @math{-\pi/2 \leq \Re \atan(x) \leq \pi/2}.
1590 1.1 mrg
1591 1.1 mrg @item @emph{Example}:
1592 1.1 mrg @smallexample
1593 1.1 mrg program test_atan
1594 1.1 mrg real(8) :: x = 2.866_8
1595 1.1 mrg x = atan(x)
1596 1.1 mrg end program test_atan
1597 1.1 mrg @end smallexample
1598 1.1 mrg
1599 1.1 mrg @item @emph{Specific names}:
1600 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1601 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1602 1.1 mrg @item @code{ATAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
1603 1.1 mrg @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
1604 1.1 mrg @end multitable
1605 1.1 mrg
1606 1.1 mrg @item @emph{See also}:
1607 1.1.1.2 mrg Inverse function: @gol
1608 1.1.1.2 mrg @ref{TAN} @gol
1609 1.1.1.2 mrg Degrees function: @gol
1610 1.1.1.2 mrg @ref{ATAND}
1611 1.1 mrg @end table
1612 1.1 mrg
1613 1.1 mrg
1614 1.1 mrg
1615 1.1 mrg @node ATAND
1616 1.1 mrg @section @code{ATAND} --- Arctangent function, degrees
1617 1.1 mrg @fnindex ATAND
1618 1.1 mrg @fnindex DATAND
1619 1.1 mrg @cindex trigonometric function, tangent, inverse, degrees
1620 1.1 mrg @cindex tangent, inverse, degrees
1621 1.1 mrg
1622 1.1 mrg @table @asis
1623 1.1 mrg @item @emph{Description}:
1624 1.1 mrg @code{ATAND(X)} computes the arctangent of @var{X} in degrees (inverse of
1625 1.1 mrg @ref{TAND}).
1626 1.1 mrg
1627 1.1 mrg This function is for compatibility only and should be avoided in favor of
1628 1.1 mrg standard constructs wherever possible.
1629 1.1 mrg
1630 1.1 mrg @item @emph{Standard}:
1631 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math}.
1632 1.1 mrg
1633 1.1 mrg @item @emph{Class}:
1634 1.1 mrg Elemental function
1635 1.1 mrg
1636 1.1 mrg @item @emph{Syntax}:
1637 1.1 mrg @multitable @columnfractions .80
1638 1.1 mrg @item @code{RESULT = ATAND(X)}
1639 1.1 mrg @item @code{RESULT = ATAND(Y, X)}
1640 1.1 mrg @end multitable
1641 1.1 mrg
1642 1.1 mrg @item @emph{Arguments}:
1643 1.1 mrg @multitable @columnfractions .15 .70
1644 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX};
1645 1.1 mrg if @var{Y} is present, @var{X} shall be REAL.
1646 1.1.1.2 mrg @item @var{Y} @tab The type and kind type parameter shall be the same as @var{X}.
1647 1.1 mrg @end multitable
1648 1.1 mrg
1649 1.1 mrg @item @emph{Return value}:
1650 1.1 mrg The return value is of the same type and kind as @var{X}.
1651 1.1 mrg If @var{Y} is present, the result is identical to @code{ATAND2(Y,X)}.
1652 1.1 mrg Otherwise, it is the arcus tangent of @var{X}, where the real part of
1653 1.1 mrg the result is in degrees and lies in the range
1654 1.1 mrg @math{-90 \leq \Re \atand(x) \leq 90}.
1655 1.1 mrg
1656 1.1 mrg @item @emph{Example}:
1657 1.1 mrg @smallexample
1658 1.1 mrg program test_atand
1659 1.1 mrg real(8) :: x = 2.866_8
1660 1.1 mrg x = atand(x)
1661 1.1 mrg end program test_atand
1662 1.1 mrg @end smallexample
1663 1.1 mrg
1664 1.1 mrg @item @emph{Specific names}:
1665 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1666 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1667 1.1.1.2 mrg @item @code{ATAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
1668 1.1.1.2 mrg @item @code{DATAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1669 1.1 mrg @end multitable
1670 1.1 mrg
1671 1.1 mrg @item @emph{See also}:
1672 1.1.1.2 mrg Inverse function: @gol
1673 1.1.1.2 mrg @ref{TAND} @gol
1674 1.1.1.2 mrg Radians function: @gol
1675 1.1.1.2 mrg @ref{ATAN}
1676 1.1 mrg @end table
1677 1.1 mrg
1678 1.1 mrg
1679 1.1 mrg
1680 1.1 mrg @node ATAN2
1681 1.1 mrg @section @code{ATAN2} --- Arctangent function
1682 1.1 mrg @fnindex ATAN2
1683 1.1 mrg @fnindex DATAN2
1684 1.1 mrg @cindex trigonometric function, tangent, inverse
1685 1.1 mrg @cindex tangent, inverse
1686 1.1 mrg
1687 1.1 mrg @table @asis
1688 1.1 mrg @item @emph{Description}:
1689 1.1 mrg @code{ATAN2(Y, X)} computes the principal value of the argument
1690 1.1 mrg function of the complex number @math{X + i Y}. This function can
1691 1.1 mrg be used to transform from Cartesian into polar coordinates and
1692 1.1 mrg allows to determine the angle in the correct quadrant.
1693 1.1 mrg
1694 1.1 mrg @item @emph{Standard}:
1695 1.1 mrg Fortran 77 and later
1696 1.1 mrg
1697 1.1 mrg @item @emph{Class}:
1698 1.1 mrg Elemental function
1699 1.1 mrg
1700 1.1 mrg @item @emph{Syntax}:
1701 1.1 mrg @code{RESULT = ATAN2(Y, X)}
1702 1.1 mrg
1703 1.1 mrg @item @emph{Arguments}:
1704 1.1 mrg @multitable @columnfractions .15 .70
1705 1.1 mrg @item @var{Y} @tab The type shall be @code{REAL}.
1706 1.1 mrg @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1707 1.1 mrg If @var{Y} is zero, then @var{X} must be nonzero.
1708 1.1 mrg @end multitable
1709 1.1 mrg
1710 1.1 mrg @item @emph{Return value}:
1711 1.1 mrg The return value has the same type and kind type parameter as @var{Y}. It
1712 1.1 mrg is the principal value of the complex number @math{X + i Y}. If @var{X}
1713 1.1 mrg is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1714 1.1 mrg The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1715 1.1 mrg the return value is zero if @var{X} is strictly positive, @math{\pi} if
1716 1.1 mrg @var{X} is negative and @var{Y} is positive zero (or the processor does
1717 1.1 mrg not handle signed zeros), and @math{-\pi} if @var{X} is negative and
1718 1.1 mrg @var{Y} is negative zero. Finally, if @var{X} is zero, then the
1719 1.1 mrg magnitude of the result is @math{\pi/2}.
1720 1.1 mrg
1721 1.1 mrg @item @emph{Example}:
1722 1.1 mrg @smallexample
1723 1.1 mrg program test_atan2
1724 1.1 mrg real(4) :: x = 1.e0_4, y = 0.5e0_4
1725 1.1 mrg x = atan2(y,x)
1726 1.1 mrg end program test_atan2
1727 1.1 mrg @end smallexample
1728 1.1 mrg
1729 1.1 mrg @item @emph{Specific names}:
1730 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1731 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1732 1.1 mrg @item @code{ATAN2(X, Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
1733 1.1 mrg @item @code{DATAN2(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
1734 1.1 mrg @end multitable
1735 1.1 mrg
1736 1.1 mrg @item @emph{See also}:
1737 1.1.1.2 mrg Alias: @gol
1738 1.1.1.2 mrg @ref{ATAN} @gol
1739 1.1.1.2 mrg Degrees function: @gol
1740 1.1.1.2 mrg @ref{ATAN2D}
1741 1.1 mrg @end table
1742 1.1 mrg
1743 1.1 mrg
1744 1.1 mrg
1745 1.1 mrg @node ATAN2D
1746 1.1 mrg @section @code{ATAN2D} --- Arctangent function, degrees
1747 1.1 mrg @fnindex ATAN2D
1748 1.1 mrg @fnindex DATAN2D
1749 1.1 mrg @cindex trigonometric function, tangent, inverse, degrees
1750 1.1 mrg @cindex tangent, inverse, degrees
1751 1.1 mrg
1752 1.1 mrg @table @asis
1753 1.1 mrg @item @emph{Description}:
1754 1.1 mrg @code{ATAN2D(Y, X)} computes the principal value of the argument
1755 1.1 mrg function of the complex number @math{X + i Y} in degrees. This function can
1756 1.1 mrg be used to transform from Cartesian into polar coordinates and
1757 1.1 mrg allows to determine the angle in the correct quadrant.
1758 1.1 mrg
1759 1.1 mrg This function is for compatibility only and should be avoided in favor of
1760 1.1 mrg standard constructs wherever possible.
1761 1.1 mrg
1762 1.1 mrg @item @emph{Standard}:
1763 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math}.
1764 1.1 mrg
1765 1.1 mrg @item @emph{Class}:
1766 1.1 mrg Elemental function
1767 1.1 mrg
1768 1.1 mrg @item @emph{Syntax}:
1769 1.1 mrg @code{RESULT = ATAN2D(Y, X)}
1770 1.1 mrg
1771 1.1 mrg @item @emph{Arguments}:
1772 1.1 mrg @multitable @columnfractions .15 .70
1773 1.1 mrg @item @var{Y} @tab The type shall be @code{REAL}.
1774 1.1 mrg @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1775 1.1 mrg If @var{Y} is zero, then @var{X} must be nonzero.
1776 1.1 mrg @end multitable
1777 1.1 mrg
1778 1.1 mrg @item @emph{Return value}:
1779 1.1 mrg The return value has the same type and kind type parameter as @var{Y}. It
1780 1.1 mrg is the principal value of the complex number @math{X + i Y}. If @var{X}
1781 1.1 mrg is nonzero, then it lies in the range @math{-180 \le \atan (x) \leq 180}.
1782 1.1 mrg The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1783 1.1 mrg the return value is zero if @var{X} is strictly positive, @math{180} if
1784 1.1 mrg @var{X} is negative and @var{Y} is positive zero (or the processor does
1785 1.1 mrg not handle signed zeros), and @math{-180} if @var{X} is negative and
1786 1.1 mrg @var{Y} is negative zero. Finally, if @var{X} is zero, then the
1787 1.1 mrg magnitude of the result is @math{90}.
1788 1.1 mrg
1789 1.1 mrg @item @emph{Example}:
1790 1.1 mrg @smallexample
1791 1.1 mrg program test_atan2d
1792 1.1 mrg real(4) :: x = 1.e0_4, y = 0.5e0_4
1793 1.1 mrg x = atan2d(y,x)
1794 1.1 mrg end program test_atan2d
1795 1.1 mrg @end smallexample
1796 1.1 mrg
1797 1.1 mrg @item @emph{Specific names}:
1798 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1799 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1800 1.1.1.2 mrg @item @code{ATAN2D(X, Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab GNU extension
1801 1.1.1.2 mrg @item @code{DATAN2D(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab GNU extension
1802 1.1 mrg @end multitable
1803 1.1 mrg
1804 1.1 mrg @item @emph{See also}:
1805 1.1.1.2 mrg Alias: @gol
1806 1.1.1.2 mrg @ref{ATAND} @gol
1807 1.1.1.2 mrg Radians function: @gol
1808 1.1.1.2 mrg @ref{ATAN2}
1809 1.1 mrg @end table
1810 1.1 mrg
1811 1.1 mrg
1812 1.1 mrg
1813 1.1 mrg @node ATANH
1814 1.1 mrg @section @code{ATANH} --- Inverse hyperbolic tangent function
1815 1.1 mrg @fnindex ATANH
1816 1.1 mrg @fnindex DATANH
1817 1.1 mrg @cindex area hyperbolic tangent
1818 1.1 mrg @cindex inverse hyperbolic tangent
1819 1.1 mrg @cindex hyperbolic function, tangent, inverse
1820 1.1 mrg @cindex tangent, hyperbolic, inverse
1821 1.1 mrg
1822 1.1 mrg @table @asis
1823 1.1 mrg @item @emph{Description}:
1824 1.1 mrg @code{ATANH(X)} computes the inverse hyperbolic tangent of @var{X}.
1825 1.1 mrg
1826 1.1 mrg @item @emph{Standard}:
1827 1.1 mrg Fortran 2008 and later
1828 1.1 mrg
1829 1.1 mrg @item @emph{Class}:
1830 1.1 mrg Elemental function
1831 1.1 mrg
1832 1.1 mrg @item @emph{Syntax}:
1833 1.1 mrg @code{RESULT = ATANH(X)}
1834 1.1 mrg
1835 1.1 mrg @item @emph{Arguments}:
1836 1.1 mrg @multitable @columnfractions .15 .70
1837 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1838 1.1 mrg @end multitable
1839 1.1 mrg
1840 1.1 mrg @item @emph{Return value}:
1841 1.1 mrg The return value has same type and kind as @var{X}. If @var{X} is
1842 1.1 mrg complex, the imaginary part of the result is in radians and lies between
1843 1.1 mrg @math{-\pi/2 \leq \Im \atanh(x) \leq \pi/2}.
1844 1.1 mrg
1845 1.1 mrg @item @emph{Example}:
1846 1.1 mrg @smallexample
1847 1.1 mrg PROGRAM test_atanh
1848 1.1 mrg REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1849 1.1 mrg WRITE (*,*) ATANH(x)
1850 1.1 mrg END PROGRAM
1851 1.1 mrg @end smallexample
1852 1.1 mrg
1853 1.1 mrg @item @emph{Specific names}:
1854 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1855 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1856 1.1 mrg @item @code{DATANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1857 1.1 mrg @end multitable
1858 1.1 mrg
1859 1.1 mrg @item @emph{See also}:
1860 1.1.1.2 mrg Inverse function: @gol
1861 1.1.1.2 mrg @ref{TANH}
1862 1.1 mrg @end table
1863 1.1 mrg
1864 1.1 mrg
1865 1.1 mrg
1866 1.1 mrg @node ATOMIC_ADD
1867 1.1 mrg @section @code{ATOMIC_ADD} --- Atomic ADD operation
1868 1.1 mrg @fnindex ATOMIC_ADD
1869 1.1 mrg @cindex Atomic subroutine, add
1870 1.1 mrg
1871 1.1 mrg @table @asis
1872 1.1 mrg @item @emph{Description}:
1873 1.1 mrg @code{ATOMIC_ADD(ATOM, VALUE)} atomically adds the value of @var{VAR} to the
1874 1.1 mrg variable @var{ATOM}. When @var{STAT} is present and the invocation was
1875 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation
1876 1.1 mrg has failed, it is assigned a positive value; in particular, for a coindexed
1877 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of
1878 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
1879 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}.
1880 1.1 mrg
1881 1.1 mrg @item @emph{Standard}:
1882 1.1 mrg TS 18508 or later
1883 1.1 mrg
1884 1.1 mrg @item @emph{Class}:
1885 1.1 mrg Atomic subroutine
1886 1.1 mrg
1887 1.1 mrg @item @emph{Syntax}:
1888 1.1 mrg @code{CALL ATOMIC_ADD (ATOM, VALUE [, STAT])}
1889 1.1 mrg
1890 1.1 mrg @item @emph{Arguments}:
1891 1.1 mrg @multitable @columnfractions .15 .70
1892 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
1893 1.1 mrg type with @code{ATOMIC_INT_KIND} kind.
1894 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
1895 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
1896 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
1897 1.1 mrg @end multitable
1898 1.1 mrg
1899 1.1 mrg @item @emph{Example}:
1900 1.1 mrg @smallexample
1901 1.1 mrg program atomic
1902 1.1 mrg use iso_fortran_env
1903 1.1 mrg integer(atomic_int_kind) :: atom[*]
1904 1.1 mrg call atomic_add (atom[1], this_image())
1905 1.1 mrg end program atomic
1906 1.1 mrg @end smallexample
1907 1.1 mrg
1908 1.1 mrg @item @emph{See also}:
1909 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol
1910 1.1.1.2 mrg @ref{ATOMIC_FETCH_ADD}, @gol
1911 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol
1912 1.1.1.2 mrg @ref{ATOMIC_AND}, @gol
1913 1.1.1.2 mrg @ref{ATOMIC_OR}, @gol
1914 1.1.1.2 mrg @ref{ATOMIC_XOR}
1915 1.1 mrg @end table
1916 1.1 mrg
1917 1.1 mrg
1918 1.1 mrg
1919 1.1 mrg
1920 1.1 mrg @node ATOMIC_AND
1921 1.1 mrg @section @code{ATOMIC_AND} --- Atomic bitwise AND operation
1922 1.1 mrg @fnindex ATOMIC_AND
1923 1.1 mrg @cindex Atomic subroutine, AND
1924 1.1 mrg
1925 1.1 mrg @table @asis
1926 1.1 mrg @item @emph{Description}:
1927 1.1 mrg @code{ATOMIC_AND(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
1928 1.1 mrg AND between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
1929 1.1 mrg and the invocation was successful, it is assigned the value 0. If it is present
1930 1.1 mrg and the invocation has failed, it is assigned a positive value; in particular,
1931 1.1 mrg for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
1932 1.1 mrg value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
1933 1.1 mrg image has failed, the value @code{STAT_FAILED_IMAGE}.
1934 1.1 mrg
1935 1.1 mrg @item @emph{Standard}:
1936 1.1 mrg TS 18508 or later
1937 1.1 mrg
1938 1.1 mrg @item @emph{Class}:
1939 1.1 mrg Atomic subroutine
1940 1.1 mrg
1941 1.1 mrg @item @emph{Syntax}:
1942 1.1 mrg @code{CALL ATOMIC_AND (ATOM, VALUE [, STAT])}
1943 1.1 mrg
1944 1.1 mrg @item @emph{Arguments}:
1945 1.1 mrg @multitable @columnfractions .15 .70
1946 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
1947 1.1 mrg type with @code{ATOMIC_INT_KIND} kind.
1948 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
1949 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
1950 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
1951 1.1 mrg @end multitable
1952 1.1 mrg
1953 1.1 mrg @item @emph{Example}:
1954 1.1 mrg @smallexample
1955 1.1 mrg program atomic
1956 1.1 mrg use iso_fortran_env
1957 1.1 mrg integer(atomic_int_kind) :: atom[*]
1958 1.1 mrg call atomic_and (atom[1], int(b'10100011101'))
1959 1.1 mrg end program atomic
1960 1.1 mrg @end smallexample
1961 1.1 mrg
1962 1.1 mrg @item @emph{See also}:
1963 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol
1964 1.1.1.2 mrg @ref{ATOMIC_FETCH_AND}, @gol
1965 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol
1966 1.1.1.2 mrg @ref{ATOMIC_ADD}, @gol
1967 1.1.1.2 mrg @ref{ATOMIC_OR}, @gol
1968 1.1.1.2 mrg @ref{ATOMIC_XOR}
1969 1.1 mrg @end table
1970 1.1 mrg
1971 1.1 mrg
1972 1.1 mrg
1973 1.1 mrg @node ATOMIC_CAS
1974 1.1 mrg @section @code{ATOMIC_CAS} --- Atomic compare and swap
1975 1.1 mrg @fnindex ATOMIC_DEFINE
1976 1.1 mrg @cindex Atomic subroutine, compare and swap
1977 1.1 mrg
1978 1.1 mrg @table @asis
1979 1.1 mrg @item @emph{Description}:
1980 1.1 mrg @code{ATOMIC_CAS} compares the variable @var{ATOM} with the value of
1981 1.1 mrg @var{COMPARE}; if the value is the same, @var{ATOM} is set to the value
1982 1.1 mrg of @var{NEW}. Additionally, @var{OLD} is set to the value of @var{ATOM}
1983 1.1 mrg that was used for the comparison. When @var{STAT} is present and the invocation
1984 1.1 mrg was successful, it is assigned the value 0. If it is present and the invocation
1985 1.1 mrg has failed, it is assigned a positive value; in particular, for a coindexed
1986 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of
1987 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
1988 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}.
1989 1.1 mrg
1990 1.1 mrg @item @emph{Standard}:
1991 1.1 mrg TS 18508 or later
1992 1.1 mrg
1993 1.1 mrg @item @emph{Class}:
1994 1.1 mrg Atomic subroutine
1995 1.1 mrg
1996 1.1 mrg @item @emph{Syntax}:
1997 1.1 mrg @code{CALL ATOMIC_CAS (ATOM, OLD, COMPARE, NEW [, STAT])}
1998 1.1 mrg
1999 1.1 mrg @item @emph{Arguments}:
2000 1.1 mrg @multitable @columnfractions .15 .70
2001 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer
2002 1.1 mrg type with @code{ATOMIC_INT_KIND} kind or logical type with
2003 1.1 mrg @code{ATOMIC_LOGICAL_KIND} kind.
2004 1.1 mrg @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2005 1.1 mrg @item @var{COMPARE} @tab Scalar variable of the same type and kind as
2006 1.1 mrg @var{ATOM}.
2007 1.1 mrg @item @var{NEW} @tab Scalar variable of the same type as @var{ATOM}. If kind
2008 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
2009 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2010 1.1 mrg @end multitable
2011 1.1 mrg
2012 1.1 mrg @item @emph{Example}:
2013 1.1 mrg @smallexample
2014 1.1 mrg program atomic
2015 1.1 mrg use iso_fortran_env
2016 1.1 mrg logical(atomic_logical_kind) :: atom[*], prev
2017 1.1 mrg call atomic_cas (atom[1], prev, .false., .true.))
2018 1.1 mrg end program atomic
2019 1.1 mrg @end smallexample
2020 1.1 mrg
2021 1.1 mrg @item @emph{See also}:
2022 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol
2023 1.1.1.2 mrg @ref{ATOMIC_REF}, @gol
2024 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}
2025 1.1 mrg @end table
2026 1.1 mrg
2027 1.1 mrg
2028 1.1 mrg
2029 1.1 mrg @node ATOMIC_DEFINE
2030 1.1 mrg @section @code{ATOMIC_DEFINE} --- Setting a variable atomically
2031 1.1 mrg @fnindex ATOMIC_DEFINE
2032 1.1 mrg @cindex Atomic subroutine, define
2033 1.1 mrg
2034 1.1 mrg @table @asis
2035 1.1 mrg @item @emph{Description}:
2036 1.1 mrg @code{ATOMIC_DEFINE(ATOM, VALUE)} defines the variable @var{ATOM} with the value
2037 1.1 mrg @var{VALUE} atomically. When @var{STAT} is present and the invocation was
2038 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation
2039 1.1 mrg has failed, it is assigned a positive value; in particular, for a coindexed
2040 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of
2041 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2042 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}.
2043 1.1 mrg
2044 1.1 mrg @item @emph{Standard}:
2045 1.1 mrg Fortran 2008 and later; with @var{STAT}, TS 18508 or later
2046 1.1 mrg
2047 1.1 mrg @item @emph{Class}:
2048 1.1 mrg Atomic subroutine
2049 1.1 mrg
2050 1.1 mrg @item @emph{Syntax}:
2051 1.1 mrg @code{CALL ATOMIC_DEFINE (ATOM, VALUE [, STAT])}
2052 1.1 mrg
2053 1.1 mrg @item @emph{Arguments}:
2054 1.1 mrg @multitable @columnfractions .15 .70
2055 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer
2056 1.1 mrg type with @code{ATOMIC_INT_KIND} kind or logical type with
2057 1.1 mrg @code{ATOMIC_LOGICAL_KIND} kind.
2058 1.1 mrg
2059 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2060 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
2061 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2062 1.1 mrg @end multitable
2063 1.1 mrg
2064 1.1 mrg @item @emph{Example}:
2065 1.1 mrg @smallexample
2066 1.1 mrg program atomic
2067 1.1 mrg use iso_fortran_env
2068 1.1 mrg integer(atomic_int_kind) :: atom[*]
2069 1.1 mrg call atomic_define (atom[1], this_image())
2070 1.1 mrg end program atomic
2071 1.1 mrg @end smallexample
2072 1.1 mrg
2073 1.1 mrg @item @emph{See also}:
2074 1.1.1.2 mrg @ref{ATOMIC_REF}, @gol
2075 1.1.1.2 mrg @ref{ATOMIC_CAS}, @gol
2076 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol
2077 1.1.1.2 mrg @ref{ATOMIC_ADD}, @gol
2078 1.1.1.2 mrg @ref{ATOMIC_AND}, @gol
2079 1.1.1.2 mrg @ref{ATOMIC_OR}, @gol
2080 1.1.1.2 mrg @ref{ATOMIC_XOR}
2081 1.1 mrg @end table
2082 1.1 mrg
2083 1.1 mrg
2084 1.1 mrg
2085 1.1 mrg @node ATOMIC_FETCH_ADD
2086 1.1 mrg @section @code{ATOMIC_FETCH_ADD} --- Atomic ADD operation with prior fetch
2087 1.1 mrg @fnindex ATOMIC_FETCH_ADD
2088 1.1 mrg @cindex Atomic subroutine, ADD with fetch
2089 1.1 mrg
2090 1.1 mrg @table @asis
2091 1.1 mrg @item @emph{Description}:
2092 1.1 mrg @code{ATOMIC_FETCH_ADD(ATOM, VALUE, OLD)} atomically stores the value of
2093 1.1 mrg @var{ATOM} in @var{OLD} and adds the value of @var{VAR} to the
2094 1.1 mrg variable @var{ATOM}. When @var{STAT} is present and the invocation was
2095 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation
2096 1.1 mrg has failed, it is assigned a positive value; in particular, for a coindexed
2097 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of
2098 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2099 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}.
2100 1.1 mrg
2101 1.1 mrg @item @emph{Standard}:
2102 1.1 mrg TS 18508 or later
2103 1.1 mrg
2104 1.1 mrg @item @emph{Class}:
2105 1.1 mrg Atomic subroutine
2106 1.1 mrg
2107 1.1 mrg @item @emph{Syntax}:
2108 1.1 mrg @code{CALL ATOMIC_FETCH_ADD (ATOM, VALUE, old [, STAT])}
2109 1.1 mrg
2110 1.1 mrg @item @emph{Arguments}:
2111 1.1 mrg @multitable @columnfractions .15 .70
2112 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2113 1.1 mrg type with @code{ATOMIC_INT_KIND} kind.
2114 1.1 mrg @code{ATOMIC_LOGICAL_KIND} kind.
2115 1.1 mrg
2116 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2117 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
2118 1.1 mrg @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2119 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2120 1.1 mrg @end multitable
2121 1.1 mrg
2122 1.1 mrg @item @emph{Example}:
2123 1.1 mrg @smallexample
2124 1.1 mrg program atomic
2125 1.1 mrg use iso_fortran_env
2126 1.1 mrg integer(atomic_int_kind) :: atom[*], old
2127 1.1 mrg call atomic_add (atom[1], this_image(), old)
2128 1.1 mrg end program atomic
2129 1.1 mrg @end smallexample
2130 1.1 mrg
2131 1.1 mrg @item @emph{See also}:
2132 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol
2133 1.1.1.2 mrg @ref{ATOMIC_ADD}, @gol
2134 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol
2135 1.1.1.2 mrg @ref{ATOMIC_FETCH_AND}, @gol
2136 1.1.1.2 mrg @ref{ATOMIC_FETCH_OR}, @gol
2137 1.1.1.2 mrg @ref{ATOMIC_FETCH_XOR}
2138 1.1 mrg @end table
2139 1.1 mrg
2140 1.1 mrg
2141 1.1 mrg
2142 1.1 mrg @node ATOMIC_FETCH_AND
2143 1.1 mrg @section @code{ATOMIC_FETCH_AND} --- Atomic bitwise AND operation with prior fetch
2144 1.1 mrg @fnindex ATOMIC_FETCH_AND
2145 1.1 mrg @cindex Atomic subroutine, AND with fetch
2146 1.1 mrg
2147 1.1 mrg @table @asis
2148 1.1 mrg @item @emph{Description}:
2149 1.1 mrg @code{ATOMIC_AND(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
2150 1.1 mrg @var{OLD} and defines @var{ATOM} with the bitwise AND between the values of
2151 1.1 mrg @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was
2152 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation has
2153 1.1 mrg failed, it is assigned a positive value; in particular, for a coindexed
2154 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of
2155 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2156 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}.
2157 1.1 mrg
2158 1.1 mrg @item @emph{Standard}:
2159 1.1 mrg TS 18508 or later
2160 1.1 mrg
2161 1.1 mrg @item @emph{Class}:
2162 1.1 mrg Atomic subroutine
2163 1.1 mrg
2164 1.1 mrg @item @emph{Syntax}:
2165 1.1 mrg @code{CALL ATOMIC_FETCH_AND (ATOM, VALUE, OLD [, STAT])}
2166 1.1 mrg
2167 1.1 mrg @item @emph{Arguments}:
2168 1.1 mrg @multitable @columnfractions .15 .70
2169 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2170 1.1 mrg type with @code{ATOMIC_INT_KIND} kind.
2171 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2172 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
2173 1.1 mrg @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2174 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2175 1.1 mrg @end multitable
2176 1.1 mrg
2177 1.1 mrg @item @emph{Example}:
2178 1.1 mrg @smallexample
2179 1.1 mrg program atomic
2180 1.1 mrg use iso_fortran_env
2181 1.1 mrg integer(atomic_int_kind) :: atom[*], old
2182 1.1 mrg call atomic_fetch_and (atom[1], int(b'10100011101'), old)
2183 1.1 mrg end program atomic
2184 1.1 mrg @end smallexample
2185 1.1 mrg
2186 1.1 mrg @item @emph{See also}:
2187 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol
2188 1.1.1.2 mrg @ref{ATOMIC_AND}, @gol
2189 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol
2190 1.1.1.2 mrg @ref{ATOMIC_FETCH_ADD}, @gol
2191 1.1.1.2 mrg @ref{ATOMIC_FETCH_OR}, @gol
2192 1.1.1.2 mrg @ref{ATOMIC_FETCH_XOR}
2193 1.1 mrg @end table
2194 1.1 mrg
2195 1.1 mrg
2196 1.1 mrg
2197 1.1 mrg @node ATOMIC_FETCH_OR
2198 1.1 mrg @section @code{ATOMIC_FETCH_OR} --- Atomic bitwise OR operation with prior fetch
2199 1.1 mrg @fnindex ATOMIC_FETCH_OR
2200 1.1 mrg @cindex Atomic subroutine, OR with fetch
2201 1.1 mrg
2202 1.1 mrg @table @asis
2203 1.1 mrg @item @emph{Description}:
2204 1.1 mrg @code{ATOMIC_OR(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
2205 1.1 mrg @var{OLD} and defines @var{ATOM} with the bitwise OR between the values of
2206 1.1 mrg @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was
2207 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation has
2208 1.1 mrg failed, it is assigned a positive value; in particular, for a coindexed
2209 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of
2210 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2211 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}.
2212 1.1 mrg
2213 1.1 mrg @item @emph{Standard}:
2214 1.1 mrg TS 18508 or later
2215 1.1 mrg
2216 1.1 mrg @item @emph{Class}:
2217 1.1 mrg Atomic subroutine
2218 1.1 mrg
2219 1.1 mrg @item @emph{Syntax}:
2220 1.1 mrg @code{CALL ATOMIC_FETCH_OR (ATOM, VALUE, OLD [, STAT])}
2221 1.1 mrg
2222 1.1 mrg @item @emph{Arguments}:
2223 1.1 mrg @multitable @columnfractions .15 .70
2224 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2225 1.1 mrg type with @code{ATOMIC_INT_KIND} kind.
2226 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2227 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
2228 1.1 mrg @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2229 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2230 1.1 mrg @end multitable
2231 1.1 mrg
2232 1.1 mrg @item @emph{Example}:
2233 1.1 mrg @smallexample
2234 1.1 mrg program atomic
2235 1.1 mrg use iso_fortran_env
2236 1.1 mrg integer(atomic_int_kind) :: atom[*], old
2237 1.1 mrg call atomic_fetch_or (atom[1], int(b'10100011101'), old)
2238 1.1 mrg end program atomic
2239 1.1 mrg @end smallexample
2240 1.1 mrg
2241 1.1 mrg @item @emph{See also}:
2242 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol
2243 1.1.1.2 mrg @ref{ATOMIC_OR}, @gol
2244 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol
2245 1.1.1.2 mrg @ref{ATOMIC_FETCH_ADD}, @gol
2246 1.1.1.2 mrg @ref{ATOMIC_FETCH_AND}, @gol
2247 1.1.1.2 mrg @ref{ATOMIC_FETCH_XOR}
2248 1.1 mrg @end table
2249 1.1 mrg
2250 1.1 mrg
2251 1.1 mrg
2252 1.1 mrg @node ATOMIC_FETCH_XOR
2253 1.1 mrg @section @code{ATOMIC_FETCH_XOR} --- Atomic bitwise XOR operation with prior fetch
2254 1.1 mrg @fnindex ATOMIC_FETCH_XOR
2255 1.1 mrg @cindex Atomic subroutine, XOR with fetch
2256 1.1 mrg
2257 1.1 mrg @table @asis
2258 1.1 mrg @item @emph{Description}:
2259 1.1 mrg @code{ATOMIC_XOR(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
2260 1.1 mrg @var{OLD} and defines @var{ATOM} with the bitwise XOR between the values of
2261 1.1 mrg @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was
2262 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation has
2263 1.1 mrg failed, it is assigned a positive value; in particular, for a coindexed
2264 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of
2265 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2266 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}.
2267 1.1 mrg
2268 1.1 mrg @item @emph{Standard}:
2269 1.1 mrg TS 18508 or later
2270 1.1 mrg
2271 1.1 mrg @item @emph{Class}:
2272 1.1 mrg Atomic subroutine
2273 1.1 mrg
2274 1.1 mrg @item @emph{Syntax}:
2275 1.1 mrg @code{CALL ATOMIC_FETCH_XOR (ATOM, VALUE, OLD [, STAT])}
2276 1.1 mrg
2277 1.1 mrg @item @emph{Arguments}:
2278 1.1 mrg @multitable @columnfractions .15 .70
2279 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2280 1.1 mrg type with @code{ATOMIC_INT_KIND} kind.
2281 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2282 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
2283 1.1 mrg @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2284 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2285 1.1 mrg @end multitable
2286 1.1 mrg
2287 1.1 mrg @item @emph{Example}:
2288 1.1 mrg @smallexample
2289 1.1 mrg program atomic
2290 1.1 mrg use iso_fortran_env
2291 1.1 mrg integer(atomic_int_kind) :: atom[*], old
2292 1.1 mrg call atomic_fetch_xor (atom[1], int(b'10100011101'), old)
2293 1.1 mrg end program atomic
2294 1.1 mrg @end smallexample
2295 1.1 mrg
2296 1.1 mrg @item @emph{See also}:
2297 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol
2298 1.1.1.2 mrg @ref{ATOMIC_XOR}, @gol
2299 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol
2300 1.1.1.2 mrg @ref{ATOMIC_FETCH_ADD}, @gol
2301 1.1.1.2 mrg @ref{ATOMIC_FETCH_AND}, @gol
2302 1.1.1.2 mrg @ref{ATOMIC_FETCH_OR}
2303 1.1 mrg @end table
2304 1.1 mrg
2305 1.1 mrg
2306 1.1 mrg
2307 1.1 mrg @node ATOMIC_OR
2308 1.1 mrg @section @code{ATOMIC_OR} --- Atomic bitwise OR operation
2309 1.1 mrg @fnindex ATOMIC_OR
2310 1.1 mrg @cindex Atomic subroutine, OR
2311 1.1 mrg
2312 1.1 mrg @table @asis
2313 1.1 mrg @item @emph{Description}:
2314 1.1 mrg @code{ATOMIC_OR(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
2315 1.1 mrg AND between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
2316 1.1 mrg and the invocation was successful, it is assigned the value 0. If it is present
2317 1.1 mrg and the invocation has failed, it is assigned a positive value; in particular,
2318 1.1 mrg for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
2319 1.1 mrg value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
2320 1.1 mrg image has failed, the value @code{STAT_FAILED_IMAGE}.
2321 1.1 mrg
2322 1.1 mrg @item @emph{Standard}:
2323 1.1 mrg TS 18508 or later
2324 1.1 mrg
2325 1.1 mrg @item @emph{Class}:
2326 1.1 mrg Atomic subroutine
2327 1.1 mrg
2328 1.1 mrg @item @emph{Syntax}:
2329 1.1 mrg @code{CALL ATOMIC_OR (ATOM, VALUE [, STAT])}
2330 1.1 mrg
2331 1.1 mrg @item @emph{Arguments}:
2332 1.1 mrg @multitable @columnfractions .15 .70
2333 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2334 1.1 mrg type with @code{ATOMIC_INT_KIND} kind.
2335 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2336 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
2337 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2338 1.1 mrg @end multitable
2339 1.1 mrg
2340 1.1 mrg @item @emph{Example}:
2341 1.1 mrg @smallexample
2342 1.1 mrg program atomic
2343 1.1 mrg use iso_fortran_env
2344 1.1 mrg integer(atomic_int_kind) :: atom[*]
2345 1.1 mrg call atomic_or (atom[1], int(b'10100011101'))
2346 1.1 mrg end program atomic
2347 1.1 mrg @end smallexample
2348 1.1 mrg
2349 1.1 mrg @item @emph{See also}:
2350 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol
2351 1.1.1.2 mrg @ref{ATOMIC_FETCH_OR}, @gol
2352 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol
2353 1.1.1.2 mrg @ref{ATOMIC_ADD}, @gol
2354 1.1.1.2 mrg @ref{ATOMIC_OR}, @gol
2355 1.1.1.2 mrg @ref{ATOMIC_XOR}
2356 1.1 mrg @end table
2357 1.1 mrg
2358 1.1 mrg
2359 1.1 mrg
2360 1.1 mrg @node ATOMIC_REF
2361 1.1 mrg @section @code{ATOMIC_REF} --- Obtaining the value of a variable atomically
2362 1.1 mrg @fnindex ATOMIC_REF
2363 1.1 mrg @cindex Atomic subroutine, reference
2364 1.1 mrg
2365 1.1 mrg @table @asis
2366 1.1 mrg @item @emph{Description}:
2367 1.1 mrg @code{ATOMIC_DEFINE(ATOM, VALUE)} atomically assigns the value of the
2368 1.1 mrg variable @var{ATOM} to @var{VALUE}. When @var{STAT} is present and the
2369 1.1 mrg invocation was successful, it is assigned the value 0. If it is present and the
2370 1.1 mrg invocation has failed, it is assigned a positive value; in particular, for a
2371 1.1 mrg coindexed @var{ATOM}, if the remote image has stopped, it is assigned the value
2372 1.1 mrg of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image
2373 1.1 mrg has failed, the value @code{STAT_FAILED_IMAGE}.
2374 1.1 mrg
2375 1.1 mrg
2376 1.1 mrg @item @emph{Standard}:
2377 1.1 mrg Fortran 2008 and later; with @var{STAT}, TS 18508 or later
2378 1.1 mrg
2379 1.1 mrg @item @emph{Class}:
2380 1.1 mrg Atomic subroutine
2381 1.1 mrg
2382 1.1 mrg @item @emph{Syntax}:
2383 1.1 mrg @code{CALL ATOMIC_REF(VALUE, ATOM [, STAT])}
2384 1.1 mrg
2385 1.1 mrg @item @emph{Arguments}:
2386 1.1 mrg @multitable @columnfractions .15 .70
2387 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2388 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
2389 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer
2390 1.1 mrg type with @code{ATOMIC_INT_KIND} kind or logical type with
2391 1.1 mrg @code{ATOMIC_LOGICAL_KIND} kind.
2392 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2393 1.1 mrg @end multitable
2394 1.1 mrg
2395 1.1 mrg @item @emph{Example}:
2396 1.1 mrg @smallexample
2397 1.1 mrg program atomic
2398 1.1 mrg use iso_fortran_env
2399 1.1 mrg logical(atomic_logical_kind) :: atom[*]
2400 1.1 mrg logical :: val
2401 1.1 mrg call atomic_ref (atom, .false.)
2402 1.1 mrg ! ...
2403 1.1 mrg call atomic_ref (atom, val)
2404 1.1 mrg if (val) then
2405 1.1 mrg print *, "Obtained"
2406 1.1 mrg end if
2407 1.1 mrg end program atomic
2408 1.1 mrg @end smallexample
2409 1.1 mrg
2410 1.1 mrg @item @emph{See also}:
2411 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol
2412 1.1.1.2 mrg @ref{ATOMIC_CAS}, @gol
2413 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol
2414 1.1.1.2 mrg @ref{ATOMIC_FETCH_ADD}, @gol
2415 1.1.1.2 mrg @ref{ATOMIC_FETCH_AND}, @gol
2416 1.1.1.2 mrg @ref{ATOMIC_FETCH_OR}, @gol
2417 1.1 mrg @ref{ATOMIC_FETCH_XOR}
2418 1.1 mrg @end table
2419 1.1 mrg
2420 1.1 mrg
2421 1.1 mrg @node ATOMIC_XOR
2422 1.1 mrg @section @code{ATOMIC_XOR} --- Atomic bitwise OR operation
2423 1.1 mrg @fnindex ATOMIC_XOR
2424 1.1 mrg @cindex Atomic subroutine, XOR
2425 1.1 mrg
2426 1.1 mrg @table @asis
2427 1.1 mrg @item @emph{Description}:
2428 1.1 mrg @code{ATOMIC_AND(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
2429 1.1 mrg XOR between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
2430 1.1 mrg and the invocation was successful, it is assigned the value 0. If it is present
2431 1.1 mrg and the invocation has failed, it is assigned a positive value; in particular,
2432 1.1 mrg for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
2433 1.1 mrg value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
2434 1.1 mrg image has failed, the value @code{STAT_FAILED_IMAGE}.
2435 1.1 mrg
2436 1.1 mrg @item @emph{Standard}:
2437 1.1 mrg TS 18508 or later
2438 1.1 mrg
2439 1.1 mrg @item @emph{Class}:
2440 1.1 mrg Atomic subroutine
2441 1.1 mrg
2442 1.1 mrg @item @emph{Syntax}:
2443 1.1 mrg @code{CALL ATOMIC_XOR (ATOM, VALUE [, STAT])}
2444 1.1 mrg
2445 1.1 mrg @item @emph{Arguments}:
2446 1.1 mrg @multitable @columnfractions .15 .70
2447 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2448 1.1 mrg type with @code{ATOMIC_INT_KIND} kind.
2449 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2450 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
2451 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2452 1.1 mrg @end multitable
2453 1.1 mrg
2454 1.1 mrg @item @emph{Example}:
2455 1.1 mrg @smallexample
2456 1.1 mrg program atomic
2457 1.1 mrg use iso_fortran_env
2458 1.1 mrg integer(atomic_int_kind) :: atom[*]
2459 1.1 mrg call atomic_xor (atom[1], int(b'10100011101'))
2460 1.1 mrg end program atomic
2461 1.1 mrg @end smallexample
2462 1.1 mrg
2463 1.1 mrg @item @emph{See also}:
2464 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol
2465 1.1.1.2 mrg @ref{ATOMIC_FETCH_XOR}, @gol
2466 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol
2467 1.1.1.2 mrg @ref{ATOMIC_ADD}, @gol
2468 1.1.1.2 mrg @ref{ATOMIC_OR}, @gol
2469 1.1.1.2 mrg @ref{ATOMIC_XOR}
2470 1.1 mrg @end table
2471 1.1 mrg
2472 1.1 mrg
2473 1.1 mrg @node BACKTRACE
2474 1.1 mrg @section @code{BACKTRACE} --- Show a backtrace
2475 1.1 mrg @fnindex BACKTRACE
2476 1.1 mrg @cindex backtrace
2477 1.1 mrg
2478 1.1 mrg @table @asis
2479 1.1 mrg @item @emph{Description}:
2480 1.1 mrg @code{BACKTRACE} shows a backtrace at an arbitrary place in user code. Program
2481 1.1 mrg execution continues normally afterwards. The backtrace information is printed
2482 1.1 mrg to the unit corresponding to @code{ERROR_UNIT} in @code{ISO_FORTRAN_ENV}.
2483 1.1 mrg
2484 1.1 mrg @item @emph{Standard}:
2485 1.1.1.2 mrg GNU extension
2486 1.1 mrg
2487 1.1 mrg @item @emph{Class}:
2488 1.1 mrg Subroutine
2489 1.1 mrg
2490 1.1 mrg @item @emph{Syntax}:
2491 1.1 mrg @code{CALL BACKTRACE}
2492 1.1 mrg
2493 1.1 mrg @item @emph{Arguments}:
2494 1.1 mrg None
2495 1.1 mrg
2496 1.1 mrg @item @emph{See also}:
2497 1.1 mrg @ref{ABORT}
2498 1.1 mrg @end table
2499 1.1 mrg
2500 1.1 mrg
2501 1.1 mrg
2502 1.1 mrg @node BESSEL_J0
2503 1.1 mrg @section @code{BESSEL_J0} --- Bessel function of the first kind of order 0
2504 1.1 mrg @fnindex BESSEL_J0
2505 1.1 mrg @fnindex BESJ0
2506 1.1 mrg @fnindex DBESJ0
2507 1.1 mrg @cindex Bessel function, first kind
2508 1.1 mrg
2509 1.1 mrg @table @asis
2510 1.1 mrg @item @emph{Description}:
2511 1.1 mrg @code{BESSEL_J0(X)} computes the Bessel function of the first kind of
2512 1.1 mrg order 0 of @var{X}. This function is available under the name
2513 1.1 mrg @code{BESJ0} as a GNU extension.
2514 1.1 mrg
2515 1.1 mrg @item @emph{Standard}:
2516 1.1 mrg Fortran 2008 and later
2517 1.1 mrg
2518 1.1 mrg @item @emph{Class}:
2519 1.1 mrg Elemental function
2520 1.1 mrg
2521 1.1 mrg @item @emph{Syntax}:
2522 1.1 mrg @code{RESULT = BESSEL_J0(X)}
2523 1.1 mrg
2524 1.1 mrg @item @emph{Arguments}:
2525 1.1 mrg @multitable @columnfractions .15 .70
2526 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
2527 1.1 mrg @end multitable
2528 1.1 mrg
2529 1.1 mrg @item @emph{Return value}:
2530 1.1 mrg The return value is of type @code{REAL} and lies in the
2531 1.1 mrg range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}. It has the same
2532 1.1 mrg kind as @var{X}.
2533 1.1 mrg
2534 1.1 mrg @item @emph{Example}:
2535 1.1 mrg @smallexample
2536 1.1 mrg program test_besj0
2537 1.1 mrg real(8) :: x = 0.0_8
2538 1.1 mrg x = bessel_j0(x)
2539 1.1 mrg end program test_besj0
2540 1.1 mrg @end smallexample
2541 1.1 mrg
2542 1.1 mrg @item @emph{Specific names}:
2543 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
2544 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
2545 1.1 mrg @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2546 1.1 mrg @end multitable
2547 1.1 mrg @end table
2548 1.1 mrg
2549 1.1 mrg
2550 1.1 mrg
2551 1.1 mrg @node BESSEL_J1
2552 1.1 mrg @section @code{BESSEL_J1} --- Bessel function of the first kind of order 1
2553 1.1 mrg @fnindex BESSEL_J1
2554 1.1 mrg @fnindex BESJ1
2555 1.1 mrg @fnindex DBESJ1
2556 1.1 mrg @cindex Bessel function, first kind
2557 1.1 mrg
2558 1.1 mrg @table @asis
2559 1.1 mrg @item @emph{Description}:
2560 1.1 mrg @code{BESSEL_J1(X)} computes the Bessel function of the first kind of
2561 1.1 mrg order 1 of @var{X}. This function is available under the name
2562 1.1 mrg @code{BESJ1} as a GNU extension.
2563 1.1 mrg
2564 1.1 mrg @item @emph{Standard}:
2565 1.1 mrg Fortran 2008
2566 1.1 mrg
2567 1.1 mrg @item @emph{Class}:
2568 1.1 mrg Elemental function
2569 1.1 mrg
2570 1.1 mrg @item @emph{Syntax}:
2571 1.1 mrg @code{RESULT = BESSEL_J1(X)}
2572 1.1 mrg
2573 1.1 mrg @item @emph{Arguments}:
2574 1.1 mrg @multitable @columnfractions .15 .70
2575 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
2576 1.1 mrg @end multitable
2577 1.1 mrg
2578 1.1 mrg @item @emph{Return value}:
2579 1.1 mrg The return value is of type @code{REAL} and lies in the
2580 1.1 mrg range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }. It has the same
2581 1.1 mrg kind as @var{X}.
2582 1.1 mrg
2583 1.1 mrg @item @emph{Example}:
2584 1.1 mrg @smallexample
2585 1.1 mrg program test_besj1
2586 1.1 mrg real(8) :: x = 1.0_8
2587 1.1 mrg x = bessel_j1(x)
2588 1.1 mrg end program test_besj1
2589 1.1 mrg @end smallexample
2590 1.1 mrg
2591 1.1 mrg @item @emph{Specific names}:
2592 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
2593 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
2594 1.1 mrg @item @code{DBESJ1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2595 1.1 mrg @end multitable
2596 1.1 mrg @end table
2597 1.1 mrg
2598 1.1 mrg
2599 1.1 mrg
2600 1.1 mrg @node BESSEL_JN
2601 1.1 mrg @section @code{BESSEL_JN} --- Bessel function of the first kind
2602 1.1 mrg @fnindex BESSEL_JN
2603 1.1 mrg @fnindex BESJN
2604 1.1 mrg @fnindex DBESJN
2605 1.1 mrg @cindex Bessel function, first kind
2606 1.1 mrg
2607 1.1 mrg @table @asis
2608 1.1 mrg @item @emph{Description}:
2609 1.1 mrg @code{BESSEL_JN(N, X)} computes the Bessel function of the first kind of
2610 1.1 mrg order @var{N} of @var{X}. This function is available under the name
2611 1.1 mrg @code{BESJN} as a GNU extension. If @var{N} and @var{X} are arrays,
2612 1.1 mrg their ranks and shapes shall conform.
2613 1.1 mrg
2614 1.1 mrg @code{BESSEL_JN(N1, N2, X)} returns an array with the Bessel functions
2615 1.1 mrg of the first kind of the orders @var{N1} to @var{N2}.
2616 1.1 mrg
2617 1.1 mrg @item @emph{Standard}:
2618 1.1 mrg Fortran 2008 and later, negative @var{N} is allowed as GNU extension
2619 1.1 mrg
2620 1.1 mrg @item @emph{Class}:
2621 1.1 mrg Elemental function, except for the transformational function
2622 1.1 mrg @code{BESSEL_JN(N1, N2, X)}
2623 1.1 mrg
2624 1.1 mrg @item @emph{Syntax}:
2625 1.1 mrg @multitable @columnfractions .80
2626 1.1 mrg @item @code{RESULT = BESSEL_JN(N, X)}
2627 1.1 mrg @item @code{RESULT = BESSEL_JN(N1, N2, X)}
2628 1.1 mrg @end multitable
2629 1.1 mrg
2630 1.1 mrg @item @emph{Arguments}:
2631 1.1 mrg @multitable @columnfractions .15 .70
2632 1.1 mrg @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER}.
2633 1.1 mrg @item @var{N1} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2634 1.1 mrg @item @var{N2} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2635 1.1 mrg @item @var{X} @tab Shall be a scalar or an array of type @code{REAL};
2636 1.1 mrg for @code{BESSEL_JN(N1, N2, X)} it shall be scalar.
2637 1.1 mrg @end multitable
2638 1.1 mrg
2639 1.1 mrg @item @emph{Return value}:
2640 1.1 mrg The return value is a scalar of type @code{REAL}. It has the same
2641 1.1 mrg kind as @var{X}.
2642 1.1 mrg
2643 1.1 mrg @item @emph{Note}:
2644 1.1 mrg The transformational function uses a recurrence algorithm which might,
2645 1.1 mrg for some values of @var{X}, lead to different results than calls to
2646 1.1 mrg the elemental function.
2647 1.1 mrg
2648 1.1 mrg @item @emph{Example}:
2649 1.1 mrg @smallexample
2650 1.1 mrg program test_besjn
2651 1.1 mrg real(8) :: x = 1.0_8
2652 1.1 mrg x = bessel_jn(5,x)
2653 1.1 mrg end program test_besjn
2654 1.1 mrg @end smallexample
2655 1.1 mrg
2656 1.1 mrg @item @emph{Specific names}:
2657 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
2658 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
2659 1.1 mrg @item @code{DBESJN(N, X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension
2660 1.1 mrg @item @tab @code{REAL(8) X} @tab @tab
2661 1.1 mrg @end multitable
2662 1.1 mrg @end table
2663 1.1 mrg
2664 1.1 mrg
2665 1.1 mrg
2666 1.1 mrg @node BESSEL_Y0
2667 1.1 mrg @section @code{BESSEL_Y0} --- Bessel function of the second kind of order 0
2668 1.1 mrg @fnindex BESSEL_Y0
2669 1.1 mrg @fnindex BESY0
2670 1.1 mrg @fnindex DBESY0
2671 1.1 mrg @cindex Bessel function, second kind
2672 1.1 mrg
2673 1.1 mrg @table @asis
2674 1.1 mrg @item @emph{Description}:
2675 1.1 mrg @code{BESSEL_Y0(X)} computes the Bessel function of the second kind of
2676 1.1 mrg order 0 of @var{X}. This function is available under the name
2677 1.1 mrg @code{BESY0} as a GNU extension.
2678 1.1 mrg
2679 1.1 mrg @item @emph{Standard}:
2680 1.1 mrg Fortran 2008 and later
2681 1.1 mrg
2682 1.1 mrg @item @emph{Class}:
2683 1.1 mrg Elemental function
2684 1.1 mrg
2685 1.1 mrg @item @emph{Syntax}:
2686 1.1 mrg @code{RESULT = BESSEL_Y0(X)}
2687 1.1 mrg
2688 1.1 mrg @item @emph{Arguments}:
2689 1.1 mrg @multitable @columnfractions .15 .70
2690 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
2691 1.1 mrg @end multitable
2692 1.1 mrg
2693 1.1 mrg @item @emph{Return value}:
2694 1.1 mrg The return value is of type @code{REAL}. It has the same kind as @var{X}.
2695 1.1 mrg
2696 1.1 mrg @item @emph{Example}:
2697 1.1 mrg @smallexample
2698 1.1 mrg program test_besy0
2699 1.1 mrg real(8) :: x = 0.0_8
2700 1.1 mrg x = bessel_y0(x)
2701 1.1 mrg end program test_besy0
2702 1.1 mrg @end smallexample
2703 1.1 mrg
2704 1.1 mrg @item @emph{Specific names}:
2705 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
2706 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
2707 1.1 mrg @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2708 1.1 mrg @end multitable
2709 1.1 mrg @end table
2710 1.1 mrg
2711 1.1 mrg
2712 1.1 mrg
2713 1.1 mrg @node BESSEL_Y1
2714 1.1 mrg @section @code{BESSEL_Y1} --- Bessel function of the second kind of order 1
2715 1.1 mrg @fnindex BESSEL_Y1
2716 1.1 mrg @fnindex BESY1
2717 1.1 mrg @fnindex DBESY1
2718 1.1 mrg @cindex Bessel function, second kind
2719 1.1 mrg
2720 1.1 mrg @table @asis
2721 1.1 mrg @item @emph{Description}:
2722 1.1 mrg @code{BESSEL_Y1(X)} computes the Bessel function of the second kind of
2723 1.1 mrg order 1 of @var{X}. This function is available under the name
2724 1.1 mrg @code{BESY1} as a GNU extension.
2725 1.1 mrg
2726 1.1 mrg @item @emph{Standard}:
2727 1.1 mrg Fortran 2008 and later
2728 1.1 mrg
2729 1.1 mrg @item @emph{Class}:
2730 1.1 mrg Elemental function
2731 1.1 mrg
2732 1.1 mrg @item @emph{Syntax}:
2733 1.1 mrg @code{RESULT = BESSEL_Y1(X)}
2734 1.1 mrg
2735 1.1 mrg @item @emph{Arguments}:
2736 1.1 mrg @multitable @columnfractions .15 .70
2737 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
2738 1.1 mrg @end multitable
2739 1.1 mrg
2740 1.1 mrg @item @emph{Return value}:
2741 1.1 mrg The return value is of type @code{REAL}. It has the same kind as @var{X}.
2742 1.1 mrg
2743 1.1 mrg @item @emph{Example}:
2744 1.1 mrg @smallexample
2745 1.1 mrg program test_besy1
2746 1.1 mrg real(8) :: x = 1.0_8
2747 1.1 mrg x = bessel_y1(x)
2748 1.1 mrg end program test_besy1
2749 1.1 mrg @end smallexample
2750 1.1 mrg
2751 1.1 mrg @item @emph{Specific names}:
2752 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
2753 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
2754 1.1 mrg @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2755 1.1 mrg @end multitable
2756 1.1 mrg @end table
2757 1.1 mrg
2758 1.1 mrg
2759 1.1 mrg
2760 1.1 mrg @node BESSEL_YN
2761 1.1 mrg @section @code{BESSEL_YN} --- Bessel function of the second kind
2762 1.1 mrg @fnindex BESSEL_YN
2763 1.1 mrg @fnindex BESYN
2764 1.1 mrg @fnindex DBESYN
2765 1.1 mrg @cindex Bessel function, second kind
2766 1.1 mrg
2767 1.1 mrg @table @asis
2768 1.1 mrg @item @emph{Description}:
2769 1.1 mrg @code{BESSEL_YN(N, X)} computes the Bessel function of the second kind of
2770 1.1 mrg order @var{N} of @var{X}. This function is available under the name
2771 1.1 mrg @code{BESYN} as a GNU extension. If @var{N} and @var{X} are arrays,
2772 1.1 mrg their ranks and shapes shall conform.
2773 1.1 mrg
2774 1.1 mrg @code{BESSEL_YN(N1, N2, X)} returns an array with the Bessel functions
2775 1.1 mrg of the first kind of the orders @var{N1} to @var{N2}.
2776 1.1 mrg
2777 1.1 mrg @item @emph{Standard}:
2778 1.1 mrg Fortran 2008 and later, negative @var{N} is allowed as GNU extension
2779 1.1 mrg
2780 1.1 mrg @item @emph{Class}:
2781 1.1 mrg Elemental function, except for the transformational function
2782 1.1 mrg @code{BESSEL_YN(N1, N2, X)}
2783 1.1 mrg
2784 1.1 mrg @item @emph{Syntax}:
2785 1.1 mrg @multitable @columnfractions .80
2786 1.1 mrg @item @code{RESULT = BESSEL_YN(N, X)}
2787 1.1 mrg @item @code{RESULT = BESSEL_YN(N1, N2, X)}
2788 1.1 mrg @end multitable
2789 1.1 mrg
2790 1.1 mrg @item @emph{Arguments}:
2791 1.1 mrg @multitable @columnfractions .15 .70
2792 1.1 mrg @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER} .
2793 1.1 mrg @item @var{N1} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2794 1.1 mrg @item @var{N2} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2795 1.1 mrg @item @var{X} @tab Shall be a scalar or an array of type @code{REAL};
2796 1.1 mrg for @code{BESSEL_YN(N1, N2, X)} it shall be scalar.
2797 1.1 mrg @end multitable
2798 1.1 mrg
2799 1.1 mrg @item @emph{Return value}:
2800 1.1 mrg The return value is a scalar of type @code{REAL}. It has the same
2801 1.1 mrg kind as @var{X}.
2802 1.1 mrg
2803 1.1 mrg @item @emph{Note}:
2804 1.1 mrg The transformational function uses a recurrence algorithm which might,
2805 1.1 mrg for some values of @var{X}, lead to different results than calls to
2806 1.1 mrg the elemental function.
2807 1.1 mrg
2808 1.1 mrg @item @emph{Example}:
2809 1.1 mrg @smallexample
2810 1.1 mrg program test_besyn
2811 1.1 mrg real(8) :: x = 1.0_8
2812 1.1 mrg x = bessel_yn(5,x)
2813 1.1 mrg end program test_besyn
2814 1.1 mrg @end smallexample
2815 1.1 mrg
2816 1.1 mrg @item @emph{Specific names}:
2817 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
2818 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
2819 1.1 mrg @item @code{DBESYN(N,X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension
2820 1.1 mrg @item @tab @code{REAL(8) X} @tab @tab
2821 1.1 mrg @end multitable
2822 1.1 mrg @end table
2823 1.1 mrg
2824 1.1 mrg
2825 1.1 mrg
2826 1.1 mrg @node BGE
2827 1.1 mrg @section @code{BGE} --- Bitwise greater than or equal to
2828 1.1 mrg @fnindex BGE
2829 1.1 mrg @cindex bitwise comparison
2830 1.1 mrg
2831 1.1 mrg @table @asis
2832 1.1 mrg @item @emph{Description}:
2833 1.1 mrg Determines whether an integral is a bitwise greater than or equal to
2834 1.1 mrg another.
2835 1.1 mrg
2836 1.1 mrg @item @emph{Standard}:
2837 1.1 mrg Fortran 2008 and later
2838 1.1 mrg
2839 1.1 mrg @item @emph{Class}:
2840 1.1 mrg Elemental function
2841 1.1 mrg
2842 1.1 mrg @item @emph{Syntax}:
2843 1.1 mrg @code{RESULT = BGE(I, J)}
2844 1.1 mrg
2845 1.1 mrg @item @emph{Arguments}:
2846 1.1 mrg @multitable @columnfractions .15 .70
2847 1.1 mrg @item @var{I} @tab Shall be of @code{INTEGER} type.
2848 1.1 mrg @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2849 1.1 mrg as @var{I}.
2850 1.1 mrg @end multitable
2851 1.1 mrg
2852 1.1 mrg @item @emph{Return value}:
2853 1.1 mrg The return value is of type @code{LOGICAL} and of the default kind.
2854 1.1 mrg
2855 1.1 mrg @item @emph{See also}:
2856 1.1.1.2 mrg @ref{BGT}, @gol
2857 1.1.1.2 mrg @ref{BLE}, @gol
2858 1.1.1.2 mrg @ref{BLT}
2859 1.1 mrg @end table
2860 1.1 mrg
2861 1.1 mrg
2862 1.1 mrg
2863 1.1 mrg @node BGT
2864 1.1 mrg @section @code{BGT} --- Bitwise greater than
2865 1.1 mrg @fnindex BGT
2866 1.1 mrg @cindex bitwise comparison
2867 1.1 mrg
2868 1.1 mrg @table @asis
2869 1.1 mrg @item @emph{Description}:
2870 1.1 mrg Determines whether an integral is a bitwise greater than another.
2871 1.1 mrg
2872 1.1 mrg @item @emph{Standard}:
2873 1.1 mrg Fortran 2008 and later
2874 1.1 mrg
2875 1.1 mrg @item @emph{Class}:
2876 1.1 mrg Elemental function
2877 1.1 mrg
2878 1.1 mrg @item @emph{Syntax}:
2879 1.1 mrg @code{RESULT = BGT(I, J)}
2880 1.1 mrg
2881 1.1 mrg @item @emph{Arguments}:
2882 1.1 mrg @multitable @columnfractions .15 .70
2883 1.1 mrg @item @var{I} @tab Shall be of @code{INTEGER} type.
2884 1.1 mrg @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2885 1.1 mrg as @var{I}.
2886 1.1 mrg @end multitable
2887 1.1 mrg
2888 1.1 mrg @item @emph{Return value}:
2889 1.1 mrg The return value is of type @code{LOGICAL} and of the default kind.
2890 1.1 mrg
2891 1.1 mrg @item @emph{See also}:
2892 1.1.1.2 mrg @ref{BGE}, @gol
2893 1.1.1.2 mrg @ref{BLE}, @gol
2894 1.1.1.2 mrg @ref{BLT}
2895 1.1 mrg @end table
2896 1.1 mrg
2897 1.1 mrg
2898 1.1 mrg
2899 1.1 mrg @node BIT_SIZE
2900 1.1 mrg @section @code{BIT_SIZE} --- Bit size inquiry function
2901 1.1 mrg @fnindex BIT_SIZE
2902 1.1 mrg @cindex bits, number of
2903 1.1 mrg @cindex size of a variable, in bits
2904 1.1 mrg
2905 1.1 mrg @table @asis
2906 1.1 mrg @item @emph{Description}:
2907 1.1 mrg @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
2908 1.1 mrg represented by the type of @var{I}. The result of @code{BIT_SIZE(I)} is
2909 1.1 mrg independent of the actual value of @var{I}.
2910 1.1 mrg
2911 1.1 mrg @item @emph{Standard}:
2912 1.1.1.2 mrg Fortran 90 and later
2913 1.1 mrg
2914 1.1 mrg @item @emph{Class}:
2915 1.1 mrg Inquiry function
2916 1.1 mrg
2917 1.1 mrg @item @emph{Syntax}:
2918 1.1 mrg @code{RESULT = BIT_SIZE(I)}
2919 1.1 mrg
2920 1.1 mrg @item @emph{Arguments}:
2921 1.1 mrg @multitable @columnfractions .15 .70
2922 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
2923 1.1 mrg @end multitable
2924 1.1 mrg
2925 1.1 mrg @item @emph{Return value}:
2926 1.1 mrg The return value is of type @code{INTEGER}
2927 1.1 mrg
2928 1.1 mrg @item @emph{Example}:
2929 1.1 mrg @smallexample
2930 1.1 mrg program test_bit_size
2931 1.1 mrg integer :: i = 123
2932 1.1 mrg integer :: size
2933 1.1 mrg size = bit_size(i)
2934 1.1 mrg print *, size
2935 1.1 mrg end program test_bit_size
2936 1.1 mrg @end smallexample
2937 1.1 mrg @end table
2938 1.1 mrg
2939 1.1 mrg
2940 1.1 mrg
2941 1.1 mrg @node BLE
2942 1.1 mrg @section @code{BLE} --- Bitwise less than or equal to
2943 1.1 mrg @fnindex BLE
2944 1.1 mrg @cindex bitwise comparison
2945 1.1 mrg
2946 1.1 mrg @table @asis
2947 1.1 mrg @item @emph{Description}:
2948 1.1 mrg Determines whether an integral is a bitwise less than or equal to
2949 1.1 mrg another.
2950 1.1 mrg
2951 1.1 mrg @item @emph{Standard}:
2952 1.1 mrg Fortran 2008 and later
2953 1.1 mrg
2954 1.1 mrg @item @emph{Class}:
2955 1.1 mrg Elemental function
2956 1.1 mrg
2957 1.1 mrg @item @emph{Syntax}:
2958 1.1 mrg @code{RESULT = BLE(I, J)}
2959 1.1 mrg
2960 1.1 mrg @item @emph{Arguments}:
2961 1.1 mrg @multitable @columnfractions .15 .70
2962 1.1 mrg @item @var{I} @tab Shall be of @code{INTEGER} type.
2963 1.1 mrg @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2964 1.1 mrg as @var{I}.
2965 1.1 mrg @end multitable
2966 1.1 mrg
2967 1.1 mrg @item @emph{Return value}:
2968 1.1 mrg The return value is of type @code{LOGICAL} and of the default kind.
2969 1.1 mrg
2970 1.1 mrg @item @emph{See also}:
2971 1.1.1.2 mrg @ref{BGT}, @gol
2972 1.1.1.2 mrg @ref{BGE}, @gol
2973 1.1.1.2 mrg @ref{BLT}
2974 1.1 mrg @end table
2975 1.1 mrg
2976 1.1 mrg
2977 1.1 mrg
2978 1.1 mrg @node BLT
2979 1.1 mrg @section @code{BLT} --- Bitwise less than
2980 1.1 mrg @fnindex BLT
2981 1.1 mrg @cindex bitwise comparison
2982 1.1 mrg
2983 1.1 mrg @table @asis
2984 1.1 mrg @item @emph{Description}:
2985 1.1 mrg Determines whether an integral is a bitwise less than another.
2986 1.1 mrg
2987 1.1 mrg @item @emph{Standard}:
2988 1.1 mrg Fortran 2008 and later
2989 1.1 mrg
2990 1.1 mrg @item @emph{Class}:
2991 1.1 mrg Elemental function
2992 1.1 mrg
2993 1.1 mrg @item @emph{Syntax}:
2994 1.1 mrg @code{RESULT = BLT(I, J)}
2995 1.1 mrg
2996 1.1 mrg @item @emph{Arguments}:
2997 1.1 mrg @multitable @columnfractions .15 .70
2998 1.1 mrg @item @var{I} @tab Shall be of @code{INTEGER} type.
2999 1.1 mrg @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
3000 1.1 mrg as @var{I}.
3001 1.1 mrg @end multitable
3002 1.1 mrg
3003 1.1 mrg @item @emph{Return value}:
3004 1.1 mrg The return value is of type @code{LOGICAL} and of the default kind.
3005 1.1 mrg
3006 1.1 mrg @item @emph{See also}:
3007 1.1.1.2 mrg @ref{BGE}, @gol
3008 1.1.1.2 mrg @ref{BGT}, @gol
3009 1.1.1.2 mrg @ref{BLE}
3010 1.1 mrg @end table
3011 1.1 mrg
3012 1.1 mrg
3013 1.1 mrg
3014 1.1 mrg @node BTEST
3015 1.1 mrg @section @code{BTEST} --- Bit test function
3016 1.1 mrg @fnindex BTEST
3017 1.1 mrg @fnindex BBTEST
3018 1.1 mrg @fnindex BITEST
3019 1.1 mrg @fnindex BJTEST
3020 1.1 mrg @fnindex BKTEST
3021 1.1 mrg @cindex bits, testing
3022 1.1 mrg
3023 1.1 mrg @table @asis
3024 1.1 mrg @item @emph{Description}:
3025 1.1 mrg @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
3026 1.1 mrg in @var{I} is set. The counting of the bits starts at 0.
3027 1.1 mrg
3028 1.1 mrg @item @emph{Standard}:
3029 1.1.1.2 mrg Fortran 90 and later, has overloads that are GNU extensions
3030 1.1 mrg
3031 1.1 mrg @item @emph{Class}:
3032 1.1 mrg Elemental function
3033 1.1 mrg
3034 1.1 mrg @item @emph{Syntax}:
3035 1.1 mrg @code{RESULT = BTEST(I, POS)}
3036 1.1 mrg
3037 1.1 mrg @item @emph{Arguments}:
3038 1.1 mrg @multitable @columnfractions .15 .70
3039 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
3040 1.1 mrg @item @var{POS} @tab The type shall be @code{INTEGER}.
3041 1.1 mrg @end multitable
3042 1.1 mrg
3043 1.1 mrg @item @emph{Return value}:
3044 1.1 mrg The return value is of type @code{LOGICAL}
3045 1.1 mrg
3046 1.1 mrg @item @emph{Example}:
3047 1.1 mrg @smallexample
3048 1.1 mrg program test_btest
3049 1.1 mrg integer :: i = 32768 + 1024 + 64
3050 1.1 mrg integer :: pos
3051 1.1 mrg logical :: bool
3052 1.1 mrg do pos=0,16
3053 1.1 mrg bool = btest(i, pos)
3054 1.1 mrg print *, pos, bool
3055 1.1 mrg end do
3056 1.1 mrg end program test_btest
3057 1.1 mrg @end smallexample
3058 1.1 mrg
3059 1.1 mrg @item @emph{Specific names}:
3060 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
3061 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
3062 1.1.1.2 mrg @item @code{BTEST(I,POS)} @tab @code{INTEGER I,POS} @tab @code{LOGICAL} @tab Fortran 95 and later
3063 1.1 mrg @item @code{BBTEST(I,POS)} @tab @code{INTEGER(1) I,POS} @tab @code{LOGICAL(1)} @tab GNU extension
3064 1.1 mrg @item @code{BITEST(I,POS)} @tab @code{INTEGER(2) I,POS} @tab @code{LOGICAL(2)} @tab GNU extension
3065 1.1 mrg @item @code{BJTEST(I,POS)} @tab @code{INTEGER(4) I,POS} @tab @code{LOGICAL(4)} @tab GNU extension
3066 1.1 mrg @item @code{BKTEST(I,POS)} @tab @code{INTEGER(8) I,POS} @tab @code{LOGICAL(8)} @tab GNU extension
3067 1.1 mrg @end multitable
3068 1.1 mrg @end table
3069 1.1 mrg
3070 1.1 mrg @node C_ASSOCIATED
3071 1.1 mrg @section @code{C_ASSOCIATED} --- Status of a C pointer
3072 1.1 mrg @fnindex C_ASSOCIATED
3073 1.1 mrg @cindex association status, C pointer
3074 1.1 mrg @cindex pointer, C association status
3075 1.1 mrg
3076 1.1 mrg @table @asis
3077 1.1 mrg @item @emph{Description}:
3078 1.1 mrg @code{C_ASSOCIATED(c_ptr_1[, c_ptr_2])} determines the status of the C pointer
3079 1.1 mrg @var{c_ptr_1} or if @var{c_ptr_1} is associated with the target @var{c_ptr_2}.
3080 1.1 mrg
3081 1.1 mrg @item @emph{Standard}:
3082 1.1 mrg Fortran 2003 and later
3083 1.1 mrg
3084 1.1 mrg @item @emph{Class}:
3085 1.1 mrg Inquiry function
3086 1.1 mrg
3087 1.1 mrg @item @emph{Syntax}:
3088 1.1 mrg @code{RESULT = C_ASSOCIATED(c_ptr_1[, c_ptr_2])}
3089 1.1 mrg
3090 1.1 mrg @item @emph{Arguments}:
3091 1.1 mrg @multitable @columnfractions .15 .70
3092 1.1 mrg @item @var{c_ptr_1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}.
3093 1.1 mrg @item @var{c_ptr_2} @tab (Optional) Scalar of the same type as @var{c_ptr_1}.
3094 1.1 mrg @end multitable
3095 1.1 mrg
3096 1.1 mrg @item @emph{Return value}:
3097 1.1 mrg The return value is of type @code{LOGICAL}; it is @code{.false.} if either
3098 1.1 mrg @var{c_ptr_1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr_2}
3099 1.1 mrg point to different addresses.
3100 1.1 mrg
3101 1.1 mrg @item @emph{Example}:
3102 1.1 mrg @smallexample
3103 1.1 mrg subroutine association_test(a,b)
3104 1.1 mrg use iso_c_binding, only: c_associated, c_loc, c_ptr
3105 1.1 mrg implicit none
3106 1.1 mrg real, pointer :: a
3107 1.1 mrg type(c_ptr) :: b
3108 1.1 mrg if(c_associated(b, c_loc(a))) &
3109 1.1 mrg stop 'b and a do not point to same target'
3110 1.1 mrg end subroutine association_test
3111 1.1 mrg @end smallexample
3112 1.1 mrg
3113 1.1 mrg @item @emph{See also}:
3114 1.1.1.2 mrg @ref{C_LOC}, @gol
3115 1.1.1.2 mrg @ref{C_FUNLOC}
3116 1.1 mrg @end table
3117 1.1 mrg
3118 1.1 mrg
3119 1.1 mrg @node C_F_POINTER
3120 1.1 mrg @section @code{C_F_POINTER} --- Convert C into Fortran pointer
3121 1.1 mrg @fnindex C_F_POINTER
3122 1.1 mrg @cindex pointer, convert C to Fortran
3123 1.1 mrg
3124 1.1 mrg @table @asis
3125 1.1 mrg @item @emph{Description}:
3126 1.1 mrg @code{C_F_POINTER(CPTR, FPTR[, SHAPE])} assigns the target of the C pointer
3127 1.1 mrg @var{CPTR} to the Fortran pointer @var{FPTR} and specifies its shape.
3128 1.1 mrg
3129 1.1 mrg @item @emph{Standard}:
3130 1.1 mrg Fortran 2003 and later
3131 1.1 mrg
3132 1.1 mrg @item @emph{Class}:
3133 1.1 mrg Subroutine
3134 1.1 mrg
3135 1.1 mrg @item @emph{Syntax}:
3136 1.1 mrg @code{CALL C_F_POINTER(CPTR, FPTR[, SHAPE])}
3137 1.1 mrg
3138 1.1 mrg @item @emph{Arguments}:
3139 1.1 mrg @multitable @columnfractions .15 .70
3140 1.1 mrg @item @var{CPTR} @tab scalar of the type @code{C_PTR}. It is
3141 1.1 mrg @code{INTENT(IN)}.
3142 1.1 mrg @item @var{FPTR} @tab pointer interoperable with @var{cptr}. It is
3143 1.1 mrg @code{INTENT(OUT)}.
3144 1.1 mrg @item @var{SHAPE} @tab (Optional) Rank-one array of type @code{INTEGER}
3145 1.1 mrg with @code{INTENT(IN)}. It shall be present
3146 1.1 mrg if and only if @var{fptr} is an array. The size
3147 1.1 mrg must be equal to the rank of @var{fptr}.
3148 1.1 mrg @end multitable
3149 1.1 mrg
3150 1.1 mrg @item @emph{Example}:
3151 1.1 mrg @smallexample
3152 1.1 mrg program main
3153 1.1 mrg use iso_c_binding
3154 1.1 mrg implicit none
3155 1.1 mrg interface
3156 1.1 mrg subroutine my_routine(p) bind(c,name='myC_func')
3157 1.1 mrg import :: c_ptr
3158 1.1 mrg type(c_ptr), intent(out) :: p
3159 1.1 mrg end subroutine
3160 1.1 mrg end interface
3161 1.1 mrg type(c_ptr) :: cptr
3162 1.1 mrg real,pointer :: a(:)
3163 1.1 mrg call my_routine(cptr)
3164 1.1 mrg call c_f_pointer(cptr, a, [12])
3165 1.1 mrg end program main
3166 1.1 mrg @end smallexample
3167 1.1 mrg
3168 1.1 mrg @item @emph{See also}:
3169 1.1.1.2 mrg @ref{C_LOC}, @gol
3170 1.1.1.2 mrg @ref{C_F_PROCPOINTER}
3171 1.1 mrg @end table
3172 1.1 mrg
3173 1.1 mrg
3174 1.1 mrg @node C_F_PROCPOINTER
3175 1.1 mrg @section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer
3176 1.1 mrg @fnindex C_F_PROCPOINTER
3177 1.1 mrg @cindex pointer, C address of pointers
3178 1.1 mrg
3179 1.1 mrg @table @asis
3180 1.1 mrg @item @emph{Description}:
3181 1.1 mrg @code{C_F_PROCPOINTER(CPTR, FPTR)} Assign the target of the C function pointer
3182 1.1 mrg @var{CPTR} to the Fortran procedure pointer @var{FPTR}.
3183 1.1 mrg
3184 1.1 mrg @item @emph{Standard}:
3185 1.1 mrg Fortran 2003 and later
3186 1.1 mrg
3187 1.1 mrg @item @emph{Class}:
3188 1.1 mrg Subroutine
3189 1.1 mrg
3190 1.1 mrg @item @emph{Syntax}:
3191 1.1 mrg @code{CALL C_F_PROCPOINTER(cptr, fptr)}
3192 1.1 mrg
3193 1.1 mrg @item @emph{Arguments}:
3194 1.1 mrg @multitable @columnfractions .15 .70
3195 1.1 mrg @item @var{CPTR} @tab scalar of the type @code{C_FUNPTR}. It is
3196 1.1 mrg @code{INTENT(IN)}.
3197 1.1 mrg @item @var{FPTR} @tab procedure pointer interoperable with @var{cptr}. It is
3198 1.1 mrg @code{INTENT(OUT)}.
3199 1.1 mrg @end multitable
3200 1.1 mrg
3201 1.1 mrg @item @emph{Example}:
3202 1.1 mrg @smallexample
3203 1.1 mrg program main
3204 1.1 mrg use iso_c_binding
3205 1.1 mrg implicit none
3206 1.1 mrg abstract interface
3207 1.1 mrg function func(a)
3208 1.1 mrg import :: c_float
3209 1.1 mrg real(c_float), intent(in) :: a
3210 1.1 mrg real(c_float) :: func
3211 1.1 mrg end function
3212 1.1 mrg end interface
3213 1.1 mrg interface
3214 1.1 mrg function getIterFunc() bind(c,name="getIterFunc")
3215 1.1 mrg import :: c_funptr
3216 1.1 mrg type(c_funptr) :: getIterFunc
3217 1.1 mrg end function
3218 1.1 mrg end interface
3219 1.1 mrg type(c_funptr) :: cfunptr
3220 1.1 mrg procedure(func), pointer :: myFunc
3221 1.1 mrg cfunptr = getIterFunc()
3222 1.1 mrg call c_f_procpointer(cfunptr, myFunc)
3223 1.1 mrg end program main
3224 1.1 mrg @end smallexample
3225 1.1 mrg
3226 1.1 mrg @item @emph{See also}:
3227 1.1.1.2 mrg @ref{C_LOC}, @gol
3228 1.1.1.2 mrg @ref{C_F_POINTER}
3229 1.1 mrg @end table
3230 1.1 mrg
3231 1.1 mrg
3232 1.1 mrg @node C_FUNLOC
3233 1.1 mrg @section @code{C_FUNLOC} --- Obtain the C address of a procedure
3234 1.1 mrg @fnindex C_FUNLOC
3235 1.1 mrg @cindex pointer, C address of procedures
3236 1.1 mrg
3237 1.1 mrg @table @asis
3238 1.1 mrg @item @emph{Description}:
3239 1.1 mrg @code{C_FUNLOC(x)} determines the C address of the argument.
3240 1.1 mrg
3241 1.1 mrg @item @emph{Standard}:
3242 1.1 mrg Fortran 2003 and later
3243 1.1 mrg
3244 1.1 mrg @item @emph{Class}:
3245 1.1 mrg Inquiry function
3246 1.1 mrg
3247 1.1 mrg @item @emph{Syntax}:
3248 1.1 mrg @code{RESULT = C_FUNLOC(x)}
3249 1.1 mrg
3250 1.1 mrg @item @emph{Arguments}:
3251 1.1 mrg @multitable @columnfractions .15 .70
3252 1.1 mrg @item @var{x} @tab Interoperable function or pointer to such function.
3253 1.1 mrg @end multitable
3254 1.1 mrg
3255 1.1 mrg @item @emph{Return value}:
3256 1.1 mrg The return value is of type @code{C_FUNPTR} and contains the C address
3257 1.1 mrg of the argument.
3258 1.1 mrg
3259 1.1 mrg @item @emph{Example}:
3260 1.1 mrg @smallexample
3261 1.1 mrg module x
3262 1.1 mrg use iso_c_binding
3263 1.1 mrg implicit none
3264 1.1 mrg contains
3265 1.1 mrg subroutine sub(a) bind(c)
3266 1.1 mrg real(c_float) :: a
3267 1.1 mrg a = sqrt(a)+5.0
3268 1.1 mrg end subroutine sub
3269 1.1 mrg end module x
3270 1.1 mrg program main
3271 1.1 mrg use iso_c_binding
3272 1.1 mrg use x
3273 1.1 mrg implicit none
3274 1.1 mrg interface
3275 1.1 mrg subroutine my_routine(p) bind(c,name='myC_func')
3276 1.1 mrg import :: c_funptr
3277 1.1 mrg type(c_funptr), intent(in) :: p
3278 1.1 mrg end subroutine
3279 1.1 mrg end interface
3280 1.1 mrg call my_routine(c_funloc(sub))
3281 1.1 mrg end program main
3282 1.1 mrg @end smallexample
3283 1.1 mrg
3284 1.1 mrg @item @emph{See also}:
3285 1.1.1.2 mrg @ref{C_ASSOCIATED}, @gol
3286 1.1.1.2 mrg @ref{C_LOC}, @gol
3287 1.1.1.2 mrg @ref{C_F_POINTER}, @gol
3288 1.1.1.2 mrg @ref{C_F_PROCPOINTER}
3289 1.1 mrg @end table
3290 1.1 mrg
3291 1.1 mrg
3292 1.1 mrg @node C_LOC
3293 1.1 mrg @section @code{C_LOC} --- Obtain the C address of an object
3294 1.1 mrg @fnindex C_LOC
3295 1.1 mrg @cindex procedure pointer, convert C to Fortran
3296 1.1 mrg
3297 1.1 mrg @table @asis
3298 1.1 mrg @item @emph{Description}:
3299 1.1 mrg @code{C_LOC(X)} determines the C address of the argument.
3300 1.1 mrg
3301 1.1 mrg @item @emph{Standard}:
3302 1.1 mrg Fortran 2003 and later
3303 1.1 mrg
3304 1.1 mrg @item @emph{Class}:
3305 1.1 mrg Inquiry function
3306 1.1 mrg
3307 1.1 mrg @item @emph{Syntax}:
3308 1.1 mrg @code{RESULT = C_LOC(X)}
3309 1.1 mrg
3310 1.1 mrg @item @emph{Arguments}:
3311 1.1 mrg @multitable @columnfractions .10 .75
3312 1.1 mrg @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.
3313 1.1 mrg
3314 1.1 mrg @end multitable
3315 1.1 mrg
3316 1.1 mrg @item @emph{Return value}:
3317 1.1 mrg The return value is of type @code{C_PTR} and contains the C address
3318 1.1 mrg of the argument.
3319 1.1 mrg
3320 1.1 mrg @item @emph{Example}:
3321 1.1 mrg @smallexample
3322 1.1 mrg subroutine association_test(a,b)
3323 1.1 mrg use iso_c_binding, only: c_associated, c_loc, c_ptr
3324 1.1 mrg implicit none
3325 1.1 mrg real, pointer :: a
3326 1.1 mrg type(c_ptr) :: b
3327 1.1 mrg if(c_associated(b, c_loc(a))) &
3328 1.1 mrg stop 'b and a do not point to same target'
3329 1.1 mrg end subroutine association_test
3330 1.1 mrg @end smallexample
3331 1.1 mrg
3332 1.1 mrg @item @emph{See also}:
3333 1.1.1.2 mrg @ref{C_ASSOCIATED}, @gol
3334 1.1.1.2 mrg @ref{C_FUNLOC}, @gol
3335 1.1.1.2 mrg @ref{C_F_POINTER}, @gol
3336 1.1.1.2 mrg @ref{C_F_PROCPOINTER}
3337 1.1 mrg @end table
3338 1.1 mrg
3339 1.1 mrg
3340 1.1 mrg @node C_SIZEOF
3341 1.1 mrg @section @code{C_SIZEOF} --- Size in bytes of an expression
3342 1.1 mrg @fnindex C_SIZEOF
3343 1.1 mrg @cindex expression size
3344 1.1 mrg @cindex size of an expression
3345 1.1 mrg
3346 1.1 mrg @table @asis
3347 1.1 mrg @item @emph{Description}:
3348 1.1 mrg @code{C_SIZEOF(X)} calculates the number of bytes of storage the
3349 1.1 mrg expression @code{X} occupies.
3350 1.1 mrg
3351 1.1 mrg @item @emph{Standard}:
3352 1.1 mrg Fortran 2008
3353 1.1 mrg
3354 1.1 mrg @item @emph{Class}:
3355 1.1 mrg Inquiry function of the module @code{ISO_C_BINDING}
3356 1.1 mrg
3357 1.1 mrg @item @emph{Syntax}:
3358 1.1 mrg @code{N = C_SIZEOF(X)}
3359 1.1 mrg
3360 1.1 mrg @item @emph{Arguments}:
3361 1.1 mrg @multitable @columnfractions .15 .70
3362 1.1 mrg @item @var{X} @tab The argument shall be an interoperable data entity.
3363 1.1 mrg @end multitable
3364 1.1 mrg
3365 1.1 mrg @item @emph{Return value}:
3366 1.1 mrg The return value is of type integer and of the system-dependent kind
3367 1.1 mrg @code{C_SIZE_T} (from the @code{ISO_C_BINDING} module). Its value is the
3368 1.1 mrg number of bytes occupied by the argument. If the argument has the
3369 1.1 mrg @code{POINTER} attribute, the number of bytes of the storage area pointed
3370 1.1 mrg to is returned. If the argument is of a derived type with @code{POINTER}
3371 1.1 mrg or @code{ALLOCATABLE} components, the return value does not account for
3372 1.1 mrg the sizes of the data pointed to by these components.
3373 1.1 mrg
3374 1.1 mrg @item @emph{Example}:
3375 1.1 mrg @smallexample
3376 1.1 mrg use iso_c_binding
3377 1.1 mrg integer(c_int) :: i
3378 1.1 mrg real(c_float) :: r, s(5)
3379 1.1 mrg print *, (c_sizeof(s)/c_sizeof(r) == 5)
3380 1.1 mrg end
3381 1.1 mrg @end smallexample
3382 1.1.1.2 mrg The example will print @code{T} unless you are using a platform
3383 1.1 mrg where default @code{REAL} variables are unusually padded.
3384 1.1 mrg
3385 1.1 mrg @item @emph{See also}:
3386 1.1.1.2 mrg @ref{SIZEOF}, @gol
3387 1.1.1.2 mrg @ref{STORAGE_SIZE}
3388 1.1 mrg @end table
3389 1.1 mrg
3390 1.1 mrg
3391 1.1 mrg @node CEILING
3392 1.1 mrg @section @code{CEILING} --- Integer ceiling function
3393 1.1 mrg @fnindex CEILING
3394 1.1 mrg @cindex ceiling
3395 1.1 mrg @cindex rounding, ceiling
3396 1.1 mrg
3397 1.1 mrg @table @asis
3398 1.1 mrg @item @emph{Description}:
3399 1.1 mrg @code{CEILING(A)} returns the least integer greater than or equal to @var{A}.
3400 1.1 mrg
3401 1.1 mrg @item @emph{Standard}:
3402 1.1 mrg Fortran 95 and later
3403 1.1 mrg
3404 1.1 mrg @item @emph{Class}:
3405 1.1 mrg Elemental function
3406 1.1 mrg
3407 1.1 mrg @item @emph{Syntax}:
3408 1.1 mrg @code{RESULT = CEILING(A [, KIND])}
3409 1.1 mrg
3410 1.1 mrg @item @emph{Arguments}:
3411 1.1 mrg @multitable @columnfractions .15 .70
3412 1.1 mrg @item @var{A} @tab The type shall be @code{REAL}.
3413 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3414 1.1 mrg expression indicating the kind parameter of the result.
3415 1.1 mrg @end multitable
3416 1.1 mrg
3417 1.1 mrg @item @emph{Return value}:
3418 1.1 mrg The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
3419 1.1 mrg and a default-kind @code{INTEGER} otherwise.
3420 1.1 mrg
3421 1.1 mrg @item @emph{Example}:
3422 1.1 mrg @smallexample
3423 1.1 mrg program test_ceiling
3424 1.1 mrg real :: x = 63.29
3425 1.1 mrg real :: y = -63.59
3426 1.1 mrg print *, ceiling(x) ! returns 64
3427 1.1 mrg print *, ceiling(y) ! returns -63
3428 1.1 mrg end program test_ceiling
3429 1.1 mrg @end smallexample
3430 1.1 mrg
3431 1.1 mrg @item @emph{See also}:
3432 1.1.1.2 mrg @ref{FLOOR}, @gol
3433 1.1.1.2 mrg @ref{NINT}
3434 1.1 mrg @end table
3435 1.1 mrg
3436 1.1 mrg
3437 1.1 mrg
3438 1.1 mrg @node CHAR
3439 1.1 mrg @section @code{CHAR} --- Character conversion function
3440 1.1 mrg @fnindex CHAR
3441 1.1 mrg @cindex conversion, to character
3442 1.1 mrg
3443 1.1 mrg @table @asis
3444 1.1 mrg @item @emph{Description}:
3445 1.1 mrg @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
3446 1.1 mrg
3447 1.1 mrg @item @emph{Standard}:
3448 1.1 mrg Fortran 77 and later
3449 1.1 mrg
3450 1.1 mrg @item @emph{Class}:
3451 1.1 mrg Elemental function
3452 1.1 mrg
3453 1.1 mrg @item @emph{Syntax}:
3454 1.1 mrg @code{RESULT = CHAR(I [, KIND])}
3455 1.1 mrg
3456 1.1 mrg @item @emph{Arguments}:
3457 1.1 mrg @multitable @columnfractions .15 .70
3458 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
3459 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3460 1.1 mrg expression indicating the kind parameter of the result.
3461 1.1 mrg @end multitable
3462 1.1 mrg
3463 1.1 mrg @item @emph{Return value}:
3464 1.1 mrg The return value is of type @code{CHARACTER(1)}
3465 1.1 mrg
3466 1.1 mrg @item @emph{Example}:
3467 1.1 mrg @smallexample
3468 1.1 mrg program test_char
3469 1.1 mrg integer :: i = 74
3470 1.1 mrg character(1) :: c
3471 1.1 mrg c = char(i)
3472 1.1 mrg print *, i, c ! returns 'J'
3473 1.1 mrg end program test_char
3474 1.1 mrg @end smallexample
3475 1.1 mrg
3476 1.1 mrg @item @emph{Specific names}:
3477 1.1.1.2 mrg @multitable @columnfractions .18 .18 .24 .25
3478 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
3479 1.1.1.2 mrg @item @code{CHAR(I)} @tab @code{INTEGER I} @tab @code{CHARACTER(LEN=1)} @tab Fortran 77 and later
3480 1.1 mrg @end multitable
3481 1.1 mrg
3482 1.1 mrg @item @emph{Note}:
3483 1.1 mrg See @ref{ICHAR} for a discussion of converting between numerical values
3484 1.1 mrg and formatted string representations.
3485 1.1 mrg
3486 1.1 mrg @item @emph{See also}:
3487 1.1.1.2 mrg @ref{ACHAR}, @gol
3488 1.1.1.2 mrg @ref{IACHAR}, @gol
3489 1.1.1.2 mrg @ref{ICHAR}
3490 1.1 mrg
3491 1.1 mrg @end table
3492 1.1 mrg
3493 1.1 mrg
3494 1.1 mrg
3495 1.1 mrg @node CHDIR
3496 1.1 mrg @section @code{CHDIR} --- Change working directory
3497 1.1 mrg @fnindex CHDIR
3498 1.1 mrg @cindex system, working directory
3499 1.1 mrg
3500 1.1 mrg @table @asis
3501 1.1 mrg @item @emph{Description}:
3502 1.1 mrg Change current working directory to a specified path.
3503 1.1 mrg
3504 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
3505 1.1 mrg only one form can be used in any given program unit.
3506 1.1 mrg
3507 1.1 mrg @item @emph{Standard}:
3508 1.1 mrg GNU extension
3509 1.1 mrg
3510 1.1 mrg @item @emph{Class}:
3511 1.1 mrg Subroutine, function
3512 1.1 mrg
3513 1.1 mrg @item @emph{Syntax}:
3514 1.1 mrg @multitable @columnfractions .80
3515 1.1 mrg @item @code{CALL CHDIR(NAME [, STATUS])}
3516 1.1 mrg @item @code{STATUS = CHDIR(NAME)}
3517 1.1 mrg @end multitable
3518 1.1 mrg
3519 1.1 mrg @item @emph{Arguments}:
3520 1.1 mrg @multitable @columnfractions .15 .70
3521 1.1 mrg @item @var{NAME} @tab The type shall be @code{CHARACTER} of default
3522 1.1 mrg kind and shall specify a valid path within the file system.
3523 1.1 mrg @item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
3524 1.1 mrg kind. Returns 0 on success, and a system specific and nonzero error code
3525 1.1 mrg otherwise.
3526 1.1 mrg @end multitable
3527 1.1 mrg
3528 1.1 mrg @item @emph{Example}:
3529 1.1 mrg @smallexample
3530 1.1 mrg PROGRAM test_chdir
3531 1.1 mrg CHARACTER(len=255) :: path
3532 1.1 mrg CALL getcwd(path)
3533 1.1 mrg WRITE(*,*) TRIM(path)
3534 1.1 mrg CALL chdir("/tmp")
3535 1.1 mrg CALL getcwd(path)
3536 1.1 mrg WRITE(*,*) TRIM(path)
3537 1.1 mrg END PROGRAM
3538 1.1 mrg @end smallexample
3539 1.1 mrg
3540 1.1 mrg @item @emph{See also}:
3541 1.1 mrg @ref{GETCWD}
3542 1.1 mrg @end table
3543 1.1 mrg
3544 1.1 mrg
3545 1.1 mrg
3546 1.1 mrg @node CHMOD
3547 1.1 mrg @section @code{CHMOD} --- Change access permissions of files
3548 1.1 mrg @fnindex CHMOD
3549 1.1 mrg @cindex file system, change access mode
3550 1.1 mrg
3551 1.1 mrg @table @asis
3552 1.1 mrg @item @emph{Description}:
3553 1.1 mrg @code{CHMOD} changes the permissions of a file.
3554 1.1 mrg
3555 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
3556 1.1 mrg only one form can be used in any given program unit.
3557 1.1 mrg
3558 1.1 mrg @item @emph{Standard}:
3559 1.1 mrg GNU extension
3560 1.1 mrg
3561 1.1 mrg @item @emph{Class}:
3562 1.1 mrg Subroutine, function
3563 1.1 mrg
3564 1.1 mrg @item @emph{Syntax}:
3565 1.1 mrg @multitable @columnfractions .80
3566 1.1 mrg @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
3567 1.1 mrg @item @code{STATUS = CHMOD(NAME, MODE)}
3568 1.1 mrg @end multitable
3569 1.1 mrg
3570 1.1 mrg @item @emph{Arguments}:
3571 1.1 mrg @multitable @columnfractions .15 .70
3572 1.1 mrg
3573 1.1 mrg @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
3574 1.1 mrg file name. Trailing blanks are ignored unless the character
3575 1.1 mrg @code{achar(0)} is present, then all characters up to and excluding
3576 1.1 mrg @code{achar(0)} are used as the file name.
3577 1.1 mrg
3578 1.1 mrg @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind giving the
3579 1.1 mrg file permission. @var{MODE} uses the same syntax as the @code{chmod} utility
3580 1.1 mrg as defined by the POSIX standard. The argument shall either be a string of
3581 1.1 mrg a nonnegative octal number or a symbolic mode.
3582 1.1 mrg
3583 1.1 mrg @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
3584 1.1 mrg @code{0} on success and nonzero otherwise.
3585 1.1 mrg @end multitable
3586 1.1 mrg
3587 1.1 mrg @item @emph{Return value}:
3588 1.1 mrg In either syntax, @var{STATUS} is set to @code{0} on success and nonzero
3589 1.1 mrg otherwise.
3590 1.1 mrg
3591 1.1 mrg @item @emph{Example}:
3592 1.1 mrg @code{CHMOD} as subroutine
3593 1.1 mrg @smallexample
3594 1.1 mrg program chmod_test
3595 1.1 mrg implicit none
3596 1.1 mrg integer :: status
3597 1.1 mrg call chmod('test.dat','u+x',status)
3598 1.1 mrg print *, 'Status: ', status
3599 1.1 mrg end program chmod_test
3600 1.1 mrg @end smallexample
3601 1.1 mrg @code{CHMOD} as function:
3602 1.1 mrg @smallexample
3603 1.1 mrg program chmod_test
3604 1.1 mrg implicit none
3605 1.1 mrg integer :: status
3606 1.1 mrg status = chmod('test.dat','u+x')
3607 1.1 mrg print *, 'Status: ', status
3608 1.1 mrg end program chmod_test
3609 1.1 mrg @end smallexample
3610 1.1 mrg
3611 1.1 mrg @end table
3612 1.1 mrg
3613 1.1 mrg
3614 1.1 mrg
3615 1.1 mrg @node CMPLX
3616 1.1 mrg @section @code{CMPLX} --- Complex conversion function
3617 1.1 mrg @fnindex CMPLX
3618 1.1 mrg @cindex complex numbers, conversion to
3619 1.1 mrg @cindex conversion, to complex
3620 1.1 mrg
3621 1.1 mrg @table @asis
3622 1.1 mrg @item @emph{Description}:
3623 1.1 mrg @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
3624 1.1 mrg the real component. If @var{Y} is present it is converted to the imaginary
3625 1.1 mrg component. If @var{Y} is not present then the imaginary component is set to
3626 1.1 mrg 0.0. If @var{X} is complex then @var{Y} must not be present.
3627 1.1 mrg
3628 1.1 mrg @item @emph{Standard}:
3629 1.1 mrg Fortran 77 and later
3630 1.1 mrg
3631 1.1 mrg @item @emph{Class}:
3632 1.1 mrg Elemental function
3633 1.1 mrg
3634 1.1 mrg @item @emph{Syntax}:
3635 1.1 mrg @code{RESULT = CMPLX(X [, Y [, KIND]])}
3636 1.1 mrg
3637 1.1 mrg @item @emph{Arguments}:
3638 1.1 mrg @multitable @columnfractions .15 .70
3639 1.1 mrg @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
3640 1.1 mrg or @code{COMPLEX}.
3641 1.1 mrg @item @var{Y} @tab (Optional; only allowed if @var{X} is not
3642 1.1 mrg @code{COMPLEX}.) May be @code{INTEGER} or @code{REAL}.
3643 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3644 1.1 mrg expression indicating the kind parameter of the result.
3645 1.1 mrg @end multitable
3646 1.1 mrg
3647 1.1 mrg @item @emph{Return value}:
3648 1.1 mrg The return value is of @code{COMPLEX} type, with a kind equal to
3649 1.1 mrg @var{KIND} if it is specified. If @var{KIND} is not specified, the
3650 1.1 mrg result is of the default @code{COMPLEX} kind, regardless of the kinds of
3651 1.1 mrg @var{X} and @var{Y}.
3652 1.1 mrg
3653 1.1 mrg @item @emph{Example}:
3654 1.1 mrg @smallexample
3655 1.1 mrg program test_cmplx
3656 1.1 mrg integer :: i = 42
3657 1.1 mrg real :: x = 3.14
3658 1.1 mrg complex :: z
3659 1.1 mrg z = cmplx(i, x)
3660 1.1 mrg print *, z, cmplx(x)
3661 1.1 mrg end program test_cmplx
3662 1.1 mrg @end smallexample
3663 1.1 mrg
3664 1.1 mrg @item @emph{See also}:
3665 1.1 mrg @ref{COMPLEX}
3666 1.1 mrg @end table
3667 1.1 mrg
3668 1.1 mrg
3669 1.1 mrg
3670 1.1 mrg @node CO_BROADCAST
3671 1.1 mrg @section @code{CO_BROADCAST} --- Copy a value to all images the current set of images
3672 1.1 mrg @fnindex CO_BROADCAST
3673 1.1 mrg @cindex Collectives, value broadcasting
3674 1.1 mrg
3675 1.1 mrg @table @asis
3676 1.1 mrg @item @emph{Description}:
3677 1.1 mrg @code{CO_BROADCAST} copies the value of argument @var{A} on the image with
3678 1.1 mrg image index @code{SOURCE_IMAGE} to all images in the current team. @var{A}
3679 1.1 mrg becomes defined as if by intrinsic assignment. If the execution was
3680 1.1 mrg successful and @var{STAT} is present, it is assigned the value zero. If the
3681 1.1 mrg execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3682 1.1 mrg @var{ERRMSG} gets assigned a value describing the occurred error.
3683 1.1 mrg
3684 1.1 mrg @item @emph{Standard}:
3685 1.1 mrg Technical Specification (TS) 18508 or later
3686 1.1 mrg
3687 1.1 mrg @item @emph{Class}:
3688 1.1 mrg Collective subroutine
3689 1.1 mrg
3690 1.1 mrg @item @emph{Syntax}:
3691 1.1 mrg @code{CALL CO_BROADCAST(A, SOURCE_IMAGE [, STAT, ERRMSG])}
3692 1.1 mrg
3693 1.1 mrg @item @emph{Arguments}:
3694 1.1.1.2 mrg @multitable @columnfractions .20 .65
3695 1.1 mrg @item @var{A} @tab INTENT(INOUT) argument; shall have the same
3696 1.1.1.2 mrg dynamic type and type parameters on all images of the current team. If it
3697 1.1 mrg is an array, it shall have the same shape on all images.
3698 1.1 mrg @item @var{SOURCE_IMAGE} @tab a scalar integer expression.
3699 1.1 mrg It shall have the same the same value on all images and refer to an
3700 1.1 mrg image of the current team.
3701 1.1 mrg @item @var{STAT} @tab (optional) a scalar integer variable
3702 1.1 mrg @item @var{ERRMSG} @tab (optional) a scalar character variable
3703 1.1 mrg @end multitable
3704 1.1 mrg
3705 1.1 mrg @item @emph{Example}:
3706 1.1 mrg @smallexample
3707 1.1 mrg program test
3708 1.1 mrg integer :: val(3)
3709 1.1 mrg if (this_image() == 1) then
3710 1.1 mrg val = [1, 5, 3]
3711 1.1 mrg end if
3712 1.1 mrg call co_broadcast (val, source_image=1)
3713 1.1 mrg print *, this_image, ":", val
3714 1.1 mrg end program test
3715 1.1 mrg @end smallexample
3716 1.1 mrg
3717 1.1 mrg @item @emph{See also}:
3718 1.1.1.2 mrg @ref{CO_MAX}, @gol
3719 1.1.1.2 mrg @ref{CO_MIN}, @gol
3720 1.1.1.2 mrg @ref{CO_SUM}, @gol
3721 1.1.1.2 mrg @ref{CO_REDUCE}
3722 1.1 mrg @end table
3723 1.1 mrg
3724 1.1 mrg
3725 1.1 mrg
3726 1.1 mrg @node CO_MAX
3727 1.1 mrg @section @code{CO_MAX} --- Maximal value on the current set of images
3728 1.1 mrg @fnindex CO_MAX
3729 1.1 mrg @cindex Collectives, maximal value
3730 1.1 mrg
3731 1.1 mrg @table @asis
3732 1.1 mrg @item @emph{Description}:
3733 1.1 mrg @code{CO_MAX} determines element-wise the maximal value of @var{A} on all
3734 1.1 mrg images of the current team. If @var{RESULT_IMAGE} is present, the maximum
3735 1.1 mrg values are returned in @var{A} on the specified image only and the value
3736 1.1 mrg of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is
3737 1.1 mrg not present, the value is returned on all images. If the execution was
3738 1.1 mrg successful and @var{STAT} is present, it is assigned the value zero. If the
3739 1.1 mrg execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3740 1.1 mrg @var{ERRMSG} gets assigned a value describing the occurred error.
3741 1.1 mrg
3742 1.1 mrg @item @emph{Standard}:
3743 1.1 mrg Technical Specification (TS) 18508 or later
3744 1.1 mrg
3745 1.1 mrg @item @emph{Class}:
3746 1.1 mrg Collective subroutine
3747 1.1 mrg
3748 1.1 mrg @item @emph{Syntax}:
3749 1.1 mrg @code{CALL CO_MAX(A [, RESULT_IMAGE, STAT, ERRMSG])}
3750 1.1 mrg
3751 1.1 mrg @item @emph{Arguments}:
3752 1.1.1.2 mrg @multitable @columnfractions .20 .65
3753 1.1 mrg @item @var{A} @tab shall be an integer, real or character variable,
3754 1.1 mrg which has the same type and type parameters on all images of the team.
3755 1.1 mrg @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3756 1.1 mrg present, it shall have the same the same value on all images and refer to an
3757 1.1 mrg image of the current team.
3758 1.1 mrg @item @var{STAT} @tab (optional) a scalar integer variable
3759 1.1 mrg @item @var{ERRMSG} @tab (optional) a scalar character variable
3760 1.1 mrg @end multitable
3761 1.1 mrg
3762 1.1 mrg @item @emph{Example}:
3763 1.1 mrg @smallexample
3764 1.1 mrg program test
3765 1.1 mrg integer :: val
3766 1.1 mrg val = this_image ()
3767 1.1 mrg call co_max (val, result_image=1)
3768 1.1 mrg if (this_image() == 1) then
3769 1.1 mrg write(*,*) "Maximal value", val ! prints num_images()
3770 1.1 mrg end if
3771 1.1 mrg end program test
3772 1.1 mrg @end smallexample
3773 1.1 mrg
3774 1.1 mrg @item @emph{See also}:
3775 1.1.1.2 mrg @ref{CO_MIN}, @gol
3776 1.1.1.2 mrg @ref{CO_SUM}, @gol
3777 1.1.1.2 mrg @ref{CO_REDUCE}, @gol
3778 1.1.1.2 mrg @ref{CO_BROADCAST}
3779 1.1 mrg @end table
3780 1.1 mrg
3781 1.1 mrg
3782 1.1 mrg
3783 1.1 mrg @node CO_MIN
3784 1.1 mrg @section @code{CO_MIN} --- Minimal value on the current set of images
3785 1.1 mrg @fnindex CO_MIN
3786 1.1 mrg @cindex Collectives, minimal value
3787 1.1 mrg
3788 1.1 mrg @table @asis
3789 1.1 mrg @item @emph{Description}:
3790 1.1 mrg @code{CO_MIN} determines element-wise the minimal value of @var{A} on all
3791 1.1 mrg images of the current team. If @var{RESULT_IMAGE} is present, the minimal
3792 1.1 mrg values are returned in @var{A} on the specified image only and the value
3793 1.1 mrg of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is
3794 1.1 mrg not present, the value is returned on all images. If the execution was
3795 1.1 mrg successful and @var{STAT} is present, it is assigned the value zero. If the
3796 1.1 mrg execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3797 1.1 mrg @var{ERRMSG} gets assigned a value describing the occurred error.
3798 1.1 mrg
3799 1.1 mrg @item @emph{Standard}:
3800 1.1 mrg Technical Specification (TS) 18508 or later
3801 1.1 mrg
3802 1.1 mrg @item @emph{Class}:
3803 1.1 mrg Collective subroutine
3804 1.1 mrg
3805 1.1 mrg @item @emph{Syntax}:
3806 1.1 mrg @code{CALL CO_MIN(A [, RESULT_IMAGE, STAT, ERRMSG])}
3807 1.1 mrg
3808 1.1 mrg @item @emph{Arguments}:
3809 1.1.1.2 mrg @multitable @columnfractions .20 .65
3810 1.1 mrg @item @var{A} @tab shall be an integer, real or character variable,
3811 1.1 mrg which has the same type and type parameters on all images of the team.
3812 1.1 mrg @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3813 1.1 mrg present, it shall have the same the same value on all images and refer to an
3814 1.1 mrg image of the current team.
3815 1.1 mrg @item @var{STAT} @tab (optional) a scalar integer variable
3816 1.1 mrg @item @var{ERRMSG} @tab (optional) a scalar character variable
3817 1.1 mrg @end multitable
3818 1.1 mrg
3819 1.1 mrg @item @emph{Example}:
3820 1.1 mrg @smallexample
3821 1.1 mrg program test
3822 1.1 mrg integer :: val
3823 1.1 mrg val = this_image ()
3824 1.1 mrg call co_min (val, result_image=1)
3825 1.1 mrg if (this_image() == 1) then
3826 1.1 mrg write(*,*) "Minimal value", val ! prints 1
3827 1.1 mrg end if
3828 1.1 mrg end program test
3829 1.1 mrg @end smallexample
3830 1.1 mrg
3831 1.1 mrg @item @emph{See also}:
3832 1.1.1.2 mrg @ref{CO_MAX}, @gol
3833 1.1.1.2 mrg @ref{CO_SUM}, @gol
3834 1.1.1.2 mrg @ref{CO_REDUCE}, @gol
3835 1.1.1.2 mrg @ref{CO_BROADCAST}
3836 1.1 mrg @end table
3837 1.1 mrg
3838 1.1 mrg
3839 1.1 mrg
3840 1.1 mrg @node CO_REDUCE
3841 1.1 mrg @section @code{CO_REDUCE} --- Reduction of values on the current set of images
3842 1.1 mrg @fnindex CO_REDUCE
3843 1.1 mrg @cindex Collectives, generic reduction
3844 1.1 mrg
3845 1.1 mrg @table @asis
3846 1.1 mrg @item @emph{Description}:
3847 1.1 mrg @code{CO_REDUCE} determines element-wise the reduction of the value of @var{A}
3848 1.1 mrg on all images of the current team. The pure function passed as @var{OPERATOR}
3849 1.1 mrg is used to pairwise reduce the values of @var{A} by passing either the value
3850 1.1 mrg of @var{A} of different images or the result values of such a reduction as
3851 1.1 mrg argument. If @var{A} is an array, the deduction is done element wise. If
3852 1.1 mrg @var{RESULT_IMAGE} is present, the result values are returned in @var{A} on
3853 1.1 mrg the specified image only and the value of @var{A} on the other images become
3854 1.1 mrg undefined. If @var{RESULT_IMAGE} is not present, the value is returned on all
3855 1.1 mrg images. If the execution was successful and @var{STAT} is present, it is
3856 1.1 mrg assigned the value zero. If the execution failed, @var{STAT} gets assigned
3857 1.1 mrg a nonzero value and, if present, @var{ERRMSG} gets assigned a value describing
3858 1.1 mrg the occurred error.
3859 1.1 mrg
3860 1.1 mrg @item @emph{Standard}:
3861 1.1 mrg Technical Specification (TS) 18508 or later
3862 1.1 mrg
3863 1.1 mrg @item @emph{Class}:
3864 1.1 mrg Collective subroutine
3865 1.1 mrg
3866 1.1 mrg @item @emph{Syntax}:
3867 1.1 mrg @code{CALL CO_REDUCE(A, OPERATOR, [, RESULT_IMAGE, STAT, ERRMSG])}
3868 1.1 mrg
3869 1.1 mrg @item @emph{Arguments}:
3870 1.1.1.2 mrg @multitable @columnfractions .20 .65
3871 1.1 mrg @item @var{A} @tab is an @code{INTENT(INOUT)} argument and shall be
3872 1.1 mrg nonpolymorphic. If it is allocatable, it shall be allocated; if it is a pointer,
3873 1.1 mrg it shall be associated. @var{A} shall have the same type and type parameters on
3874 1.1 mrg all images of the team; if it is an array, it shall have the same shape on all
3875 1.1 mrg images.
3876 1.1 mrg @item @var{OPERATOR} @tab pure function with two scalar nonallocatable
3877 1.1 mrg arguments, which shall be nonpolymorphic and have the same type and type
3878 1.1 mrg parameters as @var{A}. The function shall return a nonallocatable scalar of
3879 1.1 mrg the same type and type parameters as @var{A}. The function shall be the same on
3880 1.1 mrg all images and with regards to the arguments mathematically commutative and
3881 1.1 mrg associative. Note that @var{OPERATOR} may not be an elemental function, unless
3882 1.1 mrg it is an intrisic function.
3883 1.1 mrg @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3884 1.1 mrg present, it shall have the same the same value on all images and refer to an
3885 1.1 mrg image of the current team.
3886 1.1 mrg @item @var{STAT} @tab (optional) a scalar integer variable
3887 1.1 mrg @item @var{ERRMSG} @tab (optional) a scalar character variable
3888 1.1 mrg @end multitable
3889 1.1 mrg
3890 1.1 mrg @item @emph{Example}:
3891 1.1 mrg @smallexample
3892 1.1 mrg program test
3893 1.1 mrg integer :: val
3894 1.1 mrg val = this_image ()
3895 1.1 mrg call co_reduce (val, result_image=1, operator=myprod)
3896 1.1 mrg if (this_image() == 1) then
3897 1.1 mrg write(*,*) "Product value", val ! prints num_images() factorial
3898 1.1 mrg end if
3899 1.1 mrg contains
3900 1.1 mrg pure function myprod(a, b)
3901 1.1 mrg integer, value :: a, b
3902 1.1 mrg integer :: myprod
3903 1.1 mrg myprod = a * b
3904 1.1 mrg end function myprod
3905 1.1 mrg end program test
3906 1.1 mrg @end smallexample
3907 1.1 mrg
3908 1.1 mrg @item @emph{Note}:
3909 1.1 mrg While the rules permit in principle an intrinsic function, none of the
3910 1.1 mrg intrinsics in the standard fulfill the criteria of having a specific
3911 1.1 mrg function, which takes two arguments of the same type and returning that
3912 1.1 mrg type as result.
3913 1.1 mrg
3914 1.1 mrg @item @emph{See also}:
3915 1.1.1.2 mrg @ref{CO_MIN}, @gol
3916 1.1.1.2 mrg @ref{CO_MAX}, @gol
3917 1.1.1.2 mrg @ref{CO_SUM}, @gol
3918 1.1.1.2 mrg @ref{CO_BROADCAST}
3919 1.1 mrg @end table
3920 1.1 mrg
3921 1.1 mrg
3922 1.1 mrg
3923 1.1 mrg @node CO_SUM
3924 1.1 mrg @section @code{CO_SUM} --- Sum of values on the current set of images
3925 1.1 mrg @fnindex CO_SUM
3926 1.1 mrg @cindex Collectives, sum of values
3927 1.1 mrg
3928 1.1 mrg @table @asis
3929 1.1 mrg @item @emph{Description}:
3930 1.1 mrg @code{CO_SUM} sums up the values of each element of @var{A} on all
3931 1.1 mrg images of the current team. If @var{RESULT_IMAGE} is present, the summed-up
3932 1.1 mrg values are returned in @var{A} on the specified image only and the value
3933 1.1 mrg of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is
3934 1.1 mrg not present, the value is returned on all images. If the execution was
3935 1.1 mrg successful and @var{STAT} is present, it is assigned the value zero. If the
3936 1.1 mrg execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3937 1.1 mrg @var{ERRMSG} gets assigned a value describing the occurred error.
3938 1.1 mrg
3939 1.1 mrg @item @emph{Standard}:
3940 1.1 mrg Technical Specification (TS) 18508 or later
3941 1.1 mrg
3942 1.1 mrg @item @emph{Class}:
3943 1.1 mrg Collective subroutine
3944 1.1 mrg
3945 1.1 mrg @item @emph{Syntax}:
3946 1.1 mrg @code{CALL CO_MIN(A [, RESULT_IMAGE, STAT, ERRMSG])}
3947 1.1 mrg
3948 1.1 mrg @item @emph{Arguments}:
3949 1.1.1.2 mrg @multitable @columnfractions .20 .65
3950 1.1 mrg @item @var{A} @tab shall be an integer, real or complex variable,
3951 1.1 mrg which has the same type and type parameters on all images of the team.
3952 1.1 mrg @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3953 1.1 mrg present, it shall have the same the same value on all images and refer to an
3954 1.1 mrg image of the current team.
3955 1.1 mrg @item @var{STAT} @tab (optional) a scalar integer variable
3956 1.1 mrg @item @var{ERRMSG} @tab (optional) a scalar character variable
3957 1.1 mrg @end multitable
3958 1.1 mrg
3959 1.1 mrg @item @emph{Example}:
3960 1.1 mrg @smallexample
3961 1.1 mrg program test
3962 1.1 mrg integer :: val
3963 1.1 mrg val = this_image ()
3964 1.1 mrg call co_sum (val, result_image=1)
3965 1.1 mrg if (this_image() == 1) then
3966 1.1.1.2 mrg write(*,*) "The sum is ", val ! prints (n**2 + n)/2,
3967 1.1.1.2 mrg ! with n = num_images()
3968 1.1 mrg end if
3969 1.1 mrg end program test
3970 1.1 mrg @end smallexample
3971 1.1 mrg
3972 1.1 mrg @item @emph{See also}:
3973 1.1.1.2 mrg @ref{CO_MAX}, @gol
3974 1.1.1.2 mrg @ref{CO_MIN}, @gol
3975 1.1.1.2 mrg @ref{CO_REDUCE}, @gol
3976 1.1.1.2 mrg @ref{CO_BROADCAST}
3977 1.1 mrg @end table
3978 1.1 mrg
3979 1.1 mrg
3980 1.1 mrg
3981 1.1 mrg @node COMMAND_ARGUMENT_COUNT
3982 1.1 mrg @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
3983 1.1 mrg @fnindex COMMAND_ARGUMENT_COUNT
3984 1.1 mrg @cindex command-line arguments
3985 1.1 mrg @cindex command-line arguments, number of
3986 1.1 mrg @cindex arguments, to program
3987 1.1 mrg
3988 1.1 mrg @table @asis
3989 1.1 mrg @item @emph{Description}:
3990 1.1 mrg @code{COMMAND_ARGUMENT_COUNT} returns the number of arguments passed on the
3991 1.1 mrg command line when the containing program was invoked.
3992 1.1 mrg
3993 1.1 mrg @item @emph{Standard}:
3994 1.1 mrg Fortran 2003 and later
3995 1.1 mrg
3996 1.1 mrg @item @emph{Class}:
3997 1.1 mrg Inquiry function
3998 1.1 mrg
3999 1.1 mrg @item @emph{Syntax}:
4000 1.1 mrg @code{RESULT = COMMAND_ARGUMENT_COUNT()}
4001 1.1 mrg
4002 1.1 mrg @item @emph{Arguments}:
4003 1.1 mrg @multitable @columnfractions .15 .70
4004 1.1 mrg @item None
4005 1.1 mrg @end multitable
4006 1.1 mrg
4007 1.1 mrg @item @emph{Return value}:
4008 1.1 mrg The return value is an @code{INTEGER} of default kind.
4009 1.1 mrg
4010 1.1 mrg @item @emph{Example}:
4011 1.1 mrg @smallexample
4012 1.1 mrg program test_command_argument_count
4013 1.1 mrg integer :: count
4014 1.1 mrg count = command_argument_count()
4015 1.1 mrg print *, count
4016 1.1 mrg end program test_command_argument_count
4017 1.1 mrg @end smallexample
4018 1.1 mrg
4019 1.1 mrg @item @emph{See also}:
4020 1.1.1.2 mrg @ref{GET_COMMAND}, @gol
4021 1.1.1.2 mrg @ref{GET_COMMAND_ARGUMENT}
4022 1.1 mrg @end table
4023 1.1 mrg
4024 1.1 mrg
4025 1.1 mrg
4026 1.1 mrg @node COMPILER_OPTIONS
4027 1.1 mrg @section @code{COMPILER_OPTIONS} --- Options passed to the compiler
4028 1.1 mrg @fnindex COMPILER_OPTIONS
4029 1.1 mrg @cindex flags inquiry function
4030 1.1 mrg @cindex options inquiry function
4031 1.1 mrg @cindex compiler flags inquiry function
4032 1.1 mrg
4033 1.1 mrg @table @asis
4034 1.1 mrg @item @emph{Description}:
4035 1.1 mrg @code{COMPILER_OPTIONS} returns a string with the options used for
4036 1.1 mrg compiling.
4037 1.1 mrg
4038 1.1 mrg @item @emph{Standard}:
4039 1.1 mrg Fortran 2008
4040 1.1 mrg
4041 1.1 mrg @item @emph{Class}:
4042 1.1 mrg Inquiry function of the module @code{ISO_FORTRAN_ENV}
4043 1.1 mrg
4044 1.1 mrg @item @emph{Syntax}:
4045 1.1 mrg @code{STR = COMPILER_OPTIONS()}
4046 1.1 mrg
4047 1.1 mrg @item @emph{Arguments}:
4048 1.1.1.2 mrg None
4049 1.1 mrg
4050 1.1 mrg @item @emph{Return value}:
4051 1.1 mrg The return value is a default-kind string with system-dependent length.
4052 1.1 mrg It contains the compiler flags used to compile the file, which called
4053 1.1 mrg the @code{COMPILER_OPTIONS} intrinsic.
4054 1.1 mrg
4055 1.1 mrg @item @emph{Example}:
4056 1.1 mrg @smallexample
4057 1.1 mrg use iso_fortran_env
4058 1.1 mrg print '(4a)', 'This file was compiled by ', &
4059 1.1 mrg compiler_version(), ' using the options ', &
4060 1.1 mrg compiler_options()
4061 1.1 mrg end
4062 1.1 mrg @end smallexample
4063 1.1 mrg
4064 1.1 mrg @item @emph{See also}:
4065 1.1.1.2 mrg @ref{COMPILER_VERSION}, @gol
4066 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}
4067 1.1 mrg @end table
4068 1.1 mrg
4069 1.1 mrg
4070 1.1 mrg
4071 1.1 mrg @node COMPILER_VERSION
4072 1.1 mrg @section @code{COMPILER_VERSION} --- Compiler version string
4073 1.1 mrg @fnindex COMPILER_VERSION
4074 1.1 mrg @cindex compiler, name and version
4075 1.1 mrg @cindex version of the compiler
4076 1.1 mrg
4077 1.1 mrg @table @asis
4078 1.1 mrg @item @emph{Description}:
4079 1.1 mrg @code{COMPILER_VERSION} returns a string with the name and the
4080 1.1 mrg version of the compiler.
4081 1.1 mrg
4082 1.1 mrg @item @emph{Standard}:
4083 1.1 mrg Fortran 2008
4084 1.1 mrg
4085 1.1 mrg @item @emph{Class}:
4086 1.1 mrg Inquiry function of the module @code{ISO_FORTRAN_ENV}
4087 1.1 mrg
4088 1.1 mrg @item @emph{Syntax}:
4089 1.1 mrg @code{STR = COMPILER_VERSION()}
4090 1.1 mrg
4091 1.1 mrg @item @emph{Arguments}:
4092 1.1.1.2 mrg None
4093 1.1 mrg
4094 1.1 mrg @item @emph{Return value}:
4095 1.1 mrg The return value is a default-kind string with system-dependent length.
4096 1.1 mrg It contains the name of the compiler and its version number.
4097 1.1 mrg
4098 1.1 mrg @item @emph{Example}:
4099 1.1 mrg @smallexample
4100 1.1 mrg use iso_fortran_env
4101 1.1 mrg print '(4a)', 'This file was compiled by ', &
4102 1.1 mrg compiler_version(), ' using the options ', &
4103 1.1 mrg compiler_options()
4104 1.1 mrg end
4105 1.1 mrg @end smallexample
4106 1.1 mrg
4107 1.1 mrg @item @emph{See also}:
4108 1.1.1.2 mrg @ref{COMPILER_OPTIONS}, @gol
4109 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}
4110 1.1 mrg @end table
4111 1.1 mrg
4112 1.1 mrg
4113 1.1 mrg
4114 1.1 mrg @node COMPLEX
4115 1.1 mrg @section @code{COMPLEX} --- Complex conversion function
4116 1.1 mrg @fnindex COMPLEX
4117 1.1 mrg @cindex complex numbers, conversion to
4118 1.1 mrg @cindex conversion, to complex
4119 1.1 mrg
4120 1.1 mrg @table @asis
4121 1.1 mrg @item @emph{Description}:
4122 1.1 mrg @code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted
4123 1.1 mrg to the real component and @var{Y} is converted to the imaginary
4124 1.1 mrg component.
4125 1.1 mrg
4126 1.1 mrg @item @emph{Standard}:
4127 1.1 mrg GNU extension
4128 1.1 mrg
4129 1.1 mrg @item @emph{Class}:
4130 1.1 mrg Elemental function
4131 1.1 mrg
4132 1.1 mrg @item @emph{Syntax}:
4133 1.1 mrg @code{RESULT = COMPLEX(X, Y)}
4134 1.1 mrg
4135 1.1 mrg @item @emph{Arguments}:
4136 1.1 mrg @multitable @columnfractions .15 .70
4137 1.1 mrg @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
4138 1.1 mrg @item @var{Y} @tab The type may be @code{INTEGER} or @code{REAL}.
4139 1.1 mrg @end multitable
4140 1.1 mrg
4141 1.1 mrg @item @emph{Return value}:
4142 1.1 mrg If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return
4143 1.1 mrg value is of default @code{COMPLEX} type.
4144 1.1 mrg
4145 1.1 mrg If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL}
4146 1.1 mrg type and one is of @code{INTEGER} type, then the return value is of
4147 1.1 mrg @code{COMPLEX} type with a kind equal to that of the @code{REAL}
4148 1.1 mrg argument with the highest precision.
4149 1.1 mrg
4150 1.1 mrg @item @emph{Example}:
4151 1.1 mrg @smallexample
4152 1.1 mrg program test_complex
4153 1.1 mrg integer :: i = 42
4154 1.1 mrg real :: x = 3.14
4155 1.1 mrg print *, complex(i, x)
4156 1.1 mrg end program test_complex
4157 1.1 mrg @end smallexample
4158 1.1 mrg
4159 1.1 mrg @item @emph{See also}:
4160 1.1 mrg @ref{CMPLX}
4161 1.1 mrg @end table
4162 1.1 mrg
4163 1.1 mrg
4164 1.1 mrg
4165 1.1 mrg @node CONJG
4166 1.1 mrg @section @code{CONJG} --- Complex conjugate function
4167 1.1 mrg @fnindex CONJG
4168 1.1 mrg @fnindex DCONJG
4169 1.1 mrg @cindex complex conjugate
4170 1.1 mrg
4171 1.1 mrg @table @asis
4172 1.1 mrg @item @emph{Description}:
4173 1.1 mrg @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
4174 1.1 mrg then the result is @code{(x, -y)}
4175 1.1 mrg
4176 1.1 mrg @item @emph{Standard}:
4177 1.1.1.2 mrg Fortran 77 and later, has an overload that is a GNU extension
4178 1.1 mrg
4179 1.1 mrg @item @emph{Class}:
4180 1.1 mrg Elemental function
4181 1.1 mrg
4182 1.1 mrg @item @emph{Syntax}:
4183 1.1 mrg @code{Z = CONJG(Z)}
4184 1.1 mrg
4185 1.1 mrg @item @emph{Arguments}:
4186 1.1 mrg @multitable @columnfractions .15 .70
4187 1.1 mrg @item @var{Z} @tab The type shall be @code{COMPLEX}.
4188 1.1 mrg @end multitable
4189 1.1 mrg
4190 1.1 mrg @item @emph{Return value}:
4191 1.1 mrg The return value is of type @code{COMPLEX}.
4192 1.1 mrg
4193 1.1 mrg @item @emph{Example}:
4194 1.1 mrg @smallexample
4195 1.1 mrg program test_conjg
4196 1.1 mrg complex :: z = (2.0, 3.0)
4197 1.1 mrg complex(8) :: dz = (2.71_8, -3.14_8)
4198 1.1 mrg z= conjg(z)
4199 1.1 mrg print *, z
4200 1.1 mrg dz = dconjg(dz)
4201 1.1 mrg print *, dz
4202 1.1 mrg end program test_conjg
4203 1.1 mrg @end smallexample
4204 1.1 mrg
4205 1.1 mrg @item @emph{Specific names}:
4206 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
4207 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
4208 1.1 mrg @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
4209 1.1 mrg @end multitable
4210 1.1 mrg @end table
4211 1.1 mrg
4212 1.1 mrg
4213 1.1 mrg
4214 1.1 mrg @node COS
4215 1.1 mrg @section @code{COS} --- Cosine function
4216 1.1 mrg @fnindex COS
4217 1.1 mrg @fnindex DCOS
4218 1.1 mrg @fnindex CCOS
4219 1.1 mrg @fnindex ZCOS
4220 1.1 mrg @fnindex CDCOS
4221 1.1 mrg @cindex trigonometric function, cosine
4222 1.1 mrg @cindex cosine
4223 1.1 mrg
4224 1.1 mrg @table @asis
4225 1.1 mrg @item @emph{Description}:
4226 1.1 mrg @code{COS(X)} computes the cosine of @var{X}.
4227 1.1 mrg
4228 1.1 mrg @item @emph{Standard}:
4229 1.1 mrg Fortran 77 and later, has overloads that are GNU extensions
4230 1.1 mrg
4231 1.1 mrg @item @emph{Class}:
4232 1.1 mrg Elemental function
4233 1.1 mrg
4234 1.1 mrg @item @emph{Syntax}:
4235 1.1 mrg @code{RESULT = COS(X)}
4236 1.1 mrg
4237 1.1 mrg @item @emph{Arguments}:
4238 1.1 mrg @multitable @columnfractions .15 .70
4239 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or
4240 1.1 mrg @code{COMPLEX}.
4241 1.1 mrg @end multitable
4242 1.1 mrg
4243 1.1 mrg @item @emph{Return value}:
4244 1.1 mrg The return value is of the same type and kind as @var{X}. The real part
4245 1.1 mrg of the result is in radians. If @var{X} is of the type @code{REAL},
4246 1.1 mrg the return value lies in the range @math{ -1 \leq \cos (x) \leq 1}.
4247 1.1 mrg
4248 1.1 mrg @item @emph{Example}:
4249 1.1 mrg @smallexample
4250 1.1 mrg program test_cos
4251 1.1 mrg real :: x = 0.0
4252 1.1 mrg x = cos(x)
4253 1.1 mrg end program test_cos
4254 1.1 mrg @end smallexample
4255 1.1 mrg
4256 1.1 mrg @item @emph{Specific names}:
4257 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
4258 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
4259 1.1 mrg @item @code{COS(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
4260 1.1 mrg @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
4261 1.1 mrg @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
4262 1.1 mrg @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4263 1.1 mrg @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4264 1.1 mrg @end multitable
4265 1.1 mrg
4266 1.1 mrg @item @emph{See also}:
4267 1.1.1.2 mrg Inverse function: @gol
4268 1.1.1.2 mrg @ref{ACOS} @gol
4269 1.1.1.2 mrg Degrees function: @gol
4270 1.1.1.2 mrg @ref{COSD}
4271 1.1 mrg @end table
4272 1.1 mrg
4273 1.1 mrg
4274 1.1 mrg
4275 1.1 mrg @node COSD
4276 1.1 mrg @section @code{COSD} --- Cosine function, degrees
4277 1.1 mrg @fnindex COSD
4278 1.1 mrg @fnindex DCOSD
4279 1.1 mrg @fnindex CCOSD
4280 1.1 mrg @fnindex ZCOSD
4281 1.1 mrg @fnindex CDCOSD
4282 1.1 mrg @cindex trigonometric function, cosine, degrees
4283 1.1 mrg @cindex cosine, degrees
4284 1.1 mrg
4285 1.1 mrg @table @asis
4286 1.1 mrg @item @emph{Description}:
4287 1.1 mrg @code{COSD(X)} computes the cosine of @var{X} in degrees.
4288 1.1 mrg
4289 1.1 mrg This function is for compatibility only and should be avoided in favor of
4290 1.1 mrg standard constructs wherever possible.
4291 1.1 mrg
4292 1.1 mrg @item @emph{Standard}:
4293 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math}.
4294 1.1 mrg
4295 1.1 mrg @item @emph{Class}:
4296 1.1 mrg Elemental function
4297 1.1 mrg
4298 1.1 mrg @item @emph{Syntax}:
4299 1.1 mrg @code{RESULT = COSD(X)}
4300 1.1 mrg
4301 1.1 mrg @item @emph{Arguments}:
4302 1.1 mrg @multitable @columnfractions .15 .70
4303 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or
4304 1.1 mrg @code{COMPLEX}.
4305 1.1 mrg @end multitable
4306 1.1 mrg
4307 1.1 mrg @item @emph{Return value}:
4308 1.1 mrg The return value is of the same type and kind as @var{X}. The real part
4309 1.1 mrg of the result is in degrees. If @var{X} is of the type @code{REAL},
4310 1.1 mrg the return value lies in the range @math{ -1 \leq \cosd (x) \leq 1}.
4311 1.1 mrg
4312 1.1 mrg @item @emph{Example}:
4313 1.1 mrg @smallexample
4314 1.1 mrg program test_cosd
4315 1.1 mrg real :: x = 0.0
4316 1.1 mrg x = cosd(x)
4317 1.1 mrg end program test_cosd
4318 1.1 mrg @end smallexample
4319 1.1 mrg
4320 1.1 mrg @item @emph{Specific names}:
4321 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
4322 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
4323 1.1.1.2 mrg @item @code{COSD(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
4324 1.1.1.2 mrg @item @code{DCOSD(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
4325 1.1.1.2 mrg @item @code{CCOSD(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab GNU extension
4326 1.1 mrg @item @code{ZCOSD(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4327 1.1 mrg @item @code{CDCOSD(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4328 1.1 mrg @end multitable
4329 1.1 mrg
4330 1.1 mrg @item @emph{See also}:
4331 1.1.1.2 mrg Inverse function: @gol
4332 1.1.1.2 mrg @ref{ACOSD} @gol
4333 1.1.1.2 mrg Radians function: @gol
4334 1.1.1.2 mrg @ref{COS}
4335 1.1 mrg @end table
4336 1.1 mrg
4337 1.1 mrg
4338 1.1 mrg
4339 1.1 mrg @node COSH
4340 1.1 mrg @section @code{COSH} --- Hyperbolic cosine function
4341 1.1 mrg @fnindex COSH
4342 1.1 mrg @fnindex DCOSH
4343 1.1 mrg @cindex hyperbolic cosine
4344 1.1 mrg @cindex hyperbolic function, cosine
4345 1.1 mrg @cindex cosine, hyperbolic
4346 1.1 mrg
4347 1.1 mrg @table @asis
4348 1.1 mrg @item @emph{Description}:
4349 1.1 mrg @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
4350 1.1 mrg
4351 1.1 mrg @item @emph{Standard}:
4352 1.1 mrg Fortran 77 and later, for a complex argument Fortran 2008 or later
4353 1.1 mrg
4354 1.1 mrg @item @emph{Class}:
4355 1.1 mrg Elemental function
4356 1.1 mrg
4357 1.1 mrg @item @emph{Syntax}:
4358 1.1 mrg @code{X = COSH(X)}
4359 1.1 mrg
4360 1.1 mrg @item @emph{Arguments}:
4361 1.1 mrg @multitable @columnfractions .15 .70
4362 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
4363 1.1 mrg @end multitable
4364 1.1 mrg
4365 1.1 mrg @item @emph{Return value}:
4366 1.1 mrg The return value has same type and kind as @var{X}. If @var{X} is
4367 1.1 mrg complex, the imaginary part of the result is in radians. If @var{X}
4368 1.1 mrg is @code{REAL}, the return value has a lower bound of one,
4369 1.1 mrg @math{\cosh (x) \geq 1}.
4370 1.1 mrg
4371 1.1 mrg @item @emph{Example}:
4372 1.1 mrg @smallexample
4373 1.1 mrg program test_cosh
4374 1.1 mrg real(8) :: x = 1.0_8
4375 1.1 mrg x = cosh(x)
4376 1.1 mrg end program test_cosh
4377 1.1 mrg @end smallexample
4378 1.1 mrg
4379 1.1 mrg @item @emph{Specific names}:
4380 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
4381 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
4382 1.1 mrg @item @code{COSH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
4383 1.1 mrg @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
4384 1.1 mrg @end multitable
4385 1.1 mrg
4386 1.1 mrg @item @emph{See also}:
4387 1.1.1.2 mrg Inverse function: @gol
4388 1.1.1.2 mrg @ref{ACOSH}
4389 1.1 mrg @end table
4390 1.1 mrg
4391 1.1 mrg
4392 1.1 mrg
4393 1.1 mrg @node COTAN
4394 1.1 mrg @section @code{COTAN} --- Cotangent function
4395 1.1 mrg @fnindex COTAN
4396 1.1 mrg @fnindex DCOTAN
4397 1.1 mrg @cindex trigonometric function, cotangent
4398 1.1 mrg @cindex cotangent
4399 1.1 mrg
4400 1.1 mrg @table @asis
4401 1.1 mrg @item @emph{Description}:
4402 1.1 mrg @code{COTAN(X)} computes the cotangent of @var{X}. Equivalent to @code{COS(x)}
4403 1.1 mrg divided by @code{SIN(x)}, or @code{1 / TAN(x)}.
4404 1.1 mrg
4405 1.1 mrg This function is for compatibility only and should be avoided in favor of
4406 1.1 mrg standard constructs wherever possible.
4407 1.1 mrg
4408 1.1 mrg @item @emph{Standard}:
4409 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math}.
4410 1.1 mrg
4411 1.1 mrg @item @emph{Class}:
4412 1.1 mrg Elemental function
4413 1.1 mrg
4414 1.1 mrg @item @emph{Syntax}:
4415 1.1 mrg @code{RESULT = COTAN(X)}
4416 1.1 mrg
4417 1.1 mrg @item @emph{Arguments}:
4418 1.1 mrg @multitable @columnfractions .15 .70
4419 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
4420 1.1 mrg @end multitable
4421 1.1 mrg
4422 1.1 mrg @item @emph{Return value}:
4423 1.1 mrg The return value has same type and kind as @var{X}, and its value is in radians.
4424 1.1 mrg
4425 1.1 mrg @item @emph{Example}:
4426 1.1 mrg @smallexample
4427 1.1 mrg program test_cotan
4428 1.1 mrg real(8) :: x = 0.165_8
4429 1.1 mrg x = cotan(x)
4430 1.1 mrg end program test_cotan
4431 1.1 mrg @end smallexample
4432 1.1 mrg
4433 1.1 mrg @item @emph{Specific names}:
4434 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
4435 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
4436 1.1.1.2 mrg @item @code{COTAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
4437 1.1.1.2 mrg @item @code{DCOTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
4438 1.1 mrg @end multitable
4439 1.1 mrg
4440 1.1 mrg @item @emph{See also}:
4441 1.1.1.2 mrg Converse function: @gol
4442 1.1.1.2 mrg @ref{TAN} @gol
4443 1.1.1.2 mrg Degrees function: @gol
4444 1.1.1.2 mrg @ref{COTAND}
4445 1.1 mrg @end table
4446 1.1 mrg
4447 1.1 mrg
4448 1.1 mrg
4449 1.1 mrg @node COTAND
4450 1.1 mrg @section @code{COTAND} --- Cotangent function, degrees
4451 1.1 mrg @fnindex COTAND
4452 1.1 mrg @fnindex DCOTAND
4453 1.1 mrg @cindex trigonometric function, cotangent, degrees
4454 1.1 mrg @cindex cotangent, degrees
4455 1.1 mrg
4456 1.1 mrg @table @asis
4457 1.1 mrg @item @emph{Description}:
4458 1.1 mrg @code{COTAND(X)} computes the cotangent of @var{X} in degrees. Equivalent to
4459 1.1 mrg @code{COSD(x)} divided by @code{SIND(x)}, or @code{1 / TAND(x)}.
4460 1.1 mrg
4461 1.1 mrg @item @emph{Standard}:
4462 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math}.
4463 1.1 mrg
4464 1.1 mrg This function is for compatibility only and should be avoided in favor of
4465 1.1 mrg standard constructs wherever possible.
4466 1.1 mrg
4467 1.1 mrg @item @emph{Class}:
4468 1.1 mrg Elemental function
4469 1.1 mrg
4470 1.1 mrg @item @emph{Syntax}:
4471 1.1 mrg @code{RESULT = COTAND(X)}
4472 1.1 mrg
4473 1.1 mrg @item @emph{Arguments}:
4474 1.1 mrg @multitable @columnfractions .15 .70
4475 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
4476 1.1 mrg @end multitable
4477 1.1 mrg
4478 1.1 mrg @item @emph{Return value}:
4479 1.1 mrg The return value has same type and kind as @var{X}, and its value is in degrees.
4480 1.1 mrg
4481 1.1 mrg @item @emph{Example}:
4482 1.1 mrg @smallexample
4483 1.1 mrg program test_cotand
4484 1.1 mrg real(8) :: x = 0.165_8
4485 1.1 mrg x = cotand(x)
4486 1.1 mrg end program test_cotand
4487 1.1 mrg @end smallexample
4488 1.1 mrg
4489 1.1 mrg @item @emph{Specific names}:
4490 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
4491 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
4492 1.1.1.2 mrg @item @code{COTAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
4493 1.1.1.2 mrg @item @code{DCOTAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
4494 1.1 mrg @end multitable
4495 1.1 mrg
4496 1.1 mrg @item @emph{See also}:
4497 1.1.1.2 mrg Converse function: @gol
4498 1.1.1.2 mrg @ref{TAND} @gol
4499 1.1.1.2 mrg Radians function: @gol
4500 1.1.1.2 mrg @ref{COTAN}
4501 1.1 mrg @end table
4502 1.1 mrg
4503 1.1 mrg
4504 1.1 mrg
4505 1.1 mrg @node COUNT
4506 1.1 mrg @section @code{COUNT} --- Count function
4507 1.1 mrg @fnindex COUNT
4508 1.1 mrg @cindex array, conditionally count elements
4509 1.1 mrg @cindex array, element counting
4510 1.1 mrg @cindex array, number of elements
4511 1.1 mrg
4512 1.1 mrg @table @asis
4513 1.1 mrg @item @emph{Description}:
4514 1.1 mrg
4515 1.1 mrg Counts the number of @code{.TRUE.} elements in a logical @var{MASK},
4516 1.1 mrg or, if the @var{DIM} argument is supplied, counts the number of
4517 1.1 mrg elements along each row of the array in the @var{DIM} direction.
4518 1.1 mrg If the array has zero size, or all of the elements of @var{MASK} are
4519 1.1 mrg @code{.FALSE.}, then the result is @code{0}.
4520 1.1 mrg
4521 1.1 mrg @item @emph{Standard}:
4522 1.1.1.2 mrg Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later
4523 1.1 mrg
4524 1.1 mrg @item @emph{Class}:
4525 1.1 mrg Transformational function
4526 1.1 mrg
4527 1.1 mrg @item @emph{Syntax}:
4528 1.1 mrg @code{RESULT = COUNT(MASK [, DIM, KIND])}
4529 1.1 mrg
4530 1.1 mrg @item @emph{Arguments}:
4531 1.1 mrg @multitable @columnfractions .15 .70
4532 1.1 mrg @item @var{MASK} @tab The type shall be @code{LOGICAL}.
4533 1.1 mrg @item @var{DIM} @tab (Optional) The type shall be @code{INTEGER}.
4534 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
4535 1.1 mrg expression indicating the kind parameter of the result.
4536 1.1 mrg @end multitable
4537 1.1 mrg
4538 1.1 mrg @item @emph{Return value}:
4539 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
4540 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
4541 1.1 mrg If @var{DIM} is present, the result is an array with a rank one less
4542 1.1 mrg than the rank of @var{ARRAY}, and a size corresponding to the shape
4543 1.1 mrg of @var{ARRAY} with the @var{DIM} dimension removed.
4544 1.1 mrg
4545 1.1 mrg @item @emph{Example}:
4546 1.1 mrg @smallexample
4547 1.1 mrg program test_count
4548 1.1 mrg integer, dimension(2,3) :: a, b
4549 1.1 mrg logical, dimension(2,3) :: mask
4550 1.1 mrg a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
4551 1.1 mrg b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
4552 1.1 mrg print '(3i3)', a(1,:)
4553 1.1 mrg print '(3i3)', a(2,:)
4554 1.1 mrg print *
4555 1.1 mrg print '(3i3)', b(1,:)
4556 1.1 mrg print '(3i3)', b(2,:)
4557 1.1 mrg print *
4558 1.1 mrg mask = a.ne.b
4559 1.1 mrg print '(3l3)', mask(1,:)
4560 1.1 mrg print '(3l3)', mask(2,:)
4561 1.1 mrg print *
4562 1.1 mrg print '(3i3)', count(mask)
4563 1.1 mrg print *
4564 1.1 mrg print '(3i3)', count(mask, 1)
4565 1.1 mrg print *
4566 1.1 mrg print '(3i3)', count(mask, 2)
4567 1.1 mrg end program test_count
4568 1.1 mrg @end smallexample
4569 1.1 mrg @end table
4570 1.1 mrg
4571 1.1 mrg
4572 1.1 mrg
4573 1.1 mrg @node CPU_TIME
4574 1.1 mrg @section @code{CPU_TIME} --- CPU elapsed time in seconds
4575 1.1 mrg @fnindex CPU_TIME
4576 1.1 mrg @cindex time, elapsed
4577 1.1 mrg
4578 1.1 mrg @table @asis
4579 1.1 mrg @item @emph{Description}:
4580 1.1 mrg Returns a @code{REAL} value representing the elapsed CPU time in
4581 1.1 mrg seconds. This is useful for testing segments of code to determine
4582 1.1 mrg execution time.
4583 1.1 mrg
4584 1.1 mrg If a time source is available, time will be reported with microsecond
4585 1.1 mrg resolution. If no time source is available, @var{TIME} is set to
4586 1.1 mrg @code{-1.0}.
4587 1.1 mrg
4588 1.1 mrg Note that @var{TIME} may contain a, system dependent, arbitrary offset
4589 1.1 mrg and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute
4590 1.1 mrg value is meaningless, only differences between subsequent calls to
4591 1.1 mrg this subroutine, as shown in the example below, should be used.
4592 1.1 mrg
4593 1.1 mrg
4594 1.1 mrg @item @emph{Standard}:
4595 1.1 mrg Fortran 95 and later
4596 1.1 mrg
4597 1.1 mrg @item @emph{Class}:
4598 1.1 mrg Subroutine
4599 1.1 mrg
4600 1.1 mrg @item @emph{Syntax}:
4601 1.1 mrg @code{CALL CPU_TIME(TIME)}
4602 1.1 mrg
4603 1.1 mrg @item @emph{Arguments}:
4604 1.1 mrg @multitable @columnfractions .15 .70
4605 1.1 mrg @item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
4606 1.1 mrg @end multitable
4607 1.1 mrg
4608 1.1 mrg @item @emph{Return value}:
4609 1.1 mrg None
4610 1.1 mrg
4611 1.1 mrg @item @emph{Example}:
4612 1.1 mrg @smallexample
4613 1.1 mrg program test_cpu_time
4614 1.1 mrg real :: start, finish
4615 1.1 mrg call cpu_time(start)
4616 1.1 mrg ! put code to test here
4617 1.1 mrg call cpu_time(finish)
4618 1.1 mrg print '("Time = ",f6.3," seconds.")',finish-start
4619 1.1 mrg end program test_cpu_time
4620 1.1 mrg @end smallexample
4621 1.1 mrg
4622 1.1 mrg @item @emph{See also}:
4623 1.1.1.2 mrg @ref{SYSTEM_CLOCK}, @gol
4624 1.1.1.2 mrg @ref{DATE_AND_TIME}
4625 1.1 mrg @end table
4626 1.1 mrg
4627 1.1 mrg
4628 1.1 mrg
4629 1.1 mrg @node CSHIFT
4630 1.1 mrg @section @code{CSHIFT} --- Circular shift elements of an array
4631 1.1 mrg @fnindex CSHIFT
4632 1.1 mrg @cindex array, shift circularly
4633 1.1 mrg @cindex array, permutation
4634 1.1 mrg @cindex array, rotate
4635 1.1 mrg
4636 1.1 mrg @table @asis
4637 1.1 mrg @item @emph{Description}:
4638 1.1 mrg @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
4639 1.1 mrg @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
4640 1.1 mrg taken to be @code{1}. @var{DIM} is a scalar of type @code{INTEGER} in the
4641 1.1 mrg range of @math{1 \leq DIM \leq n)} where @math{n} is the rank of @var{ARRAY}.
4642 1.1 mrg If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
4643 1.1 mrg by @var{SHIFT} places. If rank is greater than one, then all complete rank one
4644 1.1 mrg sections of @var{ARRAY} along the given dimension are shifted. Elements
4645 1.1 mrg shifted out one end of each rank one section are shifted back in the other end.
4646 1.1 mrg
4647 1.1 mrg @item @emph{Standard}:
4648 1.1.1.2 mrg Fortran 90 and later
4649 1.1 mrg
4650 1.1 mrg @item @emph{Class}:
4651 1.1 mrg Transformational function
4652 1.1 mrg
4653 1.1 mrg @item @emph{Syntax}:
4654 1.1 mrg @code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])}
4655 1.1 mrg
4656 1.1 mrg @item @emph{Arguments}:
4657 1.1 mrg @multitable @columnfractions .15 .70
4658 1.1 mrg @item @var{ARRAY} @tab Shall be an array of any type.
4659 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
4660 1.1 mrg @item @var{DIM} @tab The type shall be @code{INTEGER}.
4661 1.1 mrg @end multitable
4662 1.1 mrg
4663 1.1 mrg @item @emph{Return value}:
4664 1.1 mrg Returns an array of same type and rank as the @var{ARRAY} argument.
4665 1.1 mrg
4666 1.1 mrg @item @emph{Example}:
4667 1.1 mrg @smallexample
4668 1.1 mrg program test_cshift
4669 1.1 mrg integer, dimension(3,3) :: a
4670 1.1 mrg a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
4671 1.1 mrg print '(3i3)', a(1,:)
4672 1.1 mrg print '(3i3)', a(2,:)
4673 1.1 mrg print '(3i3)', a(3,:)
4674 1.1 mrg a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
4675 1.1 mrg print *
4676 1.1 mrg print '(3i3)', a(1,:)
4677 1.1 mrg print '(3i3)', a(2,:)
4678 1.1 mrg print '(3i3)', a(3,:)
4679 1.1 mrg end program test_cshift
4680 1.1 mrg @end smallexample
4681 1.1 mrg @end table
4682 1.1 mrg
4683 1.1 mrg
4684 1.1 mrg
4685 1.1 mrg @node CTIME
4686 1.1 mrg @section @code{CTIME} --- Convert a time into a string
4687 1.1 mrg @fnindex CTIME
4688 1.1 mrg @cindex time, conversion to string
4689 1.1 mrg @cindex conversion, to string
4690 1.1 mrg
4691 1.1 mrg @table @asis
4692 1.1 mrg @item @emph{Description}:
4693 1.1 mrg @code{CTIME} converts a system time value, such as returned by
4694 1.1 mrg @ref{TIME8}, to a string. The output will be of the form @samp{Sat
4695 1.1 mrg Aug 19 18:13:14 1995}.
4696 1.1 mrg
4697 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
4698 1.1 mrg only one form can be used in any given program unit.
4699 1.1 mrg
4700 1.1 mrg @item @emph{Standard}:
4701 1.1 mrg GNU extension
4702 1.1 mrg
4703 1.1 mrg @item @emph{Class}:
4704 1.1 mrg Subroutine, function
4705 1.1 mrg
4706 1.1 mrg @item @emph{Syntax}:
4707 1.1 mrg @multitable @columnfractions .80
4708 1.1 mrg @item @code{CALL CTIME(TIME, RESULT)}.
4709 1.1 mrg @item @code{RESULT = CTIME(TIME)}.
4710 1.1 mrg @end multitable
4711 1.1 mrg
4712 1.1 mrg @item @emph{Arguments}:
4713 1.1 mrg @multitable @columnfractions .15 .70
4714 1.1 mrg @item @var{TIME} @tab The type shall be of type @code{INTEGER}.
4715 1.1 mrg @item @var{RESULT} @tab The type shall be of type @code{CHARACTER} and
4716 1.1 mrg of default kind. It is an @code{INTENT(OUT)} argument. If the length
4717 1.1 mrg of this variable is too short for the time and date string to fit
4718 1.1 mrg completely, it will be blank on procedure return.
4719 1.1 mrg @end multitable
4720 1.1 mrg
4721 1.1 mrg @item @emph{Return value}:
4722 1.1 mrg The converted date and time as a string.
4723 1.1 mrg
4724 1.1 mrg @item @emph{Example}:
4725 1.1 mrg @smallexample
4726 1.1 mrg program test_ctime
4727 1.1 mrg integer(8) :: i
4728 1.1 mrg character(len=30) :: date
4729 1.1 mrg i = time8()
4730 1.1 mrg
4731 1.1 mrg ! Do something, main part of the program
4732 1.1 mrg
4733 1.1 mrg call ctime(i,date)
4734 1.1 mrg print *, 'Program was started on ', date
4735 1.1 mrg end program test_ctime
4736 1.1 mrg @end smallexample
4737 1.1 mrg
4738 1.1 mrg @item @emph{See Also}:
4739 1.1.1.2 mrg @ref{DATE_AND_TIME}, @gol
4740 1.1.1.2 mrg @ref{GMTIME}, @gol
4741 1.1.1.2 mrg @ref{LTIME}, @gol
4742 1.1.1.2 mrg @ref{TIME}, @gol
4743 1.1.1.2 mrg @ref{TIME8}
4744 1.1 mrg @end table
4745 1.1 mrg
4746 1.1 mrg
4747 1.1 mrg
4748 1.1 mrg @node DATE_AND_TIME
4749 1.1 mrg @section @code{DATE_AND_TIME} --- Date and time subroutine
4750 1.1 mrg @fnindex DATE_AND_TIME
4751 1.1 mrg @cindex date, current
4752 1.1 mrg @cindex current date
4753 1.1 mrg @cindex time, current
4754 1.1 mrg @cindex current time
4755 1.1 mrg
4756 1.1 mrg @table @asis
4757 1.1 mrg @item @emph{Description}:
4758 1.1 mrg @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
4759 1.1 mrg time information from the real-time system clock. @var{DATE} is
4760 1.1 mrg @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
4761 1.1 mrg has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
4762 1.1 mrg representing the difference with respect to Coordinated Universal Time (UTC).
4763 1.1 mrg Unavailable time and date parameters return blanks.
4764 1.1 mrg
4765 1.1 mrg @var{VALUES} is @code{INTENT(OUT)} and provides the following:
4766 1.1 mrg
4767 1.1 mrg @multitable @columnfractions .15 .30 .40
4768 1.1 mrg @item @tab @code{VALUE(1)}: @tab The year
4769 1.1 mrg @item @tab @code{VALUE(2)}: @tab The month
4770 1.1 mrg @item @tab @code{VALUE(3)}: @tab The day of the month
4771 1.1 mrg @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
4772 1.1 mrg @item @tab @code{VALUE(5)}: @tab The hour of the day
4773 1.1 mrg @item @tab @code{VALUE(6)}: @tab The minutes of the hour
4774 1.1 mrg @item @tab @code{VALUE(7)}: @tab The seconds of the minute
4775 1.1 mrg @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
4776 1.1 mrg @end multitable
4777 1.1 mrg
4778 1.1 mrg @item @emph{Standard}:
4779 1.1.1.2 mrg Fortran 90 and later
4780 1.1 mrg
4781 1.1 mrg @item @emph{Class}:
4782 1.1 mrg Subroutine
4783 1.1 mrg
4784 1.1 mrg @item @emph{Syntax}:
4785 1.1 mrg @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
4786 1.1 mrg
4787 1.1 mrg @item @emph{Arguments}:
4788 1.1 mrg @multitable @columnfractions .15 .70
4789 1.1 mrg @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(LEN=8)}
4790 1.1 mrg or larger, and of default kind.
4791 1.1 mrg @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(LEN=10)}
4792 1.1 mrg or larger, and of default kind.
4793 1.1 mrg @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(LEN=5)}
4794 1.1 mrg or larger, and of default kind.
4795 1.1 mrg @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
4796 1.1 mrg @end multitable
4797 1.1 mrg
4798 1.1 mrg @item @emph{Return value}:
4799 1.1 mrg None
4800 1.1 mrg
4801 1.1 mrg @item @emph{Example}:
4802 1.1 mrg @smallexample
4803 1.1 mrg program test_time_and_date
4804 1.1 mrg character(8) :: date
4805 1.1 mrg character(10) :: time
4806 1.1 mrg character(5) :: zone
4807 1.1 mrg integer,dimension(8) :: values
4808 1.1 mrg ! using keyword arguments
4809 1.1 mrg call date_and_time(date,time,zone,values)
4810 1.1 mrg call date_and_time(DATE=date,ZONE=zone)
4811 1.1 mrg call date_and_time(TIME=time)
4812 1.1 mrg call date_and_time(VALUES=values)
4813 1.1 mrg print '(a,2x,a,2x,a)', date, time, zone
4814 1.1 mrg print '(8i5)', values
4815 1.1 mrg end program test_time_and_date
4816 1.1 mrg @end smallexample
4817 1.1 mrg
4818 1.1 mrg @item @emph{See also}:
4819 1.1.1.2 mrg @ref{CPU_TIME}, @gol
4820 1.1.1.2 mrg @ref{SYSTEM_CLOCK}
4821 1.1 mrg @end table
4822 1.1 mrg
4823 1.1 mrg
4824 1.1 mrg
4825 1.1 mrg @node DBLE
4826 1.1 mrg @section @code{DBLE} --- Double conversion function
4827 1.1 mrg @fnindex DBLE
4828 1.1 mrg @cindex conversion, to real
4829 1.1 mrg
4830 1.1 mrg @table @asis
4831 1.1 mrg @item @emph{Description}:
4832 1.1 mrg @code{DBLE(A)} Converts @var{A} to double precision real type.
4833 1.1 mrg
4834 1.1 mrg @item @emph{Standard}:
4835 1.1 mrg Fortran 77 and later
4836 1.1 mrg
4837 1.1 mrg @item @emph{Class}:
4838 1.1 mrg Elemental function
4839 1.1 mrg
4840 1.1 mrg @item @emph{Syntax}:
4841 1.1 mrg @code{RESULT = DBLE(A)}
4842 1.1 mrg
4843 1.1 mrg @item @emph{Arguments}:
4844 1.1 mrg @multitable @columnfractions .15 .70
4845 1.1 mrg @item @var{A} @tab The type shall be @code{INTEGER}, @code{REAL},
4846 1.1 mrg or @code{COMPLEX}.
4847 1.1 mrg @end multitable
4848 1.1 mrg
4849 1.1 mrg @item @emph{Return value}:
4850 1.1 mrg The return value is of type double precision real.
4851 1.1 mrg
4852 1.1 mrg @item @emph{Example}:
4853 1.1 mrg @smallexample
4854 1.1 mrg program test_dble
4855 1.1 mrg real :: x = 2.18
4856 1.1 mrg integer :: i = 5
4857 1.1 mrg complex :: z = (2.3,1.14)
4858 1.1 mrg print *, dble(x), dble(i), dble(z)
4859 1.1 mrg end program test_dble
4860 1.1 mrg @end smallexample
4861 1.1 mrg
4862 1.1 mrg @item @emph{See also}:
4863 1.1 mrg @ref{REAL}
4864 1.1 mrg @end table
4865 1.1 mrg
4866 1.1 mrg
4867 1.1 mrg
4868 1.1 mrg @node DCMPLX
4869 1.1 mrg @section @code{DCMPLX} --- Double complex conversion function
4870 1.1 mrg @fnindex DCMPLX
4871 1.1 mrg @cindex complex numbers, conversion to
4872 1.1 mrg @cindex conversion, to complex
4873 1.1 mrg
4874 1.1 mrg @table @asis
4875 1.1 mrg @item @emph{Description}:
4876 1.1 mrg @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
4877 1.1 mrg converted to the real component. If @var{Y} is present it is converted to the
4878 1.1 mrg imaginary component. If @var{Y} is not present then the imaginary component is
4879 1.1 mrg set to 0.0. If @var{X} is complex then @var{Y} must not be present.
4880 1.1 mrg
4881 1.1 mrg @item @emph{Standard}:
4882 1.1 mrg GNU extension
4883 1.1 mrg
4884 1.1 mrg @item @emph{Class}:
4885 1.1 mrg Elemental function
4886 1.1 mrg
4887 1.1 mrg @item @emph{Syntax}:
4888 1.1 mrg @code{RESULT = DCMPLX(X [, Y])}
4889 1.1 mrg
4890 1.1 mrg @item @emph{Arguments}:
4891 1.1 mrg @multitable @columnfractions .15 .70
4892 1.1 mrg @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
4893 1.1 mrg or @code{COMPLEX}.
4894 1.1 mrg @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX}.) May be
4895 1.1 mrg @code{INTEGER} or @code{REAL}.
4896 1.1 mrg @end multitable
4897 1.1 mrg
4898 1.1 mrg @item @emph{Return value}:
4899 1.1 mrg The return value is of type @code{COMPLEX(8)}
4900 1.1 mrg
4901 1.1 mrg @item @emph{Example}:
4902 1.1 mrg @smallexample
4903 1.1 mrg program test_dcmplx
4904 1.1 mrg integer :: i = 42
4905 1.1 mrg real :: x = 3.14
4906 1.1 mrg complex :: z
4907 1.1 mrg z = cmplx(i, x)
4908 1.1 mrg print *, dcmplx(i)
4909 1.1 mrg print *, dcmplx(x)
4910 1.1 mrg print *, dcmplx(z)
4911 1.1 mrg print *, dcmplx(x,i)
4912 1.1 mrg end program test_dcmplx
4913 1.1 mrg @end smallexample
4914 1.1 mrg @end table
4915 1.1 mrg
4916 1.1 mrg
4917 1.1 mrg @node DIGITS
4918 1.1 mrg @section @code{DIGITS} --- Significant binary digits function
4919 1.1 mrg @fnindex DIGITS
4920 1.1 mrg @cindex model representation, significant digits
4921 1.1 mrg
4922 1.1 mrg @table @asis
4923 1.1 mrg @item @emph{Description}:
4924 1.1 mrg @code{DIGITS(X)} returns the number of significant binary digits of the internal
4925 1.1 mrg model representation of @var{X}. For example, on a system using a 32-bit
4926 1.1 mrg floating point representation, a default real number would likely return 24.
4927 1.1 mrg
4928 1.1 mrg @item @emph{Standard}:
4929 1.1.1.2 mrg Fortran 90 and later
4930 1.1 mrg
4931 1.1 mrg @item @emph{Class}:
4932 1.1 mrg Inquiry function
4933 1.1 mrg
4934 1.1 mrg @item @emph{Syntax}:
4935 1.1 mrg @code{RESULT = DIGITS(X)}
4936 1.1 mrg
4937 1.1 mrg @item @emph{Arguments}:
4938 1.1 mrg @multitable @columnfractions .15 .70
4939 1.1 mrg @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
4940 1.1 mrg @end multitable
4941 1.1 mrg
4942 1.1 mrg @item @emph{Return value}:
4943 1.1 mrg The return value is of type @code{INTEGER}.
4944 1.1 mrg
4945 1.1 mrg @item @emph{Example}:
4946 1.1 mrg @smallexample
4947 1.1 mrg program test_digits
4948 1.1 mrg integer :: i = 12345
4949 1.1 mrg real :: x = 3.143
4950 1.1 mrg real(8) :: y = 2.33
4951 1.1 mrg print *, digits(i)
4952 1.1 mrg print *, digits(x)
4953 1.1 mrg print *, digits(y)
4954 1.1 mrg end program test_digits
4955 1.1 mrg @end smallexample
4956 1.1 mrg @end table
4957 1.1 mrg
4958 1.1 mrg
4959 1.1 mrg
4960 1.1 mrg @node DIM
4961 1.1 mrg @section @code{DIM} --- Positive difference
4962 1.1 mrg @fnindex DIM
4963 1.1 mrg @fnindex IDIM
4964 1.1 mrg @fnindex DDIM
4965 1.1 mrg @cindex positive difference
4966 1.1 mrg
4967 1.1 mrg @table @asis
4968 1.1 mrg @item @emph{Description}:
4969 1.1 mrg @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
4970 1.1 mrg otherwise returns zero.
4971 1.1 mrg
4972 1.1 mrg @item @emph{Standard}:
4973 1.1 mrg Fortran 77 and later
4974 1.1 mrg
4975 1.1 mrg @item @emph{Class}:
4976 1.1 mrg Elemental function
4977 1.1 mrg
4978 1.1 mrg @item @emph{Syntax}:
4979 1.1 mrg @code{RESULT = DIM(X, Y)}
4980 1.1 mrg
4981 1.1 mrg @item @emph{Arguments}:
4982 1.1 mrg @multitable @columnfractions .15 .70
4983 1.1 mrg @item @var{X} @tab The type shall be @code{INTEGER} or @code{REAL}
4984 1.1.1.2 mrg @item @var{Y} @tab The type shall be the same type and kind as @var{X}. (As
4985 1.1.1.2 mrg a GNU extension, arguments of different kinds are permitted.)
4986 1.1 mrg @end multitable
4987 1.1 mrg
4988 1.1 mrg @item @emph{Return value}:
4989 1.1.1.2 mrg The return value is of type @code{INTEGER} or @code{REAL}. (As a GNU
4990 1.1.1.2 mrg extension, kind is the largest kind of the actual arguments.)
4991 1.1 mrg
4992 1.1 mrg @item @emph{Example}:
4993 1.1 mrg @smallexample
4994 1.1 mrg program test_dim
4995 1.1 mrg integer :: i
4996 1.1 mrg real(8) :: x
4997 1.1 mrg i = dim(4, 15)
4998 1.1 mrg x = dim(4.345_8, 2.111_8)
4999 1.1 mrg print *, i
5000 1.1 mrg print *, x
5001 1.1 mrg end program test_dim
5002 1.1 mrg @end smallexample
5003 1.1 mrg
5004 1.1 mrg @item @emph{Specific names}:
5005 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
5006 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
5007 1.1 mrg @item @code{DIM(X,Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
5008 1.1 mrg @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X, Y} @tab @code{INTEGER(4)} @tab Fortran 77 and later
5009 1.1 mrg @item @code{DDIM(X,Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
5010 1.1 mrg @end multitable
5011 1.1 mrg @end table
5012 1.1 mrg
5013 1.1 mrg
5014 1.1 mrg
5015 1.1 mrg @node DOT_PRODUCT
5016 1.1 mrg @section @code{DOT_PRODUCT} --- Dot product function
5017 1.1 mrg @fnindex DOT_PRODUCT
5018 1.1 mrg @cindex dot product
5019 1.1 mrg @cindex vector product
5020 1.1 mrg @cindex product, vector
5021 1.1 mrg
5022 1.1 mrg @table @asis
5023 1.1 mrg @item @emph{Description}:
5024 1.1 mrg @code{DOT_PRODUCT(VECTOR_A, VECTOR_B)} computes the dot product multiplication
5025 1.1 mrg of two vectors @var{VECTOR_A} and @var{VECTOR_B}. The two vectors may be
5026 1.1 mrg either numeric or logical and must be arrays of rank one and of equal size. If
5027 1.1 mrg the vectors are @code{INTEGER} or @code{REAL}, the result is
5028 1.1 mrg @code{SUM(VECTOR_A*VECTOR_B)}. If the vectors are @code{COMPLEX}, the result
5029 1.1 mrg is @code{SUM(CONJG(VECTOR_A)*VECTOR_B)}. If the vectors are @code{LOGICAL},
5030 1.1 mrg the result is @code{ANY(VECTOR_A .AND. VECTOR_B)}.
5031 1.1 mrg
5032 1.1 mrg @item @emph{Standard}:
5033 1.1.1.2 mrg Fortran 90 and later
5034 1.1 mrg
5035 1.1 mrg @item @emph{Class}:
5036 1.1 mrg Transformational function
5037 1.1 mrg
5038 1.1 mrg @item @emph{Syntax}:
5039 1.1 mrg @code{RESULT = DOT_PRODUCT(VECTOR_A, VECTOR_B)}
5040 1.1 mrg
5041 1.1 mrg @item @emph{Arguments}:
5042 1.1 mrg @multitable @columnfractions .15 .70
5043 1.1 mrg @item @var{VECTOR_A} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
5044 1.1 mrg @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.
5045 1.1 mrg @end multitable
5046 1.1 mrg
5047 1.1 mrg @item @emph{Return value}:
5048 1.1 mrg If the arguments are numeric, the return value is a scalar of numeric type,
5049 1.1 mrg @code{INTEGER}, @code{REAL}, or @code{COMPLEX}. If the arguments are
5050 1.1 mrg @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
5051 1.1 mrg
5052 1.1 mrg @item @emph{Example}:
5053 1.1 mrg @smallexample
5054 1.1 mrg program test_dot_prod
5055 1.1 mrg integer, dimension(3) :: a, b
5056 1.1 mrg a = (/ 1, 2, 3 /)
5057 1.1 mrg b = (/ 4, 5, 6 /)
5058 1.1 mrg print '(3i3)', a
5059 1.1 mrg print *
5060 1.1 mrg print '(3i3)', b
5061 1.1 mrg print *
5062 1.1 mrg print *, dot_product(a,b)
5063 1.1 mrg end program test_dot_prod
5064 1.1 mrg @end smallexample
5065 1.1 mrg @end table
5066 1.1 mrg
5067 1.1 mrg
5068 1.1 mrg
5069 1.1 mrg @node DPROD
5070 1.1 mrg @section @code{DPROD} --- Double product function
5071 1.1 mrg @fnindex DPROD
5072 1.1 mrg @cindex product, double-precision
5073 1.1 mrg
5074 1.1 mrg @table @asis
5075 1.1 mrg @item @emph{Description}:
5076 1.1 mrg @code{DPROD(X,Y)} returns the product @code{X*Y}.
5077 1.1 mrg
5078 1.1 mrg @item @emph{Standard}:
5079 1.1 mrg Fortran 77 and later
5080 1.1 mrg
5081 1.1 mrg @item @emph{Class}:
5082 1.1 mrg Elemental function
5083 1.1 mrg
5084 1.1 mrg @item @emph{Syntax}:
5085 1.1 mrg @code{RESULT = DPROD(X, Y)}
5086 1.1 mrg
5087 1.1 mrg @item @emph{Arguments}:
5088 1.1 mrg @multitable @columnfractions .15 .70
5089 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
5090 1.1 mrg @item @var{Y} @tab The type shall be @code{REAL}.
5091 1.1 mrg @end multitable
5092 1.1 mrg
5093 1.1 mrg @item @emph{Return value}:
5094 1.1 mrg The return value is of type @code{REAL(8)}.
5095 1.1 mrg
5096 1.1 mrg @item @emph{Example}:
5097 1.1 mrg @smallexample
5098 1.1 mrg program test_dprod
5099 1.1 mrg real :: x = 5.2
5100 1.1 mrg real :: y = 2.3
5101 1.1 mrg real(8) :: d
5102 1.1 mrg d = dprod(x,y)
5103 1.1 mrg print *, d
5104 1.1 mrg end program test_dprod
5105 1.1 mrg @end smallexample
5106 1.1 mrg
5107 1.1 mrg @item @emph{Specific names}:
5108 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
5109 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
5110 1.1 mrg @item @code{DPROD(X,Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
5111 1.1 mrg @end multitable
5112 1.1 mrg
5113 1.1 mrg @end table
5114 1.1 mrg
5115 1.1 mrg
5116 1.1 mrg @node DREAL
5117 1.1 mrg @section @code{DREAL} --- Double real part function
5118 1.1 mrg @fnindex DREAL
5119 1.1 mrg @cindex complex numbers, real part
5120 1.1 mrg
5121 1.1 mrg @table @asis
5122 1.1 mrg @item @emph{Description}:
5123 1.1 mrg @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
5124 1.1 mrg
5125 1.1 mrg @item @emph{Standard}:
5126 1.1 mrg GNU extension
5127 1.1 mrg
5128 1.1 mrg @item @emph{Class}:
5129 1.1 mrg Elemental function
5130 1.1 mrg
5131 1.1 mrg @item @emph{Syntax}:
5132 1.1 mrg @code{RESULT = DREAL(A)}
5133 1.1 mrg
5134 1.1 mrg @item @emph{Arguments}:
5135 1.1 mrg @multitable @columnfractions .15 .70
5136 1.1 mrg @item @var{A} @tab The type shall be @code{COMPLEX(8)}.
5137 1.1 mrg @end multitable
5138 1.1 mrg
5139 1.1 mrg @item @emph{Return value}:
5140 1.1 mrg The return value is of type @code{REAL(8)}.
5141 1.1 mrg
5142 1.1 mrg @item @emph{Example}:
5143 1.1 mrg @smallexample
5144 1.1 mrg program test_dreal
5145 1.1 mrg complex(8) :: z = (1.3_8,7.2_8)
5146 1.1 mrg print *, dreal(z)
5147 1.1 mrg end program test_dreal
5148 1.1 mrg @end smallexample
5149 1.1 mrg
5150 1.1 mrg @item @emph{See also}:
5151 1.1 mrg @ref{AIMAG}
5152 1.1 mrg
5153 1.1 mrg @end table
5154 1.1 mrg
5155 1.1 mrg
5156 1.1 mrg
5157 1.1 mrg @node DSHIFTL
5158 1.1 mrg @section @code{DSHIFTL} --- Combined left shift
5159 1.1 mrg @fnindex DSHIFTL
5160 1.1 mrg @cindex left shift, combined
5161 1.1 mrg @cindex shift, left
5162 1.1 mrg
5163 1.1 mrg @table @asis
5164 1.1 mrg @item @emph{Description}:
5165 1.1 mrg @code{DSHIFTL(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
5166 1.1 mrg rightmost @var{SHIFT} bits of the result are the leftmost @var{SHIFT}
5167 1.1 mrg bits of @var{J}, and the remaining bits are the rightmost bits of
5168 1.1 mrg @var{I}.
5169 1.1 mrg
5170 1.1 mrg @item @emph{Standard}:
5171 1.1 mrg Fortran 2008 and later
5172 1.1 mrg
5173 1.1 mrg @item @emph{Class}:
5174 1.1 mrg Elemental function
5175 1.1 mrg
5176 1.1 mrg @item @emph{Syntax}:
5177 1.1 mrg @code{RESULT = DSHIFTL(I, J, SHIFT)}
5178 1.1 mrg
5179 1.1 mrg @item @emph{Arguments}:
5180 1.1 mrg @multitable @columnfractions .15 .70
5181 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5182 1.1 mrg @item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5183 1.1 mrg If both @var{I} and @var{J} have integer type, then they shall have
5184 1.1 mrg the same kind type parameter. @var{I} and @var{J} shall not both be
5185 1.1 mrg BOZ constants.
5186 1.1 mrg @item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall
5187 1.1 mrg be nonnegative. If @var{I} is not a BOZ constant, then @var{SHIFT}
5188 1.1 mrg shall be less than or equal to @code{BIT_SIZE(I)}; otherwise,
5189 1.1 mrg @var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}.
5190 1.1 mrg @end multitable
5191 1.1 mrg
5192 1.1 mrg @item @emph{Return value}:
5193 1.1 mrg If either @var{I} or @var{J} is a BOZ constant, it is first converted
5194 1.1 mrg as if by the intrinsic function @code{INT} to an integer type with the
5195 1.1 mrg kind type parameter of the other.
5196 1.1 mrg
5197 1.1 mrg @item @emph{See also}:
5198 1.1 mrg @ref{DSHIFTR}
5199 1.1 mrg @end table
5200 1.1 mrg
5201 1.1 mrg
5202 1.1 mrg @node DSHIFTR
5203 1.1 mrg @section @code{DSHIFTR} --- Combined right shift
5204 1.1 mrg @fnindex DSHIFTR
5205 1.1 mrg @cindex right shift, combined
5206 1.1 mrg @cindex shift, right
5207 1.1 mrg
5208 1.1 mrg @table @asis
5209 1.1 mrg @item @emph{Description}:
5210 1.1 mrg @code{DSHIFTR(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
5211 1.1 mrg leftmost @var{SHIFT} bits of the result are the rightmost @var{SHIFT}
5212 1.1 mrg bits of @var{I}, and the remaining bits are the leftmost bits of
5213 1.1 mrg @var{J}.
5214 1.1 mrg
5215 1.1 mrg @item @emph{Standard}:
5216 1.1 mrg Fortran 2008 and later
5217 1.1 mrg
5218 1.1 mrg @item @emph{Class}:
5219 1.1 mrg Elemental function
5220 1.1 mrg
5221 1.1 mrg @item @emph{Syntax}:
5222 1.1 mrg @code{RESULT = DSHIFTR(I, J, SHIFT)}
5223 1.1 mrg
5224 1.1 mrg @item @emph{Arguments}:
5225 1.1 mrg @multitable @columnfractions .15 .70
5226 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5227 1.1 mrg @item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5228 1.1 mrg If both @var{I} and @var{J} have integer type, then they shall have
5229 1.1 mrg the same kind type parameter. @var{I} and @var{J} shall not both be
5230 1.1 mrg BOZ constants.
5231 1.1 mrg @item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall
5232 1.1 mrg be nonnegative. If @var{I} is not a BOZ constant, then @var{SHIFT}
5233 1.1 mrg shall be less than or equal to @code{BIT_SIZE(I)}; otherwise,
5234 1.1 mrg @var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}.
5235 1.1 mrg @end multitable
5236 1.1 mrg
5237 1.1 mrg @item @emph{Return value}:
5238 1.1 mrg If either @var{I} or @var{J} is a BOZ constant, it is first converted
5239 1.1 mrg as if by the intrinsic function @code{INT} to an integer type with the
5240 1.1 mrg kind type parameter of the other.
5241 1.1 mrg
5242 1.1 mrg @item @emph{See also}:
5243 1.1 mrg @ref{DSHIFTL}
5244 1.1 mrg @end table
5245 1.1 mrg
5246 1.1 mrg
5247 1.1 mrg @node DTIME
5248 1.1 mrg @section @code{DTIME} --- Execution time subroutine (or function)
5249 1.1 mrg @fnindex DTIME
5250 1.1 mrg @cindex time, elapsed
5251 1.1 mrg @cindex elapsed time
5252 1.1 mrg
5253 1.1 mrg @table @asis
5254 1.1 mrg @item @emph{Description}:
5255 1.1 mrg @code{DTIME(VALUES, TIME)} initially returns the number of seconds of runtime
5256 1.1 mrg since the start of the process's execution in @var{TIME}. @var{VALUES}
5257 1.1 mrg returns the user and system components of this time in @code{VALUES(1)} and
5258 1.1 mrg @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) +
5259 1.1 mrg VALUES(2)}.
5260 1.1 mrg
5261 1.1 mrg Subsequent invocations of @code{DTIME} return values accumulated since the
5262 1.1 mrg previous invocation.
5263 1.1 mrg
5264 1.1 mrg On some systems, the underlying timings are represented using types with
5265 1.1 mrg sufficiently small limits that overflows (wrap around) are possible, such as
5266 1.1 mrg 32-bit types. Therefore, the values returned by this intrinsic might be, or
5267 1.1 mrg become, negative, or numerically less than previous values, during a single
5268 1.1 mrg run of the compiled program.
5269 1.1 mrg
5270 1.1 mrg Please note, that this implementation is thread safe if used within OpenMP
5271 1.1 mrg directives, i.e., its state will be consistent while called from multiple
5272 1.1 mrg threads. However, if @code{DTIME} is called from multiple threads, the result
5273 1.1 mrg is still the time since the last invocation. This may not give the intended
5274 1.1 mrg results. If possible, use @code{CPU_TIME} instead.
5275 1.1 mrg
5276 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
5277 1.1 mrg only one form can be used in any given program unit.
5278 1.1 mrg
5279 1.1 mrg @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
5280 1.1 mrg
5281 1.1 mrg @multitable @columnfractions .15 .30 .40
5282 1.1 mrg @item @tab @code{VALUES(1)}: @tab User time in seconds.
5283 1.1 mrg @item @tab @code{VALUES(2)}: @tab System time in seconds.
5284 1.1 mrg @item @tab @code{TIME}: @tab Run time since start in seconds.
5285 1.1 mrg @end multitable
5286 1.1 mrg
5287 1.1 mrg @item @emph{Standard}:
5288 1.1 mrg GNU extension
5289 1.1 mrg
5290 1.1 mrg @item @emph{Class}:
5291 1.1 mrg Subroutine, function
5292 1.1 mrg
5293 1.1 mrg @item @emph{Syntax}:
5294 1.1 mrg @multitable @columnfractions .80
5295 1.1 mrg @item @code{CALL DTIME(VALUES, TIME)}.
5296 1.1 mrg @item @code{TIME = DTIME(VALUES)}, (not recommended).
5297 1.1 mrg @end multitable
5298 1.1 mrg
5299 1.1 mrg @item @emph{Arguments}:
5300 1.1 mrg @multitable @columnfractions .15 .70
5301 1.1 mrg @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
5302 1.1 mrg @item @var{TIME}@tab The type shall be @code{REAL(4)}.
5303 1.1 mrg @end multitable
5304 1.1 mrg
5305 1.1 mrg @item @emph{Return value}:
5306 1.1 mrg Elapsed time in seconds since the last invocation or since the start of program
5307 1.1 mrg execution if not called before.
5308 1.1 mrg
5309 1.1 mrg @item @emph{Example}:
5310 1.1 mrg @smallexample
5311 1.1 mrg program test_dtime
5312 1.1 mrg integer(8) :: i, j
5313 1.1 mrg real, dimension(2) :: tarray
5314 1.1 mrg real :: result
5315 1.1 mrg call dtime(tarray, result)
5316 1.1 mrg print *, result
5317 1.1 mrg print *, tarray(1)
5318 1.1 mrg print *, tarray(2)
5319 1.1 mrg do i=1,100000000 ! Just a delay
5320 1.1 mrg j = i * i - i
5321 1.1 mrg end do
5322 1.1 mrg call dtime(tarray, result)
5323 1.1 mrg print *, result
5324 1.1 mrg print *, tarray(1)
5325 1.1 mrg print *, tarray(2)
5326 1.1 mrg end program test_dtime
5327 1.1 mrg @end smallexample
5328 1.1 mrg
5329 1.1 mrg @item @emph{See also}:
5330 1.1 mrg @ref{CPU_TIME}
5331 1.1 mrg
5332 1.1 mrg @end table
5333 1.1 mrg
5334 1.1 mrg
5335 1.1 mrg
5336 1.1 mrg @node EOSHIFT
5337 1.1 mrg @section @code{EOSHIFT} --- End-off shift elements of an array
5338 1.1 mrg @fnindex EOSHIFT
5339 1.1 mrg @cindex array, shift
5340 1.1 mrg
5341 1.1 mrg @table @asis
5342 1.1 mrg @item @emph{Description}:
5343 1.1 mrg @code{EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])} performs an end-off shift on
5344 1.1 mrg elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
5345 1.1 mrg omitted it is taken to be @code{1}. @var{DIM} is a scalar of type
5346 1.1 mrg @code{INTEGER} in the range of @math{1 \leq DIM \leq n)} where @math{n} is the
5347 1.1 mrg rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
5348 1.1 mrg @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
5349 1.1 mrg then all complete rank one sections of @var{ARRAY} along the given dimension are
5350 1.1 mrg shifted. Elements shifted out one end of each rank one section are dropped. If
5351 1.1 mrg @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
5352 1.1 mrg is copied back in the other end. If @var{BOUNDARY} is not present then the
5353 1.1 mrg following are copied in depending on the type of @var{ARRAY}.
5354 1.1 mrg
5355 1.1 mrg @multitable @columnfractions .15 .80
5356 1.1 mrg @item @emph{Array Type} @tab @emph{Boundary Value}
5357 1.1 mrg @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
5358 1.1 mrg @item Logical @tab @code{.FALSE.}.
5359 1.1 mrg @item Character(@var{len}) @tab @var{len} blanks.
5360 1.1 mrg @end multitable
5361 1.1 mrg
5362 1.1 mrg @item @emph{Standard}:
5363 1.1.1.2 mrg Fortran 90 and later
5364 1.1 mrg
5365 1.1 mrg @item @emph{Class}:
5366 1.1 mrg Transformational function
5367 1.1 mrg
5368 1.1 mrg @item @emph{Syntax}:
5369 1.1 mrg @code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])}
5370 1.1 mrg
5371 1.1 mrg @item @emph{Arguments}:
5372 1.1 mrg @multitable @columnfractions .15 .70
5373 1.1 mrg @item @var{ARRAY} @tab May be any type, not scalar.
5374 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
5375 1.1 mrg @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
5376 1.1 mrg @item @var{DIM} @tab The type shall be @code{INTEGER}.
5377 1.1 mrg @end multitable
5378 1.1 mrg
5379 1.1 mrg @item @emph{Return value}:
5380 1.1 mrg Returns an array of same type and rank as the @var{ARRAY} argument.
5381 1.1 mrg
5382 1.1 mrg @item @emph{Example}:
5383 1.1 mrg @smallexample
5384 1.1 mrg program test_eoshift
5385 1.1 mrg integer, dimension(3,3) :: a
5386 1.1 mrg a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
5387 1.1 mrg print '(3i3)', a(1,:)
5388 1.1 mrg print '(3i3)', a(2,:)
5389 1.1 mrg print '(3i3)', a(3,:)
5390 1.1 mrg a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
5391 1.1 mrg print *
5392 1.1 mrg print '(3i3)', a(1,:)
5393 1.1 mrg print '(3i3)', a(2,:)
5394 1.1 mrg print '(3i3)', a(3,:)
5395 1.1 mrg end program test_eoshift
5396 1.1 mrg @end smallexample
5397 1.1 mrg @end table
5398 1.1 mrg
5399 1.1 mrg
5400 1.1 mrg
5401 1.1 mrg @node EPSILON
5402 1.1 mrg @section @code{EPSILON} --- Epsilon function
5403 1.1 mrg @fnindex EPSILON
5404 1.1 mrg @cindex model representation, epsilon
5405 1.1 mrg
5406 1.1 mrg @table @asis
5407 1.1 mrg @item @emph{Description}:
5408 1.1 mrg @code{EPSILON(X)} returns the smallest number @var{E} of the same kind
5409 1.1 mrg as @var{X} such that @math{1 + E > 1}.
5410 1.1 mrg
5411 1.1 mrg @item @emph{Standard}:
5412 1.1.1.2 mrg Fortran 90 and later
5413 1.1 mrg
5414 1.1 mrg @item @emph{Class}:
5415 1.1 mrg Inquiry function
5416 1.1 mrg
5417 1.1 mrg @item @emph{Syntax}:
5418 1.1 mrg @code{RESULT = EPSILON(X)}
5419 1.1 mrg
5420 1.1 mrg @item @emph{Arguments}:
5421 1.1 mrg @multitable @columnfractions .15 .70
5422 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
5423 1.1 mrg @end multitable
5424 1.1 mrg
5425 1.1 mrg @item @emph{Return value}:
5426 1.1 mrg The return value is of same type as the argument.
5427 1.1 mrg
5428 1.1 mrg @item @emph{Example}:
5429 1.1 mrg @smallexample
5430 1.1 mrg program test_epsilon
5431 1.1 mrg real :: x = 3.143
5432 1.1 mrg real(8) :: y = 2.33
5433 1.1 mrg print *, EPSILON(x)
5434 1.1 mrg print *, EPSILON(y)
5435 1.1 mrg end program test_epsilon
5436 1.1 mrg @end smallexample
5437 1.1 mrg @end table
5438 1.1 mrg
5439 1.1 mrg
5440 1.1 mrg
5441 1.1 mrg @node ERF
5442 1.1 mrg @section @code{ERF} --- Error function
5443 1.1 mrg @fnindex ERF
5444 1.1 mrg @cindex error function
5445 1.1 mrg
5446 1.1 mrg @table @asis
5447 1.1 mrg @item @emph{Description}:
5448 1.1 mrg @code{ERF(X)} computes the error function of @var{X}.
5449 1.1 mrg
5450 1.1 mrg @item @emph{Standard}:
5451 1.1 mrg Fortran 2008 and later
5452 1.1 mrg
5453 1.1 mrg @item @emph{Class}:
5454 1.1 mrg Elemental function
5455 1.1 mrg
5456 1.1 mrg @item @emph{Syntax}:
5457 1.1 mrg @code{RESULT = ERF(X)}
5458 1.1 mrg
5459 1.1 mrg @item @emph{Arguments}:
5460 1.1 mrg @multitable @columnfractions .15 .70
5461 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
5462 1.1 mrg @end multitable
5463 1.1 mrg
5464 1.1 mrg @item @emph{Return value}:
5465 1.1 mrg The return value is of type @code{REAL}, of the same kind as
5466 1.1 mrg @var{X} and lies in the range @math{-1 \leq erf (x) \leq 1 }.
5467 1.1 mrg
5468 1.1 mrg @item @emph{Example}:
5469 1.1 mrg @smallexample
5470 1.1 mrg program test_erf
5471 1.1 mrg real(8) :: x = 0.17_8
5472 1.1 mrg x = erf(x)
5473 1.1 mrg end program test_erf
5474 1.1 mrg @end smallexample
5475 1.1 mrg
5476 1.1 mrg @item @emph{Specific names}:
5477 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
5478 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
5479 1.1 mrg @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
5480 1.1 mrg @end multitable
5481 1.1 mrg @end table
5482 1.1 mrg
5483 1.1 mrg
5484 1.1 mrg
5485 1.1 mrg @node ERFC
5486 1.1 mrg @section @code{ERFC} --- Error function
5487 1.1 mrg @fnindex ERFC
5488 1.1 mrg @cindex error function, complementary
5489 1.1 mrg
5490 1.1 mrg @table @asis
5491 1.1 mrg @item @emph{Description}:
5492 1.1 mrg @code{ERFC(X)} computes the complementary error function of @var{X}.
5493 1.1 mrg
5494 1.1 mrg @item @emph{Standard}:
5495 1.1 mrg Fortran 2008 and later
5496 1.1 mrg
5497 1.1 mrg @item @emph{Class}:
5498 1.1 mrg Elemental function
5499 1.1 mrg
5500 1.1 mrg @item @emph{Syntax}:
5501 1.1 mrg @code{RESULT = ERFC(X)}
5502 1.1 mrg
5503 1.1 mrg @item @emph{Arguments}:
5504 1.1 mrg @multitable @columnfractions .15 .70
5505 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
5506 1.1 mrg @end multitable
5507 1.1 mrg
5508 1.1 mrg @item @emph{Return value}:
5509 1.1 mrg The return value is of type @code{REAL} and of the same kind as @var{X}.
5510 1.1 mrg It lies in the range @math{ 0 \leq erfc (x) \leq 2 }.
5511 1.1 mrg
5512 1.1 mrg @item @emph{Example}:
5513 1.1 mrg @smallexample
5514 1.1 mrg program test_erfc
5515 1.1 mrg real(8) :: x = 0.17_8
5516 1.1 mrg x = erfc(x)
5517 1.1 mrg end program test_erfc
5518 1.1 mrg @end smallexample
5519 1.1 mrg
5520 1.1 mrg @item @emph{Specific names}:
5521 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
5522 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
5523 1.1 mrg @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
5524 1.1 mrg @end multitable
5525 1.1 mrg @end table
5526 1.1 mrg
5527 1.1 mrg
5528 1.1 mrg
5529 1.1 mrg @node ERFC_SCALED
5530 1.1 mrg @section @code{ERFC_SCALED} --- Error function
5531 1.1 mrg @fnindex ERFC_SCALED
5532 1.1 mrg @cindex error function, complementary, exponentially-scaled
5533 1.1 mrg
5534 1.1 mrg @table @asis
5535 1.1 mrg @item @emph{Description}:
5536 1.1 mrg @code{ERFC_SCALED(X)} computes the exponentially-scaled complementary
5537 1.1 mrg error function of @var{X}.
5538 1.1 mrg
5539 1.1 mrg @item @emph{Standard}:
5540 1.1 mrg Fortran 2008 and later
5541 1.1 mrg
5542 1.1 mrg @item @emph{Class}:
5543 1.1 mrg Elemental function
5544 1.1 mrg
5545 1.1 mrg @item @emph{Syntax}:
5546 1.1 mrg @code{RESULT = ERFC_SCALED(X)}
5547 1.1 mrg
5548 1.1 mrg @item @emph{Arguments}:
5549 1.1 mrg @multitable @columnfractions .15 .70
5550 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
5551 1.1 mrg @end multitable
5552 1.1 mrg
5553 1.1 mrg @item @emph{Return value}:
5554 1.1 mrg The return value is of type @code{REAL} and of the same kind as @var{X}.
5555 1.1 mrg
5556 1.1 mrg @item @emph{Example}:
5557 1.1 mrg @smallexample
5558 1.1 mrg program test_erfc_scaled
5559 1.1 mrg real(8) :: x = 0.17_8
5560 1.1 mrg x = erfc_scaled(x)
5561 1.1 mrg end program test_erfc_scaled
5562 1.1 mrg @end smallexample
5563 1.1 mrg @end table
5564 1.1 mrg
5565 1.1 mrg
5566 1.1 mrg
5567 1.1 mrg @node ETIME
5568 1.1 mrg @section @code{ETIME} --- Execution time subroutine (or function)
5569 1.1 mrg @fnindex ETIME
5570 1.1 mrg @cindex time, elapsed
5571 1.1 mrg
5572 1.1 mrg @table @asis
5573 1.1 mrg @item @emph{Description}:
5574 1.1 mrg @code{ETIME(VALUES, TIME)} returns the number of seconds of runtime
5575 1.1 mrg since the start of the process's execution in @var{TIME}. @var{VALUES}
5576 1.1 mrg returns the user and system components of this time in @code{VALUES(1)} and
5577 1.1 mrg @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) + VALUES(2)}.
5578 1.1 mrg
5579 1.1 mrg On some systems, the underlying timings are represented using types with
5580 1.1 mrg sufficiently small limits that overflows (wrap around) are possible, such as
5581 1.1 mrg 32-bit types. Therefore, the values returned by this intrinsic might be, or
5582 1.1 mrg become, negative, or numerically less than previous values, during a single
5583 1.1 mrg run of the compiled program.
5584 1.1 mrg
5585 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
5586 1.1 mrg only one form can be used in any given program unit.
5587 1.1 mrg
5588 1.1 mrg @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
5589 1.1 mrg
5590 1.1 mrg @multitable @columnfractions .15 .30 .60
5591 1.1 mrg @item @tab @code{VALUES(1)}: @tab User time in seconds.
5592 1.1 mrg @item @tab @code{VALUES(2)}: @tab System time in seconds.
5593 1.1 mrg @item @tab @code{TIME}: @tab Run time since start in seconds.
5594 1.1 mrg @end multitable
5595 1.1 mrg
5596 1.1 mrg @item @emph{Standard}:
5597 1.1 mrg GNU extension
5598 1.1 mrg
5599 1.1 mrg @item @emph{Class}:
5600 1.1 mrg Subroutine, function
5601 1.1 mrg
5602 1.1 mrg @item @emph{Syntax}:
5603 1.1 mrg @multitable @columnfractions .80
5604 1.1 mrg @item @code{CALL ETIME(VALUES, TIME)}.
5605 1.1 mrg @item @code{TIME = ETIME(VALUES)}, (not recommended).
5606 1.1 mrg @end multitable
5607 1.1 mrg
5608 1.1 mrg @item @emph{Arguments}:
5609 1.1 mrg @multitable @columnfractions .15 .70
5610 1.1 mrg @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
5611 1.1 mrg @item @var{TIME}@tab The type shall be @code{REAL(4)}.
5612 1.1 mrg @end multitable
5613 1.1 mrg
5614 1.1 mrg @item @emph{Return value}:
5615 1.1 mrg Elapsed time in seconds since the start of program execution.
5616 1.1 mrg
5617 1.1 mrg @item @emph{Example}:
5618 1.1 mrg @smallexample
5619 1.1 mrg program test_etime
5620 1.1 mrg integer(8) :: i, j
5621 1.1 mrg real, dimension(2) :: tarray
5622 1.1 mrg real :: result
5623 1.1 mrg call ETIME(tarray, result)
5624 1.1 mrg print *, result
5625 1.1 mrg print *, tarray(1)
5626 1.1 mrg print *, tarray(2)
5627 1.1 mrg do i=1,100000000 ! Just a delay
5628 1.1 mrg j = i * i - i
5629 1.1 mrg end do
5630 1.1 mrg call ETIME(tarray, result)
5631 1.1 mrg print *, result
5632 1.1 mrg print *, tarray(1)
5633 1.1 mrg print *, tarray(2)
5634 1.1 mrg end program test_etime
5635 1.1 mrg @end smallexample
5636 1.1 mrg
5637 1.1 mrg @item @emph{See also}:
5638 1.1 mrg @ref{CPU_TIME}
5639 1.1 mrg
5640 1.1 mrg @end table
5641 1.1 mrg
5642 1.1 mrg
5643 1.1 mrg
5644 1.1 mrg @node EVENT_QUERY
5645 1.1 mrg @section @code{EVENT_QUERY} --- Query whether a coarray event has occurred
5646 1.1 mrg @fnindex EVENT_QUERY
5647 1.1 mrg @cindex Events, EVENT_QUERY
5648 1.1 mrg
5649 1.1 mrg @table @asis
5650 1.1 mrg @item @emph{Description}:
5651 1.1 mrg @code{EVENT_QUERY} assignes the number of events to @var{COUNT} which have been
5652 1.1 mrg posted to the @var{EVENT} variable and not yet been removed by calling
5653 1.1 mrg @code{EVENT WAIT}. When @var{STAT} is present and the invocation was successful,
5654 1.1 mrg it is assigned the value 0. If it is present and the invocation has failed,
5655 1.1 mrg it is assigned a positive value and @var{COUNT} is assigned the value @math{-1}.
5656 1.1 mrg
5657 1.1 mrg @item @emph{Standard}:
5658 1.1 mrg TS 18508 or later
5659 1.1 mrg
5660 1.1 mrg @item @emph{Class}:
5661 1.1 mrg subroutine
5662 1.1 mrg
5663 1.1 mrg @item @emph{Syntax}:
5664 1.1 mrg @code{CALL EVENT_QUERY (EVENT, COUNT [, STAT])}
5665 1.1 mrg
5666 1.1 mrg @item @emph{Arguments}:
5667 1.1 mrg @multitable @columnfractions .15 .70
5668 1.1 mrg @item @var{EVENT} @tab (intent(IN)) Scalar of type @code{EVENT_TYPE},
5669 1.1 mrg defined in @code{ISO_FORTRAN_ENV}; shall not be coindexed.
5670 1.1 mrg @item @var{COUNT} @tab (intent(out))Scalar integer with at least the
5671 1.1 mrg precision of default integer.
5672 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
5673 1.1 mrg @end multitable
5674 1.1 mrg
5675 1.1 mrg @item @emph{Example}:
5676 1.1 mrg @smallexample
5677 1.1 mrg program atomic
5678 1.1 mrg use iso_fortran_env
5679 1.1 mrg implicit none
5680 1.1 mrg type(event_type) :: event_value_has_been_set[*]
5681 1.1 mrg integer :: cnt
5682 1.1 mrg if (this_image() == 1) then
5683 1.1 mrg call event_query (event_value_has_been_set, cnt)
5684 1.1 mrg if (cnt > 0) write(*,*) "Value has been set"
5685 1.1 mrg elseif (this_image() == 2) then
5686 1.1 mrg event post (event_value_has_been_set[1])
5687 1.1 mrg end if
5688 1.1 mrg end program atomic
5689 1.1 mrg @end smallexample
5690 1.1 mrg
5691 1.1 mrg @end table
5692 1.1 mrg
5693 1.1 mrg
5694 1.1 mrg
5695 1.1 mrg @node EXECUTE_COMMAND_LINE
5696 1.1 mrg @section @code{EXECUTE_COMMAND_LINE} --- Execute a shell command
5697 1.1 mrg @fnindex EXECUTE_COMMAND_LINE
5698 1.1 mrg @cindex system, system call
5699 1.1 mrg @cindex command line
5700 1.1 mrg
5701 1.1 mrg @table @asis
5702 1.1 mrg @item @emph{Description}:
5703 1.1 mrg @code{EXECUTE_COMMAND_LINE} runs a shell command, synchronously or
5704 1.1 mrg asynchronously.
5705 1.1 mrg
5706 1.1 mrg The @code{COMMAND} argument is passed to the shell and executed (The
5707 1.1 mrg shell is @code{sh} on Unix systems, and @code{cmd.exe} on Windows.).
5708 1.1 mrg If @code{WAIT} is present and has the value false, the execution of
5709 1.1 mrg the command is asynchronous if the system supports it; otherwise, the
5710 1.1 mrg command is executed synchronously using the C library's @code{system}
5711 1.1 mrg call.
5712 1.1 mrg
5713 1.1 mrg The three last arguments allow the user to get status information. After
5714 1.1 mrg synchronous execution, @code{EXITSTAT} contains the integer exit code of
5715 1.1 mrg the command, as returned by @code{system}. @code{CMDSTAT} is set to zero
5716 1.1 mrg if the command line was executed (whatever its exit status was).
5717 1.1 mrg @code{CMDMSG} is assigned an error message if an error has occurred.
5718 1.1 mrg
5719 1.1 mrg Note that the @code{system} function need not be thread-safe. It is
5720 1.1 mrg the responsibility of the user to ensure that @code{system} is not
5721 1.1 mrg called concurrently.
5722 1.1 mrg
5723 1.1 mrg For asynchronous execution on supported targets, the POSIX
5724 1.1 mrg @code{posix_spawn} or @code{fork} functions are used. Also, a signal
5725 1.1 mrg handler for the @code{SIGCHLD} signal is installed.
5726 1.1 mrg
5727 1.1 mrg @item @emph{Standard}:
5728 1.1 mrg Fortran 2008 and later
5729 1.1 mrg
5730 1.1 mrg @item @emph{Class}:
5731 1.1 mrg Subroutine
5732 1.1 mrg
5733 1.1 mrg @item @emph{Syntax}:
5734 1.1 mrg @code{CALL EXECUTE_COMMAND_LINE(COMMAND [, WAIT, EXITSTAT, CMDSTAT, CMDMSG ])}
5735 1.1 mrg
5736 1.1 mrg @item @emph{Arguments}:
5737 1.1 mrg @multitable @columnfractions .15 .70
5738 1.1 mrg @item @var{COMMAND} @tab Shall be a default @code{CHARACTER} scalar.
5739 1.1 mrg @item @var{WAIT} @tab (Optional) Shall be a default @code{LOGICAL} scalar.
5740 1.1 mrg @item @var{EXITSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
5741 1.1 mrg default kind.
5742 1.1 mrg @item @var{CMDSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
5743 1.1 mrg default kind.
5744 1.1 mrg @item @var{CMDMSG} @tab (Optional) Shall be an @code{CHARACTER} scalar of the
5745 1.1 mrg default kind.
5746 1.1 mrg @end multitable
5747 1.1 mrg
5748 1.1 mrg @item @emph{Example}:
5749 1.1 mrg @smallexample
5750 1.1 mrg program test_exec
5751 1.1 mrg integer :: i
5752 1.1 mrg
5753 1.1 mrg call execute_command_line ("external_prog.exe", exitstat=i)
5754 1.1 mrg print *, "Exit status of external_prog.exe was ", i
5755 1.1 mrg
5756 1.1 mrg call execute_command_line ("reindex_files.exe", wait=.false.)
5757 1.1 mrg print *, "Now reindexing files in the background"
5758 1.1 mrg
5759 1.1 mrg end program test_exec
5760 1.1 mrg @end smallexample
5761 1.1 mrg
5762 1.1 mrg
5763 1.1 mrg @item @emph{Note}:
5764 1.1 mrg
5765 1.1 mrg Because this intrinsic is implemented in terms of the @code{system}
5766 1.1 mrg function call, its behavior with respect to signaling is processor
5767 1.1 mrg dependent. In particular, on POSIX-compliant systems, the SIGINT and
5768 1.1 mrg SIGQUIT signals will be ignored, and the SIGCHLD will be blocked. As
5769 1.1 mrg such, if the parent process is terminated, the child process might not be
5770 1.1 mrg terminated alongside.
5771 1.1 mrg
5772 1.1 mrg
5773 1.1 mrg @item @emph{See also}:
5774 1.1 mrg @ref{SYSTEM}
5775 1.1 mrg @end table
5776 1.1 mrg
5777 1.1 mrg
5778 1.1 mrg
5779 1.1 mrg @node EXIT
5780 1.1 mrg @section @code{EXIT} --- Exit the program with status.
5781 1.1 mrg @fnindex EXIT
5782 1.1 mrg @cindex program termination
5783 1.1 mrg @cindex terminate program
5784 1.1 mrg
5785 1.1 mrg @table @asis
5786 1.1 mrg @item @emph{Description}:
5787 1.1 mrg @code{EXIT} causes immediate termination of the program with status. If status
5788 1.1 mrg is omitted it returns the canonical @emph{success} for the system. All Fortran
5789 1.1 mrg I/O units are closed.
5790 1.1 mrg
5791 1.1 mrg @item @emph{Standard}:
5792 1.1 mrg GNU extension
5793 1.1 mrg
5794 1.1 mrg @item @emph{Class}:
5795 1.1 mrg Subroutine
5796 1.1 mrg
5797 1.1 mrg @item @emph{Syntax}:
5798 1.1 mrg @code{CALL EXIT([STATUS])}
5799 1.1 mrg
5800 1.1 mrg @item @emph{Arguments}:
5801 1.1 mrg @multitable @columnfractions .15 .70
5802 1.1 mrg @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
5803 1.1 mrg @end multitable
5804 1.1 mrg
5805 1.1 mrg @item @emph{Return value}:
5806 1.1 mrg @code{STATUS} is passed to the parent process on exit.
5807 1.1 mrg
5808 1.1 mrg @item @emph{Example}:
5809 1.1 mrg @smallexample
5810 1.1 mrg program test_exit
5811 1.1 mrg integer :: STATUS = 0
5812 1.1 mrg print *, 'This program is going to exit.'
5813 1.1 mrg call EXIT(STATUS)
5814 1.1 mrg end program test_exit
5815 1.1 mrg @end smallexample
5816 1.1 mrg
5817 1.1 mrg @item @emph{See also}:
5818 1.1.1.2 mrg @ref{ABORT}, @gol
5819 1.1.1.2 mrg @ref{KILL}
5820 1.1 mrg @end table
5821 1.1 mrg
5822 1.1 mrg
5823 1.1 mrg
5824 1.1 mrg @node EXP
5825 1.1 mrg @section @code{EXP} --- Exponential function
5826 1.1 mrg @fnindex EXP
5827 1.1 mrg @fnindex DEXP
5828 1.1 mrg @fnindex CEXP
5829 1.1 mrg @fnindex ZEXP
5830 1.1 mrg @fnindex CDEXP
5831 1.1 mrg @cindex exponential function
5832 1.1 mrg @cindex logarithm function, inverse
5833 1.1 mrg
5834 1.1 mrg @table @asis
5835 1.1 mrg @item @emph{Description}:
5836 1.1 mrg @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
5837 1.1 mrg
5838 1.1 mrg @item @emph{Standard}:
5839 1.1 mrg Fortran 77 and later, has overloads that are GNU extensions
5840 1.1 mrg
5841 1.1 mrg @item @emph{Class}:
5842 1.1 mrg Elemental function
5843 1.1 mrg
5844 1.1 mrg @item @emph{Syntax}:
5845 1.1 mrg @code{RESULT = EXP(X)}
5846 1.1 mrg
5847 1.1 mrg @item @emph{Arguments}:
5848 1.1 mrg @multitable @columnfractions .15 .70
5849 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or
5850 1.1 mrg @code{COMPLEX}.
5851 1.1 mrg @end multitable
5852 1.1 mrg
5853 1.1 mrg @item @emph{Return value}:
5854 1.1 mrg The return value has same type and kind as @var{X}.
5855 1.1 mrg
5856 1.1 mrg @item @emph{Example}:
5857 1.1 mrg @smallexample
5858 1.1 mrg program test_exp
5859 1.1 mrg real :: x = 1.0
5860 1.1 mrg x = exp(x)
5861 1.1 mrg end program test_exp
5862 1.1 mrg @end smallexample
5863 1.1 mrg
5864 1.1 mrg @item @emph{Specific names}:
5865 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
5866 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
5867 1.1 mrg @item @code{EXP(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
5868 1.1 mrg @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
5869 1.1 mrg @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
5870 1.1 mrg @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
5871 1.1 mrg @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
5872 1.1 mrg @end multitable
5873 1.1 mrg @end table
5874 1.1 mrg
5875 1.1 mrg
5876 1.1 mrg
5877 1.1 mrg @node EXPONENT
5878 1.1 mrg @section @code{EXPONENT} --- Exponent function
5879 1.1 mrg @fnindex EXPONENT
5880 1.1 mrg @cindex real number, exponent
5881 1.1 mrg @cindex floating point, exponent
5882 1.1 mrg
5883 1.1 mrg @table @asis
5884 1.1 mrg @item @emph{Description}:
5885 1.1 mrg @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
5886 1.1 mrg is zero the value returned is zero.
5887 1.1 mrg
5888 1.1 mrg @item @emph{Standard}:
5889 1.1.1.2 mrg Fortran 90 and later
5890 1.1 mrg
5891 1.1 mrg @item @emph{Class}:
5892 1.1 mrg Elemental function
5893 1.1 mrg
5894 1.1 mrg @item @emph{Syntax}:
5895 1.1 mrg @code{RESULT = EXPONENT(X)}
5896 1.1 mrg
5897 1.1 mrg @item @emph{Arguments}:
5898 1.1 mrg @multitable @columnfractions .15 .70
5899 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
5900 1.1 mrg @end multitable
5901 1.1 mrg
5902 1.1 mrg @item @emph{Return value}:
5903 1.1 mrg The return value is of type default @code{INTEGER}.
5904 1.1 mrg
5905 1.1 mrg @item @emph{Example}:
5906 1.1 mrg @smallexample
5907 1.1 mrg program test_exponent
5908 1.1 mrg real :: x = 1.0
5909 1.1 mrg integer :: i
5910 1.1 mrg i = exponent(x)
5911 1.1 mrg print *, i
5912 1.1 mrg print *, exponent(0.0)
5913 1.1 mrg end program test_exponent
5914 1.1 mrg @end smallexample
5915 1.1 mrg @end table
5916 1.1 mrg
5917 1.1 mrg
5918 1.1 mrg
5919 1.1 mrg @node EXTENDS_TYPE_OF
5920 1.1 mrg @section @code{EXTENDS_TYPE_OF} --- Query dynamic type for extension
5921 1.1 mrg @fnindex EXTENDS_TYPE_OF
5922 1.1 mrg
5923 1.1 mrg @table @asis
5924 1.1 mrg @item @emph{Description}:
5925 1.1 mrg Query dynamic type for extension.
5926 1.1 mrg
5927 1.1 mrg @item @emph{Standard}:
5928 1.1 mrg Fortran 2003 and later
5929 1.1 mrg
5930 1.1 mrg @item @emph{Class}:
5931 1.1 mrg Inquiry function
5932 1.1 mrg
5933 1.1 mrg @item @emph{Syntax}:
5934 1.1 mrg @code{RESULT = EXTENDS_TYPE_OF(A, MOLD)}
5935 1.1 mrg
5936 1.1 mrg @item @emph{Arguments}:
5937 1.1 mrg @multitable @columnfractions .15 .70
5938 1.1 mrg @item @var{A} @tab Shall be an object of extensible declared type or
5939 1.1 mrg unlimited polymorphic.
5940 1.1 mrg @item @var{MOLD} @tab Shall be an object of extensible declared type or
5941 1.1 mrg unlimited polymorphic.
5942 1.1 mrg @end multitable
5943 1.1 mrg
5944 1.1 mrg @item @emph{Return value}:
5945 1.1 mrg The return value is a scalar of type default logical. It is true if and only if
5946 1.1 mrg the dynamic type of A is an extension type of the dynamic type of MOLD.
5947 1.1 mrg
5948 1.1 mrg
5949 1.1 mrg @item @emph{See also}:
5950 1.1 mrg @ref{SAME_TYPE_AS}
5951 1.1 mrg @end table
5952 1.1 mrg
5953 1.1 mrg
5954 1.1 mrg
5955 1.1 mrg @node FDATE
5956 1.1 mrg @section @code{FDATE} --- Get the current time as a string
5957 1.1 mrg @fnindex FDATE
5958 1.1 mrg @cindex time, current
5959 1.1 mrg @cindex current time
5960 1.1 mrg @cindex date, current
5961 1.1 mrg @cindex current date
5962 1.1 mrg
5963 1.1 mrg @table @asis
5964 1.1 mrg @item @emph{Description}:
5965 1.1 mrg @code{FDATE(DATE)} returns the current date (using the same format as
5966 1.1 mrg @ref{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
5967 1.1 mrg TIME())}.
5968 1.1 mrg
5969 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
5970 1.1 mrg only one form can be used in any given program unit.
5971 1.1 mrg
5972 1.1 mrg @item @emph{Standard}:
5973 1.1 mrg GNU extension
5974 1.1 mrg
5975 1.1 mrg @item @emph{Class}:
5976 1.1 mrg Subroutine, function
5977 1.1 mrg
5978 1.1 mrg @item @emph{Syntax}:
5979 1.1 mrg @multitable @columnfractions .80
5980 1.1 mrg @item @code{CALL FDATE(DATE)}.
5981 1.1 mrg @item @code{DATE = FDATE()}.
5982 1.1 mrg @end multitable
5983 1.1 mrg
5984 1.1 mrg @item @emph{Arguments}:
5985 1.1 mrg @multitable @columnfractions .15 .70
5986 1.1 mrg @item @var{DATE}@tab The type shall be of type @code{CHARACTER} of the
5987 1.1 mrg default kind. It is an @code{INTENT(OUT)} argument. If the length of
5988 1.1 mrg this variable is too short for the date and time string to fit
5989 1.1 mrg completely, it will be blank on procedure return.
5990 1.1 mrg @end multitable
5991 1.1 mrg
5992 1.1 mrg @item @emph{Return value}:
5993 1.1 mrg The current date and time as a string.
5994 1.1 mrg
5995 1.1 mrg @item @emph{Example}:
5996 1.1 mrg @smallexample
5997 1.1 mrg program test_fdate
5998 1.1 mrg integer(8) :: i, j
5999 1.1 mrg character(len=30) :: date
6000 1.1 mrg call fdate(date)
6001 1.1 mrg print *, 'Program started on ', date
6002 1.1 mrg do i = 1, 100000000 ! Just a delay
6003 1.1 mrg j = i * i - i
6004 1.1 mrg end do
6005 1.1 mrg call fdate(date)
6006 1.1 mrg print *, 'Program ended on ', date
6007 1.1 mrg end program test_fdate
6008 1.1 mrg @end smallexample
6009 1.1 mrg
6010 1.1 mrg @item @emph{See also}:
6011 1.1.1.2 mrg @ref{DATE_AND_TIME}, @gol
6012 1.1.1.2 mrg @ref{CTIME}
6013 1.1 mrg @end table
6014 1.1 mrg
6015 1.1 mrg
6016 1.1 mrg @node FGET
6017 1.1 mrg @section @code{FGET} --- Read a single character in stream mode from stdin
6018 1.1 mrg @fnindex FGET
6019 1.1 mrg @cindex read character, stream mode
6020 1.1 mrg @cindex stream mode, read character
6021 1.1 mrg @cindex file operation, read character
6022 1.1 mrg
6023 1.1 mrg @table @asis
6024 1.1 mrg @item @emph{Description}:
6025 1.1 mrg Read a single character in stream mode from stdin by bypassing normal
6026 1.1 mrg formatted output. Stream I/O should not be mixed with normal record-oriented
6027 1.1 mrg (formatted or unformatted) I/O on the same unit; the results are unpredictable.
6028 1.1 mrg
6029 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
6030 1.1 mrg only one form can be used in any given program unit.
6031 1.1 mrg
6032 1.1 mrg Note that the @code{FGET} intrinsic is provided for backwards compatibility with
6033 1.1 mrg @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
6034 1.1 mrg Programmers should consider the use of new stream IO feature in new code
6035 1.1 mrg for future portability. See also @ref{Fortran 2003 status}.
6036 1.1 mrg
6037 1.1 mrg @item @emph{Standard}:
6038 1.1 mrg GNU extension
6039 1.1 mrg
6040 1.1 mrg @item @emph{Class}:
6041 1.1 mrg Subroutine, function
6042 1.1 mrg
6043 1.1 mrg @item @emph{Syntax}:
6044 1.1 mrg @multitable @columnfractions .80
6045 1.1 mrg @item @code{CALL FGET(C [, STATUS])}
6046 1.1 mrg @item @code{STATUS = FGET(C)}
6047 1.1 mrg @end multitable
6048 1.1 mrg
6049 1.1 mrg @item @emph{Arguments}:
6050 1.1 mrg @multitable @columnfractions .15 .70
6051 1.1 mrg @item @var{C} @tab The type shall be @code{CHARACTER} and of default
6052 1.1 mrg kind.
6053 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
6054 1.1 mrg Returns 0 on success, -1 on end-of-file, and a system specific positive
6055 1.1 mrg error code otherwise.
6056 1.1 mrg @end multitable
6057 1.1 mrg
6058 1.1 mrg @item @emph{Example}:
6059 1.1 mrg @smallexample
6060 1.1 mrg PROGRAM test_fget
6061 1.1 mrg INTEGER, PARAMETER :: strlen = 100
6062 1.1 mrg INTEGER :: status, i = 1
6063 1.1 mrg CHARACTER(len=strlen) :: str = ""
6064 1.1 mrg
6065 1.1 mrg WRITE (*,*) 'Enter text:'
6066 1.1 mrg DO
6067 1.1 mrg CALL fget(str(i:i), status)
6068 1.1 mrg if (status /= 0 .OR. i > strlen) exit
6069 1.1 mrg i = i + 1
6070 1.1 mrg END DO
6071 1.1 mrg WRITE (*,*) TRIM(str)
6072 1.1 mrg END PROGRAM
6073 1.1 mrg @end smallexample
6074 1.1 mrg
6075 1.1 mrg @item @emph{See also}:
6076 1.1.1.2 mrg @ref{FGETC}, @gol
6077 1.1.1.2 mrg @ref{FPUT}, @gol
6078 1.1.1.2 mrg @ref{FPUTC}
6079 1.1 mrg @end table
6080 1.1 mrg
6081 1.1 mrg
6082 1.1 mrg
6083 1.1 mrg @node FGETC
6084 1.1 mrg @section @code{FGETC} --- Read a single character in stream mode
6085 1.1 mrg @fnindex FGETC
6086 1.1 mrg @cindex read character, stream mode
6087 1.1 mrg @cindex stream mode, read character
6088 1.1 mrg @cindex file operation, read character
6089 1.1 mrg
6090 1.1 mrg @table @asis
6091 1.1 mrg @item @emph{Description}:
6092 1.1 mrg Read a single character in stream mode by bypassing normal formatted output.
6093 1.1 mrg Stream I/O should not be mixed with normal record-oriented (formatted or
6094 1.1 mrg unformatted) I/O on the same unit; the results are unpredictable.
6095 1.1 mrg
6096 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
6097 1.1 mrg only one form can be used in any given program unit.
6098 1.1 mrg
6099 1.1 mrg Note that the @code{FGET} intrinsic is provided for backwards compatibility
6100 1.1 mrg with @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
6101 1.1 mrg Programmers should consider the use of new stream IO feature in new code
6102 1.1 mrg for future portability. See also @ref{Fortran 2003 status}.
6103 1.1 mrg
6104 1.1 mrg @item @emph{Standard}:
6105 1.1 mrg GNU extension
6106 1.1 mrg
6107 1.1 mrg @item @emph{Class}:
6108 1.1 mrg Subroutine, function
6109 1.1 mrg
6110 1.1 mrg @item @emph{Syntax}:
6111 1.1 mrg @multitable @columnfractions .80
6112 1.1 mrg @item @code{CALL FGETC(UNIT, C [, STATUS])}
6113 1.1 mrg @item @code{STATUS = FGETC(UNIT, C)}
6114 1.1 mrg @end multitable
6115 1.1 mrg
6116 1.1 mrg @item @emph{Arguments}:
6117 1.1 mrg @multitable @columnfractions .15 .70
6118 1.1 mrg @item @var{UNIT} @tab The type shall be @code{INTEGER}.
6119 1.1 mrg @item @var{C} @tab The type shall be @code{CHARACTER} and of default
6120 1.1 mrg kind.
6121 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
6122 1.1 mrg Returns 0 on success, -1 on end-of-file and a system specific positive
6123 1.1 mrg error code otherwise.
6124 1.1 mrg @end multitable
6125 1.1 mrg
6126 1.1 mrg @item @emph{Example}:
6127 1.1 mrg @smallexample
6128 1.1 mrg PROGRAM test_fgetc
6129 1.1 mrg INTEGER :: fd = 42, status
6130 1.1 mrg CHARACTER :: c
6131 1.1 mrg
6132 1.1 mrg OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
6133 1.1 mrg DO
6134 1.1 mrg CALL fgetc(fd, c, status)
6135 1.1 mrg IF (status /= 0) EXIT
6136 1.1 mrg call fput(c)
6137 1.1 mrg END DO
6138 1.1 mrg CLOSE(UNIT=fd)
6139 1.1 mrg END PROGRAM
6140 1.1 mrg @end smallexample
6141 1.1 mrg
6142 1.1 mrg @item @emph{See also}:
6143 1.1.1.2 mrg @ref{FGET}, @gol
6144 1.1.1.2 mrg @ref{FPUT}, @gol
6145 1.1.1.2 mrg @ref{FPUTC}
6146 1.1 mrg @end table
6147 1.1 mrg
6148 1.1 mrg @node FINDLOC
6149 1.1 mrg @section @code{FINDLOC} --- Search an array for a value
6150 1.1 mrg @fnindex FINDLOC
6151 1.1 mrg @cindex findloc
6152 1.1 mrg
6153 1.1 mrg @table @asis
6154 1.1 mrg @item @emph{Description}:
6155 1.1 mrg Determines the location of the element in the array with the value
6156 1.1 mrg given in the @var{VALUE} argument, or, if the @var{DIM} argument is
6157 1.1.1.2 mrg supplied, determines the locations of the elements equal to the
6158 1.1.1.2 mrg @var{VALUE} argument element along each
6159 1.1 mrg row of the array in the @var{DIM} direction. If @var{MASK} is
6160 1.1 mrg present, only the elements for which @var{MASK} is @code{.TRUE.} are
6161 1.1 mrg considered. If more than one element in the array has the value
6162 1.1 mrg @var{VALUE}, the location returned is that of the first such element
6163 1.1 mrg in array element order if the @var{BACK} is not present or if it is
6164 1.1 mrg @code{.FALSE.}. If @var{BACK} is true, the location returned is that
6165 1.1 mrg of the last such element. If the array has zero size, or all of the
6166 1.1 mrg elements of @var{MASK} are @code{.FALSE.}, then the result is an array
6167 1.1 mrg of zeroes. Similarly, if @var{DIM} is supplied and all of the
6168 1.1 mrg elements of @var{MASK} along a given row are zero, the result value
6169 1.1 mrg for that row is zero.
6170 1.1 mrg
6171 1.1 mrg @item @emph{Standard}:
6172 1.1 mrg Fortran 2008 and later.
6173 1.1 mrg
6174 1.1 mrg @item @emph{Class}:
6175 1.1 mrg Transformational function
6176 1.1 mrg
6177 1.1 mrg @item @emph{Syntax}:
6178 1.1 mrg @multitable @columnfractions .80
6179 1.1 mrg @item @code{RESULT = FINDLOC(ARRAY, VALUE, DIM [, MASK] [,KIND] [,BACK])}
6180 1.1 mrg @item @code{RESULT = FINDLOC(ARRAY, VALUE, [, MASK] [,KIND] [,BACK])}
6181 1.1 mrg @end multitable
6182 1.1 mrg
6183 1.1 mrg @item @emph{Arguments}:
6184 1.1 mrg @multitable @columnfractions .15 .70
6185 1.1 mrg @item @var{ARRAY} @tab Shall be an array of intrinsic type.
6186 1.1 mrg @item @var{VALUE} @tab A scalar of intrinsic type which is in type
6187 1.1 mrg conformance with @var{ARRAY}.
6188 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar of type
6189 1.1 mrg @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
6190 1.1 mrg inclusive. It may not be an optional dummy argument.
6191 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6192 1.1 mrg expression indicating the kind parameter of the result.
6193 1.1 mrg @item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}.
6194 1.1 mrg @end multitable
6195 1.1 mrg
6196 1.1 mrg @item @emph{Return value}:
6197 1.1 mrg If @var{DIM} is absent, the result is a rank-one array with a length
6198 1.1 mrg equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6199 1.1 mrg is an array with a rank one less than the rank of @var{ARRAY}, and a
6200 1.1 mrg size corresponding to the size of @var{ARRAY} with the @var{DIM}
6201 1.1 mrg dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6202 1.1 mrg of one, the result is a scalar. If the optional argument @var{KIND}
6203 1.1 mrg is present, the result is an integer of kind @var{KIND}, otherwise it
6204 1.1 mrg is of default kind.
6205 1.1 mrg
6206 1.1 mrg @item @emph{See also}:
6207 1.1.1.2 mrg @ref{MAXLOC}, @gol
6208 1.1.1.2 mrg @ref{MINLOC}
6209 1.1 mrg
6210 1.1 mrg @end table
6211 1.1 mrg
6212 1.1 mrg @node FLOOR
6213 1.1 mrg @section @code{FLOOR} --- Integer floor function
6214 1.1 mrg @fnindex FLOOR
6215 1.1 mrg @cindex floor
6216 1.1 mrg @cindex rounding, floor
6217 1.1 mrg
6218 1.1 mrg @table @asis
6219 1.1 mrg @item @emph{Description}:
6220 1.1 mrg @code{FLOOR(A)} returns the greatest integer less than or equal to @var{X}.
6221 1.1 mrg
6222 1.1 mrg @item @emph{Standard}:
6223 1.1 mrg Fortran 95 and later
6224 1.1 mrg
6225 1.1 mrg @item @emph{Class}:
6226 1.1 mrg Elemental function
6227 1.1 mrg
6228 1.1 mrg @item @emph{Syntax}:
6229 1.1 mrg @code{RESULT = FLOOR(A [, KIND])}
6230 1.1 mrg
6231 1.1 mrg @item @emph{Arguments}:
6232 1.1 mrg @multitable @columnfractions .15 .70
6233 1.1 mrg @item @var{A} @tab The type shall be @code{REAL}.
6234 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6235 1.1 mrg expression indicating the kind parameter of the result.
6236 1.1 mrg @end multitable
6237 1.1 mrg
6238 1.1 mrg @item @emph{Return value}:
6239 1.1 mrg The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
6240 1.1 mrg and of default-kind @code{INTEGER} otherwise.
6241 1.1 mrg
6242 1.1 mrg @item @emph{Example}:
6243 1.1 mrg @smallexample
6244 1.1 mrg program test_floor
6245 1.1 mrg real :: x = 63.29
6246 1.1 mrg real :: y = -63.59
6247 1.1 mrg print *, floor(x) ! returns 63
6248 1.1 mrg print *, floor(y) ! returns -64
6249 1.1 mrg end program test_floor
6250 1.1 mrg @end smallexample
6251 1.1 mrg
6252 1.1 mrg @item @emph{See also}:
6253 1.1.1.2 mrg @ref{CEILING}, @gol
6254 1.1.1.2 mrg @ref{NINT}
6255 1.1 mrg @end table
6256 1.1 mrg
6257 1.1 mrg
6258 1.1 mrg
6259 1.1 mrg @node FLUSH
6260 1.1 mrg @section @code{FLUSH} --- Flush I/O unit(s)
6261 1.1 mrg @fnindex FLUSH
6262 1.1 mrg @cindex file operation, flush
6263 1.1 mrg
6264 1.1 mrg @table @asis
6265 1.1 mrg @item @emph{Description}:
6266 1.1 mrg Flushes Fortran unit(s) currently open for output. Without the optional
6267 1.1 mrg argument, all units are flushed, otherwise just the unit specified.
6268 1.1 mrg
6269 1.1 mrg @item @emph{Standard}:
6270 1.1 mrg GNU extension
6271 1.1 mrg
6272 1.1 mrg @item @emph{Class}:
6273 1.1 mrg Subroutine
6274 1.1 mrg
6275 1.1 mrg @item @emph{Syntax}:
6276 1.1 mrg @code{CALL FLUSH(UNIT)}
6277 1.1 mrg
6278 1.1 mrg @item @emph{Arguments}:
6279 1.1 mrg @multitable @columnfractions .15 .70
6280 1.1 mrg @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
6281 1.1 mrg @end multitable
6282 1.1 mrg
6283 1.1 mrg @item @emph{Note}:
6284 1.1 mrg Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
6285 1.1 mrg statement that should be preferred over the @code{FLUSH} intrinsic.
6286 1.1 mrg
6287 1.1 mrg The @code{FLUSH} intrinsic and the Fortran 2003 @code{FLUSH} statement
6288 1.1 mrg have identical effect: they flush the runtime library's I/O buffer so
6289 1.1 mrg that the data becomes visible to other processes. This does not guarantee
6290 1.1 mrg that the data is committed to disk.
6291 1.1 mrg
6292 1.1 mrg On POSIX systems, you can request that all data is transferred to the
6293 1.1 mrg storage device by calling the @code{fsync} function, with the POSIX file
6294 1.1 mrg descriptor of the I/O unit as argument (retrieved with GNU intrinsic
6295 1.1 mrg @code{FNUM}). The following example shows how:
6296 1.1 mrg
6297 1.1 mrg @smallexample
6298 1.1 mrg ! Declare the interface for POSIX fsync function
6299 1.1 mrg interface
6300 1.1 mrg function fsync (fd) bind(c,name="fsync")
6301 1.1 mrg use iso_c_binding, only: c_int
6302 1.1 mrg integer(c_int), value :: fd
6303 1.1 mrg integer(c_int) :: fsync
6304 1.1 mrg end function fsync
6305 1.1 mrg end interface
6306 1.1 mrg
6307 1.1 mrg ! Variable declaration
6308 1.1 mrg integer :: ret
6309 1.1 mrg
6310 1.1 mrg ! Opening unit 10
6311 1.1 mrg open (10,file="foo")
6312 1.1 mrg
6313 1.1 mrg ! ...
6314 1.1 mrg ! Perform I/O on unit 10
6315 1.1 mrg ! ...
6316 1.1 mrg
6317 1.1 mrg ! Flush and sync
6318 1.1 mrg flush(10)
6319 1.1 mrg ret = fsync(fnum(10))
6320 1.1 mrg
6321 1.1 mrg ! Handle possible error
6322 1.1 mrg if (ret /= 0) stop "Error calling FSYNC"
6323 1.1 mrg @end smallexample
6324 1.1 mrg
6325 1.1 mrg @end table
6326 1.1 mrg
6327 1.1 mrg
6328 1.1 mrg
6329 1.1 mrg @node FNUM
6330 1.1 mrg @section @code{FNUM} --- File number function
6331 1.1 mrg @fnindex FNUM
6332 1.1 mrg @cindex file operation, file number
6333 1.1 mrg
6334 1.1 mrg @table @asis
6335 1.1 mrg @item @emph{Description}:
6336 1.1 mrg @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
6337 1.1 mrg open Fortran I/O unit @code{UNIT}.
6338 1.1 mrg
6339 1.1 mrg @item @emph{Standard}:
6340 1.1 mrg GNU extension
6341 1.1 mrg
6342 1.1 mrg @item @emph{Class}:
6343 1.1 mrg Function
6344 1.1 mrg
6345 1.1 mrg @item @emph{Syntax}:
6346 1.1 mrg @code{RESULT = FNUM(UNIT)}
6347 1.1 mrg
6348 1.1 mrg @item @emph{Arguments}:
6349 1.1 mrg @multitable @columnfractions .15 .70
6350 1.1 mrg @item @var{UNIT} @tab The type shall be @code{INTEGER}.
6351 1.1 mrg @end multitable
6352 1.1 mrg
6353 1.1 mrg @item @emph{Return value}:
6354 1.1 mrg The return value is of type @code{INTEGER}
6355 1.1 mrg
6356 1.1 mrg @item @emph{Example}:
6357 1.1 mrg @smallexample
6358 1.1 mrg program test_fnum
6359 1.1 mrg integer :: i
6360 1.1 mrg open (unit=10, status = "scratch")
6361 1.1 mrg i = fnum(10)
6362 1.1 mrg print *, i
6363 1.1 mrg close (10)
6364 1.1 mrg end program test_fnum
6365 1.1 mrg @end smallexample
6366 1.1 mrg @end table
6367 1.1 mrg
6368 1.1 mrg
6369 1.1 mrg
6370 1.1 mrg @node FPUT
6371 1.1 mrg @section @code{FPUT} --- Write a single character in stream mode to stdout
6372 1.1 mrg @fnindex FPUT
6373 1.1 mrg @cindex write character, stream mode
6374 1.1 mrg @cindex stream mode, write character
6375 1.1 mrg @cindex file operation, write character
6376 1.1 mrg
6377 1.1 mrg @table @asis
6378 1.1 mrg @item @emph{Description}:
6379 1.1 mrg Write a single character in stream mode to stdout by bypassing normal
6380 1.1 mrg formatted output. Stream I/O should not be mixed with normal record-oriented
6381 1.1 mrg (formatted or unformatted) I/O on the same unit; the results are unpredictable.
6382 1.1 mrg
6383 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
6384 1.1 mrg only one form can be used in any given program unit.
6385 1.1 mrg
6386 1.1 mrg Note that the @code{FGET} intrinsic is provided for backwards compatibility with
6387 1.1 mrg @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
6388 1.1 mrg Programmers should consider the use of new stream IO feature in new code
6389 1.1 mrg for future portability. See also @ref{Fortran 2003 status}.
6390 1.1 mrg
6391 1.1 mrg @item @emph{Standard}:
6392 1.1 mrg GNU extension
6393 1.1 mrg
6394 1.1 mrg @item @emph{Class}:
6395 1.1 mrg Subroutine, function
6396 1.1 mrg
6397 1.1 mrg @item @emph{Syntax}:
6398 1.1 mrg @multitable @columnfractions .80
6399 1.1 mrg @item @code{CALL FPUT(C [, STATUS])}
6400 1.1 mrg @item @code{STATUS = FPUT(C)}
6401 1.1 mrg @end multitable
6402 1.1 mrg
6403 1.1 mrg @item @emph{Arguments}:
6404 1.1 mrg @multitable @columnfractions .15 .70
6405 1.1 mrg @item @var{C} @tab The type shall be @code{CHARACTER} and of default
6406 1.1 mrg kind.
6407 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
6408 1.1 mrg Returns 0 on success, -1 on end-of-file and a system specific positive
6409 1.1 mrg error code otherwise.
6410 1.1 mrg @end multitable
6411 1.1 mrg
6412 1.1 mrg @item @emph{Example}:
6413 1.1 mrg @smallexample
6414 1.1 mrg PROGRAM test_fput
6415 1.1 mrg CHARACTER(len=10) :: str = "gfortran"
6416 1.1 mrg INTEGER :: i
6417 1.1 mrg DO i = 1, len_trim(str)
6418 1.1 mrg CALL fput(str(i:i))
6419 1.1 mrg END DO
6420 1.1 mrg END PROGRAM
6421 1.1 mrg @end smallexample
6422 1.1 mrg
6423 1.1 mrg @item @emph{See also}:
6424 1.1.1.2 mrg @ref{FPUTC}, @gol
6425 1.1.1.2 mrg @ref{FGET}, @gol
6426 1.1.1.2 mrg @ref{FGETC}
6427 1.1 mrg @end table
6428 1.1 mrg
6429 1.1 mrg
6430 1.1 mrg
6431 1.1 mrg @node FPUTC
6432 1.1 mrg @section @code{FPUTC} --- Write a single character in stream mode
6433 1.1 mrg @fnindex FPUTC
6434 1.1 mrg @cindex write character, stream mode
6435 1.1 mrg @cindex stream mode, write character
6436 1.1 mrg @cindex file operation, write character
6437 1.1 mrg
6438 1.1 mrg @table @asis
6439 1.1 mrg @item @emph{Description}:
6440 1.1 mrg Write a single character in stream mode by bypassing normal formatted
6441 1.1 mrg output. Stream I/O should not be mixed with normal record-oriented
6442 1.1 mrg (formatted or unformatted) I/O on the same unit; the results are unpredictable.
6443 1.1 mrg
6444 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
6445 1.1 mrg only one form can be used in any given program unit.
6446 1.1 mrg
6447 1.1 mrg Note that the @code{FGET} intrinsic is provided for backwards compatibility with
6448 1.1 mrg @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
6449 1.1 mrg Programmers should consider the use of new stream IO feature in new code
6450 1.1 mrg for future portability. See also @ref{Fortran 2003 status}.
6451 1.1 mrg
6452 1.1 mrg @item @emph{Standard}:
6453 1.1 mrg GNU extension
6454 1.1 mrg
6455 1.1 mrg @item @emph{Class}:
6456 1.1 mrg Subroutine, function
6457 1.1 mrg
6458 1.1 mrg @item @emph{Syntax}:
6459 1.1 mrg @multitable @columnfractions .80
6460 1.1 mrg @item @code{CALL FPUTC(UNIT, C [, STATUS])}
6461 1.1 mrg @item @code{STATUS = FPUTC(UNIT, C)}
6462 1.1 mrg @end multitable
6463 1.1 mrg
6464 1.1 mrg @item @emph{Arguments}:
6465 1.1 mrg @multitable @columnfractions .15 .70
6466 1.1 mrg @item @var{UNIT} @tab The type shall be @code{INTEGER}.
6467 1.1 mrg @item @var{C} @tab The type shall be @code{CHARACTER} and of default
6468 1.1 mrg kind.
6469 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
6470 1.1 mrg Returns 0 on success, -1 on end-of-file and a system specific positive
6471 1.1 mrg error code otherwise.
6472 1.1 mrg @end multitable
6473 1.1 mrg
6474 1.1 mrg @item @emph{Example}:
6475 1.1 mrg @smallexample
6476 1.1 mrg PROGRAM test_fputc
6477 1.1 mrg CHARACTER(len=10) :: str = "gfortran"
6478 1.1 mrg INTEGER :: fd = 42, i
6479 1.1 mrg
6480 1.1 mrg OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
6481 1.1 mrg DO i = 1, len_trim(str)
6482 1.1 mrg CALL fputc(fd, str(i:i))
6483 1.1 mrg END DO
6484 1.1 mrg CLOSE(fd)
6485 1.1 mrg END PROGRAM
6486 1.1 mrg @end smallexample
6487 1.1 mrg
6488 1.1 mrg @item @emph{See also}:
6489 1.1.1.2 mrg @ref{FPUT}, @gol
6490 1.1.1.2 mrg @ref{FGET}, @gol
6491 1.1.1.2 mrg @ref{FGETC}
6492 1.1 mrg @end table
6493 1.1 mrg
6494 1.1 mrg
6495 1.1 mrg
6496 1.1 mrg @node FRACTION
6497 1.1 mrg @section @code{FRACTION} --- Fractional part of the model representation
6498 1.1 mrg @fnindex FRACTION
6499 1.1 mrg @cindex real number, fraction
6500 1.1 mrg @cindex floating point, fraction
6501 1.1 mrg
6502 1.1 mrg @table @asis
6503 1.1 mrg @item @emph{Description}:
6504 1.1 mrg @code{FRACTION(X)} returns the fractional part of the model
6505 1.1 mrg representation of @code{X}.
6506 1.1 mrg
6507 1.1 mrg @item @emph{Standard}:
6508 1.1.1.2 mrg Fortran 90 and later
6509 1.1 mrg
6510 1.1 mrg @item @emph{Class}:
6511 1.1 mrg Elemental function
6512 1.1 mrg
6513 1.1 mrg @item @emph{Syntax}:
6514 1.1 mrg @code{Y = FRACTION(X)}
6515 1.1 mrg
6516 1.1 mrg @item @emph{Arguments}:
6517 1.1 mrg @multitable @columnfractions .15 .70
6518 1.1 mrg @item @var{X} @tab The type of the argument shall be a @code{REAL}.
6519 1.1 mrg @end multitable
6520 1.1 mrg
6521 1.1 mrg @item @emph{Return value}:
6522 1.1 mrg The return value is of the same type and kind as the argument.
6523 1.1 mrg The fractional part of the model representation of @code{X} is returned;
6524 1.1 mrg it is @code{X * RADIX(X)**(-EXPONENT(X))}.
6525 1.1 mrg
6526 1.1 mrg @item @emph{Example}:
6527 1.1 mrg @smallexample
6528 1.1 mrg program test_fraction
6529 1.1 mrg real :: x
6530 1.1 mrg x = 178.1387e-4
6531 1.1 mrg print *, fraction(x), x * radix(x)**(-exponent(x))
6532 1.1 mrg end program test_fraction
6533 1.1 mrg @end smallexample
6534 1.1 mrg
6535 1.1 mrg @end table
6536 1.1 mrg
6537 1.1 mrg
6538 1.1 mrg
6539 1.1 mrg @node FREE
6540 1.1 mrg @section @code{FREE} --- Frees memory
6541 1.1 mrg @fnindex FREE
6542 1.1 mrg @cindex pointer, cray
6543 1.1 mrg
6544 1.1 mrg @table @asis
6545 1.1 mrg @item @emph{Description}:
6546 1.1 mrg Frees memory previously allocated by @code{MALLOC}. The @code{FREE}
6547 1.1 mrg intrinsic is an extension intended to be used with Cray pointers, and is
6548 1.1 mrg provided in GNU Fortran to allow user to compile legacy code. For
6549 1.1 mrg new code using Fortran 95 pointers, the memory de-allocation intrinsic is
6550 1.1 mrg @code{DEALLOCATE}.
6551 1.1 mrg
6552 1.1 mrg @item @emph{Standard}:
6553 1.1 mrg GNU extension
6554 1.1 mrg
6555 1.1 mrg @item @emph{Class}:
6556 1.1 mrg Subroutine
6557 1.1 mrg
6558 1.1 mrg @item @emph{Syntax}:
6559 1.1 mrg @code{CALL FREE(PTR)}
6560 1.1 mrg
6561 1.1 mrg @item @emph{Arguments}:
6562 1.1 mrg @multitable @columnfractions .15 .70
6563 1.1 mrg @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
6564 1.1 mrg location of the memory that should be de-allocated.
6565 1.1 mrg @end multitable
6566 1.1 mrg
6567 1.1 mrg @item @emph{Return value}:
6568 1.1 mrg None
6569 1.1 mrg
6570 1.1 mrg @item @emph{Example}:
6571 1.1 mrg See @code{MALLOC} for an example.
6572 1.1 mrg
6573 1.1 mrg @item @emph{See also}:
6574 1.1 mrg @ref{MALLOC}
6575 1.1 mrg @end table
6576 1.1 mrg
6577 1.1 mrg
6578 1.1 mrg
6579 1.1 mrg @node FSEEK
6580 1.1 mrg @section @code{FSEEK} --- Low level file positioning subroutine
6581 1.1 mrg @fnindex FSEEK
6582 1.1 mrg @cindex file operation, seek
6583 1.1 mrg @cindex file operation, position
6584 1.1 mrg
6585 1.1 mrg @table @asis
6586 1.1 mrg @item @emph{Description}:
6587 1.1 mrg Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE}
6588 1.1 mrg is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
6589 1.1 mrg if set to 1, @var{OFFSET} is taken to be relative to the current position
6590 1.1 mrg @code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
6591 1.1 mrg On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek
6592 1.1 mrg fails silently.
6593 1.1 mrg
6594 1.1 mrg This intrinsic routine is not fully backwards compatible with @command{g77}.
6595 1.1 mrg In @command{g77}, the @code{FSEEK} takes a statement label instead of a
6596 1.1 mrg @var{STATUS} variable. If FSEEK is used in old code, change
6597 1.1 mrg @smallexample
6598 1.1 mrg CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
6599 1.1 mrg @end smallexample
6600 1.1 mrg to
6601 1.1 mrg @smallexample
6602 1.1 mrg INTEGER :: status
6603 1.1 mrg CALL FSEEK(UNIT, OFFSET, WHENCE, status)
6604 1.1 mrg IF (status /= 0) GOTO label
6605 1.1 mrg @end smallexample
6606 1.1 mrg
6607 1.1 mrg Please note that GNU Fortran provides the Fortran 2003 Stream facility.
6608 1.1 mrg Programmers should consider the use of new stream IO feature in new code
6609 1.1 mrg for future portability. See also @ref{Fortran 2003 status}.
6610 1.1 mrg
6611 1.1 mrg @item @emph{Standard}:
6612 1.1 mrg GNU extension
6613 1.1 mrg
6614 1.1 mrg @item @emph{Class}:
6615 1.1 mrg Subroutine
6616 1.1 mrg
6617 1.1 mrg @item @emph{Syntax}:
6618 1.1 mrg @code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
6619 1.1 mrg
6620 1.1 mrg @item @emph{Arguments}:
6621 1.1 mrg @multitable @columnfractions .15 .70
6622 1.1 mrg @item @var{UNIT} @tab Shall be a scalar of type @code{INTEGER}.
6623 1.1 mrg @item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
6624 1.1 mrg @item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
6625 1.1 mrg Its value shall be either 0, 1 or 2.
6626 1.1 mrg @item @var{STATUS} @tab (Optional) shall be a scalar of type
6627 1.1 mrg @code{INTEGER(4)}.
6628 1.1 mrg @end multitable
6629 1.1 mrg
6630 1.1 mrg @item @emph{Example}:
6631 1.1 mrg @smallexample
6632 1.1 mrg PROGRAM test_fseek
6633 1.1 mrg INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
6634 1.1 mrg INTEGER :: fd, offset, ierr
6635 1.1 mrg
6636 1.1 mrg ierr = 0
6637 1.1 mrg offset = 5
6638 1.1 mrg fd = 10
6639 1.1 mrg
6640 1.1 mrg OPEN(UNIT=fd, FILE="fseek.test")
6641 1.1 mrg CALL FSEEK(fd, offset, SEEK_SET, ierr) ! move to OFFSET
6642 1.1 mrg print *, FTELL(fd), ierr
6643 1.1 mrg
6644 1.1 mrg CALL FSEEK(fd, 0, SEEK_END, ierr) ! move to end
6645 1.1 mrg print *, FTELL(fd), ierr
6646 1.1 mrg
6647 1.1 mrg CALL FSEEK(fd, 0, SEEK_SET, ierr) ! move to beginning
6648 1.1 mrg print *, FTELL(fd), ierr
6649 1.1 mrg
6650 1.1 mrg CLOSE(UNIT=fd)
6651 1.1 mrg END PROGRAM
6652 1.1 mrg @end smallexample
6653 1.1 mrg
6654 1.1 mrg @item @emph{See also}:
6655 1.1 mrg @ref{FTELL}
6656 1.1 mrg @end table
6657 1.1 mrg
6658 1.1 mrg
6659 1.1 mrg
6660 1.1 mrg @node FSTAT
6661 1.1 mrg @section @code{FSTAT} --- Get file status
6662 1.1 mrg @fnindex FSTAT
6663 1.1 mrg @cindex file system, file status
6664 1.1 mrg
6665 1.1 mrg @table @asis
6666 1.1 mrg @item @emph{Description}:
6667 1.1 mrg @code{FSTAT} is identical to @ref{STAT}, except that information about an
6668 1.1 mrg already opened file is obtained.
6669 1.1 mrg
6670 1.1 mrg The elements in @code{VALUES} are the same as described by @ref{STAT}.
6671 1.1 mrg
6672 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
6673 1.1 mrg only one form can be used in any given program unit.
6674 1.1 mrg
6675 1.1 mrg @item @emph{Standard}:
6676 1.1 mrg GNU extension
6677 1.1 mrg
6678 1.1 mrg @item @emph{Class}:
6679 1.1 mrg Subroutine, function
6680 1.1 mrg
6681 1.1 mrg @item @emph{Syntax}:
6682 1.1 mrg @multitable @columnfractions .80
6683 1.1 mrg @item @code{CALL FSTAT(UNIT, VALUES [, STATUS])}
6684 1.1 mrg @item @code{STATUS = FSTAT(UNIT, VALUES)}
6685 1.1 mrg @end multitable
6686 1.1 mrg
6687 1.1 mrg @item @emph{Arguments}:
6688 1.1 mrg @multitable @columnfractions .15 .70
6689 1.1 mrg @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
6690 1.1 mrg @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
6691 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
6692 1.1 mrg on success and a system specific error code otherwise.
6693 1.1 mrg @end multitable
6694 1.1 mrg
6695 1.1 mrg @item @emph{Example}:
6696 1.1 mrg See @ref{STAT} for an example.
6697 1.1 mrg
6698 1.1 mrg @item @emph{See also}:
6699 1.1.1.2 mrg To stat a link: @gol
6700 1.1.1.2 mrg @ref{LSTAT} @gol
6701 1.1.1.2 mrg To stat a file: @gol
6702 1.1.1.2 mrg @ref{STAT}
6703 1.1 mrg @end table
6704 1.1 mrg
6705 1.1 mrg
6706 1.1 mrg
6707 1.1 mrg @node FTELL
6708 1.1 mrg @section @code{FTELL} --- Current stream position
6709 1.1 mrg @fnindex FTELL
6710 1.1 mrg @cindex file operation, position
6711 1.1 mrg
6712 1.1 mrg @table @asis
6713 1.1 mrg @item @emph{Description}:
6714 1.1 mrg Retrieves the current position within an open file.
6715 1.1 mrg
6716 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
6717 1.1 mrg only one form can be used in any given program unit.
6718 1.1 mrg
6719 1.1 mrg @item @emph{Standard}:
6720 1.1 mrg GNU extension
6721 1.1 mrg
6722 1.1 mrg @item @emph{Class}:
6723 1.1 mrg Subroutine, function
6724 1.1 mrg
6725 1.1 mrg @item @emph{Syntax}:
6726 1.1 mrg @multitable @columnfractions .80
6727 1.1 mrg @item @code{CALL FTELL(UNIT, OFFSET)}
6728 1.1 mrg @item @code{OFFSET = FTELL(UNIT)}
6729 1.1 mrg @end multitable
6730 1.1 mrg
6731 1.1 mrg @item @emph{Arguments}:
6732 1.1 mrg @multitable @columnfractions .15 .70
6733 1.1 mrg @item @var{OFFSET} @tab Shall of type @code{INTEGER}.
6734 1.1 mrg @item @var{UNIT} @tab Shall of type @code{INTEGER}.
6735 1.1 mrg @end multitable
6736 1.1 mrg
6737 1.1 mrg @item @emph{Return value}:
6738 1.1 mrg In either syntax, @var{OFFSET} is set to the current offset of unit
6739 1.1 mrg number @var{UNIT}, or to @math{-1} if the unit is not currently open.
6740 1.1 mrg
6741 1.1 mrg @item @emph{Example}:
6742 1.1 mrg @smallexample
6743 1.1 mrg PROGRAM test_ftell
6744 1.1 mrg INTEGER :: i
6745 1.1 mrg OPEN(10, FILE="temp.dat")
6746 1.1 mrg CALL ftell(10,i)
6747 1.1 mrg WRITE(*,*) i
6748 1.1 mrg END PROGRAM
6749 1.1 mrg @end smallexample
6750 1.1 mrg
6751 1.1 mrg @item @emph{See also}:
6752 1.1 mrg @ref{FSEEK}
6753 1.1 mrg @end table
6754 1.1 mrg
6755 1.1 mrg
6756 1.1 mrg
6757 1.1 mrg @node GAMMA
6758 1.1 mrg @section @code{GAMMA} --- Gamma function
6759 1.1 mrg @fnindex GAMMA
6760 1.1 mrg @fnindex DGAMMA
6761 1.1 mrg @cindex Gamma function
6762 1.1 mrg @cindex Factorial function
6763 1.1 mrg
6764 1.1 mrg @table @asis
6765 1.1 mrg @item @emph{Description}:
6766 1.1 mrg @code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive,
6767 1.1 mrg integer values of @var{X} the Gamma function simplifies to the factorial
6768 1.1 mrg function @math{\Gamma(x)=(x-1)!}.
6769 1.1 mrg
6770 1.1 mrg @tex
6771 1.1 mrg $$
6772 1.1 mrg \Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t
6773 1.1 mrg $$
6774 1.1 mrg @end tex
6775 1.1 mrg
6776 1.1 mrg @item @emph{Standard}:
6777 1.1 mrg Fortran 2008 and later
6778 1.1 mrg
6779 1.1 mrg @item @emph{Class}:
6780 1.1 mrg Elemental function
6781 1.1 mrg
6782 1.1 mrg @item @emph{Syntax}:
6783 1.1 mrg @code{X = GAMMA(X)}
6784 1.1 mrg
6785 1.1 mrg @item @emph{Arguments}:
6786 1.1 mrg @multitable @columnfractions .15 .70
6787 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL} and neither zero
6788 1.1 mrg nor a negative integer.
6789 1.1 mrg @end multitable
6790 1.1 mrg
6791 1.1 mrg @item @emph{Return value}:
6792 1.1 mrg The return value is of type @code{REAL} of the same kind as @var{X}.
6793 1.1 mrg
6794 1.1 mrg @item @emph{Example}:
6795 1.1 mrg @smallexample
6796 1.1 mrg program test_gamma
6797 1.1 mrg real :: x = 1.0
6798 1.1 mrg x = gamma(x) ! returns 1.0
6799 1.1 mrg end program test_gamma
6800 1.1 mrg @end smallexample
6801 1.1 mrg
6802 1.1 mrg @item @emph{Specific names}:
6803 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
6804 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
6805 1.1.1.2 mrg @item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
6806 1.1 mrg @end multitable
6807 1.1 mrg
6808 1.1 mrg @item @emph{See also}:
6809 1.1.1.2 mrg Logarithm of the Gamma function: @gol
6810 1.1.1.2 mrg @ref{LOG_GAMMA}
6811 1.1 mrg @end table
6812 1.1 mrg
6813 1.1 mrg
6814 1.1 mrg
6815 1.1 mrg @node GERROR
6816 1.1 mrg @section @code{GERROR} --- Get last system error message
6817 1.1 mrg @fnindex GERROR
6818 1.1 mrg @cindex system, error handling
6819 1.1 mrg
6820 1.1 mrg @table @asis
6821 1.1 mrg @item @emph{Description}:
6822 1.1 mrg Returns the system error message corresponding to the last system error.
6823 1.1 mrg This resembles the functionality of @code{strerror(3)} in C.
6824 1.1 mrg
6825 1.1 mrg @item @emph{Standard}:
6826 1.1 mrg GNU extension
6827 1.1 mrg
6828 1.1 mrg @item @emph{Class}:
6829 1.1 mrg Subroutine
6830 1.1 mrg
6831 1.1 mrg @item @emph{Syntax}:
6832 1.1 mrg @code{CALL GERROR(RESULT)}
6833 1.1 mrg
6834 1.1 mrg @item @emph{Arguments}:
6835 1.1 mrg @multitable @columnfractions .15 .70
6836 1.1 mrg @item @var{RESULT} @tab Shall of type @code{CHARACTER} and of default
6837 1.1 mrg @end multitable
6838 1.1 mrg
6839 1.1 mrg @item @emph{Example}:
6840 1.1 mrg @smallexample
6841 1.1 mrg PROGRAM test_gerror
6842 1.1 mrg CHARACTER(len=100) :: msg
6843 1.1 mrg CALL gerror(msg)
6844 1.1 mrg WRITE(*,*) msg
6845 1.1 mrg END PROGRAM
6846 1.1 mrg @end smallexample
6847 1.1 mrg
6848 1.1 mrg @item @emph{See also}:
6849 1.1.1.2 mrg @ref{IERRNO}, @gol
6850 1.1.1.2 mrg @ref{PERROR}
6851 1.1 mrg @end table
6852 1.1 mrg
6853 1.1 mrg
6854 1.1 mrg
6855 1.1 mrg @node GETARG
6856 1.1 mrg @section @code{GETARG} --- Get command line arguments
6857 1.1 mrg @fnindex GETARG
6858 1.1 mrg @cindex command-line arguments
6859 1.1 mrg @cindex arguments, to program
6860 1.1 mrg
6861 1.1 mrg @table @asis
6862 1.1 mrg @item @emph{Description}:
6863 1.1 mrg Retrieve the @var{POS}-th argument that was passed on the
6864 1.1 mrg command line when the containing program was invoked.
6865 1.1 mrg
6866 1.1 mrg This intrinsic routine is provided for backwards compatibility with
6867 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of
6868 1.1 mrg the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
6869 1.1 mrg standard.
6870 1.1 mrg
6871 1.1 mrg @item @emph{Standard}:
6872 1.1 mrg GNU extension
6873 1.1 mrg
6874 1.1 mrg @item @emph{Class}:
6875 1.1 mrg Subroutine
6876 1.1 mrg
6877 1.1 mrg @item @emph{Syntax}:
6878 1.1 mrg @code{CALL GETARG(POS, VALUE)}
6879 1.1 mrg
6880 1.1 mrg @item @emph{Arguments}:
6881 1.1 mrg @multitable @columnfractions .15 .70
6882 1.1 mrg @item @var{POS} @tab Shall be of type @code{INTEGER} and not wider than
6883 1.1 mrg the default integer kind; @math{@var{POS} \geq 0}
6884 1.1 mrg @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default
6885 1.1 mrg kind.
6886 1.1 mrg @item @var{VALUE} @tab Shall be of type @code{CHARACTER}.
6887 1.1 mrg @end multitable
6888 1.1 mrg
6889 1.1 mrg @item @emph{Return value}:
6890 1.1 mrg After @code{GETARG} returns, the @var{VALUE} argument holds the
6891 1.1 mrg @var{POS}th command line argument. If @var{VALUE} cannot hold the
6892 1.1 mrg argument, it is truncated to fit the length of @var{VALUE}. If there are
6893 1.1 mrg less than @var{POS} arguments specified at the command line, @var{VALUE}
6894 1.1 mrg will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set
6895 1.1 mrg to the name of the program (on systems that support this feature).
6896 1.1 mrg
6897 1.1 mrg @item @emph{Example}:
6898 1.1 mrg @smallexample
6899 1.1 mrg PROGRAM test_getarg
6900 1.1 mrg INTEGER :: i
6901 1.1 mrg CHARACTER(len=32) :: arg
6902 1.1 mrg
6903 1.1 mrg DO i = 1, iargc()
6904 1.1 mrg CALL getarg(i, arg)
6905 1.1 mrg WRITE (*,*) arg
6906 1.1 mrg END DO
6907 1.1 mrg END PROGRAM
6908 1.1 mrg @end smallexample
6909 1.1 mrg
6910 1.1 mrg @item @emph{See also}:
6911 1.1.1.2 mrg GNU Fortran 77 compatibility function: @gol
6912 1.1.1.2 mrg @ref{IARGC} @gol
6913 1.1.1.2 mrg Fortran 2003 functions and subroutines: @gol
6914 1.1.1.2 mrg @ref{GET_COMMAND}, @gol
6915 1.1.1.2 mrg @ref{GET_COMMAND_ARGUMENT}, @gol
6916 1.1.1.2 mrg @ref{COMMAND_ARGUMENT_COUNT}
6917 1.1 mrg @end table
6918 1.1 mrg
6919 1.1 mrg
6920 1.1 mrg
6921 1.1 mrg @node GET_COMMAND
6922 1.1 mrg @section @code{GET_COMMAND} --- Get the entire command line
6923 1.1 mrg @fnindex GET_COMMAND
6924 1.1 mrg @cindex command-line arguments
6925 1.1 mrg @cindex arguments, to program
6926 1.1 mrg
6927 1.1 mrg @table @asis
6928 1.1 mrg @item @emph{Description}:
6929 1.1 mrg Retrieve the entire command line that was used to invoke the program.
6930 1.1 mrg
6931 1.1 mrg @item @emph{Standard}:
6932 1.1 mrg Fortran 2003 and later
6933 1.1 mrg
6934 1.1 mrg @item @emph{Class}:
6935 1.1 mrg Subroutine
6936 1.1 mrg
6937 1.1 mrg @item @emph{Syntax}:
6938 1.1 mrg @code{CALL GET_COMMAND([COMMAND, LENGTH, STATUS])}
6939 1.1 mrg
6940 1.1 mrg @item @emph{Arguments}:
6941 1.1 mrg @multitable @columnfractions .15 .70
6942 1.1 mrg @item @var{COMMAND} @tab (Optional) shall be of type @code{CHARACTER} and
6943 1.1 mrg of default kind.
6944 1.1 mrg @item @var{LENGTH} @tab (Optional) Shall be of type @code{INTEGER} and of
6945 1.1 mrg default kind.
6946 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of type @code{INTEGER} and of
6947 1.1 mrg default kind.
6948 1.1 mrg @end multitable
6949 1.1 mrg
6950 1.1 mrg @item @emph{Return value}:
6951 1.1 mrg If @var{COMMAND} is present, stores the entire command line that was used
6952 1.1 mrg to invoke the program in @var{COMMAND}. If @var{LENGTH} is present, it is
6953 1.1 mrg assigned the length of the command line. If @var{STATUS} is present, it
6954 1.1 mrg is assigned 0 upon success of the command, -1 if @var{COMMAND} is too
6955 1.1 mrg short to store the command line, or a positive value in case of an error.
6956 1.1 mrg
6957 1.1 mrg @item @emph{Example}:
6958 1.1 mrg @smallexample
6959 1.1 mrg PROGRAM test_get_command
6960 1.1 mrg CHARACTER(len=255) :: cmd
6961 1.1 mrg CALL get_command(cmd)
6962 1.1 mrg WRITE (*,*) TRIM(cmd)
6963 1.1 mrg END PROGRAM
6964 1.1 mrg @end smallexample
6965 1.1 mrg
6966 1.1 mrg @item @emph{See also}:
6967 1.1.1.2 mrg @ref{GET_COMMAND_ARGUMENT}, @gol
6968 1.1.1.2 mrg @ref{COMMAND_ARGUMENT_COUNT}
6969 1.1 mrg @end table
6970 1.1 mrg
6971 1.1 mrg
6972 1.1 mrg
6973 1.1 mrg @node GET_COMMAND_ARGUMENT
6974 1.1 mrg @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
6975 1.1 mrg @fnindex GET_COMMAND_ARGUMENT
6976 1.1 mrg @cindex command-line arguments
6977 1.1 mrg @cindex arguments, to program
6978 1.1 mrg
6979 1.1 mrg @table @asis
6980 1.1 mrg @item @emph{Description}:
6981 1.1 mrg Retrieve the @var{NUMBER}-th argument that was passed on the
6982 1.1 mrg command line when the containing program was invoked.
6983 1.1 mrg
6984 1.1 mrg @item @emph{Standard}:
6985 1.1 mrg Fortran 2003 and later
6986 1.1 mrg
6987 1.1 mrg @item @emph{Class}:
6988 1.1 mrg Subroutine
6989 1.1 mrg
6990 1.1 mrg @item @emph{Syntax}:
6991 1.1 mrg @code{CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])}
6992 1.1 mrg
6993 1.1 mrg @item @emph{Arguments}:
6994 1.1 mrg @multitable @columnfractions .15 .70
6995 1.1 mrg @item @var{NUMBER} @tab Shall be a scalar of type @code{INTEGER} and of
6996 1.1 mrg default kind, @math{@var{NUMBER} \geq 0}
6997 1.1 mrg @item @var{VALUE} @tab (Optional) Shall be a scalar of type @code{CHARACTER}
6998 1.1 mrg and of default kind.
6999 1.1 mrg @item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER}
7000 1.1 mrg and of default kind.
7001 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER}
7002 1.1 mrg and of default kind.
7003 1.1 mrg @end multitable
7004 1.1 mrg
7005 1.1 mrg @item @emph{Return value}:
7006 1.1 mrg After @code{GET_COMMAND_ARGUMENT} returns, the @var{VALUE} argument holds the
7007 1.1 mrg @var{NUMBER}-th command line argument. If @var{VALUE} cannot hold the argument, it is
7008 1.1 mrg truncated to fit the length of @var{VALUE}. If there are less than @var{NUMBER}
7009 1.1 mrg arguments specified at the command line, @var{VALUE} will be filled with blanks.
7010 1.1 mrg If @math{@var{NUMBER} = 0}, @var{VALUE} is set to the name of the program (on
7011 1.1 mrg systems that support this feature). The @var{LENGTH} argument contains the
7012 1.1 mrg length of the @var{NUMBER}-th command line argument. If the argument retrieval
7013 1.1 mrg fails, @var{STATUS} is a positive number; if @var{VALUE} contains a truncated
7014 1.1 mrg command line argument, @var{STATUS} is -1; and otherwise the @var{STATUS} is
7015 1.1 mrg zero.
7016 1.1 mrg
7017 1.1 mrg @item @emph{Example}:
7018 1.1 mrg @smallexample
7019 1.1 mrg PROGRAM test_get_command_argument
7020 1.1 mrg INTEGER :: i
7021 1.1 mrg CHARACTER(len=32) :: arg
7022 1.1 mrg
7023 1.1 mrg i = 0
7024 1.1 mrg DO
7025 1.1 mrg CALL get_command_argument(i, arg)
7026 1.1 mrg IF (LEN_TRIM(arg) == 0) EXIT
7027 1.1 mrg
7028 1.1 mrg WRITE (*,*) TRIM(arg)
7029 1.1 mrg i = i+1
7030 1.1 mrg END DO
7031 1.1 mrg END PROGRAM
7032 1.1 mrg @end smallexample
7033 1.1 mrg
7034 1.1 mrg @item @emph{See also}:
7035 1.1.1.2 mrg @ref{GET_COMMAND}, @gol
7036 1.1.1.2 mrg @ref{COMMAND_ARGUMENT_COUNT}
7037 1.1 mrg @end table
7038 1.1 mrg
7039 1.1 mrg
7040 1.1 mrg
7041 1.1 mrg @node GETCWD
7042 1.1 mrg @section @code{GETCWD} --- Get current working directory
7043 1.1 mrg @fnindex GETCWD
7044 1.1 mrg @cindex system, working directory
7045 1.1 mrg
7046 1.1 mrg @table @asis
7047 1.1 mrg @item @emph{Description}:
7048 1.1 mrg Get current working directory.
7049 1.1 mrg
7050 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
7051 1.1 mrg only one form can be used in any given program unit.
7052 1.1 mrg
7053 1.1 mrg @item @emph{Standard}:
7054 1.1 mrg GNU extension
7055 1.1 mrg
7056 1.1 mrg @item @emph{Class}:
7057 1.1 mrg Subroutine, function
7058 1.1 mrg
7059 1.1 mrg @item @emph{Syntax}:
7060 1.1 mrg @multitable @columnfractions .80
7061 1.1 mrg @item @code{CALL GETCWD(C [, STATUS])}
7062 1.1 mrg @item @code{STATUS = GETCWD(C)}
7063 1.1 mrg @end multitable
7064 1.1 mrg
7065 1.1 mrg @item @emph{Arguments}:
7066 1.1 mrg @multitable @columnfractions .15 .70
7067 1.1 mrg @item @var{C} @tab The type shall be @code{CHARACTER} and of default kind.
7068 1.1 mrg @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
7069 1.1 mrg a system specific and nonzero error code otherwise.
7070 1.1 mrg @end multitable
7071 1.1 mrg
7072 1.1 mrg @item @emph{Example}:
7073 1.1 mrg @smallexample
7074 1.1 mrg PROGRAM test_getcwd
7075 1.1 mrg CHARACTER(len=255) :: cwd
7076 1.1 mrg CALL getcwd(cwd)
7077 1.1 mrg WRITE(*,*) TRIM(cwd)
7078 1.1 mrg END PROGRAM
7079 1.1 mrg @end smallexample
7080 1.1 mrg
7081 1.1 mrg @item @emph{See also}:
7082 1.1 mrg @ref{CHDIR}
7083 1.1 mrg @end table
7084 1.1 mrg
7085 1.1 mrg
7086 1.1 mrg
7087 1.1 mrg @node GETENV
7088 1.1 mrg @section @code{GETENV} --- Get an environmental variable
7089 1.1 mrg @fnindex GETENV
7090 1.1 mrg @cindex environment variable
7091 1.1 mrg
7092 1.1 mrg @table @asis
7093 1.1 mrg @item @emph{Description}:
7094 1.1 mrg Get the @var{VALUE} of the environmental variable @var{NAME}.
7095 1.1 mrg
7096 1.1 mrg This intrinsic routine is provided for backwards compatibility with
7097 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of
7098 1.1 mrg the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
7099 1.1 mrg 2003 standard.
7100 1.1 mrg
7101 1.1 mrg Note that @code{GETENV} need not be thread-safe. It is the
7102 1.1 mrg responsibility of the user to ensure that the environment is not being
7103 1.1 mrg updated concurrently with a call to the @code{GETENV} intrinsic.
7104 1.1 mrg
7105 1.1 mrg @item @emph{Standard}:
7106 1.1 mrg GNU extension
7107 1.1 mrg
7108 1.1 mrg @item @emph{Class}:
7109 1.1 mrg Subroutine
7110 1.1 mrg
7111 1.1 mrg @item @emph{Syntax}:
7112 1.1 mrg @code{CALL GETENV(NAME, VALUE)}
7113 1.1 mrg
7114 1.1 mrg @item @emph{Arguments}:
7115 1.1 mrg @multitable @columnfractions .15 .70
7116 1.1 mrg @item @var{NAME} @tab Shall be of type @code{CHARACTER} and of default kind.
7117 1.1 mrg @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default kind.
7118 1.1 mrg @end multitable
7119 1.1 mrg
7120 1.1 mrg @item @emph{Return value}:
7121 1.1 mrg Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is
7122 1.1 mrg not large enough to hold the data, it is truncated. If @var{NAME}
7123 1.1 mrg is not set, @var{VALUE} will be filled with blanks.
7124 1.1 mrg
7125 1.1 mrg @item @emph{Example}:
7126 1.1 mrg @smallexample
7127 1.1 mrg PROGRAM test_getenv
7128 1.1 mrg CHARACTER(len=255) :: homedir
7129 1.1 mrg CALL getenv("HOME", homedir)
7130 1.1 mrg WRITE (*,*) TRIM(homedir)
7131 1.1 mrg END PROGRAM
7132 1.1 mrg @end smallexample
7133 1.1 mrg
7134 1.1 mrg @item @emph{See also}:
7135 1.1 mrg @ref{GET_ENVIRONMENT_VARIABLE}
7136 1.1 mrg @end table
7137 1.1 mrg
7138 1.1 mrg
7139 1.1 mrg
7140 1.1 mrg @node GET_ENVIRONMENT_VARIABLE
7141 1.1 mrg @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
7142 1.1 mrg @fnindex GET_ENVIRONMENT_VARIABLE
7143 1.1 mrg @cindex environment variable
7144 1.1 mrg
7145 1.1 mrg @table @asis
7146 1.1 mrg @item @emph{Description}:
7147 1.1 mrg Get the @var{VALUE} of the environmental variable @var{NAME}.
7148 1.1 mrg
7149 1.1 mrg Note that @code{GET_ENVIRONMENT_VARIABLE} need not be thread-safe. It
7150 1.1 mrg is the responsibility of the user to ensure that the environment is
7151 1.1 mrg not being updated concurrently with a call to the
7152 1.1 mrg @code{GET_ENVIRONMENT_VARIABLE} intrinsic.
7153 1.1 mrg
7154 1.1 mrg @item @emph{Standard}:
7155 1.1 mrg Fortran 2003 and later
7156 1.1 mrg
7157 1.1 mrg @item @emph{Class}:
7158 1.1 mrg Subroutine
7159 1.1 mrg
7160 1.1 mrg @item @emph{Syntax}:
7161 1.1 mrg @code{CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)}
7162 1.1 mrg
7163 1.1 mrg @item @emph{Arguments}:
7164 1.1 mrg @multitable @columnfractions .15 .70
7165 1.1 mrg @item @var{NAME} @tab Shall be a scalar of type @code{CHARACTER}
7166 1.1 mrg and of default kind.
7167 1.1 mrg @item @var{VALUE} @tab (Optional) Shall be a scalar of type @code{CHARACTER}
7168 1.1 mrg and of default kind.
7169 1.1 mrg @item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER}
7170 1.1 mrg and of default kind.
7171 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER}
7172 1.1 mrg and of default kind.
7173 1.1 mrg @item @var{TRIM_NAME} @tab (Optional) Shall be a scalar of type @code{LOGICAL}
7174 1.1 mrg and of default kind.
7175 1.1 mrg @end multitable
7176 1.1 mrg
7177 1.1 mrg @item @emph{Return value}:
7178 1.1 mrg Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is
7179 1.1 mrg not large enough to hold the data, it is truncated. If @var{NAME}
7180 1.1 mrg is not set, @var{VALUE} will be filled with blanks. Argument @var{LENGTH}
7181 1.1 mrg contains the length needed for storing the environment variable @var{NAME}
7182 1.1 mrg or zero if it is not present. @var{STATUS} is -1 if @var{VALUE} is present
7183 1.1 mrg but too short for the environment variable; it is 1 if the environment
7184 1.1 mrg variable does not exist and 2 if the processor does not support environment
7185 1.1 mrg variables; in all other cases @var{STATUS} is zero. If @var{TRIM_NAME} is
7186 1.1 mrg present with the value @code{.FALSE.}, the trailing blanks in @var{NAME}
7187 1.1 mrg are significant; otherwise they are not part of the environment variable
7188 1.1 mrg name.
7189 1.1 mrg
7190 1.1 mrg @item @emph{Example}:
7191 1.1 mrg @smallexample
7192 1.1 mrg PROGRAM test_getenv
7193 1.1 mrg CHARACTER(len=255) :: homedir
7194 1.1 mrg CALL get_environment_variable("HOME", homedir)
7195 1.1 mrg WRITE (*,*) TRIM(homedir)
7196 1.1 mrg END PROGRAM
7197 1.1 mrg @end smallexample
7198 1.1 mrg @end table
7199 1.1 mrg
7200 1.1 mrg
7201 1.1 mrg
7202 1.1 mrg @node GETGID
7203 1.1 mrg @section @code{GETGID} --- Group ID function
7204 1.1 mrg @fnindex GETGID
7205 1.1 mrg @cindex system, group ID
7206 1.1 mrg
7207 1.1 mrg @table @asis
7208 1.1 mrg @item @emph{Description}:
7209 1.1 mrg Returns the numerical group ID of the current process.
7210 1.1 mrg
7211 1.1 mrg @item @emph{Standard}:
7212 1.1 mrg GNU extension
7213 1.1 mrg
7214 1.1 mrg @item @emph{Class}:
7215 1.1 mrg Function
7216 1.1 mrg
7217 1.1 mrg @item @emph{Syntax}:
7218 1.1 mrg @code{RESULT = GETGID()}
7219 1.1 mrg
7220 1.1 mrg @item @emph{Return value}:
7221 1.1 mrg The return value of @code{GETGID} is an @code{INTEGER} of the default
7222 1.1 mrg kind.
7223 1.1 mrg
7224 1.1 mrg
7225 1.1 mrg @item @emph{Example}:
7226 1.1 mrg See @code{GETPID} for an example.
7227 1.1 mrg
7228 1.1 mrg @item @emph{See also}:
7229 1.1.1.2 mrg @ref{GETPID}, @gol
7230 1.1.1.2 mrg @ref{GETUID}
7231 1.1 mrg @end table
7232 1.1 mrg
7233 1.1 mrg
7234 1.1 mrg
7235 1.1 mrg @node GETLOG
7236 1.1 mrg @section @code{GETLOG} --- Get login name
7237 1.1 mrg @fnindex GETLOG
7238 1.1 mrg @cindex system, login name
7239 1.1 mrg @cindex login name
7240 1.1 mrg
7241 1.1 mrg @table @asis
7242 1.1 mrg @item @emph{Description}:
7243 1.1 mrg Gets the username under which the program is running.
7244 1.1 mrg
7245 1.1 mrg @item @emph{Standard}:
7246 1.1 mrg GNU extension
7247 1.1 mrg
7248 1.1 mrg @item @emph{Class}:
7249 1.1 mrg Subroutine
7250 1.1 mrg
7251 1.1 mrg @item @emph{Syntax}:
7252 1.1 mrg @code{CALL GETLOG(C)}
7253 1.1 mrg
7254 1.1 mrg @item @emph{Arguments}:
7255 1.1 mrg @multitable @columnfractions .15 .70
7256 1.1 mrg @item @var{C} @tab Shall be of type @code{CHARACTER} and of default kind.
7257 1.1 mrg @end multitable
7258 1.1 mrg
7259 1.1 mrg @item @emph{Return value}:
7260 1.1 mrg Stores the current user name in @var{LOGIN}. (On systems where POSIX
7261 1.1 mrg functions @code{geteuid} and @code{getpwuid} are not available, and
7262 1.1 mrg the @code{getlogin} function is not implemented either, this will
7263 1.1 mrg return a blank string.)
7264 1.1 mrg
7265 1.1 mrg @item @emph{Example}:
7266 1.1 mrg @smallexample
7267 1.1 mrg PROGRAM TEST_GETLOG
7268 1.1 mrg CHARACTER(32) :: login
7269 1.1 mrg CALL GETLOG(login)
7270 1.1 mrg WRITE(*,*) login
7271 1.1 mrg END PROGRAM
7272 1.1 mrg @end smallexample
7273 1.1 mrg
7274 1.1 mrg @item @emph{See also}:
7275 1.1 mrg @ref{GETUID}
7276 1.1 mrg @end table
7277 1.1 mrg
7278 1.1 mrg
7279 1.1 mrg
7280 1.1 mrg @node GETPID
7281 1.1 mrg @section @code{GETPID} --- Process ID function
7282 1.1 mrg @fnindex GETPID
7283 1.1 mrg @cindex system, process ID
7284 1.1 mrg @cindex process ID
7285 1.1 mrg
7286 1.1 mrg @table @asis
7287 1.1 mrg @item @emph{Description}:
7288 1.1 mrg Returns the numerical process identifier of the current process.
7289 1.1 mrg
7290 1.1 mrg @item @emph{Standard}:
7291 1.1 mrg GNU extension
7292 1.1 mrg
7293 1.1 mrg @item @emph{Class}:
7294 1.1 mrg Function
7295 1.1 mrg
7296 1.1 mrg @item @emph{Syntax}:
7297 1.1 mrg @code{RESULT = GETPID()}
7298 1.1 mrg
7299 1.1 mrg @item @emph{Return value}:
7300 1.1 mrg The return value of @code{GETPID} is an @code{INTEGER} of the default
7301 1.1 mrg kind.
7302 1.1 mrg
7303 1.1 mrg
7304 1.1 mrg @item @emph{Example}:
7305 1.1 mrg @smallexample
7306 1.1 mrg program info
7307 1.1 mrg print *, "The current process ID is ", getpid()
7308 1.1 mrg print *, "Your numerical user ID is ", getuid()
7309 1.1 mrg print *, "Your numerical group ID is ", getgid()
7310 1.1 mrg end program info
7311 1.1 mrg @end smallexample
7312 1.1 mrg
7313 1.1 mrg @item @emph{See also}:
7314 1.1.1.2 mrg @ref{GETGID}, @gol
7315 1.1.1.2 mrg @ref{GETUID}
7316 1.1 mrg @end table
7317 1.1 mrg
7318 1.1 mrg
7319 1.1 mrg
7320 1.1 mrg @node GETUID
7321 1.1 mrg @section @code{GETUID} --- User ID function
7322 1.1 mrg @fnindex GETUID
7323 1.1 mrg @cindex system, user ID
7324 1.1 mrg @cindex user id
7325 1.1 mrg
7326 1.1 mrg @table @asis
7327 1.1 mrg @item @emph{Description}:
7328 1.1 mrg Returns the numerical user ID of the current process.
7329 1.1 mrg
7330 1.1 mrg @item @emph{Standard}:
7331 1.1 mrg GNU extension
7332 1.1 mrg
7333 1.1 mrg @item @emph{Class}:
7334 1.1 mrg Function
7335 1.1 mrg
7336 1.1 mrg @item @emph{Syntax}:
7337 1.1 mrg @code{RESULT = GETUID()}
7338 1.1 mrg
7339 1.1 mrg @item @emph{Return value}:
7340 1.1 mrg The return value of @code{GETUID} is an @code{INTEGER} of the default
7341 1.1 mrg kind.
7342 1.1 mrg
7343 1.1 mrg
7344 1.1 mrg @item @emph{Example}:
7345 1.1 mrg See @code{GETPID} for an example.
7346 1.1 mrg
7347 1.1 mrg @item @emph{See also}:
7348 1.1.1.2 mrg @ref{GETPID}, @gol
7349 1.1.1.2 mrg @ref{GETLOG}
7350 1.1 mrg @end table
7351 1.1 mrg
7352 1.1 mrg
7353 1.1 mrg
7354 1.1 mrg @node GMTIME
7355 1.1 mrg @section @code{GMTIME} --- Convert time to GMT info
7356 1.1 mrg @fnindex GMTIME
7357 1.1 mrg @cindex time, conversion to GMT info
7358 1.1 mrg
7359 1.1 mrg @table @asis
7360 1.1 mrg @item @emph{Description}:
7361 1.1 mrg Given a system time value @var{TIME} (as provided by the @ref{TIME}
7362 1.1 mrg intrinsic), fills @var{VALUES} with values extracted from it appropriate
7363 1.1 mrg to the UTC time zone (Universal Coordinated Time, also known in some
7364 1.1 mrg countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
7365 1.1 mrg
7366 1.1 mrg This intrinsic routine is provided for backwards compatibility with
7367 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of
7368 1.1 mrg the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
7369 1.1 mrg standard.
7370 1.1 mrg
7371 1.1 mrg @item @emph{Standard}:
7372 1.1 mrg GNU extension
7373 1.1 mrg
7374 1.1 mrg @item @emph{Class}:
7375 1.1 mrg Subroutine
7376 1.1 mrg
7377 1.1 mrg @item @emph{Syntax}:
7378 1.1 mrg @code{CALL GMTIME(TIME, VALUES)}
7379 1.1 mrg
7380 1.1 mrg @item @emph{Arguments}:
7381 1.1 mrg @multitable @columnfractions .15 .70
7382 1.1 mrg @item @var{TIME} @tab An @code{INTEGER} scalar expression
7383 1.1 mrg corresponding to a system time, with @code{INTENT(IN)}.
7384 1.1 mrg @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
7385 1.1 mrg with @code{INTENT(OUT)}.
7386 1.1 mrg @end multitable
7387 1.1 mrg
7388 1.1 mrg @item @emph{Return value}:
7389 1.1 mrg The elements of @var{VALUES} are assigned as follows:
7390 1.1 mrg @enumerate
7391 1.1 mrg @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
7392 1.1 mrg seconds
7393 1.1 mrg @item Minutes after the hour, range 0--59
7394 1.1 mrg @item Hours past midnight, range 0--23
7395 1.1 mrg @item Day of month, range 1--31
7396 1.1 mrg @item Number of months since January, range 0--11
7397 1.1 mrg @item Years since 1900
7398 1.1 mrg @item Number of days since Sunday, range 0--6
7399 1.1 mrg @item Days since January 1, range 0--365
7400 1.1 mrg @item Daylight savings indicator: positive if daylight savings is in
7401 1.1 mrg effect, zero if not, and negative if the information is not available.
7402 1.1 mrg @end enumerate
7403 1.1 mrg
7404 1.1 mrg @item @emph{See also}:
7405 1.1.1.2 mrg @ref{DATE_AND_TIME}, @gol
7406 1.1.1.2 mrg @ref{CTIME}, @gol
7407 1.1.1.2 mrg @ref{LTIME}, @gol
7408 1.1.1.2 mrg @ref{TIME}, @gol
7409 1.1.1.2 mrg @ref{TIME8}
7410 1.1 mrg @end table
7411 1.1 mrg
7412 1.1 mrg
7413 1.1 mrg
7414 1.1 mrg @node HOSTNM
7415 1.1 mrg @section @code{HOSTNM} --- Get system host name
7416 1.1 mrg @fnindex HOSTNM
7417 1.1 mrg @cindex system, host name
7418 1.1 mrg
7419 1.1 mrg @table @asis
7420 1.1 mrg @item @emph{Description}:
7421 1.1 mrg Retrieves the host name of the system on which the program is running.
7422 1.1 mrg
7423 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
7424 1.1 mrg only one form can be used in any given program unit.
7425 1.1 mrg
7426 1.1 mrg @item @emph{Standard}:
7427 1.1 mrg GNU extension
7428 1.1 mrg
7429 1.1 mrg @item @emph{Class}:
7430 1.1 mrg Subroutine, function
7431 1.1 mrg
7432 1.1 mrg @item @emph{Syntax}:
7433 1.1 mrg @multitable @columnfractions .80
7434 1.1 mrg @item @code{CALL HOSTNM(C [, STATUS])}
7435 1.1 mrg @item @code{STATUS = HOSTNM(NAME)}
7436 1.1 mrg @end multitable
7437 1.1 mrg
7438 1.1 mrg @item @emph{Arguments}:
7439 1.1 mrg @multitable @columnfractions .15 .70
7440 1.1 mrg @item @var{C} @tab Shall of type @code{CHARACTER} and of default kind.
7441 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
7442 1.1 mrg Returns 0 on success, or a system specific error code otherwise.
7443 1.1 mrg @end multitable
7444 1.1 mrg
7445 1.1 mrg @item @emph{Return value}:
7446 1.1 mrg In either syntax, @var{NAME} is set to the current hostname if it can
7447 1.1 mrg be obtained, or to a blank string otherwise.
7448 1.1 mrg
7449 1.1 mrg @end table
7450 1.1 mrg
7451 1.1 mrg
7452 1.1 mrg
7453 1.1 mrg @node HUGE
7454 1.1 mrg @section @code{HUGE} --- Largest number of a kind
7455 1.1 mrg @fnindex HUGE
7456 1.1 mrg @cindex limits, largest number
7457 1.1 mrg @cindex model representation, largest number
7458 1.1 mrg
7459 1.1 mrg @table @asis
7460 1.1 mrg @item @emph{Description}:
7461 1.1 mrg @code{HUGE(X)} returns the largest number that is not an infinity in
7462 1.1 mrg the model of the type of @code{X}.
7463 1.1 mrg
7464 1.1 mrg @item @emph{Standard}:
7465 1.1.1.2 mrg Fortran 90 and later
7466 1.1 mrg
7467 1.1 mrg @item @emph{Class}:
7468 1.1 mrg Inquiry function
7469 1.1 mrg
7470 1.1 mrg @item @emph{Syntax}:
7471 1.1 mrg @code{RESULT = HUGE(X)}
7472 1.1 mrg
7473 1.1 mrg @item @emph{Arguments}:
7474 1.1 mrg @multitable @columnfractions .15 .70
7475 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
7476 1.1 mrg @end multitable
7477 1.1 mrg
7478 1.1 mrg @item @emph{Return value}:
7479 1.1 mrg The return value is of the same type and kind as @var{X}
7480 1.1 mrg
7481 1.1 mrg @item @emph{Example}:
7482 1.1 mrg @smallexample
7483 1.1 mrg program test_huge_tiny
7484 1.1 mrg print *, huge(0), huge(0.0), huge(0.0d0)
7485 1.1 mrg print *, tiny(0.0), tiny(0.0d0)
7486 1.1 mrg end program test_huge_tiny
7487 1.1 mrg @end smallexample
7488 1.1 mrg @end table
7489 1.1 mrg
7490 1.1 mrg
7491 1.1 mrg
7492 1.1 mrg @node HYPOT
7493 1.1 mrg @section @code{HYPOT} --- Euclidean distance function
7494 1.1 mrg @fnindex HYPOT
7495 1.1 mrg @cindex Euclidean distance
7496 1.1 mrg
7497 1.1 mrg @table @asis
7498 1.1 mrg @item @emph{Description}:
7499 1.1 mrg @code{HYPOT(X,Y)} is the Euclidean distance function. It is equal to
7500 1.1 mrg @math{\sqrt{X^2 + Y^2}}, without undue underflow or overflow.
7501 1.1 mrg
7502 1.1 mrg @item @emph{Standard}:
7503 1.1 mrg Fortran 2008 and later
7504 1.1 mrg
7505 1.1 mrg @item @emph{Class}:
7506 1.1 mrg Elemental function
7507 1.1 mrg
7508 1.1 mrg @item @emph{Syntax}:
7509 1.1 mrg @code{RESULT = HYPOT(X, Y)}
7510 1.1 mrg
7511 1.1 mrg @item @emph{Arguments}:
7512 1.1 mrg @multitable @columnfractions .15 .70
7513 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
7514 1.1 mrg @item @var{Y} @tab The type and kind type parameter shall be the same as
7515 1.1 mrg @var{X}.
7516 1.1 mrg @end multitable
7517 1.1 mrg
7518 1.1 mrg @item @emph{Return value}:
7519 1.1 mrg The return value has the same type and kind type parameter as @var{X}.
7520 1.1 mrg
7521 1.1 mrg @item @emph{Example}:
7522 1.1 mrg @smallexample
7523 1.1 mrg program test_hypot
7524 1.1 mrg real(4) :: x = 1.e0_4, y = 0.5e0_4
7525 1.1 mrg x = hypot(x,y)
7526 1.1 mrg end program test_hypot
7527 1.1 mrg @end smallexample
7528 1.1 mrg @end table
7529 1.1 mrg
7530 1.1 mrg
7531 1.1 mrg
7532 1.1 mrg @node IACHAR
7533 1.1 mrg @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
7534 1.1 mrg @fnindex IACHAR
7535 1.1 mrg @cindex @acronym{ASCII} collating sequence
7536 1.1 mrg @cindex collating sequence, @acronym{ASCII}
7537 1.1 mrg @cindex conversion, to integer
7538 1.1 mrg
7539 1.1 mrg @table @asis
7540 1.1 mrg @item @emph{Description}:
7541 1.1 mrg @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
7542 1.1 mrg in the first character position of @code{C}.
7543 1.1 mrg
7544 1.1 mrg @item @emph{Standard}:
7545 1.1 mrg Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
7546 1.1 mrg
7547 1.1 mrg @item @emph{Class}:
7548 1.1 mrg Elemental function
7549 1.1 mrg
7550 1.1 mrg @item @emph{Syntax}:
7551 1.1 mrg @code{RESULT = IACHAR(C [, KIND])}
7552 1.1 mrg
7553 1.1 mrg @item @emph{Arguments}:
7554 1.1 mrg @multitable @columnfractions .15 .70
7555 1.1 mrg @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
7556 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7557 1.1 mrg expression indicating the kind parameter of the result.
7558 1.1 mrg @end multitable
7559 1.1 mrg
7560 1.1 mrg @item @emph{Return value}:
7561 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7562 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
7563 1.1 mrg
7564 1.1 mrg @item @emph{Example}:
7565 1.1 mrg @smallexample
7566 1.1 mrg program test_iachar
7567 1.1 mrg integer i
7568 1.1 mrg i = iachar(' ')
7569 1.1 mrg end program test_iachar
7570 1.1 mrg @end smallexample
7571 1.1 mrg
7572 1.1 mrg @item @emph{Note}:
7573 1.1 mrg See @ref{ICHAR} for a discussion of converting between numerical values
7574 1.1 mrg and formatted string representations.
7575 1.1 mrg
7576 1.1 mrg @item @emph{See also}:
7577 1.1.1.2 mrg @ref{ACHAR}, @gol
7578 1.1.1.2 mrg @ref{CHAR}, @gol
7579 1.1.1.2 mrg @ref{ICHAR}
7580 1.1 mrg @end table
7581 1.1 mrg
7582 1.1 mrg
7583 1.1 mrg
7584 1.1 mrg @node IALL
7585 1.1 mrg @section @code{IALL} --- Bitwise AND of array elements
7586 1.1 mrg @fnindex IALL
7587 1.1 mrg @cindex array, AND
7588 1.1 mrg @cindex bits, AND of array elements
7589 1.1 mrg
7590 1.1 mrg @table @asis
7591 1.1 mrg @item @emph{Description}:
7592 1.1 mrg Reduces with bitwise AND the elements of @var{ARRAY} along dimension @var{DIM}
7593 1.1 mrg if the corresponding element in @var{MASK} is @code{TRUE}.
7594 1.1 mrg
7595 1.1 mrg @item @emph{Standard}:
7596 1.1 mrg Fortran 2008 and later
7597 1.1 mrg
7598 1.1 mrg @item @emph{Class}:
7599 1.1 mrg Transformational function
7600 1.1 mrg
7601 1.1 mrg @item @emph{Syntax}:
7602 1.1 mrg @multitable @columnfractions .80
7603 1.1 mrg @item @code{RESULT = IALL(ARRAY[, MASK])}
7604 1.1 mrg @item @code{RESULT = IALL(ARRAY, DIM[, MASK])}
7605 1.1 mrg @end multitable
7606 1.1 mrg
7607 1.1 mrg @item @emph{Arguments}:
7608 1.1 mrg @multitable @columnfractions .15 .70
7609 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
7610 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type
7611 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n
7612 1.1 mrg equals the rank of @var{ARRAY}.
7613 1.1 mrg @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
7614 1.1 mrg and either be a scalar or an array of the same shape as @var{ARRAY}.
7615 1.1 mrg @end multitable
7616 1.1 mrg
7617 1.1 mrg @item @emph{Return value}:
7618 1.1 mrg The result is of the same type as @var{ARRAY}.
7619 1.1 mrg
7620 1.1 mrg If @var{DIM} is absent, a scalar with the bitwise ALL of all elements in
7621 1.1 mrg @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
7622 1.1 mrg the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
7623 1.1 mrg dimension @var{DIM} dropped is returned.
7624 1.1 mrg
7625 1.1 mrg @item @emph{Example}:
7626 1.1 mrg @smallexample
7627 1.1 mrg PROGRAM test_iall
7628 1.1 mrg INTEGER(1) :: a(2)
7629 1.1 mrg
7630 1.1 mrg a(1) = b'00100100'
7631 1.1 mrg a(2) = b'01101010'
7632 1.1 mrg
7633 1.1 mrg ! prints 00100000
7634 1.1 mrg PRINT '(b8.8)', IALL(a)
7635 1.1 mrg END PROGRAM
7636 1.1 mrg @end smallexample
7637 1.1 mrg
7638 1.1 mrg @item @emph{See also}:
7639 1.1.1.2 mrg @ref{IANY}, @gol
7640 1.1.1.2 mrg @ref{IPARITY}, @gol
7641 1.1.1.2 mrg @ref{IAND}
7642 1.1 mrg @end table
7643 1.1 mrg
7644 1.1 mrg
7645 1.1 mrg
7646 1.1 mrg @node IAND
7647 1.1 mrg @section @code{IAND} --- Bitwise logical and
7648 1.1 mrg @fnindex IAND
7649 1.1 mrg @fnindex BIAND
7650 1.1 mrg @fnindex IIAND
7651 1.1 mrg @fnindex JIAND
7652 1.1 mrg @fnindex KIAND
7653 1.1 mrg @cindex bitwise logical and
7654 1.1 mrg @cindex logical and, bitwise
7655 1.1 mrg
7656 1.1 mrg @table @asis
7657 1.1 mrg @item @emph{Description}:
7658 1.1 mrg Bitwise logical @code{AND}.
7659 1.1 mrg
7660 1.1 mrg @item @emph{Standard}:
7661 1.1.1.2 mrg Fortran 90 and later, with boz-literal-constant Fortran 2008 and later, has overloads that are GNU extensions
7662 1.1 mrg
7663 1.1 mrg @item @emph{Class}:
7664 1.1 mrg Elemental function
7665 1.1 mrg
7666 1.1 mrg @item @emph{Syntax}:
7667 1.1 mrg @code{RESULT = IAND(I, J)}
7668 1.1 mrg
7669 1.1 mrg @item @emph{Arguments}:
7670 1.1 mrg @multitable @columnfractions .15 .70
7671 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant.
7672 1.1 mrg @item @var{J} @tab The type shall be @code{INTEGER} with the same
7673 1.1 mrg kind type parameter as @var{I} or a boz-literal-constant.
7674 1.1 mrg @var{I} and @var{J} shall not both be boz-literal-constants.
7675 1.1 mrg @end multitable
7676 1.1 mrg
7677 1.1 mrg @item @emph{Return value}:
7678 1.1 mrg The return type is @code{INTEGER} with the kind type parameter of the
7679 1.1 mrg arguments.
7680 1.1 mrg A boz-literal-constant is converted to an @code{INTEGER} with the kind
7681 1.1 mrg type parameter of the other argument as-if a call to @ref{INT} occurred.
7682 1.1 mrg
7683 1.1 mrg @item @emph{Example}:
7684 1.1 mrg @smallexample
7685 1.1 mrg PROGRAM test_iand
7686 1.1 mrg INTEGER :: a, b
7687 1.1 mrg DATA a / Z'F' /, b / Z'3' /
7688 1.1 mrg WRITE (*,*) IAND(a, b)
7689 1.1 mrg END PROGRAM
7690 1.1 mrg @end smallexample
7691 1.1 mrg
7692 1.1 mrg @item @emph{Specific names}:
7693 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
7694 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
7695 1.1.1.2 mrg @item @code{IAND(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
7696 1.1 mrg @item @code{BIAND(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7697 1.1 mrg @item @code{IIAND(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7698 1.1 mrg @item @code{JIAND(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7699 1.1 mrg @item @code{KIAND(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7700 1.1 mrg @end multitable
7701 1.1 mrg
7702 1.1 mrg @item @emph{See also}:
7703 1.1.1.2 mrg @ref{IOR}, @gol
7704 1.1.1.2 mrg @ref{IEOR}, @gol
7705 1.1.1.2 mrg @ref{IBITS}, @gol
7706 1.1.1.2 mrg @ref{IBSET}, @gol
7707 1.1.1.2 mrg @ref{IBCLR}, @gol
7708 1.1.1.2 mrg @ref{NOT}
7709 1.1 mrg @end table
7710 1.1 mrg
7711 1.1 mrg
7712 1.1 mrg
7713 1.1 mrg @node IANY
7714 1.1 mrg @section @code{IANY} --- Bitwise OR of array elements
7715 1.1 mrg @fnindex IANY
7716 1.1 mrg @cindex array, OR
7717 1.1 mrg @cindex bits, OR of array elements
7718 1.1 mrg
7719 1.1 mrg @table @asis
7720 1.1 mrg @item @emph{Description}:
7721 1.1 mrg Reduces with bitwise OR (inclusive or) the elements of @var{ARRAY} along
7722 1.1 mrg dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
7723 1.1 mrg
7724 1.1 mrg @item @emph{Standard}:
7725 1.1 mrg Fortran 2008 and later
7726 1.1 mrg
7727 1.1 mrg @item @emph{Class}:
7728 1.1 mrg Transformational function
7729 1.1 mrg
7730 1.1 mrg @item @emph{Syntax}:
7731 1.1 mrg @multitable @columnfractions .80
7732 1.1 mrg @item @code{RESULT = IANY(ARRAY[, MASK])}
7733 1.1 mrg @item @code{RESULT = IANY(ARRAY, DIM[, MASK])}
7734 1.1 mrg @end multitable
7735 1.1 mrg
7736 1.1 mrg @item @emph{Arguments}:
7737 1.1 mrg @multitable @columnfractions .15 .70
7738 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
7739 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type
7740 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n
7741 1.1 mrg equals the rank of @var{ARRAY}.
7742 1.1 mrg @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
7743 1.1 mrg and either be a scalar or an array of the same shape as @var{ARRAY}.
7744 1.1 mrg @end multitable
7745 1.1 mrg
7746 1.1 mrg @item @emph{Return value}:
7747 1.1 mrg The result is of the same type as @var{ARRAY}.
7748 1.1 mrg
7749 1.1 mrg If @var{DIM} is absent, a scalar with the bitwise OR of all elements in
7750 1.1 mrg @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
7751 1.1 mrg the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
7752 1.1 mrg dimension @var{DIM} dropped is returned.
7753 1.1 mrg
7754 1.1 mrg @item @emph{Example}:
7755 1.1 mrg @smallexample
7756 1.1 mrg PROGRAM test_iany
7757 1.1 mrg INTEGER(1) :: a(2)
7758 1.1 mrg
7759 1.1 mrg a(1) = b'00100100'
7760 1.1 mrg a(2) = b'01101010'
7761 1.1 mrg
7762 1.1 mrg ! prints 01101110
7763 1.1 mrg PRINT '(b8.8)', IANY(a)
7764 1.1 mrg END PROGRAM
7765 1.1 mrg @end smallexample
7766 1.1 mrg
7767 1.1 mrg @item @emph{See also}:
7768 1.1.1.2 mrg @ref{IPARITY}, @gol
7769 1.1.1.2 mrg @ref{IALL}, @gol
7770 1.1.1.2 mrg @ref{IOR}
7771 1.1 mrg @end table
7772 1.1 mrg
7773 1.1 mrg
7774 1.1 mrg
7775 1.1 mrg @node IARGC
7776 1.1 mrg @section @code{IARGC} --- Get the number of command line arguments
7777 1.1 mrg @fnindex IARGC
7778 1.1 mrg @cindex command-line arguments
7779 1.1 mrg @cindex command-line arguments, number of
7780 1.1 mrg @cindex arguments, to program
7781 1.1 mrg
7782 1.1 mrg @table @asis
7783 1.1 mrg @item @emph{Description}:
7784 1.1 mrg @code{IARGC} returns the number of arguments passed on the
7785 1.1 mrg command line when the containing program was invoked.
7786 1.1 mrg
7787 1.1 mrg This intrinsic routine is provided for backwards compatibility with
7788 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of
7789 1.1 mrg the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
7790 1.1 mrg standard.
7791 1.1 mrg
7792 1.1 mrg @item @emph{Standard}:
7793 1.1 mrg GNU extension
7794 1.1 mrg
7795 1.1 mrg @item @emph{Class}:
7796 1.1 mrg Function
7797 1.1 mrg
7798 1.1 mrg @item @emph{Syntax}:
7799 1.1 mrg @code{RESULT = IARGC()}
7800 1.1 mrg
7801 1.1 mrg @item @emph{Arguments}:
7802 1.1.1.2 mrg None
7803 1.1 mrg
7804 1.1 mrg @item @emph{Return value}:
7805 1.1 mrg The number of command line arguments, type @code{INTEGER(4)}.
7806 1.1 mrg
7807 1.1 mrg @item @emph{Example}:
7808 1.1 mrg See @ref{GETARG}
7809 1.1 mrg
7810 1.1 mrg @item @emph{See also}:
7811 1.1.1.2 mrg GNU Fortran 77 compatibility subroutine: @gol
7812 1.1.1.2 mrg @ref{GETARG} @gol
7813 1.1.1.2 mrg Fortran 2003 functions and subroutines: @gol
7814 1.1.1.2 mrg @ref{GET_COMMAND}, @gol
7815 1.1.1.2 mrg @ref{GET_COMMAND_ARGUMENT}, @gol
7816 1.1.1.2 mrg @ref{COMMAND_ARGUMENT_COUNT}
7817 1.1 mrg @end table
7818 1.1 mrg
7819 1.1 mrg
7820 1.1 mrg
7821 1.1 mrg @node IBCLR
7822 1.1 mrg @section @code{IBCLR} --- Clear bit
7823 1.1 mrg @fnindex IBCLR
7824 1.1 mrg @fnindex BBCLR
7825 1.1 mrg @fnindex IIBCLR
7826 1.1 mrg @fnindex JIBCLR
7827 1.1 mrg @fnindex KIBCLR
7828 1.1 mrg @cindex bits, unset
7829 1.1 mrg @cindex bits, clear
7830 1.1 mrg
7831 1.1 mrg @table @asis
7832 1.1 mrg @item @emph{Description}:
7833 1.1 mrg @code{IBCLR} returns the value of @var{I} with the bit at position
7834 1.1 mrg @var{POS} set to zero.
7835 1.1 mrg
7836 1.1 mrg @item @emph{Standard}:
7837 1.1.1.2 mrg Fortran 90 and later, has overloads that are GNU extensions
7838 1.1 mrg
7839 1.1 mrg @item @emph{Class}:
7840 1.1 mrg Elemental function
7841 1.1 mrg
7842 1.1 mrg @item @emph{Syntax}:
7843 1.1 mrg @code{RESULT = IBCLR(I, POS)}
7844 1.1 mrg
7845 1.1 mrg @item @emph{Arguments}:
7846 1.1 mrg @multitable @columnfractions .15 .70
7847 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
7848 1.1 mrg @item @var{POS} @tab The type shall be @code{INTEGER}.
7849 1.1 mrg @end multitable
7850 1.1 mrg
7851 1.1 mrg @item @emph{Return value}:
7852 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
7853 1.1 mrg @var{I}.
7854 1.1 mrg
7855 1.1 mrg @item @emph{Specific names}:
7856 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
7857 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
7858 1.1.1.2 mrg @item @code{IBCLR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
7859 1.1 mrg @item @code{BBCLR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7860 1.1 mrg @item @code{IIBCLR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7861 1.1 mrg @item @code{JIBCLR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7862 1.1 mrg @item @code{KIBCLR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7863 1.1 mrg @end multitable
7864 1.1 mrg
7865 1.1 mrg @item @emph{See also}:
7866 1.1.1.2 mrg @ref{IBITS}, @gol
7867 1.1.1.2 mrg @ref{IBSET}, @gol
7868 1.1.1.2 mrg @ref{IAND}, @gol
7869 1.1.1.2 mrg @ref{IOR}, @gol
7870 1.1.1.2 mrg @ref{IEOR}, @gol
7871 1.1.1.2 mrg @ref{MVBITS}
7872 1.1 mrg @end table
7873 1.1 mrg
7874 1.1 mrg
7875 1.1 mrg
7876 1.1 mrg @node IBITS
7877 1.1 mrg @section @code{IBITS} --- Bit extraction
7878 1.1 mrg @fnindex IBITS
7879 1.1 mrg @fnindex BBITS
7880 1.1 mrg @fnindex IIBITS
7881 1.1 mrg @fnindex JIBITS
7882 1.1 mrg @fnindex KIBITS
7883 1.1 mrg @cindex bits, get
7884 1.1 mrg @cindex bits, extract
7885 1.1 mrg
7886 1.1 mrg @table @asis
7887 1.1 mrg @item @emph{Description}:
7888 1.1 mrg @code{IBITS} extracts a field of length @var{LEN} from @var{I},
7889 1.1 mrg starting from bit position @var{POS} and extending left for @var{LEN}
7890 1.1 mrg bits. The result is right-justified and the remaining bits are
7891 1.1 mrg zeroed. The value of @code{POS+LEN} must be less than or equal to the
7892 1.1 mrg value @code{BIT_SIZE(I)}.
7893 1.1 mrg
7894 1.1 mrg @item @emph{Standard}:
7895 1.1.1.2 mrg Fortran 90 and later, has overloads that are GNU extensions
7896 1.1 mrg
7897 1.1 mrg @item @emph{Class}:
7898 1.1 mrg Elemental function
7899 1.1 mrg
7900 1.1 mrg @item @emph{Syntax}:
7901 1.1 mrg @code{RESULT = IBITS(I, POS, LEN)}
7902 1.1 mrg
7903 1.1 mrg @item @emph{Arguments}:
7904 1.1 mrg @multitable @columnfractions .15 .70
7905 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
7906 1.1 mrg @item @var{POS} @tab The type shall be @code{INTEGER}.
7907 1.1 mrg @item @var{LEN} @tab The type shall be @code{INTEGER}.
7908 1.1 mrg @end multitable
7909 1.1 mrg
7910 1.1 mrg @item @emph{Return value}:
7911 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
7912 1.1 mrg @var{I}.
7913 1.1 mrg
7914 1.1 mrg @item @emph{Specific names}:
7915 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
7916 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
7917 1.1.1.2 mrg @item @code{IBITS(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
7918 1.1 mrg @item @code{BBITS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7919 1.1 mrg @item @code{IIBITS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7920 1.1 mrg @item @code{JIBITS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7921 1.1 mrg @item @code{KIBITS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7922 1.1 mrg @end multitable
7923 1.1 mrg
7924 1.1 mrg @item @emph{See also}:
7925 1.1.1.2 mrg @ref{BIT_SIZE}, @gol
7926 1.1.1.2 mrg @ref{IBCLR}, @gol
7927 1.1.1.2 mrg @ref{IBSET}, @gol
7928 1.1.1.2 mrg @ref{IAND}, @gol
7929 1.1.1.2 mrg @ref{IOR}, @gol
7930 1.1.1.2 mrg @ref{IEOR}
7931 1.1 mrg @end table
7932 1.1 mrg
7933 1.1 mrg
7934 1.1 mrg
7935 1.1 mrg @node IBSET
7936 1.1 mrg @section @code{IBSET} --- Set bit
7937 1.1 mrg @fnindex IBSET
7938 1.1 mrg @fnindex BBSET
7939 1.1 mrg @fnindex IIBSET
7940 1.1 mrg @fnindex JIBSET
7941 1.1 mrg @fnindex KIBSET
7942 1.1 mrg @cindex bits, set
7943 1.1 mrg
7944 1.1 mrg @table @asis
7945 1.1 mrg @item @emph{Description}:
7946 1.1 mrg @code{IBSET} returns the value of @var{I} with the bit at position
7947 1.1 mrg @var{POS} set to one.
7948 1.1 mrg
7949 1.1 mrg @item @emph{Standard}:
7950 1.1.1.2 mrg Fortran 90 and later, has overloads that are GNU extensions
7951 1.1 mrg
7952 1.1 mrg @item @emph{Class}:
7953 1.1 mrg Elemental function
7954 1.1 mrg
7955 1.1 mrg @item @emph{Syntax}:
7956 1.1 mrg @code{RESULT = IBSET(I, POS)}
7957 1.1 mrg
7958 1.1 mrg @item @emph{Arguments}:
7959 1.1 mrg @multitable @columnfractions .15 .70
7960 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
7961 1.1 mrg @item @var{POS} @tab The type shall be @code{INTEGER}.
7962 1.1 mrg @end multitable
7963 1.1 mrg
7964 1.1 mrg @item @emph{Return value}:
7965 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
7966 1.1 mrg @var{I}.
7967 1.1 mrg
7968 1.1 mrg @item @emph{Specific names}:
7969 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
7970 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
7971 1.1.1.2 mrg @item @code{IBSET(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
7972 1.1 mrg @item @code{BBSET(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7973 1.1 mrg @item @code{IIBSET(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7974 1.1 mrg @item @code{JIBSET(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7975 1.1 mrg @item @code{KIBSET(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7976 1.1 mrg @end multitable
7977 1.1 mrg
7978 1.1 mrg @item @emph{See also}:
7979 1.1.1.2 mrg @ref{IBCLR}, @gol
7980 1.1.1.2 mrg @ref{IBITS}, @gol
7981 1.1.1.2 mrg @ref{IAND}, @gol
7982 1.1.1.2 mrg @ref{IOR}, @gol
7983 1.1.1.2 mrg @ref{IEOR}, @gol
7984 1.1.1.2 mrg @ref{MVBITS}
7985 1.1 mrg @end table
7986 1.1 mrg
7987 1.1 mrg
7988 1.1 mrg
7989 1.1 mrg @node ICHAR
7990 1.1 mrg @section @code{ICHAR} --- Character-to-integer conversion function
7991 1.1 mrg @fnindex ICHAR
7992 1.1 mrg @cindex conversion, to integer
7993 1.1 mrg
7994 1.1 mrg @table @asis
7995 1.1 mrg @item @emph{Description}:
7996 1.1 mrg @code{ICHAR(C)} returns the code for the character in the first character
7997 1.1 mrg position of @code{C} in the system's native character set.
7998 1.1 mrg The correspondence between characters and their codes is not necessarily
7999 1.1 mrg the same across different GNU Fortran implementations.
8000 1.1 mrg
8001 1.1 mrg @item @emph{Standard}:
8002 1.1.1.2 mrg Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
8003 1.1 mrg
8004 1.1 mrg @item @emph{Class}:
8005 1.1 mrg Elemental function
8006 1.1 mrg
8007 1.1 mrg @item @emph{Syntax}:
8008 1.1 mrg @code{RESULT = ICHAR(C [, KIND])}
8009 1.1 mrg
8010 1.1 mrg @item @emph{Arguments}:
8011 1.1 mrg @multitable @columnfractions .15 .70
8012 1.1 mrg @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
8013 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8014 1.1 mrg expression indicating the kind parameter of the result.
8015 1.1 mrg @end multitable
8016 1.1 mrg
8017 1.1 mrg @item @emph{Return value}:
8018 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8019 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
8020 1.1 mrg
8021 1.1 mrg @item @emph{Example}:
8022 1.1 mrg @smallexample
8023 1.1 mrg program test_ichar
8024 1.1 mrg integer i
8025 1.1 mrg i = ichar(' ')
8026 1.1 mrg end program test_ichar
8027 1.1 mrg @end smallexample
8028 1.1 mrg
8029 1.1 mrg @item @emph{Specific names}:
8030 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
8031 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
8032 1.1 mrg @item @code{ICHAR(C)} @tab @code{CHARACTER C} @tab @code{INTEGER(4)} @tab Fortran 77 and later
8033 1.1 mrg @end multitable
8034 1.1 mrg
8035 1.1 mrg @item @emph{Note}:
8036 1.1 mrg No intrinsic exists to convert between a numeric value and a formatted
8037 1.1 mrg character string representation -- for instance, given the
8038 1.1 mrg @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
8039 1.1 mrg @code{REAL} value with the value 154, or vice versa. Instead, this
8040 1.1 mrg functionality is provided by internal-file I/O, as in the following
8041 1.1 mrg example:
8042 1.1 mrg @smallexample
8043 1.1 mrg program read_val
8044 1.1 mrg integer value
8045 1.1 mrg character(len=10) string, string2
8046 1.1 mrg string = '154'
8047 1.1 mrg
8048 1.1 mrg ! Convert a string to a numeric value
8049 1.1 mrg read (string,'(I10)') value
8050 1.1 mrg print *, value
8051 1.1 mrg
8052 1.1 mrg ! Convert a value to a formatted string
8053 1.1 mrg write (string2,'(I10)') value
8054 1.1 mrg print *, string2
8055 1.1 mrg end program read_val
8056 1.1 mrg @end smallexample
8057 1.1 mrg
8058 1.1 mrg @item @emph{See also}:
8059 1.1.1.2 mrg @ref{ACHAR}, @gol
8060 1.1.1.2 mrg @ref{CHAR}, @gol
8061 1.1.1.2 mrg @ref{IACHAR}
8062 1.1 mrg @end table
8063 1.1 mrg
8064 1.1 mrg
8065 1.1 mrg
8066 1.1 mrg @node IDATE
8067 1.1 mrg @section @code{IDATE} --- Get current local time subroutine (day/month/year)
8068 1.1 mrg @fnindex IDATE
8069 1.1 mrg @cindex date, current
8070 1.1 mrg @cindex current date
8071 1.1 mrg
8072 1.1 mrg @table @asis
8073 1.1 mrg @item @emph{Description}:
8074 1.1 mrg @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the
8075 1.1 mrg current local time. The day (in the range 1-31), month (in the range 1-12),
8076 1.1 mrg and year appear in elements 1, 2, and 3 of @var{VALUES}, respectively.
8077 1.1 mrg The year has four significant digits.
8078 1.1 mrg
8079 1.1 mrg This intrinsic routine is provided for backwards compatibility with
8080 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of
8081 1.1 mrg the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
8082 1.1 mrg standard.
8083 1.1 mrg
8084 1.1 mrg @item @emph{Standard}:
8085 1.1 mrg GNU extension
8086 1.1 mrg
8087 1.1 mrg @item @emph{Class}:
8088 1.1 mrg Subroutine
8089 1.1 mrg
8090 1.1 mrg @item @emph{Syntax}:
8091 1.1 mrg @code{CALL IDATE(VALUES)}
8092 1.1 mrg
8093 1.1 mrg @item @emph{Arguments}:
8094 1.1 mrg @multitable @columnfractions .15 .70
8095 1.1 mrg @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
8096 1.1 mrg the kind shall be the default integer kind.
8097 1.1 mrg @end multitable
8098 1.1 mrg
8099 1.1 mrg @item @emph{Return value}:
8100 1.1 mrg Does not return anything.
8101 1.1 mrg
8102 1.1 mrg @item @emph{Example}:
8103 1.1 mrg @smallexample
8104 1.1 mrg program test_idate
8105 1.1 mrg integer, dimension(3) :: tarray
8106 1.1 mrg call idate(tarray)
8107 1.1 mrg print *, tarray(1)
8108 1.1 mrg print *, tarray(2)
8109 1.1 mrg print *, tarray(3)
8110 1.1 mrg end program test_idate
8111 1.1 mrg @end smallexample
8112 1.1 mrg
8113 1.1 mrg @item @emph{See also}:
8114 1.1 mrg @ref{DATE_AND_TIME}
8115 1.1 mrg @end table
8116 1.1 mrg
8117 1.1 mrg
8118 1.1 mrg @node IEOR
8119 1.1 mrg @section @code{IEOR} --- Bitwise logical exclusive or
8120 1.1 mrg @fnindex IEOR
8121 1.1 mrg @fnindex BIEOR
8122 1.1 mrg @fnindex IIEOR
8123 1.1 mrg @fnindex JIEOR
8124 1.1 mrg @fnindex KIEOR
8125 1.1 mrg @cindex bitwise logical exclusive or
8126 1.1 mrg @cindex logical exclusive or, bitwise
8127 1.1 mrg
8128 1.1 mrg @table @asis
8129 1.1 mrg @item @emph{Description}:
8130 1.1 mrg @code{IEOR} returns the bitwise Boolean exclusive-OR of @var{I} and
8131 1.1 mrg @var{J}.
8132 1.1 mrg
8133 1.1 mrg @item @emph{Standard}:
8134 1.1.1.2 mrg Fortran 90 and later, with boz-literal-constant Fortran 2008 and later, has overloads that are GNU extensions
8135 1.1 mrg
8136 1.1 mrg @item @emph{Class}:
8137 1.1 mrg Elemental function
8138 1.1 mrg
8139 1.1 mrg @item @emph{Syntax}:
8140 1.1 mrg @code{RESULT = IEOR(I, J)}
8141 1.1 mrg
8142 1.1 mrg @item @emph{Arguments}:
8143 1.1 mrg @multitable @columnfractions .15 .70
8144 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant.
8145 1.1 mrg @item @var{J} @tab The type shall be @code{INTEGER} with the same
8146 1.1 mrg kind type parameter as @var{I} or a boz-literal-constant.
8147 1.1 mrg @var{I} and @var{J} shall not both be boz-literal-constants.
8148 1.1 mrg @end multitable
8149 1.1 mrg
8150 1.1 mrg @item @emph{Return value}:
8151 1.1 mrg The return type is @code{INTEGER} with the kind type parameter of the
8152 1.1 mrg arguments.
8153 1.1 mrg A boz-literal-constant is converted to an @code{INTEGER} with the kind
8154 1.1 mrg type parameter of the other argument as-if a call to @ref{INT} occurred.
8155 1.1 mrg
8156 1.1 mrg @item @emph{Specific names}:
8157 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
8158 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
8159 1.1.1.2 mrg @item @code{IEOR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
8160 1.1 mrg @item @code{BIEOR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8161 1.1 mrg @item @code{IIEOR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8162 1.1 mrg @item @code{JIEOR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8163 1.1 mrg @item @code{KIEOR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8164 1.1 mrg @end multitable
8165 1.1 mrg
8166 1.1 mrg @item @emph{See also}:
8167 1.1.1.2 mrg @ref{IOR}, @gol
8168 1.1.1.2 mrg @ref{IAND}, @gol
8169 1.1.1.2 mrg @ref{IBITS}, @gol
8170 1.1.1.2 mrg @ref{IBSET}, @gol
8171 1.1.1.2 mrg @ref{IBCLR}, @gol
8172 1.1.1.2 mrg @ref{NOT}
8173 1.1 mrg @end table
8174 1.1 mrg
8175 1.1 mrg
8176 1.1 mrg
8177 1.1 mrg @node IERRNO
8178 1.1 mrg @section @code{IERRNO} --- Get the last system error number
8179 1.1 mrg @fnindex IERRNO
8180 1.1 mrg @cindex system, error handling
8181 1.1 mrg
8182 1.1 mrg @table @asis
8183 1.1 mrg @item @emph{Description}:
8184 1.1 mrg Returns the last system error number, as given by the C @code{errno}
8185 1.1 mrg variable.
8186 1.1 mrg
8187 1.1 mrg @item @emph{Standard}:
8188 1.1 mrg GNU extension
8189 1.1 mrg
8190 1.1 mrg @item @emph{Class}:
8191 1.1 mrg Function
8192 1.1 mrg
8193 1.1 mrg @item @emph{Syntax}:
8194 1.1 mrg @code{RESULT = IERRNO()}
8195 1.1 mrg
8196 1.1 mrg @item @emph{Arguments}:
8197 1.1.1.2 mrg None
8198 1.1 mrg
8199 1.1 mrg @item @emph{Return value}:
8200 1.1 mrg The return value is of type @code{INTEGER} and of the default integer
8201 1.1 mrg kind.
8202 1.1 mrg
8203 1.1 mrg @item @emph{See also}:
8204 1.1 mrg @ref{PERROR}
8205 1.1 mrg @end table
8206 1.1 mrg
8207 1.1 mrg
8208 1.1 mrg
8209 1.1 mrg @node IMAGE_INDEX
8210 1.1 mrg @section @code{IMAGE_INDEX} --- Function that converts a cosubscript to an image index
8211 1.1 mrg @fnindex IMAGE_INDEX
8212 1.1 mrg @cindex coarray, @code{IMAGE_INDEX}
8213 1.1 mrg @cindex images, cosubscript to image index conversion
8214 1.1 mrg
8215 1.1 mrg @table @asis
8216 1.1 mrg @item @emph{Description}:
8217 1.1 mrg Returns the image index belonging to a cosubscript.
8218 1.1 mrg
8219 1.1 mrg @item @emph{Standard}:
8220 1.1 mrg Fortran 2008 and later
8221 1.1 mrg
8222 1.1 mrg @item @emph{Class}:
8223 1.1 mrg Inquiry function.
8224 1.1 mrg
8225 1.1 mrg @item @emph{Syntax}:
8226 1.1 mrg @code{RESULT = IMAGE_INDEX(COARRAY, SUB)}
8227 1.1 mrg
8228 1.1.1.2 mrg @item @emph{Arguments}:
8229 1.1 mrg @multitable @columnfractions .15 .70
8230 1.1 mrg @item @var{COARRAY} @tab Coarray of any type.
8231 1.1 mrg @item @var{SUB} @tab default integer rank-1 array of a size equal to
8232 1.1 mrg the corank of @var{COARRAY}.
8233 1.1 mrg @end multitable
8234 1.1 mrg
8235 1.1 mrg
8236 1.1 mrg @item @emph{Return value}:
8237 1.1 mrg Scalar default integer with the value of the image index which corresponds
8238 1.1 mrg to the cosubscripts. For invalid cosubscripts the result is zero.
8239 1.1 mrg
8240 1.1 mrg @item @emph{Example}:
8241 1.1 mrg @smallexample
8242 1.1 mrg INTEGER :: array[2,-1:4,8,*]
8243 1.1 mrg ! Writes 28 (or 0 if there are fewer than 28 images)
8244 1.1 mrg WRITE (*,*) IMAGE_INDEX (array, [2,0,3,1])
8245 1.1 mrg @end smallexample
8246 1.1 mrg
8247 1.1 mrg @item @emph{See also}:
8248 1.1.1.2 mrg @ref{THIS_IMAGE}, @gol
8249 1.1.1.2 mrg @ref{NUM_IMAGES}
8250 1.1 mrg @end table
8251 1.1 mrg
8252 1.1 mrg
8253 1.1 mrg
8254 1.1 mrg @node INDEX intrinsic
8255 1.1 mrg @section @code{INDEX} --- Position of a substring within a string
8256 1.1 mrg @fnindex INDEX
8257 1.1 mrg @cindex substring position
8258 1.1 mrg @cindex string, find substring
8259 1.1 mrg
8260 1.1 mrg @table @asis
8261 1.1 mrg @item @emph{Description}:
8262 1.1 mrg Returns the position of the start of the first occurrence of string
8263 1.1 mrg @var{SUBSTRING} as a substring in @var{STRING}, counting from one. If
8264 1.1 mrg @var{SUBSTRING} is not present in @var{STRING}, zero is returned. If
8265 1.1 mrg the @var{BACK} argument is present and true, the return value is the
8266 1.1 mrg start of the last occurrence rather than the first.
8267 1.1 mrg
8268 1.1 mrg @item @emph{Standard}:
8269 1.1 mrg Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
8270 1.1 mrg
8271 1.1 mrg @item @emph{Class}:
8272 1.1 mrg Elemental function
8273 1.1 mrg
8274 1.1 mrg @item @emph{Syntax}:
8275 1.1 mrg @code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])}
8276 1.1 mrg
8277 1.1 mrg @item @emph{Arguments}:
8278 1.1 mrg @multitable @columnfractions .15 .70
8279 1.1 mrg @item @var{STRING} @tab Shall be a scalar @code{CHARACTER}, with
8280 1.1 mrg @code{INTENT(IN)}
8281 1.1 mrg @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER}, with
8282 1.1 mrg @code{INTENT(IN)}
8283 1.1 mrg @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL}, with
8284 1.1 mrg @code{INTENT(IN)}
8285 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8286 1.1 mrg expression indicating the kind parameter of the result.
8287 1.1 mrg @end multitable
8288 1.1 mrg
8289 1.1 mrg @item @emph{Return value}:
8290 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8291 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
8292 1.1 mrg
8293 1.1 mrg @item @emph{Specific names}:
8294 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
8295 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
8296 1.1 mrg @item @code{INDEX(STRING, SUBSTRING)} @tab @code{CHARACTER} @tab @code{INTEGER(4)} @tab Fortran 77 and later
8297 1.1 mrg @end multitable
8298 1.1 mrg
8299 1.1 mrg @item @emph{See also}:
8300 1.1.1.2 mrg @ref{SCAN}, @gol
8301 1.1.1.2 mrg @ref{VERIFY}
8302 1.1 mrg @end table
8303 1.1 mrg
8304 1.1 mrg
8305 1.1 mrg
8306 1.1 mrg @node INT
8307 1.1 mrg @section @code{INT} --- Convert to integer type
8308 1.1 mrg @fnindex INT
8309 1.1 mrg @fnindex IFIX
8310 1.1 mrg @fnindex IDINT
8311 1.1 mrg @cindex conversion, to integer
8312 1.1 mrg
8313 1.1 mrg @table @asis
8314 1.1 mrg @item @emph{Description}:
8315 1.1 mrg Convert to integer type
8316 1.1 mrg
8317 1.1 mrg @item @emph{Standard}:
8318 1.1.1.2 mrg Fortran 77 and later, with boz-literal-constant Fortran 2008 and later.
8319 1.1 mrg
8320 1.1 mrg @item @emph{Class}:
8321 1.1 mrg Elemental function
8322 1.1 mrg
8323 1.1 mrg @item @emph{Syntax}:
8324 1.1 mrg @code{RESULT = INT(A [, KIND))}
8325 1.1 mrg
8326 1.1 mrg @item @emph{Arguments}:
8327 1.1 mrg @multitable @columnfractions .15 .70
8328 1.1 mrg @item @var{A} @tab Shall be of type @code{INTEGER},
8329 1.1.1.2 mrg @code{REAL}, or @code{COMPLEX} or or a boz-literal-constant.
8330 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8331 1.1 mrg expression indicating the kind parameter of the result.
8332 1.1 mrg @end multitable
8333 1.1 mrg
8334 1.1 mrg @item @emph{Return value}:
8335 1.1 mrg These functions return a @code{INTEGER} variable or array under
8336 1.1 mrg the following rules:
8337 1.1 mrg
8338 1.1 mrg @table @asis
8339 1.1 mrg @item (A)
8340 1.1 mrg If @var{A} is of type @code{INTEGER}, @code{INT(A) = A}
8341 1.1 mrg @item (B)
8342 1.1 mrg If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)}
8343 1.1 mrg equals @code{0}. If @math{|A| \geq 1}, then @code{INT(A)} is the integer
8344 1.1 mrg whose magnitude is the largest integer that does not exceed the magnitude
8345 1.1 mrg of @var{A} and whose sign is the same as the sign of @var{A}.
8346 1.1 mrg @item (C)
8347 1.1 mrg If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
8348 1.1 mrg @end table
8349 1.1 mrg
8350 1.1 mrg @item @emph{Example}:
8351 1.1 mrg @smallexample
8352 1.1 mrg program test_int
8353 1.1 mrg integer :: i = 42
8354 1.1 mrg complex :: z = (-3.7, 1.0)
8355 1.1 mrg print *, int(i)
8356 1.1 mrg print *, int(z), int(z,8)
8357 1.1 mrg end program
8358 1.1 mrg @end smallexample
8359 1.1 mrg
8360 1.1 mrg @item @emph{Specific names}:
8361 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
8362 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
8363 1.1 mrg @item @code{INT(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later
8364 1.1 mrg @item @code{IFIX(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later
8365 1.1 mrg @item @code{IDINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab Fortran 77 and later
8366 1.1 mrg @end multitable
8367 1.1 mrg
8368 1.1 mrg @end table
8369 1.1 mrg
8370 1.1 mrg
8371 1.1 mrg @node INT2
8372 1.1 mrg @section @code{INT2} --- Convert to 16-bit integer type
8373 1.1 mrg @fnindex INT2
8374 1.1 mrg @fnindex SHORT
8375 1.1 mrg @cindex conversion, to integer
8376 1.1 mrg
8377 1.1 mrg @table @asis
8378 1.1 mrg @item @emph{Description}:
8379 1.1 mrg Convert to a @code{KIND=2} integer type. This is equivalent to the
8380 1.1 mrg standard @code{INT} intrinsic with an optional argument of
8381 1.1 mrg @code{KIND=2}, and is only included for backwards compatibility.
8382 1.1 mrg
8383 1.1 mrg The @code{SHORT} intrinsic is equivalent to @code{INT2}.
8384 1.1 mrg
8385 1.1 mrg @item @emph{Standard}:
8386 1.1 mrg GNU extension
8387 1.1 mrg
8388 1.1 mrg @item @emph{Class}:
8389 1.1 mrg Elemental function
8390 1.1 mrg
8391 1.1 mrg @item @emph{Syntax}:
8392 1.1 mrg @code{RESULT = INT2(A)}
8393 1.1 mrg
8394 1.1 mrg @item @emph{Arguments}:
8395 1.1 mrg @multitable @columnfractions .15 .70
8396 1.1 mrg @item @var{A} @tab Shall be of type @code{INTEGER},
8397 1.1 mrg @code{REAL}, or @code{COMPLEX}.
8398 1.1 mrg @end multitable
8399 1.1 mrg
8400 1.1 mrg @item @emph{Return value}:
8401 1.1 mrg The return value is a @code{INTEGER(2)} variable.
8402 1.1 mrg
8403 1.1 mrg @item @emph{See also}:
8404 1.1.1.2 mrg @ref{INT}, @gol
8405 1.1.1.2 mrg @ref{INT8}, @gol
8406 1.1.1.2 mrg @ref{LONG}
8407 1.1 mrg @end table
8408 1.1 mrg
8409 1.1 mrg
8410 1.1 mrg
8411 1.1 mrg @node INT8
8412 1.1 mrg @section @code{INT8} --- Convert to 64-bit integer type
8413 1.1 mrg @fnindex INT8
8414 1.1 mrg @cindex conversion, to integer
8415 1.1 mrg
8416 1.1 mrg @table @asis
8417 1.1 mrg @item @emph{Description}:
8418 1.1 mrg Convert to a @code{KIND=8} integer type. This is equivalent to the
8419 1.1 mrg standard @code{INT} intrinsic with an optional argument of
8420 1.1 mrg @code{KIND=8}, and is only included for backwards compatibility.
8421 1.1 mrg
8422 1.1 mrg @item @emph{Standard}:
8423 1.1 mrg GNU extension
8424 1.1 mrg
8425 1.1 mrg @item @emph{Class}:
8426 1.1 mrg Elemental function
8427 1.1 mrg
8428 1.1 mrg @item @emph{Syntax}:
8429 1.1 mrg @code{RESULT = INT8(A)}
8430 1.1 mrg
8431 1.1 mrg @item @emph{Arguments}:
8432 1.1 mrg @multitable @columnfractions .15 .70
8433 1.1 mrg @item @var{A} @tab Shall be of type @code{INTEGER},
8434 1.1 mrg @code{REAL}, or @code{COMPLEX}.
8435 1.1 mrg @end multitable
8436 1.1 mrg
8437 1.1 mrg @item @emph{Return value}:
8438 1.1 mrg The return value is a @code{INTEGER(8)} variable.
8439 1.1 mrg
8440 1.1 mrg @item @emph{See also}:
8441 1.1.1.2 mrg @ref{INT}, @gol
8442 1.1.1.2 mrg @ref{INT2}, @gol
8443 1.1.1.2 mrg @ref{LONG}
8444 1.1 mrg @end table
8445 1.1 mrg
8446 1.1 mrg
8447 1.1 mrg
8448 1.1 mrg @node IOR
8449 1.1 mrg @section @code{IOR} --- Bitwise logical or
8450 1.1 mrg @fnindex IOR
8451 1.1 mrg @fnindex BIOR
8452 1.1 mrg @fnindex IIOR
8453 1.1 mrg @fnindex JIOR
8454 1.1 mrg @fnindex KIOR
8455 1.1 mrg @cindex bitwise logical or
8456 1.1 mrg @cindex logical or, bitwise
8457 1.1 mrg
8458 1.1 mrg @table @asis
8459 1.1 mrg @item @emph{Description}:
8460 1.1 mrg @code{IOR} returns the bitwise Boolean inclusive-OR of @var{I} and
8461 1.1 mrg @var{J}.
8462 1.1 mrg
8463 1.1 mrg @item @emph{Standard}:
8464 1.1.1.2 mrg Fortran 90 and later, with boz-literal-constant Fortran 2008 and later, has overloads that are GNU extensions
8465 1.1 mrg
8466 1.1 mrg @item @emph{Class}:
8467 1.1 mrg Elemental function
8468 1.1 mrg
8469 1.1 mrg @item @emph{Syntax}:
8470 1.1 mrg @code{RESULT = IOR(I, J)}
8471 1.1 mrg
8472 1.1 mrg @item @emph{Arguments}:
8473 1.1 mrg @multitable @columnfractions .15 .70
8474 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant.
8475 1.1 mrg @item @var{J} @tab The type shall be @code{INTEGER} with the same
8476 1.1 mrg kind type parameter as @var{I} or a boz-literal-constant.
8477 1.1 mrg @var{I} and @var{J} shall not both be boz-literal-constants.
8478 1.1 mrg @end multitable
8479 1.1 mrg
8480 1.1 mrg @item @emph{Return value}:
8481 1.1 mrg The return type is @code{INTEGER} with the kind type parameter of the
8482 1.1 mrg arguments.
8483 1.1 mrg A boz-literal-constant is converted to an @code{INTEGER} with the kind
8484 1.1 mrg type parameter of the other argument as-if a call to @ref{INT} occurred.
8485 1.1 mrg
8486 1.1 mrg @item @emph{Specific names}:
8487 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
8488 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
8489 1.1.1.2 mrg @item @code{IOR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
8490 1.1 mrg @item @code{BIOR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8491 1.1 mrg @item @code{IIOR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8492 1.1 mrg @item @code{JIOR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8493 1.1 mrg @item @code{KIOR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8494 1.1 mrg @end multitable
8495 1.1 mrg
8496 1.1 mrg @item @emph{See also}:
8497 1.1.1.2 mrg @ref{IEOR}, @gol
8498 1.1.1.2 mrg @ref{IAND}, @gol
8499 1.1.1.2 mrg @ref{IBITS}, @gol
8500 1.1.1.2 mrg @ref{IBSET}, @gol
8501 1.1.1.2 mrg @ref{IBCLR}, @gol
8502 1.1.1.2 mrg @ref{NOT}
8503 1.1 mrg @end table
8504 1.1 mrg
8505 1.1 mrg
8506 1.1 mrg
8507 1.1 mrg @node IPARITY
8508 1.1 mrg @section @code{IPARITY} --- Bitwise XOR of array elements
8509 1.1 mrg @fnindex IPARITY
8510 1.1 mrg @cindex array, parity
8511 1.1 mrg @cindex array, XOR
8512 1.1 mrg @cindex bits, XOR of array elements
8513 1.1 mrg
8514 1.1 mrg @table @asis
8515 1.1 mrg @item @emph{Description}:
8516 1.1 mrg Reduces with bitwise XOR (exclusive or) the elements of @var{ARRAY} along
8517 1.1 mrg dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
8518 1.1 mrg
8519 1.1 mrg @item @emph{Standard}:
8520 1.1 mrg Fortran 2008 and later
8521 1.1 mrg
8522 1.1 mrg @item @emph{Class}:
8523 1.1 mrg Transformational function
8524 1.1 mrg
8525 1.1 mrg @item @emph{Syntax}:
8526 1.1 mrg @multitable @columnfractions .80
8527 1.1 mrg @item @code{RESULT = IPARITY(ARRAY[, MASK])}
8528 1.1 mrg @item @code{RESULT = IPARITY(ARRAY, DIM[, MASK])}
8529 1.1 mrg @end multitable
8530 1.1 mrg
8531 1.1 mrg @item @emph{Arguments}:
8532 1.1 mrg @multitable @columnfractions .15 .70
8533 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
8534 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type
8535 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n
8536 1.1 mrg equals the rank of @var{ARRAY}.
8537 1.1 mrg @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
8538 1.1 mrg and either be a scalar or an array of the same shape as @var{ARRAY}.
8539 1.1 mrg @end multitable
8540 1.1 mrg
8541 1.1 mrg @item @emph{Return value}:
8542 1.1 mrg The result is of the same type as @var{ARRAY}.
8543 1.1 mrg
8544 1.1 mrg If @var{DIM} is absent, a scalar with the bitwise XOR of all elements in
8545 1.1 mrg @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
8546 1.1 mrg the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
8547 1.1 mrg dimension @var{DIM} dropped is returned.
8548 1.1 mrg
8549 1.1 mrg @item @emph{Example}:
8550 1.1 mrg @smallexample
8551 1.1 mrg PROGRAM test_iparity
8552 1.1 mrg INTEGER(1) :: a(2)
8553 1.1 mrg
8554 1.1.1.2 mrg a(1) = int(b'00100100', 1)
8555 1.1.1.2 mrg a(2) = int(b'01101010', 1)
8556 1.1 mrg
8557 1.1 mrg ! prints 01001110
8558 1.1 mrg PRINT '(b8.8)', IPARITY(a)
8559 1.1 mrg END PROGRAM
8560 1.1 mrg @end smallexample
8561 1.1 mrg
8562 1.1 mrg @item @emph{See also}:
8563 1.1.1.2 mrg @ref{IANY}, @gol
8564 1.1.1.2 mrg @ref{IALL}, @gol
8565 1.1.1.2 mrg @ref{IEOR}, @gol
8566 1.1.1.2 mrg @ref{PARITY}
8567 1.1 mrg @end table
8568 1.1 mrg
8569 1.1 mrg
8570 1.1 mrg
8571 1.1 mrg @node IRAND
8572 1.1 mrg @section @code{IRAND} --- Integer pseudo-random number
8573 1.1 mrg @fnindex IRAND
8574 1.1 mrg @cindex random number generation
8575 1.1 mrg
8576 1.1 mrg @table @asis
8577 1.1 mrg @item @emph{Description}:
8578 1.1 mrg @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
8579 1.1 mrg distribution between 0 and a system-dependent limit (which is in most
8580 1.1 mrg cases 2147483647). If @var{FLAG} is 0, the next number
8581 1.1 mrg in the current sequence is returned; if @var{FLAG} is 1, the generator
8582 1.1 mrg is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
8583 1.1 mrg it is used as a new seed with @code{SRAND}.
8584 1.1 mrg
8585 1.1 mrg This intrinsic routine is provided for backwards compatibility with
8586 1.1 mrg GNU Fortran 77. It implements a simple modulo generator as provided
8587 1.1 mrg by @command{g77}. For new code, one should consider the use of
8588 1.1 mrg @ref{RANDOM_NUMBER} as it implements a superior algorithm.
8589 1.1 mrg
8590 1.1 mrg @item @emph{Standard}:
8591 1.1 mrg GNU extension
8592 1.1 mrg
8593 1.1 mrg @item @emph{Class}:
8594 1.1 mrg Function
8595 1.1 mrg
8596 1.1 mrg @item @emph{Syntax}:
8597 1.1 mrg @code{RESULT = IRAND(I)}
8598 1.1 mrg
8599 1.1 mrg @item @emph{Arguments}:
8600 1.1 mrg @multitable @columnfractions .15 .70
8601 1.1 mrg @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
8602 1.1 mrg @end multitable
8603 1.1 mrg
8604 1.1 mrg @item @emph{Return value}:
8605 1.1 mrg The return value is of @code{INTEGER(kind=4)} type.
8606 1.1 mrg
8607 1.1 mrg @item @emph{Example}:
8608 1.1 mrg @smallexample
8609 1.1 mrg program test_irand
8610 1.1 mrg integer,parameter :: seed = 86456
8611 1.1 mrg
8612 1.1 mrg call srand(seed)
8613 1.1 mrg print *, irand(), irand(), irand(), irand()
8614 1.1 mrg print *, irand(seed), irand(), irand(), irand()
8615 1.1 mrg end program test_irand
8616 1.1 mrg @end smallexample
8617 1.1 mrg
8618 1.1 mrg @end table
8619 1.1 mrg
8620 1.1 mrg
8621 1.1 mrg
8622 1.1 mrg @node IS_CONTIGUOUS
8623 1.1 mrg @section @code{IS_CONTIGUOUS} --- Test whether an array is contiguous
8624 1.1 mrg @fnindex IS_IOSTAT_EOR
8625 1.1 mrg @cindex array, contiguity
8626 1.1 mrg
8627 1.1 mrg @table @asis
8628 1.1 mrg @item @emph{Description}:
8629 1.1 mrg @code{IS_CONTIGUOUS} tests whether an array is contiguous.
8630 1.1 mrg
8631 1.1 mrg @item @emph{Standard}:
8632 1.1 mrg Fortran 2008 and later
8633 1.1 mrg
8634 1.1 mrg @item @emph{Class}:
8635 1.1 mrg Inquiry function
8636 1.1 mrg
8637 1.1 mrg @item @emph{Syntax}:
8638 1.1 mrg @code{RESULT = IS_CONTIGUOUS(ARRAY)}
8639 1.1 mrg
8640 1.1 mrg @item @emph{Arguments}:
8641 1.1 mrg @multitable @columnfractions .15 .70
8642 1.1 mrg @item @var{ARRAY} @tab Shall be an array of any type.
8643 1.1 mrg @end multitable
8644 1.1 mrg
8645 1.1 mrg @item @emph{Return value}:
8646 1.1 mrg Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
8647 1.1 mrg @var{ARRAY} is contiguous and false otherwise.
8648 1.1 mrg
8649 1.1 mrg @item @emph{Example}:
8650 1.1 mrg @smallexample
8651 1.1 mrg program test
8652 1.1 mrg integer :: a(10)
8653 1.1 mrg a = [1,2,3,4,5,6,7,8,9,10]
8654 1.1 mrg call sub (a) ! every element, is contiguous
8655 1.1 mrg call sub (a(::2)) ! every other element, is noncontiguous
8656 1.1 mrg contains
8657 1.1 mrg subroutine sub (x)
8658 1.1 mrg integer :: x(:)
8659 1.1 mrg if (is_contiguous (x)) then
8660 1.1 mrg write (*,*) 'X is contiguous'
8661 1.1 mrg else
8662 1.1 mrg write (*,*) 'X is not contiguous'
8663 1.1 mrg end if
8664 1.1 mrg end subroutine sub
8665 1.1 mrg end program test
8666 1.1 mrg @end smallexample
8667 1.1 mrg @end table
8668 1.1 mrg
8669 1.1 mrg
8670 1.1 mrg
8671 1.1 mrg @node IS_IOSTAT_END
8672 1.1 mrg @section @code{IS_IOSTAT_END} --- Test for end-of-file value
8673 1.1 mrg @fnindex IS_IOSTAT_END
8674 1.1 mrg @cindex @code{IOSTAT}, end of file
8675 1.1 mrg
8676 1.1 mrg @table @asis
8677 1.1 mrg @item @emph{Description}:
8678 1.1 mrg @code{IS_IOSTAT_END} tests whether an variable has the value of the I/O
8679 1.1 mrg status ``end of file''. The function is equivalent to comparing the variable
8680 1.1 mrg with the @code{IOSTAT_END} parameter of the intrinsic module
8681 1.1 mrg @code{ISO_FORTRAN_ENV}.
8682 1.1 mrg
8683 1.1 mrg @item @emph{Standard}:
8684 1.1 mrg Fortran 2003 and later
8685 1.1 mrg
8686 1.1 mrg @item @emph{Class}:
8687 1.1 mrg Elemental function
8688 1.1 mrg
8689 1.1 mrg @item @emph{Syntax}:
8690 1.1 mrg @code{RESULT = IS_IOSTAT_END(I)}
8691 1.1 mrg
8692 1.1 mrg @item @emph{Arguments}:
8693 1.1 mrg @multitable @columnfractions .15 .70
8694 1.1 mrg @item @var{I} @tab Shall be of the type @code{INTEGER}.
8695 1.1 mrg @end multitable
8696 1.1 mrg
8697 1.1 mrg @item @emph{Return value}:
8698 1.1 mrg Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
8699 1.1 mrg @var{I} has the value which indicates an end of file condition for
8700 1.1 mrg @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
8701 1.1 mrg
8702 1.1 mrg @item @emph{Example}:
8703 1.1 mrg @smallexample
8704 1.1 mrg PROGRAM iostat
8705 1.1 mrg IMPLICIT NONE
8706 1.1 mrg INTEGER :: stat, i
8707 1.1 mrg OPEN(88, FILE='test.dat')
8708 1.1 mrg READ(88, *, IOSTAT=stat) i
8709 1.1 mrg IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
8710 1.1 mrg END PROGRAM
8711 1.1 mrg @end smallexample
8712 1.1 mrg @end table
8713 1.1 mrg
8714 1.1 mrg
8715 1.1 mrg
8716 1.1 mrg @node IS_IOSTAT_EOR
8717 1.1 mrg @section @code{IS_IOSTAT_EOR} --- Test for end-of-record value
8718 1.1 mrg @fnindex IS_IOSTAT_EOR
8719 1.1 mrg @cindex @code{IOSTAT}, end of record
8720 1.1 mrg
8721 1.1 mrg @table @asis
8722 1.1 mrg @item @emph{Description}:
8723 1.1 mrg @code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O
8724 1.1 mrg status ``end of record''. The function is equivalent to comparing the
8725 1.1 mrg variable with the @code{IOSTAT_EOR} parameter of the intrinsic module
8726 1.1 mrg @code{ISO_FORTRAN_ENV}.
8727 1.1 mrg
8728 1.1 mrg @item @emph{Standard}:
8729 1.1 mrg Fortran 2003 and later
8730 1.1 mrg
8731 1.1 mrg @item @emph{Class}:
8732 1.1 mrg Elemental function
8733 1.1 mrg
8734 1.1 mrg @item @emph{Syntax}:
8735 1.1 mrg @code{RESULT = IS_IOSTAT_EOR(I)}
8736 1.1 mrg
8737 1.1 mrg @item @emph{Arguments}:
8738 1.1 mrg @multitable @columnfractions .15 .70
8739 1.1 mrg @item @var{I} @tab Shall be of the type @code{INTEGER}.
8740 1.1 mrg @end multitable
8741 1.1 mrg
8742 1.1 mrg @item @emph{Return value}:
8743 1.1 mrg Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
8744 1.1 mrg @var{I} has the value which indicates an end of file condition for
8745 1.1 mrg @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
8746 1.1 mrg
8747 1.1 mrg @item @emph{Example}:
8748 1.1 mrg @smallexample
8749 1.1 mrg PROGRAM iostat
8750 1.1 mrg IMPLICIT NONE
8751 1.1 mrg INTEGER :: stat, i(50)
8752 1.1 mrg OPEN(88, FILE='test.dat', FORM='UNFORMATTED')
8753 1.1 mrg READ(88, IOSTAT=stat) i
8754 1.1 mrg IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD'
8755 1.1 mrg END PROGRAM
8756 1.1 mrg @end smallexample
8757 1.1 mrg @end table
8758 1.1 mrg
8759 1.1 mrg
8760 1.1 mrg @node ISATTY
8761 1.1 mrg @section @code{ISATTY} --- Whether a unit is a terminal device.
8762 1.1 mrg @fnindex ISATTY
8763 1.1 mrg @cindex system, terminal
8764 1.1 mrg
8765 1.1 mrg @table @asis
8766 1.1 mrg @item @emph{Description}:
8767 1.1 mrg Determine whether a unit is connected to a terminal device.
8768 1.1 mrg
8769 1.1 mrg @item @emph{Standard}:
8770 1.1 mrg GNU extension
8771 1.1 mrg
8772 1.1 mrg @item @emph{Class}:
8773 1.1 mrg Function
8774 1.1 mrg
8775 1.1 mrg @item @emph{Syntax}:
8776 1.1 mrg @code{RESULT = ISATTY(UNIT)}
8777 1.1 mrg
8778 1.1 mrg @item @emph{Arguments}:
8779 1.1 mrg @multitable @columnfractions .15 .70
8780 1.1 mrg @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
8781 1.1 mrg @end multitable
8782 1.1 mrg
8783 1.1 mrg @item @emph{Return value}:
8784 1.1 mrg Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal
8785 1.1 mrg device, @code{.FALSE.} otherwise.
8786 1.1 mrg
8787 1.1 mrg @item @emph{Example}:
8788 1.1 mrg @smallexample
8789 1.1 mrg PROGRAM test_isatty
8790 1.1 mrg INTEGER(kind=1) :: unit
8791 1.1 mrg DO unit = 1, 10
8792 1.1 mrg write(*,*) isatty(unit=unit)
8793 1.1 mrg END DO
8794 1.1 mrg END PROGRAM
8795 1.1 mrg @end smallexample
8796 1.1 mrg @item @emph{See also}:
8797 1.1 mrg @ref{TTYNAM}
8798 1.1 mrg @end table
8799 1.1 mrg
8800 1.1 mrg
8801 1.1 mrg
8802 1.1 mrg @node ISHFT
8803 1.1 mrg @section @code{ISHFT} --- Shift bits
8804 1.1 mrg @fnindex ISHFT
8805 1.1 mrg @fnindex BSHFT
8806 1.1 mrg @fnindex IISHFT
8807 1.1 mrg @fnindex JISHFT
8808 1.1 mrg @fnindex KISHFT
8809 1.1 mrg @cindex bits, shift
8810 1.1 mrg
8811 1.1 mrg @table @asis
8812 1.1 mrg @item @emph{Description}:
8813 1.1 mrg @code{ISHFT} returns a value corresponding to @var{I} with all of the
8814 1.1 mrg bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than
8815 1.1 mrg zero corresponds to a left shift, a value of zero corresponds to no
8816 1.1 mrg shift, and a value less than zero corresponds to a right shift. If the
8817 1.1 mrg absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
8818 1.1 mrg value is undefined. Bits shifted out from the left end or right end are
8819 1.1 mrg lost; zeros are shifted in from the opposite end.
8820 1.1 mrg
8821 1.1 mrg @item @emph{Standard}:
8822 1.1.1.2 mrg Fortran 90 and later, has overloads that are GNU extensions
8823 1.1 mrg
8824 1.1 mrg @item @emph{Class}:
8825 1.1 mrg Elemental function
8826 1.1 mrg
8827 1.1 mrg @item @emph{Syntax}:
8828 1.1 mrg @code{RESULT = ISHFT(I, SHIFT)}
8829 1.1 mrg
8830 1.1 mrg @item @emph{Arguments}:
8831 1.1 mrg @multitable @columnfractions .15 .70
8832 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
8833 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
8834 1.1 mrg @end multitable
8835 1.1 mrg
8836 1.1 mrg @item @emph{Return value}:
8837 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
8838 1.1 mrg @var{I}.
8839 1.1 mrg
8840 1.1 mrg @item @emph{Specific names}:
8841 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
8842 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
8843 1.1.1.2 mrg @item @code{ISHFT(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
8844 1.1 mrg @item @code{BSHFT(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8845 1.1 mrg @item @code{IISHFT(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8846 1.1 mrg @item @code{JISHFT(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8847 1.1 mrg @item @code{KISHFT(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8848 1.1 mrg @end multitable
8849 1.1 mrg
8850 1.1 mrg @item @emph{See also}:
8851 1.1 mrg @ref{ISHFTC}
8852 1.1 mrg @end table
8853 1.1 mrg
8854 1.1 mrg
8855 1.1 mrg
8856 1.1 mrg @node ISHFTC
8857 1.1 mrg @section @code{ISHFTC} --- Shift bits circularly
8858 1.1 mrg @fnindex ISHFTC
8859 1.1 mrg @fnindex BSHFTC
8860 1.1 mrg @fnindex IISHFTC
8861 1.1 mrg @fnindex JISHFTC
8862 1.1 mrg @fnindex KISHFTC
8863 1.1 mrg @cindex bits, shift circular
8864 1.1 mrg
8865 1.1 mrg @table @asis
8866 1.1 mrg @item @emph{Description}:
8867 1.1 mrg @code{ISHFTC} returns a value corresponding to @var{I} with the
8868 1.1 mrg rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
8869 1.1 mrg is, bits shifted out one end are shifted into the opposite end. A value
8870 1.1 mrg of @var{SHIFT} greater than zero corresponds to a left shift, a value of
8871 1.1 mrg zero corresponds to no shift, and a value less than zero corresponds to
8872 1.1 mrg a right shift. The absolute value of @var{SHIFT} must be less than
8873 1.1 mrg @var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be
8874 1.1 mrg equivalent to @code{BIT_SIZE(I)}.
8875 1.1 mrg
8876 1.1 mrg @item @emph{Standard}:
8877 1.1.1.2 mrg Fortran 90 and later, has overloads that are GNU extensions
8878 1.1 mrg
8879 1.1 mrg @item @emph{Class}:
8880 1.1 mrg Elemental function
8881 1.1 mrg
8882 1.1 mrg @item @emph{Syntax}:
8883 1.1 mrg @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
8884 1.1 mrg
8885 1.1 mrg @item @emph{Arguments}:
8886 1.1 mrg @multitable @columnfractions .15 .70
8887 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
8888 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
8889 1.1 mrg @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER};
8890 1.1 mrg the value must be greater than zero and less than or equal to
8891 1.1 mrg @code{BIT_SIZE(I)}.
8892 1.1 mrg @end multitable
8893 1.1 mrg
8894 1.1 mrg @item @emph{Return value}:
8895 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
8896 1.1 mrg @var{I}.
8897 1.1 mrg
8898 1.1 mrg @item @emph{Specific names}:
8899 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
8900 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
8901 1.1.1.2 mrg @item @code{ISHFTC(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
8902 1.1 mrg @item @code{BSHFTC(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8903 1.1 mrg @item @code{IISHFTC(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8904 1.1 mrg @item @code{JISHFTC(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8905 1.1 mrg @item @code{KISHFTC(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8906 1.1 mrg @end multitable
8907 1.1 mrg
8908 1.1 mrg @item @emph{See also}:
8909 1.1 mrg @ref{ISHFT}
8910 1.1 mrg @end table
8911 1.1 mrg
8912 1.1 mrg
8913 1.1 mrg
8914 1.1 mrg @node ISNAN
8915 1.1 mrg @section @code{ISNAN} --- Test for a NaN
8916 1.1 mrg @fnindex ISNAN
8917 1.1 mrg @cindex IEEE, ISNAN
8918 1.1 mrg
8919 1.1 mrg @table @asis
8920 1.1 mrg @item @emph{Description}:
8921 1.1 mrg @code{ISNAN} tests whether a floating-point value is an IEEE
8922 1.1 mrg Not-a-Number (NaN).
8923 1.1 mrg @item @emph{Standard}:
8924 1.1 mrg GNU extension
8925 1.1 mrg
8926 1.1 mrg @item @emph{Class}:
8927 1.1 mrg Elemental function
8928 1.1 mrg
8929 1.1 mrg @item @emph{Syntax}:
8930 1.1 mrg @code{ISNAN(X)}
8931 1.1 mrg
8932 1.1 mrg @item @emph{Arguments}:
8933 1.1 mrg @multitable @columnfractions .15 .70
8934 1.1 mrg @item @var{X} @tab Variable of the type @code{REAL}.
8935 1.1 mrg
8936 1.1 mrg @end multitable
8937 1.1 mrg
8938 1.1 mrg @item @emph{Return value}:
8939 1.1 mrg Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE}
8940 1.1 mrg if @var{X} is a NaN and @code{FALSE} otherwise.
8941 1.1 mrg
8942 1.1 mrg @item @emph{Example}:
8943 1.1 mrg @smallexample
8944 1.1 mrg program test_nan
8945 1.1 mrg implicit none
8946 1.1 mrg real :: x
8947 1.1 mrg x = -1.0
8948 1.1 mrg x = sqrt(x)
8949 1.1 mrg if (isnan(x)) stop '"x" is a NaN'
8950 1.1 mrg end program test_nan
8951 1.1 mrg @end smallexample
8952 1.1 mrg @end table
8953 1.1 mrg
8954 1.1 mrg
8955 1.1 mrg
8956 1.1 mrg @node ITIME
8957 1.1 mrg @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
8958 1.1 mrg @fnindex ITIME
8959 1.1 mrg @cindex time, current
8960 1.1 mrg @cindex current time
8961 1.1 mrg
8962 1.1 mrg @table @asis
8963 1.1 mrg @item @emph{Description}:
8964 1.1 mrg @code{ITIME(VALUES)} Fills @var{VALUES} with the numerical values at the
8965 1.1 mrg current local time. The hour (in the range 1-24), minute (in the range 1-60),
8966 1.1 mrg and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{VALUES},
8967 1.1 mrg respectively.
8968 1.1 mrg
8969 1.1 mrg This intrinsic routine is provided for backwards compatibility with
8970 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of
8971 1.1 mrg the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
8972 1.1 mrg standard.
8973 1.1 mrg
8974 1.1 mrg @item @emph{Standard}:
8975 1.1 mrg GNU extension
8976 1.1 mrg
8977 1.1 mrg @item @emph{Class}:
8978 1.1 mrg Subroutine
8979 1.1 mrg
8980 1.1 mrg @item @emph{Syntax}:
8981 1.1 mrg @code{CALL ITIME(VALUES)}
8982 1.1 mrg
8983 1.1 mrg @item @emph{Arguments}:
8984 1.1 mrg @multitable @columnfractions .15 .70
8985 1.1 mrg @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)}
8986 1.1 mrg and the kind shall be the default integer kind.
8987 1.1 mrg @end multitable
8988 1.1 mrg
8989 1.1 mrg @item @emph{Return value}:
8990 1.1 mrg Does not return anything.
8991 1.1 mrg
8992 1.1 mrg
8993 1.1 mrg @item @emph{Example}:
8994 1.1 mrg @smallexample
8995 1.1 mrg program test_itime
8996 1.1 mrg integer, dimension(3) :: tarray
8997 1.1 mrg call itime(tarray)
8998 1.1 mrg print *, tarray(1)
8999 1.1 mrg print *, tarray(2)
9000 1.1 mrg print *, tarray(3)
9001 1.1 mrg end program test_itime
9002 1.1 mrg @end smallexample
9003 1.1 mrg
9004 1.1 mrg @item @emph{See also}:
9005 1.1 mrg @ref{DATE_AND_TIME}
9006 1.1 mrg @end table
9007 1.1 mrg
9008 1.1 mrg
9009 1.1 mrg
9010 1.1 mrg @node KILL
9011 1.1 mrg @section @code{KILL} --- Send a signal to a process
9012 1.1 mrg @fnindex KILL
9013 1.1 mrg
9014 1.1 mrg @table @asis
9015 1.1 mrg @item @emph{Description}:
9016 1.1 mrg Sends the signal specified by @var{SIG} to the process @var{PID}.
9017 1.1 mrg See @code{kill(2)}.
9018 1.1 mrg
9019 1.1 mrg This intrinsic is provided in both subroutine and function forms;
9020 1.1 mrg however, only one form can be used in any given program unit.
9021 1.1.1.2 mrg @item @emph{Standard}:
9022 1.1.1.2 mrg GNU extension
9023 1.1.1.2 mrg
9024 1.1.1.2 mrg @item @emph{Standard}:
9025 1.1.1.2 mrg GNU extension
9026 1.1 mrg
9027 1.1 mrg @item @emph{Class}:
9028 1.1 mrg Subroutine, function
9029 1.1 mrg
9030 1.1 mrg @item @emph{Syntax}:
9031 1.1 mrg @multitable @columnfractions .80
9032 1.1 mrg @item @code{CALL KILL(PID, SIG [, STATUS])}
9033 1.1 mrg @item @code{STATUS = KILL(PID, SIG)}
9034 1.1 mrg @end multitable
9035 1.1 mrg
9036 1.1 mrg @item @emph{Arguments}:
9037 1.1 mrg @multitable @columnfractions .15 .70
9038 1.1 mrg @item @var{PID} @tab Shall be a scalar @code{INTEGER} with @code{INTENT(IN)}.
9039 1.1 mrg @item @var{SIG} @tab Shall be a scalar @code{INTEGER} with @code{INTENT(IN)}.
9040 1.1 mrg @item @var{STATUS} @tab [Subroutine](Optional)
9041 1.1 mrg Shall be a scalar @code{INTEGER}.
9042 1.1 mrg Returns 0 on success; otherwise a system-specific error code is returned.
9043 1.1 mrg @item @var{STATUS} @tab [Function] The kind type parameter is that of
9044 1.1 mrg @code{pid}.
9045 1.1 mrg Returns 0 on success; otherwise a system-specific error code is returned.
9046 1.1 mrg @end multitable
9047 1.1 mrg
9048 1.1 mrg @item @emph{See also}:
9049 1.1.1.2 mrg @ref{ABORT}, @gol
9050 1.1.1.2 mrg @ref{EXIT}
9051 1.1 mrg @end table
9052 1.1 mrg
9053 1.1 mrg
9054 1.1 mrg @node KIND
9055 1.1 mrg @section @code{KIND} --- Kind of an entity
9056 1.1 mrg @fnindex KIND
9057 1.1 mrg @cindex kind
9058 1.1 mrg
9059 1.1 mrg @table @asis
9060 1.1 mrg @item @emph{Description}:
9061 1.1 mrg @code{KIND(X)} returns the kind value of the entity @var{X}.
9062 1.1 mrg
9063 1.1 mrg @item @emph{Standard}:
9064 1.1 mrg Fortran 95 and later
9065 1.1 mrg
9066 1.1 mrg @item @emph{Class}:
9067 1.1 mrg Inquiry function
9068 1.1 mrg
9069 1.1 mrg @item @emph{Syntax}:
9070 1.1 mrg @code{K = KIND(X)}
9071 1.1 mrg
9072 1.1 mrg @item @emph{Arguments}:
9073 1.1 mrg @multitable @columnfractions .15 .70
9074 1.1 mrg @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
9075 1.1.1.2 mrg @code{REAL}, @code{COMPLEX} or @code{CHARACTER}. It may be scalar or
9076 1.1.1.2 mrg array valued.
9077 1.1 mrg @end multitable
9078 1.1 mrg
9079 1.1 mrg @item @emph{Return value}:
9080 1.1 mrg The return value is a scalar of type @code{INTEGER} and of the default
9081 1.1 mrg integer kind.
9082 1.1 mrg
9083 1.1 mrg @item @emph{Example}:
9084 1.1 mrg @smallexample
9085 1.1 mrg program test_kind
9086 1.1 mrg integer,parameter :: kc = kind(' ')
9087 1.1 mrg integer,parameter :: kl = kind(.true.)
9088 1.1 mrg
9089 1.1 mrg print *, "The default character kind is ", kc
9090 1.1 mrg print *, "The default logical kind is ", kl
9091 1.1 mrg end program test_kind
9092 1.1 mrg @end smallexample
9093 1.1 mrg
9094 1.1 mrg @end table
9095 1.1 mrg
9096 1.1 mrg
9097 1.1 mrg
9098 1.1 mrg @node LBOUND
9099 1.1 mrg @section @code{LBOUND} --- Lower dimension bounds of an array
9100 1.1 mrg @fnindex LBOUND
9101 1.1 mrg @cindex array, lower bound
9102 1.1 mrg
9103 1.1 mrg @table @asis
9104 1.1 mrg @item @emph{Description}:
9105 1.1 mrg Returns the lower bounds of an array, or a single lower bound
9106 1.1 mrg along the @var{DIM} dimension.
9107 1.1 mrg @item @emph{Standard}:
9108 1.1.1.2 mrg Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later
9109 1.1 mrg
9110 1.1 mrg @item @emph{Class}:
9111 1.1 mrg Inquiry function
9112 1.1 mrg
9113 1.1 mrg @item @emph{Syntax}:
9114 1.1 mrg @code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])}
9115 1.1 mrg
9116 1.1 mrg @item @emph{Arguments}:
9117 1.1 mrg @multitable @columnfractions .15 .70
9118 1.1 mrg @item @var{ARRAY} @tab Shall be an array, of any type.
9119 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
9120 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9121 1.1 mrg expression indicating the kind parameter of the result.
9122 1.1 mrg @end multitable
9123 1.1 mrg
9124 1.1 mrg @item @emph{Return value}:
9125 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9126 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
9127 1.1 mrg If @var{DIM} is absent, the result is an array of the lower bounds of
9128 1.1 mrg @var{ARRAY}. If @var{DIM} is present, the result is a scalar
9129 1.1 mrg corresponding to the lower bound of the array along that dimension. If
9130 1.1 mrg @var{ARRAY} is an expression rather than a whole array or array
9131 1.1 mrg structure component, or if it has a zero extent along the relevant
9132 1.1 mrg dimension, the lower bound is taken to be 1.
9133 1.1 mrg
9134 1.1 mrg @item @emph{See also}:
9135 1.1.1.2 mrg @ref{UBOUND}, @gol
9136 1.1.1.2 mrg @ref{LCOBOUND}
9137 1.1 mrg @end table
9138 1.1 mrg
9139 1.1 mrg
9140 1.1 mrg
9141 1.1 mrg @node LCOBOUND
9142 1.1 mrg @section @code{LCOBOUND} --- Lower codimension bounds of an array
9143 1.1 mrg @fnindex LCOBOUND
9144 1.1 mrg @cindex coarray, lower bound
9145 1.1 mrg
9146 1.1 mrg @table @asis
9147 1.1 mrg @item @emph{Description}:
9148 1.1 mrg Returns the lower bounds of a coarray, or a single lower cobound
9149 1.1 mrg along the @var{DIM} codimension.
9150 1.1 mrg @item @emph{Standard}:
9151 1.1 mrg Fortran 2008 and later
9152 1.1 mrg
9153 1.1 mrg @item @emph{Class}:
9154 1.1 mrg Inquiry function
9155 1.1 mrg
9156 1.1 mrg @item @emph{Syntax}:
9157 1.1 mrg @code{RESULT = LCOBOUND(COARRAY [, DIM [, KIND]])}
9158 1.1 mrg
9159 1.1 mrg @item @emph{Arguments}:
9160 1.1 mrg @multitable @columnfractions .15 .70
9161 1.1 mrg @item @var{ARRAY} @tab Shall be an coarray, of any type.
9162 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
9163 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9164 1.1 mrg expression indicating the kind parameter of the result.
9165 1.1 mrg @end multitable
9166 1.1 mrg
9167 1.1 mrg @item @emph{Return value}:
9168 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9169 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
9170 1.1 mrg If @var{DIM} is absent, the result is an array of the lower cobounds of
9171 1.1 mrg @var{COARRAY}. If @var{DIM} is present, the result is a scalar
9172 1.1 mrg corresponding to the lower cobound of the array along that codimension.
9173 1.1 mrg
9174 1.1 mrg @item @emph{See also}:
9175 1.1.1.2 mrg @ref{UCOBOUND}, @gol
9176 1.1.1.2 mrg @ref{LBOUND}
9177 1.1 mrg @end table
9178 1.1 mrg
9179 1.1 mrg
9180 1.1 mrg
9181 1.1 mrg @node LEADZ
9182 1.1 mrg @section @code{LEADZ} --- Number of leading zero bits of an integer
9183 1.1 mrg @fnindex LEADZ
9184 1.1 mrg @cindex zero bits
9185 1.1 mrg
9186 1.1 mrg @table @asis
9187 1.1 mrg @item @emph{Description}:
9188 1.1 mrg @code{LEADZ} returns the number of leading zero bits of an integer.
9189 1.1 mrg
9190 1.1 mrg @item @emph{Standard}:
9191 1.1 mrg Fortran 2008 and later
9192 1.1 mrg
9193 1.1 mrg @item @emph{Class}:
9194 1.1 mrg Elemental function
9195 1.1 mrg
9196 1.1 mrg @item @emph{Syntax}:
9197 1.1 mrg @code{RESULT = LEADZ(I)}
9198 1.1 mrg
9199 1.1 mrg @item @emph{Arguments}:
9200 1.1 mrg @multitable @columnfractions .15 .70
9201 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}.
9202 1.1 mrg @end multitable
9203 1.1 mrg
9204 1.1 mrg @item @emph{Return value}:
9205 1.1 mrg The type of the return value is the default @code{INTEGER}.
9206 1.1 mrg If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
9207 1.1 mrg
9208 1.1 mrg @item @emph{Example}:
9209 1.1 mrg @smallexample
9210 1.1 mrg PROGRAM test_leadz
9211 1.1 mrg WRITE (*,*) BIT_SIZE(1) ! prints 32
9212 1.1 mrg WRITE (*,*) LEADZ(1) ! prints 31
9213 1.1 mrg END PROGRAM
9214 1.1 mrg @end smallexample
9215 1.1 mrg
9216 1.1 mrg @item @emph{See also}:
9217 1.1.1.2 mrg @ref{BIT_SIZE}, @gol
9218 1.1.1.2 mrg @ref{TRAILZ}, @gol
9219 1.1.1.2 mrg @ref{POPCNT}, @gol
9220 1.1.1.2 mrg @ref{POPPAR}
9221 1.1 mrg @end table
9222 1.1 mrg
9223 1.1 mrg
9224 1.1 mrg
9225 1.1 mrg @node LEN
9226 1.1 mrg @section @code{LEN} --- Length of a character entity
9227 1.1 mrg @fnindex LEN
9228 1.1 mrg @cindex string, length
9229 1.1 mrg
9230 1.1 mrg @table @asis
9231 1.1 mrg @item @emph{Description}:
9232 1.1 mrg Returns the length of a character string. If @var{STRING} is an array,
9233 1.1 mrg the length of an element of @var{STRING} is returned. Note that
9234 1.1 mrg @var{STRING} need not be defined when this intrinsic is invoked, since
9235 1.1 mrg only the length, not the content, of @var{STRING} is needed.
9236 1.1 mrg
9237 1.1 mrg @item @emph{Standard}:
9238 1.1 mrg Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
9239 1.1 mrg
9240 1.1 mrg @item @emph{Class}:
9241 1.1 mrg Inquiry function
9242 1.1 mrg
9243 1.1 mrg @item @emph{Syntax}:
9244 1.1 mrg @code{L = LEN(STRING [, KIND])}
9245 1.1 mrg
9246 1.1 mrg @item @emph{Arguments}:
9247 1.1 mrg @multitable @columnfractions .15 .70
9248 1.1 mrg @item @var{STRING} @tab Shall be a scalar or array of type
9249 1.1 mrg @code{CHARACTER}, with @code{INTENT(IN)}
9250 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9251 1.1 mrg expression indicating the kind parameter of the result.
9252 1.1 mrg @end multitable
9253 1.1 mrg
9254 1.1 mrg @item @emph{Return value}:
9255 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9256 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
9257 1.1 mrg
9258 1.1 mrg
9259 1.1 mrg @item @emph{Specific names}:
9260 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
9261 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
9262 1.1 mrg @item @code{LEN(STRING)} @tab @code{CHARACTER} @tab @code{INTEGER} @tab Fortran 77 and later
9263 1.1 mrg @end multitable
9264 1.1 mrg
9265 1.1 mrg
9266 1.1 mrg @item @emph{See also}:
9267 1.1.1.2 mrg @ref{LEN_TRIM}, @gol
9268 1.1.1.2 mrg @ref{ADJUSTL}, @gol
9269 1.1.1.2 mrg @ref{ADJUSTR}
9270 1.1 mrg @end table
9271 1.1 mrg
9272 1.1 mrg
9273 1.1 mrg
9274 1.1 mrg @node LEN_TRIM
9275 1.1 mrg @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
9276 1.1 mrg @fnindex LEN_TRIM
9277 1.1 mrg @cindex string, length, without trailing whitespace
9278 1.1 mrg
9279 1.1 mrg @table @asis
9280 1.1 mrg @item @emph{Description}:
9281 1.1 mrg Returns the length of a character string, ignoring any trailing blanks.
9282 1.1 mrg
9283 1.1 mrg @item @emph{Standard}:
9284 1.1.1.2 mrg Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later
9285 1.1 mrg
9286 1.1 mrg @item @emph{Class}:
9287 1.1 mrg Elemental function
9288 1.1 mrg
9289 1.1 mrg @item @emph{Syntax}:
9290 1.1 mrg @code{RESULT = LEN_TRIM(STRING [, KIND])}
9291 1.1 mrg
9292 1.1 mrg @item @emph{Arguments}:
9293 1.1 mrg @multitable @columnfractions .15 .70
9294 1.1 mrg @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
9295 1.1 mrg with @code{INTENT(IN)}
9296 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9297 1.1 mrg expression indicating the kind parameter of the result.
9298 1.1 mrg @end multitable
9299 1.1 mrg
9300 1.1 mrg @item @emph{Return value}:
9301 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9302 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
9303 1.1 mrg
9304 1.1 mrg @item @emph{See also}:
9305 1.1.1.2 mrg @ref{LEN}, @gol
9306 1.1.1.2 mrg @ref{ADJUSTL}, @gol
9307 1.1.1.2 mrg @ref{ADJUSTR}
9308 1.1 mrg @end table
9309 1.1 mrg
9310 1.1 mrg
9311 1.1 mrg
9312 1.1 mrg @node LGE
9313 1.1 mrg @section @code{LGE} --- Lexical greater than or equal
9314 1.1 mrg @fnindex LGE
9315 1.1 mrg @cindex lexical comparison of strings
9316 1.1 mrg @cindex string, comparison
9317 1.1 mrg
9318 1.1 mrg @table @asis
9319 1.1 mrg @item @emph{Description}:
9320 1.1 mrg Determines whether one string is lexically greater than or equal to
9321 1.1 mrg another string, where the two strings are interpreted as containing
9322 1.1 mrg ASCII character codes. If the String A and String B are not the same
9323 1.1 mrg length, the shorter is compared as if spaces were appended to it to form
9324 1.1 mrg a value that has the same length as the longer.
9325 1.1 mrg
9326 1.1 mrg In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9327 1.1 mrg @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9328 1.1 mrg operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9329 1.1 mrg that the latter use the processor's character ordering (which is not
9330 1.1 mrg ASCII on some targets), whereas the former always use the ASCII
9331 1.1 mrg ordering.
9332 1.1 mrg
9333 1.1 mrg @item @emph{Standard}:
9334 1.1 mrg Fortran 77 and later
9335 1.1 mrg
9336 1.1 mrg @item @emph{Class}:
9337 1.1 mrg Elemental function
9338 1.1 mrg
9339 1.1 mrg @item @emph{Syntax}:
9340 1.1 mrg @code{RESULT = LGE(STRING_A, STRING_B)}
9341 1.1 mrg
9342 1.1 mrg @item @emph{Arguments}:
9343 1.1 mrg @multitable @columnfractions .15 .70
9344 1.1 mrg @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9345 1.1 mrg @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9346 1.1 mrg @end multitable
9347 1.1 mrg
9348 1.1 mrg @item @emph{Return value}:
9349 1.1 mrg Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
9350 1.1 mrg otherwise, based on the ASCII ordering.
9351 1.1 mrg
9352 1.1 mrg @item @emph{Specific names}:
9353 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
9354 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
9355 1.1 mrg @item @code{LGE(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9356 1.1 mrg @end multitable
9357 1.1 mrg
9358 1.1 mrg @item @emph{See also}:
9359 1.1.1.2 mrg @ref{LGT}, @gol
9360 1.1.1.2 mrg @ref{LLE}, @gol
9361 1.1.1.2 mrg @ref{LLT}
9362 1.1 mrg @end table
9363 1.1 mrg
9364 1.1 mrg
9365 1.1 mrg
9366 1.1 mrg @node LGT
9367 1.1 mrg @section @code{LGT} --- Lexical greater than
9368 1.1 mrg @fnindex LGT
9369 1.1 mrg @cindex lexical comparison of strings
9370 1.1 mrg @cindex string, comparison
9371 1.1 mrg
9372 1.1 mrg @table @asis
9373 1.1 mrg @item @emph{Description}:
9374 1.1 mrg Determines whether one string is lexically greater than another string,
9375 1.1 mrg where the two strings are interpreted as containing ASCII character
9376 1.1 mrg codes. If the String A and String B are not the same length, the
9377 1.1 mrg shorter is compared as if spaces were appended to it to form a value
9378 1.1 mrg that has the same length as the longer.
9379 1.1 mrg
9380 1.1 mrg In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9381 1.1 mrg @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9382 1.1 mrg operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9383 1.1 mrg that the latter use the processor's character ordering (which is not
9384 1.1 mrg ASCII on some targets), whereas the former always use the ASCII
9385 1.1 mrg ordering.
9386 1.1 mrg
9387 1.1 mrg @item @emph{Standard}:
9388 1.1 mrg Fortran 77 and later
9389 1.1 mrg
9390 1.1 mrg @item @emph{Class}:
9391 1.1 mrg Elemental function
9392 1.1 mrg
9393 1.1 mrg @item @emph{Syntax}:
9394 1.1 mrg @code{RESULT = LGT(STRING_A, STRING_B)}
9395 1.1 mrg
9396 1.1 mrg @item @emph{Arguments}:
9397 1.1 mrg @multitable @columnfractions .15 .70
9398 1.1 mrg @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9399 1.1 mrg @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9400 1.1 mrg @end multitable
9401 1.1 mrg
9402 1.1 mrg @item @emph{Return value}:
9403 1.1 mrg Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
9404 1.1 mrg otherwise, based on the ASCII ordering.
9405 1.1 mrg
9406 1.1 mrg @item @emph{Specific names}:
9407 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
9408 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
9409 1.1 mrg @item @code{LGT(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9410 1.1 mrg @end multitable
9411 1.1 mrg
9412 1.1 mrg @item @emph{See also}:
9413 1.1.1.2 mrg @ref{LGE}, @gol
9414 1.1.1.2 mrg @ref{LLE}, @gol
9415 1.1.1.2 mrg @ref{LLT}
9416 1.1 mrg @end table
9417 1.1 mrg
9418 1.1 mrg
9419 1.1 mrg
9420 1.1 mrg @node LINK
9421 1.1 mrg @section @code{LINK} --- Create a hard link
9422 1.1 mrg @fnindex LINK
9423 1.1 mrg @cindex file system, create link
9424 1.1 mrg @cindex file system, hard link
9425 1.1 mrg
9426 1.1 mrg @table @asis
9427 1.1 mrg @item @emph{Description}:
9428 1.1 mrg Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
9429 1.1 mrg character (@code{CHAR(0)}) can be used to mark the end of the names in
9430 1.1 mrg @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
9431 1.1 mrg names are ignored. If the @var{STATUS} argument is supplied, it
9432 1.1 mrg contains 0 on success or a nonzero error code upon return; see
9433 1.1 mrg @code{link(2)}.
9434 1.1 mrg
9435 1.1 mrg This intrinsic is provided in both subroutine and function forms;
9436 1.1 mrg however, only one form can be used in any given program unit.
9437 1.1 mrg
9438 1.1 mrg @item @emph{Standard}:
9439 1.1 mrg GNU extension
9440 1.1 mrg
9441 1.1 mrg @item @emph{Class}:
9442 1.1 mrg Subroutine, function
9443 1.1 mrg
9444 1.1 mrg @item @emph{Syntax}:
9445 1.1 mrg @multitable @columnfractions .80
9446 1.1 mrg @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
9447 1.1 mrg @item @code{STATUS = LINK(PATH1, PATH2)}
9448 1.1 mrg @end multitable
9449 1.1 mrg
9450 1.1 mrg @item @emph{Arguments}:
9451 1.1 mrg @multitable @columnfractions .15 .70
9452 1.1 mrg @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
9453 1.1 mrg @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
9454 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9455 1.1 mrg @end multitable
9456 1.1 mrg
9457 1.1 mrg @item @emph{See also}:
9458 1.1.1.2 mrg @ref{SYMLNK}, @gol
9459 1.1.1.2 mrg @ref{UNLINK}
9460 1.1 mrg @end table
9461 1.1 mrg
9462 1.1 mrg
9463 1.1 mrg
9464 1.1 mrg @node LLE
9465 1.1 mrg @section @code{LLE} --- Lexical less than or equal
9466 1.1 mrg @fnindex LLE
9467 1.1 mrg @cindex lexical comparison of strings
9468 1.1 mrg @cindex string, comparison
9469 1.1 mrg
9470 1.1 mrg @table @asis
9471 1.1 mrg @item @emph{Description}:
9472 1.1 mrg Determines whether one string is lexically less than or equal to another
9473 1.1 mrg string, where the two strings are interpreted as containing ASCII
9474 1.1 mrg character codes. If the String A and String B are not the same length,
9475 1.1 mrg the shorter is compared as if spaces were appended to it to form a value
9476 1.1 mrg that has the same length as the longer.
9477 1.1 mrg
9478 1.1 mrg In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9479 1.1 mrg @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9480 1.1 mrg operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9481 1.1 mrg that the latter use the processor's character ordering (which is not
9482 1.1 mrg ASCII on some targets), whereas the former always use the ASCII
9483 1.1 mrg ordering.
9484 1.1 mrg
9485 1.1 mrg @item @emph{Standard}:
9486 1.1 mrg Fortran 77 and later
9487 1.1 mrg
9488 1.1 mrg @item @emph{Class}:
9489 1.1 mrg Elemental function
9490 1.1 mrg
9491 1.1 mrg @item @emph{Syntax}:
9492 1.1 mrg @code{RESULT = LLE(STRING_A, STRING_B)}
9493 1.1 mrg
9494 1.1 mrg @item @emph{Arguments}:
9495 1.1 mrg @multitable @columnfractions .15 .70
9496 1.1 mrg @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9497 1.1 mrg @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9498 1.1 mrg @end multitable
9499 1.1 mrg
9500 1.1 mrg @item @emph{Return value}:
9501 1.1 mrg Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
9502 1.1 mrg otherwise, based on the ASCII ordering.
9503 1.1 mrg
9504 1.1 mrg @item @emph{Specific names}:
9505 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
9506 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
9507 1.1 mrg @item @code{LLE(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9508 1.1 mrg @end multitable
9509 1.1 mrg
9510 1.1 mrg @item @emph{See also}:
9511 1.1.1.2 mrg @ref{LGE}, @gol
9512 1.1.1.2 mrg @ref{LGT}, @gol
9513 1.1.1.2 mrg @ref{LLT}
9514 1.1 mrg @end table
9515 1.1 mrg
9516 1.1 mrg
9517 1.1 mrg
9518 1.1 mrg @node LLT
9519 1.1 mrg @section @code{LLT} --- Lexical less than
9520 1.1 mrg @fnindex LLT
9521 1.1 mrg @cindex lexical comparison of strings
9522 1.1 mrg @cindex string, comparison
9523 1.1 mrg
9524 1.1 mrg @table @asis
9525 1.1 mrg @item @emph{Description}:
9526 1.1 mrg Determines whether one string is lexically less than another string,
9527 1.1 mrg where the two strings are interpreted as containing ASCII character
9528 1.1 mrg codes. If the String A and String B are not the same length, the
9529 1.1 mrg shorter is compared as if spaces were appended to it to form a value
9530 1.1 mrg that has the same length as the longer.
9531 1.1 mrg
9532 1.1 mrg In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9533 1.1 mrg @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9534 1.1 mrg operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9535 1.1 mrg that the latter use the processor's character ordering (which is not
9536 1.1 mrg ASCII on some targets), whereas the former always use the ASCII
9537 1.1 mrg ordering.
9538 1.1 mrg
9539 1.1 mrg @item @emph{Standard}:
9540 1.1 mrg Fortran 77 and later
9541 1.1 mrg
9542 1.1 mrg @item @emph{Class}:
9543 1.1 mrg Elemental function
9544 1.1 mrg
9545 1.1 mrg @item @emph{Syntax}:
9546 1.1 mrg @code{RESULT = LLT(STRING_A, STRING_B)}
9547 1.1 mrg
9548 1.1 mrg @item @emph{Arguments}:
9549 1.1 mrg @multitable @columnfractions .15 .70
9550 1.1 mrg @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9551 1.1 mrg @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9552 1.1 mrg @end multitable
9553 1.1 mrg
9554 1.1 mrg @item @emph{Return value}:
9555 1.1 mrg Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
9556 1.1 mrg otherwise, based on the ASCII ordering.
9557 1.1 mrg
9558 1.1 mrg @item @emph{Specific names}:
9559 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
9560 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
9561 1.1 mrg @item @code{LLT(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9562 1.1 mrg @end multitable
9563 1.1 mrg
9564 1.1 mrg @item @emph{See also}:
9565 1.1.1.2 mrg @ref{LGE}, @gol
9566 1.1.1.2 mrg @ref{LGT}, @gol
9567 1.1.1.2 mrg @ref{LLE}
9568 1.1 mrg @end table
9569 1.1 mrg
9570 1.1 mrg
9571 1.1 mrg
9572 1.1 mrg @node LNBLNK
9573 1.1 mrg @section @code{LNBLNK} --- Index of the last non-blank character in a string
9574 1.1 mrg @fnindex LNBLNK
9575 1.1 mrg @cindex string, find non-blank character
9576 1.1 mrg
9577 1.1 mrg @table @asis
9578 1.1 mrg @item @emph{Description}:
9579 1.1 mrg Returns the length of a character string, ignoring any trailing blanks.
9580 1.1 mrg This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
9581 1.1 mrg included for backwards compatibility.
9582 1.1 mrg
9583 1.1 mrg @item @emph{Standard}:
9584 1.1 mrg GNU extension
9585 1.1 mrg
9586 1.1 mrg @item @emph{Class}:
9587 1.1 mrg Elemental function
9588 1.1 mrg
9589 1.1 mrg @item @emph{Syntax}:
9590 1.1 mrg @code{RESULT = LNBLNK(STRING)}
9591 1.1 mrg
9592 1.1 mrg @item @emph{Arguments}:
9593 1.1 mrg @multitable @columnfractions .15 .70
9594 1.1 mrg @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
9595 1.1 mrg with @code{INTENT(IN)}
9596 1.1 mrg @end multitable
9597 1.1 mrg
9598 1.1 mrg @item @emph{Return value}:
9599 1.1 mrg The return value is of @code{INTEGER(kind=4)} type.
9600 1.1 mrg
9601 1.1 mrg @item @emph{See also}:
9602 1.1.1.2 mrg @ref{INDEX intrinsic}, @gol
9603 1.1.1.2 mrg @ref{LEN_TRIM}
9604 1.1 mrg @end table
9605 1.1 mrg
9606 1.1 mrg
9607 1.1 mrg
9608 1.1 mrg @node LOC
9609 1.1 mrg @section @code{LOC} --- Returns the address of a variable
9610 1.1 mrg @fnindex LOC
9611 1.1 mrg @cindex location of a variable in memory
9612 1.1 mrg
9613 1.1 mrg @table @asis
9614 1.1 mrg @item @emph{Description}:
9615 1.1 mrg @code{LOC(X)} returns the address of @var{X} as an integer.
9616 1.1 mrg
9617 1.1 mrg @item @emph{Standard}:
9618 1.1 mrg GNU extension
9619 1.1 mrg
9620 1.1 mrg @item @emph{Class}:
9621 1.1 mrg Inquiry function
9622 1.1 mrg
9623 1.1 mrg @item @emph{Syntax}:
9624 1.1 mrg @code{RESULT = LOC(X)}
9625 1.1 mrg
9626 1.1 mrg @item @emph{Arguments}:
9627 1.1 mrg @multitable @columnfractions .15 .70
9628 1.1 mrg @item @var{X} @tab Variable of any type.
9629 1.1 mrg @end multitable
9630 1.1 mrg
9631 1.1 mrg @item @emph{Return value}:
9632 1.1 mrg The return value is of type @code{INTEGER}, with a @code{KIND}
9633 1.1 mrg corresponding to the size (in bytes) of a memory address on the target
9634 1.1 mrg machine.
9635 1.1 mrg
9636 1.1 mrg @item @emph{Example}:
9637 1.1 mrg @smallexample
9638 1.1 mrg program test_loc
9639 1.1 mrg integer :: i
9640 1.1 mrg real :: r
9641 1.1 mrg i = loc(r)
9642 1.1 mrg print *, i
9643 1.1 mrg end program test_loc
9644 1.1 mrg @end smallexample
9645 1.1 mrg @end table
9646 1.1 mrg
9647 1.1 mrg
9648 1.1 mrg
9649 1.1 mrg @node LOG
9650 1.1 mrg @section @code{LOG} --- Natural logarithm function
9651 1.1 mrg @fnindex LOG
9652 1.1 mrg @fnindex ALOG
9653 1.1 mrg @fnindex DLOG
9654 1.1 mrg @fnindex CLOG
9655 1.1 mrg @fnindex ZLOG
9656 1.1 mrg @fnindex CDLOG
9657 1.1 mrg @cindex exponential function, inverse
9658 1.1 mrg @cindex logarithm function
9659 1.1 mrg @cindex natural logarithm function
9660 1.1 mrg
9661 1.1 mrg @table @asis
9662 1.1 mrg @item @emph{Description}:
9663 1.1 mrg @code{LOG(X)} computes the natural logarithm of @var{X}, i.e. the
9664 1.1 mrg logarithm to the base @math{e}.
9665 1.1 mrg
9666 1.1 mrg @item @emph{Standard}:
9667 1.1.1.2 mrg Fortran 77 and later, has GNU extensions
9668 1.1 mrg
9669 1.1 mrg @item @emph{Class}:
9670 1.1 mrg Elemental function
9671 1.1 mrg
9672 1.1 mrg @item @emph{Syntax}:
9673 1.1 mrg @code{RESULT = LOG(X)}
9674 1.1 mrg
9675 1.1 mrg @item @emph{Arguments}:
9676 1.1 mrg @multitable @columnfractions .15 .70
9677 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or
9678 1.1 mrg @code{COMPLEX}.
9679 1.1 mrg @end multitable
9680 1.1 mrg
9681 1.1 mrg @item @emph{Return value}:
9682 1.1 mrg The return value is of type @code{REAL} or @code{COMPLEX}.
9683 1.1 mrg The kind type parameter is the same as @var{X}.
9684 1.1 mrg If @var{X} is @code{COMPLEX}, the imaginary part @math{\omega} is in the range
9685 1.1 mrg @math{-\pi < \omega \leq \pi}.
9686 1.1 mrg
9687 1.1 mrg @item @emph{Example}:
9688 1.1 mrg @smallexample
9689 1.1 mrg program test_log
9690 1.1 mrg real(8) :: x = 2.7182818284590451_8
9691 1.1 mrg complex :: z = (1.0, 2.0)
9692 1.1 mrg x = log(x) ! will yield (approximately) 1
9693 1.1 mrg z = log(z)
9694 1.1 mrg end program test_log
9695 1.1 mrg @end smallexample
9696 1.1 mrg
9697 1.1 mrg @item @emph{Specific names}:
9698 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
9699 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
9700 1.1.1.2 mrg @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 or later
9701 1.1.1.2 mrg @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 or later
9702 1.1.1.2 mrg @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 or later
9703 1.1.1.2 mrg @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
9704 1.1.1.2 mrg @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
9705 1.1 mrg @end multitable
9706 1.1 mrg @end table
9707 1.1 mrg
9708 1.1 mrg
9709 1.1 mrg
9710 1.1 mrg @node LOG10
9711 1.1 mrg @section @code{LOG10} --- Base 10 logarithm function
9712 1.1 mrg @fnindex LOG10
9713 1.1 mrg @fnindex ALOG10
9714 1.1 mrg @fnindex DLOG10
9715 1.1 mrg @cindex exponential function, inverse
9716 1.1 mrg @cindex logarithm function with base 10
9717 1.1 mrg @cindex base 10 logarithm function
9718 1.1 mrg
9719 1.1 mrg @table @asis
9720 1.1 mrg @item @emph{Description}:
9721 1.1 mrg @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
9722 1.1 mrg
9723 1.1 mrg @item @emph{Standard}:
9724 1.1 mrg Fortran 77 and later
9725 1.1 mrg
9726 1.1 mrg @item @emph{Class}:
9727 1.1 mrg Elemental function
9728 1.1 mrg
9729 1.1 mrg @item @emph{Syntax}:
9730 1.1 mrg @code{RESULT = LOG10(X)}
9731 1.1 mrg
9732 1.1 mrg @item @emph{Arguments}:
9733 1.1 mrg @multitable @columnfractions .15 .70
9734 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
9735 1.1 mrg @end multitable
9736 1.1 mrg
9737 1.1 mrg @item @emph{Return value}:
9738 1.1 mrg The return value is of type @code{REAL} or @code{COMPLEX}.
9739 1.1 mrg The kind type parameter is the same as @var{X}.
9740 1.1 mrg
9741 1.1 mrg @item @emph{Example}:
9742 1.1 mrg @smallexample
9743 1.1 mrg program test_log10
9744 1.1 mrg real(8) :: x = 10.0_8
9745 1.1 mrg x = log10(x)
9746 1.1 mrg end program test_log10
9747 1.1 mrg @end smallexample
9748 1.1 mrg
9749 1.1 mrg @item @emph{Specific names}:
9750 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
9751 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
9752 1.1.1.2 mrg @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
9753 1.1.1.2 mrg @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
9754 1.1 mrg @end multitable
9755 1.1 mrg @end table
9756 1.1 mrg
9757 1.1 mrg
9758 1.1 mrg
9759 1.1 mrg @node LOG_GAMMA
9760 1.1 mrg @section @code{LOG_GAMMA} --- Logarithm of the Gamma function
9761 1.1 mrg @fnindex LOG_GAMMA
9762 1.1 mrg @fnindex LGAMMA
9763 1.1 mrg @fnindex ALGAMA
9764 1.1 mrg @fnindex DLGAMA
9765 1.1 mrg @cindex Gamma function, logarithm of
9766 1.1 mrg
9767 1.1 mrg @table @asis
9768 1.1 mrg @item @emph{Description}:
9769 1.1 mrg @code{LOG_GAMMA(X)} computes the natural logarithm of the absolute value
9770 1.1 mrg of the Gamma (@math{\Gamma}) function.
9771 1.1 mrg
9772 1.1 mrg @item @emph{Standard}:
9773 1.1 mrg Fortran 2008 and later
9774 1.1 mrg
9775 1.1 mrg @item @emph{Class}:
9776 1.1 mrg Elemental function
9777 1.1 mrg
9778 1.1 mrg @item @emph{Syntax}:
9779 1.1 mrg @code{X = LOG_GAMMA(X)}
9780 1.1 mrg
9781 1.1 mrg @item @emph{Arguments}:
9782 1.1 mrg @multitable @columnfractions .15 .70
9783 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL} and neither zero
9784 1.1 mrg nor a negative integer.
9785 1.1 mrg @end multitable
9786 1.1 mrg
9787 1.1 mrg @item @emph{Return value}:
9788 1.1 mrg The return value is of type @code{REAL} of the same kind as @var{X}.
9789 1.1 mrg
9790 1.1 mrg @item @emph{Example}:
9791 1.1 mrg @smallexample
9792 1.1 mrg program test_log_gamma
9793 1.1 mrg real :: x = 1.0
9794 1.1 mrg x = lgamma(x) ! returns 0.0
9795 1.1 mrg end program test_log_gamma
9796 1.1 mrg @end smallexample
9797 1.1 mrg
9798 1.1 mrg @item @emph{Specific names}:
9799 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
9800 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
9801 1.1.1.2 mrg @item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
9802 1.1.1.2 mrg @item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
9803 1.1.1.2 mrg @item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
9804 1.1 mrg @end multitable
9805 1.1 mrg
9806 1.1 mrg @item @emph{See also}:
9807 1.1.1.2 mrg Gamma function: @gol
9808 1.1.1.2 mrg @ref{GAMMA}
9809 1.1 mrg @end table
9810 1.1 mrg
9811 1.1 mrg
9812 1.1 mrg
9813 1.1 mrg @node LOGICAL
9814 1.1 mrg @section @code{LOGICAL} --- Convert to logical type
9815 1.1 mrg @fnindex LOGICAL
9816 1.1 mrg @cindex conversion, to logical
9817 1.1 mrg
9818 1.1 mrg @table @asis
9819 1.1 mrg @item @emph{Description}:
9820 1.1 mrg Converts one kind of @code{LOGICAL} variable to another.
9821 1.1 mrg
9822 1.1 mrg @item @emph{Standard}:
9823 1.1.1.2 mrg Fortran 90 and later
9824 1.1 mrg
9825 1.1 mrg @item @emph{Class}:
9826 1.1 mrg Elemental function
9827 1.1 mrg
9828 1.1 mrg @item @emph{Syntax}:
9829 1.1 mrg @code{RESULT = LOGICAL(L [, KIND])}
9830 1.1 mrg
9831 1.1 mrg @item @emph{Arguments}:
9832 1.1 mrg @multitable @columnfractions .15 .70
9833 1.1 mrg @item @var{L} @tab The type shall be @code{LOGICAL}.
9834 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9835 1.1 mrg expression indicating the kind parameter of the result.
9836 1.1 mrg @end multitable
9837 1.1 mrg
9838 1.1 mrg @item @emph{Return value}:
9839 1.1 mrg The return value is a @code{LOGICAL} value equal to @var{L}, with a
9840 1.1 mrg kind corresponding to @var{KIND}, or of the default logical kind if
9841 1.1 mrg @var{KIND} is not given.
9842 1.1 mrg
9843 1.1 mrg @item @emph{See also}:
9844 1.1.1.2 mrg @ref{INT}, @gol
9845 1.1.1.2 mrg @ref{REAL}, @gol
9846 1.1.1.2 mrg @ref{CMPLX}
9847 1.1 mrg @end table
9848 1.1 mrg
9849 1.1 mrg
9850 1.1 mrg
9851 1.1 mrg @node LONG
9852 1.1 mrg @section @code{LONG} --- Convert to integer type
9853 1.1 mrg @fnindex LONG
9854 1.1 mrg @cindex conversion, to integer
9855 1.1 mrg
9856 1.1 mrg @table @asis
9857 1.1 mrg @item @emph{Description}:
9858 1.1 mrg Convert to a @code{KIND=4} integer type, which is the same size as a C
9859 1.1 mrg @code{long} integer. This is equivalent to the standard @code{INT}
9860 1.1 mrg intrinsic with an optional argument of @code{KIND=4}, and is only
9861 1.1 mrg included for backwards compatibility.
9862 1.1 mrg
9863 1.1 mrg @item @emph{Standard}:
9864 1.1 mrg GNU extension
9865 1.1 mrg
9866 1.1 mrg @item @emph{Class}:
9867 1.1 mrg Elemental function
9868 1.1 mrg
9869 1.1 mrg @item @emph{Syntax}:
9870 1.1 mrg @code{RESULT = LONG(A)}
9871 1.1 mrg
9872 1.1 mrg @item @emph{Arguments}:
9873 1.1 mrg @multitable @columnfractions .15 .70
9874 1.1 mrg @item @var{A} @tab Shall be of type @code{INTEGER},
9875 1.1 mrg @code{REAL}, or @code{COMPLEX}.
9876 1.1 mrg @end multitable
9877 1.1 mrg
9878 1.1 mrg @item @emph{Return value}:
9879 1.1 mrg The return value is a @code{INTEGER(4)} variable.
9880 1.1 mrg
9881 1.1 mrg @item @emph{See also}:
9882 1.1.1.2 mrg @ref{INT}, @gol
9883 1.1.1.2 mrg @ref{INT2}, @gol
9884 1.1.1.2 mrg @ref{INT8}
9885 1.1 mrg @end table
9886 1.1 mrg
9887 1.1 mrg
9888 1.1 mrg
9889 1.1 mrg @node LSHIFT
9890 1.1 mrg @section @code{LSHIFT} --- Left shift bits
9891 1.1 mrg @fnindex LSHIFT
9892 1.1 mrg @cindex bits, shift left
9893 1.1 mrg
9894 1.1 mrg @table @asis
9895 1.1 mrg @item @emph{Description}:
9896 1.1 mrg @code{LSHIFT} returns a value corresponding to @var{I} with all of the
9897 1.1 mrg bits shifted left by @var{SHIFT} places. @var{SHIFT} shall be
9898 1.1 mrg nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise
9899 1.1 mrg the result value is undefined. Bits shifted out from the left end are
9900 1.1 mrg lost; zeros are shifted in from the opposite end.
9901 1.1 mrg
9902 1.1 mrg This function has been superseded by the @code{ISHFT} intrinsic, which
9903 1.1 mrg is standard in Fortran 95 and later, and the @code{SHIFTL} intrinsic,
9904 1.1 mrg which is standard in Fortran 2008 and later.
9905 1.1 mrg
9906 1.1 mrg @item @emph{Standard}:
9907 1.1 mrg GNU extension
9908 1.1 mrg
9909 1.1 mrg @item @emph{Class}:
9910 1.1 mrg Elemental function
9911 1.1 mrg
9912 1.1 mrg @item @emph{Syntax}:
9913 1.1 mrg @code{RESULT = LSHIFT(I, SHIFT)}
9914 1.1 mrg
9915 1.1 mrg @item @emph{Arguments}:
9916 1.1 mrg @multitable @columnfractions .15 .70
9917 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
9918 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
9919 1.1 mrg @end multitable
9920 1.1 mrg
9921 1.1 mrg @item @emph{Return value}:
9922 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
9923 1.1 mrg @var{I}.
9924 1.1 mrg
9925 1.1 mrg @item @emph{See also}:
9926 1.1.1.2 mrg @ref{ISHFT}, @gol
9927 1.1.1.2 mrg @ref{ISHFTC}, @gol
9928 1.1.1.2 mrg @ref{RSHIFT}, @gol
9929 1.1.1.2 mrg @ref{SHIFTA}, @gol
9930 1.1.1.2 mrg @ref{SHIFTL}, @gol
9931 1.1 mrg @ref{SHIFTR}
9932 1.1 mrg @end table
9933 1.1 mrg
9934 1.1 mrg
9935 1.1 mrg
9936 1.1 mrg @node LSTAT
9937 1.1 mrg @section @code{LSTAT} --- Get file status
9938 1.1 mrg @fnindex LSTAT
9939 1.1 mrg @cindex file system, file status
9940 1.1 mrg
9941 1.1 mrg @table @asis
9942 1.1 mrg @item @emph{Description}:
9943 1.1 mrg @code{LSTAT} is identical to @ref{STAT}, except that if path is a
9944 1.1 mrg symbolic link, then the link itself is statted, not the file that it
9945 1.1 mrg refers to.
9946 1.1 mrg
9947 1.1 mrg The elements in @code{VALUES} are the same as described by @ref{STAT}.
9948 1.1 mrg
9949 1.1 mrg This intrinsic is provided in both subroutine and function forms;
9950 1.1 mrg however, only one form can be used in any given program unit.
9951 1.1 mrg
9952 1.1 mrg @item @emph{Standard}:
9953 1.1 mrg GNU extension
9954 1.1 mrg
9955 1.1 mrg @item @emph{Class}:
9956 1.1 mrg Subroutine, function
9957 1.1 mrg
9958 1.1 mrg @item @emph{Syntax}:
9959 1.1 mrg @multitable @columnfractions .80
9960 1.1 mrg @item @code{CALL LSTAT(NAME, VALUES [, STATUS])}
9961 1.1 mrg @item @code{STATUS = LSTAT(NAME, VALUES)}
9962 1.1 mrg @end multitable
9963 1.1 mrg
9964 1.1 mrg @item @emph{Arguments}:
9965 1.1 mrg @multitable @columnfractions .15 .70
9966 1.1 mrg @item @var{NAME} @tab The type shall be @code{CHARACTER} of the default
9967 1.1 mrg kind, a valid path within the file system.
9968 1.1 mrg @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
9969 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}.
9970 1.1 mrg Returns 0 on success and a system specific error code otherwise.
9971 1.1 mrg @end multitable
9972 1.1 mrg
9973 1.1 mrg @item @emph{Example}:
9974 1.1 mrg See @ref{STAT} for an example.
9975 1.1 mrg
9976 1.1 mrg @item @emph{See also}:
9977 1.1.1.2 mrg To stat an open file: @gol
9978 1.1.1.2 mrg @ref{FSTAT} @gol
9979 1.1.1.2 mrg To stat a file: @gol
9980 1.1.1.2 mrg @ref{STAT}
9981 1.1 mrg @end table
9982 1.1 mrg
9983 1.1 mrg
9984 1.1 mrg
9985 1.1 mrg @node LTIME
9986 1.1 mrg @section @code{LTIME} --- Convert time to local time info
9987 1.1 mrg @fnindex LTIME
9988 1.1 mrg @cindex time, conversion to local time info
9989 1.1 mrg
9990 1.1 mrg @table @asis
9991 1.1 mrg @item @emph{Description}:
9992 1.1 mrg Given a system time value @var{TIME} (as provided by the @ref{TIME}
9993 1.1 mrg intrinsic), fills @var{VALUES} with values extracted from it appropriate
9994 1.1 mrg to the local time zone using @code{localtime(3)}.
9995 1.1 mrg
9996 1.1 mrg This intrinsic routine is provided for backwards compatibility with
9997 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of
9998 1.1 mrg the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
9999 1.1 mrg standard.
10000 1.1 mrg
10001 1.1 mrg @item @emph{Standard}:
10002 1.1 mrg GNU extension
10003 1.1 mrg
10004 1.1 mrg @item @emph{Class}:
10005 1.1 mrg Subroutine
10006 1.1 mrg
10007 1.1 mrg @item @emph{Syntax}:
10008 1.1 mrg @code{CALL LTIME(TIME, VALUES)}
10009 1.1 mrg
10010 1.1 mrg @item @emph{Arguments}:
10011 1.1 mrg @multitable @columnfractions .15 .70
10012 1.1 mrg @item @var{TIME} @tab An @code{INTEGER} scalar expression
10013 1.1 mrg corresponding to a system time, with @code{INTENT(IN)}.
10014 1.1 mrg @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
10015 1.1 mrg with @code{INTENT(OUT)}.
10016 1.1 mrg @end multitable
10017 1.1 mrg
10018 1.1 mrg @item @emph{Return value}:
10019 1.1 mrg The elements of @var{VALUES} are assigned as follows:
10020 1.1 mrg @enumerate
10021 1.1 mrg @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
10022 1.1 mrg seconds
10023 1.1 mrg @item Minutes after the hour, range 0--59
10024 1.1 mrg @item Hours past midnight, range 0--23
10025 1.1 mrg @item Day of month, range 1--31
10026 1.1 mrg @item Number of months since January, range 0--11
10027 1.1 mrg @item Years since 1900
10028 1.1 mrg @item Number of days since Sunday, range 0--6
10029 1.1 mrg @item Days since January 1, range 0--365
10030 1.1 mrg @item Daylight savings indicator: positive if daylight savings is in
10031 1.1 mrg effect, zero if not, and negative if the information is not available.
10032 1.1 mrg @end enumerate
10033 1.1 mrg
10034 1.1 mrg @item @emph{See also}:
10035 1.1.1.2 mrg @ref{DATE_AND_TIME}, @gol
10036 1.1.1.2 mrg @ref{CTIME}, @gol
10037 1.1.1.2 mrg @ref{GMTIME}, @gol
10038 1.1.1.2 mrg @ref{TIME}, @gol
10039 1.1.1.2 mrg @ref{TIME8}
10040 1.1 mrg @end table
10041 1.1 mrg
10042 1.1 mrg
10043 1.1 mrg
10044 1.1 mrg @node MALLOC
10045 1.1 mrg @section @code{MALLOC} --- Allocate dynamic memory
10046 1.1 mrg @fnindex MALLOC
10047 1.1 mrg @cindex pointer, cray
10048 1.1 mrg
10049 1.1 mrg @table @asis
10050 1.1 mrg @item @emph{Description}:
10051 1.1 mrg @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
10052 1.1 mrg returns the address of the allocated memory. The @code{MALLOC} intrinsic
10053 1.1 mrg is an extension intended to be used with Cray pointers, and is provided
10054 1.1 mrg in GNU Fortran to allow the user to compile legacy code. For new code
10055 1.1 mrg using Fortran 95 pointers, the memory allocation intrinsic is
10056 1.1 mrg @code{ALLOCATE}.
10057 1.1 mrg
10058 1.1 mrg @item @emph{Standard}:
10059 1.1 mrg GNU extension
10060 1.1 mrg
10061 1.1 mrg @item @emph{Class}:
10062 1.1 mrg Function
10063 1.1 mrg
10064 1.1 mrg @item @emph{Syntax}:
10065 1.1 mrg @code{PTR = MALLOC(SIZE)}
10066 1.1 mrg
10067 1.1 mrg @item @emph{Arguments}:
10068 1.1 mrg @multitable @columnfractions .15 .70
10069 1.1 mrg @item @var{SIZE} @tab The type shall be @code{INTEGER}.
10070 1.1 mrg @end multitable
10071 1.1 mrg
10072 1.1 mrg @item @emph{Return value}:
10073 1.1 mrg The return value is of type @code{INTEGER(K)}, with @var{K} such that
10074 1.1 mrg variables of type @code{INTEGER(K)} have the same size as
10075 1.1 mrg C pointers (@code{sizeof(void *)}).
10076 1.1 mrg
10077 1.1 mrg @item @emph{Example}:
10078 1.1 mrg The following example demonstrates the use of @code{MALLOC} and
10079 1.1 mrg @code{FREE} with Cray pointers.
10080 1.1 mrg
10081 1.1 mrg @smallexample
10082 1.1 mrg program test_malloc
10083 1.1 mrg implicit none
10084 1.1 mrg integer i
10085 1.1 mrg real*8 x(*), z
10086 1.1 mrg pointer(ptr_x,x)
10087 1.1 mrg
10088 1.1 mrg ptr_x = malloc(20*8)
10089 1.1 mrg do i = 1, 20
10090 1.1 mrg x(i) = sqrt(1.0d0 / i)
10091 1.1 mrg end do
10092 1.1 mrg z = 0
10093 1.1 mrg do i = 1, 20
10094 1.1 mrg z = z + x(i)
10095 1.1 mrg print *, z
10096 1.1 mrg end do
10097 1.1 mrg call free(ptr_x)
10098 1.1 mrg end program test_malloc
10099 1.1 mrg @end smallexample
10100 1.1 mrg
10101 1.1 mrg @item @emph{See also}:
10102 1.1 mrg @ref{FREE}
10103 1.1 mrg @end table
10104 1.1 mrg
10105 1.1 mrg
10106 1.1 mrg
10107 1.1 mrg @node MASKL
10108 1.1 mrg @section @code{MASKL} --- Left justified mask
10109 1.1 mrg @fnindex MASKL
10110 1.1 mrg @cindex mask, left justified
10111 1.1 mrg
10112 1.1 mrg @table @asis
10113 1.1 mrg @item @emph{Description}:
10114 1.1 mrg @code{MASKL(I[, KIND])} has its leftmost @var{I} bits set to 1, and the
10115 1.1 mrg remaining bits set to 0.
10116 1.1 mrg
10117 1.1 mrg @item @emph{Standard}:
10118 1.1 mrg Fortran 2008 and later
10119 1.1 mrg
10120 1.1 mrg @item @emph{Class}:
10121 1.1 mrg Elemental function
10122 1.1 mrg
10123 1.1 mrg @item @emph{Syntax}:
10124 1.1 mrg @code{RESULT = MASKL(I[, KIND])}
10125 1.1 mrg
10126 1.1 mrg @item @emph{Arguments}:
10127 1.1 mrg @multitable @columnfractions .15 .70
10128 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}.
10129 1.1 mrg @item @var{KIND} @tab Shall be a scalar constant expression of type
10130 1.1 mrg @code{INTEGER}.
10131 1.1 mrg @end multitable
10132 1.1 mrg
10133 1.1 mrg @item @emph{Return value}:
10134 1.1 mrg The return value is of type @code{INTEGER}. If @var{KIND} is present, it
10135 1.1 mrg specifies the kind value of the return type; otherwise, it is of the
10136 1.1 mrg default integer kind.
10137 1.1 mrg
10138 1.1 mrg @item @emph{See also}:
10139 1.1 mrg @ref{MASKR}
10140 1.1 mrg @end table
10141 1.1 mrg
10142 1.1 mrg
10143 1.1 mrg
10144 1.1 mrg @node MASKR
10145 1.1 mrg @section @code{MASKR} --- Right justified mask
10146 1.1 mrg @fnindex MASKR
10147 1.1 mrg @cindex mask, right justified
10148 1.1 mrg
10149 1.1 mrg @table @asis
10150 1.1 mrg @item @emph{Description}:
10151 1.1 mrg @code{MASKL(I[, KIND])} has its rightmost @var{I} bits set to 1, and the
10152 1.1 mrg remaining bits set to 0.
10153 1.1 mrg
10154 1.1 mrg @item @emph{Standard}:
10155 1.1 mrg Fortran 2008 and later
10156 1.1 mrg
10157 1.1 mrg @item @emph{Class}:
10158 1.1 mrg Elemental function
10159 1.1 mrg
10160 1.1 mrg @item @emph{Syntax}:
10161 1.1 mrg @code{RESULT = MASKR(I[, KIND])}
10162 1.1 mrg
10163 1.1 mrg @item @emph{Arguments}:
10164 1.1 mrg @multitable @columnfractions .15 .70
10165 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}.
10166 1.1 mrg @item @var{KIND} @tab Shall be a scalar constant expression of type
10167 1.1 mrg @code{INTEGER}.
10168 1.1 mrg @end multitable
10169 1.1 mrg
10170 1.1 mrg @item @emph{Return value}:
10171 1.1 mrg The return value is of type @code{INTEGER}. If @var{KIND} is present, it
10172 1.1 mrg specifies the kind value of the return type; otherwise, it is of the
10173 1.1 mrg default integer kind.
10174 1.1 mrg
10175 1.1 mrg @item @emph{See also}:
10176 1.1 mrg @ref{MASKL}
10177 1.1 mrg @end table
10178 1.1 mrg
10179 1.1 mrg
10180 1.1 mrg
10181 1.1 mrg @node MATMUL
10182 1.1 mrg @section @code{MATMUL} --- matrix multiplication
10183 1.1 mrg @fnindex MATMUL
10184 1.1 mrg @cindex matrix multiplication
10185 1.1 mrg @cindex product, matrix
10186 1.1 mrg
10187 1.1 mrg @table @asis
10188 1.1 mrg @item @emph{Description}:
10189 1.1 mrg Performs a matrix multiplication on numeric or logical arguments.
10190 1.1 mrg
10191 1.1 mrg @item @emph{Standard}:
10192 1.1.1.2 mrg Fortran 90 and later
10193 1.1 mrg
10194 1.1 mrg @item @emph{Class}:
10195 1.1 mrg Transformational function
10196 1.1 mrg
10197 1.1 mrg @item @emph{Syntax}:
10198 1.1 mrg @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
10199 1.1 mrg
10200 1.1 mrg @item @emph{Arguments}:
10201 1.1 mrg @multitable @columnfractions .15 .70
10202 1.1 mrg @item @var{MATRIX_A} @tab An array of @code{INTEGER},
10203 1.1 mrg @code{REAL}, @code{COMPLEX}, or @code{LOGICAL} type, with a rank of
10204 1.1 mrg one or two.
10205 1.1 mrg @item @var{MATRIX_B} @tab An array of @code{INTEGER},
10206 1.1 mrg @code{REAL}, or @code{COMPLEX} type if @var{MATRIX_A} is of a numeric
10207 1.1 mrg type; otherwise, an array of @code{LOGICAL} type. The rank shall be one
10208 1.1 mrg or two, and the first (or only) dimension of @var{MATRIX_B} shall be
10209 1.1 mrg equal to the last (or only) dimension of @var{MATRIX_A}.
10210 1.1 mrg @var{MATRIX_A} and @var{MATRIX_B} shall not both be rank one arrays.
10211 1.1 mrg @end multitable
10212 1.1 mrg
10213 1.1 mrg @item @emph{Return value}:
10214 1.1 mrg The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and
10215 1.1 mrg kind of the result follow the usual type and kind promotion rules, as
10216 1.1 mrg for the @code{*} or @code{.AND.} operators.
10217 1.1 mrg @end table
10218 1.1 mrg
10219 1.1 mrg
10220 1.1 mrg
10221 1.1 mrg @node MAX
10222 1.1 mrg @section @code{MAX} --- Maximum value of an argument list
10223 1.1 mrg @fnindex MAX
10224 1.1 mrg @fnindex MAX0
10225 1.1 mrg @fnindex AMAX0
10226 1.1 mrg @fnindex MAX1
10227 1.1 mrg @fnindex AMAX1
10228 1.1 mrg @fnindex DMAX1
10229 1.1 mrg @cindex maximum value
10230 1.1 mrg
10231 1.1 mrg @table @asis
10232 1.1 mrg @item @emph{Description}:
10233 1.1 mrg Returns the argument with the largest (most positive) value.
10234 1.1 mrg
10235 1.1 mrg @item @emph{Standard}:
10236 1.1 mrg Fortran 77 and later
10237 1.1 mrg
10238 1.1 mrg @item @emph{Class}:
10239 1.1 mrg Elemental function
10240 1.1 mrg
10241 1.1 mrg @item @emph{Syntax}:
10242 1.1 mrg @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
10243 1.1 mrg
10244 1.1 mrg @item @emph{Arguments}:
10245 1.1 mrg @multitable @columnfractions .15 .70
10246 1.1 mrg @item @var{A1} @tab The type shall be @code{INTEGER} or
10247 1.1 mrg @code{REAL}.
10248 1.1 mrg @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
10249 1.1 mrg as @var{A1}. (As a GNU extension, arguments of different kinds are
10250 1.1 mrg permitted.)
10251 1.1 mrg @end multitable
10252 1.1 mrg
10253 1.1 mrg @item @emph{Return value}:
10254 1.1 mrg The return value corresponds to the maximum value among the arguments,
10255 1.1 mrg and has the same type and kind as the first argument.
10256 1.1 mrg
10257 1.1 mrg @item @emph{Specific names}:
10258 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
10259 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
10260 1.1 mrg @item @code{MAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
10261 1.1 mrg @item @code{AMAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(MAX(X))} @tab Fortran 77 and later
10262 1.1 mrg @item @code{MAX1(A1)} @tab @code{REAL A1} @tab @code{INT(MAX(X))} @tab Fortran 77 and later
10263 1.1 mrg @item @code{AMAX1(A1)} @tab @code{REAL(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
10264 1.1 mrg @item @code{DMAX1(A1)} @tab @code{REAL(8) A1} @tab @code{REAL(8)} @tab Fortran 77 and later
10265 1.1 mrg @end multitable
10266 1.1 mrg
10267 1.1 mrg @item @emph{See also}:
10268 1.1.1.2 mrg @ref{MAXLOC} @gol
10269 1.1.1.2 mrg @ref{MAXVAL}, @gol
10270 1.1.1.2 mrg @ref{MIN}
10271 1.1 mrg @end table
10272 1.1 mrg
10273 1.1 mrg
10274 1.1 mrg
10275 1.1 mrg @node MAXEXPONENT
10276 1.1 mrg @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
10277 1.1 mrg @fnindex MAXEXPONENT
10278 1.1 mrg @cindex model representation, maximum exponent
10279 1.1 mrg
10280 1.1 mrg @table @asis
10281 1.1 mrg @item @emph{Description}:
10282 1.1 mrg @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
10283 1.1 mrg type of @code{X}.
10284 1.1 mrg
10285 1.1 mrg @item @emph{Standard}:
10286 1.1.1.2 mrg Fortran 90 and later
10287 1.1 mrg
10288 1.1 mrg @item @emph{Class}:
10289 1.1 mrg Inquiry function
10290 1.1 mrg
10291 1.1 mrg @item @emph{Syntax}:
10292 1.1 mrg @code{RESULT = MAXEXPONENT(X)}
10293 1.1 mrg
10294 1.1 mrg @item @emph{Arguments}:
10295 1.1 mrg @multitable @columnfractions .15 .70
10296 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}.
10297 1.1 mrg @end multitable
10298 1.1 mrg
10299 1.1 mrg @item @emph{Return value}:
10300 1.1 mrg The return value is of type @code{INTEGER} and of the default integer
10301 1.1 mrg kind.
10302 1.1 mrg
10303 1.1 mrg @item @emph{Example}:
10304 1.1 mrg @smallexample
10305 1.1 mrg program exponents
10306 1.1 mrg real(kind=4) :: x
10307 1.1 mrg real(kind=8) :: y
10308 1.1 mrg
10309 1.1 mrg print *, minexponent(x), maxexponent(x)
10310 1.1 mrg print *, minexponent(y), maxexponent(y)
10311 1.1 mrg end program exponents
10312 1.1 mrg @end smallexample
10313 1.1 mrg @end table
10314 1.1 mrg
10315 1.1 mrg
10316 1.1 mrg
10317 1.1 mrg @node MAXLOC
10318 1.1 mrg @section @code{MAXLOC} --- Location of the maximum value within an array
10319 1.1 mrg @fnindex MAXLOC
10320 1.1 mrg @cindex array, location of maximum element
10321 1.1 mrg
10322 1.1 mrg @table @asis
10323 1.1 mrg @item @emph{Description}:
10324 1.1 mrg Determines the location of the element in the array with the maximum
10325 1.1 mrg value, or, if the @var{DIM} argument is supplied, determines the
10326 1.1 mrg locations of the maximum element along each row of the array in the
10327 1.1 mrg @var{DIM} direction. If @var{MASK} is present, only the elements for
10328 1.1 mrg which @var{MASK} is @code{.TRUE.} are considered. If more than one
10329 1.1 mrg element in the array has the maximum value, the location returned is
10330 1.1 mrg that of the first such element in array element order if the
10331 1.1 mrg @var{BACK} is not present, or is false; if @var{BACK} is true, the location
10332 1.1 mrg returned is that of the last such element. If the array has zero
10333 1.1 mrg size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
10334 1.1 mrg the result is an array of zeroes. Similarly, if @var{DIM} is supplied
10335 1.1 mrg and all of the elements of @var{MASK} along a given row are zero, the
10336 1.1 mrg result value for that row is zero.
10337 1.1 mrg
10338 1.1 mrg @item @emph{Standard}:
10339 1.1 mrg Fortran 95 and later; @var{ARRAY} of @code{CHARACTER} and the
10340 1.1 mrg @var{KIND} argument are available in Fortran 2003 and later.
10341 1.1 mrg The @var{BACK} argument is available in Fortran 2008 and later.
10342 1.1 mrg
10343 1.1 mrg @item @emph{Class}:
10344 1.1 mrg Transformational function
10345 1.1 mrg
10346 1.1 mrg @item @emph{Syntax}:
10347 1.1 mrg @multitable @columnfractions .80
10348 1.1 mrg @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK])}
10349 1.1 mrg @item @code{RESULT = MAXLOC(ARRAY [, MASK] [,KIND] [,BACK])}
10350 1.1 mrg @end multitable
10351 1.1 mrg
10352 1.1 mrg @item @emph{Arguments}:
10353 1.1 mrg @multitable @columnfractions .15 .70
10354 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
10355 1.1 mrg @code{REAL}.
10356 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar of type
10357 1.1 mrg @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10358 1.1 mrg inclusive. It may not be an optional dummy argument.
10359 1.1 mrg @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
10360 1.1 mrg and conformable with @var{ARRAY}.
10361 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10362 1.1 mrg expression indicating the kind parameter of the result.
10363 1.1 mrg @item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}.
10364 1.1 mrg @end multitable
10365 1.1 mrg
10366 1.1 mrg @item @emph{Return value}:
10367 1.1 mrg If @var{DIM} is absent, the result is a rank-one array with a length
10368 1.1 mrg equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
10369 1.1 mrg is an array with a rank one less than the rank of @var{ARRAY}, and a
10370 1.1 mrg size corresponding to the size of @var{ARRAY} with the @var{DIM}
10371 1.1 mrg dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
10372 1.1 mrg of one, the result is a scalar. If the optional argument @var{KIND}
10373 1.1 mrg is present, the result is an integer of kind @var{KIND}, otherwise it
10374 1.1 mrg is of default kind.
10375 1.1 mrg
10376 1.1 mrg @item @emph{See also}:
10377 1.1.1.2 mrg @ref{FINDLOC}, @gol
10378 1.1.1.2 mrg @ref{MAX}, @gol
10379 1.1.1.2 mrg @ref{MAXVAL}
10380 1.1 mrg @end table
10381 1.1 mrg
10382 1.1 mrg
10383 1.1 mrg
10384 1.1 mrg @node MAXVAL
10385 1.1 mrg @section @code{MAXVAL} --- Maximum value of an array
10386 1.1 mrg @fnindex MAXVAL
10387 1.1 mrg @cindex array, maximum value
10388 1.1 mrg @cindex maximum value
10389 1.1 mrg
10390 1.1 mrg @table @asis
10391 1.1 mrg @item @emph{Description}:
10392 1.1 mrg Determines the maximum value of the elements in an array value, or, if
10393 1.1 mrg the @var{DIM} argument is supplied, determines the maximum value along
10394 1.1 mrg each row of the array in the @var{DIM} direction. If @var{MASK} is
10395 1.1 mrg present, only the elements for which @var{MASK} is @code{.TRUE.} are
10396 1.1 mrg considered. If the array has zero size, or all of the elements of
10397 1.1 mrg @var{MASK} are @code{.FALSE.}, then the result is @code{-HUGE(ARRAY)}
10398 1.1 mrg if @var{ARRAY} is numeric, or a string of nulls if @var{ARRAY} is of character
10399 1.1 mrg type.
10400 1.1 mrg
10401 1.1 mrg @item @emph{Standard}:
10402 1.1.1.2 mrg Fortran 90 and later
10403 1.1 mrg
10404 1.1 mrg @item @emph{Class}:
10405 1.1 mrg Transformational function
10406 1.1 mrg
10407 1.1 mrg @item @emph{Syntax}:
10408 1.1 mrg @multitable @columnfractions .80
10409 1.1 mrg @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
10410 1.1 mrg @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
10411 1.1 mrg @end multitable
10412 1.1 mrg
10413 1.1 mrg @item @emph{Arguments}:
10414 1.1 mrg @multitable @columnfractions .15 .70
10415 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
10416 1.1 mrg @code{REAL}.
10417 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar of type
10418 1.1 mrg @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10419 1.1 mrg inclusive. It may not be an optional dummy argument.
10420 1.1.1.2 mrg @item @var{MASK} @tab (Opional) Shall be an array of type @code{LOGICAL},
10421 1.1 mrg and conformable with @var{ARRAY}.
10422 1.1 mrg @end multitable
10423 1.1 mrg
10424 1.1 mrg @item @emph{Return value}:
10425 1.1 mrg If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
10426 1.1 mrg is a scalar. If @var{DIM} is present, the result is an array with a
10427 1.1 mrg rank one less than the rank of @var{ARRAY}, and a size corresponding to
10428 1.1 mrg the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
10429 1.1 mrg cases, the result is of the same type and kind as @var{ARRAY}.
10430 1.1 mrg
10431 1.1 mrg @item @emph{See also}:
10432 1.1.1.2 mrg @ref{MAX}, @gol
10433 1.1.1.2 mrg @ref{MAXLOC}
10434 1.1 mrg @end table
10435 1.1 mrg
10436 1.1 mrg
10437 1.1 mrg
10438 1.1 mrg @node MCLOCK
10439 1.1 mrg @section @code{MCLOCK} --- Time function
10440 1.1 mrg @fnindex MCLOCK
10441 1.1 mrg @cindex time, clock ticks
10442 1.1 mrg @cindex clock ticks
10443 1.1 mrg
10444 1.1 mrg @table @asis
10445 1.1 mrg @item @emph{Description}:
10446 1.1 mrg Returns the number of clock ticks since the start of the process, based
10447 1.1 mrg on the function @code{clock(3)} in the C standard library.
10448 1.1 mrg
10449 1.1 mrg This intrinsic is not fully portable, such as to systems with 32-bit
10450 1.1 mrg @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
10451 1.1 mrg the values returned by this intrinsic might be, or become, negative, or
10452 1.1 mrg numerically less than previous values, during a single run of the
10453 1.1 mrg compiled program.
10454 1.1 mrg
10455 1.1 mrg @item @emph{Standard}:
10456 1.1 mrg GNU extension
10457 1.1 mrg
10458 1.1 mrg @item @emph{Class}:
10459 1.1 mrg Function
10460 1.1 mrg
10461 1.1 mrg @item @emph{Syntax}:
10462 1.1 mrg @code{RESULT = MCLOCK()}
10463 1.1 mrg
10464 1.1 mrg @item @emph{Return value}:
10465 1.1 mrg The return value is a scalar of type @code{INTEGER(4)}, equal to the
10466 1.1 mrg number of clock ticks since the start of the process, or @code{-1} if
10467 1.1 mrg the system does not support @code{clock(3)}.
10468 1.1 mrg
10469 1.1 mrg @item @emph{See also}:
10470 1.1.1.2 mrg @ref{CTIME}, @gol
10471 1.1.1.2 mrg @ref{GMTIME}, @gol
10472 1.1.1.2 mrg @ref{LTIME}, @gol
10473 1.1.1.2 mrg @ref{MCLOCK}, @gol
10474 1.1.1.2 mrg @ref{TIME}
10475 1.1 mrg @end table
10476 1.1 mrg
10477 1.1 mrg
10478 1.1 mrg
10479 1.1 mrg @node MCLOCK8
10480 1.1 mrg @section @code{MCLOCK8} --- Time function (64-bit)
10481 1.1 mrg @fnindex MCLOCK8
10482 1.1 mrg @cindex time, clock ticks
10483 1.1 mrg @cindex clock ticks
10484 1.1 mrg
10485 1.1 mrg @table @asis
10486 1.1 mrg @item @emph{Description}:
10487 1.1 mrg Returns the number of clock ticks since the start of the process, based
10488 1.1 mrg on the function @code{clock(3)} in the C standard library.
10489 1.1 mrg
10490 1.1 mrg @emph{Warning:} this intrinsic does not increase the range of the timing
10491 1.1 mrg values over that returned by @code{clock(3)}. On a system with a 32-bit
10492 1.1 mrg @code{clock(3)}, @code{MCLOCK8} will return a 32-bit value, even though
10493 1.1 mrg it is converted to a 64-bit @code{INTEGER(8)} value. That means
10494 1.1 mrg overflows of the 32-bit value can still occur. Therefore, the values
10495 1.1 mrg returned by this intrinsic might be or become negative or numerically
10496 1.1 mrg less than previous values during a single run of the compiled program.
10497 1.1 mrg
10498 1.1 mrg @item @emph{Standard}:
10499 1.1 mrg GNU extension
10500 1.1 mrg
10501 1.1 mrg @item @emph{Class}:
10502 1.1 mrg Function
10503 1.1 mrg
10504 1.1 mrg @item @emph{Syntax}:
10505 1.1 mrg @code{RESULT = MCLOCK8()}
10506 1.1 mrg
10507 1.1 mrg @item @emph{Return value}:
10508 1.1 mrg The return value is a scalar of type @code{INTEGER(8)}, equal to the
10509 1.1 mrg number of clock ticks since the start of the process, or @code{-1} if
10510 1.1 mrg the system does not support @code{clock(3)}.
10511 1.1 mrg
10512 1.1 mrg @item @emph{See also}:
10513 1.1.1.2 mrg @ref{CTIME}, @gol
10514 1.1.1.2 mrg @ref{GMTIME}, @gol
10515 1.1.1.2 mrg @ref{LTIME}, @gol
10516 1.1.1.2 mrg @ref{MCLOCK}, @gol
10517 1.1.1.2 mrg @ref{TIME8}
10518 1.1 mrg @end table
10519 1.1 mrg
10520 1.1 mrg
10521 1.1 mrg
10522 1.1 mrg @node MERGE
10523 1.1 mrg @section @code{MERGE} --- Merge variables
10524 1.1 mrg @fnindex MERGE
10525 1.1 mrg @cindex array, merge arrays
10526 1.1 mrg @cindex array, combine arrays
10527 1.1 mrg
10528 1.1 mrg @table @asis
10529 1.1 mrg @item @emph{Description}:
10530 1.1 mrg Select values from two arrays according to a logical mask. The result
10531 1.1 mrg is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
10532 1.1 mrg @var{FSOURCE} if it is @code{.FALSE.}.
10533 1.1 mrg
10534 1.1 mrg @item @emph{Standard}:
10535 1.1.1.2 mrg Fortran 90 and later
10536 1.1 mrg
10537 1.1 mrg @item @emph{Class}:
10538 1.1 mrg Elemental function
10539 1.1 mrg
10540 1.1 mrg @item @emph{Syntax}:
10541 1.1 mrg @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
10542 1.1 mrg
10543 1.1 mrg @item @emph{Arguments}:
10544 1.1 mrg @multitable @columnfractions .15 .70
10545 1.1 mrg @item @var{TSOURCE} @tab May be of any type.
10546 1.1 mrg @item @var{FSOURCE} @tab Shall be of the same type and type parameters
10547 1.1 mrg as @var{TSOURCE}.
10548 1.1 mrg @item @var{MASK} @tab Shall be of type @code{LOGICAL}.
10549 1.1 mrg @end multitable
10550 1.1 mrg
10551 1.1 mrg @item @emph{Return value}:
10552 1.1 mrg The result is of the same type and type parameters as @var{TSOURCE}.
10553 1.1 mrg
10554 1.1 mrg @end table
10555 1.1 mrg
10556 1.1 mrg
10557 1.1 mrg
10558 1.1 mrg @node MERGE_BITS
10559 1.1 mrg @section @code{MERGE_BITS} --- Merge of bits under mask
10560 1.1 mrg @fnindex MERGE_BITS
10561 1.1 mrg @cindex bits, merge
10562 1.1 mrg
10563 1.1 mrg @table @asis
10564 1.1 mrg @item @emph{Description}:
10565 1.1 mrg @code{MERGE_BITS(I, J, MASK)} merges the bits of @var{I} and @var{J}
10566 1.1 mrg as determined by the mask. The i-th bit of the result is equal to the
10567 1.1 mrg i-th bit of @var{I} if the i-th bit of @var{MASK} is 1; it is equal to
10568 1.1 mrg the i-th bit of @var{J} otherwise.
10569 1.1 mrg
10570 1.1 mrg @item @emph{Standard}:
10571 1.1 mrg Fortran 2008 and later
10572 1.1 mrg
10573 1.1 mrg @item @emph{Class}:
10574 1.1 mrg Elemental function
10575 1.1 mrg
10576 1.1 mrg @item @emph{Syntax}:
10577 1.1 mrg @code{RESULT = MERGE_BITS(I, J, MASK)}
10578 1.1 mrg
10579 1.1 mrg @item @emph{Arguments}:
10580 1.1 mrg @multitable @columnfractions .15 .70
10581 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER} or a boz-literal-constant.
10582 1.1 mrg @item @var{J} @tab Shall be of type @code{INTEGER} with the same
10583 1.1 mrg kind type parameter as @var{I} or a boz-literal-constant.
10584 1.1 mrg @var{I} and @var{J} shall not both be boz-literal-constants.
10585 1.1 mrg @item @var{MASK} @tab Shall be of type @code{INTEGER} or a boz-literal-constant
10586 1.1 mrg and of the same kind as @var{I}.
10587 1.1 mrg @end multitable
10588 1.1 mrg
10589 1.1 mrg @item @emph{Return value}:
10590 1.1 mrg The result is of the same type and kind as @var{I}.
10591 1.1 mrg
10592 1.1 mrg @end table
10593 1.1 mrg
10594 1.1 mrg
10595 1.1 mrg
10596 1.1 mrg @node MIN
10597 1.1 mrg @section @code{MIN} --- Minimum value of an argument list
10598 1.1 mrg @fnindex MIN
10599 1.1 mrg @fnindex MIN0
10600 1.1 mrg @fnindex AMIN0
10601 1.1 mrg @fnindex MIN1
10602 1.1 mrg @fnindex AMIN1
10603 1.1 mrg @fnindex DMIN1
10604 1.1 mrg @cindex minimum value
10605 1.1 mrg
10606 1.1 mrg @table @asis
10607 1.1 mrg @item @emph{Description}:
10608 1.1 mrg Returns the argument with the smallest (most negative) value.
10609 1.1 mrg
10610 1.1 mrg @item @emph{Standard}:
10611 1.1 mrg Fortran 77 and later
10612 1.1 mrg
10613 1.1 mrg @item @emph{Class}:
10614 1.1 mrg Elemental function
10615 1.1 mrg
10616 1.1 mrg @item @emph{Syntax}:
10617 1.1 mrg @code{RESULT = MIN(A1, A2 [, A3, ...])}
10618 1.1 mrg
10619 1.1 mrg @item @emph{Arguments}:
10620 1.1 mrg @multitable @columnfractions .15 .70
10621 1.1 mrg @item @var{A1} @tab The type shall be @code{INTEGER} or
10622 1.1 mrg @code{REAL}.
10623 1.1 mrg @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
10624 1.1 mrg as @var{A1}. (As a GNU extension, arguments of different kinds are
10625 1.1 mrg permitted.)
10626 1.1 mrg @end multitable
10627 1.1 mrg
10628 1.1 mrg @item @emph{Return value}:
10629 1.1 mrg The return value corresponds to the maximum value among the arguments,
10630 1.1 mrg and has the same type and kind as the first argument.
10631 1.1 mrg
10632 1.1 mrg @item @emph{Specific names}:
10633 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
10634 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
10635 1.1 mrg @item @code{MIN0(A1)} @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
10636 1.1 mrg @item @code{AMIN0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
10637 1.1 mrg @item @code{MIN1(A1)} @tab @code{REAL A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
10638 1.1 mrg @item @code{AMIN1(A1)} @tab @code{REAL(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
10639 1.1 mrg @item @code{DMIN1(A1)} @tab @code{REAL(8) A1} @tab @code{REAL(8)} @tab Fortran 77 and later
10640 1.1 mrg @end multitable
10641 1.1 mrg
10642 1.1 mrg @item @emph{See also}:
10643 1.1.1.2 mrg @ref{MAX}, @gol
10644 1.1.1.2 mrg @ref{MINLOC}, @gol
10645 1.1.1.2 mrg @ref{MINVAL}
10646 1.1 mrg @end table
10647 1.1 mrg
10648 1.1 mrg
10649 1.1 mrg
10650 1.1 mrg @node MINEXPONENT
10651 1.1 mrg @section @code{MINEXPONENT} --- Minimum exponent of a real kind
10652 1.1 mrg @fnindex MINEXPONENT
10653 1.1 mrg @cindex model representation, minimum exponent
10654 1.1 mrg
10655 1.1 mrg @table @asis
10656 1.1 mrg @item @emph{Description}:
10657 1.1 mrg @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
10658 1.1 mrg type of @code{X}.
10659 1.1 mrg
10660 1.1 mrg @item @emph{Standard}:
10661 1.1.1.2 mrg Fortran 90 and later
10662 1.1 mrg
10663 1.1 mrg @item @emph{Class}:
10664 1.1 mrg Inquiry function
10665 1.1 mrg
10666 1.1 mrg @item @emph{Syntax}:
10667 1.1 mrg @code{RESULT = MINEXPONENT(X)}
10668 1.1 mrg
10669 1.1 mrg @item @emph{Arguments}:
10670 1.1 mrg @multitable @columnfractions .15 .70
10671 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}.
10672 1.1 mrg @end multitable
10673 1.1 mrg
10674 1.1 mrg @item @emph{Return value}:
10675 1.1 mrg The return value is of type @code{INTEGER} and of the default integer
10676 1.1 mrg kind.
10677 1.1 mrg
10678 1.1 mrg @item @emph{Example}:
10679 1.1 mrg See @code{MAXEXPONENT} for an example.
10680 1.1 mrg @end table
10681 1.1 mrg
10682 1.1 mrg
10683 1.1 mrg
10684 1.1 mrg @node MINLOC
10685 1.1 mrg @section @code{MINLOC} --- Location of the minimum value within an array
10686 1.1 mrg @fnindex MINLOC
10687 1.1 mrg @cindex array, location of minimum element
10688 1.1 mrg
10689 1.1 mrg @table @asis
10690 1.1 mrg @item @emph{Description}:
10691 1.1 mrg Determines the location of the element in the array with the minimum
10692 1.1 mrg value, or, if the @var{DIM} argument is supplied, determines the
10693 1.1 mrg locations of the minimum element along each row of the array in the
10694 1.1 mrg @var{DIM} direction. If @var{MASK} is present, only the elements for
10695 1.1 mrg which @var{MASK} is @code{.TRUE.} are considered. If more than one
10696 1.1 mrg element in the array has the minimum value, the location returned is
10697 1.1 mrg that of the first such element in array element order if the
10698 1.1 mrg @var{BACK} is not present, or is false; if @var{BACK} is true, the location
10699 1.1 mrg returned is that of the last such element. If the array has
10700 1.1 mrg zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
10701 1.1 mrg the result is an array of zeroes. Similarly, if @var{DIM} is supplied
10702 1.1 mrg and all of the elements of @var{MASK} along a given row are zero, the
10703 1.1 mrg result value for that row is zero.
10704 1.1 mrg
10705 1.1 mrg @item @emph{Standard}:
10706 1.1.1.2 mrg Fortran 90 and later; @var{ARRAY} of @code{CHARACTER} and the
10707 1.1 mrg @var{KIND} argument are available in Fortran 2003 and later.
10708 1.1 mrg The @var{BACK} argument is available in Fortran 2008 and later.
10709 1.1 mrg
10710 1.1 mrg @item @emph{Class}:
10711 1.1 mrg Transformational function
10712 1.1 mrg
10713 1.1 mrg @item @emph{Syntax}:
10714 1.1 mrg @multitable @columnfractions .80
10715 1.1 mrg @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK])}
10716 1.1 mrg @item @code{RESULT = MINLOC(ARRAY [, MASK], [,KIND] [,BACK])}
10717 1.1 mrg @end multitable
10718 1.1 mrg
10719 1.1 mrg @item @emph{Arguments}:
10720 1.1 mrg @multitable @columnfractions .15 .70
10721 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
10722 1.1 mrg @code{REAL} or @code{CHARACTER}.
10723 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar of type
10724 1.1 mrg @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10725 1.1 mrg inclusive. It may not be an optional dummy argument.
10726 1.1 mrg @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
10727 1.1 mrg and conformable with @var{ARRAY}.
10728 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10729 1.1 mrg expression indicating the kind parameter of the result.
10730 1.1 mrg @item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}.
10731 1.1 mrg @end multitable
10732 1.1 mrg
10733 1.1 mrg @item @emph{Return value}:
10734 1.1 mrg If @var{DIM} is absent, the result is a rank-one array with a length
10735 1.1 mrg equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
10736 1.1 mrg is an array with a rank one less than the rank of @var{ARRAY}, and a
10737 1.1 mrg size corresponding to the size of @var{ARRAY} with the @var{DIM}
10738 1.1 mrg dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
10739 1.1 mrg of one, the result is a scalar. If the optional argument @var{KIND}
10740 1.1 mrg is present, the result is an integer of kind @var{KIND}, otherwise it
10741 1.1 mrg is of default kind.
10742 1.1 mrg
10743 1.1 mrg @item @emph{See also}:
10744 1.1.1.2 mrg @ref{FINDLOC}, @gol
10745 1.1.1.2 mrg @ref{MIN}, @gol
10746 1.1.1.2 mrg @ref{MINVAL}
10747 1.1 mrg @end table
10748 1.1 mrg
10749 1.1 mrg
10750 1.1 mrg
10751 1.1 mrg @node MINVAL
10752 1.1 mrg @section @code{MINVAL} --- Minimum value of an array
10753 1.1 mrg @fnindex MINVAL
10754 1.1 mrg @cindex array, minimum value
10755 1.1 mrg @cindex minimum value
10756 1.1 mrg
10757 1.1 mrg @table @asis
10758 1.1 mrg @item @emph{Description}:
10759 1.1 mrg Determines the minimum value of the elements in an array value, or, if
10760 1.1 mrg the @var{DIM} argument is supplied, determines the minimum value along
10761 1.1 mrg each row of the array in the @var{DIM} direction. If @var{MASK} is
10762 1.1 mrg present, only the elements for which @var{MASK} is @code{.TRUE.} are
10763 1.1 mrg considered. If the array has zero size, or all of the elements of
10764 1.1 mrg @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
10765 1.1 mrg @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
10766 1.1 mrg @var{ARRAY} is of character type.
10767 1.1 mrg
10768 1.1 mrg @item @emph{Standard}:
10769 1.1.1.2 mrg Fortran 90 and later
10770 1.1 mrg
10771 1.1 mrg @item @emph{Class}:
10772 1.1 mrg Transformational function
10773 1.1 mrg
10774 1.1 mrg @item @emph{Syntax}:
10775 1.1 mrg @multitable @columnfractions .80
10776 1.1 mrg @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
10777 1.1 mrg @item @code{RESULT = MINVAL(ARRAY [, MASK])}
10778 1.1 mrg @end multitable
10779 1.1 mrg
10780 1.1 mrg @item @emph{Arguments}:
10781 1.1 mrg @multitable @columnfractions .15 .70
10782 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
10783 1.1 mrg @code{REAL}.
10784 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar of type
10785 1.1 mrg @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10786 1.1 mrg inclusive. It may not be an optional dummy argument.
10787 1.1 mrg @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
10788 1.1 mrg and conformable with @var{ARRAY}.
10789 1.1 mrg @end multitable
10790 1.1 mrg
10791 1.1 mrg @item @emph{Return value}:
10792 1.1 mrg If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
10793 1.1 mrg is a scalar. If @var{DIM} is present, the result is an array with a
10794 1.1 mrg rank one less than the rank of @var{ARRAY}, and a size corresponding to
10795 1.1 mrg the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
10796 1.1 mrg cases, the result is of the same type and kind as @var{ARRAY}.
10797 1.1 mrg
10798 1.1 mrg @item @emph{See also}:
10799 1.1.1.2 mrg @ref{MIN}, @gol
10800 1.1.1.2 mrg @ref{MINLOC}
10801 1.1 mrg @end table
10802 1.1 mrg
10803 1.1 mrg
10804 1.1 mrg
10805 1.1 mrg @node MOD
10806 1.1 mrg @section @code{MOD} --- Remainder function
10807 1.1 mrg @fnindex MOD
10808 1.1 mrg @fnindex AMOD
10809 1.1 mrg @fnindex DMOD
10810 1.1 mrg @fnindex BMOD
10811 1.1 mrg @fnindex IMOD
10812 1.1 mrg @fnindex JMOD
10813 1.1 mrg @fnindex KMOD
10814 1.1 mrg @cindex remainder
10815 1.1 mrg @cindex division, remainder
10816 1.1 mrg
10817 1.1 mrg @table @asis
10818 1.1 mrg @item @emph{Description}:
10819 1.1 mrg @code{MOD(A,P)} computes the remainder of the division of A by P@.
10820 1.1 mrg
10821 1.1 mrg @item @emph{Standard}:
10822 1.1 mrg Fortran 77 and later, has overloads that are GNU extensions
10823 1.1 mrg
10824 1.1 mrg @item @emph{Class}:
10825 1.1 mrg Elemental function
10826 1.1 mrg
10827 1.1 mrg @item @emph{Syntax}:
10828 1.1 mrg @code{RESULT = MOD(A, P)}
10829 1.1 mrg
10830 1.1 mrg @item @emph{Arguments}:
10831 1.1 mrg @multitable @columnfractions .15 .70
10832 1.1 mrg @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
10833 1.1 mrg @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
10834 1.1.1.2 mrg and not equal to zero. (As a GNU extension, arguments of different kinds are
10835 1.1.1.2 mrg permitted.)
10836 1.1 mrg @end multitable
10837 1.1 mrg
10838 1.1 mrg @item @emph{Return value}:
10839 1.1 mrg The return value is the result of @code{A - (INT(A/P) * P)}. The type
10840 1.1 mrg and kind of the return value is the same as that of the arguments. The
10841 1.1 mrg returned value has the same sign as A and a magnitude less than the
10842 1.1.1.2 mrg magnitude of P. (As a GNU extension, kind is the largest kind of the actual
10843 1.1.1.2 mrg arguments.)
10844 1.1 mrg
10845 1.1 mrg @item @emph{Example}:
10846 1.1 mrg @smallexample
10847 1.1 mrg program test_mod
10848 1.1 mrg print *, mod(17,3)
10849 1.1 mrg print *, mod(17.5,5.5)
10850 1.1 mrg print *, mod(17.5d0,5.5)
10851 1.1 mrg print *, mod(17.5,5.5d0)
10852 1.1 mrg
10853 1.1 mrg print *, mod(-17,3)
10854 1.1 mrg print *, mod(-17.5,5.5)
10855 1.1 mrg print *, mod(-17.5d0,5.5)
10856 1.1 mrg print *, mod(-17.5,5.5d0)
10857 1.1 mrg
10858 1.1 mrg print *, mod(17,-3)
10859 1.1 mrg print *, mod(17.5,-5.5)
10860 1.1 mrg print *, mod(17.5d0,-5.5)
10861 1.1 mrg print *, mod(17.5,-5.5d0)
10862 1.1 mrg end program test_mod
10863 1.1 mrg @end smallexample
10864 1.1 mrg
10865 1.1 mrg @item @emph{Specific names}:
10866 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
10867 1.1 mrg @item Name @tab Arguments @tab Return type @tab Standard
10868 1.1.1.2 mrg @item @code{MOD(A,P)} @tab @code{INTEGER A,P} @tab @code{INTEGER} @tab Fortran 77 and later
10869 1.1.1.2 mrg @item @code{AMOD(A,P)} @tab @code{REAL(4) A,P} @tab @code{REAL(4)} @tab Fortran 77 and later
10870 1.1.1.2 mrg @item @code{DMOD(A,P)} @tab @code{REAL(8) A,P} @tab @code{REAL(8)} @tab Fortran 77 and later
10871 1.1 mrg @item @code{BMOD(A,P)} @tab @code{INTEGER(1) A,P} @tab @code{INTEGER(1)} @tab GNU extension
10872 1.1 mrg @item @code{IMOD(A,P)} @tab @code{INTEGER(2) A,P} @tab @code{INTEGER(2)} @tab GNU extension
10873 1.1 mrg @item @code{JMOD(A,P)} @tab @code{INTEGER(4) A,P} @tab @code{INTEGER(4)} @tab GNU extension
10874 1.1 mrg @item @code{KMOD(A,P)} @tab @code{INTEGER(8) A,P} @tab @code{INTEGER(8)} @tab GNU extension
10875 1.1 mrg @end multitable
10876 1.1 mrg
10877 1.1 mrg @item @emph{See also}:
10878 1.1 mrg @ref{MODULO}
10879 1.1 mrg
10880 1.1 mrg @end table
10881 1.1 mrg
10882 1.1 mrg
10883 1.1 mrg
10884 1.1 mrg @node MODULO
10885 1.1 mrg @section @code{MODULO} --- Modulo function
10886 1.1 mrg @fnindex MODULO
10887 1.1 mrg @cindex modulo
10888 1.1 mrg @cindex division, modulo
10889 1.1 mrg
10890 1.1 mrg @table @asis
10891 1.1 mrg @item @emph{Description}:
10892 1.1 mrg @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
10893 1.1 mrg
10894 1.1 mrg @item @emph{Standard}:
10895 1.1 mrg Fortran 95 and later
10896 1.1 mrg
10897 1.1 mrg @item @emph{Class}:
10898 1.1 mrg Elemental function
10899 1.1 mrg
10900 1.1 mrg @item @emph{Syntax}:
10901 1.1 mrg @code{RESULT = MODULO(A, P)}
10902 1.1 mrg
10903 1.1 mrg @item @emph{Arguments}:
10904 1.1 mrg @multitable @columnfractions .15 .70
10905 1.1 mrg @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
10906 1.1 mrg @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}.
10907 1.1.1.2 mrg It shall not be zero. (As a GNU extension, arguments of different kinds are
10908 1.1.1.2 mrg permitted.)
10909 1.1 mrg @end multitable
10910 1.1 mrg
10911 1.1 mrg @item @emph{Return value}:
10912 1.1.1.2 mrg The type and kind of the result are those of the arguments. (As a GNU
10913 1.1.1.2 mrg extension, kind is the largest kind of the actual arguments.)
10914 1.1 mrg @table @asis
10915 1.1 mrg @item If @var{A} and @var{P} are of type @code{INTEGER}:
10916 1.1 mrg @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
10917 1.1 mrg @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
10918 1.1 mrg (exclusive).
10919 1.1 mrg @item If @var{A} and @var{P} are of type @code{REAL}:
10920 1.1 mrg @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
10921 1.1 mrg @end table
10922 1.1 mrg The returned value has the same sign as P and a magnitude less than
10923 1.1 mrg the magnitude of P.
10924 1.1 mrg
10925 1.1 mrg @item @emph{Example}:
10926 1.1 mrg @smallexample
10927 1.1 mrg program test_modulo
10928 1.1 mrg print *, modulo(17,3)
10929 1.1 mrg print *, modulo(17.5,5.5)
10930 1.1 mrg
10931 1.1 mrg print *, modulo(-17,3)
10932 1.1 mrg print *, modulo(-17.5,5.5)
10933 1.1 mrg
10934 1.1 mrg print *, modulo(17,-3)
10935 1.1 mrg print *, modulo(17.5,-5.5)
10936 1.1 mrg end program
10937 1.1 mrg @end smallexample
10938 1.1 mrg
10939 1.1 mrg @item @emph{See also}:
10940 1.1 mrg @ref{MOD}
10941 1.1 mrg
10942 1.1 mrg @end table
10943 1.1 mrg
10944 1.1 mrg
10945 1.1 mrg
10946 1.1 mrg @node MOVE_ALLOC
10947 1.1 mrg @section @code{MOVE_ALLOC} --- Move allocation from one object to another
10948 1.1 mrg @fnindex MOVE_ALLOC
10949 1.1 mrg @cindex moving allocation
10950 1.1 mrg @cindex allocation, moving
10951 1.1 mrg
10952 1.1 mrg @table @asis
10953 1.1 mrg @item @emph{Description}:
10954 1.1 mrg @code{MOVE_ALLOC(FROM, TO)} moves the allocation from @var{FROM} to
10955 1.1 mrg @var{TO}. @var{FROM} will become deallocated in the process.
10956 1.1 mrg
10957 1.1 mrg @item @emph{Standard}:
10958 1.1 mrg Fortran 2003 and later
10959 1.1 mrg
10960 1.1 mrg @item @emph{Class}:
10961 1.1 mrg Pure subroutine
10962 1.1 mrg
10963 1.1 mrg @item @emph{Syntax}:
10964 1.1 mrg @code{CALL MOVE_ALLOC(FROM, TO)}
10965 1.1 mrg
10966 1.1 mrg @item @emph{Arguments}:
10967 1.1 mrg @multitable @columnfractions .15 .70
10968 1.1 mrg @item @var{FROM} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
10969 1.1 mrg of any type and kind.
10970 1.1 mrg @item @var{TO} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
10971 1.1 mrg of the same type, kind and rank as @var{FROM}.
10972 1.1 mrg @end multitable
10973 1.1 mrg
10974 1.1 mrg @item @emph{Return value}:
10975 1.1 mrg None
10976 1.1 mrg
10977 1.1 mrg @item @emph{Example}:
10978 1.1 mrg @smallexample
10979 1.1 mrg program test_move_alloc
10980 1.1 mrg integer, allocatable :: a(:), b(:)
10981 1.1 mrg
10982 1.1 mrg allocate(a(3))
10983 1.1 mrg a = [ 1, 2, 3 ]
10984 1.1 mrg call move_alloc(a, b)
10985 1.1 mrg print *, allocated(a), allocated(b)
10986 1.1 mrg print *, b
10987 1.1 mrg end program test_move_alloc
10988 1.1 mrg @end smallexample
10989 1.1 mrg @end table
10990 1.1 mrg
10991 1.1 mrg
10992 1.1 mrg
10993 1.1 mrg @node MVBITS
10994 1.1 mrg @section @code{MVBITS} --- Move bits from one integer to another
10995 1.1 mrg @fnindex MVBITS
10996 1.1 mrg @fnindex BMVBITS
10997 1.1 mrg @fnindex IMVBITS
10998 1.1 mrg @fnindex JMVBITS
10999 1.1 mrg @fnindex KMVBITS
11000 1.1 mrg @cindex bits, move
11001 1.1 mrg
11002 1.1 mrg @table @asis
11003 1.1 mrg @item @emph{Description}:
11004 1.1 mrg Moves @var{LEN} bits from positions @var{FROMPOS} through
11005 1.1 mrg @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
11006 1.1 mrg @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
11007 1.1 mrg affected by the movement of bits is unchanged. The values of
11008 1.1 mrg @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
11009 1.1 mrg @code{BIT_SIZE(FROM)}.
11010 1.1 mrg
11011 1.1 mrg @item @emph{Standard}:
11012 1.1.1.2 mrg Fortran 90 and later, has overloads that are GNU extensions
11013 1.1 mrg
11014 1.1 mrg @item @emph{Class}:
11015 1.1 mrg Elemental subroutine
11016 1.1 mrg
11017 1.1 mrg @item @emph{Syntax}:
11018 1.1 mrg @code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
11019 1.1 mrg
11020 1.1 mrg @item @emph{Arguments}:
11021 1.1 mrg @multitable @columnfractions .15 .70
11022 1.1 mrg @item @var{FROM} @tab The type shall be @code{INTEGER}.
11023 1.1 mrg @item @var{FROMPOS} @tab The type shall be @code{INTEGER}.
11024 1.1 mrg @item @var{LEN} @tab The type shall be @code{INTEGER}.
11025 1.1 mrg @item @var{TO} @tab The type shall be @code{INTEGER}, of the
11026 1.1 mrg same kind as @var{FROM}.
11027 1.1 mrg @item @var{TOPOS} @tab The type shall be @code{INTEGER}.
11028 1.1 mrg @end multitable
11029 1.1 mrg
11030 1.1 mrg @item @emph{Specific names}:
11031 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
11032 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
11033 1.1.1.2 mrg @item @code{MVBITS(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
11034 1.1 mrg @item @code{BMVBITS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
11035 1.1 mrg @item @code{IMVBITS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
11036 1.1 mrg @item @code{JMVBITS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
11037 1.1 mrg @item @code{KMVBITS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
11038 1.1 mrg @end multitable
11039 1.1 mrg
11040 1.1 mrg @item @emph{See also}:
11041 1.1.1.2 mrg @ref{IBCLR}, @gol
11042 1.1.1.2 mrg @ref{IBSET}, @gol
11043 1.1.1.2 mrg @ref{IBITS}, @gol
11044 1.1.1.2 mrg @ref{IAND}, @gol
11045 1.1.1.2 mrg @ref{IOR}, @gol
11046 1.1.1.2 mrg @ref{IEOR}
11047 1.1 mrg @end table
11048 1.1 mrg
11049 1.1 mrg
11050 1.1 mrg
11051 1.1 mrg @node NEAREST
11052 1.1 mrg @section @code{NEAREST} --- Nearest representable number
11053 1.1 mrg @fnindex NEAREST
11054 1.1 mrg @cindex real number, nearest different
11055 1.1 mrg @cindex floating point, nearest different
11056 1.1 mrg
11057 1.1 mrg @table @asis
11058 1.1 mrg @item @emph{Description}:
11059 1.1 mrg @code{NEAREST(X, S)} returns the processor-representable number nearest
11060 1.1 mrg to @code{X} in the direction indicated by the sign of @code{S}.
11061 1.1 mrg
11062 1.1 mrg @item @emph{Standard}:
11063 1.1.1.2 mrg Fortran 90 and later
11064 1.1 mrg
11065 1.1 mrg @item @emph{Class}:
11066 1.1 mrg Elemental function
11067 1.1 mrg
11068 1.1 mrg @item @emph{Syntax}:
11069 1.1 mrg @code{RESULT = NEAREST(X, S)}
11070 1.1 mrg
11071 1.1 mrg @item @emph{Arguments}:
11072 1.1 mrg @multitable @columnfractions .15 .70
11073 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}.
11074 1.1 mrg @item @var{S} @tab Shall be of type @code{REAL} and
11075 1.1 mrg not equal to zero.
11076 1.1 mrg @end multitable
11077 1.1 mrg
11078 1.1 mrg @item @emph{Return value}:
11079 1.1 mrg The return value is of the same type as @code{X}. If @code{S} is
11080 1.1 mrg positive, @code{NEAREST} returns the processor-representable number
11081 1.1 mrg greater than @code{X} and nearest to it. If @code{S} is negative,
11082 1.1 mrg @code{NEAREST} returns the processor-representable number smaller than
11083 1.1 mrg @code{X} and nearest to it.
11084 1.1 mrg
11085 1.1 mrg @item @emph{Example}:
11086 1.1 mrg @smallexample
11087 1.1 mrg program test_nearest
11088 1.1 mrg real :: x, y
11089 1.1 mrg x = nearest(42.0, 1.0)
11090 1.1 mrg y = nearest(42.0, -1.0)
11091 1.1 mrg write (*,"(3(G20.15))") x, y, x - y
11092 1.1 mrg end program test_nearest
11093 1.1 mrg @end smallexample
11094 1.1 mrg @end table
11095 1.1 mrg
11096 1.1 mrg
11097 1.1 mrg
11098 1.1 mrg @node NEW_LINE
11099 1.1 mrg @section @code{NEW_LINE} --- New line character
11100 1.1 mrg @fnindex NEW_LINE
11101 1.1 mrg @cindex newline
11102 1.1 mrg @cindex output, newline
11103 1.1 mrg
11104 1.1 mrg @table @asis
11105 1.1 mrg @item @emph{Description}:
11106 1.1 mrg @code{NEW_LINE(C)} returns the new-line character.
11107 1.1 mrg
11108 1.1 mrg @item @emph{Standard}:
11109 1.1 mrg Fortran 2003 and later
11110 1.1 mrg
11111 1.1 mrg @item @emph{Class}:
11112 1.1 mrg Inquiry function
11113 1.1 mrg
11114 1.1 mrg @item @emph{Syntax}:
11115 1.1 mrg @code{RESULT = NEW_LINE(C)}
11116 1.1 mrg
11117 1.1 mrg @item @emph{Arguments}:
11118 1.1 mrg @multitable @columnfractions .15 .70
11119 1.1 mrg @item @var{C} @tab The argument shall be a scalar or array of the
11120 1.1 mrg type @code{CHARACTER}.
11121 1.1 mrg @end multitable
11122 1.1 mrg
11123 1.1 mrg @item @emph{Return value}:
11124 1.1 mrg Returns a @var{CHARACTER} scalar of length one with the new-line character of
11125 1.1 mrg the same kind as parameter @var{C}.
11126 1.1 mrg
11127 1.1 mrg @item @emph{Example}:
11128 1.1 mrg @smallexample
11129 1.1 mrg program newline
11130 1.1 mrg implicit none
11131 1.1 mrg write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
11132 1.1 mrg end program newline
11133 1.1 mrg @end smallexample
11134 1.1 mrg @end table
11135 1.1 mrg
11136 1.1 mrg
11137 1.1 mrg
11138 1.1 mrg @node NINT
11139 1.1 mrg @section @code{NINT} --- Nearest whole number
11140 1.1 mrg @fnindex NINT
11141 1.1 mrg @fnindex IDNINT
11142 1.1 mrg @cindex rounding, nearest whole number
11143 1.1 mrg
11144 1.1 mrg @table @asis
11145 1.1 mrg @item @emph{Description}:
11146 1.1 mrg @code{NINT(A)} rounds its argument to the nearest whole number.
11147 1.1 mrg
11148 1.1 mrg @item @emph{Standard}:
11149 1.1 mrg Fortran 77 and later, with @var{KIND} argument Fortran 90 and later
11150 1.1 mrg
11151 1.1 mrg @item @emph{Class}:
11152 1.1 mrg Elemental function
11153 1.1 mrg
11154 1.1 mrg @item @emph{Syntax}:
11155 1.1 mrg @code{RESULT = NINT(A [, KIND])}
11156 1.1 mrg
11157 1.1 mrg @item @emph{Arguments}:
11158 1.1 mrg @multitable @columnfractions .15 .70
11159 1.1 mrg @item @var{A} @tab The type of the argument shall be @code{REAL}.
11160 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
11161 1.1 mrg expression indicating the kind parameter of the result.
11162 1.1 mrg @end multitable
11163 1.1 mrg
11164 1.1 mrg @item @emph{Return value}:
11165 1.1 mrg Returns @var{A} with the fractional portion of its magnitude eliminated by
11166 1.1 mrg rounding to the nearest whole number and with its sign preserved,
11167 1.1 mrg converted to an @code{INTEGER} of the default kind.
11168 1.1 mrg
11169 1.1 mrg @item @emph{Example}:
11170 1.1 mrg @smallexample
11171 1.1 mrg program test_nint
11172 1.1 mrg real(4) x4
11173 1.1 mrg real(8) x8
11174 1.1 mrg x4 = 1.234E0_4
11175 1.1 mrg x8 = 4.321_8
11176 1.1 mrg print *, nint(x4), idnint(x8)
11177 1.1 mrg end program test_nint
11178 1.1 mrg @end smallexample
11179 1.1 mrg
11180 1.1 mrg @item @emph{Specific names}:
11181 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
11182 1.1 mrg @item Name @tab Argument @tab Return Type @tab Standard
11183 1.1.1.2 mrg @item @code{NINT(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later
11184 1.1.1.2 mrg @item @code{IDNINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab Fortran 77 and later
11185 1.1 mrg @end multitable
11186 1.1 mrg
11187 1.1 mrg @item @emph{See also}:
11188 1.1.1.2 mrg @ref{CEILING}, @gol
11189 1.1.1.2 mrg @ref{FLOOR}
11190 1.1 mrg @end table
11191 1.1 mrg
11192 1.1 mrg
11193 1.1 mrg
11194 1.1 mrg @node NORM2
11195 1.1 mrg @section @code{NORM2} --- Euclidean vector norms
11196 1.1 mrg @fnindex NORM2
11197 1.1 mrg @cindex Euclidean vector norm
11198 1.1 mrg @cindex L2 vector norm
11199 1.1 mrg @cindex norm, Euclidean
11200 1.1 mrg
11201 1.1 mrg @table @asis
11202 1.1 mrg @item @emph{Description}:
11203 1.1 mrg Calculates the Euclidean vector norm (@math{L_2} norm) of
11204 1.1 mrg of @var{ARRAY} along dimension @var{DIM}.
11205 1.1 mrg
11206 1.1 mrg @item @emph{Standard}:
11207 1.1 mrg Fortran 2008 and later
11208 1.1 mrg
11209 1.1 mrg @item @emph{Class}:
11210 1.1 mrg Transformational function
11211 1.1 mrg
11212 1.1 mrg @item @emph{Syntax}:
11213 1.1 mrg @multitable @columnfractions .80
11214 1.1 mrg @item @code{RESULT = NORM2(ARRAY[, DIM])}
11215 1.1 mrg @end multitable
11216 1.1 mrg
11217 1.1 mrg @item @emph{Arguments}:
11218 1.1 mrg @multitable @columnfractions .15 .70
11219 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{REAL}
11220 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type
11221 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n
11222 1.1 mrg equals the rank of @var{ARRAY}.
11223 1.1 mrg @end multitable
11224 1.1 mrg
11225 1.1 mrg @item @emph{Return value}:
11226 1.1 mrg The result is of the same type as @var{ARRAY}.
11227 1.1 mrg
11228 1.1 mrg If @var{DIM} is absent, a scalar with the square root of the sum of all
11229 1.1 mrg elements in @var{ARRAY} squared is returned. Otherwise, an array of
11230 1.1 mrg rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY}, and a
11231 1.1 mrg shape similar to that of @var{ARRAY} with dimension @var{DIM} dropped
11232 1.1 mrg is returned.
11233 1.1 mrg
11234 1.1 mrg @item @emph{Example}:
11235 1.1 mrg @smallexample
11236 1.1 mrg PROGRAM test_sum
11237 1.1 mrg REAL :: x(5) = [ real :: 1, 2, 3, 4, 5 ]
11238 1.1 mrg print *, NORM2(x) ! = sqrt(55.) ~ 7.416
11239 1.1 mrg END PROGRAM
11240 1.1 mrg @end smallexample
11241 1.1 mrg @end table
11242 1.1 mrg
11243 1.1 mrg
11244 1.1 mrg
11245 1.1 mrg @node NOT
11246 1.1 mrg @section @code{NOT} --- Logical negation
11247 1.1 mrg @fnindex NOT
11248 1.1 mrg @fnindex BNOT
11249 1.1 mrg @fnindex INOT
11250 1.1 mrg @fnindex JNOT
11251 1.1 mrg @fnindex KNOT
11252 1.1 mrg @cindex bits, negate
11253 1.1 mrg @cindex bitwise logical not
11254 1.1 mrg @cindex logical not, bitwise
11255 1.1 mrg
11256 1.1 mrg @table @asis
11257 1.1 mrg @item @emph{Description}:
11258 1.1 mrg @code{NOT} returns the bitwise Boolean inverse of @var{I}.
11259 1.1 mrg
11260 1.1 mrg @item @emph{Standard}:
11261 1.1.1.2 mrg Fortran 90 and later, has overloads that are GNU extensions
11262 1.1 mrg
11263 1.1 mrg @item @emph{Class}:
11264 1.1 mrg Elemental function
11265 1.1 mrg
11266 1.1 mrg @item @emph{Syntax}:
11267 1.1 mrg @code{RESULT = NOT(I)}
11268 1.1 mrg
11269 1.1 mrg @item @emph{Arguments}:
11270 1.1 mrg @multitable @columnfractions .15 .70
11271 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
11272 1.1 mrg @end multitable
11273 1.1 mrg
11274 1.1 mrg @item @emph{Return value}:
11275 1.1 mrg The return type is @code{INTEGER}, of the same kind as the
11276 1.1 mrg argument.
11277 1.1 mrg
11278 1.1 mrg @item @emph{Specific names}:
11279 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
11280 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
11281 1.1 mrg @item @code{NOT(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
11282 1.1 mrg @item @code{BNOT(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
11283 1.1 mrg @item @code{INOT(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
11284 1.1 mrg @item @code{JNOT(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
11285 1.1 mrg @item @code{KNOT(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
11286 1.1 mrg @end multitable
11287 1.1 mrg
11288 1.1 mrg @item @emph{See also}:
11289 1.1.1.2 mrg @ref{IAND}, @gol
11290 1.1.1.2 mrg @ref{IEOR}, @gol
11291 1.1.1.2 mrg @ref{IOR}, @gol
11292 1.1.1.2 mrg @ref{IBITS}, @gol
11293 1.1.1.2 mrg @ref{IBSET}, @gol
11294 1.1.1.2 mrg @ref{IBCLR}
11295 1.1 mrg @end table
11296 1.1 mrg
11297 1.1 mrg
11298 1.1 mrg
11299 1.1 mrg @node NULL
11300 1.1 mrg @section @code{NULL} --- Function that returns an disassociated pointer
11301 1.1 mrg @fnindex NULL
11302 1.1 mrg @cindex pointer, status
11303 1.1 mrg @cindex pointer, disassociated
11304 1.1 mrg
11305 1.1 mrg @table @asis
11306 1.1 mrg @item @emph{Description}:
11307 1.1 mrg Returns a disassociated pointer.
11308 1.1 mrg
11309 1.1 mrg If @var{MOLD} is present, a disassociated pointer of the same type is
11310 1.1 mrg returned, otherwise the type is determined by context.
11311 1.1 mrg
11312 1.1 mrg In Fortran 95, @var{MOLD} is optional. Please note that Fortran 2003
11313 1.1 mrg includes cases where it is required.
11314 1.1 mrg
11315 1.1 mrg @item @emph{Standard}:
11316 1.1 mrg Fortran 95 and later
11317 1.1 mrg
11318 1.1 mrg @item @emph{Class}:
11319 1.1 mrg Transformational function
11320 1.1 mrg
11321 1.1 mrg @item @emph{Syntax}:
11322 1.1 mrg @code{PTR => NULL([MOLD])}
11323 1.1 mrg
11324 1.1 mrg @item @emph{Arguments}:
11325 1.1 mrg @multitable @columnfractions .15 .70
11326 1.1 mrg @item @var{MOLD} @tab (Optional) shall be a pointer of any association
11327 1.1 mrg status and of any type.
11328 1.1 mrg @end multitable
11329 1.1 mrg
11330 1.1 mrg @item @emph{Return value}:
11331 1.1 mrg A disassociated pointer.
11332 1.1 mrg
11333 1.1 mrg @item @emph{Example}:
11334 1.1 mrg @smallexample
11335 1.1 mrg REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
11336 1.1 mrg @end smallexample
11337 1.1 mrg
11338 1.1 mrg @item @emph{See also}:
11339 1.1 mrg @ref{ASSOCIATED}
11340 1.1 mrg @end table
11341 1.1 mrg
11342 1.1 mrg
11343 1.1 mrg
11344 1.1 mrg @node NUM_IMAGES
11345 1.1 mrg @section @code{NUM_IMAGES} --- Function that returns the number of images
11346 1.1 mrg @fnindex NUM_IMAGES
11347 1.1 mrg @cindex coarray, @code{NUM_IMAGES}
11348 1.1 mrg @cindex images, number of
11349 1.1 mrg
11350 1.1 mrg @table @asis
11351 1.1 mrg @item @emph{Description}:
11352 1.1 mrg Returns the number of images.
11353 1.1 mrg
11354 1.1 mrg @item @emph{Standard}:
11355 1.1 mrg Fortran 2008 and later. With @var{DISTANCE} or @var{FAILED} argument,
11356 1.1 mrg Technical Specification (TS) 18508 or later
11357 1.1 mrg
11358 1.1 mrg
11359 1.1 mrg @item @emph{Class}:
11360 1.1 mrg Transformational function
11361 1.1 mrg
11362 1.1 mrg @item @emph{Syntax}:
11363 1.1 mrg @code{RESULT = NUM_IMAGES(DISTANCE, FAILED)}
11364 1.1 mrg
11365 1.1 mrg @item @emph{Arguments}:
11366 1.1 mrg @multitable @columnfractions .15 .70
11367 1.1 mrg @item @var{DISTANCE} @tab (optional, intent(in)) Nonnegative scalar integer
11368 1.1 mrg @item @var{FAILED} @tab (optional, intent(in)) Scalar logical expression
11369 1.1 mrg @end multitable
11370 1.1 mrg
11371 1.1 mrg @item @emph{Return value}:
11372 1.1 mrg Scalar default-kind integer. If @var{DISTANCE} is not present or has value 0,
11373 1.1 mrg the number of images in the current team is returned. For values smaller or
11374 1.1 mrg equal distance to the initial team, it returns the number of images index
11375 1.1 mrg on the ancestor team which has a distance of @var{DISTANCE} from the invoking
11376 1.1 mrg team. If @var{DISTANCE} is larger than the distance to the initial team, the
11377 1.1 mrg number of images of the initial team is returned. If @var{FAILED} is not present
11378 1.1 mrg the total number of images is returned; if it has the value @code{.TRUE.},
11379 1.1 mrg the number of failed images is returned, otherwise, the number of images which
11380 1.1 mrg do have not the failed status.
11381 1.1 mrg
11382 1.1 mrg @item @emph{Example}:
11383 1.1 mrg @smallexample
11384 1.1 mrg INTEGER :: value[*]
11385 1.1 mrg INTEGER :: i
11386 1.1 mrg value = THIS_IMAGE()
11387 1.1 mrg SYNC ALL
11388 1.1 mrg IF (THIS_IMAGE() == 1) THEN
11389 1.1 mrg DO i = 1, NUM_IMAGES()
11390 1.1 mrg WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
11391 1.1 mrg END DO
11392 1.1 mrg END IF
11393 1.1 mrg @end smallexample
11394 1.1 mrg
11395 1.1 mrg @item @emph{See also}:
11396 1.1.1.2 mrg @ref{THIS_IMAGE}, @gol
11397 1.1.1.2 mrg @ref{IMAGE_INDEX}
11398 1.1 mrg @end table
11399 1.1 mrg
11400 1.1 mrg
11401 1.1 mrg
11402 1.1 mrg @node OR
11403 1.1 mrg @section @code{OR} --- Bitwise logical OR
11404 1.1 mrg @fnindex OR
11405 1.1 mrg @cindex bitwise logical or
11406 1.1 mrg @cindex logical or, bitwise
11407 1.1 mrg
11408 1.1 mrg @table @asis
11409 1.1 mrg @item @emph{Description}:
11410 1.1 mrg Bitwise logical @code{OR}.
11411 1.1 mrg
11412 1.1 mrg This intrinsic routine is provided for backwards compatibility with
11413 1.1 mrg GNU Fortran 77. For integer arguments, programmers should consider
11414 1.1 mrg the use of the @ref{IOR} intrinsic defined by the Fortran standard.
11415 1.1 mrg
11416 1.1 mrg @item @emph{Standard}:
11417 1.1 mrg GNU extension
11418 1.1 mrg
11419 1.1 mrg @item @emph{Class}:
11420 1.1 mrg Function
11421 1.1 mrg
11422 1.1 mrg @item @emph{Syntax}:
11423 1.1 mrg @code{RESULT = OR(I, J)}
11424 1.1 mrg
11425 1.1 mrg @item @emph{Arguments}:
11426 1.1 mrg @multitable @columnfractions .15 .70
11427 1.1 mrg @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
11428 1.1 mrg type or a scalar @code{LOGICAL} type or a boz-literal-constant.
11429 1.1 mrg @item @var{J} @tab The type shall be the same as the type of @var{I} or
11430 1.1 mrg a boz-literal-constant. @var{I} and @var{J} shall not both be
11431 1.1 mrg boz-literal-constants. If either @var{I} and @var{J} is a
11432 1.1 mrg boz-literal-constant, then the other argument must be a scalar @code{INTEGER}.
11433 1.1 mrg @end multitable
11434 1.1 mrg
11435 1.1 mrg @item @emph{Return value}:
11436 1.1 mrg The return type is either a scalar @code{INTEGER} or a scalar
11437 1.1 mrg @code{LOGICAL}. If the kind type parameters differ, then the
11438 1.1 mrg smaller kind type is implicitly converted to larger kind, and the
11439 1.1 mrg return has the larger kind. A boz-literal-constant is
11440 1.1 mrg converted to an @code{INTEGER} with the kind type parameter of
11441 1.1 mrg the other argument as-if a call to @ref{INT} occurred.
11442 1.1 mrg
11443 1.1 mrg @item @emph{Example}:
11444 1.1 mrg @smallexample
11445 1.1 mrg PROGRAM test_or
11446 1.1 mrg LOGICAL :: T = .TRUE., F = .FALSE.
11447 1.1 mrg INTEGER :: a, b
11448 1.1 mrg DATA a / Z'F' /, b / Z'3' /
11449 1.1 mrg
11450 1.1 mrg WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
11451 1.1 mrg WRITE (*,*) OR(a, b)
11452 1.1 mrg END PROGRAM
11453 1.1 mrg @end smallexample
11454 1.1 mrg
11455 1.1 mrg @item @emph{See also}:
11456 1.1.1.2 mrg Fortran 95 elemental function: @gol
11457 1.1.1.2 mrg @ref{IOR}
11458 1.1 mrg @end table
11459 1.1 mrg
11460 1.1 mrg
11461 1.1 mrg
11462 1.1 mrg @node PACK
11463 1.1 mrg @section @code{PACK} --- Pack an array into an array of rank one
11464 1.1 mrg @fnindex PACK
11465 1.1 mrg @cindex array, packing
11466 1.1 mrg @cindex array, reduce dimension
11467 1.1 mrg @cindex array, gather elements
11468 1.1 mrg
11469 1.1 mrg @table @asis
11470 1.1 mrg @item @emph{Description}:
11471 1.1 mrg Stores the elements of @var{ARRAY} in an array of rank one.
11472 1.1 mrg
11473 1.1 mrg The beginning of the resulting array is made up of elements whose @var{MASK}
11474 1.1 mrg equals @code{TRUE}. Afterwards, positions are filled with elements taken from
11475 1.1 mrg @var{VECTOR}.
11476 1.1 mrg
11477 1.1 mrg @item @emph{Standard}:
11478 1.1.1.2 mrg Fortran 90 and later
11479 1.1 mrg
11480 1.1 mrg @item @emph{Class}:
11481 1.1 mrg Transformational function
11482 1.1 mrg
11483 1.1 mrg @item @emph{Syntax}:
11484 1.1 mrg @code{RESULT = PACK(ARRAY, MASK[,VECTOR])}
11485 1.1 mrg
11486 1.1 mrg @item @emph{Arguments}:
11487 1.1 mrg @multitable @columnfractions .15 .70
11488 1.1 mrg @item @var{ARRAY} @tab Shall be an array of any type.
11489 1.1 mrg @item @var{MASK} @tab Shall be an array of type @code{LOGICAL} and
11490 1.1 mrg of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL}
11491 1.1 mrg scalar.
11492 1.1 mrg @item @var{VECTOR} @tab (Optional) shall be an array of the same type
11493 1.1 mrg as @var{ARRAY} and of rank one. If present, the number of elements in
11494 1.1 mrg @var{VECTOR} shall be equal to or greater than the number of true elements
11495 1.1 mrg in @var{MASK}. If @var{MASK} is scalar, the number of elements in
11496 1.1 mrg @var{VECTOR} shall be equal to or greater than the number of elements in
11497 1.1 mrg @var{ARRAY}.
11498 1.1 mrg @end multitable
11499 1.1 mrg
11500 1.1 mrg @item @emph{Return value}:
11501 1.1 mrg The result is an array of rank one and the same type as that of @var{ARRAY}.
11502 1.1 mrg If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
11503 1.1 mrg number of @code{TRUE} values in @var{MASK} otherwise.
11504 1.1 mrg
11505 1.1 mrg @item @emph{Example}:
11506 1.1 mrg Gathering nonzero elements from an array:
11507 1.1 mrg @smallexample
11508 1.1 mrg PROGRAM test_pack_1
11509 1.1 mrg INTEGER :: m(6)
11510 1.1 mrg m = (/ 1, 0, 0, 0, 5, 0 /)
11511 1.1 mrg WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0) ! "1 5"
11512 1.1 mrg END PROGRAM
11513 1.1 mrg @end smallexample
11514 1.1 mrg
11515 1.1 mrg Gathering nonzero elements from an array and appending elements from @var{VECTOR}:
11516 1.1 mrg @smallexample
11517 1.1 mrg PROGRAM test_pack_2
11518 1.1 mrg INTEGER :: m(4)
11519 1.1 mrg m = (/ 1, 0, 0, 2 /)
11520 1.1.1.2 mrg ! The following results in "1 2 3 4"
11521 1.1.1.2 mrg WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /))
11522 1.1 mrg END PROGRAM
11523 1.1 mrg @end smallexample
11524 1.1 mrg
11525 1.1 mrg @item @emph{See also}:
11526 1.1 mrg @ref{UNPACK}
11527 1.1 mrg @end table
11528 1.1 mrg
11529 1.1 mrg
11530 1.1 mrg
11531 1.1 mrg @node PARITY
11532 1.1 mrg @section @code{PARITY} --- Reduction with exclusive OR
11533 1.1 mrg @fnindex PARITY
11534 1.1 mrg @cindex Parity
11535 1.1 mrg @cindex Reduction, XOR
11536 1.1 mrg @cindex XOR reduction
11537 1.1 mrg
11538 1.1 mrg @table @asis
11539 1.1 mrg @item @emph{Description}:
11540 1.1 mrg Calculates the parity, i.e. the reduction using @code{.XOR.},
11541 1.1 mrg of @var{MASK} along dimension @var{DIM}.
11542 1.1 mrg
11543 1.1 mrg @item @emph{Standard}:
11544 1.1 mrg Fortran 2008 and later
11545 1.1 mrg
11546 1.1 mrg @item @emph{Class}:
11547 1.1 mrg Transformational function
11548 1.1 mrg
11549 1.1 mrg @item @emph{Syntax}:
11550 1.1 mrg @multitable @columnfractions .80
11551 1.1 mrg @item @code{RESULT = PARITY(MASK[, DIM])}
11552 1.1 mrg @end multitable
11553 1.1 mrg
11554 1.1 mrg @item @emph{Arguments}:
11555 1.1 mrg @multitable @columnfractions .15 .70
11556 1.1 mrg @item @var{LOGICAL} @tab Shall be an array of type @code{LOGICAL}
11557 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type
11558 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n
11559 1.1 mrg equals the rank of @var{MASK}.
11560 1.1 mrg @end multitable
11561 1.1 mrg
11562 1.1 mrg @item @emph{Return value}:
11563 1.1 mrg The result is of the same type as @var{MASK}.
11564 1.1 mrg
11565 1.1 mrg If @var{DIM} is absent, a scalar with the parity of all elements in
11566 1.1 mrg @var{MASK} is returned, i.e. true if an odd number of elements is
11567 1.1 mrg @code{.true.} and false otherwise. If @var{DIM} is present, an array
11568 1.1 mrg of rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY},
11569 1.1 mrg and a shape similar to that of @var{MASK} with dimension @var{DIM}
11570 1.1 mrg dropped is returned.
11571 1.1 mrg
11572 1.1 mrg @item @emph{Example}:
11573 1.1 mrg @smallexample
11574 1.1 mrg PROGRAM test_sum
11575 1.1 mrg LOGICAL :: x(2) = [ .true., .false. ]
11576 1.1 mrg print *, PARITY(x) ! prints "T" (true).
11577 1.1 mrg END PROGRAM
11578 1.1 mrg @end smallexample
11579 1.1 mrg @end table
11580 1.1 mrg
11581 1.1 mrg
11582 1.1 mrg
11583 1.1 mrg @node PERROR
11584 1.1 mrg @section @code{PERROR} --- Print system error message
11585 1.1 mrg @fnindex PERROR
11586 1.1 mrg @cindex system, error handling
11587 1.1 mrg
11588 1.1 mrg @table @asis
11589 1.1 mrg @item @emph{Description}:
11590 1.1 mrg Prints (on the C @code{stderr} stream) a newline-terminated error
11591 1.1 mrg message corresponding to the last system error. This is prefixed by
11592 1.1 mrg @var{STRING}, a colon and a space. See @code{perror(3)}.
11593 1.1 mrg
11594 1.1 mrg @item @emph{Standard}:
11595 1.1 mrg GNU extension
11596 1.1 mrg
11597 1.1 mrg @item @emph{Class}:
11598 1.1 mrg Subroutine
11599 1.1 mrg
11600 1.1 mrg @item @emph{Syntax}:
11601 1.1 mrg @code{CALL PERROR(STRING)}
11602 1.1 mrg
11603 1.1 mrg @item @emph{Arguments}:
11604 1.1 mrg @multitable @columnfractions .15 .70
11605 1.1 mrg @item @var{STRING} @tab A scalar of type @code{CHARACTER} and of the
11606 1.1 mrg default kind.
11607 1.1 mrg @end multitable
11608 1.1 mrg
11609 1.1 mrg @item @emph{See also}:
11610 1.1 mrg @ref{IERRNO}
11611 1.1 mrg @end table
11612 1.1 mrg
11613 1.1 mrg
11614 1.1 mrg
11615 1.1 mrg @node POPCNT
11616 1.1 mrg @section @code{POPCNT} --- Number of bits set
11617 1.1 mrg @fnindex POPCNT
11618 1.1 mrg @cindex binary representation
11619 1.1 mrg @cindex bits set
11620 1.1 mrg
11621 1.1 mrg @table @asis
11622 1.1 mrg @item @emph{Description}:
11623 1.1 mrg @code{POPCNT(I)} returns the number of bits set ('1' bits) in the binary
11624 1.1 mrg representation of @code{I}.
11625 1.1 mrg
11626 1.1 mrg @item @emph{Standard}:
11627 1.1 mrg Fortran 2008 and later
11628 1.1 mrg
11629 1.1 mrg @item @emph{Class}:
11630 1.1 mrg Elemental function
11631 1.1 mrg
11632 1.1 mrg @item @emph{Syntax}:
11633 1.1 mrg @code{RESULT = POPCNT(I)}
11634 1.1 mrg
11635 1.1 mrg @item @emph{Arguments}:
11636 1.1 mrg @multitable @columnfractions .15 .70
11637 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}.
11638 1.1 mrg @end multitable
11639 1.1 mrg
11640 1.1 mrg @item @emph{Return value}:
11641 1.1 mrg The return value is of type @code{INTEGER} and of the default integer
11642 1.1 mrg kind.
11643 1.1 mrg
11644 1.1 mrg @item @emph{Example}:
11645 1.1 mrg @smallexample
11646 1.1 mrg program test_population
11647 1.1 mrg print *, popcnt(127), poppar(127)
11648 1.1 mrg print *, popcnt(huge(0_4)), poppar(huge(0_4))
11649 1.1 mrg print *, popcnt(huge(0_8)), poppar(huge(0_8))
11650 1.1 mrg end program test_population
11651 1.1 mrg @end smallexample
11652 1.1.1.2 mrg @item @emph{See also}:
11653 1.1.1.2 mrg @ref{POPPAR}, @gol
11654 1.1.1.2 mrg @ref{LEADZ}, @gol
11655 1.1.1.2 mrg @ref{TRAILZ}
11656 1.1 mrg @end table
11657 1.1 mrg
11658 1.1 mrg
11659 1.1.1.2 mrg
11660 1.1 mrg @node POPPAR
11661 1.1 mrg @section @code{POPPAR} --- Parity of the number of bits set
11662 1.1 mrg @fnindex POPPAR
11663 1.1 mrg @cindex binary representation
11664 1.1 mrg @cindex parity
11665 1.1 mrg
11666 1.1 mrg @table @asis
11667 1.1 mrg @item @emph{Description}:
11668 1.1 mrg @code{POPPAR(I)} returns parity of the integer @code{I}, i.e. the parity
11669 1.1 mrg of the number of bits set ('1' bits) in the binary representation of
11670 1.1 mrg @code{I}. It is equal to 0 if @code{I} has an even number of bits set,
11671 1.1 mrg and 1 for an odd number of '1' bits.
11672 1.1 mrg
11673 1.1 mrg @item @emph{Standard}:
11674 1.1 mrg Fortran 2008 and later
11675 1.1 mrg
11676 1.1 mrg @item @emph{Class}:
11677 1.1 mrg Elemental function
11678 1.1 mrg
11679 1.1 mrg @item @emph{Syntax}:
11680 1.1 mrg @code{RESULT = POPPAR(I)}
11681 1.1 mrg
11682 1.1 mrg @item @emph{Arguments}:
11683 1.1 mrg @multitable @columnfractions .15 .70
11684 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}.
11685 1.1 mrg @end multitable
11686 1.1 mrg
11687 1.1 mrg @item @emph{Return value}:
11688 1.1 mrg The return value is of type @code{INTEGER} and of the default integer
11689 1.1 mrg kind.
11690 1.1 mrg
11691 1.1 mrg @item @emph{Example}:
11692 1.1 mrg @smallexample
11693 1.1 mrg program test_population
11694 1.1 mrg print *, popcnt(127), poppar(127)
11695 1.1 mrg print *, popcnt(huge(0_4)), poppar(huge(0_4))
11696 1.1 mrg print *, popcnt(huge(0_8)), poppar(huge(0_8))
11697 1.1 mrg end program test_population
11698 1.1 mrg @end smallexample
11699 1.1.1.2 mrg @item @emph{See also}:
11700 1.1.1.2 mrg @ref{POPCNT}, @gol
11701 1.1.1.2 mrg @ref{LEADZ}, @gol
11702 1.1.1.2 mrg @ref{TRAILZ}
11703 1.1 mrg @end table
11704 1.1 mrg
11705 1.1 mrg
11706 1.1 mrg
11707 1.1 mrg @node PRECISION
11708 1.1 mrg @section @code{PRECISION} --- Decimal precision of a real kind
11709 1.1 mrg @fnindex PRECISION
11710 1.1 mrg @cindex model representation, precision
11711 1.1 mrg
11712 1.1 mrg @table @asis
11713 1.1 mrg @item @emph{Description}:
11714 1.1 mrg @code{PRECISION(X)} returns the decimal precision in the model of the
11715 1.1 mrg type of @code{X}.
11716 1.1 mrg
11717 1.1 mrg @item @emph{Standard}:
11718 1.1.1.2 mrg Fortran 90 and later
11719 1.1 mrg
11720 1.1 mrg @item @emph{Class}:
11721 1.1 mrg Inquiry function
11722 1.1 mrg
11723 1.1 mrg @item @emph{Syntax}:
11724 1.1 mrg @code{RESULT = PRECISION(X)}
11725 1.1 mrg
11726 1.1 mrg @item @emph{Arguments}:
11727 1.1 mrg @multitable @columnfractions .15 .70
11728 1.1.1.2 mrg @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}. It may
11729 1.1.1.2 mrg be scalar or valued.
11730 1.1 mrg @end multitable
11731 1.1 mrg
11732 1.1 mrg @item @emph{Return value}:
11733 1.1 mrg The return value is of type @code{INTEGER} and of the default integer
11734 1.1 mrg kind.
11735 1.1 mrg
11736 1.1 mrg @item @emph{Example}:
11737 1.1 mrg @smallexample
11738 1.1 mrg program prec_and_range
11739 1.1 mrg real(kind=4) :: x(2)
11740 1.1 mrg complex(kind=8) :: y
11741 1.1 mrg
11742 1.1 mrg print *, precision(x), range(x)
11743 1.1 mrg print *, precision(y), range(y)
11744 1.1 mrg end program prec_and_range
11745 1.1 mrg @end smallexample
11746 1.1.1.2 mrg @item @emph{See also}:
11747 1.1.1.2 mrg @ref{SELECTED_REAL_KIND}, @gol
11748 1.1.1.2 mrg @ref{RANGE}
11749 1.1 mrg @end table
11750 1.1 mrg
11751 1.1 mrg
11752 1.1 mrg
11753 1.1 mrg @node PRESENT
11754 1.1 mrg @section @code{PRESENT} --- Determine whether an optional dummy argument is specified
11755 1.1 mrg @fnindex PRESENT
11756 1.1 mrg
11757 1.1 mrg @table @asis
11758 1.1 mrg @item @emph{Description}:
11759 1.1 mrg Determines whether an optional dummy argument is present.
11760 1.1 mrg
11761 1.1 mrg @item @emph{Standard}:
11762 1.1.1.2 mrg Fortran 90 and later
11763 1.1 mrg
11764 1.1 mrg @item @emph{Class}:
11765 1.1 mrg Inquiry function
11766 1.1 mrg
11767 1.1 mrg @item @emph{Syntax}:
11768 1.1 mrg @code{RESULT = PRESENT(A)}
11769 1.1 mrg
11770 1.1 mrg @item @emph{Arguments}:
11771 1.1 mrg @multitable @columnfractions .15 .70
11772 1.1 mrg @item @var{A} @tab May be of any type and may be a pointer, scalar or array
11773 1.1 mrg value, or a dummy procedure. It shall be the name of an optional dummy argument
11774 1.1 mrg accessible within the current subroutine or function.
11775 1.1 mrg @end multitable
11776 1.1 mrg
11777 1.1 mrg @item @emph{Return value}:
11778 1.1 mrg Returns either @code{TRUE} if the optional argument @var{A} is present, or
11779 1.1 mrg @code{FALSE} otherwise.
11780 1.1 mrg
11781 1.1 mrg @item @emph{Example}:
11782 1.1 mrg @smallexample
11783 1.1 mrg PROGRAM test_present
11784 1.1 mrg WRITE(*,*) f(), f(42) ! "F T"
11785 1.1 mrg CONTAINS
11786 1.1 mrg LOGICAL FUNCTION f(x)
11787 1.1 mrg INTEGER, INTENT(IN), OPTIONAL :: x
11788 1.1 mrg f = PRESENT(x)
11789 1.1 mrg END FUNCTION
11790 1.1 mrg END PROGRAM
11791 1.1 mrg @end smallexample
11792 1.1 mrg @end table
11793 1.1 mrg
11794 1.1 mrg
11795 1.1 mrg
11796 1.1 mrg @node PRODUCT
11797 1.1 mrg @section @code{PRODUCT} --- Product of array elements
11798 1.1 mrg @fnindex PRODUCT
11799 1.1 mrg @cindex array, product
11800 1.1 mrg @cindex array, multiply elements
11801 1.1 mrg @cindex array, conditionally multiply elements
11802 1.1 mrg @cindex multiply array elements
11803 1.1 mrg
11804 1.1 mrg @table @asis
11805 1.1 mrg @item @emph{Description}:
11806 1.1 mrg Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
11807 1.1 mrg the corresponding element in @var{MASK} is @code{TRUE}.
11808 1.1 mrg
11809 1.1 mrg @item @emph{Standard}:
11810 1.1.1.2 mrg Fortran 90 and later
11811 1.1 mrg
11812 1.1 mrg @item @emph{Class}:
11813 1.1 mrg Transformational function
11814 1.1 mrg
11815 1.1 mrg @item @emph{Syntax}:
11816 1.1 mrg @multitable @columnfractions .80
11817 1.1 mrg @item @code{RESULT = PRODUCT(ARRAY[, MASK])}
11818 1.1 mrg @item @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
11819 1.1 mrg @end multitable
11820 1.1 mrg
11821 1.1 mrg @item @emph{Arguments}:
11822 1.1 mrg @multitable @columnfractions .15 .70
11823 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
11824 1.1 mrg @code{REAL} or @code{COMPLEX}.
11825 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type
11826 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n
11827 1.1 mrg equals the rank of @var{ARRAY}.
11828 1.1 mrg @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
11829 1.1 mrg and either be a scalar or an array of the same shape as @var{ARRAY}.
11830 1.1 mrg @end multitable
11831 1.1 mrg
11832 1.1 mrg @item @emph{Return value}:
11833 1.1 mrg The result is of the same type as @var{ARRAY}.
11834 1.1 mrg
11835 1.1 mrg If @var{DIM} is absent, a scalar with the product of all elements in
11836 1.1 mrg @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
11837 1.1 mrg the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
11838 1.1 mrg dimension @var{DIM} dropped is returned.
11839 1.1 mrg
11840 1.1 mrg
11841 1.1 mrg @item @emph{Example}:
11842 1.1 mrg @smallexample
11843 1.1 mrg PROGRAM test_product
11844 1.1 mrg INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
11845 1.1 mrg print *, PRODUCT(x) ! all elements, product = 120
11846 1.1 mrg print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
11847 1.1 mrg END PROGRAM
11848 1.1 mrg @end smallexample
11849 1.1 mrg
11850 1.1 mrg @item @emph{See also}:
11851 1.1 mrg @ref{SUM}
11852 1.1 mrg @end table
11853 1.1 mrg
11854 1.1 mrg
11855 1.1 mrg
11856 1.1 mrg @node RADIX
11857 1.1 mrg @section @code{RADIX} --- Base of a model number
11858 1.1 mrg @fnindex RADIX
11859 1.1 mrg @cindex model representation, base
11860 1.1 mrg @cindex model representation, radix
11861 1.1 mrg
11862 1.1 mrg @table @asis
11863 1.1 mrg @item @emph{Description}:
11864 1.1 mrg @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
11865 1.1 mrg
11866 1.1 mrg @item @emph{Standard}:
11867 1.1.1.2 mrg Fortran 90 and later
11868 1.1 mrg
11869 1.1 mrg @item @emph{Class}:
11870 1.1 mrg Inquiry function
11871 1.1 mrg
11872 1.1 mrg @item @emph{Syntax}:
11873 1.1 mrg @code{RESULT = RADIX(X)}
11874 1.1 mrg
11875 1.1 mrg @item @emph{Arguments}:
11876 1.1 mrg @multitable @columnfractions .15 .70
11877 1.1 mrg @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
11878 1.1 mrg @end multitable
11879 1.1 mrg
11880 1.1 mrg @item @emph{Return value}:
11881 1.1 mrg The return value is a scalar of type @code{INTEGER} and of the default
11882 1.1 mrg integer kind.
11883 1.1 mrg
11884 1.1 mrg @item @emph{Example}:
11885 1.1 mrg @smallexample
11886 1.1 mrg program test_radix
11887 1.1 mrg print *, "The radix for the default integer kind is", radix(0)
11888 1.1 mrg print *, "The radix for the default real kind is", radix(0.0)
11889 1.1 mrg end program test_radix
11890 1.1 mrg @end smallexample
11891 1.1.1.2 mrg @item @emph{See also}:
11892 1.1.1.2 mrg @ref{SELECTED_REAL_KIND}
11893 1.1 mrg @end table
11894 1.1 mrg
11895 1.1 mrg
11896 1.1 mrg
11897 1.1 mrg @node RAN
11898 1.1 mrg @section @code{RAN} --- Real pseudo-random number
11899 1.1 mrg @fnindex RAN
11900 1.1 mrg @cindex random number generation
11901 1.1 mrg
11902 1.1 mrg @table @asis
11903 1.1 mrg @item @emph{Description}:
11904 1.1 mrg For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
11905 1.1 mrg provided as an alias for @code{RAND}. See @ref{RAND} for complete
11906 1.1 mrg documentation.
11907 1.1 mrg
11908 1.1 mrg @item @emph{Standard}:
11909 1.1 mrg GNU extension
11910 1.1 mrg
11911 1.1 mrg @item @emph{Class}:
11912 1.1 mrg Function
11913 1.1 mrg
11914 1.1 mrg @item @emph{See also}:
11915 1.1.1.2 mrg @ref{RAND}, @gol
11916 1.1.1.2 mrg @ref{RANDOM_NUMBER}
11917 1.1 mrg @end table
11918 1.1 mrg
11919 1.1 mrg
11920 1.1 mrg
11921 1.1 mrg @node RAND
11922 1.1 mrg @section @code{RAND} --- Real pseudo-random number
11923 1.1 mrg @fnindex RAND
11924 1.1 mrg @cindex random number generation
11925 1.1 mrg
11926 1.1 mrg @table @asis
11927 1.1 mrg @item @emph{Description}:
11928 1.1 mrg @code{RAND(FLAG)} returns a pseudo-random number from a uniform
11929 1.1 mrg distribution between 0 and 1. If @var{FLAG} is 0, the next number
11930 1.1 mrg in the current sequence is returned; if @var{FLAG} is 1, the generator
11931 1.1 mrg is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
11932 1.1 mrg it is used as a new seed with @code{SRAND}.
11933 1.1 mrg
11934 1.1 mrg This intrinsic routine is provided for backwards compatibility with
11935 1.1 mrg GNU Fortran 77. It implements a simple modulo generator as provided
11936 1.1 mrg by @command{g77}. For new code, one should consider the use of
11937 1.1 mrg @ref{RANDOM_NUMBER} as it implements a superior algorithm.
11938 1.1 mrg
11939 1.1 mrg @item @emph{Standard}:
11940 1.1 mrg GNU extension
11941 1.1 mrg
11942 1.1 mrg @item @emph{Class}:
11943 1.1 mrg Function
11944 1.1 mrg
11945 1.1 mrg @item @emph{Syntax}:
11946 1.1 mrg @code{RESULT = RAND(I)}
11947 1.1 mrg
11948 1.1 mrg @item @emph{Arguments}:
11949 1.1 mrg @multitable @columnfractions .15 .70
11950 1.1 mrg @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
11951 1.1 mrg @end multitable
11952 1.1 mrg
11953 1.1 mrg @item @emph{Return value}:
11954 1.1 mrg The return value is of @code{REAL} type and the default kind.
11955 1.1 mrg
11956 1.1 mrg @item @emph{Example}:
11957 1.1 mrg @smallexample
11958 1.1 mrg program test_rand
11959 1.1 mrg integer,parameter :: seed = 86456
11960 1.1 mrg
11961 1.1 mrg call srand(seed)
11962 1.1 mrg print *, rand(), rand(), rand(), rand()
11963 1.1 mrg print *, rand(seed), rand(), rand(), rand()
11964 1.1 mrg end program test_rand
11965 1.1 mrg @end smallexample
11966 1.1 mrg
11967 1.1 mrg @item @emph{See also}:
11968 1.1.1.2 mrg @ref{SRAND}, @gol
11969 1.1.1.2 mrg @ref{RANDOM_NUMBER}
11970 1.1 mrg
11971 1.1 mrg @end table
11972 1.1 mrg
11973 1.1 mrg
11974 1.1 mrg @node RANDOM_INIT
11975 1.1 mrg @section @code{RANDOM_INIT} --- Initialize a pseudo-random number generator
11976 1.1 mrg @fnindex RANDOM_INIT
11977 1.1 mrg @cindex random number generation, initialization
11978 1.1 mrg
11979 1.1 mrg @table @asis
11980 1.1 mrg @item @emph{Description}:
11981 1.1 mrg Initializes the state of the pseudorandom number generator used by
11982 1.1 mrg @code{RANDOM_NUMBER}.
11983 1.1 mrg
11984 1.1 mrg @item @emph{Standard}:
11985 1.1 mrg Fortran 2018
11986 1.1 mrg
11987 1.1 mrg @item @emph{Class}:
11988 1.1 mrg Subroutine
11989 1.1 mrg
11990 1.1 mrg @item @emph{Syntax}:
11991 1.1 mrg @code{CALL RANDOM_INIT(REPEATABLE, IMAGE_DISTINCT)}
11992 1.1 mrg
11993 1.1 mrg @item @emph{Arguments}:
11994 1.1.1.2 mrg @multitable @columnfractions .25 .70
11995 1.1 mrg @item @var{REPEATABLE} @tab Shall be a scalar with a @code{LOGICAL} type,
11996 1.1 mrg and it is @code{INTENT(IN)}. If it is @code{.true.}, the seed is set to
11997 1.1 mrg a processor-dependent value that is the same each time @code{RANDOM_INIT}
11998 1.1 mrg is called from the same image. The term ``same image'' means a single
11999 1.1 mrg instance of program execution. The sequence of random numbers is different
12000 1.1 mrg for repeated execution of the program. If it is @code{.false.}, the seed
12001 1.1 mrg is set to a processor-dependent value.
12002 1.1 mrg @item @var{IMAGE_DISTINCT} @tab Shall be a scalar with a
12003 1.1 mrg @code{LOGICAL} type, and it is @code{INTENT(IN)}. If it is @code{.true.},
12004 1.1 mrg the seed is set to a processor-dependent value that is distinct from th
12005 1.1 mrg seed set by a call to @code{RANDOM_INIT} in another image. If it is
12006 1.1 mrg @code{.false.}, the seed is set value that does depend which image called
12007 1.1 mrg @code{RANDOM_INIT}.
12008 1.1 mrg @end multitable
12009 1.1 mrg
12010 1.1 mrg @item @emph{Example}:
12011 1.1 mrg @smallexample
12012 1.1 mrg program test_random_seed
12013 1.1 mrg implicit none
12014 1.1 mrg real x(3), y(3)
12015 1.1 mrg call random_init(.true., .true.)
12016 1.1 mrg call random_number(x)
12017 1.1 mrg call random_init(.true., .true.)
12018 1.1 mrg call random_number(y)
12019 1.1 mrg ! x and y are the same sequence
12020 1.1 mrg if (any(x /= y)) call abort
12021 1.1 mrg end program test_random_seed
12022 1.1 mrg @end smallexample
12023 1.1 mrg
12024 1.1 mrg @item @emph{See also}:
12025 1.1.1.2 mrg @ref{RANDOM_NUMBER}, @gol
12026 1.1.1.2 mrg @ref{RANDOM_SEED}
12027 1.1 mrg @end table
12028 1.1 mrg
12029 1.1 mrg
12030 1.1 mrg @node RANDOM_NUMBER
12031 1.1 mrg @section @code{RANDOM_NUMBER} --- Pseudo-random number
12032 1.1 mrg @fnindex RANDOM_NUMBER
12033 1.1 mrg @cindex random number generation
12034 1.1 mrg
12035 1.1 mrg @table @asis
12036 1.1 mrg @item @emph{Description}:
12037 1.1 mrg Returns a single pseudorandom number or an array of pseudorandom numbers
12038 1.1 mrg from the uniform distribution over the range @math{ 0 \leq x < 1}.
12039 1.1 mrg
12040 1.1.1.2 mrg The runtime-library implements the xoshiro256** pseudorandom number
12041 1.1.1.2 mrg generator (PRNG). This generator has a period of @math{2^{256} - 1},
12042 1.1.1.2 mrg and when using multiple threads up to @math{2^{128}} threads can each
12043 1.1.1.2 mrg generate @math{2^{128}} random numbers before any aliasing occurs.
12044 1.1 mrg
12045 1.1 mrg Note that in a multi-threaded program (e.g. using OpenMP directives),
12046 1.1 mrg each thread will have its own random number state. For details of the
12047 1.1 mrg seeding procedure, see the documentation for the @code{RANDOM_SEED}
12048 1.1 mrg intrinsic.
12049 1.1 mrg
12050 1.1 mrg
12051 1.1 mrg @item @emph{Standard}:
12052 1.1.1.2 mrg Fortran 90 and later
12053 1.1 mrg
12054 1.1 mrg @item @emph{Class}:
12055 1.1 mrg Subroutine
12056 1.1 mrg
12057 1.1 mrg @item @emph{Syntax}:
12058 1.1 mrg @code{RANDOM_NUMBER(HARVEST)}
12059 1.1 mrg
12060 1.1 mrg @item @emph{Arguments}:
12061 1.1 mrg @multitable @columnfractions .15 .70
12062 1.1 mrg @item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL}.
12063 1.1 mrg @end multitable
12064 1.1 mrg
12065 1.1 mrg @item @emph{Example}:
12066 1.1 mrg @smallexample
12067 1.1 mrg program test_random_number
12068 1.1 mrg REAL :: r(5,5)
12069 1.1 mrg CALL RANDOM_NUMBER(r)
12070 1.1 mrg end program
12071 1.1 mrg @end smallexample
12072 1.1 mrg
12073 1.1 mrg @item @emph{See also}:
12074 1.1.1.2 mrg @ref{RANDOM_SEED}, @gol
12075 1.1.1.2 mrg @ref{RANDOM_INIT}
12076 1.1 mrg @end table
12077 1.1 mrg
12078 1.1 mrg
12079 1.1 mrg
12080 1.1 mrg @node RANDOM_SEED
12081 1.1 mrg @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
12082 1.1 mrg @fnindex RANDOM_SEED
12083 1.1 mrg @cindex random number generation, seeding
12084 1.1 mrg @cindex seeding a random number generator
12085 1.1 mrg
12086 1.1 mrg @table @asis
12087 1.1 mrg @item @emph{Description}:
12088 1.1 mrg Restarts or queries the state of the pseudorandom number generator used by
12089 1.1 mrg @code{RANDOM_NUMBER}.
12090 1.1 mrg
12091 1.1 mrg If @code{RANDOM_SEED} is called without arguments, it is seeded with
12092 1.1 mrg random data retrieved from the operating system.
12093 1.1 mrg
12094 1.1 mrg As an extension to the Fortran standard, the GFortran
12095 1.1 mrg @code{RANDOM_NUMBER} supports multiple threads. Each thread in a
12096 1.1 mrg multi-threaded program has its own seed. When @code{RANDOM_SEED} is
12097 1.1 mrg called either without arguments or with the @var{PUT} argument, the
12098 1.1 mrg given seed is copied into a master seed as well as the seed of the
12099 1.1 mrg current thread. When a new thread uses @code{RANDOM_NUMBER} for the
12100 1.1 mrg first time, the seed is copied from the master seed, and forwarded
12101 1.1.1.2 mrg @math{N * 2^{128}} steps to guarantee that the random stream does not
12102 1.1 mrg alias any other stream in the system, where @var{N} is the number of
12103 1.1 mrg threads that have used @code{RANDOM_NUMBER} so far during the program
12104 1.1 mrg execution.
12105 1.1 mrg
12106 1.1 mrg @item @emph{Standard}:
12107 1.1.1.2 mrg Fortran 90 and later
12108 1.1 mrg
12109 1.1 mrg @item @emph{Class}:
12110 1.1 mrg Subroutine
12111 1.1 mrg
12112 1.1 mrg @item @emph{Syntax}:
12113 1.1 mrg @code{CALL RANDOM_SEED([SIZE, PUT, GET])}
12114 1.1 mrg
12115 1.1 mrg @item @emph{Arguments}:
12116 1.1 mrg @multitable @columnfractions .15 .70
12117 1.1 mrg @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default
12118 1.1 mrg @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size
12119 1.1 mrg of the arrays used with the @var{PUT} and @var{GET} arguments.
12120 1.1 mrg @item @var{PUT} @tab (Optional) Shall be an array of type default
12121 1.1 mrg @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of
12122 1.1 mrg the array must be larger than or equal to the number returned by the
12123 1.1 mrg @var{SIZE} argument.
12124 1.1 mrg @item @var{GET} @tab (Optional) Shall be an array of type default
12125 1.1 mrg @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size
12126 1.1 mrg of the array must be larger than or equal to the number returned by
12127 1.1 mrg the @var{SIZE} argument.
12128 1.1 mrg @end multitable
12129 1.1 mrg
12130 1.1 mrg @item @emph{Example}:
12131 1.1 mrg @smallexample
12132 1.1 mrg program test_random_seed
12133 1.1 mrg implicit none
12134 1.1 mrg integer, allocatable :: seed(:)
12135 1.1 mrg integer :: n
12136 1.1 mrg
12137 1.1 mrg call random_seed(size = n)
12138 1.1 mrg allocate(seed(n))
12139 1.1 mrg call random_seed(get=seed)
12140 1.1 mrg write (*, *) seed
12141 1.1 mrg end program test_random_seed
12142 1.1 mrg @end smallexample
12143 1.1 mrg
12144 1.1 mrg @item @emph{See also}:
12145 1.1.1.2 mrg @ref{RANDOM_NUMBER}, @gol
12146 1.1.1.2 mrg @ref{RANDOM_INIT}
12147 1.1 mrg @end table
12148 1.1 mrg
12149 1.1 mrg
12150 1.1 mrg
12151 1.1 mrg @node RANGE
12152 1.1 mrg @section @code{RANGE} --- Decimal exponent range
12153 1.1 mrg @fnindex RANGE
12154 1.1 mrg @cindex model representation, range
12155 1.1 mrg
12156 1.1 mrg @table @asis
12157 1.1 mrg @item @emph{Description}:
12158 1.1 mrg @code{RANGE(X)} returns the decimal exponent range in the model of the
12159 1.1 mrg type of @code{X}.
12160 1.1 mrg
12161 1.1 mrg @item @emph{Standard}:
12162 1.1.1.2 mrg Fortran 90 and later
12163 1.1 mrg
12164 1.1 mrg @item @emph{Class}:
12165 1.1 mrg Inquiry function
12166 1.1 mrg
12167 1.1 mrg @item @emph{Syntax}:
12168 1.1 mrg @code{RESULT = RANGE(X)}
12169 1.1 mrg
12170 1.1 mrg @item @emph{Arguments}:
12171 1.1 mrg @multitable @columnfractions .15 .70
12172 1.1 mrg @item @var{X} @tab Shall be of type @code{INTEGER}, @code{REAL}
12173 1.1 mrg or @code{COMPLEX}.
12174 1.1 mrg @end multitable
12175 1.1 mrg
12176 1.1 mrg @item @emph{Return value}:
12177 1.1 mrg The return value is of type @code{INTEGER} and of the default integer
12178 1.1 mrg kind.
12179 1.1 mrg
12180 1.1 mrg @item @emph{Example}:
12181 1.1 mrg See @code{PRECISION} for an example.
12182 1.1.1.2 mrg @item @emph{See also}:
12183 1.1.1.2 mrg @ref{SELECTED_REAL_KIND}, @gol
12184 1.1.1.2 mrg @ref{PRECISION}
12185 1.1 mrg @end table
12186 1.1 mrg
12187 1.1 mrg
12188 1.1 mrg
12189 1.1 mrg @node RANK
12190 1.1 mrg @section @code{RANK} --- Rank of a data object
12191 1.1 mrg @fnindex RANK
12192 1.1 mrg @cindex rank
12193 1.1 mrg
12194 1.1 mrg @table @asis
12195 1.1 mrg @item @emph{Description}:
12196 1.1 mrg @code{RANK(A)} returns the rank of a scalar or array data object.
12197 1.1 mrg
12198 1.1 mrg @item @emph{Standard}:
12199 1.1 mrg Technical Specification (TS) 29113
12200 1.1 mrg
12201 1.1 mrg @item @emph{Class}:
12202 1.1 mrg Inquiry function
12203 1.1 mrg
12204 1.1 mrg @item @emph{Syntax}:
12205 1.1 mrg @code{RESULT = RANK(A)}
12206 1.1 mrg
12207 1.1 mrg @item @emph{Arguments}:
12208 1.1 mrg @multitable @columnfractions .15 .70
12209 1.1 mrg @item @var{A} @tab can be of any type
12210 1.1 mrg @end multitable
12211 1.1 mrg
12212 1.1 mrg @item @emph{Return value}:
12213 1.1 mrg The return value is of type @code{INTEGER} and of the default integer
12214 1.1 mrg kind. For arrays, their rank is returned; for scalars zero is returned.
12215 1.1 mrg
12216 1.1 mrg @item @emph{Example}:
12217 1.1 mrg @smallexample
12218 1.1 mrg program test_rank
12219 1.1 mrg integer :: a
12220 1.1 mrg real, allocatable :: b(:,:)
12221 1.1 mrg
12222 1.1 mrg print *, rank(a), rank(b) ! Prints: 0 2
12223 1.1 mrg end program test_rank
12224 1.1 mrg @end smallexample
12225 1.1 mrg
12226 1.1 mrg @end table
12227 1.1 mrg
12228 1.1 mrg
12229 1.1 mrg
12230 1.1 mrg @node REAL
12231 1.1 mrg @section @code{REAL} --- Convert to real type
12232 1.1 mrg @fnindex REAL
12233 1.1 mrg @fnindex REALPART
12234 1.1 mrg @fnindex FLOAT
12235 1.1 mrg @fnindex DFLOAT
12236 1.1 mrg @fnindex FLOATI
12237 1.1 mrg @fnindex FLOATJ
12238 1.1 mrg @fnindex FLOATK
12239 1.1 mrg @fnindex SNGL
12240 1.1 mrg @cindex conversion, to real
12241 1.1 mrg @cindex complex numbers, real part
12242 1.1 mrg
12243 1.1 mrg @table @asis
12244 1.1 mrg @item @emph{Description}:
12245 1.1 mrg @code{REAL(A [, KIND])} converts its argument @var{A} to a real type. The
12246 1.1 mrg @code{REALPART} function is provided for compatibility with @command{g77},
12247 1.1 mrg and its use is strongly discouraged.
12248 1.1 mrg
12249 1.1 mrg @item @emph{Standard}:
12250 1.1.1.2 mrg Fortran 77 and later, with @var{KIND} argument Fortran 90 and later, has GNU extensions
12251 1.1 mrg
12252 1.1 mrg @item @emph{Class}:
12253 1.1 mrg Elemental function
12254 1.1 mrg
12255 1.1 mrg @item @emph{Syntax}:
12256 1.1 mrg @multitable @columnfractions .80
12257 1.1 mrg @item @code{RESULT = REAL(A [, KIND])}
12258 1.1 mrg @item @code{RESULT = REALPART(Z)}
12259 1.1 mrg @end multitable
12260 1.1 mrg
12261 1.1 mrg @item @emph{Arguments}:
12262 1.1 mrg @multitable @columnfractions .15 .70
12263 1.1 mrg @item @var{A} @tab Shall be @code{INTEGER}, @code{REAL}, or
12264 1.1 mrg @code{COMPLEX}.
12265 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
12266 1.1 mrg expression indicating the kind parameter of the result.
12267 1.1 mrg @end multitable
12268 1.1 mrg
12269 1.1 mrg @item @emph{Return value}:
12270 1.1 mrg These functions return a @code{REAL} variable or array under
12271 1.1 mrg the following rules:
12272 1.1 mrg
12273 1.1 mrg @table @asis
12274 1.1 mrg @item (A)
12275 1.1 mrg @code{REAL(A)} is converted to a default real type if @var{A} is an
12276 1.1 mrg integer or real variable.
12277 1.1 mrg @item (B)
12278 1.1 mrg @code{REAL(A)} is converted to a real type with the kind type parameter
12279 1.1 mrg of @var{A} if @var{A} is a complex variable.
12280 1.1 mrg @item (C)
12281 1.1 mrg @code{REAL(A, KIND)} is converted to a real type with kind type
12282 1.1 mrg parameter @var{KIND} if @var{A} is a complex, integer, or real
12283 1.1 mrg variable.
12284 1.1 mrg @end table
12285 1.1 mrg
12286 1.1 mrg @item @emph{Example}:
12287 1.1 mrg @smallexample
12288 1.1 mrg program test_real
12289 1.1 mrg complex :: x = (1.0, 2.0)
12290 1.1 mrg print *, real(x), real(x,8), realpart(x)
12291 1.1 mrg end program test_real
12292 1.1 mrg @end smallexample
12293 1.1 mrg
12294 1.1 mrg @item @emph{Specific names}:
12295 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
12296 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
12297 1.1.1.2 mrg @item @code{FLOAT(A)} @tab @code{INTEGER(4)} @tab @code{REAL(4)} @tab GNU extension
12298 1.1 mrg @item @code{DFLOAT(A)} @tab @code{INTEGER(4)} @tab @code{REAL(8)} @tab GNU extension
12299 1.1 mrg @item @code{FLOATI(A)} @tab @code{INTEGER(2)} @tab @code{REAL(4)} @tab GNU extension
12300 1.1 mrg @item @code{FLOATJ(A)} @tab @code{INTEGER(4)} @tab @code{REAL(4)} @tab GNU extension
12301 1.1 mrg @item @code{FLOATK(A)} @tab @code{INTEGER(8)} @tab @code{REAL(4)} @tab GNU extension
12302 1.1.1.2 mrg @item @code{SNGL(A)} @tab @code{INTEGER(8)} @tab @code{REAL(4)} @tab GNU extension
12303 1.1 mrg @end multitable
12304 1.1 mrg
12305 1.1 mrg
12306 1.1 mrg @item @emph{See also}:
12307 1.1 mrg @ref{DBLE}
12308 1.1 mrg
12309 1.1 mrg @end table
12310 1.1 mrg
12311 1.1 mrg
12312 1.1 mrg
12313 1.1 mrg @node RENAME
12314 1.1 mrg @section @code{RENAME} --- Rename a file
12315 1.1 mrg @fnindex RENAME
12316 1.1 mrg @cindex file system, rename file
12317 1.1 mrg
12318 1.1 mrg @table @asis
12319 1.1 mrg @item @emph{Description}:
12320 1.1 mrg Renames a file from file @var{PATH1} to @var{PATH2}. A null
12321 1.1 mrg character (@code{CHAR(0)}) can be used to mark the end of the names in
12322 1.1 mrg @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
12323 1.1 mrg names are ignored. If the @var{STATUS} argument is supplied, it
12324 1.1 mrg contains 0 on success or a nonzero error code upon return; see
12325 1.1 mrg @code{rename(2)}.
12326 1.1 mrg
12327 1.1 mrg This intrinsic is provided in both subroutine and function forms;
12328 1.1 mrg however, only one form can be used in any given program unit.
12329 1.1 mrg
12330 1.1 mrg @item @emph{Standard}:
12331 1.1 mrg GNU extension
12332 1.1 mrg
12333 1.1 mrg @item @emph{Class}:
12334 1.1 mrg Subroutine, function
12335 1.1 mrg
12336 1.1 mrg @item @emph{Syntax}:
12337 1.1 mrg @multitable @columnfractions .80
12338 1.1 mrg @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
12339 1.1 mrg @item @code{STATUS = RENAME(PATH1, PATH2)}
12340 1.1 mrg @end multitable
12341 1.1 mrg
12342 1.1 mrg @item @emph{Arguments}:
12343 1.1 mrg @multitable @columnfractions .15 .70
12344 1.1 mrg @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
12345 1.1 mrg @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
12346 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
12347 1.1 mrg @end multitable
12348 1.1 mrg
12349 1.1 mrg @item @emph{See also}:
12350 1.1 mrg @ref{LINK}
12351 1.1 mrg
12352 1.1 mrg @end table
12353 1.1 mrg
12354 1.1 mrg
12355 1.1 mrg
12356 1.1 mrg @node REPEAT
12357 1.1 mrg @section @code{REPEAT} --- Repeated string concatenation
12358 1.1 mrg @fnindex REPEAT
12359 1.1 mrg @cindex string, repeat
12360 1.1 mrg @cindex string, concatenate
12361 1.1 mrg
12362 1.1 mrg @table @asis
12363 1.1 mrg @item @emph{Description}:
12364 1.1 mrg Concatenates @var{NCOPIES} copies of a string.
12365 1.1 mrg
12366 1.1 mrg @item @emph{Standard}:
12367 1.1.1.2 mrg Fortran 90 and later
12368 1.1 mrg
12369 1.1 mrg @item @emph{Class}:
12370 1.1 mrg Transformational function
12371 1.1 mrg
12372 1.1 mrg @item @emph{Syntax}:
12373 1.1 mrg @code{RESULT = REPEAT(STRING, NCOPIES)}
12374 1.1 mrg
12375 1.1 mrg @item @emph{Arguments}:
12376 1.1 mrg @multitable @columnfractions .15 .70
12377 1.1 mrg @item @var{STRING} @tab Shall be scalar and of type @code{CHARACTER}.
12378 1.1 mrg @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER}.
12379 1.1 mrg @end multitable
12380 1.1 mrg
12381 1.1 mrg @item @emph{Return value}:
12382 1.1 mrg A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies
12383 1.1 mrg of @var{STRING}.
12384 1.1 mrg
12385 1.1 mrg @item @emph{Example}:
12386 1.1 mrg @smallexample
12387 1.1 mrg program test_repeat
12388 1.1 mrg write(*,*) repeat("x", 5) ! "xxxxx"
12389 1.1 mrg end program
12390 1.1 mrg @end smallexample
12391 1.1 mrg @end table
12392 1.1 mrg
12393 1.1 mrg
12394 1.1 mrg
12395 1.1 mrg @node RESHAPE
12396 1.1 mrg @section @code{RESHAPE} --- Function to reshape an array
12397 1.1 mrg @fnindex RESHAPE
12398 1.1 mrg @cindex array, change dimensions
12399 1.1 mrg @cindex array, transmogrify
12400 1.1 mrg
12401 1.1 mrg @table @asis
12402 1.1 mrg @item @emph{Description}:
12403 1.1 mrg Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
12404 1.1 mrg the new array may be padded with elements from @var{PAD} or permuted
12405 1.1 mrg as defined by @var{ORDER}.
12406 1.1 mrg
12407 1.1 mrg @item @emph{Standard}:
12408 1.1.1.2 mrg Fortran 90 and later
12409 1.1 mrg
12410 1.1 mrg @item @emph{Class}:
12411 1.1 mrg Transformational function
12412 1.1 mrg
12413 1.1 mrg @item @emph{Syntax}:
12414 1.1 mrg @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
12415 1.1 mrg
12416 1.1 mrg @item @emph{Arguments}:
12417 1.1 mrg @multitable @columnfractions .15 .70
12418 1.1 mrg @item @var{SOURCE} @tab Shall be an array of any type.
12419 1.1 mrg @item @var{SHAPE} @tab Shall be of type @code{INTEGER} and an
12420 1.1 mrg array of rank one. Its values must be positive or zero.
12421 1.1 mrg @item @var{PAD} @tab (Optional) shall be an array of the same
12422 1.1 mrg type as @var{SOURCE}.
12423 1.1 mrg @item @var{ORDER} @tab (Optional) shall be of type @code{INTEGER}
12424 1.1 mrg and an array of the same shape as @var{SHAPE}. Its values shall
12425 1.1 mrg be a permutation of the numbers from 1 to n, where n is the size of
12426 1.1 mrg @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
12427 1.1 mrg be assumed.
12428 1.1 mrg @end multitable
12429 1.1 mrg
12430 1.1 mrg @item @emph{Return value}:
12431 1.1 mrg The result is an array of shape @var{SHAPE} with the same type as
12432 1.1 mrg @var{SOURCE}.
12433 1.1 mrg
12434 1.1 mrg @item @emph{Example}:
12435 1.1 mrg @smallexample
12436 1.1 mrg PROGRAM test_reshape
12437 1.1 mrg INTEGER, DIMENSION(4) :: x
12438 1.1 mrg WRITE(*,*) SHAPE(x) ! prints "4"
12439 1.1 mrg WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/))) ! prints "2 2"
12440 1.1 mrg END PROGRAM
12441 1.1 mrg @end smallexample
12442 1.1 mrg
12443 1.1 mrg @item @emph{See also}:
12444 1.1 mrg @ref{SHAPE}
12445 1.1 mrg @end table
12446 1.1 mrg
12447 1.1 mrg
12448 1.1 mrg
12449 1.1 mrg @node RRSPACING
12450 1.1 mrg @section @code{RRSPACING} --- Reciprocal of the relative spacing
12451 1.1 mrg @fnindex RRSPACING
12452 1.1 mrg @cindex real number, relative spacing
12453 1.1 mrg @cindex floating point, relative spacing
12454 1.1 mrg
12455 1.1 mrg
12456 1.1 mrg @table @asis
12457 1.1 mrg @item @emph{Description}:
12458 1.1 mrg @code{RRSPACING(X)} returns the reciprocal of the relative spacing of
12459 1.1 mrg model numbers near @var{X}.
12460 1.1 mrg
12461 1.1 mrg @item @emph{Standard}:
12462 1.1.1.2 mrg Fortran 90 and later
12463 1.1 mrg
12464 1.1 mrg @item @emph{Class}:
12465 1.1 mrg Elemental function
12466 1.1 mrg
12467 1.1 mrg @item @emph{Syntax}:
12468 1.1 mrg @code{RESULT = RRSPACING(X)}
12469 1.1 mrg
12470 1.1 mrg @item @emph{Arguments}:
12471 1.1 mrg @multitable @columnfractions .15 .70
12472 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}.
12473 1.1 mrg @end multitable
12474 1.1 mrg
12475 1.1 mrg @item @emph{Return value}:
12476 1.1 mrg The return value is of the same type and kind as @var{X}.
12477 1.1 mrg The value returned is equal to
12478 1.1 mrg @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
12479 1.1 mrg
12480 1.1 mrg @item @emph{See also}:
12481 1.1 mrg @ref{SPACING}
12482 1.1 mrg @end table
12483 1.1 mrg
12484 1.1 mrg
12485 1.1 mrg
12486 1.1 mrg @node RSHIFT
12487 1.1 mrg @section @code{RSHIFT} --- Right shift bits
12488 1.1 mrg @fnindex RSHIFT
12489 1.1 mrg @cindex bits, shift right
12490 1.1 mrg
12491 1.1 mrg @table @asis
12492 1.1 mrg @item @emph{Description}:
12493 1.1 mrg @code{RSHIFT} returns a value corresponding to @var{I} with all of the
12494 1.1 mrg bits shifted right by @var{SHIFT} places. @var{SHIFT} shall be
12495 1.1 mrg nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise
12496 1.1 mrg the result value is undefined. Bits shifted out from the right end
12497 1.1 mrg are lost. The fill is arithmetic: the bits shifted in from the left
12498 1.1 mrg end are equal to the leftmost bit, which in two's complement
12499 1.1 mrg representation is the sign bit.
12500 1.1 mrg
12501 1.1 mrg This function has been superseded by the @code{SHIFTA} intrinsic, which
12502 1.1 mrg is standard in Fortran 2008 and later.
12503 1.1 mrg
12504 1.1 mrg @item @emph{Standard}:
12505 1.1 mrg GNU extension
12506 1.1 mrg
12507 1.1 mrg @item @emph{Class}:
12508 1.1 mrg Elemental function
12509 1.1 mrg
12510 1.1 mrg @item @emph{Syntax}:
12511 1.1 mrg @code{RESULT = RSHIFT(I, SHIFT)}
12512 1.1 mrg
12513 1.1 mrg @item @emph{Arguments}:
12514 1.1 mrg @multitable @columnfractions .15 .70
12515 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
12516 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
12517 1.1 mrg @end multitable
12518 1.1 mrg
12519 1.1 mrg @item @emph{Return value}:
12520 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
12521 1.1 mrg @var{I}.
12522 1.1 mrg
12523 1.1 mrg @item @emph{See also}:
12524 1.1.1.2 mrg @ref{ISHFT}, @gol
12525 1.1.1.2 mrg @ref{ISHFTC}, @gol
12526 1.1.1.2 mrg @ref{LSHIFT}, @gol
12527 1.1.1.2 mrg @ref{SHIFTA}, @gol
12528 1.1.1.2 mrg @ref{SHIFTR}, @gol
12529 1.1 mrg @ref{SHIFTL}
12530 1.1 mrg
12531 1.1 mrg @end table
12532 1.1 mrg
12533 1.1 mrg
12534 1.1 mrg
12535 1.1 mrg @node SAME_TYPE_AS
12536 1.1 mrg @section @code{SAME_TYPE_AS} --- Query dynamic types for equality
12537 1.1 mrg @fnindex SAME_TYPE_AS
12538 1.1 mrg
12539 1.1 mrg @table @asis
12540 1.1 mrg @item @emph{Description}:
12541 1.1 mrg Query dynamic types for equality.
12542 1.1 mrg
12543 1.1 mrg @item @emph{Standard}:
12544 1.1 mrg Fortran 2003 and later
12545 1.1 mrg
12546 1.1 mrg @item @emph{Class}:
12547 1.1 mrg Inquiry function
12548 1.1 mrg
12549 1.1 mrg @item @emph{Syntax}:
12550 1.1 mrg @code{RESULT = SAME_TYPE_AS(A, B)}
12551 1.1 mrg
12552 1.1 mrg @item @emph{Arguments}:
12553 1.1 mrg @multitable @columnfractions .15 .70
12554 1.1 mrg @item @var{A} @tab Shall be an object of extensible declared type or
12555 1.1 mrg unlimited polymorphic.
12556 1.1 mrg @item @var{B} @tab Shall be an object of extensible declared type or
12557 1.1 mrg unlimited polymorphic.
12558 1.1 mrg @end multitable
12559 1.1 mrg
12560 1.1 mrg @item @emph{Return value}:
12561 1.1 mrg The return value is a scalar of type default logical. It is true if and
12562 1.1 mrg only if the dynamic type of A is the same as the dynamic type of B.
12563 1.1 mrg
12564 1.1 mrg @item @emph{See also}:
12565 1.1 mrg @ref{EXTENDS_TYPE_OF}
12566 1.1 mrg
12567 1.1 mrg @end table
12568 1.1 mrg
12569 1.1 mrg
12570 1.1 mrg
12571 1.1 mrg @node SCALE
12572 1.1 mrg @section @code{SCALE} --- Scale a real value
12573 1.1 mrg @fnindex SCALE
12574 1.1 mrg @cindex real number, scale
12575 1.1 mrg @cindex floating point, scale
12576 1.1 mrg
12577 1.1 mrg @table @asis
12578 1.1 mrg @item @emph{Description}:
12579 1.1 mrg @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
12580 1.1 mrg
12581 1.1 mrg @item @emph{Standard}:
12582 1.1.1.2 mrg Fortran 90 and later
12583 1.1 mrg
12584 1.1 mrg @item @emph{Class}:
12585 1.1 mrg Elemental function
12586 1.1 mrg
12587 1.1 mrg @item @emph{Syntax}:
12588 1.1 mrg @code{RESULT = SCALE(X, I)}
12589 1.1 mrg
12590 1.1 mrg @item @emph{Arguments}:
12591 1.1 mrg @multitable @columnfractions .15 .70
12592 1.1 mrg @item @var{X} @tab The type of the argument shall be a @code{REAL}.
12593 1.1 mrg @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
12594 1.1 mrg @end multitable
12595 1.1 mrg
12596 1.1 mrg @item @emph{Return value}:
12597 1.1 mrg The return value is of the same type and kind as @var{X}.
12598 1.1 mrg Its value is @code{X * RADIX(X)**I}.
12599 1.1 mrg
12600 1.1 mrg @item @emph{Example}:
12601 1.1 mrg @smallexample
12602 1.1 mrg program test_scale
12603 1.1 mrg real :: x = 178.1387e-4
12604 1.1 mrg integer :: i = 5
12605 1.1 mrg print *, scale(x,i), x*radix(x)**i
12606 1.1 mrg end program test_scale
12607 1.1 mrg @end smallexample
12608 1.1 mrg
12609 1.1 mrg @end table
12610 1.1 mrg
12611 1.1 mrg
12612 1.1 mrg
12613 1.1 mrg @node SCAN
12614 1.1 mrg @section @code{SCAN} --- Scan a string for the presence of a set of characters
12615 1.1 mrg @fnindex SCAN
12616 1.1 mrg @cindex string, find subset
12617 1.1 mrg
12618 1.1 mrg @table @asis
12619 1.1 mrg @item @emph{Description}:
12620 1.1 mrg Scans a @var{STRING} for any of the characters in a @var{SET}
12621 1.1 mrg of characters.
12622 1.1 mrg
12623 1.1 mrg If @var{BACK} is either absent or equals @code{FALSE}, this function
12624 1.1 mrg returns the position of the leftmost character of @var{STRING} that is
12625 1.1 mrg in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
12626 1.1 mrg is returned. If no character of @var{SET} is found in @var{STRING}, the
12627 1.1 mrg result is zero.
12628 1.1 mrg
12629 1.1 mrg @item @emph{Standard}:
12630 1.1.1.2 mrg Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later
12631 1.1 mrg
12632 1.1 mrg @item @emph{Class}:
12633 1.1 mrg Elemental function
12634 1.1 mrg
12635 1.1 mrg @item @emph{Syntax}:
12636 1.1 mrg @code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])}
12637 1.1 mrg
12638 1.1 mrg @item @emph{Arguments}:
12639 1.1 mrg @multitable @columnfractions .15 .70
12640 1.1 mrg @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
12641 1.1 mrg @item @var{SET} @tab Shall be of type @code{CHARACTER}.
12642 1.1 mrg @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
12643 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
12644 1.1 mrg expression indicating the kind parameter of the result.
12645 1.1 mrg @end multitable
12646 1.1 mrg
12647 1.1 mrg @item @emph{Return value}:
12648 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12649 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
12650 1.1 mrg
12651 1.1 mrg @item @emph{Example}:
12652 1.1 mrg @smallexample
12653 1.1 mrg PROGRAM test_scan
12654 1.1 mrg WRITE(*,*) SCAN("FORTRAN", "AO") ! 2, found 'O'
12655 1.1 mrg WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.) ! 6, found 'A'
12656 1.1 mrg WRITE(*,*) SCAN("FORTRAN", "C++") ! 0, found none
12657 1.1 mrg END PROGRAM
12658 1.1 mrg @end smallexample
12659 1.1 mrg
12660 1.1 mrg @item @emph{See also}:
12661 1.1.1.2 mrg @ref{INDEX intrinsic}, @gol
12662 1.1.1.2 mrg @ref{VERIFY}
12663 1.1 mrg @end table
12664 1.1 mrg
12665 1.1 mrg
12666 1.1 mrg
12667 1.1 mrg @node SECNDS
12668 1.1 mrg @section @code{SECNDS} --- Time function
12669 1.1 mrg @fnindex SECNDS
12670 1.1 mrg @cindex time, elapsed
12671 1.1 mrg @cindex elapsed time
12672 1.1 mrg
12673 1.1 mrg @table @asis
12674 1.1 mrg @item @emph{Description}:
12675 1.1 mrg @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
12676 1.1 mrg @var{X} is a reference time, also in seconds. If this is zero, the time in
12677 1.1 mrg seconds from midnight is returned. This function is non-standard and its
12678 1.1 mrg use is discouraged.
12679 1.1 mrg
12680 1.1 mrg @item @emph{Standard}:
12681 1.1 mrg GNU extension
12682 1.1 mrg
12683 1.1 mrg @item @emph{Class}:
12684 1.1 mrg Function
12685 1.1 mrg
12686 1.1 mrg @item @emph{Syntax}:
12687 1.1 mrg @code{RESULT = SECNDS (X)}
12688 1.1 mrg
12689 1.1 mrg @item @emph{Arguments}:
12690 1.1 mrg @multitable @columnfractions .15 .70
12691 1.1 mrg @item @var{T} @tab Shall be of type @code{REAL(4)}.
12692 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL(4)}.
12693 1.1 mrg @end multitable
12694 1.1 mrg
12695 1.1 mrg @item @emph{Return value}:
12696 1.1 mrg None
12697 1.1 mrg
12698 1.1 mrg @item @emph{Example}:
12699 1.1 mrg @smallexample
12700 1.1 mrg program test_secnds
12701 1.1 mrg integer :: i
12702 1.1 mrg real(4) :: t1, t2
12703 1.1 mrg print *, secnds (0.0) ! seconds since midnight
12704 1.1 mrg t1 = secnds (0.0) ! reference time
12705 1.1 mrg do i = 1, 10000000 ! do something
12706 1.1 mrg end do
12707 1.1 mrg t2 = secnds (t1) ! elapsed time
12708 1.1 mrg print *, "Something took ", t2, " seconds."
12709 1.1 mrg end program test_secnds
12710 1.1 mrg @end smallexample
12711 1.1 mrg @end table
12712 1.1 mrg
12713 1.1 mrg
12714 1.1 mrg
12715 1.1 mrg @node SECOND
12716 1.1 mrg @section @code{SECOND} --- CPU time function
12717 1.1 mrg @fnindex SECOND
12718 1.1 mrg @cindex time, elapsed
12719 1.1 mrg @cindex elapsed time
12720 1.1 mrg
12721 1.1 mrg @table @asis
12722 1.1 mrg @item @emph{Description}:
12723 1.1 mrg Returns a @code{REAL(4)} value representing the elapsed CPU time in
12724 1.1 mrg seconds. This provides the same functionality as the standard
12725 1.1 mrg @code{CPU_TIME} intrinsic, and is only included for backwards
12726 1.1 mrg compatibility.
12727 1.1 mrg
12728 1.1 mrg This intrinsic is provided in both subroutine and function forms;
12729 1.1 mrg however, only one form can be used in any given program unit.
12730 1.1 mrg
12731 1.1 mrg @item @emph{Standard}:
12732 1.1 mrg GNU extension
12733 1.1 mrg
12734 1.1 mrg @item @emph{Class}:
12735 1.1 mrg Subroutine, function
12736 1.1 mrg
12737 1.1 mrg @item @emph{Syntax}:
12738 1.1 mrg @multitable @columnfractions .80
12739 1.1 mrg @item @code{CALL SECOND(TIME)}
12740 1.1 mrg @item @code{TIME = SECOND()}
12741 1.1 mrg @end multitable
12742 1.1 mrg
12743 1.1 mrg @item @emph{Arguments}:
12744 1.1 mrg @multitable @columnfractions .15 .70
12745 1.1 mrg @item @var{TIME} @tab Shall be of type @code{REAL(4)}.
12746 1.1 mrg @end multitable
12747 1.1 mrg
12748 1.1 mrg @item @emph{Return value}:
12749 1.1 mrg In either syntax, @var{TIME} is set to the process's current runtime in
12750 1.1 mrg seconds.
12751 1.1 mrg
12752 1.1 mrg @item @emph{See also}:
12753 1.1 mrg @ref{CPU_TIME}
12754 1.1 mrg
12755 1.1 mrg @end table
12756 1.1 mrg
12757 1.1 mrg
12758 1.1 mrg
12759 1.1 mrg @node SELECTED_CHAR_KIND
12760 1.1 mrg @section @code{SELECTED_CHAR_KIND} --- Choose character kind
12761 1.1 mrg @fnindex SELECTED_CHAR_KIND
12762 1.1 mrg @cindex character kind
12763 1.1 mrg @cindex kind, character
12764 1.1 mrg
12765 1.1 mrg @table @asis
12766 1.1 mrg @item @emph{Description}:
12767 1.1 mrg
12768 1.1 mrg @code{SELECTED_CHAR_KIND(NAME)} returns the kind value for the character
12769 1.1 mrg set named @var{NAME}, if a character set with such a name is supported,
12770 1.1 mrg or @math{-1} otherwise. Currently, supported character sets include
12771 1.1 mrg ``ASCII'' and ``DEFAULT'', which are equivalent, and ``ISO_10646''
12772 1.1 mrg (Universal Character Set, UCS-4) which is commonly known as Unicode.
12773 1.1 mrg
12774 1.1 mrg @item @emph{Standard}:
12775 1.1 mrg Fortran 2003 and later
12776 1.1 mrg
12777 1.1 mrg @item @emph{Class}:
12778 1.1 mrg Transformational function
12779 1.1 mrg
12780 1.1 mrg @item @emph{Syntax}:
12781 1.1 mrg @code{RESULT = SELECTED_CHAR_KIND(NAME)}
12782 1.1 mrg
12783 1.1 mrg @item @emph{Arguments}:
12784 1.1 mrg @multitable @columnfractions .15 .70
12785 1.1 mrg @item @var{NAME} @tab Shall be a scalar and of the default character type.
12786 1.1 mrg @end multitable
12787 1.1 mrg
12788 1.1 mrg @item @emph{Example}:
12789 1.1 mrg @smallexample
12790 1.1 mrg program character_kind
12791 1.1 mrg use iso_fortran_env
12792 1.1 mrg implicit none
12793 1.1 mrg integer, parameter :: ascii = selected_char_kind ("ascii")
12794 1.1 mrg integer, parameter :: ucs4 = selected_char_kind ('ISO_10646')
12795 1.1 mrg
12796 1.1 mrg character(kind=ascii, len=26) :: alphabet
12797 1.1 mrg character(kind=ucs4, len=30) :: hello_world
12798 1.1 mrg
12799 1.1 mrg alphabet = ascii_"abcdefghijklmnopqrstuvwxyz"
12800 1.1 mrg hello_world = ucs4_'Hello World and Ni Hao -- ' &
12801 1.1 mrg // char (int (z'4F60'), ucs4) &
12802 1.1 mrg // char (int (z'597D'), ucs4)
12803 1.1 mrg
12804 1.1 mrg write (*,*) alphabet
12805 1.1 mrg
12806 1.1 mrg open (output_unit, encoding='UTF-8')
12807 1.1 mrg write (*,*) trim (hello_world)
12808 1.1 mrg end program character_kind
12809 1.1 mrg @end smallexample
12810 1.1 mrg @end table
12811 1.1 mrg
12812 1.1 mrg
12813 1.1 mrg
12814 1.1 mrg @node SELECTED_INT_KIND
12815 1.1 mrg @section @code{SELECTED_INT_KIND} --- Choose integer kind
12816 1.1 mrg @fnindex SELECTED_INT_KIND
12817 1.1 mrg @cindex integer kind
12818 1.1 mrg @cindex kind, integer
12819 1.1 mrg
12820 1.1 mrg @table @asis
12821 1.1 mrg @item @emph{Description}:
12822 1.1 mrg @code{SELECTED_INT_KIND(R)} return the kind value of the smallest integer
12823 1.1 mrg type that can represent all values ranging from @math{-10^R} (exclusive)
12824 1.1 mrg to @math{10^R} (exclusive). If there is no integer kind that accommodates
12825 1.1 mrg this range, @code{SELECTED_INT_KIND} returns @math{-1}.
12826 1.1 mrg
12827 1.1 mrg @item @emph{Standard}:
12828 1.1.1.2 mrg Fortran 90 and later
12829 1.1 mrg
12830 1.1 mrg @item @emph{Class}:
12831 1.1 mrg Transformational function
12832 1.1 mrg
12833 1.1 mrg @item @emph{Syntax}:
12834 1.1 mrg @code{RESULT = SELECTED_INT_KIND(R)}
12835 1.1 mrg
12836 1.1 mrg @item @emph{Arguments}:
12837 1.1 mrg @multitable @columnfractions .15 .70
12838 1.1 mrg @item @var{R} @tab Shall be a scalar and of type @code{INTEGER}.
12839 1.1 mrg @end multitable
12840 1.1 mrg
12841 1.1 mrg @item @emph{Example}:
12842 1.1 mrg @smallexample
12843 1.1 mrg program large_integers
12844 1.1 mrg integer,parameter :: k5 = selected_int_kind(5)
12845 1.1 mrg integer,parameter :: k15 = selected_int_kind(15)
12846 1.1 mrg integer(kind=k5) :: i5
12847 1.1 mrg integer(kind=k15) :: i15
12848 1.1 mrg
12849 1.1 mrg print *, huge(i5), huge(i15)
12850 1.1 mrg
12851 1.1 mrg ! The following inequalities are always true
12852 1.1 mrg print *, huge(i5) >= 10_k5**5-1
12853 1.1 mrg print *, huge(i15) >= 10_k15**15-1
12854 1.1 mrg end program large_integers
12855 1.1 mrg @end smallexample
12856 1.1 mrg @end table
12857 1.1 mrg
12858 1.1 mrg
12859 1.1 mrg
12860 1.1 mrg @node SELECTED_REAL_KIND
12861 1.1 mrg @section @code{SELECTED_REAL_KIND} --- Choose real kind
12862 1.1 mrg @fnindex SELECTED_REAL_KIND
12863 1.1 mrg @cindex real kind
12864 1.1 mrg @cindex kind, real
12865 1.1 mrg @cindex radix, real
12866 1.1 mrg
12867 1.1 mrg @table @asis
12868 1.1 mrg @item @emph{Description}:
12869 1.1 mrg @code{SELECTED_REAL_KIND(P,R)} returns the kind value of a real data type
12870 1.1 mrg with decimal precision of at least @code{P} digits, exponent range of
12871 1.1 mrg at least @code{R}, and with a radix of @code{RADIX}.
12872 1.1 mrg
12873 1.1 mrg @item @emph{Standard}:
12874 1.1.1.2 mrg Fortran 90 and later, with @code{RADIX} Fortran 2008 or later
12875 1.1 mrg
12876 1.1 mrg @item @emph{Class}:
12877 1.1 mrg Transformational function
12878 1.1 mrg
12879 1.1 mrg @item @emph{Syntax}:
12880 1.1 mrg @code{RESULT = SELECTED_REAL_KIND([P, R, RADIX])}
12881 1.1 mrg
12882 1.1 mrg @item @emph{Arguments}:
12883 1.1 mrg @multitable @columnfractions .15 .70
12884 1.1 mrg @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
12885 1.1 mrg @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
12886 1.1 mrg @item @var{RADIX} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
12887 1.1 mrg @end multitable
12888 1.1 mrg Before Fortran 2008, at least one of the arguments @var{R} or @var{P} shall
12889 1.1 mrg be present; since Fortran 2008, they are assumed to be zero if absent.
12890 1.1 mrg
12891 1.1 mrg @item @emph{Return value}:
12892 1.1 mrg
12893 1.1 mrg @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
12894 1.1 mrg a real data type with decimal precision of at least @code{P} digits, a
12895 1.1 mrg decimal exponent range of at least @code{R}, and with the requested
12896 1.1 mrg @code{RADIX}. If the @code{RADIX} parameter is absent, real kinds with
12897 1.1 mrg any radix can be returned. If more than one real data type meet the
12898 1.1 mrg criteria, the kind of the data type with the smallest decimal precision
12899 1.1 mrg is returned. If no real data type matches the criteria, the result is
12900 1.1 mrg @table @asis
12901 1.1 mrg @item -1 if the processor does not support a real data type with a
12902 1.1 mrg precision greater than or equal to @code{P}, but the @code{R} and
12903 1.1 mrg @code{RADIX} requirements can be fulfilled
12904 1.1 mrg @item -2 if the processor does not support a real type with an exponent
12905 1.1 mrg range greater than or equal to @code{R}, but @code{P} and @code{RADIX}
12906 1.1 mrg are fulfillable
12907 1.1 mrg @item -3 if @code{RADIX} but not @code{P} and @code{R} requirements
12908 1.1 mrg are fulfillable
12909 1.1 mrg @item -4 if @code{RADIX} and either @code{P} or @code{R} requirements
12910 1.1 mrg are fulfillable
12911 1.1 mrg @item -5 if there is no real type with the given @code{RADIX}
12912 1.1 mrg @end table
12913 1.1 mrg
12914 1.1 mrg @item @emph{Example}:
12915 1.1 mrg @smallexample
12916 1.1 mrg program real_kinds
12917 1.1 mrg integer,parameter :: p6 = selected_real_kind(6)
12918 1.1 mrg integer,parameter :: p10r100 = selected_real_kind(10,100)
12919 1.1 mrg integer,parameter :: r400 = selected_real_kind(r=400)
12920 1.1 mrg real(kind=p6) :: x
12921 1.1 mrg real(kind=p10r100) :: y
12922 1.1 mrg real(kind=r400) :: z
12923 1.1 mrg
12924 1.1 mrg print *, precision(x), range(x)
12925 1.1 mrg print *, precision(y), range(y)
12926 1.1 mrg print *, precision(z), range(z)
12927 1.1 mrg end program real_kinds
12928 1.1 mrg @end smallexample
12929 1.1.1.2 mrg @item @emph{See also}:
12930 1.1.1.2 mrg @ref{PRECISION}, @gol
12931 1.1.1.2 mrg @ref{RANGE}, @gol
12932 1.1.1.2 mrg @ref{RADIX}
12933 1.1 mrg @end table
12934 1.1 mrg
12935 1.1 mrg
12936 1.1 mrg
12937 1.1 mrg @node SET_EXPONENT
12938 1.1 mrg @section @code{SET_EXPONENT} --- Set the exponent of the model
12939 1.1 mrg @fnindex SET_EXPONENT
12940 1.1 mrg @cindex real number, set exponent
12941 1.1 mrg @cindex floating point, set exponent
12942 1.1 mrg
12943 1.1 mrg @table @asis
12944 1.1 mrg @item @emph{Description}:
12945 1.1 mrg @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
12946 1.1 mrg is that that of @var{X} and whose exponent part is @var{I}.
12947 1.1 mrg
12948 1.1 mrg @item @emph{Standard}:
12949 1.1.1.2 mrg Fortran 90 and later
12950 1.1 mrg
12951 1.1 mrg @item @emph{Class}:
12952 1.1 mrg Elemental function
12953 1.1 mrg
12954 1.1 mrg @item @emph{Syntax}:
12955 1.1 mrg @code{RESULT = SET_EXPONENT(X, I)}
12956 1.1 mrg
12957 1.1 mrg @item @emph{Arguments}:
12958 1.1 mrg @multitable @columnfractions .15 .70
12959 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}.
12960 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}.
12961 1.1 mrg @end multitable
12962 1.1 mrg
12963 1.1 mrg @item @emph{Return value}:
12964 1.1 mrg The return value is of the same type and kind as @var{X}.
12965 1.1 mrg The real number whose fractional part
12966 1.1 mrg is that that of @var{X} and whose exponent part if @var{I} is returned;
12967 1.1 mrg it is @code{FRACTION(X) * RADIX(X)**I}.
12968 1.1 mrg
12969 1.1 mrg @item @emph{Example}:
12970 1.1 mrg @smallexample
12971 1.1 mrg PROGRAM test_setexp
12972 1.1 mrg REAL :: x = 178.1387e-4
12973 1.1 mrg INTEGER :: i = 17
12974 1.1 mrg PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
12975 1.1 mrg END PROGRAM
12976 1.1 mrg @end smallexample
12977 1.1 mrg
12978 1.1 mrg @end table
12979 1.1 mrg
12980 1.1 mrg
12981 1.1 mrg
12982 1.1 mrg @node SHAPE
12983 1.1 mrg @section @code{SHAPE} --- Determine the shape of an array
12984 1.1 mrg @fnindex SHAPE
12985 1.1 mrg @cindex array, shape
12986 1.1 mrg
12987 1.1 mrg @table @asis
12988 1.1 mrg @item @emph{Description}:
12989 1.1 mrg Determines the shape of an array.
12990 1.1 mrg
12991 1.1 mrg @item @emph{Standard}:
12992 1.1.1.2 mrg Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later
12993 1.1 mrg
12994 1.1 mrg @item @emph{Class}:
12995 1.1 mrg Inquiry function
12996 1.1 mrg
12997 1.1 mrg @item @emph{Syntax}:
12998 1.1 mrg @code{RESULT = SHAPE(SOURCE [, KIND])}
12999 1.1 mrg
13000 1.1 mrg @item @emph{Arguments}:
13001 1.1 mrg @multitable @columnfractions .15 .70
13002 1.1 mrg @item @var{SOURCE} @tab Shall be an array or scalar of any type.
13003 1.1 mrg If @var{SOURCE} is a pointer it must be associated and allocatable
13004 1.1 mrg arrays must be allocated.
13005 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
13006 1.1 mrg expression indicating the kind parameter of the result.
13007 1.1 mrg @end multitable
13008 1.1 mrg
13009 1.1 mrg @item @emph{Return value}:
13010 1.1 mrg An @code{INTEGER} array of rank one with as many elements as @var{SOURCE}
13011 1.1 mrg has dimensions. The elements of the resulting array correspond to the extend
13012 1.1 mrg of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
13013 1.1 mrg the result is the rank one array of size zero. If @var{KIND} is absent, the
13014 1.1 mrg return value has the default integer kind otherwise the specified kind.
13015 1.1 mrg
13016 1.1 mrg @item @emph{Example}:
13017 1.1 mrg @smallexample
13018 1.1 mrg PROGRAM test_shape
13019 1.1 mrg INTEGER, DIMENSION(-1:1, -1:2) :: A
13020 1.1 mrg WRITE(*,*) SHAPE(A) ! (/ 3, 4 /)
13021 1.1 mrg WRITE(*,*) SIZE(SHAPE(42)) ! (/ /)
13022 1.1 mrg END PROGRAM
13023 1.1 mrg @end smallexample
13024 1.1 mrg
13025 1.1 mrg @item @emph{See also}:
13026 1.1.1.2 mrg @ref{RESHAPE}, @gol
13027 1.1.1.2 mrg @ref{SIZE}
13028 1.1 mrg @end table
13029 1.1 mrg
13030 1.1 mrg
13031 1.1 mrg
13032 1.1 mrg @node SHIFTA
13033 1.1 mrg @section @code{SHIFTA} --- Right shift with fill
13034 1.1 mrg @fnindex SHIFTA
13035 1.1 mrg @cindex bits, shift right
13036 1.1 mrg @cindex shift, right with fill
13037 1.1 mrg
13038 1.1 mrg @table @asis
13039 1.1 mrg @item @emph{Description}:
13040 1.1 mrg @code{SHIFTA} returns a value corresponding to @var{I} with all of the
13041 1.1 mrg bits shifted right by @var{SHIFT} places. @var{SHIFT} that be
13042 1.1 mrg nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise
13043 1.1 mrg the result value is undefined. Bits shifted out from the right end
13044 1.1 mrg are lost. The fill is arithmetic: the bits shifted in from the left
13045 1.1 mrg end are equal to the leftmost bit, which in two's complement
13046 1.1 mrg representation is the sign bit.
13047 1.1 mrg
13048 1.1 mrg @item @emph{Standard}:
13049 1.1 mrg Fortran 2008 and later
13050 1.1 mrg
13051 1.1 mrg @item @emph{Class}:
13052 1.1 mrg Elemental function
13053 1.1 mrg
13054 1.1 mrg @item @emph{Syntax}:
13055 1.1 mrg @code{RESULT = SHIFTA(I, SHIFT)}
13056 1.1 mrg
13057 1.1 mrg @item @emph{Arguments}:
13058 1.1 mrg @multitable @columnfractions .15 .70
13059 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
13060 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
13061 1.1 mrg @end multitable
13062 1.1 mrg
13063 1.1 mrg @item @emph{Return value}:
13064 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
13065 1.1 mrg @var{I}.
13066 1.1 mrg
13067 1.1 mrg @item @emph{See also}:
13068 1.1.1.2 mrg @ref{SHIFTL}, @gol
13069 1.1.1.2 mrg @ref{SHIFTR}
13070 1.1 mrg @end table
13071 1.1 mrg
13072 1.1 mrg
13073 1.1 mrg
13074 1.1 mrg @node SHIFTL
13075 1.1 mrg @section @code{SHIFTL} --- Left shift
13076 1.1 mrg @fnindex SHIFTL
13077 1.1 mrg @cindex bits, shift left
13078 1.1 mrg @cindex shift, left
13079 1.1 mrg
13080 1.1 mrg @table @asis
13081 1.1 mrg @item @emph{Description}:
13082 1.1 mrg @code{SHIFTL} returns a value corresponding to @var{I} with all of the
13083 1.1 mrg bits shifted left by @var{SHIFT} places. @var{SHIFT} shall be
13084 1.1 mrg nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise
13085 1.1 mrg the result value is undefined. Bits shifted out from the left end are
13086 1.1 mrg lost, and bits shifted in from the right end are set to 0.
13087 1.1 mrg
13088 1.1 mrg @item @emph{Standard}:
13089 1.1 mrg Fortran 2008 and later
13090 1.1 mrg
13091 1.1 mrg @item @emph{Class}:
13092 1.1 mrg Elemental function
13093 1.1 mrg
13094 1.1 mrg @item @emph{Syntax}:
13095 1.1 mrg @code{RESULT = SHIFTL(I, SHIFT)}
13096 1.1 mrg
13097 1.1 mrg @item @emph{Arguments}:
13098 1.1 mrg @multitable @columnfractions .15 .70
13099 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
13100 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
13101 1.1 mrg @end multitable
13102 1.1 mrg
13103 1.1 mrg @item @emph{Return value}:
13104 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
13105 1.1 mrg @var{I}.
13106 1.1 mrg
13107 1.1 mrg @item @emph{See also}:
13108 1.1.1.2 mrg @ref{SHIFTA}, @gol
13109 1.1.1.2 mrg @ref{SHIFTR}
13110 1.1 mrg @end table
13111 1.1 mrg
13112 1.1 mrg
13113 1.1 mrg
13114 1.1 mrg @node SHIFTR
13115 1.1 mrg @section @code{SHIFTR} --- Right shift
13116 1.1 mrg @fnindex SHIFTR
13117 1.1 mrg @cindex bits, shift right
13118 1.1 mrg @cindex shift, right
13119 1.1 mrg
13120 1.1 mrg @table @asis
13121 1.1 mrg @item @emph{Description}:
13122 1.1 mrg @code{SHIFTR} returns a value corresponding to @var{I} with all of the
13123 1.1 mrg bits shifted right by @var{SHIFT} places. @var{SHIFT} shall be
13124 1.1 mrg nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise
13125 1.1 mrg the result value is undefined. Bits shifted out from the right end
13126 1.1 mrg are lost, and bits shifted in from the left end are set to 0.
13127 1.1 mrg
13128 1.1 mrg @item @emph{Standard}:
13129 1.1 mrg Fortran 2008 and later
13130 1.1 mrg
13131 1.1 mrg @item @emph{Class}:
13132 1.1 mrg Elemental function
13133 1.1 mrg
13134 1.1 mrg @item @emph{Syntax}:
13135 1.1 mrg @code{RESULT = SHIFTR(I, SHIFT)}
13136 1.1 mrg
13137 1.1 mrg @item @emph{Arguments}:
13138 1.1 mrg @multitable @columnfractions .15 .70
13139 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
13140 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
13141 1.1 mrg @end multitable
13142 1.1 mrg
13143 1.1 mrg @item @emph{Return value}:
13144 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
13145 1.1 mrg @var{I}.
13146 1.1 mrg
13147 1.1 mrg @item @emph{See also}:
13148 1.1.1.2 mrg @ref{SHIFTA}, @gol
13149 1.1.1.2 mrg @ref{SHIFTL}
13150 1.1 mrg @end table
13151 1.1 mrg
13152 1.1 mrg
13153 1.1 mrg
13154 1.1 mrg @node SIGN
13155 1.1 mrg @section @code{SIGN} --- Sign copying function
13156 1.1 mrg @fnindex SIGN
13157 1.1 mrg @fnindex ISIGN
13158 1.1 mrg @fnindex DSIGN
13159 1.1 mrg @cindex sign copying
13160 1.1 mrg
13161 1.1 mrg @table @asis
13162 1.1 mrg @item @emph{Description}:
13163 1.1 mrg @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
13164 1.1 mrg
13165 1.1 mrg @item @emph{Standard}:
13166 1.1 mrg Fortran 77 and later
13167 1.1 mrg
13168 1.1 mrg @item @emph{Class}:
13169 1.1 mrg Elemental function
13170 1.1 mrg
13171 1.1 mrg @item @emph{Syntax}:
13172 1.1 mrg @code{RESULT = SIGN(A, B)}
13173 1.1 mrg
13174 1.1 mrg @item @emph{Arguments}:
13175 1.1 mrg @multitable @columnfractions .15 .70
13176 1.1 mrg @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
13177 1.1.1.2 mrg @item @var{B} @tab Shall be of the same type and kind as @var{A}.
13178 1.1 mrg @end multitable
13179 1.1 mrg
13180 1.1 mrg @item @emph{Return value}:
13181 1.1 mrg The kind of the return value is that of @var{A} and @var{B}.
13182 1.1 mrg If @math{B\ge 0} then the result is @code{ABS(A)}, else
13183 1.1 mrg it is @code{-ABS(A)}.
13184 1.1 mrg
13185 1.1 mrg @item @emph{Example}:
13186 1.1 mrg @smallexample
13187 1.1 mrg program test_sign
13188 1.1 mrg print *, sign(-12,1)
13189 1.1 mrg print *, sign(-12,0)
13190 1.1 mrg print *, sign(-12,-1)
13191 1.1 mrg
13192 1.1 mrg print *, sign(-12.,1.)
13193 1.1 mrg print *, sign(-12.,0.)
13194 1.1 mrg print *, sign(-12.,-1.)
13195 1.1 mrg end program test_sign
13196 1.1 mrg @end smallexample
13197 1.1 mrg
13198 1.1 mrg @item @emph{Specific names}:
13199 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
13200 1.1 mrg @item Name @tab Arguments @tab Return type @tab Standard
13201 1.1.1.2 mrg @item @code{SIGN(A,B)} @tab @code{REAL(4) A, B} @tab @code{REAL(4)} @tab Fortran 77 and later
13202 1.1.1.2 mrg @item @code{ISIGN(A,B)} @tab @code{INTEGER(4) A, B} @tab @code{INTEGER(4)} @tab Fortran 77 and later
13203 1.1.1.2 mrg @item @code{DSIGN(A,B)} @tab @code{REAL(8) A, B} @tab @code{REAL(8)} @tab Fortran 77 and later
13204 1.1 mrg @end multitable
13205 1.1 mrg @end table
13206 1.1 mrg
13207 1.1 mrg
13208 1.1 mrg
13209 1.1 mrg @node SIGNAL
13210 1.1 mrg @section @code{SIGNAL} --- Signal handling subroutine (or function)
13211 1.1 mrg @fnindex SIGNAL
13212 1.1 mrg @cindex system, signal handling
13213 1.1 mrg
13214 1.1 mrg @table @asis
13215 1.1 mrg @item @emph{Description}:
13216 1.1 mrg @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
13217 1.1 mrg @var{HANDLER} to be executed with a single integer argument when signal
13218 1.1 mrg @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
13219 1.1 mrg turn off handling of signal @var{NUMBER} or revert to its default
13220 1.1 mrg action. See @code{signal(2)}.
13221 1.1 mrg
13222 1.1 mrg If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
13223 1.1 mrg is supplied, it is set to the value returned by @code{signal(2)}.
13224 1.1 mrg
13225 1.1 mrg @item @emph{Standard}:
13226 1.1 mrg GNU extension
13227 1.1 mrg
13228 1.1 mrg @item @emph{Class}:
13229 1.1 mrg Subroutine, function
13230 1.1 mrg
13231 1.1 mrg @item @emph{Syntax}:
13232 1.1 mrg @multitable @columnfractions .80
13233 1.1 mrg @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
13234 1.1 mrg @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
13235 1.1 mrg @end multitable
13236 1.1 mrg
13237 1.1 mrg @item @emph{Arguments}:
13238 1.1 mrg @multitable @columnfractions .15 .70
13239 1.1 mrg @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
13240 1.1 mrg @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
13241 1.1 mrg @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
13242 1.1 mrg @code{INTEGER}. It is @code{INTENT(IN)}.
13243 1.1 mrg @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
13244 1.1 mrg integer. It has @code{INTENT(OUT)}.
13245 1.1 mrg @end multitable
13246 1.1 mrg @c TODO: What should the interface of the handler be? Does it take arguments?
13247 1.1 mrg
13248 1.1 mrg @item @emph{Return value}:
13249 1.1 mrg The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
13250 1.1 mrg
13251 1.1 mrg @item @emph{Example}:
13252 1.1 mrg @smallexample
13253 1.1 mrg program test_signal
13254 1.1 mrg intrinsic signal
13255 1.1 mrg external handler_print
13256 1.1 mrg
13257 1.1 mrg call signal (12, handler_print)
13258 1.1 mrg call signal (10, 1)
13259 1.1 mrg
13260 1.1 mrg call sleep (30)
13261 1.1 mrg end program test_signal
13262 1.1 mrg @end smallexample
13263 1.1 mrg @end table
13264 1.1 mrg
13265 1.1 mrg
13266 1.1 mrg
13267 1.1 mrg @node SIN
13268 1.1 mrg @section @code{SIN} --- Sine function
13269 1.1 mrg @fnindex SIN
13270 1.1 mrg @fnindex DSIN
13271 1.1 mrg @fnindex CSIN
13272 1.1 mrg @fnindex ZSIN
13273 1.1 mrg @fnindex CDSIN
13274 1.1 mrg @cindex trigonometric function, sine
13275 1.1 mrg @cindex sine
13276 1.1 mrg
13277 1.1 mrg @table @asis
13278 1.1 mrg @item @emph{Description}:
13279 1.1 mrg @code{SIN(X)} computes the sine of @var{X}.
13280 1.1 mrg
13281 1.1 mrg @item @emph{Standard}:
13282 1.1 mrg Fortran 77 and later
13283 1.1 mrg
13284 1.1 mrg @item @emph{Class}:
13285 1.1 mrg Elemental function
13286 1.1 mrg
13287 1.1 mrg @item @emph{Syntax}:
13288 1.1 mrg @code{RESULT = SIN(X)}
13289 1.1 mrg
13290 1.1 mrg @item @emph{Arguments}:
13291 1.1 mrg @multitable @columnfractions .15 .70
13292 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or
13293 1.1 mrg @code{COMPLEX}.
13294 1.1 mrg @end multitable
13295 1.1 mrg
13296 1.1 mrg @item @emph{Return value}:
13297 1.1 mrg The return value has same type and kind as @var{X}.
13298 1.1 mrg
13299 1.1 mrg @item @emph{Example}:
13300 1.1 mrg @smallexample
13301 1.1 mrg program test_sin
13302 1.1 mrg real :: x = 0.0
13303 1.1 mrg x = sin(x)
13304 1.1 mrg end program test_sin
13305 1.1 mrg @end smallexample
13306 1.1 mrg
13307 1.1 mrg @item @emph{Specific names}:
13308 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
13309 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
13310 1.1.1.2 mrg @item @code{SIN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
13311 1.1.1.2 mrg @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
13312 1.1.1.2 mrg @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
13313 1.1.1.2 mrg @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13314 1.1.1.2 mrg @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13315 1.1 mrg @end multitable
13316 1.1 mrg
13317 1.1 mrg @item @emph{See also}:
13318 1.1.1.2 mrg Inverse function: @gol
13319 1.1.1.2 mrg @ref{ASIN} @gol
13320 1.1.1.2 mrg Degrees function: @gol
13321 1.1.1.2 mrg @ref{SIND}
13322 1.1 mrg @end table
13323 1.1 mrg
13324 1.1 mrg
13325 1.1 mrg
13326 1.1 mrg @node SIND
13327 1.1 mrg @section @code{SIND} --- Sine function, degrees
13328 1.1 mrg @fnindex SIND
13329 1.1 mrg @fnindex DSIND
13330 1.1 mrg @fnindex CSIND
13331 1.1 mrg @fnindex ZSIND
13332 1.1 mrg @fnindex CDSIND
13333 1.1 mrg @cindex trigonometric function, sine, degrees
13334 1.1 mrg @cindex sine, degrees
13335 1.1 mrg
13336 1.1 mrg @table @asis
13337 1.1 mrg @item @emph{Description}:
13338 1.1 mrg @code{SIND(X)} computes the sine of @var{X} in degrees.
13339 1.1 mrg
13340 1.1 mrg This function is for compatibility only and should be avoided in favor of
13341 1.1 mrg standard constructs wherever possible.
13342 1.1 mrg
13343 1.1 mrg @item @emph{Standard}:
13344 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math}.
13345 1.1 mrg
13346 1.1 mrg @item @emph{Class}:
13347 1.1 mrg Elemental function
13348 1.1 mrg
13349 1.1 mrg @item @emph{Syntax}:
13350 1.1 mrg @code{RESULT = SIND(X)}
13351 1.1 mrg
13352 1.1 mrg @item @emph{Arguments}:
13353 1.1 mrg @multitable @columnfractions .15 .70
13354 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or
13355 1.1 mrg @code{COMPLEX}.
13356 1.1 mrg @end multitable
13357 1.1 mrg
13358 1.1 mrg @item @emph{Return value}:
13359 1.1 mrg The return value has same type and kind as @var{X}, and its value is in degrees.
13360 1.1 mrg
13361 1.1 mrg @item @emph{Example}:
13362 1.1 mrg @smallexample
13363 1.1 mrg program test_sind
13364 1.1 mrg real :: x = 0.0
13365 1.1 mrg x = sind(x)
13366 1.1 mrg end program test_sind
13367 1.1 mrg @end smallexample
13368 1.1 mrg
13369 1.1 mrg @item @emph{Specific names}:
13370 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
13371 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
13372 1.1.1.2 mrg @item @code{SIND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
13373 1.1.1.2 mrg @item @code{DSIND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
13374 1.1.1.2 mrg @item @code{CSIND(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab GNU extension
13375 1.1.1.2 mrg @item @code{ZSIND(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13376 1.1.1.2 mrg @item @code{CDSIND(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13377 1.1 mrg @end multitable
13378 1.1 mrg
13379 1.1 mrg @item @emph{See also}:
13380 1.1.1.2 mrg Inverse function: @gol
13381 1.1.1.2 mrg @ref{ASIND} @gol
13382 1.1.1.2 mrg Radians function: @gol
13383 1.1.1.2 mrg @ref{SIN} @gol
13384 1.1 mrg @end table
13385 1.1 mrg
13386 1.1 mrg
13387 1.1 mrg
13388 1.1 mrg @node SINH
13389 1.1 mrg @section @code{SINH} --- Hyperbolic sine function
13390 1.1 mrg @fnindex SINH
13391 1.1 mrg @fnindex DSINH
13392 1.1 mrg @cindex hyperbolic sine
13393 1.1 mrg @cindex hyperbolic function, sine
13394 1.1 mrg @cindex sine, hyperbolic
13395 1.1 mrg
13396 1.1 mrg @table @asis
13397 1.1 mrg @item @emph{Description}:
13398 1.1 mrg @code{SINH(X)} computes the hyperbolic sine of @var{X}.
13399 1.1 mrg
13400 1.1 mrg @item @emph{Standard}:
13401 1.1.1.2 mrg Fortran 90 and later, for a complex argument Fortran 2008 or later, has
13402 1.1.1.2 mrg a GNU extension
13403 1.1 mrg
13404 1.1 mrg @item @emph{Class}:
13405 1.1 mrg Elemental function
13406 1.1 mrg
13407 1.1 mrg @item @emph{Syntax}:
13408 1.1 mrg @code{RESULT = SINH(X)}
13409 1.1 mrg
13410 1.1 mrg @item @emph{Arguments}:
13411 1.1 mrg @multitable @columnfractions .15 .70
13412 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
13413 1.1 mrg @end multitable
13414 1.1 mrg
13415 1.1 mrg @item @emph{Return value}:
13416 1.1 mrg The return value has same type and kind as @var{X}.
13417 1.1 mrg
13418 1.1 mrg @item @emph{Example}:
13419 1.1 mrg @smallexample
13420 1.1 mrg program test_sinh
13421 1.1 mrg real(8) :: x = - 1.0_8
13422 1.1 mrg x = sinh(x)
13423 1.1 mrg end program test_sinh
13424 1.1 mrg @end smallexample
13425 1.1 mrg
13426 1.1 mrg @item @emph{Specific names}:
13427 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
13428 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
13429 1.1.1.2 mrg @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 90 and later
13430 1.1 mrg @end multitable
13431 1.1 mrg
13432 1.1 mrg @item @emph{See also}:
13433 1.1 mrg @ref{ASINH}
13434 1.1 mrg @end table
13435 1.1 mrg
13436 1.1 mrg
13437 1.1 mrg
13438 1.1 mrg @node SIZE
13439 1.1 mrg @section @code{SIZE} --- Determine the size of an array
13440 1.1 mrg @fnindex SIZE
13441 1.1 mrg @cindex array, size
13442 1.1 mrg @cindex array, number of elements
13443 1.1 mrg @cindex array, count elements
13444 1.1 mrg
13445 1.1 mrg @table @asis
13446 1.1 mrg @item @emph{Description}:
13447 1.1 mrg Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
13448 1.1 mrg or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
13449 1.1 mrg
13450 1.1 mrg @item @emph{Standard}:
13451 1.1.1.2 mrg Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later
13452 1.1 mrg
13453 1.1 mrg @item @emph{Class}:
13454 1.1 mrg Inquiry function
13455 1.1 mrg
13456 1.1 mrg @item @emph{Syntax}:
13457 1.1 mrg @code{RESULT = SIZE(ARRAY[, DIM [, KIND]])}
13458 1.1 mrg
13459 1.1 mrg @item @emph{Arguments}:
13460 1.1 mrg @multitable @columnfractions .15 .70
13461 1.1 mrg @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
13462 1.1 mrg a pointer it must be associated and allocatable arrays must be allocated.
13463 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type @code{INTEGER}
13464 1.1 mrg and its value shall be in the range from 1 to n, where n equals the rank
13465 1.1 mrg of @var{ARRAY}.
13466 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
13467 1.1 mrg expression indicating the kind parameter of the result.
13468 1.1 mrg @end multitable
13469 1.1 mrg
13470 1.1 mrg @item @emph{Return value}:
13471 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
13472 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
13473 1.1 mrg
13474 1.1 mrg @item @emph{Example}:
13475 1.1 mrg @smallexample
13476 1.1 mrg PROGRAM test_size
13477 1.1 mrg WRITE(*,*) SIZE((/ 1, 2 /)) ! 2
13478 1.1 mrg END PROGRAM
13479 1.1 mrg @end smallexample
13480 1.1 mrg
13481 1.1 mrg @item @emph{See also}:
13482 1.1.1.2 mrg @ref{SHAPE}, @gol
13483 1.1.1.2 mrg @ref{RESHAPE}
13484 1.1 mrg @end table
13485 1.1 mrg
13486 1.1 mrg
13487 1.1 mrg @node SIZEOF
13488 1.1 mrg @section @code{SIZEOF} --- Size in bytes of an expression
13489 1.1 mrg @fnindex SIZEOF
13490 1.1 mrg @cindex expression size
13491 1.1 mrg @cindex size of an expression
13492 1.1 mrg
13493 1.1 mrg @table @asis
13494 1.1 mrg @item @emph{Description}:
13495 1.1 mrg @code{SIZEOF(X)} calculates the number of bytes of storage the
13496 1.1 mrg expression @code{X} occupies.
13497 1.1 mrg
13498 1.1 mrg @item @emph{Standard}:
13499 1.1 mrg GNU extension
13500 1.1 mrg
13501 1.1 mrg @item @emph{Class}:
13502 1.1 mrg Inquiry function
13503 1.1 mrg
13504 1.1 mrg @item @emph{Syntax}:
13505 1.1 mrg @code{N = SIZEOF(X)}
13506 1.1 mrg
13507 1.1 mrg @item @emph{Arguments}:
13508 1.1 mrg @multitable @columnfractions .15 .70
13509 1.1 mrg @item @var{X} @tab The argument shall be of any type, rank or shape.
13510 1.1 mrg @end multitable
13511 1.1 mrg
13512 1.1 mrg @item @emph{Return value}:
13513 1.1 mrg The return value is of type integer and of the system-dependent kind
13514 1.1 mrg @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
13515 1.1 mrg number of bytes occupied by the argument. If the argument has the
13516 1.1 mrg @code{POINTER} attribute, the number of bytes of the storage area pointed
13517 1.1 mrg to is returned. If the argument is of a derived type with @code{POINTER}
13518 1.1 mrg or @code{ALLOCATABLE} components, the return value does not account for
13519 1.1 mrg the sizes of the data pointed to by these components. If the argument is
13520 1.1 mrg polymorphic, the size according to the dynamic type is returned. The argument
13521 1.1 mrg may not be a procedure or procedure pointer. Note that the code assumes for
13522 1.1 mrg arrays that those are contiguous; for contiguous arrays, it returns the
13523 1.1 mrg storage or an array element multiplied by the size of the array.
13524 1.1 mrg
13525 1.1 mrg @item @emph{Example}:
13526 1.1 mrg @smallexample
13527 1.1 mrg integer :: i
13528 1.1 mrg real :: r, s(5)
13529 1.1 mrg print *, (sizeof(s)/sizeof(r) == 5)
13530 1.1 mrg end
13531 1.1 mrg @end smallexample
13532 1.1 mrg The example will print @code{.TRUE.} unless you are using a platform
13533 1.1 mrg where default @code{REAL} variables are unusually padded.
13534 1.1 mrg
13535 1.1 mrg @item @emph{See also}:
13536 1.1.1.2 mrg @ref{C_SIZEOF}, @gol
13537 1.1.1.2 mrg @ref{STORAGE_SIZE}
13538 1.1 mrg @end table
13539 1.1 mrg
13540 1.1 mrg
13541 1.1 mrg @node SLEEP
13542 1.1 mrg @section @code{SLEEP} --- Sleep for the specified number of seconds
13543 1.1 mrg @fnindex SLEEP
13544 1.1 mrg @cindex delayed execution
13545 1.1 mrg
13546 1.1 mrg @table @asis
13547 1.1 mrg @item @emph{Description}:
13548 1.1 mrg Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
13549 1.1 mrg
13550 1.1 mrg @item @emph{Standard}:
13551 1.1 mrg GNU extension
13552 1.1 mrg
13553 1.1 mrg @item @emph{Class}:
13554 1.1 mrg Subroutine
13555 1.1 mrg
13556 1.1 mrg @item @emph{Syntax}:
13557 1.1 mrg @code{CALL SLEEP(SECONDS)}
13558 1.1 mrg
13559 1.1 mrg @item @emph{Arguments}:
13560 1.1 mrg @multitable @columnfractions .15 .70
13561 1.1 mrg @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
13562 1.1 mrg @end multitable
13563 1.1 mrg
13564 1.1 mrg @item @emph{Example}:
13565 1.1 mrg @smallexample
13566 1.1 mrg program test_sleep
13567 1.1 mrg call sleep(5)
13568 1.1 mrg end
13569 1.1 mrg @end smallexample
13570 1.1 mrg @end table
13571 1.1 mrg
13572 1.1 mrg
13573 1.1 mrg
13574 1.1 mrg @node SPACING
13575 1.1 mrg @section @code{SPACING} --- Smallest distance between two numbers of a given type
13576 1.1 mrg @fnindex SPACING
13577 1.1 mrg @cindex real number, relative spacing
13578 1.1 mrg @cindex floating point, relative spacing
13579 1.1 mrg
13580 1.1 mrg @table @asis
13581 1.1 mrg @item @emph{Description}:
13582 1.1 mrg Determines the distance between the argument @var{X} and the nearest
13583 1.1 mrg adjacent number of the same type.
13584 1.1 mrg
13585 1.1 mrg @item @emph{Standard}:
13586 1.1.1.2 mrg Fortran 90 and later
13587 1.1 mrg
13588 1.1 mrg @item @emph{Class}:
13589 1.1 mrg Elemental function
13590 1.1 mrg
13591 1.1 mrg @item @emph{Syntax}:
13592 1.1 mrg @code{RESULT = SPACING(X)}
13593 1.1 mrg
13594 1.1 mrg @item @emph{Arguments}:
13595 1.1 mrg @multitable @columnfractions .15 .70
13596 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}.
13597 1.1 mrg @end multitable
13598 1.1 mrg
13599 1.1 mrg @item @emph{Return value}:
13600 1.1 mrg The result is of the same type as the input argument @var{X}.
13601 1.1 mrg
13602 1.1 mrg @item @emph{Example}:
13603 1.1 mrg @smallexample
13604 1.1 mrg PROGRAM test_spacing
13605 1.1 mrg INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
13606 1.1 mrg INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
13607 1.1 mrg
13608 1.1 mrg WRITE(*,*) spacing(1.0_SGL) ! "1.1920929E-07" on i686
13609 1.1 mrg WRITE(*,*) spacing(1.0_DBL) ! "2.220446049250313E-016" on i686
13610 1.1 mrg END PROGRAM
13611 1.1 mrg @end smallexample
13612 1.1 mrg
13613 1.1 mrg @item @emph{See also}:
13614 1.1 mrg @ref{RRSPACING}
13615 1.1 mrg @end table
13616 1.1 mrg
13617 1.1 mrg
13618 1.1 mrg
13619 1.1 mrg @node SPREAD
13620 1.1 mrg @section @code{SPREAD} --- Add a dimension to an array
13621 1.1 mrg @fnindex SPREAD
13622 1.1 mrg @cindex array, increase dimension
13623 1.1 mrg @cindex array, duplicate elements
13624 1.1 mrg @cindex array, duplicate dimensions
13625 1.1 mrg
13626 1.1 mrg @table @asis
13627 1.1 mrg @item @emph{Description}:
13628 1.1 mrg Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified
13629 1.1 mrg dimension @var{DIM}.
13630 1.1 mrg
13631 1.1 mrg @item @emph{Standard}:
13632 1.1.1.2 mrg Fortran 90 and later
13633 1.1 mrg
13634 1.1 mrg @item @emph{Class}:
13635 1.1 mrg Transformational function
13636 1.1 mrg
13637 1.1 mrg @item @emph{Syntax}:
13638 1.1 mrg @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
13639 1.1 mrg
13640 1.1 mrg @item @emph{Arguments}:
13641 1.1 mrg @multitable @columnfractions .15 .70
13642 1.1 mrg @item @var{SOURCE} @tab Shall be a scalar or an array of any type and
13643 1.1 mrg a rank less than seven.
13644 1.1 mrg @item @var{DIM} @tab Shall be a scalar of type @code{INTEGER} with a
13645 1.1 mrg value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
13646 1.1 mrg @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
13647 1.1 mrg @end multitable
13648 1.1 mrg
13649 1.1 mrg @item @emph{Return value}:
13650 1.1 mrg The result is an array of the same type as @var{SOURCE} and has rank n+1
13651 1.1 mrg where n equals the rank of @var{SOURCE}.
13652 1.1 mrg
13653 1.1 mrg @item @emph{Example}:
13654 1.1 mrg @smallexample
13655 1.1 mrg PROGRAM test_spread
13656 1.1 mrg INTEGER :: a = 1, b(2) = (/ 1, 2 /)
13657 1.1 mrg WRITE(*,*) SPREAD(A, 1, 2) ! "1 1"
13658 1.1 mrg WRITE(*,*) SPREAD(B, 1, 2) ! "1 1 2 2"
13659 1.1 mrg END PROGRAM
13660 1.1 mrg @end smallexample
13661 1.1 mrg
13662 1.1 mrg @item @emph{See also}:
13663 1.1 mrg @ref{UNPACK}
13664 1.1 mrg @end table
13665 1.1 mrg
13666 1.1 mrg
13667 1.1 mrg
13668 1.1 mrg @node SQRT
13669 1.1 mrg @section @code{SQRT} --- Square-root function
13670 1.1 mrg @fnindex SQRT
13671 1.1 mrg @fnindex DSQRT
13672 1.1 mrg @fnindex CSQRT
13673 1.1 mrg @fnindex ZSQRT
13674 1.1 mrg @fnindex CDSQRT
13675 1.1 mrg @cindex root
13676 1.1 mrg @cindex square-root
13677 1.1 mrg
13678 1.1 mrg @table @asis
13679 1.1 mrg @item @emph{Description}:
13680 1.1 mrg @code{SQRT(X)} computes the square root of @var{X}.
13681 1.1 mrg
13682 1.1 mrg @item @emph{Standard}:
13683 1.1 mrg Fortran 77 and later
13684 1.1 mrg
13685 1.1 mrg @item @emph{Class}:
13686 1.1 mrg Elemental function
13687 1.1 mrg
13688 1.1 mrg @item @emph{Syntax}:
13689 1.1 mrg @code{RESULT = SQRT(X)}
13690 1.1 mrg
13691 1.1 mrg @item @emph{Arguments}:
13692 1.1 mrg @multitable @columnfractions .15 .70
13693 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or
13694 1.1 mrg @code{COMPLEX}.
13695 1.1 mrg @end multitable
13696 1.1 mrg
13697 1.1 mrg @item @emph{Return value}:
13698 1.1 mrg The return value is of type @code{REAL} or @code{COMPLEX}.
13699 1.1 mrg The kind type parameter is the same as @var{X}.
13700 1.1 mrg
13701 1.1 mrg @item @emph{Example}:
13702 1.1 mrg @smallexample
13703 1.1 mrg program test_sqrt
13704 1.1 mrg real(8) :: x = 2.0_8
13705 1.1 mrg complex :: z = (1.0, 2.0)
13706 1.1 mrg x = sqrt(x)
13707 1.1 mrg z = sqrt(z)
13708 1.1 mrg end program test_sqrt
13709 1.1 mrg @end smallexample
13710 1.1 mrg
13711 1.1 mrg @item @emph{Specific names}:
13712 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
13713 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
13714 1.1.1.2 mrg @item @code{SQRT(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
13715 1.1.1.2 mrg @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
13716 1.1.1.2 mrg @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
13717 1.1 mrg @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13718 1.1 mrg @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13719 1.1 mrg @end multitable
13720 1.1 mrg @end table
13721 1.1 mrg
13722 1.1 mrg
13723 1.1 mrg
13724 1.1 mrg @node SRAND
13725 1.1 mrg @section @code{SRAND} --- Reinitialize the random number generator
13726 1.1 mrg @fnindex SRAND
13727 1.1 mrg @cindex random number generation, seeding
13728 1.1 mrg @cindex seeding a random number generator
13729 1.1 mrg
13730 1.1 mrg @table @asis
13731 1.1 mrg @item @emph{Description}:
13732 1.1 mrg @code{SRAND} reinitializes the pseudo-random number generator
13733 1.1 mrg called by @code{RAND} and @code{IRAND}. The new seed used by the
13734 1.1 mrg generator is specified by the required argument @var{SEED}.
13735 1.1 mrg
13736 1.1 mrg @item @emph{Standard}:
13737 1.1 mrg GNU extension
13738 1.1 mrg
13739 1.1 mrg @item @emph{Class}:
13740 1.1 mrg Subroutine
13741 1.1 mrg
13742 1.1 mrg @item @emph{Syntax}:
13743 1.1 mrg @code{CALL SRAND(SEED)}
13744 1.1 mrg
13745 1.1 mrg @item @emph{Arguments}:
13746 1.1 mrg @multitable @columnfractions .15 .70
13747 1.1 mrg @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
13748 1.1 mrg @end multitable
13749 1.1 mrg
13750 1.1 mrg @item @emph{Return value}:
13751 1.1 mrg Does not return anything.
13752 1.1 mrg
13753 1.1 mrg @item @emph{Example}:
13754 1.1 mrg See @code{RAND} and @code{IRAND} for examples.
13755 1.1 mrg
13756 1.1 mrg @item @emph{Notes}:
13757 1.1 mrg The Fortran standard specifies the intrinsic subroutines
13758 1.1 mrg @code{RANDOM_SEED} to initialize the pseudo-random number
13759 1.1 mrg generator and @code{RANDOM_NUMBER} to generate pseudo-random numbers.
13760 1.1 mrg These subroutines should be used in new codes.
13761 1.1 mrg
13762 1.1 mrg Please note that in GNU Fortran, these two sets of intrinsics (@code{RAND},
13763 1.1 mrg @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
13764 1.1 mrg @code{RANDOM_SEED} on the other hand) access two independent
13765 1.1 mrg pseudo-random number generators.
13766 1.1 mrg
13767 1.1 mrg @item @emph{See also}:
13768 1.1.1.2 mrg @ref{RAND}, @gol
13769 1.1.1.2 mrg @ref{RANDOM_SEED}, @gol
13770 1.1.1.2 mrg @ref{RANDOM_NUMBER}
13771 1.1 mrg @end table
13772 1.1 mrg
13773 1.1 mrg
13774 1.1 mrg
13775 1.1 mrg @node STAT
13776 1.1 mrg @section @code{STAT} --- Get file status
13777 1.1 mrg @fnindex STAT
13778 1.1 mrg @cindex file system, file status
13779 1.1 mrg
13780 1.1 mrg @table @asis
13781 1.1 mrg @item @emph{Description}:
13782 1.1 mrg This function returns information about a file. No permissions are required on
13783 1.1 mrg the file itself, but execute (search) permission is required on all of the
13784 1.1 mrg directories in path that lead to the file.
13785 1.1 mrg
13786 1.1 mrg The elements that are obtained and stored in the array @code{VALUES}:
13787 1.1 mrg @multitable @columnfractions .15 .70
13788 1.1 mrg @item @code{VALUES(1)} @tab Device ID
13789 1.1 mrg @item @code{VALUES(2)} @tab Inode number
13790 1.1 mrg @item @code{VALUES(3)} @tab File mode
13791 1.1 mrg @item @code{VALUES(4)} @tab Number of links
13792 1.1 mrg @item @code{VALUES(5)} @tab Owner's uid
13793 1.1 mrg @item @code{VALUES(6)} @tab Owner's gid
13794 1.1 mrg @item @code{VALUES(7)} @tab ID of device containing directory entry for file (0 if not available)
13795 1.1 mrg @item @code{VALUES(8)} @tab File size (bytes)
13796 1.1 mrg @item @code{VALUES(9)} @tab Last access time
13797 1.1 mrg @item @code{VALUES(10)} @tab Last modification time
13798 1.1 mrg @item @code{VALUES(11)} @tab Last file status change time
13799 1.1 mrg @item @code{VALUES(12)} @tab Preferred I/O block size (-1 if not available)
13800 1.1 mrg @item @code{VALUES(13)} @tab Number of blocks allocated (-1 if not available)
13801 1.1 mrg @end multitable
13802 1.1 mrg
13803 1.1 mrg Not all these elements are relevant on all systems.
13804 1.1 mrg If an element is not relevant, it is returned as 0.
13805 1.1 mrg
13806 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
13807 1.1 mrg only one form can be used in any given program unit.
13808 1.1 mrg
13809 1.1 mrg @item @emph{Standard}:
13810 1.1 mrg GNU extension
13811 1.1 mrg
13812 1.1 mrg @item @emph{Class}:
13813 1.1 mrg Subroutine, function
13814 1.1 mrg
13815 1.1 mrg @item @emph{Syntax}:
13816 1.1 mrg @multitable @columnfractions .80
13817 1.1 mrg @item @code{CALL STAT(NAME, VALUES [, STATUS])}
13818 1.1 mrg @item @code{STATUS = STAT(NAME, VALUES)}
13819 1.1 mrg @end multitable
13820 1.1 mrg
13821 1.1 mrg @item @emph{Arguments}:
13822 1.1 mrg @multitable @columnfractions .15 .70
13823 1.1 mrg @item @var{NAME} @tab The type shall be @code{CHARACTER}, of the
13824 1.1 mrg default kind and a valid path within the file system.
13825 1.1 mrg @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
13826 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
13827 1.1 mrg on success and a system specific error code otherwise.
13828 1.1 mrg @end multitable
13829 1.1 mrg
13830 1.1 mrg @item @emph{Example}:
13831 1.1 mrg @smallexample
13832 1.1 mrg PROGRAM test_stat
13833 1.1 mrg INTEGER, DIMENSION(13) :: buff
13834 1.1 mrg INTEGER :: status
13835 1.1 mrg
13836 1.1 mrg CALL STAT("/etc/passwd", buff, status)
13837 1.1 mrg
13838 1.1 mrg IF (status == 0) THEN
13839 1.1 mrg WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
13840 1.1 mrg WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
13841 1.1 mrg WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
13842 1.1 mrg WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
13843 1.1 mrg WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
13844 1.1 mrg WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
13845 1.1 mrg WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
13846 1.1 mrg WRITE (*, FMT="('File size:', T30, I19)") buff(8)
13847 1.1 mrg WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
13848 1.1 mrg WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
13849 1.1 mrg WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
13850 1.1 mrg WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
13851 1.1 mrg WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
13852 1.1 mrg END IF
13853 1.1 mrg END PROGRAM
13854 1.1 mrg @end smallexample
13855 1.1 mrg
13856 1.1 mrg @item @emph{See also}:
13857 1.1.1.2 mrg To stat an open file: @gol
13858 1.1.1.2 mrg @ref{FSTAT} @gol
13859 1.1.1.2 mrg To stat a link: @gol
13860 1.1.1.2 mrg @ref{LSTAT}
13861 1.1 mrg @end table
13862 1.1 mrg
13863 1.1 mrg
13864 1.1 mrg
13865 1.1 mrg @node STORAGE_SIZE
13866 1.1 mrg @section @code{STORAGE_SIZE} --- Storage size in bits
13867 1.1 mrg @fnindex STORAGE_SIZE
13868 1.1 mrg @cindex storage size
13869 1.1 mrg
13870 1.1 mrg @table @asis
13871 1.1 mrg @item @emph{Description}:
13872 1.1 mrg Returns the storage size of argument @var{A} in bits.
13873 1.1 mrg @item @emph{Standard}:
13874 1.1 mrg Fortran 2008 and later
13875 1.1 mrg @item @emph{Class}:
13876 1.1 mrg Inquiry function
13877 1.1 mrg @item @emph{Syntax}:
13878 1.1 mrg @code{RESULT = STORAGE_SIZE(A [, KIND])}
13879 1.1 mrg
13880 1.1 mrg @item @emph{Arguments}:
13881 1.1 mrg @multitable @columnfractions .15 .70
13882 1.1 mrg @item @var{A} @tab Shall be a scalar or array of any type.
13883 1.1 mrg @item @var{KIND} @tab (Optional) shall be a scalar integer constant expression.
13884 1.1 mrg @end multitable
13885 1.1 mrg
13886 1.1 mrg @item @emph{Return Value}:
13887 1.1 mrg The result is a scalar integer with the kind type parameter specified by KIND
13888 1.1 mrg (or default integer type if KIND is missing). The result value is the size
13889 1.1 mrg expressed in bits for an element of an array that has the dynamic type and type
13890 1.1 mrg parameters of A.
13891 1.1 mrg
13892 1.1 mrg @item @emph{See also}:
13893 1.1.1.2 mrg @ref{C_SIZEOF}, @gol
13894 1.1.1.2 mrg @ref{SIZEOF}
13895 1.1 mrg @end table
13896 1.1 mrg
13897 1.1 mrg
13898 1.1 mrg
13899 1.1 mrg @node SUM
13900 1.1 mrg @section @code{SUM} --- Sum of array elements
13901 1.1 mrg @fnindex SUM
13902 1.1 mrg @cindex array, sum
13903 1.1 mrg @cindex array, add elements
13904 1.1 mrg @cindex array, conditionally add elements
13905 1.1 mrg @cindex sum array elements
13906 1.1 mrg
13907 1.1 mrg @table @asis
13908 1.1 mrg @item @emph{Description}:
13909 1.1 mrg Adds the elements of @var{ARRAY} along dimension @var{DIM} if
13910 1.1 mrg the corresponding element in @var{MASK} is @code{TRUE}.
13911 1.1 mrg
13912 1.1 mrg @item @emph{Standard}:
13913 1.1.1.2 mrg Fortran 90 and later
13914 1.1 mrg
13915 1.1 mrg @item @emph{Class}:
13916 1.1 mrg Transformational function
13917 1.1 mrg
13918 1.1 mrg @item @emph{Syntax}:
13919 1.1 mrg @multitable @columnfractions .80
13920 1.1 mrg @item @code{RESULT = SUM(ARRAY[, MASK])}
13921 1.1 mrg @item @code{RESULT = SUM(ARRAY, DIM[, MASK])}
13922 1.1 mrg @end multitable
13923 1.1 mrg
13924 1.1 mrg @item @emph{Arguments}:
13925 1.1 mrg @multitable @columnfractions .15 .70
13926 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
13927 1.1 mrg @code{REAL} or @code{COMPLEX}.
13928 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type
13929 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n
13930 1.1 mrg equals the rank of @var{ARRAY}.
13931 1.1 mrg @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
13932 1.1 mrg and either be a scalar or an array of the same shape as @var{ARRAY}.
13933 1.1 mrg @end multitable
13934 1.1 mrg
13935 1.1 mrg @item @emph{Return value}:
13936 1.1 mrg The result is of the same type as @var{ARRAY}.
13937 1.1 mrg
13938 1.1 mrg If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
13939 1.1 mrg is returned. Otherwise, an array of rank n-1, where n equals the rank of
13940 1.1 mrg @var{ARRAY}, and a shape similar to that of @var{ARRAY} with dimension @var{DIM}
13941 1.1 mrg dropped is returned.
13942 1.1 mrg
13943 1.1 mrg @item @emph{Example}:
13944 1.1 mrg @smallexample
13945 1.1 mrg PROGRAM test_sum
13946 1.1 mrg INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
13947 1.1 mrg print *, SUM(x) ! all elements, sum = 15
13948 1.1 mrg print *, SUM(x, MASK=MOD(x, 2)==1) ! odd elements, sum = 9
13949 1.1 mrg END PROGRAM
13950 1.1 mrg @end smallexample
13951 1.1 mrg
13952 1.1 mrg @item @emph{See also}:
13953 1.1 mrg @ref{PRODUCT}
13954 1.1 mrg @end table
13955 1.1 mrg
13956 1.1 mrg
13957 1.1 mrg
13958 1.1 mrg @node SYMLNK
13959 1.1 mrg @section @code{SYMLNK} --- Create a symbolic link
13960 1.1 mrg @fnindex SYMLNK
13961 1.1 mrg @cindex file system, create link
13962 1.1 mrg @cindex file system, soft link
13963 1.1 mrg
13964 1.1 mrg @table @asis
13965 1.1 mrg @item @emph{Description}:
13966 1.1 mrg Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
13967 1.1 mrg character (@code{CHAR(0)}) can be used to mark the end of the names in
13968 1.1 mrg @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
13969 1.1 mrg names are ignored. If the @var{STATUS} argument is supplied, it
13970 1.1 mrg contains 0 on success or a nonzero error code upon return; see
13971 1.1 mrg @code{symlink(2)}. If the system does not supply @code{symlink(2)},
13972 1.1 mrg @code{ENOSYS} is returned.
13973 1.1 mrg
13974 1.1 mrg This intrinsic is provided in both subroutine and function forms;
13975 1.1 mrg however, only one form can be used in any given program unit.
13976 1.1 mrg
13977 1.1 mrg @item @emph{Standard}:
13978 1.1 mrg GNU extension
13979 1.1 mrg
13980 1.1 mrg @item @emph{Class}:
13981 1.1 mrg Subroutine, function
13982 1.1 mrg
13983 1.1 mrg @item @emph{Syntax}:
13984 1.1 mrg @multitable @columnfractions .80
13985 1.1 mrg @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
13986 1.1 mrg @item @code{STATUS = SYMLNK(PATH1, PATH2)}
13987 1.1 mrg @end multitable
13988 1.1 mrg
13989 1.1 mrg @item @emph{Arguments}:
13990 1.1 mrg @multitable @columnfractions .15 .70
13991 1.1 mrg @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
13992 1.1 mrg @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
13993 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
13994 1.1 mrg @end multitable
13995 1.1 mrg
13996 1.1 mrg @item @emph{See also}:
13997 1.1.1.2 mrg @ref{LINK}, @gol
13998 1.1.1.2 mrg @ref{UNLINK}
13999 1.1 mrg @end table
14000 1.1 mrg
14001 1.1 mrg
14002 1.1 mrg
14003 1.1 mrg @node SYSTEM
14004 1.1 mrg @section @code{SYSTEM} --- Execute a shell command
14005 1.1 mrg @fnindex SYSTEM
14006 1.1 mrg @cindex system, system call
14007 1.1 mrg
14008 1.1 mrg @table @asis
14009 1.1 mrg @item @emph{Description}:
14010 1.1 mrg Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
14011 1.1 mrg argument @var{STATUS} is present, it contains the value returned by
14012 1.1 mrg @code{system(3)}, which is presumably 0 if the shell command succeeded.
14013 1.1 mrg Note that which shell is used to invoke the command is system-dependent
14014 1.1 mrg and environment-dependent.
14015 1.1 mrg
14016 1.1 mrg This intrinsic is provided in both subroutine and function forms;
14017 1.1 mrg however, only one form can be used in any given program unit.
14018 1.1 mrg
14019 1.1 mrg Note that the @code{system} function need not be thread-safe. It is
14020 1.1 mrg the responsibility of the user to ensure that @code{system} is not
14021 1.1 mrg called concurrently.
14022 1.1 mrg
14023 1.1 mrg @item @emph{Standard}:
14024 1.1 mrg GNU extension
14025 1.1 mrg
14026 1.1 mrg @item @emph{Class}:
14027 1.1 mrg Subroutine, function
14028 1.1 mrg
14029 1.1 mrg @item @emph{Syntax}:
14030 1.1 mrg @multitable @columnfractions .80
14031 1.1 mrg @item @code{CALL SYSTEM(COMMAND [, STATUS])}
14032 1.1 mrg @item @code{STATUS = SYSTEM(COMMAND)}
14033 1.1 mrg @end multitable
14034 1.1 mrg
14035 1.1 mrg @item @emph{Arguments}:
14036 1.1 mrg @multitable @columnfractions .15 .70
14037 1.1 mrg @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
14038 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
14039 1.1 mrg @end multitable
14040 1.1 mrg
14041 1.1 mrg @item @emph{See also}:
14042 1.1 mrg @ref{EXECUTE_COMMAND_LINE}, which is part of the Fortran 2008 standard
14043 1.1 mrg and should considered in new code for future portability.
14044 1.1 mrg @end table
14045 1.1 mrg
14046 1.1 mrg
14047 1.1 mrg
14048 1.1 mrg @node SYSTEM_CLOCK
14049 1.1 mrg @section @code{SYSTEM_CLOCK} --- Time function
14050 1.1 mrg @fnindex SYSTEM_CLOCK
14051 1.1 mrg @cindex time, clock ticks
14052 1.1 mrg @cindex clock ticks
14053 1.1 mrg
14054 1.1 mrg @table @asis
14055 1.1 mrg @item @emph{Description}:
14056 1.1 mrg Determines the @var{COUNT} of a processor clock since an unspecified
14057 1.1 mrg time in the past modulo @var{COUNT_MAX}, @var{COUNT_RATE} determines
14058 1.1 mrg the number of clock ticks per second. If the platform supports a
14059 1.1 mrg monotonic clock, that clock is used and can, depending on the platform
14060 1.1 mrg clock implementation, provide up to nanosecond resolution. If a
14061 1.1 mrg monotonic clock is not available, the implementation falls back to a
14062 1.1 mrg realtime clock.
14063 1.1 mrg
14064 1.1 mrg @var{COUNT_RATE} is system dependent and can vary depending on the kind of
14065 1.1 mrg the arguments. For @var{kind=4} arguments (and smaller integer kinds),
14066 1.1 mrg @var{COUNT} represents milliseconds, while for @var{kind=8} arguments (and
14067 1.1 mrg larger integer kinds), @var{COUNT} typically represents micro- or
14068 1.1 mrg nanoseconds depending on resolution of the underlying platform clock.
14069 1.1 mrg @var{COUNT_MAX} usually equals @code{HUGE(COUNT_MAX)}. Note that the
14070 1.1 mrg millisecond resolution of the @var{kind=4} version implies that the
14071 1.1 mrg @var{COUNT} will wrap around in roughly 25 days. In order to avoid issues
14072 1.1 mrg with the wrap around and for more precise timing, please use the
14073 1.1 mrg @var{kind=8} version.
14074 1.1 mrg
14075 1.1 mrg If there is no clock, or querying the clock fails, @var{COUNT} is set
14076 1.1 mrg to @code{-HUGE(COUNT)}, and @var{COUNT_RATE} and @var{COUNT_MAX} are
14077 1.1 mrg set to zero.
14078 1.1 mrg
14079 1.1 mrg When running on a platform using the GNU C library (glibc) version
14080 1.1 mrg 2.16 or older, or a derivative thereof, the high resolution monotonic
14081 1.1 mrg clock is available only when linking with the @var{rt} library. This
14082 1.1 mrg can be done explicitly by adding the @code{-lrt} flag when linking the
14083 1.1 mrg application, but is also done implicitly when using OpenMP.
14084 1.1 mrg
14085 1.1 mrg On the Windows platform, the version with @var{kind=4} arguments uses
14086 1.1 mrg the @code{GetTickCount} function, whereas the @var{kind=8} version
14087 1.1 mrg uses @code{QueryPerformanceCounter} and
14088 1.1 mrg @code{QueryPerformanceCounterFrequency}. For more information, and
14089 1.1 mrg potential caveats, please see the platform documentation.
14090 1.1 mrg
14091 1.1 mrg @item @emph{Standard}:
14092 1.1.1.2 mrg Fortran 90 and later
14093 1.1 mrg
14094 1.1 mrg @item @emph{Class}:
14095 1.1 mrg Subroutine
14096 1.1 mrg
14097 1.1 mrg @item @emph{Syntax}:
14098 1.1 mrg @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
14099 1.1 mrg
14100 1.1 mrg @item @emph{Arguments}:
14101 1.1.1.2 mrg @multitable @columnfractions .20 .65
14102 1.1 mrg @item @var{COUNT} @tab (Optional) shall be a scalar of type
14103 1.1 mrg @code{INTEGER} with @code{INTENT(OUT)}.
14104 1.1 mrg @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type
14105 1.1 mrg @code{INTEGER} or @code{REAL}, with @code{INTENT(OUT)}.
14106 1.1 mrg @item @var{COUNT_MAX} @tab (Optional) shall be a scalar of type
14107 1.1 mrg @code{INTEGER} with @code{INTENT(OUT)}.
14108 1.1 mrg @end multitable
14109 1.1 mrg
14110 1.1 mrg @item @emph{Example}:
14111 1.1 mrg @smallexample
14112 1.1 mrg PROGRAM test_system_clock
14113 1.1 mrg INTEGER :: count, count_rate, count_max
14114 1.1 mrg CALL SYSTEM_CLOCK(count, count_rate, count_max)
14115 1.1 mrg WRITE(*,*) count, count_rate, count_max
14116 1.1 mrg END PROGRAM
14117 1.1 mrg @end smallexample
14118 1.1 mrg
14119 1.1 mrg @item @emph{See also}:
14120 1.1.1.2 mrg @ref{DATE_AND_TIME}, @gol
14121 1.1.1.2 mrg @ref{CPU_TIME}
14122 1.1 mrg @end table
14123 1.1 mrg
14124 1.1 mrg
14125 1.1 mrg
14126 1.1 mrg @node TAN
14127 1.1 mrg @section @code{TAN} --- Tangent function
14128 1.1 mrg @fnindex TAN
14129 1.1 mrg @fnindex DTAN
14130 1.1 mrg @cindex trigonometric function, tangent
14131 1.1 mrg @cindex tangent
14132 1.1 mrg
14133 1.1 mrg @table @asis
14134 1.1 mrg @item @emph{Description}:
14135 1.1 mrg @code{TAN(X)} computes the tangent of @var{X}.
14136 1.1 mrg
14137 1.1 mrg @item @emph{Standard}:
14138 1.1 mrg Fortran 77 and later, for a complex argument Fortran 2008 or later
14139 1.1 mrg
14140 1.1 mrg @item @emph{Class}:
14141 1.1 mrg Elemental function
14142 1.1 mrg
14143 1.1 mrg @item @emph{Syntax}:
14144 1.1 mrg @code{RESULT = TAN(X)}
14145 1.1 mrg
14146 1.1 mrg @item @emph{Arguments}:
14147 1.1 mrg @multitable @columnfractions .15 .70
14148 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
14149 1.1 mrg @end multitable
14150 1.1 mrg
14151 1.1 mrg @item @emph{Return value}:
14152 1.1 mrg The return value has same type and kind as @var{X}, and its value is in radians.
14153 1.1 mrg
14154 1.1 mrg @item @emph{Example}:
14155 1.1 mrg @smallexample
14156 1.1 mrg program test_tan
14157 1.1 mrg real(8) :: x = 0.165_8
14158 1.1 mrg x = tan(x)
14159 1.1 mrg end program test_tan
14160 1.1 mrg @end smallexample
14161 1.1 mrg
14162 1.1 mrg @item @emph{Specific names}:
14163 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
14164 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
14165 1.1.1.2 mrg @item @code{TAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
14166 1.1.1.2 mrg @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
14167 1.1 mrg @end multitable
14168 1.1 mrg
14169 1.1 mrg @item @emph{See also}:
14170 1.1.1.2 mrg Inverse function: @gol
14171 1.1.1.2 mrg @ref{ATAN} @gol
14172 1.1.1.2 mrg Degrees function: @gol
14173 1.1.1.2 mrg @ref{TAND}
14174 1.1 mrg @end table
14175 1.1 mrg
14176 1.1 mrg
14177 1.1 mrg
14178 1.1 mrg @node TAND
14179 1.1 mrg @section @code{TAND} --- Tangent function, degrees
14180 1.1 mrg @fnindex TAND
14181 1.1 mrg @fnindex DTAND
14182 1.1 mrg @cindex trigonometric function, tangent, degrees
14183 1.1 mrg @cindex tangent, degrees
14184 1.1 mrg
14185 1.1 mrg @table @asis
14186 1.1 mrg @item @emph{Description}:
14187 1.1 mrg @code{TAND(X)} computes the tangent of @var{X} in degrees.
14188 1.1 mrg
14189 1.1 mrg This function is for compatibility only and should be avoided in favor of
14190 1.1 mrg standard constructs wherever possible.
14191 1.1 mrg
14192 1.1 mrg @item @emph{Standard}:
14193 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math}.
14194 1.1 mrg
14195 1.1 mrg @item @emph{Class}:
14196 1.1 mrg Elemental function
14197 1.1 mrg
14198 1.1 mrg @item @emph{Syntax}:
14199 1.1 mrg @code{RESULT = TAND(X)}
14200 1.1 mrg
14201 1.1 mrg @item @emph{Arguments}:
14202 1.1 mrg @multitable @columnfractions .15 .70
14203 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
14204 1.1 mrg @end multitable
14205 1.1 mrg
14206 1.1 mrg @item @emph{Return value}:
14207 1.1 mrg The return value has same type and kind as @var{X}, and its value is in degrees.
14208 1.1 mrg
14209 1.1 mrg @item @emph{Example}:
14210 1.1 mrg @smallexample
14211 1.1 mrg program test_tand
14212 1.1 mrg real(8) :: x = 0.165_8
14213 1.1 mrg x = tand(x)
14214 1.1 mrg end program test_tand
14215 1.1 mrg @end smallexample
14216 1.1 mrg
14217 1.1 mrg @item @emph{Specific names}:
14218 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
14219 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
14220 1.1.1.2 mrg @item @code{TAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
14221 1.1.1.2 mrg @item @code{DTAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
14222 1.1 mrg @end multitable
14223 1.1 mrg
14224 1.1 mrg @item @emph{See also}:
14225 1.1.1.2 mrg Inverse function: @gol
14226 1.1.1.2 mrg @ref{ATAND} @gol
14227 1.1.1.2 mrg Radians function: @gol
14228 1.1.1.2 mrg @ref{TAN}
14229 1.1 mrg @end table
14230 1.1 mrg
14231 1.1 mrg
14232 1.1 mrg
14233 1.1 mrg @node TANH
14234 1.1 mrg @section @code{TANH} --- Hyperbolic tangent function
14235 1.1 mrg @fnindex TANH
14236 1.1 mrg @fnindex DTANH
14237 1.1 mrg @cindex hyperbolic tangent
14238 1.1 mrg @cindex hyperbolic function, tangent
14239 1.1 mrg @cindex tangent, hyperbolic
14240 1.1 mrg
14241 1.1 mrg @table @asis
14242 1.1 mrg @item @emph{Description}:
14243 1.1 mrg @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
14244 1.1 mrg
14245 1.1 mrg @item @emph{Standard}:
14246 1.1 mrg Fortran 77 and later, for a complex argument Fortran 2008 or later
14247 1.1 mrg
14248 1.1 mrg @item @emph{Class}:
14249 1.1 mrg Elemental function
14250 1.1 mrg
14251 1.1 mrg @item @emph{Syntax}:
14252 1.1 mrg @code{X = TANH(X)}
14253 1.1 mrg
14254 1.1 mrg @item @emph{Arguments}:
14255 1.1 mrg @multitable @columnfractions .15 .70
14256 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
14257 1.1 mrg @end multitable
14258 1.1 mrg
14259 1.1 mrg @item @emph{Return value}:
14260 1.1 mrg The return value has same type and kind as @var{X}. If @var{X} is
14261 1.1 mrg complex, the imaginary part of the result is in radians. If @var{X}
14262 1.1 mrg is @code{REAL}, the return value lies in the range
14263 1.1 mrg @math{ - 1 \leq tanh(x) \leq 1 }.
14264 1.1 mrg
14265 1.1 mrg @item @emph{Example}:
14266 1.1 mrg @smallexample
14267 1.1 mrg program test_tanh
14268 1.1 mrg real(8) :: x = 2.1_8
14269 1.1 mrg x = tanh(x)
14270 1.1 mrg end program test_tanh
14271 1.1 mrg @end smallexample
14272 1.1 mrg
14273 1.1 mrg @item @emph{Specific names}:
14274 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
14275 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
14276 1.1.1.2 mrg @item @code{TANH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
14277 1.1.1.2 mrg @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
14278 1.1 mrg @end multitable
14279 1.1 mrg
14280 1.1 mrg @item @emph{See also}:
14281 1.1 mrg @ref{ATANH}
14282 1.1 mrg @end table
14283 1.1 mrg
14284 1.1 mrg
14285 1.1 mrg
14286 1.1 mrg @node THIS_IMAGE
14287 1.1 mrg @section @code{THIS_IMAGE} --- Function that returns the cosubscript index of this image
14288 1.1 mrg @fnindex THIS_IMAGE
14289 1.1 mrg @cindex coarray, @code{THIS_IMAGE}
14290 1.1 mrg @cindex images, index of this image
14291 1.1 mrg
14292 1.1 mrg @table @asis
14293 1.1 mrg @item @emph{Description}:
14294 1.1 mrg Returns the cosubscript for this image.
14295 1.1 mrg
14296 1.1 mrg @item @emph{Standard}:
14297 1.1 mrg Fortran 2008 and later. With @var{DISTANCE} argument,
14298 1.1 mrg Technical Specification (TS) 18508 or later
14299 1.1 mrg
14300 1.1 mrg @item @emph{Class}:
14301 1.1 mrg Transformational function
14302 1.1 mrg
14303 1.1 mrg @item @emph{Syntax}:
14304 1.1 mrg @multitable @columnfractions .80
14305 1.1 mrg @item @code{RESULT = THIS_IMAGE()}
14306 1.1 mrg @item @code{RESULT = THIS_IMAGE(DISTANCE)}
14307 1.1 mrg @item @code{RESULT = THIS_IMAGE(COARRAY [, DIM])}
14308 1.1 mrg @end multitable
14309 1.1 mrg
14310 1.1 mrg @item @emph{Arguments}:
14311 1.1 mrg @multitable @columnfractions .15 .70
14312 1.1 mrg @item @var{DISTANCE} @tab (optional, intent(in)) Nonnegative scalar integer
14313 1.1 mrg (not permitted together with @var{COARRAY}).
14314 1.1 mrg @item @var{COARRAY} @tab Coarray of any type (optional; if @var{DIM}
14315 1.1 mrg present, required).
14316 1.1 mrg @item @var{DIM} @tab default integer scalar (optional). If present,
14317 1.1 mrg @var{DIM} shall be between one and the corank of @var{COARRAY}.
14318 1.1 mrg @end multitable
14319 1.1 mrg
14320 1.1 mrg
14321 1.1 mrg @item @emph{Return value}:
14322 1.1 mrg Default integer. If @var{COARRAY} is not present, it is scalar; if
14323 1.1 mrg @var{DISTANCE} is not present or has value 0, its value is the image index on
14324 1.1 mrg the invoking image for the current team, for values smaller or equal
14325 1.1 mrg distance to the initial team, it returns the image index on the ancestor team
14326 1.1 mrg which has a distance of @var{DISTANCE} from the invoking team. If
14327 1.1 mrg @var{DISTANCE} is larger than the distance to the initial team, the image
14328 1.1 mrg index of the initial team is returned. Otherwise when the @var{COARRAY} is
14329 1.1 mrg present, if @var{DIM} is not present, a rank-1 array with corank elements is
14330 1.1 mrg returned, containing the cosubscripts for @var{COARRAY} specifying the invoking
14331 1.1 mrg image. If @var{DIM} is present, a scalar is returned, with the value of
14332 1.1 mrg the @var{DIM} element of @code{THIS_IMAGE(COARRAY)}.
14333 1.1 mrg
14334 1.1 mrg @item @emph{Example}:
14335 1.1 mrg @smallexample
14336 1.1 mrg INTEGER :: value[*]
14337 1.1 mrg INTEGER :: i
14338 1.1 mrg value = THIS_IMAGE()
14339 1.1 mrg SYNC ALL
14340 1.1 mrg IF (THIS_IMAGE() == 1) THEN
14341 1.1 mrg DO i = 1, NUM_IMAGES()
14342 1.1 mrg WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
14343 1.1 mrg END DO
14344 1.1 mrg END IF
14345 1.1 mrg
14346 1.1 mrg ! Check whether the current image is the initial image
14347 1.1 mrg IF (THIS_IMAGE(HUGE(1)) /= THIS_IMAGE())
14348 1.1 mrg error stop "something is rotten here"
14349 1.1 mrg @end smallexample
14350 1.1 mrg
14351 1.1 mrg @item @emph{See also}:
14352 1.1.1.2 mrg @ref{NUM_IMAGES}, @gol
14353 1.1.1.2 mrg @ref{IMAGE_INDEX}
14354 1.1 mrg @end table
14355 1.1 mrg
14356 1.1 mrg
14357 1.1 mrg
14358 1.1 mrg @node TIME
14359 1.1 mrg @section @code{TIME} --- Time function
14360 1.1 mrg @fnindex TIME
14361 1.1 mrg @cindex time, current
14362 1.1 mrg @cindex current time
14363 1.1 mrg
14364 1.1 mrg @table @asis
14365 1.1 mrg @item @emph{Description}:
14366 1.1 mrg Returns the current time encoded as an integer (in the manner of the
14367 1.1 mrg function @code{time(3)} in the C standard library). This value is
14368 1.1 mrg suitable for passing to @ref{CTIME}, @ref{GMTIME}, and @ref{LTIME}.
14369 1.1 mrg
14370 1.1 mrg This intrinsic is not fully portable, such as to systems with 32-bit
14371 1.1 mrg @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
14372 1.1 mrg the values returned by this intrinsic might be, or become, negative, or
14373 1.1 mrg numerically less than previous values, during a single run of the
14374 1.1 mrg compiled program.
14375 1.1 mrg
14376 1.1 mrg See @ref{TIME8}, for information on a similar intrinsic that might be
14377 1.1 mrg portable to more GNU Fortran implementations, though to fewer Fortran
14378 1.1 mrg compilers.
14379 1.1 mrg
14380 1.1 mrg @item @emph{Standard}:
14381 1.1 mrg GNU extension
14382 1.1 mrg
14383 1.1 mrg @item @emph{Class}:
14384 1.1 mrg Function
14385 1.1 mrg
14386 1.1 mrg @item @emph{Syntax}:
14387 1.1 mrg @code{RESULT = TIME()}
14388 1.1 mrg
14389 1.1 mrg @item @emph{Return value}:
14390 1.1 mrg The return value is a scalar of type @code{INTEGER(4)}.
14391 1.1 mrg
14392 1.1 mrg @item @emph{See also}:
14393 1.1.1.2 mrg @ref{DATE_AND_TIME}, @gol
14394 1.1.1.2 mrg @ref{CTIME}, @gol
14395 1.1.1.2 mrg @ref{GMTIME}, @gol
14396 1.1.1.2 mrg @ref{LTIME}, @gol
14397 1.1.1.2 mrg @ref{MCLOCK}, @gol
14398 1.1.1.2 mrg @ref{TIME8}
14399 1.1 mrg @end table
14400 1.1 mrg
14401 1.1 mrg
14402 1.1 mrg
14403 1.1 mrg @node TIME8
14404 1.1 mrg @section @code{TIME8} --- Time function (64-bit)
14405 1.1 mrg @fnindex TIME8
14406 1.1 mrg @cindex time, current
14407 1.1 mrg @cindex current time
14408 1.1 mrg
14409 1.1 mrg @table @asis
14410 1.1 mrg @item @emph{Description}:
14411 1.1 mrg Returns the current time encoded as an integer (in the manner of the
14412 1.1 mrg function @code{time(3)} in the C standard library). This value is
14413 1.1 mrg suitable for passing to @ref{CTIME}, @ref{GMTIME}, and @ref{LTIME}.
14414 1.1 mrg
14415 1.1 mrg @emph{Warning:} this intrinsic does not increase the range of the timing
14416 1.1 mrg values over that returned by @code{time(3)}. On a system with a 32-bit
14417 1.1 mrg @code{time(3)}, @code{TIME8} will return a 32-bit value, even though
14418 1.1 mrg it is converted to a 64-bit @code{INTEGER(8)} value. That means
14419 1.1 mrg overflows of the 32-bit value can still occur. Therefore, the values
14420 1.1 mrg returned by this intrinsic might be or become negative or numerically
14421 1.1 mrg less than previous values during a single run of the compiled program.
14422 1.1 mrg
14423 1.1 mrg @item @emph{Standard}:
14424 1.1 mrg GNU extension
14425 1.1 mrg
14426 1.1 mrg @item @emph{Class}:
14427 1.1 mrg Function
14428 1.1 mrg
14429 1.1 mrg @item @emph{Syntax}:
14430 1.1 mrg @code{RESULT = TIME8()}
14431 1.1 mrg
14432 1.1 mrg @item @emph{Return value}:
14433 1.1 mrg The return value is a scalar of type @code{INTEGER(8)}.
14434 1.1 mrg
14435 1.1 mrg @item @emph{See also}:
14436 1.1.1.2 mrg @ref{DATE_AND_TIME}, @gol
14437 1.1.1.2 mrg @ref{CTIME}, @gol
14438 1.1.1.2 mrg @ref{GMTIME}, @gol
14439 1.1.1.2 mrg @ref{LTIME}, @gol
14440 1.1.1.2 mrg @ref{MCLOCK8}, @gol
14441 1.1.1.2 mrg @ref{TIME}
14442 1.1 mrg @end table
14443 1.1 mrg
14444 1.1 mrg
14445 1.1 mrg
14446 1.1 mrg @node TINY
14447 1.1 mrg @section @code{TINY} --- Smallest positive number of a real kind
14448 1.1 mrg @fnindex TINY
14449 1.1 mrg @cindex limits, smallest number
14450 1.1 mrg @cindex model representation, smallest number
14451 1.1 mrg
14452 1.1 mrg @table @asis
14453 1.1 mrg @item @emph{Description}:
14454 1.1 mrg @code{TINY(X)} returns the smallest positive (non zero) number
14455 1.1 mrg in the model of the type of @code{X}.
14456 1.1 mrg
14457 1.1 mrg @item @emph{Standard}:
14458 1.1.1.2 mrg Fortran 90 and later
14459 1.1 mrg
14460 1.1 mrg @item @emph{Class}:
14461 1.1 mrg Inquiry function
14462 1.1 mrg
14463 1.1 mrg @item @emph{Syntax}:
14464 1.1 mrg @code{RESULT = TINY(X)}
14465 1.1 mrg
14466 1.1 mrg @item @emph{Arguments}:
14467 1.1 mrg @multitable @columnfractions .15 .70
14468 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}.
14469 1.1 mrg @end multitable
14470 1.1 mrg
14471 1.1 mrg @item @emph{Return value}:
14472 1.1 mrg The return value is of the same type and kind as @var{X}
14473 1.1 mrg
14474 1.1 mrg @item @emph{Example}:
14475 1.1 mrg See @code{HUGE} for an example.
14476 1.1 mrg @end table
14477 1.1 mrg
14478 1.1 mrg
14479 1.1 mrg
14480 1.1 mrg @node TRAILZ
14481 1.1 mrg @section @code{TRAILZ} --- Number of trailing zero bits of an integer
14482 1.1 mrg @fnindex TRAILZ
14483 1.1 mrg @cindex zero bits
14484 1.1 mrg
14485 1.1 mrg @table @asis
14486 1.1 mrg @item @emph{Description}:
14487 1.1 mrg @code{TRAILZ} returns the number of trailing zero bits of an integer.
14488 1.1 mrg
14489 1.1 mrg @item @emph{Standard}:
14490 1.1 mrg Fortran 2008 and later
14491 1.1 mrg
14492 1.1 mrg @item @emph{Class}:
14493 1.1 mrg Elemental function
14494 1.1 mrg
14495 1.1 mrg @item @emph{Syntax}:
14496 1.1 mrg @code{RESULT = TRAILZ(I)}
14497 1.1 mrg
14498 1.1 mrg @item @emph{Arguments}:
14499 1.1 mrg @multitable @columnfractions .15 .70
14500 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}.
14501 1.1 mrg @end multitable
14502 1.1 mrg
14503 1.1 mrg @item @emph{Return value}:
14504 1.1 mrg The type of the return value is the default @code{INTEGER}.
14505 1.1 mrg If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
14506 1.1 mrg
14507 1.1 mrg @item @emph{Example}:
14508 1.1 mrg @smallexample
14509 1.1 mrg PROGRAM test_trailz
14510 1.1 mrg WRITE (*,*) TRAILZ(8) ! prints 3
14511 1.1 mrg END PROGRAM
14512 1.1 mrg @end smallexample
14513 1.1 mrg
14514 1.1 mrg @item @emph{See also}:
14515 1.1.1.2 mrg @ref{BIT_SIZE}, @gol
14516 1.1.1.2 mrg @ref{LEADZ}, @gol
14517 1.1.1.2 mrg @ref{POPPAR}, @gol
14518 1.1.1.2 mrg @ref{POPCNT}
14519 1.1 mrg @end table
14520 1.1 mrg
14521 1.1 mrg
14522 1.1 mrg
14523 1.1 mrg @node TRANSFER
14524 1.1 mrg @section @code{TRANSFER} --- Transfer bit patterns
14525 1.1 mrg @fnindex TRANSFER
14526 1.1 mrg @cindex bits, move
14527 1.1 mrg @cindex type cast
14528 1.1 mrg
14529 1.1 mrg @table @asis
14530 1.1 mrg @item @emph{Description}:
14531 1.1 mrg Interprets the bitwise representation of @var{SOURCE} in memory as if it
14532 1.1 mrg is the representation of a variable or array of the same type and type
14533 1.1 mrg parameters as @var{MOLD}.
14534 1.1 mrg
14535 1.1 mrg This is approximately equivalent to the C concept of @emph{casting} one
14536 1.1 mrg type to another.
14537 1.1 mrg
14538 1.1 mrg @item @emph{Standard}:
14539 1.1.1.2 mrg Fortran 90 and later
14540 1.1 mrg
14541 1.1 mrg @item @emph{Class}:
14542 1.1 mrg Transformational function
14543 1.1 mrg
14544 1.1 mrg @item @emph{Syntax}:
14545 1.1 mrg @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
14546 1.1 mrg
14547 1.1 mrg @item @emph{Arguments}:
14548 1.1 mrg @multitable @columnfractions .15 .70
14549 1.1 mrg @item @var{SOURCE} @tab Shall be a scalar or an array of any type.
14550 1.1 mrg @item @var{MOLD} @tab Shall be a scalar or an array of any type.
14551 1.1 mrg @item @var{SIZE} @tab (Optional) shall be a scalar of type
14552 1.1 mrg @code{INTEGER}.
14553 1.1 mrg @end multitable
14554 1.1 mrg
14555 1.1 mrg @item @emph{Return value}:
14556 1.1 mrg The result has the same type as @var{MOLD}, with the bit level
14557 1.1 mrg representation of @var{SOURCE}. If @var{SIZE} is present, the result is
14558 1.1 mrg a one-dimensional array of length @var{SIZE}. If @var{SIZE} is absent
14559 1.1 mrg but @var{MOLD} is an array (of any size or shape), the result is a one-
14560 1.1 mrg dimensional array of the minimum length needed to contain the entirety
14561 1.1 mrg of the bitwise representation of @var{SOURCE}. If @var{SIZE} is absent
14562 1.1 mrg and @var{MOLD} is a scalar, the result is a scalar.
14563 1.1 mrg
14564 1.1 mrg If the bitwise representation of the result is longer than that of
14565 1.1 mrg @var{SOURCE}, then the leading bits of the result correspond to those of
14566 1.1 mrg @var{SOURCE} and any trailing bits are filled arbitrarily.
14567 1.1 mrg
14568 1.1 mrg When the resulting bit representation does not correspond to a valid
14569 1.1 mrg representation of a variable of the same type as @var{MOLD}, the results
14570 1.1 mrg are undefined, and subsequent operations on the result cannot be
14571 1.1 mrg guaranteed to produce sensible behavior. For example, it is possible to
14572 1.1 mrg create @code{LOGICAL} variables for which @code{@var{VAR}} and
14573 1.1 mrg @code{.NOT.@var{VAR}} both appear to be true.
14574 1.1 mrg
14575 1.1 mrg @item @emph{Example}:
14576 1.1 mrg @smallexample
14577 1.1 mrg PROGRAM test_transfer
14578 1.1 mrg integer :: x = 2143289344
14579 1.1 mrg print *, transfer(x, 1.0) ! prints "NaN" on i686
14580 1.1 mrg END PROGRAM
14581 1.1 mrg @end smallexample
14582 1.1 mrg @end table
14583 1.1 mrg
14584 1.1 mrg
14585 1.1 mrg
14586 1.1 mrg @node TRANSPOSE
14587 1.1 mrg @section @code{TRANSPOSE} --- Transpose an array of rank two
14588 1.1 mrg @fnindex TRANSPOSE
14589 1.1 mrg @cindex array, transpose
14590 1.1 mrg @cindex matrix, transpose
14591 1.1 mrg @cindex transpose
14592 1.1 mrg
14593 1.1 mrg @table @asis
14594 1.1 mrg @item @emph{Description}:
14595 1.1 mrg Transpose an array of rank two. Element (i, j) of the result has the value
14596 1.1 mrg @code{MATRIX(j, i)}, for all i, j.
14597 1.1 mrg
14598 1.1 mrg @item @emph{Standard}:
14599 1.1.1.2 mrg Fortran 90 and later
14600 1.1 mrg
14601 1.1 mrg @item @emph{Class}:
14602 1.1 mrg Transformational function
14603 1.1 mrg
14604 1.1 mrg @item @emph{Syntax}:
14605 1.1 mrg @code{RESULT = TRANSPOSE(MATRIX)}
14606 1.1 mrg
14607 1.1 mrg @item @emph{Arguments}:
14608 1.1 mrg @multitable @columnfractions .15 .70
14609 1.1 mrg @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
14610 1.1 mrg @end multitable
14611 1.1 mrg
14612 1.1 mrg @item @emph{Return value}:
14613 1.1 mrg The result has the same type as @var{MATRIX}, and has shape
14614 1.1 mrg @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
14615 1.1 mrg @end table
14616 1.1 mrg
14617 1.1 mrg
14618 1.1 mrg
14619 1.1 mrg @node TRIM
14620 1.1 mrg @section @code{TRIM} --- Remove trailing blank characters of a string
14621 1.1 mrg @fnindex TRIM
14622 1.1 mrg @cindex string, remove trailing whitespace
14623 1.1 mrg
14624 1.1 mrg @table @asis
14625 1.1 mrg @item @emph{Description}:
14626 1.1 mrg Removes trailing blank characters of a string.
14627 1.1 mrg
14628 1.1 mrg @item @emph{Standard}:
14629 1.1.1.2 mrg Fortran 90 and later
14630 1.1 mrg
14631 1.1 mrg @item @emph{Class}:
14632 1.1 mrg Transformational function
14633 1.1 mrg
14634 1.1 mrg @item @emph{Syntax}:
14635 1.1 mrg @code{RESULT = TRIM(STRING)}
14636 1.1 mrg
14637 1.1 mrg @item @emph{Arguments}:
14638 1.1 mrg @multitable @columnfractions .15 .70
14639 1.1 mrg @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}.
14640 1.1 mrg @end multitable
14641 1.1 mrg
14642 1.1 mrg @item @emph{Return value}:
14643 1.1 mrg A scalar of type @code{CHARACTER} which length is that of @var{STRING}
14644 1.1 mrg less the number of trailing blanks.
14645 1.1 mrg
14646 1.1 mrg @item @emph{Example}:
14647 1.1 mrg @smallexample
14648 1.1 mrg PROGRAM test_trim
14649 1.1 mrg CHARACTER(len=10), PARAMETER :: s = "GFORTRAN "
14650 1.1 mrg WRITE(*,*) LEN(s), LEN(TRIM(s)) ! "10 8", with/without trailing blanks
14651 1.1 mrg END PROGRAM
14652 1.1 mrg @end smallexample
14653 1.1 mrg
14654 1.1 mrg @item @emph{See also}:
14655 1.1.1.2 mrg @ref{ADJUSTL}, @gol
14656 1.1.1.2 mrg @ref{ADJUSTR}
14657 1.1 mrg @end table
14658 1.1 mrg
14659 1.1 mrg
14660 1.1 mrg
14661 1.1 mrg @node TTYNAM
14662 1.1 mrg @section @code{TTYNAM} --- Get the name of a terminal device.
14663 1.1 mrg @fnindex TTYNAM
14664 1.1 mrg @cindex system, terminal
14665 1.1 mrg
14666 1.1 mrg @table @asis
14667 1.1 mrg @item @emph{Description}:
14668 1.1 mrg Get the name of a terminal device. For more information,
14669 1.1 mrg see @code{ttyname(3)}.
14670 1.1 mrg
14671 1.1 mrg This intrinsic is provided in both subroutine and function forms;
14672 1.1 mrg however, only one form can be used in any given program unit.
14673 1.1 mrg
14674 1.1 mrg @item @emph{Standard}:
14675 1.1 mrg GNU extension
14676 1.1 mrg
14677 1.1 mrg @item @emph{Class}:
14678 1.1 mrg Subroutine, function
14679 1.1 mrg
14680 1.1 mrg @item @emph{Syntax}:
14681 1.1 mrg @multitable @columnfractions .80
14682 1.1 mrg @item @code{CALL TTYNAM(UNIT, NAME)}
14683 1.1 mrg @item @code{NAME = TTYNAM(UNIT)}
14684 1.1 mrg @end multitable
14685 1.1 mrg
14686 1.1 mrg @item @emph{Arguments}:
14687 1.1 mrg @multitable @columnfractions .15 .70
14688 1.1 mrg @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
14689 1.1 mrg @item @var{NAME} @tab Shall be of type @code{CHARACTER}.
14690 1.1 mrg @end multitable
14691 1.1 mrg
14692 1.1 mrg @item @emph{Example}:
14693 1.1 mrg @smallexample
14694 1.1 mrg PROGRAM test_ttynam
14695 1.1 mrg INTEGER :: unit
14696 1.1 mrg DO unit = 1, 10
14697 1.1 mrg IF (isatty(unit=unit)) write(*,*) ttynam(unit)
14698 1.1 mrg END DO
14699 1.1 mrg END PROGRAM
14700 1.1 mrg @end smallexample
14701 1.1 mrg
14702 1.1 mrg @item @emph{See also}:
14703 1.1 mrg @ref{ISATTY}
14704 1.1 mrg @end table
14705 1.1 mrg
14706 1.1 mrg
14707 1.1 mrg
14708 1.1 mrg @node UBOUND
14709 1.1 mrg @section @code{UBOUND} --- Upper dimension bounds of an array
14710 1.1 mrg @fnindex UBOUND
14711 1.1 mrg @cindex array, upper bound
14712 1.1 mrg
14713 1.1 mrg @table @asis
14714 1.1 mrg @item @emph{Description}:
14715 1.1 mrg Returns the upper bounds of an array, or a single upper bound
14716 1.1 mrg along the @var{DIM} dimension.
14717 1.1 mrg @item @emph{Standard}:
14718 1.1.1.2 mrg Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later
14719 1.1 mrg
14720 1.1 mrg @item @emph{Class}:
14721 1.1 mrg Inquiry function
14722 1.1 mrg
14723 1.1 mrg @item @emph{Syntax}:
14724 1.1 mrg @code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])}
14725 1.1 mrg
14726 1.1 mrg @item @emph{Arguments}:
14727 1.1 mrg @multitable @columnfractions .15 .70
14728 1.1 mrg @item @var{ARRAY} @tab Shall be an array, of any type.
14729 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
14730 1.1 mrg @item @var{KIND}@tab (Optional) An @code{INTEGER} initialization
14731 1.1 mrg expression indicating the kind parameter of the result.
14732 1.1 mrg @end multitable
14733 1.1 mrg
14734 1.1 mrg @item @emph{Return value}:
14735 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
14736 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
14737 1.1 mrg If @var{DIM} is absent, the result is an array of the upper bounds of
14738 1.1 mrg @var{ARRAY}. If @var{DIM} is present, the result is a scalar
14739 1.1 mrg corresponding to the upper bound of the array along that dimension. If
14740 1.1 mrg @var{ARRAY} is an expression rather than a whole array or array
14741 1.1 mrg structure component, or if it has a zero extent along the relevant
14742 1.1 mrg dimension, the upper bound is taken to be the number of elements along
14743 1.1 mrg the relevant dimension.
14744 1.1 mrg
14745 1.1 mrg @item @emph{See also}:
14746 1.1.1.2 mrg @ref{LBOUND}, @gol
14747 1.1.1.2 mrg @ref{LCOBOUND}
14748 1.1 mrg @end table
14749 1.1 mrg
14750 1.1 mrg
14751 1.1 mrg
14752 1.1 mrg @node UCOBOUND
14753 1.1 mrg @section @code{UCOBOUND} --- Upper codimension bounds of an array
14754 1.1 mrg @fnindex UCOBOUND
14755 1.1 mrg @cindex coarray, upper bound
14756 1.1 mrg
14757 1.1 mrg @table @asis
14758 1.1 mrg @item @emph{Description}:
14759 1.1 mrg Returns the upper cobounds of a coarray, or a single upper cobound
14760 1.1 mrg along the @var{DIM} codimension.
14761 1.1 mrg @item @emph{Standard}:
14762 1.1 mrg Fortran 2008 and later
14763 1.1 mrg
14764 1.1 mrg @item @emph{Class}:
14765 1.1 mrg Inquiry function
14766 1.1 mrg
14767 1.1 mrg @item @emph{Syntax}:
14768 1.1 mrg @code{RESULT = UCOBOUND(COARRAY [, DIM [, KIND]])}
14769 1.1 mrg
14770 1.1 mrg @item @emph{Arguments}:
14771 1.1 mrg @multitable @columnfractions .15 .70
14772 1.1 mrg @item @var{ARRAY} @tab Shall be an coarray, of any type.
14773 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
14774 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
14775 1.1 mrg expression indicating the kind parameter of the result.
14776 1.1 mrg @end multitable
14777 1.1 mrg
14778 1.1 mrg @item @emph{Return value}:
14779 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
14780 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
14781 1.1 mrg If @var{DIM} is absent, the result is an array of the lower cobounds of
14782 1.1 mrg @var{COARRAY}. If @var{DIM} is present, the result is a scalar
14783 1.1 mrg corresponding to the lower cobound of the array along that codimension.
14784 1.1 mrg
14785 1.1 mrg @item @emph{See also}:
14786 1.1.1.2 mrg @ref{LCOBOUND}, @gol
14787 1.1.1.2 mrg @ref{LBOUND}
14788 1.1 mrg @end table
14789 1.1 mrg
14790 1.1 mrg
14791 1.1 mrg
14792 1.1 mrg @node UMASK
14793 1.1 mrg @section @code{UMASK} --- Set the file creation mask
14794 1.1 mrg @fnindex UMASK
14795 1.1 mrg @cindex file system, file creation mask
14796 1.1 mrg
14797 1.1 mrg @table @asis
14798 1.1 mrg @item @emph{Description}:
14799 1.1 mrg Sets the file creation mask to @var{MASK}. If called as a function, it
14800 1.1 mrg returns the old value. If called as a subroutine and argument @var{OLD}
14801 1.1 mrg if it is supplied, it is set to the old value. See @code{umask(2)}.
14802 1.1 mrg
14803 1.1 mrg @item @emph{Standard}:
14804 1.1 mrg GNU extension
14805 1.1 mrg
14806 1.1 mrg @item @emph{Class}:
14807 1.1 mrg Subroutine, function
14808 1.1 mrg
14809 1.1 mrg @item @emph{Syntax}:
14810 1.1 mrg @multitable @columnfractions .80
14811 1.1 mrg @item @code{CALL UMASK(MASK [, OLD])}
14812 1.1 mrg @item @code{OLD = UMASK(MASK)}
14813 1.1 mrg @end multitable
14814 1.1 mrg
14815 1.1 mrg @item @emph{Arguments}:
14816 1.1 mrg @multitable @columnfractions .15 .70
14817 1.1 mrg @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER}.
14818 1.1 mrg @item @var{OLD} @tab (Optional) Shall be a scalar of type
14819 1.1 mrg @code{INTEGER}.
14820 1.1 mrg @end multitable
14821 1.1 mrg
14822 1.1 mrg @end table
14823 1.1 mrg
14824 1.1 mrg
14825 1.1 mrg
14826 1.1 mrg @node UNLINK
14827 1.1 mrg @section @code{UNLINK} --- Remove a file from the file system
14828 1.1 mrg @fnindex UNLINK
14829 1.1 mrg @cindex file system, remove file
14830 1.1 mrg
14831 1.1 mrg @table @asis
14832 1.1 mrg @item @emph{Description}:
14833 1.1 mrg Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
14834 1.1 mrg used to mark the end of the name in @var{PATH}; otherwise, trailing
14835 1.1 mrg blanks in the file name are ignored. If the @var{STATUS} argument is
14836 1.1 mrg supplied, it contains 0 on success or a nonzero error code upon return;
14837 1.1 mrg see @code{unlink(2)}.
14838 1.1 mrg
14839 1.1 mrg This intrinsic is provided in both subroutine and function forms;
14840 1.1 mrg however, only one form can be used in any given program unit.
14841 1.1 mrg
14842 1.1 mrg @item @emph{Standard}:
14843 1.1 mrg GNU extension
14844 1.1 mrg
14845 1.1 mrg @item @emph{Class}:
14846 1.1 mrg Subroutine, function
14847 1.1 mrg
14848 1.1 mrg @item @emph{Syntax}:
14849 1.1 mrg @multitable @columnfractions .80
14850 1.1 mrg @item @code{CALL UNLINK(PATH [, STATUS])}
14851 1.1 mrg @item @code{STATUS = UNLINK(PATH)}
14852 1.1 mrg @end multitable
14853 1.1 mrg
14854 1.1 mrg @item @emph{Arguments}:
14855 1.1 mrg @multitable @columnfractions .15 .70
14856 1.1 mrg @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
14857 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
14858 1.1 mrg @end multitable
14859 1.1 mrg
14860 1.1 mrg @item @emph{See also}:
14861 1.1.1.2 mrg @ref{LINK}, @gol
14862 1.1.1.2 mrg @ref{SYMLNK}
14863 1.1 mrg @end table
14864 1.1 mrg
14865 1.1 mrg
14866 1.1 mrg
14867 1.1 mrg @node UNPACK
14868 1.1 mrg @section @code{UNPACK} --- Unpack an array of rank one into an array
14869 1.1 mrg @fnindex UNPACK
14870 1.1 mrg @cindex array, unpacking
14871 1.1 mrg @cindex array, increase dimension
14872 1.1 mrg @cindex array, scatter elements
14873 1.1 mrg
14874 1.1 mrg @table @asis
14875 1.1 mrg @item @emph{Description}:
14876 1.1 mrg Store the elements of @var{VECTOR} in an array of higher rank.
14877 1.1 mrg
14878 1.1 mrg @item @emph{Standard}:
14879 1.1.1.2 mrg Fortran 90 and later
14880 1.1 mrg
14881 1.1 mrg @item @emph{Class}:
14882 1.1 mrg Transformational function
14883 1.1 mrg
14884 1.1 mrg @item @emph{Syntax}:
14885 1.1 mrg @code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
14886 1.1 mrg
14887 1.1 mrg @item @emph{Arguments}:
14888 1.1 mrg @multitable @columnfractions .15 .70
14889 1.1 mrg @item @var{VECTOR} @tab Shall be an array of any type and rank one. It
14890 1.1 mrg shall have at least as many elements as @var{MASK} has @code{TRUE} values.
14891 1.1 mrg @item @var{MASK} @tab Shall be an array of type @code{LOGICAL}.
14892 1.1 mrg @item @var{FIELD} @tab Shall be of the same type as @var{VECTOR} and have
14893 1.1 mrg the same shape as @var{MASK}.
14894 1.1 mrg @end multitable
14895 1.1 mrg
14896 1.1 mrg @item @emph{Return value}:
14897 1.1 mrg The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
14898 1.1 mrg of @var{MASK} replaced by values from @var{VECTOR} in array element order.
14899 1.1 mrg
14900 1.1 mrg @item @emph{Example}:
14901 1.1 mrg @smallexample
14902 1.1 mrg PROGRAM test_unpack
14903 1.1 mrg integer :: vector(2) = (/1,1/)
14904 1.1 mrg logical :: mask(4) = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
14905 1.1 mrg integer :: field(2,2) = 0, unity(2,2)
14906 1.1 mrg
14907 1.1 mrg ! result: unity matrix
14908 1.1 mrg unity = unpack(vector, reshape(mask, (/2,2/)), field)
14909 1.1 mrg END PROGRAM
14910 1.1 mrg @end smallexample
14911 1.1 mrg
14912 1.1 mrg @item @emph{See also}:
14913 1.1.1.2 mrg @ref{PACK}, @gol
14914 1.1.1.2 mrg @ref{SPREAD}
14915 1.1 mrg @end table
14916 1.1 mrg
14917 1.1 mrg
14918 1.1 mrg
14919 1.1 mrg @node VERIFY
14920 1.1 mrg @section @code{VERIFY} --- Scan a string for characters not a given set
14921 1.1 mrg @fnindex VERIFY
14922 1.1 mrg @cindex string, find missing set
14923 1.1 mrg
14924 1.1 mrg @table @asis
14925 1.1 mrg @item @emph{Description}:
14926 1.1 mrg Verifies that all the characters in @var{STRING} belong to the set of
14927 1.1 mrg characters in @var{SET}.
14928 1.1 mrg
14929 1.1 mrg If @var{BACK} is either absent or equals @code{FALSE}, this function
14930 1.1 mrg returns the position of the leftmost character of @var{STRING} that is
14931 1.1 mrg not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost
14932 1.1 mrg position is returned. If all characters of @var{STRING} are found in
14933 1.1 mrg @var{SET}, the result is zero.
14934 1.1 mrg
14935 1.1 mrg @item @emph{Standard}:
14936 1.1.1.2 mrg Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later
14937 1.1 mrg
14938 1.1 mrg @item @emph{Class}:
14939 1.1 mrg Elemental function
14940 1.1 mrg
14941 1.1 mrg @item @emph{Syntax}:
14942 1.1 mrg @code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])}
14943 1.1 mrg
14944 1.1 mrg @item @emph{Arguments}:
14945 1.1 mrg @multitable @columnfractions .15 .70
14946 1.1 mrg @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
14947 1.1 mrg @item @var{SET} @tab Shall be of type @code{CHARACTER}.
14948 1.1 mrg @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
14949 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
14950 1.1 mrg expression indicating the kind parameter of the result.
14951 1.1 mrg @end multitable
14952 1.1 mrg
14953 1.1 mrg @item @emph{Return value}:
14954 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
14955 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
14956 1.1 mrg
14957 1.1 mrg @item @emph{Example}:
14958 1.1 mrg @smallexample
14959 1.1 mrg PROGRAM test_verify
14960 1.1 mrg WRITE(*,*) VERIFY("FORTRAN", "AO") ! 1, found 'F'
14961 1.1 mrg WRITE(*,*) VERIFY("FORTRAN", "FOO") ! 3, found 'R'
14962 1.1 mrg WRITE(*,*) VERIFY("FORTRAN", "C++") ! 1, found 'F'
14963 1.1 mrg WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.) ! 7, found 'N'
14964 1.1 mrg WRITE(*,*) VERIFY("FORTRAN", "FORTRAN") ! 0' found none
14965 1.1 mrg END PROGRAM
14966 1.1 mrg @end smallexample
14967 1.1 mrg
14968 1.1 mrg @item @emph{See also}:
14969 1.1.1.2 mrg @ref{SCAN}, @gol
14970 1.1.1.2 mrg @ref{INDEX intrinsic}
14971 1.1 mrg @end table
14972 1.1 mrg
14973 1.1 mrg
14974 1.1 mrg
14975 1.1 mrg @node XOR
14976 1.1 mrg @section @code{XOR} --- Bitwise logical exclusive OR
14977 1.1 mrg @fnindex XOR
14978 1.1 mrg @cindex bitwise logical exclusive or
14979 1.1 mrg @cindex logical exclusive or, bitwise
14980 1.1 mrg
14981 1.1 mrg @table @asis
14982 1.1 mrg @item @emph{Description}:
14983 1.1 mrg Bitwise logical exclusive or.
14984 1.1 mrg
14985 1.1 mrg This intrinsic routine is provided for backwards compatibility with
14986 1.1 mrg GNU Fortran 77. For integer arguments, programmers should consider
14987 1.1 mrg the use of the @ref{IEOR} intrinsic and for logical arguments the
14988 1.1 mrg @code{.NEQV.} operator, which are both defined by the Fortran standard.
14989 1.1 mrg
14990 1.1 mrg @item @emph{Standard}:
14991 1.1 mrg GNU extension
14992 1.1 mrg
14993 1.1 mrg @item @emph{Class}:
14994 1.1 mrg Function
14995 1.1 mrg
14996 1.1 mrg @item @emph{Syntax}:
14997 1.1 mrg @code{RESULT = XOR(I, J)}
14998 1.1 mrg
14999 1.1 mrg @item @emph{Arguments}:
15000 1.1 mrg @multitable @columnfractions .15 .70
15001 1.1 mrg @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
15002 1.1 mrg type or a scalar @code{LOGICAL} type or a boz-literal-constant.
15003 1.1 mrg @item @var{J} @tab The type shall be the same as the type of @var{I} or
15004 1.1 mrg a boz-literal-constant. @var{I} and @var{J} shall not both be
15005 1.1 mrg boz-literal-constants. If either @var{I} and @var{J} is a
15006 1.1 mrg boz-literal-constant, then the other argument must be a scalar @code{INTEGER}.
15007 1.1 mrg @end multitable
15008 1.1 mrg
15009 1.1 mrg @item @emph{Return value}:
15010 1.1 mrg The return type is either a scalar @code{INTEGER} or a scalar
15011 1.1 mrg @code{LOGICAL}. If the kind type parameters differ, then the
15012 1.1 mrg smaller kind type is implicitly converted to larger kind, and the
15013 1.1 mrg return has the larger kind. A boz-literal-constant is
15014 1.1 mrg converted to an @code{INTEGER} with the kind type parameter of
15015 1.1 mrg the other argument as-if a call to @ref{INT} occurred.
15016 1.1 mrg
15017 1.1 mrg @item @emph{Example}:
15018 1.1 mrg @smallexample
15019 1.1 mrg PROGRAM test_xor
15020 1.1 mrg LOGICAL :: T = .TRUE., F = .FALSE.
15021 1.1 mrg INTEGER :: a, b
15022 1.1 mrg DATA a / Z'F' /, b / Z'3' /
15023 1.1 mrg
15024 1.1 mrg WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
15025 1.1 mrg WRITE (*,*) XOR(a, b)
15026 1.1 mrg END PROGRAM
15027 1.1 mrg @end smallexample
15028 1.1 mrg
15029 1.1 mrg @item @emph{See also}:
15030 1.1.1.2 mrg Fortran 95 elemental function: @gol
15031 1.1.1.2 mrg @ref{IEOR}
15032 1.1 mrg @end table
15033 1.1 mrg
15034 1.1 mrg
15035 1.1 mrg
15036 1.1 mrg @node Intrinsic Modules
15037 1.1 mrg @chapter Intrinsic Modules
15038 1.1 mrg @cindex intrinsic Modules
15039 1.1 mrg
15040 1.1 mrg @menu
15041 1.1 mrg * ISO_FORTRAN_ENV::
15042 1.1 mrg * ISO_C_BINDING::
15043 1.1 mrg * IEEE modules::
15044 1.1 mrg * OpenMP Modules OMP_LIB and OMP_LIB_KINDS::
15045 1.1 mrg * OpenACC Module OPENACC::
15046 1.1 mrg @end menu
15047 1.1 mrg
15048 1.1 mrg @node ISO_FORTRAN_ENV
15049 1.1 mrg @section @code{ISO_FORTRAN_ENV}
15050 1.1 mrg @table @asis
15051 1.1 mrg @item @emph{Standard}:
15052 1.1 mrg Fortran 2003 and later, except when otherwise noted
15053 1.1 mrg @end table
15054 1.1 mrg
15055 1.1 mrg The @code{ISO_FORTRAN_ENV} module provides the following scalar default-integer
15056 1.1 mrg named constants:
15057 1.1 mrg
15058 1.1 mrg @table @asis
15059 1.1 mrg @item @code{ATOMIC_INT_KIND}:
15060 1.1 mrg Default-kind integer constant to be used as kind parameter when defining
15061 1.1 mrg integer variables used in atomic operations. (Fortran 2008 or later.)
15062 1.1 mrg
15063 1.1 mrg @item @code{ATOMIC_LOGICAL_KIND}:
15064 1.1 mrg Default-kind integer constant to be used as kind parameter when defining
15065 1.1 mrg logical variables used in atomic operations. (Fortran 2008 or later.)
15066 1.1 mrg
15067 1.1 mrg @item @code{CHARACTER_KINDS}:
15068 1.1 mrg Default-kind integer constant array of rank one containing the supported kind
15069 1.1 mrg parameters of the @code{CHARACTER} type. (Fortran 2008 or later.)
15070 1.1 mrg
15071 1.1 mrg @item @code{CHARACTER_STORAGE_SIZE}:
15072 1.1 mrg Size in bits of the character storage unit.
15073 1.1 mrg
15074 1.1 mrg @item @code{ERROR_UNIT}:
15075 1.1 mrg Identifies the preconnected unit used for error reporting.
15076 1.1 mrg
15077 1.1 mrg @item @code{FILE_STORAGE_SIZE}:
15078 1.1 mrg Size in bits of the file-storage unit.
15079 1.1 mrg
15080 1.1 mrg @item @code{INPUT_UNIT}:
15081 1.1 mrg Identifies the preconnected unit identified by the asterisk
15082 1.1 mrg (@code{*}) in @code{READ} statement.
15083 1.1 mrg
15084 1.1 mrg @item @code{INT8}, @code{INT16}, @code{INT32}, @code{INT64}:
15085 1.1 mrg Kind type parameters to specify an INTEGER type with a storage
15086 1.1 mrg size of 16, 32, and 64 bits. It is negative if a target platform
15087 1.1 mrg does not support the particular kind. (Fortran 2008 or later.)
15088 1.1 mrg
15089 1.1 mrg @item @code{INTEGER_KINDS}:
15090 1.1 mrg Default-kind integer constant array of rank one containing the supported kind
15091 1.1 mrg parameters of the @code{INTEGER} type. (Fortran 2008 or later.)
15092 1.1 mrg
15093 1.1 mrg @item @code{IOSTAT_END}:
15094 1.1 mrg The value assigned to the variable passed to the @code{IOSTAT=} specifier of
15095 1.1 mrg an input/output statement if an end-of-file condition occurred.
15096 1.1 mrg
15097 1.1 mrg @item @code{IOSTAT_EOR}:
15098 1.1 mrg The value assigned to the variable passed to the @code{IOSTAT=} specifier of
15099 1.1 mrg an input/output statement if an end-of-record condition occurred.
15100 1.1 mrg
15101 1.1 mrg @item @code{IOSTAT_INQUIRE_INTERNAL_UNIT}:
15102 1.1 mrg Scalar default-integer constant, used by @code{INQUIRE} for the
15103 1.1 mrg @code{IOSTAT=} specifier to denote an that a unit number identifies an
15104 1.1 mrg internal unit. (Fortran 2008 or later.)
15105 1.1 mrg
15106 1.1 mrg @item @code{NUMERIC_STORAGE_SIZE}:
15107 1.1 mrg The size in bits of the numeric storage unit.
15108 1.1 mrg
15109 1.1 mrg @item @code{LOGICAL_KINDS}:
15110 1.1 mrg Default-kind integer constant array of rank one containing the supported kind
15111 1.1 mrg parameters of the @code{LOGICAL} type. (Fortran 2008 or later.)
15112 1.1 mrg
15113 1.1 mrg @item @code{OUTPUT_UNIT}:
15114 1.1 mrg Identifies the preconnected unit identified by the asterisk
15115 1.1 mrg (@code{*}) in @code{WRITE} statement.
15116 1.1 mrg
15117 1.1 mrg @item @code{REAL32}, @code{REAL64}, @code{REAL128}:
15118 1.1 mrg Kind type parameters to specify a REAL type with a storage
15119 1.1 mrg size of 32, 64, and 128 bits. It is negative if a target platform
15120 1.1 mrg does not support the particular kind. (Fortran 2008 or later.)
15121 1.1 mrg
15122 1.1 mrg @item @code{REAL_KINDS}:
15123 1.1 mrg Default-kind integer constant array of rank one containing the supported kind
15124 1.1 mrg parameters of the @code{REAL} type. (Fortran 2008 or later.)
15125 1.1 mrg
15126 1.1 mrg @item @code{STAT_LOCKED}:
15127 1.1 mrg Scalar default-integer constant used as STAT= return value by @code{LOCK} to
15128 1.1 mrg denote that the lock variable is locked by the executing image. (Fortran 2008
15129 1.1 mrg or later.)
15130 1.1 mrg
15131 1.1 mrg @item @code{STAT_LOCKED_OTHER_IMAGE}:
15132 1.1 mrg Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
15133 1.1 mrg denote that the lock variable is locked by another image. (Fortran 2008 or
15134 1.1 mrg later.)
15135 1.1 mrg
15136 1.1 mrg @item @code{STAT_STOPPED_IMAGE}:
15137 1.1 mrg Positive, scalar default-integer constant used as STAT= return value if the
15138 1.1 mrg argument in the statement requires synchronisation with an image, which has
15139 1.1 mrg initiated the termination of the execution. (Fortran 2008 or later.)
15140 1.1 mrg
15141 1.1 mrg @item @code{STAT_FAILED_IMAGE}:
15142 1.1 mrg Positive, scalar default-integer constant used as STAT= return value if the
15143 1.1 mrg argument in the statement requires communication with an image, which has
15144 1.1 mrg is in the failed state. (TS 18508 or later.)
15145 1.1 mrg
15146 1.1 mrg @item @code{STAT_UNLOCKED}:
15147 1.1 mrg Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
15148 1.1 mrg denote that the lock variable is unlocked. (Fortran 2008 or later.)
15149 1.1 mrg @end table
15150 1.1 mrg
15151 1.1 mrg The module provides the following derived type:
15152 1.1 mrg
15153 1.1 mrg @table @asis
15154 1.1 mrg @item @code{LOCK_TYPE}:
15155 1.1 mrg Derived type with private components to be use with the @code{LOCK} and
15156 1.1 mrg @code{UNLOCK} statement. A variable of its type has to be always declared
15157 1.1 mrg as coarray and may not appear in a variable-definition context.
15158 1.1 mrg (Fortran 2008 or later.)
15159 1.1 mrg @end table
15160 1.1 mrg
15161 1.1 mrg The module also provides the following intrinsic procedures:
15162 1.1 mrg @ref{COMPILER_OPTIONS} and @ref{COMPILER_VERSION}.
15163 1.1 mrg
15164 1.1 mrg
15165 1.1 mrg
15166 1.1 mrg @node ISO_C_BINDING
15167 1.1 mrg @section @code{ISO_C_BINDING}
15168 1.1 mrg @table @asis
15169 1.1 mrg @item @emph{Standard}:
15170 1.1 mrg Fortran 2003 and later, GNU extensions
15171 1.1 mrg @end table
15172 1.1 mrg
15173 1.1 mrg The following intrinsic procedures are provided by the module; their
15174 1.1 mrg definition can be found in the section Intrinsic Procedures of this
15175 1.1 mrg manual.
15176 1.1 mrg
15177 1.1 mrg @table @asis
15178 1.1 mrg @item @code{C_ASSOCIATED}
15179 1.1 mrg @item @code{C_F_POINTER}
15180 1.1 mrg @item @code{C_F_PROCPOINTER}
15181 1.1 mrg @item @code{C_FUNLOC}
15182 1.1 mrg @item @code{C_LOC}
15183 1.1 mrg @item @code{C_SIZEOF}
15184 1.1 mrg @end table
15185 1.1 mrg @c TODO: Vertical spacing between C_FUNLOC and C_LOC wrong in PDF,
15186 1.1 mrg @c don't really know why.
15187 1.1 mrg
15188 1.1 mrg The @code{ISO_C_BINDING} module provides the following named constants of
15189 1.1 mrg type default integer, which can be used as KIND type parameters.
15190 1.1 mrg
15191 1.1 mrg In addition to the integer named constants required by the Fortran 2003
15192 1.1 mrg standard and @code{C_PTRDIFF_T} of TS 29113, GNU Fortran provides as an
15193 1.1 mrg extension named constants for the 128-bit integer types supported by the
15194 1.1 mrg C compiler: @code{C_INT128_T, C_INT_LEAST128_T, C_INT_FAST128_T}.
15195 1.1 mrg Furthermore, if @code{__float128} is supported in C, the named constants
15196 1.1 mrg @code{C_FLOAT128, C_FLOAT128_COMPLEX} are defined.
15197 1.1 mrg
15198 1.1 mrg @multitable @columnfractions .15 .35 .35 .35
15199 1.1 mrg @item Fortran Type @tab Named constant @tab C type @tab Extension
15200 1.1 mrg @item @code{INTEGER}@tab @code{C_INT} @tab @code{int}
15201 1.1 mrg @item @code{INTEGER}@tab @code{C_SHORT} @tab @code{short int}
15202 1.1 mrg @item @code{INTEGER}@tab @code{C_LONG} @tab @code{long int}
15203 1.1 mrg @item @code{INTEGER}@tab @code{C_LONG_LONG} @tab @code{long long int}
15204 1.1 mrg @item @code{INTEGER}@tab @code{C_SIGNED_CHAR} @tab @code{signed char}/@code{unsigned char}
15205 1.1 mrg @item @code{INTEGER}@tab @code{C_SIZE_T} @tab @code{size_t}
15206 1.1 mrg @item @code{INTEGER}@tab @code{C_INT8_T} @tab @code{int8_t}
15207 1.1 mrg @item @code{INTEGER}@tab @code{C_INT16_T} @tab @code{int16_t}
15208 1.1 mrg @item @code{INTEGER}@tab @code{C_INT32_T} @tab @code{int32_t}
15209 1.1 mrg @item @code{INTEGER}@tab @code{C_INT64_T} @tab @code{int64_t}
15210 1.1 mrg @item @code{INTEGER}@tab @code{C_INT128_T} @tab @code{int128_t} @tab Ext.
15211 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_LEAST8_T} @tab @code{int_least8_t}
15212 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t}
15213 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t}
15214 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t}
15215 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_LEAST128_T}@tab @code{int_least128_t} @tab Ext.
15216 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_FAST8_T} @tab @code{int_fast8_t}
15217 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_FAST16_T} @tab @code{int_fast16_t}
15218 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_FAST32_T} @tab @code{int_fast32_t}
15219 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_FAST64_T} @tab @code{int_fast64_t}
15220 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_FAST128_T} @tab @code{int_fast128_t} @tab Ext.
15221 1.1 mrg @item @code{INTEGER}@tab @code{C_INTMAX_T} @tab @code{intmax_t}
15222 1.1 mrg @item @code{INTEGER}@tab @code{C_INTPTR_T} @tab @code{intptr_t}
15223 1.1 mrg @item @code{INTEGER}@tab @code{C_PTRDIFF_T} @tab @code{ptrdiff_t} @tab TS 29113
15224 1.1 mrg @item @code{REAL} @tab @code{C_FLOAT} @tab @code{float}
15225 1.1 mrg @item @code{REAL} @tab @code{C_DOUBLE} @tab @code{double}
15226 1.1 mrg @item @code{REAL} @tab @code{C_LONG_DOUBLE} @tab @code{long double}
15227 1.1 mrg @item @code{REAL} @tab @code{C_FLOAT128} @tab @code{__float128} @tab Ext.
15228 1.1 mrg @item @code{COMPLEX}@tab @code{C_FLOAT_COMPLEX} @tab @code{float _Complex}
15229 1.1 mrg @item @code{COMPLEX}@tab @code{C_DOUBLE_COMPLEX}@tab @code{double _Complex}
15230 1.1 mrg @item @code{COMPLEX}@tab @code{C_LONG_DOUBLE_COMPLEX}@tab @code{long double _Complex}
15231 1.1 mrg @item @code{REAL} @tab @code{C_FLOAT128_COMPLEX} @tab @code{__float128 _Complex} @tab Ext.
15232 1.1 mrg @item @code{LOGICAL}@tab @code{C_BOOL} @tab @code{_Bool}
15233 1.1 mrg @item @code{CHARACTER}@tab @code{C_CHAR} @tab @code{char}
15234 1.1 mrg @end multitable
15235 1.1 mrg
15236 1.1 mrg Additionally, the following parameters of type @code{CHARACTER(KIND=C_CHAR)}
15237 1.1 mrg are defined.
15238 1.1 mrg
15239 1.1 mrg @multitable @columnfractions .20 .45 .15
15240 1.1 mrg @item Name @tab C definition @tab Value
15241 1.1 mrg @item @code{C_NULL_CHAR} @tab null character @tab @code{'\0'}
15242 1.1 mrg @item @code{C_ALERT} @tab alert @tab @code{'\a'}
15243 1.1 mrg @item @code{C_BACKSPACE} @tab backspace @tab @code{'\b'}
15244 1.1 mrg @item @code{C_FORM_FEED} @tab form feed @tab @code{'\f'}
15245 1.1 mrg @item @code{C_NEW_LINE} @tab new line @tab @code{'\n'}
15246 1.1 mrg @item @code{C_CARRIAGE_RETURN} @tab carriage return @tab @code{'\r'}
15247 1.1 mrg @item @code{C_HORIZONTAL_TAB} @tab horizontal tab @tab @code{'\t'}
15248 1.1 mrg @item @code{C_VERTICAL_TAB} @tab vertical tab @tab @code{'\v'}
15249 1.1 mrg @end multitable
15250 1.1 mrg
15251 1.1 mrg Moreover, the following two named constants are defined:
15252 1.1 mrg
15253 1.1 mrg @multitable @columnfractions .20 .80
15254 1.1 mrg @item Name @tab Type
15255 1.1 mrg @item @code{C_NULL_PTR} @tab @code{C_PTR}
15256 1.1 mrg @item @code{C_NULL_FUNPTR} @tab @code{C_FUNPTR}
15257 1.1 mrg @end multitable
15258 1.1 mrg
15259 1.1 mrg Both are equivalent to the value @code{NULL} in C.
15260 1.1 mrg
15261 1.1 mrg
15262 1.1 mrg
15263 1.1 mrg @node IEEE modules
15264 1.1 mrg @section IEEE modules: @code{IEEE_EXCEPTIONS}, @code{IEEE_ARITHMETIC}, and @code{IEEE_FEATURES}
15265 1.1 mrg @table @asis
15266 1.1 mrg @item @emph{Standard}:
15267 1.1 mrg Fortran 2003 and later
15268 1.1 mrg @end table
15269 1.1 mrg
15270 1.1 mrg The @code{IEEE_EXCEPTIONS}, @code{IEEE_ARITHMETIC}, and @code{IEEE_FEATURES}
15271 1.1 mrg intrinsic modules provide support for exceptions and IEEE arithmetic, as
15272 1.1 mrg defined in Fortran 2003 and later standards, and the IEC 60559:1989 standard
15273 1.1 mrg (@emph{Binary floating-point arithmetic for microprocessor systems}). These
15274 1.1 mrg modules are only provided on the following supported platforms:
15275 1.1 mrg
15276 1.1 mrg @itemize @bullet
15277 1.1 mrg @item i386 and x86_64 processors
15278 1.1 mrg @item platforms which use the GNU C Library (glibc)
15279 1.1 mrg @item platforms with support for SysV/386 routines for floating point
15280 1.1 mrg interface (including Solaris and BSDs)
15281 1.1 mrg @item platforms with the AIX OS
15282 1.1 mrg @end itemize
15283 1.1 mrg
15284 1.1 mrg For full compliance with the Fortran standards, code using the
15285 1.1 mrg @code{IEEE_EXCEPTIONS} or @code{IEEE_ARITHMETIC} modules should be compiled
15286 1.1 mrg with the following options: @code{-fno-unsafe-math-optimizations
15287 1.1 mrg -frounding-math -fsignaling-nans}.
15288 1.1 mrg
15289 1.1 mrg
15290 1.1 mrg
15291 1.1 mrg @node OpenMP Modules OMP_LIB and OMP_LIB_KINDS
15292 1.1 mrg @section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS}
15293 1.1 mrg @table @asis
15294 1.1 mrg @item @emph{Standard}:
15295 1.1 mrg OpenMP Application Program Interface v4.5
15296 1.1 mrg @end table
15297 1.1 mrg
15298 1.1 mrg
15299 1.1 mrg The OpenMP Fortran runtime library routines are provided both in
15300 1.1 mrg a form of two Fortran 90 modules, named @code{OMP_LIB} and
15301 1.1 mrg @code{OMP_LIB_KINDS}, and in a form of a Fortran @code{include} file named
15302 1.1 mrg @file{omp_lib.h}. The procedures provided by @code{OMP_LIB} can be found
15303 1.1 mrg in the @ref{Top,,Introduction,libgomp,GNU Offloading and Multi
15304 1.1 mrg Processing Runtime Library} manual,
15305 1.1 mrg the named constants defined in the modules are listed
15306 1.1 mrg below.
15307 1.1 mrg
15308 1.1 mrg For details refer to the actual
15309 1.1 mrg @uref{http://www.openmp.org/wp-content/uploads/openmp-4.5.pdf,
15310 1.1 mrg OpenMP Application Program Interface v4.5}.
15311 1.1 mrg And for the @code{pause}-related constants to the OpenMP 5.0 specification.
15312 1.1 mrg
15313 1.1 mrg @code{OMP_LIB_KINDS} provides the following scalar default-integer
15314 1.1 mrg named constants:
15315 1.1 mrg
15316 1.1 mrg @table @asis
15317 1.1 mrg @item @code{omp_lock_kind}
15318 1.1 mrg @item @code{omp_lock_hint_kind}
15319 1.1 mrg @item @code{omp_nest_lock_kind}
15320 1.1 mrg @item @code{omp_pause_resource_kind}
15321 1.1 mrg @item @code{omp_proc_bind_kind}
15322 1.1 mrg @item @code{omp_sched_kind}
15323 1.1 mrg @end table
15324 1.1 mrg
15325 1.1 mrg @code{OMP_LIB} provides the scalar default-integer
15326 1.1 mrg named constant @code{openmp_version} with a value of the form
15327 1.1 mrg @var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month
15328 1.1 mrg of the OpenMP version; for OpenMP v4.5 the value is @code{201511}.
15329 1.1 mrg
15330 1.1 mrg The following scalar integer named constants of the
15331 1.1 mrg kind @code{omp_sched_kind}:
15332 1.1 mrg
15333 1.1 mrg @table @asis
15334 1.1 mrg @item @code{omp_sched_static}
15335 1.1 mrg @item @code{omp_sched_dynamic}
15336 1.1 mrg @item @code{omp_sched_guided}
15337 1.1 mrg @item @code{omp_sched_auto}
15338 1.1 mrg @end table
15339 1.1 mrg
15340 1.1 mrg And the following scalar integer named constants of the
15341 1.1 mrg kind @code{omp_proc_bind_kind}:
15342 1.1 mrg
15343 1.1 mrg @table @asis
15344 1.1 mrg @item @code{omp_proc_bind_false}
15345 1.1 mrg @item @code{omp_proc_bind_true}
15346 1.1 mrg @item @code{omp_proc_bind_master}
15347 1.1 mrg @item @code{omp_proc_bind_close}
15348 1.1 mrg @item @code{omp_proc_bind_spread}
15349 1.1 mrg @end table
15350 1.1 mrg
15351 1.1 mrg The following scalar integer named constants are of the
15352 1.1 mrg kind @code{omp_lock_hint_kind}:
15353 1.1 mrg
15354 1.1 mrg @table @asis
15355 1.1 mrg @item @code{omp_lock_hint_none}
15356 1.1 mrg @item @code{omp_lock_hint_uncontended}
15357 1.1 mrg @item @code{omp_lock_hint_contended}
15358 1.1 mrg @item @code{omp_lock_hint_nonspeculative}
15359 1.1 mrg @item @code{omp_lock_hint_speculative}
15360 1.1 mrg @end table
15361 1.1 mrg
15362 1.1 mrg And the following two scalar integer named constants are of the
15363 1.1 mrg kind @code{omp_pause_resource_kind}:
15364 1.1 mrg
15365 1.1 mrg @table @asis
15366 1.1 mrg @item @code{omp_pause_soft}
15367 1.1 mrg @item @code{omp_pause_hard}
15368 1.1 mrg @end table
15369 1.1 mrg
15370 1.1 mrg
15371 1.1 mrg @node OpenACC Module OPENACC
15372 1.1 mrg @section OpenACC Module @code{OPENACC}
15373 1.1 mrg @table @asis
15374 1.1 mrg @item @emph{Standard}:
15375 1.1.1.2 mrg OpenACC Application Programming Interface v2.6
15376 1.1 mrg @end table
15377 1.1 mrg
15378 1.1 mrg
15379 1.1 mrg The OpenACC Fortran runtime library routines are provided both in a
15380 1.1 mrg form of a Fortran 90 module, named @code{OPENACC}, and in form of a
15381 1.1 mrg Fortran @code{include} file named @file{openacc_lib.h}. The
15382 1.1 mrg procedures provided by @code{OPENACC} can be found in the
15383 1.1 mrg @ref{Top,,Introduction,libgomp,GNU Offloading and Multi Processing
15384 1.1 mrg Runtime Library} manual, the named constants defined in the modules
15385 1.1 mrg are listed below.
15386 1.1 mrg
15387 1.1 mrg For details refer to the actual
15388 1.1 mrg @uref{http://www.openacc.org/,
15389 1.1.1.2 mrg OpenACC Application Programming Interface v2.6}.
15390 1.1 mrg
15391 1.1 mrg @code{OPENACC} provides the scalar default-integer
15392 1.1 mrg named constant @code{openacc_version} with a value of the form
15393 1.1 mrg @var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month
15394 1.1.1.2 mrg of the OpenACC version; for OpenACC v2.6 the value is @code{201711}.
15395